From 21ec7679651a334abcf3efee6b6e934d9f54c51a Mon Sep 17 00:00:00 2001 From: Marco Castelluccio Date: Tue, 21 Nov 2023 12:38:45 +0000 Subject: [PATCH] Backed out changeset 26b001cb3993 (bug 1854045) for build bustages . CLOSED TREE UltraBlame original commit: b9fe9a49496aa38ca77c335f20236610ef01a582 --- Cargo.lock | 91 +- supply-chain/audits.toml | 47 - supply-chain/imports.lock | 186 - .../rust/aho-corasick/.cargo-checksum.json | 231 +- third_party/rust/aho-corasick/Cargo.toml | 131 +- third_party/rust/aho-corasick/DESIGN.md | 605 +- third_party/rust/aho-corasick/README.md | 228 +- .../rust/aho-corasick/src/ahocorasick.rs | 32939 +++----- .../rust/aho-corasick/src/automaton.rs | 16985 +---- .../aho-corasick/src/{util => }/buffer.rs | 308 +- .../src/{util => }/byte_frequencies.rs | 0 .../src/{util/alphabet.rs => classes.rs} | 3397 +- third_party/rust/aho-corasick/src/dfa.rs | 8543 +-- third_party/rust/aho-corasick/src/error.rs | 615 + third_party/rust/aho-corasick/src/lib.rs | 1949 +- third_party/rust/aho-corasick/src/macros.rs | 106 - .../src/{nfa/contiguous.rs => nfa.rs} | 16219 ++-- third_party/rust/aho-corasick/src/nfa/mod.rs | 419 - .../rust/aho-corasick/src/packed/api.rs | 1120 +- .../rust/aho-corasick/src/packed/ext.rs | 310 - .../rust/aho-corasick/src/packed/mod.rs | 159 +- .../rust/aho-corasick/src/packed/pattern.rs | 3287 +- .../rust/aho-corasick/src/packed/rabinkarp.rs | 267 +- .../aho-corasick/src/packed/teddy/README.md | 6 +- .../aho-corasick/src/packed/teddy/builder.rs | 6039 -- .../aho-corasick/src/packed/teddy/compile.rs | 3663 + .../rust/aho-corasick/src/packed/teddy/mod.rs | 396 +- .../packed/teddy/{generic.rs => runtime.rs} | 16462 ++-- .../rust/aho-corasick/src/packed/tests.rs | 571 +- .../rust/aho-corasick/src/packed/vector.rs | 13384 +--- .../aho-corasick/src/{util => }/prefilter.rs | 7359 +- third_party/rust/aho-corasick/src/state_id.rs | 1207 + third_party/rust/aho-corasick/src/tests.rs | 4504 +- .../rust/aho-corasick/src/transducer.rs | 2355 - .../rust/aho-corasick/src/util/debug.rs | 278 - .../rust/aho-corasick/src/util/error.rs | 1839 - third_party/rust/aho-corasick/src/util/int.rs | 1476 - third_party/rust/aho-corasick/src/util/mod.rs | 88 - .../rust/aho-corasick/src/util/primitives.rs | 6005 -- .../rust/aho-corasick/src/util/remapper.rs | 2201 - .../rust/aho-corasick/src/util/search.rs | 10584 --- .../rust/aho-corasick/src/util/special.rs | 394 - .../rust/regex-automata/.cargo-checksum.json | 1656 - third_party/rust/regex-automata/Cargo.toml | 991 - .../rust/regex-automata/LICENSE-APACHE | 1794 - third_party/rust/regex-automata/README.md | 1310 - .../rust/regex-automata/src/dfa/accel.rs | 4941 -- .../rust/regex-automata/src/dfa/automaton.rs | 23149 ------ .../rust/regex-automata/src/dfa/dense.rs | 50847 ------------- .../regex-automata/src/dfa/determinize.rs | 5266 -- .../rust/regex-automata/src/dfa/minimize.rs | 3890 - .../rust/regex-automata/src/dfa/mod.rs | 3910 - .../rust/regex-automata/src/dfa/onepass.rs | 32484 -------- .../rust/regex-automata/src/dfa/regex.rs | 9072 --- .../rust/regex-automata/src/dfa/remapper.rs | 2311 - .../rust/regex-automata/src/dfa/search.rs | 5247 -- .../rust/regex-automata/src/dfa/sparse.rs | 24517 ------ .../rust/regex-automata/src/dfa/special.rs | 4732 -- .../rust/regex-automata/src/dfa/start.rs | 626 - .../rust/regex-automata/src/hybrid/dfa.rs | 44818 ----------- .../rust/regex-automata/src/hybrid/error.rs | 1092 - .../rust/regex-automata/src/hybrid/id.rs | 3706 - .../rust/regex-automata/src/hybrid/mod.rs | 1386 - .../rust/regex-automata/src/hybrid/regex.rs | 9158 --- .../rust/regex-automata/src/hybrid/search.rs | 6803 -- third_party/rust/regex-automata/src/lib.rs | 6950 -- third_party/rust/regex-automata/src/macros.rs | 132 - .../rust/regex-automata/src/meta/error.rs | 2079 - .../rust/regex-automata/src/meta/limited.rs | 2446 - .../rust/regex-automata/src/meta/literal.rs | 782 - .../rust/regex-automata/src/meta/mod.rs | 542 - .../rust/regex-automata/src/meta/regex.rs | 39751 ---------- .../regex-automata/src/meta/reverse_inner.rs | 2210 - .../rust/regex-automata/src/meta/stopat.rs | 2144 - .../rust/regex-automata/src/meta/strategy.rs | 15745 ---- .../rust/regex-automata/src/meta/wrappers.rs | 9632 --- .../rust/regex-automata/src/nfa/mod.rs | 625 - .../src/nfa/thompson/backtrack.rs | 18951 ----- .../src/nfa/thompson/builder.rs | 13618 ---- .../src/nfa/thompson/compiler.rs | 20189 ----- .../regex-automata/src/nfa/thompson/error.rs | 1450 - .../src/nfa/thompson/literal_trie.rs | 5232 -- .../regex-automata/src/nfa/thompson/map.rs | 2789 - .../regex-automata/src/nfa/thompson/mod.rs | 832 - .../regex-automata/src/nfa/thompson/nfa.rs | 21598 ------ .../regex-automata/src/nfa/thompson/pikevm.rs | 24122 ------ .../src/nfa/thompson/range_trie.rs | 10597 --- .../rust/regex-automata/src/util/alphabet.rs | 10518 --- .../rust/regex-automata/src/util/captures.rs | 27733 ------- .../src/util/determinize/mod.rs | 5644 -- .../src/util/determinize/state.rs | 8205 -- .../rust/regex-automata/src/util/empty.rs | 3001 - .../rust/regex-automata/src/util/escape.rs | 797 - .../rust/regex-automata/src/util/int.rs | 1494 - .../regex-automata/src/util/interpolate.rs | 4331 -- .../rust/regex-automata/src/util/iter.rs | 10124 --- .../rust/regex-automata/src/util/lazy.rs | 4452 -- .../rust/regex-automata/src/util/look.rs | 16152 ---- .../rust/regex-automata/src/util/memchr.rs | 836 - .../rust/regex-automata/src/util/mod.rs | 449 - .../rust/regex-automata/src/util/pool.rs | 10318 --- .../src/util/prefilter/aho_corasick.rs | 1269 - .../src/util/prefilter/byteset.rs | 371 - .../src/util/prefilter/memchr.rs | 1194 - .../src/util/prefilter/memmem.rs | 663 - .../regex-automata/src/util/prefilter/mod.rs | 6623 -- .../src/util/prefilter/teddy.rs | 1464 - .../regex-automata/src/util/primitives.rs | 6255 -- .../rust/regex-automata/src/util/search.rs | 18998 ----- .../regex-automata/src/util/sparse_set.rs | 2012 - .../rust/regex-automata/src/util/start.rs | 2789 - .../src/util/unicode_data/mod.rs | 174 - .../src/util/unicode_data/perl_word.rs | 6206 -- .../rust/regex-automata/src/util/utf8.rs | 1924 - .../rust/regex-automata/src/util/wire.rs | 8615 --- third_party/rust/regex-automata/test | 894 - .../rust/regex-automata/tests/dfa/api.rs | 587 - .../rust/regex-automata/tests/dfa/mod.rs | 98 - .../regex-automata/tests/dfa/onepass/mod.rs | 13 - .../regex-automata/tests/dfa/onepass/suite.rs | 1613 - .../regex-automata/tests/dfa/regression.rs | 376 - .../rust/regex-automata/tests/dfa/suite.rs | 3890 - .../rust/regex-automata/tests/fuzz/dense.rs | 488 - .../rust/regex-automata/tests/fuzz/mod.rs | 6 - .../rust/regex-automata/tests/fuzz/sparse.rs | 1245 - ...h-9486fb7c8a93b12c12a62166b43d31640c0208a9 | 0 ...m-9486fb7c8a93b12c12a62166b43d31640c0208a9 | 0 ...h-0da59c0434eaf35e5a6b470fa9244bb79c72b000 | 0 ...h-18cfc246f2ddfc3dfc92b0c7893178c7cf65efa9 | 0 ...h-61fd8e3003bf9d99f6c1e5a8488727eefd234b98 | 0 ...h-a1b839d899ced76d5d7d0f78f9edb7a421505838 | 0 ...h-c383ae07ec5e191422eadc492117439011816570 | 0 ...h-d07703ceb94b10dcd9e4acb809f2051420449e2b | 0 ...h-dbb8172d3984e7e7d03f4b5f8bb86ecd1460eff9 | 0 .../rust/regex-automata/tests/gen/README.md | 522 - .../regex-automata/tests/gen/dense/mod.rs | 345 - .../tests/gen/dense/multi_pattern_v2.rs | 395 - .../dense/multi_pattern_v2_fwd.bigendian.dfa | 0 .../multi_pattern_v2_fwd.littleendian.dfa | 0 .../dense/multi_pattern_v2_rev.bigendian.dfa | 0 .../multi_pattern_v2_rev.littleendian.dfa | 0 .../rust/regex-automata/tests/gen/mod.rs | 6 - .../regex-automata/tests/gen/sparse/mod.rs | 345 - .../tests/gen/sparse/multi_pattern_v2.rs | 377 - .../sparse/multi_pattern_v2_fwd.bigendian.dfa | 0 .../multi_pattern_v2_fwd.littleendian.dfa | 0 .../sparse/multi_pattern_v2_rev.bigendian.dfa | 0 .../multi_pattern_v2_rev.littleendian.dfa | 0 .../rust/regex-automata/tests/hybrid/api.rs | 1533 - .../rust/regex-automata/tests/hybrid/mod.rs | 16 - .../rust/regex-automata/tests/hybrid/suite.rs | 3143 - third_party/rust/regex-automata/tests/lib.rs | 970 - .../rust/regex-automata/tests/meta/mod.rs | 13 - .../rust/regex-automata/tests/meta/suite.rs | 1681 - .../rust/regex-automata/tests/nfa/mod.rs | 3 - .../tests/nfa/thompson/backtrack/mod.rs | 13 - .../tests/nfa/thompson/backtrack/suite.rs | 1805 - .../regex-automata/tests/nfa/thompson/mod.rs | 32 - .../tests/nfa/thompson/pikevm/mod.rs | 13 - .../tests/nfa/thompson/pikevm/suite.rs | 1316 - .../rust/regex-syntax/.cargo-checksum.json | 62 +- third_party/rust/regex-syntax/Cargo.toml | 120 +- third_party/rust/regex-syntax/README.md | 99 +- third_party/rust/regex-syntax/src/ast/mod.rs | 7550 +- .../rust/regex-syntax/src/ast/parse.rs | 2231 +- .../rust/regex-syntax/src/ast/print.rs | 154 +- .../rust/regex-syntax/src/ast/visitor.rs | 211 +- third_party/rust/regex-syntax/src/debug.rs | 1012 - third_party/rust/regex-syntax/src/error.rs | 298 +- .../rust/regex-syntax/src/hir/interval.rs | 787 +- .../rust/regex-syntax/src/hir/literal.rs | 30817 -------- .../rust/regex-syntax/src/hir/literal/mod.rs | 15256 ++++ third_party/rust/regex-syntax/src/hir/mod.rs | 32066 +++----- .../rust/regex-syntax/src/hir/print.rs | 3063 +- .../rust/regex-syntax/src/hir/translate.rs | 28367 +++---- .../rust/regex-syntax/src/hir/visitor.rs | 122 +- third_party/rust/regex-syntax/src/lib.rs | 1824 +- third_party/rust/regex-syntax/src/parser.rs | 862 +- third_party/rust/regex-syntax/src/unicode.rs | 2094 +- third_party/rust/regex-syntax/src/utf8.rs | 172 +- third_party/rust/regex-syntax/test | 92 +- third_party/rust/regex/.cargo-checksum.json | 2300 +- third_party/rust/regex/CHANGELOG.md | 4234 -- third_party/rust/regex/Cargo.lock | 638 + third_party/rust/regex/Cargo.toml | 575 +- third_party/rust/regex/Cross.toml | 21 - third_party/rust/regex/PERFORMANCE.md | 2732 + third_party/rust/regex/README.md | 794 +- third_party/rust/regex/UNICODE.md | 78 +- .../rust/regex/examples/regexdna-input.txt | 1683 + .../rust/regex/examples/regexdna-output.txt | 99 + .../examples/shootout-regex-dna-bytes.rs | 785 + .../examples/shootout-regex-dna-cheat.rs | 922 + .../examples/shootout-regex-dna-replace.rs | 163 + .../shootout-regex-dna-single-cheat.rs | 762 + .../examples/shootout-regex-dna-single.rs | 616 + .../rust/regex/examples/shootout-regex-dna.rs | 710 + third_party/rust/regex/record/README.md | 46 - .../record/compile-test/2023-04-19_1.7.3.csv | 107 - .../record/compile-test/2023-04-20_master.csv | 107 - .../regex/record/compile-test/2023-07-05.csv | 461 - .../rust/regex/record/compile-test/README.md | 226 - .../record/old-bench-log/01-lazy-dfa/dynamic | 1747 - .../01-lazy-dfa/dynamic-no-lazy-dfa | 1977 - .../record/old-bench-log/01-lazy-dfa/native | 1614 - .../record/old-bench-log/01-lazy-dfa/nfa | 1778 - .../record/old-bench-log/01-lazy-dfa/pcre | 1364 - .../regex/record/old-bench-log/02-set/dynamic | 1883 - .../regex/record/old-bench-log/03-bytes/onig | 1687 - .../regex/record/old-bench-log/03-bytes/pcre | 1623 - .../regex/record/old-bench-log/03-bytes/rust | 2024 - .../record/old-bench-log/03-bytes/rust-bytes | 1620 - .../rust/regex/record/old-bench-log/04/onig | 1958 - .../regex/record/old-bench-log/04/pcre1-jit | 1919 - .../regex/record/old-bench-log/04/pcre2-jit | 1904 - .../rust/regex/record/old-bench-log/04/re2 | 1972 - .../rust/regex/record/old-bench-log/04/rust | 1995 - .../rust/regex/record/old-bench-log/04/tcl | 1812 - .../rust/regex/record/old-bench-log/05/onig | 2591 - .../record/old-bench-log/05/onig-vs-rust | 2709 - .../rust/regex/record/old-bench-log/05/pcre1 | 2514 - .../record/old-bench-log/05/pcre1-vs-rust | 2587 - .../rust/regex/record/old-bench-log/05/pcre2 | 2507 - .../record/old-bench-log/05/pcre2-vs-rust | 2566 - .../rust/regex/record/old-bench-log/05/re2 | 2621 - .../regex/record/old-bench-log/05/re2-vs-rust | 2729 - .../rust/regex/record/old-bench-log/05/rust | 2607 - .../rust/regex/record/old-bench-log/05/tcl | 2464 - .../regex/record/old-bench-log/05/tcl-vs-rust | 2587 - .../regex/record/old-bench-log/06/dphobos-dmd | 2597 - .../record/old-bench-log/06/dphobos-dmd-ct | 2566 - .../regex/record/old-bench-log/06/dphobos-ldc | 2587 - .../record/old-bench-log/06/dphobos-ldc-ct | 2563 - .../rust/regex/record/old-bench-log/06/pcre1 | 2523 - .../rust/regex/record/old-bench-log/06/pcre2 | 2511 - .../rust/regex/record/old-bench-log/06/re2 | 2622 - .../rust/regex/record/old-bench-log/06/rust | 2872 - .../rust/regex/record/old-bench-log/07/boost | 2502 - .../regex/record/old-bench-log/07/dphobos-dmd | 2575 - .../record/old-bench-log/07/dphobos-dmd-ct | 2515 - .../regex/record/old-bench-log/07/oniguruma | 2568 - .../rust/regex/record/old-bench-log/07/pcre1 | 2514 - .../rust/regex/record/old-bench-log/07/pcre2 | 2488 - .../rust/regex/record/old-bench-log/07/re2 | 2598 - .../rust/regex/record/old-bench-log/07/rust | 2850 - .../regex/record/old-bench-log/07/rust-bytes | 2551 - .../rust/regex/record/old-bench-log/07/stdcpp | 2259 - .../record/old-bench-log/07/stdcpp-libcxx | 2253 - .../rust/regex/record/old-bench-log/07/tcl | 2445 - .../old-bench-log/08-new-memmem/rust-after-01 | 3122 - .../old-bench-log/08-new-memmem/rust-after-02 | 3123 - .../08-new-memmem/rust-before-01 | 3123 - .../08-new-memmem/rust-before-02 | 3121 - .../old-bench-log/09-new-baseline/pcre2 | 2494 - .../record/old-bench-log/09-new-baseline/re2 | 2572 - .../record/old-bench-log/09-new-baseline/rust | 3103 - .../old-bench-log/09-new-baseline/rust-bytes | 2803 - .../10-last-frontier/rust-after-literal.log | 3110 - .../10-last-frontier/rust-before-literal.log | 3112 - .../rust-bytes-after-literal.log | 2815 - .../rust-bytes-before-literal.log | 2815 - .../record/old-bench-log/11-regex-1.7.3/rust | 3103 - .../old-bench-log/11-regex-1.7.3/rust-bytes | 2803 - .../record/old-bench-log/12-regex-1.8.1/rust | 3096 - .../old-bench-log/12-regex-1.8.1/rust-bytes | 2799 - .../record/old-bench-log/13-regex-1.9.0/rust | 2892 - .../old-bench-log/13-regex-1.9.0/rust-bytes | 2595 - .../rust/regex/record/old-bench-log/README.md | 104 - .../regex/record/old-bench-log/old/01-before | 620 - .../old-bench-log/old/02-new-syntax-crate | 620 - .../old-bench-log/old/03-new-syntax-crate | 620 - .../old-bench-log/old/04-fixed-benchmark | 645 - .../old-bench-log/old/05-thread-caching | 640 - .../record/old-bench-log/old/06-major-dynamic | 768 - .../record/old-bench-log/old/06-major-macro | 779 - .../old-bench-log/old/07-prefix-improvements | 764 - .../record/old-bench-log/old/08-case-fixes | 764 - .../old/09-before-compiler-rewrite | 764 - .../old-bench-log/old/10-compiler-rewrite | 763 - .../old-bench-log/old/11-compiler-rewrite | 766 - .../record/old-bench-log/old/12-executor | 805 - .../old-bench-log/old/12-executor-bytes | 808 - .../old/13-cache-byte-range-suffixes | 809 - third_party/rust/regex/src/backtrack.rs | 2298 + third_party/rust/regex/src/builders.rs | 25034 ------ third_party/rust/regex/src/bytes.rs | 972 - third_party/rust/regex/src/compile.rs | 10089 +++ .../nfa/noncontiguous.rs => regex/src/dfa.rs} | 25499 ++++--- third_party/rust/regex/src/error.rs | 589 +- third_party/rust/regex/src/exec.rs | 12111 +++ third_party/rust/regex/src/expand.rs | 1931 + third_party/rust/regex/src/find_byte.rs | 6 +- .../src/rank.rs => regex/src/freqs.rs} | 26 +- third_party/rust/regex/src/input.rs | 3100 + third_party/rust/regex/src/lib.rs | 18562 ++--- third_party/rust/regex/src/literal/imp.rs | 3040 + third_party/rust/regex/src/literal/mod.rs | 272 + third_party/rust/regex/src/pattern.rs | 5 +- third_party/rust/regex/src/pikevm.rs | 2578 + third_party/rust/regex/src/pool.rs | 3628 + third_party/rust/regex/src/prog.rs | 3489 + .../syntax.rs => regex/src/re_builder.rs} | 5700 +- third_party/rust/regex/src/re_bytes.rs | 12094 +++ .../src/{regexset/string.rs => re_set.rs} | 7394 +- third_party/rust/regex/src/re_trait.rs | 2171 + third_party/rust/regex/src/re_unicode.rs | 12297 +++ third_party/rust/regex/src/regex/bytes.rs | 28334 ------- third_party/rust/regex/src/regex/mod.rs | 14 - third_party/rust/regex/src/regex/string.rs | 27011 ------- third_party/rust/regex/src/regexset/bytes.rs | 6845 -- third_party/rust/regex/src/regexset/mod.rs | 14 - third_party/rust/regex/src/sparse.rs | 593 + .../src/testdata/LICENSE} | 159 +- third_party/rust/regex/src/testdata/README | 165 + .../fowler/dat => src/testdata}/basic.dat | 690 +- .../dat => src/testdata}/nullsubexpr.dat | 114 +- .../dat => src/testdata}/repetition.dat | 220 - third_party/rust/regex/src/utf8.rs | 2076 + third_party/rust/regex/test | 189 +- third_party/rust/regex/testdata/README.md | 244 - third_party/rust/regex/testdata/anchored.toml | 902 - third_party/rust/regex/testdata/bytes.toml | 1483 - third_party/rust/regex/testdata/crazy.toml | 2675 - third_party/rust/regex/testdata/crlf.toml | 1175 - third_party/rust/regex/testdata/earliest.toml | 324 - third_party/rust/regex/testdata/empty.toml | 765 - .../rust/regex/testdata/expensive.toml | 256 - third_party/rust/regex/testdata/flags.toml | 432 - .../rust/regex/testdata/fowler/basic.toml | 12846 ---- .../rust/regex/testdata/fowler/dat/README | 243 - .../regex/testdata/fowler/nullsubexpr.toml | 2870 - .../regex/testdata/fowler/repetition.toml | 6391 -- third_party/rust/regex/testdata/iter.toml | 999 - .../rust/regex/testdata/leftmost-all.toml | 145 - .../rust/regex/testdata/line-terminator.toml | 771 - third_party/rust/regex/testdata/misc.toml | 552 - .../rust/regex/testdata/multiline.toml | 7531 -- .../rust/regex/testdata/no-unicode.toml | 1506 - .../rust/regex/testdata/overlapping.toml | 2024 - .../rust/regex/testdata/regex-lite.toml | 696 - .../rust/regex/testdata/regression.toml | 7364 -- third_party/rust/regex/testdata/set.toml | 4442 -- .../rust/regex/testdata/substring.toml | 290 - third_party/rust/regex/testdata/unicode.toml | 2869 - third_party/rust/regex/testdata/utf8.toml | 2945 - .../rust/regex/testdata/word-boundary.toml | 4393 -- third_party/rust/regex/tests/api.rs | 3113 + third_party/rust/regex/tests/api_str.rs | 361 + third_party/rust/regex/tests/bytes.rs | 1378 + third_party/rust/regex/tests/consistent.rs | 1540 + third_party/rust/regex/tests/crates_regex.rs | 63116 ++++++++++++++++ third_party/rust/regex/tests/crazy.rs | 3980 + third_party/rust/regex/tests/flags.rs | 392 + third_party/rust/regex/tests/fowler.rs | 13911 ++++ third_party/rust/regex/tests/fuzz/mod.rs | 1481 - ...h-7eb3351f0965e5d6c1cb98aa8585949ef96531ff | 0 ...h-8760b19b25d74e3603d4c643e9c7404fdd3631f9 | 0 ...h-cd33b13df59ea9d74503986f9d32a270dd43cc04 | 0 ...m-8760b19b25d74e3603d4c643e9c7404fdd3631f9 | 0 ...t-3ab758ea520027fefd3f00e1384d9aeef155739e | 0 ...t-5345fccadf3812c53c3ccc7af5aa2741b7b2106c | 0 ...t-6bd643eec330166e4ada91da2d3f284268481085 | 0 ...t-93c73a43581f205f9aaffd9c17e52b34b17becd0 | 0 ...t-9ca9cc9929fee1fcbb847a78384effb8b98ea18a | 0 ...t-b8a052f4254802edbe5f569b6ce6e9b6c927e9d6 | 0 third_party/rust/regex/tests/lib.rs | 384 - third_party/rust/regex/tests/macros.rs | 1314 + third_party/rust/regex/tests/macros_bytes.rs | 350 + third_party/rust/regex/tests/macros_str.rs | 420 + third_party/rust/regex/tests/misc.rs | 1305 +- third_party/rust/regex/tests/multiline.rs | 979 + third_party/rust/regex/tests/noparse.rs | 483 + third_party/rust/regex/tests/regression.rs | 2533 +- .../rust/regex/tests/regression_fuzz.rs | 244 +- third_party/rust/regex/tests/replace.rs | 662 +- third_party/rust/regex/tests/searcher.rs | 17 +- third_party/rust/regex/tests/set.rs | 880 + .../rust/regex/tests/shortest_match.rs | 120 + .../rust/regex/tests/suffix_reverse.rs | 168 + third_party/rust/regex/tests/suite_bytes.rs | 1002 - .../rust/regex/tests/suite_bytes_set.rs | 643 - third_party/rust/regex/tests/suite_string.rs | 1034 - .../rust/regex/tests/suite_string_set.rs | 682 - .../rust/regex/tests/test_backtrack.rs | 281 + .../rust/regex/tests/test_backtrack_bytes.rs | 272 + .../regex/tests/test_backtrack_utf8bytes.rs | 291 + .../rust/regex/tests/test_crates_regex.rs | 316 + third_party/rust/regex/tests/test_default.rs | 1838 + .../rust/regex/tests/test_default_bytes.rs | 475 + third_party/rust/regex/tests/test_nfa.rs | 281 + .../rust/regex/tests/test_nfa_bytes.rs | 272 + .../rust/regex/tests/test_nfa_utf8bytes.rs | 291 + third_party/rust/regex/tests/unicode.rs | 2383 + third_party/rust/regex/tests/word_boundary.rs | 1861 + .../rust/regex/tests/word_boundary_ascii.rs | 177 + .../rust/regex/tests/word_boundary_unicode.rs | 91 + 396 files changed, 301593 insertions(+), 1210870 deletions(-) rename third_party/rust/aho-corasick/src/{util => }/buffer.rs (89%) rename third_party/rust/aho-corasick/src/{util => }/byte_frequencies.rs (100%) rename third_party/rust/aho-corasick/src/{util/alphabet.rs => classes.rs} (50%) create mode 100644 third_party/rust/aho-corasick/src/error.rs delete mode 100644 third_party/rust/aho-corasick/src/macros.rs rename third_party/rust/aho-corasick/src/{nfa/contiguous.rs => nfa.rs} (58%) delete mode 100644 third_party/rust/aho-corasick/src/nfa/mod.rs delete mode 100644 third_party/rust/aho-corasick/src/packed/ext.rs delete mode 100644 third_party/rust/aho-corasick/src/packed/teddy/builder.rs create mode 100644 third_party/rust/aho-corasick/src/packed/teddy/compile.rs rename third_party/rust/aho-corasick/src/packed/teddy/{generic.rs => runtime.rs} (55%) rename third_party/rust/aho-corasick/src/{util => }/prefilter.rs (76%) create mode 100644 third_party/rust/aho-corasick/src/state_id.rs delete mode 100644 third_party/rust/aho-corasick/src/transducer.rs delete mode 100644 third_party/rust/aho-corasick/src/util/debug.rs delete mode 100644 third_party/rust/aho-corasick/src/util/error.rs delete mode 100644 third_party/rust/aho-corasick/src/util/int.rs delete mode 100644 third_party/rust/aho-corasick/src/util/mod.rs delete mode 100644 third_party/rust/aho-corasick/src/util/primitives.rs delete mode 100644 third_party/rust/aho-corasick/src/util/remapper.rs delete mode 100644 third_party/rust/aho-corasick/src/util/search.rs delete mode 100644 third_party/rust/aho-corasick/src/util/special.rs delete mode 100644 third_party/rust/regex-automata/.cargo-checksum.json delete mode 100644 third_party/rust/regex-automata/Cargo.toml delete mode 100644 third_party/rust/regex-automata/LICENSE-APACHE delete mode 100644 third_party/rust/regex-automata/README.md delete mode 100644 third_party/rust/regex-automata/src/dfa/accel.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/automaton.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/dense.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/determinize.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/minimize.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/mod.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/onepass.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/regex.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/remapper.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/search.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/sparse.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/special.rs delete mode 100644 third_party/rust/regex-automata/src/dfa/start.rs delete mode 100644 third_party/rust/regex-automata/src/hybrid/dfa.rs delete mode 100644 third_party/rust/regex-automata/src/hybrid/error.rs delete mode 100644 third_party/rust/regex-automata/src/hybrid/id.rs delete mode 100644 third_party/rust/regex-automata/src/hybrid/mod.rs delete mode 100644 third_party/rust/regex-automata/src/hybrid/regex.rs delete mode 100644 third_party/rust/regex-automata/src/hybrid/search.rs delete mode 100644 third_party/rust/regex-automata/src/lib.rs delete mode 100644 third_party/rust/regex-automata/src/macros.rs delete mode 100644 third_party/rust/regex-automata/src/meta/error.rs delete mode 100644 third_party/rust/regex-automata/src/meta/limited.rs delete mode 100644 third_party/rust/regex-automata/src/meta/literal.rs delete mode 100644 third_party/rust/regex-automata/src/meta/mod.rs delete mode 100644 third_party/rust/regex-automata/src/meta/regex.rs delete mode 100644 third_party/rust/regex-automata/src/meta/reverse_inner.rs delete mode 100644 third_party/rust/regex-automata/src/meta/stopat.rs delete mode 100644 third_party/rust/regex-automata/src/meta/strategy.rs delete mode 100644 third_party/rust/regex-automata/src/meta/wrappers.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/mod.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/backtrack.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/builder.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/compiler.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/error.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/literal_trie.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/map.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/mod.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/nfa.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/pikevm.rs delete mode 100644 third_party/rust/regex-automata/src/nfa/thompson/range_trie.rs delete mode 100644 third_party/rust/regex-automata/src/util/alphabet.rs delete mode 100644 third_party/rust/regex-automata/src/util/captures.rs delete mode 100644 third_party/rust/regex-automata/src/util/determinize/mod.rs delete mode 100644 third_party/rust/regex-automata/src/util/determinize/state.rs delete mode 100644 third_party/rust/regex-automata/src/util/empty.rs delete mode 100644 third_party/rust/regex-automata/src/util/escape.rs delete mode 100644 third_party/rust/regex-automata/src/util/int.rs delete mode 100644 third_party/rust/regex-automata/src/util/interpolate.rs delete mode 100644 third_party/rust/regex-automata/src/util/iter.rs delete mode 100644 third_party/rust/regex-automata/src/util/lazy.rs delete mode 100644 third_party/rust/regex-automata/src/util/look.rs delete mode 100644 third_party/rust/regex-automata/src/util/memchr.rs delete mode 100644 third_party/rust/regex-automata/src/util/mod.rs delete mode 100644 third_party/rust/regex-automata/src/util/pool.rs delete mode 100644 third_party/rust/regex-automata/src/util/prefilter/aho_corasick.rs delete mode 100644 third_party/rust/regex-automata/src/util/prefilter/byteset.rs delete mode 100644 third_party/rust/regex-automata/src/util/prefilter/memchr.rs delete mode 100644 third_party/rust/regex-automata/src/util/prefilter/memmem.rs delete mode 100644 third_party/rust/regex-automata/src/util/prefilter/mod.rs delete mode 100644 third_party/rust/regex-automata/src/util/prefilter/teddy.rs delete mode 100644 third_party/rust/regex-automata/src/util/primitives.rs delete mode 100644 third_party/rust/regex-automata/src/util/search.rs delete mode 100644 third_party/rust/regex-automata/src/util/sparse_set.rs delete mode 100644 third_party/rust/regex-automata/src/util/start.rs delete mode 100644 third_party/rust/regex-automata/src/util/unicode_data/mod.rs delete mode 100644 third_party/rust/regex-automata/src/util/unicode_data/perl_word.rs delete mode 100644 third_party/rust/regex-automata/src/util/utf8.rs delete mode 100644 third_party/rust/regex-automata/src/util/wire.rs delete mode 100644 third_party/rust/regex-automata/test delete mode 100644 third_party/rust/regex-automata/tests/dfa/api.rs delete mode 100644 third_party/rust/regex-automata/tests/dfa/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/dfa/onepass/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/dfa/onepass/suite.rs delete mode 100644 third_party/rust/regex-automata/tests/dfa/regression.rs delete mode 100644 third_party/rust/regex-automata/tests/dfa/suite.rs delete mode 100644 third_party/rust/regex-automata/tests/fuzz/dense.rs delete mode 100644 third_party/rust/regex-automata/tests/fuzz/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/fuzz/sparse.rs delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_dense_crash-9486fb7c8a93b12c12a62166b43d31640c0208a9 delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_dense_minimized-from-9486fb7c8a93b12c12a62166b43d31640c0208a9 delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-0da59c0434eaf35e5a6b470fa9244bb79c72b000 delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-18cfc246f2ddfc3dfc92b0c7893178c7cf65efa9 delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-61fd8e3003bf9d99f6c1e5a8488727eefd234b98 delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-a1b839d899ced76d5d7d0f78f9edb7a421505838 delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-c383ae07ec5e191422eadc492117439011816570 delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-d07703ceb94b10dcd9e4acb809f2051420449e2b delete mode 100644 third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-dbb8172d3984e7e7d03f4b5f8bb86ecd1460eff9 delete mode 100644 third_party/rust/regex-automata/tests/gen/README.md delete mode 100644 third_party/rust/regex-automata/tests/gen/dense/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2.rs delete mode 100644 third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_fwd.bigendian.dfa delete mode 100644 third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_fwd.littleendian.dfa delete mode 100644 third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_rev.bigendian.dfa delete mode 100644 third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_rev.littleendian.dfa delete mode 100644 third_party/rust/regex-automata/tests/gen/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/gen/sparse/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2.rs delete mode 100644 third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_fwd.bigendian.dfa delete mode 100644 third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_fwd.littleendian.dfa delete mode 100644 third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_rev.bigendian.dfa delete mode 100644 third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_rev.littleendian.dfa delete mode 100644 third_party/rust/regex-automata/tests/hybrid/api.rs delete mode 100644 third_party/rust/regex-automata/tests/hybrid/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/hybrid/suite.rs delete mode 100644 third_party/rust/regex-automata/tests/lib.rs delete mode 100644 third_party/rust/regex-automata/tests/meta/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/meta/suite.rs delete mode 100644 third_party/rust/regex-automata/tests/nfa/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/nfa/thompson/backtrack/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/nfa/thompson/backtrack/suite.rs delete mode 100644 third_party/rust/regex-automata/tests/nfa/thompson/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/nfa/thompson/pikevm/mod.rs delete mode 100644 third_party/rust/regex-automata/tests/nfa/thompson/pikevm/suite.rs delete mode 100644 third_party/rust/regex-syntax/src/debug.rs delete mode 100644 third_party/rust/regex-syntax/src/hir/literal.rs create mode 100644 third_party/rust/regex-syntax/src/hir/literal/mod.rs create mode 100644 third_party/rust/regex/Cargo.lock delete mode 100644 third_party/rust/regex/Cross.toml create mode 100644 third_party/rust/regex/PERFORMANCE.md create mode 100644 third_party/rust/regex/examples/regexdna-input.txt create mode 100644 third_party/rust/regex/examples/regexdna-output.txt create mode 100644 third_party/rust/regex/examples/shootout-regex-dna-bytes.rs create mode 100644 third_party/rust/regex/examples/shootout-regex-dna-cheat.rs create mode 100644 third_party/rust/regex/examples/shootout-regex-dna-replace.rs create mode 100644 third_party/rust/regex/examples/shootout-regex-dna-single-cheat.rs create mode 100644 third_party/rust/regex/examples/shootout-regex-dna-single.rs create mode 100644 third_party/rust/regex/examples/shootout-regex-dna.rs delete mode 100644 third_party/rust/regex/record/README.md delete mode 100644 third_party/rust/regex/record/compile-test/2023-04-19_1.7.3.csv delete mode 100644 third_party/rust/regex/record/compile-test/2023-04-20_master.csv delete mode 100644 third_party/rust/regex/record/compile-test/2023-07-05.csv delete mode 100644 third_party/rust/regex/record/compile-test/README.md delete mode 100644 third_party/rust/regex/record/old-bench-log/01-lazy-dfa/dynamic delete mode 100644 third_party/rust/regex/record/old-bench-log/01-lazy-dfa/dynamic-no-lazy-dfa delete mode 100644 third_party/rust/regex/record/old-bench-log/01-lazy-dfa/native delete mode 100644 third_party/rust/regex/record/old-bench-log/01-lazy-dfa/nfa delete mode 100644 third_party/rust/regex/record/old-bench-log/01-lazy-dfa/pcre delete mode 100644 third_party/rust/regex/record/old-bench-log/02-set/dynamic delete mode 100644 third_party/rust/regex/record/old-bench-log/03-bytes/onig delete mode 100644 third_party/rust/regex/record/old-bench-log/03-bytes/pcre delete mode 100644 third_party/rust/regex/record/old-bench-log/03-bytes/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/03-bytes/rust-bytes delete mode 100644 third_party/rust/regex/record/old-bench-log/04/onig delete mode 100644 third_party/rust/regex/record/old-bench-log/04/pcre1-jit delete mode 100644 third_party/rust/regex/record/old-bench-log/04/pcre2-jit delete mode 100644 third_party/rust/regex/record/old-bench-log/04/re2 delete mode 100644 third_party/rust/regex/record/old-bench-log/04/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/04/tcl delete mode 100644 third_party/rust/regex/record/old-bench-log/05/onig delete mode 100644 third_party/rust/regex/record/old-bench-log/05/onig-vs-rust delete mode 100644 third_party/rust/regex/record/old-bench-log/05/pcre1 delete mode 100644 third_party/rust/regex/record/old-bench-log/05/pcre1-vs-rust delete mode 100644 third_party/rust/regex/record/old-bench-log/05/pcre2 delete mode 100644 third_party/rust/regex/record/old-bench-log/05/pcre2-vs-rust delete mode 100644 third_party/rust/regex/record/old-bench-log/05/re2 delete mode 100644 third_party/rust/regex/record/old-bench-log/05/re2-vs-rust delete mode 100644 third_party/rust/regex/record/old-bench-log/05/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/05/tcl delete mode 100644 third_party/rust/regex/record/old-bench-log/05/tcl-vs-rust delete mode 100644 third_party/rust/regex/record/old-bench-log/06/dphobos-dmd delete mode 100644 third_party/rust/regex/record/old-bench-log/06/dphobos-dmd-ct delete mode 100644 third_party/rust/regex/record/old-bench-log/06/dphobos-ldc delete mode 100644 third_party/rust/regex/record/old-bench-log/06/dphobos-ldc-ct delete mode 100644 third_party/rust/regex/record/old-bench-log/06/pcre1 delete mode 100644 third_party/rust/regex/record/old-bench-log/06/pcre2 delete mode 100644 third_party/rust/regex/record/old-bench-log/06/re2 delete mode 100644 third_party/rust/regex/record/old-bench-log/06/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/07/boost delete mode 100644 third_party/rust/regex/record/old-bench-log/07/dphobos-dmd delete mode 100644 third_party/rust/regex/record/old-bench-log/07/dphobos-dmd-ct delete mode 100644 third_party/rust/regex/record/old-bench-log/07/oniguruma delete mode 100644 third_party/rust/regex/record/old-bench-log/07/pcre1 delete mode 100644 third_party/rust/regex/record/old-bench-log/07/pcre2 delete mode 100644 third_party/rust/regex/record/old-bench-log/07/re2 delete mode 100644 third_party/rust/regex/record/old-bench-log/07/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/07/rust-bytes delete mode 100644 third_party/rust/regex/record/old-bench-log/07/stdcpp delete mode 100644 third_party/rust/regex/record/old-bench-log/07/stdcpp-libcxx delete mode 100644 third_party/rust/regex/record/old-bench-log/07/tcl delete mode 100644 third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-after-01 delete mode 100644 third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-after-02 delete mode 100644 third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-before-01 delete mode 100644 third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-before-02 delete mode 100644 third_party/rust/regex/record/old-bench-log/09-new-baseline/pcre2 delete mode 100644 third_party/rust/regex/record/old-bench-log/09-new-baseline/re2 delete mode 100644 third_party/rust/regex/record/old-bench-log/09-new-baseline/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/09-new-baseline/rust-bytes delete mode 100644 third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-after-literal.log delete mode 100644 third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-before-literal.log delete mode 100644 third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-bytes-after-literal.log delete mode 100644 third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-bytes-before-literal.log delete mode 100644 third_party/rust/regex/record/old-bench-log/11-regex-1.7.3/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/11-regex-1.7.3/rust-bytes delete mode 100644 third_party/rust/regex/record/old-bench-log/12-regex-1.8.1/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/12-regex-1.8.1/rust-bytes delete mode 100644 third_party/rust/regex/record/old-bench-log/13-regex-1.9.0/rust delete mode 100644 third_party/rust/regex/record/old-bench-log/13-regex-1.9.0/rust-bytes delete mode 100644 third_party/rust/regex/record/old-bench-log/README.md delete mode 100644 third_party/rust/regex/record/old-bench-log/old/01-before delete mode 100644 third_party/rust/regex/record/old-bench-log/old/02-new-syntax-crate delete mode 100644 third_party/rust/regex/record/old-bench-log/old/03-new-syntax-crate delete mode 100644 third_party/rust/regex/record/old-bench-log/old/04-fixed-benchmark delete mode 100644 third_party/rust/regex/record/old-bench-log/old/05-thread-caching delete mode 100644 third_party/rust/regex/record/old-bench-log/old/06-major-dynamic delete mode 100644 third_party/rust/regex/record/old-bench-log/old/06-major-macro delete mode 100644 third_party/rust/regex/record/old-bench-log/old/07-prefix-improvements delete mode 100644 third_party/rust/regex/record/old-bench-log/old/08-case-fixes delete mode 100644 third_party/rust/regex/record/old-bench-log/old/09-before-compiler-rewrite delete mode 100644 third_party/rust/regex/record/old-bench-log/old/10-compiler-rewrite delete mode 100644 third_party/rust/regex/record/old-bench-log/old/11-compiler-rewrite delete mode 100644 third_party/rust/regex/record/old-bench-log/old/12-executor delete mode 100644 third_party/rust/regex/record/old-bench-log/old/12-executor-bytes delete mode 100644 third_party/rust/regex/record/old-bench-log/old/13-cache-byte-range-suffixes create mode 100644 third_party/rust/regex/src/backtrack.rs delete mode 100644 third_party/rust/regex/src/builders.rs delete mode 100644 third_party/rust/regex/src/bytes.rs create mode 100644 third_party/rust/regex/src/compile.rs rename third_party/rust/{aho-corasick/src/nfa/noncontiguous.rs => regex/src/dfa.rs} (52%) create mode 100644 third_party/rust/regex/src/exec.rs create mode 100644 third_party/rust/regex/src/expand.rs rename third_party/rust/{regex-syntax/src/rank.rs => regex/src/freqs.rs} (97%) create mode 100644 third_party/rust/regex/src/input.rs create mode 100644 third_party/rust/regex/src/literal/imp.rs create mode 100644 third_party/rust/regex/src/literal/mod.rs create mode 100644 third_party/rust/regex/src/pikevm.rs create mode 100644 third_party/rust/regex/src/pool.rs create mode 100644 third_party/rust/regex/src/prog.rs rename third_party/rust/{regex-automata/src/util/syntax.rs => regex/src/re_builder.rs} (52%) create mode 100644 third_party/rust/regex/src/re_bytes.rs rename third_party/rust/regex/src/{regexset/string.rs => re_set.rs} (65%) create mode 100644 third_party/rust/regex/src/re_trait.rs create mode 100644 third_party/rust/regex/src/re_unicode.rs delete mode 100644 third_party/rust/regex/src/regex/bytes.rs delete mode 100644 third_party/rust/regex/src/regex/mod.rs delete mode 100644 third_party/rust/regex/src/regex/string.rs delete mode 100644 third_party/rust/regex/src/regexset/bytes.rs delete mode 100644 third_party/rust/regex/src/regexset/mod.rs create mode 100644 third_party/rust/regex/src/sparse.rs rename third_party/rust/{regex-automata/LICENSE-MIT => regex/src/testdata/LICENSE} (61%) create mode 100644 third_party/rust/regex/src/testdata/README rename third_party/rust/regex/{testdata/fowler/dat => src/testdata}/basic.dat (93%) rename third_party/rust/regex/{testdata/fowler/dat => src/testdata}/nullsubexpr.dat (92%) rename third_party/rust/regex/{testdata/fowler/dat => src/testdata}/repetition.dat (94%) create mode 100644 third_party/rust/regex/src/utf8.rs delete mode 100644 third_party/rust/regex/testdata/README.md delete mode 100644 third_party/rust/regex/testdata/anchored.toml delete mode 100644 third_party/rust/regex/testdata/bytes.toml delete mode 100644 third_party/rust/regex/testdata/crazy.toml delete mode 100644 third_party/rust/regex/testdata/crlf.toml delete mode 100644 third_party/rust/regex/testdata/earliest.toml delete mode 100644 third_party/rust/regex/testdata/empty.toml delete mode 100644 third_party/rust/regex/testdata/expensive.toml delete mode 100644 third_party/rust/regex/testdata/flags.toml delete mode 100644 third_party/rust/regex/testdata/fowler/basic.toml delete mode 100644 third_party/rust/regex/testdata/fowler/dat/README delete mode 100644 third_party/rust/regex/testdata/fowler/nullsubexpr.toml delete mode 100644 third_party/rust/regex/testdata/fowler/repetition.toml delete mode 100644 third_party/rust/regex/testdata/iter.toml delete mode 100644 third_party/rust/regex/testdata/leftmost-all.toml delete mode 100644 third_party/rust/regex/testdata/line-terminator.toml delete mode 100644 third_party/rust/regex/testdata/misc.toml delete mode 100644 third_party/rust/regex/testdata/multiline.toml delete mode 100644 third_party/rust/regex/testdata/no-unicode.toml delete mode 100644 third_party/rust/regex/testdata/overlapping.toml delete mode 100644 third_party/rust/regex/testdata/regex-lite.toml delete mode 100644 third_party/rust/regex/testdata/regression.toml delete mode 100644 third_party/rust/regex/testdata/set.toml delete mode 100644 third_party/rust/regex/testdata/substring.toml delete mode 100644 third_party/rust/regex/testdata/unicode.toml delete mode 100644 third_party/rust/regex/testdata/utf8.toml delete mode 100644 third_party/rust/regex/testdata/word-boundary.toml create mode 100644 third_party/rust/regex/tests/api.rs create mode 100644 third_party/rust/regex/tests/api_str.rs create mode 100644 third_party/rust/regex/tests/bytes.rs create mode 100644 third_party/rust/regex/tests/consistent.rs create mode 100644 third_party/rust/regex/tests/crates_regex.rs create mode 100644 third_party/rust/regex/tests/crazy.rs create mode 100644 third_party/rust/regex/tests/flags.rs create mode 100644 third_party/rust/regex/tests/fowler.rs delete mode 100644 third_party/rust/regex/tests/fuzz/mod.rs delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/crash-7eb3351f0965e5d6c1cb98aa8585949ef96531ff delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/crash-8760b19b25d74e3603d4c643e9c7404fdd3631f9 delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/crash-cd33b13df59ea9d74503986f9d32a270dd43cc04 delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/minimized-from-8760b19b25d74e3603d4c643e9c7404fdd3631f9 delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/slow-unit-3ab758ea520027fefd3f00e1384d9aeef155739e delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/slow-unit-5345fccadf3812c53c3ccc7af5aa2741b7b2106c delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/slow-unit-6bd643eec330166e4ada91da2d3f284268481085 delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/slow-unit-93c73a43581f205f9aaffd9c17e52b34b17becd0 delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/slow-unit-9ca9cc9929fee1fcbb847a78384effb8b98ea18a delete mode 100644 third_party/rust/regex/tests/fuzz/testdata/slow-unit-b8a052f4254802edbe5f569b6ce6e9b6c927e9d6 delete mode 100644 third_party/rust/regex/tests/lib.rs create mode 100644 third_party/rust/regex/tests/macros.rs create mode 100644 third_party/rust/regex/tests/macros_bytes.rs create mode 100644 third_party/rust/regex/tests/macros_str.rs create mode 100644 third_party/rust/regex/tests/multiline.rs create mode 100644 third_party/rust/regex/tests/noparse.rs create mode 100644 third_party/rust/regex/tests/set.rs create mode 100644 third_party/rust/regex/tests/shortest_match.rs create mode 100644 third_party/rust/regex/tests/suffix_reverse.rs delete mode 100644 third_party/rust/regex/tests/suite_bytes.rs delete mode 100644 third_party/rust/regex/tests/suite_bytes_set.rs delete mode 100644 third_party/rust/regex/tests/suite_string.rs delete mode 100644 third_party/rust/regex/tests/suite_string_set.rs create mode 100644 third_party/rust/regex/tests/test_backtrack.rs create mode 100644 third_party/rust/regex/tests/test_backtrack_bytes.rs create mode 100644 third_party/rust/regex/tests/test_backtrack_utf8bytes.rs create mode 100644 third_party/rust/regex/tests/test_crates_regex.rs create mode 100644 third_party/rust/regex/tests/test_default.rs create mode 100644 third_party/rust/regex/tests/test_default_bytes.rs create mode 100644 third_party/rust/regex/tests/test_nfa.rs create mode 100644 third_party/rust/regex/tests/test_nfa_bytes.rs create mode 100644 third_party/rust/regex/tests/test_nfa_utf8bytes.rs create mode 100644 third_party/rust/regex/tests/unicode.rs create mode 100644 third_party/rust/regex/tests/word_boundary.rs create mode 100644 third_party/rust/regex/tests/word_boundary_ascii.rs create mode 100644 third_party/rust/regex/tests/word_boundary_unicode.rs diff --git a/Cargo.lock b/Cargo.lock index 013979b19c0aa..3fbb162e736c9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -194,11 +194,11 @@ corasick version = " -1 +0 . -1 +7 . -0 +20 " source = @@ -226,7 +226,7 @@ index checksum = " -0f2135563fb5c609d2b2b87c1e8ce7bc41b0b45430fa9661f457981503dd5bf0 +cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac " dependencies = @@ -25477,80 +25477,9 @@ version " 1 . -9 -. -4 -" -source -= -" -registry -+ -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -crates -. -io -- -index -" -checksum -= -" -12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29 -" -dependencies -= -[ -" -aho -- -corasick -" -" -memchr -" -" -regex -- -automata -" -" -regex -- -syntax -" -] -[ -[ -package -] -] -name -= -" -regex -- -automata -" -version -= -" -0 -. -3 -. 7 +. +1 " source = @@ -25578,7 +25507,7 @@ index checksum = " -49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629 +48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733 " dependencies = @@ -25614,9 +25543,9 @@ version " 0 . -7 +6 . -5 +28 " source = @@ -25644,7 +25573,7 @@ index checksum = " -dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da +456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848 " [ [ diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index bdb29b39ca707..245b639e61854 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -42936,53 +42936,6 @@ trusted . regex - -automata -] -] -criteria -= -" -safe -- -to -- -deploy -" -user -- -id -= -189 -# -Andrew -Gallant -( -BurntSushi -) -start -= -" -2019 -- -02 -- -25 -" -end -= -" -2024 -- -09 -- -20 -" -[ -[ -trusted -. -regex -- syntax ] ] diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index ea1aae591155c..97dd6fd8901a2 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -55,53 +55,6 @@ Gallant [ publisher . -aho -- -corasick -] -] -version -= -" -1 -. -1 -. -0 -" -when -= -" -2023 -- -09 -- -18 -" -user -- -id -= -189 -user -- -login -= -" -BurntSushi -" -user -- -name -= -" -Andrew -Gallant -" -[ -[ -publisher -. anstyle ] ] @@ -2754,98 +2707,6 @@ Gallant publisher . regex -] -] -version -= -" -1 -. -9 -. -4 -" -when -= -" -2023 -- -08 -- -26 -" -user -- -id -= -189 -user -- -login -= -" -BurntSushi -" -user -- -name -= -" -Andrew -Gallant -" -[ -[ -publisher -. -regex -- -automata -] -] -version -= -" -0 -. -3 -. -7 -" -when -= -" -2023 -- -08 -- -26 -" -user -- -id -= -189 -user -- -login -= -" -BurntSushi -" -user -- -name -= -" -Andrew -Gallant -" -[ -[ -publisher -. -regex - syntax ] @@ -2892,53 +2753,6 @@ Gallant [ publisher . -regex -- -syntax -] -] -version -= -" -0 -. -7 -. -5 -" -when -= -" -2023 -- -08 -- -26 -" -user -- -id -= -189 -user -- -login -= -" -BurntSushi -" -user -- -name -= -" -Andrew -Gallant -" -[ -[ -publisher -. rust_cascade ] ] diff --git a/third_party/rust/aho-corasick/.cargo-checksum.json b/third_party/rust/aho-corasick/.cargo-checksum.json index b54f2a35a61dc..b7d75c2d23321 100644 --- a/third_party/rust/aho-corasick/.cargo-checksum.json +++ b/third_party/rust/aho-corasick/.cargo-checksum.json @@ -18,7 +18,7 @@ toml " : " -55608b09e18c96a0c245d8af2546e63bb4576fa378c1f2ce38c7909f3b225007 +c9b1b15e299ba4e6ed0d6f25cde30b26b13b6068a7fbd980000c37bca19b0104 " " DESIGN @@ -27,7 +27,7 @@ md " : " -59c960e1b73b1d7fb41e4df6c0c1b1fcf44dd2ebc8a349597a7d0595f8cb5130 +64ff45ea2a89d4c32b29af91acb7743a861fcac417cb94fde8e6559405d603b2 " " LICENSE @@ -45,7 +45,7 @@ md " : " -afc4d559a98cf190029af0bf320fc0022725e349cd2a303aac860254e28f3c53 +5999e5768f5da8ab9b50c016766b5185b4c79936c56bef6d311ddcb0a38c4b94 " " UNLICENSE @@ -72,7 +72,7 @@ rs " : " -c699c07df70be45c666e128509ad571a7649d2073e4ae16ac1efd6793c9c6890 +b92c9a65c4ee8029ff5a710aa1514caf838e73072c177dff5375463769f0b1ce " " src @@ -83,105 +83,97 @@ rs " : " -22258a3e118672413119f8f543a9b912cce954e63524575c0ebfdf9011f9c2dd +931af0aad03079bc4f6400d573fce832ce1edeeaf196815a16750d57b54b2183 " " src / -dfa +buffer . rs " : " -c495d615545981e1d0a4174bf0a6ab87fd81c30c7d4527acf2d64a56323bdc36 +dae7ee7c1f846ca9cf115ba4949484000e1837b4fb7311f8d8c9a35011c9c26f " " src / -lib +byte_frequencies . rs " : " -2a92d5c5e930f2d306508802e8a929135e1f41c9f5f8deda8f7eb98947179dd2 +2fb85b381c038c1e44ce94294531cdcd339dca48b1e61f41455666e802cbbc9e " " src / -macros +classes . rs " : " -c6c52ae05b24433cffaca7b78b3645d797862c5d5feffddf9f54909095ed6e05 +99a53a2ed8eea8c13699def90e31dfdff9d0b90572b1db3cb534e3396e7a0ed0 " " src / -nfa -/ -contiguous +dfa . rs " : " -aeb6ee5fd80eea04decbc4b46aa27d1ab270b78d416a644da25b7934f009ee66 +25e4455b3e179a7e192108d05f3683993456b36e3ebed99f827558c52525b7e6 " " src / -nfa -/ -mod +error . rs " : " -ee7b3109774d14bbad5239c16bb980dd6b8185ec136d94fbaf2f0dc27d5ffa15 +d34c2c9c815df5d9dedc46b4b3ce109cd2cee07825de643f0c574ec960367beb " " src / -nfa -/ -noncontiguous +lib . rs " : " -de94f02b04efd8744fb096759a8897c22012b0e0ca3ace161fd87c71befefe04 +7a47d4c87f83e0e7ddf0777a71e4858904e73477ce18404cb89e656070e86aef " " src / -packed -/ -api +nfa . rs " : " -160d3b10823316f7b0924e13c3afd222c8a7db5c0a00432401f311ef27d6a1b7 +3b817b4aa85540e8c0d35aff7ed7cfbab70ec7d2aaa779d63b4f5369bff31ce1 " " src / packed / -ext +api . rs " : " -66be06fde8558429da23a290584d4b9fae665bf64c2578db4fe5f5f3ee864869 +df42e7500c94c9de1ac44145a0dd99ea02047e6bba229da12f2575337beebcf0 " " src @@ -194,7 +186,7 @@ rs " : " -0020cd6f07ba5c8955923a9516d7f758864260eda53a6b6f629131c45ddeec62 +ad2f8e18996737347a1181a4457387276d139315bcabfc5e34494af0c0319701 " " src @@ -207,7 +199,7 @@ rs " : " -1e3a289a730c141fc30b295811e372d046c6619c7fd670308299b889a06c7673 +3abf3835d4c4f8a43753c52936a894d819f713f233fc046e19de5ef95200dcce " " src @@ -220,7 +212,7 @@ rs " : " -403146eb1d838a84601d171393542340513cd1ee7ff750f2372161dd47746586 +ad7d4533f96aed336e29c5553657ae57b0d733ace9c707a6cf4d08d8fc6edee5 " " src @@ -235,7 +227,7 @@ md " : " -3a43194b64e221543d885176aba3beb1224a927385a20eca842daf6b0ea2f342 +b4b83fb5afafbbea6cb76fe70f49cc8ced888f682d98abe5ea5773e95d9ec2b0 " " src @@ -244,13 +236,13 @@ packed / teddy / -builder +compile . rs " : " -720735ea6c7ff92b081426513e6e82feed24a922849297bb538d28f7b8129f81 +aad40b3f93d2c388b409b31fb2795d414a365237789d5b1a7510d97ceb8ce260 " " src @@ -259,13 +251,13 @@ packed / teddy / -generic +mod . rs " : " -ea252ab05b32cea7dd9d71e332071d243db7dd0362e049252a27e5881ba2bf39 +83b52bd80272970ad17234d0db293d17c1710ec582302bf516b203c8edec037e " " src @@ -274,13 +266,13 @@ packed / teddy / -mod +runtime . rs " : " -17d741f7e2fb9dbac5ba7d1bd4542cf1e35e9f146ace728e23fe6bbed20028b2 +836146e90b320b14fa2c65fe4af7915a41f6fb04408aac5fac731c22ff46adae " " src @@ -293,7 +285,7 @@ rs " : " -8e2f56eb3890ed3876ecb47d3121996e416563127b6430110d7b516df3f83b4b +b8dc4d3281ecd6d0fa2bf7ef16cf292a467dfdce64e470c7921e983bfa60fee2 " " src @@ -306,185 +298,40 @@ rs " : " -6e0400422de015e181c758ef3a4ff517fc8d0481b078a82de00f6e29e9d2e1c8 -" -" -src -/ -tests -. -rs -" -: -" -c68192ab97b6161d0d6ee96fefd80cc7d14e4486ddcd8d1f82b5c92432c24ed5 -" -" -src -/ -transducer -. -rs -" -: -" -02daa33a5d6dac41dcfd67f51df7c0d4a91c5131c781fb54c4de3520c585a6e1 -" -" -src -/ -util -/ -alphabet -. -rs -" -: -" -6dc22658a38deddc0279892035b18870d4585069e35ba7c7e649a24509acfbcc -" -" -src -/ -util -/ -buffer -. -rs -" -: -" -f9e37f662c46c6ecd734458dedbe76c3bb0e84a93b6b0117c0d4ad3042413891 -" -" -src -/ -util -/ -byte_frequencies -. -rs -" -: -" -2fb85b381c038c1e44ce94294531cdcd339dca48b1e61f41455666e802cbbc9e -" -" -src -/ -util -/ -debug -. -rs -" -: -" -ab301ad59aa912529cb97233a54a05914dd3cb2ec43e6fec7334170b97ac5998 -" -" -src -/ -util -/ -error -. -rs -" -: -" -ecccd60e7406305023efcc6adcc826eeeb083ab8f7fbfe3d97469438cd4c4e5c -" -" -src -/ -util -/ -int -. -rs -" -: -" -4ab6dbdba10027ddec2af63a9b28ce4eee30ded0daa5d8eb068b2b55542b6039 +ab3c0535fca5f09198d58cbfae44c292aeb3ce44bc92bca36d30dc72963639fc " " src / -util -/ -mod -. -rs -" -: -" -7ab28d11323ecdbd982087f32eb8bceeee84f1a2583f3aae27039c36d58cf12c -" -" -src -/ -util -/ prefilter . rs " : " -9fa4498f18bf70478b1996c1a013698b626d15f119aa81dbc536673c9f045718 +82a3eb6d5c0c3f10bc8d5f57d55d6d14cf4cf21c475bb5253e1921084063b8d7 " " src / -util -/ -primitives +state_id . rs " : " -f89f3fa1d8db4e37de9ca767c6d05e346404837cade6d063bba68972fafa610b +519ec8c7bf3fa72103d4c561c193759759f535dca924c9853efe630f406d2029 " " src / -util -/ -remapper -. -rs -" -: -" -9f12d911583a325c11806eeceb46d0dfec863cfcfa241aed84d31af73da746e5 -" -" -src -/ -util -/ -search -. -rs -" -: -" -6af803e08b8b8c8a33db100623f1621b0d741616524ce40893d8316897f27ffe -" -" -src -/ -util -/ -special +tests . rs " : " -7d2f9cb9dd9771f59816e829b2d96b1239996f32939ba98764e121696c52b146 +ee9b85f3c27cb2fba5796e5be8019aafecc13ee9a4f614553f2bc8953f51c6de " } " @@ -492,6 +339,6 @@ package " : " -0f2135563fb5c609d2b2b87c1e8ce7bc41b0b45430fa9661f457981503dd5bf0 +cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac " } diff --git a/third_party/rust/aho-corasick/Cargo.toml b/third_party/rust/aho-corasick/Cargo.toml index a80577c29bd93..07d1025d35e7f 100644 --- a/third_party/rust/aho-corasick/Cargo.toml +++ b/third_party/rust/aho-corasick/Cargo.toml @@ -100,18 +100,7 @@ package edition = " -2021 -" -rust -- -version -= -" -1 -. -60 -. -0 +2018 " name = @@ -123,11 +112,11 @@ corasick version = " -1 +0 . -1 +7 . -0 +20 " authors = @@ -154,14 +143,6 @@ corasick - debug " -" -/ -benchmarks -" -" -/ -tmp -" ] autotests = @@ -212,7 +193,7 @@ search text " " -pattern +aho " " multi @@ -252,52 +233,13 @@ aho corasick " [ -package -. -metadata -. -docs -. -rs -] -all -- -features -= -true -rustdoc -- -args -= -[ -" -- -- -cfg -" -" -docsrs -" -" -- -- -generate -- -link -- -to -- -definition -" -] -[ profile . bench ] debug = -2 +true [ profile . @@ -305,7 +247,7 @@ release ] debug = -2 +true [ lib ] @@ -317,23 +259,6 @@ aho_corasick [ dependencies . -log -] -version -= -" -0 -. -4 -. -17 -" -optional -= -true -[ -dependencies -. memchr ] version @@ -345,9 +270,6 @@ version . 0 " -optional -= -true default - features @@ -357,20 +279,7 @@ false dev - dependencies -. -doc -- -comment ] -version -= -" -0 -. -3 -. -3 -" [ features ] @@ -380,38 +289,12 @@ default " std " -" -perf -- -literal -" -] -logging -= -[ -" -dep -: -log -" -] -perf -- -literal -= -[ -" -dep -: -memchr -" ] std = [ " memchr -? / std " diff --git a/third_party/rust/aho-corasick/DESIGN.md b/third_party/rust/aho-corasick/DESIGN.md index 8a2688a6ece43..f896b54c09b69 100644 --- a/third_party/rust/aho-corasick/DESIGN.md +++ b/third_party/rust/aho-corasick/DESIGN.md @@ -150,115 +150,146 @@ Aho - Corasick as -a -noncontiguous +an NFA -. -States -have -their -transitions -represented -sparsely -and -each -state -puts -its +using +dense transitions -in -its -own -separate -allocation -. -Hence +near the -same -" -noncontiguous +root +with +sparse +transitions +elsewhere . -" * Aho - Corasick as a -contiguous -NFA +DFA . -This +( +An NFA +is +slower +to +search +but +cheaper +to +construct +and uses +less +memory +. +) +* +A +DFA +with +pre +- +multiplied +state +identifiers +. +This +saves a -single -allocation -to -represent +multiplication +instruction +in the -transitions +core +search +loop +. +* +A +DFA +with +equivalence +classes of -all -states +bytes +as +the +alphabet +instead +of +the +traditional +256 +- +byte +alphabet . -That -is -transitions -are -laid -out -contiguously +This +shrinks +the +size +of +the +DFA in memory -. -Moreover -states -near +but +adds +an +extra +lookup +in the -starting -state -are -represented -densely -such -that -finding +core +search +loop +to +map the -next -state -ID -takes -a -constant -number -of -instructions +input +byte +to +an +equivalent +class . * -Aho -- -Corasick -as -a -DFA -. -In -this -case -all -states +The +option +to +choose +how +state +identifiers are represented -densely -in -a -transition -table -that -uses +via one -allocation +of +u8 +u16 +u32 +u64 +or +usize +. +This +permits +creating +compact +automatons +when +matching +a +small +number +of +patterns . * Supporting @@ -497,10 +528,7 @@ searches which permit efficient -" -is -prefix -" +is_prefix checks for a @@ -854,7 +882,7 @@ alternative keys in the -trie +automaton . The trick @@ -2008,8 +2036,6 @@ see src / nfa -/ -noncontiguous . rs which @@ -2222,12 +2248,6 @@ failure transitions from S -until -you -reach -the -start -state . ( This @@ -2293,9 +2313,6 @@ typically slower to execute -a -search -with . For example @@ -2613,101 +2630,81 @@ actually choose between using -one -of -two -possible -NFAs -( -noncontiguous -or -contiguous -) +an +NFA or a DFA . By default -a -contiguous +an NFA is used -in -most -circumstances -but -if -the -number -of -patterns -is -small -enough -a -DFA -will -be -used -. -A -contiguous -NFA -is -chosen because it -uses -orders -of -magnitude -less -memory -than -a +typically +strikes +the +best +balance +between +space +usage +and +search +performance +. +But +the DFA -takes -only +option +is +available +for +cases +where a little -longer -to -build -than -a -noncontiguous -NFA +extra +memory and -usually -gets -pretty -close -to +upfront +time +building the -search -speed -of -a -DFA +automaton +is +okay . -( -Callers -can -override -this -automatic -selection -via +For +example the +AhoCorasick +: +: +auto_configure +and AhoCorasickBuilder : : -start_kind -configuration +auto_configure +methods +will +enable +the +DFA +setting +if +there +are +a +small +number +of +patterns . -) # More DFA @@ -3215,136 +3212,125 @@ state identifiers other than -it -imposes -a -smaller -limit -on the -total -number -of -states -in -the -DFA -. -Namely -with -premultiplied -state -identifiers +fact +that you -run -out -of -room -in -your -state -identifier +may +need +to +choose +a +bigger +integer representation -more -rapidly than +you +would +otherwise +. +For +example if -the +you +don +' +t +premultiply +state identifiers -are -just +then +an +automaton +that +uses +u8 +as +a state -indices +identifier +can +hold +up +to +256 +states . -Both -equivalence -classes -and -premultiplication +However +if +they are -always -enabled -. -There -is -a -AhoCorasickBuilder -: -: -byte_classes -configuration -but -disabling -this -just -makes +premultiplied +then it -so -there -are -always +can +only +hold +up +to +floor +( 256 -equivalence -classes -i -. -e +/ +len +( +alphabet +) +) +states . -every -class -corresponds -to -precisely -one -byte +Thus +premultiplication +impacts +how +compact +your +DFA +can +be . -When +In +practice it ' s -disabled -the -equivalence -class -map -itself -is -still -used -. -The -purpose -of -disabling -it -is -when -one +pretty +rare +to +use +u8 +as +a +state +identifier +so +premultiplication is -debugging -the -underlying -automaton -. -It -can -be -easier +usually +a +good +thing to -comprehend -when -it -uses -actual -byte -values -for -its -transitions -instead -of +do +. +Both equivalence classes +and +premultiplication +are +tuneable +parameters +via +the +AhoCorasickBuilder +type +and +both +are +enabled +by +default . # Match @@ -3768,8 +3754,6 @@ in src / nfa -/ -noncontiguous . rs . @@ -3851,8 +3835,7 @@ been found . ) -Most -other +Other implementations of Aho @@ -4056,18 +4039,7 @@ an overlapping search will -return -an -error -( -or panic -when -using -the -infallible -APIs -) . Thus to @@ -4193,6 +4165,23 @@ a single type . +Callers +may +query +whether +the +automaton +supports +overlapping +searches +via +the +AhoCorasick +: +: +supports_overlapping +method +. # Stream searching @@ -4597,6 +4586,20 @@ run at all . +( +See +Automaton +: +: +leftmost_find_at_no_state_imp +in +src +/ +automaton +. +rs +. +) However the current @@ -4606,19 +4609,13 @@ only works in x86_64 +and when SSSE3 or AVX2 are available -or -in -aarch64 -( -using -NEON -) and moreover only diff --git a/third_party/rust/aho-corasick/README.md b/third_party/rust/aho-corasick/README.md index afa2417ae843f..b8c8ceab565cb 100644 --- a/third_party/rust/aho-corasick/README.md +++ b/third_party/rust/aho-corasick/README.md @@ -236,27 +236,27 @@ corasick # # Usage -Run -cargo -add -aho -- -corasick -to -automatically -add +Add this -crate -as -a -dependency -in +to your Cargo . toml -file +: +toml +[ +dependencies +] +aho +- +corasick += +" +0 . +7 +" # # # @@ -298,10 +298,7 @@ use aho_corasick : : -{ AhoCorasick -PatternID -} ; let patterns @@ -344,10 +341,6 @@ new ( patterns ) -. -unwrap -( -) ; let mut @@ -400,35 +393,17 @@ vec ! [ ( -PatternID -: -: -must -( 1 -) 13 18 ) ( -PatternID -: -: -must -( 0 -) 28 33 ) ( -PatternID -: -: -must -( 2 -) 43 50 ) @@ -440,7 +415,6 @@ must # Example : -ASCII case insensitivity This @@ -462,10 +436,7 @@ use aho_corasick : : -{ -AhoCorasick -PatternID -} +AhoCorasickBuilder ; let patterns @@ -501,10 +472,10 @@ Snapple let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . @@ -517,10 +488,6 @@ build ( patterns ) -. -unwrap -( -) ; let mut @@ -573,35 +540,17 @@ vec ! [ ( -PatternID -: -: -must -( 1 -) 13 18 ) ( -PatternID -: -: -must -( 0 -) 28 33 ) ( -PatternID -: -: -must -( 2 -) 43 50 ) @@ -641,7 +590,6 @@ memory first . rust -ignore use aho_corasick : @@ -758,10 +706,6 @@ new ( patterns ) -. -unwrap -( -) ; ac . @@ -1038,10 +982,6 @@ new ( patterns ) -. -unwrap -( -) ; let mat @@ -1114,7 +1054,7 @@ aho_corasick : : { -AhoCorasick +AhoCorasickBuilder MatchKind } ; @@ -1141,10 +1081,10 @@ Samwise let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . @@ -1160,10 +1100,6 @@ build ( patterns ) -. -unwrap -( -) ; let mat @@ -1262,9 +1198,9 @@ version is 1 . -60 +41 . -0 +1 . The current @@ -1398,30 +1334,104 @@ for this library . -* -[ -tmikus -/ -ahocorasick_rs -] -( -https +# +# +# +Future +work +Here +are +some +plans +for +the +future : -/ -/ -github -. -com -/ -tmikus -/ -ahocorasick_rs -) +* +Assuming +the +current +API is +sufficient +I +' +d +like +to +commit +to +it +and +release a -Go -wrapper -for +1 +. +0 +version +of this -library +crate +some +time +in +the +next +6 +- +12 +months +. +* +Support +stream +searching +with +leftmost +match +semantics . +Currently +only +standard +match +semantics +are +supported +. +Getting +this +right +seems +possible +but +is +tricky +since +the +match +state +needs +to +be +propagated +through +multiple +searches +. +( +With +standard +semantics +as +soon +as +a +match +is +seen +the +search +ends +. +) diff --git a/third_party/rust/aho-corasick/src/ahocorasick.rs b/third_party/rust/aho-corasick/src/ahocorasick.rs index adf2f0036c0c5..b1408da5ffb9d 100644 --- a/third_party/rust/aho-corasick/src/ahocorasick.rs +++ b/third_party/rust/aho-corasick/src/ahocorasick.rs @@ -1,95 +1,92 @@ use -core +std : : -{ -fmt +io +; +use +crate : : -Debug -panic +automaton : : -{ -RefUnwindSafe -UnwindSafe -} -} +Automaton ; use -alloc +crate : : -{ -string +buffer : : -String -sync +Buffer +; +use +crate : : -Arc -vec +dfa : : -Vec +{ +self +DFA } ; use crate : : -{ -automaton +error +: +: +Result +; +use +crate : : -{ -self -Automaton -OverlappingState -} -dfa nfa : : { -contiguous -noncontiguous +self +NFA } -util +; +use +crate : : -{ -error +packed +; +use +crate : : -{ -BuildError -MatchError -} prefilter : : +{ Prefilter -primitives +PrefilterState +} +; +use +crate +: +: +state_id : : -{ -PatternID StateID -} -search +; +use +crate : : -{ -Anchored -Input Match -MatchKind -StartKind -} -} -} ; / / @@ -125,22 +122,57 @@ an / / automaton -with -the -default -being +including +/ +/ +/ [ AhoCorasick : : new ] +( +struct . -However -there +AhoCorasick +. +html +# +method +. +new +) +/ +/ +/ +and / / / +[ +AhoCorasick +: +: +new_auto_configured +] +( +struct +. +AhoCorasick +. +html +# +method +. +new_auto_configured +) +. +/ +/ +/ +However +there are a fair @@ -152,6 +184,9 @@ that can be set +/ +/ +/ by using / @@ -160,6 +195,16 @@ using [ AhoCorasickBuilder ] +( +struct +. +AhoCorasickBuilder +. +html +) +/ +/ +/ instead . Such @@ -169,13 +214,13 @@ but are not limited -/ -/ -/ to how matches are +/ +/ +/ determined simple case @@ -184,13 +229,13 @@ whether to use a -/ -/ -/ DFA or not and +/ +/ +/ various knobs for @@ -203,11 +248,11 @@ vs time trade offs +taken +when / / / -taken -when building the automaton @@ -218,6 +263,45 @@ automaton / / / +If +you +aren +' +t +sure +where +to +start +try +beginning +with +/ +/ +/ +[ +AhoCorasick +: +: +new_auto_configured +] +( +struct +. +AhoCorasick +. +html +# +method +. +new_auto_configured +) +. +/ +/ +/ +/ +/ +/ # Resource usage @@ -241,10 +325,10 @@ p ) time where +p / / / -p is the combined @@ -257,10 +341,10 @@ searched . With that +said / / / -said building an automaton @@ -280,26 +364,34 @@ particularly when enabling the +/ +/ +/ [ DFA ] ( -AhoCorasickKind -: -: -DFA +struct +. +AhoCorasickBuilder +. +html +# +method +. +dfa ) -option / / / -with -[ -AhoCorasickBuilder -: -: -kind -] +option +( +which +is +disabled +by +default +) . For this @@ -309,10 +401,10 @@ it s generally a -good / / / +good idea to build @@ -348,10 +440,10 @@ memory . To get +a / / / -a concrete idea of @@ -371,687 +463,607 @@ the AhoCorasick : : -memory_usage +heap_bytes ] +( +struct +. +AhoCorasick +. +html +# method . +heap_bytes +) / / / +method +. / / / -To -give -a -quick -idea -of -the -differences -between -Aho -- -Corasick / / / -implementations -and -their -resource -usage -here -' -s -a -sample -of -construction +# +Examples / / / -times -and -heap -memory -used -after -building -an -automaton -from -100 -000 -/ -/ -/ -randomly -selected -titles -from -Wikipedia -: / / / +This +example +shows +how +to +search +for +occurrences +of +multiple +patterns / / / -* -99MB -for -a -[ -noncontiguous -: -: -NFA -] +simultaneously in -240ms +a +case +insensitive +fashion . +Each +match +includes +the / / / -* -21MB -for -a -[ -contiguous -: -: -NFA -] -in -275ms +pattern +that +matched +along +with +the +byte +offsets +of +the +match . / / / -* -1 -. -6GB -for -a -[ -dfa -: -: -DFA -] -in -1 -. -88s -. / / / / / / -( -Note -that -the -memory -usage -above -reflects -the -size -of -each -automaton -and +use +aho_corasick +: +: +AhoCorasickBuilder +; / / / -not -peak -memory -usage -. -For -example -building -a -contiguous -NFA -requires / / / -first -building -a -noncontiguous -NFA -. -Once -the -contiguous -NFA -is -built -the +let +patterns += +& +[ +" +apple +" +" +maple +" +" +snapple +" +] +; / / / -noncontiguous -NFA -is -freed +let +haystack += +" +Nobody +likes +maple +in +their +apple +flavored +Snapple . -) +" +; / / / / / / -This -experiment -very -strongly -argues -that -a -contiguous -NFA -is -often -the +let +ac += +AhoCorasickBuilder +: +: +new +( +) / / / -best -balance -in -terms -of -resource -usage . -It -takes -a -little -longer -to -build +ascii_case_insensitive +( +true +) / / / -but -its -memory -usage -is -quite -small . -Its -search -speed +build ( -not -listed +patterns ) -is +; / / / -also -often -faster -than -a -noncontiguous -NFA -but -a -little -slower -than -a +let +mut +matches += +vec +! +[ +] +; / / / -DFA +for +mat +in +ac . -Indeed -when -no -specific -[ -AhoCorasickKind -] -is -used +find_iter ( -which -is -the +haystack +) +{ / / / -default +matches +. +push +( +( +mat +. +pattern +( ) -a -contiguous -NFA -is -used -in -most -cases +mat +. +start +( +) +mat . +end +( +) +) +) +; / / / +} / / / -The -only -" -catch -" -to -using -a -contiguous -NFA -is -that -because -of -its -variety -/ -/ -/ -of -compression -tricks -it -may -not -be -able -to -support -automatons -as -large -as -/ -/ -/ -what -the -noncontiguous -NFA -supports -. -In -which -case -building -a -contiguous +assert_eq +! +( +matches +vec +! +[ / / / -NFA -will -fail -and ( -by -default +1 +13 +18 ) -AhoCorasick -will -automatically -fall / / / -back -to -a -noncontiguous -NFA -. ( -This -typically -only -happens -when -building +0 +28 +33 +) / / / -automatons -from -millions -of -patterns -. +( +2 +43 +50 ) -Otherwise -the -small -additional -time / / / -for -building -a -contiguous -NFA -is -almost -certainly -worth -it -. +] +) +; / / / / / / -# -Cloning / / / +This +example +shows +how +to +replace +matches +with +some +other +string +: / / / -The -AhoCorasick -type -uses -thread -safe -reference -counting -internally -. -It / / / -is -guaranteed -that -it -is -cheap -to -clone -. / / / +use +aho_corasick +: +: +AhoCorasick +; / / / -# -Search -configuration / / / +let +patterns += +& +[ +" +fox +" +" +brown +" +" +quick +" +] +; / / / -Most -of -the -search -routines -accept -anything -that -can -be -cheaply -converted +let +haystack += +" +The +quick +brown +fox +. +" +; / / / -to -an -[ -Input -] -. -This -includes +let +replace_with += & [ -u8 +" +sloth +" +" +grey +" +" +slow +" ] -& -str -and -Input -itself -. -/ -/ -/ +; / / / -# -Construction -failure / / / +let +ac += +AhoCorasick +: +: +new +( +patterns +) +; / / / -It -is -generally -possible -for -building -an -Aho -- -Corasick -automaton -to -fail +let +result += +ac . +replace_all +( +haystack +replace_with +) +; / / / -Construction -can -fail -in -generally -one -way -: -when -the -inputs -provided -are +assert_eq +! +( +result +" +The +slow +grey +sloth +. +" +) +; / / / -too -big -. -Whether -that -' -s -a -pattern -that -is -too -long -too -many -patterns +# +[ +derive +( +Clone +Debug +) +] +pub +struct +AhoCorasick +< +S +: +StateID += +usize +> +{ +imp +: +Imp +< +S +> +match_kind +: +MatchKind +} +impl +AhoCorasick +{ / / / -or -some -combination -of -both +Create +a +new +Aho +- +Corasick +automaton +using +the +default +configuration . -A -first -approximation +/ +/ +/ +/ +/ +/ +The +default +configuration +optimizes for -the -scale +less +space +usage +but at -which +the / / / -construction -can -fail -is -somewhere -around -" -millions +expense of -patterns +longer +search +times . -" +To +change +the +configuration +use / / / +[ +AhoCorasickBuilder +] +( +struct +. +AhoCorasickBuilder +. +html +) / / / -For -that -reason -if -you -' -re -building -an -Aho +for +fine - -Corasick -automaton -from +grained +control +or / / / -untrusted -input +[ +AhoCorasick +: +: +new_auto_configured +] ( -or -input -that -doesn -' -t -have -any -reasonable -bounds -on -its +struct +. +AhoCorasick +. +html +# +method +. +new_auto_configured +) / / / -size -) -then -it -is -strongly -recommended +for +automatic +configuration +if +you +aren +' +t +sure +which +settings to -handle -the -possibility -of -an +pick +. / / / -error -. / / / +This +uses +the +default / / / -If -you -' -re -constructing -an -Aho -- -Corasick -automaton -from -static -or -trusted +[ +MatchKind +: +: +Standard +] +( +enum +. +MatchKind +. +html +# +variant +. +Standard +) / / / -data -then +match +semantics +which +reports +a +match +as +soon +as it is -likely -acceptable +found +. +This +/ +/ +/ +corresponds to -panic -( +the +standard +match +semantics +supported by -calling -unwrap -( -) -or +textbook / / / -expect -( -) -) -if -construction -fails +descriptions +of +the +Aho +- +Corasick +algorithm . / / @@ -1060,749 +1072,576 @@ fails / / # -Fallibility +Examples / / / / / / -The -AhoCorasick -type -provides -a -number -of -methods -for -searching -as -one +Basic +usage +: / / / -might -expect -. -Depending -on -how -the -Aho -- -Corasick -automaton -was -built -and / / / -depending -on -the -search -configuration -it -is -possible -for -a -search -to / / / -return -an -error -. -Since -an -error -is -_never_ -dependent -on -the -actual -contents +use +aho_corasick +: +: +AhoCorasick +; / / / -of -the -haystack -this -type -provides -both -infallible -and -fallible -methods / / / -for -searching -. -The -infallible -methods -panic -if -an -error -occurs -and -can -be +let +ac += +AhoCorasick +: +: +new +( +& +[ / / / -used -for -convenience -and -when -you -know -the -search -will -never -return -an +" +foo +" +" +bar +" +" +baz +" / / / -error -. +] +) +; / / / +assert_eq +! +( +Some +( +1 +) +ac +. +find +( +" +xxx +bar +xxx +" +) +. +map +( +| +m +| +m +. +pattern +( +) +) +) +; / / / -For -example -the -[ +pub +fn +new +< +I +P +> +( +patterns +: +I +) +- +> AhoCorasick +where +I : +IntoIterator +< +Item += +P +> +P : -find_iter -] -method -is -the -infallible -/ -/ -/ -version -of -the +AsRef +< [ -AhoCorasick +u8 +] +> +{ +AhoCorasickBuilder : : -try_find_iter -] -method +new +( +) . +build +( +patterns +) +} / / / +Build +an +Aho +- +Corasick +automaton +with +an +automatically +determined / / / -Examples -of -errors -that -can -occur -: +configuration +. / / / / / / -* -Running -a -search -that +Specifically +this requires -[ -MatchKind -: -: -Standard -] -semantics -( -such -/ -/ -/ -as a -stream -or -overlapping -search -) -with +slice +of +patterns +instead +of an -automaton -that -was -built -with +iterator / / / -[ -MatchKind -: -: -LeftmostFirst -] -or -[ -MatchKind -: -: -LeftmostLongest -] -semantics -. +since +the +configuration +is +determined +by +looking +at +the +patterns +before / / / -* -Running -an -anchored -search -with -an +constructing +the automaton -that -only -supports -/ -/ -/ -unanchored -searches . -( -By -default -AhoCorasick -only -supports -unanchored +The +idea +here +is +to +balance +space +and +time / / / -searches +automatically . -But +That +is +when +searching +a +small +number +of +patterns this -can -be -toggled -with -[ -AhoCorasickBuilder -: -: -start_kind -] -. -) / / / -* -Running -an -unanchored -search -with -an -automaton -that -only -supports +will +attempt +to +use +the +fastest +possible +configuration +since +the +total / / / -anchored -searches +space +required +will +be +small +anyway . -/ -/ -/ -/ -/ -/ -The -common -thread -between +As the -different -types +number of -errors -is -that -they -are +patterns +grows / / / -all -rooted -in -the -automaton -construction -and -search +this +will +fall +back +to +slower configurations +that +use +less +space . -If / / / -those -configurations -are -a -static -property -of -your -program -then -it -is / / / -reasonable -to -call -infallible -routines -since +If you -know -an -error -will -never +want +auto +configuration +but +with +match +semantics +different +from / / / -occur -. -And -if -one -_does_ -occur +the +default +MatchKind +: +: +Standard then -it -' -s -a -bug -in -your -program -. +use / / / +[ +AhoCorasickBuilder +: +: +auto_configure +] +( +struct +. +AhoCorasickBuilder +. +html +# +method +. +auto_configure +) +. / / / -To -re -- -iterate -if -the -patterns -build -or -search -configuration -come -from / / / -user -or -untrusted -data -then -you -should -handle -errors -at -build -or -search +# +Examples / / / -time -. -If -only -the -haystack -comes -from -user -or -untrusted -data -then -there / / / -should -be -no -need -to -handle -errors -anywhere -and -it +Basic +usage is -generally -encouraged +just +like +new +except +you +must +provide +a +slice +: / / / -to -unwrap -( -) -( -or -expect -( -) -) -both -build -and -search -time -calls -. / / / / / / -# -Examples +use +aho_corasick +: +: +AhoCorasick +; / / / / / / -This -example -shows -how -to -search -for -occurrences -of -multiple -patterns +let +ac += +AhoCorasick +: +: +new_auto_configured +( +& +[ / / / -simultaneously -in -a -case -insensitive -fashion -. -Each -match -includes -the -/ -/ -/ -pattern -that -matched -along -with -the -byte -offsets -of -the -match -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ " -apple +foo " " -maple +bar " " -snapple +baz " -] -; / / / -let -haystack -= -" -Nobody -likes -maple -in -their -apple -flavored -Snapple -. -" +] +) ; / / / -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder +assert_eq +! +( +Some ( +1 ) -/ -/ -/ +ac . -ascii_case_insensitive +find ( -true +" +xxx +bar +xxx +" ) -/ -/ -/ . -build +map ( -patterns -) -/ -/ -/ +| +m +| +m . -unwrap +pattern ( ) +) +) ; / / / -let -mut -matches -= -vec -! +pub +fn +new_auto_configured +< +B +> +( +patterns +: +& [ +B ] -; -/ -/ -/ -for -mat -in -ac -. -find_iter -( -haystack ) +- +> +AhoCorasick +where +B +: +AsRef +< +[ +u8 +] +> { -/ -/ -/ -matches -. -push -( -( -mat -. -pattern +AhoCorasickBuilder +: +: +new ( ) -mat . -start +auto_configure ( +patterns ) -mat . -end +build ( +patterns ) -) -) -; +} +} +impl +< +S +: +StateID +> +AhoCorasick +< +S +> +{ / / / -} +Returns +true +if +and +only +if +this +automaton +matches +the +haystack +at +any / / / -assert_eq -! -( -matches -vec -! -[ +position +. / / / -( -PatternID -: -: -must -( -1 -) -13 -18 -) / / / -( -PatternID -: -: -must -( -0 -) -28 -33 -) +haystack +may +be +any +type +that +is +cheaply +convertible +to +a +& +[ +u8 +] +. / / / -( -PatternID -: -: -must -( -2 -) -43 -50 -) +This +includes +but +is +not +limited +to +String +& +str +Vec +< +u8 +> +and / / / +& +[ +u8 ] -) -; +itself +. +/ / / / / / +# +Examples / / / / -This -example -shows -how -to -replace -matches -with -some -other -string +/ +/ +Basic +usage : / / @@ -1826,670 +1665,529 @@ AhoCorasick / / let -patterns +ac = +AhoCorasick +: +: +new +( & [ -" -fox -" -" -brown -" -" -quick -" -] -; / / / -let -haystack -= " -The -quick -brown -fox -. +foo " -; -/ -/ -/ -let -replace_with -= -& -[ " -sloth +bar " " -grey +quux " " -slow +baz " -] -; -/ -/ -/ / / / -let -ac -= -AhoCorasick -: -: -new -( -patterns -) -. -unwrap -( +] ) ; / / / -let -result -= +assert +! +( ac . -replace_all +is_match ( -haystack -replace_with +" +xxx +bar +xxx +" +) ) ; / / / -assert_eq +assert ! ( -result -" -The -slow -grey -sloth +! +ac . +is_match +( +" +xxx +qux +xxx " ) +) ; / / / -# +pub +fn +is_match +< +B +: +AsRef +< [ -derive +u8 +] +> +> ( -Clone +& +self +haystack +: +B ) -] -pub -struct -AhoCorasick -{ -/ -/ -/ -The -underlying -Aho - -Corasick -automaton +> +bool +{ +self . -It -' -s -one -of +earliest_find +( +haystack +) +. +is_some +( +) +} / / / -nfa -: -: -noncontiguous -: -: -NFA -nfa -: -: -contiguous -: -: -NFA -or -dfa -: -: -DFA +Returns +the +location +of +the +first +detected +match +in +haystack . -aut -: -Arc -< -dyn -AcAutomaton -> / / / -The -specific -Aho -- -Corasick -kind -chosen -. -This -makes -it -possible -to / / / -inspect -any -AhoCorasick -and -know -what -kind +This +method +has +the +same +behavior +regardless of -search -strategy -it -/ +the / / -uses -. -kind -: -AhoCorasickKind / -/ -/ -The -start -kind -of -this -automaton -as -configured -by -the -caller +[ +MatchKind +] +( +enum . +MatchKind +. +html +) / / / -/ -/ -/ -We -don -' -t -really -* -need -* -to -put +of this -here -since -the -underlying automaton +. / / / -will -correctly -return -errors -if -the -caller -requests -an -unsupported / / / -search +haystack +may +be +any type -. -But -we -do -keep -this -here -for -API -behavior -consistency +that +is +cheaply +convertible +to +a +& +[ +u8 +] . / / / -Namely -the -NFAs -in -this -crate -support -both -unanchored +This +includes +but +is +not +limited +to +String +& +str +Vec +< +u8 +> and -anchored / / / -searches -unconditionally -. -There -' -s -no -way -to -disable -one -or -the -other +& +[ +u8 +] +itself . / / / -They -always -both -work -. -But -the -DFA -in -this -crate -specifically -only / / / -supports -both -unanchored -and -anchored -searches -if -it -' -s -configured -to +# +Examples / / / -do -so -. -Why -? -Because -for -the -DFA -supporting -both -essentially -requires / / / -two -copies -of -the -transition -table +Basic +usage : -one -generated -by -following -failure -/ -/ -/ -transitions -from -the -original -NFA -and -one -generated -by -not -following / / / -those -failure -transitions -. / / / / / / -So -why -record -the -start -kind -here -? -Well -consider -what -happens +use +aho_corasick +: +: +AhoCorasick +; / / / -when -no -specific -' -AhoCorasickKind -' -is -selected -by -the -caller -and / / / -' -StartKind +let +ac += +AhoCorasick : : -Unanchored -' -is -used +new ( -both -are -the -default -) -. -It -* -might -* +& +[ / / / -result -in -using -a -DFA -or -it -might -pick -an -NFA -. -If -it -picks -an -NFA -the +" +abc +" +" +b +" / / / -caller -would -then -be -able -to -run -anchored -searches -even -though -the +] +) +; / / / -caller -only -asked -for -support -for -unanchored -searches +let +mat += +ac . -Maybe -that -' -s +earliest_find +( +" +abcd +" +) +. +expect +( +" +should +have +match +" +) +; / / / -fine -but -what -if -the -DFA -was -chosen -instead -? -Oops -the -caller -would +assert_eq +! +( +1 +mat +. +pattern +( +) +) +; / / / -get -an -error +assert_eq +! +( +( +1 +2 +) +( +mat +. +start +( +) +mat . +end +( +) +) +) +; / / / +pub +fn +earliest_find +< +B +: +AsRef +< +[ +u8 +] +> +> +( +& +self +haystack +: +B +) +- +> +Option +< +Match +> +{ +let +mut +prestate += +PrefilterState +: +: +new +( +self +. +max_pattern_len +( +) +) +; +let +mut +start += +self +. +imp +. +start_state +( +) +; +self +. +imp +. +earliest_find_at +( +& +mut +prestate +haystack +. +as_ref +( +) +0 +& +mut +start +) +} / / / -Basically -it -seems -bad +Returns +the +location +of +the +first +match +according to -return -an -error -or -not -based -on -some +the +match / / / -internal -implementation -choice +semantics +that +this +automaton +was +constructed +with . -So -we -smooth -things -out -and -ensure -/ -/ -/ -anchored -searches -* -always -* -report -an -error -when -only -unanchored -support / / / -was -asked -for -( -and -vice -versa -) -even -if -the -underlying -automaton / / / -supports -it -. -start_kind +When +using +MatchKind : -StartKind -} +: +Standard +this +corresponds +precisely +to +the / / / -Convenience -constructors -for -an -Aho -- -Corasick -searcher -. -To -configure -the +same +behavior +as / / / -searcher -use -an [ -AhoCorasickBuilder +earliest_find ] -instead +( +struct . -impl AhoCorasick -{ +. +html +# +method +. +earliest_find +) +. / / / -Create -a -new -Aho +Otherwise +match +semantics +correspond +to +either +/ +/ +/ +[ +leftmost - -Corasick -automaton -using -the -default -configuration +first +] +( +enum +. +MatchKind +. +html +# +variant . +LeftmostFirst +) / / / -/ -/ -/ -The -default -configuration -optimizes -for -less -space -usage -but -at -the -/ -/ -/ -expense -of -longer -search -times -. -To -change -the -configuration -use +or / / / [ -AhoCorasickBuilder +leftmost +- +longest ] +( +enum +. +MatchKind +. +html +# +variant +. +LeftmostLongest +) . / / @@ -2497,55 +2195,48 @@ AhoCorasickBuilder / / / -This -uses -the -default +haystack +may +be +any +type +that +is +cheaply +convertible +to +a +& [ -MatchKind -: -: -Standard +u8 ] -match -semantics -which +. / / / -reports -a -match -as -soon -as -it -is -found -. This -corresponds +includes +but +is +not +limited to -the -/ -/ -/ -standard -match -semantics -supported -by -textbook -descriptions -of -the +String +& +str +Vec +< +u8 +> +and / / / -Aho -- -Corasick -algorithm +& +[ +u8 +] +itself . / / @@ -2563,6 +2254,9 @@ Examples / Basic usage +with +standard +semantics : / / @@ -2578,8 +2272,8 @@ aho_corasick : : { -AhoCorasick -PatternID +AhoCorasickBuilder +MatchKind } ; / @@ -2589,180 +2283,287 @@ PatternID / / let -ac +patterns = -AhoCorasick -: -: -new -( & [ " -foo +b " " -bar +abc " " -baz +abcd " ] -) -. -unwrap -( -) ; / / / -assert_eq -! +let +haystack += +" +abcd +" +; +/ +/ +/ +/ +/ +/ +let +ac += +AhoCorasickBuilder +: +: +new ( +) / / / -Some +. +match_kind ( -PatternID +MatchKind : : -must -( -1 +Standard ) +/ +/ +default +not +necessary +/ +/ +/ +. +build +( +patterns ) +; / / / +let +mat += ac . find ( +haystack +) +. +expect +( " -xxx -bar -xxx +should +have +a +match " ) +; +/ +/ +/ +assert_eq +! +( +" +b +" +& +haystack +[ +mat . -map +start ( -| -m -| -m +) . -pattern +. +mat +. +end ( ) +] ) +; / / / -) -; / / / -pub -fn -new -< -I -P -> -( -patterns -: -I -) +/ +/ +/ +Now +with +leftmost - -> -Result -< -AhoCorasick -BuildError -> -where -I +first +semantics : -IntoIterator -< -Item -= -P -> -P +/ +/ +/ +/ +/ +/ +/ +/ +/ +use +aho_corasick : -AsRef -< +: +{ +AhoCorasickBuilder +MatchKind +} +; +/ +/ +/ +/ +/ +/ +let +patterns += +& [ -u8 +" +b +" +" +abc +" +" +abcd +" ] -> -{ +; +/ +/ +/ +let +haystack += +" +abcd +" +; +/ +/ +/ +/ +/ +/ +let +ac += AhoCorasickBuilder : : new ( ) -. -build -( -patterns -) -} / / / -A -convenience -method -for -returning -a -new -Aho -- -Corasick -builder . +match_kind +( +MatchKind +: +: +LeftmostFirst +) / / / +. +build +( +patterns +) +; / / / -This -usually -permits -one -to -just -import -the -AhoCorasick -type +let +mat += +ac +. +find +( +haystack +) . +expect +( +" +should +have +a +match +" +) +; / / / +assert_eq +! +( +" +abc +" +& +haystack +[ +mat +. +start +( +) +. +. +mat +. +end +( +) +] +) +; / / / -# -Examples / / / / / / -Basic -usage +And +finally +leftmost +- +longest +semantics : / / @@ -2778,8 +2579,7 @@ aho_corasick : : { -AhoCorasick -Match +AhoCorasickBuilder MatchKind } ; @@ -2790,12 +2590,44 @@ MatchKind / / let +patterns += +& +[ +" +b +" +" +abc +" +" +abcd +" +] +; +/ +/ +/ +let +haystack += +" +abcd +" +; +/ +/ +/ +/ +/ +/ +let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / @@ -2807,7 +2639,7 @@ match_kind MatchKind : : -LeftmostFirst +LeftmostLongest ) / / @@ -2815,22 +2647,30 @@ LeftmostFirst . build ( -& -[ -" -samwise -" -" -sam -" -] +patterns ) +; / / / +let +mat += +ac . -unwrap +find +( +haystack +) +. +expect ( +" +should +have +a +match +" ) ; / @@ -2839,28 +2679,25 @@ unwrap assert_eq ! ( -Some -( -Match -: -: -must +" +abcd +" +& +haystack +[ +mat +. +start ( -0 -0 +) . . -7 -) -) -ac +mat . -find +end ( -" -samwise -" ) +] ) ; / @@ -2868,152 +2705,88 @@ samwise / pub fn -builder -( -) -- -> -AhoCorasickBuilder -{ -AhoCorasickBuilder +find +< +B +: +AsRef +< +[ +u8 +] +> +> +( +& +self +haystack +: +B +) +- +> +Option +< +Match +> +{ +let +mut +prestate += +PrefilterState : : new ( +self +. +max_pattern_len +( ) -} -} -/ -/ -/ -Infallible -search -routines +) +; +self . -These -APIs -panic -when -the -underlying -search -/ -/ -/ -would -otherwise -fail +imp . -Infallible -routines -are -useful -because -the -errors -are -/ -/ -/ -a -result -of -both -search -- -time -configuration -and -what -configuration -is -used -/ -/ -/ -to -build -the -Aho -- -Corasick -searcher +find_at_no_state +( +& +mut +prestate +haystack . -Both -of -these -things -are -not -usually +as_ref +( +) +0 +) +} / / / -the -result -of -user -input -and -thus +Returns an -error -is -typically -indicative -of -a -/ -/ -/ -programmer -error -. -In -cases -where -callers -want -errors -instead +iterator of -panics -use -/ -/ -/ -the -corresponding -try -method -in +non +- +overlapping +matches +using the -section -below -. -impl -AhoCorasick -{ +match / / / -Returns -true -if -and -only -if +semantics +that this automaton -matches -the -haystack -at -any -/ -/ -/ -position +was +constructed +with . / / @@ -3021,7 +2794,7 @@ position / / / -input +haystack may be any @@ -3031,26 +2804,38 @@ is cheaply convertible to -an -Input +a +& +[ +u8 +] . -This / / / +This includes but is not limited to +String & str +Vec +< +u8 +> and +/ +/ +/ & [ u8 ] +itself . / / @@ -3058,155 +2843,189 @@ u8 / / / -Aside -from -convenience -when -AhoCorasick -was -built -with +# +Examples / / / -leftmost -- -first -or -leftmost -- -longest -semantics -this -might -result -in -a / / / -search -that -visits -less -of -the -haystack -than -[ -AhoCorasick -: +Basic +usage +with +standard +semantics : -find -] / / / -would -otherwise -. -( -For -standard -semantics -matches -are -always / / / -immediately -returned -once -they -are -seen -so -there -is -no -way -for -this -to / / / -do -less -work -in -that -case -. -) +use +aho_corasick +: +: +{ +AhoCorasickBuilder +MatchKind +} +; / / / / / / -Note -that -there -is -no -corresponding -fallible -routine -for -this -method -. +let +patterns += +& +[ +" +append +" +" +appendage +" +" +app +" +] +; / / / -If -you -need -a -fallible -version -of -this -then -[ -AhoCorasick +let +haystack += +" +append +the +app +to +the +appendage +" +; +/ +/ +/ +/ +/ +/ +let +ac += +AhoCorasickBuilder : : -try_find -] +new +( +) / / / -can -be -used -with -[ -Input +. +match_kind +( +MatchKind : : -earliest -] -enabled +Standard +) +/ +/ +default +not +necessary +/ +/ +/ . +build +( +patterns +) +; +/ +/ +/ +let +matches +: +Vec +< +usize +> += +ac / / / +. +find_iter +( +haystack +) / / / -# -Examples +. +map +( +| +mat +| +mat +. +pattern +( +) +) / / / +. +collect +( +) +; / / / -Basic -usage +assert_eq +! +( +vec +! +[ +2 +2 +2 +] +matches +) +; +/ +/ +/ +/ +/ +/ +/ +/ +/ +Now +with +leftmost +- +first +semantics : / / @@ -3221,7 +3040,10 @@ use aho_corasick : : -AhoCorasick +{ +AhoCorasickBuilder +MatchKind +} ; / / @@ -3230,273 +3052,144 @@ AhoCorasick / / let -ac +patterns = -AhoCorasick -: -: -new -( & [ -/ -/ -/ " -foo +append " " -bar +appendage " " -quux +app " +] +; +/ +/ +/ +let +haystack += " -baz +append +the +app +to +the +appendage " +; / / / -] -) -. -unwrap +/ +/ +/ +let +ac += +AhoCorasickBuilder +: +: +new ( ) -; / / / -assert -! -( -ac . -is_match +match_kind ( -" -xxx -bar -xxx -" -) +MatchKind +: +: +LeftmostFirst ) -; / / / -assert -! -( -! -ac . -is_match +build ( -" -xxx -qux -xxx -" -) +patterns ) ; / / / -pub -fn -is_match -< -' -h -I +let +matches : -Into -< -Input +Vec < -' -h -> -> +usize > -( -& -self -input -: -I -) -- -> -bool -{ -self -. -aut -. -try_find -( -& -input -. -into -( -) -. -earliest -( -true -) -) -. -expect -( -" -AhoCorasick -: -: -try_find -is -not -expected -to -fail -" -) -. -is_some -( -) -} -/ -/ -/ -Returns -the -location -of -the -first -match -according -to -the -match += +ac / / / -semantics -that -this -automaton -was -constructed -with . +find_iter +( +haystack +) / / / -/ -/ -/ -input -may -be -any -type -that -is -cheaply -convertible -to -an -Input . -This -/ -/ -/ -includes -but -is -not -limited -to -& -str -and -& -[ -u8 -] +map +( +| +mat +| +mat . +pattern +( +) +) / / / -/ -/ -/ -This -is -the -infallible -version -of -[ -AhoCorasick -: -: -try_find -] . +collect +( +) +; / / / -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when +assert_eq +! +( +vec +! [ -AhoCorasick -: -: -try_find +0 +2 +0 ] -would -return -an -error -. -/ -/ -/ +matches +) +; / / / -# -Examples / / / / / / -Basic -usage -with -standard +And +finally +leftmost +- +longest semantics : / @@ -3513,7 +3206,7 @@ aho_corasick : : { -AhoCorasick +AhoCorasickBuilder MatchKind } ; @@ -3529,13 +3222,13 @@ patterns & [ " -b +append " " -abc +appendage " " -abcd +app " ] ; @@ -3546,7 +3239,12 @@ let haystack = " -abcd +append +the +app +to +the +appendage " ; / @@ -3558,10 +3256,10 @@ abcd let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / @@ -3573,371 +3271,323 @@ match_kind MatchKind : : -Standard +LeftmostLongest ) / / -default -not -necessary -/ -/ / . build ( patterns ) -/ -/ -/ -. -unwrap -( -) ; / / / let -mat +matches +: +Vec +< +usize +> = ac +/ +/ +/ . -find +find_iter ( haystack ) -. -expect -( -" -should -have -a -match -" -) -; / / / -assert_eq -! -( -" -b -" -& -haystack -[ -mat . -start +map ( -) -. -. +| +mat +| mat . -end +pattern ( ) -] ) -; -/ -/ -/ / / / +. +collect +( +) +; / / / -Now -with -leftmost -- -first -semantics -: +assert_eq +! +( +vec +! +[ +0 +2 +1 +] +matches +) +; / / / +pub +fn +find_iter +< +' +a +' +b +B +: +? +Sized ++ +AsRef +< +[ +u8 +] +> +> +( +& +' +a +self +haystack +: +& +' +b +B +) +- +> +FindIter +< +' +a +' +b +S +> +{ +FindIter +: +: +new +( +self +haystack +. +as_ref +( +) +) +} / / / +Returns +an +iterator +of +overlapping +matches +in +the +given +haystack +. / / / -use -aho_corasick -: -: -{ -AhoCorasick -MatchKind -} -; / / / +Overlapping +matches +can +_only_ +be +detected +using / / / -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; +MatchKind +: +: +Standard +semantics +. +If +this +automaton +was +constructed +with / / / -let -haystack -= -" -abcd -" -; +leftmost +semantics +then +this +method +will +panic +. +To +determine +whether / / / +this +will +panic +at +runtime +use +the / / / -let -ac -= +[ AhoCorasick : : -builder +supports_overlapping +] ( +struct +. +AhoCorasick +. +html +# +method +. +supports_overlapping ) / / / +method . -match_kind -( -MatchKind -: -: -LeftmostFirst -) / / / -. -build -( -patterns -) / / / +haystack +may +be +any +type +that +is +cheaply +convertible +to +a +& +[ +u8 +] . -unwrap -( -) -; / / / -let -mat -= -ac -. -find -( -haystack -) -. -expect -( -" -should -have -a -match -" -) -; +This +includes +but +is +not +limited +to +String +& +str +Vec +< +u8 +> +and / / / -assert_eq -! -( -" -abc -" & -haystack [ -mat -. -start -( -) -. -. -mat -. -end -( -) +u8 ] -) -; +itself +. / / / / / / -/ -/ -/ -And -finally -leftmost -- -longest -semantics -: +# +Panics / / / / / / -/ -/ -/ -use -aho_corasick +This +panics +when +AhoCorasick : : -{ -AhoCorasick -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let -haystack -= -" -abcd -" -; -/ -/ -/ +supports_overlapping +returns +false +. / / / -let -ac -= -AhoCorasick -: -: -builder -( -) +That +is +this +panics +when +this +automaton +' +s +match +semantics +are +not / / / -. -match_kind -( MatchKind : : -LeftmostLongest -) -/ -/ -/ -. -build -( -patterns -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -mat -= -ac -. -find -( -haystack -) +Standard . -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ / / / @@ -3945,86 +3595,19 @@ match / / # -Example -: -configuring -a -search -/ -/ -/ -/ -/ -/ -Because -this -method -accepts -anything -that -can -be -turned -into -an -/ -/ -/ -[ -Input -] -it -' -s -possible -to -provide -an -Input -directly -in -order -to -/ -/ -/ -configure -the -search -. -In -this -example -we -show -how -to -use -the +Examples / / / -earliest -option -to -force -the -search -to -return -as -soon -as -it -knows / / / -a -match -has -occurred -. +Basic +usage +with +standard +semantics +: / / / @@ -4038,11 +3621,7 @@ use aho_corasick : : -{ AhoCorasick -Input -MatchKind -} ; / / @@ -4056,13 +3635,13 @@ patterns & [ " -b +append " " -abc +appendage " " -abcd +app " ] ; @@ -4073,7 +3652,12 @@ let haystack = " -abcd +append +the +app +to +the +appendage " ; / @@ -4088,148 +3672,71 @@ ac AhoCorasick : : -builder +new ( +patterns ) +; +/ +/ +/ +let +matches +: +Vec +< +usize +> += +ac / / / . -match_kind +find_overlapping_iter ( -MatchKind -: -: -LeftmostLongest +haystack ) / / / . -build +map ( -patterns +| +mat +| +mat +. +pattern +( +) ) / / / . -unwrap +collect ( ) ; / / / -let -mat -= -ac -. -find -( -Input -: -: -new -( -haystack -) -. -earliest -( -true -) -) -/ -/ -/ -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -/ -/ -The -correct -leftmost -- -longest -match -here -is -' -abcd -' -but -since -we -/ -/ -/ -/ -/ -told -the -search -to -quit -as -soon -as -it -knows -a -match -has -occurred -/ -/ -/ -/ -/ -we -get -a -different -match -back -. -/ -/ -/ assert_eq ! ( -" -b -" -& -haystack +vec +! [ -mat -. -start -( -) -. -. -mat -. -end -( -) +2 +0 +2 +2 +0 +1 ] +matches ) ; / @@ -4237,85 +3744,105 @@ end / pub fn -find +find_overlapping_iter < ' -h -I +a +' +b +B : -Into -< -Input +? +Sized ++ +AsRef < -' -h -> +[ +u8 +] > > ( & +' +a self -input +haystack : -I +& +' +b +B ) - > -Option +FindOverlappingIter < -Match +' +a +' +b +S > { +FindOverlappingIter +: +: +new +( self +haystack . -try_find +as_ref ( -input ) -. -expect -( -" -AhoCorasick -: -: -try_find -is -not -expected -to -fail -" ) } / / / -Returns -the -location -of -the -first -overlapping -match +Replace +all +matches +with +a +corresponding +value in the -given +replace_with / / / -input -with -respect +slice +given +. +Matches +correspond to the -current -state -of -the -underlying -searcher +same +matches +as +reported +by +/ +/ +/ +[ +find_iter +] +( +struct +. +AhoCorasick +. +html +# +method +. +find_iter +) . / / @@ -4323,97 +3850,41 @@ searcher / / / -input -may -be -any -type -that -is -cheaply -convertible -to -an -Input +Replacements +are +determined +by +the +index +of +the +matching +pattern . -This / / / -includes -but +For +example +if +the +pattern +with +index +2 is -not -limited -to -& -str -and -& +found +then +it +is +/ +/ +/ +replaced +by +replace_with [ -u8 -] -. -/ -/ -/ -/ -/ -/ -Overlapping -searches -do -not -report -matches -in -their -return -value -. -/ -/ -/ -Instead -matches -can -be -accessed -via -[ -OverlappingState -: -: -get_match -] -/ -/ -/ -after -a -search -call -. -/ -/ -/ -/ -/ -/ -This -is -the -infallible -version -of -/ -/ -/ -[ -AhoCorasick -: -: -try_find_overlapping +2 ] . / @@ -4433,58 +3904,29 @@ Panics This panics when -[ -AhoCorasick -: -: -try_find_overlapping -] -would -/ -/ -/ -return -an -error -. -For -example -when -the -Aho -- -Corasick -searcher -/ -/ -/ -doesn -' -t -support -overlapping -searches +replace_with . +len ( -Only -searchers -built -with +) +does +not +equal +the +total +number / / / -[ -MatchKind -: -: -Standard -] -semantics -support -overlapping -searches +of +patterns +that +are +matched +by +this +automaton . -) / / / @@ -4492,59 +3934,16 @@ searches / / # -Example -/ -/ -/ -/ -/ -/ -This -shows -how -we -can -repeatedly -call -an -overlapping -search -without -/ -/ -/ -ever -needing -to -explicitly -re -- -slice -the -haystack -. -Overlapping -search +Examples / / / -works -this -way -because -searches -depend -on -state -saved -during -the / / / -previous -search -. +Basic +usage +: / / / @@ -4559,22 +3958,8 @@ aho_corasick : : { -/ -/ -/ -automaton -: -: -OverlappingState -/ -/ -/ -AhoCorasick -Input -Match -/ -/ -/ +AhoCorasickBuilder +MatchKind } ; / @@ -4623,46 +4008,55 @@ appendage let ac = -AhoCorasick +AhoCorasickBuilder : : new ( -patterns -) -. -unwrap -( ) -; / / / -let -mut -state -= -OverlappingState +. +match_kind +( +MatchKind : : -start -( +LeftmostFirst ) -; / / / +. +build +( +patterns +) +; / / / +let +result += ac . -find_overlapping +replace_all ( haystack & -mut -state +[ +" +x +" +" +y +" +" +z +" +] ) ; / @@ -4671,449 +4065,264 @@ state assert_eq ! ( -Some -( -Match -: -: -must -( -2 -0 -. -. -3 -) -) -state -. -get_match -( -) +" +x +the +z +to +the +xage +" +result ) ; / / / -/ -/ -/ -ac -. -find_overlapping +pub +fn +replace_all +< +B +> ( +& +self haystack +: & -mut -state -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match +str +replace_with : +& +[ +B +] +) +- +> +String +where +B : -must +AsRef +< +str +> +{ +assert_eq +! ( -0 -0 -. +replace_with . -6 -) +len +( ) -state +self . -get_match +pattern_count ( ) +" +replace_all +requires +a +replacement +for +every +pattern +\ +in +the +automaton +" ) ; -/ -/ -/ -/ -/ -/ -ac -. -find_overlapping -( -haystack -& +let mut -state -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match +dst += +String : : -must +with_capacity ( -2 -11 -. -. -14 -) -) -state +haystack . -get_match +len ( ) ) ; -/ -/ -/ -/ -/ -/ -ac +self . -find_overlapping +replace_all_with ( haystack & mut -state -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -22 +dst +| +mat +_ +dst +| +{ +dst . +push_str +( +replace_with +[ +mat . -25 -) +pattern +( ) -state +] . -get_match +as_ref ( ) ) ; +true +} +) +; +dst +} / / / +Replace +all +matches +using +raw +bytes +with +a +corresponding +value +in +the / / / -ac +replace_with +slice +given . -find_overlapping -( -haystack -& -mut -state -) -; +Matches +correspond +to +the +same +matches +as / / / -assert_eq -! -( -Some -( -Match -: -: -must +reported +by +[ +find_iter +] ( -0 -22 +struct . +AhoCorasick . -28 -) -) -state +html +# +method . -get_match -( -) +find_iter ) -; +. / / / / / / -ac +Replacements +are +determined +by +the +index +of +the +matching +pattern . -find_overlapping -( -haystack -& -mut -state -) -; / / / -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -22 -. -. -31 -) -) -state -. -get_match -( -) -) -; +For +example +if +the +pattern +with +index +2 +is +found +then +it +is / / / +replaced +by +replace_with +[ +2 +] +. / / / / / -No -more -match -matches -to -be -found -. -/ / -/ -ac -. -find_overlapping -( -haystack -& -mut -state -) -; +# +Panics / / / -assert_eq -! -( -None -state -. -get_match -( -) -) -; / / / -pub -fn -find_overlapping -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -input -: -I -state -: -& -mut -OverlappingState -) -{ -self +This +panics +when +replace_with . -try_find_overlapping +len ( -input -state ) -. -expect -( -" -AhoCorasick -: -: -try_find_overlapping -is +does not -expected -to -fail -" -) -} -/ -/ -/ -Returns -an -iterator -of -non -- -overlapping -matches -using +equal the -match +total +number / / / -semantics +of +patterns that +are +matched +by this automaton -was -constructed -with -. -/ -/ -/ -/ -/ -/ -input -may -be -any -type -that -is -cheaply -convertible -to -an -Input -. -This -/ -/ -/ -includes -but -is -not -limited -to -& -str -and -& -[ -u8 -] -. -/ -/ -/ -/ -/ -/ -This -is -the -infallible -version -of -[ -AhoCorasick -: -: -try_find_iter -] -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -[ -AhoCorasick -: -: -try_find_iter -] -would -return -an -error . / / @@ -5131,9 +4340,6 @@ Examples / Basic usage -with -standard -semantics : / / @@ -5149,9 +4355,8 @@ aho_corasick : : { -AhoCorasick +AhoCorasickBuilder MatchKind -PatternID } ; / @@ -5182,6 +4387,7 @@ app let haystack = +b " append the @@ -5200,10 +4406,10 @@ appendage let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / @@ -5215,133 +4421,315 @@ match_kind MatchKind : : -Standard +LeftmostFirst ) / / -default -not -necessary -/ -/ / . build ( patterns ) -/ -/ -/ -. -unwrap -( -) ; / / / let -matches -: -Vec -< -PatternID -> +result = ac -/ -/ -/ . -find_iter +replace_all_bytes ( haystack +& +[ +" +x +" +" +y +" +" +z +" +] ) +; / / / -. -map +assert_eq +! ( -| -mat -| -mat +b +" +x +the +z +to +the +xage +" . -pattern +to_vec ( ) -) -/ -/ -/ -. -collect -( +result ) ; / / / -assert_eq -! -( -vec -! -[ -/ -/ -/ -PatternID +pub +fn +replace_all_bytes +< +B +> +( +& +self +haystack +: +& +[ +u8 +] +replace_with : +& +[ +B +] +) +- +> +Vec +< +u8 +> +where +B : -must +AsRef +< +[ +u8 +] +> +{ +assert_eq +! ( -2 +replace_with +. +len +( +) +self +. +pattern_count +( +) +" +replace_all_bytes +requires +a +replacement +for +every +pattern +\ +in +the +automaton +" ) +; +let +mut +dst += +Vec +: +: +with_capacity +( +haystack +. +len +( +) +) +; +self +. +replace_all_with_bytes +( +haystack +& +mut +dst +| +mat +_ +dst +| +{ +dst +. +extend +( +replace_with +[ +mat +. +pattern +( +) +] +. +as_ref +( +) +) +; +true +} +) +; +dst +} / / / -PatternID -: -: -must +Replace +all +matches +using +a +closure +called +on +each +match +. +/ +/ +/ +Matches +correspond +to +the +same +matches +as +reported +by +/ +/ +/ +[ +find_iter +] ( -2 +struct +. +AhoCorasick +. +html +# +method +. +find_iter ) +. / / / -PatternID -: +/ +/ +/ +The +closure +accepts +three +parameters : -must +the +match +found +the +text +of +/ +/ +/ +the +match +and +a +string +buffer +with +which +to +write +the +replaced +text +/ +/ +/ ( -2 +if +any ) +. +If +the +closure +returns +true +then +it +continues +to +the +next / / / -] -matches -) -; +match +. +If +the +closure +returns +false +then +searching +is +stopped +. / / / / / / +# +Examples / / / -Now -with -leftmost -- -first -semantics +/ +/ +/ +Basic +usage : / / @@ -5357,9 +4745,8 @@ aho_corasick : : { -AhoCorasick +AhoCorasickBuilder MatchKind -PatternID } ; / @@ -5408,10 +4795,10 @@ appendage let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / @@ -5433,118 +4820,109 @@ build ( patterns ) +; / / / -. -unwrap +let +mut +result += +String +: +: +new ( ) ; / / / -let -matches -: -Vec -< -PatternID -> -= ac -/ -/ -/ . -find_iter +replace_all_with ( haystack -) +& +mut +result +| +mat +_ +dst +| +{ / / / +dst . -map +push_str ( -| -mat -| +& mat . pattern ( ) -) -/ -/ -/ . -collect +to_string ( ) +) ; / / / -assert_eq -! -( -vec -! -[ -/ -/ -/ -PatternID -: -: -must -( -0 -) +true / / / -PatternID -: -: -must -( -2 +} ) +; / / / -PatternID -: -: -must +assert_eq +! ( +" 0 +the +2 +to +the +0age +" +result ) +; / / / -] -matches -) -; / / / / / / +Stopping +the +replacement +by +returning +false +( +continued +from +the / / / -And -finally -leftmost -- -longest -semantics +example +above +) : / / @@ -5555,22 +4933,20 @@ semantics / / / +# use aho_corasick : : { -AhoCorasick +AhoCorasickBuilder MatchKind -PatternID } ; / / / -/ -/ -/ +# let patterns = @@ -5590,6 +4966,7 @@ app / / / +# let haystack = @@ -5605,132 +4982,120 @@ appendage / / / -/ -/ -/ +# let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / / / +# . match_kind ( MatchKind : : -LeftmostLongest +LeftmostFirst ) / / / +# . build ( patterns ) +; / / / -. -unwrap +let +mut +result += +String +: +: +new ( ) ; / / / -let -matches -: -Vec -< -PatternID -> -= ac -/ -/ -/ . -find_iter +replace_all_with ( haystack -) +& +mut +result +| +mat +_ +dst +| +{ / / / +dst . -map +push_str ( -| -mat -| +& mat . pattern ( ) -) -/ -/ -/ . -collect +to_string ( ) +) ; / / / -assert_eq -! +mat +. +pattern ( -vec +) ! -[ += +2 / / / -PatternID -: -: -must -( -0 +} ) +; / / / -PatternID -: -: -must +assert_eq +! ( +" +0 +the 2 -) -/ -/ -/ -PatternID -: -: -must -( -1 -) -/ -/ -/ -] -matches +to +the +appendage +" +result ) ; / @@ -5738,127 +5103,176 @@ matches / pub fn -find_iter -< -' -a -' -h -I -: -Into -< -Input +replace_all_with < -' -h -> -> +F > ( & -' -a self -input +haystack : -I +& +str +dst +: +& +mut +String +mut +replace_with +: +F +) +where +F +: +FnMut +( +& +Match +& +str +& +mut +String ) - > -FindIter -< -' -a -' -h -> +bool { -self +let +mut +last_match += +0 +; +for +mat +in +self . -try_find_iter +find_iter ( -input +haystack ) +{ +dst . -expect +push_str ( -" -AhoCorasick -: -: -try_find_iter -is -not -expected -to -fail -" +& +haystack +[ +last_match +. +. +mat +. +start +( +) +] +) +; +last_match += +mat +. +end +( +) +; +if +! +replace_with +( +& +mat +& +haystack +[ +mat +. +start +( +) +. +. +mat +. +end +( +) +] +dst ) +{ +break +; } -/ -/ -/ -Returns -an -iterator -of -overlapping -matches +; +} +dst . -Stated -differently -this +push_str +( +& +haystack +[ +last_match +. +. +] +) +; +} / / / -returns -an -iterator -of +Replace all -possible matches -at -every -position -. -/ -/ -/ +using +raw +bytes +with +a +closure +called +on +each / / / -input -may -be -any -type -that -is -cheaply -convertible -to -an -Input +match . -This +Matches +correspond +to +the +same +matches +as +reported +by / / / -includes -but -is -not -limited -to -& -str -and -& [ -u8 +find_iter ] +( +struct +. +AhoCorasick +. +html +# +method +. +find_iter +) . / / @@ -5866,21 +5280,67 @@ u8 / / / -This -is +The +closure +accepts +three +parameters +: the -infallible -version +match +found +the +text of / / / -[ -AhoCorasick -: -: -try_find_overlapping_iter -] +the +match +and +a +byte +buffer +with +which +to +write +the +replaced +text +/ +/ +/ +( +if +any +) +. +If +the +closure +returns +true +then +it +continues +to +the +next +/ +/ +/ +match +. +If +the +closure +returns +false +then +searching +is +stopped . / / @@ -5889,94 +5349,16 @@ try_find_overlapping_iter / / # -Panics +Examples / / / / / / -This -panics -when -AhoCorasick -: +Basic +usage : -try_find_overlapping_iter -would -return -/ -/ -/ -an -error -. -For -example -when -the -Aho -- -Corasick -searcher -is -built -with -/ -/ -/ -either -leftmost -- -first -or -leftmost -- -longest -match -semantics -. -Stated -/ -/ -/ -differently -overlapping -searches -require -one -to -build -the -searcher -/ -/ -/ -with -[ -MatchKind -: -: -Standard -] -( -it -is -the -default -) -. -/ -/ -/ -/ -/ -/ -# -Example -: -basic -usage / / / @@ -5991,8 +5373,8 @@ aho_corasick : : { -AhoCorasick -PatternID +AhoCorasickBuilder +MatchKind } ; / @@ -6023,6 +5405,7 @@ app let haystack = +b " append the @@ -6041,218 +5424,479 @@ appendage let ac = -AhoCorasick +AhoCorasickBuilder : : new ( -patterns ) +/ +/ +/ . -unwrap +match_kind +( +MatchKind +: +: +LeftmostFirst +) +/ +/ +/ +. +build ( +patterns ) ; / / / let -matches -: -Vec -< -PatternID -> +mut +result = -ac +vec +! +[ +] +; / / / +ac . -find_overlapping_iter +replace_all_with_bytes ( haystack -) +& +mut +result +| +mat +_ +dst +| +{ / / / +dst . -map +extend ( -| -mat -| mat . pattern ( ) +. +to_string +( ) -/ -/ -/ . -collect +bytes ( ) +) ; / / / -assert_eq -! -( -vec -! -[ +true / / / -PatternID -: -: -must -( -2 +} ) +; / / / -PatternID -: -: -must +assert_eq +! ( +b +" 0 +the +2 +to +the +0age +" +. +to_vec +( +) +result ) +; / / / -PatternID -: -: -must +/ +/ +/ +/ +/ +/ +Stopping +the +replacement +by +returning +false ( -2 +continued +from +the +/ +/ +/ +example +above ) +: +/ +/ +/ +/ +/ +/ / / / -PatternID +# +use +aho_corasick : : -must -( -2 -) +{ +AhoCorasickBuilder +MatchKind +} +; +/ +/ +/ +# +let +patterns += +& +[ +" +append +" +" +appendage +" +" +app +" +] +; +/ +/ +/ +# +let +haystack += +b +" +append +the +app +to +the +appendage +" +; / / / -PatternID +# +let +ac += +AhoCorasickBuilder : : -must +new ( -0 ) / / / -PatternID +# +. +match_kind +( +MatchKind : : -must -( -1 +LeftmostFirst ) / / / -] -matches +# +. +build +( +patterns ) ; / / / -pub -fn -find_overlapping_iter -< -' -a -' -h -I -: -Into -< -Input +let +mut +result += +vec +! +[ +] +; +/ +/ +/ +ac +. +replace_all_with_bytes +( +haystack +& +mut +result +| +mat +_ +dst +| +{ +/ +/ +/ +dst +. +extend +( +mat +. +pattern +( +) +. +to_string +( +) +. +bytes +( +) +) +; +/ +/ +/ +mat +. +pattern +( +) +! += +2 +/ +/ +/ +} +) +; +/ +/ +/ +assert_eq +! +( +b +" +0 +the +2 +to +the +appendage +" +. +to_vec +( +) +result +) +; +/ +/ +/ +pub +fn +replace_all_with_bytes < -' -h -> -> +F > ( & -' -a self -input +haystack : -I -) -- +& +[ +u8 +] +dst +: +& +mut +Vec +< +u8 > -FindOverlappingIter +mut +replace_with +: +F +) +where +F +: +FnMut +( +& +Match +& +[ +u8 +] +& +mut +Vec < -' -a -' -h +u8 +> +) +- > +bool { +let +mut +last_match += +0 +; +for +mat +in self . -try_find_overlapping_iter +find_iter ( -input +haystack ) +{ +dst . -expect +extend ( -" -AhoCorasick -: -: -try_find_overlapping_iter -is -not -expected -to -fail -" +& +haystack +[ +last_match +. +. +mat +. +start +( +) +] +) +; +last_match += +mat +. +end +( +) +; +if +! +replace_with +( +& +mat +& +haystack +[ +mat +. +start +( +) +. +. +mat +. +end +( +) +] +dst +) +{ +break +; +} +; +} +dst +. +extend +( +& +haystack +[ +last_match +. +. +] ) +; } / / / -Replace -all +Returns +an +iterator +of +non +- +overlapping matches -with -a -corresponding -value in the -replace_with +given / / / -slice -given +stream . Matches correspond @@ -6267,73 +5911,102 @@ by / / [ -AhoCorasick -: -: find_iter ] +( +struct +. +AhoCorasick +. +html +# +method +. +find_iter +) . / -/ -/ -/ -/ -/ -Replacements -are -determined +/ +/ +/ +/ +/ +The +matches +yielded by +this +iterator +use +absolute +position +offsets +in +/ +/ +/ the -index -of +stream +given +where the -matching -pattern +first +byte +has +index +0 . +Matches +are / / / -For -example -if +yieled +until the -pattern -with -index -2 -is -found -then -it +stream is +exhausted +. / / / -replaced -by -replace_with -[ -2 -] -. / / / +Each +item +yielded +by +the +iterator +is +an +io +: +: +Result +< +Match +> +where +an / / / -This +error is +yielded +if +there +was +a +problem +reading +from the -infallible -version -of -[ -AhoCorasick -: -: -try_replace_all -] +reader +given . / / @@ -6341,49 +6014,85 @@ try_replace_all / / / -# -Panics +When +searching +a +stream +an +internal +buffer +is +used +. +Therefore +callers / / / +should +avoiding +providing +a +buffered +reader +if +possible +. / / / -This -panics -when -[ -AhoCorasick -: -: -try_replace_all -] -would -return -an / / / -error -. +Searching +a +stream +requires +that +the +automaton +was +built +with / / / +MatchKind +: +: +Standard +semantics +. +If +this +automaton +was +constructed / / / -This -also -panics -when -replace_with +with +leftmost +semantics +then +this +method +will +panic . -len -( -) -does -not -equal +To +determine +/ +/ +/ +whether +this +will +panic +at +runtime +use +the / / / @@ -6391,8 +6100,23 @@ equal AhoCorasick : : -patterns_len +supports_stream ] +( +struct +. +AhoCorasick +. +html +# +method +. +supports_stream +) +/ +/ +/ +method . / / @@ -6401,9 +6125,7 @@ patterns_len / / # -Example -: -basic +Memory usage / / @@ -6411,28 +6133,195 @@ usage / / / +In +general +searching +streams +will +use +a +constant +amount +of +memory +for / / / -use -aho_corasick -: -: -{ -AhoCorasick -MatchKind -} -; +its +internal +buffer +. +The +one +requirement +is +that +the +internal +buffer / / / +must +be +at +least +the +size +of +the +longest +possible +match +. +In +most +use / / / -let -patterns -= -& +cases +the +default +buffer +size +will +be +much +larger +than +any +individual +/ +/ +/ +match +. +/ +/ +/ +/ +/ +/ +# +Panics +/ +/ +/ +/ +/ +/ +This +panics +when +AhoCorasick +: +: +supports_stream +returns +false +. +/ +/ +/ +That +is +this +panics +when +this +automaton +' +s +match +semantics +are +not +/ +/ +/ +MatchKind +: +: +Standard +. +This +restriction +may +be +lifted +in +the +future +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Basic +usage +: +/ +/ +/ +/ +/ +/ +/ +/ +/ +use +aho_corasick +: +: +AhoCorasick +; +/ +/ +/ +/ +/ +/ +# +fn +example +( +) +- +> +Result +< +( +) +: +: +std +: +: +io +: +: +Error +> +{ +/ +/ +/ +let +patterns += +& [ " append @@ -6472,156 +6361,175 @@ ac AhoCorasick : : -builder +new ( +patterns ) +; / / / -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) +let +mut +matches += +vec +! +[ +] +; / / / +for +result +in +ac . -build +stream_find_iter +( +haystack +. +as_bytes ( -patterns ) +) +{ +/ +/ +/ +let +mat += +result +? +; / / / +matches . -unwrap +push +( +mat +. +pattern ( ) +) ; / / / -let -result -= -ac -. -replace_all +} +/ +/ +/ +assert_eq +! ( -haystack -& +vec +! [ -" -x -" -" -y -" -" -z -" +2 +2 +2 ] +matches ) ; / / / -assert_eq -! +# +Ok +( ( -" -x -the -z -to -the -xage -" -result ) +) +} ; +example +( +) +. +unwrap +( +) / / / pub fn -replace_all +stream_find_iter < -B +' +a +R +: +io +: +: +Read > ( & +' +a self -haystack +rdr : -& -str -replace_with -: -& -[ -B -] +R ) - > -String -where -B -: -AsRef +StreamFindIter < -str +' +a +R +S > { -self -. -try_replace_all -( -haystack -replace_with -) -. -expect -( -" -AhoCorasick +StreamFindIter : : -try_replace_all -is -not -expected -to -fail -" +new +( +self +rdr ) } / / / -Replace +Search +for +and +replace all matches -using -raw -bytes -with -a -corresponding -value +of +this +automaton in -the / / / -replace_with -slice +the +given +reader +and +write +the +replacements +to +the given +/ +/ +/ +writer . Matches correspond @@ -6630,17 +6538,25 @@ the same matches as +reported +by / / / -reported -by [ -AhoCorasick -: -: find_iter ] +( +struct +. +AhoCorasick +. +html +# +method +. +find_iter +) . / / @@ -6691,255 +6607,539 @@ replace_with / / / -This -is +After +all +matches +are +replaced the -infallible -version -of +writer +is +_not_ +flushed +. / / / -[ -AhoCorasick -: -: -try_replace_all_bytes -] -. / / / +If +there +was +a +problem +reading +from +the +given +reader +or +writing +to +the / / / -# -Panics +given +writer +then +the +corresponding +io +: +: +Error +is +returned +and +all / / / +replacement +is +stopped +. / / / -This -panics -when -[ -AhoCorasick -: -: -try_replace_all_bytes -] -would -return -an / / / -error +When +searching +a +stream +an +internal +buffer +is +used . +Therefore +callers / / / +should +avoiding +providing +a +buffered +reader +if +possible +. +However / / / -This -also -panics -when -replace_with +callers +may +want +to +provide +a +buffered +writer . -len -( -) -does -not -equal / / / -[ -AhoCorasick -: -: -patterns_len -] -. / / / +Searching +a +stream +requires +that +the +automaton +was +built +with / / / -# -Example +MatchKind : -basic -usage +: +Standard +semantics +. +If +this +automaton +was +constructed / / / +with +leftmost +semantics +then +this +method +will +panic +. +To +determine / / / +whether +this +will +panic +at +runtime +use +the / / / -use -aho_corasick +[ +AhoCorasick : : -{ +supports_stream +] +( +struct +. AhoCorasick -MatchKind -} -; +. +html +# +method +. +supports_stream +) / / / +method +. / / / -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] -; / / / -let -haystack -= -b -" -append +# +Memory +usage +/ +/ +/ +/ +/ +/ +In +general +searching +streams +will +use +a +constant +amount +of +memory +for +/ +/ +/ +its +internal +buffer +. +The +one +requirement +is +that the -app -to +internal +buffer +/ +/ +/ +must +be +at +least the -appendage -" -; +size +of +the +longest +possible +match +. +In +most +use / / / +cases +the +default +buffer +size +will +be +much +larger +than +any +individual / / / -let -ac -= +match +. +/ +/ +/ +/ +/ +/ +# +Panics +/ +/ +/ +/ +/ +/ +This +panics +when AhoCorasick : : -builder -( -) +supports_stream +returns +false +. +/ +/ +/ +That +is +this +panics +when +this +automaton +' +s +match +semantics +are +not / / / -. -match_kind -( MatchKind : : -LeftmostFirst -) +Standard +. +This +restriction +may +be +lifted +in +the +future +. / / / -. -build -( -patterns -) / / / -. -unwrap +# +Examples +/ +/ +/ +/ +/ +/ +Basic +usage +: +/ +/ +/ +/ +/ +/ +/ +/ +/ +use +aho_corasick +: +: +AhoCorasick +; +/ +/ +/ +/ +/ +/ +# +fn +example ( ) -; +- +> +Result +< +( +) +: +: +std +: +: +io +: +: +Error +> +{ / / / let -result +patterns = -ac -. -replace_all_bytes -( -haystack & [ " -x +fox " " -y +brown " " -z +quick " ] -) ; / / / -assert_eq -! -( -b -" -x -the -z -to -the -xage +let +haystack += " +The +quick +brown +fox . -to_vec -( -) -result -) +" ; / / / -pub -fn -replace_all_bytes -< -B -> -( -& -self -haystack -: +let +replace_with += & [ -u8 +" +sloth +" +" +grey +" +" +slow +" +] +; +/ +/ +/ +/ +/ +/ +let +ac += +AhoCorasick +: +: +new +( +patterns +) +; +/ +/ +/ +let +mut +result += +vec +! +[ ] +; +/ +/ +/ +ac +. +stream_replace_all +( +haystack +. +as_bytes +( +) +& +mut +result +replace_with +) +? +; +/ +/ +/ +assert_eq +! +( +b +" +The +slow +grey +sloth +. +" +. +to_vec +( +) +result +) +; +/ +/ +/ +# +Ok +( +( +) +) +} +; +example +( +) +. +unwrap +( +) +/ +/ +/ +pub +fn +stream_replace_all +< +R +W +B +> +( +& +self +rdr +: +R +wtr +: +W replace_with : & @@ -6949,11 +7149,27 @@ B ) - > -Vec +io +: +: +Result < -u8 +( +) > where +R +: +io +: +: +Read +W +: +io +: +: +Write B : AsRef @@ -6963,44 +7179,100 @@ u8 ] > { -self -. -try_replace_all_bytes +assert_eq +! ( -haystack replace_with +. +len +( ) +self . -expect +pattern_count ( +) " -AhoCorasick -: -: -try_replace_all_bytes -should -not -fail +stream_replace_all +requires +a +replacement +for +every +pattern +\ +in +the +automaton " ) +; +self +. +stream_replace_all_with +( +rdr +wtr +| +mat +_ +wtr +| +{ +wtr +. +write_all +( +replace_with +[ +mat +. +pattern +( +) +] +. +as_ref +( +) +) +} +) } / / / -Replace +Search +the +given +reader +and +replace all matches +of +this +automaton +/ +/ +/ using -a +the +given closure -called -on -each -match . +The +result +is +written +to +the +given / / / +writer +. Matches correspond to @@ -7014,11 +7286,19 @@ by / / [ -AhoCorasick -: -: find_iter ] +( +struct +. +AhoCorasick +. +html +# +method +. +find_iter +) . / / @@ -7044,9 +7324,8 @@ of the match and -a -string -buffer +the +writer with which to @@ -7054,37 +7333,68 @@ write the replaced text -/ -/ -/ ( if any ) . -If -the -closure -returns -true -then -it -continues -to -the -next / / / -match +/ +/ +/ +After +all +matches +are +replaced +the +writer +is +_not_ +flushed . +/ +/ +/ +/ +/ +/ If +there +was +a +problem +reading +from the -closure -returns -false +given +reader +or +writing +to +the +/ +/ +/ +given +writer then -searching +the +corresponding +io +: +: +Error +is +returned +and +all +/ +/ +/ +replacement is stopped . @@ -7094,30 +7404,42 @@ stopped / / / -Note -that -any -matches -with -boundaries -that -don -' -t -fall -on +When +searching a -valid -UTF -- -8 +stream +an +internal +buffer +is +used +. +Therefore +callers / / / -boundary -are -silently -skipped +should +avoiding +providing +a +buffered +reader +if +possible +. +However +/ +/ +/ +callers +may +want +to +provide +a +buffered +writer . / / @@ -7125,52 +7447,79 @@ skipped / / / -This -is +Searching +a +stream +requires +that the -infallible -version -of +automaton +was +built +with / / / -[ -AhoCorasick +MatchKind : : -try_replace_all_with -] +Standard +semantics . +If +this +automaton +was +constructed / / / +with +leftmost +semantics +then +this +method +will +panic +. +To +determine / / / -# -Panics -/ -/ -/ +whether +this +will +panic +at +runtime +use +the / / / -This -panics -when [ AhoCorasick : : -try_replace_all_with +supports_stream ] -would -return -an +( +struct +. +AhoCorasick +. +html +# +method +. +supports_stream +) / / / -error +method . / / @@ -7179,223 +7528,180 @@ error / / # -Examples +Memory +usage / / / / / / -Basic -usage -: +In +general +searching +streams +will +use +a +constant +amount +of +memory +for / / / +its +internal +buffer +. +The +one +requirement +is +that +the +internal +buffer / / / +must +be +at +least +the +size +of +the +longest +possible +match +. +In +most +use / / / -use -aho_corasick -: -: -{ -AhoCorasick -MatchKind -} -; +cases +the +default +buffer +size +will +be +much +larger +than +any +individual / / / +match +. / / / -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] -; / / / -let -haystack -= -" -append -the -app -to -the -appendage -" -; +# +Panics / / / / / / -let -ac -= +This +panics +when AhoCorasick : : -builder -( -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -/ -/ -/ +supports_stream +returns +false . -build -( -patterns -) / / / -. -unwrap -( -) -; +That +is +this +panics +when +this +automaton +' +s +match +semantics +are +not / / / -let -mut -result -= -String +MatchKind : : -new -( -) -; -/ -/ -/ -ac -. -replace_all_with -( -haystack -& -mut -result -| -mat -_ -dst -| -{ -/ -/ -/ -dst -. -push_str -( -& -mat -. -pattern -( -) +Standard . -as_usize -( -) +This +restriction +may +be +lifted +in +the +future . -to_string -( -) -) -; / / / -true / / / -} -) -; +# +Examples / / / -assert_eq -! -( -" -0 -the -2 -to -the -0age -" -result -) -; / / / +Basic +usage +: / / / / / / -Stopping -the -replacement -by -returning -false -( -continued -from -the / / / -example -above -) +use +std +: +: +io +: : +Write +; / / / +use +aho_corasick +: +: +AhoCorasick +; / / / @@ -7403,171 +7709,149 @@ above / / # -use -aho_corasick +fn +example +( +) +- +> +Result +< +( +) +: +: +std +: +: +io : : +Error +> { -AhoCorasick -MatchKind -PatternID -} -; / / / -# let patterns = & [ " -append +fox " " -appendage +brown " " -app +quick " ] ; / / / -# let haystack = " -append -the -app -to -the -appendage +The +quick +brown +fox +. " ; / / / -# +/ +/ +/ let ac = AhoCorasick : : -builder +new ( +patterns ) +; / / / -# -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) +let +mut +result += +vec +! +[ +] +; / / / -# +ac . -build +stream_replace_all_with ( -patterns -) / / / -# +haystack . -unwrap +as_bytes ( ) -; / / / -let +& mut result -= -String -: -: -new -( -) -; / / / -ac -. -replace_all_with -( -haystack -& -mut -result | mat _ -dst +wtr | { / / / -dst +wtr . -push_str +write_all ( -& mat . pattern ( ) . -as_usize +to_string ( ) . -to_string +as_bytes ( ) ) -; / / / -mat -. -pattern -( -) -! -= -PatternID -: -: -must -( -2 -) +} / / / -} ) +? ; / / @@ -7575,43 +7859,88 @@ must assert_eq ! ( +b " -0 -the +The 2 -to -the -appendage +1 +0 +. " +. +to_vec +( +) result ) ; / / / +# +Ok +( +( +) +) +} +; +example +( +) +. +unwrap +( +) +/ +/ +/ pub fn -replace_all_with +stream_replace_all_with < +R +W F > ( & self -haystack +rdr : -& -str -dst +R +mut +wtr : -& +W mut -String replace_with : F ) +- +> +io +: +: +Result +< +( +) +> where +R +: +io +: +: +Read +W +: +io +: +: +Write F : FnMut @@ -7619,196 +7948,250 @@ FnMut & Match & -str +[ +u8 +] & mut -String +W ) - > -bool +io +: +: +Result +< +( +) +> { +let +mut +it += +StreamChunkIter +: +: +new +( self +rdr +) +; +while +let +Some +( +result +) += +it . -try_replace_all_with +next ( -haystack -dst -replace_with ) +{ +let +chunk += +result +? +; +match +chunk +{ +StreamChunk +: +: +NonMatch +{ +bytes . -expect +. +} += +> +{ +wtr +. +write_all ( -" -AhoCorasick +bytes +) +? +; +} +StreamChunk : : -try_replace_all_with -should -not -fail -" +Match +{ +bytes +mat +} += +> +{ +replace_with +( +& +mat +bytes +& +mut +wtr +) +? +; +} +} +} +Ok +( +( +) ) } / / / -Replace -all -matches -using -raw -bytes -with -a -closure -called -on -each +Returns +the +match +kind +used +by +this +automaton +. / / / -match -. -Matches -correspond -to -the -same -matches -as -reported -by / / / -[ -AhoCorasick -: -: -find_iter -] -. +# +Examples / / / / / / -The -closure -accepts -three -parameters +Basic +usage : -the -match -found -the -text -of / / / -the -match -and -a -byte -buffer -with -which -to -write -the -replaced -text / / / -( -if -any -) -. -If -the -closure -returns -true -then -it -continues -to -the -next -/ -/ -/ -match -. -If -the -closure -returns -false -then -searching -is -stopped -. / / / +use +aho_corasick +: +: +{ +AhoCorasick +MatchKind +} +; / / / -This -is -the -infallible -version -of / / / -[ +let +ac += AhoCorasick : : -try_replace_all_with_bytes -] -. +new +( +& +[ / / / +" +foo +" +" +bar +" +" +quux +" +" +baz +" / / / -# -Panics +] +) +; / / / +assert_eq +! +( +& +MatchKind +: +: +Standard +ac +. +match_kind +( +) +) +; / / / -This -panics -when -[ -AhoCorasick -: -: -try_replace_all_with_bytes -] -would +pub +fn +match_kind +( +& +self +) +- +> +& +MatchKind +{ +self +. +imp +. +match_kind +( +) +} / / / -return -an -error +Returns +the +length +of +the +longest +pattern +matched +by +this +automaton . / / @@ -7840,10 +8223,7 @@ use aho_corasick : : -{ AhoCorasick -MatchKind -} ; / / @@ -7852,191 +8232,185 @@ MatchKind / / let -patterns +ac = +AhoCorasick +: +: +new +( & [ +/ +/ +/ " -append +foo " " -appendage +bar " " -app +quux " -] -; -/ -/ -/ -let -haystack -= -b " -append -the -app -to -the -appendage +baz " -; / / / +] +) +; / / / -let +assert_eq +! +( +4 ac -= -AhoCorasick -: -: -builder +. +max_pattern_len ( ) +) +; / / / -. -match_kind +pub +fn +max_pattern_len ( -MatchKind -: -: -LeftmostFirst +& +self ) -/ -/ -/ +- +> +usize +{ +self . -build +imp +. +max_pattern_len ( -patterns ) +} / / / +Return +the +total +number +of +patterns +matched +by +this +automaton . -unwrap -( -) -; / / / -let -mut -result -= -vec -! -[ -] -; / / / -ac +This +includes +patterns +that +may +never +participate +in +a +match . -replace_all_with_bytes -( -haystack -& -mut -result -| -mat -_ -dst -| -{ +For / / / -dst -. -extend -( -mat -. -pattern +example +if +/ +/ +/ +[ +MatchKind +: +: +LeftmostFirst +] ( -) +enum . -as_usize -( -) +MatchKind . -to_string -( -) +html +# +variant . -bytes -( -) +LeftmostFirst ) -; / / / -true +match +semantics +are +used +and +the +patterns +Sam +and +Samwise +were / / / -} -) -; +used +to +build +the +automaton +then +Samwise +can +never +participate +in +a / / / -assert_eq -! -( -b -" -0 -the -2 -to -the -0age -" +match +because +Sam +will +always +take +priority . -to_vec -( -) -result -) -; / / / / / / +# +Examples / / / -Stopping -the -replacement -by -returning -false -( -continued -from -the / / / -example -above -) +Basic +usage : / / @@ -8047,308 +8421,181 @@ above / / / -# use aho_corasick : : -{ AhoCorasick -MatchKind -PatternID -} ; / / / -# +/ +/ +/ let -patterns +ac = +AhoCorasick +: +: +new +( & [ +/ +/ +/ " -append +foo " " -appendage +bar " " -app +baz " -] -; / / / -# -let -haystack -= -b -" -append -the -app -to -the -appendage -" +] +) ; / / / -# -let +assert_eq +! +( +3 ac -= -AhoCorasick -: -: -builder +. +pattern_count ( ) +) +; / / / -# +pub +fn +pattern_count +( +& +self +) +- +> +usize +{ +self . -match_kind +imp +. +pattern_count ( -MatchKind -: -: -LeftmostFirst ) +} / / / -# -. -build -( -patterns -) +Returns +true +if +and +only +if +this +automaton +supports +reporting / / / -# +overlapping +matches . -unwrap -( -) -; / / / -let -mut -result -= -vec -! -[ -] -; / / / -ac -. -replace_all_with_bytes -( -haystack -& -mut -result -| -mat -_ -dst -| -{ +If +this +returns +false +and +overlapping +matches +are +requested +then +it / / / -dst -. -extend -( -mat -. -pattern -( -) -. -as_usize -( -) -. -to_string -( -) +will +result +in +a +panic . -bytes -( -) -) -; / / / -mat -. -pattern -( -) -! -= -PatternID -: -: -must -( -2 -) / / / -} -) -; +Since +leftmost +matching +is +inherently +incompatible +with +overlapping / / / -assert_eq -! -( -b -" -0 -the -2 -to -the -appendage -" -. -to_vec -( -) -result -) -; +matches +only / / / -pub -fn -replace_all_with_bytes -< -F -> -( -& -self -haystack -: -& [ -u8 -] -dst -: -& -mut -Vec -< -u8 -> -replace_with +MatchKind : -F -) -where -F : -FnMut -( -& -Match -& -[ -u8 +Standard ] -& -mut -Vec -< -u8 -> -) -- -> -bool -{ -self -. -try_replace_all_with_bytes ( -haystack -dst -replace_with -) +enum . -expect -( -" -AhoCorasick -: -: -try_replace_all_with_bytes -should -not -fail -" +MatchKind +. +html +# +variant +. +Standard ) -} / / / -Returns -an -iterator -of -non -- +supports overlapping matches -in -the -given -/ -/ -/ -stream . -Matches -correspond +This +is +unlikely to +change +in the -same -matches -as -reported -by -/ -/ -/ -[ -AhoCorasick -: -: -find_iter -] +future . / / @@ -8356,280 +8603,262 @@ find_iter / / / -The -matches -yielded -by -this -iterator -use -absolute -position -offsets -in +# +Examples / / / -the -stream -given -where -the -first -byte -has -index -0 -. -Matches -are / / / -yieled -until -the -stream -is -exhausted -. +Basic +usage +: / / / / / / -Each -item -yielded -by -the -iterator -is -an -Result -< -Match / / / -std -: -: -io +use +aho_corasick : : -Error -> -where -an -error -is -yielded -if -there -was -a -problem +{ +AhoCorasickBuilder +MatchKind +} +; / / / -reading -from -the -reader -given -. / / / +let +ac += +AhoCorasickBuilder +: +: +new +( +) / / / -When -searching -a -stream -an -internal -buffer -is -used . -Therefore -callers +match_kind +( +MatchKind +: +: +Standard +) / / / -should -avoiding -providing -a -buffered -reader -if -possible . +build +( +& +[ +" +foo +" +" +bar +" +" +baz +" +] +) +; / / / +assert +! +( +ac +. +supports_overlapping +( +) +) +; / / / -This -is -the -infallible -version -of -/ / / -[ -AhoCorasick +/ +let +ac += +AhoCorasickBuilder : : -try_stream_find_iter -] -. -Note -that -both -methods -return +new +( +) / / / -iterators -that -produce -Result -values . -The -difference -is -that -this +match_kind +( +MatchKind +: +: +LeftmostFirst +) / / / -routine -panics -if -_construction_ -of -the -iterator -failed . -The -Result +build +( +& +[ +" +foo +" +" +bar +" +" +baz +" +] +) +; / / / -values -yield -by -the -iterator -come -from -whether -the -given -reader -returns +assert +! +( +! +ac +. +supports_overlapping +( +) +) +; / / / -an -error -or -not -during -the -search +pub +fn +supports_overlapping +( +& +self +) +- +> +bool +{ +self +. +match_kind . +supports_overlapping +( +) +} / / / +Returns +true +if +and +only +if +this +automaton +supports +stream +searching +. / / / -# -Memory -usage / / / +If +this +returns +false +and +stream +searching +( +or +replacing +) +is +attempted / / / -In -general -searching -streams +then +it will -use +result +in a -constant -amount -of -memory -for +panic +. / / / -its -internal -buffer -. -The -one -requirement -is -that -the -internal -buffer / / / -must -be -at -least -the -size -of -the -longest -possible -match -. -In -most -use +Currently +only / / / -cases -the -default -buffer -size -will -be -much -larger -than -any -individual +[ +MatchKind +: +: +Standard +] +( +enum +. +MatchKind +. +html +# +variant +. +Standard +) / / / -match +supports +streaming +. +This +may +be +expanded +in +the +future . / / @@ -8638,79 +8867,16 @@ match / / # -Panics +Examples / / / / / / -This -panics -when -[ -AhoCorasick -: +Basic +usage : -try_stream_find_iter -] -would -return -/ -/ -/ -an -error -. -For -example -when -the -Aho -- -Corasick -searcher -doesn -' -t -support -/ -/ -/ -stream -searches -. -( -Only -searchers -built -with -[ -MatchKind -: -: -Standard -] -/ -/ -/ -semantics -support -stream -searches -. -) -/ -/ -/ -/ -/ -/ -# -Example -: -basic -usage / / / @@ -8725,8 +8891,8 @@ aho_corasick : : { -AhoCorasick -PatternID +AhoCorasickBuilder +MatchKind } ; / @@ -8736,35 +8902,57 @@ PatternID / / let -patterns +ac = +AhoCorasickBuilder +: +: +new +( +) +/ +/ +/ +. +match_kind +( +MatchKind +: +: +Standard +) +/ +/ +/ +. +build +( & [ " -append +foo " " -appendage +bar " " -app +baz " ] +) ; / / / -let -haystack -= -" -append -the -app -to -the -appendage -" +assert +! +( +ac +. +supports_stream +( +) +) ; / / @@ -8775,1480 +8963,1608 @@ appendage let ac = -AhoCorasick +AhoCorasickBuilder : : new ( -patterns ) +/ +/ +/ . -unwrap +match_kind ( +MatchKind +: +: +LeftmostFirst ) -; / / / -let -mut -matches -= -vec -! +. +build +( +& [ +" +foo +" +" +bar +" +" +baz +" ] +) ; / / / -for -result -in -ac -. -stream_find_iter +assert +! ( -haystack +! +ac . -as_bytes +supports_stream ( ) ) -{ -/ -/ -/ -let -mat -= -result -? ; / / / -matches -. -push +pub +fn +supports_stream ( -mat +& +self +) +- +> +bool +{ +self . -pattern +match_kind +. +supports_stream ( ) -) -; +} / / / -} +Returns +the +approximate +total +amount +of +heap +used +by +this +automaton +in / / / -assert_eq -! -( -vec -! -[ +units +of +bytes +. / / / -PatternID -: +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +This +example +shows +the +difference +in +heap +usage +between +a +few +/ +/ +/ +configurations : -must -( -2 -) / / / -PatternID +/ +/ +/ +ignore +/ +/ +/ +use +aho_corasick : : -must -( -2 -) +{ +AhoCorasickBuilder +MatchKind +} +; / / / -PatternID +/ +/ +/ +let +ac += +AhoCorasickBuilder : : -must +new ( -2 ) / / / -] -matches +. +dfa +( +false ) -; -/ / / +default / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( +. +build ( -) -) -/ -/ -/ -# +& [ -cfg -( -feature -= " -std +foo +" +" +bar +" +" +baz " -) ] -pub -fn -stream_find_iter -< -' -a -R -: -std -: -: -io -: -: -Read -> -( -& -' -a -self -rdr -: -R ) -- -> -StreamFindIter -< -' -a -R -> -{ -self -. -try_stream_find_iter +; +/ +/ +/ +assert_eq +! ( -rdr -) +10_336 +ac . -expect +heap_bytes ( -" -AhoCorasick -: -: -try_stream_find_iter -should -not -fail -" ) -} -} -/ +) +; / / -Fallible -search -routines -. -These -APIs -return -an -error -in -cases -where -the / / / -infallible -routines -would -panic -. -impl -AhoCorasick -{ / +let +ac += +AhoCorasickBuilder +: +: +new +( +) / / -Returns -the -location -of -the -first -match -according -to -the -match / +. +dfa +( +false +) / / -semantics -that -this -automaton -was -constructed -with -and -according +default / / / -to -the -given -Input -configuration . +ascii_case_insensitive +( +true +) / / / +. +build +( +& +[ +" +foo +" +" +bar +" +" +baz +" +] +) +; / / / -This -is -the -fallible -version -of -[ -AhoCorasick -: -: -find -] +assert_eq +! +( +10_384 +ac . +heap_bytes +( +) +) +; / / / / / / -# -Errors +let +ac += +AhoCorasickBuilder +: +: +new +( +) / / / +. +dfa +( +true +) / / / -This -returns -an -error -when -this -Aho -- -Corasick -searcher -does -not -support +. +ascii_case_insensitive +( +true +) / / / -the -given -Input -configuration . +build +( +& +[ +" +foo +" +" +bar +" +" +baz +" +] +) +; / / / +assert_eq +! +( +1_248 +ac +. +heap_bytes +( +) +) +; / / / -For -example -if -the -Aho -- -Corasick -searcher -only -supports -anchored -/ -/ -/ -searches -or -only -supports -unanchored -searches -then -providing -an -/ -/ -/ -Input -that -requests -an -anchored +pub +fn +heap_bytes ( -or -unanchored +& +self ) -search -when -it -isn -' -t -/ -/ -/ -supported -would -result -in -an -error -. -/ -/ -/ -/ -/ -/ -# -Example -: -leftmost -- -first -searching -/ -/ -/ -/ -/ -/ -Basic -usage -with -leftmost - -first -semantics -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: +> +usize { -AhoCorasick -MatchKind -Input -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let -haystack -= -" -foo -abcd -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick +match +self +. +imp +{ +Imp : : -builder +NFA ( +ref +nfa ) -/ -/ -/ += +> +nfa . -match_kind +heap_bytes ( -MatchKind +) +Imp : : -LeftmostFirst +DFA +( +ref +dfa ) -/ -/ -/ += +> +dfa . -build +heap_bytes ( -patterns ) +} +} +} / / / -. -unwrap -( -) -; +The +internal +implementation +of +Aho +- +Corasick +which +is +either +an +NFA +or / / / -let -mat -= -ac +a +DFA . -try_find -( -haystack -) -? +The +NFA +is +slower +but +uses +less +memory . -expect -( -" -should -have -a -match -" -) -; +The +DFA +is +faster +but +uses / / / -assert_eq -! -( -" -abc -" -& -haystack -[ -mat +more +memory . -span +# +[ +derive ( +Clone +Debug ) ] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: +enum +Imp +< +S : +StateID +> +{ +NFA +( +NFA < +S +> +) +DFA ( +DFA +< +S +> ) -Box +} +impl < -dyn -std -: -: -error -: +S : -Error +StateID > +Imp +< +S > -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -anchored -leftmost -- -first -searching -/ -/ -/ +{ / / / -This -shows -how -to -anchor -the -search -so -that -even -if +Returns the -haystack -/ -/ -/ -contains -a +type +of match -somewhere -a +semantics +implemented +by +this +automaton +. +fn +match_kind +( +& +self +) +- +> +& +MatchKind +{ match -won -' -t -be -reported -unless -one -can -/ -/ -/ -be -found -that -starts -at -the -beginning -of -the -search -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: +* +self { -AhoCorasick -Anchored -Input -MatchKind -StartKind -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let -haystack -= -" -foo -abcd -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick +Imp : : -builder +NFA ( +ref +nfa ) -/ -/ -/ += +> +nfa . match_kind ( -MatchKind -: -: -LeftmostFirst ) -/ -/ -/ -. -start_kind -( -StartKind +Imp : : -Anchored +DFA +( +ref +dfa ) -/ -/ -/ += +> +dfa . -build +match_kind ( -patterns ) +} +} / / / +Returns +the +identifier +of +the +start +state . -unwrap +fn +start_state ( +& +self ) -; -/ -/ -/ -let -input -= -Input +- +> +S +{ +match +* +self +{ +Imp : : -new +NFA ( -haystack +ref +nfa ) += +> +nfa . -anchored +start_state ( -Anchored +) +Imp : : -Yes -) -; -/ -/ -/ -assert_eq -! +DFA ( -None -ac +ref +dfa +) += +> +dfa . -try_find +start_state ( -input -) -? ) -; +} +} / / / +The +length +in +bytes +of +the +longest +pattern +in +this +automaton +. +This / / / -# -Ok -: -: -< +information +is +useful +for +maintaining +correct +buffer +sizes +when +/ +/ +/ +searching +on +streams +. +fn +max_pattern_len ( +& +self ) -Box -< -dyn -std -: -: -error +- +> +usize +{ +match +* +self +{ +Imp : : -Error -> +NFA +( +ref +nfa +) += > +nfa +. +max_pattern_len ( +) +Imp +: +: +DFA ( +ref +dfa ) += +> +dfa +. +max_pattern_len +( ) +} +} / / / -/ -/ -/ -/ -/ -/ -If -the -beginning +The +total +number of -the -search -is -changed +patterns +added to -where -a -match -begins -then +this +automaton +. +This +includes / / / -it -will +patterns +that +may +never +match +. +The +maximum +matching +pattern +that +can be -found -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -Anchored -Input -MatchKind -StartKind -} -; -/ / / / -/ -/ -let -patterns -= +reported +is +exactly +one +less +than +this +number +. +fn +pattern_count +( & -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let -haystack -= -" -foo -abcd -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick +self +) +- +> +usize +{ +match +* +self +{ +Imp : : -builder +NFA ( +ref +nfa ) -/ -/ -/ += +> +nfa . -match_kind +pattern_count ( -MatchKind +) +Imp : : -LeftmostFirst +DFA +( +ref +dfa ) -/ -/ -/ += +> +dfa . -start_kind +pattern_count ( -StartKind -: -: -Anchored ) +} +} / / / -. -build -( -patterns -) +Returns +the +prefilter +object +if +one +exists +for +the +underlying / / / +automaton . -unwrap +fn +prefilter ( +& +self ) -; -/ -/ -/ -let -input -= -Input +- +> +Option +< +& +dyn +Prefilter +> +{ +match +* +self +{ +Imp : : -new +NFA ( -haystack +ref +nfa ) += +> +nfa . -range +prefilter ( -4 -. -. ) -. -anchored -( -Anchored +Imp : : -Yes +DFA +( +ref +dfa ) -; += +> +dfa +. +prefilter +( +) +} +} / / / +Returns +true +if +and +only +if +we +should +attempt +to +use +a +prefilter +. +fn +use_prefilter +( +& +self +) +- +> +bool +{ let -mat +p = -ac +match +self . -try_find +prefilter ( -input ) -? -. -expect +{ +None += +> +return +false +Some ( -" -should -have -a -match -" +p ) += +> +p +} ; -/ -/ -/ -assert_eq ! +p +. +looks_for_non_start_of_match ( -" -abc -" +) +} +# +[ +inline +( +always +) +] +fn +overlapping_find_at +( +& +self +prestate +: & +mut +PrefilterState haystack +: +& [ -mat -. -span +u8 +] +at +: +usize +state_id +: +& +mut +S +match_index +: +& +mut +usize +) +- +> +Option +< +Match +> +{ +match +* +self +{ +Imp +: +: +NFA ( +ref +nfa ) -] += +> +nfa +. +overlapping_find_at +( +prestate +haystack +at +state_id +match_index ) -; -/ -/ -/ -/ -/ -/ -# -Ok +Imp : : -< +DFA ( +ref +dfa ) -Box -< -dyn -std += +> +dfa +. +overlapping_find_at +( +prestate +haystack +at +state_id +match_index +) +} +} +# +[ +inline +( +always +) +] +fn +earliest_find_at +( +& +self +prestate : +& +mut +PrefilterState +haystack : -error +& +[ +u8 +] +at : +usize +state_id : -Error +& +mut +S +) +- +> +Option +< +Match > +{ +match +* +self +{ +Imp +: +: +NFA +( +ref +nfa +) += > +{ +nfa +. +earliest_find_at ( +prestate +haystack +at +state_id +) +} +Imp +: +: +DFA ( +ref +dfa ) += +> +{ +dfa +. +earliest_find_at +( +prestate +haystack +at +state_id ) -/ -/ -/ -/ -/ -/ -/ -/ -/ +} +} +} # -Example +[ +inline +( +always +) +] +fn +find_at_no_state +( +& +self +prestate : -earliest -leftmost +& +mut +PrefilterState +haystack +: +& +[ +u8 +] +at +: +usize +) - -first -searching -/ -/ -/ -/ -/ -/ -This -shows -how -to -run -an -" -earliest -" -search -even -when -the -Aho -- -Corasick +> +Option +< +Match +> +{ +match +* +self +{ +Imp +: +: +NFA +( +ref +nfa +) += +> +nfa +. +find_at_no_state +( +prestate +haystack +at +) +Imp +: +: +DFA +( +ref +dfa +) += +> +dfa +. +find_at_no_state +( +prestate +haystack +at +) +} +} +} / / / -searcher -was -compiled -with -leftmost +An +iterator +of +non - -first -match -semantics +overlapping +matches +in +a +particular +haystack . -In -this / / / -case -the -search -is -stopped -as -soon -as -it -is -known -that -a -match -has / / / -occurred -even -if -it -doesn -' -t -correspond +This +iterator +yields +matches +according to the -leftmost -- -first -match -. / / / +[ +MatchKind +] +( +enum +. +MatchKind +. +html +) / / / +used +by +this +automaton +. / / / -use -aho_corasick -: -: -{ -AhoCorasick -Input -MatchKind -} -; / / / +This +iterator +is +constructed +via +the / / / -let -patterns -= -& [ -" -b -" -" -abc -" -" -abcd -" +AhoCorasick +: +: +find_iter ] -; +( +struct +. +AhoCorasick +. +html +# +method +. +find_iter +) / / / -let -haystack -= -" -foo -abcd -" -; +method +. / / / / / / -let -ac -= -AhoCorasick -: -: -builder -( -) +The +type +variable +S +refers +to +the +representation +used +for +state / / / +identifiers . -match_kind ( -MatchKind -: -: -LeftmostFirst +By +default +this +is +usize +. ) / / / -. -build -( -patterns -) / / / +The +lifetime +' +a +refers +to +the +lifetime +of +the +AhoCorasick +automaton . -unwrap -( -) -; / / / -let -input -= -Input -: -: -new -( -haystack -) -. -earliest -( -true -) -; / / / -let -mat -= -ac +The +lifetime +' +b +refers +to +the +lifetime +of +the +haystack +being +searched . -try_find +# +[ +derive ( -input +Debug ) -? -. -expect -( -" -should -have +] +pub +struct +FindIter +< +' a -match -" -) -; -/ -/ -/ -assert_eq -! -( -" +' b -" +S +: +StateID +> +{ +fsm +: & +' +a +Imp +< +S +> +prestate +: +PrefilterState haystack +: +& +' +b [ -mat -. -span -( -) +u8 ] -) -; -/ -/ -/ -/ -/ -/ -# -Ok +pos : +usize +} +impl +< +' +a +' +b +S : +StateID +> +FindIter < +' +a +' +b +S +> +{ +fn +new ( -) -Box -< -dyn -std -: -: -error +ac : +& +' +a +AhoCorasick +< +S +> +haystack : -Error +& +' +b +[ +u8 +] +) +- > +FindIter +< +' +a +' +b +S > +{ +let +prestate += +PrefilterState +: +: +new ( +ac +. +max_pattern_len ( ) ) -/ -/ -/ -pub -fn -try_find +; +FindIter +{ +fsm +: +& +ac +. +imp +prestate +haystack +pos +: +0 +} +} +} +impl < ' -h -I +a +' +b +S : -Into -< -Input +StateID +> +Iterator +for +FindIter < ' -h -> -> +a +' +b +S > +{ +type +Item += +Match +; +fn +next ( & +mut self -input -: -I ) - > -Result -< Option < Match > -MatchError -> { -let -input -= -input +if +self . -into -( -) -; -enforce_anchored_consistency -( +pos +> self . -start_kind -input +haystack . -get_anchored +len ( ) -) -? +{ +return +None ; +} +let +result += self . -aut +fsm . -try_find +find_at_no_state ( & -input +mut +self +. +prestate +self +. +haystack +self +. +pos +) +; +let +mat += +match +result +{ +None += +> +return +None +Some +( +mat ) += +> +mat } +; +if +mat +. +end +( +) += += +self +. +pos +{ / / -/ -Returns -the -location -of +If the -first -overlapping +automaton +can match -in the -given -/ +empty +string +and +if +we +found +an / / -input -with -respect +empty +match +then +we +need to +forcefully +move the -current -state -of -the -underlying -searcher +position . -/ -/ -/ -/ -/ -/ -Overlapping -searches -do -not -report -matches -in -their -return -value +self +. +pos ++ += +1 +; +} +else +{ +self . +pos += +mat +. +end +( +) +; +} +Some +( +mat +) +} +} / / / -Instead +An +iterator +of +overlapping matches -can -be -accessed -via -[ -OverlappingState -: -: -get_match -] -/ -/ -/ -after +in a -search -call +particular +haystack . / / @@ -10257,62 +10573,24 @@ call / / This -is -the -fallible -version -of -[ -AhoCorasick -: -: -find_overlapping -] -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ +iterator +will +report +all +possible +matches +in +a +particular +haystack / / / -This -returns -an -error +even when -this -Aho -- -Corasick -searcher -does -not -support -/ -/ -/ the -given -Input -configuration -or -if -overlapping -search -is -not -/ -/ -/ -supported +matches +overlap . / / @@ -10320,607 +10598,503 @@ supported / / / -One -example +This +iterator is -that -only -Aho -- -Corasicker -searchers -built -with +constructed +via +the / / / [ -MatchKind +AhoCorasick : : -Standard +find_overlapping_iter ] -semantics -support -overlapping -searches +( +struct . -Using -/ -/ -/ -any -other -match -semantics -will -result -in -this -returning -an -error +AhoCorasick . -/ -/ -/ -/ -/ -/ +html # -Example -: -basic -usage +method +. +find_overlapping_iter +) / / / +method +. / / / -This -shows -how -we -can -repeatedly -call -an -overlapping -search -without / / / -ever -needing +The +type +variable +S +refers to -explicitly -re -- -slice the -haystack -. -Overlapping -search -/ -/ -/ -works -this -way -because -searches -depend -on +representation +used +for state -saved -during -the / / / -previous -search +identifiers . +( +By +default +this +is +usize +. +) / / / / / / -/ -/ -/ -use -aho_corasick -: -: -{ -/ -/ -/ -automaton -: -: -OverlappingState -/ -/ -/ +The +lifetime +' +a +refers +to +the +lifetime +of +the AhoCorasick -Input -Match -/ -/ -/ -} -; +automaton +. / / / / / / -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] -; -/ -/ -/ -let -haystack -= -" -append -the -app +The +lifetime +' +b +refers to the -appendage -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -patterns -) +lifetime +of +the +haystack +being +searched . -unwrap +# +[ +derive ( +Debug ) -; -/ -/ -/ -let -mut -state -= -OverlappingState +] +pub +struct +FindOverlappingIter +< +' +a +' +b +S : +StateID +> +{ +fsm : -start -( -) -; -/ -/ -/ -/ -/ -/ -ac -. -try_find_overlapping -( +& +' +a +Imp +< +S +> +prestate +: +PrefilterState haystack +: & -mut -state -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match +' +b +[ +u8 +] +pos : +usize +state_id : -must -( -2 -0 -. -. -3 -) -) -state -. -get_match +S +match_index +: +usize +} +impl +< +' +a +' +b +S +: +StateID +> +FindOverlappingIter +< +' +a +' +b +S +> +{ +fn +new ( -) -) -; -/ -/ -/ -/ -/ -/ ac -. -try_find_overlapping -( +: +& +' +a +AhoCorasick +< +S +> haystack +: & -mut -state +' +b +[ +u8 +] ) -? -; -/ -/ -/ -assert_eq +- +> +FindOverlappingIter +< +' +a +' +b +S +> +{ +assert ! ( -Some +ac +. +supports_overlapping ( -Match +) +" +automaton +does +not +support +overlapping +searches +" +) +; +let +prestate += +PrefilterState : : -must +new ( -0 -0 -. -. -6 -) -) -state +ac . -get_match +max_pattern_len ( ) ) ; -/ -/ -/ -/ -/ -/ +FindOverlappingIter +{ +fsm +: +& ac . -try_find_overlapping -( +imp +prestate haystack -& -mut -state -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match +pos : +0 +state_id : -must -( -2 -11 -. +ac . -14 -) -) -state +imp . -get_match +start_state ( ) -) -; -/ -/ -/ -/ -/ -/ -ac -. -try_find_overlapping +match_index +: +0 +} +} +} +impl +< +' +a +' +b +S +: +StateID +> +Iterator +for +FindOverlappingIter +< +' +a +' +b +S +> +{ +type +Item += +Match +; +fn +next ( -haystack & mut -state +self ) -? -; -/ -/ -/ -assert_eq -! -( -Some -( +- +> +Option +< Match -: -: -must +> +{ +let +result += +self +. +fsm +. +overlapping_find_at ( -2 -22 +& +mut +self +. +prestate +self . +haystack +self +. +pos +& +mut +self +. +state_id +& +mut +self . -25 +match_index ) +; +match +result +{ +None += +> +return +None +Some +( +m ) -state += +> +{ +self +. +pos += +m . -get_match +end ( ) -) ; +Some +( +m +) +} +} +} +} / / / +An +iterator +that +reports +Aho +- +Corasick +matches +in +a +stream +. / / / -ac -. -try_find_overlapping -( -haystack -& -mut -state -) -? -; / / / -assert_eq -! -( -Some -( -Match +This +iterator +yields +elements +of +type +io : : -must -( -0 -22 -. +Result +< +Match +> +where +an +error +/ +/ +/ +is +reported +if +there +was +a +problem +reading +from +the +underlying +stream . -28 -) -) -state +/ +/ +/ +The +iterator +terminates +only +when +the +underlying +stream +reaches +EOF . -get_match -( -) -) -; / / / / / / -ac -. -try_find_overlapping -( -haystack -& -mut -state -) -? -; +This +iterator +is +constructed +via +the / / / -assert_eq -! -( -Some -( -Match +[ +AhoCorasick : : -must +stream_find_iter +] ( -1 -22 +struct . +AhoCorasick . -31 -) -) -state +html +# +method . -get_match -( -) +stream_find_iter ) -; -/ -/ -/ / / / -/ -/ -No -more -match -matches -to -be -found +method . / / / -ac -. -try_find_overlapping -( -haystack -& -mut -state -) -? -; -/ -/ -/ -assert_eq -! -( -None -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -implementing -your -own -overlapping -iteration -/ -/ -/ / / / The -previous -example -can -be -easily -adapted +type +variable +R +refers to -implement -your -own -/ -/ -/ -iteration -by -repeatedly -calling -try_find_overlapping -until -either +the +io +: +: +Read +stream +that +is +being +read / / / -an -error -occurs -or -no -more -matches -are -reported +from . / / @@ -10928,92 +11102,28 @@ reported / / / -This -is -effectively -equivalent +The +type +variable +S +refers to the -iterator -returned -by -/ -/ -/ -[ -AhoCorasick -: -: -try_find_overlapping_iter -] -with -the -only -difference -/ -/ -/ -being -that -the -iterator -checks -for -errors -before -construction -and -/ -/ -/ -absolves -the -caller -of -needing -to -check +representation +used for -errors -on -every -search +state / / / -call +identifiers . ( -Indeed -if -the -first -try_find_overlapping -call -succeeds -and -/ -/ -/ -the -same -Input +By +default +this is -given -to -subsequent -calls -then -all -subsequent -/ -/ -/ -calls -are -guaranteed -to -succeed +usize . ) / @@ -11022,1701 +11132,1750 @@ succeed / / / -/ -/ -/ -use -aho_corasick -: -: -{ -/ -/ -/ -automaton -: -: -OverlappingState -/ -/ -/ -AhoCorasick -Input -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] -; -/ -/ -/ -let -haystack -= -" -append -the -app +The +lifetime +' +a +refers to the -appendage -" -; -/ -/ -/ -/ -/ -/ -let -ac -= +lifetime +of +the AhoCorasick -: -: -new -( -patterns -) +automaton . -unwrap +# +[ +derive ( +Debug ) -; -/ -/ -/ -let -mut -state -= -OverlappingState +] +pub +struct +StreamFindIter +< +' +a +R +S : +StateID +> +{ +it : -start +StreamChunkIter +< +' +a +R +S +> +} +impl +< +' +a +R +: +io +: +: +Read +S +: +StateID +> +StreamFindIter +< +' +a +R +S +> +{ +fn +new ( +ac +: +& +' +a +AhoCorasick +< +S +> +rdr +: +R ) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -/ -/ -/ -loop +- +> +StreamFindIter +< +' +a +R +S +> { -/ -/ -/ +StreamFindIter +{ +it +: +StreamChunkIter +: +: +new +( ac -. -try_find_overlapping +rdr +) +} +} +} +impl +< +' +a +R +: +io +: +: +Read +S +: +StateID +> +Iterator +for +StreamFindIter +< +' +a +R +S +> +{ +type +Item += +io +: +: +Result +< +Match +> +; +fn +next ( -haystack & mut -state +self ) -? -; -/ -/ -/ -let -mat -= +- +> +Option +< +io +: +: +Result +< +Match +> +> +{ +loop +{ match -state +self +. +it . -get_match +next ( ) { -/ -/ -/ None = > -break -/ -/ -/ +return +None Some ( -mat +Err +( +err +) ) = > -mat -/ -/ -/ -} -; -/ -/ -/ -matches -. -push +return +Some ( -mat -) -; -/ -/ -/ -} -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -Match -: -: -must +Err ( -2 -0 -. -. -3 +err ) -/ -/ -/ -Match +) +Some +( +Ok +( +StreamChunk : : -must -( -0 -0 +NonMatch +{ . . -6 +} ) -/ -/ -/ -Match +) += +> +{ +} +Some +( +Ok +( +StreamChunk : : -must -( -2 -11 +Match +{ +mat . . -14 +} ) -/ -/ -/ -Match -: -: -must +) += +> +{ +return +Some ( -2 -22 -. -. -25 +Ok +( +mat ) +) +; +} +} +} +} +} / / / -Match -: -: -must -( -0 -22 -. +An +iterator +over +chunks +in +an +underlying +reader . -28 -) +Each +chunk +either / / / -Match -: -: -must -( -1 -22 -. +corresponds +to +non +- +matching +bytes +or +matching +bytes +but +all +bytes +from +/ +/ +/ +the +underlying +reader +are +reported +in +sequence . -31 -) +There +may +be +an +arbitrary / / / -] -; +number +of +non +- +matching +chunks +before +seeing +a +matching +chunk +. / / / -assert_eq -! -( -expected -matches -) -; / / / +N +. +B +. +This +does +not +actually +implement +Iterator +because +we +need +to +borrow / / / +from +the +underlying +reader +. +But +conceptually +it +' +s +still +an +iterator +. # -Ok -: -: -< +[ +derive ( +Debug ) -Box +] +struct +StreamChunkIter < -dyn -std -: -: -error -: +' +a +R +S : -Error -> +StateID > -( -( -) -) +{ / / / +The +AC +automaton +. +fsm +: +& +' +a +Imp +< +S +> / / / +State +associated +with +this +automaton +' +s +prefilter +. +It +is +a +heuristic / / / -# -Example +for +stopping +the +prefilter +if +it +' +s +deemed +ineffective +. +prestate : -anchored -iteration -/ -/ -/ +PrefilterState / / / The -previous -example -can -also -be -adapted -to -implement +source +of +bytes +we +read +from +. +rdr +: +R / / / -iteration -over -all -anchored -matches +A +fixed +size +buffer . -In -particular +This +is +what +we +actually +search +. +There +are +some / / / -[ -AhoCorasick -: -: -try_find_overlapping_iter -] -does -not -support -this +invariants +around +the +buffer +' +s +size +namely +it +must +be +big +enough +to / / / -because -it -isn -' -t -totally -clear -what +contain the +longest +possible match -semantics -ought -to -be . +buf +: +Buffer / / / +The +ID +of +the +FSM +state +we +' +re +currently +in +. +state_id +: +S / / / -In -this -example -we -will -find -all -overlapping -matches -that -start +The +current +position at -/ -/ -/ +which +to +start the -beginning -of -our +next search +in +buf . +search_pos +: +usize / / / +The +absolute +position +of +search_pos +where +0 +corresponds +to +the / / / -/ -/ -/ -use -aho_corasick -: -: -{ -/ -/ -/ -automaton -: +position +of +the +first +byte +read +from +rdr +. +absolute_pos : -OverlappingState +usize / / / -AhoCorasick -Anchored -Input -Match -StartKind +The +ending +position +of +the +last +StreamChunk +that +was +returned +to +the / / / -} -; +caller +. +This +position +is +used +to +determine +whether +we +need +to +emit / / / +non +- +matching +bytes +before +emitting +a +match +. +report_pos +: +usize / / / -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] -; +A +match +that +should +be +reported +on +the +next +call +. +pending_match +: +Option +< +Match +> / / / -let -haystack -= -" -append +Enabled +only +when the -app -to +automaton +can +match the -appendage -" -; -/ -/ -/ +empty +string +. +When / / / -let -ac -= -AhoCorasick -: -: -builder -( -) +enabled +we +need +to +execute +one +final +search +after +consuming +the / / / +reader +to +find +the +trailing +empty +match . -start_kind -( -StartKind -: +has_empty_match_at_end : -Anchored -) +bool +} / / / +A +single +chunk +yielded +by +the +stream +chunk +iterator . -build -( -patterns -) / / / -. -unwrap -( -) -; / / / -let -input -= -Input -: -: -new -( -haystack -) +The +' +r +lifetime +refers +to +the +lifetime +of +the +stream +chunk +iterator . -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start +# +[ +derive ( +Debug ) -; +] +enum +StreamChunk +< +' +r +> +{ / / / -let -mut +A +chunk +that +does +not +contain +any matches -= -vec -! +. +NonMatch +{ +bytes +: +& +' +r [ +u8 ] -; -/ +} / / / -/ -/ -loop +A +chunk +that +precisely +contains +a +match +. +Match { -/ -/ -/ +bytes +: +& +' +r +[ +u8 +] +mat +: +Match +} +} +impl +< +' +a +R +: +io +: +: +Read +S +: +StateID +> +StreamChunkIter +< +' +a +R +S +> +{ +fn +new +( ac -. -try_find_overlapping +: +& +' +a +AhoCorasick +< +S +> +rdr +: +R +) +- +> +StreamChunkIter +< +' +a +R +S +> +{ +assert +! ( -input +ac . -clone +supports_stream ( ) -& -mut -state +" +stream +searching +is +only +supported +for +Standard +match +semantics +" ) -? ; -/ -/ -/ let -mat +prestate = -match -state +if +ac . -get_match +imp +. +use_prefilter ( ) { -/ -/ -/ -None -= -> -break -/ -/ -/ -Some +PrefilterState +: +: +new ( -mat -) -= -> -mat -/ -/ -/ -} -; -/ -/ -/ -matches +ac . -push +max_pattern_len ( -mat ) -; -/ -/ -/ +) } -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -Match +else +{ +PrefilterState : : -must +disabled ( -2 -0 -. -. -3 ) -/ -/ -/ -Match +} +; +let +buf += +Buffer : : -must +new ( -0 -0 +ac . +imp . -6 +max_pattern_len +( +) ) -/ -/ -/ -] ; -/ -/ -/ -assert_eq -! +let +state_id += +ac +. +imp +. +start_state ( -expected -matches ) ; -/ -/ -/ -/ -/ -/ -# -Ok +StreamChunkIter +{ +fsm : +& +ac +. +imp +prestate +rdr +buf +state_id +absolute_pos : -< -( -) -Box -< -dyn -std +0 +report_pos : +0 +search_pos : -error +0 +pending_match : +None +has_empty_match_at_end : -Error -> -> -( +ac +. +is_match ( +" +" ) -) -/ -/ -/ -pub +} +} fn -try_find_overlapping -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> +next ( & -self -input -: -I -state -: -& mut -OverlappingState +self ) - > +Option +< +io +: +: Result < -( -) -MatchError +StreamChunk > +> +{ +loop { +if let -input -= -input -. -into +Some ( +mut +mat ) -; -enforce_anchored_consistency += +self +. +pending_match +. +take ( +) +{ +let +bytes += +& self . -start_kind -input +buf . -get_anchored +buffer ( ) +[ +mat +. +start +( ) -? +. +. +mat +. +end +( +) +] ; self . -aut +report_pos += +mat +. +end +( +) +; +mat += +mat . -try_find_overlapping +increment ( -& -input -state +self +. +absolute_pos ) +; +return +Some +( +Ok +( +StreamChunk +: +: +Match +{ +bytes +mat } -/ -/ -/ -Returns -an -iterator -of -non -- -overlapping -matches -using -the -match -/ -/ -/ -semantics -that -this -automaton -was -constructed -with +) +) +; +} +if +self . -/ -/ -/ -/ -/ -/ -This -is -the -fallible -version -of +search_pos +> += +self +. +buf +. +len +( +) +{ +if +let +Some +( +end +) += +self +. +unreported +( +) +{ +let +bytes += +& +self +. +buf +. +buffer +( +) [ -AhoCorasick +self +. +report_pos +. +. +end +] +; +self +. +report_pos += +end +; +return +Some +( +Ok +( +StreamChunk : : -find_iter -] +NonMatch +{ +bytes +} +) +) +; +} +if +self . -/ -/ -/ -/ -/ -/ -Note -that -the -error -returned -by -this -method -occurs -during -construction -/ -/ -/ -of -the -iterator +buf . -The -iterator -itself -yields -Match -values +len +( +) +> += +self . -That -is -/ +buf +. +min_buffer_len +( +) +{ / / -once -the -iterator +This is -constructed the -iteration -itself -will -never -/ -/ -/ -report -an -error -. -/ -/ -/ -/ +point +at +which +we +roll +our +buffer +which +we / / -# -Errors +only +do +if +our +buffer +has +at +least +the +minimum +amount +of / / +bytes +in +it +. +Before +rolling +we +update +our +various / / +positions +to +be +consistent +with +the +buffer +after +it +has / / -This -returns -an -error -when -this -Aho -- -Corasick -searcher -does -not -support -/ -/ -/ -the -given -Input -configuration +been +rolled . -/ -/ -/ -/ -/ -/ -For -example -if -the -Aho +self +. +report_pos - -Corasick -searcher -only -supports -anchored -/ -/ -/ -searches -or -only -supports -unanchored -searches -then -providing -an -/ -/ -/ -Input -that -requests -an -anchored += +self +. +buf +. +len ( -or -unanchored ) -search -when -it -isn -' -t -/ -/ -/ -supported -would -result -in -an -error -. -/ -/ -/ -/ -/ -/ -# -Example -: -leftmost -- -first -searching -/ -/ -/ -/ -/ -/ -Basic -usage -with -leftmost - -first -semantics -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -Input -MatchKind -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] +self +. +buf +. +min_buffer_len +( +) ; -/ -/ -/ -let -haystack +self +. +absolute_pos ++ = -" -append -the -app -to -the -appendage -" +self +. +search_pos +- +self +. +buf +. +min_buffer_len +( +) ; -/ -/ -/ -/ -/ -/ -let -ac +self +. +search_pos = -AhoCorasick -: -: -builder +self +. +buf +. +min_buffer_len ( ) -/ -/ -/ +; +self . -match_kind +buf +. +roll ( -MatchKind -: -: -LeftmostFirst ) -/ -/ -/ +; +} +match +self . -build +buf +. +fill ( -patterns -) -/ -/ -/ +& +mut +self . -unwrap +rdr +) +{ +Err ( +err ) -; -/ -/ -/ -let -matches -: -Vec -< -PatternID -> = -ac -/ -/ -/ -. -try_find_iter +> +return +Some ( -Input -: -: -new +Err ( -haystack +err ) ) -? -/ -/ -/ -. -map -( -| -mat -| -mat -. -pattern +Ok ( +false ) -) -/ += +> +{ / / -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -vec -! -[ -/ -/ -/ -PatternID -: -: -must -( -0 -) -/ +We +' +ve +hit +EOF +but +if +there +are +still +some / / -PatternID -: -: -must +unreported +bytes +remaining +return +them +now +. +if +self +. +report_pos +< +self +. +buf +. +len ( -2 ) -/ -/ -/ -PatternID -: -: -must +{ +let +bytes += +& +self +. +buf +. +buffer ( -0 ) -/ -/ -/ +[ +self +. +report_pos +. +. ] -matches -) ; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< +self +. +report_pos += +self +. +buf +. +len ( ) -Box -< -dyn -std -: -: -error +; +let +chunk += +StreamChunk : : -Error -> -> +NonMatch +{ +bytes +} +; +return +Some ( +Ok ( +chunk ) ) +; +} +else +{ / / +We +' +ve +reported +everything +but +there +might +still / / -/ -/ -/ -/ -/ -# -Example -: -anchored -leftmost -- -first -searching -/ -/ -/ -/ -/ -/ -This -shows -how -to -anchor -the -search -such -that -all -matches -must -begin -/ -/ -/ +be +a +match at the -starting -location -of -the -search +very +last +position . -For -an -iterator -an -anchored -/ -/ -/ -search -implies -that -all -matches -are -adjacent +if +! +self . -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: +has_empty_match_at_end { -/ -/ -/ -AhoCorasick -Anchored -Input -MatchKind -PatternID -StartKind -/ -/ -/ -} +return +None ; +} / / +fallthrough +for +another +search +to +get +trailing / / -/ -/ -let -patterns +empty +matches +self +. +has_empty_match_at_end = -& -[ -" -foo -" -" -bar -" -" -quux -" -] +false ; -/ -/ -/ -let -haystack +} +} +Ok +( +true +) = -" -fooquuxbar -foo -" -; -/ -/ -/ -/ -/ -/ +> +{ +} +} +} let -ac +result = -AhoCorasick -: -: -builder +self +. +fsm +. +earliest_find_at ( -) -/ -/ -/ +& +mut +self . -match_kind +prestate +self +. +buf +. +buffer ( -MatchKind -: -: -LeftmostFirst ) -/ -/ -/ +self . -start_kind -( -StartKind -: -: -Anchored +search_pos +& +mut +self +. +state_id ) -/ -/ -/ +; +match +result +{ +None += +> +{ +self . -build +search_pos += +self +. +buf +. +len ( -patterns ) -/ -/ -/ +; +} +Some +( +mat +) += +> +{ +self . -unwrap +state_id += +self +. +fsm +. +start_state ( ) ; +if +mat +. +end +( +) += += +self +. +search_pos +{ / / +If +the +automaton +can +match +the +empty +string +and +if / -let -matches -: -Vec -< -PatternID -> -= -ac / +we +found +an +empty +match +then +we +need +to +forcefully / / +move +the +position . -try_find_iter -( -Input -: -: -new +self +. +search_pos ++ += +1 +; +} +else +{ +self +. +search_pos += +mat +. +end ( -haystack ) +; +} +self . -anchored +pending_match += +Some +( +mat +. +clone ( -Anchored -: -: -Yes ) ) -? -/ -/ -/ +; +if +self . -map -( -| -mat -| +report_pos +< mat . -pattern +start ( ) +{ +let +bytes += +& +self +. +buf +. +buffer +( ) -/ -/ -/ +[ +self . -collect +report_pos +. +. +mat +. +start ( ) +] ; -/ -/ -/ -assert_eq -! +self +. +report_pos += +mat +. +start ( -vec -! -[ -/ -/ -/ -PatternID +) +; +let +chunk += +StreamChunk : : -must +NonMatch +{ +bytes +} +; +return +Some ( -0 +Ok +( +chunk ) -/ -/ -/ -PatternID -: -: -must +) +; +} +} +} +} +} +fn +unreported ( -2 +& +self ) -/ -/ -/ -PatternID -: -: -must +- +> +Option +< +usize +> +{ +let +end += +self +. +search_pos +. +saturating_sub +( +self +. +buf +. +min_buffer_len ( -1 ) -/ -/ -/ -/ -/ -The -final -' -foo -' -is -not -found -because -it -is -not -adjacent -to -the -/ -/ -/ -/ -/ -' -bar -' -match -. -It -needs -to -be -adjacent -because -our -search -is -/ -/ -/ -/ -/ -anchored -. -/ -/ -/ -] -matches ) ; +if +self +. +report_pos +< +end +{ +Some +( +end +) +} +else +{ +None +} +} +} / / / -/ -/ -/ +A +builder +for +configuring +an +Aho +- +Corasick +automaton +. # -Ok -: -: -< +[ +derive ( +Clone +Debug ) -Box -< -dyn -std +] +pub +struct +AhoCorasickBuilder +{ +nfa_builder : +nfa : -error : +Builder +dfa_builder : -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -try_find_iter -< -' -a -' -h -I +dfa : -Into -< -Input -< -' -h -> -> -> -( -& -' -a -self -input : -I +Builder +dfa +: +bool +} +impl +Default +for +AhoCorasickBuilder +{ +fn +default +( ) - > -Result -< -FindIter -< -' -a -' -h -> -MatchError -> +AhoCorasickBuilder { -let -input -= -input -. -into -( -) -; -enforce_anchored_consistency -( -self -. -start_kind -input -. -get_anchored -( -) -) -? -; -Ok -( -FindIter -( -self -. -aut -. -try_find_iter +AhoCorasickBuilder +: +: +new ( -input -) -? -) ) } +} +impl +AhoCorasickBuilder +{ / / / -Returns +Create +a +new +builder +for +configuring an -iterator -of -overlapping -matches +Aho +- +Corasick +automaton . / / @@ -12724,71 +12883,111 @@ matches / / / -This -is -the -fallible -version -of -[ -AhoCorasick -: -: -find_overlapping_iter -] -. +If +you +don +' +t +need +fine +grained +configuration +or +aren +' +t +sure +which +knobs / / / +to +set +try +using / / / -Note -that -the -error -returned -by -this +[ +AhoCorasick +: +: +new_auto_configured +] +( +struct +. +AhoCorasick +. +html +# method -occurs -during -construction +. +new_auto_configured +) / / / -of -the -iterator +instead . -The -iterator -itself -yields -Match -values -. -That -is +pub +fn +new +( +) +- +> +AhoCorasickBuilder +{ +AhoCorasickBuilder +{ +nfa_builder +: +nfa +: +: +Builder +: +: +new +( +) +dfa_builder +: +dfa +: +: +Builder +: +: +new +( +) +dfa +: +false +} +} / / / -once -the -iterator -is -constructed +Build +an +Aho +- +Corasick +automaton +using the -iteration -itself -will -never +configuration +set +on +this / / / -report -an -error +builder . / / @@ -12796,8 +12995,16 @@ error / / / -# -Errors +A +builder +may +be +reused +to +create +more +automatons +. / / / @@ -12805,93 +13012,87 @@ Errors / / This -returns -an -error -when -this -Aho -- -Corasick -searcher -does -not -support -/ -/ -/ +method +will +use the -given -Input -configuration -or -does -not -support -overlapping +default +for +representing +internal +state / / / -searches +identifiers +which +is +usize . +This +guarantees +that +building +the / / / +automaton +will +succeed +and +is +generally +a +good +default +but +can +make / / / -One -example -is -that -only -Aho +the +size +of +the +automaton +2 - -Corasicker -searchers -built -with +8 +times +bigger +than +it +needs +to +be / / / -[ -MatchKind -: -: -Standard -] -semantics -support -overlapping -searches +depending +on +your +target +platform . -Using / / / -any -other -match -semantics -will -result -in -this -returning -an -error -. / / / +# +Examples / / / -# -Example -: -basic +/ +/ +/ +Basic usage +: / / / @@ -12905,11 +13106,7 @@ use aho_corasick : : -{ -AhoCorasick -Input -PatternID -} +AhoCorasickBuilder ; / / @@ -12923,13 +13120,13 @@ patterns & [ " -append +foo " " -appendage +bar " " -app +baz " ] ; @@ -12937,268 +13134,443 @@ app / / let -haystack -= -" -append -the -app -to -the -appendage -" -; -/ -/ -/ -/ -/ -/ -let ac = -AhoCorasick +AhoCorasickBuilder : : new ( -patterns ) +/ +/ +/ . -unwrap +build ( +patterns ) ; / / / -let -matches -: -Vec -< -PatternID -> -= -ac -/ -/ -/ -. -try_find_overlapping_iter +assert_eq +! ( -Input -: -: -new +Some ( -haystack +1 ) +ac +. +find +( +" +xxx +bar +xxx +" ) -? -/ -/ -/ . map ( | -mat +m | -mat +m . pattern ( ) ) +) +; / / / -. -collect -( -) -; -/ -/ -/ -assert_eq -! +pub +fn +build +< +I +P +> ( -vec -! -[ -/ -/ -/ -PatternID -: +& +self +patterns : -must -( -2 +I ) -/ -/ -/ -PatternID +- +> +AhoCorasick +where +I : +IntoIterator +< +Item += +P +> +P : -must -( -0 -) +AsRef +< +[ +u8 +] +> +{ / / +The +builder +only +returns +an +error +if +the +chosen +state +ID +/ / -PatternID -: -: -must -( -2 -) +representation +is +too +small +to +fit +all +of +the +given +patterns +. +In / / +this +case +since +we +fix +the +representation +to +usize +it +will +always / -PatternID -: -: -must -( -2 -) / +work +because +it +' +s +impossible +to +overflow +usize +since +the +underlying / / -PatternID +storage +would +OOM +long +before +that +happens +. +self +. +build_with_size : : -must +< +usize +I +P +> ( -0 +patterns ) -/ -/ -/ -PatternID -: -: -must +. +expect ( -1 +" +usize +state +ID +type +should +always +work +" ) +} / / / -] -matches -) -; +Build +an +Aho +- +Corasick +automaton +using +the +configuration +set +on +this / / / +builder +with +a +specific +state +identifier +representation +. +This +only +has / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) +an +effect +when +the +dfa +option +is +enabled +. / / / / / / +Generally +the +choices +for +a +state +identifier +representation +are / / / -# -Example -: -anchored -overlapping -search -returns -an -error +u8 +u16 +u32 +u64 +or +usize +with +usize +being +the +default +. / / / +The +advantage +of +choosing +a +smaller +state +identifier +representation / / / -It -isn -' -t -clear -what +is +that the -match -semantics -for -anchored -overlapping +automaton +produced +will +be +smaller +. +This +might +be +/ +/ +/ +beneficial +for +just +generally +using +less +space +or +might +even +allow +it / / / -iterators -* -ought -* to -be -so -currently +fit +more +of +the +automaton +in +your +CPU +' +s +cache +leading +to +overall +/ +/ +/ +better +search +performance +. +/ +/ +/ +/ +/ +/ +Unlike +the +standard +build +method +this +can +report an error +if +the +/ +/ +/ +state +identifier +representation +cannot +support +the +size +of +the +/ +/ +/ +automaton +. +/ +/ +/ +/ +/ +/ +Note +that +the +state +identifier +representation is -returned +determined +by +the +/ +/ +/ +S +type +variable . -Callers +This +requires +a +type +hint +of +some +sort +either / / / -may -use -[ -AhoCorasick +by +specifying +the +return +type +or +using +the +turbofish +e +. +g +. +/ +/ +/ +build_with_size : : -try_find_overlapping -] -to -implement -their -own +< +u16 +_ +_ +> +( +. +. +. +) +. +/ / / / -semantics -if -desired -. +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Basic +usage +: / / / @@ -13214,9 +13586,7 @@ aho_corasick : { AhoCorasick -Anchored -Input -StartKind +AhoCorasickBuilder } ; / @@ -13225,19 +13595,41 @@ StartKind / / / +# +fn +example +( +) +- +> +Result +< +( +) +: +: +aho_corasick +: +: +Error +> +{ +/ +/ +/ let patterns = & [ " -append +foo " " -appendage +bar " " -app +baz " ] ; @@ -13245,152 +13637,250 @@ app / / let -haystack -= -" -appendappendage -app -" -; -/ -/ -/ -/ -/ -/ -let ac -= +: AhoCorasick +< +u8 +> += +AhoCorasickBuilder : : -builder +new ( ) / / / . -start_kind +build_with_size ( -StartKind -: -: -Anchored +patterns ) +? +; / / / -. -build +assert_eq +! ( -patterns +Some +( +1 ) -/ -/ -/ +ac . -unwrap +find ( +" +xxx +bar +xxx +" ) -; -/ -/ -/ -let -input -= -Input -: -: -new +. +map ( -haystack -) +| +m +| +m . -anchored +pattern ( -Anchored -: -: -Yes +) +) ) ; / / / -assert -! +# +Ok ( -ac -. -try_find_overlapping_iter ( -input ) -. -is_err +) +} +; +example ( ) +. +unwrap +( ) -; / / / / / / -# -Ok +/ +/ +/ +Or +alternatively +with +turbofish +: +/ +/ +/ +/ +/ +/ +/ +/ +/ +use +aho_corasick : : -< +AhoCorasickBuilder +; +/ +/ +/ +/ +/ +/ +# +fn +example ( ) -Box +- +> +Result < -dyn -std +( +) : : -error +aho_corasick : : Error > +{ +/ +/ +/ +let +patterns += +& +[ +" +foo +" +" +bar +" +" +baz +" +] +; +/ +/ +/ +let +ac += +AhoCorasickBuilder +: +: +new +( +) +/ +/ +/ +. +build_with_size +: +: +< +u8 +_ +_ > ( +patterns +) +? +; +/ +/ +/ +assert_eq +! +( +Some +( +1 +) +ac +. +find +( +" +xxx +bar +xxx +" +) +. +map +( +| +m +| +m +. +pattern +( +) +) +) +; +/ +/ +/ +# +Ok +( +( +) +) +} +; +example ( ) +. +unwrap +( ) / / / pub fn -try_find_overlapping_iter +build_with_size < -' -a -' -h +S I -: -Into -< -Input -< -' -h -> -> +P > ( & -' -a self -input +patterns : I ) @@ -13398,169 +13888,208 @@ I > Result < -FindOverlappingIter +AhoCorasick < -' -a -' -h +S +> +> +where +S +: +StateID +I +: +IntoIterator +< +Item += +P > -MatchError +P +: +AsRef +< +[ +u8 +] > { let -input +nfa = -input -. -into -( -) -; -enforce_anchored_consistency -( self . -start_kind -input +nfa_builder . -get_anchored +build ( -) +patterns ) ? ; -Ok +let +match_kind += +nfa +. +match_kind ( -FindOverlappingIter +) +. +clone ( +) +; +let +imp += +if +self +. +dfa +{ +let +dfa += self . -aut +dfa_builder . -try_find_overlapping_iter +build ( -input +& +nfa ) ? +; +Imp +: +: +DFA +( +dfa +) +} +else +{ +Imp +: +: +NFA +( +nfa ) +} +; +Ok +( +AhoCorasick +{ +imp +match_kind +} ) } / / / -Replace -all -matches -with -a -corresponding -value -in +Automatically +configure the -replace_with -/ -/ -/ -slice -given -. -Matches -correspond +settings +on +this +builder +according to the -same -matches -as -reported -by / / / -[ -AhoCorasick -: -: -try_find_iter -] -. -/ -/ -/ -/ -/ -/ -Replacements -are -determined -by -the -index -of +patterns +that +will +be +used +to +construct the -matching -pattern +automaton . / / / -For -example -if -the -pattern -with -index -2 -is -found -then -it -is / / / -replaced -by -replace_with -[ -2 -] +The +idea +here +is +to +balance +space +and +time +automatically . +That +is +when / / / +searching +a +small +number +of +patterns +this +will +attempt +to +use +the / / / -# -Panics -/ -/ -/ +fastest +possible +configuration +since +the +total +space +required +will +be / / / -This -panics -when -replace_with +small +anyway . -len -( -) -does -not -equal +As +the +number +of +patterns +grows +this +will +fall +back +to / / / -[ -AhoCorasick -: -: -patterns_len -] +slower +configurations +that +use +less +space . / / @@ -13568,78 +14097,41 @@ patterns_len / / / -# -Errors -/ -/ -/ -/ -/ -/ This -returns -an -error -when -this -Aho -- -Corasick -searcher -does -not -support +is +guaranteed +to +never +set +match_kind +but +any +other +option +may / / / -the -default -Input -configuration +be +overridden . -More -specifically -this -occurs -only / / / -when -the -Aho -- -Corasick -searcher -does -not -support -unanchored -searches / / / -since -this -replacement -routine -always -does -an -unanchored -search -. +# +Examples / / / / / / -# -Example -: -basic +Basic usage +: / / / @@ -13653,10 +14145,7 @@ use aho_corasick : : -{ -AhoCorasick -MatchKind -} +AhoCorasickBuilder ; / / @@ -13670,13 +14159,13 @@ patterns & [ " -append +foo " " -appendage +bar " " -app +baz " ] ; @@ -13684,42 +14173,21 @@ app / / let -haystack -= -" -append -the -app -to -the -appendage -" -; -/ -/ -/ -/ -/ -/ -let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / / / . -match_kind +auto_configure ( -MatchKind -: -: -LeftmostFirst +patterns ) / / @@ -13729,103 +14197,62 @@ build ( patterns ) +; / / / -. -unwrap +assert_eq +! +( +Some ( +1 ) -; -/ -/ -/ -let -result -= ac . -try_replace_all +find ( -haystack -& -[ -" -x -" -" -y -" " -z +xxx +bar +xxx " -] ) -? -; -/ -/ -/ -assert_eq -! +. +map ( -" -x -the -z -to -the -xage -" -result -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< +| +m +| +m +. +pattern ( ) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( ) ) +; / / / pub fn -try_replace_all +auto_configure < B +: +AsRef +< +[ +u8 +] +> > ( & +mut self -haystack -: -& -str -replace_with +patterns : & [ @@ -13834,178 +14261,265 @@ B ) - > -Result -< -String -MatchError -> -where -B -: -AsRef -< -str -> +& +mut +AhoCorasickBuilder { -enforce_anchored_consistency -( -self -. -start_kind -Anchored -: -: -No -) -? -; -self -. -aut -. -try_replace_all -( -haystack -replace_with -) -} / / -/ -Replace -all -matches -using -raw -bytes -with -a -corresponding -value -in +N +. +B +. +Currently +we +only +use the +length +of +patterns +to +make +a +/ / +decision +here +and +could +therefore +ask +for +an +ExactSizeIterator / / -replace_with -slice -given +instead . -Matches -correspond +But +it +' +s +conceivable +that +we +might +adapt +this to -the -same -matches -as -/ +look +at / / -reported -by -[ -AhoCorasick -: -: -try_find_iter -] +the +total +number +of +bytes +which +would +requires +a +second +pass . / / / / +The +logic +here +is +fairly +rudimentary +at +the +moment +but +probably / / -Replacements -are -determined -by -the -index -of -the -matching -pattern +OK . +The +idea +here +is +to +use +the +fastest +thing +possible +for +a +small / / -/ -For -example -if -the -pattern -with -index -2 -is -found -then -it +number +of +patterns +. +That is +a +DFA +with +no +byte +classes +since +byte / / -/ -replaced -by -replace_with -[ -2 -] +classes +require +an +extra +indirection +for +every +byte +searched . +With +a / / +moderate +number +of +patterns +we +still +want +a +DFA +but +save +on +both / / +space +and +compilation +time +by +enabling +byte +classes +. +Finally +fall / / -This -is +back +to the -fallible -version -of -[ -AhoCorasick -: -: -replace_all_bytes -] +slower +but +smaller +NFA . +if +patterns +. +len +( +) +< += +100 +{ / / +N +. +B +. +Using +byte +classes +can +actually +be +faster +by +improving / / +locality +but +this +only +really +applies +for +multi +- +megabyte / / -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -replace_with +automata +( +i +. +e +. +automata +that +don +' +t +fit +in +your +CPU +' +s +cache +) +. +self +. +dfa +( +true +) +; +} +else +if +patterns . len ( ) -does -not -equal +< += +5000 +{ +self +. +dfa +( +true +) +; +} +self +} / / / -[ -AhoCorasick -: -: -patterns_len -] +Set +the +desired +match +semantics . / / @@ -14013,66 +14527,69 @@ patterns_len / / / -# -Errors +The +default +is +MatchKind +: +: +Standard +which +corresponds +to +the +match / / / +semantics +supported +by +the +standard +textbook +description +of +the / / / -This -returns -an -error -when -this Aho - Corasick -searcher -does -not -support +algorithm +. +Namely +matches +are +reported +as +soon +as +they / / / -the -default -Input -configuration +are +found . -More -specifically +Moreover this -occurs -only -/ -/ -/ -when +is the -Aho -- -Corasick -searcher -does -not -support -unanchored -searches +only +way +to +get +overlapping +matches / / / -since -this -replacement -routine -always -does -an -unanchored -search +or +do +stream +searching . / / @@ -14080,65 +14597,244 @@ search / / / -# -Example -: -basic -usage -/ -/ -/ -/ -/ -/ +The +other +kinds +of +match +semantics +that +are +supported +are / / / -use -aho_corasick +MatchKind : : -{ -AhoCorasick +LeftmostFirst +and MatchKind -} -; +: +: +LeftmostLongest +. +The +former / / / +corresponds +to +the +match +you +would +get +if +you +were +to +try +to +match +/ +/ +/ +each +pattern +at +each +position +in +the +haystack +in +the +same +order +that +/ +/ +/ +you +give +to +the +automaton +. +That +is +it +returns +the +leftmost +match +/ +/ +/ +corresponding +the +earliest +pattern +given +to +the +automaton +. +The +latter +/ +/ +/ +corresponds +to +finding +the +longest +possible +match +among +all +leftmost +/ +/ +/ +matches +. +/ +/ +/ +/ +/ +/ +For +more +details +on +match +semantics +see +the +/ +/ +/ +[ +documentation +for +MatchKind +] +( +enum +. +MatchKind +. +html +) +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +In +these +examples +we +demonstrate +the +differences +between +match +/ +/ +/ +semantics +for +a +particular +set +of +patterns +in +a +specific +order +: +/ +/ +/ +b +abc +abcd +. +/ +/ +/ +/ +/ +/ +Standard +semantics +: +/ +/ +/ +/ +/ +/ +/ +/ +/ +use +aho_corasick +: +: +{ +AhoCorasickBuilder +MatchKind +} +; / / / -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] -; / / / let -haystack +patterns = +& +[ +" b " -append -the -app -to -the -appendage +" +abc +" +" +abcd +" +] +; +/ +/ +/ +let +haystack += +" +abcd " ; / @@ -14150,10 +14846,10 @@ appendage let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / @@ -14165,49 +14861,44 @@ match_kind MatchKind : : -LeftmostFirst +Standard ) / / -/ -. -build -( -patterns -) +default +not +necessary / / / . -unwrap +build ( +patterns ) ; / / / let -result +mat = ac . -try_replace_all_bytes +find ( haystack -& -[ -" -x -" -" -y -" +) +. +expect +( " -z +should +have +a +match " -] ) -? ; / / @@ -14215,20 +14906,25 @@ z assert_eq ! ( -b " -x -the -z -to -the -xage +b " +& +haystack +[ +mat . -to_vec +start ( ) -result +. +. +mat +. +end +( +) +] ) ; / @@ -14237,316 +14933,364 @@ result / / / -# -Ok -: +/ +/ +/ +Leftmost +- +first +semantics : -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) / / / -pub -fn -try_replace_all_bytes -< -B -> -( -& -self -haystack +/ +/ +/ +/ +/ +/ +use +aho_corasick : -& -[ -u8 -] -replace_with : +{ +AhoCorasickBuilder +MatchKind +} +; +/ +/ +/ +/ +/ +/ +let +patterns += & [ -B -] -) -- -> -Result -< -Vec -< -u8 -> -MatchError -> -where -B -: -AsRef -< -[ -u8 +" +b +" +" +abc +" +" +abcd +" ] -> -{ -enforce_anchored_consistency -( -self -. -start_kind -Anchored -: -: -No -) -? ; -self -. -aut -. -try_replace_all_bytes -( -haystack -replace_with -) -} / / / -Replace -all -matches -using -a -closure -called -on -each -match -. +let +haystack += +" +abcd +" +; / / / -Matches -correspond -to -the -same -matches -as -reported -by / / / -[ -AhoCorasick +let +ac += +AhoCorasickBuilder : : -try_find_iter -] -. +new +( +) / / / +. +match_kind +( +MatchKind +: +: +LeftmostFirst +) / / / -The -closure -accepts -three -parameters -: -the -match -found -the -text -of +. +build +( +patterns +) +; / / / -the -match -and +let +mat += +ac +. +find +( +haystack +) +. +expect +( +" +should +have a -string -buffer -with -which -to -write -the -replaced -text +match +" +) +; / / / +assert_eq +! +( +" +abc +" +& +haystack +[ +mat +. +start ( -if -any ) . -If -the -closure -returns -true -then -it -continues -to -the -next +. +mat +. +end +( +) +] +) +; / / / -match -. -If -the -closure -returns -false -then -searching -is -stopped -. / / / / / / -Note -that -any -matches -with -boundaries -that -don -' -t -fall -on -a -valid -UTF +Leftmost - -8 +longest +semantics +: / / / -boundary -are -silently -skipped -. / / / / / / -This -is -the -fallible -version -of -[ -AhoCorasick +use +aho_corasick : : -replace_all_with +{ +AhoCorasickBuilder +MatchKind +} +; +/ +/ +/ +/ +/ +/ +let +patterns += +& +[ +" +b +" +" +abc +" +" +abcd +" ] +; +/ +/ +/ +let +haystack += +" +abcd +" +; +/ +/ +/ +/ +/ +/ +let +ac += +AhoCorasickBuilder +: +: +new +( +) +/ +/ +/ . +match_kind +( +MatchKind +: +: +LeftmostLongest +) / / / +. +build +( +patterns +) +; / / / -# -Errors +let +mat += +ac +. +find +( +haystack +) +. +expect +( +" +should +have +a +match +" +) +; / / / +assert_eq +! +( +" +abcd +" +& +haystack +[ +mat +. +start +( +) +. +. +mat +. +end +( +) +] +) +; / / / -This -returns -an -error -when -this -Aho +pub +fn +match_kind +( +& +mut +self +kind +: +MatchKind +) - -Corasick -searcher -does -not -support +> +& +mut +AhoCorasickBuilder +{ +self +. +nfa_builder +. +match_kind +( +kind +) +; +self +} / / / +Enable +anchored +mode +which +requires +all +matches +to +start +at the -default -Input -configuration +/ +/ +/ +first +position +in +a +haystack . -More -specifically -this -occurs -only / / / -when -the -Aho -- -Corasick -searcher -does -not -support -unanchored -searches / / / -since -this -replacement -routine -always -does -an -unanchored -search +This +option +is +disabled +by +default . / / @@ -14578,10 +15322,7 @@ use aho_corasick : : -{ -AhoCorasick -MatchKind -} +AhoCorasickBuilder ; / / @@ -14595,13 +15336,10 @@ patterns & [ " -append -" -" -appendage +foo " " -app +bar " ] ; @@ -14612,12 +15350,7 @@ let haystack = " -append -the -app -to -the -appendage +foobar " ; / @@ -14629,22 +15362,19 @@ appendage let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / / / . -match_kind +anchored ( -MatchKind -: -: -LeftmostFirst +true ) / / @@ -14654,150 +15384,56 @@ build ( patterns ) +; / / / +assert_eq +! +( +1 +ac . -unwrap +find_iter +( +haystack +) +. +count ( ) +) ; / / / -let -mut -result -= -String -: -: -new -( -) -; -/ -/ -/ -ac -. -try_replace_all_with -( -haystack -& -mut -result -| -mat -_ -dst -| -{ -/ -/ -/ -dst -. -push_str -( -& -mat -. -pattern -( -) -. -as_usize -( -) -. -to_string -( -) -) -; -/ -/ -/ -true -/ -/ -/ -} -) -? -; -/ -/ -/ -assert_eq -! -( -" -0 -the -2 -to -the -0age -" -result -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) / / / / / / +When +searching +for +overlapping +matches +all +matches +that +start +at / / / -Stopping -the -replacement -by -returning -false -( -continued -from the -/ -/ -/ -example -above -) +beginning +of +a +haystack +will +be +reported : / / @@ -14808,331 +15444,212 @@ above / / / -# use aho_corasick : : -{ -AhoCorasick -MatchKind -PatternID -} +AhoCorasickBuilder ; / / / -# +/ +/ +/ let patterns = & [ " -append -" -" -appendage +foo " " -app +foofoo " ] ; / / / -# let haystack = " -append -the -app -to -the -appendage +foofoo " ; / / / -# +/ +/ +/ let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / / / -# . -match_kind +anchored ( -MatchKind -: -: -LeftmostFirst +true ) / / / -# . build ( patterns ) +; / / / -# +assert_eq +! +( +2 +ac . -unwrap +find_overlapping_iter ( +haystack ) -; -/ -/ -/ -let -mut -result -= -String -: -: -new +. +count ( ) +) ; / / / -ac +/ +/ +A +non +- +anchored +search +would +return +3 +matches . -try_replace_all_with -( -haystack -& -mut -result -| -mat -_ -dst -| -{ / / / -dst -. -push_str +pub +fn +anchored ( & -mat -. -pattern -( +mut +self +yes +: +bool ) +- +> +& +mut +AhoCorasickBuilder +{ +self . -as_usize -( -) +nfa_builder . -to_string +anchored ( -) +yes ) ; +self +} / / / -mat +Enable +ASCII +- +aware +case +insensitive +matching . -pattern -( -) -! -= -PatternID -: -: -must -( -2 -) -/ -/ -/ -} -) -? -; -/ -/ / -assert_eq -! -( -" -0 -the -2 -to -the -appendage -" -result -) -; / / / / / -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) +When +this +option +is +enabled +searching +will +be +performed +without / / / -pub -fn -try_replace_all_with -< -F -> +respect +to +case +for +ASCII +letters ( -& -self -haystack -: -& -str -dst -: -& -mut -String -replace_with -: -F -) +a - -> -Result -< -( -) -MatchError -> -where -F -: -FnMut -( -& -Match -& -str -& -mut -String -) +z +and +A - -> -bool -{ -enforce_anchored_consistency -( -self -. -start_kind -Anchored -: -: -No +Z ) -? -; -self -. -aut +only . -try_replace_all_with -( -haystack -dst -replace_with -) -} / / / -Replace -all -matches -using -raw -bytes -with -a -closure -called -on -each / / / -match -. -Matches -correspond -to +Enabling +this +option +does +not +change the -same -matches -as -reported -by +search +algorithm +but +it +may / / / -[ -AhoCorasick -: -: -try_find_iter -] +increase +the +size +of +the +automaton . / / @@ -15140,156 +15657,115 @@ try_find_iter / / / -The -closure -accepts -three -parameters +* +* +NOTE : -the -match -found -the -text -of +* +* +It +is +unlikely +that +support +for +Unicode +case +folding +will / / / +be +added +in the -match -and +future +. +The +ASCII +case +works +via a -byte -buffer -with -which +simple +hack to -write the -replaced -text / / / -( -if -any -) -. -If -the -closure -returns -true -then -it -continues -to -the -next +underlying +automaton +but +full +Unicode +handling +requires +a +fair +bit +of / / / -match +sophistication . If -the -closure -returns -false -then -searching -is -stopped -. -/ -/ -/ +you +do +need +Unicode +handling +you +might +consider / / / -This -is +using the -fallible -version -of -/ -/ -/ [ -AhoCorasick -: -: -replace_all_with_bytes +regex +crate ] -. -/ -/ -/ -/ -/ -/ -# -Errors +( +https +: / / +docs +. +rs / +regex +) +or +the +lower +level / / / -This -returns -an -error -when -this -Aho +[ +regex - -Corasick -searcher -does -not -support -/ +automata +crate +] +( +https +: / / -the -default -Input -configuration +docs . -More -specifically -this -occurs -only -/ -/ +rs / -when -the -Aho +regex - -Corasick -searcher -does -not -support -unanchored -searches -/ -/ -/ -since -this -replacement -routine -always -does -an -unanchored -search +automata +) . / / @@ -15321,10 +15797,7 @@ use aho_corasick : : -{ -AhoCorasick -MatchKind -} +AhoCorasickBuilder ; / / @@ -15338,13 +15811,13 @@ patterns & [ " -append +FOO " " -appendage +bAr " " -app +BaZ " ] ; @@ -15354,14 +15827,10 @@ app let haystack = -b " -append -the -app -to -the -appendage +foo +bar +baz " ; / @@ -15373,22 +15842,19 @@ appendage let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) / / / . -match_kind +ascii_case_insensitive ( -MatchKind -: -: -LeftmostFirst +true ) / / @@ -15398,507 +15864,600 @@ build ( patterns ) -/ -/ -/ -. -unwrap -( -) ; / / / -let -mut -result -= -vec +assert_eq ! -[ -] -; -/ -/ -/ +( +3 ac . -try_replace_all_with_bytes +find_iter ( haystack -& -mut -result -| -mat -_ -dst -| -{ -/ -/ -/ -dst -. -extend -( -mat -. -pattern -( ) . -as_usize +count ( ) -. -to_string +) +; +/ +/ +/ +pub +fn +ascii_case_insensitive ( +& +mut +self +yes +: +bool ) +- +> +& +mut +AhoCorasickBuilder +{ +self . -bytes +nfa_builder +. +ascii_case_insensitive ( -) +yes ) ; +self +} / / / -true +Set +the +limit +on +how +many +NFA +states +use +a +dense +representation +for / / / -} -) -? -; +their +transitions +. / / / -assert_eq -! -( -b -" -0 -the -2 -to -the -0age -" -. -to_vec -( -) -result -) -; / / / +A +dense +representation +uses +more +space +but +supports +faster +access +to / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) +transitions +at +search +time +. +Thus +this +setting +permits +the +control +of +a / / / +space +vs +time +trade +off +when +using +the +NFA +variant +of +Aho +- +Corasick +. / / / / / / -Stopping +This +limit +is +expressed +in +terms +of the -replacement -by -returning -false -( -continued -from +depth +of +a +state +i +. +e +. the / / / -example -above -) -: +number +of +transitions +from +the +starting +state +of +the +NFA +. +The +idea +is / / / +that +most +of +the +time +searching +will +be +spent +near +the +starting +state / / / +of +the +automaton +so +states +near +the +start +state +should +use +a +dense / / / -# +representation +. +States +further +away +from +the +start +state +would +then use -aho_corasick -: -: -{ -AhoCorasick -MatchKind -PatternID -} -; / / / -# -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] -; +a +sparse +representation +which +uses +less +space +but +is +slower +to +access / / / -# -let -haystack -= -b -" -append -the -app -to -the -appendage -" -; +transitions +at +search +time +. / / / -# -let -ac -= -AhoCorasick -: -: -builder -( -) / / / -# +By +default +this +is +set +to +a +low +but +non +- +zero +number . -match_kind -( -MatchKind -: -: -LeftmostFirst -) / / / -# -. -build -( -patterns -) / / / -# +This +setting +has +no +effect +if +the +dfa +option +is +enabled . -unwrap +pub +fn +dense_depth +( +& +mut +self +depth +: +usize +) +- +> +& +mut +AhoCorasickBuilder +{ +self +. +nfa_builder +. +dense_depth ( +depth ) ; +self +} / / / -let -mut -result -= -vec -! -[ -] -; +Compile +the +standard +Aho +- +Corasick +automaton +into +a +deterministic +finite / / / -ac -. -try_replace_all_with_bytes +automaton ( -haystack -& -mut -result -| -mat -_ -dst -| -{ +DFA +) +. / / / -dst -. -extend -( -mat -. -pattern +/ +/ +/ +When +this +is +disabled ( +which +is +the +default ) -. -as_usize +then +a +non +- +deterministic +/ +/ +/ +finite +automaton ( +NFA ) +is +used +instead . -to_string +/ +/ +/ +/ +/ +/ +The +main +benefit +to +a +DFA +is +that +it +can +execute +searches +more +quickly +/ +/ +/ +than +a +NFA ( +perhaps +2 +- +4 +times +as +fast ) . -bytes -( -) -) -; +The +main +drawback +is +that +the / / / -mat +DFA +uses +more +space +and +can +take +much +longer +to +build . -pattern -( -) -! -= -PatternID -: -: -must -( -2 -) / / / -} -) -? -; / / / -assert_eq -! -( -b -" -0 +Enabling +this +option +does +not +change the -2 -to +time +complexity +for +/ +/ +/ +constructing the -appendage -" -. -to_vec +Aho +- +Corasick +automaton +( +which +is +O ( +p ) -result +where +/ +/ +/ +p +is +the +total +number +of +patterns +being +compiled ) -; +. +Enabling +this / / / +option +does +however +reduce +the +time +complexity +of +non +- +overlapping / / / -# -Ok -: -: -< +searches +from +O ( +n ++ +p ) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( +to +O ( +n ) -) +where +n +is +the +length +of +the / / / -pub -fn -try_replace_all_with_bytes -< -F -> -( -& -self haystack -: -& -[ -u8 -] -dst -: -& -mut -Vec -< -u8 -> -replace_with -: -F -) -- -> -Result -< +. +/ +/ +/ +/ +/ +/ +In +general +it +' +s +a +good +idea +to +enable +this +if +you +' +re +searching +a +/ +/ +/ +small +number +of +fairly +short +patterns ( +~ +1000 ) -MatchError -> -where -F -: -FnMut +or +if +you +want +the +/ +/ +/ +fastest +possible +search +without +regard +to +compilation +time +or +space +/ +/ +/ +usage +. +pub +fn +dfa ( & -Match -& -[ -u8 -] -& mut -Vec -< -u8 -> +self +yes +: +bool ) - > -bool +& +mut +AhoCorasickBuilder { -enforce_anchored_consistency -( self . -start_kind -Anchored -: -: -No -) -? +dfa += +yes ; self -. -aut -. -try_replace_all_with_bytes -( -haystack -dst -replace_with -) } / / / -Returns -an -iterator -of -non -- -overlapping -matches -in -the -given -/ -/ -/ -stream -. -Matches -correspond -to -the -same -matches -as -reported -by -/ -/ -/ -[ -AhoCorasick -: -: -try_find_iter -] +Enable +heuristic +prefilter +optimizations . / / @@ -15906,89 +16465,70 @@ try_find_iter / / / -The -matches -yielded -by -this -iterator -use -absolute -position -offsets -in +When +enabled +searching +will +attempt +to +quickly +skip +to +match / / / -the -stream -given -where -the -first -byte -has -index -0 +candidates +using +specialized +literal +search +routines . -Matches -are +A +prefilter / / / -yieled -until -the -stream +cannot +always +be +used +and is -exhausted +generally +treated +as +a +heuristic . +It / / / -/ -/ -/ -Each -item -yielded -by +can +be +useful +to +disable +this +if the -iterator +prefilter is -an -Result -< -Match +observed +to +be / / / -std -: -: -io -: -: -Error -> -where -an -error -is -yielded -if -there -was +sub +- +optimal +for a -problem -/ -/ -/ -reading -from -the -reader -given +particular +workload . / / @@ -15996,112 +16536,75 @@ given / / / -When -searching -a -stream -an -internal -buffer +This is -used +enabled +by +default . -Therefore -callers -/ -/ -/ -should -avoiding -providing -a -buffered -reader -if -possible -. -/ -/ -/ -/ -/ -/ -This -is -the -fallible -version -of -[ -AhoCorasick -: +pub +fn +prefilter +( +& +mut +self +yes : -stream_find_iter -] +bool +) +- +> +& +mut +AhoCorasickBuilder +{ +self . -/ -/ -/ -Note -that -both -methods -return -iterators -that -produce -Result -values +nfa_builder . +prefilter +( +yes +) +; +self +} / / / -The -difference -is -that -this -routine -returns -an -error -if -_construction_ -/ -/ -/ +Shrink +the +size of the -iterator -failed -. -The -Result -values -yield +transition +alphabet by -the -iterator +mapping +bytes +to +their / / / -come -from -whether -the -given -reader -returns +equivalence +classes +. +This +only +has an -error -or -not -during +effect +when the +dfa +option +is / / / -search +enabled . / / @@ -16109,79 +16612,95 @@ search / / / -# -Memory -usage +When +enabled +each +a +DFA +will +use +a +map +from +all +possible +bytes / / / +to +their +corresponding +equivalence +class +. +Each +equivalence +class / / / -In -general -searching -streams -will -use +represents a -constant -amount +set of -memory -for +bytes +that +does +not +discriminate +between +a +match / / / -its -internal -buffer +and +a +non +- +match +in +the +DFA . -The -one -requirement -is -that +For +example the -internal -buffer +patterns +bar +and +baz / / / -must -be +have at least -the -size +five +equivalence +classes +: +singleton +sets of -the -longest -possible -match -. -In -most -use -/ -/ -/ -cases -the -default -buffer -size -will -be -much -larger -than -any -individual +b +a +r / / / -match +and +z +and +a +final +set +that +contains +every +other +byte . / / @@ -16189,67 +16708,89 @@ match / / / -# -Errors +The +advantage +of +this +map +is +that +the +size +of +the +transition +table +can / / / +be +reduced +drastically +from +# +states +* +256 +* +sizeof +( +id +) +to / / / -This -returns -an -error -when -this -Aho -- -Corasick -searcher -does -not -support +# +states +* +k +* +sizeof +( +id +) +where +k +is +the +number +of +equivalence / / / -the -default -Input -configuration +classes +. +As +a +result +total +space +usage +can +decrease +substantially . -More -specifically -this -occurs -only / / / -when -the -Aho -- -Corasick -searcher -does -not -support -unanchored -searches +Moreover +since +a +smaller +alphabet +is +used +compilation +becomes +faster / / / -since -this -stream -searching -routine -always -does -an -unanchored -search +as +well . / / @@ -16257,430 +16798,622 @@ search / / / -This -also -returns -an -error -if -the -searcher -does -not -support -stream +The +disadvantage +of +this +map +is +that +every +byte +searched +must +be / / / -searches -. -Only -searchers -built -with -[ -MatchKind -: -: -Standard -] -semantics +passed +through +this +map +before +it +can +be +used +to +determine +the +next / / / -support -stream -searches +transition . +This +has +a +small +match +time +performance +cost +. +However +if / / / +the +DFA +is +otherwise +very +large +without +byte +classes +then +using +byte / / / -# -Example -: -basic -usage +classes +can +greatly +improve +memory +locality +and +thus +lead +to +better / / / +overall +performance +. / / / / / / -use -aho_corasick +This +option +is +enabled +by +default +. +# +[ +deprecated +( +since += +" +0 +. +7 +. +16 +" +note += +" +not +carrying +its +weight +will +be +always +enabled +see : +https : -{ -AhoCorasick -PatternID -} -; / / +github +. +com / +BurntSushi / +aho +- +corasick / +issues / -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app +57 " +) ] +pub +fn +byte_classes +( +& +mut +self +yes +: +bool +) +- +> +& +mut +AhoCorasickBuilder +{ +self +. +dfa_builder +. +byte_classes +( +yes +) ; +self +} / / / -let -haystack -= -" -append +Premultiply +state +identifiers +in the -app -to +transition +table +. +This +only +has +/ +/ +/ +an +effect +when the -appendage -" -; +dfa +option +is +enabled +. / / / / / / -let -ac -= -AhoCorasick -: -: -new -( -patterns -) +When +enabled +state +identifiers +are +premultiplied +to +point +to +their +/ +/ +/ +corresponding +row +in +the +transition +table . -unwrap -( -) -; +That +is +given +the +i +th / / / -let -mut -matches -= -vec -! -[ -] -; +state +its +corresponding +premultiplied +identifier +is +i +* +k +where +k / / / -for -result -in -ac +is +the +alphabet +size +of +the +automaton . -try_stream_find_iter ( -haystack +The +alphabet +size +is +at +most +/ +/ +/ +256 +but +is +in +practice +smaller +if +byte +classes +is +enabled . -as_bytes -( ) -) -? -{ / / / -let -mat -= -result -? -; / / / -matches +When +state +identifiers +are +not +premultiplied +then +the +identifier +of +/ +/ +/ +the +i +th +state +is +i . -push -( -mat +/ +/ +/ +/ +/ +/ +The +advantage +of +premultiplying +state +identifiers +is +that +is +saves +a +/ +/ +/ +multiplication +instruction +per +byte +when +searching +with +a +DFA . -pattern -( -) -) -; +This +has / / / -} +been +observed +to +lead +to +a +20 +% +performance +benefit +in +micro +- +benchmarks +. / / / -assert_eq -! -( -vec -! -[ / / / -PatternID -: -: -must -( -2 -) +The +primary +disadvantage +of +premultiplying +state +identifiers +is / / / -PatternID -: -: -must -( -2 -) +that +they +require +a +larger +integer +size +to +represent +. +For +example / / / -PatternID -: -: -must -( -2 -) +if +the +DFA +has +200 +states +then +its +premultiplied +form +requires +16 / / / -] -matches -) -; +bits +to +represent +every +possible +state +identifier +where +as +its / / / +non +- +premultiplied +form +only +requires +8 +bits +. / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) / / / +This +option +is +enabled +by +default +. # [ -cfg +deprecated ( -feature +since = " -std +0 +. +7 +. +16 " -) -] -pub -fn -try_stream_find_iter -< -' -a -R -: -std -: -: -io +note += +" +not +carrying +its +weight +will +be +always +enabled +see : +https : -Read -> +/ +/ +github +. +com +/ +BurntSushi +/ +aho +- +corasick +/ +issues +/ +57 +" +) +] +pub +fn +premultiply ( & -' -a +mut self -rdr +yes : -R +bool ) - > -Result -< -StreamFindIter -< -' -a -R -> -MatchError -> +& +mut +AhoCorasickBuilder { -enforce_anchored_consistency -( self . -start_kind -Anchored -: -: -No -) -? -; -self -. -aut -. -try_stream_find_iter -( -rdr -) +dfa_builder . -map +premultiply ( -StreamFindIter +yes ) +; +self +} } / / / -Search +A +knob for -and -replace -all -matches +controlling +the +match +semantics of -this +an +Aho +- +Corasick automaton -in +. / / / -the -given -reader -and -write -the -replacements -to -the -given / / / -writer -. -Matches -correspond -to -the -same -matches -as -reported -by +There +are +two +generally +different +ways +that +Aho +- +Corasick +automatons +can / / / -[ -AhoCorasick -: -: -try_find_iter -] +report +matches . +The +first +way +is +the +" +standard +" +approach +that +results +from / / / +implementing +most +textbook +explanations +of +Aho +- +Corasick +. +The +second +way +is / / / -Replacements -are -determined -by -the -index -of +to +report +only the -matching -pattern +leftmost +non +- +overlapping +matches . -For +The +leftmost +approach / / / -example -if -the -pattern -with -index -2 -is -found -then -it is -replaced -by +in +turn +split +into +two +different +ways +of +resolving +ambiguous +matches +: / / / -replace_with -[ -2 -] +leftmost +- +first +and +leftmost +- +longest . / / @@ -16688,130 +17421,155 @@ replace_with / / / -After -all -matches -are -replaced +The +Standard +match +kind +is the -writer +default +and is -_not_ -flushed -. +the +only +one +that +supports / / / +overlapping +matches +and +stream +searching +. +( +Trying +to +find +overlapping / / / -If -there -was -a -problem -reading -from -the -given -reader or -writing -to -the +streaming +matches +using +leftmost +match +semantics +will +result +in +a / / / -given -writer -then -the -corresponding -io -: -: -Error -is -returned -and -all -/ -/ -/ -replacement -is -stopped +panic +. +) +The +Standard +match +kind +will +report +matches +as +they +are +seen . -/ -/ -/ / / / When searching -a -stream -an -internal -buffer -is -used -. -Therefore -callers +for +overlapping +matches +then +all +possible +matches +are / / / -should -avoiding -providing -a -buffered -reader -if -possible +reported . -However +When +searching +for +non +- +overlapping +matches +the +first +match +seen / / / -callers -may -want -to -provide -a -buffered -writer +is +reported . +For +example +for +non +- +overlapping +matches +given +the +patterns / / / +abcd +and +b +and +the +subject +string +abcdef +only +a +match +for +b +is / / / -Note -that -there +reported +since +it is -currently -no -infallible -version -of -this -routine +detected +first . +The +abcd +match +is +never +reported / / / -/ -/ -/ -# -Memory -usage +since +it +overlaps +with +the +b +match +. / / / @@ -16819,213 +17577,309 @@ usage / / In -general -searching -streams -will -use -a -constant -amount -of -memory -for +contrast +the +leftmost +match +kind +always +prefers +the +leftmost +match / / / -its -internal -buffer +among +all +possible +matches . -The -one -requirement -is -that +Given the -internal -buffer +same +example +as +above +with +abcd +and / / / -must -be -at -least +b +as +patterns +and +abcdef +as the -size -of +subject +string the -longest -possible +leftmost match -. -In -most -use +is / / / -cases +abcd +since +it +begins +before the -default -buffer -size -will -be -much -larger -than -any -individual +b +match +even +though +the +b +match +is / / / +detected +before +the +abcd match . +In +this +case +the +b +match +is +not / / / +reported +at +all +since +it +overlaps +with +the +abcd +match +. / / / -# -Panics / / / +The +difference +between +leftmost +- +first +and +leftmost +- +longest +is +in +how +they / / / -This -panics +resolve +ambiguous +matches when -replace_with -. -len -( -) -does -not -equal +there +are +multiple +leftmost +matches +to / / / -[ -AhoCorasick -: -: -patterns_len -] +choose +from . +Leftmost +- +first +always +chooses +the +pattern +that +was +provided / / / +earliest +where +as +leftmost +- +longest +always +chooses +the +longest +matching / / / -# -Errors -/ -/ -/ +pattern +. +For +example +given +the +patterns +a +and +ab +and +the +subject / / / -This -returns -an -error -when -this -Aho +string +ab +the +leftmost - -Corasick -searcher -does -not -support +first +match +is +a +but +the +leftmost +- +longest +match / / / +is +ab +. +Conversely +if the -default -Input -configuration +patterns +were +given +in +reverse +order +i +. +e . -More -specifically -this -occurs -only / / / -when +ab +and +a +then +both the -Aho +leftmost - -Corasick -searcher -does -not -support -unanchored -searches +first +and +leftmost +- +longest +matches / / / -since -this -stream -searching -routine -always -does -an -unanchored -search +would +be +ab . +Stated +differently +the +leftmost +- +first +match +depends +on +the / / / +order +in +which +the +patterns +were +given +to +the +Aho +- +Corasick +automaton +. / / / -This -also -returns -an -error +Because +of +that +when +leftmost +- +first +matching +is +used if -the -searcher -does -not -support -stream +a +pattern +A / / / -searches -. -Only -searchers -built -with -[ -MatchKind -: -: -Standard -] -semantics +that +appears +before +a +pattern +B +is +a +prefix +of +B +then +it +is +impossible / / / -support -stream -searches +to +ever +observe +a +match +of +B . / / @@ -17033,619 +17887,547 @@ searches / / / -# -Example -: -basic -usage -/ -/ -/ +If +you +' +re +not +sure +which +match +kind +to +pick +then +stick +with +the +standard / / / +kind +which +is +the +default +. +In +particular +if +you +need +overlapping +or / / / +streaming +matches +then +you +_must_ use -aho_corasick -: -: -AhoCorasick -; -/ -/ -/ +the +standard +kind +. +The +leftmost / / / -let -patterns -= -& -[ -" -fox -" -" -brown -" -" -quick -" -] -; -/ -/ -/ -let -haystack -= -" -The -quick -brown -fox +kinds +are +useful +in +specific +circumstances . -" -; +For +example +leftmost +- +first +can / / / -let -replace_with -= -& -[ -" -sloth -" -" -grey -" -" -slow -" -] -; +be +very +useful +as +a +way +to +implement +match +priority +based +on +the +order +of / / / +patterns +given +and +leftmost +- +longest +can +be +useful +for +dictionary +searching / / / -let -ac -= -AhoCorasick -: -: -new -( -patterns -) +such +that +only +the +longest +matching +words +are +reported . -unwrap -( -) -; / / / -let -mut -result -= -vec -! -[ -] -; / / / -ac -. -try_stream_replace_all -( +# +Relationship +with +regular +expression +alternations / / / -haystack -. -as_bytes -( -) / / / -& -mut -result +Understanding +match +semantics +can +be +a +little +tricky +and +one +easy +way / / / -replace_with +to +conceptualize +non +- +overlapping +matches +from +an +Aho +- +Corasick +automaton / / / -) -? -; +is +to +think +about +them +as +a +simple +alternation +of +literals +in +a +regular / / / -assert_eq -! -( -b -" -The -slow -grey -sloth +expression . -" +For +example +let +' +s +say +we +wanted +to +match +the +strings +/ +/ +/ +Sam +and +Samwise +which +would +turn +into +the +regex +Sam +| +Samwise . -to_vec -( -) -result -) -; +It / / / +turns +out +that +regular +expression +engines +have +two +different +ways +of / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) +matching +this +alternation +. +The +first +way +leftmost +- +longest +is +commonly / / / -# -[ -cfg +found +in +POSIX +compatible +implementations +of +regular +expressions ( -feature -= -" -std -" -) -] -pub -fn -try_stream_replace_all -< -R -W -B -> -( -& -self -rdr -: -R -wtr -: -W -replace_with -: -& -[ -B -] -) -- -> -Result -< -( -) -std -: -: -io -: -: -Error -> -where -R -: -std -: -: -io -: -: -Read -W -: -std -: -: -io -: -: -Write -B -: -AsRef -< -[ -u8 -] -> -{ -enforce_anchored_consistency -( -self -. -start_kind -Anchored -: -: -No -) -. -map_err -( -| -e -| -std -: -: -io -: -: -Error -: -: -new -( -std -: -: -io -: -: -ErrorKind -: -: -Other -e -) -) -? -; -self -. -aut -. -try_stream_replace_all -( -rdr -wtr -replace_with -) -} -/ -/ -/ -Search -the -given -reader -and -replace -all -matches -of -this -automaton +such +as / / / -using -the -given -closure +grep +) . The -result +second +way +leftmost +- +first is -written -to -the -given +commonly +found +in +backtracking / / / -writer -. -Matches -correspond -to -the -same -matches +implementations +such as -reported -by -/ -/ -/ -[ -AhoCorasick -: -: -try_find_iter -] +Perl . +( +Some +regex +engines +such +as +RE2 +and +Rust +' +s / / / +regex +engine +do +not +use +backtracking +but +still +implement +leftmost +- +first / / / -The -closure -accepts -three -parameters -: -the +semantics +in +an +effort +to match -found the -text +behavior of +dominant +backtracking / / / -the -match +regex +engines +such +as +those +found +in +Perl +Ruby +Python +Javascript and -the -writer -with -which -to -write -the -replaced -text -( -if -any -) -. -/ / / / -/ -/ -After -all -matches -are -replaced -the -writer -is -_not_ -flushed +PHP . +) / / / / / / -If -there -was +That +is +when +matching +Sam +| +Samwise +against +Samwise a -problem -reading -from -the -given -reader -or -writing -to -the +POSIX +regex / / / -given -writer -then -the -corresponding -io -: -: -Error -is -returned -and -all -/ -/ -/ -replacement +will +match +Samwise +because +it is -stopped -. +the +longest +possible +match +but +a / / / +Perl +- +like +regex +will +match +Sam +since +it +appears +earlier +in +the / / / -When -searching -a -stream -an -internal -buffer -is -used +alternation . -Therefore -callers -/ -/ -/ -should -avoiding -providing +Indeed +the +regex +Sam +| +Samwise +in a -buffered -reader -if -possible -. -However +Perl +- +like +regex +engine / / / -callers -may -want -to -provide -a -buffered -writer +will +never +match +Samwise +since +Sam +will +always +have +higher +priority . / / / +Conversely +matching +the +regex +Samwise +| +Sam +against +Samwise +will +lead +to / / / -Note -that -there -is -currently -no -infallible -version +a +match of -this -routine -. -/ -/ -/ +Samwise +in +both +POSIX +and +Perl +- +like +regexes +since +Samwise +is / / / -# -Memory -usage +still +longest +match +but +it +also +appears +earlier +than +Sam +. / / / / / / -In -general -searching -streams -will -use -a -constant -amount +The +" +standard +" +match +semantics of -memory -for +Aho +- +Corasick +generally +don +' +t +correspond / / / -its -internal -buffer -. -The -one -requirement -is -that +to the -internal -buffer +match +semantics +of +any +large +group +of +regex +implementations +so / / / -must +there +' +s +no +direct +analogy +that +can be -at -least -the -size -of -the -longest -possible -match +made +here . -In -most -use +Standard +match +semantics / / / -cases -the -default -buffer -size -will -be -much -larger -than -any -individual +are +generally +useful +for +overlapping +matches +or +if +you +just +want +to +see / / / -match +matches +as +they +are +detected . / / @@ -17653,108 +18435,136 @@ match / / / -# -Errors +The +main +conclusion +to +draw +from +this +section +is +that +the +match +semantics / / / +can +be +tweaked +to +precisely +match +either +Perl +- +like +regex +alternations +or / / / -This -returns -an -error -when -this -Aho -- -Corasick -searcher -does -not -support +POSIX +regex +alternations +. +# +[ +derive +( +Clone +Copy +Debug +Eq +PartialEq +) +] +pub +enum +MatchKind +{ / / / -the -default -Input -configuration +Use +standard +match +semantics +which +support +overlapping +matches . -More -specifically -this -occurs -only +When / / / -when -the -Aho +used +with +non - -Corasick -searcher -does -not -support -unanchored -searches +overlapping +matches +matches +are +reported +as +they +are / / / -since -this -stream -searching -routine -always -does -an -unanchored -search +seen . +Standard / / / +Use +leftmost +- +first +match +semantics +which +reports +leftmost +matches +. / / / -This -also -returns -an -error -if +When +there +are +multiple +possible +leftmost +matches the -searcher -does -not -support -stream +match / / / -searches -. -Only -searchers -built -with -[ -MatchKind -: -: -Standard -] -semantics +corresponding +to +the +pattern +that +appeared +earlier +when +constructing / / / -support -stream -searches +the +automaton +is +reported . / / @@ -17762,9128 +18572,617 @@ searches / / / -# -Example -: -basic -usage +This +does +* +* +not +* +* +support +overlapping +matches +or +stream +searching +. +If / / / +this +match +kind +is +used +attempting +to +find +overlapping +matches +or / / / +stream +matches +will +panic +. +LeftmostFirst / / / -use -std -: -: -io -: -: -Write -; +Use +leftmost +- +longest +match +semantics +which +reports +leftmost +matches +. / / / -use -aho_corasick -: -: -AhoCorasick -; +When +there +are +multiple +possible +leftmost +matches +the +longest +match / / / +is +chosen +. / / / -let -patterns -= -& -[ -" -fox -" -" -brown -" -" -quick -" -] -; / / / -let -haystack -= -" -The -quick -brown -fox +This +does +* +* +not +* +* +support +overlapping +matches +or +stream +searching . -" -; +If / / / +this +match +kind +is +used +attempting +to +find +overlapping +matches +or / / / -let -ac -= -AhoCorasick -: -: -new -( -patterns -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -result -= -vec -! -[ -] -; -/ -/ -/ -ac +stream +matches +will +panic . -try_stream_replace_all_with -( +LeftmostLongest / / / -haystack +Hints +that +destructuring +should +not +be +exhaustive . -as_bytes -( -) / / / -& -mut -result / / / -| -mat -_ -wtr -| -{ +This +enum +may +grow +additional +variants +so +this +makes +sure +clients / / / -wtr -. -write_all -( -mat -. -pattern -( -) -. -as_usize -( -) -. -to_string -( -) +don +' +t +count +on +exhaustive +matching . -as_bytes ( -) -) -/ -/ -/ -} -/ -/ -/ -) -? -; +Otherwise +adding +a +new +variant / / / -assert_eq -! -( -b -" -The -2 -1 -0 -. -" +could +break +existing +code . -to_vec -( -) -result ) -; -/ -/ -/ -/ -/ -/ # -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( +[ +doc ( +hidden ) -) +] +__Nonexhaustive +} / / / -# -[ -cfg -( -feature -= -" -std -" -) -] -pub -fn -try_stream_replace_all_with -< -R -W -F -> -( -& -self -rdr -: -R -wtr -: -W -replace_with -: -F -) -- -> -Result -< -( -) -std -: -: -io -: -: -Error -> -where -R -: -std -: -: -io -: -: -Read -W -: -std -: -: -io -: -: -Write -F -: -FnMut -( -& -Match -& -[ -u8 -] -& -mut -W -) -- -> -Result -< -( -) -std -: -: -io -: -: -Error -> -{ -enforce_anchored_consistency -( -self -. -start_kind -Anchored -: -: -No -) -. -map_err -( -| -e -| -std -: -: -io +The +default +match +kind +is +MatchKind : : -Error -: -: -new -( -std -: -: -io -: -: -ErrorKind -: -: -Other -e -) -) -? -; -self -. -aut -. -try_stream_replace_all_with -( -rdr -wtr -replace_with -) -} -} -/ -/ -/ -Routines -for -querying -information -about -the -Aho -- -Corasick -automaton -. -impl -AhoCorasick -{ -/ -/ -/ -Returns -the -kind -of -the -Aho -- -Corasick -automaton -used -by -this -searcher -. -/ -/ -/ -/ -/ -/ -Knowing -the -Aho -- -Corasick -kind -is -principally -useful -for -diagnostic -/ -/ -/ -purposes -. -In -particular -if -no -specific -kind -was -given -to -/ -/ -/ -[ -AhoCorasickBuilder -: -: -kind -] -then -one -is -automatically -chosen -and -/ -/ -/ -this -routine -will -report -which -one -. -/ -/ -/ -/ -/ -/ -Note -that -the -heuristics -used -for -choosing -which -AhoCorasickKind -/ -/ -/ -may -be -changed -in -a -semver -compatible -release -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -AhoCorasickKind -} -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -& -[ -" -foo -" -" -bar -" -" -quux -" -" -baz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -The -specific -Aho -- -Corasick -kind -chosen -is -not -guaranteed -! -/ -/ -/ -assert_eq -! -( -AhoCorasickKind -: -: -DFA -ac -. -kind -( -) -) -; -/ -/ -/ -pub -fn -kind -( -& -self -) -- -> -AhoCorasickKind -{ -self -. -kind -} -/ -/ -/ -Returns -the -type -of -starting -search -configuration -supported -by -this -/ -/ -/ -Aho -- -Corasick -automaton -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -StartKind -} -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -& -[ -" -foo -" -" -bar -" -" -quux -" -" -baz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -StartKind -: -: -Unanchored -ac -. -start_kind -( -) -) -; -/ -/ -/ -pub -fn -start_kind -( -& -self -) -- -> -StartKind -{ -self -. -start_kind -} -/ -/ -/ -Returns -the -match -kind -used -by -this -automaton -. -/ -/ -/ -/ -/ -/ -The -match -kind -is -important -because -it -determines -what -kinds -of -/ -/ -/ -matches -are -returned -. -Also -some -operations -( -such -as -overlapping -/ -/ -/ -search -and -stream -searching -) -are -only -supported -when -using -the -/ -/ -/ -[ -MatchKind -: -: -Standard -] -match -kind -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -& -[ -" -foo -" -" -bar -" -" -quux -" -" -baz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -MatchKind -: -: -Standard -ac -. -match_kind -( -) -) -; -/ -/ -/ -pub -fn -match_kind -( -& -self -) -- -> -MatchKind -{ -self -. -aut -. -match_kind -( -) -} -/ -/ -/ -Returns -the -length -of -the -shortest -pattern -matched -by -this -automaton -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -AhoCorasick -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -& -[ -" -foo -" -" -bar -" -" -quux -" -" -baz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -3 -ac -. -min_pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -an -AhoCorasick -automaton -has -a -minimum -length -of -0 -if -/ -/ -/ -and -only -if -it -can -match -the -empty -string -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -AhoCorasick -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -& -[ -" -foo -" -" -" -" -quux -" -" -baz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -0 -ac -. -min_pattern_len -( -) -) -; -/ -/ -/ -pub -fn -min_pattern_len -( -& -self -) -- -> -usize -{ -self -. -aut -. -min_pattern_len -( -) -} -/ -/ -/ -Returns -the -length -of -the -longest -pattern -matched -by -this -automaton -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -AhoCorasick -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -& -[ -" -foo -" -" -bar -" -" -quux -" -" -baz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -4 -ac -. -max_pattern_len -( -) -) -; -/ -/ -/ -pub -fn -max_pattern_len -( -& -self -) -- -> -usize -{ -self -. -aut -. -max_pattern_len -( -) -} -/ -/ -/ -Return -the -total -number -of -patterns -matched -by -this -automaton -. -/ -/ -/ -/ -/ -/ -This -includes -patterns -that -may -never -participate -in -a -match -. -For -/ -/ -/ -example -if -[ -MatchKind -: -: -LeftmostFirst -] -match -semantics -are -used -and -/ -/ -/ -the -patterns -Sam -and -Samwise -were -used -to -build -the -automaton -( -in -/ -/ -/ -that -order -) -then -Samwise -can -never -participate -in -a -match -because -/ -/ -/ -Sam -will -always -take -priority -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -AhoCorasick -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -& -[ -" -foo -" -" -bar -" -" -baz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -3 -ac -. -patterns_len -( -) -) -; -/ -/ -/ -pub -fn -patterns_len -( -& -self -) -- -> -usize -{ -self -. -aut -. -patterns_len -( -) -} -/ -/ -/ -Returns -the -approximate -total -amount -of -heap -used -by -this -automaton -in -/ -/ -/ -units -of -bytes -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -This -example -shows -the -difference -in -heap -usage -between -a -few -/ -/ -/ -configurations -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -! -cfg -! -( -target_pointer_width -= -" -64 -" -) -{ -return -; -} -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -AhoCorasickKind -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -kind -( -None -) -/ -/ -default -/ -/ -/ -. -build -( -& -[ -" -foobar -" -" -bruce -" -" -triskaidekaphobia -" -" -springsteen -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -5_632 -ac -. -memory_usage -( -) -) -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -kind -( -None -) -/ -/ -default -/ -/ -/ -. -ascii_case_insensitive -( -true -) -/ -/ -/ -. -build -( -& -[ -" -foobar -" -" -bruce -" -" -triskaidekaphobia -" -" -springsteen -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -11_136 -ac -. -memory_usage -( -) -) -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -kind -( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -) -/ -/ -/ -. -ascii_case_insensitive -( -true -) -/ -/ -/ -. -build -( -& -[ -" -foobar -" -" -bruce -" -" -triskaidekaphobia -" -" -springsteen -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -10_879 -ac -. -memory_usage -( -) -) -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -kind -( -Some -( -AhoCorasickKind -: -: -ContiguousNFA -) -) -/ -/ -/ -. -ascii_case_insensitive -( -true -) -/ -/ -/ -. -build -( -& -[ -" -foobar -" -" -bruce -" -" -triskaidekaphobia -" -" -springsteen -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -2_584 -ac -. -memory_usage -( -) -) -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -/ -/ -/ -. -ascii_case_insensitive -( -true -) -/ -/ -/ -. -build -( -& -[ -" -foobar -" -" -bruce -" -" -triskaidekaphobia -" -" -springsteen -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -While -this -shows -the -DFA -being -the -biggest -here -by -a -small -margin -/ -/ -/ -/ -/ -don -' -t -let -the -difference -fool -you -. -With -such -a -small -number -of -/ -/ -/ -/ -/ -patterns -the -difference -is -small -but -a -bigger -number -of -patterns -/ -/ -/ -/ -/ -will -reveal -that -the -rate -of -growth -of -the -DFA -is -far -bigger -than -/ -/ -/ -/ -/ -the -NFAs -above -. -For -a -large -number -of -patterns -it -is -easy -for -the -/ -/ -/ -/ -/ -DFA -to -take -an -order -of -magnitude -more -heap -space -( -or -more -! -) -. -/ -/ -/ -assert_eq -! -( -11_136 -ac -. -memory_usage -( -) -) -; -/ -/ -/ -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -aut -. -memory_usage -( -) -} -} -/ -/ -We -provide -a -manual -debug -impl -so -that -we -don -' -t -include -the -' -start_kind -' -/ -/ -principally -because -it -' -s -kind -of -weird -to -do -so -and -because -it -screws -with -/ -/ -the -carefully -curated -debug -output -for -the -underlying -automaton -. -impl -core -: -: -fmt -: -: -Debug -for -AhoCorasick -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -" -AhoCorasick -" -) -. -field -( -& -self -. -aut -) -. -finish -( -) -} -} -/ -/ -/ -An -iterator -of -non -- -overlapping -matches -in -a -particular -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -matches -according -to -the -[ -MatchKind -] -used -by -this -/ -/ -/ -automaton -. -/ -/ -/ -/ -/ -/ -This -iterator -is -constructed -via -the -[ -AhoCorasick -: -: -find_iter -] -and -/ -/ -/ -[ -AhoCorasick -: -: -try_find_iter -] -methods -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -AhoCorasick -automaton -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -h -refers -to -the -lifetime -of -the -haystack -being -searched -. -# -[ -derive -( -Debug -) -] -pub -struct -FindIter -< -' -a -' -h -> -( -automaton -: -: -FindIter -< -' -a -' -h -Arc -< -dyn -AcAutomaton -> -> -) -; -impl -< -' -a -' -h -> -Iterator -for -FindIter -< -' -a -' -h -> -{ -type -Item -= -Match -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -self -. -0 -. -next -( -) -} -} -/ -/ -/ -An -iterator -of -overlapping -matches -in -a -particular -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -will -report -all -possible -matches -in -a -particular -haystack -/ -/ -/ -even -when -the -matches -overlap -. -/ -/ -/ -/ -/ -/ -This -iterator -is -constructed -via -the -[ -AhoCorasick -: -: -find_overlapping_iter -] -/ -/ -/ -and -[ -AhoCorasick -: -: -try_find_overlapping_iter -] -methods -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -AhoCorasick -automaton -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -h -refers -to -the -lifetime -of -the -haystack -being -searched -. -# -[ -derive -( -Debug -) -] -pub -struct -FindOverlappingIter -< -' -a -' -h -> -( -automaton -: -: -FindOverlappingIter -< -' -a -' -h -Arc -< -dyn -AcAutomaton -> -> -) -; -impl -< -' -a -' -h -> -Iterator -for -FindOverlappingIter -< -' -a -' -h -> -{ -type -Item -= -Match -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -self -. -0 -. -next -( -) -} -} -/ -/ -/ -An -iterator -that -reports -Aho -- -Corasick -matches -in -a -stream -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -elements -of -type -Result -< -Match -std -: -: -io -: -: -Error -> -/ -/ -/ -where -an -error -is -reported -if -there -was -a -problem -reading -from -the -/ -/ -/ -underlying -stream -. -The -iterator -terminates -only -when -the -underlying -stream -/ -/ -/ -reaches -EOF -. -/ -/ -/ -/ -/ -/ -This -iterator -is -constructed -via -the -[ -AhoCorasick -: -: -stream_find_iter -] -and -/ -/ -/ -[ -AhoCorasick -: -: -try_stream_find_iter -] -methods -. -/ -/ -/ -/ -/ -/ -The -type -variable -R -refers -to -the -io -: -: -Read -stream -that -is -being -read -/ -/ -/ -from -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -corresponding -/ -/ -/ -[ -AhoCorasick -] -searcher -. -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -derive -( -Debug -) -] -pub -struct -StreamFindIter -< -' -a -R -> -( -automaton -: -: -StreamFindIter -< -' -a -Arc -< -dyn -AcAutomaton -> -R -> -) -; -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -< -' -a -R -: -std -: -: -io -: -: -Read -> -Iterator -for -StreamFindIter -< -' -a -R -> -{ -type -Item -= -Result -< -Match -std -: -: -io -: -: -Error -> -; -fn -next -( -& -mut -self -) -- -> -Option -< -Result -< -Match -std -: -: -io -: -: -Error -> -> -{ -self -. -0 -. -next -( -) -} -} -/ -/ -/ -A -builder -for -configuring -an -Aho -- -Corasick -automaton -. -/ -/ -/ -/ -/ -/ -# -Quick -advice -/ -/ -/ -/ -/ -/ -* -Use -[ -AhoCorasickBuilder -: -: -match_kind -] -to -configure -your -searcher -/ -/ -/ -with -[ -MatchKind -: -: -LeftmostFirst -] -if -you -want -to -match -how -backtracking -/ -/ -/ -regex -engines -execute -searches -for -pat1 -| -pat2 -| -. -. -| -patN -. -Use -/ -/ -/ -[ -MatchKind -: -: -LeftmostLongest -] -if -you -want -to -match -how -POSIX -regex -engines -/ -/ -/ -do -it -. -/ -/ -/ -* -If -you -need -an -anchored -search -use -[ -AhoCorasickBuilder -: -: -start_kind -] -to -/ -/ -/ -set -the -[ -StartKind -: -: -Anchored -] -mode -since -[ -StartKind -: -: -Unanchored -] -is -the -/ -/ -/ -default -. -Or -just -use -[ -StartKind -: -: -Both -] -to -support -both -types -of -searches -. -/ -/ -/ -* -You -might -want -to -use -[ -AhoCorasickBuilder -: -: -kind -] -to -set -your -searcher -/ -/ -/ -to -always -use -a -[ -AhoCorasickKind -: -: -DFA -] -if -search -speed -is -critical -and -/ -/ -/ -memory -usage -isn -' -t -a -concern -. -Otherwise -not -setting -a -kind -will -probably -/ -/ -/ -make -the -right -choice -for -you -. -Beware -that -if -you -use -[ -StartKind -: -: -Both -] -/ -/ -/ -to -build -a -searcher -that -supports -both -unanchored -and -anchored -searches -/ -/ -/ -_and_ -you -set -[ -AhoCorasickKind -: -: -DFA -] -then -the -DFA -will -essentially -be -/ -/ -/ -duplicated -to -support -both -simultaneously -. -This -results -in -very -high -memory -/ -/ -/ -usage -. -/ -/ -/ -* -For -all -other -options -their -defaults -are -almost -certainly -what -you -want -. -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -AhoCorasickBuilder -{ -nfa_noncontiguous -: -noncontiguous -: -: -Builder -nfa_contiguous -: -contiguous -: -: -Builder -dfa -: -dfa -: -: -Builder -kind -: -Option -< -AhoCorasickKind -> -start_kind -: -StartKind -} -impl -AhoCorasickBuilder -{ -/ -/ -/ -Create -a -new -builder -for -configuring -an -Aho -- -Corasick -automaton -. -/ -/ -/ -/ -/ -/ -The -builder -provides -a -way -to -configure -a -number -of -things -including -/ -/ -/ -ASCII -case -insensitivity -and -what -kind -of -match -semantics -are -used -. -pub -fn -new -( -) -- -> -AhoCorasickBuilder -{ -AhoCorasickBuilder -: -: -default -( -) -} -/ -/ -/ -Build -an -Aho -- -Corasick -automaton -using -the -configuration -set -on -this -/ -/ -/ -builder -. -/ -/ -/ -/ -/ -/ -A -builder -may -be -reused -to -create -more -automatons -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasickBuilder -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -foo -" -" -bar -" -" -baz -" -] -; -/ -/ -/ -let -ac -= -AhoCorasickBuilder -: -: -new -( -) -. -build -( -patterns -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -PatternID -: -: -must -( -1 -) -) -/ -/ -/ -ac -. -find -( -" -xxx -bar -xxx -" -) -. -map -( -| -m -| -m -. -pattern -( -) -) -/ -/ -/ -) -; -/ -/ -/ -pub -fn -build -< -I -P -> -( -& -self -patterns -: -I -) -- -> -Result -< -AhoCorasick -BuildError -> -where -I -: -IntoIterator -< -Item -= -P -> -P -: -AsRef -< -[ -u8 -] -> -{ -let -nfa -= -self -. -nfa_noncontiguous -. -build -( -patterns -) -? -; -let -( -aut -kind -) -: -( -Arc -< -dyn -AcAutomaton -> -AhoCorasickKind -) -= -match -self -. -kind -{ -None -= -> -{ -debug -! -( -" -asked -for -automatic -Aho -- -Corasick -implementation -\ -criteria -: -< -patterns -: -{ -: -? -} -max -pattern -len -: -{ -: -? -} -\ -start -kind -: -{ -: -? -} -> -" -nfa -. -patterns_len -( -) -nfa -. -max_pattern_len -( -) -self -. -start_kind -) -; -self -. -build_auto -( -nfa -) -} -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -= -> -{ -debug -! -( -" -forcefully -chose -noncontiguous -NFA -" -) -; -( -Arc -: -: -new -( -nfa -) -AhoCorasickKind -: -: -NoncontiguousNFA -) -} -Some -( -AhoCorasickKind -: -: -ContiguousNFA -) -= -> -{ -debug -! -( -" -forcefully -chose -contiguous -NFA -" -) -; -let -cnfa -= -self -. -nfa_contiguous -. -build_from_noncontiguous -( -& -nfa -) -? -; -( -Arc -: -: -new -( -cnfa -) -AhoCorasickKind -: -: -ContiguousNFA -) -} -Some -( -AhoCorasickKind -: -: -DFA -) -= -> -{ -debug -! -( -" -forcefully -chose -DFA -" -) -; -let -dfa -= -self -. -dfa -. -build_from_noncontiguous -( -& -nfa -) -? -; -( -Arc -: -: -new -( -dfa -) -AhoCorasickKind -: -: -DFA -) -} -} -; -Ok -( -AhoCorasick -{ -aut -kind -start_kind -: -self -. -start_kind -} -) -} -/ -/ -/ -Implements -the -automatic -selection -logic -for -the -Aho -- -Corasick -/ -/ -/ -implementation -to -use -. -Since -all -Aho -- -Corasick -automatons -are -built -/ -/ -/ -from -a -non -- -contiguous -NFA -the -caller -is -responsible -for -building -/ -/ -/ -that -first -. -fn -build_auto -( -& -self -nfa -: -noncontiguous -: -: -NFA -) -- -> -( -Arc -< -dyn -AcAutomaton -> -AhoCorasickKind -) -{ -/ -/ -We -try -to -build -a -DFA -if -we -have -a -very -small -number -of -patterns -/ -/ -otherwise -the -memory -usage -just -gets -too -crazy -. -We -also -only -do -it -/ -/ -when -the -start -kind -is -unanchored -or -anchored -but -not -both -because -/ -/ -both -implies -two -full -copies -of -the -transition -table -. -let -try_dfa -= -! -matches -! -( -self -. -start_kind -StartKind -: -: -Both -) -& -& -nfa -. -patterns_len -( -) -< -= -100 -; -if -try_dfa -{ -match -self -. -dfa -. -build_from_noncontiguous -( -& -nfa -) -{ -Ok -( -dfa -) -= -> -{ -debug -! -( -" -chose -a -DFA -" -) -; -return -( -Arc -: -: -new -( -dfa -) -AhoCorasickKind -: -: -DFA -) -; -} -Err -( -_err -) -= -> -{ -debug -! -( -" -failed -to -build -DFA -trying -something -else -: -{ -} -" -_err -) -; -} -} -} -/ -/ -We -basically -always -want -a -contiguous -NFA -if -the -limited -/ -/ -circumstances -in -which -we -use -a -DFA -are -not -true -. -It -is -quite -fast -/ -/ -and -has -excellent -memory -usage -. -The -only -way -we -don -' -t -use -it -is -if -/ -/ -there -are -so -many -states -that -it -can -' -t -fit -in -a -contiguous -NFA -. -/ -/ -And -the -only -way -to -know -that -is -to -try -to -build -it -. -Building -a -/ -/ -contiguous -NFA -is -mostly -just -reshuffling -data -from -a -noncontiguous -/ -/ -NFA -so -it -isn -' -t -too -expensive -especially -relative -to -building -a -/ -/ -noncontiguous -NFA -in -the -first -place -. -match -self -. -nfa_contiguous -. -build_from_noncontiguous -( -& -nfa -) -{ -Ok -( -nfa -) -= -> -{ -debug -! -( -" -chose -contiguous -NFA -" -) -; -return -( -Arc -: -: -new -( -nfa -) -AhoCorasickKind -: -: -ContiguousNFA -) -; -} -# -[ -allow -( -unused_variables -) -] -/ -/ -unused -when -' -logging -' -is -disabled -Err -( -_err -) -= -> -{ -debug -! -( -" -failed -to -build -contiguous -NFA -\ -trying -something -else -: -{ -} -" -_err -) -; -} -} -debug -! -( -" -chose -non -- -contiguous -NFA -" -) -; -( -Arc -: -: -new -( -nfa -) -AhoCorasickKind -: -: -NoncontiguousNFA -) -} -/ -/ -/ -Set -the -desired -match -semantics -. -/ -/ -/ -/ -/ -/ -The -default -is -[ -MatchKind -: -: -Standard -] -which -corresponds -to -the -match -/ -/ -/ -semantics -supported -by -the -standard -textbook -description -of -the -/ -/ -/ -Aho -- -Corasick -algorithm -. -Namely -matches -are -reported -as -soon -as -they -/ -/ -/ -are -found -. -Moreover -this -is -the -only -way -to -get -overlapping -matches -/ -/ -/ -or -do -stream -searching -. -/ -/ -/ -/ -/ -/ -The -other -kinds -of -match -semantics -that -are -supported -are -/ -/ -/ -[ -MatchKind -: -: -LeftmostFirst -] -and -[ -MatchKind -: -: -LeftmostLongest -] -. -The -/ -/ -/ -former -corresponds -to -the -match -you -would -get -if -you -were -to -try -to -/ -/ -/ -match -each -pattern -at -each -position -in -the -haystack -in -the -same -order -/ -/ -/ -that -you -give -to -the -automaton -. -That -is -it -returns -the -leftmost -match -/ -/ -/ -corresponding -to -the -earliest -pattern -given -to -the -automaton -. -The -/ -/ -/ -latter -corresponds -to -finding -the -longest -possible -match -among -all -/ -/ -/ -leftmost -matches -. -/ -/ -/ -/ -/ -/ -For -more -details -on -match -semantics -see -the -[ -documentation -for -/ -/ -/ -MatchKind -] -( -MatchKind -) -. -/ -/ -/ -/ -/ -/ -Note -that -setting -this -to -[ -MatchKind -: -: -LeftmostFirst -] -or -/ -/ -/ -[ -MatchKind -: -: -LeftmostLongest -] -will -cause -some -search -routines -on -/ -/ -/ -[ -AhoCorasick -] -to -return -an -error -( -or -panic -if -you -' -re -using -the -/ -/ -/ -infallible -API -) -. -Notably -this -includes -stream -and -overlapping -/ -/ -/ -searches -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -In -these -examples -we -demonstrate -the -differences -between -match -/ -/ -/ -semantics -for -a -particular -set -of -patterns -in -a -specific -order -: -/ -/ -/ -b -abc -abcd -. -/ -/ -/ -/ -/ -/ -Standard -semantics -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let -haystack -= -" -abcd -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -Standard -) -/ -/ -default -not -necessary -/ -/ -/ -. -build -( -patterns -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -mat -= -ac -. -find -( -haystack -) -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -b -" -& -haystack -[ -mat -. -start -( -) -. -. -mat -. -end -( -) -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Leftmost -- -first -semantics -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let -haystack -= -" -abcd -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -/ -/ -/ -. -build -( -patterns -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -mat -= -ac -. -find -( -haystack -) -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -abc -" -& -haystack -[ -mat -. -start -( -) -. -. -mat -. -end -( -) -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Leftmost -- -longest -semantics -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let -haystack -= -" -abcd -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -LeftmostLongest -) -/ -/ -/ -. -build -( -patterns -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -mat -= -ac -. -find -( -haystack -) -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -abcd -" -& -haystack -[ -mat -. -start -( -) -. -. -mat -. -end -( -) -] -) -; -/ -/ -/ -pub -fn -match_kind -( -& -mut -self -kind -: -MatchKind -) -- -> -& -mut -AhoCorasickBuilder -{ -self -. -nfa_noncontiguous -. -match_kind -( -kind -) -; -self -. -nfa_contiguous -. -match_kind -( -kind -) -; -self -. -dfa -. -match_kind -( -kind -) -; -self -} -/ -/ -/ -Sets -the -starting -state -configuration -for -the -automaton -. -/ -/ -/ -/ -/ -/ -Every -Aho -- -Corasick -automaton -is -capable -of -having -two -start -states -: -one -/ -/ -/ -that -is -used -for -unanchored -searches -and -one -that -is -used -for -anchored -/ -/ -/ -searches -. -Some -automatons -like -the -NFAs -support -this -with -almost -zero -/ -/ -/ -additional -cost -. -Other -automatons -like -the -DFA -require -two -copies -of -/ -/ -/ -the -underlying -transition -table -to -support -both -simultaneously -. -/ -/ -/ -/ -/ -/ -Because -there -may -be -an -added -non -- -trivial -cost -to -supporting -both -it -/ -/ -/ -is -possible -to -configure -which -starting -state -configuration -is -needed -. -/ -/ -/ -/ -/ -/ -Indeed -since -anchored -searches -tend -to -be -somewhat -more -rare -/ -/ -/ -_only_ -unanchored -searches -are -supported -by -default -. -Thus -/ -/ -/ -[ -StartKind -: -: -Unanchored -] -is -the -default -. -/ -/ -/ -/ -/ -/ -Note -that -when -this -is -set -to -[ -StartKind -: -: -Unanchored -] -then -/ -/ -/ -running -an -anchored -search -will -result -in -an -error -( -or -a -panic -/ -/ -/ -if -using -the -infallible -APIs -) -. -Similarly -when -this -is -set -to -/ -/ -/ -[ -StartKind -: -: -Anchored -] -then -running -an -unanchored -search -will -/ -/ -/ -result -in -an -error -( -or -a -panic -if -using -the -infallible -APIs -) -. -When -/ -/ -/ -[ -StartKind -: -: -Both -] -is -used -then -both -unanchored -and -anchored -searches -/ -/ -/ -are -always -supported -. -/ -/ -/ -/ -/ -/ -Also -note -that -even -if -an -AhoCorasick -searcher -is -using -an -NFA -/ -/ -/ -internally -( -which -always -supports -both -unanchored -and -anchored -/ -/ -/ -searches -) -an -error -will -still -be -reported -for -a -search -that -isn -' -t -/ -/ -/ -supported -by -the -configuration -set -via -this -method -. -This -means -/ -/ -/ -for -example -that -an -error -is -never -dependent -on -which -internal -/ -/ -/ -implementation -of -Aho -- -Corasick -is -used -. -/ -/ -/ -/ -/ -/ -# -Example -: -anchored -search -/ -/ -/ -/ -/ -/ -This -shows -how -to -build -a -searcher -that -only -supports -anchored -/ -/ -/ -searches -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -/ -/ -/ -AhoCorasick -Anchored -Input -Match -MatchKind -StartKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Anchored -) -/ -/ -/ -. -build -( -& -[ -" -b -" -" -abc -" -" -abcd -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -An -unanchored -search -is -not -supported -! -An -error -here -is -guaranteed -/ -/ -/ -/ -/ -given -the -configuration -above -regardless -of -which -kind -of -/ -/ -/ -/ -/ -Aho -- -Corasick -implementation -ends -up -being -used -internally -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo -abcd -" -) -. -anchored -( -Anchored -: -: -No -) -; -/ -/ -/ -assert -! -( -ac -. -try_find -( -input -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo -abcd -" -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -None -ac -. -try_find -( -input -) -? -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -abcd -" -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -0 -. -. -3 -) -) -ac -. -try_find -( -input -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -unanchored -and -anchored -searches -/ -/ -/ -/ -/ -/ -This -shows -how -to -build -a -searcher -that -supports -both -unanchored -and -/ -/ -/ -anchored -searches -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -/ -/ -/ -AhoCorasick -Anchored -Input -Match -MatchKind -StartKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Both -) -/ -/ -/ -. -build -( -& -[ -" -b -" -" -abc -" -" -abcd -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo -abcd -" -) -. -anchored -( -Anchored -: -: -No -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -4 -. -. -7 -) -) -ac -. -try_find -( -input -) -? -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo -abcd -" -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -None -ac -. -try_find -( -input -) -? -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -abcd -" -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -0 -. -. -3 -) -) -ac -. -try_find -( -input -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -start_kind -( -& -mut -self -kind -: -StartKind -) -- -> -& -mut -AhoCorasickBuilder -{ -self -. -dfa -. -start_kind -( -kind -) -; -self -. -start_kind -= -kind -; -self -} -/ -/ -/ -Enable -ASCII -- -aware -case -insensitive -matching -. -/ -/ -/ -/ -/ -/ -When -this -option -is -enabled -searching -will -be -performed -without -/ -/ -/ -respect -to -case -for -ASCII -letters -( -a -- -z -and -A -- -Z -) -only -. -/ -/ -/ -/ -/ -/ -Enabling -this -option -does -not -change -the -search -algorithm -but -it -may -/ -/ -/ -increase -the -size -of -the -automaton -. -/ -/ -/ -/ -/ -/ -* -* -NOTE -: -* -* -It -is -unlikely -that -support -for -Unicode -case -folding -will -/ -/ -/ -be -added -in -the -future -. -The -ASCII -case -works -via -a -simple -hack -to -the -/ -/ -/ -underlying -automaton -but -full -Unicode -handling -requires -a -fair -bit -of -/ -/ -/ -sophistication -. -If -you -do -need -Unicode -handling -you -might -consider -/ -/ -/ -using -the -[ -regex -crate -] -( -https -: -/ -/ -docs -. -rs -/ -regex -) -or -the -lower -level -/ -/ -/ -[ -regex -- -automata -crate -] -( -https -: -/ -/ -docs -. -rs -/ -regex -- -automata -) -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -AhoCorasick -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -FOO -" -" -bAr -" -" -BaZ -" -] -; -/ -/ -/ -let -haystack -= -" -foo -bar -baz -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -ascii_case_insensitive -( -true -) -/ -/ -/ -. -build -( -patterns -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -3 -ac -. -find_iter -( -haystack -) -. -count -( -) -) -; -/ -/ -/ -pub -fn -ascii_case_insensitive -( -& -mut -self -yes -: -bool -) -- -> -& -mut -AhoCorasickBuilder -{ -self -. -nfa_noncontiguous -. -ascii_case_insensitive -( -yes -) -; -self -. -nfa_contiguous -. -ascii_case_insensitive -( -yes -) -; -self -. -dfa -. -ascii_case_insensitive -( -yes -) -; -self -} -/ -/ -/ -Choose -the -type -of -underlying -automaton -to -use -. -/ -/ -/ -/ -/ -/ -Currently -there -are -four -choices -: -/ -/ -/ -/ -/ -/ -* -[ -AhoCorasickKind -: -: -NoncontiguousNFA -] -instructs -the -searcher -to -/ -/ -/ -use -a -[ -noncontiguous -: -: -NFA -] -. -A -noncontiguous -NFA -is -the -fastest -to -/ -/ -/ -be -built -has -moderate -memory -usage -and -is -typically -the -slowest -to -/ -/ -/ -execute -a -search -. -/ -/ -/ -* -[ -AhoCorasickKind -: -: -ContiguousNFA -] -instructs -the -searcher -to -use -a -/ -/ -/ -[ -contiguous -: -: -NFA -] -. -A -contiguous -NFA -is -a -little -slower -to -build -than -/ -/ -/ -a -noncontiguous -NFA -has -excellent -memory -usage -and -is -typically -a -/ -/ -/ -little -slower -than -a -DFA -for -a -search -. -/ -/ -/ -* -[ -AhoCorasickKind -: -: -DFA -] -instructs -the -searcher -to -use -a -/ -/ -/ -[ -dfa -: -: -DFA -] -. -A -DFA -is -very -slow -to -build -uses -exorbitant -amounts -of -/ -/ -/ -memory -but -will -typically -execute -searches -the -fastest -. -/ -/ -/ -* -None -( -the -default -) -instructs -the -searcher -to -choose -the -" -best -" -/ -/ -/ -Aho -- -Corasick -implementation -. -This -choice -is -typically -based -primarily -/ -/ -/ -on -the -number -of -patterns -. -/ -/ -/ -/ -/ -/ -Setting -this -configuration -does -not -change -the -time -complexity -for -/ -/ -/ -constructing -the -Aho -- -Corasick -automaton -( -which -is -O -( -p -) -where -p -/ -/ -/ -is -the -total -number -of -patterns -being -compiled -) -. -Setting -this -to -/ -/ -/ -[ -AhoCorasickKind -: -: -DFA -] -does -however -reduce -the -time -complexity -of -/ -/ -/ -non -- -overlapping -searches -from -O -( -n -+ -p -) -to -O -( -n -) -where -n -is -the -/ -/ -/ -length -of -the -haystack -. -/ -/ -/ -/ -/ -/ -In -general -you -should -probably -stick -to -the -default -unless -you -have -/ -/ -/ -some -kind -of -reason -to -use -a -specific -Aho -- -Corasick -implementation -. -For -/ -/ -/ -example -you -might -choose -AhoCorasickKind -: -: -DFA -if -you -don -' -t -care -/ -/ -/ -about -memory -usage -and -want -the -fastest -possible -search -times -. -/ -/ -/ -/ -/ -/ -Setting -this -guarantees -that -the -searcher -returned -uses -the -chosen -/ -/ -/ -implementation -. -If -that -implementation -could -not -be -constructed -then -/ -/ -/ -an -error -will -be -returned -. -In -contrast -when -None -is -used -it -is -/ -/ -/ -possible -for -it -to -attempt -to -construct -for -example -a -contiguous -/ -/ -/ -NFA -and -have -it -fail -. -In -which -case -it -will -fall -back -to -using -a -/ -/ -/ -noncontiguous -NFA -. -/ -/ -/ -/ -/ -/ -If -None -is -given -then -one -may -use -[ -AhoCorasick -: -: -kind -] -to -determine -/ -/ -/ -which -Aho -- -Corasick -implementation -was -chosen -. -/ -/ -/ -/ -/ -/ -Note -that -the -heuristics -used -for -choosing -which -AhoCorasickKind -/ -/ -/ -may -be -changed -in -a -semver -compatible -release -. -pub -fn -kind -( -& -mut -self -kind -: -Option -< -AhoCorasickKind -> -) -- -> -& -mut -AhoCorasickBuilder -{ -self -. -kind -= -kind -; -self -} -/ -/ -/ -Enable -heuristic -prefilter -optimizations -. -/ -/ -/ -/ -/ -/ -When -enabled -searching -will -attempt -to -quickly -skip -to -match -/ -/ -/ -candidates -using -specialized -literal -search -routines -. -A -prefilter -/ -/ -/ -cannot -always -be -used -and -is -generally -treated -as -a -heuristic -. -It -/ -/ -/ -can -be -useful -to -disable -this -if -the -prefilter -is -observed -to -be -/ -/ -/ -sub -- -optimal -for -a -particular -workload -. -/ -/ -/ -/ -/ -/ -Currently -prefilters -are -typically -only -active -when -building -searchers -/ -/ -/ -with -a -small -( -less -than -100 -) -number -of -patterns -. -/ -/ -/ -/ -/ -/ -This -is -enabled -by -default -. -pub -fn -prefilter -( -& -mut -self -yes -: -bool -) -- -> -& -mut -AhoCorasickBuilder -{ -self -. -nfa_noncontiguous -. -prefilter -( -yes -) -; -self -. -nfa_contiguous -. -prefilter -( -yes -) -; -self -. -dfa -. -prefilter -( -yes -) -; -self -} -/ -/ -/ -Set -the -limit -on -how -many -states -use -a -dense -representation -for -their -/ -/ -/ -transitions -. -Other -states -will -generally -use -a -sparse -representation -. -/ -/ -/ -/ -/ -/ -A -dense -representation -uses -more -memory -but -is -generally -faster -since -/ -/ -/ -the -next -transition -in -a -dense -representation -can -be -computed -in -a -/ -/ -/ -constant -number -of -instructions -. -A -sparse -representation -uses -less -/ -/ -/ -memory -but -is -generally -slower -since -the -next -transition -in -a -sparse -/ -/ -/ -representation -requires -executing -a -variable -number -of -instructions -. -/ -/ -/ -/ -/ -/ -This -setting -is -only -used -when -an -Aho -- -Corasick -implementation -is -used -/ -/ -/ -that -supports -the -dense -versus -sparse -representation -trade -off -. -Not -all -/ -/ -/ -do -. -/ -/ -/ -/ -/ -/ -This -limit -is -expressed -in -terms -of -the -depth -of -a -state -i -. -e -. -the -/ -/ -/ -number -of -transitions -from -the -starting -state -of -the -automaton -. -The -/ -/ -/ -idea -is -that -most -of -the -time -searching -will -be -spent -near -the -starting -/ -/ -/ -state -of -the -automaton -so -states -near -the -start -state -should -use -a -/ -/ -/ -dense -representation -. -States -further -away -from -the -start -state -would -/ -/ -/ -then -use -a -sparse -representation -. -/ -/ -/ -/ -/ -/ -By -default -this -is -set -to -a -low -but -non -- -zero -number -. -Setting -this -to -/ -/ -/ -0 -is -almost -never -what -you -want -since -it -is -likely -to -make -searches -/ -/ -/ -very -slow -due -to -the -start -state -itself -being -forced -to -use -a -sparse -/ -/ -/ -representation -. -However -it -is -unlikely -that -increasing -this -number -/ -/ -/ -will -help -things -much -since -the -most -active -states -have -a -small -depth -. -/ -/ -/ -More -to -the -point -the -memory -usage -increases -superlinearly -as -this -/ -/ -/ -number -increases -. -pub -fn -dense_depth -( -& -mut -self -depth -: -usize -) -- -> -& -mut -AhoCorasickBuilder -{ -self -. -nfa_noncontiguous -. -dense_depth -( -depth -) -; -self -. -nfa_contiguous -. -dense_depth -( -depth -) -; -self -} -/ -/ -/ -A -debug -settting -for -whether -to -attempt -to -shrink -the -size -of -the -/ -/ -/ -automaton -' -s -alphabet -or -not -. -/ -/ -/ -/ -/ -/ -This -option -is -enabled -by -default -and -should -never -be -disabled -unless -/ -/ -/ -one -is -debugging -the -underlying -automaton -. -/ -/ -/ -/ -/ -/ -When -enabled -some -( -but -not -all -) -Aho -- -Corasick -automatons -will -use -a -map -/ -/ -/ -from -all -possible -bytes -to -their -corresponding -equivalence -class -. -Each -/ -/ -/ -equivalence -class -represents -a -set -of -bytes -that -does -not -discriminate -/ -/ -/ -between -a -match -and -a -non -- -match -in -the -automaton -. -/ -/ -/ -/ -/ -/ -The -advantage -of -this -map -is -that -the -size -of -the -transition -table -can -/ -/ -/ -be -reduced -drastically -from -# -states -* -256 -* -sizeof -( -u32 -) -to -/ -/ -/ -# -states -* -k -* -sizeof -( -u32 -) -where -k -is -the -number -of -equivalence -/ -/ -/ -classes -( -rounded -up -to -the -nearest -power -of -2 -) -. -As -a -result -total -/ -/ -/ -space -usage -can -decrease -substantially -. -Moreover -since -a -smaller -/ -/ -/ -alphabet -is -used -automaton -compilation -becomes -faster -as -well -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -This -is -only -useful -for -debugging -automatons -. -Disabling -/ -/ -/ -this -does -not -yield -any -speed -advantages -. -Namely -even -when -this -is -/ -/ -/ -disabled -a -byte -class -map -is -still -used -while -searching -. -The -only -/ -/ -/ -difference -is -that -every -byte -will -be -forced -into -its -own -distinct -/ -/ -/ -equivalence -class -. -This -is -useful -for -debugging -the -actual -generated -/ -/ -/ -transitions -because -it -lets -one -see -the -transitions -defined -on -actual -/ -/ -/ -bytes -instead -of -the -equivalence -classes -. -pub -fn -byte_classes -( -& -mut -self -yes -: -bool -) -- -> -& -mut -AhoCorasickBuilder -{ -self -. -nfa_contiguous -. -byte_classes -( -yes -) -; -self -. -dfa -. -byte_classes -( -yes -) -; -self -} -} -/ -/ -/ -The -type -of -Aho -- -Corasick -implementation -to -use -in -an -[ -AhoCorasick -] -/ -/ -/ -searcher -. -/ -/ -/ -/ -/ -/ -This -is -principally -used -as -an -input -to -the -/ -/ -/ -[ -AhoCorasickBuilder -: -: -start_kind -] -method -. -Its -documentation -goes -into -more -/ -/ -/ -detail -about -each -choice -. -# -[ -non_exhaustive -] -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -AhoCorasickKind -{ -/ -/ -/ -Use -a -noncontiguous -NFA -. -NoncontiguousNFA -/ -/ -/ -Use -a -contiguous -NFA -. -ContiguousNFA -/ -/ -/ -Use -a -DFA -. -Warning -: -DFAs -typically -use -a -large -amount -of -memory -. -DFA -} -/ -/ -/ -A -trait -that -effectively -gives -us -practical -dynamic -dispatch -over -anything -/ -/ -/ -that -impls -Automaton -but -without -needing -to -add -a -bunch -of -bounds -to -/ -/ -/ -the -core -Automaton -trait -. -Basically -we -provide -all -of -the -marker -traits -/ -/ -/ -that -our -automatons -have -in -addition -to -Debug -impls -and -requiring -that -/ -/ -/ -there -is -no -borrowed -data -. -Without -these -the -main -AhoCorasick -type -would -/ -/ -/ -not -be -able -to -meaningfully -impl -Debug -or -the -marker -traits -without -also -/ -/ -/ -requiring -that -all -impls -of -Automaton -do -so -which -would -be -not -great -. -trait -AcAutomaton -: -Automaton -+ -Debug -+ -Send -+ -Sync -+ -UnwindSafe -+ -RefUnwindSafe -+ -' -static -{ -} -impl -< -A -> -AcAutomaton -for -A -where -A -: -Automaton -+ -Debug -+ -Send -+ -Sync -+ -UnwindSafe -+ -RefUnwindSafe -+ -' -static -{ -} -impl -crate -: -: -automaton -: -: -private -: -: -Sealed -for -Arc -< -dyn -AcAutomaton -> -{ -} -/ -/ -I -' -m -not -sure -why -this -trait -impl -shows -up -in -the -docs -as -the -AcAutomaton -/ -/ -trait -is -not -exported -. -So -we -forcefully -hide -it -. -/ -/ -/ -/ -SAFETY -: -This -just -defers -to -the -underlying -' -AcAutomaton -' -and -thus -inherits -/ -/ -its -safety -properties -. -# -[ -doc -( -hidden -) -] -unsafe -impl -Automaton -for -Arc -< -dyn -AcAutomaton -> -{ -# -[ -inline -( -always -) -] -fn -start_state -( -& -self -anchored -: -Anchored -) -- -> -Result -< -StateID -MatchError -> -{ -( -* -* -self -) -. -start_state -( -anchored -) -} -# -[ -inline -( -always -) -] -fn -next_state -( -& -self -anchored -: -Anchored -sid -: -StateID -byte -: -u8 -) -- -> -StateID -{ -( -* -* -self -) -. -next_state -( -anchored -sid -byte -) -} -# -[ -inline -( -always -) -] -fn -is_special -( -& -self -sid -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_special -( -sid -) -} -# -[ -inline -( -always -) -] -fn -is_dead -( -& -self -sid -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_dead -( -sid -) -} -# -[ -inline -( -always -) -] -fn -is_match -( -& -self -sid -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_match -( -sid -) -} -# -[ -inline -( -always -) -] -fn -is_start -( -& -self -sid -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_start -( -sid -) -} -# -[ -inline -( -always -) -] -fn -match_kind -( -& -self -) -- -> -MatchKind -{ -( -* -* -self -) -. -match_kind -( -) -} -# -[ -inline -( -always -) -] -fn -match_len -( -& -self -sid -: -StateID -) -- -> -usize -{ -( -* -* -self -) -. -match_len -( -sid -) -} -# -[ -inline -( -always -) -] -fn -match_pattern -( -& -self -sid -: -StateID -index -: -usize -) -- -> -PatternID -{ -( -* -* -self -) -. -match_pattern -( -sid -index -) -} -# -[ -inline -( -always -) -] -fn -patterns_len -( -& -self -) -- -> -usize -{ -( -* -* -self -) -. -patterns_len -( -) -} -# -[ -inline -( -always -) -] -fn -pattern_len -( -& -self -pid -: -PatternID -) -- -> -usize -{ -( -* -* -self -) -. -pattern_len -( -pid -) -} -# -[ -inline -( -always -) -] -fn -min_pattern_len -( -& -self -) -- -> -usize -{ -( -* -* -self -) -. -min_pattern_len -( -) -} -# -[ -inline -( -always -) -] +Standard +. +impl +Default +for +MatchKind +{ fn -max_pattern_len +default ( -& -self ) - > -usize +MatchKind { -( -* -* -self -) -. -max_pattern_len -( -) +MatchKind +: +: +Standard } -# -[ -inline -( -always -) -] +} +impl +MatchKind +{ fn -memory_usage +supports_overlapping ( & self ) - > -usize +bool { -( -* -* self -) . -memory_usage +is_standard ( ) } -# -[ -inline -( -always -) -] fn -prefilter +supports_stream ( & self ) - > -Option -< -& -Prefilter -> +bool { -( -* -* -self -) -. -prefilter -( -) -} -/ -/ -Even -though -' -try_find -' -and -' -try_find_overlapping -' -each -have -their / / -own -default -impls -we -explicitly -define -them -here +TODO +: +It +may +be +possible to -fix -a -perf -bug -. -/ -/ -Without -these -explicit -definitions -the -default -impl -will -wind -up -using -/ -/ -dynamic -dispatch -for -all -' -Automaton -' -method -calls -including -things -like -/ -/ -' -next_state -' -that -absolutely -must -get -inlined -or -else -perf -is -trashed -. -/ -/ -Defining -them -explicitly -here -like +support this -still -requires -dynamic -dispatch -/ -/ -to -call -' -try_find -' -itself -but -all -uses -of -' -Automaton -' -within -' -try_find +. +It ' -/ -/ -are -monomorphized +s +hard . / / / / -We -don -' -t -need -to -explicitly -impl -any -other -methods -I -think -because -/ -/ -they -are -all -implemented -themselves -in -terms -of -' -try_find -' -and +See +: +https +: / / -' -try_find_overlapping -' +github . -We -still -might -wind -up -with -an -extra -virtual +com / +rust +- +lang / -call -here -or -there -but -that -' -s -okay -since -it -' -s -outside -of -any -perf +regex / +issues / -critical -areas -. +425 # -[ -inline +issuecomment +- +471367838 +self +. +is_standard ( -always ) -] +} +pub +( +crate +) fn -try_find +is_standard ( & self -input -: -& -Input -< -' -_ -> ) - > -Result -< -Option -< -Match -> -MatchError -> +bool { -( -* * self += += +MatchKind +: +: +Standard +} +pub +( +crate ) -. -try_find +fn +is_leftmost ( -input +& +self ) +- +> +bool +{ +* +self += += +MatchKind +: +: +LeftmostFirst +| +| +* +self += += +MatchKind +: +: +LeftmostLongest } -# -[ -inline +pub ( -always +crate ) -] fn -try_find_overlapping +is_leftmost_first ( & self -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState ) - > -Result -< -( -) -MatchError -> +bool { -( -* * self -) -. -try_find_overlapping -( -input -state -) -} += += +MatchKind +: +: +LeftmostFirst } / / / -Returns -an -error -if -the -start -state -configuration -does -not -support -the +Convert +this +match +kind +into +a +packed +match +kind +. +If +this +match +kind / / / -desired -search -configuration -. -See -the -internal -' -AhoCorasick -: -: -start_kind -' +corresponds +to +standard +semantics +then +this +returns +None +since / / / -field -docs -for -more -details +packed +searching +does +not +support +standard +semantics . +pub +( +crate +) fn -enforce_anchored_consistency +as_packed ( -have -: -StartKind -want -: -Anchored +& +self ) - > -Result +Option < -( -) -MatchError +packed +: +: +MatchKind > { match -have +* +self { -StartKind +MatchKind : : -Both +Standard = > -Ok -( +None +MatchKind +: +: +LeftmostFirst += +> +Some ( +packed +: +: +MatchKind +: +: +LeftmostFirst ) -) -StartKind +MatchKind : : -Unanchored -if -! -want -. -is_anchored +LeftmostLongest += +> +{ +Some ( +packed +: +: +MatchKind +: +: +LeftmostLongest ) +} +MatchKind +: +: +__Nonexhaustive = > -Ok +unreachable +! ( +) +} +} +} +# +[ +cfg ( +test ) +] +mod +tests +{ +use +super +: +: +* +; +# +[ +test +] +fn +oibits +( ) -StartKind +{ +use +std : : -Unanchored -= +panic +: +: +{ +RefUnwindSafe +UnwindSafe +} +; +fn +assert_send +< +T +: +Send > -Err ( -MatchError -: +) +{ +} +fn +assert_sync +< +T : -invalid_input_anchored +Sync +> ( ) +{ +} +fn +assert_unwind_safe +< +T +: +RefUnwindSafe ++ +UnwindSafe +> +( ) -StartKind +{ +} +assert_send : : -Anchored -if -want -. -is_anchored +< +AhoCorasick +> ( ) -= +; +assert_sync +: +: +< +AhoCorasick > -Ok -( ( ) +; +assert_unwind_safe +: +: +< +AhoCorasick +> +( ) -StartKind +; +assert_send : : -Anchored -= +< +AhoCorasickBuilder > -Err ( -MatchError +) +; +assert_sync : : -invalid_input_unanchored +< +AhoCorasickBuilder +> ( ) +; +assert_unwind_safe +: +: +< +AhoCorasickBuilder +> +( ) +; } } diff --git a/third_party/rust/aho-corasick/src/automaton.rs b/third_party/rust/aho-corasick/src/automaton.rs index 4b5586b1e5af4..bf4ea19809e7b 100644 --- a/third_party/rust/aho-corasick/src/automaton.rs +++ b/third_party/rust/aho-corasick/src/automaton.rs @@ -1,1196 +1,1216 @@ -/ -* -! -Provides -[ -Automaton -] -trait -for -abstracting -over -Aho -- -Corasick -automata -. -The -Automaton -trait -provides -a -way -to -write -generic -code -over -any -Aho -- -Corasick -automaton -. -It -also -provides -access -to -lower -level -APIs -that -permit -walking -the -state -transitions -of -an -Aho -- -Corasick -automaton -manually -. -* -/ use -alloc -: -: -{ -string +crate : : -String -vec +ahocorasick : : -Vec -} +MatchKind ; use crate : : -util -: -: -{ -error -: -: -MatchError -primitives -: -: -PatternID -search +prefilter : : { -Anchored -Input -Match -MatchKind -Span -} +self +Candidate +Prefilter +PrefilterState } ; -pub use crate : : -util -: -: -{ -prefilter +state_id : : { -Candidate -Prefilter +dead_id +fail_id +StateID } -primitives +; +use +crate : : -{ -StateID -StateIDError -} -} +Match ; / / -/ -We -seal +NOTE +: +This +trait +essentially +started +as +a +copy +of the -Automaton +same +trait +from +from +/ +/ +regex +- +automata +with +some +wording +changed +since +we +use +this trait for -now +/ +/ +NFAs +in +addition +to +DFAs +in +this +crate +. +Additionally +we +do +not +export +/ +/ +this +trait . It ' s -a -big -trait -and +only +used +internally +to +reduce +code +duplication +. +The +/ +/ +regex +- +automata +crate +needs +to +expose it -' -s +because +its +Regex +type +is +generic / / +over +implementations +of +this +trait +. +In +this +crate +we +encapsulate +everything +/ / -conceivable -that -I -might -want -to -add -new -required -methods -and -sealing +behind the +AhoCorasick +type +. +/ / / / +This trait -permits -doing -that -in +is +a +bit +of a -backwards -compatible -fashion +mess +but +it +' +s +not +quite +clear +how +to +fix +it . -On -other -the / / +Basically +there +are +several +competing +concerns +: / -hand -if -you -have -a -solid -use -case -for -implementing -the -trait -yourself / / / -please -file -an -issue -and -we -can -discuss -it -. -This -was * -mostly -* -done -as -a +We +need +performance +so +everything +effectively +needs +to +get +monomorphized +. / / +* +There +are +several +variations +on +searching +Aho +- +Corasick +automatons +: +/ / -conservative -step +overlapping +standard +and +leftmost . -pub -( -crate -) -mod -private -{ -pub -trait -Sealed -{ -} -} -impl -private -: -: -Sealed -for -crate -: -: -nfa -: -: -noncontiguous -: -: -NFA -{ -} -impl -private -: -: -Sealed -for -crate -: -: -nfa -: -: -contiguous -: -: -NFA -{ -} -impl -private -: -: -Sealed -for -crate -: -: -dfa -: -: -DFA -{ -} -impl -< -' -a -T -: -private -: -: -Sealed -+ -? -Sized -> -private -: -: -Sealed -for -& -' -a -T -{ -} +Overlapping +and +standard +are +somewhat / / +combined +together +below +but +there +is +no +real +way +to +combine +standard +with +/ / -A -trait -that -abstracts -over -Aho -- -Corasick -automata +leftmost . +Namely +leftmost +requires +continuing +a +search +even +after +a +match / / +is +found +in +order +to +correctly +disambiguate +a +match +. / / +* +On +top +of +that +* +sometimes +* +callers +want +to +know +which +state +the +automaton / / +is +in +after +searching +. This -trait -primarily -exists +is +principally +useful for -niche -use -cases -such -as -: -/ +overlapping +and / / +stream +searches +. +However +when +callers +don +' +t +care +about +this +we +really / / +do +not +want +to +be +forced +to +compute +it +since +it +sometimes +requires +extra / -* -Using -an -NFA -or -DFA -directly -bypassing -the -top -- -level / +work +. +Thus +there +are +effectively +two +copies +of +leftmost +searching +: +one / / -[ -AhoCorasick -] -( -crate -: -: -AhoCorasick -) -searcher +for +tracking +the +state +ID +and +one +that +doesn +' +t . -Currently -these -include +We +should +ideally +do +the / / +same +for +standard +searching +but +my +sanity +stopped +me +. / -[ -noncontiguous -: -: -NFA -] -( -crate -: -: -nfa -: -: -noncontiguous -: -: -NFA -) / +SAFETY +RATIONALE +: +Previously +the +code +below +went +to +some +length +to +remove / / -[ -contiguous -: -: -NFA -] -( -crate -: -: -nfa -: -: -contiguous -: -: -NFA -) +all +bounds +checks +. +This +generally +produced +tighter +assembly and +lead +to / / +20 +- +50 +% +improvements +in +micro +- +benchmarks +on +corpora +made +up +of +random / -[ -dfa -: -: -DFA -] -( -crate -: -: -dfa -: -: -DFA -) -. / -/ -/ -* -Implementing -your -own -custom -search -routine -by -walking +characters +. +This +somewhat +makes +sense +since the -automaton -/ +branch +predictor +is +going / / -yourself -. -This -might +to be -useful -for -implementing -search +at +its +worse on -non -- -contiguous -/ -/ -/ -strings -or -streams +random +text . / / / / +However +using +the +aho +- +corasick +- +debug +tool +and +manually +benchmarking / / -For -most -use -cases -it -is -not -expected -that -users -will -need -/ -/ -/ -to -use -or -even -know -about -this -trait -. -Indeed +different +inputs the -top -level -/ +code +* +with +* +bounds +checks +actually +wound +up +being / / -[ -AhoCorasick -] -( -crate +slightly +faster : -: -AhoCorasick -) -searcher -does -not -expose -any -details / / / -about -this -trait -nor -does -it -implement -it -itself -. / +cat +input / / +Sherlock +Holmes / / +John +Watson / -Note -that -this -trait -defines -a -number -of -default -methods -such -as / +Professor +Moriarty / / -[ -Automaton -: -: -try_find -] -and -[ -Automaton -: -: -try_find_iter -] -which -implement +Irene +Adler / / +Mary +Watson / -higher -level -search -routines -in -terms -of -the -lower -level -automata -API -. / / / +aho +- +corasick +- +debug +- +safe +\ / / +input +OpenSubtitles2018 +. +raw +. +sample +. +en +- +- +kind +leftmost +- +first +- +- +dfa / -# -Sealed / +pattern +read +time +: +32 +. +824 +s / / +automaton +build +time +: +444 +. +687 +s / / +automaton +heap +usage +: +72392 +bytes / -Currently -this -trait -is -sealed -. -That -means -users -of -this -crate -can -write / +match +count +: +639 / / -generic -routines -over -this -trait -but -cannot -implement -it -themselves +count +time +: +1 . -This +809961702s / / / -restriction -may -be -lifted -in -the -future -but -sealing -the -trait -permits / +aho +- +corasick +- +debug +- +master +\ / / -adding -new -required -methods -in -a -backwards -compatible -fashion +input +OpenSubtitles2018 . +raw +. +sample +. +en +- +- +kind +leftmost +- +first +- +- +dfa / / +pattern +read +time +: +31 +. +425 +s / / +automaton +build +time +: +317 +. +434 +s / / -# -Special -states -/ -/ +automaton +heap +usage +: +72392 +bytes / / +match +count +: +639 / / -This -trait -encodes -a -notion -of -" -special -" -states -in -an -automaton +count +time +: +2 . -Namely +059157705s / / / -a -state -is -treated -as -special -if -it -is -a -dead -match -or -start -state -: / +I +was +able +to +reproduce +this +result +on +two +different +machines +( +an +i5 +and / / +an +i7 +) +. +Therefore +we +go +the +route +of +safe +code +for +now +. / / / -* A -dead -state -is -a +trait +describing +the +interface +of +an +Aho +- +Corasick +finite state -that -cannot -be -left -once -entered +machine . -All -transitions / / / -on -a +/ +/ +/ +Every +automaton +has +exactly +one +fail +state +one dead state -lead -back +and +exactly +one +/ +/ +/ +start +state +. +Generally +these +correspond to -itself +the +first +second +and +third +/ +/ +/ +states +respectively . The dead state is -meant -to -be +always treated -/ -/ -/ as a sentinel -indicating -that +. +That +/ +/ +/ +is +no +correct +Aho +- +Corasick +automaton +will +ever +transition +into the -search -should -stop -and -return -a +fail +/ +/ +/ +state +. +The +dead +state +however +can +be +transitioned +into +but +only +when +/ +/ +/ +leftmost +- +first +or +leftmost +- +longest match -if +semantics +are +enabled +and +only / / / +when +at +least one +match has been -found -and -nothing -otherwise +observed . / / / -* -A -match -state -is -a -state -that -indicates -one -or -more -patterns -have / / / -matched -. -Depending -on -the -[ -MatchKind -] -of -the +Every automaton -a -search -may +also +has +one +or +more +match +states +such +that / / / -stop -once -a -match -is -seen -or -it -may -continue -looking -for -matches -until +Automaton +: +: +is_match_state +( +id +) +returns +true +if +and +only +if +id / / / -it -enters +corresponds +to a -dead +match state -or -sees -the -end -of -the -haystack . +pub +trait +Automaton +{ / / / -* -A -start -state -is -a +The +representation +used +for state -that -a -search -begins +identifiers in +this +automaton . -It -is -useful -to -know / / / -when -a -search -enters -a -start -state -because -it -may -mean -that -a -prefilter -can / / / +Typically +this +is +one +of +u8 +u16 +u32 +u64 +or +usize +. +type +ID +: +StateID +; +/ +/ +/ +The +type +of +matching +that +should be -used -to -skip -ahead -and -quickly -look -for -candidate -matches +done . -Unlike -dead +fn +match_kind +( +& +self +) +- +> +& +MatchKind +; / / / +Returns +true +if and -match -states -it -is -never -necessary -to -explicitly -handle -start -states +only +if +this +automaton +uses +anchored +searches +. +fn +anchored +( +& +self +) +- +> +bool +; / / / +An +optional +prefilter for -correctness +quickly +skipping +to +the +next +candidate +match . -Indeed -in -this -crate -implementations -of -Automaton / / / -will -only -treat -start -states -as -" -special -" -when -a +A prefilter -is -enabled -and +must +report +at +least +every +match +although +it +may +report / / / -active +positions +that +do +not +correspond +to +a +match . -Otherwise -treating +That +is it -as -special -has -no -purpose -and -winds -up +must +not +allow / / / -slowing -down -the -overall -search -because -it -results -in -ping -- -ponging -between +false +negatives +but +can +allow +false +positives +. / / / -the -main -state -transition -and -the -" -special -" -state -logic -. / / / +Currently +a +prefilter +only +runs +when +the +automaton +is +in +the +start / / / -Since -checking -whether -a state +. +That is -special +the +position +reported by -doing -three -different +a +prefilter +should +always / / / -checks -would -be -too -expensive -inside -a -fast -search -loop +correspond +to the +start +of +a +potential +match +. +fn +prefilter +( +& +self +) +- +> +Option +< +& +dyn +Prefilter +> +; / / / -[ -Automaton +Return +the +identifier +of +this +automaton +' +s +start +state +. +fn +start_state +( +& +self +) +- +> +Self : : -is_special -] -method -is -provided -for -quickly -checking -whether +ID +; / / / +Returns +true +if +and +only +if the +given state -is -special -. -The -Automaton -: -: -is_dead -Automaton -: -: -is_match -and +identifier +refers +to +a / / / -Automaton -: -: -is_start -predicates -can -then -be -used -to -determine -which -kind -/ -/ -/ -of -special +valid state -it -is . +fn +is_valid +( +& +self +id +: +Self +: +: +ID +) +- +> +bool +; / / / +Returns +true +if +and +only +if +the +given +identifier +corresponds +to +a +match / / / -# -Panics -/ -/ -/ +state +. / / / -Most -of -the -APIs -on -this -trait -should -panic -or -give -incorrect -results / / / -if -invalid -inputs -are +The +state +ID given -to -it +must +be +valid +or +else +implementors +may +panic . -For -example -Automaton +fn +is_match_state +( +& +self +id : +Self : -next_state +: +ID +) +- +> +bool +; / / / -has -unspecified -behavior +Returns +true +if +and +only if the -state -ID given +identifier +corresponds to -it -is -not a -valid +state / / / -state -ID -for +that +is +either the -underlying -automaton -. -Valid +dead state -IDs -can -only -be -/ -/ -/ -retrieved -in -one -of -two -ways -: -calling -Automaton -: -: -start_state or -calling -/ -/ -/ -Automaton -: -: -next_state -with a -valid +match state -ID . / / @@ -1198,1200 +1218,1166 @@ ID / / / -# -Safety -/ -/ -/ -/ -/ -/ -This -trait -is -not -safe -to -implement -so -that -code -may -rely +Depending on the -/ -/ -/ -correctness -of -implementations +implementation of +the +automaton this -trait -to -avoid -undefined -behavior -. -/ -/ -/ -The -primary -correctness -guarantees -are -: +routine +can / / / +be +used +to +save +a +branch +in +the +core +matching +loop +. +Nevertheless / / / -* -Automaton -: -: -start_state +is_match_state +( +id +) +| +| +id += += +dead_id +( +) +is always -returns a valid -state -ID -or -an -error -or / / / -panics +implementation +. +Indeed +this +is +the +default +implementation . / / / -* -Automaton -: -: -next_state -when -given -a -valid -state -ID -always -returns / / / -a -valid +The state ID -for -all -values -of -anchored -and -byte +given +must +be +valid or -otherwise -/ -/ -/ -panics +else +implementors +may +panic . -/ -/ -/ -/ -/ -/ -In -general -the -rest -of -the -methods -on -Automaton -need -to -uphold -their -/ -/ -/ -contracts -as -well -. -For -example -Automaton +fn +is_match_or_dead_state +( +& +self +id : +Self : -is_dead -should -only -returns +: +ID +) +- +> +bool +{ +id += += +dead_id +( +) +| +| +self +. +is_match_state +( +id +) +} / / / -true -if +If the given state -ID is -actually a -dead +match state -. -/ -/ -/ -/ -/ -/ -Note -that -currently -this -crate -does -not -rely -on +return the -safety -property -defined -/ -/ -/ -here -to -avoid -undefined -behavior -. -Instead -this -was -done -to -make -it +match +corresponding / / / -_possible_ to -do -in the -future +given +match +index . +end +must +be +the +ending +position +of +the / / / +detected +match +. +If +no +match +exists +or +if +match_index +exceeds +the / / / -# -Example -/ -/ -/ +number +of +matches +in +this +state +then +None +is +returned +. / / / -This -example -shows -how -one -might -implement -a -basic -but -correct -search / / / -routine -. -We -keep -things -simple -by -not -using -prefilters +The +state +ID +given +must +be +valid or -worrying -about +else +implementors +may +panic +. / / / -anchored -searches -but -do -make -sure -our -search -is -correct -for -all -possible / / / -[ -MatchKind -] -semantics -. -( -The -comments -in +If the -code -below -note +given +state +ID +is +correct +and +if the -parts +match_index +is +less +than / / / +the +number +of +matches +for that -are -needed +state +then +this +is +guaranteed to -support -certain -MatchKind -semantics -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ +return / / / -automaton -: +a +match +. +fn +get_match +( +& +self +id : -Automaton -/ -/ -/ -nfa +Self : : -noncontiguous +ID +match_index : +usize +end : -NFA -/ -/ -/ -Anchored +usize +) +- +> +Option +< Match -MatchError -MatchKind +> +; / / / -} -; -/ +Returns +the +number +of +matches +for +the +given +state +. +If +the +given +state / / / +is +not +a +match +state +then +this +returns +0 +. / / / / -Run -an -unanchored -search -for -' -aut -' -in -' -haystack -' -. -Return -the -first -match / / +The +state +ID +given +must +be +valid +or +else +implementors +must +panic +. +fn +match_count +( +& +self +id +: +Self +: +: +ID +) +- +> +usize +; / / / -seen -according -to +Given the +current +state +that +this automaton -' -s -match -semantics -. -This -returns -an -error -/ -/ +is +in +and +the +next +input / / / -if +byte +this +method +returns the -given -automaton -does -not -support -unanchored -searches +identifier +of +the +next +state . +The / / / -fn -find -< -A -: -Automaton -> -( +identifier +returned +must +always +be +valid +and +may +never +correspond +to / / / -aut -: -A +the +fail +state +. +The +returned +identifier +may +however +point +to +the / / / -haystack -: -& -[ -u8 -] +dead +state +. / / / -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ / / / -let -mut -sid -= -aut -. -start_state -( -Anchored -: -: -No -) -? -; +This +is +not +safe +so +that +implementors +may +look +up +the +next +state / / / -let -mut -at -= -0 -; +without +memory +safety +checks +such +as +bounds +checks +. +As +such +callers / / / -let -mut -mat -= -None -; +must +ensure +that +the +given +identifier +corresponds +to +a +valid +automaton / / / -let -get_match -= -| -sid -at -| -{ +state +. +Implementors +must +in +turn +ensure +that +this +routine +is +safe +for / / / -let -pid -= -aut +all +valid +state +identifiers +and +for +all +possible +u8 +values . -match_pattern +fn +next_state ( -sid -0 +& +self +current +: +Self +: +: +ID +input +: +u8 ) +- +> +Self +: +: +ID ; / / / -let -len -= -aut -. -pattern_len -( -pid -) -; +Like +next_state +but +debug_asserts +that +the +underlying / / / -Match -: -: -new -( -pid +implementation +never +returns +a +fail_id ( -at -- -len -) -. -. -at ) -/ -/ -/ -} -; -/ -/ -/ -/ -/ -Start -states -can -be -match -states -! -/ -/ -/ -if -aut +for +the +next +state . -is_match +fn +next_state_no_fail ( -sid +& +self +current +: +Self +: +: +ID +input +: +u8 ) +- +> +Self +: +: +ID { -/ -/ -/ -mat +let +next = -Some -( -get_match +self +. +next_state ( -sid -at -) +current +input ) ; / / -/ -/ -/ -Standard -semantics -require -matches -to -be -reported -as -soon -as -/ -/ -/ -/ -/ -they -' -re -seen -. -Otherwise -we -continue -until -we +We +should +never see a -dead -state -/ -/ -/ -/ -/ -or -the -end -of +transition +to the -haystack +failure +state . -/ -/ -/ -if -matches +debug_assert ! ( -aut -. -match_kind +next +! += +fail_id ( ) -MatchKind -: -: -Standard -) -{ -/ -/ -/ +" +automaton +should +never return -Ok -( -mat +fail_id +for +next +state +" ) ; +next +} / / / -} +Execute +a +search +using +standard +match +semantics +. / / / -} / / / -while -at -< -haystack -. -len -( -) -{ +This +can +be +used +even +when +the +automaton +was +constructed +with +leftmost / / / -sid -= -aut +match +semantics +when +you +want +to +find +the +earliest +possible +match . -next_state -( -Anchored -: -: -No -sid -haystack -[ -at -] -) -; +This / / / -if -aut +can +also +be +used +as +part +of +an +overlapping +search +implementation . -is_special -( -sid -) -{ / / / -if -aut -. -is_dead -( -sid -) -{ / / / -return -Ok -( -mat -) -; +N +. +B +. +This +does +not +report +a +match +if +state_id +is +given +as +a +matching / / / -} -else -if -aut +state +. +As +such +this +should +not +be +used +directly . -is_match +# +[ +inline ( -sid +always ) -{ -/ -/ -/ -mat -= -Some -( -get_match +] +fn +standard_find_at ( -sid +& +self +prestate +: +& +mut +PrefilterState +haystack +: +& +[ +u8 +] at -+ -1 -) +: +usize +state_id +: +& +mut +Self +: +: +ID ) -; -/ -/ -/ -/ -/ -As -above -standard -semantics -require -that -we -return -/ -/ -/ -/ -/ -immediately -once -a -match -is -found -. -/ -/ -/ +- +> +Option +< +Match +> +{ if -matches -! +let +Some ( -aut +pre +) += +self . -match_kind +prefilter ( ) -MatchKind -: -: -Standard -) { -/ -/ -/ -return -Ok +self +. +standard_find_at_imp ( -mat +prestate +Some +( +pre ) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ +haystack at -+ -= -1 -; -/ -/ -/ +state_id +) } -/ -/ -/ -Ok +else +{ +self +. +standard_find_at_imp ( -mat +prestate +None +haystack +at +state_id ) -/ -/ -/ +} } / / +It +' +s +important +for +this +to +always +be +inlined +. +Namely +its +only +caller / / +is +standard_find_at +and +the +inlining +should +remove +the +case +analysis / / -/ -/ -Show -that -it -works for -standard -searches +prefilter +scanning +when +there +is +no +prefilter +available . -/ -/ -/ -let -nfa -= -NFA +# +[ +inline +( +always +) +] +fn +standard_find_at_imp +( +& +self +prestate : +& +mut +PrefilterState +prefilter +: +Option +< +& +dyn +Prefilter +> +haystack : -new -( & [ -" -samwise -" -" -sam -" +u8 ] +mut +at +: +usize +state_id +: +& +mut +Self +: +: +ID ) +- +> +Option +< +Match +> +{ +while +at +< +haystack . -unwrap +len ( ) -; -/ -/ -/ -assert_eq -! -( +{ +if +let Some ( -Match -: -: -must -( -1 -0 -. -. -3 -) +pre ) -find += +prefilter +{ +if +prestate +. +is_effective ( -& -nfa -b -" -samwise -" -) -? +at ) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -also -works -when -using -leftmost -- -first -. -Notice -how -the -match -result -/ -/ -/ -/ -/ -has -changed -! -/ -/ -/ -let -nfa +& +& +* +state_id = -NFA -: -: -builder -( -) -/ -/ -/ += +self . -match_kind +start_state ( -MatchKind +) +{ +let +c += +prefilter : : -LeftmostFirst -) -/ -/ -/ -. -build +next ( -& -[ -" -samwise -" -" -sam -" -] +prestate +pre +haystack +at ) -/ -/ -/ . -unwrap +into_option ( ) ; -/ -/ -/ -assert_eq -! -( +match +c +{ +None += +> +return +None Some ( -Match -: -: -must -( -0 -0 -. -. -7 -) -) -find -( -& -nfa -b -" -samwise -" -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( +i ) -Box -< -dyn -std -: -: -error -: -: -Error -> += > -( -( -) -) -/ +{ +at += +i +; +} +} +} +} / / -pub -unsafe -trait -Automaton +CORRECTNESS : -private -: -: -Sealed -{ -/ +next_state +is +correct +for +all +possible +u8 +values / / -Returns +so the -starting -state -for +only +thing +we +' +re +concerned +about +is the -given -anchor -mode -. +validity +of / / +state_id +. +state_id +either +comes +from +the +caller +( +in +which / / +case +we +assume +it +is +correct +) +or +it +comes +from +the +return / / -Upon -success -the -state -ID -returned +value +of +next_state +which is guaranteed to be -valid -for -/ -/ -/ -this -automaton +correct . +* +state_id += +self +. +next_state_no_fail +( +* +state_id +haystack +[ +at +] +) +; +at ++ += +1 +; / / +This +routine +always +quits +immediately +after +seeing +a / / +match +and +since +dead +states +can +only +come +after +seeing / / -# -Errors -/ -/ +a +match +seeing +a +dead +state +here +is +impossible +. +( +Unless / / +we +have +an +anchored +automaton +in +which +case +dead +states / / -This -returns -an -error -when -the -given -search -configuration -is -not -/ -/ -/ -supported -by -the -underlying -automaton -. -For -example -if -the -underlying -/ -/ -/ -automaton -only -supports -unanchored -searches -but -the -given -configuration -/ -/ -/ -was -set +are +used to -an -anchored +stop +a search -then -this -must -return -an -error . -fn -start_state +) +debug_assert +! ( -& +* +state_id +! += +dead_id +( +) +| +| self +. anchored -: -Anchored +( ) -- -> -Result -< -StateID -MatchError -> +" +standard +find +should +never +see +a +dead +state +" +) +; +if +self +. +is_match_or_dead_state +( +* +state_id +) +{ +return +if +* +state_id += += +dead_id +( +) +{ +None +} +else +{ +self +. +get_match +( +* +state_id +0 +at +) +} ; +} +} +None +} / / / -Performs +Execute a -state -transition -from -sid -for -byte -and -returns -the -next +search +using +leftmost +( +either +first +or +longest +) +match / / / -state +semantics . / / @@ -2399,11675 +2385,1941 @@ state / / / -anchored -should -be -[ -Anchored -: -: -Yes -] -when -executing -an -anchored -/ -/ -/ -search +The +principle +difference +between +searching +with +standard +semantics and -[ -Anchored -: -: -No -] -otherwise -. -For -some -implementations -of / / / -Automaton -it -is -required -to -know -whether -the -search +searching +with +leftmost +semantics is -anchored +that +leftmost +searching +will / / / -or -not -in -order -to -avoid -following -failure -transitions +continue +searching +even +after +a +match +has +been +found . -Other +Once +a +match / / / -implementations -may -ignore -anchored -altogether -and -depend -on +is +found +the +search +does +not +stop +until +either +the +haystack +has +been / / / -Automaton -: -: -start_state -returning +exhausted +or a +dead state -that -walks -a -different -path -/ -/ -/ -through +is +observed +in the automaton -depending -on -whether -the -search -is -anchored -or -/ -/ -/ -not . +( +Dead +states / / / +only +exist +in +automatons +constructed +with +leftmost +semantics +. +) +That +is / / / -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -may -panic -or -return -incorrect -results -when +we +rely +on the -given -state -/ -/ -/ -ID -is -invalid +construction +of +the +automaton +to +tell +us +when +to +quit . -A -state -ID -is -valid -if -and -only -if +# +[ +inline +( +never +) +] +fn +leftmost_find_at +( +& +self +prestate : -/ -/ -/ -/ -/ -/ -1 -. -It -came -from -a -call -to -Automaton +& +mut +PrefilterState +haystack : +& +[ +u8 +] +at : -start_state -or -/ -/ -/ -2 -. -It -came -from -a -previous -call -to -Automaton +usize +state_id +: +& +mut +Self : : -next_state -with -a -/ -/ -/ -valid -state ID +) +- +> +Option +< +Match +> +{ +if +let +Some +( +pre +) += +self . -/ -/ -/ -/ -/ -/ -Implementations -must -treat -all -possible -values -of -byte -as -valid +prefilter +( +) +{ +self . +leftmost_find_at_imp +( +prestate +Some +( +pre +) +haystack +at +state_id +) +} +else +{ +self +. +leftmost_find_at_imp +( +prestate +None +haystack +at +state_id +) +} +} / / +It +' +s +important +for +this +to +always +be +inlined +. +Namely +its +only +caller / / +is +leftmost_find_at +and +the +inlining +should +remove +the +case +analysis / / -Implementations -may -panic -on -unsupported -values -of -anchored -but -are -/ -/ -/ -not -required -to -do -so +for +prefilter +scanning +when +there +is +no +prefilter +available . +# +[ +inline +( +always +) +] fn -next_state +leftmost_find_at_imp ( & self -anchored +prestate : -Anchored -sid +& +mut +PrefilterState +prefilter : -StateID -byte +Option +< +& +dyn +Prefilter +> +haystack : +& +[ u8 +] +mut +at +: +usize +state_id +: +& +mut +Self +: +: +ID ) - > -StateID +Option +< +Match +> +{ +debug_assert +! +( +self +. +match_kind +( +) +. +is_leftmost +( +) +) ; -/ -/ -/ -Returns -true if -the -given -ID -represents -a -" -special -" -state -. -A -special -/ -/ -/ -state -is -a -dead -match -or -start -state -. -/ -/ -/ -/ -/ -/ -Note -that -implementations -may -choose -to -return -false -when -the -given -ID -/ -/ -/ -corresponds -to -a -start -state -. -Namely -it -always -correct -to -treat -start -/ -/ -/ -states -as -non -- -special -. -Implementations -must -return -true -for -states -that -/ -/ -/ -are -dead -or -contain -matches -. -/ -/ -/ -/ -/ -/ -This -has -unspecified -behavior -when -given -an -invalid -state -ID -. -fn -is_special -( -& -self -sid -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -true -if -the -given -ID -represents -a -dead -state -. -/ -/ -/ -/ -/ -/ -A -dead -state -is -a -type -of -" -sink -" -in -a -finite -state -machine -. -It -/ -/ -/ -corresponds -to -a -state -whose -transitions -all -loop -back -to -itself -. -That -/ -/ -/ -is -once -entered -it -can -never -be -left -. -In -practice -it -serves -as -a -/ -/ -/ -sentinel -indicating -that -the -search -should -terminate -. -/ -/ -/ -/ -/ -/ -This -has -unspecified -behavior -when -given -an -invalid -state -ID -. -fn -is_dead -( -& -self -sid -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -true -if -the -given -ID -represents -a -match -state -. -/ -/ -/ -/ -/ -/ -A -match -state -is -always -associated -with -one -or -more -pattern -IDs -that -/ -/ -/ -matched -at -the -position -in -the -haystack -when -the -match -state -was -/ -/ -/ -entered -. -When -a -match -state -is -entered -the -match -semantics -dictate -/ -/ -/ -whether -it -should -be -returned -immediately -( -for -MatchKind -: -: -Standard -) -/ -/ -/ -or -if -the -search -should -continue -( -for -MatchKind -: -: -LeftmostFirst -and -/ -/ -/ -MatchKind -: -: -LeftmostLongest -) -until -a -dead -state -is -seen -or -the -end -of -/ -/ -/ -the -haystack -has -been -reached -. -/ -/ -/ -/ -/ -/ -This -has -unspecified -behavior -when -given -an -invalid -state -ID -. -fn -is_match -( -& -self -sid -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -true -if -the -given -ID -represents -a -start -state -. -/ -/ -/ -/ -/ -/ -While -it -is -never -incorrect -to -ignore -start -states -during -a -search -/ -/ -/ -( -except -for -the -start -of -the -search -of -course -) -knowing -whether -one -has -/ -/ -/ -entered -a -start -state -can -be -useful -for -certain -classes -of -performance -/ -/ -/ -optimizations -. -For -example -if -one -is -in -a -start -state -it -may -be -legal -/ -/ -/ -to -try -to -skip -ahead -and -look -for -match -candidates -more -quickly -than -/ -/ -/ -would -otherwise -be -accomplished -by -walking -the -automaton -. -/ -/ -/ -/ -/ -/ -Implementations -of -Automaton -in -this -crate -" -unspecialize -" -start -/ -/ -/ -states -when -a -prefilter -is -not -active -or -enabled -. -In -this -case -it -/ -/ -/ -is -possible -for -Automaton -: -: -is_special -( -sid -) -to -return -false -while -/ -/ -/ -Automaton -: -: -is_start -( -sid -) -returns -true -. -/ -/ -/ -/ -/ -/ -This -has -unspecified -behavior -when -given -an -invalid -state -ID -. -fn -is_start -( -& -self -sid -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -the -match -semantics -that -this -automaton -was -built -with -. -fn -match_kind -( -& -self -) -- -> -MatchKind -; -/ -/ -/ -Returns -the -total -number -of -matches -for -the -given -state -ID -. -/ -/ -/ -/ -/ -/ -This -has -unspecified -behavior -if -the -given -ID -does -not -refer -to -a -match -/ -/ -/ -state -. -fn -match_len -( -& -self -sid -: -StateID -) -- -> -usize -; -/ -/ -/ -Returns -the -pattern -ID -for -the -match -state -given -by -sid -at -the -/ -/ -/ -index -given -. -/ -/ -/ -/ -/ -/ -Typically -index -is -only -ever -greater -than -0 -when -implementing -an -/ -/ -/ -overlapping -search -. -Otherwise -it -' -s -likely -that -your -search -only -cares -/ -/ -/ -about -reporting -the -first -pattern -ID -in -a -match -state -. -/ -/ -/ -/ -/ -/ -This -has -unspecified -behavior -if -the -given -ID -does -not -refer -to -a -match -/ -/ -/ -state -or -if -the -index -is -greater -than -or -equal -to -the -total -number -of -/ -/ -/ -matches -in -this -match -state -. -fn -match_pattern -( -& -self -sid -: -StateID -index -: -usize -) -- -> -PatternID -; -/ -/ -/ -Returns -the -total -number -of -patterns -compiled -into -this -automaton -. -fn -patterns_len -( -& -self -) -- -> -usize -; -/ -/ -/ -Returns -the -length -of -the -pattern -for -the -given -ID -. -/ -/ -/ -/ -/ -/ -This -has -unspecified -behavior -when -given -an -invalid -pattern -/ -/ -/ -ID -. -A -pattern -ID -is -valid -if -and -only -if -it -is -less -than -/ -/ -/ -Automaton -: -: -patterns_len -. -fn -pattern_len -( -& -self -pid -: -PatternID -) -- -> -usize -; -/ -/ -/ -Returns -the -length -in -bytes -of -the -shortest -pattern -in -this -/ -/ -/ -automaton -. -fn -min_pattern_len -( -& -self -) -- -> -usize -; -/ -/ -/ -Returns -the -length -in -bytes -of -the -longest -pattern -in -this -automaton -. -fn -max_pattern_len -( -& -self -) -- -> -usize -; -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -used -by -this -automaton -. -fn -memory_usage -( -& -self -) -- -> -usize -; -/ -/ -/ -Returns -a -prefilter -if -available -that -can -be -used -to -accelerate -/ -/ -/ -searches -for -this -automaton -. -/ -/ -/ -/ -/ -/ -The -typical -way -this -is -used -is -when -the -start -state -is -entered -during -/ -/ -/ -a -search -. -When -that -happens -one -can -use -a -prefilter -to -skip -ahead -and -/ -/ -/ -look -for -candidate -matches -without -having -to -walk -the -automaton -on -the -/ -/ -/ -bytes -between -candidates -. -/ -/ -/ -/ -/ -/ -Typically -a -prefilter -is -only -available -when -there -are -a -small -( -< -100 -) -/ -/ -/ -number -of -patterns -built -into -the -automaton -. -fn -prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -; -/ -/ -/ -Executes -a -non -- -overlapping -search -with -this -automaton -using -the -given -/ -/ -/ -configuration -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_find -] -( -crate -: -: -AhoCorasick -: -: -try_find -) -/ -/ -/ -for -more -documentation -and -examples -. -fn -try_find -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -try_find_fwd -( -& -self -input -) -} -/ -/ -/ -Executes -a -overlapping -search -with -this -automaton -using -the -given -/ -/ -/ -configuration -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_find_overlapping -] -( -crate -: -: -AhoCorasick -: -: -try_find_overlapping -) -/ -/ -/ -for -more -documentation -and -examples -. -fn -try_find_overlapping -( -& -self -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -try_find_overlapping_fwd -( -& -self -input -state -) -} -/ -/ -/ -Returns -an -iterator -of -non -- -overlapping -matches -with -this -automaton -/ -/ -/ -using -the -given -configuration -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_find_iter -] -( -crate -: -: -AhoCorasick -: -: -try_find_iter -) -/ -/ -/ -for -more -documentation -and -examples -. -fn -try_find_iter -< -' -a -' -h -> -( -& -' -a -self -input -: -Input -< -' -h -> -) -- -> -Result -< -FindIter -< -' -a -' -h -Self -> -MatchError -> -where -Self -: -Sized -{ -FindIter -: -: -new -( -self -input -) -} -/ -/ -/ -Returns -an -iterator -of -overlapping -matches -with -this -automaton -/ -/ -/ -using -the -given -configuration -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_find_overlapping_iter -] -( -crate -: -: -AhoCorasick -: -: -try_find_overlapping_iter -) -/ -/ -/ -for -more -documentation -and -examples -. -fn -try_find_overlapping_iter -< -' -a -' -h -> -( -& -' -a -self -input -: -Input -< -' -h -> -) -- -> -Result -< -FindOverlappingIter -< -' -a -' -h -Self -> -MatchError -> -where -Self -: -Sized -{ -if -! -self -. -match_kind -( -) -. -is_standard -( -) -{ -return -Err -( -MatchError -: -: -unsupported_overlapping -( -self -. -match_kind -( -) -) -) -; -} -/ -/ -We -might -consider -lifting -this -restriction -. -The -reason -why -I -added -/ -/ -it -was -to -ban -the -combination -of -" -anchored -search -" -and -" -overlapping -/ -/ -iteration -. -" -The -match -semantics -aren -' -t -totally -clear -in -that -case -. -/ -/ -Should -we -allow -* -any -* -matches -that -are -adjacent -to -* -any -* -previous -/ -/ -match -? -Or -only -following -the -most -recent -one -? -Or -only -matches -/ -/ -that -start -at -the -beginning -of -the -search -? -We -might -also -elect -to -/ -/ -just -keep -this -restriction -in -place -as -callers -should -be -able -to -/ -/ -implement -it -themselves -if -they -want -to -. -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -Err -( -MatchError -: -: -invalid_input_anchored -( -) -) -; -} -let -_ -= -self -. -start_state -( -input -. -get_anchored -( -) -) -? -; -let -state -= -OverlappingState -: -: -start -( -) -; -Ok -( -FindOverlappingIter -{ -aut -: -self -input -state -} -) -} -/ -/ -/ -Replaces -all -non -- -overlapping -matches -in -haystack -with -/ -/ -/ -strings -from -replace_with -depending -on -the -pattern -that -/ -/ -/ -matched -. -The -replace_with -slice -must -have -length -equal -to -/ -/ -/ -Automaton -: -: -patterns_len -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_replace_all -] -( -crate -: -: -AhoCorasick -: -: -try_replace_all -) -/ -/ -/ -for -more -documentation -and -examples -. -fn -try_replace_all -< -B -> -( -& -self -haystack -: -& -str -replace_with -: -& -[ -B -] -) -- -> -Result -< -String -MatchError -> -where -Self -: -Sized -B -: -AsRef -< -str -> -{ -assert_eq -! -( -replace_with -. -len -( -) -self -. -patterns_len -( -) -" -replace_all -requires -a -replacement -for -every -pattern -\ -in -the -automaton -" -) -; -let -mut -dst -= -String -: -: -with_capacity -( -haystack -. -len -( -) -) -; -self -. -try_replace_all_with -( -haystack -& -mut -dst -| -mat -_ -dst -| -{ -dst -. -push_str -( -replace_with -[ -mat -. -pattern -( -) -] -. -as_ref -( -) -) -; -true -} -) -? -; -Ok -( -dst -) -} -/ -/ -/ -Replaces -all -non -- -overlapping -matches -in -haystack -with -/ -/ -/ -strings -from -replace_with -depending -on -the -pattern -that -/ -/ -/ -matched -. -The -replace_with -slice -must -have -length -equal -to -/ -/ -/ -Automaton -: -: -patterns_len -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_replace_all_bytes -] -( -crate -: -: -AhoCorasick -: -: -try_replace_all_bytes -) -/ -/ -/ -for -more -documentation -and -examples -. -fn -try_replace_all_bytes -< -B -> -( -& -self -haystack -: -& -[ -u8 -] -replace_with -: -& -[ -B -] -) -- -> -Result -< -Vec -< -u8 -> -MatchError -> -where -Self -: -Sized -B -: -AsRef -< -[ -u8 -] -> -{ -assert_eq -! -( -replace_with -. -len -( -) -self -. -patterns_len -( -) -" -replace_all -requires -a -replacement -for -every -pattern -\ -in -the -automaton -" -) -; -let -mut -dst -= -Vec -: -: -with_capacity -( -haystack -. -len -( -) -) -; -self -. -try_replace_all_with_bytes -( -haystack -& -mut -dst -| -mat -_ -dst -| -{ -dst -. -extend -( -replace_with -[ -mat -. -pattern -( -) -] -. -as_ref -( -) -) -; -true -} -) -? -; -Ok -( -dst -) -} -/ -/ -/ -Replaces -all -non -- -overlapping -matches -in -haystack -by -calling -the -/ -/ -/ -replace_with -closure -given -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_replace_all_with -] -( -crate -: -: -AhoCorasick -: -: -try_replace_all_with -) -/ -/ -/ -for -more -documentation -and -examples -. -fn -try_replace_all_with -< -F -> -( -& -self -haystack -: -& -str -dst -: -& -mut -String -mut -replace_with -: -F -) -- -> -Result -< -( -) -MatchError -> -where -Self -: -Sized -F -: -FnMut -( -& -Match -& -str -& -mut -String -) -- -> -bool -{ -let -mut -last_match -= -0 -; -for -m -in -self -. -try_find_iter -( -Input -: -: -new -( -haystack -) -) -? -{ -/ -/ -Since -there -are -no -restrictions -on -what -kinds -of -patterns -are -/ -/ -in -an -Aho -- -Corasick -automaton -we -might -get -matches -that -split -/ -/ -a -codepoint -or -even -matches -of -a -partial -codepoint -. -When -that -/ -/ -happens -we -just -skip -the -match -. -if -! -haystack -. -is_char_boundary -( -m -. -start -( -) -) -| -| -! -haystack -. -is_char_boundary -( -m -. -end -( -) -) -{ -continue -; -} -dst -. -push_str -( -& -haystack -[ -last_match -. -. -m -. -start -( -) -] -) -; -last_match -= -m -. -end -( -) -; -if -! -replace_with -( -& -m -& -haystack -[ -m -. -start -( -) -. -. -m -. -end -( -) -] -dst -) -{ -break -; -} -; -} -dst -. -push_str -( -& -haystack -[ -last_match -. -. -] -) -; -Ok -( -( -) -) -} -/ -/ -/ -Replaces -all -non -- -overlapping -matches -in -haystack -by -calling -the -/ -/ -/ -replace_with -closure -given -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_replace_all_with_bytes -] -( -crate -: -: -AhoCorasick -: -: -try_replace_all_with_bytes -) -/ -/ -/ -for -more -documentation -and -examples -. -fn -try_replace_all_with_bytes -< -F -> -( -& -self -haystack -: -& -[ -u8 -] -dst -: -& -mut -Vec -< -u8 -> -mut -replace_with -: -F -) -- -> -Result -< -( -) -MatchError -> -where -Self -: -Sized -F -: -FnMut -( -& -Match -& -[ -u8 -] -& -mut -Vec -< -u8 -> -) -- -> -bool -{ -let -mut -last_match -= -0 -; -for -m -in -self -. -try_find_iter -( -Input -: -: -new -( -haystack -) -) -? -{ -dst -. -extend -( -& -haystack -[ -last_match -. -. -m -. -start -( -) -] -) -; -last_match -= -m -. -end -( -) -; -if -! -replace_with -( -& -m -& -haystack -[ -m -. -start -( -) -. -. -m -. -end -( -) -] -dst -) -{ -break -; -} -; -} -dst -. -extend -( -& -haystack -[ -last_match -. -. -] -) -; -Ok -( -( -) -) -} -/ -/ -/ -Returns -an -iterator -of -non -- -overlapping -matches -with -this -automaton -/ -/ -/ -from -the -stream -given -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_stream_find_iter -] -( -crate -: -: -AhoCorasick -: -: -try_stream_find_iter -) -/ -/ -/ -for -more -documentation -and -examples -. -# -[ -cfg -( -feature -= -" -std -" -) -] -fn -try_stream_find_iter -< -' -a -R -: -std -: -: -io -: -: -Read -> -( -& -' -a -self -rdr -: -R -) -- -> -Result -< -StreamFindIter -< -' -a -Self -R -> -MatchError -> -where -Self -: -Sized -{ -Ok -( -StreamFindIter -{ -it -: -StreamChunkIter -: -: -new -( -self -rdr -) -? -} -) -} -/ -/ -/ -Replaces -all -non -- -overlapping -matches -in -rdr -with -strings -from -/ -/ -/ -replace_with -depending -on -the -pattern -that -matched -and -writes -the -/ -/ -/ -result -to -wtr -. -The -replace_with -slice -must -have -length -equal -to -/ -/ -/ -Automaton -: -: -patterns_len -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_stream_replace_all -] -( -crate -: -: -AhoCorasick -: -: -try_stream_replace_all -) -/ -/ -/ -for -more -documentation -and -examples -. -# -[ -cfg -( -feature -= -" -std -" -) -] -fn -try_stream_replace_all -< -R -W -B -> -( -& -self -rdr -: -R -wtr -: -W -replace_with -: -& -[ -B -] -) -- -> -std -: -: -io -: -: -Result -< -( -) -> -where -Self -: -Sized -R -: -std -: -: -io -: -: -Read -W -: -std -: -: -io -: -: -Write -B -: -AsRef -< -[ -u8 -] -> -{ -assert_eq -! -( -replace_with -. -len -( -) -self -. -patterns_len -( -) -" -streaming -replace_all -requires -a -replacement -for -every -pattern -\ -in -the -automaton -" -) -; -self -. -try_stream_replace_all_with -( -rdr -wtr -| -mat -_ -wtr -| -{ -wtr -. -write_all -( -replace_with -[ -mat -. -pattern -( -) -] -. -as_ref -( -) -) -} -) -} -/ -/ -/ -Replaces -all -non -- -overlapping -matches -in -rdr -by -calling -the -/ -/ -/ -replace_with -closure -given -and -writing -the -result -to -wtr -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasick -: -: -try_stream_replace_all_with -] -( -crate -: -: -AhoCorasick -: -: -try_stream_replace_all_with -) -/ -/ -/ -for -more -documentation -and -examples -. -# -[ -cfg -( -feature -= -" -std -" -) -] -fn -try_stream_replace_all_with -< -R -W -F -> -( -& -self -rdr -: -R -mut -wtr -: -W -mut -replace_with -: -F -) -- -> -std -: -: -io -: -: -Result -< -( -) -> -where -Self -: -Sized -R -: -std -: -: -io -: -: -Read -W -: -std -: -: -io -: -: -Write -F -: -FnMut -( -& -Match -& -[ -u8 -] -& -mut -W -) -- -> -std -: -: -io -: -: -Result -< -( -) -> -{ -let -mut -it -= -StreamChunkIter -: -: -new -( -self -rdr -) -. -map_err -( -| -e -| -{ -let -kind -= -std -: -: -io -: -: -ErrorKind -: -: -Other -; -std -: -: -io -: -: -Error -: -: -new -( -kind -e -) -} -) -? -; -while -let -Some -( -result -) -= -it -. -next -( -) -{ -let -chunk -= -result -? -; -match -chunk -{ -StreamChunk -: -: -NonMatch -{ -bytes -. -. -} -= -> -{ -wtr -. -write_all -( -bytes -) -? -; -} -StreamChunk -: -: -Match -{ -bytes -mat -} -= -> -{ -replace_with -( -& -mat -bytes -& -mut -wtr -) -? -; -} -} -} -Ok -( -( -) -) -} -} -/ -/ -SAFETY -: -This -just -defers -to -the -underlying -' -AcAutomaton -' -and -thus -inherits -/ -/ -its -safety -properties -. -unsafe -impl -< -' -a -A -: -Automaton -+ -? -Sized -> -Automaton -for -& -' -a -A -{ -# -[ -inline -( -always -) -] -fn -start_state -( -& -self -anchored -: -Anchored -) -- -> -Result -< -StateID -MatchError -> -{ -( -* -* -self -) -. -start_state -( -anchored -) -} -# -[ -inline -( -always -) -] -fn -next_state -( -& -self -anchored -: -Anchored -sid -: -StateID -byte -: -u8 -) -- -> -StateID -{ -( -* -* -self -) -. -next_state -( -anchored -sid -byte -) -} -# -[ -inline -( -always -) -] -fn -is_special -( -& -self -sid -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_special -( -sid -) -} -# -[ -inline -( -always -) -] -fn -is_dead -( -& -self -sid -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_dead -( -sid -) -} -# -[ -inline -( -always -) -] -fn -is_match -( -& -self -sid -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_match -( -sid -) -} -# -[ -inline -( -always -) -] -fn -is_start -( -& -self -sid -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_start -( -sid -) -} -# -[ -inline -( -always -) -] -fn -match_kind -( -& -self -) -- -> -MatchKind -{ -( -* -* -self -) -. -match_kind -( -) -} -# -[ -inline -( -always -) -] -fn -match_len -( -& -self -sid -: -StateID -) -- -> -usize -{ -( -* -* -self -) -. -match_len -( -sid -) -} -# -[ -inline -( -always -) -] -fn -match_pattern -( -& -self -sid -: -StateID -index -: -usize -) -- -> -PatternID -{ -( -* -* -self -) -. -match_pattern -( -sid -index -) -} -# -[ -inline -( -always -) -] -fn -patterns_len -( -& -self -) -- -> -usize -{ -( -* -* -self -) -. -patterns_len -( -) -} -# -[ -inline -( -always -) -] -fn -pattern_len -( -& -self -pid -: -PatternID -) -- -> -usize -{ -( -* -* -self -) -. -pattern_len -( -pid -) -} -# -[ -inline -( -always -) -] -fn -min_pattern_len -( -& -self -) -- -> -usize -{ -( -* -* -self -) -. -min_pattern_len -( -) -} -# -[ -inline -( -always -) -] -fn -max_pattern_len -( -& -self -) -- -> -usize -{ -( -* -* -self -) -. -max_pattern_len -( -) -} -# -[ -inline -( -always -) -] -fn -memory_usage -( -& -self -) -- -> -usize -{ -( -* -* -self -) -. -memory_usage -( -) -} -# -[ -inline -( -always -) -] -fn -prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -( -* -* -self -) -. -prefilter -( -) -} -} -/ -/ -/ -Represents -the -current -state -of -an -overlapping -search -. -/ -/ -/ -/ -/ -/ -This -is -used -for -overlapping -searches -since -they -need -to -know -something -/ -/ -/ -about -the -previous -search -. -For -example -when -multiple -patterns -match -at -the -/ -/ -/ -same -position -this -state -tracks -the -last -reported -pattern -so -that -the -next -/ -/ -/ -search -knows -whether -to -report -another -matching -pattern -or -continue -with -/ -/ -/ -the -search -at -the -next -position -. -Additionally -it -also -tracks -which -state -/ -/ -/ -the -last -search -call -terminated -in -and -the -current -offset -of -the -search -/ -/ -/ -in -the -haystack -. -/ -/ -/ -/ -/ -/ -This -type -provides -limited -introspection -capabilities -. -The -only -thing -a -/ -/ -/ -caller -can -do -is -construct -it -and -pass -it -around -to -permit -search -routines -/ -/ -/ -to -use -it -to -track -state -and -to -ask -whether -a -match -has -been -found -. -/ -/ -/ -/ -/ -/ -Callers -should -always -provide -a -fresh -state -constructed -via -/ -/ -/ -[ -OverlappingState -: -: -start -] -when -starting -a -new -search -. -That -same -state -/ -/ -/ -should -be -reused -for -subsequent -searches -on -the -same -Input -. -The -state -/ -/ -/ -given -will -advance -through -the -haystack -itself -. -Callers -can -detect -the -end -/ -/ -/ -of -a -search -when -neither -an -error -nor -a -match -is -returned -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -manually -iterate -over -all -overlapping -matches -. -If -/ -/ -/ -you -need -this -you -might -consider -using -/ -/ -/ -[ -AhoCorasick -: -: -find_overlapping_iter -] -( -crate -: -: -AhoCorasick -: -: -find_overlapping_iter -) -/ -/ -/ -instead -but -this -shows -how -to -correctly -use -an -OverlappingState -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -/ -/ -/ -automaton -: -: -OverlappingState -/ -/ -/ -AhoCorasick -Input -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -append -" -" -appendage -" -" -app -" -] -; -/ -/ -/ -let -haystack -= -" -append -the -app -to -the -appendage -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -new -( -patterns -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -/ -/ -/ -loop -{ -/ -/ -/ -ac -. -find_overlapping -( -haystack -& -mut -state -) -; -/ -/ -/ -let -mat -= -match -state -. -get_match -( -) -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -mat -) -= -> -mat -/ -/ -/ -} -; -/ -/ -/ -matches -. -push -( -mat -) -; -/ -/ -/ -} -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -Match -: -: -must -( -2 -0 -. -. -3 -) -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -6 -) -/ -/ -/ -Match -: -: -must -( -2 -11 -. -. -14 -) -/ -/ -/ -Match -: -: -must -( -2 -22 -. -. -25 -) -/ -/ -/ -Match -: -: -must -( -0 -22 -. -. -28 -) -/ -/ -/ -Match -: -: -must -( -1 -22 -. -. -31 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -OverlappingState -{ -/ -/ -/ -The -match -reported -by -the -most -recent -overlapping -search -to -use -this -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -If -a -search -does -not -find -any -matches -then -it -is -expected -to -clear -/ -/ -/ -this -value -. -mat -: -Option -< -Match -> -/ -/ -/ -The -state -ID -of -the -state -at -which -the -search -was -in -when -the -call -/ -/ -/ -terminated -. -When -this -is -a -match -state -last_match -must -be -set -to -a -/ -/ -/ -non -- -None -value -. -/ -/ -/ -/ -/ -/ -A -None -value -indicates -the -start -state -of -the -corresponding -/ -/ -/ -automaton -. -We -cannot -use -the -actual -ID -since -any -one -automaton -may -/ -/ -/ -have -many -start -states -and -which -one -is -in -use -depends -on -search -- -time -/ -/ -/ -factors -( -such -as -whether -the -search -is -anchored -or -not -) -. -id -: -Option -< -StateID -> -/ -/ -/ -The -position -of -the -search -. -/ -/ -/ -/ -/ -/ -When -id -is -None -( -i -. -e -. -we -are -starting -a -search -) -this -is -set -to -/ -/ -/ -the -beginning -of -the -search -as -given -by -the -caller -regardless -of -its -/ -/ -/ -current -value -. -Subsequent -calls -to -an -overlapping -search -pick -up -at -/ -/ -/ -this -offset -. -at -: -usize -/ -/ -/ -The -index -into -the -matching -patterns -of -the -next -match -to -report -if -the -/ -/ -/ -current -state -is -a -match -state -. -Note -that -this -may -be -1 -greater -than -/ -/ -/ -the -total -number -of -matches -to -report -for -the -current -match -state -. -( -In -/ -/ -/ -which -case -no -more -matches -should -be -reported -at -the -current -position -/ -/ -/ -and -the -search -should -advance -to -the -next -position -. -) -next_match_index -: -Option -< -usize -> -} -impl -OverlappingState -{ -/ -/ -/ -Create -a -new -overlapping -state -that -begins -at -the -start -state -. -pub -fn -start -( -) -- -> -OverlappingState -{ -OverlappingState -{ -mat -: -None -id -: -None -at -: -0 -next_match_index -: -None -} -} -/ -/ -/ -Return -the -match -result -of -the -most -recent -search -to -execute -with -this -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -Every -search -will -clear -this -result -automatically -such -that -if -no -/ -/ -/ -match -is -found -this -will -always -correctly -report -None -. -pub -fn -get_match -( -& -self -) -- -> -Option -< -Match -> -{ -self -. -mat -} -} -/ -/ -/ -An -iterator -of -non -- -overlapping -matches -in -a -particular -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -matches -according -to -the -[ -MatchKind -] -used -by -this -/ -/ -/ -automaton -. -/ -/ -/ -/ -/ -/ -This -iterator -is -constructed -via -the -[ -Automaton -: -: -try_find_iter -] -method -. -/ -/ -/ -/ -/ -/ -The -type -variable -A -refers -to -the -implementation -of -the -[ -Automaton -] -/ -/ -/ -trait -used -to -execute -the -search -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -[ -Automaton -] -/ -/ -/ -implementation -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -h -refers -to -the -lifetime -of -the -haystack -being -searched -. -# -[ -derive -( -Debug -) -] -pub -struct -FindIter -< -' -a -' -h -A -> -{ -/ -/ -/ -The -automaton -used -to -drive -the -search -. -aut -: -& -' -a -A -/ -/ -/ -The -input -parameters -to -give -to -each -search -call -. -/ -/ -/ -/ -/ -/ -The -start -position -of -the -search -is -mutated -during -iteration -. -input -: -Input -< -' -h -> -/ -/ -/ -Records -the -end -offset -of -the -most -recent -match -. -This -is -necessary -to -/ -/ -/ -handle -a -corner -case -for -preventing -empty -matches -from -overlapping -with -/ -/ -/ -the -ending -bounds -of -a -prior -match -. -last_match_end -: -Option -< -usize -> -} -impl -< -' -a -' -h -A -: -Automaton -> -FindIter -< -' -a -' -h -A -> -{ -/ -/ -/ -Creates -a -new -non -- -overlapping -iterator -. -If -the -given -automaton -would -/ -/ -/ -return -an -error -on -a -search -with -the -given -input -configuration -then -/ -/ -/ -that -error -is -returned -here -. -fn -new -( -aut -: -& -' -a -A -input -: -Input -< -' -h -> -) -- -> -Result -< -FindIter -< -' -a -' -h -A -> -MatchError -> -{ -/ -/ -The -only -way -this -search -can -fail -is -if -we -cannot -retrieve -the -start -/ -/ -state -. -e -. -g -. -Asking -for -an -anchored -search -when -only -unanchored -/ -/ -searches -are -supported -. -let -_ -= -aut -. -start_state -( -input -. -get_anchored -( -) -) -? -; -Ok -( -FindIter -{ -aut -input -last_match_end -: -None -} -) -} -/ -/ -/ -Executes -a -search -and -returns -a -match -if -one -is -found -. -/ -/ -/ -/ -/ -/ -This -does -not -advance -the -input -forward -. -It -just -executes -a -search -/ -/ -/ -based -on -the -current -configuration -/ -offsets -. -fn -search -( -& -self -) -- -> -Option -< -Match -> -{ -/ -/ -The -unwrap -is -OK -here -because -we -check -at -iterator -construction -time -/ -/ -that -no -subsequent -search -call -( -using -the -same -configuration -) -will -/ -/ -ever -return -an -error -. -self -. -aut -. -try_find -( -& -self -. -input -) -. -expect -( -" -already -checked -that -no -match -error -can -occur -" -) -} -/ -/ -/ -Handles -the -special -case -of -an -empty -match -by -ensuring -that -1 -) -the -/ -/ -/ -iterator -always -advances -and -2 -) -empty -matches -never -overlap -with -other -/ -/ -/ -matches -. -/ -/ -/ -/ -/ -/ -( -1 -) -is -necessary -because -we -principally -make -progress -by -setting -the -/ -/ -/ -starting -location -of -the -next -search -to -the -ending -location -of -the -last -/ -/ -/ -match -. -But -if -a -match -is -empty -then -this -results -in -a -search -that -does -/ -/ -/ -not -advance -and -thus -does -not -terminate -. -/ -/ -/ -/ -/ -/ -( -2 -) -is -not -strictly -necessary -but -makes -intuitive -sense -and -matches -/ -/ -/ -the -presiding -behavior -of -most -general -purpose -regex -engines -. -/ -/ -/ -( -Obviously -this -crate -isn -' -t -a -regex -engine -but -we -choose -to -match -/ -/ -/ -their -semantics -. -) -The -" -intuitive -sense -" -here -is -that -we -want -to -report -/ -/ -/ -NON -- -overlapping -matches -. -So -for -example -given -the -patterns -' -a -' -and -/ -/ -/ -' -' -( -an -empty -string -) -against -the -haystack -' -a -' -without -the -special -/ -/ -/ -handling -you -' -d -get -the -matches -[ -0 -1 -) -and -[ -1 -1 -) -where -the -latter -/ -/ -/ -overlaps -with -the -end -bounds -of -the -former -. -/ -/ -/ -/ -/ -/ -Note -that -we -mark -this -cold -and -forcefully -prevent -inlining -because -/ -/ -/ -handling -empty -matches -like -this -is -extremely -rare -and -does -require -/ -/ -/ -quite -a -bit -of -code -comparatively -. -Keeping -this -code -out -of -the -main -/ -/ -/ -iterator -function -keeps -it -smaller -and -more -amenable -to -inlining -/ -/ -/ -itself -. -# -[ -cold -] -# -[ -inline -( -never -) -] -fn -handle_overlapping_empty_match -( -& -mut -self -mut -m -: -Match -) -- -> -Option -< -Match -> -{ -assert -! -( -m -. -is_empty -( -) -) -; -if -Some -( -m -. -end -( -) -) -= -= -self -. -last_match_end -{ -self -. -input -. -set_start -( -self -. -input -. -start -( -) -. -checked_add -( -1 -) -. -unwrap -( -) -) -; -m -= -self -. -search -( -) -? -; -} -Some -( -m -) -} -} -impl -< -' -a -' -h -A -: -Automaton -> -Iterator -for -FindIter -< -' -a -' -h -A -> -{ -type -Item -= -Match -; -# -[ -inline -( -always -) -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -let -mut -m -= -self -. -search -( -) -? -; -if -m -. -is_empty -( -) -{ -m -= -self -. -handle_overlapping_empty_match -( -m -) -? -; -} -self -. -input -. -set_start -( -m -. -end -( -) -) -; -self -. -last_match_end -= -Some -( -m -. -end -( -) -) -; -Some -( -m -) -} -} -/ -/ -/ -An -iterator -of -overlapping -matches -in -a -particular -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -will -report -all -possible -matches -in -a -particular -haystack -/ -/ -/ -even -when -the -matches -overlap -. -/ -/ -/ -/ -/ -/ -This -iterator -is -constructed -via -the -/ -/ -/ -[ -Automaton -: -: -try_find_overlapping_iter -] -method -. -/ -/ -/ -/ -/ -/ -The -type -variable -A -refers -to -the -implementation -of -the -[ -Automaton -] -/ -/ -/ -trait -used -to -execute -the -search -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -[ -Automaton -] -/ -/ -/ -implementation -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -h -refers -to -the -lifetime -of -the -haystack -being -searched -. -# -[ -derive -( -Debug -) -] -pub -struct -FindOverlappingIter -< -' -a -' -h -A -> -{ -aut -: -& -' -a -A -input -: -Input -< -' -h -> -state -: -OverlappingState -} -impl -< -' -a -' -h -A -: -Automaton -> -Iterator -for -FindOverlappingIter -< -' -a -' -h -A -> -{ -type -Item -= -Match -; -# -[ -inline -( -always -) -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -self -. -aut -. -try_find_overlapping -( -& -self -. -input -& -mut -self -. -state -) -. -expect -( -" -already -checked -that -no -match -error -can -occur -here -" -) -; -self -. -state -. -get_match -( -) -} -} -/ -/ -/ -An -iterator -that -reports -matches -in -a -stream -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -elements -of -type -io -: -: -Result -< -Match -> -where -an -error -/ -/ -/ -is -reported -if -there -was -a -problem -reading -from -the -underlying -stream -. -/ -/ -/ -The -iterator -terminates -only -when -the -underlying -stream -reaches -EOF -. -/ -/ -/ -/ -/ -/ -This -iterator -is -constructed -via -the -[ -Automaton -: -: -try_stream_find_iter -] -/ -/ -/ -method -. -/ -/ -/ -/ -/ -/ -The -type -variable -A -refers -to -the -implementation -of -the -[ -Automaton -] -/ -/ -/ -trait -used -to -execute -the -search -. -/ -/ -/ -/ -/ -/ -The -type -variable -R -refers -to -the -io -: -: -Read -stream -that -is -being -read -/ -/ -/ -from -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -[ -Automaton -] -/ -/ -/ -implementation -. -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -derive -( -Debug -) -] -pub -struct -StreamFindIter -< -' -a -A -R -> -{ -it -: -StreamChunkIter -< -' -a -A -R -> -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -< -' -a -A -: -Automaton -R -: -std -: -: -io -: -: -Read -> -Iterator -for -StreamFindIter -< -' -a -A -R -> -{ -type -Item -= -std -: -: -io -: -: -Result -< -Match -> -; -fn -next -( -& -mut -self -) -- -> -Option -< -std -: -: -io -: -: -Result -< -Match -> -> -{ -loop -{ -match -self -. -it -. -next -( -) -{ -None -= -> -return -None -Some -( -Err -( -err -) -) -= -> -return -Some -( -Err -( -err -) -) -Some -( -Ok -( -StreamChunk -: -: -NonMatch -{ -. -. -} -) -) -= -> -{ -} -Some -( -Ok -( -StreamChunk -: -: -Match -{ -mat -. -. -} -) -) -= -> -{ -return -Some -( -Ok -( -mat -) -) -; -} -} -} -} -} -/ -/ -/ -An -iterator -that -reports -matches -in -a -stream -. -/ -/ -/ -/ -/ -/ -( -This -doesn -' -t -actually -implement -the -Iterator -trait -because -it -returns -/ -/ -/ -something -with -a -lifetime -attached -to -a -buffer -it -owns -but -that -' -s -OK -. -It -/ -/ -/ -still -has -a -next -method -and -is -iterator -- -like -enough -to -be -fine -. -) -/ -/ -/ -/ -/ -/ -This -iterator -yields -elements -of -type -io -: -: -Result -< -StreamChunk -> -where -/ -/ -/ -an -error -is -reported -if -there -was -a -problem -reading -from -the -underlying -/ -/ -/ -stream -. -The -iterator -terminates -only -when -the -underlying -stream -reaches -/ -/ -/ -EOF -. -/ -/ -/ -/ -/ -/ -The -idea -here -is -that -each -chunk -represents -either -a -match -or -a -non -- -match -/ -/ -/ -and -if -you -concatenated -all -of -the -chunks -together -you -' -d -reproduce -the -/ -/ -/ -entire -contents -of -the -stream -byte -- -for -- -byte -. -/ -/ -/ -/ -/ -/ -This -chunk -machinery -is -a -bit -complicated -and -it -isn -' -t -strictly -required -/ -/ -/ -for -a -stream -searcher -that -just -reports -matches -. -But -we -do -need -something -/ -/ -/ -like -this -to -deal -with -the -" -replacement -" -API -which -needs -to -know -which -/ -/ -/ -chunks -it -can -copy -and -which -it -needs -to -replace -. -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -derive -( -Debug -) -] -struct -StreamChunkIter -< -' -a -A -R -> -{ -/ -/ -/ -The -underlying -automaton -to -do -the -search -. -aut -: -& -' -a -A -/ -/ -/ -The -source -of -bytes -we -read -from -. -rdr -: -R -/ -/ -/ -A -roll -buffer -for -managing -bytes -from -rdr -. -Basically -this -is -used -/ -/ -/ -to -handle -the -case -of -a -match -that -is -split -by -two -different -/ -/ -/ -calls -to -rdr -. -read -( -) -. -This -isn -' -t -strictly -needed -if -all -we -needed -to -/ -/ -/ -do -was -report -matches -but -here -we -are -reporting -chunks -of -non -- -matches -/ -/ -/ -and -matches -and -in -order -to -do -that -we -really -just -cannot -treat -our -/ -/ -/ -stream -as -non -- -overlapping -blocks -of -bytes -. -We -need -to -permit -some -/ -/ -/ -overlap -while -we -retain -bytes -from -a -previous -read -call -in -memory -. -buf -: -crate -: -: -util -: -: -buffer -: -: -Buffer -/ -/ -/ -The -unanchored -starting -state -of -this -automaton -. -start -: -StateID -/ -/ -/ -The -state -of -the -automaton -. -sid -: -StateID -/ -/ -/ -The -absolute -position -over -the -entire -stream -. -absolute_pos -: -usize -/ -/ -/ -The -position -we -' -re -currently -at -within -buf -. -buffer_pos -: -usize -/ -/ -/ -The -buffer -position -of -the -end -of -the -bytes -that -we -last -returned -/ -/ -/ -to -the -caller -. -Basically -whenever -we -find -a -match -we -look -to -see -if -/ -/ -/ -there -is -a -difference -between -where -the -match -started -and -the -position -/ -/ -/ -of -the -last -byte -we -returned -to -the -caller -. -If -there -' -s -a -difference -/ -/ -/ -then -we -need -to -return -a -' -NonMatch -' -chunk -. -buffer_reported_pos -: -usize -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -< -' -a -A -: -Automaton -R -: -std -: -: -io -: -: -Read -> -StreamChunkIter -< -' -a -A -R -> -{ -fn -new -( -aut -: -& -' -a -A -rdr -: -R -) -- -> -Result -< -StreamChunkIter -< -' -a -A -R -> -MatchError -> -{ -/ -/ -This -restriction -is -a -carry -- -over -from -older -versions -of -this -crate -. -/ -/ -I -didn -' -t -have -the -bandwidth -to -think -through -how -to -handle -say -/ -/ -leftmost -- -first -or -leftmost -- -longest -matching -but -. -. -. -it -should -be -/ -/ -possible -? -The -main -problem -is -that -once -you -see -a -match -state -in -/ -/ -leftmost -- -first -semantics -you -can -' -t -just -stop -at -that -point -and -/ -/ -report -a -match -. -You -have -to -keep -going -until -you -either -hit -a -dead -/ -/ -state -or -EOF -. -So -how -do -you -know -when -you -' -ll -hit -a -dead -state -? -Well -/ -/ -you -don -' -t -. -With -Aho -- -Corasick -I -believe -you -can -put -a -bound -on -it -/ -/ -and -say -" -once -a -match -has -been -seen -you -' -ll -need -to -scan -forward -at -/ -/ -most -N -bytes -" -where -N -= -aut -. -max_pattern_len -( -) -. -/ -/ -/ -/ -Which -is -fine -but -it -does -mean -that -state -about -whether -we -' -re -still -/ -/ -looking -for -a -dead -state -or -not -needs -to -persist -across -buffer -/ -/ -refills -. -Which -this -code -doesn -' -t -really -handle -. -It -does -preserve -/ -/ -* -some -* -state -across -buffer -refills -basically -ensuring -that -a -match -/ -/ -span -is -always -in -memory -. -if -! -aut -. -match_kind -( -) -. -is_standard -( -) -{ -return -Err -( -MatchError -: -: -unsupported_stream -( -aut -. -match_kind -( -) -) -) -; -} -/ -/ -This -is -kind -of -a -cop -- -out -but -empty -matches -are -SUPER -annoying -. -/ -/ -If -we -know -they -can -' -t -happen -( -which -is -what -we -enforce -here -) -then -/ -/ -it -makes -a -lot -of -logic -much -simpler -. -With -that -said -I -' -m -open -to -/ -/ -supporting -this -case -but -we -need -to -define -proper -semantics -for -it -/ -/ -first -. -It -wasn -' -t -totally -clear -to -me -what -it -should -do -at -the -time -/ -/ -of -writing -so -I -decided -to -just -be -conservative -. -/ -/ -/ -/ -It -also -seems -like -a -very -weird -case -to -support -anyway -. -Why -search -a -/ -/ -stream -if -you -' -re -just -going -to -get -a -match -at -every -position -? -/ -/ -/ -/ -\ -_ -( -) -_ -/ -if -aut -. -min_pattern_len -( -) -= -= -0 -{ -return -Err -( -MatchError -: -: -unsupported_empty -( -) -) -; -} -let -start -= -aut -. -start_state -( -Anchored -: -: -No -) -? -; -Ok -( -StreamChunkIter -{ -aut -rdr -buf -: -crate -: -: -util -: -: -buffer -: -: -Buffer -: -: -new -( -aut -. -max_pattern_len -( -) -) -start -sid -: -start -absolute_pos -: -0 -buffer_pos -: -0 -buffer_reported_pos -: -0 -} -) -} -fn -next -( -& -mut -self -) -- -> -Option -< -std -: -: -io -: -: -Result -< -StreamChunk -> -> -{ -/ -/ -This -code -is -pretty -gnarly -. -It -IS -simpler -than -the -equivalent -code -/ -/ -in -the -previous -aho -- -corasick -release -in -part -because -we -inline -/ -/ -automaton -traversal -here -and -also -in -part -because -we -have -abdicated -/ -/ -support -for -automatons -that -contain -an -empty -pattern -. -/ -/ -/ -/ -I -suspect -this -code -could -be -made -a -bit -simpler -by -designing -a -/ -/ -better -buffer -abstraction -. -/ -/ -/ -/ -But -in -general -this -code -is -basically -write -- -only -. -So -you -' -ll -need -/ -/ -to -go -through -it -step -- -by -- -step -to -grok -it -. -One -of -the -key -bits -of -/ -/ -complexity -is -tracking -a -few -different -offsets -. -' -buffer_pos -' -is -/ -/ -where -we -are -in -the -buffer -for -search -. -' -buffer_reported_pos -' -is -the -/ -/ -position -immediately -following -the -last -byte -in -the -buffer -that -/ -/ -we -' -ve -returned -to -the -caller -. -And -' -absolute_pos -' -is -the -overall -/ -/ -current -absolute -position -of -the -search -in -the -entire -stream -and -/ -/ -this -is -what -match -spans -are -reported -in -terms -of -. -loop -{ -if -self -. -aut -. -is_match -( -self -. -sid -) -{ -let -mat -= -self -. -get_match -( -) -; -if -let -Some -( -r -) -= -self -. -get_non_match_chunk -( -mat -) -{ -self -. -buffer_reported_pos -+ -= -r -. -len -( -) -; -let -bytes -= -& -self -. -buf -. -buffer -( -) -[ -r -] -; -return -Some -( -Ok -( -StreamChunk -: -: -NonMatch -{ -bytes -} -) -) -; -} -self -. -sid -= -self -. -start -; -let -r -= -self -. -get_match_chunk -( -mat -) -; -self -. -buffer_reported_pos -+ -= -r -. -len -( -) -; -let -bytes -= -& -self -. -buf -. -buffer -( -) -[ -r -] -; -return -Some -( -Ok -( -StreamChunk -: -: -Match -{ -bytes -mat -} -) -) -; -} -if -self -. -buffer_pos -> -= -self -. -buf -. -buffer -( -) -. -len -( -) -{ -if -let -Some -( -r -) -= -self -. -get_pre_roll_non_match_chunk -( -) -{ -self -. -buffer_reported_pos -+ -= -r -. -len -( -) -; -let -bytes -= -& -self -. -buf -. -buffer -( -) -[ -r -] -; -return -Some -( -Ok -( -StreamChunk -: -: -NonMatch -{ -bytes -} -) -) -; -} -if -self -. -buf -. -buffer -( -) -. -len -( -) -> -= -self -. -buf -. -min_buffer_len -( -) -{ -self -. -buffer_pos -= -self -. -buf -. -min_buffer_len -( -) -; -self -. -buffer_reported_pos -- -= -self -. -buf -. -buffer -( -) -. -len -( -) -- -self -. -buf -. -min_buffer_len -( -) -; -self -. -buf -. -roll -( -) -; -} -match -self -. -buf -. -fill -( -& -mut -self -. -rdr -) -{ -Err -( -err -) -= -> -return -Some -( -Err -( -err -) -) -Ok -( -true -) -= -> -{ -} -Ok -( -false -) -= -> -{ -/ -/ -We -' -ve -hit -EOF -but -if -there -are -still -some -/ -/ -unreported -bytes -remaining -return -them -now -. -if -let -Some -( -r -) -= -self -. -get_eof_non_match_chunk -( -) -{ -self -. -buffer_reported_pos -+ -= -r -. -len -( -) -; -let -bytes -= -& -self -. -buf -. -buffer -( -) -[ -r -] -; -return -Some -( -Ok -( -StreamChunk -: -: -NonMatch -{ -bytes -} -) -) -; -} -/ -/ -We -' -ve -reported -everything -! -return -None -; -} -} -} -let -start -= -self -. -absolute_pos -; -for -& -byte -in -self -. -buf -. -buffer -( -) -[ -self -. -buffer_pos -. -. -] -. -iter -( -) -{ -self -. -sid -= -self -. -aut -. -next_state -( -Anchored -: -: -No -self -. -sid -byte -) -; -self -. -absolute_pos -+ -= -1 -; -if -self -. -aut -. -is_match -( -self -. -sid -) -{ -break -; -} -} -self -. -buffer_pos -+ -= -self -. -absolute_pos -- -start -; -} -} -/ -/ -/ -Return -a -match -chunk -for -the -given -match -. -It -is -assumed -that -the -match -/ -/ -/ -ends -at -the -current -buffer_pos -. -fn -get_match_chunk -( -& -self -mat -: -Match -) -- -> -core -: -: -ops -: -: -Range -< -usize -> -{ -let -start -= -self -. -buffer_pos -- -mat -. -len -( -) -; -let -end -= -self -. -buffer_pos -; -start -. -. -end -} -/ -/ -/ -Return -a -non -- -match -chunk -if -necessary -just -before -reporting -a -match -. -/ -/ -/ -This -returns -None -if -there -is -nothing -to -report -. -Otherwise -this -/ -/ -/ -assumes -that -the -given -match -ends -at -the -current -buffer_pos -. -fn -get_non_match_chunk -( -& -self -mat -: -Match -) -- -> -Option -< -core -: -: -ops -: -: -Range -< -usize -> -> -{ -let -buffer_mat_start -= -self -. -buffer_pos -- -mat -. -len -( -) -; -if -buffer_mat_start -> -self -. -buffer_reported_pos -{ -let -start -= -self -. -buffer_reported_pos -; -let -end -= -buffer_mat_start -; -return -Some -( -start -. -. -end -) -; -} -None -} -/ -/ -/ -Look -for -any -bytes -that -should -be -reported -as -a -non -- -match -just -before -/ -/ -/ -rolling -the -buffer -. -/ -/ -/ -/ -/ -/ -Note -that -this -only -reports -bytes -up -to -buffer -. -len -( -) -- -/ -/ -/ -min_buffer_len -as -it -' -s -not -possible -to -know -whether -the -bytes -/ -/ -/ -following -that -will -participate -in -a -match -or -not -. -fn -get_pre_roll_non_match_chunk -( -& -self -) -- -> -Option -< -core -: -: -ops -: -: -Range -< -usize -> -> -{ -let -end -= -self -. -buf -. -buffer -( -) -. -len -( -) -. -saturating_sub -( -self -. -buf -. -min_buffer_len -( -) -) -; -if -self -. -buffer_reported_pos -< -end -{ -return -Some -( -self -. -buffer_reported_pos -. -. -end -) -; -} -None -} -/ -/ -/ -Return -any -unreported -bytes -as -a -non -- -match -up -to -the -end -of -the -buffer -. -/ -/ -/ -/ -/ -/ -This -should -only -be -called -when -the -entire -contents -of -the -buffer -have -/ -/ -/ -been -searched -and -EOF -has -been -hit -when -trying -to -fill -the -buffer -. -fn -get_eof_non_match_chunk -( -& -self -) -- -> -Option -< -core -: -: -ops -: -: -Range -< -usize -> -> -{ -if -self -. -buffer_reported_pos -< -self -. -buf -. -buffer -( -) -. -len -( -) -{ -return -Some -( -self -. -buffer_reported_pos -. -. -self -. -buf -. -buffer -( -) -. -len -( -) -) -; -} -None -} -/ -/ -/ -Return -the -match -at -the -current -position -for -the -current -state -. -/ -/ -/ -/ -/ -/ -This -panics -if -self -. -aut -. -is_match -( -self -. -sid -) -isn -' -t -true -. -fn -get_match -( -& -self -) -- -> -Match -{ -get_match -( -self -. -aut -self -. -sid -0 -self -. -absolute_pos -) -} -} -/ -/ -/ -A -single -chunk -yielded -by -the -stream -chunk -iterator -. -/ -/ -/ -/ -/ -/ -The -' -r -lifetime -refers -to -the -lifetime -of -the -stream -chunk -iterator -. -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -derive -( -Debug -) -] -enum -StreamChunk -< -' -r -> -{ -/ -/ -/ -A -chunk -that -does -not -contain -any -matches -. -NonMatch -{ -bytes -: -& -' -r -[ -u8 -] -} -/ -/ -/ -A -chunk -that -precisely -contains -a -match -. -Match -{ -bytes -: -& -' -r -[ -u8 -] -mat -: -Match -} -} -# -[ -inline -( -never -) -] -pub -( -crate -) -fn -try_find_fwd -< -A -: -Automaton -+ -? -Sized -> -( -aut -: -& -A -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -if -input -. -is_done -( -) -{ -return -Ok -( -None -) -; -} -let -earliest -= -aut -. -match_kind -( -) -. -is_standard -( -) -| -| -input -. -get_earliest -( -) -; -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -try_find_fwd_imp -( -aut -input -None -Anchored -: -: -Yes -earliest -) -} -else -if -let -Some -( -pre -) -= -aut -. -prefilter -( -) -{ -if -earliest -{ -try_find_fwd_imp -( -aut -input -Some -( -pre -) -Anchored -: -: -No -true -) -} -else -{ -try_find_fwd_imp -( -aut -input -Some -( -pre -) -Anchored -: -: -No -false -) -} -} -else -{ -if -earliest -{ -try_find_fwd_imp -( -aut -input -None -Anchored -: -: -No -true -) -} -else -{ -try_find_fwd_imp -( -aut -input -None -Anchored -: -: -No -false -) -} -} -} -# -[ -inline -( -always -) -] -fn -try_find_fwd_imp -< -A -: -Automaton -+ -? -Sized -> -( -aut -: -& -A -input -: -& -Input -< -' -_ -> -pre -: -Option -< -& -Prefilter -> -anchored -: -Anchored -earliest -: -bool -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -let -mut -sid -= -aut -. -start_state -( -input -. -get_anchored -( -) -) -? -; -let -mut -at -= -input -. -start -( -) -; -let -mut -mat -= -None -; -if -aut -. -is_match -( -sid -) -{ -mat -= -Some -( -get_match -( -aut -sid -0 -at -) -) -; -if -earliest -{ -return -Ok -( -mat -) -; -} -} -if -let -Some -( -pre -) -= -pre -{ -match -pre -. -find_in -( -input -. -haystack -( -) -input -. -get_span -( -) -) -{ -Candidate -: -: -None -= -> -return -Ok -( -None -) -Candidate -: -: -Match -( -m -) -= -> -return -Ok -( -Some -( -m -) -) -Candidate -: -: -PossibleStartOfMatch -( -i -) -= -> -{ -at -= -i -; -} -} -} -while -at -< -input -. -end -( -) -{ -/ -/ -I -' -ve -tried -unrolling -this -loop -and -eliding -bounds -checks -but -no -/ -/ -matter -what -I -did -I -could -not -observe -a -consistent -improvement -on -/ -/ -any -benchmark -I -could -devise -. -( -If -someone -wants -to -re -- -litigate -this -/ -/ -the -way -to -do -it -is -to -add -an -' -next_state_unchecked -' -method -to -the -/ -/ -' -Automaton -' -trait -with -a -default -impl -that -uses -' -next_state -' -. -Then -/ -/ -use -' -aut -. -next_state_unchecked -' -here -and -implement -it -on -DFA -using -/ -/ -unchecked -slice -index -acces -. -) -sid -= -aut -. -next_state -( -anchored -sid -input -. -haystack -( -) -[ -at -] -) -; -if -aut -. -is_special -( -sid -) -{ -if -aut -. -is_dead -( -sid -) -{ -return -Ok -( -mat -) -; -} -else -if -aut -. -is_match -( -sid -) -{ -/ -/ -We -use -' -at -+ -1 -' -here -because -the -match -state -is -entered -/ -/ -at -the -last -byte -of -the -pattern -. -Since -we -use -half -- -open -/ -/ -intervals -the -end -of -the -range -of -the -match -is -one -past -the -/ -/ -last -byte -. -let -m -= -get_match -( -aut -sid -0 -at -+ -1 -) -; -/ -/ -For -the -automata -in -this -crate -we -make -a -size -trade -off -/ -/ -where -we -reuse -the -same -automaton -for -both -anchored -and -/ -/ -unanchored -searches -. -We -achieve -this -principally -by -simply -/ -/ -not -following -failure -transitions -while -computing -the -next -/ -/ -state -. -Instead -if -we -fail -to -find -the -next -state -we -return -/ -/ -a -dead -state -which -instructs -the -search -to -stop -. -( -This -/ -/ -is -why -' -next_state -' -needs -to -know -whether -the -search -is -/ -/ -anchored -or -not +self . -) -In -addition -we -have -different -start -/ -/ -states -for anchored -and -unanchored -searches -. -The -latter -has -/ -/ -a +( +) +& +& +at +> +0 +& +& +* +state_id += += self -- -loop -where -as -the -former -does -not . -/ -/ -/ -/ -In -this -way -we -can -use -the -same -trie -to -execute -both -/ -/ -anchored -and -unanchored -searches +start_state +( +) +{ +return +None +; +} +let +mut +last_match += +self . -There -is -a -catch -though +get_match +( +* +state_id +0 +at +) +; +while +at +< +haystack . -/ -/ -When -building -an -Aho -- -Corasick -automaton -for -unanchored -/ -/ -searches -we -copy -matches -from -match -states -to -other -states -/ -/ +len ( -which -would -otherwise -not -be -match -states ) +{ if -they -are -/ -/ -reachable -via -a -failure -transition +let +Some +( +pre +) += +prefilter +{ +if +prestate . -In -the -case -of -an -/ -/ -anchored -search -we -* -specifically +is_effective +( +at +) +& +& * -do -not -want -to -report -/ -/ -these -matches -because -they -represent -matches -that -start -past -/ -/ -the -beginning -of -the -search -. -/ -/ -/ -/ -Now -we -could -tweak -the -automaton -somehow -to -differentiate -/ -/ -anchored -from -unanchored -match -states -but -this -would -make -/ -/ -' -aut -. -is_match -' -and -potentially -' -aut -. -is_special -' -slower +state_id += += +self . -And -/ -/ -also -make -the -automaton -itself -more -complex +start_state +( +) +{ +let +c += +prefilter +: +: +next +( +prestate +pre +haystack +at +) . +into_option +( +) +; +match +c +{ +None += +> +return +None +Some +( +i +) += +> +{ +at += +i +; +} +} +} +} / / -/ -/ -Instead -we -insert -a -special -hack +CORRECTNESS : -if -the -search +next_state is +correct +for +all +possible +u8 +values / / -anchored +so +the +only +thing we -simply -ignore -matches -that -don ' -t -begin -at -/ -/ +re +concerned +about +is the -start +validity of -the -search -. -This -is -not -quite -ideal -but -we -/ -/ -do -specialize -this -function -in -such -a -way -that -unanchored / / -searches -don -' -t -pay -for -this -additional -branch +state_id . -While -this +state_id +either +comes +from +the +caller +( +in +which / / -might -cause -a -search -to -continue -on -for -more -than +case +we +assume it -/ -/ -otherwise -optimally -would +is +correct +) +or it -will -be -no -more -than +comes +from the +return / / -longest -pattern -in -the -automaton -. -The -reason -for -this +value +of +next_state +which is -/ -/ -that -we -ensure -we -don -' -t -follow -failure -transitions -during -/ -/ -an -anchored -search +guaranteed +to +be +correct . -Combined -with -using -a -different -anchored -/ -/ -starting -state -with -no +* +state_id += self -- -loop -we -guarantee -that -we -' -ll -/ -/ +. +next_state_no_fail +( +* +state_id +haystack +[ at -worst -move -through -a -number -of -transitions -equal -to -the -/ -/ -longest -pattern +] +) +; +at ++ += +1 +; +if +self . +is_match_or_dead_state +( +* +state_id +) +{ +if +* +state_id += += +dead_id +( +) +{ / / -/ -/ -Now -for -DFAs -the -whole -point -of -them -is +The +only +way to -eliminate +enter +into +a +dead +state +is +if +a +match / / -failure -transitions -entirely +has +been +found +so +we +assert +as +much . -So -there +This is -no -way -to -say -" -if +different / / -it -' -s -an -anchored -search -don -' -t -follow -failure -transitions -. -" +from +normal +automata +where +you +might +enter +a +dead +state / / -Instead -we -actually -have -to -build -two -entirely -separate +if +you +know +a +subsequent +match +will +never +be +found / / -automatons -into -the -transition -table +( +regardless +of +whether +a +match +has +already +been +found +) . -One -with -failure / / -transitions -built -into +For +Aho +- +Corasick it -and -another -that is -effectively +built +so +that +we +can +match +at / / -just -an -encoding -of +any +position +so the -base -trie -into +possibility +of a -transition -table -. -/ -/ -DFAs -still -need -this -check -though -because -the match -states +always / / -still -carry -matches -only -reachable -via -a -failure -transition +exists . / / -Why -? -Because -removing -them -seems -difficult -although -I / / -haven -' -t -given -it -a -lot -of -thought -. -if -! ( +Unless +we +have +an anchored +automaton +in +which +case +/ +/ +dead +states +are +used +to +stop +a +search . -is_anchored -( ) -& -& -m +debug_assert +! +( +last_match . -start +is_some ( ) -> -input +| +| +self . -start +anchored ( ) -) -{ -mat -= -Some -( -m +" +dead +state +should +only +be +seen +after +match +" ) ; -if -earliest -{ return -Ok +last_match +; +} +last_match += +self +. +get_match ( -mat +* +state_id +0 +at ) ; } } +last_match } -else +/ +/ +/ +This +is +like +leftmost_find_at +but +does +not +need +to +track +a +caller +/ +/ +/ +provided +state +id +. +In +other +words +the +only +output +of +this +routine +is +a +/ +/ +/ +match if -let -Some -( -pre -) -= -pre -{ +one +exists +. / / -If +/ +/ +/ +/ +It +is +regrettable +that we -' -re -here +need +to +effectively +copy +a +chunk +of +/ +/ +/ +implementation +twice +but +when we -know -it +don ' -s -a -special +t +need +to +track +the state -that +ID +we +/ +/ +/ +can +allow +the +prefilter +to +report +matches +immediately +without +having +/ +/ +/ +to +re +- +confirm +them +with +the +automaton +. +The +re +- +confirmation +step is -not -a / / -dead -or -a -match +/ +necessary +in +leftmost_find_at +because +tracing +through +the +automaton +is +/ +/ +/ +the +only +way +to +correctly +set +the state -AND -that -a -prefilter -is -active +ID . -Thus +( +Perhaps +an +alternative / / -it -must +/ +would be +to +keep a -start +map +from +pattern +ID +to +matching state -. -debug_assert -! -( -aut -. -is_start -( -sid -) -) -; +ID +but +that / / -We -don +/ +complicates +the +code +and +still +doesn ' t -care -about -' -Candidate -: -: -Match -' -here -because -if -such +permit +us +to +defer +to +the / / -a -match -were +/ +prefilter +entirely +when possible -it -would -have -been -returned -above +. +) / / -when -we -run -the -prefilter -before -walking +/ +/ +/ +/ +I +did +try +a +few +things +to +avoid the -automaton +code +duplication +here +but +nothing +/ +/ +/ +optimized +as +well +as +this +approach . -let -span -= -Span -: -: -from ( -at -. -. -input +In +microbenchmarks +there +was +/ +/ +/ +about +a +25 +% +difference . -end -( ) +# +[ +inline +( +never ) -; -match -pre -. -find_in +] +fn +leftmost_find_at_no_state ( -input -. +& +self +prestate +: +& +mut +PrefilterState haystack -( +: +& +[ +u8 +] +at +: +usize ) -span +- +> +Option +< +Match +> +{ +if +let +Some +( +pre ) += +self . -into_option +prefilter ( ) { -None -= -> -return -Ok +self +. +leftmost_find_at_no_state_imp ( -None -) +prestate Some ( -i -) -= -> -{ -if -i -> -at -{ -at -= -i -; -continue -; -} -} -} -} -else -{ -/ -/ -When pre -. -is_none -( ) -then -starting -states -should -not -be -/ -/ -treated -as -special -. -That -is -without -a -prefilter -is_special -/ -/ -should -only -return -true -when -the -state -is -a -dead -or -a -match -/ -/ -state -. -/ -/ -/ -/ -It -is -possible -to -execute -a -search -without -a -prefilter -even -/ -/ -when -the -underlying -searcher -has -one -: -an -anchored -search +haystack +at +) +} +else +{ +self . +leftmost_find_at_no_state_imp +( +prestate +None +haystack +at +) +} +} / / -But -in +It +' +s +important +for this -case -the -automaton -makes -it -impossible to -move +always +be +inlined +. +Namely +its +only +caller / / -back -to -the -start -state -by -construction +is +leftmost_find_at_no_state and -thus -we +the +inlining should +remove +the +case / / -never -reach -this -branch +analysis +for +prefilter +scanning +when +there +is +no +prefilter +available . -debug_assert -! -( -false -" -unreachable -" -) -; -} -} -at -+ -= -1 -; -} -Ok -( -mat -) -} # [ inline ( -never +always ) ] fn -try_find_overlapping_fwd -< -A -: -Automaton -+ -? -Sized -> +leftmost_find_at_no_state_imp ( -aut -: & -A -input +self +prestate : & -Input +mut +PrefilterState +prefilter +: +Option < -' -_ +& +dyn +Prefilter > -state +haystack : & +[ +u8 +] mut -OverlappingState +at +: +usize ) - > -Result +Option < -( -) -MatchError +Match > { -state +debug_assert +! +( +self . -mat -= -None +match_kind +( +) +. +is_leftmost +( +) +) ; if -input +self . -is_done +anchored ( ) +& +& +at +> +0 { return -Ok -( -( -) -) +None ; } / / -Searching -with -a -pattern -ID -is -always -anchored -so +If +our +prefilter +handles +confirmation +of +matches +100 +% +of +the +/ +/ +time +and +since we -should -only -ever +don +' +t +need +to +track +state +IDs +we +can +avoid / / -use +Aho +- +Corasick +completely +. +if +let +Some +( +pre +) += +prefilter +{ +/ +/ +We +should +never +have a prefilter -when -no -pattern -ID -is -given +during +an +anchored +search . +debug_assert +! +( +! +self +. +anchored +( +) +) +; if -aut +! +pre . -prefilter +reports_false_positives ( ) +{ +return +match +pre . -is_some +next_candidate ( +prestate +haystack +at ) -& -& +{ +Candidate +: +: +None += +> +None +Candidate +: +: +Match +( +m +) += +> +Some +( +m +) +Candidate +: +: +PossibleStartOfMatch +( +_ +) += +> +unreachable ! -input -. -get_anchored ( ) +} +; +} +} +let +mut +state_id += +self . -is_anchored +start_state ( ) -{ +; let -pre +mut +last_match = -aut +self . -prefilter +get_match ( +state_id +0 +at ) +; +while +at +< +haystack . -unwrap +len ( ) -; -try_find_overlapping_fwd_imp -( -aut -input +{ +if +let Some ( pre ) -state -) -} -else += +prefilter { -try_find_overlapping_fwd_imp +if +prestate +. +is_effective ( -aut -input -None -state +at ) -} -} -# -[ -inline +& +& +state_id += += +self +. +start_state ( -always ) -] -fn -try_find_overlapping_fwd_imp -< -A -: -Automaton -+ -? -Sized -> -( -aut +{ +match +prefilter : -& -A -input : -& -Input -< -' -_ -> +next +( +prestate pre +haystack +at +) +{ +Candidate : -Option -< -& -Prefilter +: +None += > +return +None +/ +/ +Since +we +aren +' +t +tracking +a state +ID +we +can +/ +/ +quit +early +once +we +know +we +have +a +match +. +Candidate : -& -mut -OverlappingState +: +Match +( +m ) -- += > -Result -< +return +Some ( +m +) +Candidate +: +: +PossibleStartOfMatch +( +i ) -MatchError -> -{ -let -mut -sid -= -match -state -. -id -{ -None = > { -let -sid +at = -aut -. -start_state -( -input -. -get_anchored -( -) -) -? +i ; +} +} +} +} / / -Handle -the -case -where -the -start -state -is -a -match -state -. -That +CORRECTNESS +: +next_state is +correct +for +all +possible +u8 +values / / +so the -empty -string -is -in -our -automaton -. -We -report -every -match +only +thing we -/ -/ -can -here -before -moving -on -and -updating -' -state -. -at -' -and -' -state -. -id ' +re +concerned +about +is +the +validity +of / / -to -find -more -matches -in -other -parts -of -the -haystack -. -if -aut +state_id . -is_match -( -sid -) -{ -let -i -= -state -. -next_match_index -. -unwrap_or -( -0 -) -; -let -len -= -aut -. -match_len -( -sid -) -; -if -i -< -len -{ -state -. -next_match_index -= -Some +state_id +either +comes +from +the +caller ( -i -+ -1 +in +which +/ +/ +case +we +assume +it +is +correct ) -; -state +or +it +comes +from +the +return +/ +/ +value +of +next_state +which +is +guaranteed +to +be +correct . -mat +state_id = -Some -( -get_match -( -aut -sid -i -input +self . -start -( -) -) -) -; -return -Ok -( +next_state_no_fail ( -) +state_id +haystack +[ +at +] ) ; -} -} -state -. at ++ = -input -. -start -( -) +1 ; -state +if +self . -id -= -Some +is_match_or_dead_state ( -sid +state_id ) -; -state -. -next_match_index +{ +if +state_id = -None -; -state -. -mat = -None -; -sid -} -Some +dead_id ( -sid ) -= -> { / / -If -we -still -have -matches -left +The +only +way to -report -in -this +enter +into +a +dead state -then +is +if +a / / -report -them -until +match +has +been +found +so we -' -ve -exhausted -them +assert +as +much . -Only -after -that -do -we +This / / -advance -to -the -next -offset -in -the -haystack -. +is +different +from +normal +automata +where +you +might +/ +/ +enter +a +dead +state if -let -Some +you +know +a +subsequent +match +/ +/ +will +never +be +found ( -i +regardless +of +whether +a +match +/ +/ +has +already +been +found ) -= -state . -next_match_index -{ -let -len -= -aut +For +Aho +- +Corasick +it +is +/ +/ +built +so +that +we +can +match +at +any +position +so +the +/ +/ +possibility +of +a +match +always +exists . -match_len +/ +/ +/ +/ ( -sid +Unless +we +have +an +anchored +automaton +in +which +/ +/ +case +dead +states +are +used +to +stop +a +search +. ) -; -if -i -< -len -{ -state +debug_assert +! +( +last_match . -next_match_index -= -Some +is_some ( -i -+ -1 ) -; -state +| +| +self . -mat -= -Some -( -get_match +anchored ( -aut -sid -i -state -. -at -+ -1 ) +" +dead +state +should +only +be +seen +after +match +" ) ; return -Ok -( +last_match +; +} +last_match += +self +. +get_match ( -) +state_id +0 +at ) ; } +} +last_match +} / / -Once -we -' -ve -reported -all -matches -at -a -given -position -we -need +/ +Execute +an +overlapping +search +. / / -to -advance +/ +/ +/ +/ +When +executing +an +overlapping +match the -search +previous +state +ID +in +addition +/ +/ +/ to the -next -position -. -state +previous +match +index +should +be +given . +If +there +are +more +matches +/ +/ +/ at -+ -= -1 -; -state -. -next_match_index -= -None -; -state -. -mat -= -None -; -} -sid -} -} -; -while +the +given state +then +the +match +is +reported +and +the +given +index +is +/ +/ +/ +incremented . -at -< -input -. -end +# +[ +inline ( +always ) -{ -sid -= -aut -. -next_state -( -input -. -get_anchored +] +fn +overlapping_find_at ( -) -sid -input -. +& +self +prestate +: +& +mut +PrefilterState haystack -( -) +: +& [ -state -. -at +u8 ] +at +: +usize +state_id +: +& +mut +Self +: +: +ID +match_index +: +& +mut +usize ) -; +- +> +Option +< +Match +> +{ if -aut +self . -is_special +anchored ( -sid ) -{ -state -. -id +& +& +at +> +0 +& +& +* +state_id = -Some -( -sid -) -; -if -aut += +self . -is_dead +start_state ( -sid ) { return -Ok -( -( -) -) +None ; } -else -if -aut -. -is_match -( -sid -) -{ -state -. -next_match_index -= -Some -( -1 -) -; -state -. -mat +let +match_count = -Some -( -get_match -( -aut -sid -0 -state +self . -at -+ -1 -) -) -; -return -Ok -( +match_count ( -) -) -; -} -else -if -let -Some -( -pre -) -= -pre -{ -/ -/ -If -we -' -re -here -we -know -it -' -s -a -special -state -that -is -not -a +* +state_id +) +; +if +* +match_index +< +match_count +{ / / -dead -or +This +is +guaranteed +to +return a match -state -AND -that -a -prefilter -is -active -. -Thus +since / / -it -must -be -a -start -state +match_index +< +match_count . -debug_assert -! -( -aut +let +result += +self . -is_start +get_match ( -sid -) +* +state_id +* +match_index +at ) ; -let -span -= -Span -: -: -from +debug_assert +! ( -state -. -at -. -. -input +result . -end +is_some ( ) +" +must +be +a +match +" ) ; +* +match_index ++ += +1 +; +return +result +; +} +* +match_index += +0 +; match -pre +self . -find_in +standard_find_at ( -input -. +prestate haystack -( -) -span -) -. -into_option -( +at +state_id ) { None = > -return -Ok -( -( -) -) +None Some ( -i +m ) = > { -if -i -> -state -. -at -{ -state -. -at +* +match_index = -i -; -continue +1 ; +Some +( +m +) } } } -} -else -{ -/ -/ -When -pre -. -is_none -( -) -then -starting -states -should -not -be / / -treated -as -special -. -That -is -without -a -prefilter -is_special -/ / -should -only -return -true -when +Return the -state -is -a -dead -or -a +earliest match -/ -/ -state +found . +This +returns +as +soon +as +we +know +that / / / -/ -. -. -. -except -for -one -special -case -: -in -stream -searching we -/ -/ -currently -call -overlapping -search -with +have a -' -None -' -prefilter +match +. +As +such +this +does +not +necessarily +correspond +to +the / / -regardless -of -whether -one -exists -or -not -because -stream / +leftmost +starting +match +but +rather +the +leftmost +position +at +which +a / -searching -can -' -t -currently -deal -with -prefilters -correctly -in / / -all -cases -. -} -} -state -. -at -+ -= -1 -; -} -state +match +ends . -id -= -Some -( -sid -) -; -Ok -( -( -) -) -} # [ inline @@ -14076,558 +4328,381 @@ always ) ] fn -get_match -< -A -: -Automaton -+ -? -Sized -> +earliest_find_at ( -aut -: & -A -sid +self +prestate : -StateID -index +& +mut +PrefilterState +haystack : -usize +& +[ +u8 +] at : usize +state_id +: +& +mut +Self +: +: +ID ) - > +Option +< Match +> { -let -pid +if +* +state_id += = -aut +self . -match_pattern +start_state ( -sid -index ) -; -let -len -= -aut +{ +if +self . -pattern_len +anchored ( -pid ) +& +& +at +> +0 +{ +return +None ; -Match -: -: -new +} +if +let +Some ( -pid +m +) += +self +. +get_match ( +* +state_id +0 at -- -len ) +{ +return +Some +( +m +) +; +} +} +self . -. +standard_find_at +( +prestate +haystack at +state_id ) } / / / -Write -a -prefix -" -state -" -indicator +A +convenience +function for -fmt -: -: -Debug -impls -. -It -always -writes -/ -/ -/ -exactly -two -printable -bytes -to +finding the -given -formatter -. -/ -/ -/ -/ -/ -/ -Specifically -this -tries +next +match +according to -succinctly -distinguish the -different -types -of / / / -states -: -dead -states -start -states -and match -states +semantics +of +this +automaton . -It -even -accounts -for +For +standard +match +semantics +this / / / +finds the -possible -overlappings -of -different -state -types +earliest +match . -( -The -only -possible -/ -/ -/ -overlapping -is -that -of +Otherwise +the +leftmost match -and -start -states +is +found . -) -pub +# +[ +inline ( -crate +always ) +] fn -fmt_state_indicator -< -A -: -Automaton -> +find_at ( -f +& +self +prestate : & mut -core -: +PrefilterState +haystack : -fmt +& +[ +u8 +] +at : +usize +state_id : -Formatter -< -' -_ -> -aut +& +mut +Self : -A -id : -StateID +ID ) - > -core -: -: -fmt -: -: -Result -{ -if -aut -. -is_dead -( -id -) -{ -write -! -( -f -" -D -" -) -? -; -} -else -if -aut -. -is_match -( -id -) +Option +< +Match +> { -if -aut +match +* +self . -is_start +match_kind ( -id ) { -write -! -( -f -" -* +MatchKind +: +: +Standard += > -" -) -? -; -} -else { -write -! -( -f -" -* -" -) -? -; -} -} -else -if -aut +self . -is_start +earliest_find_at ( -id +prestate +haystack +at +state_id ) +} +MatchKind +: +: +LeftmostFirst +| +MatchKind +: +: +LeftmostLongest += +> { -write -! +self +. +leftmost_find_at ( -f -" -> -" +prestate +haystack +at +state_id ) -? -; } -else -{ -write +MatchKind +: +: +__Nonexhaustive += +> +unreachable ! ( -f -" -" ) -? -; } -Ok -( -( -) -) } / / / -Return -an -iterator -of -transitions -in -a -sparse -format -given -an -iterator -/ -/ -/ -of -all -explicitly -defined -transitions +Like +find_at +but +does +not +track +state +identifiers . -The -iterator -yields -ranges -of +This +permits +some / / / -transitions -such +optimizations +when +a +prefilter that -any -adjacent -transitions -mapped -to -the -same +confirms +its +own +matches +is / / / -state -are -combined -into -a -single -range +present . -pub +# +[ +inline ( -crate +always ) +] fn -sparse_transitions -< -' -a -> +find_at_no_state ( +& +self +prestate +: +& mut -it +PrefilterState +haystack : -impl -Iterator -< -Item -= -( +& +[ u8 -StateID -) -> -+ -' -a +] +at +: +usize ) - > -impl -Iterator -< -Item -= -( -u8 -u8 -StateID -) -> -+ -' -a -{ -let -mut -cur -: Option < -( -u8 -u8 -StateID -) +Match > -= -None -; -core -: -: -iter -: -: -from_fn -( -move -| -| { -while -let -Some -( -( -class -next -) -) -= -it +match +* +self . -next -( -) -{ -let +match_kind ( -prev_start -prev_end -prev_next ) -= -match -cur { -Some -( -x -) -= -> -x -None +MatchKind +: +: +Standard = > { -cur +let +mut +state = -Some -( +self +. +start_state ( -class -class -next -) ) ; -continue -; -} -} -; -if -prev_next -= -= -next -{ -cur -= -Some -( +self +. +earliest_find_at ( -prev_start -class -prev_next -) +prestate +haystack +at +& +mut +state ) -; } -else -{ -cur +MatchKind +: +: +LeftmostFirst +| +MatchKind +: +: +LeftmostLongest = -Some -( -( -class -class -next -) -) -; -return -Some -( +> +{ +self +. +leftmost_find_at_no_state ( -prev_start -prev_end -prev_next -) +prestate +haystack +at ) -; -} } -if -let -Some -( -( -start -end -next -) -) +MatchKind +: +: +__Nonexhaustive = -cur -. -take -( -) -{ -return -Some -( +> +unreachable +! ( -start -end -next ) -) -; } -None } -) } diff --git a/third_party/rust/aho-corasick/src/util/buffer.rs b/third_party/rust/aho-corasick/src/buffer.rs similarity index 89% rename from third_party/rust/aho-corasick/src/util/buffer.rs rename to third_party/rust/aho-corasick/src/buffer.rs index 78be1a87c0810..521f4a12f3567 100644 --- a/third_party/rust/aho-corasick/src/util/buffer.rs +++ b/third_party/rust/aho-corasick/src/buffer.rs @@ -1,14 +1,20 @@ use -alloc +std : : -{ -vec -vec +cmp +; +use +std : : -Vec -} +io +; +use +std +: +: +ptr ; / / @@ -30,7 +36,7 @@ DEFAULT_BUFFER_CAPACITY : usize = -64 +8 * ( 1 @@ -41,7 +47,7 @@ usize ; / / -64 +8 KB / / @@ -353,125 +359,6 @@ and the StreamChunkIter . -/ -/ -/ -/ -/ -/ -Note -also -that -this -buffer -is -not -actually -required -to -just -report -matches -. -/ -/ -/ -Because -a -Match -is -just -some -offsets -. -But -it -* -is -* -required -for -supporting -/ -/ -/ -things -like -try_stream_replace_all -because -that -needs -some -mechanism -for -/ -/ -/ -knowing -which -bytes -in -the -stream -correspond -to -a -match -and -which -don -' -t -. -So -/ -/ -/ -when -a -match -occurs -across -two -read -calls -* -something -* -needs -to -retain -/ -/ -/ -the -bytes -from -the -previous -read -call -because -you -don -' -t -know -before -the -/ -/ -/ -second -read -call -whether -a -match -exists -or -not -. # [ derive @@ -480,9 +367,6 @@ Debug ) ] pub -( -crate -) struct Buffer { @@ -597,9 +481,6 @@ match length . pub -( -crate -) fn new ( @@ -614,9 +495,6 @@ Buffer let min = -core -: -: cmp : : @@ -769,9 +647,6 @@ min let capacity = -core -: -: cmp : : @@ -815,9 +690,6 @@ buffer inline ] pub -( -crate -) fn buffer ( @@ -888,9 +760,6 @@ amount inline ] pub -( -crate -) fn min_buffer_len ( @@ -909,6 +778,39 @@ min / / Return +the +total +length +of +the +contents +in +the +buffer +. +# +[ +inline +] +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +end +} +/ +/ +/ +Return all free capacity @@ -1003,17 +905,11 @@ minimum amount . pub -( -crate -) fn fill < R : -std -: -: io : : @@ -1030,9 +926,6 @@ R ) - > -std -: -: io : : @@ -1091,10 +984,6 @@ readlen if self . -buffer -( -) -. len ( ) @@ -1186,9 +1075,6 @@ been searched . pub -( -crate -) fn roll ( @@ -1226,10 +1112,8 @@ amount ) ; let -roll_end +roll_len = -roll_start -+ self . min @@ -1237,7 +1121,9 @@ min assert ! ( -roll_end +roll_start ++ +roll_len < = self @@ -1245,26 +1131,104 @@ self end ) ; -self +unsafe +{ +/ +/ +SAFETY +: +A +buffer +contains +Copy +data +so +there +' +s +no +problem +/ +/ +moving +it +around . -buf +Safety +also +depends +on +our +indices +being +in +/ +/ +bounds +which +they +always +should +be +given +the +assert +above . +/ +/ +/ +/ +TODO +: +Switch +to +[ +T +] +: +: copy_within +once +our +MSRV +is +high +enough +. +ptr +: +: +copy ( +self +. +buf +[ roll_start . . -roll_end -0 +] +. +as_ptr +( +) +self +. +buf +. +as_mut_ptr +( +) +roll_len ) ; +} self . end = -self -. -min +roll_len ; } } diff --git a/third_party/rust/aho-corasick/src/util/byte_frequencies.rs b/third_party/rust/aho-corasick/src/byte_frequencies.rs similarity index 100% rename from third_party/rust/aho-corasick/src/util/byte_frequencies.rs rename to third_party/rust/aho-corasick/src/byte_frequencies.rs diff --git a/third_party/rust/aho-corasick/src/util/alphabet.rs b/third_party/rust/aho-corasick/src/classes.rs similarity index 50% rename from third_party/rust/aho-corasick/src/util/alphabet.rs rename to third_party/rust/aho-corasick/src/classes.rs index d6adca91a846d..b547cde2542f7 100644 --- a/third_party/rust/aho-corasick/src/util/alphabet.rs +++ b/third_party/rust/aho-corasick/src/classes.rs @@ -1,14 +1,8 @@ use -crate +std : : -util -: -: -int -: -: -Usize +fmt ; / / @@ -31,9 +25,8 @@ This is used in -finite -state -machines +an +FSM to reduce the @@ -41,13 +34,13 @@ size of the transition -/ -/ -/ table . This can +/ +/ +/ have a particularly @@ -59,35 +52,17 @@ on the total size -/ -/ -/ of an FSM but -also -on -FSM -build -times -because -it -reduces -the -number -of / / / -transitions -that -need -to -be -visited -/ -set +also +on +compile +times . # [ @@ -98,9 +73,6 @@ Copy ) ] pub -( -crate -) struct ByteClasses ( @@ -138,9 +110,6 @@ same class . pub -( -crate -) fn empty ( @@ -182,9 +151,6 @@ equivalence class . pub -( -crate -) fn singletons ( @@ -205,20 +171,23 @@ empty ) ; for -b +i in 0 . . -= -255 +256 { classes . set ( -b -b +i +as +u8 +i +as +u8 ) ; } @@ -241,9 +210,6 @@ byte inline ] pub -( -crate -) fn set ( @@ -262,13 +228,9 @@ self . 0 [ -usize -: -: -from -( byte -) +as +usize ] = class @@ -291,9 +253,6 @@ byte inline ] pub -( -crate -) fn get ( @@ -307,17 +266,38 @@ u8 > u8 { +/ +/ +SAFETY +: +This +is +safe +because +all +dense +transitions +have +/ +/ +exactly +256 +elements +so +all +u8 +values +are +valid +indices +. self . 0 [ -usize -: -: -from -( byte -) +as +usize ] } / @@ -359,9 +339,6 @@ classes inline ] pub -( -crate -) fn alphabet_len ( @@ -372,38 +349,14 @@ self > usize { -/ -/ -Add -one -since -the -number -of -equivalence -classes -is -one -bigger -than -/ -/ -the -last -one -. -usize -: -: -from -( self . 0 [ 255 ] -) +as +usize + 1 } @@ -411,378 +364,222 @@ self / / Returns -the -stride -as -a -base -- -2 -exponent -required -for -these +true +if +and +only +if +every +byte +in +this +class +maps +to +its +own / / / equivalence -classes -. -/ -/ -/ -/ -/ -/ -The -stride -is -always -the -smallest -power -of -2 -that -is -greater -than -or -/ -/ -/ -equal -to -the -alphabet -length +class . -This -is -done -so -that -converting -between +Equivalently +there +are +256 +equivalence +classes / / / -state -IDs and -indices -can -be -done -with -shifts -alone -which -is -much -/ -/ -/ -faster -than -integer -division -. -The -" -stride2 -" -is -the -exponent -. -i -. -e -. -/ -/ -/ -2 -^ -stride2 -= -stride +each +class +contains +exactly +one +byte . +# +[ +inline +] pub -( -crate -) fn -stride2 +is_singleton ( & self ) - > -usize +bool { -let -zeros -= self . alphabet_len ( ) -. -next_power_of_two -( -) -. -trailing_zeros -( -) -; -usize -: -: -try_from -( -zeros -) -. -unwrap -( -) += += +256 } / / / Returns -the -stride -for -these -equivalence -classes -which -corresponds +an +iterator +over +a +sequence +of +representative +bytes +from +each / / / -to -the -smallest -power -of -2 -greater -than -or -equal +equivalence +class +. +Namely +this +yields +exactly +N +items +where +N +is +/ +/ +/ +equivalent to the number of -/ -/ -/ equivalence classes . -pub -( -crate -) -fn -stride -( -& -self -) -- -> -usize -{ -1 -< -< -self -. -stride2 -( -) -} +Each +item +is +an / / / -Returns -true -if -and -only -if -every +arbitrary byte -in -this +drawn +from +each +equivalence class -maps -to -its -own +. / / / -equivalence -class -. -Equivalently -there -are -257 -equivalence -classes / / / -and -each -class -contains -exactly +This +is +useful +when one -byte -( -plus +is +determinizing +an +NFA +and the -special -EOI -class -) -. -# -[ -inline -] -pub -( -crate -) -fn -is_singleton -( -& -self -) -- -> -bool -{ -self -. -alphabet_len -( -) -= -= -256 -} +NFA +' +s +alphabet / / / -Returns -an -iterator -over -all +hasn +' +t +been +converted +to equivalence classes -in -this -set -. -pub -( -crate -) -fn -iter -( -& -self -) -- -> -ByteClassIter -{ -ByteClassIter -{ -it -: -0 -. +yet . -self -. -alphabet_len -( -) -} -} +Picking +an +arbitrary / / / -Returns -an -iterator -of -the -bytes -in -the -given +byte +from +each equivalence class +then +permits +a +full +exploration +of +/ +/ +/ +the +NFA +instead +of +using +every +possible +byte +value . pub -( -crate -) fn -elements +representatives ( & self -class -: -u8 ) - > -ByteClassElements +ByteClassRepresentatives +< +' +_ +> { -ByteClassElements +ByteClassRepresentatives { classes : self -class -bytes +byte : 0 -. -. -= -255 +last_class +: +None } } / / / Returns -an -iterator +all of -byte -ranges +the +bytes in the given @@ -795,81 +592,121 @@ class / / / -That -is -a -sequence +The +second +element +in +the +tuple +indicates +the +number of -contiguous -ranges -are -returned -. -Typically -every +elements +in / / / -class -maps -to -a -single -contiguous -range +the +array . fn -element_ranges +elements ( & self -class +equiv : u8 ) - > -ByteClassElementRanges -{ -ByteClassElementRanges -{ -elements -: -self -. -elements ( -class +[ +u8 +; +256 +] +usize ) -range -: -None -} -} -} -impl -core -: -: -fmt -: -: -Debug -for -ByteClasses { -fn -fmt +let ( -& -self -f -: -& mut -core +array +mut +len +) += +( +[ +0 +; +256 +] +0 +) +; +for +b +in +0 +. +. +256 +{ +if +self +. +get +( +b +as +u8 +) += += +equiv +{ +array +[ +len +] += +b +as +u8 +; +len ++ += +1 +; +} +} +( +array +len +) +} +} +impl +fmt +: : +Debug +for +ByteClasses +{ +fn +fmt +( +& +self +f : +& +mut fmt : : @@ -881,9 +718,6 @@ _ ) - > -core -: -: fmt : : @@ -903,15 +737,11 @@ f " ByteClasses ( -< -one -- -class -- -per -- -byte -> +{ +{ +singletons +} +} ) " ) @@ -930,118 +760,54 @@ ByteClasses ? ; for -( -i -class -) +equiv in -self +0 . -iter -( -) . -enumerate +self +. +alphabet_len ( ) { -if -i -> -0 -{ -write -! +let ( -f -" -" +members +len ) -? -; -} -write -! -( -f -" -{ -: -? -} = -> -[ -" -class -) -? -; -for -( -start -end -) -in self . -element_ranges -( -class -) -{ -if -start -= -= -end -{ -write -! +elements ( -f -" -{ -: -? -} -" -start +equiv +as +u8 ) -? ; -} -else -{ write ! ( f " { -: -? } -- += +> { : ? } " -start -end -) -? -; -} -} -write -! -( -f -" +equiv +& +members +[ +. +. +len ] -" ) ? ; @@ -1063,6 +829,9 @@ f An iterator over +representative +bytes +from each equivalence class @@ -1075,29 +844,41 @@ Debug ) ] pub -( -crate -) struct -ByteClassIter +ByteClassRepresentatives +< +' +a +> { -it -: -core -: +classes : -ops +& +' +a +ByteClasses +byte : +usize +last_class : -Range +Option < -usize +u8 > } impl +< +' +a +> Iterator for -ByteClassIter +ByteClassRepresentatives +< +' +a +> { type Item @@ -1118,143 +899,61 @@ Option u8 > { +while self . -it +byte +< +256 +{ +let +byte += +self . -next +byte +as +u8 +; +let +class += +self +. +classes +. +get ( +byte ) +; +self . -map +byte ++ += +1 +; +if +self +. +last_class +! += +Some ( -| -class -| class +) +{ +self . -as_u8 +last_class += +Some ( -) -) -} -} -/ -/ -/ -An -iterator -over -all -elements -in -a -specific -equivalence class -. -# -[ -derive -( -Debug -) -] -pub -( -crate ) -struct -ByteClassElements -< -' -a -> -{ -classes -: -& -' -a -ByteClasses -class -: -u8 -bytes -: -core -: -: -ops -: -: -RangeInclusive -< -u8 -> -} -impl -< -' -a -> -Iterator -for -ByteClassElements -< -' -a -> -{ -type -Item -= -u8 ; -fn -next -( -& -mut -self -) -- -> -Option -< -u8 -> -{ -while -let -Some -( -byte -) -= -self -. -bytes -. -next -( -) -{ -if -self -. -class -= -= -self -. -classes -. -get -( -byte -) -{ return Some ( @@ -1269,289 +968,109 @@ None / / / -An -iterator -over -all -elements +A +byte +class +builder +keeps +track +of +an +* +approximation +* +of +equivalence +/ +/ +/ +classes +of +bytes +during +NFA +construction +. +That +is +every +byte in an +/ +/ +/ equivalence class -expressed -as +cannot +discriminate +between +a +match +and a +non +- +match +. / / / -sequence -of -contiguous -ranges -. -# +/ +/ +/ +For +example +in +the +literals +abc +and +xyz +the +bytes [ -derive -( -Debug -) +\ +x00 +- ] -pub -( -crate -) -struct -ByteClassElementRanges -< -' -a -> +[ +d +- +w +] +/ +/ +/ +and +[ { -elements -: -ByteClassElements -< -' -a -> -range -: -Option -< -( -u8 -u8 -) -> -} -impl -< -' +- +\ +xFF +] +never +discriminate +between a -> -Iterator -for -ByteClassElementRanges -< -' +match +and a -> -{ -type -Item -= -( -u8 -u8 -) -; -fn -next -( -& -mut -self -) +non - -> -Option -< -( -u8 -u8 -) -> -{ -loop -{ -let -element -= -match -self -. -elements -. -next -( -) -{ -None -= -> -return -self -. -range -. -take -( -) -Some -( -element -) -= -> -element -} -; match -self -. -range -. -take -( -) -{ -None -= -> -{ -self -. -range -= -Some -( -( -element -element -) -) -; -} -Some -( -( -start -end -) -) -= -> -{ -if -usize -: -: -from -( -end -) -+ -1 -! -= -usize -: -: -from -( -element -) -{ -self -. -range -= -Some -( -( -element -element -) -) -; -return -Some -( -( -start -end -) -) -; -} -self -. -range -= -Some -( -( -start -element -) -) -; -} -} -} -} -} -/ -/ -/ -A -partitioning -of -bytes -into -equivalence -classes -. -/ -/ -/ -/ -/ -/ -A -byte -class -set -keeps -track -of -an -* -approximation -* -of -equivalence -classes +precisely / / / -of -bytes -during -NFA -construction -. -That -is -every -byte +because +they +never +occur in -an -equivalence -/ -/ -/ -class -cannot -discriminate -between -a -match -and -a -non -- -match +the +literals +anywhere . / / @@ -1560,188 +1079,252 @@ match / / Note +though that this -may +does not +necessarily compute the minimal set of -equivalence -classes -. / / / -Basically -any -byte +equivalence +classes +. +For +example in -a -pattern -given -to the -noncontiguous -NFA -builder +literals +above +the +byte +ranges / / / -will -automatically -be +[ +\ +x00 +- +] +[ +d +- +w +] +and +[ +{ +- +\ +xFF +] +are +all treated as -its -own +distinct equivalence -class -. -All -other / / / -bytes -- -- -- -any -byte -not -in -any -pattern -- -- -- -will +classes +even +though +they +could be treated -as -their -own +a +single +class +. +The +reason +for / / / -equivalence -classes +this +is +implementation +complexity . In -theory -all -bytes -not -in -any -pattern +the +future +we should +endeavor +to / / / -be -part -of +compute +the +minimal +equivalence +classes +since +they +can +have a -single +rather +large +/ +/ +/ +impact +on +the +size +of +the +DFA +. +/ +/ +/ +/ +/ +/ +The +representation +here +is +256 +booleans +all +initially +set +to +false +. +Each +/ +/ +/ +boolean +maps +to +its +corresponding +byte +based +on +position +. +A +true +value +/ +/ +/ +indicates +the +end +of +an equivalence class -but -in -practice -we -only -treat +where +its +corresponding +byte / / / -contiguous -ranges +and +all of +the bytes -as -an +corresponding +to +all +previous +contiguous +false +/ +/ +/ +values +are +in +the +same equivalence class . -So -the -number +/ +/ +/ +/ +/ +/ +This +particular +representation +only +permits +contiguous +ranges of +bytes +to / / / -classes -computed -may be -bigger -than -necessary -. -This -usually -doesn -' -t -make +in +the +same +equivalence +class +which +means +that +we +can +never +discover / / / -much -of -a -difference -and -keeps the -implementation -simple +true +minimal +set +of +equivalence +classes . # [ derive ( -Clone Debug ) ] pub -( -crate -) struct -ByteClassSet +ByteClassBuilder ( -ByteSet -) -; -impl -Default -for -ByteClassSet -{ -fn -default -( -) -- +Vec +< +bool > -ByteClassSet -{ -ByteClassSet -: -: -empty -( ) -} -} +; impl -ByteClassSet +ByteClassBuilder { / / @@ -1749,7 +1332,7 @@ ByteClassSet Create a new -set +builder of byte classes @@ -1760,33 +1343,31 @@ are part of the -same / / / +same equivalence class . pub -( -crate -) fn -empty +new ( ) - > -Self +ByteClassBuilder { -ByteClassSet -( -ByteSet -: -: -empty +ByteClassBuilder ( -) +vec +! +[ +false +; +256 +] ) } / @@ -1821,9 +1402,6 @@ the range . pub -( -crate -) fn set_range ( @@ -1855,1478 +1433,462 @@ start self . 0 -. -add -( +[ start +as +usize - 1 -) -; -} -self -. -0 -. -add -( -end -) -; -} -/ -/ -/ -Convert -this -boolean -set -to -a -map -that -maps -all -byte -values -to -their -/ -/ -/ -corresponding -equivalence -class -. -The -last -mapping -indicates -the -largest -/ -/ -/ -equivalence -class -identifier -( -which -is -never -bigger -than -255 -) -. -pub -( -crate -) -fn -byte_classes -( -& -self -) -- -> -ByteClasses -{ -let -mut -classes +] = -ByteClasses -: -: -empty -( -) +true ; -let -mut -class -= -0u8 -; -let -mut -b -= -0u8 -; -loop -{ -classes -. -set -( -b -class -) -; -if -b -= -= -255 -{ -break -; -} -if -self -. -0 -. -contains -( -b -) -{ -class -= -class -. -checked_add -( -1 -) -. -unwrap -( -) -; -} -b -= -b -. -checked_add -( -1 -) -. -unwrap -( -) -; -} -classes -} -} -/ -/ -/ -A -simple -set -of -bytes -that -is -reasonably -cheap -to -copy -and -allocation -free -. -# -[ -derive -( -Clone -Copy -Debug -Default -Eq -PartialEq -) -] -pub -( -crate -) -struct -ByteSet -{ -bits -: -BitSet -} -/ -/ -/ -The -representation -of -a -byte -set -. -Split -out -so -that -we -can -define -a -/ -/ -/ -convenient -Debug -impl -for -it -while -keeping -" -ByteSet -" -in -the -output -. -# -[ -derive -( -Clone -Copy -Default -Eq -PartialEq -) -] -struct -BitSet -( -[ -u128 -; -2 -] -) -; -impl -ByteSet -{ -/ -/ -/ -Create -an -empty -set -of -bytes -. -pub -( -crate -) -fn -empty -( -) -- -> -ByteSet -{ -ByteSet -{ -bits -: -BitSet -( -[ -0 -; -2 -] -) -} -} -/ -/ -/ -Add -a -byte -to -this -set -. -/ -/ -/ -/ -/ -/ -If -the -given -byte -already -belongs -to -this -set -then -this -is -a -no -- -op -. -pub -( -crate -) -fn -add -( -& -mut -self -byte -: -u8 -) -{ -let -bucket -= -byte -/ -128 -; -let -bit -= -byte -% -128 -; -self -. -bits -. -0 -[ -usize -: -: -from -( -bucket -) -] -| -= -1 -< -< -bit -; -} -/ -/ -/ -Return -true -if -and -only -if -the -given -byte -is -in -this -set -. -pub -( -crate -) -fn -contains -( -& -self -byte -: -u8 -) -- -> -bool -{ -let -bucket -= -byte -/ -128 -; -let -bit -= -byte -% -128 -; -self -. -bits -. -0 -[ -usize -: -: -from -( -bucket -) -] -& -( -1 -< -< -bit -) -> -0 -} -} -impl -core -: -: -fmt -: -: -Debug -for -BitSet -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -fmtd -= -f -. -debug_set -( -) -; -for -b -in -0u8 -. -. -= -255 -{ -if -( -ByteSet -{ -bits -: -* -self -} -) -. -contains -( -b -) -{ -fmtd -. -entry -( -& -b -) -; -} -} -fmtd -. -finish -( -) -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -super -: -: -* -; -# -[ -test -] -fn -byte_classes -( -) -{ -let -mut -set -= -ByteClassSet -: -: -empty -( -) -; -set -. -set_range -( -b -' -a -' -b -' -z -' -) -; -let -classes -= -set -. -byte_classes -( -) -; -assert_eq -! -( -classes -. -get -( -0 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -1 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -2 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -b -' -a -' -- -1 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -b -' -a -' -) -1 -) -; -assert_eq -! -( -classes -. -get -( -b -' -m -' -) -1 -) -; -assert_eq -! -( -classes -. -get -( -b -' -z -' -) -1 -) -; -assert_eq -! -( -classes -. -get -( -b -' -z -' -+ -1 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -254 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -255 -) -2 -) -; -let -mut -set -= -ByteClassSet -: -: -empty -( -) -; -set -. -set_range -( -0 -2 -) -; -set -. -set_range -( -4 -6 -) -; -let -classes -= -set -. -byte_classes -( -) -; -assert_eq -! -( -classes -. -get -( -0 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -1 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -2 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -3 -) -1 -) -; -assert_eq -! -( -classes -. -get -( -4 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -5 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -6 -) -2 -) -; -assert_eq -! -( -classes +} +self . -get -( -7 -) -3 -) +0 +[ +end +as +usize +] += +true ; -assert_eq -! -( +} +/ +/ +/ +Build +byte classes +that +map +all +byte +values +to +their +corresponding +/ +/ +/ +equivalence +class . -get +The +last +mapping +indicates +the +largest +equivalence +/ +/ +/ +class +identifier ( +which +is +never +bigger +than 255 ) -3 -) -; -} -# -[ -test -] +. +pub fn -full_byte_classes +build ( +& +self ) +- +> +ByteClasses { let mut -set +classes = -ByteClassSet +ByteClasses : : empty ( ) ; -for -b -in +let +mut +class += 0u8 -. -. +; +let +mut +i = -255 +0 +; +loop { -set +classes . -set_range +set ( -b -b +i +as +u8 +class +as +u8 ) ; +if +i +> += +255 +{ +break +; } -assert_eq -! -( -set +if +self . -byte_classes +0 +[ +i +] +{ +class += +class +. +checked_add ( +1 ) . -alphabet_len +unwrap ( ) -256 -) ; } +i ++ += +1 +; +} +classes +} +} # [ -test -] -fn -elements_typical +cfg ( +test ) +] +mod +tests { -let -mut -set -= -ByteClassSet +use +super : : -empty -( -) -; -set -. -set_range -( -b -' -b -' -b -' -d -' -) -; -set -. -set_range -( -b -' -g -' -b -' -m -' -) +* ; -set -. -set_range +# +[ +test +] +fn +byte_classes ( -b -' -z -' -b -' -z -' ) -; +{ let -classes -= +mut set -. -byte_classes -( -) -; -/ -/ -class -0 -: -\ -x00 -- -a -/ -/ -class -1 -: -b -- -d -/ -/ -class -2 -: -e -- -f -/ -/ -class -3 -: -g -- -m -/ -/ -class -4 -: -n -- -y -/ -/ -class -5 += +ByteClassBuilder : -z -- -z -/ -/ -class -6 : -\ -x7B -- -\ -xFF -assert_eq -! +new ( -classes +) +; +set . -alphabet_len +set_range ( -) -7 +b +' +a +' +b +' +z +' ) ; let -elements -= classes += +set . -elements +build ( -0 ) +; +assert_eq +! +( +classes . -collect -: -: -< -Vec -< -_ -> -> +get ( +0 +) +0 ) ; assert_eq ! ( -elements +classes . -len +get ( +1 ) -98 +0 ) ; assert_eq ! ( -elements -[ +classes +. +get +( +2 +) 0 -] -b -' -\ -x00 -' ) ; assert_eq ! ( -elements -[ -97 -] +classes +. +get +( b ' a ' +- +1 +) +0 ) ; -let -elements -= +assert_eq +! +( classes . -elements +get ( -1 +b +' +a +' ) -. -collect -: -: -< -Vec -< -_ -> -> -( +1 ) ; assert_eq ! ( -elements -vec -! -[ -b -' -b -' -b -' -c -' +classes +. +get +( b ' -d +m ' -] +) +1 ) ; -let -elements -= +assert_eq +! +( classes . -elements +get ( -2 +b +' +z +' ) -. -collect -: -: -< -Vec -< -_ -> -> -( +1 ) ; assert_eq ! ( -elements -vec -! -[ -b -' -e -' +classes +. +get +( b ' -f +z ' -] ++ +1 +) +2 ) ; -let -elements -= +assert_eq +! +( classes . -elements +get ( -3 +254 ) -. -collect -: -: -< -Vec -< -_ -> -> -( +2 ) ; assert_eq ! ( -elements -vec -! -[ -b -' -g -' -b -' -h -' -b -' -i -' -b -' -j -' -b -' -k -' -b -' -l -' -b -' -m -' -] +classes +. +get +( +255 +) +2 ) ; let -elements +mut +set = -classes +ByteClassBuilder +: +: +new +( +) +; +set . -elements +set_range ( -4 +0 +2 ) +; +set . -collect -: -: -< -Vec -< -_ -> -> +set_range ( +4 +6 ) ; -assert_eq -! -( -elements +let +classes += +set . -len +build ( ) -12 -) ; assert_eq ! ( -elements -[ +classes +. +get +( +0 +) 0 -] -b -' -n -' ) ; assert_eq ! ( -elements -[ -11 -] -b -' -y -' -) -; -let -elements -= classes . -elements +get ( -5 +1 ) -. -collect -: -: -< -Vec -< -_ -> -> -( +0 ) ; assert_eq ! ( -elements -vec -! -[ -b -' -z -' -] -) -; -let -elements -= classes . -elements +get ( -6 +2 ) -. -collect -: -: -< -Vec -< -_ -> -> -( +0 ) ; assert_eq ! ( -elements +classes . -len +get ( +3 ) -133 +1 ) ; assert_eq ! ( -elements -[ -0 -] -b -' -\ -x7B -' +classes +. +get +( +4 +) +2 ) ; assert_eq ! ( -elements -[ -132 -] -b -' -\ -xFF -' -) -; -} -# -[ -test -] -fn -elements_singletons -( -) -{ -let classes -= -ByteClasses -: -: -singletons +. +get ( +5 +) +2 ) ; assert_eq @@ -3334,49 +1896,35 @@ assert_eq ( classes . -alphabet_len +get ( +6 ) -256 +2 ) ; -let -elements -= +assert_eq +! +( classes . -elements +get ( -b -' -a -' +7 ) -. -collect -: -: -< -Vec -< -_ -> -> -( +3 ) ; assert_eq ! ( -elements -vec -! -[ -b -' -a -' -] +classes +. +get +( +255 +) +3 ) ; } @@ -3385,90 +1933,55 @@ a test ] fn -elements_empty +full_byte_classes ( ) { let -classes +mut +set = -ByteClasses +ByteClassBuilder : : -empty +new ( ) ; -assert_eq -! -( -classes +for +i +in +0 . -alphabet_len -( -) -1 -) -; -let -elements -= -classes . -elements -( -0 -) +256u16 +{ +set . -collect -: -: -< -Vec -< -_ -> -> +set_range ( +i +as +u8 +i +as +u8 ) ; +} assert_eq ! ( -elements +set . -len +build ( ) -256 -) -; -assert_eq -! +. +alphabet_len ( -elements -[ -0 -] -b -' -\ -x00 -' ) -; -assert_eq -! -( -elements -[ -255 -] -b -' -\ -xFF -' +256 ) ; } diff --git a/third_party/rust/aho-corasick/src/dfa.rs b/third_party/rust/aho-corasick/src/dfa.rs index f19ad6638c107..e46bc04040e8a 100644 --- a/third_party/rust/aho-corasick/src/dfa.rs +++ b/third_party/rust/aho-corasick/src/dfa.rs @@ -1,2209 +1,1534 @@ -/ -* -! -Provides -direct -access -to -a -DFA -implementation -of -Aho -- -Corasick -. -This -is -a -low -- -level -API -that -generally -only -needs -to -be -used -in -niche -circumstances -. -When -possible -prefer -using -[ -AhoCorasick -] -( -crate +use +std : : -AhoCorasick -) -instead -of -a -DFA -directly -. -Using -an -DFA -directly -is -typically -only -necessary -when -one -needs -access -to -the -[ -Automaton -] -trait -implementation -. -* -/ +mem +: +: +size_of +; use -alloc +crate : : -{ -vec -vec +ahocorasick : : -Vec -} +MatchKind ; use crate : : -{ automaton : : Automaton -nfa +; +use +crate : : -noncontiguous -util +classes : : -{ -alphabet +ByteClasses +; +use +crate : : -ByteClasses error : : -{ -BuildError -MatchError -} -int +Result +; +use +crate +: +: +nfa : : { -Usize -U32 +PatternID +PatternLength +NFA } -prefilter +; +use +crate : : -Prefilter -primitives +prefilter : : { -IteratorIndexExt -PatternID -SmallIndex -StateID +Prefilter +PrefilterObj +PrefilterState } -search +; +use +crate +: +: +state_id : : { -Anchored -MatchKind -StartKind +dead_id +fail_id +premultiply_overflow_error +StateID } -special +; +use +crate : : -Special -} -} +Match ; -/ -/ -/ -A -DFA -implementation -of -Aho -- -Corasick -. -/ -/ -/ -/ -/ -/ -When -possible -prefer -using +# [ -AhoCorasick +derive +( +Clone +Debug +) ] +pub +enum +DFA +< +S +> +{ +Standard ( -crate -: +Standard +< +S +> +) +ByteClass +( +ByteClass +< +S +> +) +Premultiplied +( +Premultiplied +< +S +> +) +PremultipliedByteClass +( +PremultipliedByteClass +< +S +> +) +} +impl +< +S : -AhoCorasick +StateID +> +DFA +< +S +> +{ +fn +repr +( +& +self ) -instead -of -/ -/ -/ -this -type -directly -. -Using -a +- +> +& +Repr +< +S +> +{ +match +* +self +{ DFA -directly -is -typically -only -necessary -when -/ -/ -/ -one -needs -access -to -the -[ -Automaton -] -trait -implementation +: +: +Standard +( +ref +dfa +) += +> +dfa . -/ -/ -/ -/ -/ -/ -This +repr +( +) DFA -can -only -be -built -by -first -constructing -a -[ -noncontiguous : : -NFA -] +ByteClass +( +ref +dfa +) += +> +dfa . -/ -/ -/ -Both -[ +repr +( +) DFA : : -new -] -and -[ -Builder +Premultiplied +( +ref +dfa +) += +> +dfa +. +repr +( +) +DFA : : -build -] -do -this -for -you -automatically -but -/ -/ -/ -[ -Builder -: -: -build_from_noncontiguous -] -permits -doing -it -explicitly +PremultipliedByteClass +( +ref +dfa +) += +> +dfa . -/ -/ -/ -/ -/ -/ -A -DFA -provides -the -best -possible -search -performance +repr ( -in -this -crate ) -via -two -/ -/ -/ -mechanisms -: -/ -/ -/ -/ -/ -/ -* -All -states -use -a -dense -representation -for -their -transitions +} +} +pub +fn +match_kind +( +& +self +) +- +> +& +MatchKind +{ +& +self . -/ -/ -/ -* -All -failure -transitions -are -pre +repr +( +) +. +match_kind +} +pub +fn +heap_bytes +( +& +self +) - -computed -such -that -they -are -never -/ -/ -/ -explicitly -handled -at -search -time +> +usize +{ +self . -/ -/ -/ -/ -/ -/ -These -two -facts -combined -mean -that -every -state -transition -is -performed -/ -/ -/ -using -a -constant -number -of -instructions +repr +( +) . -However -this -comes -at -/ -/ -/ -great -cost +heap_bytes +} +pub +fn +max_pattern_len +( +& +self +) +- +> +usize +{ +self . -The -memory -usage -of -a -DFA -can -be -quite -exorbitant +repr +( +) . -/ -/ -/ -It -is -potentially -multiple -orders -of -magnitude -greater -than -a -/ -/ -/ +max_pattern_len +} +pub +fn +pattern_count +( +& +self +) +- +> +usize +{ +self +. +repr +( +) +. +pattern_count +} +pub +fn +prefilter +( +& +self +) +- +> +Option +< +& +dyn +Prefilter +> +{ +self +. +repr +( +) +. +prefilter +. +as_ref +( +) +. +map +( +| +p +| +p +. +as_ref +( +) +) +} +pub +fn +start_state +( +& +self +) +- +> +S +{ +self +. +repr +( +) +. +start_id +} +# [ -contiguous -: -: -NFA +inline +( +always +) ] +pub +fn +overlapping_find_at ( -crate -: +& +self +prestate : -nfa +& +mut +PrefilterState +haystack : +& +[ +u8 +] +at : -contiguous +usize +state_id : +& +mut +S +match_index : -NFA +& +mut +usize ) -for -example -. -In -exchange -/ -/ -/ -a +- +> +Option +< +Match +> +{ +match +* +self +{ DFA -will -typically -have -better -search -speed -than -a -contiguous : : -NFA -but -/ -/ -/ -not -by -orders -of -magnitude -. -/ -/ -/ -/ -/ -/ -Unless -you -have -a -small -number -of -patterns -or -memory -usage -is -not -a -concern -/ -/ -/ -and -search -performance -is -critical -a -DFA -is -usually -not -the -best -choice -. -/ -/ -/ -/ -/ -/ -Moreover -unlike -the -NFAs -in -this -crate -it -is -costly -for -a -DFA -to -/ -/ -/ -support -for -anchored -and -unanchored -search -configurations +Standard +( +ref +dfa +) += +> +dfa . -Namely -/ -/ -/ -since -failure -transitions -are -pre -- -computed -supporting -both -anchored -/ -/ -/ -and -unanchored -searches -requires -a -duplication -of -the -transition -table -/ -/ -/ -making -the -memory -usage -of -such -a +overlapping_find_at +( +prestate +haystack +at +state_id +match_index +) DFA -ever -bigger -. +: +: +ByteClass ( -The -NFAs -in -this -crate -/ -/ -/ -unconditionally -support -both -anchored -and -unanchored -searches -because -there -/ -/ -/ -is -essentially -no -added -cost -for -doing -so +ref +dfa +) += +> +dfa . +overlapping_find_at +( +prestate +haystack +at +state_id +match_index ) -It -is -for -this -reason -that -/ -/ -/ -a DFA -' -s -support -for -anchored -and -unanchored -searches -can -be -configured -/ -/ -/ -via -[ -Builder : : -start_kind -] +Premultiplied +( +ref +dfa +) += +> +dfa . -By -default -a +overlapping_find_at +( +prestate +haystack +at +state_id +match_index +) DFA -only -supports -unanchored -/ -/ -/ -searches +: +: +PremultipliedByteClass +( +ref +dfa +) += +> +dfa . -/ -/ -/ -/ -/ -/ +overlapping_find_at +( +prestate +haystack +at +state_id +match_index +) +} +} # -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -an -DFA -directly -and -use -it -to -execute -/ -/ -/ [ -Automaton +inline +( +always +) +] +pub +fn +earliest_find_at +( +& +self +prestate : +& +mut +PrefilterState +haystack : -try_find +& +[ +u8 ] +at : -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: +usize +state_id : +& +mut +S +) +- +> +Option +< +Match +> { -/ -/ -/ -automaton +match +* +self +{ +DFA : : -Automaton -/ -/ -/ +Standard +( +ref dfa -: -: -DFA -/ -/ -/ -Input -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -patterns +) = -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let +> +{ +dfa +. +earliest_find_at +( +prestate haystack -= -" -abcd -" -; -/ -/ -/ -/ -/ -/ -let -nfa -= +at +state_id +) +} DFA : : -new +ByteClass ( -patterns +ref +dfa ) += +> +{ +dfa . -unwrap +earliest_find_at ( +prestate +haystack +at +state_id ) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match +} +DFA : : -must +Premultiplied ( -0 -1 -. -. -2 -) +ref +dfa ) -/ -/ -/ -nfa += +> +{ +dfa . -try_find +earliest_find_at ( -& -Input +prestate +haystack +at +state_id +) +} +DFA : : -new +PremultipliedByteClass ( -haystack -) +ref +dfa ) -? -/ -/ -/ += +> +{ +dfa +. +earliest_find_at +( +prestate +haystack +at +state_id ) -; -/ -/ -/ +} +} +} # -Ok +[ +inline +( +always +) +] +pub +fn +find_at_no_state +( +& +self +prestate : +& +mut +PrefilterState +haystack : -< -( +& +[ +u8 +] +at +: +usize ) -Box +- +> +Option < -dyn -std +Match +> +{ +match +* +self +{ +DFA : : -error +Standard +( +ref +dfa +) += +> +{ +dfa +. +find_at_no_state +( +prestate +haystack +at +) +} +DFA : : -Error -> -> +ByteClass ( +ref +dfa +) += +> +{ +dfa +. +find_at_no_state ( +prestate +haystack +at ) +} +DFA +: +: +Premultiplied +( +ref +dfa ) -/ -/ -/ -/ -/ -/ -/ -/ -/ -It -is -also -possible -to -implement -your -own -version -of -try_find += +> +{ +dfa . -See -the -/ -/ -/ -[ -Automaton -] -documentation -for -an -example +find_at_no_state +( +prestate +haystack +at +) +} +DFA +: +: +PremultipliedByteClass +( +ref +dfa +) += +> +{ +dfa . +find_at_no_state +( +prestate +haystack +at +) +} +} +} +} # [ derive ( Clone +Debug ) ] pub struct -DFA -{ -/ -/ -/ -The -DFA -transition -table -. -IDs -in -this -table -are -pre -- -multiplied -. -So -/ -/ -/ -instead -of -the -IDs -being -0 -1 -2 -3 -. -. -. -they -are -0 -* -stride -1 -* -stride -/ -/ -/ -2 -* -stride -3 -* -stride -. -. -. -trans -: -Vec +Standard < -StateID +S > -/ -/ -/ -The -matches -for -every -match -state -in -this -DFA -. -This -is -first -indexed -by -/ -/ -/ -state -index ( -so -that -' -s -sid -> +Repr +< +S > -stride2 ) -and -then -by -order -in -which -the -/ -/ -/ -matches -are -meant -to -occur -. -matches -: -Vec +; +impl < -Vec +S +: +StateID +> +Standard < -PatternID +S > +{ +fn +repr +( +& +self +) +- > -/ -/ -/ -The -amount -of -heap -memory -used -in -bytes -by -the -inner -Vecs -of -/ -/ -/ -' -matches -' +& +Repr +< +S +> +{ +& +self . -matches_memory_usage +0 +} +} +impl +< +S : -usize -/ -/ -/ -The -length -of -each -pattern +StateID +> +Automaton +for +Standard +< +S +> +{ +type +ID += +S +; +fn +match_kind +( +& +self +) +- +> +& +MatchKind +{ +& +self . -This -is -used -to -compute -the -start -offset -/ -/ -/ -of -a -match +repr +( +) . -pattern_lens -: -Vec -< -SmallIndex +match_kind +} +fn +anchored +( +& +self +) +- > -/ -/ -/ -A -prefilter -for -accelerating -searches -if -one -exists +bool +{ +self +. +repr +( +) . +anchored +} +fn prefilter -: +( +& +self +) +- +> Option < +& +dyn Prefilter > -/ -/ -/ -The -match -semantics -built -into -this -DFA +{ +self . -match_kind -: -MatchKind -/ -/ -/ -The -total -number -of -states -in -this -DFA +repr +( +) . -state_len -: -usize -/ -/ -/ -The -alphabet -size -or -total -number -of -equivalence -classes -for -this -/ -/ -/ -DFA -. -Note -that -the -actual -number -of -transitions -in -each -state -is -/ -/ -/ -stride -= -2 -^ -stride2 -where -stride -is -the -smallest -power -of -2 -greater -than -/ -/ -/ -or -equal -to -alphabet_len -. -We -do -things -this -way -so -that -we -can -use -/ -/ -/ -bitshifting -to -go -from -a -state -ID -to -an -index -into -' -matches -' +prefilter . -alphabet_len -: -usize -/ -/ -/ -The -exponent -with -a -base -2 -such -that -stride -= -2 -^ -stride2 +as_ref +( +) . -Given -a -state -/ -/ -/ -index -' -i -' -its -state -identifier -is -' -i -< -< -stride2 -' +map +( +| +p +| +p . -Given -a -state -/ -/ -/ -identifier -' -sid -' -its -state -index -is -' -sid -> +as_ref +( +) +) +} +fn +start_state +( +& +self +) +- > -stride2 -' -. -stride2 -: -usize -/ -/ -/ -The -equivalence -classes -for -this -DFA +S +{ +self . -All -transitions -are -defined -on -/ -/ -/ -equivalence -classes -and -not -on -the -256 -distinct -byte -values +repr +( +) . -byte_classes +start_id +} +fn +is_valid +( +& +self +id : -ByteClasses -/ -/ -/ -The -length -of -the -shortest -pattern -in -this -automaton +S +) +- +> +bool +{ +id . -min_pattern_len -: -usize -/ -/ -/ -The -length -of -the -longest -pattern -in -this -automaton +to_usize +( +) +< +self . -max_pattern_len -: -usize -/ -/ -/ -The -information -required -to -deduce -which -states -are -" -special -" -in -this -/ -/ -/ -DFA +repr +( +) . -special -: -Special +state_count } -impl -DFA -{ -/ -/ -/ -Create -a -new -Aho +fn +is_match_state +( +& +self +id +: +S +) - -Corasick -DFA -using -the -default -configuration +> +bool +{ +self . -/ -/ -/ -/ -/ -/ -Use -a -[ -Builder -] -if -you -want -to -change -the -configuration +repr +( +) . -pub +is_match_state +( +id +) +} fn -new -< -I -P -> +is_match_or_dead_state ( -patterns +& +self +id : -I +S ) - > -Result -< -DFA -BuildError -> -where -I +bool +{ +self +. +repr +( +) +. +is_match_or_dead_state +( +id +) +} +fn +get_match +( +& +self +id : -IntoIterator -< -Item -= -P -> -P +S +match_index : -AsRef +usize +end +: +usize +) +- +> +Option < -[ -u8 -] +Match > { -DFA -: -: -builder +self +. +repr ( ) . -build +get_match ( -patterns +id +match_index +end ) } -/ -/ -/ -A -convenience -method -for -returning -a -new -Aho -- -Corasick -DFA -builder -. -/ -/ -/ -/ -/ -/ -This -usually -permits -one -to -just -import -the -DFA -type -. -pub fn -builder +match_count ( +& +self +id +: +S ) - > -Builder +usize { -Builder -: -: -new +self +. +repr ( ) -} -} -impl -DFA -{ -/ -/ -/ -A -sentinel -state -ID -indicating -that -a -search -should -stop -once -it -has -/ -/ -/ -entered -this -state -. -When -a -search -stops -it -returns -a -match -if -one -has -/ -/ -/ -been -found -otherwise -no -match -. -A -DFA -always -has -an -actual -dead -state -/ -/ -/ -at -this -ID -. -/ -/ -/ -/ -/ -/ -N -. -B -. -DFAs -unlike -NFAs -do -not -have -any -notion -of -a -FAIL -state -. -/ -/ -/ -Namely -the -whole -point -of -a -DFA -is -that -the -FAIL -state -is -completely -/ -/ -/ -compiled -away -. -That -is -DFA -construction -involves -pre -- -computing -the -/ -/ -/ -failure -transitions -everywhere -such -that -failure -transitions -are -no -/ -/ -/ -longer -used -at -search -time -. -This -combined -with -its -uniformly -dense -/ -/ -/ -representation -are -the -two -most -important -factors -in -why -it -' -s -faster -/ -/ -/ -than -the -NFAs -in -this -crate . -const -DEAD -: -StateID -= -StateID -: -: -new_unchecked +match_count ( -0 +id ) -; -/ -/ -/ -Adds -the -given -pattern -IDs -as -matches -to -the -given -state -and -also -/ -/ -/ -records -the -added -memory -usage -. +} fn -set_matches +next_state ( & -mut self -sid +current : -StateID -pids +S +input : -impl -Iterator -< -Item -= -PatternID +u8 +) +- > -) +S { let -index +o = -( -sid +current . -as_usize +to_usize ( ) -> -> +* +256 ++ +input +as +usize +; self . -stride2 -) -. -checked_sub +repr ( -2 ) . -unwrap +trans +[ +o +] +} +} +# +[ +derive ( +Clone +Debug ) -; -let -mut -at_least_one -= -false -; -for -pid -in -pids -{ -self -. -matches -[ -index ] -. -push +pub +struct +ByteClass +< +S +> ( -pid +Repr +< +S +> ) ; -self -. -matches_memory_usage -+ -= -PatternID -: +impl +< +S : -SIZE -; -at_least_one -= -true -; -} -assert -! +StateID +> +ByteClass +< +S +> +{ +fn +repr ( -at_least_one -" -match -state -must -have -non -- -empty -pids -" +& +self ) -; +- +> +& +Repr +< +S +> +{ +& +self +. +0 } } -/ -/ -SAFETY -: -' -start_state -' -always -returns -a -valid -state -ID -' -next_state -' -always -/ -/ -returns -a -valid -state -ID -given -a -valid -state -ID -. -We -otherwise -claim -that -/ -/ -all -other -methods -are -correct -as -well -. -unsafe impl +< +S +: +StateID +> Automaton for -DFA +ByteClass +< +S +> { -# -[ -inline -( -always -) -] +type +ID += +S +; fn -start_state +match_kind ( & self -anchored -: -Anchored ) - > -Result -< -StateID -MatchError -> +& +MatchKind { -/ -/ -Either -of -the -start -state -IDs -can -be -DEAD -in -which -case -support -/ -/ -for -that -type -of -search -is -not -provided -by -this -DFA +& +self . -Which -start -/ -/ -state -IDs -are -inactive -depends -on -the -' -StartKind -' -configuration -at -/ -/ -DFA -construction -time +repr +( +) . -match +match_kind +} +fn anchored -{ -Anchored -: -: -No -= +( +& +self +) +- > +bool { -let -start -= self . -special -. -start_unanchored_id -; -if -start -= -= -DFA -: -: -DEAD -{ -Err -( -MatchError -: -: -invalid_input_unanchored +repr ( ) -) +. +anchored } -else -{ -Ok +fn +prefilter ( -start +& +self ) -} -} -Anchored -: -: -Yes -= +- +> +Option +< +& +dyn +Prefilter > { -let -start -= self . -special +repr +( +) +. +prefilter +. +as_ref +( +) . -start_anchored_id -; -if -start -= -= -DFA -: -: -DEAD -{ -Err +map ( -MatchError -: -: -invalid_input_anchored +| +p +| +p +. +as_ref ( ) ) } -else -{ -Ok +fn +start_state ( -start +& +self ) -} -} -} -} -# -[ -inline +- +> +S +{ +self +. +repr ( -always ) -] +. +start_id +} fn -next_state +is_valid ( & self -_anchored -: -Anchored -sid +id : -StateID -byte -: -u8 +S ) - > -StateID +bool { -let -class -= -self -. -byte_classes +id . -get +to_usize ( -byte ) -; +< self . -trans -[ +repr ( -sid +) . -as_u32 +state_count +} +fn +is_match_state ( -) -+ -u32 -: +& +self +id : -from -( -class -) +S ) +- +> +bool +{ +self . -as_usize +repr ( ) -] -} -# -[ -inline +. +is_match_state ( -always +id ) -] +} fn -is_special +is_match_or_dead_state ( & self -sid +id : -StateID +S ) - > bool { -sid -< -= self . -special +repr +( +) . -max_special_id -} -# -[ -inline +is_match_or_dead_state ( -always +id ) -] +} fn -is_dead +get_match ( & self -sid +id : -StateID +S +match_index +: +usize +end +: +usize ) - > -bool +Option +< +Match +> { -sid -= -= -DFA -: -: -DEAD -} -# -[ -inline +self +. +repr ( -always ) -] +. +get_match +( +id +match_index +end +) +} fn -is_match +match_count ( & self -sid +id : -StateID +S ) - > -bool +usize { -! self . -is_dead +repr ( -sid ) -& -& -sid -< -= -self -. -special . -max_match_id -} -# -[ -inline +match_count ( -always +id ) -] +} fn -is_start +next_state ( & self -sid +current : -StateID +S +input +: +u8 ) - > -bool +S { -sid -= +let +alphabet_len = self . -special +repr +( +) . -start_unanchored_id -| -| -sid +byte_classes +. +alphabet_len +( +) +; +let +input = +self +. +repr +( +) +. +byte_classes +. +get +( +input +) +; +let +o = +current +. +to_usize +( +) +* +alphabet_len ++ +input +as +usize +; self . -special +repr +( +) . -start_anchored_id +trans +[ +o +] +} } # [ -inline +derive ( -always +Clone +Debug ) ] +pub +struct +Premultiplied +< +S +> +( +Repr +< +S +> +) +; +impl +< +S +: +StateID +> +Premultiplied +< +S +> +{ +fn +repr +( +& +self +) +- +> +& +Repr +< +S +> +{ +& +self +. +0 +} +} +impl +< +S +: +StateID +> +Automaton +for +Premultiplied +< +S +> +{ +type +ID += +S +; fn match_kind ( @@ -2212,1161 +1537,792 @@ self ) - > +& MatchKind { +& self . -match_kind -} -# -[ -inline +repr ( -always ) -] +. +match_kind +} fn -patterns_len +anchored ( & self ) - > -usize +bool { self . -pattern_lens -. -len +repr ( ) +. +anchored } -# -[ -inline -( -always -) -] fn -pattern_len +prefilter ( & self -pid -: -PatternID ) - > -usize +Option +< +& +dyn +Prefilter +> { self . -pattern_lens -[ -pid -] +repr +( +) +. +prefilter . -as_usize +as_ref ( ) -} -# -[ -inline +. +map +( +| +p +| +p +. +as_ref ( -always ) -] +) +} fn -min_pattern_len +start_state ( & self ) - > -usize +S { self . -min_pattern_len -} -# -[ -inline +repr ( -always ) -] +. +start_id +} fn -max_pattern_len +is_valid ( & self +id +: +S ) - > -usize +bool { +( +id +. +to_usize +( +) +/ +256 +) +< self . -max_pattern_len -} -# -[ -inline +repr ( -always ) -] +. +state_count +} fn -match_len +is_match_state ( & self -sid +id : -StateID +S ) - > -usize +bool { -debug_assert -! -( self . -is_match +repr ( -sid -) ) -; -let -offset -= -( -sid . -as_usize +is_match_state ( +id ) -> -> +} +fn +is_match_or_dead_state +( +& self -. -stride2 +id +: +S ) - -2 -; +> +bool +{ self . -matches -[ -offset -] -. -len +repr ( ) -} -# -[ -inline +. +is_match_or_dead_state ( -always +id ) -] +} fn -match_pattern +get_match ( & self -sid +id : -StateID -index +S +match_index +: +usize +end : usize ) - > -PatternID +Option +< +Match +> { -debug_assert -! -( +if +id +> self . -is_match +repr ( -sid -) ) +. +max_match +{ +return +None ; -let -offset -= +} +self +. +repr ( -sid +) +. +matches +. +get +( +id . -as_usize +to_usize ( ) -> -> -self +/ +256 +) +. +and_then +( +| +m +| +m . -stride2 +get +( +match_index +) ) -- -2 -; -self . -matches -[ -offset -] -[ -index -] -} -# -[ -inline +map ( -always +| +& +( +id +len ) -] +| +Match +{ +pattern +: +id +len +end +} +) +} fn -memory_usage +match_count ( & self +id +: +S ) - > usize { -use -core -: -: -mem -: -: -size_of -; -( -self -. -trans +let +o += +id . -len -( -) -* -size_of -: -: -< -u32 -> +to_usize ( ) -) -+ -( +/ +256 +; self . -matches -. -len -( -) -* -size_of -: -: -< -Vec -< -PatternID -> -> +repr ( ) -) -+ -self -. -matches_memory_usage -+ -( -self . -pattern_lens +matches +[ +o +] . len ( ) -* -size_of +} +fn +next_state +( +& +self +current : +S +input : -< -SmallIndex +u8 +) +- > +S +{ +let +o += +current +. +to_usize ( ) -) + +input +as +usize +; self . -prefilter -. -as_ref +repr ( ) . -map_or -( -0 -| -p -| -p -. -memory_usage -( -) -) +trans +[ +o +] +} } # [ -inline +derive ( -always +Clone +Debug ) ] +pub +struct +PremultipliedByteClass +< +S +> +( +Repr +< +S +> +) +; +impl +< +S +: +StateID +> +PremultipliedByteClass +< +S +> +{ fn -prefilter +repr ( & self ) - > -Option -< & -Prefilter +Repr +< +S > { +& self . -prefilter -. -as_ref -( -) +0 } } impl -core -: -: -fmt -: +< +S : -Debug +StateID +> +Automaton for -DFA +PremultipliedByteClass +< +S +> { +type +ID += +S +; fn -fmt +match_kind ( & self -f -: -& -mut -core -: -: -fmt -: -: -Formatter ) - > -core -: -: -fmt -: -: -Result -{ -use -crate -: -: -{ -automaton -: -: -{ -fmt_state_indicator -sparse_transitions -} -util -: -: -debug -: -: -DebugByte -} -; -writeln -! -( -f -" -dfa -: -: -DFA -( -" -) -? -; -for -index -in -0 -. -. -self -. -state_len +& +MatchKind { -let -sid -= -StateID -: -: -new_unchecked -( -index -< -< +& self . -stride2 -) -; -/ -/ -While -we -do -currently -include -the -FAIL -state -in -the -transition -/ -/ -table +repr ( -to -simplify -construction ) -it -is -never -actually -used -. -It -/ -/ -poses -problems -with -the -code -below -because -it -gets -treated -as -/ -/ -a -match -state -incidentally -when -it -is -of -course -not -. -So -we -/ -/ -special -case -it -. -The -fail -state -is -always -the -first -state -after -/ -/ -the -dead -state . -/ -/ -/ -/ -If -the -construction -is -changed -to -remove -the -fail -state +match_kind +} +fn +anchored ( -it -/ -/ -probably -should -be +& +self ) -then -this -special -case -should -be -updated -. -if -index -= -= -1 -{ -writeln -! -( -f -" -F +- +> +bool { -: -06 -} -: -" -sid +self . -as_usize +repr ( ) -) -? -; -continue -; +. +anchored } -fmt_state_indicator +fn +prefilter ( -f +& self -sid ) -? -; -write -! -( -f -" +- +> +Option +< +& +dyn +Prefilter +> { -: -06 -} -: -" -sid +self . -as_usize +repr ( ) -) -? -; -let -it -= -( -0 -. -. -self . -byte_classes +prefilter . -alphabet_len +as_ref ( ) -) . map ( | -class +p | -{ -( -class +p . -as_u8 +as_ref +( +) +) +} +fn +start_state ( +& +self ) +- +> +S +{ self . -trans -[ -sid -. -as_usize +repr ( ) -+ -class -] -) +. +start_id } +fn +is_valid +( +& +self +id +: +S ) -; -for +- +> +bool +{ ( -i +id +. +to_usize ( -start -end -next -) ) -in -sparse_transitions +/ +self +. +repr ( -it ) . -enumerate +alphabet_len ( ) -{ -if -i -> -0 -{ -write -! +) +< +self +. +repr ( -f -" -" ) -? -; +. +state_count } -if -start -= -= -end -{ -write -! +fn +is_match_state ( -f -" -{ +& +self +id : -? -} -= +S +) +- > +bool { -: -? -} -" -DebugByte +self +. +repr ( -start ) -next . -as_usize +is_match_state ( +id ) -) -? -; } -else -{ -write -! +fn +is_match_or_dead_state ( -f -" -{ +& +self +id : -? -} +S +) - -{ -: -? -} -= > +bool { -: -? -} -" -DebugByte -( -start -) -DebugByte +self +. +repr ( -end ) -next . -as_usize +is_match_or_dead_state ( +id ) -) -? -; -} } -write -! +fn +get_match ( -f -" -\ -n -" -) -? -; -if +& self -. -is_match -( -sid -) -{ -write -! -( -f -" -matches +id : -" -) -? -; -for -i -in -0 -. -. -self -. -match_len -( -sid +S +match_index +: +usize +end +: +usize ) +- +> +Option +< +Match +> { if -i +id > -0 -{ -write -! +self +. +repr ( -f -" -" ) -? +. +max_match +{ +return +None ; } -let -pid -= self . -match_pattern +repr ( -sid -i ) -; -write -! -( -f -" -{ -} -" -pid . -as_usize +matches +. +get ( -) -) -? -; -} -write -! +id +. +to_usize ( -f -" -\ -n -" ) -? -; -} -} -writeln -! -( -f -" -match -kind -: -{ -: -? -} -" +/ self . -match_kind -) -? -; -writeln -! +repr ( -f -" -prefilter -: -{ -: -? -} -" -self -. -prefilter +) . -is_some +alphabet_len ( ) ) -? -; -writeln -! -( -f -" -state -length -: -{ -: -? -} -" -self . -state_len -) -? -; -writeln -! +and_then ( -f -" -pattern -length -: -{ -: -? -} -" -self +| +m +| +m . -patterns_len +get ( +match_index ) ) -? -; -writeln -! +. +map ( -f -" -shortest -pattern -length -: +| +& +( +id +len +) +| +Match { +pattern : -? +id +len +end } -" -self -. -min_pattern_len ) -? -; -writeln -! +} +fn +match_count ( -f -" -longest -pattern -length +& +self +id : +S +) +- +> +usize { -: -? -} -" -self +let +o += +id . -max_pattern_len -) -? -; -writeln -! +to_usize ( -f -" -alphabet -length -: -{ -: -? -} -" +) +/ self . +repr +( +) +. alphabet_len +( ) -? ; -writeln -! -( -f -" -stride -: -{ -: -? -} -" -1 -< -< self . -stride2 -) -? -; -writeln -! +repr ( -f -" -byte -classes -: -{ -: -? -} -" -self +) . -byte_classes +matches +[ +o +] +. +len +( ) -? -; -writeln -! +} +fn +next_state ( -f -" -memory -usage +& +self +current : -{ +S +input : -? -} -" +u8 +) +- +> +S +{ +let +input += self . -memory_usage +repr ( ) +. +byte_classes +. +get +( +input ) -? ; -writeln -! +let +o += +current +. +to_usize ( -f -" ) -" -) -? ++ +input +as +usize ; -Ok -( +self +. +repr ( ) -) -} -} -/ -/ -/ -A -builder -for -configuring -an -Aho -- -Corasick -DFA . -/ -/ -/ -/ -/ -/ -This -builder -has -a -subset -of -the -options -available -to -a -/ -/ -/ +trans [ -AhoCorasickBuilder +o ] -( -crate -: -: -AhoCorasickBuilder -) -. -Of -the -shared -options -/ -/ -/ -their -behavior -is -identical -. +} +} # [ derive @@ -3377,199 +2333,178 @@ Debug ] pub struct -Builder -{ -noncontiguous -: -noncontiguous -: -: -Builder -start_kind -: -StartKind -byte_classes -: -bool -} -impl -Default -for -Builder -{ -fn -default -( -) -- +Repr +< +S > -Builder -{ -Builder { -noncontiguous -: -noncontiguous -: -: -Builder -: -: -new -( -) -start_kind +match_kind : -StartKind +MatchKind +anchored : +bool +premultiplied : -Unanchored -byte_classes +bool +start_id : -true -} -} -} -impl -Builder -{ +S / / / -Create -a -new -builder +The +length +in +bytes +of +the +longest +pattern +in +this +automaton +. +This +/ +/ +/ +information +is +useful for -configuring -an -Aho -- -Corasick -DFA +keeping +correct +buffer +sizes +when +searching +/ +/ +/ +on +streams . -pub -fn -new -( -) -- -> -Builder -{ -Builder -: +max_pattern_len : -default -( -) -} +usize / / / -Build -an -Aho -- -Corasick -DFA -from -the -given -iterator +The +total +number of patterns +added +to +this +automaton +. +This +includes +/ +/ +/ +patterns +that +may +never +match . +pattern_count +: +usize +state_count +: +usize +max_match +: +S / / / +The +number +of +bytes +of +heap +used +by +this +NFA +' +s +transition +table +. +heap_bytes +: +usize / / / A -builder -may -be -reused -to -create -more -DFAs +prefilter +for +quickly +detecting +candidate +matchs +if +pertinent . -pub -fn -build +prefilter +: +Option < -I -P +PrefilterObj > -( -& -self -patterns +byte_classes : -I -) -- -> -Result +ByteClasses +trans +: +Vec < -DFA -BuildError +S > -where -I +matches : -IntoIterator +Vec < -Item -= -P +Vec +< +( +PatternID +PatternLength +) +> > -P +} +impl +< +S : -AsRef +StateID +> +Repr < -[ -u8 -] +S > { -let -nnfa -= -self -. -noncontiguous -. -build -( -patterns -) -? -; -self -. -build_from_noncontiguous -( -& -nnfa -) -} / / / -Build -an -Aho -- -Corasick -DFA -from +Returns the -given -noncontiguous -NFA +total +alphabet +size +for +this +DFA . / / @@ -3577,2513 +2512,2002 @@ NFA / / / -Note -that -when -this -method -is -used -only -the -start_kind -and -/ -/ -/ -byte_classes -settings -on -this -builder +If +byte +classes are -respected -. -The -other -/ -/ -/ -settings -only -apply +enabled +then +this +corresponds to the -initial -construction +number of -the -Aho -- -Corasick / / / -automaton +equivalence +classes . -Since -using -this -method -requires -that -initial -construction -/ -/ -/ -has -already -completed -all -settings -impacting -only -initial -construction -/ -/ -/ +If +they are -no -longer -relevant +disabled +then +this +is +always +256 . -pub fn -build_from_noncontiguous +alphabet_len ( & self -nnfa -: -& -noncontiguous -: -: -NFA ) - > -Result -< -DFA -BuildError -> +usize { -debug -! -( -" -building -DFA -" -) -; -let -byte_classes -= -if self . byte_classes -{ -nnfa . -byte_classes +alphabet_len ( ) +} +/ +/ +/ +Returns +true +only +if +the +given +state +is +a +match +state . -clone +fn +is_match_state ( -) -} -else -{ -ByteClasses -: +& +self +id : -singletons -( +S ) -} -; -let -state_len +- +> +bool +{ +id +< = -match self . -start_kind -{ -StartKind -: -: -Unanchored -| -StartKind -: -: -Anchored -= +max_match +& +& +id > -nnfa -. -states +dead_id ( ) +} +/ +/ +/ +Returns +true +only +if +the +given +state +is +either +a +dead +state +or +a +match +/ +/ +/ +state . -len +fn +is_match_or_dead_state ( -) -StartKind -: +& +self +id : -Both -= +S +) +- > +bool { +id +< += +self +. +max_match +} / / -These -unwraps -are -OK -because -we -know -that +/ +Get the -number +ith +match +for +the +given +state +where +the +end +position of +a / / -NFA -states -is -< -StateID -: -: -LIMIT -which -is -in -turn -less -than -/ / -i32 -: -: -MAX -. -Thus -there -is -always -room -to -multiply -by -2 +match +was +found +at +end . / / -Finally -the -number -of -states -is -always -at -least -4 -in -the / / -NFA -( -DEAD -FAIL -START -- -UNANCHORED -START -- -ANCHORED -) -so -the / / -subtraction -of -4 -is -okay -. +# +Panics / / / / -Note -that -we -subtract -4 -because -the -" -anchored -" -part -of / / +The +caller +must +ensure +that the -DFA -duplicates -the -unanchored -part -( -without -failure +given +state +identifier +is +valid / / -transitions -) -but -reuses -the -DEAD -FAIL -and -START -states -. -nnfa -. -states -( -) -. -len -( -) -. -checked_mul -( -2 -) -. -unwrap -( -) -. -checked_sub -( -4 -) -. -unwrap -( -) -} -} -; -let -trans_len -= -match -state_len -. -checked_shl -( -byte_classes -. -stride2 -( -) -. -as_u32 -( -) -) -{ -Some -( -trans_len -) -= -> -trans_len -None -= -> -{ -return -Err -( -BuildError -: -: -state_id_overflow -( -StateID -: -: -MAX -. -as_u64 -( -) -usize -: -: -MAX -. -as_u64 -( -) -) -) -} -} -; -StateID -: -: -new -( -trans_len -. -checked_sub -( -byte_classes -. -stride -( -) -) -. -unwrap -( -) -) +/ +otherwise +this +may +panic . -map_err -( -| -e -| -{ -BuildError -: -: -state_id_overflow -( -StateID -: -: -MAX +The +match_index +need +not +be +valid . -as_u64 -( -) -e +That +is +/ +/ +/ +if +the +given +state +has +no +matches +then +this +returns +None . -attempted +fn +get_match ( -) -) -} -) -? -; -let -num_match_states -= -match +& self -. -start_kind -{ -StartKind +id : +S +match_index : -Unanchored -| -StartKind -: +usize +end : -Anchored -= +usize +) +- +> +Option +< +Match > { -nnfa -. -special -( -) +if +id +> +self . -max_match_id +max_match +{ +return +None +; +} +self . -as_usize -( -) +matches . -checked_sub +get ( -1 -) +id . -unwrap +to_usize ( ) -} -StartKind -: -: -Both -= -> -nnfa -. -special -( ) . -max_match_id -. -as_usize +and_then ( -) +| +m +| +m . -checked_sub +get ( -1 +match_index ) -. -unwrap -( ) . -checked_mul +map ( -2 -) -. -unwrap +| +& ( +id +len ) -} -; -let -mut -dfa -= -DFA +| +Match { -trans -: -vec -! -[ -DFA -: +pattern : -DEAD -; -trans_len -] +id +len +end +} +) +} +/ +/ +/ +Return +the +total +number +of matches -: -vec -! -[ -vec -! -[ -] -; -num_match_states -] -matches_memory_usage -: -0 -pattern_lens -: -nnfa +for +the +given +state . -pattern_lens_raw -( -) +/ +/ +/ +/ +/ +/ +# +Panics +/ +/ +/ +/ +/ +/ +The +caller +must +ensure +that +the +given +identifier +is +valid +or +else +/ +/ +/ +this +panics . -to_vec +fn +match_count ( -) -prefilter +& +self +id : -nnfa -. -prefilter -( +S ) +- +> +usize +{ +self . -map -( -| -p -| -p +matches +[ +id . -clone +to_usize ( ) +] +. +len +( ) -match_kind -: -nnfa +} +/ +/ +/ +Get +the +next +state +given +from +as +the +current +state +and +byte +as +the +/ +/ +/ +current +input +byte . -match_kind +fn +next_state ( +& +self +from +: +S +byte +: +u8 ) -state_len +- +> +S +{ +let alphabet_len -: -byte_classes += +self . alphabet_len ( ) -stride2 -: -byte_classes +; +let +byte += +self . -stride2 -( -) byte_classes -min_pattern_len -: -nnfa . -min_pattern_len +get ( +byte ) -max_pattern_len -: -nnfa +; +self . -max_pattern_len +trans +[ +from +. +to_usize ( ) +* +alphabet_len ++ +byte +as +usize +] +} / / -The -special +/ +Set +the +byte +transition +for +the +from state -IDs -are -set -later +to +point +to +to . -special +fn +set_next_state +( +& +mut +self +from : -Special +S +byte : +u8 +to : -zero -( +S ) -} -; -match -self -. -start_kind { -StartKind -: -: -Both +let +alphabet_len = -> -{ self . -finish_build_both_starts +alphabet_len ( -nnfa -& -mut -dfa ) ; -} -StartKind -: -: -Unanchored +let +byte = -> -{ self . -finish_build_one_start +byte_classes +. +get ( -Anchored -: -: -No -nnfa -& -mut -dfa +byte ) ; -} -StartKind -: -: -Anchored -= -> -{ self . -finish_build_one_start +trans +[ +from +. +to_usize +( +) +* +alphabet_len ++ +byte +as +usize +] += +to +; +} +/ +/ +/ +Swap +the +given +states +in +place +. +fn +swap_states ( -Anchored -: -: -Yes -nnfa & mut -dfa +self +id1 +: +S +id2 +: +S ) -} -} -debug +{ +assert ! ( +! +self +. +premultiplied " -DFA -built -< +can +' +t +swap states -: -{ -: -? -} -size -: -{ -: -? -} -\ -alphabet -len -: -{ -: -? -} -stride -: -{ -: -? -} -> +in +premultiplied +DFA " -dfa -. -state_len -dfa +) +; +let +o1 += +id1 . -memory_usage +to_usize ( ) -dfa -. -byte_classes +* +self . alphabet_len ( ) -dfa -. -byte_classes +; +let +o2 += +id2 . -stride +to_usize ( ) +* +self +. +alphabet_len +( ) ; -/ -/ -The -vectors -can -grow -~ -twice -as -big -during -construction -because -a -/ -/ -Vec -amortizes -growth +for +b +in +0 . -But -here -let -' -s -shrink -things -back -down -to -/ -/ -what -we -actually -need -since -we -' -re -never -going -to -add -more -to -it . -dfa +self +. +alphabet_len +( +) +{ +self . trans . -shrink_to_fit +swap ( +o1 ++ +b +o2 ++ +b ) ; -dfa +} +self +. +matches +. +swap +( +id1 . -pattern_lens +to_usize +( +) +id2 . -shrink_to_fit +to_usize ( ) +) ; -dfa -. -matches +} +/ +/ +/ +This +routine +shuffles +all +match +states +in +this +DFA +to +the +beginning +/ +/ +/ +of +the +DFA +such +that +every +non +- +match +state +appears +after +every +match +/ +/ +/ +state . -shrink_to_fit ( -) -; +With +one +exception +: +the +special +fail +and +dead +states +remain +as / / -TODO -: -We -might -also -want -to -shrink -each -Vec -inside -of -dfa +/ +the +first +two +states . -matches +) / / -or -even -better -convert -it -to -one -contiguous -allocation -. -But -I -think / / -I -went -with -nested -allocs -for -good -reason -( -can -' -t -remember -) -so -this / / -may -be -tricky -to -do -. -I -decided -not +The +purpose +of +doing +this +shuffling +is to -shrink -them -here -because -it +avoid +an +extra +conditional / / -might -require +/ +in +the +search +loop +and +in +particular +detecting +whether a -fair -bit -of -work +state +is +a +/ +/ +/ +match +or +not +does +not +need to -do +access +any +memory . -It -' -s -unclear -whether -it -' -s / / -worth -it -. -Ok -( -dfa -) -} / / / -Finishes -building -a -DFA -for -either -unanchored -or -anchored -searches +/ +This +updates +self +. +max_match +to +point +to +the +last +matching +state +as / / / -but -NOT -both +well +as +self +. +start +if +the +starting +state +was +moved . fn -finish_build_one_start +shuffle_match_states ( & -self -anchored -: -Anchored -nnfa -: -& -noncontiguous -: -: -NFA -dfa -: -& mut -DFA +self ) { -/ -/ -This -function -always -succeeds -because -we -check -above -that -all -of -the -/ -/ +assert +! +( +! +self +. +premultiplied +" +cannot +shuffle +match states -in -the -NFA -can -be -mapped -to +of +premultiplied DFA -state -IDs +" +) +; +if +self . -let -stride2 +state_count +< = -dfa -. -stride2 +1 +{ +return ; +} let -old2new +mut +first_non_match = -| -oldsid -: -StateID -| -{ -StateID -: -: -new_unchecked -( -oldsid +self . -as_usize +start_id +. +to_usize ( ) -< -< -stride2 -) -} ; -for -( -oldsid -state -) -in -nnfa +while +first_non_match +< +self . -states -( -) +state_count +& +& +self . -iter -( -) +matches +[ +first_non_match +] . -with_state_ids +len ( ) +> +0 { +first_non_match ++ += +1 +; +} let -newsid +mut +swaps +: +Vec +< +S +> = -old2new +vec +! +[ +fail_id ( -oldsid ) ; -if -state -. -is_match -( -) -{ -dfa -. -set_matches -( -newsid -nnfa +self . -iter_matches -( -oldsid -) -) +state_count +] ; -} -sparse_iter -( -nnfa -oldsid -& -dfa -. -byte_classes -| -byte -class -mut -oldnextsid -| -{ -if -oldnextsid -= -= -noncontiguous -: -: -NFA -: -: -FAIL +let +mut +cur += +self +. +state_count +- +1 +; +while +cur +> +first_non_match { if -anchored +self +. +matches +[ +cur +] . -is_anchored +len ( ) +> +0 { -oldnextsid -= -noncontiguous -: -: -NFA +self +. +swap_states +( +S : : -DEAD -; -} -else -{ -oldnextsid -= -nnfa -. -next_state +from_usize ( -Anchored +cur +) +S : : -No -state -. -fail +from_usize ( +first_non_match ) -byte ) ; -} -} -dfa -. -trans +swaps [ -newsid -. -as_usize -( -) -+ -usize +cur +] += +S : : -from +from_usize ( -class +first_non_match ) +; +swaps +[ +first_non_match ] = -old2new +S +: +: +from_usize ( -oldnextsid +cur ) ; -} -) +first_non_match ++ += +1 ; -} -/ -/ -Now -that -we -' -ve -remapped -all -the -IDs -in -our -states -all -that -' -s -left -/ -/ -is -remapping -the -special -state -IDs +while +first_non_match +< +cur +& +& +self . -let -old -= -nnfa +matches +[ +first_non_match +] . -special +len ( ) -; -let -new +> +0 +{ +first_non_match ++ = -& -mut -dfa -. -special +1 ; -new -. -max_special_id +} +} +cur +- = -old2new +1 +; +} +for +id +in ( -old +0 . -max_special_id -) -; -new . -max_match_id -= -old2new -( -old +self . -max_match_id +state_count ) -; -if -anchored . -is_anchored +map ( +S +: +: +from_usize ) { -new -. -start_unanchored_id +let +alphabet_len = -DFA -: -: -DEAD -; -new +self . -start_anchored_id -= -old2new +alphabet_len ( -old -. -start_anchored_id ) ; -} -else -{ -new -. -start_unanchored_id +let +offset = -old2new -( -old +id . -start_unanchored_id +to_usize +( ) +* +alphabet_len ; -new -. -start_anchored_id -= -DFA -: -: -DEAD -; -} -} -/ -/ -/ -Finishes -building -a -DFA -that -supports -BOTH -unanchored -and -anchored -/ -/ -/ -searches -. -It -works -by -inter -- -leaving -unanchored -states -with -anchored -/ -/ -/ -states +for +next in -the -same -transition -table -. -This -way -we -avoid -needing -to -/ -/ -/ -re -- -shuffle -states -afterward -to -ensure -that -our -states -still -look -like -/ -/ -/ -DEAD -MATCH -. -. -. -START -- -UNANCHORED -START -- -ANCHORED -NON -- -MATCH -. -. -. -/ -/ -/ -/ -/ -/ -Honestly -this -is -pretty -inscrutable +& +mut +self . +trans +[ +offset . . -Simplifications -are -most -/ -/ -/ -welcome +offset ++ +alphabet_len +] +{ +if +swaps +[ +next . -fn -finish_build_both_starts +to_usize +( +) +] +! += +fail_id ( -& -self -nnfa -: -& -noncontiguous -: -: -NFA -dfa -: -& -mut -DFA ) { -let -stride2 +* +next = -dfa +swaps +[ +next . -stride2 -; -let -stride -= -1 -< -< -stride2 +to_usize +( +) +] ; -let -mut -remap_unanchored -= -vec -! +} +} +} +if +swaps [ -DFA -: -: -DEAD -; -nnfa +self . -states +start_id +. +to_usize +( +) +] +! += +fail_id ( ) +{ +self . -len +start_id += +swaps +[ +self +. +start_id +. +to_usize ( ) ] ; -let -mut -remap_anchored +} +self +. +max_match = -vec -! -[ -DFA +S : : -DEAD +from_usize +( +first_non_match +- +1 +) ; -nnfa -. -states +} +fn +premultiply +( +& +mut +self +) +- +> +Result +< ( ) +> +{ +if +self . -len +premultiplied +| +| +self +. +state_count +< += +1 +{ +return +Ok +( ( ) -] +) ; +} let -mut -is_anchored +alpha_len = -vec -! -[ -false -; -dfa +self . -state_len -] -; -let -mut -newsid -= -DFA -: -: -DEAD +alphabet_len +( +) ; -let -next_dfa_id -= -| -sid -: -StateID -| -StateID +premultiply_overflow_error +( +S : : -new_unchecked +from_usize ( -sid +self . -as_usize -( +state_count +- +1 ) -+ -stride +alpha_len ) +? ; for -( -oldsid -state -) +id in -nnfa -. -states ( +2 +. +. +self +. +state_count ) . -iter +map ( +S +: +: +from_usize ) +{ +let +offset += +id . -with_state_ids +to_usize ( ) +* +alpha_len +; +for +next +in +& +mut +self +. +trans +[ +offset +. +. +offset ++ +alpha_len +] { if -oldsid -= +* +next = -noncontiguous -: -: -NFA -: -: -DEAD -| -| -oldsid = +dead_id +( +) +{ +continue +; +} +* +next = -noncontiguous -: -: -NFA +S : : -FAIL -{ -remap_unanchored -[ -oldsid -] -= -newsid +from_usize +( +next +. +to_usize +( +) +* +alpha_len +) ; -remap_anchored -[ -oldsid -] +} +} +self +. +premultiplied = -newsid +true ; -newsid +self +. +start_id = -next_dfa_id +S +: +: +from_usize +( +self +. +start_id +. +to_usize ( -newsid +) +* +alpha_len ) ; -} -else -if -oldsid -= +self +. +max_match = -nnfa +S +: +: +from_usize +( +self . -special +max_match +. +to_usize +( +) +* +alpha_len +) +; +Ok ( +( +) ) +} +/ +/ +/ +Computes +the +total +amount +of +heap +used +by +this +NFA +in +bytes . -start_unanchored_id -| -| -oldsid -= +fn +calculate_size +( +& +mut +self +) +{ +let +mut +size = -nnfa +( +self . -special +trans +. +len +( +) +* +size_of +: +: +< +S +> ( ) +) ++ +( +self . -start_anchored_id -{ -if -oldsid -= -= -nnfa +matches . -special +len ( ) -. -start_unanchored_id -{ -remap_unanchored -[ -oldsid -] -= -newsid -; -remap_anchored -[ -oldsid -] -= -DFA +* +size_of : : -DEAD +< +Vec +< +( +PatternID +PatternLength +) +> +> +( +) +) ; -} -else +for +state_matches +in +& +self +. +matches { -remap_unanchored -[ -oldsid -] +size ++ = -DFA +state_matches +. +len +( +) +* +size_of : : -DEAD -; -remap_anchored -[ -oldsid -] -= -newsid -; -is_anchored -[ -newsid -. -as_usize +< ( +PatternID +PatternLength ) > -> -stride2 -] -= -true +( +) ; } -if -state +size ++ += +self +. +prefilter . -is_match +as_ref ( ) -{ -dfa . -set_matches +map_or +( +0 +| +p +| +p +. +as_ref ( -newsid -nnfa +) . -iter_matches +heap_bytes ( -oldsid ) ) ; -} -sparse_iter -( -nnfa -oldsid -& -dfa +self . -byte_classes -| -_ -class -oldnextsid -| -{ -let -class +heap_bytes = -usize -: -: -from -( -class -) +size ; -if -oldnextsid -= -= -noncontiguous -: -: +} +} +/ +/ +/ +A +builder +for +configuring +the +determinization +of +an NFA -: -: -FAIL -{ -dfa +into +a +DFA . -trans +# [ -newsid -. -as_usize +derive ( +Clone +Debug ) -+ -class ] -= -DFA +pub +struct +Builder +{ +premultiply : +bool +byte_classes : -DEAD -; +bool } -else +impl +Builder { -dfa -. -trans -[ -newsid +/ +/ +/ +Create +a +new +builder +for +a +DFA . -as_usize +pub +fn +new ( ) -+ -class -] -= -oldnextsid -; -} +- +> +Builder +{ +Builder +{ +premultiply +: +true +byte_classes +: +true } -) -; -newsid -= -next_dfa_id -( -newsid -) -; } -else -{ -let -unewsid -= -newsid -; -newsid -= -next_dfa_id -( -newsid -) -; -let -anewsid -= -newsid -; -newsid -= -next_dfa_id +/ +/ +/ +Build +a +DFA +from +the +given +NFA +. +/ +/ +/ +/ +/ +/ +This +returns +an +error +if +the +state +identifiers +exceed +their +/ +/ +/ +representation +size +. +This +can +only +happen +when +state +ids +are +/ +/ +/ +premultiplied ( -newsid +which +is +enabled +by +default ) -; -remap_unanchored -[ -oldsid -] -= -unewsid -; -remap_anchored -[ -oldsid -] -= -anewsid -; -is_anchored -[ -anewsid . -as_usize +pub +fn +build +< +S +: +StateID +> ( +& +self +nfa +: +& +NFA +< +S +> ) +- +> +Result +< +DFA +< +S > > -stride2 -] +{ +let +byte_classes = -true -; if -state +self . -is_match -( -) +byte_classes { -dfa -. -set_matches -( -unewsid -nnfa +nfa . -iter_matches +byte_classes ( -oldsid ) -) -; -dfa -. -set_matches -( -anewsid -nnfa . -iter_matches +clone ( -oldsid ) -) -; } -sparse_iter -( -nnfa -oldsid -& -dfa -. -byte_classes -| -byte -class -oldnextsid -| +else { -let -class -= -usize +ByteClasses : : -from +singletons ( -class ) +} ; -if -oldnextsid -= -= -noncontiguous -: -: -NFA -: -: -FAIL -{ -dfa -. -trans -[ -unewsid -. -as_usize -( -) -+ -class -] +let +alphabet_len = -nnfa -. -next_state -( -Anchored -: -: -No -state +byte_classes . -fail +alphabet_len ( ) -byte -) ; -} -else -{ -dfa -. +let trans += +vec +! [ -unewsid -. -as_usize +fail_id ( ) -+ -class -] -= -oldnextsid ; -dfa -. -trans -[ -anewsid +alphabet_len +* +nfa . -as_usize +state_len ( ) -+ -class ] -= -oldnextsid ; -} -} -) -; -} -} -for -i -in -0 -. -. -dfa -. -state_len -{ let -sid +matches = -i -< -< -stride2 -; -if -is_anchored -[ -i -] -{ -for -next -in -dfa -. -trans +vec +! [ -sid -. -. -] +vec +! [ -. -. -stride ] +; +nfa . -iter_mut +state_len ( ) -{ -* -next -= -remap_anchored -[ -* -next ] ; -} -} -else +let +mut +repr += +Repr { -for -next -in -dfa +match_kind +: +nfa . -trans -[ -sid +match_kind +( +) . +clone +( +) +anchored +: +nfa . -] -[ +anchored +( +) +premultiplied +: +false +start_id +: +nfa . +start_state +( +) +max_pattern_len +: +nfa . -stride -] +max_pattern_len +( +) +pattern_count +: +nfa . -iter_mut +pattern_count ( ) -{ -* -next -= -remap_unanchored -[ -* -next -] -; -} -} -} -/ -/ -Now -that -we -' -ve -remapped -all -the -IDs -in -our -states -all -that -' -s -left -/ -/ -is -remapping -the -special -state -IDs +state_count +: +nfa +. +state_len +( +) +max_match +: +fail_id +( +) +heap_bytes +: +0 +prefilter +: +nfa . -let -old -= -nnfa +prefilter_obj +( +) . -special +map +( +| +p +| +p +. +clone ( ) -; -let -new -= -& -mut -dfa +) +byte_classes +: +byte_classes . -special +clone +( +) +trans +matches +} ; -new +for +id +in +( +0 . -max_special_id -= -remap_anchored -[ -old . -max_special_id -] -; -new +nfa . -max_match_id -= -remap_anchored -[ -old +state_len +( +) +) . -max_match_id -] -; -new +map +( +S +: +: +from_usize +) +{ +repr . -start_unanchored_id -= -remap_unanchored +matches [ -old +id . -start_unanchored_id +to_usize +( +) ] -; -new . -start_anchored_id -= -remap_anchored -[ -old +extend_from_slice +( +nfa . -start_anchored_id -] +matches +( +id +) +) ; -} -/ -/ -/ -Set -the -desired -match -semantics -. -/ -/ -/ -/ -/ -/ -This -only -applies -when -using -[ -Builder -: -: -build -] -and -not -/ -/ -/ -[ -Builder -: -: -build_from_noncontiguous -] +let +fail += +nfa . -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: -: -match_kind -] +failure_transition ( -crate -: -: -AhoCorasickBuilder -: -: -match_kind +id ) -/ -/ -/ -for -more -documentation -and -examples +; +nfa . -pub -fn -match_kind +iter_all_transitions ( & +byte_classes +id +| +b mut -self -kind -: -MatchKind +next +| +{ +if +next += += +fail_id +( ) -- -> -& -mut -Builder { -self -. -noncontiguous -. -match_kind +next += +nfa_next_state_memoized ( -kind +nfa +& +repr +id +fail +b ) ; -self } -/ -/ -/ -Enable -ASCII -- -aware -case -insensitive -matching +repr . -/ -/ -/ -/ -/ -/ -This -only -applies -when -using -[ -Builder -: -: -build -] -and -not -/ -/ -/ -[ -Builder -: -: -build_from_noncontiguous -] +set_next_state +( +id +b +next +) +; +} +) +; +} +repr . -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: -: -ascii_case_insensitive -] +shuffle_match_states ( -crate -: -: -AhoCorasickBuilder -: -: -ascii_case_insensitive ) -/ -/ -/ -for -more -documentation -and -examples +; +repr . -pub -fn -ascii_case_insensitive +calculate_size ( -& -mut -self -yes -: -bool ) -- -> -& -mut -Builder -{ +; +if self . -noncontiguous +premultiply +{ +repr . -ascii_case_insensitive +premultiply ( -yes ) +? ; -self -} -/ -/ -/ -Enable -heuristic -prefilter -optimizations -. -/ -/ -/ -/ -/ -/ -This -only -applies -when -using -[ -Builder -: -: -build -] -and -not -/ -/ -/ -[ -Builder -: -: -build_from_noncontiguous -] +if +byte_classes . -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: -: -prefilter -] +is_singleton ( -crate -: -: -AhoCorasickBuilder +) +{ +Ok +( +DFA : : -prefilter +Premultiplied +( +Premultiplied +( +repr ) -/ -/ -/ -for -more -documentation -and -examples -. -pub -fn -prefilter +) +) +} +else +{ +Ok ( -& -mut -self -yes +DFA : -bool +: +PremultipliedByteClass +( +PremultipliedByteClass +( +repr ) -- -> -& -mut -Builder +) +) +} +} +else { -self -. -noncontiguous +if +byte_classes . -prefilter +is_singleton ( -yes ) -; -self -} -/ -/ -/ -Sets -the -starting -state -configuration -for -the -automaton -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: -: -start_kind -] +{ +Ok ( -crate +DFA : : -AhoCorasickBuilder +Standard +( +Standard +( +repr +) +) +) +} +else +{ +Ok +( +DFA : : -start_kind +ByteClass +( +ByteClass +( +repr +) ) +) +} +} +} / / / -for -more -documentation -and -examples +Whether +to +use +byte +classes +or +in +the +DFA . pub fn -start_kind +byte_classes ( & mut self -kind +yes : -StartKind +bool ) - > @@ -6093,134 +4517,27 @@ Builder { self . -start_kind +byte_classes = -kind +yes ; self } / / -/ -A -debug -setting -for -whether -to -attempt -to -shrink -the -size -of -the -/ -/ -/ -automaton -' -s -alphabet -or -not -. -/ -/ -/ -/ -/ -/ -This -should -never -be -enabled -unless -you -' -re -debugging -an -automaton -. -/ -/ -/ -Namely -disabling -byte -classes -makes -transitions -easier -to -reason -/ -/ -/ -about -since -they -use -the -actual -bytes -instead -of -equivalence -classes -. -/ -/ -/ -Disabling -this -confers -no -performance -benefit -at -search -time -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: -: -byte_classes -] -( -crate -: -: -AhoCorasickBuilder -: -: -byte_classes -) -/ -/ -/ -for -more -documentation -and -examples +/ +Whether +to +premultiply +state +identifier +in +the +DFA . pub fn -byte_classes +premultiply ( & mut @@ -6237,7 +4554,7 @@ Builder { self . -byte_classes +premultiply = yes ; @@ -6247,66 +4564,73 @@ self / / / -Iterate -over -all -possible -equivalence -class -transitions -in -this -state -. +This +returns +the +next +NFA +transition +( +including +resolving +failure / / / -The -closure -is -called -for -all transitions -with +) +except +once +it +sees a -distinct -equivalence +state +id +less +than +the +id +of +the +DFA / / / -class -even -those -not -explicitly -represented -in -this -sparse state -. -For +that +is +currently +being +populated +then +we +no +longer +need +to +follow / / / -any -implicitly -defined +failure transitions +and +can +instead +query the -given -closure -is -called -with +pre +- +computed +state +id +from / / / the -fail -state -ID +DFA +itself . / / @@ -6314,270 +4638,105 @@ ID / / / -The -closure -is -guaranteed -to +In +general +this +should +only be called -precisely -/ -/ -/ -byte_classes -. -alphabet_len -( -) -times -once -for -every -possible -class -in -/ -/ -/ -ascending -order +when +a +failure +transition +is +seen . fn -sparse_iter +nfa_next_state_memoized < -F +S : -FnMut -( -u8 -u8 StateID -) > ( -nnfa +nfa : & -noncontiguous -: -: NFA -oldsid -: -StateID -classes +< +S +> +dfa : & -ByteClasses -mut -f +Repr +< +S +> +populating : -F -) -{ -let -mut -prev_class -= -None -; -let +S mut -byte -= -0usize -; -for -t -in -nnfa -. -iter_trans -( -oldsid -) -{ -while -byte -< -usize +current : +S +input : -from -( -t -. -byte -( -) +u8 ) +- +> +S +{ +loop { -let -rep -= -byte -. -as_u8 -( -) -; -let -class -= -classes -. -get -( -rep -) -; -byte -+ -= -1 -; if -prev_class -! -= -Some -( -class -) +current +< +populating { -f -( -rep -class -noncontiguous -: -: -NFA -: -: -FAIL -) -; -prev_class -= -Some -( -class -) -; -} -} -let -rep -= -t +return +dfa . -byte +next_state ( +current +input ) ; +} let -class +next = -classes +nfa . -get +next_state ( -rep +current +input ) ; -byte -+ -= -1 -; if -prev_class +next ! = -Some +fail_id ( -class ) { -f -( -rep -class -t -. +return next -( -) -) -; -prev_class -= -Some -( -class -) ; } -} -for -b -in -byte -. -. +current = -255 -{ -let -rep -= -b -. -as_u8 -( -) -; -let -class -= -classes +nfa . -get -( -rep -) -; -if -prev_class -! -= -Some -( -class -) -{ -f -( -rep -class -noncontiguous -: -: -NFA -: -: -FAIL -) -; -prev_class -= -Some +failure_transition ( -class +current ) ; } } -} diff --git a/third_party/rust/aho-corasick/src/error.rs b/third_party/rust/aho-corasick/src/error.rs new file mode 100644 index 0000000000000..cd913001c705a --- /dev/null +++ b/third_party/rust/aho-corasick/src/error.rs @@ -0,0 +1,615 @@ +use +std +: +: +error +; +use +std +: +: +fmt +; +use +std +: +: +result +; +pub +type +Result +< +T +> += +result +: +: +Result +< +T +Error +> +; +/ +/ +/ +An +error +that +occurred +during +the +construction +of +an +Aho +- +Corasick +/ +/ +/ +automaton +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +Error +{ +kind +: +ErrorKind +} +/ +/ +/ +The +kind +of +error +that +occurred +. +# +[ +derive +( +Clone +Debug +) +] +pub +enum +ErrorKind +{ +/ +/ +/ +An +error +that +occurs +when +constructing +an +automaton +would +require +the +/ +/ +/ +use +of +a +state +ID +that +overflows +the +chosen +state +ID +representation +. +/ +/ +/ +For +example +if +one +is +using +u8 +for +state +IDs +and +builds +a +DFA +with +/ +/ +/ +257 +states +then +the +last +state +' +s +ID +will +be +256 +which +cannot +be +/ +/ +/ +represented +with +u8 +. +StateIDOverflow +{ +/ +/ +/ +The +maximum +possible +state +ID +. +max +: +usize +} +/ +/ +/ +An +error +that +occurs +when +premultiplication +of +state +IDs +is +requested +/ +/ +/ +when +constructing +an +Aho +- +Corasick +DFA +but +doing +so +would +overflow +the +/ +/ +/ +chosen +state +ID +representation +. +/ +/ +/ +/ +/ +/ +When +max += += +requested_max +then +the +state +ID +would +overflow +usize +. +PremultiplyOverflow +{ +/ +/ +/ +The +maximum +possible +state +id +. +max +: +usize +/ +/ +/ +The +maximum +ID +required +by +premultiplication +. +requested_max +: +usize +} +} +impl +Error +{ +/ +/ +/ +Return +the +kind +of +this +error +. +pub +fn +kind +( +& +self +) +- +> +& +ErrorKind +{ +& +self +. +kind +} +pub +( +crate +) +fn +state_id_overflow +( +max +: +usize +) +- +> +Error +{ +Error +{ +kind +: +ErrorKind +: +: +StateIDOverflow +{ +max +} +} +} +pub +( +crate +) +fn +premultiply_overflow +( +max +: +usize +requested_max +: +usize +) +- +> +Error +{ +Error +{ +kind +: +ErrorKind +: +: +PremultiplyOverflow +{ +max +requested_max +} +} +} +} +impl +error +: +: +Error +for +Error +{ +fn +description +( +& +self +) +- +> +& +str +{ +match +self +. +kind +{ +ErrorKind +: +: +StateIDOverflow +{ +. +. +} += +> +{ +" +state +id +representation +too +small +" +} +ErrorKind +: +: +PremultiplyOverflow +{ +. +. +} += +> +{ +" +state +id +representation +too +small +for +premultiplication +" +} +} +} +} +impl +fmt +: +: +Display +for +Error +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +match +self +. +kind +{ +ErrorKind +: +: +StateIDOverflow +{ +max +} += +> +write +! +( +f +" +building +the +automaton +failed +because +it +required +\ +building +more +states +that +can +be +identified +where +the +\ +maximum +ID +for +the +chosen +representation +is +{ +} +" +max +) +ErrorKind +: +: +PremultiplyOverflow +{ +max +requested_max +} += +> +{ +if +max += += +requested_max +{ +write +! +( +f +" +premultiplication +of +states +requires +the +ability +to +\ +represent +a +state +ID +greater +than +what +can +fit +on +\ +this +platform +' +s +usize +which +is +{ +} +" +: +: +std +: +: +usize +: +: +MAX +) +} +else +{ +write +! +( +f +" +premultiplication +of +states +requires +the +ability +to +\ +represent +at +least +a +state +ID +of +{ +} +but +the +chosen +\ +representation +only +permits +a +maximum +state +ID +of +{ +} +" +requested_max +max +) +} +} +} +} +} diff --git a/third_party/rust/aho-corasick/src/lib.rs b/third_party/rust/aho-corasick/src/lib.rs index e0d7bf15af69c..00fa1ddd4e2a7 100644 --- a/third_party/rust/aho-corasick/src/lib.rs +++ b/third_party/rust/aho-corasick/src/lib.rs @@ -113,8 +113,11 @@ streams . Finally unlike -most +all other +( +known +) Aho - Corasick @@ -129,9 +132,14 @@ leftmost first ] ( +enum +. MatchKind -: -: +. +html +# +variant +. LeftmostFirst ) or @@ -141,10 +149,15 @@ leftmost longest ] ( +enum +. MatchKind -: -: -LeftmostLongest +. +html +# +variant +. +LeftmostFirst ) match semantics @@ -171,6 +184,13 @@ the [ MatchKind ] +( +enum +. +MatchKind +. +html +) type . # @@ -193,6 +213,13 @@ crate [ AhoCorasick ] +( +struct +. +AhoCorasick +. +html +) is the primary @@ -219,6 +246,13 @@ searches [ AhoCorasickBuilder ] +( +struct +. +AhoCorasickBuilder +. +html +) can be used @@ -241,6 +275,13 @@ options [ Match ] +( +struct +. +Match +. +html +) represents a single @@ -284,6 +325,42 @@ which it matched . +Additionally +the +[ +packed +] +( +packed +/ +index +. +html +) +sub +- +module +contains +a +lower +level +API +for +using +fast +vectorized +routines +for +finding +a +small +number +of +patterns +in +a +haystack +. # Example : @@ -322,10 +399,7 @@ use aho_corasick : : -{ AhoCorasick -PatternID -} ; let patterns @@ -368,10 +442,6 @@ new ( patterns ) -. -unwrap -( -) ; let mut @@ -424,35 +494,17 @@ vec ! [ ( -PatternID -: -: -must -( 1 -) 13 18 ) ( -PatternID -: -: -must -( 0 -) 28 33 ) ( -PatternID -: -: -must -( 2 -) 43 50 ) @@ -482,10 +534,7 @@ use aho_corasick : : -{ -AhoCorasick -PatternID -} +AhoCorasickBuilder ; let patterns @@ -521,10 +570,10 @@ Snapple let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . @@ -537,10 +586,6 @@ build ( patterns ) -. -unwrap -( -) ; let mut @@ -593,35 +638,17 @@ vec ! [ ( -PatternID -: -: -must -( 1 -) 13 18 ) ( -PatternID -: -: -must -( 0 -) 28 33 ) ( -PatternID -: -: -must -( 2 -) 43 50 ) @@ -658,19 +685,6 @@ into memory first . -# -# -[ -cfg -( -feature -= -" -std -" -) -] -{ use aho_corasick : @@ -688,6 +702,8 @@ Result < ( ) +: +: std : : @@ -807,14 +823,10 @@ new ( patterns ) -. -unwrap -( -) ; ac . -try_stream_replace_all +stream_replace_all ( rdr . @@ -862,8 +874,6 @@ unwrap ( ) # -} -# Example : finding @@ -1094,10 +1104,6 @@ new ( patterns ) -. -unwrap -( -) ; let mat @@ -1169,7 +1175,7 @@ aho_corasick : : { -AhoCorasick +AhoCorasickBuilder MatchKind } ; @@ -1196,10 +1202,10 @@ Samwise let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . @@ -1215,10 +1221,6 @@ build ( patterns ) -. -unwrap -( -) ; let mat @@ -1294,6 +1296,13 @@ See [ MatchKind ] +( +enum +. +MatchKind +. +html +) for more details @@ -1433,1219 +1442,869 @@ AhoCorasickBuilder : prefilter ] +( +struct +. +AhoCorasickBuilder . +html # -Lower -level -APIs -This -crate -also -provides -several -sub -- -modules -that -collectively -expose -many -of -the -implementation -details -of -the -main +method +. +prefilter +) +. +* +/ +# +! [ -AhoCorasick +deny +( +missing_docs +) ] -type -. -Most -users -of -this -library +/ +/ +We can -completely -ignore -the -submodules -and -their -contents +never +be +truly +no_std but -if -you -needed -finer -grained -control -some -parts -of -them -may +we +could be -useful -to -you +alloc +- +only +some +day +so +/ +/ +require +the +std +feature +for +now . -Here +# +[ +cfg +( +not +( +feature += +" +std +" +) +) +] +compile_error +! +( +" +std +feature is -a -brief -overview -of -each -and -why -you -might -want +currently +required to -use -them -: -* -The +build +this +crate +" +) +; +/ +/ +# [ -packed -] -sub -- -module -contains -a -lower -level -API -for -using -fast -vectorized -routines -for -finding -a -small -number -of -patterns -in -a -haystack -. -You -might -want -to -use -this -API -when -you -want -to -completely -side -- -step -using -Aho -- -Corasick -automata -. -Otherwise -the -fast -vectorized -routines -are -used -automatically -as -prefilters -for -AhoCorasick -searches -whenever -possible -. -* -The +cfg +( +doctest +) +] +/ +/ +# [ -automaton +macro_use ] -sub -- -module -provides -a -lower -level -finite -state -machine -interface -that -the -various -Aho -- -Corasick -implementations -in -this +/ +/ +extern crate -implement -. -This -sub -- -module -' -s -main -contribution -is -the +doc_comment +; +/ +/ +# [ -Automaton -] +cfg ( -automaton -: -: -Automaton +doctest ) -trait -which -permits -manually -walking -the -state -transitions -of -an -Aho -- -Corasick -automaton -. -* -The -[ -dfa -] -and -[ -nfa ] -sub -- -modules -provide -DFA -and -NFA -implementations -of -the -aforementioned -Automaton -trait +/ +/ +doctest +! +( +" . -The -main -reason -one -might -want -to -use -these -sub -- -modules -is -to -get -access -to -a -type -that -implements -the -Automaton -trait . -( -The -top -- -level -AhoCorasick -type -does -not -implement -the -Automaton -trait +/ +README . +md +" ) -As -mentioned -above -if -you -aren -' -t -sure -whether -you -need -these -sub -- -modules -you -should -be -able -to -safely -ignore -them -and -just -focus -on -the -[ -AhoCorasick -] -type -. -# -Crate -features -This +; +pub +use crate -exposes -a -few -features -for -controlling -dependency -usage -and -whether -this +: +: +ahocorasick +: +: +{ +AhoCorasick +AhoCorasickBuilder +FindIter +FindOverlappingIter +MatchKind +StreamFindIter +} +; +pub +use crate -can -be -used -without -the -standard -library -. -* -* -* -std -* -* -- -Enables -support -for -the -standard -library -. -This -feature -is -enabled -by -default -. -When -disabled -only -core -and -alloc -are -used -. -At -an -API -level -enabling -std -enables -std : : error : : +{ Error -trait -impls -for -the -various -error -types -and -higher -level -stream -search -routines -such -as -[ -AhoCorasick +ErrorKind +} +; +pub +use +crate : : -try_stream_find_iter -] -. -But -the -std -feature -is -also -required -to -enable -vectorized -prefilters -. -Prefilters -can -greatly -accelerate -searches -but -generally -only -apply -when -the -number -of -patterns -is -small +state_id +: +: +StateID +; +mod +ahocorasick +; +mod +automaton +; +mod +buffer +; +mod +byte_frequencies +; +mod +classes +; +mod +dfa +; +mod +error +; +mod +nfa +; +pub +mod +packed +; +mod +prefilter +; +mod +state_id +; +# +[ +cfg ( -less -than -~ -100 +test ) -. -* -* -* -perf -- -literal -* -* -- -Enables -support -for -literal -prefilters -that -use -vectorized -routines -from -external -crates -. -This -feature -is -enabled +] +mod +tests +; +/ +/ +/ +A +representation +of +a +match +reported by -default -. -If -you -' -re -only -using +an Aho - Corasick -for -large -numbers +automaton +. +/ +/ +/ +/ +/ +/ +A +match +has +two +essential +pieces of -patterns -or -otherwise -can -abide -lower -throughput -when -searching -with -a -small -number +information +: +the +identifier of -patterns -then -it -is -reasonable -to -disable -this -feature -. -* -* -* -logging -* -* -- -Enables -a -dependency -on the -log -crate +/ +/ +/ +pattern +that +matched +along +with +the +start and -emits -messages -to -aide +end +offsets +of +the +match +/ +/ +/ in -diagnostics -. -This -feature -is -disabled -by -default +the +haystack . -* +/ +/ +/ +/ +/ / # -! +Examples +/ +/ +/ +/ +/ +/ +Basic +usage +: +/ +/ +/ +/ +/ +/ +/ +/ +/ +use +aho_corasick +: +: +AhoCorasick +; +/ +/ +/ +/ +/ +/ +let +ac += +AhoCorasick +: +: +new +( +& [ -no_std +/ +/ +/ +" +foo +" +" +bar +" +" +baz +" +/ +/ +/ ] -# -! -[ -deny +) +; +/ +/ +/ +let +mat += +ac +. +find ( -missing_docs +" +xxx +bar +xxx +" ) -] -# -! -[ -deny +. +expect ( -rustdoc -: -: -broken_intra_doc_links +" +should +have +a +match +" ) -] -# +; +/ +/ +/ +assert_eq ! -[ -cfg_attr ( -docsrs -feature +1 +mat +. +pattern ( -doc_auto_cfg ) ) -] -extern -crate -alloc ; -# -[ -cfg +/ +/ +/ +assert_eq +! ( -any +4 +mat +. +start ( -test -feature -= -" -std -" ) ) -] -extern -crate -std ; -# -[ -cfg -( -doctest -) -] -doc_comment -: -: -doctest +/ +/ +/ +assert_eq ! ( -" -. -. -/ -README +7 +mat . -md -" +end +( +) ) ; +/ +/ +/ # [ -cfg +derive ( -feature -= -" -std -" +Clone +Debug +Eq +Hash +PartialEq ) ] pub -use -crate -: -: -ahocorasick -: -: -StreamFindIter -; -pub -use -crate -: -: -{ -ahocorasick -: -: -{ -AhoCorasick -AhoCorasickBuilder -AhoCorasickKind -FindIter -FindOverlappingIter -} -util -: -: -{ -error -: -: -{ -BuildError -MatchError -MatchErrorKind -} -primitives -: -: +struct +Match { -PatternID -PatternIDError -} -search -: +/ +/ +/ +The +pattern +id +. +pattern : -{ -Anchored -Input -Match -MatchKind -Span -StartKind -} -} -} -; -# -[ -macro_use -] -mod -macros -; -mod -ahocorasick -; -pub -mod +usize +/ +/ +/ +The +length +of +this +match +such +that +the +starting +position +of +the +match +/ +/ +/ +is +end +- +len +. +/ +/ +/ +/ +/ +/ +We +use +length +here +because +other +than +the +pattern +id +the +only +/ +/ +/ +information +about +each +pattern +that +the automaton -; -pub -mod -dfa -; -pub -mod -nfa -; -pub -mod -packed -; -# -[ -cfg -( -test -) -] -mod -tests -; +stores +is +its +length +. / / -I -wrote -out +/ +So +using the -module -for -implementing -fst +length +here +is +just +a +bit +more +natural +. +But +it +isn +' +t +/ +/ +/ +technically +required +. +len : +usize +/ +/ +/ +The +end +offset +of +the +match +exclusive +. +end : -Automaton -only -to -later -realize +usize +} +impl +Match +{ / / +/ +Returns +the +identifier +of +the +pattern that -this -would -make -fst -a -public -dependency -and -fst -is -not -at -1 -. -0 -yet +matched . -I / / -decided -to -just -keep -the -code -in -tree -but -build -it -only -during -tests -. / / / / -TODO -: -I -think -I -' -ve -changed -my -mind -again -. -I -' -m -considering -pushing +The +identifier +of +a +pattern +is +derived +from +the +position +in +which it -out / / +/ +was +originally +inserted into -either -a -separate -crate -or -into -' -fst -' -directly -as -an -optional -feature +the +corresponding +automaton . +The +first / / -# -[ -cfg -( -test -) -] / +pattern +has +identifier +0 +and +each +subsequent +pattern +is +1 +2 / -# -[ -allow -( -dead_code -) -] / / -mod -transducer -; -pub -( -crate -) -mod -util -; +and +so +on +. # [ -cfg -( -test -) +inline ] -mod -testoibits -{ -use -std -: -: -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -; -use -super -: -: -* -; +pub fn -assert_all -< -T -: -Send -+ -Sync -+ -UnwindSafe -+ -RefUnwindSafe -> +pattern ( +& +self ) +- +> +usize { +self +. +pattern } +/ +/ +/ +The +starting +position +of +the +match +. # [ -test +inline ] +pub fn -oibits_main -( -) -{ -assert_all -: -: -< -AhoCorasick -> -( -) -; -assert_all -: -: -< -AhoCorasickBuilder -> -( -) -; -assert_all -: -: -< -AhoCorasickKind -> -( -) -; -assert_all -: -: -< -FindIter -> -( -) -; -assert_all -: -: -< -FindOverlappingIter -> -( -) -; -assert_all -: -: -< -BuildError -> -( -) -; -assert_all -: -: -< -MatchError -> -( -) -; -assert_all -: -: -< -MatchErrorKind -> -( -) -; -assert_all -: -: -< -Anchored -> -( -) -; -assert_all -: -: -< -Input -> -( -) -; -assert_all -: -: -< -Match -> -( -) -; -assert_all -: -: -< -MatchKind -> +start ( +& +self ) -; -assert_all -: -: -< -Span +- > +usize +{ +self +. +end +- +self +. +len +} +/ +/ +/ +The +ending +position +of +the +match +. +# +[ +inline +] +pub +fn +end ( +& +self ) -; -assert_all -: -: -< -StartKind +- > -( -) -; +usize +{ +self +. +end } +/ +/ +/ +The +length +in +bytes +of +the +match +. # [ -test +inline ] +pub fn -oibits_automaton +len ( +& +self ) +- +> +usize { -use -crate -: -: -{ -automaton -dfa -: -: -DFA +self +. +len } -; -assert_all -: -: -< -automaton -: -: -FindIter -< -DFA -> -> +/ +/ +/ +Returns +true +if +and +only +if +this +match +is +empty +. +That +is +when +/ +/ +/ +start ( ) -; -assert_all -: -: -< -automaton -: -: -FindOverlappingIter -< -DFA -> -> += += +end ( ) -; +. +/ +/ +/ +/ +/ +/ +An +empty +match +can +only +be +returned +when +the +empty +string +was +among +/ +/ +/ +the +patterns +used +to +build +the +Aho +- +Corasick +automaton +. # [ -cfg -( -feature -= -" -std -" -) +inline ] -assert_all -: -: -< -automaton -: -: -StreamFindIter -< -DFA -std -: -: -io -: -: -Stdin -> -> -( -) -; -assert_all -: -: -< -automaton -: -: -OverlappingState -> -( -) -; -assert_all -: -: -< -automaton -: -: -Prefilter -> +pub +fn +is_empty ( +& +self ) -; -assert_all -: -: -< -automaton -: -: -Candidate +- > -( -) -; +bool +{ +self +. +len += += +0 } # [ -test +inline ] fn -oibits_packed +increment ( -) -{ -use -crate -: -: -packed -; -assert_all -: -: -< -packed -: +& +self +by : -Config -> -( +usize ) -; -assert_all -: -: -< -packed -: -: -Builder +- > -( -) -; -assert_all -: +Match +{ +Match +{ +pattern : -< -packed +self +. +pattern +len : +self +. +len +end : -Searcher -> +self +. +end ++ +by +} +} +# +[ +inline +] +fn +from_span ( -) -; -assert_all +id : +usize +start : -< -packed -: +usize +end : -FindIter -> -( +usize ) -; -assert_all -: -: -< -packed +- +> +Match +{ +Match +{ +pattern : +id +len : -MatchKind -> -( -) -; +end +- +start +end +} } } diff --git a/third_party/rust/aho-corasick/src/macros.rs b/third_party/rust/aho-corasick/src/macros.rs deleted file mode 100644 index 61ad29abb5f57..0000000000000 --- a/third_party/rust/aho-corasick/src/macros.rs +++ /dev/null @@ -1,106 +0,0 @@ -# -! -[ -allow -( -unused_macros -) -] -macro_rules -! -log -{ -( -( -tt -: -tt -) -* -) -= -> -{ -# -[ -cfg -( -feature -= -" -logging -" -) -] -{ -( -tt -) -* -} -} -} -macro_rules -! -debug -{ -( -( -tt -: -tt -) -* -) -= -> -{ -log -! -( -log -: -: -debug -! -( -( -tt -) -* -) -) -} -} -macro_rules -! -trace -{ -( -( -tt -: -tt -) -* -) -= -> -{ -log -! -( -log -: -: -trace -! -( -( -tt -) -* -) -) -} -} diff --git a/third_party/rust/aho-corasick/src/nfa/contiguous.rs b/third_party/rust/aho-corasick/src/nfa.rs similarity index 58% rename from third_party/rust/aho-corasick/src/nfa/contiguous.rs rename to third_party/rust/aho-corasick/src/nfa.rs index 7dc4212b379cc..3916052ebb1f4 100644 --- a/third_party/rust/aho-corasick/src/nfa/contiguous.rs +++ b/third_party/rust/aho-corasick/src/nfa.rs @@ -1,401 +1,381 @@ -/ -* -! -Provides -a -contiguous -NFA -implementation -of -Aho -- -Corasick -. -This -is -a -low -- -level -API -that -generally -only -needs -to -be -used -in -niche -circumstances -. -When -possible -prefer -using -[ -AhoCorasick -] -( -crate +use +std : : -AhoCorasick -) -instead -of -a -contiguous -NFA -directly -. -Using -an -NFA -directly -is -typically -only -necessary -when -one -needs -access -to -the -[ -Automaton -] -trait -implementation -. -* -/ +cmp +; use -alloc +std +: +: +collections : : { -vec -vec +BTreeSet +VecDeque +} +; +use +std : : -Vec +fmt +; +use +std +: +: +mem +: +: +size_of +; +use +std +: +: +ops +: +: +{ +Index +IndexMut } ; use crate : : -{ +ahocorasick +: +: +MatchKind +; +use +crate +: +: automaton : : Automaton -nfa +; +use +crate : : -noncontiguous -util +classes : : { -alphabet +ByteClassBuilder +ByteClasses +} +; +use +crate : : -ByteClasses error : : -{ -BuildError -MatchError -} -int +Result +; +use +crate : : -{ -Usize -U16 -U32 -} prefilter : : +{ +self +opposite_ascii_case Prefilter -primitives +PrefilterObj +} +; +use +crate : : -{ -IteratorIndexExt -PatternID -SmallIndex -StateID -} -search +state_id : : { -Anchored -MatchKind +dead_id +fail_id +usize_to_state_id +StateID } -special +; +use +crate : : -Special -} -} +Match ; / / / -A -contiguous -NFA -implementation +The +identifier +for +a +pattern +which +is +simply +the +position of -Aho -- -Corasick -. +the +pattern / / / +in +the +sequence +of +patterns +given +by +the +caller +. +pub +type +PatternID += +usize +; / / / -When -possible -prefer -using -[ -AhoCorasick -] -( -crate -: -: -AhoCorasick -) -instead +The +length of +a +pattern +in +bytes +. +pub +type +PatternLength += +usize +; / / / -this -type -directly -. -Using +An +Aho +- +Corasick +automaton +represented +as an NFA -directly -is -typically -only -necessary +. / / / -when -one -needs -access -to -the -[ -Automaton -] -trait -implementation -. / / / +This +is +the +classical +formulation +of +Aho +- +Corasick +which +involves +building / / / -This -NFA -can -only -be -built -by -first -constructing +up a -[ -noncontiguous -: -: -NFA -] -. +prefix +trie +of +a +given +set +of +patterns +and +then +wiring +up +failure / / / -Both -[ -NFA -: -: -new -] -and -[ -Builder -: -: -build -] -do -this -for -you -automatically -but +transitions +between +states +in +order +to +guarantee +linear +time +matching +. +The / / / -[ -Builder -: -: -build_from_noncontiguous -] -permits -doing -it -explicitly -. +standard +formulation +is +technically +an +NFA +because +of +these +failure / / / +transitions +. +That +is +one +can +see +them +as +enabling +the +automaton +to +be +in / / / -The -main -difference -between -a -noncontiguous -NFA -and -a -contiguous -NFA +multiple +states +at +once +. +Indeed +during +search +it is +possible +to +check / / / -that the -latter -represents -all -of -its -states -and transitions -in +on +multiple +states +for a single +input +byte +. / / / -allocation -where -as +/ +/ +/ +This +particular +implementation +not +only +supports the -former -uses -a -separate -allocation -for -each -state -. +standard +style +of / / / -Doing -this -at -construction -time -while -keeping +matching +but +also +provides a -low -memory -footprint -isn -' -t +mode +for +choosing +leftmost +- +first +or / / / -feasible -which +leftmost +- +longest +match +semantics +. +When +a +leftmost +mode is -primarily -why -there -are -two -different -NFA -types -: -one +chosen +some / / / +failure +transitions that -does -the -least -amount -of -work -possible -to -build -itself -and -another +would +otherwise +be +added +are +elided +. +See / / / -that -does -a -little -extra -work -to -compact -itself +the +documentation +of +MatchKind +for +more +details and -make -state -transitions +examples +on +how +the / / / -faster -by -making -some -states -use -a -dense -representation +match +semantics +may +differ . / / @@ -403,1053 +383,1040 @@ representation / / / -Because -a -contiguous -NFA -uses +If +one +wants a -single -allocation -there +DFA +then +it is -a -lot -more +necessary +to +first +build +an +NFA +and +convert / / / -opportunity -for -compression -tricks -to -reduce -the -heap -memory -used +it +into +a +DFA . -Indeed +Note +however +that +because +we +' +ve +constrained +ourselves +to / / / -it -is +matching +literal +patterns +this +does not -uncommon -for -a -contiguous -NFA +need to use -an -order -of -magnitude -less +subset +construction / / / -heap -memory -than -a -noncontiguous -NFA +for +determinization . -Since -building +Instead +the +DFA +has +at +most a -contiguous -NFA +number +of +states / / / -usually -only -takes -a -fraction -of -the -time -it -takes +equivalent to -build -a -noncontiguous -/ -/ -/ -NFA the -overall -build -time -is -not -much -slower +number +of +NFA +states . -Thus -in -most -cases -a +The +only +real +difference +between / / / -contiguous -NFA +them is -the -best -choice +that +all +failure +transitions +are +followed +and +pre +- +computed . +This / / / +uses +much +more +memory +but +also +executes +searches +more +quickly +. +# +[ +derive +( +Clone +) +] +pub +struct +NFA +< +S +> +{ / / / -Since -a -contiguous +The +match +semantics +built +into +this NFA -uses -various -tricks -for -compression -and -to -achieve +. +match_kind +: +MatchKind / / / -faster +The +start state -transitions -currently -its -limit -on -the -number -of +id +as +an +index +into states -/ -/ -/ -is -somewhat -smaller -than -what -a -noncontiguous -NFA -can -achieve . -Generally +start_id +: +S / / / -speaking -you -shouldn -' -t -expect -to -run -into -this -limit -if -the -number +The +length +in +bytes of -/ -/ -/ -patterns -is -under -1 -million -. -It -is -plausible -that +the +longest +pattern +in this -limit -will -be +automaton +. +This / / / -increased -in -the -future -. -If -the -limit +information is -reached -building -a -contiguous -NFA +useful +for +keeping +correct +buffer +sizes +when +searching / / / -will -return -an -error +on +streams . -Often -since -building -a -contiguous -NFA -is -relatively +max_pattern_len +: +usize / / / -cheap -it -can -make -sense +The +total +number +of +patterns +added to -always -try -it -even -if -you -aren -' -t -sure -if -it +this +automaton +including / / / -will -fail -or -not +patterns +that +may +never +be +matched . -If -it -does -you -can -always -fall -back -to -a -noncontiguous +pattern_count +: +usize / / / +The +number +of +bytes +of +heap +used +by +this NFA +' +s +transition +table . -( -Indeed -the -main -[ -AhoCorasick -] -( -crate +heap_bytes : -: -AhoCorasick -) -type -employs -a +usize / / / -strategy -similar +A +prefilter +for +quickly +skipping to -this -at -construction -time +candidate +matches +if +pertinent . -) +prefilter +: +Option +< +PrefilterObj +> / / / +Whether +this +automaton +anchors +all +matches +to +the +start +of +input +. +anchored +: +bool / / / -# -Example +A +set +of +equivalence +classes +in +terms +of +bytes +. +We +compute +this +while / / / +building +the +NFA +but +don +' +t +use +it +in +the +NFA +' +s +states +. +Instead +we / / / -This -example -shows -how -to -build -an -NFA -directly -and use +this +for +building +the +DFA +. +We +store it -to -execute +on +the +NFA +since +it +' +s +easy / / / -[ -Automaton -: -: -try_find -] +to +compute +while +visiting +the +patterns +. +byte_classes : +ByteClasses / / / +A +set +of +states +. +Each +state +defines +its +own +transitions +a +fail / / / +transition +and +a +set +of +indices +corresponding +to +matches +. / / / -use -aho_corasick -: -: -{ / / / -automaton -: -: -Automaton +The +first +state +is +always +the +fail +state +which +is +used +only +as +a / / / -nfa -: -: -contiguous -: -: +sentinel +. +Namely +in +the +final NFA +no +transition +into +the +fail +state / / / -Input -Match +exists +. +( +Well +they +do +but +they +aren +' +t +followed +. +Instead +the +state +' +s / / / -} -; +failure +transition +is +followed +. +) / / / / / / -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; +The +second +state +( +index +1 +) +is +always +the +dead +state +. +Dead +states +are / / / -let -haystack -= -" -abcd -" -; +in +every +automaton +but +only +used +when +leftmost +- +{ +first +longest +} +match / / / +semantics +are +enabled +. +Specifically +they +instruct +search +to +stop / / / -let -nfa -= -NFA -: -: -new -( -patterns -) +at +specific +points +in +order +to +report +the +correct +match +location . -unwrap -( -) -; +In / / / -assert_eq -! -( +the +standard +Aho +- +Corasick +construction +there +are +no +transitions +to / / / -Some -( -Match -: -: -must -( -0 -1 -. +the +dead +state . -2 -) -) / / / -nfa -. -try_find -( -& -Input -: -: -new -( -haystack -) -) -? / / / +The +third +state +( +index +2 ) -; +is +generally +intended +to +be +the +starting +or / / / -# -Ok -: +" +root +" +state +. +states : +Vec < -( -) -Box +State < -dyn -std -: -: -error -: +S +> +> +} +impl +< +S : -Error +StateID > +NFA +< +S > -( -( -) -) -/ -/ -/ -/ -/ -/ +{ / / / -It -is -also -possible -to -implement -your -own -version -of -try_find -. -See +Returns the +equivalence +classes +of +bytes +found +while +constructing / / / -[ -Automaton -] -documentation -for -an -example -. -# -[ -derive -( -Clone -) -] -pub -struct -NFA -{ -/ -/ -/ -The -raw +this NFA -representation . -Each -state -is -packed -with -a -header / / / -( -containing -the -format -of -the -state -the -failure -transition -and -for / / / -a -sparse -state +Note +that the -number +NFA +doesn +' +t +actually +make +use of -transitions -) -its -transitions -and -any +these +equivalence / / / -matching -pattern -IDs +classes +. +Instead +these +are +useful for -match -states +building +the +DFA +when +desired . -repr -: -Vec -< -u32 +pub +fn +byte_classes +( +& +self +) +- > -/ -/ -/ -The -length -of -each -pattern +& +ByteClasses +{ +& +self . -This -is -used -to -compute -the -start -offset +byte_classes +} / / / -of +Returns a -match +prefilter +if +one +exists . -pattern_lens -: -Vec +pub +fn +prefilter_obj +( +& +self +) +- +> +Option < -SmallIndex +& +PrefilterObj > +{ +self +. +prefilter +. +as_ref +( +) +} / / / -The +Returns +the total number of -states -in +heap +bytes +used +by this NFA -. -state_len -: -usize +' +s +transition / / / -A -prefilter -for -accelerating -searches -if -one -exists +table . -prefilter -: -Option -< -Prefilter +pub +fn +heap_bytes +( +& +self +) +- > -/ -/ -/ -The -match -semantics -built -into -this -NFA +usize +{ +self . -match_kind -: -MatchKind -/ -/ -/ -The -alphabet -size -or -total -number -of -equivalence -classes -for -this -/ -/ -/ -NFA +heap_bytes ++ +self . -Dense -states -always -have -this -many -transitions +prefilter . -alphabet_len -: -usize -/ -/ -/ -The -equivalence -classes -for -this -NFA +as_ref +( +) . -All -transitions -dense -and -/ -/ -/ -sparse -are -defined -on -equivalence -classes -and -not -on -the -256 -distinct -/ -/ -/ -byte -values +map_or +( +0 +| +p +| +p . -byte_classes -: -ByteClasses +as_ref +( +) +. +heap_bytes +( +) +) +} / / / -The +Return +the length of the -shortest +longest pattern in this automaton . -min_pattern_len -: +pub +fn +max_pattern_len +( +& +self +) +- +> usize +{ +self +. +max_pattern_len +} / / / -The -length -of +Return the -longest -pattern -in +total +number +of +patterns +added +to this automaton . -max_pattern_len -: +pub +fn +pattern_count +( +& +self +) +- +> usize +{ +self +. +pattern_count +} / / / -The -information -required -to -deduce -which +Returns +the +total +number +of states -are -" -special -" in this -/ -/ -/ NFA . -special -: -Special -} -impl -NFA -{ -/ -/ -/ -Create -a -new -Aho +pub +fn +state_len +( +& +self +) - -Corasick -contiguous -NFA -using -the -default -/ -/ -/ -configuration +> +usize +{ +self . +states +. +len +( +) +} / / / -/ -/ -/ -Use -a -[ -Builder -] -if -you -want -to -change +Returns the -configuration +matches +for +the +given +state . pub fn -new -< -I -P -> +matches ( -patterns +& +self +id : -I +S ) - > -Result -< -NFA -BuildError -> -where -I -: -IntoIterator -< -Item -= -P -> -P -: -AsRef -< +& [ -u8 -] -> -{ -NFA -: -: -builder ( +PatternID +PatternLength ) +] +{ +& +self . -build +states +[ +id +. +to_usize ( -patterns ) +] +. +matches } / / / -A -convenience -method -for -returning -a -new -Aho -- -Corasick -contiguous -NFA +Returns +an +iterator +over +all +transitions +in +the +given +state +according / / / -builder +to +the +given +equivalence +classes +including +transitions +to +fail_id +( +) . / / / +The +number +of +transitions +returned +is +always +equivalent +to +the +number / / / -This -usually -permits -one -to -just -import -the -NFA -type +of +equivalence +classes . pub fn -builder +iter_all_transitions +< +F +: +FnMut ( +u8 +S ) -- > -Builder -{ -Builder +( +& +self +byte_classes : +& +ByteClasses +id : -new -( +S +f +: +F ) -} -} -impl -NFA { -/ -/ -/ -A -sentinel -state -ID -indicating -that -a -search -should -stop -once -it -has -/ -/ -/ -entered -this -state +self . -When -a -search -stops -it -returns -a -match -if -one -/ -/ -/ -has -been -found -otherwise -no -match +states +[ +id . -A -contiguous -NFA -always -has -an +to_usize +( +) +] +. +trans +. +iter_all +( +byte_classes +f +) +; +} / / / -actual -dead +Returns +the +failure +transition +for +the +given state -at -this -ID . -const -DEAD -: -StateID -= -StateID -: +pub +fn +failure_transition +( +& +self +id : -new_unchecked +S +) +- +> +S +{ +self +. +states +[ +id +. +to_usize ( -0 ) -; +] +. +fail +} / / / -Another -sentinel +Returns +the +next state -ID -indicating -that -a -search -should -move -through -/ -/ -/ -current +for +the +given state -' -s -failure -transition +and +input +byte . / / @@ -1459,1963 +1426,1495 @@ transition / Note that -unlike -DEAD this does not -actually -point -to -a -valid -state +follow +failure +transitions +. +As +such +the +id / / / -in -a -contiguous -NFA +returned +may +be +fail_id . +pub +fn +next_state ( -noncontiguous -: -: -NFA +& +self +current : +S +input : -FAIL -does -point -to -a -valid -/ -/ -/ -state +u8 +) +- +> +S +{ +self +. +states +[ +current . +to_usize +( ) -Instead -this -points -to -the -position -that -is -guaranteed -to -/ -/ -/ -never -be -a -valid -state -ID -( -by -making -sure -it -points -to -a -place -in -the -/ -/ -/ -middle -of -the -encoding -of -the -DEAD -state -) -. -Since -we -never -need -to -/ -/ -/ -actually -look -at -the -FAIL -state -itself -this -works -out -. -/ -/ -/ -/ -/ -/ -By -why -do -it -this -way -? -So -that -FAIL -is -a -constant -. -I -don -' -t -have -any -/ -/ -/ -concrete -evidence -that -this -materially -helps -matters -but -it -' -s -easy -to -/ -/ -/ -do -. -The -alternative -would -be -making -the -FAIL -ID -point -to -the -second -/ -/ -/ -state -which -could -be -made -a -constant -but -is -a -little -trickier -to -do -. -/ -/ -/ -The -easiest -path -is -to -just -make -the -FAIL -state -a -runtime -value -but -/ -/ -/ -since -comparisons -with -FAIL -occur -in -perf -critical -parts -of -the -search -/ -/ -/ -we -want -it -to -be -as -tight -as -possible -and -not -waste -any -registers -. -/ -/ -/ -/ -/ -/ -Very -hand -wavy -. -. -. -But -the -code -complexity -that -results -from -this -is -/ -/ -/ -very -mild +] . -const -FAIL -: -StateID -= -StateID -: -: -new_unchecked +next_state ( -1 +input ) -; } -/ -/ -SAFETY -: -' -start_state -' -always -returns -a -valid -state -ID -' -next_state -' -always -/ -/ -returns -a -valid -state -ID -given -a -valid +fn state -ID -. -We -otherwise -claim -that -/ -/ -all -other -methods -are -correct -as -well -. -unsafe -impl -Automaton -for -NFA +( +& +self +id +: +S +) +- +> +& +State +< +S +> { -# +& +self +. +states [ -inline +id +. +to_usize ( -always ) ] +} fn -start_state +state_mut ( & +mut self -anchored +id : -Anchored +S ) - > -Result +& +mut +State < -StateID -MatchError +S > { -match -anchored -{ -Anchored -: -: -No -= -> -Ok -( +& +mut self . -special +states +[ +id . -start_unanchored_id +to_usize +( ) -Anchored -: -: -Yes -= -> -Ok +] +} +fn +start ( +& +self +) +- +> +& +State +< +S +> +{ self . -special +state +( +self . -start_anchored_id +start_id ) } -} -# -[ -inline +fn +start_mut ( -always +& +mut +self ) -] +- +> +& +mut +State +< +S +> +{ +let +id += +self +. +start_id +; +self +. +state_mut +( +id +) +} fn -next_state +iter_transitions_mut ( & +mut self -anchored +id : -Anchored +S +) +- +> +IterTransitionsMut +< +' +_ +S +> +{ +IterTransitionsMut +: +: +new +( +self +id +) +} +fn +copy_matches +( +& mut -sid +self +src : -StateID -byte +S +dst : -u8 +S ) -- -> -StateID { let -repr +( +src +dst +) = +get_two_mut +( & +mut self . -repr +states +src +. +to_usize +( +) +dst +. +to_usize +( +) +) ; -let -class -= -self +dst . -byte_classes +matches . -get +extend_from_slice ( -byte +& +src +. +matches ) ; -let -u32tosid -= -StateID -: +} +fn +copy_empty_matches +( +& +mut +self +dst : -from_u32_unchecked -; -loop +S +) { let -o +start_id = -sid +self +. +start_id +; +self . -as_usize +copy_matches ( +start_id +dst ) ; -let -kind -= -repr -[ -o -] +} +fn +add_dense_state +( & -0xFF -; -/ -/ -I -tried -to -encapsulate -the -" -next -transition -" -logic -into -its -own -/ -/ -function -but -it -seemed -to -always -result -in -sub -- -optimal -codegen -/ -/ -that -led -to -real -and -significant -slowdowns -. -So -we -just -inline -/ -/ -the -logic -here -. -/ -/ -/ -/ -I -' -ve -also -tried -a -lot -of -different -ways -to -speed -up -this -/ -/ -routine -and -most -of -them -have -failed -. -if -kind -= -= -State -: +mut +self +depth : -KIND_DENSE +usize +) +- +> +Result +< +S +> { let -next +trans = -u32tosid +Transitions +: +: +Dense ( -repr -[ -o -+ -2 -+ -usize +Dense : : -from +new ( -class ) -] ) ; -if -next -! +let +id = -NFA -: -: -FAIL -{ -return -next +usize_to_state_id +( +self +. +states +. +len +( +) +) +? ; -} -} -else -if -kind -= -= +self +. +states +. +push +( State -: -: -KIND_ONE { -if -class -= -= -repr -[ -o -] +trans +/ +/ +Anchored +automatons +do +not +have +any +failure +transitions . -low_u16 -( -) +fail +: +if +self . -high_u8 +anchored +{ +dead_id ( ) +} +else { -return -u32tosid -( -repr +self +. +start_id +} +depth +matches +: +vec +! [ -o -+ -2 ] +} ) ; +Ok +( +id +) } -} -else -{ -/ -/ -NOTE -: -I -tried -a -SWAR -technique -in -the -loop -below -but -found -/ -/ -it -slower -. -See -the -' -swar -' -test -in -the -tests -for -this -module -. -let -trans_len -= -kind -. -as_usize +fn +add_sparse_state ( +& +mut +self +depth +: +usize ) -; +- +> +Result +< +S +> +{ let -classes_len +trans = -u32_len +Transitions +: +: +Sparse ( -trans_len +vec +! +[ +] ) ; let -trans_offset +id = -o -+ -2 -+ -classes_len -; -for +usize_to_state_id ( -i -& -chunk -) -in -repr -[ -o -+ -2 -. -. -] -[ -. +self . -classes_len -] +states . -iter +len ( ) +) +? +; +self . -enumerate +states +. +push ( -) +State { -let -classes -= -chunk +trans +/ +/ +Anchored +automatons +do +not +have +any +failure +transitions . -to_ne_bytes -( -) -; +fail +: if -classes -[ -0 -] -= -= -class +self +. +anchored { -return -u32tosid +dead_id ( -repr -[ -trans_offset -+ -i -* -4 -] ) -; } -if -classes -[ -1 -] -= -= -class +else { -return -u32tosid -( -repr +self +. +start_id +} +depth +matches +: +vec +! [ -trans_offset -+ -i -* -4 -+ -1 ] +} ) ; -} -if -classes -[ -2 -] -= -= -class -{ -return -u32tosid +Ok ( -repr -[ -trans_offset -+ -i -* -4 -+ -2 -] +id ) -; -} -if -classes -[ -3 -] -= -= -class -{ -return -u32tosid -( -repr -[ -trans_offset -+ -i -* -4 -+ -3 -] -) -; -} } } -/ -/ -For -an -anchored -search -we -never -follow -failure -transitions -/ -/ -because -failure -transitions -lead -us -down -a -path -to -matching -/ -/ -a -* -proper -* -suffix -of -the -path -we -were -on -. -Thus -it -can -only -/ -/ -produce -matches -that -appear -after -the -beginning -of -the -search -. -if -anchored -. -is_anchored -( -) -{ -return -NFA -: +impl +< +S : -DEAD -; -} -sid +StateID +> +Automaton +for +NFA +< +S +> +{ +type +ID = -u32tosid -( -repr -[ -o -+ -1 -] -) +S ; -} -} -# -[ -inline -( -always -) -] fn -is_special +match_kind ( & self -sid -: -StateID ) - > -bool +& +MatchKind { -sid -< -= +& self . -special -. -max_special_id +match_kind } -# -[ -inline -( -always -) -] fn -is_dead +anchored ( & self -sid -: -StateID ) - > bool { -sid -= -= -NFA -: -: -DEAD +self +. +anchored } -# -[ -inline -( -always -) -] fn -is_match +prefilter ( & self -sid -: -StateID ) - > -bool -{ -! -self -. -is_dead -( -sid -) -& -& -sid +Option < -= -self -. -special -. -max_match_id -} -# -[ -inline -( -always -) -] -fn -is_start -( & -self -sid -: -StateID -) -- +dyn +Prefilter > -bool { -sid -= -= self . -special +prefilter +. +as_ref +( +) . -start_unanchored_id +map +( | +p | -sid -= -= -self -. -special +p . -start_anchored_id -} -# -[ -inline +as_ref ( -always ) -] +) +} fn -match_kind +start_state ( & self ) - > -MatchKind +S { self . -match_kind +start_id } -# -[ -inline -( -always -) -] fn -patterns_len +is_valid ( & self +id +: +S ) - > -usize +bool { +id +. +to_usize +( +) +< self . -pattern_lens +states . len ( ) } -# -[ -inline -( -always -) -] fn -pattern_len +is_match_state ( & self -pid +id : -PatternID +S ) - > -usize +bool { self . -pattern_lens +states [ -pid -] +id . -as_usize +to_usize ( ) -} -# -[ -inline +] +. +is_match ( -always ) -] +} fn -min_pattern_len +get_match ( & self +id +: +S +match_index +: +usize +end +: +usize ) - > -usize +Option +< +Match +> { +let +state += +match self . -min_pattern_len -} -# -[ -inline +states +. +get ( -always -) -] -fn -max_pattern_len -( -& -self -) -- -> -usize -{ -self +id . -max_pattern_len -} -# -[ -inline +to_usize ( -always ) -] -fn -match_len -( -& -self -sid -: -StateID ) -- -> -usize { -State -: -: -match_len +None += +> +return +None +Some ( -self -. -alphabet_len -& -self +state +) += +> +state +} +; +state . -repr -[ -sid +matches . -as_usize +get ( +match_index ) . -. -] +map +( +| +& +( +id +len ) +| +Match +{ +pattern +: +id +len +end } -# -[ -inline -( -always ) -] +} fn -match_pattern +match_count ( & self -sid +id : -StateID -index -: -usize +S ) - > -PatternID +usize { -State -: -: -match_pattern -( -self -. -alphabet_len -& self . -repr +states [ -sid +id . -as_usize +to_usize ( ) +] . +matches . -] -index -) -} -# -[ -inline +len ( -always ) -] +} fn -memory_usage +next_state ( & self +mut +current +: +S +input +: +u8 ) - > -usize +S { -use -core -: -: -mem -: +/ +/ +This +terminates +since : -size_of -; -( -self +/ +/ +/ +/ +1 . -repr +State . -len -( -) -* -size_of -: -: -< -u32 -> +fail +never +points +to +fail_id ( ) -) -+ -( -self . -pattern_lens +/ +/ +2 . -len -( -) -* -size_of -: -: -< -SmallIndex -> -( -) -) -+ -self +All +State . -prefilter +fail +values +point +to +a +state +closer +to +start . -as_ref +/ +/ +3 +. +The +start +state +has +no +transitions +to +fail_id ( ) . -map_or -( -0 -| -p -| -p +loop +{ +let +state += +& +self . -memory_usage -( -) -) -} -# +states [ -inline +current +. +to_usize ( -always ) ] -fn -prefilter +; +let +next += +state +. +next_state ( -& -self +input ) -- -> -Option -< -& -Prefilter -> -{ -self -. -prefilter -. -as_ref +; +if +next +! += +fail_id ( ) +{ +return +next +; } +current += +state +. +fail +; } -impl -core -: -: -fmt -: -: -Debug -for +} +} +/ +/ +/ +A +representation +of +an NFA -{ -fn -fmt +state +for +an +Aho +- +Corasick +automaton +. +/ +/ +/ +/ +/ +/ +It +contains +the +transitions +to +the +next +state +a +failure +transition +for +/ +/ +/ +cases +where +there +exists +no +other +transition +for +the +current +input +byte +/ +/ +/ +the +matches +implied +by +visiting +this +state ( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter +if +any ) -- +and +the +depth +of +this +/ +/ +/ +state +. +The +depth +of +a +state +is +simply +the +distance +from +it +to +the +start +/ +/ +/ +state +in +the +automaton +where +the +depth +of +the +start +state +is +0 +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +State +< +S > -core -: -: -fmt -: -: -Result { -use -crate -: -: -automaton -: +trans : -fmt_state_indicator -; -writeln -! -( -f -" -contiguous +Transitions +< +S +> +fail : +S +matches : -NFA +Vec +< ( -" +PatternID +PatternLength ) -? -; -let -mut -sid -= -NFA -: +> +/ +/ +TODO : -DEAD -; +Strictly +speaking +this +isn +' +t +needed +for +searching +. +It +' +s +only / / -always +used +when +building +an +NFA +that +supports +leftmost +match +semantics +. +We +/ +/ +could +drop +this +from the -first state and -always -present -loop +dynamically +build +a +map +only +when +/ +/ +computing +failure +transitions +but +it +' +s +not +clear +which +is +better +. +/ +/ +Benchmark +this +. +depth +: +usize +} +impl +< +S +: +StateID +> +State +< +S +> { -let -raw -= +fn +heap_bytes +( & self +) +- +> +usize +{ +self . -repr -[ -sid +trans . -as_usize +heap_bytes ( ) ++ +( +self . +matches . -] -; -if -raw -. -is_empty +len ( ) -{ -break -; -} -let -is_match -= -self -. -is_match -( -sid -) -; -let -state -= -State +* +size_of : : -read +< ( -self -. -alphabet_len -is_match -raw +PatternID +PatternLength ) -; -fmt_state_indicator +> ( -f -self -sid ) -? -; -write -! -( -f -" -{ -: -06 +) } +fn +add_match ( -{ +& +mut +self +i : -06 -} -) +PatternID +len : -" -sid -. -as_usize -( +PatternLength ) -state +{ +self . -fail +matches . -as_usize +push ( -) -) -? -; -state -. -fmt ( -f +i +len ) -? -; -write -! -( -f -" -\ -n -" ) -? ; -if -self -. +} +fn is_match ( -sid +& +self ) +- +> +bool { -write ! -( -f -" -matches -: -" -) -? -; -for -i -in -0 -. +self . -state +matches . -match_len -{ -let -pid -= -State -: -: -match_pattern +is_empty +( +) +} +fn +next_state ( +& self -. -alphabet_len -raw -i +input +: +u8 ) -; -if -i +- > -0 +S { -write -! +self +. +trans +. +next_state ( -f -" -" +input ) -? -; } -write -! +fn +set_next_state ( -f -" +& +mut +self +input +: +u8 +next +: +S +) { -} -" -pid +self . -as_usize +trans +. +set_next_state ( +input +next ) -) -? ; } -write -! -( -f -" -\ -n -" -) -? -; } / / -The -FAIL -state -doesn -' -t -actually -have -space +/ +Represents +the +transitions for a +single +dense state -allocated +. / / -for -it -so -we -have +/ +/ +/ +/ +The +primary +purpose +here +is to -treat -it -as -a -special -case +encapsulate +index +access . -write -below +Namely +since +a / / -the -DEAD -state -. -if -sid -= -= -NFA -: -: -DEAD -{ -writeln -! -( -f -" -F -{ -: -06 -} -: -" -NFA -: -: -FAIL +/ +dense +representation +always +contains +256 +elements +all +values +of +u8 +are +/ +/ +/ +valid +indices . -as_usize +# +[ +derive ( +Clone +Debug ) +] +struct +Dense +< +S +> +( +Vec +< +S +> ) -? ; -} -let -len -= -State -: +impl +< +S +> +Dense +< +S +> +where +S : -len -( -self -. -alphabet_len -is_match -raw -) -; -sid -= StateID -: -: +{ +fn new ( -sid -. -as_usize -( ) -. -checked_add -( -len -) -. -unwrap +- +> +Self +{ +Dense ( -) -) -. -unwrap +vec +! +[ +fail_id ( ) ; +256 +] +) } -writeln -! +# +[ +inline +] +fn +len ( -f -" -match -kind -: -{ -: -? -} -" +& self -. -match_kind ) -? -; -writeln -! -( -f -" -prefilter -: +- +> +usize { -: -? -} -" self . -prefilter +0 . -is_some +len ( ) -) -? -; -writeln -! -( -f -" -state -length -: -{ -: -? } -" -self -. -state_len -) -? -; -writeln -! -( -f -" -pattern -length -: -{ -: -? } -" -self -. -patterns_len -( -) -) -? +impl +< +S +> +Index +< +u8 +> +for +Dense +< +S +> +{ +type +Output += +S ; -writeln -! +# +[ +inline +] +fn +index ( -f -" -shortest -pattern -length +& +self +i : +u8 +) +- +> +& +S { +/ +/ +SAFETY : -? -} -" +This +is +safe +because +all +dense +transitions +have +/ +/ +exactly +256 +elements +so +all +u8 +values +are +valid +indices +. +& self . -min_pattern_len -) -? -; -writeln -! +0 +[ +i +as +usize +] +} +} +impl +< +S +> +IndexMut +< +u8 +> +for +Dense +< +S +> +{ +# +[ +inline +] +fn +index_mut ( -f -" -longest -pattern -length +& +mut +self +i : +u8 +) +- +> +& +mut +S { +/ +/ +SAFETY : -? -} -" +This +is +safe +because +all +dense +transitions +have +/ +/ +exactly +256 +elements +so +all +u8 +values +are +valid +indices +. +& +mut self . -max_pattern_len -) -? -; -writeln -! -( -f -" -alphabet -length -: -{ -: -? -} -" -self -. -alphabet_len -) -? -; -writeln -! -( -f -" -byte -classes -: -{ -: -? -} -" -self -. -byte_classes -) -? -; -writeln -! -( -f -" -memory -usage -: -{ -: -? -} -" -self -. -memory_usage -( -) -) -? -; -writeln -! -( -f -" -) -" -) -? -; -Ok -( -( -) -) +0 +[ +i +as +usize +] } } / / / -The -" -in -memory -" +A representation -a -single -dense -or -sparse -state +of +transitions +in +an +NFA . / / @@ -3423,2926 +2922,3728 @@ state / / / -A -State -' -s -in -memory +Transitions +have +either +a +sparse representation +which is -not -ever -actually -materialized -/ -/ -/ -during -a -search -with -a -contiguous -NFA -. -Doing -so -would -be -too -slow -. -( -Indeed +slower +for / / / -the -only -time +lookups +but +uses +less +memory +or a -State -is -actually -constructed +dense +representation +which is -in -Debug -impls -. -) +faster / / / -Instead -a -State -exposes -a -number -of -static -methods for -reading -certain -/ -/ -/ -things -from +lookups +but +uses +more +memory +. +In the -raw -binary -encoding -of +sparse +representation the -state -. -# -[ -derive -( -Clone -) -] -struct -State -< -' -a -> -{ +absence / / / -The +of +a state -to -transition -to -when -' -class_to_next -' -yields +implies a transition -/ -/ -/ to -the -FAIL -state +fail_id +( +) . -fail -: -StateID +Transitions +to +dead_id +( +) / / / -The -number -of -pattern -IDs -in -this -state +are +still +explicitly +represented . -For -a -non -- -match -state -this -is / / / -always -zero -. -Otherwise -it -is -always -bigger -than -zero -. -match_len -: -usize / / / -The -sparse -or +For +the +NFA +by +default +we +use +a dense representation -of -the +for transitions for -this -state -. -trans -: -StateTrans -< -' -a -> -} / / / -The -underlying -representation -of -sparse -or -dense -transitions -for -a +states +close +to +the +start state -. -/ -/ -/ -/ -/ -/ -Note -that -like -State -we -don -' -t -typically -construct -values -of -this -type -/ -/ -/ -during -a -search -since -we -don +because +it ' -t -always -need -all -values -and -thus -would +s +likely +these +are +the +states / / / -represent -a -lot -of -wasteful -work +that +will +be +most +frequently +visited . # [ derive ( Clone +Debug ) ] enum -StateTrans +Transitions < -' -a +S > { -/ -/ -/ -A -sparse -representation -of -transitions -for -a -state -where -only -non -- -FAIL -/ -/ -/ -transitions -are -explicitly -represented -. Sparse -{ -classes +( +Vec +< +( +u8 +S +) +> +) +Dense +( +Dense +< +S +> +) +} +impl +< +S : +StateID +> +Transitions +< +S +> +{ +fn +heap_bytes +( & -' -a -[ -u32 -] -/ -/ -/ -The -transitions -for -this -state -where -each -transition -is -packed -/ -/ -/ -into -a -u32 -. -The -low -8 -bits -correspond -to -the -byte -class -for -the -/ -/ -/ -transition -and -the -high -24 -bits -correspond -to -the -next -state -ID -. -/ -/ -/ -/ -/ -/ -This -packing -is -why -the -max -state -ID -allowed -for -a -contiguous -/ -/ -/ -NFA -is -2 -^ -24 +self +) - -1 +> +usize +{ +match +* +self +{ +Transitions +: +: +Sparse +( +ref +sparse +) += +> +{ +sparse . -nexts +len +( +) +* +size_of : -& -' -a -[ -u32 -] +: +< +( +u8 +S +) +> +( +) } -/ -/ -/ -A -" -one -transition -" -state -that -is -never -a -match -state +Transitions +: +: +Dense +( +ref +dense +) += +> +dense . -/ -/ -/ -/ -/ -/ -These -are -by -far -the -most -common -state -so -we -use -a -specialized -and -/ -/ -/ -very -compact -representation -for -them -. -One +len +( +) +* +size_of +: +: +< +S +> +( +) +} +} +fn +next_state +( +& +self +input +: +u8 +) +- +> +S +{ +match +* +self +{ +Transitions +: +: +Sparse +( +ref +sparse +) += +> { -/ -/ -/ -The -element -of -this -NFA -' -s -alphabet -that -this -transition -is -/ -/ -/ -defined for -. -class +& +( +b +id +) +in +sparse +{ +if +b += += +input +{ +return +id +; +} +} +fail_id +( +) +} +Transitions +: +: +Dense +( +ref +dense +) += +> +dense +[ +input +] +} +} +fn +set_next_state +( +& +mut +self +input : u8 -/ -/ -/ -The -state -this -should -transition -to -if -the -current -symbol -is -/ -/ -/ -equal -to -' -class -' +next +: +S +) +{ +match +* +self +{ +Transitions +: +: +Sparse +( +ref +mut +sparse +) += +> +{ +match +sparse +. +binary_search_by_key +( +& +input +| +& +( +b +_ +) +| +b +) +{ +Ok +( +i +) += +> +sparse +[ +i +] += +( +input +next +) +Err +( +i +) += +> +sparse . +insert +( +i +( +input next +) +) +} +} +Transitions : -u32 +: +Dense +( +ref +mut +dense +) += +> +{ +dense +[ +input +] += +next +; +} +} } / / / -A -dense -representation -of +Iterate +over transitions -for -a +in +this state -where -all -/ -/ -/ -transitions -are -explicitly -represented -including +while +skipping +over transitions -to -the -/ -/ -/ -FAIL -state -. -Dense -{ / / / -A -dense -set -of -transitions to -other -states +fail_id +( +) . -The -transitions -may -/ -/ -/ -point -to -a -FAIL -state -in -which -case -the -search -should -try -the -/ -/ -/ -same -transition -lookup -at -' -fail -' -. -/ -/ -/ -/ -/ -/ -Note -that -this -is -indexed -by -byte -equivalence -classes -and -not -/ -/ -/ -byte -values -. -That -means -' -class_to_next -[ -byte -] -' -is -wrong -and -/ -/ -/ -' -class_to_next -[ -classes -. -get +fn +iter +< +F +: +FnMut ( -byte +u8 +S ) -] -' -is -correct -. -The -number -of -/ -/ -/ -transitions -is -always -equivalent -to -' -classes -. -alphabet_len +> ( +& +self +mut +f +: +F ) -' -. -class_to_next +{ +match +* +self +{ +Transitions +: : +Sparse +( +ref +sparse +) += +> +{ +for & -' -a -[ -u32 -] +( +b +id +) +in +sparse +{ +f +( +b +id +) +; } } -impl -< -' -a -> -State -< -' -a +Transitions +: +: +Dense +( +ref +dense +) += > { -/ -/ -/ -The -offset -of -where -the -" -kind -" -of -a -state -is -stored -. -If -it -isn -' -t -one -/ -/ -/ -of -the -sentinel -values -below -then -it -' -s -a -sparse -state -and -the -kind -/ -/ -/ -corresponds -to -the -number -of -transitions +for +b in -the -state -. -const -KIND +AllBytesIter : -usize +: +new +( +) +{ +let +id = -0 -; -/ -/ -/ -A -sentinel -value -indicating -that -the -state -uses -a dense -representation -. -const -KIND_DENSE -: -u32 +[ +b +] +; +if +id +! = -0xFF +fail_id +( +) +{ +f +( +b +id +) ; +} +} +} +} +} / / / -A -sentinel -value -indicating -that -the +Iterate +over +all +transitions +in +this state -uses -a -special -" -one +according +to +the +given / / / -transition -" -encoding +equivalence +classes +including +transitions +to +fail_id +( +) . -In -practice -non -- -match -states -with -one -transition -/ -/ -/ -make -up -the -overwhelming -majority -of -all -states +fn +iter_all +< +F +: +FnMut +( +u8 +S +) +> +( +& +self +classes +: +& +ByteClasses +mut +f +: +F +) +{ +if +classes +. +is_singleton +( +) +{ +match +* +self +{ +Transitions +: +: +Sparse +( +ref +sparse +) += +> +{ +sparse_iter +( +sparse +f +) +; +} +Transitions +: +: +Dense +( +ref +dense +) += +> +{ +for +b in -any -given -/ +AllBytesIter +: +: +new +( +) +{ +f +( +b +dense +[ +b +] +) +; +} +} +} +} +else +{ / / -Aho -- -Corasick -automaton -so +In +this +case we -can -specialize -them -using +only +want +to +yield a -very -compact -/ +single +byte +for +each / / -representation +equivalence +class +. +match +* +self +{ +Transitions +: +: +Sparse +( +ref +sparse +) += +> +{ +let +mut +last_class += +None +; +sparse_iter +( +sparse +| +b +next +| +{ +let +class += +classes . -const -KIND_ONE +get +( +b +) +; +if +last_class +! += +Some +( +class +) +{ +last_class += +Some +( +class +) +; +f +( +b +next +) +; +} +} +) +} +Transitions : -u32 +: +Dense +( +ref +dense +) = -0xFE +> +{ +for +b +in +classes +. +representatives +( +) +{ +f +( +b +dense +[ +b +] +) ; +} +} +} +} +} +} / / / -The -maximum -number -of +Iterator +over transitions -to -encode -as +in a -sparse state +skipping +transitions +to +fail_id +( +) . -Usually / / / -states -with -a -lot +/ +/ +/ +This +abstracts +over +the +representation of +NFA transitions -are +which +may +be +/ +/ +/ either -very -rare +in +a +sparse or -occur -near +dense +representation +. / / / -the -start -state -. -In -the -latter -case -they -are -probably -dense -already / / / -anyway -. -In +This +somewhat +idiosyncratically +borrows the -former -case -making -them -dense -is -fine -because -they -' -re -/ -/ -/ -rare -. -/ -/ -/ -/ -/ -/ -This -needs -to -be -small -enough -to -permit -each -of -the -sentinel -values -for +NFA +mutably +so +that +when +one / / / -' -KIND -' -above -. -Namely -a -sparse -state -embeds -the -number -of +is +iterating +over transitions -/ -/ -/ -into the -' -KIND -' -. -Basically -" -sparse -" -is -a -state -kind -too -but -it -' -s +caller +can +still +mutate the -/ -/ -/ -" -else -" -branch -. -/ -/ -/ -/ -/ -/ -N -. -B -. -There -isn -' -t -anything -particularly -magical -about -127 -here +NFA . -I -/ -/ -/ -just -picked -it -because -I -figured -any -sparse -state -with -this -many +This / / / -transitions is -going -to -be -exceptionally -rare -and -if -it -did -have -this -/ -/ -/ -many -transitions -then -it -would -be -quite -slow -to -do -a -linear -scan -on -/ -/ -/ -the +useful +when +creating +failure transitions -during -a -search -anyway -. -const -MAX_SPARSE_TRANSITIONS -: -usize -= -127 -; -/ -/ -/ -Remap -state -IDs -in -- -place -. -/ -/ -/ -/ -/ -/ -state -should -be -the -the -raw -binary -encoding -of -a -state . +# +[ +derive ( -The -start -/ -/ -/ -of -the -slice -must -correspond -to -the -start -of -the -state -but -the -slice -/ -/ -/ -may -extend -past -the -end -of -the -encoding -of -the -state -. +Debug ) -fn -remap -( -alphabet_len +] +struct +IterTransitionsMut +< +' +a +S : -usize -old_to_new +StateID +> +{ +nfa : & -[ +' +a +mut +NFA +< +S +> +state_id +: +S +cur +: +usize +} +impl +< +' +a +S +: StateID -] -state +> +IterTransitionsMut +< +' +a +S +> +{ +fn +new +( +nfa : & +' +a mut -[ -u32 -] +NFA +< +S +> +state_id +: +S ) - > -Result +IterTransitionsMut < -( -) -BuildError +' +a +S > { -let -kind -= -State -: +IterTransitionsMut +{ +nfa +state_id +cur : -kind +0 +} +} +fn +nfa ( -state +& +mut +self ) -; -if -kind -= -= -State -: +- +> +& +mut +NFA +< +S +> +{ +self +. +nfa +} +} +impl +< +' +a +S : -KIND_DENSE +StateID +> +Iterator +for +IterTransitionsMut +< +' +a +S +> { -state -[ -1 -] +type +Item = -old_to_new -[ -state -[ -1 -] -. -as_usize -( -) -] -. -as_u32 ( +u8 +S ) ; -for +fn next -in -state -[ -2 +( +& +mut +self +) +- +> +Option +< +( +u8 +S +) +> +{ +match +self . +nfa . -] +states [ +self . +state_id . -alphabet_len +to_usize +( +) ] . -iter_mut +trans +{ +Transitions +: +: +Sparse ( +ref +sparse ) -{ -* -next = -old_to_new -[ -next +> +{ +if +self . -as_usize -( -) -] +cur +> += +sparse . -as_u32 +len ( ) +{ +return +None ; } -} -else -if -kind +let +i = +self +. +cur +; +self +. +cur ++ = -State -: -: -KIND_ONE -{ -state -[ 1 -] -= -old_to_new -[ -state +; +Some +( +sparse [ -1 +i ] -. -as_usize -( ) -] -. -as_u32 +} +Transitions +: +: +Dense ( +ref +dense ) -; -state -[ -2 -] = -old_to_new -[ -state -[ -2 -] +> +{ +while +self +. +cur +< +dense . -as_usize +len ( ) -] +{ +/ +/ +There +are +always +exactly +255 +transitions +in +dense +repr . -as_u32 +debug_assert +! ( +self +. +cur +< +256 ) ; -} -else -{ let -trans_len +b = -State -: -: -sparse_trans_len -( -state -) +self +. +cur +as +u8 ; let -classes_len +id = -u32_len -( -trans_len -) -; -state +dense [ -1 +b ] +; +self +. +cur ++ = -old_to_new -[ -state -[ 1 -] -. -as_usize -( -) -] -. -as_u32 -( -) ; -for -next -in -state -[ -2 -+ -classes_len -. -. -] -[ -. -. -trans_len -] -. -iter_mut +if +id +! += +fail_id ( ) { -* -next -= -old_to_new -[ -next -. -as_usize +return +Some ( -) -] -. -as_u32 ( +b +id +) ) ; } } -Ok -( -( -) -) +None +} +} +} } / / / -Returns -the -length -in -number -of -u32s -of -this -state -. -/ -/ -/ -/ -/ -/ -This -is -useful +A +simple +builder for -reading -states -consecutively -e -. -g -. -in -the -Debug -/ -/ -/ -impl -without -needing -to -store -a -separate -map -from -state -index -to -state -/ -/ -/ -identifier -. -/ -/ -/ -/ -/ -/ -state -should -be -the +configuring the -raw -binary -encoding +NFA +construction of -a -state +Aho +- +Corasick . +# +[ +derive ( -The -start -/ -/ -/ -of -the -slice -must -correspond -to -the -start -of -the -state -but -the -slice -/ -/ -/ -may -extend -past -the -end -of -the -encoding -of -the -state -. +Clone +Debug ) -fn -len -( -alphabet_len +] +pub +struct +Builder +{ +dense_depth : usize -is_match +match_kind +: +MatchKind +prefilter : bool -state +anchored : -& -[ -u32 -] +bool +ascii_case_insensitive +: +bool +} +impl +Default +for +Builder +{ +fn +default +( ) - > -usize +Builder { -let -kind_len -= -1 -; -let -fail_len -= -1 -; -let -kind -= -State +Builder +{ +dense_depth : +2 +match_kind : -kind -( -state -) -; -let -( -classes_len -trans_len -) -= -if -kind -= -= -State +MatchKind : : -KIND_DENSE -{ +default ( -0 -alphabet_len ) -} -else -if -kind -= -= -State +prefilter +: +true +anchored : +false +ascii_case_insensitive : -KIND_ONE +false +} +} +} +impl +Builder { +pub +fn +new ( -0 -1 ) -} -else +- +> +Builder { -let -trans_len -= -State +Builder : : -sparse_trans_len -( -state -) -; -let -classes_len -= -u32_len -( -trans_len -) -; +default ( -classes_len -trans_len ) } -; -let -match_len -= -if -! -is_match -{ -0 -} -else -if -State -: +pub +fn +build +< +I +P +S : -match_len +StateID +> ( -alphabet_len -state +& +self +patterns +: +I ) -= -= -1 -{ -/ -/ -This -is -a -special -case -because -when -there -is -one -pattern -ID -for -/ -/ -a -match -state -it -is -represented -by -a -single -u32 -with -its -high -/ -/ -bit -set +- +> +Result +< +NFA +< +S +> +> +where +I +: +IntoIterator +< +Item += +P +> +P +: +AsRef +< +[ +u8 +] +> +{ +Compiler +: +: +new ( -which -is -impossible -for -a -valid -pattern -ID +self ) +? . -1 +compile +( +patterns +) } -else +pub +fn +match_kind +( +& +mut +self +kind +: +MatchKind +) +- +> +& +mut +Builder { -/ -/ -We -add -1 -to -include -the -u32 -that -indicates -the -number -of -/ -/ -pattern -IDs -that -follow +self . -1 -+ -State +match_kind += +kind +; +self +} +pub +fn +dense_depth +( +& +mut +self +depth : +usize +) +- +> +& +mut +Builder +{ +self +. +dense_depth += +depth +; +self +} +pub +fn +prefilter +( +& +mut +self +yes : -match_len +bool +) +- +> +& +mut +Builder +{ +self +. +prefilter += +yes +; +self +} +pub +fn +anchored ( -alphabet_len -state +& +mut +self +yes +: +bool ) +- +> +& +mut +Builder +{ +self +. +anchored += +yes +; +self } +pub +fn +ascii_case_insensitive +( +& +mut +self +yes +: +bool +) +- +> +& +mut +Builder +{ +self +. +ascii_case_insensitive += +yes ; -kind_len -+ -fail_len -+ -classes_len -+ -trans_len -+ -match_len +self +} } / / / -Returns +A +compiler +uses +a +builder +configuration +and +builds +up the -kind -of -this -state -. +NFA +formulation / / / +of +an +Aho +- +Corasick +automaton +. +This +roughly +corresponds +to +the +standard / / / -This -only -includes -the -low -byte +formulation +described +in +textbooks . # [ -inline +derive ( -always +Debug ) ] -fn -kind -( -state -: -& -[ -u32 -] -) -- +struct +Compiler +< +' +a +S +: +StateID > -u32 { -state -[ -State -: +builder : -KIND -] & -0xFF -} -/ -/ -/ -Get -the -number -of -sparse -transitions -in -this -state -. -This -can -never -/ -/ -/ -be -more -than -State +' +a +Builder +prefilter : +prefilter : -MAX_SPARSE_TRANSITIONS -as -all -states -with -more -/ -/ -/ -transitions -are -encoded -as -dense -states -. -/ -/ -/ -/ -/ -/ -state -should -be -the -the -raw -binary -encoding -of -a -sparse -state -. -( -The -/ -/ -/ -start -of -the -slice -must -correspond -to -the -start -of -the -state -but -the -/ -/ -/ -slice -may -extend -past -the -end -of -the -encoding -of -the -state -. -) -If -this -/ -/ -/ -isn +: +Builder +nfa +: +NFA +< +S +> +byte_classes +: +ByteClassBuilder +} +impl +< ' -t -a -sparse -state -then -the -return -value -is -unspecified -. -/ -/ -/ -/ -/ -/ -Do -note -that -this -is -only -legal -to -call -on -a -sparse -state -. -So -for -/ -/ -/ -example -" -one -transition -" -state -is -not a -sparse -state -so -it -would -not -/ -/ -/ -be -legal -to -call -this -method -on -such +S +: +StateID +> +Compiler +< +' a -state -. -# -[ -inline -( -always -) -] +S +> +{ fn -sparse_trans_len +new ( -state +builder : & -[ -u32 -] +' +a +Builder ) - > -usize +Result +< +Compiler +< +' +a +S +> +> { +Ok ( -state -[ -State +Compiler +{ +builder +prefilter : +prefilter : -KIND -] -& -0xFF +: +Builder +: +: +new +( +builder +. +match_kind ) . -as_usize +ascii_case_insensitive ( +builder +. +ascii_case_insensitive ) -} -/ -/ -/ -Returns -the -total -number -of -matching -pattern -IDs -in -this -state +nfa +: +NFA +{ +match_kind +: +builder . -Calling -/ -/ -/ -this -on -a -state -that -isn -' -t -a -match -results -in -unspecified -behavior -. -/ -/ -/ -Thus -the -returned -number -is -never +match_kind +start_id +: +usize_to_state_id +( +2 +) +? +max_pattern_len +: 0 -for -all -correct -calls -. -/ -/ -/ -/ -/ -/ -state -should -be -the -the -raw -binary -encoding -of -a -state +pattern_count +: +0 +heap_bytes +: +0 +prefilter +: +None +anchored +: +builder . +anchored +byte_classes +: +ByteClasses +: +: +singletons ( -The -start -/ -/ -/ -of -the -slice -must -correspond -to -the -start -of -the -state -but -the -slice -/ -/ -/ -may -extend -past -the -end -of -the -encoding -of -the -state -. ) -# +states +: +vec +! [ -inline +] +} +byte_classes +: +ByteClassBuilder +: +: +new ( -always ) -] +} +) +} fn -match_len +compile +< +I +P +> ( -alphabet_len +mut +self +patterns : -usize -state +I +) +- +> +Result +< +NFA +< +S +> +> +where +I : -& +IntoIterator +< +Item += +P +> +P +: +AsRef +< [ -u32 +u8 ] -) -- > -usize { +self +. +add_state +( +0 +) +? +; / / -We -don -' -t -need -to -handle -KIND_ONE -here -because -it -can +the +fail +state +which +is never -be -a +entered +self +. +add_state +( +0 +) +? +; / / -match +the +dead state +only +used +for +leftmost +self . -let -packed -= -if -State -: -: -kind +add_state ( -state +0 ) -= -= -State -: -: -KIND_DENSE -{ -let -start -= -2 -+ -alphabet_len +? ; -state -[ +/ +/ +the start -] +state +self . -as_usize -( -) -} -else -{ -let -trans_len -= -State -: -: -sparse_trans_len +build_trie ( -state +patterns ) +? ; -let -classes_len -= -u32_len +self +. +add_start_state_loop ( -trans_len ) ; -let -start -= -2 -+ -classes_len -+ -trans_len -; -state -[ -start -] +self . -as_usize +add_dead_state_loop ( ) -} ; if -packed -& -( -1 -< -< -31 -) -= -= -0 +! +self +. +builder +. +anchored { -packed +self +. +fill_failure_transitions +( +) +; } -else +self +. +close_start_state_loop +( +) +; +self +. +nfa +. +byte_classes += +self +. +byte_classes +. +build +( +) +; +if +! +self +. +builder +. +anchored { -1 +self +. +nfa +. +prefilter += +self +. +prefilter +. +build +( +) +; } +self +. +calculate_size +( +) +; +Ok +( +self +. +nfa +) } / / / -Returns -the -pattern -ID -corresponding -to +This +sets +up the -given -index -for +initial +prefix +trie +that +makes +up the -state +Aho +- +Corasick / / / -given +automaton . -The -index -provided -must -be -less -than +Effectively +it +creates the -number +basic +structure of -pattern -IDs -/ -/ -/ -in -this -state -. -/ -/ -/ -/ -/ -/ -state -should -be the -the -raw -binary -encoding -of -a -state -. -( -The -start -of / / / -the -slice -must -correspond -to +automaton +where +every +pattern +given +has +a +path +from the start -of -the state -but -the -slice -may +to / / / -extend -past the end of the -encoding -of -the -state -. -) -/ -/ -/ -/ -/ -/ -If -the -given -state -is -not -a -match -state -or -if -the -index -is -out -of -/ -/ -/ -bounds -then -this -has -unspecified -behavior +pattern . -# -[ -inline +fn +build_trie +< +I +P +> ( -always +& +mut +self +patterns +: +I ) -] -fn -match_pattern +- +> +Result +< ( -alphabet_len +) +> +where +I : -usize -state +IntoIterator +< +Item += +P +> +P : -& +AsRef +< [ -u32 +u8 ] -index -: -usize -) -- > -PatternID { -/ -/ -We -don ' -t -need -to -handle -KIND_ONE -here -because -it -can -never -be -a -/ -/ -match -state -. -let -start -= -if -State +PATTERNS : -: -kind +for +( +pati +pat +) +in +patterns +. +into_iter +( +) +. +enumerate ( -state ) -= -= -State -: -: -KIND_DENSE -{ -2 -+ -alphabet_len -} -else { let -trans_len +pat = -State -: -: -sparse_trans_len +pat +. +as_ref ( -state ) ; -let -classes_len +self +. +nfa +. +max_pattern_len = -u32_len +cmp +: +: +max +( +self +. +nfa +. +max_pattern_len +pat +. +len ( -trans_len +) ) ; -2 -+ -classes_len +self +. +nfa +. +pattern_count + -trans_len -} += +1 ; let -packed +mut +prev = -state -[ -start -] +self +. +nfa +. +start_id ; let -pid -= -if -packed -& -( -1 -< -< -31 -) -= +mut +saw_match = -0 -{ -state -[ -start -+ -1 -+ -index -] -} -else -{ -assert_eq -! -( -0 -index -) +false ; -packed +for +( +depth & -! +b +) +in +pat +. +iter ( -1 -< -< -31 ) -} -; -PatternID -: -: -from_u32_unchecked +. +enumerate ( -pid ) -} -/ +{ / / -Read -a -state -' -s -binary -encoding -to -its -in +When +leftmost - -memory -representation -. +first +match +semantics +are +requested +we / / +specifically +stop +adding +patterns +when +a +previously +added / / +pattern +is +a +prefix +of +it +. +We +avoid +adding +it +because / / -alphabet_len -should -be +leftmost +- +first +semantics +imply +that the -total -number -of -transitions -defined -for -/ +pattern +can +never / / -dense -states +match . +This +is +not +just +an +optimization +to +save +space +! +It / / +is +necessary +for +correctness +. +In +fact +this +is +the +only / / +difference +in +the +automaton +between +the +implementations +for / / +leftmost +- +first +and +leftmost +- +longest +. +saw_match += +saw_match +| +| +self +. +nfa +. +state +( +prev +) +. is_match -should -be -true +( +) +; if -this -state -is -a -match -state -and -false -/ +self +. +builder +. +match_kind +. +is_leftmost_first +( +) +& +& +saw_match +{ / / -otherwise +Skip +to +the +next +pattern +immediately . +This +avoids / / +incorrectly +adding +a +match +after +this +loop +terminates +. +continue +' +PATTERNS +; +} / / +Add +this +byte +to +our +equivalence +classes +. +We +don +' +t +use +these / / -state -should +for +NFA +construction +. +These +are +instead +used +only +if +we +' +re +/ +/ +building +a +DFA +. +They +would +technically be +useful +for the -the -raw -binary -encoding -of +/ +/ +NFA +but +it +would +require a -state +second +pass +over +the +patterns +. +self . +byte_classes +. +set_range ( -The -start +b +b +) +; +if +self +. +builder +. +ascii_case_insensitive +{ +let +b += +opposite_ascii_case +( +b +) +; +self +. +byte_classes +. +set_range +( +b +b +) +; +} +/ +/ +If +the +transition +from +prev +using +the +current +byte +already +/ / +exists +then +just +move +through +it +. +Otherwise +add +a +new / / -of +state +. +We +track the -slice -must -correspond +depth +here +so +that +we +can +determine +/ +/ +how to +represent +transitions +. +States +near the start -of -the state -but -the -slice / / +use +a +dense +representation +that +uses +more +memory +but +is +/ / -may -extend -past -the -end -of -the -encoding -of -the -state +faster . -) -fn -read -( -alphabet_len -: -usize -is_match -: -bool -state -: -& -' -a -[ -u32 -] -) -- -> -State -< -' +Other +states +use a -> -{ +sparse +representation +that +uses +/ +/ +less +memory +but +is +slower +. let -kind +next = -State -: -: -kind -( +self +. +nfa +. state +( +prev +) +. +next_state +( +b ) ; -let -match_len -= if +next ! -is_match += +fail_id +( +) { -0 +prev += +next +; } else { -State -: -: -match_len +let +next += +self +. +add_state ( -alphabet_len -state +depth ++ +1 ) -} +? ; -let +self +. +nfa +. +state_mut ( -trans -fail +prev ) -= +. +set_next_state +( +b +next +) +; if -kind -= -= -State -: -: -KIND_DENSE +self +. +builder +. +ascii_case_insensitive { let -fail +b = -StateID -: -: -from_u32_unchecked +opposite_ascii_case ( -state -[ -1 -] +b ) ; -let -class_to_next -= -& -state -[ -2 -. -. -] -[ -. +self . -alphabet_len -] -; -( -StateTrans -: -: -Dense -{ -class_to_next -} -fail -) -} -else -if -kind -= -= -State -: -: -KIND_ONE -{ -let -fail -= -StateID -: -: -from_u32_unchecked -( -state -[ -1 -] -) -; -let -class -= -state -[ -State -: -: -KIND -] +nfa . -low_u16 +state_mut ( +prev ) . -high_u8 +set_next_state ( +b +next ) ; -let -next +} +prev = -state -[ -2 -] -; -( -StateTrans -: -: -One -{ -class next +; } -fail -) } -else -{ -let -fail -= -StateID -: -: -from_u32_unchecked -( +/ +/ +Once +the +pattern +has +been +added +log +the +match +in +the +final +/ +/ state -[ -1 -] -) -; -let -trans_len -= -State -: -: -sparse_trans_len +that +it +reached +. +self +. +nfa +. +state_mut ( -state +prev ) -; -let -classes_len -= -u32_len +. +add_match +( +pati +pat +. +len ( -trans_len +) ) ; -let -classes -= -& -state -[ -2 +/ +/ . . -] -[ . +and +hand +it +to +the +prefilter +builder +if +applicable . -classes_len -] -; -let -nexts -= -& -state -[ -2 -+ -classes_len +if +self . +builder . -] -[ +prefilter +{ +self . +prefilter . -trans_len -] -; +add ( -StateTrans -: -: -Sparse -{ -classes -nexts -} -fail +pat ) -} ; -State -{ -fail -match_len -trans } } +Ok +( +( +) +) +} +/ +/ +/ +This +routine +creates +failure +transitions +according +to +the +standard +/ +/ +/ +textbook +formulation +of +the +Aho +- +Corasick +algorithm +with +a +couple +small +/ +/ +/ +tweaks +to +support +" +leftmost +" +semantics +. +/ +/ +/ +/ +/ +/ +Building +failure +transitions +is +the +most +interesting +part +of +building +/ +/ +/ +the +Aho +- +Corasick +automaton +because +they +are +what +allow +searches +to +/ +/ +/ +be +performed +in +linear +time +. +Specifically +a +failure +transition +is +/ +/ +/ +a +single +transition +associated +with +each +state +that +points +back +to +/ +/ +/ +the +longest +proper +suffix +of +the +pattern +being +searched +. +The +failure +/ +/ +/ +transition +is +followed +whenever +there +exists +no +transition +on +the +/ +/ +/ +current +state +for +the +current +input +byte +. +If +there +is +no +other +proper +/ +/ +/ +suffix +then +the +failure +transition +points +back +to +the +starting +state +. +/ +/ +/ +/ +/ +/ +For +example +let +' +s +say +we +built +an +Aho +- +Corasick +automaton +with +the +/ +/ +/ +following +patterns +: +' +abcd +' +and +' +cef +' +. +The +trie +looks +like +this +: +/ +/ +/ +/ +/ +/ +ignore +/ +/ +/ +a +- +S1 +- +b +- +S2 +- +c +- +S3 +- +d +- +S4 +* +/ +/ +/ +/ +/ +/ +/ +S0 +- +c +- +S5 +- +e +- +S6 +- +f +- +S7 +* +/ +/ +/ +/ +/ +/ +/ +/ +/ +At +this +point +it +should +be +fairly +straight +- +forward +to +see +how +this +/ +/ +/ +trie +can +be +used +in +a +simplistic +way +. +At +any +given +position +in +the +/ +/ +/ +text +we +' +re +searching +( +called +the +" +subject +" +string +) +all +we +need +to +do +/ +/ +/ +is +follow +the +transitions +in +the +trie +by +consuming +one +transition +for +/ +/ +/ +each +byte +in +the +subject +string +. +If +we +reach +a +match +state +then +we +can +/ +/ +/ +report +that +location +as +a +match +. +/ +/ +/ +/ +/ +/ +The +trick +comes +when +searching +a +subject +string +like +' +abcef +' +. +We +' +ll +/ +/ +/ +initially +follow +the +transition +from +S0 +to +S1 +and +wind +up +in +S3 +after +/ +/ +/ +observng +the +' +c +' +byte +. +At +this +point +the +next +byte +is +' +e +' +but +state +/ +/ +/ +S3 +has +no +transition +for +' +e +' +so +the +search +fails +. +We +then +would +need +/ +/ +/ +to +restart +the +search +at +the +next +position +in +' +abcef +' +which +/ +/ +/ +corresponds +to +' +b +' +. +The +match +would +fail +but +the +next +search +starting +/ +/ +/ +at +' +c +' +would +finally +succeed +. +The +problem +with +this +approach +is +that +/ +/ +/ +we +wind +up +searching +the +subject +string +potentially +many +times +. +In +/ +/ +/ +effect +this +makes +the +algorithm +have +worst +case +O +( +n +* +m +) +complexity +/ +/ +/ +where +n +~ +len +( +subject +) +and +m +~ +len +( +all +patterns +) +. +We +would +instead +/ +/ +/ +like +to +achieve +a +O +( +n ++ +m +) +worst +case +complexity +. +/ +/ +/ +/ +/ +/ +This +is +where +failure +transitions +come +in +. +Instead +of +dying +at +S3 +in +/ +/ +/ +the +first +search +the +automaton +can +instruct +the +search +to +move +to +/ +/ +/ +another +part +of +the +automaton +that +corresponds +to +a +suffix +of +what +/ +/ +/ +we +' +ve +seen +so +far +. +Recall +that +we +' +ve +seen +' +abc +' +in +the +subject +string +/ +/ +/ +and +the +automaton +does +indeed +have +a +non +- +empty +suffix +' +c +' +that +could +/ +/ +/ +potentially +lead +to +another +match +. +Thus +the +actual +Aho +- +Corasick +/ +/ +/ +automaton +for +our +patterns +in +this +case +looks +like +this +: +/ +/ +/ +/ +/ +/ +ignore +/ +/ +/ +a +- +S1 +- +b +- +S2 +- +c +- +S3 +- +d +- +S4 +* +/ +/ +/ +/ +/ +/ +/ +/ +/ +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +/ +/ +/ +/ +/ +/ +/ +/ +S0 +- +c +- +S5 +- +e +- +S6 +- +f +- +S7 +* +/ +/ +/ +/ +/ +/ +/ +/ +/ +That +is +we +have +a +failure +transition +from +S3 +to +S5 +which +is +followed +/ +/ +/ +exactly +in +cases +when +we +are +in +state +S3 +but +see +any +byte +other +than +/ +/ +/ +' +d +' +( +that +is +we +' +ve +" +failed +" +to +find +a +match +in +this +portion +of +our +/ +/ +/ +trie +) +. +We +know +we +can +transition +back +to +S5 +because +we +' +ve +already +seen +/ +/ +/ +a +' +c +' +byte +so +we +don +' +t +need +to +re +- +scan +it +. +We +can +then +pick +back +up +/ +/ +/ +with +the +search +starting +at +S5 +and +complete +our +match +. +/ +/ +/ +/ +/ +/ +Adding +failure +transitions +to +a +trie +is +fairly +simple +but +subtle +. +The +/ +/ +/ +key +issue +is +that +you +might +have +multiple +failure +transition +that +you +/ +/ +/ +need +to +follow +. +For +example +look +at +the +trie +for +the +patterns +/ +/ +/ +' +abcd +' +' +b +' +' +bcd +' +and +' +cd +' +: +/ +/ +/ +/ +/ +/ +ignore +/ +/ +/ +- +a +- +S1 +- +b +- +S2 +* +- +c +- +S3 +- +d +- +S4 +* +/ +/ +/ +/ +/ +/ +/ +/ +/ +/ +- +- +- +- +- +- +- +- +- +- +- +- +- +- +/ +/ +/ +/ +/ +/ +/ +/ +/ +S0 +- +- +- +b +- +S5 +* +- +c +- +S6 +- +d +- +S7 +* +/ +/ +/ +\ +/ +/ +/ +/ +\ +- +- +- +- +- +- +- +- +/ +/ +/ +\ +/ +/ +/ +/ +- +c +- +S8 +- +d +- +S9 +* +/ +/ +/ +/ +/ +/ +/ +/ +/ +The +failure +transitions +for +this +trie +are +defined +from +S2 +to +S5 +/ +/ +/ +S3 +to +S6 +and +S6 +to +S8 +. +Moreover +state +S2 +needs +to +track +that +it +/ +/ +/ +corresponds +to +a +match +since +its +failure +transition +to +S5 +is +itself +/ +/ +/ +a +match +state +. / / / -Encode -the -" -old -" -state -from -a -noncontiguous -NFA -to -its -binary / / / -representation +Perhaps +simplest +way to -the -given -dst -slice -. -classes -should -be -the -byte +think +about +adding +these +failure +transitions / / / -classes -computed -for -the -noncontiguous -NFA -that +is +recursively +. +That +is +if +you +know the -given -state -came +failure +transitions +for +every / / / -from +possible +previous +state +that +could +be +visited +( +e +. +g . +when +computing +the / / / +failure +transition +for +S3 +you +already +know +the +failure +transitions / / / -This -returns -an -error -if -dst -became -so -big -that -StateID -s +for +S0 +S1 +and +S2 +) +then +you can -no +simply +follow +the +failure +transition / / / -longer -be -created -for -new -states -. -Otherwise -it -returns +of the +previous state -ID -of +and +check +whether +the +incoming +transition +is / / / +defined +after +following the -new -state -created +failure +transition . / / @@ -6350,840 +6651,806 @@ created / / / -When -force_dense -is -true -then +For +example +when +determining the -encoded +failure state -will -always -use -a +for +S3 +by +our / / / -dense -format -. -Otherwise -the -choice -between -dense -and -sparse -will -be +assumptions +we +already +know +that +there +is +a +failure +transition +from / / / -automatically -chosen -based -on +S2 +( the -old +previous state -. -fn -write -( -nnfa -: -& -noncontiguous -: -: -NFA -oldsid -: -StateID -old -: -& -noncontiguous -: -: -State -classes -: -& -ByteClasses -dst -: -& -mut -Vec -< -u32 -> -force_dense -: -bool -) -- -> -Result -< -StateID -BuildError -> -{ -let -sid -= -StateID -: -: -new -( -dst -. -len -( -) -) -. -map_err -( -| -e -| -{ -BuildError -: -: -state_id_overflow -( -StateID -: -: -MAX -. -as_u64 -( ) -e +to +S5 . -attempted -( -) -) -} -) -? -; -let -old_len -= -nnfa +So +we +follow +that +transition +and +check +/ +/ +/ +whether +the +transition +connecting +S2 +to +S3 +is +defined . -iter_trans -( -oldsid -) +Indeed +it +is +/ +/ +/ +as +there +is +a +transition +from +S5 +to +S6 +for +the +byte +' +c +' . -count -( -) -; +If +no +such / / -For -states -with -a -lot -of -transitions +/ +transition +existed we -might -as -well -just -make +could +keep +following +the +failure +transitions / / -them -dense -. -These -kinds -of -hot -states -tend -to -be -very -rare -so +/ +until we -' -re +reach +the +start +state +which +is +the +failure +transition +for / / -okay -with -it -. -This -also -gives -us -more -sentinels -in -the +/ +every state -' -s +that +has +no +corresponding +proper +suffix +. / / +/ +/ +/ +/ +We +don ' -kind -' -which -lets -us -create -different -state -kinds +t +actually +use +recursion to -save -on +implement +this +but +instead +use +a / / -space -. -let -kind -= -if -force_dense -| -| -old_len -> -State -: -: -MAX_SPARSE_TRANSITIONS -{ -State -: -: -KIND_DENSE -} -else -if -old_len -= -= -1 -& -& -! -old +/ +breadth +first +search +of +the +automaton . -is_match -( -) -{ -State -: -: -KIND_ONE -} -else -{ +Our +base +case +is +the +start +/ / / -For -a -sparse state -the -kind +whose +failure +transition is just -the -number +a +transition +to +itself +. +/ +/ +/ +/ +/ +/ +When +building +a +leftmost +automaton +we +proceed +as +above +but +only +/ +/ +/ +include +a +subset of +failure transitions . -u32 -: -: -try_from -( -old_len -) -. -unwrap -( -) -} -; -if -kind -= -= -State -: -: -KIND_DENSE -{ -dst -. -push -( -kind -) -; -dst -. -push -( -old -. -fail -( -) -. -as_u32 -( -) -) -; -State -: -: -write_dense_trans -( -nnfa -oldsid -classes -dst -) -? -; -} -else -if -kind -= -= -State -: -: -KIND_ONE -{ -let -t -= -nnfa -. -iter_trans -( -oldsid -) -. -next -( -) -. -unwrap -( -) -; -let -class -= -u32 -: -: -from -( -classes -. -get -( -t -. -byte -( -) -) -) -; -dst +Namely +we +omit +any +failure +/ +/ +/ +transitions +that +appear +after +a +match +state +in +the +trie . -push -( -kind -| -( -class -< -< -8 -) -) -; -dst +This +is +/ +/ +/ +because +failure +transitions +always +point +back +to +a +proper +suffix +of +/ +/ +/ +what +has +been +seen +so +far . -push -( -old +Thus +following +a +failure +transition +after +/ +/ +/ +a +match +implies +looking +for +a +match +that +starts +after +the +one +that +has +/ +/ +/ +already +been +seen +which +is +of +course +therefore +not +the +leftmost +match . -fail -( -) +/ +/ +/ +/ +/ +/ +N +. +B . -as_u32 +I +came +up +with +this +algorithm +on +my +own +and +after +scouring +all +of +/ +/ +/ +the +other +AC +implementations +I +know +of ( +Perl +Snort +many +on +GitHub ) -) -; -dst . -push -( +/ +/ +/ +I +couldn +' t +find +any +that +implement +leftmost +semantics +like +this . -next -( -) +/ +/ +/ +Perl +of +course +needs +leftmost +- +first +semantics +but +they +implement +it +/ +/ +/ +with +a +seeming +hack +at +* +search +* +time +instead +of +encoding +it +into +the +/ +/ +/ +automaton +. +There +are +also +a +couple +Java +libraries +that +support +leftmost +/ +/ +/ +longest +semantics +but +they +do +it +by +building +a +queue +of +matches +at +/ +/ +/ +search +time +which +is +even +worse +than +what +Perl +is +doing . -as_u32 +- +- +- +AG +fn +fill_failure_transitions ( +& +mut +self ) -) -; -} -else { -dst -. -push -( +let kind -) -; -dst -. -push -( -old -. -fail -( -) += +self . -as_u32 -( -) -) -; -State -: -: -write_sparse_trans +match_kind ( -nnfa -oldsid -classes -dst ) -? ; -} / / -Now -finally -write -the -number +Initialize +the +queue +for +breadth +first +search +with +all +transitions +/ +/ +out of -matches -and the -matches -themselves +start +state . -if -old +We +handle +the +start +state +specially +because +/ +/ +we +only +want +to +follow +non +- +self +transitions +. +If +we +followed +self +/ +/ +transitions +then +this +would +never +terminate . -is_match -( -) -{ let -matches_len +mut +queue = -nnfa -. -iter_matches +VecDeque +: +: +new ( -oldsid ) +; +let +mut +seen += +self . -count +queued_set ( ) ; -if -matches_len -= -= -1 -{ let -pid +mut +it = -nnfa +self . -iter_matches -( -oldsid -) +nfa . -next +iter_transitions_mut ( -) +self . -unwrap -( -) +nfa . -as_u32 -( +start_id ) ; -assert_eq -! +while +let +Some ( -0 -pid -& ( -1 -< -< -31 +_ +next ) ) -; -dst += +it . -push -( +next ( -1 -< -< -31 -) -| -pid ) -; -} -else { -assert_eq -! -( -0 -matches_len -& -( -1 -< -< -31 -) -) -; -dst -. -push -( -matches_len -. -as_u32 -( -) -) -; -dst +/ +/ +Skip +anything +we +' +ve +seen +before +and +any +self +- +transitions +on +the +/ +/ +start +state . -extend -( -nnfa +if +next += += +it . -iter_matches +nfa ( -oldsid ) . -map -( +start_id | -pid | -pid +seen . -as_u32 +contains ( +next ) -) -) +{ +continue ; } -} -Ok +queue +. +push_back ( -sid +next ) -} +; +seen +. +insert +( +next +) +; +/ / +Under +leftmost +semantics +if +a +state +immediately +following / / -Encode the -" -old -" +start state -transitions -from +is a -noncontiguous -NFA +match +state +then +we +never +want to -its / / -/ -binary -sparse -representation -to +follow +its +failure +transition +since the -given -dst -slice -. -classes -should -/ +failure +transition / / -be -the -byte -classes -computed -for -the -noncontiguous -NFA -that +necessarily +leads +back +to the -given -/ -/ -/ +start state -came -from -. -/ +which +we +never / / +want +to +do +for +leftmost +matching +after +a +match +has +been / / +found +. / -This -returns -an -error -if -dst -became -so -big -that -StateID -s -can -no / / / -longer -be -created -for -new +We +apply +the +same +logic +to +non +- +start states +below +as +well . -fn -write_sparse_trans +if +kind +. +is_leftmost ( -nnfa -: -& -noncontiguous -: -: -NFA -oldsid -: -StateID -classes -: +) & -ByteClasses -dst -: & -mut -Vec -< -u32 -> +it +. +nfa +( ) -- -> -Result -< +. +state +( +next +) +. +is_match ( ) -BuildError -> { -let +it +. +nfa ( -mut -chunk -mut -len ) +. +state_mut +( +next +) +. +fail = +dead_id ( -[ -0 -; -4 -] -0 ) ; -for -t -in -nnfa +} +} +while +let +Some +( +id +) += +queue . -iter_trans +pop_front ( -oldsid ) { -chunk -[ -len -] +let +mut +it = -classes +self . -get -( -t +nfa . -byte +iter_transitions_mut ( +id ) -) -; -len -+ -= -1 ; -if -len -= -= -4 -{ -dst -. -push +while +let +Some ( -u32 -: -: -from_ne_bytes ( -chunk +b +next ) ) -; -chunk -= -[ -0 -; -4 -] -; -len = -0 -; -} -} +it +. +next +( +) +{ if -len -> -0 +seen +. +contains +( +next +) { / / -In -the -case -where -the -number -of -transitions -isn -' -t -divisible +The +only +way +to +visit +a +duplicate +state +in +a +transition / / -by -4 -the -last -u32 -chunk -will -have -some -left -over -room +list +is +when +ASCII +case +insensitivity +is +enabled . In / @@ -7191,1928 +7458,1768 @@ In this case we -" -just -" -repeat -the -last -equivalence -class +want +to +skip +it +since +it +' +s +redundant +work . -By -/ -/ -doing -this -we -know -the -leftover -faux -transitions -will -never / / -be -followed -because -if -they -were +But it would -have -been -followed +also +end +up +duplicating +matches +which / / -prior -to -it +results +in +reporting +duplicate +matches in -the -last -equivalence -class -. -This -saves -us some +cases +. / / -branching -in +See the -search -time -state -transition -code -. -let -repeat -= -chunk -[ -len -- -1 -] -; -while -len -< -4 -{ -chunk -[ -len -] -= -repeat -; -len -+ -= -1 -; -} -dst -. -push -( -u32 -: -: -from_ne_bytes -( -chunk -) -) +' +acasei010 +' +regression +test +. +continue ; } -for -t -in -nnfa -. -iter_trans -( -oldsid -) -{ -dst +queue . -push +push_back ( -t -. next -( ) +; +seen . -as_u32 +insert ( -) +next ) ; -} -Ok -( -( -) -) -} / / +As +above +for +start +states +under +leftmost +semantics +once +/ / -Encode -the -" -old -" -state -transitions -from +we +see a -noncontiguous -NFA -to -its +match +all +subsequent +states +should +have +no +failure +/ / +transitions +because +failure +transitions +always +imply +looking / / -binary -dense -representation +for +a +match +that +is +a +suffix +of +what +has +been +seen +so +far +/ +/ +( +where +" +seen +so +far +" +corresponds to the -given -dst -slice -. -classes -should -/ +string +formed +by / / -be +following the -byte -classes -computed -for +transitions +from the -noncontiguous -NFA -that +start +state +to the -given -/ / / +current state -came -from +) . +Under +leftmost +semantics +we +specifically +do / / +not +want +to +allow +this +to +happen +because +we +always +want +to / / +report +the +match +found +at +the +leftmost +position +. +/ / / -This -returns -an -error -if -dst -became -so -big -that -StateID -s -can -no / +The +difference +between +leftmost +- +first +and +leftmost +- +longest / / -longer -be -created -for -new -states +occurs +previously +while +we +build +the +trie . -fn -write_dense_trans -( -nnfa -: -& -noncontiguous -: -: -NFA -oldsid -: -StateID -classes -: -& -ByteClasses -dst -: -& -mut -Vec -< -u32 -> -) +For +/ +/ +leftmost - -> -Result -< -( -) -BuildError -> -{ +first +we +simply +omit +any +entries +that +would / / -Our -byte -classes -let -us -shrink +otherwise +require +passing +through +a +match +state +. +/ +/ +/ +/ +Note +that +for +correctness the -size -of -our -dense -states +failure +transition +has to -the +be / / -number -of -equivalence -classes -instead -of -just -fixing -it +set to -256 -. +the +dead +state +for +ALL +states +following +a +match +not / / -Any -non -- -explicitly -defined -transition -is just -a +the +match +state +itself +. +However +by +setting +the +failure +/ +/ transition to the -/ -/ -FAIL +dead state -so -we -fill -that -in -first -and -then -overwrite -them -with +on +all +match +states +the +dead / / -explicitly -defined -transitions -. -( -Most +state +will +automatically +propagate +to +all +subsequent states -probably -only -have -one / / -or -two -explicitly -defined -transitions +via +the +failure +state +computation +below +. +if +kind . +is_leftmost +( ) -/ -/ -/ -/ -N +& +& +it . -B +nfa +( +) . -Remember -that -while -building -the -contiguous -NFA -we -use state -/ -/ -IDs -from -the -noncontiguous -NFA +( +next +) . -It -isn -' -t -until -we -' -ve -added -all -/ -/ -states -that -we -go -back -and -map -noncontiguous -IDs -to -contiguous -IDs +is_match +( +) +{ +it . +nfa +( +) +. +state_mut +( +next +) +. +fail += +dead_id +( +) +; +continue +; +} let -start +mut +fail = -dst +it . -len +nfa +( +) +. +state ( +id ) +. +fail ; -dst +while +it . -extend +nfa ( -core -: -: -iter -: -: -repeat +) +. +state ( -noncontiguous -: -: -NFA -: -: -FAIL +fail +) . -as_u32 +next_state +( +b +) += += +fail_id ( ) +{ +fail += +it +. +nfa +( ) . -take +state ( -classes +fail +) +. +fail +; +} +fail += +it . -alphabet_len +nfa ( ) +. +state +( +fail ) +. +next_state +( +b ) ; -assert -! +it +. +nfa +( +) +. +state_mut +( +next +) +. +fail += +fail +; +it +. +nfa +( +) +. +copy_matches ( +fail +next +) +; +} +/ +/ +If +the +start +state +is +a +match +state +then +this +automaton +can +/ +/ +match +the +empty +string +. +This +implies +all +states +are +match +states +/ +/ +since +every +position +matches +the +empty +string +so +copy +the +/ +/ +matches +from +the +start +state +to +every +state +. +Strictly +speaking +/ +/ +this +is +only +necessary +for +overlapping +matches +since +each +/ +/ +non +- +empty +non +- start -< -dst +match +state +needs +to +report +empty +matches +/ +/ +in +addition +to +its +own . -len -( -) -" -equivalence -classes -are +For +the +non +- +overlapping +case +such +/ +/ +states +only +report +the +first +match +which +is never empty -" -) -; -for +since +/ +/ +it +isn +' t -in -nnfa -. -iter_trans -( -oldsid -) -{ -dst -[ +a start -+ -usize -: -: -from -( -classes +state . -get -( -t +if +! +kind . -byte +is_leftmost ( ) -) -) -] -= -t +{ +it . -next +nfa ( ) . -as_u32 +copy_empty_matches ( +id ) ; } -Ok -( -( -) -) +} } / / / -Return -an -iterator -over -every -explicitly -defined -transition -in -this +Returns +a +set +that +tracked +queued +states +. +/ +/ +/ +/ +/ +/ +This +is +only +necessary +when +ASCII +case +insensitivity +is +enabled +since / / / +it +is +the +only +way +to +visit +the +same state +twice . -fn -transitions -< -' -b -> -( -& -' -b -self -) -- -> -impl -Iterator -< -Item -= -( -u8 -StateID -) -> -+ -' -b -{ -let -mut -i -= -0 -; -core -: -: -iter -: -: -from_fn -( -move -| -| -match -self -. -trans -{ -StateTrans -: -: -Sparse -{ -classes -nexts -} -= -> -{ -if -i -> -= -nexts -. -len -( -) -{ -return -None -; -} -let -chunk -= -classes -[ -i +Otherwise +this / -4 -] -; -let -class -= -chunk -. -to_ne_bytes -( -) -[ -i -% -4 -] -; -let -next -= -StateID -: -: -from_u32_unchecked -( -nexts -[ -i -] -) -; -i -+ -= -1 -; -Some -( +/ +/ +returns +an +inert +set +that +nevers +adds +anything +and +always +reports +/ +/ +/ +false +for +every +member +test +. +fn +queued_set ( -class -next -) +& +self ) -} -StateTrans -: -: -One -{ -class -next -} -= +- +> +QueuedSet +< +S > { if -i -= -= -0 +self +. +builder +. +ascii_case_insensitive { -i -+ -= -1 -; -Some -( -( -class -StateID +QueuedSet : : -from_u32_unchecked +active ( -next -) -) ) } else { -None -} -} -StateTrans +QueuedSet : : -Dense -{ -class_to_next -} -= -> -{ -if -i -> -= -class_to_next -. -len +inert ( ) -{ -return -None -; } -let -class -= -i +} +/ +/ +/ +Set +the +failure +transitions +on +the +start +state +to +loop +back +to +the +/ +/ +/ +start +state . -as_u8 -( -) -; -let +This +effectively +permits +the +Aho +- +Corasick +automaton +to +/ +/ +/ +match +at +any +position +. +This +is +also +required +for +finding +the next -= -StateID -: -: -from_u32_unchecked -( -class_to_next -[ -i -] -) -; -i -+ -= -1 -; -Some -( -( -class +/ +/ +/ +state +to +terminate +namely +finding +the next -) -) -} -} -) -} -} -impl -< -' +state +should +never +return +/ +/ +/ a -> -core -: -: -fmt -: -: -Debug -for -State -< -' +fail_id +. +/ +/ +/ +/ +/ +/ +This +must +be +done +after +building +the +initial +trie +since +trie +/ +/ +/ +construction +depends +on +transitions +to +fail_id +to +determine +whether a -> -{ +/ +/ +/ +state +already +exists +or +not +. fn -fmt +add_start_state_loop ( & -self -f -: -& mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> +self ) -- -> -core -: -: -fmt -: -: -Result -{ -use -crate -: -: { -automaton -: -: -sparse_transitions -util -: -: -debug +let +start_id += +self +. +nfa +. +start_id +; +let +start += +self +. +nfa +. +start_mut +( +) +; +for +b +in +AllBytesIter : : -DebugByte -} -; -let -it -= -sparse_transitions +new ( -self +) +{ +if +start . -transitions +next_state +( +b +) += += +fail_id ( ) +{ +start +. +set_next_state +( +b +start_id ) +; +} +} +} / / -Writing -out -all -FAIL +/ +Remove +the +start +state +loop +by +rewriting +any +transitions +on +the +start +/ +/ +/ +state +back +to +the +start +state +with transitions +to +the +dead +state +. +/ +/ +/ +/ +/ +/ +The +loop is -quite -noisy +only +closed +when +two +conditions +are +met +: +the +start +state +/ +/ +/ +is +a +match +state +and +the +match +kind +is +leftmost +- +first +or +/ +/ +/ +leftmost +- +longest . -Instead +( +Alternatively +if +this +is +an +anchored +automaton +/ +/ +/ +then +the +start +state +is +always +closed +regardless +of +aforementioned +/ +/ +/ +conditions +. +) +/ +/ +/ +/ +/ +/ +The +reason +for +this +is +that +under +leftmost +semantics +a +start +state +/ +/ +/ +that +is +also +a +match +implies +that we +should +never +restart +the +search / / -just -require -readers +/ +process +. +We +allow +normal +transitions +out of the -output -to -assume -anything -absent +start +state +but +if / / -maps +/ +none +exist +we +transition to the -FAIL -transition -. +dead +state +which +signals +that +/ +/ +/ +searching +should +stop . -filter +fn +close_start_state_loop ( -| & -( -_ -_ -sid -) -| -sid -! -= -NFA -: -: -FAIL +mut +self ) +{ +if +self . -enumerate -( -) -; -for +builder +. +anchored +| +| ( -i +self +. +match_kind ( -start -end -sid -) ) -in -it -{ -if -i -> -0 -{ -write -! +. +is_leftmost ( -f -" -" ) -? -; -} -if +& +& +self +. +nfa +. start -= -= -end -{ -write -! ( -f -" -{ -: -? -} -= -> -{ -: -? -} -" -DebugByte -( -start ) -sid . -as_usize +is_match ( ) ) -? -; -} -else { -write -! +let +start_id += +self +. +nfa +. +start_id +; +let +start += +self +. +nfa +. +start_mut ( -f -" -{ -: -? -} -- -{ +) +; +for +b +in +AllBytesIter : -? -} -= -> -{ : -? -} -" -DebugByte +new ( -start ) -DebugByte +{ +if +start +. +next_state ( -end +b ) -sid += += +start_id +{ +start . -as_usize +set_next_state +( +b +dead_id ( ) ) -? ; } } -Ok -( -( -) -) } } / / / -A -builder -for -configuring -an -Aho -- -Corasick -contiguous -NFA +Sets +all +transitions +on +the +dead +state +to +point +back +to +the +dead +state . / / / +Normally +missing +transitions +map +back +to +the +failure +state +but +the / / / -This -builder -has -a -subset +point of the -options -available +dead +state +is to +act +as a -/ -/ -/ -[ -AhoCorasickBuilder -] +sink +that +can +never +be +escaped +. +fn +add_dead_state_loop ( -crate -: -: -AhoCorasickBuilder +& +mut +self ) +{ +let +dead += +self . -Of -the -shared -options -/ -/ -/ -their -behavior -is -identical +nfa . -# -[ -derive +state_mut ( -Clone -Debug -) -] -pub -struct -Builder -{ -noncontiguous -: -noncontiguous -: -: -Builder -dense_depth -: -usize -byte_classes -: -bool -} -impl -Default -for -Builder -{ -fn -default +dead_id ( ) -- -> -Builder -{ -Builder -{ -noncontiguous -: -noncontiguous -: -: -Builder +) +; +for +b +in +AllBytesIter : : new ( ) -dense_depth -: -2 -byte_classes -: -true -} -} -} -impl -Builder { -/ -/ -/ -Create -a -new -builder -for -configuring -an -Aho -- -Corasick -contiguous -NFA +dead . -pub -fn -new +set_next_state ( -) -- -> -Builder -{ -Builder -: -: -default +b +dead_id ( ) +) +; +} } / / / -Build -an -Aho -- -Corasick -contiguous -NFA -from +Computes the -given -iterator +total +amount of -/ -/ -/ -patterns -. -/ -/ -/ -/ -/ -/ -A -builder -may -be -reused -to -create -more -NFAs -. -pub -fn -build -< -I -P -> +heap +used +by +this +NFA +in +bytes +. +fn +calculate_size ( & +mut self -patterns -: -I ) -- -> -Result -< -NFA -BuildError -> -where -I -: -IntoIterator -< -Item -= -P -> -P -: -AsRef -< -[ -u8 -] -> { let -nnfa +mut +size = +0 +; +for +state +in +& self . -noncontiguous +nfa . -build +states +{ +size ++ += +size_of +: +: +< +State +< +S +> +> ( -patterns ) -? -; -self ++ +state . -build_from_noncontiguous +heap_bytes ( -& -nnfa ) +; +} +self +. +nfa +. +heap_bytes += +size +; } / / / -Build -an -Aho -- -Corasick -contiguous +Add +a +new +state +to +the +underlying NFA -from +with the given -noncontiguous -NFA +depth . +The +depth / / / -/ -/ -/ -Note -that -when -this -method is used -only +to +determine +how +to +represent the -dense_depth -and +transitions +. / / / -byte_classes -settings -on -this -builder -are -respected -. -The -other / / / -settings -only -apply -to +If +adding the -initial -construction -of +new +state +would +overflow the -Aho -- -Corasick +chosen +state +ID / / / -automaton -. -Since -using +representation +then this -method -requires -that -initial -construction -/ -/ -/ -has -already -completed -all -settings -impacting -only -initial -construction -/ -/ -/ -are -no -longer -relevant +returns +an +error . -pub fn -build_from_noncontiguous +add_state ( & +mut self -nnfa -: -& -noncontiguous -: +depth : -NFA +usize ) - > Result < -NFA -BuildError +S > { -debug -! -( -" -building -contiguous -NFA -" -) -; -let -byte_classes -= if +depth +< self . -byte_classes -{ -nnfa -. -byte_classes -( -) -. -clone -( -) -} -else -{ -ByteClasses -: -: -singletons -( -) -} -; -let -mut -index_to_state_id -= -vec -! -[ -NFA -: -: -DEAD -; -nnfa -. -states -( -) -. -len -( -) -] -; -let -mut -nfa -= -NFA -{ -repr -: -vec -! -[ -] -pattern_lens -: -nnfa -. -pattern_lens_raw -( -) -. -to_vec -( -) -state_len -: -nnfa -. -states -( -) -. -len -( -) -prefilter -: -nnfa -. -prefilter -( -) -. -map -( -| -p -| -p +builder . -clone -( -) -) -match_kind -: -nnfa +dense_depth +{ +self . -match_kind -( -) -alphabet_len -: -byte_classes +nfa . -alphabet_len +add_dense_state ( +depth ) -byte_classes -min_pattern_len -: -nnfa +} +else +{ +self . -min_pattern_len -( -) -max_pattern_len -: -nnfa +nfa . -max_pattern_len +add_sparse_state ( +depth ) +} +} / / -The -special -state -IDs -are -set -later +/ +Returns +the +match +kind +configured +on +the +underlying +builder . -special -: -Special -: -: -zero +fn +match_kind ( +& +self ) +- +> +MatchKind +{ +self +. +builder +. +match_kind } -; -for -( -oldsid +} +/ +/ +/ +A +set +of state -) +identifiers +used +to +avoid +revisiting +the +same +state +multiple +/ +/ +/ +times +when +filling in -nnfa -. -states -( -) +failure +transitions . -iter -( -) +/ +/ +/ +/ +/ +/ +This +set +has +an +" +inert +" +and +an +" +active +" +mode . -with_state_ids -( -) -{ +When +inert +the +set +never / / -We -don -' -t -actually -encode -a -fail -state -since -it -isn -' -t -necessary +/ +stores +anything +and +always +returns +false +for +every +member +test . +This +is / / -But -we -still -want +/ +useful to -make -sure -any -FAIL -ids -are -mapped +avoid +the +performance +and +memory +overhead +of +maintaining +this / / -correctly +/ +set +when +it +is +not +needed . -if -oldsid -= -= -noncontiguous -: -: -NFA -: -: -FAIL -{ -index_to_state_id +# [ -oldsid -] -= -NFA -: -: -FAIL -; -continue -; -} -let -force_dense -= -state -. -depth -( -) -. -as_usize +derive ( +Debug ) +] +struct +QueuedSet < -self -. -dense_depth -; -let -newsid -= -State -: +S +> +{ +set : -write -( -nnfa -oldsid -state -& -nfa -. -byte_classes -& -mut -nfa -. -repr -force_dense -) -? -; -index_to_state_id -[ -oldsid -] -= -newsid -; +Option +< +BTreeSet +< +S +> +> } +impl +< +S +: +StateID +> +QueuedSet +< +S +> +{ +/ +/ +/ +Return +an +inert +set +that +returns +false for -& -newsid -in -index_to_state_id +every +state +ID +membership +/ +/ +/ +test . -iter +fn +inert ( ) +- +> +QueuedSet +< +S +> { -if -newsid -= -= -NFA -: -: -FAIL +QueuedSet { -continue -; +set +: +None } -let +} +/ +/ +/ +Return +an +active +set +that +tracks state -= -& -mut -nfa -. -repr -[ -newsid +ID +membership . -as_usize +fn +active ( ) -. -. -] -; -State +- +> +QueuedSet +< +S +> +{ +QueuedSet +{ +set +: +Some +( +BTreeSet : : -remap +new ( -nfa -. -alphabet_len -& -index_to_state_id -state ) -? -; +) +} } / / -Now -that -we -' -ve -remapped -all -the -IDs -in -our -states -all -that -' -s -left -/ / -is -remapping +Inserts the -special +given state -IDs -. -let -remap -= -& -index_to_state_id -; -let -old -= -nnfa +ID +into +this +set . -special ( +If +the +set +is +inert +then +/ +/ +/ +this +is +a +no +- +op +. ) -; -let -new -= +fn +insert +( & mut -nfa -. -special -; -new -. -max_special_id -= -remap -[ -old -. -max_special_id -] -; -new -. -max_match_id -= -remap -[ -old -. -max_match_id -] -; -new -. -start_unanchored_id -= -remap -[ -old -. -start_unanchored_id -] -; -new -. -start_anchored_id -= -remap -[ -old -. -start_anchored_id -] -; -debug -! -( -" -contiguous -NFA -built -< -states -: -{ -: -? -} -size -: -{ -: -? -} -\ -alphabet -len +self +state_id : +S +) { -: -? -} -> -" -nfa -. -state_len -nfa -. -memory_usage +if +let +Some ( +ref +mut +set ) -nfa += +self . -byte_classes +set +{ +set . -alphabet_len +insert ( -) +state_id ) ; +} +} / / -The -vectors -can -grow -~ -twice -as -big -during -construction -because -a -/ / -Vec -amortizes -growth +Returns +true +if +and +only +if +the +given +state +ID +is +in +this +set . -But -here -let -' -s -shrink -things -back -down -to +If +the / / -what -we -actually -need -since -we -' -re -never -going -to -add -more -to -it -. -nfa +/ +set +is +inert +this +always +returns +false . -repr +fn +contains +( +& +self +state_id +: +S +) +- +> +bool +{ +match +self . -shrink_to_fit +set +{ +None += +> +false +Some ( +ref +set ) -; -nfa -. -pattern_lens += +> +set . -shrink_to_fit -( -) -; -Ok +contains ( -nfa +& +state_id ) } +} +} / / / -Set -the -desired -match -semantics +An +iterator +over +every +byte +value . / / @@ -9120,28 +9227,37 @@ semantics / / / -This -only -applies -when -using -[ -Builder -: -: -build -] -and -not +We +use +this +instead +of +( +0 +. +. +256 +) +. +map +( +| +b +| +b +as +u8 +) +because +this +optimizes / / / -[ -Builder -: -: -build_from_noncontiguous -] +better +in +debug +builds . / / @@ -9149,785 +9265,921 @@ build_from_noncontiguous / / / -See +We +also +use +this +instead +of +0 +. +. += +255 +because +we +' +re +targeting +Rust +1 +. +24 +and +/ +/ +/ +inclusive +range +syntax +was +stabilized +in +Rust +1 +. +26 +. +We +can +get +rid +of +this / / / +once +our +MSRV +is +Rust +1 +. +26 +or +newer +. +# [ -AhoCorasickBuilder +derive +( +Debug +) +] +struct +AllBytesIter +( +u16 +) +; +impl +AllBytesIter +{ +fn +new +( +) +- +> +AllBytesIter +{ +AllBytesIter +( +0 +) +} +} +impl +Iterator +for +AllBytesIter +{ +type +Item += +u8 +; +fn +next +( +& +mut +self +) +- +> +Option +< +Self : : -match_kind -] +Item +> +{ +if +self +. +0 +> += +256 +{ +None +} +else +{ +let +b += +self +. +0 +as +u8 +; +self +. +0 ++ += +1 +; +Some ( -crate +b +) +} +} +} +impl +< +S +: +StateID +> +fmt +: : +Debug +for +NFA +< +S +> +{ +fn +fmt +( +& +self +f : -AhoCorasickBuilder +& +mut +fmt : : -match_kind +Formatter +< +' +_ +> ) -/ -/ -/ -for -more -documentation -and -examples +- +> +fmt +: +: +Result +{ +writeln +! +( +f +" +NFA +( +" +) +? +; +writeln +! +( +f +" +match_kind +: +{ +: +? +} +" +self . -pub -fn match_kind +) +? +; +writeln +! ( -& -mut -self -kind +f +" +prefilter : -MatchKind -) -- -> -& -mut -Builder { +: +? +} +" self . -noncontiguous -. -match_kind -( -kind +prefilter ) +? ; -self +writeln +! +( +f +" +{ } -/ -/ -/ -Enable -ASCII +" +" - -aware -case -insensitive -matching -. -/ -/ -/ -/ -/ -/ -This -only -applies -when -using -[ -Builder -: -: -build -] -and -not -/ -/ -/ -[ -Builder -: -: -build_from_noncontiguous -] +" . -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: -: -ascii_case_insensitive -] +repeat ( -crate -: -: -AhoCorasickBuilder -: -: -ascii_case_insensitive +79 ) -/ -/ -/ +) +? +; for -more -documentation -and -examples -. -pub -fn -ascii_case_insensitive ( -& -mut -self -yes -: -bool +id +s ) -- -> -& -mut -Builder -{ +in self . -noncontiguous +states . -ascii_case_insensitive +iter ( -yes ) -; -self -} -/ -/ -/ -Enable -heuristic -prefilter -optimizations . -/ -/ -/ -/ -/ -/ -This -only -applies -when -using -[ -Builder -: -: -build -] -and -not -/ -/ -/ +enumerate +( +) +{ +let +mut +trans += +vec +! [ -Builder -: -: -build_from_noncontiguous ] +; +s . +trans +. +iter +( +| +byte +next +| +{ / / +The +start +state +has +a +bunch +of +uninteresting +transitions / / +back +into +itself +. +It +' +s +questionable +to +hide +them +since +they / / -See -/ -/ +are +critical +to +understanding +the +automaton +but +they +are / -[ -AhoCorasickBuilder -: -: -prefilter -] -( -crate -: -: -AhoCorasickBuilder -: -: -prefilter -) / +very +noisy +without +better +formatting +for +contiugous +ranges / / -for -more -documentation -and -examples +to +the +same +state . -pub -fn -prefilter -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ +if +id += += self . -noncontiguous +start_id . -prefilter +to_usize ( -yes ) -; +& +& +next += += self +. +start_id +{ +return +; } / / -/ -Set +Similarly the -limit -on -how -many -states -use +dead +state +has a -dense -representation -for -their -/ +bunch +of +uninteresting / / transitions +too . -Other -states -will -generally -use -a -sparse -representation -. -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: -: -dense_depth -] +if +id += += +dead_id ( -crate -: -: -AhoCorasickBuilder -: -: -dense_depth ) -/ -/ -/ -for -more -documentation -and -examples +{ +return +; +} +trans . -pub -fn -dense_depth +push ( -& -mut -self -depth -: -usize -) -- +format +! +( +" +{ +} += > -& -mut -Builder { -self +} +" +escape +( +byte +) +next . -dense_depth -= -depth +to_usize +( +) +) +) ; -self } -/ -/ -/ -A -debug -setting -for -whether -to -attempt -to -shrink -the -size -of -the -/ -/ -/ -automaton -' +) +; +writeln +! +( +f +" +{ +: +04 +} +: +{ +} +" +id +trans +. +join +( +" +" +) +) +? +; +let +matches +: +Vec +< +String +> += s -alphabet -or -not . -/ -/ -/ -/ -/ -/ -This -should -never -be -enabled -unless -you -' -re -debugging -an -automaton +matches . -/ -/ -/ -Namely -disabling -byte -classes -makes -transitions -easier -to -reason -/ -/ -/ -about -since -they -use -the -actual -bytes -instead -of -equivalence -classes +iter +( +) . -/ -/ -/ -Disabling -this -confers -no -performance -benefit -at -search -time +map +( +| +& +( +pattern_id +_ +) +| +pattern_id . -/ -/ -/ -/ -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: +to_string +( +) +) +. +collect +( +) +; +writeln +! +( +f +" +matches : -byte_classes -] +{ +} +" +matches +. +join ( -crate -: -: -AhoCorasickBuilder -: -: -byte_classes +" +" ) -/ -/ -/ -for -more -documentation -and -examples +) +? +; +writeln +! +( +f +" +fail +: +{ +} +" +s . -pub -fn -byte_classes +fail +. +to_usize ( -& -mut -self -yes +) +) +? +; +writeln +! +( +f +" +depth : -bool +{ +} +" +s +. +depth ) -- -> -& -mut -Builder +? +; +} +writeln +! +( +f +" { -self +} +" +" +- +" . -byte_classes -= -yes +repeat +( +79 +) +) +? ; -self +writeln +! +( +f +" +) +" +) +? +; +Ok +( +( +) +) } } / / / -Computes -the -number -of -u32 -values -needed -to -represent -one +Iterate +over +all +possible byte -per -the -/ -/ -/ -number -of transitions given +a +sparse +set . fn -u32_len -( -ntrans +sparse_iter +< +S : -usize +StateID +F +: +FnMut +( +u8 +S ) -- > -usize +( +trans +: +& +[ +( +u8 +S +) +] +mut +f +: +F +) { -if -ntrans -% -4 -= +let +mut +byte = -0 +0u16 +; +for +& +( +b +id +) +in +trans { -ntrans -> -> -2 -} -else +while +byte +< +( +b +as +u16 +) { +f +( +byte +as +u8 +fail_id ( -ntrans -> -> -2 ) +) +; +byte + += 1 +; } -} -# -[ -cfg +f ( -test +b +id ) -] -mod -tests -{ -/ -/ -This -test -demonstrates -a -SWAR -technique -I -tried +; +byte ++ += +1 +; +} +for +b in -the -sparse -transition -/ -/ -code -inside -of -' -next_state -' +byte . -Namely -sparse -transitions -work -by -/ -/ -iterating -over -u32 -chunks -with -each -chunk -containing -up -to -4 -classes -/ -/ -corresponding -to -4 -transitions . -This -SWAR -technique -lets -us -find -a -/ -/ -matching -transition -without -converting -the -u32 -to -a -[ +256 +{ +f +( +b +as u8 +fail_id +( +) +) ; -4 -] -. -/ +} +} / / / -It -turned -out +Safely +return +two +mutable +borrows to -be -a -little -slower -unfortunately -which -isn -' -t -too -/ -/ -surprising -since -this -is -likely -a -throughput -oriented -optimization -. -/ -/ -Loop -unrolling -doesn -' -t -really -help -us -because +two +different +locations +in the -vast -majority -of -/ -/ -states -have -very -few -transitions -. -/ -/ -/ +given / -Anyway -this -code -was -a -little -tricky -to -write -so -I -converted -it -to -a / / -test -in -case -someone -figures -out -how -to -use -it -more -effectively -than +slice +. / / -I -could -. / / / / -( This -also -only -works -on -little -endian +panics +if +i += += +j . -So -big -endian -would -need -to +fn +get_two_mut +< +T +> +( +xs +: +& +mut +[ +T +] +i +: +usize +j +: +usize +) +- +> +( +& +mut +T +& +mut +T +) +{ +assert +! +( +i +! += +j +" +{ +} +must +not be -/ -/ -accounted -for -if -we -ever -decided +equal to -use -this -I -think +{ +} +" +i +j +) +; +if +i +< +j +{ +let +( +before +after +) += +xs . +split_at_mut +( +j ) -# +; +( +& +mut +before [ -cfg +i +] +& +mut +after +[ +0 +] +) +} +else +{ +let ( -target_endian +before +after +) = -" -little -" +xs +. +split_at_mut +( +i ) +; +( +& +mut +after +[ +0 ] -# +& +mut +before [ -test +j ] +) +} +} +/ +/ +/ +Return +the +given +byte +as +its +escaped +string +form +. fn -swar +escape +( +b +: +u8 +) +- +> +String +{ +use +std +: +: +ascii +; +String +: +: +from_utf8 +( +ascii +: +: +escape_default +( +b +) +. +collect +: +: +< +Vec +< +_ +> +> +( +) +) +. +unwrap +( +) +} +# +[ +cfg ( +test ) +] +mod +tests { use super @@ -9935,256 +10187,213 @@ super : * ; +# +[ +test +] fn -has_zero_byte +scratch ( -x -: -u32 ) -- +{ +let +nfa +: +NFA +< +usize > -u32 -{ -const -LO_U32 -: -u32 = -0x01010101 -; -const -HI_U32 +Builder : -u32 -= -0x80808080 -; -x -. -wrapping_sub +: +new ( -LO_U32 ) -& -! -x -& -HI_U32 -} -fn -broadcast +. +dense_depth ( -b -: -u8 +0 ) -- -> -u32 -{ +/ +/ +. +match_kind ( -u32 +MatchKind : : -from -( -b -) +LeftmostShortest ) -* +/ +/ +. +match_kind ( -u32 +MatchKind : : -MAX -/ -255 +LeftmostLongest ) -} -fn -index_of +. +match_kind ( -x +MatchKind +: : -u32 +LeftmostFirst ) -- -> -usize -{ -let -o -= -( -( +/ +/ +. +build ( -x -- -1 -) & -0x01010101 +[ +" +abcd +" +" +ce +" +" +b +" +] ) +/ +/ . -wrapping_mul +build ( -0x01010101 -) -> -> -24 +& +[ +" +ab +" +" +bc +" +] ) -- -1 -; -o +/ +/ . -as_usize +build ( -) -} -let -bytes -: -[ -u8 -; -4 -] -= +& [ +" b -' -1 -' -b -' -A -' -b -' -a -' -b -' -z -' +" +" +bcd +" +" +ce +" ] -; -let -chunk -= -u32 -: -: -from_ne_bytes -( -bytes -) -; -let -needle -= -broadcast -( -b -' -1 -' ) -; -assert_eq -! -( -0 -index_of -( -has_zero_byte +/ +/ +. +build ( -needle -^ -chunk -) -) +& +[ +" +abc +" +" +bx +" +] ) -; -let -needle -= -broadcast +/ +/ +. +build ( -b -' -A -' +& +[ +" +abc +" +" +bd +" +" +ab +" +] ) -; -assert_eq -! -( -1 -index_of -( -has_zero_byte +/ +/ +. +build ( -needle -^ -chunk -) -) +& +[ +" +abcdefghi +" +" +hz +" +" +abcdefgh +" +] ) -; -let -needle -= -broadcast +/ +/ +. +build ( +& +[ +" +abcd +" +" +bce +" +" b -' -a -' +" +] ) -; -assert_eq -! -( -2 -index_of -( -has_zero_byte +. +build ( -needle -^ -chunk -) -) +& +[ +" +abcdefg +" +" +bcde +" +" +bcdef +" +] ) -; -let -needle -= -broadcast +. +unwrap ( -b -' -z -' ) ; -assert_eq +println ! ( -3 -index_of -( -has_zero_byte -( -needle -^ -chunk -) -) +" +{ +: +? +} +" +nfa ) ; } diff --git a/third_party/rust/aho-corasick/src/nfa/mod.rs b/third_party/rust/aho-corasick/src/nfa/mod.rs deleted file mode 100644 index 663013525e5d5..0000000000000 --- a/third_party/rust/aho-corasick/src/nfa/mod.rs +++ /dev/null @@ -1,419 +0,0 @@ -/ -* -! -Provides -direct -access -to -NFA -implementations -of -Aho -- -Corasick -. -The -principle -characteristic -of -an -NFA -in -this -crate -is -that -it -may -transition -through -multiple -states -per -byte -of -haystack -. -In -Aho -- -Corasick -parlance -NFAs -follow -failure -transitions -during -a -search -. -In -contrast -a -[ -DFA -] -( -crate -: -: -dfa -: -: -DFA -) -pre -- -computes -all -failure -transitions -during -compilation -at -the -expense -of -a -much -bigger -memory -footprint -. -Currently -there -are -two -NFA -implementations -provided -: -noncontiguous -and -contiguous -. -The -names -reflect -their -internal -representation -and -consequently -the -trade -offs -associated -with -them -: -* -A -[ -noncontiguous -: -: -NFA -] -uses -a -separate -allocation -for -every -NFA -state -to -represent -its -transitions -in -a -sparse -format -. -This -is -ideal -for -building -an -NFA -since -it -cheaply -permits -different -states -to -have -a -different -number -of -transitions -. -A -noncontiguous -NFA -is -where -the -main -Aho -- -Corasick -construction -algorithm -is -implemented -. -All -other -Aho -- -Corasick -implementations -are -built -by -first -constructing -a -noncontiguous -NFA -. -* -A -[ -contiguous -: -: -NFA -] -is -uses -a -single -allocation -to -represent -all -states -while -still -encoding -most -states -as -sparse -states -but -permitting -states -near -the -starting -state -to -have -a -dense -representation -. -The -dense -representation -uses -more -memory -but -permits -computing -transitions -during -a -search -more -quickly -. -By -only -making -the -most -active -states -dense -( -the -states -near -the -starting -state -) -a -contiguous -NFA -better -balances -memory -usage -with -search -speed -. -The -single -contiguous -allocation -also -uses -less -overhead -per -state -and -enables -compression -tricks -where -most -states -only -use -8 -bytes -of -heap -memory -. -When -given -the -choice -between -these -two -you -almost -always -want -to -pick -a -contiguous -NFA -. -It -takes -only -a -little -longer -to -build -but -both -its -memory -usage -and -search -speed -are -typically -much -better -than -a -noncontiguous -NFA -. -A -noncontiguous -NFA -is -useful -when -prioritizing -build -times -or -when -there -are -so -many -patterns -that -a -contiguous -NFA -could -not -be -built -. -( -Currently -because -of -both -memory -and -search -speed -improvements -a -contiguous -NFA -has -a -smaller -internal -limit -on -the -total -number -of -NFA -states -it -can -represent -. -But -you -would -likely -need -to -have -hundreds -of -thousands -or -even -millions -of -patterns -before -you -hit -this -limit -. -) -* -/ -pub -mod -contiguous -; -pub -mod -noncontiguous -; diff --git a/third_party/rust/aho-corasick/src/packed/api.rs b/third_party/rust/aho-corasick/src/packed/api.rs index a5702adde8014..07ca2256e7523 100644 --- a/third_party/rust/aho-corasick/src/packed/api.rs +++ b/third_party/rust/aho-corasick/src/packed/api.rs @@ -1,43 +1,54 @@ use -alloc -: -: -sync +std : : -Arc +u16 ; use crate : : -{ packed : : -{ pattern : : Patterns +; +use +crate +: +: +packed +: +: rabinkarp : : RabinKarp -teddy -} -util +; +use +crate : : -search +packed +: +: +teddy : : { -Match -Span -} +self +Teddy } ; +use +crate +: +: +Match +; / / / @@ -118,24 +129,31 @@ This differs from the +/ +/ +/ [ MatchKind ] ( -crate -: -: +. +. +/ +enum +. MatchKind +. +html ) +/ +/ +/ type in the top - level -/ -/ -/ crate module in @@ -145,14 +163,14 @@ doesn ' t support +/ +/ +/ " standard " match semantics -/ -/ -/ and instead only @@ -161,14 +179,14 @@ leftmost - first or +/ +/ +/ leftmost - longest . Namely -/ -/ -/ " standard " @@ -177,6 +195,9 @@ cannot be easily supported +/ +/ +/ by packed searchers @@ -254,10 +275,6 @@ Eq PartialEq ) ] -# -[ -non_exhaustive -] pub enum MatchKind @@ -354,6 +371,68 @@ is chosen . LeftmostLongest +/ +/ +/ +Hints +that +destructuring +should +not +be +exhaustive +. +/ +/ +/ +/ +/ +/ +This +enum +may +grow +additional +variants +so +this +makes +sure +clients +/ +/ +/ +don +' +t +count +on +exhaustive +matching +. +( +Otherwise +adding +a +new +variant +/ +/ +/ +could +break +existing +code +. +) +# +[ +doc +( +hidden +) +] +__Nonexhaustive } impl Default @@ -452,20 +531,27 @@ packed Builder ] ( +struct +. Builder +. +html ) which -in -turn -can / / / +in +turn +can be used to construct a +/ +/ +/ [ packed : @@ -473,7 +559,11 @@ packed Searcher ] ( +struct +. Searcher +. +html ) for searching @@ -528,7 +618,6 @@ use aho_corasick : : -{ packed : : @@ -536,8 +625,6 @@ packed Config MatchKind } -PatternID -} ; / / @@ -625,7 +712,7 @@ matches : Vec < -PatternID +usize > = searcher @@ -671,13 +758,7 @@ assert_eq vec ! [ -PatternID -: -: -must -( 1 -) ] matches ) @@ -700,35 +781,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -/ -/ -/ -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -/ -/ -/ -# -) -) ) { / @@ -794,21 +851,18 @@ Option < ForceAlgorithm > -only_teddy_fat +force_teddy_fat : Option < bool > -only_teddy_256bit +force_avx : Option < bool > -heuristic_pattern_limits -: -bool } / / @@ -946,15 +1000,12 @@ LeftmostFirst force : None -only_teddy_fat +force_teddy_fat : None -only_teddy_256bit +force_avx : None -heuristic_pattern_limits -: -true } } / @@ -982,9 +1033,22 @@ patterns and create a +/ +/ +/ [ Searcher ] +( +struct +. +Searcher +. +html +) +/ +/ +/ from them . @@ -1113,7 +1177,7 @@ hidden ] pub fn -only_teddy +force_teddy ( & mut @@ -1222,7 +1286,7 @@ hidden ] pub fn -only_teddy_fat +force_teddy_fat ( & mut @@ -1242,7 +1306,7 @@ Config { self . -only_teddy_fat +force_teddy_fat = yes ; @@ -1330,7 +1394,7 @@ hidden ] pub fn -only_teddy_256bit +force_avx ( & mut @@ -1350,7 +1414,7 @@ Config { self . -only_teddy_256bit +force_avx = yes ; @@ -1424,7 +1488,7 @@ hidden ] pub fn -only_rabin_karp +force_rabin_karp ( & mut @@ -1466,95 +1530,6 @@ None } self } -/ -/ -/ -Request -that -heuristic -limitations -on -the -number -of -patterns -be -/ -/ -/ -employed -. -This -useful -to -disable -for -benchmarking -where -one -wants -to -/ -/ -/ -explore -how -Teddy -performs -on -large -number -of -patterns -even -if -the -/ -/ -/ -heuristics -would -otherwise -refuse -construction -. -/ -/ -/ -/ -/ -/ -This -is -enabled -by -default -. -pub -fn -heuristic_pattern_limits -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Config -{ -self -. -heuristic_pattern_limits -= -yes -; -self -} } / / @@ -1625,7 +1600,6 @@ use aho_corasick : : -{ packed : : @@ -1633,8 +1607,6 @@ packed Builder MatchKind } -PatternID -} ; / / @@ -1704,7 +1676,7 @@ matches : Vec < -PatternID +usize > = searcher @@ -1750,10 +1722,7 @@ assert_eq vec ! [ -PatternID -: -: -ZERO +0 ] matches ) @@ -1776,35 +1745,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -/ -/ -/ -# -target_arch +target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -/ -/ -/ -# -) -) ) { / @@ -2059,17 +2004,6 @@ kind ) ; let -patterns -= -Arc -: -: -new -( -patterns -) -; -let rabinkarp = RabinKarp @@ -2182,19 +2116,6 @@ Teddy = > { -debug -! -( -" -trying -to -build -Teddy -packed -matcher -" -) -; let teddy = @@ -2203,15 +2124,9 @@ self . build_teddy ( -Arc -: -: -clone -( & patterns ) -) { None = @@ -2256,20 +2171,6 @@ RabinKarp ) = > -{ -debug -! -( -" -using -Rabin -- -Karp -packed -matcher -" -) -; ( SearchKind : @@ -2278,7 +2179,6 @@ RabinKarp 0 ) } -} ; Some ( @@ -2298,19 +2198,14 @@ build_teddy self patterns : -Arc -< +& Patterns -> ) - > Option < -teddy -: -: -Searcher +Teddy > { teddy @@ -2323,35 +2218,27 @@ new ( ) . -only_256bit -( -self -. -config -. -only_teddy_256bit -) -. -only_fat +avx ( self . config . -only_teddy_fat +force_avx ) . -heuristic_pattern_limits +fat ( self . config . -heuristic_pattern_limits +force_teddy_fat ) . build ( +& patterns ) } @@ -2566,9 +2453,6 @@ len ) < = -core -: -: u16 : : @@ -2818,71 +2702,6 @@ p } self } -/ -/ -/ -Returns -the -number -of -patterns -added -to -this -builder -. -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -patterns -. -len -( -) -} -/ -/ -/ -Returns -the -length -in -bytes -of -the -shortest -pattern -added -. -pub -fn -minimum_len -( -& -self -) -- -> -usize -{ -self -. -patterns -. -minimum_len -( -) -} } impl Default @@ -2964,12 +2783,29 @@ the [ Config ] +( +struct +. +Config +. +html +) and / or +/ +/ +/ [ Builder ] +( +struct +. +Builder +. +html +) types for more @@ -3031,7 +2867,6 @@ use aho_corasick : : -{ packed : : @@ -3039,8 +2874,6 @@ packed MatchKind Searcher } -PatternID -} ; / / @@ -3099,7 +2932,7 @@ matches : Vec < -PatternID +usize > = searcher @@ -3145,10 +2978,7 @@ assert_eq vec ! [ -PatternID -: -: -ZERO +0 ] matches ) @@ -3171,35 +3001,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -/ -/ -/ -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -/ -/ -/ -# -) -) ) { / @@ -3258,10 +3064,7 @@ Searcher { patterns : -Arc -< Patterns -> rabinkarp : RabinKarp @@ -3285,10 +3088,7 @@ SearchKind { Teddy ( -teddy -: -: -Searcher +Teddy ) RabinKarp } @@ -3393,7 +3193,6 @@ use aho_corasick : : -{ packed : : @@ -3401,8 +3200,6 @@ packed MatchKind Searcher } -PatternID -} ; / / @@ -3461,7 +3258,7 @@ matches : Vec < -PatternID +usize > = searcher @@ -3507,10 +3304,7 @@ assert_eq vec ! [ -PatternID -: -: -ZERO +0 ] matches ) @@ -3533,35 +3327,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -/ -/ -/ -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -/ -/ -/ -# -) -) ) { / @@ -3661,125 +3431,33 @@ build / / / -A -convenience -function -for -calling -Config -: -: -new -( -) -. +Return +the +first +occurrence +of +any +of +the +patterns +in +this +searcher / / / -/ -/ -/ -This -is -useful -for -avoiding -an -additional -import -. -pub -fn -config -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -/ -/ -/ -A -convenience -function -for -calling -Builder -: -: -new -( -) -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -avoiding -an -additional -import -. -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -/ -/ -/ -Return -the -first -occurrence -of -any -of -the -patterns -in -this -searcher -/ -/ -/ -according -to -its -match -semantics -in -the -given -haystack -. -The -Match +according +to +its +match +semantics +in +the +given +haystack +. +The +Match / / / @@ -3848,7 +3526,6 @@ use aho_corasick : : -{ packed : : @@ -3856,8 +3533,6 @@ packed MatchKind Searcher } -PatternID -} ; / / @@ -3930,10 +3605,7 @@ foobar assert_eq ! ( -PatternID -: -: -ZERO +0 mat . pattern @@ -3987,35 +3659,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -/ -/ -/ -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -/ -/ -/ -# -) -) ) { / @@ -4060,10 +3708,6 @@ is_none / / / -# -[ -inline -] pub fn find @@ -4091,34 +3735,12 @@ Option Match > { -let -haystack -= -haystack -. -as_ref -( -) -; self . -find_in +find_at ( haystack -Span -: -: -from -( 0 -. -. -haystack -. -len -( -) -) ) } / @@ -4252,7 +3874,6 @@ use aho_corasick : : -{ packed : : @@ -4260,9 +3881,6 @@ packed MatchKind Searcher } -PatternID -Span -} ; / / @@ -4287,16 +3905,6 @@ Option / / let -haystack -= -" -foofoobar -" -; -/ -/ -/ -let searcher = Searcher @@ -4331,23 +3939,12 @@ mat = searcher . -find_in -( -haystack -Span -: -: -from +find_at ( +" +foofoobar +" 3 -. -. -haystack -. -len -( -) -) ) ? ; @@ -4357,10 +3954,7 @@ len assert_eq ! ( -PatternID -: -: -ZERO +0 mat . pattern @@ -4414,35 +4008,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -/ -/ -/ -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -/ -/ -/ -# -) -) ) { / @@ -4487,13 +4057,9 @@ is_none / / / -# -[ -inline -] pub fn -find_in +find_at < B : @@ -4510,9 +4076,9 @@ self haystack : B -span +at : -Span +usize ) - > @@ -4549,7 +4115,9 @@ teddy if haystack [ -span +at +. +. ] . len @@ -4565,29 +4133,23 @@ minimum_len return self . -find_in_slow +slow_at ( haystack -span +at ) ; } teddy . -find +find_at ( & -haystack -[ -. -. -span -. -end -] -span +self . -start +patterns +haystack +at ) } SearchKind @@ -4604,17 +4166,11 @@ rabinkarp find_at ( & -haystack -[ -. -. -span -. -end -] -span +self . -start +patterns +haystack +at ) } } @@ -4679,7 +4235,6 @@ use aho_corasick : : -{ packed : : @@ -4687,8 +4242,6 @@ packed MatchKind Searcher } -PatternID -} ; / / @@ -4747,7 +4300,7 @@ matches : Vec < -PatternID +usize > = searcher @@ -4795,49 +4348,10 @@ assert_eq vec ! [ -/ -/ -/ -PatternID -: -: -must -( 0 -) -/ -/ -/ -PatternID -: -: -must -( 1 -) -/ -/ -/ -PatternID -: -: -must -( 1 -) -/ -/ -/ -PatternID -: -: -must -( 1 -) -/ -/ -/ ] matches ) @@ -4860,35 +4374,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -/ -/ -/ -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -/ -/ -/ -# -) -) ) { / @@ -4933,10 +4423,6 @@ is_none / / / -# -[ -inline -] pub fn find_iter @@ -4979,40 +4465,21 @@ a b > { -let +FindIter +{ +searcher +: +self haystack -= +: haystack . as_ref ( ) -; -let -span -= -Span -: +at : -from -( 0 -. -. -haystack -. -len -( -) -) -; -FindIter -{ -searcher -: -self -haystack -span } } / @@ -5163,35 +4630,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -/ -/ -/ -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -/ -/ -/ -# -) -) ) { / @@ -5236,10 +4679,6 @@ is_none / / / -# -[ -inline -] pub fn match_kind @@ -5388,10 +4827,6 @@ by this method . -# -[ -inline -] pub fn minimum_len @@ -5429,13 +4864,9 @@ units of bytes . -# -[ -inline -] pub fn -memory_usage +heap_bytes ( & self @@ -5448,7 +4879,7 @@ self . patterns . -memory_usage +heap_bytes ( ) + @@ -5456,7 +4887,7 @@ self . rabinkarp . -memory_usage +heap_bytes ( ) + @@ -5464,7 +4895,7 @@ self . search_kind . -memory_usage +heap_bytes ( ) } @@ -5542,7 +4973,7 @@ to run . fn -find_in_slow +slow_at ( & self @@ -5552,9 +4983,9 @@ haystack [ u8 ] -span +at : -Span +usize ) - > @@ -5570,17 +5001,11 @@ rabinkarp find_at ( & -haystack -[ -. -. -span -. -end -] -span +self . -start +patterns +haystack +at ) } } @@ -5588,7 +5013,7 @@ impl SearchKind { fn -memory_usage +heap_bytes ( & self @@ -5613,7 +5038,7 @@ ted > ted . -memory_usage +heap_bytes ( ) SearchKind @@ -5658,12 +5083,19 @@ lifetime of the underlying -[ -Searcher -] / / / +[ +Searcher +] +( +struct +. +Searcher +. +html +) while the lifetime @@ -5672,14 +5104,14 @@ h refers to the +/ +/ +/ lifetime of the haystack being -/ -/ -/ searched . # @@ -5713,9 +5145,9 @@ h [ u8 ] -span +at : -Span +usize } impl < @@ -5756,15 +5188,15 @@ Match if self . -span -. -start +at > self . -span +haystack . -end +len +( +) { return None @@ -5775,7 +5207,7 @@ self . searcher . -find_in +find_at ( & self @@ -5783,7 +5215,7 @@ self haystack self . -span +at ) { None @@ -5792,26 +5224,22 @@ None None Some ( -m +c ) = > { self . -span -. -start +at = -m +c . end -( -) ; Some ( -m +c ) } } diff --git a/third_party/rust/aho-corasick/src/packed/ext.rs b/third_party/rust/aho-corasick/src/packed/ext.rs deleted file mode 100644 index 1a2ad1f1d75ea..0000000000000 --- a/third_party/rust/aho-corasick/src/packed/ext.rs +++ /dev/null @@ -1,310 +0,0 @@ -/ -/ -/ -A -trait -for -adding -some -helper -routines -to -pointers -. -pub -( -crate -) -trait -Pointer -{ -/ -/ -/ -Returns -the -distance -in -units -of -T -between -self -and -origin -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Same -as -ptr -: -: -offset_from -in -addition -to -self -> -= -origin -. -unsafe -fn -distance -( -self -origin -: -Self -) -- -> -usize -; -/ -/ -/ -Casts -this -pointer -to -usize -. -/ -/ -/ -/ -/ -/ -Callers -should -not -convert -the -usize -back -to -a -pointer -if -at -all -/ -/ -/ -possible -. -( -And -if -you -believe -it -' -s -necessary -open -an -issue -to -discuss -/ -/ -/ -why -. -Otherwise -it -has -the -potential -to -violate -pointer -provenance -. -) -/ -/ -/ -The -purpose -of -this -function -is -just -to -be -able -to -do -arithmetic -i -. -e -. -/ -/ -/ -computing -offsets -or -alignments -. -fn -as_usize -( -self -) -- -> -usize -; -} -impl -< -T -> -Pointer -for -* -const -T -{ -unsafe -fn -distance -( -self -origin -: -* -const -T -) -- -> -usize -{ -/ -/ -TODO -: -Replace -with -ptr -: -: -sub_ptr -once -stabilized -. -usize -: -: -try_from -( -self -. -offset_from -( -origin -) -) -. -unwrap_unchecked -( -) -} -fn -as_usize -( -self -) -- -> -usize -{ -self -as -usize -} -} -impl -< -T -> -Pointer -for -* -mut -T -{ -unsafe -fn -distance -( -self -origin -: -* -mut -T -) -- -> -usize -{ -( -self -as -* -const -T -) -. -distance -( -origin -as -* -const -T -) -} -fn -as_usize -( -self -) -- -> -usize -{ -( -self -as -* -const -T -) -. -as_usize -( -) -} -} diff --git a/third_party/rust/aho-corasick/src/packed/mod.rs b/third_party/rust/aho-corasick/src/packed/mod.rs index 71d414650e5c2..6e208de47c78b 100644 --- a/third_party/rust/aho-corasick/src/packed/mod.rs +++ b/third_party/rust/aho-corasick/src/packed/mod.rs @@ -1,7 +1,11 @@ / * ! -Provides +A +lower +level +API +for packed multiple substring @@ -55,10 +59,14 @@ primary AhoCorasick ] ( -crate -: -: +. +. +/ +struct +. AhoCorasick +. +html ) searcher will @@ -110,6 +118,13 @@ are [ Searcher ] +( +struct +. +Searcher +. +html +) executes the actual @@ -126,6 +141,13 @@ haystack [ Builder ] +( +struct +. +Builder +. +html +) accumulates patterns incrementally @@ -139,6 +161,13 @@ Searcher [ Config ] +( +struct +. +Config +. +html +) permits tuning the @@ -214,6 +243,16 @@ level [ MatchKind ] +( +. +. +/ +enum +. +MatchKind +. +html +) type for more @@ -234,7 +273,6 @@ use aho_corasick : : -{ packed : : @@ -242,8 +280,6 @@ packed MatchKind Searcher } -PatternID -} ; # fn @@ -290,7 +326,7 @@ matches : Vec < -PatternID +usize > = searcher @@ -324,10 +360,7 @@ assert_eq vec ! [ -PatternID -: -: -ZERO +0 ] matches ) @@ -344,29 +377,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -# -) -) ) { # @@ -405,6 +420,13 @@ use [ Config ] +( +struct +. +Config +. +html +) to change the @@ -419,7 +441,6 @@ use aho_corasick : : -{ packed : : @@ -427,8 +448,6 @@ packed Config MatchKind } -PatternID -} ; # fn @@ -489,7 +508,7 @@ matches : Vec < -PatternID +usize > = searcher @@ -523,13 +542,7 @@ assert_eq vec ! [ -PatternID -: -: -must -( 1 -) ] matches ) @@ -546,29 +559,11 @@ if cfg ! ( -all -( -feature -= -" -std -" -any -( -# target_arch = " x86_64 " -target_arch -= -" -aarch64 -" -# -) -) ) { # @@ -695,14 +690,6 @@ the searcher may fail -even -when -given -a -small -number -of -patterns . However in @@ -754,15 +741,6 @@ is a fallible operation -with -no -clear -rules -for -when -it -will -fail . While the @@ -840,8 +818,6 @@ packed algorithms for x86_64 -and -aarch64 . Therefore constructing @@ -852,6 +828,13 @@ on any other target +( +e +. +g +. +ARM +) will always fail @@ -941,9 +924,6 @@ mod api ; mod -ext -; -mod pattern ; mod @@ -956,20 +936,23 @@ teddy [ cfg ( -all -( -feature -= -" -std -" test ) -) ] mod tests ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] mod vector ; diff --git a/third_party/rust/aho-corasick/src/packed/pattern.rs b/third_party/rust/aho-corasick/src/packed/pattern.rs index d927ebfef6abf..69cbda111242e 100644 --- a/third_party/rust/aho-corasick/src/packed/pattern.rs +++ b/third_party/rust/aho-corasick/src/packed/pattern.rs @@ -1,55 +1,99 @@ use -core +std : : -{ cmp -fmt -mem -u16 -usize -} ; use -alloc +std : : -{ -boxed +fmt +; +use +std : : -Box -string +mem +; +use +std : : -String -vec -vec +u16 +; +use +std : : -Vec -} +usize ; use crate : : -{ packed : : -{ api : : MatchKind -ext -: -: -Pointer -} +; +/ +/ +/ +The +type +used +for +representing +a +pattern +identifier +. +/ +/ +/ +/ +/ +/ +We +don +' +t +use +usize +here +because +our +packed +searchers +don +' +t +scale +to +/ +/ +/ +huge +numbers +of +patterns +so +we +keep +things +a +bit +smaller +. +pub +type PatternID -} += +u16 ; / / @@ -163,9 +207,6 @@ Debug ) ] pub -( -crate -) struct Patterns { @@ -355,6 +396,36 @@ usize / / The +largest +pattern +identifier +. +This +should +always +be +equivalent +to +/ +/ +/ +the +number +of +patterns +minus +one +in +this +collection +. +max_pattern_id +: +PatternID +/ +/ +/ +The total number of @@ -384,85 +455,6 @@ total_pattern_bytes : usize } -/ -/ -BREADCRUMBS -: -I -think -we -want -to -experiment -with -a -different -bucket -/ -/ -representation -. -Basically -each -bucket -is -just -a -Range -< -usize -> -to -a -single -/ -/ -contiguous -allocation -? -Maybe -length -- -prefixed -patterns -or -something -? -The -/ -/ -idea -is -to -try -to -get -rid -of -the -pointer -chasing -in -verification -. -I -don -' -t -/ -/ -know -that -that -is -the -issue -but -I -suspect -it -is -. impl Patterns { @@ -549,9 +541,6 @@ also panics . pub -( -crate -) fn new ( @@ -588,6 +577,9 @@ usize : : MAX +max_pattern_id +: +0 total_pattern_bytes : 0 @@ -619,9 +611,6 @@ is empty . pub -( -crate -) fn add ( @@ -670,11 +659,6 @@ usize let id = -PatternID -: -: -new -( self . by_id @@ -682,11 +666,14 @@ by_id len ( ) -) +as +u16 +; +self . -unwrap -( -) +max_pattern_id += +id ; self . @@ -776,9 +763,6 @@ leftmost first . pub -( -crate -) fn set_match_kind ( @@ -790,15 +774,7 @@ kind MatchKind ) { -self -. -kind -= -kind -; match -self -. kind { MatchKind @@ -857,6 +833,8 @@ id2 by_id [ id1 +as +usize ] . len @@ -869,6 +847,8 @@ cmp by_id [ id2 +as +usize ] . len @@ -883,6 +863,16 @@ reverse ) ; } +MatchKind +: +: +__Nonexhaustive += +> +unreachable +! +( +) } } / @@ -913,9 +903,6 @@ than zero . pub -( -crate -) fn len ( @@ -951,9 +938,6 @@ is empty . pub -( -crate -) fn is_empty ( @@ -996,11 +980,8 @@ of bytes . pub -( -crate -) fn -memory_usage +heap_bytes ( & self @@ -1086,9 +1067,6 @@ empty collection . pub -( -crate -) fn reset ( @@ -1133,39 +1111,122 @@ usize : MAX ; +self +. +max_pattern_id += +0 +; } / / / -Returns -the -length -in -bytes -of +Return the -smallest +maximum pattern +identifier +in +this +collection . +This +can +be / / / +useful +in +searchers +for +ensuring +that +the +collection +of +patterns +they / / / -This -is -guaranteed -to -be +are +provided at -least -one -. -pub +search +time +and +at +build +time +have +the +same +size +. +pub +fn +max_pattern_id +( +& +self +) +- +> +PatternID +{ +assert_eq +! +( +( +self +. +max_pattern_id ++ +1 +) +as +usize +self +. +len ( -crate ) +) +; +self +. +max_pattern_id +} +/ +/ +/ +Returns +the +length +in +bytes +of +the +smallest +pattern +. +/ +/ +/ +/ +/ +/ +This +is +guaranteed +to +be +at +least +one +. +pub fn minimum_len ( @@ -1193,9 +1254,6 @@ these patterns . pub -( -crate -) fn match_kind ( @@ -1238,9 +1296,6 @@ this panics . pub -( -crate -) fn get ( @@ -1266,6 +1321,8 @@ self by_id [ id +as +usize ] ) } @@ -1320,10 +1377,18 @@ using this method . -pub +# +[ +cfg ( -crate +target_arch += +" +x86_64 +" ) +] +pub unsafe fn get_unchecked @@ -1351,10 +1416,8 @@ by_id get_unchecked ( id -. -as_usize -( -) +as +usize ) ) } @@ -1557,9 +1620,6 @@ longest . ) pub -( -crate -) fn iter ( @@ -1664,9 +1724,6 @@ Debug ) ] pub -( -crate -) struct PatternIter < @@ -1810,9 +1867,6 @@ Clone ) ] pub -( -crate -) struct Pattern < @@ -1925,9 +1979,6 @@ in bytes . pub -( -crate -) fn len ( @@ -1957,9 +2008,6 @@ this pattern . pub -( -crate -) fn bytes ( @@ -2005,10 +2053,18 @@ then this panics . -pub +# +[ +cfg ( -crate +target_arch += +" +x86_64 +" ) +] +pub fn low_nybbles ( @@ -2020,11 +2076,9 @@ usize ) - > -Box +Vec < -[ u8 -] > { let @@ -2034,20 +2088,11 @@ nybs vec ! [ -0 -; -len ] -. -into_boxed_slice -( -) ; for -( -i -byte -) +& +b in self . @@ -2063,19 +2108,15 @@ take ( len ) -. -enumerate -( -) { nybs -[ -i -] -= -byte +. +push +( +b & 0xF +) ; } nybs @@ -2104,9 +2145,6 @@ always ) ] pub -( -crate -) fn is_prefix ( @@ -2123,14 +2161,35 @@ u8 > bool { -is_prefix +self +. +len ( +) +< += bytes +. +len +( +) +& +& self . +equals +( +& bytes +[ +. +. +self +. +len ( ) +] ) } / @@ -2139,323 +2198,236 @@ bytes Returns true if +and +only +if this pattern -is -a -prefix -of +equals the -haystack given -by -the +bytes +. +# +[ +inline +( +always +) +] +pub +fn +equals +( +& +self +bytes +: +& +[ +u8 +] +) +- +> +bool +{ / / +Why +not +just +use +memcmp +for +this +? +Well +memcmp +requires +calling +out +/ / -raw -start +to +libc and -end -pointers +this +routine +is +called +in +fairly +hot +code +paths . +Other / / +than +just +calling +out +to +libc +it +also +seems +to +result +in +worse / / +codegen +. +By +rolling +our +own +memcpy +in +pure +Rust +it +seems +to +appear / / -# -Safety +more +friendly +to +the +optimizer +. / / / / +This +results +in +an +improvement +in +just +about +every +benchmark +. +Some / / -* -It -must -be -the -case -that -start -< -end -and -that -the -distance -between -/ -/ -/ -them -is -at -least -equal -to -V -: -: -BYTES -. -That -is -it -must -always -be -valid -/ -/ -/ -to -do -at -least -an -unaligned -load -of -V -at -start -. -/ -/ -/ -* -Both -start -and -end -must -be -valid -for -reads -. -/ -/ -/ -* -Both -start -and -end -must -point -to -an -initialized -value -. -/ -/ -/ -* -Both -start -and -end -must -point -to -the -same -allocated -object -and -/ -/ -/ -must -either -be +smaller +than +others +but in -bounds -or -at -most -one -byte -past -the -end -of -the -/ -/ -/ -allocated -object -. -/ -/ -/ -* -Both -start -and -end -must -be -_derived -from_ -a -pointer +some +cases +up to -the -same -/ -/ -/ -object +30 +% +faster . -/ -/ -/ -* -The -distance -between -start -and -end -must -not -overflow -isize +if +self . -/ -/ -/ -* -The -distance -being -in -bounds -must -not -rely -on -" -wrapping -around -" -the -/ -/ -/ -address -space +len +( +) +! += +bytes . -# -[ -inline +len ( -always ) -] -pub +{ +return +false +; +} +if +self +. +len ( -crate ) -unsafe -fn -is_prefix_raw +< +8 +{ +for ( & -self -start -: -* -const -u8 -end -: -* -const -u8 +b1 +& +b2 ) -- -> -bool -{ -let -patlen -= +in self . bytes ( ) . -len +iter ( ) -; -let -haylen -= -end . -distance +zip ( -start +bytes ) -; +{ if -patlen -> -haylen +b1 +! += +b2 { return false ; } +} +return +true +; +} / / -SAFETY -: -We -' -ve -checked -that -the -haystack -has -length -at -least -equal -/ -/ +When +we +have +8 +or +more +bytes to -this -pattern -. -All -other -safety -concerns -are -the -responsibility +compare +then +proceed +in +chunks +of / / -of -the -caller +8 +at +a +time +using +unaligned +loads . -is_equal_raw -( -start +let +mut +p1 += self . bytes @@ -2465,2256 +2437,273 @@ bytes as_ptr ( ) -patlen +; +let +mut +p2 += +bytes +. +as_ptr +( ) -} -} -/ -/ -/ -Returns -true -if -and -only -if -needle -is -a -prefix -of -haystack -. -/ -/ -/ -/ -/ -/ -This -uses -a -latency -optimized -variant -of -memcmp -internally -which -* -might -* -/ -/ -/ -make -this -faster -for -very -short -strings +; +let +p1end += +self . -/ -/ -/ -/ -/ -/ -# -Inlining -/ -/ -/ -/ -/ -/ -This -routine -is -marked -inline +bytes ( -always ) +[ +self . -If -you -want -to -call -this -function -/ -/ -/ -in -a -way -that -is -not -always -inlined -you -' -ll -need -to -wrap -a -call -to -it -in -/ -/ -/ -another -function -that -is -marked -as -inline +len ( -never ) -or -just -inline +- +8 +. . -# -[ -inline -( -always -) ] -fn -is_prefix +. +as_ptr ( -haystack -: -& -[ -u8 -] -needle -: -& -[ -u8 -] ) -- -> -bool -{ -if -needle +; +let +p2end += +bytes +[ +bytes . len ( ) -> -haystack +- +8 . -len +. +] +. +as_ptr ( ) -{ -return -false ; -} / / SAFETY : -Our -pointers -are -derived -directly -from -borrowed -slices -which +Via +the +conditional +above +we +know +that +both +p1 +and +p2 / / -uphold -all -of -our -safety -guarantees -except -for +have +the +same length +so +p1 +< +p1end +implies +that +p2 +< +p2end . -We -account -for / / -length -with +Thus +derefencing +both +p1 +and +p2 +in the -check -above -. -unsafe -{ -is_equal_raw -( -haystack -. -as_ptr -( -) -needle -. -as_ptr -( -) -needle +loop +below +is +safe . -len -( -) -) -} -} / / / -Compare -corresponding +/ +Moreover +we +set +p1end +and +p2end +to +be +8 bytes -in -x +before +the +actual +/ +/ +end +of +of +p1 and -y -for -equality +p2 . +Thus +the +final +dereference +outside +of +the / / +loop +is +guaranteed +to +be +valid +. / / / / -That -is -this -returns -true -if -and -only -if -x +Finally +we +needn +' +t +worry +about +64 +- +bit +alignment +here +since +we +/ +/ +do +unaligned +loads . -len +unsafe +{ +while +p1 +< +p1end +{ +let +v1 += ( +p1 +as +* +const +u64 ) -= -= -y . -len +read_unaligned ( ) -and -/ -/ -/ -x -[ -i -] -= +; +let +v2 = -y -[ -i -] -for -all -0 -< -= -i -< -x -. -len -( -) -. -/ -/ -/ -/ -/ -/ -Note -that -this -isn -' -t -used -. -We -only -use -it -in -tests -as -a -convenient -way -/ -/ -/ -of -testing -is_equal_raw -. -/ -/ -/ -/ -/ -/ -# -Inlining -/ -/ -/ -/ -/ -/ -This -routine -is -marked -inline ( -always -) -. -If -you -want -to -call -this -function -/ -/ -/ -in -a -way -that -is -not -always -inlined -you -' -ll -need -to -wrap -a -call -to -it -in -/ -/ -/ -another -function -that -is -marked +p2 as -inline -( -never +* +const +u64 ) -or -just -inline -. -/ -/ -/ -/ -/ -/ -# -Motivation -/ -/ -/ -/ -/ -/ -Why -not -use -slice -equality -instead -? -Well -slice -equality -usually -results -in -/ -/ -/ -a -call -out -to -the -current -platform -' -s -libc -which -might -not -be -inlineable -/ -/ -/ -or -have -other -overhead -. -This -routine -isn -' -t -guaranteed -to -be -a -win -but -it -/ -/ -/ -might -be -in -some -cases . -# -[ -cfg -( -test -) -] -# -[ -inline -( -always -) -] -fn -is_equal +read_unaligned ( -x -: -& -[ -u8 -] -y -: -& -[ -u8 -] ) -- -> -bool -{ +; if -x -. -len -( -) +v1 ! = -y -. -len -( -) +v2 { return false ; } -/ -/ -SAFETY -: -Our -pointers -are -derived -directly -from -borrowed -slices -which -/ -/ -uphold -all -of -our -safety -guarantees -except -for -length -. -We -account -for -/ -/ -length -with -the -check -above -. -unsafe -{ -is_equal_raw -( -x -. -as_ptr -( -) -y +p1 += +p1 . -as_ptr +add ( +8 ) -x +; +p2 += +p2 . -len +add ( +8 ) -) -} +; } -/ -/ -/ -Compare -n -bytes -at -the -given -pointers -for -equality -. -/ -/ -/ -/ -/ -/ -This -returns -true -if -and -only -if +let +v1 += +( +p1end +as * -x +const +u64 +) . -add +read_unaligned ( -i ) +; +let +v2 = -= -* -y -. -add -( -i -) -for -all -/ -/ -/ -0 -< -= -i -< -n -. -/ -/ -/ -/ -/ -/ -# -Inlining -/ -/ -/ -/ -/ -/ -This -routine -is -marked -inline -( -always -) -. -If -you -want -to -call -this -function -/ -/ -/ -in -a -way -that -is -not -always -inlined -you -' -ll -need -to -wrap -a -call -to -it -in -/ -/ -/ -another -function -that -is -marked -as -inline -( -never -) -or -just -inline -. -/ -/ -/ -/ -/ -/ -# -Motivation -/ -/ -/ -/ -/ -/ -Why -not -use -slice -equality -instead -? -Well -slice -equality -usually -results -in -/ -/ -/ -a -call -out -to -the -current -platform -' -s -libc -which -might -not -be -inlineable -/ -/ -/ -or -have -other -overhead -. -This -routine -isn -' -t -guaranteed -to -be -a -win -but -it -/ -/ -/ -might -be -in -some -cases -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -* -Both -x -and -y -must -be -valid -for -reads -of -up -to -n -bytes -. -/ -/ -/ -* -Both -x -and -y -must -point -to -an -initialized -value -. -/ -/ -/ -* -Both -x -and -y -must -each -point -to -an -allocated -object -and -/ -/ -/ -must -either -be -in -bounds -or -at -most -one -byte -past -the -end -of -the -/ -/ -/ -allocated -object -. -x -and -y -do -not -need -to -point -to -the -same -allocated -/ -/ -/ -object -but -they -may -. -/ -/ -/ -* -Both -x -and -y -must -be -_derived -from_ -a -pointer -to -their -respective -/ -/ -/ -allocated -objects -. -/ -/ -/ -* -The -distance -between -x -and -x -+ -n -must -not -overflow -isize -. -Similarly -/ -/ -/ -for -y -and -y -+ -n -. -/ -/ -/ -* -The -distance -being -in -bounds -must -not -rely -on -" -wrapping -around -" -the -/ -/ -/ -address -space -. -# -[ -inline -( -always -) -] -unsafe -fn -is_equal_raw -( -mut -x -: -* -const -u8 -mut -y -: -* -const -u8 -n -: -usize -) -- -> -bool -{ -/ -/ -If -we -don -' -t -have -enough -bytes -to -do -4 -- -byte -at -a -time -loads -then -/ -/ -handle -each -possible -length -specially -. -Note -that -I -used -to -have -a -/ -/ -byte -- -at -- -a -- -time -loop -here -and -that -turned -out -to -be -quite -a -bit -slower -/ -/ -for -the -memmem -/ -pathological -/ -defeat -- -simple -- -vector -- -alphabet -benchmark -. -if -n -< -4 -{ -return -match -n -{ -0 -= -> -true -1 -= -> -x -. -read -( -) -= -= -y -. -read -( -) -2 -= -> -{ -x -. -cast -: -: -< -u16 -> -( -) -. -read_unaligned -( -) -= -= -y -. -cast -: -: -< -u16 -> -( -) -. -read_unaligned -( -) -} -/ -/ -I -also -tried -copy_nonoverlapping -here -and -it -looks -like -the -/ -/ -codegen -is -the -same -. -3 -= -> -x -. -cast -: -: -< -[ -u8 -; -3 -] -> -( -) -. -read -( -) -= -= -y -. -cast -: -: -< -[ -u8 -; -3 -] -> -( -) -. -read -( -) -_ -= -> -unreachable -! -( -) -} -; -} -/ -/ -When -we -have -4 -or -more -bytes -to -compare -then -proceed -in -chunks -of -4 -at -/ -/ -a -time -using -unaligned -loads -. -/ -/ -/ -/ -Also -why -do -4 -byte -loads -instead -of -say -8 -byte -loads -? -The -reason -is -/ -/ -that -this -particular -version -of -memcmp -is -likely -to -be -called -with -tiny -/ -/ -needles -. -That -means -that -if -we -do -8 -byte -loads -then -a -higher -proportion -/ -/ -of -memcmp -calls -will -use -the -slower -variant -above -. -With -that -said -this -/ -/ -is -a -hypothesis -and -is -only -loosely -supported -by -benchmarks -. -There -' -s -/ -/ -likely -some -improvement -that -could -be -made -here -. -The -main -thing -here -/ -/ -though -is -to -optimize -for -latency -not -throughput -. -/ -/ -SAFETY -: -The -caller -is -responsible -for -ensuring -the -pointers -we -get -are -/ -/ -valid -and -readable -for -at -least -n -bytes -. -We -also -do -unaligned -loads -/ -/ -so -there -' -s -no -need -to -ensure -we -' -re -aligned -. -( -This -is -justified -by -this -/ -/ -routine -being -specifically -for -short -strings -. -) -let -xend -= -x -. -add -( -n -. -wrapping_sub -( -4 -) -) -; -let -yend -= -y -. -add -( -n -. -wrapping_sub -( -4 -) -) -; -while -x -< -xend -{ -let -vx -= -x -. -cast -: -: -< -u32 -> -( -) -. -read_unaligned -( -) -; -let -vy -= -y -. -cast -: -: -< -u32 -> -( -) -. -read_unaligned -( -) -; -if -vx -! -= -vy -{ -return -false -; -} -x -= -x -. -add -( -4 -) -; -y -= -y -. -add -( -4 -) -; -} -let -vx -= -xend -. -cast -: -: -< -u32 -> -( -) -. -read_unaligned -( -) -; -let -vy -= -yend -. -cast -: -: -< -u32 -> -( -) -. -read_unaligned -( -) -; -vx -= -= -vy -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -super -: -: -* -; -# -[ -test -] -fn -equals_different_lengths -( -) -{ -assert -! -( -! -is_equal -( -b -" -" -b -" -a -" -) -) -; -assert -! -( -! -is_equal -( -b -" -a -" -b -" -" -) -) -; -assert -! -( -! -is_equal -( -b -" -ab -" -b -" -a -" -) -) -; -assert -! -( -! -is_equal -( -b -" -a -" -b -" -ab -" -) -) -; -} -# -[ -test -] -fn -equals_mismatch -( -) -{ -let -one_mismatch -= -[ -( -& -b -" -a -" -[ -. -. -] -& -b -" -x -" -[ -. -. -] -) -( -& -b -" -ab -" -[ -. -. -] -& -b -" -ax -" -[ -. -. -] -) -( -& -b -" -abc -" -[ -. -. -] -& -b -" -abx -" -[ -. -. -] -) -( -& -b -" -abcd -" -[ -. -. -] -& -b -" -abcx -" -[ -. -. -] -) -( -& -b -" -abcde -" -[ -. -. -] -& -b -" -abcdx -" -[ -. -. -] -) -( -& -b -" -abcdef -" -[ -. -. -] -& -b -" -abcdex -" -[ -. -. -] -) -( -& -b -" -abcdefg -" -[ -. -. -] -& -b -" -abcdefx -" -[ -. -. -] -) -( -& -b -" -abcdefgh -" -[ -. -. -] -& -b -" -abcdefgx -" -[ -. -. -] -) -( -& -b -" -abcdefghi -" -[ -. -. -] -& -b -" -abcdefghx -" -[ -. -. -] -) -( -& -b -" -abcdefghij -" -[ -. -. -] -& -b -" -abcdefghix -" -[ -. -. -] -) -( -& -b -" -abcdefghijk -" -[ -. -. -] -& -b -" -abcdefghijx -" -[ -. -. -] -) -( -& -b -" -abcdefghijkl -" -[ -. -. -] -& -b -" -abcdefghijkx -" -[ -. -. -] -) -( -& -b -" -abcdefghijklm -" -[ -. -. -] -& -b -" -abcdefghijklx -" -[ -. -. -] -) -( -& -b -" -abcdefghijklmn -" -[ -. -. -] -& -b -" -abcdefghijklmx -" -[ -. -. -] -) -] -; -for -( -x -y -) -in -one_mismatch -{ -assert_eq -! -( -x -. -len -( -) -y -. -len -( -) -" -lengths -should -match -" -) -; -assert -! -( -! -is_equal -( -x -y -) -) -; -assert -! -( -! -is_equal ( -y -x -) -) -; -} -} -# -[ -test -] -fn -equals_yes -( -) -{ -assert -! -( -is_equal -( -b -" -" -b -" -" -) -) -; -assert -! -( -is_equal -( -b -" -a -" -b -" -a -" -) -) -; -assert -! -( -is_equal -( -b -" -ab -" -b -" -ab -" -) -) -; -assert -! -( -is_equal -( -b -" -abc -" -b -" -abc -" -) -) -; -assert -! -( -is_equal -( -b -" -abcd -" -b -" -abcd -" -) -) -; -assert -! -( -is_equal -( -b -" -abcde -" -b -" -abcde -" -) -) -; -assert -! -( -is_equal -( -b -" -abcdef -" -b -" -abcdef -" -) -) -; -assert -! -( -is_equal -( -b -" -abcdefg -" -b -" -abcdefg -" -) -) -; -assert -! -( -is_equal -( -b -" -abcdefgh -" -b -" -abcdefgh -" -) +p2end +as +* +const +u64 ) -; -assert -! -( -is_equal +. +read_unaligned ( -b -" -abcdefghi -" -b -" -abcdefghi -" -) ) ; +v1 += += +v2 } -# -[ -test -] -fn -prefix -( -) -{ -assert -! -( -is_prefix -( -b -" -" -b -" -" -) -) -; -assert -! -( -is_prefix -( -b -" -a -" -b -" -" -) -) -; -assert -! -( -is_prefix -( -b -" -ab -" -b -" -" -) -) -; -assert -! -( -is_prefix -( -b -" -foo -" -b -" -foo -" -) -) -; -assert -! -( -is_prefix -( -b -" -foobar -" -b -" -foo -" -) -) -; -assert -! -( -! -is_prefix -( -b -" -foo -" -b -" -fob -" -) -) -; -assert -! -( -! -is_prefix -( -b -" -foobar -" -b -" -fob -" -) -) -; } } diff --git a/third_party/rust/aho-corasick/src/packed/rabinkarp.rs b/third_party/rust/aho-corasick/src/packed/rabinkarp.rs index d1e6d4bdaa49f..15001c2a58398 100644 --- a/third_party/rust/aho-corasick/src/packed/rabinkarp.rs +++ b/third_party/rust/aho-corasick/src/packed/rabinkarp.rs @@ -1,40 +1,29 @@ use -alloc +std : : -{ -sync -: -: -Arc -vec -vec -: -: -Vec -} +mem ; use crate : : -{ packed : : pattern : : +{ +PatternID Patterns -util -: -: -search +} +; +use +crate : : Match -PatternID -} ; / / @@ -432,9 +421,6 @@ Debug ) ] pub -( -crate -) struct RabinKarp { @@ -442,23 +428,6 @@ RabinKarp / / The -patterns -we -' -re -searching -for -. -patterns -: -Arc -< -Patterns -> -/ -/ -/ -The order of patterns @@ -630,6 +599,126 @@ byte hash_2pow : usize +/ +/ +/ +The +maximum +identifier +of +a +pattern +. +This +is +used +as +a +sanity +check +/ +/ +/ +to +ensure +that +the +patterns +provided +by +the +caller +are +the +same +as +/ +/ +/ +the +patterns +that +were +used +to +compile +the +matcher +. +This +sanity +check +/ +/ +/ +possibly +permits +safely +eliminating +bounds +checks +regardless +of +what +/ +/ +/ +patterns +are +provided +by +the +caller +. +/ +/ +/ +/ +/ +/ +( +Currently +we +don +' +t +use +this +to +elide +bounds +checks +since +it +doesn +' +t +/ +/ +/ +result +in +a +measurable +performance +improvement +but +we +do +use +it +for +/ +/ +/ +better +failure +modes +. +) +max_pattern_id +: +PatternID } impl RabinKarp @@ -679,19 +768,13 @@ itself empty . pub -( -crate -) fn new ( patterns : & -Arc -< Patterns -> ) - > @@ -758,15 +841,6 @@ rk = RabinKarp { -patterns -: -Arc -: -: -clone -( -patterns -) buckets : vec @@ -781,6 +855,13 @@ NUM_BUCKETS ] hash_len hash_2pow +max_pattern_id +: +patterns +. +max_pattern_id +( +) } ; for @@ -864,14 +945,15 @@ at at . pub -( -crate -) fn find_at ( & self +patterns +: +& +Patterns haystack : & @@ -903,6 +985,34 @@ len ) ) ; +assert_eq +! +( +self +. +max_pattern_id +patterns +. +max_pattern_id +( +) +" +Rabin +- +Karp +must +be +called +with +same +patterns +it +was +built +with +" +) +; if at + @@ -983,6 +1093,7 @@ self . verify ( +patterns pid haystack at @@ -1066,11 +1177,8 @@ of bytes . pub -( -crate -) fn -memory_usage +heap_bytes ( & self @@ -1079,6 +1187,17 @@ self > usize { +let +num_patterns += +self +. +max_pattern_id +as +usize ++ +1 +; self . buckets @@ -1087,9 +1206,6 @@ len ( ) * -core -: -: mem : : @@ -1108,17 +1224,8 @@ PatternID ( ) + -self -. -patterns -. -len -( -) +num_patterns * -core -: -: mem : : @@ -1273,6 +1380,10 @@ verify ( & self +patterns +: +& +Patterns id : PatternID @@ -1296,8 +1407,6 @@ Match let pat = -self -. patterns . get @@ -1324,12 +1433,12 @@ Some Match : : -new +from_span ( id +as +usize at -. -. at + pat diff --git a/third_party/rust/aho-corasick/src/packed/teddy/README.md b/third_party/rust/aho-corasick/src/packed/teddy/README.md index 8d689fdcc40eb..1ea71d0d9282e 100644 --- a/third_party/rust/aho-corasick/src/packed/teddy/README.md +++ b/third_party/rust/aho-corasick/src/packed/teddy/README.md @@ -2136,9 +2136,13 @@ because we only target +x86_64 +here +which +is +always little endian -here . Thus the diff --git a/third_party/rust/aho-corasick/src/packed/teddy/builder.rs b/third_party/rust/aho-corasick/src/packed/teddy/builder.rs deleted file mode 100644 index 5b81ea5bdf5a4..0000000000000 --- a/third_party/rust/aho-corasick/src/packed/teddy/builder.rs +++ /dev/null @@ -1,6039 +0,0 @@ -use -core -: -: -{ -fmt -: -: -Debug -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -} -; -use -alloc -: -: -sync -: -: -Arc -; -use -crate -: -: -packed -: -: -{ -ext -: -: -Pointer -pattern -: -: -Patterns -teddy -: -: -generic -: -: -Match -} -; -/ -/ -/ -A -builder -for -constructing -a -Teddy -matcher -. -/ -/ -/ -/ -/ -/ -The -builder -primarily -permits -fine -grained -configuration -of -the -Teddy -/ -/ -/ -matcher -. -Most -options -are -made -only -available -for -testing -/ -benchmarking -/ -/ -/ -purposes -. -In -reality -options -are -automatically -determined -by -the -nature -/ -/ -/ -and -number -of -patterns -given -to -the -builder -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Builder -{ -/ -/ -/ -When -none -this -is -automatically -determined -. -Otherwise -false -means -/ -/ -/ -slim -Teddy -is -used -( -8 -buckets -) -and -true -means -fat -Teddy -is -used -/ -/ -/ -( -16 -buckets -) -. -Fat -Teddy -requires -AVX2 -so -if -that -CPU -feature -isn -' -t -/ -/ -/ -available -and -Fat -Teddy -was -requested -no -matcher -will -be -built -. -only_fat -: -Option -< -bool -> -/ -/ -/ -When -none -this -is -automatically -determined -. -Otherwise -false -means -/ -/ -/ -that -128 -- -bit -vectors -will -be -used -( -up -to -SSSE3 -instructions -) -where -as -/ -/ -/ -true -means -that -256 -- -bit -vectors -will -be -used -. -As -with -fat -if -/ -/ -/ -256 -- -bit -vectors -are -requested -and -they -aren -' -t -available -then -a -/ -/ -/ -searcher -will -not -be -built -. -only_256bit -: -Option -< -bool -> -/ -/ -/ -When -true -( -the -default -) -the -number -of -patterns -will -be -used -as -a -/ -/ -/ -heuristic -for -refusing -construction -of -a -Teddy -searcher -. -The -point -here -/ -/ -/ -is -that -too -many -patterns -can -overwhelm -Teddy -. -But -this -can -be -disabled -/ -/ -/ -in -cases -where -the -caller -knows -better -. -heuristic_pattern_limits -: -bool -} -impl -Default -for -Builder -{ -fn -default -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -} -impl -Builder -{ -/ -/ -/ -Create -a -new -builder -for -configuring -a -Teddy -matcher -. -pub -( -crate -) -fn -new -( -) -- -> -Builder -{ -Builder -{ -only_fat -: -None -only_256bit -: -None -heuristic_pattern_limits -: -true -} -} -/ -/ -/ -Build -a -matcher -for -the -set -of -patterns -given -. -If -a -matcher -could -not -/ -/ -/ -be -built -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -Generally -a -matcher -isn -' -t -built -if -the -necessary -CPU -features -aren -' -t -/ -/ -/ -available -an -unsupported -target -or -if -the -searcher -is -believed -to -be -/ -/ -/ -slower -than -standard -techniques -( -i -. -e -. -if -there -are -too -many -literals -) -. -pub -( -crate -) -fn -build -( -& -self -patterns -: -Arc -< -Patterns -> -) -- -> -Option -< -Searcher -> -{ -self -. -build_imp -( -patterns -) -} -/ -/ -/ -Require -the -use -of -Fat -( -true -) -or -Slim -( -false -) -Teddy -. -Fat -Teddy -uses -/ -/ -/ -16 -buckets -where -as -Slim -Teddy -uses -8 -buckets -. -More -buckets -are -useful -/ -/ -/ -for -a -larger -set -of -literals -. -/ -/ -/ -/ -/ -/ -None -is -the -default -which -results -in -an -automatic -selection -based -/ -/ -/ -on -the -number -of -literals -and -available -CPU -features -. -pub -( -crate -) -fn -only_fat -( -& -mut -self -yes -: -Option -< -bool -> -) -- -> -& -mut -Builder -{ -self -. -only_fat -= -yes -; -self -} -/ -/ -/ -Request -the -use -of -256 -- -bit -vectors -( -true -) -or -128 -- -bit -vectors -( -false -) -. -/ -/ -/ -Generally -a -larger -vector -size -is -better -since -it -either -permits -/ -/ -/ -matching -more -patterns -or -matching -more -bytes -in -the -haystack -at -once -. -/ -/ -/ -/ -/ -/ -None -is -the -default -which -results -in -an -automatic -selection -based -on -/ -/ -/ -the -number -of -literals -and -available -CPU -features -. -pub -( -crate -) -fn -only_256bit -( -& -mut -self -yes -: -Option -< -bool -> -) -- -> -& -mut -Builder -{ -self -. -only_256bit -= -yes -; -self -} -/ -/ -/ -Request -that -heuristic -limitations -on -the -number -of -patterns -be -/ -/ -/ -employed -. -This -useful -to -disable -for -benchmarking -where -one -wants -to -/ -/ -/ -explore -how -Teddy -performs -on -large -number -of -patterns -even -if -the -/ -/ -/ -heuristics -would -otherwise -refuse -construction -. -/ -/ -/ -/ -/ -/ -This -is -enabled -by -default -. -pub -( -crate -) -fn -heuristic_pattern_limits -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -heuristic_pattern_limits -= -yes -; -self -} -fn -build_imp -( -& -self -patterns -: -Arc -< -Patterns -> -) -- -> -Option -< -Searcher -> -{ -let -patlimit -= -self -. -heuristic_pattern_limits -; -/ -/ -There -' -s -no -particular -reason -why -we -limit -ourselves -to -little -endian -/ -/ -here -but -it -seems -likely -that -some -parts -of -Teddy -as -they -are -/ -/ -currently -written -( -e -. -g -. -the -uses -of -trailing_zeros -) -are -likely -/ -/ -wrong -on -non -- -little -- -endian -targets -. -Such -things -are -likely -easy -to -/ -/ -fix -but -at -the -time -of -writing -( -2023 -/ -09 -/ -18 -) -I -actually -do -not -know -/ -/ -how -to -test -this -code -on -a -big -- -endian -target -. -So -for -now -we -' -re -/ -/ -conservative -and -just -bail -out -. -if -! -cfg -! -( -target_endian -= -" -little -" -) -{ -debug -! -( -" -skipping -Teddy -because -target -isn -' -t -little -endian -" -) -; -return -None -; -} -/ -/ -Too -many -patterns -will -overwhelm -Teddy -and -likely -lead -to -slow -/ -/ -downs -typically -in -the -verification -step -. -if -patlimit -& -& -patterns -. -len -( -) -> -64 -{ -debug -! -( -" -skipping -Teddy -because -of -too -many -patterns -" -) -; -return -None -; -} -# -[ -cfg -( -all -( -target_arch -= -" -x86_64 -" -target_feature -= -" -sse2 -" -) -) -] -{ -use -self -: -: -x86_64 -: -: -{ -FatAVX2 -SlimAVX2 -SlimSSSE3 -} -; -let -mask_len -= -core -: -: -cmp -: -: -min -( -4 -patterns -. -minimum_len -( -) -) -; -let -beefy -= -patterns -. -len -( -) -> -32 -; -let -has_avx2 -= -self -: -: -x86_64 -: -: -is_available_avx2 -( -) -; -let -has_ssse3 -= -has_avx2 -| -| -self -: -: -x86_64 -: -: -is_available_ssse3 -( -) -; -let -use_avx2 -= -if -self -. -only_256bit -= -= -Some -( -true -) -{ -if -! -has_avx2 -{ -debug -! -( -" -skipping -Teddy -because -avx2 -was -demanded -but -unavailable -" -) -; -return -None -; -} -true -} -else -if -self -. -only_256bit -= -= -Some -( -false -) -{ -if -! -has_ssse3 -{ -debug -! -( -" -skipping -Teddy -because -ssse3 -was -demanded -but -unavailable -" -) -; -return -None -; -} -false -} -else -if -! -has_ssse3 -& -& -! -has_avx2 -{ -debug -! -( -" -skipping -Teddy -because -ssse3 -and -avx2 -are -unavailable -" -) -; -return -None -; -} -else -{ -has_avx2 -} -; -let -fat -= -match -self -. -only_fat -{ -None -= -> -use_avx2 -& -& -beefy -Some -( -false -) -= -> -false -Some -( -true -) -if -! -use_avx2 -= -> -{ -debug -! -( -" -skipping -Teddy -because -fat -was -demanded -but -fat -\ -Teddy -requires -avx2 -which -is -unavailable -" -) -; -return -None -; -} -Some -( -true -) -= -> -true -} -; -/ -/ -Just -like -for -aarch64 -it -' -s -possible -that -too -many -patterns -will -/ -/ -overhwelm -Teddy -. -Unlike -aarch64 -though -we -have -Fat -teddy -which -/ -/ -helps -things -scale -a -bit -more -by -spreading -patterns -over -more -/ -/ -buckets -. -/ -/ -/ -/ -These -thresholds -were -determined -by -looking -at -the -measurements -/ -/ -for -the -rust -/ -aho -- -corasick -/ -packed -/ -leftmost -- -first -and -/ -/ -rust -/ -aho -- -corasick -/ -dfa -/ -leftmost -- -first -engines -on -the -teddy -/ -/ -/ -benchmarks -. -if -patlimit -& -& -mask_len -= -= -1 -& -& -patterns -. -len -( -) -> -16 -{ -debug -! -( -" -skipping -Teddy -( -mask -len -: -1 -) -because -there -are -\ -too -many -patterns -" -) -; -return -None -; -} -match -( -mask_len -use_avx2 -fat -) -{ -( -1 -false -_ -) -= -> -{ -debug -! -( -" -Teddy -choice -: -128 -- -bit -slim -1 -byte -" -) -; -SlimSSSE3 -: -: -< -1 -> -: -: -new -( -& -patterns -) -} -( -1 -true -false -) -= -> -{ -debug -! -( -" -Teddy -choice -: -256 -- -bit -slim -1 -byte -" -) -; -SlimAVX2 -: -: -< -1 -> -: -: -new -( -& -patterns -) -} -( -1 -true -true -) -= -> -{ -debug -! -( -" -Teddy -choice -: -256 -- -bit -fat -1 -byte -" -) -; -FatAVX2 -: -: -< -1 -> -: -: -new -( -& -patterns -) -} -( -2 -false -_ -) -= -> -{ -debug -! -( -" -Teddy -choice -: -128 -- -bit -slim -2 -bytes -" -) -; -SlimSSSE3 -: -: -< -2 -> -: -: -new -( -& -patterns -) -} -( -2 -true -false -) -= -> -{ -debug -! -( -" -Teddy -choice -: -256 -- -bit -slim -2 -bytes -" -) -; -SlimAVX2 -: -: -< -2 -> -: -: -new -( -& -patterns -) -} -( -2 -true -true -) -= -> -{ -debug -! -( -" -Teddy -choice -: -256 -- -bit -fat -2 -bytes -" -) -; -FatAVX2 -: -: -< -2 -> -: -: -new -( -& -patterns -) -} -( -3 -false -_ -) -= -> -{ -debug -! -( -" -Teddy -choice -: -128 -- -bit -slim -3 -bytes -" -) -; -SlimSSSE3 -: -: -< -3 -> -: -: -new -( -& -patterns -) -} -( -3 -true -false -) -= -> -{ -debug -! -( -" -Teddy -choice -: -256 -- -bit -slim -3 -bytes -" -) -; -SlimAVX2 -: -: -< -3 -> -: -: -new -( -& -patterns -) -} -( -3 -true -true -) -= -> -{ -debug -! -( -" -Teddy -choice -: -256 -- -bit -fat -3 -bytes -" -) -; -FatAVX2 -: -: -< -3 -> -: -: -new -( -& -patterns -) -} -( -4 -false -_ -) -= -> -{ -debug -! -( -" -Teddy -choice -: -128 -- -bit -slim -4 -bytes -" -) -; -SlimSSSE3 -: -: -< -4 -> -: -: -new -( -& -patterns -) -} -( -4 -true -false -) -= -> -{ -debug -! -( -" -Teddy -choice -: -256 -- -bit -slim -4 -bytes -" -) -; -SlimAVX2 -: -: -< -4 -> -: -: -new -( -& -patterns -) -} -( -4 -true -true -) -= -> -{ -debug -! -( -" -Teddy -choice -: -256 -- -bit -fat -4 -bytes -" -) -; -FatAVX2 -: -: -< -4 -> -: -: -new -( -& -patterns -) -} -_ -= -> -{ -debug -! -( -" -no -supported -Teddy -configuration -found -" -) -; -None -} -} -} -# -[ -cfg -( -target_arch -= -" -aarch64 -" -) -] -{ -use -self -: -: -aarch64 -: -: -SlimNeon -; -let -mask_len -= -core -: -: -cmp -: -: -min -( -4 -patterns -. -minimum_len -( -) -) -; -if -self -. -only_256bit -= -= -Some -( -true -) -{ -debug -! -( -" -skipping -Teddy -because -256 -- -bits -were -demanded -\ -but -unavailable -" -) -; -return -None -; -} -if -self -. -only_fat -= -= -Some -( -true -) -{ -debug -! -( -" -skipping -Teddy -because -fat -was -demanded -but -unavailable -" -) -; -} -/ -/ -Since -we -don -' -t -have -Fat -teddy -in -aarch64 -( -I -think -we -' -d -want -at -/ -/ -least -256 -- -bit -vectors -for -that -) -we -need -to -be -careful -not -to -/ -/ -allow -too -many -patterns -as -it -might -overwhelm -Teddy -. -Generally -/ -/ -speaking -as -the -mask -length -goes -up -the -more -patterns -we -can -/ -/ -handle -because -the -mask -length -results -in -fewer -candidates -/ -/ -generated -. -/ -/ -/ -/ -These -thresholds -were -determined -by -looking -at -the -measurements -/ -/ -for -the -rust -/ -aho -- -corasick -/ -packed -/ -leftmost -- -first -and -/ -/ -rust -/ -aho -- -corasick -/ -dfa -/ -leftmost -- -first -engines -on -the -teddy -/ -/ -/ -benchmarks -. -match -mask_len -{ -1 -= -> -{ -if -patlimit -& -& -patterns -. -len -( -) -> -16 -{ -debug -! -( -" -skipping -Teddy -( -mask -len -: -1 -) -because -there -are -\ -too -many -patterns -" -) -; -} -debug -! -( -" -Teddy -choice -: -128 -- -bit -slim -1 -byte -" -) -; -SlimNeon -: -: -< -1 -> -: -: -new -( -& -patterns -) -} -2 -= -> -{ -if -patlimit -& -& -patterns -. -len -( -) -> -32 -{ -debug -! -( -" -skipping -Teddy -( -mask -len -: -2 -) -because -there -are -\ -too -many -patterns -" -) -; -} -debug -! -( -" -Teddy -choice -: -128 -- -bit -slim -2 -bytes -" -) -; -SlimNeon -: -: -< -2 -> -: -: -new -( -& -patterns -) -} -3 -= -> -{ -if -patlimit -& -& -patterns -. -len -( -) -> -48 -{ -debug -! -( -" -skipping -Teddy -( -mask -len -: -3 -) -because -there -are -\ -too -many -patterns -" -) -; -} -debug -! -( -" -Teddy -choice -: -128 -- -bit -slim -3 -bytes -" -) -; -SlimNeon -: -: -< -3 -> -: -: -new -( -& -patterns -) -} -4 -= -> -{ -debug -! -( -" -Teddy -choice -: -128 -- -bit -slim -4 -bytes -" -) -; -SlimNeon -: -: -< -4 -> -: -: -new -( -& -patterns -) -} -_ -= -> -{ -debug -! -( -" -no -supported -Teddy -configuration -found -" -) -; -None -} -} -} -# -[ -cfg -( -not -( -any -( -all -( -target_arch -= -" -x86_64 -" -target_feature -= -" -sse2 -" -) -target_arch -= -" -aarch64 -" -) -) -) -] -{ -None -} -} -} -/ -/ -/ -A -searcher -that -dispatches -to -one -of -several -possible -Teddy -variants -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Searcher -{ -/ -/ -/ -The -Teddy -variant -we -use -. -We -use -dynamic -dispatch -under -the -theory -that -/ -/ -/ -it -results -in -better -codegen -then -a -enum -although -this -is -a -specious -/ -/ -/ -claim -. -/ -/ -/ -/ -/ -/ -This -Searcher -is -essentially -a -wrapper -for -a -SearcherT -trait -/ -/ -/ -object -. -We -just -make -memory_usage -and -minimum_len -available -without -/ -/ -/ -going -through -dynamic -dispatch -. -imp -: -Arc -< -dyn -SearcherT -> -/ -/ -/ -Total -heap -memory -used -by -the -Teddy -variant -. -memory_usage -: -usize -/ -/ -/ -The -minimum -haystack -length -this -searcher -can -handle -. -It -is -intended -/ -/ -/ -for -callers -to -use -some -other -search -routine -( -such -as -Rabin -- -Karp -) -in -/ -/ -/ -cases -where -the -haystack -( -or -remainer -of -the -haystack -) -is -too -short -. -minimum_len -: -usize -} -impl -Searcher -{ -/ -/ -/ -Look -for -the -leftmost -occurrence -of -any -pattern -in -this -search -in -the -/ -/ -/ -given -haystack -starting -at -the -given -position -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -haystack -[ -at -. -. -] -. -len -( -) -is -less -than -the -minimum -length -/ -/ -/ -for -this -haystack -. -# -[ -inline -( -always -) -] -pub -( -crate -) -fn -find -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Option -< -crate -: -: -Match -> -{ -/ -/ -SAFETY -: -The -Teddy -implementations -all -require -a -minimum -haystack -/ -/ -length -and -this -is -required -for -safety -. -Therefore -we -assert -it -/ -/ -here -in -order -to -make -this -method -sound -. -assert -! -( -haystack -[ -at -. -. -] -. -len -( -) -> -= -self -. -minimum_len -) -; -let -hayptr -= -haystack -. -as_ptr -( -) -; -/ -/ -SAFETY -: -Construction -of -the -searcher -guarantees -that -we -are -able -/ -/ -to -run -it -in -the -current -environment -( -i -. -e -. -we -won -' -t -get -an -AVX2 -/ -/ -searcher -on -a -x86 -- -64 -CPU -without -AVX2 -support -) -. -Also -the -pointers -/ -/ -are -valid -as -they -are -derived -directly -from -a -borrowed -slice -. -let -teddym -= -unsafe -{ -self -. -imp -. -find -( -hayptr -. -add -( -at -) -hayptr -. -add -( -haystack -. -len -( -) -) -) -? -} -; -let -start -= -teddym -. -start -( -) -. -as_usize -( -) -. -wrapping_sub -( -hayptr -. -as_usize -( -) -) -; -let -end -= -teddym -. -end -( -) -. -as_usize -( -) -. -wrapping_sub -( -hayptr -. -as_usize -( -) -) -; -let -span -= -crate -: -: -Span -{ -start -end -} -; -/ -/ -OK -because -we -won -' -t -permit -the -construction -of -a -searcher -that -/ -/ -could -report -a -pattern -ID -bigger -than -what -can -fit -in -the -crate -- -wide -/ -/ -PatternID -type -. -let -pid -= -crate -: -: -PatternID -: -: -new_unchecked -( -teddym -. -pattern -( -) -. -as_usize -( -) -) -; -let -m -= -crate -: -: -Match -: -: -new -( -pid -span -) -; -Some -( -m -) -} -/ -/ -/ -Returns -the -approximate -total -amount -of -heap -used -by -this -type -in -/ -/ -/ -units -of -bytes -. -# -[ -inline -( -always -) -] -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -memory_usage -} -/ -/ -/ -Returns -the -minimum -length -in -bytes -that -a -haystack -must -be -in -order -/ -/ -/ -to -use -it -with -this -searcher -. -# -[ -inline -( -always -) -] -pub -( -crate -) -fn -minimum_len -( -& -self -) -- -> -usize -{ -self -. -minimum_len -} -} -/ -/ -/ -A -trait -that -provides -dynamic -dispatch -over -the -different -possible -Teddy -/ -/ -/ -variants -on -the -same -algorithm -. -/ -/ -/ -/ -/ -/ -On -x86_64 -for -example -it -isn -' -t -known -until -runtime -which -of -12 -possible -/ -/ -/ -variants -will -be -used -. -One -might -use -one -of -the -four -slim -128 -- -bit -vector -/ -/ -/ -variants -or -one -of -the -four -256 -- -bit -vector -variants -or -even -one -of -the -/ -/ -/ -four -fat -256 -- -bit -vector -variants -. -/ -/ -/ -/ -/ -/ -Since -this -choice -is -generally -made -when -the -Teddy -searcher -is -constructed -/ -/ -/ -and -this -choice -is -based -on -the -patterns -given -and -what -the -current -CPU -/ -/ -/ -supports -it -follows -that -there -must -be -some -kind -of -indirection -at -search -/ -/ -/ -time -that -" -selects -" -the -variant -chosen -at -build -time -. -/ -/ -/ -/ -/ -/ -There -are -a -few -different -ways -to -go -about -this -. -One -approach -is -to -use -an -/ -/ -/ -enum -. -It -works -fine -but -in -my -experiments -this -generally -results -in -worse -/ -/ -/ -codegen -. -Another -approach -which -is -what -we -use -here -is -dynamic -dispatch -/ -/ -/ -via -a -trait -object -. -We -basically -implement -this -trait -for -each -possible -/ -/ -/ -variant -select -the -variant -we -want -at -build -time -and -convert -it -to -a -/ -/ -/ -trait -object -for -use -at -search -time -. -/ -/ -/ -/ -/ -/ -Another -approach -is -to -use -function -pointers -and -stick -each -of -the -possible -/ -/ -/ -variants -into -a -union -. -This -is -essentially -isomorphic -to -the -dynamic -/ -/ -/ -dispatch -approach -but -doesn -' -t -require -any -allocations -. -Since -this -crate -/ -/ -/ -requires -alloc -there -' -s -no -real -reason -( -AFAIK -) -to -go -down -this -path -. -( -The -/ -/ -/ -memchr -crate -does -this -. -) -trait -SearcherT -: -Debug -+ -Send -+ -Sync -+ -UnwindSafe -+ -RefUnwindSafe -+ -' -static -{ -/ -/ -/ -Execute -a -search -on -the -given -haystack -( -identified -by -start -and -end -/ -/ -/ -raw -pointers -) -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Essentially -the -start -and -end -pointers -must -be -valid -and -point -/ -/ -/ -to -a -haystack -one -can -read -. -As -long -as -you -derive -them -from -for -/ -/ -/ -example -a -& -[ -u8 -] -they -should -automatically -satisfy -all -of -the -safety -/ -/ -/ -obligations -: -/ -/ -/ -/ -/ -/ -* -Both -start -and -end -must -be -valid -for -reads -. -/ -/ -/ -* -Both -start -and -end -must -point -to -an -initialized -value -. -/ -/ -/ -* -Both -start -and -end -must -point -to -the -same -allocated -object -and -/ -/ -/ -must -either -be -in -bounds -or -at -most -one -byte -past -the -end -of -the -/ -/ -/ -allocated -object -. -/ -/ -/ -* -Both -start -and -end -must -be -_derived -from_ -a -pointer -to -the -same -/ -/ -/ -object -. -/ -/ -/ -* -The -distance -between -start -and -end -must -not -overflow -isize -. -/ -/ -/ -* -The -distance -being -in -bounds -must -not -rely -on -" -wrapping -around -" -the -/ -/ -/ -address -space -. -/ -/ -/ -* -It -must -be -the -case -that -start -< -= -end -. -/ -/ -/ -* -end -- -start -must -be -greater -than -the -minimum -length -for -this -/ -/ -/ -searcher -. -/ -/ -/ -/ -/ -/ -Also -it -is -expected -that -implementations -of -this -trait -will -tag -this -/ -/ -/ -method -with -a -target_feature -attribute -. -Callers -must -ensure -that -/ -/ -/ -they -are -executing -this -method -in -an -environment -where -that -attribute -/ -/ -/ -is -valid -. -unsafe -fn -find -( -& -self -start -: -* -const -u8 -end -: -* -const -u8 -) -- -> -Option -< -Match -> -; -} -# -[ -cfg -( -all -( -target_arch -= -" -x86_64 -" -target_feature -= -" -sse2 -" -) -) -] -mod -x86_64 -{ -use -core -: -: -arch -: -: -x86_64 -: -: -{ -__m128i -__m256i -} -; -use -alloc -: -: -sync -: -: -Arc -; -use -crate -: -: -packed -: -: -{ -ext -: -: -Pointer -pattern -: -: -Patterns -teddy -: -: -generic -: -: -{ -self -Match -} -} -; -use -super -: -: -{ -Searcher -SearcherT -} -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -super -) -struct -SlimSSSE3 -< -const -BYTES -: -usize -> -{ -slim128 -: -generic -: -: -Slim -< -__m128i -BYTES -> -} -/ -/ -Defines -SlimSSSE3 -wrapper -functions -for -1 -2 -3 -and -4 -bytes -. -macro_rules -! -slim_ssse3 -{ -( -len -: -expr -) -= -> -{ -impl -SlimSSSE3 -< -len -> -{ -/ -/ -/ -Creates -a -new -searcher -using -" -slim -" -Teddy -with -128 -- -bit -/ -/ -/ -vectors -. -If -SSSE3 -is -not -available -in -the -current -/ -/ -/ -environment -then -this -returns -None -. -pub -( -super -) -fn -new -( -patterns -: -& -Arc -< -Patterns -> -) -- -> -Option -< -Searcher -> -{ -if -! -is_available_ssse3 -( -) -{ -return -None -; -} -Some -( -unsafe -{ -SlimSSSE3 -: -: -< -len -> -: -: -new_unchecked -( -patterns -) -} -) -} -/ -/ -/ -Creates -a -new -searcher -using -" -slim -" -Teddy -with -256 -- -bit -/ -/ -/ -vectors -without -checking -whether -SSSE3 -is -available -or -not -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -SSSE3 -is -available -in -the -current -/ -/ -/ -environment -. -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -new_unchecked -( -patterns -: -& -Arc -< -Patterns -> -) -- -> -Searcher -{ -let -slim128 -= -generic -: -: -Slim -: -: -< -__m128i -len -> -: -: -new -( -Arc -: -: -clone -( -patterns -) -) -; -let -memory_usage -= -slim128 -. -memory_usage -( -) -; -let -minimum_len -= -slim128 -. -minimum_len -( -) -; -let -imp -= -Arc -: -: -new -( -SlimSSSE3 -{ -slim128 -} -) -; -Searcher -{ -imp -memory_usage -minimum_len -} -} -} -impl -SearcherT -for -SlimSSSE3 -< -len -> -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -# -[ -inline -] -unsafe -fn -find -( -& -self -start -: -* -const -u8 -end -: -* -const -u8 -) -- -> -Option -< -Match -> -{ -/ -/ -SAFETY -: -All -obligations -except -for -target_feature -are -/ -/ -passed -to -the -caller -. -Our -use -of -target_feature -is -/ -/ -safe -because -construction -of -this -type -requires -that -the -/ -/ -requisite -target -features -are -available -. -self -. -slim128 -. -find -( -start -end -) -} -} -} -; -} -slim_ssse3 -! -( -1 -) -; -slim_ssse3 -! -( -2 -) -; -slim_ssse3 -! -( -3 -) -; -slim_ssse3 -! -( -4 -) -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -super -) -struct -SlimAVX2 -< -const -BYTES -: -usize -> -{ -slim128 -: -generic -: -: -Slim -< -__m128i -BYTES -> -slim256 -: -generic -: -: -Slim -< -__m256i -BYTES -> -} -/ -/ -Defines -SlimAVX2 -wrapper -functions -for -1 -2 -3 -and -4 -bytes -. -macro_rules -! -slim_avx2 -{ -( -len -: -expr -) -= -> -{ -impl -SlimAVX2 -< -len -> -{ -/ -/ -/ -Creates -a -new -searcher -using -" -slim -" -Teddy -with -256 -- -bit -/ -/ -/ -vectors -. -If -AVX2 -is -not -available -in -the -current -/ -/ -/ -environment -then -this -returns -None -. -pub -( -super -) -fn -new -( -patterns -: -& -Arc -< -Patterns -> -) -- -> -Option -< -Searcher -> -{ -if -! -is_available_avx2 -( -) -{ -return -None -; -} -Some -( -unsafe -{ -SlimAVX2 -: -: -< -len -> -: -: -new_unchecked -( -patterns -) -} -) -} -/ -/ -/ -Creates -a -new -searcher -using -" -slim -" -Teddy -with -256 -- -bit -/ -/ -/ -vectors -without -checking -whether -AVX2 -is -available -or -not -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -AVX2 -is -available -in -the -current -/ -/ -/ -environment -. -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -new_unchecked -( -patterns -: -& -Arc -< -Patterns -> -) -- -> -Searcher -{ -let -slim128 -= -generic -: -: -Slim -: -: -< -__m128i -len -> -: -: -new -( -Arc -: -: -clone -( -& -patterns -) -) -; -let -slim256 -= -generic -: -: -Slim -: -: -< -__m256i -len -> -: -: -new -( -Arc -: -: -clone -( -& -patterns -) -) -; -let -memory_usage -= -slim128 -. -memory_usage -( -) -+ -slim256 -. -memory_usage -( -) -; -let -minimum_len -= -slim128 -. -minimum_len -( -) -; -let -imp -= -Arc -: -: -new -( -SlimAVX2 -{ -slim128 -slim256 -} -) -; -Searcher -{ -imp -memory_usage -minimum_len -} -} -} -impl -SearcherT -for -SlimAVX2 -< -len -> -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -# -[ -inline -] -unsafe -fn -find -( -& -self -start -: -* -const -u8 -end -: -* -const -u8 -) -- -> -Option -< -Match -> -{ -/ -/ -SAFETY -: -All -obligations -except -for -target_feature -are -/ -/ -passed -to -the -caller -. -Our -use -of -target_feature -is -/ -/ -safe -because -construction -of -this -type -requires -that -the -/ -/ -requisite -target -features -are -available -. -let -len -= -end -. -distance -( -start -) -; -if -len -< -self -. -slim256 -. -minimum_len -( -) -{ -self -. -slim128 -. -find -( -start -end -) -} -else -{ -self -. -slim256 -. -find -( -start -end -) -} -} -} -} -; -} -slim_avx2 -! -( -1 -) -; -slim_avx2 -! -( -2 -) -; -slim_avx2 -! -( -3 -) -; -slim_avx2 -! -( -4 -) -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -super -) -struct -FatAVX2 -< -const -BYTES -: -usize -> -{ -fat256 -: -generic -: -: -Fat -< -__m256i -BYTES -> -} -/ -/ -Defines -SlimAVX2 -wrapper -functions -for -1 -2 -3 -and -4 -bytes -. -macro_rules -! -fat_avx2 -{ -( -len -: -expr -) -= -> -{ -impl -FatAVX2 -< -len -> -{ -/ -/ -/ -Creates -a -new -searcher -using -" -slim -" -Teddy -with -256 -- -bit -/ -/ -/ -vectors -. -If -AVX2 -is -not -available -in -the -current -/ -/ -/ -environment -then -this -returns -None -. -pub -( -super -) -fn -new -( -patterns -: -& -Arc -< -Patterns -> -) -- -> -Option -< -Searcher -> -{ -if -! -is_available_avx2 -( -) -{ -return -None -; -} -Some -( -unsafe -{ -FatAVX2 -: -: -< -len -> -: -: -new_unchecked -( -patterns -) -} -) -} -/ -/ -/ -Creates -a -new -searcher -using -" -slim -" -Teddy -with -256 -- -bit -/ -/ -/ -vectors -without -checking -whether -AVX2 -is -available -or -not -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -AVX2 -is -available -in -the -current -/ -/ -/ -environment -. -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -new_unchecked -( -patterns -: -& -Arc -< -Patterns -> -) -- -> -Searcher -{ -let -fat256 -= -generic -: -: -Fat -: -: -< -__m256i -len -> -: -: -new -( -Arc -: -: -clone -( -& -patterns -) -) -; -let -memory_usage -= -fat256 -. -memory_usage -( -) -; -let -minimum_len -= -fat256 -. -minimum_len -( -) -; -let -imp -= -Arc -: -: -new -( -FatAVX2 -{ -fat256 -} -) -; -Searcher -{ -imp -memory_usage -minimum_len -} -} -} -impl -SearcherT -for -FatAVX2 -< -len -> -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -# -[ -inline -] -unsafe -fn -find -( -& -self -start -: -* -const -u8 -end -: -* -const -u8 -) -- -> -Option -< -Match -> -{ -/ -/ -SAFETY -: -All -obligations -except -for -target_feature -are -/ -/ -passed -to -the -caller -. -Our -use -of -target_feature -is -/ -/ -safe -because -construction -of -this -type -requires -that -the -/ -/ -requisite -target -features -are -available -. -self -. -fat256 -. -find -( -start -end -) -} -} -} -; -} -fat_avx2 -! -( -1 -) -; -fat_avx2 -! -( -2 -) -; -fat_avx2 -! -( -3 -) -; -fat_avx2 -! -( -4 -) -; -# -[ -inline -] -pub -( -super -) -fn -is_available_ssse3 -( -) -- -> -bool -{ -# -[ -cfg -( -not -( -target_feature -= -" -sse2 -" -) -) -] -{ -false -} -# -[ -cfg -( -target_feature -= -" -sse2 -" -) -] -{ -# -[ -cfg -( -target_feature -= -" -ssse3 -" -) -] -{ -true -} -# -[ -cfg -( -not -( -target_feature -= -" -ssse3 -" -) -) -] -{ -# -[ -cfg -( -feature -= -" -std -" -) -] -{ -std -: -: -is_x86_feature_detected -! -( -" -ssse3 -" -) -} -# -[ -cfg -( -not -( -feature -= -" -std -" -) -) -] -{ -false -} -} -} -} -# -[ -inline -] -pub -( -super -) -fn -is_available_avx2 -( -) -- -> -bool -{ -# -[ -cfg -( -not -( -target_feature -= -" -sse2 -" -) -) -] -{ -false -} -# -[ -cfg -( -target_feature -= -" -sse2 -" -) -] -{ -# -[ -cfg -( -target_feature -= -" -avx2 -" -) -] -{ -true -} -# -[ -cfg -( -not -( -target_feature -= -" -avx2 -" -) -) -] -{ -# -[ -cfg -( -feature -= -" -std -" -) -] -{ -std -: -: -is_x86_feature_detected -! -( -" -avx2 -" -) -} -# -[ -cfg -( -not -( -feature -= -" -std -" -) -) -] -{ -false -} -} -} -} -} -# -[ -cfg -( -target_arch -= -" -aarch64 -" -) -] -mod -aarch64 -{ -use -core -: -: -arch -: -: -aarch64 -: -: -uint8x16_t -; -use -alloc -: -: -sync -: -: -Arc -; -use -crate -: -: -packed -: -: -{ -pattern -: -: -Patterns -teddy -: -: -generic -: -: -{ -self -Match -} -} -; -use -super -: -: -{ -Searcher -SearcherT -} -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -super -) -struct -SlimNeon -< -const -BYTES -: -usize -> -{ -slim128 -: -generic -: -: -Slim -< -uint8x16_t -BYTES -> -} -/ -/ -Defines -SlimSSSE3 -wrapper -functions -for -1 -2 -3 -and -4 -bytes -. -macro_rules -! -slim_neon -{ -( -len -: -expr -) -= -> -{ -impl -SlimNeon -< -len -> -{ -/ -/ -/ -Creates -a -new -searcher -using -" -slim -" -Teddy -with -128 -- -bit -/ -/ -/ -vectors -. -If -SSSE3 -is -not -available -in -the -current -/ -/ -/ -environment -then -this -returns -None -. -pub -( -super -) -fn -new -( -patterns -: -& -Arc -< -Patterns -> -) -- -> -Option -< -Searcher -> -{ -Some -( -unsafe -{ -SlimNeon -: -: -< -len -> -: -: -new_unchecked -( -patterns -) -} -) -} -/ -/ -/ -Creates -a -new -searcher -using -" -slim -" -Teddy -with -256 -- -bit -/ -/ -/ -vectors -without -checking -whether -SSSE3 -is -available -or -not -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -SSSE3 -is -available -in -the -current -/ -/ -/ -environment -. -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -new_unchecked -( -patterns -: -& -Arc -< -Patterns -> -) -- -> -Searcher -{ -let -slim128 -= -generic -: -: -Slim -: -: -< -uint8x16_t -len -> -: -: -new -( -Arc -: -: -clone -( -patterns -) -) -; -let -memory_usage -= -slim128 -. -memory_usage -( -) -; -let -minimum_len -= -slim128 -. -minimum_len -( -) -; -let -imp -= -Arc -: -: -new -( -SlimNeon -{ -slim128 -} -) -; -Searcher -{ -imp -memory_usage -minimum_len -} -} -} -impl -SearcherT -for -SlimNeon -< -len -> -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -# -[ -inline -] -unsafe -fn -find -( -& -self -start -: -* -const -u8 -end -: -* -const -u8 -) -- -> -Option -< -Match -> -{ -/ -/ -SAFETY -: -All -obligations -except -for -target_feature -are -/ -/ -passed -to -the -caller -. -Our -use -of -target_feature -is -/ -/ -safe -because -construction -of -this -type -requires -that -the -/ -/ -requisite -target -features -are -available -. -self -. -slim128 -. -find -( -start -end -) -} -} -} -; -} -slim_neon -! -( -1 -) -; -slim_neon -! -( -2 -) -; -slim_neon -! -( -3 -) -; -slim_neon -! -( -4 -) -; -} diff --git a/third_party/rust/aho-corasick/src/packed/teddy/compile.rs b/third_party/rust/aho-corasick/src/packed/teddy/compile.rs new file mode 100644 index 0000000000000..71f43f510a240 --- /dev/null +++ b/third_party/rust/aho-corasick/src/packed/teddy/compile.rs @@ -0,0 +1,3663 @@ +/ +/ +See +the +README +in +this +directory +for +an +explanation +of +the +Teddy +algorithm +. +use +std +: +: +cmp +; +use +std +: +: +collections +: +: +BTreeMap +; +use +std +: +: +fmt +; +use +crate +: +: +packed +: +: +pattern +: +: +{ +PatternID +Patterns +} +; +use +crate +: +: +packed +: +: +teddy +: +: +Teddy +; +/ +/ +/ +A +builder +for +constructing +a +Teddy +matcher +. +/ +/ +/ +/ +/ +/ +The +builder +primarily +permits +fine +grained +configuration +of +the +Teddy +/ +/ +/ +matcher +. +Most +options +are +made +only +available +for +testing +/ +benchmarking +/ +/ +/ +purposes +. +In +reality +options +are +automatically +determined +by +the +nature +/ +/ +/ +and +number +of +patterns +given +to +the +builder +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +Builder +{ +/ +/ +/ +When +none +this +is +automatically +determined +. +Otherwise +false +means +/ +/ +/ +slim +Teddy +is +used +( +8 +buckets +) +and +true +means +fat +Teddy +is +used +/ +/ +/ +( +16 +buckets +) +. +Fat +Teddy +requires +AVX2 +so +if +that +CPU +feature +isn +' +t +/ +/ +/ +available +and +Fat +Teddy +was +requested +no +matcher +will +be +built +. +fat +: +Option +< +bool +> +/ +/ +/ +When +none +this +is +automatically +determined +. +Otherwise +false +means +/ +/ +/ +that +128 +- +bit +vectors +will +be +used +( +up +to +SSSE3 +instructions +) +where +as +/ +/ +/ +true +means +that +256 +- +bit +vectors +will +be +used +. +As +with +fat +if +/ +/ +/ +256 +- +bit +vectors +are +requested +and +they +aren +' +t +available +then +a +/ +/ +/ +searcher +will +not +be +built +. +avx +: +Option +< +bool +> +} +impl +Default +for +Builder +{ +fn +default +( +) +- +> +Builder +{ +Builder +: +: +new +( +) +} +} +impl +Builder +{ +/ +/ +/ +Create +a +new +builder +for +configuring +a +Teddy +matcher +. +pub +fn +new +( +) +- +> +Builder +{ +Builder +{ +fat +: +None +avx +: +None +} +} +/ +/ +/ +Build +a +matcher +for +the +set +of +patterns +given +. +If +a +matcher +could +not +/ +/ +/ +be +built +then +None +is +returned +. +/ +/ +/ +/ +/ +/ +Generally +a +matcher +isn +' +t +built +if +the +necessary +CPU +features +aren +' +t +/ +/ +/ +available +an +unsupported +target +or +if +the +searcher +is +believed +to +be +/ +/ +/ +slower +than +standard +techniques +( +i +. +e +. +if +there +are +too +many +literals +) +. +pub +fn +build +( +& +self +patterns +: +& +Patterns +) +- +> +Option +< +Teddy +> +{ +self +. +build_imp +( +patterns +) +} +/ +/ +/ +Require +the +use +of +Fat +( +true +) +or +Slim +( +false +) +Teddy +. +Fat +Teddy +uses +/ +/ +/ +16 +buckets +where +as +Slim +Teddy +uses +8 +buckets +. +More +buckets +are +useful +/ +/ +/ +for +a +larger +set +of +literals +. +/ +/ +/ +/ +/ +/ +None +is +the +default +which +results +in +an +automatic +selection +based +/ +/ +/ +on +the +number +of +literals +and +available +CPU +features +. +pub +fn +fat +( +& +mut +self +yes +: +Option +< +bool +> +) +- +> +& +mut +Builder +{ +self +. +fat += +yes +; +self +} +/ +/ +/ +Request +the +use +of +256 +- +bit +vectors +( +true +) +or +128 +- +bit +vectors +( +false +) +. +/ +/ +/ +Generally +a +larger +vector +size +is +better +since +it +either +permits +/ +/ +/ +matching +more +patterns +or +matching +more +bytes +in +the +haystack +at +once +. +/ +/ +/ +/ +/ +/ +None +is +the +default +which +results +in +an +automatic +selection +based +on +/ +/ +/ +the +number +of +literals +and +available +CPU +features +. +pub +fn +avx +( +& +mut +self +yes +: +Option +< +bool +> +) +- +> +& +mut +Builder +{ +self +. +avx += +yes +; +self +} +fn +build_imp +( +& +self +patterns +: +& +Patterns +) +- +> +Option +< +Teddy +> +{ +use +crate +: +: +packed +: +: +teddy +: +: +runtime +; +/ +/ +Most +of +the +logic +here +is +just +about +selecting +the +optimal +settings +/ +/ +or +perhaps +even +rejecting +construction +altogether +. +The +choices +/ +/ +we +have +are +: +fat +( +avx +only +) +or +not +ssse3 +or +avx2 +and +how +many +/ +/ +patterns +we +allow +ourselves +to +search +. +Additionally +for +testing +/ +/ +and +benchmarking +we +permit +callers +to +try +to +" +force +" +a +setting +/ +/ +and +if +the +setting +isn +' +t +allowed +( +e +. +g +. +forcing +AVX +when +AVX +isn +' +t +/ +/ +available +) +then +we +bail +and +return +nothing +. +if +patterns +. +len +( +) +> +64 +{ +return +None +; +} +let +has_ssse3 += +is_x86_feature_detected +! +( +" +ssse3 +" +) +; +let +has_avx += +is_x86_feature_detected +! +( +" +avx2 +" +) +; +let +avx += +if +self +. +avx += += +Some +( +true +) +{ +if +! +has_avx +{ +return +None +; +} +true +} +else +if +self +. +avx += += +Some +( +false +) +{ +if +! +has_ssse3 +{ +return +None +; +} +false +} +else +if +! +has_ssse3 +& +& +! +has_avx +{ +return +None +; +} +else +{ +has_avx +} +; +let +fat += +match +self +. +fat +{ +None += +> +avx +& +& +patterns +. +len +( +) +> +32 +Some +( +false +) += +> +false +Some +( +true +) +if +! +avx += +> +return +None +Some +( +true +) += +> +true +} +; +let +mut +compiler += +Compiler +: +: +new +( +patterns +fat +) +; +compiler +. +compile +( +) +; +let +Compiler +{ +buckets +masks +. +. +} += +compiler +; +/ +/ +SAFETY +: +It +is +required +that +the +builder +only +produce +Teddy +matchers +/ +/ +that +are +allowed +to +run +on +the +current +CPU +since +we +later +assume +/ +/ +that +the +presence +of +( +for +example +) +TeddySlim1Mask256 +means +it +is +/ +/ +safe +to +call +functions +marked +with +the +avx2 +target +feature +. +match +( +masks +. +len +( +) +avx +fat +) +{ +( +1 +false +_ +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddySlim1Mask128 +( +runtime +: +: +TeddySlim1Mask128 +{ +mask1 +: +runtime +: +: +Mask128 +: +: +new +( +masks +[ +0 +] +) +} +) +} +) +( +1 +true +false +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddySlim1Mask256 +( +runtime +: +: +TeddySlim1Mask256 +{ +mask1 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +0 +] +) +} +) +} +) +( +1 +true +true +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddyFat1Mask256 +( +runtime +: +: +TeddyFat1Mask256 +{ +mask1 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +0 +] +) +} +) +} +) +( +2 +false +_ +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddySlim2Mask128 +( +runtime +: +: +TeddySlim2Mask128 +{ +mask1 +: +runtime +: +: +Mask128 +: +: +new +( +masks +[ +0 +] +) +mask2 +: +runtime +: +: +Mask128 +: +: +new +( +masks +[ +1 +] +) +} +) +} +) +( +2 +true +false +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddySlim2Mask256 +( +runtime +: +: +TeddySlim2Mask256 +{ +mask1 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +0 +] +) +mask2 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +1 +] +) +} +) +} +) +( +2 +true +true +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddyFat2Mask256 +( +runtime +: +: +TeddyFat2Mask256 +{ +mask1 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +0 +] +) +mask2 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +1 +] +) +} +) +} +) +( +3 +false +_ +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddySlim3Mask128 +( +runtime +: +: +TeddySlim3Mask128 +{ +mask1 +: +runtime +: +: +Mask128 +: +: +new +( +masks +[ +0 +] +) +mask2 +: +runtime +: +: +Mask128 +: +: +new +( +masks +[ +1 +] +) +mask3 +: +runtime +: +: +Mask128 +: +: +new +( +masks +[ +2 +] +) +} +) +} +) +( +3 +true +false +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddySlim3Mask256 +( +runtime +: +: +TeddySlim3Mask256 +{ +mask1 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +0 +] +) +mask2 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +1 +] +) +mask3 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +2 +] +) +} +) +} +) +( +3 +true +true +) += +> +Some +( +Teddy +{ +buckets +max_pattern_id +: +patterns +. +max_pattern_id +( +) +exec +: +runtime +: +: +Exec +: +: +TeddyFat3Mask256 +( +runtime +: +: +TeddyFat3Mask256 +{ +mask1 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +0 +] +) +mask2 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +1 +] +) +mask3 +: +runtime +: +: +Mask256 +: +: +new +( +masks +[ +2 +] +) +} +) +} +) +_ += +> +unreachable +! +( +) +} +} +} +/ +/ +/ +A +compiler +is +in +charge +of +allocating +patterns +into +buckets +and +generating +/ +/ +/ +the +masks +necessary +for +searching +. +# +[ +derive +( +Clone +) +] +struct +Compiler +< +' +p +> +{ +patterns +: +& +' +p +Patterns +buckets +: +Vec +< +Vec +< +PatternID +> +> +masks +: +Vec +< +Mask +> +} +impl +< +' +p +> +Compiler +< +' +p +> +{ +/ +/ +/ +Create +a +new +Teddy +compiler +for +the +given +patterns +. +If +fat +is +true +/ +/ +/ +then +16 +buckets +will +be +used +instead +of +8 +. +/ +/ +/ +/ +/ +/ +This +panics +if +any +of +the +patterns +given +are +empty +. +fn +new +( +patterns +: +& +' +p +Patterns +fat +: +bool +) +- +> +Compiler +< +' +p +> +{ +let +mask_len += +cmp +: +: +min +( +3 +patterns +. +minimum_len +( +) +) +; +assert +! +( +1 +< += +mask_len +& +& +mask_len +< += +3 +) +; +Compiler +{ +patterns +buckets +: +vec +! +[ +vec +! +[ +] +; +if +fat +{ +16 +} +else +{ +8 +} +] +masks +: +vec +! +[ +Mask +: +: +default +( +) +; +mask_len +] +} +} +/ +/ +/ +Compile +the +patterns +in +this +compiler +into +buckets +and +masks +. +fn +compile +( +& +mut +self +) +{ +let +mut +lonibble_to_bucket +: +BTreeMap +< +Vec +< +u8 +> +usize +> += +BTreeMap +: +: +new +( +) +; +for +( +id +pattern +) +in +self +. +patterns +. +iter +( +) +{ +/ +/ +We +try +to +be +slightly +clever +in +how +we +assign +patterns +into +/ +/ +buckets +. +Generally +speaking +we +want +patterns +with +the +same +/ +/ +prefix +to +be +in +the +same +bucket +since +it +minimizes +the +amount +/ +/ +of +time +we +spend +churning +through +buckets +in +the +verification +/ +/ +step +. +/ +/ +/ +/ +So +we +could +assign +patterns +with +the +same +N +- +prefix +( +where +N +/ +/ +is +the +size +of +the +mask +which +is +one +of +{ +1 +2 +3 +} +) +to +the +/ +/ +same +bucket +. +However +case +insensitive +searches +are +fairly +/ +/ +common +so +we +' +d +for +example +ideally +want +to +treat +abc +and +/ +/ +ABC +as +if +they +shared +the +same +prefix +. +ASCII +has +the +nice +/ +/ +property +that +the +lower +4 +bits +of +A +and +a +are +the +same +so +we +/ +/ +therefore +group +patterns +with +the +same +low +- +nybbe +- +N +- +prefix +into +/ +/ +the +same +bucket +. +/ +/ +/ +/ +MOREOVER +this +is +actually +necessary +for +correctness +! +In +/ +/ +particular +by +grouping +patterns +with +the +same +prefix +into +the +/ +/ +same +bucket +we +ensure +that +we +preserve +correct +leftmost +- +first +/ +/ +and +leftmost +- +longest +match +semantics +. +In +addition +to +the +fact +/ +/ +that +patterns +. +iter +( +) +iterates +in +the +correct +order +this +/ +/ +guarantees +that +all +possible +ambiguous +matches +will +occur +in +/ +/ +the +same +bucket +. +The +verification +routine +could +be +adjusted +to +/ +/ +support +correct +leftmost +match +semantics +regardless +of +bucket +/ +/ +allocation +but +that +results +in +a +performance +hit +. +It +' +s +much +/ +/ +nicer +to +be +able +to +just +stop +as +soon +as +a +match +is +found +. +let +lonybs += +pattern +. +low_nybbles +( +self +. +masks +. +len +( +) +) +; +if +let +Some +( +& +bucket +) += +lonibble_to_bucket +. +get +( +& +lonybs +) +{ +self +. +buckets +[ +bucket +] +. +push +( +id +) +; +} +else +{ +/ +/ +N +. +B +. +We +assign +buckets +in +reverse +because +it +shouldn +' +t +have +/ +/ +any +influence +on +performance +but +it +does +make +it +harder +to +/ +/ +get +leftmost +match +semantics +accidentally +correct +. +let +bucket += +( +self +. +buckets +. +len +( +) +- +1 +) +- +( +id +as +usize +% +self +. +buckets +. +len +( +) +) +; +self +. +buckets +[ +bucket +] +. +push +( +id +) +; +lonibble_to_bucket +. +insert +( +lonybs +bucket +) +; +} +} +for +( +bucket_index +bucket +) +in +self +. +buckets +. +iter +( +) +. +enumerate +( +) +{ +for +& +pat_id +in +bucket +{ +let +pat += +self +. +patterns +. +get +( +pat_id +) +; +for +( +i +mask +) +in +self +. +masks +. +iter_mut +( +) +. +enumerate +( +) +{ +if +self +. +buckets +. +len +( +) += += +8 +{ +mask +. +add_slim +( +bucket_index +as +u8 +pat +. +bytes +( +) +[ +i +] +) +; +} +else +{ +mask +. +add_fat +( +bucket_index +as +u8 +pat +. +bytes +( +) +[ +i +] +) +; +} +} +} +} +} +} +impl +< +' +p +> +fmt +: +: +Debug +for +Compiler +< +' +p +> +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +let +mut +buckets += +vec +! +[ +vec +! +[ +] +; +self +. +buckets +. +len +( +) +] +; +for +( +i +bucket +) +in +self +. +buckets +. +iter +( +) +. +enumerate +( +) +{ +for +& +patid +in +bucket +{ +buckets +[ +i +] +. +push +( +self +. +patterns +. +get +( +patid +) +) +; +} +} +f +. +debug_struct +( +" +Compiler +" +) +. +field +( +" +buckets +" +& +buckets +) +. +field +( +" +masks +" +& +self +. +masks +) +. +finish +( +) +} +} +/ +/ +/ +Mask +represents +the +low +and +high +nybble +masks +that +will +be +used +during +/ +/ +/ +search +. +Each +mask +is +32 +bytes +wide +although +only +the +first +16 +bytes +are +/ +/ +/ +used +for +the +SSSE3 +runtime +. +/ +/ +/ +/ +/ +/ +Each +byte +in +the +mask +corresponds +to +a +8 +- +bit +bitset +where +bit +i +is +set +/ +/ +/ +if +and +only +if +the +corresponding +nybble +is +in +the +ith +bucket +. +The +index +of +/ +/ +/ +the +byte +( +0 +- +15 +inclusive +) +corresponds +to +the +nybble +. +/ +/ +/ +/ +/ +/ +Each +mask +is +used +as +the +target +of +a +shuffle +where +the +indices +for +the +/ +/ +/ +shuffle +are +taken +from +the +haystack +. +AND +' +ing +the +shuffles +for +both +the +/ +/ +/ +low +and +high +masks +together +also +results +in +8 +- +bit +bitsets +but +where +bit +/ +/ +/ +i +is +set +if +and +only +if +the +correspond +* +byte +* +is +in +the +ith +bucket +. +/ +/ +/ +/ +/ +/ +During +compilation +masks +are +just +arrays +. +But +during +search +these +masks +/ +/ +/ +are +represented +as +128 +- +bit +or +256 +- +bit +vectors +. +/ +/ +/ +/ +/ +/ +( +See +the +README +is +this +directory +for +more +details +. +) +# +[ +derive +( +Clone +Copy +Default +) +] +pub +struct +Mask +{ +lo +: +[ +u8 +; +32 +] +hi +: +[ +u8 +; +32 +] +} +impl +Mask +{ +/ +/ +/ +Update +this +mask +by +adding +the +given +byte +to +the +given +bucket +. +The +/ +/ +/ +given +bucket +must +be +in +the +range +0 +- +7 +. +/ +/ +/ +/ +/ +/ +This +is +for +" +slim +" +Teddy +where +there +are +only +8 +buckets +. +fn +add_slim +( +& +mut +self +bucket +: +u8 +byte +: +u8 +) +{ +assert +! +( +bucket +< +8 +) +; +let +byte_lo += +( +byte +& +0xF +) +as +usize +; +let +byte_hi += +( +( +byte +> +> +4 +) +& +0xF +) +as +usize +; +/ +/ +When +using +256 +- +bit +vectors +we +need +to +set +this +bucket +assignment +in +/ +/ +the +low +and +high +128 +- +bit +portions +of +the +mask +. +This +allows +us +to +/ +/ +process +32 +bytes +at +a +time +. +Namely +AVX2 +shuffles +operate +on +each +/ +/ +of +the +128 +- +bit +lanes +rather +than +the +full +256 +- +bit +vector +at +once +. +self +. +lo +[ +byte_lo +] +| += +1 +< +< +bucket +; +self +. +lo +[ +byte_lo ++ +16 +] +| += +1 +< +< +bucket +; +self +. +hi +[ +byte_hi +] +| += +1 +< +< +bucket +; +self +. +hi +[ +byte_hi ++ +16 +] +| += +1 +< +< +bucket +; +} +/ +/ +/ +Update +this +mask +by +adding +the +given +byte +to +the +given +bucket +. +The +/ +/ +/ +given +bucket +must +be +in +the +range +0 +- +15 +. +/ +/ +/ +/ +/ +/ +This +is +for +" +fat +" +Teddy +where +there +are +16 +buckets +. +fn +add_fat +( +& +mut +self +bucket +: +u8 +byte +: +u8 +) +{ +assert +! +( +bucket +< +16 +) +; +let +byte_lo += +( +byte +& +0xF +) +as +usize +; +let +byte_hi += +( +( +byte +> +> +4 +) +& +0xF +) +as +usize +; +/ +/ +Unlike +slim +teddy +fat +teddy +only +works +with +AVX2 +. +For +fat +teddy +/ +/ +the +high +128 +bits +of +our +mask +correspond +to +buckets +8 +- +15 +while +the +/ +/ +low +128 +bits +correspond +to +buckets +0 +- +7 +. +if +bucket +< +8 +{ +self +. +lo +[ +byte_lo +] +| += +1 +< +< +bucket +; +self +. +hi +[ +byte_hi +] +| += +1 +< +< +bucket +; +} +else +{ +self +. +lo +[ +byte_lo ++ +16 +] +| += +1 +< +< +( +bucket +% +8 +) +; +self +. +hi +[ +byte_hi ++ +16 +] +| += +1 +< +< +( +bucket +% +8 +) +; +} +} +/ +/ +/ +Return +the +low +128 +bits +of +the +low +- +nybble +mask +. +pub +fn +lo128 +( +& +self +) +- +> +[ +u8 +; +16 +] +{ +let +mut +tmp += +[ +0 +; +16 +] +; +tmp +. +copy_from_slice +( +& +self +. +lo +[ +. +. +16 +] +) +; +tmp +} +/ +/ +/ +Return +the +full +low +- +nybble +mask +. +pub +fn +lo256 +( +& +self +) +- +> +[ +u8 +; +32 +] +{ +self +. +lo +} +/ +/ +/ +Return +the +low +128 +bits +of +the +high +- +nybble +mask +. +pub +fn +hi128 +( +& +self +) +- +> +[ +u8 +; +16 +] +{ +let +mut +tmp += +[ +0 +; +16 +] +; +tmp +. +copy_from_slice +( +& +self +. +hi +[ +. +. +16 +] +) +; +tmp +} +/ +/ +/ +Return +the +full +high +- +nybble +mask +. +pub +fn +hi256 +( +& +self +) +- +> +[ +u8 +; +32 +] +{ +self +. +hi +} +} +impl +fmt +: +: +Debug +for +Mask +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +let +( +mut +parts_lo +mut +parts_hi +) += +( +vec +! +[ +] +vec +! +[ +] +) +; +for +i +in +0 +. +. +32 +{ +parts_lo +. +push +( +format +! +( +" +{ +: +02 +} +: +{ +: +08b +} +" +i +self +. +lo +[ +i +] +) +) +; +parts_hi +. +push +( +format +! +( +" +{ +: +02 +} +: +{ +: +08b +} +" +i +self +. +hi +[ +i +] +) +) +; +} +f +. +debug_struct +( +" +Mask +" +) +. +field +( +" +lo +" +& +parts_lo +) +. +field +( +" +hi +" +& +parts_hi +) +. +finish +( +) +} +} diff --git a/third_party/rust/aho-corasick/src/packed/teddy/mod.rs b/third_party/rust/aho-corasick/src/packed/teddy/mod.rs index 2df56a39e81ff..504031814f7b0 100644 --- a/third_party/rust/aho-corasick/src/packed/teddy/mod.rs +++ b/third_party/rust/aho-corasick/src/packed/teddy/mod.rs @@ -1,87 +1,353 @@ -/ -/ -Regrettable -but -Teddy -stuff -just -isn -' -t -used -on -all -targets -. -And -for -some -/ -/ -targets -like -aarch64 -only +# +[ +cfg +( +target_arch += " -slim +x86_64 " -Teddy -is -used -and -so +) +] +pub +use +crate +: +: +packed +: +: +teddy +: +: +compile +: +: +Builder +; +# +[ +cfg +( +not +( +target_arch += " -fat +x86_64 " -Teddy -gets -a -/ -/ -bunch -of -dead -- -code -warnings -. -Just -not -worth -trying -to -squash -them -. -Blech -. +) +) +] +pub +use +crate +: +: +packed +: +: +teddy +: +: +fallback +: +: +Builder +; # -! [ -allow +cfg ( -dead_code +not +( +target_arch += +" +x86_64 +" +) ) ] pub -( +use crate +: +: +packed +: +: +teddy +: +: +fallback +: +: +Teddy +; +# +[ +cfg +( +target_arch += +" +x86_64 +" ) +] +pub use -self +crate : : -builder +packed : : -{ -Builder -Searcher -} +teddy +: +: +runtime +: +: +Teddy +; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] +mod +compile ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] mod -builder +runtime ; +# +[ +cfg +( +not +( +target_arch += +" +x86_64 +" +) +) +] mod -generic +fallback +{ +use +crate +: +: +packed +: +: +pattern +: +: +Patterns +; +use +crate +: +: +Match +; +# +[ +derive +( +Clone +Debug +Default +) +] +pub +struct +Builder +( +( +) +) ; +impl +Builder +{ +pub +fn +new +( +) +- +> +Builder +{ +Builder +( +( +) +) +} +pub +fn +build +( +& +self +_ +: +& +Patterns +) +- +> +Option +< +Teddy +> +{ +None +} +pub +fn +fat +( +& +mut +self +_ +: +Option +< +bool +> +) +- +> +& +mut +Builder +{ +self +} +pub +fn +avx +( +& +mut +self +_ +: +Option +< +bool +> +) +- +> +& +mut +Builder +{ +self +} +} +# +[ +derive +( +Clone +Debug +) +] +pub +struct +Teddy +( +( +) +) +; +impl +Teddy +{ +pub +fn +find_at +( +& +self +_ +: +& +Patterns +_ +: +& +[ +u8 +] +_ +: +usize +) +- +> +Option +< +Match +> +{ +None +} +pub +fn +minimum_len +( +& +self +) +- +> +usize +{ +0 +} +pub +fn +heap_bytes +( +& +self +) +- +> +usize +{ +0 +} +} +} diff --git a/third_party/rust/aho-corasick/src/packed/teddy/generic.rs b/third_party/rust/aho-corasick/src/packed/teddy/runtime.rs similarity index 55% rename from third_party/rust/aho-corasick/src/packed/teddy/generic.rs rename to third_party/rust/aho-corasick/src/packed/teddy/runtime.rs index fcdcaa5265ab5..917c1476ad848 100644 --- a/third_party/rust/aho-corasick/src/packed/teddy/generic.rs +++ b/third_party/rust/aho-corasick/src/packed/teddy/runtime.rs @@ -1,1036 +1,812 @@ -use -core -: -: -fmt -: -: -Debug -; -use -alloc -: -: -{ -boxed -: -: -Box -collections -: -: -BTreeMap -format -sync -: -: -Arc -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -packed -: -: -{ -ext -: -: -Pointer -pattern -: -: -Patterns -vector -: -: -{ -FatVector -Vector -} -} -util -: -: -int -: -: -U32 -PatternID -} -; / / -/ -A -match -type -specialized -to +See +the +README +in +this +directory +for +an +explanation +of the Teddy -implementations -below +algorithm . / / -/ -/ -/ -/ -Essentially -instead -of -representing -a -match -at -byte -offsets -we -use -/ -/ -/ -raw -pointers -. -This +It is -because +strongly +recommended +to +peruse the -implementations -below -operate -on -raw -/ +README +before +trying +to +grok +this / / -pointers -and -so -this +code +as +its +use +of +SIMD is -a -more -natural -return -type -based -on -how -the -/ +pretty +opaque +although +I +tried +to +add +comments / / -implementation -works +where +appropriate . / / / / -/ -/ -Also -the -PatternID -used -here +Moreover +while +there is a -u16 -. -# -[ -derive -( -Clone -Copy -Debug -) -] -pub -( -crate -) -struct -Match -{ -pid -: -PatternID -start -: -* -const -u8 -end -: -* -const -u8 -} -impl -Match -{ -/ +lot +of +code +in +this +file +most +of +it +is / / -Returns -the -ID +repeated +variants of the -pattern -that -matched +same +thing . -pub +Specifically +there +are +three +Teddy +/ +/ +variants +: +Slim +128 +- +bit +Teddy ( -crate +8 +buckets ) -fn -pattern +Slim +256 +- +bit +Teddy ( -& -self +8 +buckets ) +/ +/ +and +Fat +256 - -> -PatternID -{ -self +bit +Teddy +( +16 +buckets +) . -pid -} +For +each +variant +there +are +three / / +implementations +corresponding +to +mask +lengths +of +1 +2 +and +3 +. +Bringing +it +to +/ / -Returns a -pointer -into +total +of +nine +variants +. +Each +one +is +structured +roughly the -haystack +same +: +/ +/ +/ +/ +while at -which -the -match -starts -. -pub +< += +len ( -crate -) -fn -start -( -& -self +haystack ) - -> -* -const -u8 -{ -self -. -start -} -/ +CHUNK_SIZE +: / / -Returns -a -pointer -into -the +let +candidate += +find_candidate_in_chunk +( haystack at -which -the -match -ends -. -pub +) +/ +/ +if +not +all +zeroes ( -crate +candidate ) -fn -end +: +/ +/ +if +match += +verify ( -& -self +haystack +at +candidate ) -- -> -* -const -u8 -{ -self -. -end -} -} +: / / +return +match / -A -" -slim -" -Teddy -implementation -that -is -generic -over -both -the -vector -type / / / -and -the -minimum -length -of +For the -patterns -being -searched -for +most +part +this +remains +unchanged . -/ -/ -/ -/ -/ -/ -Only -1 -2 -3 -and -4 -bytes +The +parts +that +vary are -supported -as -minimum -lengths -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Slim -< -V -const -BYTES -: -usize -> -{ -/ +the / / -A -generic -data -structure +verification +routine +( for -doing -" slim -" -Teddy -verification -. -teddy -: +vs +fat Teddy -< -8 -> -/ -/ -/ -The -masks -used -as -inputs -to +) +and the -shuffle -operation -to -generate -/ +candidate +extraction / / -candidates ( -which -are -fed -into +based +on the -verification -routines +number +of +masks ) . -masks -: -[ -Mask -< -V -> -; -BYTES -] -} -impl -< -V -: -Vector -const -BYTES -: -usize -> -Slim -< -V -BYTES -> -{ / / / -Create +/ +In +the +code +below a -new " -slim +candidate " -Teddy -searcher -for -the -given -patterns -. -/ -/ -/ -/ -/ -/ -# -Panics +corresponds +to +a +single +vector +with +8 +- +bit / / +lanes +. +Each +lane +is +itself +an +8 +- +bit +bitset +where +the +ith +bit +is +set +in +the / / +jth +lane +if +and +only +if +the +byte +occurring +at +position +j +is +in +the / / -This -panics -when -BYTES -is -any -value -other -than -1 -2 -3 +bucket +i +( +where +the +j +th +position +is +the +position +in +the +current +window +/ +/ +of +the +haystack +which +is +always +16 or -4 +32 +bytes +) . +Note +to +be +careful +here +: +/ +/ +the +ith +bit +and +the +jth +lane +correspond +to +the +least +significant +bits +of +the +/ / +vector +. +So +when +visualizing +how +the +current +window +of +bytes +is +stored +in +a / / +vector +you +often +need +to +flip +it +around +. +For +example +the +text +abcd +in +a / / +4 +- +byte +vector +would +look +like +this +: / -# -Safety / / / +01100100 +01100011 +01100010 +01100001 / / +d +c +b +a / -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for / / / +When the -current -CPU -. -# -[ -inline -( -always -) -] -pub -( -crate -) -unsafe -fn -new -( -patterns -: -Arc -< -Patterns -> -) -- -> -Slim -< -V -BYTES -> -{ -assert -! -( -1 -< -= -BYTES -& -& -BYTES -< -= -4 -" -only +mask +length +is 1 -2 -3 -or -4 -bytes -are -supported -" -) -; -let -teddy -= -Teddy -: -: -new -( -patterns -) -; -let -masks -= -SlimMaskBuilder -: +then +finding +the +candidate +is +pretty +straight +/ +/ +forward : -from_teddy +you +just +apply +the +shuffle +indices ( -& -teddy +from +the +haystack +window ) -; -Slim -{ -teddy -masks -} -} -/ +to / / -Returns the -approximate -total -amount -of -heap -used -by -this -type +masks +and +then +AND +them +together +as +described in +the +README +. +But +for / / -/ -units +masks of -bytes +length +2 +and +3 +you +need +to +keep +a +little +state . -# -[ -inline +Specifically +/ +/ +you +need +to +store +the +final +1 ( -always +for +mask +length +2 ) -] -pub +or +2 ( -crate +for +mask +length +3 ) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -teddy -. -memory_usage -( -) -} -/ / / -Returns -the -minimum -length -in bytes +of +the +candidate +for +use +when +searching +the +next +window +. +This +is +for +/ +/ +handling +matches that -a -haystack -must -be -in -order +span +two +windows +. +/ / / / +With +respect to -use +the +repeated +code it -with -this -searcher -. -# -[ -inline -( -always -) -] -pub -( -crate -) -fn -minimum_len -( -& -self -) -- -> -usize -{ -V -: -: -BYTES -+ -( -BYTES -- -1 -) -} -} -impl -< -V -: -Vector -> -Slim -< -V -1 -> -{ -/ +would +likely +be +possible +to +reduce / / -Look -for -an -occurrences -of the -patterns -in +number +of +copies +of +code +below +using +polymorphism +but +I +find this -finder -in -the -haystack -/ / / -given -by -the -start -and -end -pointers +formulation +clearer +instead +of +needing +to +reason +through +generics . +However / / +I +admit +there +may +be +a +simpler +generic +construction +that +I +' +m +missing +. / / / / -If -no -match -could -be -found -then -None -is -returned -. -/ +All +variants +are +fairly +heavily +tested +in +src / +packed / +tests +. +rs +. +use +std +: +: +arch +: +: +x86_64 +: +: +* +; +use +std +: +: +mem +; +use +crate +: +: +packed +: +: +pattern +: +: +{ +PatternID +Patterns +} +; +use +crate +: +: +packed +: +: +teddy +: +: +compile +; +use +crate +: +: +packed +: +: +vector +: +: +* +; +use +crate +: +: +Match +; / / / -# -Safety +The +Teddy +runtime +. / / / / / / -The -given -pointers -representing -the -haystack -must +A +Teddy +runtime +can be -valid +used to -read +quickly +search +for +occurrences +of +one +or / / / -from +more +patterns . -They -must -also -point +While +it +does +not +scale to -a -region +an +arbitrary +number of -memory -that -is -at -least -the +patterns / / / -minimum -length -required -by -this -searcher -. +like +Aho +- +Corasick +it +does +find +occurrences +for +a +small +set +of +patterns / / / +much +more +quickly +than +Aho +- +Corasick +. / / / -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for / / / -the -current -CPU -. -# -[ -inline -( -always -) -] -pub -( -crate -) -unsafe -fn -find -( -& -self -start -: -* -const -u8 -end -: -* -const -u8 -) -- -> -Option -< -Match -> -{ -let -len -= -end -. -distance -( -start -) -; -debug_assert -! -( -len -> -= -self -. -minimum_len -( -) -) -; -let -mut -cur -= -start -; -while -cur -< -= -end -. -sub -( -V -: -: -BYTES -) -{ -if -let -Some -( -m -) -= -self -. -find_one -( -cur -end -) -{ -return -Some -( -m -) -; -} -cur -= -cur -. -add -( -V -: -: -BYTES -) -; -} -if -cur -< -end -{ -cur -= -end -. -sub -( -V -: -: -BYTES -) -; -if -let -Some -( -m -) -= -self -. -find_one -( -cur -end -) -{ -return -Some -( -m -) -; -} -} -None -} +Teddy +cannot +run +on +small +haystacks +below +a +certain +size +which +is / / / -Look -for -a -match -starting -at +dependent +on the -V -: -: -BYTES -at -and -after -cur +type +of +matcher +used . -If +This +size +can +be +queried +via +the / / / -there -isn -' -t -one -then -None -is -returned +minimum_len +method +. +Violating +this +will +result +in +a +panic . / / @@ -1038,363 +814,359 @@ returned / / / -# -Safety -/ -/ -/ +Finally +when +callers +use +a +Teddy +runtime +they +must +provide +precisely +the / / / -The -given -pointers -representing -the -haystack -must -be -valid +patterns +used to -read +construct +the +Teddy +matcher +. +Violating +this +will +result / / / -from -. -They -must -also -point -to +in +either a -region -of +panic +or +incorrect +results +but +will +never +sacrifice memory -that -is -at -least -the / / / -minimum -length -required -by -this -searcher +safety . +# +[ +derive +( +Clone +Debug +) +] +pub +struct +Teddy +{ / / / +The +allocation +of +patterns +in +buckets +. +This +only +contains +the +IDs +of / / / -Callers -must -ensure -that -this -is -okay +patterns +. +In +order to -call -in +do +full +verification +callers +must +provide the -current -target -for / / / -the -current -CPU +actual +patterns +when +using +Teddy . -# -[ -inline -( -always -) -] -unsafe -fn -find_one -( -& -self -cur -: -* -const -u8 -end +pub +buckets : -* -const -u8 -) -- -> -Option +Vec < -Match +Vec +< +PatternID +> > -{ -let -c -= -self -. -candidate -( -cur -) -; -if -! -c -. -is_zero -( -) -{ -if -let -Some -( -m -) -= -self -. -teddy -. -verify -( -cur -end -c -) -{ -return -Some -( -m -) -; -} -} -None -} / / / -Look -for +The +maximum +identifier +of a -candidate -match -( -represented +pattern +. +This +is +used as a -vector -) -starting -at -the +sanity +check +to / / / -V -: -: -BYTES -at -and -after -cur -. -If -there -isn -' -t -one -then -a -vector -with +ensure +that +the +patterns +provided +by +the +caller +are +the +same +as +the / / / -all -bits -set +patterns +that +were +used to -zero -is -returned +compile +the +matcher . +This +sanity +check / / / +permits +safely +eliminating +bounds +checks +regardless +of +what +patterns / / / -# -Safety +are +provided +by +the +caller +. / / / / / / -The -given -pointer -representing +Note +that +users +of the -haystack -must -be -valid -to -read +aho +- +corasick +crate +cannot +get +this +wrong +. +Only / / / -from -. +code +internal +to +this +crate +can +get +it +wrong +since +neither +Patterns / / / +type +nor +the +Teddy +runtime +are +public +API +items +. +pub +max_pattern_id +: +PatternID / / / -Callers -must -ensure -that -this -is -okay +The +actual +runtime to -call -in -the -current -target -for +use +. +pub +exec +: +Exec +} +impl +Teddy +{ / / / +Return the -current -CPU -. -# -[ -inline -( -always -) -] -unsafe -fn -candidate -( -& -self -cur -: -* -const -u8 -) -- -> -V -{ -let -chunk -= -V -: -: -load_unaligned -( -cur -) -; -Mask -: -: -members1 -( -chunk -self +first +occurrence +of +a +match +in +the +given +haystack +after +or +/ +/ +/ +starting +at +at . -masks -) -} -} -impl -< -V -: -Vector -> -Slim -< -V -2 -> -{ / / / -See -Slim -< -V -1 -> -: -: -find +/ +/ +/ +The +patterns +provided +must +be +precisely +the +same +patterns +given +to +the +/ +/ +/ +Teddy +builder +otherwise +this +may +panic +or +produce +incorrect +results . -# -[ -inline +/ +/ +/ +/ +/ +/ +All +matches +are +consistent +with +the +match +semantics ( -always +leftmost +- +first +or +/ +/ +/ +leftmost +- +longest ) -] +set +on +pats +. pub -( -crate -) -unsafe fn -find +find_at ( & self -start +pats : -* -const -u8 -end +& +Patterns +haystack : -* -const +& +[ u8 +] +at +: +usize ) - > @@ -1403,645 +1175,940 @@ Option Match > { -let -len -= -end +/ +/ +This +assert +is +a +bit +subtle +but +it +' +s +an +important +guarantee . -distance -( -start -) -; -debug_assert +/ +/ +Namely +if +the +maximum +pattern +ID +seen +by +Teddy +is +the +same +as +the +/ +/ +one +in +the +patterns +given +then +we +are +guaranteed +that +every +pattern +/ +/ +ID +in +all +Teddy +buckets +are +valid +indices +into +pats +. +While +this +/ +/ +is +nominally +true +there +is +no +guarantee +that +callers +provide +the +/ +/ +same +pats +to +both +the +Teddy +builder +and +the +searcher +which +would +/ +/ +otherwise +make +find_at +unsafe +to +call +. +But +this +assert +lets +us +/ +/ +keep +this +routine +safe +and +eliminate +an +important +bounds +check +in +/ +/ +verification +. +assert_eq ! ( -len -> -= self . -minimum_len +max_pattern_id +pats +. +max_pattern_id ( ) +" +teddy +must +be +called +with +same +patterns +it +was +built +with +" ) ; -let -mut -cur +/ +/ +SAFETY +: +The +haystack +must +have +at +least +a +minimum +number +of +bytes +/ +/ +for +Teddy +to +be +able +to +work +. +The +minimum +number +varies +depending +on +/ +/ +which +matcher +is +used +below +. +If +this +is +violated +then +it +' +s +possible +/ +/ +for +searching +to +do +out +- +of +- +bounds +writes +. +assert +! +( +haystack +[ +at +. +. +] +. +len +( +) +> = -start +self . -add +minimum_len ( -1 +) ) ; -let -mut -prev0 -= -V +/ +/ +SAFETY +: +The +various +Teddy +matchers +are +always +safe +to +call +because +/ +/ +the +Teddy +builder +guarantees +that +a +particular +Exec +variant +is +/ +/ +built +only +when +it +can +be +run +the +current +CPU +. +That +is +the +Teddy +/ +/ +builder +will +not +produce +a +Exec +: +: +TeddySlim1Mask256 +unless +AVX2 +is +/ +/ +enabled +. +That +is +our +dynamic +CPU +feature +detection +is +performed +/ +/ +once +in +the +builder +and +we +rely +on +the +type +system +to +avoid +needing +/ +/ +to +do +it +again +. +unsafe +{ +match +self +. +exec +{ +Exec : : -splat +TeddySlim1Mask128 ( -0xFF +ref +e ) -; -while -cur -< = -end +> +{ +e . -sub +find_at ( -V +pats +self +haystack +at +) +} +Exec : : -BYTES -) -{ -if -let -Some +TeddySlim1Mask256 ( -m +ref +e ) = -self +> +{ +e . -find_one +find_at ( -cur -end -& -mut -prev0 +pats +self +haystack +at ) -{ -return -Some +} +Exec +: +: +TeddyFat1Mask256 ( -m +ref +e ) -; -} -cur = -cur +> +{ +e . -add +find_at ( -V +pats +self +haystack +at +) +} +Exec : : -BYTES +TeddySlim2Mask128 +( +ref +e ) -; -} -if -cur -< -end -{ -cur = -end +> +{ +e . -sub +find_at ( -V +pats +self +haystack +at +) +} +Exec : : -BYTES +TeddySlim2Mask256 +( +ref +e ) -; -prev0 = -V -: -: -splat +> +{ +e +. +find_at ( -0xFF +pats +self +haystack +at ) -; -if -let -Some +} +Exec +: +: +TeddyFat2Mask256 ( -m +ref +e ) = -self +> +{ +e . -find_one +find_at ( -cur -end -& -mut -prev0 -) -{ -return -Some -( -m +pats +self +haystack +at ) -; -} } -None -} -/ -/ -/ -See -Slim -< -V -1 -> +Exec : : -find_one -. -# -[ -inline +TeddySlim3Mask128 ( -always +ref +e ) -] -unsafe -fn -find_one += +> +{ +e +. +find_at ( -& +pats self -cur -: -* -const -u8 -end +haystack +at +) +} +Exec : -* -const -u8 -prev0 : -& -mut -V +TeddySlim3Mask256 +( +ref +e ) -- -> -Option -< -Match += > { -let -c -= -self +e . -candidate -( -cur -prev0 -) -; -if -! -c -. -is_zero +find_at ( +pats +self +haystack +at ) -{ -if -let -Some +} +Exec +: +: +TeddyFat3Mask256 ( -m +ref +e ) = -self -. -teddy -. -verify -( -cur -. -sub -( -1 -) -end -c -) +> { -return -Some +e +. +find_at ( -m +pats +self +haystack +at ) -; } } -None +} } / / / -See -Slim -< -V -1 -> -: -: -candidate +Returns +the +minimum +length +of +a +haystack +that +must +be +provided +by +/ +/ +/ +callers +to +this +Teddy +searcher . -# -[ -inline -( -always -) -] -unsafe +Providing +a +haystack +shorter +than +this +/ +/ +/ +will +result +in +a +panic +but +will +never +violate +memory +safety +. +pub fn -candidate +minimum_len ( & self -cur -: -* -const -u8 -prev0 -: -& -mut -V ) - > -V +usize { -let -chunk +/ +/ +SAFETY +: +These +values +must +be +correct +in +order +to +ensure +safety +. +/ +/ +The +Teddy +runtime +assumes +their +haystacks +have +at +least +these +/ +/ +lengths +. +Violating +this +will +sacrifice +memory +safety +. +match +self +. +exec +{ +Exec +: +: +TeddySlim1Mask128 +( +_ +) = -V +> +16 +Exec : : -load_unaligned +TeddySlim1Mask256 ( -cur +_ ) -; -let += +> +32 +Exec +: +: +TeddyFat1Mask256 ( -res0 -res1 +_ ) = -Mask +> +16 +Exec : : -members2 +TeddySlim2Mask128 ( -chunk -self -. -masks +_ ) -; -let -res0prev0 = -res0 -. -shift_in_one_byte +> +17 +Exec +: +: +TeddySlim2Mask256 ( -* -prev0 +_ ) -; -let -res = -res0prev0 -. -and +> +33 +Exec +: +: +TeddyFat2Mask256 ( -res1 +_ ) -; -* -prev0 = -res0 -; -res -} -} -impl -< -V -: -Vector -> -Slim -< -V -3 -> -{ -/ -/ -/ -See -Slim -< -V -1 > +17 +Exec : : -find -. -# -[ -inline -( -always -) -] -pub -( -crate -) -unsafe -fn -find +TeddySlim3Mask128 ( -& -self -start -: -* -const -u8 -end -: -* -const -u8 +_ ) -- -> -Option -< -Match -> -{ -let -len = -end -. -distance -( -start -) -; -debug_assert -! -( -len > -= -self -. -minimum_len -( -) -) -; -let -mut -cur -= -start -. -add -( -2 -) -; -let -mut -prev0 -= -V +18 +Exec : : -splat +TeddySlim3Mask256 ( -0xFF +_ ) -; -let -mut -prev1 = -V +> +34 +Exec : : -splat +TeddyFat3Mask256 ( -0xFF +_ ) -; -while -cur -< = -end +> +34 +} +} +/ +/ +/ +Returns +the +approximate +total +amount +of +heap +used +by +this +searcher +in +/ +/ +/ +units +of +bytes . -sub +pub +fn +heap_bytes ( -V -: -: -BYTES +& +self ) +- +> +usize { -if let -Some -( -m -) +num_patterns = self . -find_one -( -cur -end -& -mut -prev0 -& -mut -prev1 -) -{ -return -Some -( -m -) +max_pattern_id +as +usize ++ +1 ; -} -cur -= -cur +self . -add -( -V -: -: -BYTES -) -; -} -if -cur -< -end -{ -cur -= -end +buckets . -sub +len ( -V +) +* +mem : : -BYTES -) -; -prev0 -= -V +size_of : : -splat +< +Vec +< +PatternID +> +> ( -0xFF ) -; -prev1 -= -V ++ +num_patterns +* +mem : : -splat -( -0xFF -) -; -if -let -Some -( -m -) -= -self -. -find_one -( -cur -end -& -mut -prev0 -& -mut -prev1 -) -{ -return -Some +size_of +: +: +< +PatternID +> ( -m ) -; -} -} -None } / / / -See +Runs +the +verification +routine +for Slim -< -V -1 -> -: -: -find_one +128 +- +bit +Teddy . -# -[ -inline -( -always -) -] -unsafe -fn -find_one -( -& +/ +/ +/ +/ +/ +/ +The +candidate +given +should +be +a +collection +of +8 +- +bit +bitsets +( +one +bitset +/ +/ +/ +per +lane +) +where +the +ith +bit +is +set +in +the +jth +lane +if +and +only +if +the +/ +/ +/ +byte +occurring +at +at ++ +j +in +haystack +is +in +the +bucket +i +. +/ +/ +/ +/ +/ +/ +This +is +not +safe +to +call +unless +the +SSSE3 +target +feature +is +enabled +. +/ +/ +/ +The +target_feature +attribute +is +not +applied +since +this +function +is +/ +/ +/ +always +forcefully +inlined +. +# +[ +inline +( +always +) +] +unsafe +fn +verify128 +( +& self -cur +pats : -* -const -u8 -end +& +Patterns +haystack : -* -const +& +[ u8 -prev0 +] +at : -& -mut -V -prev1 +usize +cand : -& -mut -V +__m128i ) - > @@ -2050,26 +2117,83 @@ Option Match > { -let -c -= +debug_assert +! +( +! +is_all_zeroes128 +( +cand +) +) +; +debug_assert_eq +! +( +8 self . +buckets +. +len +( +) +) +; +/ +/ +Convert +the candidate +into +64 +- +bit +chunks +and +then +verify +each +of +/ +/ +those +chunks +. +let +parts += +unpack64x128 ( -cur -prev0 -prev1 +cand ) ; -if -! -c +for +( +i +& +part +) +in +parts +. +iter +( +) . -is_zero +enumerate ( ) { +let +pos += +at ++ +i +* +8 +; if let Some @@ -2079,18 +2203,13 @@ m = self . -teddy -. -verify -( -cur -. -sub +verify64 ( -2 -) -end -c +pats +8 +haystack +pos +part ) { return @@ -2106,152 +2225,115 @@ None / / / -See +Runs +the +verification +routine +for Slim -< -V -1 -> -: -: -candidate +256 +- +bit +Teddy . -# -[ -inline -( -always -) -] -unsafe -fn +/ +/ +/ +/ +/ +/ +The candidate +given +should +be +a +collection +of +8 +- +bit +bitsets ( -& -self -cur -: -* -const -u8 -prev0 -: -& -mut -V -prev1 -: -& -mut -V -) -- -> -V -{ -let -chunk -= -V -: -: -load_unaligned -( -cur -) -; -let -( -res0 -res1 -res2 -) -= -Mask -: -: -members3 -( -chunk -self -. -masks -) -; -let -res0prev0 -= -res0 -. -shift_in_two_bytes -( -* -prev0 -) -; -let -res1prev1 -= -res1 -. -shift_in_one_byte -( -* -prev1 +one +bitset +/ +/ +/ +per +lane ) -; -let -res -= -res0prev0 -. +where +the +ith +bit +is +set +in +the +jth +lane +if and -( -res1prev1 -) +only +if +the +/ +/ +/ +byte +occurring +at +at ++ +j +in +haystack +is +in +the +bucket +i . -and -( -res2 -) -; -* -prev0 -= -res0 -; -* -prev1 -= -res1 -; -res -} -} -impl -< -V -: -Vector -> -Slim -< -V -4 -> -{ / / / -See -Slim -< -V -1 -> -: -: -find +/ +/ +/ +This +is +not +safe +to +call +unless +the +AVX2 +target +feature +is +enabled +. +/ +/ +/ +The +target_feature +attribute +is +not +applied +since +this +function +is +/ +/ +/ +always +forcefully +inlined . # [ @@ -2260,26 +2342,28 @@ inline always ) ] -pub -( -crate -) unsafe fn -find +verify256 ( & self -start +pats : -* -const -u8 -end +& +Patterns +haystack : -* -const +& +[ u8 +] +at +: +usize +cand +: +__m256i ) - > @@ -2288,180 +2372,82 @@ Option Match > { -let -len -= -end -. -distance +debug_assert +! ( -start +! +is_all_zeroes256 +( +cand +) ) ; -debug_assert +debug_assert_eq ! ( -len -> -= +8 self . -minimum_len +buckets +. +len ( ) ) ; +/ +/ +Convert +the +candidate +into +64 +- +bit +chunks +and +then +verify +each +of +/ +/ +those +chunks +. let -mut -cur +parts = -start -. -add +unpack64x256 ( -3 +cand ) ; -let -mut -prev0 -= -V -: -: -splat +for ( -0xFF +i +& +part ) -; -let -mut -prev1 -= -V -: -: -splat +in +parts +. +iter ( -0xFF ) -; -let -mut -prev2 -= -V -: -: -splat +. +enumerate ( -0xFF -) -; -while -cur -< -= -end -. -sub -( -V -: -: -BYTES ) { -if let -Some -( -m -) -= -self -. -find_one -( -cur -end -& -mut -prev0 -& -mut -prev1 -& -mut -prev2 -) -{ -return -Some -( -m -) -; -} -cur -= -cur -. -add -( -V -: -: -BYTES -) -; -} -if -cur -< -end -{ -cur -= -end -. -sub -( -V -: -: -BYTES -) -; -prev0 -= -V -: -: -splat -( -0xFF -) -; -prev1 -= -V -: -: -splat -( -0xFF -) -; -prev2 +pos = -V -: -: -splat -( -0xFF -) +at ++ +i +* +8 ; if let @@ -2472,19 +2458,13 @@ m = self . -find_one +verify64 ( -cur -end -& -mut -prev0 -& -mut -prev1 -& -mut -prev2 +pats +8 +haystack +pos +part ) { return @@ -2500,15 +2480,136 @@ None / / / -See -Slim +Runs +the +verification +routine +for +Fat +256 +- +bit +Teddy +. +/ +/ +/ +/ +/ +/ +The +candidate +given +should +be +a +collection +of +8 +- +bit +bitsets +( +one +bitset +/ +/ +/ +per +lane +) +where +the +ith +bit +is +set +in +the +jth +lane +if +and +only +if +the +/ +/ +/ +byte +occurring +at +at ++ +( +j < -V -1 -> +16 +? +j : +j +- +16 +) +in +haystack +is +in +the +/ +/ +/ +bucket +j +< +16 +? +i : -find_one +i ++ +8 +. +/ +/ +/ +/ +/ +/ +This +is +not +safe +to +call +unless +the +AVX2 +target +feature +is +enabled +. +/ +/ +/ +The +target_feature +attribute +is +not +applied +since +this +function +is +/ +/ +/ +always +forcefully +inlined . # [ @@ -2519,35 +2620,26 @@ always ] unsafe fn -find_one +verify_fat256 ( & self -cur -: -* -const -u8 -end -: -* -const -u8 -prev0 +pats : & -mut -V -prev1 +Patterns +haystack : & -mut -V -prev2 +[ +u8 +] +at : -& -mut -V +usize +cand +: +__m256i ) - > @@ -2556,601 +2648,750 @@ Option Match > { -let -c -= -self -. -candidate +debug_assert +! ( -cur -prev0 -prev1 -prev2 +! +is_all_zeroes256 +( +cand +) ) ; -if +debug_assert_eq ! -c -. -is_zero -( -) -{ -if -let -Some ( -m -) -= +16 self . -teddy -. -verify -( -cur +buckets . -sub +len ( -3 -) -end -c ) -{ -return -Some -( -m ) ; -} -} -None -} / / +This +is +a +bit +tricky +but +we +basically +want +to +convert +our +/ / -See -Slim -< -V -1 -> -: -: -candidate -. -# -[ -inline -( -always -) -] -unsafe -fn candidate -( -& -self -cur -: -* -const -u8 -prev0 -: -& -mut -V -prev1 -: -& -mut -V -prev2 -: -& -mut -V -) -- -> -V -{ -let -chunk -= -V -: -: -load_unaligned -( -cur -) -; -let -( -res0 -res1 -res2 -res3 -) -= -Mask -: -: -members4 -( -chunk -self -. -masks -) -; -let -res0prev0 -= -res0 +which +looks +like +this +/ +/ +/ +/ +a31 +a30 . -shift_in_three_bytes -( -* -prev0 -) -; -let -res1prev1 -= -res1 . -shift_in_two_bytes -( -* -prev1 -) -; -let -res2prev2 -= -res2 . -shift_in_one_byte -( -* -prev2 -) -; -let -res -= -res0prev0 +a17 +a16 +a15 +a14 . -and -( -res1prev1 -) . -and -( -res2prev2 -) . -and -( -res3 -) -; -* -prev0 -= -res0 -; -* -prev1 -= -res1 -; -* -prev2 -= -res2 -; -res -} -} +a01 +a00 / / / -A -" -fat -" -Teddy -implementation -that +/ +where +each +a +( +i +) is -generic -over -both +an +8 +- +bit +bitset +corresponding +to the -vector -type +activated +/ +/ +buckets +to +this / / / -and -the -minimum -length -of -the -patterns -being -searched -for +/ +a31 +a15 +a30 +a14 +a29 +a13 . +. +. +a18 +a02 +a17 +a01 +a16 +a00 / / / / +Namely +for +Fat +Teddy +the +high +128 +- +bits +of +the +candidate +correspond / / -Only -1 -2 -3 -and -4 -bytes -are -supported -as -minimum -lengths -. -# -[ -derive -( -Clone -Debug -) -] -pub +to +the +same +bytes +in +the +haystack +in +the +low +128 +- +bits ( -crate -) -struct -Fat -< -V -const -BYTES -: -usize -> -{ -/ +so +we +only / / -A -generic -data -structure +scan +16 +bytes +at +a +time +) +but +are for -doing -" -fat -" -Teddy -verification +buckets +8 +- +15 +instead +of +0 +- +7 . -teddy -: -Teddy -< -16 -> +/ / / / The -masks -used -as -inputs -to -the -shuffle -operation +verification +routine +wants to -generate -/ +look +at +all +potentially +matching / / -candidates -( -which -are -fed -into +buckets +before +moving +on +to the -verification -routines -) +next +lane . -masks -: -[ -Mask -< -V -> -; -BYTES -] -} -impl -< -V -: -FatVector -const -BYTES -: -usize -> -Fat -< -V -BYTES -> -{ -/ -/ -/ -Create -a -new -" -fat -" -Teddy -searcher +So for -the -given -patterns -. +example +both / / +a16 +and +a00 +both +correspond +to +the +first +byte +in +our +window +; +a00 / / +contains +buckets +0 +- +7 +and +a16 +contains +buckets +8 +- +15 +. +Specifically / / -# -Panics +a16 +should +be +checked +before +a01 +. +So +the +transformation +shown +above / / +allows +us +to +use +our +normal +verification +procedure +with +one +small / / +change +: +we +treat +each +bitset +as +16 +bits +instead +of +8 +bits +. / / -This -panics -when -BYTES -is -any -value -other -than -1 -2 -3 -or -4 +Swap +the +128 +- +bit +lanes +in +the +candidate +vector . +let +swap += +_mm256_permute4x64_epi64 +( +cand +0x4E +) +; / / +Interleave +the +bytes +from +the +low +128 +- +bit +lanes +starting +with / / +cand +first +. +let +r1 += +_mm256_unpacklo_epi8 +( +cand +swap +) +; / / -# -Safety +Interleave +the +bytes +from +the +high +128 +- +bit +lanes +starting +with / / +cand +first +. +let +r2 += +_mm256_unpackhi_epi8 +( +cand +swap +) +; / / +Now +just +take +the +2 +low +64 +- +bit +integers +from +both +r1 +and +r2 +. +We / / -Callers -must -ensure -that -this -is -okay -to -call -in +can +drop the -current -target -for +high +64 +- +bit +integers +because +they +are +a +mirror +image / / +of +the +low +64 +- +bit +integers +. +All +we +care +about +are +the +low +128 +- +bit +/ +/ +lanes +of +r1 +and +r2 +. +Combined +they +contain +all +our +16 +- +bit +bitsets +/ / +laid +out +in the -current -CPU +desired +order +as +described +above . -# -[ -inline +let +parts += +unpacklo64x256 ( -always +r1 +r2 ) -] -pub +; +for ( -crate +i +& +part ) -unsafe -fn -new +in +parts +. +iter ( -patterns -: -Arc -< -Patterns -> ) -- -> -Fat -< -V -BYTES -> -{ -assert -! +. +enumerate ( -1 -< -= -BYTES -& -& -BYTES -< +) +{ +let +pos = +at ++ +i +* 4 -" -only -1 -2 -3 -or -4 -bytes -are -supported -" -) ; +if let -teddy -= -Teddy -: -: -new +Some ( -patterns +m ) -; -let -masks = -FatMaskBuilder -: -: -from_teddy +self +. +verify64 ( -& -teddy +pats +16 +haystack +pos +part ) -; -Fat { -teddy -masks +return +Some +( +m +) +; } } +None +} / / / -Returns -the -approximate -total -amount -of -heap -used -by -this -type +Verify +whether +there +are +any +matches +starting +at +or +after +at in +the / / / -units -of -bytes +given +haystack . -# -[ -inline +The +candidate +given +should +correspond +to +either +8 +- +bit +/ +/ +/ ( -always +for +8 +buckets ) -] -pub +or +16 +- +bit ( -crate +16 +buckets +) +bitsets +. +# +[ +inline +( +always ) +] fn -memory_usage +verify64 ( & self +pats +: +& +Patterns +bucket_count +: +usize +haystack +: +& +[ +u8 +] +at +: +usize +mut +cand +: +u64 ) - > -usize +Option +< +Match +> { +/ +/ +N +. +B +. +While +the +bucket +count +is +known +from self . -teddy +buckets . -memory_usage +len ( ) -} -/ / / -Returns -the -minimum -length -in -bytes -that +requiring +it +as a +parameter +makes +it +easier +for +the +optimizer +to +/ +/ +know +its +value +and +thus +produce +more +efficient +codegen +. +debug_assert +! +( +bucket_count += += +8 +| +| +bucket_count += += +16 +) +; +while +cand +! += +0 +{ +let +bit += +cand +. +trailing_zeros +( +) +as +usize +; +cand +& += +! +( +1 +< +< +bit +) +; +let +at += +at ++ +( +bit +/ +bucket_count +) +; +let +bucket += +bit +% +bucket_count +; +if +let +Some +( +m +) += +self +. +verify_bucket +( +pats haystack -must -be +bucket +at +) +{ +return +Some +( +m +) +; +} +} +None +} +/ +/ +/ +Verify +whether +there +are +any +matches +starting +at +at in -order +the +given / / / +haystack +corresponding +only to -use -it -with -this -searcher +patterns +in +the +given +bucket . # [ @@ -3159,576 +3400,374 @@ inline always ) ] -pub -( -crate -) fn -minimum_len +verify_bucket ( & self -) -- -> -usize -{ -V +pats : +& +Patterns +haystack : -Half +& +[ +u8 +] +bucket : +usize +at : -BYTES -+ -( -BYTES -- -1 +usize ) -} -} -impl -< -V -: -FatVector +- > -Fat +Option < -V -1 +Match > { / / -/ -Look -for -an -occurrences -of -the -patterns -in +Forcing this -finder -in -the -haystack -/ +function +to +not +inline +and +be +" +cold +" +seems +to +help / / -given -by the -start -and -end -pointers +codegen +for +Teddy +overall . -/ -/ -/ -/ -/ -/ -If -no -match -could -be -found -then -None +Interestingly +this is -returned -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ +good +for +a / / -The -given -pointers -representing +16 +% +boost +in the -haystack -must -be -valid -to -read +sherlock / +packed / +teddy / -from -. -They -must -also -point -to -a -region -of -memory -that -is -at -least -the +name / +alt1 +benchmark +( +among / / -minimum -length -required -by -this -searcher +others +) . -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that +Overall this -is -okay -to -call -in -the -current -target -for -/ +seems +like +a +problem +with +codegen +since / / +creating the -current -CPU +Match +itself +is +a +very +small +amount +of +code . # [ +cold +] +# +[ inline ( -always +never ) ] -pub -( -crate -) -unsafe fn -find +match_from_span ( -& -self +pati +: +PatternID start : -* -const -u8 +usize end : -* -const -u8 +usize ) - > -Option -< Match -> { -let -len -= -end -. -distance -( -start -) -; -debug_assert -! -( -len -> -= -self -. -minimum_len -( -) -) -; -let -mut -cur -= -start -; -while -cur -< -= -end -. -sub -( -V -: -: -Half +Match : : -BYTES -) -{ -if -let -Some -( -m -) -= -self -. -find_one +from_span ( -cur +pati +as +usize +start end ) -{ -return -Some -( -m -) -; -} -cur -= -cur -. -add -( -V -: -: -Half -: -: -BYTES -) -; } -if -cur -< -end -{ -cur -= -end +/ +/ +N . -sub -( -V -: -: -Half -: -: -BYTES -) -; -if -let -Some -( -m -) -= -self +B . -find_one -( -cur -end -) -{ -return -Some -( -m -) -; -} -} -None -} -/ +The +bounds +check +for +this +bucket +lookup +* +should +* +be +elided / / -Look -for -a -match -starting -at +since +we +assert the -V -: -: -BYTES -at -and -after -cur -. -If +number +of +buckets +in +each +find_at +routine / / -/ -there -isn -' -t -one -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -# -Safety +and +the +compiler +can +prove +that +the +% +8 +( +or +% +16 +) +in +callers / / +of +this +routine +will +always +be +in +bounds +. +for +& +pati +in +& +self +. +buckets +[ +bucket +] +{ / / +SAFETY +: +This +is +safe +because +we +are +guaranteed +that +every / / -The -given -pointers -representing -the -haystack -must -be +index +in +a +Teddy +bucket +is +a valid -to -read -/ +index +into +pats +. +This / / -from -. -They -must -also -point -to -a -region -of -memory -that +guarantee is -at -least +upheld +by the +assert +checking +max_pattern_id +in / / -/ -minimum -length -required -by -this -searcher +the +beginning +of +find_at +above . / / / / -/ -/ -Callers -must -ensure -that -this +This +explicit +bounds +check +elision is -okay -to -call -in -the -current -target +( +amazingly +) +good for +a / / +25 +- +50 +% +boost +in +some +benchmarks +particularly +ones +with +a +lot / -the -current -CPU +/ +of +short +literals . -# -[ -inline -( -always -) -] -unsafe -fn -find_one -( -& -self -cur -: -* -const -u8 -end -: -* -const -u8 -) -- -> -Option -< -Match -> -{ let -c +pat = -self +unsafe +{ +pats . -candidate +get_unchecked ( -cur +pati ) +} ; if -! -c +pat . -is_zero -( -) -{ -if -let -Some +is_prefix ( -m -) -= -self +& +haystack +[ +at . -teddy . -verify -( -cur -end -c +] ) { return Some ( -m +match_from_span +( +pati +at +at ++ +pat +. +len +( +) +) ) ; } } None } +} / / / -Look -for -a -candidate -match -( -represented -as -a -vector -) -starting -at +Exec +represents the +different +search +strategies +supported +by +the +Teddy / / / -V -: -: -BYTES -at -and -after -cur -. -If -there -isn -' -t -one -then -a -vector -with -/ -/ -/ -all -bits -set -to -zero -is -returned +runtime . / / @@ -3736,155 +3775,204 @@ returned / / / -# -Safety -/ -/ -/ +This +enum +is +an +important +safety +abstraction +. +Namely +callers +should +only / / / -The -given -pointer -representing -the -haystack -must -be -valid +construct +a +variant +in +this +enum +if +it +is +safe to -read -/ -/ -/ -from -. -/ -/ -/ +execute +its +corresponding / / / -Callers -must -ensure -that -this -is -okay -to -call -in +target +features +on the current -target -for +CPU +. +The +128 +- +bit +searchers +require +SSSE3 / / / +while the -current -CPU +256 +- +bit +searchers +require +AVX2 . # [ -inline +derive ( -always +Clone +Debug ) ] -unsafe -fn -candidate +pub +enum +Exec +{ +TeddySlim1Mask128 ( -& -self -cur -: -* -const -u8 +TeddySlim1Mask128 ) -- -> -V -{ -let -chunk -= -V -: -: -load_half_unaligned +TeddySlim1Mask256 ( -cur +TeddySlim1Mask256 ) -; -Mask -: -: -members1 +TeddyFat1Mask256 ( -chunk -self -. -masks +TeddyFat1Mask256 +) +TeddySlim2Mask128 +( +TeddySlim2Mask128 +) +TeddySlim2Mask256 +( +TeddySlim2Mask256 +) +TeddyFat2Mask256 +( +TeddyFat2Mask256 +) +TeddySlim3Mask128 +( +TeddySlim3Mask128 +) +TeddySlim3Mask256 +( +TeddySlim3Mask256 +) +TeddyFat3Mask256 +( +TeddyFat3Mask256 ) } -} -impl -< -V -: -FatVector -> -Fat -< -V -2 -> -{ / / +Most +of +the +code +below +remains +undocumented +because +they +are +effectively / -See -Fat -< -V -1 -> -: -: -find +/ +repeated +versions +of +themselves +. +The +general +structure +is +described +in +the +/ +/ +README +and +in +the +comments +above . # [ -inline +derive ( -always +Clone +Debug ) ] pub +struct +TeddySlim1Mask128 +{ +pub +mask1 +: +Mask128 +} +impl +TeddySlim1Mask128 +{ +# +[ +target_feature ( -crate +enable += +" +ssse3 +" ) +] unsafe fn -find +find_at ( & self -start +pats : -* -const -u8 -end +& +Patterns +teddy : -* -const +& +Teddy +haystack +: +& +[ u8 +] +mut +at +: +usize ) - > @@ -3893,140 +3981,107 @@ Option Match > { -let -len -= -end -. -distance -( -start -) -; debug_assert ! ( +haystack +[ +at +. +. +] +. len +( +) > = -self +teddy . minimum_len ( ) ) ; -let -mut -cur -= -start +/ +/ +This +assert +helps +eliminate +bounds +checks +for +bucket +lookups +in +/ +/ +Teddy +: +: +verify_bucket +which +has +a +small +( +3 +- +4 +% +) +performance +boost . -add +assert_eq +! +( +8 +teddy +. +buckets +. +len ( -1 +) ) ; let -mut -prev0 +len = -V -: -: -splat +haystack +. +len ( -0xFF ) ; while -cur +at < = -end -. -sub -( -V -: -: -Half -: -: -BYTES -) +len +- +16 { -if let -Some -( -m -) +c = self . -find_one -( -cur -end -& -mut -prev0 -) -{ -return -Some -( -m -) -; -} -cur -= -cur -. -add +candidate ( -V -: -: -Half -: -: -BYTES +haystack +at ) ; -} if -cur -< -end -{ -cur -= -end -. -sub -( -V -: -: -Half -: -: -BYTES -) -; -prev0 -= -V -: -: -splat +! +is_all_zeroes128 ( -0xFF +c ) -; +{ if let Some @@ -4034,15 +4089,14 @@ Some m ) = -self +teddy . -find_one +verify128 ( -cur -end -& -mut -prev0 +pats +haystack +at +c ) { return @@ -4053,57 +4107,23 @@ m ; } } -None +at ++ += +16 +; } -/ -/ -/ -See -Fat -< -V -1 -> -: -: -find_one -. -# -[ -inline -( -always -) -] -unsafe -fn -find_one -( -& -self -cur -: -* -const -u8 -end -: -* -const -u8 -prev0 -: -& -mut -V -) -- -> -Option +if +at < -Match -> +len { +at += +len +- +16 +; let c = @@ -4111,16 +4131,15 @@ self . candidate ( -cur -prev0 +haystack +at ) ; if ! -c -. -is_zero +is_all_zeroes128 ( +c ) { if @@ -4130,19 +4149,13 @@ Some m ) = -self -. teddy . -verify -( -cur -. -sub +verify128 ( -1 -) -end +pats +haystack +at c ) { @@ -4154,21 +4167,9 @@ m ; } } +} None } -/ -/ -/ -See -Fat -< -V -1 -> -: -: -candidate -. # [ inline @@ -4182,130 +4183,111 @@ candidate ( & self -cur +haystack : -* -const +& +[ u8 -prev0 +] +at : -& -mut -V +usize ) - > -V +__m128i { -let -chunk -= -V -: -: -load_half_unaligned +debug_assert +! ( -cur -) -; -let +haystack +[ +at +. +. +] +. +len ( -res0 -res1 ) +> = -Mask -: -: -members2 -( -chunk -self -. -masks +16 ) ; let -res0prev0 +chunk = -res0 -. -half_shift_in_one_byte +loadu128 ( -* -prev0 +haystack +at ) ; -let -res -= -res0prev0 -. -and +members1m128 ( -res1 +chunk +self +. +mask1 ) -; -* -prev0 -= -res0 -; -res } } -impl -< -V -: -FatVector -> -Fat -< -V -3 -> -{ -/ -/ -/ -See -Fat -< -V -1 -> -: -: -find -. # [ -inline +derive ( -always +Clone +Debug ) ] pub +struct +TeddySlim1Mask256 +{ +pub +mask1 +: +Mask256 +} +impl +TeddySlim1Mask256 +{ +# +[ +target_feature ( -crate +enable += +" +avx2 +" ) +] unsafe fn -find +find_at ( & self -start +pats : -* -const -u8 -end +& +Patterns +teddy : -* -const +& +Teddy +haystack +: +& +[ u8 +] +mut +at +: +usize ) - > @@ -4314,79 +4296,105 @@ Option Match > { -let -len -= -end -. -distance -( -start -) -; debug_assert ! ( +haystack +[ +at +. +. +] +. len +( +) > = -self +teddy . minimum_len ( ) ) ; -let -mut -cur -= -start -. -add -( -2 -) -; -let -mut -prev0 -= -V +/ +/ +This +assert +helps +eliminate +bounds +checks +for +bucket +lookups +in +/ +/ +Teddy : : -splat +verify_bucket +which +has +a +small +( +3 +- +4 +% +) +performance +boost +. +assert_eq +! +( +8 +teddy +. +buckets +. +len ( -0xFF +) ) ; let -mut -prev1 +len = -V -: -: -splat +haystack +. +len ( -0xFF ) ; while -cur +at < = -end +len +- +32 +{ +let +c += +self . -sub +candidate ( -V -: -: -Half -: -: -BYTES +haystack +at +) +; +if +! +is_all_zeroes256 +( +c ) { if @@ -4396,18 +4404,14 @@ Some m ) = -self +teddy . -find_one +verify256 ( -cur -end -& -mut -prev0 -& -mut -prev1 +pats +haystack +at +c ) { return @@ -4417,62 +4421,42 @@ m ) ; } -cur +} +at ++ = -cur -. -add -( -V -: -: -Half -: -: -BYTES -) +32 ; } if -cur +at < -end +len { -cur +at = -end -. -sub -( -V -: -: -Half -: -: -BYTES -) +len +- +32 ; -prev0 +let +c = -V -: -: -splat +self +. +candidate ( -0xFF +haystack +at ) ; -prev1 -= -V -: -: -splat +if +! +is_all_zeroes256 ( -0xFF +c ) -; +{ if let Some @@ -4480,18 +4464,14 @@ Some m ) = -self +teddy . -find_one +verify256 ( -cur -end -& -mut -prev0 -& -mut -prev1 +pats +haystack +at +c ) { return @@ -4502,21 +4482,9 @@ m ; } } +} None } -/ -/ -/ -See -Fat -< -V -1 -> -: -: -find_one -. # [ inline @@ -4526,361 +4494,282 @@ always ] unsafe fn -find_one +candidate ( & self -cur -: -* -const -u8 -end -: -* -const -u8 -prev0 +haystack : & -mut -V -prev1 +[ +u8 +] +at : -& -mut -V +usize ) - > -Option -< -Match -> +__m256i { -let -c -= -self -. -candidate -( -cur -prev0 -prev1 -) -; -if +debug_assert ! -c -. -is_zero -( -) -{ -if -let -Some ( -m -) -= -self +haystack +[ +at . -teddy . -verify -( -cur +] . -sub +len ( -2 ) -end -c +> += +32 ) -{ -return -Some +; +let +chunk += +loadu256 ( -m +haystack +at ) ; +members1m256 +( +chunk +self +. +mask1 +) } } -None -} -/ -/ -/ -See -Fat -< -V -1 -> -: +# +[ +derive +( +Clone +Debug +) +] +pub +struct +TeddyFat1Mask256 +{ +pub +mask1 : -candidate -. +Mask256 +} +impl +TeddyFat1Mask256 +{ # [ -inline +target_feature ( -always +enable += +" +avx2 +" ) ] unsafe fn -candidate +find_at ( & self -cur +pats : -* -const -u8 -prev0 +& +Patterns +teddy : & -mut -V -prev1 +Teddy +haystack : & +[ +u8 +] mut -V +at +: +usize ) - > -V +Option +< +Match +> { -let -chunk -= -V -: -: -load_half_unaligned -( -cur -) -; -let -( -res0 -res1 -res2 -) -= -Mask -: -: -members3 +debug_assert +! ( -chunk -self +haystack +[ +at . -masks -) -; -let -res0prev0 -= -res0 . -half_shift_in_two_bytes -( -* -prev0 -) -; -let -res1prev1 -= -res1 +] . -half_shift_in_one_byte +len ( -* -prev1 ) -; -let -res +> = -res0prev0 +teddy . -and +minimum_len ( -res1prev1 ) -. -and -( -res2 ) ; -* -prev0 -= -res0 -; -* -prev1 -= -res1 -; -res -} -} -impl -< -V -: -FatVector -> -Fat -< -V -4 -> -{ / / +This +assert +helps +eliminate +bounds +checks +for +bucket +lookups +in +/ / -See -Fat -< -V -1 -> +Teddy : : -find -. -# -[ -inline +verify_bucket +which +has +a +small ( -always +3 +- +4 +% ) -] -pub +performance +boost +. +assert_eq +! ( -crate -) -unsafe -fn -find +16 +teddy +. +buckets +. +len ( -& -self -start -: -* -const -u8 -end -: -* -const -u8 ) -- -> -Option -< -Match -> -{ +) +; let len = -end +haystack . -distance +len ( -start ) ; -debug_assert -! -( +while +at +< += len -> +- +16 +{ +let +c = self . -minimum_len +candidate ( -) +haystack +at ) ; +if +! +is_all_zeroes256 +( +c +) +{ +if let -mut -cur +Some +( +m +) = -start +teddy . -add +verify_fat256 ( -3 +pats +haystack +at +c ) -; -let -mut -prev0 -= -V -: -: -splat +{ +return +Some ( -0xFF +m ) ; -let -mut -prev1 +} +} +at ++ = -V -: -: -splat -( -0xFF -) +16 +; +} +if +at +< +len +{ +at += +len +- +16 ; let -mut -prev2 +c = -V -: -: -splat +self +. +candidate ( -0xFF +haystack +at ) ; -while -cur -< -= -end -. -sub +if +! +is_all_zeroes256 ( -V -: -: -Half -: -: -BYTES +c ) { if @@ -4890,21 +4779,14 @@ Some m ) = -self +teddy . -find_one +verify_fat256 ( -cur -end -& -mut -prev0 -& -mut -prev1 -& -mut -prev2 +pats +haystack +at +c ) { return @@ -4914,157 +4796,135 @@ m ) ; } -cur -= -cur -. -add +} +} +None +} +# +[ +inline ( -V -: -: -Half +always +) +] +unsafe +fn +candidate +( +& +self +haystack : +& +[ +u8 +] +at : -BYTES +usize ) -; -} -if -cur -< -end +- +> +__m256i { -cur -= -end +debug_assert +! +( +haystack +[ +at +. . -sub +] +. +len ( -V -: -: -Half -: -: -BYTES ) -; -prev0 +> = -V -: -: -splat -( -0xFF +16 ) ; -prev1 +let +chunk = -V -: -: -splat +_mm256_broadcastsi128_si256 ( -0xFF -) -; -prev2 -= -V -: -: -splat +loadu128 ( -0xFF +haystack +at +) ) ; -if -let -Some +members1m256 ( -m -) -= +chunk self . -find_one -( -cur -end -& -mut -prev0 -& -mut -prev1 -& -mut -prev2 -) -{ -return -Some -( -m +mask1 ) -; } } -None -} -/ -/ -/ -See -Fat -< -V -1 -> +# +[ +derive +( +Clone +Debug +) +] +pub +struct +TeddySlim2Mask128 +{ +pub +mask1 : +Mask128 +pub +mask2 : -find_one -. +Mask128 +} +impl +TeddySlim2Mask128 +{ # [ -inline +target_feature ( -always +enable += +" +ssse3 +" ) ] unsafe fn -find_one +find_at ( & self -cur -: -* -const -u8 -end -: -* -const -u8 -prev0 +pats : & -mut -V -prev1 +Patterns +teddy : & -mut -V -prev2 +Teddy +haystack : & +[ +u8 +] mut -V +at +: +usize ) - > @@ -5073,47 +4933,139 @@ Option Match > { -let -c -= -self +debug_assert +! +( +haystack +[ +at . -candidate +. +] +. +len ( -cur -prev0 -prev1 -prev2 ) -; -if -! -c +> += +teddy . -is_zero +minimum_len ( ) -{ -if -let -Some +) +; +/ +/ +This +assert +helps +eliminate +bounds +checks +for +bucket +lookups +in +/ +/ +Teddy +: +: +verify_bucket +which +has +a +small ( -m +3 +- +4 +% ) -= -self +performance +boost . +assert_eq +! +( +8 teddy . -verify +buckets +. +len ( -cur +) +) +; +at ++ += +1 +; +let +len += +haystack . -sub +len ( -3 ) -end +; +let +mut +prev0 += +ones128 +( +) +; +while +at +< += +len +- +16 +{ +let +c += +self +. +candidate +( +haystack +at +& +mut +prev0 +) +; +if +! +is_all_zeroes128 +( +c +) +{ +if +let +Some +( +m +) += +teddy +. +verify128 +( +pats +haystack +at +- +1 c ) { @@ -5125,21 +5077,80 @@ m ; } } -None +at ++ += +16 +; } -/ -/ -/ -See -Fat +if +at < -V -1 -> -: -: +len +{ +at += +len +- +16 +; +prev0 += +ones128 +( +) +; +let +c += +self +. candidate +( +haystack +at +& +mut +prev0 +) +; +if +! +is_all_zeroes128 +( +c +) +{ +if +let +Some +( +m +) += +teddy . +verify128 +( +pats +haystack +at +- +1 +c +) +{ +return +Some +( +m +) +; +} +} +} +None +} # [ inline @@ -5153,1479 +5164,930 @@ candidate ( & self -cur -: -* -const -u8 -prev0 +haystack : & -mut -V -prev1 +[ +u8 +] +at : -& -mut -V -prev2 +usize +prev0 : & mut -V +__m128i ) - > -V +__m128i { +debug_assert +! +( +haystack +[ +at +. +. +] +. +len +( +) +> += +16 +) +; let chunk = -V -: -: -load_half_unaligned +loadu128 ( -cur +haystack +at ) ; let ( res0 res1 -res2 -res3 ) = -Mask -: -: -members4 +members2m128 ( chunk self . -masks +mask1 +self +. +mask2 ) ; let res0prev0 = -res0 -. -half_shift_in_three_bytes +_mm_alignr_epi8 ( +res0 * prev0 +15 ) ; -let -res1prev1 -= -res1 -. -half_shift_in_two_bytes +_mm_and_si128 ( -* -prev1 +res0prev0 +res1 ) -; -let -res2prev2 -= -res2 -. -half_shift_in_one_byte +} +} +# +[ +derive ( -* -prev2 +Clone +Debug ) -; -let -res -= -res0prev0 -. -and -( -res1prev1 -) -. -and -( -res2prev2 -) -. -and +] +pub +struct +TeddySlim2Mask256 +{ +pub +mask1 +: +Mask256 +pub +mask2 +: +Mask256 +} +impl +TeddySlim2Mask256 +{ +# +[ +target_feature ( -res3 -) -; -* -prev0 -= -res0 -; -* -prev1 -= -res1 -; -* -prev2 +enable = -res2 -; -res -} -} -/ -/ -/ -The -common -elements -of -all -" -slim " -and -" -fat +avx2 " +) +] +unsafe +fn +find_at +( +& +self +pats +: +& +Patterns +teddy +: +& Teddy -search -implementations -. -/ -/ -/ -/ -/ -/ -Essentially -this -contains -the -patterns -and -the -buckets +haystack +: +& +[ +u8 +] +mut +at +: +usize +) +- +> +Option +< +Match +> +{ +debug_assert +! +( +haystack +[ +at . -Namely -it -/ -/ -/ -contains -enough -to -implement -the -verification -step -after -candidates -are -/ -/ -/ -identified -via -the -shuffle -masks . -/ -/ -/ -/ -/ -/ -It -is -generic -over -the -number -of -buckets -used +] . -In -general -the -number -of -/ -/ -/ -buckets -is -either -8 +len ( -for -" -slim -" -Teddy ) -or -16 +> += +teddy +. +minimum_len ( -for -" -fat -" -Teddy ) -. -The -generic -/ +) +; / / -parameter -isn -' -t -really -meant -to -be -instantiated +This +assert +helps +eliminate +bounds +checks for -any -value -other -than -/ -/ -/ -8 -or -16 -although -it -is -technically -possible -. -The -main -hiccup -is -that -there -/ -/ -/ -is -some -bit -- -shifting -done +bucket +lookups in -the -critical -part -of -verification -that -could / / -/ -be -quite -expensive -if -N -is -not +Teddy +: +: +verify_bucket +which +has a -multiple -of -2 -. -# -[ -derive +small ( -Clone -Debug +3 +- +4 +% ) -] -struct -Teddy -< -const -BUCKETS -: -usize -> -{ -/ -/ -/ -The -patterns -we -are -searching -for +performance +boost . -/ -/ -/ -/ -/ -/ -A -pattern -string -can -be -found -by -its -PatternID +assert_eq +! +( +8 +teddy . -patterns -: -Arc -< -Patterns -> -/ -/ -/ -The -allocation -of -patterns -in buckets . -This -only -contains -the -IDs -of -/ -/ -/ -patterns -. -In -order -to -do -full -verification -callers -must -provide -the -/ -/ -/ -actual -patterns -when -using -Teddy -. -buckets -: -[ -Vec -< -PatternID -> +len +( +) +) +; +at ++ += +1 ; -BUCKETS -] -/ -/ -N -. -B -. -The -above -representation -is -very -simple -but -it -definitely -results -/ -/ -in -ping -- -ponging -between -different -allocations -during -verification -. -I -' -ve -/ -/ -tried -experimenting -with -other -representations -that -flatten -the -pattern -/ -/ -strings -into -a -single -allocation -but -it -doesn -' -t -seem -to -help -much -. -/ -/ -Probably -everything -is -small -enough -to -fit -into -cache -anyway -and -so -the -/ -/ -pointer -chasing -isn -' -t -a -big -deal -? -/ -/ -/ -/ -One -other -avenue -I -haven -' -t -explored -is -some -kind -of -hashing -trick -/ -/ -that let -' -s -us -do -another -high -- -confidence -check -before -launching -into -/ -/ -memcmp -. -} -impl -< -const -BUCKETS -: -usize -> -Teddy -< -BUCKETS -> -{ -/ -/ -/ -Create -a -new -generic -data -structure -for -Teddy -verification +len += +haystack . -fn -new +len ( -patterns -: -Arc -< -Patterns -> ) -- -> -Teddy +; +let +mut +prev0 += +ones256 +( +) +; +while +at < -BUCKETS -> += +len +- +32 { -assert_ne -! -( -0 -patterns +let +c += +self . -len +candidate ( -) -" -Teddy -requires +haystack at -least -one -pattern -" +& +mut +prev0 ) ; -assert_ne +if ! +is_all_zeroes256 ( -0 -patterns -. -minimum_len +c +) +{ +if +let +Some ( +m ) -" -Teddy -does -not -support -zero += +teddy +. +verify256 +( +pats +haystack +at - -length -patterns -" +1 +c ) -; -assert -! +{ +return +Some ( -BUCKETS -= +m +) +; +} +} +at ++ = -8 -| -| -BUCKETS +32 +; +} +if +at +< +len +{ +at = +len +- +32 +; +prev0 = -16 -" -Teddy -only -supports -8 -or -16 -buckets -" +ones256 +( ) ; -/ -/ -MSRV -( -1 +let +c += +self . -63 +candidate +( +haystack +at +& +mut +prev0 ) -: -Use -core -: -: -array -: -: -from_fn -below -instead -of -allocating -a -/ -/ -superfluous -outer -Vec -. -Not -a -big -deal +; +if +! +is_all_zeroes256 ( -especially -given -the -BTreeMap -/ -/ -allocation -below +c ) -but -nice -to -not -do -it -. +{ +if let -buckets +Some +( +m +) = -< -[ -Vec -< -PatternID -> +teddy +. +verify256 +( +pats +haystack +at +- +1 +c +) +{ +return +Some +( +m +) ; -BUCKETS +} +} +} +None +} +# +[ +inline +( +always +) ] -> -: -: -try_from +unsafe +fn +candidate ( -vec -! +& +self +haystack +: +& [ -vec +u8 +] +at +: +usize +prev0 +: +& +mut +__m256i +) +- +> +__m256i +{ +debug_assert ! +( +haystack [ +at +. +. ] -; -BUCKETS -] -) . -unwrap +len ( ) -; -let -mut -t +> = -Teddy -{ -patterns -buckets -} +32 +) ; let -mut -map -: -BTreeMap -< -Box -< -[ -u8 -] -> -usize -> +chunk = -BTreeMap -: -: -new +loadu256 ( +haystack +at ) ; -for +let ( -id -pattern +res0 +res1 ) -in -t += +members2m256 +( +chunk +self . -patterns +mask1 +self . -iter +mask2 +) +; +let +res0prev0 += +alignr256_15 +( +res0 +* +prev0 +) +; +let +res += +_mm256_and_si256 +( +res0prev0 +res1 +) +; +* +prev0 += +res0 +; +res +} +} +# +[ +derive ( +Clone +Debug ) +] +pub +struct +TeddyFat2Mask256 { -/ -/ -We -try -to -be -slightly -clever -in -how -we -assign -patterns -into -/ -/ -buckets -. -Generally -speaking -we -want -patterns -with -the -same -/ -/ -prefix -to -be -in -the -same -bucket -since -it -minimizes -the -amount -/ -/ -of -time -we -spend -churning -through -buckets -in -the -verification -/ -/ -step -. -/ -/ -/ -/ -So -we -could -assign -patterns -with -the -same -N -- -prefix +pub +mask1 +: +Mask256 +pub +mask2 +: +Mask256 +} +impl +TeddyFat2Mask256 +{ +# +[ +target_feature ( -where -N -is -/ -/ -the -size -of -the -mask -which -is -one -of +enable += +" +avx2 +" +) +] +unsafe +fn +find_at +( +& +self +pats +: +& +Patterns +teddy +: +& +Teddy +haystack +: +& +[ +u8 +] +mut +at +: +usize +) +- +> +Option +< +Match +> { -1 -2 -3 -} +debug_assert +! +( +haystack +[ +at +. +. +] +. +len +( ) -to -the -same -/ -/ -bucket +> += +teddy . -However -case -insensitive -searches -are -fairly -common -so +minimum_len +( +) +) +; / / -we -' -d +This +assert +helps +eliminate +bounds +checks for -example -ideally -want -to -treat -abc -and -ABC -as -if +bucket +lookups +in / / -they -shared -the -same -prefix -. -ASCII +Teddy +: +: +verify_bucket +which has -the -nice -property -that -/ -/ -the -lower -4 -bits -of -A -and a -are -the -same -so -we -therefore -group -/ -/ -patterns -with -the -same -low -- -nybble -- -N +small +( +3 - -prefix -into -the -same -bucket +4 +% +) +performance +boost . -/ -/ -/ -/ -MOREOVER -this -is -actually -necessary -for -correctness +assert_eq ! -In -/ -/ -particular -by -grouping -patterns -with -the -same -prefix -into -the -/ -/ -same -bucket -we -ensure -that -we -preserve -correct -leftmost -- -first -/ -/ -and -leftmost -- -longest -match -semantics +( +16 +teddy . -In -addition -to -the -fact -/ -/ -that -patterns +buckets . -iter +len ( ) -iterates -in -the -correct -order -this -/ -/ -guarantees -that -all -possible -ambiguous -matches -will -occur -in -/ -/ -the -same -bucket -. -The -verification -routine -could -be -adjusted -to -/ -/ -support -correct -leftmost -match -semantics -regardless -of -bucket -/ -/ -allocation -but -that -results -in -a -performance -hit -. -It -' -s -much -/ -/ -nicer -to -be -able -to -just -stop -as -soon -as -a -match -is -found -. +) +; +at ++ += +1 +; let -lonybs +len = -pattern +haystack . -low_nybbles +len ( -t -. -mask_len +) +; +let +mut +prev0 += +ones256 ( ) +; +while +at +< += +len +- +16 +{ +let +c += +self +. +candidate +( +haystack +at +& +mut +prev0 ) ; if +! +is_all_zeroes256 +( +c +) +{ +if let Some ( -& -bucket +m ) = -map +teddy . -get +verify_fat256 ( -& -lonybs +pats +haystack +at +- +1 +c ) { -t -. -buckets -[ -bucket -] -. -push +return +Some ( -id +m ) ; } -else +} +at ++ += +16 +; +} +if +at +< +len { -/ -/ -N -. -B -. -We -assign -buckets -in -reverse -because -it -shouldn -' -t -have -/ -/ -any -influence -on -performance -but -it -does -make -it -harder -to -/ -/ -get -leftmost -match -semantics -accidentally -correct -. -let -bucket +at = -( -BUCKETS -- -1 -) +len - +16 +; +prev0 += +ones256 ( -id -. -as_usize -( -) -% -BUCKETS ) ; -t -. -buckets -[ -bucket -] +let +c += +self . -push +candidate ( -id +haystack +at +& +mut +prev0 ) ; -map +if +! +is_all_zeroes256 +( +c +) +{ +if +let +Some +( +m +) += +teddy . -insert +verify_fat256 ( -lonybs -bucket +pats +haystack +at +- +1 +c +) +{ +return +Some +( +m ) ; } } -t } -/ -/ -/ -Verify -whether -there -are -any -matches -starting -at -or -after -cur -in -the -/ -/ -/ -haystack -. -The +None +} +# +[ +inline +( +always +) +] +unsafe +fn candidate -chunk -given -should -correspond -to -8 -- -bit -bitsets -/ -/ -/ -for -N -buckets -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -The -given -pointers -representing -the -haystack -must -be -valid -to -read -/ -/ -/ -from -. -# -[ -inline -( -always -) -] -unsafe -fn -verify64 ( & self -cur +haystack : -* -const +& +[ u8 -end +] +at : -* -const -u8 -mut -candidate_chunk +usize +prev0 : -u64 +& +mut +__m256i ) - > -Option -< -Match -> +__m256i { -while -candidate_chunk +debug_assert ! -= -0 -{ -let -bit -= -candidate_chunk -. -trailing_zeros ( -) +haystack +[ +at +. +. +] . -as_usize +len ( ) -; -candidate_chunk -& +> = -! -( -1 -< -< -bit +16 ) ; let -cur +chunk = -cur -. -add +_mm256_broadcastsi128_si256 ( -bit -/ -BUCKETS +loadu128 +( +haystack +at +) ) ; let -bucket -= -bit -% -BUCKETS -; -if -let -Some ( -m +res0 +res1 ) = +members2m256 +( +chunk self . -verify_bucket +mask1 +self +. +mask2 +) +; +let +res0prev0 += +_mm256_alignr_epi8 ( -cur -end -bucket +res0 +* +prev0 +15 ) -{ -return -Some +; +let +res += +_mm256_and_si256 ( -m +res0prev0 +res1 ) ; +* +prev0 += +res0 +; +res } } -None -} -/ -/ -/ -Verify -whether -there -are -any -matches -starting -at -at -in -the -given -/ -/ -/ -haystack -corresponding -only -to -patterns -in -the -given -bucket -. -/ -/ -/ -/ -/ -/ # -Safety -/ -/ -/ -/ -/ -/ -The -given -pointers -representing -the -haystack -must -be -valid -to -read -/ -/ -/ -from -. -/ -/ -/ -/ -/ -/ -The -bucket -index -must -be -less -than -or -equal -to -self -. -buckets -. -len +[ +derive ( +Clone +Debug ) -. +] +pub +struct +TeddySlim3Mask128 +{ +pub +mask1 +: +Mask128 +pub +mask2 +: +Mask128 +pub +mask3 +: +Mask128 +} +impl +TeddySlim3Mask128 +{ # [ -inline +target_feature ( -always +enable += +" +ssse3 +" ) ] unsafe fn -verify_bucket +find_at ( & self -cur -: -* -const -u8 -end +pats : -* -const -u8 -bucket +& +Patterns +teddy : -usize +& +Teddy +haystack +: +& +[ +u8 +] +mut +at +: +usize ) - > @@ -6637,582 +6099,438 @@ Match debug_assert ! ( -bucket -< -self +haystack +[ +at . -buckets +. +] . len ( ) +> += +teddy +. +minimum_len +( +) ) ; / / -SAFETY -: -The -caller -must -ensure -that -the -bucket -index -is -correct -. +This +assert +helps +eliminate +bounds +checks for -pid +bucket +lookups in -self +/ +/ +Teddy +: +: +verify_bucket +which +has +a +small +( +3 +- +4 +% +) +performance +boost +. +assert_eq +! +( +8 +teddy . buckets . -get_unchecked +len ( -bucket ) +) +; +at ++ += +2 +; +let +len += +haystack . -iter +len ( ) -. -copied +; +let +( +mut +prev0 +mut +prev1 +) += +( +ones128 +( +) +ones128 ( ) +) +; +while +at +< += +len +- +16 { -/ -/ -SAFETY -: -This -is -safe -because -we -are -guaranteed -that -every -/ -/ -index -in -a -Teddy -bucket -is -a -valid -index -into -pats -by -/ -/ -construction +let +c += +self . -debug_assert +candidate +( +haystack +at +& +mut +prev0 +& +mut +prev1 +) +; +if ! +is_all_zeroes128 +( +c +) +{ +if +let +Some ( -pid +m +) += +teddy . -as_usize +verify128 +( +pats +haystack +at +- +2 +c +) +{ +return +Some ( +m ) +; +} +} +at ++ += +16 +; +} +if +at < -self -. -patterns -. len +{ +at += +len +- +16 +; +prev0 += +ones128 ( ) +; +prev1 += +ones128 +( ) ; let -pat +c = self . -patterns -. -get_unchecked +candidate ( -pid +haystack +at +& +mut +prev0 +& +mut +prev1 ) ; if -pat -. -is_prefix_raw +! +is_all_zeroes128 ( -cur -end +c ) { +if let -start -= -cur -; -let -end -= -start -. -add +Some ( -pat +m +) += +teddy . -len +verify128 ( +pats +haystack +at +- +2 +c ) -) -; +{ return Some ( -Match -{ -pid -start -end -} +m ) ; } } +} None } -/ -/ -/ -Returns -the -total -number -of -masks -required -by -the -patterns -in -this -/ -/ -/ -Teddy -searcher -. -/ -/ -/ -/ -/ -/ -Basically -the -mask -length -corresponds -to -the -type -of -Teddy -searcher -/ -/ -/ -to -use -: -a -1 -- -byte -2 -- -byte -3 -- -byte -or -4 -- -byte -searcher -. -The -bigger -the -/ -/ -/ -better -typically -since -searching -for -longer -substrings -usually -/ -/ -/ -decreases -the -rate -of -false -positives -. -Therefore -the -number -of -masks -/ -/ -/ -needed -is -the -length -of -the -shortest -pattern -in -this -searcher -. -If -the -/ -/ -/ -length -of -the -shortest -pattern +# +[ +inline ( -in -bytes +always ) -is -bigger -than -4 -then -the -/ -/ -/ -mask -length -is -4 -since -there -are -no -Teddy -searchers -for -more -than -4 -/ -/ -/ -bytes -. +] +unsafe fn -mask_len +candidate ( & self -) -- -> -usize -{ -core +haystack : +& +[ +u8 +] +at : -cmp +usize +prev0 : +& +mut +__m128i +prev1 : -min -( -4 -self -. -patterns -. -minimum_len -( -) -) -} -/ -/ -/ -Returns -the -approximate -total -amount -of -heap -used -by -this -type -in -/ -/ -/ -units -of -bytes -. -fn -memory_usage -( & -self +mut +__m128i ) - > -usize +__m128i { -/ -/ -This -is -an -upper -bound -rather -than -a -precise -accounting -. -No -/ -/ -particular -reason -other -than -it -' -s -probably -very -close -to -actual -/ -/ -memory -usage -in -practice +debug_assert +! +( +haystack +[ +at . -self . -patterns +] . len ( ) -* -core -: -: -mem -: -: -size_of -: -: -< -PatternID > += +16 +) +; +let +chunk += +loadu128 ( +haystack +at ) -} -} -impl -Teddy -< -8 -> -{ -/ -/ -/ -Runs -the -verification -routine -for -" -slim -" -Teddy -. -/ -/ -/ -/ -/ -/ -The -candidate -given -should -be -a -collection -of -8 -- -bit -bitsets +; +let ( -one -bitset -/ -/ -/ -per -lane +res0 +res1 +res2 ) -where -the -ith -bit -is -set -in -the -jth -lane -if -and -only -if -the -/ -/ -/ -byte -occurring -at -at -+ -j -in -cur -is -in -the -bucket -i += +members3m128 +( +chunk +self . -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU +mask1 +self . -/ -/ -/ -/ -/ -/ -The -given -pointers -must -be -valid -to -read -from +mask2 +self . +mask3 +) +; +let +res0prev0 += +_mm_alignr_epi8 +( +res0 +* +prev0 +14 +) +; +let +res1prev1 += +_mm_alignr_epi8 +( +res1 +* +prev1 +15 +) +; +let +res += +_mm_and_si128 +( +_mm_and_si128 +( +res0prev0 +res1prev1 +) +res2 +) +; +* +prev0 += +res0 +; +* +prev1 += +res1 +; +res +} +} # [ -inline +derive ( -always +Clone +Debug +) +] +pub +struct +TeddySlim3Mask256 +{ +pub +mask1 +: +Mask256 +pub +mask2 +: +Mask256 +pub +mask3 +: +Mask256 +} +impl +TeddySlim3Mask256 +{ +# +[ +target_feature +( +enable += +" +avx2 +" ) ] unsafe fn -verify -< -V -: -Vector -> +find_at ( & self -mut -cur +pats : -* -const -u8 -end +& +Patterns +teddy : -* -const +& +Teddy +haystack +: +& +[ u8 -candidate +] +mut +at : -V +usize ) - > @@ -7224,3843 +6542,1677 @@ Match debug_assert ! ( -! -candidate +haystack +[ +at +. +. +] +. +len +( +) +> += +teddy . -is_zero +minimum_len ( ) ) ; / / -Convert -the -candidate -into -64 -- -bit -chunks -and -then -verify -each -of -/ -/ -those -chunks -. -candidate -. -for_each_64bit_lane -( -# -[ -inline -( -always -) -] -| -_ -chunk -| -{ -let -result -= -self -. -verify64 -( -cur -end -chunk -) -; -cur -= -cur -. -add -( -8 -) -; -result -} -) -} -} -impl -Teddy -< -16 -> -{ -/ -/ -/ -Runs -the -verification -routine -for -" -fat -" -Teddy -. -/ -/ -/ -/ -/ -/ -The -candidate -given -should -be -a -collection -of -8 -- -bit -bitsets -( -one -bitset -/ -/ -/ -per -lane -) -where -the -ith -bit -is -set -in -the -jth -lane -if -and -only -if -the -/ -/ -/ -byte -occurring -at -at -+ -( -j -< -16 -? -j -: -j -- -16 -) -in -cur -is -in -the -/ -/ -/ -bucket -j -< -16 -? -i -: -i -+ -8 -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -/ -/ -/ -/ -/ -/ -The -given -pointers -must -be -valid -to -read -from -. -# -[ -inline -( -always -) -] -unsafe -fn -verify -< -V -: -FatVector -> -( -& -self -mut -cur -: -* -const -u8 -end -: -* -const -u8 -candidate -: -V -) -- -> -Option -< -Match -> -{ -/ -/ This -is -a -bit -tricky -but -we -basically -want -to -convert -our -/ -/ -candidate -which -looks -like -this -( -assuming -a -256 -- -bit -vector -) -: -/ -/ -/ -/ -a31 -a30 -. -. -. -a17 -a16 -a15 -a14 -. -. -. -a01 -a00 -/ -/ -/ -/ -where -each -a -( -i -) -is -an -8 -- -bit -bitset -corresponding -to -the -activated -/ -/ -buckets -to -this -/ -/ -/ -/ -a31 -a15 -a30 -a14 -a29 -a13 -. -. -. -a18 -a02 -a17 -a01 -a16 -a00 -/ -/ -/ -/ -Namely -for -Fat -Teddy -the -high -128 -- -bits -of -the -candidate -correspond -/ -/ -to -the -same -bytes -in -the -haystack -in -the -low -128 -- -bits -( -so -we -only -/ -/ -scan -16 -bytes -at -a -time -) -but -are -for -buckets -8 -- -15 -instead -of -0 -- -7 -. -/ -/ -/ -/ -The -verification -routine -wants -to -look -at -all -potentially -matching -/ -/ -buckets -before -moving -on -to -the -next -lane -. -So -for -example -both -/ -/ -a16 -and -a00 -both -correspond -to -the -first -byte -in -our -window -; -a00 -/ -/ -contains -buckets -0 -- -7 -and -a16 -contains -buckets -8 -- -15 -. -Specifically -/ -/ -a16 -should -be -checked -before -a01 -. -So -the -transformation -shown -above -/ -/ -allows -us -to -use -our -normal -verification -procedure -with -one -small -/ -/ -change -: -we -treat -each -bitset -as -16 -bits -instead -of -8 -bits -. -debug_assert -! -( -! -candidate -. -is_zero -( -) -) -; -/ -/ -Swap -the -128 -- -bit -lanes -in -the -candidate -vector -. -let -swapped -= -candidate -. -swap_halves -( -) -; -/ -/ -Interleave -the -bytes -from -the -low -128 -- -bit -lanes -starting -with -/ -/ -cand -first -. -let -r1 -= -candidate -. -interleave_low_8bit_lanes -( -swapped -) -; -/ -/ -Interleave -the -bytes -from -the -high -128 -- -bit -lanes -starting -with -/ -/ -cand -first -. -let -r2 -= -candidate -. -interleave_high_8bit_lanes -( -swapped -) -; -/ -/ -Now -just -take -the -2 -low -64 -- -bit -integers -from -both -r1 -and -r2 -. -We -/ -/ -can -drop -the -high -64 -- -bit -integers -because -they -are -a -mirror -image -/ -/ -of -the -low -64 -- -bit -integers -. -All -we -care -about -are -the -low -128 -- -bit -/ -/ -lanes -of -r1 -and -r2 -. -Combined -they -contain -all -our -16 -- -bit -bitsets -/ -/ -laid -out -in -the -desired -order -as -described -above -. -r1 -. -for_each_low_64bit_lane -( -r2 -# -[ -inline -( -always -) -] -| -_ -chunk -| -{ -let -result -= -self -. -verify64 -( -cur -end -chunk -) -; -cur -= -cur -. -add -( -4 -) -; -result -} -) -} -} -/ -/ -/ -A -vector -generic -mask -for -the -low -and -high -nybbles -in -a -set -of -patterns -. -/ -/ -/ -Each -8 -- -bit -lane -j -in -a -vector -corresponds -to -a -bitset -where -the -i -th -bit -/ -/ -/ -is -set -if -and -only -if -the -nybble -j -is -in -the -bucket -i -at -a -particular -/ -/ -/ -position -. -/ -/ -/ -/ -/ -/ -This -is -slightly -tweaked -dependending -on -whether -Slim -or -Fat -Teddy -is -being -/ -/ -/ -used -. -For -Slim -Teddy -the -bitsets -in -the -lower -half -are -the -same -as -the -/ -/ -/ -bitsets -in -the -higher -half -so -that -we -can -search -V -: -: -BYTES -bytes -at -a -/ -/ -/ -time -. -( -Remember -the -nybbles -in -the -haystack -are -used -as -indices -into -these -/ -/ -/ -masks -and -256 -- -bit -shuffles -only -operate -on -128 -- -bit -lanes -. -) -/ -/ -/ -/ -/ -/ -For -Fat -Teddy -the -bitsets -are -not -repeated -but -instead -the -high -half -/ -/ -/ -bits -correspond -to -an -addition -8 -buckets -. -So -that -a -bitset -00100010 -has -/ -/ -/ -buckets -1 -and -5 -set -if -it -' -s -in -the -lower -half -but -has -buckets -9 -and -13 -set -/ -/ -/ -if -it -' -s -in -the -higher -half -. -# -[ -derive -( -Clone -Copy -Debug -) -] -struct -Mask -< -V -> -{ -lo -: -V -hi -: -V -} -impl -< -V -: -Vector -> -Mask -< -V -> -{ -/ -/ -/ -Return -a -candidate -for -Teddy -( -fat -or -slim -) -that -is -searching -for -1 -- -byte -/ -/ -/ -candidates -. -/ -/ -/ -/ -/ -/ -If -a -candidate -is -returned -it -will -be -a -collection -of -8 -- -bit -bitsets -/ -/ -/ -( -one -bitset -per -lane -) -where -the -ith -bit -is -set -in -the -jth -lane -if -and -/ -/ -/ -only -if -the -byte -occurring -at -the -jth -lane -in -chunk -is -in -the -bucket -/ -/ -/ -i -. -If -no -candidate -is -found -then -the -vector -returned -will -have -all -/ -/ -/ -lanes -set -to -zero -. -/ -/ -/ -/ -/ -/ -chunk -should -correspond -to -a -V -: -: -BYTES -window -of -the -haystack -( -where -/ -/ -/ -the -least -significant -byte -corresponds -to -the -start -of -the -window -) -. -For -/ -/ -/ -fat -Teddy -the -haystack -window -length -should -be -V -: -: -BYTES -/ -2 -with -/ -/ -/ -the -window -repeated -in -each -half -of -the -vector -. -/ -/ -/ -/ -/ -/ -mask1 -should -correspond -to -a -low -/ -high -mask -for -the -first -byte -of -all -/ -/ -/ -patterns -that -are -being -searched -. -# -[ -inline -( -always -) -] -unsafe -fn -members1 -( -chunk -: -V -masks -: -[ -Mask -< -V -> -; -1 -] -) -- -> -V -{ -let -lomask -= -V -: -: -splat -( -0xF -) -; -let -hlo -= -chunk -. -and -( -lomask -) -; -let -hhi -= -chunk -. -shift_8bit_lane_right -: -: -< -4 -> -( -) -. -and -( -lomask -) -; -let -locand -= -masks -[ -0 -] -. -lo -. -shuffle_bytes -( -hlo -) -; -let -hicand -= -masks -[ -0 -] -. -hi -. -shuffle_bytes -( -hhi -) -; -locand -. -and -( -hicand -) -} -/ -/ -/ -Return -a -candidate -for -Teddy -( -fat -or -slim -) -that -is -searching -for -2 -- -byte -/ -/ -/ -candidates -. -/ -/ -/ -/ -/ -/ -If -candidates -are -returned -each -will -be -a -collection -of -8 -- -bit -bitsets -/ -/ -/ -( -one -bitset -per -lane -) -where -the -ith -bit -is -set -in -the -jth -lane -if -and -/ -/ -/ -only -if -the -byte -occurring -at -the -jth -lane -in -chunk -is -in -the -bucket -/ -/ -/ -i -. -Each -candidate -returned -corresponds -to -the -first -and -second -bytes -/ -/ -/ -of -the -patterns -being -searched -. -If -no -candidate -is -found -then -all -of -/ -/ -/ -the -lanes -will -be -set -to -zero -in -at -least -one -of -the -vectors -returned -. -/ -/ -/ -/ -/ -/ -chunk -should -correspond -to -a -V -: -: -BYTES -window -of -the -haystack -( -where -/ -/ -/ -the -least -significant -byte -corresponds -to -the -start -of -the -window -) -. -For -/ -/ -/ -fat -Teddy -the -haystack -window -length -should -be -V -: -: -BYTES -/ -2 -with -/ -/ -/ -the -window -repeated -in -each -half -of -the -vector -. -/ -/ -/ -/ -/ -/ -The -masks -should -correspond -to -the -masks -computed -for -the -first -and -/ -/ -/ -second -bytes -of -all -patterns -that -are -being -searched -. -# -[ -inline -( -always -) -] -unsafe -fn -members2 -( -chunk -: -V -masks -: -[ -Mask -< -V -> -; -2 -] -) -- -> -( -V -V -) -{ -let -lomask -= -V -: -: -splat -( -0xF -) -; -let -hlo -= -chunk -. -and -( -lomask -) -; -let -hhi -= -chunk -. -shift_8bit_lane_right -: -: -< -4 -> -( -) -. -and -( -lomask -) -; -let -locand1 -= -masks -[ -0 -] -. -lo -. -shuffle_bytes -( -hlo -) -; -let -hicand1 -= -masks -[ -0 -] -. -hi -. -shuffle_bytes -( -hhi -) -; -let -cand1 -= -locand1 -. -and -( -hicand1 -) -; -let -locand2 -= -masks -[ -1 -] -. -lo -. -shuffle_bytes -( -hlo -) -; -let -hicand2 -= -masks -[ -1 -] -. -hi -. -shuffle_bytes -( -hhi -) -; -let -cand2 -= -locand2 -. -and -( -hicand2 -) -; -( -cand1 -cand2 -) -} -/ -/ -/ -Return -a -candidate -for -Teddy -( -fat -or -slim -) -that -is -searching -for -3 -- -byte -/ -/ -/ -candidates -. -/ -/ -/ -/ -/ -/ -If -candidates -are -returned -each -will -be -a -collection -of -8 -- -bit -bitsets -/ -/ -/ -( -one -bitset -per -lane -) -where -the -ith -bit -is -set -in -the -jth -lane -if -and -/ -/ -/ -only -if -the -byte -occurring -at -the -jth -lane -in -chunk -is -in -the -bucket -/ -/ -/ -i -. -Each -candidate -returned -corresponds -to -the -first -second -and -third -/ -/ -/ -bytes -of -the -patterns -being -searched -. -If -no -candidate -is -found -then -/ -/ -/ -all -of -the -lanes -will -be -set -to -zero -in -at -least -one -of -the -vectors -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -chunk -should -correspond -to -a -V -: -: -BYTES -window -of -the -haystack -( -where -/ -/ -/ -the -least -significant -byte -corresponds -to -the -start -of -the -window -) -. -For -/ -/ -/ -fat -Teddy -the -haystack -window -length -should -be -V -: -: -BYTES -/ -2 -with -/ -/ -/ -the -window -repeated -in -each -half -of -the -vector -. -/ -/ -/ -/ -/ -/ -The -masks -should -correspond -to -the -masks -computed -for -the -first -second -/ -/ -/ -and -third -bytes -of -all -patterns -that -are -being -searched -. -# -[ -inline -( -always -) -] -unsafe -fn -members3 -( -chunk +assert +helps +eliminate +bounds +checks +for +bucket +lookups +in +/ +/ +Teddy : -V -masks : -[ -Mask -< -V -> -; +verify_bucket +which +has +a +small +( 3 -] -) - -> -( -V -V -V +4 +% ) -{ -let -lomask -= -V -: -: -splat +performance +boost +. +assert_eq +! ( -0xF +8 +teddy +. +buckets +. +len +( +) ) ; +at ++ += +2 +; let -hlo +len = -chunk +haystack . -and +len ( -lomask ) ; let -hhi +( +mut +prev0 +mut +prev1 +) = -chunk -. -shift_8bit_lane_right -: -: -< -4 -> +( +ones256 ( ) -. -and +ones256 ( -lomask +) ) ; +while +at +< += +len +- +32 +{ let -locand1 +c = -masks -[ -0 -] -. -lo +self . -shuffle_bytes +candidate ( -hlo +haystack +at +& +mut +prev0 +& +mut +prev1 ) ; +if +! +is_all_zeroes256 +( +c +) +{ +if let -hicand1 +Some +( +m +) = -masks -[ -0 -] -. -hi +teddy . -shuffle_bytes +verify256 ( -hhi +pats +haystack +at +- +2 +c +) +{ +return +Some +( +m ) ; -let -cand1 +} +} +at ++ = -locand1 -. -and +32 +; +} +if +at +< +len +{ +at += +len +- +32 +; +prev0 += +ones256 +( +) +; +prev1 += +ones256 ( -hicand1 ) ; let -locand2 +c = -masks -[ -1 -] -. -lo +self . -shuffle_bytes +candidate ( -hlo +haystack +at +& +mut +prev0 +& +mut +prev1 ) ; +if +! +is_all_zeroes256 +( +c +) +{ +if let -hicand2 +Some +( +m +) = -masks +teddy +. +verify256 +( +pats +haystack +at +- +2 +c +) +{ +return +Some +( +m +) +; +} +} +} +None +} +# [ -1 +inline +( +always +) +] +unsafe +fn +candidate +( +& +self +haystack +: +& +[ +u8 ] +at +: +usize +prev0 +: +& +mut +__m256i +prev1 +: +& +mut +__m256i +) +- +> +__m256i +{ +debug_assert +! +( +haystack +[ +at . -hi . -shuffle_bytes +] +. +len ( -hhi +) +> += +32 ) ; let -cand2 +chunk = -locand2 -. -and +loadu256 ( -hicand2 +haystack +at ) ; let -locand3 +( +res0 +res1 +res2 +) = -masks -[ -2 -] +members3m256 +( +chunk +self . -lo +mask1 +self . -shuffle_bytes -( -hlo +mask2 +self +. +mask3 ) ; let -hicand3 +res0prev0 = -masks -[ -2 -] -. -hi -. -shuffle_bytes +alignr256_14 ( -hhi +res0 +* +prev0 ) ; let -cand3 +res1prev1 = -locand3 -. -and +alignr256_15 ( -hicand3 +res1 +* +prev1 ) ; +let +res += +_mm256_and_si256 ( -cand1 -cand2 -cand3 -) -} -/ -/ -/ -Return -a -candidate -for -Teddy +_mm256_and_si256 ( -fat -or -slim +res0prev0 +res1prev1 ) -that -is -searching -for -4 -- -byte -/ -/ -/ -candidates -. -/ -/ -/ -/ -/ -/ -If -candidates -are -returned -each -will -be -a -collection -of -8 -- -bit -bitsets -/ -/ -/ -( -one -bitset -per -lane +res2 ) -where -the -ith -bit -is -set -in -the -jth -lane -if -and -/ -/ -/ -only -if -the -byte -occurring -at -the -jth -lane -in -chunk -is -in -the -bucket -/ -/ -/ -i -. -Each -candidate -returned -corresponds -to -the -first -second -third -/ -/ -/ -and -fourth -bytes -of -the -patterns -being -searched -. -If -no -candidate -is -/ -/ -/ -found -then -all -of -the -lanes -will -be -set -to -zero -in -at -least -one -of -the -/ -/ -/ -vectors -returned -. -/ -/ -/ -/ -/ -/ -chunk -should -correspond -to -a -V -: -: -BYTES -window -of -the -haystack +; +* +prev0 += +res0 +; +* +prev1 += +res1 +; +res +} +} +# +[ +derive ( -where -/ -/ -/ -the -least -significant -byte -corresponds -to -the -start -of -the -window +Clone +Debug ) -. -For -/ -/ -/ -fat -Teddy -the -haystack -window -length -should -be -V +] +pub +struct +TeddyFat3Mask256 +{ +pub +mask1 : +Mask256 +pub +mask2 : -BYTES -/ -2 -with -/ -/ -/ -the -window -repeated -in -each -half -of -the -vector -. -/ -/ -/ -/ -/ -/ -The -masks -should -correspond -to -the -masks -computed -for -the -first -/ -/ -/ -second -third -and -fourth -bytes -of -all -patterns -that -are -being -searched -. +Mask256 +pub +mask3 +: +Mask256 +} +impl +TeddyFat3Mask256 +{ # [ -inline +target_feature ( -always +enable += +" +avx2 +" ) ] unsafe fn -members4 +find_at ( -chunk +& +self +pats : -V -masks +& +Patterns +teddy +: +& +Teddy +haystack : +& [ -Mask -< -V -> -; -4 +u8 ] +mut +at +: +usize ) - > -( -V -V -V -V -) +Option +< +Match +> { -let -lomask -= -V -: -: -splat +debug_assert +! +( +haystack +[ +at +. +. +] +. +len ( -0xF ) -; -let -hlo +> = -chunk +teddy . -and +minimum_len ( -lomask +) ) ; -let -hhi -= -chunk -. -shift_8bit_lane_right +/ +/ +This +assert +helps +eliminate +bounds +checks +for +bucket +lookups +in +/ +/ +Teddy : : -< -4 -> +verify_bucket +which +has +a +small ( +3 +- +4 +% ) +performance +boost . -and +assert_eq +! ( -lomask +16 +teddy +. +buckets +. +len +( +) ) ; +at ++ += +2 +; let -locand1 +len = -masks -[ -0 -] -. -lo +haystack . -shuffle_bytes +len ( -hlo ) ; let -hicand1 +( +mut +prev0 +mut +prev1 +) = -masks -[ -0 -] -. -hi -. -shuffle_bytes ( -hhi +ones256 +( +) +ones256 +( +) ) ; +while +at +< += +len +- +16 +{ let -cand1 +c = -locand1 +self . -and +candidate ( -hicand1 +haystack +at +& +mut +prev0 +& +mut +prev1 ) ; +if +! +is_all_zeroes256 +( +c +) +{ +if let -locand2 +Some +( +m +) = -masks -[ -1 -] -. -lo +teddy . -shuffle_bytes +verify_fat256 +( +pats +haystack +at +- +2 +c +) +{ +return +Some +( +m +) +; +} +} +at ++ += +16 +; +} +if +at +< +len +{ +at += +len +- +16 +; +prev0 += +ones256 ( -hlo ) ; -let -hicand2 +prev1 = -masks -[ -1 -] -. -hi -. -shuffle_bytes +ones256 ( -hhi ) ; let -cand2 +c = -locand2 +self . -and +candidate ( -hicand2 +haystack +at +& +mut +prev0 +& +mut +prev1 ) ; +if +! +is_all_zeroes256 +( +c +) +{ +if let -locand3 +Some +( +m +) = -masks -[ -2 -] -. -lo +teddy . -shuffle_bytes +verify_fat256 ( -hlo +pats +haystack +at +- +2 +c +) +{ +return +Some +( +m ) ; -let -hicand3 -= -masks +} +} +} +None +} +# [ -2 +inline +( +always +) +] +unsafe +fn +candidate +( +& +self +haystack +: +& +[ +u8 ] +at +: +usize +prev0 +: +& +mut +__m256i +prev1 +: +& +mut +__m256i +) +- +> +__m256i +{ +debug_assert +! +( +haystack +[ +at . -hi . -shuffle_bytes +] +. +len ( -hhi +) +> += +16 ) ; let -cand3 +chunk = -locand3 -. -and +_mm256_broadcastsi128_si256 ( -hicand3 +loadu128 +( +haystack +at +) ) ; let -locand4 +( +res0 +res1 +res2 +) = -masks -[ -3 -] +members3m256 +( +chunk +self . -lo +mask1 +self . -shuffle_bytes -( -hlo +mask2 +self +. +mask3 ) ; let -hicand4 +res0prev0 = -masks -[ -3 -] -. -hi -. -shuffle_bytes +_mm256_alignr_epi8 ( -hhi +res0 +* +prev0 +14 ) ; let -cand4 +res1prev1 = -locand4 -. -and +_mm256_alignr_epi8 ( -hicand4 +res1 +* +prev1 +15 ) ; -( -cand1 -cand2 -cand3 -cand4 -) -} -} -/ -/ -/ -Represents -the -low -and -high -nybble -masks -that -will -be -used -during -/ -/ -/ -search -. -Each -mask -is -32 -bytes -wide -although -only -the -first -16 -bytes -are -/ -/ -/ -used -for -128 -- -bit -vectors -. -/ -/ -/ -/ -/ -/ -Each -byte -in -the -mask -corresponds -to -a -8 -- -bit -bitset -where -bit -i -is -set -/ -/ -/ -if -and -only -if -the -corresponding -nybble -is -in -the -ith -bucket -. -The -index -of -/ -/ -/ -the -byte -( -0 -- -15 -inclusive +let +res += +_mm256_and_si256 +( +_mm256_and_si256 +( +res0prev0 +res1prev1 ) -corresponds -to -the -nybble -. -/ -/ -/ +res2 +) +; +* +prev0 += +res0 +; +* +prev1 += +res1 +; +res +} +} / / / -Each +A +128 +- +bit mask -is -used -as -the -target -of -a -shuffle -where -the -indices -for -the -/ -/ -/ -shuffle -are -taken -from -the -haystack -. -AND -' -ing -the -shuffles for -both the -/ -/ -/ low and high -masks -together -also -results +nybbles in -8 -- -bit -bitsets -but -where -bit +a +set +of +patterns +. +Each / / / +lane +j +corresponds +to +a +bitset +where +the i +th +bit is set if and only if +/ +/ +/ the -correspond -* -byte -* +nybble +j is in the -ith bucket +i +at +a +particular +position . # [ derive ( Clone -Default +Copy +Debug ) ] +pub struct -SlimMaskBuilder +Mask128 { lo : -[ -u8 -; -32 -] +__m128i hi : -[ -u8 -; -32 -] +__m128i } impl -SlimMaskBuilder +Mask128 { / / / -Update -this +Create +a +new +SIMD mask -by -adding -the -given -byte -to +from the -given -bucket -. -The -/ -/ -/ -given -bucket -must -be -in +mask +produced +by the -range -0 -- -7 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -When -bucket -> -= -8 +Teddy +builder . +pub fn -add +new ( -& -mut -self -bucket +mask : -usize -byte +compile : -u8 +: +Mask ) +- +> +Mask128 { -assert -! -( -bucket -< -8 -) -; -let -bucket -= +/ +/ +SAFETY +: +This +is +safe +since +[ u8 +; +16 +] +has +the +same +representation +/ +/ +as +__m128i +. +unsafe +{ +Mask128 +{ +lo +: +mem : : -try_from +transmute ( -bucket -) +mask . -unwrap +lo128 ( ) -; -let -byte_lo -= -usize -: -: -from -( -byte -& -0xF ) -; -let -byte_hi -= -usize +hi : +mem : -from +: +transmute ( +mask +. +hi128 ( -byte -> -> -4 ) -& -0xF ) -; +} +} +} +} / / -When -using +/ +A 256 - bit -vectors -we -need -to -set -this -bucket -assignment -in -/ -/ +mask +for the low and high -128 -- -bit -portions +nybbles +in +a +set of -the -mask +patterns . -This -allows -us -to +Each / / -process -32 -bytes -at +/ +lane +j +corresponds +to a -time -. -Namely -AVX2 -shuffles -operate -on -each +bitset +where +the +i +th +bit +is +set +if +and +only +if +/ / / -of the -128 -- -bit -lanes -rather -than +nybble +j +is +in the -full -256 -- -bit -vector -at -once -. -self -. -lo -[ -byte_lo -] -| -= -1 -< -< -bucket -; -self -. -lo -[ -byte_lo -+ -16 -] -| -= -1 -< -< -bucket -; -self -. -hi -[ -byte_hi -] -| -= -1 -< -< bucket -; -self +i +at +a +particular +position . -hi -[ -byte_hi -+ -16 -] -| -= -1 -< -< -bucket -; -} / / / -Turn -this -builder -into -a -vector -mask -. / / / +This +is +slightly +tweaked +dependending +on +whether +Slim +or +Fat +Teddy +is +being / / / -# -Panics +used +. +For +Slim +Teddy +the +bitsets +in +the +lower +128 +- +bits +are +the +same +as / / / +the +bitsets +in +the +higher +128 +- +bits +so +that +we +can +search +32 +bytes +at +a / / / -When -V -represents -a -vector -bigger -than -what -MaskBytes -can -contain +time +. +( +Remember +the +nybbles +in +the +haystack +are +used +as +indices +into +these +/ +/ +/ +masks +and +256 +- +bit +shuffles +only +operate +on +128 +- +bit +lanes . +) / / / / / / -# -Safety +For +Fat +Teddy +the +bitsets +are +not +repeated +but +instead +the +high +128 / / / +bits +correspond +to +buckets +8 +- +15 +. +So +that +a +bitset +00100010 +has +buckets / / / -Callers -must -ensure -that -this -is -okay -to -call +1 +and +5 +set +if +it +' +s in the -current -target -for +lower +128 +bits +but +has +buckets +9 +and +13 +set / / / +if +it +' +s +in the -current -CPU +higher +128 +bits . # [ -inline +derive ( -always +Clone +Copy +Debug ) ] -unsafe -fn -build -< -V -: -Vector -> -( -& -self -) -- -> -Mask -< -V -> +pub +struct +Mask256 { -assert -! -( -V +lo : +__m256i +hi : -BYTES -< -= -self -. -lo +__m256i +} +impl +Mask256 +{ +/ +/ +/ +Create +a +new +SIMD +mask +from +the +mask +produced +by +the +Teddy +builder . -len -( -) -) -; -assert -! +pub +fn +new ( -V +mask : +compile : -BYTES -< -= -self -. -hi -. -len -( -) +: +Mask ) +- +> +Mask256 +{ +/ +/ +SAFETY +: +This +is +safe +since +[ +u8 ; -Mask +32 +] +has +the +same +representation +/ +/ +as +__m256i +. +unsafe +{ +Mask256 { lo : -V +mem : : -load_unaligned +transmute ( -self -. -lo -[ -. -. -] +mask . -as_ptr +lo256 ( ) ) hi : -V +mem : : -load_unaligned +transmute ( -self -. -hi -[ -. -. -] +mask . -as_ptr +hi256 ( ) ) } } +} +} / / -/ -A -convenience -function +The +" +members +" +routines +below +are +responsible for -building -N -vector -masks -from +taking a -slim +chunk +of +bytes / / +a +number +of +nybble +masks +and +returning +the +result +of +using +the +masks +to +/ / -Teddy -value +lookup +bytes +in +the +chunk . +The +results +of +the +high +and +low +nybble +masks +are +/ +/ +AND +' +ed +together +such +that +each +candidate +returned +is +a +vector +with +byte / / +sized +lanes +and +where +each +lane +is +an +8 +- +bit +bitset +corresponding +to +the / / +buckets +that +contain +the +corresponding +byte +. / / -# -Panics / / +In +the +case +of +masks +of +length +greater +than +1 +callers +will +need +to +keep / / +the +results +from +the +previous +haystack +' +s +window +and +then +shift +the +vectors / / -When -V -represents -a -vector -bigger -than -what -MaskBytes +so +that +they +all +line +up +. +Then +they can -contain +be +AND +' +ed +together . / / / +Return +a +candidate +for +Slim +128 +- +bit +Teddy +where +chunk +corresponds +to +a / / / -# -Safety -/ -/ -/ +16 +- +byte +window +of +the +haystack +( +where +the +least +significant +byte / / / -Callers -must -ensure -that -this -is -okay +corresponds to -call -in the -current -target -for -/ -/ -/ +start +of the -current -CPU -. -# -[ -inline -( -always -) -] -unsafe -fn -from_teddy -< -const -BYTES -: -usize -V -: -Vector -> -( -teddy -: -& -Teddy -< -8 -> +window ) -- -> -[ -Mask -< -V -> -; -BYTES -] -{ +and +mask1 +corresponds +to +a / / -MSRV -( -1 -. -63 -) -: -Use -core -: -: -array -: -: -from_fn -to -just -build -the -array -here / +low / -instead +high +mask +for +the +first +byte of -creating -a -vector -and -turning -it -into -an -array +all +patterns +that +are +being +searched . -let -mut -mask_builders -= -vec -! +# [ -SlimMaskBuilder -: -: -default -( -) -; -BYTES -] -; -for -( -bucket_index -bucket -) -in -teddy -. -buckets -. -iter -( -) -. -enumerate -( -) -{ -for -pid -in -bucket -. -iter -( -) -. -copied +target_feature ( -) -{ -let -pat +enable = -teddy -. -patterns -. -get -( -pid -) -; -for -( -i -builder -) -in -mask_builders -. -iter_mut -( -) -. -enumerate -( -) -{ -builder -. -add -( -bucket_index -pat -. -bytes -( -) -[ -i -] +" +ssse3 +" ) -; -} -} -} -let -array -= -< -[ -SlimMaskBuilder -; -BYTES ] -> -: -: -try_from -( -mask_builders -) -. -unwrap -( -) -; -array -. -map -( -| -builder -| -builder -. -build -( -) -) -} -} -impl -Debug -for -SlimMaskBuilder -{ +unsafe fn -fmt +members1m128 ( -& -self -f -: -& -mut -core -: -: -fmt +chunk : +__m128i +mask1 : -Formatter -< -' -_ -> +Mask128 ) - > -core -: -: -fmt -: -: -Result +__m128i { let -( -mut -parts_lo -mut -parts_hi -) +lomask = +_mm_set1_epi8 ( -vec -! -[ -] -vec -! -[ -] +0xF ) ; -for -i -in -0 -. -. -32 -{ -parts_lo -. -push -( -format -! +let +hlo += +_mm_and_si128 ( -" -{ -: -02 -} -: -{ -: -08b -} -" -i -self -. -lo -[ -i -] -) +chunk +lomask ) ; -parts_hi -. -push +let +hhi += +_mm_and_si128 ( -format -! +_mm_srli_epi16 ( -" -{ -: -02 -} -: -{ -: -08b -} -" -i -self -. -hi -[ -i -] +chunk +4 ) +lomask ) ; -} -f -. -debug_struct +_mm_and_si128 ( -" -SlimMaskBuilder -" -) -. -field +_mm_shuffle_epi8 ( -" +mask1 +. lo -" -& -parts_lo +hlo ) -. -field +_mm_shuffle_epi8 ( -" +mask1 +. hi -" -& -parts_hi +hhi ) -. -finish -( ) } -} -/ -/ -/ -Represents -the -low -and -high -nybble -masks -that -will -be -used -during -" -fat -" -/ -/ -/ -Teddy -search -. -/ / / / -/ -/ -Each -mask -is -32 -bytes -wide -and -at -the -time -of -writing -only +Return +a +candidate +for +Slim 256 - bit -vectors -/ -/ -/ -support -fat -Teddy -. -/ -/ -/ -/ -/ -/ -A -fat Teddy -mask -is -like +where +chunk +corresponds +to a -slim -Teddy -mask -except -that -instead -of / / / -repeating -the -bitsets -in -the -high -and -low -128 -- -bits -in -256 +32 - -bit -vectors +byte +window +of the -/ -/ -/ -high -and -low -128 -- -bit -halves -each -represent -distinct -buckets -. +haystack ( -Bringing +where the +least +significant +byte / / / -total +corresponds to -16 -instead +the +start of -8 -. -) -This -permits -spreading the -patterns -out +window +) +and +mask1 +corresponds +to a -bit / / / -more -and -thus -putting -less -pressure -on -verification -to -be -fast +low +/ +high +mask +for +the +first +byte +of +all +patterns +that +are +being +searched . / / @@ -11068,937 +8220,1091 @@ fast / / / -Each -byte -in -the -mask -corresponds -to -a -8 -- -bit -bitset +Note +that +this +can +also +be +used +for +Fat +Teddy where -bit -i -is -set -/ -/ -/ -if -and -only -if the -corresponding -nybble -is +high +128 +bits in -the -ith -bucket -. -The -index -of / / / +chunk +is the -byte -( -0 -- -15 -inclusive -) +same +as +the +low +128 +bits +which corresponds to +a +16 +byte +/ +/ +/ +window +in the -nybble +haystack . # [ -derive +target_feature ( -Clone -Copy -Default +enable += +" +avx2 +" ) ] -struct -FatMaskBuilder -{ -lo +unsafe +fn +members1m256 +( +chunk : -[ -u8 -; -32 -] -hi +__m256i +mask1 : -[ -u8 +Mask256 +) +- +> +__m256i +{ +let +lomask += +_mm256_set1_epi8 +( +0xF +) ; -32 -] +let +hlo += +_mm256_and_si256 +( +chunk +lomask +) +; +let +hhi += +_mm256_and_si256 +( +_mm256_srli_epi16 +( +chunk +4 +) +lomask +) +; +_mm256_and_si256 +( +_mm256_shuffle_epi8 +( +mask1 +. +lo +hlo +) +_mm256_shuffle_epi8 +( +mask1 +. +hi +hhi +) +) } -impl -FatMaskBuilder -{ / / / -Update -this -mask -by -adding -the -given -byte -to -the -given -bucket -. -The +Return +candidates +for +Slim +128 +- +bit +Teddy +where +chunk +corresponds / / / -given -bucket -must -be -in -the -range -0 +to +a +16 - -15 -. +byte +window +of +the +haystack +( +where +the +least +significant +byte +/ / / +corresponds +to +the +start +of +the +window +) +and +the +masks +correspond +to +a / / / +low / -# -Panics +high +mask +for +the +first +and +second +bytes +of +all +patterns +that +are +being / / / +searched +. +The +vectors +returned +correspond +to +candidates +for +the +first +and / / / -When -bucket -> -= -16 +second +bytes +in +the +patterns +represented +by +the +masks . +# +[ +target_feature +( +enable += +" +ssse3 +" +) +] +unsafe fn -add +members2m128 ( -& -mut -self -bucket +chunk : -usize -byte +__m128i +mask1 : -u8 +Mask128 +mask2 +: +Mask128 +) +- +> +( +__m128i +__m128i ) { -assert -! +let +lomask += +_mm_set1_epi8 ( -bucket -< -16 +0xF ) ; let -bucket +hlo = -u8 -: -: -try_from +_mm_and_si128 ( -bucket +chunk +lomask ) -. -unwrap +; +let +hhi += +_mm_and_si128 ( +_mm_srli_epi16 +( +chunk +4 +) +lomask ) ; let -byte_lo +res0 = -usize -: -: -from +_mm_and_si128 ( -byte -& -0xF +_mm_shuffle_epi8 +( +mask1 +. +lo +hlo +) +_mm_shuffle_epi8 +( +mask1 +. +hi +hhi +) ) ; let -byte_hi +res1 = -usize -: -: -from +_mm_and_si128 ( +_mm_shuffle_epi8 ( -byte -> -> -4 +mask2 +. +lo +hlo +) +_mm_shuffle_epi8 +( +mask2 +. +hi +hhi ) -& -0xF ) ; +( +res0 +res1 +) +} / / -Unlike -slim -teddy -fat -teddy -only -works -with -AVX2 -. -For -fat -teddy +/ +Return +candidates +for +Slim +256 +- +bit +Teddy +where +chunk +corresponds +/ +/ +/ +to +a +32 +- +byte +window +of +the +haystack +( +where +the +least +significant +byte / / +/ +corresponds +to the -high -128 -bits +start of -our +the +window +) +and +the +masks +correspond +to +a +/ +/ +/ +low +/ +high mask +for +the +first +and +second +bytes +of +all +patterns +that +are +being +/ +/ +/ +searched +. +The +vectors +returned correspond to -buckets -8 -- -15 -while +candidates +for +the +first +and +/ +/ +/ +second +bytes +in +the +patterns +represented +by +the +masks +. +/ +/ +/ +/ +/ +/ +Note +that +this +can +also +be +used +for +Fat +Teddy +where the +high +128 +bits +in / / +/ +chunk +is +the +same +as +the low 128 bits -correspond +which +corresponds to -buckets -0 -- -7 +a +16 +byte +/ +/ +/ +window +in +the +haystack . -if -bucket -< -8 +# +[ +target_feature +( +enable += +" +avx2 +" +) +] +unsafe +fn +members2m256 +( +chunk +: +__m256i +mask1 +: +Mask256 +mask2 +: +Mask256 +) +- +> +( +__m256i +__m256i +) { -self -. -lo -[ -byte_lo -] -| +let +lomask = -1 -< -< -bucket +_mm256_set1_epi8 +( +0xF +) ; -self -. -hi -[ -byte_hi -] -| +let +hlo = -1 -< -< -bucket +_mm256_and_si256 +( +chunk +lomask +) ; -} -else -{ -self -. -lo -[ -byte_lo -+ -16 -] -| +let +hhi = -1 -< -< +_mm256_and_si256 ( -bucket -% -8 +_mm256_srli_epi16 +( +chunk +4 +) +lomask ) ; -self +let +res0 += +_mm256_and_si256 +( +_mm256_shuffle_epi8 +( +mask1 +. +lo +hlo +) +_mm256_shuffle_epi8 +( +mask1 . hi -[ -byte_hi -+ -16 -] -| +hhi +) +) +; +let +res1 = -1 -< -< +_mm256_and_si256 ( -bucket -% -8 +_mm256_shuffle_epi8 +( +mask2 +. +lo +hlo +) +_mm256_shuffle_epi8 +( +mask2 +. +hi +hhi +) ) ; +( +res0 +res1 +) } -} -/ -/ -/ -Turn -this -builder -into -a -vector -mask -. -/ -/ -/ -/ -/ -/ -# -Panics / / / +Return +candidates +for +Slim +128 +- +bit +Teddy +where +chunk +corresponds / / / -When -V -represents +to a -vector -bigger -than -what -MaskBytes -can -contain -. -/ -/ +16 +- +byte +window +of +the +haystack +( +where +the +least +significant +byte / / / +corresponds +to +the +start +of +the +window +) +and +the +masks +correspond +to +a / -# -Safety / / +low / +high +mask +for +the +first +second +and +third +bytes +of +all +patterns +that / / / -Callers -must -ensure -that -this -is -okay +are +being +searched +. +The +vectors +returned +correspond to -call -in -the -current -target +candidates for +the / / / +first +second +and +third +bytes +in the -current -CPU +patterns +represented +by +the +masks . # [ -inline +target_feature ( -always +enable += +" +ssse3 +" ) ] unsafe fn -build -< -V -: -Vector -> +members3m128 ( -& -self +chunk +: +__m128i +mask1 +: +Mask128 +mask2 +: +Mask128 +mask3 +: +Mask128 ) - > -Mask -< -V -> +( +__m128i +__m128i +__m128i +) { -assert -! +let +lomask += +_mm_set1_epi8 +( +0xF +) +; +let +hlo += +_mm_and_si128 +( +chunk +lomask +) +; +let +hhi += +_mm_and_si128 +( +_mm_srli_epi16 ( -V -: -: -BYTES -< +chunk +4 +) +lomask +) +; +let +res0 = -self +_mm_and_si128 +( +_mm_shuffle_epi8 +( +mask1 . lo -. -len +hlo +) +_mm_shuffle_epi8 ( +mask1 +. +hi +hhi ) ) ; -assert -! -( -V -: -: -BYTES -< +let +res1 = -self -. -hi +_mm_and_si128 +( +_mm_shuffle_epi8 +( +mask2 . -len +lo +hlo +) +_mm_shuffle_epi8 ( +mask2 +. +hi +hhi ) ) ; -Mask -{ -lo -: -V -: -: -load_unaligned +let +res2 += +_mm_and_si128 ( -self +_mm_shuffle_epi8 +( +mask3 . lo -[ -. -. -] -. -as_ptr -( -) +hlo ) -hi -: -V -: -: -load_unaligned +_mm_shuffle_epi8 ( -self +mask3 . hi -[ -. -. -] -. -as_ptr -( +hhi ) ) -} +; +( +res0 +res1 +res2 +) } / / / -A -convenience -function +Return +candidates for -building -N -vector -masks -from -a -fat -/ -/ -/ +Slim +256 +- +bit Teddy -value -. -/ -/ +where +chunk +corresponds / / / +to +a +32 +- +byte +window +of +the +haystack +( +where +the +least +significant +byte / -# -Panics / / +corresponds +to +the +start +of +the +window +) +and +the +masks +correspond +to +a / / / +low / -When -V -represents -a -vector -bigger -than -what -MaskBytes -can -contain -. +high +mask +for +the +first +second +and +third +bytes +of +all +patterns +that / / / +are +being +searched +. +The +vectors +returned +correspond +to +candidates +for +the / / / -# -Safety +first +second +and +third +bytes +in +the +patterns +represented +by +the +masks +. / / / / / / -Callers -must -ensure +Note that this -is -okay -to -call -in -the -current -target +can +also +be +used for -/ -/ -/ -the -current -CPU -. -# -[ -inline -( -always -) -] -unsafe -fn -from_teddy -< -const -BYTES -: -usize -V -: -Vector -> -( -teddy -: -& +Fat Teddy -< -16 -> -) -- -> -[ -Mask -< -V -> -; -BYTES -] -{ +where +the +high +128 +bits +in / / -MSRV -( -1 -. -63 -) -: -Use -core -: -: -array -: -: -from_fn -to -just -build +/ +chunk +is the -array -here +same +as +the +low +128 +bits +which +corresponds +to +a +16 +byte / / -instead -of -creating -a -vector -and -turning -it -into -an -array +/ +window +in +the +haystack . -let -mut -mask_builders -= -vec -! +# [ -FatMaskBuilder -: -: -default +target_feature ( +enable += +" +avx2 +" ) -; -BYTES ] -; -for -( -bucket_index -bucket -) -in -teddy -. -buckets -. -iter -( -) -. -enumerate -( -) -{ -for -pid -in -bucket -. -iter +unsafe +fn +members3m256 ( +chunk +: +__m256i +mask1 +: +Mask256 +mask2 +: +Mask256 +mask3 +: +Mask256 ) -. -copied +- +> ( +__m256i +__m256i +__m256i ) { let -pat +lomask = -teddy -. -patterns -. -get +_mm256_set1_epi8 ( -pid +0xF ) ; -for -( -i -builder -) -in -mask_builders -. -iter_mut -( -) -. -enumerate +let +hlo += +_mm256_and_si256 ( +chunk +lomask ) -{ -builder -. -add +; +let +hhi += +_mm256_and_si256 ( -bucket_index -pat -. -bytes +_mm256_srli_epi16 ( +chunk +4 ) -[ -i -] +lomask ) ; -} -} -} let -array +res0 = -< -[ -FatMaskBuilder -; -BYTES -] -> -: -: -try_from +_mm256_and_si256 ( -mask_builders -) -. -unwrap +_mm256_shuffle_epi8 ( -) -; -array +mask1 . -map +lo +hlo +) +_mm256_shuffle_epi8 ( -| -builder -| -builder +mask1 . -build -( -) +hi +hhi ) -} -} -impl -Debug -for -FatMaskBuilder -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> ) -- -> -core -: -: -fmt -: -: -Result -{ +; let -( -mut -parts_lo -mut -parts_hi -) +res1 = +_mm256_and_si256 ( -vec -! -[ -] -vec -! -[ -] -) -; -for -i -in -0 -. -. -32 -{ -parts_lo -. -push -( -format -! +_mm256_shuffle_epi8 ( -" -{ -: -02 -} -: -{ -: -08b -} -" -i -self +mask2 . lo -[ -i -] -) +hlo ) -; -parts_hi -. -push +_mm256_shuffle_epi8 ( -format -! -( -" -{ -: -02 -} -: -{ -: -08b -} -" -i -self +mask2 . hi -[ -i -] +hhi ) ) ; -} -f -. -debug_struct +let +res2 += +_mm256_and_si256 ( -" -FatMaskBuilder -" -) -. -field +_mm256_shuffle_epi8 ( -" +mask3 +. lo -" -& -parts_lo +hlo ) -. -field +_mm256_shuffle_epi8 ( -" +mask3 +. hi -" -& -parts_hi +hhi ) -. -finish +) +; ( +res0 +res1 +res2 ) } -} diff --git a/third_party/rust/aho-corasick/src/packed/tests.rs b/third_party/rust/aho-corasick/src/packed/tests.rs index 1265d8cf944ff..68e5ef129cdbe 100644 --- a/third_party/rust/aho-corasick/src/packed/tests.rs +++ b/third_party/rust/aho-corasick/src/packed/tests.rs @@ -8,30 +8,15 @@ collections HashMap ; use -alloc -: -: -{ -format -string -: -: -{ -String -ToString -} -vec -vec +std : : -Vec -} +usize ; use crate : : -{ packed : : @@ -39,14 +24,12 @@ packed Config MatchKind } -util -: -: -search +; +use +crate : : Match -} ; / / @@ -255,23 +238,6 @@ SearchTestOwned > { let -count -= -if -cfg -! -( -miri -) -{ -1 -} -else -{ -261 -} -; -let mut tests = @@ -286,7 +252,8 @@ in 0 . . -count += +260 { tests . @@ -645,6 +612,96 @@ to_vec ) } } +/ +/ +fn +to_owned +( +& +self +) +- +> +SearchTestOwned +{ +/ +/ +SearchTestOwned +{ +/ +/ +name +: +self +. +name +. +to_string +( +) +/ +/ +patterns +: +self +. +patterns +. +iter +( +) +. +map +( +| +s +| +s +. +to_string +( +) +) +. +collect +( +) +/ +/ +haystack +: +self +. +haystack +. +to_string +( +) +/ +/ +matches +: +self +. +matches +. +iter +( +) +. +cloned +( +) +. +collect +( +) +/ +/ +} +/ +/ +} } / / @@ -1280,77 +1337,6 @@ zazabczabcz t ! ( -basic230 -& -[ -" -abcd -" -] -" -abcd -" -& -[ -( -0 -0 -4 -) -] -) -t -! -( -basic240 -& -[ -" -abcd -" -] -" -zazabzabcdz -" -& -[ -( -0 -6 -10 -) -] -) -t -! -( -basic250 -& -[ -" -abcd -" -] -" -zazabcdzabcdz -" -& -[ -( -0 -3 -7 -) -( -0 -8 -12 -) -] -) -t -! -( basic300 & [ @@ -4005,17 +3991,11 @@ mut config ) ; -let -mut -builder -= config . builder ( ) -; -builder . extend ( @@ -4039,90 +4019,14 @@ as_bytes ) ) ) -; -let -searcher -= -match -builder . build ( ) -{ -Some -( -searcher -) -= -> -searcher -None -= -> -{ -/ -/ -For -x86 -- -64 -and -aarch64 -not -building -a -searcher -is -/ -/ -probably -a -bug -so -be -loud . -if -cfg -! +unwrap ( -any -( -target_arch -= -" -x86_64 -" -target_arch -= -" -aarch64 -" -) -) -{ -panic -! -( -" -failed -to -build -packed -searcher -" ) -} -return -None -; -} -} -; -Some -( -searcher . find_iter ( @@ -4135,7 +4039,6 @@ haystack collect ( ) -) } ) ; @@ -4143,6 +4046,17 @@ collect } ; } +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4159,6 +4073,17 @@ Config } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4185,6 +4110,17 @@ LeftmostLongest } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4200,7 +4136,7 @@ Config { c . -only_teddy +force_teddy ( true ) @@ -4208,6 +4144,17 @@ true } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4223,7 +4170,7 @@ Config { c . -only_teddy +force_teddy ( true ) @@ -4239,6 +4186,17 @@ LeftmostLongest } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4254,26 +4212,12 @@ Config { c . -only_teddy +force_teddy ( true ) ; -# -[ -cfg -( -target_arch -= -" -x86_64 -" -) -] if -std -: -: is_x86_feature_detected ! ( @@ -4284,7 +4228,7 @@ ssse3 { c . -only_teddy_256bit +force_avx ( Some ( @@ -4296,6 +4240,17 @@ false } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4311,7 +4266,7 @@ Config { c . -only_teddy +force_teddy ( true ) @@ -4324,21 +4279,7 @@ MatchKind LeftmostLongest ) ; -# -[ -cfg -( -target_arch -= -" -x86_64 -" -) -] if -std -: -: is_x86_feature_detected ! ( @@ -4349,7 +4290,7 @@ ssse3 { c . -only_teddy_256bit +force_avx ( Some ( @@ -4361,6 +4302,17 @@ false } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4376,26 +4328,12 @@ Config { c . -only_teddy +force_teddy ( true ) ; -# -[ -cfg -( -target_arch -= -" -x86_64 -" -) -] if -std -: -: is_x86_feature_detected ! ( @@ -4406,7 +4344,7 @@ avx2 { c . -only_teddy_256bit +force_avx ( Some ( @@ -4418,6 +4356,17 @@ true } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4433,7 +4382,7 @@ Config { c . -only_teddy +force_teddy ( true ) @@ -4446,21 +4395,7 @@ MatchKind LeftmostLongest ) ; -# -[ -cfg -( -target_arch -= -" -x86_64 -" -) -] if -std -: -: is_x86_feature_detected ! ( @@ -4471,7 +4406,7 @@ avx2 { c . -only_teddy_256bit +force_avx ( Some ( @@ -4483,6 +4418,17 @@ true } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4498,26 +4444,12 @@ Config { c . -only_teddy +force_teddy ( true ) ; -# -[ -cfg -( -target_arch -= -" -x86_64 -" -) -] if -std -: -: is_x86_feature_detected ! ( @@ -4528,7 +4460,7 @@ avx2 { c . -only_teddy_fat +force_teddy_fat ( Some ( @@ -4540,6 +4472,17 @@ true } ) ; +# +[ +cfg +( +target_arch += +" +x86_64 +" +) +] testconfig ! ( @@ -4555,7 +4498,7 @@ Config { c . -only_teddy +force_teddy ( true ) @@ -4568,21 +4511,7 @@ MatchKind LeftmostLongest ) ; -# -[ -cfg -( -target_arch -= -" -x86_64 -" -) -] if -std -: -: is_x86_feature_detected ! ( @@ -4593,7 +4522,7 @@ avx2 { c . -only_teddy_fat +force_teddy_fat ( Some ( @@ -4620,7 +4549,7 @@ Config { c . -only_rabin_karp +force_rabin_karp ( true ) @@ -4643,7 +4572,7 @@ Config { c . -only_rabin_karp +force_rabin_karp ( true ) @@ -4838,14 +4767,11 @@ SearchTestOwned ) - > -Option -< Vec < Match > > -> ( which : @@ -4895,10 +4821,6 @@ m pattern ( ) -. -as_usize -( -) m . start @@ -4937,29 +4859,6 @@ variations ( ) { -let -results -= -match -f -( -& -test -) -{ -None -= -> -continue -Some -( -results -) -= -> -results -} -; assert_eq ! ( @@ -4968,7 +4867,11 @@ test matches get_match_triples ( -results +f +( +& +test +) ) . as_slice @@ -4986,20 +4889,11 @@ patterns ? } haystack -( -len -= -{ -: -? -} -) : { : ? } -\ offset : { @@ -5016,13 +4910,6 @@ patterns test . haystack -. -len -( -) -test -. -haystack test . offset diff --git a/third_party/rust/aho-corasick/src/packed/vector.rs b/third_party/rust/aho-corasick/src/packed/vector.rs index 8f86ada518a39..a46ac42786ff8 100644 --- a/third_party/rust/aho-corasick/src/packed/vector.rs +++ b/third_party/rust/aho-corasick/src/packed/vector.rs @@ -1,963 +1,1073 @@ / / -NOTE -: -The -descriptions -for -each +This +file +contains +a +set of -the -vector -methods -on -the -traits -below -/ -/ -are -pretty -inscrutable -. -For -this -reason -there -are -tests -for -every -method +fairly +generic +utility +functions +when +working / / -on -for -every -trait -impl -below +with +SIMD +vectors . -If -you -' -re -confused -about -what -an -op -does / / -consult -its -test -. -( -They -probably -should -be -doc -tests -but -I -couldn -' -t -figure / / -out -how -to -write -them -in -a -non -- -annoying -way -. -) -use -core +SAFETY : -: -{ -fmt -: -: -Debug -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -} -; -/ -/ -/ -A -trait -for -describing -vector -operations -used -by -vectorized -searchers -. -/ -/ -/ -/ -/ -/ -The -trait -is -highly -constrained +All +of +the +routines +below +are +unsafe to -low -level -vector -operations -needed -for -/ +call +because +they +assume / / the -specific -algorithms -used +necessary +CPU +target +features in -this -crate -. -In -general -it -was -invented -/ -/ -/ -mostly +order to -be -generic -over -x86 -' -s -__m128i -and -__m256i -types -. -At -time -of -/ +use +particular +vendor / / -writing -it -also -supports -wasm -and -aarch64 -128 -- -bit -vector -types -as -well +intrinsics . +Calling +these +routines +when +the +underlying +CPU +does +not +support / / +the +appropriate +target +features +is +NOT +safe +. +Callers +must +ensure +this / / -/ -/ -# -Safety +themselves +. / / / / +Note +that +it +may +not +look +like +this +safety +invariant +is +being +upheld +when / / -All -methods -are -not -safe -since -they +these +routines are -intended -to -be -implemented -using -/ +called +. +Namely +the +CPU +feature +check +is +typically +pretty / / -vendor -intrinsics -which +far +away +from +when +these +routines are -also -not -safe +used . -Callers -must -ensure -that -/ +Instead +we +rely +on +the +fact / / -the -appropriate +that +certain +types +serve +as +a +guaranteed +receipt +that +pertinent target +/ +/ features are enabled -in +. +For +example the -calling -function -/ +only +way +TeddySlim3Mask256 +can +be / / -and -that +constructed +is +if the -current +AVX2 CPU -supports -them +feature +is +available . -All -implementations -should +Thus +any +code +running / / +inside +of +TeddySlim3Mask256 +can +use +any +of +the +functions +below +without +any +/ / -avoid -marking +additional +checks +: +its +very +existence +* +is +* the -routines -with -# -[ -target_feature -] -and -instead -mark +check +. +use +std +: +: +arch +: +: +x86_64 +: +: +* +; / / / -them -as -# -[ -inline -( -always -) -] +Shift +a to -ensure -they -get -appropriately -inlined -. +the +left +by +two +bytes +( +removing +its +two +most +significant / / / -( -inline -( -always +bytes ) -cannot -be -used +and +concatenate +it with -target_feature +the +the +two +most +significant +bytes +of +b . +# +[ +target_feature +( +enable += +" +avx2 +" ) +] pub +unsafe +fn +alignr256_14 ( -crate -) -trait -Vector +a : -Copy -+ -Debug -+ -Send -+ -Sync -+ -UnwindSafe -+ -RefUnwindSafe -{ -/ -/ -/ -The -number -of -bits -in -the -vector -. -const -BITS +__m256i +b : -usize -; -/ +__m256i +) +- +> +__m256i +{ / / -The -number -of -bytes -in -the -vector -. -That -is +Credit +goes +to +jneem +for +figuring this -is -the -size -of -the -/ -/ -/ -vector -in -memory -. -const -BYTES +out : -usize -; -/ -/ / -Create -a -vector -with -8 -- -bit -lanes -with -the -given -byte -repeated -into -each / +https +: / / -lane +github . +com +/ +jneem / +teddy / +blob / +9ab5e899ad6ef6911aecd3cf1033f1abe6e1f66c / +src / +x86 / +teddy_simd +. +rs # -Safety +L145 +- +L184 / / / / +TL +; +DR +avx2 +' +s +PALIGNR +instruction +is +actually +just +two +128 +- +bit +PALIGNR / / -Callers -must -ensure -that -this +instructions +which is -okay +not +what +we +want +so +we +need to -call -in -the -current -target -for -/ +do +some +extra / / -the -current -CPU +shuffling . -unsafe -fn -splat -( -byte -: -u8 -) -- -> -Self -; / / -/ -Read -a -vector -- -size -number -of +This +permute +gives +us +the +low +16 bytes -from +of +a +concatenated +with the -given -pointer -. -The -pointer -/ +high / / -does -not -need +16 +bytes +of +b +in +order +of +most +significant to -be -aligned +least +significant . +So / / +v += +a +[ +15 +: +0 +] +b +[ +31 +: +16 +] +. +let +v += +_mm256_permute2x128_si256 +( +b +a +0x21 +) +; / / +This +effectively +does +this +( +where +we +deal +in +terms +of +byte +- +indexing / / -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -/ +and +byte +- +shifting +and +use +inclusive +ranges +) +: / / / / +ret +[ +15 +: +0 +] +: += +( +( +a +[ +15 +: +0 +] +< +< +16 +) +| +v +[ +15 +: +0 +] +) +> +> +14 / -Callers -must -guarantee -that -at -least -BYTES -bytes -are -readable -from / += +( +( +a +[ +15 +: +0 +] +< +< +16 +) +| +b +[ +31 +: +16 +] +) +> +> +14 / / -data -. -unsafe -fn -load_unaligned +ret +[ +31 +: +16 +] +: += ( -data +( +a +[ +31 : -* -const -u8 +16 +] +< +< +16 +) +| +v +[ +31 +: +16 +] ) -- > -Self -; -/ +> +14 / / -Returns -true -if -and -only -if -this -vector -has -zero -in -all -of -its -lanes -. += +( +( +a +[ +31 +: +16 +] +< +< +16 +) +| +a +[ +15 +: +0 +] +) +> +> +14 / / / / +Which +therefore +results +in +: / / -# -Safety / / +ret +[ +31 +: +0 +] +: += +a +[ +29 +: +16 +] +a +[ +15 +: +14 +] +a +[ +13 +: +0 +] +b +[ +31 +: +30 +] / / / / -Callers -must -ensure +The +end +result +is that +we +' +ve +effectively +done this -is -okay -to -call -in -the -current -target -for +: +/ / / / -the -current -CPU -. -unsafe -fn -is_zero ( -self +a +< +< +2 ) -- +| +( +b > -bool -; -/ -/ +> +30 +) / -Do -an -8 -- -bit -pairwise -equality -check -. -If -lane -i -is -equal -in -this / / / -vector +When +A and +B +are +strings +- +- +- +where the -one -given -then -lane -i -in +beginning +of the -resulting -vector +string is -set -/ +in / / -to -0xFF -. -Otherwise -it -is -set -to -0x00 -. +the +least +significant +bits +- +- +- +we +effectively +result +in +the +following / / +semantic +operation +: / / / / -# -Safety +( +A +> +> +2 +) +| +( +B +< +< +30 +) +/ / / / +The +reversal +being +attributed +to +the +fact +that +we +are +in +little +- +endian +. +_mm256_alignr_epi8 +( +a +v +14 +) +} / / / -Callers -must -ensure -that -this -is -okay +Shift +a to -call -in the -current -target -for +left +by +one +byte +( +removing +its +most +significant +byte +) +and / / / +concatenate +it +with the -current -CPU +the +most +significant +byte +of +b . +# +[ +target_feature +( +enable += +" +avx2 +" +) +] +pub unsafe fn -cmpeq +alignr256_15 ( -self -vector2 +a +: +__m256i +b : -Self +__m256i ) - > -Self -; -/ +__m256i +{ / / -Perform +For +explanation +see +alignr256_14 +. +let +v += +_mm256_permute2x128_si256 +( +b a -bitwise -' -and -' -of -this -vector -and -the -one -given -and -return +0x21 +) +; +_mm256_alignr_epi8 +( +a +v +15 +) +} / / / +Unpack the -result +given +128 +- +bit +vector +into +its +64 +- +bit +components . +The +first / / / -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay +element +of +the +array +returned +corresponds to -call -in the -current -target -for +least +significant +64 +- +bit / / / -the -current -CPU +lane +in +a . +# +[ +target_feature +( +enable += +" +ssse3 +" +) +] +pub unsafe fn -and +unpack64x128 ( -self -vector2 +a : -Self +__m128i ) - > -Self +[ +u64 ; -/ -/ -/ -Perform +2 +] +{ +[ +_mm_cvtsi128_si64 +( a -bitwise -' -or -' -of -this -vector -and -the -one -given -and -return +) +as +u64 +_mm_cvtsi128_si64 +( +_mm_srli_si128 +( +a +8 +) +) +as +u64 +] +} / / / +Unpack the -result +given +256 +- +bit +vector +into +its +64 +- +bit +components . +The +first / / / +element +of +the +array +returned +corresponds +to +the +least +significant +64 +- +bit / / / -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call +lane in -the -current -target -for -/ -/ -/ -the -current -CPU +a . +# +[ +target_feature +( +enable += +" +avx2 +" +) +] +pub unsafe fn -or +unpack64x256 ( -self -vector2 +a : -Self +__m256i ) - > -Self +[ +u64 ; +4 +] +{ / / -/ -Shift -each -8 -- -bit -lane -in -this -vector -to -the -right -by -the -number -of -/ -/ -/ -bits -indictated -by -the -BITS -type -parameter -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this +Using +transmute +here is -okay -to -call -in -the -current -target -for -/ +precisely +equivalent +but +actually +slower +. +It +' +s / / -the -current -CPU +not +quite +clear +why . -unsafe -fn -shift_8bit_lane_right -< -const -BITS -: -i32 -> +let +lo += +_mm256_extracti128_si256 ( -self +a +0 ) -- -> -Self ; +let +hi += +_mm256_extracti128_si256 +( +a +1 +) +; +[ +_mm_cvtsi128_si64 +( +lo +) +as +u64 +_mm_cvtsi128_si64 +( +_mm_srli_si128 +( +lo +8 +) +) +as +u64 +_mm_cvtsi128_si64 +( +hi +) +as +u64 +_mm_cvtsi128_si64 +( +_mm_srli_si128 +( +hi +8 +) +) +as +u64 +] +} / / / -Shift -this -vector -to -the -left -by -one -byte -and -shift -the -most -/ -/ -/ -significant -byte -of -vector2 -into +Unpack the -least -significant -position +low +128 +- +bits of +a +and +b +and +return +them +as +4 +64 +- +bit / / / -this -vector +integers . / / @@ -965,233 +1075,299 @@ vector / / / -Stated -differently -this -behaves -as +More +precisely if -self -and -vector2 -were -/ -/ -/ -concatenated -into a -2 -* -Self -: -: -BITS -temporary -buffer += +a4 +a3 +a2 +a1 and -then -shifted +b += +b4 +b3 +b2 +b1 +where +each +element / / / -right -by -Self -: -: -BYTES +is +a +64 - -1 -bytes -. -/ -/ -/ -/ -/ +bit +integer +and +a1 / -With -respect +b1 +correspond to the -Teddy -algorithm -vector2 -is -usually -a -previous +least +significant +64 +bits / / / -Self -: -: -BYTES -chunk -from +then the -haystack -and -self +return +value is -the -chunk -/ -/ -/ -immediately -following -it +b2 +b1 +a2 +a1 . -This -permits -combining -the -last -two -bytes -/ -/ -/ -from -the -previous -chunk +# +[ +target_feature ( -vector2 +enable += +" +avx2 +" ) -with -the -first -Self +] +pub +unsafe +fn +unpacklo64x256 +( +a : +__m256i +b : -BYTES +__m256i +) - -1 -/ -/ -/ -bytes -from -the -current -chunk -. -This -permits -aligning -the -result -of +> +[ +u64 +; +4 +] +{ +let +lo += +_mm256_castsi256_si128 +( +a +) +; +let +hi += +_mm256_castsi256_si128 +( +b +) +; +[ +_mm_cvtsi128_si64 +( +lo +) +as +u64 +_mm_cvtsi128_si64 +( +_mm_srli_si128 +( +lo +8 +) +) +as +u64 +_mm_cvtsi128_si64 +( +hi +) +as +u64 +_mm_cvtsi128_si64 +( +_mm_srli_si128 +( +hi +8 +) +) +as +u64 +] +} / / / -various -shuffles -so -that -they -can -be +Returns +true +if and +only +if +all +bits +in +the +given +128 - -ed -together -and -a -possible -/ -/ -/ -candidate -discovered +bit +vector +are +0 . -/ -/ -/ -/ -/ -/ # -Safety -/ -/ -/ +[ +target_feature +( +enable += +" +ssse3 +" +) +] +pub +unsafe +fn +is_all_zeroes128 +( +a +: +__m128i +) +- +> +bool +{ +let +cmp += +_mm_cmpeq_epi8 +( +a +zeroes128 +( +) +) +; +_mm_movemask_epi8 +( +cmp +) +as +u32 += += +0xFFFF +} / / / -Callers -must -ensure -that -this -is -okay -to -call +Returns +true +if +and +only +if +all +bits in the -current -target -for -/ -/ -/ -the -current -CPU +given +256 +- +bit +vector +are +0 . +# +[ +target_feature +( +enable += +" +avx2 +" +) +] +pub unsafe fn -shift_in_one_byte +is_all_zeroes256 ( -self -vector2 +a : -Self +__m256i ) - > -Self +bool +{ +let +cmp += +_mm256_cmpeq_epi8 +( +a +zeroes256 +( +) +) ; +_mm256_movemask_epi8 +( +cmp +) +as +u32 += += +0xFFFFFFFF +} / / / -Shift -this +Load +a +128 +- +bit vector -to -the -left -by -two -bytes -and -shift -the -two -most -/ -/ -/ -significant -bytes -of -vector2 -into +from +slice +at the -least -significant +given position -of +. +The +slice +does / / / -this -vector +not +need +to +be +unaligned . / / @@ -1199,149 +1375,168 @@ vector / / / -Stated -differently +Since this -behaves -as -if -self -and -vector2 -were -/ -/ -/ -concatenated -into -a -2 -* -Self -: -: -BITS -temporary -buffer -and -then -shifted +code +assumes +little +- +endian +( +there +is +no +big +- +endian +x86 +) +the / / / -right -by -Self -: -: -BYTES -- -2 bytes +starting +in +slice +[ +at . -/ -/ -/ -/ -/ -/ -With -respect -to +. +] +will +be +at the -Teddy -algorithm -vector2 -is -usually -a -previous +least +significant +bits +of / / / -Self -: -: -BYTES -chunk -from the -haystack -and -self +returned +vector +. +This is +important +for the -chunk +surrounding +code +since +for / / / -immediately -following -it -. -This -permits -combining +example +shifting the -last -two -bytes +resulting +vector +right +is +equivalent +to +logically / / / -from +shifting the -previous -chunk +bytes +in +slice +left +. +# +[ +target_feature ( -vector2 +enable += +" +sse2 +" ) -with -the -first -Self +] +pub +unsafe +fn +loadu128 +( +slice : +& +[ +u8 +] +at : -BYTES +usize +) - -2 +> +__m128i +{ +let +ptr += +slice +. +get_unchecked +( +at +. +. +) +. +as_ptr +( +) +; +_mm_loadu_si128 +( +ptr +as +* +const +u8 +as +* +const +__m128i +) +} / / / -bytes +Load +a +256 +- +bit +vector from +slice +at the -current -chunk +given +position . -This -permits -aligning -the -result -of +The +slice +does / / / -various -shuffles -so -that -they -can +not +need +to be -and -- -ed -together -and -a -possible -/ -/ -/ -candidate -discovered +unaligned . / / @@ -1349,10835 +1544,82 @@ discovered / / / -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that +Since this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -shift_in_two_bytes +code +assumes +little +- +endian ( -self -vector2 -: -Self -) +there +is +no +big - -> -Self -; -/ -/ -/ -Shift -this -vector -to -the -left -by -three -bytes -and -shift +endian +x86 +) the -three -most / / / -significant bytes -of -vector2 -into +starting +in +slice +[ +at +. +. +] +will +be +at the least significant -position +bits of / / / -this +the +returned vector . +This +is +important +for +the +surrounding +code +since +for / -/ -/ -/ -/ -/ -Stated -differently -this -behaves -as -if -self -and -vector2 -were -/ -/ -/ -concatenated -into -a -2 -* -Self -: -: -BITS -temporary -buffer -and -then -shifted -/ -/ -/ -right -by -Self -: -: -BYTES -- -3 -bytes -. -/ -/ -/ -/ -/ -/ -With -respect -to -the -Teddy -algorithm -vector2 -is -usually -a -previous -/ -/ -/ -Self -: -: -BYTES -chunk -from -the -haystack -and -self -is -the -chunk -/ -/ -/ -immediately -following -it -. -This -permits -combining -the -last -three -bytes -/ -/ -/ -from -the -previous -chunk -( -vector2 -) -with -the -first -Self -: -: -BYTES -- -3 -/ -/ -/ -bytes -from -the -current -chunk -. -This -permits -aligning -the -result -of -/ -/ -/ -various -shuffles -so -that -they -can -be -and -- -ed -together -and -a -possible -/ -/ -/ -candidate -discovered -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -shift_in_three_bytes -( -self -vector2 -: -Self -) -- -> -Self -; -/ -/ -/ -Shuffles -the -bytes -in -this -vector -according -to -the -indices -in -each -of -/ -/ -/ -the -corresponding -lanes -in -indices -. -/ -/ -/ -/ -/ -/ -If -i -is -the -index -of -corresponding -lanes -A -is -this -vector -B -is -/ -/ -/ -indices -and -C -is -the -resulting -vector -then -C -= -A -[ -B -[ -i -] -] -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -shuffle_bytes -( -self -indices -: -Self -) -- -> -Self -; -/ -/ -/ -Call -the -provided -function -for -each -64 -- -bit -lane -in -this -vector -. -The -/ -/ -/ -given -function -is -provided -the -lane -index -and -lane -value -as -a -u64 -. -/ -/ -/ -/ -/ -/ -If -f -returns -Some -then -iteration -over -the -lanes -is -stopped -and -the -/ -/ -/ -value -is -returned -. -Otherwise -this -returns -None -. -/ -/ -/ -/ -/ -/ -# -Notes -/ -/ -/ -/ -/ -/ -Conceptually -it -would -be -nice -if -we -could -have -a -/ -/ -/ -unpack64 -( -self -) -- -> -[ -u64 -; -BITS -/ -64 -] -method -but -defining -that -is -/ -/ -/ -tricky -given -Rust -' -s -[ -current -support -for -const -generics -] -[ -support -] -. -/ -/ -/ -And -even -if -we -could -it -would -be -tricky -to -write -generic -code -over -/ -/ -/ -it -. -( -Not -impossible -. -We -could -introduce -another -layer -that -requires -/ -/ -/ -AsRef -< -[ -u64 -] -> -or -something -. -) -/ -/ -/ -/ -/ -/ -[ -support -] -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -rust -/ -issues -/ -60551 -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -for_each_64bit_lane -< -T -> -( -self -f -: -impl -FnMut -( -usize -u64 -) -- -> -Option -< -T -> -) -- -> -Option -< -T -> -; -} -/ -/ -/ -This -trait -extends -the -Vector -trait -with -additional -operations -to -support -/ -/ -/ -Fat -Teddy -. -/ -/ -/ -/ -/ -/ -Fat -Teddy -uses -16 -buckets -instead -of -8 -but -reads -half -as -many -bytes -( -as -/ -/ -/ -the -vector -size -) -instead -of -the -full -size -of -a -vector -per -iteration -. -For -/ -/ -/ -example -when -using -a -256 -- -bit -vector -Slim -Teddy -reads -32 -bytes -at -a -timr -/ -/ -/ -but -Fat -Teddy -reads -16 -bytes -at -a -time -. -/ -/ -/ -/ -/ -/ -Fat -Teddy -is -useful -when -searching -for -a -large -number -of -literals -. -/ -/ -/ -The -extra -number -of -buckets -spreads -the -literals -out -more -and -reduces -/ -/ -/ -verification -time -. -/ -/ -/ -/ -/ -/ -Currently -we -only -implement -this -for -AVX -on -x86_64 -. -It -would -be -nice -to -/ -/ -/ -implement -this -for -SSE -on -x86_64 -and -NEON -on -aarch64 -with -the -latter -two -/ -/ -/ -only -reading -8 -bytes -at -a -time -. -It -' -s -not -clear -how -well -it -would -work -but -/ -/ -/ -there -are -some -tricky -things -to -figure -out -in -terms -of -implementation -. -The -/ -/ -/ -half_shift_in_ -{ -one -two -three -} -_bytes -methods -in -particular -are -probably -/ -/ -/ -the -trickiest -of -the -bunch -. -For -AVX2 -these -are -implemented -by -taking -/ -/ -/ -advantage -of -the -fact -that -_mm256_alignr_epi8 -operates -on -each -128 -- -bit -/ -/ -/ -half -instead -of -the -full -256 -- -bit -vector -. -( -Where -as -_mm_alignr_epi8 -/ -/ -/ -operates -on -the -full -128 -- -bit -vector -and -not -on -each -64 -- -bit -half -. -) -I -didn -' -t -/ -/ -/ -do -a -careful -survey -of -NEON -to -see -if -it -could -easily -support -these -/ -/ -/ -operations -. -pub -( -crate -) -trait -FatVector -: -Vector -{ -type -Half -: -Vector -; -/ -/ -/ -Read -a -half -- -vector -- -size -number -of -bytes -from -the -given -pointer -and -/ -/ -/ -broadcast -it -across -both -halfs -of -a -full -vector -. -The -pointer -does -not -/ -/ -/ -need -to -be -aligned -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -/ -/ -/ -/ -/ -/ -Callers -must -guarantee -that -at -least -Self -: -: -HALF -: -: -BYTES -bytes -are -/ -/ -/ -readable -from -data -. -unsafe -fn -load_half_unaligned -( -data -: -* -const -u8 -) -- -> -Self -; -/ -/ -/ -Like -Vector -: -: -shift_in_one_byte -except -this -is -done -for -each -half -/ -/ -/ -of -the -vector -instead -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -half_shift_in_one_byte -( -self -vector2 -: -Self -) -- -> -Self -; -/ -/ -/ -Like -Vector -: -: -shift_in_two_bytes -except -this -is -done -for -each -half -/ -/ -/ -of -the -vector -instead -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -half_shift_in_two_bytes -( -self -vector2 -: -Self -) -- -> -Self -; -/ -/ -/ -Like -Vector -: -: -shift_in_two_bytes -except -this -is -done -for -each -half -/ -/ -/ -of -the -vector -instead -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -half_shift_in_three_bytes -( -self -vector2 -: -Self -) -- -> -Self -; -/ -/ -/ -Swap -the -128 -- -bit -lanes -in -this -vector -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -swap_halves -( -self -) -- -> -Self -; -/ -/ -/ -Unpack -and -interleave -the -8 -- -bit -lanes -from -the -low -128 -bits -of -each -/ -/ -/ -vector -and -return -the -result -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -interleave_low_8bit_lanes -( -self -vector2 -: -Self -) -- -> -Self -; -/ -/ -/ -Unpack -and -interleave -the -8 -- -bit -lanes -from -the -high -128 -bits -of -each -/ -/ -/ -vector -and -return -the -result -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -interleave_high_8bit_lanes -( -self -vector2 -: -Self -) -- -> -Self -; -/ -/ -/ -Call -the -provided -function -for -each -64 -- -bit -lane -in -the -lower -half -/ -/ -/ -of -this -vector -and -then -in -the -other -vector -. -The -given -function -is -/ -/ -/ -provided -the -lane -index -and -lane -value -as -a -u64 -. -( -The -high -128 -- -bits -/ -/ -/ -of -each -vector -are -ignored -. -) -/ -/ -/ -/ -/ -/ -If -f -returns -Some -then -iteration -over -the -lanes -is -stopped -and -the -/ -/ -/ -value -is -returned -. -Otherwise -this -returns -None -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -this -is -okay -to -call -in -the -current -target -for -/ -/ -/ -the -current -CPU -. -unsafe -fn -for_each_low_64bit_lane -< -T -> -( -self -vector2 -: -Self -f -: -impl -FnMut -( -usize -u64 -) -- -> -Option -< -T -> -) -- -> -Option -< -T -> -; -} -# -[ -cfg -( -all -( -target_arch -= -" -x86_64 -" -target_feature -= -" -sse2 -" -) -) -] -mod -x86_64_ssse3 -{ -use -core -: -: -arch -: -: -x86_64 -: -: -* -; -use -crate -: -: -util -: -: -int -: -: -{ -I32 -I64 -I8 -} -; -use -super -: -: -Vector -; -impl -Vector -for -__m128i -{ -const -BITS -: -usize -= -128 -; -const -BYTES -: -usize -= -16 -; -# -[ -inline -( -always -) -] -unsafe -fn -splat -( -byte -: -u8 -) -- -> -__m128i -{ -_mm_set1_epi8 -( -i8 -: -: -from_bits -( -byte -) -) -} -# -[ -inline -( -always -) -] -unsafe -fn -load_unaligned -( -data -: -* -const -u8 -) -- -> -__m128i -{ -_mm_loadu_si128 -( -data -. -cast -: -: -< -__m128i -> -( -) -) -} -# -[ -inline -( -always -) -] -unsafe -fn -is_zero -( -self -) -- -> -bool -{ -let -cmp -= -self -. -cmpeq -( -Self -: -: -splat -( -0 -) -) -; -_mm_movemask_epi8 -( -cmp -) -. -to_bits -( -) -= -= -0xFFFF -} -# -[ -inline -( -always -) -] -unsafe -fn -cmpeq -( -self -vector2 -: -Self -) -- -> -__m128i -{ -_mm_cmpeq_epi8 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -and -( -self -vector2 -: -Self -) -- -> -__m128i -{ -_mm_and_si128 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -or -( -self -vector2 -: -Self -) -- -> -__m128i -{ -_mm_or_si128 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_8bit_lane_right -< -const -BITS -: -i32 -> -( -self -) -- -> -Self -{ -/ -/ -Apparently -there -is -no -_mm_srli_epi8 -so -we -emulate -it -by -/ -/ -shifting -16 -- -bit -integers -and -masking -out -the -high -nybble -of -each -/ -/ -8 -- -bit -lane -( -since -that -nybble -will -contain -bits -from -the -low -/ -/ -nybble -of -the -previous -lane -) -. -let -lomask -= -Self -: -: -splat -( -0xF -) -; -_mm_srli_epi16 -( -self -BITS -) -. -and -( -lomask -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_one_byte -( -self -vector2 -: -Self -) -- -> -Self -{ -_mm_alignr_epi8 -( -self -vector2 -15 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_two_bytes -( -self -vector2 -: -Self -) -- -> -Self -{ -_mm_alignr_epi8 -( -self -vector2 -14 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_three_bytes -( -self -vector2 -: -Self -) -- -> -Self -{ -_mm_alignr_epi8 -( -self -vector2 -13 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shuffle_bytes -( -self -indices -: -Self -) -- -> -Self -{ -_mm_shuffle_epi8 -( -self -indices -) -} -# -[ -inline -( -always -) -] -unsafe -fn -for_each_64bit_lane -< -T -> -( -self -mut -f -: -impl -FnMut -( -usize -u64 -) -- -> -Option -< -T -> -) -- -> -Option -< -T -> -{ -let -lane -= -_mm_extract_epi64 -( -self -0 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -0 -lane -) -{ -return -Some -( -t -) -; -} -let -lane -= -_mm_extract_epi64 -( -self -1 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -1 -lane -) -{ -return -Some -( -t -) -; -} -None -} -} -} -# -[ -cfg -( -all -( -target_arch -= -" -x86_64 -" -target_feature -= -" -sse2 -" -) -) -] -mod -x86_64_avx2 -{ -use -core -: -: -arch -: -: -x86_64 -: -: -* -; -use -crate -: -: -util -: -: -int -: -: -{ -I32 -I64 -I8 -} -; -use -super -: -: -{ -FatVector -Vector -} -; -impl -Vector -for -__m256i -{ -const -BITS -: -usize -= -256 -; -const -BYTES -: -usize -= -32 -; -# -[ -inline -( -always -) -] -unsafe -fn -splat -( -byte -: -u8 -) -- -> -__m256i -{ -_mm256_set1_epi8 -( -i8 -: -: -from_bits -( -byte -) -) -} -# -[ -inline -( -always -) -] -unsafe -fn -load_unaligned -( -data -: -* -const -u8 -) -- -> -__m256i -{ -_mm256_loadu_si256 -( -data -. -cast -: -: -< -__m256i -> -( -) -) -} -# -[ -inline -( -always -) -] -unsafe -fn -is_zero -( -self -) -- -> -bool -{ -let -cmp -= -self -. -cmpeq -( -Self -: -: -splat -( -0 -) -) -; -_mm256_movemask_epi8 -( -cmp -) -. -to_bits -( -) -= -= -0xFFFFFFFF -} -# -[ -inline -( -always -) -] -unsafe -fn -cmpeq -( -self -vector2 -: -Self -) -- -> -__m256i -{ -_mm256_cmpeq_epi8 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -and -( -self -vector2 -: -Self -) -- -> -__m256i -{ -_mm256_and_si256 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -or -( -self -vector2 -: -Self -) -- -> -__m256i -{ -_mm256_or_si256 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_8bit_lane_right -< -const -BITS -: -i32 -> -( -self -) -- -> -Self -{ -let -lomask -= -Self -: -: -splat -( -0xF -) -; -_mm256_srli_epi16 -( -self -BITS -) -. -and -( -lomask -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_one_byte -( -self -vector2 -: -Self -) -- -> -Self -{ -/ -/ -Credit -goes -to -jneem -for -figuring -this -out -: -/ -/ -https -: -/ -/ -github -. -com -/ -jneem -/ -teddy -/ -blob -/ -9ab5e899ad6ef6911aecd3cf1033f1abe6e1f66c -/ -src -/ -x86 -/ -teddy_simd -. -rs -# -L145 -- -L184 -/ -/ -/ -/ -TL -; -DR -avx2 -' -s -PALIGNR -instruction -is -actually -just -two -128 -- -bit -/ -/ -PALIGNR -instructions -which -is -not -what -we -want -so -we -need -to -/ -/ -do -some -extra -shuffling -. -let -v -= -_mm256_permute2x128_si256 -( -vector2 -self -0x21 -) -; -_mm256_alignr_epi8 -( -self -v -15 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_two_bytes -( -self -vector2 -: -Self -) -- -> -Self -{ -/ -/ -Credit -goes -to -jneem -for -figuring -this -out -: -/ -/ -https -: -/ -/ -github -. -com -/ -jneem -/ -teddy -/ -blob -/ -9ab5e899ad6ef6911aecd3cf1033f1abe6e1f66c -/ -src -/ -x86 -/ -teddy_simd -. -rs -# -L145 -- -L184 -/ -/ -/ -/ -TL -; -DR -avx2 -' -s -PALIGNR -instruction -is -actually -just -two -128 -- -bit -/ -/ -PALIGNR -instructions -which -is -not -what -we -want -so -we -need -to -/ -/ -do -some -extra -shuffling -. -let -v -= -_mm256_permute2x128_si256 -( -vector2 -self -0x21 -) -; -_mm256_alignr_epi8 -( -self -v -14 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_three_bytes -( -self -vector2 -: -Self -) -- -> -Self -{ -/ -/ -Credit -goes -to -jneem -for -figuring -this -out -: -/ -/ -https -: -/ -/ -github -. -com -/ -jneem -/ -teddy -/ -blob -/ -9ab5e899ad6ef6911aecd3cf1033f1abe6e1f66c -/ -src -/ -x86 -/ -teddy_simd -. -rs -# -L145 -- -L184 -/ -/ -/ -/ -TL -; -DR -avx2 -' -s -PALIGNR -instruction -is -actually -just -two -128 -- -bit -/ -/ -PALIGNR -instructions -which -is -not -what -we -want -so -we -need -to -/ -/ -do -some -extra -shuffling -. -let -v -= -_mm256_permute2x128_si256 -( -vector2 -self -0x21 -) -; -_mm256_alignr_epi8 -( -self -v -13 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shuffle_bytes -( -self -indices -: -Self -) -- -> -Self -{ -_mm256_shuffle_epi8 -( -self -indices -) -} -# -[ -inline -( -always -) -] -unsafe -fn -for_each_64bit_lane -< -T -> -( -self -mut -f -: -impl -FnMut -( -usize -u64 -) -- -> -Option -< -T -> -) -- -> -Option -< -T -> -{ -/ -/ -NOTE -: -At -one -point -in -the -past -I -used -transmute -to -this -to -/ -/ -get -a -[ -u64 -; -4 -] -but -it -turned -out -to -lead -to -worse -codegen -IIRC -. -/ -/ -I -' -ve -tried -it -more -recently -and -it -looks -like -that -' -s -no -longer -/ -/ -the -case -. -But -since -there -' -s -no -difference -we -stick -with -the -/ -/ -slightly -more -complicated -but -transmute -- -free -version -. -let -lane -= -_mm256_extract_epi64 -( -self -0 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -0 -lane -) -{ -return -Some -( -t -) -; -} -let -lane -= -_mm256_extract_epi64 -( -self -1 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -1 -lane -) -{ -return -Some -( -t -) -; -} -let -lane -= -_mm256_extract_epi64 -( -self -2 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -2 -lane -) -{ -return -Some -( -t -) -; -} -let -lane -= -_mm256_extract_epi64 -( -self -3 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -3 -lane -) -{ -return -Some -( -t -) -; -} -None -} -} -impl -FatVector -for -__m256i -{ -type -Half -= -__m128i -; -# -[ -inline -( -always -) -] -unsafe -fn -load_half_unaligned -( -data -: -* -const -u8 -) -- -> -Self -{ -let -half -= -Self -: -: -Half -: -: -load_unaligned -( -data -) -; -_mm256_broadcastsi128_si256 -( -half -) -} -# -[ -inline -( -always -) -] -unsafe -fn -half_shift_in_one_byte -( -self -vector2 -: -Self -) -- -> -Self -{ -_mm256_alignr_epi8 -( -self -vector2 -15 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -half_shift_in_two_bytes -( -self -vector2 -: -Self -) -- -> -Self -{ -_mm256_alignr_epi8 -( -self -vector2 -14 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -half_shift_in_three_bytes -( -self -vector2 -: -Self -) -- -> -Self -{ -_mm256_alignr_epi8 -( -self -vector2 -13 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -swap_halves -( -self -) -- -> -Self -{ -_mm256_permute4x64_epi64 -( -self -0x4E -) -} -# -[ -inline -( -always -) -] -unsafe -fn -interleave_low_8bit_lanes -( -self -vector2 -: -Self -) -- -> -Self -{ -_mm256_unpacklo_epi8 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -interleave_high_8bit_lanes -( -self -vector2 -: -Self -) -- -> -Self -{ -_mm256_unpackhi_epi8 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -for_each_low_64bit_lane -< -T -> -( -self -vector2 -: -Self -mut -f -: -impl -FnMut -( -usize -u64 -) -- -> -Option -< -T -> -) -- -> -Option -< -T -> -{ -let -lane -= -_mm256_extract_epi64 -( -self -0 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -0 -lane -) -{ -return -Some -( -t -) -; -} -let -lane -= -_mm256_extract_epi64 -( -self -1 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -1 -lane -) -{ -return -Some -( -t -) -; -} -let -lane -= -_mm256_extract_epi64 -( -vector2 -0 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -2 -lane -) -{ -return -Some -( -t -) -; -} -let -lane -= -_mm256_extract_epi64 -( -vector2 -1 -) -. -to_bits -( -) -; -if -let -Some -( -t -) -= -f -( -3 -lane -) -{ -return -Some -( -t -) -; -} -None -} -} -} -# -[ -cfg -( -target_arch -= -" -aarch64 -" -) -] -mod -aarch64_neon -{ -use -core -: -: -arch -: -: -aarch64 -: -: -* -; -use -super -: -: -Vector -; -impl -Vector -for -uint8x16_t -{ -const -BITS -: -usize -= -128 -; -const -BYTES -: -usize -= -16 -; -# -[ -inline -( -always -) -] -unsafe -fn -splat -( -byte -: -u8 -) -- -> -uint8x16_t -{ -vdupq_n_u8 -( -byte -) -} -# -[ -inline -( -always -) -] -unsafe -fn -load_unaligned -( -data -: -* -const -u8 -) -- -> -uint8x16_t -{ -vld1q_u8 -( -data -) -} -# -[ -inline -( -always -) -] -unsafe -fn -is_zero -( -self -) -- -> -bool -{ -/ -/ -Could -also -use -vmaxvq_u8 -. -/ -/ -. -. -. -I -tried -that -and -couldn -' -t -observe -any -meaningful -difference -/ -/ -in -benchmarks -. -let -maxes -= -vreinterpretq_u64_u8 -( -vpmaxq_u8 -( -self -self -) -) -; -vgetq_lane_u64 -( -maxes -0 -) -= -= -0 -} -# -[ -inline -( -always -) -] -unsafe -fn -cmpeq -( -self -vector2 -: -Self -) -- -> -uint8x16_t -{ -vceqq_u8 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -and -( -self -vector2 -: -Self -) -- -> -uint8x16_t -{ -vandq_u8 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -or -( -self -vector2 -: -Self -) -- -> -uint8x16_t -{ -vorrq_u8 -( -self -vector2 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_8bit_lane_right -< -const -BITS -: -i32 -> -( -self -) -- -> -Self -{ -debug_assert -! -( -BITS -< -= -7 -) -; -vshrq_n_u8 -( -self -BITS -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_one_byte -( -self -vector2 -: -Self -) -- -> -Self -{ -vextq_u8 -( -vector2 -self -15 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_two_bytes -( -self -vector2 -: -Self -) -- -> -Self -{ -vextq_u8 -( -vector2 -self -14 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shift_in_three_bytes -( -self -vector2 -: -Self -) -- -> -Self -{ -vextq_u8 -( -vector2 -self -13 -) -} -# -[ -inline -( -always -) -] -unsafe -fn -shuffle_bytes -( -self -indices -: -Self -) -- -> -Self -{ -vqtbl1q_u8 -( -self -indices -) -} -# -[ -inline -( -always -) -] -unsafe -fn -for_each_64bit_lane -< -T -> -( -self -mut -f -: -impl -FnMut -( -usize -u64 -) -- -> -Option -< -T -> -) -- -> -Option -< -T -> -{ -let -this -= -vreinterpretq_u64_u8 -( -self -) -; -let -lane -= -vgetq_lane_u64 -( -this -0 -) -; -if -let -Some -( -t -) -= -f -( -0 -lane -) -{ -return -Some -( -t -) -; -} -let -lane -= -vgetq_lane_u64 -( -this -1 -) -; -if -let -Some -( -t -) -= -f -( -1 -lane -) -{ -return -Some -( -t -) -; -} -None -} -} -} -# -[ -cfg -( -all -( -test -target_arch -= -" -x86_64 -" -target_feature -= -" -sse2 -" -) -) -] -mod -tests_x86_64_ssse3 -{ -use -core -: -: -arch -: -: -x86_64 -: -: -* -; -use -crate -: -: -util -: -: -int -: -: -{ -I32 -U32 -} -; -use -super -: -: -* -; -fn -is_runnable -( -) -- -> -bool -{ -std -: -: -is_x86_feature_detected -! -( -" -ssse3 -" -) -} -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -load -( -lanes -: -[ -u8 -; -16 -] -) -- -> -__m128i -{ -__m128i -: -: -load_unaligned -( -& -lanes -as -* -const -u8 -) -} -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -unload -( -v -: -__m128i -) -- -> -[ -u8 -; -16 -] -{ -[ -_mm_extract_epi8 -( -v -0 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -1 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -2 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -3 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -4 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -5 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -6 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -7 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -8 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -9 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -10 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -11 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -12 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -13 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -14 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm_extract_epi8 -( -v -15 -) -. -to_bits -( -) -. -low_u8 -( -) -] -} -# -[ -test -] -fn -vector_splat -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -__m128i -: -: -splat -( -0xAF -) -; -assert_eq -! -( -unload -( -v -) -[ -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_is_zero -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert -! -( -! -v -. -is_zero -( -) -) -; -let -v -= -load -( -[ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert -! -( -v -. -is_zero -( -) -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_cmpeq -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -1 -] -) -; -let -v2 -= -load -( -[ -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 -] -) -; -assert_eq -! -( -unload -( -v1 -. -cmpeq -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0xFF -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_and -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -0 -0 -0 -0 -0 -0b1001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -let -v2 -= -load -( -[ -0 -0 -0 -0 -0 -0b1010 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v1 -. -and -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0b1000 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_or -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -0 -0 -0 -0 -0 -0b1001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -let -v2 -= -load -( -[ -0 -0 -0 -0 -0 -0b1010 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v1 -. -or -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0b1011 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_8bit_lane_right -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0b1011 -0b0101 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v -. -shift_8bit_lane_right -: -: -< -2 -> -( -) -) -[ -0 -0 -0 -0 -0b0010 -0b0001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_one_byte -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_one_byte -( -v2 -) -) -[ -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_two_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_two_bytes -( -v2 -) -) -[ -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_three_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_three_bytes -( -v2 -) -) -[ -30 -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shuffle_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load -( -[ -0 -0 -0 -0 -4 -4 -4 -4 -8 -8 -8 -8 -12 -12 -12 -12 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shuffle_bytes -( -v2 -) -) -[ -1 -1 -1 -1 -5 -5 -5 -5 -9 -9 -9 -9 -13 -13 -13 -13 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_for_each_64bit_lane -( -) -{ -# -[ -target_feature -( -enable -= -" -ssse3 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -0x01 -0x02 -0x03 -0x04 -0x05 -0x06 -0x07 -0x08 -0x09 -0x0A -0x0B -0x0C -0x0D -0x0E -0x0F -0x10 -] -) -; -let -mut -lanes -= -[ -0u64 -; -2 -] -; -v -. -for_each_64bit_lane -( -| -i -lane -| -{ -lanes -[ -i -] -= -lane -; -None -: -: -< -( -) -> -} -) -; -assert_eq -! -( -lanes -[ -0x0807060504030201 -0x100F0E0D0C0B0A09 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -} -# -[ -cfg -( -all -( -test -target_arch -= -" -x86_64 -" -target_feature -= -" -sse2 -" -) -) -] -mod -tests_x86_64_avx2 -{ -use -core -: -: -arch -: -: -x86_64 -: -: -* -; -use -crate -: -: -util -: -: -int -: -: -{ -I32 -U32 -} -; -use -super -: -: -* -; -fn -is_runnable -( -) -- -> -bool -{ -std -: -: -is_x86_feature_detected -! -( -" -avx2 -" -) -} -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -load -( -lanes -: -[ -u8 -; -32 -] -) -- -> -__m256i -{ -__m256i -: -: -load_unaligned -( -& -lanes -as -* -const -u8 -) -} -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -load_half -( -lanes -: -[ -u8 -; -16 -] -) -- -> -__m256i -{ -__m256i -: -: -load_half_unaligned -( -& -lanes -as -* -const -u8 -) -} -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -unload -( -v -: -__m256i -) -- -> -[ -u8 -; -32 -] -{ -[ -_mm256_extract_epi8 -( -v -0 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -1 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -2 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -3 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -4 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -5 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -6 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -7 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -8 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -9 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -10 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -11 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -12 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -13 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -14 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -15 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -16 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -17 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -18 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -19 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -20 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -21 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -22 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -23 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -24 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -25 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -26 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -27 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -28 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -29 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -30 -) -. -to_bits -( -) -. -low_u8 -( -) -_mm256_extract_epi8 -( -v -31 -) -. -to_bits -( -) -. -low_u8 -( -) -] -} -# -[ -test -] -fn -vector_splat -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -__m256i -: -: -splat -( -0xAF -) -; -assert_eq -! -( -unload -( -v -) -[ -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_is_zero -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert -! -( -! -v -. -is_zero -( -) -) -; -let -v -= -load -( -[ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert -! -( -v -. -is_zero -( -) -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_cmpeq -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -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 -27 -28 -29 -30 -31 -1 -] -) -; -let -v2 -= -load -( -[ -32 -31 -30 -29 -28 -27 -26 -25 -24 -23 -22 -21 -20 -19 -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 -] -) -; -assert_eq -! -( -unload -( -v1 -. -cmpeq -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0xFF -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_and -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -0 -0 -0 -0 -0 -0b1001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -let -v2 -= -load -( -[ -0 -0 -0 -0 -0 -0b1010 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v1 -. -and -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0b1000 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_or -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -0 -0 -0 -0 -0 -0b1001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -let -v2 -= -load -( -[ -0 -0 -0 -0 -0 -0b1010 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v1 -. -or -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0b1011 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_8bit_lane_right -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0b1011 -0b0101 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v -. -shift_8bit_lane_right -: -: -< -2 -> -( -) -) -[ -0 -0 -0 -0 -0b0010 -0b0001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_one_byte -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -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 -27 -28 -29 -30 -31 -32 -] -) -; -let -v2 -= -load -( -[ -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_one_byte -( -v2 -) -) -[ -64 -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 -27 -28 -29 -30 -31 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_two_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -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 -27 -28 -29 -30 -31 -32 -] -) -; -let -v2 -= -load -( -[ -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_two_bytes -( -v2 -) -) -[ -63 -64 -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 -27 -28 -29 -30 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_three_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -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 -27 -28 -29 -30 -31 -32 -] -) -; -let -v2 -= -load -( -[ -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_three_bytes -( -v2 -) -) -[ -62 -63 -64 -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 -27 -28 -29 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shuffle_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -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 -27 -28 -29 -30 -31 -32 -] -) -; -let -v2 -= -load -( -[ -0 -0 -0 -0 -4 -4 -4 -4 -8 -8 -8 -8 -12 -12 -12 -12 -16 -16 -16 -16 -20 -20 -20 -20 -24 -24 -24 -24 -28 -28 -28 -28 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shuffle_bytes -( -v2 -) -) -[ -1 -1 -1 -1 -5 -5 -5 -5 -9 -9 -9 -9 -13 -13 -13 -13 -17 -17 -17 -17 -21 -21 -21 -21 -25 -25 -25 -25 -29 -29 -29 -29 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_for_each_64bit_lane -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -0x01 -0x02 -0x03 -0x04 -0x05 -0x06 -0x07 -0x08 -0x09 -0x0A -0x0B -0x0C -0x0D -0x0E -0x0F -0x10 -0x11 -0x12 -0x13 -0x14 -0x15 -0x16 -0x17 -0x18 -0x19 -0x1A -0x1B -0x1C -0x1D -0x1E -0x1F -0x20 -] -) -; -let -mut -lanes -= -[ -0u64 -; -4 -] -; -v -. -for_each_64bit_lane -( -| -i -lane -| -{ -lanes -[ -i -] -= -lane -; -None -: -: -< -( -) -> -} -) -; -assert_eq -! -( -lanes -[ -0x0807060504030201 -0x100F0E0D0C0B0A09 -0x1817161514131211 -0x201F1E1D1C1B1A19 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -fat_vector_half_shift_in_one_byte -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load_half -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load_half -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -half_shift_in_one_byte -( -v2 -) -) -[ -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -fat_vector_half_shift_in_two_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load_half -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load_half -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -half_shift_in_two_bytes -( -v2 -) -) -[ -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -fat_vector_half_shift_in_three_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load_half -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load_half -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -half_shift_in_three_bytes -( -v2 -) -) -[ -30 -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -30 -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -fat_vector_swap_halves -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -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 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v -. -swap_halves -( -) -) -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -fat_vector_interleave_low_8bit_lanes -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -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 -27 -28 -29 -30 -31 -32 -] -) -; -let -v2 -= -load -( -[ -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -] -) -; -assert_eq -! -( -unload -( -v1 -. -interleave_low_8bit_lanes -( -v2 -) -) -[ -1 -33 -2 -34 -3 -35 -4 -36 -5 -37 -6 -38 -7 -39 -8 -40 -17 -49 -18 -50 -19 -51 -20 -52 -21 -53 -22 -54 -23 -55 -24 -56 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -fat_vector_interleave_high_8bit_lanes -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -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 -27 -28 -29 -30 -31 -32 -] -) -; -let -v2 -= -load -( -[ -33 -34 -35 -36 -37 -38 -39 -40 -41 -42 -43 -44 -45 -46 -47 -48 -49 -50 -51 -52 -53 -54 -55 -56 -57 -58 -59 -60 -61 -62 -63 -64 -] -) -; -assert_eq -! -( -unload -( -v1 -. -interleave_high_8bit_lanes -( -v2 -) -) -[ -9 -41 -10 -42 -11 -43 -12 -44 -13 -45 -14 -46 -15 -47 -16 -48 -25 -57 -26 -58 -27 -59 -28 -60 -29 -61 -30 -62 -31 -63 -32 -64 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -fat_vector_for_each_low_64bit_lane -( -) -{ -# -[ -target_feature -( -enable -= -" -avx2 -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -0x01 -0x02 -0x03 -0x04 -0x05 -0x06 -0x07 -0x08 -0x09 -0x0A -0x0B -0x0C -0x0D -0x0E -0x0F -0x10 -0x11 -0x12 -0x13 -0x14 -0x15 -0x16 -0x17 -0x18 -0x19 -0x1A -0x1B -0x1C -0x1D -0x1E -0x1F -0x20 -] -) -; -let -v2 -= -load -( -[ -0x21 -0x22 -0x23 -0x24 -0x25 -0x26 -0x27 -0x28 -0x29 -0x2A -0x2B -0x2C -0x2D -0x2E -0x2F -0x30 -0x31 -0x32 -0x33 -0x34 -0x35 -0x36 -0x37 -0x38 -0x39 -0x3A -0x3B -0x3C -0x3D -0x3E -0x3F -0x40 -] -) -; -let -mut -lanes -= -[ -0u64 -; -4 -] -; -v1 -. -for_each_low_64bit_lane -( -v2 -| -i -lane -| -{ -lanes -[ -i -] -= -lane -; -None -: -: -< -( -) -> -} -) -; -assert_eq -! -( -lanes -[ -0x0807060504030201 -0x100F0E0D0C0B0A09 -0x2827262524232221 -0x302F2E2D2C2B2A29 -] -) -; -} -if -! -is_runnable -( -) -{ -return -; -} -unsafe -{ -test -( -) -} -} -} -# -[ -cfg -( -all -( -test -target_arch -= -" -aarch64 -" -target_feature -= -" -neon -" -) -) -] -mod -tests_aarch64_neon -{ -use -core -: -: -arch -: -: -aarch64 -: -: -* -; -use -super -: -: -* -; -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -load -( -lanes -: -[ -u8 -; -16 -] -) -- -> -uint8x16_t -{ -uint8x16_t -: -: -load_unaligned -( -& -lanes -as -* -const -u8 -) -} -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -unload -( -v -: -uint8x16_t -) -- -> -[ -u8 -; -16 -] -{ -[ -vgetq_lane_u8 -( -v -0 -) -vgetq_lane_u8 -( -v -1 -) -vgetq_lane_u8 -( -v -2 -) -vgetq_lane_u8 -( -v -3 -) -vgetq_lane_u8 -( -v -4 -) -vgetq_lane_u8 -( -v -5 -) -vgetq_lane_u8 -( -v -6 -) -vgetq_lane_u8 -( -v -7 -) -vgetq_lane_u8 -( -v -8 -) -vgetq_lane_u8 -( -v -9 -) -vgetq_lane_u8 -( -v -10 -) -vgetq_lane_u8 -( -v -11 -) -vgetq_lane_u8 -( -v -12 -) -vgetq_lane_u8 -( -v -13 -) -vgetq_lane_u8 -( -v -14 -) -vgetq_lane_u8 -( -v -15 -) -] -} -/ -/ -Example -functions -. -These -don -' -t -test -the -Vector -traits -but -rather -/ -/ -specific -NEON -instructions -. -They -are -basically -little -experiments -I -/ -/ -wrote -to -figure -out -what -an -instruction -does -since -their -descriptions -/ -/ -are -so -dense -. -I -decided -to -keep -the -experiments -around -as -example -tests -/ -/ -in -case -there -' -useful -. -# -[ -test -] -fn -example_vmaxvq_u8_non_zero -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -example -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -vmaxvq_u8 -( -v -) -1 -) -; -} -unsafe -{ -example -( -) -} -} -# -[ -test -] -fn -example_vmaxvq_u8_zero -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -example -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -vmaxvq_u8 -( -v -) -0 -) -; -} -unsafe -{ -example -( -) -} -} -# -[ -test -] -fn -example_vpmaxq_u8_non_zero -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -example -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -let -r -= -vpmaxq_u8 -( -v -v -) -; -assert_eq -! -( -unload -( -r -) -[ -0 -0 -1 -0 -0 -0 -0 -0 -0 -0 -1 -0 -0 -0 -0 -0 -] -) -; -} -unsafe -{ -example -( -) -} -} -# -[ -test -] -fn -example_vpmaxq_u8_self -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -example -( -) -{ -let -v -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -r -= -vpmaxq_u8 -( -v -v -) -; -assert_eq -! -( -unload -( -r -) -[ -2 -4 -6 -8 -10 -12 -14 -16 -2 -4 -6 -8 -10 -12 -14 -16 -] -) -; -} -unsafe -{ -example -( -) -} -} -# -[ -test -] -fn -example_vpmaxq_u8_other -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -example -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -let -r -= -vpmaxq_u8 -( -v1 -v2 -) -; -assert_eq -! -( -unload -( -r -) -[ -2 -4 -6 -8 -10 -12 -14 -16 -18 -20 -22 -24 -26 -28 -30 -32 -] -) -; -} -unsafe -{ -example -( -) -} -} -/ -/ -Now -we -test -the -actual -methods -on -the -Vector -trait -. -# -[ -test -] -fn -vector_splat -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -uint8x16_t -: -: -splat -( -0xAF -) -; -assert_eq -! -( -unload -( -v -) -[ -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -0xAF -] -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_is_zero -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0 -1 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert -! -( -! -v -. -is_zero -( -) -) -; -let -v -= -load -( -[ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert -! -( -v -. -is_zero -( -) -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_cmpeq -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -1 -] -) -; -let -v2 -= -load -( -[ -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -1 -] -) -; -assert_eq -! -( -unload -( -v1 -. -cmpeq -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0xFF -] -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_and -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -0 -0 -0 -0 -0 -0b1001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -let -v2 -= -load -( -[ -0 -0 -0 -0 -0 -0b1010 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v1 -. -and -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0b1000 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_or -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -0 -0 -0 -0 -0 -0b1001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -let -v2 -= -load -( -[ -0 -0 -0 -0 -0 -0b1010 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v1 -. -or -( -v2 -) -) -[ -0 -0 -0 -0 -0 -0b1011 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_8bit_lane_right -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v -= -load -( -[ -0 -0 -0 -0 -0b1011 -0b0101 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -assert_eq -! -( -unload -( -v -. -shift_8bit_lane_right -: -: -< -2 -> -( -) -) -[ -0 -0 -0 -0 -0b0010 -0b0001 -0 -0 -0 -0 -0 -0 -0 -0 -0 -0 -] -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_one_byte -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_one_byte -( -v2 -) -) -[ -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -] -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_two_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_two_bytes -( -v2 -) -) -[ -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -] -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shift_in_three_bytes -( -) -{ -# -[ -target_feature -( -enable -= -" -neon -" -) -] -unsafe -fn -test -( -) -{ -let -v1 -= -load -( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] -) -; -let -v2 -= -load -( -[ -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30 -31 -32 -] -) -; -assert_eq -! -( -unload -( -v1 -. -shift_in_three_bytes -( -v2 -) -) -[ -30 -31 -32 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -] -) -; -} -unsafe -{ -test -( -) -} -} -# -[ -test -] -fn -vector_shuffle_bytes -( -) -{ +/ +/ +example +shifting +the +resulting +vector +right +is +equivalent +to +logically +/ +/ +/ +shifting +the +bytes +in +slice +left +. # [ target_feature @@ -12185,115 +1627,158 @@ target_feature enable = " -neon +avx2 " ) ] +pub unsafe fn -test +loadu256 ( +slice +: +& +[ +u8 +] +at +: +usize ) +- +> +__m256i { let -v1 +ptr = -load +slice +. +get_unchecked ( -[ -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -] +at +. +. ) -; -let -v2 -= -load +. +as_ptr ( -[ -0 -0 -0 -0 -4 -4 -4 -4 -8 -8 -8 -8 -12 -12 -12 -12 -] ) ; -assert_eq -! -( -unload +_mm256_loadu_si256 ( -v1 +ptr +as +* +const +u8 +as +* +const +__m256i +) +} +/ +/ +/ +Returns +a +128 +- +bit +vector +with +all +bits +set +to +0 . -shuffle_bytes +# +[ +target_feature ( -v2 -) +enable += +" +sse2 +" ) -[ -1 -1 -1 -1 -5 -5 -5 -5 -9 -9 -9 -9 -13 -13 -13 -13 ] -) -; -} +pub unsafe +fn +zeroes128 +( +) +- +> +__m128i { -test +_mm_set1_epi8 ( +0 ) } -} +/ +/ +/ +Returns +a +256 +- +bit +vector +with +all +bits +set +to +0 +. # [ -test +target_feature +( +enable += +" +avx2 +" +) ] +pub +unsafe fn -vector_for_each_64bit_lane +zeroes256 ( ) +- +> +__m256i { +_mm256_set1_epi8 +( +0 +) +} +/ +/ +/ +Returns +a +128 +- +bit +vector +with +all +bits +set +to +1 +. # [ target_feature @@ -12301,93 +1786,72 @@ target_feature enable = " -neon +sse2 " ) ] +pub unsafe fn -test +ones128 ( ) +- +> +__m128i { -let -v -= -load +_mm_set1_epi8 ( -[ -0x01 -0x02 -0x03 -0x04 -0x05 -0x06 -0x07 -0x08 -0x09 -0x0A -0x0B -0x0C -0x0D -0x0E -0x0F -0x10 -] +0xFF +as +u8 +as +i8 ) -; -let -mut -lanes -= -[ -0u64 -; -2 -] -; -v +} +/ +/ +/ +Returns +a +256 +- +bit +vector +with +all +bits +set +to +1 . -for_each_64bit_lane -( -| -i -lane -| -{ -lanes +# [ -i -] -= -lane -; -None -: -: -< +target_feature ( +enable += +" +avx2 +" ) -> -} -) -; -assert_eq -! -( -lanes -[ -0x0807060504030201 -0x100F0E0D0C0B0A09 ] -) -; -} +pub unsafe +fn +ones256 +( +) +- +> +__m256i { -test +_mm256_set1_epi8 ( +0xFF +as +u8 +as +i8 ) } -} -} diff --git a/third_party/rust/aho-corasick/src/util/prefilter.rs b/third_party/rust/aho-corasick/src/prefilter.rs similarity index 76% rename from third_party/rust/aho-corasick/src/util/prefilter.rs rename to third_party/rust/aho-corasick/src/prefilter.rs index 5fd0b4cd2e89d..d7cc0d9b42518 100644 --- a/third_party/rust/aho-corasick/src/util/prefilter.rs +++ b/third_party/rust/aho-corasick/src/prefilter.rs @@ -1,13 +1,19 @@ use -core +std : : -{ cmp +; +use +std +: +: fmt +; +use +std : : -Debug panic : : @@ -15,147 +21,132 @@ panic RefUnwindSafe UnwindSafe } -u8 -} ; use -alloc -: -: -{ -sync +std : : -Arc -vec -vec +u8 +; +use +memchr : : -Vec +{ +memchr +memchr2 +memchr3 } ; use crate : : -{ -packed -util +ahocorasick : : -{ -alphabet +MatchKind +; +use +crate : : -ByteSet -search +packed +; +use +crate : : -{ Match -MatchKind -Span -} -} -} ; / / / A +candidate +is +the +result +of +running +a prefilter -for -accelerating +on +a +haystack +at a -search -. / / / +particular +position +. +The +result +is +either +no +match +a +confirmed +match +or / / / -This -crate -uses -prefilters -in -the -core -search -implementations -to -accelerate +a +possible +match +. / / / -common -cases -. -They -typically -only -apply -to -cases -where -there -are -a -small / / / -number -of -patterns -( -less -than -100 -or -so -) -but -when -they -do -thoughput -can +When +no +match +is +returned +the +prefilter +is +guaranteeing +that +no +possible / / / +match +can be -boosted -considerably -perhaps -by -an -order -of -magnitude +found +in +the +haystack +and +the +caller +may +trust +this . -When -a -prefilter +That +is / / / -is -active -it -is -used -whenever -a -search -enters -an -automaton -' -s -start -state +all +correct +prefilters +must +never +report +false +negatives . / / @@ -163,98 +154,98 @@ state / / / -Currently -prefilters -cannot -be -constructed -by +In +some +cases +a +prefilter +can +confirm +a +match +very +quickly +in +which +case / / / -callers -. -A -Prefilter -can -only -be -accessed -via the +caller +may +use +this +to +stop +what +it +' +s +doing +and +report +the +match +. +In / / / -[ -Automaton -: -: -prefilter -] -( -crate -: -: -automaton -: -: -Automaton -: -: +this +case prefilter -) +implementations +must +never +report +a +false +positive +. / / / -method -and -used -to -execute -a -search -. In other -words -a +cases +the prefilter can -be +only +report +a +potential +match +in +which / / / -used -to -optimize -your -own -search -implementation -if -necessary -but -cannot -do +case +the +callers +must +attempt +to +confirm +the +match +. +In +this +case +prefilter / / / -much -else -. -If -you -have -a -use -case -for -more -APIs -please -submit -an -issue +implementations +are +permitted +to +return +false +positives . # [ @@ -265,724 +256,650 @@ Debug ) ] pub -struct -Prefilter +enum +Candidate { -finder -: -Arc -< -dyn -PrefilterI -> -memory_usage -: +None +Match +( +Match +) +PossibleStartOfMatch +( usize +) } impl -Prefilter +Candidate { / / / -Execute -a -search -in -the -haystack -within -the -span -given +Convert +this +candidate +into +an +option . -If -a -match -or -/ -/ -/ -a -possible -match -is -returned -then -it +This is -guaranteed -to -occur -within +useful +when +callers / / / -the -bounds -of -the -span +do +not +distinguish +between +true +positives +and +false +positives +( +i +. +e . / / / -/ -/ -/ -If the -span -provided -is -invalid -for +caller +must +always +confirm the -given -haystack -then -behavior +match +in +order +to +update +some +other / / / -is -unspecified +state +) . -# -[ -inline -] pub fn -find_in +into_option ( -& self -haystack -: -& -[ -u8 -] -span -: -Span ) - > -Candidate +Option +< +usize +> { +match self -. -finder -. -find_in +{ +Candidate +: +: +None += +> +None +Candidate +: +: +Match ( -haystack -span +ref +m ) -} -# -[ -inline -] -pub += +> +Some +( +m +. +start ( -crate ) -fn -memory_usage +) +Candidate +: +: +PossibleStartOfMatch ( -& -self +start ) -- += > -usize -{ -self -. -memory_usage +Some +( +start +) +} } } / / / A -candidate -is +prefilter +describes the -result +behavior of -running -a -prefilter -on -a -haystack -at -a -/ -/ -/ -particular -position -. +fast +literal +scanners +for +quickly / / / +skipping +past +bytes +in +the +haystack +that +we +know +cannot +possibly / / / -The -result -is -either -no -match -a -confirmed -match -or +participate +in a -possible match . -/ -/ -/ -/ -/ -/ -When -no -match -is -returned +pub +trait +Prefilter +: +Send ++ +Sync ++ +RefUnwindSafe ++ +UnwindSafe ++ +fmt +: +: +Debug +{ +/ +/ +/ +Returns the -prefilter -is -guaranteeing -that -no +next possible +match +candidate +. +This +may +yield +false / / / +positives +so +callers +must +confirm +a match -can -be -found -in -the -haystack -and +starting +at the -caller -may -trust -this -. -That -is +position / / / -all -correct -prefilters +returned +. +This +however must never -report +produce false negatives . +That +is / / / -/ -/ -/ -In -some -cases -a -prefilter -can -confirm -a +this +must +at +minimum +return +the +starting +position +of +the +next match -very -quickly -in -which -case / / / +in the -caller -may -use -this -to -stop -what -it -' -s -doing -and -report +given +haystack +after +or +at the -match +given +position . -In +fn +next_candidate +( +& +self +state +: +& +mut +PrefilterState +haystack +: +& +[ +u8 +] +at +: +usize +) +- +> +Candidate +; / / / -this -case -prefilter -implementations -must -never -report +A +method +for +cloning a -false -positive -. +prefilter +to +work +- +around +the +fact +that +Clone / / / -In -other -cases -the -prefilter -can -only -report -a -potential -match -in -which +is +not +object +- +safe +. +fn +clone_prefilter +( +& +self +) +- +> +Box +< +dyn +Prefilter +> +; / / / -case -the -callers -must -attempt -to -confirm +Returns the -match -. -In +approximate +total +amount +of +heap +used +by this -case prefilter +in / / / -implementations -are -permitted -to -return -false -positives +units +of +bytes . -# -[ -derive +fn +heap_bytes ( -Clone -Debug +& +self ) -] -pub -enum -Candidate -{ +- +> +usize +; / / / -No -match -was -found -. -Since -false -negatives -are -not -possible +Returns +true +if +and +only +if this -means +prefilter +never +returns +false / / / -the -search -can -quit -as -it -is -guaranteed -not -to -find -another -match +positives . -None +This +is +useful +for +completely +avoiding +the +automaton / / / -A -confirmed -match -was -found -. -Callers -do -not -need -to +when +the +prefilter +can +quickly confirm -it +its +own +matches . -Match -( -Match -) / / / -The -start -of -a -possible -match -was -found -. -Callers -must -confirm +/ +/ +/ +By +default +this +returns +true +which +is +conservative +; it -before +is +always / / / +correct +to +return +true +. +Returning +false +here +and reporting -it -as a -match +false +/ +/ +/ +positive +will +result +in +incorrect +searches . -PossibleStartOfMatch +fn +reports_false_positives ( -usize +& +self ) -} -impl -Candidate +- +> +bool { +true +} / / / -Convert +Returns +true +if +and +only +if this -candidate -into -an -option +prefilter +may +look +for +a +non +- +starting +/ +/ +/ +position +of +a +match . +/ +/ +/ +/ +/ +/ This is useful -when -callers +in +a +streaming +context +where +prefilters +that +don +' +t +look / / / -do -not -distinguish -between -true -positives -and -false -positives -( -i -. -e +for +a +starting +position +of +a +match +can +be +quite +difficult +to +deal +with . / / / -the -caller -must -always -confirm -the -match -) +/ +/ +/ +This +returns +false +by +default . -pub fn -into_option +looks_for_non_start_of_match ( +& self ) - > -Option +bool +{ +false +} +} +impl < -usize +' +a +P +: +Prefilter ++ +? +Sized > +Prefilter +for +& +' +a +P { -match +# +[ +inline +] +fn +next_candidate +( +& self -{ -Candidate -: +state : -None -= -> -None -Candidate +& +mut +PrefilterState +haystack : +& +[ +u8 +] +at : -Match -( -ref -m +usize ) -= +- > -Some +Candidate +{ ( -m +* +* +self +) . -start +next_candidate ( +state +haystack +at ) -) -Candidate -: -: -PossibleStartOfMatch +} +fn +clone_prefilter ( -start +& +self ) -= +- > -Some +Box +< +dyn +Prefilter +> +{ ( -start +* +* +self ) -} -} -} -/ -/ -/ -A -prefilter -describes -the -behavior -of -fast -literal -scanners -for -quickly -/ -/ -/ -skipping -past -bytes -in -the -haystack -that -we -know -cannot -possibly -/ -/ -/ -participate -in -a -match -. -trait -PrefilterI -: -Send -+ -Sync -+ -RefUnwindSafe -+ -UnwindSafe -+ -Debug -+ -' -static -{ -/ -/ -/ -Returns -the -next -possible -match -candidate -. -This -may -yield -false -/ -/ -/ -positives -so -callers -must -confirm -a -match -starting -at -the -position -/ -/ -/ -returned -. -This -however -must -never -produce -false -negatives -. -That -is -/ -/ -/ -this -must -at -minimum -return -the -starting -position -of -the -next -match -/ -/ -/ -in -the -given -haystack -after -or -at -the -given -position . +clone_prefilter +( +) +} fn -find_in +heap_bytes ( & self -haystack -: -& -[ -u8 -] -span -: -Span ) - > -Candidate -; -} -impl -< -P -: -PrefilterI -+ -? -Sized -> -PrefilterI -for -Arc -< -P -> +usize { -# -[ -inline ( -always +* +* +self ) -] +. +heap_bytes +( +) +} fn -find_in +reports_false_positives ( & self -haystack -: -& -[ -u8 -] -span -: -Span ) - > -Candidate +bool { ( * @@ -990,10 +907,8 @@ Candidate self ) . -find_in +reports_false_positives ( -haystack -span ) } } @@ -1001,39 +916,21 @@ span / / A -builder +convenience +object for -constructing -the -best -possible -prefilter -. -When -constructed -/ -/ -/ -this -builder -will -heuristically -select -the -best -prefilter -it -can -build +representing +any +type +that +implements +Prefilter / / / -if -any and -discard -the -rest +is +cloneable . # [ @@ -1043,74 +940,45 @@ Debug ) ] pub -( -crate -) struct -Builder -{ -count -: -usize -ascii_case_insensitive -: -bool -start_bytes -: -StartBytesBuilder -rare_bytes -: -RareBytesBuilder -memmem -: -MemmemBuilder -packed -: -Option +PrefilterObj +( +Box < -packed -: -: -Builder +dyn +Prefilter > -/ -/ -If -we -run -across -a -condition -that -suggests -we -shouldn -' -t -use -a -prefilter -/ -/ -at -all +) +; +impl +Clone +for +PrefilterObj +{ +fn +clone ( -like -an -empty -pattern +& +self ) -then -disable -prefilters -entirely +- +> +Self +{ +PrefilterObj +( +self . -enabled -: -bool +0 +. +clone_prefilter +( +) +) +} } impl -Builder +PrefilterObj { / / @@ -1118,1538 +986,1306 @@ Builder Create a new -builder -for -constructing -the -best -possible prefilter +object . pub -( -crate -) fn new -( -kind +< +T : -MatchKind -) -- +Prefilter ++ +' +static > -Builder -{ -let -pbuilder -= -kind -. -as_packed -( -) -. -map ( -| -kind -| -packed -: -: -Config -: +t : -new -( -) -. -match_kind -( -kind -) -. -builder -( +T ) -) -; -Builder +- +> +PrefilterObj { -count -: -0 -ascii_case_insensitive -: -false -start_bytes -: -StartBytesBuilder -: -: -new +PrefilterObj ( -) -rare_bytes -: -RareBytesBuilder +Box : : new ( +t ) -memmem -: -MemmemBuilder -: -: -default -( ) -packed -: -pbuilder -enabled -: -true } -} -/ -/ -/ -Enable -ASCII -case -insensitivity -. -When -set -byte -strings -added -to -this / / / -builder -will -be -interpreted -without -respect -to -ASCII -case +Return +the +underlying +prefilter +trait +object . pub -( -crate -) fn -ascii_case_insensitive +as_ref ( -mut +& self -yes -: -bool ) - > -Builder +& +dyn +Prefilter { +& +* self . -ascii_case_insensitive -= -yes -; -self -. -start_bytes -= -self -. -start_bytes -. -ascii_case_insensitive -( -yes -) -; -self -. -rare_bytes -= -self -. -rare_bytes -. -ascii_case_insensitive -( -yes -) -; -self +0 +} } / / / -Return +PrefilterState +tracks +state +associated +with +the +effectiveness +of a -prefilter -suitable -for -quickly -finding -potential -matches -. / / / +prefilter +. +It +is +used +to +track +how +many +bytes +on +average +are +skipped +by / / / -All -patterns -added -to -an -Aho -- -Corasick -automaton -should -be -added -to +the +prefilter +. +If this +average +dips +below +a +certain +threshold +over +time / / / -builder -before -attempting -to -construct +then +the +state +renders the prefilter -. -pub -( -crate +inert +and +stops +using +it +. +/ +/ +/ +/ +/ +/ +A +prefilter +state +should +be +created +for +each +search +. +( +Where +creating +an +/ +/ +/ +iterator +via +e +. +g +. +find_iter +is +treated +as +a +single +search +. ) -fn -build +# +[ +derive ( -& -self +Clone +Debug ) -- -> -Option -< -Prefilter -> +] +pub +struct +PrefilterState { -if -! -self +/ +/ +/ +The +number +of +skips +that +has +been +executed . -enabled -{ -debug -! -( -" -prefilter -not -enabled -skipping -" -) -; -return -None -; -} +skips +: +usize / / -If -we -only +/ +The +total +number +of +bytes +that have -one -pattern -then -deferring -to -memmem -is -always +been +skipped +. +skipped +: +usize / / -the -best -choice +/ +The +maximum +length +of +a +match . This is -kind -of +used +to +help +determine +how +many +/ +/ +/ +bytes +on +average +should +be +skipped +in +order +for a -weird -case -because -well -why +prefilter +to +be / / -use -Aho -- -Corasick -if -you -only -have -one -pattern -? -But -maybe -you -don -' -t / +effective +. +max_match_len +: +usize / -know -exactly -how -many -patterns -you -' -ll -get -up -front -and -you -need -to / / -support +Once +this +heuristic +has +been +deemed +permanently +ineffective +it +will +be +/ +/ +/ +inert +throughout the -option +rest of -multiple -patterns +its +lifetime . -So -instead -of -relying -on +This +serves +as +a +cheap +way +/ / / -the -caller to -branch -and -use -memmem -explicitly -we -just -do -it -for +check +inertness +. +inert +: +bool / / -them -. -if -! -self -. -ascii_case_insensitive -{ -if -let -Some -( -pre -) -= -self -. -memmem -. -build +/ +The +last ( +absolute ) -{ -debug -! -( -" -using -memmem +position +at +which +a prefilter -" -) -; -return -Some -( -pre -) -; -} -} -let -( -packed -patlen -minlen -) -= -if -self +scanned +to . -ascii_case_insensitive -{ -( -None -usize -: -: -MAX -0 -) -} -else -{ -let -patlen -= -self -. -packed -. -as_ref -( -) -. -map_or -( -usize -: -: -MAX -| -p -| -p -. -len -( -) -) -; -let -minlen -= -self -. -packed -. -as_ref -( -) -. -map_or -( -0 -| -p -| -p -. -minimum_len -( -) -) -; -let -packed -= -self -. -packed -. -as_ref -( -) -. -and_then -( -| -b -| -b -. -build -( -) -) +/ +/ +/ +Prefilters +can +use +this +position +to +determine +whether +to +re +- +scan +or +/ +/ +/ +not . -map -( -| -s -| -{ -let -memory_usage -= -s +/ +/ +/ +/ +/ +/ +Unlike +other +things +that +impact +effectiveness +this +is +a +fleeting +/ +/ +/ +condition . -memory_usage -( -) -; -debug -! -( -" -built -packed +That +is +a prefilter -( -len -: -{ -} -\ -minimum -pattern -len -: -{ -} -memory -usage -: -{ -} -) -\ -for -consideration -" -patlen -minlen -memory_usage -) -; -Prefilter -{ -finder -: -Arc -: -: -new -( -Packed -( -s -) -) -memory_usage -} -} -) -; -( -packed -patlen -minlen -) -} -; -match -( -self -. -start_bytes -. -build -( -) -self -. -rare_bytes +can +be +considered +ineffective +if +it +is +/ +/ +/ +at +a +position +before +last_scan_at +but +can +become +effective +again +/ +/ +/ +once +the +search +moves +past +last_scan_at . -build -( -) -) -{ / / -If -we -could -build -both -start -and -rare -prefilters -then -there -are / / -a -few -cases -in -which -we -' -d -want +/ +/ +The +utility +of +this +is to -use -the -start -- -byte -prefilter +both +avoid +additional +overhead +from +calling +/ / / -over the -rare -- -byte prefilter -since -the -former -has -lower +and +to +avoid +quadratic +behavior +. +This +ensures +that +a / / -overhead -. -( -prestart -Some -( -_ -) -prerare -Some -( -_ -) -) -= -> -{ -debug -! -( -" -both -start -( -len -= -{ -} -rank -= -{ -} -) -and -\ -rare -( -len -= -{ -} -rank -= -{ -} -) +/ +prefilter +will +scan +any +particular byte -prefilters -\ -are -available -" -self -. -start_bytes -. -count -self -. -start_bytes -. -rank_sum -self -. -rare_bytes -. -count -self -. -rare_bytes -. -rank_sum -) -; -if -patlen -< -= -16 -& -& -minlen -> -= -2 -& -& -self -. -start_bytes -. -count -> -= -3 -& -& -self -. -rare_bytes +at +most +once . -count -> -= -3 -{ -debug -! ( -" -start -and -rare -byte -prefilters -available -but -\ -they -' -re -probably -slower -than -packed -so -using -\ -packed -" -) -; -return -packed -; -} +Note +that +some / / -If +/ +prefilters +like the start - byte prefilter -can -scan +do +not +need +to +use +this +/ +/ +/ +field +at +all +since +it +only +looks for -a -smaller -number +starting +bytes +. +) +last_scan_at +: +usize +} +impl +PrefilterState +{ +/ / / +The +minimum +number of -bytes -than -the -rare -- -byte -prefilter -then -it -' -s -probably +skip +attempts +to +try +before +considering +whether / / -faster +/ +a +prefilter +is +effective +or +not . -let -has_fewer_bytes +const +MIN_SKIPS +: +usize = -self -. -start_bytes -. -count -< -self -. -rare_bytes -. -count +40 ; / / -Otherwise -if -the -combined -frequency -rank +/ +The +minimum +amount of -the -detected +bytes +that +skipping +must +average +expressed +as +a / / -bytes -in +/ +factor +of the -start -- -byte -prefilter -is -" -close -" -to +multiple +of the -combined +length +of +a +possible +match +. / / -frequency -rank -of -the -rare -- -byte -prefilter -then -we -pick / / -the -start -- -byte -prefilter -even -if -the -rare -- -byte -prefilter / / -heuristically -searches -for -rare -bytes -. -This +That is -because +after +MIN_SKIPS +have +occurred +if the +average +number +of +bytes / / -rare +/ +skipped +ever +falls +below +MIN_AVG_FACTOR +* +max - -byte -prefilter -has -higher -constant -costs -so -we -tend -to +match +- +length +then +the +/ / / -prefer -the -start -- -byte prefilter -when -we -can -. -let -has_rarer_bytes -= -self -. -start_bytes +outed +to +be +rendered +inert . -rank_sum -< +const +MIN_AVG_FACTOR +: +usize = -self -. -rare_bytes -. -rank_sum -+ -50 +2 ; -if -has_fewer_bytes -{ -debug -! -( -" -using -start -byte -prefilter -because -it -has -fewer -bytes -to -search -for -than -the -rare -byte +/ +/ +/ +Create +a +fresh prefilter -" +state +. +pub +fn +new +( +max_match_len +: +usize ) -; -prestart -} -else -if -has_rarer_bytes +- +> +PrefilterState { -debug -! -( -" -using -start -byte +PrefilterState +{ +skips +: +0 +skipped +: +0 +max_match_len +inert +: +false +last_scan_at +: +0 +} +} +/ +/ +/ +Create +a prefilter -because -its -byte -\ -frequency -rank -was -determined -to -be -\ -\ -" -good -enough -\ -" -relative -to +state +that +always +disables the -rare -byte prefilter -\ -byte -frequency -rank -" -) -; -prestart -} -else -{ -debug -! +. +pub +fn +disabled ( -" -using -rare -byte -prefilter -" ) -; -prerare +- +> +PrefilterState +{ +PrefilterState +{ +skips +: +0 +skipped +: +0 +max_match_len +: +0 +inert +: +true +last_scan_at +: +0 } } +/ +/ +/ +Update +this +state +with +the +number +of +bytes +skipped +on +the +last +/ +/ +/ +invocation +of +the +prefilter +. +# +[ +inline +] +fn +update_skipped_bytes ( -prestart -Some -( -_ -) -None +& +mut +self +skipped +: +usize ) -= -> { -if -patlen -< -= -16 -& -& -minlen -> -= -2 -& -& self . -start_bytes +skips ++ += +1 +; +self . -count -> +skipped ++ = -3 -{ -debug -! -( -" -start -byte -prefilter -available -but -\ -it -' -s -probably -slower -than -packed -so -using -\ -packed -" -) -; -return -packed +skipped ; } -debug -! -( +/ +/ +/ +Updates +the +position +at +which +the +last +scan +stopped +. +This +may +be +/ +/ +/ +greater +than +the +position +of +the +last +candidate +reported +. +For +example +/ +/ +/ +searching +for +the " -have -start -byte -prefilter -but -not rare +" byte +z +in +abczdef +for +the +pattern +abcz +/ +/ +/ +will +report +a +candidate +at +position +0 +but +the +end +of +its +last +scan +/ +/ +/ +will +be +at +position +3 +. +/ +/ +/ +/ +/ +/ +This +position +factors +into +the +effectiveness +of +this prefilter -\ -so -using -start -byte +. +If +the +/ +/ +/ +current +position +is +less +than +the +last +position +at +which +a +scan +ended +/ +/ +/ +then +the prefilter -" -) -; -prestart -} -( -None -prerare -Some +should +not +be +re +- +run +until +the +search +moves +past +/ +/ +/ +that +position +. +# +[ +inline +] +fn +update_at ( -_ -) +& +mut +self +at +: +usize ) -= -> { if -patlen -< -= -16 -& -& -minlen +at > -= -2 -& -& self . -rare_bytes +last_scan_at +{ +self . -count -> +last_scan_at = -3 -{ -debug -! -( -" -rare -byte -prefilter -available -but -\ -it -' -s -probably -slower -than -packed -so -using -\ -packed -" -) -; -return -packed +at ; } -debug -! -( -" -have -rare -byte -prefilter -but -not -start -byte -prefilter -\ -so -using -rare -byte -prefilter -" -) -; -prerare } -( -None -None -) +/ +/ +/ +Return +true if -self -. -ascii_case_insensitive -= -> -{ -debug -! -( -" -no -start -or -rare -byte -prefilter and -ASCII -case -\ -insensitivity -was -enabled -so -skipping -prefilter -" -) -; -None -} -( -None -None -) -= -> -{ +only if -packed -. -is_some -( -) -{ -debug -! -( -" -falling -back -to -packed -prefilter -" -) -; -} -else -{ -debug -! -( -" -no +this +state +indicates +that +a prefilter -available -" -) -; -} -packed -} -} -} +is / / / -Add -a -literal -string +still +effective +. +/ +/ +/ +/ +/ +/ +The +given +pos +should +correspond to -this -prefilter -builder +the +current +starting +position +of +the +/ +/ +/ +search . +# +[ +inline +] pub -( -crate -) fn -add +is_effective ( & mut self -bytes +at : -& -[ -u8 -] +usize ) +- +> +bool { if -bytes -. -is_empty -( -) -{ self . -enabled -= +inert +{ +return false ; } if -! +at +< self . -enabled +last_scan_at { return +false ; } +if self . -count -+ -= -1 -; -self -. -start_bytes -. -add -( -bytes -) +skips +< +PrefilterState +: +: +MIN_SKIPS +{ +return +true ; +} +let +min_avg += +PrefilterState +: +: +MIN_AVG_FACTOR +* self . -rare_bytes -. -add -( -bytes -) +max_match_len ; +if self . -memmem -. -add -( -bytes -) -; -if -let -Some -( -ref -mut -pbuilder -) +skipped +> = +min_avg +* self . -packed +skips { -pbuilder -. -add -( -bytes -) +return +true ; } +/ +/ +We +' +re +inert +. +self +. +inert += +true +; +false } } / / / A -type -that -wraps -a -packed -searcher -and -implements +builder +for +constructing the -Prefilter +best +possible +prefilter +. +When +constructed / / / -interface +this +builder +will +heuristically +select +the +best +prefilter +it +can +build +/ +/ +/ +if +any +and +discard +the +rest . # [ derive ( -Clone Debug ) ] +pub struct -Packed -( +Builder +{ +count +: +usize +ascii_case_insensitive +: +bool +start_bytes +: +StartBytesBuilder +rare_bytes +: +RareBytesBuilder +packed +: +Option +< packed : : -Searcher -) -; +Builder +> +} impl -PrefilterI -for -Packed +Builder { -fn -find_in -( -& -self -haystack -: -& -[ -u8 -] -span +/ +/ +/ +Create +a +new +builder +for +constructing +the +best +possible +prefilter +. +pub +fn +new +( +kind : -Span +MatchKind ) - > -Candidate +Builder { -self +let +pbuilder += +kind . -0 +as_packed +( +) . -find_in +map +( +| +kind +| +packed +: +: +Config +: +: +new ( -& -haystack -span ) . -map_or +match_kind ( -Candidate +kind +) +. +builder +( +) +) +; +Builder +{ +count : +0 +ascii_case_insensitive : -None -Candidate +false +start_bytes : +StartBytesBuilder : -Match +: +new +( +) +rare_bytes +: +RareBytesBuilder +: +: +new +( ) +packed +: +pbuilder } } / / / -A +Enable +ASCII +case +insensitivity +. +When +set +byte +strings +added +to +this +/ +/ +/ builder -for -constructing -a -prefilter -that -uses -memmem +will +be +interpreted +without +respect +to +ASCII +case . -# -[ -derive +pub +fn +ascii_case_insensitive ( -Debug -Default +mut +self +yes +: +bool ) -] -struct -MemmemBuilder +- +> +Builder { +self +. +ascii_case_insensitive += +yes +; +self +. +start_bytes += +self +. +start_bytes +. +ascii_case_insensitive +( +yes +) +; +self +. +rare_bytes += +self +. +rare_bytes +. +ascii_case_insensitive +( +yes +) +; +self +} / / / -The -number -of +Return +a +prefilter +suitable +for +quickly +finding +potential +matches +. +/ +/ +/ +/ +/ +/ +All patterns -that -have -been added -. -count -: -usize +to +an +Aho +- +Corasick +automaton +should +be +added +to +this / / / -The -singular -pattern +builder +before +attempting to -search -for -. -This -is -only -set -when -count -= -= -1 +construct +the +prefilter . -one -: -Option -< -Vec -< -u8 -> -> -} -impl -MemmemBuilder -{ +pub fn build ( @@ -2660,535 +2296,507 @@ self > Option < -Prefilter +PrefilterObj > { -# -[ -cfg +/ +/ +match ( -all +self +. +start_bytes +. +build ( -feature -= -" -std -" -feature -= -" -perf -- -literal -" -) -) -] -fn -imp -( -builder -: -& -MemmemBuilder ) -- -> -Option -< -Prefilter -> -{ -let -pattern -= -builder +self . -one +rare_bytes . -as_ref +build ( ) -? -; -assert_eq -! -( -1 -builder -. -count ) -; -let -finder -= -Arc -: -: -new -( -Memmem +{ +match ( -memchr -: -: -memmem -: -: -Finder -: -: -new +self +. +start_bytes +. +build ( -pattern ) +self . -into_owned +rare_bytes +. +build ( ) ) -) -; -let -memory_usage -= -pattern +{ +/ +/ +If +we +could +build +both +start +and +rare +prefilters +then +there +are +/ +/ +a +few +cases +in +which +we +' +d +want +to +use +the +start +- +byte +prefilter +/ +/ +over +the +rare +- +byte +prefilter +since +the +former +has +lower +/ +/ +overhead . -len ( -) -; +prestart Some ( -Prefilter -{ -finder -memory_usage -} -) -} -# -[ -cfg -( -not -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -" -) -) +_ ) -] -fn -imp +prerare +Some ( _ -: -& -MemmemBuilder ) -- -> -Option -< -Prefilter +) += > { -None -} -imp -( -self -) -} -fn -add -( -& -mut -self +/ +/ +If +the +start +- +byte +prefilter +can +scan +for +a +smaller +number +/ +/ +of bytes -: -& -[ -u8 -] -) -{ -self +than +the +rare +- +byte +prefilter +then +it +' +s +probably +/ +/ +faster . -count -+ +let +has_fewer_bytes = -1 -; -if self . +start_bytes +. count -= -= -1 -{ +< self . -one -= -Some -( -bytes -. -to_vec -( -) -) -; -} -else -{ -self +rare_bytes . -one -= -None +count ; -} -} -} -/ -/ -/ -A -type -that -wraps -a -SIMD -accelerated -single -substring -search -from -the -/ -/ -/ -memchr -crate -for -use -as -a -prefilter -. -/ -/ / / +Otherwise +if +the +combined +frequency +rank +of +the +detected / / -Currently -this +bytes +in +the +start +- +byte prefilter is -only -active -for -Aho -- -Corasick -searchers -with -/ -/ -/ -a -single -pattern -. -In -theory -this -could -be -extended +" +close +" to -support -searchers -/ +the +combined / / -that -have -a -common -prefix +frequency +rank of -more -than -one -byte -( -for -one +the +rare +- byte +prefilter +then we -would -use -/ +pick / / -memchr -) -but -it -' -s -not -clear +the +start +- +byte +prefilter +even if -it -' -s -worth -it -or -not -. -/ -/ -/ -/ -/ -/ -Also -unfortunately -this -currently -also -requires the -' -std -' -feature -to -/ +rare +- +byte +prefilter / / -be -enabled +heuristically +searches +for +rare +bytes . -That -' -s +This +is because -memchr -doesn -' -t -have -a -no -- -std -- -but -- -with -- -alloc -/ +the / / -mode -and +rare +- +byte +prefilter +has +higher +constant +costs so -APIs -like -Finder -: -: -into_owned -aren -' -t -available -when -' -std -' -is -/ -/ -/ -disabled -. -But -there -should -be -an -' -alloc -' -feature -that -brings -in -APIs -like -/ +we +tend +to / / -Finder -: -: -into_owned -but -doesn -' -t -use -std +prefer +the +start - -only -features -like -runtime -CPU -/ -/ -/ -feature -detection +byte +prefilter +when +we +can . -# -[ -cfg -( -all -( -feature +let +has_rarer_bytes = -" -std -" -feature +self +. +start_bytes +. +rank_sum +< = -" -perf -- -literal -" -) -) -] -# -[ -derive +self +. +rare_bytes +. +rank_sum ++ +50 +; +if +has_fewer_bytes +| +| +has_rarer_bytes +{ +prestart +} +else +{ +prerare +} +} ( -Clone -Debug +prestart +Some +( +_ ) -] -struct -Memmem +None +) += +> +prestart ( -memchr -: +None +prerare +Some +( +_ +) +) += +> +prerare +( +None +None +) +if +self +. +ascii_case_insensitive += +> +None +( +None +None +) += +> +self +. +packed +. +as_ref +( +) +. +and_then +( +| +b +| +b +. +build +( +) +) +. +map +( +| +s +| +PrefilterObj : -memmem : +new +( +Packed +( +s +) +) +) +} +} +/ +/ +/ +Add +a +literal +string +to +this +prefilter +builder +. +pub +fn +add +( +& +mut +self +bytes : -Finder -< -' -static -> +& +[ +u8 +] ) +{ +self +. +count ++ += +1 ; -# -[ -cfg +self +. +start_bytes +. +add ( -all +bytes +) +; +self +. +rare_bytes +. +add ( -feature -= -" -std -" -feature +bytes +) +; +if +let +Some +( +ref +mut +pbuilder +) = -" -perf -- -literal -" +self +. +packed +{ +pbuilder +. +add +( +bytes ) +; +} +} +} +/ +/ +/ +A +type +that +wraps +a +packed +searcher +and +implements +the +Prefilter +/ +/ +/ +interface +. +# +[ +derive +( +Clone +Debug ) ] +struct +Packed +( +packed +: +: +Searcher +) +; impl -PrefilterI +Prefilter for -Memmem +Packed { fn -find_in +next_candidate ( & self +_state +: +& +mut +PrefilterState haystack : & [ u8 ] -span +at : -Span +usize ) - > Candidate { -use -crate -: -: -util -: -: -primitives -: -: -PatternID -; self . 0 . -find +find_at ( -& haystack -[ -span -] +at ) . map_or @@ -3197,115 +2805,67 @@ Candidate : : None -| -i -| +Candidate +: +: +Match +) +} +fn +clone_prefilter +( +& +self +) +- +> +Box +< +dyn +Prefilter +> { -let -start -= -span -. -start -+ -i -; -let -end -= -start -+ +Box +: +: +new +( self . -0 -. -needle +clone ( ) -. -len +) +} +fn +heap_bytes ( +& +self ) -; -/ -/ -N -. -B -. -We -can -declare -a -match -and -use -a -fixed -pattern -ID -here -/ -/ -because -a -Memmem -prefilter -is -only -ever -created -for -searchers -/ -/ -with -exactly -one -pattern +- +> +usize +{ +self . -Thus -every -match -is -always -a -match -/ -/ -and -it -is -always -for -the -first -and -only -pattern +0 . -Candidate -: -: -Match -( -Match -: -: -new +heap_bytes ( -PatternID -: -: -ZERO -start -. -. -end -) ) } +fn +reports_false_positives +( +& +self ) +- +> +bool +{ +false } } / @@ -3602,11 +3162,7 @@ u16 A set of -byte -offsets -keyed -by -byte +bytes . # [ @@ -3617,201 +3173,103 @@ Copy ) ] struct -RareByteOffsets -{ -/ -/ -/ -Each -entry -corresponds -to -the -maximum -offset -of -the -corresponding -/ -/ -/ -byte -across -all -patterns -seen -. -set -: +ByteSet +( [ -RareByteOffset +bool ; 256 ] -} +) +; impl -RareByteOffsets +ByteSet { -/ -/ -/ -Create -a -new -empty -set -of -rare -byte -offsets -. -pub -( -crate -) fn empty ( ) - > -RareByteOffsets -{ -RareByteOffsets +ByteSet { -set -: -[ -RareByteOffset -: -: -default +ByteSet ( -) +[ +false ; 256 ] -} -} -/ -/ -/ -Add -the -given -offset -for -the -given -byte -to -this -set -. -If -the -offset -is -/ -/ -/ -greater -than -the -existing -offset -then -it -overwrites -the -previous -/ -/ -/ -value -and -returns -false -. -If -there -is -no -previous -value -set -then -this -/ -/ -/ -sets -it -and -returns -true -. -pub -( -crate ) +} fn -set +insert ( & mut self -byte +b : u8 -off -: -RareByteOffset ) +- +> +bool { +let +new += +! self . -set -[ -byte -as -usize -] -. -max -= -cmp -: -: -max +contains ( +b +) +; self . -set +0 [ -byte +b as usize ] -. -max -off -. -max -) += +true ; +new +} +fn +contains +( +& +self +b +: +u8 +) +- +> +bool +{ +self +. +0 +[ +b +as +usize +] } } impl -core -: -: fmt : : Debug for -RareByteOffsets +ByteSet { fn fmt @@ -3822,9 +3280,6 @@ f : & mut -core -: -: fmt : : @@ -3836,9 +3291,6 @@ _ ) - > -core -: -: fmt : : @@ -3846,7 +3298,7 @@ Result { let mut -offsets +bytes = vec ! @@ -3854,28 +3306,27 @@ vec ] ; for -off +b in -self +0 . -set . -iter -( -) += +255 { if -off +self . -max -> -0 +contains +( +b +) { -offsets +bytes . push ( -off +b ) ; } @@ -3885,7 +3336,7 @@ f debug_struct ( " -RareByteOffsets +ByteSet " ) . @@ -3895,7 +3346,7 @@ field set " & -offsets +bytes ) . finish @@ -3906,34 +3357,14 @@ finish / / / -Offsets -associated -with -an -occurrence +A +set of -a -" -rare -" byte -in -any -of -the -/ -/ -/ -patterns -used -to -construct -a -single -Aho -- -Corasick -automaton +offsets +keyed +by +byte . # [ @@ -3941,257 +3372,569 @@ derive ( Clone Copy -Debug ) ] struct -RareByteOffset +RareByteOffsets { / / / -The +Each +entry +corresponds +to +the maximum offset -at -which -a -particular -byte -occurs -from +of the -start +corresponding / / / -of -any -pattern -. -This -is -used -as -a -shift -amount +byte +across +all +patterns +seen . -That -is -when -an +set +: +[ +RareByteOffset +; +256 +] +} +impl +RareByteOffsets +{ / / / -occurrence +Create +a +new +empty +set of -this +rare byte -is -found -the -candidate -position -reported -by +offsets +. +pub +fn +empty +( +) +- +> +RareByteOffsets +{ +RareByteOffsets +{ +set +: +[ +RareByteOffset +: +: +default +( +) +; +256 +] +} +} / / / +Add the -prefilter -is -position_of_byte -- -max -such -that +given +offset +for the -automaton -/ -/ -/ -will -begin -its -search -at -a -position -that -is -guaranteed +given +byte to -observe -a -/ -/ -/ -match +this +set . +If +the +offset +is / / / +greater +than +the +existing +offset +then +it +overwrites +the +previous / / / -To -avoid -accidentally -quadratic -behavior -a -prefilter +value +and +returns +false +. +If +there is -considered +no +previous +value +set +then +this / / / -ineffective -when +sets it -is -asked -to -start -scanning -from -a -position -that -it -/ -/ -/ -has -already -scanned -past +and +returns +true . -/ -/ -/ -/ -/ -/ -Using -a +pub +fn +set +( +& +mut +self +byte +: u8 -here -means -that -if -we -ever -see -a -pattern -that -' -s -longer -/ -/ -/ -than -255 -bytes -then -the -entire -rare +off +: +RareByteOffset +) +{ +self +. +set +[ byte -prefilter -is -disabled +as +usize +] . max += +cmp : -u8 +: +max +( +self +. +set +[ +byte +as +usize +] +. +max +off +. +max +) +; +} } impl -Default +fmt +: +: +Debug for -RareByteOffset +RareByteOffsets { fn -default +fmt ( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> ) - > -RareByteOffset +fmt +: +: +Result { -RareByteOffset +let +mut +offsets += +vec +! +[ +] +; +for +off +in +self +. +set +. +iter +( +) { +if +off +. max -: +> 0 +{ +offsets +. +push +( +off +) +; } } +f +. +debug_struct +( +" +RareByteOffsets +" +) +. +field +( +" +set +" +& +offsets +) +. +finish +( +) +} } -impl -RareByteOffset -{ / / / -Create +Offsets +associated +with +an +occurrence +of a -new +" rare +" byte -offset -. -If -the -given -offset -is -too -big -then -/ -/ -/ -None -is -returned -. -In -that -case -callers -should -render +in +any +of the -rare -bytes / / / -prefilter -inert +patterns +used +to +construct +a +single +Aho +- +Corasick +automaton . -fn -new +# +[ +derive ( -max -: -usize +Clone +Copy +Debug ) -- -> -Option -< +] +struct RareByteOffset -> { -if -max -> -u8 -: +/ +/ +/ +The +maximum +offset +at +which +a +particular +byte +occurs +from +the +start +/ +/ +/ +of +any +pattern +. +This +is +used +as +a +shift +amount +. +That +is +when +an +/ +/ +/ +occurrence +of +this +byte +is +found +the +candidate +position +reported +by +/ +/ +/ +the +prefilter +is +position_of_byte +- +max +such +that +the +automaton +/ +/ +/ +will +begin +its +search +at +a +position +that +is +guaranteed +to +observe +a +/ +/ +/ +match +. +/ +/ +/ +/ +/ +/ +To +avoid +accidentally +quadratic +behavior +a +prefilter +is +considered +/ +/ +/ +ineffective +when +it +is +asked +to +start +scanning +from +a +position +that +it +/ +/ +/ +has +already +scanned +past +. +/ +/ +/ +/ +/ +/ +Using +a +u8 +here +means +that +if +we +ever +see +a +pattern +that +' +s +longer +/ +/ +/ +than +255 +bytes +then +the +entire +rare +byte +prefilter +is +disabled +. +max +: +u8 +} +impl +Default +for +RareByteOffset +{ +fn +default +( +) +- +> +RareByteOffset +{ +RareByteOffset +{ +max +: +0 +} +} +} +impl +RareByteOffset +{ +/ +/ +/ +Create +a +new +rare +byte +offset +. +If +the +given +offset +is +too +big +then +/ +/ +/ +None +is +returned +. +In +that +case +callers +should +render +the +rare +bytes +/ +/ +/ +prefilter +inert +. +fn +new +( +max +: +usize +) +- +> +Option +< +RareByteOffset +> +{ +if +max +> +u8 +: : MAX as @@ -4343,9 +4086,8 @@ more than 3 distinct -rare +starting bytes -found or if heuristics @@ -4379,45 +4121,17 @@ self > Option < -Prefilter -> -{ -# -[ -cfg -( -feature -= -" -perf -- -literal -" -) -] -fn -imp -( -builder -: -& -RareBytesBuilder -) -- -> -Option -< -Prefilter +PrefilterObj > { if ! -builder +self . available | | -builder +self . count > @@ -4454,7 +4168,7 @@ in 255 { if -builder +self . rare_set . @@ -4479,27 +4193,19 @@ len ; } } -let -finder -: -Arc -< -dyn -PrefilterI -> -= match len { 0 = > -return None 1 = > -Arc +Some +( +PrefilterObj : : new @@ -4514,7 +4220,7 @@ bytes ] offset : -builder +self . byte_offsets . @@ -4529,10 +4235,13 @@ usize ] } ) +) 2 = > -Arc +Some +( +PrefilterObj : : new @@ -4541,7 +4250,7 @@ RareBytesTwo { offsets : -builder +self . byte_offsets byte1 @@ -4558,10 +4267,13 @@ bytes ] } ) +) 3 = > -Arc +Some +( +PrefilterObj : : new @@ -4570,7 +4282,7 @@ RareBytesThree { offsets : -builder +self . byte_offsets byte1 @@ -4593,6 +4305,7 @@ bytes ] } ) +) _ = > @@ -4601,55 +4314,6 @@ unreachable ( ) } -; -Some -( -Prefilter -{ -finder -memory_usage -: -0 -} -) -} -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -" -) -) -] -fn -imp -( -_ -: -& -RareBytesBuilder -) -- -> -Option -< -Prefilter -> -{ -None -} -imp -( -self -) } / / @@ -5183,27 +4847,17 @@ u8 ) { if -! self . rare_set . -contains +insert ( byte ) { self . -rare_set -. -add -( -byte -) -; -self -. count + = @@ -5241,19 +4895,6 @@ byte . # [ -cfg -( -feature -= -" -perf -- -literal -" -) -] -# -[ derive ( Clone @@ -5270,47 +4911,36 @@ offset : RareByteOffset } -# -[ -cfg -( -feature -= -" -perf -- -literal -" -) -] impl -PrefilterI +Prefilter for RareBytesOne { fn -find_in +next_candidate ( & self +state +: +& +mut +PrefilterState haystack : & [ u8 ] -span +at : -Span +usize ) - > Candidate { memchr -: -: -memchr ( self . @@ -5318,7 +4948,9 @@ byte1 & haystack [ -span +at +. +. ] ) . @@ -5331,51 +4963,441 @@ i let pos = -span -. -start +at + i ; +state +. +last_scan_at += +pos +; cmp : : max ( -span +at +pos +. +saturating_sub +( +self +. +offset +. +max +as +usize +) +) +} +) +. +map_or +( +Candidate +: +: +None +Candidate +: +: +PossibleStartOfMatch +) +} +fn +clone_prefilter +( +& +self +) +- +> +Box +< +dyn +Prefilter +> +{ +Box +: +: +new +( +self +. +clone +( +) +) +} +fn +heap_bytes +( +& +self +) +- +> +usize +{ +0 +} +fn +looks_for_non_start_of_match +( +& +self +) +- +> +bool +{ +/ +/ +TODO +: +It +should +be +possible +to +use +a +rare +byte +prefilter +in +a +/ +/ +streaming +context +. +The +main +problem +is +that +we +usually +assume +that +/ +/ +if +a +prefilter +has +scanned +some +text +and +not +found +anything +then +no +/ +/ +match +* +starts +* +in +that +text . +This +doesn +' +t +matter +in +non +- +streaming +/ +/ +contexts +but +in +a +streaming +context +if +we +' +re +looking +for +a +byte +/ +/ +that +doesn +' +t start -pos +at +the +beginning +of +a +match +and +don +' +t +find +it +/ +/ +then +it +' +s +still +possible +for +a +match +to +start +at +the +end +of +the +/ +/ +current +buffer +content +. +In +order +to +fix +this +the +streaming +searcher +/ +/ +would +need +to +become +aware +of +prefilters +that +do +this +and +use +the +/ +/ +appropriate +offset +in +various +places +. +It +is +quite +a +delicate +change +/ +/ +and +probably +shouldn +' +t +be +attempted +until +streaming +search +has +a +/ +/ +better +testing +strategy +. +In +particular +we +' +d +really +like +to +be +able +/ +/ +to +vary +the +buffer +size +to +force +strange +cases +that +occur +at +the +/ +/ +edge +of +the +buffer +. +If +we +make +the +buffer +size +minimal +then +these +/ +/ +cases +occur +more +frequently +and +easier +. +/ +/ +/ +/ +This +is +also +a +bummer +because +this +means +that +if +the +prefilter +/ +/ +builder +chose +a +rare +byte +prefilter +then +a +streaming +search +won +' +t +/ +/ +use +any +prefilter +at +all +because +the +builder +doesn +' +t +know +how +it +' +s +/ +/ +going +to +be +used . -saturating_sub -( -usize -: -: -from -( -self +Assuming +we +don +' +t +make +streaming +search +aware +of +/ +/ +these +special +types +of +prefilters +as +described +above +we +could +fix +/ +/ +this +by +building +a +" +backup +" +prefilter +that +could +be +used +when +the +/ +/ +rare +byte +prefilter +could +not . -offset +But +that +' +s +a +bandaide . -max -) -) -) -} -) +Sigh . -map_or -( -Candidate -: -: -None -Candidate -: -: -PossibleStartOfMatch -) +true } } / @@ -5394,19 +5416,6 @@ bytes . # [ -cfg -( -feature -= -" -perf -- -literal -" -) -] -# -[ derive ( Clone @@ -5426,46 +5435,35 @@ byte2 : u8 } -# -[ -cfg -( -feature -= -" -perf -- -literal -" -) -] impl -PrefilterI +Prefilter for RareBytesTwo { fn -find_in +next_candidate ( & self +state +: +& +mut +PrefilterState haystack : & [ u8 ] -span +at : -Span +usize ) - > Candidate { -memchr -: -: memchr2 ( self @@ -5477,7 +5475,9 @@ byte2 & haystack [ -span +at +. +. ] ) . @@ -5490,12 +5490,17 @@ i let pos = -span -. -start +at + i ; +state +. +update_at +( +pos +) +; let offset = @@ -5505,16 +5510,12 @@ offsets . set [ -usize -: -: -from -( haystack [ pos ] -) +as +usize ] . max @@ -5524,20 +5525,14 @@ cmp : max ( -span -. -start +at pos . saturating_sub ( -usize -: -: -from -( offset -) +as +usize ) ) } @@ -5555,6 +5550,66 @@ Candidate PossibleStartOfMatch ) } +fn +clone_prefilter +( +& +self +) +- +> +Box +< +dyn +Prefilter +> +{ +Box +: +: +new +( +self +. +clone +( +) +) +} +fn +heap_bytes +( +& +self +) +- +> +usize +{ +0 +} +fn +looks_for_non_start_of_match +( +& +self +) +- +> +bool +{ +/ +/ +TODO +: +See +Prefilter +impl +for +RareBytesOne +. +true +} } / / @@ -5572,19 +5627,6 @@ bytes . # [ -cfg -( -feature -= -" -perf -- -literal -" -) -] -# -[ derive ( Clone @@ -5607,46 +5649,35 @@ byte3 : u8 } -# -[ -cfg -( -feature -= -" -perf -- -literal -" -) -] impl -PrefilterI +Prefilter for RareBytesThree { fn -find_in +next_candidate ( & self +state +: +& +mut +PrefilterState haystack : & [ u8 ] -span +at : -Span +usize ) - > Candidate { -memchr -: -: memchr3 ( self @@ -5661,7 +5692,9 @@ byte3 & haystack [ -span +at +. +. ] ) . @@ -5674,12 +5707,17 @@ i let pos = -span -. -start +at + i ; +state +. +update_at +( +pos +) +; let offset = @@ -5689,16 +5727,12 @@ offsets . set [ -usize -: -: -from -( haystack [ pos ] -) +as +usize ] . max @@ -5708,20 +5742,14 @@ cmp : max ( -span -. -start +at pos . saturating_sub ( -usize -: -: -from -( offset -) +as +usize ) ) } @@ -5739,6 +5767,66 @@ Candidate PossibleStartOfMatch ) } +fn +clone_prefilter +( +& +self +) +- +> +Box +< +dyn +Prefilter +> +{ +Box +: +: +new +( +self +. +clone +( +) +) +} +fn +heap_bytes +( +& +self +) +- +> +usize +{ +0 +} +fn +looks_for_non_start_of_match +( +& +self +) +- +> +bool +{ +/ +/ +TODO +: +See +Prefilter +impl +for +RareBytesOne +. +true +} } / / @@ -6139,39 +6227,11 @@ self > Option < -Prefilter -> -{ -# -[ -cfg -( -feature -= -" -perf -- -literal -" -) -] -fn -imp -( -builder -: -& -StartBytesBuilder -) -- -> -Option -< -Prefilter +PrefilterObj > { if -builder +self . count > @@ -6208,7 +6268,7 @@ in { if ! -builder +self . byteset [ @@ -6328,27 +6388,19 @@ len 1 ; } -let -finder -: -Arc -< -dyn -PrefilterI -> -= match len { 0 = > -return None 1 = > -Arc +Some +( +PrefilterObj : : new @@ -6363,10 +6415,13 @@ bytes ] } ) +) 2 = > -Arc +Some +( +PrefilterObj : : new @@ -6387,10 +6442,13 @@ bytes ] } ) +) 3 = > -Arc +Some +( +PrefilterObj : : new @@ -6417,6 +6475,7 @@ bytes ] } ) +) _ = > @@ -6425,55 +6484,6 @@ unreachable ( ) } -; -Some -( -Prefilter -{ -finder -memory_usage -: -0 -} -) -} -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -" -) -) -] -fn -imp -( -_ -: -& -StartBytesBuilder -) -- -> -Option -< -Prefilter -> -{ -None -} -imp -( -self -) } / / @@ -6628,12 +6638,144 @@ rank_sum = freq_rank ( -byte +byte +) +as +u16 +; +} +} +} +/ +/ +/ +A +prefilter +for +scanning +for +a +single +starting +byte +. +# +[ +derive +( +Clone +Debug +) +] +struct +StartBytesOne +{ +byte1 +: +u8 +} +impl +Prefilter +for +StartBytesOne +{ +fn +next_candidate +( +& +self +_state +: +& +mut +PrefilterState +haystack +: +& +[ +u8 +] +at +: +usize +) +- +> +Candidate +{ +memchr +( +self +. +byte1 +& +haystack +[ +at +. +. +] +) +. +map +( +| +i +| +at ++ +i +) +. +map_or +( +Candidate +: +: +None +Candidate +: +: +PossibleStartOfMatch +) +} +fn +clone_prefilter +( +& +self +) +- +> +Box +< +dyn +Prefilter +> +{ +Box +: +: +new +( +self +. +clone +( +) ) -as -u16 -; } +fn +heap_bytes +( +& +self +) +- +> +usize +{ +0 } } / @@ -6644,26 +6786,12 @@ prefilter for scanning for -a -single +two starting -byte +bytes . # [ -cfg -( -feature -= -" -perf -- -literal -" -) -] -# -[ derive ( Clone @@ -6671,61 +6799,58 @@ Debug ) ] struct -StartBytesOne +StartBytesTwo { byte1 : u8 +byte2 +: +u8 } -# -[ -cfg -( -feature -= -" -perf -- -literal -" -) -] impl -PrefilterI +Prefilter for -StartBytesOne +StartBytesTwo { fn -find_in +next_candidate ( & self +_state +: +& +mut +PrefilterState haystack : & [ u8 ] -span +at : -Span +usize ) - > Candidate { -memchr -: -: -memchr +memchr2 ( self . byte1 +self +. +byte2 & haystack [ -span +at +. +. ] ) . @@ -6734,9 +6859,7 @@ map | i | -span -. -start +at + i ) @@ -6753,6 +6876,44 @@ Candidate PossibleStartOfMatch ) } +fn +clone_prefilter +( +& +self +) +- +> +Box +< +dyn +Prefilter +> +{ +Box +: +: +new +( +self +. +clone +( +) +) +} +fn +heap_bytes +( +& +self +) +- +> +usize +{ +0 +} } / / @@ -6762,25 +6923,12 @@ prefilter for scanning for -two +three starting bytes . # [ -cfg -( -feature -= -" -perf -- -literal -" -) -] -# -[ derive ( Clone @@ -6788,7 +6936,7 @@ Debug ) ] struct -StartBytesTwo +StartBytesThree { byte1 : @@ -6796,48 +6944,40 @@ u8 byte2 : u8 +byte3 +: +u8 } -# -[ -cfg -( -feature -= -" -perf -- -literal -" -) -] impl -PrefilterI +Prefilter for -StartBytesTwo +StartBytesThree { fn -find_in +next_candidate ( & self +_state +: +& +mut +PrefilterState haystack : & [ u8 ] -span +at : -Span +usize ) - > Candidate { -memchr -: -: -memchr2 +memchr3 ( self . @@ -6845,10 +6985,15 @@ byte1 self . byte2 +self +. +byte3 & haystack [ -span +at +. +. ] ) . @@ -6857,9 +7002,7 @@ map | i | -span -. -start +at + i ) @@ -6876,136 +7019,211 @@ Candidate PossibleStartOfMatch ) } -} -/ -/ -/ -A -prefilter -for -scanning -for -three -starting -bytes -. -# -[ -cfg +fn +clone_prefilter ( -feature -= -" -perf +& +self +) - -literal -" +> +Box +< +dyn +Prefilter +> +{ +Box +: +: +new +( +self +. +clone +( ) -] -# -[ -derive +) +} +fn +heap_bytes ( -Clone -Debug +& +self ) -] -struct -StartBytesThree +- +> +usize { -byte1 -: -u8 -byte2 -: -u8 -byte3 -: -u8 +0 } +} +/ +/ +/ +Return +the +next +candidate +reported +by +the +given +prefilter +while +/ +/ +/ +simultaneously +updating +the +given +prestate +. +/ +/ +/ +/ +/ +/ +The +caller +is +responsible +for +checking +the +prestate +before +deciding +whether +/ +/ +/ +to +initiate +a +search +. # [ -cfg -( -feature -= -" -perf -- -literal -" -) +inline ] -impl -PrefilterI -for -StartBytesThree -{ +pub fn -find_in +next +< +P +: +Prefilter +> ( +prestate +: & -self +mut +PrefilterState +prefilter +: +P haystack : & [ u8 ] -span +at : -Span +usize ) - > Candidate { -memchr -: -: -memchr3 -( -self -. -byte1 -self -. -byte2 -self +let +cand += +prefilter . -byte3 -& +next_candidate +( +prestate haystack -[ -span -] +at ) +; +match +cand +{ +Candidate +: +: +None += +> +{ +prestate . -map +update_skipped_bytes ( -| -i -| -span -. -start -+ -i -) +haystack . -map_or +len ( +) +- +at +) +; +} Candidate : : -None +Match +( +ref +m +) += +> +{ +prestate +. +update_skipped_bytes +( +m +. +start +( +) +- +at +) +; +} Candidate : : PossibleStartOfMatch +( +i +) += +> +{ +prestate +. +update_skipped_bytes +( +i +- +at ) +; } } +cand +} / / / @@ -7075,9 +7293,6 @@ is returned . pub -( -crate -) fn opposite_ascii_case ( @@ -7187,9 +7402,6 @@ use crate : : -util -: -: byte_frequencies : : @@ -7202,3 +7414,154 @@ as usize ] } +# +[ +cfg +( +test +) +] +mod +tests +{ +use +super +: +: +* +; +# +[ +test +] +fn +scratch +( +) +{ +let +mut +b += +Builder +: +: +new +( +MatchKind +: +: +LeftmostFirst +) +; +b +. +add +( +b +" +Sherlock +" +) +; +b +. +add +( +b +" +locjaw +" +) +; +/ +/ +b +. +add +( +b +" +Sherlock +" +) +; +/ +/ +b +. +add +( +b +" +Holmes +" +) +; +/ +/ +b +. +add +( +b +" +Watson +" +) +; +/ +/ +b +. +add +( +" +" +. +as_bytes +( +) +) +; +/ +/ +b +. +add +( +" +" +. +as_bytes +( +) +) +; +let +s += +b +. +build +( +) +. +unwrap +( +) +; +println +! +( +" +{ +: +? +} +" +s +) +; +} +} diff --git a/third_party/rust/aho-corasick/src/state_id.rs b/third_party/rust/aho-corasick/src/state_id.rs new file mode 100644 index 0000000000000..440f1204b20c5 --- /dev/null +++ b/third_party/rust/aho-corasick/src/state_id.rs @@ -0,0 +1,1207 @@ +use +std +: +: +fmt +: +: +Debug +; +use +std +: +: +hash +: +: +Hash +; +use +crate +: +: +error +: +: +{ +Error +Result +} +; +/ +/ +NOTE +: +Most +of +this +code +was +copied +from +regex +- +automata +but +without +the +/ +/ +( +de +) +serialization +specific +stuff +. +/ +/ +/ +Check +that +the +premultiplication +of +the +given +state +identifier +can +/ +/ +/ +fit +into +the +representation +indicated +by +S +. +If +it +cannot +or +if +it +/ +/ +/ +overflows +usize +itself +then +an +error +is +returned +. +pub +fn +premultiply_overflow_error +< +S +: +StateID +> +( +last_state +: +S +alphabet_len +: +usize +) +- +> +Result +< +( +) +> +{ +let +requested += +match +last_state +. +to_usize +( +) +. +checked_mul +( +alphabet_len +) +{ +Some +( +requested +) += +> +requested +None += +> +return +Err +( +Error +: +: +premultiply_overflow +( +0 +0 +) +) +} +; +if +requested +> +S +: +: +max_id +( +) +{ +return +Err +( +Error +: +: +premultiply_overflow +( +S +: +: +max_id +( +) +requested +) +) +; +} +Ok +( +( +) +) +} +/ +/ +/ +Convert +the +given +usize +to +the +chosen +state +identifier +/ +/ +/ +representation +. +If +the +given +value +cannot +fit +in +the +chosen +/ +/ +/ +representation +then +an +error +is +returned +. +pub +fn +usize_to_state_id +< +S +: +StateID +> +( +value +: +usize +) +- +> +Result +< +S +> +{ +if +value +> +S +: +: +max_id +( +) +{ +Err +( +Error +: +: +state_id_overflow +( +S +: +: +max_id +( +) +) +) +} +else +{ +Ok +( +S +: +: +from_usize +( +value +) +) +} +} +/ +/ +/ +Return +the +unique +identifier +for +an +automaton +' +s +fail +state +in +the +chosen +/ +/ +/ +representation +indicated +by +S +. +pub +fn +fail_id +< +S +: +StateID +> +( +) +- +> +S +{ +S +: +: +from_usize +( +0 +) +} +/ +/ +/ +Return +the +unique +identifier +for +an +automaton +' +s +fail +state +in +the +chosen +/ +/ +/ +representation +indicated +by +S +. +pub +fn +dead_id +< +S +: +StateID +> +( +) +- +> +S +{ +S +: +: +from_usize +( +1 +) +} +mod +private +{ +/ +/ +/ +Sealed +stops +crates +other +than +aho +- +corasick +from +implementing +any +/ +/ +/ +traits +that +use +it +. +pub +trait +Sealed +{ +} +impl +Sealed +for +u8 +{ +} +impl +Sealed +for +u16 +{ +} +impl +Sealed +for +u32 +{ +} +impl +Sealed +for +u64 +{ +} +impl +Sealed +for +usize +{ +} +} +/ +/ +/ +A +trait +describing +the +representation +of +an +automaton +' +s +state +identifier +. +/ +/ +/ +/ +/ +/ +The +purpose +of +this +trait +is +to +safely +express +both +the +possible +state +/ +/ +/ +identifier +representations +that +can +be +used +in +an +automaton +and +to +convert +/ +/ +/ +between +state +identifier +representations +and +types +that +can +be +used +to +/ +/ +/ +efficiently +index +memory +( +such +as +usize +) +. +/ +/ +/ +/ +/ +/ +In +general +one +should +not +need +to +implement +this +trait +explicitly +. +Indeed +/ +/ +/ +for +now +this +trait +is +sealed +such +that +it +cannot +be +implemented +by +any +/ +/ +/ +other +type +. +In +particular +this +crate +provides +implementations +for +u8 +/ +/ +/ +u16 +u32 +u64 +and +usize +. +( +u32 +and +u64 +are +only +provided +for +/ +/ +/ +targets +that +can +represent +all +corresponding +values +in +a +usize +. +) +pub +trait +StateID +: +private +: +: +Sealed ++ +Clone ++ +Copy ++ +Debug ++ +Eq ++ +Hash ++ +PartialEq ++ +PartialOrd ++ +Ord +{ +/ +/ +/ +Convert +from +a +usize +to +this +implementation +' +s +representation +. +/ +/ +/ +/ +/ +/ +Implementors +may +assume +that +n +< += +Self +: +: +max_id +. +That +is +implementors +/ +/ +/ +do +not +need +to +check +whether +n +can +fit +inside +this +implementation +' +s +/ +/ +/ +representation +. +fn +from_usize +( +n +: +usize +) +- +> +Self +; +/ +/ +/ +Convert +this +implementation +' +s +representation +to +a +usize +. +/ +/ +/ +/ +/ +/ +Implementors +must +not +return +a +usize +value +greater +than +/ +/ +/ +Self +: +: +max_id +and +must +not +permit +overflow +when +converting +between +the +/ +/ +/ +implementor +' +s +representation +and +usize +. +In +general +the +preferred +/ +/ +/ +way +for +implementors +to +achieve +this +is +to +simply +not +provide +/ +/ +/ +implementations +of +StateID +that +cannot +fit +into +the +target +platform +' +s +/ +/ +/ +usize +. +fn +to_usize +( +self +) +- +> +usize +; +/ +/ +/ +Return +the +maximum +state +identifier +supported +by +this +representation +. +/ +/ +/ +/ +/ +/ +Implementors +must +return +a +correct +bound +. +Doing +otherwise +may +result +/ +/ +/ +in +unspecified +behavior +( +but +will +not +violate +memory +safety +) +. +fn +max_id +( +) +- +> +usize +; +} +impl +StateID +for +usize +{ +# +[ +inline +] +fn +from_usize +( +n +: +usize +) +- +> +usize +{ +n +} +# +[ +inline +] +fn +to_usize +( +self +) +- +> +usize +{ +self +} +# +[ +inline +] +fn +max_id +( +) +- +> +usize +{ +: +: +std +: +: +usize +: +: +MAX +} +} +impl +StateID +for +u8 +{ +# +[ +inline +] +fn +from_usize +( +n +: +usize +) +- +> +u8 +{ +n +as +u8 +} +# +[ +inline +] +fn +to_usize +( +self +) +- +> +usize +{ +self +as +usize +} +# +[ +inline +] +fn +max_id +( +) +- +> +usize +{ +: +: +std +: +: +u8 +: +: +MAX +as +usize +} +} +impl +StateID +for +u16 +{ +# +[ +inline +] +fn +from_usize +( +n +: +usize +) +- +> +u16 +{ +n +as +u16 +} +# +[ +inline +] +fn +to_usize +( +self +) +- +> +usize +{ +self +as +usize +} +# +[ +inline +] +fn +max_id +( +) +- +> +usize +{ +: +: +std +: +: +u16 +: +: +MAX +as +usize +} +} +# +[ +cfg +( +any +( +target_pointer_width += +" +32 +" +target_pointer_width += +" +64 +" +) +) +] +impl +StateID +for +u32 +{ +# +[ +inline +] +fn +from_usize +( +n +: +usize +) +- +> +u32 +{ +n +as +u32 +} +# +[ +inline +] +fn +to_usize +( +self +) +- +> +usize +{ +self +as +usize +} +# +[ +inline +] +fn +max_id +( +) +- +> +usize +{ +: +: +std +: +: +u32 +: +: +MAX +as +usize +} +} +# +[ +cfg +( +target_pointer_width += +" +64 +" +) +] +impl +StateID +for +u64 +{ +# +[ +inline +] +fn +from_usize +( +n +: +usize +) +- +> +u64 +{ +n +as +u64 +} +# +[ +inline +] +fn +to_usize +( +self +) +- +> +usize +{ +self +as +usize +} +# +[ +inline +] +fn +max_id +( +) +- +> +usize +{ +: +: +std +: +: +u64 +: +: +MAX +as +usize +} +} diff --git a/third_party/rust/aho-corasick/src/tests.rs b/third_party/rust/aho-corasick/src/tests.rs index 55a7263c7c269..795cbff2b1b2f 100644 --- a/third_party/rust/aho-corasick/src/tests.rs +++ b/third_party/rust/aho-corasick/src/tests.rs @@ -2,35 +2,31 @@ use std : : -{ collections : : HashMap -format -string +; +use +std : : -String -vec +io +; +use +std : : -Vec -} +usize ; use crate : : { -AhoCorasick AhoCorasickBuilder -AhoCorasickKind -Anchored -Input Match MatchKind -StartKind } ; / @@ -413,33 +409,6 @@ REGRESSION ] ; / -* -Iterators -of -anchored -overlapping -searches -were -removed -from -the -API -in -after -0 -. -7 -but -we -leave -the -tests -commented -out -for -posterity -. -/ / / Tests @@ -466,8 +435,6 @@ ANCHORED_BASICS ANCHORED_OVERLAPPING ] ; -* -/ / / / @@ -691,32 +658,6 @@ basic001 & [ " -" -] -" -a -" -& -[ -( -0 -0 -0 -) -( -0 -1 -1 -) -] -) -t -! -( -basic002 -& -[ -" a " ] @@ -1763,34 +1704,6 @@ abasic000 t ! ( -abasic001 -& -[ -] -" -a -" -& -[ -] -) -t -! -( -abasic002 -& -[ -] -" -abc -" -& -[ -] -) -t -! -( abasic010 & [ @@ -1827,11 +1740,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) t @@ -1853,21 +1761,6 @@ abc 0 0 ) -( -0 -1 -1 -) -( -0 -2 -2 -) -( -0 -3 -3 -) ] ) t @@ -1912,11 +1805,6 @@ aa 0 1 ) -( -0 -1 -2 -) ] ) t @@ -1942,11 +1830,6 @@ ab 0 1 ) -( -1 -1 -2 -) ] ) t @@ -1972,11 +1855,6 @@ ba 0 1 ) -( -0 -1 -2 -) ] ) t @@ -2029,34 +1907,6 @@ foo ) ] ) -t -! -( -abasic200 -& -[ -" -foo -" -] -" -foofoo -foo -" -& -[ -( -0 -0 -3 -) -( -0 -3 -6 -) -] -) ] ; / @@ -2627,11 +2477,6 @@ a 0 0 ) -( -1 -1 -1 -) ] ) t @@ -2687,11 +2532,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) t @@ -2716,16 +2556,6 @@ aa 0 0 ) -( -0 -1 -1 -) -( -0 -2 -2 -) ] ) t @@ -2752,11 +2582,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) t @@ -2783,11 +2608,6 @@ a 0 0 ) -( -1 -1 -1 -) ] ) t @@ -2814,11 +2634,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) ] @@ -2942,34 +2757,10 @@ a 0 1 ) -] -) -t -! -( -leftmost011 -& -[ -" -a -" -" -" -] -" -ab -" -& -[ ( -0 -0 1 -) -( 1 -2 -2 +1 ) ] ) @@ -3502,22 +3293,6 @@ abcd ) ] ) -/ -/ -We -shouldn -' -t -allow -an -empty -match -immediately -following -a -match -right -? t ! ( @@ -3563,11 +3338,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) t @@ -3593,11 +3363,6 @@ aa 0 1 ) -( -0 -1 -2 -) ] ) t @@ -3623,11 +3388,6 @@ aa 0 1 ) -( -1 -1 -2 -) ] ) t @@ -3676,61 +3436,30 @@ abce t ! ( -aleftmost301 +aleftmost310 & [ " abcd " " -bcd -" -" -cd +ce " " -b +bc " ] " -abcd +abce " & [ -( -0 -0 -4 -) ] ) t ! ( -aleftmost310 -& -[ -" -abcd -" -" -ce -" -" -bc -" -] -" -abce -" -& -[ -] -) -t -! -( -aleftmost320 +aleftmost320 & [ " @@ -4007,7 +3736,7 @@ abcdefgh " ] " -abcdefghzyz +abcdefghz " & [ @@ -4016,11 +3745,6 @@ abcdefghzyz 0 8 ) -( -0 -8 -9 -) ] ) ] @@ -4188,34 +3912,8 @@ a 0 1 ) -] -) -t -! -( -leftfirst013 -& -[ -" -" -" -" -" -a -" -] -" -a -" -& -[ -( -0 -0 -0 -) ( -0 +1 1 1 ) @@ -4224,53 +3922,31 @@ a t ! ( -leftfirst014 +leftfirst013 & [ " -a " " " -] " a " -& -[ -( -0 -0 -1 -) ] -) -t -! -( -leftfirst015 -& -[ " a " -" -" -] -" -ab -" & [ ( 0 0 -1 +0 ) ( +0 +1 1 -2 -2 ) ] ) @@ -4639,11 +4315,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) t @@ -4670,11 +4341,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) t @@ -4727,11 +4393,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) t @@ -5117,6 +4778,11 @@ a 0 1 ) +( +0 +1 +1 +) ] ) t @@ -5143,6 +4809,11 @@ a 0 1 ) +( +0 +1 +1 +) ] ) t @@ -5169,6 +4840,11 @@ a 0 1 ) +( +1 +1 +1 +) ] ) t @@ -5195,34 +4871,10 @@ a 0 1 ) -] -) -t -! -( -leftlong024 -& -[ -" -" -" -a -" -] -" -ab -" -& -[ ( -1 0 1 -) -( -0 -2 -2 +1 ) ] ) @@ -5253,6 +4905,11 @@ aa 1 2 ) +( +0 +2 +2 +) ] ) t @@ -5762,11 +5419,6 @@ aa 0 1 ) -( -1 -1 -2 -) ] ) t @@ -6413,16 +6065,6 @@ abababa 0 2 ) -( -0 -2 -4 -) -( -0 -4 -6 -) ] ) t @@ -6493,11 +6135,6 @@ a 0 0 ) -( -0 -1 -1 -) ] ) ] @@ -7152,33 +6789,6 @@ foofoo ] ; / -* -Iterators -of -anchored -overlapping -searches -were -removed -from -the -API -in -after -0 -. -7 -but -we -leave -the -tests -commented -out -for -posterity -. -/ / / Like @@ -7645,8 +7255,6 @@ foofoo ) ] ; -* -/ / / / @@ -8449,7 +8057,7 @@ macro_rules testconfig { ( -anchored +overlapping name : ident @@ -8486,10 +8094,10 @@ let mut builder = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) ; @@ -8500,27 +8108,6 @@ mut builder ) ; -let -input -= -Input -: -: -new -( -test -. -haystack -) -. -anchored -( -Anchored -: -: -Yes -) -; builder . match_kind @@ -8538,17 +8125,11 @@ test patterns ) . -unwrap -( -) -. -try_find_iter +find_overlapping_iter ( -input -) +test . -unwrap -( +haystack ) . collect @@ -8561,7 +8142,7 @@ collect } ; ( -overlapping +stream name : ident @@ -8595,13 +8176,34 @@ test | { let +buf += +io +: +: +BufReader +: +: +with_capacity +( +1 +test +. +haystack +. +as_bytes +( +) +) +; +let mut builder = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) ; @@ -8629,134 +8231,17 @@ test patterns ) . -unwrap +stream_find_iter ( +buf ) . -find_overlapping_iter +map ( -test -. -haystack -) -. -collect -( -) -} -) -; -} -} -; -( -stream -name -: -ident -collection -: -expr -kind -: -ident -with -: -expr -) -= -> -{ -# -[ -test -] -fn -name -( -) -{ -run_stream_search_tests -( -collection -| -test -| -{ -let -buf -= -std -: -: -io -: -: -BufReader -: -: -with_capacity -( -1 -test -. -haystack -. -as_bytes -( -) -) -; -let -mut -builder -= -AhoCorasick -: -: -builder -( -) -; -with -( -& -mut -builder -) -; -builder -. -match_kind -( -MatchKind -: -: -kind -) -. -build -( -test -. -patterns -) -. -unwrap -( -) -. -stream_find_iter -( -buf -) -. -map -( -| -result -| -result +| +result +| +result . unwrap ( @@ -8809,10 +8294,10 @@ let mut builder = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) ; @@ -8840,10 +8325,6 @@ test patterns ) . -unwrap -( -) -. find_iter ( test @@ -8891,50 +8372,20 @@ super testconfig ! ( -default -collection -kind -| -_ -| -( -) -) -; -testconfig -! -( nfa_default collection kind | -b -: -& -mut -AhoCorasickBuilder +_ | -{ -b -. -kind -( -Some ( -AhoCorasickKind -: -: -NoncontiguousNFA ) ) ; -} -) -; testconfig ! ( -nfa_noncontig_no_prefilter +nfa_no_prefilter collection kind | @@ -8947,17 +8398,6 @@ AhoCorasickBuilder { b . -kind -( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -) -. prefilter ( false @@ -8969,7 +8409,7 @@ false testconfig ! ( -nfa_noncontig_all_sparse +nfa_all_sparse collection kind | @@ -8982,17 +8422,6 @@ AhoCorasickBuilder { b . -kind -( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -) -. dense_depth ( 0 @@ -9004,7 +8433,7 @@ dense_depth testconfig ! ( -nfa_noncontig_all_dense +nfa_all_dense collection kind | @@ -9017,17 +8446,6 @@ AhoCorasickBuilder { b . -kind -( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -) -. dense_depth ( usize @@ -9042,7 +8460,7 @@ MAX testconfig ! ( -nfa_contig_default +dfa_default collection kind | @@ -9055,15 +8473,9 @@ AhoCorasickBuilder { b . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) ; } @@ -9072,7 +8484,7 @@ ContiguousNFA testconfig ! ( -nfa_contig_no_prefilter +dfa_no_prefilter collection kind | @@ -9085,15 +8497,9 @@ AhoCorasickBuilder { b . -kind +dfa ( -Some -( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) . prefilter @@ -9107,7 +8513,7 @@ false testconfig ! ( -nfa_contig_all_sparse +dfa_all_sparse collection kind | @@ -9120,15 +8526,9 @@ AhoCorasickBuilder { b . -kind +dfa ( -Some -( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) . dense_depth @@ -9142,7 +8542,7 @@ dense_depth testconfig ! ( -nfa_contig_all_dense +dfa_all_dense collection kind | @@ -9155,15 +8555,9 @@ AhoCorasickBuilder { b . -kind +dfa ( -Some -( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) . dense_depth @@ -9180,7 +8574,7 @@ MAX testconfig ! ( -nfa_contig_no_byte_class +dfa_no_byte_class collection kind | @@ -9191,17 +8585,29 @@ mut AhoCorasickBuilder | { -b +/ +/ +TODO +: +remove +tests +when +option +is +removed . -kind -( -Some +# +[ +allow ( -AhoCorasickKind -: -: -ContiguousNFA +deprecated ) +] +b +. +dfa +( +true ) . byte_classes @@ -9215,7 +8621,7 @@ false testconfig ! ( -dfa_default +dfa_no_premultiply collection kind | @@ -9226,17 +8632,34 @@ mut AhoCorasickBuilder | { -b +/ +/ +TODO +: +remove +tests +when +option +is +removed . -kind +# +[ +allow ( -Some +deprecated +) +] +b +. +dfa ( -AhoCorasickKind -: -: -DFA +true ) +. +premultiply +( +false ) ; } @@ -9245,7 +8668,7 @@ DFA testconfig ! ( -dfa_start_both +dfa_no_byte_class_no_premultiply collection kind | @@ -9256,179 +8679,37 @@ mut AhoCorasickBuilder | { -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -start_kind -( -StartKind -: -: -Both -) -; -} -) -; -testconfig -! -( -dfa_no_prefilter -collection -kind -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -prefilter -( -false -) -; -} -) -; -testconfig -! -( -dfa_start_both_no_prefilter -collection -kind -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -start_kind -( -StartKind -: +/ +/ +TODO : -Both -) +remove +tests +when +options +are +removed . -prefilter +# +[ +allow ( -false -) -; -} +deprecated ) -; -testconfig -! -( -dfa_no_byte_class -collection -kind -| -b -: -& -mut -AhoCorasickBuilder -| -{ +] b . -kind +dfa ( -Some -( -AhoCorasickKind -: -: -DFA -) +true ) . byte_classes ( false ) -; -} -) -; -testconfig -! -( -dfa_start_both_no_byte_class -collection -kind -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -start_kind -( -StartKind -: -: -Both -) . -byte_classes +premultiply ( false ) @@ -9445,24 +8726,7 @@ false Write out the -various combinations -of -match -semantics -given -the -variety -of -/ -/ -configurations -tested -by -' -testcombo -! -' . testcombo ! @@ -9509,7 +8773,7 @@ testconfig ! ( overlapping -search_standard_overlapping_default +search_standard_overlapping_nfa_default AC_STANDARD_OVERLAPPING Standard | @@ -9523,7 +8787,7 @@ testconfig ! ( overlapping -search_standard_overlapping_nfa_noncontig_default +search_standard_overlapping_nfa_all_sparse AC_STANDARD_OVERLAPPING Standard | @@ -9536,15 +8800,9 @@ AhoCorasickBuilder { b . -kind -( -Some +dense_depth ( -AhoCorasickKind -: -: -NoncontiguousNFA -) +0 ) ; } @@ -9554,7 +8812,7 @@ testconfig ! ( overlapping -search_standard_overlapping_nfa_noncontig_no_prefilter +search_standard_overlapping_nfa_all_dense AC_STANDARD_OVERLAPPING Standard | @@ -9567,20 +8825,12 @@ AhoCorasickBuilder { b . -kind -( -Some +dense_depth ( -AhoCorasickKind +usize : : -NoncontiguousNFA -) -) -. -prefilter -( -false +MAX ) ; } @@ -9590,7 +8840,7 @@ testconfig ! ( overlapping -search_standard_overlapping_nfa_contig_default +search_standard_overlapping_dfa_default AC_STANDARD_OVERLAPPING Standard | @@ -9603,15 +8853,9 @@ AhoCorasickBuilder { b . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) ; } @@ -9621,7 +8865,7 @@ testconfig ! ( overlapping -search_standard_overlapping_nfa_contig_no_prefilter +search_standard_overlapping_dfa_all_sparse AC_STANDARD_OVERLAPPING Standard | @@ -9634,20 +8878,14 @@ AhoCorasickBuilder { b . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) . -prefilter +dense_depth ( -false +0 ) ; } @@ -9657,7 +8895,7 @@ testconfig ! ( overlapping -search_standard_overlapping_nfa_contig_all_sparse +search_standard_overlapping_dfa_all_dense AC_STANDARD_OVERLAPPING Standard | @@ -9670,20 +8908,17 @@ AhoCorasickBuilder { b . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) . dense_depth ( -0 +usize +: +: +MAX ) ; } @@ -9693,7 +8928,7 @@ testconfig ! ( overlapping -search_standard_overlapping_nfa_contig_all_dense +search_standard_overlapping_dfa_no_byte_class AC_STANDARD_OVERLAPPING Standard | @@ -9704,25 +8939,34 @@ mut AhoCorasickBuilder | { -b +/ +/ +TODO +: +remove +tests +when +option +is +removed . -kind -( -Some +# +[ +allow ( -AhoCorasickKind -: -: -ContiguousNFA +deprecated ) +] +b +. +dfa +( +true ) . -dense_depth +byte_classes ( -usize -: -: -MAX +false ) ; } @@ -9732,7 +8976,7 @@ testconfig ! ( overlapping -search_standard_overlapping_dfa_default +search_standard_overlapping_dfa_no_premultiply AC_STANDARD_OVERLAPPING Standard | @@ -9743,17 +8987,34 @@ mut AhoCorasickBuilder | { -b +/ +/ +TODO +: +remove +tests +when +option +is +removed . -kind +# +[ +allow ( -Some +deprecated +) +] +b +. +dfa ( -AhoCorasickKind -: -: -DFA +true ) +. +premultiply +( +false ) ; } @@ -9763,7 +9024,7 @@ testconfig ! ( overlapping -search_standard_overlapping_dfa_start_both +search_standard_overlapping_dfa_no_byte_class_no_premultiply AC_STANDARD_OVERLAPPING Standard | @@ -9774,183 +9035,37 @@ mut AhoCorasickBuilder | { -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -start_kind -( -StartKind -: -: -Both -) -; -} -) -; -testconfig -! -( -overlapping -search_standard_overlapping_dfa_no_prefilter -AC_STANDARD_OVERLAPPING -Standard -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -prefilter -( -false -) -; -} -) -; -testconfig -! -( -overlapping -search_standard_overlapping_dfa_start_both_no_prefilter -AC_STANDARD_OVERLAPPING -Standard -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -start_kind -( -StartKind -: +/ +/ +TODO : -Both -) +remove +tests +when +options +are +removed . -prefilter +# +[ +allow ( -false -) -; -} +deprecated ) -; -testconfig -! -( -overlapping -search_standard_overlapping_dfa_no_byte_class -AC_STANDARD_OVERLAPPING -Standard -| -b -: -& -mut -AhoCorasickBuilder -| -{ +] b . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -DFA -) +true ) . byte_classes ( false ) -; -} -) -; -testconfig -! -( -overlapping -search_standard_overlapping_dfa_start_both_no_byte_class -AC_STANDARD_OVERLAPPING -Standard -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -start_kind -( -StartKind -: -: -Both -) . -byte_classes +premultiply ( false ) @@ -9999,22 +9114,11 @@ by tests above . -# -[ -cfg -( -feature -= -" -std -" -) -] testconfig ! ( stream -search_standard_stream_default +search_standard_stream_nfa_default AC_STANDARD_NON_OVERLAPPING Standard | @@ -10024,22 +9128,11 @@ _ ) ) ; -# -[ -cfg -( -feature -= -" -std -" -) -] testconfig ! ( stream -search_standard_stream_nfa_noncontig_default +search_standard_stream_dfa_default AC_STANDARD_NON_OVERLAPPING Standard | @@ -10052,37 +9145,32 @@ AhoCorasickBuilder { b . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -NoncontiguousNFA -) +true ) ; } ) ; -# -[ -cfg -( -feature -= -" -std -" -) -] +/ +/ +Same +thing +for +anchored +searches +. +Write +them +out +manually +. testconfig ! ( -stream -search_standard_stream_nfa_contig_default -AC_STANDARD_NON_OVERLAPPING +search_standard_anchored_nfa_default +AC_STANDARD_ANCHORED_NON_OVERLAPPING Standard | b @@ -10094,37 +9182,19 @@ AhoCorasickBuilder { b . -kind -( -Some +anchored ( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) ; } ) ; -# -[ -cfg -( -feature -= -" -std -" -) -] testconfig ! ( -stream -search_standard_stream_dfa_default -AC_STANDARD_NON_OVERLAPPING +search_standard_anchored_dfa_default +AC_STANDARD_ANCHORED_NON_OVERLAPPING Standard | b @@ -10136,39 +9206,25 @@ AhoCorasickBuilder { b . -kind -( -Some +anchored ( -AhoCorasickKind -: -: -DFA +true ) +. +dfa +( +true ) ; } ) ; -/ -/ -Same -thing -for -anchored -searches -. -Write -them -out -manually -. testconfig ! ( -anchored -search_standard_anchored_default -AC_STANDARD_ANCHORED_NON_OVERLAPPING +overlapping +search_standard_anchored_overlapping_nfa_default +AC_STANDARD_ANCHORED_OVERLAPPING Standard | b @@ -10180,12 +9236,9 @@ AhoCorasickBuilder { b . -start_kind +anchored ( -StartKind -: -: -Anchored +true ) ; } @@ -10194,9 +9247,9 @@ Anchored testconfig ! ( -anchored -search_standard_anchored_nfa_noncontig_default -AC_STANDARD_ANCHORED_NON_OVERLAPPING +overlapping +search_standard_anchored_overlapping_dfa_default +AC_STANDARD_ANCHORED_OVERLAPPING Standard | b @@ -10208,23 +9261,14 @@ AhoCorasickBuilder { b . -start_kind +anchored ( -StartKind -: -: -Anchored +true ) . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -NoncontiguousNFA -) +true ) ; } @@ -10233,10 +9277,9 @@ NoncontiguousNFA testconfig ! ( -anchored -search_standard_anchored_nfa_contig_default -AC_STANDARD_ANCHORED_NON_OVERLAPPING -Standard +search_leftmost_first_anchored_nfa_default +AC_LEFTMOST_FIRST_ANCHORED +LeftmostFirst | b : @@ -10247,23 +9290,9 @@ AhoCorasickBuilder { b . -start_kind -( -StartKind -: -: -Anchored -) -. -kind -( -Some +anchored ( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) ; } @@ -10272,10 +9301,9 @@ ContiguousNFA testconfig ! ( -anchored -search_standard_anchored_dfa_default -AC_STANDARD_ANCHORED_NON_OVERLAPPING -Standard +search_leftmost_first_anchored_dfa_default +AC_LEFTMOST_FIRST_ANCHORED +LeftmostFirst | b : @@ -10286,23 +9314,14 @@ AhoCorasickBuilder { b . -start_kind +anchored ( -StartKind -: -: -Anchored +true ) . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -DFA -) +true ) ; } @@ -10311,10 +9330,9 @@ DFA testconfig ! ( -anchored -search_standard_anchored_dfa_start_both -AC_STANDARD_ANCHORED_NON_OVERLAPPING -Standard +search_leftmost_longest_anchored_nfa_default +AC_LEFTMOST_LONGEST_ANCHORED +LeftmostLongest | b : @@ -10325,23 +9343,9 @@ AhoCorasickBuilder { b . -start_kind -( -StartKind -: -: -Both -) -. -kind -( -Some +anchored ( -AhoCorasickKind -: -: -DFA -) +true ) ; } @@ -10350,10 +9354,9 @@ DFA testconfig ! ( -anchored -search_leftmost_first_anchored_default -AC_LEFTMOST_FIRST_ANCHORED -LeftmostFirst +search_leftmost_longest_anchored_dfa_default +AC_LEFTMOST_LONGEST_ANCHORED +LeftmostLongest | b : @@ -10364,24 +9367,42 @@ AhoCorasickBuilder { b . -start_kind +anchored ( -StartKind -: -: -Anchored +true +) +. +dfa +( +true ) ; } ) ; +/ +/ +And +also +write +out +the +test +combinations +for +ASCII +case +insensitivity +. testconfig ! ( -anchored -search_leftmost_first_anchored_nfa_noncontig_default -AC_LEFTMOST_FIRST_ANCHORED -LeftmostFirst +acasei_standard_nfa_default +& +[ +ASCII_CASE_INSENSITIVE +] +Standard | b : @@ -10392,23 +9413,14 @@ AhoCorasickBuilder { b . -start_kind +prefilter ( -StartKind -: -: -Anchored +false ) . -kind -( -Some +ascii_case_insensitive ( -AhoCorasickKind -: -: -NoncontiguousNFA -) +true ) ; } @@ -10417,10 +9429,13 @@ NoncontiguousNFA testconfig ! ( -anchored -search_leftmost_first_anchored_nfa_contig_default -AC_LEFTMOST_FIRST_ANCHORED -LeftmostFirst +acasei_standard_dfa_default +& +[ +ASCII_CASE_INSENSITIVE +ASCII_CASE_INSENSITIVE_NON_OVERLAPPING +] +Standard | b : @@ -10431,23 +9446,14 @@ AhoCorasickBuilder { b . -start_kind +ascii_case_insensitive ( -StartKind -: -: -Anchored +true ) . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) ; } @@ -10456,10 +9462,14 @@ ContiguousNFA testconfig ! ( -anchored -search_leftmost_first_anchored_dfa_default -AC_LEFTMOST_FIRST_ANCHORED -LeftmostFirst +overlapping +acasei_standard_overlapping_nfa_default +& +[ +ASCII_CASE_INSENSITIVE +ASCII_CASE_INSENSITIVE_OVERLAPPING +] +Standard | b : @@ -10470,23 +9480,9 @@ AhoCorasickBuilder { b . -start_kind -( -StartKind -: -: -Anchored -) -. -kind -( -Some +ascii_case_insensitive ( -AhoCorasickKind -: -: -DFA -) +true ) ; } @@ -10495,10 +9491,14 @@ DFA testconfig ! ( -anchored -search_leftmost_first_anchored_dfa_start_both -AC_LEFTMOST_FIRST_ANCHORED -LeftmostFirst +overlapping +acasei_standard_overlapping_dfa_default +& +[ +ASCII_CASE_INSENSITIVE +ASCII_CASE_INSENSITIVE_OVERLAPPING +] +Standard | b : @@ -10509,23 +9509,14 @@ AhoCorasickBuilder { b . -start_kind +ascii_case_insensitive ( -StartKind -: -: -Both +true ) . -kind -( -Some +dfa ( -AhoCorasickKind -: -: -DFA -) +true ) ; } @@ -10534,10 +9525,13 @@ DFA testconfig ! ( -anchored -search_leftmost_longest_anchored_default -AC_LEFTMOST_LONGEST_ANCHORED -LeftmostLongest +acasei_leftmost_first_nfa_default +& +[ +ASCII_CASE_INSENSITIVE +ASCII_CASE_INSENSITIVE_NON_OVERLAPPING +] +LeftmostFirst | b : @@ -10548,12 +9542,9 @@ AhoCorasickBuilder { b . -start_kind +ascii_case_insensitive ( -StartKind -: -: -Anchored +true ) ; } @@ -10562,10 +9553,13 @@ Anchored testconfig ! ( -anchored -search_leftmost_longest_anchored_nfa_noncontig_default -AC_LEFTMOST_LONGEST_ANCHORED -LeftmostLongest +acasei_leftmost_first_dfa_default +& +[ +ASCII_CASE_INSENSITIVE +ASCII_CASE_INSENSITIVE_NON_OVERLAPPING +] +LeftmostFirst | b : @@ -10576,23 +9570,14 @@ AhoCorasickBuilder { b . -start_kind +ascii_case_insensitive ( -StartKind -: -: -Anchored +true ) . -kind +dfa ( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) +true ) ; } @@ -10601,9 +9586,12 @@ NoncontiguousNFA testconfig ! ( -anchored -search_leftmost_longest_anchored_nfa_contig_default -AC_LEFTMOST_LONGEST_ANCHORED +acasei_leftmost_longest_nfa_default +& +[ +ASCII_CASE_INSENSITIVE +ASCII_CASE_INSENSITIVE_NON_OVERLAPPING +] LeftmostLongest | b @@ -10615,23 +9603,9 @@ AhoCorasickBuilder { b . -start_kind -( -StartKind -: -: -Anchored -) -. -kind -( -Some +ascii_case_insensitive ( -AhoCorasickKind -: -: -ContiguousNFA -) +true ) ; } @@ -10640,9 +9614,12 @@ ContiguousNFA testconfig ! ( -anchored -search_leftmost_longest_anchored_dfa_default -AC_LEFTMOST_LONGEST_ANCHORED +acasei_leftmost_longest_dfa_default +& +[ +ASCII_CASE_INSENSITIVE +ASCII_CASE_INSENSITIVE_NON_OVERLAPPING +] LeftmostLongest | b @@ -10654,2375 +9631,745 @@ AhoCorasickBuilder { b . -start_kind +ascii_case_insensitive ( -StartKind -: -: -Anchored +true ) . -kind +dfa ( -Some -( -AhoCorasickKind -: -: -DFA -) +true ) ; } ) ; -testconfig -! -( -anchored -search_leftmost_longest_anchored_dfa_start_both -AC_LEFTMOST_LONGEST_ANCHORED -LeftmostLongest -| -b +fn +run_search_tests +< +F : -& -mut -AhoCorasickBuilder -| -{ -b -. -start_kind +FnMut ( -StartKind -: -: -Both -) -. -kind -( -Some +& +SearchTest +) +- +> +Vec +< +Match +> +> ( -AhoCorasickKind +which : +TestCollection +mut +f : -DFA -) -) -; -} +F ) -; -/ -/ -And -also -write -out -the -test -combinations -for -ASCII -case -insensitivity -. -testconfig -! -( -acasei_standard_default -& -[ -ASCII_CASE_INSENSITIVE -] -Standard +{ +let +get_match_triples += | -b +matches : -& -mut -AhoCorasickBuilder +Vec +< +Match +> | -{ -b -. -prefilter +- +> +Vec +< ( -false +usize +usize +usize ) +> +{ +matches . -ascii_case_insensitive +into_iter ( -true ) -; -} -) -; -testconfig -! +. +map ( -acasei_standard_nfa_noncontig_default -& -[ -ASCII_CASE_INSENSITIVE -] -Standard | -b -: -& -mut -AhoCorasickBuilder +m | -{ -b -. -kind ( -Some +m +. +pattern ( -AhoCorasickKind -: -: -NoncontiguousNFA ) +m +. +start +( ) +m . -prefilter +end ( -false +) +) ) . -ascii_case_insensitive +collect ( -true ) -; } -) ; -testconfig -! -( -acasei_standard_nfa_contig_default -& -[ -ASCII_CASE_INSENSITIVE -] -Standard -| -b -: +for & -mut -AhoCorasickBuilder -| +tests +in +which { -b +for +test +in +tests +{ +assert_eq +! +( +test . -kind +matches +get_match_triples ( -Some +f ( -AhoCorasickKind -: -: -ContiguousNFA +& +test ) ) . -prefilter +as_slice ( -false ) +" +test +: +{ +} +patterns +: +{ +: +? +} +haystack +: +{ +: +? +} +" +test . -ascii_case_insensitive -( -true +name +test +. +patterns +test +. +haystack ) ; } -) -; -testconfig -! -( -acasei_standard_dfa_default -& +} +} +# [ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING +test ] -Standard +fn +search_tests_have_unique_names +( +) +{ +let +assert += | -b +constname +tests : & -mut -AhoCorasickBuilder +[ +SearchTest +] | { -b -. -kind -( -Some -( -AhoCorasickKind +let +mut +seen += +HashMap : : -DFA +new +( ) +; +/ +/ +map +from +test +name +to +position +for +( +i +test ) +in +tests . -ascii_case_insensitive +iter ( -true ) -; -} +. +enumerate +( ) -; -testconfig +{ +if ! -( -overlapping -acasei_standard_overlapping_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_OVERLAPPING -] -Standard -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -ascii_case_insensitive -( -true -) -; -} -) -; -testconfig -! -( -overlapping -acasei_standard_overlapping_nfa_noncontig_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_OVERLAPPING -] -Standard -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -) -. -ascii_case_insensitive -( -true -) -; -} -) -; -testconfig -! -( -overlapping -acasei_standard_overlapping_nfa_contig_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_OVERLAPPING -] -Standard -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b +seen . -kind -( -Some +contains_key ( -AhoCorasickKind -: -: -ContiguousNFA -) -) +test . -ascii_case_insensitive -( -true -) -; -} +name ) -; -testconfig -! -( -overlapping -acasei_standard_overlapping_dfa_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_OVERLAPPING -] -Standard -| -b -: -& -mut -AhoCorasickBuilder -| { -b +seen . -kind -( -Some +insert ( -AhoCorasickKind -: -: -DFA -) -) +test . -ascii_case_insensitive -( -true +name +i ) ; } -) -; -testconfig -! -( -acasei_leftmost_first_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING -] -LeftmostFirst -| -b -: -& -mut -AhoCorasickBuilder -| +else { -b -. -ascii_case_insensitive -( -true -) -; -} -) -; -testconfig -! -( -acasei_leftmost_first_nfa_noncontig_default -& +let +last += +seen [ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING -] -LeftmostFirst -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -) +test . -ascii_case_insensitive -( -true -) -; -} -) -; -testconfig -! -( -acasei_leftmost_first_nfa_contig_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING +name ] -LeftmostFirst -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -ContiguousNFA -) -) -. -ascii_case_insensitive -( -true -) -; -} -) ; -testconfig +panic ! ( -acasei_leftmost_first_dfa_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING -] -LeftmostFirst -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -ascii_case_insensitive -( -true -) -; -} -) -; -testconfig -! -( -acasei_leftmost_longest_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING -] -LeftmostLongest -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -ascii_case_insensitive -( -true -) -; -} -) -; -testconfig -! -( -acasei_leftmost_longest_nfa_noncontig_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING -] -LeftmostLongest -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -) -. -ascii_case_insensitive -( -true -) -; -} -) -; -testconfig -! -( -acasei_leftmost_longest_nfa_contig_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING -] -LeftmostLongest -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -ContiguousNFA -) -) -. -ascii_case_insensitive -( -true -) -; -} -) -; -testconfig -! -( -acasei_leftmost_longest_dfa_default -& -[ -ASCII_CASE_INSENSITIVE -ASCII_CASE_INSENSITIVE_NON_OVERLAPPING -] -LeftmostLongest -| -b -: -& -mut -AhoCorasickBuilder -| -{ -b -. -kind -( -Some -( -AhoCorasickKind -: -: -DFA -) -) -. -ascii_case_insensitive -( -true -) -; -} -) -; -fn -run_search_tests -< -F -: -FnMut -( -& -SearchTest -) -- -> -Vec -< -Match -> -> -( -which -: -TestCollection -mut -f -: -F -) -{ -let -get_match_triples -= -| -matches -: -Vec -< -Match -> -| -- -> -Vec -< -( -usize -usize -usize -) -> -{ -matches -. -into_iter -( -) -. -map -( -| -m -| -( -m -. -pattern -( -) -. -as_usize -( -) -m -. -start -( -) -m -. -end -( -) -) -) -. -collect -( -) -} -; -for -& -tests -in -which -{ -for -test -in -tests -{ -assert_eq -! -( -test -. -matches -get_match_triples -( -f -( -& -test -) -) -. -as_slice -( -) -" -test -: -{ -} -patterns -: -{ -: -? -} -haystack -: -{ -: -? -} -" -test -. -name -test -. -patterns -test -. -haystack -) -; -} -} -} -/ -/ -Like -' -run_search_tests -' -but -we -skip -any -tests -that -contain -the -empty -/ -/ -pattern -because -stream -searching -doesn -' -t -support -it -. -# -[ -cfg -( -feature -= -" -std -" -) -] -fn -run_stream_search_tests -< -F -: -FnMut -( -& -SearchTest -) -- -> -Vec -< -Match -> -> -( -which -: -TestCollection -mut -f -: -F -) -{ -let -get_match_triples -= -| -matches -: -Vec -< -Match -> -| -- -> -Vec -< -( -usize -usize -usize -) -> -{ -matches -. -into_iter -( -) -. -map -( -| -m -| -( -m -. -pattern -( -) -. -as_usize -( -) -m -. -start -( -) -m -. -end -( -) -) -) -. -collect -( -) -} -; -for -& -tests -in -which -{ -for -test -in -tests -{ -if -test -. -patterns -. -iter -( -) -. -any -( -| -p -| -p -. -is_empty -( -) -) -{ -continue -; -} -assert_eq -! -( -test -. -matches -get_match_triples -( -f -( -& -test -) -) -. -as_slice -( -) -" -test -: -{ -} -patterns -: -{ -: -? -} -haystack -: -{ -: -? -} -" -test -. -name -test -. -patterns -test -. -haystack -) -; -} -} -} -# -[ -test -] -fn -search_tests_have_unique_names -( -) -{ -let -assert -= -| -constname -tests -: -& -[ -SearchTest -] -| -{ -let -mut -seen -= -HashMap -: -: -new -( -) -; -/ -/ -map -from -test -name -to -position -for -( -i -test -) -in -tests -. -iter -( -) -. -enumerate -( -) -{ -if -! -seen -. -contains_key -( -test -. -name -) -{ -seen -. -insert -( -test -. -name -i -) -; -} -else -{ -let -last -= -seen -[ -test -. -name -] -; -panic -! -( -" -{ -} -tests -have -duplicate -names -at -positions -{ -} -and -{ -} -" -constname -last -i -) -; -} -} -} -; -assert -( -" -BASICS -" -BASICS -) -; -assert -( -" -STANDARD -" -STANDARD -) -; -assert -( -" -LEFTMOST -" -LEFTMOST -) -; -assert -( -" -LEFTMOST_FIRST -" -LEFTMOST_FIRST -) -; -assert -( -" -LEFTMOST_LONGEST -" -LEFTMOST_LONGEST -) -; -assert -( -" -NON_OVERLAPPING -" -NON_OVERLAPPING -) -; -assert -( -" -OVERLAPPING -" -OVERLAPPING -) -; -assert -( -" -REGRESSION -" -REGRESSION -) -; -} -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -test -] -# -[ -should_panic -] -fn -stream_not_allowed_leftmost_first -( -) -{ -let -fsm -= -AhoCorasick -: -: -builder -( -) -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -. -build -( -None -: -: -< -String -> -) -. -unwrap -( -) -; -assert_eq -! -( -fsm -. -stream_find_iter -( -& -b -" -" -[ -. -. -] -) -. -count -( -) -0 -) -; -} -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -test -] -# -[ -should_panic -] -fn -stream_not_allowed_leftmost_longest -( -) -{ -let -fsm -= -AhoCorasick -: -: -builder -( -) -. -match_kind -( -MatchKind -: -: -LeftmostLongest -) -. -build -( -None -: -: -< -String -> -) -. -unwrap -( -) -; -assert_eq -! -( -fsm -. -stream_find_iter -( -& -b -" -" -[ -. -. -] -) -. -count -( -) -0 -) -; -} -# -[ -test -] -# -[ -should_panic -] -fn -overlapping_not_allowed_leftmost_first -( -) -{ -let -fsm -= -AhoCorasick -: -: -builder -( -) -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -. -build -( -None -: -: -< -String -> -) -. -unwrap -( -) -; -assert_eq -! -( -fsm -. -find_overlapping_iter -( -" -" -) -. -count -( -) -0 -) -; -} -# -[ -test -] -# -[ -should_panic -] -fn -overlapping_not_allowed_leftmost_longest -( -) -{ -let -fsm -= -AhoCorasick -: -: -builder -( -) -. -match_kind -( -MatchKind -: -: -LeftmostLongest -) -. -build -( -None -: -: -< -String -> -) -. -unwrap -( -) -; -assert_eq -! -( -fsm -. -find_overlapping_iter -( -" -" -) -. -count -( -) -0 -) -; -} -/ -/ -This -tests -that -if -we -build -an -AC -matcher -with -an -" -unanchored -" -start -kind -/ -/ -then -we -can -' -t -run -an -anchored -search -even -if -the -underlying -searcher -/ -/ -supports -it -. -/ -/ -/ -/ -The -key -bit -here -is -that -both -of -the -NFAs -in -this -crate -unconditionally -/ -/ -support -both -unanchored -and -anchored -searches -but -the -DFA -does -not -because -/ -/ -of -the -added -cost -of -doing -so -. -To -avoid -the -top -- -level -AC -matcher -sometimes -/ -/ -supporting -anchored -and -sometimes -not -( -depending -on -which -searcher -it -/ -/ -chooses -to -use -internally -) -we -ensure -that -the -given -' -StartKind -' -is -always -/ -/ -respected -. -# -[ -test -] -fn -anchored_not_allowed_even_if_technically_available -( -) -{ -let -ac -= -AhoCorasick -: -: -builder -( -) -. -kind -( -Some -( -AhoCorasickKind -: -: -NoncontiguousNFA -) -) -. -start_kind -( -StartKind -: -: -Unanchored -) -. -build -( -& -[ " -foo +{ +} +tests +have +duplicate +names +at +positions +{ +} +and +{ +} " -] -) -. -unwrap -( +constname +last +i ) ; +} +} +} +; assert -! -( -ac -. -try_find -( -Input -: -: -new ( " -foo +BASICS " -) -. -anchored -( -Anchored -: -: -Yes -) -) -. -is_err -( -) +BASICS ) ; -let -ac -= -AhoCorasick -: -: -builder +assert ( +" +STANDARD +" +STANDARD ) -. -kind -( -Some +; +assert ( -AhoCorasickKind -: -: -ContiguousNFA -) +" +LEFTMOST +" +LEFTMOST ) -. -start_kind +; +assert ( -StartKind -: -: -Unanchored +" +LEFTMOST_FIRST +" +LEFTMOST_FIRST ) -. -build +; +assert ( -& -[ " -foo +LEFTMOST_LONGEST " -] +LEFTMOST_LONGEST ) -. -unwrap +; +assert ( +" +NON_OVERLAPPING +" +NON_OVERLAPPING ) ; assert -! -( -ac -. -try_find -( -Input -: -: -new ( " -foo +OVERLAPPING " +OVERLAPPING ) -. -anchored +; +assert ( -Anchored -: -: -Yes -) +" +REGRESSION +" +REGRESSION ) -. -is_err +; +} +# +[ +test +] +# +[ +should_panic +] +fn +stream_not_allowed_leftmost_first ( ) -) -; -/ -/ -For -completeness -check -that -the -DFA -returns -an -error -too -. +{ let -ac +fsm = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . -kind -( -Some +match_kind ( -AhoCorasickKind +MatchKind : : -DFA -) +LeftmostFirst ) . -start_kind +build ( -StartKind +None : : -Unanchored -) -. -build -( -& -[ -" -foo -" -] -) -. -unwrap -( +< +String +> ) ; -assert +assert_eq ! ( -ac +fsm . -try_find -( -Input -: -: -new +stream_find_iter ( +& +b " -foo " -) +[ . -anchored -( -Anchored -: -: -Yes -) +. +] ) . -is_err +count ( ) +0 ) ; } -/ -/ -This -is -like -the -test -aboved -but -with -unanchored -and -anchored -flipped -. -That -/ -/ -is -we -asked -for -an -AC -searcher -with -anchored -support -and -we -check -that -/ -/ -unanchored -searches -return -an -error -even -if -the -underlying -searcher -would -/ -/ -technically -support -it -. # [ test ] +# +[ +should_panic +] fn -unanchored_not_allowed_even_if_technically_available +stream_not_allowed_leftmost_longest ( ) { let -ac +fsm = -AhoCorasick +AhoCorasickBuilder : : -builder -( -) -. -kind -( -Some +new ( -AhoCorasickKind -: -: -NoncontiguousNFA -) ) . -start_kind +match_kind ( -StartKind +MatchKind : : -Anchored +LeftmostLongest ) . build ( -& -[ -" -foo -" -] -) -. -unwrap -( +None +: +: +< +String +> ) ; -assert +assert_eq ! ( -ac +fsm . -try_find -( -Input -: -: -new +stream_find_iter ( +& +b " -foo " -) +[ . -anchored -( -Anchored -: -: -No -) +. +] ) . -is_err +count ( ) +0 ) ; +} +# +[ +test +] +# +[ +should_panic +] +fn +overlapping_not_allowed_leftmost_first +( +) +{ let -ac +fsm = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . -kind -( -Some +match_kind ( -AhoCorasickKind +MatchKind : : -ContiguousNFA -) +LeftmostFirst ) . -start_kind +build ( -StartKind +None : : -Anchored -) -. -build -( -& -[ -" -foo -" -] -) -. -unwrap -( +< +String +> ) ; -assert +assert_eq ! ( -ac +fsm . -try_find -( -Input -: -: -new +find_overlapping_iter ( " -foo " ) . -anchored +count ( -Anchored -: -: -No ) +0 ) -. -is_err +; +} +# +[ +test +] +# +[ +should_panic +] +fn +overlapping_not_allowed_leftmost_longest ( ) -) -; -/ -/ -For -completeness -check -that -the -DFA -returns -an -error -too -. +{ let -ac +fsm = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . -kind -( -Some +match_kind ( -AhoCorasickKind +MatchKind : : -DFA -) +LeftmostLongest ) . -start_kind +build ( -StartKind +None : : -Anchored -) -. -build -( -& -[ -" -foo -" -] -) -. -unwrap -( +< +String +> ) ; -assert +assert_eq ! ( -ac +fsm . -try_find -( -Input -: -: -new +find_overlapping_iter ( " -foo " ) . -anchored -( -Anchored -: -: -No -) -) -. -is_err +count ( ) -) -; -} -/ -/ -This -tests -that -a -prefilter -does -not -cause -a -search -to -report -a -match -/ -/ -outside -the -bounds -provided -by -the -caller -. -/ -/ -/ -/ -This -is -a -regression -test -for -a -bug -I -introduced -during -the -rewrite -of -most -/ -/ -of -the -crate -after 0 -. -7 -. -It -was -never -released -. -The -tricky -part -here -is -/ -/ -ensuring -we -get -a -prefilter -that -can -report -matches -on -its -own -( -such -as -the -/ -/ -packed -searcher ) -. -Otherwise -prefilters -that -report -false -positives -might -/ -/ -have -searched -past -the -bounds -provided -by -the -caller -but -confirming -the -/ -/ -match -would -subsequently -fail -. +; +} # [ test ] fn -prefilter_stays_in_bounds +state_id_too_small ( ) { let -ac +mut +patterns = -AhoCorasick -: -: -builder +vec +! +[ +] +; +for +c1 +in ( +b +' +a +' +. +. +b +' +z +' ) . -match_kind +map ( -MatchKind -: -: -LeftmostFirst +| +b +| +b +as +char ) +{ +for +c2 +in +( +b +' +a +' . -build +. +b +' +z +' +) +. +map ( -& -[ -" -sam -" -" -frodo -" -" -pippin -" -" -merry -" -" -gandalf -" -" -sauron -" -] +| +b +| +b +as +char +) +{ +for +c3 +in +( +b +' +a +' +. +. +b +' +z +' ) . -unwrap +map ( +| +b +| +b +as +char ) -; -let -haystack -= +{ +patterns +. +push +( +format +! +( " -foo -gandalf +{ +} +{ +} +{ +} " +c1 +c2 +c3 +) +) ; -assert_eq -! -( -None -ac -. -find -( -Input +} +} +} +let +result += +AhoCorasickBuilder : : new ( -haystack ) . -range +build_with_size +: +: +< +u8 +_ +_ +> ( -0 -. -. -10 +& +patterns ) +; +assert +! +( +result +. +is_err +( ) ) ; @@ -13090,10 +10437,10 @@ regression_ascii_case_insensitive_no_exponential let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . @@ -13116,10 +10463,6 @@ Vol01 " ] ) -. -unwrap -( -) ; assert ! @@ -13225,7 +10568,7 @@ ac AhoCorasick : : -new +new_auto_configured ( & [ @@ -13241,10 +10584,6 @@ x " ] ) -. -unwrap -( -) ; assert ! @@ -13272,6 +10611,12 @@ regression_case_insensitive_prefilter ( ) { +use +crate +: +: +AhoCorasickBuilder +; for c in @@ -13346,10 +10691,10 @@ to_uppercase let ac = -AhoCorasick +AhoCorasickBuilder : : -builder +new ( ) . @@ -13371,10 +10716,6 @@ build needle ] ) -. -unwrap -( -) ; assert_eq ! @@ -13461,17 +10802,6 @@ active . # [ -cfg -( -feature -= -" -std -" -) -] -# -[ test ] fn @@ -13551,7 +10881,7 @@ the buffer size is -64KB +8192 by / / @@ -13562,7 +10892,7 @@ BEGIN : usize = -65_535 +8191 ; / / @@ -13636,6 +10966,8 @@ u8 ) - > +: +: std : : @@ -13647,6 +10979,18 @@ Result usize > { +/ +/ +dbg +! +( +buf +. +len +( +) +) +; if self . @@ -13858,6 +11202,8 @@ run ) - > +: +: std : : @@ -13873,40 +11219,11 @@ Result let aut = -AhoCorasick +AhoCorasickBuilder : : -builder -( -) -/ -/ -Enable -byte -classes -to -make -debugging -the -automaton -easier -. -It -/ -/ -should -have -no -effect -on -the -test -result -. -. -byte_classes +new ( -false ) . build @@ -13917,10 +11234,6 @@ build MAGIC ] ) -. -unwrap -( -) ; / / @@ -13936,9 +11249,6 @@ let mut buf = -alloc -: -: vec ! [ @@ -13993,24 +11303,12 @@ let mut file = -std -: -: -io -: -: -BufReader -: -: -new -( R : : default ( ) -) ; let begin diff --git a/third_party/rust/aho-corasick/src/transducer.rs b/third_party/rust/aho-corasick/src/transducer.rs deleted file mode 100644 index 832777e080b4a..0000000000000 --- a/third_party/rust/aho-corasick/src/transducer.rs +++ /dev/null @@ -1,2355 +0,0 @@ -/ -* -! -Provides -implementations -of -fst -: -: -Automaton -for -Aho -- -Corasick -automata -. -This -works -by -providing -two -wrapper -types -[ -Anchored -] -and -[ -Unanchored -] -. -The -former -executes -an -anchored -search -on -an -FST -while -the -latter -executes -an -unanchored -search -. -Building -these -wrappers -is -fallible -and -will -fail -if -the -underlying -Aho -- -Corasick -automaton -does -not -support -the -type -of -search -it -represents -. -* -/ -use -crate -: -: -{ -automaton -: -: -{ -Automaton -StateID -} -Anchored -as -AcAnchored -Input -MatchError -} -; -/ -/ -/ -Represents -an -unanchored -Aho -- -Corasick -search -of -a -finite -state -transducer -. -/ -/ -/ -/ -/ -/ -Wrapping -an -Aho -- -Corasick -automaton -in -Unanchored -will -fail -if -the -/ -/ -/ -underlying -automaton -does -not -support -unanchored -searches -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -build -an -FST -of -keys -and -then -run -an -unanchored -search -on -/ -/ -/ -those -keys -using -an -Aho -- -Corasick -automaton -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -nfa -: -: -contiguous -: -: -NFA -transducer -: -: -Unanchored -} -; -/ -/ -/ -use -fst -: -: -{ -Automaton -IntoStreamer -Set -Streamer -} -; -/ -/ -/ -/ -/ -/ -let -set -= -Set -: -: -from_iter -( -& -[ -" -abcd -" -" -bc -" -" -bcd -" -" -xyz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -& -[ -" -bcd -" -" -x -" -] -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -NFAs -always -support -both -unanchored -and -anchored -searches -. -/ -/ -/ -let -searcher -= -Unanchored -: -: -new -( -& -nfa -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -stream -= -set -. -search -( -searcher -) -. -into_stream -( -) -; -/ -/ -/ -let -mut -results -= -vec -! -[ -] -; -/ -/ -/ -while -let -Some -( -key -) -= -stream -. -next -( -) -{ -/ -/ -/ -results -. -push -( -std -: -: -str -: -: -from_utf8 -( -key -) -. -unwrap -( -) -. -to_string -( -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -vec -! -[ -" -abcd -" -" -bcd -" -" -xyz -" -] -results -) -; -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Unanchored -< -A -> -( -A -) -; -impl -< -A -: -Automaton -> -Unanchored -< -A -> -{ -/ -/ -/ -Create -a -new -Unanchored -implementation -of -the -fst -: -: -Automaton -trait -. -/ -/ -/ -/ -/ -/ -If -the -given -Aho -- -Corasick -automaton -does -not -support -unanchored -/ -/ -/ -searches -then -this -returns -an -error -. -pub -fn -new -( -aut -: -A -) -- -> -Result -< -Unanchored -< -A -> -MatchError -> -{ -let -input -= -Input -: -: -new -( -" -" -) -. -anchored -( -AcAnchored -: -: -No -) -; -let -_ -= -aut -. -start_state -( -& -input -) -? -; -Ok -( -Unanchored -( -aut -) -) -} -/ -/ -/ -Returns -a -borrow -to -the -underlying -automaton -. -pub -fn -as_ref -( -& -self -) -- -> -& -A -{ -& -self -. -0 -} -/ -/ -/ -Unwrap -this -value -and -return -the -inner -automaton -. -pub -fn -into_inner -( -self -) -- -> -A -{ -self -. -0 -} -} -impl -< -A -: -Automaton -> -fst -: -: -Automaton -for -Unanchored -< -A -> -{ -type -State -= -StateID -; -# -[ -inline -] -fn -start -( -& -self -) -- -> -StateID -{ -let -input -= -Input -: -: -new -( -" -" -) -. -anchored -( -AcAnchored -: -: -No -) -; -self -. -0 -. -start_state -( -& -input -) -. -expect -( -" -support -for -unanchored -searches -" -) -} -# -[ -inline -] -fn -is_match -( -& -self -state -: -& -StateID -) -- -> -bool -{ -self -. -0 -. -is_match -( -* -state -) -} -# -[ -inline -] -fn -accept -( -& -self -state -: -& -StateID -byte -: -u8 -) -- -> -StateID -{ -if -fst -: -: -Automaton -: -: -is_match -( -self -state -) -{ -return -* -state -; -} -self -. -0 -. -next_state -( -AcAnchored -: -: -No -* -state -byte -) -} -# -[ -inline -] -fn -can_match -( -& -self -state -: -& -StateID -) -- -> -bool -{ -! -self -. -0 -. -is_dead -( -* -state -) -} -} -/ -/ -/ -Represents -an -anchored -Aho -- -Corasick -search -of -a -finite -state -transducer -. -/ -/ -/ -/ -/ -/ -Wrapping -an -Aho -- -Corasick -automaton -in -Unanchored -will -fail -if -the -/ -/ -/ -underlying -automaton -does -not -support -unanchored -searches -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -build -an -FST -of -keys -and -then -run -an -anchored -search -on -/ -/ -/ -those -keys -using -an -Aho -- -Corasick -automaton -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -nfa -: -: -contiguous -: -: -NFA -transducer -: -: -Anchored -} -; -/ -/ -/ -use -fst -: -: -{ -Automaton -IntoStreamer -Set -Streamer -} -; -/ -/ -/ -/ -/ -/ -let -set -= -Set -: -: -from_iter -( -& -[ -" -abcd -" -" -bc -" -" -bcd -" -" -xyz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -& -[ -" -bcd -" -" -x -" -] -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -NFAs -always -support -both -unanchored -and -anchored -searches -. -/ -/ -/ -let -searcher -= -Anchored -: -: -new -( -& -nfa -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -stream -= -set -. -search -( -searcher -) -. -into_stream -( -) -; -/ -/ -/ -let -mut -results -= -vec -! -[ -] -; -/ -/ -/ -while -let -Some -( -key -) -= -stream -. -next -( -) -{ -/ -/ -/ -results -. -push -( -std -: -: -str -: -: -from_utf8 -( -key -) -. -unwrap -( -) -. -to_string -( -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -vec -! -[ -" -bcd -" -" -xyz -" -] -results -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -is -like -the -example -above -except -we -use -an -Aho -- -Corasick -DFA -which -/ -/ -/ -requires -explicitly -configuring -it -to -support -anchored -searches -. -( -NFAs -/ -/ -/ -unconditionally -support -both -unanchored -and -anchored -searches -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -dfa -: -: -DFA -transducer -: -: -Anchored -StartKind -} -; -/ -/ -/ -use -fst -: -: -{ -Automaton -IntoStreamer -Set -Streamer -} -; -/ -/ -/ -/ -/ -/ -let -set -= -Set -: -: -from_iter -( -& -[ -" -abcd -" -" -bc -" -" -bcd -" -" -xyz -" -] -) -. -unwrap -( -) -; -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Anchored -) -/ -/ -/ -. -build -( -& -[ -" -bcd -" -" -x -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -We -' -ve -explicitly -configured -our -DFA -to -support -anchored -searches -. -/ -/ -/ -let -searcher -= -Anchored -: -: -new -( -& -dfa -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -stream -= -set -. -search -( -searcher -) -. -into_stream -( -) -; -/ -/ -/ -let -mut -results -= -vec -! -[ -] -; -/ -/ -/ -while -let -Some -( -key -) -= -stream -. -next -( -) -{ -/ -/ -/ -results -. -push -( -std -: -: -str -: -: -from_utf8 -( -key -) -. -unwrap -( -) -. -to_string -( -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -vec -! -[ -" -bcd -" -" -xyz -" -] -results -) -; -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Anchored -< -A -> -( -A -) -; -impl -< -A -: -Automaton -> -Anchored -< -A -> -{ -/ -/ -/ -Create -a -new -Anchored -implementation -of -the -fst -: -: -Automaton -trait -. -/ -/ -/ -/ -/ -/ -If -the -given -Aho -- -Corasick -automaton -does -not -support -anchored -searches -/ -/ -/ -then -this -returns -an -error -. -pub -fn -new -( -aut -: -A -) -- -> -Result -< -Anchored -< -A -> -MatchError -> -{ -let -input -= -Input -: -: -new -( -" -" -) -. -anchored -( -AcAnchored -: -: -Yes -) -; -let -_ -= -aut -. -start_state -( -& -input -) -? -; -Ok -( -Anchored -( -aut -) -) -} -/ -/ -/ -Returns -a -borrow -to -the -underlying -automaton -. -pub -fn -as_ref -( -& -self -) -- -> -& -A -{ -& -self -. -0 -} -/ -/ -/ -Unwrap -this -value -and -return -the -inner -automaton -. -pub -fn -into_inner -( -self -) -- -> -A -{ -self -. -0 -} -} -impl -< -A -: -Automaton -> -fst -: -: -Automaton -for -Anchored -< -A -> -{ -type -State -= -StateID -; -# -[ -inline -] -fn -start -( -& -self -) -- -> -StateID -{ -let -input -= -Input -: -: -new -( -" -" -) -. -anchored -( -AcAnchored -: -: -Yes -) -; -self -. -0 -. -start_state -( -& -input -) -. -expect -( -" -support -for -unanchored -searches -" -) -} -# -[ -inline -] -fn -is_match -( -& -self -state -: -& -StateID -) -- -> -bool -{ -self -. -0 -. -is_match -( -* -state -) -} -# -[ -inline -] -fn -accept -( -& -self -state -: -& -StateID -byte -: -u8 -) -- -> -StateID -{ -if -fst -: -: -Automaton -: -: -is_match -( -self -state -) -{ -return -* -state -; -} -self -. -0 -. -next_state -( -AcAnchored -: -: -Yes -* -state -byte -) -} -# -[ -inline -] -fn -can_match -( -& -self -state -: -& -StateID -) -- -> -bool -{ -! -self -. -0 -. -is_dead -( -* -state -) -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -alloc -: -: -{ -string -: -: -String -vec -vec -: -: -Vec -} -; -use -fst -: -: -{ -Automaton -IntoStreamer -Set -Streamer -} -; -use -crate -: -: -{ -dfa -: -: -DFA -nfa -: -: -{ -contiguous -noncontiguous -} -StartKind -} -; -use -super -: -: -* -; -fn -search -< -A -: -Automaton -D -: -AsRef -< -[ -u8 -] -> -> -( -set -: -& -Set -< -D -> -aut -: -A -) -- -> -Vec -< -String -> -{ -let -mut -stream -= -set -. -search -( -aut -) -. -into_stream -( -) -; -let -mut -results -= -vec -! -[ -] -; -while -let -Some -( -key -) -= -stream -. -next -( -) -{ -results -. -push -( -String -: -: -from -( -core -: -: -str -: -: -from_utf8 -( -key -) -. -unwrap -( -) -) -) -; -} -results -} -# -[ -test -] -fn -unanchored -( -) -{ -let -set -= -Set -: -: -from_iter -( -& -[ -" -a -" -" -bar -" -" -baz -" -" -wat -" -" -xba -" -" -xbax -" -" -z -" -] -) -. -unwrap -( -) -; -let -patterns -= -vec -! -[ -" -baz -" -" -bax -" -] -; -let -expected -= -vec -! -[ -" -baz -" -" -xbax -" -] -; -let -aut -= -Unanchored -( -noncontiguous -: -: -NFA -: -: -new -( -& -patterns -) -. -unwrap -( -) -) -; -let -got -= -search -( -& -set -& -aut -) -; -assert_eq -! -( -got -expected -) -; -let -aut -= -Unanchored -( -contiguous -: -: -NFA -: -: -new -( -& -patterns -) -. -unwrap -( -) -) -; -let -got -= -search -( -& -set -& -aut -) -; -assert_eq -! -( -got -expected -) -; -let -aut -= -Unanchored -( -DFA -: -: -new -( -& -patterns -) -. -unwrap -( -) -) -; -let -got -= -search -( -& -set -& -aut -) -; -assert_eq -! -( -got -expected -) -; -} -# -[ -test -] -fn -anchored -( -) -{ -let -set -= -Set -: -: -from_iter -( -& -[ -" -a -" -" -bar -" -" -baz -" -" -wat -" -" -xba -" -" -xbax -" -" -z -" -] -) -. -unwrap -( -) -; -let -patterns -= -vec -! -[ -" -baz -" -" -bax -" -] -; -let -expected -= -vec -! -[ -" -baz -" -] -; -let -aut -= -Anchored -( -noncontiguous -: -: -NFA -: -: -new -( -& -patterns -) -. -unwrap -( -) -) -; -let -got -= -search -( -& -set -& -aut -) -; -assert_eq -! -( -got -expected -) -; -let -aut -= -Anchored -( -contiguous -: -: -NFA -: -: -new -( -& -patterns -) -. -unwrap -( -) -) -; -let -got -= -search -( -& -set -& -aut -) -; -assert_eq -! -( -got -expected -) -; -let -aut -= -Anchored -( -DFA -: -: -builder -( -) -. -start_kind -( -StartKind -: -: -Anchored -) -. -build -( -& -patterns -) -. -unwrap -( -) -) -; -let -got -= -search -( -& -set -& -aut -) -; -assert_eq -! -( -got -expected -) -; -} -} diff --git a/third_party/rust/aho-corasick/src/util/debug.rs b/third_party/rust/aho-corasick/src/util/debug.rs deleted file mode 100644 index 2ca3b700f14f4..0000000000000 --- a/third_party/rust/aho-corasick/src/util/debug.rs +++ /dev/null @@ -1,278 +0,0 @@ -/ -/ -/ -A -type -that -wraps -a -single -byte -with -a -convenient -fmt -: -: -Debug -impl -that -/ -/ -/ -escapes -the -byte -. -pub -( -crate -) -struct -DebugByte -( -pub -( -crate -) -u8 -) -; -impl -core -: -: -fmt -: -: -Debug -for -DebugByte -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -/ -/ -Special -case -ASCII -space -. -It -' -s -too -hard -to -read -otherwise -so -/ -/ -put -quotes -around -it -. -I -sometimes -wonder -whether -just -' -\ -x20 -' -would -/ -/ -be -better -. -. -. -if -self -. -0 -= -= -b -' -' -{ -return -write -! -( -f -" -' -' -" -) -; -} -/ -/ -10 -bytes -is -enough -to -cover -any -output -from -ascii -: -: -escape_default -. -let -mut -bytes -= -[ -0u8 -; -10 -] -; -let -mut -len -= -0 -; -for -( -i -mut -b -) -in -core -: -: -ascii -: -: -escape_default -( -self -. -0 -) -. -enumerate -( -) -{ -/ -/ -capitalize -\ -xab -to -\ -xAB -if -i -> -= -2 -& -& -b -' -a -' -< -= -b -& -& -b -< -= -b -' -f -' -{ -b -- -= -32 -; -} -bytes -[ -len -] -= -b -; -len -+ -= -1 -; -} -write -! -( -f -" -{ -} -" -core -: -: -str -: -: -from_utf8 -( -& -bytes -[ -. -. -len -] -) -. -unwrap -( -) -) -} -} diff --git a/third_party/rust/aho-corasick/src/util/error.rs b/third_party/rust/aho-corasick/src/util/error.rs deleted file mode 100644 index ff19cddd3db3d..0000000000000 --- a/third_party/rust/aho-corasick/src/util/error.rs +++ /dev/null @@ -1,1839 +0,0 @@ -use -crate -: -: -util -: -: -{ -primitives -: -: -{ -PatternID -SmallIndex -} -search -: -: -MatchKind -} -; -/ -/ -/ -An -error -that -occurred -during -the -construction -of -an -Aho -- -Corasick -/ -/ -/ -automaton -. -/ -/ -/ -/ -/ -/ -Build -errors -occur -when -some -kind -of -limit -has -been -exceeded -either -in -the -/ -/ -/ -number -of -states -the -number -of -patterns -of -the -length -of -a -pattern -. -These -/ -/ -/ -limits -aren -' -t -part -of -the -public -API -but -they -should -generally -be -large -/ -/ -/ -enough -to -handle -most -use -cases -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -std -: -: -error -: -: -Error -/ -/ -/ -trait -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -BuildError -{ -kind -: -ErrorKind -} -/ -/ -/ -The -kind -of -error -that -occurred -. -# -[ -derive -( -Clone -Debug -) -] -enum -ErrorKind -{ -/ -/ -/ -An -error -that -occurs -when -allocating -a -new -state -would -result -in -an -/ -/ -/ -identifier -that -exceeds -the -capacity -of -a -StateID -. -StateIDOverflow -{ -/ -/ -/ -The -maximum -possible -id -. -max -: -u64 -/ -/ -/ -The -maximum -ID -requested -. -requested_max -: -u64 -} -/ -/ -/ -An -error -that -occurs -when -adding -a -pattern -to -an -Aho -- -Corasick -/ -/ -/ -automaton -would -result -in -an -identifier -that -exceeds -the -capacity -of -a -/ -/ -/ -PatternID -. -PatternIDOverflow -{ -/ -/ -/ -The -maximum -possible -id -. -max -: -u64 -/ -/ -/ -The -maximum -ID -requested -. -requested_max -: -u64 -} -/ -/ -/ -Occurs -when -a -pattern -string -is -given -to -the -Aho -- -Corasick -constructor -/ -/ -/ -that -is -too -long -. -PatternTooLong -{ -/ -/ -/ -The -ID -of -the -pattern -that -was -too -long -. -pattern -: -PatternID -/ -/ -/ -The -length -that -was -too -long -. -len -: -usize -} -} -impl -BuildError -{ -pub -( -crate -) -fn -state_id_overflow -( -max -: -u64 -requested_max -: -u64 -) -- -> -BuildError -{ -BuildError -{ -kind -: -ErrorKind -: -: -StateIDOverflow -{ -max -requested_max -} -} -} -pub -( -crate -) -fn -pattern_id_overflow -( -max -: -u64 -requested_max -: -u64 -) -- -> -BuildError -{ -BuildError -{ -kind -: -ErrorKind -: -: -PatternIDOverflow -{ -max -requested_max -} -} -} -pub -( -crate -) -fn -pattern_too_long -( -pattern -: -PatternID -len -: -usize -) -- -> -BuildError -{ -BuildError -{ -kind -: -ErrorKind -: -: -PatternTooLong -{ -pattern -len -} -} -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -BuildError -{ -} -impl -core -: -: -fmt -: -: -Display -for -BuildError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -match -self -. -kind -{ -ErrorKind -: -: -StateIDOverflow -{ -max -requested_max -} -= -> -{ -write -! -( -f -" -state -identifier -overflow -: -failed -to -create -state -ID -\ -from -{ -} -which -exceeds -the -max -of -{ -} -" -requested_max -max -) -} -ErrorKind -: -: -PatternIDOverflow -{ -max -requested_max -} -= -> -{ -write -! -( -f -" -pattern -identifier -overflow -: -failed -to -create -pattern -ID -\ -from -{ -} -which -exceeds -the -max -of -{ -} -" -requested_max -max -) -} -ErrorKind -: -: -PatternTooLong -{ -pattern -len -} -= -> -{ -write -! -( -f -" -pattern -{ -} -with -length -{ -} -exceeds -\ -the -maximum -pattern -length -of -{ -} -" -pattern -. -as_usize -( -) -len -SmallIndex -: -: -MAX -. -as_usize -( -) -) -} -} -} -} -/ -/ -/ -An -error -that -occurred -during -an -Aho -- -Corasick -search -. -/ -/ -/ -/ -/ -/ -An -error -that -occurs -during -a -search -is -limited -to -some -kind -of -/ -/ -/ -misconfiguration -that -resulted -in -an -illegal -call -. -Stated -differently -/ -/ -/ -whether -an -error -occurs -is -not -dependent -on -the -specific -bytes -in -the -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -Examples -of -misconfiguration -: -/ -/ -/ -/ -/ -/ -* -Executing -a -stream -or -overlapping -search -on -a -searcher -that -was -built -was -/ -/ -/ -something -other -than -[ -MatchKind -: -: -Standard -] -( -crate -: -: -MatchKind -: -: -Standard -) -/ -/ -/ -semantics -. -/ -/ -/ -* -Requested -an -anchored -or -an -unanchored -search -on -a -searcher -that -doesn -' -t -/ -/ -/ -support -unanchored -or -anchored -searches -respectively -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -std -: -: -error -: -: -Error -/ -/ -/ -trait -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -MatchError -( -alloc -: -: -boxed -: -: -Box -< -MatchErrorKind -> -) -; -impl -MatchError -{ -/ -/ -/ -Create -a -new -error -value -with -the -given -kind -. -/ -/ -/ -/ -/ -/ -This -is -a -more -verbose -version -of -the -kind -- -specific -constructors -e -. -g -. -/ -/ -/ -MatchError -: -: -unsupported_stream -. -pub -fn -new -( -kind -: -MatchErrorKind -) -- -> -MatchError -{ -MatchError -( -alloc -: -: -boxed -: -: -Box -: -: -new -( -kind -) -) -} -/ -/ -/ -Returns -a -reference -to -the -underlying -error -kind -. -pub -fn -kind -( -& -self -) -- -> -& -MatchErrorKind -{ -& -self -. -0 -} -/ -/ -/ -Create -a -new -" -invalid -anchored -search -" -error -. -This -occurs -when -the -/ -/ -/ -caller -requests -an -anchored -search -but -where -anchored -searches -aren -' -t -/ -/ -/ -supported -. -/ -/ -/ -/ -/ -/ -This -is -the -same -as -calling -MatchError -: -: -new -with -a -/ -/ -/ -[ -MatchErrorKind -: -: -InvalidInputAnchored -] -kind -. -pub -fn -invalid_input_anchored -( -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -InvalidInputAnchored -) -} -/ -/ -/ -Create -a -new -" -invalid -unanchored -search -" -error -. -This -occurs -when -the -/ -/ -/ -caller -requests -an -unanchored -search -but -where -unanchored -searches -/ -/ -/ -aren -' -t -supported -. -/ -/ -/ -/ -/ -/ -This -is -the -same -as -calling -MatchError -: -: -new -with -a -/ -/ -/ -[ -MatchErrorKind -: -: -InvalidInputUnanchored -] -kind -. -pub -fn -invalid_input_unanchored -( -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -InvalidInputUnanchored -) -} -/ -/ -/ -Create -a -new -" -unsupported -stream -search -" -error -. -This -occurs -when -the -/ -/ -/ -caller -requests -a -stream -search -while -using -an -Aho -- -Corasick -automaton -/ -/ -/ -with -a -match -kind -other -than -[ -MatchKind -: -: -Standard -] -. -/ -/ -/ -/ -/ -/ -The -match -kind -given -should -be -the -match -kind -of -the -automaton -. -It -/ -/ -/ -should -never -be -MatchKind -: -: -Standard -. -pub -fn -unsupported_stream -( -got -: -MatchKind -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -UnsupportedStream -{ -got -} -) -} -/ -/ -/ -Create -a -new -" -unsupported -overlapping -search -" -error -. -This -occurs -when -/ -/ -/ -the -caller -requests -an -overlapping -search -while -using -an -Aho -- -Corasick -/ -/ -/ -automaton -with -a -match -kind -other -than -[ -MatchKind -: -: -Standard -] -. -/ -/ -/ -/ -/ -/ -The -match -kind -given -should -be -the -match -kind -of -the -automaton -. -It -/ -/ -/ -should -never -be -MatchKind -: -: -Standard -. -pub -fn -unsupported_overlapping -( -got -: -MatchKind -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -UnsupportedOverlapping -{ -got -} -) -} -/ -/ -/ -Create -a -new -" -unsupported -empty -pattern -" -error -. -This -occurs -when -the -/ -/ -/ -caller -requests -a -search -for -which -matching -an -automaton -that -contains -/ -/ -/ -an -empty -pattern -string -is -not -supported -. -pub -fn -unsupported_empty -( -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -UnsupportedEmpty -) -} -} -/ -/ -/ -The -underlying -kind -of -a -[ -MatchError -] -. -/ -/ -/ -/ -/ -/ -This -is -a -* -* -non -- -exhaustive -* -* -enum -. -That -means -new -variants -may -be -added -in -/ -/ -/ -a -semver -- -compatible -release -. -# -[ -non_exhaustive -] -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -enum -MatchErrorKind -{ -/ -/ -/ -An -error -indicating -that -an -anchored -search -was -requested -but -from -a -/ -/ -/ -searcher -that -was -built -without -anchored -support -. -InvalidInputAnchored -/ -/ -/ -An -error -indicating -that -an -unanchored -search -was -requested -but -from -a -/ -/ -/ -searcher -that -was -built -without -unanchored -support -. -InvalidInputUnanchored -/ -/ -/ -An -error -indicating -that -a -stream -search -was -attempted -on -an -/ -/ -/ -Aho -- -Corasick -automaton -with -an -unsupported -MatchKind -. -UnsupportedStream -{ -/ -/ -/ -The -match -semantics -for -the -automaton -that -was -used -. -got -: -MatchKind -} -/ -/ -/ -An -error -indicating -that -an -overlapping -search -was -attempted -on -an -/ -/ -/ -Aho -- -Corasick -automaton -with -an -unsupported -MatchKind -. -UnsupportedOverlapping -{ -/ -/ -/ -The -match -semantics -for -the -automaton -that -was -used -. -got -: -MatchKind -} -/ -/ -/ -An -error -indicating -that -the -operation -requested -doesn -' -t -support -/ -/ -/ -automatons -that -contain -an -empty -pattern -string -. -UnsupportedEmpty -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -MatchError -{ -} -impl -core -: -: -fmt -: -: -Display -for -MatchError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -match -* -self -. -kind -( -) -{ -MatchErrorKind -: -: -InvalidInputAnchored -= -> -{ -write -! -( -f -" -anchored -searches -are -not -supported -or -enabled -" -) -} -MatchErrorKind -: -: -InvalidInputUnanchored -= -> -{ -write -! -( -f -" -unanchored -searches -are -not -supported -or -enabled -" -) -} -MatchErrorKind -: -: -UnsupportedStream -{ -got -} -= -> -{ -write -! -( -f -" -match -kind -{ -: -? -} -does -not -support -stream -searching -" -got -) -} -MatchErrorKind -: -: -UnsupportedOverlapping -{ -got -} -= -> -{ -write -! -( -f -" -match -kind -{ -: -? -} -does -not -support -overlapping -searches -" -got -) -} -MatchErrorKind -: -: -UnsupportedEmpty -= -> -{ -write -! -( -f -" -matching -with -an -empty -pattern -string -is -not -\ -supported -for -this -operation -" -) -} -} -} -} diff --git a/third_party/rust/aho-corasick/src/util/int.rs b/third_party/rust/aho-corasick/src/util/int.rs deleted file mode 100644 index d9db4372a98a4..0000000000000 --- a/third_party/rust/aho-corasick/src/util/int.rs +++ /dev/null @@ -1,1476 +0,0 @@ -/ -* -! -This -module -provides -several -integer -oriented -traits -for -converting -between -both -fixed -size -integers -and -integers -whose -size -varies -based -on -the -target -( -like -usize -) -. -The -main -design -principle -for -this -module -is -to -centralize -all -uses -of -as -. -The -thinking -here -is -that -as -makes -it -very -easy -to -perform -accidental -lossy -conversions -and -if -we -centralize -all -its -uses -here -under -more -descriptive -higher -level -operations -its -use -and -correctness -becomes -easier -to -audit -. -This -was -copied -mostly -wholesale -from -regex -- -automata -. -NOTE -: -for -simplicity -we -don -' -t -take -target -pointer -width -into -account -here -for -usize -conversions -. -Since -we -currently -only -panic -in -debug -mode -skipping -the -check -when -it -can -be -proven -it -isn -' -t -needed -at -compile -time -doesn -' -t -really -matter -. -Now -if -we -wind -up -wanting -to -do -as -many -checks -as -possible -in -release -mode -then -we -would -want -to -skip -those -when -we -know -the -conversions -are -always -non -- -lossy -. -* -/ -pub -( -crate -) -trait -U8 -{ -fn -as_usize -( -self -) -- -> -usize -; -} -impl -U8 -for -u8 -{ -fn -as_usize -( -self -) -- -> -usize -{ -usize -: -: -from -( -self -) -} -} -pub -( -crate -) -trait -U16 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -low_u8 -( -self -) -- -> -u8 -; -fn -high_u8 -( -self -) -- -> -u8 -; -} -impl -U16 -for -u16 -{ -fn -as_usize -( -self -) -- -> -usize -{ -usize -: -: -from -( -self -) -} -fn -low_u8 -( -self -) -- -> -u8 -{ -self -as -u8 -} -fn -high_u8 -( -self -) -- -> -u8 -{ -( -self -> -> -8 -) -as -u8 -} -} -pub -( -crate -) -trait -U32 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -low_u8 -( -self -) -- -> -u8 -; -fn -low_u16 -( -self -) -- -> -u16 -; -fn -high_u16 -( -self -) -- -> -u16 -; -} -impl -U32 -for -u32 -{ -# -[ -inline -] -fn -as_usize -( -self -) -- -> -usize -{ -# -[ -cfg -( -debug_assertions -) -] -{ -usize -: -: -try_from -( -self -) -. -expect -( -" -u32 -overflowed -usize -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -usize -} -} -fn -low_u8 -( -self -) -- -> -u8 -{ -self -as -u8 -} -fn -low_u16 -( -self -) -- -> -u16 -{ -self -as -u16 -} -fn -high_u16 -( -self -) -- -> -u16 -{ -( -self -> -> -16 -) -as -u16 -} -} -pub -( -crate -) -trait -U64 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -low_u8 -( -self -) -- -> -u8 -; -fn -low_u16 -( -self -) -- -> -u16 -; -fn -low_u32 -( -self -) -- -> -u32 -; -fn -high_u32 -( -self -) -- -> -u32 -; -} -impl -U64 -for -u64 -{ -fn -as_usize -( -self -) -- -> -usize -{ -# -[ -cfg -( -debug_assertions -) -] -{ -usize -: -: -try_from -( -self -) -. -expect -( -" -u64 -overflowed -usize -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -usize -} -} -fn -low_u8 -( -self -) -- -> -u8 -{ -self -as -u8 -} -fn -low_u16 -( -self -) -- -> -u16 -{ -self -as -u16 -} -fn -low_u32 -( -self -) -- -> -u32 -{ -self -as -u32 -} -fn -high_u32 -( -self -) -- -> -u32 -{ -( -self -> -> -32 -) -as -u32 -} -} -pub -( -crate -) -trait -I8 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -to_bits -( -self -) -- -> -u8 -; -fn -from_bits -( -n -: -u8 -) -- -> -i8 -; -} -impl -I8 -for -i8 -{ -fn -as_usize -( -self -) -- -> -usize -{ -# -[ -cfg -( -debug_assertions -) -] -{ -usize -: -: -try_from -( -self -) -. -expect -( -" -i8 -overflowed -usize -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -usize -} -} -fn -to_bits -( -self -) -- -> -u8 -{ -self -as -u8 -} -fn -from_bits -( -n -: -u8 -) -- -> -i8 -{ -n -as -i8 -} -} -pub -( -crate -) -trait -I32 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -to_bits -( -self -) -- -> -u32 -; -fn -from_bits -( -n -: -u32 -) -- -> -i32 -; -} -impl -I32 -for -i32 -{ -fn -as_usize -( -self -) -- -> -usize -{ -# -[ -cfg -( -debug_assertions -) -] -{ -usize -: -: -try_from -( -self -) -. -expect -( -" -i32 -overflowed -usize -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -usize -} -} -fn -to_bits -( -self -) -- -> -u32 -{ -self -as -u32 -} -fn -from_bits -( -n -: -u32 -) -- -> -i32 -{ -n -as -i32 -} -} -pub -( -crate -) -trait -I64 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -to_bits -( -self -) -- -> -u64 -; -fn -from_bits -( -n -: -u64 -) -- -> -i64 -; -} -impl -I64 -for -i64 -{ -fn -as_usize -( -self -) -- -> -usize -{ -# -[ -cfg -( -debug_assertions -) -] -{ -usize -: -: -try_from -( -self -) -. -expect -( -" -i64 -overflowed -usize -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -usize -} -} -fn -to_bits -( -self -) -- -> -u64 -{ -self -as -u64 -} -fn -from_bits -( -n -: -u64 -) -- -> -i64 -{ -n -as -i64 -} -} -pub -( -crate -) -trait -Usize -{ -fn -as_u8 -( -self -) -- -> -u8 -; -fn -as_u16 -( -self -) -- -> -u16 -; -fn -as_u32 -( -self -) -- -> -u32 -; -fn -as_u64 -( -self -) -- -> -u64 -; -} -impl -Usize -for -usize -{ -fn -as_u8 -( -self -) -- -> -u8 -{ -# -[ -cfg -( -debug_assertions -) -] -{ -u8 -: -: -try_from -( -self -) -. -expect -( -" -usize -overflowed -u8 -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -u8 -} -} -fn -as_u16 -( -self -) -- -> -u16 -{ -# -[ -cfg -( -debug_assertions -) -] -{ -u16 -: -: -try_from -( -self -) -. -expect -( -" -usize -overflowed -u16 -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -u16 -} -} -fn -as_u32 -( -self -) -- -> -u32 -{ -# -[ -cfg -( -debug_assertions -) -] -{ -u32 -: -: -try_from -( -self -) -. -expect -( -" -usize -overflowed -u32 -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -u32 -} -} -fn -as_u64 -( -self -) -- -> -u64 -{ -# -[ -cfg -( -debug_assertions -) -] -{ -u64 -: -: -try_from -( -self -) -. -expect -( -" -usize -overflowed -u64 -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -u64 -} -} -} -/ -/ -Pointers -aren -' -t -integers -but -we -convert -pointers -to -integers -to -perform -/ -/ -offset -arithmetic -in -some -places -. -( -And -no -we -don -' -t -convert -the -integers -/ -/ -back -to -pointers -. -) -So -add -' -as_usize -' -conversions -here -too -for -completeness -. -/ -/ -/ -/ -These -' -as -' -casts -are -actually -okay -because -they -' -re -always -non -- -lossy -. -But -the -/ -/ -idea -here -is -to -just -try -and -remove -as -much -' -as -' -as -possible -particularly -/ -/ -in -this -crate -where -we -are -being -really -paranoid -about -offsets -and -making -/ -/ -sure -we -don -' -t -panic -on -inputs -that -might -be -untrusted -. -This -way -the -' -as -' -/ -/ -casts -become -easier -to -audit -if -they -' -re -all -in -one -place -even -when -some -of -/ -/ -them -are -actually -okay -100 -% -of -the -time -. -pub -( -crate -) -trait -Pointer -{ -fn -as_usize -( -self -) -- -> -usize -; -} -impl -< -T -> -Pointer -for -* -const -T -{ -fn -as_usize -( -self -) -- -> -usize -{ -self -as -usize -} -} -pub -( -crate -) -trait -PointerMut -{ -fn -as_usize -( -self -) -- -> -usize -; -} -impl -< -T -> -PointerMut -for -* -mut -T -{ -fn -as_usize -( -self -) -- -> -usize -{ -self -as -usize -} -} diff --git a/third_party/rust/aho-corasick/src/util/mod.rs b/third_party/rust/aho-corasick/src/util/mod.rs deleted file mode 100644 index 9587fd58b7993..0000000000000 --- a/third_party/rust/aho-corasick/src/util/mod.rs +++ /dev/null @@ -1,88 +0,0 @@ -pub -( -crate -) -mod -alphabet -; -# -[ -cfg -( -feature -= -" -std -" -) -] -pub -( -crate -) -mod -buffer -; -pub -( -crate -) -mod -byte_frequencies -; -pub -( -crate -) -mod -debug -; -pub -( -crate -) -mod -error -; -pub -( -crate -) -mod -int -; -pub -( -crate -) -mod -prefilter -; -pub -( -crate -) -mod -primitives -; -pub -( -crate -) -mod -remapper -; -pub -( -crate -) -mod -search -; -pub -( -crate -) -mod -special -; diff --git a/third_party/rust/aho-corasick/src/util/primitives.rs b/third_party/rust/aho-corasick/src/util/primitives.rs deleted file mode 100644 index 81e6293ac8e9a..0000000000000 --- a/third_party/rust/aho-corasick/src/util/primitives.rs +++ /dev/null @@ -1,6005 +0,0 @@ -/ -* -! -Lower -level -primitive -types -that -are -useful -in -a -variety -of -circumstances -. -# -Overview -This -list -represents -the -principle -types -in -this -module -and -briefly -describes -when -you -might -want -to -use -them -. -* -[ -PatternID -] -- -A -type -that -represents -the -identifier -of -a -regex -pattern -. -This -is -probably -the -most -widely -used -type -in -this -module -( -which -is -why -it -' -s -also -re -- -exported -in -the -crate -root -) -. -* -[ -StateID -] -- -A -type -the -represents -the -identifier -of -a -finite -automaton -state -. -This -is -used -for -both -NFAs -and -DFAs -with -the -notable -exception -of -the -hybrid -NFA -/ -DFA -. -( -The -hybrid -NFA -/ -DFA -uses -a -special -purpose -" -lazy -" -state -identifier -. -) -* -[ -SmallIndex -] -- -The -internal -representation -of -both -a -PatternID -and -a -StateID -. -Its -purpose -is -to -serve -as -a -type -that -can -index -memory -without -being -as -big -as -a -usize -on -64 -- -bit -targets -. -The -main -idea -behind -this -type -is -that -there -are -many -things -in -regex -engines -that -will -in -practice -never -overflow -a -32 -- -bit -integer -. -( -For -example -like -the -number -of -patterns -in -a -regex -or -the -number -of -states -in -an -NFA -. -) -Thus -a -SmallIndex -can -be -used -to -index -memory -without -peppering -as -casts -everywhere -. -Moreover -it -forces -callers -to -handle -errors -in -the -case -where -somehow -the -value -would -otherwise -overflow -either -a -32 -- -bit -integer -or -a -usize -( -e -. -g -. -on -16 -- -bit -targets -) -. -* -/ -/ -/ -The -macro -we -use -to -define -some -types -below -adds -methods -that -we -don -' -t -/ -/ -use -on -some -of -the -types -. -There -isn -' -t -much -so -we -just -squash -the -warning -. -# -! -[ -allow -( -dead_code -) -] -use -alloc -: -: -vec -: -: -Vec -; -use -crate -: -: -util -: -: -int -: -: -{ -Usize -U16 -U32 -U64 -} -; -/ -/ -/ -A -type -that -represents -a -" -small -" -index -. -/ -/ -/ -/ -/ -/ -The -main -idea -of -this -type -is -to -provide -something -that -can -index -memory -/ -/ -/ -but -uses -less -memory -than -usize -on -64 -- -bit -systems -. -Specifically -its -/ -/ -/ -representation -is -always -a -u32 -and -has -repr -( -transparent -) -enabled -. -( -So -/ -/ -/ -it -is -safe -to -transmute -between -a -u32 -and -a -SmallIndex -. -) -/ -/ -/ -/ -/ -/ -A -small -index -is -typically -useful -in -cases -where -there -is -no -practical -way -/ -/ -/ -that -the -index -will -overflow -a -32 -- -bit -integer -. -A -good -example -of -this -is -/ -/ -/ -an -NFA -state -. -If -you -could -somehow -build -an -NFA -with -2 -^ -30 -states -its -/ -/ -/ -memory -usage -would -be -exorbitant -and -its -runtime -execution -would -be -so -/ -/ -/ -slow -as -to -be -completely -worthless -. -Therefore -this -crate -generally -deems -/ -/ -/ -it -acceptable -to -return -an -error -if -it -would -otherwise -build -an -NFA -that -/ -/ -/ -requires -a -slice -longer -than -what -a -32 -- -bit -integer -can -index -. -In -exchange -/ -/ -/ -we -can -use -32 -- -bit -indices -instead -of -64 -- -bit -indices -in -various -places -. -/ -/ -/ -/ -/ -/ -This -type -ensures -this -by -providing -a -constructor -that -will -return -an -error -/ -/ -/ -if -its -argument -cannot -fit -into -the -type -. -This -makes -it -much -easier -to -/ -/ -/ -handle -these -sorts -of -boundary -cases -that -are -otherwise -extremely -subtle -. -/ -/ -/ -/ -/ -/ -On -all -targets -this -type -guarantees -that -its -value -will -fit -in -a -u32 -/ -/ -/ -i32 -usize -and -an -isize -. -This -means -that -on -16 -- -bit -targets -for -/ -/ -/ -example -this -type -' -s -maximum -value -will -never -overflow -an -isize -/ -/ -/ -which -means -it -will -never -overflow -a -i16 -even -though -its -internal -/ -/ -/ -representation -is -still -a -u32 -. -/ -/ -/ -/ -/ -/ -The -purpose -for -making -the -type -fit -into -even -signed -integer -types -like -/ -/ -/ -isize -is -to -guarantee -that -the -difference -between -any -two -small -indices -/ -/ -/ -is -itself -also -a -small -index -. -This -is -useful -in -certain -contexts -e -. -g -. -/ -/ -/ -for -delta -encoding -. -/ -/ -/ -/ -/ -/ -# -Other -types -/ -/ -/ -/ -/ -/ -The -following -types -wrap -SmallIndex -to -provide -a -more -focused -use -case -: -/ -/ -/ -/ -/ -/ -* -[ -PatternID -] -is -for -representing -the -identifiers -of -patterns -. -/ -/ -/ -* -[ -StateID -] -is -for -representing -the -identifiers -of -states -in -finite -/ -/ -/ -automata -. -It -is -used -for -both -NFAs -and -DFAs -. -/ -/ -/ -/ -/ -/ -# -Representation -/ -/ -/ -/ -/ -/ -This -type -is -always -represented -internally -by -a -u32 -and -is -marked -as -/ -/ -/ -repr -( -transparent -) -. -Thus -this -type -always -has -the -same -representation -as -/ -/ -/ -a -u32 -. -It -is -thus -safe -to -transmute -between -a -u32 -and -a -SmallIndex -. -/ -/ -/ -/ -/ -/ -# -Indexing -/ -/ -/ -/ -/ -/ -For -convenience -callers -may -use -a -SmallIndex -to -index -slices -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -While -a -SmallIndex -is -meant -to -guarantee -that -its -value -fits -into -usize -/ -/ -/ -without -using -as -much -space -as -a -usize -on -all -targets -callers -must -/ -/ -/ -not -rely -on -this -property -for -safety -. -Callers -may -choose -to -rely -on -this -/ -/ -/ -property -for -correctness -however -. -For -example -creating -a -SmallIndex -with -/ -/ -/ -an -invalid -value -can -be -done -in -entirely -safe -code -. -This -may -in -turn -result -/ -/ -/ -in -panics -or -silent -logical -errors -. -# -[ -derive -( -Clone -Copy -Debug -Default -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -# -[ -repr -( -transparent -) -] -pub -( -crate -) -struct -SmallIndex -( -u32 -) -; -impl -SmallIndex -{ -/ -/ -/ -The -maximum -index -value -. -# -[ -cfg -( -any -( -target_pointer_width -= -" -32 -" -target_pointer_width -= -" -64 -" -) -) -] -pub -const -MAX -: -SmallIndex -= -/ -/ -FIXME -: -Use -as_usize -( -) -once -const -functions -in -traits -are -stable -. -SmallIndex -: -: -new_unchecked -( -core -: -: -i32 -: -: -MAX -as -usize -- -1 -) -; -/ -/ -/ -The -maximum -index -value -. -# -[ -cfg -( -target_pointer_width -= -" -16 -" -) -] -pub -const -MAX -: -SmallIndex -= -SmallIndex -: -: -new_unchecked -( -core -: -: -isize -: -: -MAX -- -1 -) -; -/ -/ -/ -The -total -number -of -values -that -can -be -represented -as -a -small -index -. -pub -const -LIMIT -: -usize -= -SmallIndex -: -: -MAX -. -as_usize -( -) -+ -1 -; -/ -/ -/ -The -zero -index -value -. -pub -const -ZERO -: -SmallIndex -= -SmallIndex -: -: -new_unchecked -( -0 -) -; -/ -/ -/ -The -number -of -bytes -that -a -single -small -index -uses -in -memory -. -pub -const -SIZE -: -usize -= -core -: -: -mem -: -: -size_of -: -: -< -SmallIndex -> -( -) -; -/ -/ -/ -Create -a -new -small -index -. -/ -/ -/ -/ -/ -/ -If -the -given -index -exceeds -[ -SmallIndex -: -: -MAX -] -then -this -returns -/ -/ -/ -an -error -. -# -[ -inline -] -pub -fn -new -( -index -: -usize -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -SmallIndex -: -: -try_from -( -index -) -} -/ -/ -/ -Create -a -new -small -index -without -checking -whether -the -given -value -/ -/ -/ -exceeds -[ -SmallIndex -: -: -MAX -] -. -/ -/ -/ -/ -/ -/ -Using -this -routine -with -an -invalid -index -value -will -result -in -/ -/ -/ -unspecified -behavior -but -* -not -* -undefined -behavior -. -In -particular -an -/ -/ -/ -invalid -index -value -is -likely -to -cause -panics -or -possibly -even -silent -/ -/ -/ -logical -errors -. -/ -/ -/ -/ -/ -/ -Callers -must -never -rely -on -a -SmallIndex -to -be -within -a -certain -range -/ -/ -/ -for -memory -safety -. -# -[ -inline -] -pub -const -fn -new_unchecked -( -index -: -usize -) -- -> -SmallIndex -{ -/ -/ -FIXME -: -Use -as_u32 -( -) -once -const -functions -in -traits -are -stable -. -SmallIndex -: -: -from_u32_unchecked -( -index -as -u32 -) -} -/ -/ -/ -Create -a -new -small -index -from -a -u32 -without -checking -whether -the -/ -/ -/ -given -value -exceeds -[ -SmallIndex -: -: -MAX -] -. -/ -/ -/ -/ -/ -/ -Using -this -routine -with -an -invalid -index -value -will -result -in -/ -/ -/ -unspecified -behavior -but -* -not -* -undefined -behavior -. -In -particular -an -/ -/ -/ -invalid -index -value -is -likely -to -cause -panics -or -possibly -even -silent -/ -/ -/ -logical -errors -. -/ -/ -/ -/ -/ -/ -Callers -must -never -rely -on -a -SmallIndex -to -be -within -a -certain -range -/ -/ -/ -for -memory -safety -. -# -[ -inline -] -pub -const -fn -from_u32_unchecked -( -index -: -u32 -) -- -> -SmallIndex -{ -SmallIndex -( -index -) -} -/ -/ -/ -Like -[ -SmallIndex -: -: -new -] -but -panics -if -the -given -index -is -not -valid -. -# -[ -inline -] -pub -fn -must -( -index -: -usize -) -- -> -SmallIndex -{ -SmallIndex -: -: -new -( -index -) -. -expect -( -" -invalid -small -index -" -) -} -/ -/ -/ -Return -this -small -index -as -a -usize -. -This -is -guaranteed -to -never -/ -/ -/ -overflow -usize -. -# -[ -inline -] -pub -const -fn -as_usize -( -& -self -) -- -> -usize -{ -/ -/ -FIXME -: -Use -as_usize -( -) -once -const -functions -in -traits -are -stable -. -self -. -0 -as -usize -} -/ -/ -/ -Return -this -small -index -as -a -u64 -. -This -is -guaranteed -to -never -/ -/ -/ -overflow -. -# -[ -inline -] -pub -const -fn -as_u64 -( -& -self -) -- -> -u64 -{ -/ -/ -FIXME -: -Use -u64 -: -: -from -( -) -once -const -functions -in -traits -are -stable -. -self -. -0 -as -u64 -} -/ -/ -/ -Return -the -internal -u32 -of -this -small -index -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -u32 -. -# -[ -inline -] -pub -const -fn -as_u32 -( -& -self -) -- -> -u32 -{ -self -. -0 -} -/ -/ -/ -Return -the -internal -u32 -of -this -small -index -represented -as -an -i32 -. -/ -/ -/ -This -is -guaranteed -to -never -overflow -an -i32 -. -# -[ -inline -] -pub -const -fn -as_i32 -( -& -self -) -- -> -i32 -{ -/ -/ -This -is -OK -because -we -guarantee -that -our -max -value -is -< -= -i32 -: -: -MAX -. -self -. -0 -as -i32 -} -/ -/ -/ -Returns -one -more -than -this -small -index -as -a -usize -. -/ -/ -/ -/ -/ -/ -Since -a -small -index -has -constraints -on -its -maximum -value -adding -1 -to -/ -/ -/ -it -will -always -fit -in -a -usize -isize -u32 -and -a -i32 -. -# -[ -inline -] -pub -fn -one_more -( -& -self -) -- -> -usize -{ -self -. -as_usize -( -) -+ -1 -} -/ -/ -/ -Decode -this -small -index -from -the -bytes -given -using -the -native -endian -/ -/ -/ -byte -order -for -the -current -target -. -/ -/ -/ -/ -/ -/ -If -the -decoded -integer -is -not -representable -as -a -small -index -for -the -/ -/ -/ -current -target -then -this -returns -an -error -. -# -[ -inline -] -pub -fn -from_ne_bytes -( -bytes -: -[ -u8 -; -4 -] -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -let -id -= -u32 -: -: -from_ne_bytes -( -bytes -) -; -if -id -> -SmallIndex -: -: -MAX -. -as_u32 -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -u64 -: -: -from -( -id -) -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -id -. -as_usize -( -) -) -) -} -/ -/ -/ -Decode -this -small -index -from -the -bytes -given -using -the -native -endian -/ -/ -/ -byte -order -for -the -current -target -. -/ -/ -/ -/ -/ -/ -This -is -analogous -to -[ -SmallIndex -: -: -new_unchecked -] -in -that -is -does -not -/ -/ -/ -check -whether -the -decoded -integer -is -representable -as -a -small -index -. -# -[ -inline -] -pub -fn -from_ne_bytes_unchecked -( -bytes -: -[ -u8 -; -4 -] -) -- -> -SmallIndex -{ -SmallIndex -: -: -new_unchecked -( -u32 -: -: -from_ne_bytes -( -bytes -) -. -as_usize -( -) -) -} -/ -/ -/ -Return -the -underlying -small -index -integer -as -raw -bytes -in -native -endian -/ -/ -/ -format -. -# -[ -inline -] -pub -fn -to_ne_bytes -( -& -self -) -- -> -[ -u8 -; -4 -] -{ -self -. -0 -. -to_ne_bytes -( -) -} -} -impl -< -T -> -core -: -: -ops -: -: -Index -< -SmallIndex -> -for -[ -T -] -{ -type -Output -= -T -; -# -[ -inline -] -fn -index -( -& -self -index -: -SmallIndex -) -- -> -& -T -{ -& -self -[ -index -. -as_usize -( -) -] -} -} -impl -< -T -> -core -: -: -ops -: -: -IndexMut -< -SmallIndex -> -for -[ -T -] -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -SmallIndex -) -- -> -& -mut -T -{ -& -mut -self -[ -index -. -as_usize -( -) -] -} -} -impl -< -T -> -core -: -: -ops -: -: -Index -< -SmallIndex -> -for -Vec -< -T -> -{ -type -Output -= -T -; -# -[ -inline -] -fn -index -( -& -self -index -: -SmallIndex -) -- -> -& -T -{ -& -self -[ -index -. -as_usize -( -) -] -} -} -impl -< -T -> -core -: -: -ops -: -: -IndexMut -< -SmallIndex -> -for -Vec -< -T -> -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -SmallIndex -) -- -> -& -mut -T -{ -& -mut -self -[ -index -. -as_usize -( -) -] -} -} -impl -From -< -StateID -> -for -SmallIndex -{ -fn -from -( -sid -: -StateID -) -- -> -SmallIndex -{ -sid -. -0 -} -} -impl -From -< -PatternID -> -for -SmallIndex -{ -fn -from -( -pid -: -PatternID -) -- -> -SmallIndex -{ -pid -. -0 -} -} -impl -From -< -u8 -> -for -SmallIndex -{ -fn -from -( -index -: -u8 -) -- -> -SmallIndex -{ -SmallIndex -: -: -new_unchecked -( -usize -: -: -from -( -index -) -) -} -} -impl -TryFrom -< -u16 -> -for -SmallIndex -{ -type -Error -= -SmallIndexError -; -fn -try_from -( -index -: -u16 -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -if -u32 -: -: -from -( -index -) -> -SmallIndex -: -: -MAX -. -as_u32 -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -u64 -: -: -from -( -index -) -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -index -. -as_usize -( -) -) -) -} -} -impl -TryFrom -< -u32 -> -for -SmallIndex -{ -type -Error -= -SmallIndexError -; -fn -try_from -( -index -: -u32 -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -if -index -> -SmallIndex -: -: -MAX -. -as_u32 -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -u64 -: -: -from -( -index -) -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -index -. -as_usize -( -) -) -) -} -} -impl -TryFrom -< -u64 -> -for -SmallIndex -{ -type -Error -= -SmallIndexError -; -fn -try_from -( -index -: -u64 -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -if -index -> -SmallIndex -: -: -MAX -. -as_u64 -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -index -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -index -. -as_usize -( -) -) -) -} -} -impl -TryFrom -< -usize -> -for -SmallIndex -{ -type -Error -= -SmallIndexError -; -fn -try_from -( -index -: -usize -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -if -index -> -SmallIndex -: -: -MAX -. -as_usize -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -index -. -as_u64 -( -) -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -index -) -) -} -} -/ -/ -/ -This -error -occurs -when -a -small -index -could -not -be -constructed -. -/ -/ -/ -/ -/ -/ -This -occurs -when -given -an -integer -exceeding -the -maximum -small -index -value -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -Error -trait -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -SmallIndexError -{ -attempted -: -u64 -} -impl -SmallIndexError -{ -/ -/ -/ -Returns -the -value -that -could -not -be -converted -to -a -small -index -. -pub -fn -attempted -( -& -self -) -- -> -u64 -{ -self -. -attempted -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -SmallIndexError -{ -} -impl -core -: -: -fmt -: -: -Display -for -SmallIndexError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -failed -to -create -small -index -from -{ -: -? -} -which -exceeds -{ -: -? -} -" -self -. -attempted -( -) -SmallIndex -: -: -MAX -) -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -SmallIndexIter -{ -rng -: -core -: -: -ops -: -: -Range -< -usize -> -} -impl -Iterator -for -SmallIndexIter -{ -type -Item -= -SmallIndex -; -fn -next -( -& -mut -self -) -- -> -Option -< -SmallIndex -> -{ -if -self -. -rng -. -start -> -= -self -. -rng -. -end -{ -return -None -; -} -let -next_id -= -self -. -rng -. -start -+ -1 -; -let -id -= -core -: -: -mem -: -: -replace -( -& -mut -self -. -rng -. -start -next_id -) -; -/ -/ -new_unchecked -is -OK -since -we -asserted -that -the -number -of -/ -/ -elements -in -this -iterator -will -fit -in -an -ID -at -construction -. -Some -( -SmallIndex -: -: -new_unchecked -( -id -) -) -} -} -macro_rules -! -index_type_impls -{ -( -name -: -ident -err -: -ident -iter -: -ident -withiter -: -ident -) -= -> -{ -impl -name -{ -/ -/ -/ -The -maximum -value -. -pub -const -MAX -: -name -= -name -( -SmallIndex -: -: -MAX -) -; -/ -/ -/ -The -total -number -of -values -that -can -be -represented -. -pub -const -LIMIT -: -usize -= -SmallIndex -: -: -LIMIT -; -/ -/ -/ -The -zero -value -. -pub -const -ZERO -: -name -= -name -( -SmallIndex -: -: -ZERO -) -; -/ -/ -/ -The -number -of -bytes -that -a -single -value -uses -in -memory -. -pub -const -SIZE -: -usize -= -SmallIndex -: -: -SIZE -; -/ -/ -/ -Create -a -new -value -that -is -represented -by -a -" -small -index -. -" -/ -/ -/ -/ -/ -/ -If -the -given -index -exceeds -the -maximum -allowed -value -then -this -/ -/ -/ -returns -an -error -. -# -[ -inline -] -pub -fn -new -( -value -: -usize -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -new -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -/ -/ -/ -Create -a -new -value -without -checking -whether -the -given -argument -/ -/ -/ -exceeds -the -maximum -. -/ -/ -/ -/ -/ -/ -Using -this -routine -with -an -invalid -value -will -result -in -/ -/ -/ -unspecified -behavior -but -* -not -* -undefined -behavior -. -In -/ -/ -/ -particular -an -invalid -ID -value -is -likely -to -cause -panics -or -/ -/ -/ -possibly -even -silent -logical -errors -. -/ -/ -/ -/ -/ -/ -Callers -must -never -rely -on -this -type -to -be -within -a -certain -/ -/ -/ -range -for -memory -safety -. -# -[ -inline -] -pub -const -fn -new_unchecked -( -value -: -usize -) -- -> -name -{ -name -( -SmallIndex -: -: -new_unchecked -( -value -) -) -} -/ -/ -/ -Create -a -new -value -from -a -u32 -without -checking -whether -the -/ -/ -/ -given -value -exceeds -the -maximum -. -/ -/ -/ -/ -/ -/ -Using -this -routine -with -an -invalid -value -will -result -in -/ -/ -/ -unspecified -behavior -but -* -not -* -undefined -behavior -. -In -/ -/ -/ -particular -an -invalid -ID -value -is -likely -to -cause -panics -or -/ -/ -/ -possibly -even -silent -logical -errors -. -/ -/ -/ -/ -/ -/ -Callers -must -never -rely -on -this -type -to -be -within -a -certain -/ -/ -/ -range -for -memory -safety -. -# -[ -inline -] -pub -const -fn -from_u32_unchecked -( -index -: -u32 -) -- -> -name -{ -name -( -SmallIndex -: -: -from_u32_unchecked -( -index -) -) -} -/ -/ -/ -Like -new -but -panics -if -the -given -value -is -not -valid -. -# -[ -inline -] -pub -fn -must -( -value -: -usize -) -- -> -name -{ -name -: -: -new -( -value -) -. -expect -( -concat -! -( -" -invalid -" -stringify -! -( -name -) -" -value -" -) -) -} -/ -/ -/ -Return -the -internal -value -as -a -usize -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -usize -. -# -[ -inline -] -pub -const -fn -as_usize -( -& -self -) -- -> -usize -{ -self -. -0 -. -as_usize -( -) -} -/ -/ -/ -Return -the -internal -value -as -a -u64 -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -. -# -[ -inline -] -pub -const -fn -as_u64 -( -& -self -) -- -> -u64 -{ -self -. -0 -. -as_u64 -( -) -} -/ -/ -/ -Return -the -internal -value -as -a -u32 -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -u32 -. -# -[ -inline -] -pub -const -fn -as_u32 -( -& -self -) -- -> -u32 -{ -self -. -0 -. -as_u32 -( -) -} -/ -/ -/ -Return -the -internal -value -as -a -i32 -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -an -i32 -. -# -[ -inline -] -pub -const -fn -as_i32 -( -& -self -) -- -> -i32 -{ -self -. -0 -. -as_i32 -( -) -} -/ -/ -/ -Returns -one -more -than -this -value -as -a -usize -. -/ -/ -/ -/ -/ -/ -Since -values -represented -by -a -" -small -index -" -have -constraints -/ -/ -/ -on -their -maximum -value -adding -1 -to -it -will -always -fit -in -a -/ -/ -/ -usize -u32 -and -a -i32 -. -# -[ -inline -] -pub -fn -one_more -( -& -self -) -- -> -usize -{ -self -. -0 -. -one_more -( -) -} -/ -/ -/ -Decode -this -value -from -the -bytes -given -using -the -native -endian -/ -/ -/ -byte -order -for -the -current -target -. -/ -/ -/ -/ -/ -/ -If -the -decoded -integer -is -not -representable -as -a -small -index -/ -/ -/ -for -the -current -target -then -this -returns -an -error -. -# -[ -inline -] -pub -fn -from_ne_bytes -( -bytes -: -[ -u8 -; -4 -] -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -from_ne_bytes -( -bytes -) -. -map -( -name -) -. -map_err -( -err -) -} -/ -/ -/ -Decode -this -value -from -the -bytes -given -using -the -native -endian -/ -/ -/ -byte -order -for -the -current -target -. -/ -/ -/ -/ -/ -/ -This -is -analogous -to -new_unchecked -in -that -is -does -not -check -/ -/ -/ -whether -the -decoded -integer -is -representable -as -a -small -index -. -# -[ -inline -] -pub -fn -from_ne_bytes_unchecked -( -bytes -: -[ -u8 -; -4 -] -) -- -> -name -{ -name -( -SmallIndex -: -: -from_ne_bytes_unchecked -( -bytes -) -) -} -/ -/ -/ -Return -the -underlying -integer -as -raw -bytes -in -native -endian -/ -/ -/ -format -. -# -[ -inline -] -pub -fn -to_ne_bytes -( -& -self -) -- -> -[ -u8 -; -4 -] -{ -self -. -0 -. -to_ne_bytes -( -) -} -/ -/ -/ -Returns -an -iterator -over -all -values -from -0 -up -to -and -not -/ -/ -/ -including -the -given -length -. -/ -/ -/ -/ -/ -/ -If -the -given -length -exceeds -this -type -' -s -limit -then -this -/ -/ -/ -panics -. -pub -( -crate -) -fn -iter -( -len -: -usize -) -- -> -iter -{ -iter -: -: -new -( -len -) -} -} -/ -/ -We -write -our -own -Debug -impl -so -that -we -get -things -like -PatternID -( -5 -) -/ -/ -instead -of -PatternID -( -SmallIndex -( -5 -) -) -. -impl -core -: -: -fmt -: -: -Debug -for -name -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -stringify -! -( -name -) -) -. -field -( -& -self -. -as_u32 -( -) -) -. -finish -( -) -} -} -impl -< -T -> -core -: -: -ops -: -: -Index -< -name -> -for -[ -T -] -{ -type -Output -= -T -; -# -[ -inline -] -fn -index -( -& -self -index -: -name -) -- -> -& -T -{ -& -self -[ -index -. -as_usize -( -) -] -} -} -impl -< -T -> -core -: -: -ops -: -: -IndexMut -< -name -> -for -[ -T -] -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -name -) -- -> -& -mut -T -{ -& -mut -self -[ -index -. -as_usize -( -) -] -} -} -impl -< -T -> -core -: -: -ops -: -: -Index -< -name -> -for -Vec -< -T -> -{ -type -Output -= -T -; -# -[ -inline -] -fn -index -( -& -self -index -: -name -) -- -> -& -T -{ -& -self -[ -index -. -as_usize -( -) -] -} -} -impl -< -T -> -core -: -: -ops -: -: -IndexMut -< -name -> -for -Vec -< -T -> -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -name -) -- -> -& -mut -T -{ -& -mut -self -[ -index -. -as_usize -( -) -] -} -} -impl -From -< -SmallIndex -> -for -name -{ -fn -from -( -index -: -SmallIndex -) -- -> -name -{ -name -( -index -) -} -} -impl -From -< -u8 -> -for -name -{ -fn -from -( -value -: -u8 -) -- -> -name -{ -name -( -SmallIndex -: -: -from -( -value -) -) -} -} -impl -TryFrom -< -u16 -> -for -name -{ -type -Error -= -err -; -fn -try_from -( -value -: -u16 -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -try_from -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -} -impl -TryFrom -< -u32 -> -for -name -{ -type -Error -= -err -; -fn -try_from -( -value -: -u32 -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -try_from -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -} -impl -TryFrom -< -u64 -> -for -name -{ -type -Error -= -err -; -fn -try_from -( -value -: -u64 -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -try_from -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -} -impl -TryFrom -< -usize -> -for -name -{ -type -Error -= -err -; -fn -try_from -( -value -: -usize -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -try_from -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -} -/ -/ -/ -This -error -occurs -when -an -ID -could -not -be -constructed -. -/ -/ -/ -/ -/ -/ -This -occurs -when -given -an -integer -exceeding -the -maximum -allowed -/ -/ -/ -value -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -Error -/ -/ -/ -trait -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -err -( -SmallIndexError -) -; -impl -err -{ -/ -/ -/ -Returns -the -value -that -could -not -be -converted -to -an -ID -. -pub -fn -attempted -( -& -self -) -- -> -u64 -{ -self -. -0 -. -attempted -( -) -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -err -{ -} -impl -core -: -: -fmt -: -: -Display -for -err -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -failed -to -create -{ -} -from -{ -: -? -} -which -exceeds -{ -: -? -} -" -stringify -! -( -name -) -self -. -attempted -( -) -name -: -: -MAX -) -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -iter -( -SmallIndexIter -) -; -impl -iter -{ -fn -new -( -len -: -usize -) -- -> -iter -{ -assert -! -( -len -< -= -name -: -: -LIMIT -" -cannot -create -iterator -for -{ -} -when -number -of -\ -elements -exceed -{ -: -? -} -" -stringify -! -( -name -) -name -: -: -LIMIT -) -; -iter -( -SmallIndexIter -{ -rng -: -0 -. -. -len -} -) -} -} -impl -Iterator -for -iter -{ -type -Item -= -name -; -fn -next -( -& -mut -self -) -- -> -Option -< -name -> -{ -self -. -0 -. -next -( -) -. -map -( -name -) -} -} -/ -/ -/ -An -iterator -adapter -that -is -like -std -: -: -iter -: -: -Enumerate -but -attaches -/ -/ -/ -small -index -values -instead -. -It -requires -ExactSizeIterator -. -At -/ -/ -/ -construction -it -ensures -that -the -index -of -each -element -in -the -/ -/ -/ -iterator -is -representable -in -the -corresponding -small -index -type -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -withiter -< -I -> -{ -it -: -I -ids -: -iter -} -impl -< -I -: -Iterator -+ -ExactSizeIterator -> -withiter -< -I -> -{ -fn -new -( -it -: -I -) -- -> -withiter -< -I -> -{ -let -ids -= -name -: -: -iter -( -it -. -len -( -) -) -; -withiter -{ -it -ids -} -} -} -impl -< -I -: -Iterator -+ -ExactSizeIterator -> -Iterator -for -withiter -< -I -> -{ -type -Item -= -( -name -I -: -: -Item -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -name -I -: -: -Item -) -> -{ -let -item -= -self -. -it -. -next -( -) -? -; -/ -/ -Number -of -elements -in -this -iterator -must -match -according -/ -/ -to -contract -of -ExactSizeIterator -. -let -id -= -self -. -ids -. -next -( -) -. -unwrap -( -) -; -Some -( -( -id -item -) -) -} -} -} -; -} -/ -/ -/ -The -identifier -of -a -pattern -in -an -Aho -- -Corasick -automaton -. -/ -/ -/ -/ -/ -/ -It -is -represented -by -a -u32 -even -on -64 -- -bit -systems -in -order -to -conserve -/ -/ -/ -space -. -Namely -on -all -targets -this -type -guarantees -that -its -value -will -/ -/ -/ -fit -in -a -u32 -i32 -usize -and -an -isize -. -This -means -that -on -16 -- -bit -/ -/ -/ -targets -for -example -this -type -' -s -maximum -value -will -never -overflow -an -/ -/ -/ -isize -which -means -it -will -never -overflow -a -i16 -even -though -its -/ -/ -/ -internal -representation -is -still -a -u32 -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -While -a -PatternID -is -meant -to -guarantee -that -its -value -fits -into -usize -/ -/ -/ -without -using -as -much -space -as -a -usize -on -all -targets -callers -must -/ -/ -/ -not -rely -on -this -property -for -safety -. -Callers -may -choose -to -rely -on -this -/ -/ -/ -property -for -correctness -however -. -For -example -creating -a -StateID -with -an -/ -/ -/ -invalid -value -can -be -done -in -entirely -safe -code -. -This -may -in -turn -result -in -/ -/ -/ -panics -or -silent -logical -errors -. -# -[ -derive -( -Clone -Copy -Default -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -# -[ -repr -( -transparent -) -] -pub -struct -PatternID -( -SmallIndex -) -; -/ -/ -/ -The -identifier -of -a -finite -automaton -state -. -/ -/ -/ -/ -/ -/ -It -is -represented -by -a -u32 -even -on -64 -- -bit -systems -in -order -to -conserve -/ -/ -/ -space -. -Namely -on -all -targets -this -type -guarantees -that -its -value -will -/ -/ -/ -fit -in -a -u32 -i32 -usize -and -an -isize -. -This -means -that -on -16 -- -bit -/ -/ -/ -targets -for -example -this -type -' -s -maximum -value -will -never -overflow -an -/ -/ -/ -isize -which -means -it -will -never -overflow -a -i16 -even -though -its -/ -/ -/ -internal -representation -is -still -a -u32 -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -While -a -StateID -is -meant -to -guarantee -that -its -value -fits -into -usize -/ -/ -/ -without -using -as -much -space -as -a -usize -on -all -targets -callers -must -/ -/ -/ -not -rely -on -this -property -for -safety -. -Callers -may -choose -to -rely -on -this -/ -/ -/ -property -for -correctness -however -. -For -example -creating -a -StateID -with -an -/ -/ -/ -invalid -value -can -be -done -in -entirely -safe -code -. -This -may -in -turn -result -in -/ -/ -/ -panics -or -silent -logical -errors -. -# -[ -derive -( -Clone -Copy -Default -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -# -[ -repr -( -transparent -) -] -pub -struct -StateID -( -SmallIndex -) -; -index_type_impls -! -( -PatternID -PatternIDError -PatternIDIter -WithPatternIDIter -) -; -index_type_impls -! -( -StateID -StateIDError -StateIDIter -WithStateIDIter -) -; -/ -/ -/ -A -utility -trait -that -defines -a -couple -of -adapters -for -making -it -convenient -/ -/ -/ -to -access -indices -as -" -small -index -" -types -. -We -require -ExactSizeIterator -so -/ -/ -/ -that -iterator -construction -can -do -a -single -check -to -make -sure -the -index -of -/ -/ -/ -each -element -is -representable -by -its -small -index -type -. -pub -( -crate -) -trait -IteratorIndexExt -: -Iterator -{ -fn -with_pattern_ids -( -self -) -- -> -WithPatternIDIter -< -Self -> -where -Self -: -Sized -+ -ExactSizeIterator -{ -WithPatternIDIter -: -: -new -( -self -) -} -fn -with_state_ids -( -self -) -- -> -WithStateIDIter -< -Self -> -where -Self -: -Sized -+ -ExactSizeIterator -{ -WithStateIDIter -: -: -new -( -self -) -} -} -impl -< -I -: -Iterator -> -IteratorIndexExt -for -I -{ -} diff --git a/third_party/rust/aho-corasick/src/util/remapper.rs b/third_party/rust/aho-corasick/src/util/remapper.rs deleted file mode 100644 index a32eb857143ee..0000000000000 --- a/third_party/rust/aho-corasick/src/util/remapper.rs +++ /dev/null @@ -1,2201 +0,0 @@ -use -alloc -: -: -vec -: -: -Vec -; -use -crate -: -: -{ -nfa -: -: -noncontiguous -util -: -: -primitives -: -: -StateID -} -; -/ -/ -/ -Remappable -is -a -tightly -coupled -abstraction -that -facilitates -remapping -/ -/ -/ -state -identifiers -in -DFAs -. -/ -/ -/ -/ -/ -/ -The -main -idea -behind -remapping -state -IDs -is -that -DFAs -often -need -to -check -/ -/ -/ -if -a -certain -state -is -a -" -special -" -state -of -some -kind -( -like -a -match -state -) -/ -/ -/ -during -a -search -. -Since -this -is -extremely -perf -critical -code -we -want -this -/ -/ -/ -check -to -be -as -fast -as -possible -. -Partitioning -state -IDs -into -for -example -/ -/ -/ -into -" -non -- -match -" -and -" -match -" -states -means -one -can -tell -if -a -state -is -a -/ -/ -/ -match -state -via -a -simple -comparison -of -the -state -ID -. -/ -/ -/ -/ -/ -/ -The -issue -is -that -during -the -DFA -construction -process -it -' -s -not -/ -/ -/ -particularly -easy -to -partition -the -states -. -Instead -the -simplest -thing -is -/ -/ -/ -to -often -just -do -a -pass -over -all -of -the -states -and -shuffle -them -into -their -/ -/ -/ -desired -partitionings -. -To -do -that -we -need -a -mechanism -for -swapping -states -. -/ -/ -/ -Hence -this -abstraction -. -/ -/ -/ -/ -/ -/ -Normally -for -such -little -code -I -would -just -duplicate -it -. -But -this -is -a -/ -/ -/ -key -optimization -and -the -implementation -is -a -bit -subtle -. -So -the -abstraction -/ -/ -/ -is -basically -a -ham -- -fisted -attempt -at -DRY -. -The -only -place -we -use -this -is -in -/ -/ -/ -the -dense -and -one -- -pass -DFAs -. -/ -/ -/ -/ -/ -/ -See -also -src -/ -dfa -/ -special -. -rs -for -a -more -detailed -explanation -of -how -dense -/ -/ -/ -DFAs -are -partitioned -. -pub -( -crate -) -trait -Remappable -: -core -: -: -fmt -: -: -Debug -{ -/ -/ -/ -Return -the -total -number -of -states -. -fn -state_len -( -& -self -) -- -> -usize -; -/ -/ -/ -Swap -the -states -pointed -to -by -the -given -IDs -. -The -underlying -finite -/ -/ -/ -state -machine -should -be -mutated -such -that -all -of -the -transitions -in -/ -/ -/ -id1 -are -now -in -the -memory -region -where -the -transitions -for -id2 -/ -/ -/ -were -and -all -of -the -transitions -in -id2 -are -now -in -the -memory -region -/ -/ -/ -where -the -transitions -for -id1 -were -. -/ -/ -/ -/ -/ -/ -Essentially -this -" -moves -" -id1 -to -id2 -and -id2 -to -id1 -. -/ -/ -/ -/ -/ -/ -It -is -expected -that -after -calling -this -the -underlying -state -machine -/ -/ -/ -will -be -left -in -an -inconsistent -state -since -any -other -transitions -/ -/ -/ -pointing -to -e -. -g -. -id1 -need -to -be -updated -to -point -to -id2 -since -/ -/ -/ -that -' -s -where -id1 -moved -to -. -/ -/ -/ -/ -/ -/ -In -order -to -" -fix -" -the -underlying -inconsistent -state -a -Remapper -/ -/ -/ -should -be -used -to -guarantee -that -remap -is -called -at -the -appropriate -/ -/ -/ -time -. -fn -swap_states -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -; -/ -/ -/ -This -must -remap -every -single -state -ID -in -the -underlying -value -according -/ -/ -/ -to -the -function -given -. -For -example -in -a -DFA -this -should -remap -every -/ -/ -/ -transition -and -every -starting -state -ID -. -fn -remap -( -& -mut -self -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -; -} -/ -/ -/ -Remapper -is -an -abstraction -the -manages -the -remapping -of -state -IDs -in -a -/ -/ -/ -finite -state -machine -. -This -is -useful -when -one -wants -to -shuffle -states -into -/ -/ -/ -different -positions -in -the -machine -. -/ -/ -/ -/ -/ -/ -One -of -the -key -complexities -this -manages -is -the -ability -to -correctly -move -/ -/ -/ -one -state -multiple -times -. -/ -/ -/ -/ -/ -/ -Once -shuffling -is -complete -remap -must -be -called -which -will -rewrite -/ -/ -/ -all -pertinent -transitions -to -updated -state -IDs -. -Neglecting -to -call -remap -/ -/ -/ -will -almost -certainly -result -in -a -corrupt -machine -. -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -Remapper -{ -/ -/ -/ -A -map -from -the -index -of -a -state -to -its -pre -- -multiplied -identifier -. -/ -/ -/ -/ -/ -/ -When -a -state -is -swapped -with -another -then -their -corresponding -/ -/ -/ -locations -in -this -map -are -also -swapped -. -Thus -its -new -position -will -/ -/ -/ -still -point -to -its -old -pre -- -multiplied -StateID -. -/ -/ -/ -/ -/ -/ -While -there -is -a -bit -more -to -it -this -then -allows -us -to -rewrite -the -/ -/ -/ -state -IDs -in -a -DFA -' -s -transition -table -in -a -single -pass -. -This -is -done -/ -/ -/ -by -iterating -over -every -ID -in -this -map -then -iterating -over -each -/ -/ -/ -transition -for -the -state -at -that -ID -and -re -- -mapping -the -transition -from -/ -/ -/ -old_id -to -map -[ -dfa -. -to_index -( -old_id -) -] -. -That -is -we -find -the -position -/ -/ -/ -in -this -map -where -old_id -* -started -* -and -set -it -to -where -it -ended -up -/ -/ -/ -after -all -swaps -have -been -completed -. -map -: -Vec -< -StateID -> -/ -/ -/ -A -way -to -map -indices -to -state -IDs -( -and -back -) -. -idx -: -IndexMapper -} -impl -Remapper -{ -/ -/ -/ -Create -a -new -remapper -from -the -given -remappable -implementation -. -The -/ -/ -/ -remapper -can -then -be -used -to -swap -states -. -The -remappable -value -given -/ -/ -/ -here -must -the -same -one -given -to -swap -and -remap -. -/ -/ -/ -/ -/ -/ -The -given -stride -should -be -the -stride -of -the -transition -table -expressed -/ -/ -/ -as -a -power -of -2 -. -This -stride -is -used -to -map -between -state -IDs -and -state -/ -/ -/ -indices -. -If -state -IDs -and -state -indices -are -equivalent -then -provide -/ -/ -/ -a -stride2 -of -0 -which -acts -as -an -identity -. -pub -( -crate -) -fn -new -( -r -: -& -impl -Remappable -stride2 -: -usize -) -- -> -Remapper -{ -let -idx -= -IndexMapper -{ -stride2 -} -; -let -map -= -( -0 -. -. -r -. -state_len -( -) -) -. -map -( -| -i -| -idx -. -to_state_id -( -i -) -) -. -collect -( -) -; -Remapper -{ -map -idx -} -} -/ -/ -/ -Swap -two -states -. -Once -this -is -called -callers -must -follow -through -to -/ -/ -/ -call -remap -or -else -it -' -s -possible -for -the -underlying -remappable -/ -/ -/ -value -to -be -in -a -corrupt -state -. -pub -( -crate -) -fn -swap -( -& -mut -self -r -: -& -mut -impl -Remappable -id1 -: -StateID -id2 -: -StateID -) -{ -if -id1 -= -= -id2 -{ -return -; -} -r -. -swap_states -( -id1 -id2 -) -; -self -. -map -. -swap -( -self -. -idx -. -to_index -( -id1 -) -self -. -idx -. -to_index -( -id2 -) -) -; -} -/ -/ -/ -Complete -the -remapping -process -by -rewriting -all -state -IDs -in -the -/ -/ -/ -remappable -value -according -to -the -swaps -performed -. -pub -( -crate -) -fn -remap -( -mut -self -r -: -& -mut -impl -Remappable -) -{ -/ -/ -Update -the -map -to -account -for -states -that -have -been -swapped -/ -/ -multiple -times -. -For -example -if -( -A -C -) -and -( -C -G -) -are -swapped -then -/ -/ -transitions -previously -pointing -to -A -should -now -point -to -G -. -But -if -/ -/ -we -don -' -t -update -our -map -they -will -erroneously -be -set -to -C -. -All -we -/ -/ -do -is -follow -the -swaps -in -our -map -until -we -see -our -original -state -/ -/ -ID -. -/ -/ -/ -/ -The -intuition -here -is -to -think -about -how -changes -are -made -to -the -/ -/ -map -: -only -through -pairwise -swaps -. -That -means -that -starting -at -any -/ -/ -given -state -it -is -always -possible -to -find -the -loop -back -to -that -/ -/ -state -by -following -the -swaps -represented -in -the -map -( -which -might -be -/ -/ -0 -swaps -) -. -/ -/ -/ -/ -We -are -also -careful -to -clone -the -map -before -starting -in -order -to -/ -/ -freeze -it -. -We -use -the -frozen -map -to -find -our -loops -since -we -need -to -/ -/ -update -our -map -as -well -. -Without -freezing -it -our -updates -could -break -/ -/ -the -loops -referenced -above -and -produce -incorrect -results -. -let -oldmap -= -self -. -map -. -clone -( -) -; -for -i -in -0 -. -. -r -. -state_len -( -) -{ -let -cur_id -= -self -. -idx -. -to_state_id -( -i -) -; -let -mut -new_id -= -oldmap -[ -i -] -; -if -cur_id -= -= -new_id -{ -continue -; -} -loop -{ -let -id -= -oldmap -[ -self -. -idx -. -to_index -( -new_id -) -] -; -if -cur_id -= -= -id -{ -self -. -map -[ -i -] -= -new_id -; -break -; -} -new_id -= -id -; -} -} -r -. -remap -( -| -sid -| -self -. -map -[ -self -. -idx -. -to_index -( -sid -) -] -) -; -} -} -/ -/ -/ -A -simple -type -for -mapping -between -state -indices -and -state -IDs -. -/ -/ -/ -/ -/ -/ -The -reason -why -this -exists -is -because -state -IDs -are -" -premultiplied -" -in -a -/ -/ -/ -DFA -. -That -is -in -order -to -get -to -the -transitions -for -a -particular -state -/ -/ -/ -one -need -only -use -the -state -ID -as -- -is -instead -of -having -to -multiply -it -by -/ -/ -/ -transition -table -' -s -stride -. -/ -/ -/ -/ -/ -/ -The -downside -of -this -is -that -it -' -s -inconvenient -to -map -between -state -IDs -/ -/ -/ -using -a -dense -map -e -. -g -. -Vec -< -StateID -> -. -That -' -s -because -state -IDs -look -like -/ -/ -/ -0 -stride -2 -* -stride -3 -* -stride -etc -. -instead -of -0 -1 -2 -3 -/ -/ -/ -etc -. -/ -/ -/ -/ -/ -/ -Since -our -state -IDs -are -premultiplied -we -can -convert -back -- -and -- -forth -/ -/ -/ -between -IDs -and -indices -by -simply -unmultiplying -the -IDs -and -multiplying -the -/ -/ -/ -indices -. -/ -/ -/ -/ -/ -/ -Note -that -for -a -sparse -NFA -state -IDs -and -indices -are -equivalent -. -In -this -/ -/ -/ -case -we -set -the -stride -of -the -index -mapped -to -be -0 -which -acts -as -an -/ -/ -/ -identity -. -# -[ -derive -( -Debug -) -] -struct -IndexMapper -{ -/ -/ -/ -The -power -of -2 -corresponding -to -the -stride -of -the -corresponding -/ -/ -/ -transition -table -. -' -id -> -> -stride2 -' -de -- -multiplies -an -ID -while -' -index -< -< -/ -/ -/ -stride2 -' -pre -- -multiplies -an -index -to -an -ID -. -stride2 -: -usize -} -impl -IndexMapper -{ -/ -/ -/ -Convert -a -state -ID -to -a -state -index -. -fn -to_index -( -& -self -id -: -StateID -) -- -> -usize -{ -id -. -as_usize -( -) -> -> -self -. -stride2 -} -/ -/ -/ -Convert -a -state -index -to -a -state -ID -. -fn -to_state_id -( -& -self -index -: -usize -) -- -> -StateID -{ -/ -/ -CORRECTNESS -: -If -the -given -index -is -not -valid -then -it -is -not -/ -/ -required -for -this -to -panic -or -return -a -valid -state -ID -. -We -' -ll -" -just -" -/ -/ -wind -up -with -panics -or -silent -logic -errors -at -some -other -point -. -But -/ -/ -this -is -OK -because -if -Remappable -: -: -state_len -is -correct -and -so -is -/ -/ -' -to_index -' -then -all -inputs -to -' -to_state_id -' -should -be -valid -indices -/ -/ -and -thus -transform -into -valid -state -IDs -. -StateID -: -: -new_unchecked -( -index -< -< -self -. -stride2 -) -} -} -impl -Remappable -for -noncontiguous -: -: -NFA -{ -fn -state_len -( -& -self -) -- -> -usize -{ -noncontiguous -: -: -NFA -: -: -states -( -self -) -. -len -( -) -} -fn -swap_states -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -{ -noncontiguous -: -: -NFA -: -: -swap_states -( -self -id1 -id2 -) -} -fn -remap -( -& -mut -self -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -{ -noncontiguous -: -: -NFA -: -: -remap -( -self -map -) -} -} diff --git a/third_party/rust/aho-corasick/src/util/search.rs b/third_party/rust/aho-corasick/src/util/search.rs deleted file mode 100644 index 4040e78265162..0000000000000 --- a/third_party/rust/aho-corasick/src/util/search.rs +++ /dev/null @@ -1,10584 +0,0 @@ -use -core -: -: -ops -: -: -{ -Range -RangeBounds -} -; -use -crate -: -: -util -: -: -primitives -: -: -PatternID -; -/ -/ -/ -The -configuration -and -the -haystack -to -use -for -an -Aho -- -Corasick -search -. -/ -/ -/ -/ -/ -/ -When -executing -a -search -there -are -a -few -parameters -one -might -want -to -/ -/ -/ -configure -: -/ -/ -/ -/ -/ -/ -* -The -haystack -to -search -provided -to -the -[ -Input -: -: -new -] -constructor -. -This -/ -/ -/ -is -the -only -required -parameter -. -/ -/ -/ -* -The -span -_within_ -the -haystack -to -limit -a -search -to -. -( -The -default -/ -/ -/ -is -the -entire -haystack -. -) -This -is -configured -via -[ -Input -: -: -span -] -or -/ -/ -/ -[ -Input -: -: -range -] -. -/ -/ -/ -* -Whether -to -run -an -unanchored -( -matches -can -occur -anywhere -after -the -/ -/ -/ -start -of -the -search -) -or -anchored -( -matches -can -only -occur -beginning -at -/ -/ -/ -the -start -of -the -search -) -search -. -Unanchored -search -is -the -default -. -This -is -/ -/ -/ -configured -via -[ -Input -: -: -anchored -] -. -/ -/ -/ -* -Whether -to -quit -the -search -as -soon -as -a -match -has -been -found -regardless -/ -/ -/ -of -the -[ -MatchKind -] -that -the -searcher -was -built -with -. -This -is -configured -/ -/ -/ -via -[ -Input -: -: -earliest -] -. -/ -/ -/ -/ -/ -/ -For -most -cases -the -defaults -for -all -optional -parameters -are -appropriate -. -/ -/ -/ -The -utility -of -this -type -is -that -it -keeps -the -default -or -common -case -simple -/ -/ -/ -while -permitting -tweaking -parameters -in -more -niche -use -cases -while -reusing -/ -/ -/ -the -same -search -APIs -. -/ -/ -/ -/ -/ -/ -# -Valid -bounds -and -search -termination -/ -/ -/ -/ -/ -/ -An -Input -permits -setting -the -bounds -of -a -search -via -either -/ -/ -/ -[ -Input -: -: -span -] -or -[ -Input -: -: -range -] -. -The -bounds -set -must -be -valid -or -/ -/ -/ -else -a -panic -will -occur -. -Bounds -are -valid -if -and -only -if -: -/ -/ -/ -/ -/ -/ -* -The -bounds -represent -a -valid -range -into -the -input -' -s -haystack -. -/ -/ -/ -* -* -* -or -* -* -the -end -bound -is -a -valid -ending -bound -for -the -haystack -* -and -* -/ -/ -/ -the -start -bound -is -exactly -one -greater -than -the -end -bound -. -/ -/ -/ -/ -/ -/ -In -the -latter -case -[ -Input -: -: -is_done -] -will -return -true -and -indicates -any -/ -/ -/ -search -receiving -such -an -input -should -immediately -return -with -no -match -. -/ -/ -/ -/ -/ -/ -Other -than -representing -" -search -is -complete -" -the -Input -: -: -span -and -/ -/ -/ -Input -: -: -range -APIs -are -never -necessary -. -Instead -callers -can -slice -the -/ -/ -/ -haystack -instead -e -. -g -. -with -& -haystack -[ -start -. -. -end -] -. -With -that -said -they -/ -/ -/ -can -be -more -convenient -than -slicing -because -the -match -positions -reported -/ -/ -/ -when -using -Input -: -: -span -or -Input -: -: -range -are -in -terms -of -the -original -/ -/ -/ -haystack -. -If -you -instead -use -& -haystack -[ -start -. -. -end -] -then -you -' -ll -need -to -/ -/ -/ -add -start -to -any -match -position -returned -in -order -for -it -to -be -a -correct -/ -/ -/ -index -into -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -: -& -str -and -& -[ -u8 -] -automatically -convert -to -an -Input -/ -/ -/ -/ -/ -/ -There -is -a -From -< -& -T -> -for -Input -implementation -for -all -T -: -AsRef -< -[ -u8 -] -> -. -/ -/ -/ -Additionally -the -[ -AhoCorasick -] -( -crate -: -: -AhoCorasick -) -search -APIs -accept -/ -/ -/ -a -Into -< -Input -> -. -These -two -things -combined -together -mean -you -can -provide -/ -/ -/ -things -like -& -str -and -& -[ -u8 -] -to -search -APIs -when -the -defaults -are -/ -/ -/ -suitable -but -also -an -Input -when -they -' -re -not -. -For -example -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -Anchored -Input -Match -StartKind -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Build -a -searcher -that -supports -both -unanchored -and -anchored -modes -. -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Both -) -/ -/ -/ -. -build -( -& -[ -" -abcd -" -" -b -" -] -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -haystack -= -" -abcd -" -; -/ -/ -/ -/ -/ -/ -/ -/ -A -search -using -default -parameters -is -unanchored -. -With -standard -/ -/ -/ -/ -/ -semantics -this -finds -b -first -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -1 -1 -. -. -2 -) -) -/ -/ -/ -ac -. -find -( -haystack -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -Using -the -same -' -find -' -routine -we -can -provide -an -' -Input -' -explicitly -/ -/ -/ -/ -/ -that -is -configured -to -do -an -anchored -search -. -Since -' -b -' -doesn -' -t -start -/ -/ -/ -/ -/ -at -the -beginning -of -the -search -it -is -not -reported -as -a -match -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -4 -) -) -/ -/ -/ -ac -. -find -( -Input -: -: -new -( -haystack -) -. -anchored -( -Anchored -: -: -Yes -) -) -/ -/ -/ -) -; -/ -/ -/ -# -[ -derive -( -Clone -) -] -pub -struct -Input -< -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -span -: -Span -anchored -: -Anchored -earliest -: -bool -} -impl -< -' -h -> -Input -< -' -h -> -{ -/ -/ -/ -Create -a -new -search -configuration -for -the -given -haystack -. -# -[ -inline -] -pub -fn -new -< -H -: -? -Sized -+ -AsRef -< -[ -u8 -] -> -> -( -haystack -: -& -' -h -H -) -- -> -Input -< -' -h -> -{ -Input -{ -haystack -: -haystack -. -as_ref -( -) -span -: -Span -{ -start -: -0 -end -: -haystack -. -as_ref -( -) -. -len -( -) -} -anchored -: -Anchored -: -: -No -earliest -: -false -} -} -/ -/ -/ -Set -the -span -for -this -search -. -/ -/ -/ -/ -/ -/ -This -routine -is -generic -over -how -a -span -is -provided -. -While -/ -/ -/ -a -[ -Span -] -may -be -given -directly -one -may -also -provide -a -/ -/ -/ -std -: -: -ops -: -: -Range -< -usize -> -. -To -provide -anything -supported -by -range -/ -/ -/ -syntax -use -the -[ -Input -: -: -range -] -method -. -/ -/ -/ -/ -/ -/ -The -default -span -is -the -entire -haystack -. -/ -/ -/ -/ -/ -/ -Note -that -[ -Input -: -: -range -] -overrides -this -method -and -vice -versa -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -given -span -does -not -correspond -to -valid -bounds -in -/ -/ -/ -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -the -span -of -the -search -can -impact -whether -a -/ -/ -/ -match -is -reported -or -not -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -Input -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -b -" -" -abcd -" -" -abc -" -] -; -/ -/ -/ -let -haystack -= -" -abcd -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -/ -/ -/ -. -build -( -patterns -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -0 -. -. -3 -) -; -/ -/ -/ -let -mat -= -ac -. -try_find -( -input -) -? -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -/ -/ -Without -the -span -stopping -the -search -early -' -abcd -' -would -be -reported -/ -/ -/ -/ -/ -because -it -is -the -correct -leftmost -- -first -match -. -/ -/ -/ -assert_eq -! -( -" -abc -" -& -haystack -[ -mat -. -span -( -) -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -span -< -S -: -Into -< -Span -> -> -( -mut -self -span -: -S -) -- -> -Input -< -' -h -> -{ -self -. -set_span -( -span -) -; -self -} -/ -/ -/ -Like -Input -: -: -span -but -accepts -any -range -instead -. -/ -/ -/ -/ -/ -/ -The -default -range -is -the -entire -haystack -. -/ -/ -/ -/ -/ -/ -Note -that -[ -Input -: -: -span -] -overrides -this -method -and -vice -versa -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -will -panic -if -the -given -range -could -not -be -converted -/ -/ -/ -to -a -valid -[ -Range -] -. -For -example -this -would -panic -when -given -/ -/ -/ -0 -. -. -= -usize -: -: -MAX -since -it -cannot -be -represented -using -a -half -- -open -/ -/ -/ -interval -in -terms -of -usize -. -/ -/ -/ -/ -/ -/ -This -routine -also -panics -if -the -given -range -does -not -correspond -to -/ -/ -/ -valid -bounds -in -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -. -range -( -2 -. -. -= -4 -) -; -/ -/ -/ -assert_eq -! -( -2 -. -. -5 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -range -< -R -: -RangeBounds -< -usize -> -> -( -mut -self -range -: -R -) -- -> -Input -< -' -h -> -{ -self -. -set_range -( -range -) -; -self -} -/ -/ -/ -Sets -the -anchor -mode -of -a -search -. -/ -/ -/ -/ -/ -/ -When -a -search -is -anchored -( -via -[ -Anchored -: -: -Yes -] -) -a -match -must -begin -/ -/ -/ -at -the -start -of -a -search -. -When -a -search -is -not -anchored -( -that -' -s -/ -/ -/ -[ -Anchored -: -: -No -] -) -searchers -will -look -for -a -match -anywhere -in -the -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -By -default -the -anchored -mode -is -[ -Anchored -: -: -No -] -. -/ -/ -/ -/ -/ -/ -# -Support -for -anchored -searches -/ -/ -/ -/ -/ -/ -Anchored -or -unanchored -searches -might -not -always -be -available -/ -/ -/ -depending -on -the -type -of -searcher -used -and -its -configuration -: -/ -/ -/ -/ -/ -/ -* -[ -noncontiguous -: -: -NFA -] -( -crate -: -: -nfa -: -: -noncontiguous -: -: -NFA -) -always -/ -/ -/ -supports -both -unanchored -and -anchored -searches -. -/ -/ -/ -* -[ -contiguous -: -: -NFA -] -( -crate -: -: -nfa -: -: -contiguous -: -: -NFA -) -always -supports -both -/ -/ -/ -unanchored -and -anchored -searches -. -/ -/ -/ -* -[ -dfa -: -: -DFA -] -( -crate -: -: -dfa -: -: -DFA -) -supports -only -unanchored -/ -/ -/ -searches -by -default -. -/ -/ -/ -[ -dfa -: -: -Builder -: -: -start_kind -] -( -crate -: -: -dfa -: -: -Builder -: -: -start_kind -) -can -/ -/ -/ -be -used -to -change -the -default -to -supporting -both -kinds -of -searches -/ -/ -/ -or -even -just -anchored -searches -. -/ -/ -/ -* -[ -AhoCorasick -] -( -crate -: -: -AhoCorasick -) -inherits -the -same -setup -as -a -/ -/ -/ -DFA -. -Namely -it -only -supports -unanchored -searches -by -default -but -/ -/ -/ -[ -AhoCorasickBuilder -: -: -start_kind -] -( -crate -: -: -AhoCorasickBuilder -: -: -start_kind -) -/ -/ -/ -can -change -this -. -/ -/ -/ -/ -/ -/ -If -you -try -to -execute -a -search -using -a -try_ -( -" -fallible -" -) -method -with -/ -/ -/ -an -unsupported -anchor -mode -then -an -error -will -be -returned -. -For -calls -/ -/ -/ -to -infallible -search -methods -a -panic -will -result -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -demonstrates -the -differences -between -an -anchored -search -and -/ -/ -/ -an -unanchored -search -. -Notice -that -we -build -our -AhoCorasick -searcher -/ -/ -/ -with -[ -StartKind -: -: -Both -] -so -that -it -supports -both -unanchored -and -/ -/ -/ -anchored -searches -simultaneously -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -/ -/ -/ -AhoCorasick -Anchored -Input -MatchKind -StartKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -bcd -" -] -; -/ -/ -/ -let -haystack -= -" -abcd -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Both -) -/ -/ -/ -. -build -( -patterns -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -' -Anchored -: -: -No -' -is -the -default -so -it -doesn -' -t -need -to -/ -/ -/ -/ -/ -be -explicitly -specified -here -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -; -/ -/ -/ -let -mat -= -ac -. -try_find -( -input -) -? -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -bcd -" -& -haystack -[ -mat -. -span -( -) -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -While -' -bcd -' -occurs -in -the -haystack -it -does -not -begin -where -our -/ -/ -/ -/ -/ -search -begins -so -no -match -is -found -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -None -ac -. -try_find -( -input -) -? -) -; -/ -/ -/ -/ -/ -/ -/ -/ -However -if -we -start -our -search -where -' -bcd -' -starts -then -we -will -/ -/ -/ -/ -/ -find -a -match -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -1 -. -. -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -let -mat -= -ac -. -try_find -( -input -) -? -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -bcd -" -& -haystack -[ -mat -. -span -( -) -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -anchored -( -mut -self -mode -: -Anchored -) -- -> -Input -< -' -h -> -{ -self -. -set_anchored -( -mode -) -; -self -} -/ -/ -/ -Whether -to -execute -an -" -earliest -" -search -or -not -. -/ -/ -/ -/ -/ -/ -When -running -a -non -- -overlapping -search -an -" -earliest -" -search -will -/ -/ -/ -return -the -match -location -as -early -as -possible -. -For -example -given -/ -/ -/ -the -patterns -abc -and -b -and -a -haystack -of -abc -a -normal -/ -/ -/ -leftmost -- -first -search -will -return -abc -as -a -match -. -But -an -" -earliest -" -/ -/ -/ -search -will -return -as -soon -as -it -is -known -that -a -match -occurs -which -/ -/ -/ -happens -once -b -is -seen -. -/ -/ -/ -/ -/ -/ -Note -that -when -using -[ -MatchKind -: -: -Standard -] -the -" -earliest -" -option -/ -/ -/ -has -no -effect -since -standard -semantics -are -already -" -earliest -. -" -Note -/ -/ -/ -also -that -this -has -no -effect -in -overlapping -searches -since -overlapping -/ -/ -/ -searches -also -use -standard -semantics -and -report -all -possible -matches -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -difference -between -" -earliest -" -searching -and -/ -/ -/ -normal -leftmost -searching -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -AhoCorasick -Anchored -Input -MatchKind -StartKind -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -abc -" -" -b -" -] -; -/ -/ -/ -let -haystack -= -" -abc -" -; -/ -/ -/ -/ -/ -/ -let -ac -= -AhoCorasick -: -: -builder -( -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -/ -/ -/ -. -build -( -patterns -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -normal -leftmost -- -first -match -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -; -/ -/ -/ -let -mat -= -ac -. -try_find -( -input -) -? -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -abc -" -& -haystack -[ -mat -. -span -( -) -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -" -earliest -" -possible -match -even -if -it -isn -' -t -leftmost -- -first -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -earliest -( -true -) -; -/ -/ -/ -let -mat -= -ac -. -try_find -( -input -) -? -. -expect -( -" -should -have -a -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -b -" -& -haystack -[ -mat -. -span -( -) -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -earliest -( -mut -self -yes -: -bool -) -- -> -Input -< -' -h -> -{ -self -. -set_earliest -( -yes -) -; -self -} -/ -/ -/ -Set -the -span -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -This -is -like -the -[ -Input -: -: -span -] -method -except -this -mutates -the -/ -/ -/ -span -in -place -. -/ -/ -/ -/ -/ -/ -This -routine -is -generic -over -how -a -span -is -provided -. -While -/ -/ -/ -a -[ -Span -] -may -be -given -directly -one -may -also -provide -a -/ -/ -/ -std -: -: -ops -: -: -Range -< -usize -> -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -given -span -does -not -correspond -to -valid -bounds -in -/ -/ -/ -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -input -. -set_span -( -2 -. -. -4 -) -; -/ -/ -/ -assert_eq -! -( -2 -. -. -4 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_span -< -S -: -Into -< -Span -> -> -( -& -mut -self -span -: -S -) -{ -let -span -= -span -. -into -( -) -; -assert -! -( -span -. -end -< -= -self -. -haystack -. -len -( -) -& -& -span -. -start -< -= -span -. -end -. -wrapping_add -( -1 -) -" -invalid -span -{ -: -? -} -for -haystack -of -length -{ -} -" -span -self -. -haystack -. -len -( -) -) -; -self -. -span -= -span -; -} -/ -/ -/ -Set -the -span -for -this -search -configuration -given -any -range -. -/ -/ -/ -/ -/ -/ -This -is -like -the -[ -Input -: -: -range -] -method -except -this -mutates -the -/ -/ -/ -span -in -place -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -will -panic -if -the -given -range -could -not -be -converted -/ -/ -/ -to -a -valid -[ -Range -] -. -For -example -this -would -panic -when -given -/ -/ -/ -0 -. -. -= -usize -: -: -MAX -since -it -cannot -be -represented -using -a -half -- -open -/ -/ -/ -interval -in -terms -of -usize -. -/ -/ -/ -/ -/ -/ -This -routine -also -panics -if -the -given -range -does -not -correspond -to -/ -/ -/ -valid -bounds -in -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -input -. -set_range -( -2 -. -. -= -4 -) -; -/ -/ -/ -assert_eq -! -( -2 -. -. -5 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_range -< -R -: -RangeBounds -< -usize -> -> -( -& -mut -self -range -: -R -) -{ -use -core -: -: -ops -: -: -Bound -; -/ -/ -It -' -s -a -little -weird -to -convert -ranges -into -spans -and -then -spans -/ -/ -back -into -ranges -when -we -actually -slice -the -haystack -. -Because -/ -/ -of -that -process -we -always -represent -everything -as -a -half -- -open -/ -/ -internal -. -Therefore -handling -things -like -m -. -. -= -n -is -a -little -awkward -. -let -start -= -match -range -. -start_bound -( -) -{ -Bound -: -: -Included -( -& -i -) -= -> -i -/ -/ -Can -this -case -ever -happen -? -Range -syntax -doesn -' -t -support -it -. -. -. -Bound -: -: -Excluded -( -& -i -) -= -> -i -. -checked_add -( -1 -) -. -unwrap -( -) -Bound -: -: -Unbounded -= -> -0 -} -; -let -end -= -match -range -. -end_bound -( -) -{ -Bound -: -: -Included -( -& -i -) -= -> -i -. -checked_add -( -1 -) -. -unwrap -( -) -Bound -: -: -Excluded -( -& -i -) -= -> -i -Bound -: -: -Unbounded -= -> -self -. -haystack -( -) -. -len -( -) -} -; -self -. -set_span -( -Span -{ -start -end -} -) -; -} -/ -/ -/ -Set -the -starting -offset -for -the -span -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -only -mutating -the -start -of -a -span -/ -/ -/ -without -having -to -set -the -entire -span -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -given -span -does -not -correspond -to -valid -bounds -in -/ -/ -/ -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -input -. -set_start -( -5 -) -; -/ -/ -/ -assert_eq -! -( -5 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_start -( -& -mut -self -start -: -usize -) -{ -self -. -set_span -( -Span -{ -start -. -. -self -. -get_span -( -) -} -) -; -} -/ -/ -/ -Set -the -ending -offset -for -the -span -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -only -mutating -the -end -of -a -span -/ -/ -/ -without -having -to -set -the -entire -span -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -given -span -does -not -correspond -to -valid -bounds -in -/ -/ -/ -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -input -. -set_end -( -5 -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -5 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_end -( -& -mut -self -end -: -usize -) -{ -self -. -set_span -( -Span -{ -end -. -. -self -. -get_span -( -) -} -) -; -} -/ -/ -/ -Set -the -anchor -mode -of -a -search -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Input -: -: -anchored -] -except -it -mutates -the -search -/ -/ -/ -configuration -in -place -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -Anchored -Input -} -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -Anchored -: -: -No -input -. -get_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -input -. -set_anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -Anchored -: -: -Yes -input -. -get_anchored -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_anchored -( -& -mut -self -mode -: -Anchored -) -{ -self -. -anchored -= -mode -; -} -/ -/ -/ -Set -whether -the -search -should -execute -in -" -earliest -" -mode -or -not -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Input -: -: -earliest -] -except -it -mutates -the -search -/ -/ -/ -configuration -in -place -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert -! -( -! -input -. -get_earliest -( -) -) -; -/ -/ -/ -input -. -set_earliest -( -true -) -; -/ -/ -/ -assert -! -( -input -. -get_earliest -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_earliest -( -& -mut -self -yes -: -bool -) -{ -self -. -earliest -= -yes -; -} -/ -/ -/ -Return -a -borrow -of -the -underlying -haystack -as -a -slice -of -bytes -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -b -" -foobar -" -input -. -haystack -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -haystack -( -& -self -) -- -> -& -[ -u8 -] -{ -self -. -haystack -} -/ -/ -/ -Return -the -start -position -of -this -search -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -search -. -get_span -( -) -. -start -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -input -. -start -( -) -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -. -span -( -2 -. -. -4 -) -; -/ -/ -/ -assert_eq -! -( -2 -input -. -start -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -start -( -& -self -) -- -> -usize -{ -self -. -get_span -( -) -. -start -} -/ -/ -/ -Return -the -end -position -of -this -search -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -search -. -get_span -( -) -. -end -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -6 -input -. -end -( -) -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -. -span -( -2 -. -. -4 -) -; -/ -/ -/ -assert_eq -! -( -4 -input -. -end -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -end -( -& -self -) -- -> -usize -{ -self -. -get_span -( -) -. -end -} -/ -/ -/ -Return -the -span -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -If -one -was -not -explicitly -set -then -the -span -corresponds -to -the -entire -/ -/ -/ -range -of -the -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -Input -Span -} -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -Span -{ -start -: -0 -end -: -6 -} -input -. -get_span -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get_span -( -& -self -) -- -> -Span -{ -self -. -span -} -/ -/ -/ -Return -the -span -as -a -range -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -If -one -was -not -explicitly -set -then -the -span -corresponds -to -the -entire -/ -/ -/ -range -of -the -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get_range -( -& -self -) -- -> -Range -< -usize -> -{ -self -. -get_span -( -) -. -range -( -) -} -/ -/ -/ -Return -the -anchored -mode -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -If -no -anchored -mode -was -set -then -it -defaults -to -[ -Anchored -: -: -No -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -Anchored -Input -} -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -Anchored -: -: -No -input -. -get_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -input -. -set_anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -Anchored -: -: -Yes -input -. -get_anchored -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get_anchored -( -& -self -) -- -> -Anchored -{ -self -. -anchored -} -/ -/ -/ -Return -whether -this -search -should -execute -in -" -earliest -" -mode -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert -! -( -! -input -. -get_earliest -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get_earliest -( -& -self -) -- -> -bool -{ -self -. -earliest -} -/ -/ -/ -Return -true -if -this -input -has -been -exhausted -which -in -turn -means -all -/ -/ -/ -subsequent -searches -will -return -no -matches -. -/ -/ -/ -/ -/ -/ -This -occurs -precisely -when -the -start -position -of -this -search -is -greater -/ -/ -/ -than -the -end -position -of -the -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert -! -( -! -input -. -is_done -( -) -) -; -/ -/ -/ -input -. -set_start -( -6 -) -; -/ -/ -/ -assert -! -( -! -input -. -is_done -( -) -) -; -/ -/ -/ -input -. -set_start -( -7 -) -; -/ -/ -/ -assert -! -( -input -. -is_done -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_done -( -& -self -) -- -> -bool -{ -self -. -get_span -( -) -. -start -> -self -. -get_span -( -) -. -end -} -} -impl -< -' -h -> -core -: -: -fmt -: -: -Debug -for -Input -< -' -h -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -fmter -= -f -. -debug_struct -( -" -Input -" -) -; -match -core -: -: -str -: -: -from_utf8 -( -self -. -haystack -( -) -) -{ -Ok -( -nice -) -= -> -fmter -. -field -( -" -haystack -" -& -nice -) -Err -( -_ -) -= -> -fmter -. -field -( -" -haystack -" -& -self -. -haystack -( -) -) -} -. -field -( -" -span -" -& -self -. -span -) -. -field -( -" -anchored -" -& -self -. -anchored -) -. -field -( -" -earliest -" -& -self -. -earliest -) -. -finish -( -) -} -} -impl -< -' -h -H -: -? -Sized -+ -AsRef -< -[ -u8 -] -> -> -From -< -& -' -h -H -> -for -Input -< -' -h -> -{ -# -[ -inline -] -fn -from -( -haystack -: -& -' -h -H -) -- -> -Input -< -' -h -> -{ -Input -: -: -new -( -haystack -) -} -} -/ -/ -/ -A -representation -of -a -range -in -a -haystack -. -/ -/ -/ -/ -/ -/ -A -span -corresponds -to -the -starting -and -ending -_byte -offsets_ -of -a -/ -/ -/ -contiguous -region -of -bytes -. -The -starting -offset -is -inclusive -while -the -/ -/ -/ -ending -offset -is -exclusive -. -That -is -a -span -is -a -half -- -open -interval -. -/ -/ -/ -/ -/ -/ -A -span -is -used -to -report -the -offsets -of -a -match -but -it -is -also -used -to -/ -/ -/ -convey -which -region -of -a -haystack -should -be -searched -via -routines -like -/ -/ -/ -[ -Input -: -: -span -] -. -/ -/ -/ -/ -/ -/ -This -is -basically -equivalent -to -a -std -: -: -ops -: -: -Range -< -usize -> -except -this -/ -/ -/ -type -implements -Copy -which -makes -it -more -ergonomic -to -use -in -the -context -/ -/ -/ -of -this -crate -. -Indeed -Span -exists -only -because -Range -< -usize -> -does -/ -/ -/ -not -implement -Copy -. -Like -a -range -this -implements -Index -for -[ -u8 -] -/ -/ -/ -and -str -and -IndexMut -for -[ -u8 -] -. -For -convenience -this -also -impls -/ -/ -/ -From -< -Range -> -which -means -things -like -Span -: -: -from -( -5 -. -. -10 -) -work -. -/ -/ -/ -/ -/ -/ -There -are -no -constraints -on -the -values -of -a -span -. -It -is -for -example -legal -/ -/ -/ -to -create -a -span -where -start -> -end -. -# -[ -derive -( -Clone -Copy -Eq -Hash -PartialEq -) -] -pub -struct -Span -{ -/ -/ -/ -The -start -offset -of -the -span -inclusive -. -pub -start -: -usize -/ -/ -/ -The -end -offset -of -the -span -exclusive -. -pub -end -: -usize -} -impl -Span -{ -/ -/ -/ -Returns -this -span -as -a -range -. -# -[ -inline -] -pub -fn -range -( -& -self -) -- -> -Range -< -usize -> -{ -Range -: -: -from -( -* -self -) -} -/ -/ -/ -Returns -true -when -this -span -is -empty -. -That -is -when -start -> -= -end -. -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -start -> -= -self -. -end -} -/ -/ -/ -Returns -the -length -of -this -span -. -/ -/ -/ -/ -/ -/ -This -returns -0 -in -precisely -the -cases -that -is_empty -returns -true -. -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -end -. -saturating_sub -( -self -. -start -) -} -/ -/ -/ -Returns -true -when -the -given -offset -is -contained -within -this -span -. -/ -/ -/ -/ -/ -/ -Note -that -an -empty -span -contains -no -offsets -and -will -always -return -/ -/ -/ -false -. -# -[ -inline -] -pub -fn -contains -( -& -self -offset -: -usize -) -- -> -bool -{ -! -self -. -is_empty -( -) -& -& -self -. -start -< -= -offset -& -& -offset -< -= -self -. -end -} -/ -/ -/ -Returns -a -new -span -with -offset -added -to -this -span -' -s -start -and -end -/ -/ -/ -values -. -# -[ -inline -] -pub -fn -offset -( -& -self -offset -: -usize -) -- -> -Span -{ -Span -{ -start -: -self -. -start -+ -offset -end -: -self -. -end -+ -offset -} -} -} -impl -core -: -: -fmt -: -: -Debug -for -Span -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -} -. -. -{ -} -" -self -. -start -self -. -end -) -} -} -impl -core -: -: -ops -: -: -Index -< -Span -> -for -[ -u8 -] -{ -type -Output -= -[ -u8 -] -; -# -[ -inline -] -fn -index -( -& -self -index -: -Span -) -- -> -& -[ -u8 -] -{ -& -self -[ -index -. -range -( -) -] -} -} -impl -core -: -: -ops -: -: -IndexMut -< -Span -> -for -[ -u8 -] -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -Span -) -- -> -& -mut -[ -u8 -] -{ -& -mut -self -[ -index -. -range -( -) -] -} -} -impl -core -: -: -ops -: -: -Index -< -Span -> -for -str -{ -type -Output -= -str -; -# -[ -inline -] -fn -index -( -& -self -index -: -Span -) -- -> -& -str -{ -& -self -[ -index -. -range -( -) -] -} -} -impl -From -< -Range -< -usize -> -> -for -Span -{ -# -[ -inline -] -fn -from -( -range -: -Range -< -usize -> -) -- -> -Span -{ -Span -{ -start -: -range -. -start -end -: -range -. -end -} -} -} -impl -From -< -Span -> -for -Range -< -usize -> -{ -# -[ -inline -] -fn -from -( -span -: -Span -) -- -> -Range -< -usize -> -{ -Range -{ -start -: -span -. -start -end -: -span -. -end -} -} -} -impl -PartialEq -< -Range -< -usize -> -> -for -Span -{ -# -[ -inline -] -fn -eq -( -& -self -range -: -& -Range -< -usize -> -) -- -> -bool -{ -self -. -start -= -= -range -. -start -& -& -self -. -end -= -= -range -. -end -} -} -impl -PartialEq -< -Span -> -for -Range -< -usize -> -{ -# -[ -inline -] -fn -eq -( -& -self -span -: -& -Span -) -- -> -bool -{ -self -. -start -= -= -span -. -start -& -& -self -. -end -= -= -span -. -end -} -} -/ -/ -/ -The -type -of -anchored -search -to -perform -. -/ -/ -/ -/ -/ -/ -If -an -Aho -- -Corasick -searcher -does -not -support -the -anchored -mode -selected -/ -/ -/ -then -the -search -will -return -an -error -or -panic -depending -on -whether -a -/ -/ -/ -fallible -or -an -infallible -routine -was -called -. -# -[ -non_exhaustive -] -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -Anchored -{ -/ -/ -/ -Run -an -unanchored -search -. -This -means -a -match -may -occur -anywhere -at -or -/ -/ -/ -after -the -start -position -of -the -search -up -until -the -end -position -of -the -/ -/ -/ -search -. -No -/ -/ -/ -Run -an -anchored -search -. -This -means -that -a -match -must -begin -at -the -start -/ -/ -/ -position -of -the -search -and -end -before -the -end -position -of -the -search -. -Yes -} -impl -Anchored -{ -/ -/ -/ -Returns -true -if -and -only -if -this -anchor -mode -corresponds -to -an -anchored -/ -/ -/ -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Anchored -; -/ -/ -/ -/ -/ -/ -assert -! -( -! -Anchored -: -: -No -. -is_anchored -( -) -) -; -/ -/ -/ -assert -! -( -Anchored -: -: -Yes -. -is_anchored -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_anchored -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -Anchored -: -: -Yes -) -} -} -/ -/ -/ -A -representation -of -a -match -reported -by -an -Aho -- -Corasick -searcher -. -/ -/ -/ -/ -/ -/ -A -match -has -two -essential -pieces -of -information -: -the -[ -PatternID -] -that -/ -/ -/ -matches -and -the -[ -Span -] -of -the -match -in -a -haystack -. -/ -/ -/ -/ -/ -/ -The -pattern -is -identified -by -an -ID -which -corresponds -to -its -position -/ -/ -/ -( -starting -from -0 -) -relative -to -other -patterns -used -to -construct -the -/ -/ -/ -corresponding -searcher -. -If -only -a -single -pattern -is -provided -then -all -/ -/ -/ -matches -are -guaranteed -to -have -a -pattern -ID -of -0 -. -/ -/ -/ -/ -/ -/ -Every -match -reported -by -a -searcher -guarantees -that -its -span -has -its -start -/ -/ -/ -offset -as -less -than -or -equal -to -its -end -offset -. -# -[ -derive -( -Clone -Copy -Debug -Eq -Hash -PartialEq -) -] -pub -struct -Match -{ -/ -/ -/ -The -pattern -ID -. -pattern -: -PatternID -/ -/ -/ -The -underlying -match -span -. -span -: -Span -} -impl -Match -{ -/ -/ -/ -Create -a -new -match -from -a -pattern -ID -and -a -span -. -/ -/ -/ -/ -/ -/ -This -constructor -is -generic -over -how -a -span -is -provided -. -While -/ -/ -/ -a -[ -Span -] -may -be -given -directly -one -may -also -provide -a -/ -/ -/ -std -: -: -ops -: -: -Range -< -usize -> -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -end -< -start -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -create -a -match -for -the -first -pattern -in -an -/ -/ -/ -Aho -- -Corasick -searcher -using -convenient -range -syntax -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -{ -Match -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -m -= -Match -: -: -new -( -PatternID -: -: -ZERO -5 -. -. -10 -) -; -/ -/ -/ -assert_eq -! -( -0 -m -. -pattern -( -) -. -as_usize -( -) -) -; -/ -/ -/ -assert_eq -! -( -5 -m -. -start -( -) -) -; -/ -/ -/ -assert_eq -! -( -10 -m -. -end -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -new -< -S -: -Into -< -Span -> -> -( -pattern -: -PatternID -span -: -S -) -- -> -Match -{ -let -span -= -span -. -into -( -) -; -assert -! -( -span -. -start -< -= -span -. -end -" -invalid -match -span -" -) -; -Match -{ -pattern -span -} -} -/ -/ -/ -Create -a -new -match -from -a -pattern -ID -and -a -byte -offset -span -. -/ -/ -/ -/ -/ -/ -This -constructor -is -generic -over -how -a -span -is -provided -. -While -/ -/ -/ -a -[ -Span -] -may -be -given -directly -one -may -also -provide -a -/ -/ -/ -std -: -: -ops -: -: -Range -< -usize -> -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Match -: -: -new -] -but -accepts -a -usize -instead -of -a -/ -/ -/ -[ -PatternID -] -. -This -panics -if -the -given -usize -is -not -representable -/ -/ -/ -as -a -PatternID -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -end -< -start -or -if -pattern -> -PatternID -: -: -MAX -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -create -a -match -for -the -third -pattern -in -an -/ -/ -/ -Aho -- -Corasick -searcher -using -convenient -range -syntax -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -aho_corasick -: -: -Match -; -/ -/ -/ -/ -/ -/ -let -m -= -Match -: -: -must -( -3 -5 -. -. -10 -) -; -/ -/ -/ -assert_eq -! -( -3 -m -. -pattern -( -) -. -as_usize -( -) -) -; -/ -/ -/ -assert_eq -! -( -5 -m -. -start -( -) -) -; -/ -/ -/ -assert_eq -! -( -10 -m -. -end -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -must -< -S -: -Into -< -Span -> -> -( -pattern -: -usize -span -: -S -) -- -> -Match -{ -Match -: -: -new -( -PatternID -: -: -must -( -pattern -) -span -) -} -/ -/ -/ -Returns -the -ID -of -the -pattern -that -matched -. -/ -/ -/ -/ -/ -/ -The -ID -of -a -pattern -is -derived -from -the -position -in -which -it -was -/ -/ -/ -originally -inserted -into -the -corresponding -searcher -. -The -first -pattern -/ -/ -/ -has -identifier -0 -and -each -subsequent -pattern -is -1 -2 -and -so -on -. -# -[ -inline -] -pub -fn -pattern -( -& -self -) -- -> -PatternID -{ -self -. -pattern -} -/ -/ -/ -The -starting -position -of -the -match -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -Match -: -: -span -( -) -. -start -. -# -[ -inline -] -pub -fn -start -( -& -self -) -- -> -usize -{ -self -. -span -( -) -. -start -} -/ -/ -/ -The -ending -position -of -the -match -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -Match -: -: -span -( -) -. -end -. -# -[ -inline -] -pub -fn -end -( -& -self -) -- -> -usize -{ -self -. -span -( -) -. -end -} -/ -/ -/ -Returns -the -match -span -as -a -range -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -Match -: -: -span -( -) -. -range -( -) -. -# -[ -inline -] -pub -fn -range -( -& -self -) -- -> -core -: -: -ops -: -: -Range -< -usize -> -{ -self -. -span -( -) -. -range -( -) -} -/ -/ -/ -Returns -the -span -for -this -match -. -# -[ -inline -] -pub -fn -span -( -& -self -) -- -> -Span -{ -self -. -span -} -/ -/ -/ -Returns -true -when -the -span -in -this -match -is -empty -. -/ -/ -/ -/ -/ -/ -An -empty -match -can -only -be -returned -when -empty -pattern -is -in -the -/ -/ -/ -Aho -- -Corasick -searcher -. -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -span -( -) -. -is_empty -( -) -} -/ -/ -/ -Returns -the -length -of -this -match -. -/ -/ -/ -/ -/ -/ -This -returns -0 -in -precisely -the -cases -that -is_empty -returns -true -. -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -span -( -) -. -len -( -) -} -/ -/ -/ -Returns -a -new -match -with -offset -added -to -its -span -' -s -start -and -end -/ -/ -/ -values -. -# -[ -inline -] -pub -fn -offset -( -& -self -offset -: -usize -) -- -> -Match -{ -Match -{ -pattern -: -self -. -pattern -span -: -Span -{ -start -: -self -. -start -( -) -+ -offset -end -: -self -. -end -( -) -+ -offset -} -} -} -} -/ -/ -/ -A -knob -for -controlling -the -match -semantics -of -an -Aho -- -Corasick -automaton -. -/ -/ -/ -/ -/ -/ -There -are -two -generally -different -ways -that -Aho -- -Corasick -automatons -can -/ -/ -/ -report -matches -. -The -first -way -is -the -" -standard -" -approach -that -results -from -/ -/ -/ -implementing -most -textbook -explanations -of -Aho -- -Corasick -. -The -second -way -is -/ -/ -/ -to -report -only -the -leftmost -non -- -overlapping -matches -. -The -leftmost -approach -/ -/ -/ -is -in -turn -split -into -two -different -ways -of -resolving -ambiguous -matches -: -/ -/ -/ -leftmost -- -first -and -leftmost -- -longest -. -/ -/ -/ -/ -/ -/ -The -Standard -match -kind -is -the -default -and -is -the -only -one -that -supports -/ -/ -/ -overlapping -matches -and -stream -searching -. -( -Trying -to -find -overlapping -or -/ -/ -/ -streaming -matches -using -leftmost -match -semantics -will -result -in -an -error -in -/ -/ -/ -fallible -APIs -and -a -panic -when -using -infallibe -APIs -. -) -The -Standard -match -/ -/ -/ -kind -will -report -matches -as -they -are -seen -. -When -searching -for -overlapping -/ -/ -/ -matches -then -all -possible -matches -are -reported -. -When -searching -for -/ -/ -/ -non -- -overlapping -matches -the -first -match -seen -is -reported -. -For -example -for -/ -/ -/ -non -- -overlapping -matches -given -the -patterns -abcd -and -b -and -the -haystack -/ -/ -/ -abcdef -only -a -match -for -b -is -reported -since -it -is -detected -first -. -The -/ -/ -/ -abcd -match -is -never -reported -since -it -overlaps -with -the -b -match -. -/ -/ -/ -/ -/ -/ -In -contrast -the -leftmost -match -kind -always -prefers -the -leftmost -match -/ -/ -/ -among -all -possible -matches -. -Given -the -same -example -as -above -with -abcd -and -/ -/ -/ -b -as -patterns -and -abcdef -as -the -haystack -the -leftmost -match -is -abcd -/ -/ -/ -since -it -begins -before -the -b -match -even -though -the -b -match -is -detected -/ -/ -/ -before -the -abcd -match -. -In -this -case -the -b -match -is -not -reported -at -all -/ -/ -/ -since -it -overlaps -with -the -abcd -match -. -/ -/ -/ -/ -/ -/ -The -difference -between -leftmost -- -first -and -leftmost -- -longest -is -in -how -they -/ -/ -/ -resolve -ambiguous -matches -when -there -are -multiple -leftmost -matches -to -/ -/ -/ -choose -from -. -Leftmost -- -first -always -chooses -the -pattern -that -was -provided -/ -/ -/ -earliest -where -as -leftmost -- -longest -always -chooses -the -longest -matching -/ -/ -/ -pattern -. -For -example -given -the -patterns -a -and -ab -and -the -subject -/ -/ -/ -string -ab -the -leftmost -- -first -match -is -a -but -the -leftmost -- -longest -match -/ -/ -/ -is -ab -. -Conversely -if -the -patterns -were -given -in -reverse -order -i -. -e -. -/ -/ -/ -ab -and -a -then -both -the -leftmost -- -first -and -leftmost -- -longest -matches -/ -/ -/ -would -be -ab -. -Stated -differently -the -leftmost -- -first -match -depends -on -the -/ -/ -/ -order -in -which -the -patterns -were -given -to -the -Aho -- -Corasick -automaton -. -/ -/ -/ -Because -of -that -when -leftmost -- -first -matching -is -used -if -a -pattern -A -/ -/ -/ -that -appears -before -a -pattern -B -is -a -prefix -of -B -then -it -is -impossible -/ -/ -/ -to -ever -observe -a -match -of -B -. -/ -/ -/ -/ -/ -/ -If -you -' -re -not -sure -which -match -kind -to -pick -then -stick -with -the -standard -/ -/ -/ -kind -which -is -the -default -. -In -particular -if -you -need -overlapping -or -/ -/ -/ -streaming -matches -then -you -_must_ -use -the -standard -kind -. -The -leftmost -/ -/ -/ -kinds -are -useful -in -specific -circumstances -. -For -example -leftmost -- -first -can -/ -/ -/ -be -very -useful -as -a -way -to -implement -match -priority -based -on -the -order -of -/ -/ -/ -patterns -given -and -leftmost -- -longest -can -be -useful -for -dictionary -searching -/ -/ -/ -such -that -only -the -longest -matching -words -are -reported -. -/ -/ -/ -/ -/ -/ -# -Relationship -with -regular -expression -alternations -/ -/ -/ -/ -/ -/ -Understanding -match -semantics -can -be -a -little -tricky -and -one -easy -way -/ -/ -/ -to -conceptualize -non -- -overlapping -matches -from -an -Aho -- -Corasick -automaton -/ -/ -/ -is -to -think -about -them -as -a -simple -alternation -of -literals -in -a -regular -/ -/ -/ -expression -. -For -example -let -' -s -say -we -wanted -to -match -the -strings -/ -/ -/ -Sam -and -Samwise -which -would -turn -into -the -regex -Sam -| -Samwise -. -It -/ -/ -/ -turns -out -that -regular -expression -engines -have -two -different -ways -of -/ -/ -/ -matching -this -alternation -. -The -first -way -leftmost -- -longest -is -commonly -/ -/ -/ -found -in -POSIX -compatible -implementations -of -regular -expressions -( -such -as -/ -/ -/ -grep -) -. -The -second -way -leftmost -- -first -is -commonly -found -in -backtracking -/ -/ -/ -implementations -such -as -Perl -. -( -Some -regex -engines -such -as -RE2 -and -Rust -' -s -/ -/ -/ -regex -engine -do -not -use -backtracking -but -still -implement -leftmost -- -first -/ -/ -/ -semantics -in -an -effort -to -match -the -behavior -of -dominant -backtracking -/ -/ -/ -regex -engines -such -as -those -found -in -Perl -Ruby -Python -Javascript -and -/ -/ -/ -PHP -. -) -/ -/ -/ -/ -/ -/ -That -is -when -matching -Sam -| -Samwise -against -Samwise -a -POSIX -regex -/ -/ -/ -will -match -Samwise -because -it -is -the -longest -possible -match -but -a -/ -/ -/ -Perl -- -like -regex -will -match -Sam -since -it -appears -earlier -in -the -/ -/ -/ -alternation -. -Indeed -the -regex -Sam -| -Samwise -in -a -Perl -- -like -regex -engine -/ -/ -/ -will -never -match -Samwise -since -Sam -will -always -have -higher -priority -. -/ -/ -/ -Conversely -matching -the -regex -Samwise -| -Sam -against -Samwise -will -lead -to -/ -/ -/ -a -match -of -Samwise -in -both -POSIX -and -Perl -- -like -regexes -since -Samwise -is -/ -/ -/ -still -longest -match -but -it -also -appears -earlier -than -Sam -. -/ -/ -/ -/ -/ -/ -The -" -standard -" -match -semantics -of -Aho -- -Corasick -generally -don -' -t -correspond -/ -/ -/ -to -the -match -semantics -of -any -large -group -of -regex -implementations -so -/ -/ -/ -there -' -s -no -direct -analogy -that -can -be -made -here -. -Standard -match -semantics -/ -/ -/ -are -generally -useful -for -overlapping -matches -or -if -you -just -want -to -see -/ -/ -/ -matches -as -they -are -detected -. -/ -/ -/ -/ -/ -/ -The -main -conclusion -to -draw -from -this -section -is -that -the -match -semantics -/ -/ -/ -can -be -tweaked -to -precisely -match -either -Perl -- -like -regex -alternations -or -/ -/ -/ -POSIX -regex -alternations -. -# -[ -non_exhaustive -] -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -MatchKind -{ -/ -/ -/ -Use -standard -match -semantics -which -support -overlapping -matches -. -When -/ -/ -/ -used -with -non -- -overlapping -matches -matches -are -reported -as -they -are -/ -/ -/ -seen -. -Standard -/ -/ -/ -Use -leftmost -- -first -match -semantics -which -reports -leftmost -matches -. -/ -/ -/ -When -there -are -multiple -possible -leftmost -matches -the -match -/ -/ -/ -corresponding -to -the -pattern -that -appeared -earlier -when -constructing -/ -/ -/ -the -automaton -is -reported -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -support -overlapping -matches -or -stream -searching -. -If -/ -/ -/ -this -match -kind -is -used -attempting -to -find -overlapping -matches -or -/ -/ -/ -stream -matches -will -fail -. -LeftmostFirst -/ -/ -/ -Use -leftmost -- -longest -match -semantics -which -reports -leftmost -matches -. -/ -/ -/ -When -there -are -multiple -possible -leftmost -matches -the -longest -match -/ -/ -/ -is -chosen -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -support -overlapping -matches -or -stream -searching -. -If -/ -/ -/ -this -match -kind -is -used -attempting -to -find -overlapping -matches -or -/ -/ -/ -stream -matches -will -fail -. -LeftmostLongest -} -/ -/ -/ -The -default -match -kind -is -MatchKind -: -: -Standard -. -impl -Default -for -MatchKind -{ -fn -default -( -) -- -> -MatchKind -{ -MatchKind -: -: -Standard -} -} -impl -MatchKind -{ -# -[ -inline -] -pub -( -crate -) -fn -is_standard -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -MatchKind -: -: -Standard -) -} -# -[ -inline -] -pub -( -crate -) -fn -is_leftmost -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -MatchKind -: -: -LeftmostFirst -| -MatchKind -: -: -LeftmostLongest -) -} -# -[ -inline -] -pub -( -crate -) -fn -is_leftmost_first -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -MatchKind -: -: -LeftmostFirst -) -} -/ -/ -/ -Convert -this -match -kind -into -a -packed -match -kind -. -If -this -match -kind -/ -/ -/ -corresponds -to -standard -semantics -then -this -returns -None -since -/ -/ -/ -packed -searching -does -not -support -standard -semantics -. -# -[ -inline -] -pub -( -crate -) -fn -as_packed -( -& -self -) -- -> -Option -< -crate -: -: -packed -: -: -MatchKind -> -{ -match -* -self -{ -MatchKind -: -: -Standard -= -> -None -MatchKind -: -: -LeftmostFirst -= -> -{ -Some -( -crate -: -: -packed -: -: -MatchKind -: -: -LeftmostFirst -) -} -MatchKind -: -: -LeftmostLongest -= -> -{ -Some -( -crate -: -: -packed -: -: -MatchKind -: -: -LeftmostLongest -) -} -} -} -} -/ -/ -/ -The -kind -of -anchored -starting -configurations -to -support -in -an -Aho -- -Corasick -/ -/ -/ -searcher -. -/ -/ -/ -/ -/ -/ -Depending -on -which -searcher -is -used -internally -by -/ -/ -/ -[ -AhoCorasick -] -( -crate -: -: -AhoCorasick -) -supporting -both -unanchored -/ -/ -/ -and -anchored -searches -can -be -quite -costly -. -For -this -reason -/ -/ -/ -[ -AhoCorasickBuilder -: -: -start_kind -] -( -crate -: -: -AhoCorasickBuilder -: -: -start_kind -) -/ -/ -/ -can -be -used -to -configure -whether -your -searcher -supports -unanchored -/ -/ -/ -anchored -or -both -kinds -of -searches -. -/ -/ -/ -/ -/ -/ -This -searcher -configuration -knob -works -in -concert -with -the -search -time -/ -/ -/ -configuration -[ -Input -: -: -anchored -] -. -Namely -if -one -requests -an -unsupported -/ -/ -/ -anchored -mode -then -the -search -will -either -panic -or -return -an -error -/ -/ -/ -depending -on -whether -you -' -re -using -infallible -or -fallibe -APIs -respectively -. -/ -/ -/ -/ -/ -/ -AhoCorasick -by -default -only -supports -unanchored -searches -. -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -StartKind -{ -/ -/ -/ -Support -both -anchored -and -unanchored -searches -. -Both -/ -/ -/ -Support -only -unanchored -searches -. -Requesting -an -anchored -search -will -/ -/ -/ -return -an -error -in -fallible -APIs -and -panic -in -infallible -APIs -. -Unanchored -/ -/ -/ -Support -only -anchored -searches -. -Requesting -an -unanchored -search -will -/ -/ -/ -return -an -error -in -fallible -APIs -and -panic -in -infallible -APIs -. -Anchored -} -impl -Default -for -StartKind -{ -fn -default -( -) -- -> -StartKind -{ -StartKind -: -: -Unanchored -} -} diff --git a/third_party/rust/aho-corasick/src/util/special.rs b/third_party/rust/aho-corasick/src/util/special.rs deleted file mode 100644 index 8702cc800e33a..0000000000000 --- a/third_party/rust/aho-corasick/src/util/special.rs +++ /dev/null @@ -1,394 +0,0 @@ -use -crate -: -: -util -: -: -primitives -: -: -StateID -; -/ -/ -/ -A -collection -of -sentinel -state -IDs -for -Aho -- -Corasick -automata -. -/ -/ -/ -/ -/ -/ -This -specifically -enables -the -technique -by -which -we -determine -which -states -/ -/ -/ -are -dead -matches -or -start -states -. -Namely -by -arranging -states -in -a -/ -/ -/ -particular -order -we -can -determine -the -type -of -a -state -simply -by -looking -at -/ -/ -/ -its -ID -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Special -{ -/ -/ -/ -The -maximum -ID -of -all -the -" -special -" -states -. -This -corresponds -either -to -/ -/ -/ -start_anchored_id -when -a -prefilter -is -active -and -max_match_id -when -a -/ -/ -/ -prefilter -is -not -active -. -The -idea -here -is -that -if -there -is -no -prefilter -/ -/ -/ -then -there -is -no -point -in -treating -start -states -as -special -. -pub -( -crate -) -max_special_id -: -StateID -/ -/ -/ -The -maximum -ID -of -all -the -match -states -. -Any -state -ID -bigger -than -this -/ -/ -/ -is -guaranteed -to -be -a -non -- -match -ID -. -/ -/ -/ -/ -/ -/ -It -is -possible -and -legal -for -max_match_id -to -be -equal -to -/ -/ -/ -start_anchored_id -which -occurs -precisely -in -the -case -where -the -empty -/ -/ -/ -string -is -a -pattern -that -was -added -to -the -underlying -automaton -. -pub -( -crate -) -max_match_id -: -StateID -/ -/ -/ -The -state -ID -of -the -start -state -used -for -unanchored -searches -. -pub -( -crate -) -start_unanchored_id -: -StateID -/ -/ -/ -The -state -ID -of -the -start -state -used -for -anchored -searches -. -This -is -/ -/ -/ -always -start_unanchored_id -+ -1 -. -pub -( -crate -) -start_anchored_id -: -StateID -} -impl -Special -{ -/ -/ -/ -Create -a -new -set -of -" -special -" -state -IDs -with -all -IDs -initialized -to -/ -/ -/ -zero -. -The -general -idea -here -is -that -they -will -be -updated -and -set -to -/ -/ -/ -correct -values -later -. -pub -( -crate -) -fn -zero -( -) -- -> -Special -{ -Special -{ -max_special_id -: -StateID -: -: -ZERO -max_match_id -: -StateID -: -: -ZERO -start_unanchored_id -: -StateID -: -: -ZERO -start_anchored_id -: -StateID -: -: -ZERO -} -} -} diff --git a/third_party/rust/regex-automata/.cargo-checksum.json b/third_party/rust/regex-automata/.cargo-checksum.json deleted file mode 100644 index 0d1f1e65e776a..0000000000000 --- a/third_party/rust/regex-automata/.cargo-checksum.json +++ /dev/null @@ -1,1656 +0,0 @@ -{ -" -files -" -: -{ -" -Cargo -. -toml -" -: -" -755761361da0023ecaa0d56bb9aeb406e3d6c2c1d5d355e0cc3e46b3cffe7a8f -" -" -LICENSE -- -APACHE -" -: -" -a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 -" -" -LICENSE -- -MIT -" -: -" -6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb -" -" -README -. -md -" -: -" -61db25dbf26092fc80e8db89165692e55f9fb86b14e8451ebb28303f45932254 -" -" -src -/ -dfa -/ -accel -. -rs -" -: -" -800dada38f7a1d0fa443821dc04a8611c6cf06ef431e517f16867a27cbb4f27d -" -" -src -/ -dfa -/ -automaton -. -rs -" -: -" -565ebf211769b4710091c4a15b5733296e9fbbc2a137d6eeb1c521b7b69463a0 -" -" -src -/ -dfa -/ -dense -. -rs -" -: -" -73c9c7662c0b4b7901eb17632187aac10bb24e16a89a4dfe78a7bf17bc98f9f1 -" -" -src -/ -dfa -/ -determinize -. -rs -" -: -" -91b9f69d28bdd064aa86716fe0772e4145050fd458bb7869a28660b4f7b64872 -" -" -src -/ -dfa -/ -minimize -. -rs -" -: -" -b5cadb462b9f24cd4aa7a665e75fb813cd06858a92b8986c9c5ae7fd9a60dfab -" -" -src -/ -dfa -/ -mod -. -rs -" -: -" -e7210af01805f2f390374cd5b40ee502f9dc7633d6a57d988dcb17dfd93864cb -" -" -src -/ -dfa -/ -onepass -. -rs -" -: -" -d1b29d531545ce30167d58eb24ac15ba10bce158e73483c09f219d5971c8e83c -" -" -src -/ -dfa -/ -regex -. -rs -" -: -" -f970028c874e2a156db1591bbdc3915027ffa7f47d66d5bd6e97dace5a6a3d5b -" -" -src -/ -dfa -/ -remapper -. -rs -" -: -" -ca096abc0f8e45c43a2adf3a7743b8857714ae7411a623edea41cc3ce906a169 -" -" -src -/ -dfa -/ -search -. -rs -" -: -" -237cdb8c6239ece5fe8279c4b6209c8094502cdecc9a4e3f977e469e60fd32ec -" -" -src -/ -dfa -/ -sparse -. -rs -" -: -" -c3a05451a0019850b538dfd640fb12c92ac127b8a69c55f23489bd42c1c1f289 -" -" -src -/ -dfa -/ -special -. -rs -" -: -" -c2e60de5b98e68c9c45aaffbc67a08f049831a764a1ed29d1d1db0fb68efdce5 -" -" -src -/ -dfa -/ -start -. -rs -" -: -" -46b1dbaf8e4518ddddda6bbe596621aae36f8ba694390483a22355d9d799be8e -" -" -src -/ -hybrid -/ -dfa -. -rs -" -: -" -861b3602bb9ac8b10abe0eae18a2641b2145fcfc7fb22b250ed2e3a345762f4c -" -" -src -/ -hybrid -/ -error -. -rs -" -: -" -ffc6e65fd9e4694a67902f3516970e3e6cd6e33a7f59a5ab2ac16f740a049d9c -" -" -src -/ -hybrid -/ -id -. -rs -" -: -" -6168aad5c81c627494ba0575a24d61fd0ae7efabaaceeadb8ff28472275e2813 -" -" -src -/ -hybrid -/ -mod -. -rs -" -: -" -49abcf332f19d2fe87c0a729b1b7715a87794e64f411f4d2bab9d8a4331d6ace -" -" -src -/ -hybrid -/ -regex -. -rs -" -: -" -9f40aa2cfa89d7a97f9c9e32cb2ae591f4b6f3d51ddec41308d99ce924e130cf -" -" -src -/ -hybrid -/ -search -. -rs -" -: -" -2aae7ab24c7e6b8d1a1aa81a2f6081f949e9fa42e960fd3fea29f57db8db9f68 -" -" -src -/ -lib -. -rs -" -: -" -4e831d41057760c5f2f1274a206fa5a42f59dbca8f98ad3e782fe0fba0d6c37f -" -" -src -/ -macros -. -rs -" -: -" -3e4b39252bfa471fad384160a43f113ebfec7bec46a85d16f006622881dd2081 -" -" -src -/ -meta -/ -error -. -rs -" -: -" -710a6813314b1b11ace1b016a827067fff8b2624d47e15c7f52043bff5ab57da -" -" -src -/ -meta -/ -limited -. -rs -" -: -" -cf629b08d64cb2e1c17d196a1ad6084f733a41e1c947715d9c0ea99ba7f7657d -" -" -src -/ -meta -/ -literal -. -rs -" -: -" -52da98bb30995dedd22786e4728cb84e84c6093a284168bd91196b999dd0f6ec -" -" -src -/ -meta -/ -mod -. -rs -" -: -" -f3b10b96fa08efaba3e4c9b81883cf40aac6e4c1f6ae55a497a534cf5805b46d -" -" -src -/ -meta -/ -regex -. -rs -" -: -" -12ec35a66b889172439c4abebde5f9fb41e85765d6613f4bf622429e83d47b3c -" -" -src -/ -meta -/ -reverse_inner -. -rs -" -: -" -945d6c2d4c7538e1609dbd430a096784d22abd33db58b1ba65c9c9af45a7d3c0 -" -" -src -/ -meta -/ -stopat -. -rs -" -: -" -b786cd0bd21f66c6f63df2d4bc2e544cd041d548d8001b4a818be1e0f84b6747 -" -" -src -/ -meta -/ -strategy -. -rs -" -: -" -4ee8d21def7323105e5b1101bdb1e152c5befa870a11f2bf0fa85ffbac5a6609 -" -" -src -/ -meta -/ -wrappers -. -rs -" -: -" -6998ff14226905eded36697f885a8ca7508b50ffb05c4b78348ff0e9463857d5 -" -" -src -/ -nfa -/ -mod -. -rs -" -: -" -1a731e217ed4053714500e84e58cc127f402e4e075f7d0e5b9aea715cd52405a -" -" -src -/ -nfa -/ -thompson -/ -backtrack -. -rs -" -: -" -e9a986d71aa9b0145d9f871c92f466e1b992592d8ac87f7fde36ede2e8016324 -" -" -src -/ -nfa -/ -thompson -/ -builder -. -rs -" -: -" -77bdd42a7fbdedb8d6756f0161d278e677ab1fbe622ca77115c8b506a2a6db21 -" -" -src -/ -nfa -/ -thompson -/ -compiler -. -rs -" -: -" -9cc351398c2d9ce10ac11a1c285f675bc351ecb816d3f33321513dd6bfcdc335 -" -" -src -/ -nfa -/ -thompson -/ -error -. -rs -" -: -" -78488c2fdb85f819f53cc30bb11c7f96169112da5dd14c351e5cc3bcccf0e10e -" -" -src -/ -nfa -/ -thompson -/ -literal_trie -. -rs -" -: -" -c2d1d09b44da4648db797386c2410cbf63337afef8cb62e6e78cf34786892a11 -" -" -src -/ -nfa -/ -thompson -/ -map -. -rs -" -: -" -96cdf3195f7efb374bcb1791ef5cc12a1cde189ab90402bf01d9b46fb7796b60 -" -" -src -/ -nfa -/ -thompson -/ -mod -. -rs -" -: -" -0651520debd6f023ae1a2c422806aab37f8491e5bb092e20dfdc4fe4179d695c -" -" -src -/ -nfa -/ -thompson -/ -nfa -. -rs -" -: -" -9782d44b05986370b7f948067977fb20120562e2eca0e4366e35d7d18e81a679 -" -" -src -/ -nfa -/ -thompson -/ -pikevm -. -rs -" -: -" -aaf792832d1bf15fad8a8f0b2e6597170361eb3cbcb9343eb5bd242ff346d750 -" -" -src -/ -nfa -/ -thompson -/ -range_trie -. -rs -" -: -" -c9614074628bb56c9d0a137c1db7e13259a6500e4a46cdc7ddc84bee8f7e928f -" -" -src -/ -util -/ -alphabet -. -rs -" -: -" -94cd73ce2f4e34e0ae0a146d3efdc85478263afdfefd6dc105e0abf0ec79d82b -" -" -src -/ -util -/ -captures -. -rs -" -: -" -7aee3aae2836a397c1ad6e4535e0e0d177faf2d99e61476e8fb2710f69763668 -" -" -src -/ -util -/ -determinize -/ -mod -. -rs -" -: -" -32fea73cf4a7a04238c3d3b09ea7afc7fd7c85e87dc115c6152f464ab88bddb2 -" -" -src -/ -util -/ -determinize -/ -state -. -rs -" -: -" -2a0082d5cd2bd47ab75c3f04488655a3c47f1f75075b5d6f9b6e4eeb8980823e -" -" -src -/ -util -/ -empty -. -rs -" -: -" -13ec7d6cbd1520db5b4c1dae294f4419fa88d39d2bfc16f4ef258473d609f91c -" -" -src -/ -util -/ -escape -. -rs -" -: -" -5b2731b41a55cb50ab688132bb5640dbd51f14f141adaa864b9db7f0aa092c74 -" -" -src -/ -util -/ -int -. -rs -" -: -" -b7eec0a6cab0798ba66707988fce3ecfc841b93418028a7b1408c5d0f6271351 -" -" -src -/ -util -/ -interpolate -. -rs -" -: -" -5e4e6b6fb6e5a7603e393bf05c609735d86a7d1f54c2436e42111b4e1409b6dd -" -" -src -/ -util -/ -iter -. -rs -" -: -" -58ae97b4156d7160a46b909f4635d88d10354d9d892d2fcb4c5e18e24cf38f14 -" -" -src -/ -util -/ -lazy -. -rs -" -: -" -e489a96fce952e9d196fd3f5564cf8ea3374eb4aef630ff8f12d82f194ed4336 -" -" -src -/ -util -/ -look -. -rs -" -: -" -e7a5a51f8ed70c2f97edaf3dfbe8859de37b570341447634c6028cb89ff412d7 -" -" -src -/ -util -/ -memchr -. -rs -" -: -" -573109ce4983907083ae0b29a084a324b9b53da369b4d96f7f3a21fd5c8eb5c9 -" -" -src -/ -util -/ -mod -. -rs -" -: -" -16c5fd72263d3a4df994111b81aca36da17f591f4853f21a6a906ac725843f97 -" -" -src -/ -util -/ -pool -. -rs -" -: -" -5e231307962d0918888f98fd1a2bf51c2fc08bf910fa472762136f24cd040cf2 -" -" -src -/ -util -/ -prefilter -/ -aho_corasick -. -rs -" -: -" -c54fa95f4d9e7ab53e2c6463a43f8953df6a440997fc9cd528f225db0dd32582 -" -" -src -/ -util -/ -prefilter -/ -byteset -. -rs -" -: -" -1c80fa432acc23223a75a5181e37c40034764dffe42410e4b77af6f24f48bd5c -" -" -src -/ -util -/ -prefilter -/ -memchr -. -rs -" -: -" -36c6fe6354b2e729db6830166dd4862e439bc48c9e59258d88e4b6c5654e20ef -" -" -src -/ -util -/ -prefilter -/ -memmem -. -rs -" -: -" -6f6ed9450b14abf3e4a33d395337e51fbaa9743a0a16aac0009f7680aa60c500 -" -" -src -/ -util -/ -prefilter -/ -mod -. -rs -" -: -" -2818e2e92632aee1c46b0dc01b654e544bfbf460236be86d28a2d836e9fc189a -" -" -src -/ -util -/ -prefilter -/ -teddy -. -rs -" -: -" -ed54d26858b56e1c8c87e44afae5f63d81ab930787d79e671f3a3513f576e9cd -" -" -src -/ -util -/ -primitives -. -rs -" -: -" -8a9cc19ef2e1ab183943cdc2d2f095b02252476e32b7e9fff4a06a251749b068 -" -" -src -/ -util -/ -search -. -rs -" -: -" -66bf320ebbe403c119a966f3dfbd53178de0ceebd2ca1922f1ddbb79aed36837 -" -" -src -/ -util -/ -sparse_set -. -rs -" -: -" -3d4aa30b6aa9fc875d36506487a5095dbe8ed528b89e4146a65c7e7497520a4d -" -" -src -/ -util -/ -start -. -rs -" -: -" -8d2fe005698c0bd3680a0dbfc4a34eebfe2f51081ec1584968383ac4c86fd5fe -" -" -src -/ -util -/ -syntax -. -rs -" -: -" -720ac0d6600fad33f5967b5afe4e3de2096b857e4cda6fa16ba93b10a8230cab -" -" -src -/ -util -/ -unicode_data -/ -mod -. -rs -" -: -" -54c3e10bbc393e9881bfac3295815b160f59e69e2056bc29ee7cf0addd8e3cf7 -" -" -src -/ -util -/ -unicode_data -/ -perl_word -. -rs -" -: -" -2e1a5d889598bd4e73af17d3a9f7d6b4cf2f6ab24920a5336e496bb255281e56 -" -" -src -/ -util -/ -utf8 -. -rs -" -: -" -7a068009fdf07e693e521b1f0264725c0e6118dbe1eab55da9d0eab21785fcc1 -" -" -src -/ -util -/ -wire -. -rs -" -: -" -bfdf52615c516b6c07db3ce9c333ea61fdc535bd0b79560bbd7f6864ab83946e -" -" -test -" -: -" -39d79ce3532c31a51c0be89a2939816fad0e4868d2b03992c202cbe64dce9f6c -" -" -tests -/ -dfa -/ -api -. -rs -" -: -" -cc28e366b6bcbfcf379265acd492a92c62743c3f20e7a2b273019679aa9e1291 -" -" -tests -/ -dfa -/ -mod -. -rs -" -: -" -924d8fff500b9b7b140082623023e78007058a87323151cd8e361462945e4f16 -" -" -tests -/ -dfa -/ -onepass -/ -mod -. -rs -" -: -" -d08f4ecb8ec243be584944c9602af1ed3a48a8732dd11cd573b0d1d182171303 -" -" -tests -/ -dfa -/ -onepass -/ -suite -. -rs -" -: -" -6d63ec5469e6876656ae607cdbe07e6a4e17ace7836b67435763c9b1d233438a -" -" -tests -/ -dfa -/ -regression -. -rs -" -: -" -ebcf2645290286aa7531eb2b7951385e5ed8167532437aeca2ad2049768fd796 -" -" -tests -/ -dfa -/ -suite -. -rs -" -: -" -cf08499bc8838d2ff16ea9b20b07ad03c9b89d6efe093f081e2982a21ea6d666 -" -" -tests -/ -fuzz -/ -dense -. -rs -" -: -" -3e1099a0cce61e85abc0ad81bc592e85f497f159ef0e5d1d32bac1936aa6f20c -" -" -tests -/ -fuzz -/ -mod -. -rs -" -: -" -043773510e02f51def43ee0c2b8b867c53ecc8638c8a9233b2ac098de9c3ac1e -" -" -tests -/ -fuzz -/ -sparse -. -rs -" -: -" -ba61db4927ab28953037a4b20317399c86d01b4d774e46c020ade19029215e25 -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_dense_crash -- -9486fb7c8a93b12c12a62166b43d31640c0208a9 -" -: -" -8961279a8237c3e318452024dd971b1d5a26b058260c297382a74daca1b7f0d1 -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_dense_minimized -- -from -- -9486fb7c8a93b12c12a62166b43d31640c0208a9 -" -: -" -c2d52e3dea78d3f159b5b521d433358a7fee45ce20ed1545067d461f45ef66b8 -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_sparse_crash -- -0da59c0434eaf35e5a6b470fa9244bb79c72b000 -" -: -" -5b2d273023de3fb04037eaf2e6b4f51cced4c5a08d2e6b44e4be540774f939b9 -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_sparse_crash -- -18cfc246f2ddfc3dfc92b0c7893178c7cf65efa9 -" -: -" -e2e22e2f46a9a75b5c876476442276cf675fe244c5cf918789e4f6b14078fbd9 -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_sparse_crash -- -61fd8e3003bf9d99f6c1e5a8488727eefd234b98 -" -: -" -24a12712e1f2ba0a40b5782707908a74dd19941dc372ef525d65a7134f91988c -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_sparse_crash -- -a1b839d899ced76d5d7d0f78f9edb7a421505838 -" -: -" -a97f39b2febf9c73535681f7a86201e4b06d5a1ffcf135299c96c1cabfa9f6c4 -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_sparse_crash -- -c383ae07ec5e191422eadc492117439011816570 -" -: -" -44fe3ef878d35e2d51c2c17ff89bbbe3a4650e09d0cbbd48625c0f5e4dd0848b -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_sparse_crash -- -d07703ceb94b10dcd9e4acb809f2051420449e2b -" -: -" -d5534be36653b4af6cb94a7c63be58869bb8c204c5c63d67a4d6c986b44bb2e1 -" -" -tests -/ -fuzz -/ -testdata -/ -deserialize_sparse_crash -- -dbb8172d3984e7e7d03f4b5f8bb86ecd1460eff9 -" -: -" -77b844898610560afa09f2b8de73a85a0ba9a3b8cee4ff1bbf26b8c97ad4e8a2 -" -" -tests -/ -gen -/ -README -. -md -" -: -" -c3bfdf2f9ced501dd5bd75d01509a34e503efb2dff2f5f7b260580dde5519ed4 -" -" -tests -/ -gen -/ -dense -/ -mod -. -rs -" -: -" -5ae1cfb46212a674118ada2f66f37b25188e84643d406b95eb4665d722344262 -" -" -tests -/ -gen -/ -dense -/ -multi_pattern_v2 -. -rs -" -: -" -29b1e9a799adecbdbe7cd05e9748f664c2b915b10b1d2f5d36cfb6453826d1d2 -" -" -tests -/ -gen -/ -dense -/ -multi_pattern_v2_fwd -. -bigendian -. -dfa -" -: -" -8421d5a1bfc0b6c3bdc8fc90dff591a046b0aaf8e06ef7de7cc293004a35d061 -" -" -tests -/ -gen -/ -dense -/ -multi_pattern_v2_fwd -. -littleendian -. -dfa -" -: -" -dcf2fd5fd49f5f53cf1ec66f61623402f39401cb3aea30d6677b98bb1e9541bf -" -" -tests -/ -gen -/ -dense -/ -multi_pattern_v2_rev -. -bigendian -. -dfa -" -: -" -73c4f20d984e544dfa4cf05f3009d0a9b52fa84bc97b501ea0ccd179e2def4bc -" -" -tests -/ -gen -/ -dense -/ -multi_pattern_v2_rev -. -littleendian -. -dfa -" -: -" -74471209f05754e8e20c8a0222a5877b1b15b8b8f33cd8cac89ea65f708b4aff -" -" -tests -/ -gen -/ -mod -. -rs -" -: -" -043773510e02f51def43ee0c2b8b867c53ecc8638c8a9233b2ac098de9c3ac1e -" -" -tests -/ -gen -/ -sparse -/ -mod -. -rs -" -: -" -5ae1cfb46212a674118ada2f66f37b25188e84643d406b95eb4665d722344262 -" -" -tests -/ -gen -/ -sparse -/ -multi_pattern_v2 -. -rs -" -: -" -e00fb2a510a215460aab84573196b1f51bb65884ff494c2382534c04f6fdbfe9 -" -" -tests -/ -gen -/ -sparse -/ -multi_pattern_v2_fwd -. -bigendian -. -dfa -" -: -" -3287956bd2003cd69653b125f82aade95d99adbb20229bfdbb4958b8877c0a0b -" -" -tests -/ -gen -/ -sparse -/ -multi_pattern_v2_fwd -. -littleendian -. -dfa -" -: -" -bdf285901eaaac4596380115c5bbb20ab2f42f593d8d9e9238a00ed69863f9c9 -" -" -tests -/ -gen -/ -sparse -/ -multi_pattern_v2_rev -. -bigendian -. -dfa -" -: -" -e466dc085dd68b2d2220932a0e4d28759edd161c1fdad652240aa3825fd85268 -" -" -tests -/ -gen -/ -sparse -/ -multi_pattern_v2_rev -. -littleendian -. -dfa -" -: -" -80358d0c26c1cc7284065b0075f5b8804d83e673a8a8c8327f93a1c1ff455399 -" -" -tests -/ -hybrid -/ -api -. -rs -" -: -" -4b8592c412e6ad0ce4a27ed1c1496acc92366ccb1c7ec23c6fd0596fc6ebbdfb -" -" -tests -/ -hybrid -/ -mod -. -rs -" -: -" -4856a49a4d9b5e9e079c2719a5e75c32408b37e9b76cbdea057b388a3537af6d -" -" -tests -/ -hybrid -/ -suite -. -rs -" -: -" -688972275c5ef38cdc5112a1e6e54ccd2bf8290008ae2b17344c6c81e17e3a5a -" -" -tests -/ -lib -. -rs -" -: -" -5e8a014d53097dba1f865e5e35c35a69cd12f54fad74b5c49a387f8768c30847 -" -" -tests -/ -meta -/ -mod -. -rs -" -: -" -d08f4ecb8ec243be584944c9602af1ed3a48a8732dd11cd573b0d1d182171303 -" -" -tests -/ -meta -/ -suite -. -rs -" -: -" -4c441f9df82508a5e60dd08f266183f772fc9b2b236fbf69cab87650ecf3b424 -" -" -tests -/ -nfa -/ -mod -. -rs -" -: -" -49055c358e38d97e42acb1602c671f97dddf24cafe089490f0e79ed208d74d9b -" -" -tests -/ -nfa -/ -thompson -/ -backtrack -/ -mod -. -rs -" -: -" -d08f4ecb8ec243be584944c9602af1ed3a48a8732dd11cd573b0d1d182171303 -" -" -tests -/ -nfa -/ -thompson -/ -backtrack -/ -suite -. -rs -" -: -" -4e7baff70fc98b98b8297c6fd6d5818beb20343379e16cdb95bee46207ac4bd6 -" -" -tests -/ -nfa -/ -thompson -/ -mod -. -rs -" -: -" -de9f5bcea1a8d1f03c85c55ad8c0747877d69e344fcd6c6886b0a402f0661291 -" -" -tests -/ -nfa -/ -thompson -/ -pikevm -/ -mod -. -rs -" -: -" -d08f4ecb8ec243be584944c9602af1ed3a48a8732dd11cd573b0d1d182171303 -" -" -tests -/ -nfa -/ -thompson -/ -pikevm -/ -suite -. -rs -" -: -" -263837ebf5b2e1906a06237982ea875386d83567e399b4ec1f669f10b1422599 -" -} -" -package -" -: -" -49530408a136e16e5b486e883fbb6ba058e8e4e8ae6621a77b048b314336e629 -" -} diff --git a/third_party/rust/regex-automata/Cargo.toml b/third_party/rust/regex-automata/Cargo.toml deleted file mode 100644 index 9d94823c34f4c..0000000000000 --- a/third_party/rust/regex-automata/Cargo.toml +++ /dev/null @@ -1,991 +0,0 @@ -# -THIS -FILE -IS -AUTOMATICALLY -GENERATED -BY -CARGO -# -# -When -uploading -crates -to -the -registry -Cargo -will -automatically -# -" -normalize -" -Cargo -. -toml -files -for -maximal -compatibility -# -with -all -versions -of -Cargo -and -also -rewrite -path -dependencies -# -to -registry -( -e -. -g -. -crates -. -io -) -dependencies -. -# -# -If -you -are -reading -this -file -be -aware -that -the -original -Cargo -. -toml -# -will -likely -look -very -different -( -and -much -more -reasonable -) -. -# -See -Cargo -. -toml -. -orig -for -the -original -contents -. -[ -package -] -edition -= -" -2021 -" -name -= -" -regex -- -automata -" -version -= -" -0 -. -3 -. -7 -" -authors -= -[ -" -The -Rust -Project -Developers -" -" -Andrew -Gallant -< -jamslam -gmail -. -com -> -" -] -autoexamples -= -false -description -= -" -Automata -construction -and -matching -using -regular -expressions -. -" -documentation -= -" -https -: -/ -/ -docs -. -rs -/ -regex -- -automata -" -readme -= -" -README -. -md -" -keywords -= -[ -" -regex -" -" -dfa -" -" -automata -" -" -automaton -" -" -nfa -" -] -categories -= -[ -" -text -- -processing -" -] -license -= -" -MIT -OR -Apache -- -2 -. -0 -" -repository -= -" -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -tree -/ -master -/ -regex -- -automata -" -[ -lib -] -bench -= -false -[ -[ -test -] -] -name -= -" -integration -" -path -= -" -tests -/ -lib -. -rs -" -[ -dependencies -. -aho -- -corasick -] -version -= -" -1 -. -0 -. -0 -" -optional -= -true -default -- -features -= -false -[ -dependencies -. -log -] -version -= -" -0 -. -4 -. -14 -" -optional -= -true -[ -dependencies -. -memchr -] -version -= -" -2 -. -5 -. -0 -" -optional -= -true -default -- -features -= -false -[ -dependencies -. -regex -- -syntax -] -version -= -" -0 -. -7 -. -4 -" -optional -= -true -default -- -features -= -false -[ -dev -- -dependencies -. -anyhow -] -version -= -" -1 -. -0 -. -69 -" -[ -dev -- -dependencies -. -bstr -] -version -= -" -1 -. -3 -. -0 -" -features -= -[ -" -std -" -] -default -- -features -= -false -[ -dev -- -dependencies -. -doc -- -comment -] -version -= -" -0 -. -3 -. -3 -" -[ -dev -- -dependencies -. -env_logger -] -version -= -" -0 -. -9 -. -3 -" -features -= -[ -" -atty -" -" -humantime -" -" -termcolor -" -] -default -- -features -= -false -[ -dev -- -dependencies -. -quickcheck -] -version -= -" -1 -. -0 -. -3 -" -default -- -features -= -false -[ -dev -- -dependencies -. -regex -- -test -] -version -= -" -0 -. -1 -. -0 -" -[ -features -] -alloc -= -[ -] -default -= -[ -" -std -" -" -syntax -" -" -perf -" -" -unicode -" -" -meta -" -" -nfa -" -" -dfa -" -" -hybrid -" -] -dfa -= -[ -" -dfa -- -build -" -" -dfa -- -search -" -" -dfa -- -onepass -" -] -dfa -- -build -= -[ -" -nfa -- -thompson -" -" -dfa -- -search -" -] -dfa -- -onepass -= -[ -" -nfa -- -thompson -" -] -dfa -- -search -= -[ -] -hybrid -= -[ -" -alloc -" -" -nfa -- -thompson -" -] -internal -- -instrument -= -[ -" -internal -- -instrument -- -pikevm -" -] -internal -- -instrument -- -pikevm -= -[ -" -logging -" -" -std -" -] -logging -= -[ -" -dep -: -log -" -" -aho -- -corasick -? -/ -logging -" -] -meta -= -[ -" -syntax -" -" -nfa -- -pikevm -" -] -nfa -= -[ -" -nfa -- -thompson -" -" -nfa -- -pikevm -" -" -nfa -- -backtrack -" -] -nfa -- -backtrack -= -[ -" -nfa -- -thompson -" -] -nfa -- -pikevm -= -[ -" -nfa -- -thompson -" -] -nfa -- -thompson -= -[ -" -alloc -" -] -perf -= -[ -" -perf -- -inline -" -" -perf -- -literal -" -] -perf -- -inline -= -[ -] -perf -- -literal -= -[ -" -perf -- -literal -- -substring -" -" -perf -- -literal -- -multisubstring -" -] -perf -- -literal -- -multisubstring -= -[ -" -std -" -" -dep -: -aho -- -corasick -" -] -perf -- -literal -- -substring -= -[ -" -aho -- -corasick -? -/ -perf -- -literal -" -" -dep -: -memchr -" -] -std -= -[ -" -regex -- -syntax -? -/ -std -" -" -memchr -? -/ -std -" -" -aho -- -corasick -? -/ -std -" -" -alloc -" -] -syntax -= -[ -" -dep -: -regex -- -syntax -" -" -alloc -" -] -unicode -= -[ -" -unicode -- -age -" -" -unicode -- -bool -" -" -unicode -- -case -" -" -unicode -- -gencat -" -" -unicode -- -perl -" -" -unicode -- -script -" -" -unicode -- -segment -" -" -unicode -- -word -- -boundary -" -" -regex -- -syntax -? -/ -unicode -" -] -unicode -- -age -= -[ -" -regex -- -syntax -? -/ -unicode -- -age -" -] -unicode -- -bool -= -[ -" -regex -- -syntax -? -/ -unicode -- -bool -" -] -unicode -- -case -= -[ -" -regex -- -syntax -? -/ -unicode -- -case -" -] -unicode -- -gencat -= -[ -" -regex -- -syntax -? -/ -unicode -- -gencat -" -] -unicode -- -perl -= -[ -" -regex -- -syntax -? -/ -unicode -- -perl -" -] -unicode -- -script -= -[ -" -regex -- -syntax -? -/ -unicode -- -script -" -] -unicode -- -segment -= -[ -" -regex -- -syntax -? -/ -unicode -- -segment -" -] -unicode -- -word -- -boundary -= -[ -] diff --git a/third_party/rust/regex-automata/LICENSE-APACHE b/third_party/rust/regex-automata/LICENSE-APACHE deleted file mode 100644 index 689c90d245bbc..0000000000000 --- a/third_party/rust/regex-automata/LICENSE-APACHE +++ /dev/null @@ -1,1794 +0,0 @@ -Apache -License -Version -2 -. -0 -January -2004 -http -: -/ -/ -www -. -apache -. -org -/ -licenses -/ -TERMS -AND -CONDITIONS -FOR -USE -REPRODUCTION -AND -DISTRIBUTION -1 -. -Definitions -. -" -License -" -shall -mean -the -terms -and -conditions -for -use -reproduction -and -distribution -as -defined -by -Sections -1 -through -9 -of -this -document -. -" -Licensor -" -shall -mean -the -copyright -owner -or -entity -authorized -by -the -copyright -owner -that -is -granting -the -License -. -" -Legal -Entity -" -shall -mean -the -union -of -the -acting -entity -and -all -other -entities -that -control -are -controlled -by -or -are -under -common -control -with -that -entity -. -For -the -purposes -of -this -definition -" -control -" -means -( -i -) -the -power -direct -or -indirect -to -cause -the -direction -or -management -of -such -entity -whether -by -contract -or -otherwise -or -( -ii -) -ownership -of -fifty -percent -( -50 -% -) -or -more -of -the -outstanding -shares -or -( -iii -) -beneficial -ownership -of -such -entity -. -" -You -" -( -or -" -Your -" -) -shall -mean -an -individual -or -Legal -Entity -exercising -permissions -granted -by -this -License -. -" -Source -" -form -shall -mean -the -preferred -form -for -making -modifications -including -but -not -limited -to -software -source -code -documentation -source -and -configuration -files -. -" -Object -" -form -shall -mean -any -form -resulting -from -mechanical -transformation -or -translation -of -a -Source -form -including -but -not -limited -to -compiled -object -code -generated -documentation -and -conversions -to -other -media -types -. -" -Work -" -shall -mean -the -work -of -authorship -whether -in -Source -or -Object -form -made -available -under -the -License -as -indicated -by -a -copyright -notice -that -is -included -in -or -attached -to -the -work -( -an -example -is -provided -in -the -Appendix -below -) -. -" -Derivative -Works -" -shall -mean -any -work -whether -in -Source -or -Object -form -that -is -based -on -( -or -derived -from -) -the -Work -and -for -which -the -editorial -revisions -annotations -elaborations -or -other -modifications -represent -as -a -whole -an -original -work -of -authorship -. -For -the -purposes -of -this -License -Derivative -Works -shall -not -include -works -that -remain -separable -from -or -merely -link -( -or -bind -by -name -) -to -the -interfaces -of -the -Work -and -Derivative -Works -thereof -. -" -Contribution -" -shall -mean -any -work -of -authorship -including -the -original -version -of -the -Work -and -any -modifications -or -additions -to -that -Work -or -Derivative -Works -thereof -that -is -intentionally -submitted -to -Licensor -for -inclusion -in -the -Work -by -the -copyright -owner -or -by -an -individual -or -Legal -Entity -authorized -to -submit -on -behalf -of -the -copyright -owner -. -For -the -purposes -of -this -definition -" -submitted -" -means -any -form -of -electronic -verbal -or -written -communication -sent -to -the -Licensor -or -its -representatives -including -but -not -limited -to -communication -on -electronic -mailing -lists -source -code -control -systems -and -issue -tracking -systems -that -are -managed -by -or -on -behalf -of -the -Licensor -for -the -purpose -of -discussing -and -improving -the -Work -but -excluding -communication -that -is -conspicuously -marked -or -otherwise -designated -in -writing -by -the -copyright -owner -as -" -Not -a -Contribution -. -" -" -Contributor -" -shall -mean -Licensor -and -any -individual -or -Legal -Entity -on -behalf -of -whom -a -Contribution -has -been -received -by -Licensor -and -subsequently -incorporated -within -the -Work -. -2 -. -Grant -of -Copyright -License -. -Subject -to -the -terms -and -conditions -of -this -License -each -Contributor -hereby -grants -to -You -a -perpetual -worldwide -non -- -exclusive -no -- -charge -royalty -- -free -irrevocable -copyright -license -to -reproduce -prepare -Derivative -Works -of -publicly -display -publicly -perform -sublicense -and -distribute -the -Work -and -such -Derivative -Works -in -Source -or -Object -form -. -3 -. -Grant -of -Patent -License -. -Subject -to -the -terms -and -conditions -of -this -License -each -Contributor -hereby -grants -to -You -a -perpetual -worldwide -non -- -exclusive -no -- -charge -royalty -- -free -irrevocable -( -except -as -stated -in -this -section -) -patent -license -to -make -have -made -use -offer -to -sell -sell -import -and -otherwise -transfer -the -Work -where -such -license -applies -only -to -those -patent -claims -licensable -by -such -Contributor -that -are -necessarily -infringed -by -their -Contribution -( -s -) -alone -or -by -combination -of -their -Contribution -( -s -) -with -the -Work -to -which -such -Contribution -( -s -) -was -submitted -. -If -You -institute -patent -litigation -against -any -entity -( -including -a -cross -- -claim -or -counterclaim -in -a -lawsuit -) -alleging -that -the -Work -or -a -Contribution -incorporated -within -the -Work -constitutes -direct -or -contributory -patent -infringement -then -any -patent -licenses -granted -to -You -under -this -License -for -that -Work -shall -terminate -as -of -the -date -such -litigation -is -filed -. -4 -. -Redistribution -. -You -may -reproduce -and -distribute -copies -of -the -Work -or -Derivative -Works -thereof -in -any -medium -with -or -without -modifications -and -in -Source -or -Object -form -provided -that -You -meet -the -following -conditions -: -( -a -) -You -must -give -any -other -recipients -of -the -Work -or -Derivative -Works -a -copy -of -this -License -; -and -( -b -) -You -must -cause -any -modified -files -to -carry -prominent -notices -stating -that -You -changed -the -files -; -and -( -c -) -You -must -retain -in -the -Source -form -of -any -Derivative -Works -that -You -distribute -all -copyright -patent -trademark -and -attribution -notices -from -the -Source -form -of -the -Work -excluding -those -notices -that -do -not -pertain -to -any -part -of -the -Derivative -Works -; -and -( -d -) -If -the -Work -includes -a -" -NOTICE -" -text -file -as -part -of -its -distribution -then -any -Derivative -Works -that -You -distribute -must -include -a -readable -copy -of -the -attribution -notices -contained -within -such -NOTICE -file -excluding -those -notices -that -do -not -pertain -to -any -part -of -the -Derivative -Works -in -at -least -one -of -the -following -places -: -within -a -NOTICE -text -file -distributed -as -part -of -the -Derivative -Works -; -within -the -Source -form -or -documentation -if -provided -along -with -the -Derivative -Works -; -or -within -a -display -generated -by -the -Derivative -Works -if -and -wherever -such -third -- -party -notices -normally -appear -. -The -contents -of -the -NOTICE -file -are -for -informational -purposes -only -and -do -not -modify -the -License -. -You -may -add -Your -own -attribution -notices -within -Derivative -Works -that -You -distribute -alongside -or -as -an -addendum -to -the -NOTICE -text -from -the -Work -provided -that -such -additional -attribution -notices -cannot -be -construed -as -modifying -the -License -. -You -may -add -Your -own -copyright -statement -to -Your -modifications -and -may -provide -additional -or -different -license -terms -and -conditions -for -use -reproduction -or -distribution -of -Your -modifications -or -for -any -such -Derivative -Works -as -a -whole -provided -Your -use -reproduction -and -distribution -of -the -Work -otherwise -complies -with -the -conditions -stated -in -this -License -. -5 -. -Submission -of -Contributions -. -Unless -You -explicitly -state -otherwise -any -Contribution -intentionally -submitted -for -inclusion -in -the -Work -by -You -to -the -Licensor -shall -be -under -the -terms -and -conditions -of -this -License -without -any -additional -terms -or -conditions -. -Notwithstanding -the -above -nothing -herein -shall -supersede -or -modify -the -terms -of -any -separate -license -agreement -you -may -have -executed -with -Licensor -regarding -such -Contributions -. -6 -. -Trademarks -. -This -License -does -not -grant -permission -to -use -the -trade -names -trademarks -service -marks -or -product -names -of -the -Licensor -except -as -required -for -reasonable -and -customary -use -in -describing -the -origin -of -the -Work -and -reproducing -the -content -of -the -NOTICE -file -. -7 -. -Disclaimer -of -Warranty -. -Unless -required -by -applicable -law -or -agreed -to -in -writing -Licensor -provides -the -Work -( -and -each -Contributor -provides -its -Contributions -) -on -an -" -AS -IS -" -BASIS -WITHOUT -WARRANTIES -OR -CONDITIONS -OF -ANY -KIND -either -express -or -implied -including -without -limitation -any -warranties -or -conditions -of -TITLE -NON -- -INFRINGEMENT -MERCHANTABILITY -or -FITNESS -FOR -A -PARTICULAR -PURPOSE -. -You -are -solely -responsible -for -determining -the -appropriateness -of -using -or -redistributing -the -Work -and -assume -any -risks -associated -with -Your -exercise -of -permissions -under -this -License -. -8 -. -Limitation -of -Liability -. -In -no -event -and -under -no -legal -theory -whether -in -tort -( -including -negligence -) -contract -or -otherwise -unless -required -by -applicable -law -( -such -as -deliberate -and -grossly -negligent -acts -) -or -agreed -to -in -writing -shall -any -Contributor -be -liable -to -You -for -damages -including -any -direct -indirect -special -incidental -or -consequential -damages -of -any -character -arising -as -a -result -of -this -License -or -out -of -the -use -or -inability -to -use -the -Work -( -including -but -not -limited -to -damages -for -loss -of -goodwill -work -stoppage -computer -failure -or -malfunction -or -any -and -all -other -commercial -damages -or -losses -) -even -if -such -Contributor -has -been -advised -of -the -possibility -of -such -damages -. -9 -. -Accepting -Warranty -or -Additional -Liability -. -While -redistributing -the -Work -or -Derivative -Works -thereof -You -may -choose -to -offer -and -charge -a -fee -for -acceptance -of -support -warranty -indemnity -or -other -liability -obligations -and -/ -or -rights -consistent -with -this -License -. -However -in -accepting -such -obligations -You -may -act -only -on -Your -own -behalf -and -on -Your -sole -responsibility -not -on -behalf -of -any -other -Contributor -and -only -if -You -agree -to -indemnify -defend -and -hold -each -Contributor -harmless -for -any -liability -incurred -by -or -claims -asserted -against -such -Contributor -by -reason -of -your -accepting -any -such -warranty -or -additional -liability -. -END -OF -TERMS -AND -CONDITIONS -APPENDIX -: -How -to -apply -the -Apache -License -to -your -work -. -To -apply -the -Apache -License -to -your -work -attach -the -following -boilerplate -notice -with -the -fields -enclosed -by -brackets -" -[ -] -" -replaced -with -your -own -identifying -information -. -( -Don -' -t -include -the -brackets -! -) -The -text -should -be -enclosed -in -the -appropriate -comment -syntax -for -the -file -format -. -We -also -recommend -that -a -file -or -class -name -and -description -of -purpose -be -included -on -the -same -" -printed -page -" -as -the -copyright -notice -for -easier -identification -within -third -- -party -archives -. -Copyright -[ -yyyy -] -[ -name -of -copyright -owner -] -Licensed -under -the -Apache -License -Version -2 -. -0 -( -the -" -License -" -) -; -you -may -not -use -this -file -except -in -compliance -with -the -License -. -You -may -obtain -a -copy -of -the -License -at -http -: -/ -/ -www -. -apache -. -org -/ -licenses -/ -LICENSE -- -2 -. -0 -Unless -required -by -applicable -law -or -agreed -to -in -writing -software -distributed -under -the -License -is -distributed -on -an -" -AS -IS -" -BASIS -WITHOUT -WARRANTIES -OR -CONDITIONS -OF -ANY -KIND -either -express -or -implied -. -See -the -License -for -the -specific -language -governing -permissions -and -limitations -under -the -License -. diff --git a/third_party/rust/regex-automata/README.md b/third_party/rust/regex-automata/README.md deleted file mode 100644 index d4dc71db4ac0e..0000000000000 --- a/third_party/rust/regex-automata/README.md +++ /dev/null @@ -1,1310 +0,0 @@ -regex -- -automata -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -crate -exposes -a -variety -of -regex -engines -used -by -the -regex -crate -. -It -provides -a -vast -sprawling -and -" -expert -" -level -API -to -each -regex -engine -. -The -regex -engines -provided -by -this -crate -focus -heavily -on -finite -automata -implementations -and -specifically -guarantee -worst -case -O -( -m -* -n -) -time -complexity -for -all -searches -. -( -Where -m -~ -len -( -regex -) -and -n -~ -len -( -haystack -) -. -) -[ -! -[ -Build -status -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -workflows -/ -ci -/ -badge -. -svg -) -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -actions -) -[ -! -[ -Crates -. -io -] -( -https -: -/ -/ -img -. -shields -. -io -/ -crates -/ -v -/ -regex -- -automata -. -svg -) -] -( -https -: -/ -/ -crates -. -io -/ -crates -/ -regex -- -automata -) -# -# -# -Documentation -https -: -/ -/ -docs -. -rs -/ -regex -- -automata -# -# -# -Example -This -example -shows -how -to -search -for -matches -of -multiple -regexes -where -each -regex -uses -the -same -capture -group -names -to -parse -different -key -- -value -formats -. -rust -use -regex_automata -: -: -{ -meta -: -: -Regex -PatternID -} -; -let -re -= -Regex -: -: -new_many -( -& -[ -r -# -" -( -? -m -) -^ -( -? -< -key -> -[ -[ -: -word -: -] -] -+ -) -= -( -? -< -val -> -[ -[ -: -word -: -] -] -+ -) -" -# -r -# -" -( -? -m -) -^ -( -? -< -key -> -[ -[ -: -word -: -] -] -+ -) -= -" -( -? -< -val -> -[ -^ -" -] -+ -) -" -" -# -r -# -" -( -? -m -) -^ -( -? -< -key -> -[ -[ -: -word -: -] -] -+ -) -= -' -( -? -< -val -> -[ -^ -' -] -+ -) -' -" -# -r -# -" -( -? -m -) -^ -( -? -< -key -> -[ -[ -: -word -: -] -] -+ -) -: -\ -s -* -( -? -< -val -> -[ -[ -: -word -: -] -] -+ -) -" -# -] -) -. -unwrap -( -) -; -let -hay -= -r -# -" -best_album -= -" -Blow -Your -Face -Out -" -best_quote -= -' -" -then -as -it -was -then -again -it -will -be -" -' -best_year -= -1973 -best_simpsons_episode -: -HOMR -" -# -; -let -mut -kvs -= -vec -! -[ -] -; -for -caps -in -re -. -captures_iter -( -hay -) -{ -/ -/ -N -. -B -. -One -could -use -capture -indices -' -1 -' -and -' -2 -' -here -/ -/ -as -well -. -Capture -indices -are -local -to -each -pattern -. -/ -/ -( -Just -like -names -are -. -) -let -key -= -& -hay -[ -caps -. -get_group_by_name -( -" -key -" -) -. -unwrap -( -) -] -; -let -val -= -& -hay -[ -caps -. -get_group_by_name -( -" -val -" -) -. -unwrap -( -) -] -; -kvs -. -push -( -( -key -val -) -) -; -} -assert_eq -! -( -kvs -vec -! -[ -( -" -best_album -" -" -Blow -Your -Face -Out -" -) -( -" -best_quote -" -" -\ -" -then -as -it -was -then -again -it -will -be -\ -" -" -) -( -" -best_year -" -" -1973 -" -) -( -" -best_simpsons_episode -" -" -HOMR -" -) -] -) -; -# -# -# -Safety -* -* -I -welcome -audits -of -unsafe -code -. -* -* -This -crate -tries -to -be -extremely -conservative -in -its -use -of -unsafe -but -does -use -it -in -a -few -spots -. -In -general -I -am -very -open -to -removing -uses -of -unsafe -if -it -doesn -' -t -result -in -measurable -performance -regressions -and -doesn -' -t -result -in -significantly -more -complex -code -. -Below -is -an -outline -of -how -unsafe -is -used -in -this -crate -. -* -util -: -: -pool -: -: -Pool -makes -use -of -unsafe -to -implement -a -fast -path -for -accessing -an -element -of -the -pool -. -The -fast -path -applies -to -the -first -thread -that -uses -the -pool -. -In -effect -the -fast -path -is -fast -because -it -avoid -a -mutex -lock -. -unsafe -is -also -used -in -the -no -- -std -version -of -Pool -to -implement -a -spin -lock -for -synchronization -. -* -util -: -: -lazy -: -: -Lazy -uses -unsafe -to -implement -a -variant -of -once_cell -: -: -sync -: -: -Lazy -that -works -in -no -- -std -environments -. -A -no -- -std -no -- -alloc -implementation -is -also -provided -that -requires -use -of -unsafe -. -* -The -dfa -module -makes -extensive -use -of -unsafe -to -support -zero -- -copy -deserialization -of -DFAs -. -The -high -level -problem -is -that -you -need -to -get -from -& -[ -u8 -] -to -the -internal -representation -of -a -DFA -without -doing -any -copies -. -This -is -required -for -support -in -no -- -std -no -- -alloc -environments -. -It -also -makes -deserialization -extremely -cheap -. -* -The -dfa -and -hybrid -modules -use -unsafe -to -explicitly -elide -bounds -checks -in -the -core -search -loops -. -This -makes -the -codegen -tighter -and -typically -leads -to -consistent -5 -- -10 -% -performance -improvements -on -some -workloads -. -In -general -the -above -reflect -the -only -uses -of -unsafe -throughout -the -entire -regex -crate -. -At -present -there -are -no -plans -to -meaningfully -expand -the -use -of -unsafe -. -With -that -said -one -thing -folks -have -been -asking -for -is -cheap -deserialization -of -a -regex -: -: -Regex -. -My -sense -is -that -this -feature -will -require -a -lot -more -unsafe -in -places -to -support -zero -- -copy -deserialization -. -It -is -unclear -at -this -point -whether -this -will -be -pursued -. -# -# -# -Motivation -I -started -out -building -this -crate -because -I -wanted -to -re -- -work -the -regex -crate -internals -to -make -it -more -amenable -to -optimizations -. -It -turns -out -that -there -are -a -lot -of -different -ways -to -build -regex -engines -and -even -more -ways -to -compose -them -. -Moreover -heuristic -literal -optimizations -are -often -tricky -to -get -correct -but -the -fruit -they -bear -is -attractive -. -All -of -these -things -were -difficult -to -expand -upon -without -risking -the -introduction -of -more -bugs -. -So -I -decided -to -tear -things -down -and -start -fresh -. -In -the -course -of -doing -so -I -ended -up -designing -strong -boundaries -between -each -component -so -that -each -component -could -be -reasoned -and -tested -independently -. -This -also -made -it -somewhat -natural -to -expose -the -components -as -a -library -unto -itself -. -Namely -folks -have -been -asking -for -more -capabilities -in -the -regex -crate -for -a -long -time -but -these -capabilities -usually -come -with -additional -API -complexity -that -I -didn -' -t -want -to -introduce -in -the -regex -crate -proper -. -But -exposing -them -in -an -" -expert -" -level -crate -like -regex -- -automata -seemed -quite -fine -. -In -the -end -I -do -still -somewhat -consider -this -crate -an -experiment -. -It -is -unclear -whether -the -strong -boundaries -between -components -will -be -an -impediment -to -ongoing -development -or -not -. -De -- -coupling -tends -to -lead -to -slower -development -in -my -experience -and -when -you -mix -in -the -added -cost -of -not -introducing -breaking -changes -all -of -the -time -things -can -get -quite -complicated -. -But -I -don -' -t -think -anyone -has -ever -release -the -internals -of -a -regex -engine -as -a -library -before -. -So -it -will -be -interesting -to -see -how -it -plays -out -! diff --git a/third_party/rust/regex-automata/src/dfa/accel.rs b/third_party/rust/regex-automata/src/dfa/accel.rs deleted file mode 100644 index 0284ac7e661d5..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/accel.rs +++ /dev/null @@ -1,4941 +0,0 @@ -/ -/ -This -module -defines -some -core -types -for -dealing -with -accelerated -DFA -states -. -/ -/ -Briefly -a -DFA -state -can -be -" -accelerated -" -if -all -of -its -transitions -except -/ -/ -for -a -few -loop -back -to -itself -. -This -directly -implies -that -the -only -way -out -/ -/ -of -such -a -state -is -if -a -byte -corresponding -to -one -of -those -non -- -loopback -/ -/ -transitions -is -found -. -Such -states -are -often -found -in -simple -repetitions -in -/ -/ -non -- -Unicode -regexes -. -For -example -consider -' -( -? -- -u -) -[ -^ -a -] -+ -a -' -. -We -can -look -at -its -/ -/ -DFA -with -regex -- -cli -: -/ -/ -/ -/ -regex -- -cli -debug -dfa -dense -' -( -? -- -u -) -[ -^ -a -] -+ -a -' -- -BbC -/ -/ -dense -: -: -DFA -( -/ -/ -D -000000 -: -/ -/ -Q -000001 -: -/ -/ -* -000002 -: -/ -/ -A -000003 -: -\ -x00 -- -= -> -3 -a -= -> -5 -b -- -\ -xFF -= -> -3 -/ -/ -> -000004 -: -\ -x00 -- -= -> -3 -a -= -> -4 -b -- -\ -xFF -= -> -3 -/ -/ -000005 -: -\ -x00 -- -\ -xFF -= -> -2 -EOI -= -> -2 -/ -/ -) -/ -/ -/ -/ -In -particular -state -3 -is -accelerated -( -shown -via -the -' -A -' -indicator -) -since -/ -/ -the -only -way -to -leave -that -state -once -entered -is -to -see -an -' -a -' -byte -. -If -/ -/ -there -is -a -long -run -of -non -- -' -a -' -bytes -then -using -something -like -' -memchr -' -/ -/ -to -find -the -next -' -a -' -byte -can -be -significantly -faster -than -just -using -the -/ -/ -standard -byte -- -at -- -a -- -time -state -machine -. -/ -/ -/ -/ -Unfortunately -this -optimization -rarely -applies -when -Unicode -is -enabled -. -/ -/ -For -example -patterns -like -' -[ -^ -a -] -' -don -' -t -actually -match -any -byte -that -isn -' -t -/ -/ -' -a -' -but -rather -any -UTF -- -8 -encoding -of -a -Unicode -scalar -value -that -isn -' -t -/ -/ -' -a -' -. -This -makes -the -state -machine -much -more -complex -- -- -- -far -beyond -a -single -/ -/ -state -- -- -- -and -removes -the -ability -to -easily -accelerate -it -. -( -Because -if -the -/ -/ -machine -sees -a -non -- -UTF -- -8 -sequence -then -the -machine -won -' -t -match -through -it -. -) -/ -/ -/ -/ -In -practice -we -only -consider -accelerating -states -that -have -3 -or -fewer -/ -/ -non -- -loop -transitions -. -At -a -certain -point -you -get -diminishing -returns -but -/ -/ -also -because -that -' -s -what -the -memchr -crate -supports -. -The -structures -below -/ -/ -hard -- -code -this -assumption -and -provide -( -de -) -serialization -APIs -for -use -inside -/ -/ -a -DFA -. -/ -/ -/ -/ -And -finally -note -that -there -is -some -trickery -involved -in -making -it -very -/ -/ -fast -to -not -only -check -whether -a -state -is -accelerated -at -search -time -but -/ -/ -also -to -access -the -bytes -to -search -for -to -implement -the -acceleration -itself -. -/ -/ -dfa -/ -special -. -rs -provides -more -detail -but -the -short -story -is -that -all -/ -/ -accelerated -states -appear -contiguously -in -a -DFA -. -This -means -we -can -represent -/ -/ -the -ID -space -of -all -accelerated -DFA -states -with -a -single -range -. -So -given -/ -/ -a -state -ID -we -can -determine -whether -it -' -s -accelerated -via -/ -/ -/ -/ -min_accel_id -< -= -id -< -= -max_accel_id -/ -/ -/ -/ -And -find -its -corresponding -accelerator -with -: -/ -/ -/ -/ -accels -. -get -( -( -id -- -min_accel_id -) -/ -dfa_stride -) -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -util -: -: -{ -int -: -: -Pointer -memchr -wire -: -: -{ -self -DeserializeError -Endian -SerializeError -} -} -; -/ -/ -/ -The -base -type -used -to -represent -a -collection -of -accelerators -. -/ -/ -/ -/ -/ -/ -While -an -Accel -is -represented -as -a -fixed -size -array -of -bytes -a -/ -/ -/ -* -collection -* -of -Accel -s -( -called -Accels -) -is -represented -internally -as -a -/ -/ -/ -slice -of -u32 -. -While -it -' -s -a -bit -unnatural -to -do -this -and -costs -us -a -bit -of -/ -/ -/ -fairly -low -- -risk -not -- -safe -code -it -lets -us -remove -the -need -for -a -second -type -/ -/ -/ -parameter -in -the -definition -of -dense -: -: -DFA -. -( -Which -really -wants -everything -/ -/ -/ -to -be -a -slice -of -u32 -. -) -type -AccelTy -= -u32 -; -/ -/ -/ -The -size -of -the -unit -of -representation -for -accelerators -. -/ -/ -/ -/ -/ -/ -ACCEL_CAP -* -must -* -be -a -multiple -of -this -size -. -const -ACCEL_TY_SIZE -: -usize -= -core -: -: -mem -: -: -size_of -: -: -< -AccelTy -> -( -) -; -/ -/ -/ -The -maximum -length -in -bytes -that -a -single -Accel -can -be -. -This -is -distinct -/ -/ -/ -from -the -capacity -of -an -accelerator -in -that -the -length -represents -only -the -/ -/ -/ -bytes -that -should -be -read -. -const -ACCEL_LEN -: -usize -= -4 -; -/ -/ -/ -The -capacity -of -each -accelerator -in -bytes -. -We -set -this -to -8 -since -it -' -s -a -/ -/ -/ -multiple -of -4 -( -our -ID -size -) -and -because -it -gives -us -a -little -wiggle -room -/ -/ -/ -if -we -want -to -support -more -accel -bytes -in -the -future -without -a -breaking -/ -/ -/ -change -. -/ -/ -/ -/ -/ -/ -This -MUST -be -a -multiple -of -ACCEL_TY_SIZE -. -const -ACCEL_CAP -: -usize -= -8 -; -/ -/ -/ -Search -for -between -1 -and -3 -needle -bytes -in -the -given -haystack -starting -the -/ -/ -/ -search -at -the -given -position -. -If -needles -has -a -length -other -than -1 -- -3 -/ -/ -/ -then -this -panics -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -find_fwd -( -needles -: -& -[ -u8 -] -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Option -< -usize -> -{ -let -bs -= -needles -; -let -i -= -match -needles -. -len -( -) -{ -1 -= -> -memchr -: -: -memchr -( -bs -[ -0 -] -& -haystack -[ -at -. -. -] -) -? -2 -= -> -memchr -: -: -memchr2 -( -bs -[ -0 -] -bs -[ -1 -] -& -haystack -[ -at -. -. -] -) -? -3 -= -> -memchr -: -: -memchr3 -( -bs -[ -0 -] -bs -[ -1 -] -bs -[ -2 -] -& -haystack -[ -at -. -. -] -) -? -0 -= -> -panic -! -( -" -cannot -find -with -empty -needles -" -) -n -= -> -panic -! -( -" -invalid -needles -length -: -{ -} -" -n -) -} -; -Some -( -at -+ -i -) -} -/ -/ -/ -Search -for -between -1 -and -3 -needle -bytes -in -the -given -haystack -in -reverse -/ -/ -/ -starting -the -search -at -the -given -position -. -If -needles -has -a -length -other -/ -/ -/ -than -1 -- -3 -then -this -panics -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -find_rev -( -needles -: -& -[ -u8 -] -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Option -< -usize -> -{ -let -bs -= -needles -; -match -needles -. -len -( -) -{ -1 -= -> -memchr -: -: -memrchr -( -bs -[ -0 -] -& -haystack -[ -. -. -at -] -) -2 -= -> -memchr -: -: -memrchr2 -( -bs -[ -0 -] -bs -[ -1 -] -& -haystack -[ -. -. -at -] -) -3 -= -> -memchr -: -: -memrchr3 -( -bs -[ -0 -] -bs -[ -1 -] -bs -[ -2 -] -& -haystack -[ -. -. -at -] -) -0 -= -> -panic -! -( -" -cannot -find -with -empty -needles -" -) -n -= -> -panic -! -( -" -invalid -needles -length -: -{ -} -" -n -) -} -} -/ -/ -/ -Represents -the -accelerators -for -all -accelerated -states -in -a -dense -DFA -. -/ -/ -/ -/ -/ -/ -The -A -type -parameter -represents -the -type -of -the -underlying -bytes -. -/ -/ -/ -Generally -this -is -either -& -[ -AccelTy -] -or -Vec -< -AccelTy -> -. -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -Accels -< -A -> -{ -/ -/ -/ -A -length -prefixed -slice -of -contiguous -accelerators -. -See -the -top -comment -/ -/ -/ -in -this -module -for -more -details -on -how -we -can -jump -from -a -DFA -' -s -state -/ -/ -/ -ID -to -an -accelerator -in -this -list -. -/ -/ -/ -/ -/ -/ -The -first -4 -bytes -always -correspond -to -the -number -of -accelerators -/ -/ -/ -that -follow -. -accels -: -A -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -Accels -< -Vec -< -AccelTy -> -> -{ -/ -/ -/ -Create -an -empty -sequence -of -accelerators -for -a -DFA -. -pub -fn -empty -( -) -- -> -Accels -< -Vec -< -AccelTy -> -> -{ -Accels -{ -accels -: -vec -! -[ -0 -] -} -} -/ -/ -/ -Add -an -accelerator -to -this -sequence -. -/ -/ -/ -/ -/ -/ -This -adds -to -the -accelerator -to -the -end -of -the -sequence -and -therefore -/ -/ -/ -should -be -done -in -correspondence -with -its -state -in -the -DFA -. -/ -/ -/ -/ -/ -/ -This -panics -if -this -results -in -more -accelerators -than -AccelTy -: -: -MAX -. -pub -fn -add -( -& -mut -self -accel -: -Accel -) -{ -self -. -accels -. -extend_from_slice -( -& -accel -. -as_accel_tys -( -) -) -; -let -len -= -self -. -len -( -) -; -self -. -set_len -( -len -+ -1 -) -; -} -/ -/ -/ -Set -the -number -of -accelerators -in -this -sequence -which -is -encoded -in -/ -/ -/ -the -first -4 -bytes -of -the -underlying -bytes -. -fn -set_len -( -& -mut -self -new_len -: -usize -) -{ -/ -/ -The -only -way -an -accelerator -gets -added -is -if -a -state -exists -for -/ -/ -it -and -if -a -state -exists -then -its -index -is -guaranteed -to -be -/ -/ -representable -by -a -AccelTy -by -virtue -of -the -guarantees -provided -by -/ -/ -StateID -. -let -new_len -= -AccelTy -: -: -try_from -( -new_len -) -. -unwrap -( -) -; -self -. -accels -[ -0 -] -= -new_len -; -} -} -impl -< -' -a -> -Accels -< -& -' -a -[ -AccelTy -] -> -{ -/ -/ -/ -Deserialize -a -sequence -of -accelerators -from -the -given -bytes -. -If -there -/ -/ -/ -was -a -problem -deserializing -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -run -in -constant -time -. -This -does -not -guarantee -/ -/ -/ -that -every -accelerator -in -the -returned -collection -is -valid -. -Thus -/ -/ -/ -accessing -one -may -panic -or -not -- -safe -code -that -relies -on -accelerators -/ -/ -/ -being -correct -my -result -in -UB -. -/ -/ -/ -/ -/ -/ -Callers -may -check -the -validity -of -every -accelerator -with -the -validate -/ -/ -/ -method -. -pub -fn -from_bytes_unchecked -( -mut -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -Accels -< -& -' -a -[ -AccelTy -] -> -usize -) -DeserializeError -> -{ -let -slice_start -= -slice -. -as_ptr -( -) -. -as_usize -( -) -; -let -( -accel_len -_ -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -accelerators -length -" -) -? -; -/ -/ -The -accelerator -length -is -part -of -the -accel_tys -slice -that -/ -/ -we -deserialize -. -This -is -perhaps -a -bit -idiosyncratic -. -It -would -/ -/ -probably -be -better -to -split -out -the -length -into -a -real -field -. -let -accel_tys_len -= -wire -: -: -add -( -wire -: -: -mul -( -accel_len -2 -" -total -number -of -accelerator -accel_tys -" -) -? -1 -" -total -number -of -accel_tys -" -) -? -; -let -accel_tys_bytes_len -= -wire -: -: -mul -( -ACCEL_TY_SIZE -accel_tys_len -" -total -number -of -bytes -in -accelerators -" -) -? -; -wire -: -: -check_slice_len -( -slice -accel_tys_bytes_len -" -accelerators -" -) -? -; -wire -: -: -check_alignment -: -: -< -AccelTy -> -( -slice -) -? -; -let -accel_tys -= -& -slice -[ -. -. -accel_tys_bytes_len -] -; -slice -= -& -slice -[ -accel_tys_bytes_len -. -. -] -; -/ -/ -SAFETY -: -We -' -ve -checked -the -length -and -alignment -above -and -since -/ -/ -slice -is -just -bytes -and -AccelTy -is -just -a -u32 -we -can -safely -cast -to -/ -/ -a -slice -of -& -[ -AccelTy -] -. -let -accels -= -unsafe -{ -core -: -: -slice -: -: -from_raw_parts -( -accel_tys -. -as_ptr -( -) -. -cast -: -: -< -AccelTy -> -( -) -accel_tys_len -) -} -; -Ok -( -( -Accels -{ -accels -} -slice -. -as_ptr -( -) -. -as_usize -( -) -- -slice_start -) -) -} -} -impl -< -A -: -AsRef -< -[ -AccelTy -] -> -> -Accels -< -A -> -{ -/ -/ -/ -Return -an -owned -version -of -the -accelerators -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -fn -to_owned -( -& -self -) -- -> -Accels -< -alloc -: -: -vec -: -: -Vec -< -AccelTy -> -> -{ -Accels -{ -accels -: -self -. -accels -. -as_ref -( -) -. -to_vec -( -) -} -} -/ -/ -/ -Return -a -borrowed -version -of -the -accelerators -. -pub -fn -as_ref -( -& -self -) -- -> -Accels -< -& -[ -AccelTy -] -> -{ -Accels -{ -accels -: -self -. -accels -. -as_ref -( -) -} -} -/ -/ -/ -Return -the -bytes -representing -the -serialization -of -the -accelerators -. -pub -fn -as_bytes -( -& -self -) -- -> -& -[ -u8 -] -{ -let -accels -= -self -. -accels -. -as_ref -( -) -; -/ -/ -SAFETY -: -This -is -safe -because -accels -is -a -just -a -slice -of -AccelTy -/ -/ -and -u8 -always -has -a -smaller -alignment -. -unsafe -{ -core -: -: -slice -: -: -from_raw_parts -( -accels -. -as_ptr -( -) -. -cast -: -: -< -u8 -> -( -) -accels -. -len -( -) -* -ACCEL_TY_SIZE -) -} -} -/ -/ -/ -Returns -the -memory -usage -in -bytes -of -these -accelerators -. -/ -/ -/ -/ -/ -/ -The -memory -usage -is -computed -based -on -the -number -of -bytes -used -to -/ -/ -/ -represent -all -of -the -accelerators -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -by -this -value -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -as_bytes -( -) -. -len -( -) -} -/ -/ -/ -Return -the -bytes -to -search -for -corresponding -to -the -accelerator -in -this -/ -/ -/ -sequence -at -index -i -. -If -no -such -accelerator -exists -then -this -panics -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -index -is -that -it -should -be -in -correspondence -/ -/ -/ -with -the -index -of -the -corresponding -DFA -. -That -is -accelerated -DFA -/ -/ -/ -states -are -stored -contiguously -in -the -DFA -and -have -an -ordering -implied -/ -/ -/ -by -their -respective -state -IDs -. -The -state -' -s -index -in -that -sequence -/ -/ -/ -corresponds -to -the -index -of -its -corresponding -accelerator -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -fn -needles -( -& -self -i -: -usize -) -- -> -& -[ -u8 -] -{ -if -i -> -= -self -. -len -( -) -{ -panic -! -( -" -invalid -accelerator -index -{ -} -" -i -) -; -} -let -bytes -= -self -. -as_bytes -( -) -; -let -offset -= -ACCEL_TY_SIZE -+ -i -* -ACCEL_CAP -; -let -len -= -usize -: -: -from -( -bytes -[ -offset -] -) -; -& -bytes -[ -offset -+ -1 -. -. -offset -+ -1 -+ -len -] -} -/ -/ -/ -Return -the -total -number -of -accelerators -in -this -sequence -. -pub -fn -len -( -& -self -) -- -> -usize -{ -/ -/ -This -should -never -panic -since -deserialization -checks -that -the -/ -/ -length -can -fit -into -a -usize -. -usize -: -: -try_from -( -self -. -accels -. -as_ref -( -) -[ -0 -] -) -. -unwrap -( -) -} -/ -/ -/ -Return -the -accelerator -in -this -sequence -at -index -i -. -If -no -such -/ -/ -/ -accelerator -exists -then -this -returns -None -. -/ -/ -/ -/ -/ -/ -See -the -docs -for -needles -on -the -significance -of -the -index -. -fn -get -( -& -self -i -: -usize -) -- -> -Option -< -Accel -> -{ -if -i -> -= -self -. -len -( -) -{ -return -None -; -} -let -offset -= -ACCEL_TY_SIZE -+ -i -* -ACCEL_CAP -; -let -accel -= -Accel -: -: -from_slice -( -& -self -. -as_bytes -( -) -[ -offset -. -. -] -) -. -expect -( -" -Accels -must -contain -valid -accelerators -" -) -; -Some -( -accel -) -} -/ -/ -/ -Returns -an -iterator -of -accelerators -in -this -sequence -. -fn -iter -( -& -self -) -- -> -IterAccels -< -' -_ -A -> -{ -IterAccels -{ -accels -: -self -i -: -0 -} -} -/ -/ -/ -Writes -these -accelerators -to -the -given -byte -buffer -using -the -indicated -/ -/ -/ -endianness -. -If -the -given -buffer -is -too -small -then -an -error -is -/ -/ -/ -returned -. -Upon -success -the -total -number -of -bytes -written -is -returned -. -/ -/ -/ -The -number -of -bytes -written -is -guaranteed -to -be -a -multiple -of -8 -. -pub -fn -write_to -< -E -: -Endian -> -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -assert_eq -! -( -nwrite -% -ACCEL_TY_SIZE -0 -" -expected -accelerator -bytes -written -to -be -a -multiple -of -{ -} -" -ACCEL_TY_SIZE -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -accelerators -" -) -) -; -} -/ -/ -The -number -of -accelerators -can -never -exceed -AccelTy -: -: -MAX -. -E -: -: -write_u32 -( -AccelTy -: -: -try_from -( -self -. -len -( -) -) -. -unwrap -( -) -dst -) -; -/ -/ -The -actual -accelerators -are -just -raw -bytes -and -thus -their -endianness -/ -/ -is -irrelevant -. -So -we -can -copy -them -as -bytes -. -dst -[ -ACCEL_TY_SIZE -. -. -nwrite -] -. -copy_from_slice -( -& -self -. -as_bytes -( -) -[ -ACCEL_TY_SIZE -. -. -nwrite -] -) -; -Ok -( -nwrite -) -} -/ -/ -/ -Validates -that -every -accelerator -in -this -collection -can -be -successfully -/ -/ -/ -deserialized -as -a -valid -accelerator -. -pub -fn -validate -( -& -self -) -- -> -Result -< -( -) -DeserializeError -> -{ -for -chunk -in -self -. -as_bytes -( -) -[ -ACCEL_TY_SIZE -. -. -] -. -chunks -( -ACCEL_CAP -) -{ -let -_ -= -Accel -: -: -from_slice -( -chunk -) -? -; -} -Ok -( -( -) -) -} -/ -/ -/ -Returns -the -total -number -of -bytes -written -by -write_to -. -pub -fn -write_to_len -( -& -self -) -- -> -usize -{ -self -. -as_bytes -( -) -. -len -( -) -} -} -impl -< -A -: -AsRef -< -[ -AccelTy -] -> -> -core -: -: -fmt -: -: -Debug -for -Accels -< -A -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -Accels -( -" -) -? -; -let -mut -list -= -f -. -debug_list -( -) -; -for -a -in -self -. -iter -( -) -{ -list -. -entry -( -& -a -) -; -} -list -. -finish -( -) -? -; -write -! -( -f -" -) -" -) -} -} -# -[ -derive -( -Debug -) -] -struct -IterAccels -< -' -a -A -: -AsRef -< -[ -AccelTy -] -> -> -{ -accels -: -& -' -a -Accels -< -A -> -i -: -usize -} -impl -< -' -a -A -: -AsRef -< -[ -AccelTy -] -> -> -Iterator -for -IterAccels -< -' -a -A -> -{ -type -Item -= -Accel -; -fn -next -( -& -mut -self -) -- -> -Option -< -Accel -> -{ -let -accel -= -self -. -accels -. -get -( -self -. -i -) -? -; -self -. -i -+ -= -1 -; -Some -( -accel -) -} -} -/ -/ -/ -Accel -represents -a -structure -for -determining -how -to -" -accelerate -" -a -DFA -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -Namely -it -contains -zero -or -more -bytes -that -must -be -seen -in -order -for -the -/ -/ -/ -DFA -to -leave -the -state -it -is -associated -with -. -In -practice -the -actual -range -/ -/ -/ -is -1 -to -3 -bytes -. -/ -/ -/ -/ -/ -/ -The -purpose -of -acceleration -is -to -identify -states -whose -vast -majority -/ -/ -/ -of -transitions -are -just -loops -back -to -the -same -state -. -For -example -/ -/ -/ -in -the -regex -( -? -- -u -) -^ -[ -^ -a -] -+ -b -the -corresponding -DFA -will -have -a -state -/ -/ -/ -( -corresponding -to -[ -^ -a -] -+ -) -where -all -transitions -* -except -* -for -a -and -/ -/ -/ -b -loop -back -to -itself -. -Thus -this -state -can -be -" -accelerated -" -by -simply -/ -/ -/ -looking -for -the -next -occurrence -of -either -a -or -b -instead -of -explicitly -/ -/ -/ -following -transitions -. -( -In -this -case -b -transitions -to -the -next -state -/ -/ -/ -where -as -a -would -transition -to -the -dead -state -. -) -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -Accel -{ -/ -/ -/ -The -first -byte -is -the -length -. -Subsequent -bytes -are -the -accelerated -/ -/ -/ -bytes -. -/ -/ -/ -/ -/ -/ -Note -that -we -make -every -accelerator -8 -bytes -as -a -slightly -wasteful -/ -/ -/ -way -of -making -sure -alignment -is -always -correct -for -state -ID -sizes -of -/ -/ -/ -1 -2 -4 -and -8 -. -This -should -be -okay -since -accelerated -states -aren -' -t -/ -/ -/ -particularly -common -especially -when -Unicode -is -enabled -. -bytes -: -[ -u8 -; -ACCEL_CAP -] -} -impl -Accel -{ -/ -/ -/ -Returns -an -empty -accel -where -no -bytes -are -accelerated -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -new -( -) -- -> -Accel -{ -Accel -{ -bytes -: -[ -0 -; -ACCEL_CAP -] -} -} -/ -/ -/ -Returns -a -verified -accelerator -derived -from -the -beginning -of -the -given -/ -/ -/ -slice -. -/ -/ -/ -/ -/ -/ -If -the -slice -is -not -long -enough -or -contains -invalid -bytes -for -an -/ -/ -/ -accelerator -then -this -returns -an -error -. -pub -fn -from_slice -( -mut -slice -: -& -[ -u8 -] -) -- -> -Result -< -Accel -DeserializeError -> -{ -slice -= -& -slice -[ -. -. -core -: -: -cmp -: -: -min -( -ACCEL_LEN -slice -. -len -( -) -) -] -; -let -bytes -= -slice -. -try_into -( -) -. -map_err -( -| -_ -| -DeserializeError -: -: -buffer_too_small -( -" -accelerator -" -) -) -? -; -Accel -: -: -from_bytes -( -bytes -) -} -/ -/ -/ -Returns -a -verified -accelerator -derived -from -raw -bytes -. -/ -/ -/ -/ -/ -/ -If -the -given -bytes -are -invalid -then -this -returns -an -error -. -fn -from_bytes -( -bytes -: -[ -u8 -; -4 -] -) -- -> -Result -< -Accel -DeserializeError -> -{ -if -usize -: -: -from -( -bytes -[ -0 -] -) -> -= -ACCEL_LEN -{ -return -Err -( -DeserializeError -: -: -generic -( -" -accelerator -bytes -cannot -have -length -more -than -3 -" -) -) -; -} -Ok -( -Accel -: -: -from_bytes_unchecked -( -bytes -) -) -} -/ -/ -/ -Returns -an -accelerator -derived -from -raw -bytes -. -/ -/ -/ -/ -/ -/ -This -does -not -check -whether -the -given -bytes -are -valid -. -Invalid -bytes -/ -/ -/ -cannot -sacrifice -memory -safety -but -may -result -in -panics -or -silent -/ -/ -/ -logic -bugs -. -fn -from_bytes_unchecked -( -bytes -: -[ -u8 -; -4 -] -) -- -> -Accel -{ -Accel -{ -bytes -: -[ -bytes -[ -0 -] -bytes -[ -1 -] -bytes -[ -2 -] -bytes -[ -3 -] -0 -0 -0 -0 -] -} -} -/ -/ -/ -Attempts -to -add -the -given -byte -to -this -accelerator -. -If -the -accelerator -/ -/ -/ -is -already -full -or -thinks -the -byte -is -a -poor -accelerator -then -this -/ -/ -/ -returns -false -. -Otherwise -returns -true -. -/ -/ -/ -/ -/ -/ -If -the -given -byte -is -already -in -this -accelerator -then -it -panics -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -add -( -& -mut -self -byte -: -u8 -) -- -> -bool -{ -if -self -. -len -( -) -> -= -3 -{ -return -false -; -} -/ -/ -As -a -special -case -we -totally -reject -trying -to -accelerate -a -state -/ -/ -with -an -ASCII -space -. -In -most -cases -it -occurs -very -frequently -and -/ -/ -tends -to -result -in -worse -overall -performance -. -if -byte -= -= -b -' -' -{ -return -false -; -} -assert -! -( -! -self -. -contains -( -byte -) -" -accelerator -already -contains -{ -: -? -} -" -crate -: -: -util -: -: -escape -: -: -DebugByte -( -byte -) -) -; -self -. -bytes -[ -self -. -len -( -) -+ -1 -] -= -byte -; -self -. -bytes -[ -0 -] -+ -= -1 -; -true -} -/ -/ -/ -Return -the -number -of -bytes -in -this -accelerator -. -pub -fn -len -( -& -self -) -- -> -usize -{ -usize -: -: -from -( -self -. -bytes -[ -0 -] -) -} -/ -/ -/ -Returns -true -if -and -only -if -there -are -no -bytes -in -this -accelerator -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -len -( -) -= -= -0 -} -/ -/ -/ -Returns -the -slice -of -bytes -to -accelerate -. -/ -/ -/ -/ -/ -/ -If -this -accelerator -is -empty -then -this -returns -an -empty -slice -. -fn -needles -( -& -self -) -- -> -& -[ -u8 -] -{ -& -self -. -bytes -[ -1 -. -. -1 -+ -self -. -len -( -) -] -} -/ -/ -/ -Returns -true -if -and -only -if -this -accelerator -will -accelerate -the -given -/ -/ -/ -byte -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -contains -( -& -self -byte -: -u8 -) -- -> -bool -{ -self -. -needles -( -) -. -iter -( -) -. -position -( -| -& -b -| -b -= -= -byte -) -. -is_some -( -) -} -/ -/ -/ -Returns -the -accelerator -bytes -as -an -array -of -AccelTys -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -as_accel_tys -( -& -self -) -- -> -[ -AccelTy -; -2 -] -{ -assert_eq -! -( -ACCEL_CAP -8 -) -; -/ -/ -These -unwraps -are -OK -since -ACCEL_CAP -is -set -to -8 -. -let -first -= -AccelTy -: -: -from_ne_bytes -( -self -. -bytes -[ -0 -. -. -4 -] -. -try_into -( -) -. -unwrap -( -) -) -; -let -second -= -AccelTy -: -: -from_ne_bytes -( -self -. -bytes -[ -4 -. -. -8 -] -. -try_into -( -) -. -unwrap -( -) -) -; -[ -first -second -] -} -} -impl -core -: -: -fmt -: -: -Debug -for -Accel -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -Accel -( -" -) -? -; -let -mut -set -= -f -. -debug_set -( -) -; -for -& -b -in -self -. -needles -( -) -{ -set -. -entry -( -& -crate -: -: -util -: -: -escape -: -: -DebugByte -( -b -) -) -; -} -set -. -finish -( -) -? -; -write -! -( -f -" -) -" -) -} -} diff --git a/third_party/rust/regex-automata/src/dfa/automaton.rs b/third_party/rust/regex-automata/src/dfa/automaton.rs deleted file mode 100644 index 93d09c768a64c..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/automaton.rs +++ /dev/null @@ -1,23149 +0,0 @@ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -use -crate -: -: -util -: -: -search -: -: -PatternSet -; -use -crate -: -: -{ -dfa -: -: -search -util -: -: -{ -empty -prefilter -: -: -Prefilter -primitives -: -: -{ -PatternID -StateID -} -search -: -: -{ -Anchored -HalfMatch -Input -MatchError -} -} -} -; -/ -/ -/ -A -trait -describing -the -interface -of -a -deterministic -finite -automaton -( -DFA -) -. -/ -/ -/ -/ -/ -/ -The -complexity -of -this -trait -probably -means -that -it -' -s -unlikely -for -others -/ -/ -/ -to -implement -it -. -The -primary -purpose -of -the -trait -is -to -provide -for -a -way -/ -/ -/ -of -abstracting -over -different -types -of -DFAs -. -In -this -crate -that -means -/ -/ -/ -dense -DFAs -and -sparse -DFAs -. -( -Dense -DFAs -are -fast -but -memory -hungry -where -/ -/ -/ -as -sparse -DFAs -are -slower -but -come -with -a -smaller -memory -footprint -. -But -/ -/ -/ -they -otherwise -provide -exactly -equivalent -expressive -power -. -) -For -example -a -/ -/ -/ -[ -dfa -: -: -regex -: -: -Regex -] -( -crate -: -: -dfa -: -: -regex -: -: -Regex -) -is -generic -over -this -trait -. -/ -/ -/ -/ -/ -/ -Normally -a -DFA -' -s -execution -model -is -very -simple -. -You -might -have -a -single -/ -/ -/ -start -state -zero -or -more -final -or -" -match -" -states -and -a -function -that -/ -/ -/ -transitions -from -one -state -to -the -next -given -the -next -byte -of -input -. -/ -/ -/ -Unfortunately -the -interface -described -by -this -trait -is -significantly -/ -/ -/ -more -complicated -than -this -. -The -complexity -has -a -number -of -different -/ -/ -/ -reasons -mostly -motivated -by -performance -functionality -or -space -savings -: -/ -/ -/ -/ -/ -/ -* -A -DFA -can -search -for -multiple -patterns -simultaneously -. -This -/ -/ -/ -means -extra -information -is -returned -when -a -match -occurs -. -Namely -/ -/ -/ -a -match -is -not -just -an -offset -but -an -offset -plus -a -pattern -ID -. -/ -/ -/ -[ -Automaton -: -: -pattern_len -] -returns -the -number -of -patterns -compiled -into -/ -/ -/ -the -DFA -[ -Automaton -: -: -match_len -] -returns -the -total -number -of -patterns -/ -/ -/ -that -match -in -a -particular -state -and -[ -Automaton -: -: -match_pattern -] -permits -/ -/ -/ -iterating -over -the -patterns -that -match -in -a -particular -state -. -/ -/ -/ -* -A -DFA -can -have -multiple -start -states -and -the -choice -of -which -start -/ -/ -/ -state -to -use -depends -on -the -content -of -the -string -being -searched -and -/ -/ -/ -position -of -the -search -as -well -as -whether -the -search -is -an -anchored -/ -/ -/ -search -for -a -specific -pattern -in -the -DFA -. -Moreover -computing -the -start -/ -/ -/ -state -also -depends -on -whether -you -' -re -doing -a -forward -or -a -reverse -search -. -/ -/ -/ -[ -Automaton -: -: -start_state_forward -] -and -[ -Automaton -: -: -start_state_reverse -] -/ -/ -/ -are -used -to -compute -the -start -state -for -forward -and -reverse -searches -/ -/ -/ -respectively -. -/ -/ -/ -* -All -matches -are -delayed -by -one -byte -to -support -things -like -and -\ -b -/ -/ -/ -at -the -end -of -a -pattern -. -Therefore -every -use -of -a -DFA -is -required -to -use -/ -/ -/ -[ -Automaton -: -: -next_eoi_state -] -/ -/ -/ -at -the -end -of -the -search -to -compute -the -final -transition -. -/ -/ -/ -* -For -optimization -reasons -some -states -are -treated -specially -. -Every -/ -/ -/ -state -is -either -special -or -not -which -can -be -determined -via -the -/ -/ -/ -[ -Automaton -: -: -is_special_state -] -method -. -If -it -' -s -special -then -the -state -/ -/ -/ -must -be -at -least -one -of -a -few -possible -types -of -states -. -( -Note -that -some -/ -/ -/ -types -can -overlap -for -example -a -match -state -can -also -be -an -accel -state -. -/ -/ -/ -But -some -types -can -' -t -. -If -a -state -is -a -dead -state -then -it -can -never -be -any -/ -/ -/ -other -type -of -state -. -) -Those -types -are -: -/ -/ -/ -* -A -dead -state -. -A -dead -state -means -the -DFA -will -never -enter -a -match -/ -/ -/ -state -. -This -can -be -queried -via -the -[ -Automaton -: -: -is_dead_state -] -method -. -/ -/ -/ -* -A -quit -state -. -A -quit -state -occurs -if -the -DFA -had -to -stop -the -search -/ -/ -/ -prematurely -for -some -reason -. -This -can -be -queried -via -the -/ -/ -/ -[ -Automaton -: -: -is_quit_state -] -method -. -/ -/ -/ -* -A -match -state -. -A -match -state -occurs -when -a -match -is -found -. -When -a -DFA -/ -/ -/ -enters -a -match -state -the -search -may -stop -immediately -( -when -looking -/ -/ -/ -for -the -earliest -match -) -or -it -may -continue -to -find -the -leftmost -- -first -/ -/ -/ -match -. -This -can -be -queried -via -the -[ -Automaton -: -: -is_match_state -] -/ -/ -/ -method -. -/ -/ -/ -* -A -start -state -. -A -start -state -is -where -a -search -begins -. -For -every -/ -/ -/ -search -there -is -exactly -one -start -state -that -is -used -however -a -/ -/ -/ -DFA -may -contain -many -start -states -. -When -the -search -is -in -a -start -/ -/ -/ -state -it -may -use -a -prefilter -to -quickly -skip -to -candidate -matches -/ -/ -/ -without -executing -the -DFA -on -every -byte -. -This -can -be -queried -via -the -/ -/ -/ -[ -Automaton -: -: -is_start_state -] -method -. -/ -/ -/ -* -An -accel -state -. -An -accel -state -is -a -state -that -is -accelerated -. -/ -/ -/ -That -is -it -is -a -state -where -_most_ -of -its -transitions -loop -back -to -/ -/ -/ -itself -and -only -a -small -number -of -transitions -lead -to -other -states -. -/ -/ -/ -This -kind -of -state -is -said -to -be -accelerated -because -a -search -routine -/ -/ -/ -can -quickly -look -for -the -bytes -leading -out -of -the -state -instead -of -/ -/ -/ -continuing -to -execute -the -DFA -on -each -byte -. -This -can -be -queried -via -the -/ -/ -/ -[ -Automaton -: -: -is_accel_state -] -method -. -And -the -bytes -that -lead -out -of -/ -/ -/ -the -state -can -be -queried -via -the -[ -Automaton -: -: -accelerator -] -method -. -/ -/ -/ -/ -/ -/ -There -are -a -number -of -provided -methods -on -this -trait -that -implement -/ -/ -/ -efficient -searching -( -for -forwards -and -backwards -) -with -a -DFA -using -/ -/ -/ -all -of -the -above -features -of -this -trait -. -In -particular -given -the -/ -/ -/ -complexity -of -all -these -features -implementing -a -search -routine -in -/ -/ -/ -this -trait -can -be -a -little -subtle -. -With -that -said -it -is -possible -to -/ -/ -/ -somewhat -simplify -the -search -routine -. -For -example -handling -accelerated -/ -/ -/ -states -is -strictly -optional -since -it -is -always -correct -to -assume -that -/ -/ -/ -Automaton -: -: -is_accel_state -returns -false -. -However -one -complex -part -of -/ -/ -/ -writing -a -search -routine -using -this -trait -is -handling -the -1 -- -byte -delay -of -a -/ -/ -/ -match -. -That -is -not -optional -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -This -trait -is -not -safe -to -implement -so -that -code -may -rely -on -the -/ -/ -/ -correctness -of -implementations -of -this -trait -to -avoid -undefined -behavior -. -/ -/ -/ -The -primary -correctness -guarantees -are -: -/ -/ -/ -/ -/ -/ -* -Automaton -: -: -start_state -always -returns -a -valid -state -ID -or -an -error -or -/ -/ -/ -panics -. -/ -/ -/ -* -Automaton -: -: -next_state -when -given -a -valid -state -ID -always -returns -/ -/ -/ -a -valid -state -ID -for -all -values -of -anchored -and -byte -or -otherwise -/ -/ -/ -panics -. -/ -/ -/ -/ -/ -/ -In -general -the -rest -of -the -methods -on -Automaton -need -to -uphold -their -/ -/ -/ -contracts -as -well -. -For -example -Automaton -: -: -is_dead -should -only -returns -/ -/ -/ -true -if -the -given -state -ID -is -actually -a -dead -state -. -pub -unsafe -trait -Automaton -{ -/ -/ -/ -Transitions -from -the -current -state -to -the -next -state -given -the -next -/ -/ -/ -byte -of -input -. -/ -/ -/ -/ -/ -/ -Implementations -must -guarantee -that -the -returned -ID -is -always -a -valid -/ -/ -/ -ID -when -current -refers -to -a -valid -ID -. -Moreover -the -transition -/ -/ -/ -function -must -be -defined -for -all -possible -values -of -input -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -given -ID -does -not -refer -to -a -valid -state -then -this -routine -/ -/ -/ -may -panic -but -it -also -may -not -panic -and -instead -return -an -invalid -ID -. -/ -/ -/ -However -if -the -caller -provides -an -invalid -ID -then -this -must -never -/ -/ -/ -sacrifice -memory -safety -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -simplistic -example -for -walking -a -DFA -for -a -given -haystack -/ -/ -/ -by -using -the -next_state -method -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -r -" -) -? -; -/ -/ -/ -let -haystack -= -" -bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -/ -/ -/ -let -mut -state -= -dfa -. -start_state_forward -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -/ -/ -/ -for -& -b -in -haystack -{ -/ -/ -/ -state -= -dfa -. -next_state -( -state -b -) -; -/ -/ -/ -} -/ -/ -/ -/ -/ -Matches -are -always -delayed -by -1 -byte -so -we -must -explicitly -walk -the -/ -/ -/ -/ -/ -special -" -EOI -" -transition -at -the -end -of -the -search -. -/ -/ -/ -state -= -dfa -. -next_eoi_state -( -state -) -; -/ -/ -/ -assert -! -( -dfa -. -is_match_state -( -state -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -next_state -( -& -self -current -: -StateID -input -: -u8 -) -- -> -StateID -; -/ -/ -/ -Transitions -from -the -current -state -to -the -next -state -given -the -next -/ -/ -/ -byte -of -input -. -/ -/ -/ -/ -/ -/ -Unlike -[ -Automaton -: -: -next_state -] -implementations -may -implement -this -/ -/ -/ -more -efficiently -by -assuming -that -the -current -state -ID -is -valid -. -/ -/ -/ -Typically -this -manifests -by -eliding -bounds -checks -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -of -this -method -must -guarantee -that -current -refers -to -a -valid -/ -/ -/ -state -ID -. -If -current -is -not -a -valid -state -ID -for -this -automaton -then -/ -/ -/ -calling -this -routine -may -result -in -undefined -behavior -. -/ -/ -/ -/ -/ -/ -If -current -is -valid -then -implementations -must -guarantee -that -the -ID -/ -/ -/ -returned -is -valid -for -all -possible -values -of -input -. -unsafe -fn -next_state_unchecked -( -& -self -current -: -StateID -input -: -u8 -) -- -> -StateID -; -/ -/ -/ -Transitions -from -the -current -state -to -the -next -state -for -the -special -/ -/ -/ -EOI -symbol -. -/ -/ -/ -/ -/ -/ -Implementations -must -guarantee -that -the -returned -ID -is -always -a -valid -/ -/ -/ -ID -when -current -refers -to -a -valid -ID -. -/ -/ -/ -/ -/ -/ -This -routine -must -be -called -at -the -end -of -every -search -in -a -correct -/ -/ -/ -implementation -of -search -. -Namely -DFAs -in -this -crate -delay -matches -/ -/ -/ -by -one -byte -in -order -to -support -look -- -around -operators -. -Thus -after -/ -/ -/ -reaching -the -end -of -a -haystack -a -search -implementation -must -follow -one -/ -/ -/ -last -EOI -transition -. -/ -/ -/ -/ -/ -/ -It -is -best -to -think -of -EOI -as -an -additional -symbol -in -the -alphabet -of -/ -/ -/ -a -DFA -that -is -distinct -from -every -other -symbol -. -That -is -the -alphabet -/ -/ -/ -of -DFAs -in -this -crate -has -a -logical -size -of -257 -instead -of -256 -where -/ -/ -/ -256 -corresponds -to -every -possible -inhabitant -of -u8 -. -( -In -practice -the -/ -/ -/ -physical -alphabet -size -may -be -smaller -because -of -alphabet -compression -/ -/ -/ -via -equivalence -classes -but -EOI -is -always -represented -somehow -in -the -/ -/ -/ -alphabet -. -) -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -given -ID -does -not -refer -to -a -valid -state -then -this -routine -/ -/ -/ -may -panic -but -it -also -may -not -panic -and -instead -return -an -invalid -ID -. -/ -/ -/ -However -if -the -caller -provides -an -invalid -ID -then -this -must -never -/ -/ -/ -sacrifice -memory -safety -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -simplistic -example -for -walking -a -DFA -for -a -given -haystack -/ -/ -/ -and -then -finishing -the -search -with -the -final -EOI -transition -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -r -" -) -? -; -/ -/ -/ -let -haystack -= -" -bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -The -unwrap -is -OK -because -we -aren -' -t -requesting -a -start -state -for -a -/ -/ -/ -/ -/ -specific -pattern -. -/ -/ -/ -let -mut -state -= -dfa -. -start_state_forward -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -/ -/ -/ -for -& -b -in -haystack -{ -/ -/ -/ -state -= -dfa -. -next_state -( -state -b -) -; -/ -/ -/ -} -/ -/ -/ -/ -/ -Matches -are -always -delayed -by -1 -byte -so -we -must -explicitly -walk -/ -/ -/ -/ -/ -the -special -" -EOI -" -transition -at -the -end -of -the -search -. -Without -this -/ -/ -/ -/ -/ -final -transition -the -assert -below -will -fail -since -the -DFA -will -not -/ -/ -/ -/ -/ -have -entered -a -match -state -yet -! -/ -/ -/ -state -= -dfa -. -next_eoi_state -( -state -) -; -/ -/ -/ -assert -! -( -dfa -. -is_match_state -( -state -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -next_eoi_state -( -& -self -current -: -StateID -) -- -> -StateID -; -/ -/ -/ -Return -the -ID -of -the -start -state -for -this -lazy -DFA -when -executing -a -/ -/ -/ -forward -search -. -/ -/ -/ -/ -/ -/ -Unlike -typical -DFA -implementations -the -start -state -for -DFAs -in -this -/ -/ -/ -crate -is -dependent -on -a -few -different -factors -: -/ -/ -/ -/ -/ -/ -* -The -[ -Anchored -] -mode -of -the -search -. -Unanchored -anchored -and -/ -/ -/ -anchored -searches -for -a -specific -[ -PatternID -] -all -use -different -start -/ -/ -/ -states -. -/ -/ -/ -* -The -position -at -which -the -search -begins -via -[ -Input -: -: -start -] -. -This -/ -/ -/ -and -the -byte -immediately -preceding -the -start -of -the -search -( -if -one -/ -/ -/ -exists -) -influence -which -look -- -behind -assertions -are -true -at -the -start -/ -/ -/ -of -the -search -. -This -in -turn -influences -which -start -state -is -selected -. -/ -/ -/ -* -Whether -the -search -is -a -forward -or -reverse -search -. -This -routine -can -/ -/ -/ -only -be -used -for -forward -searches -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -may -return -a -[ -MatchError -] -if -the -search -needs -to -give -up -/ -/ -/ -when -determining -the -start -state -( -for -example -if -it -sees -a -" -quit -" -/ -/ -/ -byte -) -. -This -can -also -return -an -error -if -the -given -Input -contains -an -/ -/ -/ -unsupported -[ -Anchored -] -configuration -. -fn -start_state_forward -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -; -/ -/ -/ -Return -the -ID -of -the -start -state -for -this -lazy -DFA -when -executing -a -/ -/ -/ -reverse -search -. -/ -/ -/ -/ -/ -/ -Unlike -typical -DFA -implementations -the -start -state -for -DFAs -in -this -/ -/ -/ -crate -is -dependent -on -a -few -different -factors -: -/ -/ -/ -/ -/ -/ -* -The -[ -Anchored -] -mode -of -the -search -. -Unanchored -anchored -and -/ -/ -/ -anchored -searches -for -a -specific -[ -PatternID -] -all -use -different -start -/ -/ -/ -states -. -/ -/ -/ -* -The -position -at -which -the -search -begins -via -[ -Input -: -: -start -] -. -This -/ -/ -/ -and -the -byte -immediately -preceding -the -start -of -the -search -( -if -one -/ -/ -/ -exists -) -influence -which -look -- -behind -assertions -are -true -at -the -start -/ -/ -/ -of -the -search -. -This -in -turn -influences -which -start -state -is -selected -. -/ -/ -/ -* -Whether -the -search -is -a -forward -or -reverse -search -. -This -routine -can -/ -/ -/ -only -be -used -for -reverse -searches -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -may -return -a -[ -MatchError -] -if -the -search -needs -to -give -up -/ -/ -/ -when -determining -the -start -state -( -for -example -if -it -sees -a -" -quit -" -/ -/ -/ -byte -) -. -This -can -also -return -an -error -if -the -given -Input -contains -an -/ -/ -/ -unsupported -[ -Anchored -] -configuration -. -fn -start_state_reverse -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -; -/ -/ -/ -If -this -DFA -has -a -universal -starting -state -for -the -given -anchor -mode -/ -/ -/ -and -the -DFA -supports -universal -starting -states -then -this -returns -that -/ -/ -/ -state -' -s -identifier -. -/ -/ -/ -/ -/ -/ -A -DFA -is -said -to -have -a -universal -starting -state -when -the -starting -/ -/ -/ -state -is -invariant -with -respect -to -the -haystack -. -Usually -the -starting -/ -/ -/ -state -is -chosen -depending -on -the -bytes -immediately -surrounding -the -/ -/ -/ -starting -position -of -a -search -. -However -the -starting -state -only -differs -/ -/ -/ -when -one -or -more -of -the -patterns -in -the -DFA -have -look -- -around -assertions -/ -/ -/ -in -its -prefix -. -/ -/ -/ -/ -/ -/ -Stated -differently -if -none -of -the -patterns -in -a -DFA -have -look -- -around -/ -/ -/ -assertions -in -their -prefix -then -the -DFA -has -a -universal -starting -state -/ -/ -/ -and -_may_ -be -returned -by -this -method -. -/ -/ -/ -/ -/ -/ -It -is -always -correct -for -implementations -to -return -None -and -indeed -/ -/ -/ -this -is -what -the -default -implementation -does -. -When -this -returns -None -/ -/ -/ -callers -must -use -either -start_state_forward -or -start_state_reverse -/ -/ -/ -to -get -the -starting -state -. -/ -/ -/ -/ -/ -/ -# -Use -case -/ -/ -/ -/ -/ -/ -There -are -a -few -reasons -why -one -might -want -to -use -this -: -/ -/ -/ -/ -/ -/ -* -If -you -know -your -regex -patterns -have -no -look -- -around -assertions -in -/ -/ -/ -their -prefix -then -calling -this -routine -is -likely -cheaper -and -perhaps -/ -/ -/ -more -semantically -meaningful -. -/ -/ -/ -* -When -implementing -prefilter -support -in -a -DFA -regex -implementation -/ -/ -/ -it -is -necessary -to -re -- -compute -the -start -state -after -a -candidate -/ -/ -/ -is -returned -from -the -prefilter -. -However -this -is -only -needed -when -/ -/ -/ -there -isn -' -t -a -universal -start -state -. -When -one -exists -one -can -avoid -/ -/ -/ -re -- -computing -the -start -state -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -/ -/ -/ -Anchored -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -There -are -no -look -- -around -assertions -in -the -prefixes -of -any -of -the -/ -/ -/ -/ -/ -patterns -so -we -get -a -universal -start -state -. -/ -/ -/ -let -dfa -= -DFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -assert -! -( -dfa -. -universal_start_state -( -Anchored -: -: -No -) -. -is_some -( -) -) -; -/ -/ -/ -assert -! -( -dfa -. -universal_start_state -( -Anchored -: -: -Yes -) -. -is_some -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -One -of -the -patterns -has -a -look -- -around -assertion -in -its -prefix -/ -/ -/ -/ -/ -so -this -means -there -is -no -longer -a -universal -start -state -. -/ -/ -/ -let -dfa -= -DFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -^ -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -assert -! -( -! -dfa -. -universal_start_state -( -Anchored -: -: -No -) -. -is_some -( -) -) -; -/ -/ -/ -assert -! -( -! -dfa -. -universal_start_state -( -Anchored -: -: -Yes -) -. -is_some -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -fn -universal_start_state -( -& -self -_mode -: -Anchored -) -- -> -Option -< -StateID -> -{ -None -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -identifier -corresponds -to -a -/ -/ -/ -" -special -" -state -. -A -special -state -is -one -or -more -of -the -following -: -/ -/ -/ -a -dead -state -a -quit -state -a -match -state -a -start -state -or -an -/ -/ -/ -accelerated -state -. -/ -/ -/ -/ -/ -/ -A -correct -implementation -_may_ -always -return -false -for -states -that -/ -/ -/ -are -either -start -states -or -accelerated -states -since -that -information -/ -/ -/ -is -only -intended -to -be -used -for -optimization -purposes -. -Correct -/ -/ -/ -implementations -must -return -true -if -the -state -is -a -dead -quit -or -match -/ -/ -/ -state -. -This -is -because -search -routines -using -this -trait -must -be -able -/ -/ -/ -to -rely -on -is_special_state -as -an -indicator -that -a -state -may -need -/ -/ -/ -special -treatment -. -( -For -example -when -a -search -routine -sees -a -dead -/ -/ -/ -state -it -must -terminate -. -) -/ -/ -/ -/ -/ -/ -This -routine -permits -search -implementations -to -use -a -single -branch -to -/ -/ -/ -check -whether -a -state -needs -special -attention -before -executing -the -next -/ -/ -/ -transition -. -The -example -below -shows -how -to -do -this -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -is_special_state -can -be -used -to -implement -a -/ -/ -/ -correct -search -routine -with -minimal -branching -. -In -particular -this -/ -/ -/ -search -routine -implements -" -leftmost -" -matching -which -means -that -it -/ -/ -/ -doesn -' -t -immediately -stop -once -a -match -is -found -. -Instead -it -continues -/ -/ -/ -until -it -reaches -a -dead -state -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -} -/ -/ -/ -HalfMatch -MatchError -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -fn -find -< -A -: -Automaton -> -( -/ -/ -/ -dfa -: -& -A -/ -/ -/ -haystack -: -& -[ -u8 -] -/ -/ -/ -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -Note -that -start -states -can -never -/ -/ -/ -/ -/ -be -match -states -( -since -DFAs -in -this -crate -delay -matches -by -1 -/ -/ -/ -/ -/ -byte -) -so -we -don -' -t -need -to -check -if -the -start -state -is -a -match -. -/ -/ -/ -let -mut -state -= -dfa -. -start_state_forward -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -let -mut -last_match -= -None -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -We -can -quit -early -if -we -see -/ -/ -/ -/ -/ -a -dead -or -a -quit -state -. -The -former -means -the -automaton -will -/ -/ -/ -/ -/ -never -transition -to -any -other -state -. -The -latter -means -that -the -/ -/ -/ -/ -/ -automaton -entered -a -condition -in -which -its -search -failed -. -/ -/ -/ -for -( -i -& -b -) -in -haystack -. -iter -( -) -. -enumerate -( -) -{ -/ -/ -/ -state -= -dfa -. -next_state -( -state -b -) -; -/ -/ -/ -if -dfa -. -is_special_state -( -state -) -{ -/ -/ -/ -if -dfa -. -is_match_state -( -state -) -{ -/ -/ -/ -last_match -= -Some -( -HalfMatch -: -: -new -( -/ -/ -/ -dfa -. -match_pattern -( -state -0 -) -/ -/ -/ -i -/ -/ -/ -) -) -; -/ -/ -/ -} -else -if -dfa -. -is_dead_state -( -state -) -{ -/ -/ -/ -return -Ok -( -last_match -) -; -/ -/ -/ -} -else -if -dfa -. -is_quit_state -( -state -) -{ -/ -/ -/ -/ -/ -It -is -possible -to -enter -into -a -quit -state -after -/ -/ -/ -/ -/ -observing -a -match -has -occurred -. -In -that -case -we -/ -/ -/ -/ -/ -should -return -the -match -instead -of -an -error -. -/ -/ -/ -if -last_match -. -is_some -( -) -{ -/ -/ -/ -return -Ok -( -last_match -) -; -/ -/ -/ -} -/ -/ -/ -return -Err -( -MatchError -: -: -quit -( -b -i -) -) -; -/ -/ -/ -} -/ -/ -/ -/ -/ -Implementors -may -also -want -to -check -for -start -or -accel -/ -/ -/ -/ -/ -states -and -handle -them -differently -for -performance -/ -/ -/ -/ -/ -reasons -. -But -it -is -not -necessary -for -correctness -. -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -Matches -are -always -delayed -by -1 -byte -so -we -must -explicitly -walk -/ -/ -/ -/ -/ -the -special -" -EOI -" -transition -at -the -end -of -the -search -. -/ -/ -/ -state -= -dfa -. -next_eoi_state -( -state -) -; -/ -/ -/ -if -dfa -. -is_match_state -( -state -) -{ -/ -/ -/ -last_match -= -Some -( -HalfMatch -: -: -new -( -/ -/ -/ -dfa -. -match_pattern -( -state -0 -) -/ -/ -/ -haystack -. -len -( -) -/ -/ -/ -) -) -; -/ -/ -/ -} -/ -/ -/ -Ok -( -last_match -) -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -We -use -a -greedy -' -+ -' -operator -to -show -how -the -search -doesn -' -t -just -/ -/ -/ -/ -/ -stop -once -a -match -is -detected -. -It -continues -extending -the -match -. -/ -/ -/ -/ -/ -Using -' -[ -a -- -z -] -+ -? -' -would -also -work -as -expected -and -stop -the -search -/ -/ -/ -/ -/ -early -. -Greediness -is -built -into -the -automaton -. -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -mat -= -find -( -& -dfa -haystack -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -10 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Here -' -s -another -example -that -tests -our -handling -of -the -special -EOI -/ -/ -/ -/ -/ -transition -. -This -will -fail -to -find -a -match -if -we -don -' -t -call -/ -/ -/ -/ -/ -' -next_eoi_state -' -at -the -end -of -the -search -since -the -match -isn -' -t -/ -/ -/ -/ -/ -found -until -the -final -byte -in -the -haystack -. -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -" -) -? -; -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -mat -= -find -( -& -dfa -haystack -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -15 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -note -that -our -search -implementation -above -automatically -works -/ -/ -/ -/ -/ -with -multi -- -DFAs -. -Namely -dfa -. -match_pattern -( -match_state -0 -) -selects -/ -/ -/ -/ -/ -the -appropriate -pattern -ID -for -us -. -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new_many -( -& -[ -r -" -[ -a -- -z -] -+ -" -r -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -mat -= -find -( -& -dfa -haystack -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -1 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -3 -) -; -/ -/ -/ -let -mat -= -find -( -& -dfa -& -haystack -[ -3 -. -. -] -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -7 -) -; -/ -/ -/ -let -mat -= -find -( -& -dfa -& -haystack -[ -10 -. -. -] -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -1 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -5 -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -is_special_state -( -& -self -id -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -true -if -and -only -if -the -given -identifier -corresponds -to -a -dead -/ -/ -/ -state -. -When -a -DFA -enters -a -dead -state -it -is -impossible -to -leave -. -That -/ -/ -/ -is -every -transition -on -a -dead -state -by -definition -leads -back -to -the -/ -/ -/ -same -dead -state -. -/ -/ -/ -/ -/ -/ -In -practice -the -dead -state -always -corresponds -to -the -identifier -0 -. -/ -/ -/ -Moreover -in -practice -there -is -only -one -dead -state -. -/ -/ -/ -/ -/ -/ -The -existence -of -a -dead -state -is -not -strictly -required -in -the -classical -/ -/ -/ -model -of -finite -state -machines -where -one -generally -only -cares -about -/ -/ -/ -the -question -of -whether -an -input -sequence -matches -or -not -. -Dead -states -/ -/ -/ -are -not -needed -to -answer -that -question -since -one -can -immediately -quit -/ -/ -/ -as -soon -as -one -enters -a -final -or -" -match -" -state -. -However -we -don -' -t -just -/ -/ -/ -care -about -matches -but -also -care -about -the -location -of -matches -and -/ -/ -/ -more -specifically -care -about -semantics -like -" -greedy -" -matching -. -/ -/ -/ -/ -/ -/ -For -example -given -the -pattern -a -+ -and -the -input -aaaz -the -dead -/ -/ -/ -state -won -' -t -be -entered -until -the -state -machine -reaches -z -in -the -/ -/ -/ -input -at -which -point -the -search -routine -can -quit -. -But -without -the -/ -/ -/ -dead -state -the -search -routine -wouldn -' -t -know -when -to -quit -. -In -a -/ -/ -/ -classical -representation -the -search -routine -would -stop -after -seeing -/ -/ -/ -the -first -a -( -which -is -when -the -search -would -enter -a -match -state -) -. -But -/ -/ -/ -this -wouldn -' -t -implement -" -greedy -" -matching -where -a -+ -matches -as -many -/ -/ -/ -a -' -s -as -possible -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -See -the -example -for -[ -Automaton -: -: -is_special_state -] -for -how -to -use -this -/ -/ -/ -method -correctly -. -fn -is_dead_state -( -& -self -id -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -true -if -and -only -if -the -given -identifier -corresponds -to -a -quit -/ -/ -/ -state -. -A -quit -state -is -like -a -dead -state -( -it -has -no -transitions -other -/ -/ -/ -than -to -itself -) -except -it -indicates -that -the -DFA -failed -to -complete -/ -/ -/ -the -search -. -When -this -occurs -callers -can -neither -accept -or -reject -that -/ -/ -/ -a -match -occurred -. -/ -/ -/ -/ -/ -/ -In -practice -the -quit -state -always -corresponds -to -the -state -immediately -/ -/ -/ -following -the -dead -state -. -( -Which -is -not -usually -represented -by -1 -/ -/ -/ -since -state -identifiers -are -pre -- -multiplied -by -the -state -machine -' -s -/ -/ -/ -alphabet -stride -and -the -alphabet -stride -varies -between -DFAs -. -) -/ -/ -/ -/ -/ -/ -The -typical -way -in -which -a -quit -state -can -occur -is -when -heuristic -/ -/ -/ -support -for -Unicode -word -boundaries -is -enabled -via -the -/ -/ -/ -[ -dense -: -: -Config -: -: -unicode_word_boundary -] -( -crate -: -: -dfa -: -: -dense -: -: -Config -: -: -unicode_word_boundary -) -/ -/ -/ -option -. -But -other -options -like -the -lower -level -/ -/ -/ -[ -dense -: -: -Config -: -: -quit -] -( -crate -: -: -dfa -: -: -dense -: -: -Config -: -: -quit -) -/ -/ -/ -configuration -can -also -result -in -a -quit -state -being -entered -. -The -/ -/ -/ -purpose -of -the -quit -state -is -to -provide -a -way -to -execute -a -fast -DFA -/ -/ -/ -in -common -cases -while -delegating -to -slower -routines -when -the -DFA -quits -. -/ -/ -/ -/ -/ -/ -The -default -search -implementations -provided -by -this -crate -will -return -a -/ -/ -/ -[ -MatchError -: -: -quit -] -error -when -a -quit -state -is -entered -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -See -the -example -for -[ -Automaton -: -: -is_special_state -] -for -how -to -use -this -/ -/ -/ -method -correctly -. -fn -is_quit_state -( -& -self -id -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -true -if -and -only -if -the -given -identifier -corresponds -to -a -/ -/ -/ -match -state -. -A -match -state -is -also -referred -to -as -a -" -final -" -state -and -/ -/ -/ -indicates -that -a -match -has -been -found -. -/ -/ -/ -/ -/ -/ -If -all -you -care -about -is -whether -a -particular -pattern -matches -in -the -/ -/ -/ -input -sequence -then -a -search -routine -can -quit -early -as -soon -as -the -/ -/ -/ -machine -enters -a -match -state -. -However -if -you -' -re -looking -for -the -/ -/ -/ -standard -" -leftmost -- -first -" -match -location -then -search -_must_ -continue -/ -/ -/ -until -either -the -end -of -the -input -or -until -the -machine -enters -a -dead -/ -/ -/ -state -. -( -Since -either -condition -implies -that -no -other -useful -work -can -/ -/ -/ -be -done -. -) -Namely -when -looking -for -the -location -of -a -match -then -/ -/ -/ -search -implementations -should -record -the -most -recent -location -in -/ -/ -/ -which -a -match -state -was -entered -but -otherwise -continue -executing -the -/ -/ -/ -search -as -normal -. -( -The -search -may -even -leave -the -match -state -. -) -Once -/ -/ -/ -the -termination -condition -is -reached -the -most -recently -recorded -match -/ -/ -/ -location -should -be -returned -. -/ -/ -/ -/ -/ -/ -Finally -one -additional -power -given -to -match -states -in -this -crate -/ -/ -/ -is -that -they -are -always -associated -with -a -specific -pattern -in -order -/ -/ -/ -to -support -multi -- -DFAs -. -See -[ -Automaton -: -: -match_pattern -] -for -more -/ -/ -/ -details -and -an -example -for -how -to -query -the -pattern -associated -with -a -/ -/ -/ -particular -match -state -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -See -the -example -for -[ -Automaton -: -: -is_special_state -] -for -how -to -use -this -/ -/ -/ -method -correctly -. -fn -is_match_state -( -& -self -id -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -true -only -if -the -given -identifier -corresponds -to -a -start -/ -/ -/ -state -/ -/ -/ -/ -/ -/ -A -start -state -is -a -state -in -which -a -DFA -begins -a -search -. -/ -/ -/ -All -searches -begin -in -a -start -state -. -Moreover -since -all -matches -are -/ -/ -/ -delayed -by -one -byte -a -start -state -can -never -be -a -match -state -. -/ -/ -/ -/ -/ -/ -The -main -role -of -a -start -state -is -as -mentioned -to -be -a -starting -/ -/ -/ -point -for -a -DFA -. -This -starting -point -is -determined -via -one -of -/ -/ -/ -[ -Automaton -: -: -start_state_forward -] -or -/ -/ -/ -[ -Automaton -: -: -start_state_reverse -] -depending -on -whether -one -is -doing -/ -/ -/ -a -forward -or -a -reverse -search -respectively -. -/ -/ -/ -/ -/ -/ -A -secondary -use -of -start -states -is -for -prefix -acceleration -. -Namely -/ -/ -/ -while -executing -a -search -if -one -detects -that -you -' -re -in -a -start -state -/ -/ -/ -then -it -may -be -faster -to -look -for -the -next -match -of -a -prefix -of -the -/ -/ -/ -pattern -if -one -exists -. -If -a -prefix -exists -and -since -all -matches -must -/ -/ -/ -begin -with -that -prefix -then -skipping -ahead -to -occurrences -of -that -/ -/ -/ -prefix -may -be -much -faster -than -executing -the -DFA -. -/ -/ -/ -/ -/ -/ -As -mentioned -in -the -documentation -for -/ -/ -/ -[ -is_special_state -] -( -Automaton -: -: -is_special_state -) -implementations -/ -/ -/ -_may_ -always -return -false -even -if -the -given -identifier -is -a -start -/ -/ -/ -state -. -This -is -because -knowing -whether -a -state -is -a -start -state -or -not -/ -/ -/ -is -not -necessary -for -correctness -and -is -only -treated -as -a -potential -/ -/ -/ -performance -optimization -. -( -For -example -the -implementations -of -this -/ -/ -/ -trait -in -this -crate -will -only -return -true -when -the -given -identifier -/ -/ -/ -corresponds -to -a -start -state -and -when -[ -specialization -of -start -/ -/ -/ -states -] -( -crate -: -: -dfa -: -: -dense -: -: -Config -: -: -specialize_start_states -) -was -enabled -/ -/ -/ -during -DFA -construction -. -If -start -state -specialization -is -disabled -/ -/ -/ -( -which -is -the -default -) -then -this -method -will -always -return -false -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -implement -your -own -search -routine -that -does -/ -/ -/ -a -prefix -search -whenever -the -search -enters -a -start -state -. -/ -/ -/ -/ -/ -/ -Note -that -you -do -not -need -to -implement -your -own -search -routine -/ -/ -/ -to -make -use -of -prefilters -like -this -. -The -search -routines -/ -/ -/ -provided -by -this -crate -already -implement -prefilter -support -via -/ -/ -/ -the -[ -Prefilter -] -( -crate -: -: -util -: -: -prefilter -: -: -Prefilter -) -trait -. -/ -/ -/ -A -prefilter -can -be -added -to -your -search -configuration -with -/ -/ -/ -[ -dense -: -: -Config -: -: -prefilter -] -( -crate -: -: -dfa -: -: -dense -: -: -Config -: -: -prefilter -) -for -/ -/ -/ -dense -and -sparse -DFAs -in -this -crate -. -/ -/ -/ -/ -/ -/ -This -example -is -meant -to -show -how -you -might -deal -with -prefilters -in -a -/ -/ -/ -simplified -case -if -you -are -implementing -your -own -search -routine -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -} -/ -/ -/ -HalfMatch -MatchError -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -fn -find_byte -( -slice -: -& -[ -u8 -] -at -: -usize -byte -: -u8 -) -- -> -Option -< -usize -> -{ -/ -/ -/ -/ -/ -Would -be -faster -to -use -the -memchr -crate -but -this -is -still -/ -/ -/ -/ -/ -faster -than -running -through -the -DFA -. -/ -/ -/ -slice -[ -at -. -. -] -. -iter -( -) -. -position -( -| -& -b -| -b -= -= -byte -) -. -map -( -| -i -| -at -+ -i -) -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -fn -find -< -A -: -Automaton -> -( -/ -/ -/ -dfa -: -& -A -/ -/ -/ -haystack -: -& -[ -u8 -] -/ -/ -/ -prefix_byte -: -Option -< -u8 -> -/ -/ -/ -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -/ -/ -/ -/ -/ -See -the -Automaton -: -: -is_special_state -example -for -similar -code -/ -/ -/ -/ -/ -with -more -comments -. -/ -/ -/ -/ -/ -/ -let -mut -state -= -dfa -. -start_state_forward -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -let -mut -last_match -= -None -; -/ -/ -/ -let -mut -pos -= -0 -; -/ -/ -/ -while -pos -< -haystack -. -len -( -) -{ -/ -/ -/ -let -b -= -haystack -[ -pos -] -; -/ -/ -/ -state -= -dfa -. -next_state -( -state -b -) -; -/ -/ -/ -pos -+ -= -1 -; -/ -/ -/ -if -dfa -. -is_special_state -( -state -) -{ -/ -/ -/ -if -dfa -. -is_match_state -( -state -) -{ -/ -/ -/ -last_match -= -Some -( -HalfMatch -: -: -new -( -/ -/ -/ -dfa -. -match_pattern -( -state -0 -) -/ -/ -/ -pos -- -1 -/ -/ -/ -) -) -; -/ -/ -/ -} -else -if -dfa -. -is_dead_state -( -state -) -{ -/ -/ -/ -return -Ok -( -last_match -) -; -/ -/ -/ -} -else -if -dfa -. -is_quit_state -( -state -) -{ -/ -/ -/ -/ -/ -It -is -possible -to -enter -into -a -quit -state -after -/ -/ -/ -/ -/ -observing -a -match -has -occurred -. -In -that -case -we -/ -/ -/ -/ -/ -should -return -the -match -instead -of -an -error -. -/ -/ -/ -if -last_match -. -is_some -( -) -{ -/ -/ -/ -return -Ok -( -last_match -) -; -/ -/ -/ -} -/ -/ -/ -return -Err -( -MatchError -: -: -quit -( -b -pos -- -1 -) -) -; -/ -/ -/ -} -else -if -dfa -. -is_start_state -( -state -) -{ -/ -/ -/ -/ -/ -If -we -' -re -in -a -start -state -and -know -all -matches -begin -/ -/ -/ -/ -/ -with -a -particular -byte -then -we -can -quickly -skip -to -/ -/ -/ -/ -/ -candidate -matches -without -running -the -DFA -through -/ -/ -/ -/ -/ -every -byte -inbetween -. -/ -/ -/ -if -let -Some -( -prefix_byte -) -= -prefix_byte -{ -/ -/ -/ -pos -= -match -find_byte -( -haystack -pos -prefix_byte -) -{ -/ -/ -/ -Some -( -pos -) -= -> -pos -/ -/ -/ -None -= -> -break -/ -/ -/ -} -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -Matches -are -always -delayed -by -1 -byte -so -we -must -explicitly -walk -/ -/ -/ -/ -/ -the -special -" -EOI -" -transition -at -the -end -of -the -search -. -/ -/ -/ -state -= -dfa -. -next_eoi_state -( -state -) -; -/ -/ -/ -if -dfa -. -is_match_state -( -state -) -{ -/ -/ -/ -last_match -= -Some -( -HalfMatch -: -: -new -( -/ -/ -/ -dfa -. -match_pattern -( -state -0 -) -/ -/ -/ -haystack -. -len -( -) -/ -/ -/ -) -) -; -/ -/ -/ -} -/ -/ -/ -Ok -( -last_match -) -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -In -this -example -it -' -s -obvious -that -all -occurrences -of -our -pattern -/ -/ -/ -/ -/ -begin -with -' -Z -' -so -we -pass -in -' -Z -' -. -Note -also -that -we -need -to -/ -/ -/ -/ -/ -enable -start -state -specialization -or -else -it -won -' -t -be -possible -to -/ -/ -/ -/ -/ -detect -start -states -during -a -search -. -( -' -is_start_state -' -would -always -/ -/ -/ -/ -/ -return -false -. -) -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -dense -: -: -DFA -: -: -config -( -) -. -specialize_start_states -( -true -) -) -/ -/ -/ -. -build -( -r -" -Z -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -haystack -= -" -123 -foobar -Zbaz -quux -" -. -as_bytes -( -) -; -/ -/ -/ -let -mat -= -find -( -& -dfa -haystack -Some -( -b -' -Z -' -) -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -15 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -note -that -we -don -' -t -need -to -pass -in -a -prefix -byte -. -If -we -don -' -t -/ -/ -/ -/ -/ -then -the -search -routine -does -no -acceleration -. -/ -/ -/ -let -mat -= -find -( -& -dfa -haystack -None -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -15 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -However -if -we -pass -an -incorrect -byte -then -the -prefix -search -will -/ -/ -/ -/ -/ -result -in -incorrect -results -. -/ -/ -/ -assert_eq -! -( -find -( -& -dfa -haystack -Some -( -b -' -X -' -) -) -? -None -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -is_start_state -( -& -self -id -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -true -if -and -only -if -the -given -identifier -corresponds -to -an -/ -/ -/ -accelerated -state -. -/ -/ -/ -/ -/ -/ -An -accelerated -state -is -a -special -optimization -/ -/ -/ -trick -implemented -by -this -crate -. -Namely -if -/ -/ -/ -[ -dense -: -: -Config -: -: -accelerate -] -( -crate -: -: -dfa -: -: -dense -: -: -Config -: -: -accelerate -) -is -/ -/ -/ -enabled -( -and -it -is -by -default -) -then -DFAs -generated -by -this -crate -will -/ -/ -/ -tag -states -meeting -certain -characteristics -as -accelerated -. -States -meet -/ -/ -/ -this -criteria -whenever -most -of -their -transitions -are -self -- -transitions -. -/ -/ -/ -That -is -transitions -that -loop -back -to -the -same -state -. -When -a -small -/ -/ -/ -number -of -transitions -aren -' -t -self -- -transitions -then -it -follows -that -/ -/ -/ -there -are -only -a -small -number -of -bytes -that -can -cause -the -DFA -to -leave -/ -/ -/ -that -state -. -Thus -there -is -an -opportunity -to -look -for -those -bytes -/ -/ -/ -using -more -optimized -routines -rather -than -continuing -to -run -through -/ -/ -/ -the -DFA -. -This -trick -is -similar -to -the -prefilter -idea -described -in -/ -/ -/ -the -documentation -of -[ -Automaton -: -: -is_start_state -] -with -two -main -/ -/ -/ -differences -: -/ -/ -/ -/ -/ -/ -1 -. -It -is -more -limited -since -acceleration -only -applies -to -single -bytes -. -/ -/ -/ -This -means -states -are -rarely -accelerated -when -Unicode -mode -is -enabled -/ -/ -/ -( -which -is -enabled -by -default -) -. -/ -/ -/ -2 -. -It -can -occur -anywhere -in -the -DFA -which -increases -optimization -/ -/ -/ -opportunities -. -/ -/ -/ -/ -/ -/ -Like -the -prefilter -idea -the -main -downside -( -and -a -possible -reason -to -/ -/ -/ -disable -it -) -is -that -it -can -lead -to -worse -performance -in -some -cases -. -/ -/ -/ -Namely -if -a -state -is -accelerated -for -very -common -bytes -then -the -/ -/ -/ -overhead -of -checking -for -acceleration -and -using -the -more -optimized -/ -/ -/ -routines -to -look -for -those -bytes -can -cause -overall -performance -to -be -/ -/ -/ -worse -than -if -acceleration -wasn -' -t -enabled -at -all -. -/ -/ -/ -/ -/ -/ -A -simple -example -of -a -regex -that -has -an -accelerated -state -is -/ -/ -/ -( -? -- -u -) -[ -^ -a -] -+ -a -. -Namely -the -[ -^ -a -] -+ -sub -- -expression -gets -compiled -down -/ -/ -/ -into -a -single -state -where -all -transitions -except -for -a -loop -back -to -/ -/ -/ -itself -and -where -a -is -the -only -transition -( -other -than -the -special -/ -/ -/ -EOI -transition -) -that -goes -to -some -other -state -. -Thus -this -state -can -/ -/ -/ -be -accelerated -and -implemented -more -efficiently -by -calling -an -/ -/ -/ -optimized -routine -like -memchr -with -a -as -the -needle -. -Notice -that -/ -/ -/ -the -( -? -- -u -) -to -disable -Unicode -is -necessary -here -as -without -it -/ -/ -/ -[ -^ -a -] -will -match -any -UTF -- -8 -encoding -of -any -Unicode -scalar -value -other -/ -/ -/ -than -a -. -This -more -complicated -expression -compiles -down -to -many -DFA -/ -/ -/ -states -and -the -simple -acceleration -optimization -is -no -longer -available -. -/ -/ -/ -/ -/ -/ -Typically -this -routine -is -used -to -guard -calls -to -/ -/ -/ -[ -Automaton -: -: -accelerator -] -which -returns -the -accelerated -bytes -for -/ -/ -/ -the -specified -state -. -fn -is_accel_state -( -& -self -id -: -StateID -) -- -> -bool -; -/ -/ -/ -Returns -the -total -number -of -patterns -compiled -into -this -DFA -. -/ -/ -/ -/ -/ -/ -In -the -case -of -a -DFA -that -contains -no -patterns -this -must -return -0 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -pattern -length -for -a -DFA -that -never -matches -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -; -/ -/ -/ -/ -/ -/ -let -dfa -: -DFA -< -Vec -< -u32 -> -> -= -DFA -: -: -never_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -dfa -. -pattern_len -( -) -0 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -another -example -for -a -DFA -that -matches -at -every -position -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -; -/ -/ -/ -/ -/ -/ -let -dfa -: -DFA -< -Vec -< -u32 -> -> -= -DFA -: -: -always_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -dfa -. -pattern_len -( -) -1 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -finally -a -DFA -that -was -constructed -from -multiple -patterns -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -dfa -. -pattern_len -( -) -3 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -pattern_len -( -& -self -) -- -> -usize -; -/ -/ -/ -Returns -the -total -number -of -patterns -that -match -in -this -state -. -/ -/ -/ -/ -/ -/ -If -the -given -state -is -not -a -match -state -then -implementations -may -/ -/ -/ -panic -. -/ -/ -/ -/ -/ -/ -If -the -DFA -was -compiled -with -one -pattern -then -this -must -necessarily -/ -/ -/ -always -return -1 -for -all -match -states -. -/ -/ -/ -/ -/ -/ -Implementations -must -guarantee -that -[ -Automaton -: -: -match_pattern -] -can -be -/ -/ -/ -called -with -indices -up -to -( -but -not -including -) -the -length -returned -by -/ -/ -/ -this -routine -without -panicking -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -Implementations -are -permitted -to -panic -if -the -provided -state -ID -does -/ -/ -/ -not -correspond -to -a -match -state -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -simple -instance -of -implementing -overlapping -/ -/ -/ -matches -. -In -particular -it -shows -not -only -how -to -determine -how -many -/ -/ -/ -patterns -have -matched -in -a -particular -state -but -also -how -to -access -/ -/ -/ -which -specific -patterns -have -matched -. -/ -/ -/ -/ -/ -/ -Notice -that -we -must -use -/ -/ -/ -[ -MatchKind -: -: -All -] -( -crate -: -: -MatchKind -: -: -All -) -/ -/ -/ -when -building -the -DFA -. -If -we -used -/ -/ -/ -[ -MatchKind -: -: -LeftmostFirst -] -( -crate -: -: -MatchKind -: -: -LeftmostFirst -) -/ -/ -/ -instead -then -the -DFA -would -not -be -constructed -in -a -way -that -/ -/ -/ -supports -overlapping -matches -. -( -It -would -only -report -a -single -pattern -/ -/ -/ -that -matches -at -any -particular -point -in -time -. -) -/ -/ -/ -/ -/ -/ -Another -thing -to -take -note -of -is -the -patterns -used -and -the -order -in -/ -/ -/ -which -the -pattern -IDs -are -reported -. -In -the -example -below -pattern -3 -/ -/ -/ -is -yielded -first -. -Why -? -Because -it -corresponds -to -the -match -that -/ -/ -/ -appears -first -. -Namely -the -symbol -is -part -of -\ -S -+ -but -not -part -/ -/ -/ -of -any -of -the -other -patterns -. -Since -the -\ -S -+ -pattern -has -a -match -that -/ -/ -/ -starts -to -the -left -of -any -other -pattern -its -ID -is -returned -before -any -/ -/ -/ -other -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -Input -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -& -[ -/ -/ -/ -r -" -[ -[ -: -word -: -] -] -+ -" -r -" -[ -a -- -z -] -+ -" -r -" -[ -A -- -Z -] -+ -" -r -" -[ -[ -: -^ -space -: -] -] -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -haystack -= -" -bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -/ -/ -/ -let -mut -state -= -dfa -. -start_state_forward -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -/ -/ -/ -for -& -b -in -haystack -{ -/ -/ -/ -state -= -dfa -. -next_state -( -state -b -) -; -/ -/ -/ -} -/ -/ -/ -state -= -dfa -. -next_eoi_state -( -state -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -dfa -. -is_match_state -( -state -) -) -; -/ -/ -/ -assert_eq -! -( -dfa -. -match_len -( -state -) -3 -) -; -/ -/ -/ -/ -/ -The -following -calls -are -guaranteed -to -not -panic -since -match_len -/ -/ -/ -/ -/ -returned -3 -above -. -/ -/ -/ -assert_eq -! -( -dfa -. -match_pattern -( -state -0 -) -. -as_usize -( -) -3 -) -; -/ -/ -/ -assert_eq -! -( -dfa -. -match_pattern -( -state -1 -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -dfa -. -match_pattern -( -state -2 -) -. -as_usize -( -) -1 -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -match_len -( -& -self -id -: -StateID -) -- -> -usize -; -/ -/ -/ -Returns -the -pattern -ID -corresponding -to -the -given -match -index -in -the -/ -/ -/ -given -state -. -/ -/ -/ -/ -/ -/ -See -[ -Automaton -: -: -match_len -] -for -an -example -of -how -to -use -this -/ -/ -/ -method -correctly -. -Note -that -if -you -know -your -DFA -is -compiled -with -a -/ -/ -/ -single -pattern -then -this -routine -is -never -necessary -since -it -will -/ -/ -/ -always -return -a -pattern -ID -of -0 -for -an -index -of -0 -when -id -/ -/ -/ -corresponds -to -a -match -state -. -/ -/ -/ -/ -/ -/ -Typically -this -routine -is -used -when -implementing -an -overlapping -/ -/ -/ -search -as -the -example -for -Automaton -: -: -match_len -does -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -state -ID -is -not -a -match -state -or -if -the -match -index -is -out -/ -/ -/ -of -bounds -for -the -given -state -then -this -routine -may -either -panic -/ -/ -/ -or -produce -an -incorrect -result -. -If -the -state -ID -is -correct -and -the -/ -/ -/ -match -index -is -correct -then -this -routine -must -always -produce -a -valid -/ -/ -/ -PatternID -. -fn -match_pattern -( -& -self -id -: -StateID -index -: -usize -) -- -> -PatternID -; -/ -/ -/ -Returns -true -if -and -only -if -this -automaton -can -match -the -empty -string -. -/ -/ -/ -When -it -returns -false -all -possible -matches -are -guaranteed -to -have -a -/ -/ -/ -non -- -zero -length -. -/ -/ -/ -/ -/ -/ -This -is -useful -as -cheap -way -to -know -whether -code -needs -to -handle -the -/ -/ -/ -case -of -a -zero -length -match -. -This -is -particularly -important -when -UTF -- -8 -/ -/ -/ -modes -are -enabled -as -when -UTF -- -8 -mode -is -enabled -empty -matches -that -/ -/ -/ -split -a -codepoint -must -never -be -reported -. -This -extra -handling -can -/ -/ -/ -sometimes -be -costly -and -since -regexes -matching -an -empty -string -are -/ -/ -/ -somewhat -rare -it -can -be -beneficial -to -treat -such -regexes -specially -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -few -different -DFAs -and -whether -they -match -the -/ -/ -/ -empty -string -or -not -. -Notice -the -empty -string -isn -' -t -merely -a -matter -/ -/ -/ -of -a -string -of -length -literally -0 -but -rather -whether -a -match -can -/ -/ -/ -occur -between -specific -pairs -of -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -dense -: -: -DFA -Automaton -} -util -: -: -syntax -} -; -/ -/ -/ -/ -/ -/ -/ -/ -The -empty -regex -matches -the -empty -string -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -" -) -? -; -/ -/ -/ -assert -! -( -dfa -. -has_empty -( -) -" -empty -matches -empty -" -) -; -/ -/ -/ -/ -/ -The -' -+ -' -repetition -operator -requires -at -least -one -match -and -so -/ -/ -/ -/ -/ -does -not -match -the -empty -string -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -a -+ -" -) -? -; -/ -/ -/ -assert -! -( -! -dfa -. -has_empty -( -) -" -+ -does -not -match -empty -" -) -; -/ -/ -/ -/ -/ -But -the -' -* -' -repetition -operator -does -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -a -* -" -) -? -; -/ -/ -/ -assert -! -( -dfa -. -has_empty -( -) -" -* -does -match -empty -" -) -; -/ -/ -/ -/ -/ -And -wrapping -' -+ -' -in -an -operator -that -can -match -an -empty -string -also -/ -/ -/ -/ -/ -causes -it -to -match -the -empty -string -too -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -( -a -+ -) -* -" -) -? -; -/ -/ -/ -assert -! -( -dfa -. -has_empty -( -) -" -+ -inside -of -* -matches -empty -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -If -a -regex -is -just -made -of -a -look -- -around -assertion -even -if -the -/ -/ -/ -/ -/ -assertion -requires -some -kind -of -non -- -empty -string -around -it -( -such -as -/ -/ -/ -/ -/ -\ -b -) -then -it -is -still -treated -as -if -it -matches -the -empty -string -. -/ -/ -/ -/ -/ -Namely -if -a -match -occurs -of -just -a -look -- -around -assertion -then -the -/ -/ -/ -/ -/ -match -returned -is -empty -. -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -unicode_word_boundary -( -true -) -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -^ -\ -A -\ -z -\ -b -\ -B -( -? -- -u -: -\ -b -\ -B -) -" -) -? -; -/ -/ -/ -assert -! -( -dfa -. -has_empty -( -) -" -assertions -match -empty -" -) -; -/ -/ -/ -/ -/ -Even -when -an -assertion -is -wrapped -in -a -' -+ -' -it -still -matches -the -/ -/ -/ -/ -/ -empty -string -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -^ -+ -" -) -? -; -/ -/ -/ -assert -! -( -dfa -. -has_empty -( -) -" -+ -of -an -assertion -matches -empty -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -An -alternation -with -even -one -branch -that -can -match -the -empty -string -/ -/ -/ -/ -/ -is -also -said -to -match -the -empty -string -overall -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -foo -| -( -bar -) -? -| -quux -" -) -? -; -/ -/ -/ -assert -! -( -dfa -. -has_empty -( -) -" -alternations -can -match -empty -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -An -NFA -that -matches -nothing -does -not -match -the -empty -string -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -[ -a -& -& -b -] -" -) -? -; -/ -/ -/ -assert -! -( -! -dfa -. -has_empty -( -) -" -never -matching -means -not -matching -empty -" -) -; -/ -/ -/ -/ -/ -But -if -it -' -s -wrapped -in -something -that -doesn -' -t -require -a -match -at -/ -/ -/ -/ -/ -all -then -it -can -match -the -empty -string -! -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -[ -a -& -& -b -] -* -" -) -? -; -/ -/ -/ -assert -! -( -dfa -. -has_empty -( -) -" -* -on -never -- -match -still -matches -empty -" -) -; -/ -/ -/ -/ -/ -Since -a -' -+ -' -requires -a -match -using -it -on -something -that -can -never -/ -/ -/ -/ -/ -match -will -itself -produce -a -regex -that -can -never -match -anything -/ -/ -/ -/ -/ -and -thus -does -not -match -the -empty -string -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -[ -a -& -& -b -] -+ -" -) -? -; -/ -/ -/ -assert -! -( -! -dfa -. -has_empty -( -) -" -+ -on -never -- -match -still -matches -nothing -" -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -has_empty -( -& -self -) -- -> -bool -; -/ -/ -/ -Whether -UTF -- -8 -mode -is -enabled -for -this -DFA -or -not -. -/ -/ -/ -/ -/ -/ -When -UTF -- -8 -mode -is -enabled -all -matches -reported -by -a -DFA -are -/ -/ -/ -guaranteed -to -correspond -to -spans -of -valid -UTF -- -8 -. -This -includes -/ -/ -/ -zero -- -width -matches -. -For -example -the -DFA -must -guarantee -that -the -empty -/ -/ -/ -regex -will -not -match -at -the -positions -between -code -units -in -the -UTF -- -8 -/ -/ -/ -encoding -of -a -single -codepoint -. -/ -/ -/ -/ -/ -/ -See -[ -thompson -: -: -Config -: -: -utf8 -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -: -: -utf8 -) -for -/ -/ -/ -more -information -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -UTF -- -8 -mode -can -impact -the -match -spans -that -may -/ -/ -/ -be -reported -in -certain -cases -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -: -: -DFA -Automaton -} -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -UTF -- -8 -mode -is -enabled -by -default -. -/ -/ -/ -let -re -= -DFA -: -: -new -( -" -" -) -? -; -/ -/ -/ -assert -! -( -re -. -is_utf8 -( -) -) -; -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -got -= -re -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -0 -) -) -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -an -empty -regex -matches -at -1 -. -. -1 -our -next -match -is -/ -/ -/ -/ -/ -3 -. -. -3 -because -1 -. -. -1 -and -2 -. -. -2 -split -the -snowman -codepoint -( -which -is -/ -/ -/ -/ -/ -three -bytes -long -) -. -/ -/ -/ -input -. -set_start -( -1 -) -; -/ -/ -/ -let -got -= -re -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -disable -UTF -- -8 -then -we -' -ll -get -matches -at -1 -. -. -1 -and -2 -. -. -2 -: -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -" -" -) -? -; -/ -/ -/ -assert -! -( -! -re -. -is_utf8 -( -) -) -; -/ -/ -/ -let -got -= -re -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -1 -) -) -got -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -2 -) -; -/ -/ -/ -let -got -= -re -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -2 -) -) -got -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -3 -) -; -/ -/ -/ -let -got -= -re -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -got -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -4 -) -; -/ -/ -/ -let -got -= -re -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -None -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -is_utf8 -( -& -self -) -- -> -bool -; -/ -/ -/ -Returns -true -if -and -only -if -this -DFA -is -limited -to -returning -matches -/ -/ -/ -whose -start -position -is -0 -. -/ -/ -/ -/ -/ -/ -Note -that -if -you -' -re -using -DFAs -provided -by -/ -/ -/ -this -crate -then -this -is -_orthogonal_ -to -/ -/ -/ -[ -Config -: -: -start_kind -] -( -crate -: -: -dfa -: -: -dense -: -: -Config -: -: -start_kind -) -. -/ -/ -/ -/ -/ -/ -This -is -useful -in -some -cases -because -if -a -DFA -is -limited -to -producing -/ -/ -/ -matches -that -start -at -offset -0 -then -a -reverse -search -is -never -/ -/ -/ -required -for -finding -the -start -of -a -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -{ -dense -: -: -DFA -Automaton -} -; -/ -/ -/ -/ -/ -/ -/ -/ -The -empty -regex -matches -anywhere -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -" -) -? -; -/ -/ -/ -assert -! -( -! -dfa -. -is_always_start_anchored -( -) -" -empty -matches -anywhere -" -) -; -/ -/ -/ -/ -/ -' -a -' -matches -anywhere -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -a -" -) -? -; -/ -/ -/ -assert -! -( -! -dfa -. -is_always_start_anchored -( -) -" -' -a -' -matches -anywhere -" -) -; -/ -/ -/ -/ -/ -' -^ -' -only -matches -at -offset -0 -! -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -^ -a -" -) -? -; -/ -/ -/ -assert -! -( -dfa -. -is_always_start_anchored -( -) -" -' -^ -a -' -matches -only -at -0 -" -) -; -/ -/ -/ -/ -/ -But -' -( -? -m -: -^ -) -' -matches -at -0 -but -at -other -offsets -too -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -( -? -m -: -^ -) -a -" -) -? -; -/ -/ -/ -assert -! -( -! -dfa -. -is_always_start_anchored -( -) -" -' -( -? -m -: -^ -) -a -' -matches -anywhere -" -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -fn -is_always_start_anchored -( -& -self -) -- -> -bool -; -/ -/ -/ -Return -a -slice -of -bytes -to -accelerate -for -the -given -state -if -possible -. -/ -/ -/ -/ -/ -/ -If -the -given -state -has -no -accelerator -then -an -empty -slice -must -be -/ -/ -/ -returned -. -If -Automaton -: -: -is_accel_state -returns -true -for -the -given -ID -/ -/ -/ -then -this -routine -_must_ -return -a -non -- -empty -slice -. -But -note -that -it -is -/ -/ -/ -not -required -for -an -implementation -of -this -trait -to -ever -return -true -/ -/ -/ -for -is_accel_state -even -if -the -state -_could_ -be -accelerated -. -That -/ -/ -/ -is -acceleration -is -an -optional -optimization -. -But -the -return -values -of -/ -/ -/ -is_accel_state -and -accelerator -must -be -in -sync -. -/ -/ -/ -/ -/ -/ -If -the -given -ID -is -not -a -valid -state -ID -for -this -automaton -then -/ -/ -/ -implementations -may -panic -or -produce -incorrect -results -. -/ -/ -/ -/ -/ -/ -See -[ -Automaton -: -: -is_accel_state -] -for -more -details -on -state -/ -/ -/ -acceleration -. -/ -/ -/ -/ -/ -/ -By -default -this -method -will -always -return -an -empty -slice -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -contrived -case -in -which -we -build -a -regex -that -we -/ -/ -/ -know -is -accelerated -and -extract -the -accelerator -from -a -state -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -} -/ -/ -/ -util -: -: -{ -primitives -: -: -StateID -syntax -} -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -/ -/ -We -disable -Unicode -everywhere -and -permit -the -regex -to -match -/ -/ -/ -/ -/ -invalid -UTF -- -8 -. -e -. -g -. -[ -^ -abc -] -matches -\ -xFF -which -is -not -valid -/ -/ -/ -/ -/ -UTF -- -8 -. -If -we -left -Unicode -enabled -[ -^ -abc -] -would -match -any -UTF -- -8 -/ -/ -/ -/ -/ -encoding -of -any -Unicode -scalar -value -except -for -' -a -' -' -b -' -or -' -c -' -. -/ -/ -/ -/ -/ -That -translates -to -a -much -more -complicated -DFA -and -also -/ -/ -/ -/ -/ -inhibits -the -' -accelerator -' -optimization -that -we -are -trying -to -/ -/ -/ -/ -/ -demonstrate -in -this -example -. -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -unicode -( -false -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -" -[ -^ -abc -] -+ -a -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Here -we -just -pluck -out -the -state -that -we -know -is -accelerated -. -/ -/ -/ -/ -/ -While -the -stride -calculations -are -something -that -can -be -relied -/ -/ -/ -/ -/ -on -by -callers -the -specific -position -of -the -accelerated -state -is -/ -/ -/ -/ -/ -implementation -defined -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -We -get -' -3 -' -by -inspecting -the -state -machine -using -' -regex -- -cli -' -. -/ -/ -/ -/ -/ -e -. -g -. -try -regex -- -cli -debug -dfa -dense -' -[ -^ -abc -] -+ -a -' -- -BbUC -. -/ -/ -/ -let -id -= -StateID -: -: -new -( -3 -* -dfa -. -stride -( -) -) -. -unwrap -( -) -; -/ -/ -/ -let -accelerator -= -dfa -. -accelerator -( -id -) -; -/ -/ -/ -/ -/ -The -[ -^ -abc -] -+ -sub -- -expression -permits -[ -a -b -c -] -to -be -accelerated -. -/ -/ -/ -assert_eq -! -( -accelerator -& -[ -b -' -a -' -b -' -b -' -b -' -c -' -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -fn -accelerator -( -& -self -_id -: -StateID -) -- -> -& -[ -u8 -] -{ -& -[ -] -} -/ -/ -/ -Returns -the -prefilter -associated -with -a -DFA -if -one -exists -. -/ -/ -/ -/ -/ -/ -The -default -implementation -of -this -trait -always -returns -None -. -And -/ -/ -/ -indeed -it -is -always -correct -to -return -None -. -/ -/ -/ -/ -/ -/ -For -DFAs -in -this -crate -a -prefilter -can -be -attached -to -a -DFA -via -/ -/ -/ -[ -dense -: -: -Config -: -: -prefilter -] -( -crate -: -: -dfa -: -: -dense -: -: -Config -: -: -prefilter -) -. -/ -/ -/ -/ -/ -/ -Do -note -that -prefilters -are -not -serialized -by -DFAs -in -this -crate -. -/ -/ -/ -So -if -you -deserialize -a -DFA -that -had -a -prefilter -attached -to -it -/ -/ -/ -at -serialization -time -then -it -will -not -have -a -prefilter -after -/ -/ -/ -deserialization -. -# -[ -inline -] -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -None -} -/ -/ -/ -Executes -a -forward -search -and -returns -the -end -position -of -the -leftmost -/ -/ -/ -match -that -is -found -. -If -no -match -exists -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -In -particular -this -method -continues -searching -even -after -it -enters -/ -/ -/ -a -match -state -. -The -search -only -terminates -once -it -has -reached -the -/ -/ -/ -end -of -the -input -or -when -it -has -entered -a -dead -or -quit -state -. -Upon -/ -/ -/ -termination -the -position -of -the -last -byte -seen -while -still -in -a -match -/ -/ -/ -state -is -returned -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -DFA -quitting -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Notes -for -implementors -/ -/ -/ -/ -/ -/ -Implementors -of -this -trait -are -not -required -to -implement -any -particular -/ -/ -/ -match -semantics -( -such -as -leftmost -- -first -) -which -are -instead -manifest -in -/ -/ -/ -the -DFA -' -s -transitions -. -But -this -search -routine -should -behave -as -a -/ -/ -/ -general -" -leftmost -" -search -. -/ -/ -/ -/ -/ -/ -In -particular -this -method -must -continue -searching -even -after -it -enters -/ -/ -/ -a -match -state -. -The -search -should -only -terminate -once -it -has -reached -/ -/ -/ -the -end -of -the -input -or -when -it -has -entered -a -dead -or -quit -state -. -Upon -/ -/ -/ -termination -the -position -of -the -last -byte -seen -while -still -in -a -match -/ -/ -/ -state -is -returned -. -/ -/ -/ -/ -/ -/ -Since -this -trait -provides -an -implementation -for -this -method -by -default -/ -/ -/ -it -' -s -unlikely -that -one -will -need -to -implement -this -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -this -method -with -a -/ -/ -/ -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -b -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -a -match -is -found -after -reading -the -first -byte -( -a -) -/ -/ -/ -/ -/ -the -leftmost -first -match -semantics -demand -that -we -find -the -earliest -/ -/ -/ -/ -/ -match -that -prefers -earlier -parts -of -the -pattern -over -latter -parts -. -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new -( -" -abc -| -a -" -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -b -" -abc -" -) -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specific -pattern -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -multi -- -DFA -that -permits -searching -for -/ -/ -/ -specific -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -} -/ -/ -/ -Anchored -HalfMatch -PatternID -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -starts_for_each_pattern -( -true -) -) -/ -/ -/ -. -build_many -( -& -[ -" -[ -a -- -z0 -- -9 -] -{ -6 -} -" -" -[ -a -- -z -] -[ -a -- -z0 -- -9 -] -{ -5 -} -" -] -) -? -; -/ -/ -/ -let -haystack -= -" -foo123 -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -are -using -the -default -leftmost -- -first -match -and -both -/ -/ -/ -/ -/ -patterns -match -at -the -same -starting -position -only -the -first -pattern -/ -/ -/ -/ -/ -will -be -returned -in -this -case -when -doing -a -search -for -any -of -the -/ -/ -/ -/ -/ -patterns -. -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -6 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -want -to -check -whether -some -other -pattern -matches -then -we -/ -/ -/ -/ -/ -can -provide -its -pattern -ID -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -1 -6 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specifying -the -bounds -of -a -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -providing -the -bounds -of -a -search -can -produce -/ -/ -/ -different -results -than -simply -sub -- -slicing -the -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -We -disable -Unicode -here -so -that -we -use -a -simple -ASCII -word -/ -/ -/ -/ -/ -boundary -. -Alternatively -we -could -enable -heuristic -support -for -/ -/ -/ -/ -/ -Unicode -word -boundaries -. -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new -( -r -" -( -? -- -u -) -\ -b -[ -0 -- -9 -] -{ -3 -} -\ -b -" -) -? -; -/ -/ -/ -let -haystack -= -" -foo123bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -sub -- -slice -the -haystack -the -search -doesn -' -t -know -about -the -/ -/ -/ -/ -/ -larger -context -and -assumes -that -123 -is -surrounded -by -word -/ -/ -/ -/ -/ -boundaries -. -And -of -course -the -match -position -is -reported -relative -/ -/ -/ -/ -/ -to -the -sub -- -slice -as -well -which -means -we -get -3 -instead -of -6 -. -/ -/ -/ -let -input -= -Input -: -: -new -( -& -haystack -[ -3 -. -. -6 -] -) -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -provide -the -bounds -of -the -search -within -the -context -of -the -/ -/ -/ -/ -/ -entire -haystack -then -the -search -can -take -the -surrounding -context -/ -/ -/ -/ -/ -into -account -. -( -And -if -we -did -find -a -match -it -would -be -reported -/ -/ -/ -/ -/ -as -a -valid -offset -into -haystack -instead -of -its -sub -- -slice -. -) -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -3 -. -. -6 -) -; -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -fn -try_search_fwd -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -let -utf8empty -= -self -. -has_empty -( -) -& -& -self -. -is_utf8 -( -) -; -let -hm -= -match -search -: -: -find_fwd -( -& -self -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -hm -) -if -! -utf8empty -= -> -return -Ok -( -Some -( -hm -) -) -Some -( -hm -) -= -> -hm -} -; -/ -/ -We -get -to -this -point -when -we -know -our -DFA -can -match -the -empty -string -/ -/ -AND -when -UTF -- -8 -mode -is -enabled -. -In -this -case -we -skip -any -matches -/ -/ -whose -offset -splits -a -codepoint -. -Such -a -match -is -necessarily -a -/ -/ -zero -- -width -match -because -UTF -- -8 -mode -requires -the -underlying -NFA -/ -/ -to -be -built -such -that -all -non -- -empty -matches -span -valid -UTF -- -8 -. -/ -/ -Therefore -any -match -that -ends -in -the -middle -of -a -codepoint -cannot -/ -/ -be -part -of -a -span -of -valid -UTF -- -8 -and -thus -must -be -an -empty -match -. -/ -/ -In -such -cases -we -skip -it -so -as -not -to -report -matches -that -split -a -/ -/ -codepoint -. -/ -/ -/ -/ -Note -that -this -is -not -a -checked -assumption -. -Callers -* -can -* -provide -an -/ -/ -NFA -with -UTF -- -8 -mode -enabled -but -produces -non -- -empty -matches -that -span -/ -/ -invalid -UTF -- -8 -. -But -doing -so -is -documented -to -result -in -unspecified -/ -/ -behavior -. -empty -: -: -skip_splits_fwd -( -input -hm -hm -. -offset -( -) -| -input -| -{ -let -got -= -search -: -: -find_fwd -( -& -self -input -) -? -; -Ok -( -got -. -map -( -| -hm -| -( -hm -hm -. -offset -( -) -) -) -) -} -) -} -/ -/ -/ -Executes -a -reverse -search -and -returns -the -start -of -the -position -of -the -/ -/ -/ -leftmost -match -that -is -found -. -If -no -match -exists -then -None -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -DFA -quitting -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -this -method -with -a -/ -/ -/ -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -. -In -particular -this -/ -/ -/ -routine -is -principally -useful -when -used -in -conjunction -with -the -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -: -: -reverse -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -: -: -reverse -) -/ -/ -/ -configuration -. -In -general -it -' -s -unlikely -to -be -correct -to -use -/ -/ -/ -both -try_search_fwd -and -try_search_rev -with -the -same -DFA -since -/ -/ -/ -any -particular -DFA -will -only -support -searching -in -one -direction -with -/ -/ -/ -respect -to -the -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -dfa -: -: -{ -Automaton -dense -} -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -0 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_rev -( -& -Input -: -: -new -( -b -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -a -match -is -found -after -reading -the -last -byte -( -c -) -/ -/ -/ -/ -/ -the -leftmost -first -match -semantics -demand -that -we -find -the -earliest -/ -/ -/ -/ -/ -match -that -prefers -earlier -parts -of -the -pattern -over -latter -parts -. -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build -( -" -abc -| -c -" -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -0 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_rev -( -& -Input -: -: -new -( -b -" -abc -" -) -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -UTF -- -8 -mode -/ -/ -/ -/ -/ -/ -This -examples -demonstrates -that -UTF -- -8 -mode -applies -to -reverse -/ -/ -/ -DFAs -. -When -UTF -- -8 -mode -is -enabled -in -the -underlying -NFA -then -all -/ -/ -/ -matches -reported -must -correspond -to -valid -UTF -- -8 -spans -. -This -includes -/ -/ -/ -prohibiting -zero -- -width -matches -that -split -a -codepoint -. -/ -/ -/ -/ -/ -/ -UTF -- -8 -mode -is -enabled -by -default -. -Notice -below -how -the -only -zero -- -width -/ -/ -/ -matches -reported -are -those -at -UTF -- -8 -boundaries -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -: -: -DFA -Automaton -} -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build -( -r -" -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Run -the -reverse -DFA -to -collect -all -matches -. -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -match -dfa -. -try_search_rev -( -& -input -) -? -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -hm -) -= -> -{ -/ -/ -/ -matches -. -push -( -hm -) -; -/ -/ -/ -if -hm -. -offset -( -) -= -= -0 -| -| -input -. -end -( -) -= -= -0 -{ -/ -/ -/ -break -; -/ -/ -/ -} -else -if -hm -. -offset -( -) -< -input -. -end -( -) -{ -/ -/ -/ -input -. -set_end -( -hm -. -offset -( -) -) -; -/ -/ -/ -} -else -{ -/ -/ -/ -/ -/ -This -is -only -necessary -to -handle -zero -- -width -/ -/ -/ -/ -/ -matches -which -of -course -occur -in -this -example -. -/ -/ -/ -/ -/ -Without -this -the -search -would -never -advance -/ -/ -/ -/ -/ -backwards -beyond -the -initial -match -. -/ -/ -/ -input -. -set_end -( -input -. -end -( -) -- -1 -) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -No -matches -split -a -codepoint -. -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -0 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Now -let -' -s -look -at -the -same -example -but -with -UTF -- -8 -mode -on -the -/ -/ -/ -original -NFA -disabled -( -which -results -in -disabling -UTF -- -8 -mode -on -the -/ -/ -/ -DFA -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -: -: -DFA -Automaton -} -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Run -the -reverse -DFA -to -collect -all -matches -. -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -match -dfa -. -try_search_rev -( -& -input -) -? -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -hm -) -= -> -{ -/ -/ -/ -matches -. -push -( -hm -) -; -/ -/ -/ -if -hm -. -offset -( -) -= -= -0 -| -| -input -. -end -( -) -= -= -0 -{ -/ -/ -/ -break -; -/ -/ -/ -} -else -if -hm -. -offset -( -) -< -input -. -end -( -) -{ -/ -/ -/ -input -. -set_end -( -hm -. -offset -( -) -) -; -/ -/ -/ -} -else -{ -/ -/ -/ -/ -/ -This -is -only -necessary -to -handle -zero -- -width -/ -/ -/ -/ -/ -matches -which -of -course -occur -in -this -example -. -/ -/ -/ -/ -/ -Without -this -the -search -would -never -advance -/ -/ -/ -/ -/ -backwards -beyond -the -initial -match -. -/ -/ -/ -input -. -set_end -( -input -. -end -( -) -- -1 -) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -No -matches -split -a -codepoint -. -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -2 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -1 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -0 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -fn -try_search_rev -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -let -utf8empty -= -self -. -has_empty -( -) -& -& -self -. -is_utf8 -( -) -; -let -hm -= -match -search -: -: -find_rev -( -self -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -hm -) -if -! -utf8empty -= -> -return -Ok -( -Some -( -hm -) -) -Some -( -hm -) -= -> -hm -} -; -empty -: -: -skip_splits_rev -( -input -hm -hm -. -offset -( -) -| -input -| -{ -let -got -= -search -: -: -find_rev -( -self -input -) -? -; -Ok -( -got -. -map -( -| -hm -| -( -hm -hm -. -offset -( -) -) -) -) -} -) -} -/ -/ -/ -Executes -an -overlapping -forward -search -. -Matches -if -one -exists -can -be -/ -/ -/ -obtained -via -the -[ -OverlappingState -: -: -get_match -] -method -. -/ -/ -/ -/ -/ -/ -This -routine -is -principally -only -useful -when -searching -for -multiple -/ -/ -/ -patterns -on -inputs -where -multiple -patterns -may -match -the -same -regions -/ -/ -/ -of -text -. -In -particular -callers -must -preserve -the -automaton -' -s -search -/ -/ -/ -state -from -prior -calls -so -that -the -implementation -knows -where -the -last -/ -/ -/ -match -occurred -. -/ -/ -/ -/ -/ -/ -When -using -this -routine -to -implement -an -iterator -of -overlapping -/ -/ -/ -matches -the -start -of -the -search -should -always -be -set -to -the -end -/ -/ -/ -of -the -last -match -. -If -more -patterns -match -at -the -previous -location -/ -/ -/ -then -they -will -be -immediately -returned -. -( -This -is -tracked -by -the -given -/ -/ -/ -overlapping -state -. -) -Otherwise -the -search -continues -at -the -starting -/ -/ -/ -position -given -. -/ -/ -/ -/ -/ -/ -If -for -some -reason -you -want -the -search -to -forget -about -its -previous -/ -/ -/ -state -and -restart -the -search -at -a -particular -position -then -setting -the -/ -/ -/ -state -to -[ -OverlappingState -: -: -start -] -will -accomplish -that -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -DFA -quitting -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -run -a -basic -overlapping -search -with -a -/ -/ -/ -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -. -Notice -that -we -build -the -/ -/ -/ -automaton -with -a -MatchKind -: -: -All -configuration -. -Overlapping -searches -/ -/ -/ -are -unlikely -to -work -as -one -would -expect -when -using -the -default -/ -/ -/ -MatchKind -: -: -LeftmostFirst -match -semantics -since -leftmost -- -first -/ -/ -/ -matching -is -fundamentally -incompatible -with -overlapping -searches -. -/ -/ -/ -Namely -overlapping -searches -need -to -report -matches -as -they -are -seen -/ -/ -/ -where -as -leftmost -- -first -searches -will -continue -searching -even -after -a -/ -/ -/ -match -has -been -observed -in -order -to -find -the -conventional -end -position -/ -/ -/ -of -the -match -. -More -concretely -leftmost -- -first -searches -use -dead -states -/ -/ -/ -to -terminate -a -search -after -a -specific -match -can -no -longer -be -extended -. -/ -/ -/ -Overlapping -searches -instead -do -the -opposite -by -continuing -the -search -/ -/ -/ -to -find -totally -new -matches -( -potentially -of -other -patterns -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -OverlappingState -dense -} -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -[ -[ -: -word -: -] -] -+ -" -r -" -[ -[ -: -^ -space -: -] -] -+ -" -] -) -? -; -/ -/ -/ -let -haystack -= -" -foo -" -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -1 -4 -) -) -; -/ -/ -/ -dfa -. -try_search_overlapping_fwd -( -& -Input -: -: -new -( -haystack -) -& -mut -state -) -? -; -/ -/ -/ -assert_eq -! -( -expected -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -first -pattern -also -matches -at -the -same -position -so -re -- -running -/ -/ -/ -/ -/ -the -search -will -yield -another -match -. -Notice -also -that -the -first -/ -/ -/ -/ -/ -pattern -is -returned -after -the -second -. -This -is -because -the -second -/ -/ -/ -/ -/ -pattern -begins -its -match -before -the -first -is -therefore -an -earlier -/ -/ -/ -/ -/ -match -and -is -thus -reported -first -. -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -4 -) -) -; -/ -/ -/ -dfa -. -try_search_overlapping_fwd -( -& -Input -: -: -new -( -haystack -) -& -mut -state -) -? -; -/ -/ -/ -assert_eq -! -( -expected -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -fn -try_search_overlapping_fwd -( -& -self -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -let -utf8empty -= -self -. -has_empty -( -) -& -& -self -. -is_utf8 -( -) -; -search -: -: -find_overlapping_fwd -( -self -input -state -) -? -; -match -state -. -get_match -( -) -{ -None -= -> -Ok -( -( -) -) -Some -( -_ -) -if -! -utf8empty -= -> -Ok -( -( -) -) -Some -( -_ -) -= -> -skip_empty_utf8_splits_overlapping -( -input -state -| -input -state -| -{ -search -: -: -find_overlapping_fwd -( -self -input -state -) -} -) -} -} -/ -/ -/ -Executes -a -reverse -overlapping -forward -search -. -Matches -if -one -exists -/ -/ -/ -can -be -obtained -via -the -[ -OverlappingState -: -: -get_match -] -method -. -/ -/ -/ -/ -/ -/ -When -using -this -routine -to -implement -an -iterator -of -overlapping -/ -/ -/ -matches -the -start -of -the -search -should -remain -invariant -throughout -/ -/ -/ -iteration -. -The -OverlappingState -given -to -the -search -will -keep -track -/ -/ -/ -of -the -current -position -of -the -search -. -( -This -is -because -multiple -/ -/ -/ -matches -may -be -reported -at -the -same -position -so -only -the -search -/ -/ -/ -implementation -itself -knows -when -to -advance -the -position -. -) -/ -/ -/ -/ -/ -/ -If -for -some -reason -you -want -the -search -to -forget -about -its -previous -/ -/ -/ -state -and -restart -the -search -at -a -particular -position -then -setting -the -/ -/ -/ -state -to -[ -OverlappingState -: -: -start -] -will -accomplish -that -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -DFA -quitting -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -: -UTF -- -8 -mode -/ -/ -/ -/ -/ -/ -This -examples -demonstrates -that -UTF -- -8 -mode -applies -to -reverse -/ -/ -/ -DFAs -. -When -UTF -- -8 -mode -is -enabled -in -the -underlying -NFA -then -all -/ -/ -/ -matches -reported -must -correspond -to -valid -UTF -- -8 -spans -. -This -includes -/ -/ -/ -prohibiting -zero -- -width -matches -that -split -a -codepoint -. -/ -/ -/ -/ -/ -/ -UTF -- -8 -mode -is -enabled -by -default -. -Notice -below -how -the -only -zero -- -width -/ -/ -/ -matches -reported -are -those -at -UTF -- -8 -boundaries -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -: -: -DFA -Automaton -OverlappingState -} -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -" -r -" -" -] -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Run -the -reverse -DFA -to -collect -all -matches -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -dfa -. -try_search_overlapping_rev -( -& -input -& -mut -state -) -? -; -/ -/ -/ -match -state -. -get_match -( -) -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -hm -) -= -> -matches -. -push -( -hm -) -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -No -matches -split -a -codepoint -. -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -1 -0 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -0 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Now -let -' -s -look -at -the -same -example -but -with -UTF -- -8 -mode -on -the -/ -/ -/ -original -NFA -disabled -( -which -results -in -disabling -UTF -- -8 -mode -on -the -/ -/ -/ -DFA -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -: -: -DFA -Automaton -OverlappingState -} -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -" -r -" -" -] -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Run -the -reverse -DFA -to -collect -all -matches -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -dfa -. -try_search_overlapping_rev -( -& -input -& -mut -state -) -? -; -/ -/ -/ -match -state -. -get_match -( -) -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -hm -) -= -> -matches -. -push -( -hm -) -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -Now -* -all -* -positions -match -even -within -a -codepoint -/ -/ -/ -/ -/ -because -we -lifted -the -requirement -that -matches -/ -/ -/ -/ -/ -correspond -to -valid -UTF -- -8 -spans -. -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -2 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -1 -) -/ -/ -/ -HalfMatch -: -: -must -( -1 -0 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -0 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -fn -try_search_overlapping_rev -( -& -self -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -let -utf8empty -= -self -. -has_empty -( -) -& -& -self -. -is_utf8 -( -) -; -search -: -: -find_overlapping_rev -( -self -input -state -) -? -; -match -state -. -get_match -( -) -{ -None -= -> -Ok -( -( -) -) -Some -( -_ -) -if -! -utf8empty -= -> -Ok -( -( -) -) -Some -( -_ -) -= -> -skip_empty_utf8_splits_overlapping -( -input -state -| -input -state -| -{ -search -: -: -find_overlapping_rev -( -self -input -state -) -} -) -} -} -/ -/ -/ -Writes -the -set -of -patterns -that -match -anywhere -in -the -given -search -/ -/ -/ -configuration -to -patset -. -If -multiple -patterns -match -at -the -same -/ -/ -/ -position -and -the -underlying -DFA -supports -overlapping -matches -then -all -/ -/ -/ -matching -patterns -are -written -to -the -given -set -. -/ -/ -/ -/ -/ -/ -Unless -all -of -the -patterns -in -this -DFA -are -anchored -then -generally -/ -/ -/ -speaking -this -will -visit -every -byte -in -the -haystack -. -/ -/ -/ -/ -/ -/ -This -search -routine -* -does -not -* -clear -the -pattern -set -. -This -gives -some -/ -/ -/ -flexibility -to -the -caller -( -e -. -g -. -running -multiple -searches -with -the -/ -/ -/ -same -pattern -set -) -but -does -make -the -API -bug -- -prone -if -you -' -re -reusing -/ -/ -/ -the -same -pattern -set -for -multiple -searches -but -intended -them -to -be -/ -/ -/ -independent -. -/ -/ -/ -/ -/ -/ -If -a -pattern -ID -matched -but -the -given -PatternSet -does -not -have -/ -/ -/ -sufficient -capacity -to -store -it -then -it -is -not -inserted -and -silently -/ -/ -/ -dropped -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -DFA -quitting -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -all -matching -patterns -in -a -haystack -/ -/ -/ -even -when -some -patterns -match -at -the -same -position -as -other -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -/ -/ -/ -Input -MatchKind -PatternSet -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -/ -/ -/ -r -" -[ -[ -: -word -: -] -] -+ -" -/ -/ -/ -r -" -[ -0 -- -9 -] -+ -" -/ -/ -/ -r -" -[ -[ -: -alpha -: -] -] -+ -" -/ -/ -/ -r -" -foo -" -/ -/ -/ -r -" -bar -" -/ -/ -/ -r -" -barfoo -" -/ -/ -/ -r -" -foobar -" -/ -/ -/ -] -; -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -patterns -) -? -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -let -mut -patset -= -PatternSet -: -: -new -( -dfa -. -pattern_len -( -) -) -; -/ -/ -/ -dfa -. -try_which_overlapping_matches -( -& -input -& -mut -patset -) -? -; -/ -/ -/ -let -expected -= -vec -! -[ -0 -2 -3 -4 -6 -] -; -/ -/ -/ -let -got -: -Vec -< -usize -> -= -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -# -[ -inline -] -fn -try_which_overlapping_matches -( -& -self -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -- -> -Result -< -( -) -MatchError -> -{ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -while -let -Some -( -m -) -= -{ -self -. -try_search_overlapping_fwd -( -input -& -mut -state -) -? -; -state -. -get_match -( -) -} -{ -let -_ -= -patset -. -insert -( -m -. -pattern -( -) -) -; -/ -/ -There -' -s -nothing -left -to -find -so -we -can -stop -. -Or -the -caller -/ -/ -asked -us -to -. -if -patset -. -is_full -( -) -| -| -input -. -get_earliest -( -) -{ -break -; -} -} -Ok -( -( -) -) -} -} -unsafe -impl -< -' -a -A -: -Automaton -+ -? -Sized -> -Automaton -for -& -' -a -A -{ -# -[ -inline -] -fn -next_state -( -& -self -current -: -StateID -input -: -u8 -) -- -> -StateID -{ -( -* -* -self -) -. -next_state -( -current -input -) -} -# -[ -inline -] -unsafe -fn -next_state_unchecked -( -& -self -current -: -StateID -input -: -u8 -) -- -> -StateID -{ -( -* -* -self -) -. -next_state_unchecked -( -current -input -) -} -# -[ -inline -] -fn -next_eoi_state -( -& -self -current -: -StateID -) -- -> -StateID -{ -( -* -* -self -) -. -next_eoi_state -( -current -) -} -# -[ -inline -] -fn -start_state_forward -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -{ -( -* -* -self -) -. -start_state_forward -( -input -) -} -# -[ -inline -] -fn -start_state_reverse -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -{ -( -* -* -self -) -. -start_state_reverse -( -input -) -} -# -[ -inline -] -fn -universal_start_state -( -& -self -mode -: -Anchored -) -- -> -Option -< -StateID -> -{ -( -* -* -self -) -. -universal_start_state -( -mode -) -} -# -[ -inline -] -fn -is_special_state -( -& -self -id -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_special_state -( -id -) -} -# -[ -inline -] -fn -is_dead_state -( -& -self -id -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_dead_state -( -id -) -} -# -[ -inline -] -fn -is_quit_state -( -& -self -id -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_quit_state -( -id -) -} -# -[ -inline -] -fn -is_match_state -( -& -self -id -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_match_state -( -id -) -} -# -[ -inline -] -fn -is_start_state -( -& -self -id -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_start_state -( -id -) -} -# -[ -inline -] -fn -is_accel_state -( -& -self -id -: -StateID -) -- -> -bool -{ -( -* -* -self -) -. -is_accel_state -( -id -) -} -# -[ -inline -] -fn -pattern_len -( -& -self -) -- -> -usize -{ -( -* -* -self -) -. -pattern_len -( -) -} -# -[ -inline -] -fn -match_len -( -& -self -id -: -StateID -) -- -> -usize -{ -( -* -* -self -) -. -match_len -( -id -) -} -# -[ -inline -] -fn -match_pattern -( -& -self -id -: -StateID -index -: -usize -) -- -> -PatternID -{ -( -* -* -self -) -. -match_pattern -( -id -index -) -} -# -[ -inline -] -fn -has_empty -( -& -self -) -- -> -bool -{ -( -* -* -self -) -. -has_empty -( -) -} -# -[ -inline -] -fn -is_utf8 -( -& -self -) -- -> -bool -{ -( -* -* -self -) -. -is_utf8 -( -) -} -# -[ -inline -] -fn -is_always_start_anchored -( -& -self -) -- -> -bool -{ -( -* -* -self -) -. -is_always_start_anchored -( -) -} -# -[ -inline -] -fn -accelerator -( -& -self -id -: -StateID -) -- -> -& -[ -u8 -] -{ -( -* -* -self -) -. -accelerator -( -id -) -} -# -[ -inline -] -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -( -* -* -self -) -. -get_prefilter -( -) -} -# -[ -inline -] -fn -try_search_fwd -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -( -* -* -self -) -. -try_search_fwd -( -input -) -} -# -[ -inline -] -fn -try_search_rev -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -( -* -* -self -) -. -try_search_rev -( -input -) -} -# -[ -inline -] -fn -try_search_overlapping_fwd -( -& -self -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -( -* -* -self -) -. -try_search_overlapping_fwd -( -input -state -) -} -# -[ -inline -] -fn -try_search_overlapping_rev -( -& -self -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -( -* -* -self -) -. -try_search_overlapping_rev -( -input -state -) -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -# -[ -inline -] -fn -try_which_overlapping_matches -( -& -self -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -- -> -Result -< -( -) -MatchError -> -{ -( -* -* -self -) -. -try_which_overlapping_matches -( -input -patset -) -} -} -/ -/ -/ -Represents -the -current -state -of -an -overlapping -search -. -/ -/ -/ -/ -/ -/ -This -is -used -for -overlapping -searches -since -they -need -to -know -something -/ -/ -/ -about -the -previous -search -. -For -example -when -multiple -patterns -match -at -the -/ -/ -/ -same -position -this -state -tracks -the -last -reported -pattern -so -that -the -next -/ -/ -/ -search -knows -whether -to -report -another -matching -pattern -or -continue -with -/ -/ -/ -the -search -at -the -next -position -. -Additionally -it -also -tracks -which -state -/ -/ -/ -the -last -search -call -terminated -in -. -/ -/ -/ -/ -/ -/ -This -type -provides -little -introspection -capabilities -. -The -only -thing -a -/ -/ -/ -caller -can -do -is -construct -it -and -pass -it -around -to -permit -search -routines -/ -/ -/ -to -use -it -to -track -state -and -also -ask -whether -a -match -has -been -found -. -/ -/ -/ -/ -/ -/ -Callers -should -always -provide -a -fresh -state -constructed -via -/ -/ -/ -[ -OverlappingState -: -: -start -] -when -starting -a -new -search -. -Reusing -state -from -/ -/ -/ -a -previous -search -may -result -in -incorrect -results -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -OverlappingState -{ -/ -/ -/ -The -match -reported -by -the -most -recent -overlapping -search -to -use -this -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -If -a -search -does -not -find -any -matches -then -it -is -expected -to -clear -/ -/ -/ -this -value -. -pub -( -crate -) -mat -: -Option -< -HalfMatch -> -/ -/ -/ -The -state -ID -of -the -state -at -which -the -search -was -in -when -the -call -/ -/ -/ -terminated -. -When -this -is -a -match -state -last_match -must -be -set -to -a -/ -/ -/ -non -- -None -value -. -/ -/ -/ -/ -/ -/ -A -None -value -indicates -the -start -state -of -the -corresponding -/ -/ -/ -automaton -. -We -cannot -use -the -actual -ID -since -any -one -automaton -may -/ -/ -/ -have -many -start -states -and -which -one -is -in -use -depends -on -several -/ -/ -/ -search -- -time -factors -. -pub -( -crate -) -id -: -Option -< -StateID -> -/ -/ -/ -The -position -of -the -search -. -/ -/ -/ -/ -/ -/ -When -id -is -None -( -i -. -e -. -we -are -starting -a -search -) -this -is -set -to -/ -/ -/ -the -beginning -of -the -search -as -given -by -the -caller -regardless -of -its -/ -/ -/ -current -value -. -Subsequent -calls -to -an -overlapping -search -pick -up -at -/ -/ -/ -this -offset -. -pub -( -crate -) -at -: -usize -/ -/ -/ -The -index -into -the -matching -patterns -of -the -next -match -to -report -if -the -/ -/ -/ -current -state -is -a -match -state -. -Note -that -this -may -be -1 -greater -than -/ -/ -/ -the -total -number -of -matches -to -report -for -the -current -match -state -. -( -In -/ -/ -/ -which -case -no -more -matches -should -be -reported -at -the -current -position -/ -/ -/ -and -the -search -should -advance -to -the -next -position -. -) -pub -( -crate -) -next_match_index -: -Option -< -usize -> -/ -/ -/ -This -is -set -to -true -when -a -reverse -overlapping -search -has -entered -its -/ -/ -/ -EOI -transitions -. -/ -/ -/ -/ -/ -/ -This -isn -' -t -used -in -a -forward -search -because -it -knows -to -stop -once -the -/ -/ -/ -position -exceeds -the -end -of -the -search -range -. -In -a -reverse -search -/ -/ -/ -since -we -use -unsigned -offsets -we -don -' -t -" -know -" -once -we -' -ve -gone -past -/ -/ -/ -0 -. -So -the -only -way -to -detect -it -is -with -this -extra -flag -. -The -reverse -/ -/ -/ -overlapping -search -knows -to -terminate -specifically -after -it -has -/ -/ -/ -reported -all -matches -after -following -the -EOI -transition -. -pub -( -crate -) -rev_eoi -: -bool -} -impl -OverlappingState -{ -/ -/ -/ -Create -a -new -overlapping -state -that -begins -at -the -start -state -of -any -/ -/ -/ -automaton -. -pub -fn -start -( -) -- -> -OverlappingState -{ -OverlappingState -{ -mat -: -None -id -: -None -at -: -0 -next_match_index -: -None -rev_eoi -: -false -} -} -/ -/ -/ -Return -the -match -result -of -the -most -recent -search -to -execute -with -this -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -A -searches -will -clear -this -result -automatically -such -that -if -no -/ -/ -/ -match -is -found -this -will -correctly -report -None -. -pub -fn -get_match -( -& -self -) -- -> -Option -< -HalfMatch -> -{ -self -. -mat -} -} -/ -/ -/ -Runs -the -given -overlapping -search -function -( -forwards -or -backwards -) -until -/ -/ -/ -a -match -is -found -whose -offset -does -not -split -a -codepoint -. -/ -/ -/ -/ -/ -/ -This -is -* -not -* -always -correct -to -call -. -It -should -only -be -called -when -the -DFA -/ -/ -/ -has -UTF -- -8 -mode -enabled -* -and -* -it -can -produce -zero -- -width -matches -. -Calling -/ -/ -/ -this -when -both -of -those -things -aren -' -t -true -might -result -in -legitimate -/ -/ -/ -matches -getting -skipped -. -# -[ -cold -] -# -[ -inline -( -never -) -] -fn -skip_empty_utf8_splits_overlapping -< -F -> -( -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -mut -search -: -F -) -- -> -Result -< -( -) -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -/ -/ -Note -that -this -routine -works -for -forwards -and -reverse -searches -/ -/ -even -though -there -' -s -no -code -here -to -handle -those -cases -. -That -' -s -/ -/ -because -overlapping -searches -drive -themselves -to -completion -via -/ -/ -OverlappingState -. -So -all -we -have -to -do -is -push -it -until -no -matches -are -/ -/ -found -. -let -mut -hm -= -match -state -. -get_match -( -) -{ -None -= -> -return -Ok -( -( -) -) -Some -( -hm -) -= -> -hm -} -; -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -if -! -input -. -is_char_boundary -( -hm -. -offset -( -) -) -{ -state -. -mat -= -None -; -} -return -Ok -( -( -) -) -; -} -while -! -input -. -is_char_boundary -( -hm -. -offset -( -) -) -{ -search -( -input -state -) -? -; -hm -= -match -state -. -get_match -( -) -{ -None -= -> -return -Ok -( -( -) -) -Some -( -hm -) -= -> -hm -} -; -} -Ok -( -( -) -) -} -/ -/ -/ -Write -a -prefix -" -state -" -indicator -for -fmt -: -: -Debug -impls -. -/ -/ -/ -/ -/ -/ -Specifically -this -tries -to -succinctly -distinguish -the -different -types -of -/ -/ -/ -states -: -dead -states -quit -states -accelerated -states -start -states -and -/ -/ -/ -match -states -. -It -even -accounts -for -the -possible -overlappings -of -different -/ -/ -/ -state -types -. -pub -( -crate -) -fn -fmt_state_indicator -< -A -: -Automaton -> -( -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -dfa -: -A -id -: -StateID -) -- -> -core -: -: -fmt -: -: -Result -{ -if -dfa -. -is_dead_state -( -id -) -{ -write -! -( -f -" -D -" -) -? -; -if -dfa -. -is_start_state -( -id -) -{ -write -! -( -f -" -> -" -) -? -; -} -else -{ -write -! -( -f -" -" -) -? -; -} -} -else -if -dfa -. -is_quit_state -( -id -) -{ -write -! -( -f -" -Q -" -) -? -; -} -else -if -dfa -. -is_start_state -( -id -) -{ -if -dfa -. -is_accel_state -( -id -) -{ -write -! -( -f -" -A -> -" -) -? -; -} -else -{ -write -! -( -f -" -> -" -) -? -; -} -} -else -if -dfa -. -is_match_state -( -id -) -{ -if -dfa -. -is_accel_state -( -id -) -{ -write -! -( -f -" -A -* -" -) -? -; -} -else -{ -write -! -( -f -" -* -" -) -? -; -} -} -else -if -dfa -. -is_accel_state -( -id -) -{ -write -! -( -f -" -A -" -) -? -; -} -else -{ -write -! -( -f -" -" -) -? -; -} -Ok -( -( -) -) -} -# -[ -cfg -( -all -( -test -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -mod -tests -{ -/ -/ -A -basic -test -ensuring -that -our -Automaton -trait -is -object -safe -. -( -This -is -/ -/ -the -main -reason -why -we -don -' -t -define -the -search -routines -as -generic -over -/ -/ -Into -< -Input -> -. -) -# -[ -test -] -fn -object_safe -( -) -{ -use -crate -: -: -{ -dfa -: -: -{ -dense -Automaton -} -HalfMatch -Input -} -; -let -dfa -= -dense -: -: -DFA -: -: -new -( -" -abc -" -) -. -unwrap -( -) -; -let -dfa -: -& -dyn -Automaton -= -& -dfa -; -assert_eq -! -( -Ok -( -Some -( -HalfMatch -: -: -must -( -0 -6 -) -) -) -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -b -" -xyzabcxyz -" -) -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/dfa/dense.rs b/third_party/rust/regex-automata/src/dfa/dense.rs deleted file mode 100644 index 01befde6b66ae..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/dense.rs +++ /dev/null @@ -1,50847 +0,0 @@ -/ -* -! -Types -and -routines -specific -to -dense -DFAs -. -This -module -is -the -home -of -[ -dense -: -: -DFA -] -( -DFA -) -. -This -module -also -contains -a -[ -dense -: -: -Builder -] -( -Builder -) -and -a -[ -dense -: -: -Config -] -( -Config -) -for -building -and -configuring -a -dense -DFA -. -* -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -core -: -: -cmp -; -use -core -: -: -{ -convert -: -: -TryFrom -fmt -iter -mem -: -: -size_of -slice -} -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -alloc -: -: -{ -collections -: -: -{ -BTreeMap -BTreeSet -} -vec -vec -: -: -Vec -} -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -crate -: -: -{ -dfa -: -: -{ -accel -: -: -Accel -determinize -minimize -: -: -Minimizer -remapper -: -: -Remapper -sparse -} -nfa -: -: -thompson -util -: -: -{ -look -: -: -LookMatcher -search -: -: -MatchKind -} -} -; -use -crate -: -: -{ -dfa -: -: -{ -accel -: -: -Accels -automaton -: -: -{ -fmt_state_indicator -Automaton -} -special -: -: -Special -start -: -: -StartKind -DEAD -} -util -: -: -{ -alphabet -: -: -{ -self -ByteClasses -ByteSet -} -int -: -: -{ -Pointer -Usize -} -prefilter -: -: -Prefilter -primitives -: -: -{ -PatternID -StateID -} -search -: -: -{ -Anchored -Input -MatchError -} -start -: -: -{ -Start -StartByteMap -} -wire -: -: -{ -self -DeserializeError -Endian -SerializeError -} -} -} -; -/ -/ -/ -The -label -that -is -pre -- -pended -to -a -serialized -DFA -. -const -LABEL -: -& -str -= -" -rust -- -regex -- -automata -- -dfa -- -dense -" -; -/ -/ -/ -The -format -version -of -dense -regexes -. -This -version -gets -incremented -when -a -/ -/ -/ -change -occurs -. -A -change -may -not -necessarily -be -a -breaking -change -but -the -/ -/ -/ -version -does -permit -good -error -messages -in -the -case -where -a -breaking -change -/ -/ -/ -is -made -. -const -VERSION -: -u32 -= -2 -; -/ -/ -/ -The -configuration -used -for -compiling -a -dense -DFA -. -/ -/ -/ -/ -/ -/ -As -a -convenience -[ -DFA -: -: -config -] -is -an -alias -for -[ -Config -: -: -new -] -. -The -/ -/ -/ -advantage -of -the -former -is -that -it -often -lets -you -avoid -importing -the -/ -/ -/ -Config -type -directly -. -/ -/ -/ -/ -/ -/ -A -dense -DFA -configuration -is -a -simple -data -object -that -is -typically -used -/ -/ -/ -with -[ -dense -: -: -Builder -: -: -configure -] -( -self -: -: -Builder -: -: -configure -) -. -/ -/ -/ -/ -/ -/ -The -default -configuration -guarantees -that -a -search -will -never -return -/ -/ -/ -a -" -quit -" -error -although -it -is -possible -for -a -search -to -fail -if -/ -/ -/ -[ -Config -: -: -starts_for_each_pattern -] -wasn -' -t -enabled -( -which -it -is -not -by -/ -/ -/ -default -) -and -an -[ -Anchored -: -: -Pattern -] -mode -is -requested -via -[ -Input -] -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -Config -{ -/ -/ -As -with -other -configuration -types -in -this -crate -we -put -all -our -knobs -/ -/ -in -options -so -that -we -can -distinguish -between -" -default -" -and -" -not -set -. -" -/ -/ -This -makes -it -possible -to -easily -combine -multiple -configurations -/ -/ -without -default -values -overwriting -explicitly -specified -values -. -See -the -/ -/ -' -overwrite -' -method -. -/ -/ -/ -/ -For -docs -on -the -fields -below -see -the -corresponding -method -setters -. -accelerate -: -Option -< -bool -> -pre -: -Option -< -Option -< -Prefilter -> -> -minimize -: -Option -< -bool -> -match_kind -: -Option -< -MatchKind -> -start_kind -: -Option -< -StartKind -> -starts_for_each_pattern -: -Option -< -bool -> -byte_classes -: -Option -< -bool -> -unicode_word_boundary -: -Option -< -bool -> -quitset -: -Option -< -ByteSet -> -specialize_start_states -: -Option -< -bool -> -dfa_size_limit -: -Option -< -Option -< -usize -> -> -determinize_size_limit -: -Option -< -Option -< -usize -> -> -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -Config -{ -/ -/ -/ -Return -a -new -default -dense -DFA -compiler -configuration -. -pub -fn -new -( -) -- -> -Config -{ -Config -: -: -default -( -) -} -/ -/ -/ -Enable -state -acceleration -. -/ -/ -/ -/ -/ -/ -When -enabled -DFA -construction -will -analyze -each -state -to -determine -/ -/ -/ -whether -it -is -eligible -for -simple -acceleration -. -Acceleration -typically -/ -/ -/ -occurs -when -most -of -a -state -' -s -transitions -loop -back -to -itself -leaving -/ -/ -/ -only -a -select -few -bytes -that -will -exit -the -state -. -When -this -occurs -/ -/ -/ -other -routines -like -memchr -can -be -used -to -look -for -those -bytes -which -/ -/ -/ -may -be -much -faster -than -traversing -the -DFA -. -/ -/ -/ -/ -/ -/ -Callers -may -elect -to -disable -this -if -consistent -performance -is -more -/ -/ -/ -desirable -than -variable -performance -. -Namely -acceleration -can -sometimes -/ -/ -/ -make -searching -slower -than -it -otherwise -would -be -if -the -transitions -/ -/ -/ -that -leave -accelerated -states -are -traversed -frequently -. -/ -/ -/ -/ -/ -/ -See -[ -Automaton -: -: -accelerator -] -( -crate -: -: -dfa -: -: -Automaton -: -: -accelerator -) -for -/ -/ -/ -an -example -. -/ -/ -/ -/ -/ -/ -This -is -enabled -by -default -. -pub -fn -accelerate -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -accelerate -= -Some -( -yes -) -; -self -} -/ -/ -/ -Set -a -prefilter -to -be -used -whenever -a -start -state -is -entered -. -/ -/ -/ -/ -/ -/ -A -[ -Prefilter -] -in -this -context -is -meant -to -accelerate -searches -by -/ -/ -/ -looking -for -literal -prefixes -that -every -match -for -the -corresponding -/ -/ -/ -pattern -( -or -patterns -) -must -start -with -. -Once -a -prefilter -produces -a -/ -/ -/ -match -the -underlying -search -routine -continues -on -to -try -and -confirm -/ -/ -/ -the -match -. -/ -/ -/ -/ -/ -/ -Be -warned -that -setting -a -prefilter -does -not -guarantee -that -the -search -/ -/ -/ -will -be -faster -. -While -it -' -s -usually -a -good -bet -if -the -prefilter -/ -/ -/ -produces -a -lot -of -false -positive -candidates -( -i -. -e -. -positions -matched -/ -/ -/ -by -the -prefilter -but -not -by -the -regex -) -then -the -overall -result -can -/ -/ -/ -be -slower -than -if -you -had -just -executed -the -regex -engine -without -any -/ -/ -/ -prefilters -. -/ -/ -/ -/ -/ -/ -Note -that -unless -[ -Config -: -: -specialize_start_states -] -has -been -/ -/ -/ -explicitly -set -then -setting -this -will -also -enable -( -when -pre -is -/ -/ -/ -Some -) -or -disable -( -when -pre -is -None -) -start -state -specialization -. -/ -/ -/ -This -occurs -because -without -start -state -specialization -a -prefilter -/ -/ -/ -is -likely -to -be -less -effective -. -And -without -a -prefilter -start -state -/ -/ -/ -specialization -is -usually -pointless -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -Note -that -prefilters -are -not -preserved -as -part -of -/ -/ -/ -serialization -. -Serializing -a -DFA -will -drop -its -prefilter -. -/ -/ -/ -/ -/ -/ -By -default -no -prefilter -is -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -: -: -DFA -Automaton -} -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Input -HalfMatch -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -prefilter -( -pre -) -) -/ -/ -/ -. -build -( -r -" -( -foo -| -bar -) -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo1 -barfox -bar -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -HalfMatch -: -: -must -( -0 -11 -) -) -/ -/ -/ -re -. -try_search_fwd -( -& -input -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Be -warned -though -that -an -incorrect -prefilter -can -lead -to -incorrect -/ -/ -/ -results -! -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -: -: -DFA -Automaton -} -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Input -HalfMatch -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -foo -" -" -car -" -] -) -; -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -prefilter -( -pre -) -) -/ -/ -/ -. -build -( -r -" -( -foo -| -bar -) -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo1 -barfox -bar -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -/ -/ -No -match -reported -even -though -there -clearly -is -one -! -/ -/ -/ -None -/ -/ -/ -re -. -try_search_fwd -( -& -input -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -prefilter -( -mut -self -pre -: -Option -< -Prefilter -> -) -- -> -Config -{ -self -. -pre -= -Some -( -pre -) -; -if -self -. -specialize_start_states -. -is_none -( -) -{ -self -. -specialize_start_states -= -Some -( -self -. -get_prefilter -( -) -. -is_some -( -) -) -; -} -self -} -/ -/ -/ -Minimize -the -DFA -. -/ -/ -/ -/ -/ -/ -When -enabled -the -DFA -built -will -be -minimized -such -that -it -is -as -small -/ -/ -/ -as -possible -. -/ -/ -/ -/ -/ -/ -Whether -one -enables -minimization -or -not -depends -on -the -types -of -costs -/ -/ -/ -you -' -re -willing -to -pay -and -how -much -you -care -about -its -benefits -. -In -/ -/ -/ -particular -minimization -has -worst -case -O -( -n -* -k -* -logn -) -time -and -O -( -k -* -n -) -/ -/ -/ -space -where -n -is -the -number -of -DFA -states -and -k -is -the -alphabet -/ -/ -/ -size -. -In -practice -minimization -can -be -quite -costly -in -terms -of -both -/ -/ -/ -space -and -time -so -it -should -only -be -done -if -you -' -re -willing -to -wait -/ -/ -/ -longer -to -produce -a -DFA -. -In -general -you -might -want -a -minimal -DFA -in -/ -/ -/ -the -following -circumstances -: -/ -/ -/ -/ -/ -/ -1 -. -You -would -like -to -optimize -for -the -size -of -the -automaton -. -This -can -/ -/ -/ -manifest -in -one -of -two -ways -. -Firstly -if -you -' -re -converting -the -/ -/ -/ -DFA -into -Rust -code -( -or -a -table -embedded -in -the -code -) -then -a -minimal -/ -/ -/ -DFA -will -translate -into -a -corresponding -reduction -in -code -size -and -/ -/ -/ -thus -also -the -final -compiled -binary -size -. -Secondly -if -you -are -/ -/ -/ -building -many -DFAs -and -putting -them -on -the -heap -you -' -ll -be -able -to -/ -/ -/ -fit -more -if -they -are -smaller -. -Note -though -that -building -a -minimal -/ -/ -/ -DFA -itself -requires -additional -space -; -you -only -realize -the -space -/ -/ -/ -savings -once -the -minimal -DFA -is -constructed -( -at -which -point -the -/ -/ -/ -space -used -for -minimization -is -freed -) -. -/ -/ -/ -2 -. -You -' -ve -observed -that -a -smaller -DFA -results -in -faster -match -/ -/ -/ -performance -. -Naively -this -isn -' -t -guaranteed -since -there -is -no -/ -/ -/ -inherent -difference -between -matching -with -a -bigger -- -than -- -minimal -/ -/ -/ -DFA -and -a -minimal -DFA -. -However -a -smaller -DFA -may -make -use -of -your -/ -/ -/ -CPU -' -s -cache -more -efficiently -. -/ -/ -/ -3 -. -You -are -trying -to -establish -an -equivalence -between -regular -/ -/ -/ -languages -. -The -standard -method -for -this -is -to -build -a -minimal -DFA -/ -/ -/ -for -each -language -and -then -compare -them -. -If -the -DFAs -are -equivalent -/ -/ -/ -( -up -to -state -renaming -) -then -the -languages -are -equivalent -. -/ -/ -/ -/ -/ -/ -Typically -minimization -only -makes -sense -as -an -offline -process -. -That -/ -/ -/ -is -one -might -minimize -a -DFA -before -serializing -it -to -persistent -/ -/ -/ -storage -. -In -practical -terms -minimization -can -take -around -an -order -of -/ -/ -/ -magnitude -more -time -than -compiling -the -initial -DFA -via -determinization -. -/ -/ -/ -/ -/ -/ -This -option -is -disabled -by -default -. -pub -fn -minimize -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -minimize -= -Some -( -yes -) -; -self -} -/ -/ -/ -Set -the -desired -match -semantics -. -/ -/ -/ -/ -/ -/ -The -default -is -[ -MatchKind -: -: -LeftmostFirst -] -which -corresponds -to -the -/ -/ -/ -match -semantics -of -Perl -- -like -regex -engines -. -That -is -when -multiple -/ -/ -/ -patterns -would -match -at -the -same -leftmost -position -the -pattern -that -/ -/ -/ -appears -first -in -the -concrete -syntax -is -chosen -. -/ -/ -/ -/ -/ -/ -Currently -the -only -other -kind -of -match -semantics -supported -is -/ -/ -/ -[ -MatchKind -: -: -All -] -. -This -corresponds -to -classical -DFA -construction -/ -/ -/ -where -all -possible -matches -are -added -to -the -DFA -. -/ -/ -/ -/ -/ -/ -Typically -All -is -used -when -one -wants -to -execute -an -overlapping -/ -/ -/ -search -and -LeftmostFirst -otherwise -. -In -particular -it -rarely -makes -/ -/ -/ -sense -to -use -All -with -the -various -" -leftmost -" -find -routines -since -the -/ -/ -/ -leftmost -routines -depend -on -the -LeftmostFirst -automata -construction -/ -/ -/ -strategy -. -Specifically -LeftmostFirst -adds -dead -states -to -the -DFA -/ -/ -/ -as -a -way -to -terminate -the -search -and -report -a -match -. -LeftmostFirst -/ -/ -/ -also -supports -non -- -greedy -matches -using -this -strategy -where -as -All -/ -/ -/ -does -not -. -/ -/ -/ -/ -/ -/ -# -Example -: -overlapping -search -/ -/ -/ -/ -/ -/ -This -example -shows -the -typical -use -of -MatchKind -: -: -All -which -is -to -/ -/ -/ -report -overlapping -matches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -OverlappingState -dense -} -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -\ -w -+ -" -r -" -\ -S -+ -" -] -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo -" -) -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -1 -4 -) -) -; -/ -/ -/ -dfa -. -try_search_overlapping_fwd -( -& -input -& -mut -state -) -? -; -/ -/ -/ -assert_eq -! -( -expected -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -first -pattern -also -matches -at -the -same -position -so -re -- -running -/ -/ -/ -/ -/ -the -search -will -yield -another -match -. -Notice -also -that -the -first -/ -/ -/ -/ -/ -pattern -is -returned -after -the -second -. -This -is -because -the -second -/ -/ -/ -/ -/ -pattern -begins -its -match -before -the -first -is -therefore -an -earlier -/ -/ -/ -/ -/ -match -and -is -thus -reported -first -. -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -4 -) -) -; -/ -/ -/ -dfa -. -try_search_overlapping_fwd -( -& -input -& -mut -state -) -? -; -/ -/ -/ -assert_eq -! -( -expected -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -reverse -automaton -to -find -start -of -match -/ -/ -/ -/ -/ -/ -Another -example -for -using -MatchKind -: -: -All -is -for -constructing -a -/ -/ -/ -reverse -automaton -to -find -the -start -of -a -match -. -All -semantics -are -/ -/ -/ -used -for -this -in -order -to -find -the -longest -possible -match -which -/ -/ -/ -corresponds -to -the -leftmost -starting -position -. -/ -/ -/ -/ -/ -/ -Note -that -if -you -need -the -starting -position -then -/ -/ -/ -[ -dfa -: -: -regex -: -: -Regex -] -( -crate -: -: -dfa -: -: -regex -: -: -Regex -) -will -handle -this -for -/ -/ -/ -you -so -it -' -s -usually -not -necessary -to -do -this -yourself -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -Automaton -StartKind -} -/ -/ -/ -nfa -: -: -thompson -: -: -NFA -/ -/ -/ -Anchored -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -123foobar456 -" -. -as_bytes -( -) -; -/ -/ -/ -let -pattern -= -r -" -[ -a -- -z -] -+ -r -" -; -/ -/ -/ -/ -/ -/ -let -dfa_fwd -= -dense -: -: -DFA -: -: -new -( -pattern -) -? -; -/ -/ -/ -let -dfa_rev -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -/ -/ -/ -/ -/ -This -isn -' -t -strictly -necessary -since -both -anchored -and -/ -/ -/ -/ -/ -unanchored -searches -are -supported -by -default -. -But -since -/ -/ -/ -/ -/ -finding -the -start -- -of -- -match -only -requires -anchored -searches -/ -/ -/ -/ -/ -we -can -get -rid -of -the -unanchored -configuration -and -possibly -/ -/ -/ -/ -/ -slim -down -our -DFA -considerably -. -/ -/ -/ -. -start_kind -( -StartKind -: -: -Anchored -) -/ -/ -/ -. -match_kind -( -MatchKind -: -: -All -) -/ -/ -/ -) -/ -/ -/ -. -build -( -pattern -) -? -; -/ -/ -/ -let -expected_fwd -= -HalfMatch -: -: -must -( -0 -9 -) -; -/ -/ -/ -let -expected_rev -= -HalfMatch -: -: -must -( -0 -3 -) -; -/ -/ -/ -let -got_fwd -= -dfa_fwd -. -try_search_fwd -( -& -Input -: -: -new -( -haystack -) -) -? -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Here -we -don -' -t -specify -the -pattern -to -search -for -since -there -' -s -only -/ -/ -/ -/ -/ -one -pattern -and -we -' -re -doing -a -leftmost -search -. -But -if -this -were -an -/ -/ -/ -/ -/ -overlapping -search -you -' -d -need -to -specify -the -pattern -that -matched -/ -/ -/ -/ -/ -in -the -forward -direction -. -( -Otherwise -you -might -wind -up -finding -the -/ -/ -/ -/ -/ -starting -position -of -a -match -of -some -other -pattern -. -) -That -in -turn -/ -/ -/ -/ -/ -requires -building -the -reverse -automaton -with -starts_for_each_pattern -/ -/ -/ -/ -/ -enabled -. -Indeed -this -is -what -Regex -does -internally -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -range -( -. -. -got_fwd -. -offset -( -) -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -let -got_rev -= -dfa_rev -. -try_search_rev -( -& -input -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -expected_fwd -got_fwd -) -; -/ -/ -/ -assert_eq -! -( -expected_rev -got_rev -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -match_kind -( -mut -self -kind -: -MatchKind -) -- -> -Config -{ -self -. -match_kind -= -Some -( -kind -) -; -self -} -/ -/ -/ -The -type -of -starting -state -configuration -to -use -for -a -DFA -. -/ -/ -/ -/ -/ -/ -By -default -the -starting -state -configuration -is -[ -StartKind -: -: -Both -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -: -: -DFA -Automaton -StartKind -} -/ -/ -/ -Anchored -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -quux -foo123 -" -; -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -11 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -By -default -DFAs -support -both -anchored -and -unanchored -searches -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -& -input -) -? -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -only -need -anchored -searches -then -we -can -build -a -DFA -/ -/ -/ -/ -/ -that -only -supports -anchored -searches -. -This -leads -to -a -smaller -DFA -/ -/ -/ -/ -/ -( -potentially -significantly -smaller -in -some -cases -) -but -a -DFA -that -/ -/ -/ -/ -/ -will -panic -if -you -try -to -use -it -with -an -unanchored -search -. -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -start_kind -( -StartKind -: -: -Anchored -) -) -/ -/ -/ -. -build -( -r -" -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -range -( -8 -. -. -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -& -input -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -start_kind -( -mut -self -kind -: -StartKind -) -- -> -Config -{ -self -. -start_kind -= -Some -( -kind -) -; -self -} -/ -/ -/ -Whether -to -compile -a -separate -start -state -for -each -pattern -in -the -/ -/ -/ -automaton -. -/ -/ -/ -/ -/ -/ -When -enabled -a -separate -* -* -anchored -* -* -start -state -is -added -for -each -/ -/ -/ -pattern -in -the -DFA -. -When -this -start -state -is -used -then -the -DFA -will -/ -/ -/ -only -search -for -matches -for -the -pattern -specified -even -if -there -are -/ -/ -/ -other -patterns -in -the -DFA -. -/ -/ -/ -/ -/ -/ -The -main -downside -of -this -option -is -that -it -can -potentially -increase -/ -/ -/ -the -size -of -the -DFA -and -/ -or -increase -the -time -it -takes -to -build -the -DFA -. -/ -/ -/ -/ -/ -/ -There -are -a -few -reasons -one -might -want -to -enable -this -( -it -' -s -disabled -/ -/ -/ -by -default -) -: -/ -/ -/ -/ -/ -/ -1 -. -When -looking -for -the -start -of -an -overlapping -match -( -using -a -/ -/ -/ -reverse -DFA -) -doing -it -correctly -requires -starting -the -reverse -search -/ -/ -/ -using -the -starting -state -of -the -pattern -that -matched -in -the -forward -/ -/ -/ -direction -. -Indeed -when -building -a -[ -Regex -] -( -crate -: -: -dfa -: -: -regex -: -: -Regex -) -/ -/ -/ -it -will -automatically -enable -this -option -when -building -the -reverse -DFA -/ -/ -/ -internally -. -/ -/ -/ -2 -. -When -you -want -to -use -a -DFA -with -multiple -patterns -to -both -search -/ -/ -/ -for -matches -of -any -pattern -or -to -search -for -anchored -matches -of -one -/ -/ -/ -particular -pattern -while -using -the -same -DFA -. -( -Otherwise -you -would -need -/ -/ -/ -to -compile -a -new -DFA -for -each -pattern -. -) -/ -/ -/ -3 -. -Since -the -start -states -added -for -each -pattern -are -anchored -if -you -/ -/ -/ -compile -an -unanchored -DFA -with -one -pattern -while -also -enabling -this -/ -/ -/ -option -then -you -can -use -the -same -DFA -to -perform -anchored -or -unanchored -/ -/ -/ -searches -. -The -latter -you -get -with -the -standard -search -APIs -. -The -former -/ -/ -/ -you -get -from -the -various -_at -search -methods -that -allow -you -specify -a -/ -/ -/ -pattern -ID -to -search -for -. -/ -/ -/ -/ -/ -/ -By -default -this -is -disabled -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -this -option -to -permit -the -same -DFA -to -/ -/ -/ -run -both -anchored -and -unanchored -searches -for -a -single -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -Automaton -} -/ -/ -/ -Anchored -HalfMatch -PatternID -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -starts_for_each_pattern -( -true -) -) -/ -/ -/ -. -build -( -r -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -haystack -= -" -quux -foo123 -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Here -' -s -a -normal -unanchored -search -. -Notice -that -we -use -' -None -' -for -the -/ -/ -/ -/ -/ -pattern -ID -. -Since -the -DFA -was -built -as -an -unanchored -machine -it -/ -/ -/ -/ -/ -use -its -default -unanchored -starting -state -. -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -11 -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -& -input -) -? -) -; -/ -/ -/ -/ -/ -But -now -if -we -explicitly -specify -the -pattern -to -search -( -' -0 -' -being -/ -/ -/ -/ -/ -the -only -pattern -in -the -DFA -) -then -it -will -use -the -starting -state -/ -/ -/ -/ -/ -for -that -specific -pattern -which -is -always -anchored -. -Since -the -/ -/ -/ -/ -/ -pattern -doesn -' -t -have -a -match -at -the -beginning -of -the -haystack -we -/ -/ -/ -/ -/ -find -nothing -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -0 -) -) -) -; -/ -/ -/ -assert_eq -! -( -None -dfa -. -try_search_fwd -( -& -input -) -? -) -; -/ -/ -/ -/ -/ -And -finally -an -anchored -search -is -not -the -same -as -putting -a -' -^ -' -at -/ -/ -/ -/ -/ -beginning -of -the -pattern -. -An -anchored -search -can -only -match -at -the -/ -/ -/ -/ -/ -beginning -of -the -* -search -* -which -we -can -change -: -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -0 -) -) -) -/ -/ -/ -. -range -( -5 -. -. -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -& -input -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -starts_for_each_pattern -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -starts_for_each_pattern -= -Some -( -yes -) -; -self -} -/ -/ -/ -Whether -to -attempt -to -shrink -the -size -of -the -DFA -' -s -alphabet -or -not -. -/ -/ -/ -/ -/ -/ -This -option -is -enabled -by -default -and -should -never -be -disabled -unless -/ -/ -/ -one -is -debugging -a -generated -DFA -. -/ -/ -/ -/ -/ -/ -When -enabled -the -DFA -will -use -a -map -from -all -possible -bytes -to -their -/ -/ -/ -corresponding -equivalence -class -. -Each -equivalence -class -represents -a -/ -/ -/ -set -of -bytes -that -does -not -discriminate -between -a -match -and -a -non -- -match -/ -/ -/ -in -the -DFA -. -For -example -the -pattern -[ -ab -] -+ -has -at -least -two -/ -/ -/ -equivalence -classes -: -a -set -containing -a -and -b -and -a -set -containing -/ -/ -/ -every -byte -except -for -a -and -b -. -a -and -b -are -in -the -same -/ -/ -/ -equivalence -class -because -they -never -discriminate -between -a -match -and -a -/ -/ -/ -non -- -match -. -/ -/ -/ -/ -/ -/ -The -advantage -of -this -map -is -that -the -size -of -the -transition -table -/ -/ -/ -can -be -reduced -drastically -from -# -states -* -256 -* -sizeof -( -StateID -) -to -/ -/ -/ -# -states -* -k -* -sizeof -( -StateID -) -where -k -is -the -number -of -equivalence -/ -/ -/ -classes -( -rounded -up -to -the -nearest -power -of -2 -) -. -As -a -result -total -/ -/ -/ -space -usage -can -decrease -substantially -. -Moreover -since -a -smaller -/ -/ -/ -alphabet -is -used -DFA -compilation -becomes -faster -as -well -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -This -is -only -useful -for -debugging -DFAs -. -Disabling -this -/ -/ -/ -does -not -yield -any -speed -advantages -. -Namely -even -when -this -is -/ -/ -/ -disabled -a -byte -class -map -is -still -used -while -searching -. -The -only -/ -/ -/ -difference -is -that -every -byte -will -be -forced -into -its -own -distinct -/ -/ -/ -equivalence -class -. -This -is -useful -for -debugging -the -actual -generated -/ -/ -/ -transitions -because -it -lets -one -see -the -transitions -defined -on -actual -/ -/ -/ -bytes -instead -of -the -equivalence -classes -. -pub -fn -byte_classes -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -byte_classes -= -Some -( -yes -) -; -self -} -/ -/ -/ -Heuristically -enable -Unicode -word -boundaries -. -/ -/ -/ -/ -/ -/ -When -set -this -will -attempt -to -implement -Unicode -word -boundaries -as -if -/ -/ -/ -they -were -ASCII -word -boundaries -. -This -only -works -when -the -search -input -/ -/ -/ -is -ASCII -only -. -If -a -non -- -ASCII -byte -is -observed -while -searching -then -a -/ -/ -/ -[ -MatchError -: -: -quit -] -( -crate -: -: -MatchError -: -: -quit -) -error -is -returned -. -/ -/ -/ -/ -/ -/ -A -possible -alternative -to -enabling -this -option -is -to -simply -use -an -/ -/ -/ -ASCII -word -boundary -e -. -g -. -via -( -? -- -u -: -\ -b -) -. -The -main -reason -to -use -this -/ -/ -/ -option -is -if -you -absolutely -need -Unicode -support -. -This -option -lets -one -/ -/ -/ -use -a -fast -search -implementation -( -a -DFA -) -for -some -potentially -very -/ -/ -/ -common -cases -while -providing -the -option -to -fall -back -to -some -other -/ -/ -/ -regex -engine -to -handle -the -general -case -when -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -If -the -pattern -provided -has -no -Unicode -word -boundary -in -it -then -this -/ -/ -/ -option -has -no -effect -. -( -That -is -quitting -on -a -non -- -ASCII -byte -only -/ -/ -/ -occurs -when -this -option -is -enabled -_and_ -a -Unicode -word -boundary -is -/ -/ -/ -present -in -the -pattern -. -) -/ -/ -/ -/ -/ -/ -This -is -almost -equivalent -to -setting -all -non -- -ASCII -bytes -to -be -quit -/ -/ -/ -bytes -. -The -only -difference -is -that -this -will -cause -non -- -ASCII -bytes -to -/ -/ -/ -be -quit -bytes -_only_ -when -a -Unicode -word -boundary -is -present -in -the -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -When -enabling -this -option -callers -_must_ -be -prepared -to -handle -/ -/ -/ -a -[ -MatchError -] -( -crate -: -: -MatchError -) -error -during -search -. -/ -/ -/ -When -using -a -[ -Regex -] -( -crate -: -: -dfa -: -: -regex -: -: -Regex -) -this -corresponds -/ -/ -/ -to -using -the -try_ -suite -of -methods -. -Alternatively -if -/ -/ -/ -callers -can -guarantee -that -their -input -is -ASCII -only -then -a -/ -/ -/ -[ -MatchError -: -: -quit -] -( -crate -: -: -MatchError -: -: -quit -) -error -will -never -be -/ -/ -/ -returned -while -searching -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -heuristically -enable -Unicode -word -boundaries -/ -/ -/ -in -a -pattern -. -It -also -shows -what -happens -when -a -search -comes -across -a -/ -/ -/ -non -- -ASCII -byte -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -} -/ -/ -/ -HalfMatch -Input -MatchError -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -unicode_word_boundary -( -true -) -) -/ -/ -/ -. -build -( -r -" -\ -b -[ -0 -- -9 -] -+ -\ -b -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -The -match -occurs -before -the -search -ever -observes -the -snowman -/ -/ -/ -/ -/ -character -so -no -error -occurs -. -/ -/ -/ -let -haystack -= -" -foo -123 -" -. -as_bytes -( -) -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -7 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -this -search -fails -even -though -the -snowman -character -/ -/ -/ -/ -/ -occurs -after -the -ending -match -offset -. -This -is -because -search -/ -/ -/ -/ -/ -routines -read -one -byte -past -the -end -of -the -search -to -account -for -/ -/ -/ -/ -/ -look -- -around -and -indeed -this -is -required -here -to -determine -whether -/ -/ -/ -/ -/ -the -trailing -\ -b -matches -. -/ -/ -/ -let -haystack -= -" -foo -123 -" -. -as_bytes -( -) -; -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -0xE2 -8 -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -haystack -) -) -; -/ -/ -/ -assert_eq -! -( -Err -( -expected -) -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Another -example -is -executing -a -search -where -the -span -of -the -haystack -/ -/ -/ -/ -/ -we -specify -is -all -ASCII -but -there -is -non -- -ASCII -just -before -it -. -This -/ -/ -/ -/ -/ -correctly -also -reports -an -error -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -2 -. -. -) -; -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -0xB2 -1 -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -input -) -; -/ -/ -/ -assert_eq -! -( -Err -( -expected -) -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -similarly -for -the -trailing -word -boundary -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -. -. -3 -) -; -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -0xCE -3 -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -input -) -; -/ -/ -/ -assert_eq -! -( -Err -( -expected -) -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -unicode_word_boundary -( -mut -self -yes -: -bool -) -- -> -Config -{ -/ -/ -We -have -a -separate -option -for -this -instead -of -just -setting -the -/ -/ -appropriate -quit -bytes -here -because -we -don -' -t -want -to -set -quit -bytes -/ -/ -for -every -regex -. -We -only -want -to -set -them -when -the -regex -contains -a -/ -/ -Unicode -word -boundary -. -self -. -unicode_word_boundary -= -Some -( -yes -) -; -self -} -/ -/ -/ -Add -a -" -quit -" -byte -to -the -DFA -. -/ -/ -/ -/ -/ -/ -When -a -quit -byte -is -seen -during -search -time -then -search -will -return -/ -/ -/ -a -[ -MatchError -: -: -quit -] -( -crate -: -: -MatchError -: -: -quit -) -error -indicating -the -/ -/ -/ -offset -at -which -the -search -stopped -. -/ -/ -/ -/ -/ -/ -A -quit -byte -will -always -overrule -any -other -aspects -of -a -regex -. -For -/ -/ -/ -example -if -the -x -byte -is -added -as -a -quit -byte -and -the -regex -\ -w -is -/ -/ -/ -used -then -observing -x -will -cause -the -search -to -quit -immediately -/ -/ -/ -despite -the -fact -that -x -is -in -the -\ -w -class -. -/ -/ -/ -/ -/ -/ -This -mechanism -is -primarily -useful -for -heuristically -enabling -certain -/ -/ -/ -features -like -Unicode -word -boundaries -in -a -DFA -. -Namely -if -the -input -/ -/ -/ -to -search -is -ASCII -then -a -Unicode -word -boundary -can -be -implemented -/ -/ -/ -via -an -ASCII -word -boundary -with -no -change -in -semantics -. -Thus -a -DFA -/ -/ -/ -can -attempt -to -match -a -Unicode -word -boundary -but -give -up -as -soon -as -it -/ -/ -/ -observes -a -non -- -ASCII -byte -. -Indeed -if -callers -set -all -non -- -ASCII -bytes -/ -/ -/ -to -be -quit -bytes -then -Unicode -word -boundaries -will -be -permitted -when -/ -/ -/ -building -DFAs -. -Of -course -callers -should -enable -/ -/ -/ -[ -Config -: -: -unicode_word_boundary -] -if -they -want -this -behavior -instead -. -/ -/ -/ -( -The -advantage -being -that -non -- -ASCII -quit -bytes -will -only -be -added -if -a -/ -/ -/ -Unicode -word -boundary -is -in -the -pattern -. -) -/ -/ -/ -/ -/ -/ -When -enabling -this -option -callers -_must_ -be -prepared -to -handle -a -/ -/ -/ -[ -MatchError -] -( -crate -: -: -MatchError -) -error -during -search -. -When -using -a -/ -/ -/ -[ -Regex -] -( -crate -: -: -dfa -: -: -regex -: -: -Regex -) -this -corresponds -to -using -the -/ -/ -/ -try_ -suite -of -methods -. -/ -/ -/ -/ -/ -/ -By -default -there -are -no -quit -bytes -set -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -heuristic -Unicode -word -boundaries -are -enabled -and -any -/ -/ -/ -non -- -ASCII -byte -is -removed -from -the -set -of -quit -bytes -. -Namely -enabling -/ -/ -/ -Unicode -word -boundaries -requires -setting -every -non -- -ASCII -byte -to -a -quit -/ -/ -/ -byte -. -So -if -the -caller -attempts -to -undo -any -of -that -then -this -will -/ -/ -/ -panic -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -cause -a -search -to -terminate -if -it -sees -a -/ -/ -/ -\ -n -byte -. -This -could -be -useful -if -for -example -you -wanted -to -prevent -/ -/ -/ -a -user -supplied -pattern -from -matching -across -a -line -boundary -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -Input -MatchError -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -quit -( -b -' -\ -n -' -true -) -) -/ -/ -/ -. -build -( -r -" -foo -\ -p -{ -any -} -+ -bar -" -) -? -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -foo -\ -nbar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -Normally -this -would -produce -a -match -since -\ -p -{ -any -} -contains -' -\ -n -' -. -/ -/ -/ -/ -/ -But -since -we -instructed -the -automaton -to -enter -a -quit -state -if -a -/ -/ -/ -/ -/ -' -\ -n -' -is -observed -this -produces -a -match -error -instead -. -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -b -' -\ -n -' -3 -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -haystack -) -) -. -unwrap_err -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -quit -( -mut -self -byte -: -u8 -yes -: -bool -) -- -> -Config -{ -if -self -. -get_unicode_word_boundary -( -) -& -& -! -byte -. -is_ascii -( -) -& -& -! -yes -{ -panic -! -( -" -cannot -set -non -- -ASCII -byte -to -be -non -- -quit -when -\ -Unicode -word -boundaries -are -enabled -" -) -; -} -if -self -. -quitset -. -is_none -( -) -{ -self -. -quitset -= -Some -( -ByteSet -: -: -empty -( -) -) -; -} -if -yes -{ -self -. -quitset -. -as_mut -( -) -. -unwrap -( -) -. -add -( -byte -) -; -} -else -{ -self -. -quitset -. -as_mut -( -) -. -unwrap -( -) -. -remove -( -byte -) -; -} -self -} -/ -/ -/ -Enable -specializing -start -states -in -the -DFA -. -/ -/ -/ -/ -/ -/ -When -start -states -are -specialized -an -implementor -of -a -search -routine -/ -/ -/ -using -a -lazy -DFA -can -tell -when -the -search -has -entered -a -starting -state -. -/ -/ -/ -When -start -states -aren -' -t -specialized -then -it -is -impossible -to -know -/ -/ -/ -whether -the -search -has -entered -a -start -state -. -/ -/ -/ -/ -/ -/ -Ideally -this -option -wouldn -' -t -need -to -exist -and -we -could -always -/ -/ -/ -specialize -start -states -. -The -problem -is -that -start -states -can -be -quite -/ -/ -/ -active -. -This -in -turn -means -that -an -efficient -search -routine -is -likely -/ -/ -/ -to -ping -- -pong -between -a -heavily -optimized -hot -loop -that -handles -most -/ -/ -/ -states -and -to -a -less -optimized -specialized -handling -of -start -states -. -/ -/ -/ -This -causes -branches -to -get -heavily -mispredicted -and -overall -can -/ -/ -/ -materially -decrease -throughput -. -Therefore -specializing -start -states -/ -/ -/ -should -only -be -enabled -when -it -is -needed -. -/ -/ -/ -/ -/ -/ -Knowing -whether -a -search -is -in -a -start -state -is -typically -useful -when -a -/ -/ -/ -prefilter -is -active -for -the -search -. -A -prefilter -is -typically -only -run -/ -/ -/ -when -in -a -start -state -and -a -prefilter -can -greatly -accelerate -a -search -. -/ -/ -/ -Therefore -the -possible -cost -of -specializing -start -states -is -worth -it -/ -/ -/ -in -this -case -. -Otherwise -if -you -have -no -prefilter -there -is -likely -no -/ -/ -/ -reason -to -specialize -start -states -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -but -note -that -it -is -automatically -/ -/ -/ -enabled -( -or -disabled -) -if -[ -Config -: -: -prefilter -] -is -set -. -Namely -unless -/ -/ -/ -specialize_start_states -has -already -been -set -[ -Config -: -: -prefilter -] -/ -/ -/ -will -automatically -enable -or -disable -it -based -on -whether -a -prefilter -/ -/ -/ -is -present -or -not -respectively -. -This -is -done -because -a -prefilter -' -s -/ -/ -/ -effectiveness -is -rooted -in -being -executed -whenever -the -DFA -is -in -a -/ -/ -/ -start -state -and -that -' -s -only -possible -to -do -when -they -are -specialized -. -/ -/ -/ -/ -/ -/ -Note -that -it -is -plausibly -reasonable -to -_disable_ -this -option -/ -/ -/ -explicitly -while -_enabling_ -a -prefilter -. -In -that -case -a -prefilter -/ -/ -/ -will -still -be -run -at -the -beginning -of -a -search -but -never -again -. -This -/ -/ -/ -in -theory -could -strike -a -good -balance -if -you -' -re -in -a -situation -where -a -/ -/ -/ -prefilter -is -likely -to -produce -many -false -positive -candidates -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -enable -start -state -specialization -and -then -/ -/ -/ -shows -how -to -check -whether -a -state -is -a -start -state -or -not -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -specialize_start_states -( -true -) -) -/ -/ -/ -. -build -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -sid -= -dfa -. -start_state_forward -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -/ -/ -The -ID -returned -by -' -start_state_forward -' -will -always -be -tagged -as -/ -/ -/ -/ -/ -a -start -state -when -start -state -specialization -is -enabled -. -/ -/ -/ -assert -! -( -dfa -. -is_special_state -( -sid -) -) -; -/ -/ -/ -assert -! -( -dfa -. -is_start_state -( -sid -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Compare -the -above -with -the -default -DFA -configuration -where -start -states -/ -/ -/ -are -_not_ -specialized -. -In -this -case -the -start -state -is -not -tagged -at -/ -/ -/ -all -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -; -/ -/ -/ -let -sid -= -dfa -. -start_state_forward -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -/ -/ -Start -states -are -not -special -in -the -default -configuration -! -/ -/ -/ -assert -! -( -! -dfa -. -is_special_state -( -sid -) -) -; -/ -/ -/ -assert -! -( -! -dfa -. -is_start_state -( -sid -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -specialize_start_states -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -specialize_start_states -= -Some -( -yes -) -; -self -} -/ -/ -/ -Set -a -size -limit -on -the -total -heap -used -by -a -DFA -. -/ -/ -/ -/ -/ -/ -This -size -limit -is -expressed -in -bytes -and -is -applied -during -/ -/ -/ -determinization -of -an -NFA -into -a -DFA -. -If -the -DFA -' -s -heap -usage -and -only -/ -/ -/ -the -DFA -exceeds -this -configured -limit -then -determinization -is -stopped -/ -/ -/ -and -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -This -limit -does -not -apply -to -auxiliary -storage -used -during -/ -/ -/ -determinization -that -isn -' -t -part -of -the -generated -DFA -. -/ -/ -/ -/ -/ -/ -This -limit -is -only -applied -during -determinization -. -Currently -there -is -/ -/ -/ -no -way -to -post -- -pone -this -check -to -after -minimization -if -minimization -/ -/ -/ -was -enabled -. -/ -/ -/ -/ -/ -/ -The -total -limit -on -heap -used -during -determinization -is -the -sum -of -the -/ -/ -/ -DFA -and -determinization -size -limits -. -/ -/ -/ -/ -/ -/ -The -default -is -no -limit -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -DFA -that -fails -to -build -because -of -a -configured -/ -/ -/ -size -limit -. -This -particular -example -also -serves -as -a -cautionary -tale -/ -/ -/ -demonstrating -just -how -big -DFAs -with -large -Unicode -character -classes -/ -/ -/ -can -get -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -dense -Automaton -} -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -6MB -isn -' -t -enough -! -/ -/ -/ -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -dfa_size_limit -( -Some -( -6_000_000 -) -) -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -/ -/ -/ -. -unwrap_err -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -. -. -. -but -7MB -probably -is -! -/ -/ -/ -/ -/ -( -Note -that -DFA -sizes -aren -' -t -necessarily -stable -between -releases -. -) -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -dfa_size_limit -( -Some -( -7_000_000 -) -) -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -? -; -/ -/ -/ -let -haystack -= -" -A -" -. -repeat -( -20 -) -. -into_bytes -( -) -; -/ -/ -/ -assert -! -( -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -& -haystack -) -) -? -. -is_some -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -While -one -needs -a -little -more -than -6MB -to -represent -\ -w -{ -20 -} -it -/ -/ -/ -turns -out -that -you -only -need -a -little -more -than -6KB -to -represent -/ -/ -/ -( -? -- -u -: -\ -w -{ -20 -} -) -. -So -only -use -Unicode -if -you -need -it -! -/ -/ -/ -/ -/ -/ -As -with -[ -Config -: -: -determinize_size_limit -] -the -size -of -a -DFA -is -/ -/ -/ -influenced -by -other -factors -such -as -what -start -state -configurations -/ -/ -/ -to -support -. -For -example -if -you -only -need -unanchored -searches -and -not -/ -/ -/ -anchored -searches -then -configuring -the -DFA -to -only -support -unanchored -/ -/ -/ -searches -can -reduce -its -size -. -By -default -DFAs -support -both -unanchored -/ -/ -/ -and -anchored -searches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -dense -Automaton -StartKind -} -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -3MB -isn -' -t -enough -! -/ -/ -/ -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -/ -/ -/ -. -dfa_size_limit -( -Some -( -3_000_000 -) -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Unanchored -) -/ -/ -/ -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -/ -/ -/ -. -unwrap_err -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -. -. -. -but -4MB -probably -is -! -/ -/ -/ -/ -/ -( -Note -that -DFA -sizes -aren -' -t -necessarily -stable -between -releases -. -) -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -/ -/ -/ -. -dfa_size_limit -( -Some -( -4_000_000 -) -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Unanchored -) -/ -/ -/ -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -? -; -/ -/ -/ -let -haystack -= -" -A -" -. -repeat -( -20 -) -. -into_bytes -( -) -; -/ -/ -/ -assert -! -( -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -& -haystack -) -) -? -. -is_some -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -dfa_size_limit -( -mut -self -bytes -: -Option -< -usize -> -) -- -> -Config -{ -self -. -dfa_size_limit -= -Some -( -bytes -) -; -self -} -/ -/ -/ -Set -a -size -limit -on -the -total -heap -used -by -determinization -. -/ -/ -/ -/ -/ -/ -This -size -limit -is -expressed -in -bytes -and -is -applied -during -/ -/ -/ -determinization -of -an -NFA -into -a -DFA -. -If -the -heap -used -for -auxiliary -/ -/ -/ -storage -during -determinization -( -memory -that -is -not -in -the -DFA -but -/ -/ -/ -necessary -for -building -the -DFA -) -exceeds -this -configured -limit -then -/ -/ -/ -determinization -is -stopped -and -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -This -limit -does -not -apply -to -heap -used -by -the -DFA -itself -. -/ -/ -/ -/ -/ -/ -The -total -limit -on -heap -used -during -determinization -is -the -sum -of -the -/ -/ -/ -DFA -and -determinization -size -limits -. -/ -/ -/ -/ -/ -/ -The -default -is -no -limit -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -DFA -that -fails -to -build -because -of -a -/ -/ -/ -configured -size -limit -on -the -amount -of -heap -space -used -by -/ -/ -/ -determinization -. -This -particular -example -complements -the -example -for -/ -/ -/ -[ -Config -: -: -dfa_size_limit -] -by -demonstrating -that -not -only -does -Unicode -/ -/ -/ -potentially -make -DFAs -themselves -big -but -it -also -results -in -more -/ -/ -/ -auxiliary -storage -during -determinization -. -( -Although -auxiliary -storage -/ -/ -/ -is -still -not -as -much -as -the -DFA -itself -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -# -if -! -cfg -! -( -target_pointer_width -= -" -64 -" -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -see -# -1039 -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -dense -Automaton -} -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -600KB -isn -' -t -enough -! -/ -/ -/ -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -/ -/ -/ -. -determinize_size_limit -( -Some -( -600_000 -) -) -/ -/ -/ -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -/ -/ -/ -. -unwrap_err -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -. -. -. -but -700KB -probably -is -! -/ -/ -/ -/ -/ -( -Note -that -auxiliary -storage -sizes -aren -' -t -necessarily -stable -between -/ -/ -/ -/ -/ -releases -. -) -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -/ -/ -/ -. -determinize_size_limit -( -Some -( -700_000 -) -) -/ -/ -/ -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -? -; -/ -/ -/ -let -haystack -= -" -A -" -. -repeat -( -20 -) -. -into_bytes -( -) -; -/ -/ -/ -assert -! -( -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -& -haystack -) -) -? -. -is_some -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -some -parts -of -the -configuration -on -a -DFA -can -have -a -/ -/ -/ -big -impact -on -how -big -the -DFA -is -and -thus -how -much -memory -is -/ -/ -/ -used -. -For -example -the -default -setting -for -[ -Config -: -: -start_kind -] -is -/ -/ -/ -[ -StartKind -: -: -Both -] -. -But -if -you -only -need -an -anchored -search -for -/ -/ -/ -example -then -it -can -be -much -cheaper -to -build -a -DFA -that -only -supports -/ -/ -/ -anchored -searches -. -( -Running -an -unanchored -search -with -it -would -panic -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -# -if -! -cfg -! -( -target_pointer_width -= -" -64 -" -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -see -# -1039 -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -dense -Automaton -StartKind -} -/ -/ -/ -Anchored -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -200KB -isn -' -t -enough -! -/ -/ -/ -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -/ -/ -/ -. -determinize_size_limit -( -Some -( -200_000 -) -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Anchored -) -/ -/ -/ -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -/ -/ -/ -. -unwrap_err -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -. -. -. -but -300KB -probably -is -! -/ -/ -/ -/ -/ -( -Note -that -auxiliary -storage -sizes -aren -' -t -necessarily -stable -between -/ -/ -/ -/ -/ -releases -. -) -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -/ -/ -/ -. -determinize_size_limit -( -Some -( -300_000 -) -) -/ -/ -/ -. -start_kind -( -StartKind -: -: -Anchored -) -/ -/ -/ -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -? -; -/ -/ -/ -let -haystack -= -" -A -" -. -repeat -( -20 -) -. -into_bytes -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -& -haystack -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert -! -( -dfa -. -try_search_fwd -( -& -input -) -? -. -is_some -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -determinize_size_limit -( -mut -self -bytes -: -Option -< -usize -> -) -- -> -Config -{ -self -. -determinize_size_limit -= -Some -( -bytes -) -; -self -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -simple -state -/ -/ -/ -acceleration -. -pub -fn -get_accelerate -( -& -self -) -- -> -bool -{ -self -. -accelerate -. -unwrap_or -( -true -) -} -/ -/ -/ -Returns -the -prefilter -attached -to -this -configuration -if -any -. -pub -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -self -. -pre -. -as_ref -( -) -. -unwrap_or -( -& -None -) -. -as_ref -( -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -the -expensive -process -/ -/ -/ -of -minimizing -a -DFA -. -pub -fn -get_minimize -( -& -self -) -- -> -bool -{ -self -. -minimize -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -the -match -semantics -set -in -this -configuration -. -pub -fn -get_match_kind -( -& -self -) -- -> -MatchKind -{ -self -. -match_kind -. -unwrap_or -( -MatchKind -: -: -LeftmostFirst -) -} -/ -/ -/ -Returns -the -starting -state -configuration -for -a -DFA -. -pub -fn -get_starts -( -& -self -) -- -> -StartKind -{ -self -. -start_kind -. -unwrap_or -( -StartKind -: -: -Both -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -anchored -starting -states -/ -/ -/ -for -every -pattern -in -the -DFA -. -pub -fn -get_starts_for_each_pattern -( -& -self -) -- -> -bool -{ -self -. -starts_for_each_pattern -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -byte -classes -or -not -. -/ -/ -/ -This -is -typically -a -debugging -oriented -option -as -disabling -it -confers -/ -/ -/ -no -speed -benefit -. -pub -fn -get_byte_classes -( -& -self -) -- -> -bool -{ -self -. -byte_classes -. -unwrap_or -( -true -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -heuristic -Unicode -word -/ -/ -/ -boundary -support -. -When -enabled -it -is -possible -for -a -search -to -return -/ -/ -/ -an -error -. -pub -fn -get_unicode_word_boundary -( -& -self -) -- -> -bool -{ -self -. -unicode_word_boundary -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -whether -this -configuration -will -instruct -the -DFA -to -enter -a -/ -/ -/ -quit -state -whenever -the -given -byte -is -seen -during -a -search -. -When -at -/ -/ -/ -least -one -byte -has -this -enabled -it -is -possible -for -a -search -to -return -/ -/ -/ -an -error -. -pub -fn -get_quit -( -& -self -byte -: -u8 -) -- -> -bool -{ -self -. -quitset -. -map_or -( -false -| -q -| -q -. -contains -( -byte -) -) -} -/ -/ -/ -Returns -whether -this -configuration -will -instruct -the -DFA -to -/ -/ -/ -" -specialize -" -start -states -. -When -enabled -the -DFA -will -mark -start -states -/ -/ -/ -as -" -special -" -so -that -search -routines -using -the -DFA -can -detect -when -/ -/ -/ -it -' -s -in -a -start -state -and -do -some -kind -of -optimization -( -like -run -a -/ -/ -/ -prefilter -) -. -pub -fn -get_specialize_start_states -( -& -self -) -- -> -bool -{ -self -. -specialize_start_states -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -the -DFA -size -limit -of -this -configuration -if -one -was -set -. -/ -/ -/ -The -size -limit -is -total -number -of -bytes -on -the -heap -that -a -DFA -is -/ -/ -/ -permitted -to -use -. -If -the -DFA -exceeds -this -limit -during -construction -/ -/ -/ -then -construction -is -stopped -and -an -error -is -returned -. -pub -fn -get_dfa_size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -dfa_size_limit -. -unwrap_or -( -None -) -} -/ -/ -/ -Returns -the -determinization -size -limit -of -this -configuration -if -one -/ -/ -/ -was -set -. -The -size -limit -is -total -number -of -bytes -on -the -heap -that -/ -/ -/ -determinization -is -permitted -to -use -. -If -determinization -exceeds -this -/ -/ -/ -limit -during -construction -then -construction -is -stopped -and -an -error -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -This -is -different -from -the -DFA -size -limit -in -that -this -only -applies -to -/ -/ -/ -the -auxiliary -storage -used -during -determinization -. -Once -determinization -/ -/ -/ -is -complete -this -memory -is -freed -. -/ -/ -/ -/ -/ -/ -The -limit -on -the -total -heap -memory -used -is -the -sum -of -the -DFA -and -/ -/ -/ -determinization -size -limits -. -pub -fn -get_determinize_size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -determinize_size_limit -. -unwrap_or -( -None -) -} -/ -/ -/ -Overwrite -the -default -configuration -such -that -the -options -in -o -are -/ -/ -/ -always -used -. -If -an -option -in -o -is -not -set -then -the -corresponding -/ -/ -/ -option -in -self -is -used -. -If -it -' -s -not -set -in -self -either -then -it -/ -/ -/ -remains -not -set -. -pub -( -crate -) -fn -overwrite -( -& -self -o -: -Config -) -- -> -Config -{ -Config -{ -accelerate -: -o -. -accelerate -. -or -( -self -. -accelerate -) -pre -: -o -. -pre -. -or_else -( -| -| -self -. -pre -. -clone -( -) -) -minimize -: -o -. -minimize -. -or -( -self -. -minimize -) -match_kind -: -o -. -match_kind -. -or -( -self -. -match_kind -) -start_kind -: -o -. -start_kind -. -or -( -self -. -start_kind -) -starts_for_each_pattern -: -o -. -starts_for_each_pattern -. -or -( -self -. -starts_for_each_pattern -) -byte_classes -: -o -. -byte_classes -. -or -( -self -. -byte_classes -) -unicode_word_boundary -: -o -. -unicode_word_boundary -. -or -( -self -. -unicode_word_boundary -) -quitset -: -o -. -quitset -. -or -( -self -. -quitset -) -specialize_start_states -: -o -. -specialize_start_states -. -or -( -self -. -specialize_start_states -) -dfa_size_limit -: -o -. -dfa_size_limit -. -or -( -self -. -dfa_size_limit -) -determinize_size_limit -: -o -. -determinize_size_limit -. -or -( -self -. -determinize_size_limit -) -} -} -} -/ -/ -/ -A -builder -for -constructing -a -deterministic -finite -automaton -from -regular -/ -/ -/ -expressions -. -/ -/ -/ -/ -/ -/ -This -builder -provides -two -main -things -: -/ -/ -/ -/ -/ -/ -1 -. -It -provides -a -few -different -build -routines -for -actually -constructing -/ -/ -/ -a -DFA -from -different -kinds -of -inputs -. -The -most -convenient -is -/ -/ -/ -[ -Builder -: -: -build -] -which -builds -a -DFA -directly -from -a -pattern -string -. -The -/ -/ -/ -most -flexible -is -[ -Builder -: -: -build_from_nfa -] -which -builds -a -DFA -straight -/ -/ -/ -from -an -NFA -. -/ -/ -/ -2 -. -The -builder -permits -configuring -a -number -of -things -. -/ -/ -/ -[ -Builder -: -: -configure -] -is -used -with -[ -Config -] -to -configure -aspects -of -/ -/ -/ -the -DFA -and -the -construction -process -itself -. -[ -Builder -: -: -syntax -] -and -/ -/ -/ -[ -Builder -: -: -thompson -] -permit -configuring -the -regex -parser -and -Thompson -NFA -/ -/ -/ -construction -respectively -. -The -syntax -and -thompson -configurations -only -/ -/ -/ -apply -when -building -from -a -pattern -string -. -/ -/ -/ -/ -/ -/ -This -builder -always -constructs -a -* -single -* -DFA -. -As -such -this -builder -/ -/ -/ -can -only -be -used -to -construct -regexes -that -either -detect -the -presence -/ -/ -/ -of -a -match -or -find -the -end -location -of -a -match -. -A -single -DFA -cannot -/ -/ -/ -produce -both -the -start -and -end -of -a -match -. -For -that -information -use -a -/ -/ -/ -[ -Regex -] -( -crate -: -: -dfa -: -: -regex -: -: -Regex -) -which -can -be -similarly -configured -/ -/ -/ -using -[ -regex -: -: -Builder -] -( -crate -: -: -dfa -: -: -regex -: -: -Builder -) -. -The -main -reason -to -/ -/ -/ -use -a -DFA -directly -is -if -the -end -location -of -a -match -is -enough -for -your -use -/ -/ -/ -case -. -Namely -a -Regex -will -construct -two -DFAs -instead -of -one -since -a -/ -/ -/ -second -reverse -DFA -is -needed -to -find -the -start -of -a -match -. -/ -/ -/ -/ -/ -/ -Note -that -if -one -wants -to -build -a -sparse -DFA -you -must -first -build -a -dense -/ -/ -/ -DFA -and -convert -that -to -a -sparse -DFA -. -There -is -no -way -to -build -a -sparse -/ -/ -/ -DFA -without -first -building -a -dense -DFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -minimized -DFA -that -completely -disables -/ -/ -/ -Unicode -. -That -is -: -/ -/ -/ -/ -/ -/ -* -Things -such -as -\ -w -. -and -\ -b -are -no -longer -Unicode -- -aware -. -\ -w -/ -/ -/ -and -\ -b -are -ASCII -- -only -while -. -matches -any -byte -except -for -\ -n -/ -/ -/ -( -instead -of -any -UTF -- -8 -encoding -of -a -Unicode -scalar -value -except -for -/ -/ -/ -\ -n -) -. -Things -that -are -Unicode -only -such -as -\ -pL -are -not -allowed -. -/ -/ -/ -* -The -pattern -itself -is -permitted -to -match -invalid -UTF -- -8 -. -For -example -/ -/ -/ -things -like -[ -^ -a -] -that -match -any -byte -except -for -a -are -permitted -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -} -/ -/ -/ -util -: -: -syntax -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -minimize -( -false -) -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -unicode -( -false -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -[ -^ -b -] -ar -. -* -" -) -? -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFar -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -10 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Builder -{ -config -: -Config -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -Builder -{ -/ -/ -/ -Create -a -new -dense -DFA -builder -with -the -default -configuration -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -{ -config -: -Config -: -: -default -( -) -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -: -: -new -( -) -} -} -/ -/ -/ -Build -a -DFA -from -the -given -pattern -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -or -compiling -the -pattern -then -an -error -/ -/ -/ -is -returned -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -OwnedDFA -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Build -a -DFA -from -the -given -patterns -. -/ -/ -/ -/ -/ -/ -When -matches -are -returned -the -pattern -ID -corresponds -to -the -index -of -/ -/ -/ -the -pattern -in -the -slice -given -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -OwnedDFA -BuildError -> -{ -let -nfa -= -self -. -thompson -. -clone -( -) -/ -/ -We -can -always -forcefully -disable -captures -because -DFAs -do -not -/ -/ -support -them -. -. -configure -( -thompson -: -: -Config -: -: -new -( -) -. -which_captures -( -thompson -: -: -WhichCaptures -: -: -None -) -) -. -build_many -( -patterns -) -. -map_err -( -BuildError -: -: -nfa -) -? -; -self -. -build_from_nfa -( -& -nfa -) -} -/ -/ -/ -Build -a -DFA -from -the -given -NFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -DFA -if -you -already -have -an -NFA -in -/ -/ -/ -hand -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -} -/ -/ -/ -nfa -: -: -thompson -: -: -NFA -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -foo123bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -This -shows -how -to -set -non -- -default -options -for -building -an -NFA -. -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -shrink -( -true -) -) -/ -/ -/ -. -build -( -r -" -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -. -build_from_nfa -( -& -nfa -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -6 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_from_nfa -( -& -self -nfa -: -& -thompson -: -: -NFA -) -- -> -Result -< -OwnedDFA -BuildError -> -{ -let -mut -quitset -= -self -. -config -. -quitset -. -unwrap_or -( -ByteSet -: -: -empty -( -) -) -; -if -self -. -config -. -get_unicode_word_boundary -( -) -& -& -nfa -. -look_set_any -( -) -. -contains_word_unicode -( -) -{ -for -b -in -0x80 -. -. -= -0xFF -{ -quitset -. -add -( -b -) -; -} -} -let -classes -= -if -! -self -. -config -. -get_byte_classes -( -) -{ -/ -/ -DFAs -will -always -use -the -equivalence -class -map -but -enabling -/ -/ -this -option -is -useful -for -debugging -. -Namely -this -will -cause -all -/ -/ -transitions -to -be -defined -over -their -actual -bytes -instead -of -an -/ -/ -opaque -equivalence -class -identifier -. -The -former -is -much -easier -/ -/ -to -grok -as -a -human -. -ByteClasses -: -: -singletons -( -) -} -else -{ -let -mut -set -= -nfa -. -byte_class_set -( -) -. -clone -( -) -; -/ -/ -It -is -important -to -distinguish -any -" -quit -" -bytes -from -all -other -/ -/ -bytes -. -Otherwise -a -non -- -quit -byte -may -end -up -in -the -same -class -/ -/ -as -a -quit -byte -and -thus -cause -the -DFA -stop -when -it -shouldn -' -t -. -/ -/ -/ -/ -Test -case -: -/ -/ -/ -/ -regex -- -cli -find -hybrid -regex -- -w -conn -. -json -. -1000x -. -log -\ -/ -/ -' -^ -# -' -' -\ -b10 -\ -. -55 -\ -. -182 -\ -. -100 -\ -b -' -if -! -quitset -. -is_empty -( -) -{ -set -. -add_set -( -& -quitset -) -; -} -set -. -byte_classes -( -) -} -; -let -mut -dfa -= -DFA -: -: -initial -( -classes -nfa -. -pattern_len -( -) -self -. -config -. -get_starts -( -) -nfa -. -look_matcher -( -) -self -. -config -. -get_starts_for_each_pattern -( -) -self -. -config -. -get_prefilter -( -) -. -map -( -| -p -| -p -. -clone -( -) -) -quitset -Flags -: -: -from_nfa -( -& -nfa -) -) -? -; -determinize -: -: -Config -: -: -new -( -) -. -match_kind -( -self -. -config -. -get_match_kind -( -) -) -. -quit -( -quitset -) -. -dfa_size_limit -( -self -. -config -. -get_dfa_size_limit -( -) -) -. -determinize_size_limit -( -self -. -config -. -get_determinize_size_limit -( -) -) -. -run -( -nfa -& -mut -dfa -) -? -; -if -self -. -config -. -get_minimize -( -) -{ -dfa -. -minimize -( -) -; -} -if -self -. -config -. -get_accelerate -( -) -{ -dfa -. -accelerate -( -) -; -} -/ -/ -The -state -shuffling -done -before -this -point -always -assumes -that -start -/ -/ -states -should -be -marked -as -" -special -" -even -though -it -isn -' -t -the -/ -/ -default -configuration -. -State -shuffling -is -complex -enough -as -it -is -/ -/ -so -it -' -s -simpler -to -just -" -fix -" -our -special -state -ID -ranges -to -not -/ -/ -include -starting -states -after -- -the -- -fact -. -if -! -self -. -config -. -get_specialize_start_states -( -) -{ -dfa -. -special -. -set_no_special_start_states -( -) -; -} -/ -/ -Look -for -and -set -the -universal -starting -states -. -dfa -. -set_universal_starts -( -) -; -Ok -( -dfa -) -} -/ -/ -/ -Apply -the -given -dense -DFA -configuration -options -to -this -builder -. -pub -fn -configure -( -& -mut -self -config -: -Config -) -- -> -& -mut -Builder -{ -self -. -config -= -self -. -config -. -overwrite -( -config -) -; -self -} -/ -/ -/ -Set -the -syntax -configuration -for -this -builder -using -/ -/ -/ -[ -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -case -insensitivity -Unicode -and -multi -/ -/ -/ -line -mode -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -DFA -directly -from -a -/ -/ -/ -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -syntax -( -config -) -; -self -} -/ -/ -/ -Set -the -Thompson -NFA -configuration -for -this -builder -using -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -whether -the -DFA -should -match -the -regex -/ -/ -/ -in -reverse -or -if -additional -time -should -be -spent -shrinking -the -size -of -/ -/ -/ -the -NFA -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -DFA -directly -from -a -/ -/ -/ -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -thompson -( -& -mut -self -config -: -thompson -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -configure -( -config -) -; -self -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -Default -for -Builder -{ -fn -default -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -} -/ -/ -/ -A -convenience -alias -for -an -owned -DFA -. -We -use -this -particular -instantiation -/ -/ -/ -a -lot -in -this -crate -so -it -' -s -worth -giving -it -a -name -. -This -instantiation -/ -/ -/ -is -commonly -used -for -mutable -APIs -on -the -DFA -while -building -it -. -The -main -/ -/ -/ -reason -for -making -DFAs -generic -is -no_std -support -and -more -generally -/ -/ -/ -making -it -possible -to -load -a -DFA -from -an -arbitrary -slice -of -bytes -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -( -crate -) -type -OwnedDFA -= -DFA -< -alloc -: -: -vec -: -: -Vec -< -u32 -> -> -; -/ -/ -/ -A -dense -table -- -based -deterministic -finite -automaton -( -DFA -) -. -/ -/ -/ -/ -/ -/ -All -dense -DFAs -have -one -or -more -start -states -zero -or -more -match -states -/ -/ -/ -and -a -transition -table -that -maps -the -current -state -and -the -current -byte -/ -/ -/ -of -input -to -the -next -state -. -A -DFA -can -use -this -information -to -implement -/ -/ -/ -fast -searching -. -In -particular -the -use -of -a -dense -DFA -generally -makes -the -/ -/ -/ -trade -off -that -match -speed -is -the -most -valuable -characteristic -even -if -/ -/ -/ -building -the -DFA -may -take -significant -time -* -and -* -space -. -( -More -concretely -/ -/ -/ -building -a -DFA -takes -time -and -space -that -is -exponential -in -the -size -of -the -/ -/ -/ -pattern -in -the -worst -case -. -) -As -such -the -processing -of -every -byte -of -input -/ -/ -/ -is -done -with -a -small -constant -number -of -operations -that -does -not -vary -with -/ -/ -/ -the -pattern -its -size -or -the -size -of -the -alphabet -. -If -your -needs -don -' -t -line -/ -/ -/ -up -with -this -trade -off -then -a -dense -DFA -may -not -be -an -adequate -solution -to -/ -/ -/ -your -problem -. -/ -/ -/ -/ -/ -/ -In -contrast -a -[ -sparse -: -: -DFA -] -makes -the -opposite -/ -/ -/ -trade -off -: -it -uses -less -space -but -will -execute -a -variable -number -of -/ -/ -/ -instructions -per -byte -at -match -time -which -makes -it -slower -for -matching -. -/ -/ -/ -( -Note -that -space -usage -is -still -exponential -in -the -size -of -the -pattern -in -/ -/ -/ -the -worst -case -. -) -/ -/ -/ -/ -/ -/ -A -DFA -can -be -built -using -the -default -configuration -via -the -/ -/ -/ -[ -DFA -: -: -new -] -constructor -. -Otherwise -one -can -/ -/ -/ -configure -various -aspects -via -[ -dense -: -: -Builder -] -( -Builder -) -. -/ -/ -/ -/ -/ -/ -A -single -DFA -fundamentally -supports -the -following -operations -: -/ -/ -/ -/ -/ -/ -1 -. -Detection -of -a -match -. -/ -/ -/ -2 -. -Location -of -the -end -of -a -match -. -/ -/ -/ -3 -. -In -the -case -of -a -DFA -with -multiple -patterns -which -pattern -matched -is -/ -/ -/ -reported -as -well -. -/ -/ -/ -/ -/ -/ -A -notable -absence -from -the -above -list -of -capabilities -is -the -location -of -/ -/ -/ -the -* -start -* -of -a -match -. -In -order -to -provide -both -the -start -and -end -of -/ -/ -/ -a -match -* -two -* -DFAs -are -required -. -This -functionality -is -provided -by -a -/ -/ -/ -[ -Regex -] -( -crate -: -: -dfa -: -: -regex -: -: -Regex -) -. -/ -/ -/ -/ -/ -/ -# -Type -parameters -/ -/ -/ -/ -/ -/ -A -DFA -has -one -type -parameter -T -which -is -used -to -represent -state -IDs -/ -/ -/ -pattern -IDs -and -accelerators -. -T -is -typically -a -Vec -< -u32 -> -or -a -& -[ -u32 -] -. -/ -/ -/ -/ -/ -/ -# -The -Automaton -trait -/ -/ -/ -/ -/ -/ -This -type -implements -the -[ -Automaton -] -trait -which -means -it -can -be -used -/ -/ -/ -for -searching -. -For -example -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -8 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -) -] -pub -struct -DFA -< -T -> -{ -/ -/ -/ -The -transition -table -for -this -DFA -. -This -includes -the -transitions -/ -/ -/ -themselves -along -with -the -stride -number -of -states -and -the -equivalence -/ -/ -/ -class -mapping -. -tt -: -TransitionTable -< -T -> -/ -/ -/ -The -set -of -starting -state -identifiers -for -this -DFA -. -The -starting -state -/ -/ -/ -IDs -act -as -pointers -into -the -transition -table -. -The -specific -starting -/ -/ -/ -state -chosen -for -each -search -is -dependent -on -the -context -at -which -the -/ -/ -/ -search -begins -. -st -: -StartTable -< -T -> -/ -/ -/ -The -set -of -match -states -and -the -patterns -that -match -for -each -/ -/ -/ -corresponding -match -state -. -/ -/ -/ -/ -/ -/ -This -structure -is -technically -only -needed -because -of -support -for -/ -/ -/ -multi -- -regexes -. -Namely -multi -- -regexes -require -answering -not -just -whether -/ -/ -/ -a -match -exists -but -_which_ -patterns -match -. -So -we -need -to -store -the -/ -/ -/ -matching -pattern -IDs -for -each -match -state -. -We -do -this -even -when -there -/ -/ -/ -is -only -one -pattern -for -the -sake -of -simplicity -. -In -practice -this -uses -/ -/ -/ -up -very -little -space -for -the -case -of -one -pattern -. -ms -: -MatchStates -< -T -> -/ -/ -/ -Information -about -which -states -are -" -special -. -" -Special -states -are -states -/ -/ -/ -that -are -dead -quit -matching -starting -or -accelerated -. -For -more -info -/ -/ -/ -see -the -docs -for -Special -. -special -: -Special -/ -/ -/ -The -accelerators -for -this -DFA -. -/ -/ -/ -/ -/ -/ -If -a -state -is -accelerated -then -there -exist -only -a -small -number -of -/ -/ -/ -bytes -that -can -cause -the -DFA -to -leave -the -state -. -This -permits -searching -/ -/ -/ -to -use -optimized -routines -to -find -those -specific -bytes -instead -of -using -/ -/ -/ -the -transition -table -. -/ -/ -/ -/ -/ -/ -All -accelerated -states -exist -in -a -contiguous -range -in -the -DFA -' -s -/ -/ -/ -transition -table -. -See -dfa -/ -special -. -rs -for -more -details -on -how -states -are -/ -/ -/ -arranged -. -accels -: -Accels -< -T -> -/ -/ -/ -Any -prefilter -attached -to -this -DFA -. -/ -/ -/ -/ -/ -/ -Note -that -currently -prefilters -are -not -serialized -. -When -deserializing -/ -/ -/ -a -DFA -from -bytes -this -is -always -set -to -None -. -pre -: -Option -< -Prefilter -> -/ -/ -/ -The -set -of -" -quit -" -bytes -for -this -DFA -. -/ -/ -/ -/ -/ -/ -This -is -only -used -when -computing -the -start -state -for -a -particular -/ -/ -/ -position -in -a -haystack -. -Namely -in -the -case -where -there -is -a -quit -/ -/ -/ -byte -immediately -before -the -start -of -the -search -this -set -needs -to -be -/ -/ -/ -explicitly -consulted -. -In -all -other -cases -quit -bytes -are -detected -by -/ -/ -/ -the -DFA -itself -by -transitioning -all -quit -bytes -to -a -special -" -quit -/ -/ -/ -state -. -" -quitset -: -ByteSet -/ -/ -/ -Various -flags -describing -the -behavior -of -this -DFA -. -flags -: -Flags -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -OwnedDFA -{ -/ -/ -/ -Parse -the -given -regular -expression -using -a -default -configuration -and -/ -/ -/ -return -the -corresponding -DFA -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -/ -/ -/ -[ -dense -: -: -Builder -] -( -Builder -) -to -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -11 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345bar -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -OwnedDFA -BuildError -> -{ -Builder -: -: -new -( -) -. -build -( -pattern -) -} -/ -/ -/ -Parse -the -given -regular -expressions -using -a -default -configuration -and -/ -/ -/ -return -the -corresponding -multi -- -DFA -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -/ -/ -/ -[ -dense -: -: -Builder -] -( -Builder -) -to -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -] -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -1 -3 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345bar -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -OwnedDFA -BuildError -> -{ -Builder -: -: -new -( -) -. -build_many -( -patterns -) -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -OwnedDFA -{ -/ -/ -/ -Create -a -new -DFA -that -matches -every -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -always_match -( -) -? -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -0 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -" -) -) -? -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -always_match -( -) -- -> -Result -< -OwnedDFA -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -always_match -( -) -; -Builder -: -: -new -( -) -. -build_from_nfa -( -& -nfa -) -} -/ -/ -/ -Create -a -new -DFA -that -never -matches -any -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dense -: -: -DFA -: -: -never_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -None -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -" -) -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -never_match -( -) -- -> -Result -< -OwnedDFA -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -never_match -( -) -; -Builder -: -: -new -( -) -. -build_from_nfa -( -& -nfa -) -} -/ -/ -/ -Create -an -initial -DFA -with -the -given -equivalence -classes -pattern -/ -/ -/ -length -and -whether -anchored -starting -states -are -enabled -for -each -/ -/ -/ -pattern -. -An -initial -DFA -can -be -further -mutated -via -determinization -. -fn -initial -( -classes -: -ByteClasses -pattern_len -: -usize -starts -: -StartKind -lookm -: -& -LookMatcher -starts_for_each_pattern -: -bool -pre -: -Option -< -Prefilter -> -quitset -: -ByteSet -flags -: -Flags -) -- -> -Result -< -OwnedDFA -BuildError -> -{ -let -start_pattern_len -= -if -starts_for_each_pattern -{ -Some -( -pattern_len -) -} -else -{ -None -} -; -Ok -( -DFA -{ -tt -: -TransitionTable -: -: -minimal -( -classes -) -st -: -StartTable -: -: -dead -( -starts -lookm -start_pattern_len -) -? -ms -: -MatchStates -: -: -empty -( -pattern_len -) -special -: -Special -: -: -new -( -) -accels -: -Accels -: -: -empty -( -) -pre -quitset -flags -} -) -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -DFA -< -& -[ -u32 -] -> -{ -/ -/ -/ -Return -a -new -default -dense -DFA -compiler -configuration -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -[ -Config -] -/ -/ -/ -type -when -customizing -the -construction -of -a -dense -DFA -. -pub -fn -config -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -/ -/ -/ -Create -a -new -dense -DFA -builder -with -the -default -configuration -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Builder -] -type -in -common -cases -. -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -} -impl -< -T -: -AsRef -< -[ -u32 -] -> -> -DFA -< -T -> -{ -/ -/ -/ -Cheaply -return -a -borrowed -version -of -this -dense -DFA -. -Specifically -/ -/ -/ -the -DFA -returned -always -uses -& -[ -u32 -] -for -its -transition -table -. -pub -fn -as_ref -( -& -self -) -- -> -DFA -< -& -' -_ -[ -u32 -] -> -{ -DFA -{ -tt -: -self -. -tt -. -as_ref -( -) -st -: -self -. -st -. -as_ref -( -) -ms -: -self -. -ms -. -as_ref -( -) -special -: -self -. -special -accels -: -self -. -accels -( -) -pre -: -self -. -pre -. -clone -( -) -quitset -: -self -. -quitset -flags -: -self -. -flags -} -} -/ -/ -/ -Return -an -owned -version -of -this -sparse -DFA -. -Specifically -the -DFA -/ -/ -/ -returned -always -uses -Vec -< -u32 -> -for -its -transition -table -. -/ -/ -/ -/ -/ -/ -Effectively -this -returns -a -dense -DFA -whose -transition -table -lives -on -/ -/ -/ -the -heap -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -fn -to_owned -( -& -self -) -- -> -OwnedDFA -{ -DFA -{ -tt -: -self -. -tt -. -to_owned -( -) -st -: -self -. -st -. -to_owned -( -) -ms -: -self -. -ms -. -to_owned -( -) -special -: -self -. -special -accels -: -self -. -accels -( -) -. -to_owned -( -) -pre -: -self -. -pre -. -clone -( -) -quitset -: -self -. -quitset -flags -: -self -. -flags -} -} -/ -/ -/ -Returns -the -starting -state -configuration -for -this -DFA -. -/ -/ -/ -/ -/ -/ -The -default -is -[ -StartKind -: -: -Both -] -which -means -the -DFA -supports -both -/ -/ -/ -unanchored -and -anchored -searches -. -However -this -can -generally -lead -to -/ -/ -/ -bigger -DFAs -. -Therefore -a -DFA -might -be -compiled -with -support -for -just -/ -/ -/ -unanchored -or -anchored -searches -. -In -that -case -running -a -search -with -/ -/ -/ -an -unsupported -configuration -will -panic -. -pub -fn -start_kind -( -& -self -) -- -> -StartKind -{ -self -. -st -. -kind -} -/ -/ -/ -Returns -the -start -byte -map -used -for -computing -the -Start -configuration -/ -/ -/ -at -the -beginning -of -a -search -. -pub -( -crate -) -fn -start_map -( -& -self -) -- -> -& -StartByteMap -{ -& -self -. -st -. -start_map -} -/ -/ -/ -Returns -true -only -if -this -DFA -has -starting -states -for -each -pattern -. -/ -/ -/ -/ -/ -/ -When -a -DFA -has -starting -states -for -each -pattern -then -a -search -with -the -/ -/ -/ -DFA -can -be -configured -to -only -look -for -anchored -matches -of -a -specific -/ -/ -/ -pattern -. -Specifically -APIs -like -[ -Automaton -: -: -try_search_fwd -] -can -/ -/ -/ -accept -a -non -- -None -pattern_id -if -and -only -if -this -method -returns -true -. -/ -/ -/ -Otherwise -calling -try_search_fwd -will -panic -. -/ -/ -/ -/ -/ -/ -Note -that -if -the -DFA -has -no -patterns -this -always -returns -false -. -pub -fn -starts_for_each_pattern -( -& -self -) -- -> -bool -{ -self -. -st -. -pattern_len -. -is_some -( -) -} -/ -/ -/ -Returns -the -equivalence -classes -that -make -up -the -alphabet -for -this -DFA -. -/ -/ -/ -/ -/ -/ -Unless -[ -Config -: -: -byte_classes -] -was -disabled -it -is -possible -that -/ -/ -/ -multiple -distinct -bytes -are -grouped -into -the -same -equivalence -class -/ -/ -/ -if -it -is -impossible -for -them -to -discriminate -between -a -match -and -a -/ -/ -/ -non -- -match -. -This -has -the -effect -of -reducing -the -overall -alphabet -size -/ -/ -/ -and -in -turn -potentially -substantially -reducing -the -size -of -the -DFA -' -s -/ -/ -/ -transition -table -. -/ -/ -/ -/ -/ -/ -The -downside -of -using -equivalence -classes -like -this -is -that -every -state -/ -/ -/ -transition -will -automatically -use -this -map -to -convert -an -arbitrary -/ -/ -/ -byte -to -its -corresponding -equivalence -class -. -In -practice -this -has -a -/ -/ -/ -negligible -impact -on -performance -. -pub -fn -byte_classes -( -& -self -) -- -> -& -ByteClasses -{ -& -self -. -tt -. -classes -} -/ -/ -/ -Returns -the -total -number -of -elements -in -the -alphabet -for -this -DFA -. -/ -/ -/ -/ -/ -/ -That -is -this -returns -the -total -number -of -transitions -that -each -state -/ -/ -/ -in -this -DFA -must -have -. -Typically -a -normal -byte -oriented -DFA -would -/ -/ -/ -always -have -an -alphabet -size -of -256 -corresponding -to -the -number -of -/ -/ -/ -unique -values -in -a -single -byte -. -However -this -implementation -has -two -/ -/ -/ -peculiarities -that -impact -the -alphabet -length -: -/ -/ -/ -/ -/ -/ -* -Every -state -has -a -special -" -EOI -" -transition -that -is -only -followed -/ -/ -/ -after -the -end -of -some -haystack -is -reached -. -This -EOI -transition -is -/ -/ -/ -necessary -to -account -for -one -byte -of -look -- -ahead -when -implementing -/ -/ -/ -things -like -\ -b -and -. -/ -/ -/ -* -Bytes -are -grouped -into -equivalence -classes -such -that -no -two -bytes -in -/ -/ -/ -the -same -class -can -distinguish -a -match -from -a -non -- -match -. -For -example -/ -/ -/ -in -the -regex -^ -[ -a -- -z -] -+ -the -ASCII -bytes -a -- -z -could -all -be -in -the -/ -/ -/ -same -equivalence -class -. -This -leads -to -a -massive -space -savings -. -/ -/ -/ -/ -/ -/ -Note -though -that -the -alphabet -length -does -_not_ -necessarily -equal -the -/ -/ -/ -total -stride -space -taken -up -by -a -single -DFA -state -in -the -transition -/ -/ -/ -table -. -Namely -for -performance -reasons -the -stride -is -always -the -/ -/ -/ -smallest -power -of -two -that -is -greater -than -or -equal -to -the -alphabet -/ -/ -/ -length -. -For -this -reason -[ -DFA -: -: -stride -] -or -[ -DFA -: -: -stride2 -] -are -/ -/ -/ -often -more -useful -. -The -alphabet -length -is -typically -useful -only -for -/ -/ -/ -informational -purposes -. -pub -fn -alphabet_len -( -& -self -) -- -> -usize -{ -self -. -tt -. -alphabet_len -( -) -} -/ -/ -/ -Returns -the -total -stride -for -every -state -in -this -DFA -expressed -as -the -/ -/ -/ -exponent -of -a -power -of -2 -. -The -stride -is -the -amount -of -space -each -state -/ -/ -/ -takes -up -in -the -transition -table -expressed -as -a -number -of -transitions -. -/ -/ -/ -( -Unused -transitions -map -to -dead -states -. -) -/ -/ -/ -/ -/ -/ -The -stride -of -a -DFA -is -always -equivalent -to -the -smallest -power -of -2 -/ -/ -/ -that -is -greater -than -or -equal -to -the -DFA -' -s -alphabet -length -. -This -/ -/ -/ -definition -uses -extra -space -but -permits -faster -translation -between -/ -/ -/ -premultiplied -state -identifiers -and -contiguous -indices -( -by -using -shifts -/ -/ -/ -instead -of -relying -on -integer -division -) -. -/ -/ -/ -/ -/ -/ -For -example -if -the -DFA -' -s -stride -is -16 -transitions -then -its -stride2 -/ -/ -/ -is -4 -since -2 -^ -4 -= -16 -. -/ -/ -/ -/ -/ -/ -The -minimum -stride2 -value -is -1 -( -corresponding -to -a -stride -of -2 -) -/ -/ -/ -while -the -maximum -stride2 -value -is -9 -( -corresponding -to -a -stride -of -/ -/ -/ -512 -) -. -The -maximum -is -not -8 -since -the -maximum -alphabet -size -is -257 -/ -/ -/ -when -accounting -for -the -special -EOI -transition -. -However -an -alphabet -/ -/ -/ -length -of -that -size -is -exceptionally -rare -since -the -alphabet -is -shrunk -/ -/ -/ -into -equivalence -classes -. -pub -fn -stride2 -( -& -self -) -- -> -usize -{ -self -. -tt -. -stride2 -} -/ -/ -/ -Returns -the -total -stride -for -every -state -in -this -DFA -. -This -corresponds -/ -/ -/ -to -the -total -number -of -transitions -used -by -each -state -in -this -DFA -' -s -/ -/ -/ -transition -table -. -/ -/ -/ -/ -/ -/ -Please -see -[ -DFA -: -: -stride2 -] -for -more -information -. -In -particular -this -/ -/ -/ -returns -the -stride -as -the -number -of -transitions -where -as -stride2 -/ -/ -/ -returns -it -as -the -exponent -of -a -power -of -2 -. -pub -fn -stride -( -& -self -) -- -> -usize -{ -self -. -tt -. -stride -( -) -} -/ -/ -/ -Returns -the -memory -usage -in -bytes -of -this -DFA -. -/ -/ -/ -/ -/ -/ -The -memory -usage -is -computed -based -on -the -number -of -bytes -used -to -/ -/ -/ -represent -this -DFA -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -DFA -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -dense -: -: -DFA -> -( -) -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -tt -. -memory_usage -( -) -+ -self -. -st -. -memory_usage -( -) -+ -self -. -ms -. -memory_usage -( -) -+ -self -. -accels -. -memory_usage -( -) -} -} -/ -/ -/ -Routines -for -converting -a -dense -DFA -to -other -representations -such -as -/ -/ -/ -sparse -DFAs -or -raw -bytes -suitable -for -persistent -storage -. -impl -< -T -: -AsRef -< -[ -u32 -] -> -> -DFA -< -T -> -{ -/ -/ -/ -Convert -this -dense -DFA -to -a -sparse -DFA -. -/ -/ -/ -/ -/ -/ -If -a -StateID -is -too -small -to -represent -all -states -in -the -sparse -/ -/ -/ -DFA -then -this -returns -an -error -. -In -most -cases -if -a -dense -DFA -is -/ -/ -/ -constructable -with -StateID -then -a -sparse -DFA -will -be -as -well -. -/ -/ -/ -However -it -is -not -guaranteed -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dense -= -dense -: -: -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -sparse -= -dense -. -to_sparse -( -) -? -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -sparse -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -to_sparse -( -& -self -) -- -> -Result -< -sparse -: -: -DFA -< -Vec -< -u8 -> -> -BuildError -> -{ -sparse -: -: -DFA -: -: -from_dense -( -self -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -a -Vec -< -u8 -> -in -little -endian -/ -/ -/ -format -. -Upon -success -the -Vec -< -u8 -> -and -the -initial -padding -length -are -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -The -padding -returned -is -non -- -zero -if -the -returned -Vec -< -u8 -> -starts -at -/ -/ -/ -an -address -that -does -not -have -the -same -alignment -as -u32 -. -The -padding -/ -/ -/ -corresponds -to -the -number -of -leading -bytes -written -to -the -returned -/ -/ -/ -Vec -< -u8 -> -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -We -use -native -endianness -here -to -make -the -example -work -but -/ -/ -/ -/ -/ -using -to_bytes_little_endian -would -work -on -a -little -endian -target -. -/ -/ -/ -let -( -buf -_ -) -= -original_dfa -. -to_bytes_native_endian -( -) -; -/ -/ -/ -/ -/ -Even -if -buf -has -initial -padding -DFA -: -: -from_bytes -will -automatically -/ -/ -/ -/ -/ -ignore -it -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -buf -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -to_bytes_little_endian -( -& -self -) -- -> -( -Vec -< -u8 -> -usize -) -{ -self -. -to_bytes -: -: -< -wire -: -: -LE -> -( -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -a -Vec -< -u8 -> -in -big -endian -/ -/ -/ -format -. -Upon -success -the -Vec -< -u8 -> -and -the -initial -padding -length -are -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -The -padding -returned -is -non -- -zero -if -the -returned -Vec -< -u8 -> -starts -at -/ -/ -/ -an -address -that -does -not -have -the -same -alignment -as -u32 -. -The -padding -/ -/ -/ -corresponds -to -the -number -of -leading -bytes -written -to -the -returned -/ -/ -/ -Vec -< -u8 -> -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -We -use -native -endianness -here -to -make -the -example -work -but -/ -/ -/ -/ -/ -using -to_bytes_big_endian -would -work -on -a -big -endian -target -. -/ -/ -/ -let -( -buf -_ -) -= -original_dfa -. -to_bytes_native_endian -( -) -; -/ -/ -/ -/ -/ -Even -if -buf -has -initial -padding -DFA -: -: -from_bytes -will -automatically -/ -/ -/ -/ -/ -ignore -it -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -buf -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -to_bytes_big_endian -( -& -self -) -- -> -( -Vec -< -u8 -> -usize -) -{ -self -. -to_bytes -: -: -< -wire -: -: -BE -> -( -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -a -Vec -< -u8 -> -in -native -endian -/ -/ -/ -format -. -Upon -success -the -Vec -< -u8 -> -and -the -initial -padding -length -are -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -The -padding -returned -is -non -- -zero -if -the -returned -Vec -< -u8 -> -starts -at -/ -/ -/ -an -address -that -does -not -have -the -same -alignment -as -u32 -. -The -padding -/ -/ -/ -corresponds -to -the -number -of -leading -bytes -written -to -the -returned -/ -/ -/ -Vec -< -u8 -> -. -/ -/ -/ -/ -/ -/ -Generally -speaking -native -endian -format -should -only -be -used -when -/ -/ -/ -you -know -that -the -target -you -' -re -compiling -the -DFA -for -matches -the -/ -/ -/ -endianness -of -the -target -on -which -you -' -re -compiling -DFA -. -For -example -/ -/ -/ -if -serialization -and -deserialization -happen -in -the -same -process -or -on -/ -/ -/ -the -same -machine -. -Otherwise -when -serializing -a -DFA -for -use -in -a -/ -/ -/ -portable -environment -you -' -ll -almost -certainly -want -to -serialize -_both_ -/ -/ -/ -a -little -endian -and -a -big -endian -version -and -then -load -the -correct -one -/ -/ -/ -based -on -the -target -' -s -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -let -( -buf -_ -) -= -original_dfa -. -to_bytes_native_endian -( -) -; -/ -/ -/ -/ -/ -Even -if -buf -has -initial -padding -DFA -: -: -from_bytes -will -automatically -/ -/ -/ -/ -/ -ignore -it -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -buf -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -to_bytes_native_endian -( -& -self -) -- -> -( -Vec -< -u8 -> -usize -) -{ -self -. -to_bytes -: -: -< -wire -: -: -NE -> -( -) -} -/ -/ -/ -The -implementation -of -the -public -to_bytes -serialization -methods -/ -/ -/ -which -is -generic -over -endianness -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -to_bytes -< -E -: -Endian -> -( -& -self -) -- -> -( -Vec -< -u8 -> -usize -) -{ -let -len -= -self -. -write_to_len -( -) -; -let -( -mut -buf -padding -) -= -wire -: -: -alloc_aligned_buffer -: -: -< -u32 -> -( -len -) -; -/ -/ -This -should -always -succeed -since -the -only -possible -serialization -/ -/ -error -is -providing -a -buffer -that -' -s -too -small -but -we -' -ve -ensured -that -/ -/ -buf -is -big -enough -here -. -self -. -as_ref -( -) -. -write_to -: -: -< -E -> -( -& -mut -buf -[ -padding -. -. -] -) -. -unwrap -( -) -; -( -buf -padding -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -the -given -slice -in -little -endian -/ -/ -/ -format -. -Upon -success -the -total -number -of -bytes -written -to -dst -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -Note -that -unlike -the -various -to_byte_ -* -routines -this -does -not -write -/ -/ -/ -any -padding -. -Callers -are -responsible -for -handling -alignment -correctly -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -given -destination -slice -is -not -big -enough -/ -/ -/ -to -contain -the -full -serialized -DFA -. -If -an -error -occurs -then -nothing -/ -/ -/ -is -written -to -dst -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -without -/ -/ -/ -dynamic -memory -allocation -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Create -a -4KB -buffer -on -the -stack -to -store -our -serialized -DFA -. -We -/ -/ -/ -/ -/ -need -to -use -a -special -type -to -force -the -alignment -of -our -[ -u8 -; -N -] -/ -/ -/ -/ -/ -array -to -be -aligned -to -a -4 -byte -boundary -. -Otherwise -deserializing -/ -/ -/ -/ -/ -the -DFA -may -fail -because -of -an -alignment -mismatch -. -/ -/ -/ -# -[ -repr -( -C -) -] -/ -/ -/ -struct -Aligned -< -B -: -? -Sized -> -{ -/ -/ -/ -_align -: -[ -u32 -; -0 -] -/ -/ -/ -bytes -: -B -/ -/ -/ -} -/ -/ -/ -let -mut -buf -= -Aligned -{ -_align -: -[ -] -bytes -: -[ -0u8 -; -4 -* -( -1 -< -< -10 -) -] -} -; -/ -/ -/ -/ -/ -N -. -B -. -We -use -native -endianness -here -to -make -the -example -work -but -/ -/ -/ -/ -/ -using -write_to_little_endian -would -work -on -a -little -endian -target -. -/ -/ -/ -let -written -= -original_dfa -. -write_to_native_endian -( -& -mut -buf -. -bytes -) -? -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -buf -. -bytes -[ -. -. -written -] -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -write_to_little_endian -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -self -. -as_ref -( -) -. -write_to -: -: -< -wire -: -: -LE -> -( -dst -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -the -given -slice -in -big -endian -/ -/ -/ -format -. -Upon -success -the -total -number -of -bytes -written -to -dst -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -Note -that -unlike -the -various -to_byte_ -* -routines -this -does -not -write -/ -/ -/ -any -padding -. -Callers -are -responsible -for -handling -alignment -correctly -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -given -destination -slice -is -not -big -enough -/ -/ -/ -to -contain -the -full -serialized -DFA -. -If -an -error -occurs -then -nothing -/ -/ -/ -is -written -to -dst -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -without -/ -/ -/ -dynamic -memory -allocation -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Create -a -4KB -buffer -on -the -stack -to -store -our -serialized -DFA -. -We -/ -/ -/ -/ -/ -need -to -use -a -special -type -to -force -the -alignment -of -our -[ -u8 -; -N -] -/ -/ -/ -/ -/ -array -to -be -aligned -to -a -4 -byte -boundary -. -Otherwise -deserializing -/ -/ -/ -/ -/ -the -DFA -may -fail -because -of -an -alignment -mismatch -. -/ -/ -/ -# -[ -repr -( -C -) -] -/ -/ -/ -struct -Aligned -< -B -: -? -Sized -> -{ -/ -/ -/ -_align -: -[ -u32 -; -0 -] -/ -/ -/ -bytes -: -B -/ -/ -/ -} -/ -/ -/ -let -mut -buf -= -Aligned -{ -_align -: -[ -] -bytes -: -[ -0u8 -; -4 -* -( -1 -< -< -10 -) -] -} -; -/ -/ -/ -/ -/ -N -. -B -. -We -use -native -endianness -here -to -make -the -example -work -but -/ -/ -/ -/ -/ -using -write_to_big_endian -would -work -on -a -big -endian -target -. -/ -/ -/ -let -written -= -original_dfa -. -write_to_native_endian -( -& -mut -buf -. -bytes -) -? -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -buf -. -bytes -[ -. -. -written -] -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -write_to_big_endian -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -self -. -as_ref -( -) -. -write_to -: -: -< -wire -: -: -BE -> -( -dst -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -the -given -slice -in -native -endian -/ -/ -/ -format -. -Upon -success -the -total -number -of -bytes -written -to -dst -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -Generally -speaking -native -endian -format -should -only -be -used -when -/ -/ -/ -you -know -that -the -target -you -' -re -compiling -the -DFA -for -matches -the -/ -/ -/ -endianness -of -the -target -on -which -you -' -re -compiling -DFA -. -For -example -/ -/ -/ -if -serialization -and -deserialization -happen -in -the -same -process -or -on -/ -/ -/ -the -same -machine -. -Otherwise -when -serializing -a -DFA -for -use -in -a -/ -/ -/ -portable -environment -you -' -ll -almost -certainly -want -to -serialize -_both_ -/ -/ -/ -a -little -endian -and -a -big -endian -version -and -then -load -the -correct -one -/ -/ -/ -based -on -the -target -' -s -configuration -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -the -various -to_byte_ -* -routines -this -does -not -write -/ -/ -/ -any -padding -. -Callers -are -responsible -for -handling -alignment -correctly -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -given -destination -slice -is -not -big -enough -/ -/ -/ -to -contain -the -full -serialized -DFA -. -If -an -error -occurs -then -nothing -/ -/ -/ -is -written -to -dst -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -without -/ -/ -/ -dynamic -memory -allocation -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Create -a -4KB -buffer -on -the -stack -to -store -our -serialized -DFA -. -We -/ -/ -/ -/ -/ -need -to -use -a -special -type -to -force -the -alignment -of -our -[ -u8 -; -N -] -/ -/ -/ -/ -/ -array -to -be -aligned -to -a -4 -byte -boundary -. -Otherwise -deserializing -/ -/ -/ -/ -/ -the -DFA -may -fail -because -of -an -alignment -mismatch -. -/ -/ -/ -# -[ -repr -( -C -) -] -/ -/ -/ -struct -Aligned -< -B -: -? -Sized -> -{ -/ -/ -/ -_align -: -[ -u32 -; -0 -] -/ -/ -/ -bytes -: -B -/ -/ -/ -} -/ -/ -/ -let -mut -buf -= -Aligned -{ -_align -: -[ -] -bytes -: -[ -0u8 -; -4 -* -( -1 -< -< -10 -) -] -} -; -/ -/ -/ -let -written -= -original_dfa -. -write_to_native_endian -( -& -mut -buf -. -bytes -) -? -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -buf -. -bytes -[ -. -. -written -] -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -write_to_native_endian -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -self -. -as_ref -( -) -. -write_to -: -: -< -wire -: -: -NE -> -( -dst -) -} -/ -/ -/ -Return -the -total -number -of -bytes -required -to -serialize -this -DFA -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -determining -the -size -of -the -buffer -required -to -pass -/ -/ -/ -to -one -of -the -serialization -routines -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -write_to_little_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_big_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_native_endian -] -/ -/ -/ -/ -/ -/ -Passing -a -buffer -smaller -than -the -size -returned -by -this -method -will -/ -/ -/ -result -in -a -serialization -error -. -Serialization -routines -are -guaranteed -/ -/ -/ -to -succeed -when -the -buffer -is -big -enough -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -dynamically -allocate -enough -room -to -serialize -/ -/ -/ -a -DFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -buf -= -vec -! -[ -0 -; -original_dfa -. -write_to_len -( -) -] -; -/ -/ -/ -/ -/ -This -is -guaranteed -to -succeed -because -the -only -serialization -error -/ -/ -/ -/ -/ -that -can -occur -is -when -the -provided -buffer -is -too -small -. -But -/ -/ -/ -/ -/ -write_to_len -guarantees -a -correct -size -. -/ -/ -/ -let -written -= -original_dfa -. -write_to_native_endian -( -& -mut -buf -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -But -this -is -not -guaranteed -to -succeed -! -In -particular -/ -/ -/ -/ -/ -deserialization -requires -proper -alignment -for -& -[ -u32 -] -but -our -buffer -/ -/ -/ -/ -/ -was -allocated -as -a -& -[ -u8 -] -whose -required -alignment -is -smaller -than -/ -/ -/ -/ -/ -& -[ -u32 -] -. -However -it -' -s -likely -to -work -in -practice -because -of -how -most -/ -/ -/ -/ -/ -allocators -work -. -So -if -you -write -code -like -this -make -sure -to -either -/ -/ -/ -/ -/ -handle -the -error -correctly -and -/ -or -run -it -under -Miri -since -Miri -will -/ -/ -/ -/ -/ -likely -provoke -the -error -by -returning -Vec -< -u8 -> -buffers -with -alignment -/ -/ -/ -/ -/ -less -than -& -[ -u32 -] -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -match -DFA -: -: -from_bytes -( -& -buf -[ -. -. -written -] -) -{ -/ -/ -/ -/ -/ -As -mentioned -above -it -is -legal -for -an -error -to -be -returned -/ -/ -/ -/ -/ -here -. -It -is -quite -difficult -to -get -a -Vec -< -u8 -> -with -a -guaranteed -/ -/ -/ -/ -/ -alignment -equivalent -to -Vec -< -u32 -> -. -/ -/ -/ -Err -( -_ -) -= -> -return -Ok -( -( -) -) -/ -/ -/ -Ok -( -( -dfa -_ -) -) -= -> -dfa -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -this -example -isn -' -t -actually -guaranteed -to -work -! -In -/ -/ -/ -particular -if -buf -is -not -aligned -to -a -4 -- -byte -boundary -then -the -/ -/ -/ -DFA -: -: -from_bytes -call -will -fail -. -If -you -need -this -to -work -then -you -/ -/ -/ -either -need -to -deal -with -adding -some -initial -padding -yourself -or -use -/ -/ -/ -one -of -the -to_bytes -methods -which -will -do -it -for -you -. -pub -fn -write_to_len -( -& -self -) -- -> -usize -{ -wire -: -: -write_label_len -( -LABEL -) -+ -wire -: -: -write_endianness_check_len -( -) -+ -wire -: -: -write_version_len -( -) -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -unused -intended -for -future -flexibility -+ -self -. -flags -. -write_to_len -( -) -+ -self -. -tt -. -write_to_len -( -) -+ -self -. -st -. -write_to_len -( -) -+ -self -. -ms -. -write_to_len -( -) -+ -self -. -special -. -write_to_len -( -) -+ -self -. -accels -. -write_to_len -( -) -+ -self -. -quitset -. -write_to_len -( -) -} -} -impl -< -' -a -> -DFA -< -& -' -a -[ -u32 -] -> -{ -/ -/ -/ -Safely -deserialize -a -DFA -with -a -specific -state -identifier -/ -/ -/ -representation -. -Upon -success -this -returns -both -the -deserialized -DFA -/ -/ -/ -and -the -number -of -bytes -read -from -the -given -slice -. -Namely -the -contents -/ -/ -/ -of -the -slice -beyond -the -DFA -are -not -read -. -/ -/ -/ -/ -/ -/ -Deserializing -a -DFA -using -this -routine -will -never -allocate -heap -memory -. -/ -/ -/ -For -safety -purposes -the -DFA -' -s -transition -table -will -be -verified -such -/ -/ -/ -that -every -transition -points -to -a -valid -state -. -If -this -verification -is -/ -/ -/ -too -costly -then -a -[ -DFA -: -: -from_bytes_unchecked -] -API -is -provided -which -/ -/ -/ -will -always -execute -in -constant -time -. -/ -/ -/ -/ -/ -/ -The -bytes -given -must -be -generated -by -one -of -the -serialization -APIs -/ -/ -/ -of -a -DFA -using -a -semver -compatible -release -of -this -crate -. -Those -/ -/ -/ -include -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -to_bytes_little_endian -] -/ -/ -/ -* -[ -DFA -: -: -to_bytes_big_endian -] -/ -/ -/ -* -[ -DFA -: -: -to_bytes_native_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_little_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_big_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_native_endian -] -/ -/ -/ -/ -/ -/ -The -to_bytes -methods -allocate -and -return -a -Vec -< -u8 -> -for -you -along -/ -/ -/ -with -handling -alignment -correctly -. -The -write_to -methods -do -not -/ -/ -/ -allocate -and -write -to -an -existing -slice -( -which -may -be -on -the -stack -) -. -/ -/ -/ -Since -deserialization -always -uses -the -native -endianness -of -the -target -/ -/ -/ -platform -the -serialization -API -you -use -should -match -the -endianness -of -/ -/ -/ -the -target -platform -. -( -It -' -s -often -a -good -idea -to -generate -serialized -/ -/ -/ -DFAs -for -both -forms -of -endianness -and -then -load -the -correct -one -based -/ -/ -/ -on -endianness -. -) -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -Generally -speaking -it -' -s -easier -to -state -the -conditions -in -which -an -/ -/ -/ -error -is -_not_ -returned -. -All -of -the -following -must -be -true -: -/ -/ -/ -/ -/ -/ -* -The -bytes -given -must -be -produced -by -one -of -the -serialization -APIs -/ -/ -/ -on -this -DFA -as -mentioned -above -. -/ -/ -/ -* -The -endianness -of -the -target -platform -matches -the -endianness -used -to -/ -/ -/ -serialized -the -provided -DFA -. -/ -/ -/ -* -The -slice -given -must -have -the -same -alignment -as -u32 -. -/ -/ -/ -/ -/ -/ -If -any -of -the -above -are -not -true -then -an -error -will -be -returned -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -will -never -panic -for -any -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -a -DFA -to -raw -bytes -deserialize -it -/ -/ -/ -and -then -use -it -for -searching -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -initial -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -( -bytes -_ -) -= -initial -. -to_bytes_native_endian -( -) -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -bytes -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -dealing -with -alignment -and -padding -/ -/ -/ -/ -/ -/ -In -the -above -example -we -used -the -to_bytes_native_endian -method -to -/ -/ -/ -serialize -a -DFA -but -we -ignored -part -of -its -return -value -corresponding -/ -/ -/ -to -padding -added -to -the -beginning -of -the -serialized -DFA -. -This -is -OK -/ -/ -/ -because -deserialization -will -skip -this -initial -padding -. -What -matters -/ -/ -/ -is -that -the -address -immediately -following -the -padding -has -an -alignment -/ -/ -/ -that -matches -u32 -. -That -is -the -following -is -an -equivalent -but -/ -/ -/ -alternative -way -to -write -the -above -example -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -initial -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -Serialization -returns -the -number -of -leading -padding -bytes -added -to -/ -/ -/ -/ -/ -the -returned -Vec -< -u8 -> -. -/ -/ -/ -let -( -bytes -pad -) -= -initial -. -to_bytes_native_endian -( -) -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -bytes -[ -pad -. -. -] -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -padding -is -necessary -because -Rust -' -s -standard -library -does -/ -/ -/ -not -expose -any -safe -and -robust -way -of -creating -a -Vec -< -u8 -> -with -a -/ -/ -/ -guaranteed -alignment -other -than -1 -. -Now -in -practice -the -underlying -/ -/ -/ -allocator -is -likely -to -provide -a -Vec -< -u8 -> -that -meets -our -alignment -/ -/ -/ -requirements -which -means -pad -is -zero -in -practice -most -of -the -time -. -/ -/ -/ -/ -/ -/ -The -purpose -of -exposing -the -padding -like -this -is -flexibility -for -the -/ -/ -/ -caller -. -For -example -if -one -wants -to -embed -a -serialized -DFA -into -a -/ -/ -/ -compiled -program -then -it -' -s -important -to -guarantee -that -it -starts -at -a -/ -/ -/ -u32 -- -aligned -address -. -The -simplest -way -to -do -this -is -to -discard -the -/ -/ -/ -padding -bytes -and -set -it -up -so -that -the -serialized -DFA -itself -begins -at -/ -/ -/ -a -properly -aligned -address -. -We -can -show -this -in -two -parts -. -The -first -/ -/ -/ -part -is -serializing -the -DFA -to -a -file -: -/ -/ -/ -/ -/ -/ -no_run -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -dense -: -: -DFA -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -let -( -bytes -pad -) -= -dfa -. -to_bytes_big_endian -( -) -; -/ -/ -/ -/ -/ -Write -the -contents -of -the -DFA -* -without -* -the -initial -padding -. -/ -/ -/ -std -: -: -fs -: -: -write -( -" -foo -. -bigendian -. -dfa -" -& -bytes -[ -pad -. -. -] -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Do -it -again -but -this -time -for -little -endian -. -/ -/ -/ -let -( -bytes -pad -) -= -dfa -. -to_bytes_little_endian -( -) -; -/ -/ -/ -std -: -: -fs -: -: -write -( -" -foo -. -littleendian -. -dfa -" -& -bytes -[ -pad -. -. -] -) -? -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -now -the -second -part -is -embedding -the -DFA -into -the -compiled -program -/ -/ -/ -and -deserializing -it -at -runtime -on -first -use -. -We -use -conditional -/ -/ -/ -compilation -to -choose -the -correct -endianness -. -/ -/ -/ -/ -/ -/ -no_run -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -/ -/ -/ -util -: -: -{ -lazy -: -: -Lazy -wire -: -: -AlignAs -} -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -This -crate -provides -its -own -" -lazy -" -type -kind -of -like -/ -/ -/ -/ -/ -lazy_static -! -or -once_cell -: -: -sync -: -: -Lazy -. -But -it -works -in -no -- -alloc -/ -/ -/ -/ -/ -no -- -std -environments -and -let -' -s -us -write -this -using -completely -/ -/ -/ -/ -/ -safe -code -. -/ -/ -/ -static -RE -: -Lazy -< -DFA -< -& -' -static -[ -u32 -] -> -> -= -Lazy -: -: -new -( -| -| -{ -/ -/ -/ -# -const -_ -: -& -str -= -stringify -! -{ -/ -/ -/ -/ -/ -This -assignment -is -made -possible -( -implicitly -) -via -the -/ -/ -/ -/ -/ -CoerceUnsized -trait -. -This -is -what -guarantees -that -our -/ -/ -/ -/ -/ -bytes -are -stored -in -memory -on -a -4 -byte -boundary -. -You -/ -/ -/ -/ -/ -* -must -* -do -this -or -something -equivalent -for -correct -/ -/ -/ -/ -/ -deserialization -. -/ -/ -/ -static -ALIGNED -: -& -AlignAs -< -[ -u8 -] -u32 -> -= -& -AlignAs -{ -/ -/ -/ -_align -: -[ -] -/ -/ -/ -# -[ -cfg -( -target_endian -= -" -big -" -) -] -/ -/ -/ -bytes -: -* -include_bytes -! -( -" -foo -. -bigendian -. -dfa -" -) -/ -/ -/ -# -[ -cfg -( -target_endian -= -" -little -" -) -] -/ -/ -/ -bytes -: -* -include_bytes -! -( -" -foo -. -littleendian -. -dfa -" -) -/ -/ -/ -} -; -/ -/ -/ -# -} -; -/ -/ -/ -# -static -ALIGNED -: -& -AlignAs -< -[ -u8 -] -u32 -> -= -& -AlignAs -{ -/ -/ -/ -# -_align -: -[ -] -/ -/ -/ -# -bytes -: -[ -] -/ -/ -/ -# -} -; -/ -/ -/ -/ -/ -/ -let -( -dfa -_ -) -= -DFA -: -: -from_bytes -( -& -ALIGNED -. -bytes -) -/ -/ -/ -. -expect -( -" -serialized -DFA -should -be -valid -" -) -; -/ -/ -/ -dfa -/ -/ -/ -} -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Ok -( -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -RE -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -An -alternative -to -[ -util -: -: -lazy -: -: -Lazy -] -( -crate -: -: -util -: -: -lazy -: -: -Lazy -) -/ -/ -/ -is -[ -lazy_static -] -( -https -: -/ -/ -crates -. -io -/ -crates -/ -lazy_static -) -or -/ -/ -/ -[ -once_cell -] -( -https -: -/ -/ -crates -. -io -/ -crates -/ -once_cell -) -which -provide -/ -/ -/ -stronger -guarantees -( -like -the -initialization -function -only -being -/ -/ -/ -executed -once -) -. -And -once_cell -in -particular -provides -a -more -/ -/ -/ -expressive -API -. -But -a -Lazy -value -from -this -crate -is -likely -just -fine -/ -/ -/ -in -most -circumstances -. -/ -/ -/ -/ -/ -/ -Note -that -regardless -of -which -initialization -method -you -use -you -/ -/ -/ -will -still -need -to -use -the -[ -AlignAs -] -( -crate -: -: -util -: -: -wire -: -: -AlignAs -) -/ -/ -/ -trick -above -to -force -correct -alignment -but -this -is -safe -to -do -and -/ -/ -/ -from_bytes -will -return -an -error -if -you -get -it -wrong -. -pub -fn -from_bytes -( -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -DFA -< -& -' -a -[ -u32 -] -> -usize -) -DeserializeError -> -{ -/ -/ -SAFETY -: -This -is -safe -because -we -validate -the -transition -table -start -/ -/ -table -match -states -and -accelerators -below -. -If -any -validation -fails -/ -/ -then -we -return -an -error -. -let -( -dfa -nread -) -= -unsafe -{ -DFA -: -: -from_bytes_unchecked -( -slice -) -? -} -; -dfa -. -tt -. -validate -( -& -dfa -. -special -) -? -; -dfa -. -st -. -validate -( -& -dfa -. -tt -) -? -; -dfa -. -ms -. -validate -( -& -dfa -) -? -; -dfa -. -accels -. -validate -( -) -? -; -/ -/ -N -. -B -. -dfa -. -special -doesn -' -t -have -a -way -to -do -unchecked -deserialization -/ -/ -so -it -has -already -been -validated -. -Ok -( -( -dfa -nread -) -) -} -/ -/ -/ -Deserialize -a -DFA -with -a -specific -state -identifier -representation -in -/ -/ -/ -constant -time -by -omitting -the -verification -of -the -validity -of -the -/ -/ -/ -transition -table -and -other -data -inside -the -DFA -. -/ -/ -/ -/ -/ -/ -This -is -just -like -[ -DFA -: -: -from_bytes -] -except -it -can -potentially -return -/ -/ -/ -a -DFA -that -exhibits -undefined -behavior -if -its -transition -table -contains -/ -/ -/ -invalid -state -identifiers -. -/ -/ -/ -/ -/ -/ -This -routine -is -useful -if -you -need -to -deserialize -a -DFA -cheaply -/ -/ -/ -and -cannot -afford -the -transition -table -validation -performed -by -/ -/ -/ -from_bytes -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -initial -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -( -bytes -_ -) -= -initial -. -to_bytes_native_endian -( -) -; -/ -/ -/ -/ -/ -SAFETY -: -This -is -guaranteed -to -be -safe -since -the -bytes -given -come -/ -/ -/ -/ -/ -directly -from -a -compatible -serialization -routine -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -unsafe -{ -DFA -: -: -from_bytes_unchecked -( -& -bytes -) -? -. -0 -} -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -unsafe -fn -from_bytes_unchecked -( -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -DFA -< -& -' -a -[ -u32 -] -> -usize -) -DeserializeError -> -{ -let -mut -nr -= -0 -; -nr -+ -= -wire -: -: -skip_initial_padding -( -slice -) -; -wire -: -: -check_alignment -: -: -< -StateID -> -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -wire -: -: -read_label -( -& -slice -[ -nr -. -. -] -LABEL -) -? -; -nr -+ -= -wire -: -: -read_endianness_check -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -wire -: -: -read_version -( -& -slice -[ -nr -. -. -] -VERSION -) -? -; -let -_unused -= -wire -: -: -try_read_u32 -( -& -slice -[ -nr -. -. -] -" -unused -space -" -) -? -; -nr -+ -= -size_of -: -: -< -u32 -> -( -) -; -let -( -flags -nread -) -= -Flags -: -: -from_bytes -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -let -( -tt -nread -) -= -TransitionTable -: -: -from_bytes_unchecked -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -let -( -st -nread -) -= -StartTable -: -: -from_bytes_unchecked -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -let -( -ms -nread -) -= -MatchStates -: -: -from_bytes_unchecked -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -let -( -special -nread -) -= -Special -: -: -from_bytes -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -special -. -validate_state_len -( -tt -. -len -( -) -tt -. -stride2 -) -? -; -let -( -accels -nread -) -= -Accels -: -: -from_bytes_unchecked -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -let -( -quitset -nread -) -= -ByteSet -: -: -from_bytes -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -/ -/ -Prefilters -don -' -t -support -serialization -so -they -' -re -always -absent -. -let -pre -= -None -; -Ok -( -( -DFA -{ -tt -st -ms -special -accels -pre -quitset -flags -} -nr -) -) -} -/ -/ -/ -The -implementation -of -the -public -write_to -serialization -methods -/ -/ -/ -which -is -generic -over -endianness -. -/ -/ -/ -/ -/ -/ -This -is -defined -only -for -& -[ -u32 -] -to -reduce -binary -size -/ -compilation -time -. -fn -write_to -< -E -: -Endian -> -( -& -self -mut -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -dense -DFA -" -) -) -; -} -dst -= -& -mut -dst -[ -. -. -nwrite -] -; -let -mut -nw -= -0 -; -nw -+ -= -wire -: -: -write_label -( -LABEL -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -wire -: -: -write_endianness_check -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -wire -: -: -write_version -: -: -< -E -> -( -VERSION -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -{ -/ -/ -Currently -unused -intended -for -future -flexibility -E -: -: -write_u32 -( -0 -& -mut -dst -[ -nw -. -. -] -) -; -size_of -: -: -< -u32 -> -( -) -} -; -nw -+ -= -self -. -flags -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -tt -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -st -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -ms -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -special -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -accels -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -quitset -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -Ok -( -nw -) -} -} -/ -/ -The -following -methods -implement -mutable -routines -on -the -internal -/ -/ -representation -of -a -DFA -. -As -such -we -must -fix -the -first -type -parameter -to -a -/ -/ -Vec -< -u32 -> -since -a -generic -T -: -AsRef -< -[ -u32 -] -> -does -not -permit -mutation -. -We -/ -/ -can -get -away -with -this -because -these -methods -are -internal -to -the -crate -and -/ -/ -are -exclusively -used -during -construction -of -the -DFA -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -OwnedDFA -{ -/ -/ -/ -Add -a -start -state -of -this -DFA -. -pub -( -crate -) -fn -set_start_state -( -& -mut -self -anchored -: -Anchored -start -: -Start -id -: -StateID -) -{ -assert -! -( -self -. -tt -. -is_valid -( -id -) -" -invalid -start -state -" -) -; -self -. -st -. -set_start -( -anchored -start -id -) -; -} -/ -/ -/ -Set -the -given -transition -to -this -DFA -. -Both -the -from -and -to -states -/ -/ -/ -must -already -exist -. -pub -( -crate -) -fn -set_transition -( -& -mut -self -from -: -StateID -byte -: -alphabet -: -: -Unit -to -: -StateID -) -{ -self -. -tt -. -set -( -from -byte -to -) -; -} -/ -/ -/ -An -an -empty -state -( -a -state -where -all -transitions -lead -to -a -dead -state -) -/ -/ -/ -and -return -its -identifier -. -The -identifier -returned -is -guaranteed -to -/ -/ -/ -not -point -to -any -other -existing -state -. -/ -/ -/ -/ -/ -/ -If -adding -a -state -would -exceed -StateID -: -: -LIMIT -then -this -returns -an -/ -/ -/ -error -. -pub -( -crate -) -fn -add_empty_state -( -& -mut -self -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -tt -. -add_empty_state -( -) -} -/ -/ -/ -Swap -the -two -states -given -in -the -transition -table -. -/ -/ -/ -/ -/ -/ -This -routine -does -not -do -anything -to -check -the -correctness -of -this -/ -/ -/ -swap -. -Callers -must -ensure -that -other -states -pointing -to -id1 -and -id2 -are -/ -/ -/ -updated -appropriately -. -pub -( -crate -) -fn -swap_states -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -{ -self -. -tt -. -swap -( -id1 -id2 -) -; -} -/ -/ -/ -Remap -all -of -the -state -identifiers -in -this -DFA -according -to -the -map -/ -/ -/ -function -given -. -This -includes -all -transitions -and -all -starting -state -/ -/ -/ -identifiers -. -pub -( -crate -) -fn -remap -( -& -mut -self -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -{ -/ -/ -We -could -loop -over -each -state -ID -and -call -' -remap_state -' -here -but -/ -/ -this -is -more -direct -: -just -map -every -transition -directly -. -This -/ -/ -technically -might -do -a -little -extra -work -since -the -alphabet -length -/ -/ -is -likely -less -than -the -stride -but -if -that -is -indeed -an -issue -we -/ -/ -should -benchmark -it -and -fix -it -. -for -sid -in -self -. -tt -. -table_mut -( -) -. -iter_mut -( -) -{ -* -sid -= -map -( -* -sid -) -; -} -for -sid -in -self -. -st -. -table_mut -( -) -. -iter_mut -( -) -{ -* -sid -= -map -( -* -sid -) -; -} -} -/ -/ -/ -Remap -the -transitions -for -the -state -given -according -to -the -function -/ -/ -/ -given -. -This -applies -the -given -map -function -to -every -transition -in -the -/ -/ -/ -given -state -and -changes -the -transition -in -place -to -the -result -of -the -/ -/ -/ -map -function -for -that -transition -. -pub -( -crate -) -fn -remap_state -( -& -mut -self -id -: -StateID -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -{ -self -. -tt -. -remap -( -id -map -) -; -} -/ -/ -/ -Truncate -the -states -in -this -DFA -to -the -given -length -. -/ -/ -/ -/ -/ -/ -This -routine -does -not -do -anything -to -check -the -correctness -of -this -/ -/ -/ -truncation -. -Callers -must -ensure -that -other -states -pointing -to -truncated -/ -/ -/ -states -are -updated -appropriately -. -pub -( -crate -) -fn -truncate_states -( -& -mut -self -len -: -usize -) -{ -self -. -tt -. -truncate -( -len -) -; -} -/ -/ -/ -Minimize -this -DFA -in -place -using -Hopcroft -' -s -algorithm -. -pub -( -crate -) -fn -minimize -( -& -mut -self -) -{ -Minimizer -: -: -new -( -self -) -. -run -( -) -; -} -/ -/ -/ -Updates -the -match -state -pattern -ID -map -to -use -the -one -provided -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -it -' -s -convenient -to -manipulate -matching -states -/ -/ -/ -( -and -their -corresponding -pattern -IDs -) -as -a -map -. -In -particular -the -/ -/ -/ -representation -used -by -a -DFA -for -this -map -is -not -amenable -to -mutation -/ -/ -/ -so -if -things -need -to -be -changed -( -like -when -shuffling -states -) -it -' -s -/ -/ -/ -often -easier -to -work -with -the -map -form -. -pub -( -crate -) -fn -set_pattern_map -( -& -mut -self -map -: -& -BTreeMap -< -StateID -Vec -< -PatternID -> -> -) -- -> -Result -< -( -) -BuildError -> -{ -self -. -ms -= -self -. -ms -. -new_with_map -( -map -) -? -; -Ok -( -( -) -) -} -/ -/ -/ -Find -states -that -have -a -small -number -of -non -- -loop -transitions -and -mark -/ -/ -/ -them -as -candidates -for -acceleration -during -search -. -pub -( -crate -) -fn -accelerate -( -& -mut -self -) -{ -/ -/ -dead -and -quit -states -can -never -be -accelerated -. -if -self -. -state_len -( -) -< -= -2 -{ -return -; -} -/ -/ -Go -through -every -state -and -record -their -accelerator -if -possible -. -let -mut -accels -= -BTreeMap -: -: -new -( -) -; -/ -/ -Count -the -number -of -accelerated -match -start -and -non -- -match -/ -start -/ -/ -states -. -let -( -mut -cmatch -mut -cstart -mut -cnormal -) -= -( -0 -0 -0 -) -; -for -state -in -self -. -states -( -) -{ -if -let -Some -( -accel -) -= -state -. -accelerate -( -self -. -byte_classes -( -) -) -{ -debug -! -( -" -accelerating -full -DFA -state -{ -} -: -{ -: -? -} -" -state -. -id -( -) -. -as_usize -( -) -accel -) -; -accels -. -insert -( -state -. -id -( -) -accel -) -; -if -self -. -is_match_state -( -state -. -id -( -) -) -{ -cmatch -+ -= -1 -; -} -else -if -self -. -is_start_state -( -state -. -id -( -) -) -{ -cstart -+ -= -1 -; -} -else -{ -assert -! -( -! -self -. -is_dead_state -( -state -. -id -( -) -) -) -; -assert -! -( -! -self -. -is_quit_state -( -state -. -id -( -) -) -) -; -cnormal -+ -= -1 -; -} -} -} -/ -/ -If -no -states -were -able -to -be -accelerated -then -we -' -re -done -. -if -accels -. -is_empty -( -) -{ -return -; -} -let -original_accels_len -= -accels -. -len -( -) -; -/ -/ -A -remapper -keeps -track -of -state -ID -changes -. -Once -we -' -re -done -/ -/ -shuffling -the -remapper -is -used -to -rewrite -all -transitions -in -the -/ -/ -DFA -based -on -the -new -positions -of -states -. -let -mut -remapper -= -Remapper -: -: -new -( -self -) -; -/ -/ -As -we -swap -states -if -they -are -match -states -we -need -to -swap -their -/ -/ -pattern -ID -lists -too -( -for -multi -- -regexes -) -. -We -do -this -by -converting -/ -/ -the -lists -to -an -easily -swappable -map -and -then -convert -back -to -/ -/ -MatchStates -once -we -' -re -done -. -let -mut -new_matches -= -self -. -ms -. -to_map -( -self -) -; -/ -/ -There -is -at -least -one -state -that -gets -accelerated -so -these -are -/ -/ -guaranteed -to -get -set -to -sensible -values -below -. -self -. -special -. -min_accel -= -StateID -: -: -MAX -; -self -. -special -. -max_accel -= -StateID -: -: -ZERO -; -let -update_special_accel -= -| -special -: -& -mut -Special -accel_id -: -StateID -| -{ -special -. -min_accel -= -cmp -: -: -min -( -special -. -min_accel -accel_id -) -; -special -. -max_accel -= -cmp -: -: -max -( -special -. -max_accel -accel_id -) -; -} -; -/ -/ -Start -by -shuffling -match -states -. -Any -match -states -that -are -/ -/ -accelerated -get -moved -to -the -end -of -the -match -state -range -. -if -cmatch -> -0 -& -& -self -. -special -. -matches -( -) -{ -/ -/ -N -. -B -. -special -. -{ -min -max -} -_match -do -not -need -updating -since -the -/ -/ -range -/ -number -of -match -states -does -not -change -. -Only -the -ordering -/ -/ -of -match -states -may -change -. -let -mut -next_id -= -self -. -special -. -max_match -; -let -mut -cur_id -= -next_id -; -while -cur_id -> -= -self -. -special -. -min_match -{ -if -let -Some -( -accel -) -= -accels -. -remove -( -& -cur_id -) -{ -accels -. -insert -( -next_id -accel -) -; -update_special_accel -( -& -mut -self -. -special -next_id -) -; -/ -/ -No -need -to -do -any -actual -swapping -for -equivalent -IDs -. -if -cur_id -! -= -next_id -{ -remapper -. -swap -( -self -cur_id -next_id -) -; -/ -/ -Swap -pattern -IDs -for -match -states -. -let -cur_pids -= -new_matches -. -remove -( -& -cur_id -) -. -unwrap -( -) -; -let -next_pids -= -new_matches -. -remove -( -& -next_id -) -. -unwrap -( -) -; -new_matches -. -insert -( -cur_id -next_pids -) -; -new_matches -. -insert -( -next_id -cur_pids -) -; -} -next_id -= -self -. -tt -. -prev_state_id -( -next_id -) -; -} -cur_id -= -self -. -tt -. -prev_state_id -( -cur_id -) -; -} -} -/ -/ -This -is -where -it -gets -tricky -. -Without -acceleration -start -states -/ -/ -normally -come -right -after -match -states -. -But -we -want -accelerated -/ -/ -states -to -be -a -single -contiguous -range -( -to -make -it -very -fast -/ -/ -to -determine -whether -a -state -* -is -* -accelerated -) -while -also -keeping -/ -/ -match -and -starting -states -as -contiguous -ranges -for -the -same -reason -. -/ -/ -So -what -we -do -here -is -shuffle -states -such -that -it -looks -like -this -: -/ -/ -/ -/ -DQMMMMAAAAASSSSSSNNNNNNN -/ -/ -| -| -/ -/ -| -- -- -- -- -- -- -- -- -- -| -/ -/ -accelerated -states -/ -/ -/ -/ -Where -: -/ -/ -D -- -dead -state -/ -/ -Q -- -quit -state -/ -/ -M -- -match -state -( -may -be -accelerated -) -/ -/ -A -- -normal -state -that -is -accelerated -/ -/ -S -- -start -state -( -may -be -accelerated -) -/ -/ -N -- -normal -state -that -is -NOT -accelerated -/ -/ -/ -/ -We -implement -this -by -shuffling -states -which -is -done -by -a -sequence -/ -/ -of -pairwise -swaps -. -We -start -by -looking -at -all -normal -states -to -be -/ -/ -accelerated -. -When -we -find -one -we -swap -it -with -the -earliest -starting -/ -/ -state -and -then -swap -that -with -the -earliest -normal -state -. -This -/ -/ -preserves -the -contiguous -property -. -/ -/ -/ -/ -Once -we -' -re -done -looking -for -accelerated -normal -states -now -we -look -/ -/ -for -accelerated -starting -states -by -moving -them -to -the -beginning -/ -/ -of -the -starting -state -range -( -just -like -we -moved -accelerated -match -/ -/ -states -to -the -end -of -the -matching -state -range -) -. -/ -/ -/ -/ -For -a -more -detailed -/ -different -perspective -on -this -see -the -docs -/ -/ -in -dfa -/ -special -. -rs -. -if -cnormal -> -0 -{ -/ -/ -our -next -available -starting -and -normal -states -for -swapping -. -let -mut -next_start_id -= -self -. -special -. -min_start -; -let -mut -cur_id -= -self -. -to_state_id -( -self -. -state_len -( -) -- -1 -) -; -/ -/ -This -is -guaranteed -to -exist -since -cnormal -> -0 -. -let -mut -next_norm_id -= -self -. -tt -. -next_state_id -( -self -. -special -. -max_start -) -; -while -cur_id -> -= -next_norm_id -{ -if -let -Some -( -accel -) -= -accels -. -remove -( -& -cur_id -) -{ -remapper -. -swap -( -self -next_start_id -cur_id -) -; -remapper -. -swap -( -self -next_norm_id -cur_id -) -; -/ -/ -Keep -our -accelerator -map -updated -with -new -IDs -if -the -/ -/ -states -we -swapped -were -also -accelerated -. -if -let -Some -( -accel2 -) -= -accels -. -remove -( -& -next_norm_id -) -{ -accels -. -insert -( -cur_id -accel2 -) -; -} -if -let -Some -( -accel2 -) -= -accels -. -remove -( -& -next_start_id -) -{ -accels -. -insert -( -next_norm_id -accel2 -) -; -} -accels -. -insert -( -next_start_id -accel -) -; -update_special_accel -( -& -mut -self -. -special -next_start_id -) -; -/ -/ -Our -start -range -shifts -one -to -the -right -now -. -self -. -special -. -min_start -= -self -. -tt -. -next_state_id -( -self -. -special -. -min_start -) -; -self -. -special -. -max_start -= -self -. -tt -. -next_state_id -( -self -. -special -. -max_start -) -; -next_start_id -= -self -. -tt -. -next_state_id -( -next_start_id -) -; -next_norm_id -= -self -. -tt -. -next_state_id -( -next_norm_id -) -; -} -/ -/ -This -is -pretty -tricky -but -if -our -' -next_norm_id -' -state -also -/ -/ -happened -to -be -accelerated -then -the -result -is -that -it -is -/ -/ -now -in -the -position -of -cur_id -so -we -need -to -consider -it -/ -/ -again -. -This -loop -is -still -guaranteed -to -terminate -though -/ -/ -because -when -accels -contains -cur_id -we -' -re -guaranteed -to -/ -/ -increment -next_norm_id -even -if -cur_id -remains -unchanged -. -if -! -accels -. -contains_key -( -& -cur_id -) -{ -cur_id -= -self -. -tt -. -prev_state_id -( -cur_id -) -; -} -} -} -/ -/ -Just -like -we -did -for -match -states -but -we -want -to -move -accelerated -/ -/ -start -states -to -the -beginning -of -the -range -instead -of -the -end -. -if -cstart -> -0 -{ -/ -/ -N -. -B -. -special -. -{ -min -max -} -_start -do -not -need -updating -since -the -/ -/ -range -/ -number -of -start -states -does -not -change -at -this -point -. -Only -/ -/ -the -ordering -of -start -states -may -change -. -let -mut -next_id -= -self -. -special -. -min_start -; -let -mut -cur_id -= -next_id -; -while -cur_id -< -= -self -. -special -. -max_start -{ -if -let -Some -( -accel -) -= -accels -. -remove -( -& -cur_id -) -{ -remapper -. -swap -( -self -cur_id -next_id -) -; -accels -. -insert -( -next_id -accel -) -; -update_special_accel -( -& -mut -self -. -special -next_id -) -; -next_id -= -self -. -tt -. -next_state_id -( -next_id -) -; -} -cur_id -= -self -. -tt -. -next_state_id -( -cur_id -) -; -} -} -/ -/ -Remap -all -transitions -in -our -DFA -and -assert -some -things -. -remapper -. -remap -( -self -) -; -/ -/ -This -unwrap -is -OK -because -acceleration -never -changes -the -number -of -/ -/ -match -states -or -patterns -in -those -match -states -. -Since -acceleration -/ -/ -runs -after -the -pattern -map -has -been -set -at -least -once -we -know -that -/ -/ -our -match -states -cannot -error -. -self -. -set_pattern_map -( -& -new_matches -) -. -unwrap -( -) -; -self -. -special -. -set_max -( -) -; -self -. -special -. -validate -( -) -. -expect -( -" -special -state -ranges -should -validate -" -) -; -self -. -special -. -validate_state_len -( -self -. -state_len -( -) -self -. -stride2 -( -) -) -. -expect -( -" -special -state -ranges -should -be -consistent -with -state -length -" -) -; -assert_eq -! -( -self -. -special -. -accel_len -( -self -. -stride -( -) -) -/ -/ -We -record -the -number -of -accelerated -states -initially -detected -/ -/ -since -the -accels -map -is -itself -mutated -in -the -process -above -. -/ -/ -If -mutated -incorrectly -its -size -may -change -and -thus -can -' -t -be -/ -/ -trusted -as -a -source -of -truth -of -how -many -accelerated -states -we -/ -/ -expected -there -to -be -. -original_accels_len -" -mismatch -with -expected -number -of -accelerated -states -" -) -; -/ -/ -And -finally -record -our -accelerators -. -We -kept -our -accels -map -updated -/ -/ -as -we -shuffled -states -above -so -the -accelerators -should -now -/ -/ -correspond -to -a -contiguous -range -in -the -state -ID -space -. -( -Which -we -/ -/ -assert -. -) -let -mut -prev -: -Option -< -StateID -> -= -None -; -for -( -id -accel -) -in -accels -{ -assert -! -( -prev -. -map_or -( -true -| -p -| -self -. -tt -. -next_state_id -( -p -) -= -= -id -) -) -; -prev -= -Some -( -id -) -; -self -. -accels -. -add -( -accel -) -; -} -} -/ -/ -/ -Shuffle -the -states -in -this -DFA -so -that -starting -states -match -/ -/ -/ -states -and -accelerated -states -are -all -contiguous -. -/ -/ -/ -/ -/ -/ -See -dfa -/ -special -. -rs -for -more -details -. -pub -( -crate -) -fn -shuffle -( -& -mut -self -mut -matches -: -BTreeMap -< -StateID -Vec -< -PatternID -> -> -) -- -> -Result -< -( -) -BuildError -> -{ -/ -/ -The -determinizer -always -adds -a -quit -state -and -it -is -always -second -. -self -. -special -. -quit_id -= -self -. -to_state_id -( -1 -) -; -/ -/ -If -all -we -have -are -the -dead -and -quit -states -then -we -' -re -done -and -/ -/ -the -DFA -will -never -produce -a -match -. -if -self -. -state_len -( -) -< -= -2 -{ -self -. -special -. -set_max -( -) -; -return -Ok -( -( -) -) -; -} -/ -/ -Collect -all -our -non -- -DEAD -start -states -into -a -convenient -set -and -/ -/ -confirm -there -is -no -overlap -with -match -states -. -In -the -classicl -DFA -/ -/ -construction -start -states -can -be -match -states -. -But -because -of -/ -/ -look -- -around -we -delay -all -matches -by -a -byte -which -prevents -start -/ -/ -states -from -being -match -states -. -let -mut -is_start -: -BTreeSet -< -StateID -> -= -BTreeSet -: -: -new -( -) -; -for -( -start_id -_ -_ -) -in -self -. -starts -( -) -{ -/ -/ -If -a -starting -configuration -points -to -a -DEAD -state -then -we -/ -/ -don -' -t -want -to -shuffle -it -. -The -DEAD -state -is -always -the -first -/ -/ -state -with -ID -= -0 -. -So -we -can -just -leave -it -be -. -if -start_id -= -= -DEAD -{ -continue -; -} -assert -! -( -! -matches -. -contains_key -( -& -start_id -) -" -{ -: -? -} -is -both -a -start -and -a -match -state -which -is -not -allowed -" -start_id -) -; -is_start -. -insert -( -start_id -) -; -} -/ -/ -We -implement -shuffling -by -a -sequence -of -pairwise -swaps -of -states -. -/ -/ -Since -we -have -a -number -of -things -referencing -states -via -their -/ -/ -IDs -and -swapping -them -changes -their -IDs -we -need -to -record -every -/ -/ -swap -we -make -so -that -we -can -remap -IDs -. -The -remapper -handles -this -/ -/ -book -- -keeping -for -us -. -let -mut -remapper -= -Remapper -: -: -new -( -self -) -; -/ -/ -Shuffle -matching -states -. -if -matches -. -is_empty -( -) -{ -self -. -special -. -min_match -= -DEAD -; -self -. -special -. -max_match -= -DEAD -; -} -else -{ -/ -/ -The -determinizer -guarantees -that -the -first -two -states -are -the -/ -/ -dead -and -quit -states -respectively -. -We -want -our -match -states -to -/ -/ -come -right -after -quit -. -let -mut -next_id -= -self -. -to_state_id -( -2 -) -; -let -mut -new_matches -= -BTreeMap -: -: -new -( -) -; -self -. -special -. -min_match -= -next_id -; -for -( -id -pids -) -in -matches -{ -remapper -. -swap -( -self -next_id -id -) -; -new_matches -. -insert -( -next_id -pids -) -; -/ -/ -If -we -swapped -a -start -state -then -update -our -set -. -if -is_start -. -contains -( -& -next_id -) -{ -is_start -. -remove -( -& -next_id -) -; -is_start -. -insert -( -id -) -; -} -next_id -= -self -. -tt -. -next_state_id -( -next_id -) -; -} -matches -= -new_matches -; -self -. -special -. -max_match -= -cmp -: -: -max -( -self -. -special -. -min_match -self -. -tt -. -prev_state_id -( -next_id -) -) -; -} -/ -/ -Shuffle -starting -states -. -{ -let -mut -next_id -= -self -. -to_state_id -( -2 -) -; -if -self -. -special -. -matches -( -) -{ -next_id -= -self -. -tt -. -next_state_id -( -self -. -special -. -max_match -) -; -} -self -. -special -. -min_start -= -next_id -; -for -id -in -is_start -{ -remapper -. -swap -( -self -next_id -id -) -; -next_id -= -self -. -tt -. -next_state_id -( -next_id -) -; -} -self -. -special -. -max_start -= -cmp -: -: -max -( -self -. -special -. -min_start -self -. -tt -. -prev_state_id -( -next_id -) -) -; -} -/ -/ -Finally -remap -all -transitions -in -our -DFA -. -remapper -. -remap -( -self -) -; -self -. -set_pattern_map -( -& -matches -) -? -; -self -. -special -. -set_max -( -) -; -self -. -special -. -validate -( -) -. -expect -( -" -special -state -ranges -should -validate -" -) -; -self -. -special -. -validate_state_len -( -self -. -state_len -( -) -self -. -stride2 -( -) -) -. -expect -( -" -special -state -ranges -should -be -consistent -with -state -length -" -) -; -Ok -( -( -) -) -} -/ -/ -/ -Checks -whether -there -are -universal -start -states -( -both -anchored -and -/ -/ -/ -unanchored -) -and -if -so -sets -the -relevant -fields -to -the -start -state -/ -/ -/ -IDs -. -/ -/ -/ -/ -/ -/ -Universal -start -states -occur -precisely -when -the -all -patterns -in -the -/ -/ -/ -DFA -have -no -look -- -around -assertions -in -their -prefix -. -fn -set_universal_starts -( -& -mut -self -) -{ -assert_eq -! -( -6 -Start -: -: -len -( -) -" -expected -6 -start -configurations -" -) -; -let -start_id -= -| -dfa -: -& -mut -OwnedDFA -inp -: -& -Input -< -' -_ -> -start -: -Start -| -{ -/ -/ -This -OK -because -we -only -call -' -start -' -under -conditions -/ -/ -in -which -we -know -it -will -succeed -. -dfa -. -st -. -start -( -inp -start -) -. -expect -( -" -valid -Input -configuration -" -) -} -; -if -self -. -start_kind -( -) -. -has_unanchored -( -) -{ -let -inp -= -Input -: -: -new -( -" -" -) -. -anchored -( -Anchored -: -: -No -) -; -let -sid -= -start_id -( -self -& -inp -Start -: -: -NonWordByte -) -; -if -sid -= -= -start_id -( -self -& -inp -Start -: -: -WordByte -) -& -& -sid -= -= -start_id -( -self -& -inp -Start -: -: -Text -) -& -& -sid -= -= -start_id -( -self -& -inp -Start -: -: -LineLF -) -& -& -sid -= -= -start_id -( -self -& -inp -Start -: -: -LineCR -) -& -& -sid -= -= -start_id -( -self -& -inp -Start -: -: -CustomLineTerminator -) -{ -self -. -st -. -universal_start_unanchored -= -Some -( -sid -) -; -} -} -if -self -. -start_kind -( -) -. -has_anchored -( -) -{ -let -inp -= -Input -: -: -new -( -" -" -) -. -anchored -( -Anchored -: -: -Yes -) -; -let -sid -= -start_id -( -self -& -inp -Start -: -: -NonWordByte -) -; -if -sid -= -= -start_id -( -self -& -inp -Start -: -: -WordByte -) -& -& -sid -= -= -start_id -( -self -& -inp -Start -: -: -Text -) -& -& -sid -= -= -start_id -( -self -& -inp -Start -: -: -LineLF -) -& -& -sid -= -= -start_id -( -self -& -inp -Start -: -: -LineCR -) -& -& -sid -= -= -start_id -( -self -& -inp -Start -: -: -CustomLineTerminator -) -{ -self -. -st -. -universal_start_anchored -= -Some -( -sid -) -; -} -} -} -} -/ -/ -A -variety -of -generic -internal -methods -for -accessing -DFA -internals -. -impl -< -T -: -AsRef -< -[ -u32 -] -> -> -DFA -< -T -> -{ -/ -/ -/ -Return -the -info -about -special -states -. -pub -( -crate -) -fn -special -( -& -self -) -- -> -& -Special -{ -& -self -. -special -} -/ -/ -/ -Return -the -info -about -special -states -as -a -mutable -borrow -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -special_mut -( -& -mut -self -) -- -> -& -mut -Special -{ -& -mut -self -. -special -} -/ -/ -/ -Returns -the -quit -set -( -may -be -empty -) -used -by -this -DFA -. -pub -( -crate -) -fn -quitset -( -& -self -) -- -> -& -ByteSet -{ -& -self -. -quitset -} -/ -/ -/ -Returns -the -flags -for -this -DFA -. -pub -( -crate -) -fn -flags -( -& -self -) -- -> -& -Flags -{ -& -self -. -flags -} -/ -/ -/ -Returns -an -iterator -over -all -states -in -this -DFA -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -a -tuple -for -each -state -. -The -first -element -of -the -/ -/ -/ -tuple -corresponds -to -a -state -' -s -identifier -and -the -second -element -/ -/ -/ -corresponds -to -the -state -itself -( -comprised -of -its -transitions -) -. -pub -( -crate -) -fn -states -( -& -self -) -- -> -StateIter -< -' -_ -T -> -{ -self -. -tt -. -states -( -) -} -/ -/ -/ -Return -the -total -number -of -states -in -this -DFA -. -Every -DFA -has -at -least -/ -/ -/ -1 -state -even -the -empty -DFA -. -pub -( -crate -) -fn -state_len -( -& -self -) -- -> -usize -{ -self -. -tt -. -len -( -) -} -/ -/ -/ -Return -an -iterator -over -all -pattern -IDs -for -the -given -match -state -. -/ -/ -/ -/ -/ -/ -If -the -given -state -is -not -a -match -state -then -this -panics -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -pattern_id_slice -( -& -self -id -: -StateID -) -- -> -& -[ -PatternID -] -{ -assert -! -( -self -. -is_match_state -( -id -) -) -; -self -. -ms -. -pattern_id_slice -( -self -. -match_state_index -( -id -) -) -} -/ -/ -/ -Return -the -total -number -of -pattern -IDs -for -the -given -match -state -. -/ -/ -/ -/ -/ -/ -If -the -given -state -is -not -a -match -state -then -this -panics -. -pub -( -crate -) -fn -match_pattern_len -( -& -self -id -: -StateID -) -- -> -usize -{ -assert -! -( -self -. -is_match_state -( -id -) -) -; -self -. -ms -. -pattern_len -( -self -. -match_state_index -( -id -) -) -} -/ -/ -/ -Returns -the -total -number -of -patterns -matched -by -this -DFA -. -pub -( -crate -) -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -ms -. -pattern_len -} -/ -/ -/ -Returns -a -map -from -match -state -ID -to -a -list -of -pattern -IDs -that -match -/ -/ -/ -in -that -state -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -pattern_map -( -& -self -) -- -> -BTreeMap -< -StateID -Vec -< -PatternID -> -> -{ -self -. -ms -. -to_map -( -self -) -} -/ -/ -/ -Returns -the -ID -of -the -quit -state -for -this -DFA -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -quit_id -( -& -self -) -- -> -StateID -{ -self -. -to_state_id -( -1 -) -} -/ -/ -/ -Convert -the -given -state -identifier -to -the -state -' -s -index -. -The -state -' -s -/ -/ -/ -index -corresponds -to -the -position -in -which -it -appears -in -the -transition -/ -/ -/ -table -. -When -a -DFA -is -NOT -premultiplied -then -a -state -' -s -identifier -is -/ -/ -/ -also -its -index -. -When -a -DFA -is -premultiplied -then -a -state -' -s -identifier -/ -/ -/ -is -equal -to -index -* -alphabet_len -. -This -routine -reverses -that -. -pub -( -crate -) -fn -to_index -( -& -self -id -: -StateID -) -- -> -usize -{ -self -. -tt -. -to_index -( -id -) -} -/ -/ -/ -Convert -an -index -to -a -state -( -in -the -range -0 -. -. -self -. -state_len -( -) -) -to -an -/ -/ -/ -actual -state -identifier -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -using -a -Vec -< -T -> -as -an -efficient -map -keyed -by -state -/ -/ -/ -to -some -other -information -( -such -as -a -remapped -state -ID -) -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -to_state_id -( -& -self -index -: -usize -) -- -> -StateID -{ -self -. -tt -. -to_state_id -( -index -) -} -/ -/ -/ -Return -the -table -of -state -IDs -for -this -DFA -' -s -start -states -. -pub -( -crate -) -fn -starts -( -& -self -) -- -> -StartStateIter -< -' -_ -> -{ -self -. -st -. -iter -( -) -} -/ -/ -/ -Returns -the -index -of -the -match -state -for -the -given -ID -. -If -the -/ -/ -/ -given -ID -does -not -correspond -to -a -match -state -then -this -may -/ -/ -/ -panic -or -produce -an -incorrect -result -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -match_state_index -( -& -self -id -: -StateID -) -- -> -usize -{ -debug_assert -! -( -self -. -is_match_state -( -id -) -) -; -/ -/ -This -is -one -of -the -places -where -we -rely -on -the -fact -that -match -/ -/ -states -are -contiguous -in -the -transition -table -. -Namely -that -the -/ -/ -first -match -state -ID -always -corresponds -to -dfa -. -special -. -min_match -. -/ -/ -From -there -since -we -know -the -stride -we -can -compute -the -overall -/ -/ -index -of -any -match -state -given -the -match -state -' -s -ID -. -let -min -= -self -. -special -( -) -. -min_match -. -as_usize -( -) -; -/ -/ -CORRECTNESS -: -We -' -re -allowed -to -produce -an -incorrect -result -or -panic -/ -/ -so -both -the -subtraction -and -the -unchecked -StateID -construction -is -/ -/ -OK -. -self -. -to_index -( -StateID -: -: -new_unchecked -( -id -. -as_usize -( -) -- -min -) -) -} -/ -/ -/ -Returns -the -index -of -the -accelerator -state -for -the -given -ID -. -If -the -/ -/ -/ -given -ID -does -not -correspond -to -an -accelerator -state -then -this -may -/ -/ -/ -panic -or -produce -an -incorrect -result -. -fn -accelerator_index -( -& -self -id -: -StateID -) -- -> -usize -{ -let -min -= -self -. -special -( -) -. -min_accel -. -as_usize -( -) -; -/ -/ -CORRECTNESS -: -We -' -re -allowed -to -produce -an -incorrect -result -or -panic -/ -/ -so -both -the -subtraction -and -the -unchecked -StateID -construction -is -/ -/ -OK -. -self -. -to_index -( -StateID -: -: -new_unchecked -( -id -. -as_usize -( -) -- -min -) -) -} -/ -/ -/ -Return -the -accelerators -for -this -DFA -. -fn -accels -( -& -self -) -- -> -Accels -< -& -[ -u32 -] -> -{ -self -. -accels -. -as_ref -( -) -} -/ -/ -/ -Return -this -DFA -' -s -transition -table -as -a -slice -. -fn -trans -( -& -self -) -- -> -& -[ -StateID -] -{ -self -. -tt -. -table -( -) -} -} -impl -< -T -: -AsRef -< -[ -u32 -] -> -> -fmt -: -: -Debug -for -DFA -< -T -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -writeln -! -( -f -" -dense -: -: -DFA -( -" -) -? -; -for -state -in -self -. -states -( -) -{ -fmt_state_indicator -( -f -self -state -. -id -( -) -) -? -; -let -id -= -if -f -. -alternate -( -) -{ -state -. -id -( -) -. -as_usize -( -) -} -else -{ -self -. -to_index -( -state -. -id -( -) -) -} -; -write -! -( -f -" -{ -: -06 -? -} -: -" -id -) -? -; -state -. -fmt -( -f -) -? -; -write -! -( -f -" -\ -n -" -) -? -; -} -writeln -! -( -f -" -" -) -? -; -for -( -i -( -start_id -anchored -sty -) -) -in -self -. -starts -( -) -. -enumerate -( -) -{ -let -id -= -if -f -. -alternate -( -) -{ -start_id -. -as_usize -( -) -} -else -{ -self -. -to_index -( -start_id -) -} -; -if -i -% -self -. -st -. -stride -= -= -0 -{ -match -anchored -{ -Anchored -: -: -No -= -> -writeln -! -( -f -" -START -- -GROUP -( -unanchored -) -" -) -? -Anchored -: -: -Yes -= -> -writeln -! -( -f -" -START -- -GROUP -( -anchored -) -" -) -? -Anchored -: -: -Pattern -( -pid -) -= -> -{ -writeln -! -( -f -" -START_GROUP -( -pattern -: -{ -: -? -} -) -" -pid -) -? -} -} -} -writeln -! -( -f -" -{ -: -? -} -= -> -{ -: -06 -? -} -" -sty -id -) -? -; -} -if -self -. -pattern_len -( -) -> -1 -{ -writeln -! -( -f -" -" -) -? -; -for -i -in -0 -. -. -self -. -ms -. -len -( -) -{ -let -id -= -self -. -ms -. -match_state_id -( -self -i -) -; -let -id -= -if -f -. -alternate -( -) -{ -id -. -as_usize -( -) -} -else -{ -self -. -to_index -( -id -) -} -; -write -! -( -f -" -MATCH -( -{ -: -06 -? -} -) -: -" -id -) -? -; -for -( -i -& -pid -) -in -self -. -ms -. -pattern_id_slice -( -i -) -. -iter -( -) -. -enumerate -( -) -{ -if -i -> -0 -{ -write -! -( -f -" -" -) -? -; -} -write -! -( -f -" -{ -: -? -} -" -pid -) -? -; -} -writeln -! -( -f -" -" -) -? -; -} -} -writeln -! -( -f -" -state -length -: -{ -: -? -} -" -self -. -state_len -( -) -) -? -; -writeln -! -( -f -" -pattern -length -: -{ -: -? -} -" -self -. -pattern_len -( -) -) -? -; -writeln -! -( -f -" -flags -: -{ -: -? -} -" -self -. -flags -) -? -; -writeln -! -( -f -" -) -" -) -? -; -Ok -( -( -) -) -} -} -/ -/ -SAFETY -: -We -assert -that -our -implementation -of -each -method -is -correct -. -unsafe -impl -< -T -: -AsRef -< -[ -u32 -] -> -> -Automaton -for -DFA -< -T -> -{ -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_special_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_special_state -( -id -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_dead_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_dead_state -( -id -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_quit_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_quit_state -( -id -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_match_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_match_state -( -id -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_start_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_start_state -( -id -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_accel_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_accel_state -( -id -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -next_state -( -& -self -current -: -StateID -input -: -u8 -) -- -> -StateID -{ -let -input -= -self -. -byte_classes -( -) -. -get -( -input -) -; -let -o -= -current -. -as_usize -( -) -+ -usize -: -: -from -( -input -) -; -self -. -trans -( -) -[ -o -] -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -unsafe -fn -next_state_unchecked -( -& -self -current -: -StateID -byte -: -u8 -) -- -> -StateID -{ -/ -/ -We -don -' -t -( -or -shouldn -' -t -) -need -an -unchecked -variant -for -the -byte -/ -/ -class -mapping -since -bound -checks -should -be -omitted -automatically -/ -/ -by -virtue -of -its -representation -. -If -this -ends -up -not -being -true -as -/ -/ -confirmed -by -codegen -please -file -an -issue -. -- -- -- -AG -let -class -= -self -. -byte_classes -( -) -. -get -( -byte -) -; -let -o -= -current -. -as_usize -( -) -+ -usize -: -: -from -( -class -) -; -let -next -= -* -self -. -trans -( -) -. -get_unchecked -( -o -) -; -next -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -next_eoi_state -( -& -self -current -: -StateID -) -- -> -StateID -{ -let -eoi -= -self -. -byte_classes -( -) -. -eoi -( -) -. -as_usize -( -) -; -let -o -= -current -. -as_usize -( -) -+ -eoi -; -self -. -trans -( -) -[ -o -] -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -ms -. -pattern_len -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -match_len -( -& -self -id -: -StateID -) -- -> -usize -{ -self -. -match_pattern_len -( -id -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -match_pattern -( -& -self -id -: -StateID -match_index -: -usize -) -- -> -PatternID -{ -/ -/ -This -is -an -optimization -for -the -very -common -case -of -a -DFA -with -a -/ -/ -single -pattern -. -This -conditional -avoids -a -somewhat -more -costly -path -/ -/ -that -finds -the -pattern -ID -from -the -state -machine -which -requires -/ -/ -a -bit -of -slicing -/ -pointer -- -chasing -. -This -optimization -tends -to -only -/ -/ -matter -when -matches -are -frequent -. -if -self -. -ms -. -pattern_len -= -= -1 -{ -return -PatternID -: -: -ZERO -; -} -let -state_index -= -self -. -match_state_index -( -id -) -; -self -. -ms -. -pattern_id -( -state_index -match_index -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -has_empty -( -& -self -) -- -> -bool -{ -self -. -flags -. -has_empty -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_utf8 -( -& -self -) -- -> -bool -{ -self -. -flags -. -is_utf8 -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_always_start_anchored -( -& -self -) -- -> -bool -{ -self -. -flags -. -is_always_start_anchored -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -start_state_forward -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -{ -if -! -self -. -quitset -. -is_empty -( -) -& -& -input -. -start -( -) -> -0 -{ -let -offset -= -input -. -start -( -) -- -1 -; -let -byte -= -input -. -haystack -( -) -[ -offset -] -; -if -self -. -quitset -. -contains -( -byte -) -{ -return -Err -( -MatchError -: -: -quit -( -byte -offset -) -) -; -} -} -let -start -= -self -. -st -. -start_map -. -fwd -( -& -input -) -; -self -. -st -. -start -( -input -start -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -start_state_reverse -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -{ -if -! -self -. -quitset -. -is_empty -( -) -& -& -input -. -end -( -) -< -input -. -haystack -( -) -. -len -( -) -{ -let -offset -= -input -. -end -( -) -; -let -byte -= -input -. -haystack -( -) -[ -offset -] -; -if -self -. -quitset -. -contains -( -byte -) -{ -return -Err -( -MatchError -: -: -quit -( -byte -offset -) -) -; -} -} -let -start -= -self -. -st -. -start_map -. -rev -( -& -input -) -; -self -. -st -. -start -( -input -start -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -universal_start_state -( -& -self -mode -: -Anchored -) -- -> -Option -< -StateID -> -{ -match -mode -{ -Anchored -: -: -No -= -> -self -. -st -. -universal_start_unanchored -Anchored -: -: -Yes -= -> -self -. -st -. -universal_start_anchored -Anchored -: -: -Pattern -( -_ -) -= -> -None -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -accelerator -( -& -self -id -: -StateID -) -- -> -& -[ -u8 -] -{ -if -! -self -. -is_accel_state -( -id -) -{ -return -& -[ -] -; -} -self -. -accels -. -needles -( -self -. -accelerator_index -( -id -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -self -. -pre -. -as_ref -( -) -} -} -/ -/ -/ -The -transition -table -portion -of -a -dense -DFA -. -/ -/ -/ -/ -/ -/ -The -transition -table -is -the -core -part -of -the -DFA -in -that -it -describes -how -/ -/ -/ -to -move -from -one -state -to -another -based -on -the -input -sequence -observed -. -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -TransitionTable -< -T -> -{ -/ -/ -/ -A -contiguous -region -of -memory -representing -the -transition -table -in -/ -/ -/ -row -- -major -order -. -The -representation -is -dense -. -That -is -every -state -/ -/ -/ -has -precisely -the -same -number -of -transitions -. -The -maximum -number -of -/ -/ -/ -transitions -per -state -is -257 -( -256 -for -each -possible -byte -value -plus -1 -/ -/ -/ -for -the -special -EOI -transition -) -. -If -a -DFA -has -been -instructed -to -use -/ -/ -/ -byte -classes -( -the -default -) -then -the -number -of -transitions -is -usually -/ -/ -/ -substantially -fewer -. -/ -/ -/ -/ -/ -/ -In -practice -T -is -either -Vec -< -u32 -> -or -& -[ -u32 -] -. -table -: -T -/ -/ -/ -A -set -of -equivalence -classes -where -a -single -equivalence -class -/ -/ -/ -represents -a -set -of -bytes -that -never -discriminate -between -a -match -/ -/ -/ -and -a -non -- -match -in -the -DFA -. -Each -equivalence -class -corresponds -to -a -/ -/ -/ -single -character -in -this -DFA -' -s -alphabet -where -the -maximum -number -of -/ -/ -/ -characters -is -257 -( -each -possible -value -of -a -byte -plus -the -special -/ -/ -/ -EOI -transition -) -. -Consequently -the -number -of -equivalence -classes -/ -/ -/ -corresponds -to -the -number -of -transitions -for -each -DFA -state -. -Note -/ -/ -/ -though -that -the -* -space -* -used -by -each -DFA -state -in -the -transition -table -/ -/ -/ -may -be -larger -. -The -total -space -used -by -each -DFA -state -is -known -as -the -/ -/ -/ -stride -. -/ -/ -/ -/ -/ -/ -The -only -time -the -number -of -equivalence -classes -is -fewer -than -257 -is -if -/ -/ -/ -the -DFA -' -s -kind -uses -byte -classes -( -which -is -the -default -) -. -Equivalence -/ -/ -/ -classes -should -generally -only -be -disabled -when -debugging -so -that -/ -/ -/ -the -transitions -themselves -aren -' -t -obscured -. -Disabling -them -has -no -/ -/ -/ -other -benefit -since -the -equivalence -class -map -is -always -used -while -/ -/ -/ -searching -. -In -the -vast -majority -of -cases -the -number -of -equivalence -/ -/ -/ -classes -is -substantially -smaller -than -257 -particularly -when -large -/ -/ -/ -Unicode -classes -aren -' -t -used -. -classes -: -ByteClasses -/ -/ -/ -The -stride -of -each -DFA -state -expressed -as -a -power -- -of -- -two -exponent -. -/ -/ -/ -/ -/ -/ -The -stride -of -a -DFA -corresponds -to -the -total -amount -of -space -used -by -/ -/ -/ -each -DFA -state -in -the -transition -table -. -This -may -be -bigger -than -the -/ -/ -/ -size -of -a -DFA -' -s -alphabet -since -the -stride -is -always -the -smallest -/ -/ -/ -power -of -two -greater -than -or -equal -to -the -alphabet -size -. -/ -/ -/ -/ -/ -/ -While -this -wastes -space -this -avoids -the -need -for -integer -division -/ -/ -/ -to -convert -between -premultiplied -state -IDs -and -their -corresponding -/ -/ -/ -indices -. -Instead -we -can -use -simple -bit -- -shifts -. -/ -/ -/ -/ -/ -/ -See -the -docs -for -the -stride2 -method -for -more -details -. -/ -/ -/ -/ -/ -/ -The -minimum -stride2 -value -is -1 -( -corresponding -to -a -stride -of -2 -) -/ -/ -/ -while -the -maximum -stride2 -value -is -9 -( -corresponding -to -a -stride -of -/ -/ -/ -512 -) -. -The -maximum -is -not -8 -since -the -maximum -alphabet -size -is -257 -/ -/ -/ -when -accounting -for -the -special -EOI -transition -. -However -an -alphabet -/ -/ -/ -length -of -that -size -is -exceptionally -rare -since -the -alphabet -is -shrunk -/ -/ -/ -into -equivalence -classes -. -stride2 -: -usize -} -impl -< -' -a -> -TransitionTable -< -& -' -a -[ -u32 -] -> -{ -/ -/ -/ -Deserialize -a -transition -table -starting -at -the -beginning -of -slice -. -/ -/ -/ -Upon -success -return -the -total -number -of -bytes -read -along -with -the -/ -/ -/ -transition -table -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -deserializing -any -part -of -the -transition -table -/ -/ -/ -then -this -returns -an -error -. -Notably -if -the -given -slice -does -not -have -/ -/ -/ -the -same -alignment -as -StateID -then -this -will -return -an -error -( -among -/ -/ -/ -other -possible -errors -) -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -execute -in -constant -time -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -This -routine -is -not -safe -because -it -does -not -check -the -validity -of -the -/ -/ -/ -transition -table -itself -. -In -particular -the -transition -table -can -be -/ -/ -/ -quite -large -so -checking -its -validity -can -be -somewhat -expensive -. -An -/ -/ -/ -invalid -transition -table -is -not -safe -because -other -code -may -rely -on -the -/ -/ -/ -transition -table -being -correct -( -such -as -explicit -bounds -check -elision -) -. -/ -/ -/ -Therefore -an -invalid -transition -table -can -lead -to -undefined -behavior -. -/ -/ -/ -/ -/ -/ -Callers -that -use -this -function -must -either -pass -on -the -safety -invariant -/ -/ -/ -or -guarantee -that -the -bytes -given -contain -a -valid -transition -table -. -/ -/ -/ -This -guarantee -is -upheld -by -the -bytes -written -by -write_to -. -unsafe -fn -from_bytes_unchecked -( -mut -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -TransitionTable -< -& -' -a -[ -u32 -] -> -usize -) -DeserializeError -> -{ -let -slice_start -= -slice -. -as_ptr -( -) -. -as_usize -( -) -; -let -( -state_len -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -state -length -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -stride2 -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -stride2 -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -classes -nr -) -= -ByteClasses -: -: -from_bytes -( -slice -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -/ -/ -The -alphabet -length -( -determined -by -the -byte -class -map -) -cannot -be -/ -/ -bigger -than -the -stride -( -total -space -used -by -each -DFA -state -) -. -if -stride2 -> -9 -{ -return -Err -( -DeserializeError -: -: -generic -( -" -dense -DFA -has -invalid -stride2 -( -too -big -) -" -) -) -; -} -/ -/ -It -also -cannot -be -zero -since -even -a -DFA -that -never -matches -anything -/ -/ -has -a -non -- -zero -number -of -states -with -at -least -two -equivalence -/ -/ -classes -: -one -for -all -256 -byte -values -and -another -for -the -EOI -/ -/ -sentinel -. -if -stride2 -< -1 -{ -return -Err -( -DeserializeError -: -: -generic -( -" -dense -DFA -has -invalid -stride2 -( -too -small -) -" -) -) -; -} -/ -/ -This -is -OK -since -1 -< -= -stride2 -< -= -9 -. -let -stride -= -1usize -. -checked_shl -( -u32 -: -: -try_from -( -stride2 -) -. -unwrap -( -) -) -. -unwrap -( -) -; -if -classes -. -alphabet_len -( -) -> -stride -{ -return -Err -( -DeserializeError -: -: -generic -( -" -alphabet -size -cannot -be -bigger -than -transition -table -stride -" -) -) -; -} -let -trans_len -= -wire -: -: -shl -( -state_len -stride2 -" -dense -table -transition -length -" -) -? -; -let -table_bytes_len -= -wire -: -: -mul -( -trans_len -StateID -: -: -SIZE -" -dense -table -state -byte -length -" -) -? -; -wire -: -: -check_slice_len -( -slice -table_bytes_len -" -transition -table -" -) -? -; -wire -: -: -check_alignment -: -: -< -StateID -> -( -slice -) -? -; -let -table_bytes -= -& -slice -[ -. -. -table_bytes_len -] -; -slice -= -& -slice -[ -table_bytes_len -. -. -] -; -/ -/ -SAFETY -: -Since -StateID -is -always -representable -as -a -u32 -all -we -need -/ -/ -to -do -is -ensure -that -we -have -the -proper -length -and -alignment -. -We -' -ve -/ -/ -checked -both -above -so -the -cast -below -is -safe -. -/ -/ -/ -/ -N -. -B -. -This -is -the -only -not -- -safe -code -in -this -function -. -let -table -= -core -: -: -slice -: -: -from_raw_parts -( -table_bytes -. -as_ptr -( -) -. -cast -: -: -< -u32 -> -( -) -trans_len -) -; -let -tt -= -TransitionTable -{ -table -classes -stride2 -} -; -Ok -( -( -tt -slice -. -as_ptr -( -) -. -as_usize -( -) -- -slice_start -) -) -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -TransitionTable -< -Vec -< -u32 -> -> -{ -/ -/ -/ -Create -a -minimal -transition -table -with -just -two -states -: -a -dead -state -/ -/ -/ -and -a -quit -state -. -The -alphabet -length -and -stride -of -the -transition -/ -/ -/ -table -is -determined -by -the -given -set -of -equivalence -classes -. -fn -minimal -( -classes -: -ByteClasses -) -- -> -TransitionTable -< -Vec -< -u32 -> -> -{ -let -mut -tt -= -TransitionTable -{ -table -: -vec -! -[ -] -classes -stride2 -: -classes -. -stride2 -( -) -} -; -/ -/ -Two -states -regardless -of -alphabet -size -can -always -fit -into -u32 -. -tt -. -add_empty_state -( -) -. -unwrap -( -) -; -/ -/ -dead -state -tt -. -add_empty_state -( -) -. -unwrap -( -) -; -/ -/ -quit -state -tt -} -/ -/ -/ -Set -a -transition -in -this -table -. -Both -the -from -and -to -states -must -/ -/ -/ -already -exist -otherwise -this -panics -. -unit -should -correspond -to -the -/ -/ -/ -transition -out -of -from -to -set -to -to -. -fn -set -( -& -mut -self -from -: -StateID -unit -: -alphabet -: -: -Unit -to -: -StateID -) -{ -assert -! -( -self -. -is_valid -( -from -) -" -invalid -' -from -' -state -" -) -; -assert -! -( -self -. -is_valid -( -to -) -" -invalid -' -to -' -state -" -) -; -self -. -table -[ -from -. -as_usize -( -) -+ -self -. -classes -. -get_by_unit -( -unit -) -] -= -to -. -as_u32 -( -) -; -} -/ -/ -/ -Add -an -empty -state -( -a -state -where -all -transitions -lead -to -a -dead -state -) -/ -/ -/ -and -return -its -identifier -. -The -identifier -returned -is -guaranteed -to -/ -/ -/ -not -point -to -any -other -existing -state -. -/ -/ -/ -/ -/ -/ -If -adding -a -state -would -exhaust -the -state -identifier -space -then -this -/ -/ -/ -returns -an -error -. -fn -add_empty_state -( -& -mut -self -) -- -> -Result -< -StateID -BuildError -> -{ -/ -/ -Normally -to -get -a -fresh -state -identifier -we -would -just -/ -/ -take -the -index -of -the -next -state -added -to -the -transition -/ -/ -table -. -However -we -actually -perform -an -optimization -here -/ -/ -that -premultiplies -state -IDs -by -the -stride -such -that -they -/ -/ -point -immediately -at -the -beginning -of -their -transitions -in -/ -/ -the -transition -table -. -This -avoids -an -extra -multiplication -/ -/ -instruction -for -state -lookup -at -search -time -. -/ -/ -/ -/ -Premultiplied -identifiers -means -that -instead -of -your -matching -/ -/ -loop -looking -something -like -this -: -/ -/ -/ -/ -state -= -dfa -. -start -/ -/ -for -byte -in -haystack -: -/ -/ -next -= -dfa -. -transitions -[ -state -* -stride -+ -byte -] -/ -/ -if -dfa -. -is_match -( -next -) -: -/ -/ -return -true -/ -/ -return -false -/ -/ -/ -/ -it -can -instead -look -like -this -: -/ -/ -/ -/ -state -= -dfa -. -start -/ -/ -for -byte -in -haystack -: -/ -/ -next -= -dfa -. -transitions -[ -state -+ -byte -] -/ -/ -if -dfa -. -is_match -( -next -) -: -/ -/ -return -true -/ -/ -return -false -/ -/ -/ -/ -In -other -words -we -save -a -multiplication -instruction -in -the -/ -/ -critical -path -. -This -turns -out -to -be -a -decent -performance -win -. -/ -/ -The -cost -of -using -premultiplied -state -ids -is -that -they -can -/ -/ -require -a -bigger -state -id -representation -. -( -And -they -also -make -/ -/ -the -code -a -bit -more -complex -especially -during -minimization -and -/ -/ -when -reshuffling -states -as -one -needs -to -convert -back -and -forth -/ -/ -between -state -IDs -and -state -indices -. -) -/ -/ -/ -/ -To -do -this -we -simply -take -the -index -of -the -state -into -the -/ -/ -entire -transition -table -rather -than -the -index -of -the -state -/ -/ -itself -. -e -. -g -. -If -the -stride -is -64 -then -the -ID -of -the -3rd -state -/ -/ -is -192 -not -2 -. -let -next -= -self -. -table -. -len -( -) -; -let -id -= -StateID -: -: -new -( -next -) -. -map_err -( -| -_ -| -BuildError -: -: -too_many_states -( -) -) -? -; -self -. -table -. -extend -( -iter -: -: -repeat -( -0 -) -. -take -( -self -. -stride -( -) -) -) -; -Ok -( -id -) -} -/ -/ -/ -Swap -the -two -states -given -in -this -transition -table -. -/ -/ -/ -/ -/ -/ -This -routine -does -not -do -anything -to -check -the -correctness -of -this -/ -/ -/ -swap -. -Callers -must -ensure -that -other -states -pointing -to -id1 -and -id2 -are -/ -/ -/ -updated -appropriately -. -/ -/ -/ -/ -/ -/ -Both -id1 -and -id2 -must -point -to -valid -states -otherwise -this -panics -. -fn -swap -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -{ -assert -! -( -self -. -is_valid -( -id1 -) -" -invalid -' -id1 -' -state -: -{ -: -? -} -" -id1 -) -; -assert -! -( -self -. -is_valid -( -id2 -) -" -invalid -' -id2 -' -state -: -{ -: -? -} -" -id2 -) -; -/ -/ -We -only -need -to -swap -the -parts -of -the -state -that -are -used -. -So -if -the -/ -/ -stride -is -64 -but -the -alphabet -length -is -only -33 -then -we -save -a -lot -/ -/ -of -work -. -for -b -in -0 -. -. -self -. -classes -. -alphabet_len -( -) -{ -self -. -table -. -swap -( -id1 -. -as_usize -( -) -+ -b -id2 -. -as_usize -( -) -+ -b -) -; -} -} -/ -/ -/ -Remap -the -transitions -for -the -state -given -according -to -the -function -/ -/ -/ -given -. -This -applies -the -given -map -function -to -every -transition -in -the -/ -/ -/ -given -state -and -changes -the -transition -in -place -to -the -result -of -the -/ -/ -/ -map -function -for -that -transition -. -fn -remap -( -& -mut -self -id -: -StateID -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -{ -for -byte -in -0 -. -. -self -. -alphabet_len -( -) -{ -let -i -= -id -. -as_usize -( -) -+ -byte -; -let -next -= -self -. -table -( -) -[ -i -] -; -self -. -table_mut -( -) -[ -id -. -as_usize -( -) -+ -byte -] -= -map -( -next -) -; -} -} -/ -/ -/ -Truncate -the -states -in -this -transition -table -to -the -given -length -. -/ -/ -/ -/ -/ -/ -This -routine -does -not -do -anything -to -check -the -correctness -of -this -/ -/ -/ -truncation -. -Callers -must -ensure -that -other -states -pointing -to -truncated -/ -/ -/ -states -are -updated -appropriately -. -fn -truncate -( -& -mut -self -len -: -usize -) -{ -self -. -table -. -truncate -( -len -< -< -self -. -stride2 -) -; -} -} -impl -< -T -: -AsRef -< -[ -u32 -] -> -> -TransitionTable -< -T -> -{ -/ -/ -/ -Writes -a -serialized -form -of -this -transition -table -to -the -buffer -given -. -/ -/ -/ -If -the -buffer -is -too -small -then -an -error -is -returned -. -To -determine -/ -/ -/ -how -big -the -buffer -must -be -use -write_to_len -. -fn -write_to -< -E -: -Endian -> -( -& -self -mut -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -transition -table -" -) -) -; -} -dst -= -& -mut -dst -[ -. -. -nwrite -] -; -/ -/ -write -state -length -/ -/ -Unwrap -is -OK -since -number -of -states -is -guaranteed -to -fit -in -a -u32 -. -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -len -( -) -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -state -stride -( -as -power -of -2 -) -/ -/ -Unwrap -is -OK -since -stride2 -is -guaranteed -to -be -< -= -9 -. -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -stride2 -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -byte -class -map -let -n -= -self -. -classes -. -write_to -( -dst -) -? -; -dst -= -& -mut -dst -[ -n -. -. -] -; -/ -/ -write -actual -transitions -for -& -sid -in -self -. -table -( -) -{ -let -n -= -wire -: -: -write_state_id -: -: -< -E -> -( -sid -& -mut -dst -) -; -dst -= -& -mut -dst -[ -n -. -. -] -; -} -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -number -of -bytes -the -serialized -form -of -this -transition -/ -/ -/ -table -will -use -. -fn -write_to_len -( -& -self -) -- -> -usize -{ -size_of -: -: -< -u32 -> -( -) -/ -/ -state -length -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -stride2 -+ -self -. -classes -. -write_to_len -( -) -+ -( -self -. -table -( -) -. -len -( -) -* -StateID -: -: -SIZE -) -} -/ -/ -/ -Validates -that -every -state -ID -in -this -transition -table -is -valid -. -/ -/ -/ -/ -/ -/ -That -is -every -state -ID -can -be -used -to -correctly -index -a -state -in -this -/ -/ -/ -table -. -fn -validate -( -& -self -sp -: -& -Special -) -- -> -Result -< -( -) -DeserializeError -> -{ -for -state -in -self -. -states -( -) -{ -/ -/ -We -check -that -the -ID -itself -is -well -formed -. -That -is -if -it -' -s -/ -/ -a -special -state -then -it -must -actually -be -a -quit -dead -accel -/ -/ -match -or -start -state -. -if -sp -. -is_special_state -( -state -. -id -( -) -) -{ -let -is_actually_special -= -sp -. -is_dead_state -( -state -. -id -( -) -) -| -| -sp -. -is_quit_state -( -state -. -id -( -) -) -| -| -sp -. -is_match_state -( -state -. -id -( -) -) -| -| -sp -. -is_start_state -( -state -. -id -( -) -) -| -| -sp -. -is_accel_state -( -state -. -id -( -) -) -; -if -! -is_actually_special -{ -/ -/ -This -is -kind -of -a -cryptic -error -message -. -. -. -return -Err -( -DeserializeError -: -: -generic -( -" -found -dense -state -tagged -as -special -but -\ -wasn -' -t -actually -special -" -) -) -; -} -} -for -( -_ -to -) -in -state -. -transitions -( -) -{ -if -! -self -. -is_valid -( -to -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -found -invalid -state -ID -in -transition -table -" -) -) -; -} -} -} -Ok -( -( -) -) -} -/ -/ -/ -Converts -this -transition -table -to -a -borrowed -value -. -fn -as_ref -( -& -self -) -- -> -TransitionTable -< -& -' -_ -[ -u32 -] -> -{ -TransitionTable -{ -table -: -self -. -table -. -as_ref -( -) -classes -: -self -. -classes -. -clone -( -) -stride2 -: -self -. -stride2 -} -} -/ -/ -/ -Converts -this -transition -table -to -an -owned -value -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -fn -to_owned -( -& -self -) -- -> -TransitionTable -< -alloc -: -: -vec -: -: -Vec -< -u32 -> -> -{ -TransitionTable -{ -table -: -self -. -table -. -as_ref -( -) -. -to_vec -( -) -classes -: -self -. -classes -. -clone -( -) -stride2 -: -self -. -stride2 -} -} -/ -/ -/ -Return -the -state -for -the -given -ID -. -If -the -given -ID -is -not -valid -then -/ -/ -/ -this -panics -. -fn -state -( -& -self -id -: -StateID -) -- -> -State -< -' -_ -> -{ -assert -! -( -self -. -is_valid -( -id -) -) -; -let -i -= -id -. -as_usize -( -) -; -State -{ -id -stride2 -: -self -. -stride2 -transitions -: -& -self -. -table -( -) -[ -i -. -. -i -+ -self -. -alphabet_len -( -) -] -} -} -/ -/ -/ -Returns -an -iterator -over -all -states -in -this -transition -table -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -a -tuple -for -each -state -. -The -first -element -of -the -/ -/ -/ -tuple -corresponds -to -a -state -' -s -identifier -and -the -second -element -/ -/ -/ -corresponds -to -the -state -itself -( -comprised -of -its -transitions -) -. -fn -states -( -& -self -) -- -> -StateIter -< -' -_ -T -> -{ -StateIter -{ -tt -: -self -it -: -self -. -table -( -) -. -chunks -( -self -. -stride -( -) -) -. -enumerate -( -) -} -} -/ -/ -/ -Convert -a -state -identifier -to -an -index -to -a -state -( -in -the -range -/ -/ -/ -0 -. -. -self -. -len -( -) -) -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -using -a -Vec -< -T -> -as -an -efficient -map -keyed -by -state -/ -/ -/ -to -some -other -information -( -such -as -a -remapped -state -ID -) -. -/ -/ -/ -/ -/ -/ -If -the -given -ID -is -not -valid -then -this -may -panic -or -produce -an -/ -/ -/ -incorrect -index -. -fn -to_index -( -& -self -id -: -StateID -) -- -> -usize -{ -id -. -as_usize -( -) -> -> -self -. -stride2 -} -/ -/ -/ -Convert -an -index -to -a -state -( -in -the -range -0 -. -. -self -. -len -( -) -) -to -an -actual -/ -/ -/ -state -identifier -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -using -a -Vec -< -T -> -as -an -efficient -map -keyed -by -state -/ -/ -/ -to -some -other -information -( -such -as -a -remapped -state -ID -) -. -/ -/ -/ -/ -/ -/ -If -the -given -index -is -not -in -the -specified -range -then -this -may -panic -/ -/ -/ -or -produce -an -incorrect -state -ID -. -fn -to_state_id -( -& -self -index -: -usize -) -- -> -StateID -{ -/ -/ -CORRECTNESS -: -If -the -given -index -is -not -valid -then -it -is -not -/ -/ -required -for -this -to -panic -or -return -a -valid -state -ID -. -StateID -: -: -new_unchecked -( -index -< -< -self -. -stride2 -) -} -/ -/ -/ -Returns -the -state -ID -for -the -state -immediately -following -the -one -given -. -/ -/ -/ -/ -/ -/ -This -does -not -check -whether -the -state -ID -returned -is -invalid -. -In -fact -/ -/ -/ -if -the -state -ID -given -is -the -last -state -in -this -DFA -then -the -state -ID -/ -/ -/ -returned -is -guaranteed -to -be -invalid -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -next_state_id -( -& -self -id -: -StateID -) -- -> -StateID -{ -self -. -to_state_id -( -self -. -to_index -( -id -) -. -checked_add -( -1 -) -. -unwrap -( -) -) -} -/ -/ -/ -Returns -the -state -ID -for -the -state -immediately -preceding -the -one -given -. -/ -/ -/ -/ -/ -/ -If -the -dead -ID -given -( -which -is -zero -) -then -this -panics -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -prev_state_id -( -& -self -id -: -StateID -) -- -> -StateID -{ -self -. -to_state_id -( -self -. -to_index -( -id -) -. -checked_sub -( -1 -) -. -unwrap -( -) -) -} -/ -/ -/ -Returns -the -table -as -a -slice -of -state -IDs -. -fn -table -( -& -self -) -- -> -& -[ -StateID -] -{ -wire -: -: -u32s_to_state_ids -( -self -. -table -. -as_ref -( -) -) -} -/ -/ -/ -Returns -the -total -number -of -states -in -this -transition -table -. -/ -/ -/ -/ -/ -/ -Note -that -a -DFA -always -has -at -least -two -states -: -the -dead -and -quit -/ -/ -/ -states -. -In -particular -the -dead -state -always -has -ID -0 -and -is -/ -/ -/ -correspondingly -always -the -first -state -. -The -dead -state -is -never -a -match -/ -/ -/ -state -. -fn -len -( -& -self -) -- -> -usize -{ -self -. -table -( -) -. -len -( -) -> -> -self -. -stride2 -} -/ -/ -/ -Returns -the -total -stride -for -every -state -in -this -DFA -. -This -corresponds -/ -/ -/ -to -the -total -number -of -transitions -used -by -each -state -in -this -DFA -' -s -/ -/ -/ -transition -table -. -fn -stride -( -& -self -) -- -> -usize -{ -1 -< -< -self -. -stride2 -} -/ -/ -/ -Returns -the -total -number -of -elements -in -the -alphabet -for -this -/ -/ -/ -transition -table -. -This -is -always -less -than -or -equal -to -self -. -stride -( -) -. -/ -/ -/ -It -is -only -equal -when -the -alphabet -length -is -a -power -of -2 -. -Otherwise -/ -/ -/ -it -is -always -strictly -less -. -fn -alphabet_len -( -& -self -) -- -> -usize -{ -self -. -classes -. -alphabet_len -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -state -ID -is -valid -for -this -/ -/ -/ -transition -table -. -Validity -in -this -context -means -that -the -given -ID -can -/ -/ -/ -be -used -as -a -valid -offset -with -self -. -stride -( -) -to -index -this -transition -/ -/ -/ -table -. -fn -is_valid -( -& -self -id -: -StateID -) -- -> -bool -{ -let -id -= -id -. -as_usize -( -) -; -id -< -self -. -table -( -) -. -len -( -) -& -& -id -% -self -. -stride -( -) -= -= -0 -} -/ -/ -/ -Return -the -memory -usage -in -bytes -of -this -transition -table -. -/ -/ -/ -/ -/ -/ -This -does -not -include -the -size -of -a -TransitionTable -value -itself -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -table -( -) -. -len -( -) -* -StateID -: -: -SIZE -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -< -T -: -AsMut -< -[ -u32 -] -> -> -TransitionTable -< -T -> -{ -/ -/ -/ -Returns -the -table -as -a -slice -of -state -IDs -. -fn -table_mut -( -& -mut -self -) -- -> -& -mut -[ -StateID -] -{ -wire -: -: -u32s_to_state_ids_mut -( -self -. -table -. -as_mut -( -) -) -} -} -/ -/ -/ -The -set -of -all -possible -starting -states -in -a -DFA -. -/ -/ -/ -/ -/ -/ -The -set -of -starting -states -corresponds -to -the -possible -choices -one -can -make -/ -/ -/ -in -terms -of -starting -a -DFA -. -That -is -before -following -the -first -transition -/ -/ -/ -you -first -need -to -select -the -state -that -you -start -in -. -/ -/ -/ -/ -/ -/ -Normally -a -DFA -converted -from -an -NFA -that -has -a -single -starting -state -/ -/ -/ -would -itself -just -have -one -starting -state -. -However -our -support -for -look -/ -/ -/ -around -generally -requires -more -starting -states -. -The -correct -starting -state -/ -/ -/ -is -chosen -based -on -certain -properties -of -the -position -at -which -we -begin -/ -/ -/ -our -search -. -/ -/ -/ -/ -/ -/ -Before -listing -those -properties -we -first -must -define -two -terms -: -/ -/ -/ -/ -/ -/ -* -haystack -- -The -bytes -to -execute -the -search -. -The -search -always -starts -/ -/ -/ -at -the -beginning -of -haystack -and -ends -before -or -at -the -end -of -/ -/ -/ -haystack -. -/ -/ -/ -* -context -- -The -( -possibly -empty -) -bytes -surrounding -haystack -. -haystack -/ -/ -/ -must -be -contained -within -context -such -that -context -is -at -least -as -big -/ -/ -/ -as -haystack -. -/ -/ -/ -/ -/ -/ -This -split -is -crucial -for -dealing -with -look -- -around -. -For -example -consider -/ -/ -/ -the -context -foobarbaz -the -haystack -bar -and -the -regex -^ -bar -. -This -/ -/ -/ -regex -should -_not_ -match -the -haystack -since -bar -does -not -appear -at -the -/ -/ -/ -beginning -of -the -input -. -Similarly -the -regex -\ -Bbar -\ -B -should -match -the -/ -/ -/ -haystack -because -bar -is -not -surrounded -by -word -boundaries -. -But -a -search -/ -/ -/ -that -does -not -take -context -into -account -would -not -permit -\ -B -to -match -/ -/ -/ -since -the -beginning -of -any -string -matches -a -word -boundary -. -Similarly -a -/ -/ -/ -search -that -does -not -take -context -into -account -when -searching -^ -bar -in -/ -/ -/ -the -haystack -bar -would -produce -a -match -when -it -shouldn -' -t -. -/ -/ -/ -/ -/ -/ -Thus -it -follows -that -the -starting -state -is -chosen -based -on -the -following -/ -/ -/ -criteria -derived -from -the -position -at -which -the -search -starts -in -the -/ -/ -/ -context -( -corresponding -to -the -start -of -haystack -) -: -/ -/ -/ -/ -/ -/ -1 -. -If -the -search -starts -at -the -beginning -of -context -then -the -Text -/ -/ -/ -start -state -is -used -. -( -Since -^ -corresponds -to -/ -/ -/ -hir -: -: -Anchor -: -: -Start -. -) -/ -/ -/ -2 -. -If -the -search -starts -at -a -position -immediately -following -a -line -/ -/ -/ -terminator -then -the -Line -start -state -is -used -. -( -Since -( -? -m -: -^ -) -/ -/ -/ -corresponds -to -hir -: -: -Anchor -: -: -StartLF -. -) -/ -/ -/ -3 -. -If -the -search -starts -at -a -position -immediately -following -a -byte -/ -/ -/ -classified -as -a -" -word -" -character -( -[ -_0 -- -9a -- -zA -- -Z -] -) -then -the -WordByte -/ -/ -/ -start -state -is -used -. -( -Since -( -? -- -u -: -\ -b -) -corresponds -to -a -word -boundary -. -) -/ -/ -/ -4 -. -Otherwise -if -the -search -starts -at -a -position -immediately -following -/ -/ -/ -a -byte -that -is -not -classified -as -a -" -word -" -character -( -[ -^ -_0 -- -9a -- -zA -- -Z -] -) -/ -/ -/ -then -the -NonWordByte -start -state -is -used -. -( -Since -( -? -- -u -: -\ -B -) -/ -/ -/ -corresponds -to -a -not -- -word -- -boundary -. -) -/ -/ -/ -/ -/ -/ -( -N -. -B -. -Unicode -word -boundaries -are -not -supported -by -the -DFA -because -they -/ -/ -/ -require -multi -- -byte -look -- -around -and -this -is -difficult -to -support -in -a -DFA -. -) -/ -/ -/ -/ -/ -/ -To -further -complicate -things -we -also -support -constructing -individual -/ -/ -/ -anchored -start -states -for -each -pattern -in -the -DFA -. -( -Which -is -required -to -/ -/ -/ -implement -overlapping -regexes -correctly -but -is -also -generally -useful -. -) -/ -/ -/ -Thus -when -individual -start -states -for -each -pattern -are -enabled -then -the -/ -/ -/ -total -number -of -start -states -represented -is -4 -+ -( -4 -* -# -patterns -) -where -/ -/ -/ -the -4 -comes -from -each -of -the -4 -possibilities -above -. -The -first -4 -represents -/ -/ -/ -the -starting -states -for -the -entire -DFA -which -support -searching -for -/ -/ -/ -multiple -patterns -simultaneously -( -possibly -unanchored -) -. -/ -/ -/ -/ -/ -/ -If -individual -start -states -are -disabled -then -this -will -only -store -4 -/ -/ -/ -start -states -. -Typically -individual -start -states -are -only -enabled -when -/ -/ -/ -constructing -the -reverse -DFA -for -regex -matching -. -But -they -are -also -useful -/ -/ -/ -for -building -DFAs -that -can -search -for -a -specific -pattern -or -even -to -support -/ -/ -/ -both -anchored -and -unanchored -searches -with -the -same -DFA -. -/ -/ -/ -/ -/ -/ -Note -though -that -while -the -start -table -always -has -either -4 -or -/ -/ -/ -4 -+ -( -4 -* -# -patterns -) -starting -state -* -ids -* -the -total -number -of -states -/ -/ -/ -might -be -considerably -smaller -. -That -is -many -of -the -IDs -may -be -duplicative -. -/ -/ -/ -( -For -example -if -a -regex -doesn -' -t -have -a -\ -b -sub -- -pattern -then -there -' -s -no -/ -/ -/ -reason -to -generate -a -unique -starting -state -for -handling -word -boundaries -. -/ -/ -/ -Similarly -for -start -/ -end -anchors -. -) -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -StartTable -< -T -> -{ -/ -/ -/ -The -initial -start -state -IDs -. -/ -/ -/ -/ -/ -/ -In -practice -T -is -either -Vec -< -u32 -> -or -& -[ -u32 -] -. -/ -/ -/ -/ -/ -/ -The -first -2 -* -stride -( -currently -always -8 -) -entries -always -correspond -/ -/ -/ -to -the -starts -states -for -the -entire -DFA -with -the -first -4 -entries -being -/ -/ -/ -for -unanchored -searches -and -the -second -4 -entries -being -for -anchored -/ -/ -/ -searches -. -To -keep -things -simple -we -always -use -8 -entries -even -if -the -/ -/ -/ -StartKind -is -not -both -. -/ -/ -/ -/ -/ -/ -After -that -there -are -stride -* -patterns -state -IDs -where -patterns -/ -/ -/ -may -be -zero -in -the -case -of -a -DFA -with -no -patterns -or -in -the -case -where -/ -/ -/ -the -DFA -was -built -without -enabling -starting -states -for -each -pattern -. -table -: -T -/ -/ -/ -The -starting -state -configuration -supported -. -When -' -both -' -both -/ -/ -/ -unanchored -and -anchored -searches -work -. -When -' -unanchored -' -anchored -/ -/ -/ -searches -panic -. -When -' -anchored -' -unanchored -searches -panic -. -kind -: -StartKind -/ -/ -/ -The -start -state -configuration -for -every -possible -byte -. -start_map -: -StartByteMap -/ -/ -/ -The -number -of -starting -state -IDs -per -pattern -. -stride -: -usize -/ -/ -/ -The -total -number -of -patterns -for -which -starting -states -are -encoded -. -/ -/ -/ -This -is -None -for -DFAs -that -were -built -without -start -states -for -each -/ -/ -/ -pattern -. -Thus -one -cannot -use -this -field -to -say -how -many -patterns -/ -/ -/ -are -in -the -DFA -in -all -cases -. -It -is -specific -to -how -many -patterns -are -/ -/ -/ -represented -in -this -start -table -. -pattern_len -: -Option -< -usize -> -/ -/ -/ -The -universal -starting -state -for -unanchored -searches -. -This -is -only -/ -/ -/ -present -when -the -DFA -supports -unanchored -searches -and -when -all -starting -/ -/ -/ -state -IDs -for -an -unanchored -search -are -equivalent -. -universal_start_unanchored -: -Option -< -StateID -> -/ -/ -/ -The -universal -starting -state -for -anchored -searches -. -This -is -only -/ -/ -/ -present -when -the -DFA -supports -anchored -searches -and -when -all -starting -/ -/ -/ -state -IDs -for -an -anchored -search -are -equivalent -. -universal_start_anchored -: -Option -< -StateID -> -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -StartTable -< -Vec -< -u32 -> -> -{ -/ -/ -/ -Create -a -valid -set -of -start -states -all -pointing -to -the -dead -state -. -/ -/ -/ -/ -/ -/ -When -the -corresponding -DFA -is -constructed -with -start -states -for -each -/ -/ -/ -pattern -then -patterns -should -be -the -number -of -patterns -. -Otherwise -/ -/ -/ -it -should -be -zero -. -/ -/ -/ -/ -/ -/ -If -the -total -table -size -could -exceed -the -allocatable -limit -then -this -/ -/ -/ -returns -an -error -. -In -practice -this -is -unlikely -to -be -able -to -occur -/ -/ -/ -since -it -' -s -likely -that -allocation -would -have -failed -long -before -it -got -/ -/ -/ -to -this -point -. -fn -dead -( -kind -: -StartKind -lookm -: -& -LookMatcher -pattern_len -: -Option -< -usize -> -) -- -> -Result -< -StartTable -< -Vec -< -u32 -> -> -BuildError -> -{ -if -let -Some -( -len -) -= -pattern_len -{ -assert -! -( -len -< -= -PatternID -: -: -LIMIT -) -; -} -let -stride -= -Start -: -: -len -( -) -; -/ -/ -OK -because -2 -* -4 -is -never -going -to -overflow -anything -. -let -starts_len -= -stride -. -checked_mul -( -2 -) -. -unwrap -( -) -; -let -pattern_starts_len -= -match -stride -. -checked_mul -( -pattern_len -. -unwrap_or -( -0 -) -) -{ -Some -( -x -) -= -> -x -None -= -> -return -Err -( -BuildError -: -: -too_many_start_states -( -) -) -} -; -let -table_len -= -match -starts_len -. -checked_add -( -pattern_starts_len -) -{ -Some -( -x -) -= -> -x -None -= -> -return -Err -( -BuildError -: -: -too_many_start_states -( -) -) -} -; -if -let -Err -( -_ -) -= -isize -: -: -try_from -( -table_len -) -{ -return -Err -( -BuildError -: -: -too_many_start_states -( -) -) -; -} -let -table -= -vec -! -[ -DEAD -. -as_u32 -( -) -; -table_len -] -; -let -start_map -= -StartByteMap -: -: -new -( -lookm -) -; -Ok -( -StartTable -{ -table -kind -start_map -stride -pattern_len -universal_start_unanchored -: -None -universal_start_anchored -: -None -} -) -} -} -impl -< -' -a -> -StartTable -< -& -' -a -[ -u32 -] -> -{ -/ -/ -/ -Deserialize -a -table -of -start -state -IDs -starting -at -the -beginning -of -/ -/ -/ -slice -. -Upon -success -return -the -total -number -of -bytes -read -along -with -/ -/ -/ -the -table -of -starting -state -IDs -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -deserializing -any -part -of -the -starting -IDs -/ -/ -/ -then -this -returns -an -error -. -Notably -if -the -given -slice -does -not -have -/ -/ -/ -the -same -alignment -as -StateID -then -this -will -return -an -error -( -among -/ -/ -/ -other -possible -errors -) -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -execute -in -constant -time -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -This -routine -is -not -safe -because -it -does -not -check -the -validity -of -the -/ -/ -/ -starting -state -IDs -themselves -. -In -particular -the -number -of -starting -/ -/ -/ -IDs -can -be -of -variable -length -so -it -' -s -possible -that -checking -their -/ -/ -/ -validity -cannot -be -done -in -constant -time -. -An -invalid -starting -state -/ -/ -/ -ID -is -not -safe -because -other -code -may -rely -on -the -starting -IDs -being -/ -/ -/ -correct -( -such -as -explicit -bounds -check -elision -) -. -Therefore -an -invalid -/ -/ -/ -start -ID -can -lead -to -undefined -behavior -. -/ -/ -/ -/ -/ -/ -Callers -that -use -this -function -must -either -pass -on -the -safety -invariant -/ -/ -/ -or -guarantee -that -the -bytes -given -contain -valid -starting -state -IDs -. -/ -/ -/ -This -guarantee -is -upheld -by -the -bytes -written -by -write_to -. -unsafe -fn -from_bytes_unchecked -( -mut -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -StartTable -< -& -' -a -[ -u32 -] -> -usize -) -DeserializeError -> -{ -let -slice_start -= -slice -. -as_ptr -( -) -. -as_usize -( -) -; -let -( -kind -nr -) -= -StartKind -: -: -from_bytes -( -slice -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -start_map -nr -) -= -StartByteMap -: -: -from_bytes -( -slice -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -stride -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -start -table -stride -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -if -stride -! -= -Start -: -: -len -( -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -starting -table -stride -" -) -) -; -} -let -( -maybe_pattern_len -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -start -table -patterns -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -pattern_len -= -if -maybe_pattern_len -. -as_u32 -( -) -= -= -u32 -: -: -MAX -{ -None -} -else -{ -Some -( -maybe_pattern_len -) -} -; -if -pattern_len -. -map_or -( -false -| -len -| -len -> -PatternID -: -: -LIMIT -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -number -of -patterns -" -) -) -; -} -let -( -universal_unanchored -nr -) -= -wire -: -: -try_read_u32 -( -slice -" -universal -unanchored -start -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -universal_start_unanchored -= -if -universal_unanchored -= -= -u32 -: -: -MAX -{ -None -} -else -{ -Some -( -StateID -: -: -try_from -( -universal_unanchored -) -. -map_err -( -| -e -| -{ -DeserializeError -: -: -state_id_error -( -e -" -universal -unanchored -start -" -) -} -) -? -) -} -; -let -( -universal_anchored -nr -) -= -wire -: -: -try_read_u32 -( -slice -" -universal -anchored -start -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -universal_start_anchored -= -if -universal_anchored -= -= -u32 -: -: -MAX -{ -None -} -else -{ -Some -( -StateID -: -: -try_from -( -universal_anchored -) -. -map_err -( -| -e -| -{ -DeserializeError -: -: -state_id_error -( -e -" -universal -anchored -start -" -) -} -) -? -) -} -; -let -pattern_table_size -= -wire -: -: -mul -( -stride -pattern_len -. -unwrap_or -( -0 -) -" -invalid -pattern -length -" -) -? -; -/ -/ -Our -start -states -always -start -with -a -two -stride -of -start -states -for -/ -/ -the -entire -automaton -. -The -first -stride -is -for -unanchored -starting -/ -/ -states -and -the -second -stride -is -for -anchored -starting -states -. -What -/ -/ -follows -it -are -an -optional -set -of -start -states -for -each -pattern -. -let -start_state_len -= -wire -: -: -add -( -wire -: -: -mul -( -2 -stride -" -start -state -stride -too -big -" -) -? -pattern_table_size -" -invalid -' -any -' -pattern -starts -size -" -) -? -; -let -table_bytes_len -= -wire -: -: -mul -( -start_state_len -StateID -: -: -SIZE -" -pattern -table -bytes -length -" -) -? -; -wire -: -: -check_slice_len -( -slice -table_bytes_len -" -start -ID -table -" -) -? -; -wire -: -: -check_alignment -: -: -< -StateID -> -( -slice -) -? -; -let -table_bytes -= -& -slice -[ -. -. -table_bytes_len -] -; -slice -= -& -slice -[ -table_bytes_len -. -. -] -; -/ -/ -SAFETY -: -Since -StateID -is -always -representable -as -a -u32 -all -we -need -/ -/ -to -do -is -ensure -that -we -have -the -proper -length -and -alignment -. -We -' -ve -/ -/ -checked -both -above -so -the -cast -below -is -safe -. -/ -/ -/ -/ -N -. -B -. -This -is -the -only -not -- -safe -code -in -this -function -. -let -table -= -core -: -: -slice -: -: -from_raw_parts -( -table_bytes -. -as_ptr -( -) -. -cast -: -: -< -u32 -> -( -) -start_state_len -) -; -let -st -= -StartTable -{ -table -kind -start_map -stride -pattern_len -universal_start_unanchored -universal_start_anchored -} -; -Ok -( -( -st -slice -. -as_ptr -( -) -. -as_usize -( -) -- -slice_start -) -) -} -} -impl -< -T -: -AsRef -< -[ -u32 -] -> -> -StartTable -< -T -> -{ -/ -/ -/ -Writes -a -serialized -form -of -this -start -table -to -the -buffer -given -. -If -/ -/ -/ -the -buffer -is -too -small -then -an -error -is -returned -. -To -determine -how -/ -/ -/ -big -the -buffer -must -be -use -write_to_len -. -fn -write_to -< -E -: -Endian -> -( -& -self -mut -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -starting -table -ids -" -) -) -; -} -dst -= -& -mut -dst -[ -. -. -nwrite -] -; -/ -/ -write -start -kind -let -nw -= -self -. -kind -. -write_to -: -: -< -E -> -( -dst -) -? -; -dst -= -& -mut -dst -[ -nw -. -. -] -; -/ -/ -write -start -byte -map -let -nw -= -self -. -start_map -. -write_to -( -dst -) -? -; -dst -= -& -mut -dst -[ -nw -. -. -] -; -/ -/ -write -stride -/ -/ -Unwrap -is -OK -since -the -stride -is -always -4 -( -currently -) -. -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -stride -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -pattern -length -/ -/ -Unwrap -is -OK -since -number -of -patterns -is -guaranteed -to -fit -in -a -u32 -. -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -pattern_len -. -unwrap_or -( -0xFFFF_FFFF -) -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -universal -start -unanchored -state -id -u32 -: -: -MAX -if -absent -E -: -: -write_u32 -( -self -. -universal_start_unanchored -. -map_or -( -u32 -: -: -MAX -| -sid -| -sid -. -as_u32 -( -) -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -universal -start -anchored -state -id -u32 -: -: -MAX -if -absent -E -: -: -write_u32 -( -self -. -universal_start_anchored -. -map_or -( -u32 -: -: -MAX -| -sid -| -sid -. -as_u32 -( -) -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -start -IDs -for -& -sid -in -self -. -table -( -) -{ -let -n -= -wire -: -: -write_state_id -: -: -< -E -> -( -sid -& -mut -dst -) -; -dst -= -& -mut -dst -[ -n -. -. -] -; -} -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -number -of -bytes -the -serialized -form -of -this -start -ID -table -/ -/ -/ -will -use -. -fn -write_to_len -( -& -self -) -- -> -usize -{ -self -. -kind -. -write_to_len -( -) -+ -self -. -start_map -. -write_to_len -( -) -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -stride -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -# -patterns -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -universal -unanchored -start -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -universal -anchored -start -+ -( -self -. -table -( -) -. -len -( -) -* -StateID -: -: -SIZE -) -} -/ -/ -/ -Validates -that -every -state -ID -in -this -start -table -is -valid -by -checking -/ -/ -/ -it -against -the -given -transition -table -( -which -must -be -for -the -same -DFA -) -. -/ -/ -/ -/ -/ -/ -That -is -every -state -ID -can -be -used -to -correctly -index -a -state -. -fn -validate -( -& -self -tt -: -& -TransitionTable -< -T -> -) -- -> -Result -< -( -) -DeserializeError -> -{ -if -! -self -. -universal_start_unanchored -. -map_or -( -true -| -s -| -tt -. -is_valid -( -s -) -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -found -invalid -universal -unanchored -starting -state -ID -" -) -) -; -} -if -! -self -. -universal_start_anchored -. -map_or -( -true -| -s -| -tt -. -is_valid -( -s -) -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -found -invalid -universal -anchored -starting -state -ID -" -) -) -; -} -for -& -id -in -self -. -table -( -) -{ -if -! -tt -. -is_valid -( -id -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -found -invalid -starting -state -ID -" -) -) -; -} -} -Ok -( -( -) -) -} -/ -/ -/ -Converts -this -start -list -to -a -borrowed -value -. -fn -as_ref -( -& -self -) -- -> -StartTable -< -& -' -_ -[ -u32 -] -> -{ -StartTable -{ -table -: -self -. -table -. -as_ref -( -) -kind -: -self -. -kind -start_map -: -self -. -start_map -. -clone -( -) -stride -: -self -. -stride -pattern_len -: -self -. -pattern_len -universal_start_unanchored -: -self -. -universal_start_unanchored -universal_start_anchored -: -self -. -universal_start_anchored -} -} -/ -/ -/ -Converts -this -start -list -to -an -owned -value -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -fn -to_owned -( -& -self -) -- -> -StartTable -< -alloc -: -: -vec -: -: -Vec -< -u32 -> -> -{ -StartTable -{ -table -: -self -. -table -. -as_ref -( -) -. -to_vec -( -) -kind -: -self -. -kind -start_map -: -self -. -start_map -. -clone -( -) -stride -: -self -. -stride -pattern_len -: -self -. -pattern_len -universal_start_unanchored -: -self -. -universal_start_unanchored -universal_start_anchored -: -self -. -universal_start_anchored -} -} -/ -/ -/ -Return -the -start -state -for -the -given -input -and -starting -configuration -. -/ -/ -/ -This -returns -an -error -if -the -input -configuration -is -not -supported -by -/ -/ -/ -this -DFA -. -For -example -requesting -an -unanchored -search -when -the -DFA -was -/ -/ -/ -not -built -with -unanchored -starting -states -. -Or -asking -for -an -anchored -/ -/ -/ -pattern -search -with -an -invalid -pattern -ID -or -on -a -DFA -that -was -not -/ -/ -/ -built -with -start -states -for -each -pattern -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -start -( -& -self -input -: -& -Input -< -' -_ -> -start -: -Start -) -- -> -Result -< -StateID -MatchError -> -{ -let -start_index -= -start -. -as_usize -( -) -; -let -mode -= -input -. -get_anchored -( -) -; -let -index -= -match -mode -{ -Anchored -: -: -No -= -> -{ -if -! -self -. -kind -. -has_unanchored -( -) -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -mode -) -) -; -} -start_index -} -Anchored -: -: -Yes -= -> -{ -if -! -self -. -kind -. -has_anchored -( -) -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -mode -) -) -; -} -self -. -stride -+ -start_index -} -Anchored -: -: -Pattern -( -pid -) -= -> -{ -let -len -= -match -self -. -pattern_len -{ -None -= -> -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -mode -) -) -} -Some -( -len -) -= -> -len -} -; -if -pid -. -as_usize -( -) -> -= -len -{ -return -Ok -( -DEAD -) -; -} -( -2 -* -self -. -stride -) -+ -( -self -. -stride -* -pid -. -as_usize -( -) -) -+ -start_index -} -} -; -Ok -( -self -. -table -( -) -[ -index -] -) -} -/ -/ -/ -Returns -an -iterator -over -all -start -state -IDs -in -this -table -. -/ -/ -/ -/ -/ -/ -Each -item -is -a -triple -of -: -start -state -ID -the -start -state -type -and -the -/ -/ -/ -pattern -ID -( -if -any -) -. -fn -iter -( -& -self -) -- -> -StartStateIter -< -' -_ -> -{ -StartStateIter -{ -st -: -self -. -as_ref -( -) -i -: -0 -} -} -/ -/ -/ -Returns -the -table -as -a -slice -of -state -IDs -. -fn -table -( -& -self -) -- -> -& -[ -StateID -] -{ -wire -: -: -u32s_to_state_ids -( -self -. -table -. -as_ref -( -) -) -} -/ -/ -/ -Return -the -memory -usage -in -bytes -of -this -start -list -. -/ -/ -/ -/ -/ -/ -This -does -not -include -the -size -of -a -StartList -value -itself -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -table -( -) -. -len -( -) -* -StateID -: -: -SIZE -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -< -T -: -AsMut -< -[ -u32 -] -> -> -StartTable -< -T -> -{ -/ -/ -/ -Set -the -start -state -for -the -given -index -and -pattern -. -/ -/ -/ -/ -/ -/ -If -the -pattern -ID -or -state -ID -are -not -valid -then -this -will -panic -. -fn -set_start -( -& -mut -self -anchored -: -Anchored -start -: -Start -id -: -StateID -) -{ -let -start_index -= -start -. -as_usize -( -) -; -let -index -= -match -anchored -{ -Anchored -: -: -No -= -> -start_index -Anchored -: -: -Yes -= -> -self -. -stride -+ -start_index -Anchored -: -: -Pattern -( -pid -) -= -> -{ -let -pid -= -pid -. -as_usize -( -) -; -let -len -= -self -. -pattern_len -. -expect -( -" -start -states -for -each -pattern -enabled -" -) -; -assert -! -( -pid -< -len -" -invalid -pattern -ID -{ -: -? -} -" -pid -) -; -self -. -stride -. -checked_mul -( -pid -) -. -unwrap -( -) -. -checked_add -( -self -. -stride -. -checked_mul -( -2 -) -. -unwrap -( -) -) -. -unwrap -( -) -. -checked_add -( -start_index -) -. -unwrap -( -) -} -} -; -self -. -table_mut -( -) -[ -index -] -= -id -; -} -/ -/ -/ -Returns -the -table -as -a -mutable -slice -of -state -IDs -. -fn -table_mut -( -& -mut -self -) -- -> -& -mut -[ -StateID -] -{ -wire -: -: -u32s_to_state_ids_mut -( -self -. -table -. -as_mut -( -) -) -} -} -/ -/ -/ -An -iterator -over -start -state -IDs -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -a -triple -of -start -state -ID -the -anchored -mode -and -the -/ -/ -/ -start -state -type -. -If -a -pattern -ID -is -relevant -then -the -anchored -mode -will -/ -/ -/ -contain -it -. -Start -states -with -an -anchored -mode -containing -a -pattern -ID -will -/ -/ -/ -only -occur -when -the -DFA -was -compiled -with -start -states -for -each -pattern -/ -/ -/ -( -which -is -disabled -by -default -) -. -pub -( -crate -) -struct -StartStateIter -< -' -a -> -{ -st -: -StartTable -< -& -' -a -[ -u32 -] -> -i -: -usize -} -impl -< -' -a -> -Iterator -for -StartStateIter -< -' -a -> -{ -type -Item -= -( -StateID -Anchored -Start -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -StateID -Anchored -Start -) -> -{ -let -i -= -self -. -i -; -let -table -= -self -. -st -. -table -( -) -; -if -i -> -= -table -. -len -( -) -{ -return -None -; -} -self -. -i -+ -= -1 -; -/ -/ -This -unwrap -is -okay -since -the -stride -of -the -starting -state -table -/ -/ -must -always -match -the -number -of -start -state -types -. -let -start_type -= -Start -: -: -from_usize -( -i -% -self -. -st -. -stride -) -. -unwrap -( -) -; -let -anchored -= -if -i -< -self -. -st -. -stride -{ -Anchored -: -: -No -} -else -if -i -< -( -2 -* -self -. -st -. -stride -) -{ -Anchored -: -: -Yes -} -else -{ -let -pid -= -( -i -- -( -2 -* -self -. -st -. -stride -) -) -/ -self -. -st -. -stride -; -Anchored -: -: -Pattern -( -PatternID -: -: -new -( -pid -) -. -unwrap -( -) -) -} -; -Some -( -( -table -[ -i -] -anchored -start_type -) -) -} -} -/ -/ -/ -This -type -represents -that -patterns -that -should -be -reported -whenever -a -DFA -/ -/ -/ -enters -a -match -state -. -This -structure -exists -to -support -DFAs -that -search -for -/ -/ -/ -matches -for -multiple -regexes -. -/ -/ -/ -/ -/ -/ -This -structure -relies -on -the -fact -that -all -match -states -in -a -DFA -occur -/ -/ -/ -contiguously -in -the -DFA -' -s -transition -table -. -( -See -dfa -/ -special -. -rs -for -a -more -/ -/ -/ -detailed -breakdown -of -the -representation -. -) -Namely -when -a -match -occurs -we -/ -/ -/ -know -its -state -ID -. -Since -we -know -the -start -and -end -of -the -contiguous -region -/ -/ -/ -of -match -states -we -can -use -that -to -compute -the -position -at -which -the -match -/ -/ -/ -state -occurs -. -That -in -turn -is -used -as -an -offset -into -this -structure -. -# -[ -derive -( -Clone -Debug -) -] -struct -MatchStates -< -T -> -{ -/ -/ -/ -Slices -is -a -flattened -sequence -of -pairs -where -each -pair -points -to -a -/ -/ -/ -sub -- -slice -of -pattern_ids -. -The -first -element -of -the -pair -is -an -offset -/ -/ -/ -into -pattern_ids -and -the -second -element -of -the -pair -is -the -number -/ -/ -/ -of -32 -- -bit -pattern -IDs -starting -at -that -position -. -That -is -each -pair -/ -/ -/ -corresponds -to -a -single -DFA -match -state -and -its -corresponding -match -/ -/ -/ -IDs -. -The -number -of -pairs -always -corresponds -to -the -number -of -distinct -/ -/ -/ -DFA -match -states -. -/ -/ -/ -/ -/ -/ -In -practice -T -is -either -Vec -< -u32 -> -or -& -[ -u32 -] -. -slices -: -T -/ -/ -/ -A -flattened -sequence -of -pattern -IDs -for -each -DFA -match -state -. -The -only -/ -/ -/ -way -to -correctly -read -this -sequence -is -indirectly -via -slices -. -/ -/ -/ -/ -/ -/ -In -practice -T -is -either -Vec -< -u32 -> -or -& -[ -u32 -] -. -pattern_ids -: -T -/ -/ -/ -The -total -number -of -unique -patterns -represented -by -these -match -states -. -pattern_len -: -usize -} -impl -< -' -a -> -MatchStates -< -& -' -a -[ -u32 -] -> -{ -unsafe -fn -from_bytes_unchecked -( -mut -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -MatchStates -< -& -' -a -[ -u32 -] -> -usize -) -DeserializeError -> -{ -let -slice_start -= -slice -. -as_ptr -( -) -. -as_usize -( -) -; -/ -/ -Read -the -total -number -of -match -states -. -let -( -state_len -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -match -state -length -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -/ -/ -Read -the -slice -start -/ -length -pairs -. -let -pair_len -= -wire -: -: -mul -( -2 -state_len -" -match -state -offset -pairs -" -) -? -; -let -slices_bytes_len -= -wire -: -: -mul -( -pair_len -PatternID -: -: -SIZE -" -match -state -slice -offset -byte -length -" -) -? -; -wire -: -: -check_slice_len -( -slice -slices_bytes_len -" -match -state -slices -" -) -? -; -wire -: -: -check_alignment -: -: -< -PatternID -> -( -slice -) -? -; -let -slices_bytes -= -& -slice -[ -. -. -slices_bytes_len -] -; -slice -= -& -slice -[ -slices_bytes_len -. -. -] -; -/ -/ -SAFETY -: -Since -PatternID -is -always -representable -as -a -u32 -all -we -/ -/ -need -to -do -is -ensure -that -we -have -the -proper -length -and -alignment -. -/ -/ -We -' -ve -checked -both -above -so -the -cast -below -is -safe -. -/ -/ -/ -/ -N -. -B -. -This -is -one -of -the -few -not -- -safe -snippets -in -this -function -/ -/ -so -we -mark -it -explicitly -to -call -it -out -. -let -slices -= -core -: -: -slice -: -: -from_raw_parts -( -slices_bytes -. -as_ptr -( -) -. -cast -: -: -< -u32 -> -( -) -pair_len -) -; -/ -/ -Read -the -total -number -of -unique -pattern -IDs -( -which -is -always -1 -more -/ -/ -than -the -maximum -pattern -ID -in -this -automaton -since -pattern -IDs -are -/ -/ -handed -out -contiguously -starting -at -0 -) -. -let -( -pattern_len -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -pattern -length -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -/ -/ -Now -read -the -pattern -ID -length -. -We -don -' -t -need -to -store -this -/ -/ -explicitly -but -we -need -it -to -know -how -many -pattern -IDs -to -read -. -let -( -idlen -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -pattern -ID -length -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -/ -/ -Read -the -actual -pattern -IDs -. -let -pattern_ids_len -= -wire -: -: -mul -( -idlen -PatternID -: -: -SIZE -" -pattern -ID -byte -length -" -) -? -; -wire -: -: -check_slice_len -( -slice -pattern_ids_len -" -match -pattern -IDs -" -) -? -; -wire -: -: -check_alignment -: -: -< -PatternID -> -( -slice -) -? -; -let -pattern_ids_bytes -= -& -slice -[ -. -. -pattern_ids_len -] -; -slice -= -& -slice -[ -pattern_ids_len -. -. -] -; -/ -/ -SAFETY -: -Since -PatternID -is -always -representable -as -a -u32 -all -we -/ -/ -need -to -do -is -ensure -that -we -have -the -proper -length -and -alignment -. -/ -/ -We -' -ve -checked -both -above -so -the -cast -below -is -safe -. -/ -/ -/ -/ -N -. -B -. -This -is -one -of -the -few -not -- -safe -snippets -in -this -function -/ -/ -so -we -mark -it -explicitly -to -call -it -out -. -let -pattern_ids -= -core -: -: -slice -: -: -from_raw_parts -( -pattern_ids_bytes -. -as_ptr -( -) -. -cast -: -: -< -u32 -> -( -) -idlen -) -; -let -ms -= -MatchStates -{ -slices -pattern_ids -pattern_len -} -; -Ok -( -( -ms -slice -. -as_ptr -( -) -. -as_usize -( -) -- -slice_start -) -) -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -MatchStates -< -Vec -< -u32 -> -> -{ -fn -empty -( -pattern_len -: -usize -) -- -> -MatchStates -< -Vec -< -u32 -> -> -{ -assert -! -( -pattern_len -< -= -PatternID -: -: -LIMIT -) -; -MatchStates -{ -slices -: -vec -! -[ -] -pattern_ids -: -vec -! -[ -] -pattern_len -} -} -fn -new -( -matches -: -& -BTreeMap -< -StateID -Vec -< -PatternID -> -> -pattern_len -: -usize -) -- -> -Result -< -MatchStates -< -Vec -< -u32 -> -> -BuildError -> -{ -let -mut -m -= -MatchStates -: -: -empty -( -pattern_len -) -; -for -( -_ -pids -) -in -matches -. -iter -( -) -{ -let -start -= -PatternID -: -: -new -( -m -. -pattern_ids -. -len -( -) -) -. -map_err -( -| -_ -| -BuildError -: -: -too_many_match_pattern_ids -( -) -) -? -; -m -. -slices -. -push -( -start -. -as_u32 -( -) -) -; -/ -/ -This -is -always -correct -since -the -number -of -patterns -in -a -single -/ -/ -match -state -can -never -exceed -maximum -number -of -allowable -/ -/ -patterns -. -Why -? -Because -a -pattern -can -only -appear -once -in -a -/ -/ -particular -match -state -by -construction -. -( -And -since -our -pattern -/ -/ -ID -limit -is -one -less -than -u32 -: -: -MAX -we -' -re -guaranteed -that -the -/ -/ -length -fits -in -a -u32 -. -) -m -. -slices -. -push -( -u32 -: -: -try_from -( -pids -. -len -( -) -) -. -unwrap -( -) -) -; -for -& -pid -in -pids -{ -m -. -pattern_ids -. -push -( -pid -. -as_u32 -( -) -) -; -} -} -m -. -pattern_len -= -pattern_len -; -Ok -( -m -) -} -fn -new_with_map -( -& -self -matches -: -& -BTreeMap -< -StateID -Vec -< -PatternID -> -> -) -- -> -Result -< -MatchStates -< -Vec -< -u32 -> -> -BuildError -> -{ -MatchStates -: -: -new -( -matches -self -. -pattern_len -) -} -} -impl -< -T -: -AsRef -< -[ -u32 -] -> -> -MatchStates -< -T -> -{ -/ -/ -/ -Writes -a -serialized -form -of -these -match -states -to -the -buffer -given -. -If -/ -/ -/ -the -buffer -is -too -small -then -an -error -is -returned -. -To -determine -how -/ -/ -/ -big -the -buffer -must -be -use -write_to_len -. -fn -write_to -< -E -: -Endian -> -( -& -self -mut -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -match -states -" -) -) -; -} -dst -= -& -mut -dst -[ -. -. -nwrite -] -; -/ -/ -write -state -ID -length -/ -/ -Unwrap -is -OK -since -number -of -states -is -guaranteed -to -fit -in -a -u32 -. -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -len -( -) -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -slice -offset -pairs -for -& -pid -in -self -. -slices -( -) -{ -let -n -= -wire -: -: -write_pattern_id -: -: -< -E -> -( -pid -& -mut -dst -) -; -dst -= -& -mut -dst -[ -n -. -. -] -; -} -/ -/ -write -unique -pattern -ID -length -/ -/ -Unwrap -is -OK -since -number -of -patterns -is -guaranteed -to -fit -in -a -u32 -. -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -pattern_len -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -pattern -ID -length -/ -/ -Unwrap -is -OK -since -we -check -at -construction -( -and -deserialization -) -/ -/ -that -the -number -of -patterns -is -representable -as -a -u32 -. -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -pattern_ids -( -) -. -len -( -) -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -pattern -IDs -for -& -pid -in -self -. -pattern_ids -( -) -{ -let -n -= -wire -: -: -write_pattern_id -: -: -< -E -> -( -pid -& -mut -dst -) -; -dst -= -& -mut -dst -[ -n -. -. -] -; -} -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -number -of -bytes -the -serialized -form -of -these -match -states -/ -/ -/ -will -use -. -fn -write_to_len -( -& -self -) -- -> -usize -{ -size_of -: -: -< -u32 -> -( -) -/ -/ -match -state -length -+ -( -self -. -slices -( -) -. -len -( -) -* -PatternID -: -: -SIZE -) -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -unique -pattern -ID -length -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -pattern -ID -length -+ -( -self -. -pattern_ids -( -) -. -len -( -) -* -PatternID -: -: -SIZE -) -} -/ -/ -/ -Valides -that -the -match -state -info -is -itself -internally -consistent -and -/ -/ -/ -consistent -with -the -recorded -match -state -region -in -the -given -DFA -. -fn -validate -( -& -self -dfa -: -& -DFA -< -T -> -) -- -> -Result -< -( -) -DeserializeError -> -{ -if -self -. -len -( -) -! -= -dfa -. -special -. -match_len -( -dfa -. -stride -( -) -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -match -state -length -mismatch -" -) -) -; -} -for -si -in -0 -. -. -self -. -len -( -) -{ -let -start -= -self -. -slices -( -) -[ -si -* -2 -] -. -as_usize -( -) -; -let -len -= -self -. -slices -( -) -[ -si -* -2 -+ -1 -] -. -as_usize -( -) -; -if -start -> -= -self -. -pattern_ids -( -) -. -len -( -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -pattern -ID -start -offset -" -) -) -; -} -if -start -+ -len -> -self -. -pattern_ids -( -) -. -len -( -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -pattern -ID -length -" -) -) -; -} -for -mi -in -0 -. -. -len -{ -let -pid -= -self -. -pattern_id -( -si -mi -) -; -if -pid -. -as_usize -( -) -> -= -self -. -pattern_len -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -pattern -ID -" -) -) -; -} -} -} -Ok -( -( -) -) -} -/ -/ -/ -Converts -these -match -states -back -into -their -map -form -. -This -is -useful -/ -/ -/ -when -shuffling -states -as -the -normal -MatchStates -representation -is -not -/ -/ -/ -amenable -to -easy -state -swapping -. -But -with -this -map -to -swap -id1 -and -/ -/ -/ -id2 -all -you -need -to -do -is -: -/ -/ -/ -/ -/ -/ -if -let -Some -( -pids -) -= -map -. -remove -( -& -id1 -) -{ -/ -/ -/ -map -. -insert -( -id2 -pids -) -; -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -Once -shuffling -is -done -use -MatchStates -: -: -new -to -convert -back -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -to_map -( -& -self -dfa -: -& -DFA -< -T -> -) -- -> -BTreeMap -< -StateID -Vec -< -PatternID -> -> -{ -let -mut -map -= -BTreeMap -: -: -new -( -) -; -for -i -in -0 -. -. -self -. -len -( -) -{ -let -mut -pids -= -vec -! -[ -] -; -for -j -in -0 -. -. -self -. -pattern_len -( -i -) -{ -pids -. -push -( -self -. -pattern_id -( -i -j -) -) -; -} -map -. -insert -( -self -. -match_state_id -( -dfa -i -) -pids -) -; -} -map -} -/ -/ -/ -Converts -these -match -states -to -a -borrowed -value -. -fn -as_ref -( -& -self -) -- -> -MatchStates -< -& -' -_ -[ -u32 -] -> -{ -MatchStates -{ -slices -: -self -. -slices -. -as_ref -( -) -pattern_ids -: -self -. -pattern_ids -. -as_ref -( -) -pattern_len -: -self -. -pattern_len -} -} -/ -/ -/ -Converts -these -match -states -to -an -owned -value -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -fn -to_owned -( -& -self -) -- -> -MatchStates -< -alloc -: -: -vec -: -: -Vec -< -u32 -> -> -{ -MatchStates -{ -slices -: -self -. -slices -. -as_ref -( -) -. -to_vec -( -) -pattern_ids -: -self -. -pattern_ids -. -as_ref -( -) -. -to_vec -( -) -pattern_len -: -self -. -pattern_len -} -} -/ -/ -/ -Returns -the -match -state -ID -given -the -match -state -index -. -( -Where -the -/ -/ -/ -first -match -state -corresponds -to -index -0 -. -) -/ -/ -/ -/ -/ -/ -This -panics -if -there -is -no -match -state -at -the -given -index -. -fn -match_state_id -( -& -self -dfa -: -& -DFA -< -T -> -index -: -usize -) -- -> -StateID -{ -assert -! -( -dfa -. -special -. -matches -( -) -" -no -match -states -to -index -" -) -; -/ -/ -This -is -one -of -the -places -where -we -rely -on -the -fact -that -match -/ -/ -states -are -contiguous -in -the -transition -table -. -Namely -that -the -/ -/ -first -match -state -ID -always -corresponds -to -dfa -. -special -. -min_start -. -/ -/ -From -there -since -we -know -the -stride -we -can -compute -the -ID -of -any -/ -/ -match -state -given -its -index -. -let -stride2 -= -u32 -: -: -try_from -( -dfa -. -stride2 -( -) -) -. -unwrap -( -) -; -let -offset -= -index -. -checked_shl -( -stride2 -) -. -unwrap -( -) -; -let -id -= -dfa -. -special -. -min_match -. -as_usize -( -) -. -checked_add -( -offset -) -. -unwrap -( -) -; -let -sid -= -StateID -: -: -new -( -id -) -. -unwrap -( -) -; -assert -! -( -dfa -. -is_match_state -( -sid -) -) -; -sid -} -/ -/ -/ -Returns -the -pattern -ID -at -the -given -match -index -for -the -given -match -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -The -match -state -index -is -the -state -index -minus -the -state -index -of -the -/ -/ -/ -first -match -state -in -the -DFA -. -/ -/ -/ -/ -/ -/ -The -match -index -is -the -index -of -the -pattern -ID -for -the -given -state -. -/ -/ -/ -The -index -must -be -less -than -self -. -pattern_len -( -state_index -) -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -pattern_id -( -& -self -state_index -: -usize -match_index -: -usize -) -- -> -PatternID -{ -self -. -pattern_id_slice -( -state_index -) -[ -match_index -] -} -/ -/ -/ -Returns -the -number -of -patterns -in -the -given -match -state -. -/ -/ -/ -/ -/ -/ -The -match -state -index -is -the -state -index -minus -the -state -index -of -the -/ -/ -/ -first -match -state -in -the -DFA -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -pattern_len -( -& -self -state_index -: -usize -) -- -> -usize -{ -self -. -slices -( -) -[ -state_index -* -2 -+ -1 -] -. -as_usize -( -) -} -/ -/ -/ -Returns -all -of -the -pattern -IDs -for -the -given -match -state -index -. -/ -/ -/ -/ -/ -/ -The -match -state -index -is -the -state -index -minus -the -state -index -of -the -/ -/ -/ -first -match -state -in -the -DFA -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -pattern_id_slice -( -& -self -state_index -: -usize -) -- -> -& -[ -PatternID -] -{ -let -start -= -self -. -slices -( -) -[ -state_index -* -2 -] -. -as_usize -( -) -; -let -len -= -self -. -pattern_len -( -state_index -) -; -& -self -. -pattern_ids -( -) -[ -start -. -. -start -+ -len -] -} -/ -/ -/ -Returns -the -pattern -ID -offset -slice -of -u32 -as -a -slice -of -PatternID -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -slices -( -& -self -) -- -> -& -[ -PatternID -] -{ -wire -: -: -u32s_to_pattern_ids -( -self -. -slices -. -as_ref -( -) -) -} -/ -/ -/ -Returns -the -total -number -of -match -states -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -len -( -& -self -) -- -> -usize -{ -assert_eq -! -( -0 -self -. -slices -( -) -. -len -( -) -% -2 -) -; -self -. -slices -( -) -. -len -( -) -/ -2 -} -/ -/ -/ -Returns -the -pattern -ID -slice -of -u32 -as -a -slice -of -PatternID -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -pattern_ids -( -& -self -) -- -> -& -[ -PatternID -] -{ -wire -: -: -u32s_to_pattern_ids -( -self -. -pattern_ids -. -as_ref -( -) -) -} -/ -/ -/ -Return -the -memory -usage -in -bytes -of -these -match -pairs -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -( -self -. -slices -( -) -. -len -( -) -+ -self -. -pattern_ids -( -) -. -len -( -) -) -* -PatternID -: -: -SIZE -} -} -/ -/ -/ -A -common -set -of -flags -for -both -dense -and -sparse -DFAs -. -This -primarily -/ -/ -/ -centralizes -the -serialization -format -of -these -flags -at -a -bitset -. -# -[ -derive -( -Clone -Copy -Debug -) -] -pub -( -crate -) -struct -Flags -{ -/ -/ -/ -Whether -the -DFA -can -match -the -empty -string -. -When -this -is -false -all -/ -/ -/ -matches -returned -by -this -DFA -are -guaranteed -to -have -non -- -zero -length -. -pub -( -crate -) -has_empty -: -bool -/ -/ -/ -Whether -the -DFA -should -only -produce -matches -with -spans -that -correspond -/ -/ -/ -to -valid -UTF -- -8 -. -This -also -includes -omitting -any -zero -- -width -matches -that -/ -/ -/ -split -the -UTF -- -8 -encoding -of -a -codepoint -. -pub -( -crate -) -is_utf8 -: -bool -/ -/ -/ -Whether -the -DFA -is -always -anchored -or -not -regardless -of -Input -/ -/ -/ -configuration -. -This -is -useful -for -avoiding -a -reverse -scan -even -when -/ -/ -/ -executing -unanchored -searches -. -pub -( -crate -) -is_always_start_anchored -: -bool -} -impl -Flags -{ -/ -/ -/ -Creates -a -set -of -flags -for -a -DFA -from -an -NFA -. -/ -/ -/ -/ -/ -/ -N -. -B -. -This -constructor -was -defined -at -the -time -of -writing -because -all -/ -/ -/ -of -the -flags -are -derived -directly -from -the -NFA -. -If -this -changes -in -the -/ -/ -/ -future -we -might -be -more -thoughtful -about -how -the -Flags -value -is -/ -/ -/ -itself -built -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -from_nfa -( -nfa -: -& -thompson -: -: -NFA -) -- -> -Flags -{ -Flags -{ -has_empty -: -nfa -. -has_empty -( -) -is_utf8 -: -nfa -. -is_utf8 -( -) -is_always_start_anchored -: -nfa -. -is_always_start_anchored -( -) -} -} -/ -/ -/ -Deserializes -the -flags -from -the -given -slice -. -On -success -this -also -/ -/ -/ -returns -the -number -of -bytes -read -from -the -slice -. -pub -( -crate -) -fn -from_bytes -( -slice -: -& -[ -u8 -] -) -- -> -Result -< -( -Flags -usize -) -DeserializeError -> -{ -let -( -bits -nread -) -= -wire -: -: -try_read_u32 -( -slice -" -flag -bitset -" -) -? -; -let -flags -= -Flags -{ -has_empty -: -bits -& -( -1 -< -< -0 -) -! -= -0 -is_utf8 -: -bits -& -( -1 -< -< -1 -) -! -= -0 -is_always_start_anchored -: -bits -& -( -1 -< -< -2 -) -! -= -0 -} -; -Ok -( -( -flags -nread -) -) -} -/ -/ -/ -Writes -these -flags -to -the -given -byte -slice -. -If -the -buffer -is -too -small -/ -/ -/ -then -an -error -is -returned -. -To -determine -how -big -the -buffer -must -be -/ -/ -/ -use -write_to_len -. -pub -( -crate -) -fn -write_to -< -E -: -Endian -> -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -fn -bool_to_int -( -b -: -bool -) -- -> -u32 -{ -if -b -{ -1 -} -else -{ -0 -} -} -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -flag -bitset -" -) -) -; -} -let -bits -= -( -bool_to_int -( -self -. -has_empty -) -< -< -0 -) -| -( -bool_to_int -( -self -. -is_utf8 -) -< -< -1 -) -| -( -bool_to_int -( -self -. -is_always_start_anchored -) -< -< -2 -) -; -E -: -: -write_u32 -( -bits -dst -) -; -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -number -of -bytes -the -serialized -form -of -these -flags -/ -/ -/ -will -use -. -pub -( -crate -) -fn -write_to_len -( -& -self -) -- -> -usize -{ -size_of -: -: -< -u32 -> -( -) -} -} -/ -/ -/ -An -iterator -over -all -states -in -a -DFA -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -a -tuple -for -each -state -. -The -first -element -of -the -/ -/ -/ -tuple -corresponds -to -a -state -' -s -identifier -and -the -second -element -/ -/ -/ -corresponds -to -the -state -itself -( -comprised -of -its -transitions -) -. -/ -/ -/ -/ -/ -/ -' -a -corresponding -to -the -lifetime -of -original -DFA -T -corresponds -to -/ -/ -/ -the -type -of -the -transition -table -itself -. -pub -( -crate -) -struct -StateIter -< -' -a -T -> -{ -tt -: -& -' -a -TransitionTable -< -T -> -it -: -iter -: -: -Enumerate -< -slice -: -: -Chunks -< -' -a -StateID -> -> -} -impl -< -' -a -T -: -AsRef -< -[ -u32 -] -> -> -Iterator -for -StateIter -< -' -a -T -> -{ -type -Item -= -State -< -' -a -> -; -fn -next -( -& -mut -self -) -- -> -Option -< -State -< -' -a -> -> -{ -self -. -it -. -next -( -) -. -map -( -| -( -index -_ -) -| -{ -let -id -= -self -. -tt -. -to_state_id -( -index -) -; -self -. -tt -. -state -( -id -) -} -) -} -} -/ -/ -/ -An -immutable -representation -of -a -single -DFA -state -. -/ -/ -/ -/ -/ -/ -' -a -correspondings -to -the -lifetime -of -a -DFA -' -s -transition -table -. -pub -( -crate -) -struct -State -< -' -a -> -{ -id -: -StateID -stride2 -: -usize -transitions -: -& -' -a -[ -StateID -] -} -impl -< -' -a -> -State -< -' -a -> -{ -/ -/ -/ -Return -an -iterator -over -all -transitions -in -this -state -. -This -yields -/ -/ -/ -a -number -of -transitions -equivalent -to -the -alphabet -length -of -the -/ -/ -/ -corresponding -DFA -. -/ -/ -/ -/ -/ -/ -Each -transition -is -represented -by -a -tuple -. -The -first -element -is -/ -/ -/ -the -input -byte -for -that -transition -and -the -second -element -is -the -/ -/ -/ -transitions -itself -. -pub -( -crate -) -fn -transitions -( -& -self -) -- -> -StateTransitionIter -< -' -_ -> -{ -StateTransitionIter -{ -len -: -self -. -transitions -. -len -( -) -it -: -self -. -transitions -. -iter -( -) -. -enumerate -( -) -} -} -/ -/ -/ -Return -an -iterator -over -a -sparse -representation -of -the -transitions -in -/ -/ -/ -this -state -. -Only -non -- -dead -transitions -are -returned -. -/ -/ -/ -/ -/ -/ -The -" -sparse -" -representation -in -this -case -corresponds -to -a -sequence -of -/ -/ -/ -triples -. -The -first -two -elements -of -the -triple -comprise -an -inclusive -/ -/ -/ -byte -range -while -the -last -element -corresponds -to -the -transition -taken -/ -/ -/ -for -all -bytes -in -the -range -. -/ -/ -/ -/ -/ -/ -This -is -somewhat -more -condensed -than -the -classical -sparse -/ -/ -/ -representation -( -where -you -have -an -element -for -every -non -- -dead -/ -/ -/ -transition -) -but -in -practice -checking -if -a -byte -is -in -a -range -is -very -/ -/ -/ -cheap -and -using -ranges -tends -to -conserve -quite -a -bit -more -space -. -pub -( -crate -) -fn -sparse_transitions -( -& -self -) -- -> -StateSparseTransitionIter -< -' -_ -> -{ -StateSparseTransitionIter -{ -dense -: -self -. -transitions -( -) -cur -: -None -} -} -/ -/ -/ -Returns -the -identifier -for -this -state -. -pub -( -crate -) -fn -id -( -& -self -) -- -> -StateID -{ -self -. -id -} -/ -/ -/ -Analyzes -this -state -to -determine -whether -it -can -be -accelerated -. -If -so -/ -/ -/ -it -returns -an -accelerator -that -contains -at -least -one -byte -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -accelerate -( -& -self -classes -: -& -ByteClasses -) -- -> -Option -< -Accel -> -{ -/ -/ -We -just -try -to -add -bytes -to -our -accelerator -. -Once -adding -fails -/ -/ -( -because -we -' -ve -added -too -many -bytes -) -then -give -up -. -let -mut -accel -= -Accel -: -: -new -( -) -; -for -( -class -id -) -in -self -. -transitions -( -) -{ -if -id -= -= -self -. -id -( -) -{ -continue -; -} -for -unit -in -classes -. -elements -( -class -) -{ -if -let -Some -( -byte -) -= -unit -. -as_u8 -( -) -{ -if -! -accel -. -add -( -byte -) -{ -return -None -; -} -} -} -} -if -accel -. -is_empty -( -) -{ -None -} -else -{ -Some -( -accel -) -} -} -} -impl -< -' -a -> -fmt -: -: -Debug -for -State -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -for -( -i -( -start -end -sid -) -) -in -self -. -sparse_transitions -( -) -. -enumerate -( -) -{ -let -id -= -if -f -. -alternate -( -) -{ -sid -. -as_usize -( -) -} -else -{ -sid -. -as_usize -( -) -> -> -self -. -stride2 -} -; -if -i -> -0 -{ -write -! -( -f -" -" -) -? -; -} -if -start -= -= -end -{ -write -! -( -f -" -{ -: -? -} -= -> -{ -: -? -} -" -start -id -) -? -; -} -else -{ -write -! -( -f -" -{ -: -? -} -- -{ -: -? -} -= -> -{ -: -? -} -" -start -end -id -) -? -; -} -} -Ok -( -( -) -) -} -} -/ -/ -/ -An -iterator -over -all -transitions -in -a -single -DFA -state -. -This -yields -/ -/ -/ -a -number -of -transitions -equivalent -to -the -alphabet -length -of -the -/ -/ -/ -corresponding -DFA -. -/ -/ -/ -/ -/ -/ -Each -transition -is -represented -by -a -tuple -. -The -first -element -is -the -input -/ -/ -/ -byte -for -that -transition -and -the -second -element -is -the -transition -itself -. -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -StateTransitionIter -< -' -a -> -{ -len -: -usize -it -: -iter -: -: -Enumerate -< -slice -: -: -Iter -< -' -a -StateID -> -> -} -impl -< -' -a -> -Iterator -for -StateTransitionIter -< -' -a -> -{ -type -Item -= -( -alphabet -: -: -Unit -StateID -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -alphabet -: -: -Unit -StateID -) -> -{ -self -. -it -. -next -( -) -. -map -( -| -( -i -& -id -) -| -{ -let -unit -= -if -i -+ -1 -= -= -self -. -len -{ -alphabet -: -: -Unit -: -: -eoi -( -i -) -} -else -{ -let -b -= -u8 -: -: -try_from -( -i -) -. -expect -( -" -raw -byte -alphabet -is -never -exceeded -" -) -; -alphabet -: -: -Unit -: -: -u8 -( -b -) -} -; -( -unit -id -) -} -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -DEAD -transitions -in -a -single -DFA -state -using -a -/ -/ -/ -sparse -representation -. -/ -/ -/ -/ -/ -/ -Each -transition -is -represented -by -a -triple -. -The -first -two -elements -of -the -/ -/ -/ -triple -comprise -an -inclusive -byte -range -while -the -last -element -corresponds -/ -/ -/ -to -the -transition -taken -for -all -bytes -in -the -range -. -/ -/ -/ -/ -/ -/ -As -a -convenience -this -always -returns -alphabet -: -: -Unit -values -of -the -same -/ -/ -/ -type -. -That -is -you -' -ll -never -get -a -( -byte -EOI -) -or -a -( -EOI -byte -) -. -Only -( -byte -/ -/ -/ -byte -) -and -( -EOI -EOI -) -values -are -yielded -. -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -StateSparseTransitionIter -< -' -a -> -{ -dense -: -StateTransitionIter -< -' -a -> -cur -: -Option -< -( -alphabet -: -: -Unit -alphabet -: -: -Unit -StateID -) -> -} -impl -< -' -a -> -Iterator -for -StateSparseTransitionIter -< -' -a -> -{ -type -Item -= -( -alphabet -: -: -Unit -alphabet -: -: -Unit -StateID -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -alphabet -: -: -Unit -alphabet -: -: -Unit -StateID -) -> -{ -while -let -Some -( -( -unit -next -) -) -= -self -. -dense -. -next -( -) -{ -let -( -prev_start -prev_end -prev_next -) -= -match -self -. -cur -{ -Some -( -t -) -= -> -t -None -= -> -{ -self -. -cur -= -Some -( -( -unit -unit -next -) -) -; -continue -; -} -} -; -if -prev_next -= -= -next -& -& -! -unit -. -is_eoi -( -) -{ -self -. -cur -= -Some -( -( -prev_start -unit -prev_next -) -) -; -} -else -{ -self -. -cur -= -Some -( -( -unit -unit -next -) -) -; -if -prev_next -! -= -DEAD -{ -return -Some -( -( -prev_start -prev_end -prev_next -) -) -; -} -} -} -if -let -Some -( -( -start -end -next -) -) -= -self -. -cur -. -take -( -) -{ -if -next -! -= -DEAD -{ -return -Some -( -( -start -end -next -) -) -; -} -} -None -} -} -/ -/ -/ -An -error -that -occurred -during -the -construction -of -a -DFA -. -/ -/ -/ -/ -/ -/ -This -error -does -not -provide -many -introspection -capabilities -. -There -are -/ -/ -/ -generally -only -two -things -you -can -do -with -it -: -/ -/ -/ -/ -/ -/ -* -Obtain -a -human -readable -message -via -its -std -: -: -fmt -: -: -Display -impl -. -/ -/ -/ -* -Access -an -underlying -[ -nfa -: -: -thompson -: -: -BuildError -] -( -thompson -: -: -BuildError -) -/ -/ -/ -type -from -its -source -method -via -the -std -: -: -error -: -: -Error -trait -. -This -error -/ -/ -/ -only -occurs -when -using -convenience -routines -for -building -a -DFA -directly -/ -/ -/ -from -a -pattern -string -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -std -: -: -error -: -: -Error -/ -/ -/ -trait -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -# -[ -derive -( -Clone -Debug -) -] -pub -struct -BuildError -{ -kind -: -BuildErrorKind -} -/ -/ -/ -The -kind -of -error -that -occurred -during -the -construction -of -a -DFA -. -/ -/ -/ -/ -/ -/ -Note -that -this -error -is -non -- -exhaustive -. -Adding -new -variants -is -not -/ -/ -/ -considered -a -breaking -change -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -# -[ -derive -( -Clone -Debug -) -] -enum -BuildErrorKind -{ -/ -/ -/ -An -error -that -occurred -while -constructing -an -NFA -as -a -precursor -step -/ -/ -/ -before -a -DFA -is -compiled -. -NFA -( -thompson -: -: -BuildError -) -/ -/ -/ -An -error -that -occurred -because -an -unsupported -regex -feature -was -used -. -/ -/ -/ -The -message -string -describes -which -unsupported -feature -was -used -. -/ -/ -/ -/ -/ -/ -The -primary -regex -feature -that -is -unsupported -by -DFAs -is -the -Unicode -/ -/ -/ -word -boundary -look -- -around -assertion -( -\ -b -) -. -This -can -be -worked -around -/ -/ -/ -by -either -using -an -ASCII -word -boundary -( -( -? -- -u -: -\ -b -) -) -or -by -enabling -/ -/ -/ -Unicode -word -boundaries -when -building -a -DFA -. -Unsupported -( -& -' -static -str -) -/ -/ -/ -An -error -that -occurs -if -too -many -states -are -produced -while -building -a -/ -/ -/ -DFA -. -TooManyStates -/ -/ -/ -An -error -that -occurs -if -too -many -start -states -are -needed -while -building -/ -/ -/ -a -DFA -. -/ -/ -/ -/ -/ -/ -This -is -a -kind -of -oddball -error -that -occurs -when -building -a -DFA -with -/ -/ -/ -start -states -enabled -for -each -pattern -and -enough -patterns -to -cause -/ -/ -/ -the -table -of -start -states -to -overflow -usize -. -TooManyStartStates -/ -/ -/ -This -is -another -oddball -error -that -can -occur -if -there -are -too -many -/ -/ -/ -patterns -spread -out -across -too -many -match -states -. -TooManyMatchPatternIDs -/ -/ -/ -An -error -that -occurs -if -the -DFA -got -too -big -during -determinization -. -DFAExceededSizeLimit -{ -limit -: -usize -} -/ -/ -/ -An -error -that -occurs -if -auxiliary -storage -( -not -the -DFA -) -used -during -/ -/ -/ -determinization -got -too -big -. -DeterminizeExceededSizeLimit -{ -limit -: -usize -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -BuildError -{ -/ -/ -/ -Return -the -kind -of -this -error -. -fn -kind -( -& -self -) -- -> -& -BuildErrorKind -{ -& -self -. -kind -} -pub -( -crate -) -fn -nfa -( -err -: -thompson -: -: -BuildError -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -NFA -( -err -) -} -} -pub -( -crate -) -fn -unsupported_dfa_word_boundary_unicode -( -) -- -> -BuildError -{ -let -msg -= -" -cannot -build -DFAs -for -regexes -with -Unicode -word -\ -boundaries -; -switch -to -ASCII -word -boundaries -or -\ -heuristically -enable -Unicode -word -boundaries -or -use -a -\ -different -regex -engine -" -; -BuildError -{ -kind -: -BuildErrorKind -: -: -Unsupported -( -msg -) -} -} -pub -( -crate -) -fn -too_many_states -( -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -TooManyStates -} -} -pub -( -crate -) -fn -too_many_start_states -( -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -TooManyStartStates -} -} -pub -( -crate -) -fn -too_many_match_pattern_ids -( -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -TooManyMatchPatternIDs -} -} -pub -( -crate -) -fn -dfa_exceeded_size_limit -( -limit -: -usize -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -DFAExceededSizeLimit -{ -limit -} -} -} -pub -( -crate -) -fn -determinize_exceeded_size_limit -( -limit -: -usize -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -DeterminizeExceededSizeLimit -{ -limit -} -} -} -} -# -[ -cfg -( -all -( -feature -= -" -std -" -feature -= -" -dfa -- -build -" -) -) -] -impl -std -: -: -error -: -: -Error -for -BuildError -{ -fn -source -( -& -self -) -- -> -Option -< -& -( -dyn -std -: -: -error -: -: -Error -+ -' -static -) -> -{ -match -self -. -kind -( -) -{ -BuildErrorKind -: -: -NFA -( -ref -err -) -= -> -Some -( -err -) -_ -= -> -None -} -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -core -: -: -fmt -: -: -Display -for -BuildError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -match -self -. -kind -( -) -{ -BuildErrorKind -: -: -NFA -( -_ -) -= -> -write -! -( -f -" -error -building -NFA -" -) -BuildErrorKind -: -: -Unsupported -( -ref -msg -) -= -> -{ -write -! -( -f -" -unsupported -regex -feature -for -DFAs -: -{ -} -" -msg -) -} -BuildErrorKind -: -: -TooManyStates -= -> -write -! -( -f -" -number -of -DFA -states -exceeds -limit -of -{ -} -" -StateID -: -: -LIMIT -) -BuildErrorKind -: -: -TooManyStartStates -= -> -{ -let -stride -= -Start -: -: -len -( -) -; -/ -/ -The -start -table -has -stride -entries -for -starting -states -for -/ -/ -the -entire -DFA -and -then -stride -entries -for -each -pattern -/ -/ -if -start -states -for -each -pattern -are -enabled -( -which -is -the -/ -/ -only -way -this -error -can -occur -) -. -Thus -the -total -number -of -/ -/ -patterns -that -can -fit -in -the -table -is -stride -less -than -/ -/ -what -we -can -allocate -. -let -max -= -usize -: -: -try_from -( -core -: -: -isize -: -: -MAX -) -. -unwrap -( -) -; -let -limit -= -( -max -- -stride -) -/ -stride -; -write -! -( -f -" -compiling -DFA -with -start -states -exceeds -pattern -\ -pattern -limit -of -{ -} -" -limit -) -} -BuildErrorKind -: -: -TooManyMatchPatternIDs -= -> -write -! -( -f -" -compiling -DFA -with -total -patterns -in -all -match -states -\ -exceeds -limit -of -{ -} -" -PatternID -: -: -LIMIT -) -BuildErrorKind -: -: -DFAExceededSizeLimit -{ -limit -} -= -> -write -! -( -f -" -DFA -exceeded -size -limit -of -{ -: -? -} -during -determinization -" -limit -) -BuildErrorKind -: -: -DeterminizeExceededSizeLimit -{ -limit -} -= -> -{ -write -! -( -f -" -determinization -exceeded -size -limit -of -{ -: -? -} -" -limit -) -} -} -} -} -# -[ -cfg -( -all -( -test -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -mod -tests -{ -use -super -: -: -* -; -# -[ -test -] -fn -errors_with_unicode_word_boundary -( -) -{ -let -pattern -= -r -" -\ -b -" -; -assert -! -( -Builder -: -: -new -( -) -. -build -( -pattern -) -. -is_err -( -) -) -; -} -# -[ -test -] -fn -roundtrip_never_match -( -) -{ -let -dfa -= -DFA -: -: -never_match -( -) -. -unwrap -( -) -; -let -( -buf -_ -) -= -dfa -. -to_bytes_native_endian -( -) -; -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -buf -) -. -unwrap -( -) -. -0 -; -assert_eq -! -( -None -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -. -unwrap -( -) -) -; -} -# -[ -test -] -fn -roundtrip_always_match -( -) -{ -use -crate -: -: -HalfMatch -; -let -dfa -= -DFA -: -: -always_match -( -) -. -unwrap -( -) -; -let -( -buf -_ -) -= -dfa -. -to_bytes_native_endian -( -) -; -let -dfa -: -DFA -< -& -[ -u32 -] -> -= -DFA -: -: -from_bytes -( -& -buf -) -. -unwrap -( -) -. -0 -; -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -0 -) -) -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -. -unwrap -( -) -) -; -} -/ -/ -See -the -analogous -test -in -src -/ -hybrid -/ -dfa -. -rs -. -# -[ -test -] -fn -heuristic_unicode_reverse -( -) -{ -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -unicode_word_boundary -( -true -) -) -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -. -build -( -r -" -\ -b -[ -0 -- -9 -] -+ -\ -b -" -) -. -unwrap -( -) -; -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -2 -. -. -) -; -let -expected -= -MatchError -: -: -quit -( -0xB2 -1 -) -; -let -got -= -dfa -. -try_search_rev -( -& -input -) -; -assert_eq -! -( -Err -( -expected -) -got -) -; -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -. -. -3 -) -; -let -expected -= -MatchError -: -: -quit -( -0xCE -3 -) -; -let -got -= -dfa -. -try_search_rev -( -& -input -) -; -assert_eq -! -( -Err -( -expected -) -got -) -; -} -} diff --git a/third_party/rust/regex-automata/src/dfa/determinize.rs b/third_party/rust/regex-automata/src/dfa/determinize.rs deleted file mode 100644 index 9b68355af54f2..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/determinize.rs +++ /dev/null @@ -1,5266 +0,0 @@ -use -alloc -: -: -{ -collections -: -: -BTreeMap -vec -: -: -Vec -} -; -use -crate -: -: -{ -dfa -: -: -{ -dense -: -: -{ -self -BuildError -} -DEAD -} -nfa -: -: -thompson -util -: -: -{ -self -alphabet -: -: -{ -self -ByteSet -} -determinize -: -: -{ -State -StateBuilderEmpty -StateBuilderNFA -} -primitives -: -: -{ -PatternID -StateID -} -search -: -: -{ -Anchored -MatchKind -} -sparse_set -: -: -SparseSets -start -: -: -Start -} -} -; -/ -/ -/ -A -builder -for -configuring -and -running -a -DFA -determinizer -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Config -{ -match_kind -: -MatchKind -quit -: -ByteSet -dfa_size_limit -: -Option -< -usize -> -determinize_size_limit -: -Option -< -usize -> -} -impl -Config -{ -/ -/ -/ -Create -a -new -default -config -for -a -determinizer -. -The -determinizer -may -be -/ -/ -/ -configured -before -calling -run -. -pub -fn -new -( -) -- -> -Config -{ -Config -{ -match_kind -: -MatchKind -: -: -LeftmostFirst -quit -: -ByteSet -: -: -empty -( -) -dfa_size_limit -: -None -determinize_size_limit -: -None -} -} -/ -/ -/ -Run -determinization -on -the -given -NFA -and -write -the -resulting -DFA -into -/ -/ -/ -the -one -given -. -The -DFA -given -should -be -initialized -but -otherwise -empty -. -/ -/ -/ -" -Initialized -" -means -that -it -is -setup -to -handle -the -NFA -' -s -byte -classes -/ -/ -/ -number -of -patterns -and -whether -to -build -start -states -for -each -pattern -. -pub -fn -run -( -& -self -nfa -: -& -thompson -: -: -NFA -dfa -: -& -mut -dense -: -: -OwnedDFA -) -- -> -Result -< -( -) -BuildError -> -{ -let -dead -= -State -: -: -dead -( -) -; -let -quit -= -State -: -: -dead -( -) -; -let -mut -cache -= -StateMap -: -: -default -( -) -; -/ -/ -We -only -insert -the -dead -state -here -since -its -representation -is -/ -/ -identical -to -the -quit -state -. -And -we -never -want -anything -pointing -/ -/ -to -the -quit -state -other -than -specific -transitions -derived -from -the -/ -/ -determinizer -' -s -configured -" -quit -" -bytes -. -/ -/ -/ -/ -We -do -put -the -quit -state -into -' -builder_states -' -below -. -This -ensures -/ -/ -that -a -proper -DFA -state -ID -is -allocated -for -it -and -that -no -other -/ -/ -DFA -state -uses -the -" -location -after -the -DEAD -state -. -" -That -is -it -/ -/ -is -assumed -that -the -quit -state -is -always -the -state -immediately -/ -/ -following -the -DEAD -state -. -cache -. -insert -( -dead -. -clone -( -) -DEAD -) -; -let -runner -= -Runner -{ -config -: -self -. -clone -( -) -nfa -dfa -builder_states -: -alloc -: -: -vec -! -[ -dead -quit -] -cache -memory_usage_state -: -0 -sparses -: -SparseSets -: -: -new -( -nfa -. -states -( -) -. -len -( -) -) -stack -: -alloc -: -: -vec -! -[ -] -scratch_state_builder -: -StateBuilderEmpty -: -: -new -( -) -} -; -runner -. -run -( -) -} -/ -/ -/ -The -match -semantics -to -use -for -determinization -. -/ -/ -/ -/ -/ -/ -MatchKind -: -: -All -corresponds -to -the -standard -textbook -construction -. -/ -/ -/ -All -possible -match -states -are -represented -in -the -DFA -. -/ -/ -/ -MatchKind -: -: -LeftmostFirst -permits -greediness -and -otherwise -tries -to -/ -/ -/ -simulate -the -match -semantics -of -backtracking -regex -engines -. -Namely -/ -/ -/ -only -a -subset -of -match -states -are -built -and -dead -states -are -used -to -/ -/ -/ -stop -searches -with -an -unanchored -prefix -. -/ -/ -/ -/ -/ -/ -The -default -is -MatchKind -: -: -LeftmostFirst -. -pub -fn -match_kind -( -& -mut -self -kind -: -MatchKind -) -- -> -& -mut -Config -{ -self -. -match_kind -= -kind -; -self -} -/ -/ -/ -The -set -of -bytes -to -use -that -will -cause -the -DFA -to -enter -a -quit -state -/ -/ -/ -stop -searching -and -return -an -error -. -By -default -this -is -empty -. -pub -fn -quit -( -& -mut -self -set -: -ByteSet -) -- -> -& -mut -Config -{ -self -. -quit -= -set -; -self -} -/ -/ -/ -The -limit -in -bytes -of -the -heap -that -the -DFA -is -permitted -to -use -. -This -/ -/ -/ -does -not -include -the -auxiliary -heap -storage -used -by -determinization -. -pub -fn -dfa_size_limit -( -& -mut -self -bytes -: -Option -< -usize -> -) -- -> -& -mut -Config -{ -self -. -dfa_size_limit -= -bytes -; -self -} -/ -/ -/ -The -limit -in -bytes -of -the -heap -that -determinization -itself -is -allowed -/ -/ -/ -to -use -. -This -does -not -include -the -size -of -the -DFA -being -built -. -pub -fn -determinize_size_limit -( -& -mut -self -bytes -: -Option -< -usize -> -) -- -> -& -mut -Config -{ -self -. -determinize_size_limit -= -bytes -; -self -} -} -/ -/ -/ -The -actual -implementation -of -determinization -that -converts -an -NFA -to -a -DFA -/ -/ -/ -through -powerset -construction -. -/ -/ -/ -/ -/ -/ -This -determinizer -roughly -follows -the -typical -powerset -construction -where -/ -/ -/ -each -DFA -state -is -comprised -of -one -or -more -NFA -states -. -In -the -worst -case -/ -/ -/ -there -is -one -DFA -state -for -every -possible -combination -of -NFA -states -. -In -/ -/ -/ -practice -this -only -happens -in -certain -conditions -typically -when -there -are -/ -/ -/ -bounded -repetitions -. -/ -/ -/ -/ -/ -/ -The -main -differences -between -this -implementation -and -typical -deteminization -/ -/ -/ -are -that -this -implementation -delays -matches -by -one -state -and -hackily -makes -/ -/ -/ -look -- -around -work -. -Comments -below -attempt -to -explain -this -. -/ -/ -/ -/ -/ -/ -The -lifetime -variable -' -a -refers -to -the -lifetime -of -the -NFA -or -DFA -/ -/ -/ -whichever -is -shorter -. -# -[ -derive -( -Debug -) -] -struct -Runner -< -' -a -> -{ -/ -/ -/ -The -configuration -used -to -initialize -determinization -. -config -: -Config -/ -/ -/ -The -NFA -we -' -re -converting -into -a -DFA -. -nfa -: -& -' -a -thompson -: -: -NFA -/ -/ -/ -The -DFA -we -' -re -building -. -dfa -: -& -' -a -mut -dense -: -: -OwnedDFA -/ -/ -/ -Each -DFA -state -being -built -is -defined -as -an -* -ordered -* -set -of -NFA -/ -/ -/ -states -along -with -some -meta -facts -about -the -ordered -set -of -NFA -states -. -/ -/ -/ -/ -/ -/ -This -is -never -empty -. -The -first -state -is -always -a -dummy -state -such -that -/ -/ -/ -a -state -id -= -= -0 -corresponds -to -a -dead -state -. -The -second -state -is -always -/ -/ -/ -the -quit -state -. -/ -/ -/ -/ -/ -/ -Why -do -we -have -states -in -both -a -Vec -and -in -a -cache -map -below -? -/ -/ -/ -Well -they -serve -two -different -roles -based -on -access -patterns -. -/ -/ -/ -builder_states -is -the -canonical -home -of -each -state -and -provides -/ -/ -/ -constant -random -access -by -a -DFA -state -' -s -ID -. -The -cache -map -below -on -/ -/ -/ -the -other -hand -provides -a -quick -way -of -searching -for -identical -DFA -/ -/ -/ -states -by -using -the -DFA -state -as -a -key -in -the -map -. -Of -course -we -use -/ -/ -/ -reference -counting -to -avoid -actually -duplicating -the -state -' -s -data -/ -/ -/ -itself -. -( -Although -this -has -never -been -benchmarked -. -) -Note -that -the -cache -/ -/ -/ -map -does -not -give -us -full -minimization -; -it -just -lets -us -avoid -some -very -/ -/ -/ -obvious -redundant -states -. -/ -/ -/ -/ -/ -/ -Note -that -the -index -into -this -Vec -isn -' -t -quite -the -DFA -' -s -state -ID -. -/ -/ -/ -Rather -it -' -s -just -an -index -. -To -get -the -state -ID -you -have -to -multiply -/ -/ -/ -it -by -the -DFA -' -s -stride -. -That -' -s -done -by -self -. -dfa -. -from_index -. -And -the -/ -/ -/ -inverse -is -self -. -dfa -. -to_index -. -/ -/ -/ -/ -/ -/ -Moreover -DFA -states -don -' -t -usually -retain -the -IDs -assigned -to -them -/ -/ -/ -by -their -position -in -this -Vec -. -After -determinization -completes -/ -/ -/ -states -are -shuffled -around -to -support -other -optimizations -. -See -the -/ -/ -/ -sibling -' -special -' -module -for -more -details -on -that -. -( -The -reason -for -/ -/ -/ -mentioning -this -is -that -if -you -print -out -the -DFA -for -debugging -during -/ -/ -/ -determinization -and -then -print -out -the -final -DFA -after -it -is -fully -/ -/ -/ -built -then -the -state -IDs -likely -won -' -t -match -up -. -) -builder_states -: -Vec -< -State -> -/ -/ -/ -A -cache -of -DFA -states -that -already -exist -and -can -be -easily -looked -up -/ -/ -/ -via -ordered -sets -of -NFA -states -. -/ -/ -/ -/ -/ -/ -See -builder_states -docs -for -why -we -store -states -in -two -different -/ -/ -/ -ways -. -cache -: -StateMap -/ -/ -/ -The -memory -usage -in -bytes -used -by -builder_states -and -cache -. -We -track -/ -/ -/ -this -as -new -states -are -added -since -states -use -a -variable -amount -of -/ -/ -/ -heap -. -Tracking -this -as -we -add -states -makes -it -possible -to -compute -the -/ -/ -/ -total -amount -of -memory -used -by -the -determinizer -in -constant -time -. -memory_usage_state -: -usize -/ -/ -/ -A -pair -of -sparse -sets -for -tracking -ordered -sets -of -NFA -state -IDs -. -/ -/ -/ -These -are -reused -throughout -determinization -. -A -bounded -sparse -set -/ -/ -/ -gives -us -constant -time -insertion -membership -testing -and -clearing -. -sparses -: -SparseSets -/ -/ -/ -Scratch -space -for -a -stack -of -NFA -states -to -visit -for -depth -first -/ -/ -/ -visiting -without -recursion -. -stack -: -Vec -< -StateID -> -/ -/ -/ -Scratch -space -for -storing -an -ordered -sequence -of -NFA -states -for -/ -/ -/ -amortizing -allocation -. -This -is -principally -useful -for -when -we -avoid -/ -/ -/ -adding -a -new -DFA -state -since -it -already -exists -. -In -order -to -detect -this -/ -/ -/ -case -though -we -still -need -an -ordered -set -of -NFA -state -IDs -. -So -we -use -/ -/ -/ -this -space -to -stage -that -ordered -set -before -we -know -whether -we -need -to -/ -/ -/ -create -a -new -DFA -state -or -not -. -scratch_state_builder -: -StateBuilderEmpty -} -/ -/ -/ -A -map -from -states -to -state -identifiers -. -When -using -std -we -use -a -standard -/ -/ -/ -hashmap -since -it -' -s -a -bit -faster -for -this -use -case -. -( -Other -maps -like -/ -/ -/ -one -' -s -based -on -FNV -have -not -yet -been -benchmarked -. -) -/ -/ -/ -/ -/ -/ -The -main -purpose -of -this -map -is -to -reuse -states -where -possible -. -This -won -' -t -/ -/ -/ -fully -minimize -the -DFA -but -it -works -well -in -a -lot -of -cases -. -# -[ -cfg -( -feature -= -" -std -" -) -] -type -StateMap -= -std -: -: -collections -: -: -HashMap -< -State -StateID -> -; -# -[ -cfg -( -not -( -feature -= -" -std -" -) -) -] -type -StateMap -= -BTreeMap -< -State -StateID -> -; -impl -< -' -a -> -Runner -< -' -a -> -{ -/ -/ -/ -Build -the -DFA -. -If -there -was -a -problem -constructing -the -DFA -( -e -. -g -. -if -/ -/ -/ -the -chosen -state -identifier -representation -is -too -small -) -then -an -error -/ -/ -/ -is -returned -. -fn -run -( -mut -self -) -- -> -Result -< -( -) -BuildError -> -{ -if -self -. -nfa -. -look_set_any -( -) -. -contains_word_unicode -( -) -& -& -! -self -. -config -. -quit -. -contains_range -( -0x80 -0xFF -) -{ -return -Err -( -BuildError -: -: -unsupported_dfa_word_boundary_unicode -( -) -) -; -} -/ -/ -A -sequence -of -" -representative -" -bytes -drawn -from -each -equivalence -/ -/ -class -. -These -representative -bytes -are -fed -to -the -NFA -to -compute -/ -/ -state -transitions -. -This -allows -us -to -avoid -re -- -computing -state -/ -/ -transitions -for -bytes -that -are -guaranteed -to -produce -identical -/ -/ -results -. -Since -computing -the -representatives -needs -to -do -a -little -/ -/ -work -we -do -it -once -here -because -we -' -ll -be -iterating -over -them -a -lot -. -let -representatives -: -Vec -< -alphabet -: -: -Unit -> -= -self -. -dfa -. -byte_classes -( -) -. -representatives -( -. -. -) -. -collect -( -) -; -/ -/ -The -set -of -all -DFA -state -IDs -that -still -need -to -have -their -/ -/ -transitions -set -. -We -start -by -seeding -this -with -all -starting -states -. -let -mut -uncompiled -= -alloc -: -: -vec -! -[ -] -; -self -. -add_all_starts -( -& -mut -uncompiled -) -? -; -while -let -Some -( -dfa_id -) -= -uncompiled -. -pop -( -) -{ -for -& -unit -in -& -representatives -{ -if -unit -. -as_u8 -( -) -. -map_or -( -false -| -b -| -self -. -config -. -quit -. -contains -( -b -) -) -{ -continue -; -} -/ -/ -In -many -cases -the -state -we -transition -to -has -already -been -/ -/ -computed -. -' -cached_state -' -will -do -the -minimal -amount -of -work -/ -/ -to -check -this -and -if -it -exists -immediately -return -an -/ -/ -already -existing -state -ID -. -let -( -next_dfa_id -is_new -) -= -self -. -cached_state -( -dfa_id -unit -) -? -; -self -. -dfa -. -set_transition -( -dfa_id -unit -next_dfa_id -) -; -/ -/ -If -the -state -ID -we -got -back -is -newly -created -then -we -need -/ -/ -to -compile -it -so -add -it -to -our -uncompiled -frontier -. -if -is_new -{ -uncompiled -. -push -( -next_dfa_id -) -; -} -} -} -debug -! -( -" -determinization -complete -memory -usage -: -{ -} -\ -dense -DFA -size -: -{ -} -\ -is -reverse -? -{ -} -" -self -. -memory_usage -( -) -self -. -dfa -. -memory_usage -( -) -self -. -nfa -. -is_reverse -( -) -) -; -/ -/ -A -map -from -DFA -state -ID -to -one -or -more -NFA -match -IDs -. -Each -NFA -match -/ -/ -ID -corresponds -to -a -distinct -regex -pattern -that -matches -in -the -state -/ -/ -corresponding -to -the -key -. -let -mut -matches -: -BTreeMap -< -StateID -Vec -< -PatternID -> -> -= -BTreeMap -: -: -new -( -) -; -self -. -cache -. -clear -( -) -; -# -[ -cfg -( -feature -= -" -logging -" -) -] -let -mut -total_pat_len -= -0 -; -for -( -i -state -) -in -self -. -builder_states -. -into_iter -( -) -. -enumerate -( -) -{ -if -let -Some -( -pat_ids -) -= -state -. -match_pattern_ids -( -) -{ -let -id -= -self -. -dfa -. -to_state_id -( -i -) -; -log -! -{ -total_pat_len -+ -= -pat_ids -. -len -( -) -; -} -matches -. -insert -( -id -pat_ids -) -; -} -} -log -! -{ -use -core -: -: -mem -: -: -size_of -; -let -per_elem -= -size_of -: -: -< -StateID -> -( -) -+ -size_of -: -: -< -Vec -< -PatternID -> -> -( -) -; -let -pats -= -total_pat_len -* -size_of -: -: -< -PatternID -> -( -) -; -let -mem -= -( -matches -. -len -( -) -* -per_elem -) -+ -pats -; -log -: -: -debug -! -( -" -matches -map -built -memory -usage -: -{ -} -" -mem -) -; -} -/ -/ -At -this -point -we -shuffle -the -" -special -" -states -in -the -final -DFA -. -/ -/ -This -permits -a -DFA -' -s -match -loop -to -detect -a -match -condition -( -among -/ -/ -other -things -) -by -merely -inspecting -the -current -state -' -s -identifier -/ -/ -and -avoids -the -need -for -any -additional -auxiliary -storage -. -self -. -dfa -. -shuffle -( -matches -) -? -; -Ok -( -( -) -) -} -/ -/ -/ -Return -the -identifier -for -the -next -DFA -state -given -an -existing -DFA -/ -/ -/ -state -and -an -input -byte -. -If -the -next -DFA -state -already -exists -then -/ -/ -/ -return -its -identifier -from -the -cache -. -Otherwise -build -the -state -cache -/ -/ -/ -it -and -return -its -identifier -. -/ -/ -/ -/ -/ -/ -This -routine -returns -a -boolean -indicating -whether -a -new -state -was -/ -/ -/ -built -. -If -a -new -state -is -built -then -the -caller -needs -to -add -it -to -its -/ -/ -/ -frontier -of -uncompiled -DFA -states -to -compute -transitions -for -. -fn -cached_state -( -& -mut -self -dfa_id -: -StateID -unit -: -alphabet -: -: -Unit -) -- -> -Result -< -( -StateID -bool -) -BuildError -> -{ -/ -/ -Compute -the -set -of -all -reachable -NFA -states -including -epsilons -. -let -empty_builder -= -self -. -get_state_builder -( -) -; -let -builder -= -util -: -: -determinize -: -: -next -( -self -. -nfa -self -. -config -. -match_kind -& -mut -self -. -sparses -& -mut -self -. -stack -& -self -. -builder_states -[ -self -. -dfa -. -to_index -( -dfa_id -) -] -unit -empty_builder -) -; -self -. -maybe_add_state -( -builder -) -} -/ -/ -/ -Compute -the -set -of -DFA -start -states -and -add -their -identifiers -in -/ -/ -/ -' -dfa_state_ids -' -( -no -duplicates -are -added -) -. -fn -add_all_starts -( -& -mut -self -dfa_state_ids -: -& -mut -Vec -< -StateID -> -) -- -> -Result -< -( -) -BuildError -> -{ -/ -/ -These -should -be -the -first -states -added -. -assert -! -( -dfa_state_ids -. -is_empty -( -) -) -; -/ -/ -We -only -want -to -add -( -un -) -anchored -starting -states -that -is -consistent -/ -/ -with -our -DFA -' -s -configuration -. -Unconditionally -adding -both -( -although -/ -/ -it -is -the -default -) -can -make -DFAs -quite -a -bit -bigger -. -if -self -. -dfa -. -start_kind -( -) -. -has_unanchored -( -) -{ -self -. -add_start_group -( -Anchored -: -: -No -dfa_state_ids -) -? -; -} -if -self -. -dfa -. -start_kind -( -) -. -has_anchored -( -) -{ -self -. -add_start_group -( -Anchored -: -: -Yes -dfa_state_ids -) -? -; -} -/ -/ -I -previously -has -an -' -assert -' -here -checking -that -either -/ -/ -' -dfa_state_ids -' -was -non -- -empty -or -the -NFA -had -zero -patterns -. -But -it -/ -/ -turns -out -this -isn -' -t -always -true -. -For -example -the -NFA -might -have -/ -/ -one -or -more -patterns -but -where -all -such -patterns -are -just -' -fail -' -/ -/ -states -. -These -will -ultimately -just -compile -down -to -DFA -dead -states -/ -/ -and -since -the -dead -state -was -added -earlier -no -new -DFA -states -are -/ -/ -added -. -And -thus -it -is -valid -and -okay -for -' -dfa_state_ids -' -to -be -/ -/ -empty -even -if -there -are -a -non -- -zero -number -of -patterns -in -the -NFA -. -/ -/ -We -only -need -to -compute -anchored -start -states -for -each -pattern -if -it -/ -/ -was -requested -to -do -so -. -if -self -. -dfa -. -starts_for_each_pattern -( -) -{ -for -pid -in -self -. -nfa -. -patterns -( -) -{ -self -. -add_start_group -( -Anchored -: -: -Pattern -( -pid -) -dfa_state_ids -) -? -; -} -} -Ok -( -( -) -) -} -/ -/ -/ -Add -a -group -of -start -states -for -the -given -match -pattern -ID -. -Any -new -/ -/ -/ -DFA -states -added -are -pushed -on -to -' -dfa_state_ids -' -. -( -No -duplicates -are -/ -/ -/ -pushed -. -) -/ -/ -/ -/ -/ -/ -When -pattern_id -is -None -then -this -will -compile -a -group -of -unanchored -/ -/ -/ -start -states -( -if -the -DFA -is -unanchored -) -. -When -the -pattern_id -is -/ -/ -/ -present -then -this -will -compile -a -group -of -anchored -start -states -that -/ -/ -/ -only -match -the -given -pattern -. -/ -/ -/ -/ -/ -/ -This -panics -if -anchored -corresponds -to -an -invalid -pattern -ID -. -fn -add_start_group -( -& -mut -self -anchored -: -Anchored -dfa_state_ids -: -& -mut -Vec -< -StateID -> -) -- -> -Result -< -( -) -BuildError -> -{ -let -nfa_start -= -match -anchored -{ -Anchored -: -: -No -= -> -self -. -nfa -. -start_unanchored -( -) -Anchored -: -: -Yes -= -> -self -. -nfa -. -start_anchored -( -) -Anchored -: -: -Pattern -( -pid -) -= -> -{ -self -. -nfa -. -start_pattern -( -pid -) -. -expect -( -" -valid -pattern -ID -" -) -} -} -; -/ -/ -When -compiling -start -states -we -' -re -careful -not -to -build -additional -/ -/ -states -that -aren -' -t -necessary -. -For -example -if -the -NFA -has -no -word -/ -/ -boundary -assertion -then -there -' -s -no -reason -to -have -distinct -start -/ -/ -states -for -' -NonWordByte -' -and -' -WordByte -' -starting -configurations -. -/ -/ -Instead -the -' -WordByte -' -starting -configuration -can -just -point -/ -/ -directly -to -the -start -state -for -the -' -NonWordByte -' -config -. -/ -/ -/ -/ -Note -though -that -we -only -need -to -care -about -assertions -in -the -prefix -/ -/ -of -an -NFA -since -this -only -concerns -the -starting -states -. -( -Actually -/ -/ -the -most -precisely -thing -we -could -do -it -is -look -at -the -prefix -/ -/ -assertions -of -each -pattern -when -' -anchored -= -= -Anchored -: -: -Pattern -' -/ -/ -and -then -only -compile -extra -states -if -the -prefix -is -non -- -empty -. -) -But -/ -/ -we -settle -for -simplicity -here -instead -of -absolute -minimalism -. -It -is -/ -/ -somewhat -rare -after -all -for -multiple -patterns -in -the -same -regex -to -/ -/ -have -different -prefix -look -- -arounds -. -let -( -id -is_new -) -= -self -. -add_one_start -( -nfa_start -Start -: -: -NonWordByte -) -? -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -NonWordByte -id -) -; -if -is_new -{ -dfa_state_ids -. -push -( -id -) -; -} -if -! -self -. -nfa -. -look_set_prefix_any -( -) -. -contains_word -( -) -{ -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -WordByte -id -) -; -} -else -{ -let -( -id -is_new -) -= -self -. -add_one_start -( -nfa_start -Start -: -: -WordByte -) -? -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -WordByte -id -) -; -if -is_new -{ -dfa_state_ids -. -push -( -id -) -; -} -} -if -! -self -. -nfa -. -look_set_prefix_any -( -) -. -contains_anchor -( -) -{ -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -Text -id -) -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -LineLF -id -) -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -LineCR -id -) -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -CustomLineTerminator -id -) -; -} -else -{ -let -( -id -is_new -) -= -self -. -add_one_start -( -nfa_start -Start -: -: -Text -) -? -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -Text -id -) -; -if -is_new -{ -dfa_state_ids -. -push -( -id -) -; -} -let -( -id -is_new -) -= -self -. -add_one_start -( -nfa_start -Start -: -: -LineLF -) -? -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -LineLF -id -) -; -if -is_new -{ -dfa_state_ids -. -push -( -id -) -; -} -let -( -id -is_new -) -= -self -. -add_one_start -( -nfa_start -Start -: -: -LineCR -) -? -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -LineCR -id -) -; -if -is_new -{ -dfa_state_ids -. -push -( -id -) -; -} -let -( -id -is_new -) -= -self -. -add_one_start -( -nfa_start -Start -: -: -CustomLineTerminator -) -? -; -self -. -dfa -. -set_start_state -( -anchored -Start -: -: -CustomLineTerminator -id -) -; -if -is_new -{ -dfa_state_ids -. -push -( -id -) -; -} -} -Ok -( -( -) -) -} -/ -/ -/ -Add -a -new -DFA -start -state -corresponding -to -the -given -starting -NFA -/ -/ -/ -state -and -the -starting -search -configuration -. -( -The -starting -search -/ -/ -/ -configuration -essentially -tells -us -which -look -- -behind -assertions -are -/ -/ -/ -true -for -this -particular -state -. -) -/ -/ -/ -/ -/ -/ -The -boolean -returned -indicates -whether -the -state -ID -returned -is -a -newly -/ -/ -/ -created -state -or -a -previously -cached -state -. -fn -add_one_start -( -& -mut -self -nfa_start -: -StateID -start -: -Start -) -- -> -Result -< -( -StateID -bool -) -BuildError -> -{ -/ -/ -Compute -the -look -- -behind -assertions -that -are -true -in -this -starting -/ -/ -configuration -and -the -determine -the -epsilon -closure -. -While -/ -/ -computing -the -epsilon -closure -we -only -follow -condiional -epsilon -/ -/ -transitions -that -satisfy -the -look -- -behind -assertions -in -' -look_have -' -. -let -mut -builder_matches -= -self -. -get_state_builder -( -) -. -into_matches -( -) -; -util -: -: -determinize -: -: -set_lookbehind_from_start -( -self -. -nfa -& -start -& -mut -builder_matches -) -; -self -. -sparses -. -set1 -. -clear -( -) -; -util -: -: -determinize -: -: -epsilon_closure -( -self -. -nfa -nfa_start -builder_matches -. -look_have -( -) -& -mut -self -. -stack -& -mut -self -. -sparses -. -set1 -) -; -let -mut -builder -= -builder_matches -. -into_nfa -( -) -; -util -: -: -determinize -: -: -add_nfa_states -( -& -self -. -nfa -& -self -. -sparses -. -set1 -& -mut -builder -) -; -self -. -maybe_add_state -( -builder -) -} -/ -/ -/ -Adds -the -given -state -to -the -DFA -being -built -depending -on -whether -it -/ -/ -/ -already -exists -in -this -determinizer -' -s -cache -. -/ -/ -/ -/ -/ -/ -If -it -does -exist -then -the -memory -used -by -' -state -' -is -put -back -into -the -/ -/ -/ -determinizer -and -the -previously -created -state -' -s -ID -is -returned -. -( -Along -/ -/ -/ -with -' -false -' -indicating -that -no -new -state -was -added -. -) -/ -/ -/ -/ -/ -/ -If -it -does -not -exist -then -the -state -is -added -to -the -DFA -being -built -/ -/ -/ -and -a -fresh -ID -is -allocated -( -if -ID -allocation -fails -then -an -error -is -/ -/ -/ -returned -) -and -returned -. -( -Along -with -' -true -' -indicating -that -a -new -state -/ -/ -/ -was -added -. -) -fn -maybe_add_state -( -& -mut -self -builder -: -StateBuilderNFA -) -- -> -Result -< -( -StateID -bool -) -BuildError -> -{ -if -let -Some -( -& -cached_id -) -= -self -. -cache -. -get -( -builder -. -as_bytes -( -) -) -{ -/ -/ -Since -we -have -a -cached -state -put -the -constructed -state -' -s -/ -/ -memory -back -into -our -scratch -space -so -that -it -can -be -reused -. -self -. -put_state_builder -( -builder -) -; -return -Ok -( -( -cached_id -false -) -) -; -} -self -. -add_state -( -builder -) -. -map -( -| -sid -| -( -sid -true -) -) -} -/ -/ -/ -Add -the -given -state -to -the -DFA -and -make -it -available -in -the -cache -. -/ -/ -/ -/ -/ -/ -The -state -initially -has -no -transitions -. -That -is -it -transitions -to -the -/ -/ -/ -dead -state -for -all -possible -inputs -and -transitions -to -the -quit -state -/ -/ -/ -for -all -quit -bytes -. -/ -/ -/ -/ -/ -/ -If -adding -the -state -would -exceed -the -maximum -value -for -StateID -then -an -/ -/ -/ -error -is -returned -. -fn -add_state -( -& -mut -self -builder -: -StateBuilderNFA -) -- -> -Result -< -StateID -BuildError -> -{ -let -id -= -self -. -dfa -. -add_empty_state -( -) -? -; -if -! -self -. -config -. -quit -. -is_empty -( -) -{ -for -b -in -self -. -config -. -quit -. -iter -( -) -{ -self -. -dfa -. -set_transition -( -id -alphabet -: -: -Unit -: -: -u8 -( -b -) -self -. -dfa -. -quit_id -( -) -) -; -} -} -let -state -= -builder -. -to_state -( -) -; -/ -/ -States -use -reference -counting -internally -so -we -only -need -to -count -/ -/ -their -memory -usage -once -. -self -. -memory_usage_state -+ -= -state -. -memory_usage -( -) -; -self -. -builder_states -. -push -( -state -. -clone -( -) -) -; -self -. -cache -. -insert -( -state -id -) -; -self -. -put_state_builder -( -builder -) -; -if -let -Some -( -limit -) -= -self -. -config -. -dfa_size_limit -{ -if -self -. -dfa -. -memory_usage -( -) -> -limit -{ -return -Err -( -BuildError -: -: -dfa_exceeded_size_limit -( -limit -) -) -; -} -} -if -let -Some -( -limit -) -= -self -. -config -. -determinize_size_limit -{ -if -self -. -memory_usage -( -) -> -limit -{ -return -Err -( -BuildError -: -: -determinize_exceeded_size_limit -( -limit -) -) -; -} -} -Ok -( -id -) -} -/ -/ -/ -Returns -a -state -builder -from -this -determinizer -that -might -have -existing -/ -/ -/ -capacity -. -This -helps -avoid -allocs -in -cases -where -a -state -is -built -that -/ -/ -/ -turns -out -to -already -be -cached -. -/ -/ -/ -/ -/ -/ -Callers -must -put -the -state -builder -back -with -' -put_state_builder -' -/ -/ -/ -otherwise -the -allocation -reuse -won -' -t -work -. -fn -get_state_builder -( -& -mut -self -) -- -> -StateBuilderEmpty -{ -core -: -: -mem -: -: -replace -( -& -mut -self -. -scratch_state_builder -StateBuilderEmpty -: -: -new -( -) -) -} -/ -/ -/ -Puts -the -given -state -builder -back -into -this -determinizer -for -reuse -. -/ -/ -/ -/ -/ -/ -Note -that -building -a -' -State -' -from -a -builder -always -creates -a -new -/ -/ -/ -alloc -so -callers -should -always -put -the -builder -back -. -fn -put_state_builder -( -& -mut -self -builder -: -StateBuilderNFA -) -{ -let -_ -= -core -: -: -mem -: -: -replace -( -& -mut -self -. -scratch_state_builder -builder -. -clear -( -) -) -; -} -/ -/ -/ -Return -the -memory -usage -in -bytes -of -this -determinizer -at -the -current -/ -/ -/ -point -in -time -. -This -does -not -include -memory -used -by -the -NFA -or -the -/ -/ -/ -dense -DFA -itself -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -use -core -: -: -mem -: -: -size_of -; -self -. -builder_states -. -len -( -) -* -size_of -: -: -< -State -> -( -) -/ -/ -Maps -likely -use -more -memory -than -this -but -it -' -s -probably -close -. -+ -self -. -cache -. -len -( -) -* -( -size_of -: -: -< -State -> -( -) -+ -size_of -: -: -< -StateID -> -( -) -) -+ -self -. -memory_usage_state -+ -self -. -stack -. -capacity -( -) -* -size_of -: -: -< -StateID -> -( -) -+ -self -. -scratch_state_builder -. -capacity -( -) -} -} diff --git a/third_party/rust/regex-automata/src/dfa/minimize.rs b/third_party/rust/regex-automata/src/dfa/minimize.rs deleted file mode 100644 index 5a3b77d582042..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/minimize.rs +++ /dev/null @@ -1,3890 +0,0 @@ -use -core -: -: -{ -cell -: -: -RefCell -fmt -mem -} -; -use -alloc -: -: -{ -collections -: -: -BTreeMap -rc -: -: -Rc -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -dfa -: -: -{ -automaton -: -: -Automaton -dense -DEAD -} -util -: -: -{ -alphabet -primitives -: -: -{ -PatternID -StateID -} -} -} -; -/ -/ -/ -An -implementation -of -Hopcroft -' -s -algorithm -for -minimizing -DFAs -. -/ -/ -/ -/ -/ -/ -The -algorithm -implemented -here -is -mostly -taken -from -Wikipedia -: -/ -/ -/ -https -: -/ -/ -en -. -wikipedia -. -org -/ -wiki -/ -DFA_minimization -# -Hopcroft -' -s_algorithm -/ -/ -/ -/ -/ -/ -This -code -has -had -some -light -optimization -attention -paid -to -it -/ -/ -/ -particularly -in -the -form -of -reducing -allocation -as -much -as -possible -. -/ -/ -/ -However -it -is -still -generally -slow -. -Future -optimization -work -should -/ -/ -/ -probably -focus -on -the -bigger -picture -rather -than -micro -- -optimizations -. -For -/ -/ -/ -example -: -/ -/ -/ -/ -/ -/ -1 -. -Figure -out -how -to -more -intelligently -create -initial -partitions -. -That -is -/ -/ -/ -Hopcroft -' -s -algorithm -starts -by -creating -two -partitions -of -DFA -states -/ -/ -/ -that -are -known -to -NOT -be -equivalent -: -match -states -and -non -- -match -states -. -/ -/ -/ -The -algorithm -proceeds -by -progressively -refining -these -partitions -into -/ -/ -/ -smaller -partitions -. -If -we -could -start -with -more -partitions -then -we -/ -/ -/ -could -reduce -the -amount -of -work -that -Hopcroft -' -s -algorithm -needs -to -do -. -/ -/ -/ -2 -. -For -every -partition -that -we -visit -we -find -all -incoming -transitions -to -/ -/ -/ -every -state -in -the -partition -for -* -every -* -element -in -the -alphabet -. -( -This -/ -/ -/ -is -why -using -byte -classes -can -significantly -decrease -minimization -times -/ -/ -/ -since -byte -classes -shrink -the -alphabet -. -) -This -is -quite -costly -and -there -/ -/ -/ -is -perhaps -some -redundant -work -being -performed -depending -on -the -specific -/ -/ -/ -states -in -the -set -. -For -example -we -might -be -able -to -only -visit -some -/ -/ -/ -elements -of -the -alphabet -based -on -the -transitions -. -/ -/ -/ -3 -. -Move -parts -of -minimization -into -determinization -. -If -minimization -has -/ -/ -/ -fewer -states -to -deal -with -then -it -should -run -faster -. -A -prime -example -/ -/ -/ -of -this -might -be -large -Unicode -classes -which -are -generated -in -way -that -/ -/ -/ -can -create -a -lot -of -redundant -states -. -( -Some -work -has -been -done -on -this -/ -/ -/ -point -during -NFA -compilation -via -the -algorithm -described -in -the -/ -/ -/ -" -Incremental -Construction -of -MinimalAcyclic -Finite -- -State -Automata -" -/ -/ -/ -paper -. -) -pub -( -crate -) -struct -Minimizer -< -' -a -> -{ -dfa -: -& -' -a -mut -dense -: -: -OwnedDFA -in_transitions -: -Vec -< -Vec -< -Vec -< -StateID -> -> -> -partitions -: -Vec -< -StateSet -> -waiting -: -Vec -< -StateSet -> -} -impl -< -' -a -> -fmt -: -: -Debug -for -Minimizer -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -f -. -debug_struct -( -" -Minimizer -" -) -. -field -( -" -dfa -" -& -self -. -dfa -) -. -field -( -" -in_transitions -" -& -self -. -in_transitions -) -. -field -( -" -partitions -" -& -self -. -partitions -) -. -field -( -" -waiting -" -& -self -. -waiting -) -. -finish -( -) -} -} -/ -/ -/ -A -set -of -states -. -A -state -set -makes -up -a -single -partition -in -Hopcroft -' -s -/ -/ -/ -algorithm -. -/ -/ -/ -/ -/ -/ -It -is -represented -by -an -ordered -set -of -state -identifiers -. -We -use -shared -/ -/ -/ -ownership -so -that -a -single -state -set -can -be -in -both -the -set -of -partitions -/ -/ -/ -and -in -the -set -of -waiting -sets -simultaneously -without -an -additional -/ -/ -/ -allocation -. -Generally -once -a -state -set -is -built -it -becomes -immutable -. -/ -/ -/ -/ -/ -/ -We -use -this -representation -because -it -avoids -the -overhead -of -more -/ -/ -/ -traditional -set -data -structures -( -HashSet -/ -BTreeSet -) -and -also -because -/ -/ -/ -computing -intersection -/ -subtraction -on -this -representation -is -especially -/ -/ -/ -fast -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -PartialOrd -Ord -) -] -struct -StateSet -{ -ids -: -Rc -< -RefCell -< -Vec -< -StateID -> -> -> -} -impl -< -' -a -> -Minimizer -< -' -a -> -{ -pub -fn -new -( -dfa -: -& -' -a -mut -dense -: -: -OwnedDFA -) -- -> -Minimizer -< -' -a -> -{ -let -in_transitions -= -Minimizer -: -: -incoming_transitions -( -dfa -) -; -let -partitions -= -Minimizer -: -: -initial_partitions -( -dfa -) -; -let -waiting -= -partitions -. -clone -( -) -; -Minimizer -{ -dfa -in_transitions -partitions -waiting -} -} -pub -fn -run -( -mut -self -) -{ -let -stride2 -= -self -. -dfa -. -stride2 -( -) -; -let -as_state_id -= -| -index -: -usize -| -- -> -StateID -{ -StateID -: -: -new -( -index -< -< -stride2 -) -. -unwrap -( -) -} -; -let -as_index -= -| -id -: -StateID -| -- -> -usize -{ -id -. -as_usize -( -) -> -> -stride2 -} -; -let -mut -incoming -= -StateSet -: -: -empty -( -) -; -let -mut -scratch1 -= -StateSet -: -: -empty -( -) -; -let -mut -scratch2 -= -StateSet -: -: -empty -( -) -; -let -mut -newparts -= -vec -! -[ -] -; -/ -/ -This -loop -is -basically -Hopcroft -' -s -algorithm -. -Everything -else -is -just -/ -/ -shuffling -data -around -to -fit -our -representation -. -while -let -Some -( -set -) -= -self -. -waiting -. -pop -( -) -{ -for -b -in -self -. -dfa -. -byte_classes -( -) -. -iter -( -) -{ -self -. -find_incoming_to -( -b -& -set -& -mut -incoming -) -; -/ -/ -If -incoming -is -empty -then -the -intersection -with -any -other -/ -/ -set -must -also -be -empty -. -So -' -newparts -' -just -ends -up -being -/ -/ -' -self -. -partitions -' -. -So -there -' -s -no -need -to -go -through -the -loop -/ -/ -below -. -/ -/ -/ -/ -This -actually -turns -out -to -be -rather -large -optimization -. -On -/ -/ -the -order -of -making -minimization -4 -- -5x -faster -. -It -' -s -likely -/ -/ -that -the -vast -majority -of -all -states -have -very -few -incoming -/ -/ -transitions -. -if -incoming -. -is_empty -( -) -{ -continue -; -} -for -p -in -0 -. -. -self -. -partitions -. -len -( -) -{ -self -. -partitions -[ -p -] -. -intersection -( -& -incoming -& -mut -scratch1 -) -; -if -scratch1 -. -is_empty -( -) -{ -newparts -. -push -( -self -. -partitions -[ -p -] -. -clone -( -) -) -; -continue -; -} -self -. -partitions -[ -p -] -. -subtract -( -& -incoming -& -mut -scratch2 -) -; -if -scratch2 -. -is_empty -( -) -{ -newparts -. -push -( -self -. -partitions -[ -p -] -. -clone -( -) -) -; -continue -; -} -let -( -x -y -) -= -( -scratch1 -. -deep_clone -( -) -scratch2 -. -deep_clone -( -) -) -; -newparts -. -push -( -x -. -clone -( -) -) -; -newparts -. -push -( -y -. -clone -( -) -) -; -match -self -. -find_waiting -( -& -self -. -partitions -[ -p -] -) -{ -Some -( -i -) -= -> -{ -self -. -waiting -[ -i -] -= -x -; -self -. -waiting -. -push -( -y -) -; -} -None -= -> -{ -if -x -. -len -( -) -< -= -y -. -len -( -) -{ -self -. -waiting -. -push -( -x -) -; -} -else -{ -self -. -waiting -. -push -( -y -) -; -} -} -} -} -newparts -= -mem -: -: -replace -( -& -mut -self -. -partitions -newparts -) -; -newparts -. -clear -( -) -; -} -} -/ -/ -At -this -point -we -now -have -a -minimal -partitioning -of -states -where -/ -/ -each -partition -is -an -equivalence -class -of -DFA -states -. -Now -we -need -to -/ -/ -use -this -partitioning -to -update -the -DFA -to -only -contain -one -state -for -/ -/ -each -partition -. -/ -/ -Create -a -map -from -DFA -state -ID -to -the -representative -ID -of -the -/ -/ -equivalence -class -to -which -it -belongs -. -The -representative -ID -of -an -/ -/ -equivalence -class -of -states -is -the -minimum -ID -in -that -class -. -let -mut -state_to_part -= -vec -! -[ -DEAD -; -self -. -dfa -. -state_len -( -) -] -; -for -p -in -& -self -. -partitions -{ -p -. -iter -( -| -id -| -state_to_part -[ -as_index -( -id -) -] -= -p -. -min -( -) -) -; -} -/ -/ -Generate -a -new -contiguous -sequence -of -IDs -for -minimal -states -and -/ -/ -create -a -map -from -equivalence -IDs -to -the -new -IDs -. -Thus -the -new -/ -/ -minimal -ID -of -* -any -* -state -in -the -unminimized -DFA -can -be -obtained -/ -/ -with -minimals_ids -[ -state_to_part -[ -old_id -] -] -. -let -mut -minimal_ids -= -vec -! -[ -DEAD -; -self -. -dfa -. -state_len -( -) -] -; -let -mut -new_index -= -0 -; -for -state -in -self -. -dfa -. -states -( -) -{ -if -state_to_part -[ -as_index -( -state -. -id -( -) -) -] -= -= -state -. -id -( -) -{ -minimal_ids -[ -as_index -( -state -. -id -( -) -) -] -= -as_state_id -( -new_index -) -; -new_index -+ -= -1 -; -} -} -/ -/ -The -total -number -of -states -in -the -minimal -DFA -. -let -minimal_count -= -new_index -; -/ -/ -Convenience -function -for -remapping -state -IDs -. -This -takes -an -old -ID -/ -/ -looks -up -its -Hopcroft -partition -and -then -maps -that -to -the -new -ID -/ -/ -range -. -let -remap -= -| -old -| -minimal_ids -[ -as_index -( -state_to_part -[ -as_index -( -old -) -] -) -] -; -/ -/ -Re -- -map -this -DFA -in -place -such -that -the -only -states -remaining -/ -/ -correspond -to -the -representative -states -of -every -equivalence -class -. -for -id -in -( -0 -. -. -self -. -dfa -. -state_len -( -) -) -. -map -( -as_state_id -) -{ -/ -/ -If -this -state -isn -' -t -a -representative -for -an -equivalence -class -/ -/ -then -we -skip -it -since -it -won -' -t -appear -in -the -minimal -DFA -. -if -state_to_part -[ -as_index -( -id -) -] -! -= -id -{ -continue -; -} -self -. -dfa -. -remap_state -( -id -remap -) -; -self -. -dfa -. -swap_states -( -id -minimal_ids -[ -as_index -( -id -) -] -) -; -} -/ -/ -Trim -off -all -unused -states -from -the -pre -- -minimized -DFA -. -This -/ -/ -represents -all -states -that -were -merged -into -a -non -- -singleton -/ -/ -equivalence -class -of -states -and -appeared -after -the -first -state -/ -/ -in -each -such -class -. -( -Because -the -state -with -the -smallest -ID -in -each -/ -/ -equivalence -class -is -its -representative -ID -. -) -self -. -dfa -. -truncate_states -( -minimal_count -) -; -/ -/ -Update -the -new -start -states -which -is -now -just -the -minimal -ID -of -/ -/ -whatever -state -the -old -start -state -was -collapsed -into -. -Also -we -/ -/ -collect -everything -before -- -hand -to -work -around -the -borrow -checker -. -/ -/ -We -' -re -already -allocating -so -much -that -this -is -probably -fine -. -If -this -/ -/ -turns -out -to -be -costly -then -I -guess -add -a -starts_mut -iterator -. -let -starts -: -Vec -< -_ -> -= -self -. -dfa -. -starts -( -) -. -collect -( -) -; -for -( -old_start_id -anchored -start_type -) -in -starts -{ -self -. -dfa -. -set_start_state -( -anchored -start_type -remap -( -old_start_id -) -) -; -} -/ -/ -Update -the -match -state -pattern -ID -list -for -multi -- -regexes -. -All -we -/ -/ -need -to -do -is -remap -the -match -state -IDs -. -The -pattern -ID -lists -are -/ -/ -always -the -same -as -they -were -since -match -states -with -distinct -/ -/ -pattern -ID -lists -are -always -considered -distinct -states -. -let -mut -pmap -= -BTreeMap -: -: -new -( -) -; -for -( -match_id -pattern_ids -) -in -self -. -dfa -. -pattern_map -( -) -{ -let -new_id -= -remap -( -match_id -) -; -pmap -. -insert -( -new_id -pattern_ids -) -; -} -/ -/ -This -unwrap -is -OK -because -minimization -never -increases -the -number -of -/ -/ -match -states -or -patterns -in -those -match -states -. -Since -minimization -/ -/ -runs -after -the -pattern -map -has -already -been -set -at -least -once -we -/ -/ -know -that -our -match -states -cannot -error -. -self -. -dfa -. -set_pattern_map -( -& -pmap -) -. -unwrap -( -) -; -/ -/ -In -order -to -update -the -ID -of -the -maximum -match -state -we -need -to -/ -/ -find -the -maximum -ID -among -all -of -the -match -states -in -the -minimized -/ -/ -DFA -. -This -is -not -necessarily -the -new -ID -of -the -unminimized -maximum -/ -/ -match -state -since -that -could -have -been -collapsed -with -a -much -/ -/ -earlier -match -state -. -Therefore -to -find -the -new -max -match -state -/ -/ -we -iterate -over -all -previous -match -states -find -their -corresponding -/ -/ -new -minimal -ID -and -take -the -maximum -of -those -. -let -old -= -self -. -dfa -. -special -( -) -. -clone -( -) -; -let -new -= -self -. -dfa -. -special_mut -( -) -; -/ -/ -. -. -. -but -only -remap -if -we -had -match -states -. -if -old -. -matches -( -) -{ -new -. -min_match -= -StateID -: -: -MAX -; -new -. -max_match -= -StateID -: -: -ZERO -; -for -i -in -as_index -( -old -. -min_match -) -. -. -= -as_index -( -old -. -max_match -) -{ -let -new_id -= -remap -( -as_state_id -( -i -) -) -; -if -new_id -< -new -. -min_match -{ -new -. -min_match -= -new_id -; -} -if -new_id -> -new -. -max_match -{ -new -. -max_match -= -new_id -; -} -} -} -/ -/ -. -. -. -same -but -for -start -states -. -if -old -. -starts -( -) -{ -new -. -min_start -= -StateID -: -: -MAX -; -new -. -max_start -= -StateID -: -: -ZERO -; -for -i -in -as_index -( -old -. -min_start -) -. -. -= -as_index -( -old -. -max_start -) -{ -let -new_id -= -remap -( -as_state_id -( -i -) -) -; -if -new_id -= -= -DEAD -{ -continue -; -} -if -new_id -< -new -. -min_start -{ -new -. -min_start -= -new_id -; -} -if -new_id -> -new -. -max_start -{ -new -. -max_start -= -new_id -; -} -} -if -new -. -max_start -= -= -DEAD -{ -new -. -min_start -= -DEAD -; -} -} -new -. -quit_id -= -remap -( -new -. -quit_id -) -; -new -. -set_max -( -) -; -} -fn -find_waiting -( -& -self -set -: -& -StateSet -) -- -> -Option -< -usize -> -{ -self -. -waiting -. -iter -( -) -. -position -( -| -s -| -s -= -= -set -) -} -fn -find_incoming_to -( -& -self -b -: -alphabet -: -: -Unit -set -: -& -StateSet -incoming -: -& -mut -StateSet -) -{ -incoming -. -clear -( -) -; -set -. -iter -( -| -id -| -{ -for -& -inid -in -& -self -. -in_transitions -[ -self -. -dfa -. -to_index -( -id -) -] -[ -b -. -as_usize -( -) -] -{ -incoming -. -add -( -inid -) -; -} -} -) -; -incoming -. -canonicalize -( -) -; -} -fn -initial_partitions -( -dfa -: -& -dense -: -: -OwnedDFA -) -- -> -Vec -< -StateSet -> -{ -/ -/ -For -match -states -we -know -that -two -match -states -with -different -/ -/ -pattern -ID -lists -will -* -always -* -be -distinct -so -we -can -partition -them -/ -/ -initially -based -on -that -. -let -mut -matching -: -BTreeMap -< -Vec -< -PatternID -> -StateSet -> -= -BTreeMap -: -: -new -( -) -; -let -mut -is_quit -= -StateSet -: -: -empty -( -) -; -let -mut -no_match -= -StateSet -: -: -empty -( -) -; -for -state -in -dfa -. -states -( -) -{ -if -dfa -. -is_match_state -( -state -. -id -( -) -) -{ -let -mut -pids -= -vec -! -[ -] -; -for -i -in -0 -. -. -dfa -. -match_len -( -state -. -id -( -) -) -{ -pids -. -push -( -dfa -. -match_pattern -( -state -. -id -( -) -i -) -) -; -} -matching -. -entry -( -pids -) -. -or_insert -( -StateSet -: -: -empty -( -) -) -. -add -( -state -. -id -( -) -) -; -} -else -if -dfa -. -is_quit_state -( -state -. -id -( -) -) -{ -is_quit -. -add -( -state -. -id -( -) -) -; -} -else -{ -no_match -. -add -( -state -. -id -( -) -) -; -} -} -let -mut -sets -: -Vec -< -StateSet -> -= -matching -. -into_iter -( -) -. -map -( -| -( -_ -set -) -| -set -) -. -collect -( -) -; -sets -. -push -( -no_match -) -; -sets -. -push -( -is_quit -) -; -sets -} -fn -incoming_transitions -( -dfa -: -& -dense -: -: -OwnedDFA -) -- -> -Vec -< -Vec -< -Vec -< -StateID -> -> -> -{ -let -mut -incoming -= -vec -! -[ -] -; -for -_ -in -dfa -. -states -( -) -{ -incoming -. -push -( -vec -! -[ -vec -! -[ -] -; -dfa -. -alphabet_len -( -) -] -) -; -} -for -state -in -dfa -. -states -( -) -{ -for -( -b -next -) -in -state -. -transitions -( -) -{ -incoming -[ -dfa -. -to_index -( -next -) -] -[ -b -. -as_usize -( -) -] -. -push -( -state -. -id -( -) -) -; -} -} -incoming -} -} -impl -StateSet -{ -fn -empty -( -) -- -> -StateSet -{ -StateSet -{ -ids -: -Rc -: -: -new -( -RefCell -: -: -new -( -vec -! -[ -] -) -) -} -} -fn -add -( -& -mut -self -id -: -StateID -) -{ -self -. -ids -. -borrow_mut -( -) -. -push -( -id -) -; -} -fn -min -( -& -self -) -- -> -StateID -{ -self -. -ids -. -borrow -( -) -[ -0 -] -} -fn -canonicalize -( -& -mut -self -) -{ -self -. -ids -. -borrow_mut -( -) -. -sort -( -) -; -self -. -ids -. -borrow_mut -( -) -. -dedup -( -) -; -} -fn -clear -( -& -mut -self -) -{ -self -. -ids -. -borrow_mut -( -) -. -clear -( -) -; -} -fn -len -( -& -self -) -- -> -usize -{ -self -. -ids -. -borrow -( -) -. -len -( -) -} -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -len -( -) -= -= -0 -} -fn -deep_clone -( -& -self -) -- -> -StateSet -{ -let -ids -= -self -. -ids -. -borrow -( -) -. -iter -( -) -. -cloned -( -) -. -collect -( -) -; -StateSet -{ -ids -: -Rc -: -: -new -( -RefCell -: -: -new -( -ids -) -) -} -} -fn -iter -< -F -: -FnMut -( -StateID -) -> -( -& -self -mut -f -: -F -) -{ -for -& -id -in -self -. -ids -. -borrow -( -) -. -iter -( -) -{ -f -( -id -) -; -} -} -fn -intersection -( -& -self -other -: -& -StateSet -dest -: -& -mut -StateSet -) -{ -dest -. -clear -( -) -; -if -self -. -is_empty -( -) -| -| -other -. -is_empty -( -) -{ -return -; -} -let -( -seta -setb -) -= -( -self -. -ids -. -borrow -( -) -other -. -ids -. -borrow -( -) -) -; -let -( -mut -ita -mut -itb -) -= -( -seta -. -iter -( -) -. -cloned -( -) -setb -. -iter -( -) -. -cloned -( -) -) -; -let -( -mut -a -mut -b -) -= -( -ita -. -next -( -) -. -unwrap -( -) -itb -. -next -( -) -. -unwrap -( -) -) -; -loop -{ -if -a -= -= -b -{ -dest -. -add -( -a -) -; -a -= -match -ita -. -next -( -) -{ -None -= -> -break -Some -( -a -) -= -> -a -} -; -b -= -match -itb -. -next -( -) -{ -None -= -> -break -Some -( -b -) -= -> -b -} -; -} -else -if -a -< -b -{ -a -= -match -ita -. -next -( -) -{ -None -= -> -break -Some -( -a -) -= -> -a -} -; -} -else -{ -b -= -match -itb -. -next -( -) -{ -None -= -> -break -Some -( -b -) -= -> -b -} -; -} -} -} -fn -subtract -( -& -self -other -: -& -StateSet -dest -: -& -mut -StateSet -) -{ -dest -. -clear -( -) -; -if -self -. -is_empty -( -) -| -| -other -. -is_empty -( -) -{ -self -. -iter -( -| -s -| -dest -. -add -( -s -) -) -; -return -; -} -let -( -seta -setb -) -= -( -self -. -ids -. -borrow -( -) -other -. -ids -. -borrow -( -) -) -; -let -( -mut -ita -mut -itb -) -= -( -seta -. -iter -( -) -. -cloned -( -) -setb -. -iter -( -) -. -cloned -( -) -) -; -let -( -mut -a -mut -b -) -= -( -ita -. -next -( -) -. -unwrap -( -) -itb -. -next -( -) -. -unwrap -( -) -) -; -loop -{ -if -a -= -= -b -{ -a -= -match -ita -. -next -( -) -{ -None -= -> -break -Some -( -a -) -= -> -a -} -; -b -= -match -itb -. -next -( -) -{ -None -= -> -{ -dest -. -add -( -a -) -; -break -; -} -Some -( -b -) -= -> -b -} -; -} -else -if -a -< -b -{ -dest -. -add -( -a -) -; -a -= -match -ita -. -next -( -) -{ -None -= -> -break -Some -( -a -) -= -> -a -} -; -} -else -{ -b -= -match -itb -. -next -( -) -{ -None -= -> -{ -dest -. -add -( -a -) -; -break -; -} -Some -( -b -) -= -> -b -} -; -} -} -for -a -in -ita -{ -dest -. -add -( -a -) -; -} -} -} diff --git a/third_party/rust/regex-automata/src/dfa/mod.rs b/third_party/rust/regex-automata/src/dfa/mod.rs deleted file mode 100644 index c43dd7ffd855b..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/mod.rs +++ /dev/null @@ -1,3910 +0,0 @@ -/ -* -! -A -module -for -building -and -searching -with -deterministic -finite -automata -( -DFAs -) -. -Like -other -modules -in -this -crate -DFAs -support -a -rich -regex -syntax -with -Unicode -features -. -DFAs -also -have -extensive -options -for -configuring -the -best -space -vs -time -trade -off -for -your -use -case -and -provides -support -for -cheap -deserialization -of -automata -for -use -in -no_std -environments -. -If -you -' -re -looking -for -lazy -DFAs -that -build -themselves -incrementally -during -search -then -please -see -the -top -- -level -[ -hybrid -module -] -( -crate -: -: -hybrid -) -. -# -Overview -This -section -gives -a -brief -overview -of -the -primary -types -in -this -module -: -* -A -[ -regex -: -: -Regex -] -provides -a -way -to -search -for -matches -of -a -regular -expression -using -DFAs -. -This -includes -iterating -over -matches -with -both -the -start -and -end -positions -of -each -match -. -* -A -[ -dense -: -: -DFA -] -provides -low -level -access -to -a -DFA -that -uses -a -dense -representation -( -uses -lots -of -space -but -fast -searching -) -. -* -A -[ -sparse -: -: -DFA -] -provides -the -same -API -as -a -dense -: -: -DFA -but -uses -a -sparse -representation -( -uses -less -space -but -slower -searching -) -. -* -An -[ -Automaton -] -trait -that -defines -an -interface -that -both -dense -and -sparse -DFAs -implement -. -( -A -regex -: -: -Regex -is -generic -over -this -trait -. -) -* -Both -dense -DFAs -and -sparse -DFAs -support -serialization -to -raw -bytes -( -e -. -g -. -[ -dense -: -: -DFA -: -: -to_bytes_little_endian -] -) -and -cheap -deserialization -( -e -. -g -. -[ -dense -: -: -DFA -: -: -from_bytes -] -) -. -There -is -also -a -[ -onepass -] -module -that -provides -a -[ -one -- -pass -DFA -] -( -onepass -: -: -DFA -) -. -The -unique -advantage -of -this -DFA -is -that -for -the -class -of -regexes -it -can -be -built -with -it -supports -reporting -the -spans -of -matching -capturing -groups -. -It -is -the -only -DFA -in -this -crate -capable -of -such -a -thing -. -# -Example -: -basic -regex -searching -This -example -shows -how -to -compile -a -regex -using -the -default -configuration -and -then -use -it -to -find -matches -in -a -byte -string -: -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -let -re -= -Regex -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -? -; -let -text -= -b -" -2018 -- -12 -- -24 -2016 -- -10 -- -08 -" -; -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -text -) -. -collect -( -) -; -assert_eq -! -( -matches -vec -! -[ -Match -: -: -must -( -0 -0 -. -. -10 -) -Match -: -: -must -( -0 -11 -. -. -21 -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -Example -: -searching -with -regex -sets -The -DFAs -in -this -module -all -fully -support -searching -with -multiple -regexes -simultaneously -. -You -can -use -this -support -with -standard -leftmost -- -first -style -searching -to -find -non -- -overlapping -matches -: -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -let -re -= -Regex -: -: -new_many -( -& -[ -r -" -\ -w -+ -" -r -" -\ -S -+ -" -] -) -? -; -let -text -= -b -" -foo -bar -" -; -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -text -) -. -collect -( -) -; -assert_eq -! -( -matches -vec -! -[ -Match -: -: -must -( -1 -0 -. -. -4 -) -Match -: -: -must -( -0 -5 -. -. -8 -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -Example -: -use -sparse -DFAs -By -default -compiling -a -regex -will -use -dense -DFAs -internally -. -This -uses -more -memory -but -executes -searches -more -quickly -. -If -you -can -abide -slower -searches -( -somewhere -around -3 -- -5x -) -then -sparse -DFAs -might -make -more -sense -since -they -can -use -significantly -less -space -. -Using -sparse -DFAs -is -as -easy -as -using -Regex -: -: -new_sparse -instead -of -Regex -: -: -new -: -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -let -re -= -Regex -: -: -new_sparse -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -. -unwrap -( -) -; -let -text -= -b -" -2018 -- -12 -- -24 -2016 -- -10 -- -08 -" -; -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -text -) -. -collect -( -) -; -assert_eq -! -( -matches -vec -! -[ -Match -: -: -must -( -0 -0 -. -. -10 -) -Match -: -: -must -( -0 -11 -. -. -21 -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -If -you -already -have -dense -DFAs -for -some -reason -they -can -be -converted -to -sparse -DFAs -and -used -to -build -a -new -Regex -. -For -example -: -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -let -dense_re -= -Regex -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -. -unwrap -( -) -; -let -sparse_re -= -Regex -: -: -builder -( -) -. -build_from_dfas -( -dense_re -. -forward -( -) -. -to_sparse -( -) -? -dense_re -. -reverse -( -) -. -to_sparse -( -) -? -) -; -let -text -= -b -" -2018 -- -12 -- -24 -2016 -- -10 -- -08 -" -; -let -matches -: -Vec -< -Match -> -= -sparse_re -. -find_iter -( -text -) -. -collect -( -) -; -assert_eq -! -( -matches -vec -! -[ -Match -: -: -must -( -0 -0 -. -. -10 -) -Match -: -: -must -( -0 -11 -. -. -21 -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -Example -: -deserialize -a -DFA -This -shows -how -to -first -serialize -a -DFA -into -raw -bytes -and -then -deserialize -those -raw -bytes -back -into -a -DFA -. -While -this -particular -example -is -a -bit -contrived -this -same -technique -can -be -used -in -your -program -to -deserialize -a -DFA -at -start -up -time -or -by -memory -mapping -a -file -. -use -regex_automata -: -: -{ -Match -dfa -: -: -{ -dense -regex -: -: -Regex -} -} -; -let -re1 -= -Regex -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -. -unwrap -( -) -; -/ -/ -serialize -both -the -forward -and -reverse -DFAs -see -note -below -let -( -fwd_bytes -fwd_pad -) -= -re1 -. -forward -( -) -. -to_bytes_native_endian -( -) -; -let -( -rev_bytes -rev_pad -) -= -re1 -. -reverse -( -) -. -to_bytes_native_endian -( -) -; -/ -/ -now -deserialize -both -- -- -- -we -need -to -specify -the -correct -type -! -let -fwd -: -dense -: -: -DFA -< -& -[ -u32 -] -> -= -dense -: -: -DFA -: -: -from_bytes -( -& -fwd_bytes -[ -fwd_pad -. -. -] -) -? -. -0 -; -let -rev -: -dense -: -: -DFA -< -& -[ -u32 -] -> -= -dense -: -: -DFA -: -: -from_bytes -( -& -rev_bytes -[ -rev_pad -. -. -] -) -? -. -0 -; -/ -/ -finally -reconstruct -our -regex -let -re2 -= -Regex -: -: -builder -( -) -. -build_from_dfas -( -fwd -rev -) -; -/ -/ -we -can -use -it -like -normal -let -text -= -b -" -2018 -- -12 -- -24 -2016 -- -10 -- -08 -" -; -let -matches -: -Vec -< -Match -> -= -re2 -. -find_iter -( -text -) -. -collect -( -) -; -assert_eq -! -( -matches -vec -! -[ -Match -: -: -must -( -0 -0 -. -. -10 -) -Match -: -: -must -( -0 -11 -. -. -21 -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -There -are -a -few -points -worth -noting -here -: -* -We -need -to -extract -the -raw -DFAs -used -by -the -regex -and -serialize -those -. -You -can -build -the -DFAs -manually -yourself -using -[ -dense -: -: -Builder -] -but -using -the -DFAs -from -a -Regex -guarantees -that -the -DFAs -are -built -correctly -. -( -In -particular -a -Regex -constructs -a -reverse -DFA -for -finding -the -starting -location -of -matches -. -) -* -To -convert -the -DFA -to -raw -bytes -we -use -the -to_bytes_native_endian -method -. -In -practice -you -' -ll -want -to -use -either -[ -dense -: -: -DFA -: -: -to_bytes_little_endian -] -or -[ -dense -: -: -DFA -: -: -to_bytes_big_endian -] -depending -on -which -platform -you -' -re -deserializing -your -DFA -from -. -If -you -intend -to -deserialize -on -either -platform -then -you -' -ll -need -to -serialize -both -and -deserialize -the -right -one -depending -on -your -target -' -s -endianness -. -* -Safely -deserializing -a -DFA -requires -verifying -the -raw -bytes -particularly -if -they -are -untrusted -since -an -invalid -DFA -could -cause -logical -errors -panics -or -even -undefined -behavior -. -This -verification -step -requires -visiting -all -of -the -transitions -in -the -DFA -which -can -be -costly -. -If -cheaper -verification -is -desired -then -[ -dense -: -: -DFA -: -: -from_bytes_unchecked -] -is -available -that -only -does -verification -that -can -be -performed -in -constant -time -. -However -one -can -only -use -this -routine -if -the -caller -can -guarantee -that -the -bytes -provided -encoded -a -valid -DFA -. -The -same -process -can -be -achieved -with -sparse -DFAs -as -well -: -use -regex_automata -: -: -{ -Match -dfa -: -: -{ -sparse -regex -: -: -Regex -} -} -; -let -re1 -= -Regex -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -. -unwrap -( -) -; -/ -/ -serialize -both -let -fwd_bytes -= -re1 -. -forward -( -) -. -to_sparse -( -) -? -. -to_bytes_native_endian -( -) -; -let -rev_bytes -= -re1 -. -reverse -( -) -. -to_sparse -( -) -? -. -to_bytes_native_endian -( -) -; -/ -/ -now -deserialize -both -- -- -- -we -need -to -specify -the -correct -type -! -let -fwd -: -sparse -: -: -DFA -< -& -[ -u8 -] -> -= -sparse -: -: -DFA -: -: -from_bytes -( -& -fwd_bytes -) -? -. -0 -; -let -rev -: -sparse -: -: -DFA -< -& -[ -u8 -] -> -= -sparse -: -: -DFA -: -: -from_bytes -( -& -rev_bytes -) -? -. -0 -; -/ -/ -finally -reconstruct -our -regex -let -re2 -= -Regex -: -: -builder -( -) -. -build_from_dfas -( -fwd -rev -) -; -/ -/ -we -can -use -it -like -normal -let -text -= -b -" -2018 -- -12 -- -24 -2016 -- -10 -- -08 -" -; -let -matches -: -Vec -< -Match -> -= -re2 -. -find_iter -( -text -) -. -collect -( -) -; -assert_eq -! -( -matches -vec -! -[ -Match -: -: -must -( -0 -0 -. -. -10 -) -Match -: -: -must -( -0 -11 -. -. -21 -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -Note -that -unlike -dense -DFAs -sparse -DFAs -have -no -alignment -requirements -. -Conversely -dense -DFAs -must -be -be -aligned -to -the -same -alignment -as -a -[ -StateID -] -( -crate -: -: -util -: -: -primitives -: -: -StateID -) -. -# -Support -for -no_std -and -alloc -- -only -This -crate -comes -with -alloc -and -std -features -that -are -enabled -by -default -. -When -the -alloc -or -std -features -are -enabled -the -API -of -this -module -will -include -the -facilities -necessary -for -compiling -serializing -deserializing -and -searching -with -DFAs -. -When -only -the -alloc -feature -is -enabled -then -implementations -of -the -std -: -: -error -: -: -Error -trait -are -dropped -but -everything -else -generally -remains -the -same -. -When -both -the -alloc -and -std -features -are -disabled -the -API -of -this -module -will -shrink -such -that -it -only -includes -the -facilities -necessary -for -deserializing -and -searching -with -DFAs -. -The -intended -workflow -for -no_std -environments -is -thus -as -follows -: -* -Write -a -program -with -the -alloc -or -std -features -that -compiles -and -serializes -a -regular -expression -. -You -may -need -to -serialize -both -little -and -big -endian -versions -of -each -DFA -. -( -So -that -' -s -4 -DFAs -in -total -for -each -regex -. -) -* -In -your -no_std -environment -follow -the -examples -above -for -deserializing -your -previously -serialized -DFAs -into -regexes -. -You -can -then -search -with -them -as -you -would -any -regex -. -Deserialization -can -happen -anywhere -. -For -example -with -bytes -embedded -into -a -binary -or -with -a -file -memory -mapped -at -runtime -. -The -regex -- -cli -command -( -found -in -the -same -repository -as -this -crate -) -can -be -used -to -serialize -DFAs -to -files -and -generate -Rust -code -to -read -them -. -# -Syntax -This -module -supports -the -same -syntax -as -the -regex -crate -since -they -share -the -same -parser -. -You -can -find -an -exhaustive -list -of -supported -syntax -in -the -[ -documentation -for -the -regex -crate -] -( -https -: -/ -/ -docs -. -rs -/ -regex -/ -1 -/ -regex -/ -# -syntax -) -. -There -are -two -things -that -are -not -supported -by -the -DFAs -in -this -module -: -* -Capturing -groups -. -The -DFAs -( -and -[ -Regex -] -( -regex -: -: -Regex -) -es -built -on -top -of -them -) -can -only -find -the -offsets -of -an -entire -match -but -cannot -resolve -the -offsets -of -each -capturing -group -. -This -is -because -DFAs -do -not -have -the -expressive -power -necessary -. -* -Unicode -word -boundaries -. -These -present -particularly -difficult -challenges -for -DFA -construction -and -would -result -in -an -explosion -in -the -number -of -states -. -One -can -enable -[ -dense -: -: -Config -: -: -unicode_word_boundary -] -though -which -provides -heuristic -support -for -Unicode -word -boundaries -that -only -works -on -ASCII -text -. -Otherwise -one -can -use -( -? -- -u -: -\ -b -) -for -an -ASCII -word -boundary -which -will -work -on -any -input -. -There -are -no -plans -to -lift -either -of -these -limitations -. -Note -that -these -restrictions -are -identical -to -the -restrictions -on -lazy -DFAs -. -# -Differences -with -general -purpose -regexes -The -main -goal -of -the -[ -regex -] -( -https -: -/ -/ -docs -. -rs -/ -regex -) -crate -is -to -serve -as -a -general -purpose -regular -expression -engine -. -It -aims -to -automatically -balance -low -compile -times -fast -search -times -and -low -memory -usage -while -also -providing -a -convenient -API -for -users -. -In -contrast -this -module -provides -a -lower -level -regular -expression -interface -based -exclusively -on -DFAs -that -is -a -bit -less -convenient -while -providing -more -explicit -control -over -memory -usage -and -search -times -. -Here -are -some -specific -negative -differences -: -* -* -* -Compilation -can -take -an -exponential -amount -of -time -and -space -* -* -in -the -size -of -the -regex -pattern -. -While -most -patterns -do -not -exhibit -worst -case -exponential -time -such -patterns -do -exist -. -For -example -[ -01 -] -* -1 -[ -01 -] -{ -N -} -will -build -a -DFA -with -approximately -2 -^ -( -N -+ -2 -) -states -. -For -this -reason -untrusted -patterns -should -not -be -compiled -with -this -module -. -( -In -the -future -the -API -may -expose -an -option -to -return -an -error -if -the -DFA -gets -too -big -. -) -* -This -module -does -not -support -sub -- -match -extraction -via -capturing -groups -which -can -be -achieved -with -the -regex -crate -' -s -" -captures -" -API -. -* -While -the -regex -crate -doesn -' -t -necessarily -sport -fast -compilation -times -the -regexes -in -this -module -are -almost -universally -slow -to -compile -especially -when -they -contain -large -Unicode -character -classes -. -For -example -on -my -system -compiling -\ -w -{ -50 -} -takes -about -1 -second -and -almost -15MB -of -memory -! -( -Compiling -a -sparse -regex -takes -about -the -same -time -but -only -uses -about -1 -. -2MB -of -memory -. -) -Conversely -compiling -the -same -regex -without -Unicode -support -e -. -g -. -( -? -- -u -) -\ -w -{ -50 -} -takes -under -1 -millisecond -and -about -15KB -of -memory -. -For -this -reason -you -should -only -use -Unicode -character -classes -if -you -absolutely -need -them -! -( -They -are -enabled -by -default -though -. -) -* -This -module -does -not -support -Unicode -word -boundaries -. -ASCII -word -bondaries -may -be -used -though -by -disabling -Unicode -or -selectively -doing -so -in -the -syntax -e -. -g -. -( -? -- -u -: -\ -b -) -. -There -is -also -an -option -to -[ -heuristically -enable -Unicode -word -boundaries -] -( -crate -: -: -dfa -: -: -dense -: -: -Config -: -: -unicode_word_boundary -) -where -the -corresponding -DFA -will -give -up -if -any -non -- -ASCII -byte -is -seen -. -* -As -a -lower -level -API -this -module -does -not -do -literal -optimizations -automatically -. -Although -it -does -provide -hooks -in -its -API -to -make -use -of -the -[ -Prefilter -] -( -crate -: -: -util -: -: -prefilter -: -: -Prefilter -) -trait -. -Missing -literal -optimizations -means -that -searches -may -run -much -slower -than -what -you -' -re -accustomed -to -although -it -does -provide -more -predictable -and -consistent -performance -. -* -There -is -no -& -str -API -like -in -the -regex -crate -. -In -this -module -all -APIs -operate -on -& -[ -u8 -] -. -By -default -match -indices -are -guaranteed -to -fall -on -UTF -- -8 -boundaries -unless -either -of -[ -syntax -: -: -Config -: -: -utf8 -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -utf8 -) -or -[ -thompson -: -: -Config -: -: -utf8 -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -: -: -utf8 -) -are -disabled -. -With -some -of -the -downsides -out -of -the -way -here -are -some -positive -differences -: -* -Both -dense -and -sparse -DFAs -can -be -serialized -to -raw -bytes -and -then -cheaply -deserialized -. -Deserialization -can -be -done -in -constant -time -with -the -unchecked -APIs -since -searching -can -be -performed -directly -on -the -raw -serialized -bytes -of -a -DFA -. -* -This -module -was -specifically -designed -so -that -the -searching -phase -of -a -DFA -has -minimal -runtime -requirements -and -can -therefore -be -used -in -no_std -environments -. -While -no_std -environments -cannot -compile -regexes -they -can -deserialize -pre -- -compiled -regexes -. -* -Since -this -module -builds -DFAs -ahead -of -time -it -will -generally -out -- -perform -the -regex -crate -on -equivalent -tasks -. -The -performance -difference -is -likely -not -large -. -However -because -of -a -complex -set -of -optimizations -in -the -regex -crate -( -like -literal -optimizations -) -an -accurate -performance -comparison -may -be -difficult -to -do -. -* -Sparse -DFAs -provide -a -way -to -build -a -DFA -ahead -of -time -that -sacrifices -search -performance -a -small -amount -but -uses -much -less -storage -space -. -Potentially -even -less -than -what -the -regex -crate -uses -. -* -This -module -exposes -DFAs -directly -such -as -[ -dense -: -: -DFA -] -and -[ -sparse -: -: -DFA -] -which -enables -one -to -do -less -work -in -some -cases -. -For -example -if -you -only -need -the -end -of -a -match -and -not -the -start -of -a -match -then -you -can -use -a -DFA -directly -without -building -a -Regex -which -always -requires -a -second -DFA -to -find -the -start -of -a -match -. -* -This -module -provides -more -control -over -memory -usage -. -Aside -from -choosing -between -dense -and -sparse -DFAs -one -can -also -choose -a -smaller -state -identifier -representation -to -use -less -space -. -Also -one -can -enable -DFA -minimization -via -[ -dense -: -: -Config -: -: -minimize -] -but -it -can -increase -compilation -times -dramatically -. -* -/ -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -pub -use -crate -: -: -dfa -: -: -{ -automaton -: -: -{ -Automaton -OverlappingState -} -start -: -: -StartKind -} -; -/ -/ -/ -This -is -an -alias -for -a -state -ID -of -zero -. -It -has -special -significance -/ -/ -/ -because -it -always -corresponds -to -the -first -state -in -a -DFA -and -the -first -/ -/ -/ -state -in -a -DFA -is -always -" -dead -. -" -That -is -the -dead -state -always -has -all -/ -/ -/ -of -its -transitions -set -to -itself -. -Moreover -the -dead -state -is -used -as -a -/ -/ -/ -sentinel -for -various -things -. -e -. -g -. -In -search -reaching -a -dead -state -means -/ -/ -/ -that -the -search -must -stop -. -const -DEAD -: -crate -: -: -util -: -: -primitives -: -: -StateID -= -crate -: -: -util -: -: -primitives -: -: -StateID -: -: -ZERO -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -pub -mod -dense -; -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -pub -mod -onepass -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -pub -mod -regex -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -pub -mod -sparse -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -pub -( -crate -) -mod -accel -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -mod -automaton -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -mod -determinize -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -mod -minimize -; -# -[ -cfg -( -any -( -feature -= -" -dfa -- -build -" -feature -= -" -dfa -- -onepass -" -) -) -] -mod -remapper -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -mod -search -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -mod -special -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -mod -start -; diff --git a/third_party/rust/regex-automata/src/dfa/onepass.rs b/third_party/rust/regex-automata/src/dfa/onepass.rs deleted file mode 100644 index fe241d890cda9..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/onepass.rs +++ /dev/null @@ -1,32484 +0,0 @@ -/ -* -! -A -DFA -that -can -return -spans -for -matching -capturing -groups -. -This -module -is -the -home -of -a -[ -one -- -pass -DFA -] -( -DFA -) -. -This -module -also -contains -a -[ -Builder -] -and -a -[ -Config -] -for -building -and -configuring -a -one -- -pass -DFA -. -* -/ -/ -/ -A -note -on -naming -and -credit -: -/ -/ -/ -/ -As -far -as -I -know -Russ -Cox -came -up -with -the -practical -vision -and -/ -/ -implementation -of -a -" -one -- -pass -regex -engine -. -" -He -mentions -and -describes -it -/ -/ -briefly -in -the -third -article -of -his -regexp -article -series -: -/ -/ -https -: -/ -/ -swtch -. -com -/ -~ -rsc -/ -regexp -/ -regexp3 -. -html -/ -/ -/ -/ -Cox -' -s -implementation -is -in -RE2 -and -the -implementation -below -is -most -/ -/ -heavily -inspired -by -RE2 -' -s -. -The -key -thing -they -have -in -common -is -that -/ -/ -their -transitions -are -defined -over -an -alphabet -of -bytes -. -In -contrast -/ -/ -Go -' -s -regex -engine -also -has -a -one -- -pass -engine -but -its -transitions -are -/ -/ -more -firmly -rooted -on -Unicode -codepoints -. -The -ideas -are -the -same -but -the -/ -/ -implementations -are -different -. -/ -/ -/ -/ -RE2 -tends -to -call -this -a -" -one -- -pass -NFA -. -" -Here -we -call -it -a -" -one -- -pass -DFA -. -" -/ -/ -They -' -re -both -true -in -their -own -ways -: -/ -/ -/ -/ -* -The -" -one -- -pass -" -criterion -is -generally -a -property -of -the -NFA -itself -. -In -/ -/ -particular -it -is -said -that -an -NFA -is -one -- -pass -if -after -each -byte -of -input -/ -/ -during -a -search -there -is -at -most -one -" -VM -thread -" -remaining -to -take -for -the -/ -/ -next -byte -of -input -. -That -is -there -is -never -any -ambiguity -as -to -the -path -to -/ -/ -take -through -the -NFA -during -a -search -. -/ -/ -/ -/ -* -On -the -other -hand -once -a -one -- -pass -NFA -has -its -representation -converted -/ -/ -to -something -where -a -constant -number -of -instructions -is -used -for -each -byte -/ -/ -of -input -the -implementation -looks -a -lot -more -like -a -DFA -. -It -' -s -technically -/ -/ -more -powerful -than -a -DFA -since -it -has -side -effects -( -storing -offsets -inside -/ -/ -of -slots -activated -by -a -transition -) -but -it -is -far -closer -to -a -DFA -than -an -/ -/ -NFA -simulation -. -/ -/ -/ -/ -Thus -in -this -crate -we -call -it -a -one -- -pass -DFA -. -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -dfa -: -: -{ -remapper -: -: -Remapper -DEAD -} -nfa -: -: -thompson -: -: -{ -self -NFA -} -util -: -: -{ -alphabet -: -: -ByteClasses -captures -: -: -Captures -escape -: -: -DebugByte -int -: -: -{ -Usize -U32 -U64 -U8 -} -look -: -: -{ -Look -LookSet -UnicodeWordBoundaryError -} -primitives -: -: -{ -NonMaxUsize -PatternID -StateID -} -search -: -: -{ -Anchored -Input -Match -MatchError -MatchKind -Span -} -sparse_set -: -: -SparseSet -} -} -; -/ -/ -/ -The -configuration -used -for -building -a -[ -one -- -pass -DFA -] -( -DFA -) -. -/ -/ -/ -/ -/ -/ -A -one -- -pass -DFA -configuration -is -a -simple -data -object -that -is -typically -used -/ -/ -/ -with -[ -Builder -: -: -configure -] -. -It -can -be -cheaply -cloned -. -/ -/ -/ -/ -/ -/ -A -default -configuration -can -be -created -either -with -Config -: -: -new -or -/ -/ -/ -perhaps -more -conveniently -with -[ -DFA -: -: -config -] -. -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -Config -{ -match_kind -: -Option -< -MatchKind -> -starts_for_each_pattern -: -Option -< -bool -> -byte_classes -: -Option -< -bool -> -size_limit -: -Option -< -Option -< -usize -> -> -} -impl -Config -{ -/ -/ -/ -Return -a -new -default -one -- -pass -DFA -configuration -. -pub -fn -new -( -) -- -> -Config -{ -Config -: -: -default -( -) -} -/ -/ -/ -Set -the -desired -match -semantics -. -/ -/ -/ -/ -/ -/ -The -default -is -[ -MatchKind -: -: -LeftmostFirst -] -which -corresponds -to -the -/ -/ -/ -match -semantics -of -Perl -- -like -regex -engines -. -That -is -when -multiple -/ -/ -/ -patterns -would -match -at -the -same -leftmost -position -the -pattern -that -/ -/ -/ -appears -first -in -the -concrete -syntax -is -chosen -. -/ -/ -/ -/ -/ -/ -Currently -the -only -other -kind -of -match -semantics -supported -is -/ -/ -/ -[ -MatchKind -: -: -All -] -. -This -corresponds -to -" -classical -DFA -" -construction -/ -/ -/ -where -all -possible -matches -are -visited -. -/ -/ -/ -/ -/ -/ -When -it -comes -to -the -one -- -pass -DFA -it -is -rarer -for -preference -order -and -/ -/ -/ -" -longest -match -" -to -actually -disagree -. -Since -if -they -did -disagree -then -/ -/ -/ -the -regex -typically -isn -' -t -one -- -pass -. -For -example -searching -Samwise -/ -/ -/ -for -Sam -| -Samwise -will -report -Sam -for -leftmost -- -first -matching -and -/ -/ -/ -Samwise -for -" -longest -match -" -or -" -all -" -matching -. -However -this -regex -is -/ -/ -/ -not -one -- -pass -if -taken -literally -. -The -equivalent -regex -Sam -( -? -: -| -wise -) -/ -/ -/ -is -one -- -pass -and -Sam -| -Samwise -may -be -optimized -to -it -. -/ -/ -/ -/ -/ -/ -The -other -main -difference -is -that -" -all -" -match -semantics -don -' -t -support -/ -/ -/ -non -- -greedy -matches -. -" -All -" -match -semantics -always -try -to -match -as -much -/ -/ -/ -as -possible -. -pub -fn -match_kind -( -mut -self -kind -: -MatchKind -) -- -> -Config -{ -self -. -match_kind -= -Some -( -kind -) -; -self -} -/ -/ -/ -Whether -to -compile -a -separate -start -state -for -each -pattern -in -the -/ -/ -/ -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -When -enabled -a -separate -* -* -anchored -* -* -start -state -is -added -for -each -/ -/ -/ -pattern -in -the -DFA -. -When -this -start -state -is -used -then -the -DFA -will -/ -/ -/ -only -search -for -matches -for -the -pattern -specified -even -if -there -are -/ -/ -/ -other -patterns -in -the -DFA -. -/ -/ -/ -/ -/ -/ -The -main -downside -of -this -option -is -that -it -can -potentially -increase -/ -/ -/ -the -size -of -the -DFA -and -/ -or -increase -the -time -it -takes -to -build -the -DFA -. -/ -/ -/ -/ -/ -/ -You -might -want -to -enable -this -option -when -you -want -to -both -search -for -/ -/ -/ -anchored -matches -of -any -pattern -or -to -search -for -anchored -matches -of -/ -/ -/ -one -particular -pattern -while -using -the -same -DFA -. -( -Otherwise -you -would -/ -/ -/ -need -to -compile -a -new -DFA -for -each -pattern -. -) -/ -/ -/ -/ -/ -/ -By -default -this -is -disabled -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -multi -- -regex -and -then -search -for -/ -/ -/ -matches -for -a -any -of -the -patterns -or -matches -for -a -specific -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -onepass -: -: -DFA -Anchored -Input -Match -PatternID -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -starts_for_each_pattern -( -true -) -) -/ -/ -/ -. -build_many -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -123abc -" -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -/ -/ -/ -/ -/ -A -normal -multi -- -pattern -search -will -show -pattern -1 -matches -. -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -input -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -0 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -If -we -only -want -to -report -pattern -0 -matches -then -we -' -ll -get -no -/ -/ -/ -/ -/ -match -here -. -/ -/ -/ -let -input -= -input -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -0 -) -) -) -; -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -input -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -starts_for_each_pattern -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -starts_for_each_pattern -= -Some -( -yes -) -; -self -} -/ -/ -/ -Whether -to -attempt -to -shrink -the -size -of -the -DFA -' -s -alphabet -or -not -. -/ -/ -/ -/ -/ -/ -This -option -is -enabled -by -default -and -should -never -be -disabled -unless -/ -/ -/ -one -is -debugging -a -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -When -enabled -the -DFA -will -use -a -map -from -all -possible -bytes -to -their -/ -/ -/ -corresponding -equivalence -class -. -Each -equivalence -class -represents -a -/ -/ -/ -set -of -bytes -that -does -not -discriminate -between -a -match -and -a -non -- -match -/ -/ -/ -in -the -DFA -. -For -example -the -pattern -[ -ab -] -+ -has -at -least -two -/ -/ -/ -equivalence -classes -: -a -set -containing -a -and -b -and -a -set -containing -/ -/ -/ -every -byte -except -for -a -and -b -. -a -and -b -are -in -the -same -/ -/ -/ -equivalence -class -because -they -never -discriminate -between -a -match -and -a -/ -/ -/ -non -- -match -. -/ -/ -/ -/ -/ -/ -The -advantage -of -this -map -is -that -the -size -of -the -transition -table -/ -/ -/ -can -be -reduced -drastically -from -( -approximately -) -# -states -* -256 -* -/ -/ -/ -sizeof -( -StateID -) -to -# -states -* -k -* -sizeof -( -StateID -) -where -k -is -the -/ -/ -/ -number -of -equivalence -classes -( -rounded -up -to -the -nearest -power -of -2 -) -. -/ -/ -/ -As -a -result -total -space -usage -can -decrease -substantially -. -Moreover -/ -/ -/ -since -a -smaller -alphabet -is -used -DFA -compilation -becomes -faster -as -/ -/ -/ -well -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -This -is -only -useful -for -debugging -DFAs -. -Disabling -this -/ -/ -/ -does -not -yield -any -speed -advantages -. -Namely -even -when -this -is -/ -/ -/ -disabled -a -byte -class -map -is -still -used -while -searching -. -The -only -/ -/ -/ -difference -is -that -every -byte -will -be -forced -into -its -own -distinct -/ -/ -/ -equivalence -class -. -This -is -useful -for -debugging -the -actual -generated -/ -/ -/ -transitions -because -it -lets -one -see -the -transitions -defined -on -actual -/ -/ -/ -bytes -instead -of -the -equivalence -classes -. -pub -fn -byte_classes -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -byte_classes -= -Some -( -yes -) -; -self -} -/ -/ -/ -Set -a -size -limit -on -the -total -heap -used -by -a -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -This -size -limit -is -expressed -in -bytes -and -is -applied -during -/ -/ -/ -construction -of -a -one -- -pass -DFA -. -If -the -DFA -' -s -heap -usage -exceeds -/ -/ -/ -this -configured -limit -then -construction -is -stopped -and -an -error -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -default -is -no -limit -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -one -- -pass -DFA -that -fails -to -build -because -of -/ -/ -/ -a -configured -size -limit -. -This -particular -example -also -serves -as -a -/ -/ -/ -cautionary -tale -demonstrating -just -how -big -DFAs -with -large -Unicode -/ -/ -/ -character -classes -can -get -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -} -; -/ -/ -/ -/ -/ -/ -/ -/ -6MB -isn -' -t -enough -! -/ -/ -/ -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -size_limit -( -Some -( -6_000_000 -) -) -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -/ -/ -/ -. -unwrap_err -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -. -. -. -but -7MB -probably -is -! -/ -/ -/ -/ -/ -( -Note -that -DFA -sizes -aren -' -t -necessarily -stable -between -releases -. -) -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -size_limit -( -Some -( -7_000_000 -) -) -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -A -" -. -repeat -( -20 -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -& -haystack -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -20 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -While -one -needs -a -little -more -than -3MB -to -represent -\ -w -{ -20 -} -it -/ -/ -/ -turns -out -that -you -only -need -a -little -more -than -4KB -to -represent -/ -/ -/ -( -? -- -u -: -\ -w -{ -20 -} -) -. -So -only -use -Unicode -if -you -need -it -! -pub -fn -size_limit -( -mut -self -limit -: -Option -< -usize -> -) -- -> -Config -{ -self -. -size_limit -= -Some -( -limit -) -; -self -} -/ -/ -/ -Returns -the -match -semantics -set -in -this -configuration -. -pub -fn -get_match_kind -( -& -self -) -- -> -MatchKind -{ -self -. -match_kind -. -unwrap_or -( -MatchKind -: -: -LeftmostFirst -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -anchored -starting -states -/ -/ -/ -for -every -pattern -in -the -DFA -. -pub -fn -get_starts_for_each_pattern -( -& -self -) -- -> -bool -{ -self -. -starts_for_each_pattern -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -byte -classes -or -not -. -/ -/ -/ -This -is -typically -a -debugging -oriented -option -as -disabling -it -confers -/ -/ -/ -no -speed -benefit -. -pub -fn -get_byte_classes -( -& -self -) -- -> -bool -{ -self -. -byte_classes -. -unwrap_or -( -true -) -} -/ -/ -/ -Returns -the -DFA -size -limit -of -this -configuration -if -one -was -set -. -/ -/ -/ -The -size -limit -is -total -number -of -bytes -on -the -heap -that -a -DFA -is -/ -/ -/ -permitted -to -use -. -If -the -DFA -exceeds -this -limit -during -construction -/ -/ -/ -then -construction -is -stopped -and -an -error -is -returned -. -pub -fn -get_size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -size_limit -. -unwrap_or -( -None -) -} -/ -/ -/ -Overwrite -the -default -configuration -such -that -the -options -in -o -are -/ -/ -/ -always -used -. -If -an -option -in -o -is -not -set -then -the -corresponding -/ -/ -/ -option -in -self -is -used -. -If -it -' -s -not -set -in -self -either -then -it -/ -/ -/ -remains -not -set -. -pub -( -crate -) -fn -overwrite -( -& -self -o -: -Config -) -- -> -Config -{ -Config -{ -match_kind -: -o -. -match_kind -. -or -( -self -. -match_kind -) -starts_for_each_pattern -: -o -. -starts_for_each_pattern -. -or -( -self -. -starts_for_each_pattern -) -byte_classes -: -o -. -byte_classes -. -or -( -self -. -byte_classes -) -size_limit -: -o -. -size_limit -. -or -( -self -. -size_limit -) -} -} -} -/ -/ -/ -A -builder -for -a -[ -one -- -pass -DFA -] -( -DFA -) -. -/ -/ -/ -/ -/ -/ -This -builder -permits -configuring -options -for -the -syntax -of -a -pattern -the -/ -/ -/ -NFA -construction -and -the -DFA -construction -. -This -builder -is -different -from -a -/ -/ -/ -general -purpose -regex -builder -in -that -it -permits -fine -grain -configuration -/ -/ -/ -of -the -construction -process -. -The -trade -off -for -this -is -complexity -and -/ -/ -/ -the -possibility -of -setting -a -configuration -that -might -not -make -sense -. -For -/ -/ -/ -example -there -are -two -different -UTF -- -8 -modes -: -/ -/ -/ -/ -/ -/ -* -[ -syntax -: -: -Config -: -: -utf8 -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -utf8 -) -controls -/ -/ -/ -whether -the -pattern -itself -can -contain -sub -- -expressions -that -match -invalid -/ -/ -/ -UTF -- -8 -. -/ -/ -/ -* -[ -thompson -: -: -Config -: -: -utf8 -] -controls -whether -empty -matches -that -split -a -/ -/ -/ -Unicode -codepoint -are -reported -or -not -. -/ -/ -/ -/ -/ -/ -Generally -speaking -callers -will -want -to -either -enable -all -of -these -or -/ -/ -/ -disable -all -of -these -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -disable -UTF -- -8 -mode -in -the -syntax -and -the -NFA -. -/ -/ -/ -This -is -generally -what -you -want -for -matching -on -arbitrary -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -onepass -: -: -DFA -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -util -: -: -syntax -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -foo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -haystack -& -mut -caps -) -; -/ -/ -/ -/ -/ -Notice -that -( -? -- -u -: -[ -^ -b -] -) -matches -invalid -UTF -- -8 -/ -/ -/ -/ -/ -but -the -subsequent -. -* -does -not -! -Disabling -UTF -- -8 -/ -/ -/ -/ -/ -on -the -syntax -permits -this -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -This -example -does -not -show -the -impact -of -/ -/ -/ -/ -/ -disabling -UTF -- -8 -mode -on -a -one -- -pass -DFA -Config -/ -/ -/ -/ -/ -since -that -only -impacts -regexes -that -can -/ -/ -/ -/ -/ -produce -matches -of -length -0 -. -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -8 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Builder -{ -config -: -Config -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -} -impl -Builder -{ -/ -/ -/ -Create -a -new -one -- -pass -DFA -builder -with -the -default -configuration -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -{ -config -: -Config -: -: -default -( -) -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -: -: -new -( -) -} -} -/ -/ -/ -Build -a -one -- -pass -DFA -from -the -given -pattern -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -or -compiling -the -pattern -then -an -error -/ -/ -/ -is -returned -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -DFA -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Build -a -one -- -pass -DFA -from -the -given -patterns -. -/ -/ -/ -/ -/ -/ -When -matches -are -returned -the -pattern -ID -corresponds -to -the -index -of -/ -/ -/ -the -pattern -in -the -slice -given -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -DFA -BuildError -> -{ -let -nfa -= -self -. -thompson -. -build_many -( -patterns -) -. -map_err -( -BuildError -: -: -nfa -) -? -; -self -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Build -a -DFA -from -the -given -NFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -DFA -if -you -already -have -an -NFA -in -/ -/ -/ -hand -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -nfa -: -: -thompson -: -: -NFA -Match -} -; -/ -/ -/ -/ -/ -/ -/ -/ -This -shows -how -to -set -non -- -default -options -for -building -an -NFA -. -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -shrink -( -true -) -) -/ -/ -/ -. -build -( -r -" -[ -a -- -z0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -. -build_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -foo123bar -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -9 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_from_nfa -( -& -self -nfa -: -NFA -) -- -> -Result -< -DFA -BuildError -> -{ -/ -/ -Why -take -ownership -if -we -' -re -just -going -to -pass -a -reference -to -the -/ -/ -NFA -to -our -internal -builder -? -Well -the -first -thing -to -note -is -that -/ -/ -an -NFA -uses -reference -counting -internally -so -either -choice -is -going -/ -/ -to -be -cheap -. -So -there -isn -' -t -much -cost -either -way -. -/ -/ -/ -/ -The -real -reason -is -that -a -one -- -pass -DFA -semantically -shares -/ -/ -ownership -of -an -NFA -. -This -is -unlike -other -DFAs -that -don -' -t -share -/ -/ -ownership -of -an -NFA -at -all -primarily -because -they -want -to -be -/ -/ -self -- -contained -in -order -to -support -cheap -( -de -) -serialization -. -/ -/ -/ -/ -But -then -why -pass -a -' -& -nfa -' -below -if -we -want -to -share -ownership -? -/ -/ -Well -it -turns -out -that -using -a -' -& -NFA -' -in -our -internal -builder -/ -/ -separates -its -lifetime -from -the -DFA -we -' -re -building -and -this -turns -/ -/ -out -to -make -code -a -bit -more -composable -. -e -. -g -. -We -can -iterate -over -/ -/ -things -inside -the -NFA -while -borrowing -the -builder -as -mutable -because -/ -/ -we -know -the -NFA -cannot -be -mutated -. -So -TL -; -DR -- -- -- -this -weirdness -is -/ -/ -" -because -borrow -checker -. -" -InternalBuilder -: -: -new -( -self -. -config -. -clone -( -) -& -nfa -) -. -build -( -) -} -/ -/ -/ -Apply -the -given -one -- -pass -DFA -configuration -options -to -this -builder -. -pub -fn -configure -( -& -mut -self -config -: -Config -) -- -> -& -mut -Builder -{ -self -. -config -= -self -. -config -. -overwrite -( -config -) -; -self -} -/ -/ -/ -Set -the -syntax -configuration -for -this -builder -using -/ -/ -/ -[ -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -case -insensitivity -Unicode -and -multi -/ -/ -/ -line -mode -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -one -- -pass -DFA -directly -/ -/ -/ -from -a -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -syntax -( -config -) -; -self -} -/ -/ -/ -Set -the -Thompson -NFA -configuration -for -this -builder -using -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -whether -additional -time -should -be -/ -/ -/ -spent -shrinking -the -size -of -the -NFA -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -DFA -directly -from -a -/ -/ -/ -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -thompson -( -& -mut -self -config -: -thompson -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -configure -( -config -) -; -self -} -} -/ -/ -/ -An -internal -builder -for -encapsulating -the -state -necessary -to -build -a -/ -/ -/ -one -- -pass -DFA -. -Typical -use -is -just -InternalBuilder -: -: -new -( -. -. -) -. -build -( -) -. -/ -/ -/ -/ -/ -/ -There -is -no -separate -pass -for -determining -whether -the -NFA -is -one -- -pass -or -/ -/ -/ -not -. -We -just -try -to -build -the -DFA -. -If -during -construction -we -discover -that -/ -/ -/ -it -is -not -one -- -pass -we -bail -out -. -This -is -likely -to -lead -to -some -undesirable -/ -/ -/ -expense -in -some -cases -so -it -might -make -sense -to -try -an -identify -common -/ -/ -/ -patterns -in -the -NFA -that -make -it -definitively -not -one -- -pass -. -That -way -we -/ -/ -/ -can -avoid -ever -trying -to -build -a -one -- -pass -DFA -in -the -first -place -. -For -/ -/ -/ -example -' -\ -w -* -\ -s -' -is -not -one -- -pass -and -since -' -\ -w -' -is -Unicode -- -aware -by -/ -/ -/ -default -it -' -s -probably -not -a -trivial -cost -to -try -and -build -a -one -- -pass -DFA -/ -/ -/ -for -it -and -then -fail -. -/ -/ -/ -/ -/ -/ -Note -that -some -( -immutable -) -fields -are -duplicated -here -. -For -example -the -/ -/ -/ -' -nfa -' -and -' -classes -' -fields -are -both -in -the -' -DFA -' -. -They -are -the -same -thing -/ -/ -/ -but -we -duplicate -them -because -it -makes -composition -easier -below -. -Otherwise -/ -/ -/ -since -the -borrow -checker -can -' -t -see -through -method -calls -the -mutable -borrow -/ -/ -/ -we -use -to -mutate -the -DFA -winds -up -preventing -borrowing -from -any -other -part -/ -/ -/ -of -the -DFA -even -though -we -aren -' -t -mutating -those -parts -. -We -only -do -this -/ -/ -/ -because -the -duplication -is -cheap -. -# -[ -derive -( -Debug -) -] -struct -InternalBuilder -< -' -a -> -{ -/ -/ -/ -The -DFA -we -' -re -building -. -dfa -: -DFA -/ -/ -/ -An -unordered -collection -of -NFA -state -IDs -that -we -haven -' -t -yet -tried -to -/ -/ -/ -build -into -a -DFA -state -yet -. -/ -/ -/ -/ -/ -/ -This -collection -does -not -ultimately -wind -up -including -every -NFA -state -/ -/ -/ -ID -. -Instead -each -ID -represents -a -" -start -" -state -for -a -sub -- -graph -of -the -/ -/ -/ -NFA -. -The -set -of -NFA -states -we -then -use -to -build -a -DFA -state -consists -/ -/ -/ -of -that -" -start -" -state -and -all -states -reachable -from -it -via -epsilon -/ -/ -/ -transitions -. -uncompiled_nfa_ids -: -Vec -< -StateID -> -/ -/ -/ -A -map -from -NFA -state -ID -to -DFA -state -ID -. -This -is -useful -for -easily -/ -/ -/ -determining -whether -an -NFA -state -has -been -used -as -a -" -starting -" -point -/ -/ -/ -to -build -a -DFA -state -yet -. -If -it -hasn -' -t -then -it -is -mapped -to -DEAD -/ -/ -/ -and -since -DEAD -is -specially -added -and -never -corresponds -to -any -NFA -/ -/ -/ -state -it -follows -that -a -mapping -to -DEAD -implies -the -NFA -state -has -/ -/ -/ -no -corresponding -DFA -state -yet -. -nfa_to_dfa_id -: -Vec -< -StateID -> -/ -/ -/ -A -stack -used -to -traverse -the -NFA -states -that -make -up -a -single -DFA -/ -/ -/ -state -. -Traversal -occurs -until -the -stack -is -empty -and -we -only -push -to -/ -/ -/ -the -stack -when -the -state -ID -isn -' -t -in -' -seen -' -. -Actually -even -more -than -/ -/ -/ -that -if -we -try -to -push -something -on -to -this -stack -that -is -already -in -/ -/ -/ -' -seen -' -then -we -bail -out -on -construction -completely -since -it -implies -/ -/ -/ -that -the -NFA -is -not -one -- -pass -. -stack -: -Vec -< -( -StateID -Epsilons -) -> -/ -/ -/ -The -set -of -NFA -states -that -we -' -ve -visited -via -' -stack -' -. -seen -: -SparseSet -/ -/ -/ -Whether -a -match -NFA -state -has -been -observed -while -constructing -a -/ -/ -/ -one -- -pass -DFA -state -. -Once -a -match -state -is -seen -assuming -we -are -using -/ -/ -/ -leftmost -- -first -match -semantics -then -we -don -' -t -add -any -more -transitions -/ -/ -/ -to -the -DFA -state -we -' -re -building -. -matched -: -bool -/ -/ -/ -The -config -passed -to -the -builder -. -/ -/ -/ -/ -/ -/ -This -is -duplicated -in -dfa -. -config -. -config -: -Config -/ -/ -/ -The -NFA -we -' -re -building -a -one -- -pass -DFA -from -. -/ -/ -/ -/ -/ -/ -This -is -duplicated -in -dfa -. -nfa -. -nfa -: -& -' -a -NFA -/ -/ -/ -The -equivalence -classes -that -make -up -the -alphabet -for -this -DFA -> -/ -/ -/ -/ -/ -/ -This -is -duplicated -in -dfa -. -classes -. -classes -: -ByteClasses -} -impl -< -' -a -> -InternalBuilder -< -' -a -> -{ -/ -/ -/ -Create -a -new -builder -with -an -initial -empty -DFA -. -fn -new -( -config -: -Config -nfa -: -& -' -a -NFA -) -- -> -InternalBuilder -{ -let -classes -= -if -! -config -. -get_byte_classes -( -) -{ -/ -/ -A -one -- -pass -DFA -will -always -use -the -equivalence -class -map -but -/ -/ -enabling -this -option -is -useful -for -debugging -. -Namely -this -will -/ -/ -cause -all -transitions -to -be -defined -over -their -actual -bytes -/ -/ -instead -of -an -opaque -equivalence -class -identifier -. -The -former -is -/ -/ -much -easier -to -grok -as -a -human -. -ByteClasses -: -: -singletons -( -) -} -else -{ -nfa -. -byte_classes -( -) -. -clone -( -) -} -; -/ -/ -Normally -a -DFA -alphabet -includes -the -EOI -symbol -but -we -don -' -t -need -/ -/ -that -in -the -one -- -pass -DFA -since -we -handle -look -- -around -explicitly -/ -/ -without -encoding -it -into -the -DFA -. -Thus -we -don -' -t -need -to -delay -/ -/ -matches -by -1 -byte -. -However -we -reuse -the -space -that -* -would -* -be -used -/ -/ -by -the -EOI -transition -by -putting -match -information -there -( -like -which -/ -/ -pattern -matches -and -which -look -- -around -assertions -need -to -hold -) -. -So -/ -/ -this -means -our -real -alphabet -length -is -1 -fewer -than -what -the -byte -/ -/ -classes -report -since -we -don -' -t -use -EOI -. -let -alphabet_len -= -classes -. -alphabet_len -( -) -. -checked_sub -( -1 -) -. -unwrap -( -) -; -let -stride2 -= -classes -. -stride2 -( -) -; -let -dfa -= -DFA -{ -config -: -config -. -clone -( -) -nfa -: -nfa -. -clone -( -) -table -: -vec -! -[ -] -starts -: -vec -! -[ -] -/ -/ -Since -one -- -pass -DFAs -have -a -smaller -state -ID -max -than -/ -/ -StateID -: -: -MAX -it -follows -that -StateID -: -: -MAX -is -a -valid -initial -/ -/ -value -for -min_match_id -since -no -state -ID -can -ever -be -greater -/ -/ -than -it -. -In -the -case -of -a -one -- -pass -DFA -with -no -match -states -the -/ -/ -min_match_id -will -keep -this -sentinel -value -. -min_match_id -: -StateID -: -: -MAX -classes -: -classes -. -clone -( -) -alphabet_len -stride2 -pateps_offset -: -alphabet_len -/ -/ -OK -because -PatternID -: -: -MAX -* -2 -is -guaranteed -not -to -overflow -. -explicit_slot_start -: -nfa -. -pattern_len -( -) -. -checked_mul -( -2 -) -. -unwrap -( -) -} -; -InternalBuilder -{ -dfa -uncompiled_nfa_ids -: -vec -! -[ -] -nfa_to_dfa_id -: -vec -! -[ -DEAD -; -nfa -. -states -( -) -. -len -( -) -] -stack -: -vec -! -[ -] -seen -: -SparseSet -: -: -new -( -nfa -. -states -( -) -. -len -( -) -) -matched -: -false -config -nfa -classes -} -} -/ -/ -/ -Build -the -DFA -from -the -NFA -given -to -this -builder -. -If -the -NFA -is -not -/ -/ -/ -one -- -pass -then -return -an -error -. -An -error -may -also -be -returned -if -a -/ -/ -/ -particular -limit -is -exceeded -. -( -Some -limits -like -the -total -heap -memory -/ -/ -/ -used -are -configurable -. -Others -like -the -total -patterns -or -slots -are -/ -/ -/ -hard -- -coded -based -on -representational -limitations -. -) -fn -build -( -mut -self -) -- -> -Result -< -DFA -BuildError -> -{ -self -. -nfa -. -look_set_any -( -) -. -available -( -) -. -map_err -( -BuildError -: -: -word -) -? -; -for -look -in -self -. -nfa -. -look_set_any -( -) -. -iter -( -) -{ -/ -/ -This -is -a -future -incompatibility -check -where -if -we -add -any -/ -/ -more -look -- -around -assertions -then -the -one -- -pass -DFA -either -/ -/ -needs -to -reject -them -( -what -we -do -here -) -or -it -needs -to -have -its -/ -/ -Transition -representation -modified -to -be -capable -of -storing -the -/ -/ -new -assertions -. -if -look -. -as_repr -( -) -> -Look -: -: -WordUnicodeNegate -. -as_repr -( -) -{ -return -Err -( -BuildError -: -: -unsupported_look -( -look -) -) -; -} -} -if -self -. -nfa -. -pattern_len -( -) -. -as_u64 -( -) -> -PatternEpsilons -: -: -PATTERN_ID_LIMIT -{ -return -Err -( -BuildError -: -: -too_many_patterns -( -PatternEpsilons -: -: -PATTERN_ID_LIMIT -) -) -; -} -if -self -. -nfa -. -group_info -( -) -. -explicit_slot_len -( -) -> -Slots -: -: -LIMIT -{ -return -Err -( -BuildError -: -: -not_one_pass -( -" -too -many -explicit -capturing -groups -( -max -is -16 -) -" -) -) -; -} -assert_eq -! -( -DEAD -self -. -add_empty_state -( -) -? -) -; -/ -/ -This -is -where -the -explicit -slots -start -. -We -care -about -this -because -/ -/ -we -only -need -to -track -explicit -slots -. -The -implicit -slots -- -- -- -two -for -/ -/ -each -pattern -- -- -- -are -tracked -as -part -of -the -search -routine -itself -. -let -explicit_slot_start -= -self -. -nfa -. -pattern_len -( -) -* -2 -; -self -. -add_start_state -( -None -self -. -nfa -. -start_anchored -( -) -) -? -; -if -self -. -config -. -get_starts_for_each_pattern -( -) -{ -for -pid -in -self -. -nfa -. -patterns -( -) -{ -self -. -add_start_state -( -Some -( -pid -) -self -. -nfa -. -start_pattern -( -pid -) -. -unwrap -( -) -) -? -; -} -} -/ -/ -NOTE -: -One -wonders -what -the -effects -of -treating -' -uncompiled_nfa_ids -' -/ -/ -as -a -stack -are -. -It -is -really -an -unordered -* -set -* -of -NFA -state -IDs -. -/ -/ -If -it -for -example -in -practice -led -to -discovering -whether -a -regex -/ -/ -was -or -wasn -' -t -one -- -pass -later -than -if -we -processed -NFA -state -IDs -in -/ -/ -ascending -order -then -that -would -make -this -routine -more -costly -in -/ -/ -the -somewhat -common -case -of -a -regex -that -isn -' -t -one -- -pass -. -while -let -Some -( -nfa_id -) -= -self -. -uncompiled_nfa_ids -. -pop -( -) -{ -let -dfa_id -= -self -. -nfa_to_dfa_id -[ -nfa_id -] -; -/ -/ -Once -we -see -a -match -we -keep -going -but -don -' -t -add -any -new -/ -/ -transitions -. -Normally -we -' -d -just -stop -but -we -have -to -keep -/ -/ -going -in -order -to -verify -that -our -regex -is -actually -one -- -pass -. -self -. -matched -= -false -; -/ -/ -The -NFA -states -we -' -ve -already -explored -for -this -DFA -state -. -self -. -seen -. -clear -( -) -; -/ -/ -The -NFA -states -to -explore -via -epsilon -transitions -. -If -we -ever -/ -/ -try -to -push -an -NFA -state -that -we -' -ve -already -seen -then -the -NFA -/ -/ -is -not -one -- -pass -because -it -implies -there -are -multiple -epsilon -/ -/ -transition -paths -that -lead -to -the -same -NFA -state -. -In -other -/ -/ -words -there -is -ambiguity -. -self -. -stack_push -( -nfa_id -Epsilons -: -: -empty -( -) -) -? -; -while -let -Some -( -( -id -epsilons -) -) -= -self -. -stack -. -pop -( -) -{ -match -* -self -. -nfa -. -state -( -id -) -{ -thompson -: -: -State -: -: -ByteRange -{ -ref -trans -} -= -> -{ -self -. -compile_transition -( -dfa_id -trans -epsilons -) -? -; -} -thompson -: -: -State -: -: -Sparse -( -ref -sparse -) -= -> -{ -for -trans -in -sparse -. -transitions -. -iter -( -) -{ -self -. -compile_transition -( -dfa_id -trans -epsilons -) -? -; -} -} -thompson -: -: -State -: -: -Dense -( -ref -dense -) -= -> -{ -for -trans -in -dense -. -iter -( -) -{ -self -. -compile_transition -( -dfa_id -& -trans -epsilons -) -? -; -} -} -thompson -: -: -State -: -: -Look -{ -look -next -} -= -> -{ -let -looks -= -epsilons -. -looks -( -) -. -insert -( -look -) -; -self -. -stack_push -( -next -epsilons -. -set_looks -( -looks -) -) -? -; -} -thompson -: -: -State -: -: -Union -{ -ref -alternates -} -= -> -{ -for -& -sid -in -alternates -. -iter -( -) -. -rev -( -) -{ -self -. -stack_push -( -sid -epsilons -) -? -; -} -} -thompson -: -: -State -: -: -BinaryUnion -{ -alt1 -alt2 -} -= -> -{ -self -. -stack_push -( -alt2 -epsilons -) -? -; -self -. -stack_push -( -alt1 -epsilons -) -? -; -} -thompson -: -: -State -: -: -Capture -{ -next -slot -. -. -} -= -> -{ -let -slot -= -slot -. -as_usize -( -) -; -let -epsilons -= -if -slot -< -explicit_slot_start -{ -/ -/ -If -this -is -an -implicit -slot -we -don -' -t -care -/ -/ -about -it -since -we -handle -implicit -slots -in -/ -/ -the -search -routine -. -We -can -get -away -with -that -/ -/ -because -there -are -2 -implicit -slots -for -every -/ -/ -pattern -. -epsilons -} -else -{ -/ -/ -Offset -our -explicit -slots -so -that -they -start -/ -/ -at -index -0 -. -let -offset -= -slot -- -explicit_slot_start -; -epsilons -. -set_slots -( -epsilons -. -slots -( -) -. -insert -( -offset -) -) -} -; -self -. -stack_push -( -next -epsilons -) -? -; -} -thompson -: -: -State -: -: -Fail -= -> -{ -continue -; -} -thompson -: -: -State -: -: -Match -{ -pattern_id -} -= -> -{ -/ -/ -If -we -found -two -different -paths -to -a -match -state -/ -/ -for -the -same -DFA -state -then -we -have -ambiguity -. -/ -/ -Thus -it -' -s -not -one -- -pass -. -if -self -. -matched -{ -return -Err -( -BuildError -: -: -not_one_pass -( -" -multiple -epsilon -transitions -to -match -state -" -) -) -; -} -self -. -matched -= -true -; -/ -/ -Shove -the -matching -pattern -ID -and -the -' -epsilons -' -/ -/ -into -the -current -DFA -state -' -s -pattern -epsilons -. -The -/ -/ -' -epsilons -' -includes -the -slots -we -need -to -capture -/ -/ -before -reporting -the -match -and -also -the -conditional -/ -/ -epsilon -transitions -we -need -to -check -before -we -can -/ -/ -report -a -match -. -self -. -dfa -. -set_pattern_epsilons -( -dfa_id -PatternEpsilons -: -: -empty -( -) -. -set_pattern_id -( -pattern_id -) -. -set_epsilons -( -epsilons -) -) -; -/ -/ -N -. -B -. -It -is -tempting -to -just -bail -out -here -when -/ -/ -compiling -a -leftmost -- -first -DFA -since -we -will -never -/ -/ -compile -any -more -transitions -in -that -case -. -But -we -/ -/ -actually -need -to -keep -going -in -order -to -verify -that -/ -/ -we -actually -have -a -one -- -pass -regex -. -e -. -g -. -We -might -/ -/ -see -more -Match -states -( -e -. -g -. -for -other -patterns -) -/ -/ -that -imply -that -we -don -' -t -have -a -one -- -pass -regex -. -/ -/ -So -instead -we -mark -that -we -' -ve -found -a -match -and -/ -/ -continue -on -. -When -we -go -to -compile -a -new -DFA -state -/ -/ -we -just -skip -that -part -. -But -otherwise -check -that -the -/ -/ -one -- -pass -property -is -upheld -. -} -} -} -} -self -. -shuffle_states -( -) -; -Ok -( -self -. -dfa -) -} -/ -/ -/ -Shuffle -all -match -states -to -the -end -of -the -transition -table -and -set -/ -/ -/ -' -min_match_id -' -to -the -ID -of -the -first -such -match -state -. -/ -/ -/ -/ -/ -/ -The -point -of -this -is -to -make -it -extremely -cheap -to -determine -whether -/ -/ -/ -a -state -is -a -match -state -or -not -. -We -need -to -check -on -this -on -every -/ -/ -/ -transition -during -a -search -so -it -being -cheap -is -important -. -This -/ -/ -/ -permits -us -to -check -it -by -simply -comparing -two -state -identifiers -as -/ -/ -/ -opposed -to -looking -for -the -pattern -ID -in -the -state -' -s -PatternEpsilons -. -/ -/ -/ -( -Which -requires -a -memory -load -and -some -light -arithmetic -. -) -fn -shuffle_states -( -& -mut -self -) -{ -let -mut -remapper -= -Remapper -: -: -new -( -& -self -. -dfa -) -; -let -mut -next_dest -= -self -. -dfa -. -last_state_id -( -) -; -for -i -in -( -0 -. -. -self -. -dfa -. -state_len -( -) -) -. -rev -( -) -{ -let -id -= -StateID -: -: -must -( -i -) -; -let -is_match -= -self -. -dfa -. -pattern_epsilons -( -id -) -. -pattern_id -( -) -. -is_some -( -) -; -if -! -is_match -{ -continue -; -} -remapper -. -swap -( -& -mut -self -. -dfa -next_dest -id -) -; -self -. -dfa -. -min_match_id -= -next_dest -; -next_dest -= -self -. -dfa -. -prev_state_id -( -next_dest -) -. -expect -( -" -match -states -should -be -a -proper -subset -of -all -states -" -) -; -} -remapper -. -remap -( -& -mut -self -. -dfa -) -; -} -/ -/ -/ -Compile -the -given -NFA -transition -into -the -DFA -state -given -. -/ -/ -/ -/ -/ -/ -' -Epsilons -' -corresponds -to -any -conditional -epsilon -transitions -that -need -/ -/ -/ -to -be -satisfied -to -follow -this -transition -and -any -slots -that -need -to -/ -/ -/ -be -saved -if -the -transition -is -followed -. -/ -/ -/ -/ -/ -/ -If -this -transition -indicates -that -the -NFA -is -not -one -- -pass -then -/ -/ -/ -this -returns -an -error -. -( -This -occurs -for -example -if -the -DFA -state -/ -/ -/ -already -has -a -transition -defined -for -the -same -input -symbols -as -the -/ -/ -/ -given -transition -* -and -* -the -result -of -the -old -and -new -transitions -is -/ -/ -/ -different -. -) -fn -compile_transition -( -& -mut -self -dfa_id -: -StateID -trans -: -& -thompson -: -: -Transition -epsilons -: -Epsilons -) -- -> -Result -< -( -) -BuildError -> -{ -let -next_dfa_id -= -self -. -add_dfa_state_for_nfa_state -( -trans -. -next -) -? -; -for -byte -in -self -. -classes -. -representatives -( -trans -. -start -. -. -= -trans -. -end -) -. -filter_map -( -| -r -| -r -. -as_u8 -( -) -) -{ -let -oldtrans -= -self -. -dfa -. -transition -( -dfa_id -byte -) -; -let -newtrans -= -Transition -: -: -new -( -self -. -matched -next_dfa_id -epsilons -) -; -/ -/ -If -the -old -transition -points -to -the -DEAD -state -then -we -know -/ -/ -' -byte -' -has -not -been -mapped -to -any -transition -for -this -DFA -state -/ -/ -yet -. -So -set -it -unconditionally -. -Otherwise -we -require -that -the -/ -/ -old -and -new -transitions -are -equivalent -. -Otherwise -there -is -/ -/ -ambiguity -and -thus -the -regex -is -not -one -- -pass -. -if -oldtrans -. -state_id -( -) -= -= -DEAD -{ -self -. -dfa -. -set_transition -( -dfa_id -byte -newtrans -) -; -} -else -if -oldtrans -! -= -newtrans -{ -return -Err -( -BuildError -: -: -not_one_pass -( -" -conflicting -transition -" -) -) -; -} -} -Ok -( -( -) -) -} -/ -/ -/ -Add -a -start -state -to -the -DFA -corresponding -to -the -given -NFA -starting -/ -/ -/ -state -ID -. -/ -/ -/ -/ -/ -/ -If -adding -a -state -would -blow -any -limits -( -configured -or -hard -- -coded -) -/ -/ -/ -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -If -the -starting -state -is -an -anchored -state -for -a -particular -pattern -/ -/ -/ -then -callers -must -provide -the -pattern -ID -for -that -starting -state -. -/ -/ -/ -Callers -must -also -ensure -that -the -first -starting -state -added -is -the -/ -/ -/ -start -state -for -all -patterns -and -then -each -anchored -starting -state -for -/ -/ -/ -each -pattern -( -if -necessary -) -added -in -order -. -Otherwise -this -panics -. -fn -add_start_state -( -& -mut -self -pid -: -Option -< -PatternID -> -nfa_id -: -StateID -) -- -> -Result -< -StateID -BuildError -> -{ -match -pid -{ -/ -/ -With -no -pid -this -should -be -the -start -state -for -all -patterns -/ -/ -and -thus -be -the -first -one -. -None -= -> -assert -! -( -self -. -dfa -. -starts -. -is_empty -( -) -) -/ -/ -With -a -pid -we -want -it -to -be -at -self -. -dfa -. -starts -[ -pid -+ -1 -] -. -Some -( -pid -) -= -> -assert -! -( -self -. -dfa -. -starts -. -len -( -) -= -= -pid -. -one_more -( -) -) -} -let -dfa_id -= -self -. -add_dfa_state_for_nfa_state -( -nfa_id -) -? -; -self -. -dfa -. -starts -. -push -( -dfa_id -) -; -Ok -( -dfa_id -) -} -/ -/ -/ -Add -a -new -DFA -state -corresponding -to -the -given -NFA -state -. -If -adding -a -/ -/ -/ -state -would -blow -any -limits -( -configured -or -hard -- -coded -) -then -an -error -/ -/ -/ -is -returned -. -If -a -DFA -state -already -exists -for -the -given -NFA -state -/ -/ -/ -then -that -DFA -state -' -s -ID -is -returned -and -no -new -states -are -added -. -/ -/ -/ -/ -/ -/ -It -is -not -expected -that -this -routine -is -called -for -every -NFA -state -. -/ -/ -/ -Instead -an -NFA -state -ID -will -usually -correspond -to -the -" -start -" -state -/ -/ -/ -for -a -sub -- -graph -of -the -NFA -where -all -states -in -the -sub -- -graph -are -/ -/ -/ -reachable -via -epsilon -transitions -( -conditional -or -unconditional -) -. -That -/ -/ -/ -sub -- -graph -of -NFA -states -is -ultimately -what -produces -a -single -DFA -state -. -fn -add_dfa_state_for_nfa_state -( -& -mut -self -nfa_id -: -StateID -) -- -> -Result -< -StateID -BuildError -> -{ -/ -/ -If -we -' -ve -already -built -a -DFA -state -for -the -given -NFA -state -then -/ -/ -just -return -that -. -We -definitely -do -not -want -to -have -more -than -one -/ -/ -DFA -state -in -existence -for -the -same -NFA -state -since -all -but -one -of -/ -/ -them -will -likely -become -unreachable -. -And -at -least -some -of -them -are -/ -/ -likely -to -wind -up -being -incomplete -. -let -existing_dfa_id -= -self -. -nfa_to_dfa_id -[ -nfa_id -] -; -if -existing_dfa_id -! -= -DEAD -{ -return -Ok -( -existing_dfa_id -) -; -} -/ -/ -If -we -don -' -t -have -any -DFA -state -yet -add -it -and -then -add -the -given -/ -/ -NFA -state -to -the -list -of -states -to -explore -. -let -dfa_id -= -self -. -add_empty_state -( -) -? -; -self -. -nfa_to_dfa_id -[ -nfa_id -] -= -dfa_id -; -self -. -uncompiled_nfa_ids -. -push -( -nfa_id -) -; -Ok -( -dfa_id -) -} -/ -/ -/ -Unconditionally -add -a -new -empty -DFA -state -. -If -adding -it -would -exceed -/ -/ -/ -any -limits -( -configured -or -hard -- -coded -) -then -an -error -is -returned -. -The -/ -/ -/ -ID -of -the -new -state -is -returned -on -success -. -/ -/ -/ -/ -/ -/ -The -added -state -is -* -not -* -a -match -state -. -fn -add_empty_state -( -& -mut -self -) -- -> -Result -< -StateID -BuildError -> -{ -let -state_limit -= -Transition -: -: -STATE_ID_LIMIT -; -/ -/ -Note -that -unlike -dense -and -lazy -DFAs -we -specifically -do -NOT -/ -/ -premultiply -our -state -IDs -here -. -The -reason -is -that -we -want -to -pack -/ -/ -our -state -IDs -into -64 -- -bit -transitions -with -other -info -so -the -fewer -/ -/ -the -bits -we -use -for -state -IDs -the -better -. -If -we -premultiply -then -/ -/ -our -state -ID -space -shrinks -. -We -justify -this -by -the -assumption -that -/ -/ -a -one -- -pass -DFA -is -just -already -doing -a -fair -bit -more -work -than -a -/ -/ -normal -DFA -anyway -so -an -extra -multiplication -to -compute -a -state -/ -/ -transition -doesn -' -t -seem -like -a -huge -deal -. -let -next_id -= -self -. -dfa -. -table -. -len -( -) -> -> -self -. -dfa -. -stride2 -( -) -; -let -id -= -StateID -: -: -new -( -next_id -) -. -map_err -( -| -_ -| -BuildError -: -: -too_many_states -( -state_limit -) -) -? -; -if -id -. -as_u64 -( -) -> -Transition -: -: -STATE_ID_LIMIT -{ -return -Err -( -BuildError -: -: -too_many_states -( -state_limit -) -) -; -} -self -. -dfa -. -table -. -extend -( -core -: -: -iter -: -: -repeat -( -Transition -( -0 -) -) -. -take -( -self -. -dfa -. -stride -( -) -) -) -; -/ -/ -The -default -empty -value -for -' -PatternEpsilons -' -is -sadly -not -all -/ -/ -zeroes -. -Instead -a -special -sentinel -is -used -to -indicate -that -there -/ -/ -is -no -pattern -. -So -we -need -to -explicitly -set -the -pattern -epsilons -to -/ -/ -the -correct -" -empty -" -PatternEpsilons -. -self -. -dfa -. -set_pattern_epsilons -( -id -PatternEpsilons -: -: -empty -( -) -) -; -if -let -Some -( -size_limit -) -= -self -. -config -. -get_size_limit -( -) -{ -if -self -. -dfa -. -memory_usage -( -) -> -size_limit -{ -return -Err -( -BuildError -: -: -exceeded_size_limit -( -size_limit -) -) -; -} -} -Ok -( -id -) -} -/ -/ -/ -Push -the -given -NFA -state -ID -and -its -corresponding -epsilons -( -slots -and -/ -/ -/ -conditional -epsilon -transitions -) -on -to -a -stack -for -use -in -a -depth -first -/ -/ -/ -traversal -of -a -sub -- -graph -of -the -NFA -. -/ -/ -/ -/ -/ -/ -If -the -given -NFA -state -ID -has -already -been -pushed -on -to -the -stack -then -/ -/ -/ -it -indicates -the -regex -is -not -one -- -pass -and -this -correspondingly -returns -/ -/ -/ -an -error -. -fn -stack_push -( -& -mut -self -nfa_id -: -StateID -epsilons -: -Epsilons -) -- -> -Result -< -( -) -BuildError -> -{ -/ -/ -If -we -already -have -seen -a -match -and -we -are -compiling -a -leftmost -/ -/ -first -DFA -then -we -shouldn -' -t -add -any -more -states -to -look -at -. -This -is -/ -/ -effectively -how -preference -order -and -non -- -greediness -is -implemented -. -/ -/ -if -! -self -. -config -. -get_match_kind -( -) -. -continue_past_first_match -( -) -/ -/ -& -& -self -. -matched -/ -/ -{ -/ -/ -return -Ok -( -( -) -) -; -/ -/ -} -if -! -self -. -seen -. -insert -( -nfa_id -) -{ -return -Err -( -BuildError -: -: -not_one_pass -( -" -multiple -epsilon -transitions -to -same -state -" -) -) -; -} -self -. -stack -. -push -( -( -nfa_id -epsilons -) -) -; -Ok -( -( -) -) -} -} -/ -/ -/ -A -one -- -pass -DFA -for -executing -a -subset -of -anchored -regex -searches -while -/ -/ -/ -resolving -capturing -groups -. -/ -/ -/ -/ -/ -/ -A -one -- -pass -DFA -can -be -built -from -an -NFA -that -is -one -- -pass -. -An -NFA -is -/ -/ -/ -one -- -pass -when -there -is -never -any -ambiguity -about -how -to -continue -a -search -. -/ -/ -/ -For -example -a -* -a -is -not -one -- -pass -becuase -during -a -search -it -' -s -not -/ -/ -/ -possible -to -know -whether -to -continue -matching -the -a -* -or -to -move -on -to -/ -/ -/ -the -single -a -. -However -a -* -b -is -one -- -pass -because -for -every -byte -in -the -/ -/ -/ -input -it -' -s -always -clear -when -to -move -on -from -a -* -to -b -. -/ -/ -/ -/ -/ -/ -# -Only -anchored -searches -are -supported -/ -/ -/ -/ -/ -/ -In -this -crate -especially -for -DFAs -unanchored -searches -are -implemented -by -/ -/ -/ -treating -the -pattern -as -if -it -had -a -( -? -s -- -u -: -. -) -* -? -prefix -. -While -the -prefix -/ -/ -/ -is -one -- -pass -on -its -own -adding -anything -after -it -e -. -g -. -( -? -s -- -u -: -. -) -* -? -a -will -/ -/ -/ -make -the -overall -pattern -not -one -- -pass -. -Why -? -Because -the -( -? -s -- -u -: -. -) -matches -/ -/ -/ -any -byte -and -there -is -therefore -ambiguity -as -to -when -the -prefix -should -/ -/ -/ -stop -matching -and -something -else -should -start -matching -. -/ -/ -/ -/ -/ -/ -Therefore -one -- -pass -DFAs -do -not -support -unanchored -searches -. -In -addition -/ -/ -/ -to -many -regexes -simply -not -being -one -- -pass -it -implies -that -one -- -pass -DFAs -/ -/ -/ -have -limited -utility -. -With -that -said -when -a -one -- -pass -DFA -can -be -used -it -/ -/ -/ -can -potentially -provide -a -dramatic -speed -up -over -alternatives -like -the -/ -/ -/ -[ -BoundedBacktracker -] -( -crate -: -: -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -) -/ -/ -/ -and -the -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -. -In -particular -/ -/ -/ -a -one -- -pass -DFA -is -the -only -DFA -capable -of -reporting -the -spans -of -matching -/ -/ -/ -capturing -groups -. -/ -/ -/ -/ -/ -/ -To -clarify -when -we -say -that -unanchored -searches -are -not -supported -what -/ -/ -/ -that -actually -means -is -: -/ -/ -/ -/ -/ -/ -* -The -high -level -routines -[ -DFA -: -: -is_match -] -and -[ -DFA -: -: -captures -] -always -/ -/ -/ -do -anchored -searches -. -/ -/ -/ -* -Since -iterators -are -most -useful -in -the -context -of -unanchored -searches -/ -/ -/ -there -is -no -DFA -: -: -captures_iter -method -. -/ -/ -/ -* -For -lower -level -routines -like -[ -DFA -: -: -try_search -] -an -error -will -be -/ -/ -/ -returned -if -the -given -[ -Input -] -is -configured -to -do -an -unanchored -search -or -/ -/ -/ -search -for -an -invalid -pattern -ID -. -( -Note -that -an -[ -Input -] -is -configured -to -/ -/ -/ -do -an -unanchored -search -by -default -so -just -giving -a -Input -: -: -new -is -/ -/ -/ -guaranteed -to -return -an -error -. -) -/ -/ -/ -/ -/ -/ -# -Other -limitations -/ -/ -/ -/ -/ -/ -In -addition -to -the -[ -configurable -heap -limit -] -( -Config -: -: -size_limit -) -and -/ -/ -/ -the -requirement -that -a -regex -pattern -be -one -- -pass -there -are -some -other -/ -/ -/ -limitations -: -/ -/ -/ -/ -/ -/ -* -There -is -an -internal -limit -on -the -total -number -of -explicit -capturing -/ -/ -/ -groups -that -appear -across -all -patterns -. -It -is -somewhat -small -and -there -is -/ -/ -/ -no -way -to -configure -it -. -If -your -pattern -( -s -) -exceed -this -limit -then -building -/ -/ -/ -a -one -- -pass -DFA -will -fail -. -/ -/ -/ -* -If -the -number -of -patterns -exceeds -an -internal -unconfigurable -limit -then -/ -/ -/ -building -a -one -- -pass -DFA -will -fail -. -This -limit -is -quite -large -and -you -' -re -/ -/ -/ -unlikely -to -hit -it -. -/ -/ -/ -* -If -the -total -number -of -states -exceeds -an -internal -unconfigurable -limit -/ -/ -/ -then -building -a -one -- -pass -DFA -will -fail -. -This -limit -is -quite -large -and -/ -/ -/ -you -' -re -unlikely -to -hit -it -. -/ -/ -/ -/ -/ -/ -# -Other -examples -of -regexes -that -aren -' -t -one -- -pass -/ -/ -/ -/ -/ -/ -One -particularly -unfortunate -example -is -that -enabling -Unicode -can -cause -/ -/ -/ -regexes -that -were -one -- -pass -to -no -longer -be -one -- -pass -. -Consider -the -regex -/ -/ -/ -( -? -- -u -) -\ -w -* -\ -s -for -example -. -It -is -one -- -pass -because -there -is -exactly -no -/ -/ -/ -overlap -between -the -ASCII -definitions -of -\ -w -and -\ -s -. -But -\ -w -* -\ -s -/ -/ -/ -( -i -. -e -. -with -Unicode -enabled -) -is -* -not -* -one -- -pass -because -\ -w -and -\ -s -get -/ -/ -/ -translated -to -UTF -- -8 -automatons -. -And -while -the -* -codepoints -* -in -\ -w -and -\ -s -/ -/ -/ -do -not -overlap -the -underlying -UTF -- -8 -encodings -do -. -Indeed -because -of -the -/ -/ -/ -overlap -between -UTF -- -8 -automata -the -use -of -Unicode -character -classes -will -/ -/ -/ -tend -to -vastly -increase -the -likelihood -of -a -regex -not -being -one -- -pass -. -/ -/ -/ -/ -/ -/ -# -How -does -one -know -if -a -regex -is -one -- -pass -or -not -? -/ -/ -/ -/ -/ -/ -At -the -time -of -writing -the -only -way -to -know -is -to -try -and -build -a -one -- -pass -/ -/ -/ -DFA -. -The -one -- -pass -property -is -checked -while -constructing -the -DFA -. -/ -/ -/ -/ -/ -/ -This -does -mean -that -you -might -potentially -waste -some -CPU -cycles -and -memory -/ -/ -/ -by -optimistically -trying -to -build -a -one -- -pass -DFA -. -But -this -is -currently -the -/ -/ -/ -only -way -. -In -the -future -building -a -one -- -pass -DFA -might -be -able -to -use -some -/ -/ -/ -heuristics -to -detect -common -violations -of -the -one -- -pass -property -and -bail -/ -/ -/ -more -quickly -. -/ -/ -/ -/ -/ -/ -# -Resource -usage -/ -/ -/ -/ -/ -/ -Unlike -a -general -DFA -a -one -- -pass -DFA -has -stricter -bounds -on -its -resource -/ -/ -/ -usage -. -Namely -construction -of -a -one -- -pass -DFA -has -a -time -and -space -/ -/ -/ -complexity -of -O -( -n -) -where -n -~ -nfa -. -states -( -) -. -len -( -) -. -( -A -general -DFA -' -s -time -/ -/ -/ -and -space -complexity -is -O -( -2 -^ -n -) -. -) -This -smaller -time -bound -is -achieved -/ -/ -/ -because -there -is -at -most -one -DFA -state -created -for -each -NFA -state -. -If -/ -/ -/ -additional -DFA -states -would -be -required -then -the -pattern -is -not -one -- -pass -/ -/ -/ -and -construction -will -fail -. -/ -/ -/ -/ -/ -/ -Note -though -that -currently -this -DFA -uses -a -fully -dense -representation -. -/ -/ -/ -This -means -that -while -its -space -complexity -is -no -worse -than -an -NFA -it -may -/ -/ -/ -in -practice -use -more -memory -because -of -higher -constant -factors -. -The -reason -/ -/ -/ -for -this -trade -off -is -two -- -fold -. -Firstly -a -dense -representation -makes -the -/ -/ -/ -search -faster -. -Secondly -the -bigger -an -NFA -the -more -unlikely -it -is -to -be -/ -/ -/ -one -- -pass -. -Therefore -most -one -- -pass -DFAs -are -usually -pretty -small -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -one -- -pass -DFA -implements -Unicode -word -boundaries -/ -/ -/ -correctly -while -simultaneously -reporting -spans -for -capturing -groups -that -/ -/ -/ -participate -in -a -match -. -( -This -is -the -only -DFA -that -implements -full -support -/ -/ -/ -for -Unicode -word -boundaries -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -r -" -\ -b -( -? -P -< -first -> -\ -w -+ -) -[ -[ -: -space -: -] -] -+ -( -? -P -< -last -> -\ -w -+ -) -\ -b -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -23 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -12 -) -) -caps -. -get_group_by_name -( -" -first -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -13 -. -. -23 -) -) -caps -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -iteration -/ -/ -/ -/ -/ -/ -Unlike -other -regex -engines -in -this -crate -this -one -does -not -provide -/ -/ -/ -iterator -search -functions -. -This -is -because -a -one -- -pass -DFA -only -supports -/ -/ -/ -anchored -searches -and -so -iterator -functions -are -generally -not -applicable -. -/ -/ -/ -/ -/ -/ -However -if -you -know -that -all -of -your -matches -are -/ -/ -/ -directly -adjacent -then -an -iterator -can -be -used -. -The -/ -/ -/ -[ -util -: -: -iter -: -: -Searcher -] -( -crate -: -: -util -: -: -iter -: -: -Searcher -) -type -can -be -used -for -/ -/ -/ -this -purpose -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -onepass -: -: -DFA -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -Anchored -Input -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -r -" -\ -w -( -\ -d -) -\ -w -" -) -? -; -/ -/ -/ -let -( -mut -cache -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -a1zb2yc3x -" -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -Searcher -: -: -new -( -input -) -. -into_captures_iter -( -caps -| -input -caps -| -{ -/ -/ -/ -Ok -( -re -. -try_search -( -& -mut -cache -input -caps -) -? -) -/ -/ -/ -} -) -. -infallible -( -) -; -/ -/ -/ -let -caps0 -= -it -. -next -( -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -1 -. -. -2 -) -) -caps0 -. -get_group -( -1 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -) -] -pub -struct -DFA -{ -/ -/ -/ -The -configuration -provided -by -the -caller -. -config -: -Config -/ -/ -/ -The -NFA -used -to -build -this -DFA -. -/ -/ -/ -/ -/ -/ -NOTE -: -We -probably -don -' -t -need -to -store -the -NFA -here -but -we -use -enough -/ -/ -/ -bits -from -it -that -it -' -s -convenient -to -do -so -. -And -there -really -isn -' -t -much -/ -/ -/ -cost -to -doing -so -either -since -an -NFA -is -reference -counted -internally -. -nfa -: -NFA -/ -/ -/ -The -transition -table -. -Given -a -state -ID -' -s -' -and -a -byte -of -haystack -' -b -' -/ -/ -/ -the -next -state -is -table -[ -sid -+ -classes -[ -byte -] -] -. -/ -/ -/ -/ -/ -/ -The -stride -of -this -table -( -i -. -e -. -the -number -of -columns -) -is -always -/ -/ -/ -a -power -of -2 -even -if -the -alphabet -length -is -smaller -. -This -makes -/ -/ -/ -converting -between -state -IDs -and -state -indices -very -cheap -. -/ -/ -/ -/ -/ -/ -Note -that -the -stride -always -includes -room -for -one -extra -" -transition -" -/ -/ -/ -that -isn -' -t -actually -a -transition -. -It -is -a -' -PatternEpsilons -' -that -is -/ -/ -/ -used -for -match -states -only -. -Because -of -this -the -maximum -number -of -/ -/ -/ -active -columns -in -the -transition -table -is -257 -which -means -the -maximum -/ -/ -/ -stride -is -512 -( -the -next -power -of -2 -greater -than -or -equal -to -257 -) -. -table -: -Vec -< -Transition -> -/ -/ -/ -The -DFA -state -IDs -of -the -starting -states -. -/ -/ -/ -/ -/ -/ -starts -[ -0 -] -is -always -present -and -corresponds -to -the -starting -state -/ -/ -/ -when -searching -for -matches -of -any -pattern -in -the -DFA -. -/ -/ -/ -/ -/ -/ -starts -[ -i -] -where -i -> -0 -corresponds -to -the -starting -state -for -the -pattern -/ -/ -/ -ID -' -i -- -1 -' -. -These -starting -states -are -optional -. -starts -: -Vec -< -StateID -> -/ -/ -/ -Every -state -ID -> -= -this -value -corresponds -to -a -match -state -. -/ -/ -/ -/ -/ -/ -This -is -what -a -search -uses -to -detect -whether -a -state -is -a -match -state -/ -/ -/ -or -not -. -It -requires -only -a -simple -comparison -instead -of -bit -- -unpacking -/ -/ -/ -the -PatternEpsilons -from -every -state -. -min_match_id -: -StateID -/ -/ -/ -The -alphabet -of -this -DFA -split -into -equivalence -classes -. -Bytes -in -the -/ -/ -/ -same -equivalence -class -can -never -discriminate -between -a -match -and -a -/ -/ -/ -non -- -match -. -classes -: -ByteClasses -/ -/ -/ -The -number -of -elements -in -each -state -in -the -transition -table -. -This -may -/ -/ -/ -be -less -than -the -stride -since -the -stride -is -always -a -power -of -2 -and -/ -/ -/ -the -alphabet -length -can -be -anything -up -to -and -including -256 -. -alphabet_len -: -usize -/ -/ -/ -The -number -of -columns -in -the -transition -table -expressed -as -a -power -of -/ -/ -/ -2 -. -stride2 -: -usize -/ -/ -/ -The -offset -at -which -the -PatternEpsilons -for -a -match -state -is -stored -in -/ -/ -/ -the -transition -table -. -/ -/ -/ -/ -/ -/ -PERF -: -One -wonders -whether -it -would -be -better -to -put -this -in -a -separate -/ -/ -/ -allocation -since -only -match -states -have -a -non -- -empty -PatternEpsilons -/ -/ -/ -and -the -number -of -match -states -tends -be -dwarfed -by -the -number -of -/ -/ -/ -non -- -match -states -. -So -this -would -save -' -8 -* -len -( -non_match_states -) -' -for -each -/ -/ -/ -DFA -. -The -question -is -whether -moving -this -to -a -different -allocation -will -/ -/ -/ -lead -to -a -perf -hit -during -searches -. -You -might -think -dealing -with -match -/ -/ -/ -states -is -rare -but -some -regexes -spend -a -lot -of -time -in -match -states -/ -/ -/ -gobbling -up -input -. -But -. -. -. -match -state -handling -is -already -somewhat -/ -/ -/ -expensive -so -maybe -this -wouldn -' -t -do -much -? -Either -way -it -' -s -worth -/ -/ -/ -experimenting -. -pateps_offset -: -usize -/ -/ -/ -The -first -explicit -slot -index -. -This -refers -to -the -first -slot -appearing -/ -/ -/ -immediately -after -the -last -implicit -slot -. -It -is -always -' -patterns -. -len -( -) -/ -/ -/ -* -2 -' -. -/ -/ -/ -/ -/ -/ -We -record -this -because -we -only -store -the -explicit -slots -in -our -DFA -/ -/ -/ -transition -table -that -need -to -be -saved -. -Implicit -slots -are -handled -/ -/ -/ -automatically -as -part -of -the -search -. -explicit_slot_start -: -usize -} -impl -DFA -{ -/ -/ -/ -Parse -the -given -regular -expression -using -the -default -configuration -and -/ -/ -/ -return -the -corresponding -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -[ -Builder -] -to -/ -/ -/ -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -foo12345barzzz -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -11 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -# -[ -inline -] -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -DFA -BuildError -> -{ -DFA -: -: -builder -( -) -. -build -( -pattern -) -} -/ -/ -/ -Like -new -but -parses -multiple -patterns -into -a -single -" -multi -regex -. -" -/ -/ -/ -This -similarly -uses -the -default -regex -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new_many -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -abc123 -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -123abc -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -0 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -# -[ -inline -] -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -DFA -BuildError -> -{ -DFA -: -: -builder -( -) -. -build_many -( -patterns -) -} -/ -/ -/ -Like -new -but -builds -a -one -- -pass -DFA -directly -from -an -NFA -. -This -is -/ -/ -/ -useful -if -you -already -have -an -NFA -or -even -if -you -hand -- -assembled -the -/ -/ -/ -NFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -hand -assemble -a -regular -expression -via -its -HIR -/ -/ -/ -compile -an -NFA -from -it -and -build -a -one -- -pass -DFA -from -the -NFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -onepass -: -: -DFA -/ -/ -/ -nfa -: -: -thompson -: -: -NFA -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -{ -Hir -Class -ClassBytes -ClassBytesRange -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new -( -vec -! -[ -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -0 -' -b -' -9 -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -A -' -b -' -Z -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -_ -' -b -' -_ -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -a -' -b -' -z -' -) -/ -/ -/ -] -) -) -) -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_from_hir -( -& -hir -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -1 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -A -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new_from_nfa -( -nfa -: -NFA -) -- -> -Result -< -DFA -BuildError -> -{ -DFA -: -: -builder -( -) -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Create -a -new -one -- -pass -DFA -that -matches -every -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -always_match -( -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -dfa -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Match -: -: -must -( -0 -0 -. -. -0 -) -; -/ -/ -/ -dfa -. -captures -( -& -mut -cache -" -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -caps -. -get_match -( -) -) -; -/ -/ -/ -dfa -. -captures -( -& -mut -cache -" -foo -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -caps -. -get_match -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -always_match -( -) -- -> -Result -< -DFA -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -always_match -( -) -; -Builder -: -: -new -( -) -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Create -a -new -one -- -pass -DFA -that -never -matches -any -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -onepass -: -: -DFA -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -never_match -( -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -dfa -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -dfa -. -captures -( -& -mut -cache -" -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -dfa -. -captures -( -& -mut -cache -" -foo -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -never_match -( -) -- -> -Result -< -DFA -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -never_match -( -) -; -Builder -: -: -new -( -) -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Return -a -default -configuration -for -a -DFA -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -Config -/ -/ -/ -type -when -customizing -the -construction -of -a -DFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -change -the -match -semantics -of -this -DFA -from -/ -/ -/ -its -default -" -leftmost -first -" -to -" -all -. -" -When -using -" -all -" -non -- -greediness -/ -/ -/ -doesn -' -t -apply -and -neither -does -preference -order -matching -. -Instead -the -/ -/ -/ -longest -match -possible -is -always -returned -. -( -Although -by -construction -/ -/ -/ -it -' -s -impossible -for -a -one -- -pass -DFA -to -have -a -different -answer -for -/ -/ -/ -" -preference -order -" -vs -" -longest -match -. -" -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build -( -r -" -( -abc -) -+ -? -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -abcabc -" -& -mut -caps -) -; -/ -/ -/ -/ -/ -Normally -the -non -- -greedy -repetition -would -give -us -a -0 -. -. -3 -match -. -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -6 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -config -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -/ -/ -/ -Return -a -builder -for -configuring -the -construction -of -a -DFA -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Builder -] -type -in -common -cases -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -the -builder -to -disable -UTF -- -8 -mode -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -onepass -: -: -DFA -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -util -: -: -syntax -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -foo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -8 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -haystack -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -/ -/ -/ -Create -a -new -empty -set -of -capturing -groups -that -is -guaranteed -to -be -/ -/ -/ -valid -for -the -search -APIs -on -this -DFA -. -/ -/ -/ -/ -/ -/ -A -Captures -value -created -for -a -specific -DFA -cannot -be -used -with -any -/ -/ -/ -other -DFA -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -function -for -[ -Captures -: -: -all -] -. -See -the -/ -/ -/ -[ -Captures -] -documentation -for -an -explanation -of -its -alternative -/ -/ -/ -constructors -that -permit -the -DFA -to -do -less -work -during -a -search -and -/ -/ -/ -thus -might -make -it -faster -. -# -[ -inline -] -pub -fn -create_captures -( -& -self -) -- -> -Captures -{ -Captures -: -: -all -( -self -. -nfa -. -group_info -( -) -. -clone -( -) -) -} -/ -/ -/ -Create -a -new -cache -for -this -DFA -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -this -/ -/ -/ -DFA -. -If -you -want -to -reuse -the -cache -for -another -DFA -then -you -/ -/ -/ -must -call -[ -Cache -: -: -reset -] -with -that -DFA -( -or -equivalently -/ -/ -/ -[ -DFA -: -: -reset_cache -] -) -. -# -[ -inline -] -pub -fn -create_cache -( -& -self -) -- -> -Cache -{ -Cache -: -: -new -( -self -) -} -/ -/ -/ -Reset -the -given -cache -such -that -it -can -be -used -for -searching -with -the -/ -/ -/ -this -DFA -( -and -only -this -DFA -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -DFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -DFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -DFA -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -DFA -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -let -mut -caps1 -= -re1 -. -create_captures -( -) -; -/ -/ -/ -let -mut -caps2 -= -re2 -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -/ -/ -/ -{ -re1 -. -captures -( -& -mut -cache -" -" -& -mut -caps1 -) -; -caps1 -. -get_match -( -) -} -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -one -- -pass -DFA -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -re2 -. -reset_cache -( -& -mut -cache -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -/ -/ -/ -{ -re2 -. -captures -( -& -mut -cache -" -" -& -mut -caps2 -) -; -caps2 -. -get_match -( -) -} -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -cache -. -reset -( -self -) -; -} -/ -/ -/ -Return -the -config -for -this -one -- -pass -DFA -. -# -[ -inline -] -pub -fn -get_config -( -& -self -) -- -> -& -Config -{ -& -self -. -config -} -/ -/ -/ -Returns -a -reference -to -the -underlying -NFA -. -# -[ -inline -] -pub -fn -get_nfa -( -& -self -) -- -> -& -NFA -{ -& -self -. -nfa -} -/ -/ -/ -Returns -the -total -number -of -patterns -compiled -into -this -DFA -. -/ -/ -/ -/ -/ -/ -In -the -case -of -a -DFA -that -contains -no -patterns -this -returns -0 -. -# -[ -inline -] -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -get_nfa -( -) -. -pattern_len -( -) -} -/ -/ -/ -Returns -the -total -number -of -states -in -this -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -dense -or -sparse -DFAs -a -one -- -pass -DFA -does -not -expose -/ -/ -/ -a -low -level -DFA -API -. -Therefore -this -routine -has -little -use -other -than -/ -/ -/ -being -informational -. -# -[ -inline -] -pub -fn -state_len -( -& -self -) -- -> -usize -{ -self -. -table -. -len -( -) -> -> -self -. -stride2 -( -) -} -/ -/ -/ -Returns -the -total -number -of -elements -in -the -alphabet -for -this -DFA -. -/ -/ -/ -/ -/ -/ -That -is -this -returns -the -total -number -of -transitions -that -each -/ -/ -/ -state -in -this -DFA -must -have -. -The -maximum -alphabet -size -is -256 -which -/ -/ -/ -corresponds -to -each -possible -byte -value -. -/ -/ -/ -/ -/ -/ -The -alphabet -size -may -be -less -than -256 -though -and -unless -/ -/ -/ -[ -Config -: -: -byte_classes -] -is -disabled -it -is -typically -must -less -than -/ -/ -/ -256 -. -Namely -bytes -are -grouped -into -equivalence -classes -such -that -no -/ -/ -/ -two -bytes -in -the -same -class -can -distinguish -a -match -from -a -non -- -match -. -/ -/ -/ -For -example -in -the -regex -^ -[ -a -- -z -] -+ -the -ASCII -bytes -a -- -z -could -/ -/ -/ -all -be -in -the -same -equivalence -class -. -This -leads -to -a -massive -space -/ -/ -/ -savings -. -/ -/ -/ -/ -/ -/ -Note -though -that -the -alphabet -length -does -_not_ -necessarily -equal -the -/ -/ -/ -total -stride -space -taken -up -by -a -single -DFA -state -in -the -transition -/ -/ -/ -table -. -Namely -for -performance -reasons -the -stride -is -always -the -/ -/ -/ -smallest -power -of -two -that -is -greater -than -or -equal -to -the -alphabet -/ -/ -/ -length -. -For -this -reason -[ -DFA -: -: -stride -] -or -[ -DFA -: -: -stride2 -] -are -/ -/ -/ -often -more -useful -. -The -alphabet -length -is -typically -useful -only -for -/ -/ -/ -informational -purposes -. -/ -/ -/ -/ -/ -/ -Note -also -that -unlike -dense -or -sparse -DFAs -a -one -- -pass -DFA -does -/ -/ -/ -not -have -a -special -end -- -of -- -input -( -EOI -) -transition -. -This -is -because -/ -/ -/ -a -one -- -pass -DFA -handles -look -- -around -assertions -explicitly -( -like -the -/ -/ -/ -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -) -and -does -not -build -/ -/ -/ -them -into -the -transitions -of -the -DFA -. -# -[ -inline -] -pub -fn -alphabet_len -( -& -self -) -- -> -usize -{ -self -. -alphabet_len -} -/ -/ -/ -Returns -the -total -stride -for -every -state -in -this -DFA -expressed -as -the -/ -/ -/ -exponent -of -a -power -of -2 -. -The -stride -is -the -amount -of -space -each -state -/ -/ -/ -takes -up -in -the -transition -table -expressed -as -a -number -of -transitions -. -/ -/ -/ -( -Unused -transitions -map -to -dead -states -. -) -/ -/ -/ -/ -/ -/ -The -stride -of -a -DFA -is -always -equivalent -to -the -smallest -power -of -/ -/ -/ -2 -that -is -greater -than -or -equal -to -the -DFA -' -s -alphabet -length -. -This -/ -/ -/ -definition -uses -extra -space -but -possibly -permits -faster -translation -/ -/ -/ -between -state -identifiers -and -their -corresponding -offsets -in -this -DFA -' -s -/ -/ -/ -transition -table -. -/ -/ -/ -/ -/ -/ -For -example -if -the -DFA -' -s -stride -is -16 -transitions -then -its -stride2 -/ -/ -/ -is -4 -since -2 -^ -4 -= -16 -. -/ -/ -/ -/ -/ -/ -The -minimum -stride2 -value -is -1 -( -corresponding -to -a -stride -of -2 -) -/ -/ -/ -while -the -maximum -stride2 -value -is -9 -( -corresponding -to -a -stride -/ -/ -/ -of -512 -) -. -The -maximum -in -theory -should -be -8 -but -because -of -some -/ -/ -/ -implementation -quirks -that -may -be -relaxed -in -the -future -it -is -one -more -/ -/ -/ -than -8 -. -( -Do -note -that -a -maximal -stride -is -incredibly -rare -as -it -/ -/ -/ -would -imply -that -there -is -almost -no -redundant -in -the -regex -pattern -. -) -/ -/ -/ -/ -/ -/ -Note -that -unlike -dense -or -sparse -DFAs -a -one -- -pass -DFA -does -not -expose -/ -/ -/ -a -low -level -DFA -API -. -Therefore -this -routine -has -little -use -other -than -/ -/ -/ -being -informational -. -# -[ -inline -] -pub -fn -stride2 -( -& -self -) -- -> -usize -{ -self -. -stride2 -} -/ -/ -/ -Returns -the -total -stride -for -every -state -in -this -DFA -. -This -corresponds -/ -/ -/ -to -the -total -number -of -transitions -used -by -each -state -in -this -DFA -' -s -/ -/ -/ -transition -table -. -/ -/ -/ -/ -/ -/ -Please -see -[ -DFA -: -: -stride2 -] -for -more -information -. -In -particular -this -/ -/ -/ -returns -the -stride -as -the -number -of -transitions -where -as -stride2 -/ -/ -/ -returns -it -as -the -exponent -of -a -power -of -2 -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -dense -or -sparse -DFAs -a -one -- -pass -DFA -does -not -expose -/ -/ -/ -a -low -level -DFA -API -. -Therefore -this -routine -has -little -use -other -than -/ -/ -/ -being -informational -. -# -[ -inline -] -pub -fn -stride -( -& -self -) -- -> -usize -{ -1 -< -< -self -. -stride2 -( -) -} -/ -/ -/ -Returns -the -memory -usage -in -bytes -of -this -DFA -. -/ -/ -/ -/ -/ -/ -The -memory -usage -is -computed -based -on -the -number -of -bytes -used -to -/ -/ -/ -represent -this -DFA -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -DFA -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -onepass -: -: -DFA -> -( -) -. -# -[ -inline -] -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -use -core -: -: -mem -: -: -size_of -; -self -. -table -. -len -( -) -* -size_of -: -: -< -Transition -> -( -) -+ -self -. -starts -. -len -( -) -* -size_of -: -: -< -StateID -> -( -) -} -} -impl -DFA -{ -/ -/ -/ -Executes -an -anchored -leftmost -forward -search -and -returns -true -if -and -/ -/ -/ -only -if -this -one -- -pass -DFA -matches -the -given -haystack -. -/ -/ -/ -/ -/ -/ -This -routine -may -short -circuit -if -it -knows -that -scanning -future -/ -/ -/ -input -will -never -lead -to -a -different -result -. -In -particular -if -the -/ -/ -/ -underlying -DFA -enters -a -match -state -then -this -routine -will -return -/ -/ -/ -true -immediately -without -inspecting -any -future -input -. -( -Consider -how -/ -/ -/ -this -might -make -a -difference -given -the -regex -a -+ -on -the -haystack -/ -/ -/ -aaaaaaaaaaaaaaa -. -This -routine -can -stop -after -it -sees -the -first -a -/ -/ -/ -but -routines -like -find -need -to -continue -searching -because -+ -is -/ -/ -/ -greedy -by -default -. -) -/ -/ -/ -/ -/ -/ -The -given -Input -is -forcefully -set -to -use -[ -Anchored -: -: -Yes -] -if -the -/ -/ -/ -given -configuration -was -[ -Anchored -: -: -No -] -( -which -is -the -default -) -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -panics -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -the -following -circumstances -: -/ -/ -/ -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -Concretely -/ -/ -/ -this -occurs -when -using -[ -Anchored -: -: -Pattern -] -without -enabling -/ -/ -/ -[ -Config -: -: -starts_for_each_pattern -] -. -/ -/ -/ -/ -/ -/ -When -a -search -panics -callers -cannot -know -whether -a -match -exists -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -Use -[ -DFA -: -: -try_search -] -if -you -want -to -handle -these -panics -as -error -/ -/ -/ -values -instead -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -onepass -: -: -DFA -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -& -mut -cache -" -foo12345bar -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -& -mut -cache -" -foobar -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -consistency -with -search -APIs -/ -/ -/ -/ -/ -/ -is_match -is -guaranteed -to -return -true -whenever -captures -returns -/ -/ -/ -a -match -. -This -includes -searches -that -are -executed -entirely -within -a -/ -/ -/ -codepoint -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -" -a -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -! -re -. -is_match -( -& -mut -cache -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -when -UTF -- -8 -mode -is -disabled -then -the -above -reports -a -/ -/ -/ -match -because -the -restriction -against -zero -- -width -matches -that -split -a -/ -/ -/ -codepoint -has -been -lifted -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -nfa -: -: -thompson -: -: -NFA -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -" -a -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -& -mut -cache -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -) -- -> -bool -{ -let -mut -input -= -input -. -into -( -) -. -earliest -( -true -) -; -if -matches -! -( -input -. -get_anchored -( -) -Anchored -: -: -No -) -{ -input -. -set_anchored -( -Anchored -: -: -Yes -) -; -} -self -. -try_search_slots -( -cache -& -input -& -mut -[ -] -) -. -unwrap -( -) -. -is_some -( -) -} -/ -/ -/ -Executes -an -anchored -leftmost -forward -search -and -returns -a -Match -if -/ -/ -/ -and -only -if -this -one -- -pass -DFA -matches -the -given -haystack -. -/ -/ -/ -/ -/ -/ -This -routine -only -includes -the -overall -match -span -. -To -get -access -to -the -/ -/ -/ -individual -spans -of -each -capturing -group -use -[ -DFA -: -: -captures -] -. -/ -/ -/ -/ -/ -/ -The -given -Input -is -forcefully -set -to -use -[ -Anchored -: -: -Yes -] -if -the -/ -/ -/ -given -configuration -was -[ -Anchored -: -: -No -] -( -which -is -the -default -) -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -panics -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -the -following -circumstances -: -/ -/ -/ -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -Concretely -/ -/ -/ -this -occurs -when -using -[ -Anchored -: -: -Pattern -] -without -enabling -/ -/ -/ -[ -Config -: -: -starts_for_each_pattern -] -. -/ -/ -/ -/ -/ -/ -When -a -search -panics -callers -cannot -know -whether -a -match -exists -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -Use -[ -DFA -: -: -try_search -] -if -you -want -to -handle -these -panics -as -error -/ -/ -/ -values -instead -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Leftmost -first -match -semantics -corresponds -to -the -match -with -the -/ -/ -/ -smallest -starting -offset -but -where -the -end -offset -is -determined -by -/ -/ -/ -preferring -earlier -branches -in -the -original -regular -expression -. -For -/ -/ -/ -example -Sam -| -Samwise -will -match -Sam -in -Samwise -but -Samwise -| -Sam -/ -/ -/ -will -match -Samwise -in -Samwise -. -/ -/ -/ -/ -/ -/ -Generally -speaking -the -" -leftmost -first -" -match -is -how -most -backtracking -/ -/ -/ -regular -expressions -tend -to -work -. -This -is -in -contrast -to -POSIX -- -style -/ -/ -/ -regular -expressions -that -yield -" -leftmost -longest -" -matches -. -Namely -/ -/ -/ -both -Sam -| -Samwise -and -Samwise -| -Sam -match -Samwise -when -using -/ -/ -/ -leftmost -longest -semantics -. -( -This -crate -does -not -currently -support -/ -/ -/ -leftmost -longest -semantics -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -Match -: -: -must -( -0 -0 -. -. -8 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -re -. -find -( -& -mut -cache -" -foo12345 -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -a -match -is -found -after -reading -the -first -byte -( -a -) -/ -/ -/ -/ -/ -the -leftmost -first -match -semantics -demand -that -we -find -the -earliest -/ -/ -/ -/ -/ -match -that -prefers -earlier -parts -of -the -pattern -over -later -parts -. -/ -/ -/ -let -re -= -DFA -: -: -new -( -" -abc -| -a -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -Match -: -: -must -( -0 -0 -. -. -3 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -re -. -find -( -& -mut -cache -" -abc -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -) -- -> -Option -< -Match -> -{ -let -mut -input -= -input -. -into -( -) -; -if -matches -! -( -input -. -get_anchored -( -) -Anchored -: -: -No -) -{ -input -. -set_anchored -( -Anchored -: -: -Yes -) -; -} -if -self -. -get_nfa -( -) -. -pattern_len -( -) -= -= -1 -{ -let -mut -slots -= -[ -None -None -] -; -let -pid -= -self -. -try_search_slots -( -cache -& -input -& -mut -slots -) -. -unwrap -( -) -? -; -let -start -= -slots -[ -0 -] -. -unwrap -( -) -. -get -( -) -; -let -end -= -slots -[ -1 -] -. -unwrap -( -) -. -get -( -) -; -return -Some -( -Match -: -: -new -( -pid -Span -{ -start -end -} -) -) -; -} -let -ginfo -= -self -. -get_nfa -( -) -. -group_info -( -) -; -let -slots_len -= -ginfo -. -implicit_slot_len -( -) -; -let -mut -slots -= -vec -! -[ -None -; -slots_len -] -; -let -pid -= -self -. -try_search_slots -( -cache -& -input -& -mut -slots -) -. -unwrap -( -) -? -; -let -start -= -slots -[ -pid -. -as_usize -( -) -* -2 -] -. -unwrap -( -) -. -get -( -) -; -let -end -= -slots -[ -pid -. -as_usize -( -) -* -2 -+ -1 -] -. -unwrap -( -) -. -get -( -) -; -Some -( -Match -: -: -new -( -pid -Span -{ -start -end -} -) -) -} -/ -/ -/ -Executes -an -anchored -leftmost -forward -search -and -writes -the -spans -/ -/ -/ -of -capturing -groups -that -participated -in -a -match -into -the -provided -/ -/ -/ -[ -Captures -] -value -. -If -no -match -was -found -then -[ -Captures -: -: -is_match -] -/ -/ -/ -is -guaranteed -to -return -false -. -/ -/ -/ -/ -/ -/ -The -given -Input -is -forcefully -set -to -use -[ -Anchored -: -: -Yes -] -if -the -/ -/ -/ -given -configuration -was -[ -Anchored -: -: -No -] -( -which -is -the -default -) -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -panics -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -the -following -circumstances -: -/ -/ -/ -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -Concretely -/ -/ -/ -this -occurs -when -using -[ -Anchored -: -: -Pattern -] -without -enabling -/ -/ -/ -[ -Config -: -: -starts_for_each_pattern -] -. -/ -/ -/ -/ -/ -/ -When -a -search -panics -callers -cannot -know -whether -a -match -exists -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -Use -[ -DFA -: -: -try_search -] -if -you -want -to -handle -these -panics -as -error -/ -/ -/ -values -instead -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -simple -example -of -a -one -- -pass -regex -that -extracts -/ -/ -/ -capturing -group -spans -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -/ -/ -/ -/ -/ -Notice -that -we -use -ASCII -here -. -The -corresponding -Unicode -regex -/ -/ -/ -/ -/ -is -sadly -not -one -- -pass -. -/ -/ -/ -" -( -? -P -< -first -> -[ -[ -: -alpha -: -] -] -+ -) -[ -[ -: -space -: -] -] -+ -( -? -P -< -last -> -[ -[ -: -alpha -: -] -] -+ -) -" -/ -/ -/ -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -Bruce -Springsteen -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -17 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -5 -) -) -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -6 -. -. -17 -) -) -caps -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -captures -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -caps -: -& -mut -Captures -) -{ -let -mut -input -= -input -. -into -( -) -; -if -matches -! -( -input -. -get_anchored -( -) -Anchored -: -: -No -) -{ -input -. -set_anchored -( -Anchored -: -: -Yes -) -; -} -self -. -try_search -( -cache -& -input -caps -) -. -unwrap -( -) -; -} -/ -/ -/ -Executes -an -anchored -leftmost -forward -search -and -writes -the -spans -/ -/ -/ -of -capturing -groups -that -participated -in -a -match -into -the -provided -/ -/ -/ -[ -Captures -] -value -. -If -no -match -was -found -then -[ -Captures -: -: -is_match -] -/ -/ -/ -is -guaranteed -to -return -false -. -/ -/ -/ -/ -/ -/ -The -differences -with -[ -DFA -: -: -captures -] -are -: -/ -/ -/ -/ -/ -/ -1 -. -This -returns -an -error -instead -of -panicking -if -the -search -fails -. -/ -/ -/ -2 -. -Accepts -an -& -Input -instead -of -a -Into -< -Input -> -. -This -permits -reusing -/ -/ -/ -the -same -input -for -multiple -searches -which -_may_ -be -important -for -/ -/ -/ -latency -. -/ -/ -/ -3 -. -This -does -not -automatically -change -the -[ -Anchored -] -mode -from -No -/ -/ -/ -to -Yes -. -Instead -if -[ -Input -: -: -anchored -] -is -Anchored -: -: -No -then -an -/ -/ -/ -error -is -returned -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -the -following -circumstances -: -/ -/ -/ -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -Concretely -/ -/ -/ -this -occurs -when -using -[ -Anchored -: -: -Pattern -] -without -enabling -/ -/ -/ -[ -Config -: -: -starts_for_each_pattern -] -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -: -specific -pattern -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -multi -- -regex -that -permits -searching -/ -/ -/ -for -specific -patterns -. -Note -that -this -is -somewhat -less -useful -than -/ -/ -/ -in -other -regex -engines -since -a -one -- -pass -DFA -by -definition -has -no -/ -/ -/ -ambiguity -about -which -pattern -can -match -at -a -position -. -That -is -if -it -/ -/ -/ -were -possible -for -two -different -patterns -to -match -at -the -same -starting -/ -/ -/ -position -then -the -multi -- -regex -would -not -be -one -- -pass -and -construction -/ -/ -/ -would -have -failed -. -/ -/ -/ -/ -/ -/ -Nevertheless -this -can -still -be -useful -if -you -only -care -about -matches -/ -/ -/ -for -a -specific -pattern -and -want -the -DFA -to -report -" -no -match -" -even -if -/ -/ -/ -some -other -pattern -would -have -matched -. -/ -/ -/ -/ -/ -/ -Note -that -in -order -to -make -use -of -this -functionality -/ -/ -/ -[ -Config -: -: -starts_for_each_pattern -] -must -be -enabled -. -It -is -disabled -/ -/ -/ -by -default -since -it -may -result -in -higher -memory -usage -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -onepass -: -: -DFA -Anchored -Input -Match -PatternID -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -starts_for_each_pattern -( -true -) -) -/ -/ -/ -. -build_many -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -123abc -" -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -/ -/ -/ -/ -/ -A -normal -multi -- -pattern -search -will -show -pattern -1 -matches -. -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -input -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -0 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -If -we -only -want -to -report -pattern -0 -matches -then -we -' -ll -get -no -/ -/ -/ -/ -/ -match -here -. -/ -/ -/ -let -input -= -input -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -0 -) -) -) -; -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -input -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specifying -the -bounds -of -a -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -providing -the -bounds -of -a -search -can -produce -/ -/ -/ -different -results -than -simply -sub -- -slicing -the -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Anchored -Input -Match -} -; -/ -/ -/ -/ -/ -/ -/ -/ -one -- -pass -DFAs -fully -support -Unicode -word -boundaries -! -/ -/ -/ -/ -/ -A -sad -joke -is -that -a -Unicode -aware -regex -like -\ -w -+ -\ -s -is -not -one -- -pass -. -/ -/ -/ -/ -/ -: -- -( -/ -/ -/ -let -re -= -DFA -: -: -new -( -r -" -\ -b -[ -0 -- -9 -] -{ -3 -} -\ -b -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -sub -- -slice -the -haystack -the -search -doesn -' -t -know -about -/ -/ -/ -/ -/ -the -larger -context -and -assumes -that -123 -is -surrounded -by -word -/ -/ -/ -/ -/ -boundaries -. -And -of -course -the -match -position -is -reported -relative -/ -/ -/ -/ -/ -to -the -sub -- -slice -as -well -which -means -we -get -0 -. -. -3 -instead -of -/ -/ -/ -/ -/ -3 -. -. -6 -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -& -haystack -[ -3 -. -. -6 -] -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -input -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -provide -the -bounds -of -the -search -within -the -context -of -the -/ -/ -/ -/ -/ -entire -haystack -then -the -search -can -take -the -surrounding -context -/ -/ -/ -/ -/ -into -account -. -( -And -if -we -did -find -a -match -it -would -be -reported -/ -/ -/ -/ -/ -as -a -valid -offset -into -haystack -instead -of -its -sub -- -slice -. -) -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -3 -. -. -6 -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -input -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -caps -: -& -mut -Captures -) -- -> -Result -< -( -) -MatchError -> -{ -let -pid -= -self -. -try_search_slots -( -cache -input -caps -. -slots_mut -( -) -) -? -; -caps -. -set_pattern -( -pid -) -; -Ok -( -( -) -) -} -/ -/ -/ -Executes -an -anchored -leftmost -forward -search -and -writes -the -spans -/ -/ -/ -of -capturing -groups -that -participated -in -a -match -into -the -provided -/ -/ -/ -slots -and -returns -the -matching -pattern -ID -. -The -contents -of -the -/ -/ -/ -slots -for -patterns -other -than -the -matching -pattern -are -unspecified -. -If -/ -/ -/ -no -match -was -found -then -None -is -returned -and -the -contents -of -all -/ -/ -/ -slots -is -unspecified -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -DFA -: -: -try_search -] -but -it -accepts -a -raw -slots -slice -/ -/ -/ -instead -of -a -Captures -value -. -This -is -useful -in -contexts -where -you -/ -/ -/ -don -' -t -want -or -need -to -allocate -a -Captures -. -/ -/ -/ -/ -/ -/ -It -is -legal -to -pass -_any_ -number -of -slots -to -this -routine -. -If -the -regex -/ -/ -/ -engine -would -otherwise -write -a -slot -offset -that -doesn -' -t -fit -in -the -/ -/ -/ -provided -slice -then -it -is -simply -skipped -. -In -general -though -there -are -/ -/ -/ -usually -three -slice -lengths -you -might -want -to -use -: -/ -/ -/ -/ -/ -/ -* -An -empty -slice -if -you -only -care -about -which -pattern -matched -. -/ -/ -/ -* -A -slice -with -/ -/ -/ -[ -pattern_len -( -) -* -2 -] -( -crate -: -: -dfa -: -: -onepass -: -: -DFA -: -: -pattern_len -) -/ -/ -/ -slots -if -you -only -care -about -the -overall -match -spans -for -each -matching -/ -/ -/ -pattern -. -/ -/ -/ -* -A -slice -with -/ -/ -/ -[ -slot_len -( -) -] -( -crate -: -: -util -: -: -captures -: -: -GroupInfo -: -: -slot_len -) -slots -which -/ -/ -/ -permits -recording -match -offsets -for -every -capturing -group -in -every -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -the -following -circumstances -: -/ -/ -/ -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -Concretely -/ -/ -/ -this -occurs -when -using -[ -Anchored -: -: -Pattern -] -without -enabling -/ -/ -/ -[ -Config -: -: -starts_for_each_pattern -] -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -the -overall -match -offsets -in -a -/ -/ -/ -multi -- -pattern -search -without -allocating -a -Captures -value -. -Indeed -we -/ -/ -/ -can -put -our -slots -right -on -the -stack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Anchored -Input -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new_many -( -& -[ -/ -/ -/ -r -" -[ -a -- -zA -- -Z -] -+ -" -/ -/ -/ -r -" -[ -0 -- -9 -] -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -123 -" -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -only -care -about -the -overall -match -offsets -here -so -we -just -/ -/ -/ -/ -/ -allocate -two -slots -for -each -pattern -. -Each -slot -records -the -start -/ -/ -/ -/ -/ -and -end -of -the -match -. -/ -/ -/ -let -mut -slots -= -[ -None -; -4 -] -; -/ -/ -/ -let -pid -= -re -. -try_search_slots -( -& -mut -cache -& -input -& -mut -slots -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -pid -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -overall -match -offsets -are -always -at -' -pid -* -2 -' -and -' -pid -* -2 -+ -1 -' -. -/ -/ -/ -/ -/ -See -' -GroupInfo -' -for -more -details -on -the -mapping -between -groups -and -/ -/ -/ -/ -/ -slot -indices -. -/ -/ -/ -let -slot_start -= -pid -. -unwrap -( -) -. -as_usize -( -) -* -2 -; -/ -/ -/ -let -slot_end -= -slot_start -+ -1 -; -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -slots -[ -slot_start -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -slots -[ -slot_end -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Result -< -Option -< -PatternID -> -MatchError -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -if -! -utf8empty -{ -return -self -. -try_search_slots_imp -( -cache -input -slots -) -; -} -/ -/ -See -PikeVM -: -: -try_search_slots -for -why -we -do -this -. -let -min -= -self -. -get_nfa -( -) -. -group_info -( -) -. -implicit_slot_len -( -) -; -if -slots -. -len -( -) -> -= -min -{ -return -self -. -try_search_slots_imp -( -cache -input -slots -) -; -} -if -self -. -get_nfa -( -) -. -pattern_len -( -) -= -= -1 -{ -let -mut -enough -= -[ -None -None -] -; -let -got -= -self -. -try_search_slots_imp -( -cache -input -& -mut -enough -) -? -; -/ -/ -This -is -OK -because -we -know -enough_slots -is -strictly -bigger -/ -/ -than -slots -otherwise -this -special -case -isn -' -t -reached -. -slots -. -copy_from_slice -( -& -enough -[ -. -. -slots -. -len -( -) -] -) -; -return -Ok -( -got -) -; -} -let -mut -enough -= -vec -! -[ -None -; -min -] -; -let -got -= -self -. -try_search_slots_imp -( -cache -input -& -mut -enough -) -? -; -/ -/ -This -is -OK -because -we -know -enough_slots -is -strictly -bigger -than -/ -/ -slots -otherwise -this -special -case -isn -' -t -reached -. -slots -. -copy_from_slice -( -& -enough -[ -. -. -slots -. -len -( -) -] -) -; -Ok -( -got -) -} -# -[ -inline -( -never -) -] -fn -try_search_slots_imp -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Result -< -Option -< -PatternID -> -MatchError -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -match -self -. -search_imp -( -cache -input -slots -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -pid -) -if -! -utf8empty -= -> -return -Ok -( -Some -( -pid -) -) -Some -( -pid -) -= -> -{ -/ -/ -These -slot -indices -are -always -correct -because -we -know -our -/ -/ -' -pid -' -is -valid -and -thus -we -know -that -the -slot -indices -for -it -/ -/ -are -valid -. -let -slot_start -= -pid -. -as_usize -( -) -. -wrapping_mul -( -2 -) -; -let -slot_end -= -slot_start -. -wrapping_add -( -1 -) -; -/ -/ -OK -because -we -know -we -have -a -match -and -we -know -our -caller -/ -/ -provided -slots -are -big -enough -( -which -we -make -true -above -if -/ -/ -the -caller -didn -' -t -) -. -Namely -we -' -re -only -here -when -' -utf8empty -' -/ -/ -is -true -and -when -that -' -s -true -we -require -slots -for -every -/ -/ -pattern -. -let -start -= -slots -[ -slot_start -] -. -unwrap -( -) -. -get -( -) -; -let -end -= -slots -[ -slot_end -] -. -unwrap -( -) -. -get -( -) -; -/ -/ -If -our -match -splits -a -codepoint -then -we -cannot -report -is -/ -/ -as -a -match -. -And -since -one -- -pass -DFAs -only -support -anchored -/ -/ -searches -we -don -' -t -try -to -skip -ahead -to -find -the -next -match -. -/ -/ -We -can -just -quit -with -nothing -. -if -start -= -= -end -& -& -! -input -. -is_char_boundary -( -start -) -{ -return -Ok -( -None -) -; -} -Ok -( -Some -( -pid -) -) -} -} -} -} -impl -DFA -{ -fn -search_imp -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Result -< -Option -< -PatternID -> -MatchError -> -{ -/ -/ -PERF -: -Some -ideas -. -I -ran -out -of -steam -after -my -initial -impl -to -try -/ -/ -many -of -these -. -/ -/ -/ -/ -1 -) -Try -doing -more -state -shuffling -. -Right -now -all -we -do -is -push -/ -/ -match -states -to -the -end -of -the -transition -table -so -that -we -can -do -/ -/ -' -if -sid -> -= -self -. -min_match_id -' -to -know -whether -we -' -re -in -a -match -/ -/ -state -or -not -. -But -what -about -doing -something -like -dense -DFAs -and -/ -/ -pushing -dead -match -and -states -with -captures -/ -looks -all -toward -the -/ -/ -beginning -of -the -transition -table -. -Then -we -could -do -' -if -sid -< -= -/ -/ -self -. -max_special_id -' -in -which -case -we -need -to -do -some -special -/ -/ -handling -of -some -sort -. -Otherwise -we -get -the -happy -path -just -/ -/ -like -in -a -DFA -search -. -The -main -argument -against -this -is -that -the -/ -/ -one -- -pass -DFA -is -likely -to -be -used -most -often -with -capturing -groups -/ -/ -and -if -capturing -groups -are -common -then -this -might -wind -up -being -a -/ -/ -pessimization -. -/ -/ -/ -/ -2 -) -Consider -moving -' -PatternEpsilons -' -out -of -the -transition -table -. -/ -/ -It -is -only -needed -for -match -states -and -usually -a -small -minority -of -/ -/ -states -are -match -states -. -Therefore -we -' -re -using -an -extra -' -u64 -' -for -/ -/ -most -states -. -/ -/ -/ -/ -3 -) -I -played -around -with -the -match -state -handling -and -it -seems -like -/ -/ -there -is -probably -a -lot -left -on -the -table -for -improvement -. -The -/ -/ -key -tension -is -that -the -' -find_match -' -routine -is -a -giant -mess -but -/ -/ -splitting -it -out -into -a -non -- -inlineable -function -is -a -non -- -starter -/ -/ -because -the -match -state -might -consume -input -so -' -find_match -' -COULD -/ -/ -be -called -quite -a -lot -and -a -function -call -at -that -point -would -trash -/ -/ -perf -. -In -theory -we -could -detect -whether -a -match -state -consumes -/ -/ -input -and -then -specialize -our -search -routine -based -on -that -. -In -that -/ -/ -case -maybe -an -extra -function -call -is -OK -but -even -then -it -might -be -/ -/ -too -much -of -a -latency -hit -. -Another -idea -is -to -just -try -and -figure -/ -/ -out -how -to -reduce -the -code -size -of -' -find_match -' -. -RE2 -has -a -trick -/ -/ -here -where -the -match -handling -isn -' -t -done -if -we -know -the -next -byte -of -/ -/ -input -yields -a -match -too -. -Maybe -we -adopt -that -? -/ -/ -/ -/ -This -just -might -be -a -tricky -DFA -to -optimize -. -if -input -. -is_done -( -) -{ -return -Ok -( -None -) -; -} -/ -/ -We -unfortunately -have -a -bit -of -book -- -keeping -to -do -to -set -things -/ -/ -up -. -We -do -have -to -setup -our -cache -and -clear -all -of -our -slots -. -In -/ -/ -particular -clearing -the -slots -is -necessary -for -the -case -where -we -/ -/ -report -a -match -but -one -of -the -capturing -groups -didn -' -t -participate -/ -/ -in -the -match -but -had -a -span -set -from -a -previous -search -. -That -would -/ -/ -be -bad -. -In -theory -we -could -avoid -all -this -slot -clearing -if -we -knew -/ -/ -that -every -slot -was -always -activated -for -every -match -. -Then -we -would -/ -/ -know -they -would -always -be -overwritten -when -a -match -is -found -. -let -explicit_slots_len -= -core -: -: -cmp -: -: -min -( -Slots -: -: -LIMIT -slots -. -len -( -) -. -saturating_sub -( -self -. -explicit_slot_start -) -) -; -cache -. -setup_search -( -explicit_slots_len -) -; -for -slot -in -cache -. -explicit_slots -( -) -{ -* -slot -= -None -; -} -for -slot -in -slots -. -iter_mut -( -) -{ -* -slot -= -None -; -} -/ -/ -We -set -the -starting -slots -for -every -pattern -up -front -. -This -does -/ -/ -increase -our -latency -somewhat -but -it -avoids -having -to -do -it -every -/ -/ -time -we -see -a -match -state -( -which -could -be -many -times -in -a -single -/ -/ -search -if -the -match -state -consumes -input -) -. -for -pid -in -self -. -nfa -. -patterns -( -) -{ -let -i -= -pid -. -as_usize -( -) -* -2 -; -if -i -> -= -slots -. -len -( -) -{ -break -; -} -slots -[ -i -] -= -NonMaxUsize -: -: -new -( -input -. -start -( -) -) -; -} -let -mut -pid -= -None -; -let -mut -next_sid -= -match -input -. -get_anchored -( -) -{ -Anchored -: -: -Yes -= -> -self -. -start -( -) -Anchored -: -: -Pattern -( -pid -) -= -> -self -. -start_pattern -( -pid -) -? -Anchored -: -: -No -= -> -{ -/ -/ -If -the -regex -is -itself -always -anchored -then -we -' -re -fine -/ -/ -even -if -the -search -is -configured -to -be -unanchored -. -if -! -self -. -nfa -. -is_always_start_anchored -( -) -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -Anchored -: -: -No -) -) -; -} -self -. -start -( -) -} -} -; -let -leftmost_first -= -matches -! -( -self -. -config -. -get_match_kind -( -) -MatchKind -: -: -LeftmostFirst -) -; -for -at -in -input -. -start -( -) -. -. -input -. -end -( -) -{ -let -sid -= -next_sid -; -let -trans -= -self -. -transition -( -sid -input -. -haystack -( -) -[ -at -] -) -; -next_sid -= -trans -. -state_id -( -) -; -let -epsilons -= -trans -. -epsilons -( -) -; -if -sid -> -= -self -. -min_match_id -{ -if -self -. -find_match -( -cache -input -at -sid -slots -& -mut -pid -) -{ -if -input -. -get_earliest -( -) -| -| -( -leftmost_first -& -& -trans -. -match_wins -( -) -) -{ -return -Ok -( -pid -) -; -} -} -} -if -sid -= -= -DEAD -| -| -( -! -epsilons -. -looks -( -) -. -is_empty -( -) -& -& -! -self -. -nfa -. -look_matcher -( -) -. -matches_set_inline -( -epsilons -. -looks -( -) -input -. -haystack -( -) -at -) -) -{ -return -Ok -( -pid -) -; -} -epsilons -. -slots -( -) -. -apply -( -at -cache -. -explicit_slots -( -) -) -; -} -if -next_sid -> -= -self -. -min_match_id -{ -self -. -find_match -( -cache -input -input -. -end -( -) -next_sid -slots -& -mut -pid -) -; -} -Ok -( -pid -) -} -/ -/ -/ -Assumes -' -sid -' -is -a -match -state -and -looks -for -whether -a -match -can -/ -/ -/ -be -reported -. -If -so -appropriate -offsets -are -written -to -' -slots -' -and -/ -/ -/ -' -matched_pid -' -is -set -to -the -matching -pattern -ID -. -/ -/ -/ -/ -/ -/ -Even -when -' -sid -' -is -a -match -state -it -' -s -possible -that -a -match -won -' -t -/ -/ -/ -be -reported -. -For -example -when -the -conditional -epsilon -transitions -/ -/ -/ -leading -to -the -match -state -aren -' -t -satisfied -at -the -given -position -in -/ -/ -/ -the -haystack -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -find_match -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -at -: -usize -sid -: -StateID -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -matched_pid -: -& -mut -Option -< -PatternID -> -) -- -> -bool -{ -debug_assert -! -( -sid -> -= -self -. -min_match_id -) -; -let -pateps -= -self -. -pattern_epsilons -( -sid -) -; -let -epsilons -= -pateps -. -epsilons -( -) -; -if -! -epsilons -. -looks -( -) -. -is_empty -( -) -& -& -! -self -. -nfa -. -look_matcher -( -) -. -matches_set_inline -( -epsilons -. -looks -( -) -input -. -haystack -( -) -at -) -{ -return -false -; -} -let -pid -= -pateps -. -pattern_id_unchecked -( -) -; -/ -/ -This -calculation -is -always -correct -because -we -know -our -' -pid -' -is -/ -/ -valid -and -thus -we -know -that -the -slot -indices -for -it -are -valid -. -let -slot_end -= -pid -. -as_usize -( -) -. -wrapping_mul -( -2 -) -. -wrapping_add -( -1 -) -; -/ -/ -Set -the -implicit -' -end -' -slot -for -the -matching -pattern -. -( -The -' -start -' -/ -/ -slot -was -set -at -the -beginning -of -the -search -. -) -if -slot_end -< -slots -. -len -( -) -{ -slots -[ -slot_end -] -= -NonMaxUsize -: -: -new -( -at -) -; -} -/ -/ -If -the -caller -provided -enough -room -copy -the -previously -recorded -/ -/ -explicit -slots -from -our -scratch -space -to -the -caller -provided -slots -. -/ -/ -We -* -also -* -need -to -set -any -explicit -slots -that -are -active -as -part -of -/ -/ -the -path -to -the -match -state -. -if -self -. -explicit_slot_start -< -slots -. -len -( -) -{ -/ -/ -NOTE -: -The -' -cache -. -explicit_slots -( -) -' -slice -is -setup -at -the -/ -/ -beginning -of -every -search -such -that -it -is -guaranteed -to -return -a -/ -/ -slice -of -length -equivalent -to -' -slots -[ -explicit_slot_start -. -. -] -' -. -slots -[ -self -. -explicit_slot_start -. -. -] -. -copy_from_slice -( -cache -. -explicit_slots -( -) -) -; -epsilons -. -slots -( -) -. -apply -( -at -& -mut -slots -[ -self -. -explicit_slot_start -. -. -] -) -; -} -* -matched_pid -= -Some -( -pid -) -; -true -} -} -impl -DFA -{ -/ -/ -/ -Returns -the -anchored -start -state -for -matching -any -pattern -in -this -DFA -. -fn -start -( -& -self -) -- -> -StateID -{ -self -. -starts -[ -0 -] -} -/ -/ -/ -Returns -the -anchored -start -state -for -matching -the -given -pattern -. -If -/ -/ -/ -' -starts_for_each_pattern -' -/ -/ -/ -was -not -enabled -then -this -returns -an -error -. -If -the -given -pattern -is -/ -/ -/ -not -in -this -DFA -then -Ok -( -None -) -is -returned -. -fn -start_pattern -( -& -self -pid -: -PatternID -) -- -> -Result -< -StateID -MatchError -> -{ -if -! -self -. -config -. -get_starts_for_each_pattern -( -) -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -Anchored -: -: -Pattern -( -pid -) -) -) -; -} -/ -/ -' -starts -' -always -has -non -- -zero -length -. -The -first -entry -is -always -the -/ -/ -anchored -starting -state -for -all -patterns -and -the -following -entries -/ -/ -are -optional -and -correspond -to -the -anchored -starting -states -for -/ -/ -patterns -at -pid -+ -1 -. -Thus -starts -. -len -( -) -- -1 -corresponds -to -the -total -/ -/ -number -of -patterns -that -one -can -explicitly -search -for -. -( -And -it -may -/ -/ -be -zero -. -) -Ok -( -self -. -starts -. -get -( -pid -. -one_more -( -) -) -. -copied -( -) -. -unwrap_or -( -DEAD -) -) -} -/ -/ -/ -Returns -the -transition -from -the -given -state -ID -and -byte -of -input -. -The -/ -/ -/ -transition -includes -the -next -state -ID -the -slots -that -should -be -saved -/ -/ -/ -and -any -conditional -epsilon -transitions -that -must -be -satisfied -in -order -/ -/ -/ -to -take -this -transition -. -fn -transition -( -& -self -sid -: -StateID -byte -: -u8 -) -- -> -Transition -{ -let -offset -= -sid -. -as_usize -( -) -< -< -self -. -stride2 -( -) -; -let -class -= -self -. -classes -. -get -( -byte -) -. -as_usize -( -) -; -self -. -table -[ -offset -+ -class -] -} -/ -/ -/ -Set -the -transition -from -the -given -state -ID -and -byte -of -input -to -the -/ -/ -/ -transition -given -. -fn -set_transition -( -& -mut -self -sid -: -StateID -byte -: -u8 -to -: -Transition -) -{ -let -offset -= -sid -. -as_usize -( -) -< -< -self -. -stride2 -( -) -; -let -class -= -self -. -classes -. -get -( -byte -) -. -as_usize -( -) -; -self -. -table -[ -offset -+ -class -] -= -to -; -} -/ -/ -/ -Return -an -iterator -of -" -sparse -" -transitions -for -the -given -state -ID -. -/ -/ -/ -" -sparse -" -in -this -context -means -that -consecutive -transitions -that -are -/ -/ -/ -equivalent -are -returned -as -one -group -and -transitions -to -the -DEAD -state -/ -/ -/ -are -ignored -. -/ -/ -/ -/ -/ -/ -This -winds -up -being -useful -for -debug -printing -since -it -' -s -much -terser -/ -/ -/ -to -display -runs -of -equivalent -transitions -than -the -transition -for -every -/ -/ -/ -possible -byte -value -. -Indeed -in -practice -it -' -s -very -common -for -runs -/ -/ -/ -of -equivalent -transitions -to -appear -. -fn -sparse_transitions -( -& -self -sid -: -StateID -) -- -> -SparseTransitionIter -< -' -_ -> -{ -let -start -= -sid -. -as_usize -( -) -< -< -self -. -stride2 -( -) -; -let -end -= -start -+ -self -. -alphabet_len -( -) -; -SparseTransitionIter -{ -it -: -self -. -table -[ -start -. -. -end -] -. -iter -( -) -. -enumerate -( -) -cur -: -None -} -} -/ -/ -/ -Return -the -pattern -epsilons -for -the -given -state -ID -. -/ -/ -/ -/ -/ -/ -If -the -given -state -ID -does -not -correspond -to -a -match -state -ID -then -the -/ -/ -/ -pattern -epsilons -returned -is -empty -. -fn -pattern_epsilons -( -& -self -sid -: -StateID -) -- -> -PatternEpsilons -{ -let -offset -= -sid -. -as_usize -( -) -< -< -self -. -stride2 -( -) -; -PatternEpsilons -( -self -. -table -[ -offset -+ -self -. -pateps_offset -] -. -0 -) -} -/ -/ -/ -Set -the -pattern -epsilons -for -the -given -state -ID -. -fn -set_pattern_epsilons -( -& -mut -self -sid -: -StateID -pateps -: -PatternEpsilons -) -{ -let -offset -= -sid -. -as_usize -( -) -< -< -self -. -stride2 -( -) -; -self -. -table -[ -offset -+ -self -. -pateps_offset -] -= -Transition -( -pateps -. -0 -) -; -} -/ -/ -/ -Returns -the -state -ID -prior -to -the -one -given -. -This -returns -None -if -the -/ -/ -/ -given -ID -is -the -first -DFA -state -. -fn -prev_state_id -( -& -self -id -: -StateID -) -- -> -Option -< -StateID -> -{ -if -id -= -= -DEAD -{ -None -} -else -{ -/ -/ -CORRECTNESS -: -Since -' -id -' -is -not -the -first -state -subtracting -1 -/ -/ -is -always -valid -. -Some -( -StateID -: -: -new_unchecked -( -id -. -as_usize -( -) -. -checked_sub -( -1 -) -. -unwrap -( -) -) -) -} -} -/ -/ -/ -Returns -the -state -ID -of -the -last -state -in -this -DFA -' -s -transition -table -. -/ -/ -/ -" -last -" -in -this -context -means -the -last -state -to -appear -in -memory -i -. -e -. -/ -/ -/ -the -one -with -the -greatest -ID -. -fn -last_state_id -( -& -self -) -- -> -StateID -{ -/ -/ -CORRECTNESS -: -A -DFA -table -is -always -non -- -empty -since -it -always -at -/ -/ -least -contains -a -DEAD -state -. -Since -every -state -has -the -same -stride -/ -/ -we -can -just -compute -what -the -" -next -" -state -ID -would -have -been -and -/ -/ -then -subtract -1 -from -it -. -StateID -: -: -new_unchecked -( -( -self -. -table -. -len -( -) -> -> -self -. -stride2 -( -) -) -. -checked_sub -( -1 -) -. -unwrap -( -) -) -} -/ -/ -/ -Move -the -transitions -from -' -id1 -' -to -' -id2 -' -and -vice -versa -. -/ -/ -/ -/ -/ -/ -WARNING -: -This -does -not -update -the -rest -of -the -transition -table -to -have -/ -/ -/ -transitions -to -' -id1 -' -changed -to -' -id2 -' -and -vice -versa -. -This -merely -moves -/ -/ -/ -the -states -in -memory -. -pub -( -super -) -fn -swap_states -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -{ -let -o1 -= -id1 -. -as_usize -( -) -< -< -self -. -stride2 -( -) -; -let -o2 -= -id2 -. -as_usize -( -) -< -< -self -. -stride2 -( -) -; -for -b -in -0 -. -. -self -. -stride -( -) -{ -self -. -table -. -swap -( -o1 -+ -b -o2 -+ -b -) -; -} -} -/ -/ -/ -Map -all -state -IDs -in -this -DFA -( -transition -table -+ -start -states -) -/ -/ -/ -according -to -the -closure -given -. -pub -( -super -) -fn -remap -( -& -mut -self -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -{ -for -i -in -0 -. -. -self -. -state_len -( -) -{ -let -offset -= -i -< -< -self -. -stride2 -( -) -; -for -b -in -0 -. -. -self -. -alphabet_len -( -) -{ -let -next -= -self -. -table -[ -offset -+ -b -] -. -state_id -( -) -; -self -. -table -[ -offset -+ -b -] -. -set_state_id -( -map -( -next -) -) -; -} -} -for -i -in -0 -. -. -self -. -starts -. -len -( -) -{ -self -. -starts -[ -i -] -= -map -( -self -. -starts -[ -i -] -) -; -} -} -} -impl -core -: -: -fmt -: -: -Debug -for -DFA -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -fn -debug_state_transitions -( -f -: -& -mut -core -: -: -fmt -: -: -Formatter -dfa -: -& -DFA -sid -: -StateID -) -- -> -core -: -: -fmt -: -: -Result -{ -for -( -i -( -start -end -trans -) -) -in -dfa -. -sparse_transitions -( -sid -) -. -enumerate -( -) -{ -let -next -= -trans -. -state_id -( -) -; -if -i -> -0 -{ -write -! -( -f -" -" -) -? -; -} -if -start -= -= -end -{ -write -! -( -f -" -{ -: -? -} -= -> -{ -: -? -} -" -DebugByte -( -start -) -next -. -as_usize -( -) -) -? -; -} -else -{ -write -! -( -f -" -{ -: -? -} -- -{ -: -? -} -= -> -{ -: -? -} -" -DebugByte -( -start -) -DebugByte -( -end -) -next -. -as_usize -( -) -) -? -; -} -if -trans -. -match_wins -( -) -{ -write -! -( -f -" -( -MW -) -" -) -? -; -} -if -! -trans -. -epsilons -( -) -. -is_empty -( -) -{ -write -! -( -f -" -( -{ -: -? -} -) -" -trans -. -epsilons -( -) -) -? -; -} -} -Ok -( -( -) -) -} -writeln -! -( -f -" -onepass -: -: -DFA -( -" -) -? -; -for -index -in -0 -. -. -self -. -state_len -( -) -{ -let -sid -= -StateID -: -: -must -( -index -) -; -let -pateps -= -self -. -pattern_epsilons -( -sid -) -; -if -sid -= -= -DEAD -{ -write -! -( -f -" -D -" -) -? -; -} -else -if -pateps -. -pattern_id -( -) -. -is_some -( -) -{ -write -! -( -f -" -* -" -) -? -; -} -else -{ -write -! -( -f -" -" -) -? -; -} -write -! -( -f -" -{ -: -06 -? -} -" -sid -. -as_usize -( -) -) -? -; -if -! -pateps -. -is_empty -( -) -{ -write -! -( -f -" -( -{ -: -? -} -) -" -pateps -) -? -; -} -write -! -( -f -" -: -" -) -? -; -debug_state_transitions -( -f -self -sid -) -? -; -write -! -( -f -" -\ -n -" -) -? -; -} -writeln -! -( -f -" -" -) -? -; -for -( -i -& -sid -) -in -self -. -starts -. -iter -( -) -. -enumerate -( -) -{ -if -i -= -= -0 -{ -writeln -! -( -f -" -START -( -ALL -) -: -{ -: -? -} -" -sid -. -as_usize -( -) -) -? -; -} -else -{ -writeln -! -( -f -" -START -( -pattern -: -{ -: -? -} -) -: -{ -: -? -} -" -i -- -1 -sid -. -as_usize -( -) -) -? -; -} -} -writeln -! -( -f -" -state -length -: -{ -: -? -} -" -self -. -state_len -( -) -) -? -; -writeln -! -( -f -" -pattern -length -: -{ -: -? -} -" -self -. -pattern_len -( -) -) -? -; -writeln -! -( -f -" -) -" -) -? -; -Ok -( -( -) -) -} -} -/ -/ -/ -An -iterator -over -groups -of -consecutive -equivalent -transitions -in -a -single -/ -/ -/ -state -. -# -[ -derive -( -Debug -) -] -struct -SparseTransitionIter -< -' -a -> -{ -it -: -core -: -: -iter -: -: -Enumerate -< -core -: -: -slice -: -: -Iter -< -' -a -Transition -> -> -cur -: -Option -< -( -u8 -u8 -Transition -) -> -} -impl -< -' -a -> -Iterator -for -SparseTransitionIter -< -' -a -> -{ -type -Item -= -( -u8 -u8 -Transition -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -u8 -u8 -Transition -) -> -{ -while -let -Some -( -( -b -& -trans -) -) -= -self -. -it -. -next -( -) -{ -/ -/ -Fine -because -we -' -ll -never -have -more -than -u8 -: -: -MAX -transitions -in -/ -/ -one -state -. -let -b -= -b -. -as_u8 -( -) -; -let -( -prev_start -prev_end -prev_trans -) -= -match -self -. -cur -{ -Some -( -t -) -= -> -t -None -= -> -{ -self -. -cur -= -Some -( -( -b -b -trans -) -) -; -continue -; -} -} -; -if -prev_trans -= -= -trans -{ -self -. -cur -= -Some -( -( -prev_start -b -prev_trans -) -) -; -} -else -{ -self -. -cur -= -Some -( -( -b -b -trans -) -) -; -if -prev_trans -. -state_id -( -) -! -= -DEAD -{ -return -Some -( -( -prev_start -prev_end -prev_trans -) -) -; -} -} -} -if -let -Some -( -( -start -end -trans -) -) -= -self -. -cur -. -take -( -) -{ -if -trans -. -state_id -( -) -! -= -DEAD -{ -return -Some -( -( -start -end -trans -) -) -; -} -} -None -} -} -/ -/ -/ -A -cache -represents -mutable -state -that -a -one -- -pass -[ -DFA -] -requires -during -a -/ -/ -/ -search -. -/ -/ -/ -/ -/ -/ -For -a -given -one -- -pass -DFA -its -corresponding -cache -may -be -created -either -via -/ -/ -/ -[ -DFA -: -: -create_cache -] -or -via -[ -Cache -: -: -new -] -. -They -are -equivalent -in -every -/ -/ -/ -way -except -the -former -does -not -require -explicitly -importing -Cache -. -/ -/ -/ -/ -/ -/ -A -particular -Cache -is -coupled -with -the -one -- -pass -DFA -from -which -it -was -/ -/ -/ -created -. -It -may -only -be -used -with -that -one -- -pass -DFA -. -A -cache -and -its -/ -/ -/ -allocations -may -be -re -- -purposed -via -[ -Cache -: -: -reset -] -in -which -case -it -can -/ -/ -/ -only -be -used -with -the -new -one -- -pass -DFA -( -and -not -the -old -one -) -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Cache -{ -/ -/ -/ -Scratch -space -used -to -store -slots -during -a -search -. -Basically -we -use -/ -/ -/ -the -caller -provided -slots -to -store -slots -known -when -a -match -occurs -. -/ -/ -/ -But -after -a -match -occurs -we -might -continue -a -search -but -ultimately -/ -/ -/ -fail -to -extend -the -match -. -When -continuing -the -search -we -need -some -/ -/ -/ -place -to -store -candidate -capture -offsets -without -overwriting -the -slot -/ -/ -/ -offsets -recorded -for -the -most -recently -seen -match -. -explicit_slots -: -Vec -< -Option -< -NonMaxUsize -> -> -/ -/ -/ -The -number -of -slots -in -the -caller -- -provided -' -Captures -' -value -for -the -/ -/ -/ -current -search -. -This -is -always -at -most -' -explicit_slots -. -len -( -) -' -but -/ -/ -/ -might -be -less -than -it -if -the -caller -provided -fewer -slots -to -fill -. -explicit_slot_len -: -usize -} -impl -Cache -{ -/ -/ -/ -Create -a -new -[ -onepass -: -: -DFA -] -( -DFA -) -cache -. -/ -/ -/ -/ -/ -/ -A -potentially -more -convenient -routine -to -create -a -cache -is -/ -/ -/ -[ -DFA -: -: -create_cache -] -as -it -does -not -require -also -importing -the -/ -/ -/ -Cache -type -. -/ -/ -/ -/ -/ -/ -If -you -want -to -reuse -the -returned -Cache -with -some -other -one -- -pass -DFA -/ -/ -/ -then -you -must -call -[ -Cache -: -: -reset -] -with -the -desired -one -- -pass -DFA -. -pub -fn -new -( -re -: -& -DFA -) -- -> -Cache -{ -let -mut -cache -= -Cache -{ -explicit_slots -: -vec -! -[ -] -explicit_slot_len -: -0 -} -; -cache -. -reset -( -re -) -; -cache -} -/ -/ -/ -Reset -this -cache -such -that -it -can -be -used -for -searching -with -a -/ -/ -/ -different -[ -onepass -: -: -DFA -] -( -DFA -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -one -- -pass -/ -/ -/ -DFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -DFA -Match -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -DFA -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -DFA -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -let -mut -caps1 -= -re1 -. -create_captures -( -) -; -/ -/ -/ -let -mut -caps2 -= -re2 -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -/ -/ -/ -{ -re1 -. -captures -( -& -mut -cache -" -" -& -mut -caps1 -) -; -caps1 -. -get_match -( -) -} -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -one -- -pass -DFA -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -re2 -. -reset_cache -( -& -mut -cache -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -/ -/ -/ -{ -re2 -. -captures -( -& -mut -cache -" -" -& -mut -caps2 -) -; -caps2 -. -get_match -( -) -} -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset -( -& -mut -self -re -: -& -DFA -) -{ -let -explicit_slot_len -= -re -. -get_nfa -( -) -. -group_info -( -) -. -explicit_slot_len -( -) -; -self -. -explicit_slots -. -resize -( -explicit_slot_len -None -) -; -self -. -explicit_slot_len -= -explicit_slot_len -; -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -of -this -cache -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -cache -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -Cache -> -( -) -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -explicit_slots -. -len -( -) -* -core -: -: -mem -: -: -size_of -: -: -< -Option -< -NonMaxUsize -> -> -( -) -} -fn -explicit_slots -( -& -mut -self -) -- -> -& -mut -[ -Option -< -NonMaxUsize -> -] -{ -& -mut -self -. -explicit_slots -[ -. -. -self -. -explicit_slot_len -] -} -fn -setup_search -( -& -mut -self -explicit_slot_len -: -usize -) -{ -self -. -explicit_slot_len -= -explicit_slot_len -; -} -} -/ -/ -/ -Represents -a -single -transition -in -a -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -The -high -24 -bits -corresponds -to -the -state -ID -. -The -low -48 -bits -corresponds -/ -/ -/ -to -the -transition -epsilons -which -contains -the -slots -that -should -be -saved -/ -/ -/ -when -this -transition -is -followed -and -the -conditional -epsilon -transitions -/ -/ -/ -that -must -be -satisfied -in -order -to -follow -this -transition -. -# -[ -derive -( -Clone -Copy -Eq -PartialEq -) -] -struct -Transition -( -u64 -) -; -impl -Transition -{ -const -STATE_ID_BITS -: -u64 -= -21 -; -const -STATE_ID_SHIFT -: -u64 -= -64 -- -Transition -: -: -STATE_ID_BITS -; -const -STATE_ID_LIMIT -: -u64 -= -1 -< -< -Transition -: -: -STATE_ID_BITS -; -const -MATCH_WINS_SHIFT -: -u64 -= -64 -- -( -Transition -: -: -STATE_ID_BITS -+ -1 -) -; -const -INFO_MASK -: -u64 -= -0x000003FF_FFFFFFFF -; -/ -/ -/ -Return -a -new -transition -to -the -given -state -ID -with -the -given -epsilons -. -fn -new -( -match_wins -: -bool -sid -: -StateID -epsilons -: -Epsilons -) -- -> -Transition -{ -let -match_wins -= -if -match_wins -{ -1 -< -< -Transition -: -: -MATCH_WINS_SHIFT -} -else -{ -0 -} -; -let -sid -= -sid -. -as_u64 -( -) -< -< -Transition -: -: -STATE_ID_SHIFT -; -Transition -( -sid -| -match_wins -| -epsilons -. -0 -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -transition -points -to -the -DEAD -state -. -fn -is_dead -( -self -) -- -> -bool -{ -self -. -state_id -( -) -= -= -DEAD -} -/ -/ -/ -Return -whether -this -transition -has -a -" -match -wins -" -property -. -/ -/ -/ -/ -/ -/ -When -a -transition -has -this -property -it -means -that -if -a -match -has -been -/ -/ -/ -found -and -the -search -uses -leftmost -- -first -semantics -then -that -match -/ -/ -/ -should -be -returned -immediately -instead -of -continuing -on -. -/ -/ -/ -/ -/ -/ -The -" -match -wins -" -name -comes -from -RE2 -which -uses -a -pretty -much -/ -/ -/ -identical -mechanism -for -implementing -leftmost -- -first -semantics -. -fn -match_wins -( -& -self -) -- -> -bool -{ -( -self -. -0 -> -> -Transition -: -: -MATCH_WINS_SHIFT -& -1 -) -= -= -1 -} -/ -/ -/ -Return -the -" -next -" -state -ID -that -this -transition -points -to -. -fn -state_id -( -& -self -) -- -> -StateID -{ -/ -/ -OK -because -a -Transition -has -a -valid -StateID -in -its -upper -bits -by -/ -/ -construction -. -The -cast -to -usize -is -also -correct -even -on -16 -- -bit -/ -/ -targets -because -again -we -know -the -upper -bits -is -a -valid -StateID -/ -/ -which -can -never -overflow -usize -on -any -supported -target -. -StateID -: -: -new_unchecked -( -( -self -. -0 -> -> -Transition -: -: -STATE_ID_SHIFT -) -. -as_usize -( -) -) -} -/ -/ -/ -Set -the -" -next -" -state -ID -in -this -transition -. -fn -set_state_id -( -& -mut -self -sid -: -StateID -) -{ -* -self -= -Transition -: -: -new -( -self -. -match_wins -( -) -sid -self -. -epsilons -( -) -) -; -} -/ -/ -/ -Return -the -epsilons -embedded -in -this -transition -. -fn -epsilons -( -& -self -) -- -> -Epsilons -{ -Epsilons -( -self -. -0 -& -Transition -: -: -INFO_MASK -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -Transition -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -if -self -. -is_dead -( -) -{ -return -write -! -( -f -" -0 -" -) -; -} -write -! -( -f -" -{ -} -" -self -. -state_id -( -) -. -as_usize -( -) -) -? -; -if -self -. -match_wins -( -) -{ -write -! -( -f -" -- -MW -" -) -? -; -} -if -! -self -. -epsilons -( -) -. -is_empty -( -) -{ -write -! -( -f -" -- -{ -: -? -} -" -self -. -epsilons -( -) -) -? -; -} -Ok -( -( -) -) -} -} -/ -/ -/ -A -representation -of -a -match -state -' -s -pattern -ID -along -with -the -epsilons -for -/ -/ -/ -when -a -match -occurs -. -/ -/ -/ -/ -/ -/ -A -match -state -in -a -one -- -pass -DFA -unlike -in -a -more -general -DFA -has -exactly -/ -/ -/ -one -pattern -ID -. -If -it -had -more -then -the -original -NFA -would -not -have -been -/ -/ -/ -one -- -pass -. -/ -/ -/ -/ -/ -/ -The -" -epsilons -" -part -of -this -corresponds -to -what -was -found -in -the -epsilon -/ -/ -/ -transitions -between -the -transition -taken -in -the -last -byte -of -input -and -the -/ -/ -/ -ultimate -match -state -. -This -might -include -saving -slots -and -/ -or -conditional -/ -/ -/ -epsilon -transitions -that -must -be -satisfied -before -one -can -report -the -match -. -/ -/ -/ -/ -/ -/ -Technically -every -state -has -room -for -a -' -PatternEpsilons -' -but -it -is -only -/ -/ -/ -ever -non -- -empty -for -match -states -. -# -[ -derive -( -Clone -Copy -) -] -struct -PatternEpsilons -( -u64 -) -; -impl -PatternEpsilons -{ -const -PATTERN_ID_BITS -: -u64 -= -22 -; -const -PATTERN_ID_SHIFT -: -u64 -= -64 -- -PatternEpsilons -: -: -PATTERN_ID_BITS -; -/ -/ -A -sentinel -value -indicating -that -this -is -not -a -match -state -. -We -don -' -t -/ -/ -use -0 -since -0 -is -a -valid -pattern -ID -. -const -PATTERN_ID_NONE -: -u64 -= -0x00000000_003FFFFF -; -const -PATTERN_ID_LIMIT -: -u64 -= -PatternEpsilons -: -: -PATTERN_ID_NONE -; -const -PATTERN_ID_MASK -: -u64 -= -0xFFFFFC00_00000000 -; -const -EPSILONS_MASK -: -u64 -= -0x000003FF_FFFFFFFF -; -/ -/ -/ -Return -a -new -empty -pattern -epsilons -that -has -no -pattern -ID -and -has -no -/ -/ -/ -epsilons -. -This -is -suitable -for -non -- -match -states -. -fn -empty -( -) -- -> -PatternEpsilons -{ -PatternEpsilons -( -PatternEpsilons -: -: -PATTERN_ID_NONE -< -< -PatternEpsilons -: -: -PATTERN_ID_SHIFT -) -} -/ -/ -/ -Whether -this -pattern -epsilons -is -empty -or -not -. -It -' -s -empty -when -it -has -/ -/ -/ -no -pattern -ID -and -an -empty -epsilons -. -fn -is_empty -( -self -) -- -> -bool -{ -self -. -pattern_id -( -) -. -is_none -( -) -& -& -self -. -epsilons -( -) -. -is_empty -( -) -} -/ -/ -/ -Return -the -pattern -ID -in -this -pattern -epsilons -if -one -exists -. -fn -pattern_id -( -self -) -- -> -Option -< -PatternID -> -{ -let -pid -= -self -. -0 -> -> -PatternEpsilons -: -: -PATTERN_ID_SHIFT -; -if -pid -= -= -PatternEpsilons -: -: -PATTERN_ID_LIMIT -{ -None -} -else -{ -Some -( -PatternID -: -: -new_unchecked -( -pid -. -as_usize -( -) -) -) -} -} -/ -/ -/ -Returns -the -pattern -ID -without -checking -whether -it -' -s -valid -. -If -this -is -/ -/ -/ -called -and -there -is -no -pattern -ID -in -this -PatternEpsilons -then -this -/ -/ -/ -will -likely -produce -an -incorrect -result -or -possibly -even -a -panic -or -/ -/ -/ -an -overflow -. -But -safety -will -not -be -violated -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -you -know -a -particular -state -is -a -match -state -. -If -/ -/ -/ -it -' -s -a -match -state -then -it -must -have -a -pattern -ID -. -fn -pattern_id_unchecked -( -self -) -- -> -PatternID -{ -let -pid -= -self -. -0 -> -> -PatternEpsilons -: -: -PATTERN_ID_SHIFT -; -PatternID -: -: -new_unchecked -( -pid -. -as_usize -( -) -) -} -/ -/ -/ -Return -a -new -pattern -epsilons -with -the -given -pattern -ID -but -the -same -/ -/ -/ -epsilons -. -fn -set_pattern_id -( -self -pid -: -PatternID -) -- -> -PatternEpsilons -{ -PatternEpsilons -( -( -pid -. -as_u64 -( -) -< -< -PatternEpsilons -: -: -PATTERN_ID_SHIFT -) -| -( -self -. -0 -& -PatternEpsilons -: -: -EPSILONS_MASK -) -) -} -/ -/ -/ -Return -the -epsilons -part -of -this -pattern -epsilons -. -fn -epsilons -( -self -) -- -> -Epsilons -{ -Epsilons -( -self -. -0 -& -PatternEpsilons -: -: -EPSILONS_MASK -) -} -/ -/ -/ -Return -a -new -pattern -epsilons -with -the -given -epsilons -but -the -same -/ -/ -/ -pattern -ID -. -fn -set_epsilons -( -self -epsilons -: -Epsilons -) -- -> -PatternEpsilons -{ -PatternEpsilons -( -( -self -. -0 -& -PatternEpsilons -: -: -PATTERN_ID_MASK -) -| -u64 -: -: -from -( -epsilons -. -0 -) -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -PatternEpsilons -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -if -self -. -is_empty -( -) -{ -return -write -! -( -f -" -N -/ -A -" -) -; -} -if -let -Some -( -pid -) -= -self -. -pattern_id -( -) -{ -write -! -( -f -" -{ -} -" -pid -. -as_usize -( -) -) -? -; -} -if -! -self -. -epsilons -( -) -. -is_empty -( -) -{ -if -self -. -pattern_id -( -) -. -is_some -( -) -{ -write -! -( -f -" -/ -" -) -? -; -} -write -! -( -f -" -{ -: -? -} -" -self -. -epsilons -( -) -) -? -; -} -Ok -( -( -) -) -} -} -/ -/ -/ -Epsilons -represents -all -of -the -NFA -epsilons -transitions -that -went -into -a -/ -/ -/ -single -transition -in -a -single -DFA -state -. -In -this -case -it -only -represents -/ -/ -/ -the -epsilon -transitions -that -have -some -kind -of -non -- -consuming -side -effect -: -/ -/ -/ -either -the -transition -requires -storing -the -current -position -of -the -search -/ -/ -/ -into -a -slot -or -the -transition -is -conditional -and -requires -the -current -/ -/ -/ -position -in -the -input -to -satisfy -an -assertion -before -the -transition -may -be -/ -/ -/ -taken -. -/ -/ -/ -/ -/ -/ -This -folds -the -cumulative -effect -of -a -group -of -NFA -states -( -all -connected -/ -/ -/ -by -epsilon -transitions -) -down -into -a -single -set -of -bits -. -While -these -bits -/ -/ -/ -can -represent -all -possible -conditional -epsilon -transitions -it -only -permits -/ -/ -/ -storing -up -to -a -somewhat -small -number -of -slots -. -/ -/ -/ -/ -/ -/ -Epsilons -is -represented -as -a -42 -- -bit -integer -. -For -example -it -is -packed -into -/ -/ -/ -the -lower -42 -bits -of -a -Transition -. -( -Where -the -high -22 -bits -contains -a -/ -/ -/ -StateID -and -a -special -" -match -wins -" -property -. -) -# -[ -derive -( -Clone -Copy -) -] -struct -Epsilons -( -u64 -) -; -impl -Epsilons -{ -const -SLOT_MASK -: -u64 -= -0x000003FF_FFFFFC00 -; -const -SLOT_SHIFT -: -u64 -= -10 -; -const -LOOK_MASK -: -u64 -= -0x00000000_000003FF -; -/ -/ -/ -Create -a -new -empty -epsilons -. -It -has -no -slots -and -no -assertions -that -/ -/ -/ -need -to -be -satisfied -. -fn -empty -( -) -- -> -Epsilons -{ -Epsilons -( -0 -) -} -/ -/ -/ -Returns -true -if -this -epsilons -contains -no -slots -and -no -assertions -. -fn -is_empty -( -self -) -- -> -bool -{ -self -. -0 -= -= -0 -} -/ -/ -/ -Returns -the -slot -epsilon -transitions -. -fn -slots -( -self -) -- -> -Slots -{ -Slots -( -( -self -. -0 -> -> -Epsilons -: -: -SLOT_SHIFT -) -. -low_u32 -( -) -) -} -/ -/ -/ -Set -the -slot -epsilon -transitions -. -fn -set_slots -( -self -slots -: -Slots -) -- -> -Epsilons -{ -Epsilons -( -( -u64 -: -: -from -( -slots -. -0 -) -< -< -Epsilons -: -: -SLOT_SHIFT -) -| -( -self -. -0 -& -Epsilons -: -: -LOOK_MASK -) -) -} -/ -/ -/ -Return -the -set -of -look -- -around -assertions -in -these -epsilon -transitions -. -fn -looks -( -self -) -- -> -LookSet -{ -LookSet -{ -bits -: -( -self -. -0 -& -Epsilons -: -: -LOOK_MASK -) -. -low_u16 -( -) -} -} -/ -/ -/ -Set -the -look -- -around -assertions -on -these -epsilon -transitions -. -fn -set_looks -( -self -look_set -: -LookSet -) -- -> -Epsilons -{ -Epsilons -( -( -self -. -0 -& -Epsilons -: -: -SLOT_MASK -) -| -u64 -: -: -from -( -look_set -. -bits -) -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -Epsilons -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -wrote -= -false -; -if -! -self -. -slots -( -) -. -is_empty -( -) -{ -write -! -( -f -" -{ -: -? -} -" -self -. -slots -( -) -) -? -; -wrote -= -true -; -} -if -! -self -. -looks -( -) -. -is_empty -( -) -{ -if -wrote -{ -write -! -( -f -" -/ -" -) -? -; -} -write -! -( -f -" -{ -: -? -} -" -self -. -looks -( -) -) -? -; -wrote -= -true -; -} -if -! -wrote -{ -write -! -( -f -" -N -/ -A -" -) -? -; -} -Ok -( -( -) -) -} -} -/ -/ -/ -The -set -of -epsilon -transitions -indicating -that -the -current -position -in -a -/ -/ -/ -search -should -be -saved -to -a -slot -. -/ -/ -/ -/ -/ -/ -This -* -only -* -represents -explicit -slots -. -So -for -example -the -pattern -/ -/ -/ -[ -a -- -z -] -+ -( -[ -0 -- -9 -] -+ -) -( -[ -a -- -z -] -+ -) -has -: -/ -/ -/ -/ -/ -/ -* -3 -capturing -groups -thus -6 -slots -. -/ -/ -/ -* -1 -implicit -capturing -group -thus -2 -implicit -slots -. -/ -/ -/ -* -2 -explicit -capturing -groups -thus -4 -explicit -slots -. -/ -/ -/ -/ -/ -/ -While -implicit -slots -are -represented -by -epsilon -transitions -in -an -NFA -we -/ -/ -/ -do -not -explicitly -represent -them -here -. -Instead -implicit -slots -are -assumed -/ -/ -/ -to -be -present -and -handled -automatically -in -the -search -code -. -Therefore -/ -/ -/ -that -means -we -only -need -to -represent -explicit -slots -in -our -epsilon -/ -/ -/ -transitions -. -/ -/ -/ -/ -/ -/ -Its -representation -is -a -bit -set -. -The -bit -' -i -' -is -set -if -and -only -if -there -/ -/ -/ -exists -an -explicit -slot -at -index -' -c -' -where -' -c -= -( -# -patterns -* -2 -) -+ -i -' -. -That -/ -/ -/ -is -the -bit -' -i -' -corresponds -to -the -first -explicit -slot -and -the -first -/ -/ -/ -explicit -slot -appears -immediately -following -the -last -implicit -slot -. -( -If -/ -/ -/ -this -is -confusing -see -GroupInfo -for -more -details -on -how -slots -works -. -) -/ -/ -/ -/ -/ -/ -A -single -Slots -represents -all -the -active -slots -in -a -sub -- -graph -of -an -NFA -/ -/ -/ -where -all -the -states -are -connected -by -epsilon -transitions -. -In -effect -when -/ -/ -/ -traversing -the -one -- -pass -DFA -during -a -search -all -slots -set -in -a -particular -/ -/ -/ -transition -must -be -captured -by -recording -the -current -search -position -. -/ -/ -/ -/ -/ -/ -The -API -of -Slots -requires -the -caller -to -handle -the -explicit -slot -offset -. -/ -/ -/ -That -is -a -Slots -doesn -' -t -know -where -the -explicit -slots -start -for -a -/ -/ -/ -particular -NFA -. -Thus -if -the -callers -see -' -s -the -bit -' -i -' -is -set -then -they -/ -/ -/ -need -to -do -the -arithmetic -above -to -find -' -c -' -which -is -the -real -actual -slot -/ -/ -/ -index -in -the -corresponding -NFA -. -# -[ -derive -( -Clone -Copy -) -] -struct -Slots -( -u32 -) -; -impl -Slots -{ -const -LIMIT -: -usize -= -32 -; -/ -/ -/ -Insert -the -slot -at -the -given -bit -index -. -fn -insert -( -self -slot -: -usize -) -- -> -Slots -{ -debug_assert -! -( -slot -< -Slots -: -: -LIMIT -) -; -Slots -( -self -. -0 -| -( -1 -< -< -slot -. -as_u32 -( -) -) -) -} -/ -/ -/ -Remove -the -slot -at -the -given -bit -index -. -fn -remove -( -self -slot -: -usize -) -- -> -Slots -{ -debug_assert -! -( -slot -< -Slots -: -: -LIMIT -) -; -Slots -( -self -. -0 -& -! -( -1 -< -< -slot -. -as_u32 -( -) -) -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -no -slots -. -fn -is_empty -( -self -) -- -> -bool -{ -self -. -0 -= -= -0 -} -/ -/ -/ -Returns -an -iterator -over -all -of -the -set -bits -in -this -set -. -fn -iter -( -self -) -- -> -SlotsIter -{ -SlotsIter -{ -slots -: -self -} -} -/ -/ -/ -For -the -position -at -in -the -current -haystack -copy -it -to -/ -/ -/ -caller_explicit_slots -for -all -slots -that -are -in -this -set -. -/ -/ -/ -/ -/ -/ -Callers -may -pass -a -slice -of -any -length -. -Slots -in -this -set -bigger -than -/ -/ -/ -the -length -of -the -given -explicit -slots -are -simply -skipped -. -/ -/ -/ -/ -/ -/ -The -slice -* -must -* -correspond -only -to -the -explicit -slots -and -the -first -/ -/ -/ -element -of -the -slice -must -always -correspond -to -the -first -explicit -slot -/ -/ -/ -in -the -corresponding -NFA -. -fn -apply -( -self -at -: -usize -caller_explicit_slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -{ -if -self -. -is_empty -( -) -{ -return -; -} -let -at -= -NonMaxUsize -: -: -new -( -at -) -; -for -slot -in -self -. -iter -( -) -{ -if -slot -> -= -caller_explicit_slots -. -len -( -) -{ -break -; -} -caller_explicit_slots -[ -slot -] -= -at -; -} -} -} -impl -core -: -: -fmt -: -: -Debug -for -Slots -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -S -" -) -? -; -for -slot -in -self -. -iter -( -) -{ -write -! -( -f -" -- -{ -: -? -} -" -slot -) -? -; -} -Ok -( -( -) -) -} -} -/ -/ -/ -An -iterator -over -all -of -the -bits -set -in -a -slot -set -. -/ -/ -/ -/ -/ -/ -This -returns -the -bit -index -that -is -set -so -callers -may -need -to -offset -it -/ -/ -/ -to -get -the -actual -NFA -slot -index -. -# -[ -derive -( -Debug -) -] -struct -SlotsIter -{ -slots -: -Slots -} -impl -Iterator -for -SlotsIter -{ -type -Item -= -usize -; -fn -next -( -& -mut -self -) -- -> -Option -< -usize -> -{ -/ -/ -Number -of -zeroes -here -is -always -< -= -u8 -: -: -MAX -and -so -fits -in -a -usize -. -let -slot -= -self -. -slots -. -0 -. -trailing_zeros -( -) -. -as_usize -( -) -; -if -slot -> -= -Slots -: -: -LIMIT -{ -return -None -; -} -self -. -slots -= -self -. -slots -. -remove -( -slot -) -; -Some -( -slot -) -} -} -/ -/ -/ -An -error -that -occurred -during -the -construction -of -a -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -This -error -does -not -provide -many -introspection -capabilities -. -There -are -/ -/ -/ -generally -only -two -things -you -can -do -with -it -: -/ -/ -/ -/ -/ -/ -* -Obtain -a -human -readable -message -via -its -std -: -: -fmt -: -: -Display -impl -. -/ -/ -/ -* -Access -an -underlying -[ -thompson -: -: -BuildError -] -type -from -its -source -/ -/ -/ -method -via -the -std -: -: -error -: -: -Error -trait -. -This -error -only -occurs -when -using -/ -/ -/ -convenience -routines -for -building -a -one -- -pass -DFA -directly -from -a -pattern -/ -/ -/ -string -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -std -: -: -error -: -: -Error -/ -/ -/ -trait -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -BuildError -{ -kind -: -BuildErrorKind -} -/ -/ -/ -The -kind -of -error -that -occurred -during -the -construction -of -a -one -- -pass -DFA -. -# -[ -derive -( -Clone -Debug -) -] -enum -BuildErrorKind -{ -NFA -( -crate -: -: -nfa -: -: -thompson -: -: -BuildError -) -Word -( -UnicodeWordBoundaryError -) -TooManyStates -{ -limit -: -u64 -} -TooManyPatterns -{ -limit -: -u64 -} -UnsupportedLook -{ -look -: -Look -} -ExceededSizeLimit -{ -limit -: -usize -} -NotOnePass -{ -msg -: -& -' -static -str -} -} -impl -BuildError -{ -fn -nfa -( -err -: -crate -: -: -nfa -: -: -thompson -: -: -BuildError -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -NFA -( -err -) -} -} -fn -word -( -err -: -UnicodeWordBoundaryError -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -Word -( -err -) -} -} -fn -too_many_states -( -limit -: -u64 -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -TooManyStates -{ -limit -} -} -} -fn -too_many_patterns -( -limit -: -u64 -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -TooManyPatterns -{ -limit -} -} -} -fn -unsupported_look -( -look -: -Look -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -UnsupportedLook -{ -look -} -} -} -fn -exceeded_size_limit -( -limit -: -usize -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -ExceededSizeLimit -{ -limit -} -} -} -fn -not_one_pass -( -msg -: -& -' -static -str -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -NotOnePass -{ -msg -} -} -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -BuildError -{ -fn -source -( -& -self -) -- -> -Option -< -& -( -dyn -std -: -: -error -: -: -Error -+ -' -static -) -> -{ -use -self -: -: -BuildErrorKind -: -: -* -; -match -self -. -kind -{ -NFA -( -ref -err -) -= -> -Some -( -err -) -Word -( -ref -err -) -= -> -Some -( -err -) -_ -= -> -None -} -} -} -impl -core -: -: -fmt -: -: -Display -for -BuildError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -use -self -: -: -BuildErrorKind -: -: -* -; -match -self -. -kind -{ -NFA -( -_ -) -= -> -write -! -( -f -" -error -building -NFA -" -) -Word -( -_ -) -= -> -write -! -( -f -" -NFA -contains -Unicode -word -boundary -" -) -TooManyStates -{ -limit -} -= -> -write -! -( -f -" -one -- -pass -DFA -exceeded -a -limit -of -{ -: -? -} -for -number -of -states -" -limit -) -TooManyPatterns -{ -limit -} -= -> -write -! -( -f -" -one -- -pass -DFA -exceeded -a -limit -of -{ -: -? -} -for -number -of -patterns -" -limit -) -UnsupportedLook -{ -look -} -= -> -write -! -( -f -" -one -- -pass -DFA -does -not -support -the -{ -: -? -} -assertion -" -look -) -ExceededSizeLimit -{ -limit -} -= -> -write -! -( -f -" -one -- -pass -DFA -exceeded -size -limit -of -{ -: -? -} -during -building -" -limit -) -NotOnePass -{ -msg -} -= -> -write -! -( -f -" -one -- -pass -DFA -could -not -be -built -because -\ -pattern -is -not -one -- -pass -: -{ -} -" -msg -) -} -} -} -# -[ -cfg -( -all -( -test -feature -= -" -syntax -" -) -) -] -mod -tests -{ -use -alloc -: -: -string -: -: -ToString -; -use -super -: -: -* -; -# -[ -test -] -fn -fail_conflicting_transition -( -) -{ -let -predicate -= -| -err -: -& -str -| -err -. -contains -( -" -conflicting -transition -" -) -; -let -err -= -DFA -: -: -new -( -r -" -a -* -[ -ab -] -" -) -. -unwrap_err -( -) -. -to_string -( -) -; -assert -! -( -predicate -( -& -err -) -" -{ -} -" -err -) -; -} -# -[ -test -] -fn -fail_multiple_epsilon -( -) -{ -let -predicate -= -| -err -: -& -str -| -{ -err -. -contains -( -" -multiple -epsilon -transitions -to -same -state -" -) -} -; -let -err -= -DFA -: -: -new -( -r -" -( -^ -| -) -a -" -) -. -unwrap_err -( -) -. -to_string -( -) -; -assert -! -( -predicate -( -& -err -) -" -{ -} -" -err -) -; -} -# -[ -test -] -fn -fail_multiple_match -( -) -{ -let -predicate -= -| -err -: -& -str -| -{ -err -. -contains -( -" -multiple -epsilon -transitions -to -match -state -" -) -} -; -let -err -= -DFA -: -: -new_many -( -& -[ -r -" -^ -" -r -" -" -] -) -. -unwrap_err -( -) -. -to_string -( -) -; -assert -! -( -predicate -( -& -err -) -" -{ -} -" -err -) -; -} -/ -/ -This -test -is -meant -to -build -a -one -- -pass -regex -with -the -maximum -number -of -/ -/ -possible -slots -. -/ -/ -/ -/ -NOTE -: -Remember -that -the -slot -limit -only -applies -to -explicit -capturing -/ -/ -groups -. -Any -number -of -implicit -capturing -groups -is -supported -( -up -to -the -/ -/ -maximum -number -of -supported -patterns -) -since -implicit -groups -are -handled -/ -/ -by -the -search -loop -itself -. -# -[ -test -] -fn -max_slots -( -) -{ -/ -/ -One -too -many -. -. -. -let -pat -= -r -" -( -a -) -( -b -) -( -c -) -( -d -) -( -e -) -( -f -) -( -g -) -( -h -) -( -i -) -( -j -) -( -k -) -( -l -) -( -m -) -( -n -) -( -o -) -( -p -) -( -q -) -" -; -assert -! -( -DFA -: -: -new -( -pat -) -. -is_err -( -) -) -; -/ -/ -Just -right -. -let -pat -= -r -" -( -a -) -( -b -) -( -c -) -( -d -) -( -e -) -( -f -) -( -g -) -( -h -) -( -i -) -( -j -) -( -k -) -( -l -) -( -m -) -( -n -) -( -o -) -( -p -) -" -; -assert -! -( -DFA -: -: -new -( -pat -) -. -is_ok -( -) -) -; -} -/ -/ -This -test -ensures -that -the -one -- -pass -DFA -works -with -all -look -- -around -/ -/ -assertions -that -we -expect -it -to -work -with -. -/ -/ -/ -/ -The -utility -of -this -test -is -that -each -one -- -pass -transition -has -a -small -/ -/ -amount -of -space -to -store -look -- -around -assertions -. -Currently -there -is -/ -/ -logic -in -the -one -- -pass -constructor -to -ensure -there -aren -' -t -more -than -ten -/ -/ -possible -assertions -. -And -indeed -there -are -only -ten -possible -assertions -/ -/ -( -at -time -of -writing -) -so -this -is -okay -. -But -conceivably -more -assertions -/ -/ -could -be -added -. -So -we -check -that -things -at -least -work -with -what -we -/ -/ -expect -them -to -work -with -. -# -[ -test -] -fn -assertions -( -) -{ -/ -/ -haystack -anchors -assert -! -( -DFA -: -: -new -( -r -" -^ -" -) -. -is_ok -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -" -) -. -is_ok -( -) -) -; -/ -/ -line -anchors -assert -! -( -DFA -: -: -new -( -r -" -( -? -m -) -^ -" -) -. -is_ok -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -( -? -m -) -" -) -. -is_ok -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -( -? -Rm -) -^ -" -) -. -is_ok -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -( -? -Rm -) -" -) -. -is_ok -( -) -) -; -/ -/ -word -boundaries -if -cfg -! -( -feature -= -" -unicode -- -word -- -boundary -" -) -{ -assert -! -( -DFA -: -: -new -( -r -" -\ -b -" -) -. -is_ok -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -\ -B -" -) -. -is_ok -( -) -) -; -} -assert -! -( -DFA -: -: -new -( -r -" -( -? -- -u -) -\ -b -" -) -. -is_ok -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -( -? -- -u -) -\ -B -" -) -. -is_ok -( -) -) -; -} -# -[ -cfg -( -not -( -miri -) -) -] -/ -/ -takes -too -long -on -miri -# -[ -test -] -fn -is_one_pass -( -) -{ -use -crate -: -: -util -: -: -syntax -; -assert -! -( -DFA -: -: -new -( -r -" -a -* -b -" -) -. -is_ok -( -) -) -; -if -cfg -! -( -feature -= -" -unicode -- -perl -" -) -{ -assert -! -( -DFA -: -: -new -( -r -" -\ -w -" -) -. -is_ok -( -) -) -; -} -assert -! -( -DFA -: -: -new -( -r -" -( -? -- -u -) -\ -w -* -\ -s -" -) -. -is_ok -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -( -? -s -: -. -) -* -? -" -) -. -is_ok -( -) -) -; -assert -! -( -DFA -: -: -builder -( -) -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -. -build -( -r -" -( -? -s -- -u -: -. -) -* -? -" -) -. -is_ok -( -) -) -; -} -# -[ -test -] -fn -is_not_one_pass -( -) -{ -assert -! -( -DFA -: -: -new -( -r -" -a -* -a -" -) -. -is_err -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -( -? -s -- -u -: -. -) -* -? -" -) -. -is_err -( -) -) -; -assert -! -( -DFA -: -: -new -( -r -" -( -? -s -: -. -) -* -? -a -" -) -. -is_err -( -) -) -; -} -# -[ -cfg -( -not -( -miri -) -) -] -# -[ -test -] -fn -is_not_one_pass_bigger -( -) -{ -assert -! -( -DFA -: -: -new -( -r -" -\ -w -* -\ -s -" -) -. -is_err -( -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/dfa/regex.rs b/third_party/rust/regex-automata/src/dfa/regex.rs deleted file mode 100644 index 93551525505a1..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/regex.rs +++ /dev/null @@ -1,9072 +0,0 @@ -/ -* -! -A -DFA -- -backed -Regex -. -This -module -provides -[ -Regex -] -which -is -defined -generically -over -the -[ -Automaton -] -trait -. -A -Regex -implements -convenience -routines -you -might -have -come -to -expect -such -as -finding -the -start -/ -end -of -a -match -and -iterating -over -all -non -- -overlapping -matches -. -This -Regex -type -is -limited -in -its -capabilities -to -what -a -DFA -can -provide -. -Therefore -APIs -involving -capturing -groups -for -example -are -not -provided -. -Internally -a -Regex -is -composed -of -two -DFAs -. -One -is -a -" -forward -" -DFA -that -finds -the -end -offset -of -a -match -where -as -the -other -is -a -" -reverse -" -DFA -that -find -the -start -offset -of -a -match -. -See -the -[ -parent -module -] -( -crate -: -: -dfa -) -for -examples -. -* -/ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -use -alloc -: -: -vec -: -: -Vec -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -crate -: -: -dfa -: -: -dense -: -: -BuildError -; -use -crate -: -: -{ -dfa -: -: -{ -automaton -: -: -Automaton -dense -} -util -: -: -{ -iter -search -: -: -Input -} -Anchored -Match -MatchError -} -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -use -crate -: -: -{ -dfa -: -: -{ -sparse -StartKind -} -util -: -: -search -: -: -MatchKind -} -; -/ -/ -When -the -alloc -feature -is -enabled -the -regex -type -sets -its -A -type -parameter -/ -/ -to -default -to -an -owned -dense -DFA -. -But -without -alloc -we -set -no -default -. -This -/ -/ -makes -things -a -lot -more -convenient -in -the -common -case -since -writing -out -the -/ -/ -DFA -types -is -pretty -annoying -. -/ -/ -/ -/ -Since -we -have -two -different -definitions -but -only -want -to -write -one -doc -/ -/ -string -we -use -a -macro -to -capture -the -doc -and -other -attributes -once -and -then -/ -/ -repeat -them -for -each -definition -. -macro_rules -! -define_regex_type -{ -( -( -# -[ -doc -: -meta -] -) -* -) -= -> -{ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -( -# -[ -doc -] -) -* -pub -struct -Regex -< -A -= -dense -: -: -OwnedDFA -> -{ -forward -: -A -reverse -: -A -} -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -( -# -[ -doc -] -) -* -pub -struct -Regex -< -A -> -{ -forward -: -A -reverse -: -A -} -} -; -} -define_regex_type -! -( -/ -/ -/ -A -regular -expression -that -uses -deterministic -finite -automata -for -fast -/ -/ -/ -searching -. -/ -/ -/ -/ -/ -/ -A -regular -expression -is -comprised -of -two -DFAs -a -" -forward -" -DFA -and -a -/ -/ -/ -" -reverse -" -DFA -. -The -forward -DFA -is -responsible -for -detecting -the -end -of -/ -/ -/ -a -match -while -the -reverse -DFA -is -responsible -for -detecting -the -start -/ -/ -/ -of -a -match -. -Thus -in -order -to -find -the -bounds -of -any -given -match -a -/ -/ -/ -forward -search -must -first -be -run -followed -by -a -reverse -search -. -A -match -/ -/ -/ -found -by -the -forward -DFA -guarantees -that -the -reverse -DFA -will -also -find -/ -/ -/ -a -match -. -/ -/ -/ -/ -/ -/ -The -type -of -the -DFA -used -by -a -Regex -corresponds -to -the -A -type -/ -/ -/ -parameter -which -must -satisfy -the -[ -Automaton -] -trait -. -Typically -/ -/ -/ -A -is -either -a -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -or -a -/ -/ -/ -[ -sparse -: -: -DFA -] -( -crate -: -: -dfa -: -: -sparse -: -: -DFA -) -where -dense -DFAs -use -more -/ -/ -/ -memory -but -search -faster -while -sparse -DFAs -use -less -memory -but -search -/ -/ -/ -more -slowly -. -/ -/ -/ -/ -/ -/ -# -Crate -features -/ -/ -/ -/ -/ -/ -Note -that -despite -what -the -documentation -auto -- -generates -the -_only_ -/ -/ -/ -crate -feature -needed -to -use -this -type -is -dfa -- -search -. -You -do -_not_ -/ -/ -/ -need -to -enable -the -alloc -feature -. -/ -/ -/ -/ -/ -/ -By -default -a -regex -' -s -automaton -type -parameter -is -set -to -/ -/ -/ -dense -: -: -DFA -< -Vec -< -u32 -> -> -when -the -alloc -feature -is -enabled -. -For -most -/ -/ -/ -in -- -memory -work -loads -this -is -the -most -convenient -type -that -gives -the -/ -/ -/ -best -search -performance -. -When -the -alloc -feature -is -disabled -no -/ -/ -/ -default -type -is -used -. -/ -/ -/ -/ -/ -/ -# -When -should -I -use -this -? -/ -/ -/ -/ -/ -/ -Generally -speaking -if -you -can -afford -the -overhead -of -building -a -full -/ -/ -/ -DFA -for -your -regex -and -you -don -' -t -need -things -like -capturing -groups -/ -/ -/ -then -this -is -a -good -choice -if -you -' -re -looking -to -optimize -for -matching -/ -/ -/ -speed -. -Note -however -that -its -speed -may -be -worse -than -a -general -purpose -/ -/ -/ -regex -engine -if -you -don -' -t -provide -a -[ -dense -: -: -Config -: -: -prefilter -] -to -the -/ -/ -/ -underlying -DFA -. -/ -/ -/ -/ -/ -/ -# -Sparse -DFAs -/ -/ -/ -/ -/ -/ -Since -a -Regex -is -generic -over -the -[ -Automaton -] -trait -it -can -be -/ -/ -/ -used -with -any -kind -of -DFA -. -While -this -crate -constructs -dense -DFAs -by -/ -/ -/ -default -it -is -easy -enough -to -build -corresponding -sparse -DFAs -and -then -/ -/ -/ -build -a -regex -from -them -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -/ -/ -First -build -a -regex -that -uses -dense -DFAs -. -/ -/ -/ -let -dense_re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Second -build -sparse -DFAs -from -the -forward -and -reverse -dense -DFAs -. -/ -/ -/ -let -fwd -= -dense_re -. -forward -( -) -. -to_sparse -( -) -? -; -/ -/ -/ -let -rev -= -dense_re -. -reverse -( -) -. -to_sparse -( -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Third -build -a -new -regex -from -the -constituent -sparse -DFAs -. -/ -/ -/ -let -sparse_re -= -Regex -: -: -builder -( -) -. -build_from_dfas -( -fwd -rev -) -; -/ -/ -/ -/ -/ -/ -/ -/ -A -regex -that -uses -sparse -DFAs -can -be -used -just -like -with -dense -DFAs -. -/ -/ -/ -assert_eq -! -( -true -sparse_re -. -is_match -( -b -" -foo123 -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Alternatively -one -can -use -a -[ -Builder -] -to -construct -a -sparse -DFA -/ -/ -/ -more -succinctly -. -( -Note -though -that -dense -DFAs -are -still -constructed -/ -/ -/ -first -internally -and -then -converted -to -sparse -DFAs -as -in -the -example -/ -/ -/ -above -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -sparse_re -= -Regex -: -: -builder -( -) -. -build_sparse -( -r -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -A -regex -that -uses -sparse -DFAs -can -be -used -just -like -with -dense -DFAs -. -/ -/ -/ -assert -! -( -sparse_re -. -is_match -( -b -" -foo123 -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Fallibility -/ -/ -/ -/ -/ -/ -Most -of -the -search -routines -defined -on -this -type -will -_panic_ -when -the -/ -/ -/ -underlying -search -fails -. -This -might -be -because -the -DFA -gave -up -because -/ -/ -/ -it -saw -a -quit -byte -whether -configured -explicitly -or -via -heuristic -/ -/ -/ -Unicode -word -boundary -support -although -neither -are -enabled -by -default -. -/ -/ -/ -Or -it -might -fail -because -an -invalid -Input -configuration -is -given -/ -/ -/ -for -example -with -an -unsupported -[ -Anchored -] -mode -. -/ -/ -/ -/ -/ -/ -If -you -need -to -handle -these -error -cases -instead -of -allowing -them -to -/ -/ -/ -trigger -a -panic -then -the -lower -level -[ -Regex -: -: -try_search -] -provides -/ -/ -/ -a -fallible -API -that -never -panics -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -cause -a -search -to -terminate -if -it -sees -a -/ -/ -/ -\ -n -byte -and -handle -the -error -returned -. -This -could -be -useful -if -for -/ -/ -/ -example -you -wanted -to -prevent -a -user -supplied -pattern -from -matching -/ -/ -/ -across -a -line -boundary -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -self -regex -: -: -Regex -} -Input -MatchError -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -dense -( -dfa -: -: -dense -: -: -Config -: -: -new -( -) -. -quit -( -b -' -\ -n -' -true -) -) -/ -/ -/ -. -build -( -r -" -foo -\ -p -{ -any -} -+ -bar -" -) -? -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo -\ -nbar -" -) -; -/ -/ -/ -/ -/ -Normally -this -would -produce -a -match -since -\ -p -{ -any -} -contains -' -\ -n -' -. -/ -/ -/ -/ -/ -But -since -we -instructed -the -automaton -to -enter -a -quit -state -if -a -/ -/ -/ -/ -/ -' -\ -n -' -is -observed -this -produces -a -match -error -instead -. -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -b -' -\ -n -' -3 -) -; -/ -/ -/ -let -got -= -re -. -try_search -( -& -input -) -. -unwrap_err -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -) -; -# -[ -cfg -( -all -( -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -impl -Regex -{ -/ -/ -/ -Parse -the -given -regular -expression -using -the -default -configuration -and -/ -/ -/ -return -the -corresponding -regex -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -[ -Builder -] -to -/ -/ -/ -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -3 -. -. -14 -) -) -/ -/ -/ -re -. -find -( -b -" -zzzfoo12345barzzz -" -) -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -Regex -BuildError -> -{ -Builder -: -: -new -( -) -. -build -( -pattern -) -} -/ -/ -/ -Like -new -but -parses -multiple -patterns -into -a -single -" -regex -set -. -" -/ -/ -/ -This -similarly -uses -the -default -regex -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -re -. -find_iter -( -b -" -abc -1 -foo -4567 -0 -quux -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -4 -. -. -5 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -6 -. -. -9 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -10 -. -. -14 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -15 -. -. -16 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -17 -. -. -21 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -Regex -BuildError -> -{ -Builder -: -: -new -( -) -. -build_many -( -patterns -) -} -} -# -[ -cfg -( -all -( -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -impl -Regex -< -sparse -: -: -DFA -< -Vec -< -u8 -> -> -> -{ -/ -/ -/ -Parse -the -given -regular -expression -using -the -default -configuration -/ -/ -/ -except -using -sparse -DFAs -and -return -the -corresponding -regex -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -[ -Builder -] -to -/ -/ -/ -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_sparse -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -3 -. -. -14 -) -) -/ -/ -/ -re -. -find -( -b -" -zzzfoo12345barzzz -" -) -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new_sparse -( -pattern -: -& -str -) -- -> -Result -< -Regex -< -sparse -: -: -DFA -< -Vec -< -u8 -> -> -> -BuildError -> -{ -Builder -: -: -new -( -) -. -build_sparse -( -pattern -) -} -/ -/ -/ -Like -new -but -parses -multiple -patterns -into -a -single -" -regex -set -" -/ -/ -/ -using -sparse -DFAs -. -This -otherwise -similarly -uses -the -default -regex -/ -/ -/ -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many_sparse -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -re -. -find_iter -( -b -" -abc -1 -foo -4567 -0 -quux -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -4 -. -. -5 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -6 -. -. -9 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -10 -. -. -14 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -15 -. -. -16 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -17 -. -. -21 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new_many_sparse -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -Regex -< -sparse -: -: -DFA -< -Vec -< -u8 -> -> -> -BuildError -> -{ -Builder -: -: -new -( -) -. -build_many_sparse -( -patterns -) -} -} -/ -/ -/ -Convenience -routines -for -regex -construction -. -impl -Regex -< -dense -: -: -DFA -< -& -' -static -[ -u32 -] -> -> -{ -/ -/ -/ -Return -a -builder -for -configuring -the -construction -of -a -Regex -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Builder -] -type -in -common -cases -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -the -builder -to -disable -UTF -- -8 -mode -/ -/ -/ -everywhere -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -regex -: -: -Regex -nfa -: -: -thompson -util -: -: -syntax -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -1 -. -. -9 -) -) -; -/ -/ -/ -let -got -= -re -. -find -( -haystack -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -} -/ -/ -/ -Standard -search -routines -for -finding -and -iterating -over -matches -. -impl -< -A -: -Automaton -> -Regex -< -A -> -{ -/ -/ -/ -Returns -true -if -and -only -if -this -regex -matches -the -given -haystack -. -/ -/ -/ -/ -/ -/ -This -routine -may -short -circuit -if -it -knows -that -scanning -future -input -/ -/ -/ -will -never -lead -to -a -different -result -. -In -particular -if -the -underlying -/ -/ -/ -DFA -enters -a -match -state -or -a -dead -state -then -this -routine -will -return -/ -/ -/ -true -or -false -respectively -without -inspecting -any -future -input -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -panics -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -DFA -quitting -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -panics -callers -cannot -know -whether -a -match -exists -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -Use -[ -Regex -: -: -try_search -] -if -you -want -to -handle -these -error -conditions -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -assert_eq -! -( -true -re -. -is_match -( -" -foo12345bar -" -) -) -; -/ -/ -/ -assert_eq -! -( -false -re -. -is_match -( -" -foobar -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -input -: -I -) -- -> -bool -{ -/ -/ -Not -only -can -we -do -an -" -earliest -" -search -but -we -can -avoid -doing -a -/ -/ -reverse -scan -too -. -let -input -= -input -. -into -( -) -. -earliest -( -true -) -; -self -. -forward -( -) -. -try_search_fwd -( -& -input -) -. -map -( -| -x -| -x -. -is_some -( -) -) -. -unwrap -( -) -} -/ -/ -/ -Returns -the -start -and -end -offset -of -the -leftmost -match -. -If -no -match -/ -/ -/ -exists -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -panics -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -DFA -quitting -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -panics -callers -cannot -know -whether -a -match -exists -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -Use -[ -Regex -: -: -try_search -] -if -you -want -to -handle -these -error -conditions -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Greediness -is -applied -appropriately -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -3 -. -. -11 -) -) -re -. -find -( -" -zzzfoo12345zzz -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -a -match -is -found -after -reading -the -first -byte -( -a -) -/ -/ -/ -/ -/ -the -default -leftmost -- -first -match -semantics -demand -that -we -find -the -/ -/ -/ -/ -/ -earliest -match -that -prefers -earlier -parts -of -the -pattern -over -latter -/ -/ -/ -/ -/ -parts -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -abc -| -a -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -re -. -find -( -" -abc -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -input -: -I -) -- -> -Option -< -Match -> -{ -self -. -try_search -( -& -input -. -into -( -) -) -. -unwrap -( -) -} -/ -/ -/ -Returns -an -iterator -over -all -non -- -overlapping -leftmost -matches -in -the -/ -/ -/ -given -bytes -. -If -no -match -exists -then -the -iterator -yields -no -elements -. -/ -/ -/ -/ -/ -/ -This -corresponds -to -the -" -standard -" -regex -search -iterator -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -search -returns -an -error -during -iteration -then -iteration -/ -/ -/ -panics -. -See -[ -Regex -: -: -find -] -for -the -panic -conditions -. -/ -/ -/ -/ -/ -/ -Use -[ -Regex -: -: -try_search -] -with -/ -/ -/ -[ -util -: -: -iter -: -: -Searcher -] -( -crate -: -: -util -: -: -iter -: -: -Searcher -) -if -you -want -to -/ -/ -/ -handle -these -error -conditions -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Match -dfa -: -: -regex -: -: -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -text -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -text -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -4 -) -/ -/ -/ -Match -: -: -must -( -0 -5 -. -. -10 -) -/ -/ -/ -Match -: -: -must -( -0 -11 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find_iter -< -' -r -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -input -: -I -) -- -> -FindMatches -< -' -r -' -h -A -> -{ -let -it -= -iter -: -: -Searcher -: -: -new -( -input -. -into -( -) -) -; -FindMatches -{ -re -: -self -it -} -} -} -/ -/ -/ -Lower -level -fallible -search -routines -that -permit -controlling -where -the -/ -/ -/ -search -starts -and -ends -in -a -particular -sequence -. -impl -< -A -: -Automaton -> -Regex -< -A -> -{ -/ -/ -/ -Returns -the -start -and -end -offset -of -the -leftmost -match -. -If -no -match -/ -/ -/ -exists -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Regex -: -: -find -] -but -with -two -differences -: -/ -/ -/ -/ -/ -/ -1 -. -It -is -not -generic -over -Into -< -Input -> -and -instead -accepts -a -/ -/ -/ -& -Input -. -This -permits -reusing -the -same -Input -for -multiple -searches -/ -/ -/ -without -needing -to -create -a -new -one -. -This -_may_ -help -with -latency -. -/ -/ -/ -2 -. -It -returns -an -error -if -the -search -could -not -complete -where -as -/ -/ -/ -[ -Regex -: -: -find -] -will -panic -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -the -following -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -DFA -quitting -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -# -[ -inline -] -pub -fn -try_search -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -let -( -fwd -rev -) -= -( -self -. -forward -( -) -self -. -reverse -( -) -) -; -let -end -= -match -fwd -. -try_search_fwd -( -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -end -) -= -> -end -} -; -/ -/ -This -special -cases -an -empty -match -at -the -beginning -of -the -search -. -If -/ -/ -our -end -matches -our -start -then -since -a -reverse -DFA -can -' -t -match -past -/ -/ -the -start -it -must -follow -that -our -starting -position -is -also -our -end -/ -/ -position -. -So -short -circuit -and -skip -the -reverse -search -. -if -input -. -start -( -) -= -= -end -. -offset -( -) -{ -return -Ok -( -Some -( -Match -: -: -new -( -end -. -pattern -( -) -end -. -offset -( -) -. -. -end -. -offset -( -) -) -) -) -; -} -/ -/ -We -can -also -skip -the -reverse -search -if -we -know -our -search -was -/ -/ -anchored -. -This -occurs -either -when -the -input -config -is -anchored -or -/ -/ -when -we -know -the -regex -itself -is -anchored -. -In -this -case -we -know -the -/ -/ -start -of -the -match -if -one -is -found -must -be -the -start -of -the -/ -/ -search -. -if -self -. -is_anchored -( -input -) -{ -return -Ok -( -Some -( -Match -: -: -new -( -end -. -pattern -( -) -input -. -start -( -) -. -. -end -. -offset -( -) -) -) -) -; -} -/ -/ -N -. -B -. -I -have -tentatively -convinced -myself -that -it -isn -' -t -necessary -/ -/ -to -specify -the -specific -pattern -for -the -reverse -search -since -the -/ -/ -reverse -search -will -always -find -the -same -pattern -to -match -as -the -/ -/ -forward -search -. -But -I -lack -a -rigorous -proof -. -Why -not -just -provide -/ -/ -the -pattern -anyway -? -Well -if -it -is -needed -then -leaving -it -out -/ -/ -gives -us -a -chance -to -find -a -witness -. -( -Also -if -we -don -' -t -need -to -/ -/ -specify -the -pattern -then -we -don -' -t -need -to -build -the -reverse -DFA -/ -/ -with -' -starts_for_each_pattern -' -enabled -. -) -/ -/ -/ -/ -We -also -need -to -be -careful -to -disable -' -earliest -' -for -the -reverse -/ -/ -search -since -it -could -be -enabled -for -the -forward -search -. -In -the -/ -/ -reverse -case -to -satisfy -" -leftmost -" -criteria -we -need -to -match -/ -/ -as -much -as -we -can -. -We -also -need -to -be -careful -to -make -the -search -/ -/ -anchored -. -We -don -' -t -want -the -reverse -search -to -report -any -matches -/ -/ -other -than -the -one -beginning -at -the -end -of -our -forward -search -. -let -revsearch -= -input -. -clone -( -) -. -span -( -input -. -start -( -) -. -. -end -. -offset -( -) -) -. -anchored -( -Anchored -: -: -Yes -) -. -earliest -( -false -) -; -let -start -= -rev -. -try_search_rev -( -& -revsearch -) -? -. -expect -( -" -reverse -search -must -match -if -forward -search -does -" -) -; -assert_eq -! -( -start -. -pattern -( -) -end -. -pattern -( -) -" -forward -and -reverse -search -must -match -same -pattern -" -) -; -assert -! -( -start -. -offset -( -) -< -= -end -. -offset -( -) -) -; -Ok -( -Some -( -Match -: -: -new -( -end -. -pattern -( -) -start -. -offset -( -) -. -. -end -. -offset -( -) -) -) -) -} -/ -/ -/ -Returns -true -if -either -the -given -input -specifies -an -anchored -search -/ -/ -/ -or -if -the -underlying -DFA -is -always -anchored -. -fn -is_anchored -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -match -input -. -get_anchored -( -) -{ -Anchored -: -: -No -= -> -self -. -forward -( -) -. -is_always_start_anchored -( -) -Anchored -: -: -Yes -| -Anchored -: -: -Pattern -( -_ -) -= -> -true -} -} -} -/ -/ -/ -Non -- -search -APIs -for -querying -information -about -the -regex -and -setting -a -/ -/ -/ -prefilter -. -impl -< -A -: -Automaton -> -Regex -< -A -> -{ -/ -/ -/ -Return -the -underlying -DFA -responsible -for -forward -matching -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -accessing -the -underlying -DFA -and -converting -it -to -/ -/ -/ -some -other -format -or -size -. -See -the -[ -Builder -: -: -build_from_dfas -] -docs -/ -/ -/ -for -an -example -of -where -this -might -be -useful -. -pub -fn -forward -( -& -self -) -- -> -& -A -{ -& -self -. -forward -} -/ -/ -/ -Return -the -underlying -DFA -responsible -for -reverse -matching -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -accessing -the -underlying -DFA -and -converting -it -to -/ -/ -/ -some -other -format -or -size -. -See -the -[ -Builder -: -: -build_from_dfas -] -docs -/ -/ -/ -for -an -example -of -where -this -might -be -useful -. -pub -fn -reverse -( -& -self -) -- -> -& -A -{ -& -self -. -reverse -} -/ -/ -/ -Returns -the -total -number -of -patterns -matched -by -this -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -r -" -[ -a -- -z -] -+ -" -r -" -[ -0 -- -9 -] -+ -" -r -" -\ -w -+ -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -3 -re -. -pattern_len -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -assert_eq -! -( -self -. -forward -( -) -. -pattern_len -( -) -self -. -reverse -( -) -. -pattern_len -( -) -) -; -self -. -forward -( -) -. -pattern_len -( -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -for -an -infallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -Match -] -value -until -no -more -matches -could -be -found -. -/ -/ -/ -If -the -underlying -regex -engine -returns -an -error -then -a -panic -occurs -. -/ -/ -/ -/ -/ -/ -The -type -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -A -represents -the -type -of -the -underlying -DFA -that -implements -the -/ -/ -/ -[ -Automaton -] -trait -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -regex -object -itself -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -Regex -: -: -find_iter -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -FindMatches -< -' -r -' -h -A -> -{ -re -: -& -' -r -Regex -< -A -> -it -: -iter -: -: -Searcher -< -' -h -> -} -impl -< -' -r -' -h -A -: -Automaton -> -Iterator -for -FindMatches -< -' -r -' -h -A -> -{ -type -Item -= -Match -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -let -FindMatches -{ -re -ref -mut -it -} -= -* -self -; -it -. -advance -( -| -input -| -re -. -try_search -( -input -) -) -} -} -/ -/ -/ -A -builder -for -a -regex -based -on -deterministic -finite -automatons -. -/ -/ -/ -/ -/ -/ -This -builder -permits -configuring -options -for -the -syntax -of -a -pattern -the -/ -/ -/ -NFA -construction -the -DFA -construction -and -finally -the -regex -searching -/ -/ -/ -itself -. -This -builder -is -different -from -a -general -purpose -regex -builder -in -/ -/ -/ -that -it -permits -fine -grain -configuration -of -the -construction -process -. -The -/ -/ -/ -trade -off -for -this -is -complexity -and -the -possibility -of -setting -a -/ -/ -/ -configuration -that -might -not -make -sense -. -For -example -there -are -two -/ -/ -/ -different -UTF -- -8 -modes -: -/ -/ -/ -/ -/ -/ -* -[ -syntax -: -: -Config -: -: -utf8 -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -utf8 -) -controls -/ -/ -/ -whether -the -pattern -itself -can -contain -sub -- -expressions -that -match -invalid -/ -/ -/ -UTF -- -8 -. -/ -/ -/ -* -[ -thompson -: -: -Config -: -: -utf8 -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -: -: -utf8 -) -controls -/ -/ -/ -how -the -regex -iterators -themselves -advance -the -starting -position -of -the -/ -/ -/ -next -search -when -a -match -with -zero -length -is -found -. -/ -/ -/ -/ -/ -/ -Generally -speaking -callers -will -want -to -either -enable -all -of -these -or -/ -/ -/ -disable -all -of -these -. -/ -/ -/ -/ -/ -/ -Internally -building -a -regex -requires -building -two -DFAs -where -one -is -/ -/ -/ -responsible -for -finding -the -end -of -a -match -and -the -other -is -responsible -/ -/ -/ -for -finding -the -start -of -a -match -. -If -you -only -need -to -detect -whether -/ -/ -/ -something -matched -or -only -the -end -of -a -match -then -you -should -use -a -/ -/ -/ -[ -dense -: -: -Builder -] -to -construct -a -single -DFA -which -is -cheaper -than -/ -/ -/ -building -two -DFAs -. -/ -/ -/ -/ -/ -/ -# -Build -methods -/ -/ -/ -/ -/ -/ -This -builder -has -a -few -" -build -" -methods -. -In -general -it -' -s -the -result -of -/ -/ -/ -combining -the -following -parameters -: -/ -/ -/ -/ -/ -/ -* -Building -one -or -many -regexes -. -/ -/ -/ -* -Building -a -regex -with -dense -or -sparse -DFAs -. -/ -/ -/ -/ -/ -/ -The -simplest -" -build -" -method -is -[ -Builder -: -: -build -] -. -It -accepts -a -single -/ -/ -/ -pattern -and -builds -a -dense -DFA -using -usize -for -the -state -identifier -/ -/ -/ -representation -. -/ -/ -/ -/ -/ -/ -The -most -general -" -build -" -method -is -[ -Builder -: -: -build_many -] -which -permits -/ -/ -/ -building -a -regex -that -searches -for -multiple -patterns -simultaneously -while -/ -/ -/ -using -a -specific -state -identifier -representation -. -/ -/ -/ -/ -/ -/ -The -most -flexible -" -build -" -method -but -hardest -to -use -is -/ -/ -/ -[ -Builder -: -: -build_from_dfas -] -. -This -exposes -the -fact -that -a -[ -Regex -] -is -/ -/ -/ -just -a -pair -of -DFAs -and -this -method -allows -you -to -specify -those -DFAs -/ -/ -/ -exactly -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -disable -UTF -- -8 -mode -in -the -syntax -and -the -regex -/ -/ -/ -itself -. -This -is -generally -what -you -want -for -matching -on -arbitrary -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -regex -: -: -Regex -nfa -: -: -thompson -util -: -: -syntax -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -1 -. -. -9 -) -) -; -/ -/ -/ -let -got -= -re -. -find -( -haystack -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -Notice -that -( -? -- -u -: -[ -^ -b -] -) -matches -invalid -UTF -- -8 -/ -/ -/ -/ -/ -but -the -subsequent -. -* -does -not -! -Disabling -UTF -- -8 -/ -/ -/ -/ -/ -on -the -syntax -permits -this -. -/ -/ -/ -assert_eq -! -( -b -" -foo -\ -xFFarzz -" -& -haystack -[ -got -. -unwrap -( -) -. -range -( -) -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Builder -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -dfa -: -dense -: -: -Builder -} -impl -Builder -{ -/ -/ -/ -Create -a -new -regex -builder -with -the -default -configuration -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -dfa -: -dense -: -: -Builder -: -: -new -( -) -} -} -/ -/ -/ -Build -a -regex -from -the -given -pattern -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -or -compiling -the -pattern -then -an -error -/ -/ -/ -is -returned -. -# -[ -cfg -( -all -( -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -Regex -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Build -a -regex -from -the -given -pattern -using -sparse -DFAs -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -or -compiling -the -pattern -then -an -error -/ -/ -/ -is -returned -. -# -[ -cfg -( -all -( -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -pub -fn -build_sparse -( -& -self -pattern -: -& -str -) -- -> -Result -< -Regex -< -sparse -: -: -DFA -< -Vec -< -u8 -> -> -> -BuildError -> -{ -self -. -build_many_sparse -( -& -[ -pattern -] -) -} -/ -/ -/ -Build -a -regex -from -the -given -patterns -. -# -[ -cfg -( -all -( -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -Regex -BuildError -> -{ -let -forward -= -self -. -dfa -. -build_many -( -patterns -) -? -; -let -reverse -= -self -. -dfa -. -clone -( -) -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -prefilter -( -None -) -. -specialize_start_states -( -false -) -. -start_kind -( -StartKind -: -: -Anchored -) -. -match_kind -( -MatchKind -: -: -All -) -) -. -thompson -( -crate -: -: -nfa -: -: -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -. -build_many -( -patterns -) -? -; -Ok -( -self -. -build_from_dfas -( -forward -reverse -) -) -} -/ -/ -/ -Build -a -sparse -regex -from -the -given -patterns -. -# -[ -cfg -( -all -( -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -pub -fn -build_many_sparse -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -Regex -< -sparse -: -: -DFA -< -Vec -< -u8 -> -> -> -BuildError -> -{ -let -re -= -self -. -build_many -( -patterns -) -? -; -let -forward -= -re -. -forward -( -) -. -to_sparse -( -) -? -; -let -reverse -= -re -. -reverse -( -) -. -to_sparse -( -) -? -; -Ok -( -self -. -build_from_dfas -( -forward -reverse -) -) -} -/ -/ -/ -Build -a -regex -from -its -component -forward -and -reverse -DFAs -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -deserializing -a -regex -from -some -arbitrary -/ -/ -/ -memory -region -. -This -is -also -useful -for -building -regexes -from -other -/ -/ -/ -types -of -DFAs -. -/ -/ -/ -/ -/ -/ -If -you -' -re -building -the -DFAs -from -scratch -instead -of -building -new -DFAs -/ -/ -/ -from -other -DFAs -then -you -' -ll -need -to -make -sure -that -the -reverse -DFA -is -/ -/ -/ -configured -correctly -to -match -the -intended -semantics -. -Namely -: -/ -/ -/ -/ -/ -/ -* -It -should -be -anchored -. -/ -/ -/ -* -It -should -use -[ -MatchKind -: -: -All -] -semantics -. -/ -/ -/ -* -It -should -match -in -reverse -. -/ -/ -/ -* -Otherwise -its -configuration -should -match -the -forward -DFA -. -/ -/ -/ -/ -/ -/ -If -these -conditions -aren -' -t -satisfied -then -the -behavior -of -searches -is -/ -/ -/ -unspecified -. -/ -/ -/ -/ -/ -/ -Note -that -when -using -this -constructor -no -configuration -is -applied -. -/ -/ -/ -Since -this -routine -provides -the -DFAs -to -the -builder -there -is -no -/ -/ -/ -opportunity -to -apply -other -configuration -options -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -is -a -bit -a -contrived -. -The -usual -use -of -these -methods -/ -/ -/ -would -involve -serializing -initial_re -somewhere -and -then -deserializing -/ -/ -/ -it -later -to -build -a -regex -. -But -in -this -case -we -do -everything -in -/ -/ -/ -memory -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -initial_re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -assert_eq -! -( -true -initial_re -. -is_match -( -b -" -foo123 -" -) -) -; -/ -/ -/ -/ -/ -/ -let -( -fwd -rev -) -= -( -initial_re -. -forward -( -) -initial_re -. -reverse -( -) -) -; -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -. -build_from_dfas -( -fwd -rev -) -; -/ -/ -/ -assert_eq -! -( -true -re -. -is_match -( -b -" -foo123 -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -Regex -that -uses -sparse -DFAs -instead -/ -/ -/ -of -dense -DFAs -without -using -one -of -the -convenience -build_sparse -/ -/ -/ -routines -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -initial_re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -assert_eq -! -( -true -initial_re -. -is_match -( -b -" -foo123 -" -) -) -; -/ -/ -/ -/ -/ -/ -let -fwd -= -initial_re -. -forward -( -) -. -to_sparse -( -) -? -; -/ -/ -/ -let -rev -= -initial_re -. -reverse -( -) -. -to_sparse -( -) -? -; -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -. -build_from_dfas -( -fwd -rev -) -; -/ -/ -/ -assert_eq -! -( -true -re -. -is_match -( -b -" -foo123 -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_from_dfas -< -A -: -Automaton -> -( -& -self -forward -: -A -reverse -: -A -) -- -> -Regex -< -A -> -{ -Regex -{ -forward -reverse -} -} -/ -/ -/ -Set -the -syntax -configuration -for -this -builder -using -/ -/ -/ -[ -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -case -insensitivity -Unicode -and -multi -/ -/ -/ -line -mode -. -# -[ -cfg -( -all -( -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -dfa -. -syntax -( -config -) -; -self -} -/ -/ -/ -Set -the -Thompson -NFA -configuration -for -this -builder -using -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -whether -additional -time -should -be -/ -/ -/ -spent -shrinking -the -size -of -the -NFA -. -# -[ -cfg -( -all -( -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -pub -fn -thompson -( -& -mut -self -config -: -crate -: -: -nfa -: -: -thompson -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -dfa -. -thompson -( -config -) -; -self -} -/ -/ -/ -Set -the -dense -DFA -compilation -configuration -for -this -builder -using -/ -/ -/ -[ -dense -: -: -Config -] -( -dense -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -whether -the -underlying -DFAs -should -/ -/ -/ -be -minimized -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -dense -( -& -mut -self -config -: -dense -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -dfa -. -configure -( -config -) -; -self -} -} -impl -Default -for -Builder -{ -fn -default -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -} diff --git a/third_party/rust/regex-automata/src/dfa/remapper.rs b/third_party/rust/regex-automata/src/dfa/remapper.rs deleted file mode 100644 index 23b419f531a8c..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/remapper.rs +++ /dev/null @@ -1,2311 +0,0 @@ -use -alloc -: -: -vec -: -: -Vec -; -use -crate -: -: -util -: -: -primitives -: -: -StateID -; -/ -/ -/ -Remappable -is -a -tightly -coupled -abstraction -that -facilitates -remapping -/ -/ -/ -state -identifiers -in -DFAs -. -/ -/ -/ -/ -/ -/ -The -main -idea -behind -remapping -state -IDs -is -that -DFAs -often -need -to -check -/ -/ -/ -if -a -certain -state -is -a -" -special -" -state -of -some -kind -( -like -a -match -state -) -/ -/ -/ -during -a -search -. -Since -this -is -extremely -perf -critical -code -we -want -this -/ -/ -/ -check -to -be -as -fast -as -possible -. -Partitioning -state -IDs -into -for -example -/ -/ -/ -into -" -non -- -match -" -and -" -match -" -states -means -one -can -tell -if -a -state -is -a -/ -/ -/ -match -state -via -a -simple -comparison -of -the -state -ID -. -/ -/ -/ -/ -/ -/ -The -issue -is -that -during -the -DFA -construction -process -it -' -s -not -/ -/ -/ -particularly -easy -to -partition -the -states -. -Instead -the -simplest -thing -is -/ -/ -/ -to -often -just -do -a -pass -over -all -of -the -states -and -shuffle -them -into -their -/ -/ -/ -desired -partitionings -. -To -do -that -we -need -a -mechanism -for -swapping -states -. -/ -/ -/ -Hence -this -abstraction -. -/ -/ -/ -/ -/ -/ -Normally -for -such -little -code -I -would -just -duplicate -it -. -But -this -is -a -/ -/ -/ -key -optimization -and -the -implementation -is -a -bit -subtle -. -So -the -abstraction -/ -/ -/ -is -basically -a -ham -- -fisted -attempt -at -DRY -. -The -only -place -we -use -this -is -in -/ -/ -/ -the -dense -and -one -- -pass -DFAs -. -/ -/ -/ -/ -/ -/ -See -also -src -/ -dfa -/ -special -. -rs -for -a -more -detailed -explanation -of -how -dense -/ -/ -/ -DFAs -are -partitioned -. -pub -( -super -) -trait -Remappable -: -core -: -: -fmt -: -: -Debug -{ -/ -/ -/ -Return -the -total -number -of -states -. -fn -state_len -( -& -self -) -- -> -usize -; -/ -/ -/ -Return -the -power -- -of -- -2 -exponent -that -yields -the -stride -. -The -pertinent -/ -/ -/ -laws -here -are -where -N -= -stride2 -: -2 -^ -N -= -stride -and -len -( -alphabet -) -< -= -stride -. -fn -stride2 -( -& -self -) -- -> -usize -; -/ -/ -/ -Swap -the -states -pointed -to -by -the -given -IDs -. -The -underlying -finite -/ -/ -/ -state -machine -should -be -mutated -such -that -all -of -the -transitions -in -/ -/ -/ -id1 -are -now -in -the -memory -region -where -the -transitions -for -id2 -/ -/ -/ -were -and -all -of -the -transitions -in -id2 -are -now -in -the -memory -region -/ -/ -/ -where -the -transitions -for -id1 -were -. -/ -/ -/ -/ -/ -/ -Essentially -this -" -moves -" -id1 -to -id2 -and -id2 -to -id1 -. -/ -/ -/ -/ -/ -/ -It -is -expected -that -after -calling -this -the -underlying -value -will -be -/ -/ -/ -left -in -an -inconsistent -state -since -any -other -transitions -pointing -to -/ -/ -/ -e -. -g -. -id1 -need -to -be -updated -to -point -to -id2 -since -that -' -s -where -/ -/ -/ -id1 -moved -to -. -/ -/ -/ -/ -/ -/ -In -order -to -" -fix -" -the -underlying -inconsistent -state -a -Remapper -/ -/ -/ -should -be -used -to -guarantee -that -remap -is -called -at -the -appropriate -/ -/ -/ -time -. -fn -swap_states -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -; -/ -/ -/ -This -must -remap -every -single -state -ID -in -the -underlying -value -according -/ -/ -/ -to -the -function -given -. -For -example -in -a -DFA -this -should -remap -every -/ -/ -/ -transition -and -every -starting -state -ID -. -fn -remap -( -& -mut -self -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -; -} -/ -/ -/ -Remapper -is -an -abstraction -the -manages -the -remapping -of -state -IDs -in -a -/ -/ -/ -finite -state -machine -. -This -is -useful -when -one -wants -to -shuffle -states -into -/ -/ -/ -different -positions -in -the -machine -. -/ -/ -/ -/ -/ -/ -One -of -the -key -complexities -this -manages -is -the -ability -to -correctly -move -/ -/ -/ -one -state -multiple -times -. -/ -/ -/ -/ -/ -/ -Once -shuffling -is -complete -remap -must -be -called -which -will -rewrite -/ -/ -/ -all -pertinent -transitions -to -updated -state -IDs -. -Neglecting -to -call -remap -/ -/ -/ -will -almost -certainly -result -in -a -corrupt -machine -. -# -[ -derive -( -Debug -) -] -pub -( -super -) -struct -Remapper -{ -/ -/ -/ -A -map -from -the -index -of -a -state -to -its -pre -- -multiplied -identifier -. -/ -/ -/ -/ -/ -/ -When -a -state -is -swapped -with -another -then -their -corresponding -/ -/ -/ -locations -in -this -map -are -also -swapped -. -Thus -its -new -position -will -/ -/ -/ -still -point -to -its -old -pre -- -multiplied -StateID -. -/ -/ -/ -/ -/ -/ -While -there -is -a -bit -more -to -it -this -then -allows -us -to -rewrite -the -/ -/ -/ -state -IDs -in -a -DFA -' -s -transition -table -in -a -single -pass -. -This -is -done -/ -/ -/ -by -iterating -over -every -ID -in -this -map -then -iterating -over -each -/ -/ -/ -transition -for -the -state -at -that -ID -and -re -- -mapping -the -transition -from -/ -/ -/ -old_id -to -map -[ -dfa -. -to_index -( -old_id -) -] -. -That -is -we -find -the -position -/ -/ -/ -in -this -map -where -old_id -* -started -* -and -set -it -to -where -it -ended -up -/ -/ -/ -after -all -swaps -have -been -completed -. -map -: -Vec -< -StateID -> -/ -/ -/ -A -mapper -from -state -index -to -state -ID -( -and -back -) -. -idxmap -: -IndexMapper -} -impl -Remapper -{ -/ -/ -/ -Create -a -new -remapper -from -the -given -remappable -implementation -. -The -/ -/ -/ -remapper -can -then -be -used -to -swap -states -. -The -remappable -value -given -/ -/ -/ -here -must -the -same -one -given -to -swap -and -remap -. -pub -( -super -) -fn -new -( -r -: -& -impl -Remappable -) -- -> -Remapper -{ -let -idxmap -= -IndexMapper -{ -stride2 -: -r -. -stride2 -( -) -} -; -let -map -= -( -0 -. -. -r -. -state_len -( -) -) -. -map -( -| -i -| -idxmap -. -to_state_id -( -i -) -) -. -collect -( -) -; -Remapper -{ -map -idxmap -} -} -/ -/ -/ -Swap -two -states -. -Once -this -is -called -callers -must -follow -through -to -/ -/ -/ -call -remap -or -else -it -' -s -possible -for -the -underlying -remappable -/ -/ -/ -value -to -be -in -a -corrupt -state -. -pub -( -super -) -fn -swap -( -& -mut -self -r -: -& -mut -impl -Remappable -id1 -: -StateID -id2 -: -StateID -) -{ -if -id1 -= -= -id2 -{ -return -; -} -r -. -swap_states -( -id1 -id2 -) -; -self -. -map -. -swap -( -self -. -idxmap -. -to_index -( -id1 -) -self -. -idxmap -. -to_index -( -id2 -) -) -; -} -/ -/ -/ -Complete -the -remapping -process -by -rewriting -all -state -IDs -in -the -/ -/ -/ -remappable -value -according -to -the -swaps -performed -. -pub -( -super -) -fn -remap -( -mut -self -r -: -& -mut -impl -Remappable -) -{ -/ -/ -Update -the -map -to -account -for -states -that -have -been -swapped -/ -/ -multiple -times -. -For -example -if -( -A -C -) -and -( -C -G -) -are -swapped -then -/ -/ -transitions -previously -pointing -to -A -should -now -point -to -G -. -But -if -/ -/ -we -don -' -t -update -our -map -they -will -erroneously -be -set -to -C -. -All -we -/ -/ -do -is -follow -the -swaps -in -our -map -until -we -see -our -original -state -/ -/ -ID -. -/ -/ -/ -/ -The -intuition -here -is -to -think -about -how -changes -are -made -to -the -/ -/ -map -: -only -through -pairwise -swaps -. -That -means -that -starting -at -any -/ -/ -given -state -it -is -always -possible -to -find -the -loop -back -to -that -/ -/ -state -by -following -the -swaps -represented -in -the -map -( -which -might -be -/ -/ -0 -swaps -) -. -/ -/ -/ -/ -We -are -also -careful -to -clone -the -map -before -starting -in -order -to -/ -/ -freeze -it -. -We -use -the -frozen -map -to -find -our -loops -since -we -need -to -/ -/ -update -our -map -as -well -. -Without -freezing -it -our -updates -could -break -/ -/ -the -loops -referenced -above -and -produce -incorrect -results -. -let -oldmap -= -self -. -map -. -clone -( -) -; -for -i -in -0 -. -. -r -. -state_len -( -) -{ -let -cur_id -= -self -. -idxmap -. -to_state_id -( -i -) -; -let -mut -new_id -= -oldmap -[ -i -] -; -if -cur_id -= -= -new_id -{ -continue -; -} -loop -{ -let -id -= -oldmap -[ -self -. -idxmap -. -to_index -( -new_id -) -] -; -if -cur_id -= -= -id -{ -self -. -map -[ -i -] -= -new_id -; -break -; -} -new_id -= -id -; -} -} -r -. -remap -( -| -next -| -self -. -map -[ -self -. -idxmap -. -to_index -( -next -) -] -) -; -} -} -/ -/ -/ -A -simple -type -for -mapping -between -state -indices -and -state -IDs -. -/ -/ -/ -/ -/ -/ -The -reason -why -this -exists -is -because -state -IDs -are -" -premultiplied -. -" -That -/ -/ -/ -is -in -order -to -get -to -the -transitions -for -a -particular -state -one -need -/ -/ -/ -only -use -the -state -ID -as -- -is -instead -of -having -to -multiple -it -by -transition -/ -/ -/ -table -' -s -stride -. -/ -/ -/ -/ -/ -/ -The -downside -of -this -is -that -it -' -s -inconvenient -to -map -between -state -IDs -/ -/ -/ -using -a -dense -map -e -. -g -. -Vec -< -StateID -> -. -That -' -s -because -state -IDs -look -like -/ -/ -/ -0 -0 -+ -stride -0 -+ -2 -* -stride -0 -+ -3 -* -stride -etc -. -instead -of -0 -1 -/ -/ -/ -2 -3 -etc -. -/ -/ -/ -/ -/ -/ -Since -our -state -IDs -are -premultiplied -we -can -convert -back -- -and -- -forth -/ -/ -/ -between -IDs -and -indices -by -simply -unmultiplying -the -IDs -and -multiplying -the -/ -/ -/ -indices -. -# -[ -derive -( -Debug -) -] -struct -IndexMapper -{ -/ -/ -/ -The -power -of -2 -corresponding -to -the -stride -of -the -corresponding -/ -/ -/ -transition -table -. -' -id -> -> -stride2 -' -de -- -multiplies -an -ID -while -' -index -< -< -/ -/ -/ -stride2 -' -pre -- -multiplies -an -index -to -an -ID -. -stride2 -: -usize -} -impl -IndexMapper -{ -/ -/ -/ -Convert -a -state -ID -to -a -state -index -. -fn -to_index -( -& -self -id -: -StateID -) -- -> -usize -{ -id -. -as_usize -( -) -> -> -self -. -stride2 -} -/ -/ -/ -Convert -a -state -index -to -a -state -ID -. -fn -to_state_id -( -& -self -index -: -usize -) -- -> -StateID -{ -/ -/ -CORRECTNESS -: -If -the -given -index -is -not -valid -then -it -is -not -/ -/ -required -for -this -to -panic -or -return -a -valid -state -ID -. -We -' -ll -" -just -" -/ -/ -wind -up -with -panics -or -silent -logic -errors -at -some -other -point -. -StateID -: -: -new_unchecked -( -index -< -< -self -. -stride2 -) -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -mod -dense -{ -use -crate -: -: -{ -dfa -: -: -dense -: -: -OwnedDFA -util -: -: -primitives -: -: -StateID -} -; -use -super -: -: -Remappable -; -impl -Remappable -for -OwnedDFA -{ -fn -state_len -( -& -self -) -- -> -usize -{ -OwnedDFA -: -: -state_len -( -self -) -} -fn -stride2 -( -& -self -) -- -> -usize -{ -OwnedDFA -: -: -stride2 -( -self -) -} -fn -swap_states -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -{ -OwnedDFA -: -: -swap_states -( -self -id1 -id2 -) -} -fn -remap -( -& -mut -self -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -{ -OwnedDFA -: -: -remap -( -self -map -) -} -} -} -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -mod -onepass -{ -use -crate -: -: -{ -dfa -: -: -onepass -: -: -DFA -util -: -: -primitives -: -: -StateID -} -; -use -super -: -: -Remappable -; -impl -Remappable -for -DFA -{ -fn -state_len -( -& -self -) -- -> -usize -{ -DFA -: -: -state_len -( -self -) -} -fn -stride2 -( -& -self -) -- -> -usize -{ -/ -/ -We -don -' -t -do -pre -- -multiplication -for -the -one -- -pass -DFA -so -/ -/ -returning -0 -has -the -effect -of -making -state -IDs -and -state -indices -/ -/ -equivalent -. -0 -} -fn -swap_states -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -{ -DFA -: -: -swap_states -( -self -id1 -id2 -) -} -fn -remap -( -& -mut -self -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -{ -DFA -: -: -remap -( -self -map -) -} -} -} diff --git a/third_party/rust/regex-automata/src/dfa/search.rs b/third_party/rust/regex-automata/src/dfa/search.rs deleted file mode 100644 index e2f6b09bd9b5d..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/search.rs +++ /dev/null @@ -1,5247 +0,0 @@ -use -crate -: -: -{ -dfa -: -: -{ -accel -automaton -: -: -{ -Automaton -OverlappingState -} -} -util -: -: -{ -prefilter -: -: -Prefilter -primitives -: -: -StateID -search -: -: -{ -Anchored -HalfMatch -Input -Span -} -} -MatchError -} -; -# -[ -inline -( -never -) -] -pub -fn -find_fwd -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -if -input -. -is_done -( -) -{ -return -Ok -( -None -) -; -} -let -pre -= -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -None -} -else -{ -dfa -. -get_prefilter -( -) -} -; -/ -/ -Searching -with -a -pattern -ID -is -always -anchored -so -we -should -never -use -/ -/ -a -prefilter -. -if -pre -. -is_some -( -) -{ -if -input -. -get_earliest -( -) -{ -find_fwd_imp -( -dfa -input -pre -true -) -} -else -{ -find_fwd_imp -( -dfa -input -pre -false -) -} -} -else -{ -if -input -. -get_earliest -( -) -{ -find_fwd_imp -( -dfa -input -None -true -) -} -else -{ -find_fwd_imp -( -dfa -input -None -false -) -} -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -find_fwd_imp -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -pre -: -Option -< -& -' -_ -Prefilter -> -earliest -: -bool -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -/ -/ -See -' -prefilter_restart -' -docs -for -explanation -. -let -universal_start -= -dfa -. -universal_start_state -( -Anchored -: -: -No -) -. -is_some -( -) -; -let -mut -mat -= -None -; -let -mut -sid -= -init_fwd -( -dfa -input -) -? -; -let -mut -at -= -input -. -start -( -) -; -/ -/ -This -could -just -be -a -closure -but -then -I -think -it -would -be -unsound -/ -/ -because -it -would -need -to -be -safe -to -invoke -. -This -way -the -lack -of -safety -/ -/ -is -clearer -in -the -code -below -. -macro_rules -! -next_unchecked -{ -( -sid -: -expr -at -: -expr -) -= -> -{ -{ -let -byte -= -* -input -. -haystack -( -) -. -get_unchecked -( -at -) -; -dfa -. -next_state_unchecked -( -sid -byte -) -} -} -; -} -if -let -Some -( -ref -pre -) -= -pre -{ -let -span -= -Span -: -: -from -( -at -. -. -input -. -end -( -) -) -; -/ -/ -If -a -prefilter -doesn -' -t -report -false -positives -then -we -don -' -t -need -to -/ -/ -touch -the -DFA -at -all -. -However -since -all -matches -include -the -pattern -/ -/ -ID -and -the -prefilter -infrastructure -doesn -' -t -report -pattern -IDs -we -/ -/ -limit -this -optimization -to -cases -where -there -is -exactly -one -pattern -. -/ -/ -In -that -case -any -match -must -be -the -0th -pattern -. -match -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -return -Ok -( -mat -) -Some -( -ref -span -) -= -> -{ -at -= -span -. -start -; -if -! -universal_start -{ -sid -= -prefilter_restart -( -dfa -& -input -at -) -? -; -} -} -} -} -while -at -< -input -. -end -( -) -{ -/ -/ -SAFETY -: -There -are -two -safety -invariants -we -need -to -uphold -here -in -/ -/ -the -loops -below -: -that -' -sid -' -and -' -prev_sid -' -are -valid -state -IDs -/ -/ -for -this -DFA -and -that -' -at -' -is -a -valid -index -into -' -haystack -' -. -/ -/ -For -the -former -we -rely -on -the -invariant -that -next_state -* -and -/ -/ -start_state_forward -always -returns -a -valid -state -ID -( -given -a -valid -/ -/ -state -ID -in -the -former -case -) -. -For -the -latter -safety -invariant -we -/ -/ -always -guard -unchecked -access -with -a -check -that -' -at -' -is -less -than -/ -/ -' -end -' -where -' -end -< -= -haystack -. -len -( -) -' -. -In -the -unrolled -loop -below -we -/ -/ -ensure -that -' -at -' -is -always -in -bounds -. -/ -/ -/ -/ -PERF -: -See -a -similar -comment -in -src -/ -hybrid -/ -search -. -rs -that -justifies -/ -/ -this -extra -work -to -make -the -search -loop -fast -. -The -same -reasoning -and -/ -/ -benchmarks -apply -here -. -let -mut -prev_sid -; -while -at -< -input -. -end -( -) -{ -prev_sid -= -unsafe -{ -next_unchecked -! -( -sid -at -) -} -; -if -dfa -. -is_special_state -( -prev_sid -) -| -| -at -+ -3 -> -= -input -. -end -( -) -{ -core -: -: -mem -: -: -swap -( -& -mut -prev_sid -& -mut -sid -) -; -break -; -} -at -+ -= -1 -; -sid -= -unsafe -{ -next_unchecked -! -( -prev_sid -at -) -} -; -if -dfa -. -is_special_state -( -sid -) -{ -break -; -} -at -+ -= -1 -; -prev_sid -= -unsafe -{ -next_unchecked -! -( -sid -at -) -} -; -if -dfa -. -is_special_state -( -prev_sid -) -{ -core -: -: -mem -: -: -swap -( -& -mut -prev_sid -& -mut -sid -) -; -break -; -} -at -+ -= -1 -; -sid -= -unsafe -{ -next_unchecked -! -( -prev_sid -at -) -} -; -if -dfa -. -is_special_state -( -sid -) -{ -break -; -} -at -+ -= -1 -; -} -if -dfa -. -is_special_state -( -sid -) -{ -if -dfa -. -is_start_state -( -sid -) -{ -if -let -Some -( -ref -pre -) -= -pre -{ -let -span -= -Span -: -: -from -( -at -. -. -input -. -end -( -) -) -; -match -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -return -Ok -( -mat -) -Some -( -ref -span -) -= -> -{ -/ -/ -We -want -to -skip -any -update -to -' -at -' -below -/ -/ -at -the -end -of -this -iteration -and -just -/ -/ -jump -immediately -back -to -the -next -state -/ -/ -transition -at -the -leading -position -of -the -/ -/ -candidate -match -. -/ -/ -/ -/ -. -. -. -but -only -if -we -actually -made -progress -/ -/ -with -our -prefilter -otherwise -if -the -start -/ -/ -state -has -a -self -- -loop -we -can -get -stuck -. -if -span -. -start -> -at -{ -at -= -span -. -start -; -if -! -universal_start -{ -sid -= -prefilter_restart -( -dfa -& -input -at -) -? -; -} -continue -; -} -} -} -} -else -if -dfa -. -is_accel_state -( -sid -) -{ -let -needles -= -dfa -. -accelerator -( -sid -) -; -at -= -accel -: -: -find_fwd -( -needles -input -. -haystack -( -) -at -+ -1 -) -. -unwrap_or -( -input -. -end -( -) -) -; -continue -; -} -} -else -if -dfa -. -is_match_state -( -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -sid -0 -) -; -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -at -) -) -; -if -earliest -{ -return -Ok -( -mat -) -; -} -if -dfa -. -is_accel_state -( -sid -) -{ -let -needles -= -dfa -. -accelerator -( -sid -) -; -at -= -accel -: -: -find_fwd -( -needles -input -. -haystack -( -) -at -+ -1 -) -. -unwrap_or -( -input -. -end -( -) -) -; -continue -; -} -} -else -if -dfa -. -is_accel_state -( -sid -) -{ -let -needs -= -dfa -. -accelerator -( -sid -) -; -at -= -accel -: -: -find_fwd -( -needs -input -. -haystack -( -) -at -+ -1 -) -. -unwrap_or -( -input -. -end -( -) -) -; -continue -; -} -else -if -dfa -. -is_dead_state -( -sid -) -{ -return -Ok -( -mat -) -; -} -else -{ -/ -/ -It -' -s -important -that -this -is -a -debug_assert -since -this -can -/ -/ -actually -be -tripped -even -if -DFA -: -: -from_bytes -succeeds -and -/ -/ -returns -a -supposedly -valid -DFA -. -debug_assert -! -( -dfa -. -is_quit_state -( -sid -) -) -; -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -at -] -at -) -) -; -} -} -at -+ -= -1 -; -} -eoi_fwd -( -dfa -input -& -mut -sid -& -mut -mat -) -? -; -Ok -( -mat -) -} -# -[ -inline -( -never -) -] -pub -fn -find_rev -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -if -input -. -is_done -( -) -{ -return -Ok -( -None -) -; -} -if -input -. -get_earliest -( -) -{ -find_rev_imp -( -dfa -input -true -) -} -else -{ -find_rev_imp -( -dfa -input -false -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -find_rev_imp -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -earliest -: -bool -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -let -mut -mat -= -None -; -let -mut -sid -= -init_rev -( -dfa -input -) -? -; -/ -/ -In -reverse -search -the -loop -below -can -' -t -handle -the -case -of -searching -an -/ -/ -empty -slice -. -Ideally -we -could -write -something -congruent -to -the -forward -/ -/ -search -i -. -e -. -' -while -at -> -= -start -' -but -' -start -' -might -be -0 -. -Since -we -use -/ -/ -an -unsigned -offset -' -at -> -= -0 -' -is -trivially -always -true -. -We -could -avoid -/ -/ -this -extra -case -handling -by -using -a -signed -offset -but -Rust -makes -it -/ -/ -annoying -to -do -. -So -. -. -. -We -just -handle -the -empty -case -separately -. -if -input -. -start -( -) -= -= -input -. -end -( -) -{ -eoi_rev -( -dfa -input -& -mut -sid -& -mut -mat -) -? -; -return -Ok -( -mat -) -; -} -let -mut -at -= -input -. -end -( -) -- -1 -; -macro_rules -! -next_unchecked -{ -( -sid -: -expr -at -: -expr -) -= -> -{ -{ -let -byte -= -* -input -. -haystack -( -) -. -get_unchecked -( -at -) -; -dfa -. -next_state_unchecked -( -sid -byte -) -} -} -; -} -loop -{ -/ -/ -SAFETY -: -See -comments -in -' -find_fwd -' -for -a -safety -argument -. -let -mut -prev_sid -; -while -at -> -= -input -. -start -( -) -{ -prev_sid -= -unsafe -{ -next_unchecked -! -( -sid -at -) -} -; -if -dfa -. -is_special_state -( -prev_sid -) -| -| -at -< -= -input -. -start -( -) -. -saturating_add -( -3 -) -{ -core -: -: -mem -: -: -swap -( -& -mut -prev_sid -& -mut -sid -) -; -break -; -} -at -- -= -1 -; -sid -= -unsafe -{ -next_unchecked -! -( -prev_sid -at -) -} -; -if -dfa -. -is_special_state -( -sid -) -{ -break -; -} -at -- -= -1 -; -prev_sid -= -unsafe -{ -next_unchecked -! -( -sid -at -) -} -; -if -dfa -. -is_special_state -( -prev_sid -) -{ -core -: -: -mem -: -: -swap -( -& -mut -prev_sid -& -mut -sid -) -; -break -; -} -at -- -= -1 -; -sid -= -unsafe -{ -next_unchecked -! -( -prev_sid -at -) -} -; -if -dfa -. -is_special_state -( -sid -) -{ -break -; -} -at -- -= -1 -; -} -if -dfa -. -is_special_state -( -sid -) -{ -if -dfa -. -is_start_state -( -sid -) -{ -if -dfa -. -is_accel_state -( -sid -) -{ -let -needles -= -dfa -. -accelerator -( -sid -) -; -at -= -accel -: -: -find_rev -( -needles -input -. -haystack -( -) -at -) -. -map -( -| -i -| -i -+ -1 -) -. -unwrap_or -( -input -. -start -( -) -) -; -} -} -else -if -dfa -. -is_match_state -( -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -sid -0 -) -; -/ -/ -Since -reverse -searches -report -the -beginning -of -a -match -/ -/ -and -the -beginning -is -inclusive -( -not -exclusive -like -the -/ -/ -end -of -a -match -) -we -add -1 -to -make -it -inclusive -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -at -+ -1 -) -) -; -if -earliest -{ -return -Ok -( -mat -) -; -} -if -dfa -. -is_accel_state -( -sid -) -{ -let -needles -= -dfa -. -accelerator -( -sid -) -; -at -= -accel -: -: -find_rev -( -needles -input -. -haystack -( -) -at -) -. -map -( -| -i -| -i -+ -1 -) -. -unwrap_or -( -input -. -start -( -) -) -; -} -} -else -if -dfa -. -is_accel_state -( -sid -) -{ -let -needles -= -dfa -. -accelerator -( -sid -) -; -/ -/ -If -the -accelerator -returns -nothing -why -don -' -t -we -quit -the -/ -/ -search -? -Well -if -the -accelerator -doesn -' -t -find -anything -that -/ -/ -doesn -' -t -mean -we -don -' -t -have -a -match -. -It -just -means -that -we -/ -/ -can -' -t -leave -the -current -state -given -one -of -the -255 -possible -/ -/ -byte -values -. -However -there -might -be -an -EOI -transition -. -So -/ -/ -we -set -' -at -' -to -the -end -of -the -haystack -which -will -cause -/ -/ -this -loop -to -stop -and -fall -down -into -the -EOI -transition -. -at -= -accel -: -: -find_rev -( -needles -input -. -haystack -( -) -at -) -. -map -( -| -i -| -i -+ -1 -) -. -unwrap_or -( -input -. -start -( -) -) -; -} -else -if -dfa -. -is_dead_state -( -sid -) -{ -return -Ok -( -mat -) -; -} -else -{ -debug_assert -! -( -dfa -. -is_quit_state -( -sid -) -) -; -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -at -] -at -) -) -; -} -} -if -at -= -= -input -. -start -( -) -{ -break -; -} -at -- -= -1 -; -} -eoi_rev -( -dfa -input -& -mut -sid -& -mut -mat -) -? -; -Ok -( -mat -) -} -# -[ -inline -( -never -) -] -pub -fn -find_overlapping_fwd -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -state -. -mat -= -None -; -if -input -. -is_done -( -) -{ -return -Ok -( -( -) -) -; -} -let -pre -= -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -None -} -else -{ -dfa -. -get_prefilter -( -) -} -; -if -pre -. -is_some -( -) -{ -find_overlapping_fwd_imp -( -dfa -input -pre -state -) -} -else -{ -find_overlapping_fwd_imp -( -dfa -input -None -state -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -find_overlapping_fwd_imp -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -pre -: -Option -< -& -' -_ -Prefilter -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -/ -/ -See -' -prefilter_restart -' -docs -for -explanation -. -let -universal_start -= -dfa -. -universal_start_state -( -Anchored -: -: -No -) -. -is_some -( -) -; -let -mut -sid -= -match -state -. -id -{ -None -= -> -{ -state -. -at -= -input -. -start -( -) -; -init_fwd -( -dfa -input -) -? -} -Some -( -sid -) -= -> -{ -if -let -Some -( -match_index -) -= -state -. -next_match_index -{ -let -match_len -= -dfa -. -match_len -( -sid -) -; -if -match_index -< -match_len -{ -state -. -next_match_index -= -Some -( -match_index -+ -1 -) -; -let -pattern -= -dfa -. -match_pattern -( -sid -match_index -) -; -state -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -state -. -at -) -) -; -return -Ok -( -( -) -) -; -} -} -/ -/ -Once -we -' -ve -reported -all -matches -at -a -given -position -we -need -to -/ -/ -advance -the -search -to -the -next -position -. -state -. -at -+ -= -1 -; -if -state -. -at -> -input -. -end -( -) -{ -return -Ok -( -( -) -) -; -} -sid -} -} -; -/ -/ -NOTE -: -We -don -' -t -optimize -the -crap -out -of -this -routine -primarily -because -/ -/ -it -seems -like -most -find_overlapping -searches -will -have -higher -match -/ -/ -counts -and -thus -throughput -is -perhaps -not -as -important -. -But -if -you -/ -/ -have -a -use -case -for -something -faster -feel -free -to -file -an -issue -. -while -state -. -at -< -input -. -end -( -) -{ -sid -= -dfa -. -next_state -( -sid -input -. -haystack -( -) -[ -state -. -at -] -) -; -if -dfa -. -is_special_state -( -sid -) -{ -state -. -id -= -Some -( -sid -) -; -if -dfa -. -is_start_state -( -sid -) -{ -if -let -Some -( -ref -pre -) -= -pre -{ -let -span -= -Span -: -: -from -( -state -. -at -. -. -input -. -end -( -) -) -; -match -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -return -Ok -( -( -) -) -Some -( -ref -span -) -= -> -{ -if -span -. -start -> -state -. -at -{ -state -. -at -= -span -. -start -; -if -! -universal_start -{ -sid -= -prefilter_restart -( -dfa -& -input -state -. -at -) -? -; -} -continue -; -} -} -} -} -else -if -dfa -. -is_accel_state -( -sid -) -{ -let -needles -= -dfa -. -accelerator -( -sid -) -; -state -. -at -= -accel -: -: -find_fwd -( -needles -input -. -haystack -( -) -state -. -at -+ -1 -) -. -unwrap_or -( -input -. -end -( -) -) -; -continue -; -} -} -else -if -dfa -. -is_match_state -( -sid -) -{ -state -. -next_match_index -= -Some -( -1 -) -; -let -pattern -= -dfa -. -match_pattern -( -sid -0 -) -; -state -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -state -. -at -) -) -; -return -Ok -( -( -) -) -; -} -else -if -dfa -. -is_accel_state -( -sid -) -{ -let -needs -= -dfa -. -accelerator -( -sid -) -; -/ -/ -If -the -accelerator -returns -nothing -why -don -' -t -we -quit -the -/ -/ -search -? -Well -if -the -accelerator -doesn -' -t -find -anything -that -/ -/ -doesn -' -t -mean -we -don -' -t -have -a -match -. -It -just -means -that -we -/ -/ -can -' -t -leave -the -current -state -given -one -of -the -255 -possible -/ -/ -byte -values -. -However -there -might -be -an -EOI -transition -. -So -/ -/ -we -set -' -at -' -to -the -end -of -the -haystack -which -will -cause -/ -/ -this -loop -to -stop -and -fall -down -into -the -EOI -transition -. -state -. -at -= -accel -: -: -find_fwd -( -needs -input -. -haystack -( -) -state -. -at -+ -1 -) -. -unwrap_or -( -input -. -end -( -) -) -; -continue -; -} -else -if -dfa -. -is_dead_state -( -sid -) -{ -return -Ok -( -( -) -) -; -} -else -{ -debug_assert -! -( -dfa -. -is_quit_state -( -sid -) -) -; -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -state -. -at -] -state -. -at -) -) -; -} -} -state -. -at -+ -= -1 -; -} -let -result -= -eoi_fwd -( -dfa -input -& -mut -sid -& -mut -state -. -mat -) -; -state -. -id -= -Some -( -sid -) -; -if -state -. -mat -. -is_some -( -) -{ -/ -/ -' -1 -' -is -always -correct -here -since -if -we -get -to -this -point -this -/ -/ -always -corresponds -to -the -first -( -index -' -0 -' -) -match -discovered -at -/ -/ -this -position -. -So -the -next -match -to -report -at -this -position -( -if -/ -/ -it -exists -) -is -at -index -' -1 -' -. -state -. -next_match_index -= -Some -( -1 -) -; -} -result -} -# -[ -inline -( -never -) -] -pub -( -crate -) -fn -find_overlapping_rev -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -state -. -mat -= -None -; -if -input -. -is_done -( -) -{ -return -Ok -( -( -) -) -; -} -let -mut -sid -= -match -state -. -id -{ -None -= -> -{ -let -sid -= -init_rev -( -dfa -input -) -? -; -state -. -id -= -Some -( -sid -) -; -if -input -. -start -( -) -= -= -input -. -end -( -) -{ -state -. -rev_eoi -= -true -; -} -else -{ -state -. -at -= -input -. -end -( -) -- -1 -; -} -sid -} -Some -( -sid -) -= -> -{ -if -let -Some -( -match_index -) -= -state -. -next_match_index -{ -let -match_len -= -dfa -. -match_len -( -sid -) -; -if -match_index -< -match_len -{ -state -. -next_match_index -= -Some -( -match_index -+ -1 -) -; -let -pattern -= -dfa -. -match_pattern -( -sid -match_index -) -; -state -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -state -. -at -) -) -; -return -Ok -( -( -) -) -; -} -} -/ -/ -Once -we -' -ve -reported -all -matches -at -a -given -position -we -need -/ -/ -to -advance -the -search -to -the -next -position -. -However -if -we -' -ve -/ -/ -already -followed -the -EOI -transition -then -we -know -we -' -re -done -/ -/ -with -the -search -and -there -cannot -be -any -more -matches -to -report -. -if -state -. -rev_eoi -{ -return -Ok -( -( -) -) -; -} -else -if -state -. -at -= -= -input -. -start -( -) -{ -/ -/ -At -this -point -we -should -follow -the -EOI -transition -. -This -/ -/ -will -cause -us -the -skip -the -main -loop -below -and -fall -through -/ -/ -to -the -final -' -eoi_rev -' -transition -. -state -. -rev_eoi -= -true -; -} -else -{ -/ -/ -We -haven -' -t -hit -the -end -of -the -search -yet -so -move -on -. -state -. -at -- -= -1 -; -} -sid -} -} -; -while -! -state -. -rev_eoi -{ -sid -= -dfa -. -next_state -( -sid -input -. -haystack -( -) -[ -state -. -at -] -) -; -if -dfa -. -is_special_state -( -sid -) -{ -state -. -id -= -Some -( -sid -) -; -if -dfa -. -is_start_state -( -sid -) -{ -if -dfa -. -is_accel_state -( -sid -) -{ -let -needles -= -dfa -. -accelerator -( -sid -) -; -state -. -at -= -accel -: -: -find_rev -( -needles -input -. -haystack -( -) -state -. -at -) -. -map -( -| -i -| -i -+ -1 -) -. -unwrap_or -( -input -. -start -( -) -) -; -} -} -else -if -dfa -. -is_match_state -( -sid -) -{ -state -. -next_match_index -= -Some -( -1 -) -; -let -pattern -= -dfa -. -match_pattern -( -sid -0 -) -; -state -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -state -. -at -+ -1 -) -) -; -return -Ok -( -( -) -) -; -} -else -if -dfa -. -is_accel_state -( -sid -) -{ -let -needles -= -dfa -. -accelerator -( -sid -) -; -/ -/ -If -the -accelerator -returns -nothing -why -don -' -t -we -quit -the -/ -/ -search -? -Well -if -the -accelerator -doesn -' -t -find -anything -that -/ -/ -doesn -' -t -mean -we -don -' -t -have -a -match -. -It -just -means -that -we -/ -/ -can -' -t -leave -the -current -state -given -one -of -the -255 -possible -/ -/ -byte -values -. -However -there -might -be -an -EOI -transition -. -So -/ -/ -we -set -' -at -' -to -the -end -of -the -haystack -which -will -cause -/ -/ -this -loop -to -stop -and -fall -down -into -the -EOI -transition -. -state -. -at -= -accel -: -: -find_rev -( -needles -input -. -haystack -( -) -state -. -at -) -. -map -( -| -i -| -i -+ -1 -) -. -unwrap_or -( -input -. -start -( -) -) -; -} -else -if -dfa -. -is_dead_state -( -sid -) -{ -return -Ok -( -( -) -) -; -} -else -{ -debug_assert -! -( -dfa -. -is_quit_state -( -sid -) -) -; -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -state -. -at -] -state -. -at -) -) -; -} -} -if -state -. -at -= -= -input -. -start -( -) -{ -break -; -} -state -. -at -- -= -1 -; -} -let -result -= -eoi_rev -( -dfa -input -& -mut -sid -& -mut -state -. -mat -) -; -state -. -rev_eoi -= -true -; -state -. -id -= -Some -( -sid -) -; -if -state -. -mat -. -is_some -( -) -{ -/ -/ -' -1 -' -is -always -correct -here -since -if -we -get -to -this -point -this -/ -/ -always -corresponds -to -the -first -( -index -' -0 -' -) -match -discovered -at -/ -/ -this -position -. -So -the -next -match -to -report -at -this -position -( -if -/ -/ -it -exists -) -is -at -index -' -1 -' -. -state -. -next_match_index -= -Some -( -1 -) -; -} -result -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -init_fwd -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -{ -let -sid -= -dfa -. -start_state_forward -( -input -) -? -; -/ -/ -Start -states -can -never -be -match -states -since -all -matches -are -delayed -/ -/ -by -1 -byte -. -debug_assert -! -( -! -dfa -. -is_match_state -( -sid -) -) -; -Ok -( -sid -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -init_rev -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -{ -let -sid -= -dfa -. -start_state_reverse -( -input -) -? -; -/ -/ -Start -states -can -never -be -match -states -since -all -matches -are -delayed -/ -/ -by -1 -byte -. -debug_assert -! -( -! -dfa -. -is_match_state -( -sid -) -) -; -Ok -( -sid -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -eoi_fwd -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -sid -: -& -mut -StateID -mat -: -& -mut -Option -< -HalfMatch -> -) -- -> -Result -< -( -) -MatchError -> -{ -let -sp -= -input -. -get_span -( -) -; -match -input -. -haystack -( -) -. -get -( -sp -. -end -) -{ -Some -( -& -b -) -= -> -{ -* -sid -= -dfa -. -next_state -( -* -sid -b -) -; -if -dfa -. -is_match_state -( -* -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -sp -. -end -) -) -; -} -else -if -dfa -. -is_quit_state -( -* -sid -) -{ -return -Err -( -MatchError -: -: -quit -( -b -sp -. -end -) -) -; -} -} -None -= -> -{ -* -sid -= -dfa -. -next_eoi_state -( -* -sid -) -; -if -dfa -. -is_match_state -( -* -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -input -. -haystack -( -) -. -len -( -) -) -) -; -} -/ -/ -N -. -B -. -We -don -' -t -have -to -check -' -is_quit -' -here -because -the -EOI -/ -/ -transition -can -never -lead -to -a -quit -state -. -debug_assert -! -( -! -dfa -. -is_quit_state -( -* -sid -) -) -; -} -} -Ok -( -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -eoi_rev -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -sid -: -& -mut -StateID -mat -: -& -mut -Option -< -HalfMatch -> -) -- -> -Result -< -( -) -MatchError -> -{ -let -sp -= -input -. -get_span -( -) -; -if -sp -. -start -> -0 -{ -let -byte -= -input -. -haystack -( -) -[ -sp -. -start -- -1 -] -; -* -sid -= -dfa -. -next_state -( -* -sid -byte -) -; -if -dfa -. -is_match_state -( -* -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -sp -. -start -) -) -; -} -else -if -dfa -. -is_quit_state -( -* -sid -) -{ -return -Err -( -MatchError -: -: -quit -( -byte -sp -. -start -- -1 -) -) -; -} -} -else -{ -* -sid -= -dfa -. -next_eoi_state -( -* -sid -) -; -if -dfa -. -is_match_state -( -* -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -0 -) -) -; -} -/ -/ -N -. -B -. -We -don -' -t -have -to -check -' -is_quit -' -here -because -the -EOI -/ -/ -transition -can -never -lead -to -a -quit -state -. -debug_assert -! -( -! -dfa -. -is_quit_state -( -* -sid -) -) -; -} -Ok -( -( -) -) -} -/ -/ -/ -Re -- -compute -the -starting -state -that -a -DFA -should -be -in -after -finding -a -/ -/ -/ -prefilter -candidate -match -at -the -position -at -. -/ -/ -/ -/ -/ -/ -The -function -with -the -same -name -has -a -bit -more -docs -in -hybrid -/ -search -. -rs -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -prefilter_restart -< -A -: -Automaton -+ -? -Sized -> -( -dfa -: -& -A -input -: -& -Input -< -' -_ -> -at -: -usize -) -- -> -Result -< -StateID -MatchError -> -{ -let -mut -input -= -input -. -clone -( -) -; -input -. -set_start -( -at -) -; -init_fwd -( -dfa -& -input -) -} diff --git a/third_party/rust/regex-automata/src/dfa/sparse.rs b/third_party/rust/regex-automata/src/dfa/sparse.rs deleted file mode 100644 index 5390a387e7e0b..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/sparse.rs +++ /dev/null @@ -1,24517 +0,0 @@ -/ -* -! -Types -and -routines -specific -to -sparse -DFAs -. -This -module -is -the -home -of -[ -sparse -: -: -DFA -] -( -DFA -) -. -Unlike -the -[ -dense -] -( -super -: -: -dense -) -module -this -module -does -not -contain -a -builder -or -configuration -specific -for -sparse -DFAs -. -Instead -the -intended -way -to -build -a -sparse -DFA -is -either -by -using -a -default -configuration -with -its -constructor -[ -sparse -: -: -DFA -: -: -new -] -( -DFA -: -: -new -) -or -by -first -configuring -the -construction -of -a -dense -DFA -with -[ -dense -: -: -Builder -] -( -super -: -: -dense -: -: -Builder -) -and -then -calling -[ -dense -: -: -DFA -: -: -to_sparse -] -( -super -: -: -dense -: -: -DFA -: -: -to_sparse -) -. -For -example -this -configures -a -sparse -DFA -to -do -an -overlapping -search -: -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -OverlappingState -dense -} -HalfMatch -Input -MatchKind -} -; -let -dense_re -= -dense -: -: -Builder -: -: -new -( -) -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -. -build -( -r -" -Samwise -| -Sam -" -) -? -; -let -sparse_re -= -dense_re -. -to_sparse -( -) -? -; -/ -/ -Setup -our -haystack -and -initial -start -state -. -let -input -= -Input -: -: -new -( -" -Samwise -" -) -; -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -First -' -Sam -' -will -match -. -sparse_re -. -try_search_overlapping_fwd -( -& -input -& -mut -state -) -? -; -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -state -. -get_match -( -) -) -; -/ -/ -And -now -' -Samwise -' -will -match -. -sparse_re -. -try_search_overlapping_fwd -( -& -input -& -mut -state -) -? -; -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -7 -) -) -state -. -get_match -( -) -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -* -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -core -: -: -iter -; -use -core -: -: -{ -convert -: -: -{ -TryFrom -TryInto -} -fmt -mem -: -: -size_of -} -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -crate -: -: -dfa -: -: -dense -: -: -{ -self -BuildError -} -; -use -crate -: -: -{ -dfa -: -: -{ -automaton -: -: -{ -fmt_state_indicator -Automaton -} -dense -: -: -Flags -special -: -: -Special -StartKind -DEAD -} -util -: -: -{ -alphabet -: -: -{ -ByteClasses -ByteSet -} -escape -: -: -DebugByte -int -: -: -{ -Pointer -Usize -U16 -U32 -} -prefilter -: -: -Prefilter -primitives -: -: -{ -PatternID -StateID -} -search -: -: -{ -Anchored -Input -MatchError -} -start -: -: -{ -Start -StartByteMap -} -wire -: -: -{ -self -DeserializeError -Endian -SerializeError -} -} -} -; -const -LABEL -: -& -str -= -" -rust -- -regex -- -automata -- -dfa -- -sparse -" -; -const -VERSION -: -u32 -= -2 -; -/ -/ -/ -A -sparse -deterministic -finite -automaton -( -DFA -) -with -variable -sized -states -. -/ -/ -/ -/ -/ -/ -In -contrast -to -a -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -a -sparse -DFA -uses -/ -/ -/ -a -more -space -efficient -representation -for -its -transitions -. -Consequently -/ -/ -/ -sparse -DFAs -may -use -much -less -memory -than -dense -DFAs -but -this -comes -at -a -/ -/ -/ -price -. -In -particular -reading -the -more -space -efficient -transitions -takes -/ -/ -/ -more -work -and -consequently -searching -using -a -sparse -DFA -is -typically -/ -/ -/ -slower -than -a -dense -DFA -. -/ -/ -/ -/ -/ -/ -A -sparse -DFA -can -be -built -using -the -default -configuration -via -the -/ -/ -/ -[ -DFA -: -: -new -] -constructor -. -Otherwise -one -can -configure -various -aspects -/ -/ -/ -of -a -dense -DFA -via -[ -dense -: -: -Builder -] -( -crate -: -: -dfa -: -: -dense -: -: -Builder -) -/ -/ -/ -and -then -convert -a -dense -DFA -to -a -sparse -DFA -using -/ -/ -/ -[ -dense -: -: -DFA -: -: -to_sparse -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -: -: -to_sparse -) -. -/ -/ -/ -/ -/ -/ -In -general -a -sparse -DFA -supports -all -the -same -search -operations -as -a -dense -/ -/ -/ -DFA -. -/ -/ -/ -/ -/ -/ -Making -the -choice -between -a -dense -and -sparse -DFA -depends -on -your -specific -/ -/ -/ -work -load -. -If -you -can -sacrifice -a -bit -of -search -time -performance -then -a -/ -/ -/ -sparse -DFA -might -be -the -best -choice -. -In -particular -while -sparse -DFAs -are -/ -/ -/ -probably -always -slower -than -dense -DFAs -you -may -find -that -they -are -easily -/ -/ -/ -fast -enough -for -your -purposes -! -/ -/ -/ -/ -/ -/ -# -Type -parameters -/ -/ -/ -/ -/ -/ -A -DFA -has -one -type -parameter -T -which -is -used -to -represent -the -parts -/ -/ -/ -of -a -sparse -DFA -. -T -is -typically -a -Vec -< -u8 -> -or -a -& -[ -u8 -] -. -/ -/ -/ -/ -/ -/ -# -The -Automaton -trait -/ -/ -/ -/ -/ -/ -This -type -implements -the -[ -Automaton -] -trait -which -means -it -can -be -used -/ -/ -/ -for -searching -. -For -example -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -) -] -pub -struct -DFA -< -T -> -{ -/ -/ -When -compared -to -a -dense -DFA -a -sparse -DFA -* -looks -* -a -lot -simpler -/ -/ -representation -- -wise -. -In -reality -it -is -perhaps -more -complicated -. -Namely -/ -/ -in -a -dense -DFA -all -information -needs -to -be -very -cheaply -accessible -/ -/ -using -only -state -IDs -. -In -a -sparse -DFA -however -each -state -uses -a -/ -/ -variable -amount -of -space -because -each -state -encodes -more -information -/ -/ -than -just -its -transitions -. -Each -state -also -includes -an -accelerator -if -/ -/ -one -exists -along -with -the -matching -pattern -IDs -if -the -state -is -a -match -/ -/ -state -. -/ -/ -/ -/ -That -is -a -lot -of -the -complexity -is -pushed -down -into -how -each -state -/ -/ -itself -is -represented -. -tt -: -Transitions -< -T -> -st -: -StartTable -< -T -> -special -: -Special -pre -: -Option -< -Prefilter -> -quitset -: -ByteSet -flags -: -Flags -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -DFA -< -Vec -< -u8 -> -> -{ -/ -/ -/ -Parse -the -given -regular -expression -using -a -default -configuration -and -/ -/ -/ -return -the -corresponding -sparse -DFA -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -/ -/ -/ -the -[ -dense -: -: -Builder -] -( -crate -: -: -dfa -: -: -dense -: -: -Builder -) -/ -/ -/ -to -set -your -own -configuration -and -then -call -/ -/ -/ -[ -dense -: -: -DFA -: -: -to_sparse -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -: -: -to_sparse -) -to -create -/ -/ -/ -a -sparse -DFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -sparse -: -: -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -11 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345bar -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -DFA -< -Vec -< -u8 -> -> -BuildError -> -{ -dense -: -: -Builder -: -: -new -( -) -. -build -( -pattern -) -. -and_then -( -| -dense -| -dense -. -to_sparse -( -) -) -} -/ -/ -/ -Parse -the -given -regular -expressions -using -a -default -configuration -and -/ -/ -/ -return -the -corresponding -multi -- -DFA -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -/ -/ -/ -the -[ -dense -: -: -Builder -] -( -crate -: -: -dfa -: -: -dense -: -: -Builder -) -/ -/ -/ -to -set -your -own -configuration -and -then -call -/ -/ -/ -[ -dense -: -: -DFA -: -: -to_sparse -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -: -: -to_sparse -) -to -create -/ -/ -/ -a -sparse -DFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -sparse -: -: -DFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -] -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -1 -3 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345bar -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -DFA -< -Vec -< -u8 -> -> -BuildError -> -{ -dense -: -: -Builder -: -: -new -( -) -. -build_many -( -patterns -) -. -and_then -( -| -dense -| -dense -. -to_sparse -( -) -) -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -DFA -< -Vec -< -u8 -> -> -{ -/ -/ -/ -Create -a -new -DFA -that -matches -every -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -sparse -} -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -sparse -: -: -DFA -: -: -always_match -( -) -? -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -0 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -" -) -) -? -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -always_match -( -) -- -> -Result -< -DFA -< -Vec -< -u8 -> -> -BuildError -> -{ -dense -: -: -DFA -: -: -always_match -( -) -? -. -to_sparse -( -) -} -/ -/ -/ -Create -a -new -sparse -DFA -that -never -matches -any -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -} -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -sparse -: -: -DFA -: -: -never_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -None -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -" -) -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -never_match -( -) -- -> -Result -< -DFA -< -Vec -< -u8 -> -> -BuildError -> -{ -dense -: -: -DFA -: -: -never_match -( -) -? -. -to_sparse -( -) -} -/ -/ -/ -The -implementation -for -constructing -a -sparse -DFA -from -a -dense -DFA -. -pub -( -crate -) -fn -from_dense -< -T -: -AsRef -< -[ -u32 -] -> -> -( -dfa -: -& -dense -: -: -DFA -< -T -> -) -- -> -Result -< -DFA -< -Vec -< -u8 -> -> -BuildError -> -{ -/ -/ -In -order -to -build -the -transition -table -we -need -to -be -able -to -write -/ -/ -state -identifiers -for -each -of -the -" -next -" -transitions -in -each -state -. -/ -/ -Our -state -identifiers -correspond -to -the -byte -offset -in -the -/ -/ -transition -table -at -which -the -state -is -encoded -. -Therefore -we -do -not -/ -/ -actually -know -what -the -state -identifiers -are -until -we -' -ve -allocated -/ -/ -exactly -as -much -space -as -we -need -for -each -state -. -Thus -construction -/ -/ -of -the -transition -table -happens -in -two -passes -. -/ -/ -/ -/ -In -the -first -pass -we -fill -out -the -shell -of -each -state -which -/ -/ -includes -the -transition -length -the -input -byte -ranges -and -/ -/ -zero -- -filled -space -for -the -transitions -and -accelerators -if -present -. -/ -/ -In -this -first -pass -we -also -build -up -a -map -from -the -state -identifier -/ -/ -index -of -the -dense -DFA -to -the -state -identifier -in -this -sparse -DFA -. -/ -/ -/ -/ -In -the -second -pass -we -fill -in -the -transitions -based -on -the -map -/ -/ -built -in -the -first -pass -. -/ -/ -The -capacity -given -here -reflects -a -minimum -. -( -Well -the -true -minimum -/ -/ -is -likely -even -bigger -but -hopefully -this -saves -a -few -reallocs -. -) -let -mut -sparse -= -Vec -: -: -with_capacity -( -StateID -: -: -SIZE -* -dfa -. -state_len -( -) -) -; -/ -/ -This -maps -state -indices -from -the -dense -DFA -to -StateIDs -in -the -sparse -/ -/ -DFA -. -We -build -out -this -map -on -the -first -pass -and -then -use -it -in -the -/ -/ -second -pass -to -back -- -fill -our -transitions -. -let -mut -remap -: -Vec -< -StateID -> -= -vec -! -[ -DEAD -; -dfa -. -state_len -( -) -] -; -for -state -in -dfa -. -states -( -) -{ -let -pos -= -sparse -. -len -( -) -; -remap -[ -dfa -. -to_index -( -state -. -id -( -) -) -] -= -StateID -: -: -new -( -pos -) -. -map_err -( -| -_ -| -BuildError -: -: -too_many_states -( -) -) -? -; -/ -/ -zero -- -filled -space -for -the -transition -length -sparse -. -push -( -0 -) -; -sparse -. -push -( -0 -) -; -let -mut -transition_len -= -0 -; -for -( -unit1 -unit2 -_ -) -in -state -. -sparse_transitions -( -) -{ -match -( -unit1 -. -as_u8 -( -) -unit2 -. -as_u8 -( -) -) -{ -( -Some -( -b1 -) -Some -( -b2 -) -) -= -> -{ -transition_len -+ -= -1 -; -sparse -. -push -( -b1 -) -; -sparse -. -push -( -b2 -) -; -} -( -None -None -) -= -> -{ -} -( -Some -( -_ -) -None -) -| -( -None -Some -( -_ -) -) -= -> -{ -/ -/ -can -never -occur -because -sparse_transitions -never -/ -/ -groups -EOI -with -any -other -transition -. -unreachable -! -( -) -} -} -} -/ -/ -Add -dummy -EOI -transition -. -This -is -never -actually -read -while -/ -/ -searching -but -having -space -equivalent -to -the -total -number -/ -/ -of -transitions -is -convenient -. -Otherwise -we -' -d -need -to -track -/ -/ -a -different -number -of -transitions -for -the -byte -ranges -as -for -/ -/ -the -' -next -' -states -. -/ -/ -/ -/ -N -. -B -. -The -loop -above -is -not -guaranteed -to -yield -the -EOI -/ -/ -transition -since -it -may -point -to -a -DEAD -state -. -By -putting -/ -/ -it -here -we -always -write -the -EOI -transition -and -thus -/ -/ -guarantee -that -our -transition -length -is -> -0 -. -Why -do -we -always -/ -/ -need -the -EOI -transition -? -Because -in -order -to -implement -/ -/ -Automaton -: -: -next_eoi_state -this -lets -us -just -ask -for -the -last -/ -/ -transition -. -There -are -probably -other -/ -better -ways -to -do -this -. -transition_len -+ -= -1 -; -sparse -. -push -( -0 -) -; -sparse -. -push -( -0 -) -; -/ -/ -Check -some -assumptions -about -transition -length -. -assert_ne -! -( -transition_len -0 -" -transition -length -should -be -non -- -zero -" -) -; -assert -! -( -transition_len -< -= -257 -" -expected -transition -length -{ -} -to -be -< -= -257 -" -transition_len -) -; -/ -/ -Fill -in -the -transition -length -. -/ -/ -Since -transition -length -is -always -< -= -257 -we -use -the -most -/ -/ -significant -bit -to -indicate -whether -this -is -a -match -state -or -/ -/ -not -. -let -ntrans -= -if -dfa -. -is_match_state -( -state -. -id -( -) -) -{ -transition_len -| -( -1 -< -< -15 -) -} -else -{ -transition_len -} -; -wire -: -: -NE -: -: -write_u16 -( -ntrans -& -mut -sparse -[ -pos -. -. -] -) -; -/ -/ -zero -- -fill -the -actual -transitions -. -/ -/ -Unwraps -are -OK -since -transition_length -< -= -257 -and -our -minimum -/ -/ -support -usize -size -is -16 -- -bits -. -let -zeros -= -usize -: -: -try_from -( -transition_len -) -. -unwrap -( -) -. -checked_mul -( -StateID -: -: -SIZE -) -. -unwrap -( -) -; -sparse -. -extend -( -iter -: -: -repeat -( -0 -) -. -take -( -zeros -) -) -; -/ -/ -If -this -is -a -match -state -write -the -pattern -IDs -matched -by -this -/ -/ -state -. -if -dfa -. -is_match_state -( -state -. -id -( -) -) -{ -let -plen -= -dfa -. -match_pattern_len -( -state -. -id -( -) -) -; -/ -/ -Write -the -actual -pattern -IDs -with -a -u32 -length -prefix -. -/ -/ -First -zero -- -fill -space -. -let -mut -pos -= -sparse -. -len -( -) -; -/ -/ -Unwraps -are -OK -since -it -' -s -guaranteed -that -plen -< -= -/ -/ -PatternID -: -: -LIMIT -which -is -in -turn -guaranteed -to -fit -into -a -/ -/ -u32 -. -let -zeros -= -size_of -: -: -< -u32 -> -( -) -. -checked_mul -( -plen -) -. -unwrap -( -) -. -checked_add -( -size_of -: -: -< -u32 -> -( -) -) -. -unwrap -( -) -; -sparse -. -extend -( -iter -: -: -repeat -( -0 -) -. -take -( -zeros -) -) -; -/ -/ -Now -write -the -length -prefix -. -wire -: -: -NE -: -: -write_u32 -( -/ -/ -Will -never -fail -since -u32 -: -: -MAX -is -invalid -pattern -ID -. -/ -/ -Thus -the -number -of -pattern -IDs -is -representable -by -a -/ -/ -u32 -. -plen -. -try_into -( -) -. -expect -( -" -pattern -ID -length -fits -in -u32 -" -) -& -mut -sparse -[ -pos -. -. -] -) -; -pos -+ -= -size_of -: -: -< -u32 -> -( -) -; -/ -/ -Now -write -the -pattern -IDs -. -for -& -pid -in -dfa -. -pattern_id_slice -( -state -. -id -( -) -) -{ -pos -+ -= -wire -: -: -write_pattern_id -: -: -< -wire -: -: -NE -> -( -pid -& -mut -sparse -[ -pos -. -. -] -) -; -} -} -/ -/ -And -now -add -the -accelerator -if -one -exists -. -An -accelerator -is -/ -/ -at -most -4 -bytes -and -at -least -1 -byte -. -The -first -byte -is -the -/ -/ -length -N -. -N -bytes -follow -the -length -. -The -set -of -bytes -that -/ -/ -follow -correspond -( -exhaustively -) -to -the -bytes -that -must -be -seen -/ -/ -to -leave -this -state -. -let -accel -= -dfa -. -accelerator -( -state -. -id -( -) -) -; -sparse -. -push -( -accel -. -len -( -) -. -try_into -( -) -. -unwrap -( -) -) -; -sparse -. -extend_from_slice -( -accel -) -; -} -let -mut -new -= -DFA -{ -tt -: -Transitions -{ -sparse -classes -: -dfa -. -byte_classes -( -) -. -clone -( -) -state_len -: -dfa -. -state_len -( -) -pattern_len -: -dfa -. -pattern_len -( -) -} -st -: -StartTable -: -: -from_dense_dfa -( -dfa -& -remap -) -? -special -: -dfa -. -special -( -) -. -remap -( -| -id -| -remap -[ -dfa -. -to_index -( -id -) -] -) -pre -: -dfa -. -get_prefilter -( -) -. -map -( -| -p -| -p -. -clone -( -) -) -quitset -: -dfa -. -quitset -( -) -. -clone -( -) -flags -: -dfa -. -flags -( -) -. -clone -( -) -} -; -/ -/ -And -here -' -s -our -second -pass -. -Iterate -over -all -of -the -dense -states -/ -/ -again -and -update -the -transitions -in -each -of -the -states -in -the -/ -/ -sparse -DFA -. -for -old_state -in -dfa -. -states -( -) -{ -let -new_id -= -remap -[ -dfa -. -to_index -( -old_state -. -id -( -) -) -] -; -let -mut -new_state -= -new -. -tt -. -state_mut -( -new_id -) -; -let -sparse -= -old_state -. -sparse_transitions -( -) -; -for -( -i -( -_ -_ -next -) -) -in -sparse -. -enumerate -( -) -{ -let -next -= -remap -[ -dfa -. -to_index -( -next -) -] -; -new_state -. -set_next_at -( -i -next -) -; -} -} -debug -! -( -" -created -sparse -DFA -memory -usage -: -{ -} -( -dense -memory -usage -: -{ -} -) -" -new -. -memory_usage -( -) -dfa -. -memory_usage -( -) -) -; -Ok -( -new -) -} -} -impl -< -T -: -AsRef -< -[ -u8 -] -> -> -DFA -< -T -> -{ -/ -/ -/ -Cheaply -return -a -borrowed -version -of -this -sparse -DFA -. -Specifically -the -/ -/ -/ -DFA -returned -always -uses -& -[ -u8 -] -for -its -transitions -. -pub -fn -as_ref -< -' -a -> -( -& -' -a -self -) -- -> -DFA -< -& -' -a -[ -u8 -] -> -{ -DFA -{ -tt -: -self -. -tt -. -as_ref -( -) -st -: -self -. -st -. -as_ref -( -) -special -: -self -. -special -pre -: -self -. -pre -. -clone -( -) -quitset -: -self -. -quitset -flags -: -self -. -flags -} -} -/ -/ -/ -Return -an -owned -version -of -this -sparse -DFA -. -Specifically -the -DFA -/ -/ -/ -returned -always -uses -Vec -< -u8 -> -for -its -transitions -. -/ -/ -/ -/ -/ -/ -Effectively -this -returns -a -sparse -DFA -whose -transitions -live -on -the -/ -/ -/ -heap -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -fn -to_owned -( -& -self -) -- -> -DFA -< -alloc -: -: -vec -: -: -Vec -< -u8 -> -> -{ -DFA -{ -tt -: -self -. -tt -. -to_owned -( -) -st -: -self -. -st -. -to_owned -( -) -special -: -self -. -special -pre -: -self -. -pre -. -clone -( -) -quitset -: -self -. -quitset -flags -: -self -. -flags -} -} -/ -/ -/ -Returns -the -starting -state -configuration -for -this -DFA -. -/ -/ -/ -/ -/ -/ -The -default -is -[ -StartKind -: -: -Both -] -which -means -the -DFA -supports -both -/ -/ -/ -unanchored -and -anchored -searches -. -However -this -can -generally -lead -to -/ -/ -/ -bigger -DFAs -. -Therefore -a -DFA -might -be -compiled -with -support -for -just -/ -/ -/ -unanchored -or -anchored -searches -. -In -that -case -running -a -search -with -/ -/ -/ -an -unsupported -configuration -will -panic -. -pub -fn -start_kind -( -& -self -) -- -> -StartKind -{ -self -. -st -. -kind -} -/ -/ -/ -Returns -true -only -if -this -DFA -has -starting -states -for -each -pattern -. -/ -/ -/ -/ -/ -/ -When -a -DFA -has -starting -states -for -each -pattern -then -a -search -with -the -/ -/ -/ -DFA -can -be -configured -to -only -look -for -anchored -matches -of -a -specific -/ -/ -/ -pattern -. -Specifically -APIs -like -[ -Automaton -: -: -try_search_fwd -] -can -/ -/ -/ -accept -a -[ -Anchored -: -: -Pattern -] -if -and -only -if -this -method -returns -true -. -/ -/ -/ -Otherwise -an -error -will -be -returned -. -/ -/ -/ -/ -/ -/ -Note -that -if -the -DFA -is -empty -this -always -returns -false -. -pub -fn -starts_for_each_pattern -( -& -self -) -- -> -bool -{ -self -. -st -. -pattern_len -. -is_some -( -) -} -/ -/ -/ -Returns -the -equivalence -classes -that -make -up -the -alphabet -for -this -DFA -. -/ -/ -/ -/ -/ -/ -Unless -[ -dense -: -: -Config -: -: -byte_classes -] -was -disabled -it -is -possible -/ -/ -/ -that -multiple -distinct -bytes -are -grouped -into -the -same -equivalence -/ -/ -/ -class -if -it -is -impossible -for -them -to -discriminate -between -a -match -and -/ -/ -/ -a -non -- -match -. -This -has -the -effect -of -reducing -the -overall -alphabet -size -/ -/ -/ -and -in -turn -potentially -substantially -reducing -the -size -of -the -DFA -' -s -/ -/ -/ -transition -table -. -/ -/ -/ -/ -/ -/ -The -downside -of -using -equivalence -classes -like -this -is -that -every -state -/ -/ -/ -transition -will -automatically -use -this -map -to -convert -an -arbitrary -/ -/ -/ -byte -to -its -corresponding -equivalence -class -. -In -practice -this -has -a -/ -/ -/ -negligible -impact -on -performance -. -pub -fn -byte_classes -( -& -self -) -- -> -& -ByteClasses -{ -& -self -. -tt -. -classes -} -/ -/ -/ -Returns -the -memory -usage -in -bytes -of -this -DFA -. -/ -/ -/ -/ -/ -/ -The -memory -usage -is -computed -based -on -the -number -of -bytes -used -to -/ -/ -/ -represent -this -DFA -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -DFA -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -sparse -: -: -DFA -> -( -) -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -tt -. -memory_usage -( -) -+ -self -. -st -. -memory_usage -( -) -} -} -/ -/ -/ -Routines -for -converting -a -sparse -DFA -to -other -representations -such -as -raw -/ -/ -/ -bytes -suitable -for -persistent -storage -. -impl -< -T -: -AsRef -< -[ -u8 -] -> -> -DFA -< -T -> -{ -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -a -Vec -< -u8 -> -in -little -endian -/ -/ -/ -format -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -Note -that -unlike -a -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -' -s -/ -/ -/ -serialization -methods -this -does -not -add -any -initial -padding -to -the -/ -/ -/ -returned -bytes -. -Padding -isn -' -t -required -for -sparse -DFAs -since -they -have -/ -/ -/ -no -alignment -requirements -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -We -use -native -endianness -here -to -make -the -example -work -but -/ -/ -/ -/ -/ -using -to_bytes_little_endian -would -work -on -a -little -endian -target -. -/ -/ -/ -let -buf -= -original_dfa -. -to_bytes_native_endian -( -) -; -/ -/ -/ -/ -/ -Even -if -buf -has -initial -padding -DFA -: -: -from_bytes -will -automatically -/ -/ -/ -/ -/ -ignore -it -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -DFA -: -: -from_bytes -( -& -buf -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -to_bytes_little_endian -( -& -self -) -- -> -Vec -< -u8 -> -{ -self -. -to_bytes -: -: -< -wire -: -: -LE -> -( -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -a -Vec -< -u8 -> -in -big -endian -/ -/ -/ -format -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -Note -that -unlike -a -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -' -s -/ -/ -/ -serialization -methods -this -does -not -add -any -initial -padding -to -the -/ -/ -/ -returned -bytes -. -Padding -isn -' -t -required -for -sparse -DFAs -since -they -have -/ -/ -/ -no -alignment -requirements -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -We -use -native -endianness -here -to -make -the -example -work -but -/ -/ -/ -/ -/ -using -to_bytes_big_endian -would -work -on -a -big -endian -target -. -/ -/ -/ -let -buf -= -original_dfa -. -to_bytes_native_endian -( -) -; -/ -/ -/ -/ -/ -Even -if -buf -has -initial -padding -DFA -: -: -from_bytes -will -automatically -/ -/ -/ -/ -/ -ignore -it -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -DFA -: -: -from_bytes -( -& -buf -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -to_bytes_big_endian -( -& -self -) -- -> -Vec -< -u8 -> -{ -self -. -to_bytes -: -: -< -wire -: -: -BE -> -( -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -a -Vec -< -u8 -> -in -native -endian -/ -/ -/ -format -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -Note -that -unlike -a -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -' -s -/ -/ -/ -serialization -methods -this -does -not -add -any -initial -padding -to -the -/ -/ -/ -returned -bytes -. -Padding -isn -' -t -required -for -sparse -DFAs -since -they -have -/ -/ -/ -no -alignment -requirements -. -/ -/ -/ -/ -/ -/ -Generally -speaking -native -endian -format -should -only -be -used -when -/ -/ -/ -you -know -that -the -target -you -' -re -compiling -the -DFA -for -matches -the -/ -/ -/ -endianness -of -the -target -on -which -you -' -re -compiling -DFA -. -For -example -/ -/ -/ -if -serialization -and -deserialization -happen -in -the -same -process -or -on -/ -/ -/ -the -same -machine -. -Otherwise -when -serializing -a -DFA -for -use -in -a -/ -/ -/ -portable -environment -you -' -ll -almost -certainly -want -to -serialize -_both_ -/ -/ -/ -a -little -endian -and -a -big -endian -version -and -then -load -the -correct -one -/ -/ -/ -based -on -the -target -' -s -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -let -buf -= -original_dfa -. -to_bytes_native_endian -( -) -; -/ -/ -/ -/ -/ -Even -if -buf -has -initial -padding -DFA -: -: -from_bytes -will -automatically -/ -/ -/ -/ -/ -ignore -it -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -DFA -: -: -from_bytes -( -& -buf -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -fn -to_bytes_native_endian -( -& -self -) -- -> -Vec -< -u8 -> -{ -self -. -to_bytes -: -: -< -wire -: -: -NE -> -( -) -} -/ -/ -/ -The -implementation -of -the -public -to_bytes -serialization -methods -/ -/ -/ -which -is -generic -over -endianness -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -fn -to_bytes -< -E -: -Endian -> -( -& -self -) -- -> -Vec -< -u8 -> -{ -let -mut -buf -= -vec -! -[ -0 -; -self -. -write_to_len -( -) -] -; -/ -/ -This -should -always -succeed -since -the -only -possible -serialization -/ -/ -error -is -providing -a -buffer -that -' -s -too -small -but -we -' -ve -ensured -that -/ -/ -buf -is -big -enough -here -. -self -. -write_to -: -: -< -E -> -( -& -mut -buf -) -. -unwrap -( -) -; -buf -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -the -given -slice -in -little -endian -/ -/ -/ -format -. -Upon -success -the -total -number -of -bytes -written -to -dst -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -given -destination -slice -is -not -big -enough -/ -/ -/ -to -contain -the -full -serialized -DFA -. -If -an -error -occurs -then -nothing -/ -/ -/ -is -written -to -dst -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -without -/ -/ -/ -dynamic -memory -allocation -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Create -a -4KB -buffer -on -the -stack -to -store -our -serialized -DFA -. -/ -/ -/ -let -mut -buf -= -[ -0u8 -; -4 -* -( -1 -< -< -10 -) -] -; -/ -/ -/ -/ -/ -N -. -B -. -We -use -native -endianness -here -to -make -the -example -work -but -/ -/ -/ -/ -/ -using -write_to_little_endian -would -work -on -a -little -endian -target -. -/ -/ -/ -let -written -= -original_dfa -. -write_to_native_endian -( -& -mut -buf -) -? -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -DFA -: -: -from_bytes -( -& -buf -[ -. -. -written -] -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -write_to_little_endian -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -self -. -write_to -: -: -< -wire -: -: -LE -> -( -dst -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -the -given -slice -in -big -endian -/ -/ -/ -format -. -Upon -success -the -total -number -of -bytes -written -to -dst -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -given -destination -slice -is -not -big -enough -/ -/ -/ -to -contain -the -full -serialized -DFA -. -If -an -error -occurs -then -nothing -/ -/ -/ -is -written -to -dst -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -without -/ -/ -/ -dynamic -memory -allocation -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Create -a -4KB -buffer -on -the -stack -to -store -our -serialized -DFA -. -/ -/ -/ -let -mut -buf -= -[ -0u8 -; -4 -* -( -1 -< -< -10 -) -] -; -/ -/ -/ -/ -/ -N -. -B -. -We -use -native -endianness -here -to -make -the -example -work -but -/ -/ -/ -/ -/ -using -write_to_big_endian -would -work -on -a -big -endian -target -. -/ -/ -/ -let -written -= -original_dfa -. -write_to_native_endian -( -& -mut -buf -) -? -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -DFA -: -: -from_bytes -( -& -buf -[ -. -. -written -] -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -write_to_big_endian -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -self -. -write_to -: -: -< -wire -: -: -BE -> -( -dst -) -} -/ -/ -/ -Serialize -this -DFA -as -raw -bytes -to -the -given -slice -in -native -endian -/ -/ -/ -format -. -Upon -success -the -total -number -of -bytes -written -to -dst -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -The -written -bytes -are -guaranteed -to -be -deserialized -correctly -and -/ -/ -/ -without -errors -in -a -semver -compatible -release -of -this -crate -by -a -/ -/ -/ -DFA -' -s -deserialization -APIs -( -assuming -all -other -criteria -for -the -/ -/ -/ -deserialization -APIs -has -been -satisfied -) -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -from_bytes -] -/ -/ -/ -* -[ -DFA -: -: -from_bytes_unchecked -] -/ -/ -/ -/ -/ -/ -Generally -speaking -native -endian -format -should -only -be -used -when -/ -/ -/ -you -know -that -the -target -you -' -re -compiling -the -DFA -for -matches -the -/ -/ -/ -endianness -of -the -target -on -which -you -' -re -compiling -DFA -. -For -example -/ -/ -/ -if -serialization -and -deserialization -happen -in -the -same -process -or -on -/ -/ -/ -the -same -machine -. -Otherwise -when -serializing -a -DFA -for -use -in -a -/ -/ -/ -portable -environment -you -' -ll -almost -certainly -want -to -serialize -_both_ -/ -/ -/ -a -little -endian -and -a -big -endian -version -and -then -load -the -correct -one -/ -/ -/ -based -on -the -target -' -s -configuration -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -given -destination -slice -is -not -big -enough -/ -/ -/ -to -contain -the -full -serialized -DFA -. -If -an -error -occurs -then -nothing -/ -/ -/ -is -written -to -dst -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -and -deserialize -a -DFA -without -/ -/ -/ -dynamic -memory -allocation -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Create -a -4KB -buffer -on -the -stack -to -store -our -serialized -DFA -. -/ -/ -/ -let -mut -buf -= -[ -0u8 -; -4 -* -( -1 -< -< -10 -) -] -; -/ -/ -/ -let -written -= -original_dfa -. -write_to_native_endian -( -& -mut -buf -) -? -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -DFA -: -: -from_bytes -( -& -buf -[ -. -. -written -] -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -write_to_native_endian -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -self -. -write_to -: -: -< -wire -: -: -NE -> -( -dst -) -} -/ -/ -/ -The -implementation -of -the -public -write_to -serialization -methods -/ -/ -/ -which -is -generic -over -endianness -. -fn -write_to -< -E -: -Endian -> -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -mut -nw -= -0 -; -nw -+ -= -wire -: -: -write_label -( -LABEL -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -wire -: -: -write_endianness_check -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -wire -: -: -write_version -: -: -< -E -> -( -VERSION -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -{ -/ -/ -Currently -unused -intended -for -future -flexibility -E -: -: -write_u32 -( -0 -& -mut -dst -[ -nw -. -. -] -) -; -size_of -: -: -< -u32 -> -( -) -} -; -nw -+ -= -self -. -flags -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -tt -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -st -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -special -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -nw -+ -= -self -. -quitset -. -write_to -: -: -< -E -> -( -& -mut -dst -[ -nw -. -. -] -) -? -; -Ok -( -nw -) -} -/ -/ -/ -Return -the -total -number -of -bytes -required -to -serialize -this -DFA -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -determining -the -size -of -the -buffer -required -to -pass -/ -/ -/ -to -one -of -the -serialization -routines -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -write_to_little_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_big_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_native_endian -] -/ -/ -/ -/ -/ -/ -Passing -a -buffer -smaller -than -the -size -returned -by -this -method -will -/ -/ -/ -result -in -a -serialization -error -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -dynamically -allocate -enough -room -to -serialize -/ -/ -/ -a -sparse -DFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -our -original -DFA -. -/ -/ -/ -let -original_dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -buf -= -vec -! -[ -0 -; -original_dfa -. -write_to_len -( -) -] -; -/ -/ -/ -let -written -= -original_dfa -. -write_to_native_endian -( -& -mut -buf -) -? -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -DFA -: -: -from_bytes -( -& -buf -[ -. -. -written -] -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -write_to_len -( -& -self -) -- -> -usize -{ -wire -: -: -write_label_len -( -LABEL -) -+ -wire -: -: -write_endianness_check_len -( -) -+ -wire -: -: -write_version_len -( -) -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -unused -intended -for -future -flexibility -+ -self -. -flags -. -write_to_len -( -) -+ -self -. -tt -. -write_to_len -( -) -+ -self -. -st -. -write_to_len -( -) -+ -self -. -special -. -write_to_len -( -) -+ -self -. -quitset -. -write_to_len -( -) -} -} -impl -< -' -a -> -DFA -< -& -' -a -[ -u8 -] -> -{ -/ -/ -/ -Safely -deserialize -a -sparse -DFA -with -a -specific -state -identifier -/ -/ -/ -representation -. -Upon -success -this -returns -both -the -deserialized -DFA -/ -/ -/ -and -the -number -of -bytes -read -from -the -given -slice -. -Namely -the -contents -/ -/ -/ -of -the -slice -beyond -the -DFA -are -not -read -. -/ -/ -/ -/ -/ -/ -Deserializing -a -DFA -using -this -routine -will -never -allocate -heap -memory -. -/ -/ -/ -For -safety -purposes -the -DFA -' -s -transitions -will -be -verified -such -that -/ -/ -/ -every -transition -points -to -a -valid -state -. -If -this -verification -is -too -/ -/ -/ -costly -then -a -[ -DFA -: -: -from_bytes_unchecked -] -API -is -provided -which -/ -/ -/ -will -always -execute -in -constant -time -. -/ -/ -/ -/ -/ -/ -The -bytes -given -must -be -generated -by -one -of -the -serialization -APIs -/ -/ -/ -of -a -DFA -using -a -semver -compatible -release -of -this -crate -. -Those -/ -/ -/ -include -: -/ -/ -/ -/ -/ -/ -* -[ -DFA -: -: -to_bytes_little_endian -] -/ -/ -/ -* -[ -DFA -: -: -to_bytes_big_endian -] -/ -/ -/ -* -[ -DFA -: -: -to_bytes_native_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_little_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_big_endian -] -/ -/ -/ -* -[ -DFA -: -: -write_to_native_endian -] -/ -/ -/ -/ -/ -/ -The -to_bytes -methods -allocate -and -return -a -Vec -< -u8 -> -for -you -. -The -/ -/ -/ -write_to -methods -do -not -allocate -and -write -to -an -existing -slice -/ -/ -/ -( -which -may -be -on -the -stack -) -. -Since -deserialization -always -uses -the -/ -/ -/ -native -endianness -of -the -target -platform -the -serialization -API -you -use -/ -/ -/ -should -match -the -endianness -of -the -target -platform -. -( -It -' -s -often -a -good -/ -/ -/ -idea -to -generate -serialized -DFAs -for -both -forms -of -endianness -and -then -/ -/ -/ -load -the -correct -one -based -on -endianness -. -) -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -Generally -speaking -it -' -s -easier -to -state -the -conditions -in -which -an -/ -/ -/ -error -is -_not_ -returned -. -All -of -the -following -must -be -true -: -/ -/ -/ -/ -/ -/ -* -The -bytes -given -must -be -produced -by -one -of -the -serialization -APIs -/ -/ -/ -on -this -DFA -as -mentioned -above -. -/ -/ -/ -* -The -endianness -of -the -target -platform -matches -the -endianness -used -to -/ -/ -/ -serialized -the -provided -DFA -. -/ -/ -/ -/ -/ -/ -If -any -of -the -above -are -not -true -then -an -error -will -be -returned -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -deserializing -a -/ -/ -/ -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -deserializing -a -sparse -DFA -has -/ -/ -/ -no -alignment -requirements -. -That -is -an -alignment -of -1 -is -valid -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -will -never -panic -for -any -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -serialize -a -DFA -to -raw -bytes -deserialize -it -/ -/ -/ -and -then -use -it -for -searching -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -initial -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -bytes -= -initial -. -to_bytes_native_endian -( -) -; -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -DFA -: -: -from_bytes -( -& -bytes -) -? -. -0 -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -loading -a -DFA -from -static -memory -/ -/ -/ -/ -/ -/ -One -use -case -this -library -supports -is -the -ability -to -serialize -a -/ -/ -/ -DFA -to -disk -and -then -use -include_bytes -! -to -store -it -in -a -compiled -/ -/ -/ -Rust -program -. -Those -bytes -can -then -be -cheaply -deserialized -into -a -/ -/ -/ -DFA -structure -at -runtime -and -used -for -searching -without -having -to -/ -/ -/ -re -- -compile -the -DFA -( -which -can -be -quite -costly -) -. -/ -/ -/ -/ -/ -/ -We -can -show -this -in -two -parts -. -The -first -part -is -serializing -the -DFA -to -/ -/ -/ -a -file -: -/ -/ -/ -/ -/ -/ -no_run -/ -/ -/ -use -regex_automata -: -: -dfa -: -: -sparse -: -: -DFA -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Write -a -big -endian -serialized -version -of -this -DFA -to -a -file -. -/ -/ -/ -let -bytes -= -dfa -. -to_bytes_big_endian -( -) -; -/ -/ -/ -std -: -: -fs -: -: -write -( -" -foo -. -bigendian -. -dfa -" -& -bytes -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Do -it -again -but -this -time -for -little -endian -. -/ -/ -/ -let -bytes -= -dfa -. -to_bytes_little_endian -( -) -; -/ -/ -/ -std -: -: -fs -: -: -write -( -" -foo -. -littleendian -. -dfa -" -& -bytes -) -? -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -now -the -second -part -is -embedding -the -DFA -into -the -compiled -program -/ -/ -/ -and -deserializing -it -at -runtime -on -first -use -. -We -use -conditional -/ -/ -/ -compilation -to -choose -the -correct -endianness -. -We -do -not -need -to -employ -/ -/ -/ -any -special -tricks -to -ensure -a -proper -alignment -since -a -sparse -DFA -has -/ -/ -/ -no -alignment -requirements -. -/ -/ -/ -/ -/ -/ -no_run -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -/ -/ -/ -util -: -: -lazy -: -: -Lazy -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -This -crate -provides -its -own -" -lazy -" -type -kind -of -like -/ -/ -/ -/ -/ -lazy_static -! -or -once_cell -: -: -sync -: -: -Lazy -. -But -it -works -in -no -- -alloc -/ -/ -/ -/ -/ -no -- -std -environments -and -let -' -s -us -write -this -using -completely -/ -/ -/ -/ -/ -safe -code -. -/ -/ -/ -static -RE -: -Lazy -< -DFA -< -& -' -static -[ -u8 -] -> -> -= -Lazy -: -: -new -( -| -| -{ -/ -/ -/ -# -const -_ -: -& -str -= -stringify -! -{ -/ -/ -/ -# -[ -cfg -( -target_endian -= -" -big -" -) -] -/ -/ -/ -static -BYTES -: -& -[ -u8 -] -= -include_bytes -! -( -" -foo -. -bigendian -. -dfa -" -) -; -/ -/ -/ -# -[ -cfg -( -target_endian -= -" -little -" -) -] -/ -/ -/ -static -BYTES -: -& -[ -u8 -] -= -include_bytes -! -( -" -foo -. -littleendian -. -dfa -" -) -; -/ -/ -/ -# -} -; -/ -/ -/ -# -static -BYTES -: -& -[ -u8 -] -= -b -" -" -; -/ -/ -/ -/ -/ -/ -let -( -dfa -_ -) -= -DFA -: -: -from_bytes -( -BYTES -) -/ -/ -/ -. -expect -( -" -serialized -DFA -should -be -valid -" -) -; -/ -/ -/ -dfa -/ -/ -/ -} -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Ok -( -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -RE -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Alternatively -consider -using -/ -/ -/ -[ -lazy_static -] -( -https -: -/ -/ -crates -. -io -/ -crates -/ -lazy_static -) -/ -/ -/ -or -/ -/ -/ -[ -once_cell -] -( -https -: -/ -/ -crates -. -io -/ -crates -/ -once_cell -) -/ -/ -/ -which -will -guarantee -safety -for -you -. -pub -fn -from_bytes -( -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -DFA -< -& -' -a -[ -u8 -] -> -usize -) -DeserializeError -> -{ -/ -/ -SAFETY -: -This -is -safe -because -we -validate -both -the -sparse -transitions -/ -/ -( -by -trying -to -decode -every -state -) -and -start -state -ID -list -below -. -If -/ -/ -either -validation -fails -then -we -return -an -error -. -let -( -dfa -nread -) -= -unsafe -{ -DFA -: -: -from_bytes_unchecked -( -slice -) -? -} -; -dfa -. -tt -. -validate -( -& -dfa -. -special -) -? -; -dfa -. -st -. -validate -( -& -dfa -. -special -& -dfa -. -tt -) -? -; -/ -/ -N -. -B -. -dfa -. -special -doesn -' -t -have -a -way -to -do -unchecked -deserialization -/ -/ -so -it -has -already -been -validated -. -Ok -( -( -dfa -nread -) -) -} -/ -/ -/ -Deserialize -a -DFA -with -a -specific -state -identifier -representation -in -/ -/ -/ -constant -time -by -omitting -the -verification -of -the -validity -of -the -/ -/ -/ -sparse -transitions -. -/ -/ -/ -/ -/ -/ -This -is -just -like -[ -DFA -: -: -from_bytes -] -except -it -can -potentially -return -/ -/ -/ -a -DFA -that -exhibits -undefined -behavior -if -its -transitions -contains -/ -/ -/ -invalid -state -identifiers -. -/ -/ -/ -/ -/ -/ -This -routine -is -useful -if -you -need -to -deserialize -a -DFA -cheaply -and -/ -/ -/ -cannot -afford -the -transition -validation -performed -by -from_bytes -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -This -routine -is -not -safe -because -it -permits -callers -to -provide -/ -/ -/ -arbitrary -transitions -with -possibly -incorrect -state -identifiers -. -While -/ -/ -/ -the -various -serialization -routines -will -never -return -an -incorrect -/ -/ -/ -DFA -there -is -no -guarantee -that -the -bytes -provided -here -are -correct -. -/ -/ -/ -While -from_bytes_unchecked -will -still -do -several -forms -of -basic -/ -/ -/ -validation -this -routine -does -not -check -that -the -transitions -themselves -/ -/ -/ -are -correct -. -Given -an -incorrect -transition -table -it -is -possible -for -/ -/ -/ -the -search -routines -to -access -out -- -of -- -bounds -memory -because -of -explicit -/ -/ -/ -bounds -check -elision -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -sparse -: -: -DFA -} -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -initial -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -bytes -= -initial -. -to_bytes_native_endian -( -) -; -/ -/ -/ -/ -/ -SAFETY -: -This -is -guaranteed -to -be -safe -since -the -bytes -given -come -/ -/ -/ -/ -/ -directly -from -a -compatible -serialization -routine -. -/ -/ -/ -let -dfa -: -DFA -< -& -[ -u8 -] -> -= -unsafe -{ -DFA -: -: -from_bytes_unchecked -( -& -bytes -) -? -. -0 -} -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -unsafe -fn -from_bytes_unchecked -( -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -DFA -< -& -' -a -[ -u8 -] -> -usize -) -DeserializeError -> -{ -let -mut -nr -= -0 -; -nr -+ -= -wire -: -: -read_label -( -& -slice -[ -nr -. -. -] -LABEL -) -? -; -nr -+ -= -wire -: -: -read_endianness_check -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -wire -: -: -read_version -( -& -slice -[ -nr -. -. -] -VERSION -) -? -; -let -_unused -= -wire -: -: -try_read_u32 -( -& -slice -[ -nr -. -. -] -" -unused -space -" -) -? -; -nr -+ -= -size_of -: -: -< -u32 -> -( -) -; -let -( -flags -nread -) -= -Flags -: -: -from_bytes -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -let -( -tt -nread -) -= -Transitions -: -: -from_bytes_unchecked -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -let -( -st -nread -) -= -StartTable -: -: -from_bytes_unchecked -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -let -( -special -nread -) -= -Special -: -: -from_bytes -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -if -special -. -max -. -as_usize -( -) -> -= -tt -. -sparse -( -) -. -len -( -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -max -should -not -be -greater -than -or -equal -to -sparse -bytes -" -) -) -; -} -let -( -quitset -nread -) -= -ByteSet -: -: -from_bytes -( -& -slice -[ -nr -. -. -] -) -? -; -nr -+ -= -nread -; -/ -/ -Prefilters -don -' -t -support -serialization -so -they -' -re -always -absent -. -let -pre -= -None -; -Ok -( -( -DFA -{ -tt -st -special -pre -quitset -flags -} -nr -) -) -} -} -impl -< -T -: -AsRef -< -[ -u8 -] -> -> -fmt -: -: -Debug -for -DFA -< -T -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -writeln -! -( -f -" -sparse -: -: -DFA -( -" -) -? -; -for -state -in -self -. -tt -. -states -( -) -{ -fmt_state_indicator -( -f -self -state -. -id -( -) -) -? -; -writeln -! -( -f -" -{ -: -06 -? -} -: -{ -: -? -} -" -state -. -id -( -) -. -as_usize -( -) -state -) -? -; -} -writeln -! -( -f -" -" -) -? -; -for -( -i -( -start_id -anchored -sty -) -) -in -self -. -st -. -iter -( -) -. -enumerate -( -) -{ -if -i -% -self -. -st -. -stride -= -= -0 -{ -match -anchored -{ -Anchored -: -: -No -= -> -writeln -! -( -f -" -START -- -GROUP -( -unanchored -) -" -) -? -Anchored -: -: -Yes -= -> -writeln -! -( -f -" -START -- -GROUP -( -anchored -) -" -) -? -Anchored -: -: -Pattern -( -pid -) -= -> -writeln -! -( -f -" -START_GROUP -( -pattern -: -{ -: -? -} -) -" -pid -. -as_usize -( -) -) -? -} -} -writeln -! -( -f -" -{ -: -? -} -= -> -{ -: -06 -? -} -" -sty -start_id -. -as_usize -( -) -) -? -; -} -writeln -! -( -f -" -state -length -: -{ -: -? -} -" -self -. -tt -. -state_len -) -? -; -writeln -! -( -f -" -pattern -length -: -{ -: -? -} -" -self -. -pattern_len -( -) -) -? -; -writeln -! -( -f -" -flags -: -{ -: -? -} -" -self -. -flags -) -? -; -writeln -! -( -f -" -) -" -) -? -; -Ok -( -( -) -) -} -} -/ -/ -SAFETY -: -We -assert -that -our -implementation -of -each -method -is -correct -. -unsafe -impl -< -T -: -AsRef -< -[ -u8 -] -> -> -Automaton -for -DFA -< -T -> -{ -# -[ -inline -] -fn -is_special_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_special_state -( -id -) -} -# -[ -inline -] -fn -is_dead_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_dead_state -( -id -) -} -# -[ -inline -] -fn -is_quit_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_quit_state -( -id -) -} -# -[ -inline -] -fn -is_match_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_match_state -( -id -) -} -# -[ -inline -] -fn -is_start_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_start_state -( -id -) -} -# -[ -inline -] -fn -is_accel_state -( -& -self -id -: -StateID -) -- -> -bool -{ -self -. -special -. -is_accel_state -( -id -) -} -/ -/ -This -is -marked -as -inline -to -help -dramatically -boost -sparse -searching -/ -/ -which -decodes -each -state -it -enters -to -follow -the -next -transition -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -next_state -( -& -self -current -: -StateID -input -: -u8 -) -- -> -StateID -{ -let -input -= -self -. -tt -. -classes -. -get -( -input -) -; -self -. -tt -. -state -( -current -) -. -next -( -input -) -} -# -[ -inline -] -unsafe -fn -next_state_unchecked -( -& -self -current -: -StateID -input -: -u8 -) -- -> -StateID -{ -self -. -next_state -( -current -input -) -} -# -[ -inline -] -fn -next_eoi_state -( -& -self -current -: -StateID -) -- -> -StateID -{ -self -. -tt -. -state -( -current -) -. -next_eoi -( -) -} -# -[ -inline -] -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -tt -. -pattern_len -} -# -[ -inline -] -fn -match_len -( -& -self -id -: -StateID -) -- -> -usize -{ -self -. -tt -. -state -( -id -) -. -pattern_len -( -) -} -# -[ -inline -] -fn -match_pattern -( -& -self -id -: -StateID -match_index -: -usize -) -- -> -PatternID -{ -/ -/ -This -is -an -optimization -for -the -very -common -case -of -a -DFA -with -a -/ -/ -single -pattern -. -This -conditional -avoids -a -somewhat -more -costly -path -/ -/ -that -finds -the -pattern -ID -from -the -state -machine -which -requires -/ -/ -a -bit -of -slicing -/ -pointer -- -chasing -. -This -optimization -tends -to -only -/ -/ -matter -when -matches -are -frequent -. -if -self -. -tt -. -pattern_len -= -= -1 -{ -return -PatternID -: -: -ZERO -; -} -self -. -tt -. -state -( -id -) -. -pattern_id -( -match_index -) -} -# -[ -inline -] -fn -has_empty -( -& -self -) -- -> -bool -{ -self -. -flags -. -has_empty -} -# -[ -inline -] -fn -is_utf8 -( -& -self -) -- -> -bool -{ -self -. -flags -. -is_utf8 -} -# -[ -inline -] -fn -is_always_start_anchored -( -& -self -) -- -> -bool -{ -self -. -flags -. -is_always_start_anchored -} -# -[ -inline -] -fn -start_state_forward -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -{ -if -! -self -. -quitset -. -is_empty -( -) -& -& -input -. -start -( -) -> -0 -{ -let -offset -= -input -. -start -( -) -- -1 -; -let -byte -= -input -. -haystack -( -) -[ -offset -] -; -if -self -. -quitset -. -contains -( -byte -) -{ -return -Err -( -MatchError -: -: -quit -( -byte -offset -) -) -; -} -} -let -start -= -self -. -st -. -start_map -. -fwd -( -& -input -) -; -self -. -st -. -start -( -input -start -) -} -# -[ -inline -] -fn -start_state_reverse -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -StateID -MatchError -> -{ -if -! -self -. -quitset -. -is_empty -( -) -& -& -input -. -end -( -) -< -input -. -haystack -( -) -. -len -( -) -{ -let -offset -= -input -. -end -( -) -; -let -byte -= -input -. -haystack -( -) -[ -offset -] -; -if -self -. -quitset -. -contains -( -byte -) -{ -return -Err -( -MatchError -: -: -quit -( -byte -offset -) -) -; -} -} -let -start -= -self -. -st -. -start_map -. -rev -( -& -input -) -; -self -. -st -. -start -( -input -start -) -} -# -[ -inline -] -fn -universal_start_state -( -& -self -mode -: -Anchored -) -- -> -Option -< -StateID -> -{ -match -mode -{ -Anchored -: -: -No -= -> -self -. -st -. -universal_start_unanchored -Anchored -: -: -Yes -= -> -self -. -st -. -universal_start_anchored -Anchored -: -: -Pattern -( -_ -) -= -> -None -} -} -# -[ -inline -] -fn -accelerator -( -& -self -id -: -StateID -) -- -> -& -[ -u8 -] -{ -self -. -tt -. -state -( -id -) -. -accelerator -( -) -} -# -[ -inline -] -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -self -. -pre -. -as_ref -( -) -} -} -/ -/ -/ -The -transition -table -portion -of -a -sparse -DFA -. -/ -/ -/ -/ -/ -/ -The -transition -table -is -the -core -part -of -the -DFA -in -that -it -describes -how -/ -/ -/ -to -move -from -one -state -to -another -based -on -the -input -sequence -observed -. -/ -/ -/ -/ -/ -/ -Unlike -a -typical -dense -table -based -DFA -states -in -a -sparse -transition -/ -/ -/ -table -have -variable -size -. -That -is -states -with -more -transitions -use -more -/ -/ -/ -space -than -states -with -fewer -transitions -. -This -means -that -finding -the -next -/ -/ -/ -transition -takes -more -work -than -with -a -dense -DFA -but -also -typically -uses -/ -/ -/ -much -less -space -. -# -[ -derive -( -Clone -) -] -struct -Transitions -< -T -> -{ -/ -/ -/ -The -raw -encoding -of -each -state -in -this -DFA -. -/ -/ -/ -/ -/ -/ -Each -state -has -the -following -information -: -/ -/ -/ -/ -/ -/ -* -A -set -of -transitions -to -subsequent -states -. -Transitions -to -the -dead -/ -/ -/ -state -are -omitted -. -/ -/ -/ -* -If -the -state -can -be -accelerated -then -any -additional -accelerator -/ -/ -/ -information -. -/ -/ -/ -* -If -the -state -is -a -match -state -then -the -state -contains -all -pattern -/ -/ -/ -IDs -that -match -when -in -that -state -. -/ -/ -/ -/ -/ -/ -To -decode -a -state -use -Transitions -: -: -state -. -/ -/ -/ -/ -/ -/ -In -practice -T -is -either -Vec -< -u8 -> -or -& -[ -u8 -] -. -sparse -: -T -/ -/ -/ -A -set -of -equivalence -classes -where -a -single -equivalence -class -/ -/ -/ -represents -a -set -of -bytes -that -never -discriminate -between -a -match -/ -/ -/ -and -a -non -- -match -in -the -DFA -. -Each -equivalence -class -corresponds -to -a -/ -/ -/ -single -character -in -this -DFA -' -s -alphabet -where -the -maximum -number -of -/ -/ -/ -characters -is -257 -( -each -possible -value -of -a -byte -plus -the -special -/ -/ -/ -EOI -transition -) -. -Consequently -the -number -of -equivalence -classes -/ -/ -/ -corresponds -to -the -number -of -transitions -for -each -DFA -state -. -Note -/ -/ -/ -though -that -the -* -space -* -used -by -each -DFA -state -in -the -transition -table -/ -/ -/ -may -be -larger -. -The -total -space -used -by -each -DFA -state -is -known -as -the -/ -/ -/ -stride -and -is -documented -above -. -/ -/ -/ -/ -/ -/ -The -only -time -the -number -of -equivalence -classes -is -fewer -than -257 -is -/ -/ -/ -if -the -DFA -' -s -kind -uses -byte -classes -which -is -the -default -. -Equivalence -/ -/ -/ -classes -should -generally -only -be -disabled -when -debugging -so -that -/ -/ -/ -the -transitions -themselves -aren -' -t -obscured -. -Disabling -them -has -no -/ -/ -/ -other -benefit -since -the -equivalence -class -map -is -always -used -while -/ -/ -/ -searching -. -In -the -vast -majority -of -cases -the -number -of -equivalence -/ -/ -/ -classes -is -substantially -smaller -than -257 -particularly -when -large -/ -/ -/ -Unicode -classes -aren -' -t -used -. -/ -/ -/ -/ -/ -/ -N -. -B -. -Equivalence -classes -aren -' -t -particularly -useful -in -a -sparse -DFA -/ -/ -/ -in -the -current -implementation -since -equivalence -classes -generally -tend -/ -/ -/ -to -correspond -to -continuous -ranges -of -bytes -that -map -to -the -same -/ -/ -/ -transition -. -So -in -a -sparse -DFA -equivalence -classes -don -' -t -really -lead -/ -/ -/ -to -a -space -savings -. -In -the -future -it -would -be -good -to -try -and -remove -/ -/ -/ -them -from -sparse -DFAs -entirely -but -requires -a -bit -of -work -since -sparse -/ -/ -/ -DFAs -are -built -from -dense -DFAs -which -are -in -turn -built -on -top -of -/ -/ -/ -equivalence -classes -. -classes -: -ByteClasses -/ -/ -/ -The -total -number -of -states -in -this -DFA -. -Note -that -a -DFA -always -has -at -/ -/ -/ -least -one -state -- -- -- -the -dead -state -- -- -- -even -the -empty -DFA -. -In -particular -/ -/ -/ -the -dead -state -always -has -ID -0 -and -is -correspondingly -always -the -first -/ -/ -/ -state -. -The -dead -state -is -never -a -match -state -. -state_len -: -usize -/ -/ -/ -The -total -number -of -unique -patterns -represented -by -these -match -states -. -pattern_len -: -usize -} -impl -< -' -a -> -Transitions -< -& -' -a -[ -u8 -] -> -{ -unsafe -fn -from_bytes_unchecked -( -mut -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -Transitions -< -& -' -a -[ -u8 -] -> -usize -) -DeserializeError -> -{ -let -slice_start -= -slice -. -as_ptr -( -) -. -as_usize -( -) -; -let -( -state_len -nr -) -= -wire -: -: -try_read_u32_as_usize -( -& -slice -" -state -length -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -pattern_len -nr -) -= -wire -: -: -try_read_u32_as_usize -( -& -slice -" -pattern -length -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -classes -nr -) -= -ByteClasses -: -: -from_bytes -( -& -slice -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -len -nr -) -= -wire -: -: -try_read_u32_as_usize -( -& -slice -" -sparse -transitions -length -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -wire -: -: -check_slice_len -( -slice -len -" -sparse -states -byte -length -" -) -? -; -let -sparse -= -& -slice -[ -. -. -len -] -; -slice -= -& -slice -[ -len -. -. -] -; -let -trans -= -Transitions -{ -sparse -classes -state_len -pattern_len -} -; -Ok -( -( -trans -slice -. -as_ptr -( -) -. -as_usize -( -) -- -slice_start -) -) -} -} -impl -< -T -: -AsRef -< -[ -u8 -] -> -> -Transitions -< -T -> -{ -/ -/ -/ -Writes -a -serialized -form -of -this -transition -table -to -the -buffer -given -. -/ -/ -/ -If -the -buffer -is -too -small -then -an -error -is -returned -. -To -determine -/ -/ -/ -how -big -the -buffer -must -be -use -write_to_len -. -fn -write_to -< -E -: -Endian -> -( -& -self -mut -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -sparse -transition -table -" -) -) -; -} -dst -= -& -mut -dst -[ -. -. -nwrite -] -; -/ -/ -write -state -length -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -state_len -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -pattern -length -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -pattern_len -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -byte -class -map -let -n -= -self -. -classes -. -write_to -( -dst -) -? -; -dst -= -& -mut -dst -[ -n -. -. -] -; -/ -/ -write -number -of -bytes -in -sparse -transitions -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -sparse -( -) -. -len -( -) -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -actual -transitions -let -mut -id -= -DEAD -; -while -id -. -as_usize -( -) -< -self -. -sparse -( -) -. -len -( -) -{ -let -state -= -self -. -state -( -id -) -; -let -n -= -state -. -write_to -: -: -< -E -> -( -& -mut -dst -) -? -; -dst -= -& -mut -dst -[ -n -. -. -] -; -/ -/ -The -next -ID -is -the -offset -immediately -following -state -. -id -= -StateID -: -: -new -( -id -. -as_usize -( -) -+ -state -. -write_to_len -( -) -) -. -unwrap -( -) -; -} -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -number -of -bytes -the -serialized -form -of -this -transition -/ -/ -/ -table -will -use -. -fn -write_to_len -( -& -self -) -- -> -usize -{ -size_of -: -: -< -u32 -> -( -) -/ -/ -state -length -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -pattern -length -+ -self -. -classes -. -write_to_len -( -) -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -sparse -transitions -length -+ -self -. -sparse -( -) -. -len -( -) -} -/ -/ -/ -Validates -that -every -state -ID -in -this -transition -table -is -valid -. -/ -/ -/ -/ -/ -/ -That -is -every -state -ID -can -be -used -to -correctly -index -a -state -in -this -/ -/ -/ -table -. -fn -validate -( -& -self -sp -: -& -Special -) -- -> -Result -< -( -) -DeserializeError -> -{ -/ -/ -In -order -to -validate -everything -we -not -only -need -to -make -sure -we -/ -/ -can -decode -every -state -but -that -every -transition -in -every -state -/ -/ -points -to -a -valid -state -. -There -are -many -duplicative -transitions -so -/ -/ -we -record -state -IDs -that -we -' -ve -verified -so -that -we -don -' -t -redo -the -/ -/ -decoding -work -. -/ -/ -/ -/ -Except -when -in -no_std -mode -we -don -' -t -have -dynamic -memory -allocation -/ -/ -available -to -us -so -we -skip -this -optimization -. -It -' -s -not -clear -/ -/ -whether -doing -something -more -clever -is -worth -it -just -yet -. -If -you -' -re -/ -/ -profiling -this -code -and -need -it -to -run -faster -please -file -an -issue -. -/ -/ -/ -/ -OK -so -we -also -use -this -to -record -the -set -of -valid -state -IDs -. -Since -/ -/ -it -is -possible -for -a -transition -to -point -to -an -invalid -state -ID -that -/ -/ -still -( -somehow -) -deserializes -to -a -valid -state -. -So -we -need -to -make -/ -/ -sure -our -transitions -are -limited -to -actually -correct -state -IDs -. -/ -/ -The -problem -is -I -' -m -not -sure -how -to -do -this -verification -step -in -/ -/ -no -- -std -no -- -alloc -mode -. -I -think -we -' -d -* -have -* -to -store -the -set -of -valid -/ -/ -state -IDs -in -the -DFA -itself -. -For -now -we -don -' -t -do -this -verification -/ -/ -in -no -- -std -no -- -alloc -mode -. -The -worst -thing -that -can -happen -is -an -/ -/ -incorrect -result -. -But -no -panics -or -memory -safety -problems -should -/ -/ -result -. -Because -we -still -do -validate -that -the -state -itself -is -/ -/ -" -valid -" -in -the -sense -that -everything -it -points -to -actually -exists -. -/ -/ -/ -/ -- -- -- -AG -struct -Seen -{ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -set -: -alloc -: -: -collections -: -: -BTreeSet -< -StateID -> -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -set -: -core -: -: -marker -: -: -PhantomData -< -StateID -> -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -Seen -{ -fn -new -( -) -- -> -Seen -{ -Seen -{ -set -: -alloc -: -: -collections -: -: -BTreeSet -: -: -new -( -) -} -} -fn -insert -( -& -mut -self -id -: -StateID -) -{ -self -. -set -. -insert -( -id -) -; -} -fn -contains -( -& -self -id -: -& -StateID -) -- -> -bool -{ -self -. -set -. -contains -( -id -) -} -} -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -impl -Seen -{ -fn -new -( -) -- -> -Seen -{ -Seen -{ -set -: -core -: -: -marker -: -: -PhantomData -} -} -fn -insert -( -& -mut -self -_id -: -StateID -) -{ -} -fn -contains -( -& -self -_id -: -& -StateID -) -- -> -bool -{ -false -} -} -let -mut -verified -: -Seen -= -Seen -: -: -new -( -) -; -/ -/ -We -need -to -make -sure -that -we -decode -the -correct -number -of -states -. -/ -/ -Otherwise -an -empty -set -of -transitions -would -validate -even -if -the -/ -/ -recorded -state -length -is -non -- -empty -. -let -mut -len -= -0 -; -/ -/ -We -can -' -t -use -the -self -. -states -( -) -iterator -because -it -assumes -the -state -/ -/ -encodings -are -valid -. -It -could -panic -if -they -aren -' -t -. -let -mut -id -= -DEAD -; -while -id -. -as_usize -( -) -< -self -. -sparse -( -) -. -len -( -) -{ -/ -/ -Before -we -even -decode -the -state -we -check -that -the -ID -itself -/ -/ -is -well -formed -. -That -is -if -it -' -s -a -special -state -then -it -must -/ -/ -actually -be -a -quit -dead -accel -match -or -start -state -. -if -sp -. -is_special_state -( -id -) -{ -let -is_actually_special -= -sp -. -is_dead_state -( -id -) -| -| -sp -. -is_quit_state -( -id -) -| -| -sp -. -is_match_state -( -id -) -| -| -sp -. -is_start_state -( -id -) -| -| -sp -. -is_accel_state -( -id -) -; -if -! -is_actually_special -{ -/ -/ -This -is -kind -of -a -cryptic -error -message -. -. -. -return -Err -( -DeserializeError -: -: -generic -( -" -found -sparse -state -tagged -as -special -but -\ -wasn -' -t -actually -special -" -) -) -; -} -} -let -state -= -self -. -try_state -( -sp -id -) -? -; -verified -. -insert -( -id -) -; -/ -/ -The -next -ID -should -be -the -offset -immediately -following -state -. -id -= -StateID -: -: -new -( -wire -: -: -add -( -id -. -as_usize -( -) -state -. -write_to_len -( -) -" -next -state -ID -offset -" -) -? -) -. -map_err -( -| -err -| -{ -DeserializeError -: -: -state_id_error -( -err -" -next -state -ID -offset -" -) -} -) -? -; -len -+ -= -1 -; -} -/ -/ -Now -that -we -' -ve -checked -that -all -top -- -level -states -are -correct -and -/ -/ -importantly -collected -a -set -of -valid -state -IDs -we -have -all -the -/ -/ -information -we -need -to -check -that -all -transitions -are -correct -too -. -/ -/ -/ -/ -Note -that -we -can -' -t -use -valid_ids -to -iterate -because -it -will -/ -/ -be -empty -in -no -- -std -no -- -alloc -contexts -. -( -And -yes -that -means -our -/ -/ -verification -isn -' -t -quite -as -good -. -) -We -can -use -self -. -states -( -) -/ -/ -though -at -least -since -we -know -that -all -states -can -at -least -be -/ -/ -decoded -and -traversed -correctly -. -for -state -in -self -. -states -( -) -{ -/ -/ -Check -that -all -transitions -in -this -state -are -correct -. -for -i -in -0 -. -. -state -. -ntrans -{ -let -to -= -state -. -next_at -( -i -) -; -/ -/ -For -no -- -alloc -we -just -check -that -the -state -can -decode -. -It -is -/ -/ -technically -possible -that -the -state -ID -could -still -point -to -/ -/ -a -non -- -existent -state -even -if -it -decodes -( -fuzzing -proved -this -/ -/ -to -be -true -) -but -it -shouldn -' -t -result -in -any -memory -unsafety -/ -/ -or -panics -in -non -- -debug -mode -. -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -{ -let -_ -= -self -. -try_state -( -sp -to -) -? -; -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -{ -if -! -verified -. -contains -( -& -to -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -found -transition -that -points -to -a -\ -non -- -existent -state -" -) -) -; -} -} -} -} -if -len -! -= -self -. -state_len -{ -return -Err -( -DeserializeError -: -: -generic -( -" -mismatching -sparse -state -length -" -) -) -; -} -Ok -( -( -) -) -} -/ -/ -/ -Converts -these -transitions -to -a -borrowed -value -. -fn -as_ref -( -& -self -) -- -> -Transitions -< -& -' -_ -[ -u8 -] -> -{ -Transitions -{ -sparse -: -self -. -sparse -( -) -classes -: -self -. -classes -. -clone -( -) -state_len -: -self -. -state_len -pattern_len -: -self -. -pattern_len -} -} -/ -/ -/ -Converts -these -transitions -to -an -owned -value -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -fn -to_owned -( -& -self -) -- -> -Transitions -< -alloc -: -: -vec -: -: -Vec -< -u8 -> -> -{ -Transitions -{ -sparse -: -self -. -sparse -( -) -. -to_vec -( -) -classes -: -self -. -classes -. -clone -( -) -state_len -: -self -. -state_len -pattern_len -: -self -. -pattern_len -} -} -/ -/ -/ -Return -a -convenient -representation -of -the -given -state -. -/ -/ -/ -/ -/ -/ -This -panics -if -the -state -is -invalid -. -/ -/ -/ -/ -/ -/ -This -is -marked -as -inline -to -help -dramatically -boost -sparse -searching -/ -/ -/ -which -decodes -each -state -it -enters -to -follow -the -next -transition -. -Other -/ -/ -/ -functions -involved -are -also -inlined -which -should -hopefully -eliminate -/ -/ -/ -a -lot -of -the -extraneous -decoding -that -is -never -needed -just -to -follow -/ -/ -/ -the -next -transition -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -state -( -& -self -id -: -StateID -) -- -> -State -< -' -_ -> -{ -let -mut -state -= -& -self -. -sparse -( -) -[ -id -. -as_usize -( -) -. -. -] -; -let -mut -ntrans -= -wire -: -: -read_u16 -( -& -state -) -. -as_usize -( -) -; -let -is_match -= -( -1 -< -< -15 -) -& -ntrans -! -= -0 -; -ntrans -& -= -! -( -1 -< -< -15 -) -; -state -= -& -state -[ -2 -. -. -] -; -let -( -input_ranges -state -) -= -state -. -split_at -( -ntrans -* -2 -) -; -let -( -next -state -) -= -state -. -split_at -( -ntrans -* -StateID -: -: -SIZE -) -; -let -( -pattern_ids -state -) -= -if -is_match -{ -let -npats -= -wire -: -: -read_u32 -( -& -state -) -. -as_usize -( -) -; -state -[ -4 -. -. -] -. -split_at -( -npats -* -4 -) -} -else -{ -( -& -[ -] -[ -. -. -] -state -) -} -; -let -accel_len -= -usize -: -: -from -( -state -[ -0 -] -) -; -let -accel -= -& -state -[ -1 -. -. -accel_len -+ -1 -] -; -State -{ -id -is_match -ntrans -input_ranges -next -pattern_ids -accel -} -} -/ -/ -/ -Like -state -but -will -return -an -error -if -the -state -encoding -is -/ -/ -/ -invalid -. -This -is -useful -for -verifying -states -after -deserialization -/ -/ -/ -which -is -required -for -a -safe -deserialization -API -. -/ -/ -/ -/ -/ -/ -Note -that -this -only -verifies -that -this -state -is -decodable -and -that -/ -/ -/ -all -of -its -data -is -consistent -. -It -does -not -verify -that -its -state -ID -/ -/ -/ -transitions -point -to -valid -states -themselves -nor -does -it -verify -that -/ -/ -/ -every -pattern -ID -is -valid -. -fn -try_state -( -& -self -sp -: -& -Special -id -: -StateID -) -- -> -Result -< -State -< -' -_ -> -DeserializeError -> -{ -if -id -. -as_usize -( -) -> -self -. -sparse -( -) -. -len -( -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -caller -provided -sparse -state -ID -" -) -) -; -} -let -mut -state -= -& -self -. -sparse -( -) -[ -id -. -as_usize -( -) -. -. -] -; -/ -/ -Encoding -format -starts -with -a -u16 -that -stores -the -total -number -of -/ -/ -transitions -in -this -state -. -let -( -mut -ntrans -_ -) -= -wire -: -: -try_read_u16_as_usize -( -state -" -state -transition -length -" -) -? -; -let -is_match -= -( -( -1 -< -< -15 -) -& -ntrans -) -! -= -0 -; -ntrans -& -= -! -( -1 -< -< -15 -) -; -state -= -& -state -[ -2 -. -. -] -; -if -ntrans -> -257 -| -| -ntrans -= -= -0 -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -transition -length -" -) -) -; -} -if -is_match -& -& -! -sp -. -is_match_state -( -id -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -state -marked -as -match -but -not -in -match -ID -range -" -) -) -; -} -else -if -! -is_match -& -& -sp -. -is_match_state -( -id -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -state -in -match -ID -range -but -not -marked -as -match -state -" -) -) -; -} -/ -/ -Each -transition -has -two -pieces -: -an -inclusive -range -of -bytes -on -which -/ -/ -it -is -defined -and -the -state -ID -that -those -bytes -transition -to -. -The -/ -/ -pairs -come -first -followed -by -a -corresponding -sequence -of -state -IDs -. -let -input_ranges_len -= -ntrans -. -checked_mul -( -2 -) -. -unwrap -( -) -; -wire -: -: -check_slice_len -( -state -input_ranges_len -" -sparse -byte -pairs -" -) -? -; -let -( -input_ranges -state -) -= -state -. -split_at -( -input_ranges_len -) -; -/ -/ -Every -range -should -be -of -the -form -A -- -B -where -A -< -= -B -. -for -pair -in -input_ranges -. -chunks -( -2 -) -{ -let -( -start -end -) -= -( -pair -[ -0 -] -pair -[ -1 -] -) -; -if -start -> -end -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -input -range -" -) -) -; -} -} -/ -/ -And -now -extract -the -corresponding -sequence -of -state -IDs -. -We -leave -/ -/ -this -sequence -as -a -& -[ -u8 -] -instead -of -a -& -[ -S -] -because -sparse -DFAs -do -/ -/ -not -have -any -alignment -requirements -. -let -next_len -= -ntrans -. -checked_mul -( -self -. -id_len -( -) -) -. -expect -( -" -state -size -* -# -trans -should -always -fit -in -a -usize -" -) -; -wire -: -: -check_slice_len -( -state -next_len -" -sparse -trans -state -IDs -" -) -? -; -let -( -next -state -) -= -state -. -split_at -( -next_len -) -; -/ -/ -We -can -at -least -verify -that -every -state -ID -is -in -bounds -. -for -idbytes -in -next -. -chunks -( -self -. -id_len -( -) -) -{ -let -( -id -_ -) -= -wire -: -: -read_state_id -( -idbytes -" -sparse -state -ID -in -try_state -" -) -? -; -wire -: -: -check_slice_len -( -self -. -sparse -( -) -id -. -as_usize -( -) -" -invalid -sparse -state -ID -" -) -? -; -} -/ -/ -If -this -is -a -match -state -then -read -the -pattern -IDs -for -this -state -. -/ -/ -Pattern -IDs -is -a -u32 -- -length -prefixed -sequence -of -native -endian -/ -/ -encoded -32 -- -bit -integers -. -let -( -pattern_ids -state -) -= -if -is_match -{ -let -( -npats -nr -) -= -wire -: -: -try_read_u32_as_usize -( -state -" -pattern -ID -length -" -) -? -; -let -state -= -& -state -[ -nr -. -. -] -; -if -npats -= -= -0 -{ -return -Err -( -DeserializeError -: -: -generic -( -" -state -marked -as -a -match -but -has -no -pattern -IDs -" -) -) -; -} -let -pattern_ids_len -= -wire -: -: -mul -( -npats -4 -" -sparse -pattern -ID -byte -length -" -) -? -; -wire -: -: -check_slice_len -( -state -pattern_ids_len -" -sparse -pattern -IDs -" -) -? -; -let -( -pattern_ids -state -) -= -state -. -split_at -( -pattern_ids_len -) -; -for -patbytes -in -pattern_ids -. -chunks -( -PatternID -: -: -SIZE -) -{ -wire -: -: -read_pattern_id -( -patbytes -" -sparse -pattern -ID -in -try_state -" -) -? -; -} -( -pattern_ids -state -) -} -else -{ -( -& -[ -] -[ -. -. -] -state -) -} -; -/ -/ -Now -read -this -state -' -s -accelerator -info -. -The -first -byte -is -the -length -/ -/ -of -the -accelerator -which -is -typically -0 -( -for -no -acceleration -) -but -/ -/ -is -no -bigger -than -3 -. -The -length -indicates -the -number -of -bytes -that -/ -/ -follow -where -each -byte -corresponds -to -a -transition -out -of -this -/ -/ -state -. -if -state -. -is_empty -( -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -no -accelerator -length -" -) -) -; -} -let -( -accel_len -state -) -= -( -usize -: -: -from -( -state -[ -0 -] -) -& -state -[ -1 -. -. -] -) -; -if -accel_len -> -3 -{ -return -Err -( -DeserializeError -: -: -generic -( -" -sparse -invalid -accelerator -length -" -) -) -; -} -else -if -accel_len -= -= -0 -& -& -sp -. -is_accel_state -( -id -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -got -no -accelerators -in -state -but -in -accelerator -ID -range -" -) -) -; -} -else -if -accel_len -> -0 -& -& -! -sp -. -is_accel_state -( -id -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -state -in -accelerator -ID -range -but -has -no -accelerators -" -) -) -; -} -wire -: -: -check_slice_len -( -state -accel_len -" -sparse -corrupt -accelerator -length -" -) -? -; -let -( -accel -_ -) -= -( -& -state -[ -. -. -accel_len -] -& -state -[ -accel_len -. -. -] -) -; -let -state -= -State -{ -id -is_match -ntrans -input_ranges -next -pattern_ids -accel -} -; -if -sp -. -is_quit_state -( -state -. -next_at -( -state -. -ntrans -- -1 -) -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -state -with -EOI -transition -to -quit -state -is -illegal -" -) -) -; -} -Ok -( -state -) -} -/ -/ -/ -Return -an -iterator -over -all -of -the -states -in -this -DFA -. -/ -/ -/ -/ -/ -/ -The -iterator -returned -yields -tuples -where -the -first -element -is -the -/ -/ -/ -state -ID -and -the -second -element -is -the -state -itself -. -fn -states -( -& -self -) -- -> -StateIter -< -' -_ -T -> -{ -StateIter -{ -trans -: -self -id -: -DEAD -. -as_usize -( -) -} -} -/ -/ -/ -Returns -the -sparse -transitions -as -raw -bytes -. -fn -sparse -( -& -self -) -- -> -& -[ -u8 -] -{ -self -. -sparse -. -as_ref -( -) -} -/ -/ -/ -Returns -the -number -of -bytes -represented -by -a -single -state -ID -. -fn -id_len -( -& -self -) -- -> -usize -{ -StateID -: -: -SIZE -} -/ -/ -/ -Return -the -memory -usage -in -bytes -of -these -transitions -. -/ -/ -/ -/ -/ -/ -This -does -not -include -the -size -of -a -Transitions -value -itself -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -sparse -( -) -. -len -( -) -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -< -T -: -AsMut -< -[ -u8 -] -> -> -Transitions -< -T -> -{ -/ -/ -/ -Return -a -convenient -mutable -representation -of -the -given -state -. -/ -/ -/ -This -panics -if -the -state -is -invalid -. -fn -state_mut -( -& -mut -self -id -: -StateID -) -- -> -StateMut -< -' -_ -> -{ -let -mut -state -= -& -mut -self -. -sparse_mut -( -) -[ -id -. -as_usize -( -) -. -. -] -; -let -mut -ntrans -= -wire -: -: -read_u16 -( -& -state -) -. -as_usize -( -) -; -let -is_match -= -( -1 -< -< -15 -) -& -ntrans -! -= -0 -; -ntrans -& -= -! -( -1 -< -< -15 -) -; -state -= -& -mut -state -[ -2 -. -. -] -; -let -( -input_ranges -state -) -= -state -. -split_at_mut -( -ntrans -* -2 -) -; -let -( -next -state -) -= -state -. -split_at_mut -( -ntrans -* -StateID -: -: -SIZE -) -; -let -( -pattern_ids -state -) -= -if -is_match -{ -let -npats -= -wire -: -: -read_u32 -( -& -state -) -. -as_usize -( -) -; -state -[ -4 -. -. -] -. -split_at_mut -( -npats -* -4 -) -} -else -{ -( -& -mut -[ -] -[ -. -. -] -state -) -} -; -let -accel_len -= -usize -: -: -from -( -state -[ -0 -] -) -; -let -accel -= -& -mut -state -[ -1 -. -. -accel_len -+ -1 -] -; -StateMut -{ -id -is_match -ntrans -input_ranges -next -pattern_ids -accel -} -} -/ -/ -/ -Returns -the -sparse -transitions -as -raw -mutable -bytes -. -fn -sparse_mut -( -& -mut -self -) -- -> -& -mut -[ -u8 -] -{ -self -. -sparse -. -as_mut -( -) -} -} -/ -/ -/ -The -set -of -all -possible -starting -states -in -a -DFA -. -/ -/ -/ -/ -/ -/ -See -the -eponymous -type -in -the -dense -module -for -more -details -. -This -type -/ -/ -/ -is -very -similar -to -dense -: -: -StartTable -except -that -its -underlying -/ -/ -/ -representation -is -& -[ -u8 -] -instead -of -& -[ -S -] -. -( -The -latter -would -require -/ -/ -/ -sparse -DFAs -to -be -aligned -which -is -explicitly -something -we -do -not -require -/ -/ -/ -because -we -don -' -t -really -need -it -. -) -# -[ -derive -( -Clone -) -] -struct -StartTable -< -T -> -{ -/ -/ -/ -The -initial -start -state -IDs -as -a -contiguous -table -of -native -endian -/ -/ -/ -encoded -integers -represented -by -S -. -/ -/ -/ -/ -/ -/ -In -practice -T -is -either -Vec -< -u8 -> -or -& -[ -u8 -] -and -has -no -alignment -/ -/ -/ -requirements -. -/ -/ -/ -/ -/ -/ -The -first -2 -* -stride -( -currently -always -8 -) -entries -always -correspond -/ -/ -/ -to -the -starts -states -for -the -entire -DFA -with -the -first -4 -entries -being -/ -/ -/ -for -unanchored -searches -and -the -second -4 -entries -being -for -anchored -/ -/ -/ -searches -. -To -keep -things -simple -we -always -use -8 -entries -even -if -the -/ -/ -/ -StartKind -is -not -both -. -/ -/ -/ -/ -/ -/ -After -that -there -are -stride -* -patterns -state -IDs -where -patterns -/ -/ -/ -may -be -zero -in -the -case -of -a -DFA -with -no -patterns -or -in -the -case -where -/ -/ -/ -the -DFA -was -built -without -enabling -starting -states -for -each -pattern -. -table -: -T -/ -/ -/ -The -starting -state -configuration -supported -. -When -' -both -' -both -/ -/ -/ -unanchored -and -anchored -searches -work -. -When -' -unanchored -' -anchored -/ -/ -/ -searches -panic -. -When -' -anchored -' -unanchored -searches -panic -. -kind -: -StartKind -/ -/ -/ -The -start -state -configuration -for -every -possible -byte -. -start_map -: -StartByteMap -/ -/ -/ -The -number -of -starting -state -IDs -per -pattern -. -stride -: -usize -/ -/ -/ -The -total -number -of -patterns -for -which -starting -states -are -encoded -. -/ -/ -/ -This -is -None -for -DFAs -that -were -built -without -start -states -for -each -/ -/ -/ -pattern -. -Thus -one -cannot -use -this -field -to -say -how -many -patterns -/ -/ -/ -are -in -the -DFA -in -all -cases -. -It -is -specific -to -how -many -patterns -are -/ -/ -/ -represented -in -this -start -table -. -pattern_len -: -Option -< -usize -> -/ -/ -/ -The -universal -starting -state -for -unanchored -searches -. -This -is -only -/ -/ -/ -present -when -the -DFA -supports -unanchored -searches -and -when -all -starting -/ -/ -/ -state -IDs -for -an -unanchored -search -are -equivalent -. -universal_start_unanchored -: -Option -< -StateID -> -/ -/ -/ -The -universal -starting -state -for -anchored -searches -. -This -is -only -/ -/ -/ -present -when -the -DFA -supports -anchored -searches -and -when -all -starting -/ -/ -/ -state -IDs -for -an -anchored -search -are -equivalent -. -universal_start_anchored -: -Option -< -StateID -> -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -StartTable -< -Vec -< -u8 -> -> -{ -fn -new -< -T -: -AsRef -< -[ -u32 -] -> -> -( -dfa -: -& -dense -: -: -DFA -< -T -> -pattern_len -: -Option -< -usize -> -) -- -> -StartTable -< -Vec -< -u8 -> -> -{ -let -stride -= -Start -: -: -len -( -) -; -/ -/ -This -is -OK -since -the -only -way -we -' -re -here -is -if -a -dense -DFA -could -be -/ -/ -constructed -successfully -which -uses -the -same -space -. -let -len -= -stride -. -checked_mul -( -pattern_len -. -unwrap_or -( -0 -) -) -. -unwrap -( -) -. -checked_add -( -stride -. -checked_mul -( -2 -) -. -unwrap -( -) -) -. -unwrap -( -) -. -checked_mul -( -StateID -: -: -SIZE -) -. -unwrap -( -) -; -StartTable -{ -table -: -vec -! -[ -0 -; -len -] -kind -: -dfa -. -start_kind -( -) -start_map -: -dfa -. -start_map -( -) -. -clone -( -) -stride -pattern_len -universal_start_unanchored -: -dfa -. -universal_start_state -( -Anchored -: -: -No -) -universal_start_anchored -: -dfa -. -universal_start_state -( -Anchored -: -: -Yes -) -} -} -fn -from_dense_dfa -< -T -: -AsRef -< -[ -u32 -] -> -> -( -dfa -: -& -dense -: -: -DFA -< -T -> -remap -: -& -[ -StateID -] -) -- -> -Result -< -StartTable -< -Vec -< -u8 -> -> -BuildError -> -{ -/ -/ -Unless -the -DFA -has -start -states -compiled -for -each -pattern -then -/ -/ -as -far -as -the -starting -state -table -is -concerned -there -are -zero -/ -/ -patterns -to -account -for -. -It -will -instead -only -store -starting -states -/ -/ -for -the -entire -DFA -. -let -start_pattern_len -= -if -dfa -. -starts_for_each_pattern -( -) -{ -Some -( -dfa -. -pattern_len -( -) -) -} -else -{ -None -} -; -let -mut -sl -= -StartTable -: -: -new -( -dfa -start_pattern_len -) -; -for -( -old_start_id -anchored -sty -) -in -dfa -. -starts -( -) -{ -let -new_start_id -= -remap -[ -dfa -. -to_index -( -old_start_id -) -] -; -sl -. -set_start -( -anchored -sty -new_start_id -) -; -} -Ok -( -sl -) -} -} -impl -< -' -a -> -StartTable -< -& -' -a -[ -u8 -] -> -{ -unsafe -fn -from_bytes_unchecked -( -mut -slice -: -& -' -a -[ -u8 -] -) -- -> -Result -< -( -StartTable -< -& -' -a -[ -u8 -] -> -usize -) -DeserializeError -> -{ -let -slice_start -= -slice -. -as_ptr -( -) -. -as_usize -( -) -; -let -( -kind -nr -) -= -StartKind -: -: -from_bytes -( -slice -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -start_map -nr -) -= -StartByteMap -: -: -from_bytes -( -slice -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -( -stride -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -sparse -start -table -stride -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -if -stride -! -= -Start -: -: -len -( -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -invalid -sparse -starting -table -stride -" -) -) -; -} -let -( -maybe_pattern_len -nr -) -= -wire -: -: -try_read_u32_as_usize -( -slice -" -sparse -start -table -patterns -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -pattern_len -= -if -maybe_pattern_len -. -as_u32 -( -) -= -= -u32 -: -: -MAX -{ -None -} -else -{ -Some -( -maybe_pattern_len -) -} -; -if -pattern_len -. -map_or -( -false -| -len -| -len -> -PatternID -: -: -LIMIT -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -sparse -invalid -number -of -patterns -" -) -) -; -} -let -( -universal_unanchored -nr -) -= -wire -: -: -try_read_u32 -( -slice -" -universal -unanchored -start -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -universal_start_unanchored -= -if -universal_unanchored -= -= -u32 -: -: -MAX -{ -None -} -else -{ -Some -( -StateID -: -: -try_from -( -universal_unanchored -) -. -map_err -( -| -e -| -{ -DeserializeError -: -: -state_id_error -( -e -" -universal -unanchored -start -" -) -} -) -? -) -} -; -let -( -universal_anchored -nr -) -= -wire -: -: -try_read_u32 -( -slice -" -universal -anchored -start -" -) -? -; -slice -= -& -slice -[ -nr -. -. -] -; -let -universal_start_anchored -= -if -universal_anchored -= -= -u32 -: -: -MAX -{ -None -} -else -{ -Some -( -StateID -: -: -try_from -( -universal_anchored -) -. -map_err -( -| -e -| -{ -DeserializeError -: -: -state_id_error -( -e -" -universal -anchored -start -" -) -} -) -? -) -} -; -let -pattern_table_size -= -wire -: -: -mul -( -stride -pattern_len -. -unwrap_or -( -0 -) -" -sparse -invalid -pattern -length -" -) -? -; -/ -/ -Our -start -states -always -start -with -a -single -stride -of -start -states -/ -/ -for -the -entire -automaton -which -permit -it -to -match -any -pattern -. -What -/ -/ -follows -it -are -an -optional -set -of -start -states -for -each -pattern -. -let -start_state_len -= -wire -: -: -add -( -wire -: -: -mul -( -2 -stride -" -start -state -stride -too -big -" -) -? -pattern_table_size -" -sparse -invalid -' -any -' -pattern -starts -size -" -) -? -; -let -table_bytes_len -= -wire -: -: -mul -( -start_state_len -StateID -: -: -SIZE -" -sparse -pattern -table -bytes -length -" -) -? -; -wire -: -: -check_slice_len -( -slice -table_bytes_len -" -sparse -start -ID -table -" -) -? -; -let -table -= -& -slice -[ -. -. -table_bytes_len -] -; -slice -= -& -slice -[ -table_bytes_len -. -. -] -; -let -sl -= -StartTable -{ -table -kind -start_map -stride -pattern_len -universal_start_unanchored -universal_start_anchored -} -; -Ok -( -( -sl -slice -. -as_ptr -( -) -. -as_usize -( -) -- -slice_start -) -) -} -} -impl -< -T -: -AsRef -< -[ -u8 -] -> -> -StartTable -< -T -> -{ -fn -write_to -< -E -: -Endian -> -( -& -self -mut -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -sparse -starting -table -ids -" -) -) -; -} -dst -= -& -mut -dst -[ -. -. -nwrite -] -; -/ -/ -write -start -kind -let -nw -= -self -. -kind -. -write_to -: -: -< -E -> -( -dst -) -? -; -dst -= -& -mut -dst -[ -nw -. -. -] -; -/ -/ -write -start -byte -map -let -nw -= -self -. -start_map -. -write_to -( -dst -) -? -; -dst -= -& -mut -dst -[ -nw -. -. -] -; -/ -/ -write -stride -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -stride -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -pattern -length -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -pattern_len -. -unwrap_or -( -0xFFFF_FFFF -) -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -universal -start -unanchored -state -id -u32 -: -: -MAX -if -absent -E -: -: -write_u32 -( -self -. -universal_start_unanchored -. -map_or -( -u32 -: -: -MAX -| -sid -| -sid -. -as_u32 -( -) -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -universal -start -anchored -state -id -u32 -: -: -MAX -if -absent -E -: -: -write_u32 -( -self -. -universal_start_anchored -. -map_or -( -u32 -: -: -MAX -| -sid -| -sid -. -as_u32 -( -) -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -/ -/ -write -start -IDs -for -( -sid -_ -_ -) -in -self -. -iter -( -) -{ -E -: -: -write_u32 -( -sid -. -as_u32 -( -) -dst -) -; -dst -= -& -mut -dst -[ -StateID -: -: -SIZE -. -. -] -; -} -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -number -of -bytes -the -serialized -form -of -this -transition -/ -/ -/ -table -will -use -. -fn -write_to_len -( -& -self -) -- -> -usize -{ -self -. -kind -. -write_to_len -( -) -+ -self -. -start_map -. -write_to_len -( -) -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -stride -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -# -patterns -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -universal -unanchored -start -+ -size_of -: -: -< -u32 -> -( -) -/ -/ -universal -anchored -start -+ -self -. -table -( -) -. -len -( -) -} -/ -/ -/ -Validates -that -every -starting -state -ID -in -this -table -is -valid -. -/ -/ -/ -/ -/ -/ -That -is -every -starting -state -ID -can -be -used -to -correctly -decode -a -/ -/ -/ -state -in -the -DFA -' -s -sparse -transitions -. -fn -validate -( -& -self -sp -: -& -Special -trans -: -& -Transitions -< -T -> -) -- -> -Result -< -( -) -DeserializeError -> -{ -for -( -id -_ -_ -) -in -self -. -iter -( -) -{ -if -sp -. -is_match_state -( -id -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -start -states -cannot -be -match -states -" -) -) -; -} -/ -/ -Confirm -that -the -start -state -points -to -a -valid -state -. -let -state -= -trans -. -try_state -( -sp -id -) -? -; -/ -/ -And -like -for -the -transition -table -confirm -that -the -transitions -/ -/ -on -all -start -states -themselves -point -to -a -valid -state -. -/ -/ -/ -/ -It -' -d -probably -be -better -to -integrate -this -validation -with -the -/ -/ -transition -table -or -otherwise -store -a -sorted -sequence -of -all -/ -/ -valid -state -IDs -in -the -sparse -DFA -itself -. -That -way -we -could -/ -/ -check -that -every -pointer -to -a -state -corresponds -precisely -to -a -/ -/ -correct -and -valid -state -. -for -i -in -0 -. -. -state -. -ntrans -{ -let -to -= -state -. -next_at -( -i -) -; -let -_ -= -trans -. -try_state -( -sp -to -) -? -; -} -} -Ok -( -( -) -) -} -/ -/ -/ -Converts -this -start -list -to -a -borrowed -value -. -fn -as_ref -( -& -self -) -- -> -StartTable -< -& -' -_ -[ -u8 -] -> -{ -StartTable -{ -table -: -self -. -table -( -) -kind -: -self -. -kind -start_map -: -self -. -start_map -. -clone -( -) -stride -: -self -. -stride -pattern_len -: -self -. -pattern_len -universal_start_unanchored -: -self -. -universal_start_unanchored -universal_start_anchored -: -self -. -universal_start_anchored -} -} -/ -/ -/ -Converts -this -start -list -to -an -owned -value -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -fn -to_owned -( -& -self -) -- -> -StartTable -< -alloc -: -: -vec -: -: -Vec -< -u8 -> -> -{ -StartTable -{ -table -: -self -. -table -( -) -. -to_vec -( -) -kind -: -self -. -kind -start_map -: -self -. -start_map -. -clone -( -) -stride -: -self -. -stride -pattern_len -: -self -. -pattern_len -universal_start_unanchored -: -self -. -universal_start_unanchored -universal_start_anchored -: -self -. -universal_start_anchored -} -} -/ -/ -/ -Return -the -start -state -for -the -given -index -and -pattern -ID -. -If -the -/ -/ -/ -pattern -ID -is -None -then -the -corresponding -start -state -for -the -entire -/ -/ -/ -DFA -is -returned -. -If -the -pattern -ID -is -not -None -then -the -corresponding -/ -/ -/ -starting -state -for -the -given -pattern -is -returned -. -If -this -start -table -/ -/ -/ -does -not -have -individual -starting -states -for -each -pattern -then -this -/ -/ -/ -panics -. -fn -start -( -& -self -input -: -& -Input -< -' -_ -> -start -: -Start -) -- -> -Result -< -StateID -MatchError -> -{ -let -start_index -= -start -. -as_usize -( -) -; -let -mode -= -input -. -get_anchored -( -) -; -let -index -= -match -mode -{ -Anchored -: -: -No -= -> -{ -if -! -self -. -kind -. -has_unanchored -( -) -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -mode -) -) -; -} -start_index -} -Anchored -: -: -Yes -= -> -{ -if -! -self -. -kind -. -has_anchored -( -) -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -mode -) -) -; -} -self -. -stride -+ -start_index -} -Anchored -: -: -Pattern -( -pid -) -= -> -{ -let -len -= -match -self -. -pattern_len -{ -None -= -> -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -mode -) -) -} -Some -( -len -) -= -> -len -} -; -if -pid -. -as_usize -( -) -> -= -len -{ -return -Ok -( -DEAD -) -; -} -( -2 -* -self -. -stride -) -+ -( -self -. -stride -* -pid -. -as_usize -( -) -) -+ -start_index -} -} -; -let -start -= -index -* -StateID -: -: -SIZE -; -/ -/ -This -OK -since -we -' -re -allowed -to -assume -that -the -start -table -contains -/ -/ -valid -StateIDs -. -Ok -( -wire -: -: -read_state_id_unchecked -( -& -self -. -table -( -) -[ -start -. -. -] -) -. -0 -) -} -/ -/ -/ -Return -an -iterator -over -all -start -IDs -in -this -table -. -fn -iter -( -& -self -) -- -> -StartStateIter -< -' -_ -T -> -{ -StartStateIter -{ -st -: -self -i -: -0 -} -} -/ -/ -/ -Returns -the -total -number -of -start -state -IDs -in -this -table -. -fn -len -( -& -self -) -- -> -usize -{ -self -. -table -( -) -. -len -( -) -/ -StateID -: -: -SIZE -} -/ -/ -/ -Returns -the -table -as -a -raw -slice -of -bytes -. -fn -table -( -& -self -) -- -> -& -[ -u8 -] -{ -self -. -table -. -as_ref -( -) -} -/ -/ -/ -Return -the -memory -usage -in -bytes -of -this -start -list -. -/ -/ -/ -/ -/ -/ -This -does -not -include -the -size -of -a -StartTable -value -itself -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -table -( -) -. -len -( -) -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -< -T -: -AsMut -< -[ -u8 -] -> -> -StartTable -< -T -> -{ -/ -/ -/ -Set -the -start -state -for -the -given -index -and -pattern -. -/ -/ -/ -/ -/ -/ -If -the -pattern -ID -or -state -ID -are -not -valid -then -this -will -panic -. -fn -set_start -( -& -mut -self -anchored -: -Anchored -start -: -Start -id -: -StateID -) -{ -let -start_index -= -start -. -as_usize -( -) -; -let -index -= -match -anchored -{ -Anchored -: -: -No -= -> -start_index -Anchored -: -: -Yes -= -> -self -. -stride -+ -start_index -Anchored -: -: -Pattern -( -pid -) -= -> -{ -let -pid -= -pid -. -as_usize -( -) -; -let -len -= -self -. -pattern_len -. -expect -( -" -start -states -for -each -pattern -enabled -" -) -; -assert -! -( -pid -< -len -" -invalid -pattern -ID -{ -: -? -} -" -pid -) -; -self -. -stride -. -checked_mul -( -pid -) -. -unwrap -( -) -. -checked_add -( -self -. -stride -. -checked_mul -( -2 -) -. -unwrap -( -) -) -. -unwrap -( -) -. -checked_add -( -start_index -) -. -unwrap -( -) -} -} -; -let -start -= -index -* -StateID -: -: -SIZE -; -let -end -= -start -+ -StateID -: -: -SIZE -; -wire -: -: -write_state_id -: -: -< -wire -: -: -NE -> -( -id -& -mut -self -. -table -. -as_mut -( -) -[ -start -. -. -end -] -) -; -} -} -/ -/ -/ -An -iterator -over -all -state -state -IDs -in -a -sparse -DFA -. -struct -StartStateIter -< -' -a -T -> -{ -st -: -& -' -a -StartTable -< -T -> -i -: -usize -} -impl -< -' -a -T -: -AsRef -< -[ -u8 -] -> -> -Iterator -for -StartStateIter -< -' -a -T -> -{ -type -Item -= -( -StateID -Anchored -Start -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -StateID -Anchored -Start -) -> -{ -let -i -= -self -. -i -; -if -i -> -= -self -. -st -. -len -( -) -{ -return -None -; -} -self -. -i -+ -= -1 -; -/ -/ -This -unwrap -is -okay -since -the -stride -of -any -DFA -must -always -match -/ -/ -the -number -of -start -state -types -. -let -start_type -= -Start -: -: -from_usize -( -i -% -self -. -st -. -stride -) -. -unwrap -( -) -; -let -anchored -= -if -i -< -self -. -st -. -stride -{ -Anchored -: -: -No -} -else -if -i -< -( -2 -* -self -. -st -. -stride -) -{ -Anchored -: -: -Yes -} -else -{ -let -pid -= -( -i -- -( -2 -* -self -. -st -. -stride -) -) -/ -self -. -st -. -stride -; -Anchored -: -: -Pattern -( -PatternID -: -: -new -( -pid -) -. -unwrap -( -) -) -} -; -let -start -= -i -* -StateID -: -: -SIZE -; -let -end -= -start -+ -StateID -: -: -SIZE -; -let -bytes -= -self -. -st -. -table -( -) -[ -start -. -. -end -] -. -try_into -( -) -. -unwrap -( -) -; -/ -/ -This -is -OK -since -we -' -re -allowed -to -assume -that -any -IDs -in -this -start -/ -/ -table -are -correct -and -valid -for -this -DFA -. -let -id -= -StateID -: -: -from_ne_bytes_unchecked -( -bytes -) -; -Some -( -( -id -anchored -start_type -) -) -} -} -impl -< -' -a -T -> -fmt -: -: -Debug -for -StartStateIter -< -' -a -T -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -) -- -> -fmt -: -: -Result -{ -f -. -debug_struct -( -" -StartStateIter -" -) -. -field -( -" -i -" -& -self -. -i -) -. -finish -( -) -} -} -/ -/ -/ -An -iterator -over -all -states -in -a -sparse -DFA -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -tuples -where -the -first -element -is -the -state -ID -and -/ -/ -/ -the -second -element -is -the -state -itself -. -struct -StateIter -< -' -a -T -> -{ -trans -: -& -' -a -Transitions -< -T -> -id -: -usize -} -impl -< -' -a -T -: -AsRef -< -[ -u8 -] -> -> -Iterator -for -StateIter -< -' -a -T -> -{ -type -Item -= -State -< -' -a -> -; -fn -next -( -& -mut -self -) -- -> -Option -< -State -< -' -a -> -> -{ -if -self -. -id -> -= -self -. -trans -. -sparse -( -) -. -len -( -) -{ -return -None -; -} -let -state -= -self -. -trans -. -state -( -StateID -: -: -new_unchecked -( -self -. -id -) -) -; -self -. -id -= -self -. -id -+ -state -. -write_to_len -( -) -; -Some -( -state -) -} -} -impl -< -' -a -T -> -fmt -: -: -Debug -for -StateIter -< -' -a -T -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -) -- -> -fmt -: -: -Result -{ -f -. -debug_struct -( -" -StateIter -" -) -. -field -( -" -id -" -& -self -. -id -) -. -finish -( -) -} -} -/ -/ -/ -A -representation -of -a -sparse -DFA -state -that -can -be -cheaply -materialized -/ -/ -/ -from -a -state -identifier -. -# -[ -derive -( -Clone -) -] -struct -State -< -' -a -> -{ -/ -/ -/ -The -identifier -of -this -state -. -id -: -StateID -/ -/ -/ -Whether -this -is -a -match -state -or -not -. -is_match -: -bool -/ -/ -/ -The -number -of -transitions -in -this -state -. -ntrans -: -usize -/ -/ -/ -Pairs -of -input -ranges -where -there -is -one -pair -for -each -transition -. -/ -/ -/ -Each -pair -specifies -an -inclusive -start -and -end -byte -range -for -the -/ -/ -/ -corresponding -transition -. -input_ranges -: -& -' -a -[ -u8 -] -/ -/ -/ -Transitions -to -the -next -state -. -This -slice -contains -native -endian -/ -/ -/ -encoded -state -identifiers -with -S -as -the -representation -. -Thus -there -/ -/ -/ -are -ntrans -* -size_of -: -: -< -S -> -( -) -bytes -in -this -slice -. -next -: -& -' -a -[ -u8 -] -/ -/ -/ -If -this -is -a -match -state -then -this -contains -the -pattern -IDs -that -match -/ -/ -/ -when -the -DFA -is -in -this -state -. -/ -/ -/ -/ -/ -/ -This -is -a -contiguous -sequence -of -32 -- -bit -native -endian -encoded -integers -. -pattern_ids -: -& -' -a -[ -u8 -] -/ -/ -/ -An -accelerator -for -this -state -if -present -. -If -this -state -has -no -/ -/ -/ -accelerator -then -this -is -an -empty -slice -. -When -non -- -empty -this -slice -/ -/ -/ -has -length -at -most -3 -and -corresponds -to -the -exhaustive -set -of -bytes -/ -/ -/ -that -must -be -seen -in -order -to -transition -out -of -this -state -. -accel -: -& -' -a -[ -u8 -] -} -impl -< -' -a -> -State -< -' -a -> -{ -/ -/ -/ -Searches -for -the -next -transition -given -an -input -byte -. -If -no -such -/ -/ -/ -transition -could -be -found -then -a -dead -state -is -returned -. -/ -/ -/ -/ -/ -/ -This -is -marked -as -inline -to -help -dramatically -boost -sparse -searching -/ -/ -/ -which -decodes -each -state -it -enters -to -follow -the -next -transition -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -next -( -& -self -input -: -u8 -) -- -> -StateID -{ -/ -/ -This -straight -linear -search -was -observed -to -be -much -better -than -/ -/ -binary -search -on -ASCII -haystacks -likely -because -a -binary -search -/ -/ -visits -the -ASCII -case -last -but -a -linear -search -sees -it -first -. -A -/ -/ -binary -search -does -do -a -little -better -on -non -- -ASCII -haystacks -but -/ -/ -not -by -much -. -There -might -be -a -better -trade -off -lurking -here -. -for -i -in -0 -. -. -( -self -. -ntrans -- -1 -) -{ -let -( -start -end -) -= -self -. -range -( -i -) -; -if -start -< -= -input -& -& -input -< -= -end -{ -return -self -. -next_at -( -i -) -; -} -/ -/ -We -could -bail -early -with -an -extra -branch -: -if -input -< -b1 -then -/ -/ -we -know -we -' -ll -never -find -a -matching -transition -. -Interestingly -/ -/ -this -extra -branch -seems -to -not -help -performance -or -will -even -/ -/ -hurt -it -. -It -' -s -likely -very -dependent -on -the -DFA -itself -and -what -/ -/ -is -being -searched -. -} -DEAD -} -/ -/ -/ -Returns -the -next -state -ID -for -the -special -EOI -transition -. -fn -next_eoi -( -& -self -) -- -> -StateID -{ -self -. -next_at -( -self -. -ntrans -- -1 -) -} -/ -/ -/ -Returns -the -identifier -for -this -state -. -fn -id -( -& -self -) -- -> -StateID -{ -self -. -id -} -/ -/ -/ -Returns -the -inclusive -input -byte -range -for -the -ith -transition -in -this -/ -/ -/ -state -. -fn -range -( -& -self -i -: -usize -) -- -> -( -u8 -u8 -) -{ -( -self -. -input_ranges -[ -i -* -2 -] -self -. -input_ranges -[ -i -* -2 -+ -1 -] -) -} -/ -/ -/ -Returns -the -next -state -for -the -ith -transition -in -this -state -. -fn -next_at -( -& -self -i -: -usize -) -- -> -StateID -{ -let -start -= -i -* -StateID -: -: -SIZE -; -let -end -= -start -+ -StateID -: -: -SIZE -; -let -bytes -= -self -. -next -[ -start -. -. -end -] -. -try_into -( -) -. -unwrap -( -) -; -StateID -: -: -from_ne_bytes_unchecked -( -bytes -) -} -/ -/ -/ -Returns -the -pattern -ID -for -the -given -match -index -. -If -the -match -index -/ -/ -/ -is -invalid -then -this -panics -. -fn -pattern_id -( -& -self -match_index -: -usize -) -- -> -PatternID -{ -let -start -= -match_index -* -PatternID -: -: -SIZE -; -wire -: -: -read_pattern_id_unchecked -( -& -self -. -pattern_ids -[ -start -. -. -] -) -. -0 -} -/ -/ -/ -Returns -the -total -number -of -pattern -IDs -for -this -state -. -This -is -always -/ -/ -/ -zero -when -is_match -is -false -. -fn -pattern_len -( -& -self -) -- -> -usize -{ -assert_eq -! -( -0 -self -. -pattern_ids -. -len -( -) -% -4 -) -; -self -. -pattern_ids -. -len -( -) -/ -4 -} -/ -/ -/ -Return -an -accelerator -for -this -state -. -fn -accelerator -( -& -self -) -- -> -& -' -a -[ -u8 -] -{ -self -. -accel -} -/ -/ -/ -Write -the -raw -representation -of -this -state -to -the -given -buffer -using -/ -/ -/ -the -given -endianness -. -fn -write_to -< -E -: -Endian -> -( -& -self -mut -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -sparse -state -transitions -" -) -) -; -} -let -ntrans -= -if -self -. -is_match -{ -self -. -ntrans -| -( -1 -< -< -15 -) -} -else -{ -self -. -ntrans -} -; -E -: -: -write_u16 -( -u16 -: -: -try_from -( -ntrans -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u16 -> -( -) -. -. -] -; -dst -[ -. -. -self -. -input_ranges -. -len -( -) -] -. -copy_from_slice -( -self -. -input_ranges -) -; -dst -= -& -mut -dst -[ -self -. -input_ranges -. -len -( -) -. -. -] -; -for -i -in -0 -. -. -self -. -ntrans -{ -E -: -: -write_u32 -( -self -. -next_at -( -i -) -. -as_u32 -( -) -dst -) -; -dst -= -& -mut -dst -[ -StateID -: -: -SIZE -. -. -] -; -} -if -self -. -is_match -{ -E -: -: -write_u32 -( -u32 -: -: -try_from -( -self -. -pattern_len -( -) -) -. -unwrap -( -) -dst -) -; -dst -= -& -mut -dst -[ -size_of -: -: -< -u32 -> -( -) -. -. -] -; -for -i -in -0 -. -. -self -. -pattern_len -( -) -{ -let -pid -= -self -. -pattern_id -( -i -) -; -E -: -: -write_u32 -( -pid -. -as_u32 -( -) -dst -) -; -dst -= -& -mut -dst -[ -PatternID -: -: -SIZE -. -. -] -; -} -} -dst -[ -0 -] -= -u8 -: -: -try_from -( -self -. -accel -. -len -( -) -) -. -unwrap -( -) -; -dst -[ -1 -. -. -] -[ -. -. -self -. -accel -. -len -( -) -] -. -copy_from_slice -( -self -. -accel -) -; -Ok -( -nwrite -) -} -/ -/ -/ -Return -the -total -number -of -bytes -that -this -state -consumes -in -its -/ -/ -/ -encoded -form -. -fn -write_to_len -( -& -self -) -- -> -usize -{ -let -mut -len -= -2 -+ -( -self -. -ntrans -* -2 -) -+ -( -self -. -ntrans -* -StateID -: -: -SIZE -) -+ -( -1 -+ -self -. -accel -. -len -( -) -) -; -if -self -. -is_match -{ -len -+ -= -size_of -: -: -< -u32 -> -( -) -+ -self -. -pattern_ids -. -len -( -) -; -} -len -} -} -impl -< -' -a -> -fmt -: -: -Debug -for -State -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -let -mut -printed -= -false -; -for -i -in -0 -. -. -( -self -. -ntrans -- -1 -) -{ -let -next -= -self -. -next_at -( -i -) -; -if -next -= -= -DEAD -{ -continue -; -} -if -printed -{ -write -! -( -f -" -" -) -? -; -} -let -( -start -end -) -= -self -. -range -( -i -) -; -if -start -= -= -end -{ -write -! -( -f -" -{ -: -? -} -= -> -{ -: -? -} -" -DebugByte -( -start -) -next -. -as_usize -( -) -) -? -; -} -else -{ -write -! -( -f -" -{ -: -? -} -- -{ -: -? -} -= -> -{ -: -? -} -" -DebugByte -( -start -) -DebugByte -( -end -) -next -. -as_usize -( -) -) -? -; -} -printed -= -true -; -} -let -eoi -= -self -. -next_at -( -self -. -ntrans -- -1 -) -; -if -eoi -! -= -DEAD -{ -if -printed -{ -write -! -( -f -" -" -) -? -; -} -write -! -( -f -" -EOI -= -> -{ -: -? -} -" -eoi -. -as_usize -( -) -) -? -; -} -Ok -( -( -) -) -} -} -/ -/ -/ -A -representation -of -a -mutable -sparse -DFA -state -that -can -be -cheaply -/ -/ -/ -materialized -from -a -state -identifier -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -struct -StateMut -< -' -a -> -{ -/ -/ -/ -The -identifier -of -this -state -. -id -: -StateID -/ -/ -/ -Whether -this -is -a -match -state -or -not -. -is_match -: -bool -/ -/ -/ -The -number -of -transitions -in -this -state -. -ntrans -: -usize -/ -/ -/ -Pairs -of -input -ranges -where -there -is -one -pair -for -each -transition -. -/ -/ -/ -Each -pair -specifies -an -inclusive -start -and -end -byte -range -for -the -/ -/ -/ -corresponding -transition -. -input_ranges -: -& -' -a -mut -[ -u8 -] -/ -/ -/ -Transitions -to -the -next -state -. -This -slice -contains -native -endian -/ -/ -/ -encoded -state -identifiers -with -S -as -the -representation -. -Thus -there -/ -/ -/ -are -ntrans -* -size_of -: -: -< -S -> -( -) -bytes -in -this -slice -. -next -: -& -' -a -mut -[ -u8 -] -/ -/ -/ -If -this -is -a -match -state -then -this -contains -the -pattern -IDs -that -match -/ -/ -/ -when -the -DFA -is -in -this -state -. -/ -/ -/ -/ -/ -/ -This -is -a -contiguous -sequence -of -32 -- -bit -native -endian -encoded -integers -. -pattern_ids -: -& -' -a -[ -u8 -] -/ -/ -/ -An -accelerator -for -this -state -if -present -. -If -this -state -has -no -/ -/ -/ -accelerator -then -this -is -an -empty -slice -. -When -non -- -empty -this -slice -/ -/ -/ -has -length -at -most -3 -and -corresponds -to -the -exhaustive -set -of -bytes -/ -/ -/ -that -must -be -seen -in -order -to -transition -out -of -this -state -. -accel -: -& -' -a -mut -[ -u8 -] -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -< -' -a -> -StateMut -< -' -a -> -{ -/ -/ -/ -Sets -the -ith -transition -to -the -given -state -. -fn -set_next_at -( -& -mut -self -i -: -usize -next -: -StateID -) -{ -let -start -= -i -* -StateID -: -: -SIZE -; -let -end -= -start -+ -StateID -: -: -SIZE -; -wire -: -: -write_state_id -: -: -< -wire -: -: -NE -> -( -next -& -mut -self -. -next -[ -start -. -. -end -] -) -; -} -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -impl -< -' -a -> -fmt -: -: -Debug -for -StateMut -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -let -state -= -State -{ -id -: -self -. -id -is_match -: -self -. -is_match -ntrans -: -self -. -ntrans -input_ranges -: -self -. -input_ranges -next -: -self -. -next -pattern_ids -: -self -. -pattern_ids -accel -: -self -. -accel -} -; -fmt -: -: -Debug -: -: -fmt -( -& -state -f -) -} -} -/ -* -/ -/ -/ -A -binary -search -routine -specialized -specifically -to -a -sparse -DFA -state -' -s -/ -/ -/ -transitions -. -Specifically -the -transitions -are -defined -as -a -set -of -pairs -/ -/ -/ -of -input -bytes -that -delineate -an -inclusive -range -of -bytes -. -If -the -input -/ -/ -/ -byte -is -in -the -range -then -the -corresponding -transition -is -a -match -. -/ -/ -/ -/ -/ -/ -This -binary -search -accepts -a -slice -of -these -pairs -and -returns -the -position -/ -/ -/ -of -the -matching -pair -( -the -ith -transition -) -or -None -if -no -matching -pair -/ -/ -/ -could -be -found -. -/ -/ -/ -/ -/ -/ -Note -that -this -routine -is -not -currently -used -since -it -was -observed -to -/ -/ -/ -either -decrease -performance -when -searching -ASCII -or -did -not -provide -enough -/ -/ -/ -of -a -boost -on -non -- -ASCII -haystacks -to -be -worth -it -. -However -we -leave -it -here -/ -/ -/ -for -posterity -in -case -we -can -find -a -way -to -use -it -. -/ -/ -/ -/ -/ -/ -In -theory -we -could -use -the -standard -library -' -s -search -routine -if -we -could -/ -/ -/ -cast -a -& -[ -u8 -] -to -a -& -[ -( -u8 -u8 -) -] -but -I -don -' -t -believe -this -is -currently -/ -/ -/ -guaranteed -to -be -safe -and -is -thus -UB -( -since -I -don -' -t -think -the -in -- -memory -/ -/ -/ -representation -of -( -u8 -u8 -) -has -been -nailed -down -) -. -One -could -define -a -/ -/ -/ -repr -( -C -) -type -but -the -casting -doesn -' -t -seem -justified -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -binary_search_ranges -( -ranges -: -& -[ -u8 -] -needle -: -u8 -) -- -> -Option -< -usize -> -{ -debug_assert -! -( -ranges -. -len -( -) -% -2 -= -= -0 -" -ranges -must -have -even -length -" -) -; -debug_assert -! -( -ranges -. -len -( -) -< -= -512 -" -ranges -should -be -short -" -) -; -let -( -mut -left -mut -right -) -= -( -0 -ranges -. -len -( -) -/ -2 -) -; -while -left -< -right -{ -let -mid -= -( -left -+ -right -) -/ -2 -; -let -( -b1 -b2 -) -= -( -ranges -[ -mid -* -2 -] -ranges -[ -mid -* -2 -+ -1 -] -) -; -if -needle -< -b1 -{ -right -= -mid -; -} -else -if -needle -> -b2 -{ -left -= -mid -+ -1 -; -} -else -{ -return -Some -( -mid -) -; -} -} -None -} -* -/ -# -[ -cfg -( -all -( -test -feature -= -" -syntax -" -feature -= -" -dfa -- -build -" -) -) -] -mod -tests -{ -use -crate -: -: -{ -dfa -: -: -{ -dense -: -: -DFA -Automaton -} -nfa -: -: -thompson -Input -MatchError -} -; -/ -/ -See -the -analogous -test -in -src -/ -hybrid -/ -dfa -. -rs -and -src -/ -dfa -/ -dense -. -rs -. -# -[ -test -] -fn -heuristic_unicode_forward -( -) -{ -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -unicode_word_boundary -( -true -) -) -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -. -build -( -r -" -\ -b -[ -0 -- -9 -] -+ -\ -b -" -) -. -unwrap -( -) -. -to_sparse -( -) -. -unwrap -( -) -; -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -2 -. -. -) -; -let -expected -= -MatchError -: -: -quit -( -0xB2 -1 -) -; -let -got -= -dfa -. -try_search_fwd -( -& -input -) -; -assert_eq -! -( -Err -( -expected -) -got -) -; -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -. -. -3 -) -; -let -expected -= -MatchError -: -: -quit -( -0xCE -3 -) -; -let -got -= -dfa -. -try_search_fwd -( -& -input -) -; -assert_eq -! -( -Err -( -expected -) -got -) -; -} -/ -/ -See -the -analogous -test -in -src -/ -hybrid -/ -dfa -. -rs -and -src -/ -dfa -/ -dense -. -rs -. -# -[ -test -] -fn -heuristic_unicode_reverse -( -) -{ -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -unicode_word_boundary -( -true -) -) -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -. -build -( -r -" -\ -b -[ -0 -- -9 -] -+ -\ -b -" -) -. -unwrap -( -) -. -to_sparse -( -) -. -unwrap -( -) -; -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -2 -. -. -) -; -let -expected -= -MatchError -: -: -quit -( -0xB2 -1 -) -; -let -got -= -dfa -. -try_search_rev -( -& -input -) -; -assert_eq -! -( -Err -( -expected -) -got -) -; -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -. -. -3 -) -; -let -expected -= -MatchError -: -: -quit -( -0xCE -3 -) -; -let -got -= -dfa -. -try_search_rev -( -& -input -) -; -assert_eq -! -( -Err -( -expected -) -got -) -; -} -} diff --git a/third_party/rust/regex-automata/src/dfa/special.rs b/third_party/rust/regex-automata/src/dfa/special.rs deleted file mode 100644 index 04350c3669761..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/special.rs +++ /dev/null @@ -1,4732 +0,0 @@ -use -crate -: -: -{ -dfa -: -: -DEAD -util -: -: -{ -primitives -: -: -StateID -wire -: -: -{ -self -DeserializeError -Endian -SerializeError -} -} -} -; -macro_rules -! -err -{ -( -msg -: -expr -) -= -> -{ -return -Err -( -DeserializeError -: -: -generic -( -msg -) -) -; -} -; -} -/ -/ -Special -represents -the -identifiers -in -a -DFA -that -correspond -to -" -special -" -/ -/ -states -. -If -a -state -is -one -or -more -of -the -following -then -it -is -considered -/ -/ -special -: -/ -/ -/ -/ -* -dead -- -A -non -- -matching -state -where -all -outgoing -transitions -lead -back -to -/ -/ -itself -. -There -is -only -one -of -these -regardless -of -whether -minimization -/ -/ -has -run -. -The -dead -state -always -has -an -ID -of -0 -. -i -. -e -. -It -is -always -the -/ -/ -first -state -in -a -DFA -. -/ -/ -* -quit -- -A -state -that -is -entered -whenever -a -byte -is -seen -that -should -cause -/ -/ -a -DFA -to -give -up -and -stop -searching -. -This -results -in -a -MatchError -: -: -quit -/ -/ -error -being -returned -at -search -time -. -The -default -configuration -for -a -DFA -/ -/ -has -no -quit -bytes -which -means -this -state -is -unreachable -by -default -/ -/ -although -it -is -always -present -for -reasons -of -implementation -simplicity -. -/ -/ -This -state -is -only -reachable -when -the -caller -configures -the -DFA -to -quit -/ -/ -on -certain -bytes -. -There -is -always -exactly -one -of -these -states -and -it -/ -/ -is -always -the -second -state -. -( -Its -actual -ID -depends -on -the -size -of -the -/ -/ -alphabet -in -dense -DFAs -since -state -IDs -are -premultiplied -in -order -to -/ -/ -allow -them -to -be -used -directly -as -indices -into -the -transition -table -. -) -/ -/ -* -match -- -An -accepting -state -i -. -e -. -indicative -of -a -match -. -There -may -be -/ -/ -zero -or -more -of -these -states -. -/ -/ -* -accelerated -- -A -state -where -all -of -its -outgoing -transitions -except -a -/ -/ -few -loop -back -to -itself -. -These -states -are -candidates -for -acceleration -/ -/ -via -memchr -during -search -. -There -may -be -zero -or -more -of -these -states -. -/ -/ -* -start -- -A -non -- -matching -state -that -indicates -where -the -automaton -should -/ -/ -start -during -a -search -. -There -is -always -at -least -one -starting -state -and -/ -/ -all -are -guaranteed -to -be -non -- -match -states -. -( -A -start -state -cannot -be -a -/ -/ -match -state -because -the -DFAs -in -this -crate -delay -all -matches -by -one -byte -. -/ -/ -So -every -search -that -finds -a -match -must -move -through -one -transition -to -/ -/ -some -other -match -state -even -when -searching -an -empty -string -. -) -/ -/ -/ -/ -These -are -not -mutually -exclusive -categories -. -Namely -the -following -/ -/ -overlappings -can -occur -: -/ -/ -/ -/ -* -{ -dead -start -} -- -If -a -DFA -can -never -lead -to -a -match -and -it -is -minimized -/ -/ -then -it -will -typically -compile -to -something -where -all -starting -IDs -point -/ -/ -to -the -DFA -' -s -dead -state -. -/ -/ -* -{ -match -accelerated -} -- -It -is -possible -for -a -match -state -to -have -the -/ -/ -majority -of -its -transitions -loop -back -to -itself -which -means -it -' -s -/ -/ -possible -for -a -match -state -to -be -accelerated -. -/ -/ -* -{ -start -accelerated -} -- -Similarly -it -is -possible -for -a -start -state -to -be -/ -/ -accelerated -. -Note -that -it -is -possible -for -an -accelerated -state -to -be -/ -/ -neither -a -match -or -a -start -state -. -Also -note -that -just -because -both -match -/ -/ -and -start -states -overlap -with -accelerated -states -does -not -mean -that -/ -/ -match -and -start -states -overlap -with -each -other -. -In -fact -they -are -/ -/ -guaranteed -not -to -overlap -. -/ -/ -/ -/ -As -a -special -mention -every -DFA -always -has -a -dead -and -a -quit -state -even -/ -/ -though -from -the -perspective -of -the -DFA -they -are -equivalent -. -( -Indeed -/ -/ -minimization -special -cases -them -to -ensure -they -don -' -t -get -merged -. -) -The -/ -/ -purpose -of -keeping -them -distinct -is -to -use -the -quit -state -as -a -sentinel -to -/ -/ -distguish -between -whether -a -search -finished -successfully -without -finding -/ -/ -anything -or -whether -it -gave -up -before -finishing -. -/ -/ -/ -/ -So -the -main -problem -we -want -to -solve -here -is -the -* -fast -* -detection -of -whether -/ -/ -a -state -is -special -or -not -. -And -we -also -want -to -do -this -while -storing -as -/ -/ -little -extra -data -as -possible -. -AND -we -want -to -be -able -to -quickly -determine -/ -/ -which -categories -a -state -falls -into -above -if -it -is -special -. -/ -/ -/ -/ -We -achieve -this -by -essentially -shuffling -all -special -states -to -the -beginning -/ -/ -of -a -DFA -. -That -is -all -special -states -appear -before -every -other -non -- -special -/ -/ -state -. -By -representing -special -states -this -way -we -can -determine -whether -a -/ -/ -state -is -special -or -not -by -a -single -comparison -where -special -. -max -is -the -/ -/ -identifier -of -the -last -special -state -in -the -DFA -: -/ -/ -/ -/ -if -current_state -< -= -special -. -max -: -/ -/ -. -. -. -do -something -with -special -state -/ -/ -/ -/ -The -only -thing -left -to -do -is -to -determine -what -kind -of -special -state -/ -/ -it -is -. -Because -what -we -do -next -depends -on -that -. -Since -special -states -/ -/ -are -typically -rare -we -can -afford -to -do -a -bit -more -extra -work -but -we -' -d -/ -/ -still -like -this -to -be -as -fast -as -possible -. -The -trick -we -employ -here -is -to -/ -/ -continue -shuffling -states -even -within -the -special -state -range -. -Such -that -/ -/ -one -contiguous -region -corresponds -to -match -states -another -for -start -states -/ -/ -and -then -an -overlapping -range -for -accelerated -states -. -At -a -high -level -our -/ -/ -special -state -detection -might -look -like -this -( -for -leftmost -searching -where -/ -/ -we -continue -searching -even -after -seeing -a -match -) -: -/ -/ -/ -/ -byte -= -input -[ -offset -] -/ -/ -current_state -= -next_state -( -current_state -byte -) -/ -/ -offset -+ -= -1 -/ -/ -if -current_state -< -= -special -. -max -: -/ -/ -if -current_state -= -= -0 -: -/ -/ -# -We -can -never -leave -a -dead -state -so -this -always -marks -the -/ -/ -# -end -of -our -search -. -/ -/ -return -last_match -/ -/ -if -current_state -= -= -special -. -quit_id -: -/ -/ -# -A -quit -state -means -we -give -up -. -If -he -DFA -has -no -quit -state -/ -/ -# -then -special -. -quit_id -= -= -0 -= -= -dead -which -is -handled -by -the -/ -/ -# -conditional -above -. -/ -/ -return -Err -( -MatchError -: -: -quit -{ -byte -offset -: -offset -- -1 -} -) -/ -/ -if -special -. -min_match -< -= -current_state -< -= -special -. -max_match -: -/ -/ -last_match -= -Some -( -offset -) -/ -/ -if -special -. -min_accel -< -= -current_state -< -= -special -. -max_accel -: -/ -/ -offset -= -accelerate -( -input -offset -) -/ -/ -last_match -= -Some -( -offset -) -/ -/ -elif -special -. -min_start -< -= -current_state -< -= -special -. -max_start -: -/ -/ -offset -= -prefilter -. -find -( -input -offset -) -/ -/ -if -special -. -min_accel -< -= -current_state -< -= -special -. -max_accel -: -/ -/ -offset -= -accelerate -( -input -offset -) -/ -/ -elif -special -. -min_accel -< -= -current_state -< -= -special -. -max_accel -: -/ -/ -offset -= -accelerate -( -input -offset -) -/ -/ -/ -/ -There -are -some -small -details -left -out -of -the -logic -above -. -For -example -/ -/ -in -order -to -accelerate -a -state -we -need -to -know -which -bytes -to -search -for -. -/ -/ -This -in -turn -implies -some -extra -data -we -need -to -store -in -the -DFA -. -To -keep -/ -/ -things -compact -we -would -ideally -only -store -/ -/ -/ -/ -N -= -special -. -max_accel -- -special -. -min_accel -+ -1 -/ -/ -/ -/ -items -. -But -state -IDs -are -premultiplied -which -means -they -are -not -contiguous -. -/ -/ -So -in -order -to -take -a -state -ID -and -index -an -array -of -accelerated -structures -/ -/ -we -need -to -do -: -/ -/ -/ -/ -i -= -( -state_id -- -special -. -min_accel -) -/ -stride -/ -/ -/ -/ -( -N -. -B -. -' -stride -' -is -always -a -power -of -2 -so -the -above -can -be -implemented -via -/ -/ -' -( -state_id -- -special -. -min_accel -) -> -> -stride2 -' -where -' -stride2 -' -is -x -in -/ -/ -2 -^ -x -= -stride -. -) -/ -/ -/ -/ -Moreover -some -of -these -specialty -categories -may -be -empty -. -For -example -/ -/ -DFAs -are -not -required -to -have -any -match -states -or -any -accelerated -states -. -/ -/ -In -that -case -the -lower -and -upper -bounds -are -both -set -to -0 -( -the -dead -state -/ -/ -ID -) -and -the -first -current_state -= -= -0 -check -subsumes -cases -where -the -/ -/ -ranges -are -empty -. -/ -/ -/ -/ -Loop -unrolling -if -applicable -has -also -been -left -out -of -the -logic -above -. -/ -/ -/ -/ -Graphically -the -ranges -look -like -this -where -asterisks -indicate -ranges -/ -/ -that -can -be -empty -. -Each -' -x -' -is -a -state -. -/ -/ -/ -/ -quit -/ -/ -dead -| -/ -/ -| -| -/ -/ -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx -/ -/ -| -| -| -| -start -| -| -/ -/ -| -| -- -- -- -- -- -- -- -- -- -- -- -- -- -| -| -- -- -- -- -- -- -- -| -| -/ -/ -| -match -* -| -| -| -| -/ -/ -| -| -| -| -| -/ -/ -| -| -- -- -- -- -- -- -- -- -- -- -| -| -| -/ -/ -| -accel -* -| -| -/ -/ -| -| -| -/ -/ -| -| -| -/ -/ -| -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -| -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -/ -/ -special -non -- -special -* -# -[ -derive -( -Clone -Copy -Debug -) -] -pub -( -crate -) -struct -Special -{ -/ -/ -/ -The -identifier -of -the -last -special -state -in -a -DFA -. -A -state -is -special -/ -/ -/ -if -and -only -if -its -identifier -is -less -than -or -equal -to -max -. -pub -( -crate -) -max -: -StateID -/ -/ -/ -The -identifier -of -the -quit -state -in -a -DFA -. -( -There -is -no -analogous -field -/ -/ -/ -for -the -dead -state -since -the -dead -state -' -s -ID -is -always -zero -regardless -/ -/ -/ -of -state -ID -size -. -) -pub -( -crate -) -quit_id -: -StateID -/ -/ -/ -The -identifier -of -the -first -match -state -. -pub -( -crate -) -min_match -: -StateID -/ -/ -/ -The -identifier -of -the -last -match -state -. -pub -( -crate -) -max_match -: -StateID -/ -/ -/ -The -identifier -of -the -first -accelerated -state -. -pub -( -crate -) -min_accel -: -StateID -/ -/ -/ -The -identifier -of -the -last -accelerated -state -. -pub -( -crate -) -max_accel -: -StateID -/ -/ -/ -The -identifier -of -the -first -start -state -. -pub -( -crate -) -min_start -: -StateID -/ -/ -/ -The -identifier -of -the -last -start -state -. -pub -( -crate -) -max_start -: -StateID -} -impl -Special -{ -/ -/ -/ -Creates -a -new -set -of -special -ranges -for -a -DFA -. -All -ranges -are -initially -/ -/ -/ -set -to -only -contain -the -dead -state -. -This -is -interpreted -as -an -empty -/ -/ -/ -range -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -new -( -) -- -> -Special -{ -Special -{ -max -: -DEAD -quit_id -: -DEAD -min_match -: -DEAD -max_match -: -DEAD -min_accel -: -DEAD -max_accel -: -DEAD -min_start -: -DEAD -max_start -: -DEAD -} -} -/ -/ -/ -Remaps -all -of -the -special -state -identifiers -using -the -function -given -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -remap -( -& -self -map -: -impl -Fn -( -StateID -) -- -> -StateID -) -- -> -Special -{ -Special -{ -max -: -map -( -self -. -max -) -quit_id -: -map -( -self -. -quit_id -) -min_match -: -map -( -self -. -min_match -) -max_match -: -map -( -self -. -max_match -) -min_accel -: -map -( -self -. -min_accel -) -max_accel -: -map -( -self -. -max_accel -) -min_start -: -map -( -self -. -min_start -) -max_start -: -map -( -self -. -max_start -) -} -} -/ -/ -/ -Deserialize -the -given -bytes -into -special -state -ranges -. -If -the -slice -/ -/ -/ -given -is -not -big -enough -then -this -returns -an -error -. -Similarly -if -/ -/ -/ -any -of -the -expected -invariants -around -special -state -ranges -aren -' -t -/ -/ -/ -upheld -an -error -is -returned -. -Note -that -this -does -not -guarantee -that -/ -/ -/ -the -information -returned -is -correct -. -/ -/ -/ -/ -/ -/ -Upon -success -this -returns -the -number -of -bytes -read -in -addition -to -the -/ -/ -/ -special -state -IDs -themselves -. -pub -( -crate -) -fn -from_bytes -( -mut -slice -: -& -[ -u8 -] -) -- -> -Result -< -( -Special -usize -) -DeserializeError -> -{ -wire -: -: -check_slice_len -( -slice -8 -* -StateID -: -: -SIZE -" -special -states -" -) -? -; -let -mut -nread -= -0 -; -let -mut -read_id -= -| -what -| -- -> -Result -< -StateID -DeserializeError -> -{ -let -( -id -nr -) -= -wire -: -: -try_read_state_id -( -slice -what -) -? -; -nread -+ -= -nr -; -slice -= -& -slice -[ -StateID -: -: -SIZE -. -. -] -; -Ok -( -id -) -} -; -let -max -= -read_id -( -" -special -max -id -" -) -? -; -let -quit_id -= -read_id -( -" -special -quit -id -" -) -? -; -let -min_match -= -read_id -( -" -special -min -match -id -" -) -? -; -let -max_match -= -read_id -( -" -special -max -match -id -" -) -? -; -let -min_accel -= -read_id -( -" -special -min -accel -id -" -) -? -; -let -max_accel -= -read_id -( -" -special -max -accel -id -" -) -? -; -let -min_start -= -read_id -( -" -special -min -start -id -" -) -? -; -let -max_start -= -read_id -( -" -special -max -start -id -" -) -? -; -let -special -= -Special -{ -max -quit_id -min_match -max_match -min_accel -max_accel -min_start -max_start -} -; -special -. -validate -( -) -? -; -assert_eq -! -( -nread -special -. -write_to_len -( -) -) -; -Ok -( -( -special -nread -) -) -} -/ -/ -/ -Validate -that -the -information -describing -special -states -satisfies -/ -/ -/ -all -known -invariants -. -pub -( -crate -) -fn -validate -( -& -self -) -- -> -Result -< -( -) -DeserializeError -> -{ -/ -/ -Check -that -both -ends -of -the -range -are -DEAD -or -neither -are -. -if -self -. -min_match -= -= -DEAD -& -& -self -. -max_match -! -= -DEAD -{ -err -! -( -" -min_match -is -DEAD -but -max_match -is -not -" -) -; -} -if -self -. -min_match -! -= -DEAD -& -& -self -. -max_match -= -= -DEAD -{ -err -! -( -" -max_match -is -DEAD -but -min_match -is -not -" -) -; -} -if -self -. -min_accel -= -= -DEAD -& -& -self -. -max_accel -! -= -DEAD -{ -err -! -( -" -min_accel -is -DEAD -but -max_accel -is -not -" -) -; -} -if -self -. -min_accel -! -= -DEAD -& -& -self -. -max_accel -= -= -DEAD -{ -err -! -( -" -max_accel -is -DEAD -but -min_accel -is -not -" -) -; -} -if -self -. -min_start -= -= -DEAD -& -& -self -. -max_start -! -= -DEAD -{ -err -! -( -" -min_start -is -DEAD -but -max_start -is -not -" -) -; -} -if -self -. -min_start -! -= -DEAD -& -& -self -. -max_start -= -= -DEAD -{ -err -! -( -" -max_start -is -DEAD -but -min_start -is -not -" -) -; -} -/ -/ -Check -that -ranges -are -well -formed -. -if -self -. -min_match -> -self -. -max_match -{ -err -! -( -" -min_match -should -not -be -greater -than -max_match -" -) -; -} -if -self -. -min_accel -> -self -. -max_accel -{ -err -! -( -" -min_accel -should -not -be -greater -than -max_accel -" -) -; -} -if -self -. -min_start -> -self -. -max_start -{ -err -! -( -" -min_start -should -not -be -greater -than -max_start -" -) -; -} -/ -/ -Check -that -ranges -are -ordered -with -respect -to -one -another -. -if -self -. -matches -( -) -& -& -self -. -quit_id -> -= -self -. -min_match -{ -err -! -( -" -quit_id -should -not -be -greater -than -min_match -" -) -; -} -if -self -. -accels -( -) -& -& -self -. -quit_id -> -= -self -. -min_accel -{ -err -! -( -" -quit_id -should -not -be -greater -than -min_accel -" -) -; -} -if -self -. -starts -( -) -& -& -self -. -quit_id -> -= -self -. -min_start -{ -err -! -( -" -quit_id -should -not -be -greater -than -min_start -" -) -; -} -if -self -. -matches -( -) -& -& -self -. -accels -( -) -& -& -self -. -min_accel -< -self -. -min_match -{ -err -! -( -" -min_match -should -not -be -greater -than -min_accel -" -) -; -} -if -self -. -matches -( -) -& -& -self -. -starts -( -) -& -& -self -. -min_start -< -self -. -min_match -{ -err -! -( -" -min_match -should -not -be -greater -than -min_start -" -) -; -} -if -self -. -accels -( -) -& -& -self -. -starts -( -) -& -& -self -. -min_start -< -self -. -min_accel -{ -err -! -( -" -min_accel -should -not -be -greater -than -min_start -" -) -; -} -/ -/ -Check -that -max -is -at -least -as -big -as -everything -else -. -if -self -. -max -< -self -. -quit_id -{ -err -! -( -" -quit_id -should -not -be -greater -than -max -" -) -; -} -if -self -. -max -< -self -. -max_match -{ -err -! -( -" -max_match -should -not -be -greater -than -max -" -) -; -} -if -self -. -max -< -self -. -max_accel -{ -err -! -( -" -max_accel -should -not -be -greater -than -max -" -) -; -} -if -self -. -max -< -self -. -max_start -{ -err -! -( -" -max_start -should -not -be -greater -than -max -" -) -; -} -Ok -( -( -) -) -} -/ -/ -/ -Validate -that -the -special -state -information -is -compatible -with -the -/ -/ -/ -given -state -len -. -pub -( -crate -) -fn -validate_state_len -( -& -self -len -: -usize -stride2 -: -usize -) -- -> -Result -< -( -) -DeserializeError -> -{ -/ -/ -We -assume -that -' -validate -' -has -already -passed -so -we -know -that -' -max -' -/ -/ -is -truly -the -max -. -So -all -we -need -to -check -is -that -the -max -state -ID -/ -/ -is -less -than -the -state -ID -len -. -The -max -legal -value -here -is -len -- -1 -/ -/ -which -occurs -when -there -are -no -non -- -special -states -. -if -( -self -. -max -. -as_usize -( -) -> -> -stride2 -) -> -= -len -{ -err -! -( -" -max -should -not -be -greater -than -or -equal -to -state -length -" -) -; -} -Ok -( -( -) -) -} -/ -/ -/ -Write -the -IDs -and -ranges -for -special -states -to -the -given -byte -buffer -. -/ -/ -/ -The -buffer -given -must -have -enough -room -to -store -all -data -otherwise -/ -/ -/ -this -will -return -an -error -. -The -number -of -bytes -written -is -returned -/ -/ -/ -on -success -. -The -number -of -bytes -written -is -guaranteed -to -be -a -multiple -/ -/ -/ -of -8 -. -pub -( -crate -) -fn -write_to -< -E -: -Endian -> -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -use -crate -: -: -util -: -: -wire -: -: -write_state_id -as -write -; -if -dst -. -len -( -) -< -self -. -write_to_len -( -) -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -special -state -ids -" -) -) -; -} -let -mut -nwrite -= -0 -; -nwrite -+ -= -write -: -: -< -E -> -( -self -. -max -& -mut -dst -[ -nwrite -. -. -] -) -; -nwrite -+ -= -write -: -: -< -E -> -( -self -. -quit_id -& -mut -dst -[ -nwrite -. -. -] -) -; -nwrite -+ -= -write -: -: -< -E -> -( -self -. -min_match -& -mut -dst -[ -nwrite -. -. -] -) -; -nwrite -+ -= -write -: -: -< -E -> -( -self -. -max_match -& -mut -dst -[ -nwrite -. -. -] -) -; -nwrite -+ -= -write -: -: -< -E -> -( -self -. -min_accel -& -mut -dst -[ -nwrite -. -. -] -) -; -nwrite -+ -= -write -: -: -< -E -> -( -self -. -max_accel -& -mut -dst -[ -nwrite -. -. -] -) -; -nwrite -+ -= -write -: -: -< -E -> -( -self -. -min_start -& -mut -dst -[ -nwrite -. -. -] -) -; -nwrite -+ -= -write -: -: -< -E -> -( -self -. -max_start -& -mut -dst -[ -nwrite -. -. -] -) -; -assert_eq -! -( -self -. -write_to_len -( -) -nwrite -" -expected -to -write -certain -number -of -bytes -" -) -; -assert_eq -! -( -nwrite -% -8 -0 -" -expected -to -write -multiple -of -8 -bytes -for -special -states -" -) -; -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -total -number -of -bytes -written -by -write_to -. -pub -( -crate -) -fn -write_to_len -( -& -self -) -- -> -usize -{ -8 -* -StateID -: -: -SIZE -} -/ -/ -/ -Sets -the -maximum -special -state -ID -based -on -the -current -values -. -This -/ -/ -/ -should -be -used -once -all -possible -state -IDs -are -set -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -set_max -( -& -mut -self -) -{ -use -core -: -: -cmp -: -: -max -; -self -. -max -= -max -( -self -. -quit_id -max -( -self -. -max_match -max -( -self -. -max_accel -self -. -max_start -) -) -) -; -} -/ -/ -/ -Sets -the -maximum -special -state -ID -such -that -starting -states -are -not -/ -/ -/ -considered -" -special -. -" -This -also -marks -the -min -/ -max -starting -states -as -/ -/ -/ -DEAD -such -that -' -is_start_state -' -always -returns -false -even -if -the -state -/ -/ -/ -is -actually -a -starting -state -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -there -is -no -prefilter -set -. -It -will -avoid -/ -/ -/ -ping -- -ponging -between -the -hot -path -in -the -DFA -search -code -and -the -start -/ -/ -/ -state -handling -code -which -is -typically -only -useful -for -executing -a -/ -/ -/ -prefilter -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -set_no_special_start_states -( -& -mut -self -) -{ -use -core -: -: -cmp -: -: -max -; -self -. -max -= -max -( -self -. -quit_id -max -( -self -. -max_match -self -. -max_accel -) -) -; -self -. -min_start -= -DEAD -; -self -. -max_start -= -DEAD -; -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -state -ID -is -a -special -state -. -# -[ -inline -] -pub -( -crate -) -fn -is_special_state -( -& -self -id -: -StateID -) -- -> -bool -{ -id -< -= -self -. -max -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -state -ID -is -a -dead -state -. -# -[ -inline -] -pub -( -crate -) -fn -is_dead_state -( -& -self -id -: -StateID -) -- -> -bool -{ -id -= -= -DEAD -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -state -ID -is -a -quit -state -. -# -[ -inline -] -pub -( -crate -) -fn -is_quit_state -( -& -self -id -: -StateID -) -- -> -bool -{ -! -self -. -is_dead_state -( -id -) -& -& -self -. -quit_id -= -= -id -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -state -ID -is -a -match -state -. -# -[ -inline -] -pub -( -crate -) -fn -is_match_state -( -& -self -id -: -StateID -) -- -> -bool -{ -! -self -. -is_dead_state -( -id -) -& -& -self -. -min_match -< -= -id -& -& -id -< -= -self -. -max_match -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -state -ID -is -an -accel -state -. -# -[ -inline -] -pub -( -crate -) -fn -is_accel_state -( -& -self -id -: -StateID -) -- -> -bool -{ -! -self -. -is_dead_state -( -id -) -& -& -self -. -min_accel -< -= -id -& -& -id -< -= -self -. -max_accel -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -state -ID -is -a -start -state -. -# -[ -inline -] -pub -( -crate -) -fn -is_start_state -( -& -self -id -: -StateID -) -- -> -bool -{ -! -self -. -is_dead_state -( -id -) -& -& -self -. -min_start -< -= -id -& -& -id -< -= -self -. -max_start -} -/ -/ -/ -Returns -the -total -number -of -match -states -for -a -dense -table -based -DFA -. -# -[ -inline -] -pub -( -crate -) -fn -match_len -( -& -self -stride -: -usize -) -- -> -usize -{ -if -self -. -matches -( -) -{ -( -self -. -max_match -. -as_usize -( -) -- -self -. -min_match -. -as_usize -( -) -+ -stride -) -/ -stride -} -else -{ -0 -} -} -/ -/ -/ -Returns -true -if -and -only -if -there -is -at -least -one -match -state -. -# -[ -inline -] -pub -( -crate -) -fn -matches -( -& -self -) -- -> -bool -{ -self -. -min_match -! -= -DEAD -} -/ -/ -/ -Returns -the -total -number -of -accel -states -. -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -accel_len -( -& -self -stride -: -usize -) -- -> -usize -{ -if -self -. -accels -( -) -{ -( -self -. -max_accel -. -as_usize -( -) -- -self -. -min_accel -. -as_usize -( -) -+ -stride -) -/ -stride -} -else -{ -0 -} -} -/ -/ -/ -Returns -true -if -and -only -if -there -is -at -least -one -accel -state -. -# -[ -inline -] -pub -( -crate -) -fn -accels -( -& -self -) -- -> -bool -{ -self -. -min_accel -! -= -DEAD -} -/ -/ -/ -Returns -true -if -and -only -if -there -is -at -least -one -start -state -. -# -[ -inline -] -pub -( -crate -) -fn -starts -( -& -self -) -- -> -bool -{ -self -. -min_start -! -= -DEAD -} -} diff --git a/third_party/rust/regex-automata/src/dfa/start.rs b/third_party/rust/regex-automata/src/dfa/start.rs deleted file mode 100644 index fce0374bd7ac8..0000000000000 --- a/third_party/rust/regex-automata/src/dfa/start.rs +++ /dev/null @@ -1,626 +0,0 @@ -use -core -: -: -mem -: -: -size_of -; -use -crate -: -: -util -: -: -wire -: -: -{ -self -DeserializeError -Endian -SerializeError -} -; -/ -/ -/ -The -kind -of -anchored -starting -configurations -to -support -in -a -DFA -. -/ -/ -/ -/ -/ -/ -Fully -compiled -DFAs -need -to -be -explicitly -configured -as -to -which -anchored -/ -/ -/ -starting -configurations -to -support -. -The -reason -for -not -just -supporting -/ -/ -/ -everything -unconditionally -is -that -it -can -use -more -resources -( -such -as -/ -/ -/ -memory -and -build -time -) -. -The -downside -of -this -is -that -if -you -try -to -execute -/ -/ -/ -a -search -using -an -[ -Anchored -] -( -crate -: -: -Anchored -) -mode -that -is -not -supported -/ -/ -/ -by -the -DFA -then -the -search -will -return -an -error -. -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -StartKind -{ -/ -/ -/ -Support -both -anchored -and -unanchored -searches -. -Both -/ -/ -/ -Support -only -unanchored -searches -. -Requesting -an -anchored -search -will -/ -/ -/ -panic -. -/ -/ -/ -/ -/ -/ -Note -that -even -if -an -unanchored -search -is -requested -the -pattern -itself -/ -/ -/ -may -still -be -anchored -. -For -example -^ -abc -will -only -match -abc -at -the -/ -/ -/ -start -of -a -haystack -. -This -will -remain -true -even -if -the -regex -engine -/ -/ -/ -only -supported -unanchored -searches -. -Unanchored -/ -/ -/ -Support -only -anchored -searches -. -Requesting -an -unanchored -search -will -/ -/ -/ -panic -. -Anchored -} -impl -StartKind -{ -pub -( -crate -) -fn -from_bytes -( -slice -: -& -[ -u8 -] -) -- -> -Result -< -( -StartKind -usize -) -DeserializeError -> -{ -wire -: -: -check_slice_len -( -slice -size_of -: -: -< -u32 -> -( -) -" -start -kind -bytes -" -) -? -; -let -( -n -nr -) -= -wire -: -: -try_read_u32 -( -slice -" -start -kind -integer -" -) -? -; -match -n -{ -0 -= -> -Ok -( -( -StartKind -: -: -Both -nr -) -) -1 -= -> -Ok -( -( -StartKind -: -: -Unanchored -nr -) -) -2 -= -> -Ok -( -( -StartKind -: -: -Anchored -nr -) -) -_ -= -> -Err -( -DeserializeError -: -: -generic -( -" -unrecognized -start -kind -" -) -) -} -} -pub -( -crate -) -fn -write_to -< -E -: -Endian -> -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -start -kind -" -) -) -; -} -let -n -= -match -* -self -{ -StartKind -: -: -Both -= -> -0 -StartKind -: -: -Unanchored -= -> -1 -StartKind -: -: -Anchored -= -> -2 -} -; -E -: -: -write_u32 -( -n -dst -) -; -Ok -( -nwrite -) -} -pub -( -crate -) -fn -write_to_len -( -& -self -) -- -> -usize -{ -size_of -: -: -< -u32 -> -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -has_unanchored -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -StartKind -: -: -Both -| -StartKind -: -: -Unanchored -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -has_anchored -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -StartKind -: -: -Both -| -StartKind -: -: -Anchored -) -} -} diff --git a/third_party/rust/regex-automata/src/hybrid/dfa.rs b/third_party/rust/regex-automata/src/hybrid/dfa.rs deleted file mode 100644 index 3368cce9e4103..0000000000000 --- a/third_party/rust/regex-automata/src/hybrid/dfa.rs +++ /dev/null @@ -1,44818 +0,0 @@ -/ -* -! -Types -and -routines -specific -to -lazy -DFAs -. -This -module -is -the -home -of -[ -hybrid -: -: -dfa -: -: -DFA -] -( -DFA -) -. -This -module -also -contains -a -[ -hybrid -: -: -dfa -: -: -Builder -] -( -Builder -) -and -a -[ -hybrid -: -: -dfa -: -: -Config -] -( -Config -) -for -configuring -and -building -a -lazy -DFA -. -* -/ -use -core -: -: -{ -iter -mem -: -: -size_of -} -; -use -alloc -: -: -vec -: -: -Vec -; -use -crate -: -: -{ -hybrid -: -: -{ -error -: -: -{ -BuildError -CacheError -} -id -: -: -{ -LazyStateID -LazyStateIDError -} -search -} -nfa -: -: -thompson -util -: -: -{ -alphabet -: -: -{ -self -ByteClasses -ByteSet -} -determinize -: -: -{ -self -State -StateBuilderEmpty -StateBuilderNFA -} -empty -prefilter -: -: -Prefilter -primitives -: -: -{ -PatternID -StateID -as -NFAStateID -} -search -: -: -{ -Anchored -HalfMatch -Input -MatchError -MatchKind -PatternSet -} -sparse_set -: -: -SparseSets -start -: -: -{ -Start -StartByteMap -} -} -} -; -/ -/ -/ -The -minimum -number -of -states -that -a -lazy -DFA -' -s -cache -size -must -support -. -/ -/ -/ -/ -/ -/ -This -is -checked -at -time -of -construction -to -ensure -that -at -least -some -small -/ -/ -/ -number -of -states -can -fit -in -the -given -capacity -allotment -. -If -we -can -' -t -fit -/ -/ -/ -at -least -this -number -of -states -then -the -thinking -is -that -it -' -s -pretty -/ -/ -/ -senseless -to -use -the -lazy -DFA -. -More -to -the -point -parts -of -the -code -do -/ -/ -/ -assume -that -the -cache -can -fit -at -least -some -small -number -of -states -. -const -MIN_STATES -: -usize -= -SENTINEL_STATES -+ -2 -; -/ -/ -/ -The -number -of -" -sentinel -" -states -that -get -added -to -every -lazy -DFA -. -/ -/ -/ -/ -/ -/ -These -are -special -states -indicating -status -conditions -of -a -search -: -unknown -/ -/ -/ -dead -and -quit -. -These -states -in -particular -also -use -zero -NFA -states -so -/ -/ -/ -their -memory -usage -is -quite -small -. -This -is -relevant -for -computing -the -/ -/ -/ -minimum -memory -needed -for -a -lazy -DFA -cache -. -const -SENTINEL_STATES -: -usize -= -3 -; -/ -/ -/ -A -hybrid -NFA -/ -DFA -( -also -called -a -" -lazy -DFA -" -) -for -regex -searching -. -/ -/ -/ -/ -/ -/ -A -lazy -DFA -is -a -DFA -that -builds -itself -at -search -time -. -It -otherwise -has -/ -/ -/ -very -similar -characteristics -as -a -[ -dense -: -: -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -. -/ -/ -/ -Indeed -both -support -precisely -the -same -regex -features -with -precisely -the -/ -/ -/ -same -semantics -. -/ -/ -/ -/ -/ -/ -Where -as -a -dense -: -: -DFA -must -be -completely -built -to -handle -any -input -before -/ -/ -/ -it -may -be -used -for -search -a -lazy -DFA -starts -off -effectively -empty -. -During -/ -/ -/ -a -search -a -lazy -DFA -will -build -itself -depending -on -whether -it -has -already -/ -/ -/ -computed -the -next -transition -or -not -. -If -it -has -then -it -looks -a -lot -like -/ -/ -/ -a -dense -: -: -DFA -internally -: -it -does -a -very -fast -table -based -access -to -find -/ -/ -/ -the -next -transition -. -Otherwise -if -the -state -hasn -' -t -been -computed -then -it -/ -/ -/ -does -determinization -_for -that -specific -transition_ -to -compute -the -next -DFA -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -The -main -selling -point -of -a -lazy -DFA -is -that -in -practice -it -has -/ -/ -/ -the -performance -profile -of -a -dense -: -: -DFA -without -the -weakness -of -it -/ -/ -/ -taking -worst -case -exponential -time -to -build -. -Indeed -for -each -byte -of -/ -/ -/ -input -the -lazy -DFA -will -construct -as -most -one -new -DFA -state -. -Thus -a -/ -/ -/ -lazy -DFA -achieves -worst -case -O -( -mn -) -time -for -regex -search -( -where -m -~ -/ -/ -/ -pattern -. -len -( -) -and -n -~ -haystack -. -len -( -) -) -. -/ -/ -/ -/ -/ -/ -The -main -downsides -of -a -lazy -DFA -are -: -/ -/ -/ -/ -/ -/ -1 -. -It -requires -mutable -" -cache -" -space -during -search -. -This -is -where -the -/ -/ -/ -transition -table -among -other -things -is -stored -. -/ -/ -/ -2 -. -In -pathological -cases -( -e -. -g -. -if -the -cache -is -too -small -) -it -will -run -/ -/ -/ -out -of -room -and -either -require -a -bigger -cache -capacity -or -will -repeatedly -/ -/ -/ -clear -the -cache -and -thus -repeatedly -regenerate -DFA -states -. -Overall -this -/ -/ -/ -will -tend -to -be -slower -than -a -typical -NFA -simulation -. -/ -/ -/ -/ -/ -/ -# -Capabilities -/ -/ -/ -/ -/ -/ -Like -a -dense -: -: -DFA -a -single -lazy -DFA -fundamentally -supports -the -following -/ -/ -/ -operations -: -/ -/ -/ -/ -/ -/ -1 -. -Detection -of -a -match -. -/ -/ -/ -2 -. -Location -of -the -end -of -a -match -. -/ -/ -/ -3 -. -In -the -case -of -a -lazy -DFA -with -multiple -patterns -which -pattern -matched -/ -/ -/ -is -reported -as -well -. -/ -/ -/ -/ -/ -/ -A -notable -absence -from -the -above -list -of -capabilities -is -the -location -of -/ -/ -/ -the -* -start -* -of -a -match -. -In -order -to -provide -both -the -start -and -end -of -/ -/ -/ -a -match -* -two -* -lazy -DFAs -are -required -. -This -functionality -is -provided -by -a -/ -/ -/ -[ -Regex -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -build -a -lazy -DFA -with -the -default -configuration -and -/ -/ -/ -execute -a -search -. -Notice -how -in -contrast -to -a -dense -: -: -DFA -we -must -create -/ -/ -/ -a -cache -and -pass -it -to -our -search -routine -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -8 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -dfa -. -try_search_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -DFA -{ -config -: -Config -nfa -: -thompson -: -: -NFA -stride2 -: -usize -start_map -: -StartByteMap -classes -: -ByteClasses -quitset -: -ByteSet -cache_capacity -: -usize -} -impl -DFA -{ -/ -/ -/ -Parse -the -given -regular -expression -using -a -default -configuration -and -/ -/ -/ -return -the -corresponding -lazy -DFA -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -[ -Builder -] -to -/ -/ -/ -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -11 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -expected -) -/ -/ -/ -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -foo12345bar -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -DFA -BuildError -> -{ -DFA -: -: -builder -( -) -. -build -( -pattern -) -} -/ -/ -/ -Parse -the -given -regular -expressions -using -a -default -configuration -and -/ -/ -/ -return -the -corresponding -lazy -multi -- -DFA -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -[ -Builder -] -to -/ -/ -/ -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -1 -3 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -expected -) -/ -/ -/ -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -foo12345bar -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -DFA -BuildError -> -{ -DFA -: -: -builder -( -) -. -build_many -( -patterns -) -} -/ -/ -/ -Create -a -new -lazy -DFA -that -matches -every -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -always_match -( -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -0 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -" -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -" -foo -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -always_match -( -) -- -> -Result -< -DFA -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -always_match -( -) -; -Builder -: -: -new -( -) -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Create -a -new -lazy -DFA -that -never -matches -any -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -never_match -( -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -None -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -foo -" -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -never_match -( -) -- -> -Result -< -DFA -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -never_match -( -) -; -Builder -: -: -new -( -) -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Return -a -default -configuration -for -a -DFA -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -[ -Config -] -/ -/ -/ -type -when -customizing -the -construction -of -a -lazy -DFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -lazy -DFA -that -heuristically -supports -/ -/ -/ -Unicode -word -boundaries -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -MatchError -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -unicode_word_boundary -( -true -) -) -/ -/ -/ -. -build -( -r -" -\ -b -\ -w -+ -\ -b -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -our -haystack -is -all -ASCII -the -DFA -search -sees -then -and -knows -/ -/ -/ -/ -/ -it -is -legal -to -interpret -Unicode -word -boundaries -as -ASCII -word -/ -/ -/ -/ -/ -boundaries -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -! -! -foo -! -! -" -) -; -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -5 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -re -. -try_search_fwd -( -& -mut -cache -& -input -) -? -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -our -haystack -contains -non -- -ASCII -then -the -search -will -fail -/ -/ -/ -/ -/ -with -an -error -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -! -! -! -! -" -) -; -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -b -' -\ -xCE -' -2 -) -; -/ -/ -/ -assert_eq -! -( -Err -( -expected -) -re -. -try_search_fwd -( -& -mut -cache -& -input -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -config -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -/ -/ -/ -Return -a -builder -for -configuring -the -construction -of -a -Regex -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Builder -] -type -in -common -cases -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -the -builder -to -disable -UTF -- -8 -mode -/ -/ -/ -everywhere -for -lazy -DFAs -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -util -: -: -syntax -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -) -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -9 -) -) -; -/ -/ -/ -let -got -= -re -. -try_search_fwd -( -& -mut -cache -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -/ -/ -/ -Create -a -new -cache -for -this -lazy -DFA -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -this -/ -/ -/ -lazy -DFA -. -If -you -want -to -reuse -the -cache -for -another -DFA -then -/ -/ -/ -you -must -call -[ -Cache -: -: -reset -] -with -that -DFA -( -or -equivalently -/ -/ -/ -[ -DFA -: -: -reset_cache -] -) -. -pub -fn -create_cache -( -& -self -) -- -> -Cache -{ -Cache -: -: -new -( -self -) -} -/ -/ -/ -Reset -the -given -cache -such -that -it -can -be -used -for -searching -with -the -/ -/ -/ -this -lazy -DFA -( -and -only -this -DFA -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -lazy -DFA -. -/ -/ -/ -/ -/ -/ -Resetting -a -cache -sets -its -" -clear -count -" -to -0 -. -This -is -relevant -if -the -/ -/ -/ -lazy -DFA -has -been -configured -to -" -give -up -" -after -it -has -cleared -the -/ -/ -/ -cache -a -certain -number -of -times -. -/ -/ -/ -/ -/ -/ -Any -lazy -state -ID -generated -by -the -cache -prior -to -resetting -it -is -/ -/ -/ -invalid -after -the -reset -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -DFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa1 -= -DFA -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -dfa2 -= -DFA -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -dfa1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -HalfMatch -: -: -must -( -0 -2 -) -) -/ -/ -/ -dfa1 -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -dfa2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -DFA -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -dfa1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -dfa2 -. -reset_cache -( -& -mut -cache -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -/ -/ -/ -dfa2 -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -Lazy -: -: -new -( -self -cache -) -. -reset_cache -( -) -} -/ -/ -/ -Returns -the -total -number -of -patterns -compiled -into -this -lazy -DFA -. -/ -/ -/ -/ -/ -/ -In -the -case -of -a -DFA -that -contains -no -patterns -this -returns -0 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -pattern -length -for -a -DFA -that -never -matches -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -hybrid -: -: -dfa -: -: -DFA -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -never_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -dfa -. -pattern_len -( -) -0 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -another -example -for -a -DFA -that -matches -at -every -position -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -hybrid -: -: -dfa -: -: -DFA -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -always_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -dfa -. -pattern_len -( -) -1 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -finally -a -DFA -that -was -constructed -from -multiple -patterns -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -hybrid -: -: -dfa -: -: -DFA -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -dfa -. -pattern_len -( -) -3 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -nfa -. -pattern_len -( -) -} -/ -/ -/ -Returns -the -equivalence -classes -that -make -up -the -alphabet -for -this -DFA -. -/ -/ -/ -/ -/ -/ -Unless -[ -Config -: -: -byte_classes -] -was -disabled -it -is -possible -that -/ -/ -/ -multiple -distinct -bytes -are -grouped -into -the -same -equivalence -class -/ -/ -/ -if -it -is -impossible -for -them -to -discriminate -between -a -match -and -a -/ -/ -/ -non -- -match -. -This -has -the -effect -of -reducing -the -overall -alphabet -size -/ -/ -/ -and -in -turn -potentially -substantially -reducing -the -size -of -the -DFA -' -s -/ -/ -/ -transition -table -. -/ -/ -/ -/ -/ -/ -The -downside -of -using -equivalence -classes -like -this -is -that -every -state -/ -/ -/ -transition -will -automatically -use -this -map -to -convert -an -arbitrary -/ -/ -/ -byte -to -its -corresponding -equivalence -class -. -In -practice -this -has -a -/ -/ -/ -negligible -impact -on -performance -. -pub -fn -byte_classes -( -& -self -) -- -> -& -ByteClasses -{ -& -self -. -classes -} -/ -/ -/ -Returns -this -lazy -DFA -' -s -configuration -. -pub -fn -get_config -( -& -self -) -- -> -& -Config -{ -& -self -. -config -} -/ -/ -/ -Returns -a -reference -to -the -underlying -NFA -. -pub -fn -get_nfa -( -& -self -) -- -> -& -thompson -: -: -NFA -{ -& -self -. -nfa -} -/ -/ -/ -Returns -the -stride -as -a -base -- -2 -exponent -required -for -these -/ -/ -/ -equivalence -classes -. -/ -/ -/ -/ -/ -/ -The -stride -is -always -the -smallest -power -of -2 -that -is -greater -than -or -/ -/ -/ -equal -to -the -alphabet -length -. -This -is -done -so -that -converting -between -/ -/ -/ -state -IDs -and -indices -can -be -done -with -shifts -alone -which -is -much -/ -/ -/ -faster -than -integer -division -. -fn -stride2 -( -& -self -) -- -> -usize -{ -self -. -stride2 -} -/ -/ -/ -Returns -the -total -stride -for -every -state -in -this -lazy -DFA -. -This -/ -/ -/ -corresponds -to -the -total -number -of -transitions -used -by -each -state -in -/ -/ -/ -this -DFA -' -s -transition -table -. -fn -stride -( -& -self -) -- -> -usize -{ -1 -< -< -self -. -stride2 -( -) -} -/ -/ -/ -Returns -the -memory -usage -in -bytes -of -this -lazy -DFA -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -lazy -DFA -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -DFA -> -( -) -. -This -also -does -not -/ -/ -/ -include -the -size -of -the -Cache -used -. -/ -/ -/ -/ -/ -/ -This -also -does -not -include -any -heap -memory -used -by -the -NFA -inside -of -/ -/ -/ -this -hybrid -NFA -/ -DFA -. -This -is -because -the -NFA -' -s -ownership -is -shared -and -/ -/ -/ -thus -not -owned -by -this -hybrid -NFA -/ -DFA -. -More -practically -several -regex -/ -/ -/ -engines -in -this -crate -embed -an -NFA -and -reporting -the -NFA -' -s -memory -/ -/ -/ -usage -in -all -of -them -would -likely -result -in -reporting -higher -heap -/ -/ -/ -memory -than -is -actually -used -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -/ -/ -The -only -thing -that -uses -heap -memory -in -a -DFA -is -the -NFA -. -But -the -/ -/ -NFA -has -shared -ownership -so -reporting -its -memory -as -part -of -the -/ -/ -hybrid -DFA -is -likely -to -lead -to -double -- -counting -the -NFA -memory -/ -/ -somehow -. -In -particular -this -DFA -does -not -really -own -an -NFA -so -/ -/ -including -it -in -the -DFA -' -s -memory -usage -doesn -' -t -seem -semantically -/ -/ -correct -. -0 -} -} -impl -DFA -{ -/ -/ -/ -Executes -a -forward -search -and -returns -the -end -position -of -the -leftmost -/ -/ -/ -match -that -is -found -. -If -no -match -exists -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -In -particular -this -method -continues -searching -even -after -it -enters -/ -/ -/ -a -match -state -. -The -search -only -terminates -once -it -has -reached -the -/ -/ -/ -end -of -the -input -or -when -it -has -entered -a -dead -or -quit -state -. -Upon -/ -/ -/ -termination -the -position -of -the -last -byte -seen -while -still -in -a -match -/ -/ -/ -state -is -returned -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -run -a -basic -search -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -8 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -a -match -is -found -after -reading -the -first -byte -( -a -) -/ -/ -/ -/ -/ -the -leftmost -first -match -semantics -demand -that -we -find -the -earliest -/ -/ -/ -/ -/ -match -that -prefers -earlier -parts -of -the -pattern -over -later -parts -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -" -abc -| -a -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -3 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -" -abc -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specific -pattern -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -lazy -multi -- -DFA -that -permits -searching -/ -/ -/ -for -specific -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -Anchored -HalfMatch -PatternID -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -starts_for_each_pattern -( -true -) -) -/ -/ -/ -. -build_many -( -& -[ -" -[ -a -- -z0 -- -9 -] -{ -6 -} -" -" -[ -a -- -z -] -[ -a -- -z0 -- -9 -] -{ -5 -} -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -foo123 -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -are -using -the -default -leftmost -- -first -match -and -both -/ -/ -/ -/ -/ -patterns -match -at -the -same -starting -position -only -the -first -pattern -/ -/ -/ -/ -/ -will -be -returned -in -this -case -when -doing -a -search -for -any -of -the -/ -/ -/ -/ -/ -patterns -. -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -6 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -want -to -check -whether -some -other -pattern -matches -then -we -/ -/ -/ -/ -/ -can -provide -its -pattern -ID -. -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -1 -6 -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -input -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specifying -the -bounds -of -a -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -providing -the -bounds -of -a -search -can -produce -/ -/ -/ -different -results -than -simply -sub -- -slicing -the -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -We -disable -Unicode -here -so -that -we -use -a -simple -ASCII -word -/ -/ -/ -/ -/ -boundary -. -Alternatively -we -could -enable -heuristic -support -for -/ -/ -/ -/ -/ -Unicode -word -boundaries -since -our -haystack -is -pure -ASCII -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -( -? -- -u -) -\ -b -[ -0 -- -9 -] -{ -3 -} -\ -b -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -sub -- -slice -the -haystack -the -search -doesn -' -t -know -about -the -/ -/ -/ -/ -/ -larger -context -and -assumes -that -123 -is -surrounded -by -word -/ -/ -/ -/ -/ -boundaries -. -And -of -course -the -match -position -is -reported -relative -/ -/ -/ -/ -/ -to -the -sub -- -slice -as -well -which -means -we -get -3 -instead -of -6 -. -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -/ -/ -/ -& -mut -cache -/ -/ -/ -& -Input -: -: -new -( -& -haystack -[ -3 -. -. -6 -] -) -/ -/ -/ -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -provide -the -bounds -of -the -search -within -the -context -of -the -/ -/ -/ -/ -/ -entire -haystack -then -the -search -can -take -the -surrounding -context -/ -/ -/ -/ -/ -into -account -. -( -And -if -we -did -find -a -match -it -would -be -reported -/ -/ -/ -/ -/ -as -a -valid -offset -into -haystack -instead -of -its -sub -- -slice -. -) -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -/ -/ -/ -& -mut -cache -/ -/ -/ -& -Input -: -: -new -( -haystack -) -. -range -( -3 -. -. -6 -) -/ -/ -/ -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_search_fwd -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -let -hm -= -match -search -: -: -find_fwd -( -self -cache -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -hm -) -if -! -utf8empty -= -> -return -Ok -( -Some -( -hm -) -) -Some -( -hm -) -= -> -hm -} -; -/ -/ -We -get -to -this -point -when -we -know -our -DFA -can -match -the -empty -string -/ -/ -AND -when -UTF -- -8 -mode -is -enabled -. -In -this -case -we -skip -any -matches -/ -/ -whose -offset -splits -a -codepoint -. -Such -a -match -is -necessarily -a -/ -/ -zero -- -width -match -because -UTF -- -8 -mode -requires -the -underlying -NFA -/ -/ -to -be -built -such -that -all -non -- -empty -matches -span -valid -UTF -- -8 -. -/ -/ -Therefore -any -match -that -ends -in -the -middle -of -a -codepoint -cannot -/ -/ -be -part -of -a -span -of -valid -UTF -- -8 -and -thus -must -be -an -empty -match -. -/ -/ -In -such -cases -we -skip -it -so -as -not -to -report -matches -that -split -a -/ -/ -codepoint -. -/ -/ -/ -/ -Note -that -this -is -not -a -checked -assumption -. -Callers -* -can -* -provide -an -/ -/ -NFA -with -UTF -- -8 -mode -enabled -but -produces -non -- -empty -matches -that -span -/ -/ -invalid -UTF -- -8 -. -But -doing -so -is -documented -to -result -in -unspecified -/ -/ -behavior -. -empty -: -: -skip_splits_fwd -( -input -hm -hm -. -offset -( -) -| -input -| -{ -let -got -= -search -: -: -find_fwd -( -self -cache -input -) -? -; -Ok -( -got -. -map -( -| -hm -| -( -hm -hm -. -offset -( -) -) -) -) -} -) -} -/ -/ -/ -Executes -a -reverse -search -and -returns -the -start -of -the -position -of -the -/ -/ -/ -leftmost -match -that -is -found -. -If -no -match -exists -then -None -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -routine -is -principally -useful -when -used -in -/ -/ -/ -conjunction -with -the -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -: -: -reverse -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -: -: -reverse -) -/ -/ -/ -configuration -. -In -general -it -' -s -unlikely -to -be -correct -to -use -both -/ -/ -/ -try_search_fwd -and -try_search_rev -with -the -same -DFA -since -any -/ -/ -/ -particular -DFA -will -only -support -searching -in -one -direction -with -/ -/ -/ -respect -to -the -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -0 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -expected -) -/ -/ -/ -dfa -. -try_search_rev -( -& -mut -cache -& -Input -: -: -new -( -" -foo12345 -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -a -match -is -found -after -reading -the -last -byte -( -c -) -/ -/ -/ -/ -/ -the -leftmost -first -match -semantics -demand -that -we -find -the -earliest -/ -/ -/ -/ -/ -match -that -prefers -earlier -parts -of -the -pattern -over -latter -parts -. -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build -( -" -abc -| -c -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -0 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_rev -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -" -abc -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -UTF -- -8 -mode -/ -/ -/ -/ -/ -/ -This -examples -demonstrates -that -UTF -- -8 -mode -applies -to -reverse -/ -/ -/ -DFAs -. -When -UTF -- -8 -mode -is -enabled -in -the -underlying -NFA -then -all -/ -/ -/ -matches -reported -must -correspond -to -valid -UTF -- -8 -spans -. -This -includes -/ -/ -/ -prohibiting -zero -- -width -matches -that -split -a -codepoint -. -/ -/ -/ -/ -/ -/ -UTF -- -8 -mode -is -enabled -by -default -. -Notice -below -how -the -only -zero -- -width -/ -/ -/ -matches -reported -are -those -at -UTF -- -8 -boundaries -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build -( -r -" -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Run -the -reverse -DFA -to -collect -all -matches -. -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -match -dfa -. -try_search_rev -( -& -mut -cache -& -input -) -? -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -hm -) -= -> -{ -/ -/ -/ -matches -. -push -( -hm -) -; -/ -/ -/ -if -hm -. -offset -( -) -= -= -0 -| -| -input -. -end -( -) -= -= -0 -{ -/ -/ -/ -break -; -/ -/ -/ -} -else -if -hm -. -offset -( -) -< -input -. -end -( -) -{ -/ -/ -/ -input -. -set_end -( -hm -. -offset -( -) -) -; -/ -/ -/ -} -else -{ -/ -/ -/ -/ -/ -This -is -only -necessary -to -handle -zero -- -width -/ -/ -/ -/ -/ -matches -which -of -course -occur -in -this -example -. -/ -/ -/ -/ -/ -Without -this -the -search -would -never -advance -/ -/ -/ -/ -/ -backwards -beyond -the -initial -match -. -/ -/ -/ -input -. -set_end -( -input -. -end -( -) -- -1 -) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -No -matches -split -a -codepoint -. -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -0 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Now -let -' -s -look -at -the -same -example -but -with -UTF -- -8 -mode -on -the -/ -/ -/ -underlying -NFA -disabled -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Run -the -reverse -DFA -to -collect -all -matches -. -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -match -dfa -. -try_search_rev -( -& -mut -cache -& -input -) -? -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -hm -) -= -> -{ -/ -/ -/ -matches -. -push -( -hm -) -; -/ -/ -/ -if -hm -. -offset -( -) -= -= -0 -| -| -input -. -end -( -) -= -= -0 -{ -/ -/ -/ -break -; -/ -/ -/ -} -else -if -hm -. -offset -( -) -< -input -. -end -( -) -{ -/ -/ -/ -input -. -set_end -( -hm -. -offset -( -) -) -; -/ -/ -/ -} -else -{ -/ -/ -/ -/ -/ -This -is -only -necessary -to -handle -zero -- -width -/ -/ -/ -/ -/ -matches -which -of -course -occur -in -this -example -. -/ -/ -/ -/ -/ -Without -this -the -search -would -never -advance -/ -/ -/ -/ -/ -backwards -beyond -the -initial -match -. -/ -/ -/ -input -. -set_end -( -input -. -end -( -) -- -1 -) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -No -matches -split -a -codepoint -. -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -2 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -1 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -0 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_search_rev -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -let -hm -= -match -search -: -: -find_rev -( -self -cache -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -hm -) -if -! -utf8empty -= -> -return -Ok -( -Some -( -hm -) -) -Some -( -hm -) -= -> -hm -} -; -empty -: -: -skip_splits_rev -( -input -hm -hm -. -offset -( -) -| -input -| -{ -let -got -= -search -: -: -find_rev -( -self -cache -input -) -? -; -Ok -( -got -. -map -( -| -hm -| -( -hm -hm -. -offset -( -) -) -) -) -} -) -} -/ -/ -/ -Executes -an -overlapping -forward -search -and -returns -the -end -position -of -/ -/ -/ -matches -as -they -are -found -. -If -no -match -exists -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -This -routine -is -principally -only -useful -when -searching -for -multiple -/ -/ -/ -patterns -on -inputs -where -multiple -patterns -may -match -the -same -regions -/ -/ -/ -of -text -. -In -particular -callers -must -preserve -the -automaton -' -s -search -/ -/ -/ -state -from -prior -calls -so -that -the -implementation -knows -where -the -last -/ -/ -/ -match -occurred -. -/ -/ -/ -/ -/ -/ -When -using -this -routine -to -implement -an -iterator -of -overlapping -/ -/ -/ -matches -the -start -of -the -search -should -remain -invariant -throughout -/ -/ -/ -iteration -. -The -OverlappingState -given -to -the -search -will -keep -track -/ -/ -/ -of -the -current -position -of -the -search -. -( -This -is -because -multiple -/ -/ -/ -matches -may -be -reported -at -the -same -position -so -only -the -search -/ -/ -/ -implementation -itself -knows -when -to -advance -the -position -. -) -/ -/ -/ -/ -/ -/ -If -for -some -reason -you -want -the -search -to -forget -about -its -previous -/ -/ -/ -state -and -restart -the -search -at -a -particular -position -then -setting -the -/ -/ -/ -state -to -[ -OverlappingState -: -: -start -] -will -accomplish -that -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -run -a -basic -overlapping -search -. -Notice -/ -/ -/ -that -we -build -the -automaton -with -a -MatchKind -: -: -All -configuration -. -/ -/ -/ -Overlapping -searches -are -unlikely -to -work -as -one -would -expect -when -/ -/ -/ -using -the -default -MatchKind -: -: -LeftmostFirst -match -semantics -since -/ -/ -/ -leftmost -- -first -matching -is -fundamentally -incompatible -with -overlapping -/ -/ -/ -searches -. -Namely -overlapping -searches -need -to -report -matches -as -they -/ -/ -/ -are -seen -where -as -leftmost -- -first -searches -will -continue -searching -even -/ -/ -/ -after -a -match -has -been -observed -in -order -to -find -the -conventional -end -/ -/ -/ -position -of -the -match -. -More -concretely -leftmost -- -first -searches -use -/ -/ -/ -dead -states -to -terminate -a -search -after -a -specific -match -can -no -longer -/ -/ -/ -be -extended -. -Overlapping -searches -instead -do -the -opposite -by -continuing -/ -/ -/ -the -search -to -find -totally -new -matches -( -potentially -of -other -patterns -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -{ -DFA -OverlappingState -} -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -\ -w -+ -" -r -" -\ -S -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -foo -" -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -1 -4 -) -) -; -/ -/ -/ -dfa -. -try_search_overlapping_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -& -mut -state -/ -/ -/ -) -? -; -/ -/ -/ -assert_eq -! -( -expected -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -first -pattern -also -matches -at -the -same -position -so -re -- -running -/ -/ -/ -/ -/ -the -search -will -yield -another -match -. -Notice -also -that -the -first -/ -/ -/ -/ -/ -pattern -is -returned -after -the -second -. -This -is -because -the -second -/ -/ -/ -/ -/ -pattern -begins -its -match -before -the -first -is -therefore -an -earlier -/ -/ -/ -/ -/ -match -and -is -thus -reported -first -. -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -4 -) -) -; -/ -/ -/ -dfa -. -try_search_overlapping_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -& -mut -state -/ -/ -/ -) -? -; -/ -/ -/ -assert_eq -! -( -expected -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_search_overlapping_fwd -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -search -: -: -find_overlapping_fwd -( -self -cache -input -state -) -? -; -match -state -. -get_match -( -) -{ -None -= -> -Ok -( -( -) -) -Some -( -_ -) -if -! -utf8empty -= -> -Ok -( -( -) -) -Some -( -_ -) -= -> -skip_empty_utf8_splits_overlapping -( -input -state -| -input -state -| -{ -search -: -: -find_overlapping_fwd -( -self -cache -input -state -) -} -) -} -} -/ -/ -/ -Executes -a -reverse -overlapping -search -and -returns -the -start -of -the -/ -/ -/ -position -of -the -leftmost -match -that -is -found -. -If -no -match -exists -then -/ -/ -/ -None -is -returned -. -/ -/ -/ -/ -/ -/ -When -using -this -routine -to -implement -an -iterator -of -overlapping -/ -/ -/ -matches -the -start -of -the -search -should -remain -invariant -throughout -/ -/ -/ -iteration -. -The -OverlappingState -given -to -the -search -will -keep -track -/ -/ -/ -of -the -current -position -of -the -search -. -( -This -is -because -multiple -/ -/ -/ -matches -may -be -reported -at -the -same -position -so -only -the -search -/ -/ -/ -implementation -itself -knows -when -to -advance -the -position -. -) -/ -/ -/ -/ -/ -/ -If -for -some -reason -you -want -the -search -to -forget -about -its -previous -/ -/ -/ -state -and -restart -the -search -at -a -particular -position -then -setting -the -/ -/ -/ -state -to -[ -OverlappingState -: -: -start -] -will -accomplish -that -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -: -UTF -- -8 -mode -/ -/ -/ -/ -/ -/ -This -examples -demonstrates -that -UTF -- -8 -mode -applies -to -reverse -/ -/ -/ -DFAs -. -When -UTF -- -8 -mode -is -enabled -in -the -underlying -NFA -then -all -/ -/ -/ -matches -reported -must -correspond -to -valid -UTF -- -8 -spans -. -This -includes -/ -/ -/ -prohibiting -zero -- -width -matches -that -split -a -codepoint -. -/ -/ -/ -/ -/ -/ -UTF -- -8 -mode -is -enabled -by -default -. -Notice -below -how -the -only -zero -- -width -/ -/ -/ -matches -reported -are -those -at -UTF -- -8 -boundaries -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -{ -DFA -OverlappingState -} -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -" -r -" -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Run -the -reverse -DFA -to -collect -all -matches -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -dfa -. -try_search_overlapping_rev -( -& -mut -cache -& -input -& -mut -state -) -? -; -/ -/ -/ -match -state -. -get_match -( -) -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -hm -) -= -> -matches -. -push -( -hm -) -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -No -matches -split -a -codepoint -. -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -1 -0 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -0 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Now -let -' -s -look -at -the -same -example -but -with -UTF -- -8 -mode -on -the -/ -/ -/ -underlying -NFA -disabled -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -{ -DFA -OverlappingState -} -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -" -r -" -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Run -the -reverse -DFA -to -collect -all -matches -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -dfa -. -try_search_overlapping_rev -( -& -mut -cache -& -input -& -mut -state -) -? -; -/ -/ -/ -match -state -. -get_match -( -) -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -hm -) -= -> -matches -. -push -( -hm -) -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -Now -* -all -* -positions -match -even -within -a -codepoint -/ -/ -/ -/ -/ -because -we -lifted -the -requirement -that -matches -/ -/ -/ -/ -/ -correspond -to -valid -UTF -- -8 -spans -. -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -2 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -1 -) -/ -/ -/ -HalfMatch -: -: -must -( -1 -0 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -0 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -matches -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_search_overlapping_rev -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -search -: -: -find_overlapping_rev -( -self -cache -input -state -) -? -; -match -state -. -get_match -( -) -{ -None -= -> -Ok -( -( -) -) -Some -( -_ -) -if -! -utf8empty -= -> -Ok -( -( -) -) -Some -( -_ -) -= -> -skip_empty_utf8_splits_overlapping -( -input -state -| -input -state -| -{ -search -: -: -find_overlapping_rev -( -self -cache -input -state -) -} -) -} -} -/ -/ -/ -Writes -the -set -of -patterns -that -match -anywhere -in -the -given -search -/ -/ -/ -configuration -to -patset -. -If -multiple -patterns -match -at -the -same -/ -/ -/ -position -and -the -underlying -DFA -supports -overlapping -matches -then -all -/ -/ -/ -matching -patterns -are -written -to -the -given -set -. -/ -/ -/ -/ -/ -/ -Unless -all -of -the -patterns -in -this -DFA -are -anchored -then -generally -/ -/ -/ -speaking -this -will -visit -every -byte -in -the -haystack -. -/ -/ -/ -/ -/ -/ -This -search -routine -* -does -not -* -clear -the -pattern -set -. -This -gives -some -/ -/ -/ -flexibility -to -the -caller -( -e -. -g -. -running -multiple -searches -with -the -/ -/ -/ -same -pattern -set -) -but -does -make -the -API -bug -- -prone -if -you -' -re -reusing -/ -/ -/ -the -same -pattern -set -for -multiple -searches -but -intended -them -to -be -/ -/ -/ -independent -. -/ -/ -/ -/ -/ -/ -If -a -pattern -ID -matched -but -the -given -PatternSet -does -not -have -/ -/ -/ -sufficient -capacity -to -store -it -then -it -is -not -inserted -and -silently -/ -/ -/ -dropped -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -all -matching -patterns -in -a -haystack -/ -/ -/ -even -when -some -patterns -match -at -the -same -position -as -other -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -Input -MatchKind -PatternSet -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -/ -/ -/ -r -" -\ -w -+ -" -r -" -\ -d -+ -" -r -" -\ -pL -+ -" -r -" -foo -" -r -" -bar -" -r -" -barfoo -" -r -" -foobar -" -/ -/ -/ -] -; -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -patterns -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -let -mut -patset -= -PatternSet -: -: -new -( -dfa -. -pattern_len -( -) -) -; -/ -/ -/ -dfa -. -try_which_overlapping_matches -( -& -mut -cache -& -input -& -mut -patset -) -? -; -/ -/ -/ -let -expected -= -vec -! -[ -0 -2 -3 -4 -6 -] -; -/ -/ -/ -let -got -: -Vec -< -usize -> -= -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_which_overlapping_matches -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -- -> -Result -< -( -) -MatchError -> -{ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -while -let -Some -( -m -) -= -{ -self -. -try_search_overlapping_fwd -( -cache -input -& -mut -state -) -? -; -state -. -get_match -( -) -} -{ -let -_ -= -patset -. -try_insert -( -m -. -pattern -( -) -) -; -/ -/ -There -' -s -nothing -left -to -find -so -we -can -stop -. -Or -the -caller -/ -/ -asked -us -to -. -if -patset -. -is_full -( -) -| -| -input -. -get_earliest -( -) -{ -break -; -} -} -Ok -( -( -) -) -} -} -impl -DFA -{ -/ -/ -/ -Transitions -from -the -current -state -to -the -next -state -given -the -next -/ -/ -/ -byte -of -input -. -/ -/ -/ -/ -/ -/ -The -given -cache -is -used -to -either -reuse -pre -- -computed -state -/ -/ -/ -transitions -or -to -store -this -newly -computed -transition -for -future -/ -/ -/ -reuse -. -Thus -this -routine -guarantees -that -it -will -never -return -a -state -/ -/ -/ -ID -that -has -an -" -unknown -" -tag -. -/ -/ -/ -/ -/ -/ -# -State -identifier -validity -/ -/ -/ -/ -/ -/ -The -only -valid -value -for -current -is -the -lazy -state -ID -returned -/ -/ -/ -by -the -most -recent -call -to -next_state -next_state_untagged -/ -/ -/ -next_state_untagged_unchecked -start_state_forward -or -/ -/ -/ -state_state_reverse -for -the -given -cache -. -Any -state -ID -returned -from -/ -/ -/ -prior -calls -to -these -routines -( -with -the -same -cache -) -is -considered -/ -/ -/ -invalid -( -even -if -it -gives -an -appearance -of -working -) -. -State -IDs -returned -/ -/ -/ -from -_any_ -prior -call -for -different -cache -values -are -also -always -/ -/ -/ -invalid -. -/ -/ -/ -/ -/ -/ -The -returned -ID -is -always -a -valid -ID -when -current -refers -to -a -valid -/ -/ -/ -ID -. -Moreover -this -routine -is -defined -for -all -possible -values -of -/ -/ -/ -input -. -/ -/ -/ -/ -/ -/ -These -validity -rules -are -not -checked -even -in -debug -mode -. -Callers -are -/ -/ -/ -required -to -uphold -these -rules -themselves -. -/ -/ -/ -/ -/ -/ -Violating -these -state -ID -validity -rules -will -not -sacrifice -memory -/ -/ -/ -safety -but -_may_ -produce -an -incorrect -result -or -a -panic -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -given -ID -does -not -refer -to -a -valid -state -then -this -routine -/ -/ -/ -may -panic -but -it -also -may -not -panic -and -instead -return -an -invalid -or -/ -/ -/ -incorrect -ID -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -simplistic -example -for -walking -a -lazy -DFA -for -a -given -/ -/ -/ -haystack -by -using -the -next_state -method -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -r -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -/ -/ -/ -let -mut -sid -= -dfa -. -start_state_forward -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -/ -/ -/ -) -? -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -/ -/ -/ -for -& -b -in -haystack -{ -/ -/ -/ -sid -= -dfa -. -next_state -( -& -mut -cache -sid -b -) -? -; -/ -/ -/ -} -/ -/ -/ -/ -/ -Matches -are -always -delayed -by -1 -byte -so -we -must -explicitly -walk -the -/ -/ -/ -/ -/ -special -" -EOI -" -transition -at -the -end -of -the -search -. -/ -/ -/ -sid -= -dfa -. -next_eoi_state -( -& -mut -cache -sid -) -? -; -/ -/ -/ -assert -! -( -sid -. -is_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -next_state -( -& -self -cache -: -& -mut -Cache -current -: -LazyStateID -input -: -u8 -) -- -> -Result -< -LazyStateID -CacheError -> -{ -let -class -= -usize -: -: -from -( -self -. -classes -. -get -( -input -) -) -; -let -offset -= -current -. -as_usize_untagged -( -) -+ -class -; -let -sid -= -cache -. -trans -[ -offset -] -; -if -! -sid -. -is_unknown -( -) -{ -return -Ok -( -sid -) -; -} -let -unit -= -alphabet -: -: -Unit -: -: -u8 -( -input -) -; -Lazy -: -: -new -( -self -cache -) -. -cache_next_state -( -current -unit -) -} -/ -/ -/ -Transitions -from -the -current -state -to -the -next -state -given -the -next -/ -/ -/ -byte -of -input -and -a -state -ID -that -is -not -tagged -. -/ -/ -/ -/ -/ -/ -The -only -reason -to -use -this -routine -is -performance -. -In -particular -the -/ -/ -/ -next_state -method -needs -to -do -some -additional -checks -among -them -is -/ -/ -/ -to -account -for -identifiers -to -states -that -are -not -yet -computed -. -In -/ -/ -/ -such -a -case -the -transition -is -computed -on -the -fly -. -However -if -it -is -/ -/ -/ -known -that -the -current -state -ID -is -untagged -then -these -checks -can -be -/ -/ -/ -omitted -. -/ -/ -/ -/ -/ -/ -Since -this -routine -does -not -compute -states -on -the -fly -it -does -not -/ -/ -/ -modify -the -cache -and -thus -cannot -return -an -error -. -Consequently -cache -/ -/ -/ -does -not -need -to -be -mutable -and -it -is -possible -for -this -routine -to -/ -/ -/ -return -a -state -ID -corresponding -to -the -special -" -unknown -" -state -. -In -/ -/ -/ -this -case -it -is -the -caller -' -s -responsibility -to -use -the -prior -state -/ -/ -/ -ID -and -input -with -next_state -in -order -to -force -the -computation -of -/ -/ -/ -the -unknown -transition -. -Otherwise -trying -to -use -the -" -unknown -" -state -/ -/ -/ -ID -will -just -result -in -transitioning -back -to -itself -and -thus -never -/ -/ -/ -terminating -. -( -This -is -technically -a -special -exemption -to -the -state -ID -/ -/ -/ -validity -rules -but -is -permissible -since -this -routine -is -guarateed -to -/ -/ -/ -never -mutate -the -given -cache -and -thus -the -identifier -is -guaranteed -/ -/ -/ -to -remain -valid -. -) -/ -/ -/ -/ -/ -/ -See -[ -LazyStateID -] -for -more -details -on -what -it -means -for -a -state -ID -/ -/ -/ -to -be -tagged -. -Also -see -/ -/ -/ -[ -next_state_untagged_unchecked -] -( -DFA -: -: -next_state_untagged_unchecked -) -/ -/ -/ -for -this -same -idea -but -with -bounds -checks -forcefully -elided -. -/ -/ -/ -/ -/ -/ -# -State -identifier -validity -/ -/ -/ -/ -/ -/ -The -only -valid -value -for -current -is -an -* -* -untagged -* -* -lazy -/ -/ -/ -state -ID -returned -by -the -most -recent -call -to -next_state -/ -/ -/ -next_state_untagged -next_state_untagged_unchecked -/ -/ -/ -start_state_forward -or -state_state_reverse -for -the -given -cache -. -/ -/ -/ -Any -state -ID -returned -from -prior -calls -to -these -routines -( -with -the -/ -/ -/ -same -cache -) -is -considered -invalid -( -even -if -it -gives -an -appearance -/ -/ -/ -of -working -) -. -State -IDs -returned -from -_any_ -prior -call -for -different -/ -/ -/ -cache -values -are -also -always -invalid -. -/ -/ -/ -/ -/ -/ -The -returned -ID -is -always -a -valid -ID -when -current -refers -to -a -valid -/ -/ -/ -ID -although -it -may -be -tagged -. -Moreover -this -routine -is -defined -for -/ -/ -/ -all -possible -values -of -input -. -/ -/ -/ -/ -/ -/ -Not -all -validity -rules -are -checked -even -in -debug -mode -. -Callers -are -/ -/ -/ -required -to -uphold -these -rules -themselves -. -/ -/ -/ -/ -/ -/ -Violating -these -state -ID -validity -rules -will -not -sacrifice -memory -/ -/ -/ -safety -but -_may_ -produce -an -incorrect -result -or -a -panic -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -given -ID -does -not -refer -to -a -valid -state -then -this -routine -/ -/ -/ -may -panic -but -it -also -may -not -panic -and -instead -return -an -invalid -or -/ -/ -/ -incorrect -ID -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -simplistic -example -for -walking -a -lazy -DFA -for -a -given -/ -/ -/ -haystack -by -using -the -next_state_untagged -method -where -possible -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -r -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -/ -/ -/ -let -mut -sid -= -dfa -. -start_state_forward -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -/ -/ -/ -) -? -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -/ -/ -/ -let -mut -at -= -0 -; -/ -/ -/ -while -at -< -haystack -. -len -( -) -{ -/ -/ -/ -if -sid -. -is_tagged -( -) -{ -/ -/ -/ -sid -= -dfa -. -next_state -( -& -mut -cache -sid -haystack -[ -at -] -) -? -; -/ -/ -/ -} -else -{ -/ -/ -/ -let -mut -prev_sid -= -sid -; -/ -/ -/ -/ -/ -We -attempt -to -chew -through -as -much -as -we -can -while -moving -/ -/ -/ -/ -/ -through -untagged -state -IDs -. -Thus -the -transition -function -/ -/ -/ -/ -/ -does -less -work -on -average -per -byte -. -( -Unrolling -this -loop -/ -/ -/ -/ -/ -may -help -even -more -. -) -/ -/ -/ -while -at -< -haystack -. -len -( -) -{ -/ -/ -/ -prev_sid -= -sid -; -/ -/ -/ -sid -= -dfa -. -next_state_untagged -( -/ -/ -/ -& -mut -cache -sid -haystack -[ -at -] -/ -/ -/ -) -; -/ -/ -/ -at -+ -= -1 -; -/ -/ -/ -if -sid -. -is_tagged -( -) -{ -/ -/ -/ -break -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -We -must -ensure -that -we -never -proceed -to -the -next -iteration -/ -/ -/ -/ -/ -with -an -unknown -state -ID -. -If -we -don -' -t -account -for -this -/ -/ -/ -/ -/ -case -then -search -isn -' -t -guaranteed -to -terminate -since -all -/ -/ -/ -/ -/ -transitions -on -unknown -states -loop -back -to -itself -. -/ -/ -/ -if -sid -. -is_unknown -( -) -{ -/ -/ -/ -sid -= -dfa -. -next_state -( -/ -/ -/ -& -mut -cache -prev_sid -haystack -[ -at -- -1 -] -/ -/ -/ -) -? -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -Matches -are -always -delayed -by -1 -byte -so -we -must -explicitly -walk -the -/ -/ -/ -/ -/ -special -" -EOI -" -transition -at -the -end -of -the -search -. -/ -/ -/ -sid -= -dfa -. -next_eoi_state -( -& -mut -cache -sid -) -? -; -/ -/ -/ -assert -! -( -sid -. -is_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -next_state_untagged -( -& -self -cache -: -& -Cache -current -: -LazyStateID -input -: -u8 -) -- -> -LazyStateID -{ -debug_assert -! -( -! -current -. -is_tagged -( -) -) -; -let -class -= -usize -: -: -from -( -self -. -classes -. -get -( -input -) -) -; -let -offset -= -current -. -as_usize_unchecked -( -) -+ -class -; -cache -. -trans -[ -offset -] -} -/ -/ -/ -Transitions -from -the -current -state -to -the -next -state -eliding -bounds -/ -/ -/ -checks -given -the -next -byte -of -input -and -a -state -ID -that -is -not -tagged -. -/ -/ -/ -/ -/ -/ -The -only -reason -to -use -this -routine -is -performance -. -In -particular -the -/ -/ -/ -next_state -method -needs -to -do -some -additional -checks -among -them -is -/ -/ -/ -to -account -for -identifiers -to -states -that -are -not -yet -computed -. -In -/ -/ -/ -such -a -case -the -transition -is -computed -on -the -fly -. -However -if -it -is -/ -/ -/ -known -that -the -current -state -ID -is -untagged -then -these -checks -can -be -/ -/ -/ -omitted -. -/ -/ -/ -/ -/ -/ -Since -this -routine -does -not -compute -states -on -the -fly -it -does -not -/ -/ -/ -modify -the -cache -and -thus -cannot -return -an -error -. -Consequently -cache -/ -/ -/ -does -not -need -to -be -mutable -and -it -is -possible -for -this -routine -to -/ -/ -/ -return -a -state -ID -corresponding -to -the -special -" -unknown -" -state -. -In -/ -/ -/ -this -case -it -is -the -caller -' -s -responsibility -to -use -the -prior -state -/ -/ -/ -ID -and -input -with -next_state -in -order -to -force -the -computation -of -/ -/ -/ -the -unknown -transition -. -Otherwise -trying -to -use -the -" -unknown -" -state -/ -/ -/ -ID -will -just -result -in -transitioning -back -to -itself -and -thus -never -/ -/ -/ -terminating -. -( -This -is -technically -a -special -exemption -to -the -state -ID -/ -/ -/ -validity -rules -but -is -permissible -since -this -routine -is -guarateed -to -/ -/ -/ -never -mutate -the -given -cache -and -thus -the -identifier -is -guaranteed -/ -/ -/ -to -remain -valid -. -) -/ -/ -/ -/ -/ -/ -See -[ -LazyStateID -] -for -more -details -on -what -it -means -for -a -state -ID -/ -/ -/ -to -be -tagged -. -Also -see -/ -/ -/ -[ -next_state_untagged -] -( -DFA -: -: -next_state_untagged -) -/ -/ -/ -for -this -same -idea -but -with -memory -safety -guaranteed -by -retaining -/ -/ -/ -bounds -checks -. -/ -/ -/ -/ -/ -/ -# -State -identifier -validity -/ -/ -/ -/ -/ -/ -The -only -valid -value -for -current -is -an -* -* -untagged -* -* -lazy -/ -/ -/ -state -ID -returned -by -the -most -recent -call -to -next_state -/ -/ -/ -next_state_untagged -next_state_untagged_unchecked -/ -/ -/ -start_state_forward -or -state_state_reverse -for -the -given -cache -. -/ -/ -/ -Any -state -ID -returned -from -prior -calls -to -these -routines -( -with -the -/ -/ -/ -same -cache -) -is -considered -invalid -( -even -if -it -gives -an -appearance -/ -/ -/ -of -working -) -. -State -IDs -returned -from -_any_ -prior -call -for -different -/ -/ -/ -cache -values -are -also -always -invalid -. -/ -/ -/ -/ -/ -/ -The -returned -ID -is -always -a -valid -ID -when -current -refers -to -a -valid -/ -/ -/ -ID -although -it -may -be -tagged -. -Moreover -this -routine -is -defined -for -/ -/ -/ -all -possible -values -of -input -. -/ -/ -/ -/ -/ -/ -Not -all -validity -rules -are -checked -even -in -debug -mode -. -Callers -are -/ -/ -/ -required -to -uphold -these -rules -themselves -. -/ -/ -/ -/ -/ -/ -Violating -these -state -ID -validity -rules -will -not -sacrifice -memory -/ -/ -/ -safety -but -_may_ -produce -an -incorrect -result -or -a -panic -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -Callers -of -this -method -must -guarantee -that -current -refers -to -a -valid -/ -/ -/ -state -ID -according -to -the -rules -described -above -. -If -current -is -not -a -/ -/ -/ -valid -state -ID -for -this -automaton -then -calling -this -routine -may -result -/ -/ -/ -in -undefined -behavior -. -/ -/ -/ -/ -/ -/ -If -current -is -valid -then -the -ID -returned -is -valid -for -all -possible -/ -/ -/ -values -of -input -. -# -[ -inline -] -pub -unsafe -fn -next_state_untagged_unchecked -( -& -self -cache -: -& -Cache -current -: -LazyStateID -input -: -u8 -) -- -> -LazyStateID -{ -debug_assert -! -( -! -current -. -is_tagged -( -) -) -; -let -class -= -usize -: -: -from -( -self -. -classes -. -get -( -input -) -) -; -let -offset -= -current -. -as_usize_unchecked -( -) -+ -class -; -* -cache -. -trans -. -get_unchecked -( -offset -) -} -/ -/ -/ -Transitions -from -the -current -state -to -the -next -state -for -the -special -/ -/ -/ -EOI -symbol -. -/ -/ -/ -/ -/ -/ -The -given -cache -is -used -to -either -reuse -pre -- -computed -state -/ -/ -/ -transitions -or -to -store -this -newly -computed -transition -for -future -/ -/ -/ -reuse -. -Thus -this -routine -guarantees -that -it -will -never -return -a -state -/ -/ -/ -ID -that -has -an -" -unknown -" -tag -. -/ -/ -/ -/ -/ -/ -This -routine -must -be -called -at -the -end -of -every -search -in -a -correct -/ -/ -/ -implementation -of -search -. -Namely -lazy -DFAs -in -this -crate -delay -matches -/ -/ -/ -by -one -byte -in -order -to -support -look -- -around -operators -. -Thus -after -/ -/ -/ -reaching -the -end -of -a -haystack -a -search -implementation -must -follow -one -/ -/ -/ -last -EOI -transition -. -/ -/ -/ -/ -/ -/ -It -is -best -to -think -of -EOI -as -an -additional -symbol -in -the -alphabet -of -a -/ -/ -/ -DFA -that -is -distinct -from -every -other -symbol -. -That -is -the -alphabet -of -/ -/ -/ -lazy -DFAs -in -this -crate -has -a -logical -size -of -257 -instead -of -256 -where -/ -/ -/ -256 -corresponds -to -every -possible -inhabitant -of -u8 -. -( -In -practice -the -/ -/ -/ -physical -alphabet -size -may -be -smaller -because -of -alphabet -compression -/ -/ -/ -via -equivalence -classes -but -EOI -is -always -represented -somehow -in -the -/ -/ -/ -alphabet -. -) -/ -/ -/ -/ -/ -/ -# -State -identifier -validity -/ -/ -/ -/ -/ -/ -The -only -valid -value -for -current -is -the -lazy -state -ID -returned -/ -/ -/ -by -the -most -recent -call -to -next_state -next_state_untagged -/ -/ -/ -next_state_untagged_unchecked -start_state_forward -or -/ -/ -/ -state_state_reverse -for -the -given -cache -. -Any -state -ID -returned -from -/ -/ -/ -prior -calls -to -these -routines -( -with -the -same -cache -) -is -considered -/ -/ -/ -invalid -( -even -if -it -gives -an -appearance -of -working -) -. -State -IDs -returned -/ -/ -/ -from -_any_ -prior -call -for -different -cache -values -are -also -always -/ -/ -/ -invalid -. -/ -/ -/ -/ -/ -/ -The -returned -ID -is -always -a -valid -ID -when -current -refers -to -a -valid -/ -/ -/ -ID -. -/ -/ -/ -/ -/ -/ -These -validity -rules -are -not -checked -even -in -debug -mode -. -Callers -are -/ -/ -/ -required -to -uphold -these -rules -themselves -. -/ -/ -/ -/ -/ -/ -Violating -these -state -ID -validity -rules -will -not -sacrifice -memory -/ -/ -/ -safety -but -_may_ -produce -an -incorrect -result -or -a -panic -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -given -ID -does -not -refer -to -a -valid -state -then -this -routine -/ -/ -/ -may -panic -but -it -also -may -not -panic -and -instead -return -an -invalid -or -/ -/ -/ -incorrect -ID -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -simplistic -example -for -walking -a -DFA -for -a -given -haystack -/ -/ -/ -and -then -finishing -the -search -with -the -final -EOI -transition -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -r -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -/ -/ -/ -let -mut -sid -= -dfa -. -start_state_forward -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -/ -/ -/ -) -? -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -/ -/ -/ -for -& -b -in -haystack -{ -/ -/ -/ -sid -= -dfa -. -next_state -( -& -mut -cache -sid -b -) -? -; -/ -/ -/ -} -/ -/ -/ -/ -/ -Matches -are -always -delayed -by -1 -byte -so -we -must -explicitly -walk -/ -/ -/ -/ -/ -the -special -" -EOI -" -transition -at -the -end -of -the -search -. -Without -this -/ -/ -/ -/ -/ -final -transition -the -assert -below -will -fail -since -the -DFA -will -not -/ -/ -/ -/ -/ -have -entered -a -match -state -yet -! -/ -/ -/ -sid -= -dfa -. -next_eoi_state -( -& -mut -cache -sid -) -? -; -/ -/ -/ -assert -! -( -sid -. -is_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -next_eoi_state -( -& -self -cache -: -& -mut -Cache -current -: -LazyStateID -) -- -> -Result -< -LazyStateID -CacheError -> -{ -let -eoi -= -self -. -classes -. -eoi -( -) -. -as_usize -( -) -; -let -offset -= -current -. -as_usize_untagged -( -) -+ -eoi -; -let -sid -= -cache -. -trans -[ -offset -] -; -if -! -sid -. -is_unknown -( -) -{ -return -Ok -( -sid -) -; -} -let -unit -= -self -. -classes -. -eoi -( -) -; -Lazy -: -: -new -( -self -cache -) -. -cache_next_state -( -current -unit -) -} -/ -/ -/ -Return -the -ID -of -the -start -state -for -this -lazy -DFA -when -executing -a -/ -/ -/ -forward -search -. -/ -/ -/ -/ -/ -/ -Unlike -typical -DFA -implementations -the -start -state -for -DFAs -in -this -/ -/ -/ -crate -is -dependent -on -a -few -different -factors -: -/ -/ -/ -/ -/ -/ -* -The -[ -Anchored -] -mode -of -the -search -. -Unanchored -anchored -and -/ -/ -/ -anchored -searches -for -a -specific -[ -PatternID -] -all -use -different -start -/ -/ -/ -states -. -/ -/ -/ -* -The -position -at -which -the -search -begins -via -[ -Input -: -: -start -] -. -This -/ -/ -/ -and -the -byte -immediately -preceding -the -start -of -the -search -( -if -one -/ -/ -/ -exists -) -influence -which -look -- -behind -assertions -are -true -at -the -start -/ -/ -/ -of -the -search -. -This -in -turn -influences -which -start -state -is -selected -. -/ -/ -/ -* -Whether -the -search -is -a -forward -or -reverse -search -. -This -routine -can -/ -/ -/ -only -be -used -for -forward -searches -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -may -return -a -[ -MatchError -] -( -not -a -[ -CacheError -] -! -) -if -the -search -/ -/ -/ -needs -to -give -up -when -determining -the -start -state -( -for -example -if -/ -/ -/ -it -sees -a -" -quit -" -byte -or -if -the -cache -has -been -cleared -too -many -/ -/ -/ -times -) -. -This -can -also -return -an -error -if -the -given -Input -contains -an -/ -/ -/ -unsupported -[ -Anchored -] -configuration -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -fn -start_state_forward -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -LazyStateID -MatchError -> -{ -if -! -self -. -quitset -. -is_empty -( -) -& -& -input -. -start -( -) -> -0 -{ -let -offset -= -input -. -start -( -) -- -1 -; -let -byte -= -input -. -haystack -( -) -[ -offset -] -; -if -self -. -quitset -. -contains -( -byte -) -{ -return -Err -( -MatchError -: -: -quit -( -byte -offset -) -) -; -} -} -let -start_type -= -self -. -start_map -. -fwd -( -input -) -; -let -start -= -LazyRef -: -: -new -( -self -cache -) -. -get_cached_start_id -( -input -start_type -) -? -; -if -! -start -. -is_unknown -( -) -{ -return -Ok -( -start -) -; -} -Lazy -: -: -new -( -self -cache -) -. -cache_start_group -( -input -start_type -) -} -/ -/ -/ -Return -the -ID -of -the -start -state -for -this -lazy -DFA -when -executing -a -/ -/ -/ -reverse -search -. -/ -/ -/ -/ -/ -/ -Unlike -typical -DFA -implementations -the -start -state -for -DFAs -in -this -/ -/ -/ -crate -is -dependent -on -a -few -different -factors -: -/ -/ -/ -/ -/ -/ -* -The -[ -Anchored -] -mode -of -the -search -. -Unanchored -anchored -and -/ -/ -/ -anchored -searches -for -a -specific -[ -PatternID -] -all -use -different -start -/ -/ -/ -states -. -/ -/ -/ -* -The -position -at -which -the -search -begins -via -[ -Input -: -: -start -] -. -This -/ -/ -/ -and -the -byte -immediately -preceding -the -start -of -the -search -( -if -one -/ -/ -/ -exists -) -influence -which -look -- -behind -assertions -are -true -at -the -start -/ -/ -/ -of -the -search -. -This -in -turn -influences -which -start -state -is -selected -. -/ -/ -/ -* -Whether -the -search -is -a -forward -or -reverse -search -. -This -routine -can -/ -/ -/ -only -be -used -for -reverse -searches -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -may -return -a -[ -MatchError -] -( -not -a -[ -CacheError -] -! -) -if -the -search -/ -/ -/ -needs -to -give -up -when -determining -the -start -state -( -for -example -if -/ -/ -/ -it -sees -a -" -quit -" -byte -or -if -the -cache -has -been -cleared -too -many -/ -/ -/ -times -) -. -This -can -also -return -an -error -if -the -given -Input -contains -an -/ -/ -/ -unsupported -[ -Anchored -] -configuration -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -fn -start_state_reverse -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -LazyStateID -MatchError -> -{ -if -! -self -. -quitset -. -is_empty -( -) -& -& -input -. -end -( -) -< -input -. -haystack -( -) -. -len -( -) -{ -let -offset -= -input -. -end -( -) -; -let -byte -= -input -. -haystack -( -) -[ -offset -] -; -if -self -. -quitset -. -contains -( -byte -) -{ -return -Err -( -MatchError -: -: -quit -( -byte -offset -) -) -; -} -} -let -start_type -= -self -. -start_map -. -rev -( -input -) -; -let -start -= -LazyRef -: -: -new -( -self -cache -) -. -get_cached_start_id -( -input -start_type -) -? -; -if -! -start -. -is_unknown -( -) -{ -return -Ok -( -start -) -; -} -Lazy -: -: -new -( -self -cache -) -. -cache_start_group -( -input -start_type -) -} -/ -/ -/ -Returns -the -total -number -of -patterns -that -match -in -this -state -. -/ -/ -/ -/ -/ -/ -If -the -lazy -DFA -was -compiled -with -one -pattern -then -this -must -/ -/ -/ -necessarily -always -return -1 -for -all -match -states -. -/ -/ -/ -/ -/ -/ -A -lazy -DFA -guarantees -that -[ -DFA -: -: -match_pattern -] -can -be -called -with -/ -/ -/ -indices -up -to -( -but -not -including -) -the -length -returned -by -this -routine -/ -/ -/ -without -panicking -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -given -state -is -not -a -match -state -then -this -may -either -panic -/ -/ -/ -or -return -an -incorrect -result -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -simple -instance -of -implementing -overlapping -/ -/ -/ -matches -. -In -particular -it -shows -not -only -how -to -determine -how -many -/ -/ -/ -patterns -have -matched -in -a -particular -state -but -also -how -to -access -/ -/ -/ -which -specific -patterns -have -matched -. -/ -/ -/ -/ -/ -/ -Notice -that -we -must -use -[ -MatchKind -: -: -All -] -when -building -the -DFA -. -If -we -/ -/ -/ -used -[ -MatchKind -: -: -LeftmostFirst -] -instead -then -the -DFA -would -not -be -/ -/ -/ -constructed -in -a -way -that -supports -overlapping -matches -. -( -It -would -only -/ -/ -/ -report -a -single -pattern -that -matches -at -any -particular -point -in -time -. -) -/ -/ -/ -/ -/ -/ -Another -thing -to -take -note -of -is -the -patterns -used -and -the -order -in -/ -/ -/ -which -the -pattern -IDs -are -reported -. -In -the -example -below -pattern -3 -/ -/ -/ -is -yielded -first -. -Why -? -Because -it -corresponds -to -the -match -that -/ -/ -/ -appears -first -. -Namely -the -symbol -is -part -of -\ -S -+ -but -not -part -/ -/ -/ -of -any -of -the -other -patterns -. -Since -the -\ -S -+ -pattern -has -a -match -that -/ -/ -/ -starts -to -the -left -of -any -other -pattern -its -ID -is -returned -before -any -/ -/ -/ -other -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -Input -MatchKind -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -& -[ -/ -/ -/ -r -" -\ -w -+ -" -r -" -[ -a -- -z -] -+ -" -r -" -[ -A -- -Z -] -+ -" -r -" -\ -S -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -bar -" -. -as_bytes -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -/ -/ -/ -let -mut -sid -= -dfa -. -start_state_forward -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -/ -/ -/ -) -? -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -/ -/ -/ -for -& -b -in -haystack -{ -/ -/ -/ -sid -= -dfa -. -next_state -( -& -mut -cache -sid -b -) -? -; -/ -/ -/ -} -/ -/ -/ -sid -= -dfa -. -next_eoi_state -( -& -mut -cache -sid -) -? -; -/ -/ -/ -/ -/ -/ -assert -! -( -sid -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -dfa -. -match_len -( -& -mut -cache -sid -) -3 -) -; -/ -/ -/ -/ -/ -The -following -calls -are -guaranteed -to -not -panic -since -match_len -/ -/ -/ -/ -/ -returned -3 -above -. -/ -/ -/ -assert_eq -! -( -dfa -. -match_pattern -( -& -mut -cache -sid -0 -) -. -as_usize -( -) -3 -) -; -/ -/ -/ -assert_eq -! -( -dfa -. -match_pattern -( -& -mut -cache -sid -1 -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -dfa -. -match_pattern -( -& -mut -cache -sid -2 -) -. -as_usize -( -) -1 -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -match_len -( -& -self -cache -: -& -Cache -id -: -LazyStateID -) -- -> -usize -{ -assert -! -( -id -. -is_match -( -) -) -; -LazyRef -: -: -new -( -self -cache -) -. -get_cached_state -( -id -) -. -match_len -( -) -} -/ -/ -/ -Returns -the -pattern -ID -corresponding -to -the -given -match -index -in -the -/ -/ -/ -given -state -. -/ -/ -/ -/ -/ -/ -See -[ -DFA -: -: -match_len -] -for -an -example -of -how -to -use -this -method -/ -/ -/ -correctly -. -Note -that -if -you -know -your -lazy -DFA -is -configured -with -a -/ -/ -/ -single -pattern -then -this -routine -is -never -necessary -since -it -will -/ -/ -/ -always -return -a -pattern -ID -of -0 -for -an -index -of -0 -when -id -/ -/ -/ -corresponds -to -a -match -state -. -/ -/ -/ -/ -/ -/ -Typically -this -routine -is -used -when -implementing -an -overlapping -/ -/ -/ -search -as -the -example -for -DFA -: -: -match_len -does -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -state -ID -is -not -a -match -state -or -if -the -match -index -is -out -/ -/ -/ -of -bounds -for -the -given -state -then -this -routine -may -either -panic -/ -/ -/ -or -produce -an -incorrect -result -. -If -the -state -ID -is -correct -and -the -/ -/ -/ -match -index -is -correct -then -this -routine -always -produces -a -valid -/ -/ -/ -PatternID -. -# -[ -inline -] -pub -fn -match_pattern -( -& -self -cache -: -& -Cache -id -: -LazyStateID -match_index -: -usize -) -- -> -PatternID -{ -/ -/ -This -is -an -optimization -for -the -very -common -case -of -a -DFA -with -a -/ -/ -single -pattern -. -This -conditional -avoids -a -somewhat -more -costly -path -/ -/ -that -finds -the -pattern -ID -from -the -corresponding -State -which -/ -/ -requires -a -bit -of -slicing -/ -pointer -- -chasing -. -This -optimization -tends -/ -/ -to -only -matter -when -matches -are -frequent -. -if -self -. -pattern_len -( -) -= -= -1 -{ -return -PatternID -: -: -ZERO -; -} -LazyRef -: -: -new -( -self -cache -) -. -get_cached_state -( -id -) -. -match_pattern -( -match_index -) -} -} -/ -/ -/ -A -cache -represents -a -partially -computed -DFA -. -/ -/ -/ -/ -/ -/ -A -cache -is -the -key -component -that -differentiates -a -classical -DFA -and -a -/ -/ -/ -hybrid -NFA -/ -DFA -( -also -called -a -" -lazy -DFA -" -) -. -Where -a -classical -DFA -builds -a -/ -/ -/ -complete -transition -table -that -can -handle -all -possible -inputs -a -hybrid -/ -/ -/ -NFA -/ -DFA -starts -with -an -empty -transition -table -and -builds -only -the -parts -/ -/ -/ -required -during -search -. -The -parts -that -are -built -are -stored -in -a -cache -. -For -/ -/ -/ -this -reason -a -cache -is -a -required -parameter -for -nearly -every -operation -on -/ -/ -/ -a -[ -DFA -] -. -/ -/ -/ -/ -/ -/ -Caches -can -be -created -from -their -corresponding -DFA -via -/ -/ -/ -[ -DFA -: -: -create_cache -] -. -A -cache -can -only -be -used -with -either -the -DFA -that -/ -/ -/ -created -it -or -the -DFA -that -was -most -recently -used -to -reset -it -with -/ -/ -/ -[ -Cache -: -: -reset -] -. -Using -a -cache -with -any -other -DFA -may -result -in -panics -/ -/ -/ -or -incorrect -results -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Cache -{ -/ -/ -N -. -B -. -If -you -' -re -looking -to -understand -how -determinization -works -it -/ -/ -is -probably -simpler -to -first -grok -src -/ -dfa -/ -determinize -. -rs -since -that -/ -/ -doesn -' -t -have -the -" -laziness -" -component -. -/ -/ -/ -The -transition -table -. -/ -/ -/ -/ -/ -/ -Given -a -current -LazyStateID -and -an -input -byte -the -next -state -can -/ -/ -/ -be -computed -via -trans -[ -untagged -( -current -) -+ -equiv_class -( -input -) -] -. -Notice -/ -/ -/ -that -no -multiplication -is -used -. -That -' -s -because -state -identifiers -are -/ -/ -/ -" -premultiplied -. -" -/ -/ -/ -/ -/ -/ -Note -that -the -next -state -may -be -the -" -unknown -" -state -. -In -this -case -the -/ -/ -/ -next -state -is -not -known -and -determinization -for -current -on -input -/ -/ -/ -must -be -performed -. -trans -: -Vec -< -LazyStateID -> -/ -/ -/ -The -starting -states -for -this -DFA -. -/ -/ -/ -/ -/ -/ -These -are -computed -lazily -. -Initially -these -are -all -set -to -" -unknown -" -/ -/ -/ -lazy -state -IDs -. -/ -/ -/ -/ -/ -/ -When -' -starts_for_each_pattern -' -is -disabled -( -the -default -) -then -the -size -/ -/ -/ -of -this -is -constrained -to -the -possible -starting -configurations -based -/ -/ -/ -on -the -search -parameters -. -( -At -time -of -writing -that -' -s -4 -. -) -However -/ -/ -/ -when -starting -states -for -each -pattern -is -enabled -then -there -are -N -/ -/ -/ -additional -groups -of -starting -states -where -each -group -reflects -the -/ -/ -/ -different -possible -configurations -and -N -is -the -number -of -patterns -. -starts -: -Vec -< -LazyStateID -> -/ -/ -/ -A -sequence -of -NFA -/ -DFA -powerset -states -that -have -been -computed -for -this -/ -/ -/ -lazy -DFA -. -This -sequence -is -indexable -by -untagged -LazyStateIDs -. -( -Every -/ -/ -/ -tagged -LazyStateID -can -be -used -to -index -this -sequence -by -converting -it -/ -/ -/ -to -its -untagged -form -. -) -states -: -Vec -< -State -> -/ -/ -/ -A -map -from -states -to -their -corresponding -IDs -. -This -map -may -be -accessed -/ -/ -/ -via -the -raw -byte -representation -of -a -state -which -means -that -a -State -/ -/ -/ -does -not -need -to -be -allocated -to -determine -whether -it -already -exists -/ -/ -/ -in -this -map -. -Indeed -the -existence -of -such -a -state -is -what -determines -/ -/ -/ -whether -we -allocate -a -new -State -or -not -. -/ -/ -/ -/ -/ -/ -The -higher -level -idea -here -is -that -we -do -just -enough -determinization -/ -/ -/ -for -a -state -to -check -whether -we -' -ve -already -computed -it -. -If -we -have -/ -/ -/ -then -we -can -save -a -little -( -albeit -not -much -) -work -. -The -real -savings -is -/ -/ -/ -in -memory -usage -. -If -we -never -checked -for -trivially -duplicate -states -/ -/ -/ -then -our -memory -usage -would -explode -to -unreasonable -levels -. -states_to_id -: -StateMap -/ -/ -/ -Sparse -sets -used -to -track -which -NFA -states -have -been -visited -during -/ -/ -/ -various -traversals -. -sparses -: -SparseSets -/ -/ -/ -Scratch -space -for -traversing -the -NFA -graph -. -( -We -use -space -on -the -heap -/ -/ -/ -instead -of -the -call -stack -. -) -stack -: -Vec -< -NFAStateID -> -/ -/ -/ -Scratch -space -for -building -a -NFA -/ -DFA -powerset -state -. -This -is -used -to -/ -/ -/ -help -amortize -allocation -since -not -every -powerset -state -generated -is -/ -/ -/ -added -to -the -cache -. -In -particular -if -it -already -exists -in -the -cache -/ -/ -/ -then -there -is -no -need -to -allocate -a -new -State -for -it -. -scratch_state_builder -: -StateBuilderEmpty -/ -/ -/ -A -simple -abstraction -for -handling -the -saving -of -at -most -a -single -state -/ -/ -/ -across -a -cache -clearing -. -This -is -required -for -correctness -. -Namely -if -/ -/ -/ -adding -a -new -state -after -clearing -the -cache -fails -then -the -caller -/ -/ -/ -must -retain -the -ability -to -continue -using -the -state -ID -given -. -The -/ -/ -/ -state -corresponding -to -the -state -ID -is -what -we -preserve -across -cache -/ -/ -/ -clearings -. -state_saver -: -StateSaver -/ -/ -/ -The -memory -usage -in -bytes -used -by -' -states -' -and -' -states_to_id -' -. -We -/ -/ -/ -track -this -as -new -states -are -added -since -states -use -a -variable -amount -/ -/ -/ -of -heap -. -Tracking -this -as -we -add -states -makes -it -possible -to -compute -/ -/ -/ -the -total -amount -of -memory -used -by -the -determinizer -in -constant -time -. -memory_usage_state -: -usize -/ -/ -/ -The -number -of -times -the -cache -has -been -cleared -. -When -a -minimum -cache -/ -/ -/ -clear -count -is -set -then -the -cache -will -return -an -error -instead -of -/ -/ -/ -clearing -the -cache -if -the -count -has -been -exceeded -. -clear_count -: -usize -/ -/ -/ -The -total -number -of -bytes -searched -since -the -last -time -this -cache -was -/ -/ -/ -cleared -not -including -the -current -search -. -/ -/ -/ -/ -/ -/ -This -can -be -added -to -the -length -of -the -current -search -to -get -the -true -/ -/ -/ -total -number -of -bytes -searched -. -/ -/ -/ -/ -/ -/ -This -is -generally -only -non -- -zero -when -the -/ -/ -/ -Cache -: -: -search_ -{ -start -update -finish -} -APIs -are -used -to -track -search -/ -/ -/ -progress -. -bytes_searched -: -usize -/ -/ -/ -The -progress -of -the -current -search -. -/ -/ -/ -/ -/ -/ -This -is -only -non -- -None -when -callers -utlize -the -Cache -: -: -search_start -/ -/ -/ -Cache -: -: -search_update -and -Cache -: -: -search_finish -APIs -. -/ -/ -/ -/ -/ -/ -The -purpose -of -recording -search -progress -is -to -be -able -to -make -a -/ -/ -/ -determination -about -the -efficiency -of -the -cache -. -Namely -by -keeping -/ -/ -/ -track -of -the -progress -: -Option -< -SearchProgress -> -} -impl -Cache -{ -/ -/ -/ -Create -a -new -cache -for -the -given -lazy -DFA -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -the -given -DFA -. -/ -/ -/ -If -you -want -to -reuse -the -cache -for -another -DFA -then -you -must -call -/ -/ -/ -[ -Cache -: -: -reset -] -with -that -DFA -. -pub -fn -new -( -dfa -: -& -DFA -) -- -> -Cache -{ -let -mut -cache -= -Cache -{ -trans -: -alloc -: -: -vec -! -[ -] -starts -: -alloc -: -: -vec -! -[ -] -states -: -alloc -: -: -vec -! -[ -] -states_to_id -: -StateMap -: -: -new -( -) -sparses -: -SparseSets -: -: -new -( -dfa -. -get_nfa -( -) -. -states -( -) -. -len -( -) -) -stack -: -alloc -: -: -vec -! -[ -] -scratch_state_builder -: -StateBuilderEmpty -: -: -new -( -) -state_saver -: -StateSaver -: -: -none -( -) -memory_usage_state -: -0 -clear_count -: -0 -bytes_searched -: -0 -progress -: -None -} -; -debug -! -( -" -pre -- -init -lazy -DFA -cache -size -: -{ -} -" -cache -. -memory_usage -( -) -) -; -Lazy -{ -dfa -cache -: -& -mut -cache -} -. -init_cache -( -) -; -debug -! -( -" -post -- -init -lazy -DFA -cache -size -: -{ -} -" -cache -. -memory_usage -( -) -) -; -cache -} -/ -/ -/ -Reset -this -cache -such -that -it -can -be -used -for -searching -with -the -given -/ -/ -/ -lazy -DFA -( -and -only -that -DFA -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -lazy -DFA -. -/ -/ -/ -/ -/ -/ -Resetting -a -cache -sets -its -" -clear -count -" -to -0 -. -This -is -relevant -if -the -/ -/ -/ -lazy -DFA -has -been -configured -to -" -give -up -" -after -it -has -cleared -the -/ -/ -/ -cache -a -certain -number -of -times -. -/ -/ -/ -/ -/ -/ -Any -lazy -state -ID -generated -by -the -cache -prior -to -resetting -it -is -/ -/ -/ -invalid -after -the -reset -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -DFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa1 -= -DFA -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -dfa2 -= -DFA -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -dfa1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -HalfMatch -: -: -must -( -0 -2 -) -) -/ -/ -/ -dfa1 -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -dfa2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -DFA -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -dfa1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -cache -. -reset -( -& -dfa2 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -/ -/ -/ -dfa2 -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset -( -& -mut -self -dfa -: -& -DFA -) -{ -Lazy -: -: -new -( -dfa -self -) -. -reset_cache -( -) -} -/ -/ -/ -Initializes -a -new -search -starting -at -the -given -position -. -/ -/ -/ -/ -/ -/ -If -a -previous -search -was -unfinished -then -it -is -finished -automatically -/ -/ -/ -and -a -new -search -is -begun -. -/ -/ -/ -/ -/ -/ -Note -that -keeping -track -of -search -progress -is -_not -necessary_ -/ -/ -/ -for -correct -implementations -of -search -using -a -lazy -DFA -. -Keeping -/ -/ -/ -track -of -search -progress -is -only -necessary -if -you -want -the -/ -/ -/ -[ -Config -: -: -minimum_bytes_per_state -] -configuration -knob -to -work -. -# -[ -inline -] -pub -fn -search_start -( -& -mut -self -at -: -usize -) -{ -/ -/ -If -a -previous -search -wasn -' -t -marked -as -finished -then -finish -it -/ -/ -now -automatically -. -if -let -Some -( -p -) -= -self -. -progress -. -take -( -) -{ -self -. -bytes_searched -+ -= -p -. -len -( -) -; -} -self -. -progress -= -Some -( -SearchProgress -{ -start -: -at -at -} -) -; -} -/ -/ -/ -Updates -the -current -search -to -indicate -that -it -has -search -to -the -/ -/ -/ -current -position -. -/ -/ -/ -/ -/ -/ -No -special -care -needs -to -be -taken -for -reverse -searches -. -Namely -the -/ -/ -/ -position -given -may -be -_less -than_ -the -starting -position -of -the -search -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -no -search -has -been -started -by -[ -Cache -: -: -search_start -] -. -# -[ -inline -] -pub -fn -search_update -( -& -mut -self -at -: -usize -) -{ -let -p -= -self -. -progress -. -as_mut -( -) -. -expect -( -" -no -in -- -progress -search -to -update -" -) -; -p -. -at -= -at -; -} -/ -/ -/ -Indicates -that -a -search -has -finished -at -the -given -position -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -no -search -has -been -started -by -[ -Cache -: -: -search_start -] -. -# -[ -inline -] -pub -fn -search_finish -( -& -mut -self -at -: -usize -) -{ -let -mut -p -= -self -. -progress -. -take -( -) -. -expect -( -" -no -in -- -progress -search -to -finish -" -) -; -p -. -at -= -at -; -self -. -bytes_searched -+ -= -p -. -len -( -) -; -} -/ -/ -/ -Returns -the -total -number -of -bytes -that -have -been -searched -since -this -/ -/ -/ -cache -was -last -cleared -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -determining -the -efficiency -of -the -cache -. -For -/ -/ -/ -example -the -lazy -DFA -uses -this -value -in -conjunction -with -the -/ -/ -/ -[ -Config -: -: -minimum_bytes_per_state -] -knob -to -help -determine -whether -it -/ -/ -/ -should -quit -searching -. -/ -/ -/ -/ -/ -/ -This -always -returns -0 -if -search -progress -isn -' -t -being -tracked -. -Note -/ -/ -/ -that -the -lazy -DFA -search -routines -in -this -crate -always -track -search -/ -/ -/ -progress -. -pub -fn -search_total_len -( -& -self -) -- -> -usize -{ -self -. -bytes_searched -+ -self -. -progress -. -as_ref -( -) -. -map_or -( -0 -| -p -| -p -. -len -( -) -) -} -/ -/ -/ -Returns -the -total -number -of -times -this -cache -has -been -cleared -since -it -/ -/ -/ -was -either -created -or -last -reset -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -informational -purposes -or -if -you -want -to -change -/ -/ -/ -search -strategies -based -on -the -number -of -times -the -cache -has -been -/ -/ -/ -cleared -. -pub -fn -clear_count -( -& -self -) -- -> -usize -{ -self -. -clear_count -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -of -this -cache -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -cache -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -Cache -> -( -) -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -const -ID_SIZE -: -usize -= -size_of -: -: -< -LazyStateID -> -( -) -; -const -STATE_SIZE -: -usize -= -size_of -: -: -< -State -> -( -) -; -/ -/ -NOTE -: -If -you -make -changes -to -the -below -then -/ -/ -' -minimum_cache_capacity -' -should -be -updated -correspondingly -. -self -. -trans -. -len -( -) -* -ID_SIZE -+ -self -. -starts -. -len -( -) -* -ID_SIZE -+ -self -. -states -. -len -( -) -* -STATE_SIZE -/ -/ -Maps -likely -use -more -memory -than -this -but -it -' -s -probably -close -. -+ -self -. -states_to_id -. -len -( -) -* -( -STATE_SIZE -+ -ID_SIZE -) -+ -self -. -sparses -. -memory_usage -( -) -+ -self -. -stack -. -capacity -( -) -* -ID_SIZE -+ -self -. -scratch_state_builder -. -capacity -( -) -/ -/ -Heap -memory -used -by -' -State -' -in -both -' -states -' -and -' -states_to_id -' -. -+ -self -. -memory_usage_state -} -} -/ -/ -/ -Keeps -track -of -the -progress -of -the -current -search -. -/ -/ -/ -/ -/ -/ -This -is -updated -via -the -Cache -: -: -search_ -{ -start -update -finish -} -APIs -to -/ -/ -/ -record -how -many -bytes -have -been -searched -. -This -permits -computing -a -/ -/ -/ -heuristic -that -represents -the -efficiency -of -a -cache -and -thus -helps -inform -/ -/ -/ -whether -the -lazy -DFA -should -give -up -or -not -. -# -[ -derive -( -Clone -Debug -) -] -struct -SearchProgress -{ -start -: -usize -at -: -usize -} -impl -SearchProgress -{ -/ -/ -/ -Returns -the -length -in -bytes -of -this -search -so -far -. -/ -/ -/ -/ -/ -/ -This -automatically -handles -the -case -of -a -reverse -search -where -at -/ -/ -/ -is -likely -to -be -less -than -start -. -fn -len -( -& -self -) -- -> -usize -{ -if -self -. -start -< -= -self -. -at -{ -self -. -at -- -self -. -start -} -else -{ -self -. -start -- -self -. -at -} -} -} -/ -/ -/ -A -map -from -states -to -state -identifiers -. -When -using -std -we -use -a -standard -/ -/ -/ -hashmap -since -it -' -s -a -bit -faster -for -this -use -case -. -( -Other -maps -like -/ -/ -/ -one -' -s -based -on -FNV -have -not -yet -been -benchmarked -. -) -/ -/ -/ -/ -/ -/ -The -main -purpose -of -this -map -is -to -reuse -states -where -possible -. -This -won -' -t -/ -/ -/ -fully -minimize -the -DFA -but -it -works -well -in -a -lot -of -cases -. -# -[ -cfg -( -feature -= -" -std -" -) -] -type -StateMap -= -std -: -: -collections -: -: -HashMap -< -State -LazyStateID -> -; -# -[ -cfg -( -not -( -feature -= -" -std -" -) -) -] -type -StateMap -= -alloc -: -: -collections -: -: -BTreeMap -< -State -LazyStateID -> -; -/ -/ -/ -A -type -that -groups -methods -that -require -the -base -NFA -/ -DFA -and -writable -/ -/ -/ -access -to -the -cache -. -# -[ -derive -( -Debug -) -] -struct -Lazy -< -' -i -' -c -> -{ -dfa -: -& -' -i -DFA -cache -: -& -' -c -mut -Cache -} -impl -< -' -i -' -c -> -Lazy -< -' -i -' -c -> -{ -/ -/ -/ -Creates -a -new -' -Lazy -' -wrapper -for -a -DFA -and -its -corresponding -cache -. -fn -new -( -dfa -: -& -' -i -DFA -cache -: -& -' -c -mut -Cache -) -- -> -Lazy -< -' -i -' -c -> -{ -Lazy -{ -dfa -cache -} -} -/ -/ -/ -Return -an -immutable -view -by -downgrading -a -writable -cache -to -a -read -- -only -/ -/ -/ -cache -. -fn -as_ref -< -' -a -> -( -& -' -a -self -) -- -> -LazyRef -< -' -i -' -a -> -{ -LazyRef -: -: -new -( -self -. -dfa -self -. -cache -) -} -/ -/ -/ -This -is -marked -as -' -inline -( -never -) -' -to -avoid -bloating -methods -on -' -DFA -' -/ -/ -/ -like -' -next_state -' -and -' -next_eoi_state -' -that -are -called -in -critical -/ -/ -/ -areas -. -The -idea -is -to -let -the -optimizer -focus -on -the -other -areas -of -/ -/ -/ -those -methods -as -the -hot -path -. -/ -/ -/ -/ -/ -/ -Here -' -s -an -example -that -justifies -' -inline -( -never -) -' -/ -/ -/ -/ -/ -/ -ignore -/ -/ -/ -regex -- -cli -find -hybrid -dfa -\ -/ -/ -/ -all -- -codepoints -- -utf8 -- -100x -' -\ -pL -{ -100 -} -' -- -- -cache -- -capacity -10000000 -/ -/ -/ -/ -/ -/ -/ -/ -/ -Where -' -all -- -codepoints -- -utf8 -- -100x -' -is -the -UTF -- -8 -encoding -of -every -/ -/ -/ -codepoint -in -sequence -repeated -100 -times -. -/ -/ -/ -/ -/ -/ -With -' -inline -( -never -) -' -hyperfine -reports -1 -. -1s -per -run -. -With -/ -/ -/ -' -inline -( -always -) -' -hyperfine -reports -1 -. -23s -. -So -that -' -s -a -10 -% -improvement -. -# -[ -cold -] -# -[ -inline -( -never -) -] -fn -cache_next_state -( -& -mut -self -mut -current -: -LazyStateID -unit -: -alphabet -: -: -Unit -) -- -> -Result -< -LazyStateID -CacheError -> -{ -let -stride2 -= -self -. -dfa -. -stride2 -( -) -; -let -empty_builder -= -self -. -get_state_builder -( -) -; -let -builder -= -determinize -: -: -next -( -self -. -dfa -. -get_nfa -( -) -self -. -dfa -. -get_config -( -) -. -get_match_kind -( -) -& -mut -self -. -cache -. -sparses -& -mut -self -. -cache -. -stack -& -self -. -cache -. -states -[ -current -. -as_usize_untagged -( -) -> -> -stride2 -] -unit -empty_builder -) -; -let -save_state -= -! -self -. -as_ref -( -) -. -state_builder_fits_in_cache -( -& -builder -) -; -if -save_state -{ -self -. -save_state -( -current -) -; -} -let -next -= -self -. -add_builder_state -( -builder -| -sid -| -sid -) -? -; -if -save_state -{ -current -= -self -. -saved_state_id -( -) -; -} -/ -/ -This -is -the -payoff -. -The -next -time -' -next_state -' -is -called -with -this -/ -/ -state -and -alphabet -unit -it -will -find -this -transition -and -avoid -/ -/ -having -to -re -- -determinize -this -transition -. -self -. -set_transition -( -current -unit -next -) -; -Ok -( -next -) -} -/ -/ -/ -Compute -and -cache -the -starting -state -for -the -given -pattern -ID -( -if -/ -/ -/ -present -) -and -the -starting -configuration -. -/ -/ -/ -/ -/ -/ -This -panics -if -a -pattern -ID -is -given -and -the -DFA -isn -' -t -configured -to -/ -/ -/ -build -anchored -start -states -for -each -pattern -. -/ -/ -/ -/ -/ -/ -This -will -never -return -an -unknown -lazy -state -ID -. -/ -/ -/ -/ -/ -/ -If -caching -this -state -would -otherwise -result -in -a -cache -that -has -been -/ -/ -/ -cleared -too -many -times -then -an -error -is -returned -. -# -[ -cold -] -# -[ -inline -( -never -) -] -fn -cache_start_group -( -& -mut -self -input -: -& -Input -< -' -_ -> -start -: -Start -) -- -> -Result -< -LazyStateID -MatchError -> -{ -let -mode -= -input -. -get_anchored -( -) -; -let -nfa_start_id -= -match -mode -{ -Anchored -: -: -No -= -> -self -. -dfa -. -get_nfa -( -) -. -start_unanchored -( -) -Anchored -: -: -Yes -= -> -self -. -dfa -. -get_nfa -( -) -. -start_anchored -( -) -Anchored -: -: -Pattern -( -pid -) -= -> -{ -if -! -self -. -dfa -. -get_config -( -) -. -get_starts_for_each_pattern -( -) -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -mode -) -) -; -} -match -self -. -dfa -. -get_nfa -( -) -. -start_pattern -( -pid -) -{ -None -= -> -return -Ok -( -self -. -as_ref -( -) -. -dead_id -( -) -) -Some -( -sid -) -= -> -sid -} -} -} -; -let -id -= -self -. -cache_start_one -( -nfa_start_id -start -) -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -input -. -start -( -) -) -) -? -; -self -. -set_start_state -( -input -start -id -) -; -Ok -( -id -) -} -/ -/ -/ -Compute -and -cache -the -starting -state -for -the -given -NFA -state -ID -and -the -/ -/ -/ -starting -configuration -. -The -NFA -state -ID -might -be -one -of -the -following -: -/ -/ -/ -/ -/ -/ -1 -) -An -unanchored -start -state -to -match -any -pattern -. -/ -/ -/ -2 -) -An -anchored -start -state -to -match -any -pattern -. -/ -/ -/ -3 -) -An -anchored -start -state -for -a -particular -pattern -. -/ -/ -/ -/ -/ -/ -This -will -never -return -an -unknown -lazy -state -ID -. -/ -/ -/ -/ -/ -/ -If -caching -this -state -would -otherwise -result -in -a -cache -that -has -been -/ -/ -/ -cleared -too -many -times -then -an -error -is -returned -. -fn -cache_start_one -( -& -mut -self -nfa_start_id -: -NFAStateID -start -: -Start -) -- -> -Result -< -LazyStateID -CacheError -> -{ -let -mut -builder_matches -= -self -. -get_state_builder -( -) -. -into_matches -( -) -; -determinize -: -: -set_lookbehind_from_start -( -self -. -dfa -. -get_nfa -( -) -& -start -& -mut -builder_matches -) -; -self -. -cache -. -sparses -. -set1 -. -clear -( -) -; -determinize -: -: -epsilon_closure -( -self -. -dfa -. -get_nfa -( -) -nfa_start_id -builder_matches -. -look_have -( -) -& -mut -self -. -cache -. -stack -& -mut -self -. -cache -. -sparses -. -set1 -) -; -let -mut -builder -= -builder_matches -. -into_nfa -( -) -; -determinize -: -: -add_nfa_states -( -& -self -. -dfa -. -get_nfa -( -) -& -self -. -cache -. -sparses -. -set1 -& -mut -builder -) -; -let -tag_starts -= -self -. -dfa -. -get_config -( -) -. -get_specialize_start_states -( -) -; -self -. -add_builder_state -( -builder -| -id -| -{ -if -tag_starts -{ -id -. -to_start -( -) -} -else -{ -id -} -} -) -} -/ -/ -/ -Either -add -the -given -builder -state -to -this -cache -or -return -an -ID -to -an -/ -/ -/ -equivalent -state -already -in -this -cache -. -/ -/ -/ -/ -/ -/ -In -the -case -where -no -equivalent -state -exists -the -idmap -function -given -/ -/ -/ -may -be -used -to -transform -the -identifier -allocated -. -This -is -useful -if -/ -/ -/ -the -caller -needs -to -tag -the -ID -with -additional -information -. -/ -/ -/ -/ -/ -/ -This -will -never -return -an -unknown -lazy -state -ID -. -/ -/ -/ -/ -/ -/ -If -caching -this -state -would -otherwise -result -in -a -cache -that -has -been -/ -/ -/ -cleared -too -many -times -then -an -error -is -returned -. -fn -add_builder_state -( -& -mut -self -builder -: -StateBuilderNFA -idmap -: -impl -Fn -( -LazyStateID -) -- -> -LazyStateID -) -- -> -Result -< -LazyStateID -CacheError -> -{ -if -let -Some -( -& -cached_id -) -= -self -. -cache -. -states_to_id -. -get -( -builder -. -as_bytes -( -) -) -{ -/ -/ -Since -we -have -a -cached -state -put -the -constructed -state -' -s -/ -/ -memory -back -into -our -scratch -space -so -that -it -can -be -reused -. -self -. -put_state_builder -( -builder -) -; -return -Ok -( -cached_id -) -; -} -let -result -= -self -. -add_state -( -builder -. -to_state -( -) -idmap -) -; -self -. -put_state_builder -( -builder -) -; -result -} -/ -/ -/ -Allocate -a -new -state -ID -and -add -the -given -state -to -this -cache -. -/ -/ -/ -/ -/ -/ -The -idmap -function -given -may -be -used -to -transform -the -identifier -/ -/ -/ -allocated -. -This -is -useful -if -the -caller -needs -to -tag -the -ID -with -/ -/ -/ -additional -information -. -/ -/ -/ -/ -/ -/ -This -will -never -return -an -unknown -lazy -state -ID -. -/ -/ -/ -/ -/ -/ -If -caching -this -state -would -otherwise -result -in -a -cache -that -has -been -/ -/ -/ -cleared -too -many -times -then -an -error -is -returned -. -fn -add_state -( -& -mut -self -state -: -State -idmap -: -impl -Fn -( -LazyStateID -) -- -> -LazyStateID -) -- -> -Result -< -LazyStateID -CacheError -> -{ -if -! -self -. -as_ref -( -) -. -state_fits_in_cache -( -& -state -) -{ -self -. -try_clear_cache -( -) -? -; -} -/ -/ -It -' -s -important -for -this -to -come -second -since -the -above -may -clear -/ -/ -the -cache -. -If -we -clear -the -cache -after -ID -generation -then -the -ID -/ -/ -is -likely -bunk -since -it -would -have -been -generated -based -on -a -larger -/ -/ -transition -table -. -let -mut -id -= -idmap -( -self -. -next_state_id -( -) -? -) -; -if -state -. -is_match -( -) -{ -id -= -id -. -to_match -( -) -; -} -/ -/ -Add -room -in -the -transition -table -. -Since -this -is -a -fresh -state -all -/ -/ -of -its -transitions -are -unknown -. -self -. -cache -. -trans -. -extend -( -iter -: -: -repeat -( -self -. -as_ref -( -) -. -unknown_id -( -) -) -. -take -( -self -. -dfa -. -stride -( -) -) -) -; -/ -/ -When -we -add -a -sentinel -state -we -never -want -to -set -any -quit -/ -/ -transitions -. -Technically -this -is -harmless -since -sentinel -states -/ -/ -have -all -of -their -transitions -set -to -loop -back -to -themselves -. -But -/ -/ -when -creating -sentinel -states -before -the -quit -sentinel -state -/ -/ -this -will -try -to -call -' -set_transition -' -on -a -state -ID -that -doesn -' -t -/ -/ -actually -exist -yet -which -isn -' -t -allowed -. -So -we -just -skip -doing -so -/ -/ -entirely -. -if -! -self -. -dfa -. -quitset -. -is_empty -( -) -& -& -! -self -. -as_ref -( -) -. -is_sentinel -( -id -) -{ -let -quit_id -= -self -. -as_ref -( -) -. -quit_id -( -) -; -for -b -in -self -. -dfa -. -quitset -. -iter -( -) -{ -self -. -set_transition -( -id -alphabet -: -: -Unit -: -: -u8 -( -b -) -quit_id -) -; -} -} -self -. -cache -. -memory_usage_state -+ -= -state -. -memory_usage -( -) -; -self -. -cache -. -states -. -push -( -state -. -clone -( -) -) -; -self -. -cache -. -states_to_id -. -insert -( -state -id -) -; -Ok -( -id -) -} -/ -/ -/ -Allocate -a -new -state -ID -. -/ -/ -/ -/ -/ -/ -This -will -never -return -an -unknown -lazy -state -ID -. -/ -/ -/ -/ -/ -/ -If -caching -this -state -would -otherwise -result -in -a -cache -that -has -been -/ -/ -/ -cleared -too -many -times -then -an -error -is -returned -. -fn -next_state_id -( -& -mut -self -) -- -> -Result -< -LazyStateID -CacheError -> -{ -let -sid -= -match -LazyStateID -: -: -new -( -self -. -cache -. -trans -. -len -( -) -) -{ -Ok -( -sid -) -= -> -sid -Err -( -_ -) -= -> -{ -self -. -try_clear_cache -( -) -? -; -/ -/ -This -has -to -pass -since -we -check -that -ID -capacity -at -/ -/ -construction -time -can -fit -at -least -MIN_STATES -states -. -LazyStateID -: -: -new -( -self -. -cache -. -trans -. -len -( -) -) -. -unwrap -( -) -} -} -; -Ok -( -sid -) -} -/ -/ -/ -Attempt -to -clear -the -cache -used -by -this -lazy -DFA -. -/ -/ -/ -/ -/ -/ -If -clearing -the -cache -exceeds -the -minimum -number -of -required -cache -/ -/ -/ -clearings -then -this -will -return -a -cache -error -. -In -this -case -/ -/ -/ -callers -should -bubble -this -up -as -the -cache -can -' -t -be -used -until -it -is -/ -/ -/ -reset -. -Implementations -of -search -should -convert -this -error -into -a -/ -/ -/ -[ -MatchError -: -: -gave_up -] -. -/ -/ -/ -/ -/ -/ -If -' -self -. -state_saver -' -is -set -to -save -a -state -then -this -state -is -/ -/ -/ -persisted -through -cache -clearing -. -Otherwise -the -cache -is -returned -to -/ -/ -/ -its -state -after -initialization -with -two -exceptions -: -its -clear -count -/ -/ -/ -is -incremented -and -some -of -its -memory -likely -has -additional -capacity -. -/ -/ -/ -That -is -clearing -a -cache -does -_not_ -release -memory -. -/ -/ -/ -/ -/ -/ -Otherwise -any -lazy -state -ID -generated -by -the -cache -prior -to -resetting -/ -/ -/ -it -is -invalid -after -the -reset -. -fn -try_clear_cache -( -& -mut -self -) -- -> -Result -< -( -) -CacheError -> -{ -let -c -= -self -. -dfa -. -get_config -( -) -; -if -let -Some -( -min_count -) -= -c -. -get_minimum_cache_clear_count -( -) -{ -if -self -. -cache -. -clear_count -> -= -min_count -{ -if -let -Some -( -min_bytes_per -) -= -c -. -get_minimum_bytes_per_state -( -) -{ -let -len -= -self -. -cache -. -search_total_len -( -) -; -let -min_bytes -= -min_bytes_per -. -saturating_mul -( -self -. -cache -. -states -. -len -( -) -) -; -/ -/ -If -we -' -ve -searched -0 -bytes -then -probably -something -has -/ -/ -gone -wrong -and -the -lazy -DFA -search -implementation -isn -' -t -/ -/ -correctly -updating -the -search -progress -state -. -if -len -= -= -0 -{ -trace -! -( -" -number -of -bytes -searched -is -0 -but -\ -a -minimum -bytes -per -state -searched -( -{ -} -) -is -\ -enabled -maybe -Cache -: -: -search_update -\ -is -not -being -used -? -" -min_bytes_per -) -; -} -if -len -< -min_bytes -{ -trace -! -( -" -lazy -DFA -cache -has -been -cleared -{ -} -times -\ -which -exceeds -the -limit -of -{ -} -\ -AND -its -bytes -searched -per -state -is -less -\ -than -the -configured -minimum -of -{ -} -\ -therefore -lazy -DFA -is -giving -up -\ -( -bytes -searched -since -cache -clear -= -{ -} -\ -number -of -states -= -{ -} -) -" -self -. -cache -. -clear_count -min_count -min_bytes_per -len -self -. -cache -. -states -. -len -( -) -) -; -return -Err -( -CacheError -: -: -bad_efficiency -( -) -) -; -} -else -{ -trace -! -( -" -lazy -DFA -cache -has -been -cleared -{ -} -times -\ -which -exceeds -the -limit -of -{ -} -\ -AND -its -bytes -searched -per -state -is -greater -\ -than -the -configured -minimum -of -{ -} -\ -therefore -lazy -DFA -is -continuing -! -\ -( -bytes -searched -since -cache -clear -= -{ -} -\ -number -of -states -= -{ -} -) -" -self -. -cache -. -clear_count -min_count -min_bytes_per -len -self -. -cache -. -states -. -len -( -) -) -; -} -} -else -{ -trace -! -( -" -lazy -DFA -cache -has -been -cleared -{ -} -times -\ -which -exceeds -the -limit -of -{ -} -\ -since -there -is -no -configured -bytes -per -state -\ -minimum -lazy -DFA -is -giving -up -" -self -. -cache -. -clear_count -min_count -) -; -return -Err -( -CacheError -: -: -too_many_cache_clears -( -) -) -; -} -} -} -self -. -clear_cache -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Clears -_and_ -resets -the -cache -. -Resetting -the -cache -means -that -no -/ -/ -/ -states -are -persisted -and -the -clear -count -is -reset -to -0 -. -No -heap -memory -/ -/ -/ -is -released -. -/ -/ -/ -/ -/ -/ -Note -that -the -caller -may -reset -a -cache -with -a -different -DFA -than -what -/ -/ -/ -it -was -created -from -. -In -which -case -the -cache -can -now -be -used -with -the -/ -/ -/ -new -DFA -( -and -not -the -old -DFA -) -. -fn -reset_cache -( -& -mut -self -) -{ -self -. -cache -. -state_saver -= -StateSaver -: -: -none -( -) -; -self -. -clear_cache -( -) -; -/ -/ -If -a -new -DFA -is -used -it -might -have -a -different -number -of -NFA -/ -/ -states -so -we -need -to -make -sure -our -sparse -sets -have -the -appropriate -/ -/ -size -. -self -. -cache -. -sparses -. -resize -( -self -. -dfa -. -get_nfa -( -) -. -states -( -) -. -len -( -) -) -; -self -. -cache -. -clear_count -= -0 -; -self -. -cache -. -progress -= -None -; -} -/ -/ -/ -Clear -the -cache -used -by -this -lazy -DFA -. -/ -/ -/ -/ -/ -/ -If -' -self -. -state_saver -' -is -set -to -save -a -state -then -this -state -is -/ -/ -/ -persisted -through -cache -clearing -. -Otherwise -the -cache -is -returned -to -/ -/ -/ -its -state -after -initialization -with -two -exceptions -: -its -clear -count -/ -/ -/ -is -incremented -and -some -of -its -memory -likely -has -additional -capacity -. -/ -/ -/ -That -is -clearing -a -cache -does -_not_ -release -memory -. -/ -/ -/ -/ -/ -/ -Otherwise -any -lazy -state -ID -generated -by -the -cache -prior -to -resetting -/ -/ -/ -it -is -invalid -after -the -reset -. -fn -clear_cache -( -& -mut -self -) -{ -self -. -cache -. -trans -. -clear -( -) -; -self -. -cache -. -starts -. -clear -( -) -; -self -. -cache -. -states -. -clear -( -) -; -self -. -cache -. -states_to_id -. -clear -( -) -; -self -. -cache -. -memory_usage_state -= -0 -; -self -. -cache -. -clear_count -+ -= -1 -; -self -. -cache -. -bytes_searched -= -0 -; -if -let -Some -( -ref -mut -progress -) -= -self -. -cache -. -progress -{ -progress -. -start -= -progress -. -at -; -} -trace -! -( -" -lazy -DFA -cache -has -been -cleared -( -count -: -{ -} -) -" -self -. -cache -. -clear_count -) -; -self -. -init_cache -( -) -; -/ -/ -If -the -state -we -want -to -save -is -one -of -the -sentinel -/ -/ -( -unknown -/ -dead -/ -quit -) -states -then -' -init_cache -' -adds -those -back -and -/ -/ -their -identifier -values -remains -invariant -. -So -there -' -s -no -need -to -add -/ -/ -it -again -. -( -And -indeed -doing -so -would -be -incorrect -! -) -if -let -Some -( -( -old_id -state -) -) -= -self -. -cache -. -state_saver -. -take_to_save -( -) -{ -/ -/ -If -the -state -is -one -of -the -special -sentinel -states -then -it -is -/ -/ -automatically -added -by -cache -initialization -and -its -ID -always -/ -/ -remains -the -same -. -With -that -said -this -should -never -occur -since -/ -/ -the -sentinel -states -are -all -loop -states -back -to -themselves -. -So -/ -/ -we -should -never -be -in -a -position -where -we -' -re -attempting -to -save -/ -/ -a -sentinel -state -since -we -never -compute -transitions -out -of -a -/ -/ -sentinel -state -. -assert -! -( -! -self -. -as_ref -( -) -. -is_sentinel -( -old_id -) -" -cannot -save -sentinel -state -" -) -; -let -new_id -= -self -. -add_state -( -state -| -id -| -{ -if -old_id -. -is_start -( -) -{ -/ -/ -We -don -' -t -need -to -consult -the -/ -/ -' -specialize_start_states -' -config -knob -here -because -/ -/ -if -it -' -s -disabled -old_id -. -is_start -( -) -will -never -/ -/ -return -true -. -id -. -to_start -( -) -} -else -{ -id -} -} -) -/ -/ -The -unwrap -here -is -OK -because -lazy -DFA -creation -ensures -that -/ -/ -we -have -room -in -the -cache -to -add -MIN_STATES -states -. -Since -/ -/ -' -init_cache -' -above -adds -3 -this -adds -a -4th -. -. -expect -( -" -adding -one -state -after -cache -clear -must -work -" -) -; -self -. -cache -. -state_saver -= -StateSaver -: -: -Saved -( -new_id -) -; -} -} -/ -/ -/ -Initialize -this -cache -from -emptiness -to -a -place -where -it -can -be -used -/ -/ -/ -for -search -. -/ -/ -/ -/ -/ -/ -This -is -called -both -at -cache -creation -time -and -after -the -cache -has -been -/ -/ -/ -cleared -. -/ -/ -/ -/ -/ -/ -Primarily -this -adds -the -three -sentinel -states -and -allocates -some -/ -/ -/ -initial -memory -. -fn -init_cache -( -& -mut -self -) -{ -/ -/ -Why -multiply -by -2 -here -? -Because -we -make -room -for -both -the -unanchored -/ -/ -and -anchored -start -states -. -Unanchored -is -first -and -then -anchored -. -let -mut -starts_len -= -Start -: -: -len -( -) -. -checked_mul -( -2 -) -. -unwrap -( -) -; -/ -/ -. -. -. -but -if -we -also -want -start -states -for -every -pattern -we -make -room -/ -/ -for -that -too -. -if -self -. -dfa -. -get_config -( -) -. -get_starts_for_each_pattern -( -) -{ -starts_len -+ -= -Start -: -: -len -( -) -* -self -. -dfa -. -pattern_len -( -) -; -} -self -. -cache -. -starts -. -extend -( -iter -: -: -repeat -( -self -. -as_ref -( -) -. -unknown_id -( -) -) -. -take -( -starts_len -) -) -; -/ -/ -This -is -the -set -of -NFA -states -that -corresponds -to -each -of -our -three -/ -/ -sentinel -states -: -the -empty -set -. -let -dead -= -State -: -: -dead -( -) -; -/ -/ -This -sets -up -some -states -that -we -use -as -sentinels -that -are -present -/ -/ -in -every -DFA -. -While -it -would -be -technically -possible -to -implement -/ -/ -this -DFA -without -explicitly -putting -these -states -in -the -transition -/ -/ -table -this -is -convenient -to -do -to -make -next_state -correct -for -all -/ -/ -valid -state -IDs -without -needing -explicit -conditionals -to -special -/ -/ -case -these -sentinel -states -. -/ -/ -/ -/ -All -three -of -these -states -are -" -dead -" -states -. -That -is -all -of -/ -/ -them -transition -only -to -themselves -. -So -once -you -enter -one -of -/ -/ -these -states -it -' -s -impossible -to -leave -them -. -Thus -any -correct -/ -/ -search -routine -must -explicitly -check -for -these -state -types -. -( -Sans -/ -/ -unknown -since -that -is -only -used -internally -to -represent -missing -/ -/ -states -. -) -let -unk_id -= -self -. -add_state -( -dead -. -clone -( -) -| -id -| -id -. -to_unknown -( -) -) -. -unwrap -( -) -; -let -dead_id -= -self -. -add_state -( -dead -. -clone -( -) -| -id -| -id -. -to_dead -( -) -) -. -unwrap -( -) -; -let -quit_id -= -self -. -add_state -( -dead -. -clone -( -) -| -id -| -id -. -to_quit -( -) -) -. -unwrap -( -) -; -assert_eq -! -( -unk_id -self -. -as_ref -( -) -. -unknown_id -( -) -) -; -assert_eq -! -( -dead_id -self -. -as_ref -( -) -. -dead_id -( -) -) -; -assert_eq -! -( -quit_id -self -. -as_ref -( -) -. -quit_id -( -) -) -; -/ -/ -The -idea -here -is -that -if -you -start -in -an -unknown -/ -dead -/ -quit -state -and -/ -/ -try -to -transition -on -them -then -you -should -end -up -where -you -started -. -self -. -set_all_transitions -( -unk_id -unk_id -) -; -self -. -set_all_transitions -( -dead_id -dead_id -) -; -self -. -set_all_transitions -( -quit_id -quit_id -) -; -/ -/ -All -of -these -states -are -technically -equivalent -from -the -FSM -/ -/ -perspective -so -putting -all -three -of -them -in -the -cache -isn -' -t -/ -/ -possible -. -( -They -are -distinct -merely -because -we -use -their -/ -/ -identifiers -as -sentinels -to -mean -something -as -indicated -by -the -/ -/ -names -. -) -Moreover -we -wouldn -' -t -want -to -do -that -. -Unknown -and -quit -/ -/ -states -are -special -in -that -they -are -artificial -constructions -/ -/ -this -implementation -. -But -dead -states -are -a -natural -part -of -/ -/ -determinization -. -When -you -reach -a -point -in -the -NFA -where -you -cannot -/ -/ -go -anywhere -else -a -dead -state -will -naturally -arise -and -we -MUST -/ -/ -reuse -the -canonical -dead -state -that -we -' -ve -created -here -. -Why -? -Because -/ -/ -it -is -the -state -ID -that -tells -the -search -routine -whether -a -state -is -/ -/ -dead -or -not -and -thus -whether -to -stop -the -search -. -Having -a -bunch -of -/ -/ -distinct -dead -states -would -be -quite -wasteful -! -self -. -cache -. -states_to_id -. -insert -( -dead -dead_id -) -; -} -/ -/ -/ -Save -the -state -corresponding -to -the -ID -given -such -that -the -state -/ -/ -/ -persists -through -a -cache -clearing -. -/ -/ -/ -/ -/ -/ -While -the -state -may -persist -the -ID -may -not -. -In -order -to -discover -the -/ -/ -/ -new -state -ID -one -must -call -' -saved_state_id -' -after -a -cache -clearing -. -fn -save_state -( -& -mut -self -id -: -LazyStateID -) -{ -let -state -= -self -. -as_ref -( -) -. -get_cached_state -( -id -) -. -clone -( -) -; -self -. -cache -. -state_saver -= -StateSaver -: -: -ToSave -{ -id -state -} -; -} -/ -/ -/ -Returns -the -updated -lazy -state -ID -for -a -state -that -was -persisted -/ -/ -/ -through -a -cache -clearing -. -/ -/ -/ -/ -/ -/ -It -is -only -correct -to -call -this -routine -when -both -a -state -has -been -/ -/ -/ -saved -and -the -cache -has -just -been -cleared -. -Otherwise -this -panics -. -fn -saved_state_id -( -& -mut -self -) -- -> -LazyStateID -{ -self -. -cache -. -state_saver -. -take_saved -( -) -. -expect -( -" -state -saver -does -not -have -saved -state -ID -" -) -} -/ -/ -/ -Set -all -transitions -on -the -state -' -from -' -to -' -to -' -. -fn -set_all_transitions -( -& -mut -self -from -: -LazyStateID -to -: -LazyStateID -) -{ -for -unit -in -self -. -dfa -. -classes -. -representatives -( -. -. -) -{ -self -. -set_transition -( -from -unit -to -) -; -} -} -/ -/ -/ -Set -the -transition -on -' -from -' -for -' -unit -' -to -' -to -' -. -/ -/ -/ -/ -/ -/ -This -panics -if -either -' -from -' -or -' -to -' -is -invalid -. -/ -/ -/ -/ -/ -/ -All -unit -values -are -OK -. -fn -set_transition -( -& -mut -self -from -: -LazyStateID -unit -: -alphabet -: -: -Unit -to -: -LazyStateID -) -{ -assert -! -( -self -. -as_ref -( -) -. -is_valid -( -from -) -" -invalid -' -from -' -id -: -{ -: -? -} -" -from -) -; -assert -! -( -self -. -as_ref -( -) -. -is_valid -( -to -) -" -invalid -' -to -' -id -: -{ -: -? -} -" -to -) -; -let -offset -= -from -. -as_usize_untagged -( -) -+ -self -. -dfa -. -classes -. -get_by_unit -( -unit -) -; -self -. -cache -. -trans -[ -offset -] -= -to -; -} -/ -/ -/ -Set -the -start -ID -for -the -given -pattern -ID -( -if -given -) -and -starting -/ -/ -/ -configuration -to -the -ID -given -. -/ -/ -/ -/ -/ -/ -This -panics -if -' -id -' -is -not -valid -or -if -a -pattern -ID -is -given -and -/ -/ -/ -' -starts_for_each_pattern -' -is -not -enabled -. -fn -set_start_state -( -& -mut -self -input -: -& -Input -< -' -_ -> -start -: -Start -id -: -LazyStateID -) -{ -assert -! -( -self -. -as_ref -( -) -. -is_valid -( -id -) -) -; -let -start_index -= -start -. -as_usize -( -) -; -let -index -= -match -input -. -get_anchored -( -) -{ -Anchored -: -: -No -= -> -start_index -Anchored -: -: -Yes -= -> -Start -: -: -len -( -) -+ -start_index -Anchored -: -: -Pattern -( -pid -) -= -> -{ -assert -! -( -self -. -dfa -. -get_config -( -) -. -get_starts_for_each_pattern -( -) -" -attempted -to -search -for -a -specific -pattern -\ -without -enabling -starts_for_each_pattern -" -) -; -let -pid -= -pid -. -as_usize -( -) -; -( -2 -* -Start -: -: -len -( -) -) -+ -( -Start -: -: -len -( -) -* -pid -) -+ -start_index -} -} -; -self -. -cache -. -starts -[ -index -] -= -id -; -} -/ -/ -/ -Returns -a -state -builder -from -this -DFA -that -might -have -existing -/ -/ -/ -capacity -. -This -helps -avoid -allocs -in -cases -where -a -state -is -built -that -/ -/ -/ -turns -out -to -already -be -cached -. -/ -/ -/ -/ -/ -/ -Callers -must -put -the -state -builder -back -with -' -put_state_builder -' -/ -/ -/ -otherwise -the -allocation -reuse -won -' -t -work -. -fn -get_state_builder -( -& -mut -self -) -- -> -StateBuilderEmpty -{ -core -: -: -mem -: -: -replace -( -& -mut -self -. -cache -. -scratch_state_builder -StateBuilderEmpty -: -: -new -( -) -) -} -/ -/ -/ -Puts -the -given -state -builder -back -into -this -DFA -for -reuse -. -/ -/ -/ -/ -/ -/ -Note -that -building -a -' -State -' -from -a -builder -always -creates -a -new -alloc -/ -/ -/ -so -callers -should -always -put -the -builder -back -. -fn -put_state_builder -( -& -mut -self -builder -: -StateBuilderNFA -) -{ -let -_ -= -core -: -: -mem -: -: -replace -( -& -mut -self -. -cache -. -scratch_state_builder -builder -. -clear -( -) -) -; -} -} -/ -/ -/ -A -type -that -groups -methods -that -require -the -base -NFA -/ -DFA -and -read -- -only -/ -/ -/ -access -to -the -cache -. -# -[ -derive -( -Debug -) -] -struct -LazyRef -< -' -i -' -c -> -{ -dfa -: -& -' -i -DFA -cache -: -& -' -c -Cache -} -impl -< -' -i -' -c -> -LazyRef -< -' -i -' -c -> -{ -/ -/ -/ -Creates -a -new -' -Lazy -' -wrapper -for -a -DFA -and -its -corresponding -cache -. -fn -new -( -dfa -: -& -' -i -DFA -cache -: -& -' -c -Cache -) -- -> -LazyRef -< -' -i -' -c -> -{ -LazyRef -{ -dfa -cache -} -} -/ -/ -/ -Return -the -ID -of -the -start -state -for -the -given -configuration -. -/ -/ -/ -/ -/ -/ -If -the -start -state -has -not -yet -been -computed -then -this -returns -an -/ -/ -/ -unknown -lazy -state -ID -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -get_cached_start_id -( -& -self -input -: -& -Input -< -' -_ -> -start -: -Start -) -- -> -Result -< -LazyStateID -MatchError -> -{ -let -start_index -= -start -. -as_usize -( -) -; -let -mode -= -input -. -get_anchored -( -) -; -let -index -= -match -mode -{ -Anchored -: -: -No -= -> -start_index -Anchored -: -: -Yes -= -> -Start -: -: -len -( -) -+ -start_index -Anchored -: -: -Pattern -( -pid -) -= -> -{ -if -! -self -. -dfa -. -get_config -( -) -. -get_starts_for_each_pattern -( -) -{ -return -Err -( -MatchError -: -: -unsupported_anchored -( -mode -) -) -; -} -if -pid -. -as_usize -( -) -> -= -self -. -dfa -. -pattern_len -( -) -{ -return -Ok -( -self -. -dead_id -( -) -) -; -} -( -2 -* -Start -: -: -len -( -) -) -+ -( -Start -: -: -len -( -) -* -pid -. -as_usize -( -) -) -+ -start_index -} -} -; -Ok -( -self -. -cache -. -starts -[ -index -] -) -} -/ -/ -/ -Return -the -cached -NFA -/ -DFA -powerset -state -for -the -given -ID -. -/ -/ -/ -/ -/ -/ -This -panics -if -the -given -ID -does -not -address -a -valid -state -. -fn -get_cached_state -( -& -self -sid -: -LazyStateID -) -- -> -& -State -{ -let -index -= -sid -. -as_usize_untagged -( -) -> -> -self -. -dfa -. -stride2 -( -) -; -& -self -. -cache -. -states -[ -index -] -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -ID -corresponds -to -a -" -sentinel -" -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -A -sentinel -state -is -a -state -that -signifies -a -special -condition -of -/ -/ -/ -search -and -where -every -transition -maps -back -to -itself -. -See -LazyStateID -/ -/ -/ -for -more -details -. -Note -that -start -and -match -states -are -_not_ -sentinels -/ -/ -/ -since -they -may -otherwise -be -real -states -with -non -- -trivial -transitions -. -/ -/ -/ -The -purposes -of -sentinel -states -is -purely -to -indicate -something -. -Their -/ -/ -/ -transitions -are -not -meant -to -be -followed -. -fn -is_sentinel -( -& -self -id -: -LazyStateID -) -- -> -bool -{ -id -= -= -self -. -unknown_id -( -) -| -| -id -= -= -self -. -dead_id -( -) -| -| -id -= -= -self -. -quit_id -( -) -} -/ -/ -/ -Returns -the -ID -of -the -unknown -state -for -this -lazy -DFA -. -fn -unknown_id -( -& -self -) -- -> -LazyStateID -{ -/ -/ -This -unwrap -is -OK -since -0 -is -always -a -valid -state -ID -. -LazyStateID -: -: -new -( -0 -) -. -unwrap -( -) -. -to_unknown -( -) -} -/ -/ -/ -Returns -the -ID -of -the -dead -state -for -this -lazy -DFA -. -fn -dead_id -( -& -self -) -- -> -LazyStateID -{ -/ -/ -This -unwrap -is -OK -since -the -maximum -value -here -is -1 -* -512 -= -512 -/ -/ -which -is -< -= -2047 -( -the -maximum -state -ID -on -16 -- -bit -systems -) -. -Where -/ -/ -512 -is -the -worst -case -for -our -equivalence -classes -( -every -byte -is -a -/ -/ -distinct -class -) -. -LazyStateID -: -: -new -( -1 -< -< -self -. -dfa -. -stride2 -( -) -) -. -unwrap -( -) -. -to_dead -( -) -} -/ -/ -/ -Returns -the -ID -of -the -quit -state -for -this -lazy -DFA -. -fn -quit_id -( -& -self -) -- -> -LazyStateID -{ -/ -/ -This -unwrap -is -OK -since -the -maximum -value -here -is -2 -* -512 -= -1024 -/ -/ -which -is -< -= -2047 -( -the -maximum -state -ID -on -16 -- -bit -systems -) -. -Where -/ -/ -512 -is -the -worst -case -for -our -equivalence -classes -( -every -byte -is -a -/ -/ -distinct -class -) -. -LazyStateID -: -: -new -( -2 -< -< -self -. -dfa -. -stride2 -( -) -) -. -unwrap -( -) -. -to_quit -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -ID -is -valid -. -/ -/ -/ -/ -/ -/ -An -ID -is -valid -if -it -is -both -a -valid -index -into -the -transition -table -/ -/ -/ -and -is -a -multiple -of -the -DFA -' -s -stride -. -fn -is_valid -( -& -self -id -: -LazyStateID -) -- -> -bool -{ -let -id -= -id -. -as_usize_untagged -( -) -; -id -< -self -. -cache -. -trans -. -len -( -) -& -& -id -% -self -. -dfa -. -stride -( -) -= -= -0 -} -/ -/ -/ -Returns -true -if -adding -the -state -given -would -fit -in -this -cache -. -fn -state_fits_in_cache -( -& -self -state -: -& -State -) -- -> -bool -{ -let -needed -= -self -. -cache -. -memory_usage -( -) -+ -self -. -memory_usage_for_one_more_state -( -state -. -memory_usage -( -) -) -; -trace -! -( -" -lazy -DFA -cache -capacity -check -: -{ -: -? -} -? -< -= -? -{ -: -? -} -" -needed -self -. -dfa -. -cache_capacity -) -; -needed -< -= -self -. -dfa -. -cache_capacity -} -/ -/ -/ -Returns -true -if -adding -the -state -to -be -built -by -the -given -builder -would -/ -/ -/ -fit -in -this -cache -. -fn -state_builder_fits_in_cache -( -& -self -state -: -& -StateBuilderNFA -) -- -> -bool -{ -let -needed -= -self -. -cache -. -memory_usage -( -) -+ -self -. -memory_usage_for_one_more_state -( -state -. -as_bytes -( -) -. -len -( -) -) -; -needed -< -= -self -. -dfa -. -cache_capacity -} -/ -/ -/ -Returns -the -additional -memory -usage -in -bytes -required -to -add -one -more -/ -/ -/ -state -to -this -cache -. -The -given -size -should -be -the -heap -size -in -bytes -/ -/ -/ -that -would -be -used -by -the -new -state -being -added -. -fn -memory_usage_for_one_more_state -( -& -self -state_heap_size -: -usize -) -- -> -usize -{ -const -ID_SIZE -: -usize -= -size_of -: -: -< -LazyStateID -> -( -) -; -const -STATE_SIZE -: -usize -= -size_of -: -: -< -State -> -( -) -; -self -. -dfa -. -stride -( -) -* -ID_SIZE -/ -/ -additional -space -needed -in -trans -table -+ -STATE_SIZE -/ -/ -space -in -cache -. -states -+ -( -STATE_SIZE -+ -ID_SIZE -) -/ -/ -space -in -cache -. -states_to_id -+ -state_heap_size -/ -/ -heap -memory -used -by -state -itself -} -} -/ -/ -/ -A -simple -type -that -encapsulates -the -saving -of -a -state -ID -through -a -cache -/ -/ -/ -clearing -. -/ -/ -/ -/ -/ -/ -A -state -ID -can -be -marked -for -saving -with -ToSave -while -a -state -ID -can -be -/ -/ -/ -saved -itself -with -Saved -. -# -[ -derive -( -Clone -Debug -) -] -enum -StateSaver -{ -/ -/ -/ -An -empty -state -saver -. -In -this -case -no -states -( -other -than -the -special -/ -/ -/ -sentinel -states -) -are -preserved -after -clearing -the -cache -. -None -/ -/ -/ -An -ID -of -a -state -( -and -the -state -itself -) -that -should -be -preserved -after -/ -/ -/ -the -lazy -DFA -' -s -cache -has -been -cleared -. -After -clearing -the -updated -ID -/ -/ -/ -is -stored -in -' -Saved -' -since -it -may -have -changed -. -ToSave -{ -id -: -LazyStateID -state -: -State -} -/ -/ -/ -An -ID -that -of -a -state -that -has -been -persisted -through -a -lazy -DFA -/ -/ -/ -cache -clearing -. -The -ID -recorded -here -corresponds -to -an -ID -that -was -/ -/ -/ -once -marked -as -ToSave -. -The -IDs -are -likely -not -equivalent -even -though -/ -/ -/ -the -states -they -point -to -are -. -Saved -( -LazyStateID -) -} -impl -StateSaver -{ -/ -/ -/ -Create -an -empty -state -saver -. -fn -none -( -) -- -> -StateSaver -{ -StateSaver -: -: -None -} -/ -/ -/ -Replace -this -state -saver -with -an -empty -saver -and -if -this -saver -is -a -/ -/ -/ -request -to -save -a -state -return -that -request -. -fn -take_to_save -( -& -mut -self -) -- -> -Option -< -( -LazyStateID -State -) -> -{ -match -core -: -: -mem -: -: -replace -( -self -StateSaver -: -: -None -) -{ -StateSaver -: -: -None -| -StateSaver -: -: -Saved -( -_ -) -= -> -None -StateSaver -: -: -ToSave -{ -id -state -} -= -> -Some -( -( -id -state -) -) -} -} -/ -/ -/ -Replace -this -state -saver -with -an -empty -saver -and -if -this -saver -is -a -/ -/ -/ -saved -state -( -or -a -request -to -save -a -state -) -return -that -state -' -s -ID -. -/ -/ -/ -/ -/ -/ -The -idea -here -is -that -a -request -to -save -a -state -isn -' -t -necessarily -/ -/ -/ -honored -because -it -might -not -be -needed -. -e -. -g -. -Some -higher -level -code -/ -/ -/ -might -request -a -state -to -be -saved -on -the -off -chance -that -the -cache -gets -/ -/ -/ -cleared -when -a -new -state -is -added -at -a -lower -level -. -But -if -that -new -/ -/ -/ -state -is -never -added -then -the -cache -is -never -cleared -and -the -state -and -/ -/ -/ -its -ID -remain -unchanged -. -fn -take_saved -( -& -mut -self -) -- -> -Option -< -LazyStateID -> -{ -match -core -: -: -mem -: -: -replace -( -self -StateSaver -: -: -None -) -{ -StateSaver -: -: -None -= -> -None -StateSaver -: -: -Saved -( -id -) -| -StateSaver -: -: -ToSave -{ -id -. -. -} -= -> -Some -( -id -) -} -} -} -/ -/ -/ -The -configuration -used -for -building -a -lazy -DFA -. -/ -/ -/ -/ -/ -/ -As -a -convenience -[ -DFA -: -: -config -] -is -an -alias -for -[ -Config -: -: -new -] -. -The -/ -/ -/ -advantage -of -the -former -is -that -it -often -lets -you -avoid -importing -the -/ -/ -/ -Config -type -directly -. -/ -/ -/ -/ -/ -/ -A -lazy -DFA -configuration -is -a -simple -data -object -that -is -typically -used -/ -/ -/ -with -[ -Builder -: -: -configure -] -. -/ -/ -/ -/ -/ -/ -The -default -configuration -guarantees -that -a -search -will -never -return -a -/ -/ -/ -" -gave -up -" -or -" -quit -" -error -although -it -is -possible -for -a -search -to -fail -/ -/ -/ -if -[ -Config -: -: -starts_for_each_pattern -] -wasn -' -t -enabled -( -which -it -is -not -by -/ -/ -/ -default -) -and -an -[ -Anchored -: -: -Pattern -] -mode -is -requested -via -[ -Input -] -. -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -Config -{ -/ -/ -As -with -other -configuration -types -in -this -crate -we -put -all -our -knobs -/ -/ -in -options -so -that -we -can -distinguish -between -" -default -" -and -" -not -set -. -" -/ -/ -This -makes -it -possible -to -easily -combine -multiple -configurations -/ -/ -without -default -values -overwriting -explicitly -specified -values -. -See -the -/ -/ -' -overwrite -' -method -. -/ -/ -/ -/ -For -docs -on -the -fields -below -see -the -corresponding -method -setters -. -match_kind -: -Option -< -MatchKind -> -pre -: -Option -< -Option -< -Prefilter -> -> -starts_for_each_pattern -: -Option -< -bool -> -byte_classes -: -Option -< -bool -> -unicode_word_boundary -: -Option -< -bool -> -quitset -: -Option -< -ByteSet -> -specialize_start_states -: -Option -< -bool -> -cache_capacity -: -Option -< -usize -> -skip_cache_capacity_check -: -Option -< -bool -> -minimum_cache_clear_count -: -Option -< -Option -< -usize -> -> -minimum_bytes_per_state -: -Option -< -Option -< -usize -> -> -} -impl -Config -{ -/ -/ -/ -Return -a -new -default -lazy -DFA -builder -configuration -. -pub -fn -new -( -) -- -> -Config -{ -Config -: -: -default -( -) -} -/ -/ -/ -Set -the -desired -match -semantics -. -/ -/ -/ -/ -/ -/ -The -default -is -[ -MatchKind -: -: -LeftmostFirst -] -which -corresponds -to -the -/ -/ -/ -match -semantics -of -Perl -- -like -regex -engines -. -That -is -when -multiple -/ -/ -/ -patterns -would -match -at -the -same -leftmost -position -the -pattern -that -/ -/ -/ -appears -first -in -the -concrete -syntax -is -chosen -. -/ -/ -/ -/ -/ -/ -Currently -the -only -other -kind -of -match -semantics -supported -is -/ -/ -/ -[ -MatchKind -: -: -All -] -. -This -corresponds -to -classical -DFA -construction -/ -/ -/ -where -all -possible -matches -are -added -to -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -Typically -All -is -used -when -one -wants -to -execute -an -overlapping -/ -/ -/ -search -and -LeftmostFirst -otherwise -. -In -particular -it -rarely -makes -/ -/ -/ -sense -to -use -All -with -the -various -" -leftmost -" -find -routines -since -the -/ -/ -/ -leftmost -routines -depend -on -the -LeftmostFirst -automata -construction -/ -/ -/ -strategy -. -Specifically -LeftmostFirst -adds -dead -states -to -the -/ -/ -/ -lazy -DFA -as -a -way -to -terminate -the -search -and -report -a -match -. -/ -/ -/ -LeftmostFirst -also -supports -non -- -greedy -matches -using -this -strategy -/ -/ -/ -where -as -All -does -not -. -/ -/ -/ -/ -/ -/ -# -Example -: -overlapping -search -/ -/ -/ -/ -/ -/ -This -example -shows -the -typical -use -of -MatchKind -: -: -All -which -is -to -/ -/ -/ -report -overlapping -matches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -{ -DFA -OverlappingState -} -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -\ -w -+ -" -r -" -\ -S -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -foo -" -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -1 -4 -) -) -; -/ -/ -/ -dfa -. -try_search_overlapping_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -& -mut -state -/ -/ -/ -) -? -; -/ -/ -/ -assert_eq -! -( -expected -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -first -pattern -also -matches -at -the -same -position -so -re -- -running -/ -/ -/ -/ -/ -the -search -will -yield -another -match -. -Notice -also -that -the -first -/ -/ -/ -/ -/ -pattern -is -returned -after -the -second -. -This -is -because -the -second -/ -/ -/ -/ -/ -pattern -begins -its -match -before -the -first -is -therefore -an -earlier -/ -/ -/ -/ -/ -match -and -is -thus -reported -first -. -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -4 -) -) -; -/ -/ -/ -dfa -. -try_search_overlapping_fwd -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -& -mut -state -/ -/ -/ -) -? -; -/ -/ -/ -assert_eq -! -( -expected -state -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -reverse -automaton -to -find -start -of -match -/ -/ -/ -/ -/ -/ -Another -example -for -using -MatchKind -: -: -All -is -for -constructing -a -/ -/ -/ -reverse -automaton -to -find -the -start -of -a -match -. -All -semantics -are -/ -/ -/ -used -for -this -in -order -to -find -the -longest -possible -match -which -/ -/ -/ -corresponds -to -the -leftmost -starting -position -. -/ -/ -/ -/ -/ -/ -Note -that -if -you -need -the -starting -position -then -/ -/ -/ -[ -hybrid -: -: -regex -: -: -Regex -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -will -handle -this -/ -/ -/ -for -you -so -it -' -s -usually -not -necessary -to -do -this -yourself -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -nfa -: -: -thompson -: -: -NFA -/ -/ -/ -Anchored -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -123foobar456 -" -) -; -/ -/ -/ -let -pattern -= -r -" -[ -a -- -z -] -+ -r -" -; -/ -/ -/ -/ -/ -/ -let -dfa_fwd -= -DFA -: -: -new -( -pattern -) -? -; -/ -/ -/ -let -dfa_rev -= -DFA -: -: -builder -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build -( -pattern -) -? -; -/ -/ -/ -let -mut -cache_fwd -= -dfa_fwd -. -create_cache -( -) -; -/ -/ -/ -let -mut -cache_rev -= -dfa_rev -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -expected_fwd -= -HalfMatch -: -: -must -( -0 -9 -) -; -/ -/ -/ -let -expected_rev -= -HalfMatch -: -: -must -( -0 -3 -) -; -/ -/ -/ -let -got_fwd -= -dfa_fwd -. -try_search_fwd -( -& -mut -cache_fwd -& -input -) -? -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Here -we -don -' -t -specify -the -pattern -to -search -for -since -there -' -s -only -/ -/ -/ -/ -/ -one -pattern -and -we -' -re -doing -a -leftmost -search -. -But -if -this -were -an -/ -/ -/ -/ -/ -overlapping -search -you -' -d -need -to -specify -the -pattern -that -matched -/ -/ -/ -/ -/ -in -the -forward -direction -. -( -Otherwise -you -might -wind -up -finding -the -/ -/ -/ -/ -/ -starting -position -of -a -match -of -some -other -pattern -. -) -That -in -turn -/ -/ -/ -/ -/ -requires -building -the -reverse -automaton -with -starts_for_each_pattern -/ -/ -/ -/ -/ -enabled -. -/ -/ -/ -let -input -= -input -/ -/ -/ -. -clone -( -) -/ -/ -/ -. -range -( -. -. -got_fwd -. -offset -( -) -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -let -got_rev -= -dfa_rev -. -try_search_rev -( -& -mut -cache_rev -& -input -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -expected_fwd -got_fwd -) -; -/ -/ -/ -assert_eq -! -( -expected_rev -got_rev -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -match_kind -( -mut -self -kind -: -MatchKind -) -- -> -Config -{ -self -. -match_kind -= -Some -( -kind -) -; -self -} -/ -/ -/ -Set -a -prefilter -to -be -used -whenever -a -start -state -is -entered -. -/ -/ -/ -/ -/ -/ -A -[ -Prefilter -] -in -this -context -is -meant -to -accelerate -searches -by -/ -/ -/ -looking -for -literal -prefixes -that -every -match -for -the -corresponding -/ -/ -/ -pattern -( -or -patterns -) -must -start -with -. -Once -a -prefilter -produces -a -/ -/ -/ -match -the -underlying -search -routine -continues -on -to -try -and -confirm -/ -/ -/ -the -match -. -/ -/ -/ -/ -/ -/ -Be -warned -that -setting -a -prefilter -does -not -guarantee -that -the -search -/ -/ -/ -will -be -faster -. -While -it -' -s -usually -a -good -bet -if -the -prefilter -/ -/ -/ -produces -a -lot -of -false -positive -candidates -( -i -. -e -. -positions -matched -/ -/ -/ -by -the -prefilter -but -not -by -the -regex -) -then -the -overall -result -can -/ -/ -/ -be -slower -than -if -you -had -just -executed -the -regex -engine -without -any -/ -/ -/ -prefilters -. -/ -/ -/ -/ -/ -/ -Note -that -unless -[ -Config -: -: -specialize_start_states -] -has -been -/ -/ -/ -explicitly -set -then -setting -this -will -also -enable -( -when -pre -is -/ -/ -/ -Some -) -or -disable -( -when -pre -is -None -) -start -state -specialization -. -/ -/ -/ -This -occurs -because -without -start -state -specialization -a -prefilter -/ -/ -/ -is -likely -to -be -less -effective -. -And -without -a -prefilter -start -state -/ -/ -/ -specialization -is -usually -pointless -. -/ -/ -/ -/ -/ -/ -By -default -no -prefilter -is -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Input -HalfMatch -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -prefilter -( -pre -) -) -/ -/ -/ -. -build -( -r -" -( -foo -| -bar -) -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo1 -barfox -bar -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -HalfMatch -: -: -must -( -0 -11 -) -) -/ -/ -/ -re -. -try_search_fwd -( -& -mut -cache -& -input -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Be -warned -though -that -an -incorrect -prefilter -can -lead -to -incorrect -/ -/ -/ -results -! -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Input -HalfMatch -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -foo -" -" -car -" -] -) -; -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -prefilter -( -pre -) -) -/ -/ -/ -. -build -( -r -" -( -foo -| -bar -) -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo1 -barfox -bar -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -/ -/ -No -match -reported -even -though -there -clearly -is -one -! -/ -/ -/ -None -/ -/ -/ -re -. -try_search_fwd -( -& -mut -cache -& -input -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -prefilter -( -mut -self -pre -: -Option -< -Prefilter -> -) -- -> -Config -{ -self -. -pre -= -Some -( -pre -) -; -if -self -. -specialize_start_states -. -is_none -( -) -{ -self -. -specialize_start_states -= -Some -( -self -. -get_prefilter -( -) -. -is_some -( -) -) -; -} -self -} -/ -/ -/ -Whether -to -compile -a -separate -start -state -for -each -pattern -in -the -/ -/ -/ -lazy -DFA -. -/ -/ -/ -/ -/ -/ -When -enabled -a -separate -* -* -anchored -* -* -start -state -is -added -for -each -/ -/ -/ -pattern -in -the -lazy -DFA -. -When -this -start -state -is -used -then -the -DFA -/ -/ -/ -will -only -search -for -matches -for -the -pattern -specified -even -if -there -/ -/ -/ -are -other -patterns -in -the -DFA -. -/ -/ -/ -/ -/ -/ -The -main -downside -of -this -option -is -that -it -can -potentially -increase -/ -/ -/ -the -size -of -the -DFA -and -/ -or -increase -the -time -it -takes -to -build -the -/ -/ -/ -DFA -at -search -time -. -However -since -this -is -configuration -for -a -lazy -/ -/ -/ -DFA -these -states -aren -' -t -actually -built -unless -they -' -re -used -. -Enabling -/ -/ -/ -this -isn -' -t -necessarily -free -however -as -it -may -result -in -higher -cache -/ -/ -/ -usage -. -/ -/ -/ -/ -/ -/ -There -are -a -few -reasons -one -might -want -to -enable -this -( -it -' -s -disabled -/ -/ -/ -by -default -) -: -/ -/ -/ -/ -/ -/ -1 -. -When -looking -for -the -start -of -an -overlapping -match -( -using -a -reverse -/ -/ -/ -DFA -) -doing -it -correctly -requires -starting -the -reverse -search -using -the -/ -/ -/ -starting -state -of -the -pattern -that -matched -in -the -forward -direction -. -/ -/ -/ -Indeed -when -building -a -[ -Regex -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -it -/ -/ -/ -will -automatically -enable -this -option -when -building -the -reverse -DFA -/ -/ -/ -internally -. -/ -/ -/ -2 -. -When -you -want -to -use -a -DFA -with -multiple -patterns -to -both -search -/ -/ -/ -for -matches -of -any -pattern -or -to -search -for -anchored -matches -of -one -/ -/ -/ -particular -pattern -while -using -the -same -DFA -. -( -Otherwise -you -would -need -/ -/ -/ -to -compile -a -new -DFA -for -each -pattern -. -) -/ -/ -/ -/ -/ -/ -By -default -this -is -disabled -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -this -option -to -permit -the -same -lazy -DFA -/ -/ -/ -to -run -both -general -searches -for -any -pattern -and -anchored -searches -for -/ -/ -/ -a -specific -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -Anchored -HalfMatch -Input -PatternID -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -starts_for_each_pattern -( -true -) -) -/ -/ -/ -. -build_many -( -& -[ -r -" -[ -a -- -z0 -- -9 -] -{ -6 -} -" -r -" -[ -a -- -z -] -[ -a -- -z0 -- -9 -] -{ -5 -} -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -bar -foo123 -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Here -' -s -a -normal -unanchored -search -that -looks -for -any -pattern -. -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -10 -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -& -mut -cache -& -input -) -? -) -; -/ -/ -/ -/ -/ -We -can -also -do -a -normal -anchored -search -for -any -pattern -. -Since -it -' -s -/ -/ -/ -/ -/ -an -anchored -search -we -position -the -start -of -the -search -where -we -/ -/ -/ -/ -/ -know -the -match -will -begin -. -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -0 -10 -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -4 -. -. -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -& -mut -cache -& -input -) -? -) -; -/ -/ -/ -/ -/ -Since -we -compiled -anchored -start -states -for -each -pattern -we -can -/ -/ -/ -/ -/ -also -look -for -matches -of -other -patterns -explicitly -even -if -a -/ -/ -/ -/ -/ -different -pattern -would -have -normally -matched -. -/ -/ -/ -let -expected -= -HalfMatch -: -: -must -( -1 -10 -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -range -( -4 -. -. -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -dfa -. -try_search_fwd -( -& -mut -cache -& -input -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -starts_for_each_pattern -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -starts_for_each_pattern -= -Some -( -yes -) -; -self -} -/ -/ -/ -Whether -to -attempt -to -shrink -the -size -of -the -lazy -DFA -' -s -alphabet -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -This -option -is -enabled -by -default -and -should -never -be -disabled -unless -/ -/ -/ -one -is -debugging -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -When -enabled -the -lazy -DFA -will -use -a -map -from -all -possible -bytes -/ -/ -/ -to -their -corresponding -equivalence -class -. -Each -equivalence -class -/ -/ -/ -represents -a -set -of -bytes -that -does -not -discriminate -between -a -match -/ -/ -/ -and -a -non -- -match -in -the -DFA -. -For -example -the -pattern -[ -ab -] -+ -has -at -/ -/ -/ -least -two -equivalence -classes -: -a -set -containing -a -and -b -and -a -set -/ -/ -/ -containing -every -byte -except -for -a -and -b -. -a -and -b -are -in -the -/ -/ -/ -same -equivalence -classes -because -they -never -discriminate -between -a -/ -/ -/ -match -and -a -non -- -match -. -/ -/ -/ -/ -/ -/ -The -advantage -of -this -map -is -that -the -size -of -the -transition -table -/ -/ -/ -can -be -reduced -drastically -from -# -states -* -256 -* -sizeof -( -LazyStateID -) -/ -/ -/ -to -# -states -* -k -* -sizeof -( -LazyStateID -) -where -k -is -the -number -of -/ -/ -/ -equivalence -classes -( -rounded -up -to -the -nearest -power -of -2 -) -. -As -a -/ -/ -/ -result -total -space -usage -can -decrease -substantially -. -Moreover -since -a -/ -/ -/ -smaller -alphabet -is -used -DFA -compilation -during -search -becomes -faster -/ -/ -/ -as -well -since -it -will -potentially -be -able -to -reuse -a -single -transition -/ -/ -/ -for -multiple -bytes -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -This -is -only -useful -for -debugging -lazy -DFAs -. -Disabling -/ -/ -/ -this -does -not -yield -any -speed -advantages -. -Namely -even -when -this -is -/ -/ -/ -disabled -a -byte -class -map -is -still -used -while -searching -. -The -only -/ -/ -/ -difference -is -that -every -byte -will -be -forced -into -its -own -distinct -/ -/ -/ -equivalence -class -. -This -is -useful -for -debugging -the -actual -generated -/ -/ -/ -transitions -because -it -lets -one -see -the -transitions -defined -on -actual -/ -/ -/ -bytes -instead -of -the -equivalence -classes -. -pub -fn -byte_classes -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -byte_classes -= -Some -( -yes -) -; -self -} -/ -/ -/ -Heuristically -enable -Unicode -word -boundaries -. -/ -/ -/ -/ -/ -/ -When -set -this -will -attempt -to -implement -Unicode -word -boundaries -as -if -/ -/ -/ -they -were -ASCII -word -boundaries -. -This -only -works -when -the -search -input -/ -/ -/ -is -ASCII -only -. -If -a -non -- -ASCII -byte -is -observed -while -searching -then -a -/ -/ -/ -[ -MatchError -: -: -quit -] -error -is -returned -. -/ -/ -/ -/ -/ -/ -A -possible -alternative -to -enabling -this -option -is -to -simply -use -an -/ -/ -/ -ASCII -word -boundary -e -. -g -. -via -( -? -- -u -: -\ -b -) -. -The -main -reason -to -use -this -/ -/ -/ -option -is -if -you -absolutely -need -Unicode -support -. -This -option -lets -one -/ -/ -/ -use -a -fast -search -implementation -( -a -DFA -) -for -some -potentially -very -/ -/ -/ -common -cases -while -providing -the -option -to -fall -back -to -some -other -/ -/ -/ -regex -engine -to -handle -the -general -case -when -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -If -the -pattern -provided -has -no -Unicode -word -boundary -in -it -then -this -/ -/ -/ -option -has -no -effect -. -( -That -is -quitting -on -a -non -- -ASCII -byte -only -/ -/ -/ -occurs -when -this -option -is -enabled -_and_ -a -Unicode -word -boundary -is -/ -/ -/ -present -in -the -pattern -. -) -/ -/ -/ -/ -/ -/ -This -is -almost -equivalent -to -setting -all -non -- -ASCII -bytes -to -be -quit -/ -/ -/ -bytes -. -The -only -difference -is -that -this -will -cause -non -- -ASCII -bytes -to -/ -/ -/ -be -quit -bytes -_only_ -when -a -Unicode -word -boundary -is -present -in -the -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -When -enabling -this -option -callers -_must_ -be -prepared -to -handle -/ -/ -/ -a -[ -MatchError -] -( -crate -: -: -MatchError -) -error -during -search -. -/ -/ -/ -When -using -a -[ -Regex -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -this -/ -/ -/ -corresponds -to -using -the -try_ -suite -of -methods -. -Alternatively -/ -/ -/ -if -callers -can -guarantee -that -their -input -is -ASCII -only -then -a -/ -/ -/ -[ -MatchError -: -: -quit -] -error -will -never -be -returned -while -searching -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -heuristically -enable -Unicode -word -boundaries -/ -/ -/ -in -a -pattern -. -It -also -shows -what -happens -when -a -search -comes -across -a -/ -/ -/ -non -- -ASCII -byte -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -HalfMatch -Input -MatchError -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -unicode_word_boundary -( -true -) -) -/ -/ -/ -. -build -( -r -" -\ -b -[ -0 -- -9 -] -+ -\ -b -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -match -occurs -before -the -search -ever -observes -the -snowman -/ -/ -/ -/ -/ -character -so -no -error -occurs -. -/ -/ -/ -let -haystack -= -" -foo -123 -" -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -7 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -this -search -fails -even -though -the -snowman -character -/ -/ -/ -/ -/ -occurs -after -the -ending -match -offset -. -This -is -because -search -/ -/ -/ -/ -/ -routines -read -one -byte -past -the -end -of -the -search -to -account -for -/ -/ -/ -/ -/ -look -- -around -and -indeed -this -is -required -here -to -determine -whether -/ -/ -/ -/ -/ -the -trailing -\ -b -matches -. -/ -/ -/ -let -haystack -= -" -foo -123 -" -; -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -0xE2 -8 -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -) -; -/ -/ -/ -assert_eq -! -( -Err -( -expected -) -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Another -example -is -executing -a -search -where -the -span -of -the -haystack -/ -/ -/ -/ -/ -we -specify -is -all -ASCII -but -there -is -non -- -ASCII -just -before -it -. -This -/ -/ -/ -/ -/ -correctly -also -reports -an -error -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -2 -. -. -) -; -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -0xB2 -1 -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -input -) -; -/ -/ -/ -assert_eq -! -( -Err -( -expected -) -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -similarly -for -the -trailing -word -boundary -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -. -. -3 -) -; -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -0xCE -3 -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -input -) -; -/ -/ -/ -assert_eq -! -( -Err -( -expected -) -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -unicode_word_boundary -( -mut -self -yes -: -bool -) -- -> -Config -{ -/ -/ -We -have -a -separate -option -for -this -instead -of -just -setting -the -/ -/ -appropriate -quit -bytes -here -because -we -don -' -t -want -to -set -quit -bytes -/ -/ -for -every -regex -. -We -only -want -to -set -them -when -the -regex -contains -a -/ -/ -Unicode -word -boundary -. -self -. -unicode_word_boundary -= -Some -( -yes -) -; -self -} -/ -/ -/ -Add -a -" -quit -" -byte -to -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -When -a -quit -byte -is -seen -during -search -time -then -search -will -return -a -/ -/ -/ -[ -MatchError -: -: -quit -] -error -indicating -the -offset -at -which -the -search -/ -/ -/ -stopped -. -/ -/ -/ -/ -/ -/ -A -quit -byte -will -always -overrule -any -other -aspects -of -a -regex -. -For -/ -/ -/ -example -if -the -x -byte -is -added -as -a -quit -byte -and -the -regex -\ -w -is -/ -/ -/ -used -then -observing -x -will -cause -the -search -to -quit -immediately -/ -/ -/ -despite -the -fact -that -x -is -in -the -\ -w -class -. -/ -/ -/ -/ -/ -/ -This -mechanism -is -primarily -useful -for -heuristically -enabling -certain -/ -/ -/ -features -like -Unicode -word -boundaries -in -a -DFA -. -Namely -if -the -input -/ -/ -/ -to -search -is -ASCII -then -a -Unicode -word -boundary -can -be -implemented -/ -/ -/ -via -an -ASCII -word -boundary -with -no -change -in -semantics -. -Thus -a -DFA -/ -/ -/ -can -attempt -to -match -a -Unicode -word -boundary -but -give -up -as -soon -as -it -/ -/ -/ -observes -a -non -- -ASCII -byte -. -Indeed -if -callers -set -all -non -- -ASCII -bytes -/ -/ -/ -to -be -quit -bytes -then -Unicode -word -boundaries -will -be -permitted -when -/ -/ -/ -building -lazy -DFAs -. -Of -course -callers -should -enable -/ -/ -/ -[ -Config -: -: -unicode_word_boundary -] -if -they -want -this -behavior -instead -. -/ -/ -/ -( -The -advantage -being -that -non -- -ASCII -quit -bytes -will -only -be -added -if -a -/ -/ -/ -Unicode -word -boundary -is -in -the -pattern -. -) -/ -/ -/ -/ -/ -/ -When -enabling -this -option -callers -_must_ -be -prepared -to -handle -a -/ -/ -/ -[ -MatchError -] -( -crate -: -: -MatchError -) -error -during -search -. -When -using -a -/ -/ -/ -[ -Regex -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -this -corresponds -to -using -the -/ -/ -/ -try_ -suite -of -methods -. -/ -/ -/ -/ -/ -/ -By -default -there -are -no -quit -bytes -set -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -heuristic -Unicode -word -boundaries -are -enabled -and -any -/ -/ -/ -non -- -ASCII -byte -is -removed -from -the -set -of -quit -bytes -. -Namely -enabling -/ -/ -/ -Unicode -word -boundaries -requires -setting -every -non -- -ASCII -byte -to -a -quit -/ -/ -/ -byte -. -So -if -the -caller -attempts -to -undo -any -of -that -then -this -will -/ -/ -/ -panic -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -cause -a -search -to -terminate -if -it -sees -a -/ -/ -/ -\ -n -byte -. -This -could -be -useful -if -for -example -you -wanted -to -prevent -/ -/ -/ -a -user -supplied -pattern -from -matching -across -a -line -boundary -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -MatchError -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -quit -( -b -' -\ -n -' -true -) -) -/ -/ -/ -. -build -( -r -" -foo -\ -p -{ -any -} -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -foo -\ -nbar -" -; -/ -/ -/ -/ -/ -Normally -this -would -produce -a -match -since -\ -p -{ -any -} -contains -' -\ -n -' -. -/ -/ -/ -/ -/ -But -since -we -instructed -the -automaton -to -enter -a -quit -state -if -a -/ -/ -/ -/ -/ -' -\ -n -' -is -observed -this -produces -a -match -error -instead -. -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -b -' -\ -n -' -3 -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -/ -/ -/ -& -mut -cache -/ -/ -/ -& -Input -: -: -new -( -haystack -) -/ -/ -/ -) -. -unwrap_err -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -quit -( -mut -self -byte -: -u8 -yes -: -bool -) -- -> -Config -{ -if -self -. -get_unicode_word_boundary -( -) -& -& -! -byte -. -is_ascii -( -) -& -& -! -yes -{ -panic -! -( -" -cannot -set -non -- -ASCII -byte -to -be -non -- -quit -when -\ -Unicode -word -boundaries -are -enabled -" -) -; -} -if -self -. -quitset -. -is_none -( -) -{ -self -. -quitset -= -Some -( -ByteSet -: -: -empty -( -) -) -; -} -if -yes -{ -self -. -quitset -. -as_mut -( -) -. -unwrap -( -) -. -add -( -byte -) -; -} -else -{ -self -. -quitset -. -as_mut -( -) -. -unwrap -( -) -. -remove -( -byte -) -; -} -self -} -/ -/ -/ -Enable -specializing -start -states -in -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -When -start -states -are -specialized -an -implementor -of -a -search -routine -/ -/ -/ -using -a -lazy -DFA -can -tell -when -the -search -has -entered -a -starting -state -. -/ -/ -/ -When -start -states -aren -' -t -specialized -then -it -is -impossible -to -know -/ -/ -/ -whether -the -search -has -entered -a -start -state -. -/ -/ -/ -/ -/ -/ -Ideally -this -option -wouldn -' -t -need -to -exist -and -we -could -always -/ -/ -/ -specialize -start -states -. -The -problem -is -that -start -states -can -be -quite -/ -/ -/ -active -. -This -in -turn -means -that -an -efficient -search -routine -is -likely -/ -/ -/ -to -ping -- -pong -between -a -heavily -optimized -hot -loop -that -handles -most -/ -/ -/ -states -and -to -a -less -optimized -specialized -handling -of -start -states -. -/ -/ -/ -This -causes -branches -to -get -heavily -mispredicted -and -overall -can -/ -/ -/ -materially -decrease -throughput -. -Therefore -specializing -start -states -/ -/ -/ -should -only -be -enabled -when -it -is -needed -. -/ -/ -/ -/ -/ -/ -Knowing -whether -a -search -is -in -a -start -state -is -typically -useful -when -a -/ -/ -/ -prefilter -is -active -for -the -search -. -A -prefilter -is -typically -only -run -/ -/ -/ -when -in -a -start -state -and -a -prefilter -can -greatly -accelerate -a -search -. -/ -/ -/ -Therefore -the -possible -cost -of -specializing -start -states -is -worth -it -/ -/ -/ -in -this -case -. -Otherwise -if -you -have -no -prefilter -there -is -likely -no -/ -/ -/ -reason -to -specialize -start -states -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -but -note -that -it -is -automatically -/ -/ -/ -enabled -( -or -disabled -) -if -[ -Config -: -: -prefilter -] -is -set -. -Namely -unless -/ -/ -/ -specialize_start_states -has -already -been -set -[ -Config -: -: -prefilter -] -/ -/ -/ -will -automatically -enable -or -disable -it -based -on -whether -a -prefilter -/ -/ -/ -is -present -or -not -respectively -. -This -is -done -because -a -prefilter -' -s -/ -/ -/ -effectiveness -is -rooted -in -being -executed -whenever -the -DFA -is -in -a -/ -/ -/ -start -state -and -that -' -s -only -possible -to -do -when -they -are -specialized -. -/ -/ -/ -/ -/ -/ -Note -that -it -is -plausibly -reasonable -to -_disable_ -this -option -/ -/ -/ -explicitly -while -_enabling_ -a -prefilter -. -In -that -case -a -prefilter -/ -/ -/ -will -still -be -run -at -the -beginning -of -a -search -but -never -again -. -This -/ -/ -/ -in -theory -could -strike -a -good -balance -if -you -' -re -in -a -situation -where -a -/ -/ -/ -prefilter -is -likely -to -produce -many -false -positive -candidates -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -enable -start -state -specialization -and -then -/ -/ -/ -shows -how -to -check -whether -a -state -is -a -start -state -or -not -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -MatchError -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -specialize_start_states -( -true -) -) -/ -/ -/ -. -build -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -sid -= -dfa -. -start_state_forward -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -/ -/ -The -ID -returned -by -' -start_state_forward -' -will -always -be -tagged -as -/ -/ -/ -/ -/ -a -start -state -when -start -state -specialization -is -enabled -. -/ -/ -/ -assert -! -( -sid -. -is_tagged -( -) -) -; -/ -/ -/ -assert -! -( -sid -. -is_start -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Compare -the -above -with -the -default -lazy -DFA -configuration -where -/ -/ -/ -start -states -are -_not_ -specialized -. -In -this -case -the -start -state -/ -/ -/ -is -not -tagged -and -sid -. -is_start -( -) -returns -false -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -MatchError -Input -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -sid -= -dfa -. -start_state_forward -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -/ -/ -Start -states -are -not -tagged -in -the -default -configuration -! -/ -/ -/ -assert -! -( -! -sid -. -is_tagged -( -) -) -; -/ -/ -/ -assert -! -( -! -sid -. -is_start -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -specialize_start_states -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -specialize_start_states -= -Some -( -yes -) -; -self -} -/ -/ -/ -Sets -the -maximum -amount -of -heap -memory -in -bytes -to -allocate -to -the -/ -/ -/ -cache -for -use -during -a -lazy -DFA -search -. -If -the -lazy -DFA -would -otherwise -/ -/ -/ -use -more -heap -memory -then -depending -on -other -configuration -knobs -/ -/ -/ -either -stop -the -search -and -return -an -error -or -clear -the -cache -and -/ -/ -/ -continue -the -search -. -/ -/ -/ -/ -/ -/ -The -default -cache -capacity -is -some -" -reasonable -" -number -that -will -/ -/ -/ -accommodate -most -regular -expressions -. -You -may -find -that -if -you -need -/ -/ -/ -to -build -a -large -DFA -then -it -may -be -necessary -to -increase -the -cache -/ -/ -/ -capacity -. -/ -/ -/ -/ -/ -/ -Note -that -while -building -a -lazy -DFA -will -do -a -" -minimum -" -check -to -ensure -/ -/ -/ -the -capacity -is -big -enough -this -is -more -or -less -about -correctness -. -/ -/ -/ -If -the -cache -is -bigger -than -the -minimum -but -still -" -too -small -" -then -the -/ -/ -/ -lazy -DFA -could -wind -up -spending -a -lot -of -time -clearing -the -cache -and -/ -/ -/ -recomputing -transitions -thus -negating -the -performance -benefits -of -a -/ -/ -/ -lazy -DFA -. -Thus -setting -the -cache -capacity -is -mostly -an -experimental -/ -/ -/ -endeavor -. -For -most -common -patterns -however -the -default -should -be -/ -/ -/ -sufficient -. -/ -/ -/ -/ -/ -/ -For -more -details -on -how -the -lazy -DFA -' -s -cache -is -used -see -the -/ -/ -/ -documentation -for -[ -Cache -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -what -happens -if -the -configured -cache -capacity -is -/ -/ -/ -too -small -. -In -such -cases -one -can -override -the -cache -capacity -to -make -/ -/ -/ -it -bigger -. -Alternatively -one -might -want -to -use -less -memory -by -setting -/ -/ -/ -a -smaller -cache -capacity -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -pattern -= -r -" -\ -p -{ -L -} -{ -1000 -} -" -; -/ -/ -/ -/ -/ -/ -/ -/ -The -default -cache -capacity -is -likely -too -small -to -deal -with -regexes -/ -/ -/ -/ -/ -that -are -very -large -. -Large -repetitions -of -large -Unicode -character -/ -/ -/ -/ -/ -classes -are -a -common -way -to -make -very -large -regexes -. -/ -/ -/ -let -_ -= -DFA -: -: -new -( -pattern -) -. -unwrap_err -( -) -; -/ -/ -/ -/ -/ -Bump -up -the -capacity -to -something -bigger -. -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -cache_capacity -( -100 -* -( -1 -< -< -20 -) -) -) -/ -/ -100 -MB -/ -/ -/ -. -build -( -pattern -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -" -. -repeat -( -50 -) -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -2000 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -cache_capacity -( -mut -self -bytes -: -usize -) -- -> -Config -{ -self -. -cache_capacity -= -Some -( -bytes -) -; -self -} -/ -/ -/ -Configures -construction -of -a -lazy -DFA -to -use -the -minimum -cache -capacity -/ -/ -/ -if -the -configured -capacity -is -otherwise -too -small -for -the -provided -NFA -. -/ -/ -/ -/ -/ -/ -This -is -useful -if -you -never -want -lazy -DFA -construction -to -fail -because -/ -/ -/ -of -a -capacity -that -is -too -small -. -/ -/ -/ -/ -/ -/ -In -general -this -option -is -typically -not -a -good -idea -. -In -particular -/ -/ -/ -while -a -minimum -cache -capacity -does -permit -the -lazy -DFA -to -function -/ -/ -/ -where -it -otherwise -couldn -' -t -it -' -s -plausible -that -it -may -not -function -/ -/ -/ -well -if -it -' -s -constantly -running -out -of -room -. -In -that -case -the -speed -/ -/ -/ -advantages -of -the -lazy -DFA -may -be -negated -. -On -the -other -hand -the -/ -/ -/ -" -minimum -" -cache -capacity -computed -may -not -be -completely -accurate -and -/ -/ -/ -could -actually -be -bigger -than -what -is -really -necessary -. -Therefore -it -/ -/ -/ -is -plausible -that -using -the -minimum -cache -capacity -could -still -result -/ -/ -/ -in -very -good -performance -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -what -happens -if -the -configured -cache -capacity -is -/ -/ -/ -too -small -. -In -such -cases -one -could -override -the -capacity -explicitly -. -/ -/ -/ -An -alternative -demonstrated -here -let -' -s -us -force -construction -to -use -/ -/ -/ -the -minimum -cache -capacity -if -the -configured -capacity -is -otherwise -/ -/ -/ -too -small -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -HalfMatch -Input -} -; -/ -/ -/ -/ -/ -/ -let -pattern -= -r -" -\ -p -{ -L -} -{ -1000 -} -" -; -/ -/ -/ -/ -/ -/ -/ -/ -The -default -cache -capacity -is -likely -too -small -to -deal -with -regexes -/ -/ -/ -/ -/ -that -are -very -large -. -Large -repetitions -of -large -Unicode -character -/ -/ -/ -/ -/ -classes -are -a -common -way -to -make -very -large -regexes -. -/ -/ -/ -let -_ -= -DFA -: -: -new -( -pattern -) -. -unwrap_err -( -) -; -/ -/ -/ -/ -/ -Configure -construction -such -it -automatically -selects -the -minimum -/ -/ -/ -/ -/ -cache -capacity -if -it -would -otherwise -be -too -small -. -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -skip_cache_capacity_check -( -true -) -) -/ -/ -/ -. -build -( -pattern -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -" -. -repeat -( -50 -) -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -2000 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -skip_cache_capacity_check -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -skip_cache_capacity_check -= -Some -( -yes -) -; -self -} -/ -/ -/ -Configure -a -lazy -DFA -search -to -quit -after -a -certain -number -of -cache -/ -/ -/ -clearings -. -/ -/ -/ -/ -/ -/ -When -a -minimum -is -set -then -a -lazy -DFA -search -will -* -possibly -* -" -give -/ -/ -/ -up -" -after -the -minimum -number -of -cache -clearings -has -occurred -. -This -is -/ -/ -/ -typically -useful -in -scenarios -where -callers -want -to -detect -whether -the -/ -/ -/ -lazy -DFA -search -is -" -efficient -" -or -not -. -If -the -cache -is -cleared -too -many -/ -/ -/ -times -this -is -a -good -indicator -that -it -is -not -efficient -and -thus -the -/ -/ -/ -caller -may -wish -to -use -some -other -regex -engine -. -/ -/ -/ -/ -/ -/ -Note -that -the -number -of -times -a -cache -is -cleared -is -a -property -of -/ -/ -/ -the -cache -itself -. -Thus -if -a -cache -is -used -in -a -subsequent -search -/ -/ -/ -with -a -similarly -configured -lazy -DFA -then -it -could -cause -the -/ -/ -/ -search -to -" -give -up -" -if -the -cache -needed -to -be -cleared -depending -/ -/ -/ -on -its -internal -count -and -configured -minimum -. -The -cache -clear -/ -/ -/ -count -can -only -be -reset -to -0 -via -[ -DFA -: -: -reset_cache -] -( -or -/ -/ -/ -[ -Regex -: -: -reset_cache -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -: -: -reset_cache -) -if -/ -/ -/ -you -' -re -using -the -Regex -API -) -. -/ -/ -/ -/ -/ -/ -By -default -no -minimum -is -configured -. -Thus -a -lazy -DFA -search -will -/ -/ -/ -never -give -up -due -to -cache -clearings -. -If -you -do -set -this -option -you -/ -/ -/ -might -consider -also -setting -[ -Config -: -: -minimum_bytes_per_state -] -in -/ -/ -/ -order -for -the -lazy -DFA -to -take -efficiency -into -account -before -giving -/ -/ -/ -up -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -uses -a -somewhat -pathological -configuration -to -demonstrate -/ -/ -/ -the -_possible_ -behavior -of -cache -clearing -and -how -it -might -result -/ -/ -/ -in -a -search -that -returns -an -error -. -/ -/ -/ -/ -/ -/ -It -is -important -to -note -that -the -precise -mechanics -of -how -and -when -/ -/ -/ -a -cache -gets -cleared -is -an -implementation -detail -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -Input -MatchError -MatchErrorKind -} -; -/ -/ -/ -/ -/ -/ -/ -/ -This -is -a -carefully -chosen -regex -. -The -idea -is -to -pick -one -/ -/ -/ -/ -/ -that -requires -some -decent -number -of -states -( -hence -the -bounded -/ -/ -/ -/ -/ -repetition -) -. -But -we -specifically -choose -to -create -a -class -with -an -/ -/ -/ -/ -/ -ASCII -letter -and -a -non -- -ASCII -letter -so -that -we -can -check -that -no -new -/ -/ -/ -/ -/ -states -are -created -once -the -cache -is -full -. -Namely -if -we -fill -up -the -/ -/ -/ -/ -/ -cache -on -a -haystack -of -' -a -' -s -then -in -order -to -match -one -' -' -a -new -/ -/ -/ -/ -/ -state -will -need -to -be -created -since -a -' -' -is -encoded -with -multiple -/ -/ -/ -/ -/ -bytes -. -Since -there -' -s -no -room -for -this -state -the -search -should -quit -/ -/ -/ -/ -/ -at -the -very -first -position -. -/ -/ -/ -let -pattern -= -r -" -[ -a -] -{ -100 -} -" -; -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -/ -/ -/ -/ -/ -Configure -it -so -that -we -have -the -minimum -cache -capacity -/ -/ -/ -/ -/ -possible -. -And -that -if -any -clearings -occur -the -search -quits -. -/ -/ -/ -DFA -: -: -config -( -) -/ -/ -/ -. -skip_cache_capacity_check -( -true -) -/ -/ -/ -. -cache_capacity -( -0 -) -/ -/ -/ -. -minimum_cache_clear_count -( -Some -( -0 -) -) -/ -/ -/ -) -/ -/ -/ -. -build -( -pattern -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Our -search -will -give -up -before -reaching -the -end -! -/ -/ -/ -let -haystack -= -" -a -" -. -repeat -( -101 -) -. -into_bytes -( -) -; -/ -/ -/ -let -result -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -; -/ -/ -/ -assert -! -( -matches -! -( -/ -/ -/ -* -result -. -unwrap_err -( -) -. -kind -( -) -/ -/ -/ -MatchErrorKind -: -: -GaveUp -{ -. -. -} -/ -/ -/ -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -that -we -know -the -cache -is -full -if -we -search -a -haystack -that -we -/ -/ -/ -/ -/ -know -will -require -creating -at -least -one -new -state -it -should -not -/ -/ -/ -/ -/ -be -able -to -make -much -progress -. -/ -/ -/ -let -haystack -= -" -" -. -repeat -( -101 -) -. -into_bytes -( -) -; -/ -/ -/ -let -result -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -; -/ -/ -/ -assert -! -( -matches -! -( -/ -/ -/ -* -result -. -unwrap_err -( -) -. -kind -( -) -/ -/ -/ -MatchErrorKind -: -: -GaveUp -{ -. -. -} -/ -/ -/ -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -If -we -reset -the -cache -then -we -should -be -able -to -create -more -states -/ -/ -/ -/ -/ -and -make -more -progress -with -searching -for -betas -. -/ -/ -/ -cache -. -reset -( -& -dfa -) -; -/ -/ -/ -let -haystack -= -" -" -. -repeat -( -101 -) -. -into_bytes -( -) -; -/ -/ -/ -let -result -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -; -/ -/ -/ -assert -! -( -matches -! -( -/ -/ -/ -* -result -. -unwrap_err -( -) -. -kind -( -) -/ -/ -/ -MatchErrorKind -: -: -GaveUp -{ -. -. -} -/ -/ -/ -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -. -. -. -switching -back -to -ASCII -still -makes -progress -since -it -just -needs -/ -/ -/ -/ -/ -to -set -transitions -on -existing -states -! -/ -/ -/ -let -haystack -= -" -a -" -. -repeat -( -101 -) -. -into_bytes -( -) -; -/ -/ -/ -let -result -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -; -/ -/ -/ -assert -! -( -matches -! -( -/ -/ -/ -* -result -. -unwrap_err -( -) -. -kind -( -) -/ -/ -/ -MatchErrorKind -: -: -GaveUp -{ -. -. -} -/ -/ -/ -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -minimum_cache_clear_count -( -mut -self -min -: -Option -< -usize -> -) -- -> -Config -{ -self -. -minimum_cache_clear_count -= -Some -( -min -) -; -self -} -/ -/ -/ -Configure -a -lazy -DFA -search -to -quit -only -when -its -efficiency -drops -/ -/ -/ -below -the -given -minimum -. -/ -/ -/ -/ -/ -/ -The -efficiency -of -the -cache -is -determined -by -the -number -of -DFA -states -/ -/ -/ -compiled -per -byte -of -haystack -searched -. -For -example -if -the -efficiency -/ -/ -/ -is -2 -then -it -means -the -lazy -DFA -is -creating -a -new -DFA -state -after -/ -/ -/ -searching -approximately -2 -bytes -in -a -haystack -. -Generally -speaking -2 -/ -/ -/ -is -quite -bad -and -it -' -s -likely -that -even -a -slower -regex -engine -like -the -/ -/ -/ -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -would -be -faster -. -/ -/ -/ -/ -/ -/ -This -has -no -effect -if -[ -Config -: -: -minimum_cache_clear_count -] -is -not -set -. -/ -/ -/ -Namely -this -option -only -kicks -in -when -the -cache -has -been -cleared -more -/ -/ -/ -than -the -minimum -number -. -If -no -minimum -is -set -then -the -cache -is -simply -/ -/ -/ -cleared -whenever -it -fills -up -and -it -is -impossible -for -the -lazy -DFA -to -/ -/ -/ -quit -due -to -ineffective -use -of -the -cache -. -/ -/ -/ -/ -/ -/ -In -general -if -one -is -setting -[ -Config -: -: -minimum_cache_clear_count -] -/ -/ -/ -then -one -should -probably -also -set -this -knob -as -well -. -The -reason -is -/ -/ -/ -that -the -absolute -number -of -times -the -cache -is -cleared -is -generally -/ -/ -/ -not -a -great -predictor -of -efficiency -. -For -example -if -a -new -DFA -state -/ -/ -/ -is -created -for -every -1 -000 -bytes -searched -then -it -wouldn -' -t -be -hard -/ -/ -/ -for -the -cache -to -get -cleared -more -than -N -times -and -then -cause -the -/ -/ -/ -lazy -DFA -to -quit -. -But -a -new -DFA -state -every -1 -000 -bytes -is -likely -quite -/ -/ -/ -good -from -a -performance -perspective -and -it -' -s -likely -that -the -lazy -/ -/ -/ -DFA -should -continue -searching -even -if -it -requires -clearing -the -cache -/ -/ -/ -occasionally -. -/ -/ -/ -/ -/ -/ -Finally -note -that -if -you -' -re -implementing -your -own -lazy -DFA -search -/ -/ -/ -routine -and -also -want -this -efficiency -check -to -work -correctly -then -/ -/ -/ -you -' -ll -need -to -use -the -following -routines -to -record -search -progress -: -/ -/ -/ -/ -/ -/ -* -Call -[ -Cache -: -: -search_start -] -at -the -beginning -of -every -search -. -/ -/ -/ -* -Call -[ -Cache -: -: -search_update -] -whenever -[ -DFA -: -: -next_state -] -is -/ -/ -/ -called -. -/ -/ -/ -* -Call -[ -Cache -: -: -search_finish -] -before -completing -a -search -. -( -It -is -/ -/ -/ -not -strictly -necessary -to -call -this -when -an -error -is -returned -as -/ -/ -/ -Cache -: -: -search_start -will -automatically -finish -the -previous -search -/ -/ -/ -for -you -. -But -calling -it -where -possible -before -returning -helps -improve -/ -/ -/ -the -accuracy -of -how -many -bytes -have -actually -been -searched -. -) -pub -fn -minimum_bytes_per_state -( -mut -self -min -: -Option -< -usize -> -) -- -> -Config -{ -self -. -minimum_bytes_per_state -= -Some -( -min -) -; -self -} -/ -/ -/ -Returns -the -match -semantics -set -in -this -configuration -. -pub -fn -get_match_kind -( -& -self -) -- -> -MatchKind -{ -self -. -match_kind -. -unwrap_or -( -MatchKind -: -: -LeftmostFirst -) -} -/ -/ -/ -Returns -the -prefilter -set -in -this -configuration -if -one -at -all -. -pub -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -self -. -pre -. -as_ref -( -) -. -unwrap_or -( -& -None -) -. -as_ref -( -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -anchored -starting -states -/ -/ -/ -for -every -pattern -in -the -DFA -. -pub -fn -get_starts_for_each_pattern -( -& -self -) -- -> -bool -{ -self -. -starts_for_each_pattern -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -byte -classes -or -not -. -/ -/ -/ -This -is -typically -a -debugging -oriented -option -as -disabling -it -confers -/ -/ -/ -no -speed -benefit -. -pub -fn -get_byte_classes -( -& -self -) -- -> -bool -{ -self -. -byte_classes -. -unwrap_or -( -true -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -heuristic -Unicode -word -/ -/ -/ -boundary -support -. -When -enabled -it -is -possible -for -a -search -to -return -/ -/ -/ -an -error -. -pub -fn -get_unicode_word_boundary -( -& -self -) -- -> -bool -{ -self -. -unicode_word_boundary -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -whether -this -configuration -will -instruct -the -lazy -DFA -to -enter -/ -/ -/ -a -quit -state -whenever -the -given -byte -is -seen -during -a -search -. -When -at -/ -/ -/ -least -one -byte -has -this -enabled -it -is -possible -for -a -search -to -return -/ -/ -/ -an -error -. -pub -fn -get_quit -( -& -self -byte -: -u8 -) -- -> -bool -{ -self -. -quitset -. -map_or -( -false -| -q -| -q -. -contains -( -byte -) -) -} -/ -/ -/ -Returns -whether -this -configuration -will -instruct -the -lazy -DFA -to -/ -/ -/ -" -specialize -" -start -states -. -When -enabled -the -lazy -DFA -will -tag -start -/ -/ -/ -states -so -that -search -routines -using -the -lazy -DFA -can -detect -when -/ -/ -/ -it -' -s -in -a -start -state -and -do -some -kind -of -optimization -( -like -run -a -/ -/ -/ -prefilter -) -. -pub -fn -get_specialize_start_states -( -& -self -) -- -> -bool -{ -self -. -specialize_start_states -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -the -cache -capacity -set -on -this -configuration -. -pub -fn -get_cache_capacity -( -& -self -) -- -> -usize -{ -self -. -cache_capacity -. -unwrap_or -( -2 -* -( -1 -< -< -20 -) -) -} -/ -/ -/ -Returns -whether -the -cache -capacity -check -should -be -skipped -. -pub -fn -get_skip_cache_capacity_check -( -& -self -) -- -> -bool -{ -self -. -skip_cache_capacity_check -. -unwrap_or -( -false -) -} -/ -/ -/ -Returns -if -set -the -minimum -number -of -times -the -cache -must -be -cleared -/ -/ -/ -before -a -lazy -DFA -search -can -give -up -. -When -no -minimum -is -set -then -a -/ -/ -/ -search -will -never -quit -and -will -always -clear -the -cache -whenever -it -/ -/ -/ -fills -up -. -pub -fn -get_minimum_cache_clear_count -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -minimum_cache_clear_count -. -unwrap_or -( -None -) -} -/ -/ -/ -Returns -if -set -the -minimum -number -of -bytes -per -state -that -need -to -be -/ -/ -/ -processed -in -order -for -the -lazy -DFA -to -keep -going -. -If -the -minimum -falls -/ -/ -/ -below -this -number -( -and -the -cache -has -been -cleared -a -minimum -number -of -/ -/ -/ -times -) -then -the -lazy -DFA -will -return -a -" -gave -up -" -error -. -pub -fn -get_minimum_bytes_per_state -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -minimum_bytes_per_state -. -unwrap_or -( -None -) -} -/ -/ -/ -Returns -the -minimum -lazy -DFA -cache -capacity -required -for -the -given -NFA -. -/ -/ -/ -/ -/ -/ -The -cache -capacity -required -for -a -particular -NFA -may -change -without -/ -/ -/ -notice -. -Callers -should -not -rely -on -it -being -stable -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -informational -purposes -but -can -also -be -useful -for -/ -/ -/ -other -reasons -. -For -example -if -one -wants -to -check -the -minimum -cache -/ -/ -/ -capacity -themselves -or -if -one -wants -to -set -the -capacity -based -on -the -/ -/ -/ -minimum -. -/ -/ -/ -/ -/ -/ -This -may -return -an -error -if -this -configuration -does -not -support -all -of -/ -/ -/ -the -instructions -used -in -the -given -NFA -. -For -example -if -the -NFA -has -a -/ -/ -/ -Unicode -word -boundary -but -this -configuration -does -not -enable -heuristic -/ -/ -/ -support -for -Unicode -word -boundaries -. -pub -fn -get_minimum_cache_capacity -( -& -self -nfa -: -& -thompson -: -: -NFA -) -- -> -Result -< -usize -BuildError -> -{ -let -quitset -= -self -. -quit_set_from_nfa -( -nfa -) -? -; -let -classes -= -self -. -byte_classes_from_nfa -( -nfa -& -quitset -) -; -let -starts -= -self -. -get_starts_for_each_pattern -( -) -; -Ok -( -minimum_cache_capacity -( -nfa -& -classes -starts -) -) -} -/ -/ -/ -Returns -the -byte -class -map -used -during -search -from -the -given -NFA -. -/ -/ -/ -/ -/ -/ -If -byte -classes -are -disabled -on -this -configuration -then -a -map -is -/ -/ -/ -returned -that -puts -each -byte -in -its -own -equivalent -class -. -fn -byte_classes_from_nfa -( -& -self -nfa -: -& -thompson -: -: -NFA -quit -: -& -ByteSet -) -- -> -ByteClasses -{ -if -! -self -. -get_byte_classes -( -) -{ -/ -/ -The -lazy -DFA -will -always -use -the -equivalence -class -map -but -/ -/ -enabling -this -option -is -useful -for -debugging -. -Namely -this -will -/ -/ -cause -all -transitions -to -be -defined -over -their -actual -bytes -/ -/ -instead -of -an -opaque -equivalence -class -identifier -. -The -former -is -/ -/ -much -easier -to -grok -as -a -human -. -ByteClasses -: -: -singletons -( -) -} -else -{ -let -mut -set -= -nfa -. -byte_class_set -( -) -. -clone -( -) -; -/ -/ -It -is -important -to -distinguish -any -" -quit -" -bytes -from -all -other -/ -/ -bytes -. -Otherwise -a -non -- -quit -byte -may -end -up -in -the -same -class -/ -/ -as -a -quit -byte -and -thus -cause -the -DFA -stop -when -it -shouldn -' -t -. -/ -/ -/ -/ -Test -case -: -/ -/ -/ -/ -regex -- -cli -find -hybrid -regex -- -w -conn -. -json -. -1000x -. -log -\ -/ -/ -' -^ -# -' -' -\ -b10 -\ -. -55 -\ -. -182 -\ -. -100 -\ -b -' -if -! -quit -. -is_empty -( -) -{ -set -. -add_set -( -& -quit -) -; -} -set -. -byte_classes -( -) -} -} -/ -/ -/ -Return -the -quit -set -for -this -configuration -and -the -given -NFA -. -/ -/ -/ -/ -/ -/ -This -may -return -an -error -if -the -NFA -is -incompatible -with -this -/ -/ -/ -configuration -' -s -quit -set -. -For -example -if -the -NFA -has -a -Unicode -word -/ -/ -/ -boundary -and -the -quit -set -doesn -' -t -include -non -- -ASCII -bytes -. -fn -quit_set_from_nfa -( -& -self -nfa -: -& -thompson -: -: -NFA -) -- -> -Result -< -ByteSet -BuildError -> -{ -let -mut -quit -= -self -. -quitset -. -unwrap_or -( -ByteSet -: -: -empty -( -) -) -; -if -nfa -. -look_set_any -( -) -. -contains_word_unicode -( -) -{ -if -self -. -get_unicode_word_boundary -( -) -{ -for -b -in -0x80 -. -. -= -0xFF -{ -quit -. -add -( -b -) -; -} -} -else -{ -/ -/ -If -heuristic -support -for -Unicode -word -boundaries -wasn -' -t -/ -/ -enabled -then -we -can -still -check -if -our -quit -set -is -correct -. -/ -/ -If -the -caller -set -their -quit -bytes -in -a -way -that -causes -the -/ -/ -DFA -to -quit -on -at -least -all -non -- -ASCII -bytes -then -that -' -s -all -/ -/ -we -need -for -heuristic -support -to -work -. -if -! -quit -. -contains_range -( -0x80 -0xFF -) -{ -return -Err -( -BuildError -: -: -unsupported_dfa_word_boundary_unicode -( -) -) -; -} -} -} -Ok -( -quit -) -} -/ -/ -/ -Overwrite -the -default -configuration -such -that -the -options -in -o -are -/ -/ -/ -always -used -. -If -an -option -in -o -is -not -set -then -the -corresponding -/ -/ -/ -option -in -self -is -used -. -If -it -' -s -not -set -in -self -either -then -it -/ -/ -/ -remains -not -set -. -fn -overwrite -( -& -self -o -: -Config -) -- -> -Config -{ -Config -{ -match_kind -: -o -. -match_kind -. -or -( -self -. -match_kind -) -pre -: -o -. -pre -. -or_else -( -| -| -self -. -pre -. -clone -( -) -) -starts_for_each_pattern -: -o -. -starts_for_each_pattern -. -or -( -self -. -starts_for_each_pattern -) -byte_classes -: -o -. -byte_classes -. -or -( -self -. -byte_classes -) -unicode_word_boundary -: -o -. -unicode_word_boundary -. -or -( -self -. -unicode_word_boundary -) -quitset -: -o -. -quitset -. -or -( -self -. -quitset -) -specialize_start_states -: -o -. -specialize_start_states -. -or -( -self -. -specialize_start_states -) -cache_capacity -: -o -. -cache_capacity -. -or -( -self -. -cache_capacity -) -skip_cache_capacity_check -: -o -. -skip_cache_capacity_check -. -or -( -self -. -skip_cache_capacity_check -) -minimum_cache_clear_count -: -o -. -minimum_cache_clear_count -. -or -( -self -. -minimum_cache_clear_count -) -minimum_bytes_per_state -: -o -. -minimum_bytes_per_state -. -or -( -self -. -minimum_bytes_per_state -) -} -} -} -/ -/ -/ -A -builder -for -constructing -a -lazy -deterministic -finite -automaton -from -/ -/ -/ -regular -expressions -. -/ -/ -/ -/ -/ -/ -As -a -convenience -[ -DFA -: -: -builder -] -is -an -alias -for -[ -Builder -: -: -new -] -. -The -/ -/ -/ -advantage -of -the -former -is -that -it -often -lets -you -avoid -importing -the -/ -/ -/ -Builder -type -directly -. -/ -/ -/ -/ -/ -/ -This -builder -provides -two -main -things -: -/ -/ -/ -/ -/ -/ -1 -. -It -provides -a -few -different -build -routines -for -actually -constructing -/ -/ -/ -a -DFA -from -different -kinds -of -inputs -. -The -most -convenient -is -/ -/ -/ -[ -Builder -: -: -build -] -which -builds -a -DFA -directly -from -a -pattern -string -. -The -/ -/ -/ -most -flexible -is -[ -Builder -: -: -build_from_nfa -] -which -builds -a -DFA -straight -/ -/ -/ -from -an -NFA -. -/ -/ -/ -2 -. -The -builder -permits -configuring -a -number -of -things -. -/ -/ -/ -[ -Builder -: -: -configure -] -is -used -with -[ -Config -] -to -configure -aspects -of -/ -/ -/ -the -DFA -and -the -construction -process -itself -. -[ -Builder -: -: -syntax -] -and -/ -/ -/ -[ -Builder -: -: -thompson -] -permit -configuring -the -regex -parser -and -Thompson -NFA -/ -/ -/ -construction -respectively -. -The -syntax -and -thompson -configurations -only -/ -/ -/ -apply -when -building -from -a -pattern -string -. -/ -/ -/ -/ -/ -/ -This -builder -always -constructs -a -* -single -* -lazy -DFA -. -As -such -this -builder -/ -/ -/ -can -only -be -used -to -construct -regexes -that -either -detect -the -presence -/ -/ -/ -of -a -match -or -find -the -end -location -of -a -match -. -A -single -DFA -cannot -/ -/ -/ -produce -both -the -start -and -end -of -a -match -. -For -that -information -use -a -/ -/ -/ -[ -Regex -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -which -can -be -similarly -configured -/ -/ -/ -using -[ -regex -: -: -Builder -] -( -crate -: -: -hybrid -: -: -regex -: -: -Builder -) -. -The -main -reason -/ -/ -/ -to -use -a -DFA -directly -is -if -the -end -location -of -a -match -is -enough -for -your -/ -/ -/ -use -case -. -Namely -a -Regex -will -construct -two -lazy -DFAs -instead -of -one -/ -/ -/ -since -a -second -reverse -DFA -is -needed -to -find -the -start -of -a -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -lazy -DFA -that -uses -a -tiny -cache -capacity -/ -/ -/ -and -completely -disables -Unicode -. -That -is -: -/ -/ -/ -/ -/ -/ -* -Things -such -as -\ -w -. -and -\ -b -are -no -longer -Unicode -- -aware -. -\ -w -/ -/ -/ -and -\ -b -are -ASCII -- -only -while -. -matches -any -byte -except -for -\ -n -/ -/ -/ -( -instead -of -any -UTF -- -8 -encoding -of -a -Unicode -scalar -value -except -for -/ -/ -/ -\ -n -) -. -Things -that -are -Unicode -only -such -as -\ -pL -are -not -allowed -. -/ -/ -/ -* -The -pattern -itself -is -permitted -to -match -invalid -UTF -- -8 -. -For -example -/ -/ -/ -things -like -[ -^ -a -] -that -match -any -byte -except -for -a -are -permitted -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -util -: -: -syntax -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -cache_capacity -( -5_000 -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -unicode -( -false -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -[ -^ -b -] -ar -. -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFar -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -10 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Builder -{ -config -: -Config -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -} -impl -Builder -{ -/ -/ -/ -Create -a -new -lazy -DFA -builder -with -the -default -configuration -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -{ -config -: -Config -: -: -default -( -) -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -: -: -new -( -) -} -} -/ -/ -/ -Build -a -lazy -DFA -from -the -given -pattern -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -or -compiling -the -pattern -then -an -error -/ -/ -/ -is -returned -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -DFA -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Build -a -lazy -DFA -from -the -given -patterns -. -/ -/ -/ -/ -/ -/ -When -matches -are -returned -the -pattern -ID -corresponds -to -the -index -of -/ -/ -/ -the -pattern -in -the -slice -given -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -DFA -BuildError -> -{ -let -nfa -= -self -. -thompson -. -clone -( -) -/ -/ -We -can -always -forcefully -disable -captures -because -DFAs -do -not -/ -/ -support -them -. -. -configure -( -thompson -: -: -Config -: -: -new -( -) -. -which_captures -( -thompson -: -: -WhichCaptures -: -: -None -) -) -. -build_many -( -patterns -) -. -map_err -( -BuildError -: -: -nfa -) -? -; -self -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Build -a -DFA -from -the -given -NFA -. -/ -/ -/ -/ -/ -/ -Note -that -this -requires -owning -a -thompson -: -: -NFA -. -While -this -may -force -/ -/ -/ -you -to -clone -the -NFA -such -a -clone -is -not -a -deep -clone -. -Namely -NFAs -/ -/ -/ -are -defined -internally -to -support -shared -ownership -such -that -cloning -is -/ -/ -/ -very -cheap -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -lazy -DFA -if -you -already -have -an -NFA -/ -/ -/ -in -hand -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -/ -/ -This -shows -how -to -set -non -- -default -options -for -building -an -NFA -. -/ -/ -/ -let -nfa -= -thompson -: -: -Compiler -: -: -new -( -) -/ -/ -/ -. -configure -( -thompson -: -: -Config -: -: -new -( -) -. -shrink -( -true -) -) -/ -/ -/ -. -build -( -r -" -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -dfa -= -DFA -: -: -builder -( -) -. -build_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -6 -) -) -; -/ -/ -/ -let -got -= -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_from_nfa -( -& -self -nfa -: -thompson -: -: -NFA -) -- -> -Result -< -DFA -BuildError -> -{ -let -quitset -= -self -. -config -. -quit_set_from_nfa -( -& -nfa -) -? -; -let -classes -= -self -. -config -. -byte_classes_from_nfa -( -& -nfa -& -quitset -) -; -/ -/ -Check -that -we -can -fit -at -least -a -few -states -into -our -cache -/ -/ -otherwise -it -' -s -pretty -senseless -to -use -the -lazy -DFA -. -This -does -have -/ -/ -a -possible -failure -mode -though -. -This -assumes -the -maximum -size -of -a -/ -/ -state -in -powerset -space -( -so -the -total -number -of -NFA -states -) -which -/ -/ -may -never -actually -materialize -and -could -be -quite -a -bit -larger -/ -/ -than -the -actual -biggest -state -. -If -this -turns -out -to -be -a -problem -/ -/ -we -could -expose -a -knob -that -disables -this -check -. -But -if -so -we -have -/ -/ -to -be -careful -not -to -panic -in -other -areas -of -the -code -( -the -cache -/ -/ -clearing -and -init -code -) -that -tend -to -assume -some -minimum -useful -/ -/ -cache -capacity -. -let -min_cache -= -minimum_cache_capacity -( -& -nfa -& -classes -self -. -config -. -get_starts_for_each_pattern -( -) -) -; -let -mut -cache_capacity -= -self -. -config -. -get_cache_capacity -( -) -; -if -cache_capacity -< -min_cache -{ -/ -/ -When -the -caller -has -asked -us -to -skip -the -cache -capacity -check -/ -/ -then -we -simply -force -the -cache -capacity -to -its -minimum -amount -/ -/ -and -mush -on -. -if -self -. -config -. -get_skip_cache_capacity_check -( -) -{ -debug -! -( -" -given -capacity -( -{ -} -) -is -too -small -\ -since -skip_cache_capacity_check -is -enabled -\ -setting -cache -capacity -to -minimum -( -{ -} -) -" -cache_capacity -min_cache -) -; -cache_capacity -= -min_cache -; -} -else -{ -return -Err -( -BuildError -: -: -insufficient_cache_capacity -( -min_cache -cache_capacity -) -) -; -} -} -/ -/ -We -also -need -to -check -that -we -can -fit -at -least -some -small -number -/ -/ -of -states -in -our -state -ID -space -. -This -is -unlikely -to -trigger -in -/ -/ -> -= -32 -- -bit -systems -but -16 -- -bit -systems -have -a -pretty -small -state -ID -/ -/ -space -since -a -number -of -bits -are -used -up -as -sentinels -. -if -let -Err -( -err -) -= -minimum_lazy_state_id -( -& -classes -) -{ -return -Err -( -BuildError -: -: -insufficient_state_id_capacity -( -err -) -) -; -} -let -stride2 -= -classes -. -stride2 -( -) -; -let -start_map -= -StartByteMap -: -: -new -( -nfa -. -look_matcher -( -) -) -; -Ok -( -DFA -{ -config -: -self -. -config -. -clone -( -) -nfa -stride2 -start_map -classes -quitset -cache_capacity -} -) -} -/ -/ -/ -Apply -the -given -lazy -DFA -configuration -options -to -this -builder -. -pub -fn -configure -( -& -mut -self -config -: -Config -) -- -> -& -mut -Builder -{ -self -. -config -= -self -. -config -. -overwrite -( -config -) -; -self -} -/ -/ -/ -Set -the -syntax -configuration -for -this -builder -using -/ -/ -/ -[ -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -case -insensitivity -Unicode -and -multi -/ -/ -/ -line -mode -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -lazy -DFA -directly -from -a -/ -/ -/ -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -syntax -( -config -) -; -self -} -/ -/ -/ -Set -the -Thompson -NFA -configuration -for -this -builder -using -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -whether -the -DFA -should -match -the -regex -/ -/ -/ -in -reverse -or -if -additional -time -should -be -spent -shrinking -the -size -of -/ -/ -/ -the -NFA -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -DFA -directly -from -a -/ -/ -/ -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -thompson -( -& -mut -self -config -: -thompson -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -configure -( -config -) -; -self -} -} -/ -/ -/ -Represents -the -current -state -of -an -overlapping -search -. -/ -/ -/ -/ -/ -/ -This -is -used -for -overlapping -searches -since -they -need -to -know -something -/ -/ -/ -about -the -previous -search -. -For -example -when -multiple -patterns -match -at -the -/ -/ -/ -same -position -this -state -tracks -the -last -reported -pattern -so -that -the -next -/ -/ -/ -search -knows -whether -to -report -another -matching -pattern -or -continue -with -/ -/ -/ -the -search -at -the -next -position -. -Additionally -it -also -tracks -which -state -/ -/ -/ -the -last -search -call -terminated -in -. -/ -/ -/ -/ -/ -/ -This -type -provides -little -introspection -capabilities -. -The -only -thing -a -/ -/ -/ -caller -can -do -is -construct -it -and -pass -it -around -to -permit -search -routines -/ -/ -/ -to -use -it -to -track -state -and -also -ask -whether -a -match -has -been -found -. -/ -/ -/ -/ -/ -/ -Callers -should -always -provide -a -fresh -state -constructed -via -/ -/ -/ -[ -OverlappingState -: -: -start -] -when -starting -a -new -search -. -Reusing -state -from -/ -/ -/ -a -previous -search -may -result -in -incorrect -results -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -OverlappingState -{ -/ -/ -/ -The -match -reported -by -the -most -recent -overlapping -search -to -use -this -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -If -a -search -does -not -find -any -matches -then -it -is -expected -to -clear -/ -/ -/ -this -value -. -pub -( -crate -) -mat -: -Option -< -HalfMatch -> -/ -/ -/ -The -state -ID -of -the -state -at -which -the -search -was -in -when -the -call -/ -/ -/ -terminated -. -When -this -is -a -match -state -last_match -must -be -set -to -a -/ -/ -/ -non -- -None -value -. -/ -/ -/ -/ -/ -/ -A -None -value -indicates -the -start -state -of -the -corresponding -/ -/ -/ -automaton -. -We -cannot -use -the -actual -ID -since -any -one -automaton -may -/ -/ -/ -have -many -start -states -and -which -one -is -in -use -depends -on -several -/ -/ -/ -search -- -time -factors -. -pub -( -crate -) -id -: -Option -< -LazyStateID -> -/ -/ -/ -The -position -of -the -search -. -/ -/ -/ -/ -/ -/ -When -id -is -None -( -i -. -e -. -we -are -starting -a -search -) -this -is -set -to -/ -/ -/ -the -beginning -of -the -search -as -given -by -the -caller -regardless -of -its -/ -/ -/ -current -value -. -Subsequent -calls -to -an -overlapping -search -pick -up -at -/ -/ -/ -this -offset -. -pub -( -crate -) -at -: -usize -/ -/ -/ -The -index -into -the -matching -patterns -of -the -next -match -to -report -if -the -/ -/ -/ -current -state -is -a -match -state -. -Note -that -this -may -be -1 -greater -than -/ -/ -/ -the -total -number -of -matches -to -report -for -the -current -match -state -. -( -In -/ -/ -/ -which -case -no -more -matches -should -be -reported -at -the -current -position -/ -/ -/ -and -the -search -should -advance -to -the -next -position -. -) -pub -( -crate -) -next_match_index -: -Option -< -usize -> -/ -/ -/ -This -is -set -to -true -when -a -reverse -overlapping -search -has -entered -its -/ -/ -/ -EOI -transitions -. -/ -/ -/ -/ -/ -/ -This -isn -' -t -used -in -a -forward -search -because -it -knows -to -stop -once -the -/ -/ -/ -position -exceeds -the -end -of -the -search -range -. -In -a -reverse -search -/ -/ -/ -since -we -use -unsigned -offsets -we -don -' -t -" -know -" -once -we -' -ve -gone -past -/ -/ -/ -0 -. -So -the -only -way -to -detect -it -is -with -this -extra -flag -. -The -reverse -/ -/ -/ -overlapping -search -knows -to -terminate -specifically -after -it -has -/ -/ -/ -reported -all -matches -after -following -the -EOI -transition -. -pub -( -crate -) -rev_eoi -: -bool -} -impl -OverlappingState -{ -/ -/ -/ -Create -a -new -overlapping -state -that -begins -at -the -start -state -of -any -/ -/ -/ -automaton -. -pub -fn -start -( -) -- -> -OverlappingState -{ -OverlappingState -{ -mat -: -None -id -: -None -at -: -0 -next_match_index -: -None -rev_eoi -: -false -} -} -/ -/ -/ -Return -the -match -result -of -the -most -recent -search -to -execute -with -this -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -A -searches -will -clear -this -result -automatically -such -that -if -no -/ -/ -/ -match -is -found -this -will -correctly -report -None -. -pub -fn -get_match -( -& -self -) -- -> -Option -< -HalfMatch -> -{ -self -. -mat -} -} -/ -/ -/ -Runs -the -given -overlapping -search -function -( -forwards -or -backwards -) -until -/ -/ -/ -a -match -is -found -whose -offset -does -not -split -a -codepoint -. -/ -/ -/ -/ -/ -/ -This -is -* -not -* -always -correct -to -call -. -It -should -only -be -called -when -the -/ -/ -/ -underlying -NFA -has -UTF -- -8 -mode -enabled -* -and -* -it -can -produce -zero -- -width -/ -/ -/ -matches -. -Calling -this -when -both -of -those -things -aren -' -t -true -might -result -/ -/ -/ -in -legitimate -matches -getting -skipped -. -# -[ -cold -] -# -[ -inline -( -never -) -] -fn -skip_empty_utf8_splits_overlapping -< -F -> -( -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -mut -search -: -F -) -- -> -Result -< -( -) -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -/ -/ -Note -that -this -routine -works -for -forwards -and -reverse -searches -/ -/ -even -though -there -' -s -no -code -here -to -handle -those -cases -. -That -' -s -/ -/ -because -overlapping -searches -drive -themselves -to -completion -via -/ -/ -OverlappingState -. -So -all -we -have -to -do -is -push -it -until -no -matches -are -/ -/ -found -. -let -mut -hm -= -match -state -. -get_match -( -) -{ -None -= -> -return -Ok -( -( -) -) -Some -( -hm -) -= -> -hm -} -; -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -if -! -input -. -is_char_boundary -( -hm -. -offset -( -) -) -{ -state -. -mat -= -None -; -} -return -Ok -( -( -) -) -; -} -while -! -input -. -is_char_boundary -( -hm -. -offset -( -) -) -{ -search -( -input -state -) -? -; -hm -= -match -state -. -get_match -( -) -{ -None -= -> -return -Ok -( -( -) -) -Some -( -hm -) -= -> -hm -} -; -} -Ok -( -( -) -) -} -/ -/ -/ -Based -on -the -minimum -number -of -states -required -for -a -useful -lazy -DFA -cache -/ -/ -/ -this -returns -the -minimum -lazy -state -ID -that -must -be -representable -. -/ -/ -/ -/ -/ -/ -It -' -s -not -likely -for -this -to -have -any -impact -32 -- -bit -systems -( -or -higher -) -but -/ -/ -/ -on -16 -- -bit -systems -the -lazy -state -ID -space -is -quite -constrained -and -thus -/ -/ -/ -may -be -insufficient -if -our -MIN_STATES -value -is -( -for -some -reason -) -too -high -. -fn -minimum_lazy_state_id -( -classes -: -& -ByteClasses -) -- -> -Result -< -LazyStateID -LazyStateIDError -> -{ -let -stride -= -1 -< -< -classes -. -stride2 -( -) -; -let -min_state_index -= -MIN_STATES -. -checked_sub -( -1 -) -. -unwrap -( -) -; -LazyStateID -: -: -new -( -min_state_index -* -stride -) -} -/ -/ -/ -Based -on -the -minimum -number -of -states -required -for -a -useful -lazy -DFA -cache -/ -/ -/ -this -returns -a -heuristic -minimum -number -of -bytes -of -heap -space -required -. -/ -/ -/ -/ -/ -/ -This -is -a -" -heuristic -" -because -the -minimum -it -returns -is -likely -bigger -than -/ -/ -/ -the -true -minimum -. -Namely -it -assumes -that -each -powerset -NFA -/ -DFA -state -uses -/ -/ -/ -the -maximum -number -of -NFA -states -( -all -of -them -) -. -This -is -likely -bigger -/ -/ -/ -than -what -is -required -in -practice -. -Computing -the -true -minimum -effectively -/ -/ -/ -requires -determinization -which -is -probably -too -much -work -to -do -for -a -/ -/ -/ -simple -check -like -this -. -/ -/ -/ -/ -/ -/ -One -of -the -issues -with -this -approach -IMO -is -that -it -requires -that -this -/ -/ -/ -be -in -sync -with -the -calculation -above -for -computing -how -much -heap -memory -/ -/ -/ -the -DFA -cache -uses -. -If -we -get -it -wrong -it -' -s -possible -for -example -for -the -/ -/ -/ -minimum -to -be -smaller -than -the -computed -heap -memory -and -thus -it -may -be -/ -/ -/ -the -case -that -we -can -' -t -add -the -required -minimum -number -of -states -. -That -in -/ -/ -/ -turn -will -make -lazy -DFA -panic -because -we -assume -that -we -can -add -at -least -a -/ -/ -/ -minimum -number -of -states -. -/ -/ -/ -/ -/ -/ -Another -approach -would -be -to -always -allow -the -minimum -number -of -states -to -/ -/ -/ -be -added -to -the -lazy -DFA -cache -even -if -it -exceeds -the -configured -cache -/ -/ -/ -limit -. -This -does -mean -that -the -limit -isn -' -t -really -a -limit -in -all -cases -/ -/ -/ -which -is -unfortunate -. -But -it -does -at -least -guarantee -that -the -lazy -DFA -can -/ -/ -/ -always -make -progress -even -if -it -is -slow -. -( -This -approach -is -very -similar -to -/ -/ -/ -enabling -the -' -skip_cache_capacity_check -' -config -knob -except -it -wouldn -' -t -/ -/ -/ -rely -on -cache -size -calculation -. -Instead -it -would -just -always -permit -a -/ -/ -/ -minimum -number -of -states -to -be -added -. -) -fn -minimum_cache_capacity -( -nfa -: -& -thompson -: -: -NFA -classes -: -& -ByteClasses -starts_for_each_pattern -: -bool -) -- -> -usize -{ -const -ID_SIZE -: -usize -= -size_of -: -: -< -LazyStateID -> -( -) -; -const -STATE_SIZE -: -usize -= -size_of -: -: -< -State -> -( -) -; -let -stride -= -1 -< -< -classes -. -stride2 -( -) -; -let -states_len -= -nfa -. -states -( -) -. -len -( -) -; -let -sparses -= -2 -* -states_len -* -NFAStateID -: -: -SIZE -; -let -trans -= -MIN_STATES -* -stride -* -ID_SIZE -; -let -mut -starts -= -Start -: -: -len -( -) -* -ID_SIZE -; -if -starts_for_each_pattern -{ -starts -+ -= -( -Start -: -: -len -( -) -* -nfa -. -pattern_len -( -) -) -* -ID_SIZE -; -} -/ -/ -The -min -number -of -states -HAS -to -be -at -least -4 -: -we -have -3 -sentinel -states -/ -/ -and -then -we -need -space -for -one -more -when -we -save -a -state -after -clearing -/ -/ -the -cache -. -We -also -need -space -for -one -more -otherwise -we -get -stuck -in -a -/ -/ -loop -where -we -try -to -add -a -5th -state -which -gets -rejected -which -clears -/ -/ -the -cache -which -adds -back -a -saved -state -( -4th -total -state -) -which -then -/ -/ -tries -to -add -the -5th -state -again -. -assert -! -( -MIN_STATES -> -= -5 -" -minimum -number -of -states -has -to -be -at -least -5 -" -) -; -/ -/ -The -minimum -number -of -non -- -sentinel -states -. -We -consider -this -separately -/ -/ -because -sentinel -states -are -much -smaller -in -that -they -contain -no -NFA -/ -/ -states -. -Given -our -aggressive -calculation -here -it -' -s -worth -being -more -/ -/ -precise -with -the -number -of -states -we -need -. -let -non_sentinel -= -MIN_STATES -. -checked_sub -( -SENTINEL_STATES -) -. -unwrap -( -) -; -/ -/ -Every -State -has -5 -bytes -for -flags -4 -bytes -( -max -) -for -the -number -of -/ -/ -patterns -followed -by -32 -- -bit -encodings -of -patterns -and -then -delta -/ -/ -varint -encodings -of -NFA -state -IDs -. -We -use -the -worst -case -( -which -isn -' -t -/ -/ -technically -possible -) -of -5 -bytes -for -each -NFA -state -ID -. -/ -/ -/ -/ -HOWEVER -three -of -the -states -needed -by -a -lazy -DFA -are -just -the -sentinel -/ -/ -unknown -dead -and -quit -states -. -Those -states -have -a -known -size -and -it -is -/ -/ -small -. -let -dead_state_size -= -State -: -: -dead -( -) -. -memory_usage -( -) -; -let -max_state_size -= -5 -+ -4 -+ -( -nfa -. -pattern_len -( -) -* -4 -) -+ -( -states_len -* -5 -) -; -let -states -= -( -SENTINEL_STATES -* -( -STATE_SIZE -+ -dead_state_size -) -) -+ -( -non_sentinel -* -( -STATE_SIZE -+ -max_state_size -) -) -; -/ -/ -NOTE -: -We -don -' -t -double -count -heap -memory -used -by -State -for -this -map -since -/ -/ -we -use -reference -counting -to -avoid -doubling -memory -usage -. -( -This -tends -to -/ -/ -be -where -most -memory -is -allocated -in -the -cache -. -) -let -states_to_sid -= -( -MIN_STATES -* -STATE_SIZE -) -+ -( -MIN_STATES -* -ID_SIZE -) -; -let -stack -= -states_len -* -NFAStateID -: -: -SIZE -; -let -scratch_state_builder -= -max_state_size -; -trans -+ -starts -+ -states -+ -states_to_sid -+ -sparses -+ -stack -+ -scratch_state_builder -} -# -[ -cfg -( -all -( -test -feature -= -" -syntax -" -) -) -] -mod -tests -{ -use -super -: -: -* -; -/ -/ -Tests -that -we -handle -heuristic -Unicode -word -boundary -support -in -reverse -/ -/ -DFAs -in -the -specific -case -of -contextual -searches -. -/ -/ -/ -/ -I -wrote -this -test -when -I -discovered -a -bug -in -how -heuristic -word -/ -/ -boundaries -were -handled -. -Namely -that -the -starting -state -selection -/ -/ -didn -' -t -consider -the -DFA -' -s -quit -byte -set -when -looking -at -the -byte -/ -/ -immediately -before -the -start -of -the -search -( -or -immediately -after -the -/ -/ -end -of -the -search -in -the -case -of -a -reverse -search -) -. -As -a -result -it -was -/ -/ -possible -for -' -\ -bfoo -\ -b -' -to -match -' -123 -' -because -the -trailing -\ -xB2 -byte -/ -/ -in -the -' -' -codepoint -would -be -treated -as -a -non -- -word -character -. -But -of -/ -/ -course -this -search -should -trigger -the -DFA -to -quit -since -there -is -a -/ -/ -non -- -ASCII -byte -in -consideration -. -/ -/ -/ -/ -Thus -I -fixed -' -start_state_ -{ -forward -reverse -} -' -to -check -the -quit -byte -set -/ -/ -if -it -wasn -' -t -empty -. -The -forward -case -is -tested -in -the -doc -test -for -the -/ -/ -Config -: -: -unicode_word_boundary -API -. -We -test -the -reverse -case -here -which -/ -/ -is -sufficiently -niche -that -it -doesn -' -t -really -belong -in -a -doc -test -. -# -[ -test -] -fn -heuristic_unicode_reverse -( -) -{ -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -unicode_word_boundary -( -true -) -) -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -. -build -( -r -" -\ -b -[ -0 -- -9 -] -+ -\ -b -" -) -. -unwrap -( -) -; -let -mut -cache -= -dfa -. -create_cache -( -) -; -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -2 -. -. -) -; -let -expected -= -MatchError -: -: -quit -( -0xB2 -1 -) -; -let -got -= -dfa -. -try_search_rev -( -& -mut -cache -& -input -) -; -assert_eq -! -( -Err -( -expected -) -got -) -; -let -input -= -Input -: -: -new -( -" -123 -" -) -. -range -( -. -. -3 -) -; -let -expected -= -MatchError -: -: -quit -( -0xCE -3 -) -; -let -got -= -dfa -. -try_search_rev -( -& -mut -cache -& -input -) -; -assert_eq -! -( -Err -( -expected -) -got -) -; -} -} diff --git a/third_party/rust/regex-automata/src/hybrid/error.rs b/third_party/rust/regex-automata/src/hybrid/error.rs deleted file mode 100644 index 8d6e0c16dae18..0000000000000 --- a/third_party/rust/regex-automata/src/hybrid/error.rs +++ /dev/null @@ -1,1092 +0,0 @@ -use -crate -: -: -{ -hybrid -: -: -id -: -: -LazyStateIDError -nfa -} -; -/ -/ -/ -An -error -that -occurs -when -initial -construction -of -a -lazy -DFA -fails -. -/ -/ -/ -/ -/ -/ -A -build -error -can -occur -when -insufficient -cache -capacity -is -configured -or -/ -/ -/ -if -something -about -the -NFA -is -unsupported -. -( -For -example -if -one -attempts -/ -/ -/ -to -build -a -lazy -DFA -without -heuristic -Unicode -support -but -with -an -NFA -that -/ -/ -/ -contains -a -Unicode -word -boundary -. -) -/ -/ -/ -/ -/ -/ -This -error -does -not -provide -many -introspection -capabilities -. -There -are -/ -/ -/ -generally -only -two -things -you -can -do -with -it -: -/ -/ -/ -/ -/ -/ -* -Obtain -a -human -readable -message -via -its -std -: -: -fmt -: -: -Display -impl -. -/ -/ -/ -* -Access -an -underlying -/ -/ -/ -[ -nfa -: -: -thompson -: -: -BuildError -] -( -crate -: -: -nfa -: -: -thompson -: -: -BuildError -) -/ -/ -/ -type -from -its -source -method -via -the -std -: -: -error -: -: -Error -trait -. -This -error -/ -/ -/ -only -occurs -when -using -convenience -routines -for -building -a -lazy -DFA -/ -/ -/ -directly -from -a -pattern -string -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -std -: -: -error -: -: -Error -/ -/ -/ -trait -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -BuildError -{ -kind -: -BuildErrorKind -} -# -[ -derive -( -Clone -Debug -) -] -enum -BuildErrorKind -{ -NFA -( -nfa -: -: -thompson -: -: -BuildError -) -InsufficientCacheCapacity -{ -minimum -: -usize -given -: -usize -} -InsufficientStateIDCapacity -{ -err -: -LazyStateIDError -} -Unsupported -( -& -' -static -str -) -} -impl -BuildError -{ -pub -( -crate -) -fn -nfa -( -err -: -nfa -: -: -thompson -: -: -BuildError -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -NFA -( -err -) -} -} -pub -( -crate -) -fn -insufficient_cache_capacity -( -minimum -: -usize -given -: -usize -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -InsufficientCacheCapacity -{ -minimum -given -} -} -} -pub -( -crate -) -fn -insufficient_state_id_capacity -( -err -: -LazyStateIDError -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -InsufficientStateIDCapacity -{ -err -} -} -} -pub -( -crate -) -fn -unsupported_dfa_word_boundary_unicode -( -) -- -> -BuildError -{ -let -msg -= -" -cannot -build -lazy -DFAs -for -regexes -with -Unicode -word -\ -boundaries -; -switch -to -ASCII -word -boundaries -or -\ -heuristically -enable -Unicode -word -boundaries -or -use -a -\ -different -regex -engine -" -; -BuildError -{ -kind -: -BuildErrorKind -: -: -Unsupported -( -msg -) -} -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -BuildError -{ -fn -source -( -& -self -) -- -> -Option -< -& -( -dyn -std -: -: -error -: -: -Error -+ -' -static -) -> -{ -match -self -. -kind -{ -BuildErrorKind -: -: -NFA -( -ref -err -) -= -> -Some -( -err -) -_ -= -> -None -} -} -} -impl -core -: -: -fmt -: -: -Display -for -BuildError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -match -self -. -kind -{ -BuildErrorKind -: -: -NFA -( -_ -) -= -> -write -! -( -f -" -error -building -NFA -" -) -BuildErrorKind -: -: -InsufficientCacheCapacity -{ -minimum -given -} -= -> -{ -write -! -( -f -" -given -cache -capacity -( -{ -} -) -is -smaller -than -\ -minimum -required -( -{ -} -) -" -given -minimum -) -} -BuildErrorKind -: -: -InsufficientStateIDCapacity -{ -ref -err -} -= -> -{ -err -. -fmt -( -f -) -} -BuildErrorKind -: -: -Unsupported -( -ref -msg -) -= -> -{ -write -! -( -f -" -unsupported -regex -feature -for -DFAs -: -{ -} -" -msg -) -} -} -} -} -/ -/ -/ -An -error -that -occurs -when -cache -usage -has -become -inefficient -. -/ -/ -/ -/ -/ -/ -One -of -the -weaknesses -of -a -lazy -DFA -is -that -it -may -need -to -clear -its -/ -/ -/ -cache -repeatedly -if -it -' -s -not -big -enough -. -If -this -happens -too -much -then -it -/ -/ -/ -can -slow -searching -down -significantly -. -A -mitigation -to -this -is -to -use -/ -/ -/ -heuristics -to -detect -whether -the -cache -is -being -used -efficiently -or -not -. -/ -/ -/ -If -not -then -a -lazy -DFA -can -return -a -CacheError -. -/ -/ -/ -/ -/ -/ -The -default -configuration -of -a -lazy -DFA -in -this -crate -is -/ -/ -/ -set -such -that -a -CacheError -will -never -occur -. -Instead -/ -/ -/ -callers -must -opt -into -this -behavior -with -settings -like -/ -/ -/ -[ -dfa -: -: -Config -: -: -minimum_cache_clear_count -] -( -crate -: -: -hybrid -: -: -dfa -: -: -Config -: -: -minimum_cache_clear_count -) -/ -/ -/ -and -/ -/ -/ -[ -dfa -: -: -Config -: -: -minimum_bytes_per_state -] -( -crate -: -: -hybrid -: -: -dfa -: -: -Config -: -: -minimum_bytes_per_state -) -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -std -: -: -error -: -: -Error -/ -/ -/ -trait -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -CacheError -( -( -) -) -; -impl -CacheError -{ -pub -( -crate -) -fn -too_many_cache_clears -( -) -- -> -CacheError -{ -CacheError -( -( -) -) -} -pub -( -crate -) -fn -bad_efficiency -( -) -- -> -CacheError -{ -CacheError -( -( -) -) -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -CacheError -{ -fn -source -( -& -self -) -- -> -Option -< -& -( -dyn -std -: -: -error -: -: -Error -+ -' -static -) -> -{ -None -} -} -impl -core -: -: -fmt -: -: -Display -for -CacheError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -lazy -DFA -cache -has -been -cleared -too -many -times -" -) -} -} diff --git a/third_party/rust/regex-automata/src/hybrid/id.rs b/third_party/rust/regex-automata/src/hybrid/id.rs deleted file mode 100644 index ab023b82b4192..0000000000000 --- a/third_party/rust/regex-automata/src/hybrid/id.rs +++ /dev/null @@ -1,3706 +0,0 @@ -/ -/ -/ -A -state -identifier -specifically -tailored -for -lazy -DFAs -. -/ -/ -/ -/ -/ -/ -A -lazy -state -ID -logically -represents -a -pointer -to -a -DFA -state -. -In -practice -/ -/ -/ -by -limiting -the -number -of -DFA -states -it -can -address -it -reserves -some -/ -/ -/ -bits -of -its -representation -to -encode -some -additional -information -. -That -/ -/ -/ -additional -information -is -called -a -" -tag -. -" -That -tag -is -used -to -record -/ -/ -/ -whether -the -state -it -points -to -is -an -unknown -dead -quit -start -or -match -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -When -implementing -a -low -level -search -routine -with -a -lazy -DFA -it -is -/ -/ -/ -necessary -to -query -the -type -of -the -current -state -to -know -what -to -do -: -/ -/ -/ -/ -/ -/ -* -* -* -Unknown -* -* -- -The -state -has -not -yet -been -computed -. -The -/ -/ -/ -parameters -used -to -get -this -state -ID -must -be -re -- -passed -to -/ -/ -/ -[ -DFA -: -: -next_state -] -( -crate -: -: -hybrid -: -: -dfa -: -: -DFA -: -: -next_state -) -which -will -never -/ -/ -/ -return -an -unknown -state -ID -. -/ -/ -/ -* -* -* -Dead -* -* -- -A -dead -state -only -has -transitions -to -itself -. -It -indicates -that -/ -/ -/ -the -search -cannot -do -anything -else -and -should -stop -with -whatever -result -it -/ -/ -/ -has -. -/ -/ -/ -* -* -* -Quit -* -* -- -A -quit -state -indicates -that -the -automaton -could -not -answer -/ -/ -/ -whether -a -match -exists -or -not -. -Correct -search -implementations -must -return -a -/ -/ -/ -[ -MatchError -: -: -quit -] -( -crate -: -: -MatchError -: -: -quit -) -when -a -DFA -enters -a -quit -/ -/ -/ -state -. -/ -/ -/ -* -* -* -Start -* -* -- -A -start -state -is -a -state -in -which -a -search -can -begin -. -/ -/ -/ -Lazy -DFAs -usually -have -more -than -one -start -state -. -Branching -on -/ -/ -/ -this -isn -' -t -required -for -correctness -but -a -common -optimization -is -/ -/ -/ -to -run -a -prefilter -when -a -search -enters -a -start -state -. -Note -that -/ -/ -/ -start -states -are -* -not -* -tagged -automatically -and -one -must -enable -the -/ -/ -/ -[ -Config -: -: -specialize_start_states -] -( -crate -: -: -hybrid -: -: -dfa -: -: -Config -: -: -specialize_start_states -) -/ -/ -/ -setting -for -start -states -to -be -tagged -. -The -reason -for -this -is -/ -/ -/ -that -a -DFA -search -loop -is -usually -written -to -execute -a -prefilter -once -it -/ -/ -/ -enters -a -start -state -. -But -if -there -is -no -prefilter -this -handling -can -be -/ -/ -/ -quite -diastrous -as -the -DFA -may -ping -- -pong -between -the -special -handling -code -/ -/ -/ -and -a -possible -optimized -hot -path -for -handling -untagged -states -. -When -start -/ -/ -/ -states -aren -' -t -specialized -then -they -are -untagged -and -remain -in -the -hot -/ -/ -/ -path -. -/ -/ -/ -* -* -* -Match -* -* -- -A -match -state -indicates -that -a -match -has -been -found -. -/ -/ -/ -Depending -on -the -semantics -of -your -search -implementation -it -may -either -/ -/ -/ -continue -until -the -end -of -the -haystack -or -a -dead -state -or -it -might -quit -/ -/ -/ -and -return -the -match -immediately -. -/ -/ -/ -/ -/ -/ -As -an -optimization -the -[ -is_tagged -] -( -LazyStateID -: -: -is_tagged -) -predicate -/ -/ -/ -can -be -used -to -determine -if -a -tag -exists -at -all -. -This -is -useful -to -avoid -/ -/ -/ -branching -on -all -of -the -above -types -for -every -byte -searched -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -LazyStateID -can -be -used -to -implement -a -correct -/ -/ -/ -search -routine -with -minimal -branching -. -In -particular -this -search -routine -/ -/ -/ -implements -" -leftmost -" -matching -which -means -that -it -doesn -' -t -immediately -/ -/ -/ -stop -once -a -match -is -found -. -Instead -it -continues -until -it -reaches -a -dead -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -Notice -also -how -a -correct -search -implementation -deals -with -/ -/ -/ -[ -CacheError -] -( -crate -: -: -hybrid -: -: -CacheError -) -s -returned -by -some -of -/ -/ -/ -the -lazy -DFA -routines -. -When -a -CacheError -occurs -it -returns -/ -/ -/ -[ -MatchError -: -: -gave_up -] -( -crate -: -: -MatchError -: -: -gave_up -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -{ -Cache -DFA -} -/ -/ -/ -HalfMatch -MatchError -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -fn -find_leftmost_first -( -/ -/ -/ -dfa -: -& -DFA -/ -/ -/ -cache -: -& -mut -Cache -/ -/ -/ -haystack -: -& -[ -u8 -] -/ -/ -/ -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -/ -/ -/ -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -/ -/ -/ -initial -bytes -of -the -haystack -. -Note -that -start -states -can -never -/ -/ -/ -/ -/ -be -match -states -( -since -DFAs -in -this -crate -delay -matches -by -1 -/ -/ -/ -/ -/ -byte -) -so -we -don -' -t -need -to -check -if -the -start -state -is -a -match -. -/ -/ -/ -let -mut -sid -= -dfa -. -start_state_forward -( -/ -/ -/ -cache -/ -/ -/ -& -Input -: -: -new -( -haystack -) -/ -/ -/ -) -? -; -/ -/ -/ -let -mut -last_match -= -None -; -/ -/ -/ -/ -/ -Walk -all -the -bytes -in -the -haystack -. -We -can -quit -early -if -we -see -/ -/ -/ -/ -/ -a -dead -or -a -quit -state -. -The -former -means -the -automaton -will -/ -/ -/ -/ -/ -never -transition -to -any -other -state -. -The -latter -means -that -the -/ -/ -/ -/ -/ -automaton -entered -a -condition -in -which -its -search -failed -. -/ -/ -/ -for -( -i -& -b -) -in -haystack -. -iter -( -) -. -enumerate -( -) -{ -/ -/ -/ -sid -= -dfa -/ -/ -/ -. -next_state -( -cache -sid -b -) -/ -/ -/ -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -i -) -) -? -; -/ -/ -/ -if -sid -. -is_tagged -( -) -{ -/ -/ -/ -if -sid -. -is_match -( -) -{ -/ -/ -/ -last_match -= -Some -( -HalfMatch -: -: -new -( -/ -/ -/ -dfa -. -match_pattern -( -cache -sid -0 -) -/ -/ -/ -i -/ -/ -/ -) -) -; -/ -/ -/ -} -else -if -sid -. -is_dead -( -) -{ -/ -/ -/ -return -Ok -( -last_match -) -; -/ -/ -/ -} -else -if -sid -. -is_quit -( -) -{ -/ -/ -/ -/ -/ -It -is -possible -to -enter -into -a -quit -state -after -/ -/ -/ -/ -/ -observing -a -match -has -occurred -. -In -that -case -we -/ -/ -/ -/ -/ -should -return -the -match -instead -of -an -error -. -/ -/ -/ -if -last_match -. -is_some -( -) -{ -/ -/ -/ -return -Ok -( -last_match -) -; -/ -/ -/ -} -/ -/ -/ -return -Err -( -MatchError -: -: -quit -( -b -i -) -) -; -/ -/ -/ -} -/ -/ -/ -/ -/ -Implementors -may -also -want -to -check -for -start -states -and -/ -/ -/ -/ -/ -handle -them -differently -for -performance -reasons -. -But -it -is -/ -/ -/ -/ -/ -not -necessary -for -correctness -. -Note -that -in -order -to -check -/ -/ -/ -/ -/ -for -start -states -you -' -ll -need -to -enable -the -/ -/ -/ -/ -/ -' -specialize_start_states -' -config -knob -otherwise -start -/ -/ -/ -/ -/ -states -will -not -be -tagged -. -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -Matches -are -always -delayed -by -1 -byte -so -we -must -explicitly -walk -/ -/ -/ -/ -/ -the -special -" -EOI -" -transition -at -the -end -of -the -search -. -/ -/ -/ -sid -= -dfa -/ -/ -/ -. -next_eoi_state -( -cache -sid -) -/ -/ -/ -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -haystack -. -len -( -) -) -) -? -; -/ -/ -/ -if -sid -. -is_match -( -) -{ -/ -/ -/ -last_match -= -Some -( -HalfMatch -: -: -new -( -/ -/ -/ -dfa -. -match_pattern -( -cache -sid -0 -) -/ -/ -/ -haystack -. -len -( -) -/ -/ -/ -) -) -; -/ -/ -/ -} -/ -/ -/ -Ok -( -last_match -) -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -We -use -a -greedy -' -+ -' -operator -to -show -how -the -search -doesn -' -t -just -stop -/ -/ -/ -/ -/ -once -a -match -is -detected -. -It -continues -extending -the -match -. -Using -/ -/ -/ -/ -/ -' -[ -a -- -z -] -+ -? -' -would -also -work -as -expected -and -stop -the -search -early -. -/ -/ -/ -/ -/ -Greediness -is -built -into -the -automaton -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -mat -= -find_leftmost_first -( -& -dfa -& -mut -cache -haystack -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -10 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Here -' -s -another -example -that -tests -our -handling -of -the -special -/ -/ -/ -/ -/ -EOI -transition -. -This -will -fail -to -find -a -match -if -we -don -' -t -call -/ -/ -/ -/ -/ -' -next_eoi_state -' -at -the -end -of -the -search -since -the -match -isn -' -t -found -/ -/ -/ -/ -/ -until -the -final -byte -in -the -haystack -. -/ -/ -/ -let -dfa -= -DFA -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -" -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -mat -= -find_leftmost_first -( -& -dfa -& -mut -cache -haystack -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -15 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -note -that -our -search -implementation -above -automatically -works -/ -/ -/ -/ -/ -with -multi -- -DFAs -. -Namely -dfa -. -match_pattern -( -match_state -0 -) -selects -/ -/ -/ -/ -/ -the -appropriate -pattern -ID -for -us -. -/ -/ -/ -let -dfa -= -DFA -: -: -new_many -( -& -[ -r -" -[ -a -- -z -] -+ -" -r -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -dfa -. -create_cache -( -) -; -/ -/ -/ -let -haystack -= -" -123 -foobar -4567 -" -. -as_bytes -( -) -; -/ -/ -/ -let -mat -= -find_leftmost_first -( -& -dfa -& -mut -cache -haystack -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -1 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -3 -) -; -/ -/ -/ -let -mat -= -find_leftmost_first -( -& -dfa -& -mut -cache -& -haystack -[ -3 -. -. -] -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -0 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -7 -) -; -/ -/ -/ -let -mat -= -find_leftmost_first -( -& -dfa -& -mut -cache -& -haystack -[ -10 -. -. -] -) -? -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -mat -. -pattern -( -) -. -as_usize -( -) -1 -) -; -/ -/ -/ -assert_eq -! -( -mat -. -offset -( -) -5 -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Copy -Debug -Default -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -pub -struct -LazyStateID -( -u32 -) -; -impl -LazyStateID -{ -# -[ -cfg -( -any -( -target_pointer_width -= -" -32 -" -target_pointer_width -= -" -64 -" -) -) -] -const -MAX_BIT -: -usize -= -31 -; -# -[ -cfg -( -target_pointer_width -= -" -16 -" -) -] -const -MAX_BIT -: -usize -= -15 -; -const -MASK_UNKNOWN -: -usize -= -1 -< -< -( -LazyStateID -: -: -MAX_BIT -) -; -const -MASK_DEAD -: -usize -= -1 -< -< -( -LazyStateID -: -: -MAX_BIT -- -1 -) -; -const -MASK_QUIT -: -usize -= -1 -< -< -( -LazyStateID -: -: -MAX_BIT -- -2 -) -; -const -MASK_START -: -usize -= -1 -< -< -( -LazyStateID -: -: -MAX_BIT -- -3 -) -; -const -MASK_MATCH -: -usize -= -1 -< -< -( -LazyStateID -: -: -MAX_BIT -- -4 -) -; -const -MAX -: -usize -= -LazyStateID -: -: -MASK_MATCH -- -1 -; -/ -/ -/ -Create -a -new -lazy -state -ID -. -/ -/ -/ -/ -/ -/ -If -the -given -identifier -exceeds -[ -LazyStateID -: -: -MAX -] -then -this -returns -/ -/ -/ -an -error -. -# -[ -inline -] -pub -( -crate -) -fn -new -( -id -: -usize -) -- -> -Result -< -LazyStateID -LazyStateIDError -> -{ -if -id -> -LazyStateID -: -: -MAX -{ -let -attempted -= -u64 -: -: -try_from -( -id -) -. -unwrap -( -) -; -return -Err -( -LazyStateIDError -{ -attempted -} -) -; -} -Ok -( -LazyStateID -: -: -new_unchecked -( -id -) -) -} -/ -/ -/ -Create -a -new -lazy -state -ID -without -checking -whether -the -given -value -/ -/ -/ -exceeds -[ -LazyStateID -: -: -MAX -] -. -/ -/ -/ -/ -/ -/ -While -this -is -unchecked -providing -an -incorrect -value -must -never -/ -/ -/ -sacrifice -memory -safety -. -# -[ -inline -] -const -fn -new_unchecked -( -id -: -usize -) -- -> -LazyStateID -{ -/ -/ -FIXME -: -Use -as_u32 -( -) -once -const -functions -in -traits -are -stable -. -LazyStateID -( -id -as -u32 -) -} -/ -/ -/ -Return -this -lazy -state -ID -as -an -untagged -usize -. -/ -/ -/ -/ -/ -/ -If -this -lazy -state -ID -is -tagged -then -the -usize -returned -is -the -state -/ -/ -/ -ID -without -the -tag -. -If -the -ID -was -not -tagged -then -the -usize -returned -/ -/ -/ -is -equivalent -to -the -state -ID -. -# -[ -inline -] -pub -( -crate -) -fn -as_usize_untagged -( -& -self -) -- -> -usize -{ -self -. -as_usize_unchecked -( -) -& -LazyStateID -: -: -MAX -} -/ -/ -/ -Return -this -lazy -state -ID -as -its -raw -internal -usize -value -which -may -/ -/ -/ -be -tagged -( -and -thus -greater -than -LazyStateID -: -: -MAX -) -. -# -[ -inline -] -pub -( -crate -) -const -fn -as_usize_unchecked -( -& -self -) -- -> -usize -{ -/ -/ -FIXME -: -Use -as_usize -( -) -once -const -functions -in -traits -are -stable -. -self -. -0 -as -usize -} -# -[ -inline -] -pub -( -crate -) -const -fn -to_unknown -( -& -self -) -- -> -LazyStateID -{ -LazyStateID -: -: -new_unchecked -( -self -. -as_usize_unchecked -( -) -| -LazyStateID -: -: -MASK_UNKNOWN -) -} -# -[ -inline -] -pub -( -crate -) -const -fn -to_dead -( -& -self -) -- -> -LazyStateID -{ -LazyStateID -: -: -new_unchecked -( -self -. -as_usize_unchecked -( -) -| -LazyStateID -: -: -MASK_DEAD -) -} -# -[ -inline -] -pub -( -crate -) -const -fn -to_quit -( -& -self -) -- -> -LazyStateID -{ -LazyStateID -: -: -new_unchecked -( -self -. -as_usize_unchecked -( -) -| -LazyStateID -: -: -MASK_QUIT -) -} -/ -/ -/ -Return -this -lazy -state -ID -as -a -state -ID -that -is -tagged -as -a -start -/ -/ -/ -state -. -# -[ -inline -] -pub -( -crate -) -const -fn -to_start -( -& -self -) -- -> -LazyStateID -{ -LazyStateID -: -: -new_unchecked -( -self -. -as_usize_unchecked -( -) -| -LazyStateID -: -: -MASK_START -) -} -/ -/ -/ -Return -this -lazy -state -ID -as -a -lazy -state -ID -that -is -tagged -as -a -match -/ -/ -/ -state -. -# -[ -inline -] -pub -( -crate -) -const -fn -to_match -( -& -self -) -- -> -LazyStateID -{ -LazyStateID -: -: -new_unchecked -( -self -. -as_usize_unchecked -( -) -| -LazyStateID -: -: -MASK_MATCH -) -} -/ -/ -/ -Return -true -if -and -only -if -this -lazy -state -ID -is -tagged -. -/ -/ -/ -/ -/ -/ -When -a -lazy -state -ID -is -tagged -then -one -can -conclude -that -it -is -one -/ -/ -/ -of -a -match -start -dead -quit -or -unknown -state -. -# -[ -inline -] -pub -const -fn -is_tagged -( -& -self -) -- -> -bool -{ -self -. -as_usize_unchecked -( -) -> -LazyStateID -: -: -MAX -} -/ -/ -/ -Return -true -if -and -only -if -this -represents -a -lazy -state -ID -that -is -/ -/ -/ -" -unknown -. -" -That -is -the -state -has -not -yet -been -created -. -When -a -caller -/ -/ -/ -sees -this -state -ID -it -generally -means -that -a -state -has -to -be -computed -/ -/ -/ -in -order -to -proceed -. -# -[ -inline -] -pub -const -fn -is_unknown -( -& -self -) -- -> -bool -{ -self -. -as_usize_unchecked -( -) -& -LazyStateID -: -: -MASK_UNKNOWN -> -0 -} -/ -/ -/ -Return -true -if -and -only -if -this -represents -a -dead -state -. -A -dead -state -/ -/ -/ -is -a -state -that -can -never -transition -to -any -other -state -except -the -/ -/ -/ -dead -state -. -When -a -dead -state -is -seen -it -generally -indicates -that -a -/ -/ -/ -search -should -stop -. -# -[ -inline -] -pub -const -fn -is_dead -( -& -self -) -- -> -bool -{ -self -. -as_usize_unchecked -( -) -& -LazyStateID -: -: -MASK_DEAD -> -0 -} -/ -/ -/ -Return -true -if -and -only -if -this -represents -a -quit -state -. -A -quit -state -/ -/ -/ -is -a -state -that -is -representationally -equivalent -to -a -dead -state -/ -/ -/ -except -it -indicates -the -automaton -has -reached -a -point -at -which -it -can -/ -/ -/ -no -longer -determine -whether -a -match -exists -or -not -. -In -general -this -/ -/ -/ -indicates -an -error -during -search -and -the -caller -must -either -pass -this -/ -/ -/ -error -up -or -use -a -different -search -technique -. -# -[ -inline -] -pub -const -fn -is_quit -( -& -self -) -- -> -bool -{ -self -. -as_usize_unchecked -( -) -& -LazyStateID -: -: -MASK_QUIT -> -0 -} -/ -/ -/ -Return -true -if -and -only -if -this -lazy -state -ID -has -been -tagged -as -a -/ -/ -/ -start -state -. -/ -/ -/ -/ -/ -/ -Note -that -if -/ -/ -/ -[ -Config -: -: -specialize_start_states -] -( -crate -: -: -hybrid -: -: -dfa -: -: -Config -) -is -/ -/ -/ -disabled -( -which -is -the -default -) -then -this -will -always -return -false -/ -/ -/ -since -start -states -won -' -t -be -tagged -. -# -[ -inline -] -pub -const -fn -is_start -( -& -self -) -- -> -bool -{ -self -. -as_usize_unchecked -( -) -& -LazyStateID -: -: -MASK_START -> -0 -} -/ -/ -/ -Return -true -if -and -only -if -this -lazy -state -ID -has -been -tagged -as -a -/ -/ -/ -match -state -. -# -[ -inline -] -pub -const -fn -is_match -( -& -self -) -- -> -bool -{ -self -. -as_usize_unchecked -( -) -& -LazyStateID -: -: -MASK_MATCH -> -0 -} -} -/ -/ -/ -This -error -occurs -when -a -lazy -state -ID -could -not -be -constructed -. -/ -/ -/ -/ -/ -/ -This -occurs -when -given -an -integer -exceeding -the -maximum -lazy -state -ID -/ -/ -/ -value -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -Error -trait -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -( -crate -) -struct -LazyStateIDError -{ -attempted -: -u64 -} -impl -LazyStateIDError -{ -/ -/ -/ -Returns -the -value -that -failed -to -constructed -a -lazy -state -ID -. -pub -( -crate -) -fn -attempted -( -& -self -) -- -> -u64 -{ -self -. -attempted -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -LazyStateIDError -{ -} -impl -core -: -: -fmt -: -: -Display -for -LazyStateIDError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -failed -to -create -LazyStateID -from -{ -: -? -} -which -exceeds -{ -: -? -} -" -self -. -attempted -( -) -LazyStateID -: -: -MAX -) -} -} diff --git a/third_party/rust/regex-automata/src/hybrid/mod.rs b/third_party/rust/regex-automata/src/hybrid/mod.rs deleted file mode 100644 index 1d2f0b225498b..0000000000000 --- a/third_party/rust/regex-automata/src/hybrid/mod.rs +++ /dev/null @@ -1,1386 +0,0 @@ -/ -* -! -A -module -for -building -and -searching -with -lazy -deterministic -finite -automata -( -DFAs -) -. -Like -other -modules -in -this -crate -lazy -DFAs -support -a -rich -regex -syntax -with -Unicode -features -. -The -key -feature -of -a -lazy -DFA -is -that -it -builds -itself -incrementally -during -search -and -never -uses -more -than -a -configured -capacity -of -memory -. -Thus -when -searching -with -a -lazy -DFA -one -must -supply -a -mutable -" -cache -" -in -which -the -actual -DFA -' -s -transition -table -is -stored -. -If -you -' -re -looking -for -fully -compiled -DFAs -then -please -see -the -top -- -level -[ -dfa -module -] -( -crate -: -: -dfa -) -. -# -Overview -This -section -gives -a -brief -overview -of -the -primary -types -in -this -module -: -* -A -[ -regex -: -: -Regex -] -provides -a -way -to -search -for -matches -of -a -regular -expression -using -lazy -DFAs -. -This -includes -iterating -over -matches -with -both -the -start -and -end -positions -of -each -match -. -* -A -[ -dfa -: -: -DFA -] -provides -direct -low -level -access -to -a -lazy -DFA -. -# -Example -: -basic -regex -searching -This -example -shows -how -to -compile -a -regex -using -the -default -configuration -and -then -use -it -to -find -matches -in -a -byte -string -: -use -regex_automata -: -: -{ -hybrid -: -: -regex -: -: -Regex -Match -} -; -let -re -= -Regex -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -? -; -let -mut -cache -= -re -. -create_cache -( -) -; -let -haystack -= -" -2018 -- -12 -- -24 -2016 -- -10 -- -08 -" -; -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -& -mut -cache -haystack -) -. -collect -( -) -; -assert_eq -! -( -matches -vec -! -[ -Match -: -: -must -( -0 -0 -. -. -10 -) -Match -: -: -must -( -0 -11 -. -. -21 -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -Example -: -searching -with -multiple -regexes -The -lazy -DFAs -in -this -module -all -fully -support -searching -with -multiple -regexes -simultaneously -. -You -can -use -this -support -with -standard -leftmost -- -first -style -searching -to -find -non -- -overlapping -matches -: -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -use -regex_automata -: -: -{ -hybrid -: -: -regex -: -: -Regex -Match -} -; -let -re -= -Regex -: -: -new_many -( -& -[ -r -" -\ -w -+ -" -r -" -\ -S -+ -" -] -) -? -; -let -mut -cache -= -re -. -create_cache -( -) -; -let -haystack -= -" -foo -bar -" -; -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -& -mut -cache -haystack -) -. -collect -( -) -; -assert_eq -! -( -matches -vec -! -[ -Match -: -: -must -( -1 -0 -. -. -4 -) -Match -: -: -must -( -0 -5 -. -. -8 -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -When -should -I -use -this -? -Generally -speaking -if -you -can -abide -the -use -of -mutable -state -during -search -and -you -don -' -t -need -things -like -capturing -groups -or -Unicode -word -boundary -support -in -non -- -ASCII -text -then -a -lazy -DFA -is -likely -a -robust -choice -with -respect -to -both -search -speed -and -memory -usage -. -Note -however -that -its -speed -may -be -worse -than -a -general -purpose -regex -engine -if -you -don -' -t -select -a -good -[ -prefilter -] -( -crate -: -: -util -: -: -prefilter -) -. -If -you -know -ahead -of -time -that -your -pattern -would -result -in -a -very -large -DFA -if -it -was -fully -compiled -it -may -be -better -to -use -an -NFA -simulation -instead -of -a -lazy -DFA -. -Either -that -or -increase -the -cache -capacity -of -your -lazy -DFA -to -something -that -is -big -enough -to -hold -the -state -machine -( -likely -through -experimentation -) -. -The -issue -here -is -that -if -the -cache -is -too -small -then -it -could -wind -up -being -reset -too -frequently -and -this -might -decrease -searching -speed -significantly -. -# -Differences -with -fully -compiled -DFAs -A -[ -hybrid -: -: -regex -: -: -Regex -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -and -a -[ -dfa -: -: -regex -: -: -Regex -] -( -crate -: -: -dfa -: -: -regex -: -: -Regex -) -both -have -the -same -capabilities -( -and -similarly -for -their -underlying -DFAs -) -but -they -achieve -them -through -different -means -. -The -main -difference -is -that -a -hybrid -or -" -lazy -" -regex -builds -its -DFA -lazily -during -search -where -as -a -fully -compiled -regex -will -build -its -DFA -at -construction -time -. -While -building -a -DFA -at -search -time -might -sound -like -it -' -s -slow -it -tends -to -work -out -where -most -bytes -seen -during -a -search -will -reuse -pre -- -built -parts -of -the -DFA -and -thus -can -be -almost -as -fast -as -a -fully -compiled -DFA -. -The -main -downside -is -that -searching -requires -mutable -space -to -store -the -DFA -and -in -the -worst -case -a -search -can -result -in -a -new -state -being -created -for -each -byte -seen -which -would -make -searching -quite -a -bit -slower -. -A -fully -compiled -DFA -never -has -to -worry -about -searches -being -slower -once -it -' -s -built -. -( -Aside -from -say -the -transition -table -being -so -large -that -it -is -subject -to -harsh -CPU -cache -effects -. -) -However -of -course -building -a -full -DFA -can -be -quite -time -consuming -and -memory -hungry -. -Particularly -when -large -Unicode -character -classes -are -used -which -tend -to -translate -into -very -large -DFAs -. -A -lazy -DFA -strikes -a -nice -balance -_in -practice_ -particularly -in -the -presence -of -Unicode -mode -by -only -building -what -is -needed -. -It -avoids -the -worst -case -exponential -time -complexity -of -DFA -compilation -by -guaranteeing -that -it -will -only -build -at -most -one -state -per -byte -searched -. -While -the -worst -case -here -can -lead -to -a -very -high -constant -it -will -never -be -exponential -. -# -Syntax -This -module -supports -the -same -syntax -as -the -regex -crate -since -they -share -the -same -parser -. -You -can -find -an -exhaustive -list -of -supported -syntax -in -the -[ -documentation -for -the -regex -crate -] -( -https -: -/ -/ -docs -. -rs -/ -regex -/ -1 -/ -regex -/ -# -syntax -) -. -There -are -two -things -that -are -not -supported -by -the -lazy -DFAs -in -this -module -: -* -Capturing -groups -. -The -DFAs -( -and -[ -Regex -] -( -regex -: -: -Regex -) -es -built -on -top -of -them -) -can -only -find -the -offsets -of -an -entire -match -but -cannot -resolve -the -offsets -of -each -capturing -group -. -This -is -because -DFAs -do -not -have -the -expressive -power -necessary -. -Note -that -it -is -okay -to -build -a -lazy -DFA -from -an -NFA -that -contains -capture -groups -. -The -capture -groups -will -simply -be -ignored -. -* -Unicode -word -boundaries -. -These -present -particularly -difficult -challenges -for -DFA -construction -and -would -result -in -an -explosion -in -the -number -of -states -. -One -can -enable -[ -dfa -: -: -Config -: -: -unicode_word_boundary -] -though -which -provides -heuristic -support -for -Unicode -word -boundaries -that -only -works -on -ASCII -text -. -Otherwise -one -can -use -( -? -- -u -: -\ -b -) -for -an -ASCII -word -boundary -which -will -work -on -any -input -. -There -are -no -plans -to -lift -either -of -these -limitations -. -Note -that -these -restrictions -are -identical -to -the -restrictions -on -fully -compiled -DFAs -. -* -/ -pub -use -self -: -: -{ -error -: -: -{ -BuildError -CacheError -} -id -: -: -LazyStateID -} -; -pub -mod -dfa -; -mod -error -; -mod -id -; -pub -mod -regex -; -mod -search -; diff --git a/third_party/rust/regex-automata/src/hybrid/regex.rs b/third_party/rust/regex-automata/src/hybrid/regex.rs deleted file mode 100644 index f75d63cd4415f..0000000000000 --- a/third_party/rust/regex-automata/src/hybrid/regex.rs +++ /dev/null @@ -1,9158 +0,0 @@ -/ -* -! -A -lazy -DFA -backed -Regex -. -This -module -provides -a -[ -Regex -] -backed -by -a -lazy -DFA -. -A -Regex -implements -convenience -routines -you -might -have -come -to -expect -such -as -finding -a -match -and -iterating -over -all -non -- -overlapping -matches -. -This -Regex -type -is -limited -in -its -capabilities -to -what -a -lazy -DFA -can -provide -. -Therefore -APIs -involving -capturing -groups -for -example -are -not -provided -. -Internally -a -Regex -is -composed -of -two -DFAs -. -One -is -a -" -forward -" -DFA -that -finds -the -end -offset -of -a -match -where -as -the -other -is -a -" -reverse -" -DFA -that -find -the -start -offset -of -a -match -. -See -the -[ -parent -module -] -( -crate -: -: -hybrid -) -for -examples -. -* -/ -use -crate -: -: -{ -hybrid -: -: -{ -dfa -: -: -{ -self -DFA -} -error -: -: -BuildError -} -nfa -: -: -thompson -util -: -: -{ -iter -search -: -: -{ -Anchored -Input -Match -MatchError -MatchKind -} -} -} -; -/ -/ -/ -A -regular -expression -that -uses -hybrid -NFA -/ -DFAs -( -also -called -" -lazy -DFAs -" -) -/ -/ -/ -for -searching -. -/ -/ -/ -/ -/ -/ -A -regular -expression -is -comprised -of -two -lazy -DFAs -a -" -forward -" -DFA -and -a -/ -/ -/ -" -reverse -" -DFA -. -The -forward -DFA -is -responsible -for -detecting -the -end -of -/ -/ -/ -a -match -while -the -reverse -DFA -is -responsible -for -detecting -the -start -/ -/ -/ -of -a -match -. -Thus -in -order -to -find -the -bounds -of -any -given -match -a -/ -/ -/ -forward -search -must -first -be -run -followed -by -a -reverse -search -. -A -match -/ -/ -/ -found -by -the -forward -DFA -guarantees -that -the -reverse -DFA -will -also -find -/ -/ -/ -a -match -. -/ -/ -/ -/ -/ -/ -# -Fallibility -/ -/ -/ -/ -/ -/ -Most -of -the -search -routines -defined -on -this -type -will -_panic_ -when -the -/ -/ -/ -underlying -search -fails -. -This -might -be -because -the -DFA -gave -up -because -it -/ -/ -/ -saw -a -quit -byte -whether -configured -explicitly -or -via -heuristic -Unicode -/ -/ -/ -word -boundary -support -although -neither -are -enabled -by -default -. -It -might -/ -/ -/ -also -fail -if -the -underlying -DFA -determines -it -isn -' -t -making -effective -use -of -/ -/ -/ -the -cache -( -which -also -never -happens -by -default -) -. -Or -it -might -fail -because -/ -/ -/ -an -invalid -Input -configuration -is -given -for -example -with -an -unsupported -/ -/ -/ -[ -Anchored -] -mode -. -/ -/ -/ -/ -/ -/ -If -you -need -to -handle -these -error -cases -instead -of -allowing -them -to -trigger -/ -/ -/ -a -panic -then -the -lower -level -[ -Regex -: -: -try_search -] -provides -a -fallible -API -/ -/ -/ -that -never -panics -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -cause -a -search -to -terminate -if -it -sees -a -/ -/ -/ -\ -n -byte -and -handle -the -error -returned -. -This -could -be -useful -if -for -/ -/ -/ -example -you -wanted -to -prevent -a -user -supplied -pattern -from -matching -/ -/ -/ -across -a -line -boundary -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -{ -dfa -regex -: -: -Regex -} -Input -MatchError -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -dfa -( -dfa -: -: -Config -: -: -new -( -) -. -quit -( -b -' -\ -n -' -true -) -) -/ -/ -/ -. -build -( -r -" -foo -\ -p -{ -any -} -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo -\ -nbar -" -) -; -/ -/ -/ -/ -/ -Normally -this -would -produce -a -match -since -\ -p -{ -any -} -contains -' -\ -n -' -. -/ -/ -/ -/ -/ -But -since -we -instructed -the -automaton -to -enter -a -quit -state -if -a -/ -/ -/ -/ -/ -' -\ -n -' -is -observed -this -produces -a -match -error -instead -. -/ -/ -/ -let -expected -= -MatchError -: -: -quit -( -b -' -\ -n -' -3 -) -; -/ -/ -/ -let -got -= -re -. -try_search -( -& -mut -cache -& -input -) -. -unwrap_err -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Debug -) -] -pub -struct -Regex -{ -/ -/ -/ -The -forward -lazy -DFA -. -This -can -only -find -the -end -of -a -match -. -forward -: -DFA -/ -/ -/ -The -reverse -lazy -DFA -. -This -can -only -find -the -start -of -a -match -. -/ -/ -/ -/ -/ -/ -This -is -built -with -' -all -' -match -semantics -( -instead -of -leftmost -- -first -) -/ -/ -/ -so -that -it -always -finds -the -longest -possible -match -( -which -corresponds -/ -/ -/ -to -the -leftmost -starting -position -) -. -It -is -also -compiled -as -an -anchored -/ -/ -/ -matcher -and -has -' -starts_for_each_pattern -' -enabled -. -Including -starting -/ -/ -/ -states -for -each -pattern -is -necessary -to -ensure -that -we -only -look -for -/ -/ -/ -matches -of -a -pattern -that -matched -in -the -forward -direction -. -Otherwise -/ -/ -/ -we -might -wind -up -finding -the -" -leftmost -" -starting -position -of -a -totally -/ -/ -/ -different -pattern -! -reverse -: -DFA -} -/ -/ -/ -Convenience -routines -for -regex -and -cache -construction -. -impl -Regex -{ -/ -/ -/ -Parse -the -given -regular -expression -using -the -default -configuration -and -/ -/ -/ -return -the -corresponding -regex -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -[ -Builder -] -to -/ -/ -/ -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -regex -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -3 -. -. -14 -) -) -/ -/ -/ -re -. -find -( -& -mut -cache -" -zzzfoo12345barzzz -" -) -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -Regex -BuildError -> -{ -Regex -: -: -builder -( -) -. -build -( -pattern -) -} -/ -/ -/ -Like -new -but -parses -multiple -patterns -into -a -single -" -multi -regex -. -" -/ -/ -/ -This -similarly -uses -the -default -regex -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -regex -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -re -. -find_iter -( -& -mut -cache -" -abc -1 -foo -4567 -0 -quux -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -4 -. -. -5 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -6 -. -. -9 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -10 -. -. -14 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -15 -. -. -16 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -17 -. -. -21 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -Regex -BuildError -> -{ -Regex -: -: -builder -( -) -. -build_many -( -patterns -) -} -/ -/ -/ -Return -a -builder -for -configuring -the -construction -of -a -Regex -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Builder -] -type -in -common -cases -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -the -builder -to -disable -UTF -- -8 -mode -/ -/ -/ -everywhere -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -regex -: -: -Regex -nfa -: -: -thompson -util -: -: -syntax -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -1 -. -. -9 -) -) -; -/ -/ -/ -let -got -= -re -. -find -( -& -mut -cache -haystack -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -/ -/ -/ -Create -a -new -cache -for -this -Regex -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -this -/ -/ -/ -Regex -. -If -you -want -to -reuse -the -cache -for -another -Regex -then -/ -/ -/ -you -must -call -[ -Cache -: -: -reset -] -with -that -Regex -( -or -equivalently -/ -/ -/ -[ -Regex -: -: -reset_cache -] -) -. -pub -fn -create_cache -( -& -self -) -- -> -Cache -{ -Cache -: -: -new -( -self -) -} -/ -/ -/ -Reset -the -given -cache -such -that -it -can -be -used -for -searching -with -the -/ -/ -/ -this -Regex -( -and -only -this -Regex -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -Regex -. -/ -/ -/ -/ -/ -/ -Resetting -a -cache -sets -its -" -clear -count -" -to -0 -. -This -is -relevant -if -the -/ -/ -/ -Regex -has -been -configured -to -" -give -up -" -after -it -has -cleared -the -cache -/ -/ -/ -a -certain -number -of -times -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -Regex -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -regex -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -Regex -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -Regex -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -/ -/ -/ -re1 -. -find -( -& -mut -cache -" -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -Regex -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -re2 -. -reset_cache -( -& -mut -cache -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -/ -/ -/ -re2 -. -find -( -& -mut -cache -" -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -self -. -forward -( -) -. -reset_cache -( -& -mut -cache -. -forward -) -; -self -. -reverse -( -) -. -reset_cache -( -& -mut -cache -. -reverse -) -; -} -} -/ -/ -/ -Standard -infallible -search -routines -for -finding -and -iterating -over -matches -. -impl -Regex -{ -/ -/ -/ -Returns -true -if -and -only -if -this -regex -matches -the -given -haystack -. -/ -/ -/ -/ -/ -/ -This -routine -may -short -circuit -if -it -knows -that -scanning -future -input -/ -/ -/ -will -never -lead -to -a -different -result -. -In -particular -if -the -underlying -/ -/ -/ -DFA -enters -a -match -state -or -a -dead -state -then -this -routine -will -return -/ -/ -/ -true -or -false -respectively -without -inspecting -any -future -input -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -panics -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -panics -callers -cannot -know -whether -a -match -exists -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -Use -[ -Regex -: -: -try_search -] -if -you -want -to -handle -these -error -conditions -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -hybrid -: -: -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -& -mut -cache -" -foo12345bar -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -& -mut -cache -" -foobar -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -) -- -> -bool -{ -/ -/ -Not -only -can -we -do -an -" -earliest -" -search -but -we -can -avoid -doing -a -/ -/ -reverse -scan -too -. -self -. -forward -( -) -. -try_search_fwd -( -& -mut -cache -. -forward -& -input -. -into -( -) -. -earliest -( -true -) -) -. -unwrap -( -) -. -is_some -( -) -} -/ -/ -/ -Returns -the -start -and -end -offset -of -the -leftmost -match -. -If -no -match -/ -/ -/ -exists -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -panics -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -panics -callers -cannot -know -whether -a -match -exists -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -Use -[ -Regex -: -: -try_search -] -if -you -want -to -handle -these -error -conditions -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Match -hybrid -: -: -regex -: -: -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -3 -. -. -11 -) -) -/ -/ -/ -re -. -find -( -& -mut -cache -" -zzzfoo12345zzz -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -a -match -is -found -after -reading -the -first -byte -( -a -) -/ -/ -/ -/ -/ -the -default -leftmost -- -first -match -semantics -demand -that -we -find -the -/ -/ -/ -/ -/ -earliest -match -that -prefers -earlier -parts -of -the -pattern -over -latter -/ -/ -/ -/ -/ -parts -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -abc -| -a -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -re -. -find -( -& -mut -cache -" -abc -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -) -- -> -Option -< -Match -> -{ -self -. -try_search -( -cache -& -input -. -into -( -) -) -. -unwrap -( -) -} -/ -/ -/ -Returns -an -iterator -over -all -non -- -overlapping -leftmost -matches -in -the -/ -/ -/ -given -bytes -. -If -no -match -exists -then -the -iterator -yields -no -elements -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -panics -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -panics -callers -cannot -know -whether -a -match -exists -or -/ -/ -/ -not -. -/ -/ -/ -/ -/ -/ -The -above -conditions -also -apply -to -the -iterator -returned -as -well -. -For -/ -/ -/ -example -if -the -lazy -DFA -gives -up -or -quits -during -a -search -using -this -/ -/ -/ -method -then -a -panic -will -occur -during -iteration -. -/ -/ -/ -/ -/ -/ -Use -[ -Regex -: -: -try_search -] -with -[ -util -: -: -iter -: -: -Searcher -] -( -iter -: -: -Searcher -) -/ -/ -/ -if -you -want -to -handle -these -error -conditions -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -regex -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -text -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -& -mut -cache -text -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -4 -) -/ -/ -/ -Match -: -: -must -( -0 -5 -. -. -10 -) -/ -/ -/ -Match -: -: -must -( -0 -11 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find_iter -< -' -r -' -c -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -cache -: -& -' -c -mut -Cache -input -: -I -) -- -> -FindMatches -< -' -r -' -c -' -h -> -{ -let -it -= -iter -: -: -Searcher -: -: -new -( -input -. -into -( -) -) -; -FindMatches -{ -re -: -self -cache -it -} -} -} -/ -/ -/ -Lower -level -" -search -" -primitives -that -accept -a -& -Input -for -cheap -reuse -/ -/ -/ -and -return -an -error -if -one -occurs -instead -of -panicking -. -impl -Regex -{ -/ -/ -/ -Returns -the -start -and -end -offset -of -the -leftmost -match -. -If -no -match -/ -/ -/ -exists -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Regex -: -: -find -] -but -with -two -differences -: -/ -/ -/ -/ -/ -/ -1 -. -It -is -not -generic -over -Into -< -Input -> -and -instead -accepts -a -/ -/ -/ -& -Input -. -This -permits -reusing -the -same -Input -for -multiple -searches -/ -/ -/ -without -needing -to -create -a -new -one -. -This -_may_ -help -with -latency -. -/ -/ -/ -2 -. -It -returns -an -error -if -the -search -could -not -complete -where -as -/ -/ -/ -[ -Regex -: -: -find -] -will -panic -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -errors -if -the -search -could -not -complete -. -This -can -occur -/ -/ -/ -in -a -number -of -circumstances -: -/ -/ -/ -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -permit -it -to -" -quit -" -the -search -. -/ -/ -/ -For -example -setting -quit -bytes -or -enabling -heuristic -support -for -/ -/ -/ -Unicode -word -boundaries -. -The -default -configuration -does -not -enable -any -/ -/ -/ -option -that -could -result -in -the -lazy -DFA -quitting -. -/ -/ -/ -* -The -configuration -of -the -lazy -DFA -may -also -permit -it -to -" -give -up -" -/ -/ -/ -on -a -search -if -it -makes -ineffective -use -of -its -transition -table -/ -/ -/ -cache -. -The -default -configuration -does -not -enable -this -by -default -/ -/ -/ -although -it -is -typically -a -good -idea -to -. -/ -/ -/ -* -When -the -provided -Input -configuration -is -not -supported -. -For -/ -/ -/ -example -by -providing -an -unsupported -anchor -mode -. -/ -/ -/ -/ -/ -/ -When -a -search -returns -an -error -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -# -[ -inline -] -pub -fn -try_search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -let -( -fcache -rcache -) -= -( -& -mut -cache -. -forward -& -mut -cache -. -reverse -) -; -let -end -= -match -self -. -forward -( -) -. -try_search_fwd -( -fcache -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -end -) -= -> -end -} -; -/ -/ -This -special -cases -an -empty -match -at -the -beginning -of -the -search -. -If -/ -/ -our -end -matches -our -start -then -since -a -reverse -DFA -can -' -t -match -past -/ -/ -the -start -it -must -follow -that -our -starting -position -is -also -our -end -/ -/ -position -. -So -short -circuit -and -skip -the -reverse -search -. -if -input -. -start -( -) -= -= -end -. -offset -( -) -{ -return -Ok -( -Some -( -Match -: -: -new -( -end -. -pattern -( -) -end -. -offset -( -) -. -. -end -. -offset -( -) -) -) -) -; -} -/ -/ -We -can -also -skip -the -reverse -search -if -we -know -our -search -was -/ -/ -anchored -. -This -occurs -either -when -the -input -config -is -anchored -or -/ -/ -when -we -know -the -regex -itself -is -anchored -. -In -this -case -we -know -the -/ -/ -start -of -the -match -if -one -is -found -must -be -the -start -of -the -/ -/ -search -. -if -self -. -is_anchored -( -input -) -{ -return -Ok -( -Some -( -Match -: -: -new -( -end -. -pattern -( -) -input -. -start -( -) -. -. -end -. -offset -( -) -) -) -) -; -} -/ -/ -N -. -B -. -I -have -tentatively -convinced -myself -that -it -isn -' -t -necessary -/ -/ -to -specify -the -specific -pattern -for -the -reverse -search -since -the -/ -/ -reverse -search -will -always -find -the -same -pattern -to -match -as -the -/ -/ -forward -search -. -But -I -lack -a -rigorous -proof -. -Why -not -just -provide -/ -/ -the -pattern -anyway -? -Well -if -it -is -needed -then -leaving -it -out -/ -/ -gives -us -a -chance -to -find -a -witness -. -( -Also -if -we -don -' -t -need -to -/ -/ -specify -the -pattern -then -we -don -' -t -need -to -build -the -reverse -DFA -/ -/ -with -' -starts_for_each_pattern -' -enabled -. -It -doesn -' -t -matter -too -much -/ -/ -for -the -lazy -DFA -but -does -make -the -overall -DFA -bigger -. -) -/ -/ -/ -/ -We -also -need -to -be -careful -to -disable -' -earliest -' -for -the -reverse -/ -/ -search -since -it -could -be -enabled -for -the -forward -search -. -In -the -/ -/ -reverse -case -to -satisfy -" -leftmost -" -criteria -we -need -to -match -as -/ -/ -much -as -we -can -. -We -also -need -to -be -careful -to -make -the -search -/ -/ -anchored -. -We -don -' -t -want -the -reverse -search -to -report -any -matches -/ -/ -other -than -the -one -beginning -at -the -end -of -our -forward -search -. -let -revsearch -= -input -. -clone -( -) -. -span -( -input -. -start -( -) -. -. -end -. -offset -( -) -) -. -anchored -( -Anchored -: -: -Yes -) -. -earliest -( -false -) -; -let -start -= -self -. -reverse -( -) -. -try_search_rev -( -rcache -& -revsearch -) -? -. -expect -( -" -reverse -search -must -match -if -forward -search -does -" -) -; -debug_assert_eq -! -( -start -. -pattern -( -) -end -. -pattern -( -) -" -forward -and -reverse -search -must -match -same -pattern -" -) -; -debug_assert -! -( -start -. -offset -( -) -< -= -end -. -offset -( -) -) -; -Ok -( -Some -( -Match -: -: -new -( -end -. -pattern -( -) -start -. -offset -( -) -. -. -end -. -offset -( -) -) -) -) -} -/ -/ -/ -Returns -true -if -either -the -given -input -specifies -an -anchored -search -/ -/ -/ -or -if -the -underlying -NFA -is -always -anchored -. -fn -is_anchored -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -match -input -. -get_anchored -( -) -{ -Anchored -: -: -No -= -> -{ -self -. -forward -( -) -. -get_nfa -( -) -. -is_always_start_anchored -( -) -} -Anchored -: -: -Yes -| -Anchored -: -: -Pattern -( -_ -) -= -> -true -} -} -} -/ -/ -/ -Non -- -search -APIs -for -querying -information -about -the -regex -and -setting -a -/ -/ -/ -prefilter -. -impl -Regex -{ -/ -/ -/ -Return -the -underlying -lazy -DFA -responsible -for -forward -matching -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -accessing -the -underlying -lazy -DFA -and -using -it -/ -/ -/ -directly -if -the -situation -calls -for -it -. -pub -fn -forward -( -& -self -) -- -> -& -DFA -{ -& -self -. -forward -} -/ -/ -/ -Return -the -underlying -lazy -DFA -responsible -for -reverse -matching -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -accessing -the -underlying -lazy -DFA -and -using -it -/ -/ -/ -directly -if -the -situation -calls -for -it -. -pub -fn -reverse -( -& -self -) -- -> -& -DFA -{ -& -self -. -reverse -} -/ -/ -/ -Returns -the -total -number -of -patterns -matched -by -this -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -hybrid -: -: -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -r -" -[ -a -- -z -] -+ -" -r -" -[ -0 -- -9 -] -+ -" -r -" -\ -w -+ -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -3 -re -. -pattern_len -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -assert_eq -! -( -self -. -forward -( -) -. -pattern_len -( -) -self -. -reverse -( -) -. -pattern_len -( -) -) -; -self -. -forward -( -) -. -pattern_len -( -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -for -an -infallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -Match -] -value -until -no -more -matches -could -be -found -. -/ -/ -/ -If -the -underlying -regex -engine -returns -an -error -then -a -panic -occurs -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -regex -object -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -* -' -c -represents -the -lifetime -of -the -regex -cache -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -Regex -: -: -find_iter -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -FindMatches -< -' -r -' -c -' -h -> -{ -re -: -& -' -r -Regex -cache -: -& -' -c -mut -Cache -it -: -iter -: -: -Searcher -< -' -h -> -} -impl -< -' -r -' -c -' -h -> -Iterator -for -FindMatches -< -' -r -' -c -' -h -> -{ -type -Item -= -Match -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -let -FindMatches -{ -re -ref -mut -cache -ref -mut -it -} -= -* -self -; -it -. -advance -( -| -input -| -re -. -try_search -( -cache -input -) -) -} -} -/ -/ -/ -A -cache -represents -a -partially -computed -forward -and -reverse -DFA -. -/ -/ -/ -/ -/ -/ -A -cache -is -the -key -component -that -differentiates -a -classical -DFA -and -a -/ -/ -/ -hybrid -NFA -/ -DFA -( -also -called -a -" -lazy -DFA -" -) -. -Where -a -classical -DFA -builds -a -/ -/ -/ -complete -transition -table -that -can -handle -all -possible -inputs -a -hybrid -/ -/ -/ -NFA -/ -DFA -starts -with -an -empty -transition -table -and -builds -only -the -parts -/ -/ -/ -required -during -search -. -The -parts -that -are -built -are -stored -in -a -cache -. -For -/ -/ -/ -this -reason -a -cache -is -a -required -parameter -for -nearly -every -operation -on -/ -/ -/ -a -[ -Regex -] -. -/ -/ -/ -/ -/ -/ -Caches -can -be -created -from -their -corresponding -Regex -via -/ -/ -/ -[ -Regex -: -: -create_cache -] -. -A -cache -can -only -be -used -with -either -the -Regex -/ -/ -/ -that -created -it -or -the -Regex -that -was -most -recently -used -to -reset -it -/ -/ -/ -with -[ -Cache -: -: -reset -] -. -Using -a -cache -with -any -other -Regex -may -result -in -/ -/ -/ -panics -or -incorrect -results -. -# -[ -derive -( -Debug -Clone -) -] -pub -struct -Cache -{ -forward -: -dfa -: -: -Cache -reverse -: -dfa -: -: -Cache -} -impl -Cache -{ -/ -/ -/ -Create -a -new -cache -for -the -given -Regex -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -the -given -/ -/ -/ -Regex -. -If -you -want -to -reuse -the -cache -for -another -Regex -then -you -/ -/ -/ -must -call -[ -Cache -: -: -reset -] -with -that -Regex -. -pub -fn -new -( -re -: -& -Regex -) -- -> -Cache -{ -let -forward -= -dfa -: -: -Cache -: -: -new -( -re -. -forward -( -) -) -; -let -reverse -= -dfa -: -: -Cache -: -: -new -( -re -. -reverse -( -) -) -; -Cache -{ -forward -reverse -} -} -/ -/ -/ -Reset -this -cache -such -that -it -can -be -used -for -searching -with -the -given -/ -/ -/ -Regex -( -and -only -that -Regex -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -Regex -. -/ -/ -/ -/ -/ -/ -Resetting -a -cache -sets -its -" -clear -count -" -to -0 -. -This -is -relevant -if -the -/ -/ -/ -Regex -has -been -configured -to -" -give -up -" -after -it -has -cleared -the -cache -/ -/ -/ -a -certain -number -of -times -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -Regex -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -hybrid -: -: -regex -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -Regex -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -Regex -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -/ -/ -/ -re1 -. -find -( -& -mut -cache -" -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -Regex -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -cache -. -reset -( -& -re2 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -/ -/ -/ -re2 -. -find -( -& -mut -cache -" -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset -( -& -mut -self -re -: -& -Regex -) -{ -self -. -forward -. -reset -( -re -. -forward -( -) -) -; -self -. -reverse -. -reset -( -re -. -reverse -( -) -) -; -} -/ -/ -/ -Return -a -reference -to -the -forward -cache -. -pub -fn -forward -( -& -mut -self -) -- -> -& -dfa -: -: -Cache -{ -& -self -. -forward -} -/ -/ -/ -Return -a -reference -to -the -reverse -cache -. -pub -fn -reverse -( -& -mut -self -) -- -> -& -dfa -: -: -Cache -{ -& -self -. -reverse -} -/ -/ -/ -Return -a -mutable -reference -to -the -forward -cache -. -/ -/ -/ -/ -/ -/ -If -you -need -mutable -references -to -both -the -forward -and -reverse -caches -/ -/ -/ -then -use -[ -Cache -: -: -as_parts_mut -] -. -pub -fn -forward_mut -( -& -mut -self -) -- -> -& -mut -dfa -: -: -Cache -{ -& -mut -self -. -forward -} -/ -/ -/ -Return -a -mutable -reference -to -the -reverse -cache -. -/ -/ -/ -/ -/ -/ -If -you -need -mutable -references -to -both -the -forward -and -reverse -caches -/ -/ -/ -then -use -[ -Cache -: -: -as_parts_mut -] -. -pub -fn -reverse_mut -( -& -mut -self -) -- -> -& -mut -dfa -: -: -Cache -{ -& -mut -self -. -reverse -} -/ -/ -/ -Return -references -to -the -forward -and -reverse -caches -respectively -. -pub -fn -as_parts -( -& -self -) -- -> -( -& -dfa -: -: -Cache -& -dfa -: -: -Cache -) -{ -( -& -self -. -forward -& -self -. -reverse -) -} -/ -/ -/ -Return -mutable -references -to -the -forward -and -reverse -caches -/ -/ -/ -respectively -. -pub -fn -as_parts_mut -( -& -mut -self -) -- -> -( -& -mut -dfa -: -: -Cache -& -mut -dfa -: -: -Cache -) -{ -( -& -mut -self -. -forward -& -mut -self -. -reverse -) -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -as -a -sum -of -the -forward -and -/ -/ -/ -reverse -lazy -DFA -caches -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -cache -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -Cache -> -( -) -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -forward -. -memory_usage -( -) -+ -self -. -reverse -. -memory_usage -( -) -} -} -/ -/ -/ -A -builder -for -a -regex -based -on -a -hybrid -NFA -/ -DFA -. -/ -/ -/ -/ -/ -/ -This -builder -permits -configuring -options -for -the -syntax -of -a -pattern -the -/ -/ -/ -NFA -construction -the -lazy -DFA -construction -and -finally -the -regex -searching -/ -/ -/ -itself -. -This -builder -is -different -from -a -general -purpose -regex -builder -/ -/ -/ -in -that -it -permits -fine -grain -configuration -of -the -construction -process -. -/ -/ -/ -The -trade -off -for -this -is -complexity -and -the -possibility -of -setting -a -/ -/ -/ -configuration -that -might -not -make -sense -. -For -example -there -are -two -/ -/ -/ -different -UTF -- -8 -modes -: -/ -/ -/ -/ -/ -/ -* -[ -syntax -: -: -Config -: -: -utf8 -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -utf8 -) -controls -/ -/ -/ -whether -the -pattern -itself -can -contain -sub -- -expressions -that -match -invalid -/ -/ -/ -UTF -- -8 -. -/ -/ -/ -* -[ -thompson -: -: -Config -: -: -utf8 -] -controls -how -the -regex -iterators -themselves -/ -/ -/ -advance -the -starting -position -of -the -next -search -when -a -match -with -zero -/ -/ -/ -length -is -found -. -/ -/ -/ -/ -/ -/ -Generally -speaking -callers -will -want -to -either -enable -all -of -these -or -/ -/ -/ -disable -all -of -these -. -/ -/ -/ -/ -/ -/ -Internally -building -a -regex -requires -building -two -hybrid -NFA -/ -DFAs -/ -/ -/ -where -one -is -responsible -for -finding -the -end -of -a -match -and -the -other -is -/ -/ -/ -responsible -for -finding -the -start -of -a -match -. -If -you -only -need -to -detect -/ -/ -/ -whether -something -matched -or -only -the -end -of -a -match -then -you -should -use -/ -/ -/ -a -[ -dfa -: -: -Builder -] -to -construct -a -single -hybrid -NFA -/ -DFA -which -is -cheaper -/ -/ -/ -than -building -two -of -them -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -disable -UTF -- -8 -mode -in -the -syntax -and -the -regex -/ -/ -/ -itself -. -This -is -generally -what -you -want -for -matching -on -arbitrary -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -regex -: -: -Regex -nfa -: -: -thompson -util -: -: -syntax -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -1 -. -. -9 -) -) -; -/ -/ -/ -let -got -= -re -. -find -( -& -mut -cache -haystack -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -Notice -that -( -? -- -u -: -[ -^ -b -] -) -matches -invalid -UTF -- -8 -/ -/ -/ -/ -/ -but -the -subsequent -. -* -does -not -! -Disabling -UTF -- -8 -/ -/ -/ -/ -/ -on -the -syntax -permits -this -. -/ -/ -/ -assert_eq -! -( -b -" -foo -\ -xFFarzz -" -& -haystack -[ -got -. -unwrap -( -) -. -range -( -) -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Builder -{ -dfa -: -dfa -: -: -Builder -} -impl -Builder -{ -/ -/ -/ -Create -a -new -regex -builder -with -the -default -configuration -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -{ -dfa -: -DFA -: -: -builder -( -) -} -} -/ -/ -/ -Build -a -regex -from -the -given -pattern -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -or -compiling -the -pattern -then -an -error -/ -/ -/ -is -returned -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -Regex -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Build -a -regex -from -the -given -patterns -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -Regex -BuildError -> -{ -let -forward -= -self -. -dfa -. -build_many -( -patterns -) -? -; -let -reverse -= -self -. -dfa -. -clone -( -) -. -configure -( -DFA -: -: -config -( -) -. -prefilter -( -None -) -. -specialize_start_states -( -false -) -. -match_kind -( -MatchKind -: -: -All -) -) -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -. -build_many -( -patterns -) -? -; -Ok -( -self -. -build_from_dfas -( -forward -reverse -) -) -} -/ -/ -/ -Build -a -regex -from -its -component -forward -and -reverse -hybrid -NFA -/ -DFAs -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -you -' -ve -built -a -forward -and -reverse -lazy -DFA -/ -/ -/ -separately -and -want -to -combine -them -into -a -single -regex -. -Once -build -/ -/ -/ -the -individual -DFAs -given -can -still -be -accessed -via -[ -Regex -: -: -forward -] -/ -/ -/ -and -[ -Regex -: -: -reverse -] -. -/ -/ -/ -/ -/ -/ -It -is -important -that -the -reverse -lazy -DFA -be -compiled -under -the -/ -/ -/ -following -conditions -: -/ -/ -/ -/ -/ -/ -* -It -should -use -[ -MatchKind -: -: -All -] -semantics -. -/ -/ -/ -* -It -should -match -in -reverse -. -/ -/ -/ -* -Otherwise -its -configuration -should -match -the -forward -DFA -. -/ -/ -/ -/ -/ -/ -If -these -conditions -aren -' -t -satisfied -then -the -behavior -of -searches -is -/ -/ -/ -unspecified -. -/ -/ -/ -/ -/ -/ -Note -that -when -using -this -constructor -no -configuration -is -applied -. -/ -/ -/ -Since -this -routine -provides -the -DFAs -to -the -builder -there -is -no -/ -/ -/ -opportunity -to -apply -other -configuration -options -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -build -individual -lazy -forward -and -reverse -DFAs -and -/ -/ -/ -then -combine -them -into -a -single -Regex -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -{ -dfa -: -: -DFA -regex -: -: -Regex -} -/ -/ -/ -nfa -: -: -thompson -/ -/ -/ -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -fwd -= -DFA -: -: -new -( -r -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -rev -= -DFA -: -: -builder -( -) -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -/ -/ -/ -. -build -( -r -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -. -build_from_dfas -( -fwd -rev -) -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -true -re -. -is_match -( -& -mut -cache -" -foo123 -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_from_dfas -( -& -self -forward -: -DFA -reverse -: -DFA -) -- -> -Regex -{ -Regex -{ -forward -reverse -} -} -/ -/ -/ -Set -the -syntax -configuration -for -this -builder -using -/ -/ -/ -[ -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -case -insensitivity -Unicode -and -multi -/ -/ -/ -line -mode -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -dfa -. -syntax -( -config -) -; -self -} -/ -/ -/ -Set -the -Thompson -NFA -configuration -for -this -builder -using -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -] -( -thompson -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -whether -additional -time -should -be -/ -/ -/ -spent -shrinking -the -size -of -the -NFA -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -thompson -( -& -mut -self -config -: -thompson -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -dfa -. -thompson -( -config -) -; -self -} -/ -/ -/ -Set -the -lazy -DFA -compilation -configuration -for -this -builder -using -/ -/ -/ -[ -dfa -: -: -Config -] -( -dfa -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -whether -Unicode -word -boundaries -should -/ -/ -/ -be -heuristically -supported -or -settings -how -the -behavior -of -the -cache -. -pub -fn -dfa -( -& -mut -self -config -: -dfa -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -dfa -. -configure -( -config -) -; -self -} -} -impl -Default -for -Builder -{ -fn -default -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -} diff --git a/third_party/rust/regex-automata/src/hybrid/search.rs b/third_party/rust/regex-automata/src/hybrid/search.rs deleted file mode 100644 index 1766727bd4631..0000000000000 --- a/third_party/rust/regex-automata/src/hybrid/search.rs +++ /dev/null @@ -1,6803 +0,0 @@ -use -crate -: -: -{ -hybrid -: -: -{ -dfa -: -: -{ -Cache -OverlappingState -DFA -} -id -: -: -LazyStateID -} -util -: -: -{ -prefilter -: -: -Prefilter -search -: -: -{ -HalfMatch -Input -MatchError -Span -} -} -} -; -# -[ -inline -( -never -) -] -pub -( -crate -) -fn -find_fwd -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -if -input -. -is_done -( -) -{ -return -Ok -( -None -) -; -} -let -pre -= -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -None -} -else -{ -dfa -. -get_config -( -) -. -get_prefilter -( -) -} -; -/ -/ -So -what -we -do -here -is -specialize -four -different -versions -of -' -find_fwd -' -: -/ -/ -one -for -each -of -the -combinations -for -' -has -prefilter -' -and -' -is -earliest -/ -/ -search -' -. -The -reason -for -doing -this -is -that -both -of -these -things -require -/ -/ -branches -and -special -handling -in -some -code -that -can -be -very -hot -/ -/ -and -shaving -off -as -much -as -we -can -when -we -don -' -t -need -it -tends -to -be -/ -/ -beneficial -in -ad -hoc -benchmarks -. -To -see -these -differences -you -often -/ -/ -need -a -query -with -a -high -match -count -. -In -other -words -specializing -these -/ -/ -four -routines -* -tends -* -to -help -latency -more -than -throughput -. -if -pre -. -is_some -( -) -{ -if -input -. -get_earliest -( -) -{ -find_fwd_imp -( -dfa -cache -input -pre -true -) -} -else -{ -find_fwd_imp -( -dfa -cache -input -pre -false -) -} -} -else -{ -if -input -. -get_earliest -( -) -{ -find_fwd_imp -( -dfa -cache -input -None -true -) -} -else -{ -find_fwd_imp -( -dfa -cache -input -None -false -) -} -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -find_fwd_imp -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -pre -: -Option -< -& -' -_ -Prefilter -> -earliest -: -bool -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -/ -/ -See -' -prefilter_restart -' -docs -for -explanation -. -let -universal_start -= -dfa -. -get_nfa -( -) -. -look_set_prefix_any -( -) -. -is_empty -( -) -; -let -mut -mat -= -None -; -let -mut -sid -= -init_fwd -( -dfa -cache -input -) -? -; -let -mut -at -= -input -. -start -( -) -; -/ -/ -This -could -just -be -a -closure -but -then -I -think -it -would -be -unsound -/ -/ -because -it -would -need -to -be -safe -to -invoke -. -This -way -the -lack -of -safety -/ -/ -is -clearer -in -the -code -below -. -macro_rules -! -next_unchecked -{ -( -sid -: -expr -at -: -expr -) -= -> -{ -{ -let -byte -= -* -input -. -haystack -( -) -. -get_unchecked -( -at -) -; -dfa -. -next_state_untagged_unchecked -( -cache -sid -byte -) -} -} -; -} -if -let -Some -( -ref -pre -) -= -pre -{ -let -span -= -Span -: -: -from -( -at -. -. -input -. -end -( -) -) -; -match -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -return -Ok -( -mat -) -Some -( -ref -span -) -= -> -{ -at -= -span -. -start -; -if -! -universal_start -{ -sid -= -prefilter_restart -( -dfa -cache -& -input -at -) -? -; -} -} -} -} -cache -. -search_start -( -at -) -; -while -at -< -input -. -end -( -) -{ -if -sid -. -is_tagged -( -) -{ -cache -. -search_update -( -at -) -; -sid -= -dfa -. -next_state -( -cache -sid -input -. -haystack -( -) -[ -at -] -) -. -map_err -( -| -_ -| -gave_up -( -at -) -) -? -; -} -else -{ -/ -/ -SAFETY -: -There -are -two -safety -invariants -we -need -to -uphold -/ -/ -here -in -the -loops -below -: -that -' -sid -' -and -' -prev_sid -' -are -valid -/ -/ -state -IDs -for -this -DFA -and -that -' -at -' -is -a -valid -index -into -/ -/ -' -haystack -' -. -For -the -former -we -rely -on -the -invariant -that -/ -/ -next_state -* -and -start_state_forward -always -returns -a -valid -state -/ -/ -ID -( -given -a -valid -state -ID -in -the -former -case -) -and -that -we -are -/ -/ -only -at -this -place -in -the -code -if -' -sid -' -is -untagged -. -Moreover -/ -/ -every -call -to -next_state_untagged_unchecked -below -is -guarded -by -/ -/ -a -check -that -sid -is -untagged -. -For -the -latter -safety -invariant -/ -/ -we -always -guard -unchecked -access -with -a -check -that -' -at -' -is -less -/ -/ -than -' -end -' -where -' -end -< -= -haystack -. -len -( -) -' -. -In -the -unrolled -loop -/ -/ -below -we -ensure -that -' -at -' -is -always -in -bounds -. -/ -/ -/ -/ -PERF -: -For -justification -of -omitting -bounds -checks -it -gives -us -a -/ -/ -~ -10 -% -bump -in -search -time -. -This -was -used -for -a -benchmark -: -/ -/ -/ -/ -regex -- -cli -find -hybrid -dfa -bigfile -' -( -? -m -) -^ -. -+ -' -- -UBb -/ -/ -/ -/ -PERF -: -For -justification -for -the -loop -unrolling -we -use -a -few -/ -/ -different -tests -: -/ -/ -/ -/ -regex -- -cli -find -hybrid -dfa -bigfile -' -\ -w -{ -50 -} -' -- -UBb -/ -/ -regex -- -cli -find -hybrid -dfa -bigfile -' -( -? -m -) -^ -. -+ -' -- -UBb -/ -/ -regex -- -cli -find -hybrid -dfa -bigfile -' -ZQZQZQZQ -' -- -UBb -/ -/ -/ -/ -And -there -are -three -different -configurations -: -/ -/ -/ -/ -nounroll -: -this -entire -' -else -' -block -vanishes -and -we -just -/ -/ -always -use -' -dfa -. -next_state -( -. -. -) -' -. -/ -/ -unroll1 -: -just -the -outer -loop -below -/ -/ -unroll2 -: -just -the -inner -loop -below -/ -/ -unroll3 -: -both -the -outer -and -inner -loops -below -/ -/ -/ -/ -This -results -in -a -matrix -of -timings -for -each -of -the -above -/ -/ -regexes -with -each -of -the -above -unrolling -configurations -: -/ -/ -/ -/ -' -\ -w -{ -50 -} -' -' -( -? -m -) -^ -. -+ -' -' -ZQZQZQZQ -' -/ -/ -nounroll -1 -. -51s -2 -. -34s -1 -. -51s -/ -/ -unroll1 -1 -. -53s -2 -. -32s -1 -. -56s -/ -/ -unroll2 -2 -. -22s -1 -. -50s -0 -. -61s -/ -/ -unroll3 -1 -. -67s -1 -. -45s -0 -. -61s -/ -/ -/ -/ -Ideally -we -' -d -be -able -to -find -a -configuration -that -yields -the -/ -/ -best -time -for -all -regexes -but -alas -we -settle -for -unroll3 -that -/ -/ -gives -us -* -almost -* -the -best -for -' -\ -w -{ -50 -} -' -and -the -best -for -the -/ -/ -other -two -regexes -. -/ -/ -/ -/ -So -what -exactly -is -going -on -here -? -The -first -unrolling -( -grouping -/ -/ -together -runs -of -untagged -transitions -) -specifically -targets -/ -/ -our -choice -of -representation -. -The -second -unrolling -( -grouping -/ -/ -together -runs -of -self -- -transitions -) -specifically -targets -a -common -/ -/ -DFA -topology -. -Let -' -s -dig -in -a -little -bit -by -looking -at -our -/ -/ -regexes -: -/ -/ -/ -/ -' -\ -w -{ -50 -} -' -: -This -regex -spends -a -lot -of -time -outside -of -the -DFA -' -s -/ -/ -start -state -matching -some -part -of -the -' -\ -w -' -repetition -. -This -/ -/ -means -that -it -' -s -a -bit -of -a -worst -case -for -loop -unrolling -that -/ -/ -targets -self -- -transitions -since -the -self -- -transitions -in -' -\ -w -{ -50 -} -' -/ -/ -are -not -particularly -active -for -this -haystack -. -However -the -/ -/ -first -unrolling -( -grouping -together -untagged -transitions -) -/ -/ -does -apply -quite -well -here -since -very -few -transitions -hit -/ -/ -match -/ -dead -/ -quit -/ -unknown -states -. -It -is -however -worth -mentioning -/ -/ -that -if -start -states -are -configured -to -be -tagged -( -which -you -/ -/ -typically -want -to -do -if -you -have -a -prefilter -) -then -this -regex -/ -/ -actually -slows -way -down -because -it -is -constantly -ping -- -ponging -/ -/ -out -of -the -unrolled -loop -and -into -the -handling -of -a -tagged -start -/ -/ -state -below -. -But -when -start -states -aren -' -t -tagged -the -unrolled -/ -/ -loop -stays -hot -. -( -This -is -why -it -' -s -imperative -that -start -state -/ -/ -tagging -be -disabled -when -there -isn -' -t -a -prefilter -! -) -/ -/ -/ -/ -' -( -? -m -) -^ -. -+ -' -: -There -are -two -important -aspects -of -this -regex -: -1 -) -/ -/ -on -this -haystack -its -match -count -is -very -high -much -higher -/ -/ -than -the -other -two -regex -and -2 -) -it -spends -the -vast -majority -/ -/ -of -its -time -matching -' -. -+ -' -. -Since -Unicode -mode -is -disabled -/ -/ -this -corresponds -to -repeatedly -following -self -transitions -for -/ -/ -the -vast -majority -of -the -input -. -This -does -benefit -from -the -/ -/ -untagged -unrolling -since -most -of -the -transitions -will -be -to -/ -/ -untagged -states -but -the -untagged -unrolling -does -more -work -than -/ -/ -what -is -actually -required -. -Namely -it -has -to -keep -track -of -the -/ -/ -previous -and -next -state -IDs -which -I -guess -requires -a -bit -more -/ -/ -shuffling -. -This -is -supported -by -the -fact -that -nounroll -+ -unroll1 -/ -/ -are -both -slower -than -unroll2 -+ -unroll3 -where -the -latter -has -a -/ -/ -loop -unrolling -that -specifically -targets -self -- -transitions -. -/ -/ -/ -/ -' -ZQZQZQZQ -' -: -This -one -is -very -similar -to -' -( -? -m -) -^ -. -+ -' -because -it -/ -/ -spends -the -vast -majority -of -its -time -in -self -- -transitions -for -/ -/ -the -( -implicit -) -unanchored -prefix -. -The -main -difference -with -/ -/ -' -( -? -m -) -^ -. -+ -' -is -that -it -has -a -much -lower -match -count -. -So -there -/ -/ -isn -' -t -much -time -spent -in -the -overhead -of -reporting -matches -. -This -/ -/ -is -the -primary -explainer -in -the -perf -difference -here -. -We -include -/ -/ -this -regex -and -the -former -to -make -sure -we -have -comparison -points -/ -/ -with -high -and -low -match -counts -. -/ -/ -/ -/ -NOTE -: -I -used -' -OpenSubtitles2018 -. -raw -. -sample -. -en -' -for -' -bigfile -' -. -/ -/ -/ -/ -NOTE -: -In -a -follow -- -up -it -turns -out -that -the -" -inner -" -loop -/ -/ -mentioned -above -was -a -pretty -big -pessimization -in -some -other -/ -/ -cases -. -Namely -it -resulted -in -too -much -ping -- -ponging -into -and -out -/ -/ -of -the -loop -which -resulted -in -nearly -~ -2x -regressions -in -search -/ -/ -time -when -compared -to -the -originally -lazy -DFA -in -the -regex -crate -. -/ -/ -So -I -' -ve -removed -the -second -loop -unrolling -that -targets -the -/ -/ -self -- -transition -case -. -let -mut -prev_sid -= -sid -; -while -at -< -input -. -end -( -) -{ -prev_sid -= -unsafe -{ -next_unchecked -! -( -sid -at -) -} -; -if -prev_sid -. -is_tagged -( -) -| -| -at -+ -3 -> -= -input -. -end -( -) -{ -core -: -: -mem -: -: -swap -( -& -mut -prev_sid -& -mut -sid -) -; -break -; -} -at -+ -= -1 -; -sid -= -unsafe -{ -next_unchecked -! -( -prev_sid -at -) -} -; -if -sid -. -is_tagged -( -) -{ -break -; -} -at -+ -= -1 -; -prev_sid -= -unsafe -{ -next_unchecked -! -( -sid -at -) -} -; -if -prev_sid -. -is_tagged -( -) -{ -core -: -: -mem -: -: -swap -( -& -mut -prev_sid -& -mut -sid -) -; -break -; -} -at -+ -= -1 -; -sid -= -unsafe -{ -next_unchecked -! -( -prev_sid -at -) -} -; -if -sid -. -is_tagged -( -) -{ -break -; -} -at -+ -= -1 -; -} -/ -/ -If -we -quit -out -of -the -code -above -with -an -unknown -state -ID -at -/ -/ -any -point -then -we -need -to -re -- -compute -that -transition -using -/ -/ -' -next_state -' -which -will -do -NFA -powerset -construction -for -us -. -if -sid -. -is_unknown -( -) -{ -cache -. -search_update -( -at -) -; -sid -= -dfa -. -next_state -( -cache -prev_sid -input -. -haystack -( -) -[ -at -] -) -. -map_err -( -| -_ -| -gave_up -( -at -) -) -? -; -} -} -if -sid -. -is_tagged -( -) -{ -if -sid -. -is_start -( -) -{ -if -let -Some -( -ref -pre -) -= -pre -{ -let -span -= -Span -: -: -from -( -at -. -. -input -. -end -( -) -) -; -match -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -{ -cache -. -search_finish -( -span -. -end -) -; -return -Ok -( -mat -) -; -} -Some -( -ref -span -) -= -> -{ -/ -/ -We -want -to -skip -any -update -to -' -at -' -below -/ -/ -at -the -end -of -this -iteration -and -just -/ -/ -jump -immediately -back -to -the -next -state -/ -/ -transition -at -the -leading -position -of -the -/ -/ -candidate -match -. -/ -/ -/ -/ -. -. -. -but -only -if -we -actually -made -progress -/ -/ -with -our -prefilter -otherwise -if -the -start -/ -/ -state -has -a -self -- -loop -we -can -get -stuck -. -if -span -. -start -> -at -{ -at -= -span -. -start -; -if -! -universal_start -{ -sid -= -prefilter_restart -( -dfa -cache -& -input -at -) -? -; -} -continue -; -} -} -} -} -} -else -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -sid -0 -) -; -/ -/ -Since -slice -ranges -are -inclusive -at -the -beginning -and -/ -/ -exclusive -at -the -end -and -since -forward -searches -report -/ -/ -the -end -we -can -return -' -at -' -as -- -is -. -This -only -works -because -/ -/ -matches -are -delayed -by -1 -byte -. -So -by -the -time -we -observe -a -/ -/ -match -' -at -' -has -already -been -set -to -1 -byte -past -the -actual -/ -/ -match -location -which -is -precisely -the -exclusive -ending -/ -/ -bound -of -the -match -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -at -) -) -; -if -earliest -{ -cache -. -search_finish -( -at -) -; -return -Ok -( -mat -) -; -} -} -else -if -sid -. -is_dead -( -) -{ -cache -. -search_finish -( -at -) -; -return -Ok -( -mat -) -; -} -else -if -sid -. -is_quit -( -) -{ -cache -. -search_finish -( -at -) -; -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -at -] -at -) -) -; -} -else -{ -debug_assert -! -( -sid -. -is_unknown -( -) -) -; -unreachable -! -( -" -sid -being -unknown -is -a -bug -" -) -; -} -} -at -+ -= -1 -; -} -eoi_fwd -( -dfa -cache -input -& -mut -sid -& -mut -mat -) -? -; -cache -. -search_finish -( -input -. -end -( -) -) -; -Ok -( -mat -) -} -# -[ -inline -( -never -) -] -pub -( -crate -) -fn -find_rev -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -if -input -. -is_done -( -) -{ -return -Ok -( -None -) -; -} -if -input -. -get_earliest -( -) -{ -find_rev_imp -( -dfa -cache -input -true -) -} -else -{ -find_rev_imp -( -dfa -cache -input -false -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -find_rev_imp -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -earliest -: -bool -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -let -mut -mat -= -None -; -let -mut -sid -= -init_rev -( -dfa -cache -input -) -? -; -/ -/ -In -reverse -search -the -loop -below -can -' -t -handle -the -case -of -searching -an -/ -/ -empty -slice -. -Ideally -we -could -write -something -congruent -to -the -forward -/ -/ -search -i -. -e -. -' -while -at -> -= -start -' -but -' -start -' -might -be -0 -. -Since -we -use -/ -/ -an -unsigned -offset -' -at -> -= -0 -' -is -trivially -always -true -. -We -could -avoid -/ -/ -this -extra -case -handling -by -using -a -signed -offset -but -Rust -makes -it -/ -/ -annoying -to -do -. -So -. -. -. -We -just -handle -the -empty -case -separately -. -if -input -. -start -( -) -= -= -input -. -end -( -) -{ -eoi_rev -( -dfa -cache -input -& -mut -sid -& -mut -mat -) -? -; -return -Ok -( -mat -) -; -} -let -mut -at -= -input -. -end -( -) -- -1 -; -macro_rules -! -next_unchecked -{ -( -sid -: -expr -at -: -expr -) -= -> -{ -{ -let -byte -= -* -input -. -haystack -( -) -. -get_unchecked -( -at -) -; -dfa -. -next_state_untagged_unchecked -( -cache -sid -byte -) -} -} -; -} -cache -. -search_start -( -at -) -; -loop -{ -if -sid -. -is_tagged -( -) -{ -cache -. -search_update -( -at -) -; -sid -= -dfa -. -next_state -( -cache -sid -input -. -haystack -( -) -[ -at -] -) -. -map_err -( -| -_ -| -gave_up -( -at -) -) -? -; -} -else -{ -/ -/ -SAFETY -: -See -comments -in -' -find_fwd -' -for -a -safety -argument -. -/ -/ -/ -/ -PERF -: -The -comments -in -' -find_fwd -' -also -provide -a -justification -/ -/ -from -a -performance -perspective -as -to -1 -) -why -we -elide -bounds -/ -/ -checks -and -2 -) -why -we -do -a -specialized -version -of -unrolling -/ -/ -below -. -The -reverse -search -does -have -a -slightly -different -/ -/ -consideration -in -that -most -reverse -searches -tend -to -be -/ -/ -anchored -and -on -shorter -haystacks -. -However -this -still -makes -a -/ -/ -difference -. -Take -this -command -for -example -: -/ -/ -/ -/ -regex -- -cli -find -hybrid -regex -bigfile -' -( -? -m -) -^ -. -+ -' -- -UBb -/ -/ -/ -/ -( -Notice -that -we -use -' -find -hybrid -regex -' -not -' -find -hybrid -dfa -' -/ -/ -like -in -the -justification -for -the -forward -direction -. -The -' -regex -' -/ -/ -sub -- -command -will -find -start -- -of -- -match -and -thus -run -the -reverse -/ -/ -direction -. -) -/ -/ -/ -/ -Without -unrolling -below -the -above -command -takes -around -3 -. -76s -. -/ -/ -But -with -the -unrolling -below -we -get -down -to -2 -. -55s -. -If -we -keep -/ -/ -the -unrolling -but -add -in -bounds -checks -then -we -get -2 -. -86s -. -/ -/ -/ -/ -NOTE -: -I -used -' -OpenSubtitles2018 -. -raw -. -sample -. -en -' -for -' -bigfile -' -. -let -mut -prev_sid -= -sid -; -while -at -> -= -input -. -start -( -) -{ -prev_sid -= -unsafe -{ -next_unchecked -! -( -sid -at -) -} -; -if -prev_sid -. -is_tagged -( -) -| -| -at -< -= -input -. -start -( -) -. -saturating_add -( -3 -) -{ -core -: -: -mem -: -: -swap -( -& -mut -prev_sid -& -mut -sid -) -; -break -; -} -at -- -= -1 -; -sid -= -unsafe -{ -next_unchecked -! -( -prev_sid -at -) -} -; -if -sid -. -is_tagged -( -) -{ -break -; -} -at -- -= -1 -; -prev_sid -= -unsafe -{ -next_unchecked -! -( -sid -at -) -} -; -if -prev_sid -. -is_tagged -( -) -{ -core -: -: -mem -: -: -swap -( -& -mut -prev_sid -& -mut -sid -) -; -break -; -} -at -- -= -1 -; -sid -= -unsafe -{ -next_unchecked -! -( -prev_sid -at -) -} -; -if -sid -. -is_tagged -( -) -{ -break -; -} -at -- -= -1 -; -} -/ -/ -If -we -quit -out -of -the -code -above -with -an -unknown -state -ID -at -/ -/ -any -point -then -we -need -to -re -- -compute -that -transition -using -/ -/ -' -next_state -' -which -will -do -NFA -powerset -construction -for -us -. -if -sid -. -is_unknown -( -) -{ -cache -. -search_update -( -at -) -; -sid -= -dfa -. -next_state -( -cache -prev_sid -input -. -haystack -( -) -[ -at -] -) -. -map_err -( -| -_ -| -gave_up -( -at -) -) -? -; -} -} -if -sid -. -is_tagged -( -) -{ -if -sid -. -is_start -( -) -{ -/ -/ -do -nothing -} -else -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -sid -0 -) -; -/ -/ -Since -reverse -searches -report -the -beginning -of -a -match -/ -/ -and -the -beginning -is -inclusive -( -not -exclusive -like -the -/ -/ -end -of -a -match -) -we -add -1 -to -make -it -inclusive -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -at -+ -1 -) -) -; -if -earliest -{ -cache -. -search_finish -( -at -) -; -return -Ok -( -mat -) -; -} -} -else -if -sid -. -is_dead -( -) -{ -cache -. -search_finish -( -at -) -; -return -Ok -( -mat -) -; -} -else -if -sid -. -is_quit -( -) -{ -cache -. -search_finish -( -at -) -; -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -at -] -at -) -) -; -} -else -{ -debug_assert -! -( -sid -. -is_unknown -( -) -) -; -unreachable -! -( -" -sid -being -unknown -is -a -bug -" -) -; -} -} -if -at -= -= -input -. -start -( -) -{ -break -; -} -at -- -= -1 -; -} -cache -. -search_finish -( -input -. -start -( -) -) -; -eoi_rev -( -dfa -cache -input -& -mut -sid -& -mut -mat -) -? -; -Ok -( -mat -) -} -# -[ -inline -( -never -) -] -pub -( -crate -) -fn -find_overlapping_fwd -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -state -. -mat -= -None -; -if -input -. -is_done -( -) -{ -return -Ok -( -( -) -) -; -} -let -pre -= -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -None -} -else -{ -dfa -. -get_config -( -) -. -get_prefilter -( -) -} -; -if -pre -. -is_some -( -) -{ -find_overlapping_fwd_imp -( -dfa -cache -input -pre -state -) -} -else -{ -find_overlapping_fwd_imp -( -dfa -cache -input -None -state -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -find_overlapping_fwd_imp -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -pre -: -Option -< -& -' -_ -Prefilter -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -/ -/ -See -' -prefilter_restart -' -docs -for -explanation -. -let -universal_start -= -dfa -. -get_nfa -( -) -. -look_set_prefix_any -( -) -. -is_empty -( -) -; -let -mut -sid -= -match -state -. -id -{ -None -= -> -{ -state -. -at -= -input -. -start -( -) -; -init_fwd -( -dfa -cache -input -) -? -} -Some -( -sid -) -= -> -{ -if -let -Some -( -match_index -) -= -state -. -next_match_index -{ -let -match_len -= -dfa -. -match_len -( -cache -sid -) -; -if -match_index -< -match_len -{ -state -. -next_match_index -= -Some -( -match_index -+ -1 -) -; -let -pattern -= -dfa -. -match_pattern -( -cache -sid -match_index -) -; -state -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -state -. -at -) -) -; -return -Ok -( -( -) -) -; -} -} -/ -/ -Once -we -' -ve -reported -all -matches -at -a -given -position -we -need -to -/ -/ -advance -the -search -to -the -next -position -. -state -. -at -+ -= -1 -; -if -state -. -at -> -input -. -end -( -) -{ -return -Ok -( -( -) -) -; -} -sid -} -} -; -/ -/ -NOTE -: -We -don -' -t -optimize -the -crap -out -of -this -routine -primarily -because -/ -/ -it -seems -like -most -overlapping -searches -will -have -higher -match -counts -/ -/ -and -thus -throughput -is -perhaps -not -as -important -. -But -if -you -have -a -use -/ -/ -case -for -something -faster -feel -free -to -file -an -issue -. -cache -. -search_start -( -state -. -at -) -; -while -state -. -at -< -input -. -end -( -) -{ -sid -= -dfa -. -next_state -( -cache -sid -input -. -haystack -( -) -[ -state -. -at -] -) -. -map_err -( -| -_ -| -gave_up -( -state -. -at -) -) -? -; -if -sid -. -is_tagged -( -) -{ -state -. -id -= -Some -( -sid -) -; -if -sid -. -is_start -( -) -{ -if -let -Some -( -ref -pre -) -= -pre -{ -let -span -= -Span -: -: -from -( -state -. -at -. -. -input -. -end -( -) -) -; -match -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -return -Ok -( -( -) -) -Some -( -ref -span -) -= -> -{ -if -span -. -start -> -state -. -at -{ -state -. -at -= -span -. -start -; -if -! -universal_start -{ -sid -= -prefilter_restart -( -dfa -cache -& -input -state -. -at -) -? -; -} -continue -; -} -} -} -} -} -else -if -sid -. -is_match -( -) -{ -state -. -next_match_index -= -Some -( -1 -) -; -let -pattern -= -dfa -. -match_pattern -( -cache -sid -0 -) -; -state -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -state -. -at -) -) -; -cache -. -search_finish -( -state -. -at -) -; -return -Ok -( -( -) -) -; -} -else -if -sid -. -is_dead -( -) -{ -cache -. -search_finish -( -state -. -at -) -; -return -Ok -( -( -) -) -; -} -else -if -sid -. -is_quit -( -) -{ -cache -. -search_finish -( -state -. -at -) -; -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -state -. -at -] -state -. -at -) -) -; -} -else -{ -debug_assert -! -( -sid -. -is_unknown -( -) -) -; -unreachable -! -( -" -sid -being -unknown -is -a -bug -" -) -; -} -} -state -. -at -+ -= -1 -; -cache -. -search_update -( -state -. -at -) -; -} -let -result -= -eoi_fwd -( -dfa -cache -input -& -mut -sid -& -mut -state -. -mat -) -; -state -. -id -= -Some -( -sid -) -; -if -state -. -mat -. -is_some -( -) -{ -/ -/ -' -1 -' -is -always -correct -here -since -if -we -get -to -this -point -this -/ -/ -always -corresponds -to -the -first -( -index -' -0 -' -) -match -discovered -at -/ -/ -this -position -. -So -the -next -match -to -report -at -this -position -( -if -/ -/ -it -exists -) -is -at -index -' -1 -' -. -state -. -next_match_index -= -Some -( -1 -) -; -} -cache -. -search_finish -( -input -. -end -( -) -) -; -result -} -# -[ -inline -( -never -) -] -pub -( -crate -) -fn -find_overlapping_rev -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -state -: -& -mut -OverlappingState -) -- -> -Result -< -( -) -MatchError -> -{ -state -. -mat -= -None -; -if -input -. -is_done -( -) -{ -return -Ok -( -( -) -) -; -} -let -mut -sid -= -match -state -. -id -{ -None -= -> -{ -let -sid -= -init_rev -( -dfa -cache -input -) -? -; -state -. -id -= -Some -( -sid -) -; -if -input -. -start -( -) -= -= -input -. -end -( -) -{ -state -. -rev_eoi -= -true -; -} -else -{ -state -. -at -= -input -. -end -( -) -- -1 -; -} -sid -} -Some -( -sid -) -= -> -{ -if -let -Some -( -match_index -) -= -state -. -next_match_index -{ -let -match_len -= -dfa -. -match_len -( -cache -sid -) -; -if -match_index -< -match_len -{ -state -. -next_match_index -= -Some -( -match_index -+ -1 -) -; -let -pattern -= -dfa -. -match_pattern -( -cache -sid -match_index -) -; -state -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -state -. -at -) -) -; -return -Ok -( -( -) -) -; -} -} -/ -/ -Once -we -' -ve -reported -all -matches -at -a -given -position -we -need -/ -/ -to -advance -the -search -to -the -next -position -. -However -if -we -' -ve -/ -/ -already -followed -the -EOI -transition -then -we -know -we -' -re -done -/ -/ -with -the -search -and -there -cannot -be -any -more -matches -to -report -. -if -state -. -rev_eoi -{ -return -Ok -( -( -) -) -; -} -else -if -state -. -at -= -= -input -. -start -( -) -{ -/ -/ -At -this -point -we -should -follow -the -EOI -transition -. -This -/ -/ -will -cause -us -the -skip -the -main -loop -below -and -fall -through -/ -/ -to -the -final -' -eoi_rev -' -transition -. -state -. -rev_eoi -= -true -; -} -else -{ -/ -/ -We -haven -' -t -hit -the -end -of -the -search -yet -so -move -on -. -state -. -at -- -= -1 -; -} -sid -} -} -; -cache -. -search_start -( -state -. -at -) -; -while -! -state -. -rev_eoi -{ -sid -= -dfa -. -next_state -( -cache -sid -input -. -haystack -( -) -[ -state -. -at -] -) -. -map_err -( -| -_ -| -gave_up -( -state -. -at -) -) -? -; -if -sid -. -is_tagged -( -) -{ -state -. -id -= -Some -( -sid -) -; -if -sid -. -is_start -( -) -{ -/ -/ -do -nothing -} -else -if -sid -. -is_match -( -) -{ -state -. -next_match_index -= -Some -( -1 -) -; -let -pattern -= -dfa -. -match_pattern -( -cache -sid -0 -) -; -state -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -state -. -at -+ -1 -) -) -; -cache -. -search_finish -( -state -. -at -) -; -return -Ok -( -( -) -) -; -} -else -if -sid -. -is_dead -( -) -{ -cache -. -search_finish -( -state -. -at -) -; -return -Ok -( -( -) -) -; -} -else -if -sid -. -is_quit -( -) -{ -cache -. -search_finish -( -state -. -at -) -; -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -state -. -at -] -state -. -at -) -) -; -} -else -{ -debug_assert -! -( -sid -. -is_unknown -( -) -) -; -unreachable -! -( -" -sid -being -unknown -is -a -bug -" -) -; -} -} -if -state -. -at -= -= -input -. -start -( -) -{ -break -; -} -state -. -at -- -= -1 -; -cache -. -search_update -( -state -. -at -) -; -} -let -result -= -eoi_rev -( -dfa -cache -input -& -mut -sid -& -mut -state -. -mat -) -; -state -. -rev_eoi -= -true -; -state -. -id -= -Some -( -sid -) -; -if -state -. -mat -. -is_some -( -) -{ -/ -/ -' -1 -' -is -always -correct -here -since -if -we -get -to -this -point -this -/ -/ -always -corresponds -to -the -first -( -index -' -0 -' -) -match -discovered -at -/ -/ -this -position -. -So -the -next -match -to -report -at -this -position -( -if -/ -/ -it -exists -) -is -at -index -' -1 -' -. -state -. -next_match_index -= -Some -( -1 -) -; -} -cache -. -search_finish -( -input -. -start -( -) -) -; -result -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -init_fwd -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -LazyStateID -MatchError -> -{ -let -sid -= -dfa -. -start_state_forward -( -cache -input -) -? -; -/ -/ -Start -states -can -never -be -match -states -since -all -matches -are -delayed -/ -/ -by -1 -byte -. -debug_assert -! -( -! -sid -. -is_match -( -) -) -; -Ok -( -sid -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -init_rev -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -LazyStateID -MatchError -> -{ -let -sid -= -dfa -. -start_state_reverse -( -cache -input -) -? -; -/ -/ -Start -states -can -never -be -match -states -since -all -matches -are -delayed -/ -/ -by -1 -byte -. -debug_assert -! -( -! -sid -. -is_match -( -) -) -; -Ok -( -sid -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -eoi_fwd -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -sid -: -& -mut -LazyStateID -mat -: -& -mut -Option -< -HalfMatch -> -) -- -> -Result -< -( -) -MatchError -> -{ -let -sp -= -input -. -get_span -( -) -; -match -input -. -haystack -( -) -. -get -( -sp -. -end -) -{ -Some -( -& -b -) -= -> -{ -* -sid -= -dfa -. -next_state -( -cache -* -sid -b -) -. -map_err -( -| -_ -| -gave_up -( -sp -. -end -) -) -? -; -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -sp -. -end -) -) -; -} -else -if -sid -. -is_quit -( -) -{ -return -Err -( -MatchError -: -: -quit -( -b -sp -. -end -) -) -; -} -} -None -= -> -{ -* -sid -= -dfa -. -next_eoi_state -( -cache -* -sid -) -. -map_err -( -| -_ -| -gave_up -( -input -. -haystack -( -) -. -len -( -) -) -) -? -; -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -input -. -haystack -( -) -. -len -( -) -) -) -; -} -/ -/ -N -. -B -. -We -don -' -t -have -to -check -' -is_quit -' -here -because -the -EOI -/ -/ -transition -can -never -lead -to -a -quit -state -. -debug_assert -! -( -! -sid -. -is_quit -( -) -) -; -} -} -Ok -( -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -eoi_rev -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -sid -: -& -mut -LazyStateID -mat -: -& -mut -Option -< -HalfMatch -> -) -- -> -Result -< -( -) -MatchError -> -{ -let -sp -= -input -. -get_span -( -) -; -if -sp -. -start -> -0 -{ -let -byte -= -input -. -haystack -( -) -[ -sp -. -start -- -1 -] -; -* -sid -= -dfa -. -next_state -( -cache -* -sid -byte -) -. -map_err -( -| -_ -| -gave_up -( -sp -. -start -) -) -? -; -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -sp -. -start -) -) -; -} -else -if -sid -. -is_quit -( -) -{ -return -Err -( -MatchError -: -: -quit -( -byte -sp -. -start -- -1 -) -) -; -} -} -else -{ -* -sid -= -dfa -. -next_eoi_state -( -cache -* -sid -) -. -map_err -( -| -_ -| -gave_up -( -sp -. -start -) -) -? -; -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -0 -) -) -; -} -/ -/ -N -. -B -. -We -don -' -t -have -to -check -' -is_quit -' -here -because -the -EOI -/ -/ -transition -can -never -lead -to -a -quit -state -. -debug_assert -! -( -! -sid -. -is_quit -( -) -) -; -} -Ok -( -( -) -) -} -/ -/ -/ -Re -- -compute -the -starting -state -that -a -DFA -should -be -in -after -finding -a -/ -/ -/ -prefilter -candidate -match -at -the -position -at -. -/ -/ -/ -/ -/ -/ -It -is -always -correct -to -call -this -but -not -always -necessary -. -Namely -/ -/ -/ -whenever -the -DFA -has -a -universal -start -state -the -DFA -can -remain -in -the -/ -/ -/ -start -state -that -it -was -in -when -it -ran -the -prefilter -. -Why -? -Because -in -that -/ -/ -/ -case -there -is -only -one -start -state -. -/ -/ -/ -/ -/ -/ -When -does -a -DFA -have -a -universal -start -state -? -In -precisely -cases -where -/ -/ -/ -it -has -no -look -- -around -assertions -in -its -prefix -. -So -for -example -\ -bfoo -/ -/ -/ -does -not -have -a -universal -start -state -because -the -start -state -depends -on -/ -/ -/ -whether -the -byte -immediately -before -the -start -position -is -a -word -byte -or -/ -/ -/ -not -. -However -foo -\ -b -does -have -a -universal -start -state -because -the -word -/ -/ -/ -boundary -does -not -appear -in -the -pattern -' -s -prefix -. -/ -/ -/ -/ -/ -/ -So -. -. -. -most -cases -don -' -t -need -this -but -when -a -pattern -doesn -' -t -have -a -/ -/ -/ -universal -start -state -then -after -a -prefilter -candidate -has -been -found -the -/ -/ -/ -current -state -* -must -* -be -re -- -litigated -as -if -computing -the -start -state -at -the -/ -/ -/ -beginning -of -the -search -because -it -might -change -. -That -is -not -all -start -/ -/ -/ -states -are -created -equal -. -/ -/ -/ -/ -/ -/ -Why -avoid -it -? -Because -while -it -' -s -not -super -expensive -it -isn -' -t -a -trivial -/ -/ -/ -operation -to -compute -the -start -state -. -It -is -much -better -to -avoid -it -and -/ -/ -/ -just -state -in -the -current -state -if -you -know -it -to -be -correct -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -prefilter_restart -( -dfa -: -& -DFA -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -at -: -usize -) -- -> -Result -< -LazyStateID -MatchError -> -{ -let -mut -input -= -input -. -clone -( -) -; -input -. -set_start -( -at -) -; -init_fwd -( -dfa -cache -& -input -) -} -/ -/ -/ -A -convenience -routine -for -constructing -a -" -gave -up -" -match -error -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -gave_up -( -offset -: -usize -) -- -> -MatchError -{ -MatchError -: -: -gave_up -( -offset -) -} diff --git a/third_party/rust/regex-automata/src/lib.rs b/third_party/rust/regex-automata/src/lib.rs deleted file mode 100644 index 4e55a2bb83070..0000000000000 --- a/third_party/rust/regex-automata/src/lib.rs +++ /dev/null @@ -1,6950 +0,0 @@ -/ -* -! -This -crate -exposes -a -variety -of -regex -engines -used -by -the -regex -crate -. -It -provides -a -vast -sprawling -and -" -expert -" -level -API -to -each -regex -engine -. -The -regex -engines -provided -by -this -crate -focus -heavily -on -finite -automata -implementations -and -specifically -guarantee -worst -case -O -( -m -* -n -) -time -complexity -for -all -searches -. -( -Where -m -~ -len -( -regex -) -and -n -~ -len -( -haystack -) -. -) -The -primary -goal -of -this -crate -is -to -serve -as -an -implementation -detail -for -the -regex -crate -. -A -secondary -goal -is -to -make -its -internals -available -for -use -by -others -. -# -Table -of -contents -* -[ -Should -I -be -using -this -crate -? -] -( -# -should -- -i -- -be -- -using -- -this -- -crate -) -gives -some -reasons -for -and -against -using -this -crate -. -* -[ -Examples -] -( -# -examples -) -provides -a -small -selection -of -things -you -can -do -with -this -crate -. -* -[ -Available -regex -engines -] -( -# -available -- -regex -- -engines -) -provides -a -hyperlinked -list -of -all -regex -engines -in -this -crate -. -* -[ -API -themes -] -( -# -api -- -themes -) -discusses -common -elements -used -throughout -this -crate -. -* -[ -Crate -features -] -( -# -crate -- -features -) -documents -the -extensive -list -of -Cargo -features -available -. -# -Should -I -be -using -this -crate -? -If -you -find -yourself -here -because -you -just -want -to -use -regexes -then -you -should -first -check -out -whether -the -[ -regex -crate -] -( -https -: -/ -/ -docs -. -rs -/ -regex -) -meets -your -needs -. -It -provides -a -streamlined -and -difficult -- -to -- -misuse -API -for -regex -searching -. -If -you -' -re -here -because -there -is -something -specific -you -want -to -do -that -can -' -t -be -easily -done -with -regex -crate -then -you -are -perhaps -in -the -right -place -. -It -' -s -most -likely -that -the -first -stop -you -' -ll -want -to -make -is -to -explore -the -[ -meta -regex -APIs -] -( -meta -) -. -Namely -the -regex -crate -is -just -a -light -wrapper -over -a -[ -meta -: -: -Regex -] -so -its -API -will -probably -be -the -easiest -to -transition -to -. -In -contrast -to -the -regex -crate -the -meta -: -: -Regex -API -supports -more -search -parameters -and -does -multi -- -pattern -searches -. -However -it -isn -' -t -quite -as -ergonomic -. -Otherwise -the -following -is -an -inexhaustive -list -of -reasons -to -use -this -crate -: -* -You -want -to -analyze -or -use -a -[ -Thompson -NFA -] -( -nfa -: -: -thompson -: -: -NFA -) -directly -. -* -You -want -more -powerful -multi -- -pattern -search -than -what -is -provided -by -RegexSet -in -the -regex -crate -. -All -regex -engines -in -this -crate -support -multi -- -pattern -searches -. -* -You -want -to -use -one -of -the -regex -crate -' -s -internal -engines -directly -because -of -some -interesting -configuration -that -isn -' -t -possible -via -the -regex -crate -. -For -example -a -[ -lazy -DFA -' -s -configuration -] -( -hybrid -: -: -dfa -: -: -Config -) -exposes -a -dizzying -number -of -options -for -controlling -its -execution -. -* -You -want -to -use -the -lower -level -search -APIs -. -For -example -both -the -[ -lazy -DFA -] -( -hybrid -: -: -dfa -) -and -[ -fully -compiled -DFAs -] -( -dfa -) -support -searching -by -exploring -the -automaton -one -state -at -a -time -. -This -might -be -useful -for -example -for -stream -searches -or -searches -of -strings -stored -in -non -- -contiguous -in -memory -. -* -You -want -to -build -a -fully -compiled -DFA -and -then -[ -use -zero -- -copy -deserialization -] -( -dfa -: -: -dense -: -: -DFA -: -: -from_bytes -) -to -load -it -into -memory -and -use -it -for -searching -. -This -use -case -is -supported -in -core -- -only -no -- -std -/ -no -- -alloc -environments -. -* -You -want -to -run -[ -anchored -searches -] -( -Input -: -: -anchored -) -without -using -the -^ -anchor -in -your -regex -pattern -. -* -You -need -to -work -- -around -contention -issues -with -sharing -a -regex -across -multiple -threads -. -The -[ -meta -: -: -Regex -: -: -search_with -] -( -meta -: -: -Regex -: -: -search_with -) -API -permits -bypassing -any -kind -of -synchronization -at -all -by -requiring -the -caller -to -provide -the -mutable -scratch -spaced -needed -during -a -search -. -* -You -want -to -build -your -own -regex -engine -on -top -of -the -regex -crate -' -s -infrastructure -. -# -Examples -This -section -tries -to -identify -a -few -interesting -things -you -can -do -with -this -crate -and -demonstrates -them -. -# -# -# -Multi -- -pattern -searches -with -capture -groups -One -of -the -more -frustrating -limitations -of -RegexSet -in -the -regex -crate -( -at -the -time -of -writing -) -is -that -it -doesn -' -t -report -match -positions -. -With -this -crate -multi -- -pattern -support -was -intentionally -designed -in -from -the -beginning -which -means -it -works -in -all -regex -engines -and -even -for -capture -groups -as -well -. -This -example -shows -how -to -search -for -matches -of -multiple -regexes -where -each -regex -uses -the -same -capture -group -names -to -parse -different -key -- -value -formats -. -use -regex_automata -: -: -{ -meta -: -: -Regex -PatternID -} -; -let -re -= -Regex -: -: -new_many -( -& -[ -r -# -" -( -? -m -) -^ -( -? -< -key -> -[ -[ -: -word -: -] -] -+ -) -= -( -? -< -val -> -[ -[ -: -word -: -] -] -+ -) -" -# -r -# -" -( -? -m -) -^ -( -? -< -key -> -[ -[ -: -word -: -] -] -+ -) -= -" -( -? -< -val -> -[ -^ -" -] -+ -) -" -" -# -r -# -" -( -? -m -) -^ -( -? -< -key -> -[ -[ -: -word -: -] -] -+ -) -= -' -( -? -< -val -> -[ -^ -' -] -+ -) -' -" -# -r -# -" -( -? -m -) -^ -( -? -< -key -> -[ -[ -: -word -: -] -] -+ -) -: -\ -s -* -( -? -< -val -> -[ -[ -: -word -: -] -] -+ -) -" -# -] -) -? -; -let -hay -= -r -# -" -best_album -= -" -Blow -Your -Face -Out -" -best_quote -= -' -" -then -as -it -was -then -again -it -will -be -" -' -best_year -= -1973 -best_simpsons_episode -: -HOMR -" -# -; -let -mut -kvs -= -vec -! -[ -] -; -for -caps -in -re -. -captures_iter -( -hay -) -{ -/ -/ -N -. -B -. -One -could -use -capture -indices -' -1 -' -and -' -2 -' -here -/ -/ -as -well -. -Capture -indices -are -local -to -each -pattern -. -/ -/ -( -Just -like -names -are -. -) -let -key -= -& -hay -[ -caps -. -get_group_by_name -( -" -key -" -) -. -unwrap -( -) -] -; -let -val -= -& -hay -[ -caps -. -get_group_by_name -( -" -val -" -) -. -unwrap -( -) -] -; -kvs -. -push -( -( -key -val -) -) -; -} -assert_eq -! -( -kvs -vec -! -[ -( -" -best_album -" -" -Blow -Your -Face -Out -" -) -( -" -best_quote -" -" -\ -" -then -as -it -was -then -again -it -will -be -\ -" -" -) -( -" -best_year -" -" -1973 -" -) -( -" -best_simpsons_episode -" -" -HOMR -" -) -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -# -# -Build -a -full -DFA -and -walk -it -manually -One -of -the -regex -engines -in -this -crate -is -a -fully -compiled -DFA -. -It -takes -worst -case -exponential -time -to -build -but -once -built -it -can -be -easily -explored -and -used -for -searches -. -Here -' -s -a -simple -example -that -uses -its -lower -level -APIs -to -implement -a -simple -anchored -search -by -hand -. -use -regex_automata -: -: -{ -dfa -: -: -{ -Automaton -dense -} -Input -} -; -let -dfa -= -dense -: -: -DFA -: -: -new -( -r -" -( -? -- -u -) -\ -b -[ -A -- -Z -] -\ -w -+ -z -\ -b -" -) -? -; -let -haystack -= -" -Quartz -" -; -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -initial -bytes -of -the -haystack -. -let -mut -state -= -dfa -. -start_state_forward -( -& -Input -: -: -new -( -haystack -) -) -? -; -/ -/ -Walk -all -the -bytes -in -the -haystack -. -for -& -b -in -haystack -. -as_bytes -( -) -. -iter -( -) -{ -state -= -dfa -. -next_state -( -state -b -) -; -} -/ -/ -DFAs -in -this -crate -require -an -explicit -/ -/ -end -- -of -- -input -transition -if -a -search -reaches -/ -/ -the -end -of -a -haystack -. -state -= -dfa -. -next_eoi_state -( -state -) -; -assert -! -( -dfa -. -is_match_state -( -state -) -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -Or -do -the -same -with -a -lazy -DFA -that -avoids -exponential -worst -case -compile -time -but -requires -mutable -scratch -space -to -lazily -build -the -DFA -during -the -search -. -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -DFA -Input -} -; -let -dfa -= -DFA -: -: -new -( -r -" -( -? -- -u -) -\ -b -[ -A -- -Z -] -\ -w -+ -z -\ -b -" -) -? -; -let -mut -cache -= -dfa -. -create_cache -( -) -; -let -hay -= -" -Quartz -" -; -/ -/ -The -start -state -is -determined -by -inspecting -the -position -and -the -/ -/ -initial -bytes -of -the -haystack -. -let -mut -state -= -dfa -. -start_state_forward -( -& -mut -cache -& -Input -: -: -new -( -hay -) -) -? -; -/ -/ -Walk -all -the -bytes -in -the -haystack -. -for -& -b -in -hay -. -as_bytes -( -) -. -iter -( -) -{ -state -= -dfa -. -next_state -( -& -mut -cache -state -b -) -? -; -} -/ -/ -DFAs -in -this -crate -require -an -explicit -/ -/ -end -- -of -- -input -transition -if -a -search -reaches -/ -/ -the -end -of -a -haystack -. -state -= -dfa -. -next_eoi_state -( -& -mut -cache -state -) -? -; -assert -! -( -state -. -is_match -( -) -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -# -# -Find -all -overlapping -matches -This -example -shows -how -to -build -a -DFA -and -use -it -to -find -all -possible -matches -including -overlapping -matches -. -A -similar -example -will -work -with -a -lazy -DFA -as -well -. -This -also -works -with -multiple -patterns -and -will -report -all -matches -at -the -same -position -where -multiple -patterns -match -. -use -regex_automata -: -: -{ -dfa -: -: -{ -dense -Automaton -OverlappingState -} -Input -MatchKind -} -; -let -dfa -= -dense -: -: -DFA -: -: -builder -( -) -. -configure -( -dense -: -: -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -. -build -( -r -" -( -? -- -u -) -\ -w -{ -3 -} -" -) -? -; -let -input -= -Input -: -: -new -( -" -homer -marge -bart -lisa -maggie -" -) -; -let -mut -state -= -OverlappingState -: -: -start -( -) -; -let -mut -matches -= -vec -! -[ -] -; -while -let -Some -( -hm -) -= -{ -dfa -. -try_search_overlapping_fwd -( -& -input -& -mut -state -) -? -; -state -. -get_match -( -) -} -{ -matches -. -push -( -hm -. -offset -( -) -) -; -} -assert_eq -! -( -matches -vec -! -[ -3 -4 -5 -/ -/ -hom -home -homer -9 -10 -11 -/ -/ -mar -marg -marge -15 -16 -/ -/ -bar -bart -20 -21 -/ -/ -lis -lisa -25 -26 -27 -28 -/ -/ -mag -magg -maggi -maggie -] -) -; -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -Available -regex -engines -The -following -is -a -complete -list -of -all -regex -engines -provided -by -this -crate -along -with -a -very -brief -description -of -it -and -why -you -might -want -to -use -it -. -* -[ -dfa -: -: -regex -: -: -Regex -] -is -a -regex -engine -that -works -on -top -of -either -[ -dense -] -( -dfa -: -: -dense -) -or -[ -sparse -] -( -dfa -: -: -sparse -) -fully -compiled -DFAs -. -You -might -use -a -DFA -if -you -need -the -fastest -possible -regex -engine -in -this -crate -and -can -afford -the -exorbitant -memory -usage -usually -required -by -DFAs -. -Low -level -APIs -on -fully -compiled -DFAs -are -provided -by -the -[ -Automaton -trait -] -( -dfa -: -: -Automaton -) -. -Fully -compiled -dense -DFAs -can -handle -all -regexes -except -for -searching -a -regex -with -a -Unicode -word -boundary -on -non -- -ASCII -haystacks -. -A -fully -compiled -DFA -based -regex -can -only -report -the -start -and -end -of -each -match -. -* -[ -hybrid -: -: -regex -: -: -Regex -] -is -a -regex -engine -that -works -on -top -of -a -lazily -built -DFA -. -Its -performance -profile -is -very -similar -to -that -of -fully -compiled -DFAs -but -can -be -slower -in -some -pathological -cases -. -Fully -compiled -DFAs -are -also -amenable -to -more -optimizations -such -as -state -acceleration -that -aren -' -t -available -in -a -lazy -DFA -. -You -might -use -this -lazy -DFA -if -you -can -' -t -abide -the -worst -case -exponential -compile -time -of -a -full -DFA -but -still -want -the -DFA -search -performance -in -the -vast -majority -of -cases -. -A -lazy -DFA -based -regex -can -only -report -the -start -and -end -of -each -match -. -* -[ -dfa -: -: -onepass -: -: -DFA -] -is -a -regex -engine -that -is -implemented -as -a -DFA -but -can -report -the -matches -of -each -capture -group -in -addition -to -the -start -and -end -of -each -match -. -The -catch -is -that -it -only -works -on -a -somewhat -small -subset -of -regexes -known -as -" -one -- -pass -. -" -You -' -ll -want -to -use -this -for -cases -when -you -need -capture -group -matches -and -the -regex -is -one -- -pass -since -it -is -likely -to -be -faster -than -any -alternative -. -A -one -- -pass -DFA -can -handle -all -types -of -regexes -but -does -have -some -reasonable -limits -on -the -number -of -capture -groups -it -can -handle -. -* -[ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -] -is -a -regex -engine -that -uses -backtracking -but -keeps -track -of -the -work -it -has -done -to -avoid -catastrophic -backtracking -. -Like -the -one -- -pass -DFA -it -provides -the -matches -of -each -capture -group -. -It -retains -the -O -( -m -* -n -) -worst -case -time -bound -. -This -tends -to -be -slower -than -the -one -- -pass -DFA -regex -engine -but -faster -than -the -PikeVM -. -It -can -handle -all -types -of -regexes -but -usually -only -works -well -with -small -haystacks -and -small -regexes -due -to -the -memory -required -to -avoid -redoing -work -. -* -[ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -] -is -a -regex -engine -that -can -handle -all -regexes -of -all -sizes -and -provides -capture -group -matches -. -It -tends -to -be -a -tool -of -last -resort -because -it -is -also -usually -the -slowest -regex -engine -. -* -[ -meta -: -: -Regex -] -is -the -meta -regex -engine -that -combines -* -all -* -of -the -above -engines -into -one -. -The -reason -for -this -is -that -each -of -the -engines -above -have -their -own -caveats -such -as -" -only -handles -a -subset -of -regexes -" -or -" -is -generally -slow -. -" -The -meta -regex -engine -accounts -for -all -of -these -caveats -and -composes -the -engines -in -a -way -that -attempts -to -mitigate -each -engine -' -s -weaknesses -while -emphasizing -its -strengths -. -For -example -it -will -attempt -to -run -a -lazy -DFA -even -if -it -might -fail -. -In -which -case -it -will -restart -the -search -with -a -likely -slower -but -more -capable -regex -engine -. -The -meta -regex -engine -is -what -you -should -default -to -. -Use -one -of -the -above -engines -directly -only -if -you -have -a -specific -reason -to -. -# -API -themes -While -each -regex -engine -has -its -own -APIs -and -configuration -options -there -are -some -general -themes -followed -by -all -of -them -. -# -# -# -The -Input -abstraction -Most -search -routines -in -this -crate -accept -anything -that -implements -Into -< -Input -> -. -Both -& -str -and -& -[ -u8 -] -haystacks -satisfy -this -constraint -which -means -that -things -like -engine -. -search -( -" -foo -" -) -will -work -as -you -would -expect -. -By -virtue -of -accepting -an -Into -< -Input -> -though -callers -can -provide -more -than -just -a -haystack -. -Indeed -the -[ -Input -] -type -has -more -details -but -briefly -callers -can -use -it -to -configure -various -aspects -of -the -search -: -* -The -span -of -the -haystack -to -search -via -[ -Input -: -: -span -] -or -[ -Input -: -: -range -] -which -might -be -a -substring -of -the -haystack -. -* -Whether -to -run -an -anchored -search -or -not -via -[ -Input -: -: -anchored -] -. -This -permits -one -to -require -matches -to -start -at -the -same -offset -that -the -search -started -. -* -Whether -to -ask -the -regex -engine -to -stop -as -soon -as -a -match -is -seen -via -[ -Input -: -: -earliest -] -. -This -can -be -used -to -find -the -offset -of -a -match -as -soon -as -it -is -known -without -waiting -for -the -full -leftmost -- -first -match -to -be -found -. -This -can -also -be -used -to -avoid -the -worst -case -O -( -m -* -n -^ -2 -) -time -complexity -of -iteration -. -Some -lower -level -search -routines -accept -an -& -Input -for -performance -reasons -. -In -which -case -& -Input -: -: -new -( -" -haystack -" -) -can -be -used -for -a -simple -search -. -# -# -# -Error -reporting -Most -but -not -all -regex -engines -in -this -crate -can -fail -to -execute -a -search -. -When -a -search -fails -callers -cannot -determine -whether -or -not -a -match -exists -. -That -is -the -result -is -indeterminate -. -Search -failure -in -all -cases -in -this -crate -is -represented -by -a -[ -MatchError -] -. -Routines -that -can -fail -start -with -the -try_ -prefix -in -their -name -. -For -example -[ -hybrid -: -: -regex -: -: -Regex -: -: -try_search -] -can -fail -for -a -number -of -reasons -. -Conversely -routines -that -either -can -' -t -fail -or -can -panic -on -failure -lack -the -try_ -prefix -. -For -example -[ -hybrid -: -: -regex -: -: -Regex -: -: -find -] -will -panic -in -cases -where -[ -hybrid -: -: -regex -: -: -Regex -: -: -try_search -] -would -return -an -error -and -[ -meta -: -: -Regex -: -: -find -] -will -never -panic -. -Therefore -callers -need -to -pay -close -attention -to -the -panicking -conditions -in -the -documentation -. -In -most -cases -the -reasons -that -a -search -fails -are -either -predictable -or -configurable -albeit -at -some -additional -cost -. -An -example -of -predictable -failure -is -[ -BoundedBacktracker -: -: -try_search -] -( -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -: -: -try_search -) -. -Namely -it -fails -whenever -the -multiplication -of -the -haystack -the -regex -and -some -constant -exceeds -the -[ -configured -visited -capacity -] -( -nfa -: -: -thompson -: -: -backtrack -: -: -Config -: -: -visited_capacity -) -. -Callers -can -predict -the -failure -in -terms -of -haystack -length -via -the -[ -BoundedBacktracker -: -: -max_haystack_len -] -( -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -: -: -max_haystack_len -) -method -. -While -this -form -of -failure -is -technically -avoidable -by -increasing -the -visited -capacity -it -isn -' -t -practical -to -do -so -for -all -inputs -because -the -memory -usage -required -for -larger -haystacks -becomes -impractically -large -. -So -in -practice -if -one -is -using -the -bounded -backtracker -you -really -do -have -to -deal -with -the -failure -. -An -example -of -configurable -failure -happens -when -one -enables -heuristic -support -for -Unicode -word -boundaries -in -a -DFA -. -Namely -since -the -DFAs -in -this -crate -( -except -for -the -one -- -pass -DFA -) -do -not -support -Unicode -word -boundaries -on -non -- -ASCII -haystacks -building -a -DFA -from -an -NFA -that -contains -a -Unicode -word -boundary -will -itself -fail -. -However -one -can -configure -DFAs -to -still -be -built -in -this -case -by -[ -configuring -heuristic -support -for -Unicode -word -boundaries -] -( -hybrid -: -: -dfa -: -: -Config -: -: -unicode_word_boundary -) -. -If -the -NFA -the -DFA -is -built -from -contains -a -Unicode -word -boundary -then -the -DFA -will -still -be -built -but -special -transitions -will -be -added -to -every -state -that -cause -the -DFA -to -fail -if -any -non -- -ASCII -byte -is -seen -. -This -failure -happens -at -search -time -and -it -requires -the -caller -to -opt -into -this -. -There -are -other -ways -for -regex -engines -to -fail -in -this -crate -but -the -above -two -should -represent -the -general -theme -of -failures -one -can -find -. -Dealing -with -these -failures -is -in -part -one -the -responsibilities -of -the -[ -meta -regex -engine -] -( -meta -) -. -Notice -for -example -that -the -meta -regex -engine -exposes -an -API -that -never -returns -an -error -nor -panics -. -It -carefully -manages -all -of -the -ways -in -which -the -regex -engines -can -fail -and -either -avoids -the -predictable -ones -entirely -( -e -. -g -. -the -bounded -backtracker -) -or -reacts -to -configured -failures -by -falling -back -to -a -different -engine -( -e -. -g -. -the -lazy -DFA -quitting -because -it -saw -a -non -- -ASCII -byte -) -. -# -# -# -Configuration -and -Builders -Most -of -the -regex -engines -in -this -crate -come -with -two -types -to -facilitate -building -the -regex -engine -: -a -Config -and -a -Builder -. -A -Config -is -usually -specific -to -that -particular -regex -engine -but -other -objects -such -as -parsing -and -NFA -compilation -have -Config -types -too -. -A -Builder -is -the -thing -responsible -for -taking -inputs -( -either -pattern -strings -or -already -- -parsed -patterns -or -even -NFAs -directly -) -and -turning -them -into -an -actual -regex -engine -that -can -be -used -for -searching -. -The -main -reason -why -building -a -regex -engine -is -a -bit -complicated -is -because -of -the -desire -to -permit -composition -with -de -- -coupled -components -. -For -example -you -might -want -to -[ -manually -construct -a -Thompson -NFA -] -( -nfa -: -: -thompson -: -: -Builder -) -and -then -build -a -regex -engine -from -it -without -ever -using -a -regex -parser -at -all -. -On -the -other -hand -you -might -also -want -to -build -a -regex -engine -directly -from -the -concrete -syntax -. -This -demonstrates -why -regex -engine -construction -is -so -flexible -: -it -needs -to -support -not -just -convenient -construction -but -also -construction -from -parts -built -elsewhere -. -This -is -also -in -turn -why -there -are -many -different -Config -structs -in -this -crate -. -Let -' -s -look -more -closely -at -an -example -: -[ -hybrid -: -: -regex -: -: -Builder -] -. -It -accepts -three -different -Config -types -for -configuring -construction -of -a -lazy -DFA -regex -: -* -[ -hybrid -: -: -regex -: -: -Builder -: -: -syntax -] -accepts -a -[ -util -: -: -syntax -: -: -Config -] -for -configuring -the -options -found -in -the -[ -regex -- -syntax -] -( -regex_syntax -) -crate -. -For -example -whether -to -match -case -insensitively -. -* -[ -hybrid -: -: -regex -: -: -Builder -: -: -thompson -] -accepts -a -[ -nfa -: -: -thompson -: -: -Config -] -for -configuring -construction -of -a -[ -Thompson -NFA -] -( -nfa -: -: -thompson -: -: -NFA -) -. -For -example -whether -to -build -an -NFA -that -matches -the -reverse -language -described -by -the -regex -. -* -[ -hybrid -: -: -regex -: -: -Builder -: -: -dfa -] -accept -a -[ -hybrid -: -: -dfa -: -: -Config -] -for -configuring -construction -of -the -pair -of -underlying -lazy -DFAs -that -make -up -the -lazy -DFA -regex -engine -. -For -example -changing -the -capacity -of -the -cache -used -to -store -the -transition -table -. -The -lazy -DFA -regex -engine -uses -all -three -of -those -configuration -objects -for -methods -like -[ -hybrid -: -: -regex -: -: -Builder -: -: -build -] -which -accepts -a -pattern -string -containing -the -concrete -syntax -of -your -regex -. -It -uses -the -syntax -configuration -to -parse -it -into -an -AST -and -translate -it -into -an -HIR -. -Then -the -NFA -configuration -when -compiling -the -HIR -into -an -NFA -. -And -then -finally -the -DFA -configuration -when -lazily -determinizing -the -NFA -into -a -DFA -. -Notice -though -that -the -builder -also -has -a -[ -hybrid -: -: -regex -: -: -Builder -: -: -build_from_dfas -] -constructor -. -This -permits -callers -to -build -the -underlying -pair -of -lazy -DFAs -themselves -( -one -for -the -forward -searching -to -find -the -end -of -a -match -and -one -for -the -reverse -searching -to -find -the -start -of -a -match -) -and -then -build -the -regex -engine -from -them -. -The -lazy -DFAs -in -turn -have -their -own -builder -that -permits -[ -construction -directly -from -a -Thompson -NFA -] -( -hybrid -: -: -dfa -: -: -Builder -: -: -build_from_nfa -) -. -Continuing -down -the -rabbit -hole -a -Thompson -NFA -has -its -own -compiler -that -permits -[ -construction -directly -from -an -HIR -] -( -nfa -: -: -thompson -: -: -Compiler -: -: -build_from_hir -) -. -The -lazy -DFA -regex -engine -builder -lets -you -follow -this -rabbit -hole -all -the -way -down -but -also -provides -convenience -routines -that -do -it -for -you -when -you -don -' -t -need -precise -control -over -every -component -. -The -[ -meta -regex -engine -] -( -meta -) -is -a -good -example -of -something -that -utilizes -the -full -flexibility -of -these -builders -. -It -often -needs -not -only -precise -control -over -each -component -but -also -shares -them -across -multiple -regex -engines -. -( -Most -sharing -is -done -by -internal -reference -accounting -. -For -example -an -[ -NFA -] -( -nfa -: -: -thompson -: -: -NFA -) -is -reference -counted -internally -which -makes -cloning -cheap -. -) -# -# -# -Size -limits -Unlike -the -regex -crate -the -regex -- -automata -crate -specifically -does -not -enable -any -size -limits -by -default -. -That -means -users -of -this -crate -need -to -be -quite -careful -when -using -untrusted -patterns -. -Namely -because -bounded -repetitions -can -grow -exponentially -by -stacking -them -it -is -possible -to -build -a -very -large -internal -regex -object -from -just -a -small -pattern -string -. -For -example -the -NFA -built -from -the -pattern -a -{ -10 -} -{ -10 -} -{ -10 -} -{ -10 -} -{ -10 -} -{ -10 -} -{ -10 -} -is -over -240MB -. -There -are -multiple -size -limit -options -in -this -crate -. -If -one -or -more -size -limits -are -relevant -for -the -object -you -' -re -building -they -will -be -configurable -via -methods -on -a -corresponding -Config -type -. -# -Crate -features -This -crate -has -a -dizzying -number -of -features -. -The -main -idea -is -to -be -able -to -control -how -much -stuff -you -pull -in -for -your -specific -use -case -since -the -full -crate -is -quite -large -and -can -dramatically -increase -compile -times -and -binary -size -. -The -most -barebones -but -useful -configuration -is -to -disable -all -default -features -and -enable -only -dfa -- -search -. -This -will -bring -in -just -the -DFA -deserialization -and -search -routines -without -any -dependency -on -std -or -alloc -. -This -does -require -generating -and -serializing -a -DFA -and -then -storing -it -somewhere -but -it -permits -regex -searches -in -freestanding -or -embedded -environments -. -Because -there -are -so -many -features -they -are -split -into -a -few -groups -. -The -default -set -of -features -is -: -std -syntax -perf -unicode -meta -nfa -dfa -and -hybrid -. -Basically -the -default -is -to -enable -everything -except -for -development -related -features -like -logging -. -# -# -# -Ecosystem -features -* -* -* -std -* -* -- -Enables -use -of -the -standard -library -. -In -terms -of -APIs -this -usually -just -means -that -error -types -implement -the -std -: -: -error -: -: -Error -trait -. -Otherwise -std -sometimes -enables -the -code -to -be -faster -for -example -using -a -HashMap -instead -of -a -BTreeMap -. -( -The -std -feature -matters -more -for -dependencies -like -aho -- -corasick -and -memchr -where -std -is -required -to -enable -certain -classes -of -SIMD -optimizations -. -) -Enabling -std -automatically -enables -alloc -. -* -* -* -alloc -* -* -- -Enables -use -of -the -alloc -library -. -This -is -required -for -most -APIs -in -this -crate -. -The -main -exception -is -deserializing -and -searching -with -fully -compiled -DFAs -. -* -* -* -logging -* -* -- -Adds -a -dependency -on -the -log -crate -and -makes -this -crate -emit -log -messages -of -varying -degrees -of -utility -. -The -log -messages -are -especially -useful -in -trying -to -understand -what -the -meta -regex -engine -is -doing -. -# -# -# -Performance -features -* -* -* -perf -* -* -- -Enables -all -of -the -below -features -. -* -* -* -perf -- -inline -* -* -- -When -enabled -inline -( -always -) -is -used -in -( -many -) -strategic -locations -to -help -performance -at -the -expense -of -longer -compile -times -and -increased -binary -size -. -* -* -* -perf -- -literal -* -* -- -Enables -all -literal -related -optimizations -. -* -* -* -perf -- -literal -- -substring -* -* -- -Enables -all -single -substring -literal -optimizations -. -This -includes -adding -a -dependency -on -the -memchr -crate -. -* -* -* -perf -- -literal -- -multisubstring -* -* -- -Enables -all -multiple -substring -literal -optimizations -. -This -includes -adding -a -dependency -on -the -aho -- -corasick -crate -. -# -# -# -Unicode -features -* -* -* -unicode -* -* -- -Enables -all -Unicode -features -. -This -feature -is -enabled -by -default -and -will -always -cover -all -Unicode -features -even -if -more -are -added -in -the -future -. -* -* -* -unicode -- -age -* -* -- -Provide -the -data -for -the -[ -Unicode -Age -property -] -( -https -: -/ -/ -www -. -unicode -. -org -/ -reports -/ -tr44 -/ -tr44 -- -24 -. -html -# -Character_Age -) -. -This -makes -it -possible -to -use -classes -like -\ -p -{ -Age -: -6 -. -0 -} -to -refer -to -all -codepoints -first -introduced -in -Unicode -6 -. -0 -* -* -* -unicode -- -bool -* -* -- -Provide -the -data -for -numerous -Unicode -boolean -properties -. -The -full -list -is -not -included -here -but -contains -properties -like -Alphabetic -Emoji -Lowercase -Math -Uppercase -and -White_Space -. -* -* -* -unicode -- -case -* -* -- -Provide -the -data -for -case -insensitive -matching -using -[ -Unicode -' -s -" -simple -loose -matches -" -specification -] -( -https -: -/ -/ -www -. -unicode -. -org -/ -reports -/ -tr18 -/ -# -Simple_Loose_Matches -) -. -* -* -* -unicode -- -gencat -* -* -- -Provide -the -data -for -[ -Unicode -general -categories -] -( -https -: -/ -/ -www -. -unicode -. -org -/ -reports -/ -tr44 -/ -tr44 -- -24 -. -html -# -General_Category_Values -) -. -This -includes -but -is -not -limited -to -Decimal_Number -Letter -Math_Symbol -Number -and -Punctuation -. -* -* -* -unicode -- -perl -* -* -- -Provide -the -data -for -supporting -the -Unicode -- -aware -Perl -character -classes -corresponding -to -\ -w -\ -s -and -\ -d -. -This -is -also -necessary -for -using -Unicode -- -aware -word -boundary -assertions -. -Note -that -if -this -feature -is -disabled -the -\ -s -and -\ -d -character -classes -are -still -available -if -the -unicode -- -bool -and -unicode -- -gencat -features -are -enabled -respectively -. -* -* -* -unicode -- -script -* -* -- -Provide -the -data -for -[ -Unicode -scripts -and -script -extensions -] -( -https -: -/ -/ -www -. -unicode -. -org -/ -reports -/ -tr24 -/ -) -. -This -includes -but -is -not -limited -to -Arabic -Cyrillic -Hebrew -Latin -and -Thai -. -* -* -* -unicode -- -segment -* -* -- -Provide -the -data -necessary -to -provide -the -properties -used -to -implement -the -[ -Unicode -text -segmentation -algorithms -] -( -https -: -/ -/ -www -. -unicode -. -org -/ -reports -/ -tr29 -/ -) -. -This -enables -using -classes -like -\ -p -{ -gcb -= -Extend -} -\ -p -{ -wb -= -Katakana -} -and -\ -p -{ -sb -= -ATerm -} -. -* -* -* -unicode -- -word -- -boundary -* -* -- -Enables -support -for -Unicode -word -boundaries -i -. -e -. -\ -b -in -regexes -. -When -this -and -unicode -- -perl -are -enabled -then -data -tables -from -regex -- -syntax -are -used -to -implement -Unicode -word -boundaries -. -However -if -regex -- -syntax -isn -' -t -enabled -as -a -dependency -then -one -can -still -enable -this -feature -. -It -will -cause -regex -- -automata -to -bundle -its -own -data -table -that -would -otherwise -be -redundant -with -regex -- -syntax -' -s -table -. -# -# -# -Regex -engine -features -* -* -* -syntax -* -* -- -Enables -a -dependency -on -regex -- -syntax -. -This -makes -APIs -for -building -regex -engines -from -pattern -strings -available -. -Without -the -regex -- -syntax -dependency -the -only -way -to -build -a -regex -engine -is -generally -to -deserialize -a -previously -built -DFA -or -to -hand -assemble -an -NFA -using -its -[ -builder -API -] -( -nfa -: -: -thompson -: -: -Builder -) -. -Once -you -have -an -NFA -you -can -build -any -of -the -regex -engines -in -this -crate -. -The -syntax -feature -also -enables -alloc -. -* -* -* -meta -* -* -- -Enables -the -meta -regex -engine -. -This -also -enables -the -syntax -and -nfa -- -pikevm -features -as -both -are -the -minimal -requirements -needed -. -The -meta -regex -engine -benefits -from -enabling -any -of -the -other -regex -engines -and -will -use -them -automatically -when -appropriate -. -* -* -* -nfa -* -* -- -Enables -all -NFA -related -features -below -. -* -* -* -nfa -- -thompson -* -* -- -Enables -the -Thompson -NFA -APIs -. -This -enables -alloc -. -* -* -* -nfa -- -pikevm -* -* -- -Enables -the -PikeVM -regex -engine -. -This -enables -nfa -- -thompson -. -* -* -* -nfa -- -backtrack -* -* -- -Enables -the -bounded -backtracker -regex -engine -. -This -enables -nfa -- -thompson -. -* -* -* -dfa -* -* -- -Enables -all -DFA -related -features -below -. -* -* -* -dfa -- -build -* -* -- -Enables -APIs -for -determinizing -DFAs -from -NFAs -. -This -enables -nfa -- -thompson -and -dfa -- -search -. -* -* -* -dfa -- -search -* -* -- -Enables -APIs -for -searching -with -DFAs -. -* -* -* -dfa -- -onepass -* -* -- -Enables -the -one -- -pass -DFA -API -. -This -enables -nfa -- -thompson -. -* -* -* -hybrid -* -* -- -Enables -the -hybrid -NFA -/ -DFA -or -" -lazy -DFA -" -regex -engine -. -This -enables -alloc -and -nfa -- -thompson -. -* -/ -/ -/ -We -are -no_std -. -# -! -[ -no_std -] -/ -/ -All -APIs -need -docs -! -# -! -[ -deny -( -missing_docs -) -] -/ -/ -Some -intra -- -doc -links -are -broken -when -certain -features -are -disabled -so -we -/ -/ -only -bleat -about -it -when -most -( -all -? -) -features -are -enabled -. -But -when -we -do -/ -/ -we -block -the -build -. -Links -need -to -work -. -# -! -[ -cfg_attr -( -all -( -feature -= -" -std -" -feature -= -" -nfa -" -feature -= -" -dfa -" -feature -= -" -hybrid -" -) -deny -( -rustdoc -: -: -broken_intra_doc_links -) -) -] -/ -/ -Broken -rustdoc -links -are -very -easy -to -come -by -when -you -start -disabling -/ -/ -features -. -Namely -features -tend -to -change -imports -and -imports -change -what -' -s -/ -/ -available -to -link -to -. -/ -/ -/ -/ -Basically -we -just -don -' -t -support -rustdoc -for -anything -other -than -the -maximal -/ -/ -feature -configuration -. -Other -configurations -will -work -they -just -won -' -t -be -/ -/ -perfect -. -/ -/ -/ -/ -So -here -we -specifically -allow -them -so -we -don -' -t -even -get -warned -about -them -. -# -! -[ -cfg_attr -( -not -( -all -( -feature -= -" -std -" -feature -= -" -nfa -" -feature -= -" -dfa -" -feature -= -" -hybrid -" -) -) -allow -( -rustdoc -: -: -broken_intra_doc_links -) -) -] -/ -/ -Kinda -similar -but -eliminating -all -of -the -dead -code -and -unused -import -/ -/ -warnings -for -every -feature -combo -is -a -fool -' -s -errand -. -Instead -we -just -/ -/ -suppress -those -but -still -let -them -through -in -a -common -configuration -when -we -/ -/ -build -most -of -everything -. -/ -/ -/ -/ -This -does -actually -suggest -that -when -features -are -disabled -we -are -actually -/ -/ -compiling -more -code -than -we -need -to -be -. -And -this -is -perhaps -not -so -great -/ -/ -because -disabling -features -is -usually -done -in -order -to -reduce -compile -times -/ -/ -by -reducing -the -amount -of -code -one -compiles -. -. -. -However -usually -most -of -the -/ -/ -time -this -dead -code -is -a -relatively -small -amount -from -the -' -util -' -module -. -/ -/ -But -. -. -. -I -confess -. -. -. -There -isn -' -t -a -ton -of -visibility -on -this -. -/ -/ -/ -/ -I -' -m -happy -to -try -to -address -this -in -a -different -way -but -" -let -' -s -annotate -/ -/ -every -function -in -' -util -' -with -some -non -- -local -combination -of -features -" -just -/ -/ -cannot -be -the -way -forward -. -# -! -[ -cfg_attr -( -not -( -all -( -feature -= -" -std -" -feature -= -" -nfa -" -feature -= -" -dfa -" -feature -= -" -hybrid -" -feature -= -" -perf -- -literal -- -substring -" -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -allow -( -dead_code -unused_imports -unused_variables -) -) -] -/ -/ -We -generally -want -all -types -to -impl -Debug -. -# -! -[ -warn -( -missing_debug_implementations -) -] -/ -/ -No -clue -why -this -thing -is -still -unstable -because -it -' -s -pretty -amazing -. -This -/ -/ -adds -Cargo -feature -annotations -to -items -in -the -rustdoc -output -. -Which -is -/ -/ -sadly -hugely -beneficial -for -this -crate -due -to -the -number -of -features -. -# -! -[ -cfg_attr -( -docsrs -feature -( -doc_auto_cfg -) -) -] -/ -/ -I -have -literally -never -tested -this -crate -on -16 -- -bit -so -it -is -quite -/ -/ -suspicious -to -advertise -support -for -it -. -But -. -. -. -the -regex -crate -at -time -/ -/ -of -writing -at -least -claims -to -support -it -by -not -doing -any -conditional -/ -/ -compilation -based -on -the -target -pointer -width -. -So -I -guess -I -remain -/ -/ -consistent -with -that -here -. -/ -/ -/ -/ -If -you -are -here -because -you -' -re -on -a -16 -- -bit -system -and -you -were -somehow -using -/ -/ -the -regex -crate -previously -please -file -an -issue -. -Please -be -prepared -to -/ -/ -provide -some -kind -of -reproduction -or -carve -out -some -path -to -getting -16 -- -bit -/ -/ -working -in -CI -. -( -Via -qemu -? -) -# -[ -cfg -( -not -( -any -( -target_pointer_width -= -" -16 -" -target_pointer_width -= -" -32 -" -target_pointer_width -= -" -64 -" -) -) -) -] -compile_error -! -( -" -not -supported -on -non -- -{ -16 -32 -64 -} -please -file -an -issue -" -) -; -# -[ -cfg -( -any -( -test -feature -= -" -std -" -) -) -] -extern -crate -std -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -extern -crate -alloc -; -# -[ -cfg -( -doctest -) -] -doc_comment -: -: -doctest -! -( -" -. -. -/ -README -. -md -" -) -; -# -[ -doc -( -inline -) -] -pub -use -crate -: -: -util -: -: -primitives -: -: -PatternID -; -pub -use -crate -: -: -util -: -: -search -: -: -* -; -# -[ -macro_use -] -mod -macros -; -# -[ -cfg -( -any -( -feature -= -" -dfa -- -search -" -feature -= -" -dfa -- -onepass -" -) -) -] -pub -mod -dfa -; -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -pub -mod -hybrid -; -# -[ -cfg -( -feature -= -" -meta -" -) -] -pub -mod -meta -; -# -[ -cfg -( -feature -= -" -nfa -- -thompson -" -) -] -pub -mod -nfa -; -pub -mod -util -; diff --git a/third_party/rust/regex-automata/src/macros.rs b/third_party/rust/regex-automata/src/macros.rs deleted file mode 100644 index ad5d3bc556525..0000000000000 --- a/third_party/rust/regex-automata/src/macros.rs +++ /dev/null @@ -1,132 +0,0 @@ -/ -/ -Some -feature -combinations -result -in -some -of -these -macros -never -being -used -. -/ -/ -Which -is -fine -. -Just -squash -the -warnings -. -# -! -[ -allow -( -unused_macros -) -] -macro_rules -! -log -{ -( -( -tt -: -tt -) -* -) -= -> -{ -# -[ -cfg -( -feature -= -" -logging -" -) -] -{ -( -tt -) -* -} -} -} -macro_rules -! -debug -{ -( -( -tt -: -tt -) -* -) -= -> -{ -log -! -( -log -: -: -debug -! -( -( -tt -) -* -) -) -} -} -macro_rules -! -trace -{ -( -( -tt -: -tt -) -* -) -= -> -{ -log -! -( -log -: -: -trace -! -( -( -tt -) -* -) -) -} -} diff --git a/third_party/rust/regex-automata/src/meta/error.rs b/third_party/rust/regex-automata/src/meta/error.rs deleted file mode 100644 index fced1487bed3f..0000000000000 --- a/third_party/rust/regex-automata/src/meta/error.rs +++ /dev/null @@ -1,2079 +0,0 @@ -use -regex_syntax -: -: -{ -ast -hir -} -; -use -crate -: -: -{ -nfa -util -: -: -search -: -: -MatchError -PatternID -} -; -/ -/ -/ -An -error -that -occurs -when -construction -of -a -Regex -fails -. -/ -/ -/ -/ -/ -/ -A -build -error -is -generally -a -result -of -one -of -two -possible -failure -/ -/ -/ -modes -. -First -is -a -parse -or -syntax -error -in -the -concrete -syntax -of -a -/ -/ -/ -pattern -. -Second -is -that -the -construction -of -the -underlying -regex -matcher -/ -/ -/ -fails -usually -because -it -gets -too -big -with -respect -to -limits -like -/ -/ -/ -[ -Config -: -: -nfa_size_limit -] -( -crate -: -: -meta -: -: -Config -: -: -nfa_size_limit -) -. -/ -/ -/ -/ -/ -/ -This -error -provides -very -little -introspection -capabilities -. -You -can -: -/ -/ -/ -/ -/ -/ -* -Ask -for -the -[ -PatternID -] -of -the -pattern -that -caused -an -error -if -one -/ -/ -/ -is -available -. -This -is -available -for -things -like -syntax -errors -but -not -for -/ -/ -/ -cases -where -build -limits -are -exceeded -. -/ -/ -/ -* -Ask -for -the -underlying -syntax -error -but -only -if -the -error -is -a -syntax -/ -/ -/ -error -. -/ -/ -/ -* -Ask -for -a -human -readable -message -corresponding -to -the -underlying -error -. -/ -/ -/ -* -The -BuildError -: -: -source -method -( -from -the -std -: -: -error -: -: -Error -/ -/ -/ -trait -implementation -) -may -be -used -to -query -for -an -underlying -error -if -one -/ -/ -/ -exists -. -There -are -no -API -guarantees -about -which -error -is -returned -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -std -: -: -error -: -: -Error -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -BuildError -{ -kind -: -BuildErrorKind -} -# -[ -derive -( -Clone -Debug -) -] -enum -BuildErrorKind -{ -Syntax -{ -pid -: -PatternID -err -: -regex_syntax -: -: -Error -} -NFA -( -nfa -: -: -thompson -: -: -BuildError -) -} -impl -BuildError -{ -/ -/ -/ -If -it -is -known -which -pattern -ID -caused -this -build -error -to -occur -then -/ -/ -/ -this -method -returns -it -. -/ -/ -/ -/ -/ -/ -Some -errors -are -not -associated -with -a -particular -pattern -. -However -any -/ -/ -/ -errors -that -occur -as -part -of -parsing -a -pattern -are -guaranteed -to -be -/ -/ -/ -associated -with -a -pattern -ID -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -err -= -Regex -: -: -new_many -( -& -[ -" -a -" -" -b -" -r -" -\ -p -{ -Foo -} -" -" -c -" -] -) -. -unwrap_err -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -2 -) -) -err -. -pattern -( -) -) -; -/ -/ -/ -pub -fn -pattern -( -& -self -) -- -> -Option -< -PatternID -> -{ -match -self -. -kind -{ -BuildErrorKind -: -: -Syntax -{ -pid -. -. -} -= -> -Some -( -pid -) -_ -= -> -None -} -} -/ -/ -/ -If -this -error -occurred -because -the -regex -exceeded -the -configured -size -/ -/ -/ -limit -before -being -built -then -this -returns -the -configured -size -limit -. -/ -/ -/ -/ -/ -/ -The -limit -returned -is -what -was -configured -and -corresponds -to -the -/ -/ -/ -maximum -amount -of -heap -usage -in -bytes -. -pub -fn -size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -match -self -. -kind -{ -BuildErrorKind -: -: -NFA -( -ref -err -) -= -> -err -. -size_limit -( -) -_ -= -> -None -} -} -/ -/ -/ -If -this -error -corresponds -to -a -syntax -error -then -a -reference -to -it -is -/ -/ -/ -returned -by -this -method -. -pub -fn -syntax_error -( -& -self -) -- -> -Option -< -& -regex_syntax -: -: -Error -> -{ -match -self -. -kind -{ -BuildErrorKind -: -: -Syntax -{ -ref -err -. -. -} -= -> -Some -( -err -) -_ -= -> -None -} -} -pub -( -crate -) -fn -ast -( -pid -: -PatternID -err -: -ast -: -: -Error -) -- -> -BuildError -{ -let -err -= -regex_syntax -: -: -Error -: -: -from -( -err -) -; -BuildError -{ -kind -: -BuildErrorKind -: -: -Syntax -{ -pid -err -} -} -} -pub -( -crate -) -fn -hir -( -pid -: -PatternID -err -: -hir -: -: -Error -) -- -> -BuildError -{ -let -err -= -regex_syntax -: -: -Error -: -: -from -( -err -) -; -BuildError -{ -kind -: -BuildErrorKind -: -: -Syntax -{ -pid -err -} -} -} -pub -( -crate -) -fn -nfa -( -err -: -nfa -: -: -thompson -: -: -BuildError -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -NFA -( -err -) -} -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -BuildError -{ -fn -source -( -& -self -) -- -> -Option -< -& -( -dyn -std -: -: -error -: -: -Error -+ -' -static -) -> -{ -match -self -. -kind -{ -BuildErrorKind -: -: -Syntax -{ -ref -err -. -. -} -= -> -Some -( -err -) -BuildErrorKind -: -: -NFA -( -ref -err -) -= -> -Some -( -err -) -} -} -} -impl -core -: -: -fmt -: -: -Display -for -BuildError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -match -self -. -kind -{ -BuildErrorKind -: -: -Syntax -{ -pid -. -. -} -= -> -{ -write -! -( -f -" -error -parsing -pattern -{ -} -" -pid -. -as_usize -( -) -) -} -BuildErrorKind -: -: -NFA -( -_ -) -= -> -write -! -( -f -" -error -building -NFA -" -) -} -} -} -/ -/ -/ -An -error -that -occurs -when -a -search -should -be -retried -. -/ -/ -/ -/ -/ -/ -This -retry -error -distinguishes -between -two -different -failure -modes -. -/ -/ -/ -/ -/ -/ -The -first -is -one -where -potential -quadratic -behavior -has -been -detected -. -/ -/ -/ -In -this -case -whatever -optimization -that -led -to -this -behavior -should -be -/ -/ -/ -stopped -and -the -next -best -strategy -should -be -used -. -/ -/ -/ -/ -/ -/ -The -second -indicates -that -the -underlying -regex -engine -has -failed -for -some -/ -/ -/ -reason -. -This -usually -occurs -because -either -a -lazy -DFA -' -s -cache -has -become -/ -/ -/ -ineffective -or -because -a -non -- -ASCII -byte -has -been -seen -* -and -* -a -Unicode -word -/ -/ -/ -boundary -was -used -in -one -of -the -patterns -. -In -this -failure -case -a -different -/ -/ -/ -regex -engine -that -won -' -t -fail -in -these -ways -( -PikeVM -backtracker -or -the -/ -/ -/ -one -- -pass -DFA -) -should -be -used -. -/ -/ -/ -/ -/ -/ -This -is -an -internal -error -only -and -should -never -bleed -into -the -public -/ -/ -/ -API -. -# -[ -derive -( -Debug -) -] -pub -( -crate -) -enum -RetryError -{ -Quadratic -( -RetryQuadraticError -) -Fail -( -RetryFailError -) -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -RetryError -{ -} -impl -core -: -: -fmt -: -: -Display -for -RetryError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -match -* -self -{ -RetryError -: -: -Quadratic -( -ref -err -) -= -> -err -. -fmt -( -f -) -RetryError -: -: -Fail -( -ref -err -) -= -> -err -. -fmt -( -f -) -} -} -} -impl -From -< -MatchError -> -for -RetryError -{ -fn -from -( -merr -: -MatchError -) -- -> -RetryError -{ -RetryError -: -: -Fail -( -RetryFailError -: -: -from -( -merr -) -) -} -} -/ -/ -/ -An -error -that -occurs -when -potential -quadratic -behavior -has -been -detected -/ -/ -/ -when -applying -either -the -" -reverse -suffix -" -or -" -reverse -inner -" -optimizations -. -/ -/ -/ -/ -/ -/ -When -this -error -occurs -callers -should -abandon -the -" -reverse -" -optimization -/ -/ -/ -and -use -a -normal -forward -search -. -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -RetryQuadraticError -( -( -) -) -; -impl -RetryQuadraticError -{ -pub -( -crate -) -fn -new -( -) -- -> -RetryQuadraticError -{ -RetryQuadraticError -( -( -) -) -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -RetryQuadraticError -{ -} -impl -core -: -: -fmt -: -: -Display -for -RetryQuadraticError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -regex -engine -gave -up -to -avoid -quadratic -behavior -" -) -} -} -impl -From -< -RetryQuadraticError -> -for -RetryError -{ -fn -from -( -err -: -RetryQuadraticError -) -- -> -RetryError -{ -RetryError -: -: -Quadratic -( -err -) -} -} -/ -/ -/ -An -error -that -occurs -when -a -regex -engine -" -gives -up -" -for -some -reason -before -/ -/ -/ -finishing -a -search -. -Usually -this -occurs -because -of -heuristic -Unicode -word -/ -/ -/ -boundary -support -or -because -of -ineffective -cache -usage -in -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -When -this -error -occurs -callers -should -retry -the -regex -search -with -a -/ -/ -/ -different -regex -engine -. -/ -/ -/ -/ -/ -/ -Note -that -this -has -convenient -From -impls -that -will -automatically -/ -/ -/ -convert -a -MatchError -into -this -error -. -This -works -because -the -meta -/ -/ -/ -regex -engine -internals -guarantee -that -errors -like -HaystackTooLong -and -/ -/ -/ -UnsupportedAnchored -will -never -occur -. -The -only -errors -left -are -Quit -and -/ -/ -/ -GaveUp -which -both -correspond -to -this -" -failure -" -error -. -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -RetryFailError -{ -offset -: -usize -} -impl -RetryFailError -{ -pub -( -crate -) -fn -from_offset -( -offset -: -usize -) -- -> -RetryFailError -{ -RetryFailError -{ -offset -} -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -RetryFailError -{ -} -impl -core -: -: -fmt -: -: -Display -for -RetryFailError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -regex -engine -failed -at -offset -{ -: -? -} -" -self -. -offset -) -} -} -impl -From -< -RetryFailError -> -for -RetryError -{ -fn -from -( -err -: -RetryFailError -) -- -> -RetryError -{ -RetryError -: -: -Fail -( -err -) -} -} -impl -From -< -MatchError -> -for -RetryFailError -{ -fn -from -( -merr -: -MatchError -) -- -> -RetryFailError -{ -use -crate -: -: -util -: -: -search -: -: -MatchErrorKind -: -: -* -; -match -* -merr -. -kind -( -) -{ -Quit -{ -offset -. -. -} -= -> -RetryFailError -: -: -from_offset -( -offset -) -GaveUp -{ -offset -} -= -> -RetryFailError -: -: -from_offset -( -offset -) -/ -/ -These -can -never -occur -because -we -avoid -them -by -construction -/ -/ -or -with -higher -level -control -flow -logic -. -For -example -the -/ -/ -backtracker -' -s -wrapper -will -never -hand -out -a -backtracker -engine -/ -/ -when -the -haystack -would -be -too -long -. -HaystackTooLong -{ -. -. -} -| -UnsupportedAnchored -{ -. -. -} -= -> -{ -unreachable -! -( -" -found -impossible -error -in -meta -engine -: -{ -} -" -merr -) -} -} -} -} diff --git a/third_party/rust/regex-automata/src/meta/limited.rs b/third_party/rust/regex-automata/src/meta/limited.rs deleted file mode 100644 index 2f7e76344b52d..0000000000000 --- a/third_party/rust/regex-automata/src/meta/limited.rs +++ /dev/null @@ -1,2446 +0,0 @@ -/ -* -! -This -module -defines -two -bespoke -reverse -DFA -searching -routines -. -( -One -for -the -lazy -DFA -and -one -for -the -fully -compiled -DFA -. -) -These -routines -differ -from -the -usual -ones -by -permitting -the -caller -to -specify -a -minimum -starting -position -. -That -is -the -search -will -begin -at -input -. -end -( -) -and -will -usually -stop -at -input -. -start -( -) -unless -min_start -> -input -. -start -( -) -in -which -case -the -search -will -stop -at -min_start -. -In -other -words -this -lets -you -say -" -no -the -search -must -not -extend -past -this -point -even -if -it -' -s -within -the -bounds -of -the -given -Input -. -" -And -if -the -search -* -does -* -want -to -go -past -that -point -it -stops -and -returns -a -" -may -be -quadratic -" -error -which -indicates -that -the -caller -should -retry -using -some -other -technique -. -These -routines -specifically -exist -to -protect -against -quadratic -behavior -when -employing -the -" -reverse -suffix -" -and -" -reverse -inner -" -optimizations -. -Without -the -backstop -these -routines -provide -it -is -possible -for -parts -of -the -haystack -to -get -re -- -scanned -over -and -over -again -. -The -backstop -not -only -prevents -this -but -* -tells -you -when -it -is -happening -* -so -that -you -can -change -the -strategy -. -Why -can -' -t -we -just -use -the -normal -search -routines -? -We -could -use -the -normal -search -routines -and -just -set -the -start -bound -on -the -provided -Input -to -our -min_start -position -. -The -problem -here -is -that -it -' -s -impossible -to -distinguish -between -" -no -match -because -we -reached -the -end -of -input -" -and -" -determined -there -was -no -match -well -before -the -end -of -input -. -" -The -former -case -is -what -we -care -about -with -respect -to -quadratic -behavior -. -The -latter -case -is -totally -fine -. -Why -don -' -t -we -modify -the -normal -search -routines -to -report -the -position -at -which -the -search -stops -? -I -considered -this -and -I -still -wonder -if -it -is -indeed -the -right -thing -to -do -. -However -I -think -the -straight -- -forward -thing -to -do -there -would -be -to -complicate -the -return -type -signature -of -almost -every -search -routine -in -this -crate -which -I -really -do -not -want -to -do -. -It -therefore -might -make -more -sense -to -provide -a -richer -way -for -search -routines -to -report -meta -data -but -that -was -beyond -my -bandwidth -to -work -on -at -the -time -of -writing -. -See -the -' -opt -/ -reverse -- -inner -' -and -' -opt -/ -reverse -- -suffix -' -benchmarks -in -rebar -for -a -real -demonstration -of -how -quadratic -behavior -is -mitigated -. -* -/ -use -crate -: -: -{ -meta -: -: -error -: -: -{ -RetryError -RetryQuadraticError -} -HalfMatch -Input -MatchError -} -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -dfa_try_search_half_rev -( -dfa -: -& -crate -: -: -dfa -: -: -dense -: -: -DFA -< -alloc -: -: -vec -: -: -Vec -< -u32 -> -> -input -: -& -Input -< -' -_ -> -min_start -: -usize -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -use -crate -: -: -dfa -: -: -Automaton -; -let -mut -mat -= -None -; -let -mut -sid -= -dfa -. -start_state_reverse -( -input -) -? -; -if -input -. -start -( -) -= -= -input -. -end -( -) -{ -dfa_eoi_rev -( -dfa -input -& -mut -sid -& -mut -mat -) -? -; -return -Ok -( -mat -) -; -} -let -mut -at -= -input -. -end -( -) -- -1 -; -loop -{ -sid -= -dfa -. -next_state -( -sid -input -. -haystack -( -) -[ -at -] -) -; -if -dfa -. -is_special_state -( -sid -) -{ -if -dfa -. -is_match_state -( -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -sid -0 -) -; -/ -/ -Since -reverse -searches -report -the -beginning -of -a -/ -/ -match -and -the -beginning -is -inclusive -( -not -exclusive -/ -/ -like -the -end -of -a -match -) -we -add -1 -to -make -it -/ -/ -inclusive -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -at -+ -1 -) -) -; -} -else -if -dfa -. -is_dead_state -( -sid -) -{ -return -Ok -( -mat -) -; -} -else -if -dfa -. -is_quit_state -( -sid -) -{ -if -mat -. -is_some -( -) -{ -return -Ok -( -mat -) -; -} -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -at -] -at -) -. -into -( -) -) -; -} -} -if -at -= -= -input -. -start -( -) -{ -break -; -} -at -- -= -1 -; -if -at -< -min_start -{ -trace -! -( -" -reached -position -{ -} -which -is -before -the -previous -literal -\ -match -quitting -to -avoid -quadratic -behavior -" -at -) -; -return -Err -( -RetryError -: -: -Quadratic -( -RetryQuadraticError -: -: -new -( -) -) -) -; -} -} -let -was_dead -= -dfa -. -is_dead_state -( -sid -) -; -dfa_eoi_rev -( -dfa -input -& -mut -sid -& -mut -mat -) -? -; -/ -/ -If -we -reach -the -beginning -of -the -search -and -we -could -otherwise -still -/ -/ -potentially -keep -matching -if -there -was -more -to -match -then -we -actually -/ -/ -return -an -error -to -indicate -giving -up -on -this -optimization -. -Why -? -Because -/ -/ -we -can -' -t -prove -that -the -real -match -begins -at -where -we -would -report -it -. -/ -/ -/ -/ -This -only -happens -when -all -of -the -following -are -true -: -/ -/ -/ -/ -1 -) -We -reach -the -starting -point -of -our -search -span -. -/ -/ -2 -) -The -match -we -found -is -before -the -starting -point -. -/ -/ -3 -) -The -FSM -reports -we -could -possibly -find -a -longer -match -. -/ -/ -/ -/ -We -need -( -1 -) -because -otherwise -the -search -stopped -before -the -starting -/ -/ -point -and -there -is -no -possible -way -to -find -a -more -leftmost -position -. -/ -/ -/ -/ -We -need -( -2 -) -because -if -the -match -found -has -an -offset -equal -to -the -minimum -/ -/ -possible -offset -then -there -is -no -possible -more -leftmost -match -. -/ -/ -/ -/ -We -need -( -3 -) -because -if -the -FSM -couldn -' -t -continue -anyway -( -i -. -e -. -it -' -s -in -/ -/ -a -dead -state -) -then -we -know -we -couldn -' -t -find -anything -more -leftmost -/ -/ -than -what -we -have -. -( -We -have -to -check -the -state -we -were -in -prior -to -the -/ -/ -EOI -transition -since -the -EOI -transition -will -usually -bring -us -to -a -dead -/ -/ -state -by -virtue -of -it -represents -the -end -- -of -- -input -. -) -if -at -= -= -input -. -start -( -) -& -& -mat -. -map_or -( -false -| -m -| -m -. -offset -( -) -> -input -. -start -( -) -) -& -& -! -was_dead -{ -trace -! -( -" -reached -beginning -of -search -at -offset -{ -} -without -hitting -\ -a -dead -state -quitting -to -avoid -potential -false -positive -match -" -at -) -; -return -Err -( -RetryError -: -: -Quadratic -( -RetryQuadraticError -: -: -new -( -) -) -) -; -} -Ok -( -mat -) -} -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -pub -( -crate -) -fn -hybrid_try_search_half_rev -( -dfa -: -& -crate -: -: -hybrid -: -: -dfa -: -: -DFA -cache -: -& -mut -crate -: -: -hybrid -: -: -dfa -: -: -Cache -input -: -& -Input -< -' -_ -> -min_start -: -usize -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -let -mut -mat -= -None -; -let -mut -sid -= -dfa -. -start_state_reverse -( -cache -input -) -? -; -if -input -. -start -( -) -= -= -input -. -end -( -) -{ -hybrid_eoi_rev -( -dfa -cache -input -& -mut -sid -& -mut -mat -) -? -; -return -Ok -( -mat -) -; -} -let -mut -at -= -input -. -end -( -) -- -1 -; -loop -{ -sid -= -dfa -. -next_state -( -cache -sid -input -. -haystack -( -) -[ -at -] -) -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -at -) -) -? -; -if -sid -. -is_tagged -( -) -{ -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -sid -0 -) -; -/ -/ -Since -reverse -searches -report -the -beginning -of -a -/ -/ -match -and -the -beginning -is -inclusive -( -not -exclusive -/ -/ -like -the -end -of -a -match -) -we -add -1 -to -make -it -/ -/ -inclusive -. -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -at -+ -1 -) -) -; -} -else -if -sid -. -is_dead -( -) -{ -return -Ok -( -mat -) -; -} -else -if -sid -. -is_quit -( -) -{ -if -mat -. -is_some -( -) -{ -return -Ok -( -mat -) -; -} -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -at -] -at -) -. -into -( -) -) -; -} -} -if -at -= -= -input -. -start -( -) -{ -break -; -} -at -- -= -1 -; -if -at -< -min_start -{ -trace -! -( -" -reached -position -{ -} -which -is -before -the -previous -literal -\ -match -quitting -to -avoid -quadratic -behavior -" -at -) -; -return -Err -( -RetryError -: -: -Quadratic -( -RetryQuadraticError -: -: -new -( -) -) -) -; -} -} -let -was_dead -= -sid -. -is_dead -( -) -; -hybrid_eoi_rev -( -dfa -cache -input -& -mut -sid -& -mut -mat -) -? -; -/ -/ -See -the -comments -in -the -full -DFA -routine -above -for -why -we -need -this -. -if -at -= -= -input -. -start -( -) -& -& -mat -. -map_or -( -false -| -m -| -m -. -offset -( -) -> -input -. -start -( -) -) -& -& -! -was_dead -{ -trace -! -( -" -reached -beginning -of -search -at -offset -{ -} -without -hitting -\ -a -dead -state -quitting -to -avoid -potential -false -positive -match -" -at -) -; -return -Err -( -RetryError -: -: -Quadratic -( -RetryQuadraticError -: -: -new -( -) -) -) -; -} -Ok -( -mat -) -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -dfa_eoi_rev -( -dfa -: -& -crate -: -: -dfa -: -: -dense -: -: -DFA -< -alloc -: -: -vec -: -: -Vec -< -u32 -> -> -input -: -& -Input -< -' -_ -> -sid -: -& -mut -crate -: -: -util -: -: -primitives -: -: -StateID -mat -: -& -mut -Option -< -HalfMatch -> -) -- -> -Result -< -( -) -MatchError -> -{ -use -crate -: -: -dfa -: -: -Automaton -; -let -sp -= -input -. -get_span -( -) -; -if -sp -. -start -> -0 -{ -let -byte -= -input -. -haystack -( -) -[ -sp -. -start -- -1 -] -; -* -sid -= -dfa -. -next_state -( -* -sid -byte -) -; -if -dfa -. -is_match_state -( -* -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -sp -. -start -) -) -; -} -else -if -dfa -. -is_quit_state -( -* -sid -) -{ -if -mat -. -is_some -( -) -{ -return -Ok -( -( -) -) -; -} -return -Err -( -MatchError -: -: -quit -( -byte -sp -. -start -- -1 -) -) -; -} -} -else -{ -* -sid -= -dfa -. -next_eoi_state -( -* -sid -) -; -if -dfa -. -is_match_state -( -* -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -0 -) -) -; -} -/ -/ -N -. -B -. -We -don -' -t -have -to -check -' -is_quit -' -here -because -the -EOI -/ -/ -transition -can -never -lead -to -a -quit -state -. -debug_assert -! -( -! -dfa -. -is_quit_state -( -* -sid -) -) -; -} -Ok -( -( -) -) -} -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -hybrid_eoi_rev -( -dfa -: -& -crate -: -: -hybrid -: -: -dfa -: -: -DFA -cache -: -& -mut -crate -: -: -hybrid -: -: -dfa -: -: -Cache -input -: -& -Input -< -' -_ -> -sid -: -& -mut -crate -: -: -hybrid -: -: -LazyStateID -mat -: -& -mut -Option -< -HalfMatch -> -) -- -> -Result -< -( -) -MatchError -> -{ -let -sp -= -input -. -get_span -( -) -; -if -sp -. -start -> -0 -{ -let -byte -= -input -. -haystack -( -) -[ -sp -. -start -- -1 -] -; -* -sid -= -dfa -. -next_state -( -cache -* -sid -byte -) -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -sp -. -start -) -) -? -; -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -sp -. -start -) -) -; -} -else -if -sid -. -is_quit -( -) -{ -if -mat -. -is_some -( -) -{ -return -Ok -( -( -) -) -; -} -return -Err -( -MatchError -: -: -quit -( -byte -sp -. -start -- -1 -) -) -; -} -} -else -{ -* -sid -= -dfa -. -next_eoi_state -( -cache -* -sid -) -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -sp -. -start -) -) -? -; -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -0 -) -) -; -} -/ -/ -N -. -B -. -We -don -' -t -have -to -check -' -is_quit -' -here -because -the -EOI -/ -/ -transition -can -never -lead -to -a -quit -state -. -debug_assert -! -( -! -sid -. -is_quit -( -) -) -; -} -Ok -( -( -) -) -} diff --git a/third_party/rust/regex-automata/src/meta/literal.rs b/third_party/rust/regex-automata/src/meta/literal.rs deleted file mode 100644 index 4626472fb8bf3..0000000000000 --- a/third_party/rust/regex-automata/src/meta/literal.rs +++ /dev/null @@ -1,782 +0,0 @@ -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -regex_syntax -: -: -hir -: -: -Hir -; -use -crate -: -: -{ -meta -: -: -regex -: -: -RegexInfo -util -: -: -search -: -: -MatchKind -} -; -/ -/ -/ -Pull -out -an -alternation -of -literals -from -the -given -sequence -of -HIR -/ -/ -/ -expressions -. -/ -/ -/ -/ -/ -/ -There -are -numerous -ways -for -this -to -fail -. -Generally -this -only -applies -/ -/ -/ -to -regexes -of -the -form -' -foo -| -bar -| -baz -| -. -. -. -| -quux -' -. -It -can -also -fail -if -there -/ -/ -/ -are -" -too -few -" -alternates -in -which -case -the -regex -engine -is -likely -faster -. -/ -/ -/ -/ -/ -/ -And -currently -this -only -returns -something -when -' -hirs -. -len -( -) -= -= -1 -' -. -pub -( -crate -) -fn -alternation_literals -( -info -: -& -RegexInfo -hirs -: -& -[ -& -Hir -] -) -- -> -Option -< -Vec -< -Vec -< -u8 -> -> -> -{ -use -regex_syntax -: -: -hir -: -: -{ -HirKind -Literal -} -; -/ -/ -Might -as -well -skip -the -work -below -if -we -know -we -can -' -t -build -an -/ -/ -Aho -- -Corasick -searcher -. -if -! -cfg -! -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -{ -return -None -; -} -/ -/ -This -is -pretty -hacky -but -basically -if -is_alternation_literal -is -/ -/ -true -then -we -can -make -several -assumptions -about -the -structure -of -our -/ -/ -HIR -. -This -is -what -justifies -the -unreachable -! -statements -below -. -if -hirs -. -len -( -) -! -= -1 -| -| -! -info -. -props -( -) -[ -0 -] -. -look_set -( -) -. -is_empty -( -) -| -| -info -. -props -( -) -[ -0 -] -. -explicit_captures_len -( -) -> -0 -| -| -! -info -. -props -( -) -[ -0 -] -. -is_alternation_literal -( -) -| -| -info -. -config -( -) -. -get_match_kind -( -) -! -= -MatchKind -: -: -LeftmostFirst -{ -return -None -; -} -let -hir -= -& -hirs -[ -0 -] -; -let -alts -= -match -* -hir -. -kind -( -) -{ -HirKind -: -: -Alternation -( -ref -alts -) -= -> -alts -_ -= -> -return -None -/ -/ -one -literal -isn -' -t -worth -it -} -; -let -mut -lits -= -vec -! -[ -] -; -for -alt -in -alts -{ -let -mut -lit -= -vec -! -[ -] -; -match -* -alt -. -kind -( -) -{ -HirKind -: -: -Literal -( -Literal -( -ref -bytes -) -) -= -> -{ -lit -. -extend_from_slice -( -bytes -) -} -HirKind -: -: -Concat -( -ref -exprs -) -= -> -{ -for -e -in -exprs -{ -match -* -e -. -kind -( -) -{ -HirKind -: -: -Literal -( -Literal -( -ref -bytes -) -) -= -> -{ -lit -. -extend_from_slice -( -bytes -) -; -} -_ -= -> -unreachable -! -( -" -expected -literal -got -{ -: -? -} -" -e -) -} -} -} -_ -= -> -unreachable -! -( -" -expected -literal -or -concat -got -{ -: -? -} -" -alt -) -} -lits -. -push -( -lit -) -; -} -/ -/ -Why -do -this -? -Well -when -the -number -of -literals -is -small -it -' -s -likely -/ -/ -that -we -' -ll -use -the -lazy -DFA -which -is -in -turn -likely -to -be -faster -than -/ -/ -Aho -- -Corasick -in -such -cases -. -Primarily -because -Aho -- -Corasick -doesn -' -t -have -/ -/ -a -" -lazy -DFA -" -but -either -a -contiguous -NFA -or -a -full -DFA -. -We -rarely -use -/ -/ -the -latter -because -it -is -so -hungry -( -in -time -and -space -) -and -the -former -/ -/ -is -decently -fast -but -not -as -fast -as -a -well -oiled -lazy -DFA -. -/ -/ -/ -/ -However -once -the -number -starts -getting -large -the -lazy -DFA -is -likely -/ -/ -to -start -thrashing -because -of -the -modest -default -cache -size -. -When -/ -/ -exactly -does -this -happen -? -Dunno -. -But -at -whatever -point -that -is -( -we -make -/ -/ -a -guess -below -based -on -ad -hoc -benchmarking -) -we -' -ll -want -to -cut -over -to -/ -/ -Aho -- -Corasick -where -even -the -contiguous -NFA -is -likely -to -do -much -better -. -if -lits -. -len -( -) -< -3000 -{ -debug -! -( -" -skipping -Aho -- -Corasick -because -there -are -too -few -literals -" -) -; -return -None -; -} -Some -( -lits -) -} diff --git a/third_party/rust/regex-automata/src/meta/mod.rs b/third_party/rust/regex-automata/src/meta/mod.rs deleted file mode 100644 index 087374db4bf0d..0000000000000 --- a/third_party/rust/regex-automata/src/meta/mod.rs +++ /dev/null @@ -1,542 +0,0 @@ -/ -* -! -Provides -a -regex -matcher -that -composes -several -other -regex -matchers -automatically -. -This -module -is -home -to -a -meta -[ -Regex -] -which -provides -a -convenient -high -level -API -for -executing -regular -expressions -in -linear -time -. -# -Comparison -with -the -regex -crate -A -meta -Regex -is -the -implementation -used -directly -by -the -regex -crate -. -Indeed -the -regex -crate -API -is -essentially -just -a -light -wrapper -over -a -meta -Regex -. -This -means -that -if -you -need -the -full -flexibility -offered -by -this -API -then -you -should -be -able -to -switch -to -using -this -API -directly -without -any -changes -in -match -semantics -or -syntax -. -However -there -are -some -API -level -differences -: -* -The -regex -crate -API -returns -match -objects -that -include -references -to -the -haystack -itself -which -in -turn -makes -it -easy -to -access -the -matching -strings -without -having -to -slice -the -haystack -yourself -. -In -contrast -a -meta -Regex -returns -match -objects -that -only -have -offsets -in -them -. -* -At -time -of -writing -a -meta -Regex -doesn -' -t -have -some -of -the -convenience -routines -that -the -regex -crate -has -such -as -replacements -. -Note -though -that -[ -Captures -: -: -interpolate_string -] -( -crate -: -: -util -: -: -captures -: -: -Captures -: -: -interpolate_string -) -will -handle -the -replacement -string -interpolation -for -you -. -* -A -meta -Regex -supports -the -[ -Input -] -( -crate -: -: -Input -) -abstraction -which -provides -a -way -to -configure -a -search -in -more -ways -than -is -supported -by -the -regex -crate -. -For -example -[ -Input -: -: -anchored -] -( -crate -: -: -Input -: -: -anchored -) -can -be -used -to -run -an -anchored -search -regardless -of -whether -the -pattern -is -itself -anchored -with -a -^ -. -* -A -meta -Regex -supports -multi -- -pattern -searching -everywhere -. -Indeed -every -[ -Match -] -( -crate -: -: -Match -) -returned -by -the -search -APIs -include -a -[ -PatternID -] -( -crate -: -: -PatternID -) -indicating -which -pattern -matched -. -In -the -single -pattern -case -all -matches -correspond -to -[ -PatternID -: -: -ZERO -] -( -crate -: -: -PatternID -: -: -ZERO -) -. -In -contrast -the -regex -crate -has -distinct -Regex -and -a -RegexSet -APIs -. -The -former -only -supports -a -single -pattern -while -the -latter -supports -multiple -patterns -but -cannot -report -the -offsets -of -a -match -. -* -A -meta -Regex -provides -the -explicit -capability -of -bypassing -its -internal -memory -pool -for -automatically -acquiring -mutable -scratch -space -required -by -its -internal -regex -engines -. -Namely -a -[ -Cache -] -can -be -explicitly -provided -to -lower -level -routines -such -as -[ -Regex -: -: -search_with -] -. -* -/ -pub -use -self -: -: -{ -error -: -: -BuildError -regex -: -: -{ -Builder -Cache -CapturesMatches -Config -FindMatches -Regex -Split -SplitN -} -} -; -mod -error -; -# -[ -cfg -( -any -( -feature -= -" -dfa -- -build -" -feature -= -" -hybrid -" -) -) -] -mod -limited -; -mod -literal -; -mod -regex -; -mod -reverse_inner -; -# -[ -cfg -( -any -( -feature -= -" -dfa -- -build -" -feature -= -" -hybrid -" -) -) -] -mod -stopat -; -mod -strategy -; -mod -wrappers -; diff --git a/third_party/rust/regex-automata/src/meta/regex.rs b/third_party/rust/regex-automata/src/meta/regex.rs deleted file mode 100644 index be63f0216ed06..0000000000000 --- a/third_party/rust/regex-automata/src/meta/regex.rs +++ /dev/null @@ -1,39751 +0,0 @@ -use -core -: -: -{ -borrow -: -: -Borrow -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -} -; -use -alloc -: -: -{ -boxed -: -: -Box -sync -: -: -Arc -vec -vec -: -: -Vec -} -; -use -regex_syntax -: -: -{ -ast -hir -: -: -{ -self -Hir -} -} -; -use -crate -: -: -{ -meta -: -: -{ -error -: -: -BuildError -strategy -: -: -{ -self -Strategy -} -wrappers -} -nfa -: -: -thompson -: -: -WhichCaptures -util -: -: -{ -captures -: -: -{ -Captures -GroupInfo -} -iter -pool -: -: -{ -Pool -PoolGuard -} -prefilter -: -: -Prefilter -primitives -: -: -{ -NonMaxUsize -PatternID -} -search -: -: -{ -HalfMatch -Input -Match -MatchKind -PatternSet -Span -} -} -} -; -/ -/ -/ -A -type -alias -for -our -pool -of -meta -: -: -Cache -that -fixes -the -type -parameters -to -/ -/ -/ -what -we -use -for -the -meta -regex -below -. -type -CachePool -= -Pool -< -Cache -CachePoolFn -> -; -/ -/ -/ -Same -as -above -but -for -the -guard -returned -by -a -pool -. -type -CachePoolGuard -< -' -a -> -= -PoolGuard -< -' -a -Cache -CachePoolFn -> -; -/ -/ -/ -The -type -of -the -closure -we -use -to -create -new -caches -. -We -need -to -spell -out -/ -/ -/ -all -of -the -marker -traits -or -else -we -risk -leaking -! -MARKER -impls -. -type -CachePoolFn -= -Box -< -dyn -Fn -( -) -- -> -Cache -+ -Send -+ -Sync -+ -UnwindSafe -+ -RefUnwindSafe -> -; -/ -/ -/ -A -regex -matcher -that -works -by -composing -several -other -regex -matchers -/ -/ -/ -automatically -. -/ -/ -/ -/ -/ -/ -In -effect -a -meta -regex -papers -over -a -lot -of -the -quirks -or -performance -/ -/ -/ -problems -in -each -of -the -regex -engines -in -this -crate -. -Its -goal -is -to -provide -/ -/ -/ -an -infallible -and -simple -API -that -" -just -does -the -right -thing -" -in -the -common -/ -/ -/ -case -. -/ -/ -/ -/ -/ -/ -A -meta -regex -is -the -implementation -of -a -Regex -in -the -regex -crate -. -/ -/ -/ -Indeed -the -regex -crate -API -is -essentially -just -a -light -wrapper -over -/ -/ -/ -this -type -. -This -includes -the -regex -crate -' -s -RegexSet -API -! -/ -/ -/ -/ -/ -/ -# -Composition -/ -/ -/ -/ -/ -/ -This -is -called -a -" -meta -" -matcher -precisely -because -it -uses -other -regex -/ -/ -/ -matchers -to -provide -a -convenient -high -level -regex -API -. -Here -are -some -/ -/ -/ -examples -of -how -other -regex -matchers -are -composed -: -/ -/ -/ -/ -/ -/ -* -When -calling -[ -Regex -: -: -captures -] -instead -of -immediately -/ -/ -/ -running -a -slower -but -more -capable -regex -engine -like -the -/ -/ -/ -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -the -meta -regex -engine -/ -/ -/ -will -usually -first -look -for -the -bounds -of -a -match -with -a -higher -throughput -/ -/ -/ -regex -engine -like -a -[ -lazy -DFA -] -( -crate -: -: -hybrid -) -. -Only -when -a -match -is -found -/ -/ -/ -is -a -slower -engine -like -PikeVM -used -to -find -the -matching -span -for -each -/ -/ -/ -capture -group -. -/ -/ -/ -* -While -higher -throughout -engines -like -the -lazy -DFA -cannot -handle -/ -/ -/ -Unicode -word -boundaries -in -general -they -can -still -be -used -on -pure -ASCII -/ -/ -/ -haystacks -by -pretending -that -Unicode -word -boundaries -are -just -plain -ASCII -/ -/ -/ -word -boundaries -. -However -if -a -haystack -is -not -ASCII -the -meta -regex -engine -/ -/ -/ -will -automatically -switch -to -a -( -possibly -slower -) -regex -engine -that -supports -/ -/ -/ -Unicode -word -boundaries -in -general -. -/ -/ -/ -* -In -some -cases -where -a -regex -pattern -is -just -a -simple -literal -or -a -small -/ -/ -/ -set -of -literals -an -actual -regex -engine -won -' -t -be -used -at -all -. -Instead -/ -/ -/ -substring -or -multi -- -substring -search -algorithms -will -be -employed -. -/ -/ -/ -/ -/ -/ -There -are -many -other -forms -of -composition -happening -too -but -the -above -/ -/ -/ -should -give -a -general -idea -. -In -particular -it -may -perhaps -be -surprising -/ -/ -/ -that -* -multiple -* -regex -engines -might -get -executed -for -a -single -search -. -That -/ -/ -/ -is -the -decision -of -what -regex -engine -to -use -is -not -_just_ -based -on -the -/ -/ -/ -pattern -but -also -based -on -the -dynamic -execution -of -the -search -itself -. -/ -/ -/ -/ -/ -/ -The -primary -reason -for -this -composition -is -performance -. -The -fundamental -/ -/ -/ -tension -is -that -the -faster -engines -tend -to -be -less -capable -and -the -more -/ -/ -/ -capable -engines -tend -to -be -slower -. -/ -/ -/ -/ -/ -/ -Note -that -the -forms -of -composition -that -are -allowed -are -determined -by -/ -/ -/ -compile -time -crate -features -and -configuration -. -For -example -if -the -hybrid -/ -/ -/ -feature -isn -' -t -enabled -or -if -[ -Config -: -: -hybrid -] -has -been -disabled -then -the -/ -/ -/ -meta -regex -engine -will -never -use -a -lazy -DFA -. -/ -/ -/ -/ -/ -/ -# -Synchronization -and -cloning -/ -/ -/ -/ -/ -/ -Most -of -the -regex -engines -in -this -crate -require -some -kind -of -mutable -/ -/ -/ -" -scratch -" -space -to -read -and -write -from -while -performing -a -search -. -Since -/ -/ -/ -a -meta -regex -composes -these -regex -engines -a -meta -regex -also -requires -/ -/ -/ -mutable -scratch -space -. -This -scratch -space -is -called -a -[ -Cache -] -. -/ -/ -/ -/ -/ -/ -Most -regex -engines -_also_ -usually -have -a -read -- -only -component -typically -/ -/ -/ -a -[ -Thompson -NFA -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -) -. -/ -/ -/ -/ -/ -/ -In -order -to -make -the -Regex -API -convenient -most -of -the -routines -hide -/ -/ -/ -the -fact -that -a -Cache -is -needed -at -all -. -To -achieve -this -a -[ -memory -/ -/ -/ -pool -] -( -crate -: -: -util -: -: -pool -: -: -Pool -) -is -used -internally -to -retrieve -Cache -/ -/ -/ -values -in -a -thread -safe -way -that -also -permits -reuse -. -This -in -turn -implies -/ -/ -/ -that -every -such -search -call -requires -some -form -of -synchronization -. -Usually -/ -/ -/ -this -synchronization -is -fast -enough -to -not -notice -but -in -some -cases -it -/ -/ -/ -can -be -a -bottleneck -. -This -typically -occurs -when -all -of -the -following -are -/ -/ -/ -true -: -/ -/ -/ -/ -/ -/ -* -The -same -Regex -is -shared -across -multiple -threads -simultaneously -/ -/ -/ -usually -via -a -[ -util -: -: -lazy -: -: -Lazy -] -( -crate -: -: -util -: -: -lazy -: -: -Lazy -) -or -something -/ -/ -/ -similar -from -the -once_cell -or -lazy_static -crates -. -/ -/ -/ -* -The -primary -unit -of -work -in -each -thread -is -a -regex -search -. -/ -/ -/ -* -Searches -are -run -on -very -short -haystacks -. -/ -/ -/ -/ -/ -/ -This -particular -case -can -lead -to -high -contention -on -the -pool -used -by -a -/ -/ -/ -Regex -internally -which -can -in -turn -increase -latency -to -a -noticeable -/ -/ -/ -effect -. -This -cost -can -be -mitigated -in -one -of -the -following -ways -: -/ -/ -/ -/ -/ -/ -* -Use -a -distinct -copy -of -a -Regex -in -each -thread -usually -by -cloning -it -. -/ -/ -/ -Cloning -a -Regex -_does -not_ -do -a -deep -copy -of -its -read -- -only -component -. -/ -/ -/ -But -it -does -lead -to -each -Regex -having -its -own -memory -pool -which -in -/ -/ -/ -turn -eliminates -the -problem -of -contention -. -In -general -this -technique -should -/ -/ -/ -not -result -in -any -additional -memory -usage -when -compared -to -sharing -the -same -/ -/ -/ -Regex -across -multiple -threads -simultaneously -. -/ -/ -/ -* -Use -lower -level -APIs -like -[ -Regex -: -: -search_with -] -which -permit -passing -/ -/ -/ -a -Cache -explicitly -. -In -this -case -it -is -up -to -you -to -determine -how -best -/ -/ -/ -to -provide -a -Cache -. -For -example -you -might -put -a -Cache -in -thread -- -local -/ -/ -/ -storage -if -your -use -case -allows -for -it -. -/ -/ -/ -/ -/ -/ -Overall -this -is -an -issue -that -happens -rarely -in -practice -but -it -can -/ -/ -/ -happen -. -/ -/ -/ -/ -/ -/ -# -Warning -: -spin -- -locks -may -be -used -in -alloc -- -only -mode -/ -/ -/ -/ -/ -/ -When -this -crate -is -built -without -the -std -feature -and -the -high -level -APIs -/ -/ -/ -on -a -Regex -are -used -then -a -spin -- -lock -will -be -used -to -synchronize -access -/ -/ -/ -to -an -internal -pool -of -Cache -values -. -This -may -be -undesirable -because -/ -/ -/ -a -spin -- -lock -is -[ -effectively -impossible -to -implement -correctly -in -user -/ -/ -/ -space -] -[ -spinlocks -- -are -- -bad -] -. -That -is -more -concretely -the -spin -- -lock -could -/ -/ -/ -result -in -a -deadlock -. -/ -/ -/ -/ -/ -/ -[ -spinlocks -- -are -- -bad -] -: -https -: -/ -/ -matklad -. -github -. -io -/ -2020 -/ -01 -/ -02 -/ -spinlocks -- -considered -- -harmful -. -html -/ -/ -/ -/ -/ -/ -If -one -wants -to -avoid -the -use -of -spin -- -locks -when -the -std -feature -is -/ -/ -/ -disabled -then -you -must -use -APIs -that -accept -a -Cache -value -explicitly -. -/ -/ -/ -For -example -[ -Regex -: -: -search_with -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -^ -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -? -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -2010 -- -03 -- -14 -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -anchored -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -[ -Input -: -: -anchored -] -to -run -an -anchored -/ -/ -/ -search -even -when -the -regex -pattern -itself -isn -' -t -anchored -. -An -anchored -/ -/ -/ -search -guarantees -that -if -a -match -is -found -then -the -start -offset -of -the -/ -/ -/ -match -corresponds -to -the -offset -at -which -the -search -was -started -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Anchored -Input -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bfoo -\ -b -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -xx -foo -xx -" -) -. -range -( -3 -. -. -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -/ -/ -The -offsets -are -in -terms -of -the -original -haystack -. -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -3 -. -. -6 -) -) -re -. -find -( -input -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -no -match -occurs -here -because -\ -b -still -takes -the -/ -/ -/ -/ -/ -surrounding -context -into -account -even -if -it -means -looking -back -/ -/ -/ -/ -/ -before -the -start -of -your -search -. -/ -/ -/ -let -hay -= -" -xxfoo -xx -" -; -/ -/ -/ -let -input -= -Input -: -: -new -( -hay -) -. -range -( -2 -. -. -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -input -) -) -; -/ -/ -/ -/ -/ -Indeed -you -cannot -achieve -the -above -by -simply -slicing -the -/ -/ -/ -/ -/ -haystack -itself -since -the -regex -engine -can -' -t -see -the -/ -/ -/ -/ -/ -surrounding -context -. -This -is -why -' -Input -' -permits -setting -/ -/ -/ -/ -/ -the -bounds -of -a -search -! -/ -/ -/ -let -input -= -Input -: -: -new -( -& -hay -[ -2 -. -. -] -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -/ -/ -WRONG -! -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -re -. -find -( -input -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -earliest -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -[ -Input -: -: -earliest -] -to -run -a -search -that -/ -/ -/ -might -stop -before -finding -the -typical -leftmost -match -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Anchored -Input -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -- -z -] -{ -3 -} -| -b -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -abc -" -) -. -earliest -( -true -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -2 -) -) -re -. -find -( -input -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -" -earliest -" -isn -' -t -really -a -match -semantic -unto -itself -. -/ -/ -/ -/ -/ -Instead -it -is -merely -an -instruction -to -whatever -regex -engine -/ -/ -/ -/ -/ -gets -used -internally -to -quit -as -soon -as -it -can -. -For -example -/ -/ -/ -/ -/ -this -regex -uses -a -different -search -technique -and -winds -up -/ -/ -/ -/ -/ -producing -a -different -( -but -valid -) -match -! -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -abc -| -b -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -abc -" -) -. -earliest -( -true -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -re -. -find -( -input -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -change -the -line -terminator -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -enable -multi -- -line -mode -by -default -and -change -/ -/ -/ -the -line -terminator -to -the -NUL -byte -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -multi_line -( -true -) -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -line_terminator -( -b -' -\ -x00 -' -) -) -/ -/ -/ -. -build -( -r -" -^ -foo -" -) -? -; -/ -/ -/ -let -hay -= -" -\ -x00foo -\ -x00 -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -4 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Debug -) -] -pub -struct -Regex -{ -/ -/ -/ -The -actual -regex -implementation -. -imp -: -Arc -< -RegexI -> -/ -/ -/ -A -thread -safe -pool -of -caches -. -/ -/ -/ -/ -/ -/ -For -the -higher -level -search -APIs -a -Cache -is -automatically -plucked -/ -/ -/ -from -this -pool -before -running -a -search -. -The -lower -level -with -methods -/ -/ -/ -permit -the -caller -to -provide -their -own -cache -thereby -bypassing -/ -/ -/ -accesses -to -this -pool -. -/ -/ -/ -/ -/ -/ -Note -that -we -put -this -outside -the -Arc -so -that -cloning -a -Regex -/ -/ -/ -results -in -creating -a -fresh -CachePool -. -This -in -turn -permits -callers -/ -/ -/ -to -clone -regexes -into -separate -threads -where -each -such -regex -gets -/ -/ -/ -the -pool -' -s -" -thread -owner -" -optimization -. -Otherwise -if -one -shares -the -/ -/ -/ -Regex -directly -then -the -pool -will -go -through -a -slower -mutex -path -for -/ -/ -/ -all -threads -except -for -the -" -owner -. -" -pool -: -CachePool -} -/ -/ -/ -The -internal -implementation -of -Regex -split -out -so -that -it -can -be -wrapped -/ -/ -/ -in -an -Arc -. -# -[ -derive -( -Debug -) -] -struct -RegexI -{ -/ -/ -/ -The -core -matching -engine -. -/ -/ -/ -/ -/ -/ -Why -is -this -reference -counted -when -RegexI -is -already -wrapped -in -an -Arc -? -/ -/ -/ -Well -we -need -to -capture -this -in -a -closure -to -our -Pool -below -in -order -/ -/ -/ -to -create -new -Cache -values -when -needed -. -So -since -it -needs -to -be -in -/ -/ -/ -two -places -we -make -it -reference -counted -. -/ -/ -/ -/ -/ -/ -We -make -RegexI -itself -reference -counted -too -so -that -Regex -itself -/ -/ -/ -stays -extremely -small -and -very -cheap -to -clone -. -strat -: -Arc -< -dyn -Strategy -> -/ -/ -/ -Metadata -about -the -regexes -driving -the -strategy -. -The -metadata -is -also -/ -/ -/ -usually -stored -inside -the -strategy -too -but -we -put -it -here -as -well -/ -/ -/ -so -that -we -can -get -quick -access -to -it -( -without -virtual -calls -) -before -/ -/ -/ -executing -the -regex -engine -. -For -example -we -use -this -metadata -to -/ -/ -/ -detect -a -subset -of -cases -where -we -know -a -match -is -impossible -and -can -/ -/ -/ -thus -avoid -calling -into -the -strategy -at -all -. -/ -/ -/ -/ -/ -/ -Since -RegexInfo -is -stored -in -multiple -places -it -is -also -reference -/ -/ -/ -counted -. -info -: -RegexInfo -} -/ -/ -/ -Convenience -constructors -for -a -Regex -using -the -default -configuration -. -impl -Regex -{ -/ -/ -/ -Builds -a -Regex -from -a -single -pattern -string -using -the -default -/ -/ -/ -configuration -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -the -pattern -or -a -problem -turning -it -into -/ -/ -/ -a -regex -matcher -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -If -you -want -to -change -the -configuration -of -a -Regex -use -a -[ -Builder -] -/ -/ -/ -with -a -[ -Config -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -Rm -) -^ -foo -" -) -? -; -/ -/ -/ -let -hay -= -" -\ -r -\ -nfoo -\ -r -\ -n -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -5 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -Regex -BuildError -> -{ -Regex -: -: -builder -( -) -. -build -( -pattern -) -} -/ -/ -/ -Builds -a -Regex -from -many -pattern -strings -using -the -default -/ -/ -/ -configuration -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -any -of -the -patterns -or -a -problem -turning -/ -/ -/ -them -into -a -regex -matcher -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -If -you -want -to -change -the -configuration -of -a -Regex -use -a -[ -Builder -] -/ -/ -/ -with -a -[ -Config -] -. -/ -/ -/ -/ -/ -/ -# -Example -: -simple -lexer -/ -/ -/ -/ -/ -/ -This -simplistic -example -leverages -the -multi -- -pattern -support -to -build -a -/ -/ -/ -simple -little -lexer -. -The -pattern -ID -in -the -match -tells -you -which -regex -/ -/ -/ -matched -which -in -turn -might -be -used -to -map -back -to -the -" -type -" -of -the -/ -/ -/ -token -returned -by -the -lexer -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -/ -/ -/ -r -" -[ -[ -: -space -: -] -] -" -/ -/ -/ -r -" -[ -A -- -Za -- -z0 -- -9 -] -[ -A -- -Za -- -z0 -- -9_ -] -+ -" -/ -/ -/ -r -" -- -> -" -/ -/ -/ -r -" -. -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -haystack -= -" -fn -is_boss -( -bruce -: -i32 -springsteen -: -String -) -- -> -bool -; -" -; -/ -/ -/ -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -haystack -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Match -: -: -must -( -1 -0 -. -. -2 -) -/ -/ -' -fn -' -/ -/ -/ -Match -: -: -must -( -0 -2 -. -. -3 -) -/ -/ -' -' -/ -/ -/ -Match -: -: -must -( -1 -3 -. -. -10 -) -/ -/ -' -is_boss -' -/ -/ -/ -Match -: -: -must -( -3 -10 -. -. -11 -) -/ -/ -' -( -' -/ -/ -/ -Match -: -: -must -( -1 -11 -. -. -16 -) -/ -/ -' -bruce -' -/ -/ -/ -Match -: -: -must -( -3 -16 -. -. -17 -) -/ -/ -' -: -' -/ -/ -/ -Match -: -: -must -( -0 -17 -. -. -18 -) -/ -/ -' -' -/ -/ -/ -Match -: -: -must -( -1 -18 -. -. -21 -) -/ -/ -' -i32 -' -/ -/ -/ -Match -: -: -must -( -3 -21 -. -. -22 -) -/ -/ -' -' -/ -/ -/ -Match -: -: -must -( -0 -22 -. -. -23 -) -/ -/ -' -' -/ -/ -/ -Match -: -: -must -( -1 -23 -. -. -34 -) -/ -/ -' -springsteen -' -/ -/ -/ -Match -: -: -must -( -3 -34 -. -. -35 -) -/ -/ -' -: -' -/ -/ -/ -Match -: -: -must -( -0 -35 -. -. -36 -) -/ -/ -' -' -/ -/ -/ -Match -: -: -must -( -1 -36 -. -. -42 -) -/ -/ -' -String -' -/ -/ -/ -Match -: -: -must -( -3 -42 -. -. -43 -) -/ -/ -' -) -' -/ -/ -/ -Match -: -: -must -( -0 -43 -. -. -44 -) -/ -/ -' -' -/ -/ -/ -Match -: -: -must -( -2 -44 -. -. -46 -) -/ -/ -' -- -> -' -/ -/ -/ -Match -: -: -must -( -0 -46 -. -. -47 -) -/ -/ -' -' -/ -/ -/ -Match -: -: -must -( -1 -47 -. -. -51 -) -/ -/ -' -bool -' -/ -/ -/ -Match -: -: -must -( -3 -51 -. -. -52 -) -/ -/ -' -; -' -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -One -can -write -a -lexer -like -the -above -using -a -regex -like -/ -/ -/ -( -? -P -< -space -> -[ -[ -: -space -: -] -] -) -| -( -? -P -< -ident -> -[ -A -- -Za -- -z0 -- -9 -] -[ -A -- -Za -- -z0 -- -9_ -] -+ -) -| -. -. -. -/ -/ -/ -but -then -you -need -to -ask -whether -capture -group -matched -to -determine -/ -/ -/ -which -branch -in -the -regex -matched -and -thus -which -token -the -match -/ -/ -/ -corresponds -to -. -In -contrast -the -above -example -includes -the -pattern -ID -/ -/ -/ -in -the -match -. -There -' -s -no -need -to -use -capture -groups -at -all -. -/ -/ -/ -/ -/ -/ -# -Example -: -finding -the -pattern -that -caused -an -error -/ -/ -/ -/ -/ -/ -When -a -syntax -error -occurs -it -is -possible -to -ask -which -pattern -/ -/ -/ -caused -the -syntax -error -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -err -= -Regex -: -: -new_many -( -& -[ -" -a -" -" -b -" -r -" -\ -p -{ -Foo -} -" -" -c -" -] -) -. -unwrap_err -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -2 -) -) -err -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -zero -patterns -is -valid -/ -/ -/ -/ -/ -/ -Building -a -regex -with -zero -patterns -results -in -a -regex -that -never -/ -/ -/ -matches -anything -. -Because -this -routine -is -generic -passing -an -empty -/ -/ -/ -slice -usually -requires -a -turbo -- -fish -( -or -something -else -to -help -type -/ -/ -/ -inference -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -: -: -< -& -str -> -( -& -[ -] -) -? -; -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -" -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -Regex -BuildError -> -{ -Regex -: -: -builder -( -) -. -build_many -( -patterns -) -} -/ -/ -/ -Return -a -default -configuration -for -a -Regex -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -[ -Config -] -/ -/ -/ -type -when -customizing -the -construction -of -a -Regex -. -/ -/ -/ -/ -/ -/ -# -Example -: -lower -the -NFA -size -limit -/ -/ -/ -/ -/ -/ -In -some -cases -the -default -size -limit -might -be -too -big -. -The -size -limit -/ -/ -/ -can -be -lowered -which -will -prevent -large -regex -patterns -from -compiling -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -result -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -nfa_size_limit -( -Some -( -20 -* -( -1 -< -< -10 -) -) -) -) -/ -/ -/ -/ -/ -Not -even -20KB -is -enough -to -build -a -single -large -Unicode -class -! -/ -/ -/ -. -build -( -r -" -\ -pL -" -) -; -/ -/ -/ -assert -! -( -result -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -config -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -/ -/ -/ -Return -a -builder -for -configuring -the -construction -of -a -Regex -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Builder -] -type -in -common -cases -. -/ -/ -/ -/ -/ -/ -# -Example -: -change -the -line -terminator -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -enable -multi -- -line -mode -by -default -and -change -/ -/ -/ -the -line -terminator -to -the -NUL -byte -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -multi_line -( -true -) -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -line_terminator -( -b -' -\ -x00 -' -) -) -/ -/ -/ -. -build -( -r -" -^ -foo -" -) -? -; -/ -/ -/ -let -hay -= -" -\ -x00foo -\ -x00 -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -4 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -} -/ -/ -/ -High -level -convenience -routines -for -using -a -regex -to -search -a -haystack -. -impl -Regex -{ -/ -/ -/ -Returns -true -if -and -only -if -this -regex -matches -the -given -haystack -. -/ -/ -/ -/ -/ -/ -This -routine -may -short -circuit -if -it -knows -that -scanning -future -input -/ -/ -/ -will -never -lead -to -a -different -result -. -( -Consider -how -this -might -make -/ -/ -/ -a -difference -given -the -regex -a -+ -on -the -haystack -aaaaaaaaaaaaaaa -. -/ -/ -/ -This -routine -_may_ -stop -after -it -sees -the -first -a -but -routines -like -/ -/ -/ -find -need -to -continue -searching -because -+ -is -greedy -by -default -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -" -foo12345bar -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -foobar -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -consistency -with -search -APIs -/ -/ -/ -/ -/ -/ -is_match -is -guaranteed -to -return -true -whenever -find -returns -a -/ -/ -/ -match -. -This -includes -searches -that -are -executed -entirely -within -a -/ -/ -/ -codepoint -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -a -* -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -This -doesn -' -t -match -because -the -default -configuration -bans -empty -/ -/ -/ -/ -/ -matches -from -splitting -a -codepoint -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -when -UTF -- -8 -mode -is -disabled -then -the -above -reports -a -/ -/ -/ -match -because -the -restriction -against -zero -- -width -matches -that -split -a -/ -/ -/ -codepoint -has -been -lifted -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -utf8_empty -( -false -) -) -/ -/ -/ -. -build -( -" -a -* -" -) -? -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -1 -. -. -1 -) -) -/ -/ -/ -re -. -find -( -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -A -similar -idea -applies -when -using -line -anchors -with -CRLF -mode -enabled -/ -/ -/ -which -prevents -them -from -matching -between -a -\ -r -and -a -\ -n -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -Rm -: -) -" -) -? -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -Input -: -: -new -( -" -\ -r -\ -n -" -) -. -span -( -1 -. -. -1 -) -) -) -; -/ -/ -/ -/ -/ -A -regular -line -anchor -which -only -considers -\ -n -as -a -/ -/ -/ -/ -/ -line -terminator -will -match -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -m -: -) -" -) -? -; -/ -/ -/ -assert -! -( -re -. -is_match -( -Input -: -: -new -( -" -\ -r -\ -n -" -) -. -span -( -1 -. -. -1 -) -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -input -: -I -) -- -> -bool -{ -let -input -= -input -. -into -( -) -. -earliest -( -true -) -; -if -self -. -imp -. -info -. -is_impossible -( -& -input -) -{ -return -false -; -} -let -mut -guard -= -self -. -pool -. -get -( -) -; -let -result -= -self -. -imp -. -strat -. -is_match -( -& -mut -guard -& -input -) -; -/ -/ -See -' -Regex -: -: -search -' -for -why -we -put -the -guard -back -explicitly -. -PoolGuard -: -: -put -( -guard -) -; -result -} -/ -/ -/ -Executes -a -leftmost -search -and -returns -the -first -match -that -is -found -/ -/ -/ -if -one -exists -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -8 -) -) -re -. -find -( -" -foo12345 -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -input -: -I -) -- -> -Option -< -Match -> -{ -self -. -search -( -& -input -. -into -( -) -) -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -[ -Captures -] -/ -/ -/ -value -. -If -no -match -was -found -then -[ -Captures -: -: -is_match -] -is -guaranteed -/ -/ -/ -to -return -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -^ -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -? -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -" -2010 -- -03 -- -14 -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -4 -) -) -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -5 -. -. -7 -) -) -caps -. -get_group -( -2 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -8 -. -. -10 -) -) -caps -. -get_group -( -3 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -captures -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -input -: -I -caps -: -& -mut -Captures -) -{ -self -. -search_captures -( -& -input -. -into -( -) -caps -) -} -/ -/ -/ -Returns -an -iterator -over -all -non -- -overlapping -leftmost -matches -in -/ -/ -/ -the -given -haystack -. -If -no -match -exists -then -the -iterator -yields -no -/ -/ -/ -elements -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -haystack -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -haystack -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -4 -) -/ -/ -/ -Match -: -: -must -( -0 -5 -. -. -10 -) -/ -/ -/ -Match -: -: -must -( -0 -11 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find_iter -< -' -r -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -input -: -I -) -- -> -FindMatches -< -' -r -' -h -> -{ -let -cache -= -self -. -pool -. -get -( -) -; -let -it -= -iter -: -: -Searcher -: -: -new -( -input -. -into -( -) -) -; -FindMatches -{ -re -: -self -cache -it -} -} -/ -/ -/ -Returns -an -iterator -over -all -non -- -overlapping -Captures -values -. -If -no -/ -/ -/ -match -exists -then -the -iterator -yields -no -elements -. -/ -/ -/ -/ -/ -/ -This -yields -the -same -matches -as -[ -Regex -: -: -find_iter -] -but -it -includes -/ -/ -/ -the -spans -of -all -capturing -groups -that -participate -in -each -match -. -/ -/ -/ -/ -/ -/ -* -* -Tip -: -* -* -See -[ -util -: -: -iter -: -: -Searcher -] -( -crate -: -: -util -: -: -iter -: -: -Searcher -) -for -/ -/ -/ -how -to -correctly -iterate -over -all -matches -in -a -haystack -while -avoiding -/ -/ -/ -the -creation -of -a -new -Captures -value -for -every -match -. -( -Which -you -are -/ -/ -/ -forced -to -do -with -an -Iterator -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -foo -( -? -P -< -numbers -> -[ -0 -- -9 -] -+ -) -" -) -? -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -let -matches -: -Vec -< -Span -> -= -re -/ -/ -/ -. -captures_iter -( -haystack -) -/ -/ -/ -/ -/ -The -unwrap -is -OK -since -' -numbers -' -matches -if -the -pattern -matches -. -/ -/ -/ -. -map -( -| -caps -| -caps -. -get_group_by_name -( -" -numbers -" -) -. -unwrap -( -) -) -/ -/ -/ -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Span -: -: -from -( -3 -. -. -4 -) -/ -/ -/ -Span -: -: -from -( -8 -. -. -10 -) -/ -/ -/ -Span -: -: -from -( -14 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -captures_iter -< -' -r -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -input -: -I -) -- -> -CapturesMatches -< -' -r -' -h -> -{ -let -cache -= -self -. -pool -. -get -( -) -; -let -caps -= -self -. -create_captures -( -) -; -let -it -= -iter -: -: -Searcher -: -: -new -( -input -. -into -( -) -) -; -CapturesMatches -{ -re -: -self -cache -caps -it -} -} -/ -/ -/ -Returns -an -iterator -of -spans -of -the -haystack -given -delimited -by -a -/ -/ -/ -match -of -the -regex -. -Namely -each -element -of -the -iterator -corresponds -to -/ -/ -/ -a -part -of -the -haystack -that -* -isn -' -t -* -matched -by -the -regular -expression -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -To -split -a -string -delimited -by -arbitrary -amounts -of -spaces -or -tabs -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -\ -t -] -+ -" -) -? -; -/ -/ -/ -let -hay -= -" -a -b -\ -t -c -\ -td -e -" -; -/ -/ -/ -let -fields -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -span -| -& -hay -[ -span -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -fields -vec -! -[ -" -a -" -" -b -" -" -c -" -" -d -" -" -e -" -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -more -cases -/ -/ -/ -/ -/ -/ -Basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -? -; -/ -/ -/ -let -hay -= -" -Mary -had -a -little -lamb -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -Mary -" -" -had -" -" -a -" -" -little -" -" -lamb -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -? -; -/ -/ -/ -let -hay -= -" -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -? -; -/ -/ -/ -let -hay -= -" -lionXXtigerXleopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -lion -" -" -" -" -tiger -" -" -leopard -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -: -: -" -) -? -; -/ -/ -/ -let -hay -= -" -lion -: -: -tiger -: -: -leopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -lion -" -" -tiger -" -" -leopard -" -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -If -a -haystack -contains -multiple -contiguous -matches -you -will -end -up -/ -/ -/ -with -empty -spans -yielded -by -the -iterator -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -? -; -/ -/ -/ -let -hay -= -" -XXXXaXXbXc -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -" -" -" -" -" -" -a -" -" -" -" -b -" -" -c -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -/ -" -) -? -; -/ -/ -/ -let -hay -= -" -( -/ -/ -/ -) -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -( -" -" -" -" -" -" -) -" -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Separators -at -the -start -or -end -of -a -haystack -are -neighbored -by -empty -/ -/ -/ -spans -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -0 -" -) -? -; -/ -/ -/ -let -hay -= -" -010 -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -1 -" -" -" -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -When -the -empty -string -is -used -as -a -regex -it -splits -at -every -valid -/ -/ -/ -UTF -- -8 -boundary -by -default -( -which -includes -the -beginning -and -end -of -the -/ -/ -/ -haystack -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -? -; -/ -/ -/ -let -hay -= -" -rust -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -r -" -" -u -" -" -s -" -" -t -" -" -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Splitting -by -an -empty -string -is -UTF -- -8 -aware -by -default -! -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -? -; -/ -/ -/ -let -hay -= -" -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -" -" -" -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -But -note -that -UTF -- -8 -mode -for -empty -strings -can -be -disabled -which -will -/ -/ -/ -then -result -in -a -match -at -every -byte -offset -in -the -haystack -/ -/ -/ -including -between -every -UTF -- -8 -code -unit -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -utf8_empty -( -false -) -) -/ -/ -/ -. -build -( -r -" -" -) -? -; -/ -/ -/ -let -hay -= -" -" -. -as_bytes -( -) -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -/ -/ -Writing -byte -string -slices -is -just -brutal -. -The -problem -is -that -/ -/ -/ -/ -/ -b -" -foo -" -has -type -& -[ -u8 -; -3 -] -instead -of -& -[ -u8 -] -. -/ -/ -/ -& -[ -] -[ -. -. -] -& -[ -b -' -\ -xE2 -' -] -[ -. -. -] -& -[ -b -' -\ -x98 -' -] -[ -. -. -] -& -[ -b -' -\ -x83 -' -] -[ -. -. -] -& -[ -] -[ -. -. -] -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Contiguous -separators -( -commonly -shows -up -with -whitespace -) -can -lead -to -/ -/ -/ -possibly -surprising -behavior -. -For -example -this -code -is -correct -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -? -; -/ -/ -/ -let -hay -= -" -a -b -c -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -" -" -" -" -" -" -a -" -" -" -" -b -" -" -c -" -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -It -does -* -not -* -give -you -[ -" -a -" -" -b -" -" -c -" -] -. -For -that -behavior -you -' -d -want -/ -/ -/ -to -match -contiguous -space -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -+ -" -) -? -; -/ -/ -/ -let -hay -= -" -a -b -c -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -/ -/ -N -. -B -. -This -does -still -include -a -leading -empty -span -because -' -+ -' -/ -/ -/ -/ -/ -matches -at -the -beginning -of -the -haystack -. -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -a -" -" -b -" -" -c -" -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -split -< -' -r -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -input -: -I -) -- -> -Split -< -' -r -' -h -> -{ -Split -{ -finder -: -self -. -find_iter -( -input -) -last -: -0 -} -} -/ -/ -/ -Returns -an -iterator -of -at -most -limit -spans -of -the -haystack -given -/ -/ -/ -delimited -by -a -match -of -the -regex -. -( -A -limit -of -0 -will -return -no -/ -/ -/ -spans -. -) -Namely -each -element -of -the -iterator -corresponds -to -a -part -/ -/ -/ -of -the -haystack -that -* -isn -' -t -* -matched -by -the -regular -expression -. -The -/ -/ -/ -remainder -of -the -haystack -that -is -not -split -will -be -the -last -element -in -/ -/ -/ -the -iterator -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Get -the -first -two -words -in -some -haystack -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -W -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Hey -! -How -are -you -? -" -; -/ -/ -/ -let -fields -: -Vec -< -& -str -> -= -/ -/ -/ -re -. -splitn -( -hay -3 -) -. -map -( -| -span -| -& -hay -[ -span -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -fields -vec -! -[ -" -Hey -" -" -How -" -" -are -you -? -" -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Examples -: -more -cases -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -? -; -/ -/ -/ -let -hay -= -" -Mary -had -a -little -lamb -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -3 -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -Mary -" -" -had -" -" -a -little -lamb -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -? -; -/ -/ -/ -let -hay -= -" -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -3 -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -? -; -/ -/ -/ -let -hay -= -" -lionXXtigerXleopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -3 -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -lion -" -" -" -" -tigerXleopard -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -: -: -" -) -? -; -/ -/ -/ -let -hay -= -" -lion -: -: -tiger -: -: -leopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -2 -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -lion -" -" -tiger -: -: -leopard -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -? -; -/ -/ -/ -let -hay -= -" -abcXdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -1 -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -abcXdef -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -? -; -/ -/ -/ -let -hay -= -" -abcdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -2 -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -abcdef -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -? -; -/ -/ -/ -let -hay -= -" -abcXdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -0 -) -. -map -( -| -sp -| -& -hay -[ -sp -] -) -. -collect -( -) -; -/ -/ -/ -assert -! -( -got -. -is_empty -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -splitn -< -' -r -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -input -: -I -limit -: -usize -) -- -> -SplitN -< -' -r -' -h -> -{ -SplitN -{ -splits -: -self -. -split -( -input -) -limit -} -} -} -/ -/ -/ -Lower -level -search -routines -that -give -more -control -. -impl -Regex -{ -/ -/ -/ -Returns -the -start -and -end -offset -of -the -leftmost -match -. -If -no -match -/ -/ -/ -exists -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Regex -: -: -find -] -but -but -it -accepts -a -concrete -& -Input -/ -/ -/ -instead -of -an -Into -< -Input -> -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -Samwise -| -Sam -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -/ -/ -/ -" -one -of -the -chief -characters -Samwise -the -Brave -" -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -29 -. -. -36 -) -) -re -. -search -( -& -input -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -{ -if -self -. -imp -. -info -. -is_impossible -( -input -) -{ -return -None -; -} -let -mut -guard -= -self -. -pool -. -get -( -) -; -let -result -= -self -. -imp -. -strat -. -search -( -& -mut -guard -input -) -; -/ -/ -We -do -this -dance -with -the -guard -and -explicitly -put -it -back -in -the -/ -/ -pool -because -it -seems -to -result -in -better -codegen -. -If -we -let -the -/ -/ -guard -' -s -Drop -impl -put -it -back -in -the -pool -then -functions -like -/ -/ -ptr -: -: -drop_in_place -get -called -and -they -* -don -' -t -* -get -inlined -. -This -/ -/ -isn -' -t -usually -a -big -deal -but -in -latency -sensitive -benchmarks -the -/ -/ -extra -function -call -can -matter -. -/ -/ -/ -/ -I -used -rebar -measure -- -f -' -^ -grep -/ -every -- -line -' -- -e -meta -to -measure -/ -/ -the -effects -here -. -/ -/ -/ -/ -Note -that -this -doesn -' -t -eliminate -the -latency -effects -of -using -the -/ -/ -pool -. -There -is -still -some -( -minor -) -cost -for -the -" -thread -owner -" -of -the -/ -/ -pool -. -( -i -. -e -. -The -thread -that -first -calls -a -regex -search -routine -. -) -/ -/ -However -for -other -threads -using -the -regex -the -pool -access -can -be -/ -/ -quite -expensive -as -it -goes -through -a -mutex -. -Callers -can -avoid -this -/ -/ -by -either -cloning -the -Regex -( -which -creates -a -distinct -copy -of -the -/ -/ -pool -) -or -callers -can -use -the -lower -level -APIs -that -accept -a -' -Cache -' -/ -/ -directly -and -do -their -own -handling -. -PoolGuard -: -: -put -( -guard -) -; -result -} -/ -/ -/ -Returns -the -end -offset -of -the -leftmost -match -. -If -no -match -exists -then -/ -/ -/ -None -is -returned -. -/ -/ -/ -/ -/ -/ -This -is -distinct -from -[ -Regex -: -: -search -] -in -that -it -only -returns -the -end -/ -/ -/ -of -a -match -and -not -the -start -of -the -match -. -Depending -on -a -variety -of -/ -/ -/ -implementation -details -this -_may_ -permit -the -regex -engine -to -do -less -/ -/ -/ -overall -work -. -For -example -if -a -DFA -is -being -used -to -execute -a -search -/ -/ -/ -then -the -start -of -a -match -usually -requires -running -a -separate -DFA -in -/ -/ -/ -reverse -to -the -find -the -start -of -a -match -. -If -one -only -needs -the -end -of -/ -/ -/ -a -match -then -the -separate -reverse -scan -to -find -the -start -of -a -match -/ -/ -/ -can -be -skipped -. -( -Note -that -the -reverse -scan -is -avoided -even -when -using -/ -/ -/ -Regex -: -: -search -when -possible -for -example -in -the -case -of -an -anchored -/ -/ -/ -search -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -HalfMatch -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -Samwise -| -Sam -" -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -/ -/ -/ -" -one -of -the -chief -characters -Samwise -the -Brave -" -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -Some -( -HalfMatch -: -: -must -( -0 -36 -) -) -re -. -search_half -( -& -input -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search_half -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -{ -if -self -. -imp -. -info -. -is_impossible -( -input -) -{ -return -None -; -} -let -mut -guard -= -self -. -pool -. -get -( -) -; -let -result -= -self -. -imp -. -strat -. -search_half -( -& -mut -guard -input -) -; -/ -/ -See -' -Regex -: -: -search -' -for -why -we -put -the -guard -back -explicitly -. -PoolGuard -: -: -put -( -guard -) -; -result -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -[ -Captures -] -/ -/ -/ -value -. -If -no -match -was -found -then -[ -Captures -: -: -is_match -] -is -guaranteed -/ -/ -/ -to -return -false -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Regex -: -: -captures -] -but -it -accepts -a -concrete -& -Input -/ -/ -/ -instead -of -an -Into -< -Input -> -. -/ -/ -/ -/ -/ -/ -# -Example -: -specific -pattern -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -multi -- -pattern -Regex -that -permits -/ -/ -/ -searching -for -specific -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -meta -: -: -Regex -/ -/ -/ -Anchored -Match -PatternID -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -" -[ -a -- -z0 -- -9 -] -{ -6 -} -" -" -[ -a -- -z -] -[ -a -- -z0 -- -9 -] -{ -5 -} -" -] -) -? -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -haystack -= -" -foo123 -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -are -using -the -default -leftmost -- -first -match -and -both -/ -/ -/ -/ -/ -patterns -match -at -the -same -starting -position -only -the -first -pattern -/ -/ -/ -/ -/ -will -be -returned -in -this -case -when -doing -a -search -for -any -of -the -/ -/ -/ -/ -/ -patterns -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -6 -) -) -; -/ -/ -/ -re -. -search_captures -( -& -Input -: -: -new -( -haystack -) -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -want -to -check -whether -some -other -pattern -matches -then -we -/ -/ -/ -/ -/ -can -provide -its -pattern -ID -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -1 -0 -. -. -6 -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -re -. -search_captures -( -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specifying -the -bounds -of -a -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -providing -the -bounds -of -a -search -can -produce -/ -/ -/ -different -results -than -simply -sub -- -slicing -the -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -b -[ -0 -- -9 -] -{ -3 -} -\ -b -" -) -? -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -haystack -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -sub -- -slice -the -haystack -the -search -doesn -' -t -know -about -/ -/ -/ -/ -/ -the -larger -context -and -assumes -that -123 -is -surrounded -by -word -/ -/ -/ -/ -/ -boundaries -. -And -of -course -the -match -position -is -reported -relative -/ -/ -/ -/ -/ -to -the -sub -- -slice -as -well -which -means -we -get -0 -. -. -3 -instead -of -/ -/ -/ -/ -/ -3 -. -. -6 -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -& -haystack -[ -3 -. -. -6 -] -) -; -/ -/ -/ -re -. -search_captures -( -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -provide -the -bounds -of -the -search -within -the -context -of -the -/ -/ -/ -/ -/ -entire -haystack -then -the -search -can -take -the -surrounding -context -/ -/ -/ -/ -/ -into -account -. -( -And -if -we -did -find -a -match -it -would -be -reported -/ -/ -/ -/ -/ -as -a -valid -offset -into -haystack -instead -of -its -sub -- -slice -. -) -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -3 -. -. -6 -) -; -/ -/ -/ -re -. -search_captures -( -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search_captures -( -& -self -input -: -& -Input -< -' -_ -> -caps -: -& -mut -Captures -) -{ -caps -. -set_pattern -( -None -) -; -let -pid -= -self -. -search_slots -( -input -caps -. -slots_mut -( -) -) -; -caps -. -set_pattern -( -pid -) -; -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -slots -and -/ -/ -/ -returns -the -matching -pattern -ID -. -The -contents -of -the -slots -for -patterns -/ -/ -/ -other -than -the -matching -pattern -are -unspecified -. -If -no -match -was -found -/ -/ -/ -then -None -is -returned -and -the -contents -of -slots -is -unspecified -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Regex -: -: -search -] -but -it -accepts -a -raw -slots -slice -/ -/ -/ -instead -of -a -Captures -value -. -This -is -useful -in -contexts -where -you -/ -/ -/ -don -' -t -want -or -need -to -allocate -a -Captures -. -/ -/ -/ -/ -/ -/ -It -is -legal -to -pass -_any_ -number -of -slots -to -this -routine -. -If -the -regex -/ -/ -/ -engine -would -otherwise -write -a -slot -offset -that -doesn -' -t -fit -in -the -/ -/ -/ -provided -slice -then -it -is -simply -skipped -. -In -general -though -there -are -/ -/ -/ -usually -three -slice -lengths -you -might -want -to -use -: -/ -/ -/ -/ -/ -/ -* -An -empty -slice -if -you -only -care -about -which -pattern -matched -. -/ -/ -/ -* -A -slice -with -[ -pattern_len -( -) -* -2 -] -( -Regex -: -: -pattern_len -) -slots -if -you -/ -/ -/ -only -care -about -the -overall -match -spans -for -each -matching -pattern -. -/ -/ -/ -* -A -slice -with -/ -/ -/ -[ -slot_len -( -) -] -( -crate -: -: -util -: -: -captures -: -: -GroupInfo -: -: -slot_len -) -slots -which -/ -/ -/ -permits -recording -match -offsets -for -every -capturing -group -in -every -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -the -overall -match -offsets -in -a -/ -/ -/ -multi -- -pattern -search -without -allocating -a -Captures -value -. -Indeed -we -/ -/ -/ -can -put -our -slots -right -on -the -stack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -PatternID -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -/ -/ -/ -r -" -\ -pL -+ -" -/ -/ -/ -r -" -\ -d -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -! -# -123 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -only -care -about -the -overall -match -offsets -here -so -we -just -/ -/ -/ -/ -/ -allocate -two -slots -for -each -pattern -. -Each -slot -records -the -start -/ -/ -/ -/ -/ -and -end -of -the -match -. -/ -/ -/ -let -mut -slots -= -[ -None -; -4 -] -; -/ -/ -/ -let -pid -= -re -. -search_slots -( -& -input -& -mut -slots -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -pid -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -overall -match -offsets -are -always -at -' -pid -* -2 -' -and -' -pid -* -2 -+ -1 -' -. -/ -/ -/ -/ -/ -See -' -GroupInfo -' -for -more -details -on -the -mapping -between -groups -and -/ -/ -/ -/ -/ -slot -indices -. -/ -/ -/ -let -slot_start -= -pid -. -unwrap -( -) -. -as_usize -( -) -* -2 -; -/ -/ -/ -let -slot_end -= -slot_start -+ -1 -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -slots -[ -slot_start -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -6 -) -slots -[ -slot_end -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search_slots -( -& -self -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -if -self -. -imp -. -info -. -is_impossible -( -input -) -{ -return -None -; -} -let -mut -guard -= -self -. -pool -. -get -( -) -; -let -result -= -self -. -imp -. -strat -. -search_slots -( -& -mut -guard -input -slots -) -; -/ -/ -See -' -Regex -: -: -search -' -for -why -we -put -the -guard -back -explicitly -. -PoolGuard -: -: -put -( -guard -) -; -result -} -/ -/ -/ -Writes -the -set -of -patterns -that -match -anywhere -in -the -given -search -/ -/ -/ -configuration -to -patset -. -If -multiple -patterns -match -at -the -same -/ -/ -/ -position -and -this -Regex -was -configured -with -[ -MatchKind -: -: -All -] -/ -/ -/ -semantics -then -all -matching -patterns -are -written -to -the -given -set -. -/ -/ -/ -/ -/ -/ -Unless -all -of -the -patterns -in -this -Regex -are -anchored -then -generally -/ -/ -/ -speaking -this -will -scan -the -entire -haystack -. -/ -/ -/ -/ -/ -/ -This -search -routine -* -does -not -* -clear -the -pattern -set -. -This -gives -some -/ -/ -/ -flexibility -to -the -caller -( -e -. -g -. -running -multiple -searches -with -the -/ -/ -/ -same -pattern -set -) -but -does -make -the -API -bug -- -prone -if -you -' -re -reusing -/ -/ -/ -the -same -pattern -set -for -multiple -searches -but -intended -them -to -be -/ -/ -/ -independent -. -/ -/ -/ -/ -/ -/ -If -a -pattern -ID -matched -but -the -given -PatternSet -does -not -have -/ -/ -/ -sufficient -capacity -to -store -it -then -it -is -not -inserted -and -silently -/ -/ -/ -dropped -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -all -matching -patterns -in -a -haystack -/ -/ -/ -even -when -some -patterns -match -at -the -same -position -as -other -patterns -. -/ -/ -/ -It -is -important -that -we -configure -the -Regex -with -[ -MatchKind -: -: -All -] -/ -/ -/ -semantics -here -or -else -overlapping -matches -will -not -be -reported -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -MatchKind -PatternSet -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -/ -/ -/ -r -" -\ -w -+ -" -r -" -\ -d -+ -" -r -" -\ -pL -+ -" -r -" -foo -" -r -" -bar -" -r -" -barfoo -" -r -" -foobar -" -/ -/ -/ -] -; -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -patterns -) -? -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -let -mut -patset -= -PatternSet -: -: -new -( -re -. -pattern_len -( -) -) -; -/ -/ -/ -re -. -which_overlapping_matches -( -& -input -& -mut -patset -) -; -/ -/ -/ -let -expected -= -vec -! -[ -0 -2 -3 -4 -6 -] -; -/ -/ -/ -let -got -: -Vec -< -usize -> -= -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -which_overlapping_matches -( -& -self -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -if -self -. -imp -. -info -. -is_impossible -( -input -) -{ -return -; -} -let -mut -guard -= -self -. -pool -. -get -( -) -; -let -result -= -self -. -imp -. -strat -. -which_overlapping_matches -( -& -mut -guard -input -patset -) -; -/ -/ -See -' -Regex -: -: -search -' -for -why -we -put -the -guard -back -explicitly -. -PoolGuard -: -: -put -( -guard -) -; -result -} -} -/ -/ -/ -Lower -level -search -routines -that -give -more -control -and -require -the -caller -/ -/ -/ -to -provide -an -explicit -[ -Cache -] -parameter -. -impl -Regex -{ -/ -/ -/ -This -is -like -[ -Regex -: -: -search -] -but -requires -the -caller -to -/ -/ -/ -explicitly -pass -a -[ -Cache -] -. -/ -/ -/ -/ -/ -/ -# -Why -pass -a -Cache -explicitly -? -/ -/ -/ -/ -/ -/ -Passing -a -Cache -explicitly -will -bypass -the -use -of -an -internal -memory -/ -/ -/ -pool -used -by -Regex -to -get -a -Cache -for -a -search -. -The -use -of -this -/ -/ -/ -pool -can -be -slower -in -some -cases -when -a -Regex -is -used -from -multiple -/ -/ -/ -threads -simultaneously -. -Typically -performance -only -becomes -an -issue -/ -/ -/ -when -there -is -heavy -contention -which -in -turn -usually -only -occurs -/ -/ -/ -when -each -thread -' -s -primary -unit -of -work -is -a -regex -search -on -a -small -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -Samwise -| -Sam -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -/ -/ -/ -" -one -of -the -chief -characters -Samwise -the -Brave -" -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -29 -. -. -36 -) -) -/ -/ -/ -re -. -search_with -( -& -mut -cache -& -input -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search_with -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -{ -if -self -. -imp -. -info -. -is_impossible -( -input -) -{ -return -None -; -} -self -. -imp -. -strat -. -search -( -cache -input -) -} -/ -/ -/ -This -is -like -[ -Regex -: -: -search_half -] -but -requires -the -caller -to -/ -/ -/ -explicitly -pass -a -[ -Cache -] -. -/ -/ -/ -/ -/ -/ -# -Why -pass -a -Cache -explicitly -? -/ -/ -/ -/ -/ -/ -Passing -a -Cache -explicitly -will -bypass -the -use -of -an -internal -memory -/ -/ -/ -pool -used -by -Regex -to -get -a -Cache -for -a -search -. -The -use -of -this -/ -/ -/ -pool -can -be -slower -in -some -cases -when -a -Regex -is -used -from -multiple -/ -/ -/ -threads -simultaneously -. -Typically -performance -only -becomes -an -issue -/ -/ -/ -when -there -is -heavy -contention -which -in -turn -usually -only -occurs -/ -/ -/ -when -each -thread -' -s -primary -unit -of -work -is -a -regex -search -on -a -small -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -HalfMatch -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -Samwise -| -Sam -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -/ -/ -/ -" -one -of -the -chief -characters -Samwise -the -Brave -" -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -HalfMatch -: -: -must -( -0 -36 -) -) -/ -/ -/ -re -. -search_half_with -( -& -mut -cache -& -input -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search_half_with -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -{ -if -self -. -imp -. -info -. -is_impossible -( -input -) -{ -return -None -; -} -self -. -imp -. -strat -. -search_half -( -cache -input -) -} -/ -/ -/ -This -is -like -[ -Regex -: -: -search_captures -] -but -requires -the -caller -to -/ -/ -/ -explicitly -pass -a -[ -Cache -] -. -/ -/ -/ -/ -/ -/ -# -Why -pass -a -Cache -explicitly -? -/ -/ -/ -/ -/ -/ -Passing -a -Cache -explicitly -will -bypass -the -use -of -an -internal -memory -/ -/ -/ -pool -used -by -Regex -to -get -a -Cache -for -a -search -. -The -use -of -this -/ -/ -/ -pool -can -be -slower -in -some -cases -when -a -Regex -is -used -from -multiple -/ -/ -/ -threads -simultaneously -. -Typically -performance -only -becomes -an -issue -/ -/ -/ -when -there -is -heavy -contention -which -in -turn -usually -only -occurs -/ -/ -/ -when -each -thread -' -s -primary -unit -of -work -is -a -regex -search -on -a -small -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -: -specific -pattern -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -multi -- -pattern -Regex -that -permits -/ -/ -/ -searching -for -specific -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -meta -: -: -Regex -/ -/ -/ -Anchored -Match -PatternID -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -" -[ -a -- -z0 -- -9 -] -{ -6 -} -" -" -[ -a -- -z -] -[ -a -- -z0 -- -9 -] -{ -5 -} -" -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -foo123 -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -are -using -the -default -leftmost -- -first -match -and -both -/ -/ -/ -/ -/ -patterns -match -at -the -same -starting -position -only -the -first -pattern -/ -/ -/ -/ -/ -will -be -returned -in -this -case -when -doing -a -search -for -any -of -the -/ -/ -/ -/ -/ -patterns -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -6 -) -) -; -/ -/ -/ -re -. -search_captures_with -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -want -to -check -whether -some -other -pattern -matches -then -we -/ -/ -/ -/ -/ -can -provide -its -pattern -ID -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -1 -0 -. -. -6 -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -re -. -search_captures_with -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specifying -the -bounds -of -a -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -providing -the -bounds -of -a -search -can -produce -/ -/ -/ -different -results -than -simply -sub -- -slicing -the -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -b -[ -0 -- -9 -] -{ -3 -} -\ -b -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -sub -- -slice -the -haystack -the -search -doesn -' -t -know -about -/ -/ -/ -/ -/ -the -larger -context -and -assumes -that -123 -is -surrounded -by -word -/ -/ -/ -/ -/ -boundaries -. -And -of -course -the -match -position -is -reported -relative -/ -/ -/ -/ -/ -to -the -sub -- -slice -as -well -which -means -we -get -0 -. -. -3 -instead -of -/ -/ -/ -/ -/ -3 -. -. -6 -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -& -haystack -[ -3 -. -. -6 -] -) -; -/ -/ -/ -re -. -search_captures_with -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -provide -the -bounds -of -the -search -within -the -context -of -the -/ -/ -/ -/ -/ -entire -haystack -then -the -search -can -take -the -surrounding -context -/ -/ -/ -/ -/ -into -account -. -( -And -if -we -did -find -a -match -it -would -be -reported -/ -/ -/ -/ -/ -as -a -valid -offset -into -haystack -instead -of -its -sub -- -slice -. -) -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -3 -. -. -6 -) -; -/ -/ -/ -re -. -search_captures_with -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search_captures_with -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -caps -: -& -mut -Captures -) -{ -caps -. -set_pattern -( -None -) -; -let -pid -= -self -. -search_slots_with -( -cache -input -caps -. -slots_mut -( -) -) -; -caps -. -set_pattern -( -pid -) -; -} -/ -/ -/ -This -is -like -[ -Regex -: -: -search_slots -] -but -requires -the -caller -to -/ -/ -/ -explicitly -pass -a -[ -Cache -] -. -/ -/ -/ -/ -/ -/ -# -Why -pass -a -Cache -explicitly -? -/ -/ -/ -/ -/ -/ -Passing -a -Cache -explicitly -will -bypass -the -use -of -an -internal -memory -/ -/ -/ -pool -used -by -Regex -to -get -a -Cache -for -a -search -. -The -use -of -this -/ -/ -/ -pool -can -be -slower -in -some -cases -when -a -Regex -is -used -from -multiple -/ -/ -/ -threads -simultaneously -. -Typically -performance -only -becomes -an -issue -/ -/ -/ -when -there -is -heavy -contention -which -in -turn -usually -only -occurs -/ -/ -/ -when -each -thread -' -s -primary -unit -of -work -is -a -regex -search -on -a -small -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -the -overall -match -offsets -in -a -/ -/ -/ -multi -- -pattern -search -without -allocating -a -Captures -value -. -Indeed -we -/ -/ -/ -can -put -our -slots -right -on -the -stack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -PatternID -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -/ -/ -/ -r -" -\ -pL -+ -" -/ -/ -/ -r -" -\ -d -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -! -# -123 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -only -care -about -the -overall -match -offsets -here -so -we -just -/ -/ -/ -/ -/ -allocate -two -slots -for -each -pattern -. -Each -slot -records -the -start -/ -/ -/ -/ -/ -and -end -of -the -match -. -/ -/ -/ -let -mut -slots -= -[ -None -; -4 -] -; -/ -/ -/ -let -pid -= -re -. -search_slots_with -( -& -mut -cache -& -input -& -mut -slots -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -pid -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -overall -match -offsets -are -always -at -' -pid -* -2 -' -and -' -pid -* -2 -+ -1 -' -. -/ -/ -/ -/ -/ -See -' -GroupInfo -' -for -more -details -on -the -mapping -between -groups -and -/ -/ -/ -/ -/ -slot -indices -. -/ -/ -/ -let -slot_start -= -pid -. -unwrap -( -) -. -as_usize -( -) -* -2 -; -/ -/ -/ -let -slot_end -= -slot_start -+ -1 -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -slots -[ -slot_start -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -6 -) -slots -[ -slot_end -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search_slots_with -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -if -self -. -imp -. -info -. -is_impossible -( -input -) -{ -return -None -; -} -self -. -imp -. -strat -. -search_slots -( -cache -input -slots -) -} -/ -/ -/ -This -is -like -[ -Regex -: -: -which_overlapping_matches -] -but -requires -the -/ -/ -/ -caller -to -explicitly -pass -a -[ -Cache -] -. -/ -/ -/ -/ -/ -/ -Passing -a -Cache -explicitly -will -bypass -the -use -of -an -internal -memory -/ -/ -/ -pool -used -by -Regex -to -get -a -Cache -for -a -search -. -The -use -of -this -/ -/ -/ -pool -can -be -slower -in -some -cases -when -a -Regex -is -used -from -multiple -/ -/ -/ -threads -simultaneously -. -Typically -performance -only -becomes -an -issue -/ -/ -/ -when -there -is -heavy -contention -which -in -turn -usually -only -occurs -/ -/ -/ -when -each -thread -' -s -primary -unit -of -work -is -a -regex -search -on -a -small -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -# -Why -pass -a -Cache -explicitly -? -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -MatchKind -PatternSet -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -/ -/ -/ -r -" -\ -w -+ -" -r -" -\ -d -+ -" -r -" -\ -pL -+ -" -r -" -foo -" -r -" -bar -" -r -" -barfoo -" -r -" -foobar -" -/ -/ -/ -] -; -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -patterns -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -let -mut -patset -= -PatternSet -: -: -new -( -re -. -pattern_len -( -) -) -; -/ -/ -/ -re -. -which_overlapping_matches_with -( -& -mut -cache -& -input -& -mut -patset -) -; -/ -/ -/ -let -expected -= -vec -! -[ -0 -2 -3 -4 -6 -] -; -/ -/ -/ -let -got -: -Vec -< -usize -> -= -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -which_overlapping_matches_with -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -if -self -. -imp -. -info -. -is_impossible -( -input -) -{ -return -; -} -self -. -imp -. -strat -. -which_overlapping_matches -( -cache -input -patset -) -} -} -/ -/ -/ -Various -non -- -search -routines -for -querying -properties -of -a -Regex -and -/ -/ -/ -convenience -routines -for -creating -[ -Captures -] -and -[ -Cache -] -values -. -impl -Regex -{ -/ -/ -/ -Creates -a -new -object -for -recording -capture -group -offsets -. -This -is -used -/ -/ -/ -in -search -APIs -like -[ -Regex -: -: -captures -] -and -[ -Regex -: -: -search_captures -] -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -/ -/ -/ -Captures -: -: -all -( -re -. -group_info -( -) -. -clone -( -) -) -. -Callers -may -build -other -types -/ -/ -/ -of -Captures -values -that -record -less -information -( -and -thus -require -/ -/ -/ -less -work -from -the -regex -engine -) -using -[ -Captures -: -: -matches -] -and -/ -/ -/ -[ -Captures -: -: -empty -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -some -alternatives -to -[ -Regex -: -: -create_captures -] -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -meta -: -: -Regex -/ -/ -/ -util -: -: -captures -: -: -Captures -/ -/ -/ -Match -PatternID -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -[ -A -- -Z -] -[ -a -- -z -] -+ -) -( -? -< -last -> -[ -A -- -Z -] -[ -a -- -z -] -+ -) -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -Regex -: -: -create_captures -. -It -stores -matching -/ -/ -/ -/ -/ -offsets -for -all -groups -in -the -regex -. -/ -/ -/ -let -mut -all -= -Captures -: -: -all -( -re -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -re -. -captures -( -" -Bruce -Springsteen -" -& -mut -all -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -17 -) -) -all -. -get_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -5 -) -) -all -. -get_group_by_name -( -" -first -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -6 -. -. -17 -) -) -all -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -In -this -version -we -only -care -about -the -implicit -groups -which -/ -/ -/ -/ -/ -means -offsets -for -the -explicit -groups -will -be -unavailable -. -It -can -/ -/ -/ -/ -/ -sometimes -be -faster -to -ask -for -fewer -groups -since -the -underlying -/ -/ -/ -/ -/ -regex -engine -needs -to -do -less -work -to -keep -track -of -them -. -/ -/ -/ -let -mut -matches -= -Captures -: -: -matches -( -re -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -re -. -captures -( -" -Bruce -Springsteen -" -& -mut -matches -) -; -/ -/ -/ -/ -/ -We -still -get -the -overall -match -info -. -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -17 -) -) -matches -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -But -now -the -explicit -groups -are -unavailable -. -/ -/ -/ -assert_eq -! -( -None -matches -. -get_group_by_name -( -" -first -" -) -) -; -/ -/ -/ -assert_eq -! -( -None -matches -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Finally -in -this -version -we -don -' -t -ask -to -keep -track -of -offsets -for -/ -/ -/ -/ -/ -* -any -* -groups -. -All -we -get -back -is -whether -a -match -occurred -and -if -/ -/ -/ -/ -/ -so -the -ID -of -the -pattern -that -matched -. -/ -/ -/ -let -mut -empty -= -Captures -: -: -empty -( -re -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -re -. -captures -( -" -Bruce -Springsteen -" -& -mut -empty -) -; -/ -/ -/ -/ -/ -it -' -s -a -match -! -/ -/ -/ -assert -! -( -empty -. -is_match -( -) -) -; -/ -/ -/ -/ -/ -for -pattern -ID -0 -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -ZERO -) -empty -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -Match -offsets -are -unavailable -. -/ -/ -/ -assert_eq -! -( -None -empty -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -And -of -course -explicit -groups -are -unavailable -too -. -/ -/ -/ -assert_eq -! -( -None -empty -. -get_group_by_name -( -" -first -" -) -) -; -/ -/ -/ -assert_eq -! -( -None -empty -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -create_captures -( -& -self -) -- -> -Captures -{ -Captures -: -: -all -( -self -. -group_info -( -) -. -clone -( -) -) -} -/ -/ -/ -Creates -a -new -cache -for -use -with -lower -level -search -APIs -like -/ -/ -/ -[ -Regex -: -: -search_with -] -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -this -Regex -. -/ -/ -/ -If -you -want -to -reuse -the -cache -for -another -Regex -then -you -must -call -/ -/ -/ -[ -Cache -: -: -reset -] -with -that -Regex -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -[ -Cache -: -: -new -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -- -u -) -m -\ -w -+ -\ -s -+ -m -\ -w -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -crazy -janey -and -her -mission -man -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -20 -. -. -31 -) -) -/ -/ -/ -re -. -search_with -( -& -mut -cache -& -input -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -create_cache -( -& -self -) -- -> -Cache -{ -self -. -imp -. -strat -. -create_cache -( -) -} -/ -/ -/ -Returns -the -total -number -of -patterns -in -this -regex -. -/ -/ -/ -/ -/ -/ -The -standard -[ -Regex -: -: -new -] -constructor -always -results -in -a -Regex -/ -/ -/ -with -a -single -pattern -but -[ -Regex -: -: -new_many -] -permits -building -a -/ -/ -/ -multi -- -pattern -regex -. -/ -/ -/ -/ -/ -/ -A -Regex -guarantees -that -the -maximum -possible -PatternID -returned -in -/ -/ -/ -any -match -is -Regex -: -: -pattern_len -( -) -- -1 -. -In -the -case -where -the -number -/ -/ -/ -of -patterns -is -0 -a -match -is -impossible -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -[ -a -- -z -] -" -) -? -; -/ -/ -/ -assert_eq -! -( -1 -re -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -: -: -< -& -str -> -( -& -[ -] -) -? -; -/ -/ -/ -assert_eq -! -( -0 -re -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new_many -( -& -[ -" -a -" -" -b -" -" -c -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -3 -re -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -imp -. -info -. -pattern_len -( -) -} -/ -/ -/ -Returns -the -total -number -of -capturing -groups -. -/ -/ -/ -/ -/ -/ -This -includes -the -implicit -capturing -group -corresponding -to -the -/ -/ -/ -entire -match -. -Therefore -the -minimum -value -returned -is -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -few -patterns -and -how -many -capture -groups -they -have -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -len -= -| -pattern -| -{ -/ -/ -/ -Regex -: -: -new -( -pattern -) -. -map -( -| -re -| -re -. -captures_len -( -) -) -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -1 -len -( -" -a -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -2 -len -( -" -( -a -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -3 -len -( -" -( -a -) -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -5 -len -( -" -( -a -) -( -b -) -| -( -c -) -( -d -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -2 -len -( -" -( -a -) -| -b -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -2 -len -( -" -a -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -2 -len -( -" -( -b -) -* -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -2 -len -( -" -( -b -) -+ -" -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -multiple -patterns -/ -/ -/ -/ -/ -/ -This -routine -also -works -for -multiple -patterns -. -The -total -number -is -/ -/ -/ -the -sum -of -the -capture -groups -of -each -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -len -= -| -patterns -| -{ -/ -/ -/ -Regex -: -: -new_many -( -patterns -) -. -map -( -| -re -| -re -. -captures_len -( -) -) -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -2 -len -( -& -[ -" -a -" -" -b -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -4 -len -( -& -[ -" -( -a -) -" -" -( -b -) -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -6 -len -( -& -[ -" -( -a -) -| -( -b -) -" -" -( -c -) -| -( -d -) -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -8 -len -( -& -[ -" -( -a -) -( -b -) -| -( -c -) -( -d -) -" -" -( -x -) -( -y -) -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -3 -len -( -& -[ -" -( -a -) -" -" -b -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -3 -len -( -& -[ -" -a -" -" -( -b -) -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -4 -len -( -& -[ -" -( -a -) -" -" -( -b -) -* -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -4 -len -( -& -[ -" -( -a -) -+ -" -" -( -b -) -+ -" -] -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -captures_len -( -& -self -) -- -> -usize -{ -self -. -imp -. -info -. -props_union -( -) -. -explicit_captures_len -( -) -. -saturating_add -( -self -. -pattern_len -( -) -) -} -/ -/ -/ -Returns -the -total -number -of -capturing -groups -that -appear -in -every -/ -/ -/ -possible -match -. -/ -/ -/ -/ -/ -/ -If -the -number -of -capture -groups -can -vary -depending -on -the -match -then -/ -/ -/ -this -returns -None -. -That -is -a -value -is -only -returned -when -the -number -/ -/ -/ -of -matching -groups -is -invariant -or -" -static -. -" -/ -/ -/ -/ -/ -/ -Note -that -like -[ -Regex -: -: -captures_len -] -this -* -* -does -* -* -include -the -/ -/ -/ -implicit -capturing -group -corresponding -to -the -entire -match -. -Therefore -/ -/ -/ -when -a -non -- -None -value -is -returned -it -is -guaranteed -to -be -at -least -1 -. -/ -/ -/ -Stated -differently -a -return -value -of -Some -( -0 -) -is -impossible -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -few -cases -where -a -static -number -of -capture -groups -is -/ -/ -/ -available -and -a -few -cases -where -it -is -not -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -len -= -| -pattern -| -{ -/ -/ -/ -Regex -: -: -new -( -pattern -) -. -map -( -| -re -| -re -. -static_captures_len -( -) -) -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -len -( -" -a -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -a -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -a -) -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -len -( -" -( -a -) -( -b -) -| -( -c -) -( -d -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -( -a -) -| -b -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -a -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -( -b -) -* -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -b -) -+ -" -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -multiple -patterns -/ -/ -/ -/ -/ -/ -This -property -extends -to -regexes -with -multiple -patterns -as -well -. -In -/ -/ -/ -order -for -their -to -be -a -static -number -of -capture -groups -in -this -case -/ -/ -/ -every -pattern -must -have -the -same -static -number -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -len -= -| -patterns -| -{ -/ -/ -/ -Regex -: -: -new_many -( -patterns -) -. -map -( -| -re -| -re -. -static_captures_len -( -) -) -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -len -( -& -[ -" -a -" -" -b -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -& -[ -" -( -a -) -" -" -( -b -) -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -& -[ -" -( -a -) -| -( -b -) -" -" -( -c -) -| -( -d -) -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -len -( -& -[ -" -( -a -) -( -b -) -| -( -c -) -( -d -) -" -" -( -x -) -( -y -) -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -& -[ -" -( -a -) -" -" -b -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -& -[ -" -a -" -" -( -b -) -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -& -[ -" -( -a -) -" -" -( -b -) -* -" -] -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -& -[ -" -( -a -) -+ -" -" -( -b -) -+ -" -] -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -static_captures_len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -imp -. -info -. -props_union -( -) -. -static_explicit_captures_len -( -) -. -map -( -| -len -| -len -. -saturating_add -( -1 -) -) -} -/ -/ -/ -Return -information -about -the -capture -groups -in -this -Regex -. -/ -/ -/ -/ -/ -/ -A -GroupInfo -is -an -immutable -object -that -can -be -cheaply -cloned -. -It -/ -/ -/ -is -responsible -for -maintaining -a -mapping -between -the -capture -groups -/ -/ -/ -in -the -concrete -syntax -of -zero -or -more -regex -patterns -and -their -/ -/ -/ -internal -representation -used -by -some -of -the -regex -matchers -. -It -is -also -/ -/ -/ -responsible -for -maintaining -a -mapping -between -the -name -of -each -group -/ -/ -/ -( -if -one -exists -) -and -its -corresponding -group -index -. -/ -/ -/ -/ -/ -/ -A -GroupInfo -is -ultimately -what -is -used -to -build -a -[ -Captures -] -value -/ -/ -/ -which -is -some -mutable -space -where -group -offsets -are -stored -as -a -result -/ -/ -/ -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -some -alternatives -to -[ -Regex -: -: -create_captures -] -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -meta -: -: -Regex -/ -/ -/ -util -: -: -captures -: -: -Captures -/ -/ -/ -Match -PatternID -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -[ -A -- -Z -] -[ -a -- -z -] -+ -) -( -? -< -last -> -[ -A -- -Z -] -[ -a -- -z -] -+ -) -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -Regex -: -: -create_captures -. -It -stores -matching -/ -/ -/ -/ -/ -offsets -for -all -groups -in -the -regex -. -/ -/ -/ -let -mut -all -= -Captures -: -: -all -( -re -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -re -. -captures -( -" -Bruce -Springsteen -" -& -mut -all -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -17 -) -) -all -. -get_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -5 -) -) -all -. -get_group_by_name -( -" -first -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -6 -. -. -17 -) -) -all -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -In -this -version -we -only -care -about -the -implicit -groups -which -/ -/ -/ -/ -/ -means -offsets -for -the -explicit -groups -will -be -unavailable -. -It -can -/ -/ -/ -/ -/ -sometimes -be -faster -to -ask -for -fewer -groups -since -the -underlying -/ -/ -/ -/ -/ -regex -engine -needs -to -do -less -work -to -keep -track -of -them -. -/ -/ -/ -let -mut -matches -= -Captures -: -: -matches -( -re -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -re -. -captures -( -" -Bruce -Springsteen -" -& -mut -matches -) -; -/ -/ -/ -/ -/ -We -still -get -the -overall -match -info -. -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -17 -) -) -matches -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -But -now -the -explicit -groups -are -unavailable -. -/ -/ -/ -assert_eq -! -( -None -matches -. -get_group_by_name -( -" -first -" -) -) -; -/ -/ -/ -assert_eq -! -( -None -matches -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Finally -in -this -version -we -don -' -t -ask -to -keep -track -of -offsets -for -/ -/ -/ -/ -/ -* -any -* -groups -. -All -we -get -back -is -whether -a -match -occurred -and -if -/ -/ -/ -/ -/ -so -the -ID -of -the -pattern -that -matched -. -/ -/ -/ -let -mut -empty -= -Captures -: -: -empty -( -re -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -re -. -captures -( -" -Bruce -Springsteen -" -& -mut -empty -) -; -/ -/ -/ -/ -/ -it -' -s -a -match -! -/ -/ -/ -assert -! -( -empty -. -is_match -( -) -) -; -/ -/ -/ -/ -/ -for -pattern -ID -0 -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -ZERO -) -empty -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -Match -offsets -are -unavailable -. -/ -/ -/ -assert_eq -! -( -None -empty -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -And -of -course -explicit -groups -are -unavailable -too -. -/ -/ -/ -assert_eq -! -( -None -empty -. -get_group_by_name -( -" -first -" -) -) -; -/ -/ -/ -assert_eq -! -( -None -empty -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -self -. -imp -. -strat -. -group_info -( -) -} -/ -/ -/ -Returns -the -configuration -object -used -to -build -this -Regex -. -/ -/ -/ -/ -/ -/ -If -no -configuration -object -was -explicitly -passed -then -the -/ -/ -/ -configuration -returned -represents -the -default -. -# -[ -inline -] -pub -fn -get_config -( -& -self -) -- -> -& -Config -{ -self -. -imp -. -info -. -config -( -) -} -/ -/ -/ -Returns -true -if -this -regex -has -a -high -chance -of -being -" -accelerated -. -" -/ -/ -/ -/ -/ -/ -The -precise -meaning -of -" -accelerated -" -is -specifically -left -unspecified -/ -/ -/ -but -the -general -meaning -is -that -the -search -is -a -high -likelihood -of -/ -/ -/ -running -faster -than -than -a -character -- -at -- -a -- -time -loop -inside -a -standard -/ -/ -/ -regex -engine -. -/ -/ -/ -/ -/ -/ -When -a -regex -is -accelerated -it -is -only -a -* -probabilistic -* -claim -. -That -/ -/ -/ -is -just -because -the -regex -is -believed -to -be -accelerated -that -doesn -' -t -/ -/ -/ -mean -it -will -definitely -execute -searches -very -fast -. -Similarly -if -a -/ -/ -/ -regex -is -* -not -* -accelerated -that -is -also -a -probabilistic -claim -. -That -/ -/ -/ -is -a -regex -for -which -is_accelerated -returns -false -could -still -run -/ -/ -/ -searches -more -quickly -than -a -regex -for -which -is_accelerated -returns -/ -/ -/ -true -. -/ -/ -/ -/ -/ -/ -Whether -a -regex -is -marked -as -accelerated -or -not -is -dependent -on -/ -/ -/ -implementations -details -that -may -change -in -a -semver -compatible -release -. -/ -/ -/ -That -is -a -regex -that -is -accelerated -in -a -x -. -y -. -1 -release -might -not -be -/ -/ -/ -accelerated -in -a -x -. -y -. -2 -release -. -/ -/ -/ -/ -/ -/ -Basically -the -value -of -acceleration -boils -down -to -a -hedge -: -a -hodge -/ -/ -/ -podge -of -internal -heuristics -combine -to -make -a -probabilistic -guess -/ -/ -/ -that -this -regex -search -may -run -" -fast -. -" -The -value -in -knowing -this -from -/ -/ -/ -a -caller -' -s -perspective -is -that -it -may -act -as -a -signal -that -no -further -/ -/ -/ -work -should -be -done -to -accelerate -a -search -. -For -example -a -grep -- -like -/ -/ -/ -tool -might -try -to -do -some -extra -work -extracting -literals -from -a -regex -/ -/ -/ -to -create -its -own -heuristic -acceleration -strategies -. -But -it -might -/ -/ -/ -choose -to -defer -to -this -crate -' -s -acceleration -strategy -if -one -exists -. -/ -/ -/ -This -routine -permits -querying -whether -such -a -strategy -is -active -for -a -/ -/ -/ -particular -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -/ -/ -A -simple -literal -is -very -likely -to -be -accelerated -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -foo -" -) -? -; -/ -/ -/ -assert -! -( -re -. -is_accelerated -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -A -regex -with -no -literals -is -likely -to -not -be -accelerated -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -assert -! -( -! -re -. -is_accelerated -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_accelerated -( -& -self -) -- -> -bool -{ -self -. -imp -. -strat -. -is_accelerated -( -) -} -/ -/ -/ -Return -the -total -approximate -heap -memory -in -bytes -used -by -this -Regex -. -/ -/ -/ -/ -/ -/ -Note -that -currently -there -is -no -high -level -configuration -for -setting -/ -/ -/ -a -limit -on -the -specific -value -returned -by -this -routine -. -Instead -the -/ -/ -/ -following -routines -can -be -used -to -control -heap -memory -at -a -bit -of -a -/ -/ -/ -lower -level -: -/ -/ -/ -/ -/ -/ -* -[ -Config -: -: -nfa_size_limit -] -controls -how -big -_any_ -of -the -NFAs -are -/ -/ -/ -allowed -to -be -. -/ -/ -/ -* -[ -Config -: -: -onepass_size_limit -] -controls -how -big -the -one -- -pass -DFA -is -/ -/ -/ -allowed -to -be -. -/ -/ -/ -* -[ -Config -: -: -hybrid_cache_capacity -] -controls -how -much -memory -the -lazy -/ -/ -/ -DFA -is -permitted -to -allocate -to -store -its -transition -table -. -/ -/ -/ -* -[ -Config -: -: -dfa_size_limit -] -controls -how -big -a -fully -compiled -DFA -is -/ -/ -/ -allowed -to -be -. -/ -/ -/ -* -[ -Config -: -: -dfa_state_limit -] -controls -the -conditions -under -which -the -/ -/ -/ -meta -regex -engine -will -even -attempt -to -build -a -fully -compiled -DFA -. -# -[ -inline -] -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -imp -. -strat -. -memory_usage -( -) -} -} -impl -Clone -for -Regex -{ -fn -clone -( -& -self -) -- -> -Regex -{ -let -imp -= -Arc -: -: -clone -( -& -self -. -imp -) -; -let -pool -= -{ -let -strat -= -Arc -: -: -clone -( -& -imp -. -strat -) -; -let -create -: -CachePoolFn -= -Box -: -: -new -( -move -| -| -strat -. -create_cache -( -) -) -; -Pool -: -: -new -( -create -) -} -; -Regex -{ -imp -pool -} -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -RegexInfo -( -Arc -< -RegexInfoI -> -) -; -# -[ -derive -( -Clone -Debug -) -] -struct -RegexInfoI -{ -config -: -Config -props -: -Vec -< -hir -: -: -Properties -> -props_union -: -hir -: -: -Properties -} -impl -RegexInfo -{ -fn -new -( -config -: -Config -hirs -: -& -[ -& -Hir -] -) -- -> -RegexInfo -{ -/ -/ -Collect -all -of -the -properties -from -each -of -the -HIRs -and -also -/ -/ -union -them -into -one -big -set -of -properties -representing -all -HIRs -/ -/ -as -if -they -were -in -one -big -alternation -. -let -mut -props -= -vec -! -[ -] -; -for -hir -in -hirs -. -iter -( -) -{ -props -. -push -( -hir -. -properties -( -) -. -clone -( -) -) -; -} -let -props_union -= -hir -: -: -Properties -: -: -union -( -& -props -) -; -RegexInfo -( -Arc -: -: -new -( -RegexInfoI -{ -config -props -props_union -} -) -) -} -pub -( -crate -) -fn -config -( -& -self -) -- -> -& -Config -{ -& -self -. -0 -. -config -} -pub -( -crate -) -fn -props -( -& -self -) -- -> -& -[ -hir -: -: -Properties -] -{ -& -self -. -0 -. -props -} -pub -( -crate -) -fn -props_union -( -& -self -) -- -> -& -hir -: -: -Properties -{ -& -self -. -0 -. -props_union -} -pub -( -crate -) -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -props -( -) -. -len -( -) -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -props -( -) -. -iter -( -) -. -map -( -| -p -| -p -. -memory_usage -( -) -) -. -sum -: -: -< -usize -> -( -) -+ -self -. -props_union -( -) -. -memory_usage -( -) -} -/ -/ -/ -Returns -true -when -the -search -is -guaranteed -to -be -anchored -. -That -is -/ -/ -/ -when -a -match -is -reported -its -offset -is -guaranteed -to -correspond -to -/ -/ -/ -the -start -of -the -search -. -/ -/ -/ -/ -/ -/ -This -includes -returning -true -when -input -_isn -' -t_ -anchored -but -the -/ -/ -/ -underlying -regex -is -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -is_anchored_start -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -input -. -get_anchored -( -) -. -is_anchored -( -) -| -| -self -. -is_always_anchored_start -( -) -} -/ -/ -/ -Returns -true -when -this -regex -is -always -anchored -to -the -start -of -a -/ -/ -/ -search -. -And -in -particular -that -regardless -of -an -Input -configuration -/ -/ -/ -if -any -match -is -reported -it -must -start -at -0 -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -is_always_anchored_start -( -& -self -) -- -> -bool -{ -use -regex_syntax -: -: -hir -: -: -Look -; -self -. -props_union -( -) -. -look_set_prefix -( -) -. -contains -( -Look -: -: -Start -) -} -/ -/ -/ -Returns -true -when -this -regex -is -always -anchored -to -the -end -of -a -/ -/ -/ -search -. -And -in -particular -that -regardless -of -an -Input -configuration -/ -/ -/ -if -any -match -is -reported -it -must -end -at -the -end -of -the -haystack -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -is_always_anchored_end -( -& -self -) -- -> -bool -{ -use -regex_syntax -: -: -hir -: -: -Look -; -self -. -props_union -( -) -. -look_set_suffix -( -) -. -contains -( -Look -: -: -End -) -} -/ -/ -/ -Returns -true -if -and -only -if -it -is -known -that -a -match -is -impossible -/ -/ -/ -for -the -given -input -. -This -is -useful -for -short -- -circuiting -and -avoiding -/ -/ -/ -running -the -regex -engine -if -it -' -s -known -no -match -can -be -reported -. -/ -/ -/ -/ -/ -/ -Note -that -this -doesn -' -t -necessarily -detect -every -possible -case -. -For -/ -/ -/ -example -when -pattern_len -( -) -= -= -0 -a -match -is -impossible -but -that -/ -/ -/ -case -is -so -rare -that -it -' -s -fine -to -be -handled -by -the -regex -engine -/ -/ -/ -itself -. -That -is -it -' -s -not -worth -the -cost -of -adding -it -here -in -order -to -/ -/ -/ -make -it -a -little -faster -. -The -reason -is -that -this -is -called -for -every -/ -/ -/ -search -. -so -there -is -some -cost -to -adding -checks -here -. -Arguably -some -of -/ -/ -/ -the -checks -that -are -here -already -probably -shouldn -' -t -be -here -. -. -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_impossible -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -/ -/ -The -underlying -regex -is -anchored -so -if -we -don -' -t -start -the -search -/ -/ -at -position -0 -a -match -is -impossible -because -the -anchor -can -only -/ -/ -match -at -position -0 -. -if -input -. -start -( -) -> -0 -& -& -self -. -is_always_anchored_start -( -) -{ -return -true -; -} -/ -/ -Same -idea -but -for -the -end -anchor -. -if -input -. -end -( -) -< -input -. -haystack -( -) -. -len -( -) -& -& -self -. -is_always_anchored_end -( -) -{ -return -true -; -} -/ -/ -If -the -haystack -is -smaller -than -the -minimum -length -required -then -/ -/ -we -know -there -can -be -no -match -. -let -minlen -= -match -self -. -props_union -( -) -. -minimum_len -( -) -{ -None -= -> -return -false -Some -( -minlen -) -= -> -minlen -} -; -if -input -. -get_span -( -) -. -len -( -) -< -minlen -{ -return -true -; -} -/ -/ -Same -idea -as -minimum -but -for -maximum -. -This -is -trickier -. -We -can -/ -/ -only -apply -the -maximum -when -we -know -the -entire -span -that -we -' -re -/ -/ -searching -* -has -* -to -match -according -to -the -regex -( -and -possibly -the -/ -/ -input -configuration -) -. -If -we -know -there -is -too -much -for -the -regex -/ -/ -to -match -we -can -bail -early -. -/ -/ -/ -/ -I -don -' -t -think -we -can -apply -the -maximum -otherwise -unfortunately -. -if -self -. -is_anchored_start -( -input -) -& -& -self -. -is_always_anchored_end -( -) -{ -let -maxlen -= -match -self -. -props_union -( -) -. -maximum_len -( -) -{ -None -= -> -return -false -Some -( -maxlen -) -= -> -maxlen -} -; -if -input -. -get_span -( -) -. -len -( -) -> -maxlen -{ -return -true -; -} -} -false -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -Match -] -value -until -no -more -matches -could -be -found -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -Regex -that -produced -this -iterator -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -Regex -: -: -find_iter -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -FindMatches -< -' -r -' -h -> -{ -re -: -& -' -r -Regex -cache -: -CachePoolGuard -< -' -r -> -it -: -iter -: -: -Searcher -< -' -h -> -} -impl -< -' -r -' -h -> -FindMatches -< -' -r -' -h -> -{ -/ -/ -/ -Returns -the -Regex -value -that -created -this -iterator -. -# -[ -inline -] -pub -fn -regex -( -& -self -) -- -> -& -' -r -Regex -{ -self -. -re -} -/ -/ -/ -Returns -the -current -Input -associated -with -this -iterator -. -/ -/ -/ -/ -/ -/ -The -start -position -on -the -given -Input -may -change -during -iteration -/ -/ -/ -but -all -other -values -are -guaranteed -to -remain -invariant -. -# -[ -inline -] -pub -fn -input -< -' -s -> -( -& -' -s -self -) -- -> -& -' -s -Input -< -' -h -> -{ -self -. -it -. -input -( -) -} -} -impl -< -' -r -' -h -> -Iterator -for -FindMatches -< -' -r -' -h -> -{ -type -Item -= -Match -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -let -FindMatches -{ -re -ref -mut -cache -ref -mut -it -} -= -* -self -; -it -. -advance -( -| -input -| -Ok -( -re -. -search_with -( -cache -input -) -) -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -/ -/ -If -all -we -care -about -is -a -count -of -matches -then -we -only -need -to -/ -/ -find -the -end -position -of -each -match -. -This -can -give -us -a -2x -perf -/ -/ -boost -in -some -cases -because -it -avoids -needing -to -do -a -reverse -scan -/ -/ -to -find -the -start -of -a -match -. -let -FindMatches -{ -re -mut -cache -it -} -= -self -; -/ -/ -This -does -the -deref -for -PoolGuard -once -instead -of -every -iter -. -let -cache -= -& -mut -* -cache -; -it -. -into_half_matches_iter -( -| -input -| -Ok -( -re -. -search_half_with -( -cache -input -) -) -) -. -count -( -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -FindMatches -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -leftmost -matches -with -their -capturing -/ -/ -/ -groups -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -Captures -] -value -until -no -more -matches -could -be -/ -/ -/ -found -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -Regex -that -produced -this -iterator -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -Regex -: -: -captures_iter -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -CapturesMatches -< -' -r -' -h -> -{ -re -: -& -' -r -Regex -cache -: -CachePoolGuard -< -' -r -> -caps -: -Captures -it -: -iter -: -: -Searcher -< -' -h -> -} -impl -< -' -r -' -h -> -CapturesMatches -< -' -r -' -h -> -{ -/ -/ -/ -Returns -the -Regex -value -that -created -this -iterator -. -# -[ -inline -] -pub -fn -regex -( -& -self -) -- -> -& -' -r -Regex -{ -self -. -re -} -/ -/ -/ -Returns -the -current -Input -associated -with -this -iterator -. -/ -/ -/ -/ -/ -/ -The -start -position -on -the -given -Input -may -change -during -iteration -/ -/ -/ -but -all -other -values -are -guaranteed -to -remain -invariant -. -# -[ -inline -] -pub -fn -input -< -' -s -> -( -& -' -s -self -) -- -> -& -' -s -Input -< -' -h -> -{ -self -. -it -. -input -( -) -} -} -impl -< -' -r -' -h -> -Iterator -for -CapturesMatches -< -' -r -' -h -> -{ -type -Item -= -Captures -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Captures -> -{ -/ -/ -Splitting -' -self -' -apart -seems -necessary -to -appease -borrowck -. -let -CapturesMatches -{ -re -ref -mut -cache -ref -mut -caps -ref -mut -it -} -= -* -self -; -let -_ -= -it -. -advance -( -| -input -| -{ -re -. -search_captures_with -( -cache -input -caps -) -; -Ok -( -caps -. -get_match -( -) -) -} -) -; -if -caps -. -is_match -( -) -{ -Some -( -caps -. -clone -( -) -) -} -else -{ -None -} -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -let -CapturesMatches -{ -re -mut -cache -it -. -. -} -= -self -; -/ -/ -This -does -the -deref -for -PoolGuard -once -instead -of -every -iter -. -let -cache -= -& -mut -* -cache -; -it -. -into_half_matches_iter -( -| -input -| -Ok -( -re -. -search_half_with -( -cache -input -) -) -) -. -count -( -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -CapturesMatches -< -' -r -' -h -> -{ -} -/ -/ -/ -Yields -all -substrings -delimited -by -a -regular -expression -match -. -/ -/ -/ -/ -/ -/ -The -spans -correspond -to -the -offsets -between -matches -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -Regex -that -produced -this -iterator -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -Regex -: -: -split -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -Split -< -' -r -' -h -> -{ -finder -: -FindMatches -< -' -r -' -h -> -last -: -usize -} -impl -< -' -r -' -h -> -Split -< -' -r -' -h -> -{ -/ -/ -/ -Returns -the -current -Input -associated -with -this -iterator -. -/ -/ -/ -/ -/ -/ -The -start -position -on -the -given -Input -may -change -during -iteration -/ -/ -/ -but -all -other -values -are -guaranteed -to -remain -invariant -. -# -[ -inline -] -pub -fn -input -< -' -s -> -( -& -' -s -self -) -- -> -& -' -s -Input -< -' -h -> -{ -self -. -finder -. -input -( -) -} -} -impl -< -' -r -' -h -> -Iterator -for -Split -< -' -r -' -h -> -{ -type -Item -= -Span -; -fn -next -( -& -mut -self -) -- -> -Option -< -Span -> -{ -match -self -. -finder -. -next -( -) -{ -None -= -> -{ -let -len -= -self -. -finder -. -it -. -input -( -) -. -haystack -( -) -. -len -( -) -; -if -self -. -last -> -len -{ -None -} -else -{ -let -span -= -Span -: -: -from -( -self -. -last -. -. -len -) -; -self -. -last -= -len -+ -1 -; -/ -/ -Next -call -will -return -None -Some -( -span -) -} -} -Some -( -m -) -= -> -{ -let -span -= -Span -: -: -from -( -self -. -last -. -. -m -. -start -( -) -) -; -self -. -last -= -m -. -end -( -) -; -Some -( -span -) -} -} -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -Split -< -' -r -' -h -> -{ -} -/ -/ -/ -Yields -at -most -N -spans -delimited -by -a -regular -expression -match -. -/ -/ -/ -/ -/ -/ -The -spans -correspond -to -the -offsets -between -matches -. -The -last -span -will -be -/ -/ -/ -whatever -remains -after -splitting -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -Regex -that -produced -this -iterator -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -Regex -: -: -splitn -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -SplitN -< -' -r -' -h -> -{ -splits -: -Split -< -' -r -' -h -> -limit -: -usize -} -impl -< -' -r -' -h -> -SplitN -< -' -r -' -h -> -{ -/ -/ -/ -Returns -the -current -Input -associated -with -this -iterator -. -/ -/ -/ -/ -/ -/ -The -start -position -on -the -given -Input -may -change -during -iteration -/ -/ -/ -but -all -other -values -are -guaranteed -to -remain -invariant -. -# -[ -inline -] -pub -fn -input -< -' -s -> -( -& -' -s -self -) -- -> -& -' -s -Input -< -' -h -> -{ -self -. -splits -. -input -( -) -} -} -impl -< -' -r -' -h -> -Iterator -for -SplitN -< -' -r -' -h -> -{ -type -Item -= -Span -; -fn -next -( -& -mut -self -) -- -> -Option -< -Span -> -{ -if -self -. -limit -= -= -0 -{ -return -None -; -} -self -. -limit -- -= -1 -; -if -self -. -limit -> -0 -{ -return -self -. -splits -. -next -( -) -; -} -let -len -= -self -. -splits -. -finder -. -it -. -input -( -) -. -haystack -( -) -. -len -( -) -; -if -self -. -splits -. -last -> -len -{ -/ -/ -We -' -ve -already -returned -all -substrings -. -None -} -else -{ -/ -/ -self -. -n -= -= -0 -so -future -calls -will -return -None -immediately -Some -( -Span -: -: -from -( -self -. -splits -. -last -. -. -len -) -) -} -} -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -( -0 -Some -( -self -. -limit -) -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -SplitN -< -' -r -' -h -> -{ -} -/ -/ -/ -Represents -mutable -scratch -space -used -by -regex -engines -during -a -search -. -/ -/ -/ -/ -/ -/ -Most -of -the -regex -engines -in -this -crate -require -some -kind -of -/ -/ -/ -mutable -state -in -order -to -execute -a -search -. -This -mutable -state -is -/ -/ -/ -explicitly -separated -from -the -the -core -regex -object -( -such -as -a -/ -/ -/ -[ -thompson -: -: -NFA -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -) -) -so -that -the -read -- -only -regex -/ -/ -/ -object -can -be -shared -across -multiple -threads -simultaneously -without -any -/ -/ -/ -synchronization -. -Conversely -a -Cache -must -either -be -duplicated -if -using -/ -/ -/ -the -same -Regex -from -multiple -threads -or -else -there -must -be -some -kind -of -/ -/ -/ -synchronization -that -guarantees -exclusive -access -while -it -' -s -in -use -by -one -/ -/ -/ -thread -. -/ -/ -/ -/ -/ -/ -A -Regex -attempts -to -do -this -synchronization -for -you -by -using -a -thread -/ -/ -/ -pool -internally -. -Its -size -scales -roughly -with -the -number -of -simultaneous -/ -/ -/ -regex -searches -. -/ -/ -/ -/ -/ -/ -For -cases -where -one -does -not -want -to -rely -on -a -Regex -' -s -internal -thread -/ -/ -/ -pool -lower -level -routines -such -as -[ -Regex -: -: -search_with -] -are -provided -/ -/ -/ -that -permit -callers -to -pass -a -Cache -into -the -search -routine -explicitly -. -/ -/ -/ -/ -/ -/ -General -advice -is -that -the -thread -pool -is -often -more -than -good -enough -. -/ -/ -/ -However -it -may -be -possible -to -observe -the -effects -of -its -latency -/ -/ -/ -especially -when -searching -many -small -haystacks -from -many -threads -/ -/ -/ -simultaneously -. -/ -/ -/ -/ -/ -/ -Caches -can -be -created -from -their -corresponding -Regex -via -/ -/ -/ -[ -Regex -: -: -create_cache -] -. -A -cache -can -only -be -used -with -either -the -Regex -/ -/ -/ -that -created -it -or -the -Regex -that -was -most -recently -used -to -reset -it -/ -/ -/ -with -[ -Cache -: -: -reset -] -. -Using -a -cache -with -any -other -Regex -may -result -in -/ -/ -/ -panics -or -incorrect -results -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Input -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -- -u -) -m -\ -w -+ -\ -s -+ -m -\ -w -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -crazy -janey -and -her -mission -man -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -20 -. -. -31 -) -) -/ -/ -/ -re -. -search_with -( -& -mut -cache -& -input -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Debug -Clone -) -] -pub -struct -Cache -{ -pub -( -crate -) -capmatches -: -Captures -pub -( -crate -) -pikevm -: -wrappers -: -: -PikeVMCache -pub -( -crate -) -backtrack -: -wrappers -: -: -BoundedBacktrackerCache -pub -( -crate -) -onepass -: -wrappers -: -: -OnePassCache -pub -( -crate -) -hybrid -: -wrappers -: -: -HybridCache -pub -( -crate -) -revhybrid -: -wrappers -: -: -ReverseHybridCache -} -impl -Cache -{ -/ -/ -/ -Creates -a -new -Cache -for -use -with -this -regex -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -the -given -/ -/ -/ -Regex -. -If -you -want -to -reuse -the -cache -for -another -Regex -then -you -/ -/ -/ -must -call -[ -Cache -: -: -reset -] -with -that -Regex -. -pub -fn -new -( -re -: -& -Regex -) -- -> -Cache -{ -re -. -create_cache -( -) -} -/ -/ -/ -Reset -this -cache -such -that -it -can -be -used -for -searching -with -the -given -/ -/ -/ -Regex -( -and -only -that -Regex -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -potentially -reusing -memory -already -allocated -in -/ -/ -/ -this -cache -with -a -different -Regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -Regex -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -Input -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -Regex -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -Regex -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -/ -/ -/ -re1 -. -search_with -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -Regex -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -cache -. -reset -( -& -re2 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -/ -/ -/ -re2 -. -search_with -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset -( -& -mut -self -re -: -& -Regex -) -{ -re -. -imp -. -strat -. -reset_cache -( -self -) -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -of -this -cache -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -cache -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -Cache -> -( -) -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -let -mut -bytes -= -0 -; -bytes -+ -= -self -. -pikevm -. -memory_usage -( -) -; -bytes -+ -= -self -. -backtrack -. -memory_usage -( -) -; -bytes -+ -= -self -. -onepass -. -memory_usage -( -) -; -bytes -+ -= -self -. -hybrid -. -memory_usage -( -) -; -bytes -+ -= -self -. -revhybrid -. -memory_usage -( -) -; -bytes -} -} -/ -/ -/ -An -object -describing -the -configuration -of -a -Regex -. -/ -/ -/ -/ -/ -/ -This -configuration -only -includes -options -for -the -/ -/ -/ -non -- -syntax -behavior -of -a -Regex -and -can -be -applied -via -the -/ -/ -/ -[ -Builder -: -: -configure -] -method -. -For -configuring -the -syntax -options -see -/ -/ -/ -[ -util -: -: -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -# -Example -: -lower -the -NFA -size -limit -/ -/ -/ -/ -/ -/ -In -some -cases -the -default -size -limit -might -be -too -big -. -The -size -limit -can -/ -/ -/ -be -lowered -which -will -prevent -large -regex -patterns -from -compiling -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -result -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -nfa_size_limit -( -Some -( -20 -* -( -1 -< -< -10 -) -) -) -) -/ -/ -/ -/ -/ -Not -even -20KB -is -enough -to -build -a -single -large -Unicode -class -! -/ -/ -/ -. -build -( -r -" -\ -pL -" -) -; -/ -/ -/ -assert -! -( -result -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -Config -{ -/ -/ -As -with -other -configuration -types -in -this -crate -we -put -all -our -knobs -/ -/ -in -options -so -that -we -can -distinguish -between -" -default -" -and -" -not -set -. -" -/ -/ -This -makes -it -possible -to -easily -combine -multiple -configurations -/ -/ -without -default -values -overwriting -explicitly -specified -values -. -See -the -/ -/ -' -overwrite -' -method -. -/ -/ -/ -/ -For -docs -on -the -fields -below -see -the -corresponding -method -setters -. -match_kind -: -Option -< -MatchKind -> -utf8_empty -: -Option -< -bool -> -autopre -: -Option -< -bool -> -pre -: -Option -< -Option -< -Prefilter -> -> -which_captures -: -Option -< -WhichCaptures -> -nfa_size_limit -: -Option -< -Option -< -usize -> -> -onepass_size_limit -: -Option -< -Option -< -usize -> -> -hybrid_cache_capacity -: -Option -< -usize -> -hybrid -: -Option -< -bool -> -dfa -: -Option -< -bool -> -dfa_size_limit -: -Option -< -Option -< -usize -> -> -dfa_state_limit -: -Option -< -Option -< -usize -> -> -onepass -: -Option -< -bool -> -backtrack -: -Option -< -bool -> -byte_classes -: -Option -< -bool -> -line_terminator -: -Option -< -u8 -> -} -impl -Config -{ -/ -/ -/ -Create -a -new -configuration -object -for -a -Regex -. -pub -fn -new -( -) -- -> -Config -{ -Config -: -: -default -( -) -} -/ -/ -/ -Set -the -match -semantics -for -a -Regex -. -/ -/ -/ -/ -/ -/ -The -default -value -is -[ -MatchKind -: -: -LeftmostFirst -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -MatchKind -} -; -/ -/ -/ -/ -/ -/ -/ -/ -By -default -leftmost -- -first -semantics -are -used -which -/ -/ -/ -/ -/ -disambiguates -matches -at -the -same -position -by -selecting -/ -/ -/ -/ -/ -the -one -that -corresponds -earlier -in -the -pattern -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -sam -| -samwise -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -re -. -find -( -" -samwise -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -with -' -all -' -semantics -match -priority -is -ignored -/ -/ -/ -/ -/ -and -all -match -states -are -included -. -When -coupled -with -/ -/ -/ -/ -/ -a -leftmost -search -the -search -will -report -the -last -/ -/ -/ -/ -/ -possible -match -. -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build -( -" -sam -| -samwise -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -7 -) -) -re -. -find -( -" -samwise -" -) -) -; -/ -/ -/ -/ -/ -Beware -that -this -can -lead -to -skipping -matches -! -/ -/ -/ -/ -/ -Usually -' -all -' -is -used -for -anchored -reverse -searches -/ -/ -/ -/ -/ -only -or -for -overlapping -searches -. -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -4 -. -. -11 -) -) -re -. -find -( -" -sam -samwise -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -match_kind -( -self -kind -: -MatchKind -) -- -> -Config -{ -Config -{ -match_kind -: -Some -( -kind -) -. -. -self -} -} -/ -/ -/ -Toggles -whether -empty -matches -are -permitted -to -occur -between -the -code -/ -/ -/ -units -of -a -UTF -- -8 -encoded -codepoint -. -/ -/ -/ -/ -/ -/ -This -should -generally -be -enabled -when -search -a -& -str -or -anything -that -/ -/ -/ -you -otherwise -know -is -valid -UTF -- -8 -. -It -should -be -disabled -in -all -other -/ -/ -/ -cases -. -Namely -if -the -haystack -is -not -valid -UTF -- -8 -and -this -is -enabled -/ -/ -/ -then -behavior -is -unspecified -. -/ -/ -/ -/ -/ -/ -By -default -this -is -enabled -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -" -) -? -; -/ -/ -/ -let -got -: -Vec -< -Match -> -= -re -. -find_iter -( -" -" -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Matches -only -occur -at -the -beginning -and -end -of -the -snowman -. -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -0 -) -/ -/ -/ -Match -: -: -must -( -0 -3 -. -. -3 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -utf8_empty -( -false -) -) -/ -/ -/ -. -build -( -" -" -) -? -; -/ -/ -/ -let -got -: -Vec -< -Match -> -= -re -. -find_iter -( -" -" -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Matches -now -occur -at -every -position -! -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -0 -) -/ -/ -/ -Match -: -: -must -( -0 -1 -. -. -1 -) -/ -/ -/ -Match -: -: -must -( -0 -2 -. -. -2 -) -/ -/ -/ -Match -: -: -must -( -0 -3 -. -. -3 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -utf8_empty -( -self -yes -: -bool -) -- -> -Config -{ -Config -{ -utf8_empty -: -Some -( -yes -) -. -. -self -} -} -/ -/ -/ -Toggles -whether -automatic -prefilter -support -is -enabled -. -/ -/ -/ -/ -/ -/ -If -this -is -disabled -and -[ -Config -: -: -prefilter -] -is -not -set -then -the -/ -/ -/ -meta -regex -engine -will -not -use -any -prefilters -. -This -can -sometimes -/ -/ -/ -be -beneficial -in -cases -where -you -know -( -or -have -measured -) -that -the -/ -/ -/ -prefilter -leads -to -overall -worse -search -performance -. -/ -/ -/ -/ -/ -/ -By -default -this -is -enabled -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -auto_prefilter -( -false -) -) -/ -/ -/ -. -build -( -r -" -Bruce -\ -w -+ -" -) -? -; -/ -/ -/ -let -hay -= -" -Hello -Bruce -Springsteen -! -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -6 -. -. -23 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -auto_prefilter -( -self -yes -: -bool -) -- -> -Config -{ -Config -{ -autopre -: -Some -( -yes -) -. -. -self -} -} -/ -/ -/ -Overrides -and -sets -the -prefilter -to -use -inside -a -Regex -. -/ -/ -/ -/ -/ -/ -This -permits -one -to -forcefully -set -a -prefilter -in -cases -where -the -/ -/ -/ -caller -knows -better -than -whatever -the -automatic -prefilter -logic -is -/ -/ -/ -capable -of -. -/ -/ -/ -/ -/ -/ -By -default -this -is -set -to -None -and -an -automatic -prefilter -will -be -/ -/ -/ -used -if -one -could -be -built -. -( -Assuming -[ -Config -: -: -auto_prefilter -] -is -/ -/ -/ -enabled -which -it -is -by -default -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -set -your -own -prefilter -. -In -the -case -of -a -/ -/ -/ -pattern -like -Bruce -\ -w -+ -the -automatic -prefilter -is -likely -to -be -/ -/ -/ -constructed -in -a -way -that -it -will -look -for -occurrences -of -Bruce -. -/ -/ -/ -In -most -cases -this -is -the -best -choice -. -But -in -some -cases -it -may -be -/ -/ -/ -the -case -that -running -memchr -on -B -is -the -best -choice -. -One -can -/ -/ -/ -achieve -that -behavior -by -overriding -the -automatic -prefilter -logic -/ -/ -/ -and -providing -a -prefilter -that -just -matches -B -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -meta -: -: -Regex -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Match -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -B -" -] -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -prefilter -( -Some -( -pre -) -) -) -/ -/ -/ -. -build -( -r -" -Bruce -\ -w -+ -" -) -? -; -/ -/ -/ -let -hay -= -" -Hello -Bruce -Springsteen -! -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -6 -. -. -23 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -incorrect -prefilters -can -lead -to -incorrect -results -! -/ -/ -/ -/ -/ -/ -Be -warned -that -setting -an -incorrect -prefilter -can -lead -to -missed -/ -/ -/ -matches -. -So -if -you -use -this -option -ensure -your -prefilter -can -_never_ -/ -/ -/ -report -false -negatives -. -( -A -false -positive -is -on -the -other -hand -quite -/ -/ -/ -okay -and -generally -unavoidable -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -meta -: -: -Regex -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Match -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -Z -" -] -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -prefilter -( -Some -( -pre -) -) -) -/ -/ -/ -. -build -( -r -" -Bruce -\ -w -+ -" -) -? -; -/ -/ -/ -let -hay -= -" -Hello -Bruce -Springsteen -! -" -; -/ -/ -/ -/ -/ -Oops -! -No -match -found -but -there -should -be -one -! -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -prefilter -( -self -pre -: -Option -< -Prefilter -> -) -- -> -Config -{ -Config -{ -pre -: -Some -( -pre -) -. -. -self -} -} -/ -/ -/ -Configures -what -kinds -of -groups -are -compiled -as -" -capturing -" -in -the -/ -/ -/ -underlying -regex -engine -. -/ -/ -/ -/ -/ -/ -This -is -set -to -[ -WhichCaptures -: -: -All -] -by -default -. -Callers -may -wish -to -/ -/ -/ -use -[ -WhichCaptures -: -: -Implicit -] -in -cases -where -one -wants -avoid -the -/ -/ -/ -overhead -of -capture -states -for -explicit -groups -. -/ -/ -/ -/ -/ -/ -Note -that -another -approach -to -avoiding -the -overhead -of -capture -groups -/ -/ -/ -is -by -using -non -- -capturing -groups -in -the -regex -pattern -. -That -is -/ -/ -/ -( -? -: -a -) -instead -of -( -a -) -. -This -option -is -useful -when -you -can -' -t -control -/ -/ -/ -the -concrete -syntax -but -know -that -you -don -' -t -need -the -underlying -capture -/ -/ -/ -states -. -For -example -using -WhichCaptures -: -: -Implicit -will -behave -as -if -/ -/ -/ -all -explicit -capturing -groups -in -the -pattern -were -non -- -capturing -. -/ -/ -/ -/ -/ -/ -Setting -this -to -WhichCaptures -: -: -None -is -usually -not -the -right -thing -to -/ -/ -/ -do -. -When -no -capture -states -are -compiled -some -regex -engines -( -such -as -/ -/ -/ -the -PikeVM -) -won -' -t -be -able -to -report -match -offsets -. -This -will -manifest -/ -/ -/ -as -no -match -being -found -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -demonstrates -how -the -results -of -capture -groups -can -change -/ -/ -/ -based -on -this -option -. -First -we -show -the -default -( -all -capture -groups -in -/ -/ -/ -the -pattern -are -capturing -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -foo -( -[ -0 -- -9 -] -+ -) -bar -" -) -? -; -/ -/ -/ -let -hay -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -re -. -captures -( -hay -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -9 -) -) -caps -. -get_group -( -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -3 -. -. -6 -) -) -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -/ -/ -/ -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -now -we -show -the -behavior -when -we -only -include -implicit -capture -/ -/ -/ -groups -. -In -this -case -we -can -only -find -the -overall -match -span -but -the -/ -/ -/ -spans -of -any -other -explicit -group -don -' -t -exist -because -they -are -treated -/ -/ -/ -as -non -- -capturing -. -( -In -effect -when -WhichCaptures -: -: -Implicit -is -used -/ -/ -/ -there -is -no -real -point -in -using -[ -Regex -: -: -captures -] -since -it -will -never -/ -/ -/ -be -able -to -report -more -information -than -[ -Regex -: -: -find -] -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -meta -: -: -Regex -/ -/ -/ -nfa -: -: -thompson -: -: -WhichCaptures -/ -/ -/ -Match -/ -/ -/ -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -Implicit -) -) -/ -/ -/ -. -build -( -r -" -foo -( -[ -0 -- -9 -] -+ -) -bar -" -) -? -; -/ -/ -/ -let -hay -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -re -. -captures -( -hay -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -9 -) -) -caps -. -get_group -( -0 -) -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -/ -/ -/ -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -which_captures -( -mut -self -which_captures -: -WhichCaptures -) -- -> -Config -{ -self -. -which_captures -= -Some -( -which_captures -) -; -self -} -/ -/ -/ -Sets -the -size -limit -in -bytes -to -enforce -on -the -construction -of -every -/ -/ -/ -NFA -build -by -the -meta -regex -engine -. -/ -/ -/ -/ -/ -/ -Setting -it -to -None -disables -the -limit -. -This -is -not -recommended -if -/ -/ -/ -you -' -re -compiling -untrusted -patterns -. -/ -/ -/ -/ -/ -/ -Note -that -this -limit -is -applied -to -_each_ -NFA -built -and -if -any -of -/ -/ -/ -them -excceed -the -limit -then -construction -will -fail -. -This -limit -does -/ -/ -/ -_not_ -correspond -to -the -total -memory -used -by -all -NFAs -in -the -meta -regex -/ -/ -/ -engine -. -/ -/ -/ -/ -/ -/ -This -defaults -to -some -reasonable -number -that -permits -most -reasonable -/ -/ -/ -patterns -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -result -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -nfa_size_limit -( -Some -( -20 -* -( -1 -< -< -10 -) -) -) -) -/ -/ -/ -/ -/ -Not -even -20KB -is -enough -to -build -a -single -large -Unicode -class -! -/ -/ -/ -. -build -( -r -" -\ -pL -" -) -; -/ -/ -/ -assert -! -( -result -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -notice -that -building -such -a -regex -with -the -exact -same -limit -/ -/ -/ -/ -/ -can -succeed -depending -on -other -aspects -of -the -configuration -. -For -/ -/ -/ -/ -/ -example -a -single -* -forward -* -NFA -will -( -at -time -of -writing -) -fit -into -/ -/ -/ -/ -/ -the -20KB -limit -but -a -* -reverse -* -NFA -of -the -same -pattern -will -not -. -/ -/ -/ -/ -/ -So -if -one -configures -a -meta -regex -such -that -a -reverse -NFA -is -never -/ -/ -/ -/ -/ -needed -and -thus -never -built -then -the -20KB -limit -will -be -enough -for -/ -/ -/ -/ -/ -a -pattern -like -\ -pL -! -/ -/ -/ -let -result -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -/ -/ -/ -. -nfa_size_limit -( -Some -( -20 -* -( -1 -< -< -10 -) -) -) -/ -/ -/ -/ -/ -The -DFAs -are -the -only -thing -that -( -currently -) -need -a -reverse -/ -/ -/ -/ -/ -NFA -. -So -if -both -are -disabled -the -meta -regex -engine -will -/ -/ -/ -/ -/ -skip -building -the -reverse -NFA -. -Note -that -this -isn -' -t -an -API -/ -/ -/ -/ -/ -guarantee -. -A -future -semver -compatible -version -may -introduce -/ -/ -/ -/ -/ -new -use -cases -for -a -reverse -NFA -. -/ -/ -/ -. -hybrid -( -false -) -/ -/ -/ -. -dfa -( -false -) -/ -/ -/ -) -/ -/ -/ -/ -/ -Not -even -20KB -is -enough -to -build -a -single -large -Unicode -class -! -/ -/ -/ -. -build -( -r -" -\ -pL -" -) -; -/ -/ -/ -assert -! -( -result -. -is_ok -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -nfa_size_limit -( -self -limit -: -Option -< -usize -> -) -- -> -Config -{ -Config -{ -nfa_size_limit -: -Some -( -limit -) -. -. -self -} -} -/ -/ -/ -Sets -the -size -limit -in -bytes -for -the -one -- -pass -DFA -. -/ -/ -/ -/ -/ -/ -Setting -it -to -None -disables -the -limit -. -Disabling -the -limit -is -/ -/ -/ -strongly -discouraged -when -compiling -untrusted -patterns -. -Even -if -the -/ -/ -/ -patterns -are -trusted -it -still -may -not -be -a -good -idea -since -a -one -- -pass -/ -/ -/ -DFA -can -use -a -lot -of -memory -. -With -that -said -as -the -size -of -a -regex -/ -/ -/ -increases -the -likelihood -of -it -being -one -- -pass -likely -decreases -. -/ -/ -/ -/ -/ -/ -This -defaults -to -some -reasonable -number -that -permits -most -reasonable -/ -/ -/ -one -- -pass -patterns -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -set -the -one -- -pass -DFA -size -limit -. -Note -that -since -/ -/ -/ -a -one -- -pass -DFA -is -an -optional -component -of -the -meta -regex -engine -/ -/ -/ -this -size -limit -only -impacts -what -is -built -internally -and -will -never -/ -/ -/ -determine -whether -a -Regex -itself -fails -to -build -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -result -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -onepass_size_limit -( -Some -( -2 -* -( -1 -< -< -20 -) -) -) -) -/ -/ -/ -. -build -( -r -" -\ -pL -{ -5 -} -" -) -; -/ -/ -/ -assert -! -( -result -. -is_ok -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -onepass_size_limit -( -self -limit -: -Option -< -usize -> -) -- -> -Config -{ -Config -{ -onepass_size_limit -: -Some -( -limit -) -. -. -self -} -} -/ -/ -/ -Set -the -cache -capacity -in -bytes -for -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -The -cache -capacity -of -the -lazy -DFA -determines -approximately -how -much -/ -/ -/ -heap -memory -it -is -allowed -to -use -to -store -its -state -transitions -. -The -/ -/ -/ -state -transitions -are -computed -at -search -time -and -if -the -cache -fills -/ -/ -/ -up -it -it -is -cleared -. -At -this -point -any -previously -generated -state -/ -/ -/ -transitions -are -lost -and -are -re -- -generated -if -they -' -re -needed -again -. -/ -/ -/ -/ -/ -/ -This -sort -of -cache -filling -and -clearing -works -quite -well -_so -long -as -/ -/ -/ -cache -clearing -happens -infrequently_ -. -If -it -happens -too -often -then -the -/ -/ -/ -meta -regex -engine -will -stop -using -the -lazy -DFA -and -switch -over -to -a -/ -/ -/ -different -regex -engine -. -/ -/ -/ -/ -/ -/ -In -cases -where -the -cache -is -cleared -too -often -it -may -be -possible -to -/ -/ -/ -give -the -cache -more -space -and -reduce -( -or -eliminate -) -how -often -it -is -/ -/ -/ -cleared -. -Similarly -sometimes -a -regex -is -so -big -that -the -lazy -DFA -isn -' -t -/ -/ -/ -used -at -all -if -its -cache -capacity -isn -' -t -big -enough -. -/ -/ -/ -/ -/ -/ -The -capacity -set -here -is -a -_limit_ -on -how -much -memory -is -used -. -The -/ -/ -/ -actual -memory -used -is -only -allocated -as -it -' -s -needed -. -/ -/ -/ -/ -/ -/ -Determining -the -right -value -for -this -is -a -little -tricky -and -will -likely -/ -/ -/ -required -some -profiling -. -Enabling -the -logging -feature -and -setting -the -/ -/ -/ -log -level -to -trace -will -also -tell -you -how -often -the -cache -is -being -/ -/ -/ -cleared -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -result -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -hybrid_cache_capacity -( -20 -* -( -1 -< -< -20 -) -) -) -/ -/ -/ -. -build -( -r -" -\ -pL -{ -5 -} -" -) -; -/ -/ -/ -assert -! -( -result -. -is_ok -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -hybrid_cache_capacity -( -self -limit -: -usize -) -- -> -Config -{ -Config -{ -hybrid_cache_capacity -: -Some -( -limit -) -. -. -self -} -} -/ -/ -/ -Sets -the -size -limit -in -bytes -for -heap -memory -used -for -a -fully -/ -/ -/ -compiled -DFA -. -/ -/ -/ -/ -/ -/ -* -* -NOTE -: -* -* -If -you -increase -this -you -' -ll -likely -also -need -to -increase -/ -/ -/ -[ -Config -: -: -dfa_state_limit -] -. -/ -/ -/ -/ -/ -/ -In -contrast -to -the -lazy -DFA -building -a -full -DFA -requires -computing -/ -/ -/ -all -of -its -state -transitions -up -front -. -This -can -be -a -very -expensive -/ -/ -/ -process -and -runs -in -worst -case -2 -^ -n -time -and -space -( -where -n -is -/ -/ -/ -proportional -to -the -size -of -the -regex -) -. -However -a -full -DFA -unlocks -/ -/ -/ -some -additional -optimization -opportunities -. -/ -/ -/ -/ -/ -/ -Because -full -DFAs -can -be -so -expensive -the -default -limits -for -them -are -/ -/ -/ -incredibly -small -. -Generally -speaking -if -your -regex -is -moderately -big -/ -/ -/ -or -if -you -' -re -using -Unicode -features -( -\ -w -is -Unicode -- -aware -by -default -/ -/ -/ -for -example -) -then -you -can -expect -that -the -meta -regex -engine -won -' -t -even -/ -/ -/ -attempt -to -build -a -DFA -for -it -. -/ -/ -/ -/ -/ -/ -If -this -and -[ -Config -: -: -dfa_state_limit -] -are -set -to -None -then -the -/ -/ -/ -meta -regex -will -not -use -any -sort -of -limits -when -deciding -whether -to -/ -/ -/ -build -a -DFA -. -This -in -turn -makes -construction -of -a -Regex -take -/ -/ -/ -worst -case -exponential -time -and -space -. -Even -short -patterns -can -result -/ -/ -/ -in -huge -space -blow -ups -. -So -it -is -strongly -recommended -to -keep -some -kind -/ -/ -/ -of -limit -set -! -/ -/ -/ -/ -/ -/ -The -default -is -set -to -a -small -number -that -permits -some -simple -regexes -/ -/ -/ -to -get -compiled -into -DFAs -in -reasonable -time -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -result -= -Regex -: -: -builder -( -) -/ -/ -/ -/ -/ -100MB -is -much -bigger -than -the -default -. -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -/ -/ -/ -. -dfa_size_limit -( -Some -( -100 -* -( -1 -< -< -20 -) -) -) -/ -/ -/ -/ -/ -We -don -' -t -care -about -size -too -much -here -so -just -/ -/ -/ -/ -/ -remove -the -NFA -state -limit -altogether -. -/ -/ -/ -. -dfa_state_limit -( -None -) -) -/ -/ -/ -. -build -( -r -" -\ -pL -{ -5 -} -" -) -; -/ -/ -/ -assert -! -( -result -. -is_ok -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -dfa_size_limit -( -self -limit -: -Option -< -usize -> -) -- -> -Config -{ -Config -{ -dfa_size_limit -: -Some -( -limit -) -. -. -self -} -} -/ -/ -/ -Sets -a -limit -on -the -total -number -of -NFA -states -beyond -which -a -full -/ -/ -/ -DFA -is -not -attempted -to -be -compiled -. -/ -/ -/ -/ -/ -/ -This -limit -works -in -concert -with -[ -Config -: -: -dfa_size_limit -] -. -Namely -/ -/ -/ -where -as -Config -: -: -dfa_size_limit -is -applied -by -attempting -to -construct -/ -/ -/ -a -DFA -this -limit -is -used -to -avoid -the -attempt -in -the -first -place -. -This -/ -/ -/ -is -useful -to -avoid -hefty -initialization -costs -associated -with -building -/ -/ -/ -a -DFA -for -cases -where -it -is -obvious -the -DFA -will -ultimately -be -too -big -. -/ -/ -/ -/ -/ -/ -By -default -this -is -set -to -a -very -small -number -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -meta -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -result -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -/ -/ -/ -/ -/ -Sometimes -the -default -state -limit -rejects -DFAs -even -/ -/ -/ -/ -/ -if -they -would -fit -in -the -size -limit -. -Here -we -disable -/ -/ -/ -/ -/ -the -check -on -the -number -of -NFA -states -and -just -rely -on -/ -/ -/ -/ -/ -the -size -limit -. -/ -/ -/ -. -dfa_state_limit -( -None -) -) -/ -/ -/ -. -build -( -r -" -( -? -- -u -) -\ -w -{ -30 -} -" -) -; -/ -/ -/ -assert -! -( -result -. -is_ok -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -dfa_state_limit -( -self -limit -: -Option -< -usize -> -) -- -> -Config -{ -Config -{ -dfa_state_limit -: -Some -( -limit -) -. -. -self -} -} -/ -/ -/ -Whether -to -attempt -to -shrink -the -size -of -the -alphabet -for -the -regex -/ -/ -/ -pattern -or -not -. -When -enabled -the -alphabet -is -shrunk -into -a -set -of -/ -/ -/ -equivalence -classes -where -every -byte -in -the -same -equivalence -class -/ -/ -/ -cannot -discriminate -between -a -match -or -non -- -match -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -This -is -only -useful -for -debugging -DFAs -. -Disabling -this -/ -/ -/ -does -not -yield -any -speed -advantages -. -Indeed -disabling -it -can -result -/ -/ -/ -in -much -higher -memory -usage -. -Disabling -byte -classes -is -useful -for -/ -/ -/ -debugging -the -actual -generated -transitions -because -it -lets -one -see -the -/ -/ -/ -transitions -defined -on -actual -bytes -instead -of -the -equivalence -classes -. -/ -/ -/ -/ -/ -/ -This -option -is -enabled -by -default -and -should -never -be -disabled -unless -/ -/ -/ -one -is -debugging -the -meta -regex -engine -' -s -internals -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -byte_classes -( -false -) -) -/ -/ -/ -. -build -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -hay -= -" -! -! -quux -! -! -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -6 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -byte_classes -( -self -yes -: -bool -) -- -> -Config -{ -Config -{ -byte_classes -: -Some -( -yes -) -. -. -self -} -} -/ -/ -/ -Set -the -line -terminator -to -be -used -by -the -^ -and -anchors -in -/ -/ -/ -multi -- -line -mode -. -/ -/ -/ -/ -/ -/ -This -option -has -no -effect -when -CRLF -mode -is -enabled -. -That -is -/ -/ -/ -regardless -of -this -setting -( -? -Rm -: -^ -) -and -( -? -Rm -: -) -will -always -treat -/ -/ -/ -\ -r -and -\ -n -as -line -terminators -( -and -will -never -match -between -a -\ -r -/ -/ -/ -and -a -\ -n -) -. -/ -/ -/ -/ -/ -/ -By -default -\ -n -is -the -line -terminator -. -/ -/ -/ -/ -/ -/ -* -* -Warning -* -* -: -This -does -not -change -the -behavior -of -. -. -To -do -that -/ -/ -/ -you -' -ll -need -to -configure -the -syntax -option -/ -/ -/ -[ -syntax -: -: -Config -: -: -line_terminator -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -line_terminator -) -/ -/ -/ -in -addition -to -this -. -Otherwise -. -will -continue -to -match -any -/ -/ -/ -character -other -than -\ -n -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -multi_line -( -true -) -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -line_terminator -( -b -' -\ -x00 -' -) -) -/ -/ -/ -. -build -( -r -" -^ -foo -" -) -? -; -/ -/ -/ -let -hay -= -" -\ -x00foo -\ -x00 -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -4 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -line_terminator -( -self -byte -: -u8 -) -- -> -Config -{ -Config -{ -line_terminator -: -Some -( -byte -) -. -. -self -} -} -/ -/ -/ -Toggle -whether -the -hybrid -NFA -/ -DFA -( -also -known -as -the -" -lazy -DFA -" -) -should -/ -/ -/ -be -available -for -use -by -the -meta -regex -engine -. -/ -/ -/ -/ -/ -/ -Enabling -this -does -not -necessarily -mean -that -the -lazy -DFA -will -/ -/ -/ -definitely -be -used -. -It -just -means -that -it -will -be -_available_ -for -use -/ -/ -/ -if -the -meta -regex -engine -thinks -it -will -be -useful -. -/ -/ -/ -/ -/ -/ -When -the -hybrid -crate -feature -is -enabled -then -this -is -enabled -by -/ -/ -/ -default -. -Otherwise -if -the -crate -feature -is -disabled -then -this -is -/ -/ -/ -always -disabled -regardless -of -its -setting -by -the -caller -. -pub -fn -hybrid -( -self -yes -: -bool -) -- -> -Config -{ -Config -{ -hybrid -: -Some -( -yes -) -. -. -self -} -} -/ -/ -/ -Toggle -whether -a -fully -compiled -DFA -should -be -available -for -use -by -the -/ -/ -/ -meta -regex -engine -. -/ -/ -/ -/ -/ -/ -Enabling -this -does -not -necessarily -mean -that -a -DFA -will -definitely -be -/ -/ -/ -used -. -It -just -means -that -it -will -be -_available_ -for -use -if -the -meta -/ -/ -/ -regex -engine -thinks -it -will -be -useful -. -/ -/ -/ -/ -/ -/ -When -the -dfa -- -build -crate -feature -is -enabled -then -this -is -enabled -by -/ -/ -/ -default -. -Otherwise -if -the -crate -feature -is -disabled -then -this -is -/ -/ -/ -always -disabled -regardless -of -its -setting -by -the -caller -. -pub -fn -dfa -( -self -yes -: -bool -) -- -> -Config -{ -Config -{ -dfa -: -Some -( -yes -) -. -. -self -} -} -/ -/ -/ -Toggle -whether -a -one -- -pass -DFA -should -be -available -for -use -by -the -meta -/ -/ -/ -regex -engine -. -/ -/ -/ -/ -/ -/ -Enabling -this -does -not -necessarily -mean -that -a -one -- -pass -DFA -will -/ -/ -/ -definitely -be -used -. -It -just -means -that -it -will -be -_available_ -for -/ -/ -/ -use -if -the -meta -regex -engine -thinks -it -will -be -useful -. -( -Indeed -a -/ -/ -/ -one -- -pass -DFA -can -only -be -used -when -the -regex -is -one -- -pass -. -See -the -/ -/ -/ -[ -dfa -: -: -onepass -] -( -crate -: -: -dfa -: -: -onepass -) -module -for -more -details -. -) -/ -/ -/ -/ -/ -/ -When -the -dfa -- -onepass -crate -feature -is -enabled -then -this -is -enabled -/ -/ -/ -by -default -. -Otherwise -if -the -crate -feature -is -disabled -then -this -is -/ -/ -/ -always -disabled -regardless -of -its -setting -by -the -caller -. -pub -fn -onepass -( -self -yes -: -bool -) -- -> -Config -{ -Config -{ -onepass -: -Some -( -yes -) -. -. -self -} -} -/ -/ -/ -Toggle -whether -a -bounded -backtracking -regex -engine -should -be -available -/ -/ -/ -for -use -by -the -meta -regex -engine -. -/ -/ -/ -/ -/ -/ -Enabling -this -does -not -necessarily -mean -that -a -bounded -backtracker -will -/ -/ -/ -definitely -be -used -. -It -just -means -that -it -will -be -_available_ -for -use -/ -/ -/ -if -the -meta -regex -engine -thinks -it -will -be -useful -. -/ -/ -/ -/ -/ -/ -When -the -nfa -- -backtrack -crate -feature -is -enabled -then -this -is -enabled -/ -/ -/ -by -default -. -Otherwise -if -the -crate -feature -is -disabled -then -this -is -/ -/ -/ -always -disabled -regardless -of -its -setting -by -the -caller -. -pub -fn -backtrack -( -self -yes -: -bool -) -- -> -Config -{ -Config -{ -backtrack -: -Some -( -yes -) -. -. -self -} -} -/ -/ -/ -Returns -the -match -kind -on -this -configuration -as -set -by -/ -/ -/ -[ -Config -: -: -match_kind -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_match_kind -( -& -self -) -- -> -MatchKind -{ -self -. -match_kind -. -unwrap_or -( -MatchKind -: -: -LeftmostFirst -) -} -/ -/ -/ -Returns -whether -empty -matches -must -fall -on -valid -UTF -- -8 -boundaries -as -/ -/ -/ -set -by -[ -Config -: -: -utf8_empty -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_utf8_empty -( -& -self -) -- -> -bool -{ -self -. -utf8_empty -. -unwrap_or -( -true -) -} -/ -/ -/ -Returns -whether -automatic -prefilters -are -enabled -as -set -by -/ -/ -/ -[ -Config -: -: -auto_prefilter -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_auto_prefilter -( -& -self -) -- -> -bool -{ -self -. -autopre -. -unwrap_or -( -true -) -} -/ -/ -/ -Returns -a -manually -set -prefilter -if -one -was -set -by -/ -/ -/ -[ -Config -: -: -prefilter -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -self -. -pre -. -as_ref -( -) -. -unwrap_or -( -& -None -) -. -as_ref -( -) -} -/ -/ -/ -Returns -the -capture -configuration -as -set -by -/ -/ -/ -[ -Config -: -: -which_captures -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_which_captures -( -& -self -) -- -> -WhichCaptures -{ -self -. -which_captures -. -unwrap_or -( -WhichCaptures -: -: -All -) -} -/ -/ -/ -Returns -NFA -size -limit -as -set -by -[ -Config -: -: -nfa_size_limit -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_nfa_size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -nfa_size_limit -. -unwrap_or -( -Some -( -10 -* -( -1 -< -< -20 -) -) -) -} -/ -/ -/ -Returns -one -- -pass -DFA -size -limit -as -set -by -/ -/ -/ -[ -Config -: -: -onepass_size_limit -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_onepass_size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -onepass_size_limit -. -unwrap_or -( -Some -( -1 -* -( -1 -< -< -20 -) -) -) -} -/ -/ -/ -Returns -hybrid -NFA -/ -DFA -cache -capacity -as -set -by -/ -/ -/ -[ -Config -: -: -hybrid_cache_capacity -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_hybrid_cache_capacity -( -& -self -) -- -> -usize -{ -self -. -hybrid_cache_capacity -. -unwrap_or -( -2 -* -( -1 -< -< -20 -) -) -} -/ -/ -/ -Returns -DFA -size -limit -as -set -by -[ -Config -: -: -dfa_size_limit -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_dfa_size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -/ -/ -The -default -for -this -is -VERY -small -because -building -a -full -DFA -is -/ -/ -ridiculously -costly -. -But -for -regexes -that -are -very -small -it -can -be -/ -/ -beneficial -to -use -a -full -DFA -. -In -particular -a -full -DFA -can -enable -/ -/ -additional -optimizations -via -something -called -" -accelerated -" -states -. -/ -/ -Namely -when -there -' -s -a -state -with -only -a -few -outgoing -transitions -/ -/ -we -can -temporary -suspend -walking -the -transition -table -and -use -memchr -/ -/ -for -just -those -outgoing -transitions -to -skip -ahead -very -quickly -. -/ -/ -/ -/ -Generally -speaking -if -Unicode -is -enabled -in -your -regex -and -you -' -re -/ -/ -using -some -kind -of -Unicode -feature -then -it -' -s -going -to -blow -this -/ -/ -size -limit -. -Moreover -Unicode -tends -to -defeat -the -" -accelerated -" -/ -/ -state -optimization -too -so -it -' -s -a -double -whammy -. -/ -/ -/ -/ -We -also -use -a -limit -on -the -number -of -NFA -states -to -avoid -even -/ -/ -starting -the -DFA -construction -process -. -Namely -DFA -construction -/ -/ -itself -could -make -lots -of -initial -allocs -proportional -to -the -size -/ -/ -of -the -NFA -and -if -the -NFA -is -large -it -doesn -' -t -make -sense -to -pay -/ -/ -that -cost -if -we -know -it -' -s -likely -to -be -blown -by -a -large -margin -. -self -. -dfa_size_limit -. -unwrap_or -( -Some -( -40 -* -( -1 -< -< -10 -) -) -) -} -/ -/ -/ -Returns -DFA -size -limit -in -terms -of -the -number -of -states -in -the -NFA -as -/ -/ -/ -set -by -[ -Config -: -: -dfa_state_limit -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_dfa_state_limit -( -& -self -) -- -> -Option -< -usize -> -{ -/ -/ -Again -as -with -the -size -limit -we -keep -this -very -small -. -self -. -dfa_state_limit -. -unwrap_or -( -Some -( -30 -) -) -} -/ -/ -/ -Returns -whether -byte -classes -are -enabled -as -set -by -/ -/ -/ -[ -Config -: -: -byte_classes -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_byte_classes -( -& -self -) -- -> -bool -{ -self -. -byte_classes -. -unwrap_or -( -true -) -} -/ -/ -/ -Returns -the -line -terminator -for -this -configuration -as -set -by -/ -/ -/ -[ -Config -: -: -line_terminator -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_line_terminator -( -& -self -) -- -> -u8 -{ -self -. -line_terminator -. -unwrap_or -( -b -' -\ -n -' -) -} -/ -/ -/ -Returns -whether -the -hybrid -NFA -/ -DFA -regex -engine -may -be -used -as -set -by -/ -/ -/ -[ -Config -: -: -hybrid -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_hybrid -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -self -. -hybrid -. -unwrap_or -( -true -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -false -} -} -/ -/ -/ -Returns -whether -the -DFA -regex -engine -may -be -used -as -set -by -/ -/ -/ -[ -Config -: -: -dfa -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_dfa -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -self -. -dfa -. -unwrap_or -( -true -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -false -} -} -/ -/ -/ -Returns -whether -the -one -- -pass -DFA -regex -engine -may -be -used -as -set -by -/ -/ -/ -[ -Config -: -: -onepass -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_onepass -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -{ -self -. -onepass -. -unwrap_or -( -true -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -{ -false -} -} -/ -/ -/ -Returns -whether -the -bounded -backtracking -regex -engine -may -be -used -as -/ -/ -/ -set -by -[ -Config -: -: -backtrack -] -. -/ -/ -/ -/ -/ -/ -If -it -was -not -explicitly -set -then -a -default -value -is -returned -. -pub -fn -get_backtrack -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -{ -self -. -backtrack -. -unwrap_or -( -true -) -} -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -{ -false -} -} -/ -/ -/ -Overwrite -the -default -configuration -such -that -the -options -in -o -are -/ -/ -/ -always -used -. -If -an -option -in -o -is -not -set -then -the -corresponding -/ -/ -/ -option -in -self -is -used -. -If -it -' -s -not -set -in -self -either -then -it -/ -/ -/ -remains -not -set -. -pub -( -crate -) -fn -overwrite -( -& -self -o -: -Config -) -- -> -Config -{ -Config -{ -match_kind -: -o -. -match_kind -. -or -( -self -. -match_kind -) -utf8_empty -: -o -. -utf8_empty -. -or -( -self -. -utf8_empty -) -autopre -: -o -. -autopre -. -or -( -self -. -autopre -) -pre -: -o -. -pre -. -or_else -( -| -| -self -. -pre -. -clone -( -) -) -which_captures -: -o -. -which_captures -. -or -( -self -. -which_captures -) -nfa_size_limit -: -o -. -nfa_size_limit -. -or -( -self -. -nfa_size_limit -) -onepass_size_limit -: -o -. -onepass_size_limit -. -or -( -self -. -onepass_size_limit -) -hybrid_cache_capacity -: -o -. -hybrid_cache_capacity -. -or -( -self -. -hybrid_cache_capacity -) -hybrid -: -o -. -hybrid -. -or -( -self -. -hybrid -) -dfa -: -o -. -dfa -. -or -( -self -. -dfa -) -dfa_size_limit -: -o -. -dfa_size_limit -. -or -( -self -. -dfa_size_limit -) -dfa_state_limit -: -o -. -dfa_state_limit -. -or -( -self -. -dfa_state_limit -) -onepass -: -o -. -onepass -. -or -( -self -. -onepass -) -backtrack -: -o -. -backtrack -. -or -( -self -. -backtrack -) -byte_classes -: -o -. -byte_classes -. -or -( -self -. -byte_classes -) -line_terminator -: -o -. -line_terminator -. -or -( -self -. -line_terminator -) -} -} -} -/ -/ -/ -A -builder -for -configuring -and -constructing -a -Regex -. -/ -/ -/ -/ -/ -/ -The -builder -permits -configuring -two -different -aspects -of -a -Regex -: -/ -/ -/ -/ -/ -/ -* -[ -Builder -: -: -configure -] -will -set -high -- -level -configuration -options -as -/ -/ -/ -described -by -a -[ -Config -] -. -/ -/ -/ -* -[ -Builder -: -: -syntax -] -will -set -the -syntax -level -configuration -options -/ -/ -/ -as -described -by -a -[ -util -: -: -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -This -only -applies -when -building -a -Regex -from -pattern -strings -. -/ -/ -/ -/ -/ -/ -Once -configured -the -builder -can -then -be -used -to -construct -a -Regex -from -/ -/ -/ -one -of -4 -different -inputs -: -/ -/ -/ -/ -/ -/ -* -[ -Builder -: -: -build -] -creates -a -regex -from -a -single -pattern -string -. -/ -/ -/ -* -[ -Builder -: -: -build_many -] -creates -a -regex -from -many -pattern -strings -. -/ -/ -/ -* -[ -Builder -: -: -build_from_hir -] -creates -a -regex -from -a -/ -/ -/ -[ -regex -- -syntax -: -: -Hir -] -( -Hir -) -expression -. -/ -/ -/ -* -[ -Builder -: -: -build_many_from_hir -] -creates -a -regex -from -many -/ -/ -/ -[ -regex -- -syntax -: -: -Hir -] -( -Hir -) -expressions -. -/ -/ -/ -/ -/ -/ -The -latter -two -methods -in -particular -provide -a -way -to -construct -a -fully -/ -/ -/ -feature -regular -expression -matcher -directly -from -an -Hir -expression -/ -/ -/ -without -having -to -first -convert -it -to -a -string -. -( -This -is -in -contrast -to -the -/ -/ -/ -top -- -level -regex -crate -which -intentionally -provides -no -such -API -in -order -/ -/ -/ -to -avoid -making -regex -- -syntax -a -public -dependency -. -) -/ -/ -/ -/ -/ -/ -As -a -convenience -this -builder -may -be -created -via -[ -Regex -: -: -builder -] -which -/ -/ -/ -may -help -avoid -an -extra -import -. -/ -/ -/ -/ -/ -/ -# -Example -: -change -the -line -terminator -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -enable -multi -- -line -mode -by -default -and -change -the -/ -/ -/ -line -terminator -to -the -NUL -byte -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -multi_line -( -true -) -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -line_terminator -( -b -' -\ -x00 -' -) -) -/ -/ -/ -. -build -( -r -" -^ -foo -" -) -? -; -/ -/ -/ -let -hay -= -" -\ -x00foo -\ -x00 -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -4 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -disable -UTF -- -8 -requirement -/ -/ -/ -/ -/ -/ -By -default -regex -patterns -are -required -to -match -UTF -- -8 -. -This -includes -/ -/ -/ -regex -patterns -that -can -produce -matches -of -length -zero -. -In -the -case -of -an -/ -/ -/ -empty -match -by -default -matches -will -not -appear -between -the -code -units -of -/ -/ -/ -a -UTF -- -8 -encoded -codepoint -. -/ -/ -/ -/ -/ -/ -However -it -can -be -useful -to -disable -this -requirement -particularly -if -/ -/ -/ -you -' -re -searching -things -like -& -[ -u8 -] -that -are -not -known -to -be -valid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -mut -builder -= -Regex -: -: -builder -( -) -; -/ -/ -/ -/ -/ -Disables -the -requirement -that -non -- -empty -matches -match -UTF -- -8 -. -/ -/ -/ -builder -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -; -/ -/ -/ -/ -/ -Disables -the -requirement -that -empty -matches -match -UTF -- -8 -boundaries -. -/ -/ -/ -builder -. -configure -( -Regex -: -: -config -( -) -. -utf8_empty -( -false -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -can -match -raw -bytes -via -\ -xZZ -syntax -but -we -need -to -disable -/ -/ -/ -/ -/ -Unicode -mode -to -do -that -. -We -could -disable -it -everywhere -or -just -/ -/ -/ -/ -/ -selectively -as -shown -here -. -/ -/ -/ -let -re -= -builder -. -build -( -r -" -( -? -- -u -: -\ -xFF -) -foo -( -? -- -u -: -\ -xFF -) -" -) -? -; -/ -/ -/ -let -hay -= -b -" -\ -xFFfoo -\ -xFF -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -5 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -can -also -match -between -code -units -. -/ -/ -/ -let -re -= -builder -. -build -( -r -" -" -) -? -; -/ -/ -/ -let -hay -= -" -" -; -/ -/ -/ -assert_eq -! -( -re -. -find_iter -( -hay -) -. -collect -: -: -< -Vec -< -Match -> -> -( -) -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -0 -) -/ -/ -/ -Match -: -: -must -( -0 -1 -. -. -1 -) -/ -/ -/ -Match -: -: -must -( -0 -2 -. -. -2 -) -/ -/ -/ -Match -: -: -must -( -0 -3 -. -. -3 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Builder -{ -config -: -Config -ast -: -ast -: -: -parse -: -: -ParserBuilder -hir -: -hir -: -: -translate -: -: -TranslatorBuilder -} -impl -Builder -{ -/ -/ -/ -Creates -a -new -builder -for -configuring -and -constructing -a -[ -Regex -] -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -{ -config -: -Config -: -: -default -( -) -ast -: -ast -: -: -parse -: -: -ParserBuilder -: -: -new -( -) -hir -: -hir -: -: -translate -: -: -TranslatorBuilder -: -: -new -( -) -} -} -/ -/ -/ -Builds -a -Regex -from -a -single -pattern -string -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -the -pattern -or -a -problem -turning -it -into -/ -/ -/ -a -regex -matcher -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -configure -syntax -options -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -crlf -( -true -) -. -multi_line -( -true -) -) -/ -/ -/ -. -build -( -r -" -^ -foo -" -) -? -; -/ -/ -/ -let -hay -= -" -\ -r -\ -nfoo -\ -r -\ -n -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -5 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -Regex -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Builds -a -Regex -from -many -pattern -strings -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -any -of -the -patterns -or -a -problem -turning -/ -/ -/ -them -into -a -regex -matcher -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -# -Example -: -finding -the -pattern -that -caused -an -error -/ -/ -/ -/ -/ -/ -When -a -syntax -error -occurs -it -is -possible -to -ask -which -pattern -/ -/ -/ -caused -the -syntax -error -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -err -= -Regex -: -: -builder -( -) -/ -/ -/ -. -build_many -( -& -[ -" -a -" -" -b -" -r -" -\ -p -{ -Foo -} -" -" -c -" -] -) -/ -/ -/ -. -unwrap_err -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -2 -) -) -err -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -zero -patterns -is -valid -/ -/ -/ -/ -/ -/ -Building -a -regex -with -zero -patterns -results -in -a -regex -that -never -/ -/ -/ -matches -anything -. -Because -this -routine -is -generic -passing -an -empty -/ -/ -/ -slice -usually -requires -a -turbo -- -fish -( -or -something -else -to -help -type -/ -/ -/ -inference -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -build_many -: -: -< -& -str -> -( -& -[ -] -) -? -; -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -" -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -Regex -BuildError -> -{ -use -crate -: -: -util -: -: -primitives -: -: -IteratorIndexExt -; -log -! -{ -debug -! -( -" -building -meta -regex -with -{ -} -patterns -: -" -patterns -. -len -( -) -) -; -for -( -pid -p -) -in -patterns -. -iter -( -) -. -with_pattern_ids -( -) -{ -let -p -= -p -. -as_ref -( -) -; -/ -/ -We -might -split -a -grapheme -with -this -truncation -logic -but -/ -/ -that -' -s -fine -. -We -at -least -avoid -splitting -a -codepoint -. -let -maxoff -= -p -. -char_indices -( -) -. -map -( -| -( -i -ch -) -| -i -+ -ch -. -len_utf8 -( -) -) -. -take -( -1000 -) -. -last -( -) -. -unwrap_or -( -0 -) -; -if -maxoff -< -p -. -len -( -) -{ -debug -! -( -" -{ -: -? -} -: -{ -} -[ -. -. -. -snip -. -. -. -] -" -pid -& -p -[ -. -. -maxoff -] -) -; -} -else -{ -debug -! -( -" -{ -: -? -} -: -{ -} -" -pid -p -) -; -} -} -} -let -( -mut -asts -mut -hirs -) -= -( -vec -! -[ -] -vec -! -[ -] -) -; -for -( -pid -p -) -in -patterns -. -iter -( -) -. -with_pattern_ids -( -) -{ -let -ast -= -self -. -ast -. -build -( -) -. -parse -( -p -. -as_ref -( -) -) -. -map_err -( -| -err -| -BuildError -: -: -ast -( -pid -err -) -) -? -; -asts -. -push -( -ast -) -; -} -for -( -( -pid -p -) -ast -) -in -patterns -. -iter -( -) -. -with_pattern_ids -( -) -. -zip -( -asts -. -iter -( -) -) -{ -let -hir -= -self -. -hir -. -build -( -) -. -translate -( -p -. -as_ref -( -) -ast -) -. -map_err -( -| -err -| -BuildError -: -: -hir -( -pid -err -) -) -? -; -hirs -. -push -( -hir -) -; -} -self -. -build_many_from_hir -( -& -hirs -) -} -/ -/ -/ -Builds -a -Regex -directly -from -an -Hir -expression -. -/ -/ -/ -/ -/ -/ -This -is -useful -if -you -needed -to -parse -a -pattern -string -into -an -Hir -/ -/ -/ -for -other -reasons -( -such -as -analysis -or -transformations -) -. -This -routine -/ -/ -/ -permits -building -a -Regex -directly -from -the -Hir -expression -instead -/ -/ -/ -of -first -converting -the -Hir -back -to -a -pattern -string -. -/ -/ -/ -/ -/ -/ -When -using -this -method -any -options -set -via -[ -Builder -: -: -syntax -] -are -/ -/ -/ -ignored -. -Namely -the -syntax -options -only -apply -when -parsing -a -pattern -/ -/ -/ -string -which -isn -' -t -relevant -here -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -building -the -underlying -regex -matcher -for -the -/ -/ -/ -given -Hir -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -one -can -hand -- -construct -an -Hir -expression -and -/ -/ -/ -build -a -regex -from -it -without -doing -any -parsing -at -all -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -{ -/ -/ -/ -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -/ -/ -/ -regex_syntax -: -: -hir -: -: -{ -Hir -Look -} -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -( -? -Rm -) -^ -foo -/ -/ -/ -let -hir -= -Hir -: -: -concat -( -vec -! -[ -/ -/ -/ -Hir -: -: -look -( -Look -: -: -StartCRLF -) -/ -/ -/ -Hir -: -: -literal -( -" -foo -" -. -as_bytes -( -) -) -/ -/ -/ -Hir -: -: -look -( -Look -: -: -EndCRLF -) -/ -/ -/ -] -) -; -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -build_from_hir -( -& -hir -) -? -; -/ -/ -/ -let -hay -= -" -\ -r -\ -nfoo -\ -r -\ -n -" -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -5 -) -) -re -. -find -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_from_hir -( -& -self -hir -: -& -Hir -) -- -> -Result -< -Regex -BuildError -> -{ -self -. -build_many_from_hir -( -& -[ -hir -] -) -} -/ -/ -/ -Builds -a -Regex -directly -from -many -Hir -expressions -. -/ -/ -/ -/ -/ -/ -This -is -useful -if -you -needed -to -parse -pattern -strings -into -Hir -/ -/ -/ -expressions -for -other -reasons -( -such -as -analysis -or -transformations -) -. -/ -/ -/ -This -routine -permits -building -a -Regex -directly -from -the -Hir -/ -/ -/ -expressions -instead -of -first -converting -the -Hir -expressions -back -to -/ -/ -/ -pattern -strings -. -/ -/ -/ -/ -/ -/ -When -using -this -method -any -options -set -via -[ -Builder -: -: -syntax -] -are -/ -/ -/ -ignored -. -Namely -the -syntax -options -only -apply -when -parsing -a -pattern -/ -/ -/ -string -which -isn -' -t -relevant -here -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -building -the -underlying -regex -matcher -for -the -/ -/ -/ -given -Hir -expressions -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -[ -Builder -: -: -build_many -] -this -can -only -fail -as -a -/ -/ -/ -result -of -building -the -underlying -matcher -. -In -that -case -there -is -/ -/ -/ -no -single -Hir -expression -that -can -be -isolated -as -a -reason -for -the -/ -/ -/ -failure -. -So -if -this -routine -fails -it -' -s -not -possible -to -determine -which -/ -/ -/ -Hir -expression -caused -the -failure -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -one -can -hand -- -construct -multiple -Hir -/ -/ -/ -expressions -and -build -a -single -regex -from -them -without -doing -any -/ -/ -/ -parsing -at -all -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -{ -/ -/ -/ -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -/ -/ -/ -regex_syntax -: -: -hir -: -: -{ -Hir -Look -} -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -( -? -Rm -) -^ -foo -/ -/ -/ -let -hir1 -= -Hir -: -: -concat -( -vec -! -[ -/ -/ -/ -Hir -: -: -look -( -Look -: -: -StartCRLF -) -/ -/ -/ -Hir -: -: -literal -( -" -foo -" -. -as_bytes -( -) -) -/ -/ -/ -Hir -: -: -look -( -Look -: -: -EndCRLF -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -( -? -Rm -) -^ -bar -/ -/ -/ -let -hir2 -= -Hir -: -: -concat -( -vec -! -[ -/ -/ -/ -Hir -: -: -look -( -Look -: -: -StartCRLF -) -/ -/ -/ -Hir -: -: -literal -( -" -bar -" -. -as_bytes -( -) -) -/ -/ -/ -Hir -: -: -look -( -Look -: -: -EndCRLF -) -/ -/ -/ -] -) -; -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -build_many_from_hir -( -& -[ -& -hir1 -& -hir2 -] -) -? -; -/ -/ -/ -let -hay -= -" -\ -r -\ -nfoo -\ -r -\ -nbar -" -; -/ -/ -/ -let -got -: -Vec -< -Match -> -= -re -. -find_iter -( -hay -) -. -collect -( -) -; -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -2 -. -. -5 -) -/ -/ -/ -Match -: -: -must -( -1 -7 -. -. -10 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_many_from_hir -< -H -: -Borrow -< -Hir -> -> -( -& -self -hirs -: -& -[ -H -] -) -- -> -Result -< -Regex -BuildError -> -{ -let -config -= -self -. -config -. -clone -( -) -; -/ -/ -We -collect -the -HIRs -into -a -vec -so -we -can -write -internal -routines -/ -/ -with -' -& -[ -& -Hir -] -' -. -i -. -e -. -Don -' -t -use -generics -everywhere -to -keep -code -/ -/ -bloat -down -. -. -let -hirs -: -Vec -< -& -Hir -> -= -hirs -. -iter -( -) -. -map -( -| -hir -| -hir -. -borrow -( -) -) -. -collect -( -) -; -let -info -= -RegexInfo -: -: -new -( -config -& -hirs -) -; -let -strat -= -strategy -: -: -new -( -& -info -& -hirs -) -? -; -let -pool -= -{ -let -strat -= -Arc -: -: -clone -( -& -strat -) -; -let -create -: -CachePoolFn -= -Box -: -: -new -( -move -| -| -strat -. -create_cache -( -) -) -; -Pool -: -: -new -( -create -) -} -; -Ok -( -Regex -{ -imp -: -Arc -: -: -new -( -RegexI -{ -strat -info -} -) -pool -} -) -} -/ -/ -/ -Configure -the -behavior -of -a -Regex -. -/ -/ -/ -/ -/ -/ -This -configuration -controls -non -- -syntax -options -related -to -the -behavior -/ -/ -/ -of -a -Regex -. -This -includes -things -like -whether -empty -matches -can -split -/ -/ -/ -a -codepoint -prefilters -line -terminators -and -a -long -list -of -options -/ -/ -/ -for -configuring -which -regex -engines -the -meta -regex -engine -will -be -able -/ -/ -/ -to -use -internally -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -disable -UTF -- -8 -empty -mode -. -This -will -permit -/ -/ -/ -empty -matches -to -occur -between -the -UTF -- -8 -encoding -of -a -codepoint -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -" -) -? -; -/ -/ -/ -let -got -: -Vec -< -Match -> -= -re -. -find_iter -( -" -" -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Matches -only -occur -at -the -beginning -and -end -of -the -snowman -. -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -0 -) -/ -/ -/ -Match -: -: -must -( -0 -3 -. -. -3 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -configure -( -Regex -: -: -config -( -) -. -utf8_empty -( -false -) -) -/ -/ -/ -. -build -( -" -" -) -? -; -/ -/ -/ -let -got -: -Vec -< -Match -> -= -re -. -find_iter -( -" -" -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Matches -now -occur -at -every -position -! -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -0 -) -/ -/ -/ -Match -: -: -must -( -0 -1 -. -. -1 -) -/ -/ -/ -Match -: -: -must -( -0 -2 -. -. -2 -) -/ -/ -/ -Match -: -: -must -( -0 -3 -. -. -3 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -configure -( -& -mut -self -config -: -Config -) -- -> -& -mut -Builder -{ -self -. -config -= -self -. -config -. -overwrite -( -config -) -; -self -} -/ -/ -/ -Configure -the -syntax -options -when -parsing -a -pattern -string -while -/ -/ -/ -building -a -Regex -. -/ -/ -/ -/ -/ -/ -These -options -_only_ -apply -when -[ -Builder -: -: -build -] -or -[ -Builder -: -: -build_many -] -/ -/ -/ -are -used -. -The -other -build -methods -accept -Hir -values -which -have -/ -/ -/ -already -been -parsed -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -enable -case -insensitive -mode -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -meta -: -: -Regex -util -: -: -syntax -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -case_insensitive -( -true -) -) -/ -/ -/ -. -build -( -r -" -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -re -. -find -( -r -" -" -) -) -; -/ -/ -/ -/ -/ -/ -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Builder -{ -config -. -apply_ast -( -& -mut -self -. -ast -) -; -config -. -apply_hir -( -& -mut -self -. -hir -) -; -self -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -super -: -: -* -; -/ -/ -I -found -this -in -the -course -of -building -out -the -benchmark -suite -for -/ -/ -rebar -. -# -[ -test -] -fn -regression -( -) -{ -env_logger -: -: -init -( -) -; -let -re -= -Regex -: -: -new -( -r -" -[ -a -- -zA -- -Z -] -+ -ing -" -) -. -unwrap -( -) -; -assert_eq -! -( -1 -re -. -find_iter -( -" -tingling -" -) -. -count -( -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/meta/reverse_inner.rs b/third_party/rust/regex-automata/src/meta/reverse_inner.rs deleted file mode 100644 index 7b9539ab877c7..0000000000000 --- a/third_party/rust/regex-automata/src/meta/reverse_inner.rs +++ /dev/null @@ -1,2210 +0,0 @@ -/ -* -! -A -module -dedicated -to -plucking -inner -literals -out -of -a -regex -pattern -and -then -constructing -a -prefilter -for -them -. -We -also -include -a -regex -pattern -" -prefix -" -that -corresponds -to -the -bits -of -the -regex -that -need -to -match -before -the -literals -do -. -The -reverse -inner -optimization -then -proceeds -by -looking -for -matches -of -the -inner -literal -( -s -) -and -then -doing -a -reverse -search -of -the -prefix -from -the -start -of -the -literal -match -to -find -the -overall -start -position -of -the -match -. -The -essential -invariant -we -want -to -uphold -here -is -that -the -literals -we -return -reflect -a -set -where -* -at -least -* -one -of -them -must -match -in -order -for -the -overall -regex -to -match -. -We -also -need -to -maintain -the -invariant -that -the -regex -prefix -returned -corresponds -to -the -entirety -of -the -regex -up -until -the -literals -we -return -. -This -somewhat -limits -what -we -can -do -. -That -is -if -we -a -regex -like -\ -w -+ -( -! -| -% -% -) -\ -w -+ -then -we -can -pluck -the -{ -! -% -% -} -out -and -build -a -prefilter -from -it -. -Then -we -just -need -to -compile -\ -w -+ -in -reverse -. -No -fuss -no -muss -. -But -if -we -have -a -regex -like -\ -d -+ -! -| -\ -w -+ -% -% -then -we -get -kind -of -stymied -. -Technically -we -could -still -extract -{ -! -% -% -} -and -it -is -true -that -at -least -of -them -must -match -. -But -then -what -is -our -regex -prefix -? -Again -in -theory -that -could -be -\ -d -+ -| -\ -w -+ -but -that -' -s -not -quite -right -because -the -\ -d -+ -only -matches -when -! -matches -and -\ -w -+ -only -matches -when -% -% -matches -. -All -of -that -is -technically -possible -to -do -but -it -seemingly -requires -a -lot -of -sophistication -and -machinery -. -Probably -the -way -to -tackle -that -is -with -some -kind -of -formalism -and -approach -this -problem -more -generally -. -For -now -the -code -below -basically -just -looks -for -a -top -- -level -concatenation -. -And -if -it -can -find -one -it -looks -for -literals -in -each -of -the -direct -child -sub -- -expressions -of -that -concatenation -. -If -some -good -ones -are -found -we -return -those -and -a -concatenation -of -the -Hir -expressions -seen -up -to -that -point -. -* -/ -use -alloc -: -: -vec -: -: -Vec -; -use -regex_syntax -: -: -hir -: -: -{ -self -literal -Hir -HirKind -} -; -use -crate -: -: -{ -util -: -: -prefilter -: -: -Prefilter -MatchKind -} -; -/ -/ -/ -Attempts -to -extract -an -" -inner -" -prefilter -from -the -given -HIR -expressions -. -If -/ -/ -/ -one -was -found -then -a -concatenation -of -the -HIR -expressions -that -precede -it -/ -/ -/ -is -returned -. -/ -/ -/ -/ -/ -/ -The -idea -here -is -that -the -prefilter -returned -can -be -used -to -find -candidate -/ -/ -/ -matches -. -And -then -the -HIR -returned -can -be -used -to -build -a -reverse -regex -/ -/ -/ -matcher -which -will -find -the -start -of -the -candidate -match -. -Finally -the -/ -/ -/ -match -still -has -to -be -confirmed -with -a -normal -anchored -forward -scan -to -find -/ -/ -/ -the -end -position -of -the -match -. -/ -/ -/ -/ -/ -/ -Note -that -this -assumes -leftmost -- -first -match -semantics -so -callers -must -/ -/ -/ -not -call -this -otherwise -. -pub -( -crate -) -fn -extract -( -hirs -: -& -[ -& -Hir -] -) -- -> -Option -< -( -Hir -Prefilter -) -> -{ -if -hirs -. -len -( -) -! -= -1 -{ -debug -! -( -" -skipping -reverse -inner -optimization -since -it -only -\ -supports -1 -pattern -{ -} -were -given -" -hirs -. -len -( -) -) -; -return -None -; -} -let -mut -concat -= -match -top_concat -( -hirs -[ -0 -] -) -{ -Some -( -concat -) -= -> -concat -None -= -> -{ -debug -! -( -" -skipping -reverse -inner -optimization -because -a -top -- -level -\ -concatenation -could -not -found -" -) -; -return -None -; -} -} -; -/ -/ -We -skip -the -first -HIR -because -if -it -did -have -a -prefix -prefilter -in -it -/ -/ -we -probably -wouldn -' -t -be -here -looking -for -an -inner -prefilter -. -for -i -in -1 -. -. -concat -. -len -( -) -{ -let -hir -= -& -concat -[ -i -] -; -let -pre -= -match -prefilter -( -hir -) -{ -None -= -> -continue -Some -( -pre -) -= -> -pre -} -; -/ -/ -Even -if -we -got -a -prefilter -if -it -isn -' -t -consider -" -fast -" -then -we -/ -/ -probably -don -' -t -want -to -bother -with -it -. -Namely -since -the -reverse -/ -/ -inner -optimization -requires -some -overhead -it -likely -only -makes -/ -/ -sense -if -the -prefilter -scan -itself -is -( -believed -) -to -be -much -faster -/ -/ -than -the -regex -engine -. -if -! -pre -. -is_fast -( -) -{ -debug -! -( -" -skipping -extracted -inner -prefilter -because -\ -it -probably -isn -' -t -fast -" -) -; -continue -; -} -let -concat_suffix -= -Hir -: -: -concat -( -concat -. -split_off -( -i -) -) -; -let -concat_prefix -= -Hir -: -: -concat -( -concat -) -; -/ -/ -Look -for -a -prefilter -again -. -Why -? -Because -above -we -only -looked -for -/ -/ -a -prefilter -on -the -individual -' -hir -' -but -we -might -be -able -to -find -/ -/ -something -better -and -more -discriminatory -by -looking -at -the -entire -/ -/ -suffix -. -We -don -' -t -do -this -above -to -avoid -making -this -loop -worst -case -/ -/ -quadratic -in -the -length -of -' -concat -' -. -let -pre2 -= -match -prefilter -( -& -concat_suffix -) -{ -None -= -> -pre -Some -( -pre2 -) -= -> -{ -if -pre2 -. -is_fast -( -) -{ -pre2 -} -else -{ -pre -} -} -} -; -return -Some -( -( -concat_prefix -pre2 -) -) -; -} -debug -! -( -" -skipping -reverse -inner -optimization -because -a -top -- -level -\ -sub -- -expression -with -a -fast -prefilter -could -not -be -found -" -) -; -None -} -/ -/ -/ -Attempt -to -extract -a -prefilter -from -an -HIR -expression -. -/ -/ -/ -/ -/ -/ -We -do -a -little -massaging -here -to -do -our -best -that -the -prefilter -we -get -out -/ -/ -/ -of -this -is -* -probably -* -fast -. -Basically -the -false -positive -rate -has -a -much -/ -/ -/ -higher -impact -for -things -like -the -reverse -inner -optimization -because -more -/ -/ -/ -work -needs -to -potentially -be -done -for -each -candidate -match -. -/ -/ -/ -/ -/ -/ -Note -that -this -assumes -leftmost -- -first -match -semantics -so -callers -must -/ -/ -/ -not -call -this -otherwise -. -fn -prefilter -( -hir -: -& -Hir -) -- -> -Option -< -Prefilter -> -{ -let -mut -extractor -= -literal -: -: -Extractor -: -: -new -( -) -; -extractor -. -kind -( -literal -: -: -ExtractKind -: -: -Prefix -) -; -let -mut -prefixes -= -extractor -. -extract -( -hir -) -; -debug -! -( -" -inner -prefixes -( -len -= -{ -: -? -} -) -extracted -before -optimization -: -{ -: -? -} -" -prefixes -. -len -( -) -prefixes -) -; -/ -/ -Since -these -are -inner -literals -we -know -they -cannot -be -exact -. -But -the -/ -/ -extractor -doesn -' -t -know -this -. -We -mark -them -as -inexact -because -this -might -/ -/ -impact -literal -optimization -. -Namely -optimization -weights -" -all -literals -/ -/ -are -exact -" -as -very -high -because -it -presumes -that -any -match -results -in -/ -/ -an -overall -match -. -But -of -course -that -is -not -the -case -here -. -/ -/ -/ -/ -In -practice -this -avoids -plucking -out -a -ASCII -- -only -\ -s -as -an -alternation -/ -/ -of -single -- -byte -whitespace -characters -. -prefixes -. -make_inexact -( -) -; -prefixes -. -optimize_for_prefix_by_preference -( -) -; -debug -! -( -" -inner -prefixes -( -len -= -{ -: -? -} -) -extracted -after -optimization -: -{ -: -? -} -" -prefixes -. -len -( -) -prefixes -) -; -prefixes -. -literals -( -) -. -and_then -( -| -lits -| -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -lits -) -) -} -/ -/ -/ -Looks -for -a -" -top -level -" -HirKind -: -: -Concat -item -in -the -given -HIR -. -This -will -/ -/ -/ -try -to -return -one -even -if -it -' -s -embedded -in -a -capturing -group -but -is -/ -/ -/ -otherwise -pretty -conservative -in -what -is -returned -. -/ -/ -/ -/ -/ -/ -The -HIR -returned -is -a -complete -copy -of -the -concat -with -all -capturing -/ -/ -/ -groups -removed -. -In -effect -the -concat -returned -is -" -flattened -" -with -respect -/ -/ -/ -to -capturing -groups -. -This -makes -the -detection -logic -above -for -prefixes -/ -/ -/ -a -bit -simpler -and -it -works -because -1 -) -capturing -groups -never -influence -/ -/ -/ -whether -a -match -occurs -or -not -and -2 -) -capturing -groups -are -not -used -when -/ -/ -/ -doing -the -reverse -inner -search -to -find -the -start -of -the -match -. -fn -top_concat -( -mut -hir -: -& -Hir -) -- -> -Option -< -Vec -< -Hir -> -> -{ -loop -{ -hir -= -match -hir -. -kind -( -) -{ -HirKind -: -: -Empty -| -HirKind -: -: -Literal -( -_ -) -| -HirKind -: -: -Class -( -_ -) -| -HirKind -: -: -Look -( -_ -) -| -HirKind -: -: -Repetition -( -_ -) -| -HirKind -: -: -Alternation -( -_ -) -= -> -return -None -HirKind -: -: -Capture -( -hir -: -: -Capture -{ -ref -sub -. -. -} -) -= -> -sub -HirKind -: -: -Concat -( -ref -subs -) -= -> -{ -/ -/ -We -are -careful -to -only -do -the -flattening -/ -copy -when -we -know -/ -/ -we -have -a -" -top -level -" -concat -we -can -inspect -. -This -avoids -/ -/ -doing -extra -work -in -cases -where -we -definitely -won -' -t -use -it -. -/ -/ -( -This -might -still -be -wasted -work -if -we -can -' -t -go -on -to -find -/ -/ -some -literals -to -extract -. -) -let -concat -= -Hir -: -: -concat -( -subs -. -iter -( -) -. -map -( -| -h -| -flatten -( -h -) -) -. -collect -( -) -) -; -return -match -concat -. -into_kind -( -) -{ -HirKind -: -: -Concat -( -xs -) -= -> -Some -( -xs -) -/ -/ -It -is -actually -possible -for -this -case -to -occur -because -/ -/ -' -Hir -: -: -concat -' -might -simplify -the -expression -to -the -point -/ -/ -that -concatenations -are -actually -removed -. -One -wonders -/ -/ -whether -this -leads -to -other -cases -where -we -should -be -/ -/ -extracting -literals -but -in -theory -I -believe -if -we -do -/ -/ -get -here -then -it -means -that -a -" -real -" -prefilter -failed -/ -/ -to -be -extracted -and -we -should -probably -leave -well -enough -/ -/ -alone -. -( -A -" -real -" -prefilter -is -unbothered -by -" -top -- -level -/ -/ -concats -" -and -" -capturing -groups -. -" -) -_ -= -> -return -None -} -; -} -} -; -} -} -/ -/ -/ -Returns -a -copy -of -the -given -HIR -but -with -all -capturing -groups -removed -. -fn -flatten -( -hir -: -& -Hir -) -- -> -Hir -{ -match -hir -. -kind -( -) -{ -HirKind -: -: -Empty -= -> -Hir -: -: -empty -( -) -HirKind -: -: -Literal -( -hir -: -: -Literal -( -ref -x -) -) -= -> -Hir -: -: -literal -( -x -. -clone -( -) -) -HirKind -: -: -Class -( -ref -x -) -= -> -Hir -: -: -class -( -x -. -clone -( -) -) -HirKind -: -: -Look -( -ref -x -) -= -> -Hir -: -: -look -( -x -. -clone -( -) -) -HirKind -: -: -Repetition -( -ref -x -) -= -> -Hir -: -: -repetition -( -x -. -with -( -flatten -( -& -x -. -sub -) -) -) -/ -/ -This -is -the -interesting -case -. -We -just -drop -the -group -information -/ -/ -entirely -and -use -the -child -HIR -itself -. -HirKind -: -: -Capture -( -hir -: -: -Capture -{ -ref -sub -. -. -} -) -= -> -flatten -( -sub -) -HirKind -: -: -Alternation -( -ref -xs -) -= -> -{ -Hir -: -: -alternation -( -xs -. -iter -( -) -. -map -( -| -x -| -flatten -( -x -) -) -. -collect -( -) -) -} -HirKind -: -: -Concat -( -ref -xs -) -= -> -{ -Hir -: -: -concat -( -xs -. -iter -( -) -. -map -( -| -x -| -flatten -( -x -) -) -. -collect -( -) -) -} -} -} diff --git a/third_party/rust/regex-automata/src/meta/stopat.rs b/third_party/rust/regex-automata/src/meta/stopat.rs deleted file mode 100644 index 351e2e1958a74..0000000000000 --- a/third_party/rust/regex-automata/src/meta/stopat.rs +++ /dev/null @@ -1,2144 +0,0 @@ -/ -* -! -This -module -defines -two -bespoke -forward -DFA -search -routines -. -One -for -the -lazy -DFA -and -one -for -the -fully -compiled -DFA -. -These -routines -differ -from -the -normal -ones -by -reporting -the -position -at -which -the -search -terminates -when -a -match -* -isn -' -t -* -found -. -This -position -at -which -a -search -terminates -is -useful -in -contexts -where -the -meta -regex -engine -runs -optimizations -that -could -go -quadratic -if -we -aren -' -t -careful -. -Namely -a -regex -search -* -could -* -scan -to -the -end -of -the -haystack -only -to -report -a -non -- -match -. -If -the -caller -doesn -' -t -know -that -the -search -scanned -to -the -end -of -the -haystack -it -might -restart -the -search -at -the -next -literal -candidate -it -finds -and -repeat -the -process -. -Providing -the -caller -with -the -position -at -which -the -search -stopped -provides -a -way -for -the -caller -to -determine -the -point -at -which -subsequent -scans -should -not -pass -. -This -is -principally -used -in -the -" -reverse -inner -" -optimization -which -works -like -this -: -1 -. -Look -for -a -match -of -an -inner -literal -. -Say -' -Z -' -in -' -\ -w -+ -Z -\ -d -+ -' -. -2 -. -At -the -spot -where -' -Z -' -matches -do -a -reverse -anchored -search -from -there -for -' -\ -w -+ -' -. -3 -. -If -the -reverse -search -matches -it -corresponds -to -the -start -position -of -a -( -possible -) -match -. -At -this -point -do -a -forward -anchored -search -to -find -the -end -position -. -If -an -end -position -is -found -then -we -have -a -match -and -we -know -its -bounds -. -If -the -forward -anchored -search -in -( -3 -) -searches -the -entire -rest -of -the -haystack -but -reports -a -non -- -match -then -a -naive -implementation -of -the -above -will -continue -back -at -step -1 -looking -for -more -candidates -. -There -might -still -be -a -match -to -be -found -! -It -' -s -possible -. -But -we -already -scanned -the -whole -haystack -. -So -if -we -keep -repeating -the -process -then -we -might -wind -up -taking -quadratic -time -in -the -size -of -the -haystack -which -is -not -great -. -So -if -the -forward -anchored -search -in -( -3 -) -reports -the -position -at -which -it -stops -then -we -can -detect -whether -quadratic -behavior -might -be -occurring -in -steps -( -1 -) -and -( -2 -) -. -For -( -1 -) -it -occurs -if -the -literal -candidate -found -occurs -* -before -* -the -end -of -the -previous -search -in -( -3 -) -since -that -means -we -' -re -now -going -to -look -for -another -match -in -a -place -where -the -forward -search -has -already -scanned -. -It -is -* -correct -* -to -do -so -but -our -technique -has -become -inefficient -. -For -( -2 -) -quadratic -behavior -occurs -similarly -when -its -reverse -search -extends -past -the -point -where -the -previous -forward -search -in -( -3 -) -terminated -. -Indeed -to -implement -( -2 -) -we -use -the -sibling -' -limited -' -module -for -ensuring -our -reverse -scan -doesn -' -t -go -further -than -we -want -. -See -the -' -opt -/ -reverse -- -inner -' -benchmarks -in -rebar -for -a -real -demonstration -of -how -quadratic -behavior -is -mitigated -. -* -/ -use -crate -: -: -{ -meta -: -: -error -: -: -RetryFailError -HalfMatch -Input -MatchError -} -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -pub -( -crate -) -fn -dfa_try_search_half_fwd -( -dfa -: -& -crate -: -: -dfa -: -: -dense -: -: -DFA -< -alloc -: -: -vec -: -: -Vec -< -u32 -> -> -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Result -< -HalfMatch -usize -> -RetryFailError -> -{ -use -crate -: -: -dfa -: -: -{ -accel -Automaton -} -; -let -mut -mat -= -None -; -let -mut -sid -= -dfa -. -start_state_forward -( -input -) -? -; -let -mut -at -= -input -. -start -( -) -; -while -at -< -input -. -end -( -) -{ -sid -= -dfa -. -next_state -( -sid -input -. -haystack -( -) -[ -at -] -) -; -if -dfa -. -is_special_state -( -sid -) -{ -if -dfa -. -is_match_state -( -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -sid -0 -) -; -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -at -) -) -; -if -input -. -get_earliest -( -) -{ -return -Ok -( -mat -. -ok_or -( -at -) -) -; -} -if -dfa -. -is_accel_state -( -sid -) -{ -let -needs -= -dfa -. -accelerator -( -sid -) -; -at -= -accel -: -: -find_fwd -( -needs -input -. -haystack -( -) -at -) -. -unwrap_or -( -input -. -end -( -) -) -; -continue -; -} -} -else -if -dfa -. -is_accel_state -( -sid -) -{ -let -needs -= -dfa -. -accelerator -( -sid -) -; -at -= -accel -: -: -find_fwd -( -needs -input -. -haystack -( -) -at -) -. -unwrap_or -( -input -. -end -( -) -) -; -continue -; -} -else -if -dfa -. -is_dead_state -( -sid -) -{ -return -Ok -( -mat -. -ok_or -( -at -) -) -; -} -else -if -dfa -. -is_quit_state -( -sid -) -{ -if -mat -. -is_some -( -) -{ -return -Ok -( -mat -. -ok_or -( -at -) -) -; -} -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -at -] -at -) -. -into -( -) -) -; -} -else -{ -/ -/ -Ideally -we -wouldn -' -t -use -a -DFA -that -specialized -start -states -/ -/ -and -thus -' -is_start_state -( -) -' -could -never -be -true -here -but -in -/ -/ -practice -we -reuse -the -DFA -created -for -the -full -regex -which -/ -/ -will -specialize -start -states -whenever -there -is -a -prefilter -. -debug_assert -! -( -dfa -. -is_start_state -( -sid -) -) -; -} -} -at -+ -= -1 -; -} -dfa_eoi_fwd -( -dfa -input -& -mut -sid -& -mut -mat -) -? -; -Ok -( -mat -. -ok_or -( -at -) -) -} -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -pub -( -crate -) -fn -hybrid_try_search_half_fwd -( -dfa -: -& -crate -: -: -hybrid -: -: -dfa -: -: -DFA -cache -: -& -mut -crate -: -: -hybrid -: -: -dfa -: -: -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Result -< -HalfMatch -usize -> -RetryFailError -> -{ -let -mut -mat -= -None -; -let -mut -sid -= -dfa -. -start_state_forward -( -cache -input -) -? -; -let -mut -at -= -input -. -start -( -) -; -while -at -< -input -. -end -( -) -{ -sid -= -dfa -. -next_state -( -cache -sid -input -. -haystack -( -) -[ -at -] -) -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -at -) -) -? -; -if -sid -. -is_tagged -( -) -{ -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -sid -0 -) -; -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -at -) -) -; -if -input -. -get_earliest -( -) -{ -return -Ok -( -mat -. -ok_or -( -at -) -) -; -} -} -else -if -sid -. -is_dead -( -) -{ -return -Ok -( -mat -. -ok_or -( -at -) -) -; -} -else -if -sid -. -is_quit -( -) -{ -if -mat -. -is_some -( -) -{ -return -Ok -( -mat -. -ok_or -( -at -) -) -; -} -return -Err -( -MatchError -: -: -quit -( -input -. -haystack -( -) -[ -at -] -at -) -. -into -( -) -) -; -} -else -{ -/ -/ -We -should -NEVER -get -an -unknown -state -ID -back -from -/ -/ -dfa -. -next_state -( -) -. -debug_assert -! -( -! -sid -. -is_unknown -( -) -) -; -/ -/ -Ideally -we -wouldn -' -t -use -a -lazy -DFA -that -specialized -start -/ -/ -states -and -thus -' -sid -. -is_start -( -) -' -could -never -be -true -here -/ -/ -but -in -practice -we -reuse -the -lazy -DFA -created -for -the -full -/ -/ -regex -which -will -specialize -start -states -whenever -there -is -/ -/ -a -prefilter -. -debug_assert -! -( -sid -. -is_start -( -) -) -; -} -} -at -+ -= -1 -; -} -hybrid_eoi_fwd -( -dfa -cache -input -& -mut -sid -& -mut -mat -) -? -; -Ok -( -mat -. -ok_or -( -at -) -) -} -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -dfa_eoi_fwd -( -dfa -: -& -crate -: -: -dfa -: -: -dense -: -: -DFA -< -alloc -: -: -vec -: -: -Vec -< -u32 -> -> -input -: -& -Input -< -' -_ -> -sid -: -& -mut -crate -: -: -util -: -: -primitives -: -: -StateID -mat -: -& -mut -Option -< -HalfMatch -> -) -- -> -Result -< -( -) -MatchError -> -{ -use -crate -: -: -dfa -: -: -Automaton -; -let -sp -= -input -. -get_span -( -) -; -match -input -. -haystack -( -) -. -get -( -sp -. -end -) -{ -Some -( -& -b -) -= -> -{ -* -sid -= -dfa -. -next_state -( -* -sid -b -) -; -if -dfa -. -is_match_state -( -* -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -sp -. -end -) -) -; -} -else -if -dfa -. -is_quit_state -( -* -sid -) -{ -if -mat -. -is_some -( -) -{ -return -Ok -( -( -) -) -; -} -return -Err -( -MatchError -: -: -quit -( -b -sp -. -end -) -) -; -} -} -None -= -> -{ -* -sid -= -dfa -. -next_eoi_state -( -* -sid -) -; -if -dfa -. -is_match_state -( -* -sid -) -{ -let -pattern -= -dfa -. -match_pattern -( -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -input -. -haystack -( -) -. -len -( -) -) -) -; -} -/ -/ -N -. -B -. -We -don -' -t -have -to -check -' -is_quit -' -here -because -the -EOI -/ -/ -transition -can -never -lead -to -a -quit -state -. -debug_assert -! -( -! -dfa -. -is_quit_state -( -* -sid -) -) -; -} -} -Ok -( -( -) -) -} -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -hybrid_eoi_fwd -( -dfa -: -& -crate -: -: -hybrid -: -: -dfa -: -: -DFA -cache -: -& -mut -crate -: -: -hybrid -: -: -dfa -: -: -Cache -input -: -& -Input -< -' -_ -> -sid -: -& -mut -crate -: -: -hybrid -: -: -LazyStateID -mat -: -& -mut -Option -< -HalfMatch -> -) -- -> -Result -< -( -) -MatchError -> -{ -let -sp -= -input -. -get_span -( -) -; -match -input -. -haystack -( -) -. -get -( -sp -. -end -) -{ -Some -( -& -b -) -= -> -{ -* -sid -= -dfa -. -next_state -( -cache -* -sid -b -) -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -sp -. -end -) -) -? -; -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -sp -. -end -) -) -; -} -else -if -sid -. -is_quit -( -) -{ -if -mat -. -is_some -( -) -{ -return -Ok -( -( -) -) -; -} -return -Err -( -MatchError -: -: -quit -( -b -sp -. -end -) -) -; -} -} -None -= -> -{ -* -sid -= -dfa -. -next_eoi_state -( -cache -* -sid -) -. -map_err -( -| -_ -| -MatchError -: -: -gave_up -( -input -. -haystack -( -) -. -len -( -) -) -) -? -; -if -sid -. -is_match -( -) -{ -let -pattern -= -dfa -. -match_pattern -( -cache -* -sid -0 -) -; -* -mat -= -Some -( -HalfMatch -: -: -new -( -pattern -input -. -haystack -( -) -. -len -( -) -) -) -; -} -/ -/ -N -. -B -. -We -don -' -t -have -to -check -' -is_quit -' -here -because -the -EOI -/ -/ -transition -can -never -lead -to -a -quit -state -. -debug_assert -! -( -! -sid -. -is_quit -( -) -) -; -} -} -Ok -( -( -) -) -} diff --git a/third_party/rust/regex-automata/src/meta/strategy.rs b/third_party/rust/regex-automata/src/meta/strategy.rs deleted file mode 100644 index b58ab7f1ec719..0000000000000 --- a/third_party/rust/regex-automata/src/meta/strategy.rs +++ /dev/null @@ -1,15745 +0,0 @@ -use -core -: -: -{ -fmt -: -: -Debug -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -} -; -use -alloc -: -: -sync -: -: -Arc -; -use -regex_syntax -: -: -hir -: -: -{ -literal -Hir -} -; -use -crate -: -: -{ -meta -: -: -{ -error -: -: -{ -BuildError -RetryError -RetryFailError -RetryQuadraticError -} -regex -: -: -{ -Cache -RegexInfo -} -reverse_inner -wrappers -} -nfa -: -: -thompson -: -: -{ -self -WhichCaptures -NFA -} -util -: -: -{ -captures -: -: -{ -Captures -GroupInfo -} -look -: -: -LookMatcher -prefilter -: -: -{ -self -Prefilter -PrefilterI -} -primitives -: -: -{ -NonMaxUsize -PatternID -} -search -: -: -{ -Anchored -HalfMatch -Input -Match -MatchKind -PatternSet -} -} -} -; -/ -/ -/ -A -trait -that -represents -a -single -meta -strategy -. -Its -main -utility -is -in -/ -/ -/ -providing -a -way -to -do -dynamic -dispatch -over -a -few -choices -. -/ -/ -/ -/ -/ -/ -Why -dynamic -dispatch -? -I -actually -don -' -t -have -a -super -compelling -reason -and -/ -/ -/ -importantly -I -have -not -benchmarked -it -with -the -main -alternative -: -an -enum -. -/ -/ -/ -I -went -with -dynamic -dispatch -initially -because -the -regex -engine -search -code -/ -/ -/ -really -can -' -t -be -inlined -into -caller -code -in -most -cases -because -it -' -s -just -/ -/ -/ -too -big -. -In -other -words -it -is -already -expected -that -every -regex -search -/ -/ -/ -will -entail -at -least -the -cost -of -a -function -call -. -/ -/ -/ -/ -/ -/ -I -do -wonder -whether -using -enums -would -result -in -better -codegen -overall -/ -/ -/ -though -. -It -' -s -a -worthwhile -experiment -to -try -. -Probably -the -most -interesting -/ -/ -/ -benchmark -to -run -in -such -a -case -would -be -one -with -a -high -match -count -. -That -/ -/ -/ -is -a -benchmark -to -test -the -overall -latency -of -a -search -call -. -pub -( -super -) -trait -Strategy -: -Debug -+ -Send -+ -Sync -+ -RefUnwindSafe -+ -UnwindSafe -+ -' -static -{ -fn -group_info -( -& -self -) -- -> -& -GroupInfo -; -fn -create_cache -( -& -self -) -- -> -Cache -; -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -; -fn -is_accelerated -( -& -self -) -- -> -bool -; -fn -memory_usage -( -& -self -) -- -> -usize -; -fn -search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -; -fn -search_half -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -; -fn -is_match -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -bool -; -fn -search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -; -fn -which_overlapping_matches -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -; -} -pub -( -super -) -fn -new -( -info -: -& -RegexInfo -hirs -: -& -[ -& -Hir -] -) -- -> -Result -< -Arc -< -dyn -Strategy -> -BuildError -> -{ -/ -/ -At -this -point -we -' -re -committed -to -a -regex -engine -of -some -kind -. -So -pull -/ -/ -out -a -prefilter -if -we -can -which -will -feed -to -each -of -the -constituent -/ -/ -regex -engines -. -let -pre -= -if -info -. -is_always_anchored_start -( -) -{ -/ -/ -PERF -: -I -' -m -not -sure -we -necessarily -want -to -do -this -. -. -. -We -may -want -to -/ -/ -run -a -prefilter -for -quickly -rejecting -in -some -cases -. -The -problem -/ -/ -is -that -anchored -searches -overlap -quite -a -bit -with -the -use -case -/ -/ -of -" -run -a -regex -on -every -line -to -extract -data -. -" -In -that -case -the -/ -/ -regex -always -matches -so -running -a -prefilter -doesn -' -t -really -help -us -/ -/ -there -. -The -main -place -where -a -prefilter -helps -in -an -anchored -search -/ -/ -is -if -the -anchored -search -is -not -expected -to -match -frequently -. -That -/ -/ -is -the -prefilter -gives -us -a -way -to -possibly -reject -a -haystack -very -/ -/ -quickly -. -/ -/ -/ -/ -Maybe -we -should -do -use -a -prefilter -but -only -for -longer -haystacks -? -/ -/ -Or -maybe -we -should -only -use -a -prefilter -when -we -think -it -' -s -" -fast -" -? -/ -/ -/ -/ -Interestingly -I -think -we -currently -lack -the -infrastructure -for -/ -/ -disabling -a -prefilter -based -on -haystack -length -. -That -would -probably -/ -/ -need -to -be -a -new -' -Input -' -option -. -( -Interestingly -an -' -Input -' -used -to -/ -/ -carry -a -' -Prefilter -' -with -it -but -I -moved -away -from -that -. -) -debug -! -( -" -skipping -literal -extraction -since -regex -is -anchored -" -) -; -None -} -else -if -let -Some -( -pre -) -= -info -. -config -( -) -. -get_prefilter -( -) -{ -debug -! -( -" -skipping -literal -extraction -since -the -caller -provided -a -prefilter -" -) -; -Some -( -pre -. -clone -( -) -) -} -else -if -info -. -config -( -) -. -get_auto_prefilter -( -) -{ -let -kind -= -info -. -config -( -) -. -get_match_kind -( -) -; -let -prefixes -= -crate -: -: -util -: -: -prefilter -: -: -prefixes -( -kind -hirs -) -; -/ -/ -If -we -can -build -a -full -Strategy -from -just -the -extracted -prefixes -/ -/ -then -we -can -short -- -circuit -and -avoid -building -a -regex -engine -at -all -. -if -let -Some -( -pre -) -= -Pre -: -: -from_prefixes -( -info -& -prefixes -) -{ -debug -! -( -" -found -that -the -regex -can -be -broken -down -to -a -literal -\ -search -avoiding -the -regex -engine -entirely -" -) -; -return -Ok -( -pre -) -; -} -/ -/ -This -now -attempts -another -short -- -circuit -of -the -regex -engine -: -if -we -/ -/ -have -a -huge -alternation -of -just -plain -literals -then -we -can -just -use -/ -/ -Aho -- -Corasick -for -that -and -avoid -the -regex -engine -entirely -. -/ -/ -/ -/ -You -might -think -this -case -would -just -be -handled -by -/ -/ -Pre -: -: -from_prefixes -but -that -technique -relies -on -heuristic -literal -/ -/ -extraction -from -the -corresponding -Hir -. -That -works -but -part -of -/ -/ -heuristics -limit -the -size -and -number -of -literals -returned -. -This -case -/ -/ -will -specifically -handle -patterns -with -very -large -alternations -. -/ -/ -/ -/ -One -wonders -if -we -should -just -roll -this -our -heuristic -literal -/ -/ -extraction -and -then -I -think -this -case -could -disappear -entirely -. -if -let -Some -( -pre -) -= -Pre -: -: -from_alternation_literals -( -info -hirs -) -{ -debug -! -( -" -found -plain -alternation -of -literals -\ -avoiding -regex -engine -entirely -and -using -Aho -- -Corasick -" -) -; -return -Ok -( -pre -) -; -} -prefixes -. -literals -( -) -. -and_then -( -| -strings -| -{ -debug -! -( -" -creating -prefilter -from -{ -} -literals -: -{ -: -? -} -" -strings -. -len -( -) -strings -) -; -Prefilter -: -: -new -( -kind -strings -) -} -) -} -else -{ -debug -! -( -" -skipping -literal -extraction -since -prefilters -were -disabled -" -) -; -None -} -; -let -mut -core -= -Core -: -: -new -( -info -. -clone -( -) -pre -. -clone -( -) -hirs -) -? -; -/ -/ -Now -that -we -have -our -core -regex -engines -built -there -are -a -few -cases -/ -/ -where -we -can -do -a -little -bit -better -than -just -a -normal -" -search -forward -/ -/ -and -maybe -use -a -prefilter -when -in -a -start -state -. -" -However -these -cases -/ -/ -may -not -always -work -or -otherwise -build -on -top -of -the -Core -searcher -. -/ -/ -For -example -the -reverse -anchored -optimization -seems -like -it -might -/ -/ -always -work -but -only -the -DFAs -support -reverse -searching -and -the -DFAs -/ -/ -might -give -up -or -quit -for -reasons -. -If -we -had -e -. -g -. -a -PikeVM -that -/ -/ -supported -reverse -searching -then -we -could -avoid -building -a -full -Core -/ -/ -engine -for -this -case -. -core -= -match -ReverseAnchored -: -: -new -( -core -) -{ -Err -( -core -) -= -> -core -Ok -( -ra -) -= -> -{ -debug -! -( -" -using -reverse -anchored -strategy -" -) -; -return -Ok -( -Arc -: -: -new -( -ra -) -) -; -} -} -; -core -= -match -ReverseSuffix -: -: -new -( -core -hirs -) -{ -Err -( -core -) -= -> -core -Ok -( -rs -) -= -> -{ -debug -! -( -" -using -reverse -suffix -strategy -" -) -; -return -Ok -( -Arc -: -: -new -( -rs -) -) -; -} -} -; -core -= -match -ReverseInner -: -: -new -( -core -hirs -) -{ -Err -( -core -) -= -> -core -Ok -( -ri -) -= -> -{ -debug -! -( -" -using -reverse -inner -strategy -" -) -; -return -Ok -( -Arc -: -: -new -( -ri -) -) -; -} -} -; -debug -! -( -" -using -core -strategy -" -) -; -Ok -( -Arc -: -: -new -( -core -) -) -} -# -[ -derive -( -Clone -Debug -) -] -struct -Pre -< -P -> -{ -pre -: -P -group_info -: -GroupInfo -} -impl -< -P -: -PrefilterI -> -Pre -< -P -> -{ -fn -new -( -pre -: -P -) -- -> -Arc -< -dyn -Strategy -> -{ -/ -/ -The -only -thing -we -support -when -we -use -prefilters -directly -as -a -/ -/ -strategy -is -the -start -and -end -of -the -overall -match -for -a -single -/ -/ -pattern -. -In -other -words -exactly -one -implicit -capturing -group -. -Which -/ -/ -is -exactly -what -we -use -here -for -a -GroupInfo -. -let -group_info -= -GroupInfo -: -: -new -( -[ -[ -None -: -: -< -& -str -> -] -] -) -. -unwrap -( -) -; -Arc -: -: -new -( -Pre -{ -pre -group_info -} -) -} -} -/ -/ -This -is -a -little -weird -but -we -don -' -t -actually -care -about -the -type -parameter -/ -/ -here -because -we -' -re -selecting -which -underlying -prefilter -to -use -. -So -we -just -/ -/ -define -it -on -an -arbitrary -type -. -impl -Pre -< -( -) -> -{ -/ -/ -/ -Given -a -sequence -of -prefixes -attempt -to -return -a -full -Strategy -using -/ -/ -/ -just -the -prefixes -. -/ -/ -/ -/ -/ -/ -Basically -this -occurs -when -the -prefixes -given -not -just -prefixes -/ -/ -/ -but -an -enumeration -of -the -entire -language -matched -by -the -regular -/ -/ -/ -expression -. -/ -/ -/ -/ -/ -/ -A -number -of -other -conditions -need -to -be -true -too -. -For -example -there -/ -/ -/ -can -be -only -one -pattern -the -number -of -explicit -capture -groups -is -0 -no -/ -/ -/ -look -- -around -assertions -and -so -on -. -/ -/ -/ -/ -/ -/ -Note -that -this -ignores -Config -: -: -get_auto_prefilter -because -if -this -/ -/ -/ -returns -something -then -it -isn -' -t -a -prefilter -but -a -matcher -itself -. -/ -/ -/ -Therefore -it -shouldn -' -t -suffer -from -the -problems -typical -to -prefilters -/ -/ -/ -( -such -as -a -high -false -positive -rate -) -. -fn -from_prefixes -( -info -: -& -RegexInfo -prefixes -: -& -literal -: -: -Seq -) -- -> -Option -< -Arc -< -dyn -Strategy -> -> -{ -let -kind -= -info -. -config -( -) -. -get_match_kind -( -) -; -/ -/ -Check -to -see -if -our -prefixes -are -exact -which -means -we -might -be -/ -/ -able -to -bypass -the -regex -engine -entirely -and -just -rely -on -literal -/ -/ -searches -. -if -! -prefixes -. -is_exact -( -) -{ -return -None -; -} -/ -/ -We -also -require -that -we -have -a -single -regex -pattern -. -Namely -/ -/ -we -reuse -the -prefilter -infrastructure -to -implement -search -and -/ -/ -prefilters -only -report -spans -. -Prefilters -don -' -t -know -about -pattern -/ -/ -IDs -. -The -multi -- -regex -case -isn -' -t -a -lost -cause -we -might -still -use -/ -/ -Aho -- -Corasick -and -we -might -still -just -use -a -regular -prefilter -but -/ -/ -that -' -s -done -below -. -if -info -. -pattern_len -( -) -! -= -1 -{ -return -None -; -} -/ -/ -We -can -' -t -have -any -capture -groups -either -. -The -literal -engines -don -' -t -/ -/ -know -how -to -deal -with -things -like -' -( -foo -) -( -bar -) -' -. -In -that -case -a -/ -/ -prefilter -will -just -be -used -and -then -the -regex -engine -will -resolve -/ -/ -the -capture -groups -. -if -info -. -props -( -) -[ -0 -] -. -explicit_captures_len -( -) -! -= -0 -{ -return -None -; -} -/ -/ -We -also -require -that -it -has -zero -look -- -around -assertions -. -Namely -/ -/ -literal -extraction -treats -look -- -around -assertions -as -if -they -match -/ -/ -* -every -* -empty -string -. -But -of -course -that -isn -' -t -true -. -So -for -/ -/ -example -' -foo -\ -bquux -' -never -matches -anything -but -' -fooquux -' -is -/ -/ -extracted -from -that -as -an -exact -literal -. -Such -cases -should -just -run -/ -/ -the -regex -engine -. -' -fooquux -' -will -be -used -as -a -normal -prefilter -and -/ -/ -then -the -regex -engine -will -try -to -look -for -an -actual -match -. -if -! -info -. -props -( -) -[ -0 -] -. -look_set -( -) -. -is_empty -( -) -{ -return -None -; -} -/ -/ -Finally -currently -our -prefilters -are -all -oriented -around -/ -/ -leftmost -- -first -match -semantics -so -don -' -t -try -to -use -them -if -the -/ -/ -caller -asked -for -anything -else -. -if -kind -! -= -MatchKind -: -: -LeftmostFirst -{ -return -None -; -} -/ -/ -The -above -seems -like -a -lot -of -requirements -to -meet -but -it -applies -/ -/ -to -a -lot -of -cases -. -' -foo -' -' -[ -abc -] -[ -123 -] -' -and -' -foo -| -bar -| -quux -' -all -meet -/ -/ -the -above -criteria -for -example -. -/ -/ -/ -/ -Note -that -this -is -effectively -a -latency -optimization -. -If -we -didn -' -t -/ -/ -do -this -then -the -extracted -literals -would -still -get -bundled -into -/ -/ -a -prefilter -and -every -regex -engine -capable -of -running -unanchored -/ -/ -searches -supports -prefilters -. -So -this -optimization -merely -sidesteps -/ -/ -having -to -run -the -regex -engine -at -all -to -confirm -the -match -. -Thus -it -/ -/ -decreases -the -latency -of -a -match -. -/ -/ -OK -because -we -know -the -set -is -exact -and -thus -finite -. -let -prefixes -= -prefixes -. -literals -( -) -. -unwrap -( -) -; -debug -! -( -" -trying -to -bypass -regex -engine -by -creating -\ -prefilter -from -{ -} -literals -: -{ -: -? -} -" -prefixes -. -len -( -) -prefixes -) -; -let -choice -= -match -prefilter -: -: -Choice -: -: -new -( -kind -prefixes -) -{ -Some -( -choice -) -= -> -choice -None -= -> -{ -debug -! -( -" -regex -bypass -failed -because -no -prefilter -could -be -built -" -) -; -return -None -; -} -} -; -let -strat -: -Arc -< -dyn -Strategy -> -= -match -choice -{ -prefilter -: -: -Choice -: -: -Memchr -( -pre -) -= -> -Pre -: -: -new -( -pre -) -prefilter -: -: -Choice -: -: -Memchr2 -( -pre -) -= -> -Pre -: -: -new -( -pre -) -prefilter -: -: -Choice -: -: -Memchr3 -( -pre -) -= -> -Pre -: -: -new -( -pre -) -prefilter -: -: -Choice -: -: -Memmem -( -pre -) -= -> -Pre -: -: -new -( -pre -) -prefilter -: -: -Choice -: -: -Teddy -( -pre -) -= -> -Pre -: -: -new -( -pre -) -prefilter -: -: -Choice -: -: -ByteSet -( -pre -) -= -> -Pre -: -: -new -( -pre -) -prefilter -: -: -Choice -: -: -AhoCorasick -( -pre -) -= -> -Pre -: -: -new -( -pre -) -} -; -Some -( -strat -) -} -/ -/ -/ -Attempts -to -extract -an -alternation -of -literals -and -if -it -' -s -deemed -/ -/ -/ -worth -doing -returns -an -Aho -- -Corasick -prefilter -as -a -strategy -. -/ -/ -/ -/ -/ -/ -And -currently -this -only -returns -something -when -' -hirs -. -len -( -) -= -= -1 -' -. -This -/ -/ -/ -could -in -theory -do -something -if -there -are -multiple -HIRs -where -all -of -/ -/ -/ -them -are -alternation -of -literals -but -I -haven -' -t -had -the -time -to -go -down -/ -/ -/ -that -path -yet -. -fn -from_alternation_literals -( -info -: -& -RegexInfo -hirs -: -& -[ -& -Hir -] -) -- -> -Option -< -Arc -< -dyn -Strategy -> -> -{ -use -crate -: -: -util -: -: -prefilter -: -: -AhoCorasick -; -let -lits -= -crate -: -: -meta -: -: -literal -: -: -alternation_literals -( -info -hirs -) -? -; -let -ac -= -AhoCorasick -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -lits -) -? -; -Some -( -Pre -: -: -new -( -ac -) -) -} -} -/ -/ -This -implements -Strategy -for -anything -that -implements -PrefilterI -. -/ -/ -/ -/ -Note -that -this -must -only -be -used -for -regexes -of -length -1 -. -Multi -- -regexes -/ -/ -don -' -t -work -here -. -The -prefilter -interface -only -provides -the -span -of -a -match -/ -/ -and -not -the -pattern -ID -. -( -I -did -consider -making -it -more -expressive -but -I -/ -/ -couldn -' -t -figure -out -how -to -tie -everything -together -elegantly -. -) -Thus -so -long -/ -/ -as -the -regex -only -contains -one -pattern -we -can -simply -assume -that -a -match -/ -/ -corresponds -to -PatternID -: -: -ZERO -. -And -indeed -that -' -s -what -we -do -here -. -/ -/ -/ -/ -In -practice -since -this -impl -is -used -to -report -matches -directly -and -thus -/ -/ -completely -bypasses -the -regex -engine -we -only -wind -up -using -this -under -the -/ -/ -following -restrictions -: -/ -/ -/ -/ -* -There -must -be -only -one -pattern -. -As -explained -above -. -/ -/ -* -The -literal -sequence -must -be -finite -and -only -contain -exact -literals -. -/ -/ -* -There -must -not -be -any -look -- -around -assertions -. -If -there -are -the -literals -/ -/ -extracted -might -be -exact -but -a -match -doesn -' -t -necessarily -imply -an -overall -/ -/ -match -. -As -a -trivial -example -' -foo -\ -bbar -' -does -not -match -' -foobar -' -. -/ -/ -* -The -pattern -must -not -have -any -explicit -capturing -groups -. -If -it -does -the -/ -/ -caller -might -expect -them -to -be -resolved -. -e -. -g -. -' -foo -( -bar -) -' -. -/ -/ -/ -/ -So -when -all -of -those -things -are -true -we -use -a -prefilter -directly -as -a -/ -/ -strategy -. -/ -/ -/ -/ -In -the -case -where -the -number -of -patterns -is -more -than -1 -we -don -' -t -use -this -/ -/ -but -do -use -a -special -Aho -- -Corasick -strategy -if -all -of -the -regexes -are -just -/ -/ -simple -literals -or -alternations -of -literals -. -( -We -also -use -the -Aho -- -Corasick -/ -/ -strategy -when -len -( -patterns -) -= -= -1 -if -the -number -of -literals -is -large -. -In -that -/ -/ -case -literal -extraction -gives -up -and -will -return -an -infinite -set -. -) -impl -< -P -: -PrefilterI -> -Strategy -for -Pre -< -P -> -{ -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -& -self -. -group_info -} -fn -create_cache -( -& -self -) -- -> -Cache -{ -Cache -{ -capmatches -: -Captures -: -: -all -( -self -. -group_info -( -) -. -clone -( -) -) -pikevm -: -wrappers -: -: -PikeVMCache -: -: -none -( -) -backtrack -: -wrappers -: -: -BoundedBacktrackerCache -: -: -none -( -) -onepass -: -wrappers -: -: -OnePassCache -: -: -none -( -) -hybrid -: -wrappers -: -: -HybridCache -: -: -none -( -) -revhybrid -: -wrappers -: -: -ReverseHybridCache -: -: -none -( -) -} -} -fn -reset_cache -( -& -self -_cache -: -& -mut -Cache -) -{ -} -fn -is_accelerated -( -& -self -) -- -> -bool -{ -self -. -pre -. -is_fast -( -) -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -pre -. -memory_usage -( -) -} -fn -search -( -& -self -_cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -{ -if -input -. -is_done -( -) -{ -return -None -; -} -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -pre -. -prefix -( -input -. -haystack -( -) -input -. -get_span -( -) -) -. -map -( -| -sp -| -Match -: -: -new -( -PatternID -: -: -ZERO -sp -) -) -; -} -self -. -pre -. -find -( -input -. -haystack -( -) -input -. -get_span -( -) -) -. -map -( -| -sp -| -Match -: -: -new -( -PatternID -: -: -ZERO -sp -) -) -} -fn -search_half -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -{ -self -. -search -( -cache -input -) -. -map -( -| -m -| -HalfMatch -: -: -new -( -m -. -pattern -( -) -m -. -end -( -) -) -) -} -fn -is_match -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -self -. -search -( -cache -input -) -. -is_some -( -) -} -fn -search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -let -m -= -self -. -search -( -cache -input -) -? -; -if -let -Some -( -slot -) -= -slots -. -get_mut -( -0 -) -{ -* -slot -= -NonMaxUsize -: -: -new -( -m -. -start -( -) -) -; -} -if -let -Some -( -slot -) -= -slots -. -get_mut -( -1 -) -{ -* -slot -= -NonMaxUsize -: -: -new -( -m -. -end -( -) -) -; -} -Some -( -m -. -pattern -( -) -) -} -fn -which_overlapping_matches -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -if -self -. -search -( -cache -input -) -. -is_some -( -) -{ -patset -. -insert -( -PatternID -: -: -ZERO -) -; -} -} -} -# -[ -derive -( -Debug -) -] -struct -Core -{ -info -: -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -NFA -nfarev -: -Option -< -NFA -> -pikevm -: -wrappers -: -: -PikeVM -backtrack -: -wrappers -: -: -BoundedBacktracker -onepass -: -wrappers -: -: -OnePass -hybrid -: -wrappers -: -: -Hybrid -dfa -: -wrappers -: -: -DFA -} -impl -Core -{ -fn -new -( -info -: -RegexInfo -pre -: -Option -< -Prefilter -> -hirs -: -& -[ -& -Hir -] -) -- -> -Result -< -Core -BuildError -> -{ -let -mut -lookm -= -LookMatcher -: -: -new -( -) -; -lookm -. -set_line_terminator -( -info -. -config -( -) -. -get_line_terminator -( -) -) -; -let -thompson_config -= -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -info -. -config -( -) -. -get_utf8_empty -( -) -) -. -nfa_size_limit -( -info -. -config -( -) -. -get_nfa_size_limit -( -) -) -. -shrink -( -false -) -. -which_captures -( -info -. -config -( -) -. -get_which_captures -( -) -) -. -look_matcher -( -lookm -) -; -let -nfa -= -thompson -: -: -Compiler -: -: -new -( -) -. -configure -( -thompson_config -. -clone -( -) -) -. -build_many_from_hir -( -hirs -) -. -map_err -( -BuildError -: -: -nfa -) -? -; -/ -/ -It -' -s -possible -for -the -PikeVM -or -the -BB -to -fail -to -build -even -though -/ -/ -at -this -point -we -already -have -a -full -NFA -in -hand -. -They -can -fail -/ -/ -when -a -Unicode -word -boundary -is -used -but -where -Unicode -word -boundary -/ -/ -support -is -disabled -at -compile -time -thus -making -it -impossible -to -/ -/ -match -. -( -Construction -can -also -fail -if -the -NFA -was -compiled -without -/ -/ -captures -but -we -always -enable -that -above -. -) -let -pikevm -= -wrappers -: -: -PikeVM -: -: -new -( -& -info -pre -. -clone -( -) -& -nfa -) -? -; -let -backtrack -= -wrappers -: -: -BoundedBacktracker -: -: -new -( -& -info -pre -. -clone -( -) -& -nfa -) -? -; -/ -/ -The -onepass -engine -can -of -course -fail -to -build -but -we -expect -it -to -/ -/ -fail -in -many -cases -because -it -is -an -optimization -that -doesn -' -t -apply -/ -/ -to -all -regexes -. -The -' -OnePass -' -wrapper -encapsulates -this -failure -( -and -/ -/ -logs -a -message -if -it -occurs -) -. -let -onepass -= -wrappers -: -: -OnePass -: -: -new -( -& -info -& -nfa -) -; -/ -/ -We -try -to -encapsulate -whether -a -particular -regex -engine -should -be -/ -/ -used -within -each -respective -wrapper -but -the -DFAs -need -a -reverse -NFA -/ -/ -to -build -itself -and -we -really -do -not -want -to -build -a -reverse -NFA -if -/ -/ -we -know -we -aren -' -t -going -to -use -the -lazy -DFA -. -So -we -do -a -config -check -/ -/ -up -front -which -is -in -practice -the -only -way -we -won -' -t -try -to -use -the -/ -/ -DFA -. -let -( -nfarev -hybrid -dfa -) -= -if -! -info -. -config -( -) -. -get_hybrid -( -) -& -& -! -info -. -config -( -) -. -get_dfa -( -) -{ -( -None -wrappers -: -: -Hybrid -: -: -none -( -) -wrappers -: -: -DFA -: -: -none -( -) -) -} -else -{ -/ -/ -FIXME -: -Technically -we -don -' -t -quite -yet -KNOW -that -we -need -/ -/ -a -reverse -NFA -. -It -' -s -possible -for -the -DFAs -below -to -both -/ -/ -fail -to -build -just -based -on -the -forward -NFA -. -In -which -case -/ -/ -building -the -reverse -NFA -was -totally -wasted -work -. -But -. -. -. -/ -/ -fixing -this -requires -breaking -DFA -construction -apart -into -/ -/ -two -pieces -: -one -for -the -forward -part -and -another -for -the -/ -/ -reverse -part -. -Quite -annoying -. -Making -it -worse -when -building -/ -/ -both -DFAs -fails -it -' -s -quite -likely -that -the -NFA -is -large -and -/ -/ -that -it -will -take -quite -some -time -to -build -the -reverse -NFA -/ -/ -too -. -So -. -. -. -it -' -s -really -probably -worth -it -to -do -this -! -let -nfarev -= -thompson -: -: -Compiler -: -: -new -( -) -/ -/ -Currently -reverse -NFAs -don -' -t -support -capturing -groups -/ -/ -so -we -MUST -disable -them -. -But -even -if -we -didn -' -t -have -to -/ -/ -we -would -because -nothing -in -this -crate -does -anything -/ -/ -useful -with -capturing -groups -in -reverse -. -And -of -course -/ -/ -the -lazy -DFA -ignores -capturing -groups -in -all -cases -. -. -configure -( -thompson_config -. -clone -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -. -reverse -( -true -) -) -. -build_many_from_hir -( -hirs -) -. -map_err -( -BuildError -: -: -nfa -) -? -; -let -dfa -= -if -! -info -. -config -( -) -. -get_dfa -( -) -{ -wrappers -: -: -DFA -: -: -none -( -) -} -else -{ -wrappers -: -: -DFA -: -: -new -( -& -info -pre -. -clone -( -) -& -nfa -& -nfarev -) -} -; -let -hybrid -= -if -! -info -. -config -( -) -. -get_hybrid -( -) -{ -wrappers -: -: -Hybrid -: -: -none -( -) -} -else -if -dfa -. -is_some -( -) -{ -debug -! -( -" -skipping -lazy -DFA -because -we -have -a -full -DFA -" -) -; -wrappers -: -: -Hybrid -: -: -none -( -) -} -else -{ -wrappers -: -: -Hybrid -: -: -new -( -& -info -pre -. -clone -( -) -& -nfa -& -nfarev -) -} -; -( -Some -( -nfarev -) -hybrid -dfa -) -} -; -Ok -( -Core -{ -info -pre -nfa -nfarev -pikevm -backtrack -onepass -hybrid -dfa -} -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -try_search_mayfail -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Result -< -Option -< -Match -> -RetryFailError -> -> -{ -if -let -Some -( -e -) -= -self -. -dfa -. -get -( -input -) -{ -trace -! -( -" -using -full -DFA -for -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -Some -( -e -. -try_search -( -input -) -) -} -else -if -let -Some -( -e -) -= -self -. -hybrid -. -get -( -input -) -{ -trace -! -( -" -using -lazy -DFA -for -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -Some -( -e -. -try_search -( -& -mut -cache -. -hybrid -input -) -) -} -else -{ -None -} -} -fn -search_nofail -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -{ -let -caps -= -& -mut -cache -. -capmatches -; -caps -. -set_pattern -( -None -) -; -/ -/ -We -manually -inline -' -try_search_slots_nofail -' -here -because -we -need -to -/ -/ -borrow -from -' -cache -. -capmatches -' -in -this -method -but -if -we -do -then -/ -/ -we -can -' -t -pass -' -cache -' -wholesale -to -to -' -try_slots_no_hybrid -' -. -It -' -s -a -/ -/ -classic -example -of -how -the -borrow -checker -inhibits -decomposition -. -/ -/ -There -are -of -course -work -- -arounds -( -more -types -and -/ -or -interior -/ -/ -mutability -) -but -that -' -s -more -annoying -than -this -IMO -. -let -pid -= -if -let -Some -( -ref -e -) -= -self -. -onepass -. -get -( -input -) -{ -trace -! -( -" -using -OnePass -for -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -search_slots -( -& -mut -cache -. -onepass -input -caps -. -slots_mut -( -) -) -} -else -if -let -Some -( -ref -e -) -= -self -. -backtrack -. -get -( -input -) -{ -trace -! -( -" -using -BoundedBacktracker -for -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -search_slots -( -& -mut -cache -. -backtrack -input -caps -. -slots_mut -( -) -) -} -else -{ -trace -! -( -" -using -PikeVM -for -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -let -e -= -self -. -pikevm -. -get -( -) -; -e -. -search_slots -( -& -mut -cache -. -pikevm -input -caps -. -slots_mut -( -) -) -} -; -caps -. -set_pattern -( -pid -) -; -caps -. -get_match -( -) -} -fn -search_half_nofail -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -{ -/ -/ -Only -the -lazy -/ -full -DFA -returns -half -- -matches -since -the -DFA -requires -/ -/ -a -reverse -scan -to -find -the -start -position -. -These -fallback -regex -/ -/ -engines -can -find -the -start -and -end -in -a -single -pass -so -we -just -do -/ -/ -that -and -throw -away -the -start -offset -to -conform -to -the -API -. -let -m -= -self -. -search_nofail -( -cache -input -) -? -; -Some -( -HalfMatch -: -: -new -( -m -. -pattern -( -) -m -. -end -( -) -) -) -} -fn -search_slots_nofail -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -if -let -Some -( -ref -e -) -= -self -. -onepass -. -get -( -input -) -{ -trace -! -( -" -using -OnePass -for -capture -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -search_slots -( -& -mut -cache -. -onepass -input -slots -) -} -else -if -let -Some -( -ref -e -) -= -self -. -backtrack -. -get -( -input -) -{ -trace -! -( -" -using -BoundedBacktracker -for -capture -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -search_slots -( -& -mut -cache -. -backtrack -input -slots -) -} -else -{ -trace -! -( -" -using -PikeVM -for -capture -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -let -e -= -self -. -pikevm -. -get -( -) -; -e -. -search_slots -( -& -mut -cache -. -pikevm -input -slots -) -} -} -fn -is_match_nofail -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -if -let -Some -( -ref -e -) -= -self -. -onepass -. -get -( -input -) -{ -trace -! -( -" -using -OnePass -for -is -- -match -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -search_slots -( -& -mut -cache -. -onepass -input -& -mut -[ -] -) -. -is_some -( -) -} -else -if -let -Some -( -ref -e -) -= -self -. -backtrack -. -get -( -input -) -{ -trace -! -( -" -using -BoundedBacktracker -for -is -- -match -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -is_match -( -& -mut -cache -. -backtrack -input -) -} -else -{ -trace -! -( -" -using -PikeVM -for -is -- -match -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -let -e -= -self -. -pikevm -. -get -( -) -; -e -. -is_match -( -& -mut -cache -. -pikevm -input -) -} -} -fn -is_capture_search_needed -( -& -self -slots_len -: -usize -) -- -> -bool -{ -slots_len -> -self -. -nfa -. -group_info -( -) -. -implicit_slot_len -( -) -} -} -impl -Strategy -for -Core -{ -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -self -. -nfa -. -group_info -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -create_cache -( -& -self -) -- -> -Cache -{ -Cache -{ -capmatches -: -Captures -: -: -all -( -self -. -group_info -( -) -. -clone -( -) -) -pikevm -: -self -. -pikevm -. -create_cache -( -) -backtrack -: -self -. -backtrack -. -create_cache -( -) -onepass -: -self -. -onepass -. -create_cache -( -) -hybrid -: -self -. -hybrid -. -create_cache -( -) -revhybrid -: -wrappers -: -: -ReverseHybridCache -: -: -none -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -cache -. -pikevm -. -reset -( -& -self -. -pikevm -) -; -cache -. -backtrack -. -reset -( -& -self -. -backtrack -) -; -cache -. -onepass -. -reset -( -& -self -. -onepass -) -; -cache -. -hybrid -. -reset -( -& -self -. -hybrid -) -; -} -fn -is_accelerated -( -& -self -) -- -> -bool -{ -self -. -pre -. -as_ref -( -) -. -map_or -( -false -| -pre -| -pre -. -is_fast -( -) -) -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -info -. -memory_usage -( -) -+ -self -. -pre -. -as_ref -( -) -. -map_or -( -0 -| -pre -| -pre -. -memory_usage -( -) -) -+ -self -. -nfa -. -memory_usage -( -) -+ -self -. -nfarev -. -as_ref -( -) -. -map_or -( -0 -| -nfa -| -nfa -. -memory_usage -( -) -) -+ -self -. -onepass -. -memory_usage -( -) -+ -self -. -dfa -. -memory_usage -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -{ -/ -/ -We -manually -inline -try_search_mayfail -here -because -letting -the -/ -/ -compiler -do -it -seems -to -produce -pretty -crappy -codegen -. -return -if -let -Some -( -e -) -= -self -. -dfa -. -get -( -input -) -{ -trace -! -( -" -using -full -DFA -for -full -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -match -e -. -try_search -( -input -) -{ -Ok -( -x -) -= -> -x -Err -( -_err -) -= -> -{ -trace -! -( -" -full -DFA -search -failed -: -{ -} -" -_err -) -; -self -. -search_nofail -( -cache -input -) -} -} -} -else -if -let -Some -( -e -) -= -self -. -hybrid -. -get -( -input -) -{ -trace -! -( -" -using -lazy -DFA -for -full -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -match -e -. -try_search -( -& -mut -cache -. -hybrid -input -) -{ -Ok -( -x -) -= -> -x -Err -( -_err -) -= -> -{ -trace -! -( -" -lazy -DFA -search -failed -: -{ -} -" -_err -) -; -self -. -search_nofail -( -cache -input -) -} -} -} -else -{ -self -. -search_nofail -( -cache -input -) -} -; -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search_half -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -{ -/ -/ -The -main -difference -with -' -search -' -is -that -if -we -' -re -using -a -DFA -we -/ -/ -can -use -a -single -forward -scan -without -needing -to -run -the -reverse -/ -/ -DFA -. -if -let -Some -( -e -) -= -self -. -dfa -. -get -( -input -) -{ -trace -! -( -" -using -full -DFA -for -half -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -match -e -. -try_search_half_fwd -( -input -) -{ -Ok -( -x -) -= -> -x -Err -( -_err -) -= -> -{ -trace -! -( -" -full -DFA -half -search -failed -: -{ -} -" -_err -) -; -self -. -search_half_nofail -( -cache -input -) -} -} -} -else -if -let -Some -( -e -) -= -self -. -hybrid -. -get -( -input -) -{ -trace -! -( -" -using -lazy -DFA -for -half -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -match -e -. -try_search_half_fwd -( -& -mut -cache -. -hybrid -input -) -{ -Ok -( -x -) -= -> -x -Err -( -_err -) -= -> -{ -trace -! -( -" -lazy -DFA -half -search -failed -: -{ -} -" -_err -) -; -self -. -search_half_nofail -( -cache -input -) -} -} -} -else -{ -self -. -search_half_nofail -( -cache -input -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_match -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -if -let -Some -( -e -) -= -self -. -dfa -. -get -( -input -) -{ -trace -! -( -" -using -full -DFA -for -is -- -match -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -match -e -. -try_search_half_fwd -( -input -) -{ -Ok -( -x -) -= -> -x -. -is_some -( -) -Err -( -_err -) -= -> -{ -trace -! -( -" -full -DFA -half -search -failed -: -{ -} -" -_err -) -; -self -. -is_match_nofail -( -cache -input -) -} -} -} -else -if -let -Some -( -e -) -= -self -. -hybrid -. -get -( -input -) -{ -trace -! -( -" -using -lazy -DFA -for -is -- -match -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -match -e -. -try_search_half_fwd -( -& -mut -cache -. -hybrid -input -) -{ -Ok -( -x -) -= -> -x -. -is_some -( -) -Err -( -_err -) -= -> -{ -trace -! -( -" -lazy -DFA -half -search -failed -: -{ -} -" -_err -) -; -self -. -is_match_nofail -( -cache -input -) -} -} -} -else -{ -self -. -is_match_nofail -( -cache -input -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -/ -/ -Even -if -the -regex -has -explicit -capture -groups -if -the -caller -didn -' -t -/ -/ -provide -any -explicit -slots -then -it -doesn -' -t -make -sense -to -try -and -do -/ -/ -extra -work -to -get -offsets -for -those -slots -. -Ideally -the -caller -should -/ -/ -realize -this -and -not -call -this -routine -in -the -first -place -but -alas -/ -/ -we -try -to -save -the -caller -from -themselves -if -they -do -. -if -! -self -. -is_capture_search_needed -( -slots -. -len -( -) -) -{ -trace -! -( -" -asked -for -slots -unnecessarily -trying -fast -path -" -) -; -let -m -= -self -. -search -( -cache -input -) -? -; -copy_match_to_slots -( -m -slots -) -; -return -Some -( -m -. -pattern -( -) -) -; -} -/ -/ -If -the -onepass -DFA -is -available -for -this -search -( -which -only -happens -/ -/ -when -it -' -s -anchored -) -then -skip -running -a -fallible -DFA -. -The -onepass -/ -/ -DFA -isn -' -t -as -fast -as -a -full -or -lazy -DFA -but -it -is -typically -quite -/ -/ -a -bit -faster -than -the -backtracker -or -the -PikeVM -. -So -it -isn -' -t -as -/ -/ -advantageous -to -try -and -do -a -full -/ -lazy -DFA -scan -first -. -/ -/ -/ -/ -We -still -theorize -that -it -' -s -better -to -do -a -full -/ -lazy -DFA -scan -even -/ -/ -when -it -' -s -anchored -because -it -' -s -usually -much -faster -and -permits -us -/ -/ -to -say -" -no -match -" -much -more -quickly -. -This -does -hurt -the -case -of -/ -/ -say -parsing -each -line -in -a -log -file -into -capture -groups -because -/ -/ -in -that -case -the -line -always -matches -. -So -the -lazy -DFA -scan -is -/ -/ -usually -just -wasted -work -. -But -the -lazy -DFA -is -usually -quite -fast -/ -/ -and -doesn -' -t -cost -too -much -here -. -if -self -. -onepass -. -get -( -& -input -) -. -is_some -( -) -{ -return -self -. -search_slots_nofail -( -cache -& -input -slots -) -; -} -let -m -= -match -self -. -try_search_mayfail -( -cache -input -) -{ -Some -( -Ok -( -Some -( -m -) -) -) -= -> -m -Some -( -Ok -( -None -) -) -= -> -return -None -Some -( -Err -( -_err -) -) -= -> -{ -trace -! -( -" -fast -capture -search -failed -: -{ -} -" -_err -) -; -return -self -. -search_slots_nofail -( -cache -input -slots -) -; -} -None -= -> -{ -return -self -. -search_slots_nofail -( -cache -input -slots -) -; -} -} -; -/ -/ -At -this -point -now -that -we -' -ve -found -the -bounds -of -the -/ -/ -match -we -need -to -re -- -run -something -that -can -resolve -/ -/ -capturing -groups -. -But -we -only -need -to -run -on -it -on -the -/ -/ -match -bounds -and -not -the -entire -haystack -. -trace -! -( -" -match -found -at -{ -} -. -. -{ -} -in -capture -search -\ -using -another -engine -to -find -captures -" -m -. -start -( -) -m -. -end -( -) -) -; -let -input -= -input -. -clone -( -) -. -span -( -m -. -start -( -) -. -. -m -. -end -( -) -) -. -anchored -( -Anchored -: -: -Pattern -( -m -. -pattern -( -) -) -) -; -Some -( -self -. -search_slots_nofail -( -cache -& -input -slots -) -. -expect -( -" -should -find -a -match -" -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -which_overlapping_matches -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -if -let -Some -( -e -) -= -self -. -dfa -. -get -( -input -) -{ -trace -! -( -" -using -full -DFA -for -overlapping -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -let -_err -= -match -e -. -try_which_overlapping_matches -( -input -patset -) -{ -Ok -( -( -) -) -= -> -return -Err -( -err -) -= -> -err -} -; -trace -! -( -" -fast -overlapping -search -failed -: -{ -} -" -_err -) -; -} -else -if -let -Some -( -e -) -= -self -. -hybrid -. -get -( -input -) -{ -trace -! -( -" -using -lazy -DFA -for -overlapping -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -let -_err -= -match -e -. -try_which_overlapping_matches -( -& -mut -cache -. -hybrid -input -patset -) -{ -Ok -( -( -) -) -= -> -{ -return -; -} -Err -( -err -) -= -> -err -} -; -trace -! -( -" -fast -overlapping -search -failed -: -{ -} -" -_err -) -; -} -trace -! -( -" -using -PikeVM -for -overlapping -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -let -e -= -self -. -pikevm -. -get -( -) -; -e -. -which_overlapping_matches -( -& -mut -cache -. -pikevm -input -patset -) -} -} -# -[ -derive -( -Debug -) -] -struct -ReverseAnchored -{ -core -: -Core -} -impl -ReverseAnchored -{ -fn -new -( -core -: -Core -) -- -> -Result -< -ReverseAnchored -Core -> -{ -if -! -core -. -info -. -is_always_anchored_end -( -) -{ -debug -! -( -" -skipping -reverse -anchored -optimization -because -\ -the -regex -is -not -always -anchored -at -the -end -" -) -; -return -Err -( -core -) -; -} -/ -/ -Note -that -the -caller -can -still -request -an -anchored -search -even -when -/ -/ -the -regex -isn -' -t -anchored -at -the -start -. -We -detect -that -case -in -the -/ -/ -search -routines -below -and -just -fallback -to -the -core -engine -. -This -/ -/ -is -fine -because -both -searches -are -anchored -. -It -' -s -just -a -matter -of -/ -/ -picking -one -. -Falling -back -to -the -core -engine -is -a -little -simpler -/ -/ -since -if -we -used -the -reverse -anchored -approach -we -' -d -have -to -add -an -/ -/ -extra -check -to -ensure -the -match -reported -starts -at -the -place -where -/ -/ -the -caller -requested -the -search -to -start -. -if -core -. -info -. -is_always_anchored_start -( -) -{ -debug -! -( -" -skipping -reverse -anchored -optimization -because -\ -the -regex -is -also -anchored -at -the -start -" -) -; -return -Err -( -core -) -; -} -/ -/ -Only -DFAs -can -do -reverse -searches -( -currently -) -so -we -need -one -of -/ -/ -them -in -order -to -do -this -optimization -. -It -' -s -possible -( -although -/ -/ -pretty -unlikely -) -that -we -have -neither -and -need -to -give -up -. -if -! -core -. -hybrid -. -is_some -( -) -& -& -! -core -. -dfa -. -is_some -( -) -{ -debug -! -( -" -skipping -reverse -anchored -optimization -because -\ -we -don -' -t -have -a -lazy -DFA -or -a -full -DFA -" -) -; -return -Err -( -core -) -; -} -Ok -( -ReverseAnchored -{ -core -} -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -try_search_half_anchored_rev -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -RetryFailError -> -{ -/ -/ -We -of -course -always -want -an -anchored -search -. -In -theory -the -/ -/ -underlying -regex -engines -should -automatically -enable -anchored -/ -/ -searches -since -the -regex -is -itself -anchored -but -this -more -clearly -/ -/ -expresses -intent -and -is -always -correct -. -let -input -= -input -. -clone -( -) -. -anchored -( -Anchored -: -: -Yes -) -; -if -let -Some -( -e -) -= -self -. -core -. -dfa -. -get -( -& -input -) -{ -trace -! -( -" -using -full -DFA -for -reverse -anchored -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -try_search_half_rev -( -& -input -) -} -else -if -let -Some -( -e -) -= -self -. -core -. -hybrid -. -get -( -& -input -) -{ -trace -! -( -" -using -lazy -DFA -for -reverse -anchored -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -try_search_half_rev -( -& -mut -cache -. -hybrid -& -input -) -} -else -{ -unreachable -! -( -" -ReverseAnchored -always -has -a -DFA -" -) -} -} -} -/ -/ -Note -that -in -this -impl -we -don -' -t -check -that -' -input -. -end -( -) -= -= -/ -/ -input -. -haystack -( -) -. -len -( -) -' -. -In -particular -when -that -condition -is -false -a -/ -/ -match -is -always -impossible -because -we -know -that -the -regex -is -always -anchored -/ -/ -at -the -end -( -or -else -' -ReverseAnchored -' -won -' -t -be -built -) -. -We -don -' -t -check -that -/ -/ -here -because -the -' -Regex -' -wrapper -actually -does -that -for -us -in -all -cases -. -/ -/ -Thus -in -this -impl -we -can -actually -assume -that -the -end -position -in -' -input -' -/ -/ -is -equivalent -to -the -length -of -the -haystack -. -impl -Strategy -for -ReverseAnchored -{ -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -self -. -core -. -group_info -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -create_cache -( -& -self -) -- -> -Cache -{ -self -. -core -. -create_cache -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -self -. -core -. -reset_cache -( -cache -) -; -} -fn -is_accelerated -( -& -self -) -- -> -bool -{ -/ -/ -Since -this -is -anchored -at -the -end -a -reverse -anchored -search -is -/ -/ -almost -certainly -guaranteed -to -result -in -a -much -faster -search -than -/ -/ -a -standard -forward -search -. -true -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -core -. -memory_usage -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search -( -cache -input -) -; -} -match -self -. -try_search_half_anchored_rev -( -cache -input -) -{ -Err -( -_err -) -= -> -{ -trace -! -( -" -fast -reverse -anchored -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -None -Ok -( -Some -( -hm -) -) -= -> -{ -Some -( -Match -: -: -new -( -hm -. -pattern -( -) -hm -. -offset -( -) -. -. -input -. -end -( -) -) -) -} -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search_half -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search_half -( -cache -input -) -; -} -match -self -. -try_search_half_anchored_rev -( -cache -input -) -{ -Err -( -_err -) -= -> -{ -trace -! -( -" -fast -reverse -anchored -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_half_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -None -Ok -( -Some -( -hm -) -) -= -> -{ -/ -/ -Careful -here -! -' -try_search_half -' -is -a -* -forward -* -search -that -/ -/ -only -cares -about -the -* -end -* -position -of -a -match -. -But -/ -/ -' -hm -. -offset -( -) -' -is -actually -the -start -of -the -match -. -So -we -/ -/ -actually -just -throw -that -away -here -and -since -we -know -we -/ -/ -have -a -match -return -the -only -possible -position -at -which -a -/ -/ -match -can -occur -: -input -. -end -( -) -. -Some -( -HalfMatch -: -: -new -( -hm -. -pattern -( -) -input -. -end -( -) -) -) -} -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_match -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -is_match -( -cache -input -) -; -} -match -self -. -try_search_half_anchored_rev -( -cache -input -) -{ -Err -( -_err -) -= -> -{ -trace -! -( -" -fast -reverse -anchored -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -is_match_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -false -Ok -( -Some -( -_ -) -) -= -> -true -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search_slots -( -cache -input -slots -) -; -} -match -self -. -try_search_half_anchored_rev -( -cache -input -) -{ -Err -( -_err -) -= -> -{ -trace -! -( -" -fast -reverse -anchored -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_slots_nofail -( -cache -input -slots -) -} -Ok -( -None -) -= -> -None -Ok -( -Some -( -hm -) -) -= -> -{ -if -! -self -. -core -. -is_capture_search_needed -( -slots -. -len -( -) -) -{ -trace -! -( -" -asked -for -slots -unnecessarily -skipping -captures -" -) -; -let -m -= -Match -: -: -new -( -hm -. -pattern -( -) -hm -. -offset -( -) -. -. -input -. -end -( -) -) -; -copy_match_to_slots -( -m -slots -) -; -return -Some -( -m -. -pattern -( -) -) -; -} -let -start -= -hm -. -offset -( -) -; -let -input -= -input -. -clone -( -) -. -span -( -start -. -. -input -. -end -( -) -) -. -anchored -( -Anchored -: -: -Pattern -( -hm -. -pattern -( -) -) -) -; -self -. -core -. -search_slots_nofail -( -cache -& -input -slots -) -} -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -which_overlapping_matches -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -/ -/ -It -seems -like -this -could -probably -benefit -from -a -reverse -anchored -/ -/ -optimization -perhaps -by -doing -an -overlapping -reverse -search -( -which -/ -/ -the -DFAs -do -support -) -. -I -haven -' -t -given -it -much -thought -though -and -/ -/ -I -' -m -currently -focus -more -on -the -single -pattern -case -. -self -. -core -. -which_overlapping_matches -( -cache -input -patset -) -} -} -# -[ -derive -( -Debug -) -] -struct -ReverseSuffix -{ -core -: -Core -pre -: -Prefilter -} -impl -ReverseSuffix -{ -fn -new -( -core -: -Core -hirs -: -& -[ -& -Hir -] -) -- -> -Result -< -ReverseSuffix -Core -> -{ -if -! -core -. -info -. -config -( -) -. -get_auto_prefilter -( -) -{ -debug -! -( -" -skipping -reverse -suffix -optimization -because -\ -automatic -prefilters -are -disabled -" -) -; -return -Err -( -core -) -; -} -/ -/ -Like -the -reverse -inner -optimization -we -don -' -t -do -this -for -regexes -/ -/ -that -are -always -anchored -. -It -could -lead -to -scanning -too -much -but -/ -/ -could -say -" -no -match -" -much -more -quickly -than -running -the -regex -/ -/ -engine -if -the -initial -literal -scan -doesn -' -t -match -. -With -that -said -/ -/ -the -reverse -suffix -optimization -has -lower -overhead -since -it -only -/ -/ -requires -a -reverse -scan -after -a -literal -match -to -confirm -or -reject -/ -/ -the -match -. -( -Although -in -the -case -of -confirmation -it -then -needs -to -/ -/ -do -another -forward -scan -to -find -the -end -position -. -) -/ -/ -/ -/ -Note -that -the -caller -can -still -request -an -anchored -search -even -/ -/ -when -the -regex -isn -' -t -anchored -. -We -detect -that -case -in -the -search -/ -/ -routines -below -and -just -fallback -to -the -core -engine -. -Currently -this -/ -/ -optimization -assumes -all -searches -are -unanchored -so -if -we -do -want -/ -/ -to -enable -this -optimization -for -anchored -searches -it -will -need -a -/ -/ -little -work -to -support -it -. -if -core -. -info -. -is_always_anchored_start -( -) -{ -debug -! -( -" -skipping -reverse -suffix -optimization -because -\ -the -regex -is -always -anchored -at -the -start -" -) -; -return -Err -( -core -) -; -} -/ -/ -Only -DFAs -can -do -reverse -searches -( -currently -) -so -we -need -one -of -/ -/ -them -in -order -to -do -this -optimization -. -It -' -s -possible -( -although -/ -/ -pretty -unlikely -) -that -we -have -neither -and -need -to -give -up -. -if -! -core -. -hybrid -. -is_some -( -) -& -& -! -core -. -dfa -. -is_some -( -) -{ -debug -! -( -" -skipping -reverse -suffix -optimization -because -\ -we -don -' -t -have -a -lazy -DFA -or -a -full -DFA -" -) -; -return -Err -( -core -) -; -} -if -core -. -pre -. -as_ref -( -) -. -map_or -( -false -| -p -| -p -. -is_fast -( -) -) -{ -debug -! -( -" -skipping -reverse -suffix -optimization -because -\ -we -already -have -a -prefilter -that -we -think -is -fast -" -) -; -return -Err -( -core -) -; -} -let -kind -= -core -. -info -. -config -( -) -. -get_match_kind -( -) -; -let -suffixes -= -crate -: -: -util -: -: -prefilter -: -: -suffixes -( -kind -hirs -) -; -let -lcs -= -match -suffixes -. -longest_common_suffix -( -) -{ -None -= -> -{ -debug -! -( -" -skipping -reverse -suffix -optimization -because -\ -a -longest -common -suffix -could -not -be -found -" -) -; -return -Err -( -core -) -; -} -Some -( -lcs -) -if -lcs -. -is_empty -( -) -= -> -{ -debug -! -( -" -skipping -reverse -suffix -optimization -because -\ -the -longest -common -suffix -is -the -empty -string -" -) -; -return -Err -( -core -) -; -} -Some -( -lcs -) -= -> -lcs -} -; -let -pre -= -match -Prefilter -: -: -new -( -kind -& -[ -lcs -] -) -{ -Some -( -pre -) -= -> -pre -None -= -> -{ -debug -! -( -" -skipping -reverse -suffix -optimization -because -\ -a -prefilter -could -not -be -constructed -from -the -\ -longest -common -suffix -" -) -; -return -Err -( -core -) -; -} -} -; -if -! -pre -. -is_fast -( -) -{ -debug -! -( -" -skipping -reverse -suffix -optimization -because -\ -while -we -have -a -suffix -prefilter -it -is -not -\ -believed -to -be -' -fast -' -" -) -; -return -Err -( -core -) -; -} -Ok -( -ReverseSuffix -{ -core -pre -} -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -try_search_half_start -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -let -mut -span -= -input -. -get_span -( -) -; -let -mut -min_start -= -0 -; -loop -{ -let -litmatch -= -match -self -. -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -return -Ok -( -None -) -Some -( -span -) -= -> -span -} -; -trace -! -( -" -reverse -suffix -scan -found -suffix -match -at -{ -: -? -} -" -litmatch -) -; -let -revinput -= -input -. -clone -( -) -. -anchored -( -Anchored -: -: -Yes -) -. -span -( -input -. -start -( -) -. -. -litmatch -. -end -) -; -match -self -. -try_search_half_rev_limited -( -cache -& -revinput -min_start -) -? -{ -None -= -> -{ -if -span -. -start -> -= -span -. -end -{ -break -; -} -span -. -start -= -litmatch -. -start -. -checked_add -( -1 -) -. -unwrap -( -) -; -} -Some -( -hm -) -= -> -return -Ok -( -Some -( -hm -) -) -} -min_start -= -litmatch -. -end -; -} -Ok -( -None -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -try_search_half_fwd -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -RetryFailError -> -{ -if -let -Some -( -e -) -= -self -. -core -. -dfa -. -get -( -& -input -) -{ -trace -! -( -" -using -full -DFA -for -forward -reverse -suffix -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -try_search_half_fwd -( -& -input -) -} -else -if -let -Some -( -e -) -= -self -. -core -. -hybrid -. -get -( -& -input -) -{ -trace -! -( -" -using -lazy -DFA -for -forward -reverse -suffix -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -try_search_half_fwd -( -& -mut -cache -. -hybrid -& -input -) -} -else -{ -unreachable -! -( -" -ReverseSuffix -always -has -a -DFA -" -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -try_search_half_rev_limited -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -min_start -: -usize -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -if -let -Some -( -e -) -= -self -. -core -. -dfa -. -get -( -& -input -) -{ -trace -! -( -" -using -full -DFA -for -reverse -suffix -search -at -{ -: -? -} -\ -but -will -be -stopped -at -{ -} -to -avoid -quadratic -behavior -" -input -. -get_span -( -) -min_start -) -; -e -. -try_search_half_rev_limited -( -& -input -min_start -) -} -else -if -let -Some -( -e -) -= -self -. -core -. -hybrid -. -get -( -& -input -) -{ -trace -! -( -" -using -lazy -DFA -for -reverse -inner -search -at -{ -: -? -} -\ -but -will -be -stopped -at -{ -} -to -avoid -quadratic -behavior -" -input -. -get_span -( -) -min_start -) -; -e -. -try_search_half_rev_limited -( -& -mut -cache -. -hybrid -& -input -min_start -) -} -else -{ -unreachable -! -( -" -ReverseSuffix -always -has -a -DFA -" -) -} -} -} -impl -Strategy -for -ReverseSuffix -{ -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -self -. -core -. -group_info -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -create_cache -( -& -self -) -- -> -Cache -{ -self -. -core -. -create_cache -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -self -. -core -. -reset_cache -( -cache -) -; -} -fn -is_accelerated -( -& -self -) -- -> -bool -{ -self -. -pre -. -is_fast -( -) -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -core -. -memory_usage -( -) -+ -self -. -pre -. -memory_usage -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search -( -cache -input -) -; -} -match -self -. -try_search_half_start -( -cache -input -) -{ -Err -( -RetryError -: -: -Quadratic -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -suffix -optimization -failed -: -{ -} -" -_err -) -; -self -. -core -. -search -( -cache -input -) -} -Err -( -RetryError -: -: -Fail -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -suffix -reverse -fast -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -None -Ok -( -Some -( -hm_start -) -) -= -> -{ -let -fwdinput -= -input -. -clone -( -) -. -anchored -( -Anchored -: -: -Pattern -( -hm_start -. -pattern -( -) -) -) -. -span -( -hm_start -. -offset -( -) -. -. -input -. -end -( -) -) -; -match -self -. -try_search_half_fwd -( -cache -& -fwdinput -) -{ -Err -( -_err -) -= -> -{ -trace -! -( -" -reverse -suffix -forward -fast -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -{ -unreachable -! -( -" -suffix -match -plus -reverse -match -implies -\ -there -must -be -a -match -" -) -} -Ok -( -Some -( -hm_end -) -) -= -> -Some -( -Match -: -: -new -( -hm_start -. -pattern -( -) -hm_start -. -offset -( -) -. -. -hm_end -. -offset -( -) -) -) -} -} -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search_half -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search_half -( -cache -input -) -; -} -match -self -. -try_search_half_start -( -cache -input -) -{ -Err -( -RetryError -: -: -Quadratic -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -suffix -half -optimization -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_half -( -cache -input -) -} -Err -( -RetryError -: -: -Fail -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -suffix -reverse -fast -half -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_half_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -None -Ok -( -Some -( -hm_start -) -) -= -> -{ -/ -/ -This -is -a -bit -subtle -. -It -is -tempting -to -just -stop -searching -/ -/ -at -this -point -and -return -a -half -- -match -with -an -offset -/ -/ -corresponding -to -where -the -suffix -was -found -. -But -the -suffix -/ -/ -match -does -not -necessarily -correspond -to -the -end -of -the -/ -/ -proper -leftmost -- -first -match -. -Consider -/ -[ -a -- -z -] -+ -ing -/ -against -/ -/ -' -tingling -' -. -The -first -suffix -match -is -the -first -' -ing -' -and -/ -/ -the -/ -[ -a -- -z -] -+ -/ -matches -the -' -t -' -. -So -if -we -stopped -here -then -/ -/ -we -' -d -report -' -ting -' -as -the -match -. -But -' -tingling -' -is -the -/ -/ -correct -match -because -of -greediness -. -let -fwdinput -= -input -. -clone -( -) -. -anchored -( -Anchored -: -: -Pattern -( -hm_start -. -pattern -( -) -) -) -. -span -( -hm_start -. -offset -( -) -. -. -input -. -end -( -) -) -; -match -self -. -try_search_half_fwd -( -cache -& -fwdinput -) -{ -Err -( -_err -) -= -> -{ -trace -! -( -" -reverse -suffix -forward -fast -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_half_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -{ -unreachable -! -( -" -suffix -match -plus -reverse -match -implies -\ -there -must -be -a -match -" -) -} -Ok -( -Some -( -hm_end -) -) -= -> -Some -( -hm_end -) -} -} -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_match -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -is_match -( -cache -input -) -; -} -match -self -. -try_search_half_start -( -cache -input -) -{ -Err -( -RetryError -: -: -Quadratic -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -suffix -half -optimization -failed -: -{ -} -" -_err -) -; -self -. -core -. -is_match_nofail -( -cache -input -) -} -Err -( -RetryError -: -: -Fail -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -suffix -reverse -fast -half -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -is_match_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -false -Ok -( -Some -( -_ -) -) -= -> -true -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search_slots -( -cache -input -slots -) -; -} -if -! -self -. -core -. -is_capture_search_needed -( -slots -. -len -( -) -) -{ -trace -! -( -" -asked -for -slots -unnecessarily -trying -fast -path -" -) -; -let -m -= -self -. -search -( -cache -input -) -? -; -copy_match_to_slots -( -m -slots -) -; -return -Some -( -m -. -pattern -( -) -) -; -} -let -hm_start -= -match -self -. -try_search_half_start -( -cache -input -) -{ -Err -( -RetryError -: -: -Quadratic -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -suffix -captures -optimization -failed -: -{ -} -" -_err -) -; -return -self -. -core -. -search_slots -( -cache -input -slots -) -; -} -Err -( -RetryError -: -: -Fail -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -suffix -reverse -fast -captures -search -failed -: -{ -} -" -_err -) -; -return -self -. -core -. -search_slots_nofail -( -cache -input -slots -) -; -} -Ok -( -None -) -= -> -return -None -Ok -( -Some -( -hm_start -) -) -= -> -hm_start -} -; -trace -! -( -" -match -found -at -{ -} -. -. -{ -} -in -capture -search -\ -using -another -engine -to -find -captures -" -hm_start -. -offset -( -) -input -. -end -( -) -) -; -let -start -= -hm_start -. -offset -( -) -; -let -input -= -input -. -clone -( -) -. -span -( -start -. -. -input -. -end -( -) -) -. -anchored -( -Anchored -: -: -Pattern -( -hm_start -. -pattern -( -) -) -) -; -self -. -core -. -search_slots_nofail -( -cache -& -input -slots -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -which_overlapping_matches -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -self -. -core -. -which_overlapping_matches -( -cache -input -patset -) -} -} -# -[ -derive -( -Debug -) -] -struct -ReverseInner -{ -core -: -Core -preinner -: -Prefilter -nfarev -: -NFA -hybrid -: -wrappers -: -: -ReverseHybrid -dfa -: -wrappers -: -: -ReverseDFA -} -impl -ReverseInner -{ -fn -new -( -core -: -Core -hirs -: -& -[ -& -Hir -] -) -- -> -Result -< -ReverseInner -Core -> -{ -if -! -core -. -info -. -config -( -) -. -get_auto_prefilter -( -) -{ -debug -! -( -" -skipping -reverse -inner -optimization -because -\ -automatic -prefilters -are -disabled -" -) -; -return -Err -( -core -) -; -} -/ -/ -Currently -we -hard -- -code -the -assumption -of -leftmost -- -first -match -/ -/ -semantics -. -This -isn -' -t -a -huge -deal -because -' -all -' -semantics -tend -to -/ -/ -only -be -used -for -forward -overlapping -searches -with -multiple -regexes -/ -/ -and -this -optimization -only -supports -a -single -pattern -at -the -moment -. -if -core -. -info -. -config -( -) -. -get_match_kind -( -) -! -= -MatchKind -: -: -LeftmostFirst -{ -debug -! -( -" -skipping -reverse -inner -optimization -because -\ -match -kind -is -{ -: -? -} -but -this -only -supports -leftmost -- -first -" -core -. -info -. -config -( -) -. -get_match_kind -( -) -) -; -return -Err -( -core -) -; -} -/ -/ -It -' -s -likely -that -a -reverse -inner -scan -has -too -much -overhead -for -it -/ -/ -to -be -worth -it -when -the -regex -is -anchored -at -the -start -. -It -is -/ -/ -possible -for -it -to -be -quite -a -bit -faster -if -the -initial -literal -/ -/ -scan -fails -to -detect -a -match -in -which -case -we -can -say -" -no -match -" -/ -/ -very -quickly -. -But -this -could -be -undesirable -e -. -g -. -scanning -too -far -/ -/ -or -when -the -literal -scan -matches -. -If -it -matches -then -confirming -the -/ -/ -match -requires -a -reverse -scan -followed -by -a -forward -scan -to -confirm -/ -/ -or -reject -which -is -a -fair -bit -of -work -. -/ -/ -/ -/ -Note -that -the -caller -can -still -request -an -anchored -search -even -/ -/ -when -the -regex -isn -' -t -anchored -. -We -detect -that -case -in -the -search -/ -/ -routines -below -and -just -fallback -to -the -core -engine -. -Currently -this -/ -/ -optimization -assumes -all -searches -are -unanchored -so -if -we -do -want -/ -/ -to -enable -this -optimization -for -anchored -searches -it -will -need -a -/ -/ -little -work -to -support -it -. -if -core -. -info -. -is_always_anchored_start -( -) -{ -debug -! -( -" -skipping -reverse -inner -optimization -because -\ -the -regex -is -always -anchored -at -the -start -" -) -; -return -Err -( -core -) -; -} -/ -/ -Only -DFAs -can -do -reverse -searches -( -currently -) -so -we -need -one -of -/ -/ -them -in -order -to -do -this -optimization -. -It -' -s -possible -( -although -/ -/ -pretty -unlikely -) -that -we -have -neither -and -need -to -give -up -. -if -! -core -. -hybrid -. -is_some -( -) -& -& -! -core -. -dfa -. -is_some -( -) -{ -debug -! -( -" -skipping -reverse -inner -optimization -because -\ -we -don -' -t -have -a -lazy -DFA -or -a -full -DFA -" -) -; -return -Err -( -core -) -; -} -if -core -. -pre -. -as_ref -( -) -. -map_or -( -false -| -p -| -p -. -is_fast -( -) -) -{ -debug -! -( -" -skipping -reverse -inner -optimization -because -\ -we -already -have -a -prefilter -that -we -think -is -fast -" -) -; -return -Err -( -core -) -; -} -else -if -core -. -pre -. -is_some -( -) -{ -debug -! -( -" -core -engine -has -a -prefix -prefilter -but -it -is -\ -probably -not -fast -so -continuing -with -attempt -to -\ -use -reverse -inner -prefilter -" -) -; -} -let -( -concat_prefix -preinner -) -= -match -reverse_inner -: -: -extract -( -hirs -) -{ -Some -( -x -) -= -> -x -/ -/ -N -. -B -. -the -' -extract -' -function -emits -debug -messages -explaining -/ -/ -why -we -bailed -out -here -. -None -= -> -return -Err -( -core -) -} -; -debug -! -( -" -building -reverse -NFA -for -prefix -before -inner -literal -" -) -; -let -mut -lookm -= -LookMatcher -: -: -new -( -) -; -lookm -. -set_line_terminator -( -core -. -info -. -config -( -) -. -get_line_terminator -( -) -) -; -let -thompson_config -= -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -. -utf8 -( -core -. -info -. -config -( -) -. -get_utf8_empty -( -) -) -. -nfa_size_limit -( -core -. -info -. -config -( -) -. -get_nfa_size_limit -( -) -) -. -shrink -( -false -) -. -which_captures -( -WhichCaptures -: -: -None -) -. -look_matcher -( -lookm -) -; -let -result -= -thompson -: -: -Compiler -: -: -new -( -) -. -configure -( -thompson_config -) -. -build_from_hir -( -& -concat_prefix -) -; -let -nfarev -= -match -result -{ -Ok -( -nfarev -) -= -> -nfarev -Err -( -_err -) -= -> -{ -debug -! -( -" -skipping -reverse -inner -optimization -because -the -\ -reverse -NFA -failed -to -build -: -{ -} -" -_err -) -; -return -Err -( -core -) -; -} -} -; -debug -! -( -" -building -reverse -DFA -for -prefix -before -inner -literal -" -) -; -let -dfa -= -if -! -core -. -info -. -config -( -) -. -get_dfa -( -) -{ -wrappers -: -: -ReverseDFA -: -: -none -( -) -} -else -{ -wrappers -: -: -ReverseDFA -: -: -new -( -& -core -. -info -& -nfarev -) -} -; -let -hybrid -= -if -! -core -. -info -. -config -( -) -. -get_hybrid -( -) -{ -wrappers -: -: -ReverseHybrid -: -: -none -( -) -} -else -if -dfa -. -is_some -( -) -{ -debug -! -( -" -skipping -lazy -DFA -for -reverse -inner -optimization -\ -because -we -have -a -full -DFA -" -) -; -wrappers -: -: -ReverseHybrid -: -: -none -( -) -} -else -{ -wrappers -: -: -ReverseHybrid -: -: -new -( -& -core -. -info -& -nfarev -) -} -; -Ok -( -ReverseInner -{ -core -preinner -nfarev -hybrid -dfa -} -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -try_search_full -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -RetryError -> -{ -let -mut -span -= -input -. -get_span -( -) -; -let -mut -min_match_start -= -0 -; -let -mut -min_pre_start -= -0 -; -loop -{ -let -litmatch -= -match -self -. -preinner -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -return -Ok -( -None -) -Some -( -span -) -= -> -span -} -; -if -litmatch -. -start -< -min_pre_start -{ -trace -! -( -" -found -inner -prefilter -match -at -{ -: -? -} -which -starts -\ -before -the -end -of -the -last -forward -scan -at -{ -} -\ -quitting -to -avoid -quadratic -behavior -" -litmatch -min_pre_start -) -; -return -Err -( -RetryError -: -: -Quadratic -( -RetryQuadraticError -: -: -new -( -) -) -) -; -} -trace -! -( -" -reverse -inner -scan -found -inner -match -at -{ -: -? -} -" -litmatch -) -; -let -revinput -= -input -. -clone -( -) -. -anchored -( -Anchored -: -: -Yes -) -. -span -( -input -. -start -( -) -. -. -litmatch -. -start -) -; -/ -/ -Note -that -in -addition -to -the -literal -search -above -scanning -past -/ -/ -our -minimum -start -point -this -routine -can -also -return -an -error -/ -/ -as -a -result -of -detecting -possible -quadratic -behavior -if -the -/ -/ -reverse -scan -goes -past -the -minimum -start -point -. -That -is -the -/ -/ -literal -search -might -not -but -the -reverse -regex -search -for -the -/ -/ -prefix -might -! -match -self -. -try_search_half_rev_limited -( -cache -& -revinput -min_match_start -) -? -{ -None -= -> -{ -if -span -. -start -> -= -span -. -end -{ -break -; -} -span -. -start -= -litmatch -. -start -. -checked_add -( -1 -) -. -unwrap -( -) -; -} -Some -( -hm_start -) -= -> -{ -let -fwdinput -= -input -. -clone -( -) -. -anchored -( -Anchored -: -: -Pattern -( -hm_start -. -pattern -( -) -) -) -. -span -( -hm_start -. -offset -( -) -. -. -input -. -end -( -) -) -; -match -self -. -try_search_half_fwd_stopat -( -cache -& -fwdinput -) -? -{ -Err -( -stopat -) -= -> -{ -min_pre_start -= -stopat -; -span -. -start -= -litmatch -. -start -. -checked_add -( -1 -) -. -unwrap -( -) -; -} -Ok -( -hm_end -) -= -> -{ -return -Ok -( -Some -( -Match -: -: -new -( -hm_start -. -pattern -( -) -hm_start -. -offset -( -) -. -. -hm_end -. -offset -( -) -) -) -) -} -} -} -} -min_match_start -= -litmatch -. -end -; -} -Ok -( -None -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -try_search_half_fwd_stopat -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Result -< -HalfMatch -usize -> -RetryFailError -> -{ -if -let -Some -( -e -) -= -self -. -core -. -dfa -. -get -( -& -input -) -{ -trace -! -( -" -using -full -DFA -for -forward -reverse -inner -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -try_search_half_fwd_stopat -( -& -input -) -} -else -if -let -Some -( -e -) -= -self -. -core -. -hybrid -. -get -( -& -input -) -{ -trace -! -( -" -using -lazy -DFA -for -forward -reverse -inner -search -at -{ -: -? -} -" -input -. -get_span -( -) -) -; -e -. -try_search_half_fwd_stopat -( -& -mut -cache -. -hybrid -& -input -) -} -else -{ -unreachable -! -( -" -ReverseInner -always -has -a -DFA -" -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -try_search_half_rev_limited -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -min_start -: -usize -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -if -let -Some -( -e -) -= -self -. -dfa -. -get -( -& -input -) -{ -trace -! -( -" -using -full -DFA -for -reverse -inner -search -at -{ -: -? -} -\ -but -will -be -stopped -at -{ -} -to -avoid -quadratic -behavior -" -input -. -get_span -( -) -min_start -) -; -e -. -try_search_half_rev_limited -( -& -input -min_start -) -} -else -if -let -Some -( -e -) -= -self -. -hybrid -. -get -( -& -input -) -{ -trace -! -( -" -using -lazy -DFA -for -reverse -inner -search -at -{ -: -? -} -\ -but -will -be -stopped -at -{ -} -to -avoid -quadratic -behavior -" -input -. -get_span -( -) -min_start -) -; -e -. -try_search_half_rev_limited -( -& -mut -cache -. -revhybrid -& -input -min_start -) -} -else -{ -unreachable -! -( -" -ReverseInner -always -has -a -DFA -" -) -} -} -} -impl -Strategy -for -ReverseInner -{ -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -self -. -core -. -group_info -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -create_cache -( -& -self -) -- -> -Cache -{ -let -mut -cache -= -self -. -core -. -create_cache -( -) -; -cache -. -revhybrid -= -self -. -hybrid -. -create_cache -( -) -; -cache -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -self -. -core -. -reset_cache -( -cache -) -; -cache -. -revhybrid -. -reset -( -& -self -. -hybrid -) -; -} -fn -is_accelerated -( -& -self -) -- -> -bool -{ -self -. -preinner -. -is_fast -( -) -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -core -. -memory_usage -( -) -+ -self -. -preinner -. -memory_usage -( -) -+ -self -. -nfarev -. -memory_usage -( -) -+ -self -. -dfa -. -memory_usage -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -Match -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search -( -cache -input -) -; -} -match -self -. -try_search_full -( -cache -input -) -{ -Err -( -RetryError -: -: -Quadratic -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -inner -optimization -failed -: -{ -} -" -_err -) -; -self -. -core -. -search -( -cache -input -) -} -Err -( -RetryError -: -: -Fail -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -inner -fast -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_nofail -( -cache -input -) -} -Ok -( -matornot -) -= -> -matornot -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search_half -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -HalfMatch -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search_half -( -cache -input -) -; -} -match -self -. -try_search_full -( -cache -input -) -{ -Err -( -RetryError -: -: -Quadratic -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -inner -half -optimization -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_half -( -cache -input -) -} -Err -( -RetryError -: -: -Fail -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -inner -fast -half -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -search_half_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -None -Ok -( -Some -( -m -) -) -= -> -Some -( -HalfMatch -: -: -new -( -m -. -pattern -( -) -m -. -end -( -) -) -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_match -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -is_match -( -cache -input -) -; -} -match -self -. -try_search_full -( -cache -input -) -{ -Err -( -RetryError -: -: -Quadratic -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -inner -half -optimization -failed -: -{ -} -" -_err -) -; -self -. -core -. -is_match_nofail -( -cache -input -) -} -Err -( -RetryError -: -: -Fail -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -inner -fast -half -search -failed -: -{ -} -" -_err -) -; -self -. -core -. -is_match_nofail -( -cache -input -) -} -Ok -( -None -) -= -> -false -Ok -( -Some -( -_ -) -) -= -> -true -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -self -. -core -. -search_slots -( -cache -input -slots -) -; -} -if -! -self -. -core -. -is_capture_search_needed -( -slots -. -len -( -) -) -{ -trace -! -( -" -asked -for -slots -unnecessarily -trying -fast -path -" -) -; -let -m -= -self -. -search -( -cache -input -) -? -; -copy_match_to_slots -( -m -slots -) -; -return -Some -( -m -. -pattern -( -) -) -; -} -let -m -= -match -self -. -try_search_full -( -cache -input -) -{ -Err -( -RetryError -: -: -Quadratic -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -inner -captures -optimization -failed -: -{ -} -" -_err -) -; -return -self -. -core -. -search_slots -( -cache -input -slots -) -; -} -Err -( -RetryError -: -: -Fail -( -_err -) -) -= -> -{ -trace -! -( -" -reverse -inner -fast -captures -search -failed -: -{ -} -" -_err -) -; -return -self -. -core -. -search_slots_nofail -( -cache -input -slots -) -; -} -Ok -( -None -) -= -> -return -None -Ok -( -Some -( -m -) -) -= -> -m -} -; -trace -! -( -" -match -found -at -{ -} -. -. -{ -} -in -capture -search -\ -using -another -engine -to -find -captures -" -m -. -start -( -) -m -. -end -( -) -) -; -let -input -= -input -. -clone -( -) -. -span -( -m -. -start -( -) -. -. -m -. -end -( -) -) -. -anchored -( -Anchored -: -: -Pattern -( -m -. -pattern -( -) -) -) -; -self -. -core -. -search_slots_nofail -( -cache -& -input -slots -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -which_overlapping_matches -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -self -. -core -. -which_overlapping_matches -( -cache -input -patset -) -} -} -/ -/ -/ -Copies -the -offsets -in -the -given -match -to -the -corresponding -positions -in -/ -/ -/ -slots -. -/ -/ -/ -/ -/ -/ -In -effect -this -sets -the -slots -corresponding -to -the -implicit -group -for -the -/ -/ -/ -pattern -in -the -given -match -. -If -the -indices -for -the -corresponding -slots -do -/ -/ -/ -not -exist -then -no -slots -are -set -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -the -caller -provides -slots -( -or -captures -) -but -you -use -a -/ -/ -/ -regex -engine -that -doesn -' -t -operate -on -slots -( -like -a -lazy -DFA -) -. -This -function -/ -/ -/ -lets -you -map -the -match -you -get -back -to -the -slots -provided -by -the -caller -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -copy_match_to_slots -( -m -: -Match -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -{ -let -slot_start -= -m -. -pattern -( -) -. -as_usize -( -) -* -2 -; -let -slot_end -= -slot_start -+ -1 -; -if -let -Some -( -slot -) -= -slots -. -get_mut -( -slot_start -) -{ -* -slot -= -NonMaxUsize -: -: -new -( -m -. -start -( -) -) -; -} -if -let -Some -( -slot -) -= -slots -. -get_mut -( -slot_end -) -{ -* -slot -= -NonMaxUsize -: -: -new -( -m -. -end -( -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/meta/wrappers.rs b/third_party/rust/regex-automata/src/meta/wrappers.rs deleted file mode 100644 index 657f2fddb7d67..0000000000000 --- a/third_party/rust/regex-automata/src/meta/wrappers.rs +++ /dev/null @@ -1,9632 +0,0 @@ -/ -* -! -This -module -contains -a -boat -load -of -wrappers -around -each -of -our -internal -regex -engines -. -They -encapsulate -a -few -things -: -1 -. -The -wrappers -manage -the -conditional -existence -of -the -regex -engine -. -Namely -the -PikeVM -is -the -only -required -regex -engine -. -The -rest -are -optional -. -These -wrappers -present -a -uniform -API -regardless -of -which -engines -are -available -. -And -availability -might -be -determined -by -compile -time -features -or -by -dynamic -configuration -via -meta -: -: -Config -. -Encapsulating -the -conditional -compilation -features -is -in -particular -a -huge -simplification -for -the -higher -level -code -that -composes -these -engines -. -2 -. -The -wrappers -manage -construction -of -each -engine -including -skipping -it -if -the -engine -is -unavailable -or -configured -to -not -be -used -. -3 -. -The -wrappers -manage -whether -an -engine -* -can -* -be -used -for -a -particular -search -configuration -. -For -example -BoundedBacktracker -: -: -get -only -returns -a -backtracking -engine -when -the -haystack -is -bigger -than -the -maximum -supported -length -. -The -wrappers -also -sometimes -take -a -position -on -when -an -engine -* -ought -* -to -be -used -but -only -in -cases -where -the -logic -is -extremely -local -to -the -engine -itself -. -Otherwise -things -like -" -choose -between -the -backtracker -and -the -one -- -pass -DFA -" -are -managed -by -the -higher -level -meta -strategy -code -. -There -are -also -corresponding -wrappers -for -the -various -Cache -types -for -each -regex -engine -that -needs -them -. -If -an -engine -is -unavailable -or -not -used -then -a -cache -for -it -will -* -not -* -actually -be -allocated -. -* -/ -use -alloc -: -: -vec -: -: -Vec -; -use -crate -: -: -{ -meta -: -: -{ -error -: -: -{ -BuildError -RetryError -RetryFailError -} -regex -: -: -RegexInfo -} -nfa -: -: -thompson -: -: -{ -pikevm -NFA -} -util -: -: -{ -prefilter -: -: -Prefilter -primitives -: -: -NonMaxUsize -} -HalfMatch -Input -Match -MatchKind -PatternID -PatternSet -} -; -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -use -crate -: -: -dfa -; -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -use -crate -: -: -dfa -: -: -onepass -; -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -use -crate -: -: -hybrid -; -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -use -crate -: -: -nfa -: -: -thompson -: -: -backtrack -; -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -PikeVM -( -PikeVMEngine -) -; -impl -PikeVM -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -& -NFA -) -- -> -Result -< -PikeVM -BuildError -> -{ -PikeVMEngine -: -: -new -( -info -pre -nfa -) -. -map -( -PikeVM -) -} -pub -( -crate -) -fn -create_cache -( -& -self -) -- -> -PikeVMCache -{ -PikeVMCache -: -: -new -( -self -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -get -( -& -self -) -- -> -& -PikeVMEngine -{ -& -self -. -0 -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -PikeVMEngine -( -pikevm -: -: -PikeVM -) -; -impl -PikeVMEngine -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -& -NFA -) -- -> -Result -< -PikeVMEngine -BuildError -> -{ -let -pikevm_config -= -pikevm -: -: -Config -: -: -new -( -) -. -match_kind -( -info -. -config -( -) -. -get_match_kind -( -) -) -. -prefilter -( -pre -) -; -let -engine -= -pikevm -: -: -Builder -: -: -new -( -) -. -configure -( -pikevm_config -) -. -build_from_nfa -( -nfa -. -clone -( -) -) -. -map_err -( -BuildError -: -: -nfa -) -? -; -debug -! -( -" -PikeVM -built -" -) -; -Ok -( -PikeVMEngine -( -engine -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -is_match -( -& -self -cache -: -& -mut -PikeVMCache -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -self -. -0 -. -is_match -( -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -input -. -clone -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -search_slots -( -& -self -cache -: -& -mut -PikeVMCache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -self -. -0 -. -search_slots -( -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -input -slots -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -which_overlapping_matches -( -& -self -cache -: -& -mut -PikeVMCache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -self -. -0 -. -which_overlapping_matches -( -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -input -patset -) -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -PikeVMCache -( -Option -< -pikevm -: -: -Cache -> -) -; -impl -PikeVMCache -{ -pub -( -crate -) -fn -none -( -) -- -> -PikeVMCache -{ -PikeVMCache -( -None -) -} -pub -( -crate -) -fn -new -( -builder -: -& -PikeVM -) -- -> -PikeVMCache -{ -PikeVMCache -( -Some -( -builder -. -get -( -) -. -0 -. -create_cache -( -) -) -) -} -pub -( -crate -) -fn -reset -( -& -mut -self -builder -: -& -PikeVM -) -{ -self -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -reset -( -& -builder -. -get -( -) -. -0 -) -; -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -0 -. -as_ref -( -) -. -map_or -( -0 -| -c -| -c -. -memory_usage -( -) -) -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -BoundedBacktracker -( -Option -< -BoundedBacktrackerEngine -> -) -; -impl -BoundedBacktracker -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -& -NFA -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -BoundedBacktrackerEngine -: -: -new -( -info -pre -nfa -) -. -map -( -BoundedBacktracker -) -} -pub -( -crate -) -fn -create_cache -( -& -self -) -- -> -BoundedBacktrackerCache -{ -BoundedBacktrackerCache -: -: -new -( -self -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -get -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -& -BoundedBacktrackerEngine -> -{ -let -engine -= -self -. -0 -. -as_ref -( -) -? -; -/ -/ -It -is -difficult -to -make -the -backtracker -give -up -early -if -it -is -/ -/ -guaranteed -to -eventually -wind -up -in -a -match -state -. -This -is -because -/ -/ -of -the -greedy -nature -of -a -backtracker -: -it -just -blindly -mushes -/ -/ -forward -. -Every -other -regex -engine -is -able -to -give -up -more -quickly -/ -/ -so -even -if -the -backtracker -might -be -able -to -zip -through -faster -than -/ -/ -( -say -) -the -PikeVM -we -prefer -the -theoretical -benefit -that -some -other -/ -/ -engine -might -be -able -to -scan -much -less -of -the -haystack -than -the -/ -/ -backtracker -. -/ -/ -/ -/ -Now -if -the -haystack -is -really -short -already -then -we -allow -the -/ -/ -backtracker -to -run -. -( -This -hasn -' -t -been -litigated -quantitatively -with -/ -/ -benchmarks -. -Just -a -hunch -. -) -if -input -. -get_earliest -( -) -& -& -input -. -haystack -( -) -. -len -( -) -> -128 -{ -return -None -; -} -/ -/ -If -the -backtracker -is -just -going -to -return -an -error -because -the -/ -/ -haystack -is -too -long -then -obviously -do -not -use -it -. -if -input -. -get_span -( -) -. -len -( -) -> -engine -. -max_haystack_len -( -) -{ -return -None -; -} -Some -( -engine -) -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -BoundedBacktrackerEngine -( -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -backtrack -: -: -BoundedBacktracker -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -( -) -) -; -impl -BoundedBacktrackerEngine -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -& -NFA -) -- -> -Result -< -Option -< -BoundedBacktrackerEngine -> -BuildError -> -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -{ -if -! -info -. -config -( -) -. -get_backtrack -( -) -| -| -info -. -config -( -) -. -get_match_kind -( -) -! -= -MatchKind -: -: -LeftmostFirst -{ -return -Ok -( -None -) -; -} -let -backtrack_config -= -backtrack -: -: -Config -: -: -new -( -) -. -prefilter -( -pre -) -; -let -engine -= -backtrack -: -: -Builder -: -: -new -( -) -. -configure -( -backtrack_config -) -. -build_from_nfa -( -nfa -. -clone -( -) -) -. -map_err -( -BuildError -: -: -nfa -) -? -; -debug -! -( -" -BoundedBacktracker -built -" -) -; -Ok -( -Some -( -BoundedBacktrackerEngine -( -engine -) -) -) -} -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -{ -Ok -( -None -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -is_match -( -& -self -cache -: -& -mut -BoundedBacktrackerCache -input -: -& -Input -< -' -_ -> -) -- -> -bool -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -{ -/ -/ -OK -because -we -only -permit -access -to -this -engine -when -we -know -/ -/ -the -haystack -is -short -enough -for -the -backtracker -to -run -without -/ -/ -reporting -an -error -. -self -. -0 -. -try_is_match -( -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -input -. -clone -( -) -) -. -unwrap -( -) -} -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -search_slots -( -& -self -cache -: -& -mut -BoundedBacktrackerCache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -{ -/ -/ -OK -because -we -only -permit -access -to -this -engine -when -we -know -/ -/ -the -haystack -is -short -enough -for -the -backtracker -to -run -without -/ -/ -reporting -an -error -. -self -. -0 -. -try_search_slots -( -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -input -slots -) -. -unwrap -( -) -} -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -max_haystack_len -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -{ -self -. -0 -. -max_haystack_len -( -) -} -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -BoundedBacktrackerCache -( -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -Option -< -backtrack -: -: -Cache -> -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -( -) -) -; -impl -BoundedBacktrackerCache -{ -pub -( -crate -) -fn -none -( -) -- -> -BoundedBacktrackerCache -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -{ -BoundedBacktrackerCache -( -None -) -} -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -{ -BoundedBacktrackerCache -( -( -) -) -} -} -pub -( -crate -) -fn -new -( -builder -: -& -BoundedBacktracker -) -- -> -BoundedBacktrackerCache -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -{ -BoundedBacktrackerCache -( -builder -. -0 -. -as_ref -( -) -. -map -( -| -e -| -e -. -0 -. -create_cache -( -) -) -) -} -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -{ -BoundedBacktrackerCache -( -( -) -) -} -} -pub -( -crate -) -fn -reset -( -& -mut -self -builder -: -& -BoundedBacktracker -) -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -if -let -Some -( -ref -e -) -= -builder -. -0 -{ -self -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -reset -( -& -e -. -0 -) -; -} -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -{ -self -. -0 -. -as_ref -( -) -. -map_or -( -0 -| -c -| -c -. -memory_usage -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -nfa -- -backtrack -" -) -) -] -{ -0 -} -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -OnePass -( -Option -< -OnePassEngine -> -) -; -impl -OnePass -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -nfa -: -& -NFA -) -- -> -OnePass -{ -OnePass -( -OnePassEngine -: -: -new -( -info -nfa -) -) -} -pub -( -crate -) -fn -create_cache -( -& -self -) -- -> -OnePassCache -{ -OnePassCache -: -: -new -( -self -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -get -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -& -OnePassEngine -> -{ -let -engine -= -self -. -0 -. -as_ref -( -) -? -; -if -! -input -. -get_anchored -( -) -. -is_anchored -( -) -& -& -! -engine -. -get_nfa -( -) -. -is_always_start_anchored -( -) -{ -return -None -; -} -Some -( -engine -) -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -0 -. -as_ref -( -) -. -map_or -( -0 -| -e -| -e -. -memory_usage -( -) -) -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -OnePassEngine -( -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -onepass -: -: -DFA -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -( -) -) -; -impl -OnePassEngine -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -nfa -: -& -NFA -) -- -> -Option -< -OnePassEngine -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -{ -if -! -info -. -config -( -) -. -get_onepass -( -) -{ -return -None -; -} -/ -/ -In -order -to -even -attempt -building -a -one -- -pass -DFA -we -require -/ -/ -that -we -either -have -at -least -one -explicit -capturing -group -or -/ -/ -there -' -s -a -Unicode -word -boundary -somewhere -. -If -we -don -' -t -have -/ -/ -either -of -these -things -then -the -lazy -DFA -will -almost -certainly -/ -/ -be -useable -and -be -much -faster -. -The -only -case -where -it -might -/ -/ -not -is -if -the -lazy -DFA -isn -' -t -utilizing -its -cache -effectively -/ -/ -but -in -those -cases -the -underlying -regex -is -almost -certainly -/ -/ -not -one -- -pass -or -is -too -big -to -fit -within -the -current -one -- -pass -/ -/ -implementation -limits -. -if -info -. -props_union -( -) -. -explicit_captures_len -( -) -= -= -0 -& -& -! -info -. -props_union -( -) -. -look_set -( -) -. -contains_word_unicode -( -) -{ -debug -! -( -" -not -building -OnePass -because -it -isn -' -t -worth -it -" -) -; -return -None -; -} -let -onepass_config -= -onepass -: -: -Config -: -: -new -( -) -. -match_kind -( -info -. -config -( -) -. -get_match_kind -( -) -) -/ -/ -Like -for -the -lazy -DFA -we -unconditionally -enable -this -/ -/ -because -it -doesn -' -t -cost -much -and -makes -the -API -more -/ -/ -flexible -. -. -starts_for_each_pattern -( -true -) -. -byte_classes -( -info -. -config -( -) -. -get_byte_classes -( -) -) -. -size_limit -( -info -. -config -( -) -. -get_onepass_size_limit -( -) -) -; -let -result -= -onepass -: -: -Builder -: -: -new -( -) -. -configure -( -onepass_config -) -. -build_from_nfa -( -nfa -. -clone -( -) -) -; -let -engine -= -match -result -{ -Ok -( -engine -) -= -> -engine -Err -( -_err -) -= -> -{ -debug -! -( -" -OnePass -failed -to -build -: -{ -} -" -_err -) -; -return -None -; -} -} -; -debug -! -( -" -OnePass -built -{ -} -bytes -" -engine -. -memory_usage -( -) -) -; -Some -( -OnePassEngine -( -engine -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -{ -None -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -search_slots -( -& -self -cache -: -& -mut -OnePassCache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -{ -/ -/ -OK -because -we -only -permit -getting -a -OnePassEngine -when -we -know -/ -/ -the -search -is -anchored -and -thus -an -error -cannot -occur -. -self -. -0 -. -try_search_slots -( -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -input -slots -) -. -unwrap -( -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -{ -self -. -0 -. -memory_usage -( -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -get_nfa -( -& -self -) -- -> -& -NFA -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -{ -self -. -0 -. -get_nfa -( -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -OnePassCache -( -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -Option -< -onepass -: -: -Cache -> -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -( -) -) -; -impl -OnePassCache -{ -pub -( -crate -) -fn -none -( -) -- -> -OnePassCache -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -{ -OnePassCache -( -None -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -{ -OnePassCache -( -( -) -) -} -} -pub -( -crate -) -fn -new -( -builder -: -& -OnePass -) -- -> -OnePassCache -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -{ -OnePassCache -( -builder -. -0 -. -as_ref -( -) -. -map -( -| -e -| -e -. -0 -. -create_cache -( -) -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -{ -OnePassCache -( -( -) -) -} -} -pub -( -crate -) -fn -reset -( -& -mut -self -builder -: -& -OnePass -) -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -if -let -Some -( -ref -e -) -= -builder -. -0 -{ -self -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -reset -( -& -e -. -0 -) -; -} -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -{ -self -. -0 -. -as_ref -( -) -. -map_or -( -0 -| -c -| -c -. -memory_usage -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -onepass -" -) -) -] -{ -0 -} -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -Hybrid -( -Option -< -HybridEngine -> -) -; -impl -Hybrid -{ -pub -( -crate -) -fn -none -( -) -- -> -Hybrid -{ -Hybrid -( -None -) -} -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -& -NFA -nfarev -: -& -NFA -) -- -> -Hybrid -{ -Hybrid -( -HybridEngine -: -: -new -( -info -pre -nfa -nfarev -) -) -} -pub -( -crate -) -fn -create_cache -( -& -self -) -- -> -HybridCache -{ -HybridCache -: -: -new -( -self -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -get -( -& -self -_input -: -& -Input -< -' -_ -> -) -- -> -Option -< -& -HybridEngine -> -{ -let -engine -= -self -. -0 -. -as_ref -( -) -? -; -Some -( -engine -) -} -pub -( -crate -) -fn -is_some -( -& -self -) -- -> -bool -{ -self -. -0 -. -is_some -( -) -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -HybridEngine -( -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -hybrid -: -: -regex -: -: -Regex -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -( -) -) -; -impl -HybridEngine -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -& -NFA -nfarev -: -& -NFA -) -- -> -Option -< -HybridEngine -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -if -! -info -. -config -( -) -. -get_hybrid -( -) -{ -return -None -; -} -let -dfa_config -= -hybrid -: -: -dfa -: -: -Config -: -: -new -( -) -. -match_kind -( -info -. -config -( -) -. -get_match_kind -( -) -) -. -prefilter -( -pre -. -clone -( -) -) -/ -/ -Enabling -this -is -necessary -for -ensuring -we -can -service -any -/ -/ -kind -of -' -Input -' -search -without -error -. -For -the -lazy -DFA -/ -/ -this -is -not -particularly -costly -since -the -start -states -are -/ -/ -generated -lazily -. -. -starts_for_each_pattern -( -true -) -. -byte_classes -( -info -. -config -( -) -. -get_byte_classes -( -) -) -. -unicode_word_boundary -( -true -) -. -specialize_start_states -( -pre -. -is_some -( -) -) -. -cache_capacity -( -info -. -config -( -) -. -get_hybrid_cache_capacity -( -) -) -/ -/ -This -makes -it -possible -for -building -a -lazy -DFA -to -/ -/ -fail -even -though -the -NFA -has -already -been -built -. -Namely -/ -/ -if -the -cache -capacity -is -too -small -to -fit -some -minimum -/ -/ -number -of -states -( -which -is -small -like -4 -or -5 -) -then -the -/ -/ -DFA -will -refuse -to -build -. -/ -/ -/ -/ -We -shouldn -' -t -enable -this -to -make -building -always -work -since -/ -/ -this -could -cause -the -allocation -of -a -cache -bigger -than -the -/ -/ -provided -capacity -amount -. -/ -/ -/ -/ -This -is -effectively -the -only -reason -why -building -a -lazy -DFA -/ -/ -could -fail -. -If -it -does -then -we -simply -suppress -the -error -/ -/ -and -return -None -. -. -skip_cache_capacity_check -( -false -) -/ -/ -This -and -enabling -heuristic -Unicode -word -boundary -support -/ -/ -above -make -it -so -the -lazy -DFA -can -quit -at -match -time -. -. -minimum_cache_clear_count -( -Some -( -3 -) -) -. -minimum_bytes_per_state -( -Some -( -10 -) -) -; -let -result -= -hybrid -: -: -dfa -: -: -Builder -: -: -new -( -) -. -configure -( -dfa_config -. -clone -( -) -) -. -build_from_nfa -( -nfa -. -clone -( -) -) -; -let -fwd -= -match -result -{ -Ok -( -fwd -) -= -> -fwd -Err -( -_err -) -= -> -{ -debug -! -( -" -forward -lazy -DFA -failed -to -build -: -{ -} -" -_err -) -; -return -None -; -} -} -; -let -result -= -hybrid -: -: -dfa -: -: -Builder -: -: -new -( -) -. -configure -( -dfa_config -. -clone -( -) -. -match_kind -( -MatchKind -: -: -All -) -. -prefilter -( -None -) -. -specialize_start_states -( -false -) -) -. -build_from_nfa -( -nfarev -. -clone -( -) -) -; -let -rev -= -match -result -{ -Ok -( -rev -) -= -> -rev -Err -( -_err -) -= -> -{ -debug -! -( -" -reverse -lazy -DFA -failed -to -build -: -{ -} -" -_err -) -; -return -None -; -} -} -; -let -engine -= -hybrid -: -: -regex -: -: -Builder -: -: -new -( -) -. -build_from_dfas -( -fwd -rev -) -; -debug -! -( -" -lazy -DFA -built -" -) -; -Some -( -HybridEngine -( -engine -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -None -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search -( -& -self -cache -: -& -mut -HybridCache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -let -cache -= -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -; -self -. -0 -. -try_search -( -cache -input -) -. -map_err -( -| -e -| -e -. -into -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_fwd -( -& -self -cache -: -& -mut -HybridCache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -let -fwd -= -self -. -0 -. -forward -( -) -; -let -mut -fwdcache -= -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -as_parts_mut -( -) -. -0 -; -fwd -. -try_search_fwd -( -& -mut -fwdcache -input -) -. -map_err -( -| -e -| -e -. -into -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_fwd_stopat -( -& -self -cache -: -& -mut -HybridCache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Result -< -HalfMatch -usize -> -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -let -dfa -= -self -. -0 -. -forward -( -) -; -let -mut -cache -= -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -as_parts_mut -( -) -. -0 -; -crate -: -: -meta -: -: -stopat -: -: -hybrid_try_search_half_fwd -( -dfa -& -mut -cache -input -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_rev -( -& -self -cache -: -& -mut -HybridCache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -let -rev -= -self -. -0 -. -reverse -( -) -; -let -mut -revcache -= -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -as_parts_mut -( -) -. -1 -; -rev -. -try_search_rev -( -& -mut -revcache -input -) -. -map_err -( -| -e -| -e -. -into -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_rev_limited -( -& -self -cache -: -& -mut -HybridCache -input -: -& -Input -< -' -_ -> -min_start -: -usize -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -let -dfa -= -self -. -0 -. -reverse -( -) -; -let -mut -cache -= -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -as_parts_mut -( -) -. -1 -; -crate -: -: -meta -: -: -limited -: -: -hybrid_try_search_half_rev -( -dfa -& -mut -cache -input -min_start -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -inline -] -pub -( -crate -) -fn -try_which_overlapping_matches -( -& -self -cache -: -& -mut -HybridCache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -- -> -Result -< -( -) -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -let -fwd -= -self -. -0 -. -forward -( -) -; -let -mut -fwdcache -= -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -as_parts_mut -( -) -. -0 -; -fwd -. -try_which_overlapping_matches -( -& -mut -fwdcache -input -patset -) -. -map_err -( -| -e -| -e -. -into -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -HybridCache -( -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -Option -< -hybrid -: -: -regex -: -: -Cache -> -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -( -) -) -; -impl -HybridCache -{ -pub -( -crate -) -fn -none -( -) -- -> -HybridCache -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -HybridCache -( -None -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -HybridCache -( -( -) -) -} -} -pub -( -crate -) -fn -new -( -builder -: -& -Hybrid -) -- -> -HybridCache -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -HybridCache -( -builder -. -0 -. -as_ref -( -) -. -map -( -| -e -| -e -. -0 -. -create_cache -( -) -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -HybridCache -( -( -) -) -} -} -pub -( -crate -) -fn -reset -( -& -mut -self -builder -: -& -Hybrid -) -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -if -let -Some -( -ref -e -) -= -builder -. -0 -{ -self -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -reset -( -& -e -. -0 -) -; -} -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -self -. -0 -. -as_ref -( -) -. -map_or -( -0 -| -c -| -c -. -memory_usage -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -0 -} -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -DFA -( -Option -< -DFAEngine -> -) -; -impl -DFA -{ -pub -( -crate -) -fn -none -( -) -- -> -DFA -{ -DFA -( -None -) -} -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -& -NFA -nfarev -: -& -NFA -) -- -> -DFA -{ -DFA -( -DFAEngine -: -: -new -( -info -pre -nfa -nfarev -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -get -( -& -self -_input -: -& -Input -< -' -_ -> -) -- -> -Option -< -& -DFAEngine -> -{ -let -engine -= -self -. -0 -. -as_ref -( -) -? -; -Some -( -engine -) -} -pub -( -crate -) -fn -is_some -( -& -self -) -- -> -bool -{ -self -. -0 -. -is_some -( -) -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -0 -. -as_ref -( -) -. -map_or -( -0 -| -e -| -e -. -memory_usage -( -) -) -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -DFAEngine -( -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -dfa -: -: -regex -: -: -Regex -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -( -) -) -; -impl -DFAEngine -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -pre -: -Option -< -Prefilter -> -nfa -: -& -NFA -nfarev -: -& -NFA -) -- -> -Option -< -DFAEngine -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -if -! -info -. -config -( -) -. -get_dfa -( -) -{ -return -None -; -} -/ -/ -If -our -NFA -is -anything -but -small -don -' -t -even -bother -with -a -DFA -. -if -let -Some -( -state_limit -) -= -info -. -config -( -) -. -get_dfa_state_limit -( -) -{ -if -nfa -. -states -( -) -. -len -( -) -> -state_limit -{ -debug -! -( -" -skipping -full -DFA -because -NFA -has -{ -} -states -\ -which -exceeds -the -heuristic -limit -of -{ -} -" -nfa -. -states -( -) -. -len -( -) -state_limit -) -; -return -None -; -} -} -/ -/ -We -cut -the -size -limit -in -four -because -the -total -heap -used -by -/ -/ -DFA -construction -is -determinization -aux -memory -and -the -DFA -/ -/ -itself -and -those -things -are -configured -independently -in -the -/ -/ -lower -level -DFA -builder -API -. -And -then -split -that -in -two -because -/ -/ -of -forward -and -reverse -DFAs -. -let -size_limit -= -info -. -config -( -) -. -get_dfa_size_limit -( -) -. -map -( -| -n -| -n -/ -4 -) -; -let -dfa_config -= -dfa -: -: -dense -: -: -Config -: -: -new -( -) -. -match_kind -( -info -. -config -( -) -. -get_match_kind -( -) -) -. -prefilter -( -pre -. -clone -( -) -) -/ -/ -Enabling -this -is -necessary -for -ensuring -we -can -service -any -/ -/ -kind -of -' -Input -' -search -without -error -. -For -the -full -DFA -this -/ -/ -can -be -quite -costly -. -But -since -we -have -such -a -small -bound -/ -/ -on -the -size -of -the -DFA -in -practice -any -multl -- -regexes -are -/ -/ -probably -going -to -blow -the -limit -anyway -. -. -starts_for_each_pattern -( -true -) -. -byte_classes -( -info -. -config -( -) -. -get_byte_classes -( -) -) -. -unicode_word_boundary -( -true -) -. -specialize_start_states -( -pre -. -is_some -( -) -) -. -determinize_size_limit -( -size_limit -) -. -dfa_size_limit -( -size_limit -) -; -let -result -= -dfa -: -: -dense -: -: -Builder -: -: -new -( -) -. -configure -( -dfa_config -. -clone -( -) -) -. -build_from_nfa -( -& -nfa -) -; -let -fwd -= -match -result -{ -Ok -( -fwd -) -= -> -fwd -Err -( -_err -) -= -> -{ -debug -! -( -" -forward -full -DFA -failed -to -build -: -{ -} -" -_err -) -; -return -None -; -} -} -; -let -result -= -dfa -: -: -dense -: -: -Builder -: -: -new -( -) -. -configure -( -dfa_config -. -clone -( -) -/ -/ -We -never -need -unanchored -reverse -searches -so -/ -/ -there -' -s -no -point -in -building -it -into -the -DFA -which -/ -/ -WILL -take -more -space -. -( -This -isn -' -t -done -for -the -lazy -/ -/ -DFA -because -the -DFA -is -well -lazy -. -It -doesn -' -t -pay -/ -/ -the -cost -for -supporting -unanchored -searches -unless -/ -/ -you -actually -do -an -unanchored -search -which -we -/ -/ -don -' -t -. -) -. -start_kind -( -dfa -: -: -StartKind -: -: -Anchored -) -. -match_kind -( -MatchKind -: -: -All -) -. -prefilter -( -None -) -. -specialize_start_states -( -false -) -) -. -build_from_nfa -( -& -nfarev -) -; -let -rev -= -match -result -{ -Ok -( -rev -) -= -> -rev -Err -( -_err -) -= -> -{ -debug -! -( -" -reverse -full -DFA -failed -to -build -: -{ -} -" -_err -) -; -return -None -; -} -} -; -let -engine -= -dfa -: -: -regex -: -: -Builder -: -: -new -( -) -. -build_from_dfas -( -fwd -rev -) -; -debug -! -( -" -fully -compiled -forward -and -reverse -DFAs -built -{ -} -bytes -" -engine -. -forward -( -) -. -memory_usage -( -) -+ -engine -. -reverse -( -) -. -memory_usage -( -) -) -; -Some -( -DFAEngine -( -engine -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -None -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -self -. -0 -. -try_search -( -input -) -. -map_err -( -| -e -| -e -. -into -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_fwd -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -use -crate -: -: -dfa -: -: -Automaton -; -self -. -0 -. -forward -( -) -. -try_search_fwd -( -input -) -. -map_err -( -| -e -| -e -. -into -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_fwd_stopat -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Result -< -HalfMatch -usize -> -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -let -dfa -= -self -. -0 -. -forward -( -) -; -crate -: -: -meta -: -: -stopat -: -: -dfa_try_search_half_fwd -( -dfa -input -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_rev -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -use -crate -: -: -dfa -: -: -Automaton -; -self -. -0 -. -reverse -( -) -. -try_search_rev -( -& -input -) -. -map_err -( -| -e -| -e -. -into -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_rev_limited -( -& -self -input -: -& -Input -< -' -_ -> -min_start -: -usize -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -let -dfa -= -self -. -0 -. -reverse -( -) -; -crate -: -: -meta -: -: -limited -: -: -dfa_try_search_half_rev -( -dfa -input -min_start -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -# -[ -inline -] -pub -( -crate -) -fn -try_which_overlapping_matches -( -& -self -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -- -> -Result -< -( -) -RetryFailError -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -use -crate -: -: -dfa -: -: -Automaton -; -self -. -0 -. -forward -( -) -. -try_which_overlapping_matches -( -input -patset -) -. -map_err -( -| -e -| -e -. -into -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -self -. -0 -. -forward -( -) -. -memory_usage -( -) -+ -self -. -0 -. -reverse -( -) -. -memory_usage -( -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -ReverseHybrid -( -Option -< -ReverseHybridEngine -> -) -; -impl -ReverseHybrid -{ -pub -( -crate -) -fn -none -( -) -- -> -ReverseHybrid -{ -ReverseHybrid -( -None -) -} -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -nfarev -: -& -NFA -) -- -> -ReverseHybrid -{ -ReverseHybrid -( -ReverseHybridEngine -: -: -new -( -info -nfarev -) -) -} -pub -( -crate -) -fn -create_cache -( -& -self -) -- -> -ReverseHybridCache -{ -ReverseHybridCache -: -: -new -( -self -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -get -( -& -self -_input -: -& -Input -< -' -_ -> -) -- -> -Option -< -& -ReverseHybridEngine -> -{ -let -engine -= -self -. -0 -. -as_ref -( -) -? -; -Some -( -engine -) -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -ReverseHybridEngine -( -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -hybrid -: -: -dfa -: -: -DFA -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -( -) -) -; -impl -ReverseHybridEngine -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -nfarev -: -& -NFA -) -- -> -Option -< -ReverseHybridEngine -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -if -! -info -. -config -( -) -. -get_hybrid -( -) -{ -return -None -; -} -/ -/ -Since -we -only -use -this -for -reverse -searches -we -can -hard -- -code -/ -/ -a -number -of -things -like -match -semantics -prefilters -starts -/ -/ -for -each -pattern -and -so -on -. -let -dfa_config -= -hybrid -: -: -dfa -: -: -Config -: -: -new -( -) -. -match_kind -( -MatchKind -: -: -All -) -. -prefilter -( -None -) -. -starts_for_each_pattern -( -false -) -. -byte_classes -( -info -. -config -( -) -. -get_byte_classes -( -) -) -. -unicode_word_boundary -( -true -) -. -specialize_start_states -( -false -) -. -cache_capacity -( -info -. -config -( -) -. -get_hybrid_cache_capacity -( -) -) -. -skip_cache_capacity_check -( -false -) -. -minimum_cache_clear_count -( -Some -( -3 -) -) -. -minimum_bytes_per_state -( -Some -( -10 -) -) -; -let -result -= -hybrid -: -: -dfa -: -: -Builder -: -: -new -( -) -. -configure -( -dfa_config -) -. -build_from_nfa -( -nfarev -. -clone -( -) -) -; -let -rev -= -match -result -{ -Ok -( -rev -) -= -> -rev -Err -( -_err -) -= -> -{ -debug -! -( -" -lazy -reverse -DFA -failed -to -build -: -{ -} -" -_err -) -; -return -None -; -} -} -; -debug -! -( -" -lazy -reverse -DFA -built -" -) -; -Some -( -ReverseHybridEngine -( -rev -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -None -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_rev_limited -( -& -self -cache -: -& -mut -ReverseHybridCache -input -: -& -Input -< -' -_ -> -min_start -: -usize -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -let -dfa -= -& -self -. -0 -; -let -mut -cache -= -cache -. -0 -. -as_mut -( -) -. -unwrap -( -) -; -crate -: -: -meta -: -: -limited -: -: -hybrid_try_search_half_rev -( -dfa -& -mut -cache -input -min_start -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -ReverseHybridCache -( -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -Option -< -hybrid -: -: -dfa -: -: -Cache -> -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -( -) -) -; -impl -ReverseHybridCache -{ -pub -( -crate -) -fn -none -( -) -- -> -ReverseHybridCache -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -ReverseHybridCache -( -None -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -ReverseHybridCache -( -( -) -) -} -} -pub -( -crate -) -fn -new -( -builder -: -& -ReverseHybrid -) -- -> -ReverseHybridCache -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -ReverseHybridCache -( -builder -. -0 -. -as_ref -( -) -. -map -( -| -e -| -e -. -0 -. -create_cache -( -) -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -ReverseHybridCache -( -( -) -) -} -} -pub -( -crate -) -fn -reset -( -& -mut -self -builder -: -& -ReverseHybrid -) -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -if -let -Some -( -ref -e -) -= -builder -. -0 -{ -self -. -0 -. -as_mut -( -) -. -unwrap -( -) -. -reset -( -& -e -. -0 -) -; -} -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -{ -self -. -0 -. -as_ref -( -) -. -map_or -( -0 -| -c -| -c -. -memory_usage -( -) -) -} -# -[ -cfg -( -not -( -feature -= -" -hybrid -" -) -) -] -{ -0 -} -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -ReverseDFA -( -Option -< -ReverseDFAEngine -> -) -; -impl -ReverseDFA -{ -pub -( -crate -) -fn -none -( -) -- -> -ReverseDFA -{ -ReverseDFA -( -None -) -} -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -nfarev -: -& -NFA -) -- -> -ReverseDFA -{ -ReverseDFA -( -ReverseDFAEngine -: -: -new -( -info -nfarev -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -get -( -& -self -_input -: -& -Input -< -' -_ -> -) -- -> -Option -< -& -ReverseDFAEngine -> -{ -let -engine -= -self -. -0 -. -as_ref -( -) -? -; -Some -( -engine -) -} -pub -( -crate -) -fn -is_some -( -& -self -) -- -> -bool -{ -self -. -0 -. -is_some -( -) -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -0 -. -as_ref -( -) -. -map_or -( -0 -| -e -| -e -. -memory_usage -( -) -) -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -ReverseDFAEngine -( -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -dfa -: -: -dense -: -: -DFA -< -Vec -< -u32 -> -> -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -( -) -) -; -impl -ReverseDFAEngine -{ -pub -( -crate -) -fn -new -( -info -: -& -RegexInfo -nfarev -: -& -NFA -) -- -> -Option -< -ReverseDFAEngine -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -if -! -info -. -config -( -) -. -get_dfa -( -) -{ -return -None -; -} -/ -/ -If -our -NFA -is -anything -but -small -don -' -t -even -bother -with -a -DFA -. -if -let -Some -( -state_limit -) -= -info -. -config -( -) -. -get_dfa_state_limit -( -) -{ -if -nfarev -. -states -( -) -. -len -( -) -> -state_limit -{ -debug -! -( -" -skipping -full -reverse -DFA -because -NFA -has -{ -} -states -\ -which -exceeds -the -heuristic -limit -of -{ -} -" -nfarev -. -states -( -) -. -len -( -) -state_limit -) -; -return -None -; -} -} -/ -/ -We -cut -the -size -limit -in -two -because -the -total -heap -used -by -DFA -/ -/ -construction -is -determinization -aux -memory -and -the -DFA -itself -/ -/ -and -those -things -are -configured -independently -in -the -lower -level -/ -/ -DFA -builder -API -. -let -size_limit -= -info -. -config -( -) -. -get_dfa_size_limit -( -) -. -map -( -| -n -| -n -/ -2 -) -; -/ -/ -Since -we -only -use -this -for -reverse -searches -we -can -hard -- -code -/ -/ -a -number -of -things -like -match -semantics -prefilters -starts -/ -/ -for -each -pattern -and -so -on -. -We -also -disable -acceleration -since -/ -/ -it -' -s -incompatible -with -limited -searches -( -which -is -the -only -/ -/ -operation -we -support -for -this -kind -of -engine -at -the -moment -) -. -let -dfa_config -= -dfa -: -: -dense -: -: -Config -: -: -new -( -) -. -match_kind -( -MatchKind -: -: -All -) -. -prefilter -( -None -) -. -accelerate -( -false -) -. -start_kind -( -dfa -: -: -StartKind -: -: -Anchored -) -. -starts_for_each_pattern -( -false -) -. -byte_classes -( -info -. -config -( -) -. -get_byte_classes -( -) -) -. -unicode_word_boundary -( -true -) -. -specialize_start_states -( -false -) -. -determinize_size_limit -( -size_limit -) -. -dfa_size_limit -( -size_limit -) -; -let -result -= -dfa -: -: -dense -: -: -Builder -: -: -new -( -) -. -configure -( -dfa_config -) -. -build_from_nfa -( -& -nfarev -) -; -let -rev -= -match -result -{ -Ok -( -rev -) -= -> -rev -Err -( -_err -) -= -> -{ -debug -! -( -" -full -reverse -DFA -failed -to -build -: -{ -} -" -_err -) -; -return -None -; -} -} -; -debug -! -( -" -fully -compiled -reverse -DFA -built -{ -} -bytes -" -rev -. -memory_usage -( -) -) -; -Some -( -ReverseDFAEngine -( -rev -) -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -None -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -try_search_half_rev_limited -( -& -self -input -: -& -Input -< -' -_ -> -min_start -: -usize -) -- -> -Result -< -Option -< -HalfMatch -> -RetryError -> -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -let -dfa -= -& -self -. -0 -; -crate -: -: -meta -: -: -limited -: -: -dfa_try_search_half_rev -( -dfa -input -min_start -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -feature -= -" -dfa -- -build -" -) -] -{ -self -. -0 -. -memory_usage -( -) -} -# -[ -cfg -( -not -( -feature -= -" -dfa -- -build -" -) -) -] -{ -/ -/ -Impossible -to -reach -because -this -engine -is -never -constructed -/ -/ -if -the -requisite -features -aren -' -t -enabled -. -unreachable -! -( -) -} -} -} diff --git a/third_party/rust/regex-automata/src/nfa/mod.rs b/third_party/rust/regex-automata/src/nfa/mod.rs deleted file mode 100644 index 7facd6d844ad1..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/mod.rs +++ /dev/null @@ -1,625 +0,0 @@ -/ -* -! -Provides -non -- -deterministic -finite -automata -( -NFA -) -and -regex -engines -that -use -them -. -While -NFAs -and -DFAs -( -deterministic -finite -automata -) -have -equivalent -* -theoretical -* -power -their -usage -in -practice -tends -to -result -in -different -engineering -trade -offs -. -While -this -isn -' -t -meant -to -be -a -comprehensive -treatment -of -the -topic -here -are -a -few -key -trade -offs -that -are -at -minimum -true -for -this -crate -: -* -NFAs -tend -to -be -represented -sparsely -where -as -DFAs -are -represented -densely -. -Sparse -representations -use -less -memory -but -are -slower -to -traverse -. -Conversely -dense -representations -use -more -memory -but -are -faster -to -traverse -. -( -Sometimes -these -lines -are -blurred -. -For -example -an -NFA -might -choose -to -represent -a -particular -state -in -a -dense -fashion -and -a -DFA -can -be -built -using -a -sparse -representation -via -[ -sparse -: -: -DFA -] -( -crate -: -: -dfa -: -: -sparse -: -: -DFA -) -. -* -NFAs -have -espilon -transitions -and -DFAs -don -' -t -. -In -practice -this -means -that -handling -a -single -byte -in -a -haystack -with -an -NFA -at -search -time -may -require -visiting -multiple -NFA -states -. -In -a -DFA -each -byte -only -requires -visiting -a -single -state -. -Stated -differently -NFAs -require -a -variable -number -of -CPU -instructions -to -process -one -byte -in -a -haystack -where -as -a -DFA -uses -a -constant -number -of -CPU -instructions -to -process -one -byte -. -* -NFAs -are -generally -easier -to -amend -with -secondary -storage -. -For -example -the -[ -thompson -: -: -pikevm -: -: -PikeVM -] -uses -an -NFA -to -match -but -also -uses -additional -memory -beyond -the -model -of -a -finite -state -machine -to -track -offsets -for -matching -capturing -groups -. -Conversely -the -most -a -DFA -can -do -is -report -the -offset -( -and -pattern -ID -) -at -which -a -match -occurred -. -This -is -generally -why -we -also -compile -DFAs -in -reverse -so -that -we -can -run -them -after -finding -the -end -of -a -match -to -also -find -the -start -of -a -match -. -* -NFAs -take -worst -case -linear -time -to -build -but -DFAs -take -worst -case -exponential -time -to -build -. -The -[ -hybrid -NFA -/ -DFA -] -( -crate -: -: -hybrid -) -mitigates -this -challenge -for -DFAs -in -many -practical -cases -. -There -are -likely -other -differences -but -the -bottom -line -is -that -NFAs -tend -to -be -more -memory -efficient -and -give -easier -opportunities -for -increasing -expressive -power -where -as -DFAs -are -faster -to -search -with -. -# -Why -only -a -Thompson -NFA -? -Currently -the -only -kind -of -NFA -we -support -in -this -crate -is -a -[ -Thompson -NFA -] -( -https -: -/ -/ -en -. -wikipedia -. -org -/ -wiki -/ -Thompson -% -27s_construction -) -. -This -refers -to -a -specific -construction -algorithm -that -takes -the -syntax -of -a -regex -pattern -and -converts -it -to -an -NFA -. -Specifically -it -makes -gratuitous -use -of -epsilon -transitions -in -order -to -keep -its -structure -simple -. -In -exchange -its -construction -time -is -linear -in -the -size -of -the -regex -. -A -Thompson -NFA -also -makes -the -guarantee -that -given -any -state -and -a -character -in -a -haystack -there -is -at -most -one -transition -defined -for -it -. -( -Although -there -may -be -many -epsilon -transitions -. -) -It -possible -that -other -types -of -NFAs -will -be -added -in -the -future -such -as -a -[ -Glushkov -NFA -] -( -https -: -/ -/ -en -. -wikipedia -. -org -/ -wiki -/ -Glushkov -% -27s_construction_algorithm -) -. -But -currently -this -crate -only -provides -a -Thompson -NFA -. -* -/ -# -[ -cfg -( -feature -= -" -nfa -- -thompson -" -) -] -pub -mod -thompson -; diff --git a/third_party/rust/regex-automata/src/nfa/thompson/backtrack.rs b/third_party/rust/regex-automata/src/nfa/thompson/backtrack.rs deleted file mode 100644 index 618ff45a1b38e..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/backtrack.rs +++ /dev/null @@ -1,18951 +0,0 @@ -/ -* -! -An -NFA -backed -bounded -backtracker -for -executing -regex -searches -with -capturing -groups -. -This -module -provides -a -[ -BoundedBacktracker -] -that -works -by -simulating -an -NFA -using -the -classical -backtracking -algorithm -with -a -twist -: -it -avoids -redoing -work -that -it -has -done -before -and -thereby -avoids -worst -case -exponential -time -. -In -exchange -it -can -only -be -used -on -" -short -" -haystacks -. -Its -advantage -is -that -is -can -be -faster -than -the -[ -PikeVM -] -( -thompson -: -: -pikevm -: -: -PikeVM -) -in -many -cases -because -it -does -less -book -- -keeping -. -* -/ -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -{ -self -BuildError -State -NFA -} -util -: -: -{ -captures -: -: -Captures -empty -iter -prefilter -: -: -Prefilter -primitives -: -: -{ -NonMaxUsize -PatternID -SmallIndex -StateID -} -search -: -: -{ -Anchored -HalfMatch -Input -Match -MatchError -Span -} -} -} -; -/ -/ -/ -Returns -the -minimum -visited -capacity -for -the -given -haystack -. -/ -/ -/ -/ -/ -/ -This -function -can -be -used -as -the -argument -to -[ -Config -: -: -visited_capacity -] -/ -/ -/ -in -order -to -guarantee -that -a -backtracking -search -for -the -given -input -/ -/ -/ -won -' -t -return -an -error -when -using -a -[ -BoundedBacktracker -] -built -from -the -/ -/ -/ -given -NFA -. -/ -/ -/ -/ -/ -/ -This -routine -exists -primarily -as -a -way -to -test -that -the -bounded -backtracker -/ -/ -/ -works -correctly -when -its -capacity -is -set -to -the -smallest -possible -amount -. -/ -/ -/ -Still -it -may -be -useful -in -cases -where -you -know -you -want -to -use -the -bounded -/ -/ -/ -backtracker -for -a -specific -input -and -just -need -to -know -what -visited -/ -/ -/ -capacity -to -provide -to -make -it -work -. -/ -/ -/ -/ -/ -/ -Be -warned -that -this -number -could -be -quite -large -as -it -is -multiplicative -in -/ -/ -/ -the -size -the -given -NFA -and -haystack -. -pub -fn -min_visited_capacity -( -nfa -: -& -NFA -input -: -& -Input -< -' -_ -> -) -- -> -usize -{ -div_ceil -( -nfa -. -states -( -) -. -len -( -) -* -( -input -. -get_span -( -) -. -len -( -) -+ -1 -) -8 -) -} -/ -/ -/ -The -configuration -used -for -building -a -bounded -backtracker -. -/ -/ -/ -/ -/ -/ -A -bounded -backtracker -configuration -is -a -simple -data -object -that -is -/ -/ -/ -typically -used -with -[ -Builder -: -: -configure -] -. -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -Config -{ -pre -: -Option -< -Option -< -Prefilter -> -> -visited_capacity -: -Option -< -usize -> -} -impl -Config -{ -/ -/ -/ -Return -a -new -default -regex -configuration -. -pub -fn -new -( -) -- -> -Config -{ -Config -: -: -default -( -) -} -/ -/ -/ -Set -a -prefilter -to -be -used -whenever -a -start -state -is -entered -. -/ -/ -/ -/ -/ -/ -A -[ -Prefilter -] -in -this -context -is -meant -to -accelerate -searches -by -/ -/ -/ -looking -for -literal -prefixes -that -every -match -for -the -corresponding -/ -/ -/ -pattern -( -or -patterns -) -must -start -with -. -Once -a -prefilter -produces -a -/ -/ -/ -match -the -underlying -search -routine -continues -on -to -try -and -confirm -/ -/ -/ -the -match -. -/ -/ -/ -/ -/ -/ -Be -warned -that -setting -a -prefilter -does -not -guarantee -that -the -search -/ -/ -/ -will -be -faster -. -While -it -' -s -usually -a -good -bet -if -the -prefilter -/ -/ -/ -produces -a -lot -of -false -positive -candidates -( -i -. -e -. -positions -matched -/ -/ -/ -by -the -prefilter -but -not -by -the -regex -) -then -the -overall -result -can -/ -/ -/ -be -slower -than -if -you -had -just -executed -the -regex -engine -without -any -/ -/ -/ -prefilters -. -/ -/ -/ -/ -/ -/ -By -default -no -prefilter -is -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Input -Match -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -configure -( -BoundedBacktracker -: -: -config -( -) -. -prefilter -( -pre -) -) -/ -/ -/ -. -build -( -r -" -( -foo -| -bar -) -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo1 -barfox -bar -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -5 -. -. -11 -) -) -/ -/ -/ -re -. -try_find -( -& -mut -cache -input -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Be -warned -though -that -an -incorrect -prefilter -can -lead -to -incorrect -/ -/ -/ -results -! -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Input -HalfMatch -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -foo -" -" -car -" -] -) -; -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -configure -( -BoundedBacktracker -: -: -config -( -) -. -prefilter -( -pre -) -) -/ -/ -/ -. -build -( -r -" -( -foo -| -bar -) -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo1 -barfox -bar -" -) -; -/ -/ -/ -/ -/ -No -match -reported -even -though -there -clearly -is -one -! -/ -/ -/ -assert_eq -! -( -None -re -. -try_find -( -& -mut -cache -input -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -prefilter -( -mut -self -pre -: -Option -< -Prefilter -> -) -- -> -Config -{ -self -. -pre -= -Some -( -pre -) -; -self -} -/ -/ -/ -Set -the -visited -capacity -used -to -bound -backtracking -. -/ -/ -/ -/ -/ -/ -The -visited -capacity -represents -the -amount -of -heap -memory -( -in -bytes -) -to -/ -/ -/ -allocate -toward -tracking -which -parts -of -the -backtracking -search -have -/ -/ -/ -been -done -before -. -The -heap -memory -needed -for -any -particular -search -is -/ -/ -/ -proportional -to -haystack -. -len -( -) -* -nfa -. -states -( -) -. -len -( -) -which -an -be -/ -/ -/ -quite -large -. -Therefore -the -bounded -backtracker -is -typically -only -able -/ -/ -/ -to -run -on -shorter -haystacks -. -/ -/ -/ -/ -/ -/ -For -a -given -regex -increasing -the -visited -capacity -means -that -the -/ -/ -/ -maximum -haystack -length -that -can -be -searched -is -increased -. -The -/ -/ -/ -[ -BoundedBacktracker -: -: -max_haystack_len -] -method -returns -that -maximum -. -/ -/ -/ -/ -/ -/ -The -default -capacity -is -a -reasonable -but -empirically -chosen -size -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -As -with -other -regex -engines -Unicode -is -what -tends -to -make -the -bounded -/ -/ -/ -backtracker -less -useful -by -making -the -maximum -haystack -length -quite -/ -/ -/ -small -. -If -necessary -increasing -the -visited -capacity -using -this -routine -/ -/ -/ -will -increase -the -maximum -haystack -length -at -the -cost -of -using -more -/ -/ -/ -memory -. -/ -/ -/ -/ -/ -/ -Note -though -that -the -specific -maximum -values -here -are -not -an -API -/ -/ -/ -guarantee -. -The -default -visited -capacity -is -subject -to -change -and -not -/ -/ -/ -covered -by -semver -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -; -/ -/ -/ -/ -/ -/ -/ -/ -Unicode -inflates -the -size -of -the -underlying -NFA -quite -a -bit -and -/ -/ -/ -/ -/ -thus -means -that -the -backtracker -can -only -handle -smaller -haystacks -/ -/ -/ -/ -/ -assuming -that -the -visited -capacity -remains -unchanged -. -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -r -" -\ -w -+ -" -) -? -; -/ -/ -/ -assert -! -( -re -. -max_haystack_len -( -) -< -= -7_000 -) -; -/ -/ -/ -/ -/ -But -we -can -increase -the -visited -capacity -to -handle -bigger -haystacks -! -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -configure -( -BoundedBacktracker -: -: -config -( -) -. -visited_capacity -( -1 -< -< -20 -) -) -/ -/ -/ -. -build -( -r -" -\ -w -+ -" -) -? -; -/ -/ -/ -assert -! -( -re -. -max_haystack_len -( -) -> -= -25_000 -) -; -/ -/ -/ -assert -! -( -re -. -max_haystack_len -( -) -< -= -28_000 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -visited_capacity -( -mut -self -capacity -: -usize -) -- -> -Config -{ -self -. -visited_capacity -= -Some -( -capacity -) -; -self -} -/ -/ -/ -Returns -the -prefilter -set -in -this -configuration -if -one -at -all -. -pub -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -self -. -pre -. -as_ref -( -) -. -unwrap_or -( -& -None -) -. -as_ref -( -) -} -/ -/ -/ -Returns -the -configured -visited -capacity -. -/ -/ -/ -/ -/ -/ -Note -that -the -actual -capacity -used -may -be -slightly -bigger -than -the -/ -/ -/ -configured -capacity -. -pub -fn -get_visited_capacity -( -& -self -) -- -> -usize -{ -const -DEFAULT -: -usize -= -256 -* -( -1 -< -< -10 -) -; -/ -/ -256 -KB -self -. -visited_capacity -. -unwrap_or -( -DEFAULT -) -} -/ -/ -/ -Overwrite -the -default -configuration -such -that -the -options -in -o -are -/ -/ -/ -always -used -. -If -an -option -in -o -is -not -set -then -the -corresponding -/ -/ -/ -option -in -self -is -used -. -If -it -' -s -not -set -in -self -either -then -it -/ -/ -/ -remains -not -set -. -pub -( -crate -) -fn -overwrite -( -& -self -o -: -Config -) -- -> -Config -{ -Config -{ -pre -: -o -. -pre -. -or_else -( -| -| -self -. -pre -. -clone -( -) -) -visited_capacity -: -o -. -visited_capacity -. -or -( -self -. -visited_capacity -) -} -} -} -/ -/ -/ -A -builder -for -a -bounded -backtracker -. -/ -/ -/ -/ -/ -/ -This -builder -permits -configuring -options -for -the -syntax -of -a -pattern -the -/ -/ -/ -NFA -construction -and -the -BoundedBacktracker -construction -. -This -builder -/ -/ -/ -is -different -from -a -general -purpose -regex -builder -in -that -it -permits -fine -/ -/ -/ -grain -configuration -of -the -construction -process -. -The -trade -off -for -this -is -/ -/ -/ -complexity -and -the -possibility -of -setting -a -configuration -that -might -not -/ -/ -/ -make -sense -. -For -example -there -are -two -different -UTF -- -8 -modes -: -/ -/ -/ -/ -/ -/ -* -[ -syntax -: -: -Config -: -: -utf8 -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -utf8 -) -controls -/ -/ -/ -whether -the -pattern -itself -can -contain -sub -- -expressions -that -match -invalid -/ -/ -/ -UTF -- -8 -. -/ -/ -/ -* -[ -thompson -: -: -Config -: -: -utf8 -] -controls -how -the -regex -iterators -themselves -/ -/ -/ -advance -the -starting -position -of -the -next -search -when -a -match -with -zero -/ -/ -/ -length -is -found -. -/ -/ -/ -/ -/ -/ -Generally -speaking -callers -will -want -to -either -enable -all -of -these -or -/ -/ -/ -disable -all -of -these -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -disable -UTF -- -8 -mode -in -the -syntax -and -the -regex -/ -/ -/ -itself -. -This -is -generally -what -you -want -for -matching -on -arbitrary -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -backtrack -: -: -BoundedBacktracker -} -/ -/ -/ -util -: -: -syntax -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Ok -( -Match -: -: -must -( -0 -1 -. -. -9 -) -) -) -; -/ -/ -/ -let -got -= -re -. -try_find_iter -( -& -mut -cache -haystack -) -. -next -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -Notice -that -( -? -- -u -: -[ -^ -b -] -) -matches -invalid -UTF -- -8 -/ -/ -/ -/ -/ -but -the -subsequent -. -* -does -not -! -Disabling -UTF -- -8 -/ -/ -/ -/ -/ -on -the -syntax -permits -this -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -This -example -does -not -show -the -impact -of -/ -/ -/ -/ -/ -disabling -UTF -- -8 -mode -on -a -BoundedBacktracker -Config -since -that -/ -/ -/ -/ -/ -only -impacts -regexes -that -can -produce -matches -of -/ -/ -/ -/ -/ -length -0 -. -/ -/ -/ -assert_eq -! -( -b -" -foo -\ -xFFarzz -" -& -haystack -[ -got -. -unwrap -( -) -? -. -range -( -) -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Builder -{ -config -: -Config -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -} -impl -Builder -{ -/ -/ -/ -Create -a -new -BoundedBacktracker -builder -with -its -default -configuration -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -{ -config -: -Config -: -: -default -( -) -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -: -: -new -( -) -} -} -/ -/ -/ -Build -a -BoundedBacktracker -from -the -given -pattern -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -or -compiling -the -pattern -then -an -error -/ -/ -/ -is -returned -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Build -a -BoundedBacktracker -from -the -given -patterns -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -let -nfa -= -self -. -thompson -. -build_many -( -patterns -) -? -; -self -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Build -a -BoundedBacktracker -directly -from -its -NFA -. -/ -/ -/ -/ -/ -/ -Note -that -when -using -this -method -any -configuration -that -applies -to -the -/ -/ -/ -construction -of -the -NFA -itself -will -of -course -be -ignored -since -the -NFA -/ -/ -/ -given -here -is -already -built -. -pub -fn -build_from_nfa -( -& -self -nfa -: -NFA -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -nfa -. -look_set_any -( -) -. -available -( -) -. -map_err -( -BuildError -: -: -word -) -? -; -Ok -( -BoundedBacktracker -{ -config -: -self -. -config -. -clone -( -) -nfa -} -) -} -/ -/ -/ -Apply -the -given -BoundedBacktracker -configuration -options -to -this -/ -/ -/ -builder -. -pub -fn -configure -( -& -mut -self -config -: -Config -) -- -> -& -mut -Builder -{ -self -. -config -= -self -. -config -. -overwrite -( -config -) -; -self -} -/ -/ -/ -Set -the -syntax -configuration -for -this -builder -using -/ -/ -/ -[ -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -case -insensitivity -Unicode -and -multi -/ -/ -/ -line -mode -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -BoundedBacktracker -/ -/ -/ -directly -from -a -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -syntax -( -config -) -; -self -} -/ -/ -/ -Set -the -Thompson -NFA -configuration -for -this -builder -using -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -if -additional -time -should -be -spent -/ -/ -/ -shrinking -the -size -of -the -NFA -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -BoundedBacktracker -/ -/ -/ -directly -from -a -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -thompson -( -& -mut -self -config -: -thompson -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -configure -( -config -) -; -self -} -} -/ -/ -/ -A -backtracking -regex -engine -that -bounds -its -execution -to -avoid -exponential -/ -/ -/ -blow -- -up -. -/ -/ -/ -/ -/ -/ -This -regex -engine -only -implements -leftmost -- -first -match -semantics -and -/ -/ -/ -only -supports -leftmost -searches -. -It -effectively -does -the -same -thing -as -a -/ -/ -/ -[ -PikeVM -] -( -thompson -: -: -pikevm -: -: -PikeVM -) -but -typically -does -it -faster -because -/ -/ -/ -it -doesn -' -t -have -to -worry -about -copying -capturing -group -spans -for -most -NFA -/ -/ -/ -states -. -Instead -the -backtracker -can -maintain -one -set -of -captures -( -provided -/ -/ -/ -by -the -caller -) -and -never -needs -to -copy -them -. -In -exchange -the -backtracker -/ -/ -/ -bounds -itself -to -ensure -it -doesn -' -t -exhibit -worst -case -exponential -time -. -/ -/ -/ -This -results -in -the -backtracker -only -being -able -to -handle -short -haystacks -/ -/ -/ -given -reasonable -memory -usage -. -/ -/ -/ -/ -/ -/ -# -Searches -may -return -an -error -! -/ -/ -/ -/ -/ -/ -By -design -this -backtracking -regex -engine -is -bounded -. -This -bound -is -/ -/ -/ -implemented -by -not -visiting -any -combination -of -NFA -state -ID -and -position -/ -/ -/ -in -a -haystack -more -than -once -. -Thus -the -total -memory -required -to -bound -/ -/ -/ -backtracking -is -proportional -to -haystack -. -len -( -) -* -nfa -. -states -( -) -. -len -( -) -. -/ -/ -/ -This -can -obviously -get -quite -large -since -large -haystacks -aren -' -t -terribly -/ -/ -/ -uncommon -. -To -avoid -using -exorbitant -memory -the -capacity -is -bounded -by -/ -/ -/ -a -fixed -limit -set -via -[ -Config -: -: -visited_capacity -] -. -Thus -if -the -total -/ -/ -/ -capacity -required -for -a -particular -regex -and -a -haystack -exceeds -this -/ -/ -/ -capacity -then -the -search -routine -will -return -an -error -. -/ -/ -/ -/ -/ -/ -Unlike -other -regex -engines -that -may -return -an -error -at -search -time -( -like -/ -/ -/ -the -DFA -or -the -hybrid -NFA -/ -DFA -) -there -is -no -way -to -guarantee -that -a -bounded -/ -/ -/ -backtracker -will -work -for -every -haystack -. -Therefore -this -regex -engine -/ -/ -/ -_only_ -exposes -fallible -search -routines -to -avoid -the -footgun -of -panicking -/ -/ -/ -when -running -a -search -on -a -haystack -that -is -too -big -. -/ -/ -/ -/ -/ -/ -If -one -wants -to -use -the -fallible -search -APIs -without -handling -the -/ -/ -/ -error -the -only -way -to -guarantee -an -error -won -' -t -occur -from -the -/ -/ -/ -haystack -length -is -to -ensure -the -haystack -length -does -not -exceed -/ -/ -/ -[ -BoundedBacktracker -: -: -max_haystack_len -] -. -/ -/ -/ -/ -/ -/ -# -Example -: -Unicode -word -boundaries -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -bounded -backtracker -implements -Unicode -word -/ -/ -/ -boundaries -correctly -by -default -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -r -" -\ -b -\ -w -+ -\ -b -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -re -. -try_find_iter -( -& -mut -cache -" -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -12 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -13 -. -. -23 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -multiple -regex -patterns -/ -/ -/ -/ -/ -/ -The -bounded -backtracker -supports -searching -for -multiple -patterns -/ -/ -/ -simultaneously -just -like -other -regex -engines -. -Note -though -that -because -it -/ -/ -/ -uses -a -backtracking -strategy -this -regex -engine -is -unlikely -to -scale -well -/ -/ -/ -as -more -patterns -are -added -. -But -then -again -as -more -patterns -are -added -the -/ -/ -/ -maximum -haystack -length -allowed -will -also -shorten -( -assuming -the -visited -/ -/ -/ -capacity -remains -invariant -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new_many -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -re -. -try_find_iter -( -& -mut -cache -" -abc -1 -foo -4567 -0 -quux -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -1 -4 -. -. -5 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -6 -. -. -9 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -1 -10 -. -. -14 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -1 -15 -. -. -16 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -17 -. -. -21 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -BoundedBacktracker -{ -config -: -Config -nfa -: -NFA -} -impl -BoundedBacktracker -{ -/ -/ -/ -Parse -the -given -regular -expression -using -the -default -configuration -and -/ -/ -/ -return -the -corresponding -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -[ -Builder -] -to -/ -/ -/ -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Ok -( -Match -: -: -must -( -0 -3 -. -. -14 -) -) -) -/ -/ -/ -re -. -try_find_iter -( -& -mut -cache -" -zzzfoo12345barzzz -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -BoundedBacktracker -: -: -builder -( -) -. -build -( -pattern -) -} -/ -/ -/ -Like -new -but -parses -multiple -patterns -into -a -single -" -multi -regex -. -" -/ -/ -/ -This -similarly -uses -the -default -regex -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new_many -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -re -. -try_find_iter -( -& -mut -cache -" -abc -1 -foo -4567 -0 -quux -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -1 -4 -. -. -5 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -6 -. -. -9 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -1 -10 -. -. -14 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -1 -15 -. -. -16 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -17 -. -. -21 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -BoundedBacktracker -: -: -builder -( -) -. -build_many -( -patterns -) -} -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -hand -assemble -a -regular -expression -via -its -HIR -/ -/ -/ -compile -an -NFA -from -it -and -build -a -BoundedBacktracker -from -the -NFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -NFA -backtrack -: -: -BoundedBacktracker -} -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -{ -Hir -Class -ClassBytes -ClassBytesRange -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new -( -vec -! -[ -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -0 -' -b -' -9 -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -A -' -b -' -Z -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -_ -' -b -' -_ -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -a -' -b -' -z -' -) -/ -/ -/ -] -) -) -) -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_from_hir -( -& -hir -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -3 -. -. -4 -) -) -; -/ -/ -/ -re -. -try_captures -( -& -mut -cache -" -! -# -A -# -! -" -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new_from_nfa -( -nfa -: -NFA -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -BoundedBacktracker -: -: -builder -( -) -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Create -a -new -BoundedBacktracker -that -matches -every -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -always_match -( -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -0 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -re -. -try_find_iter -( -& -mut -cache -" -" -) -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -expected -re -. -try_find_iter -( -& -mut -cache -" -foo -" -) -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -always_match -( -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -always_match -( -) -; -BoundedBacktracker -: -: -new_from_nfa -( -nfa -) -} -/ -/ -/ -Create -a -new -BoundedBacktracker -that -never -matches -any -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -never_match -( -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -None -re -. -try_find_iter -( -& -mut -cache -" -" -) -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -try_find_iter -( -& -mut -cache -" -foo -" -) -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -never_match -( -) -- -> -Result -< -BoundedBacktracker -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -never_match -( -) -; -BoundedBacktracker -: -: -new_from_nfa -( -nfa -) -} -/ -/ -/ -Return -a -default -configuration -for -a -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -Config -/ -/ -/ -type -when -customizing -the -construction -of -a -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -disable -UTF -- -8 -mode -. -When -UTF -- -8 -mode -is -/ -/ -/ -disabled -zero -- -width -matches -that -split -a -codepoint -are -allowed -. -/ -/ -/ -Otherwise -they -are -never -reported -. -/ -/ -/ -/ -/ -/ -In -the -code -below -notice -that -" -" -is -permitted -to -match -positions -/ -/ -/ -that -split -the -encoding -of -a -codepoint -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -backtrack -: -: -BoundedBacktracker -} -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -a -z -" -; -/ -/ -/ -let -mut -it -= -re -. -try_find_iter -( -& -mut -cache -haystack -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -0 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -1 -. -. -1 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -2 -. -. -2 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -3 -. -. -3 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -4 -. -. -4 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Ok -( -Match -: -: -must -( -0 -5 -. -. -5 -) -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -config -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -/ -/ -/ -Return -a -builder -for -configuring -the -construction -of -a -/ -/ -/ -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Builder -] -type -in -common -cases -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -the -builder -to -disable -UTF -- -8 -mode -/ -/ -/ -everywhere -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -backtrack -: -: -BoundedBacktracker -} -/ -/ -/ -util -: -: -syntax -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -1 -. -. -9 -) -) -; -/ -/ -/ -re -. -try_captures -( -& -mut -cache -haystack -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -/ -/ -/ -Create -a -new -cache -for -this -regex -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -this -/ -/ -/ -regex -. -If -you -want -to -reuse -the -cache -for -another -regex -then -you -/ -/ -/ -must -call -[ -Cache -: -: -reset -] -with -that -regex -( -or -equivalently -/ -/ -/ -[ -BoundedBacktracker -: -: -reset_cache -] -) -. -pub -fn -create_cache -( -& -self -) -- -> -Cache -{ -Cache -: -: -new -( -self -) -} -/ -/ -/ -Create -a -new -empty -set -of -capturing -groups -that -is -guaranteed -to -be -/ -/ -/ -valid -for -the -search -APIs -on -this -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -A -Captures -value -created -for -a -specific -BoundedBacktracker -cannot -/ -/ -/ -be -used -with -any -other -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -function -for -[ -Captures -: -: -all -] -. -See -the -/ -/ -/ -[ -Captures -] -documentation -for -an -explanation -of -its -alternative -/ -/ -/ -constructors -that -permit -the -BoundedBacktracker -to -do -less -work -/ -/ -/ -during -a -search -and -thus -might -make -it -faster -. -pub -fn -create_captures -( -& -self -) -- -> -Captures -{ -Captures -: -: -all -( -self -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -} -/ -/ -/ -Reset -the -given -cache -such -that -it -can -be -used -for -searching -with -the -/ -/ -/ -this -BoundedBacktracker -( -and -only -this -BoundedBacktracker -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -/ -/ -/ -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -BoundedBacktracker -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -BoundedBacktracker -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -) -/ -/ -/ -re1 -. -try_find_iter -( -& -mut -cache -" -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -BoundedBacktracker -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -cache -. -reset -( -& -re2 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -) -/ -/ -/ -re2 -. -try_find_iter -( -& -mut -cache -" -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -cache -. -reset -( -self -) -; -} -/ -/ -/ -Returns -the -total -number -of -patterns -compiled -into -this -/ -/ -/ -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -In -the -case -of -a -BoundedBacktracker -that -contains -no -patterns -this -/ -/ -/ -returns -0 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -pattern -length -for -a -BoundedBacktracker -that -/ -/ -/ -never -matches -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -never_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -re -. -pattern_len -( -) -0 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -another -example -for -a -BoundedBacktracker -that -matches -at -every -/ -/ -/ -position -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -always_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -re -. -pattern_len -( -) -1 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -finally -a -BoundedBacktracker -that -was -constructed -from -multiple -/ -/ -/ -patterns -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -re -. -pattern_len -( -) -3 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -nfa -. -pattern_len -( -) -} -/ -/ -/ -Return -the -config -for -this -BoundedBacktracker -. -# -[ -inline -] -pub -fn -get_config -( -& -self -) -- -> -& -Config -{ -& -self -. -config -} -/ -/ -/ -Returns -a -reference -to -the -underlying -NFA -. -# -[ -inline -] -pub -fn -get_nfa -( -& -self -) -- -> -& -NFA -{ -& -self -. -nfa -} -/ -/ -/ -Returns -the -maximum -haystack -length -supported -by -this -backtracker -. -/ -/ -/ -/ -/ -/ -This -routine -is -a -function -of -both -[ -Config -: -: -visited_capacity -] -and -the -/ -/ -/ -internal -size -of -the -backtracker -' -s -NFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -the -maximum -haystack -length -can -vary -depending -/ -/ -/ -on -the -size -of -the -regex -itself -. -Note -though -that -the -specific -maximum -/ -/ -/ -values -here -are -not -an -API -guarantee -. -The -default -visited -capacity -is -/ -/ -/ -subject -to -change -and -not -covered -by -semver -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -MatchError -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -If -you -' -re -only -using -ASCII -you -get -a -big -budget -. -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -r -" -( -? -- -u -) -\ -w -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -re -. -max_haystack_len -( -) -299_592 -) -; -/ -/ -/ -/ -/ -Things -work -up -to -the -max -. -/ -/ -/ -let -mut -haystack -= -" -a -" -. -repeat -( -299_592 -) -; -/ -/ -/ -let -expected -= -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -299_592 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -re -. -try_find_iter -( -& -mut -cache -& -haystack -) -. -next -( -) -) -; -/ -/ -/ -/ -/ -But -you -' -ll -get -an -error -if -you -provide -a -haystack -that -' -s -too -big -. -/ -/ -/ -/ -/ -Notice -that -we -use -the -' -try_find_iter -' -routine -instead -which -/ -/ -/ -/ -/ -yields -Result -< -Match -MatchError -> -instead -of -Match -. -/ -/ -/ -haystack -. -push -( -' -a -' -) -; -/ -/ -/ -let -expected -= -Some -( -Err -( -MatchError -: -: -haystack_too_long -( -299_593 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -re -. -try_find_iter -( -& -mut -cache -& -haystack -) -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Unicode -inflates -the -size -of -the -underlying -NFA -quite -a -bit -and -/ -/ -/ -/ -/ -thus -means -that -the -backtracker -can -only -handle -smaller -haystacks -/ -/ -/ -/ -/ -assuming -that -the -visited -capacity -remains -unchanged -. -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -r -" -\ -w -+ -" -) -? -; -/ -/ -/ -assert -! -( -re -. -max_haystack_len -( -) -< -= -7_000 -) -; -/ -/ -/ -/ -/ -But -we -can -increase -the -visited -capacity -to -handle -bigger -haystacks -! -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -configure -( -BoundedBacktracker -: -: -config -( -) -. -visited_capacity -( -1 -< -< -20 -) -) -/ -/ -/ -. -build -( -r -" -\ -w -+ -" -) -? -; -/ -/ -/ -assert -! -( -re -. -max_haystack_len -( -) -> -= -25_000 -) -; -/ -/ -/ -assert -! -( -re -. -max_haystack_len -( -) -< -= -28_000 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -max_haystack_len -( -& -self -) -- -> -usize -{ -/ -/ -The -capacity -given -in -the -config -is -" -bytes -of -heap -memory -" -but -the -/ -/ -capacity -we -use -here -is -" -number -of -bits -. -" -So -convert -the -capacity -in -/ -/ -bytes -to -the -capacity -in -bits -. -let -capacity -= -8 -* -self -. -get_config -( -) -. -get_visited_capacity -( -) -; -let -blocks -= -div_ceil -( -capacity -Visited -: -: -BLOCK_SIZE -) -; -let -real_capacity -= -blocks -* -Visited -: -: -BLOCK_SIZE -; -( -real_capacity -/ -self -. -nfa -. -states -( -) -. -len -( -) -) -- -1 -} -} -impl -BoundedBacktracker -{ -/ -/ -/ -Returns -true -if -and -only -if -this -regex -matches -the -given -haystack -. -/ -/ -/ -/ -/ -/ -In -the -case -of -a -backtracking -regex -engine -and -unlike -most -other -/ -/ -/ -regex -engines -in -this -crate -short -circuiting -isn -' -t -practical -. -However -/ -/ -/ -this -routine -may -still -be -faster -because -it -instructs -backtracking -to -/ -/ -/ -not -keep -track -of -any -capturing -groups -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -only -errors -if -the -search -could -not -complete -. -For -this -/ -/ -/ -backtracking -regex -engine -this -only -occurs -when -the -haystack -length -/ -/ -/ -exceeds -[ -BoundedBacktracker -: -: -max_haystack_len -] -. -/ -/ -/ -/ -/ -/ -When -a -search -cannot -complete -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -try_is_match -( -& -mut -cache -" -foo12345bar -" -) -? -) -; -/ -/ -/ -assert -! -( -! -re -. -try_is_match -( -& -mut -cache -" -foobar -" -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -consistency -with -search -APIs -/ -/ -/ -/ -/ -/ -is_match -is -guaranteed -to -return -true -whenever -find -returns -a -/ -/ -/ -match -. -This -includes -searches -that -are -executed -entirely -within -a -/ -/ -/ -codepoint -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -" -a -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -! -re -. -try_is_match -( -& -mut -cache -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -when -UTF -- -8 -mode -is -disabled -then -the -above -reports -a -/ -/ -/ -match -because -the -restriction -against -zero -- -width -matches -that -split -a -/ -/ -/ -codepoint -has -been -lifted -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -backtrack -: -: -BoundedBacktracker -NFA -} -/ -/ -/ -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -" -a -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -try_is_match -( -& -mut -cache -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -? -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_is_match -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -) -- -> -Result -< -bool -MatchError -> -{ -let -input -= -input -. -into -( -) -. -earliest -( -true -) -; -self -. -try_search_slots -( -cache -& -input -& -mut -[ -] -) -. -map -( -| -pid -| -pid -. -is_some -( -) -) -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -returns -a -Match -if -one -exists -. -/ -/ -/ -/ -/ -/ -This -routine -only -includes -the -overall -match -span -. -To -get -/ -/ -/ -access -to -the -individual -spans -of -each -capturing -group -use -/ -/ -/ -[ -BoundedBacktracker -: -: -try_captures -] -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -only -errors -if -the -search -could -not -complete -. -For -this -/ -/ -/ -backtracking -regex -engine -this -only -occurs -when -the -haystack -length -/ -/ -/ -exceeds -[ -BoundedBacktracker -: -: -max_haystack_len -] -. -/ -/ -/ -/ -/ -/ -When -a -search -cannot -complete -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -Match -: -: -must -( -0 -0 -. -. -8 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -re -. -try_find -( -& -mut -cache -" -foo12345 -" -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_find -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -let -input -= -input -. -into -( -) -; -if -self -. -get_nfa -( -) -. -pattern_len -( -) -= -= -1 -{ -let -mut -slots -= -[ -None -None -] -; -let -pid -= -match -self -. -try_search_slots -( -cache -& -input -& -mut -slots -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -pid -) -= -> -pid -} -; -let -start -= -match -slots -[ -0 -] -{ -None -= -> -return -Ok -( -None -) -Some -( -s -) -= -> -s -. -get -( -) -} -; -let -end -= -match -slots -[ -1 -] -{ -None -= -> -return -Ok -( -None -) -Some -( -s -) -= -> -s -. -get -( -) -} -; -return -Ok -( -Some -( -Match -: -: -new -( -pid -Span -{ -start -end -} -) -) -) -; -} -let -ginfo -= -self -. -get_nfa -( -) -. -group_info -( -) -; -let -slots_len -= -ginfo -. -implicit_slot_len -( -) -; -let -mut -slots -= -vec -! -[ -None -; -slots_len -] -; -let -pid -= -match -self -. -try_search_slots -( -cache -& -input -& -mut -slots -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -pid -) -= -> -pid -} -; -let -start -= -match -slots -[ -pid -. -as_usize -( -) -* -2 -] -{ -None -= -> -return -Ok -( -None -) -Some -( -s -) -= -> -s -. -get -( -) -} -; -let -end -= -match -slots -[ -pid -. -as_usize -( -) -* -2 -+ -1 -] -{ -None -= -> -return -Ok -( -None -) -Some -( -s -) -= -> -s -. -get -( -) -} -; -Ok -( -Some -( -Match -: -: -new -( -pid -Span -{ -start -end -} -) -) -) -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -[ -Captures -] -/ -/ -/ -value -. -If -no -match -was -found -then -[ -Captures -: -: -is_match -] -is -guaranteed -/ -/ -/ -to -return -false -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -only -errors -if -the -search -could -not -complete -. -For -this -/ -/ -/ -backtracking -regex -engine -this -only -occurs -when -the -haystack -length -/ -/ -/ -exceeds -[ -BoundedBacktracker -: -: -max_haystack_len -] -. -/ -/ -/ -/ -/ -/ -When -a -search -cannot -complete -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -/ -/ -/ -r -" -^ -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -/ -/ -/ -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -try_captures -( -& -mut -cache -" -2010 -- -03 -- -14 -" -& -mut -caps -) -? -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -4 -) -) -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -5 -. -. -7 -) -) -caps -. -get_group -( -2 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -8 -. -. -10 -) -) -caps -. -get_group -( -3 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_captures -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -caps -: -& -mut -Captures -) -- -> -Result -< -( -) -MatchError -> -{ -self -. -try_search -( -cache -& -input -. -into -( -) -caps -) -} -/ -/ -/ -Returns -an -iterator -over -all -non -- -overlapping -leftmost -matches -in -the -/ -/ -/ -given -bytes -. -If -no -match -exists -then -the -iterator -yields -no -elements -. -/ -/ -/ -/ -/ -/ -If -the -regex -engine -returns -an -error -at -any -point -then -the -iterator -/ -/ -/ -will -yield -that -error -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -MatchError -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -text -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -let -result -: -Result -< -Vec -< -Match -> -MatchError -> -= -re -/ -/ -/ -. -try_find_iter -( -& -mut -cache -text -) -/ -/ -/ -. -collect -( -) -; -/ -/ -/ -let -matches -= -result -? -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -4 -) -/ -/ -/ -Match -: -: -must -( -0 -5 -. -. -10 -) -/ -/ -/ -Match -: -: -must -( -0 -11 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_find_iter -< -' -r -' -c -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -cache -: -& -' -c -mut -Cache -input -: -I -) -- -> -TryFindMatches -< -' -r -' -c -' -h -> -{ -let -caps -= -Captures -: -: -matches -( -self -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -; -let -it -= -iter -: -: -Searcher -: -: -new -( -input -. -into -( -) -) -; -TryFindMatches -{ -re -: -self -cache -caps -it -} -} -/ -/ -/ -Returns -an -iterator -over -all -non -- -overlapping -Captures -values -. -If -no -/ -/ -/ -match -exists -then -the -iterator -yields -no -elements -. -/ -/ -/ -/ -/ -/ -This -yields -the -same -matches -as -[ -BoundedBacktracker -: -: -try_find_iter -] -/ -/ -/ -but -it -includes -the -spans -of -all -capturing -groups -that -participate -in -/ -/ -/ -each -match -. -/ -/ -/ -/ -/ -/ -If -the -regex -engine -returns -an -error -at -any -point -then -the -iterator -/ -/ -/ -will -yield -that -error -. -/ -/ -/ -/ -/ -/ -* -* -Tip -: -* -* -See -[ -util -: -: -iter -: -: -Searcher -] -( -crate -: -: -util -: -: -iter -: -: -Searcher -) -for -/ -/ -/ -how -to -correctly -iterate -over -all -matches -in -a -haystack -while -avoiding -/ -/ -/ -the -creation -of -a -new -Captures -value -for -every -match -. -( -Which -you -are -/ -/ -/ -forced -to -do -with -an -Iterator -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -" -foo -( -? -P -< -numbers -> -[ -0 -- -9 -] -+ -) -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -text -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -let -mut -spans -= -vec -! -[ -] -; -/ -/ -/ -for -result -in -re -. -try_captures_iter -( -& -mut -cache -text -) -{ -/ -/ -/ -let -caps -= -result -? -; -/ -/ -/ -/ -/ -The -unwrap -is -OK -since -' -numbers -' -matches -if -the -pattern -matches -. -/ -/ -/ -spans -. -push -( -caps -. -get_group_by_name -( -" -numbers -" -) -. -unwrap -( -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -spans -vec -! -[ -/ -/ -/ -Span -: -: -from -( -3 -. -. -4 -) -/ -/ -/ -Span -: -: -from -( -8 -. -. -10 -) -/ -/ -/ -Span -: -: -from -( -14 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_captures_iter -< -' -r -' -c -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -cache -: -& -' -c -mut -Cache -input -: -I -) -- -> -TryCapturesMatches -< -' -r -' -c -' -h -> -{ -let -caps -= -self -. -create_captures -( -) -; -let -it -= -iter -: -: -Searcher -: -: -new -( -input -. -into -( -) -) -; -TryCapturesMatches -{ -re -: -self -cache -caps -it -} -} -} -impl -BoundedBacktracker -{ -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -[ -Captures -] -/ -/ -/ -value -. -If -no -match -was -found -then -[ -Captures -: -: -is_match -] -is -guaranteed -/ -/ -/ -to -return -false -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -BoundedBacktracker -: -: -try_captures -] -but -it -accepts -a -/ -/ -/ -concrete -& -Input -instead -of -an -Into -< -Input -> -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -only -errors -if -the -search -could -not -complete -. -For -this -/ -/ -/ -backtracking -regex -engine -this -only -occurs -when -the -haystack -length -/ -/ -/ -exceeds -[ -BoundedBacktracker -: -: -max_haystack_len -] -. -/ -/ -/ -/ -/ -/ -When -a -search -cannot -complete -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -: -specific -pattern -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -multi -bounded -backtracker -that -/ -/ -/ -permits -searching -for -specific -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Anchored -Input -Match -PatternID -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new_many -( -& -[ -/ -/ -/ -" -[ -a -- -z0 -- -9 -] -{ -6 -} -" -/ -/ -/ -" -[ -a -- -z -] -[ -a -- -z0 -- -9 -] -{ -5 -} -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -foo123 -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -are -using -the -default -leftmost -- -first -match -and -both -/ -/ -/ -/ -/ -patterns -match -at -the -same -starting -position -only -the -first -pattern -/ -/ -/ -/ -/ -will -be -returned -in -this -case -when -doing -a -search -for -any -of -the -/ -/ -/ -/ -/ -patterns -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -6 -) -) -; -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -want -to -check -whether -some -other -pattern -matches -then -we -/ -/ -/ -/ -/ -can -provide -its -pattern -ID -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -1 -0 -. -. -6 -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -input -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specifying -the -bounds -of -a -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -providing -the -bounds -of -a -search -can -produce -/ -/ -/ -different -results -than -simply -sub -- -slicing -the -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new -( -r -" -\ -b -[ -0 -- -9 -] -{ -3 -} -\ -b -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -sub -- -slice -the -haystack -the -search -doesn -' -t -know -about -/ -/ -/ -/ -/ -the -larger -context -and -assumes -that -123 -is -surrounded -by -word -/ -/ -/ -/ -/ -boundaries -. -And -of -course -the -match -position -is -reported -relative -/ -/ -/ -/ -/ -to -the -sub -- -slice -as -well -which -means -we -get -0 -. -. -3 -instead -of -/ -/ -/ -/ -/ -3 -. -. -6 -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -; -/ -/ -/ -re -. -try_search -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -[ -3 -. -. -6 -] -) -& -mut -caps -) -? -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -provide -the -bounds -of -the -search -within -the -context -of -the -/ -/ -/ -/ -/ -entire -haystack -then -the -search -can -take -the -surrounding -context -/ -/ -/ -/ -/ -into -account -. -( -And -if -we -did -find -a -match -it -would -be -reported -/ -/ -/ -/ -/ -as -a -valid -offset -into -haystack -instead -of -its -sub -- -slice -. -) -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -re -. -try_search -( -/ -/ -/ -& -mut -cache -& -Input -: -: -new -( -haystack -) -. -range -( -3 -. -. -6 -) -& -mut -caps -/ -/ -/ -) -? -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -caps -: -& -mut -Captures -) -- -> -Result -< -( -) -MatchError -> -{ -caps -. -set_pattern -( -None -) -; -let -pid -= -self -. -try_search_slots -( -cache -input -caps -. -slots_mut -( -) -) -? -; -caps -. -set_pattern -( -pid -) -; -Ok -( -( -) -) -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -slots -and -/ -/ -/ -returns -the -matching -pattern -ID -. -The -contents -of -the -slots -for -patterns -/ -/ -/ -other -than -the -matching -pattern -are -unspecified -. -If -no -match -was -found -/ -/ -/ -then -None -is -returned -and -the -contents -of -all -slots -is -unspecified -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -BoundedBacktracker -: -: -try_search -] -but -it -accepts -a -raw -/ -/ -/ -slots -slice -instead -of -a -Captures -value -. -This -is -useful -in -contexts -/ -/ -/ -where -you -don -' -t -want -or -need -to -allocate -a -Captures -. -/ -/ -/ -/ -/ -/ -It -is -legal -to -pass -_any_ -number -of -slots -to -this -routine -. -If -the -regex -/ -/ -/ -engine -would -otherwise -write -a -slot -offset -that -doesn -' -t -fit -in -the -/ -/ -/ -provided -slice -then -it -is -simply -skipped -. -In -general -though -there -are -/ -/ -/ -usually -three -slice -lengths -you -might -want -to -use -: -/ -/ -/ -/ -/ -/ -* -An -empty -slice -if -you -only -care -about -which -pattern -matched -. -/ -/ -/ -* -A -slice -with -/ -/ -/ -[ -pattern_len -( -) -* -2 -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -: -: -pattern_len -) -/ -/ -/ -slots -if -you -only -care -about -the -overall -match -spans -for -each -matching -/ -/ -/ -pattern -. -/ -/ -/ -* -A -slice -with -/ -/ -/ -[ -slot_len -( -) -] -( -crate -: -: -util -: -: -captures -: -: -GroupInfo -: -: -slot_len -) -slots -which -/ -/ -/ -permits -recording -match -offsets -for -every -capturing -group -in -every -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -routine -only -errors -if -the -search -could -not -complete -. -For -this -/ -/ -/ -backtracking -regex -engine -this -only -occurs -when -the -haystack -length -/ -/ -/ -exceeds -[ -BoundedBacktracker -: -: -max_haystack_len -] -. -/ -/ -/ -/ -/ -/ -When -a -search -cannot -complete -callers -cannot -know -whether -a -match -/ -/ -/ -exists -or -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -the -overall -match -offsets -in -a -/ -/ -/ -multi -- -pattern -search -without -allocating -a -Captures -value -. -Indeed -we -/ -/ -/ -can -put -our -slots -right -on -the -stack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -PatternID -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -new_many -( -& -[ -/ -/ -/ -r -" -\ -pL -+ -" -/ -/ -/ -r -" -\ -d -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -! -# -123 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -only -care -about -the -overall -match -offsets -here -so -we -just -/ -/ -/ -/ -/ -allocate -two -slots -for -each -pattern -. -Each -slot -records -the -start -/ -/ -/ -/ -/ -and -end -of -the -match -. -/ -/ -/ -let -mut -slots -= -[ -None -; -4 -] -; -/ -/ -/ -let -pid -= -re -. -try_search_slots -( -& -mut -cache -& -input -& -mut -slots -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -pid -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -overall -match -offsets -are -always -at -' -pid -* -2 -' -and -' -pid -* -2 -+ -1 -' -. -/ -/ -/ -/ -/ -See -' -GroupInfo -' -for -more -details -on -the -mapping -between -groups -and -/ -/ -/ -/ -/ -slot -indices -. -/ -/ -/ -let -slot_start -= -pid -. -unwrap -( -) -. -as_usize -( -) -* -2 -; -/ -/ -/ -let -slot_end -= -slot_start -+ -1 -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -slots -[ -slot_start -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -6 -) -slots -[ -slot_end -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -try_search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Result -< -Option -< -PatternID -> -MatchError -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -if -! -utf8empty -{ -let -maybe_hm -= -self -. -try_search_slots_imp -( -cache -input -slots -) -? -; -return -Ok -( -maybe_hm -. -map -( -| -hm -| -hm -. -pattern -( -) -) -) -; -} -/ -/ -See -PikeVM -: -: -try_search_slots -for -why -we -do -this -. -let -min -= -self -. -get_nfa -( -) -. -group_info -( -) -. -implicit_slot_len -( -) -; -if -slots -. -len -( -) -> -= -min -{ -let -maybe_hm -= -self -. -try_search_slots_imp -( -cache -input -slots -) -? -; -return -Ok -( -maybe_hm -. -map -( -| -hm -| -hm -. -pattern -( -) -) -) -; -} -if -self -. -get_nfa -( -) -. -pattern_len -( -) -= -= -1 -{ -let -mut -enough -= -[ -None -None -] -; -let -got -= -self -. -try_search_slots_imp -( -cache -input -& -mut -enough -) -? -; -/ -/ -This -is -OK -because -we -know -enough_slots -is -strictly -bigger -/ -/ -than -slots -otherwise -this -special -case -isn -' -t -reached -. -slots -. -copy_from_slice -( -& -enough -[ -. -. -slots -. -len -( -) -] -) -; -return -Ok -( -got -. -map -( -| -hm -| -hm -. -pattern -( -) -) -) -; -} -let -mut -enough -= -vec -! -[ -None -; -min -] -; -let -got -= -self -. -try_search_slots_imp -( -cache -input -& -mut -enough -) -? -; -/ -/ -This -is -OK -because -we -know -enough_slots -is -strictly -bigger -than -/ -/ -slots -otherwise -this -special -case -isn -' -t -reached -. -slots -. -copy_from_slice -( -& -enough -[ -. -. -slots -. -len -( -) -] -) -; -Ok -( -got -. -map -( -| -hm -| -hm -. -pattern -( -) -) -) -} -/ -/ -/ -This -is -the -actual -implementation -of -try_search_slots_imp -that -/ -/ -/ -doesn -' -t -account -for -the -special -case -when -1 -) -the -NFA -has -UTF -- -8 -mode -/ -/ -/ -enabled -2 -) -the -NFA -can -match -the -empty -string -and -3 -) -the -caller -has -/ -/ -/ -provided -an -insufficient -number -of -slots -to -record -match -offsets -. -# -[ -inline -( -never -) -] -fn -try_search_slots_imp -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -let -hm -= -match -self -. -search_imp -( -cache -input -slots -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -hm -) -if -! -utf8empty -= -> -return -Ok -( -Some -( -hm -) -) -Some -( -hm -) -= -> -hm -} -; -empty -: -: -skip_splits_fwd -( -input -hm -hm -. -offset -( -) -| -input -| -{ -Ok -( -self -. -search_imp -( -cache -input -slots -) -? -. -map -( -| -hm -| -( -hm -hm -. -offset -( -) -) -) -) -} -) -} -/ -/ -/ -The -implementation -of -standard -leftmost -backtracking -search -. -/ -/ -/ -/ -/ -/ -Capturing -group -spans -are -written -to -' -caps -' -but -only -if -requested -. -/ -/ -/ -' -caps -' -can -be -one -of -three -things -: -1 -) -totally -empty -in -which -case -we -/ -/ -/ -only -report -the -pattern -that -matched -or -2 -) -only -has -slots -for -recording -/ -/ -/ -the -overall -match -offsets -for -any -pattern -or -3 -) -has -all -slots -available -/ -/ -/ -for -recording -the -spans -of -any -groups -participating -in -a -match -. -fn -search_imp -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -/ -/ -Unlike -in -the -PikeVM -we -write -our -capturing -group -spans -directly -/ -/ -into -the -caller -' -s -captures -groups -. -So -we -have -to -make -sure -we -' -re -/ -/ -starting -with -a -blank -slate -first -. -In -the -PikeVM -we -avoid -this -/ -/ -by -construction -: -the -spans -that -are -copied -to -every -slot -in -the -/ -/ -' -Captures -' -value -already -account -for -presence -/ -absence -. -In -this -/ -/ -backtracker -we -write -directly -into -the -caller -provided -slots -where -/ -/ -as -in -the -PikeVM -we -write -into -scratch -space -first -and -only -copy -/ -/ -them -to -the -caller -provided -slots -when -a -match -is -found -. -for -slot -in -slots -. -iter_mut -( -) -{ -* -slot -= -None -; -} -cache -. -setup_search -( -& -self -input -) -? -; -if -input -. -is_done -( -) -{ -return -Ok -( -None -) -; -} -let -( -anchored -start_id -) -= -match -input -. -get_anchored -( -) -{ -/ -/ -Only -way -we -' -re -unanchored -is -if -both -the -caller -asked -for -an -/ -/ -unanchored -search -* -and -* -the -pattern -is -itself -not -anchored -. -Anchored -: -: -No -= -> -( -self -. -nfa -. -is_always_start_anchored -( -) -/ -/ -We -always -use -the -anchored -starting -state -here -even -if -/ -/ -doing -an -unanchored -search -. -The -" -unanchored -" -part -of -it -is -/ -/ -implemented -in -the -loop -below -by -simply -trying -the -next -/ -/ -byte -offset -if -the -previous -backtracking -exploration -failed -. -self -. -nfa -. -start_anchored -( -) -) -Anchored -: -: -Yes -= -> -( -true -self -. -nfa -. -start_anchored -( -) -) -Anchored -: -: -Pattern -( -pid -) -= -> -match -self -. -nfa -. -start_pattern -( -pid -) -{ -None -= -> -return -Ok -( -None -) -Some -( -sid -) -= -> -( -true -sid -) -} -} -; -if -anchored -{ -let -at -= -input -. -start -( -) -; -return -Ok -( -self -. -backtrack -( -cache -input -at -start_id -slots -) -) -; -} -let -pre -= -self -. -get_config -( -) -. -get_prefilter -( -) -; -let -mut -at -= -input -. -start -( -) -; -while -at -< -= -input -. -end -( -) -{ -if -let -Some -( -ref -pre -) -= -pre -{ -let -span -= -Span -: -: -from -( -at -. -. -input -. -end -( -) -) -; -match -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -break -Some -( -ref -span -) -= -> -at -= -span -. -start -} -} -if -let -Some -( -hm -) -= -self -. -backtrack -( -cache -input -at -start_id -slots -) -{ -return -Ok -( -Some -( -hm -) -) -; -} -at -+ -= -1 -; -} -Ok -( -None -) -} -/ -/ -/ -Look -for -a -match -starting -at -at -in -input -and -write -the -matching -/ -/ -/ -pattern -ID -and -group -spans -to -caps -. -The -search -uses -start_id -as -its -/ -/ -/ -starting -state -in -the -underlying -NFA -. -/ -/ -/ -/ -/ -/ -If -no -match -was -found -then -the -caller -should -increment -at -and -try -/ -/ -/ -at -the -next -position -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -backtrack -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -at -: -usize -start_id -: -StateID -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -HalfMatch -> -{ -cache -. -stack -. -push -( -Frame -: -: -Step -{ -sid -: -start_id -at -} -) -; -while -let -Some -( -frame -) -= -cache -. -stack -. -pop -( -) -{ -match -frame -{ -Frame -: -: -Step -{ -sid -at -} -= -> -{ -if -let -Some -( -hm -) -= -self -. -step -( -cache -input -sid -at -slots -) -{ -return -Some -( -hm -) -; -} -} -Frame -: -: -RestoreCapture -{ -slot -offset -} -= -> -{ -slots -[ -slot -] -= -offset -; -} -} -} -None -} -/ -/ -LAMENTATION -: -The -actual -backtracking -search -is -implemented -in -about -/ -/ -75 -lines -below -. -Yet -this -file -is -over -2 -000 -lines -long -. -What -have -I -/ -/ -done -? -/ -/ -/ -Execute -a -" -step -" -in -the -backtracing -algorithm -. -/ -/ -/ -/ -/ -/ -A -" -step -" -is -somewhat -of -a -misnomer -because -this -routine -keeps -going -/ -/ -/ -until -it -either -runs -out -of -things -to -try -or -fins -a -match -. -In -the -/ -/ -/ -former -case -it -may -have -pushed -some -things -on -to -the -backtracking -/ -/ -/ -stack -in -which -case -those -will -be -tried -next -as -part -of -the -/ -/ -/ -' -backtrack -' -routine -above -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -step -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -mut -sid -: -StateID -mut -at -: -usize -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -HalfMatch -> -{ -loop -{ -if -! -cache -. -visited -. -insert -( -sid -at -- -input -. -start -( -) -) -{ -return -None -; -} -match -* -self -. -nfa -. -state -( -sid -) -{ -State -: -: -ByteRange -{ -ref -trans -} -= -> -{ -/ -/ -Why -do -we -need -this -? -Unlike -other -regex -engines -in -this -/ -/ -crate -the -backtracker -can -steam -roll -ahead -in -the -/ -/ -haystack -outside -of -the -main -loop -over -the -bytes -in -the -/ -/ -haystack -. -While -' -trans -. -matches -( -) -' -below -handles -the -case -/ -/ -of -' -at -' -being -out -of -bounds -of -' -input -. -haystack -( -) -' -we -/ -/ -also -need -to -handle -the -case -of -' -at -' -going -out -of -bounds -/ -/ -of -the -span -the -caller -asked -to -search -. -/ -/ -/ -/ -We -should -perhaps -make -the -' -trans -. -matches -( -) -' -API -accept -/ -/ -an -' -& -Input -' -instead -of -a -' -& -[ -u8 -] -' -. -Or -at -least -add -a -new -/ -/ -API -that -does -it -. -if -at -> -= -input -. -end -( -) -{ -return -None -; -} -if -! -trans -. -matches -( -input -. -haystack -( -) -at -) -{ -return -None -; -} -sid -= -trans -. -next -; -at -+ -= -1 -; -} -State -: -: -Sparse -( -ref -sparse -) -= -> -{ -if -at -> -= -input -. -end -( -) -{ -return -None -; -} -sid -= -sparse -. -matches -( -input -. -haystack -( -) -at -) -? -; -at -+ -= -1 -; -} -State -: -: -Dense -( -ref -dense -) -= -> -{ -if -at -> -= -input -. -end -( -) -{ -return -None -; -} -sid -= -dense -. -matches -( -input -. -haystack -( -) -at -) -? -; -at -+ -= -1 -; -} -State -: -: -Look -{ -look -next -} -= -> -{ -/ -/ -OK -because -we -don -' -t -permit -building -a -searcher -with -a -/ -/ -Unicode -word -boundary -if -the -requisite -Unicode -data -is -/ -/ -unavailable -. -if -! -self -. -nfa -. -look_matcher -( -) -. -matches_inline -( -look -input -. -haystack -( -) -at -) -{ -return -None -; -} -sid -= -next -; -} -State -: -: -Union -{ -ref -alternates -} -= -> -{ -sid -= -match -alternates -. -get -( -0 -) -{ -None -= -> -return -None -Some -( -& -sid -) -= -> -sid -} -; -cache -. -stack -. -extend -( -alternates -[ -1 -. -. -] -. -iter -( -) -. -copied -( -) -. -rev -( -) -. -map -( -| -sid -| -Frame -: -: -Step -{ -sid -at -} -) -) -; -} -State -: -: -BinaryUnion -{ -alt1 -alt2 -} -= -> -{ -sid -= -alt1 -; -cache -. -stack -. -push -( -Frame -: -: -Step -{ -sid -: -alt2 -at -} -) -; -} -State -: -: -Capture -{ -next -slot -. -. -} -= -> -{ -if -slot -. -as_usize -( -) -< -slots -. -len -( -) -{ -cache -. -stack -. -push -( -Frame -: -: -RestoreCapture -{ -slot -offset -: -slots -[ -slot -] -} -) -; -slots -[ -slot -] -= -NonMaxUsize -: -: -new -( -at -) -; -} -sid -= -next -; -} -State -: -: -Fail -= -> -return -None -State -: -: -Match -{ -pattern_id -} -= -> -{ -return -Some -( -HalfMatch -: -: -new -( -pattern_id -at -) -) -; -} -} -} -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -for -a -fallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -Result -< -Match -MatchError -value -until -no -more -/ -/ -/ -matches -could -be -found -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -BoundedBacktracker -. -/ -/ -/ -* -' -c -represents -the -lifetime -of -the -BoundedBacktracker -' -s -cache -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -BoundedBacktracker -: -: -try_find_iter -] -/ -/ -/ -method -. -# -[ -derive -( -Debug -) -] -pub -struct -TryFindMatches -< -' -r -' -c -' -h -> -{ -re -: -& -' -r -BoundedBacktracker -cache -: -& -' -c -mut -Cache -caps -: -Captures -it -: -iter -: -: -Searcher -< -' -h -> -} -impl -< -' -r -' -c -' -h -> -Iterator -for -TryFindMatches -< -' -r -' -c -' -h -> -{ -type -Item -= -Result -< -Match -MatchError -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Result -< -Match -MatchError -> -> -{ -/ -/ -Splitting -' -self -' -apart -seems -necessary -to -appease -borrowck -. -let -TryFindMatches -{ -re -ref -mut -cache -ref -mut -caps -ref -mut -it -} -= -* -self -; -it -. -try_advance -( -| -input -| -{ -re -. -try_search -( -cache -input -caps -) -? -; -Ok -( -caps -. -get_match -( -) -) -} -) -. -transpose -( -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -leftmost -matches -with -their -capturing -/ -/ -/ -groups -for -a -fallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -Result -< -Captures -MatchError -> -value -until -no -more -/ -/ -/ -matches -could -be -found -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -BoundedBacktracker -. -/ -/ -/ -* -' -c -represents -the -lifetime -of -the -BoundedBacktracker -' -s -cache -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -/ -/ -/ -[ -BoundedBacktracker -: -: -try_captures_iter -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -TryCapturesMatches -< -' -r -' -c -' -h -> -{ -re -: -& -' -r -BoundedBacktracker -cache -: -& -' -c -mut -Cache -caps -: -Captures -it -: -iter -: -: -Searcher -< -' -h -> -} -impl -< -' -r -' -c -' -h -> -Iterator -for -TryCapturesMatches -< -' -r -' -c -' -h -> -{ -type -Item -= -Result -< -Captures -MatchError -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Result -< -Captures -MatchError -> -> -{ -/ -/ -Splitting -' -self -' -apart -seems -necessary -to -appease -borrowck -. -let -TryCapturesMatches -{ -re -ref -mut -cache -ref -mut -caps -ref -mut -it -} -= -* -self -; -let -_ -= -it -. -try_advance -( -| -input -| -{ -re -. -try_search -( -cache -input -caps -) -? -; -Ok -( -caps -. -get_match -( -) -) -} -) -. -transpose -( -) -? -; -if -caps -. -is_match -( -) -{ -Some -( -Ok -( -caps -. -clone -( -) -) -) -} -else -{ -None -} -} -} -/ -/ -/ -A -cache -represents -mutable -state -that -a -[ -BoundedBacktracker -] -requires -/ -/ -/ -during -a -search -. -/ -/ -/ -/ -/ -/ -For -a -given -[ -BoundedBacktracker -] -its -corresponding -cache -may -be -created -/ -/ -/ -either -via -[ -BoundedBacktracker -: -: -create_cache -] -or -via -[ -Cache -: -: -new -] -. -/ -/ -/ -They -are -equivalent -in -every -way -except -the -former -does -not -require -/ -/ -/ -explicitly -importing -Cache -. -/ -/ -/ -/ -/ -/ -A -particular -Cache -is -coupled -with -the -[ -BoundedBacktracker -] -from -which -/ -/ -/ -it -was -created -. -It -may -only -be -used -with -that -BoundedBacktracker -. -A -cache -/ -/ -/ -and -its -allocations -may -be -re -- -purposed -via -[ -Cache -: -: -reset -] -in -which -case -/ -/ -/ -it -can -only -be -used -with -the -new -BoundedBacktracker -( -and -not -the -old -/ -/ -/ -one -) -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Cache -{ -/ -/ -/ -Stack -used -on -the -heap -for -doing -backtracking -instead -of -the -/ -/ -/ -traditional -recursive -approach -. -We -don -' -t -want -recursion -because -then -/ -/ -/ -we -' -re -likely -to -hit -a -stack -overflow -for -bigger -regexes -. -stack -: -Vec -< -Frame -> -/ -/ -/ -The -set -of -( -StateID -HaystackOffset -) -pairs -that -have -been -visited -/ -/ -/ -by -the -backtracker -within -a -single -search -. -If -such -a -pair -has -been -/ -/ -/ -visited -then -we -avoid -doing -the -work -for -that -pair -again -. -This -is -/ -/ -/ -what -" -bounds -" -the -backtracking -and -prevents -it -from -having -worst -case -/ -/ -/ -exponential -time -. -visited -: -Visited -} -impl -Cache -{ -/ -/ -/ -Create -a -new -[ -BoundedBacktracker -] -cache -. -/ -/ -/ -/ -/ -/ -A -potentially -more -convenient -routine -to -create -a -cache -is -/ -/ -/ -[ -BoundedBacktracker -: -: -create_cache -] -as -it -does -not -require -also -/ -/ -/ -importing -the -Cache -type -. -/ -/ -/ -/ -/ -/ -If -you -want -to -reuse -the -returned -Cache -with -some -other -/ -/ -/ -BoundedBacktracker -then -you -must -call -[ -Cache -: -: -reset -] -with -the -/ -/ -/ -desired -BoundedBacktracker -. -pub -fn -new -( -re -: -& -BoundedBacktracker -) -- -> -Cache -{ -Cache -{ -stack -: -vec -! -[ -] -visited -: -Visited -: -: -new -( -re -) -} -} -/ -/ -/ -Reset -this -cache -such -that -it -can -be -used -for -searching -with -different -/ -/ -/ -[ -BoundedBacktracker -] -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -/ -/ -/ -BoundedBacktracker -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -BoundedBacktracker -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -BoundedBacktracker -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -) -/ -/ -/ -re1 -. -try_find_iter -( -& -mut -cache -" -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -BoundedBacktracker -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -cache -. -reset -( -& -re2 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -) -/ -/ -/ -re2 -. -try_find_iter -( -& -mut -cache -" -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset -( -& -mut -self -re -: -& -BoundedBacktracker -) -{ -self -. -visited -. -reset -( -re -) -; -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -of -this -cache -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -cache -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -Cache -> -( -) -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -stack -. -len -( -) -* -core -: -: -mem -: -: -size_of -: -: -< -Frame -> -( -) -+ -self -. -visited -. -memory_usage -( -) -} -/ -/ -/ -Clears -this -cache -. -This -should -be -called -at -the -start -of -every -search -/ -/ -/ -to -ensure -we -start -with -a -clean -slate -. -/ -/ -/ -/ -/ -/ -This -also -sets -the -length -of -the -capturing -groups -used -in -the -current -/ -/ -/ -search -. -This -permits -an -optimization -where -by -' -SlotTable -: -: -for_state -' -/ -/ -/ -only -returns -the -number -of -slots -equivalent -to -the -number -of -slots -/ -/ -/ -given -in -the -' -Captures -' -value -. -This -may -be -less -than -the -total -number -/ -/ -/ -of -possible -slots -e -. -g -. -when -one -only -wants -to -track -overall -match -/ -/ -/ -offsets -. -This -in -turn -permits -less -copying -of -capturing -group -spans -/ -/ -/ -in -the -BoundedBacktracker -. -fn -setup_search -( -& -mut -self -re -: -& -BoundedBacktracker -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -( -) -MatchError -> -{ -self -. -stack -. -clear -( -) -; -self -. -visited -. -setup_search -( -re -input -) -? -; -Ok -( -( -) -) -} -} -/ -/ -/ -Represents -a -stack -frame -on -the -heap -while -doing -backtracking -. -/ -/ -/ -/ -/ -/ -Instead -of -using -explicit -recursion -for -backtracking -we -use -a -stack -on -/ -/ -/ -the -heap -to -keep -track -of -things -that -we -want -to -explore -if -the -current -/ -/ -/ -backtracking -branch -turns -out -to -not -lead -to -a -match -. -# -[ -derive -( -Clone -Debug -) -] -enum -Frame -{ -/ -/ -/ -Look -for -a -match -starting -at -sid -and -the -given -position -in -the -/ -/ -/ -haystack -. -Step -{ -sid -: -StateID -at -: -usize -} -/ -/ -/ -Reset -the -given -slot -to -the -given -offset -( -which -might -be -None -) -. -/ -/ -/ -This -effectively -gives -a -" -scope -" -to -capturing -groups -such -that -an -/ -/ -/ -offset -for -a -particular -group -only -gets -returned -if -the -match -goes -/ -/ -/ -through -that -capturing -group -. -If -backtracking -ends -up -going -down -a -/ -/ -/ -different -branch -that -results -in -a -different -offset -( -or -perhaps -none -at -/ -/ -/ -all -) -then -this -" -restore -capture -" -frame -will -cause -the -offset -to -get -/ -/ -/ -reset -. -RestoreCapture -{ -slot -: -SmallIndex -offset -: -Option -< -NonMaxUsize -> -} -} -/ -/ -/ -A -bitset -that -keeps -track -of -whether -a -particular -( -StateID -offset -) -has -/ -/ -/ -been -considered -during -backtracking -. -If -it -has -already -been -visited -then -/ -/ -/ -backtracking -skips -it -. -This -is -what -gives -backtracking -its -" -bound -. -" -# -[ -derive -( -Clone -Debug -) -] -struct -Visited -{ -/ -/ -/ -The -actual -underlying -bitset -. -Each -element -in -the -bitset -corresponds -/ -/ -/ -to -a -particular -( -StateID -offset -) -pair -. -States -correspond -to -the -rows -/ -/ -/ -and -the -offsets -correspond -to -the -columns -. -/ -/ -/ -/ -/ -/ -If -our -underlying -NFA -has -N -states -and -the -haystack -we -' -re -searching -/ -/ -/ -has -M -bytes -then -we -have -N -* -( -M -+ -1 -) -entries -in -our -bitset -table -. -The -/ -/ -/ -M -+ -1 -occurs -because -our -matches -are -delayed -by -one -byte -( -to -support -/ -/ -/ -look -- -around -) -and -so -we -need -to -handle -the -end -position -itself -rather -/ -/ -/ -than -stopping -just -before -the -end -. -( -If -there -is -no -end -position -then -/ -/ -/ -it -' -s -treated -as -" -end -- -of -- -input -" -which -is -matched -by -things -like -' -' -. -) -/ -/ -/ -/ -/ -/ -Given -BITS -= -N -* -( -M -+ -1 -) -we -wind -up -with -div_ceil -( -BITS -sizeof -( -usize -) -) -/ -/ -/ -blocks -. -/ -/ -/ -/ -/ -/ -We -use -' -usize -' -to -represent -our -blocks -because -it -makes -some -of -the -/ -/ -/ -arithmetic -in -' -insert -' -a -bit -nicer -. -For -example -if -we -used -' -u32 -' -for -/ -/ -/ -our -block -we -' -d -either -need -to -cast -u32s -to -usizes -or -usizes -to -u32s -. -bitset -: -Vec -< -usize -> -/ -/ -/ -The -stride -represents -one -plus -length -of -the -haystack -we -' -re -searching -/ -/ -/ -( -as -described -above -) -. -The -stride -must -be -initialized -for -each -search -. -stride -: -usize -} -impl -Visited -{ -/ -/ -/ -The -size -of -each -block -in -bits -. -const -BLOCK_SIZE -: -usize -= -8 -* -core -: -: -mem -: -: -size_of -: -: -< -usize -> -( -) -; -/ -/ -/ -Create -a -new -visited -set -for -the -given -backtracker -. -/ -/ -/ -/ -/ -/ -The -set -is -ready -to -use -but -must -be -setup -at -the -beginning -of -each -/ -/ -/ -search -by -calling -setup_search -. -fn -new -( -re -: -& -BoundedBacktracker -) -- -> -Visited -{ -let -mut -visited -= -Visited -{ -bitset -: -vec -! -[ -] -stride -: -0 -} -; -visited -. -reset -( -re -) -; -visited -} -/ -/ -/ -Insert -the -given -( -StateID -offset -) -pair -into -this -set -. -If -it -already -/ -/ -/ -exists -then -this -is -a -no -- -op -and -it -returns -false -. -Otherwise -this -/ -/ -/ -returns -true -. -fn -insert -( -& -mut -self -sid -: -StateID -at -: -usize -) -- -> -bool -{ -let -table_index -= -sid -. -as_usize -( -) -* -self -. -stride -+ -at -; -let -block_index -= -table_index -/ -Visited -: -: -BLOCK_SIZE -; -let -bit -= -table_index -% -Visited -: -: -BLOCK_SIZE -; -let -block_with_bit -= -1 -< -< -bit -; -if -self -. -bitset -[ -block_index -] -& -block_with_bit -! -= -0 -{ -return -false -; -} -self -. -bitset -[ -block_index -] -| -= -block_with_bit -; -true -} -/ -/ -/ -Reset -this -visited -set -to -work -with -the -given -bounded -backtracker -. -fn -reset -( -& -mut -self -_ -: -& -BoundedBacktracker -) -{ -self -. -bitset -. -truncate -( -0 -) -; -} -/ -/ -/ -Setup -this -visited -set -to -work -for -a -search -using -the -given -NFA -/ -/ -/ -and -input -configuration -. -The -NFA -must -be -the -same -NFA -used -by -the -/ -/ -/ -BoundedBacktracker -given -to -Visited -: -: -reset -. -Failing -to -call -this -might -/ -/ -/ -result -in -panics -or -silently -incorrect -search -behavior -. -fn -setup_search -( -& -mut -self -re -: -& -BoundedBacktracker -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -( -) -MatchError -> -{ -/ -/ -Our -haystack -length -is -only -the -length -of -the -span -of -the -entire -/ -/ -haystack -that -we -' -ll -be -searching -. -let -haylen -= -input -. -get_span -( -) -. -len -( -) -; -let -err -= -| -| -MatchError -: -: -haystack_too_long -( -haylen -) -; -/ -/ -Our -stride -is -one -more -than -the -length -of -the -input -because -our -main -/ -/ -search -loop -includes -the -position -at -input -. -end -( -) -. -( -And -it -does -this -/ -/ -because -matches -are -delayed -by -one -byte -to -account -for -look -- -around -. -) -self -. -stride -= -haylen -+ -1 -; -let -needed_capacity -= -match -re -. -get_nfa -( -) -. -states -( -) -. -len -( -) -. -checked_mul -( -self -. -stride -) -{ -None -= -> -return -Err -( -err -( -) -) -Some -( -capacity -) -= -> -capacity -} -; -let -max_capacity -= -8 -* -re -. -get_config -( -) -. -get_visited_capacity -( -) -; -if -needed_capacity -> -max_capacity -{ -return -Err -( -err -( -) -) -; -} -let -needed_blocks -= -div_ceil -( -needed_capacity -Visited -: -: -BLOCK_SIZE -) -; -self -. -bitset -. -truncate -( -needed_blocks -) -; -for -block -in -self -. -bitset -. -iter_mut -( -) -{ -* -block -= -0 -; -} -if -needed_blocks -> -self -. -bitset -. -len -( -) -{ -self -. -bitset -. -resize -( -needed_blocks -0 -) -; -} -Ok -( -( -) -) -} -/ -/ -/ -Return -the -heap -memory -usage -in -bytes -of -this -visited -set -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -bitset -. -len -( -) -* -core -: -: -mem -: -: -size_of -: -: -< -usize -> -( -) -} -} -/ -/ -/ -Integer -division -but -rounds -up -instead -of -down -. -fn -div_ceil -( -lhs -: -usize -rhs -: -usize -) -- -> -usize -{ -if -lhs -% -rhs -= -= -0 -{ -lhs -/ -rhs -} -else -{ -( -lhs -/ -rhs -) -+ -1 -} -} diff --git a/third_party/rust/regex-automata/src/nfa/thompson/builder.rs b/third_party/rust/regex-automata/src/nfa/thompson/builder.rs deleted file mode 100644 index ca634e7961e57..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/builder.rs +++ /dev/null @@ -1,13618 +0,0 @@ -use -core -: -: -mem -; -use -alloc -: -: -{ -sync -: -: -Arc -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -{ -error -: -: -BuildError -nfa -: -: -{ -self -SparseTransitions -Transition -NFA -} -} -util -: -: -{ -look -: -: -{ -Look -LookMatcher -} -primitives -: -: -{ -IteratorIndexExt -PatternID -SmallIndex -StateID -} -} -} -; -/ -/ -/ -An -intermediate -NFA -state -used -during -construction -. -/ -/ -/ -/ -/ -/ -During -construction -of -an -NFA -it -is -often -convenient -to -work -with -states -/ -/ -/ -that -are -amenable -to -mutation -and -other -carry -more -information -than -we -/ -/ -/ -otherwise -need -once -an -NFA -has -been -built -. -This -type -represents -those -/ -/ -/ -needs -. -/ -/ -/ -/ -/ -/ -Once -construction -is -finished -the -builder -will -convert -these -states -to -a -/ -/ -/ -[ -nfa -: -: -thompson -: -: -State -] -( -crate -: -: -nfa -: -: -thompson -: -: -State -) -. -This -conversion -not -/ -/ -/ -only -results -in -a -simpler -representation -but -in -some -cases -entire -classes -/ -/ -/ -of -states -are -completely -removed -( -such -as -[ -State -: -: -Empty -] -) -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -enum -State -{ -/ -/ -/ -An -empty -state -whose -only -purpose -is -to -forward -the -automaton -to -/ -/ -/ -another -state -via -an -unconditional -epsilon -transition -. -/ -/ -/ -/ -/ -/ -Unconditional -epsilon -transitions -are -quite -useful -during -the -/ -/ -/ -construction -of -an -NFA -as -they -permit -the -insertion -of -no -- -op -/ -/ -/ -placeholders -that -make -it -easier -to -compose -NFA -sub -- -graphs -. -When -/ -/ -/ -the -Thompson -NFA -builder -produces -a -final -NFA -all -unconditional -/ -/ -/ -epsilon -transitions -are -removed -and -state -identifiers -are -remapped -/ -/ -/ -accordingly -. -Empty -{ -/ -/ -/ -The -next -state -that -this -state -should -transition -to -. -next -: -StateID -} -/ -/ -/ -A -state -that -only -transitions -to -another -state -if -the -current -input -/ -/ -/ -byte -is -in -a -particular -range -of -bytes -. -ByteRange -{ -trans -: -Transition -} -/ -/ -/ -A -state -with -possibly -many -transitions -represented -in -a -sparse -/ -/ -/ -fashion -. -Transitions -must -be -ordered -lexicographically -by -input -range -/ -/ -/ -and -be -non -- -overlapping -. -As -such -this -may -only -be -used -when -every -/ -/ -/ -transition -has -equal -priority -. -( -In -practice -this -is -only -used -for -/ -/ -/ -encoding -large -UTF -- -8 -automata -. -) -In -contrast -a -Union -state -has -each -/ -/ -/ -alternate -in -order -of -priority -. -Priority -is -used -to -implement -greedy -/ -/ -/ -matching -and -also -alternations -themselves -e -. -g -. -abc -| -a -where -abc -/ -/ -/ -has -priority -over -a -. -/ -/ -/ -/ -/ -/ -To -clarify -it -is -possible -to -remove -Sparse -and -represent -all -things -/ -/ -/ -that -Sparse -is -used -for -via -Union -. -But -this -creates -a -more -bloated -/ -/ -/ -NFA -with -more -epsilon -transitions -than -is -necessary -in -the -special -case -/ -/ -/ -of -character -classes -. -Sparse -{ -transitions -: -Vec -< -Transition -> -} -/ -/ -/ -A -conditional -epsilon -transition -satisfied -via -some -sort -of -/ -/ -/ -look -- -around -. -Look -{ -look -: -Look -next -: -StateID -} -/ -/ -/ -An -empty -state -that -records -the -start -of -a -capture -location -. -This -is -an -/ -/ -/ -unconditional -epsilon -transition -like -Empty -except -it -can -be -used -to -/ -/ -/ -record -position -information -for -a -captue -group -when -using -the -NFA -for -/ -/ -/ -search -. -CaptureStart -{ -/ -/ -/ -The -ID -of -the -pattern -that -this -capture -was -defined -. -pattern_id -: -PatternID -/ -/ -/ -The -capture -group -index -that -this -capture -state -corresponds -to -. -/ -/ -/ -The -capture -group -index -is -always -relative -to -its -corresponding -/ -/ -/ -pattern -. -Therefore -in -the -presence -of -multiple -patterns -both -the -/ -/ -/ -pattern -ID -and -the -capture -group -index -are -required -to -uniquely -/ -/ -/ -identify -a -capturing -group -. -group_index -: -SmallIndex -/ -/ -/ -The -next -state -that -this -state -should -transition -to -. -next -: -StateID -} -/ -/ -/ -An -empty -state -that -records -the -end -of -a -capture -location -. -This -is -an -/ -/ -/ -unconditional -epsilon -transition -like -Empty -except -it -can -be -used -to -/ -/ -/ -record -position -information -for -a -captue -group -when -using -the -NFA -for -/ -/ -/ -search -. -CaptureEnd -{ -/ -/ -/ -The -ID -of -the -pattern -that -this -capture -was -defined -. -pattern_id -: -PatternID -/ -/ -/ -The -capture -group -index -that -this -capture -state -corresponds -to -. -/ -/ -/ -The -capture -group -index -is -always -relative -to -its -corresponding -/ -/ -/ -pattern -. -Therefore -in -the -presence -of -multiple -patterns -both -the -/ -/ -/ -pattern -ID -and -the -capture -group -index -are -required -to -uniquely -/ -/ -/ -identify -a -capturing -group -. -group_index -: -SmallIndex -/ -/ -/ -The -next -state -that -this -state -should -transition -to -. -next -: -StateID -} -/ -/ -/ -An -alternation -such -that -there -exists -an -epsilon -transition -to -all -/ -/ -/ -states -in -alternates -where -matches -found -via -earlier -transitions -/ -/ -/ -are -preferred -over -later -transitions -. -Union -{ -alternates -: -Vec -< -StateID -> -} -/ -/ -/ -An -alternation -such -that -there -exists -an -epsilon -transition -to -all -/ -/ -/ -states -in -alternates -where -matches -found -via -later -transitions -are -/ -/ -/ -preferred -over -earlier -transitions -. -/ -/ -/ -/ -/ -/ -This -" -reverse -" -state -exists -for -convenience -during -compilation -that -/ -/ -/ -permits -easy -construction -of -non -- -greedy -combinations -of -NFA -states -. -At -/ -/ -/ -the -end -of -compilation -Union -and -UnionReverse -states -are -merged -into -/ -/ -/ -one -Union -type -of -state -where -the -latter -has -its -epsilon -transitions -/ -/ -/ -reversed -to -reflect -the -priority -inversion -. -/ -/ -/ -/ -/ -/ -The -" -convenience -" -here -arises -from -the -fact -that -as -new -states -are -/ -/ -/ -added -to -the -list -of -alternates -we -would -like -that -add -operation -/ -/ -/ -to -be -amortized -constant -time -. -But -if -we -used -a -Union -we -' -d -need -to -/ -/ -/ -prepend -the -state -which -takes -O -( -n -) -time -. -There -are -other -approaches -we -/ -/ -/ -could -use -to -solve -this -but -this -seems -simple -enough -. -UnionReverse -{ -alternates -: -Vec -< -StateID -> -} -/ -/ -/ -A -state -that -cannot -be -transitioned -out -of -. -This -is -useful -for -cases -/ -/ -/ -where -you -want -to -prevent -matching -from -occurring -. -For -example -if -your -/ -/ -/ -regex -parser -permits -empty -character -classes -then -one -could -choose -a -/ -/ -/ -Fail -state -to -represent -it -. -Fail -/ -/ -/ -A -match -state -. -There -is -at -most -one -such -occurrence -of -this -state -in -/ -/ -/ -an -NFA -for -each -pattern -compiled -into -the -NFA -. -At -time -of -writing -a -/ -/ -/ -match -state -is -always -produced -for -every -pattern -given -but -in -theory -/ -/ -/ -if -a -pattern -can -never -lead -to -a -match -then -the -match -state -could -be -/ -/ -/ -omitted -. -/ -/ -/ -/ -/ -/ -pattern_id -refers -to -the -ID -of -the -pattern -itself -which -corresponds -/ -/ -/ -to -the -pattern -' -s -index -( -starting -at -0 -) -. -Match -{ -pattern_id -: -PatternID -} -} -impl -State -{ -/ -/ -/ -If -this -state -is -an -unconditional -espilon -transition -then -this -returns -/ -/ -/ -the -target -of -the -transition -. -fn -goto -( -& -self -) -- -> -Option -< -StateID -> -{ -match -* -self -{ -State -: -: -Empty -{ -next -} -= -> -Some -( -next -) -State -: -: -Union -{ -ref -alternates -} -if -alternates -. -len -( -) -= -= -1 -= -> -{ -Some -( -alternates -[ -0 -] -) -} -State -: -: -UnionReverse -{ -ref -alternates -} -if -alternates -. -len -( -) -= -= -1 -= -> -{ -Some -( -alternates -[ -0 -] -) -} -_ -= -> -None -} -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -of -this -state -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -match -* -self -{ -State -: -: -Empty -{ -. -. -} -| -State -: -: -ByteRange -{ -. -. -} -| -State -: -: -Look -{ -. -. -} -| -State -: -: -CaptureStart -{ -. -. -} -| -State -: -: -CaptureEnd -{ -. -. -} -| -State -: -: -Fail -| -State -: -: -Match -{ -. -. -} -= -> -0 -State -: -: -Sparse -{ -ref -transitions -} -= -> -{ -transitions -. -len -( -) -* -mem -: -: -size_of -: -: -< -Transition -> -( -) -} -State -: -: -Union -{ -ref -alternates -} -= -> -{ -alternates -. -len -( -) -* -mem -: -: -size_of -: -: -< -StateID -> -( -) -} -State -: -: -UnionReverse -{ -ref -alternates -} -= -> -{ -alternates -. -len -( -) -* -mem -: -: -size_of -: -: -< -StateID -> -( -) -} -} -} -} -/ -/ -/ -An -abstraction -for -building -Thompson -NFAs -by -hand -. -/ -/ -/ -/ -/ -/ -A -builder -is -what -a -[ -thompson -: -: -Compiler -] -( -crate -: -: -nfa -: -: -thompson -: -: -Compiler -) -/ -/ -/ -uses -internally -to -translate -a -regex -' -s -high -- -level -intermediate -/ -/ -/ -representation -into -an -[ -NFA -] -. -/ -/ -/ -/ -/ -/ -The -primary -function -of -this -builder -is -to -abstract -away -the -internal -/ -/ -/ -representation -of -an -NFA -and -make -it -difficult -to -produce -NFAs -are -that -/ -/ -/ -internally -invalid -or -inconsistent -. -This -builder -also -provides -a -way -to -/ -/ -/ -add -" -empty -" -states -( -which -can -be -thought -of -as -unconditional -epsilon -/ -/ -/ -transitions -) -despite -the -fact -that -[ -thompson -: -: -State -] -( -nfa -: -: -State -) -does -/ -/ -/ -not -have -any -" -empty -" -representation -. -The -advantage -of -" -empty -" -states -is -/ -/ -/ -that -they -make -the -code -for -constructing -a -Thompson -NFA -logically -simpler -. -/ -/ -/ -/ -/ -/ -Many -of -the -routines -on -this -builder -may -panic -or -return -errors -. -Generally -/ -/ -/ -speaking -panics -occur -when -an -invalid -sequence -of -method -calls -were -made -/ -/ -/ -where -as -an -error -occurs -if -things -get -too -big -. -( -Where -" -too -big -" -might -mean -/ -/ -/ -exhausting -identifier -space -or -using -up -too -much -heap -memory -in -accordance -/ -/ -/ -with -the -configured -[ -size_limit -] -( -Builder -: -: -set_size_limit -) -. -) -/ -/ -/ -/ -/ -/ -# -Overview -/ -/ -/ -/ -/ -/ -# -# -Adding -multiple -patterns -/ -/ -/ -/ -/ -/ -Each -pattern -you -add -to -an -NFA -should -correspond -to -a -pair -of -/ -/ -/ -[ -Builder -: -: -start_pattern -] -and -[ -Builder -: -: -finish_pattern -] -calls -with -/ -/ -/ -calls -inbetween -that -add -NFA -states -for -that -pattern -. -NFA -states -may -be -/ -/ -/ -added -without -first -calling -start_pattern -with -the -exception -of -adding -/ -/ -/ -capturing -states -. -/ -/ -/ -/ -/ -/ -# -# -Adding -NFA -states -/ -/ -/ -/ -/ -/ -Here -is -a -very -brief -overview -of -each -of -the -methods -that -add -NFA -states -. -/ -/ -/ -Every -method -adds -a -single -state -. -/ -/ -/ -/ -/ -/ -* -[ -add_empty -] -( -Builder -: -: -add_empty -) -: -Add -a -state -with -a -single -/ -/ -/ -unconditional -epsilon -transition -to -another -state -. -/ -/ -/ -* -[ -add_union -] -( -Builder -: -: -add_union -) -: -Adds -a -state -with -unconditional -/ -/ -/ -epsilon -transitions -to -two -or -more -states -with -earlier -transitions -/ -/ -/ -preferred -over -later -ones -. -/ -/ -/ -* -[ -add_union_reverse -] -( -Builder -: -: -add_union_reverse -) -: -Adds -a -state -with -/ -/ -/ -unconditional -epsilon -transitions -to -two -or -more -states -with -later -/ -/ -/ -transitions -preferred -over -earlier -ones -. -/ -/ -/ -* -[ -add_range -] -( -Builder -: -: -add_range -) -: -Adds -a -state -with -a -single -transition -/ -/ -/ -to -another -state -that -can -only -be -followed -if -the -current -input -byte -is -/ -/ -/ -within -the -range -given -. -/ -/ -/ -* -[ -add_sparse -] -( -Builder -: -: -add_sparse -) -: -Adds -a -state -with -two -or -more -/ -/ -/ -range -transitions -to -other -states -where -a -transition -is -only -followed -/ -/ -/ -if -the -current -input -byte -is -within -one -of -the -ranges -. -All -transitions -/ -/ -/ -in -this -state -have -equal -priority -and -the -corresponding -ranges -must -be -/ -/ -/ -non -- -overlapping -. -/ -/ -/ -* -[ -add_look -] -( -Builder -: -: -add_look -) -: -Adds -a -state -with -a -single -* -conditional -* -/ -/ -/ -epsilon -transition -to -another -state -where -the -condition -depends -on -a -/ -/ -/ -limited -look -- -around -property -. -/ -/ -/ -* -[ -add_capture_start -] -( -Builder -: -: -add_capture_start -) -: -Adds -a -state -with -/ -/ -/ -a -single -unconditional -epsilon -transition -that -also -instructs -an -NFA -/ -/ -/ -simulation -to -record -the -current -input -position -to -a -specific -location -in -/ -/ -/ -memory -. -This -is -intended -to -represent -the -starting -location -of -a -capturing -/ -/ -/ -group -. -/ -/ -/ -* -[ -add_capture_end -] -( -Builder -: -: -add_capture_end -) -: -Adds -a -state -with -/ -/ -/ -a -single -unconditional -epsilon -transition -that -also -instructs -an -NFA -/ -/ -/ -simulation -to -record -the -current -input -position -to -a -specific -location -in -/ -/ -/ -memory -. -This -is -intended -to -represent -the -ending -location -of -a -capturing -/ -/ -/ -group -. -/ -/ -/ -* -[ -add_fail -] -( -Builder -: -: -add_fail -) -: -Adds -a -state -that -never -transitions -to -/ -/ -/ -another -state -. -/ -/ -/ -* -[ -add_match -] -( -Builder -: -: -add_match -) -: -Add -a -state -that -indicates -a -match -has -/ -/ -/ -been -found -for -a -particular -pattern -. -A -match -state -is -a -final -state -with -/ -/ -/ -no -outgoing -transitions -. -/ -/ -/ -/ -/ -/ -# -# -Setting -transitions -between -NFA -states -/ -/ -/ -/ -/ -/ -The -[ -Builder -: -: -patch -] -method -creates -a -transition -from -one -state -to -the -/ -/ -/ -next -. -If -the -from -state -corresponds -to -a -state -that -supports -multiple -/ -/ -/ -outgoing -transitions -( -such -as -" -union -" -) -then -this -adds -the -corresponding -/ -/ -/ -transition -. -Otherwise -it -sets -the -single -transition -. -( -This -routine -panics -/ -/ -/ -if -from -corresponds -to -a -state -added -by -add_sparse -since -sparse -states -/ -/ -/ -need -more -specialized -handling -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -annotated -example -shows -how -to -hand -construct -the -regex -[ -a -- -z -] -+ -/ -/ -/ -( -without -an -unanchored -prefix -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -pikevm -: -: -PikeVM -Builder -Transition -} -/ -/ -/ -util -: -: -primitives -: -: -StateID -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -mut -builder -= -Builder -: -: -new -( -) -; -/ -/ -/ -/ -/ -Before -adding -NFA -states -for -our -pattern -we -need -to -tell -the -builder -/ -/ -/ -/ -/ -that -we -are -starting -the -pattern -. -/ -/ -/ -builder -. -start_pattern -( -) -? -; -/ -/ -/ -/ -/ -Since -we -use -the -Pike -VM -below -for -searching -we -need -to -add -capturing -/ -/ -/ -/ -/ -states -. -If -you -' -re -just -going -to -build -a -DFA -from -the -NFA -then -capturing -/ -/ -/ -/ -/ -states -do -not -need -to -be -added -. -/ -/ -/ -let -start -= -builder -. -add_capture_start -( -StateID -: -: -ZERO -0 -None -) -? -; -/ -/ -/ -let -range -= -builder -. -add_range -( -Transition -{ -/ -/ -/ -/ -/ -We -don -' -t -know -the -state -ID -of -the -' -next -' -state -yet -so -we -just -fill -/ -/ -/ -/ -/ -in -a -dummy -' -ZERO -' -value -. -/ -/ -/ -start -: -b -' -a -' -end -: -b -' -z -' -next -: -StateID -: -: -ZERO -/ -/ -/ -} -) -? -; -/ -/ -/ -/ -/ -This -state -will -point -back -to -' -range -' -but -also -enable -us -to -move -ahead -. -/ -/ -/ -/ -/ -That -is -this -implements -the -' -+ -' -repetition -operator -. -We -add -' -range -' -and -/ -/ -/ -/ -/ -then -' -end -' -below -to -this -alternation -. -/ -/ -/ -let -alt -= -builder -. -add_union -( -vec -! -[ -] -) -? -; -/ -/ -/ -/ -/ -The -final -state -before -the -match -state -which -serves -to -capture -the -/ -/ -/ -/ -/ -end -location -of -the -match -. -/ -/ -/ -let -end -= -builder -. -add_capture_end -( -StateID -: -: -ZERO -0 -) -? -; -/ -/ -/ -/ -/ -The -match -state -for -our -pattern -. -/ -/ -/ -let -mat -= -builder -. -add_match -( -) -? -; -/ -/ -/ -/ -/ -Now -we -fill -in -the -transitions -between -states -. -/ -/ -/ -builder -. -patch -( -start -range -) -? -; -/ -/ -/ -builder -. -patch -( -range -alt -) -? -; -/ -/ -/ -/ -/ -If -we -added -' -end -' -before -' -range -' -then -we -' -d -implement -non -- -greedy -/ -/ -/ -/ -/ -matching -i -. -e -. -' -+ -? -' -. -/ -/ -/ -builder -. -patch -( -alt -range -) -? -; -/ -/ -/ -builder -. -patch -( -alt -end -) -? -; -/ -/ -/ -builder -. -patch -( -end -mat -) -? -; -/ -/ -/ -/ -/ -We -must -explicitly -finish -pattern -and -provide -the -starting -state -ID -for -/ -/ -/ -/ -/ -this -particular -pattern -. -/ -/ -/ -builder -. -finish_pattern -( -start -) -? -; -/ -/ -/ -/ -/ -Finally -when -we -build -the -NFA -we -provide -the -anchored -and -unanchored -/ -/ -/ -/ -/ -starting -state -IDs -. -Since -we -didn -' -t -bother -with -an -unanchored -prefix -/ -/ -/ -/ -/ -here -we -only -support -anchored -searching -. -Thus -both -starting -states -are -/ -/ -/ -/ -/ -the -same -. -/ -/ -/ -let -nfa -= -builder -. -build -( -start -start -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -build -a -Pike -VM -from -our -NFA -and -use -it -for -searching -. -This -shows -/ -/ -/ -/ -/ -how -we -can -use -a -regex -engine -without -ever -worrying -about -syntax -! -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -foo0 -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -Builder -{ -/ -/ -/ -The -ID -of -the -pattern -that -we -' -re -currently -building -. -/ -/ -/ -/ -/ -/ -Callers -are -required -to -set -( -and -unset -) -this -by -calling -/ -/ -/ -{ -start -finish -} -_pattern -. -Otherwise -most -methods -will -panic -. -pattern_id -: -Option -< -PatternID -> -/ -/ -/ -A -sequence -of -intermediate -NFA -states -. -Once -a -state -is -added -to -this -/ -/ -/ -sequence -it -is -assigned -a -state -ID -equivalent -to -its -index -. -Once -a -/ -/ -/ -state -is -added -it -is -still -expected -to -be -mutated -e -. -g -. -to -set -its -/ -/ -/ -transition -to -a -state -that -didn -' -t -exist -at -the -time -it -was -added -. -states -: -Vec -< -State -> -/ -/ -/ -The -starting -states -for -each -individual -pattern -. -Starting -at -any -/ -/ -/ -of -these -states -will -result -in -only -an -anchored -search -for -the -/ -/ -/ -corresponding -pattern -. -The -vec -is -indexed -by -pattern -ID -. -When -the -NFA -/ -/ -/ -contains -a -single -regex -then -start_pattern -[ -0 -] -and -start_anchored -/ -/ -/ -are -always -equivalent -. -start_pattern -: -Vec -< -StateID -> -/ -/ -/ -A -map -from -pattern -ID -to -capture -group -index -to -name -. -( -If -no -name -/ -/ -/ -exists -then -a -None -entry -is -present -. -Thus -all -capturing -groups -are -/ -/ -/ -present -in -this -mapping -. -) -/ -/ -/ -/ -/ -/ -The -outer -vec -is -indexed -by -pattern -ID -while -the -inner -vec -is -indexed -/ -/ -/ -by -capture -index -offset -for -the -corresponding -pattern -. -/ -/ -/ -/ -/ -/ -The -first -capture -group -for -each -pattern -is -always -unnamed -and -is -thus -/ -/ -/ -always -None -. -captures -: -Vec -< -Vec -< -Option -< -Arc -< -str -> -> -> -> -/ -/ -/ -The -combined -memory -used -by -each -of -the -' -State -' -s -in -' -states -' -. -This -/ -/ -/ -only -includes -heap -usage -by -each -state -and -not -the -size -of -the -state -/ -/ -/ -itself -. -In -other -words -this -tracks -heap -memory -used -that -isn -' -t -/ -/ -/ -captured -via -size_of -: -: -< -State -> -( -) -* -states -. -len -( -) -. -memory_states -: -usize -/ -/ -/ -Whether -this -NFA -only -matches -UTF -- -8 -and -whether -regex -engines -using -/ -/ -/ -this -NFA -for -searching -should -report -empty -matches -that -split -a -/ -/ -/ -codepoint -. -utf8 -: -bool -/ -/ -/ -Whether -this -NFA -should -be -matched -in -reverse -or -not -. -reverse -: -bool -/ -/ -/ -The -matcher -to -use -for -look -- -around -assertions -. -look_matcher -: -LookMatcher -/ -/ -/ -A -size -limit -to -respect -when -building -an -NFA -. -If -the -total -heap -memory -/ -/ -/ -of -the -intermediate -NFA -states -exceeds -( -or -would -exceed -) -this -amount -/ -/ -/ -then -an -error -is -returned -. -size_limit -: -Option -< -usize -> -} -impl -Builder -{ -/ -/ -/ -Create -a -new -builder -for -hand -- -assembling -NFAs -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -: -: -default -( -) -} -/ -/ -/ -Clear -this -builder -. -/ -/ -/ -/ -/ -/ -Clearing -removes -all -state -associated -with -building -an -NFA -but -does -/ -/ -/ -not -reset -configuration -( -such -as -size -limits -and -whether -the -NFA -/ -/ -/ -should -only -match -UTF -- -8 -) -. -After -clearing -the -builder -can -be -reused -to -/ -/ -/ -assemble -an -entirely -new -NFA -. -pub -fn -clear -( -& -mut -self -) -{ -self -. -pattern_id -= -None -; -self -. -states -. -clear -( -) -; -self -. -start_pattern -. -clear -( -) -; -self -. -captures -. -clear -( -) -; -self -. -memory_states -= -0 -; -} -/ -/ -/ -Assemble -a -[ -NFA -] -from -the -states -added -so -far -. -/ -/ -/ -/ -/ -/ -After -building -an -NFA -more -states -may -be -added -and -build -may -be -/ -/ -/ -called -again -. -To -reuse -a -builder -to -produce -an -entirely -new -NFA -from -/ -/ -/ -scratch -call -the -[ -clear -] -( -Builder -: -: -clear -) -method -first -. -/ -/ -/ -/ -/ -/ -start_anchored -refers -to -the -ID -of -the -starting -state -that -anchored -/ -/ -/ -searches -should -use -. -That -is -searches -who -matches -are -limited -to -the -/ -/ -/ -starting -position -of -the -search -. -/ -/ -/ -/ -/ -/ -start_unanchored -refers -to -the -ID -of -the -starting -state -that -/ -/ -/ -unanchored -searches -should -use -. -This -permits -searches -to -report -matches -/ -/ -/ -that -start -after -the -beginning -of -the -search -. -In -cases -where -unanchored -/ -/ -/ -searches -are -not -supported -the -unanchored -starting -state -ID -must -be -/ -/ -/ -the -same -as -the -anchored -starting -state -ID -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -there -was -a -problem -producing -the -final -NFA -. -/ -/ -/ -In -particular -this -might -include -an -error -if -the -capturing -groups -/ -/ -/ -added -to -this -builder -violate -any -of -the -invariants -documented -on -/ -/ -/ -[ -GroupInfo -] -( -crate -: -: -util -: -: -captures -: -: -GroupInfo -) -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -start_pattern -was -called -then -finish_pattern -must -be -called -/ -/ -/ -before -build -otherwise -this -panics -. -/ -/ -/ -/ -/ -/ -This -may -panic -for -other -invalid -uses -of -a -builder -. -For -example -if -/ -/ -/ -a -" -start -capture -" -state -was -added -without -a -corresponding -" -end -capture -" -/ -/ -/ -state -. -pub -fn -build -( -& -self -start_anchored -: -StateID -start_unanchored -: -StateID -) -- -> -Result -< -NFA -BuildError -> -{ -assert -! -( -self -. -pattern_id -. -is_none -( -) -" -must -call -' -finish_pattern -' -first -" -) -; -debug -! -( -" -intermediate -NFA -compilation -via -builder -is -complete -\ -intermediate -NFA -size -: -{ -} -states -{ -} -bytes -on -heap -" -self -. -states -. -len -( -) -self -. -memory_usage -( -) -) -; -let -mut -nfa -= -nfa -: -: -Inner -: -: -default -( -) -; -nfa -. -set_utf8 -( -self -. -utf8 -) -; -nfa -. -set_reverse -( -self -. -reverse -) -; -nfa -. -set_look_matcher -( -self -. -look_matcher -. -clone -( -) -) -; -/ -/ -A -set -of -compiler -internal -state -IDs -that -correspond -to -states -/ -/ -that -are -exclusively -epsilon -transitions -i -. -e -. -goto -instructions -/ -/ -combined -with -the -state -that -they -point -to -. -This -is -used -to -/ -/ -record -said -states -while -transforming -the -compiler -' -s -internal -NFA -/ -/ -representation -to -the -external -form -. -let -mut -empties -= -vec -! -[ -] -; -/ -/ -A -map -used -to -re -- -map -state -IDs -when -translating -this -builder -' -s -/ -/ -internal -NFA -state -representation -to -the -final -NFA -representation -. -let -mut -remap -= -vec -! -[ -] -; -remap -. -resize -( -self -. -states -. -len -( -) -StateID -: -: -ZERO -) -; -nfa -. -set_starts -( -start_anchored -start_unanchored -& -self -. -start_pattern -) -; -nfa -. -set_captures -( -& -self -. -captures -) -. -map_err -( -BuildError -: -: -captures -) -? -; -/ -/ -The -idea -here -is -to -convert -our -intermediate -states -to -their -final -/ -/ -form -. -The -only -real -complexity -here -is -the -process -of -converting -/ -/ -transitions -which -are -expressed -in -terms -of -state -IDs -. -The -new -/ -/ -set -of -states -will -be -smaller -because -of -partial -epsilon -removal -/ -/ -so -the -state -IDs -will -not -be -the -same -. -for -( -sid -state -) -in -self -. -states -. -iter -( -) -. -with_state_ids -( -) -{ -match -* -state -{ -State -: -: -Empty -{ -next -} -= -> -{ -/ -/ -Since -we -' -re -removing -empty -states -we -need -to -handle -/ -/ -them -later -since -we -don -' -t -yet -know -which -new -state -this -/ -/ -empty -state -will -be -mapped -to -. -empties -. -push -( -( -sid -next -) -) -; -} -State -: -: -ByteRange -{ -trans -} -= -> -{ -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -ByteRange -{ -trans -} -) -; -} -State -: -: -Sparse -{ -ref -transitions -} -= -> -{ -remap -[ -sid -] -= -match -transitions -. -len -( -) -{ -0 -= -> -nfa -. -add -( -nfa -: -: -State -: -: -Fail -) -1 -= -> -nfa -. -add -( -nfa -: -: -State -: -: -ByteRange -{ -trans -: -transitions -[ -0 -] -} -) -_ -= -> -{ -let -transitions -= -transitions -. -to_vec -( -) -. -into_boxed_slice -( -) -; -let -sparse -= -SparseTransitions -{ -transitions -} -; -nfa -. -add -( -nfa -: -: -State -: -: -Sparse -( -sparse -) -) -} -} -} -State -: -: -Look -{ -look -next -} -= -> -{ -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Look -{ -look -next -} -) -; -} -State -: -: -CaptureStart -{ -pattern_id -group_index -next -} -= -> -{ -/ -/ -We -can -' -t -remove -this -empty -state -because -of -the -side -/ -/ -effect -of -capturing -an -offset -for -this -capture -slot -. -let -slot -= -nfa -. -group_info -( -) -. -slot -( -pattern_id -group_index -. -as_usize -( -) -) -. -expect -( -" -invalid -capture -index -" -) -; -let -slot -= -SmallIndex -: -: -new -( -slot -) -. -expect -( -" -a -small -enough -slot -" -) -; -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Capture -{ -next -pattern_id -group_index -slot -} -) -; -} -State -: -: -CaptureEnd -{ -pattern_id -group_index -next -} -= -> -{ -/ -/ -We -can -' -t -remove -this -empty -state -because -of -the -side -/ -/ -effect -of -capturing -an -offset -for -this -capture -slot -. -/ -/ -Also -this -always -succeeds -because -we -check -that -all -/ -/ -slot -indices -are -valid -for -all -capture -indices -when -they -/ -/ -are -initially -added -. -let -slot -= -nfa -. -group_info -( -) -. -slot -( -pattern_id -group_index -. -as_usize -( -) -) -. -expect -( -" -invalid -capture -index -" -) -. -checked_add -( -1 -) -. -unwrap -( -) -; -let -slot -= -SmallIndex -: -: -new -( -slot -) -. -expect -( -" -a -small -enough -slot -" -) -; -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Capture -{ -next -pattern_id -group_index -slot -} -) -; -} -State -: -: -Union -{ -ref -alternates -} -= -> -{ -if -alternates -. -is_empty -( -) -{ -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Fail -) -; -} -else -if -alternates -. -len -( -) -= -= -1 -{ -empties -. -push -( -( -sid -alternates -[ -0 -] -) -) -; -remap -[ -sid -] -= -alternates -[ -0 -] -; -} -else -if -alternates -. -len -( -) -= -= -2 -{ -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -BinaryUnion -{ -alt1 -: -alternates -[ -0 -] -alt2 -: -alternates -[ -1 -] -} -) -; -} -else -{ -let -alternates -= -alternates -. -to_vec -( -) -. -into_boxed_slice -( -) -; -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Union -{ -alternates -} -) -; -} -} -State -: -: -UnionReverse -{ -ref -alternates -} -= -> -{ -if -alternates -. -is_empty -( -) -{ -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Fail -) -; -} -else -if -alternates -. -len -( -) -= -= -1 -{ -empties -. -push -( -( -sid -alternates -[ -0 -] -) -) -; -remap -[ -sid -] -= -alternates -[ -0 -] -; -} -else -if -alternates -. -len -( -) -= -= -2 -{ -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -BinaryUnion -{ -alt1 -: -alternates -[ -1 -] -alt2 -: -alternates -[ -0 -] -} -) -; -} -else -{ -let -mut -alternates -= -alternates -. -to_vec -( -) -. -into_boxed_slice -( -) -; -alternates -. -reverse -( -) -; -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Union -{ -alternates -} -) -; -} -} -State -: -: -Fail -= -> -{ -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Fail -) -; -} -State -: -: -Match -{ -pattern_id -} -= -> -{ -remap -[ -sid -] -= -nfa -. -add -( -nfa -: -: -State -: -: -Match -{ -pattern_id -} -) -; -} -} -} -/ -/ -Some -of -the -new -states -still -point -to -empty -state -IDs -so -we -need -to -/ -/ -follow -each -of -them -and -remap -the -empty -state -IDs -to -their -non -- -empty -/ -/ -state -IDs -. -/ -/ -/ -/ -We -also -keep -track -of -which -states -we -' -ve -already -mapped -. -This -helps -/ -/ -avoid -quadratic -behavior -in -a -long -chain -of -empty -states -. -For -/ -/ -example -in -' -a -{ -0 -} -{ -50000 -} -' -. -let -mut -remapped -= -vec -! -[ -false -; -self -. -states -. -len -( -) -] -; -for -& -( -empty_id -empty_next -) -in -empties -. -iter -( -) -{ -if -remapped -[ -empty_id -] -{ -continue -; -} -/ -/ -empty -states -can -point -to -other -empty -states -forming -a -chain -. -/ -/ -So -we -must -follow -the -chain -until -the -end -which -must -end -at -/ -/ -a -non -- -empty -state -and -therefore -a -state -that -is -correctly -/ -/ -remapped -. -We -are -guaranteed -to -terminate -because -our -compiler -/ -/ -never -builds -a -loop -among -only -empty -states -. -let -mut -new_next -= -empty_next -; -while -let -Some -( -next -) -= -self -. -states -[ -new_next -] -. -goto -( -) -{ -new_next -= -next -; -} -remap -[ -empty_id -] -= -remap -[ -new_next -] -; -remapped -[ -empty_id -] -= -true -; -/ -/ -Now -that -we -' -ve -remapped -the -main -' -empty_id -' -above -we -re -- -follow -/ -/ -the -chain -from -above -and -remap -every -empty -state -we -found -along -/ -/ -the -way -to -our -ultimate -non -- -empty -target -. -We -are -careful -to -set -/ -/ -' -remapped -' -to -true -for -each -such -state -. -We -thus -will -not -need -/ -/ -to -re -- -compute -this -chain -for -any -subsequent -empty -states -in -/ -/ -' -empties -' -that -are -part -of -this -chain -. -let -mut -next2 -= -empty_next -; -while -let -Some -( -next -) -= -self -. -states -[ -next2 -] -. -goto -( -) -{ -remap -[ -next2 -] -= -remap -[ -new_next -] -; -remapped -[ -next2 -] -= -true -; -next2 -= -next -; -} -} -/ -/ -Finally -remap -all -of -the -state -IDs -. -nfa -. -remap -( -& -remap -) -; -let -final_nfa -= -nfa -. -into_nfa -( -) -; -debug -! -( -" -NFA -compilation -via -builder -complete -\ -final -NFA -size -: -{ -} -states -{ -} -bytes -on -heap -\ -has -empty -? -{ -: -? -} -utf8 -? -{ -: -? -} -" -final_nfa -. -states -( -) -. -len -( -) -final_nfa -. -memory_usage -( -) -final_nfa -. -has_empty -( -) -final_nfa -. -is_utf8 -( -) -) -; -Ok -( -final_nfa -) -} -/ -/ -/ -Start -the -assembly -of -a -pattern -in -this -NFA -. -/ -/ -/ -/ -/ -/ -Upon -success -this -returns -the -identifier -for -the -new -pattern -. -/ -/ -/ -Identifiers -start -at -0 -and -are -incremented -by -1 -for -each -new -pattern -. -/ -/ -/ -/ -/ -/ -It -is -necessary -to -call -this -routine -before -adding -capturing -states -. -/ -/ -/ -Otherwise -any -other -NFA -state -may -be -added -before -starting -a -pattern -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -If -the -pattern -identifier -space -is -exhausted -then -this -returns -an -/ -/ -/ -error -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -this -is -called -while -assembling -another -pattern -( -i -. -e -. -before -/ -/ -/ -finish_pattern -is -called -) -then -this -panics -. -pub -fn -start_pattern -( -& -mut -self -) -- -> -Result -< -PatternID -BuildError -> -{ -assert -! -( -self -. -pattern_id -. -is_none -( -) -" -must -call -' -finish_pattern -' -first -" -) -; -let -proposed -= -self -. -start_pattern -. -len -( -) -; -let -pid -= -PatternID -: -: -new -( -proposed -) -. -map_err -( -| -_ -| -BuildError -: -: -too_many_patterns -( -proposed -) -) -? -; -self -. -pattern_id -= -Some -( -pid -) -; -/ -/ -This -gets -filled -in -when -' -finish_pattern -' -is -called -. -self -. -start_pattern -. -push -( -StateID -: -: -ZERO -) -; -Ok -( -pid -) -} -/ -/ -/ -Finish -the -assembly -of -a -pattern -in -this -NFA -. -/ -/ -/ -/ -/ -/ -Upon -success -this -returns -the -identifier -for -the -new -pattern -. -/ -/ -/ -Identifiers -start -at -0 -and -are -incremented -by -1 -for -each -new -/ -/ -/ -pattern -. -This -is -the -same -identifier -returned -by -the -corresponding -/ -/ -/ -start_pattern -call -. -/ -/ -/ -/ -/ -/ -Note -that -start_pattern -and -finish_pattern -pairs -cannot -be -/ -/ -/ -interleaved -or -nested -. -A -correct -finish_pattern -call -_always_ -/ -/ -/ -corresponds -to -the -most -recently -called -start_pattern -routine -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -currently -never -returns -an -error -but -this -is -subject -to -change -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -this -is -called -without -a -corresponding -start_pattern -call -then -/ -/ -/ -this -panics -. -pub -fn -finish_pattern -( -& -mut -self -start_id -: -StateID -) -- -> -Result -< -PatternID -BuildError -> -{ -let -pid -= -self -. -current_pattern_id -( -) -; -self -. -start_pattern -[ -pid -] -= -start_id -; -self -. -pattern_id -= -None -; -Ok -( -pid -) -} -/ -/ -/ -Returns -the -pattern -identifier -of -the -current -pattern -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -this -doesn -' -t -occur -after -a -start_pattern -call -and -before -the -/ -/ -/ -corresponding -finish_pattern -call -then -this -panics -. -pub -fn -current_pattern_id -( -& -self -) -- -> -PatternID -{ -self -. -pattern_id -. -expect -( -" -must -call -' -start_pattern -' -first -" -) -} -/ -/ -/ -Returns -the -number -of -patterns -added -to -this -builder -so -far -. -/ -/ -/ -/ -/ -/ -This -only -includes -patterns -that -have -had -finish_pattern -called -/ -/ -/ -for -them -. -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -start_pattern -. -len -( -) -} -/ -/ -/ -Add -an -" -empty -" -NFA -state -. -/ -/ -/ -/ -/ -/ -An -" -empty -" -NFA -state -is -a -state -with -a -single -unconditional -epsilon -/ -/ -/ -transition -to -another -NFA -state -. -Such -empty -states -are -removed -before -/ -/ -/ -building -the -final -[ -NFA -] -( -which -has -no -such -" -empty -" -states -) -but -they -/ -/ -/ -can -be -quite -useful -in -the -construction -process -of -an -NFA -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -. -pub -fn -add_empty -( -& -mut -self -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -add -( -State -: -: -Empty -{ -next -: -StateID -: -: -ZERO -} -) -} -/ -/ -/ -Add -a -" -union -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -union -" -NFA -state -that -contains -zero -or -more -unconditional -epsilon -/ -/ -/ -transitions -to -other -NFA -states -. -The -order -of -these -transitions -/ -/ -/ -reflects -a -priority -order -where -earlier -transitions -are -preferred -over -/ -/ -/ -later -transitions -. -/ -/ -/ -/ -/ -/ -Callers -may -provide -an -empty -set -of -alternates -to -this -method -call -and -/ -/ -/ -then -later -add -transitions -via -patch -. -At -final -build -time -a -" -union -" -/ -/ -/ -state -with -no -alternates -is -converted -to -a -" -fail -" -state -and -a -" -union -" -/ -/ -/ -state -with -exactly -one -alternate -is -treated -as -if -it -were -an -" -empty -" -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -. -pub -fn -add_union -( -& -mut -self -alternates -: -Vec -< -StateID -> -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -add -( -State -: -: -Union -{ -alternates -} -) -} -/ -/ -/ -Add -a -" -reverse -union -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -reverse -union -" -NFA -state -contains -zero -or -more -unconditional -epsilon -/ -/ -/ -transitions -to -other -NFA -states -. -The -order -of -these -transitions -/ -/ -/ -reflects -a -priority -order -where -later -transitions -are -preferred -/ -/ -/ -over -earlier -transitions -. -This -is -an -inverted -priority -order -when -/ -/ -/ -compared -to -add_union -. -This -is -useful -for -example -for -implementing -/ -/ -/ -non -- -greedy -repetition -operators -. -/ -/ -/ -/ -/ -/ -Callers -may -provide -an -empty -set -of -alternates -to -this -method -call -and -/ -/ -/ -then -later -add -transitions -via -patch -. -At -final -build -time -a -" -reverse -/ -/ -/ -union -" -state -with -no -alternates -is -converted -to -a -" -fail -" -state -and -a -/ -/ -/ -" -reverse -union -" -state -with -exactly -one -alternate -is -treated -as -if -it -/ -/ -/ -were -an -" -empty -" -state -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -. -pub -fn -add_union_reverse -( -& -mut -self -alternates -: -Vec -< -StateID -> -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -add -( -State -: -: -UnionReverse -{ -alternates -} -) -} -/ -/ -/ -Add -a -" -range -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -range -" -NFA -state -is -a -state -with -one -outgoing -transition -to -another -/ -/ -/ -state -where -that -transition -may -only -be -followed -if -the -current -input -/ -/ -/ -byte -falls -between -a -range -of -bytes -given -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -. -pub -fn -add_range -( -& -mut -self -trans -: -Transition -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -add -( -State -: -: -ByteRange -{ -trans -} -) -} -/ -/ -/ -Add -a -" -sparse -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -sparse -" -NFA -state -contains -zero -or -more -outgoing -transitions -where -/ -/ -/ -the -transition -to -be -followed -( -if -any -) -is -chosen -based -on -whether -the -/ -/ -/ -current -input -byte -falls -in -the -range -of -one -such -transition -. -The -/ -/ -/ -transitions -given -* -must -* -be -non -- -overlapping -and -in -ascending -order -. -( -A -/ -/ -/ -" -sparse -" -state -with -no -transitions -is -equivalent -to -a -" -fail -" -state -. -) -/ -/ -/ -/ -/ -/ -A -" -sparse -" -state -is -like -adding -a -" -union -" -state -and -pointing -it -at -a -/ -/ -/ -bunch -of -" -range -" -states -except -that -the -different -alternates -have -/ -/ -/ -equal -priority -. -/ -/ -/ -/ -/ -/ -Note -that -a -" -sparse -" -state -is -the -only -state -that -cannot -be -patched -. -/ -/ -/ -This -is -because -a -" -sparse -" -state -has -many -transitions -each -of -which -/ -/ -/ -may -point -to -a -different -NFA -state -. -Moreover -adding -more -such -/ -/ -/ -transitions -requires -more -than -just -an -NFA -state -ID -to -point -to -. -It -/ -/ -/ -also -requires -a -byte -range -. -The -patch -routine -does -not -support -the -/ -/ -/ -additional -information -required -. -Therefore -callers -must -ensure -that -/ -/ -/ -all -outgoing -transitions -for -this -state -are -included -when -add_sparse -/ -/ -/ -is -called -. -There -is -no -way -to -add -more -later -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -_may_ -panic -if -the -transitions -given -overlap -or -are -not -/ -/ -/ -in -ascending -order -. -pub -fn -add_sparse -( -& -mut -self -transitions -: -Vec -< -Transition -> -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -add -( -State -: -: -Sparse -{ -transitions -} -) -} -/ -/ -/ -Add -a -" -look -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -look -" -NFA -state -corresponds -to -a -state -with -exactly -one -/ -/ -/ -* -conditional -* -epsilon -transition -to -another -NFA -state -. -Namely -it -/ -/ -/ -represents -one -of -a -small -set -of -simplistic -look -- -around -operators -. -/ -/ -/ -/ -/ -/ -Callers -may -provide -a -" -dummy -" -state -ID -( -typically -[ -StateID -: -: -ZERO -] -) -/ -/ -/ -and -then -change -it -later -with -[ -patch -] -( -Builder -: -: -patch -) -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -. -pub -fn -add_look -( -& -mut -self -next -: -StateID -look -: -Look -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -add -( -State -: -: -Look -{ -look -next -} -) -} -/ -/ -/ -Add -a -" -start -capture -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -start -capture -" -NFA -state -corresponds -to -a -state -with -exactly -one -/ -/ -/ -outgoing -unconditional -epsilon -transition -to -another -state -. -Unlike -/ -/ -/ -" -empty -" -states -a -" -start -capture -" -state -also -carries -with -it -an -/ -/ -/ -instruction -for -saving -the -current -position -of -input -to -a -particular -/ -/ -/ -location -in -memory -. -NFA -simulations -like -the -Pike -VM -may -use -this -/ -/ -/ -information -to -report -the -match -locations -of -capturing -groups -in -a -/ -/ -/ -regex -pattern -. -/ -/ -/ -/ -/ -/ -If -the -corresponding -capturing -group -has -a -name -then -callers -should -/ -/ -/ -include -it -here -. -/ -/ -/ -/ -/ -/ -Callers -may -provide -a -" -dummy -" -state -ID -( -typically -[ -StateID -: -: -ZERO -] -) -/ -/ -/ -and -then -change -it -later -with -[ -patch -] -( -Builder -: -: -patch -) -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -start_pattern -/ -finish_pattern -capturing -start -and -/ -/ -/ -end -states -may -be -interleaved -. -Indeed -it -is -typical -for -many -" -start -/ -/ -/ -capture -" -NFA -states -to -appear -before -the -first -" -end -capture -" -state -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -or -if -the -given -/ -/ -/ -capture -index -overflows -usize -. -/ -/ -/ -/ -/ -/ -While -the -above -are -the -only -conditions -in -which -this -routine -can -/ -/ -/ -currently -return -an -error -it -is -possible -to -call -this -method -with -an -/ -/ -/ -inputs -that -results -in -the -final -build -( -) -step -failing -to -produce -an -/ -/ -/ -NFA -. -For -example -if -one -adds -two -distinct -capturing -groups -with -the -/ -/ -/ -same -name -then -that -will -result -in -build -( -) -failing -with -an -error -. -/ -/ -/ -/ -/ -/ -See -the -[ -GroupInfo -] -( -crate -: -: -util -: -: -captures -: -: -GroupInfo -) -type -for -/ -/ -/ -more -information -on -what -qualifies -as -valid -capturing -groups -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -an -error -occurs -when -one -tries -to -add -multiple -/ -/ -/ -capturing -groups -with -the -same -name -to -the -same -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -Builder -/ -/ -/ -util -: -: -primitives -: -: -StateID -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -name -= -Some -( -std -: -: -sync -: -: -Arc -: -: -from -( -" -foo -" -) -) -; -/ -/ -/ -let -mut -builder -= -Builder -: -: -new -( -) -; -/ -/ -/ -builder -. -start_pattern -( -) -? -; -/ -/ -/ -/ -/ -0th -capture -group -should -always -be -unnamed -. -/ -/ -/ -let -start -= -builder -. -add_capture_start -( -StateID -: -: -ZERO -0 -None -) -? -; -/ -/ -/ -/ -/ -OK -/ -/ -/ -builder -. -add_capture_start -( -StateID -: -: -ZERO -1 -name -. -clone -( -) -) -? -; -/ -/ -/ -/ -/ -This -is -not -OK -but -' -add_capture_start -' -still -succeeds -. -We -don -' -t -/ -/ -/ -/ -/ -get -an -error -until -we -call -' -build -' -below -. -Without -this -call -the -/ -/ -/ -/ -/ -call -to -' -build -' -below -would -succeed -. -/ -/ -/ -builder -. -add_capture_start -( -StateID -: -: -ZERO -2 -name -. -clone -( -) -) -? -; -/ -/ -/ -/ -/ -Finish -our -pattern -so -we -can -try -to -build -the -NFA -. -/ -/ -/ -builder -. -finish_pattern -( -start -) -? -; -/ -/ -/ -let -result -= -builder -. -build -( -start -start -) -; -/ -/ -/ -assert -! -( -result -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -However -adding -multiple -capturing -groups -with -the -same -name -to -/ -/ -/ -distinct -patterns -is -okay -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -std -: -: -sync -: -: -Arc -; -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -pikevm -: -: -PikeVM -Builder -Transition -} -/ -/ -/ -util -: -: -{ -/ -/ -/ -captures -: -: -Captures -/ -/ -/ -primitives -: -: -{ -PatternID -StateID -} -/ -/ -/ -} -/ -/ -/ -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Hand -- -compile -the -patterns -' -( -? -P -< -foo -> -[ -a -- -z -] -) -' -and -' -( -? -P -< -foo -> -[ -A -- -Z -] -) -' -. -/ -/ -/ -let -mut -builder -= -Builder -: -: -new -( -) -; -/ -/ -/ -/ -/ -We -compile -them -to -support -an -unanchored -search -which -requires -/ -/ -/ -/ -/ -adding -an -implicit -' -( -? -s -- -u -: -. -) -* -? -' -prefix -before -adding -either -pattern -. -/ -/ -/ -let -unanchored_prefix -= -builder -. -add_union_reverse -( -vec -! -[ -] -) -? -; -/ -/ -/ -let -any -= -builder -. -add_range -( -Transition -{ -/ -/ -/ -start -: -b -' -\ -x00 -' -end -: -b -' -\ -xFF -' -next -: -StateID -: -: -ZERO -/ -/ -/ -} -) -? -; -/ -/ -/ -builder -. -patch -( -unanchored_prefix -any -) -? -; -/ -/ -/ -builder -. -patch -( -any -unanchored_prefix -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -an -alternation -that -permits -matching -multiple -patterns -. -/ -/ -/ -let -alt -= -builder -. -add_union -( -vec -! -[ -] -) -? -; -/ -/ -/ -builder -. -patch -( -unanchored_prefix -alt -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -' -( -? -P -< -foo -> -[ -a -- -z -] -+ -) -' -. -/ -/ -/ -builder -. -start_pattern -( -) -? -; -/ -/ -/ -let -start0 -= -builder -. -add_capture_start -( -StateID -: -: -ZERO -0 -None -) -? -; -/ -/ -/ -/ -/ -N -. -B -. -0th -capture -group -must -always -be -unnamed -. -/ -/ -/ -let -foo_start0 -= -builder -. -add_capture_start -( -/ -/ -/ -StateID -: -: -ZERO -1 -Some -( -Arc -: -: -from -( -" -foo -" -) -) -/ -/ -/ -) -? -; -/ -/ -/ -let -lowercase -= -builder -. -add_range -( -Transition -{ -/ -/ -/ -start -: -b -' -a -' -end -: -b -' -z -' -next -: -StateID -: -: -ZERO -/ -/ -/ -} -) -? -; -/ -/ -/ -let -foo_end0 -= -builder -. -add_capture_end -( -StateID -: -: -ZERO -1 -) -? -; -/ -/ -/ -let -end0 -= -builder -. -add_capture_end -( -StateID -: -: -ZERO -0 -) -? -; -/ -/ -/ -let -match0 -= -builder -. -add_match -( -) -? -; -/ -/ -/ -builder -. -patch -( -start0 -foo_start0 -) -? -; -/ -/ -/ -builder -. -patch -( -foo_start0 -lowercase -) -? -; -/ -/ -/ -builder -. -patch -( -lowercase -foo_end0 -) -? -; -/ -/ -/ -builder -. -patch -( -foo_end0 -end0 -) -? -; -/ -/ -/ -builder -. -patch -( -end0 -match0 -) -? -; -/ -/ -/ -builder -. -finish_pattern -( -start0 -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -' -( -? -P -< -foo -> -[ -A -- -Z -] -+ -) -' -. -/ -/ -/ -builder -. -start_pattern -( -) -? -; -/ -/ -/ -let -start1 -= -builder -. -add_capture_start -( -StateID -: -: -ZERO -0 -None -) -? -; -/ -/ -/ -/ -/ -N -. -B -. -0th -capture -group -must -always -be -unnamed -. -/ -/ -/ -let -foo_start1 -= -builder -. -add_capture_start -( -/ -/ -/ -StateID -: -: -ZERO -1 -Some -( -Arc -: -: -from -( -" -foo -" -) -) -/ -/ -/ -) -? -; -/ -/ -/ -let -uppercase -= -builder -. -add_range -( -Transition -{ -/ -/ -/ -start -: -b -' -A -' -end -: -b -' -Z -' -next -: -StateID -: -: -ZERO -/ -/ -/ -} -) -? -; -/ -/ -/ -let -foo_end1 -= -builder -. -add_capture_end -( -StateID -: -: -ZERO -1 -) -? -; -/ -/ -/ -let -end1 -= -builder -. -add_capture_end -( -StateID -: -: -ZERO -0 -) -? -; -/ -/ -/ -let -match1 -= -builder -. -add_match -( -) -? -; -/ -/ -/ -builder -. -patch -( -start1 -foo_start1 -) -? -; -/ -/ -/ -builder -. -patch -( -foo_start1 -uppercase -) -? -; -/ -/ -/ -builder -. -patch -( -uppercase -foo_end1 -) -? -; -/ -/ -/ -builder -. -patch -( -foo_end1 -end1 -) -? -; -/ -/ -/ -builder -. -patch -( -end1 -match1 -) -? -; -/ -/ -/ -builder -. -finish_pattern -( -start1 -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -add -the -patterns -to -our -alternation -that -we -started -above -. -/ -/ -/ -builder -. -patch -( -alt -start0 -) -? -; -/ -/ -/ -builder -. -patch -( -alt -start1 -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Finally -build -the -NFA -. -The -first -argument -is -the -anchored -starting -/ -/ -/ -/ -/ -state -( -the -pattern -alternation -) -where -as -the -second -is -the -/ -/ -/ -/ -/ -unanchored -starting -state -( -the -unanchored -prefix -) -. -/ -/ -/ -let -nfa -= -builder -. -build -( -alt -unanchored_prefix -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -build -a -Pike -VM -from -our -NFA -and -access -the -' -foo -' -capture -/ -/ -/ -/ -/ -group -regardless -of -which -pattern -matched -since -it -is -defined -/ -/ -/ -/ -/ -for -both -patterns -. -/ -/ -/ -let -vm -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -vm -. -create_cache -( -) -; -/ -/ -/ -let -caps -: -Vec -< -Captures -> -= -/ -/ -/ -vm -. -captures_iter -( -& -mut -cache -" -0123aAaAA -" -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -5 -caps -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -0 -) -) -caps -[ -0 -] -. -pattern -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -4 -. -. -5 -) -) -caps -[ -0 -] -. -get_group_by_name -( -" -foo -" -) -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -caps -[ -1 -] -. -pattern -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -5 -. -. -6 -) -) -caps -[ -1 -] -. -get_group_by_name -( -" -foo -" -) -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -0 -) -) -caps -[ -2 -] -. -pattern -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -6 -. -. -7 -) -) -caps -[ -2 -] -. -get_group_by_name -( -" -foo -" -) -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -caps -[ -3 -] -. -pattern -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -7 -. -. -8 -) -) -caps -[ -3 -] -. -get_group_by_name -( -" -foo -" -) -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -caps -[ -4 -] -. -pattern -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -8 -. -. -9 -) -) -caps -[ -4 -] -. -get_group_by_name -( -" -foo -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -add_capture_start -( -& -mut -self -next -: -StateID -group_index -: -u32 -name -: -Option -< -Arc -< -str -> -> -) -- -> -Result -< -StateID -BuildError -> -{ -let -pid -= -self -. -current_pattern_id -( -) -; -let -group_index -= -match -SmallIndex -: -: -try_from -( -group_index -) -{ -Err -( -_ -) -= -> -{ -return -Err -( -BuildError -: -: -invalid_capture_index -( -group_index -) -) -} -Ok -( -group_index -) -= -> -group_index -} -; -/ -/ -Make -sure -we -have -space -to -insert -our -( -pid -index -) -| -- -- -> -name -mapping -. -if -pid -. -as_usize -( -) -> -= -self -. -captures -. -len -( -) -{ -for -_ -in -0 -. -. -= -( -pid -. -as_usize -( -) -- -self -. -captures -. -len -( -) -) -{ -self -. -captures -. -push -( -vec -! -[ -] -) -; -} -} -/ -/ -In -the -case -where -' -group_index -< -self -. -captures -[ -pid -] -. -len -( -) -' -it -means -/ -/ -that -we -are -adding -a -duplicate -capture -group -. -This -is -somewhat -/ -/ -weird -but -permissible -because -the -capture -group -itself -can -be -/ -/ -repeated -in -the -syntax -. -For -example -' -( -[ -a -- -z -] -) -{ -4 -} -' -will -produce -4 -/ -/ -capture -groups -. -In -practice -only -the -last -will -be -set -at -search -/ -/ -time -when -a -match -occurs -. -For -duplicates -we -don -' -t -need -to -push -/ -/ -anything -other -than -a -CaptureStart -NFA -state -. -if -group_index -. -as_usize -( -) -> -= -self -. -captures -[ -pid -] -. -len -( -) -{ -/ -/ -For -discontiguous -indices -push -placeholders -for -earlier -capture -/ -/ -groups -that -weren -' -t -explicitly -added -. -for -_ -in -0 -. -. -( -group_index -. -as_usize -( -) -- -self -. -captures -[ -pid -] -. -len -( -) -) -{ -self -. -captures -[ -pid -] -. -push -( -None -) -; -} -self -. -captures -[ -pid -] -. -push -( -name -) -; -} -self -. -add -( -State -: -: -CaptureStart -{ -pattern_id -: -pid -group_index -next -} -) -} -/ -/ -/ -Add -a -" -end -capture -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -end -capture -" -NFA -state -corresponds -to -a -state -with -exactly -one -/ -/ -/ -outgoing -unconditional -epsilon -transition -to -another -state -. -Unlike -/ -/ -/ -" -empty -" -states -a -" -end -capture -" -state -also -carries -with -it -an -/ -/ -/ -instruction -for -saving -the -current -position -of -input -to -a -particular -/ -/ -/ -location -in -memory -. -NFA -simulations -like -the -Pike -VM -may -use -this -/ -/ -/ -information -to -report -the -match -locations -of -capturing -groups -in -a -/ -/ -/ -/ -/ -/ -Callers -may -provide -a -" -dummy -" -state -ID -( -typically -[ -StateID -: -: -ZERO -] -) -/ -/ -/ -and -then -change -it -later -with -[ -patch -] -( -Builder -: -: -patch -) -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -start_pattern -/ -finish_pattern -capturing -start -and -/ -/ -/ -end -states -may -be -interleaved -. -Indeed -it -is -typical -for -many -" -start -/ -/ -/ -capture -" -NFA -states -to -appear -before -the -first -" -end -capture -" -state -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -or -if -the -given -/ -/ -/ -capture -index -overflows -usize -. -/ -/ -/ -/ -/ -/ -While -the -above -are -the -only -conditions -in -which -this -routine -can -/ -/ -/ -currently -return -an -error -it -is -possible -to -call -this -method -with -an -/ -/ -/ -inputs -that -results -in -the -final -build -( -) -step -failing -to -produce -an -/ -/ -/ -NFA -. -For -example -if -one -adds -two -distinct -capturing -groups -with -the -/ -/ -/ -same -name -then -that -will -result -in -build -( -) -failing -with -an -error -. -/ -/ -/ -/ -/ -/ -See -the -[ -GroupInfo -] -( -crate -: -: -util -: -: -captures -: -: -GroupInfo -) -type -for -/ -/ -/ -more -information -on -what -qualifies -as -valid -capturing -groups -. -pub -fn -add_capture_end -( -& -mut -self -next -: -StateID -group_index -: -u32 -) -- -> -Result -< -StateID -BuildError -> -{ -let -pid -= -self -. -current_pattern_id -( -) -; -let -group_index -= -match -SmallIndex -: -: -try_from -( -group_index -) -{ -Err -( -_ -) -= -> -{ -return -Err -( -BuildError -: -: -invalid_capture_index -( -group_index -) -) -} -Ok -( -group_index -) -= -> -group_index -} -; -self -. -add -( -State -: -: -CaptureEnd -{ -pattern_id -: -pid -group_index -next -} -) -} -/ -/ -/ -Adds -a -" -fail -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -fail -" -state -is -simply -a -state -that -has -no -outgoing -transitions -. -It -/ -/ -/ -acts -as -a -way -to -cause -a -search -to -stop -without -reporting -a -match -. -/ -/ -/ -For -example -one -way -to -represent -an -NFA -with -zero -patterns -is -with -a -/ -/ -/ -single -" -fail -" -state -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -. -pub -fn -add_fail -( -& -mut -self -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -add -( -State -: -: -Fail -) -} -/ -/ -/ -Adds -a -" -match -" -NFA -state -. -/ -/ -/ -/ -/ -/ -A -" -match -" -state -has -no -outgoing -transitions -( -just -like -a -" -fail -" -/ -/ -/ -state -) -but -it -has -special -significance -in -that -if -a -search -enters -/ -/ -/ -this -state -then -a -match -has -been -found -. -The -match -state -that -is -added -/ -/ -/ -automatically -has -the -current -pattern -ID -associated -with -it -. -This -is -/ -/ -/ -used -to -report -the -matching -pattern -ID -at -search -time -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -the -state -identifier -space -is -exhausted -or -if -/ -/ -/ -the -configured -heap -size -limit -has -been -exceeded -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -must -be -called -after -a -start_pattern -call -but -before -the -/ -/ -/ -corresponding -finish_pattern -call -. -Otherwise -it -panics -. -pub -fn -add_match -( -& -mut -self -) -- -> -Result -< -StateID -BuildError -> -{ -let -pattern_id -= -self -. -current_pattern_id -( -) -; -let -sid -= -self -. -add -( -State -: -: -Match -{ -pattern_id -} -) -? -; -Ok -( -sid -) -} -/ -/ -/ -The -common -implementation -of -" -add -a -state -. -" -It -handles -the -common -/ -/ -/ -error -cases -of -state -ID -exhausting -( -by -owning -state -ID -allocation -) -and -/ -/ -/ -whether -the -size -limit -has -been -exceeded -. -fn -add -( -& -mut -self -state -: -State -) -- -> -Result -< -StateID -BuildError -> -{ -let -id -= -StateID -: -: -new -( -self -. -states -. -len -( -) -) -. -map_err -( -| -_ -| -BuildError -: -: -too_many_states -( -self -. -states -. -len -( -) -) -) -? -; -self -. -memory_states -+ -= -state -. -memory_usage -( -) -; -self -. -states -. -push -( -state -) -; -self -. -check_size_limit -( -) -? -; -Ok -( -id -) -} -/ -/ -/ -Add -a -transition -from -one -state -to -another -. -/ -/ -/ -/ -/ -/ -This -routine -is -called -" -patch -" -since -it -is -very -common -to -add -the -/ -/ -/ -states -you -want -typically -with -" -dummy -" -state -ID -transitions -and -then -/ -/ -/ -" -patch -" -in -the -real -state -IDs -later -. -This -is -because -you -don -' -t -always -/ -/ -/ -know -all -of -the -necessary -state -IDs -to -add -because -they -might -not -/ -/ -/ -exist -yet -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -may -error -if -patching -leads -to -an -increase -in -heap -usage -beyond -/ -/ -/ -the -configured -size -limit -. -Heap -usage -only -grows -when -patching -adds -a -/ -/ -/ -new -transition -( -as -in -the -case -of -a -" -union -" -state -) -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -from -corresponds -to -a -" -sparse -" -state -. -When -" -sparse -" -/ -/ -/ -states -are -added -there -is -no -way -to -patch -them -after -- -the -- -fact -. -( -If -you -/ -/ -/ -have -a -use -case -where -this -would -be -helpful -please -file -an -issue -. -It -/ -/ -/ -will -likely -require -a -new -API -. -) -pub -fn -patch -( -& -mut -self -from -: -StateID -to -: -StateID -) -- -> -Result -< -( -) -BuildError -> -{ -let -old_memory_states -= -self -. -memory_states -; -match -self -. -states -[ -from -] -{ -State -: -: -Empty -{ -ref -mut -next -} -= -> -{ -* -next -= -to -; -} -State -: -: -ByteRange -{ -ref -mut -trans -} -= -> -{ -trans -. -next -= -to -; -} -State -: -: -Sparse -{ -. -. -} -= -> -{ -panic -! -( -" -cannot -patch -from -a -sparse -NFA -state -" -) -} -State -: -: -Look -{ -ref -mut -next -. -. -} -= -> -{ -* -next -= -to -; -} -State -: -: -Union -{ -ref -mut -alternates -} -= -> -{ -alternates -. -push -( -to -) -; -self -. -memory_states -+ -= -mem -: -: -size_of -: -: -< -StateID -> -( -) -; -} -State -: -: -UnionReverse -{ -ref -mut -alternates -} -= -> -{ -alternates -. -push -( -to -) -; -self -. -memory_states -+ -= -mem -: -: -size_of -: -: -< -StateID -> -( -) -; -} -State -: -: -CaptureStart -{ -ref -mut -next -. -. -} -= -> -{ -* -next -= -to -; -} -State -: -: -CaptureEnd -{ -ref -mut -next -. -. -} -= -> -{ -* -next -= -to -; -} -State -: -: -Fail -= -> -{ -} -State -: -: -Match -{ -. -. -} -= -> -{ -} -} -if -old_memory_states -! -= -self -. -memory_states -{ -self -. -check_size_limit -( -) -? -; -} -Ok -( -( -) -) -} -/ -/ -/ -Set -whether -the -NFA -produced -by -this -builder -should -only -match -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -This -should -be -set -when -both -of -the -following -are -true -: -/ -/ -/ -/ -/ -/ -1 -. -The -caller -guarantees -that -the -NFA -created -by -this -build -will -only -/ -/ -/ -report -non -- -empty -matches -with -spans -that -are -valid -UTF -- -8 -. -/ -/ -/ -2 -. -The -caller -desires -regex -engines -using -this -NFA -to -avoid -reporting -/ -/ -/ -empty -matches -with -a -span -that -splits -a -valid -UTF -- -8 -encoded -codepoint -. -/ -/ -/ -/ -/ -/ -Property -( -1 -) -is -not -checked -. -Instead -this -requires -the -caller -to -/ -/ -/ -promise -that -it -is -true -. -Property -( -2 -) -corresponds -to -the -behavior -of -/ -/ -/ -regex -engines -using -the -NFA -created -by -this -builder -. -Namely -there -/ -/ -/ -is -no -way -in -the -NFA -' -s -graph -itself -to -say -that -empty -matches -found -/ -/ -/ -by -for -example -the -regex -a -* -will -fall -on -valid -UTF -- -8 -boundaries -. -/ -/ -/ -Instead -this -option -is -used -to -communicate -the -UTF -- -8 -semantic -to -regex -/ -/ -/ -engines -that -will -typically -implement -it -as -a -post -- -processing -step -by -/ -/ -/ -filtering -out -empty -matches -that -don -' -t -fall -on -UTF -- -8 -boundaries -. -/ -/ -/ -/ -/ -/ -If -you -' -re -building -an -NFA -from -an -HIR -( -and -not -using -a -/ -/ -/ -[ -thompson -: -: -Compiler -] -( -crate -: -: -nfa -: -: -thompson -: -: -Compiler -) -) -then -you -can -/ -/ -/ -use -the -[ -syntax -: -: -Config -: -: -utf8 -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -utf8 -) -/ -/ -/ -option -to -guarantee -that -if -the -HIR -detects -a -non -- -empty -match -then -it -/ -/ -/ -is -guaranteed -to -be -valid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -Note -that -property -( -2 -) -does -* -not -* -specify -the -behavior -of -executing -/ -/ -/ -a -search -on -a -haystack -that -is -not -valid -UTF -- -8 -. -Therefore -if -you -' -re -/ -/ -/ -* -not -* -running -this -NFA -on -strings -that -are -guaranteed -to -be -valid -/ -/ -/ -UTF -- -8 -you -almost -certainly -do -not -want -to -enable -this -option -. -/ -/ -/ -Similarly -if -you -are -running -the -NFA -on -strings -that -* -are -* -guaranteed -/ -/ -/ -to -be -valid -UTF -- -8 -then -you -almost -certainly -want -to -enable -this -option -/ -/ -/ -unless -you -can -guarantee -that -your -NFA -will -never -produce -a -zero -- -width -/ -/ -/ -match -. -/ -/ -/ -/ -/ -/ -It -is -disabled -by -default -. -pub -fn -set_utf8 -( -& -mut -self -yes -: -bool -) -{ -self -. -utf8 -= -yes -; -} -/ -/ -/ -Returns -whether -UTF -- -8 -mode -is -enabled -for -this -builder -. -/ -/ -/ -/ -/ -/ -See -[ -Builder -: -: -set_utf8 -] -for -more -details -about -what -" -UTF -- -8 -mode -" -is -. -pub -fn -get_utf8 -( -& -self -) -- -> -bool -{ -self -. -utf8 -} -/ -/ -/ -Sets -whether -the -NFA -produced -by -this -builder -should -be -matched -in -/ -/ -/ -reverse -or -not -. -Generally -speaking -when -enabled -the -NFA -produced -/ -/ -/ -should -be -matched -by -moving -backwards -through -a -haystack -from -a -higher -/ -/ -/ -memory -address -to -a -lower -memory -address -. -/ -/ -/ -/ -/ -/ -See -also -[ -NFA -: -: -is_reverse -] -for -more -details -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -which -means -NFAs -are -by -default -matched -/ -/ -/ -in -the -forward -direction -. -pub -fn -set_reverse -( -& -mut -self -yes -: -bool -) -{ -self -. -reverse -= -yes -; -} -/ -/ -/ -Returns -whether -reverse -mode -is -enabled -for -this -builder -. -/ -/ -/ -/ -/ -/ -See -[ -Builder -: -: -set_reverse -] -for -more -details -about -what -" -reverse -mode -" -/ -/ -/ -is -. -pub -fn -get_reverse -( -& -self -) -- -> -bool -{ -self -. -reverse -} -/ -/ -/ -Sets -the -look -- -around -matcher -that -should -be -used -for -the -resulting -NFA -. -/ -/ -/ -/ -/ -/ -A -look -- -around -matcher -can -be -used -to -configure -how -look -- -around -/ -/ -/ -assertions -are -matched -. -For -example -a -matcher -might -carry -/ -/ -/ -configuration -that -changes -the -line -terminator -used -for -( -? -m -: -^ -) -and -/ -/ -/ -( -? -m -: -) -assertions -. -pub -fn -set_look_matcher -( -& -mut -self -m -: -LookMatcher -) -{ -self -. -look_matcher -= -m -; -} -/ -/ -/ -Returns -the -look -- -around -matcher -used -for -this -builder -. -/ -/ -/ -/ -/ -/ -If -a -matcher -was -not -explicitly -set -then -LookMatcher -: -: -default -( -) -is -/ -/ -/ -returned -. -pub -fn -get_look_matcher -( -& -self -) -- -> -& -LookMatcher -{ -& -self -. -look_matcher -} -/ -/ -/ -Set -the -size -limit -on -this -builder -. -/ -/ -/ -/ -/ -/ -Setting -the -size -limit -will -also -check -whether -the -NFA -built -so -far -/ -/ -/ -fits -within -the -given -size -limit -. -If -it -doesn -' -t -then -an -error -is -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -By -default -there -is -no -configured -size -limit -. -pub -fn -set_size_limit -( -& -mut -self -limit -: -Option -< -usize -> -) -- -> -Result -< -( -) -BuildError -> -{ -self -. -size_limit -= -limit -; -self -. -check_size_limit -( -) -} -/ -/ -/ -Return -the -currently -configured -size -limit -. -/ -/ -/ -/ -/ -/ -By -default -this -returns -None -which -corresponds -to -no -configured -/ -/ -/ -size -limit -. -pub -fn -get_size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -size_limit -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -used -by -the -NFA -states -added -/ -/ -/ -so -far -. -/ -/ -/ -/ -/ -/ -Note -that -this -is -an -approximation -of -how -big -the -final -NFA -will -be -. -/ -/ -/ -In -practice -the -final -NFA -will -likely -be -a -bit -smaller -because -of -/ -/ -/ -its -simpler -state -representation -. -( -For -example -using -things -like -/ -/ -/ -Box -< -[ -StateID -] -> -instead -of -Vec -< -StateID -> -. -) -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -states -. -len -( -) -* -mem -: -: -size_of -: -: -< -State -> -( -) -+ -self -. -memory_states -} -fn -check_size_limit -( -& -self -) -- -> -Result -< -( -) -BuildError -> -{ -if -let -Some -( -limit -) -= -self -. -size_limit -{ -if -self -. -memory_usage -( -) -> -limit -{ -return -Err -( -BuildError -: -: -exceeded_size_limit -( -limit -) -) -; -} -} -Ok -( -( -) -) -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -super -: -: -* -; -/ -/ -This -asserts -that -a -builder -state -doesn -' -t -have -its -size -changed -. -It -is -/ -/ -* -really -* -easy -to -accidentally -increase -the -size -and -thus -potentially -/ -/ -dramatically -increase -the -memory -usage -of -NFA -builder -. -/ -/ -/ -/ -This -assert -doesn -' -t -mean -we -absolutely -cannot -increase -the -size -of -a -/ -/ -builder -state -. -We -can -. -It -' -s -just -here -to -make -sure -we -do -it -knowingly -/ -/ -and -intentionally -. -/ -/ -/ -/ -A -builder -state -is -unfortunately -a -little -bigger -than -an -NFA -state -/ -/ -since -we -really -want -to -support -adding -things -to -a -pre -- -existing -state -. -/ -/ -i -. -e -. -We -use -Vec -< -thing -> -instead -of -Box -< -[ -thing -] -> -. -So -we -end -up -using -an -/ -/ -extra -8 -bytes -per -state -. -Sad -but -at -least -it -gets -freed -once -the -NFA -/ -/ -is -built -. -# -[ -test -] -fn -state_has_small_size -( -) -{ -# -[ -cfg -( -target_pointer_width -= -" -64 -" -) -] -assert_eq -! -( -32 -core -: -: -mem -: -: -size_of -: -: -< -State -> -( -) -) -; -# -[ -cfg -( -target_pointer_width -= -" -32 -" -) -] -assert_eq -! -( -16 -core -: -: -mem -: -: -size_of -: -: -< -State -> -( -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/nfa/thompson/compiler.rs b/third_party/rust/regex-automata/src/nfa/thompson/compiler.rs deleted file mode 100644 index 096e01fa8c1d7..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/compiler.rs +++ /dev/null @@ -1,20189 +0,0 @@ -use -core -: -: -{ -borrow -: -: -Borrow -cell -: -: -RefCell -} -; -use -alloc -: -: -{ -sync -: -: -Arc -vec -vec -: -: -Vec -} -; -use -regex_syntax -: -: -{ -hir -: -: -{ -self -Hir -} -utf8 -: -: -{ -Utf8Range -Utf8Sequences -} -ParserBuilder -} -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -{ -builder -: -: -Builder -error -: -: -BuildError -literal_trie -: -: -LiteralTrie -map -: -: -{ -Utf8BoundedMap -Utf8SuffixKey -Utf8SuffixMap -} -nfa -: -: -{ -Transition -NFA -} -range_trie -: -: -RangeTrie -} -util -: -: -{ -look -: -: -{ -Look -LookMatcher -} -primitives -: -: -{ -PatternID -StateID -} -} -} -; -/ -/ -/ -The -configuration -used -for -a -Thompson -NFA -compiler -. -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -Config -{ -utf8 -: -Option -< -bool -> -reverse -: -Option -< -bool -> -nfa_size_limit -: -Option -< -Option -< -usize -> -> -shrink -: -Option -< -bool -> -which_captures -: -Option -< -WhichCaptures -> -look_matcher -: -Option -< -LookMatcher -> -# -[ -cfg -( -test -) -] -unanchored_prefix -: -Option -< -bool -> -} -impl -Config -{ -/ -/ -/ -Return -a -new -default -Thompson -NFA -compiler -configuration -. -pub -fn -new -( -) -- -> -Config -{ -Config -: -: -default -( -) -} -/ -/ -/ -Whether -to -enable -UTF -- -8 -mode -during -search -or -not -. -/ -/ -/ -/ -/ -/ -A -regex -engine -is -said -to -be -in -UTF -- -8 -mode -when -it -guarantees -that -/ -/ -/ -all -matches -returned -by -it -have -spans -consisting -of -only -valid -UTF -- -8 -. -/ -/ -/ -That -is -it -is -impossible -for -a -match -span -to -be -returned -that -/ -/ -/ -contains -any -invalid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -UTF -- -8 -mode -generally -consists -of -two -things -: -/ -/ -/ -/ -/ -/ -1 -. -Whether -the -NFA -' -s -states -are -constructed -such -that -all -paths -to -a -/ -/ -/ -match -state -that -consume -at -least -one -byte -always -correspond -to -valid -/ -/ -/ -UTF -- -8 -. -/ -/ -/ -2 -. -Whether -all -paths -to -a -match -state -that -do -_not_ -consume -any -bytes -/ -/ -/ -should -always -correspond -to -valid -UTF -- -8 -boundaries -. -/ -/ -/ -/ -/ -/ -( -1 -) -is -a -guarantee -made -by -whoever -constructs -the -NFA -. -/ -/ -/ -If -you -' -re -parsing -a -regex -from -its -concrete -syntax -then -/ -/ -/ -[ -syntax -: -: -Config -: -: -utf8 -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -utf8 -) -can -make -/ -/ -/ -this -guarantee -for -you -. -It -does -it -by -returning -an -error -if -the -regex -/ -/ -/ -pattern -could -every -report -a -non -- -empty -match -span -that -contains -invalid -/ -/ -/ -UTF -- -8 -. -So -long -as -syntax -: -: -Config -: -: -utf8 -mode -is -enabled -and -your -regex -/ -/ -/ -successfully -parses -then -you -' -re -guaranteed -that -the -corresponding -NFA -/ -/ -/ -will -only -ever -report -non -- -empty -match -spans -containing -valid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -( -2 -) -is -a -trickier -guarantee -because -it -cannot -be -enforced -by -the -NFA -/ -/ -/ -state -graph -itself -. -Consider -for -example -the -regex -a -* -. -It -matches -/ -/ -/ -the -empty -strings -in -at -positions -0 -1 -2 -and -3 -where -/ -/ -/ -positions -1 -and -2 -occur -within -the -UTF -- -8 -encoding -of -a -codepoint -/ -/ -/ -and -thus -correspond -to -invalid -UTF -- -8 -boundaries -. -Therefore -this -/ -/ -/ -guarantee -must -be -made -at -a -higher -level -than -the -NFA -state -graph -/ -/ -/ -itself -. -This -crate -deals -with -this -case -in -each -regex -engine -. -Namely -/ -/ -/ -when -a -zero -- -width -match -that -splits -a -codepoint -is -found -and -UTF -- -8 -/ -/ -/ -mode -enabled -then -it -is -ignored -and -the -engine -moves -on -looking -for -/ -/ -/ -the -next -match -. -/ -/ -/ -/ -/ -/ -Thus -UTF -- -8 -mode -is -both -a -promise -that -the -NFA -built -only -reports -/ -/ -/ -non -- -empty -matches -that -are -valid -UTF -- -8 -and -an -* -instruction -* -to -regex -/ -/ -/ -engines -that -empty -matches -that -split -codepoints -should -be -banned -. -/ -/ -/ -/ -/ -/ -Because -UTF -- -8 -mode -is -fundamentally -about -avoiding -invalid -UTF -- -8 -spans -/ -/ -/ -it -only -makes -sense -to -enable -this -option -when -you -* -know -* -your -haystack -/ -/ -/ -is -valid -UTF -- -8 -. -( -For -example -a -& -str -. -) -Enabling -UTF -- -8 -mode -and -/ -/ -/ -searching -a -haystack -that -contains -invalid -UTF -- -8 -leads -to -* -* -unspecified -/ -/ -/ -behavior -* -* -. -/ -/ -/ -/ -/ -/ -Therefore -it -may -make -sense -to -enable -syntax -: -: -Config -: -: -utf8 -while -/ -/ -/ -simultaneously -* -disabling -* -this -option -. -That -would -ensure -all -non -- -empty -/ -/ -/ -match -spans -are -valid -UTF -- -8 -but -that -empty -match -spans -may -still -split -/ -/ -/ -a -codepoint -or -match -at -other -places -that -aren -' -t -valid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -In -general -this -mode -is -only -relevant -if -your -regex -can -match -the -/ -/ -/ -empty -string -. -Most -regexes -don -' -t -. -/ -/ -/ -/ -/ -/ -This -is -enabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -UTF -- -8 -mode -can -impact -the -match -spans -that -may -/ -/ -/ -be -reported -in -certain -cases -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -PikeVM -} -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -UTF -- -8 -mode -is -enabled -by -default -. -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -0 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -an -empty -regex -matches -at -1 -. -. -1 -our -next -match -is -/ -/ -/ -/ -/ -3 -. -. -3 -because -1 -. -. -1 -and -2 -. -. -2 -split -the -snowman -codepoint -( -which -is -/ -/ -/ -/ -/ -three -bytes -long -) -. -/ -/ -/ -input -. -set_start -( -1 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -3 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -disable -UTF -- -8 -then -we -' -ll -get -matches -at -1 -. -. -1 -and -2 -. -. -2 -: -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -" -" -) -? -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -1 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -2 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -2 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -3 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -3 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -4 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -utf8 -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -utf8 -= -Some -( -yes -) -; -self -} -/ -/ -/ -Reverse -the -NFA -. -/ -/ -/ -/ -/ -/ -A -NFA -reversal -is -performed -by -reversing -all -of -the -concatenated -/ -/ -/ -sub -- -expressions -in -the -original -pattern -recursively -. -( -Look -around -/ -/ -/ -operators -are -also -inverted -. -) -The -resulting -NFA -can -be -used -to -match -/ -/ -/ -the -pattern -starting -from -the -end -of -a -string -instead -of -the -beginning -/ -/ -/ -of -a -string -. -/ -/ -/ -/ -/ -/ -Reversing -the -NFA -is -useful -for -building -a -reverse -DFA -which -is -most -/ -/ -/ -useful -for -finding -the -start -of -a -match -after -its -ending -position -has -/ -/ -/ -been -found -. -NFA -execution -engines -typically -do -not -work -on -reverse -/ -/ -/ -NFAs -. -For -example -currently -the -Pike -VM -reports -the -starting -location -/ -/ -/ -of -matches -without -a -reverse -NFA -. -/ -/ -/ -/ -/ -/ -Currently -enabling -this -setting -requires -disabling -the -/ -/ -/ -[ -captures -] -( -Config -: -: -captures -) -setting -. -If -both -are -enabled -then -the -/ -/ -/ -compiler -will -return -an -error -. -It -is -expected -that -this -limitation -will -/ -/ -/ -be -lifted -in -the -future -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -DFA -from -a -reverse -NFA -and -then -use -/ -/ -/ -the -DFA -to -search -backwards -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -dfa -: -: -{ -self -Automaton -} -/ -/ -/ -nfa -: -: -thompson -: -: -{ -NFA -WhichCaptures -} -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -dfa -= -dfa -: -: -dense -: -: -Builder -: -: -new -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -/ -/ -/ -. -which_captures -( -WhichCaptures -: -: -None -) -/ -/ -/ -. -reverse -( -true -) -/ -/ -/ -) -/ -/ -/ -. -build -( -" -baz -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -3 -) -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -expected -/ -/ -/ -dfa -. -try_search_rev -( -& -Input -: -: -new -( -" -foobaz12345bar -" -) -) -? -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reverse -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -reverse -= -Some -( -yes -) -; -self -} -/ -/ -/ -Sets -an -approximate -size -limit -on -the -total -heap -used -by -the -NFA -being -/ -/ -/ -compiled -. -/ -/ -/ -/ -/ -/ -This -permits -imposing -constraints -on -the -size -of -a -compiled -NFA -. -This -/ -/ -/ -may -be -useful -in -contexts -where -the -regex -pattern -is -untrusted -and -one -/ -/ -/ -wants -to -avoid -using -too -much -memory -. -/ -/ -/ -/ -/ -/ -This -size -limit -does -not -apply -to -auxiliary -heap -used -during -/ -/ -/ -compilation -that -is -not -part -of -the -built -NFA -. -/ -/ -/ -/ -/ -/ -Note -that -this -size -limit -is -applied -during -compilation -in -order -for -/ -/ -/ -the -limit -to -prevent -too -much -heap -from -being -used -. -However -the -/ -/ -/ -implementation -may -use -an -intermediate -NFA -representation -that -is -/ -/ -/ -otherwise -slightly -bigger -than -the -final -public -form -. -Since -the -size -/ -/ -/ -limit -may -be -applied -to -an -intermediate -representation -there -is -not -/ -/ -/ -necessarily -a -precise -correspondence -between -the -configured -size -limit -/ -/ -/ -and -the -heap -usage -of -the -final -NFA -. -/ -/ -/ -/ -/ -/ -There -is -no -size -limit -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -demonstrates -how -Unicode -mode -can -greatly -increase -the -/ -/ -/ -size -of -the -NFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -/ -/ -300KB -isn -' -t -enough -! -/ -/ -/ -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -300_000 -) -) -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -/ -/ -/ -. -unwrap_err -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -. -. -. -but -400KB -probably -is -. -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -400_000 -) -) -) -/ -/ -/ -. -build -( -r -" -\ -w -{ -20 -} -" -) -? -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -nfa -. -pattern_len -( -) -1 -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -nfa_size_limit -( -mut -self -bytes -: -Option -< -usize -> -) -- -> -Config -{ -self -. -nfa_size_limit -= -Some -( -bytes -) -; -self -} -/ -/ -/ -Apply -best -effort -heuristics -to -shrink -the -NFA -at -the -expense -of -more -/ -/ -/ -time -/ -memory -. -/ -/ -/ -/ -/ -/ -Generally -speaking -if -one -is -using -an -NFA -to -compile -a -DFA -then -the -/ -/ -/ -extra -time -used -to -shrink -the -NFA -will -be -more -than -made -up -for -during -/ -/ -/ -DFA -construction -( -potentially -by -a -lot -) -. -In -other -words -enabling -this -/ -/ -/ -can -substantially -decrease -the -overall -amount -of -time -it -takes -to -build -/ -/ -/ -a -DFA -. -/ -/ -/ -/ -/ -/ -A -reason -to -keep -this -disabled -is -if -you -want -to -compile -an -NFA -and -/ -/ -/ -start -using -it -as -quickly -as -possible -without -needing -to -build -a -DFA -/ -/ -/ -and -you -don -' -t -mind -using -a -bit -of -extra -memory -for -the -NFA -. -e -. -g -. -for -/ -/ -/ -an -NFA -simulation -or -for -a -lazy -DFA -. -/ -/ -/ -/ -/ -/ -NFA -shrinking -is -currently -most -useful -when -compiling -a -reverse -/ -/ -/ -NFA -with -large -Unicode -character -classes -. -In -particular -it -trades -/ -/ -/ -additional -CPU -time -during -NFA -compilation -in -favor -of -generating -fewer -/ -/ -/ -NFA -states -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -because -it -can -increase -compile -times -/ -/ -/ -quite -a -bit -if -you -aren -' -t -building -a -full -DFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -NFA -shrinking -can -lead -to -substantial -space -/ -/ -/ -savings -in -some -cases -. -Notice -that -as -noted -above -we -build -a -reverse -/ -/ -/ -DFA -and -use -a -pattern -with -a -large -Unicode -character -class -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -NFA -WhichCaptures -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Currently -we -have -to -disable -captures -when -enabling -reverse -NFA -. -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -/ -/ -/ -. -which_captures -( -WhichCaptures -: -: -None -) -/ -/ -/ -. -reverse -( -true -) -; -/ -/ -/ -let -not_shrunk -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -config -. -clone -( -) -. -shrink -( -false -) -) -/ -/ -/ -. -build -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -shrunk -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -config -. -clone -( -) -. -shrink -( -true -) -) -/ -/ -/ -. -build -( -r -" -\ -w -" -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -While -a -specific -shrink -factor -is -not -guaranteed -the -savings -can -be -/ -/ -/ -/ -/ -considerable -in -some -cases -. -/ -/ -/ -assert -! -( -shrunk -. -states -( -) -. -len -( -) -* -2 -< -not_shrunk -. -states -( -) -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -shrink -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -shrink -= -Some -( -yes -) -; -self -} -/ -/ -/ -Whether -to -include -' -Capture -' -states -in -the -NFA -. -/ -/ -/ -/ -/ -/ -Currently -enabling -this -setting -requires -disabling -the -/ -/ -/ -[ -reverse -] -( -Config -: -: -reverse -) -setting -. -If -both -are -enabled -then -the -/ -/ -/ -compiler -will -return -an -error -. -It -is -expected -that -this -limitation -will -/ -/ -/ -be -lifted -in -the -future -. -/ -/ -/ -/ -/ -/ -This -is -enabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -demonstrates -that -some -regex -engines -like -the -Pike -VM -/ -/ -/ -require -capturing -states -to -be -present -in -the -NFA -to -report -match -/ -/ -/ -offsets -. -/ -/ -/ -/ -/ -/ -( -Note -that -since -this -method -is -deprecated -the -example -below -uses -/ -/ -/ -[ -Config -: -: -which_captures -] -to -disable -capture -states -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -/ -/ -/ -pikevm -: -: -PikeVM -/ -/ -/ -NFA -/ -/ -/ -WhichCaptures -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -& -mut -cache -" -abc -" -) -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -& -mut -cache -" -abc -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -deprecated -( -since -= -" -0 -. -3 -. -5 -" -note -= -" -use -which_captures -instead -" -) -] -pub -fn -captures -( -self -yes -: -bool -) -- -> -Config -{ -self -. -which_captures -( -if -yes -{ -WhichCaptures -: -: -All -} -else -{ -WhichCaptures -: -: -None -} -) -} -/ -/ -/ -Configures -what -kinds -of -capture -groups -are -compiled -into -/ -/ -/ -[ -State -: -: -Capture -] -( -crate -: -: -nfa -: -: -thompson -: -: -State -: -: -Capture -) -states -in -a -/ -/ -/ -Thompson -NFA -. -/ -/ -/ -/ -/ -/ -Currently -using -any -option -except -for -[ -WhichCaptures -: -: -None -] -requires -/ -/ -/ -disabling -the -[ -reverse -] -( -Config -: -: -reverse -) -setting -. -If -both -are -/ -/ -/ -enabled -then -the -compiler -will -return -an -error -. -It -is -expected -that -/ -/ -/ -this -limitation -will -be -lifted -in -the -future -. -/ -/ -/ -/ -/ -/ -This -is -set -to -[ -WhichCaptures -: -: -All -] -by -default -. -Callers -may -wish -to -/ -/ -/ -use -[ -WhichCaptures -: -: -Implicit -] -in -cases -where -one -wants -avoid -the -/ -/ -/ -overhead -of -capture -states -for -explicit -groups -. -Usually -this -occurs -/ -/ -/ -when -one -wants -to -use -the -PikeVM -only -for -determining -the -overall -/ -/ -/ -match -. -Otherwise -the -PikeVM -could -use -much -more -memory -than -is -/ -/ -/ -necessary -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -demonstrates -that -some -regex -engines -like -the -Pike -VM -/ -/ -/ -require -capturing -states -to -be -present -in -the -NFA -to -report -match -/ -/ -/ -offsets -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -/ -/ -/ -pikevm -: -: -PikeVM -/ -/ -/ -NFA -/ -/ -/ -WhichCaptures -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -& -mut -cache -" -abc -" -) -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -& -mut -cache -" -abc -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -The -same -applies -to -the -bounded -backtracker -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -/ -/ -/ -backtrack -: -: -BoundedBacktracker -/ -/ -/ -NFA -/ -/ -/ -WhichCaptures -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -BoundedBacktracker -: -: -builder -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -try_is_match -( -& -mut -cache -" -abc -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -try_find -( -& -mut -cache -" -abc -" -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -which_captures -( -mut -self -which_captures -: -WhichCaptures -) -- -> -Config -{ -self -. -which_captures -= -Some -( -which_captures -) -; -self -} -/ -/ -/ -Sets -the -look -- -around -matcher -that -should -be -used -with -this -NFA -. -/ -/ -/ -/ -/ -/ -A -look -- -around -matcher -determines -how -to -match -look -- -around -assertions -. -/ -/ -/ -In -particular -some -assertions -are -configurable -. -For -example -the -/ -/ -/ -( -? -m -: -^ -) -and -( -? -m -: -) -assertions -can -have -their -line -terminator -changed -/ -/ -/ -from -the -default -of -\ -n -to -any -other -byte -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -change -the -line -terminator -for -multi -- -line -assertions -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -PikeVM -} -/ -/ -/ -util -: -: -look -: -: -LookMatcher -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -mut -lookm -= -LookMatcher -: -: -new -( -) -; -/ -/ -/ -lookm -. -set_line_terminator -( -b -' -\ -x00 -' -) -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -look_matcher -( -lookm -) -) -/ -/ -/ -. -build -( -r -" -( -? -m -) -^ -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Multi -- -line -assertions -now -use -NUL -as -a -terminator -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -1 -. -. -4 -) -) -/ -/ -/ -re -. -find -( -& -mut -cache -b -" -\ -x00abc -\ -x00 -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -. -. -. -and -\ -n -is -no -longer -recognized -as -a -terminator -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -None -/ -/ -/ -re -. -find -( -& -mut -cache -b -" -\ -nabc -\ -n -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -look_matcher -( -mut -self -m -: -LookMatcher -) -- -> -Config -{ -self -. -look_matcher -= -Some -( -m -) -; -self -} -/ -/ -/ -Whether -to -compile -an -unanchored -prefix -into -this -NFA -. -/ -/ -/ -/ -/ -/ -This -is -enabled -by -default -. -It -is -made -available -for -tests -only -to -make -/ -/ -/ -it -easier -to -unit -test -the -output -of -the -compiler -. -# -[ -cfg -( -test -) -] -fn -unanchored_prefix -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -unanchored_prefix -= -Some -( -yes -) -; -self -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -UTF -- -8 -mode -. -pub -fn -get_utf8 -( -& -self -) -- -> -bool -{ -self -. -utf8 -. -unwrap_or -( -true -) -} -/ -/ -/ -Returns -whether -this -configuration -has -enabled -reverse -NFA -compilation -. -pub -fn -get_reverse -( -& -self -) -- -> -bool -{ -self -. -reverse -. -unwrap_or -( -false -) -} -/ -/ -/ -Return -the -configured -NFA -size -limit -if -it -exists -in -the -number -of -/ -/ -/ -bytes -of -heap -used -. -pub -fn -get_nfa_size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -nfa_size_limit -. -unwrap_or -( -None -) -} -/ -/ -/ -Return -whether -NFA -shrinking -is -enabled -. -pub -fn -get_shrink -( -& -self -) -- -> -bool -{ -self -. -shrink -. -unwrap_or -( -false -) -} -/ -/ -/ -Return -whether -NFA -compilation -is -configured -to -produce -capture -states -. -# -[ -deprecated -( -since -= -" -0 -. -3 -. -5 -" -note -= -" -use -get_which_captures -instead -" -) -] -pub -fn -get_captures -( -& -self -) -- -> -bool -{ -self -. -get_which_captures -( -) -. -is_any -( -) -} -/ -/ -/ -Return -what -kinds -of -capture -states -will -be -compiled -into -an -NFA -. -pub -fn -get_which_captures -( -& -self -) -- -> -WhichCaptures -{ -self -. -which_captures -. -unwrap_or -( -WhichCaptures -: -: -All -) -} -/ -/ -/ -Return -the -look -- -around -matcher -for -this -NFA -. -pub -fn -get_look_matcher -( -& -self -) -- -> -LookMatcher -{ -self -. -look_matcher -. -clone -( -) -. -unwrap_or -( -LookMatcher -: -: -default -( -) -) -} -/ -/ -/ -Return -whether -NFA -compilation -is -configured -to -include -an -unanchored -/ -/ -/ -prefix -. -/ -/ -/ -/ -/ -/ -This -is -always -false -when -not -in -test -mode -. -fn -get_unanchored_prefix -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -test -) -] -{ -self -. -unanchored_prefix -. -unwrap_or -( -true -) -} -# -[ -cfg -( -not -( -test -) -) -] -{ -true -} -} -/ -/ -/ -Overwrite -the -default -configuration -such -that -the -options -in -o -are -/ -/ -/ -always -used -. -If -an -option -in -o -is -not -set -then -the -corresponding -/ -/ -/ -option -in -self -is -used -. -If -it -' -s -not -set -in -self -either -then -it -/ -/ -/ -remains -not -set -. -pub -( -crate -) -fn -overwrite -( -& -self -o -: -Config -) -- -> -Config -{ -Config -{ -utf8 -: -o -. -utf8 -. -or -( -self -. -utf8 -) -reverse -: -o -. -reverse -. -or -( -self -. -reverse -) -nfa_size_limit -: -o -. -nfa_size_limit -. -or -( -self -. -nfa_size_limit -) -shrink -: -o -. -shrink -. -or -( -self -. -shrink -) -which_captures -: -o -. -which_captures -. -or -( -self -. -which_captures -) -look_matcher -: -o -. -look_matcher -. -or_else -( -| -| -self -. -look_matcher -. -clone -( -) -) -# -[ -cfg -( -test -) -] -unanchored_prefix -: -o -. -unanchored_prefix -. -or -( -self -. -unanchored_prefix -) -} -} -} -/ -/ -/ -A -configuration -indicating -which -kinds -of -/ -/ -/ -[ -State -: -: -Capture -] -( -crate -: -: -nfa -: -: -thompson -: -: -State -: -: -Capture -) -states -to -include -. -/ -/ -/ -/ -/ -/ -This -configuration -can -be -used -with -[ -Config -: -: -which_captures -] -to -control -/ -/ -/ -which -capture -states -are -compiled -into -a -Thompson -NFA -. -/ -/ -/ -/ -/ -/ -The -default -configuration -is -[ -WhichCaptures -: -: -All -] -. -# -[ -derive -( -Clone -Copy -Debug -) -] -pub -enum -WhichCaptures -{ -/ -/ -/ -All -capture -states -including -those -corresponding -to -both -implicit -and -/ -/ -/ -explicit -capture -groups -are -included -in -the -Thompson -NFA -. -All -/ -/ -/ -Only -capture -states -corresponding -to -implicit -capture -groups -are -/ -/ -/ -included -. -Implicit -capture -groups -appear -in -every -pattern -implicitly -/ -/ -/ -and -correspond -to -the -overall -match -of -a -pattern -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -one -only -cares -about -the -overall -match -of -a -/ -/ -/ -pattern -. -By -excluding -capture -states -from -explicit -capture -groups -/ -/ -/ -one -might -be -able -to -reduce -the -memory -usage -of -a -multi -- -pattern -regex -/ -/ -/ -substantially -if -it -was -otherwise -written -to -have -many -explicit -capture -/ -/ -/ -groups -. -Implicit -/ -/ -/ -No -capture -states -are -compiled -into -the -Thompson -NFA -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -capture -states -are -either -not -needed -( -for -example -/ -/ -/ -if -one -is -only -trying -to -build -a -DFA -) -or -if -they -aren -' -t -supported -( -for -/ -/ -/ -example -a -reverse -NFA -) -. -None -} -impl -Default -for -WhichCaptures -{ -fn -default -( -) -- -> -WhichCaptures -{ -WhichCaptures -: -: -All -} -} -impl -WhichCaptures -{ -/ -/ -/ -Returns -true -if -this -configuration -indicates -that -no -capture -states -/ -/ -/ -should -be -produced -in -an -NFA -. -pub -fn -is_none -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -WhichCaptures -: -: -None -) -} -/ -/ -/ -Returns -true -if -this -configuration -indicates -that -some -capture -states -/ -/ -/ -should -be -added -to -an -NFA -. -Note -that -this -might -only -include -capture -/ -/ -/ -states -for -implicit -capture -groups -. -pub -fn -is_any -( -& -self -) -- -> -bool -{ -! -self -. -is_none -( -) -} -} -/ -* -This -compiler -below -uses -Thompson -' -s -construction -algorithm -. -The -compiler -takes -a -regex -- -syntax -: -: -Hir -as -input -and -emits -an -NFA -graph -as -output -. -The -NFA -graph -is -structured -in -a -way -that -permits -it -to -be -executed -by -a -virtual -machine -and -also -used -to -efficiently -build -a -DFA -. -The -compiler -deals -with -a -slightly -expanded -set -of -NFA -states -than -what -is -in -a -final -NFA -( -as -exhibited -by -builder -: -: -State -and -nfa -: -: -State -) -. -Notably -a -compiler -state -includes -an -empty -node -that -has -exactly -one -unconditional -epsilon -transition -to -the -next -state -. -In -other -words -it -' -s -a -" -goto -" -instruction -if -one -views -Thompson -' -s -NFA -as -a -set -of -bytecode -instructions -. -These -goto -instructions -are -removed -in -a -subsequent -phase -before -returning -the -NFA -to -the -caller -. -The -purpose -of -these -empty -nodes -is -that -they -make -the -construction -algorithm -substantially -simpler -to -implement -. -We -remove -them -before -returning -to -the -caller -because -they -can -represent -substantial -overhead -when -traversing -the -NFA -graph -( -either -while -searching -using -the -NFA -directly -or -while -building -a -DFA -) -. -In -the -future -it -would -be -nice -to -provide -a -Glushkov -compiler -as -well -as -it -would -work -well -as -a -bit -- -parallel -NFA -for -smaller -regexes -. -But -the -Thompson -construction -is -one -I -' -m -more -familiar -with -and -seems -more -straight -- -forward -to -deal -with -when -it -comes -to -large -Unicode -character -classes -. -Internally -the -compiler -uses -interior -mutability -to -improve -composition -in -the -face -of -the -borrow -checker -. -In -particular -we -' -d -really -like -to -be -able -to -write -things -like -this -: -self -. -c_concat -( -exprs -. -iter -( -) -. -map -( -| -e -| -self -. -c -( -e -) -) -) -Which -elegantly -uses -iterators -to -build -up -a -sequence -of -compiled -regex -sub -- -expressions -and -then -hands -it -off -to -the -concatenating -compiler -routine -. -Without -interior -mutability -the -borrow -checker -won -' -t -let -us -borrow -self -mutably -both -inside -and -outside -the -closure -at -the -same -time -. -* -/ -/ -/ -/ -A -builder -for -compiling -an -NFA -from -a -regex -' -s -high -- -level -intermediate -/ -/ -/ -representation -( -HIR -) -. -/ -/ -/ -/ -/ -/ -This -compiler -provides -a -way -to -translate -a -parsed -regex -pattern -into -an -/ -/ -/ -NFA -state -graph -. -The -NFA -state -graph -can -either -be -used -directly -to -execute -/ -/ -/ -a -search -( -e -. -g -. -with -a -Pike -VM -) -or -it -can -be -further -used -to -build -a -DFA -. -/ -/ -/ -/ -/ -/ -This -compiler -provides -APIs -both -for -compiling -regex -patterns -directly -from -/ -/ -/ -their -concrete -syntax -or -via -a -[ -regex_syntax -: -: -hir -: -: -Hir -] -. -/ -/ -/ -/ -/ -/ -This -compiler -has -various -options -that -may -be -configured -via -/ -/ -/ -[ -thompson -: -: -Config -] -( -Config -) -. -/ -/ -/ -/ -/ -/ -Note -that -a -compiler -is -not -the -same -as -a -[ -thompson -: -: -Builder -] -( -Builder -) -. -/ -/ -/ -A -Builder -provides -a -lower -level -API -that -is -uncoupled -from -a -regex -/ -/ -/ -pattern -' -s -concrete -syntax -or -even -its -HIR -. -Instead -it -permits -stitching -/ -/ -/ -together -an -NFA -by -hand -. -See -its -docs -for -examples -. -/ -/ -/ -/ -/ -/ -# -Example -: -compilation -from -concrete -syntax -/ -/ -/ -/ -/ -/ -This -shows -how -to -compile -an -NFA -from -a -pattern -string -while -setting -a -size -/ -/ -/ -limit -on -how -big -the -NFA -is -allowed -to -be -( -in -terms -of -bytes -of -heap -used -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build -( -r -" -( -? -- -u -) -\ -w -" -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -3 -. -. -4 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -! -# -A -# -! -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -compilation -from -HIR -/ -/ -/ -/ -/ -/ -This -shows -how -to -hand -assemble -a -regular -expression -via -its -HIR -and -then -/ -/ -/ -compile -an -NFA -directly -from -it -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -Match -} -; -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -{ -Hir -Class -ClassBytes -ClassBytesRange -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new -( -vec -! -[ -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -0 -' -b -' -9 -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -A -' -b -' -Z -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -_ -' -b -' -_ -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -a -' -b -' -z -' -) -/ -/ -/ -] -) -) -) -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_from_hir -( -& -hir -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -3 -. -. -4 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -! -# -A -# -! -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Compiler -{ -/ -/ -/ -A -regex -parser -used -when -compiling -an -NFA -directly -from -a -pattern -/ -/ -/ -string -. -parser -: -ParserBuilder -/ -/ -/ -The -compiler -configuration -. -config -: -Config -/ -/ -/ -The -builder -for -actually -constructing -an -NFA -. -This -provides -a -/ -/ -/ -convenient -abstraction -for -writing -a -compiler -. -builder -: -RefCell -< -Builder -> -/ -/ -/ -State -used -for -compiling -character -classes -to -UTF -- -8 -byte -automata -. -/ -/ -/ -State -is -not -retained -between -character -class -compilations -. -This -just -/ -/ -/ -serves -to -amortize -allocation -to -the -extent -possible -. -utf8_state -: -RefCell -< -Utf8State -> -/ -/ -/ -State -used -for -arranging -character -classes -in -reverse -into -a -trie -. -trie_state -: -RefCell -< -RangeTrie -> -/ -/ -/ -State -used -for -caching -common -suffixes -when -compiling -reverse -UTF -- -8 -/ -/ -/ -automata -( -for -Unicode -character -classes -) -. -utf8_suffix -: -RefCell -< -Utf8SuffixMap -> -} -impl -Compiler -{ -/ -/ -/ -Create -a -new -NFA -builder -with -its -default -configuration -. -pub -fn -new -( -) -- -> -Compiler -{ -Compiler -{ -parser -: -ParserBuilder -: -: -new -( -) -config -: -Config -: -: -default -( -) -builder -: -RefCell -: -: -new -( -Builder -: -: -new -( -) -) -utf8_state -: -RefCell -: -: -new -( -Utf8State -: -: -new -( -) -) -trie_state -: -RefCell -: -: -new -( -RangeTrie -: -: -new -( -) -) -utf8_suffix -: -RefCell -: -: -new -( -Utf8SuffixMap -: -: -new -( -1000 -) -) -} -} -/ -/ -/ -Compile -the -given -regular -expression -pattern -into -an -NFA -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -the -regex -then -that -error -is -returned -. -/ -/ -/ -/ -/ -/ -Otherwise -if -there -was -a -problem -building -the -NFA -then -an -error -is -/ -/ -/ -returned -. -The -only -error -that -can -occur -is -if -the -compiled -regex -would -/ -/ -/ -exceed -the -size -limits -configured -on -this -builder -or -if -any -part -of -/ -/ -/ -the -NFA -would -exceed -the -integer -representations -used -. -( -For -example -/ -/ -/ -too -many -states -might -plausibly -occur -on -a -16 -- -bit -target -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -Match -} -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build -( -r -" -( -? -- -u -) -\ -w -" -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -3 -. -. -4 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -! -# -A -# -! -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -NFA -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Compile -the -given -regular -expression -patterns -into -a -single -NFA -. -/ -/ -/ -/ -/ -/ -When -matches -are -returned -the -pattern -ID -corresponds -to -the -index -of -/ -/ -/ -the -pattern -in -the -slice -given -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -Match -} -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_many -( -& -[ -/ -/ -/ -r -" -( -? -- -u -) -\ -s -" -/ -/ -/ -r -" -( -? -- -u -) -\ -w -" -/ -/ -/ -] -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -1 -1 -. -. -2 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -! -A -! -! -A -! -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -NFA -BuildError -> -{ -let -mut -hirs -= -vec -! -[ -] -; -for -p -in -patterns -{ -hirs -. -push -( -self -. -parser -. -build -( -) -. -parse -( -p -. -as_ref -( -) -) -. -map_err -( -BuildError -: -: -syntax -) -? -) -; -debug -! -( -" -parsed -: -{ -: -? -} -" -p -. -as_ref -( -) -) -; -} -self -. -build_many_from_hir -( -& -hirs -) -} -/ -/ -/ -Compile -the -given -high -level -intermediate -representation -of -a -regular -/ -/ -/ -expression -into -an -NFA -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -building -the -NFA -then -an -error -is -returned -. -The -/ -/ -/ -only -error -that -can -occur -is -if -the -compiled -regex -would -exceed -the -/ -/ -/ -size -limits -configured -on -this -builder -or -if -any -part -of -the -NFA -would -/ -/ -/ -exceed -the -integer -representations -used -. -( -For -example -too -many -states -/ -/ -/ -might -plausibly -occur -on -a -16 -- -bit -target -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -Match -} -; -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -{ -Hir -Class -ClassBytes -ClassBytesRange -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new -( -vec -! -[ -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -0 -' -b -' -9 -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -A -' -b -' -Z -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -_ -' -b -' -_ -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -a -' -b -' -z -' -) -/ -/ -/ -] -) -) -) -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_from_hir -( -& -hir -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -3 -. -. -4 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -! -# -A -# -! -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_from_hir -( -& -self -expr -: -& -Hir -) -- -> -Result -< -NFA -BuildError -> -{ -self -. -build_many_from_hir -( -& -[ -expr -] -) -} -/ -/ -/ -Compile -the -given -high -level -intermediate -representations -of -regular -/ -/ -/ -expressions -into -a -single -NFA -. -/ -/ -/ -/ -/ -/ -When -matches -are -returned -the -pattern -ID -corresponds -to -the -index -of -/ -/ -/ -the -pattern -in -the -slice -given -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -Match -} -; -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -{ -Hir -Class -ClassBytes -ClassBytesRange -} -; -/ -/ -/ -/ -/ -/ -let -hirs -= -& -[ -/ -/ -/ -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new -( -vec -! -[ -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -\ -t -' -b -' -\ -r -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -' -b -' -' -) -/ -/ -/ -] -) -) -) -/ -/ -/ -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new -( -vec -! -[ -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -0 -' -b -' -9 -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -A -' -b -' -Z -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -_ -' -b -' -_ -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -a -' -b -' -z -' -) -/ -/ -/ -] -) -) -) -/ -/ -/ -] -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_many_from_hir -( -hirs -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -1 -1 -. -. -2 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -! -A -! -! -A -! -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -build_many_from_hir -< -H -: -Borrow -< -Hir -> -> -( -& -self -exprs -: -& -[ -H -] -) -- -> -Result -< -NFA -BuildError -> -{ -self -. -compile -( -exprs -) -} -/ -/ -/ -Apply -the -given -NFA -configuration -options -to -this -builder -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build -( -r -" -( -? -- -u -) -\ -w -" -) -? -; -/ -/ -/ -assert_eq -! -( -nfa -. -pattern_len -( -) -1 -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -configure -( -& -mut -self -config -: -Config -) -- -> -& -mut -Compiler -{ -self -. -config -= -self -. -config -. -overwrite -( -config -) -; -self -} -/ -/ -/ -Set -the -syntax -configuration -for -this -builder -using -/ -/ -/ -[ -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -case -insensitivity -Unicode -and -multi -/ -/ -/ -line -mode -. -/ -/ -/ -/ -/ -/ -This -syntax -configuration -only -applies -when -an -NFA -is -built -directly -/ -/ -/ -from -a -pattern -string -. -If -an -NFA -is -built -from -an -HIR -then -all -syntax -/ -/ -/ -settings -are -ignored -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -util -: -: -syntax -} -; -/ -/ -/ -/ -/ -/ -let -syntax_config -= -syntax -: -: -Config -: -: -new -( -) -. -unicode -( -false -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -syntax -( -syntax_config -) -. -build -( -r -" -\ -w -" -) -? -; -/ -/ -/ -/ -/ -If -Unicode -were -enabled -the -number -of -states -would -be -much -bigger -. -/ -/ -/ -assert -! -( -nfa -. -states -( -) -. -len -( -) -< -15 -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Compiler -{ -config -. -apply -( -& -mut -self -. -parser -) -; -self -} -} -impl -Compiler -{ -/ -/ -/ -Compile -the -sequence -of -HIR -expressions -given -. -Pattern -IDs -are -/ -/ -/ -allocated -starting -from -0 -in -correspondence -with -the -slice -given -. -/ -/ -/ -/ -/ -/ -It -is -legal -to -provide -an -empty -slice -. -In -that -case -the -NFA -returned -/ -/ -/ -has -no -patterns -and -will -never -match -anything -. -fn -compile -< -H -: -Borrow -< -Hir -> -> -( -& -self -exprs -: -& -[ -H -] -) -- -> -Result -< -NFA -BuildError -> -{ -if -exprs -. -len -( -) -> -PatternID -: -: -LIMIT -{ -return -Err -( -BuildError -: -: -too_many_patterns -( -exprs -. -len -( -) -) -) -; -} -if -self -. -config -. -get_reverse -( -) -& -& -self -. -config -. -get_which_captures -( -) -. -is_any -( -) -{ -return -Err -( -BuildError -: -: -unsupported_captures -( -) -) -; -} -self -. -builder -. -borrow_mut -( -) -. -clear -( -) -; -self -. -builder -. -borrow_mut -( -) -. -set_utf8 -( -self -. -config -. -get_utf8 -( -) -) -; -self -. -builder -. -borrow_mut -( -) -. -set_reverse -( -self -. -config -. -get_reverse -( -) -) -; -self -. -builder -. -borrow_mut -( -) -. -set_look_matcher -( -self -. -config -. -get_look_matcher -( -) -) -; -self -. -builder -. -borrow_mut -( -) -. -set_size_limit -( -self -. -config -. -get_nfa_size_limit -( -) -) -? -; -/ -/ -We -always -add -an -unanchored -prefix -unless -we -were -specifically -told -/ -/ -not -to -( -for -tests -only -) -or -if -we -know -that -the -regex -is -anchored -/ -/ -for -all -matches -. -When -an -unanchored -prefix -is -not -added -then -the -/ -/ -NFA -' -s -anchored -and -unanchored -start -states -are -equivalent -. -let -all_anchored -= -exprs -. -iter -( -) -. -all -( -| -e -| -{ -e -. -borrow -( -) -. -properties -( -) -. -look_set_prefix -( -) -. -contains -( -hir -: -: -Look -: -: -Start -) -} -) -; -let -anchored -= -! -self -. -config -. -get_unanchored_prefix -( -) -| -| -all_anchored -; -let -unanchored_prefix -= -if -anchored -{ -self -. -c_empty -( -) -? -} -else -{ -self -. -c_at_least -( -& -Hir -: -: -dot -( -hir -: -: -Dot -: -: -AnyByte -) -false -0 -) -? -} -; -let -compiled -= -self -. -c_alt_iter -( -exprs -. -iter -( -) -. -map -( -| -e -| -{ -let -_ -= -self -. -start_pattern -( -) -? -; -let -one -= -self -. -c_cap -( -0 -None -e -. -borrow -( -) -) -? -; -let -match_state_id -= -self -. -add_match -( -) -? -; -self -. -patch -( -one -. -end -match_state_id -) -? -; -let -_ -= -self -. -finish_pattern -( -one -. -start -) -? -; -Ok -( -ThompsonRef -{ -start -: -one -. -start -end -: -match_state_id -} -) -} -) -) -? -; -self -. -patch -( -unanchored_prefix -. -end -compiled -. -start -) -? -; -let -nfa -= -self -. -builder -. -borrow_mut -( -) -. -build -( -compiled -. -start -unanchored_prefix -. -start -) -? -; -debug -! -( -" -HIR -- -to -- -NFA -compilation -complete -config -: -{ -: -? -} -" -self -. -config -) -; -Ok -( -nfa -) -} -/ -/ -/ -Compile -an -arbitrary -HIR -expression -. -fn -c -( -& -self -expr -: -& -Hir -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -use -regex_syntax -: -: -hir -: -: -{ -Class -HirKind -: -: -* -} -; -match -* -expr -. -kind -( -) -{ -Empty -= -> -self -. -c_empty -( -) -Literal -( -hir -: -: -Literal -( -ref -bytes -) -) -= -> -self -. -c_literal -( -bytes -) -Class -( -Class -: -: -Bytes -( -ref -c -) -) -= -> -self -. -c_byte_class -( -c -) -Class -( -Class -: -: -Unicode -( -ref -c -) -) -= -> -self -. -c_unicode_class -( -c -) -Look -( -ref -look -) -= -> -self -. -c_look -( -look -) -Repetition -( -ref -rep -) -= -> -self -. -c_repetition -( -rep -) -Capture -( -ref -c -) -= -> -self -. -c_cap -( -c -. -index -c -. -name -. -as_deref -( -) -& -c -. -sub -) -Concat -( -ref -es -) -= -> -self -. -c_concat -( -es -. -iter -( -) -. -map -( -| -e -| -self -. -c -( -e -) -) -) -Alternation -( -ref -es -) -= -> -self -. -c_alt_slice -( -es -) -} -} -/ -/ -/ -Compile -a -concatenation -of -the -sub -- -expressions -yielded -by -the -given -/ -/ -/ -iterator -. -If -the -iterator -yields -no -elements -then -this -compiles -down -/ -/ -/ -to -an -" -empty -" -state -that -always -matches -. -/ -/ -/ -/ -/ -/ -If -the -compiler -is -in -reverse -mode -then -the -expressions -given -are -/ -/ -/ -automatically -compiled -in -reverse -. -fn -c_concat -< -I -> -( -& -self -mut -it -: -I -) -- -> -Result -< -ThompsonRef -BuildError -> -where -I -: -DoubleEndedIterator -< -Item -= -Result -< -ThompsonRef -BuildError -> -> -{ -let -first -= -if -self -. -is_reverse -( -) -{ -it -. -next_back -( -) -} -else -{ -it -. -next -( -) -} -; -let -ThompsonRef -{ -start -mut -end -} -= -match -first -{ -Some -( -result -) -= -> -result -? -None -= -> -return -self -. -c_empty -( -) -} -; -loop -{ -let -next -= -if -self -. -is_reverse -( -) -{ -it -. -next_back -( -) -} -else -{ -it -. -next -( -) -} -; -let -compiled -= -match -next -{ -Some -( -result -) -= -> -result -? -None -= -> -break -} -; -self -. -patch -( -end -compiled -. -start -) -? -; -end -= -compiled -. -end -; -} -Ok -( -ThompsonRef -{ -start -end -} -) -} -/ -/ -/ -Compile -an -alternation -of -the -given -HIR -values -. -/ -/ -/ -/ -/ -/ -This -is -like -' -c_alt_iter -' -but -it -accepts -a -slice -of -HIR -values -instead -/ -/ -/ -of -an -iterator -of -compiled -NFA -subgraphs -. -The -point -of -accepting -a -/ -/ -/ -slice -here -is -that -it -opens -up -some -optimization -opportunities -. -For -/ -/ -/ -example -if -all -of -the -HIR -values -are -literals -then -this -routine -might -/ -/ -/ -re -- -shuffle -them -to -make -NFA -epsilon -closures -substantially -faster -. -fn -c_alt_slice -( -& -self -exprs -: -& -[ -Hir -] -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -/ -/ -self -. -c_alt_iter -( -exprs -. -iter -( -) -. -map -( -| -e -| -self -. -c -( -e -) -) -) -let -literal_count -= -exprs -. -iter -( -) -. -filter -( -| -e -| -{ -matches -! -( -* -e -. -kind -( -) -hir -: -: -HirKind -: -: -Literal -( -hir -: -: -Literal -( -_ -) -) -) -} -) -. -count -( -) -; -if -literal_count -< -= -1 -| -| -literal_count -< -exprs -. -len -( -) -{ -return -self -. -c_alt_iter -( -exprs -. -iter -( -) -. -map -( -| -e -| -self -. -c -( -e -) -) -) -; -} -let -mut -trie -= -if -self -. -is_reverse -( -) -{ -LiteralTrie -: -: -reverse -( -) -} -else -{ -LiteralTrie -: -: -forward -( -) -} -; -for -expr -in -exprs -. -iter -( -) -{ -let -literal -= -match -* -expr -. -kind -( -) -{ -hir -: -: -HirKind -: -: -Literal -( -hir -: -: -Literal -( -ref -bytes -) -) -= -> -bytes -_ -= -> -unreachable -! -( -) -} -; -trie -. -add -( -literal -) -? -; -} -trie -. -compile -( -& -mut -self -. -builder -. -borrow_mut -( -) -) -} -/ -/ -/ -Compile -an -alternation -where -each -element -yielded -by -the -given -/ -/ -/ -iterator -represents -an -item -in -the -alternation -. -If -the -iterator -yields -/ -/ -/ -no -elements -then -this -compiles -down -to -a -" -fail -" -state -. -/ -/ -/ -/ -/ -/ -In -an -alternation -expressions -appearing -earlier -are -" -preferred -" -at -/ -/ -/ -match -time -over -expressions -appearing -later -. -At -least -this -is -true -/ -/ -/ -when -using -" -leftmost -first -" -match -semantics -. -( -If -" -leftmost -longest -" -are -/ -/ -/ -ever -added -in -the -future -then -this -preference -order -of -priority -would -/ -/ -/ -not -apply -in -that -mode -. -) -fn -c_alt_iter -< -I -> -( -& -self -mut -it -: -I -) -- -> -Result -< -ThompsonRef -BuildError -> -where -I -: -Iterator -< -Item -= -Result -< -ThompsonRef -BuildError -> -> -{ -let -first -= -match -it -. -next -( -) -{ -None -= -> -return -self -. -c_fail -( -) -Some -( -result -) -= -> -result -? -} -; -let -second -= -match -it -. -next -( -) -{ -None -= -> -return -Ok -( -first -) -Some -( -result -) -= -> -result -? -} -; -let -union -= -self -. -add_union -( -) -? -; -let -end -= -self -. -add_empty -( -) -? -; -self -. -patch -( -union -first -. -start -) -? -; -self -. -patch -( -first -. -end -end -) -? -; -self -. -patch -( -union -second -. -start -) -? -; -self -. -patch -( -second -. -end -end -) -? -; -for -result -in -it -{ -let -compiled -= -result -? -; -self -. -patch -( -union -compiled -. -start -) -? -; -self -. -patch -( -compiled -. -end -end -) -? -; -} -Ok -( -ThompsonRef -{ -start -: -union -end -} -) -} -/ -/ -/ -Compile -the -given -capture -sub -- -expression -. -expr -should -be -the -/ -/ -/ -sub -- -expression -contained -inside -the -capture -. -If -" -capture -" -states -are -/ -/ -/ -enabled -then -they -are -added -as -appropriate -. -/ -/ -/ -/ -/ -/ -This -accepts -the -pieces -of -a -capture -instead -of -a -hir -: -: -Capture -so -/ -/ -/ -that -it -' -s -easy -to -manufacture -a -" -fake -" -group -when -necessary -e -. -g -. -for -/ -/ -/ -adding -the -entire -pattern -as -if -it -were -a -group -in -order -to -create -/ -/ -/ -appropriate -" -capture -" -states -in -the -NFA -. -fn -c_cap -( -& -self -index -: -u32 -name -: -Option -< -& -str -> -expr -: -& -Hir -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -match -self -. -config -. -get_which_captures -( -) -{ -/ -/ -No -capture -states -means -we -always -skip -them -. -WhichCaptures -: -: -None -= -> -return -self -. -c -( -expr -) -/ -/ -Implicit -captures -states -means -we -only -add -when -index -= -= -0 -since -/ -/ -index -= -= -0 -implies -the -group -is -implicit -. -WhichCaptures -: -: -Implicit -if -index -> -0 -= -> -return -self -. -c -( -expr -) -_ -= -> -{ -} -} -let -start -= -self -. -add_capture_start -( -index -name -) -? -; -let -inner -= -self -. -c -( -expr -) -? -; -let -end -= -self -. -add_capture_end -( -index -) -? -; -self -. -patch -( -start -inner -. -start -) -? -; -self -. -patch -( -inner -. -end -end -) -? -; -Ok -( -ThompsonRef -{ -start -end -} -) -} -/ -/ -/ -Compile -the -given -repetition -expression -. -This -handles -all -types -of -/ -/ -/ -repetitions -and -greediness -. -fn -c_repetition -( -& -self -rep -: -& -hir -: -: -Repetition -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -match -( -rep -. -min -rep -. -max -) -{ -( -0 -Some -( -1 -) -) -= -> -self -. -c_zero_or_one -( -& -rep -. -sub -rep -. -greedy -) -( -min -None -) -= -> -self -. -c_at_least -( -& -rep -. -sub -rep -. -greedy -min -) -( -min -Some -( -max -) -) -if -min -= -= -max -= -> -self -. -c_exactly -( -& -rep -. -sub -min -) -( -min -Some -( -max -) -) -= -> -self -. -c_bounded -( -& -rep -. -sub -rep -. -greedy -min -max -) -} -} -/ -/ -/ -Compile -the -given -expression -such -that -it -matches -at -least -min -times -/ -/ -/ -but -no -more -than -max -times -. -/ -/ -/ -/ -/ -/ -When -greedy -is -true -then -the -preference -is -for -the -expression -to -/ -/ -/ -match -as -much -as -possible -. -Otherwise -it -will -match -as -little -as -/ -/ -/ -possible -. -fn -c_bounded -( -& -self -expr -: -& -Hir -greedy -: -bool -min -: -u32 -max -: -u32 -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -let -prefix -= -self -. -c_exactly -( -expr -min -) -? -; -if -min -= -= -max -{ -return -Ok -( -prefix -) -; -} -/ -/ -It -is -tempting -here -to -compile -the -rest -here -as -a -concatenation -/ -/ -of -zero -- -or -- -one -matches -. -i -. -e -. -for -a -{ -2 -5 -} -compile -it -as -if -it -/ -/ -were -aaa -? -a -? -a -? -. -The -problem -here -is -that -it -leads -to -this -program -: -/ -/ -/ -/ -> -000000 -: -61 -= -> -01 -/ -/ -000001 -: -61 -= -> -02 -/ -/ -000002 -: -union -( -03 -04 -) -/ -/ -000003 -: -61 -= -> -04 -/ -/ -000004 -: -union -( -05 -06 -) -/ -/ -000005 -: -61 -= -> -06 -/ -/ -000006 -: -union -( -07 -08 -) -/ -/ -000007 -: -61 -= -> -08 -/ -/ -000008 -: -MATCH -/ -/ -/ -/ -And -effectively -once -you -hit -state -2 -the -epsilon -closure -will -/ -/ -include -states -3 -5 -6 -7 -and -8 -which -is -quite -a -bit -. -It -is -better -/ -/ -to -instead -compile -it -like -so -: -/ -/ -/ -/ -> -000000 -: -61 -= -> -01 -/ -/ -000001 -: -61 -= -> -02 -/ -/ -000002 -: -union -( -03 -08 -) -/ -/ -000003 -: -61 -= -> -04 -/ -/ -000004 -: -union -( -05 -08 -) -/ -/ -000005 -: -61 -= -> -06 -/ -/ -000006 -: -union -( -07 -08 -) -/ -/ -000007 -: -61 -= -> -08 -/ -/ -000008 -: -MATCH -/ -/ -/ -/ -So -that -the -epsilon -closure -of -state -2 -is -now -just -3 -and -8 -. -let -empty -= -self -. -add_empty -( -) -? -; -let -mut -prev_end -= -prefix -. -end -; -for -_ -in -min -. -. -max -{ -let -union -= -if -greedy -{ -self -. -add_union -( -) -} -else -{ -self -. -add_union_reverse -( -) -} -? -; -let -compiled -= -self -. -c -( -expr -) -? -; -self -. -patch -( -prev_end -union -) -? -; -self -. -patch -( -union -compiled -. -start -) -? -; -self -. -patch -( -union -empty -) -? -; -prev_end -= -compiled -. -end -; -} -self -. -patch -( -prev_end -empty -) -? -; -Ok -( -ThompsonRef -{ -start -: -prefix -. -start -end -: -empty -} -) -} -/ -/ -/ -Compile -the -given -expression -such -that -it -may -be -matched -n -or -more -/ -/ -/ -times -where -n -can -be -any -integer -. -( -Although -a -particularly -large -/ -/ -/ -integer -is -likely -to -run -afoul -of -any -configured -size -limits -. -) -/ -/ -/ -/ -/ -/ -When -greedy -is -true -then -the -preference -is -for -the -expression -to -/ -/ -/ -match -as -much -as -possible -. -Otherwise -it -will -match -as -little -as -/ -/ -/ -possible -. -fn -c_at_least -( -& -self -expr -: -& -Hir -greedy -: -bool -n -: -u32 -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -if -n -= -= -0 -{ -/ -/ -When -the -expression -cannot -match -the -empty -string -then -we -/ -/ -can -get -away -with -something -much -simpler -: -just -one -' -alt -' -/ -/ -instruction -that -optionally -repeats -itself -. -But -if -the -expr -/ -/ -can -match -the -empty -string -. -. -. -see -below -. -if -expr -. -properties -( -) -. -minimum_len -( -) -. -map_or -( -false -| -len -| -len -> -0 -) -{ -let -union -= -if -greedy -{ -self -. -add_union -( -) -} -else -{ -self -. -add_union_reverse -( -) -} -? -; -let -compiled -= -self -. -c -( -expr -) -? -; -self -. -patch -( -union -compiled -. -start -) -? -; -self -. -patch -( -compiled -. -end -union -) -? -; -return -Ok -( -ThompsonRef -{ -start -: -union -end -: -union -} -) -; -} -/ -/ -What -' -s -going -on -here -? -Shouldn -' -t -x -* -be -simpler -than -this -? -It -/ -/ -turns -out -that -when -implementing -leftmost -- -first -( -Perl -- -like -) -/ -/ -match -semantics -x -* -results -in -an -incorrect -preference -order -/ -/ -when -computing -the -transitive -closure -of -states -if -and -only -if -/ -/ -' -x -' -can -match -the -empty -string -. -So -instead -we -compile -x -* -as -/ -/ -( -x -+ -) -? -which -preserves -the -correct -preference -order -. -/ -/ -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -779 -let -compiled -= -self -. -c -( -expr -) -? -; -let -plus -= -if -greedy -{ -self -. -add_union -( -) -} -else -{ -self -. -add_union_reverse -( -) -} -? -; -self -. -patch -( -compiled -. -end -plus -) -? -; -self -. -patch -( -plus -compiled -. -start -) -? -; -let -question -= -if -greedy -{ -self -. -add_union -( -) -} -else -{ -self -. -add_union_reverse -( -) -} -? -; -let -empty -= -self -. -add_empty -( -) -? -; -self -. -patch -( -question -compiled -. -start -) -? -; -self -. -patch -( -question -empty -) -? -; -self -. -patch -( -plus -empty -) -? -; -Ok -( -ThompsonRef -{ -start -: -question -end -: -empty -} -) -} -else -if -n -= -= -1 -{ -let -compiled -= -self -. -c -( -expr -) -? -; -let -union -= -if -greedy -{ -self -. -add_union -( -) -} -else -{ -self -. -add_union_reverse -( -) -} -? -; -self -. -patch -( -compiled -. -end -union -) -? -; -self -. -patch -( -union -compiled -. -start -) -? -; -Ok -( -ThompsonRef -{ -start -: -compiled -. -start -end -: -union -} -) -} -else -{ -let -prefix -= -self -. -c_exactly -( -expr -n -- -1 -) -? -; -let -last -= -self -. -c -( -expr -) -? -; -let -union -= -if -greedy -{ -self -. -add_union -( -) -} -else -{ -self -. -add_union_reverse -( -) -} -? -; -self -. -patch -( -prefix -. -end -last -. -start -) -? -; -self -. -patch -( -last -. -end -union -) -? -; -self -. -patch -( -union -last -. -start -) -? -; -Ok -( -ThompsonRef -{ -start -: -prefix -. -start -end -: -union -} -) -} -} -/ -/ -/ -Compile -the -given -expression -such -that -it -may -be -matched -zero -or -one -/ -/ -/ -times -. -/ -/ -/ -/ -/ -/ -When -greedy -is -true -then -the -preference -is -for -the -expression -to -/ -/ -/ -match -as -much -as -possible -. -Otherwise -it -will -match -as -little -as -/ -/ -/ -possible -. -fn -c_zero_or_one -( -& -self -expr -: -& -Hir -greedy -: -bool -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -let -union -= -if -greedy -{ -self -. -add_union -( -) -} -else -{ -self -. -add_union_reverse -( -) -} -? -; -let -compiled -= -self -. -c -( -expr -) -? -; -let -empty -= -self -. -add_empty -( -) -? -; -self -. -patch -( -union -compiled -. -start -) -? -; -self -. -patch -( -union -empty -) -? -; -self -. -patch -( -compiled -. -end -empty -) -? -; -Ok -( -ThompsonRef -{ -start -: -union -end -: -empty -} -) -} -/ -/ -/ -Compile -the -given -HIR -expression -exactly -n -times -. -fn -c_exactly -( -& -self -expr -: -& -Hir -n -: -u32 -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -let -it -= -( -0 -. -. -n -) -. -map -( -| -_ -| -self -. -c -( -expr -) -) -; -self -. -c_concat -( -it -) -} -/ -/ -/ -Compile -the -given -byte -oriented -character -class -. -/ -/ -/ -/ -/ -/ -This -uses -" -sparse -" -states -to -represent -an -alternation -between -ranges -in -/ -/ -/ -this -character -class -. -We -can -use -" -sparse -" -states -instead -of -stitching -/ -/ -/ -together -a -" -union -" -state -because -all -ranges -in -a -character -class -have -/ -/ -/ -equal -priority -* -and -* -are -non -- -overlapping -( -thus -only -one -can -match -so -/ -/ -/ -there -' -s -never -a -question -of -priority -in -the -first -place -) -. -This -saves -a -/ -/ -/ -fair -bit -of -overhead -when -traversing -an -NFA -. -/ -/ -/ -/ -/ -/ -This -routine -compiles -an -empty -character -class -into -a -" -fail -" -state -. -fn -c_byte_class -( -& -self -cls -: -& -hir -: -: -ClassBytes -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -let -end -= -self -. -add_empty -( -) -? -; -let -mut -trans -= -Vec -: -: -with_capacity -( -cls -. -ranges -( -) -. -len -( -) -) -; -for -r -in -cls -. -iter -( -) -{ -trans -. -push -( -Transition -{ -start -: -r -. -start -( -) -end -: -r -. -end -( -) -next -: -end -} -) -; -} -Ok -( -ThompsonRef -{ -start -: -self -. -add_sparse -( -trans -) -? -end -} -) -} -/ -/ -/ -Compile -the -given -Unicode -character -class -. -/ -/ -/ -/ -/ -/ -This -routine -specifically -tries -to -use -various -types -of -compression -/ -/ -/ -since -UTF -- -8 -automata -of -large -classes -can -get -quite -large -. -The -specific -/ -/ -/ -type -of -compression -used -depends -on -forward -vs -reverse -compilation -and -/ -/ -/ -whether -NFA -shrinking -is -enabled -or -not -. -/ -/ -/ -/ -/ -/ -Aside -from -repetitions -causing -lots -of -repeat -group -this -is -like -the -/ -/ -/ -single -most -expensive -part -of -regex -compilation -. -Therefore -a -large -part -/ -/ -/ -of -the -expense -of -compilation -may -be -reduce -by -disabling -Unicode -in -the -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -This -routine -compiles -an -empty -character -class -into -a -" -fail -" -state -. -fn -c_unicode_class -( -& -self -cls -: -& -hir -: -: -ClassUnicode -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -/ -/ -If -all -we -have -are -ASCII -ranges -wrapped -in -a -Unicode -package -then -/ -/ -there -is -zero -reason -to -bring -out -the -big -guns -. -We -can -fit -all -ASCII -/ -/ -ranges -within -a -single -sparse -state -. -if -cls -. -is_ascii -( -) -{ -let -end -= -self -. -add_empty -( -) -? -; -let -mut -trans -= -Vec -: -: -with_capacity -( -cls -. -ranges -( -) -. -len -( -) -) -; -for -r -in -cls -. -iter -( -) -{ -/ -/ -The -unwraps -below -are -OK -because -we -' -ve -verified -that -this -/ -/ -class -only -contains -ASCII -codepoints -. -trans -. -push -( -Transition -{ -/ -/ -FIXME -( -1 -. -59 -) -: -use -the -' -TryFrom -< -char -> -for -u8 -' -impl -. -start -: -u8 -: -: -try_from -( -u32 -: -: -from -( -r -. -start -( -) -) -) -. -unwrap -( -) -end -: -u8 -: -: -try_from -( -u32 -: -: -from -( -r -. -end -( -) -) -) -. -unwrap -( -) -next -: -end -} -) -; -} -Ok -( -ThompsonRef -{ -start -: -self -. -add_sparse -( -trans -) -? -end -} -) -} -else -if -self -. -is_reverse -( -) -{ -if -! -self -. -config -. -get_shrink -( -) -{ -/ -/ -When -we -don -' -t -want -to -spend -the -extra -time -shrinking -we -/ -/ -compile -the -UTF -- -8 -automaton -in -reverse -using -something -like -/ -/ -the -" -naive -" -approach -but -will -attempt -to -re -- -use -common -/ -/ -suffixes -. -self -. -c_unicode_class_reverse_with_suffix -( -cls -) -} -else -{ -/ -/ -When -we -want -to -shrink -our -NFA -for -reverse -UTF -- -8 -automata -/ -/ -we -cannot -feed -UTF -- -8 -sequences -directly -to -the -UTF -- -8 -/ -/ -compiler -since -the -UTF -- -8 -compiler -requires -all -sequences -/ -/ -to -be -lexicographically -sorted -. -Instead -we -organize -our -/ -/ -sequences -into -a -range -trie -which -can -then -output -our -/ -/ -sequences -in -the -correct -order -. -Unfortunately -building -the -/ -/ -range -trie -is -fairly -expensive -( -but -not -nearly -as -expensive -/ -/ -as -building -a -DFA -) -. -Hence -the -reason -why -the -' -shrink -' -option -/ -/ -exists -so -that -this -path -can -be -toggled -off -. -For -example -/ -/ -we -might -want -to -turn -this -off -if -we -know -we -won -' -t -be -/ -/ -compiling -a -DFA -. -let -mut -trie -= -self -. -trie_state -. -borrow_mut -( -) -; -trie -. -clear -( -) -; -for -rng -in -cls -. -iter -( -) -{ -for -mut -seq -in -Utf8Sequences -: -: -new -( -rng -. -start -( -) -rng -. -end -( -) -) -{ -seq -. -reverse -( -) -; -trie -. -insert -( -seq -. -as_slice -( -) -) -; -} -} -let -mut -builder -= -self -. -builder -. -borrow_mut -( -) -; -let -mut -utf8_state -= -self -. -utf8_state -. -borrow_mut -( -) -; -let -mut -utf8c -= -Utf8Compiler -: -: -new -( -& -mut -* -builder -& -mut -* -utf8_state -) -? -; -trie -. -iter -( -| -seq -| -{ -utf8c -. -add -( -& -seq -) -? -; -Ok -( -( -) -) -} -) -? -; -utf8c -. -finish -( -) -} -} -else -{ -/ -/ -In -the -forward -direction -we -always -shrink -our -UTF -- -8 -automata -/ -/ -because -we -can -stream -it -right -into -the -UTF -- -8 -compiler -. -There -/ -/ -is -almost -no -downside -( -in -either -memory -or -time -) -to -using -this -/ -/ -approach -. -let -mut -builder -= -self -. -builder -. -borrow_mut -( -) -; -let -mut -utf8_state -= -self -. -utf8_state -. -borrow_mut -( -) -; -let -mut -utf8c -= -Utf8Compiler -: -: -new -( -& -mut -* -builder -& -mut -* -utf8_state -) -? -; -for -rng -in -cls -. -iter -( -) -{ -for -seq -in -Utf8Sequences -: -: -new -( -rng -. -start -( -) -rng -. -end -( -) -) -{ -utf8c -. -add -( -seq -. -as_slice -( -) -) -? -; -} -} -utf8c -. -finish -( -) -} -/ -/ -For -reference -the -code -below -is -the -" -naive -" -version -of -compiling -a -/ -/ -UTF -- -8 -automaton -. -It -is -deliciously -simple -( -and -works -for -both -the -/ -/ -forward -and -reverse -cases -) -but -will -unfortunately -produce -very -/ -/ -large -NFAs -. -When -compiling -a -forward -automaton -the -size -difference -/ -/ -can -sometimes -be -an -order -of -magnitude -. -For -example -the -' -\ -w -' -regex -/ -/ -will -generate -about -~ -3000 -NFA -states -using -the -naive -approach -below -/ -/ -but -only -283 -states -when -using -the -approach -above -. -This -is -because -/ -/ -the -approach -above -actually -compiles -a -* -minimal -* -( -or -near -minimal -/ -/ -because -of -the -bounded -hashmap -for -reusing -equivalent -states -) -UTF -- -8 -/ -/ -automaton -. -/ -/ -/ -/ -The -code -below -is -kept -as -a -reference -point -in -order -to -make -it -/ -/ -easier -to -understand -the -higher -level -goal -here -. -Although -it -will -/ -/ -almost -certainly -bit -- -rot -so -keep -that -in -mind -. -Also -if -you -try -to -/ -/ -use -it -some -of -the -tests -in -this -module -will -fail -because -they -look -/ -/ -for -terser -byte -code -produce -by -the -more -optimized -handling -above -. -/ -/ -But -the -integration -test -suite -should -still -pass -. -/ -/ -/ -/ -One -good -example -of -the -substantial -difference -this -can -make -is -to -/ -/ -compare -and -contrast -performance -of -the -Pike -VM -when -the -code -below -/ -/ -is -active -vs -the -code -above -. -Here -' -s -an -example -to -try -: -/ -/ -/ -/ -regex -- -cli -find -match -pikevm -- -b -- -p -' -( -? -m -) -^ -\ -w -{ -20 -} -' -- -y -' -smallishru -' -/ -/ -/ -/ -With -Unicode -classes -generated -below -this -search -takes -about -45s -on -/ -/ -my -machine -. -But -with -the -compressed -version -above -the -search -takes -/ -/ -only -around -1 -. -4s -. -The -NFA -is -also -20 -% -smaller -. -This -is -in -part -due -/ -/ -to -the -compression -but -also -because -of -the -utilization -of -' -sparse -' -/ -/ -NFA -states -. -They -lead -to -much -less -state -shuffling -during -the -NFA -/ -/ -search -. -/ -* -let -it -= -cls -. -iter -( -) -. -flat_map -( -| -rng -| -Utf8Sequences -: -: -new -( -rng -. -start -( -) -rng -. -end -( -) -) -) -. -map -( -| -seq -| -{ -let -it -= -seq -. -as_slice -( -) -. -iter -( -) -. -map -( -| -rng -| -self -. -c_range -( -rng -. -start -rng -. -end -) -) -; -self -. -c_concat -( -it -) -} -) -; -self -. -c_alt_iter -( -it -) -* -/ -} -/ -/ -/ -Compile -the -given -Unicode -character -class -in -reverse -with -suffix -/ -/ -/ -caching -. -/ -/ -/ -/ -/ -/ -This -is -a -" -quick -" -way -to -compile -large -Unicode -classes -into -reverse -/ -/ -/ -UTF -- -8 -automata -while -doing -a -small -amount -of -compression -on -that -/ -/ -/ -automata -by -reusing -common -suffixes -. -/ -/ -/ -/ -/ -/ -A -more -comprehensive -compression -scheme -can -be -accomplished -by -using -/ -/ -/ -a -range -trie -to -efficiently -sort -a -reverse -sequence -of -UTF -- -8 -byte -/ -/ -/ -rqanges -and -then -use -Daciuk -' -s -algorithm -via -Utf8Compiler -. -/ -/ -/ -/ -/ -/ -This -is -the -technique -used -when -" -NFA -shrinking -" -is -disabled -. -/ -/ -/ -/ -/ -/ -( -This -also -tries -to -use -" -sparse -" -states -where -possible -just -like -/ -/ -/ -c_byte_class -does -. -) -fn -c_unicode_class_reverse_with_suffix -( -& -self -cls -: -& -hir -: -: -ClassUnicode -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -/ -/ -N -. -B -. -It -would -likely -be -better -to -cache -common -* -prefixes -* -in -the -/ -/ -reverse -direction -but -it -' -s -not -quite -clear -how -to -do -that -. -The -/ -/ -advantage -of -caching -suffixes -is -that -it -does -give -us -a -win -and -/ -/ -has -a -very -small -additional -overhead -. -let -mut -cache -= -self -. -utf8_suffix -. -borrow_mut -( -) -; -cache -. -clear -( -) -; -let -union -= -self -. -add_union -( -) -? -; -let -alt_end -= -self -. -add_empty -( -) -? -; -for -urng -in -cls -. -iter -( -) -{ -for -seq -in -Utf8Sequences -: -: -new -( -urng -. -start -( -) -urng -. -end -( -) -) -{ -let -mut -end -= -alt_end -; -for -brng -in -seq -. -as_slice -( -) -{ -let -key -= -Utf8SuffixKey -{ -from -: -end -start -: -brng -. -start -end -: -brng -. -end -} -; -let -hash -= -cache -. -hash -( -& -key -) -; -if -let -Some -( -id -) -= -cache -. -get -( -& -key -hash -) -{ -end -= -id -; -continue -; -} -let -compiled -= -self -. -c_range -( -brng -. -start -brng -. -end -) -? -; -self -. -patch -( -compiled -. -end -end -) -? -; -end -= -compiled -. -start -; -cache -. -set -( -key -hash -end -) -; -} -self -. -patch -( -union -end -) -? -; -} -} -Ok -( -ThompsonRef -{ -start -: -union -end -: -alt_end -} -) -} -/ -/ -/ -Compile -the -given -HIR -look -- -around -assertion -to -an -NFA -look -- -around -/ -/ -/ -assertion -. -fn -c_look -( -& -self -anchor -: -& -hir -: -: -Look -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -let -look -= -match -* -anchor -{ -hir -: -: -Look -: -: -Start -= -> -Look -: -: -Start -hir -: -: -Look -: -: -End -= -> -Look -: -: -End -hir -: -: -Look -: -: -StartLF -= -> -Look -: -: -StartLF -hir -: -: -Look -: -: -EndLF -= -> -Look -: -: -EndLF -hir -: -: -Look -: -: -StartCRLF -= -> -Look -: -: -StartCRLF -hir -: -: -Look -: -: -EndCRLF -= -> -Look -: -: -EndCRLF -hir -: -: -Look -: -: -WordAscii -= -> -Look -: -: -WordAscii -hir -: -: -Look -: -: -WordAsciiNegate -= -> -Look -: -: -WordAsciiNegate -hir -: -: -Look -: -: -WordUnicode -= -> -Look -: -: -WordUnicode -hir -: -: -Look -: -: -WordUnicodeNegate -= -> -Look -: -: -WordUnicodeNegate -} -; -let -id -= -self -. -add_look -( -look -) -? -; -Ok -( -ThompsonRef -{ -start -: -id -end -: -id -} -) -} -/ -/ -/ -Compile -the -given -byte -string -to -a -concatenation -of -bytes -. -fn -c_literal -( -& -self -bytes -: -& -[ -u8 -] -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -self -. -c_concat -( -bytes -. -iter -( -) -. -copied -( -) -. -map -( -| -b -| -self -. -c_range -( -b -b -) -) -) -} -/ -/ -/ -Compile -a -" -range -" -state -with -one -transition -that -may -only -be -followed -/ -/ -/ -if -the -input -byte -is -in -the -( -inclusive -) -range -given -. -/ -/ -/ -/ -/ -/ -Both -the -start -and -end -locations -point -to -the -state -created -. -/ -/ -/ -Callers -will -likely -want -to -keep -the -start -but -patch -the -end -to -/ -/ -/ -point -to -some -other -state -. -fn -c_range -( -& -self -start -: -u8 -end -: -u8 -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -let -id -= -self -. -add_range -( -start -end -) -? -; -Ok -( -ThompsonRef -{ -start -: -id -end -: -id -} -) -} -/ -/ -/ -Compile -an -" -empty -" -state -with -one -unconditional -epsilon -transition -. -/ -/ -/ -/ -/ -/ -Both -the -start -and -end -locations -point -to -the -state -created -. -/ -/ -/ -Callers -will -likely -want -to -keep -the -start -but -patch -the -end -to -/ -/ -/ -point -to -some -other -state -. -fn -c_empty -( -& -self -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -let -id -= -self -. -add_empty -( -) -? -; -Ok -( -ThompsonRef -{ -start -: -id -end -: -id -} -) -} -/ -/ -/ -Compile -a -" -fail -" -state -that -can -never -have -any -outgoing -transitions -. -fn -c_fail -( -& -self -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -let -id -= -self -. -add_fail -( -) -? -; -Ok -( -ThompsonRef -{ -start -: -id -end -: -id -} -) -} -/ -/ -The -below -helpers -are -meant -to -be -simple -wrappers -around -the -/ -/ -corresponding -Builder -methods -. -For -the -most -part -they -let -us -write -/ -/ -' -self -. -add_foo -( -) -' -instead -of -' -self -. -builder -. -borrow_mut -( -) -. -add_foo -( -) -' -where -/ -/ -the -latter -is -a -mouthful -. -Some -of -the -methods -do -inject -a -little -bit -/ -/ -of -extra -logic -. -e -. -g -. -Flipping -look -- -around -operators -when -compiling -in -/ -/ -reverse -mode -. -fn -patch -( -& -self -from -: -StateID -to -: -StateID -) -- -> -Result -< -( -) -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -patch -( -from -to -) -} -fn -start_pattern -( -& -self -) -- -> -Result -< -PatternID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -start_pattern -( -) -} -fn -finish_pattern -( -& -self -start_id -: -StateID -) -- -> -Result -< -PatternID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -finish_pattern -( -start_id -) -} -fn -add_empty -( -& -self -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -add_empty -( -) -} -fn -add_range -( -& -self -start -: -u8 -end -: -u8 -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -add_range -( -Transition -{ -start -end -next -: -StateID -: -: -ZERO -} -) -} -fn -add_sparse -( -& -self -ranges -: -Vec -< -Transition -> -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -add_sparse -( -ranges -) -} -fn -add_look -( -& -self -mut -look -: -Look -) -- -> -Result -< -StateID -BuildError -> -{ -if -self -. -is_reverse -( -) -{ -look -= -look -. -reversed -( -) -; -} -self -. -builder -. -borrow_mut -( -) -. -add_look -( -StateID -: -: -ZERO -look -) -} -fn -add_union -( -& -self -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -add_union -( -vec -! -[ -] -) -} -fn -add_union_reverse -( -& -self -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -add_union_reverse -( -vec -! -[ -] -) -} -fn -add_capture_start -( -& -self -capture_index -: -u32 -name -: -Option -< -& -str -> -) -- -> -Result -< -StateID -BuildError -> -{ -let -name -= -name -. -map -( -| -n -| -Arc -: -: -from -( -n -) -) -; -self -. -builder -. -borrow_mut -( -) -. -add_capture_start -( -StateID -: -: -ZERO -capture_index -name -) -} -fn -add_capture_end -( -& -self -capture_index -: -u32 -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -add_capture_end -( -StateID -: -: -ZERO -capture_index -) -} -fn -add_fail -( -& -self -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -add_fail -( -) -} -fn -add_match -( -& -self -) -- -> -Result -< -StateID -BuildError -> -{ -self -. -builder -. -borrow_mut -( -) -. -add_match -( -) -} -fn -is_reverse -( -& -self -) -- -> -bool -{ -self -. -config -. -get_reverse -( -) -} -} -/ -/ -/ -A -value -that -represents -the -result -of -compiling -a -sub -- -expression -of -a -/ -/ -/ -regex -' -s -HIR -. -Specifically -this -represents -a -sub -- -graph -of -the -NFA -that -/ -/ -/ -has -an -initial -state -at -start -and -a -final -state -at -end -. -# -[ -derive -( -Clone -Copy -Debug -) -] -pub -( -crate -) -struct -ThompsonRef -{ -pub -( -crate -) -start -: -StateID -pub -( -crate -) -end -: -StateID -} -/ -/ -/ -A -UTF -- -8 -compiler -based -on -Daciuk -' -s -algorithm -for -compilining -minimal -DFAs -/ -/ -/ -from -a -lexicographically -sorted -sequence -of -strings -in -linear -time -. -/ -/ -/ -/ -/ -/ -The -trick -here -is -that -any -Unicode -codepoint -range -can -be -converted -to -/ -/ -/ -a -sequence -of -byte -ranges -that -form -a -UTF -- -8 -automaton -. -Connecting -them -/ -/ -/ -together -via -an -alternation -is -trivial -and -indeed -it -works -. -However -/ -/ -/ -there -is -a -lot -of -redundant -structure -in -many -UTF -- -8 -automatons -. -Since -our -/ -/ -/ -UTF -- -8 -ranges -are -in -lexicographic -order -we -can -use -Daciuk -' -s -algorithm -/ -/ -/ -to -build -nearly -minimal -DFAs -in -linear -time -. -( -They -are -guaranteed -to -be -/ -/ -/ -minimal -because -we -use -a -bounded -cache -of -previously -build -DFA -states -. -) -/ -/ -/ -/ -/ -/ -The -drawback -is -that -this -sadly -doesn -' -t -work -for -reverse -automata -since -/ -/ -/ -the -ranges -are -no -longer -in -lexicographic -order -. -For -that -we -invented -the -/ -/ -/ -range -trie -( -which -gets -its -own -module -) -. -Once -a -range -trie -is -built -we -then -/ -/ -/ -use -this -same -Utf8Compiler -to -build -a -reverse -UTF -- -8 -automaton -. -/ -/ -/ -/ -/ -/ -The -high -level -idea -is -described -here -: -/ -/ -/ -https -: -/ -/ -blog -. -burntsushi -. -net -/ -transducers -/ -# -finite -- -state -- -machines -- -as -- -data -- -structures -/ -/ -/ -/ -/ -/ -There -is -also -another -implementation -of -this -in -the -fst -crate -. -# -[ -derive -( -Debug -) -] -struct -Utf8Compiler -< -' -a -> -{ -builder -: -& -' -a -mut -Builder -state -: -& -' -a -mut -Utf8State -target -: -StateID -} -# -[ -derive -( -Clone -Debug -) -] -struct -Utf8State -{ -compiled -: -Utf8BoundedMap -uncompiled -: -Vec -< -Utf8Node -> -} -# -[ -derive -( -Clone -Debug -) -] -struct -Utf8Node -{ -trans -: -Vec -< -Transition -> -last -: -Option -< -Utf8LastTransition -> -} -# -[ -derive -( -Clone -Debug -) -] -struct -Utf8LastTransition -{ -start -: -u8 -end -: -u8 -} -impl -Utf8State -{ -fn -new -( -) -- -> -Utf8State -{ -Utf8State -{ -compiled -: -Utf8BoundedMap -: -: -new -( -10_000 -) -uncompiled -: -vec -! -[ -] -} -} -fn -clear -( -& -mut -self -) -{ -self -. -compiled -. -clear -( -) -; -self -. -uncompiled -. -clear -( -) -; -} -} -impl -< -' -a -> -Utf8Compiler -< -' -a -> -{ -fn -new -( -builder -: -& -' -a -mut -Builder -state -: -& -' -a -mut -Utf8State -) -- -> -Result -< -Utf8Compiler -< -' -a -> -BuildError -> -{ -let -target -= -builder -. -add_empty -( -) -? -; -state -. -clear -( -) -; -let -mut -utf8c -= -Utf8Compiler -{ -builder -state -target -} -; -utf8c -. -add_empty -( -) -; -Ok -( -utf8c -) -} -fn -finish -( -& -mut -self -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -self -. -compile_from -( -0 -) -? -; -let -node -= -self -. -pop_root -( -) -; -let -start -= -self -. -compile -( -node -) -? -; -Ok -( -ThompsonRef -{ -start -end -: -self -. -target -} -) -} -fn -add -( -& -mut -self -ranges -: -& -[ -Utf8Range -] -) -- -> -Result -< -( -) -BuildError -> -{ -let -prefix_len -= -ranges -. -iter -( -) -. -zip -( -& -self -. -state -. -uncompiled -) -. -take_while -( -| -& -( -range -node -) -| -{ -node -. -last -. -as_ref -( -) -. -map_or -( -false -| -t -| -{ -( -t -. -start -t -. -end -) -= -= -( -range -. -start -range -. -end -) -} -) -} -) -. -count -( -) -; -assert -! -( -prefix_len -< -ranges -. -len -( -) -) -; -self -. -compile_from -( -prefix_len -) -? -; -self -. -add_suffix -( -& -ranges -[ -prefix_len -. -. -] -) -; -Ok -( -( -) -) -} -fn -compile_from -( -& -mut -self -from -: -usize -) -- -> -Result -< -( -) -BuildError -> -{ -let -mut -next -= -self -. -target -; -while -from -+ -1 -< -self -. -state -. -uncompiled -. -len -( -) -{ -let -node -= -self -. -pop_freeze -( -next -) -; -next -= -self -. -compile -( -node -) -? -; -} -self -. -top_last_freeze -( -next -) -; -Ok -( -( -) -) -} -fn -compile -( -& -mut -self -node -: -Vec -< -Transition -> -) -- -> -Result -< -StateID -BuildError -> -{ -let -hash -= -self -. -state -. -compiled -. -hash -( -& -node -) -; -if -let -Some -( -id -) -= -self -. -state -. -compiled -. -get -( -& -node -hash -) -{ -return -Ok -( -id -) -; -} -let -id -= -self -. -builder -. -add_sparse -( -node -. -clone -( -) -) -? -; -self -. -state -. -compiled -. -set -( -node -hash -id -) -; -Ok -( -id -) -} -fn -add_suffix -( -& -mut -self -ranges -: -& -[ -Utf8Range -] -) -{ -assert -! -( -! -ranges -. -is_empty -( -) -) -; -let -last -= -self -. -state -. -uncompiled -. -len -( -) -. -checked_sub -( -1 -) -. -expect -( -" -non -- -empty -nodes -" -) -; -assert -! -( -self -. -state -. -uncompiled -[ -last -] -. -last -. -is_none -( -) -) -; -self -. -state -. -uncompiled -[ -last -] -. -last -= -Some -( -Utf8LastTransition -{ -start -: -ranges -[ -0 -] -. -start -end -: -ranges -[ -0 -] -. -end -} -) -; -for -r -in -& -ranges -[ -1 -. -. -] -{ -self -. -state -. -uncompiled -. -push -( -Utf8Node -{ -trans -: -vec -! -[ -] -last -: -Some -( -Utf8LastTransition -{ -start -: -r -. -start -end -: -r -. -end -} -) -} -) -; -} -} -fn -add_empty -( -& -mut -self -) -{ -self -. -state -. -uncompiled -. -push -( -Utf8Node -{ -trans -: -vec -! -[ -] -last -: -None -} -) -; -} -fn -pop_freeze -( -& -mut -self -next -: -StateID -) -- -> -Vec -< -Transition -> -{ -let -mut -uncompiled -= -self -. -state -. -uncompiled -. -pop -( -) -. -unwrap -( -) -; -uncompiled -. -set_last_transition -( -next -) -; -uncompiled -. -trans -} -fn -pop_root -( -& -mut -self -) -- -> -Vec -< -Transition -> -{ -assert_eq -! -( -self -. -state -. -uncompiled -. -len -( -) -1 -) -; -assert -! -( -self -. -state -. -uncompiled -[ -0 -] -. -last -. -is_none -( -) -) -; -self -. -state -. -uncompiled -. -pop -( -) -. -expect -( -" -non -- -empty -nodes -" -) -. -trans -} -fn -top_last_freeze -( -& -mut -self -next -: -StateID -) -{ -let -last -= -self -. -state -. -uncompiled -. -len -( -) -. -checked_sub -( -1 -) -. -expect -( -" -non -- -empty -nodes -" -) -; -self -. -state -. -uncompiled -[ -last -] -. -set_last_transition -( -next -) -; -} -} -impl -Utf8Node -{ -fn -set_last_transition -( -& -mut -self -next -: -StateID -) -{ -if -let -Some -( -last -) -= -self -. -last -. -take -( -) -{ -self -. -trans -. -push -( -Transition -{ -start -: -last -. -start -end -: -last -. -end -next -} -) -; -} -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -{ -SparseTransitions -State -Transition -NFA -} -util -: -: -primitives -: -: -{ -PatternID -SmallIndex -StateID -} -} -; -use -super -: -: -* -; -fn -build -( -pattern -: -& -str -) -- -> -NFA -{ -NFA -: -: -compiler -( -) -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -. -unanchored_prefix -( -false -) -) -. -build -( -pattern -) -. -unwrap -( -) -} -fn -pid -( -id -: -usize -) -- -> -PatternID -{ -PatternID -: -: -new -( -id -) -. -unwrap -( -) -} -fn -sid -( -id -: -usize -) -- -> -StateID -{ -StateID -: -: -new -( -id -) -. -unwrap -( -) -} -fn -s_byte -( -byte -: -u8 -next -: -usize -) -- -> -State -{ -let -next -= -sid -( -next -) -; -let -trans -= -Transition -{ -start -: -byte -end -: -byte -next -} -; -State -: -: -ByteRange -{ -trans -} -} -fn -s_range -( -start -: -u8 -end -: -u8 -next -: -usize -) -- -> -State -{ -let -next -= -sid -( -next -) -; -let -trans -= -Transition -{ -start -end -next -} -; -State -: -: -ByteRange -{ -trans -} -} -fn -s_sparse -( -transitions -: -& -[ -( -u8 -u8 -usize -) -] -) -- -> -State -{ -let -transitions -= -transitions -. -iter -( -) -. -map -( -| -& -( -start -end -next -) -| -Transition -{ -start -end -next -: -sid -( -next -) -} -) -. -collect -( -) -; -State -: -: -Sparse -( -SparseTransitions -{ -transitions -} -) -} -fn -s_bin_union -( -alt1 -: -usize -alt2 -: -usize -) -- -> -State -{ -State -: -: -BinaryUnion -{ -alt1 -: -sid -( -alt1 -) -alt2 -: -sid -( -alt2 -) -} -} -fn -s_union -( -alts -: -& -[ -usize -] -) -- -> -State -{ -State -: -: -Union -{ -alternates -: -alts -. -iter -( -) -. -map -( -| -& -id -| -sid -( -id -) -) -. -collect -: -: -< -Vec -< -StateID -> -> -( -) -. -into_boxed_slice -( -) -} -} -fn -s_cap -( -next -: -usize -pattern -: -usize -index -: -usize -slot -: -usize -) -- -> -State -{ -State -: -: -Capture -{ -next -: -sid -( -next -) -pattern_id -: -pid -( -pattern -) -group_index -: -SmallIndex -: -: -new -( -index -) -. -unwrap -( -) -slot -: -SmallIndex -: -: -new -( -slot -) -. -unwrap -( -) -} -} -fn -s_fail -( -) -- -> -State -{ -State -: -: -Fail -} -fn -s_match -( -id -: -usize -) -- -> -State -{ -State -: -: -Match -{ -pattern_id -: -pid -( -id -) -} -} -/ -/ -Test -that -building -an -unanchored -NFA -has -an -appropriate -( -? -s -: -. -) -* -? -/ -/ -prefix -. -# -[ -test -] -fn -compile_unanchored_prefix -( -) -{ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -. -build -( -r -" -a -" -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_bin_union -( -2 -1 -) -s_range -( -0 -255 -0 -) -s_byte -( -b -' -a -' -3 -) -s_match -( -0 -) -] -) -; -} -# -[ -test -] -fn -compile_empty -( -) -{ -assert_eq -! -( -build -( -" -" -) -. -states -( -) -& -[ -s_match -( -0 -) -] -) -; -} -# -[ -test -] -fn -compile_literal -( -) -{ -assert_eq -! -( -build -( -" -a -" -) -. -states -( -) -& -[ -s_byte -( -b -' -a -' -1 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -" -ab -" -) -. -states -( -) -& -[ -s_byte -( -b -' -a -' -1 -) -s_byte -( -b -' -b -' -2 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -" -" -) -. -states -( -) -& -[ -s_byte -( -0xE2 -1 -) -s_byte -( -0x98 -2 -) -s_byte -( -0x83 -3 -) -s_match -( -0 -) -] -) -; -/ -/ -Check -that -non -- -UTF -- -8 -literals -work -. -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -. -unanchored_prefix -( -false -) -) -. -syntax -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -. -build -( -r -" -( -? -- -u -) -\ -xFF -" -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_byte -( -b -' -\ -xFF -' -1 -) -s_match -( -0 -) -] -) -; -} -# -[ -test -] -fn -compile_class_ascii -( -) -{ -assert_eq -! -( -build -( -r -" -[ -a -- -z -] -" -) -. -states -( -) -& -[ -s_range -( -b -' -a -' -b -' -z -' -1 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -[ -x -- -za -- -c -] -" -) -. -states -( -) -& -[ -s_sparse -( -& -[ -( -b -' -a -' -b -' -c -' -1 -) -( -b -' -x -' -b -' -z -' -1 -) -] -) -s_match -( -0 -) -] -) -; -} -# -[ -test -] -# -[ -cfg -( -not -( -miri -) -) -] -fn -compile_class_unicode -( -) -{ -assert_eq -! -( -build -( -r -" -[ -\ -u03B1 -- -\ -u03B4 -] -" -) -. -states -( -) -& -[ -s_range -( -0xB1 -0xB4 -2 -) -s_byte -( -0xCE -0 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -[ -\ -u03B1 -- -\ -u03B4 -\ -u -{ -1F919 -} -- -\ -u -{ -1F91E -} -] -" -) -. -states -( -) -& -[ -s_range -( -0xB1 -0xB4 -5 -) -s_range -( -0x99 -0x9E -5 -) -s_byte -( -0xA4 -1 -) -s_byte -( -0x9F -2 -) -s_sparse -( -& -[ -( -0xCE -0xCE -0 -) -( -0xF0 -0xF0 -3 -) -] -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -[ -a -- -z -] -" -) -. -states -( -) -& -[ -s_byte -( -0x83 -3 -) -s_byte -( -0x98 -0 -) -s_sparse -( -& -[ -( -b -' -a -' -b -' -z -' -3 -) -( -0xE2 -0xE2 -1 -) -] -) -s_match -( -0 -) -] -) -; -} -# -[ -test -] -fn -compile_repetition -( -) -{ -assert_eq -! -( -build -( -r -" -a -? -" -) -. -states -( -) -& -[ -s_bin_union -( -1 -2 -) -s_byte -( -b -' -a -' -2 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -a -? -? -" -) -. -states -( -) -& -[ -s_bin_union -( -2 -1 -) -s_byte -( -b -' -a -' -2 -) -s_match -( -0 -) -] -) -; -} -# -[ -test -] -fn -compile_group -( -) -{ -assert_eq -! -( -build -( -r -" -ab -+ -" -) -. -states -( -) -& -[ -s_byte -( -b -' -a -' -1 -) -s_byte -( -b -' -b -' -2 -) -s_bin_union -( -1 -3 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -( -ab -) -" -) -. -states -( -) -& -[ -s_byte -( -b -' -a -' -1 -) -s_byte -( -b -' -b -' -2 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -( -ab -) -+ -" -) -. -states -( -) -& -[ -s_byte -( -b -' -a -' -1 -) -s_byte -( -b -' -b -' -2 -) -s_bin_union -( -0 -3 -) -s_match -( -0 -) -] -) -; -} -# -[ -test -] -fn -compile_alternation -( -) -{ -assert_eq -! -( -build -( -r -" -a -| -b -" -) -. -states -( -) -& -[ -s_range -( -b -' -a -' -b -' -b -' -1 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -ab -| -cd -" -) -. -states -( -) -& -[ -s_byte -( -b -' -b -' -3 -) -s_byte -( -b -' -d -' -3 -) -s_sparse -( -& -[ -( -b -' -a -' -b -' -a -' -0 -) -( -b -' -c -' -b -' -c -' -1 -) -] -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -| -b -" -) -. -states -( -) -& -[ -s_byte -( -b -' -b -' -2 -) -s_bin_union -( -2 -0 -) -s_match -( -0 -) -] -) -; -assert_eq -! -( -build -( -r -" -a -| -" -) -. -states -( -) -& -[ -s_byte -( -b -' -a -' -2 -) -s_bin_union -( -0 -2 -) -s_match -( -0 -) -] -) -; -} -/ -/ -This -tests -the -use -of -a -non -- -binary -union -i -. -e -. -a -state -with -more -than -/ -/ -2 -unconditional -epsilon -transitions -. -The -only -place -they -tend -to -appear -/ -/ -is -in -reverse -NFAs -when -shrinking -is -disabled -. -Otherwise -' -binary -- -union -' -/ -/ -and -' -sparse -' -tend -to -cover -all -other -cases -of -alternation -. -# -[ -test -] -fn -compile_non_binary_union -( -) -{ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -. -reverse -( -true -) -. -shrink -( -false -) -. -unanchored_prefix -( -false -) -) -. -build -( -r -" -[ -\ -u1000 -\ -u2000 -\ -u3000 -] -" -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_union -( -& -[ -3 -6 -9 -] -) -s_byte -( -0xE1 -10 -) -s_byte -( -0x80 -1 -) -s_byte -( -0x80 -2 -) -s_byte -( -0xE2 -10 -) -s_byte -( -0x80 -4 -) -s_byte -( -0x80 -5 -) -s_byte -( -0xE3 -10 -) -s_byte -( -0x80 -7 -) -s_byte -( -0x80 -8 -) -s_match -( -0 -) -] -) -; -} -# -[ -test -] -fn -compile_many_start_pattern -( -) -{ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -. -unanchored_prefix -( -false -) -) -. -build_many -( -& -[ -" -a -" -" -b -" -] -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_byte -( -b -' -a -' -1 -) -s_match -( -0 -) -s_byte -( -b -' -b -' -3 -) -s_match -( -1 -) -s_bin_union -( -0 -2 -) -] -) -; -assert_eq -! -( -nfa -. -start_anchored -( -) -. -as_usize -( -) -4 -) -; -assert_eq -! -( -nfa -. -start_unanchored -( -) -. -as_usize -( -) -4 -) -; -/ -/ -Test -that -the -start -states -for -each -individual -pattern -are -correct -. -assert_eq -! -( -nfa -. -start_pattern -( -pid -( -0 -) -) -. -unwrap -( -) -sid -( -0 -) -) -; -assert_eq -! -( -nfa -. -start_pattern -( -pid -( -1 -) -) -. -unwrap -( -) -sid -( -2 -) -) -; -} -/ -/ -This -tests -that -our -compiler -can -handle -an -empty -character -class -. -At -the -/ -/ -time -of -writing -the -regex -parser -forbids -it -so -the -only -way -to -test -it -/ -/ -is -to -provide -a -hand -written -HIR -. -# -[ -test -] -fn -empty_class_bytes -( -) -{ -use -regex_syntax -: -: -hir -: -: -{ -Class -ClassBytes -Hir -} -; -let -hir -= -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new -( -vec -! -[ -] -) -) -) -; -let -config -= -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -. -unanchored_prefix -( -false -) -; -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_from_hir -( -& -hir -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_fail -( -) -s_match -( -0 -) -] -) -; -} -/ -/ -Like -empty_class_bytes -but -for -a -Unicode -class -. -# -[ -test -] -fn -empty_class_unicode -( -) -{ -use -regex_syntax -: -: -hir -: -: -{ -Class -ClassUnicode -Hir -} -; -let -hir -= -Hir -: -: -class -( -Class -: -: -Unicode -( -ClassUnicode -: -: -new -( -vec -! -[ -] -) -) -) -; -let -config -= -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -. -unanchored_prefix -( -false -) -; -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_from_hir -( -& -hir -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_fail -( -) -s_match -( -0 -) -] -) -; -} -# -[ -test -] -fn -compile_captures_all -( -) -{ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -NFA -: -: -config -( -) -. -unanchored_prefix -( -false -) -. -which_captures -( -WhichCaptures -: -: -All -) -) -. -build -( -" -a -( -b -) -c -" -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_cap -( -1 -0 -0 -0 -) -s_byte -( -b -' -a -' -2 -) -s_cap -( -3 -0 -1 -2 -) -s_byte -( -b -' -b -' -4 -) -s_cap -( -5 -0 -1 -3 -) -s_byte -( -b -' -c -' -6 -) -s_cap -( -7 -0 -0 -1 -) -s_match -( -0 -) -] -) -; -let -ginfo -= -nfa -. -group_info -( -) -; -assert_eq -! -( -2 -ginfo -. -all_group_len -( -) -) -; -} -# -[ -test -] -fn -compile_captures_implicit -( -) -{ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -NFA -: -: -config -( -) -. -unanchored_prefix -( -false -) -. -which_captures -( -WhichCaptures -: -: -Implicit -) -) -. -build -( -" -a -( -b -) -c -" -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_cap -( -1 -0 -0 -0 -) -s_byte -( -b -' -a -' -2 -) -s_byte -( -b -' -b -' -3 -) -s_byte -( -b -' -c -' -4 -) -s_cap -( -5 -0 -0 -1 -) -s_match -( -0 -) -] -) -; -let -ginfo -= -nfa -. -group_info -( -) -; -assert_eq -! -( -1 -ginfo -. -all_group_len -( -) -) -; -} -# -[ -test -] -fn -compile_captures_none -( -) -{ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -NFA -: -: -config -( -) -. -unanchored_prefix -( -false -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -. -build -( -" -a -( -b -) -c -" -) -. -unwrap -( -) -; -assert_eq -! -( -nfa -. -states -( -) -& -[ -s_byte -( -b -' -a -' -1 -) -s_byte -( -b -' -b -' -2 -) -s_byte -( -b -' -c -' -3 -) -s_match -( -0 -) -] -) -; -let -ginfo -= -nfa -. -group_info -( -) -; -assert_eq -! -( -0 -ginfo -. -all_group_len -( -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/nfa/thompson/error.rs b/third_party/rust/regex-automata/src/nfa/thompson/error.rs deleted file mode 100644 index fd85d7abea0f4..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/error.rs +++ /dev/null @@ -1,1450 +0,0 @@ -use -crate -: -: -util -: -: -{ -captures -look -primitives -: -: -{ -PatternID -StateID -} -} -; -/ -/ -/ -An -error -that -can -occurred -during -the -construction -of -a -thompson -NFA -. -/ -/ -/ -/ -/ -/ -This -error -does -not -provide -many -introspection -capabilities -. -There -are -/ -/ -/ -generally -only -two -things -you -can -do -with -it -: -/ -/ -/ -/ -/ -/ -* -Obtain -a -human -readable -message -via -its -std -: -: -fmt -: -: -Display -impl -. -/ -/ -/ -* -Access -an -underlying -[ -regex_syntax -: -: -Error -] -type -from -its -source -/ -/ -/ -method -via -the -std -: -: -error -: -: -Error -trait -. -This -error -only -occurs -when -using -/ -/ -/ -convenience -routines -for -building -an -NFA -directly -from -a -pattern -string -. -/ -/ -/ -/ -/ -/ -Otherwise -errors -typically -occur -when -a -limit -has -been -breeched -. -For -/ -/ -/ -example -if -the -total -heap -usage -of -the -compiled -NFA -exceeds -the -limit -/ -/ -/ -set -by -[ -Config -: -: -nfa_size_limit -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -) -then -/ -/ -/ -building -the -NFA -will -fail -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -BuildError -{ -kind -: -BuildErrorKind -} -/ -/ -/ -The -kind -of -error -that -occurred -during -the -construction -of -a -thompson -NFA -. -# -[ -derive -( -Clone -Debug -) -] -enum -BuildErrorKind -{ -/ -/ -/ -An -error -that -occurred -while -parsing -a -regular -expression -. -Note -that -/ -/ -/ -this -error -may -be -printed -over -multiple -lines -and -is -generally -/ -/ -/ -intended -to -be -end -user -readable -on -its -own -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -Syntax -( -regex_syntax -: -: -Error -) -/ -/ -/ -An -error -that -occurs -if -the -capturing -groups -provided -to -an -NFA -builder -/ -/ -/ -do -not -satisfy -the -documented -invariants -. -For -example -things -like -/ -/ -/ -too -many -groups -missing -groups -having -the -first -( -zeroth -) -group -be -/ -/ -/ -named -or -duplicate -group -names -within -the -same -pattern -. -Captures -( -captures -: -: -GroupInfoError -) -/ -/ -/ -An -error -that -occurs -when -an -NFA -contains -a -Unicode -word -boundary -but -/ -/ -/ -where -the -crate -was -compiled -without -the -necessary -data -for -dealing -/ -/ -/ -with -Unicode -word -boundaries -. -Word -( -look -: -: -UnicodeWordBoundaryError -) -/ -/ -/ -An -error -that -occurs -if -too -many -patterns -were -given -to -the -NFA -/ -/ -/ -compiler -. -TooManyPatterns -{ -/ -/ -/ -The -number -of -patterns -given -which -exceeds -the -limit -. -given -: -usize -/ -/ -/ -The -limit -on -the -number -of -patterns -. -limit -: -usize -} -/ -/ -/ -An -error -that -occurs -if -too -states -are -produced -while -building -an -NFA -. -TooManyStates -{ -/ -/ -/ -The -minimum -number -of -states -that -are -desired -which -exceeds -the -/ -/ -/ -limit -. -given -: -usize -/ -/ -/ -The -limit -on -the -number -of -states -. -limit -: -usize -} -/ -/ -/ -An -error -that -occurs -when -NFA -compilation -exceeds -a -configured -heap -/ -/ -/ -limit -. -ExceededSizeLimit -{ -/ -/ -/ -The -configured -limit -in -bytes -. -limit -: -usize -} -/ -/ -/ -An -error -that -occurs -when -an -invalid -capture -group -index -is -added -to -/ -/ -/ -the -NFA -. -An -" -invalid -" -index -can -be -one -that -would -otherwise -overflow -/ -/ -/ -a -usize -on -the -current -target -. -InvalidCaptureIndex -{ -/ -/ -/ -The -invalid -index -that -was -given -. -index -: -u32 -} -/ -/ -/ -An -error -that -occurs -when -one -tries -to -build -a -reverse -NFA -with -/ -/ -/ -captures -enabled -. -Currently -this -isn -' -t -supported -but -we -probably -/ -/ -/ -should -support -it -at -some -point -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -UnsupportedCaptures -} -impl -BuildError -{ -/ -/ -/ -If -this -error -occurred -because -the -NFA -exceeded -the -configured -size -/ -/ -/ -limit -before -being -built -then -this -returns -the -configured -size -limit -. -/ -/ -/ -/ -/ -/ -The -limit -returned -is -what -was -configured -and -corresponds -to -the -/ -/ -/ -maximum -amount -of -heap -usage -in -bytes -. -pub -fn -size_limit -( -& -self -) -- -> -Option -< -usize -> -{ -match -self -. -kind -{ -BuildErrorKind -: -: -ExceededSizeLimit -{ -limit -} -= -> -Some -( -limit -) -_ -= -> -None -} -} -fn -kind -( -& -self -) -- -> -& -BuildErrorKind -{ -& -self -. -kind -} -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -( -crate -) -fn -syntax -( -err -: -regex_syntax -: -: -Error -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -Syntax -( -err -) -} -} -pub -( -crate -) -fn -captures -( -err -: -captures -: -: -GroupInfoError -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -Captures -( -err -) -} -} -pub -( -crate -) -fn -word -( -err -: -look -: -: -UnicodeWordBoundaryError -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -Word -( -err -) -} -} -pub -( -crate -) -fn -too_many_patterns -( -given -: -usize -) -- -> -BuildError -{ -let -limit -= -PatternID -: -: -LIMIT -; -BuildError -{ -kind -: -BuildErrorKind -: -: -TooManyPatterns -{ -given -limit -} -} -} -pub -( -crate -) -fn -too_many_states -( -given -: -usize -) -- -> -BuildError -{ -let -limit -= -StateID -: -: -LIMIT -; -BuildError -{ -kind -: -BuildErrorKind -: -: -TooManyStates -{ -given -limit -} -} -} -pub -( -crate -) -fn -exceeded_size_limit -( -limit -: -usize -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -ExceededSizeLimit -{ -limit -} -} -} -pub -( -crate -) -fn -invalid_capture_index -( -index -: -u32 -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -InvalidCaptureIndex -{ -index -} -} -} -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -( -crate -) -fn -unsupported_captures -( -) -- -> -BuildError -{ -BuildError -{ -kind -: -BuildErrorKind -: -: -UnsupportedCaptures -} -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -BuildError -{ -fn -source -( -& -self -) -- -> -Option -< -& -( -dyn -std -: -: -error -: -: -Error -+ -' -static -) -> -{ -match -self -. -kind -( -) -{ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -BuildErrorKind -: -: -Syntax -( -ref -err -) -= -> -Some -( -err -) -BuildErrorKind -: -: -Captures -( -ref -err -) -= -> -Some -( -err -) -_ -= -> -None -} -} -} -impl -core -: -: -fmt -: -: -Display -for -BuildError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -match -self -. -kind -( -) -{ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -BuildErrorKind -: -: -Syntax -( -_ -) -= -> -write -! -( -f -" -error -parsing -regex -" -) -BuildErrorKind -: -: -Captures -( -_ -) -= -> -{ -write -! -( -f -" -error -with -capture -groups -" -) -} -BuildErrorKind -: -: -Word -( -_ -) -= -> -{ -write -! -( -f -" -NFA -contains -Unicode -word -boundary -" -) -} -BuildErrorKind -: -: -TooManyPatterns -{ -given -limit -} -= -> -write -! -( -f -" -attempted -to -compile -{ -} -patterns -\ -which -exceeds -the -limit -of -{ -} -" -given -limit -) -BuildErrorKind -: -: -TooManyStates -{ -given -limit -} -= -> -write -! -( -f -" -attempted -to -compile -{ -} -NFA -states -\ -which -exceeds -the -limit -of -{ -} -" -given -limit -) -BuildErrorKind -: -: -ExceededSizeLimit -{ -limit -} -= -> -write -! -( -f -" -heap -usage -during -NFA -compilation -exceeded -limit -of -{ -} -" -limit -) -BuildErrorKind -: -: -InvalidCaptureIndex -{ -index -} -= -> -write -! -( -f -" -capture -group -index -{ -} -is -invalid -( -too -big -or -discontinuous -) -" -index -) -# -[ -cfg -( -feature -= -" -syntax -" -) -] -BuildErrorKind -: -: -UnsupportedCaptures -= -> -write -! -( -f -" -currently -captures -must -be -disabled -when -compiling -\ -a -reverse -NFA -" -) -} -} -} diff --git a/third_party/rust/regex-automata/src/nfa/thompson/literal_trie.rs b/third_party/rust/regex-automata/src/nfa/thompson/literal_trie.rs deleted file mode 100644 index 6f524fb6c7ee2..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/literal_trie.rs +++ /dev/null @@ -1,5232 +0,0 @@ -use -core -: -: -mem -; -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -{ -self -compiler -: -: -ThompsonRef -BuildError -Builder -} -util -: -: -primitives -: -: -{ -IteratorIndexExt -StateID -} -} -; -/ -/ -/ -A -trie -that -preserves -leftmost -- -first -match -semantics -. -/ -/ -/ -/ -/ -/ -This -is -a -purpose -- -built -data -structure -for -optimizing -' -lit1 -| -lit2 -| -. -. -| -litN -' -/ -/ -/ -patterns -. -It -can -* -only -* -handle -alternations -of -literals -which -makes -it -/ -/ -/ -somewhat -restricted -in -its -scope -but -literal -alternations -are -fairly -/ -/ -/ -common -. -/ -/ -/ -/ -/ -/ -At -a -5 -000 -foot -level -the -main -idea -of -this -trie -is -make -an -alternation -of -/ -/ -/ -literals -look -more -like -a -DFA -than -an -NFA -via -epsilon -removal -. -/ -/ -/ -/ -/ -/ -More -precisely -the -main -issue -is -in -how -alternations -are -compiled -into -/ -/ -/ -a -Thompson -NFA -. -Namely -each -alternation -gets -a -single -NFA -" -union -" -state -/ -/ -/ -with -an -epsilon -transition -for -every -branch -of -the -alternation -pointing -to -/ -/ -/ -an -NFA -state -corresponding -to -the -start -of -that -branch -. -The -main -problem -/ -/ -/ -with -this -representation -is -the -cost -of -computing -an -epsilon -closure -. -Once -/ -/ -/ -you -hit -the -alternation -' -s -start -state -it -acts -as -a -sort -of -" -clog -" -that -/ -/ -/ -requires -you -to -traverse -all -of -the -epsilon -transitions -to -compute -the -full -/ -/ -/ -closure -. -/ -/ -/ -/ -/ -/ -While -fixing -such -clogs -in -the -general -case -is -pretty -tricky -without -going -/ -/ -/ -to -a -DFA -( -or -perhaps -a -Glushkov -NFA -but -that -comes -with -other -problems -) -. -/ -/ -/ -But -at -least -in -the -case -of -an -alternation -of -literals -we -can -convert -/ -/ -/ -that -to -a -prefix -trie -without -too -much -cost -. -In -theory -that -' -s -all -you -/ -/ -/ -really -need -to -do -: -build -the -trie -and -then -compile -it -to -a -Thompson -NFA -. -/ -/ -/ -For -example -if -you -have -the -pattern -' -bar -| -baz -| -foo -' -then -using -a -trie -it -/ -/ -/ -is -transformed -to -something -like -' -b -( -a -( -r -| -z -) -) -| -f -' -. -This -reduces -the -clog -by -/ -/ -/ -reducing -the -number -of -epsilon -transitions -out -of -the -alternation -' -s -start -/ -/ -/ -state -from -3 -to -2 -( -it -actually -gets -down -to -1 -when -you -use -a -sparse -state -/ -/ -/ -which -we -do -below -) -. -It -' -s -a -small -effect -here -but -when -your -alternation -is -/ -/ -/ -huge -the -savings -is -also -huge -. -/ -/ -/ -/ -/ -/ -And -that -is -. -. -. -essentially -what -a -LiteralTrie -does -. -But -there -is -one -/ -/ -/ -hiccup -. -Consider -a -regex -like -' -sam -| -samwise -' -. -How -does -a -prefix -trie -compile -/ -/ -/ -that -when -leftmost -- -first -semantics -are -used -? -If -' -sam -| -samwise -' -was -the -/ -/ -/ -entire -regex -then -you -could -just -drop -the -' -samwise -' -branch -entirely -since -/ -/ -/ -it -is -impossible -to -match -( -' -sam -' -will -always -take -priority -and -since -it -/ -/ -/ -is -a -prefix -of -' -samwise -' -' -samwise -' -will -never -match -) -. -But -what -about -the -/ -/ -/ -regex -' -\ -b -( -sam -| -samwise -) -\ -b -' -? -In -that -case -you -can -' -t -remove -' -samwise -' -because -/ -/ -/ -it -might -match -when -' -sam -' -doesn -' -t -fall -on -a -word -boundary -. -/ -/ -/ -/ -/ -/ -The -main -idea -is -that -' -sam -| -samwise -' -can -be -translated -to -' -sam -( -? -: -| -wise -) -' -/ -/ -/ -which -is -a -precisely -equivalent -regex -that -also -gets -rid -of -the -clog -. -/ -/ -/ -/ -/ -/ -Another -example -is -' -zapper -| -z -| -zap -' -. -That -gets -translated -to -/ -/ -/ -' -z -( -? -: -apper -| -| -ap -) -' -. -/ -/ -/ -/ -/ -/ -We -accomplish -this -by -giving -each -state -in -the -trie -multiple -" -chunks -" -of -/ -/ -/ -transitions -. -Each -chunk -barrier -represents -a -match -. -The -idea -is -that -once -/ -/ -/ -you -know -a -match -occurs -none -of -the -transitions -after -the -match -can -be -/ -/ -/ -re -- -ordered -and -mixed -in -with -the -transitions -before -the -match -. -Otherwise -/ -/ -/ -the -match -semantics -could -be -changed -. -/ -/ -/ -/ -/ -/ -See -the -' -State -' -data -type -for -a -bit -more -detail -. -/ -/ -/ -/ -/ -/ -Future -work -: -/ -/ -/ -/ -/ -/ -* -In -theory -it -would -be -nice -to -generalize -the -idea -of -removing -clogs -and -/ -/ -/ -apply -it -to -the -NFA -graph -itself -. -Then -this -could -in -theory -work -for -/ -/ -/ -case -insensitive -alternations -of -literals -or -even -just -alternations -where -/ -/ -/ -each -branch -starts -with -a -non -- -epsilon -transition -. -/ -/ -/ -* -Could -we -instead -use -the -Aho -- -Corasick -algorithm -here -? -The -aho -- -corasick -/ -/ -/ -crate -deals -with -leftmost -- -first -matches -correctly -but -I -think -this -implies -/ -/ -/ -encoding -failure -transitions -into -a -Thompson -NFA -somehow -. -Which -seems -fine -/ -/ -/ -because -failure -transitions -are -just -unconditional -epsilon -transitions -? -/ -/ -/ -* -Or -perhaps -even -better -could -we -use -an -aho_corasick -: -: -AhoCorasick -/ -/ -/ -directly -? -At -time -of -writing -0 -. -7 -is -the -current -version -of -the -/ -/ -/ -aho -- -corasick -crate -and -that -definitely -cannot -be -used -as -- -is -. -But -if -we -/ -/ -/ -expose -the -underlying -finite -state -machine -API -then -could -we -use -it -? -That -/ -/ -/ -would -be -super -. -If -we -could -figure -that -out -it -might -also -lend -itself -to -/ -/ -/ -more -general -composition -of -finite -state -machines -. -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -LiteralTrie -{ -/ -/ -/ -The -set -of -trie -states -. -Each -state -contains -one -or -more -chunks -where -/ -/ -/ -each -chunk -is -a -sparse -set -of -transitions -to -other -states -. -A -leaf -state -/ -/ -/ -is -always -a -match -state -that -contains -only -empty -chunks -( -i -. -e -. -no -/ -/ -/ -transitions -) -. -states -: -Vec -< -State -> -/ -/ -/ -Whether -to -add -literals -in -reverse -to -the -trie -. -Useful -when -building -/ -/ -/ -a -reverse -NFA -automaton -. -rev -: -bool -} -impl -LiteralTrie -{ -/ -/ -/ -Create -a -new -literal -trie -that -adds -literals -in -the -forward -direction -. -pub -( -crate -) -fn -forward -( -) -- -> -LiteralTrie -{ -let -root -= -State -: -: -default -( -) -; -LiteralTrie -{ -states -: -vec -! -[ -root -] -rev -: -false -} -} -/ -/ -/ -Create -a -new -literal -trie -that -adds -literals -in -reverse -. -pub -( -crate -) -fn -reverse -( -) -- -> -LiteralTrie -{ -let -root -= -State -: -: -default -( -) -; -LiteralTrie -{ -states -: -vec -! -[ -root -] -rev -: -true -} -} -/ -/ -/ -Add -the -given -literal -to -this -trie -. -/ -/ -/ -/ -/ -/ -If -the -literal -could -not -be -added -because -the -StateID -space -was -/ -/ -/ -exhausted -then -an -error -is -returned -. -If -an -error -returns -the -trie -/ -/ -/ -is -in -an -unspecified -state -. -pub -( -crate -) -fn -add -( -& -mut -self -bytes -: -& -[ -u8 -] -) -- -> -Result -< -( -) -BuildError -> -{ -let -mut -prev -= -StateID -: -: -ZERO -; -let -mut -it -= -bytes -. -iter -( -) -. -copied -( -) -; -while -let -Some -( -b -) -= -if -self -. -rev -{ -it -. -next_back -( -) -} -else -{ -it -. -next -( -) -} -{ -prev -= -self -. -get_or_add_state -( -prev -b -) -? -; -} -self -. -states -[ -prev -] -. -add_match -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -If -the -given -transition -is -defined -then -return -the -next -state -ID -. -/ -/ -/ -Otherwise -add -the -transition -to -from -and -point -it -to -a -new -state -. -/ -/ -/ -/ -/ -/ -If -a -new -state -ID -could -not -be -allocated -then -an -error -is -returned -. -fn -get_or_add_state -( -& -mut -self -from -: -StateID -byte -: -u8 -) -- -> -Result -< -StateID -BuildError -> -{ -let -active -= -self -. -states -[ -from -] -. -active_chunk -( -) -; -match -active -. -binary_search_by_key -( -& -byte -| -t -| -t -. -byte -) -{ -Ok -( -i -) -= -> -Ok -( -active -[ -i -] -. -next -) -Err -( -i -) -= -> -{ -/ -/ -Add -a -new -state -and -get -its -ID -. -let -next -= -StateID -: -: -new -( -self -. -states -. -len -( -) -) -. -map_err -( -| -_ -| -{ -BuildError -: -: -too_many_states -( -self -. -states -. -len -( -) -) -} -) -? -; -self -. -states -. -push -( -State -: -: -default -( -) -) -; -/ -/ -Offset -our -position -to -account -for -all -transitions -and -not -/ -/ -just -the -ones -in -the -active -chunk -. -let -i -= -self -. -states -[ -from -] -. -active_chunk_start -( -) -+ -i -; -let -t -= -Transition -{ -byte -next -} -; -self -. -states -[ -from -] -. -transitions -. -insert -( -i -t -) -; -Ok -( -next -) -} -} -} -/ -/ -/ -Compile -this -literal -trie -to -the -NFA -builder -given -. -/ -/ -/ -/ -/ -/ -This -forwards -any -errors -that -may -occur -while -using -the -given -builder -. -pub -( -crate -) -fn -compile -( -& -self -builder -: -& -mut -Builder -) -- -> -Result -< -ThompsonRef -BuildError -> -{ -/ -/ -Compilation -proceeds -via -depth -- -first -traversal -of -the -trie -. -/ -/ -/ -/ -This -is -overall -pretty -brutal -. -The -recursive -version -of -this -is -/ -/ -deliciously -simple -. -( -See -' -compile_to_hir -' -below -for -what -it -might -/ -/ -look -like -. -) -But -recursion -on -a -trie -means -your -call -stack -grows -/ -/ -in -accordance -with -the -longest -literal -which -just -does -not -seem -/ -/ -appropriate -. -So -we -push -the -call -stack -to -the -heap -. -But -as -a -result -/ -/ -the -trie -traversal -becomes -pretty -brutal -because -we -essentially -/ -/ -have -to -encode -the -state -of -a -double -for -- -loop -into -an -explicit -call -/ -/ -frame -. -If -someone -can -simplify -this -without -using -recursion -that -' -d -/ -/ -be -great -. -/ -/ -' -end -' -is -our -match -state -for -this -trie -but -represented -in -the -the -/ -/ -NFA -. -Any -time -we -see -a -match -in -the -trie -we -insert -a -transition -/ -/ -from -the -current -state -we -' -re -in -to -' -end -' -. -let -end -= -builder -. -add_empty -( -) -? -; -let -mut -stack -= -vec -! -[ -] -; -let -mut -f -= -Frame -: -: -new -( -& -self -. -states -[ -StateID -: -: -ZERO -] -) -; -loop -{ -if -let -Some -( -t -) -= -f -. -transitions -. -next -( -) -{ -if -self -. -states -[ -t -. -next -] -. -is_leaf -( -) -{ -f -. -sparse -. -push -( -thompson -: -: -Transition -{ -start -: -t -. -byte -end -: -t -. -byte -next -: -end -} -) -; -} -else -{ -f -. -sparse -. -push -( -thompson -: -: -Transition -{ -start -: -t -. -byte -end -: -t -. -byte -/ -/ -This -is -a -little -funny -but -when -the -frame -we -create -/ -/ -below -completes -it -will -pop -this -parent -frame -off -/ -/ -and -modify -this -transition -to -point -to -the -correct -/ -/ -state -. -next -: -StateID -: -: -ZERO -} -) -; -stack -. -push -( -f -) -; -f -= -Frame -: -: -new -( -& -self -. -states -[ -t -. -next -] -) -; -} -continue -; -} -/ -/ -At -this -point -we -have -visited -all -transitions -in -f -. -chunk -so -/ -/ -add -it -as -a -sparse -NFA -state -. -Unless -the -chunk -was -empty -in -/ -/ -which -case -we -don -' -t -do -anything -. -if -! -f -. -sparse -. -is_empty -( -) -{ -let -chunk_id -= -if -f -. -sparse -. -len -( -) -= -= -1 -{ -builder -. -add_range -( -f -. -sparse -. -pop -( -) -. -unwrap -( -) -) -? -} -else -{ -let -sparse -= -mem -: -: -replace -( -& -mut -f -. -sparse -vec -! -[ -] -) -; -builder -. -add_sparse -( -sparse -) -? -} -; -f -. -union -. -push -( -chunk_id -) -; -} -/ -/ -Now -we -need -to -look -to -see -if -there -are -other -chunks -to -visit -. -if -let -Some -( -chunk -) -= -f -. -chunks -. -next -( -) -{ -/ -/ -If -we -' -re -here -it -means -we -' -re -on -the -second -( -or -greater -) -/ -/ -chunk -which -implies -there -is -a -match -at -this -point -. -So -/ -/ -connect -this -state -to -the -final -end -state -. -f -. -union -. -push -( -end -) -; -/ -/ -Advance -to -the -next -chunk -. -f -. -transitions -= -chunk -. -iter -( -) -; -continue -; -} -/ -/ -Now -that -we -are -out -of -chunks -we -have -completely -visited -/ -/ -this -state -. -So -turn -our -union -of -chunks -into -an -NFA -union -/ -/ -state -and -add -that -union -state -to -the -parent -state -' -s -current -/ -/ -sparse -state -. -( -If -there -is -no -parent -we -' -re -done -. -) -let -start -= -builder -. -add_union -( -f -. -union -) -? -; -match -stack -. -pop -( -) -{ -None -= -> -{ -return -Ok -( -ThompsonRef -{ -start -end -} -) -; -} -Some -( -mut -parent -) -= -> -{ -/ -/ -OK -because -the -only -way -a -frame -gets -pushed -on -to -the -/ -/ -stack -( -aside -from -the -root -) -is -when -a -transition -has -/ -/ -been -added -to -' -sparse -' -. -parent -. -sparse -. -last_mut -( -) -. -unwrap -( -) -. -next -= -start -; -f -= -parent -; -} -} -} -} -/ -/ -/ -Converts -this -trie -to -an -equivalent -HIR -expression -. -/ -/ -/ -/ -/ -/ -We -don -' -t -actually -use -this -but -it -' -s -useful -for -tests -. -In -particular -/ -/ -/ -it -provides -a -( -somewhat -) -human -readable -representation -of -the -trie -/ -/ -/ -itself -. -# -[ -cfg -( -test -) -] -fn -compile_to_hir -( -& -self -) -- -> -regex_syntax -: -: -hir -: -: -Hir -{ -self -. -compile_state_to_hir -( -StateID -: -: -ZERO -) -} -/ -/ -/ -The -recursive -implementation -of -' -to_hir -' -. -/ -/ -/ -/ -/ -/ -Notice -how -simple -this -is -compared -to -' -compile -' -above -. -' -compile -' -could -/ -/ -/ -be -similarly -simple -but -we -opt -to -not -use -recursion -in -order -to -avoid -/ -/ -/ -overflowing -the -stack -in -the -case -of -a -longer -literal -. -# -[ -cfg -( -test -) -] -fn -compile_state_to_hir -( -& -self -sid -: -StateID -) -- -> -regex_syntax -: -: -hir -: -: -Hir -{ -use -regex_syntax -: -: -hir -: -: -Hir -; -let -mut -alt -= -vec -! -[ -] -; -for -( -i -chunk -) -in -self -. -states -[ -sid -] -. -chunks -( -) -. -enumerate -( -) -{ -if -i -> -0 -{ -alt -. -push -( -Hir -: -: -empty -( -) -) -; -} -if -chunk -. -is_empty -( -) -{ -continue -; -} -let -mut -chunk_alt -= -vec -! -[ -] -; -for -t -in -chunk -. -iter -( -) -{ -chunk_alt -. -push -( -Hir -: -: -concat -( -vec -! -[ -Hir -: -: -literal -( -vec -! -[ -t -. -byte -] -) -self -. -compile_state_to_hir -( -t -. -next -) -] -) -) -; -} -alt -. -push -( -Hir -: -: -alternation -( -chunk_alt -) -) -; -} -Hir -: -: -alternation -( -alt -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -LiteralTrie -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -writeln -! -( -f -" -LiteralTrie -( -" -) -? -; -for -( -sid -state -) -in -self -. -states -. -iter -( -) -. -with_state_ids -( -) -{ -writeln -! -( -f -" -{ -: -06 -? -} -: -{ -: -? -} -" -sid -. -as_usize -( -) -state -) -? -; -} -writeln -! -( -f -" -) -" -) -? -; -Ok -( -( -) -) -} -} -/ -/ -/ -An -explicit -stack -frame -used -for -traversing -the -trie -without -using -/ -/ -/ -recursion -. -/ -/ -/ -/ -/ -/ -Each -frame -is -tied -to -the -traversal -of -a -single -trie -state -. -The -frame -is -/ -/ -/ -dropped -once -the -entire -state -( -and -all -of -its -children -) -have -been -visited -. -/ -/ -/ -The -" -output -" -of -compiling -a -state -is -the -' -union -' -vector -which -is -turn -/ -/ -/ -converted -to -a -NFA -union -state -. -Each -branch -of -the -union -corresponds -to -a -/ -/ -/ -chunk -in -the -trie -state -. -/ -/ -/ -/ -/ -/ -' -sparse -' -corresponds -to -the -set -of -transitions -for -a -particular -chunk -in -a -/ -/ -/ -trie -state -. -It -is -ultimately -converted -to -an -NFA -sparse -state -. -The -' -sparse -' -/ -/ -/ -field -after -being -converted -to -a -sparse -NFA -state -is -reused -for -any -/ -/ -/ -subsequent -chunks -in -the -trie -state -if -any -exist -. -# -[ -derive -( -Debug -) -] -struct -Frame -< -' -a -> -{ -/ -/ -/ -The -remaining -chunks -to -visit -for -a -trie -state -. -chunks -: -StateChunksIter -< -' -a -> -/ -/ -/ -The -transitions -of -the -current -chunk -that -we -' -re -iterating -over -. -Since -/ -/ -/ -every -trie -state -has -at -least -one -chunk -every -frame -is -initialized -/ -/ -/ -with -the -first -chunk -' -s -transitions -ready -to -be -consumed -. -transitions -: -core -: -: -slice -: -: -Iter -< -' -a -Transition -> -/ -/ -/ -The -NFA -state -IDs -pointing -to -the -start -of -each -chunk -compiled -by -/ -/ -/ -this -trie -state -. -This -ultimately -gets -converted -to -an -NFA -union -once -/ -/ -/ -the -entire -trie -state -( -and -all -of -its -children -) -have -been -compiled -. -/ -/ -/ -The -order -of -these -matters -for -leftmost -- -first -match -semantics -since -/ -/ -/ -earlier -matches -in -the -union -are -preferred -over -later -ones -. -union -: -Vec -< -StateID -> -/ -/ -/ -The -actual -NFA -transitions -for -a -single -chunk -in -a -trie -state -. -This -/ -/ -/ -gets -converted -to -an -NFA -sparse -state -and -its -corresponding -NFA -state -/ -/ -/ -ID -should -get -added -to -' -union -' -. -sparse -: -Vec -< -thompson -: -: -Transition -> -} -impl -< -' -a -> -Frame -< -' -a -> -{ -/ -/ -/ -Create -a -new -stack -frame -for -trie -traversal -. -This -initializes -the -/ -/ -/ -' -transitions -' -iterator -to -the -transitions -for -the -first -chunk -with -the -/ -/ -/ -' -chunks -' -iterator -being -every -chunk -after -the -first -one -. -fn -new -( -state -: -& -' -a -State -) -- -> -Frame -< -' -a -> -{ -let -mut -chunks -= -state -. -chunks -( -) -; -/ -/ -every -state -has -at -least -1 -chunk -let -chunk -= -chunks -. -next -( -) -. -unwrap -( -) -; -let -transitions -= -chunk -. -iter -( -) -; -Frame -{ -chunks -transitions -union -: -vec -! -[ -] -sparse -: -vec -! -[ -] -} -} -} -/ -/ -/ -A -state -in -a -trie -. -/ -/ -/ -/ -/ -/ -This -uses -a -sparse -representation -. -Since -we -don -' -t -use -literal -tries -/ -/ -/ -for -searching -and -ultimately -( -and -compilation -requires -visiting -every -/ -/ -/ -transition -anyway -) -we -use -a -sparse -representation -for -transitions -. -This -/ -/ -/ -means -we -save -on -memory -at -the -expense -of -' -LiteralTrie -: -: -add -' -being -perhaps -/ -/ -/ -a -bit -slower -. -/ -/ -/ -/ -/ -/ -While -' -transitions -' -is -pretty -standard -as -far -as -tries -goes -the -' -chunks -' -/ -/ -/ -piece -here -is -more -unusual -. -In -effect -' -chunks -' -defines -a -partitioning -/ -/ -/ -of -' -transitions -' -where -each -chunk -corresponds -to -a -distinct -set -of -/ -/ -/ -transitions -. -The -key -invariant -is -that -a -transition -in -one -chunk -cannot -/ -/ -/ -be -moved -to -another -chunk -. -This -is -the -secret -sauce -that -preserve -/ -/ -/ -leftmost -- -first -match -semantics -. -/ -/ -/ -/ -/ -/ -A -new -chunk -is -added -whenever -we -mark -a -state -as -a -match -state -. -Once -a -/ -/ -/ -new -chunk -is -added -the -old -active -chunk -is -frozen -and -is -never -mutated -/ -/ -/ -again -. -The -new -chunk -becomes -the -active -chunk -which -is -defined -as -/ -/ -/ -' -& -transitions -[ -chunks -. -last -( -) -. -map_or -( -0 -| -c -| -c -. -1 -) -. -. -] -' -. -Thus -a -state -where -/ -/ -/ -' -chunks -' -is -empty -actually -contains -one -chunk -. -Thus -every -state -contains -/ -/ -/ -at -least -one -( -possibly -empty -) -chunk -. -/ -/ -/ -/ -/ -/ -A -" -leaf -" -state -is -a -state -that -has -no -outgoing -transitions -( -so -/ -/ -/ -' -transitions -' -is -empty -) -. -Note -that -there -is -no -way -for -a -leaf -state -to -be -a -/ -/ -/ -non -- -matching -state -. -( -Although -while -building -the -trie -within -' -add -' -a -leaf -/ -/ -/ -state -may -exist -while -not -containing -any -matches -. -But -this -invariant -is -/ -/ -/ -only -broken -within -' -add -' -. -Once -' -add -' -returns -the -invariant -is -upheld -. -) -# -[ -derive -( -Clone -Default -) -] -struct -State -{ -transitions -: -Vec -< -Transition -> -chunks -: -Vec -< -( -usize -usize -) -> -} -impl -State -{ -/ -/ -/ -Mark -this -state -as -a -match -state -and -freeze -the -active -chunk -such -that -/ -/ -/ -it -can -not -be -further -mutated -. -fn -add_match -( -& -mut -self -) -{ -/ -/ -This -is -not -strictly -necessary -but -there -' -s -no -point -in -recording -/ -/ -another -match -by -adding -another -chunk -if -the -state -has -no -/ -/ -transitions -. -Note -though -that -we -only -skip -this -if -we -already -know -/ -/ -this -is -a -match -state -which -is -only -true -if -' -chunks -' -is -not -empty -. -/ -/ -Basically -if -we -didn -' -t -do -this -nothing -semantically -would -change -/ -/ -but -we -' -d -end -up -pushing -another -chunk -and -potentially -triggering -an -/ -/ -alloc -. -if -self -. -transitions -. -is_empty -( -) -& -& -! -self -. -chunks -. -is_empty -( -) -{ -return -; -} -let -chunk_start -= -self -. -active_chunk_start -( -) -; -let -chunk_end -= -self -. -transitions -. -len -( -) -; -self -. -chunks -. -push -( -( -chunk_start -chunk_end -) -) -; -} -/ -/ -/ -Returns -true -if -and -only -if -this -state -is -a -leaf -state -. -That -is -a -/ -/ -/ -state -that -has -no -outgoing -transitions -. -fn -is_leaf -( -& -self -) -- -> -bool -{ -self -. -transitions -. -is_empty -( -) -} -/ -/ -/ -Returns -an -iterator -over -all -of -the -chunks -( -including -the -currently -/ -/ -/ -active -chunk -) -in -this -state -. -Since -the -active -chunk -is -included -the -/ -/ -/ -iterator -is -guaranteed -to -always -yield -at -least -one -chunk -( -although -the -/ -/ -/ -chunk -may -be -empty -) -. -fn -chunks -( -& -self -) -- -> -StateChunksIter -< -' -_ -> -{ -StateChunksIter -{ -transitions -: -& -* -self -. -transitions -chunks -: -self -. -chunks -. -iter -( -) -active -: -Some -( -self -. -active_chunk -( -) -) -} -} -/ -/ -/ -Returns -the -active -chunk -as -a -slice -of -transitions -. -fn -active_chunk -( -& -self -) -- -> -& -[ -Transition -] -{ -let -start -= -self -. -active_chunk_start -( -) -; -& -self -. -transitions -[ -start -. -. -] -} -/ -/ -/ -Returns -the -index -into -' -transitions -' -where -the -active -chunk -starts -. -fn -active_chunk_start -( -& -self -) -- -> -usize -{ -self -. -chunks -. -last -( -) -. -map_or -( -0 -| -& -( -_ -end -) -| -end -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -State -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -spacing -= -" -" -; -for -( -i -chunk -) -in -self -. -chunks -( -) -. -enumerate -( -) -{ -if -i -> -0 -{ -write -! -( -f -" -{ -} -MATCH -" -spacing -) -? -; -} -spacing -= -" -" -; -for -( -j -t -) -in -chunk -. -iter -( -) -. -enumerate -( -) -{ -spacing -= -" -" -; -if -j -= -= -0 -& -& -i -> -0 -{ -write -! -( -f -" -" -) -? -; -} -else -if -j -> -0 -{ -write -! -( -f -" -" -) -? -; -} -write -! -( -f -" -{ -: -? -} -" -t -) -? -; -} -} -Ok -( -( -) -) -} -} -/ -/ -/ -An -iterator -over -all -of -the -chunks -in -a -state -including -the -active -chunk -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -State -: -: -chunks -. -We -name -this -iterator -so -that -/ -/ -/ -we -can -include -it -in -the -Frame -type -for -non -- -recursive -trie -traversal -. -# -[ -derive -( -Debug -) -] -struct -StateChunksIter -< -' -a -> -{ -transitions -: -& -' -a -[ -Transition -] -chunks -: -core -: -: -slice -: -: -Iter -< -' -a -( -usize -usize -) -> -active -: -Option -< -& -' -a -[ -Transition -] -> -} -impl -< -' -a -> -Iterator -for -StateChunksIter -< -' -a -> -{ -type -Item -= -& -' -a -[ -Transition -] -; -fn -next -( -& -mut -self -) -- -> -Option -< -& -' -a -[ -Transition -] -> -{ -if -let -Some -( -& -( -start -end -) -) -= -self -. -chunks -. -next -( -) -{ -return -Some -( -& -self -. -transitions -[ -start -. -. -end -] -) -; -} -if -let -Some -( -chunk -) -= -self -. -active -. -take -( -) -{ -return -Some -( -chunk -) -; -} -None -} -} -/ -/ -/ -A -single -transition -in -a -trie -to -another -state -. -# -[ -derive -( -Clone -Copy -) -] -struct -Transition -{ -byte -: -u8 -next -: -StateID -} -impl -core -: -: -fmt -: -: -Debug -for -Transition -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -: -? -} -= -> -{ -} -" -crate -: -: -util -: -: -escape -: -: -DebugByte -( -self -. -byte -) -self -. -next -. -as_usize -( -) -) -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -bstr -: -: -B -; -use -regex_syntax -: -: -hir -: -: -Hir -; -use -super -: -: -* -; -# -[ -test -] -fn -zap -( -) -{ -let -mut -trie -= -LiteralTrie -: -: -forward -( -) -; -trie -. -add -( -b -" -zapper -" -) -. -unwrap -( -) -; -trie -. -add -( -b -" -z -" -) -. -unwrap -( -) -; -trie -. -add -( -b -" -zap -" -) -. -unwrap -( -) -; -let -got -= -trie -. -compile_to_hir -( -) -; -let -expected -= -Hir -: -: -concat -( -vec -! -[ -Hir -: -: -literal -( -B -( -" -z -" -) -) -Hir -: -: -alternation -( -vec -! -[ -Hir -: -: -literal -( -B -( -" -apper -" -) -) -Hir -: -: -empty -( -) -Hir -: -: -literal -( -B -( -" -ap -" -) -) -] -) -] -) -; -assert_eq -! -( -expected -got -) -; -} -# -[ -test -] -fn -maker -( -) -{ -let -mut -trie -= -LiteralTrie -: -: -forward -( -) -; -trie -. -add -( -b -" -make -" -) -. -unwrap -( -) -; -trie -. -add -( -b -" -maple -" -) -. -unwrap -( -) -; -trie -. -add -( -b -" -maker -" -) -. -unwrap -( -) -; -let -got -= -trie -. -compile_to_hir -( -) -; -let -expected -= -Hir -: -: -concat -( -vec -! -[ -Hir -: -: -literal -( -B -( -" -ma -" -) -) -Hir -: -: -alternation -( -vec -! -[ -Hir -: -: -concat -( -vec -! -[ -Hir -: -: -literal -( -B -( -" -ke -" -) -) -Hir -: -: -alternation -( -vec -! -[ -Hir -: -: -empty -( -) -Hir -: -: -literal -( -B -( -" -r -" -) -) -] -) -] -) -Hir -: -: -literal -( -B -( -" -ple -" -) -) -] -) -] -) -; -assert_eq -! -( -expected -got -) -; -} -} diff --git a/third_party/rust/regex-automata/src/nfa/thompson/map.rs b/third_party/rust/regex-automata/src/nfa/thompson/map.rs deleted file mode 100644 index e0a3046c3969f..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/map.rs +++ /dev/null @@ -1,2789 +0,0 @@ -/ -/ -This -module -contains -a -couple -simple -and -purpose -built -hash -maps -. -The -key -/ -/ -trade -off -they -make -is -that -they -serve -as -caches -rather -than -true -maps -. -That -/ -/ -is -inserting -a -new -entry -may -cause -eviction -of -another -entry -. -This -gives -/ -/ -us -two -things -. -First -there -' -s -less -overhead -associated -with -inserts -and -/ -/ -lookups -. -Secondly -it -lets -us -control -our -memory -usage -. -/ -/ -/ -/ -These -maps -are -used -in -some -fairly -hot -code -when -generating -NFA -states -for -/ -/ -large -Unicode -character -classes -. -/ -/ -/ -/ -Instead -of -exposing -a -rich -hashmap -entry -API -we -just -permit -the -caller -to -/ -/ -produce -a -hash -of -the -key -directly -. -The -hash -can -then -be -reused -for -both -/ -/ -lookups -and -insertions -at -the -cost -of -leaking -abstraction -a -bit -. -But -these -/ -/ -are -for -internal -use -only -so -it -' -s -fine -. -/ -/ -/ -/ -The -Utf8BoundedMap -is -used -for -Daciuk -' -s -algorithm -for -constructing -a -/ -/ -( -almost -) -minimal -DFA -for -large -Unicode -character -classes -in -linear -time -. -/ -/ -( -Daciuk -' -s -algorithm -is -always -used -when -compiling -forward -NFAs -. -For -reverse -/ -/ -NFAs -it -' -s -only -used -when -the -compiler -is -configured -to -' -shrink -' -the -NFA -/ -/ -since -there -' -s -a -bit -more -expense -in -the -reverse -direction -. -) -/ -/ -/ -/ -The -Utf8SuffixMap -is -used -when -compiling -large -Unicode -character -classes -for -/ -/ -reverse -NFAs -when -' -shrink -' -is -disabled -. -Specifically -it -augments -the -naive -/ -/ -construction -of -UTF -- -8 -automata -by -caching -common -suffixes -. -This -doesn -' -t -/ -/ -get -the -same -space -savings -as -Daciuk -' -s -algorithm -but -it -' -s -basically -as -/ -/ -fast -as -the -naive -approach -and -typically -winds -up -using -less -memory -( -since -/ -/ -it -generates -smaller -NFAs -) -despite -the -presence -of -the -cache -. -/ -/ -/ -/ -These -maps -effectively -represent -caching -mechanisms -for -sparse -and -/ -/ -byte -- -range -NFA -states -respectively -. -The -former -represents -a -single -NFA -/ -/ -state -with -many -transitions -of -equivalent -priority -while -the -latter -/ -/ -represents -a -single -NFA -state -with -a -single -transition -. -( -Neither -state -ever -/ -/ -has -or -is -an -epsilon -transition -. -) -Thus -they -have -different -key -types -. -It -' -s -/ -/ -likely -we -could -make -one -generic -map -but -the -machinery -didn -' -t -seem -worth -/ -/ -it -. -They -are -simple -enough -. -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -Transition -util -: -: -{ -int -: -: -{ -Usize -U64 -} -primitives -: -: -StateID -} -} -; -/ -/ -Basic -FNV -- -1a -hash -constants -as -described -in -: -/ -/ -https -: -/ -/ -en -. -wikipedia -. -org -/ -wiki -/ -Fowler -% -E2 -% -80 -% -93Noll -% -E2 -% -80 -% -93Vo_hash_function -const -PRIME -: -u64 -= -1099511628211 -; -const -INIT -: -u64 -= -14695981039346656037 -; -/ -/ -/ -A -bounded -hash -map -where -the -key -is -a -sequence -of -NFA -transitions -and -the -/ -/ -/ -value -is -a -pre -- -existing -NFA -state -ID -. -/ -/ -/ -/ -/ -/ -std -' -s -hashmap -can -be -used -for -this -however -this -map -has -two -important -/ -/ -/ -advantages -. -Firstly -it -has -lower -overhead -. -Secondly -it -permits -us -to -/ -/ -/ -control -our -memory -usage -by -limited -the -number -of -slots -. -In -general -the -/ -/ -/ -cost -here -is -that -this -map -acts -as -a -cache -. -That -is -inserting -a -new -entry -/ -/ -/ -may -remove -an -old -entry -. -We -are -okay -with -this -since -it -does -not -impact -/ -/ -/ -correctness -in -the -cases -where -it -is -used -. -The -only -effect -that -dropping -/ -/ -/ -states -from -the -cache -has -is -that -the -resulting -NFA -generated -may -be -bigger -/ -/ -/ -than -it -otherwise -would -be -. -/ -/ -/ -/ -/ -/ -This -improves -benchmarks -that -compile -large -Unicode -character -classes -/ -/ -/ -since -it -makes -the -generation -of -( -almost -) -minimal -UTF -- -8 -automaton -faster -. -/ -/ -/ -Specifically -one -could -observe -the -difference -with -std -' -s -hashmap -via -/ -/ -/ -something -like -the -following -benchmark -: -/ -/ -/ -/ -/ -/ -hyperfine -" -regex -- -cli -debug -nfa -thompson -- -- -quiet -- -- -reverse -' -\ -w -{ -90 -} -ecurB -' -" -/ -/ -/ -/ -/ -/ -But -to -observe -that -difference -you -' -d -have -to -modify -the -code -to -use -/ -/ -/ -std -' -s -hashmap -. -/ -/ -/ -/ -/ -/ -It -is -quite -possible -that -there -is -a -better -way -to -approach -this -problem -. -/ -/ -/ -For -example -if -there -happens -to -be -a -very -common -state -that -collides -with -/ -/ -/ -a -lot -of -less -frequent -states -then -we -could -wind -up -with -very -poor -caching -/ -/ -/ -behavior -. -Alas -the -effectiveness -of -this -cache -has -not -been -measured -. -/ -/ -/ -Instead -ad -hoc -experiments -suggest -that -it -is -" -good -enough -. -" -Additional -/ -/ -/ -smarts -( -such -as -an -LRU -eviction -policy -) -have -to -be -weighed -against -the -/ -/ -/ -amount -of -extra -time -they -cost -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Utf8BoundedMap -{ -/ -/ -/ -The -current -version -of -this -map -. -Only -entries -with -matching -versions -/ -/ -/ -are -considered -during -lookups -. -If -an -entry -is -found -with -a -mismatched -/ -/ -/ -version -then -the -map -behaves -as -if -the -entry -does -not -exist -. -/ -/ -/ -/ -/ -/ -This -makes -it -possible -to -clear -the -map -by -simply -incrementing -the -/ -/ -/ -version -number -instead -of -actually -deallocating -any -storage -. -version -: -u16 -/ -/ -/ -The -total -number -of -entries -this -map -can -store -. -capacity -: -usize -/ -/ -/ -The -actual -entries -keyed -by -hash -. -Collisions -between -different -states -/ -/ -/ -result -in -the -old -state -being -dropped -. -map -: -Vec -< -Utf8BoundedEntry -> -} -/ -/ -/ -An -entry -in -this -map -. -# -[ -derive -( -Clone -Debug -Default -) -] -struct -Utf8BoundedEntry -{ -/ -/ -/ -The -version -of -the -map -used -to -produce -this -entry -. -If -this -entry -' -s -/ -/ -/ -version -does -not -match -the -current -version -of -the -map -then -the -map -/ -/ -/ -should -behave -as -if -this -entry -does -not -exist -. -version -: -u16 -/ -/ -/ -The -key -which -is -a -sorted -sequence -of -non -- -overlapping -NFA -transitions -. -key -: -Vec -< -Transition -> -/ -/ -/ -The -state -ID -corresponding -to -the -state -containing -the -transitions -in -/ -/ -/ -this -entry -. -val -: -StateID -} -impl -Utf8BoundedMap -{ -/ -/ -/ -Create -a -new -bounded -map -with -the -given -capacity -. -The -map -will -never -/ -/ -/ -grow -beyond -the -given -size -. -/ -/ -/ -/ -/ -/ -Note -that -this -does -not -allocate -. -Instead -callers -must -call -clear -/ -/ -/ -before -using -this -map -. -clear -will -allocate -space -if -necessary -. -/ -/ -/ -/ -/ -/ -This -avoids -the -need -to -pay -for -the -allocation -of -this -map -when -/ -/ -/ -compiling -regexes -that -lack -large -Unicode -character -classes -. -pub -fn -new -( -capacity -: -usize -) -- -> -Utf8BoundedMap -{ -assert -! -( -capacity -> -0 -) -; -Utf8BoundedMap -{ -version -: -0 -capacity -map -: -vec -! -[ -] -} -} -/ -/ -/ -Clear -this -map -of -all -entries -but -permit -the -reuse -of -allocation -/ -/ -/ -if -possible -. -/ -/ -/ -/ -/ -/ -This -must -be -called -before -the -map -can -be -used -. -pub -fn -clear -( -& -mut -self -) -{ -if -self -. -map -. -is_empty -( -) -{ -self -. -map -= -vec -! -[ -Utf8BoundedEntry -: -: -default -( -) -; -self -. -capacity -] -; -} -else -{ -self -. -version -= -self -. -version -. -wrapping_add -( -1 -) -; -/ -/ -If -we -loop -back -to -version -0 -then -we -forcefully -clear -the -/ -/ -entire -map -. -Otherwise -it -might -be -possible -to -incorrectly -/ -/ -match -entries -used -to -generate -other -NFAs -. -if -self -. -version -= -= -0 -{ -self -. -map -= -vec -! -[ -Utf8BoundedEntry -: -: -default -( -) -; -self -. -capacity -] -; -} -} -} -/ -/ -/ -Return -a -hash -of -the -given -transitions -. -pub -fn -hash -( -& -self -key -: -& -[ -Transition -] -) -- -> -usize -{ -let -mut -h -= -INIT -; -for -t -in -key -{ -h -= -( -h -^ -u64 -: -: -from -( -t -. -start -) -) -. -wrapping_mul -( -PRIME -) -; -h -= -( -h -^ -u64 -: -: -from -( -t -. -end -) -) -. -wrapping_mul -( -PRIME -) -; -h -= -( -h -^ -t -. -next -. -as_u64 -( -) -) -. -wrapping_mul -( -PRIME -) -; -} -( -h -% -self -. -map -. -len -( -) -. -as_u64 -( -) -) -. -as_usize -( -) -} -/ -/ -/ -Retrieve -the -cached -state -ID -corresponding -to -the -given -key -. -The -hash -/ -/ -/ -given -must -have -been -computed -with -hash -using -the -same -key -value -. -/ -/ -/ -/ -/ -/ -If -there -is -no -cached -state -with -the -given -transitions -then -None -is -/ -/ -/ -returned -. -pub -fn -get -( -& -mut -self -key -: -& -[ -Transition -] -hash -: -usize -) -- -> -Option -< -StateID -> -{ -let -entry -= -& -self -. -map -[ -hash -] -; -if -entry -. -version -! -= -self -. -version -{ -return -None -; -} -/ -/ -There -may -be -a -hash -collision -so -we -need -to -confirm -real -equality -. -if -entry -. -key -! -= -key -{ -return -None -; -} -Some -( -entry -. -val -) -} -/ -/ -/ -Add -a -cached -state -to -this -map -with -the -given -key -. -Callers -should -/ -/ -/ -ensure -that -state_id -points -to -a -state -that -contains -precisely -the -/ -/ -/ -NFA -transitions -given -. -/ -/ -/ -/ -/ -/ -hash -must -have -been -computed -using -the -hash -method -with -the -same -/ -/ -/ -key -. -pub -fn -set -( -& -mut -self -key -: -Vec -< -Transition -> -hash -: -usize -state_id -: -StateID -) -{ -self -. -map -[ -hash -] -= -Utf8BoundedEntry -{ -version -: -self -. -version -key -val -: -state_id -} -; -} -} -/ -/ -/ -A -cache -of -suffixes -used -to -modestly -compress -UTF -- -8 -automata -for -large -/ -/ -/ -Unicode -character -classes -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Utf8SuffixMap -{ -/ -/ -/ -The -current -version -of -this -map -. -Only -entries -with -matching -versions -/ -/ -/ -are -considered -during -lookups -. -If -an -entry -is -found -with -a -mismatched -/ -/ -/ -version -then -the -map -behaves -as -if -the -entry -does -not -exist -. -version -: -u16 -/ -/ -/ -The -total -number -of -entries -this -map -can -store -. -capacity -: -usize -/ -/ -/ -The -actual -entries -keyed -by -hash -. -Collisions -between -different -states -/ -/ -/ -result -in -the -old -state -being -dropped -. -map -: -Vec -< -Utf8SuffixEntry -> -} -/ -/ -/ -A -key -that -uniquely -identifies -an -NFA -state -. -It -is -a -triple -that -represents -/ -/ -/ -a -transition -from -one -state -for -a -particular -byte -range -. -# -[ -derive -( -Clone -Debug -Default -Eq -PartialEq -) -] -pub -struct -Utf8SuffixKey -{ -pub -from -: -StateID -pub -start -: -u8 -pub -end -: -u8 -} -/ -/ -/ -An -entry -in -this -map -. -# -[ -derive -( -Clone -Debug -Default -) -] -struct -Utf8SuffixEntry -{ -/ -/ -/ -The -version -of -the -map -used -to -produce -this -entry -. -If -this -entry -' -s -/ -/ -/ -version -does -not -match -the -current -version -of -the -map -then -the -map -/ -/ -/ -should -behave -as -if -this -entry -does -not -exist -. -version -: -u16 -/ -/ -/ -The -key -which -consists -of -a -transition -in -a -particular -state -. -key -: -Utf8SuffixKey -/ -/ -/ -The -identifier -that -the -transition -in -the -key -maps -to -. -val -: -StateID -} -impl -Utf8SuffixMap -{ -/ -/ -/ -Create -a -new -bounded -map -with -the -given -capacity -. -The -map -will -never -/ -/ -/ -grow -beyond -the -given -size -. -/ -/ -/ -/ -/ -/ -Note -that -this -does -not -allocate -. -Instead -callers -must -call -clear -/ -/ -/ -before -using -this -map -. -clear -will -allocate -space -if -necessary -. -/ -/ -/ -/ -/ -/ -This -avoids -the -need -to -pay -for -the -allocation -of -this -map -when -/ -/ -/ -compiling -regexes -that -lack -large -Unicode -character -classes -. -pub -fn -new -( -capacity -: -usize -) -- -> -Utf8SuffixMap -{ -assert -! -( -capacity -> -0 -) -; -Utf8SuffixMap -{ -version -: -0 -capacity -map -: -vec -! -[ -] -} -} -/ -/ -/ -Clear -this -map -of -all -entries -but -permit -the -reuse -of -allocation -/ -/ -/ -if -possible -. -/ -/ -/ -/ -/ -/ -This -must -be -called -before -the -map -can -be -used -. -pub -fn -clear -( -& -mut -self -) -{ -if -self -. -map -. -is_empty -( -) -{ -self -. -map -= -vec -! -[ -Utf8SuffixEntry -: -: -default -( -) -; -self -. -capacity -] -; -} -else -{ -self -. -version -= -self -. -version -. -wrapping_add -( -1 -) -; -if -self -. -version -= -= -0 -{ -self -. -map -= -vec -! -[ -Utf8SuffixEntry -: -: -default -( -) -; -self -. -capacity -] -; -} -} -} -/ -/ -/ -Return -a -hash -of -the -given -transition -. -pub -fn -hash -( -& -self -key -: -& -Utf8SuffixKey -) -- -> -usize -{ -/ -/ -Basic -FNV -- -1a -hash -as -described -: -/ -/ -https -: -/ -/ -en -. -wikipedia -. -org -/ -wiki -/ -Fowler -% -E2 -% -80 -% -93Noll -% -E2 -% -80 -% -93Vo_hash_function -const -PRIME -: -u64 -= -1099511628211 -; -const -INIT -: -u64 -= -14695981039346656037 -; -let -mut -h -= -INIT -; -h -= -( -h -^ -key -. -from -. -as_u64 -( -) -) -. -wrapping_mul -( -PRIME -) -; -h -= -( -h -^ -u64 -: -: -from -( -key -. -start -) -) -. -wrapping_mul -( -PRIME -) -; -h -= -( -h -^ -u64 -: -: -from -( -key -. -end -) -) -. -wrapping_mul -( -PRIME -) -; -( -h -% -self -. -map -. -len -( -) -. -as_u64 -( -) -) -. -as_usize -( -) -} -/ -/ -/ -Retrieve -the -cached -state -ID -corresponding -to -the -given -key -. -The -hash -/ -/ -/ -given -must -have -been -computed -with -hash -using -the -same -key -value -. -/ -/ -/ -/ -/ -/ -If -there -is -no -cached -state -with -the -given -key -then -None -is -returned -. -pub -fn -get -( -& -mut -self -key -: -& -Utf8SuffixKey -hash -: -usize -) -- -> -Option -< -StateID -> -{ -let -entry -= -& -self -. -map -[ -hash -] -; -if -entry -. -version -! -= -self -. -version -{ -return -None -; -} -if -key -! -= -& -entry -. -key -{ -return -None -; -} -Some -( -entry -. -val -) -} -/ -/ -/ -Add -a -cached -state -to -this -map -with -the -given -key -. -Callers -should -/ -/ -/ -ensure -that -state_id -points -to -a -state -that -contains -precisely -the -/ -/ -/ -NFA -transition -given -. -/ -/ -/ -/ -/ -/ -hash -must -have -been -computed -using -the -hash -method -with -the -same -/ -/ -/ -key -. -pub -fn -set -( -& -mut -self -key -: -Utf8SuffixKey -hash -: -usize -state_id -: -StateID -) -{ -self -. -map -[ -hash -] -= -Utf8SuffixEntry -{ -version -: -self -. -version -key -val -: -state_id -} -; -} -} diff --git a/third_party/rust/regex-automata/src/nfa/thompson/mod.rs b/third_party/rust/regex-automata/src/nfa/thompson/mod.rs deleted file mode 100644 index 6d3b302bed8d0..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/mod.rs +++ /dev/null @@ -1,832 +0,0 @@ -/ -* -! -Defines -a -Thompson -NFA -and -provides -the -[ -PikeVM -] -( -pikevm -: -: -PikeVM -) -and -[ -BoundedBacktracker -] -( -backtrack -: -: -BoundedBacktracker -) -regex -engines -. -A -Thompson -NFA -( -non -- -deterministic -finite -automaton -) -is -arguably -_the_ -central -data -type -in -this -library -. -It -is -the -result -of -what -is -commonly -referred -to -as -" -regex -compilation -. -" -That -is -turning -a -regex -pattern -from -its -concrete -syntax -string -into -something -that -can -run -a -search -looks -roughly -like -this -: -* -A -& -str -is -parsed -into -a -[ -regex -- -syntax -: -: -ast -: -: -Ast -] -( -regex_syntax -: -: -ast -: -: -Ast -) -. -* -An -Ast -is -translated -into -a -[ -regex -- -syntax -: -: -hir -: -: -Hir -] -( -regex_syntax -: -: -hir -: -: -Hir -) -. -* -An -Hir -is -compiled -into -a -[ -NFA -] -. -* -The -NFA -is -then -used -to -build -one -of -a -few -different -regex -engines -: -* -An -NFA -is -used -directly -in -the -PikeVM -and -BoundedBacktracker -engines -. -* -An -NFA -is -used -by -a -[ -hybrid -NFA -/ -DFA -] -( -crate -: -: -hybrid -) -to -build -out -a -DFA -' -s -transition -table -at -search -time -. -* -An -NFA -assuming -it -is -one -- -pass -is -used -to -build -a -full -[ -one -- -pass -DFA -] -( -crate -: -: -dfa -: -: -onepass -) -ahead -of -time -. -* -An -NFA -is -used -to -build -a -[ -full -DFA -] -( -crate -: -: -dfa -) -ahead -of -time -. -The -[ -meta -] -( -crate -: -: -meta -) -regex -engine -makes -all -of -these -choices -for -you -based -on -various -criteria -. -However -if -you -have -a -lower -level -use -case -_you_ -can -build -any -of -the -above -regex -engines -and -use -them -directly -. -But -you -must -start -here -by -building -an -NFA -. -# -Details -It -is -perhaps -worth -expanding -a -bit -more -on -what -it -means -to -go -through -the -& -str -- -> -Ast -- -> -Hir -- -> -NFA -process -. -* -Parsing -a -string -into -an -Ast -gives -it -a -structured -representation -. -Crucially -the -size -and -amount -of -work -done -in -this -step -is -proportional -to -the -size -of -the -original -string -. -No -optimization -or -Unicode -handling -is -done -at -this -point -. -This -means -that -parsing -into -an -Ast -has -very -predictable -costs -. -Moreover -an -Ast -can -be -roundtripped -back -to -its -original -pattern -string -as -written -. -* -Translating -an -Ast -into -an -Hir -is -a -process -by -which -the -structured -representation -is -simplified -down -to -its -most -fundamental -components -. -Translation -deals -with -flags -such -as -case -insensitivity -by -converting -things -like -( -? -i -: -a -) -to -[ -Aa -] -. -Translation -is -also -where -Unicode -tables -are -consulted -to -resolve -things -like -\ -p -{ -Emoji -} -and -\ -p -{ -Greek -} -. -It -also -flattens -each -character -class -regardless -of -how -deeply -nested -it -is -into -a -single -sequence -of -non -- -overlapping -ranges -. -All -the -various -literal -forms -are -thrown -out -in -favor -of -one -common -representation -. -Overall -the -Hir -is -small -enough -to -fit -into -your -head -and -makes -analysis -and -other -tasks -much -simpler -. -* -Compiling -an -Hir -into -an -NFA -formulates -the -regex -into -a -finite -state -machine -whose -transitions -are -defined -over -bytes -. -For -example -an -Hir -might -have -a -Unicode -character -class -corresponding -to -a -sequence -of -ranges -defined -in -terms -of -char -. -Compilation -is -then -responsible -for -turning -those -ranges -into -a -UTF -- -8 -automaton -. -That -is -an -automaton -that -matches -the -UTF -- -8 -encoding -of -just -the -codepoints -specified -by -those -ranges -. -Otherwise -the -main -job -of -an -NFA -is -to -serve -as -a -byte -- -code -of -sorts -for -a -virtual -machine -. -It -can -be -seen -as -a -sequence -of -instructions -for -how -to -match -a -regex -. -* -/ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -pub -mod -backtrack -; -mod -builder -; -# -[ -cfg -( -feature -= -" -syntax -" -) -] -mod -compiler -; -mod -error -; -# -[ -cfg -( -feature -= -" -syntax -" -) -] -mod -literal_trie -; -# -[ -cfg -( -feature -= -" -syntax -" -) -] -mod -map -; -mod -nfa -; -# -[ -cfg -( -feature -= -" -nfa -- -pikevm -" -) -] -pub -mod -pikevm -; -# -[ -cfg -( -feature -= -" -syntax -" -) -] -mod -range_trie -; -pub -use -self -: -: -{ -builder -: -: -Builder -error -: -: -BuildError -nfa -: -: -{ -DenseTransitions -PatternIter -SparseTransitions -State -Transition -NFA -} -} -; -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -use -compiler -: -: -{ -Compiler -Config -WhichCaptures -} -; diff --git a/third_party/rust/regex-automata/src/nfa/thompson/nfa.rs b/third_party/rust/regex-automata/src/nfa/thompson/nfa.rs deleted file mode 100644 index 5d8c12198388b..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/nfa.rs +++ /dev/null @@ -1,21598 +0,0 @@ -use -core -: -: -{ -fmt -mem -} -; -use -alloc -: -: -{ -boxed -: -: -Box -format -string -: -: -String -sync -: -: -Arc -vec -vec -: -: -Vec -} -; -# -[ -cfg -( -feature -= -" -syntax -" -) -] -use -crate -: -: -nfa -: -: -thompson -: -: -{ -compiler -: -: -{ -Compiler -Config -} -error -: -: -BuildError -} -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -builder -: -: -Builder -util -: -: -{ -alphabet -: -: -{ -self -ByteClassSet -ByteClasses -} -captures -: -: -{ -GroupInfo -GroupInfoError -} -look -: -: -{ -Look -LookMatcher -LookSet -} -primitives -: -: -{ -IteratorIndexExt -PatternID -PatternIDIter -SmallIndex -StateID -} -sparse_set -: -: -SparseSet -} -} -; -/ -/ -/ -A -byte -oriented -Thompson -non -- -deterministic -finite -automaton -( -NFA -) -. -/ -/ -/ -/ -/ -/ -A -Thompson -NFA -is -a -finite -state -machine -that -permits -unconditional -epsilon -/ -/ -/ -transitions -but -guarantees -that -there -exists -at -most -one -non -- -epsilon -/ -/ -/ -transition -for -each -element -in -the -alphabet -for -each -state -. -/ -/ -/ -/ -/ -/ -An -NFA -may -be -used -directly -for -searching -for -analysis -or -to -build -/ -/ -/ -a -deterministic -finite -automaton -( -DFA -) -. -/ -/ -/ -/ -/ -/ -# -Cheap -clones -/ -/ -/ -/ -/ -/ -Since -an -NFA -is -a -core -data -type -in -this -crate -that -many -other -regex -/ -/ -/ -engines -are -based -on -top -of -it -is -convenient -to -give -ownership -of -an -NFA -/ -/ -/ -to -said -regex -engines -. -Because -of -this -an -NFA -uses -reference -counting -/ -/ -/ -internally -. -Therefore -it -is -cheap -to -clone -and -it -is -encouraged -to -do -so -. -/ -/ -/ -/ -/ -/ -# -Capabilities -/ -/ -/ -/ -/ -/ -Using -an -NFA -for -searching -via -the -/ -/ -/ -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -provides -the -most -amount -/ -/ -/ -of -" -power -" -of -any -regex -engine -in -this -crate -. -Namely -it -supports -the -/ -/ -/ -following -in -all -cases -: -/ -/ -/ -/ -/ -/ -1 -. -Detection -of -a -match -. -/ -/ -/ -2 -. -Location -of -a -match -including -both -the -start -and -end -offset -in -a -/ -/ -/ -single -pass -of -the -haystack -. -/ -/ -/ -3 -. -Location -of -matching -capturing -groups -. -/ -/ -/ -4 -. -Handles -multiple -patterns -including -( -1 -) -- -( -3 -) -when -multiple -patterns -are -/ -/ -/ -present -. -/ -/ -/ -/ -/ -/ -# -Capturing -Groups -/ -/ -/ -/ -/ -/ -Groups -refer -to -parenthesized -expressions -inside -a -regex -pattern -. -They -look -/ -/ -/ -like -this -where -exp -is -an -arbitrary -regex -: -/ -/ -/ -/ -/ -/ -* -( -exp -) -- -An -unnamed -capturing -group -. -/ -/ -/ -* -( -? -P -< -name -> -exp -) -or -( -? -< -name -> -exp -) -- -A -named -capturing -group -. -/ -/ -/ -* -( -? -: -exp -) -- -A -non -- -capturing -group -. -/ -/ -/ -* -( -? -i -: -exp -) -- -A -non -- -capturing -group -that -sets -flags -. -/ -/ -/ -/ -/ -/ -Only -the -first -two -forms -are -said -to -be -_capturing_ -. -Capturing -/ -/ -/ -means -that -the -last -position -at -which -they -match -is -reportable -. -The -/ -/ -/ -[ -Captures -] -( -crate -: -: -util -: -: -captures -: -: -Captures -) -type -provides -convenient -/ -/ -/ -access -to -the -match -positions -of -capturing -groups -which -includes -looking -/ -/ -/ -up -capturing -groups -by -their -name -. -/ -/ -/ -/ -/ -/ -# -Byte -oriented -/ -/ -/ -/ -/ -/ -This -NFA -is -byte -oriented -which -means -that -all -of -its -transitions -are -/ -/ -/ -defined -on -bytes -. -In -other -words -the -alphabet -of -an -NFA -consists -of -the -/ -/ -/ -256 -different -byte -values -. -/ -/ -/ -/ -/ -/ -While -DFAs -nearly -demand -that -they -be -byte -oriented -for -performance -/ -/ -/ -reasons -an -NFA -could -conceivably -be -* -Unicode -codepoint -* -oriented -. -Indeed -/ -/ -/ -a -previous -version -of -this -NFA -supported -both -byte -and -codepoint -oriented -/ -/ -/ -modes -. -A -codepoint -oriented -mode -can -work -because -an -NFA -fundamentally -uses -/ -/ -/ -a -sparse -representation -of -transitions -which -works -well -with -the -large -/ -/ -/ -sparse -space -of -Unicode -codepoints -. -/ -/ -/ -/ -/ -/ -Nevertheless -this -NFA -is -only -byte -oriented -. -This -choice -is -primarily -/ -/ -/ -driven -by -implementation -simplicity -and -also -in -part -memory -usage -. -In -/ -/ -/ -practice -performance -between -the -two -is -roughly -comparable -. -However -/ -/ -/ -building -a -DFA -( -including -a -hybrid -DFA -) -really -wants -a -byte -oriented -NFA -. -/ -/ -/ -So -if -we -do -have -a -codepoint -oriented -NFA -then -we -also -need -to -generate -/ -/ -/ -byte -oriented -NFA -in -order -to -build -an -hybrid -NFA -/ -DFA -. -Thus -by -only -/ -/ -/ -generating -byte -oriented -NFAs -we -can -produce -one -less -NFA -. -In -other -words -/ -/ -/ -if -we -made -our -NFA -codepoint -oriented -we -' -d -need -to -* -also -* -make -it -support -/ -/ -/ -a -byte -oriented -mode -which -is -more -complicated -. -But -a -byte -oriented -mode -/ -/ -/ -can -support -everything -. -/ -/ -/ -/ -/ -/ -# -Differences -with -DFAs -/ -/ -/ -/ -/ -/ -At -the -theoretical -level -the -precise -difference -between -an -NFA -and -a -DFA -/ -/ -/ -is -that -in -a -DFA -for -every -state -an -input -symbol -unambiguously -refers -/ -/ -/ -to -a -single -transition -_and_ -that -an -input -symbol -is -required -for -each -/ -/ -/ -transition -. -At -a -practical -level -this -permits -DFA -implementations -to -be -/ -/ -/ -implemented -at -their -core -with -a -small -constant -number -of -CPU -instructions -/ -/ -/ -for -each -byte -of -input -searched -. -In -practice -this -makes -them -quite -a -bit -/ -/ -/ -faster -than -NFAs -_in -general_ -. -Namely -in -order -to -execute -a -search -for -any -/ -/ -/ -Thompson -NFA -one -needs -to -keep -track -of -a -_set_ -of -states -and -execute -/ -/ -/ -the -possible -transitions -on -all -of -those -states -for -each -input -symbol -. -/ -/ -/ -Overall -this -results -in -much -more -overhead -. -To -a -first -approximation -one -/ -/ -/ -can -expect -DFA -searches -to -be -about -an -order -of -magnitude -faster -. -/ -/ -/ -/ -/ -/ -So -why -use -an -NFA -at -all -? -The -main -advantage -of -an -NFA -is -that -it -takes -/ -/ -/ -linear -time -( -in -the -size -of -the -pattern -string -after -repetitions -have -been -/ -/ -/ -expanded -) -to -build -and -linear -memory -usage -. -A -DFA -on -the -other -hand -may -/ -/ -/ -take -exponential -time -and -/ -or -space -to -build -. -Even -in -non -- -pathological -/ -/ -/ -cases -DFAs -often -take -quite -a -bit -more -memory -than -their -NFA -counterparts -/ -/ -/ -_especially_ -if -large -Unicode -character -classes -are -involved -. -Of -course -/ -/ -/ -an -NFA -also -provides -additional -capabilities -. -For -example -it -can -match -/ -/ -/ -Unicode -word -boundaries -on -non -- -ASCII -text -and -resolve -the -positions -of -/ -/ -/ -capturing -groups -. -/ -/ -/ -/ -/ -/ -Note -that -a -[ -hybrid -: -: -regex -: -: -Regex -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -strikes -a -/ -/ -/ -good -balance -between -an -NFA -and -a -DFA -. -It -avoids -the -exponential -build -time -/ -/ -/ -of -a -DFA -while -maintaining -its -fast -search -time -. -The -downside -of -a -hybrid -/ -/ -/ -NFA -/ -DFA -is -that -in -some -cases -it -can -be -slower -at -search -time -than -the -NFA -. -/ -/ -/ -( -It -also -has -less -functionality -than -a -pure -NFA -. -It -cannot -handle -Unicode -/ -/ -/ -word -boundaries -on -non -- -ASCII -text -and -cannot -resolve -capturing -groups -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -build -an -NFA -with -the -default -configuration -and -execute -a -/ -/ -/ -search -using -the -Pike -VM -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -8 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -b -" -foo12345 -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -resolving -capturing -groups -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -parse -some -simple -dates -and -extract -the -/ -/ -/ -components -of -each -date -via -capturing -groups -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -captures -: -: -Captures -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -vm -= -PikeVM -: -: -new -( -r -" -( -? -P -< -y -> -\ -d -{ -4 -} -) -- -( -? -P -< -m -> -\ -d -{ -2 -} -) -- -( -? -P -< -d -> -\ -d -{ -2 -} -) -" -) -? -; -/ -/ -/ -let -mut -cache -= -vm -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -2012 -- -03 -- -14 -2013 -- -01 -- -01 -and -2014 -- -07 -- -05 -" -; -/ -/ -/ -let -all -: -Vec -< -Captures -> -= -vm -. -captures_iter -( -/ -/ -/ -& -mut -cache -haystack -. -as_bytes -( -) -/ -/ -/ -) -. -collect -( -) -; -/ -/ -/ -/ -/ -There -should -be -a -total -of -3 -matches -. -/ -/ -/ -assert_eq -! -( -3 -all -. -len -( -) -) -; -/ -/ -/ -/ -/ -The -year -from -the -second -match -is -' -2013 -' -. -/ -/ -/ -let -span -= -all -[ -1 -] -. -get_group_by_name -( -" -y -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -" -2013 -" -& -haystack -[ -span -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -that -only -the -last -match -of -a -capturing -group -is -/ -/ -/ -reported -even -if -it -had -to -match -multiple -times -for -an -overall -match -/ -/ -/ -to -occur -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -( -[ -a -- -z -] -) -{ -4 -} -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -quux -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -haystack -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -3 -. -. -4 -) -) -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -) -] -pub -struct -NFA -( -/ -/ -We -make -NFAs -reference -counted -primarily -for -two -reasons -. -First -is -that -/ -/ -the -NFA -type -itself -is -quite -large -( -at -least -0 -. -5KB -) -and -so -it -makes -/ -/ -sense -to -put -it -on -the -heap -by -default -anyway -. -Second -is -that -for -Arc -/ -/ -specifically -this -enables -cheap -clones -. -This -tends -to -be -useful -because -/ -/ -several -structures -( -the -backtracker -the -Pike -VM -the -hybrid -NFA -/ -DFA -) -/ -/ -all -want -to -hang -on -to -an -NFA -for -use -during -search -time -. -We -could -/ -/ -provide -the -NFA -at -search -time -via -a -function -argument -but -this -makes -/ -/ -for -an -unnecessarily -annoying -API -. -Instead -we -just -let -each -structure -/ -/ -share -ownership -of -the -NFA -. -Using -a -deep -clone -would -not -be -smart -since -/ -/ -the -NFA -can -use -quite -a -bit -of -heap -space -. -Arc -< -Inner -> -) -; -impl -NFA -{ -/ -/ -/ -Parse -the -given -regular -expression -using -a -default -configuration -and -/ -/ -/ -build -an -NFA -from -it -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -NFA -/ -/ -/ -[ -Compiler -] -with -a -[ -Config -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -8 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -b -" -foo12345 -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -NFA -BuildError -> -{ -NFA -: -: -compiler -( -) -. -build -( -pattern -) -} -/ -/ -/ -Parse -the -given -regular -expressions -using -a -default -configuration -and -/ -/ -/ -build -a -multi -- -NFA -from -them -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -NFA -/ -/ -/ -[ -Compiler -] -with -a -[ -Config -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -1 -0 -. -. -3 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -b -" -foo12345bar -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -NFA -BuildError -> -{ -NFA -: -: -compiler -( -) -. -build_many -( -patterns -) -} -/ -/ -/ -Returns -an -NFA -with -a -single -regex -pattern -that -always -matches -at -every -/ -/ -/ -position -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -NFA -: -: -always_match -( -) -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -0 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -b -" -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -b -" -foo -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -always_match -( -) -- -> -NFA -{ -/ -/ -We -could -use -NFA -: -: -new -( -" -" -) -here -and -we -' -d -get -the -same -semantics -but -/ -/ -hand -- -assembling -the -NFA -( -as -below -) -does -the -same -thing -with -a -fewer -/ -/ -number -of -states -. -It -also -avoids -needing -the -' -syntax -' -feature -/ -/ -enabled -. -/ -/ -/ -/ -Technically -all -we -need -is -the -" -match -" -state -but -we -add -the -/ -/ -" -capture -" -states -so -that -the -PikeVM -can -use -this -NFA -. -/ -/ -/ -/ -The -unwraps -below -are -OK -because -we -add -so -few -states -that -they -will -/ -/ -never -exhaust -any -default -limits -in -any -environment -. -let -mut -builder -= -Builder -: -: -new -( -) -; -let -pid -= -builder -. -start_pattern -( -) -. -unwrap -( -) -; -assert_eq -! -( -pid -. -as_usize -( -) -0 -) -; -let -start_id -= -builder -. -add_capture_start -( -StateID -: -: -ZERO -0 -None -) -. -unwrap -( -) -; -let -end_id -= -builder -. -add_capture_end -( -StateID -: -: -ZERO -0 -) -. -unwrap -( -) -; -let -match_id -= -builder -. -add_match -( -) -. -unwrap -( -) -; -builder -. -patch -( -start_id -end_id -) -. -unwrap -( -) -; -builder -. -patch -( -end_id -match_id -) -. -unwrap -( -) -; -let -pid -= -builder -. -finish_pattern -( -start_id -) -. -unwrap -( -) -; -assert_eq -! -( -pid -. -as_usize -( -) -0 -) -; -builder -. -build -( -start_id -start_id -) -. -unwrap -( -) -} -/ -/ -/ -Returns -an -NFA -that -never -matches -at -any -position -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -creating -an -NFA -with -zero -patterns -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -NFA -: -: -never_match -( -) -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -b -" -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -! -caps -. -is_match -( -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -b -" -foo -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -! -caps -. -is_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -never_match -( -) -- -> -NFA -{ -/ -/ -This -always -succeeds -because -it -only -requires -one -NFA -state -which -/ -/ -will -never -exhaust -any -( -default -) -limits -. -let -mut -builder -= -Builder -: -: -new -( -) -; -let -sid -= -builder -. -add_fail -( -) -. -unwrap -( -) -; -builder -. -build -( -sid -sid -) -. -unwrap -( -) -} -/ -/ -/ -Return -a -default -configuration -for -an -NFA -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -Config -/ -/ -/ -type -when -customizing -the -construction -of -an -NFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -an -NFA -with -a -small -size -limit -that -/ -/ -/ -results -in -a -compilation -error -for -any -regex -that -tries -to -use -more -/ -/ -/ -heap -memory -than -the -configured -limit -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -; -/ -/ -/ -/ -/ -/ -let -result -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -) -/ -/ -/ -/ -/ -Remember -\ -w -is -Unicode -- -aware -by -default -and -thus -huge -. -/ -/ -/ -. -build -( -r -" -\ -w -+ -" -) -; -/ -/ -/ -assert -! -( -result -. -is_err -( -) -) -; -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -config -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -/ -/ -/ -Return -a -compiler -for -configuring -the -construction -of -an -NFA -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Compiler -] -type -in -common -cases -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -an -NFA -that -is -permitted -match -invalid -/ -/ -/ -UTF -- -8 -. -Without -the -additional -syntax -configuration -here -compilation -of -/ -/ -/ -( -? -- -u -: -. -) -would -fail -because -it -is -permitted -to -match -invalid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -syntax -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -[ -a -- -z -] -+ -( -? -- -u -: -. -) -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -1 -. -. -5 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -b -" -\ -xFFabc -\ -xFF -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -compiler -( -) -- -> -Compiler -{ -Compiler -: -: -new -( -) -} -/ -/ -/ -Returns -an -iterator -over -all -pattern -identifiers -in -this -NFA -. -/ -/ -/ -/ -/ -/ -Pattern -IDs -are -allocated -in -sequential -order -starting -from -zero -/ -/ -/ -where -the -order -corresponds -to -the -order -of -patterns -provided -to -the -/ -/ -/ -[ -NFA -: -: -new_many -] -constructor -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -let -pids -: -Vec -< -PatternID -> -= -nfa -. -patterns -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -pids -vec -! -[ -/ -/ -/ -PatternID -: -: -must -( -0 -) -/ -/ -/ -PatternID -: -: -must -( -1 -) -/ -/ -/ -PatternID -: -: -must -( -2 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -patterns -( -& -self -) -- -> -PatternIter -< -' -_ -> -{ -PatternIter -{ -it -: -PatternID -: -: -iter -( -self -. -pattern_len -( -) -) -_marker -: -core -: -: -marker -: -: -PhantomData -} -} -/ -/ -/ -Returns -the -total -number -of -regex -patterns -in -this -NFA -. -/ -/ -/ -/ -/ -/ -This -may -return -zero -if -the -NFA -was -constructed -with -no -patterns -. -In -/ -/ -/ -this -case -the -NFA -can -never -produce -a -match -for -any -input -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -be -no -bigger -than -[ -PatternID -: -: -LIMIT -] -because -/ -/ -/ -NFA -construction -will -fail -if -too -many -patterns -are -added -. -/ -/ -/ -/ -/ -/ -It -is -always -true -that -nfa -. -patterns -( -) -. -count -( -) -= -= -nfa -. -pattern_len -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -3 -nfa -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -never_match -( -) -; -/ -/ -/ -assert_eq -! -( -0 -nfa -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -always_match -( -) -; -/ -/ -/ -assert_eq -! -( -1 -nfa -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -0 -. -start_pattern -. -len -( -) -} -/ -/ -/ -Return -the -state -identifier -of -the -initial -anchored -state -of -this -NFA -. -/ -/ -/ -/ -/ -/ -The -returned -identifier -is -guaranteed -to -be -a -valid -index -into -the -/ -/ -/ -slice -returned -by -[ -NFA -: -: -states -] -and -is -also -a -valid -argument -to -/ -/ -/ -[ -NFA -: -: -state -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -somewhat -contrived -example -where -we -can -easily -/ -/ -/ -predict -the -anchored -starting -state -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -NFA -State -WhichCaptures -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -" -a -" -) -? -; -/ -/ -/ -let -state -= -nfa -. -state -( -nfa -. -start_anchored -( -) -) -; -/ -/ -/ -match -* -state -{ -/ -/ -/ -State -: -: -ByteRange -{ -trans -} -= -> -{ -/ -/ -/ -assert_eq -! -( -b -' -a -' -trans -. -start -) -; -/ -/ -/ -assert_eq -! -( -b -' -a -' -trans -. -end -) -; -/ -/ -/ -} -/ -/ -/ -_ -= -> -unreachable -! -( -" -unexpected -state -" -) -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -start_anchored -( -& -self -) -- -> -StateID -{ -self -. -0 -. -start_anchored -} -/ -/ -/ -Return -the -state -identifier -of -the -initial -unanchored -state -of -this -/ -/ -/ -NFA -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -the -identifier -returned -by -/ -/ -/ -[ -NFA -: -: -start_anchored -] -when -the -NFA -has -no -unanchored -starting -state -. -/ -/ -/ -/ -/ -/ -The -returned -identifier -is -guaranteed -to -be -a -valid -index -into -the -/ -/ -/ -slice -returned -by -[ -NFA -: -: -states -] -and -is -also -a -valid -argument -to -/ -/ -/ -[ -NFA -: -: -state -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -anchored -and -unanchored -starting -states -/ -/ -/ -are -equivalent -when -an -anchored -NFA -is -built -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -^ -a -" -) -? -; -/ -/ -/ -assert_eq -! -( -nfa -. -start_anchored -( -) -nfa -. -start_unanchored -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -start_unanchored -( -& -self -) -- -> -StateID -{ -self -. -0 -. -start_unanchored -} -/ -/ -/ -Return -the -state -identifier -of -the -initial -anchored -state -for -the -given -/ -/ -/ -pattern -or -None -if -there -is -no -pattern -corresponding -to -the -given -/ -/ -/ -identifier -. -/ -/ -/ -/ -/ -/ -If -one -uses -the -starting -state -for -a -particular -pattern -then -the -only -/ -/ -/ -match -that -can -be -returned -is -for -the -corresponding -pattern -. -/ -/ -/ -/ -/ -/ -The -returned -identifier -is -guaranteed -to -be -a -valid -index -into -the -/ -/ -/ -slice -returned -by -[ -NFA -: -: -states -] -and -is -also -a -valid -argument -to -/ -/ -/ -[ -NFA -: -: -state -] -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -If -the -pattern -doesn -' -t -exist -in -this -NFA -then -this -returns -an -error -. -/ -/ -/ -This -occurs -when -pid -. -as_usize -( -) -> -= -nfa -. -pattern_len -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -anchored -and -unanchored -starting -states -/ -/ -/ -are -equivalent -when -an -anchored -NFA -is -built -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -^ -a -" -" -^ -b -" -] -) -? -; -/ -/ -/ -/ -/ -The -anchored -and -unanchored -states -for -the -entire -NFA -are -the -same -/ -/ -/ -/ -/ -since -all -of -the -patterns -are -anchored -. -/ -/ -/ -assert_eq -! -( -nfa -. -start_anchored -( -) -nfa -. -start_unanchored -( -) -) -; -/ -/ -/ -/ -/ -But -the -anchored -starting -states -for -each -pattern -are -distinct -/ -/ -/ -/ -/ -because -these -starting -states -can -only -lead -to -matches -for -the -/ -/ -/ -/ -/ -corresponding -pattern -. -/ -/ -/ -let -anchored -= -Some -( -nfa -. -start_anchored -( -) -) -; -/ -/ -/ -assert_ne -! -( -anchored -nfa -. -start_pattern -( -PatternID -: -: -must -( -0 -) -) -) -; -/ -/ -/ -assert_ne -! -( -anchored -nfa -. -start_pattern -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -/ -/ -Requesting -a -pattern -not -in -the -NFA -will -result -in -None -: -/ -/ -/ -assert_eq -! -( -None -nfa -. -start_pattern -( -PatternID -: -: -must -( -2 -) -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -start_pattern -( -& -self -pid -: -PatternID -) -- -> -Option -< -StateID -> -{ -self -. -0 -. -start_pattern -. -get -( -pid -. -as_usize -( -) -) -. -copied -( -) -} -/ -/ -/ -Get -the -byte -class -set -for -this -NFA -. -/ -/ -/ -/ -/ -/ -A -byte -class -set -is -a -partitioning -of -this -NFA -' -s -alphabet -into -/ -/ -/ -equivalence -classes -. -Any -two -bytes -in -the -same -equivalence -class -are -/ -/ -/ -guaranteed -to -never -discriminate -between -a -match -or -a -non -- -match -. -( -The -/ -/ -/ -partitioning -may -not -be -minimal -. -) -/ -/ -/ -/ -/ -/ -Byte -classes -are -used -internally -by -this -crate -when -building -DFAs -. -/ -/ -/ -Namely -among -other -optimizations -they -enable -a -space -optimization -/ -/ -/ -where -the -DFA -' -s -internal -alphabet -is -defined -over -the -equivalence -/ -/ -/ -classes -of -bytes -instead -of -all -possible -byte -values -. -The -former -is -/ -/ -/ -often -quite -a -bit -smaller -than -the -latter -which -permits -the -DFA -to -use -/ -/ -/ -less -space -for -its -transition -table -. -# -[ -inline -] -pub -( -crate -) -fn -byte_class_set -( -& -self -) -- -> -& -ByteClassSet -{ -& -self -. -0 -. -byte_class_set -} -/ -/ -/ -Get -the -byte -classes -for -this -NFA -. -/ -/ -/ -/ -/ -/ -Byte -classes -represent -a -partitioning -of -this -NFA -' -s -alphabet -into -/ -/ -/ -equivalence -classes -. -Any -two -bytes -in -the -same -equivalence -class -are -/ -/ -/ -guaranteed -to -never -discriminate -between -a -match -or -a -non -- -match -. -( -The -/ -/ -/ -partitioning -may -not -be -minimal -. -) -/ -/ -/ -/ -/ -/ -Byte -classes -are -used -internally -by -this -crate -when -building -DFAs -. -/ -/ -/ -Namely -among -other -optimizations -they -enable -a -space -optimization -/ -/ -/ -where -the -DFA -' -s -internal -alphabet -is -defined -over -the -equivalence -/ -/ -/ -classes -of -bytes -instead -of -all -possible -byte -values -. -The -former -is -/ -/ -/ -often -quite -a -bit -smaller -than -the -latter -which -permits -the -DFA -to -use -/ -/ -/ -less -space -for -its -transition -table -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -query -the -class -of -various -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -classes -= -nfa -. -byte_classes -( -) -; -/ -/ -/ -/ -/ -' -a -' -and -' -z -' -are -in -the -same -class -for -this -regex -. -/ -/ -/ -assert_eq -! -( -classes -. -get -( -b -' -a -' -) -classes -. -get -( -b -' -z -' -) -) -; -/ -/ -/ -/ -/ -But -' -a -' -and -' -A -' -are -not -. -/ -/ -/ -assert_ne -! -( -classes -. -get -( -b -' -a -' -) -classes -. -get -( -b -' -A -' -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -byte_classes -( -& -self -) -- -> -& -ByteClasses -{ -& -self -. -0 -. -byte_classes -} -/ -/ -/ -Return -a -reference -to -the -NFA -state -corresponding -to -the -given -ID -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -nfa -. -states -( -) -[ -id -] -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -the -given -identifier -does -not -reference -a -valid -state -. -/ -/ -/ -That -is -when -id -. -as_usize -( -) -> -= -nfa -. -states -( -) -. -len -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -The -anchored -state -for -a -pattern -will -typically -correspond -to -a -/ -/ -/ -capturing -state -for -that -pattern -. -( -Although -this -is -not -an -API -/ -/ -/ -guarantee -! -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -State -} -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -a -" -) -? -; -/ -/ -/ -let -state -= -nfa -. -state -( -nfa -. -start_pattern -( -PatternID -: -: -ZERO -) -. -unwrap -( -) -) -; -/ -/ -/ -match -* -state -{ -/ -/ -/ -State -: -: -Capture -{ -slot -. -. -} -= -> -{ -/ -/ -/ -assert_eq -! -( -0 -slot -. -as_usize -( -) -) -; -/ -/ -/ -} -/ -/ -/ -_ -= -> -unreachable -! -( -" -unexpected -state -" -) -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -state -( -& -self -id -: -StateID -) -- -> -& -State -{ -& -self -. -states -( -) -[ -id -] -} -/ -/ -/ -Returns -a -slice -of -all -states -in -this -NFA -. -/ -/ -/ -/ -/ -/ -The -slice -returned -is -indexed -by -StateID -. -This -provides -a -convenient -/ -/ -/ -way -to -access -states -while -following -transitions -among -those -states -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -demonstrates -that -disabling -UTF -- -8 -mode -can -shrink -the -size -of -the -/ -/ -/ -NFA -considerably -in -some -cases -especially -when -using -Unicode -character -/ -/ -/ -classes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -let -nfa_unicode -= -NFA -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -nfa_ascii -= -NFA -: -: -new -( -r -" -( -? -- -u -) -\ -w -" -) -? -; -/ -/ -/ -/ -/ -Yes -a -factor -of -45 -difference -. -No -lie -. -/ -/ -/ -assert -! -( -40 -* -nfa_ascii -. -states -( -) -. -len -( -) -< -nfa_unicode -. -states -( -) -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -states -( -& -self -) -- -> -& -[ -State -] -{ -& -self -. -0 -. -states -} -/ -/ -/ -Returns -the -capturing -group -info -for -this -NFA -. -/ -/ -/ -/ -/ -/ -The -[ -GroupInfo -] -provides -a -way -to -map -to -and -from -capture -index -/ -/ -/ -and -capture -name -for -each -pattern -. -It -also -provides -a -mapping -from -/ -/ -/ -each -of -the -capturing -groups -in -every -pattern -to -their -corresponding -/ -/ -/ -slot -offsets -encoded -in -[ -State -: -: -Capture -] -states -. -/ -/ -/ -/ -/ -/ -Note -that -GroupInfo -uses -reference -counting -internally -such -that -/ -/ -/ -cloning -a -GroupInfo -is -very -cheap -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -a -list -of -all -capture -group -names -for -/ -/ -/ -a -particular -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -r -" -( -a -) -( -? -P -< -foo -> -b -) -( -c -) -( -d -) -( -? -P -< -bar -> -e -) -" -) -? -; -/ -/ -/ -/ -/ -The -first -is -the -implicit -group -that -is -always -unnammed -. -The -next -/ -/ -/ -/ -/ -5 -groups -are -the -explicit -groups -found -in -the -concrete -syntax -above -. -/ -/ -/ -let -expected -= -vec -! -[ -None -None -Some -( -" -foo -" -) -None -None -Some -( -" -bar -" -) -] -; -/ -/ -/ -let -got -: -Vec -< -Option -< -& -str -> -> -= -/ -/ -/ -nfa -. -group_info -( -) -. -pattern_names -( -PatternID -: -: -ZERO -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -an -invalid -pattern -ID -will -result -in -nothing -yielded -. -/ -/ -/ -let -got -= -nfa -. -group_info -( -) -. -pattern_names -( -PatternID -: -: -must -( -999 -) -) -. -count -( -) -; -/ -/ -/ -assert_eq -! -( -0 -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -& -self -. -0 -. -group_info -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -NFA -has -at -least -one -/ -/ -/ -[ -Capture -] -( -State -: -: -Capture -) -in -its -sequence -of -states -. -/ -/ -/ -/ -/ -/ -This -is -useful -as -a -way -to -perform -a -quick -test -before -attempting -/ -/ -/ -something -that -does -or -does -not -require -capture -states -. -For -example -/ -/ -/ -some -regex -engines -( -like -the -PikeVM -) -require -capture -states -in -order -to -/ -/ -/ -work -at -all -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -few -different -NFAs -and -whether -they -have -captures -/ -/ -/ -or -not -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -NFA -WhichCaptures -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Obviously -has -capture -states -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -( -a -) -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_capture -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Less -obviously -has -capture -states -because -every -pattern -has -at -/ -/ -/ -/ -/ -least -one -anonymous -capture -group -corresponding -to -the -match -for -the -/ -/ -/ -/ -/ -entire -pattern -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -a -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_capture -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Other -than -hand -building -your -own -NFA -this -is -the -only -way -to -build -/ -/ -/ -/ -/ -an -NFA -without -capturing -groups -. -In -general -you -should -only -do -this -/ -/ -/ -/ -/ -if -you -don -' -t -intend -to -use -any -of -the -NFA -- -oriented -regex -engines -. -/ -/ -/ -/ -/ -Overall -capturing -groups -don -' -t -have -many -downsides -. -Although -they -/ -/ -/ -/ -/ -can -add -a -bit -of -noise -to -simple -NFAs -so -it -can -be -nice -to -disable -/ -/ -/ -/ -/ -them -for -debugging -purposes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -' -has_capture -' -is -false -here -even -when -we -have -an -/ -/ -/ -/ -/ -explicit -capture -group -in -the -pattern -. -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -" -( -a -) -" -) -? -; -/ -/ -/ -assert -! -( -! -nfa -. -has_capture -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -has_capture -( -& -self -) -- -> -bool -{ -self -. -0 -. -has_capture -} -/ -/ -/ -Returns -true -if -and -only -if -this -NFA -can -match -the -empty -string -. -/ -/ -/ -When -it -returns -false -all -possible -matches -are -guaranteed -to -have -a -/ -/ -/ -non -- -zero -length -. -/ -/ -/ -/ -/ -/ -This -is -useful -as -cheap -way -to -know -whether -code -needs -to -handle -the -/ -/ -/ -case -of -a -zero -length -match -. -This -is -particularly -important -when -UTF -- -8 -/ -/ -/ -modes -are -enabled -as -when -UTF -- -8 -mode -is -enabled -empty -matches -that -/ -/ -/ -split -a -codepoint -must -never -be -reported -. -This -extra -handling -can -/ -/ -/ -sometimes -be -costly -and -since -regexes -matching -an -empty -string -are -/ -/ -/ -somewhat -rare -it -can -be -beneficial -to -treat -such -regexes -specially -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -few -different -NFAs -and -whether -they -match -the -/ -/ -/ -empty -string -or -not -. -Notice -the -empty -string -isn -' -t -merely -a -matter -/ -/ -/ -of -a -string -of -length -literally -0 -but -rather -whether -a -match -can -/ -/ -/ -occur -between -specific -pairs -of -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -util -: -: -syntax -} -; -/ -/ -/ -/ -/ -/ -/ -/ -The -empty -regex -matches -the -empty -string -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_empty -( -) -" -empty -matches -empty -" -) -; -/ -/ -/ -/ -/ -The -' -+ -' -repetition -operator -requires -at -least -one -match -and -so -/ -/ -/ -/ -/ -does -not -match -the -empty -string -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -a -+ -" -) -? -; -/ -/ -/ -assert -! -( -! -nfa -. -has_empty -( -) -" -+ -does -not -match -empty -" -) -; -/ -/ -/ -/ -/ -But -the -' -* -' -repetition -operator -does -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -a -* -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_empty -( -) -" -* -does -match -empty -" -) -; -/ -/ -/ -/ -/ -And -wrapping -' -+ -' -in -an -operator -that -can -match -an -empty -string -also -/ -/ -/ -/ -/ -causes -it -to -match -the -empty -string -too -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -( -a -+ -) -* -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_empty -( -) -" -+ -inside -of -* -matches -empty -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -If -a -regex -is -just -made -of -a -look -- -around -assertion -even -if -the -/ -/ -/ -/ -/ -assertion -requires -some -kind -of -non -- -empty -string -around -it -( -such -as -/ -/ -/ -/ -/ -\ -b -) -then -it -is -still -treated -as -if -it -matches -the -empty -string -. -/ -/ -/ -/ -/ -Namely -if -a -match -occurs -of -just -a -look -- -around -assertion -then -the -/ -/ -/ -/ -/ -match -returned -is -empty -. -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -^ -\ -A -\ -z -\ -b -\ -B -( -? -- -u -: -\ -b -\ -B -) -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_empty -( -) -" -assertions -match -empty -" -) -; -/ -/ -/ -/ -/ -Even -when -an -assertion -is -wrapped -in -a -' -+ -' -it -still -matches -the -/ -/ -/ -/ -/ -empty -string -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -r -" -\ -b -+ -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_empty -( -) -" -+ -of -an -assertion -matches -empty -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -An -alternation -with -even -one -branch -that -can -match -the -empty -string -/ -/ -/ -/ -/ -is -also -said -to -match -the -empty -string -overall -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -foo -| -( -bar -) -? -| -quux -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_empty -( -) -" -alternations -can -match -empty -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -An -NFA -that -matches -nothing -does -not -match -the -empty -string -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -[ -a -& -& -b -] -" -) -? -; -/ -/ -/ -assert -! -( -! -nfa -. -has_empty -( -) -" -never -matching -means -not -matching -empty -" -) -; -/ -/ -/ -/ -/ -But -if -it -' -s -wrapped -in -something -that -doesn -' -t -require -a -match -at -/ -/ -/ -/ -/ -all -then -it -can -match -the -empty -string -! -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -[ -a -& -& -b -] -* -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -has_empty -( -) -" -* -on -never -- -match -still -matches -empty -" -) -; -/ -/ -/ -/ -/ -Since -a -' -+ -' -requires -a -match -using -it -on -something -that -can -never -/ -/ -/ -/ -/ -match -will -itself -produce -a -regex -that -can -never -match -anything -/ -/ -/ -/ -/ -and -thus -does -not -match -the -empty -string -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -[ -a -& -& -b -] -+ -" -) -? -; -/ -/ -/ -assert -! -( -! -nfa -. -has_empty -( -) -" -+ -on -never -- -match -still -matches -nothing -" -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -has_empty -( -& -self -) -- -> -bool -{ -self -. -0 -. -has_empty -} -/ -/ -/ -Whether -UTF -- -8 -mode -is -enabled -for -this -NFA -or -not -. -/ -/ -/ -/ -/ -/ -When -UTF -- -8 -mode -is -enabled -all -matches -reported -by -a -regex -engine -/ -/ -/ -derived -from -this -NFA -are -guaranteed -to -correspond -to -spans -of -valid -/ -/ -/ -UTF -- -8 -. -This -includes -zero -- -width -matches -. -For -example -the -regex -engine -/ -/ -/ -must -guarantee -that -the -empty -regex -will -not -match -at -the -positions -/ -/ -/ -between -code -units -in -the -UTF -- -8 -encoding -of -a -single -codepoint -. -/ -/ -/ -/ -/ -/ -See -[ -Config -: -: -utf8 -] -for -more -information -. -/ -/ -/ -/ -/ -/ -This -is -enabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -UTF -- -8 -mode -can -impact -the -match -spans -that -may -/ -/ -/ -be -reported -in -certain -cases -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -PikeVM -} -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -UTF -- -8 -mode -is -enabled -by -default -. -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -0 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -an -empty -regex -matches -at -1 -. -. -1 -our -next -match -is -/ -/ -/ -/ -/ -3 -. -. -3 -because -1 -. -. -1 -and -2 -. -. -2 -split -the -snowman -codepoint -( -which -is -/ -/ -/ -/ -/ -three -bytes -long -) -. -/ -/ -/ -input -. -set_start -( -1 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -3 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -disable -UTF -- -8 -then -we -' -ll -get -matches -at -1 -. -. -1 -and -2 -. -. -2 -: -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -" -" -) -? -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -1 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -2 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -2 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -3 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -3 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -input -. -set_start -( -4 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_utf8 -( -& -self -) -- -> -bool -{ -self -. -0 -. -utf8 -} -/ -/ -/ -Returns -true -when -this -NFA -is -meant -to -be -matched -in -reverse -. -/ -/ -/ -/ -/ -/ -Generally -speaking -when -this -is -true -it -means -the -NFA -is -supposed -to -/ -/ -/ -be -used -in -conjunction -with -moving -backwards -through -the -haystack -. -That -/ -/ -/ -is -from -a -higher -memory -address -to -a -lower -memory -address -. -/ -/ -/ -/ -/ -/ -It -is -often -the -case -that -lower -level -routines -dealing -with -an -NFA -/ -/ -/ -don -' -t -need -to -care -about -whether -it -is -" -meant -" -to -be -matched -in -reverse -/ -/ -/ -or -not -. -However -there -are -some -specific -cases -where -it -matters -. -For -/ -/ -/ -example -the -implementation -of -CRLF -- -aware -^ -and -line -anchors -/ -/ -/ -needs -to -know -whether -the -search -is -in -the -forward -or -reverse -/ -/ -/ -direction -. -In -the -forward -direction -neither -^ -nor -should -match -/ -/ -/ -when -a -\ -r -has -been -seen -previously -and -a -\ -n -is -next -. -However -in -/ -/ -/ -the -reverse -direction -neither -^ -nor -should -match -when -a -\ -n -/ -/ -/ -has -been -seen -previously -and -a -\ -r -is -next -. -This -fundamentally -changes -/ -/ -/ -how -the -state -machine -is -constructed -and -thus -needs -to -be -altered -/ -/ -/ -based -on -the -direction -of -the -search -. -/ -/ -/ -/ -/ -/ -This -is -automatically -set -when -using -a -[ -Compiler -] -with -a -configuration -/ -/ -/ -where -[ -Config -: -: -reverse -] -is -enabled -. -If -you -' -re -building -your -own -NFA -/ -/ -/ -by -hand -via -a -[ -Builder -] -# -[ -inline -] -pub -fn -is_reverse -( -& -self -) -- -> -bool -{ -self -. -0 -. -reverse -} -/ -/ -/ -Returns -true -if -and -only -if -all -starting -states -for -this -NFA -correspond -/ -/ -/ -to -the -beginning -of -an -anchored -search -. -/ -/ -/ -/ -/ -/ -Typically -an -NFA -will -have -both -an -anchored -and -an -unanchored -starting -/ -/ -/ -state -. -Namely -because -it -tends -to -be -useful -to -have -both -and -the -cost -/ -/ -/ -of -having -an -unanchored -starting -state -is -almost -zero -( -for -an -NFA -) -. -/ -/ -/ -However -if -all -patterns -in -the -NFA -are -themselves -anchored -then -even -/ -/ -/ -the -unanchored -starting -state -will -correspond -to -an -anchored -search -/ -/ -/ -since -the -pattern -doesn -' -t -permit -anything -else -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -few -different -scenarios -where -this -method -' -s -/ -/ -/ -return -value -varies -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -/ -/ -The -unanchored -starting -state -permits -matching -this -pattern -anywhere -/ -/ -/ -/ -/ -in -a -haystack -instead -of -just -at -the -beginning -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -a -" -) -? -; -/ -/ -/ -assert -! -( -! -nfa -. -is_always_start_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -In -this -case -the -pattern -is -itself -anchored -so -there -is -no -way -/ -/ -/ -/ -/ -to -run -an -unanchored -search -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -^ -a -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -is_always_start_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -When -multiline -mode -is -enabled -' -^ -' -can -match -at -the -start -of -a -line -/ -/ -/ -/ -/ -in -addition -to -the -start -of -a -haystack -so -an -unanchored -search -is -/ -/ -/ -/ -/ -actually -possible -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -( -? -m -) -^ -a -" -) -? -; -/ -/ -/ -assert -! -( -! -nfa -. -is_always_start_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Weird -cases -also -work -. -A -pattern -is -only -considered -anchored -if -all -/ -/ -/ -/ -/ -matches -may -only -occur -at -the -start -of -a -haystack -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -( -^ -a -) -| -a -" -) -? -; -/ -/ -/ -assert -! -( -! -nfa -. -is_always_start_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -When -multiple -patterns -are -present -if -they -are -all -anchored -then -/ -/ -/ -/ -/ -the -NFA -is -always -anchored -too -. -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -^ -a -" -" -^ -b -" -" -^ -c -" -] -) -? -; -/ -/ -/ -assert -! -( -nfa -. -is_always_start_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -one -pattern -is -unanchored -then -the -NFA -must -permit -an -/ -/ -/ -/ -/ -unanchored -search -. -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -^ -a -" -" -b -" -" -^ -c -" -] -) -? -; -/ -/ -/ -assert -! -( -! -nfa -. -is_always_start_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_always_start_anchored -( -& -self -) -- -> -bool -{ -self -. -start_anchored -( -) -= -= -self -. -start_unanchored -( -) -} -/ -/ -/ -Returns -the -look -- -around -matcher -associated -with -this -NFA -. -/ -/ -/ -/ -/ -/ -A -look -- -around -matcher -determines -how -to -match -look -- -around -assertions -. -/ -/ -/ -In -particular -some -assertions -are -configurable -. -For -example -the -/ -/ -/ -( -? -m -: -^ -) -and -( -? -m -: -) -assertions -can -have -their -line -terminator -changed -/ -/ -/ -from -the -default -of -\ -n -to -any -other -byte -. -/ -/ -/ -/ -/ -/ -If -the -NFA -was -built -using -a -[ -Compiler -] -then -this -matcher -/ -/ -/ -can -be -set -via -the -[ -Config -: -: -look_matcher -] -configuration -/ -/ -/ -knob -. -Otherwise -if -you -' -ve -built -an -NFA -by -hand -it -is -set -via -/ -/ -/ -[ -Builder -: -: -set_look_matcher -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -change -the -line -terminator -for -multi -- -line -assertions -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -PikeVM -} -/ -/ -/ -util -: -: -look -: -: -LookMatcher -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -mut -lookm -= -LookMatcher -: -: -new -( -) -; -/ -/ -/ -lookm -. -set_line_terminator -( -b -' -\ -x00 -' -) -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -look_matcher -( -lookm -) -) -/ -/ -/ -. -build -( -r -" -( -? -m -) -^ -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Multi -- -line -assertions -now -use -NUL -as -a -terminator -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -1 -. -. -4 -) -) -/ -/ -/ -re -. -find -( -& -mut -cache -b -" -\ -x00abc -\ -x00 -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -. -. -. -and -\ -n -is -no -longer -recognized -as -a -terminator -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -None -/ -/ -/ -re -. -find -( -& -mut -cache -b -" -\ -nabc -\ -n -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -look_matcher -( -& -self -) -- -> -& -LookMatcher -{ -& -self -. -0 -. -look_matcher -} -/ -/ -/ -Returns -the -union -of -all -look -- -around -assertions -used -throughout -this -/ -/ -/ -NFA -. -When -the -returned -set -is -empty -it -implies -that -the -NFA -has -no -/ -/ -/ -look -- -around -assertions -and -thus -zero -conditional -epsilon -transitions -. -/ -/ -/ -/ -/ -/ -This -is -useful -in -some -cases -enabling -optimizations -. -It -is -not -/ -/ -/ -unusual -for -example -for -optimizations -to -be -of -the -form -" -for -any -/ -/ -/ -regex -with -zero -conditional -epsilon -transitions -do -. -. -. -" -where -" -. -. -. -" -/ -/ -/ -is -some -kind -of -optimization -. -/ -/ -/ -/ -/ -/ -This -isn -' -t -only -helpful -for -optimizations -either -. -Sometimes -look -- -around -/ -/ -/ -assertions -are -difficult -to -support -. -For -example -many -of -the -DFAs -in -/ -/ -/ -this -crate -don -' -t -support -Unicode -word -boundaries -or -handle -them -using -/ -/ -/ -heuristics -. -Handling -that -correctly -typically -requires -some -kind -of -/ -/ -/ -cheap -check -of -whether -the -NFA -has -a -Unicode -word -boundary -in -the -first -/ -/ -/ -place -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -this -routine -varies -based -on -the -regex -pattern -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -util -: -: -look -: -: -Look -} -; -/ -/ -/ -/ -/ -/ -/ -/ -No -look -- -around -at -all -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -a -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -look_set_any -( -) -. -is_empty -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -When -multiple -patterns -are -present -since -this -returns -the -union -/ -/ -/ -/ -/ -it -will -include -look -- -around -assertions -that -only -appear -in -one -/ -/ -/ -/ -/ -pattern -. -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -a -" -" -b -" -" -a -^ -b -" -" -c -" -] -) -? -; -/ -/ -/ -assert -! -( -nfa -. -look_set_any -( -) -. -contains -( -Look -: -: -Start -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Some -groups -of -assertions -have -various -shortcuts -. -For -example -: -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -r -" -( -? -- -u -: -\ -b -) -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -look_set_any -( -) -. -contains_word -( -) -) -; -/ -/ -/ -assert -! -( -! -nfa -. -look_set_any -( -) -. -contains_word_unicode -( -) -) -; -/ -/ -/ -assert -! -( -nfa -. -look_set_any -( -) -. -contains_word_ascii -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -look_set_any -( -& -self -) -- -> -LookSet -{ -self -. -0 -. -look_set_any -} -/ -/ -/ -Returns -the -union -of -all -prefix -look -- -around -assertions -for -every -/ -/ -/ -pattern -in -this -NFA -. -When -the -returned -set -is -empty -it -implies -none -of -/ -/ -/ -the -patterns -require -moving -through -a -conditional -epsilon -transition -/ -/ -/ -before -inspecting -the -first -byte -in -the -haystack -. -/ -/ -/ -/ -/ -/ -This -can -be -useful -for -determining -what -kinds -of -assertions -need -to -be -/ -/ -/ -satisfied -at -the -beginning -of -a -search -. -For -example -typically -DFAs -/ -/ -/ -in -this -crate -will -build -a -distinct -starting -state -for -each -possible -/ -/ -/ -starting -configuration -that -might -result -in -look -- -around -assertions -/ -/ -/ -being -satisfied -differently -. -However -if -the -set -returned -here -is -/ -/ -/ -empty -then -you -know -that -the -start -state -is -invariant -because -there -/ -/ -/ -are -no -conditional -epsilon -transitions -to -consider -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -this -routine -varies -based -on -the -regex -pattern -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -util -: -: -look -: -: -Look -} -; -/ -/ -/ -/ -/ -/ -/ -/ -No -look -- -around -at -all -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -a -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -look_set_prefix_any -( -) -. -is_empty -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -When -multiple -patterns -are -present -since -this -returns -the -union -/ -/ -/ -/ -/ -it -will -include -look -- -around -assertions -that -only -appear -in -one -/ -/ -/ -/ -/ -pattern -. -But -it -will -only -include -assertions -that -are -in -the -prefix -/ -/ -/ -/ -/ -of -a -pattern -. -For -example -this -includes -' -^ -' -but -not -' -' -even -though -/ -/ -/ -/ -/ -' -' -does -appear -. -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -a -" -" -b -" -" -^ -ab -" -" -c -" -] -) -? -; -/ -/ -/ -assert -! -( -nfa -. -look_set_prefix_any -( -) -. -contains -( -Look -: -: -Start -) -) -; -/ -/ -/ -assert -! -( -! -nfa -. -look_set_prefix_any -( -) -. -contains -( -Look -: -: -End -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -look_set_prefix_any -( -& -self -) -- -> -LookSet -{ -self -. -0 -. -look_set_prefix_any -} -/ -/ -FIXME -: -The -look_set_prefix_all -computation -was -not -correct -and -it -/ -/ -seemed -a -little -tricky -to -fix -it -. -Since -I -wasn -' -t -actually -using -it -for -/ -/ -anything -I -just -decided -to -remove -it -in -the -run -up -to -the -regex -1 -. -9 -/ -/ -release -. -If -you -need -this -please -file -an -issue -. -/ -* -/ -/ -/ -Returns -the -intersection -of -all -prefix -look -- -around -assertions -for -every -/ -/ -/ -pattern -in -this -NFA -. -When -the -returned -set -is -empty -it -implies -at -/ -/ -/ -least -one -of -the -patterns -does -not -require -moving -through -a -conditional -/ -/ -/ -epsilon -transition -before -inspecting -the -first -byte -in -the -haystack -. -/ -/ -/ -Conversely -when -the -set -contains -an -assertion -it -implies -that -every -/ -/ -/ -pattern -in -the -NFA -also -contains -that -assertion -in -its -prefix -. -/ -/ -/ -/ -/ -/ -This -can -be -useful -for -determining -what -kinds -of -assertions -need -to -be -/ -/ -/ -satisfied -at -the -beginning -of -a -search -. -For -example -if -you -know -that -/ -/ -/ -[ -Look -: -: -Start -] -is -in -the -prefix -intersection -set -returned -here -then -/ -/ -/ -you -know -that -all -searches -regardless -of -input -configuration -will -be -/ -/ -/ -anchored -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -this -routine -varies -based -on -the -regex -pattern -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -util -: -: -look -: -: -Look -} -; -/ -/ -/ -/ -/ -/ -/ -/ -No -look -- -around -at -all -. -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -a -" -) -? -; -/ -/ -/ -assert -! -( -nfa -. -look_set_prefix_all -( -) -. -is_empty -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -When -multiple -patterns -are -present -since -this -returns -the -/ -/ -/ -/ -/ -intersection -it -will -only -include -assertions -present -in -every -/ -/ -/ -/ -/ -prefix -and -only -the -prefix -. -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -^ -a -" -" -^ -b -" -" -^ -ab -" -" -^ -c -" -] -) -? -; -/ -/ -/ -assert -! -( -nfa -. -look_set_prefix_all -( -) -. -contains -( -Look -: -: -Start -) -) -; -/ -/ -/ -assert -! -( -! -nfa -. -look_set_prefix_all -( -) -. -contains -( -Look -: -: -End -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -look_set_prefix_all -( -& -self -) -- -> -LookSet -{ -self -. -0 -. -look_set_prefix_all -} -* -/ -/ -/ -/ -Returns -the -memory -usage -in -bytes -of -this -NFA -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -NFA -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -NFA -> -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -large -Unicode -character -classes -can -use -quite -/ -/ -/ -a -bit -of -memory -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -let -nfa_unicode -= -NFA -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -nfa_ascii -= -NFA -: -: -new -( -r -" -( -? -- -u -: -\ -w -) -" -) -? -; -/ -/ -/ -/ -/ -/ -assert -! -( -10 -* -nfa_ascii -. -memory_usage -( -) -< -nfa_unicode -. -memory_usage -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -use -core -: -: -mem -: -: -size_of -; -size_of -: -: -< -Inner -> -( -) -/ -/ -allocated -on -the -heap -via -Arc -+ -self -. -0 -. -states -. -len -( -) -* -size_of -: -: -< -State -> -( -) -+ -self -. -0 -. -start_pattern -. -len -( -) -* -size_of -: -: -< -StateID -> -( -) -+ -self -. -0 -. -group_info -. -memory_usage -( -) -+ -self -. -0 -. -memory_extra -} -} -impl -fmt -: -: -Debug -for -NFA -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -self -. -0 -. -fmt -( -f -) -} -} -/ -/ -/ -The -" -inner -" -part -of -the -NFA -. -We -split -this -part -out -so -that -we -can -easily -/ -/ -/ -wrap -it -in -an -Arc -above -in -the -definition -of -NFA -. -/ -/ -/ -/ -/ -/ -See -builder -. -rs -for -the -code -that -actually -builds -this -type -. -This -module -/ -/ -/ -does -provide -( -internal -) -mutable -methods -for -adding -things -to -this -/ -/ -/ -NFA -before -finalizing -it -but -the -high -level -construction -process -is -/ -/ -/ -controlled -by -the -builder -abstraction -. -( -Which -is -complicated -enough -to -/ -/ -/ -get -its -own -module -. -) -# -[ -derive -( -Default -) -] -pub -( -super -) -struct -Inner -{ -/ -/ -/ -The -state -sequence -. -This -sequence -is -guaranteed -to -be -indexable -by -all -/ -/ -/ -starting -state -IDs -and -it -is -also -guaranteed -to -contain -at -most -one -/ -/ -/ -Match -state -for -each -pattern -compiled -into -this -NFA -. -( -A -pattern -may -/ -/ -/ -not -have -a -corresponding -Match -state -if -a -Match -state -is -impossible -/ -/ -/ -to -reach -. -) -states -: -Vec -< -State -> -/ -/ -/ -The -anchored -starting -state -of -this -NFA -. -start_anchored -: -StateID -/ -/ -/ -The -unanchored -starting -state -of -this -NFA -. -start_unanchored -: -StateID -/ -/ -/ -The -starting -states -for -each -individual -pattern -. -Starting -at -any -/ -/ -/ -of -these -states -will -result -in -only -an -anchored -search -for -the -/ -/ -/ -corresponding -pattern -. -The -vec -is -indexed -by -pattern -ID -. -When -the -NFA -/ -/ -/ -contains -a -single -regex -then -start_pattern -[ -0 -] -and -start_anchored -/ -/ -/ -are -always -equivalent -. -start_pattern -: -Vec -< -StateID -> -/ -/ -/ -Info -about -the -capturing -groups -in -this -NFA -. -This -is -responsible -for -/ -/ -/ -mapping -groups -to -slots -mapping -groups -to -names -and -names -to -groups -. -group_info -: -GroupInfo -/ -/ -/ -A -representation -of -equivalence -classes -over -the -transitions -in -this -/ -/ -/ -NFA -. -Two -bytes -in -the -same -equivalence -class -must -not -discriminate -/ -/ -/ -between -a -match -or -a -non -- -match -. -This -map -can -be -used -to -shrink -the -/ -/ -/ -total -size -of -a -DFA -' -s -transition -table -with -a -small -match -- -time -cost -. -/ -/ -/ -/ -/ -/ -Note -that -the -NFA -' -s -transitions -are -* -not -* -defined -in -terms -of -these -/ -/ -/ -equivalence -classes -. -The -NFA -' -s -transitions -are -defined -on -the -original -/ -/ -/ -byte -values -. -For -the -most -part -this -is -because -they -wouldn -' -t -really -/ -/ -/ -help -the -NFA -much -since -the -NFA -already -uses -a -sparse -representation -/ -/ -/ -to -represent -transitions -. -Byte -classes -are -most -effective -in -a -dense -/ -/ -/ -representation -. -byte_class_set -: -ByteClassSet -/ -/ -/ -This -is -generated -from -byte_class_set -and -essentially -represents -the -/ -/ -/ -same -thing -but -supports -different -access -patterns -. -Namely -this -permits -/ -/ -/ -looking -up -the -equivalence -class -of -a -byte -very -cheaply -. -/ -/ -/ -/ -/ -/ -Ideally -we -would -just -store -this -but -because -of -annoying -code -/ -/ -/ -structure -reasons -we -keep -both -this -and -byte_class_set -around -for -/ -/ -/ -now -. -I -think -I -would -prefer -that -byte_class_set -were -computed -in -the -/ -/ -/ -Builder -but -right -now -we -compute -it -as -states -are -added -to -the -/ -/ -/ -NFA -. -byte_classes -: -ByteClasses -/ -/ -/ -Whether -this -NFA -has -a -Capture -state -anywhere -. -has_capture -: -bool -/ -/ -/ -When -the -empty -string -is -in -the -language -matched -by -this -NFA -. -has_empty -: -bool -/ -/ -/ -Whether -UTF -- -8 -mode -is -enabled -for -this -NFA -. -Briefly -this -means -that -/ -/ -/ -all -non -- -empty -matches -produced -by -this -NFA -correspond -to -spans -of -valid -/ -/ -/ -UTF -- -8 -and -any -empty -matches -produced -by -this -NFA -that -split -a -UTF -- -8 -/ -/ -/ -encoded -codepoint -should -be -filtered -out -by -the -corresponding -regex -/ -/ -/ -engine -. -utf8 -: -bool -/ -/ -/ -Whether -this -NFA -is -meant -to -be -matched -in -reverse -or -not -. -reverse -: -bool -/ -/ -/ -The -matcher -to -be -used -for -look -- -around -assertions -. -look_matcher -: -LookMatcher -/ -/ -/ -The -union -of -all -look -- -around -assertions -that -occur -anywhere -within -/ -/ -/ -this -NFA -. -If -this -set -is -empty -then -it -means -there -are -precisely -zero -/ -/ -/ -conditional -epsilon -transitions -in -the -NFA -. -look_set_any -: -LookSet -/ -/ -/ -The -union -of -all -look -- -around -assertions -that -occur -as -a -zero -- -length -/ -/ -/ -prefix -for -any -of -the -patterns -in -this -NFA -. -look_set_prefix_any -: -LookSet -/ -* -/ -/ -/ -The -intersection -of -all -look -- -around -assertions -that -occur -as -a -/ -/ -/ -zero -- -length -prefix -for -any -of -the -patterns -in -this -NFA -. -look_set_prefix_all -: -LookSet -* -/ -/ -/ -/ -Heap -memory -used -indirectly -by -NFA -states -and -other -things -( -like -the -/ -/ -/ -various -capturing -group -representations -above -) -. -Since -each -state -/ -/ -/ -might -use -a -different -amount -of -heap -we -need -to -keep -track -of -this -/ -/ -/ -incrementally -. -memory_extra -: -usize -} -impl -Inner -{ -/ -/ -/ -Runs -any -last -finalization -bits -and -turns -this -into -a -full -NFA -. -pub -( -super -) -fn -into_nfa -( -mut -self -) -- -> -NFA -{ -self -. -byte_classes -= -self -. -byte_class_set -. -byte_classes -( -) -; -/ -/ -Do -epsilon -closure -from -the -start -state -of -every -pattern -in -order -/ -/ -to -compute -various -properties -such -as -look -- -around -assertions -and -/ -/ -whether -the -empty -string -can -be -matched -. -let -mut -stack -= -vec -! -[ -] -; -let -mut -seen -= -SparseSet -: -: -new -( -self -. -states -. -len -( -) -) -; -for -& -start_id -in -self -. -start_pattern -. -iter -( -) -{ -stack -. -push -( -start_id -) -; -seen -. -clear -( -) -; -/ -/ -let -mut -prefix_all -= -LookSet -: -: -full -( -) -; -let -mut -prefix_any -= -LookSet -: -: -empty -( -) -; -while -let -Some -( -sid -) -= -stack -. -pop -( -) -{ -if -! -seen -. -insert -( -sid -) -{ -continue -; -} -match -self -. -states -[ -sid -] -{ -State -: -: -ByteRange -{ -. -. -} -| -State -: -: -Dense -{ -. -. -} -| -State -: -: -Fail -= -> -continue -State -: -: -Sparse -( -_ -) -= -> -{ -/ -/ -This -snippet -below -will -rewrite -this -sparse -state -/ -/ -as -a -dense -state -. -By -doing -it -here -we -apply -this -/ -/ -optimization -to -all -hot -" -sparse -" -states -since -these -/ -/ -are -the -states -that -are -reachable -from -the -start -/ -/ -state -via -an -epsilon -closure -. -/ -/ -/ -/ -Unfortunately -this -optimization -did -not -seem -to -/ -/ -help -much -in -some -very -limited -ad -hoc -benchmarking -. -/ -/ -/ -/ -I -left -the -' -Dense -' -state -type -in -place -in -case -we -/ -/ -want -to -revisit -this -but -I -suspect -the -real -way -/ -/ -to -make -forward -progress -is -a -more -fundamental -/ -/ -rearchitecting -of -how -data -in -the -NFA -is -laid -out -. -/ -/ -I -think -we -should -consider -a -single -contiguous -/ -/ -allocation -instead -of -all -this -indirection -and -/ -/ -potential -heap -allocations -for -every -state -. -But -this -/ -/ -is -a -large -re -- -design -and -will -require -API -breaking -/ -/ -changes -. -/ -/ -self -. -memory_extra -- -= -self -. -states -[ -sid -] -. -memory_usage -( -) -; -/ -/ -let -trans -= -DenseTransitions -: -: -from_sparse -( -sparse -) -; -/ -/ -self -. -states -[ -sid -] -= -State -: -: -Dense -( -trans -) -; -/ -/ -self -. -memory_extra -+ -= -self -. -states -[ -sid -] -. -memory_usage -( -) -; -continue -; -} -State -: -: -Match -{ -. -. -} -= -> -self -. -has_empty -= -true -State -: -: -Look -{ -look -next -} -= -> -{ -prefix_any -= -prefix_any -. -insert -( -look -) -; -stack -. -push -( -next -) -; -} -State -: -: -Union -{ -ref -alternates -} -= -> -{ -/ -/ -Order -doesn -' -t -matter -here -since -we -' -re -just -dealing -/ -/ -with -look -- -around -sets -. -But -if -we -do -richer -analysis -/ -/ -here -that -needs -to -care -about -preference -order -then -/ -/ -this -should -be -done -in -reverse -. -stack -. -extend -( -alternates -. -iter -( -) -) -; -} -State -: -: -BinaryUnion -{ -alt1 -alt2 -} -= -> -{ -stack -. -push -( -alt2 -) -; -stack -. -push -( -alt1 -) -; -} -State -: -: -Capture -{ -next -. -. -} -= -> -{ -stack -. -push -( -next -) -; -} -} -} -self -. -look_set_prefix_any -= -self -. -look_set_prefix_any -. -union -( -prefix_any -) -; -} -NFA -( -Arc -: -: -new -( -self -) -) -} -/ -/ -/ -Returns -the -capturing -group -info -for -this -NFA -. -pub -( -super -) -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -& -self -. -group_info -} -/ -/ -/ -Add -the -given -state -to -this -NFA -after -allocating -a -fresh -identifier -for -/ -/ -/ -it -. -/ -/ -/ -/ -/ -/ -This -panics -if -too -many -states -are -added -such -that -a -fresh -identifier -/ -/ -/ -could -not -be -created -. -( -Currently -the -only -caller -of -this -routine -is -/ -/ -/ -a -Builder -and -it -upholds -this -invariant -. -) -pub -( -super -) -fn -add -( -& -mut -self -state -: -State -) -- -> -StateID -{ -match -state -{ -State -: -: -ByteRange -{ -ref -trans -} -= -> -{ -self -. -byte_class_set -. -set_range -( -trans -. -start -trans -. -end -) -; -} -State -: -: -Sparse -( -ref -sparse -) -= -> -{ -for -trans -in -sparse -. -transitions -. -iter -( -) -{ -self -. -byte_class_set -. -set_range -( -trans -. -start -trans -. -end -) -; -} -} -State -: -: -Dense -{ -. -. -} -= -> -unreachable -! -( -) -State -: -: -Look -{ -look -. -. -} -= -> -{ -self -. -look_matcher -. -add_to_byteset -( -look -& -mut -self -. -byte_class_set -) -; -self -. -look_set_any -= -self -. -look_set_any -. -insert -( -look -) -; -} -State -: -: -Capture -{ -. -. -} -= -> -{ -self -. -has_capture -= -true -; -} -State -: -: -Union -{ -. -. -} -| -State -: -: -BinaryUnion -{ -. -. -} -| -State -: -: -Fail -| -State -: -: -Match -{ -. -. -} -= -> -{ -} -} -let -id -= -StateID -: -: -new -( -self -. -states -. -len -( -) -) -. -unwrap -( -) -; -self -. -memory_extra -+ -= -state -. -memory_usage -( -) -; -self -. -states -. -push -( -state -) -; -id -} -/ -/ -/ -Set -the -starting -state -identifiers -for -this -NFA -. -/ -/ -/ -/ -/ -/ -start_anchored -and -start_unanchored -may -be -equivalent -. -When -they -/ -/ -/ -are -then -the -NFA -can -only -execute -anchored -searches -. -This -might -/ -/ -/ -occur -for -example -for -patterns -that -are -unconditionally -anchored -. -/ -/ -/ -e -. -g -. -^ -foo -. -pub -( -super -) -fn -set_starts -( -& -mut -self -start_anchored -: -StateID -start_unanchored -: -StateID -start_pattern -: -& -[ -StateID -] -) -{ -self -. -start_anchored -= -start_anchored -; -self -. -start_unanchored -= -start_unanchored -; -self -. -start_pattern -= -start_pattern -. -to_vec -( -) -; -} -/ -/ -/ -Sets -the -UTF -- -8 -mode -of -this -NFA -. -pub -( -super -) -fn -set_utf8 -( -& -mut -self -yes -: -bool -) -{ -self -. -utf8 -= -yes -; -} -/ -/ -/ -Sets -the -reverse -mode -of -this -NFA -. -pub -( -super -) -fn -set_reverse -( -& -mut -self -yes -: -bool -) -{ -self -. -reverse -= -yes -; -} -/ -/ -/ -Sets -the -look -- -around -assertion -matcher -for -this -NFA -. -pub -( -super -) -fn -set_look_matcher -( -& -mut -self -m -: -LookMatcher -) -{ -self -. -look_matcher -= -m -; -} -/ -/ -/ -Set -the -capturing -groups -for -this -NFA -. -/ -/ -/ -/ -/ -/ -The -given -slice -should -contain -the -capturing -groups -for -each -pattern -/ -/ -/ -The -capturing -groups -in -turn -should -correspond -to -the -total -number -of -/ -/ -/ -capturing -groups -in -the -pattern -including -the -anonymous -first -capture -/ -/ -/ -group -for -each -pattern -. -If -a -capturing -group -does -have -a -name -then -it -/ -/ -/ -should -be -provided -as -a -Arc -< -str -> -. -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -a -corresponding -GroupInfo -could -not -be -/ -/ -/ -built -. -pub -( -super -) -fn -set_captures -( -& -mut -self -captures -: -& -[ -Vec -< -Option -< -Arc -< -str -> -> -> -] -) -- -> -Result -< -( -) -GroupInfoError -> -{ -self -. -group_info -= -GroupInfo -: -: -new -( -captures -. -iter -( -) -. -map -( -| -x -| -x -. -iter -( -) -. -map -( -| -y -| -y -. -as_ref -( -) -) -) -) -? -; -Ok -( -( -) -) -} -/ -/ -/ -Remap -the -transitions -in -every -state -of -this -NFA -using -the -given -map -. -/ -/ -/ -The -given -map -should -be -indexed -according -to -state -ID -namespace -used -by -/ -/ -/ -the -transitions -of -the -states -currently -in -this -NFA -. -/ -/ -/ -/ -/ -/ -This -is -particularly -useful -to -the -NFA -builder -since -it -is -convenient -/ -/ -/ -to -add -NFA -states -in -order -to -produce -their -final -IDs -. -Then -after -all -/ -/ -/ -of -the -intermediate -" -empty -" -states -( -unconditional -epsilon -transitions -) -/ -/ -/ -have -been -removed -from -the -builder -' -s -representation -we -can -re -- -map -all -/ -/ -/ -of -the -transitions -in -the -states -already -added -to -their -final -IDs -. -pub -( -super -) -fn -remap -( -& -mut -self -old_to_new -: -& -[ -StateID -] -) -{ -for -state -in -& -mut -self -. -states -{ -state -. -remap -( -old_to_new -) -; -} -self -. -start_anchored -= -old_to_new -[ -self -. -start_anchored -] -; -self -. -start_unanchored -= -old_to_new -[ -self -. -start_unanchored -] -; -for -id -in -self -. -start_pattern -. -iter_mut -( -) -{ -* -id -= -old_to_new -[ -* -id -] -; -} -} -} -impl -fmt -: -: -Debug -for -Inner -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -writeln -! -( -f -" -thompson -: -: -NFA -( -" -) -? -; -for -( -sid -state -) -in -self -. -states -. -iter -( -) -. -with_state_ids -( -) -{ -let -status -= -if -sid -= -= -self -. -start_anchored -{ -' -^ -' -} -else -if -sid -= -= -self -. -start_unanchored -{ -' -> -' -} -else -{ -' -' -} -; -writeln -! -( -f -" -{ -} -{ -: -06 -? -} -: -{ -: -? -} -" -status -sid -. -as_usize -( -) -state -) -? -; -} -let -pattern_len -= -self -. -start_pattern -. -len -( -) -; -if -pattern_len -> -1 -{ -writeln -! -( -f -" -" -) -? -; -for -pid -in -0 -. -. -pattern_len -{ -let -sid -= -self -. -start_pattern -[ -pid -] -; -writeln -! -( -f -" -START -( -{ -: -06 -? -} -) -: -{ -: -? -} -" -pid -sid -. -as_usize -( -) -) -? -; -} -} -writeln -! -( -f -" -" -) -? -; -writeln -! -( -f -" -transition -equivalence -classes -: -{ -: -? -} -" -self -. -byte_classes -) -? -; -writeln -! -( -f -" -) -" -) -? -; -Ok -( -( -) -) -} -} -/ -/ -/ -A -state -in -an -NFA -. -/ -/ -/ -/ -/ -/ -In -theory -it -can -help -to -conceptualize -an -NFA -as -a -graph -consisting -of -/ -/ -/ -State -s -. -Each -State -contains -its -complete -set -of -outgoing -transitions -. -/ -/ -/ -/ -/ -/ -In -practice -it -can -help -to -conceptualize -an -NFA -as -a -sequence -of -/ -/ -/ -instructions -for -a -virtual -machine -. -Each -State -says -what -to -do -and -where -/ -/ -/ -to -go -next -. -/ -/ -/ -/ -/ -/ -Strictly -speaking -the -practical -interpretation -is -the -most -correct -one -/ -/ -/ -because -of -the -[ -Capture -] -( -State -: -: -Capture -) -state -. -Namely -a -Capture -/ -/ -/ -state -always -forwards -execution -to -another -state -unconditionally -. -Its -only -/ -/ -/ -purpose -is -to -cause -a -side -effect -: -the -recording -of -the -current -input -/ -/ -/ -position -at -a -particular -location -in -memory -. -In -this -sense -an -NFA -/ -/ -/ -has -more -power -than -a -theoretical -non -- -deterministic -finite -automaton -. -/ -/ -/ -/ -/ -/ -For -most -uses -of -this -crate -it -is -likely -that -one -may -never -even -need -to -/ -/ -/ -be -aware -of -this -type -at -all -. -The -main -use -cases -for -looking -at -State -s -/ -/ -/ -directly -are -if -you -need -to -write -your -own -search -implementation -or -if -you -/ -/ -/ -need -to -do -some -kind -of -analysis -on -the -NFA -. -# -[ -derive -( -Clone -Eq -PartialEq -) -] -pub -enum -State -{ -/ -/ -/ -A -state -with -a -single -transition -that -can -only -be -taken -if -the -current -/ -/ -/ -input -symbol -is -in -a -particular -range -of -bytes -. -ByteRange -{ -/ -/ -/ -The -transition -from -this -state -to -the -next -. -trans -: -Transition -} -/ -/ -/ -A -state -with -possibly -many -transitions -represented -in -a -sparse -fashion -. -/ -/ -/ -Transitions -are -non -- -overlapping -and -ordered -lexicographically -by -input -/ -/ -/ -range -. -/ -/ -/ -/ -/ -/ -In -practice -this -is -used -for -encoding -UTF -- -8 -automata -. -Its -presence -is -/ -/ -/ -primarily -an -optimization -that -avoids -many -additional -unconditional -/ -/ -/ -epsilon -transitions -( -via -[ -Union -] -( -State -: -: -Union -) -states -) -and -thus -/ -/ -/ -decreases -the -overhead -of -traversing -the -NFA -. -This -can -improve -both -/ -/ -/ -matching -time -and -DFA -construction -time -. -Sparse -( -SparseTransitions -) -/ -/ -/ -A -dense -representation -of -a -state -with -multiple -transitions -. -Dense -( -DenseTransitions -) -/ -/ -/ -A -conditional -epsilon -transition -satisfied -via -some -sort -of -/ -/ -/ -look -- -around -. -Look -- -around -is -limited -to -anchor -and -word -boundary -/ -/ -/ -assertions -. -/ -/ -/ -/ -/ -/ -Look -- -around -states -are -meant -to -be -evaluated -while -performing -epsilon -/ -/ -/ -closure -( -computing -the -set -of -states -reachable -from -a -particular -state -/ -/ -/ -via -only -epsilon -transitions -) -. -If -the -current -position -in -the -haystack -/ -/ -/ -satisfies -the -look -- -around -assertion -then -you -' -re -permitted -to -follow -/ -/ -/ -that -epsilon -transition -. -Look -{ -/ -/ -/ -The -look -- -around -assertion -that -must -be -satisfied -before -moving -/ -/ -/ -to -next -. -look -: -Look -/ -/ -/ -The -state -to -transition -to -if -the -look -- -around -assertion -is -/ -/ -/ -satisfied -. -next -: -StateID -} -/ -/ -/ -An -alternation -such -that -there -exists -an -epsilon -transition -to -all -/ -/ -/ -states -in -alternates -where -matches -found -via -earlier -transitions -/ -/ -/ -are -preferred -over -later -transitions -. -Union -{ -/ -/ -/ -An -ordered -sequence -of -unconditional -epsilon -transitions -to -other -/ -/ -/ -states -. -Transitions -earlier -in -the -sequence -are -preferred -over -/ -/ -/ -transitions -later -in -the -sequence -. -alternates -: -Box -< -[ -StateID -] -> -} -/ -/ -/ -An -alternation -such -that -there -exists -precisely -two -unconditional -/ -/ -/ -epsilon -transitions -where -matches -found -via -alt1 -are -preferred -over -/ -/ -/ -matches -found -via -alt2 -. -/ -/ -/ -/ -/ -/ -This -state -exists -as -a -common -special -case -of -Union -where -there -are -/ -/ -/ -only -two -alternates -. -In -this -case -we -don -' -t -need -any -allocations -to -/ -/ -/ -represent -the -state -. -This -saves -a -bit -of -memory -and -also -saves -an -/ -/ -/ -additional -memory -access -when -traversing -the -NFA -. -BinaryUnion -{ -/ -/ -/ -An -unconditional -epsilon -transition -to -another -NFA -state -. -This -/ -/ -/ -is -preferred -over -alt2 -. -alt1 -: -StateID -/ -/ -/ -An -unconditional -epsilon -transition -to -another -NFA -state -. -Matches -/ -/ -/ -reported -via -this -transition -should -only -be -reported -if -no -matches -/ -/ -/ -were -found -by -following -alt1 -. -alt2 -: -StateID -} -/ -/ -/ -An -empty -state -that -records -a -capture -location -. -/ -/ -/ -/ -/ -/ -From -the -perspective -of -finite -automata -this -is -precisely -equivalent -/ -/ -/ -to -an -unconditional -epsilon -transition -but -serves -the -purpose -of -/ -/ -/ -instructing -NFA -simulations -to -record -additional -state -when -the -finite -/ -/ -/ -state -machine -passes -through -this -epsilon -transition -. -/ -/ -/ -/ -/ -/ -slot -in -this -context -refers -to -the -specific -capture -group -slot -/ -/ -/ -offset -that -is -being -recorded -. -Each -capturing -group -has -two -slots -/ -/ -/ -corresponding -to -the -start -and -end -of -the -matching -portion -of -that -/ -/ -/ -group -. -/ -/ -/ -/ -/ -/ -The -pattern -ID -and -capture -group -index -are -also -included -in -this -state -/ -/ -/ -in -case -they -are -useful -. -But -mostly -all -you -' -ll -need -is -next -and -/ -/ -/ -slot -. -Capture -{ -/ -/ -/ -The -state -to -transition -to -unconditionally -. -next -: -StateID -/ -/ -/ -The -pattern -ID -that -this -capture -belongs -to -. -pattern_id -: -PatternID -/ -/ -/ -The -capture -group -index -that -this -capture -belongs -to -. -Capture -group -/ -/ -/ -indices -are -local -to -each -pattern -. -For -example -when -capturing -/ -/ -/ -groups -are -enabled -every -pattern -has -a -capture -group -at -index -/ -/ -/ -0 -. -group_index -: -SmallIndex -/ -/ -/ -The -slot -index -for -this -capture -. -Every -capturing -group -has -two -/ -/ -/ -slots -: -one -for -the -start -haystack -offset -and -one -for -the -end -/ -/ -/ -haystack -offset -. -Unlike -capture -group -indices -slot -indices -are -/ -/ -/ -global -across -all -patterns -in -this -NFA -. -That -is -each -slot -belongs -/ -/ -/ -to -a -single -pattern -but -there -is -only -one -slot -at -index -i -. -slot -: -SmallIndex -} -/ -/ -/ -A -state -that -cannot -be -transitioned -out -of -. -This -is -useful -for -cases -/ -/ -/ -where -you -want -to -prevent -matching -from -occurring -. -For -example -if -your -/ -/ -/ -regex -parser -permits -empty -character -classes -then -one -could -choose -/ -/ -/ -a -Fail -state -to -represent -them -. -( -An -empty -character -class -can -be -/ -/ -/ -thought -of -as -an -empty -set -. -Since -nothing -is -in -an -empty -set -they -can -/ -/ -/ -never -match -anything -. -) -Fail -/ -/ -/ -A -match -state -. -There -is -at -least -one -such -occurrence -of -this -state -for -/ -/ -/ -each -regex -that -can -match -that -is -in -this -NFA -. -Match -{ -/ -/ -/ -The -matching -pattern -ID -. -pattern_id -: -PatternID -} -} -impl -State -{ -/ -/ -/ -Returns -true -if -and -only -if -this -state -contains -one -or -more -epsilon -/ -/ -/ -transitions -. -/ -/ -/ -/ -/ -/ -In -practice -a -state -has -no -outgoing -transitions -( -like -Match -) -has -/ -/ -/ -only -non -- -epsilon -transitions -( -like -ByteRange -) -or -has -only -epsilon -/ -/ -/ -transitions -( -like -Union -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -State -Transition -} -/ -/ -/ -util -: -: -primitives -: -: -{ -PatternID -StateID -SmallIndex -} -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Capture -states -are -epsilon -transitions -. -/ -/ -/ -let -state -= -State -: -: -Capture -{ -/ -/ -/ -next -: -StateID -: -: -ZERO -/ -/ -/ -pattern_id -: -PatternID -: -: -ZERO -/ -/ -/ -group_index -: -SmallIndex -: -: -ZERO -/ -/ -/ -slot -: -SmallIndex -: -: -ZERO -/ -/ -/ -} -; -/ -/ -/ -assert -! -( -state -. -is_epsilon -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -ByteRange -states -are -not -. -/ -/ -/ -let -state -= -State -: -: -ByteRange -{ -/ -/ -/ -trans -: -Transition -{ -start -: -b -' -a -' -end -: -b -' -z -' -next -: -StateID -: -: -ZERO -} -/ -/ -/ -} -; -/ -/ -/ -assert -! -( -! -state -. -is_epsilon -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_epsilon -( -& -self -) -- -> -bool -{ -match -* -self -{ -State -: -: -ByteRange -{ -. -. -} -| -State -: -: -Sparse -{ -. -. -} -| -State -: -: -Dense -{ -. -. -} -| -State -: -: -Fail -| -State -: -: -Match -{ -. -. -} -= -> -false -State -: -: -Look -{ -. -. -} -| -State -: -: -Union -{ -. -. -} -| -State -: -: -BinaryUnion -{ -. -. -} -| -State -: -: -Capture -{ -. -. -} -= -> -true -} -} -/ -/ -/ -Returns -the -heap -memory -usage -of -this -NFA -state -in -bytes -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -match -* -self -{ -State -: -: -ByteRange -{ -. -. -} -| -State -: -: -Look -{ -. -. -} -| -State -: -: -BinaryUnion -{ -. -. -} -| -State -: -: -Capture -{ -. -. -} -| -State -: -: -Match -{ -. -. -} -| -State -: -: -Fail -= -> -0 -State -: -: -Sparse -( -SparseTransitions -{ -ref -transitions -} -) -= -> -{ -transitions -. -len -( -) -* -mem -: -: -size_of -: -: -< -Transition -> -( -) -} -State -: -: -Dense -{ -. -. -} -= -> -256 -* -mem -: -: -size_of -: -: -< -StateID -> -( -) -State -: -: -Union -{ -ref -alternates -} -= -> -{ -alternates -. -len -( -) -* -mem -: -: -size_of -: -: -< -StateID -> -( -) -} -} -} -/ -/ -/ -Remap -the -transitions -in -this -state -using -the -given -map -. -Namely -the -/ -/ -/ -given -map -should -be -indexed -according -to -the -transitions -currently -/ -/ -/ -in -this -state -. -/ -/ -/ -/ -/ -/ -This -is -used -during -the -final -phase -of -the -NFA -compiler -which -turns -/ -/ -/ -its -intermediate -NFA -into -the -final -NFA -. -fn -remap -( -& -mut -self -remap -: -& -[ -StateID -] -) -{ -match -* -self -{ -State -: -: -ByteRange -{ -ref -mut -trans -} -= -> -{ -trans -. -next -= -remap -[ -trans -. -next -] -} -State -: -: -Sparse -( -SparseTransitions -{ -ref -mut -transitions -} -) -= -> -{ -for -t -in -transitions -. -iter_mut -( -) -{ -t -. -next -= -remap -[ -t -. -next -] -; -} -} -State -: -: -Dense -( -DenseTransitions -{ -ref -mut -transitions -} -) -= -> -{ -for -sid -in -transitions -. -iter_mut -( -) -{ -* -sid -= -remap -[ -* -sid -] -; -} -} -State -: -: -Look -{ -ref -mut -next -. -. -} -= -> -* -next -= -remap -[ -* -next -] -State -: -: -Union -{ -ref -mut -alternates -} -= -> -{ -for -alt -in -alternates -. -iter_mut -( -) -{ -* -alt -= -remap -[ -* -alt -] -; -} -} -State -: -: -BinaryUnion -{ -ref -mut -alt1 -ref -mut -alt2 -} -= -> -{ -* -alt1 -= -remap -[ -* -alt1 -] -; -* -alt2 -= -remap -[ -* -alt2 -] -; -} -State -: -: -Capture -{ -ref -mut -next -. -. -} -= -> -* -next -= -remap -[ -* -next -] -State -: -: -Fail -= -> -{ -} -State -: -: -Match -{ -. -. -} -= -> -{ -} -} -} -} -impl -fmt -: -: -Debug -for -State -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -match -* -self -{ -State -: -: -ByteRange -{ -ref -trans -} -= -> -trans -. -fmt -( -f -) -State -: -: -Sparse -( -SparseTransitions -{ -ref -transitions -} -) -= -> -{ -let -rs -= -transitions -. -iter -( -) -. -map -( -| -t -| -format -! -( -" -{ -: -? -} -" -t -) -) -. -collect -: -: -< -Vec -< -String -> -> -( -) -. -join -( -" -" -) -; -write -! -( -f -" -sparse -( -{ -} -) -" -rs -) -} -State -: -: -Dense -( -ref -dense -) -= -> -{ -write -! -( -f -" -dense -( -" -) -? -; -for -( -i -t -) -in -dense -. -iter -( -) -. -enumerate -( -) -{ -if -i -> -0 -{ -write -! -( -f -" -" -) -? -; -} -write -! -( -f -" -{ -: -? -} -" -t -) -? -; -} -write -! -( -f -" -) -" -) -} -State -: -: -Look -{ -ref -look -next -} -= -> -{ -write -! -( -f -" -{ -: -? -} -= -> -{ -: -? -} -" -look -next -. -as_usize -( -) -) -} -State -: -: -Union -{ -ref -alternates -} -= -> -{ -let -alts -= -alternates -. -iter -( -) -. -map -( -| -id -| -format -! -( -" -{ -: -? -} -" -id -. -as_usize -( -) -) -) -. -collect -: -: -< -Vec -< -String -> -> -( -) -. -join -( -" -" -) -; -write -! -( -f -" -union -( -{ -} -) -" -alts -) -} -State -: -: -BinaryUnion -{ -alt1 -alt2 -} -= -> -{ -write -! -( -f -" -binary -- -union -( -{ -} -{ -} -) -" -alt1 -. -as_usize -( -) -alt2 -. -as_usize -( -) -) -} -State -: -: -Capture -{ -next -pattern_id -group_index -slot -} -= -> -{ -write -! -( -f -" -capture -( -pid -= -{ -: -? -} -group -= -{ -: -? -} -slot -= -{ -: -? -} -) -= -> -{ -: -? -} -" -pattern_id -. -as_usize -( -) -group_index -. -as_usize -( -) -slot -. -as_usize -( -) -next -. -as_usize -( -) -) -} -State -: -: -Fail -= -> -write -! -( -f -" -FAIL -" -) -State -: -: -Match -{ -pattern_id -} -= -> -{ -write -! -( -f -" -MATCH -( -{ -: -? -} -) -" -pattern_id -. -as_usize -( -) -) -} -} -} -} -/ -/ -/ -A -sequence -of -transitions -used -to -represent -a -sparse -state -. -/ -/ -/ -/ -/ -/ -This -is -the -primary -representation -of -a -[ -Sparse -] -( -State -: -: -Sparse -) -state -. -/ -/ -/ -It -corresponds -to -a -sorted -sequence -of -transitions -with -non -- -overlapping -/ -/ -/ -byte -ranges -. -If -the -byte -at -the -current -position -in -the -haystack -matches -/ -/ -/ -one -of -the -byte -ranges -then -the -finite -state -machine -should -take -the -/ -/ -/ -corresponding -transition -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -SparseTransitions -{ -/ -/ -/ -The -sorted -sequence -of -non -- -overlapping -transitions -. -pub -transitions -: -Box -< -[ -Transition -] -> -} -impl -SparseTransitions -{ -/ -/ -/ -This -follows -the -matching -transition -for -a -particular -byte -. -/ -/ -/ -/ -/ -/ -The -matching -transition -is -found -by -looking -for -a -matching -byte -/ -/ -/ -range -( -there -is -at -most -one -) -corresponding -to -the -position -at -in -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -If -at -> -= -haystack -. -len -( -) -then -this -returns -None -. -# -[ -inline -] -pub -fn -matches -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Option -< -StateID -> -{ -haystack -. -get -( -at -) -. -and_then -( -| -& -b -| -self -. -matches_byte -( -b -) -) -} -/ -/ -/ -This -follows -the -matching -transition -for -any -member -of -the -alphabet -. -/ -/ -/ -/ -/ -/ -The -matching -transition -is -found -by -looking -for -a -matching -byte -/ -/ -/ -range -( -there -is -at -most -one -) -corresponding -to -the -position -at -in -/ -/ -/ -haystack -. -If -the -given -alphabet -unit -is -[ -EOI -] -( -alphabet -: -: -Unit -: -: -eoi -) -/ -/ -/ -then -this -always -returns -None -. -# -[ -inline -] -pub -( -crate -) -fn -matches_unit -( -& -self -unit -: -alphabet -: -: -Unit -) -- -> -Option -< -StateID -> -{ -unit -. -as_u8 -( -) -. -map_or -( -None -| -byte -| -self -. -matches_byte -( -byte -) -) -} -/ -/ -/ -This -follows -the -matching -transition -for -a -particular -byte -. -/ -/ -/ -/ -/ -/ -The -matching -transition -is -found -by -looking -for -a -matching -byte -range -/ -/ -/ -( -there -is -at -most -one -) -corresponding -to -the -byte -given -. -# -[ -inline -] -pub -fn -matches_byte -( -& -self -byte -: -u8 -) -- -> -Option -< -StateID -> -{ -for -t -in -self -. -transitions -. -iter -( -) -{ -if -t -. -start -> -byte -{ -break -; -} -else -if -t -. -matches_byte -( -byte -) -{ -return -Some -( -t -. -next -) -; -} -} -None -/ -* -/ -/ -This -is -an -alternative -implementation -that -uses -binary -search -. -In -/ -/ -some -ad -hoc -experiments -like -/ -/ -/ -/ -smallishru -= -OpenSubtitles2018 -. -raw -. -sample -. -smallish -. -ru -/ -/ -regex -- -cli -find -nfa -thompson -pikevm -- -b -" -smallishru -" -' -\ -b -\ -w -+ -\ -b -' -/ -/ -/ -/ -I -could -not -observe -any -improvement -and -in -fact -things -seemed -to -/ -/ -be -a -bit -slower -. -I -can -see -an -improvement -in -at -least -one -benchmark -: -/ -/ -/ -/ -allcpssmall -= -all -- -codepoints -- -utf8 -- -10x -/ -/ -regex -- -cli -find -nfa -thompson -pikevm -allcpssmall -' -\ -pL -{ -100 -} -' -/ -/ -/ -/ -Where -total -search -time -goes -from -3 -. -2s -to -2 -. -4s -when -using -binary -/ -/ -search -. -self -. -transitions -. -binary_search_by -( -| -t -| -{ -if -t -. -end -< -byte -{ -core -: -: -cmp -: -: -Ordering -: -: -Less -} -else -if -t -. -start -> -byte -{ -core -: -: -cmp -: -: -Ordering -: -: -Greater -} -else -{ -core -: -: -cmp -: -: -Ordering -: -: -Equal -} -} -) -. -ok -( -) -. -map -( -| -i -| -self -. -transitions -[ -i -] -. -next -) -* -/ -} -} -/ -/ -/ -A -sequence -of -transitions -used -to -represent -a -dense -state -. -/ -/ -/ -/ -/ -/ -This -is -the -primary -representation -of -a -[ -Dense -] -( -State -: -: -Dense -) -state -. -It -/ -/ -/ -provides -constant -time -matching -. -That -is -given -a -byte -in -a -haystack -and -/ -/ -/ -a -DenseTransitions -one -can -determine -if -the -state -matches -in -constant -/ -/ -/ -time -. -/ -/ -/ -/ -/ -/ -This -is -in -contrast -to -SparseTransitions -whose -time -complexity -is -/ -/ -/ -necessarily -bigger -than -constant -time -. -Also -in -contrast -DenseTransitions -/ -/ -/ -usually -requires -( -much -) -more -heap -memory -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -DenseTransitions -{ -/ -/ -/ -A -dense -representation -of -this -state -' -s -transitions -on -the -heap -. -This -/ -/ -/ -always -has -length -256 -. -pub -transitions -: -Box -< -[ -StateID -] -> -} -impl -DenseTransitions -{ -/ -/ -/ -This -follows -the -matching -transition -for -a -particular -byte -. -/ -/ -/ -/ -/ -/ -The -matching -transition -is -found -by -looking -for -a -transition -that -/ -/ -/ -doesn -' -t -correspond -to -StateID -: -: -ZERO -for -the -byte -at -the -given -/ -/ -/ -position -in -haystack -. -/ -/ -/ -/ -/ -/ -If -at -> -= -haystack -. -len -( -) -then -this -returns -None -. -# -[ -inline -] -pub -fn -matches -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Option -< -StateID -> -{ -haystack -. -get -( -at -) -. -and_then -( -| -& -b -| -self -. -matches_byte -( -b -) -) -} -/ -/ -/ -This -follows -the -matching -transition -for -any -member -of -the -alphabet -. -/ -/ -/ -/ -/ -/ -The -matching -transition -is -found -by -looking -for -a -transition -that -/ -/ -/ -doesn -' -t -correspond -to -StateID -: -: -ZERO -for -the -byte -at -the -given -/ -/ -/ -position -in -haystack -. -/ -/ -/ -/ -/ -/ -If -at -> -= -haystack -. -len -( -) -or -if -the -given -alphabet -unit -is -/ -/ -/ -[ -EOI -] -( -alphabet -: -: -Unit -: -: -eoi -) -then -this -returns -None -. -# -[ -inline -] -pub -( -crate -) -fn -matches_unit -( -& -self -unit -: -alphabet -: -: -Unit -) -- -> -Option -< -StateID -> -{ -unit -. -as_u8 -( -) -. -map_or -( -None -| -byte -| -self -. -matches_byte -( -byte -) -) -} -/ -/ -/ -This -follows -the -matching -transition -for -a -particular -byte -. -/ -/ -/ -/ -/ -/ -The -matching -transition -is -found -by -looking -for -a -transition -that -/ -/ -/ -doesn -' -t -correspond -to -StateID -: -: -ZERO -for -the -given -byte -. -/ -/ -/ -/ -/ -/ -If -at -> -= -haystack -. -len -( -) -then -this -returns -None -. -# -[ -inline -] -pub -fn -matches_byte -( -& -self -byte -: -u8 -) -- -> -Option -< -StateID -> -{ -let -next -= -self -. -transitions -[ -usize -: -: -from -( -byte -) -] -; -if -next -= -= -StateID -: -: -ZERO -{ -None -} -else -{ -Some -( -next -) -} -} -/ -* -/ -/ -/ -The -dense -state -optimization -isn -' -t -currently -enabled -so -permit -a -/ -/ -/ -little -bit -of -dead -code -. -pub -( -crate -) -fn -from_sparse -( -sparse -: -& -SparseTransitions -) -- -> -DenseTransitions -{ -let -mut -dense -= -vec -! -[ -StateID -: -: -ZERO -; -256 -] -; -for -t -in -sparse -. -transitions -. -iter -( -) -{ -for -b -in -t -. -start -. -. -= -t -. -end -{ -dense -[ -usize -: -: -from -( -b -) -] -= -t -. -next -; -} -} -DenseTransitions -{ -transitions -: -dense -. -into_boxed_slice -( -) -} -} -* -/ -/ -/ -/ -Returns -an -iterator -over -all -transitions -that -don -' -t -point -to -/ -/ -/ -StateID -: -: -ZERO -. -pub -( -crate -) -fn -iter -( -& -self -) -- -> -impl -Iterator -< -Item -= -Transition -> -+ -' -_ -{ -use -crate -: -: -util -: -: -int -: -: -Usize -; -self -. -transitions -. -iter -( -) -. -enumerate -( -) -. -filter -( -| -& -( -_ -& -sid -) -| -sid -! -= -StateID -: -: -ZERO -) -. -map -( -| -( -byte -& -next -) -| -Transition -{ -start -: -byte -. -as_u8 -( -) -end -: -byte -. -as_u8 -( -) -next -} -) -} -} -/ -/ -/ -A -single -transition -to -another -state -. -/ -/ -/ -/ -/ -/ -This -transition -may -only -be -followed -if -the -current -byte -in -the -haystack -/ -/ -/ -falls -in -the -inclusive -range -of -bytes -specified -. -# -[ -derive -( -Clone -Copy -Eq -Hash -PartialEq -) -] -pub -struct -Transition -{ -/ -/ -/ -The -inclusive -start -of -the -byte -range -. -pub -start -: -u8 -/ -/ -/ -The -inclusive -end -of -the -byte -range -. -pub -end -: -u8 -/ -/ -/ -The -identifier -of -the -state -to -transition -to -. -pub -next -: -StateID -} -impl -Transition -{ -/ -/ -/ -Returns -true -if -the -position -at -in -haystack -falls -in -this -/ -/ -/ -transition -' -s -range -of -bytes -. -/ -/ -/ -/ -/ -/ -If -at -> -= -haystack -. -len -( -) -then -this -returns -false -. -pub -fn -matches -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -haystack -. -get -( -at -) -. -map_or -( -false -| -& -b -| -self -. -matches_byte -( -b -) -) -} -/ -/ -/ -Returns -true -if -the -given -alphabet -unit -falls -in -this -transition -' -s -/ -/ -/ -range -of -bytes -. -If -the -given -unit -is -[ -EOI -] -( -alphabet -: -: -Unit -: -: -eoi -) -then -/ -/ -/ -this -returns -false -. -pub -fn -matches_unit -( -& -self -unit -: -alphabet -: -: -Unit -) -- -> -bool -{ -unit -. -as_u8 -( -) -. -map_or -( -false -| -byte -| -self -. -matches_byte -( -byte -) -) -} -/ -/ -/ -Returns -true -if -the -given -byte -falls -in -this -transition -' -s -range -of -/ -/ -/ -bytes -. -pub -fn -matches_byte -( -& -self -byte -: -u8 -) -- -> -bool -{ -self -. -start -< -= -byte -& -& -byte -< -= -self -. -end -} -} -impl -fmt -: -: -Debug -for -Transition -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -use -crate -: -: -util -: -: -escape -: -: -DebugByte -; -let -Transition -{ -start -end -next -} -= -* -self -; -if -self -. -start -= -= -self -. -end -{ -write -! -( -f -" -{ -: -? -} -= -> -{ -: -? -} -" -DebugByte -( -start -) -next -. -as_usize -( -) -) -} -else -{ -write -! -( -f -" -{ -: -? -} -- -{ -: -? -} -= -> -{ -: -? -} -" -DebugByte -( -start -) -DebugByte -( -end -) -next -. -as_usize -( -) -) -} -} -} -/ -/ -/ -An -iterator -over -all -pattern -IDs -in -an -NFA -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -NFA -: -: -patterns -] -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameter -' -a -refers -to -the -lifetime -of -the -NFA -from -which -/ -/ -/ -this -pattern -iterator -was -created -. -# -[ -derive -( -Debug -) -] -pub -struct -PatternIter -< -' -a -> -{ -it -: -PatternIDIter -/ -/ -/ -We -explicitly -associate -a -lifetime -with -this -iterator -even -though -we -/ -/ -/ -don -' -t -actually -borrow -anything -from -the -NFA -. -We -do -this -for -backward -/ -/ -/ -compatibility -purposes -. -If -we -ever -do -need -to -borrow -something -from -/ -/ -/ -the -NFA -then -we -can -and -just -get -rid -of -this -marker -without -breaking -/ -/ -/ -the -public -API -. -_marker -: -core -: -: -marker -: -: -PhantomData -< -& -' -a -( -) -> -} -impl -< -' -a -> -Iterator -for -PatternIter -< -' -a -> -{ -type -Item -= -PatternID -; -fn -next -( -& -mut -self -) -- -> -Option -< -PatternID -> -{ -self -. -it -. -next -( -) -} -} -# -[ -cfg -( -all -( -test -feature -= -" -nfa -- -pikevm -" -) -) -] -mod -tests -{ -use -super -: -: -* -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Input -} -; -/ -/ -This -asserts -that -an -NFA -state -doesn -' -t -have -its -size -changed -. -It -is -/ -/ -* -really -* -easy -to -accidentally -increase -the -size -and -thus -potentially -/ -/ -dramatically -increase -the -memory -usage -of -every -NFA -. -/ -/ -/ -/ -This -assert -doesn -' -t -mean -we -absolutely -cannot -increase -the -size -of -an -/ -/ -NFA -state -. -We -can -. -It -' -s -just -here -to -make -sure -we -do -it -knowingly -and -/ -/ -intentionally -. -# -[ -test -] -fn -state_has_small_size -( -) -{ -# -[ -cfg -( -target_pointer_width -= -" -64 -" -) -] -assert_eq -! -( -24 -core -: -: -mem -: -: -size_of -: -: -< -State -> -( -) -) -; -# -[ -cfg -( -target_pointer_width -= -" -32 -" -) -] -assert_eq -! -( -20 -core -: -: -mem -: -: -size_of -: -: -< -State -> -( -) -) -; -} -# -[ -test -] -fn -always_match -( -) -{ -let -re -= -PikeVM -: -: -new_from_nfa -( -NFA -: -: -always_match -( -) -) -. -unwrap -( -) -; -let -mut -cache -= -re -. -create_cache -( -) -; -let -mut -caps -= -re -. -create_captures -( -) -; -let -mut -find -= -| -haystack -start -end -| -{ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -start -. -. -end -) -; -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -caps -. -get_match -( -) -. -map -( -| -m -| -m -. -end -( -) -) -} -; -assert_eq -! -( -Some -( -0 -) -find -( -" -" -0 -0 -) -) -; -assert_eq -! -( -Some -( -0 -) -find -( -" -a -" -0 -1 -) -) -; -assert_eq -! -( -Some -( -1 -) -find -( -" -a -" -1 -1 -) -) -; -assert_eq -! -( -Some -( -0 -) -find -( -" -ab -" -0 -2 -) -) -; -assert_eq -! -( -Some -( -1 -) -find -( -" -ab -" -1 -2 -) -) -; -assert_eq -! -( -Some -( -2 -) -find -( -" -ab -" -2 -2 -) -) -; -} -# -[ -test -] -fn -never_match -( -) -{ -let -re -= -PikeVM -: -: -new_from_nfa -( -NFA -: -: -never_match -( -) -) -. -unwrap -( -) -; -let -mut -cache -= -re -. -create_cache -( -) -; -let -mut -caps -= -re -. -create_captures -( -) -; -let -mut -find -= -| -haystack -start -end -| -{ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -start -. -. -end -) -; -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -caps -. -get_match -( -) -. -map -( -| -m -| -m -. -end -( -) -) -} -; -assert_eq -! -( -None -find -( -" -" -0 -0 -) -) -; -assert_eq -! -( -None -find -( -" -a -" -0 -1 -) -) -; -assert_eq -! -( -None -find -( -" -a -" -1 -1 -) -) -; -assert_eq -! -( -None -find -( -" -ab -" -0 -2 -) -) -; -assert_eq -! -( -None -find -( -" -ab -" -1 -2 -) -) -; -assert_eq -! -( -None -find -( -" -ab -" -2 -2 -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/nfa/thompson/pikevm.rs b/third_party/rust/regex-automata/src/nfa/thompson/pikevm.rs deleted file mode 100644 index 1c8d390dd6cfd..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/pikevm.rs +++ /dev/null @@ -1,24122 +0,0 @@ -/ -* -! -An -NFA -backed -Pike -VM -for -executing -regex -searches -with -capturing -groups -. -This -module -provides -a -[ -PikeVM -] -that -works -by -simulating -an -NFA -and -resolving -all -spans -of -capturing -groups -that -participate -in -a -match -. -* -/ -# -[ -cfg -( -feature -= -" -internal -- -instrument -- -pikevm -" -) -] -use -core -: -: -cell -: -: -RefCell -; -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -nfa -: -: -thompson -: -: -{ -self -BuildError -State -NFA -} -util -: -: -{ -captures -: -: -Captures -empty -iter -prefilter -: -: -Prefilter -primitives -: -: -{ -NonMaxUsize -PatternID -SmallIndex -StateID -} -search -: -: -{ -Anchored -HalfMatch -Input -Match -MatchKind -PatternSet -Span -} -sparse_set -: -: -SparseSet -} -} -; -/ -/ -/ -A -simple -macro -for -conditionally -executing -instrumentation -logic -when -/ -/ -/ -the -' -trace -' -log -level -is -enabled -. -This -is -a -compile -- -time -no -- -op -when -the -/ -/ -/ -' -internal -- -instrument -- -pikevm -' -feature -isn -' -t -enabled -. -The -intent -here -is -that -/ -/ -/ -this -makes -it -easier -to -avoid -doing -extra -work -when -instrumentation -isn -' -t -/ -/ -/ -enabled -. -/ -/ -/ -/ -/ -/ -This -macro -accepts -a -closure -of -type -| -& -mut -Counters -| -. -The -closure -can -/ -/ -/ -then -increment -counters -( -or -whatever -) -in -accordance -with -what -one -wants -/ -/ -/ -to -track -. -macro_rules -! -instrument -{ -( -fun -: -expr -) -= -> -{ -# -[ -cfg -( -feature -= -" -internal -- -instrument -- -pikevm -" -) -] -{ -let -fun -: -& -mut -dyn -FnMut -( -& -mut -Counters -) -= -& -mut -fun -; -COUNTERS -. -with -( -| -c -: -& -RefCell -< -Counters -> -| -fun -( -& -mut -* -c -. -borrow_mut -( -) -) -) -; -} -} -; -} -# -[ -cfg -( -feature -= -" -internal -- -instrument -- -pikevm -" -) -] -std -: -: -thread_local -! -{ -/ -/ -/ -Effectively -global -state -used -to -keep -track -of -instrumentation -/ -/ -/ -counters -. -The -" -proper -" -way -to -do -this -is -to -thread -it -through -the -/ -/ -/ -PikeVM -but -it -makes -the -code -quite -icky -. -Since -this -is -just -a -/ -/ -/ -debugging -feature -we -' -re -content -to -relegate -it -to -thread -local -/ -/ -/ -state -. -When -instrumentation -is -enabled -the -counters -are -reset -at -the -/ -/ -/ -beginning -of -every -search -and -printed -( -with -the -' -trace -' -log -level -) -at -/ -/ -/ -the -end -of -every -search -. -static -COUNTERS -: -RefCell -< -Counters -> -= -RefCell -: -: -new -( -Counters -: -: -empty -( -) -) -; -} -/ -/ -/ -The -configuration -used -for -building -a -[ -PikeVM -] -. -/ -/ -/ -/ -/ -/ -A -PikeVM -configuration -is -a -simple -data -object -that -is -typically -used -with -/ -/ -/ -[ -Builder -: -: -configure -] -. -It -can -be -cheaply -cloned -. -/ -/ -/ -/ -/ -/ -A -default -configuration -can -be -created -either -with -Config -: -: -new -or -/ -/ -/ -perhaps -more -conveniently -with -[ -PikeVM -: -: -config -] -. -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -Config -{ -match_kind -: -Option -< -MatchKind -> -pre -: -Option -< -Option -< -Prefilter -> -> -} -impl -Config -{ -/ -/ -/ -Return -a -new -default -PikeVM -configuration -. -pub -fn -new -( -) -- -> -Config -{ -Config -: -: -default -( -) -} -/ -/ -/ -Set -the -desired -match -semantics -. -/ -/ -/ -/ -/ -/ -The -default -is -[ -MatchKind -: -: -LeftmostFirst -] -which -corresponds -to -the -/ -/ -/ -match -semantics -of -Perl -- -like -regex -engines -. -That -is -when -multiple -/ -/ -/ -patterns -would -match -at -the -same -leftmost -position -the -pattern -that -/ -/ -/ -appears -first -in -the -concrete -syntax -is -chosen -. -/ -/ -/ -/ -/ -/ -Currently -the -only -other -kind -of -match -semantics -supported -is -/ -/ -/ -[ -MatchKind -: -: -All -] -. -This -corresponds -to -" -classical -DFA -" -construction -/ -/ -/ -where -all -possible -matches -are -visited -in -the -NFA -by -the -PikeVM -. -/ -/ -/ -/ -/ -/ -Typically -All -is -used -when -one -wants -to -execute -an -overlapping -/ -/ -/ -search -and -LeftmostFirst -otherwise -. -In -particular -it -rarely -makes -/ -/ -/ -sense -to -use -All -with -the -various -" -leftmost -" -find -routines -since -the -/ -/ -/ -leftmost -routines -depend -on -the -LeftmostFirst -automata -construction -/ -/ -/ -strategy -. -Specifically -LeftmostFirst -results -in -the -PikeVM -/ -/ -/ -simulating -dead -states -as -a -way -to -terminate -the -search -and -report -a -/ -/ -/ -match -. -LeftmostFirst -also -supports -non -- -greedy -matches -using -this -/ -/ -/ -strategy -where -as -All -does -not -. -pub -fn -match_kind -( -mut -self -kind -: -MatchKind -) -- -> -Config -{ -self -. -match_kind -= -Some -( -kind -) -; -self -} -/ -/ -/ -Set -a -prefilter -to -be -used -whenever -a -start -state -is -entered -. -/ -/ -/ -/ -/ -/ -A -[ -Prefilter -] -in -this -context -is -meant -to -accelerate -searches -by -/ -/ -/ -looking -for -literal -prefixes -that -every -match -for -the -corresponding -/ -/ -/ -pattern -( -or -patterns -) -must -start -with -. -Once -a -prefilter -produces -a -/ -/ -/ -match -the -underlying -search -routine -continues -on -to -try -and -confirm -/ -/ -/ -the -match -. -/ -/ -/ -/ -/ -/ -Be -warned -that -setting -a -prefilter -does -not -guarantee -that -the -search -/ -/ -/ -will -be -faster -. -While -it -' -s -usually -a -good -bet -if -the -prefilter -/ -/ -/ -produces -a -lot -of -false -positive -candidates -( -i -. -e -. -positions -matched -/ -/ -/ -by -the -prefilter -but -not -by -the -regex -) -then -the -overall -result -can -/ -/ -/ -be -slower -than -if -you -had -just -executed -the -regex -engine -without -any -/ -/ -/ -prefilters -. -/ -/ -/ -/ -/ -/ -By -default -no -prefilter -is -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Input -Match -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -configure -( -PikeVM -: -: -config -( -) -. -prefilter -( -pre -) -) -/ -/ -/ -. -build -( -r -" -( -foo -| -bar -) -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo1 -barfox -bar -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -5 -. -. -11 -) -) -re -. -find -( -& -mut -cache -input -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Be -warned -though -that -an -incorrect -prefilter -can -lead -to -incorrect -/ -/ -/ -results -! -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Input -HalfMatch -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -foo -" -" -car -" -] -) -; -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -configure -( -PikeVM -: -: -config -( -) -. -prefilter -( -pre -) -) -/ -/ -/ -. -build -( -r -" -( -foo -| -bar -) -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo1 -barfox -bar -" -) -; -/ -/ -/ -/ -/ -No -match -reported -even -though -there -clearly -is -one -! -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -& -mut -cache -input -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -prefilter -( -mut -self -pre -: -Option -< -Prefilter -> -) -- -> -Config -{ -self -. -pre -= -Some -( -pre -) -; -self -} -/ -/ -/ -Returns -the -match -semantics -set -in -this -configuration -. -pub -fn -get_match_kind -( -& -self -) -- -> -MatchKind -{ -self -. -match_kind -. -unwrap_or -( -MatchKind -: -: -LeftmostFirst -) -} -/ -/ -/ -Returns -the -prefilter -set -in -this -configuration -if -one -at -all -. -pub -fn -get_prefilter -( -& -self -) -- -> -Option -< -& -Prefilter -> -{ -self -. -pre -. -as_ref -( -) -. -unwrap_or -( -& -None -) -. -as_ref -( -) -} -/ -/ -/ -Overwrite -the -default -configuration -such -that -the -options -in -o -are -/ -/ -/ -always -used -. -If -an -option -in -o -is -not -set -then -the -corresponding -/ -/ -/ -option -in -self -is -used -. -If -it -' -s -not -set -in -self -either -then -it -/ -/ -/ -remains -not -set -. -pub -( -crate -) -fn -overwrite -( -& -self -o -: -Config -) -- -> -Config -{ -Config -{ -match_kind -: -o -. -match_kind -. -or -( -self -. -match_kind -) -pre -: -o -. -pre -. -or_else -( -| -| -self -. -pre -. -clone -( -) -) -} -} -} -/ -/ -/ -A -builder -for -a -PikeVM -. -/ -/ -/ -/ -/ -/ -This -builder -permits -configuring -options -for -the -syntax -of -a -pattern -/ -/ -/ -the -NFA -construction -and -the -PikeVM -construction -. -This -builder -is -/ -/ -/ -different -from -a -general -purpose -regex -builder -in -that -it -permits -fine -/ -/ -/ -grain -configuration -of -the -construction -process -. -The -trade -off -for -this -is -/ -/ -/ -complexity -and -the -possibility -of -setting -a -configuration -that -might -not -/ -/ -/ -make -sense -. -For -example -there -are -two -different -UTF -- -8 -modes -: -/ -/ -/ -/ -/ -/ -* -[ -util -: -: -syntax -: -: -Config -: -: -utf8 -] -( -crate -: -: -util -: -: -syntax -: -: -Config -: -: -utf8 -) -/ -/ -/ -controls -whether -the -pattern -itself -can -contain -sub -- -expressions -that -match -/ -/ -/ -invalid -UTF -- -8 -. -/ -/ -/ -* -[ -thompson -: -: -Config -: -: -utf8 -] -controls -whether -empty -matches -that -split -a -/ -/ -/ -Unicode -codepoint -are -reported -or -not -. -/ -/ -/ -/ -/ -/ -Generally -speaking -callers -will -want -to -either -enable -all -of -these -or -/ -/ -/ -disable -all -of -these -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -disable -UTF -- -8 -mode -in -the -syntax -and -the -regex -/ -/ -/ -itself -. -This -is -generally -what -you -want -for -matching -on -arbitrary -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -PikeVM -} -/ -/ -/ -util -: -: -syntax -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -1 -. -. -9 -) -) -; -/ -/ -/ -let -got -= -re -. -find_iter -( -& -mut -cache -haystack -) -. -next -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -Notice -that -( -? -- -u -: -[ -^ -b -] -) -matches -invalid -UTF -- -8 -/ -/ -/ -/ -/ -but -the -subsequent -. -* -does -not -! -Disabling -UTF -- -8 -/ -/ -/ -/ -/ -on -the -syntax -permits -this -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -N -. -B -. -This -example -does -not -show -the -impact -of -/ -/ -/ -/ -/ -disabling -UTF -- -8 -mode -on -a -PikeVM -Config -since -that -/ -/ -/ -/ -/ -only -impacts -regexes -that -can -produce -matches -of -/ -/ -/ -/ -/ -length -0 -. -/ -/ -/ -assert_eq -! -( -b -" -foo -\ -xFFarzz -" -& -haystack -[ -got -. -unwrap -( -) -. -range -( -) -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Builder -{ -config -: -Config -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -} -impl -Builder -{ -/ -/ -/ -Create -a -new -PikeVM -builder -with -its -default -configuration -. -pub -fn -new -( -) -- -> -Builder -{ -Builder -{ -config -: -Config -: -: -default -( -) -# -[ -cfg -( -feature -= -" -syntax -" -) -] -thompson -: -thompson -: -: -Compiler -: -: -new -( -) -} -} -/ -/ -/ -Build -a -PikeVM -from -the -given -pattern -. -/ -/ -/ -/ -/ -/ -If -there -was -a -problem -parsing -or -compiling -the -pattern -then -an -error -/ -/ -/ -is -returned -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build -( -& -self -pattern -: -& -str -) -- -> -Result -< -PikeVM -BuildError -> -{ -self -. -build_many -( -& -[ -pattern -] -) -} -/ -/ -/ -Build -a -PikeVM -from -the -given -patterns -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -build_many -< -P -: -AsRef -< -str -> -> -( -& -self -patterns -: -& -[ -P -] -) -- -> -Result -< -PikeVM -BuildError -> -{ -let -nfa -= -self -. -thompson -. -build_many -( -patterns -) -? -; -self -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Build -a -PikeVM -directly -from -its -NFA -. -/ -/ -/ -/ -/ -/ -Note -that -when -using -this -method -any -configuration -that -applies -to -the -/ -/ -/ -construction -of -the -NFA -itself -will -of -course -be -ignored -since -the -NFA -/ -/ -/ -given -here -is -already -built -. -pub -fn -build_from_nfa -( -& -self -nfa -: -NFA -) -- -> -Result -< -PikeVM -BuildError -> -{ -nfa -. -look_set_any -( -) -. -available -( -) -. -map_err -( -BuildError -: -: -word -) -? -; -Ok -( -PikeVM -{ -config -: -self -. -config -. -clone -( -) -nfa -} -) -} -/ -/ -/ -Apply -the -given -PikeVM -configuration -options -to -this -builder -. -pub -fn -configure -( -& -mut -self -config -: -Config -) -- -> -& -mut -Builder -{ -self -. -config -= -self -. -config -. -overwrite -( -config -) -; -self -} -/ -/ -/ -Set -the -syntax -configuration -for -this -builder -using -/ -/ -/ -[ -syntax -: -: -Config -] -( -crate -: -: -util -: -: -syntax -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -case -insensitivity -Unicode -and -multi -/ -/ -/ -line -mode -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -PikeVM -directly -from -a -/ -/ -/ -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -syntax -( -& -mut -self -config -: -crate -: -: -util -: -: -syntax -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -syntax -( -config -) -; -self -} -/ -/ -/ -Set -the -Thompson -NFA -configuration -for -this -builder -using -/ -/ -/ -[ -nfa -: -: -thompson -: -: -Config -] -( -crate -: -: -nfa -: -: -thompson -: -: -Config -) -. -/ -/ -/ -/ -/ -/ -This -permits -setting -things -like -if -additional -time -should -be -spent -/ -/ -/ -shrinking -the -size -of -the -NFA -. -/ -/ -/ -/ -/ -/ -These -settings -only -apply -when -constructing -a -PikeVM -directly -from -a -/ -/ -/ -pattern -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -thompson -( -& -mut -self -config -: -thompson -: -: -Config -) -- -> -& -mut -Builder -{ -self -. -thompson -. -configure -( -config -) -; -self -} -} -/ -/ -/ -A -virtual -machine -for -executing -regex -searches -with -capturing -groups -. -/ -/ -/ -/ -/ -/ -# -Infallible -APIs -/ -/ -/ -/ -/ -/ -Unlike -most -other -regex -engines -in -this -crate -a -PikeVM -never -returns -an -/ -/ -/ -error -at -search -time -. -It -supports -all -[ -Anchored -] -configurations -never -/ -/ -/ -quits -and -works -on -haystacks -of -arbitrary -length -. -/ -/ -/ -/ -/ -/ -There -are -two -caveats -to -mention -though -: -/ -/ -/ -/ -/ -/ -* -If -an -invalid -pattern -ID -is -given -to -a -search -via -[ -Anchored -: -: -Pattern -] -/ -/ -/ -then -the -PikeVM -will -report -" -no -match -. -" -This -is -consistent -with -all -other -/ -/ -/ -regex -engines -in -this -crate -. -/ -/ -/ -* -When -using -[ -PikeVM -: -: -which_overlapping_matches -] -with -a -[ -PatternSet -] -/ -/ -/ -that -has -insufficient -capacity -to -store -all -valid -pattern -IDs -then -if -a -/ -/ -/ -match -occurs -for -a -PatternID -that -cannot -be -inserted -it -is -silently -/ -/ -/ -dropped -as -if -it -did -not -match -. -/ -/ -/ -/ -/ -/ -# -Advice -/ -/ -/ -/ -/ -/ -The -PikeVM -is -generally -the -most -" -powerful -" -regex -engine -in -this -crate -. -/ -/ -/ -" -Powerful -" -in -this -context -means -that -it -can -handle -any -regular -expression -/ -/ -/ -that -is -parseable -by -regex -- -syntax -and -any -size -haystack -. -Regretably -/ -/ -/ -the -PikeVM -is -also -simultaneously -often -the -_slowest_ -regex -engine -in -/ -/ -/ -practice -. -This -results -in -an -annoying -situation -where -one -generally -tries -/ -/ -/ -to -pick -any -other -regex -engine -( -or -perhaps -none -at -all -) -before -being -/ -/ -/ -forced -to -fall -back -to -a -PikeVM -. -/ -/ -/ -/ -/ -/ -For -example -a -common -strategy -for -dealing -with -capturing -groups -is -to -/ -/ -/ -actually -look -for -the -overall -match -of -the -regex -using -a -faster -regex -/ -/ -/ -engine -like -a -[ -lazy -DFA -] -( -crate -: -: -hybrid -: -: -regex -: -: -Regex -) -. -Once -the -overall -/ -/ -/ -match -is -found -one -can -then -run -the -PikeVM -on -just -the -match -span -to -/ -/ -/ -find -the -spans -of -the -capturing -groups -. -In -this -way -the -faster -regex -/ -/ -/ -engine -does -the -majority -of -the -work -while -the -PikeVM -only -lends -its -/ -/ -/ -power -in -a -more -limited -role -. -/ -/ -/ -/ -/ -/ -Unfortunately -this -isn -' -t -always -possible -because -the -faster -regex -engines -/ -/ -/ -don -' -t -support -all -of -the -regex -features -in -regex -- -syntax -. -This -notably -/ -/ -/ -includes -( -and -is -currently -limited -to -) -Unicode -word -boundaries -. -So -if -/ -/ -/ -your -pattern -has -Unicode -word -boundaries -you -typically -can -' -t -use -a -/ -/ -/ -DFA -- -based -regex -engine -at -all -( -unless -you -[ -enable -heuristic -support -for -/ -/ -/ -it -] -( -crate -: -: -hybrid -: -: -dfa -: -: -Config -: -: -unicode_word_boundary -) -) -. -( -The -[ -one -- -pass -/ -/ -/ -DFA -] -( -crate -: -: -dfa -: -: -onepass -: -: -DFA -) -can -handle -Unicode -word -boundaries -for -/ -/ -/ -anchored -searches -only -but -in -a -cruel -sort -of -joke -many -Unicode -features -/ -/ -/ -tend -to -result -in -making -the -regex -_not_ -one -- -pass -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -PikeVM -implements -Unicode -word -boundaries -/ -/ -/ -correctly -by -default -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -\ -b -\ -w -+ -\ -b -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -re -. -find_iter -( -& -mut -cache -" -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -12 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -13 -. -. -23 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -PikeVM -{ -config -: -Config -nfa -: -NFA -} -impl -PikeVM -{ -/ -/ -/ -Parse -the -given -regular -expression -using -the -default -configuration -and -/ -/ -/ -return -the -corresponding -PikeVM -. -/ -/ -/ -/ -/ -/ -If -you -want -a -non -- -default -configuration -then -use -the -[ -Builder -] -to -/ -/ -/ -set -your -own -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -3 -. -. -14 -) -) -/ -/ -/ -re -. -find_iter -( -& -mut -cache -" -zzzfoo12345barzzz -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new -( -pattern -: -& -str -) -- -> -Result -< -PikeVM -BuildError -> -{ -PikeVM -: -: -builder -( -) -. -build -( -pattern -) -} -/ -/ -/ -Like -new -but -parses -multiple -patterns -into -a -single -" -multi -regex -. -" -/ -/ -/ -This -similarly -uses -the -default -regex -configuration -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -" -[ -a -- -z -] -+ -" -" -[ -0 -- -9 -] -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -re -. -find_iter -( -& -mut -cache -" -abc -1 -foo -4567 -0 -quux -" -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -4 -. -. -5 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -6 -. -. -9 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -10 -. -. -14 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -15 -. -. -16 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -17 -. -. -21 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -new_many -< -P -: -AsRef -< -str -> -> -( -patterns -: -& -[ -P -] -) -- -> -Result -< -PikeVM -BuildError -> -{ -PikeVM -: -: -builder -( -) -. -build_many -( -patterns -) -} -/ -/ -/ -Like -new -but -builds -a -PikeVM -directly -from -an -NFA -. -This -is -useful -/ -/ -/ -if -you -already -have -an -NFA -or -even -if -you -hand -- -assembled -the -NFA -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -hand -assemble -a -regular -expression -via -its -HIR -/ -/ -/ -compile -an -NFA -from -it -and -build -a -PikeVM -from -the -NFA -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -pikevm -: -: -PikeVM -} -Match -} -; -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -{ -Hir -Class -ClassBytes -ClassBytesRange -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new -( -vec -! -[ -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -0 -' -b -' -9 -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -A -' -b -' -Z -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -_ -' -b -' -_ -' -) -/ -/ -/ -ClassBytesRange -: -: -new -( -b -' -a -' -b -' -z -' -) -/ -/ -/ -] -) -) -) -; -/ -/ -/ -/ -/ -/ -let -config -= -NFA -: -: -config -( -) -. -nfa_size_limit -( -Some -( -1_000 -) -) -; -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config -) -. -build_from_hir -( -& -hir -) -? -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_from_nfa -( -nfa -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -3 -. -. -4 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -" -! -# -A -# -! -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new_from_nfa -( -nfa -: -NFA -) -- -> -Result -< -PikeVM -BuildError -> -{ -PikeVM -: -: -builder -( -) -. -build_from_nfa -( -nfa -) -} -/ -/ -/ -Create -a -new -PikeVM -that -matches -every -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -always_match -( -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Match -: -: -must -( -0 -0 -. -. -0 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -re -. -find_iter -( -& -mut -cache -" -" -) -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -re -. -find_iter -( -& -mut -cache -" -foo -" -) -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -always_match -( -) -- -> -Result -< -PikeVM -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -always_match -( -) -; -PikeVM -: -: -new_from_nfa -( -nfa -) -} -/ -/ -/ -Create -a -new -PikeVM -that -never -matches -any -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -never_match -( -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -None -re -. -find_iter -( -& -mut -cache -" -" -) -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -find_iter -( -& -mut -cache -" -foo -" -) -. -next -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -never_match -( -) -- -> -Result -< -PikeVM -BuildError -> -{ -let -nfa -= -thompson -: -: -NFA -: -: -never_match -( -) -; -PikeVM -: -: -new_from_nfa -( -nfa -) -} -/ -/ -/ -Return -a -default -configuration -for -a -PikeVM -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -Config -/ -/ -/ -type -when -customizing -the -construction -of -a -PikeVM -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -disable -UTF -- -8 -mode -. -When -UTF -- -8 -mode -is -/ -/ -/ -disabled -zero -- -width -matches -that -split -a -codepoint -are -allowed -. -/ -/ -/ -Otherwise -they -are -never -reported -. -/ -/ -/ -/ -/ -/ -In -the -code -below -notice -that -" -" -is -permitted -to -match -positions -/ -/ -/ -that -split -the -encoding -of -a -codepoint -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -PikeVM -} -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -a -z -" -; -/ -/ -/ -let -mut -it -= -re -. -find_iter -( -& -mut -cache -haystack -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -0 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -1 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -2 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -3 -. -. -3 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -4 -. -. -4 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -5 -. -. -5 -) -) -it -. -next -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -config -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -/ -/ -/ -Return -a -builder -for -configuring -the -construction -of -a -PikeVM -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -to -avoid -needing -to -import -the -/ -/ -/ -[ -Builder -] -type -in -common -cases -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -the -builder -to -disable -UTF -- -8 -mode -/ -/ -/ -everywhere -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -PikeVM -} -/ -/ -/ -util -: -: -syntax -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -syntax -( -syntax -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -r -" -foo -( -? -- -u -: -[ -^ -b -] -) -ar -. -* -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -b -" -\ -xFEfoo -\ -xFFarzz -\ -xE2 -\ -x98 -\ -xFF -\ -n -" -; -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -1 -. -. -9 -) -) -; -/ -/ -/ -re -. -captures -( -& -mut -cache -haystack -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -builder -( -) -- -> -Builder -{ -Builder -: -: -new -( -) -} -/ -/ -/ -Create -a -new -empty -set -of -capturing -groups -that -is -guaranteed -to -be -/ -/ -/ -valid -for -the -search -APIs -on -this -PikeVM -. -/ -/ -/ -/ -/ -/ -A -Captures -value -created -for -a -specific -PikeVM -cannot -be -used -with -/ -/ -/ -any -other -PikeVM -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -function -for -[ -Captures -: -: -all -] -. -See -the -/ -/ -/ -[ -Captures -] -documentation -for -an -explanation -of -its -alternative -/ -/ -/ -constructors -that -permit -the -PikeVM -to -do -less -work -during -a -search -/ -/ -/ -and -thus -might -make -it -faster -. -pub -fn -create_captures -( -& -self -) -- -> -Captures -{ -Captures -: -: -all -( -self -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -} -/ -/ -/ -Create -a -new -cache -for -this -PikeVM -. -/ -/ -/ -/ -/ -/ -The -cache -returned -should -only -be -used -for -searches -for -this -/ -/ -/ -PikeVM -. -If -you -want -to -reuse -the -cache -for -another -PikeVM -then -/ -/ -/ -you -must -call -[ -Cache -: -: -reset -] -with -that -PikeVM -( -or -equivalently -/ -/ -/ -[ -PikeVM -: -: -reset_cache -] -) -. -pub -fn -create_cache -( -& -self -) -- -> -Cache -{ -Cache -: -: -new -( -self -) -} -/ -/ -/ -Reset -the -given -cache -such -that -it -can -be -used -for -searching -with -the -/ -/ -/ -this -PikeVM -( -and -only -this -PikeVM -) -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -PikeVM -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -PikeVM -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -PikeVM -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -PikeVM -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -/ -/ -/ -re1 -. -find_iter -( -& -mut -cache -" -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -PikeVM -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -re2 -. -reset_cache -( -& -mut -cache -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -/ -/ -/ -re2 -. -find_iter -( -& -mut -cache -" -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset_cache -( -& -self -cache -: -& -mut -Cache -) -{ -cache -. -reset -( -self -) -; -} -/ -/ -/ -Returns -the -total -number -of -patterns -compiled -into -this -PikeVM -. -/ -/ -/ -/ -/ -/ -In -the -case -of -a -PikeVM -that -contains -no -patterns -this -returns -0 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -pattern -length -for -a -PikeVM -that -never -/ -/ -/ -matches -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -never_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -re -. -pattern_len -( -) -0 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -another -example -for -a -PikeVM -that -matches -at -every -position -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -always_match -( -) -? -; -/ -/ -/ -assert_eq -! -( -re -. -pattern_len -( -) -1 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -And -finally -a -PikeVM -that -was -constructed -from -multiple -patterns -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -re -. -pattern_len -( -) -3 -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -nfa -. -pattern_len -( -) -} -/ -/ -/ -Return -the -config -for -this -PikeVM -. -# -[ -inline -] -pub -fn -get_config -( -& -self -) -- -> -& -Config -{ -& -self -. -config -} -/ -/ -/ -Returns -a -reference -to -the -underlying -NFA -. -# -[ -inline -] -pub -fn -get_nfa -( -& -self -) -- -> -& -NFA -{ -& -self -. -nfa -} -} -impl -PikeVM -{ -/ -/ -/ -Returns -true -if -and -only -if -this -PikeVM -matches -the -given -haystack -. -/ -/ -/ -/ -/ -/ -This -routine -may -short -circuit -if -it -knows -that -scanning -future -/ -/ -/ -input -will -never -lead -to -a -different -result -. -In -particular -if -the -/ -/ -/ -underlying -NFA -enters -a -match -state -then -this -routine -will -return -/ -/ -/ -true -immediately -without -inspecting -any -future -input -. -( -Consider -how -/ -/ -/ -this -might -make -a -difference -given -the -regex -a -+ -on -the -haystack -/ -/ -/ -aaaaaaaaaaaaaaa -. -This -routine -can -stop -after -it -sees -the -first -a -/ -/ -/ -but -routines -like -find -need -to -continue -searching -because -+ -is -/ -/ -/ -greedy -by -default -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -& -mut -cache -" -foo12345bar -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -& -mut -cache -" -foobar -" -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -consistency -with -search -APIs -/ -/ -/ -/ -/ -/ -is_match -is -guaranteed -to -return -true -whenever -find -returns -a -/ -/ -/ -match -. -This -includes -searches -that -are -executed -entirely -within -a -/ -/ -/ -codepoint -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -a -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -! -re -. -is_match -( -& -mut -cache -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -when -UTF -- -8 -mode -is -disabled -then -the -above -reports -a -/ -/ -/ -match -because -the -restriction -against -zero -- -width -matches -that -split -a -/ -/ -/ -codepoint -has -been -lifted -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -pikevm -: -: -PikeVM -NFA -} -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -NFA -: -: -config -( -) -. -utf8 -( -false -) -) -/ -/ -/ -. -build -( -" -a -* -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -re -. -is_match -( -& -mut -cache -Input -: -: -new -( -" -" -) -. -span -( -1 -. -. -2 -) -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -) -- -> -bool -{ -let -input -= -input -. -into -( -) -. -earliest -( -true -) -; -self -. -search_slots -( -cache -& -input -& -mut -[ -] -) -. -is_some -( -) -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -returns -a -Match -if -one -exists -. -/ -/ -/ -/ -/ -/ -This -routine -only -includes -the -overall -match -span -. -To -get -access -to -the -/ -/ -/ -individual -spans -of -each -capturing -group -use -[ -PikeVM -: -: -captures -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Leftmost -first -match -semantics -corresponds -to -the -match -with -the -/ -/ -/ -smallest -starting -offset -but -where -the -end -offset -is -determined -by -/ -/ -/ -preferring -earlier -branches -in -the -original -regular -expression -. -For -/ -/ -/ -example -Sam -| -Samwise -will -match -Sam -in -Samwise -but -Samwise -| -Sam -/ -/ -/ -will -match -Samwise -in -Samwise -. -/ -/ -/ -/ -/ -/ -Generally -speaking -the -" -leftmost -first -" -match -is -how -most -backtracking -/ -/ -/ -regular -expressions -tend -to -work -. -This -is -in -contrast -to -POSIX -- -style -/ -/ -/ -regular -expressions -that -yield -" -leftmost -longest -" -matches -. -Namely -/ -/ -/ -both -Sam -| -Samwise -and -Samwise -| -Sam -match -Samwise -when -using -/ -/ -/ -leftmost -longest -semantics -. -( -This -crate -does -not -currently -support -/ -/ -/ -leftmost -longest -semantics -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -Match -: -: -must -( -0 -0 -. -. -8 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -re -. -find -( -& -mut -cache -" -foo12345 -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Even -though -a -match -is -found -after -reading -the -first -byte -( -a -) -/ -/ -/ -/ -/ -the -leftmost -first -match -semantics -demand -that -we -find -the -earliest -/ -/ -/ -/ -/ -match -that -prefers -earlier -parts -of -the -pattern -over -later -parts -. -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -abc -| -a -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -expected -= -Match -: -: -must -( -0 -0 -. -. -3 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -expected -) -re -. -find -( -& -mut -cache -" -abc -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -) -- -> -Option -< -Match -> -{ -let -input -= -input -. -into -( -) -; -if -self -. -get_nfa -( -) -. -pattern_len -( -) -= -= -1 -{ -let -mut -slots -= -[ -None -None -] -; -let -pid -= -self -. -search_slots -( -cache -& -input -& -mut -slots -) -? -; -let -start -= -slots -[ -0 -] -? -. -get -( -) -; -let -end -= -slots -[ -1 -] -? -. -get -( -) -; -return -Some -( -Match -: -: -new -( -pid -Span -{ -start -end -} -) -) -; -} -let -ginfo -= -self -. -get_nfa -( -) -. -group_info -( -) -; -let -slots_len -= -ginfo -. -implicit_slot_len -( -) -; -let -mut -slots -= -vec -! -[ -None -; -slots_len -] -; -let -pid -= -self -. -search_slots -( -cache -& -input -& -mut -slots -) -? -; -let -start -= -slots -[ -pid -. -as_usize -( -) -* -2 -] -? -. -get -( -) -; -let -end -= -slots -[ -pid -. -as_usize -( -) -* -2 -+ -1 -] -? -. -get -( -) -; -Some -( -Match -: -: -new -( -pid -Span -{ -start -end -} -) -) -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -[ -Captures -] -/ -/ -/ -value -. -If -no -match -was -found -then -[ -Captures -: -: -is_match -] -is -guaranteed -/ -/ -/ -to -return -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -^ -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -2010 -- -03 -- -14 -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -4 -) -) -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -5 -. -. -7 -) -) -caps -. -get_group -( -2 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -8 -. -. -10 -) -) -caps -. -get_group -( -3 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -captures -< -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -self -cache -: -& -mut -Cache -input -: -I -caps -: -& -mut -Captures -) -{ -self -. -search -( -cache -& -input -. -into -( -) -caps -) -} -/ -/ -/ -Returns -an -iterator -over -all -non -- -overlapping -leftmost -matches -in -the -/ -/ -/ -given -bytes -. -If -no -match -exists -then -the -iterator -yields -no -elements -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -text -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -let -matches -: -Vec -< -Match -> -= -re -. -find_iter -( -& -mut -cache -text -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Match -: -: -must -( -0 -0 -. -. -4 -) -/ -/ -/ -Match -: -: -must -( -0 -5 -. -. -10 -) -/ -/ -/ -Match -: -: -must -( -0 -11 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find_iter -< -' -r -' -c -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -cache -: -& -' -c -mut -Cache -input -: -I -) -- -> -FindMatches -< -' -r -' -c -' -h -> -{ -let -caps -= -Captures -: -: -matches -( -self -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -; -let -it -= -iter -: -: -Searcher -: -: -new -( -input -. -into -( -) -) -; -FindMatches -{ -re -: -self -cache -caps -it -} -} -/ -/ -/ -Returns -an -iterator -over -all -non -- -overlapping -Captures -values -. -If -no -/ -/ -/ -match -exists -then -the -iterator -yields -no -elements -. -/ -/ -/ -/ -/ -/ -This -yields -the -same -matches -as -[ -PikeVM -: -: -find_iter -] -but -it -includes -/ -/ -/ -the -spans -of -all -capturing -groups -that -participate -in -each -match -. -/ -/ -/ -/ -/ -/ -* -* -Tip -: -* -* -See -[ -util -: -: -iter -: -: -Searcher -] -( -crate -: -: -util -: -: -iter -: -: -Searcher -) -for -/ -/ -/ -how -to -correctly -iterate -over -all -matches -in -a -haystack -while -avoiding -/ -/ -/ -the -creation -of -a -new -Captures -value -for -every -match -. -( -Which -you -are -/ -/ -/ -forced -to -do -with -an -Iterator -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -foo -( -? -P -< -numbers -> -[ -0 -- -9 -] -+ -) -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -text -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -let -matches -: -Vec -< -Span -> -= -re -/ -/ -/ -. -captures_iter -( -& -mut -cache -text -) -/ -/ -/ -/ -/ -The -unwrap -is -OK -since -' -numbers -' -matches -if -the -pattern -matches -. -/ -/ -/ -. -map -( -| -caps -| -caps -. -get_group_by_name -( -" -numbers -" -) -. -unwrap -( -) -) -/ -/ -/ -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Span -: -: -from -( -3 -. -. -4 -) -/ -/ -/ -Span -: -: -from -( -8 -. -. -10 -) -/ -/ -/ -Span -: -: -from -( -14 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -captures_iter -< -' -r -' -c -' -h -I -: -Into -< -Input -< -' -h -> -> -> -( -& -' -r -self -cache -: -& -' -c -mut -Cache -input -: -I -) -- -> -CapturesMatches -< -' -r -' -c -' -h -> -{ -let -caps -= -self -. -create_captures -( -) -; -let -it -= -iter -: -: -Searcher -: -: -new -( -input -. -into -( -) -) -; -CapturesMatches -{ -re -: -self -cache -caps -it -} -} -} -impl -PikeVM -{ -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -[ -Captures -] -/ -/ -/ -value -. -If -no -match -was -found -then -[ -Captures -: -: -is_match -] -is -guaranteed -/ -/ -/ -to -return -false -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -PikeVM -: -: -captures -] -but -it -accepts -a -concrete -& -Input -/ -/ -/ -instead -of -an -Into -< -Input -> -. -/ -/ -/ -/ -/ -/ -# -Example -: -specific -pattern -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -multi -- -PikeVM -that -permits -searching -/ -/ -/ -for -specific -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -Anchored -Match -PatternID -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -" -[ -a -- -z0 -- -9 -] -{ -6 -} -" -" -[ -a -- -z -] -[ -a -- -z0 -- -9 -] -{ -5 -} -" -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -foo123 -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -are -using -the -default -leftmost -- -first -match -and -both -/ -/ -/ -/ -/ -patterns -match -at -the -same -starting -position -only -the -first -pattern -/ -/ -/ -/ -/ -will -be -returned -in -this -case -when -doing -a -search -for -any -of -the -/ -/ -/ -/ -/ -patterns -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -6 -) -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -Input -: -: -new -( -haystack -) -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -want -to -check -whether -some -other -pattern -matches -then -we -/ -/ -/ -/ -/ -can -provide -its -pattern -ID -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -1 -0 -. -. -6 -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -specifying -the -bounds -of -a -search -/ -/ -/ -/ -/ -/ -This -example -shows -how -providing -the -bounds -of -a -search -can -produce -/ -/ -/ -different -results -than -simply -sub -- -slicing -the -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -\ -b -[ -0 -- -9 -] -{ -3 -} -\ -b -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -haystack -= -" -foo123bar -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Since -we -sub -- -slice -the -haystack -the -search -doesn -' -t -know -about -/ -/ -/ -/ -/ -the -larger -context -and -assumes -that -123 -is -surrounded -by -word -/ -/ -/ -/ -/ -boundaries -. -And -of -course -the -match -position -is -reported -relative -/ -/ -/ -/ -/ -to -the -sub -- -slice -as -well -which -means -we -get -0 -. -. -3 -instead -of -/ -/ -/ -/ -/ -3 -. -. -6 -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -[ -3 -. -. -6 -] -) -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -provide -the -bounds -of -the -search -within -the -context -of -the -/ -/ -/ -/ -/ -entire -haystack -then -the -search -can -take -the -surrounding -context -/ -/ -/ -/ -/ -into -account -. -( -And -if -we -did -find -a -match -it -would -be -reported -/ -/ -/ -/ -/ -as -a -valid -offset -into -haystack -instead -of -its -sub -- -slice -. -) -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -range -( -3 -. -. -6 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -caps -: -& -mut -Captures -) -{ -caps -. -set_pattern -( -None -) -; -let -pid -= -self -. -search_slots -( -cache -input -caps -. -slots_mut -( -) -) -; -caps -. -set_pattern -( -pid -) -; -} -/ -/ -/ -Executes -a -leftmost -forward -search -and -writes -the -spans -of -capturing -/ -/ -/ -groups -that -participated -in -a -match -into -the -provided -slots -and -/ -/ -/ -returns -the -matching -pattern -ID -. -The -contents -of -the -slots -for -patterns -/ -/ -/ -other -than -the -matching -pattern -are -unspecified -. -If -no -match -was -found -/ -/ -/ -then -None -is -returned -and -the -contents -of -slots -is -unspecified -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -PikeVM -: -: -search -] -but -it -accepts -a -raw -slots -slice -/ -/ -/ -instead -of -a -Captures -value -. -This -is -useful -in -contexts -where -you -/ -/ -/ -don -' -t -want -or -need -to -allocate -a -Captures -. -/ -/ -/ -/ -/ -/ -It -is -legal -to -pass -_any_ -number -of -slots -to -this -routine -. -If -the -regex -/ -/ -/ -engine -would -otherwise -write -a -slot -offset -that -doesn -' -t -fit -in -the -/ -/ -/ -provided -slice -then -it -is -simply -skipped -. -In -general -though -there -are -/ -/ -/ -usually -three -slice -lengths -you -might -want -to -use -: -/ -/ -/ -/ -/ -/ -* -An -empty -slice -if -you -only -care -about -which -pattern -matched -. -/ -/ -/ -* -A -slice -with -/ -/ -/ -[ -pattern_len -( -) -* -2 -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -: -: -pattern_len -) -/ -/ -/ -slots -if -you -only -care -about -the -overall -match -spans -for -each -matching -/ -/ -/ -pattern -. -/ -/ -/ -* -A -slice -with -/ -/ -/ -[ -slot_len -( -) -] -( -crate -: -: -util -: -: -captures -: -: -GroupInfo -: -: -slot_len -) -slots -which -/ -/ -/ -permits -recording -match -offsets -for -every -capturing -group -in -every -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -the -overall -match -offsets -in -a -/ -/ -/ -multi -- -pattern -search -without -allocating -a -Captures -value -. -Indeed -we -/ -/ -/ -can -put -our -slots -right -on -the -stack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -PatternID -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -\ -pL -+ -" -/ -/ -/ -r -" -\ -d -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -! -# -123 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -only -care -about -the -overall -match -offsets -here -so -we -just -/ -/ -/ -/ -/ -allocate -two -slots -for -each -pattern -. -Each -slot -records -the -start -/ -/ -/ -/ -/ -and -end -of -the -match -. -/ -/ -/ -let -mut -slots -= -[ -None -; -4 -] -; -/ -/ -/ -let -pid -= -re -. -search_slots -( -& -mut -cache -& -input -& -mut -slots -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -pid -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -overall -match -offsets -are -always -at -' -pid -* -2 -' -and -' -pid -* -2 -+ -1 -' -. -/ -/ -/ -/ -/ -See -' -GroupInfo -' -for -more -details -on -the -mapping -between -groups -and -/ -/ -/ -/ -/ -slot -indices -. -/ -/ -/ -let -slot_start -= -pid -. -unwrap -( -) -. -as_usize -( -) -* -2 -; -/ -/ -/ -let -slot_end -= -slot_start -+ -1 -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -slots -[ -slot_start -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -6 -) -slots -[ -slot_end -] -. -map -( -| -s -| -s -. -get -( -) -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -search_slots -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -if -! -utf8empty -{ -let -hm -= -self -. -search_slots_imp -( -cache -input -slots -) -? -; -return -Some -( -hm -. -pattern -( -) -) -; -} -/ -/ -There -is -an -unfortunate -special -case -where -if -the -regex -can -/ -/ -match -the -empty -string -and -UTF -- -8 -mode -is -enabled -the -search -/ -/ -implementation -requires -that -the -slots -have -at -least -as -much -space -/ -/ -to -report -the -bounds -of -any -match -. -This -is -so -zero -- -width -matches -/ -/ -that -split -a -codepoint -can -be -filtered -out -. -/ -/ -/ -/ -Note -that -if -utf8empty -is -true -we -specialize -the -case -for -when -/ -/ -the -number -of -patterns -is -1 -. -In -that -case -we -can -just -use -a -stack -/ -/ -allocation -. -Otherwise -we -resort -to -a -heap -allocation -which -we -/ -/ -convince -ourselves -we -' -re -fine -with -due -to -the -pathological -nature -of -/ -/ -this -case -. -let -min -= -self -. -get_nfa -( -) -. -group_info -( -) -. -implicit_slot_len -( -) -; -if -slots -. -len -( -) -> -= -min -{ -let -hm -= -self -. -search_slots_imp -( -cache -input -slots -) -? -; -return -Some -( -hm -. -pattern -( -) -) -; -} -if -self -. -get_nfa -( -) -. -pattern_len -( -) -= -= -1 -{ -let -mut -enough -= -[ -None -None -] -; -let -got -= -self -. -search_slots_imp -( -cache -input -& -mut -enough -) -; -/ -/ -This -is -OK -because -we -know -enough -is -strictly -bigger -than -/ -/ -slots -otherwise -this -special -case -isn -' -t -reached -. -slots -. -copy_from_slice -( -& -enough -[ -. -. -slots -. -len -( -) -] -) -; -return -got -. -map -( -| -hm -| -hm -. -pattern -( -) -) -; -} -let -mut -enough -= -vec -! -[ -None -; -min -] -; -let -got -= -self -. -search_slots_imp -( -cache -input -& -mut -enough -) -; -/ -/ -This -is -OK -because -we -know -enough -is -strictly -bigger -than -slots -/ -/ -otherwise -this -special -case -isn -' -t -reached -. -slots -. -copy_from_slice -( -& -enough -[ -. -. -slots -. -len -( -) -] -) -; -got -. -map -( -| -hm -| -hm -. -pattern -( -) -) -} -/ -/ -/ -This -is -the -actual -implementation -of -search_slots_imp -that -/ -/ -/ -doesn -' -t -account -for -the -special -case -when -1 -) -the -NFA -has -UTF -- -8 -mode -/ -/ -/ -enabled -2 -) -the -NFA -can -match -the -empty -string -and -3 -) -the -caller -has -/ -/ -/ -provided -an -insufficient -number -of -slots -to -record -match -offsets -. -# -[ -inline -( -never -) -] -fn -search_slots_imp -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -HalfMatch -> -{ -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -let -hm -= -match -self -. -search_imp -( -cache -input -slots -) -{ -None -= -> -return -None -Some -( -hm -) -if -! -utf8empty -= -> -return -Some -( -hm -) -Some -( -hm -) -= -> -hm -} -; -empty -: -: -skip_splits_fwd -( -input -hm -hm -. -offset -( -) -| -input -| -{ -Ok -( -self -. -search_imp -( -cache -input -slots -) -. -map -( -| -hm -| -( -hm -hm -. -offset -( -) -) -) -) -} -) -/ -/ -OK -because -the -PikeVM -never -errors -. -. -unwrap -( -) -} -/ -/ -/ -Writes -the -set -of -patterns -that -match -anywhere -in -the -given -search -/ -/ -/ -configuration -to -patset -. -If -multiple -patterns -match -at -the -same -/ -/ -/ -position -and -this -PikeVM -was -configured -with -[ -MatchKind -: -: -All -] -/ -/ -/ -semantics -then -all -matching -patterns -are -written -to -the -given -set -. -/ -/ -/ -/ -/ -/ -Unless -all -of -the -patterns -in -this -PikeVM -are -anchored -then -/ -/ -/ -generally -speaking -this -will -visit -every -byte -in -the -haystack -. -/ -/ -/ -/ -/ -/ -This -search -routine -* -does -not -* -clear -the -pattern -set -. -This -gives -some -/ -/ -/ -flexibility -to -the -caller -( -e -. -g -. -running -multiple -searches -with -the -/ -/ -/ -same -pattern -set -) -but -does -make -the -API -bug -- -prone -if -you -' -re -reusing -/ -/ -/ -the -same -pattern -set -for -multiple -searches -but -intended -them -to -be -/ -/ -/ -independent -. -/ -/ -/ -/ -/ -/ -If -a -pattern -ID -matched -but -the -given -PatternSet -does -not -have -/ -/ -/ -sufficient -capacity -to -store -it -then -it -is -not -inserted -and -silently -/ -/ -/ -dropped -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -all -matching -patterns -in -a -haystack -/ -/ -/ -even -when -some -patterns -match -at -the -same -position -as -other -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -Input -MatchKind -PatternSet -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -/ -/ -/ -r -" -\ -w -+ -" -r -" -\ -d -+ -" -r -" -\ -pL -+ -" -r -" -foo -" -r -" -bar -" -r -" -barfoo -" -r -" -foobar -" -/ -/ -/ -] -; -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -configure -( -PikeVM -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build_many -( -patterns -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -let -mut -patset -= -PatternSet -: -: -new -( -re -. -pattern_len -( -) -) -; -/ -/ -/ -re -. -which_overlapping_matches -( -& -mut -cache -& -input -& -mut -patset -) -; -/ -/ -/ -let -expected -= -vec -! -[ -0 -2 -3 -4 -6 -] -; -/ -/ -/ -let -got -: -Vec -< -usize -> -= -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -which_overlapping_matches -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -self -. -which_overlapping_imp -( -cache -input -patset -) -} -} -impl -PikeVM -{ -/ -/ -/ -The -implementation -of -standard -leftmost -search -. -/ -/ -/ -/ -/ -/ -Capturing -group -spans -are -written -to -slots -but -only -if -requested -. -/ -/ -/ -slots -can -be -any -length -. -Any -slot -in -the -NFA -that -is -activated -but -/ -/ -/ -which -is -out -of -bounds -for -the -given -slots -is -ignored -. -fn -search_imp -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -HalfMatch -> -{ -cache -. -setup_search -( -slots -. -len -( -) -) -; -if -input -. -is_done -( -) -{ -return -None -; -} -/ -/ -Why -do -we -even -care -about -this -? -Well -in -our -' -Captures -' -/ -/ -representation -we -use -usize -: -: -MAX -as -a -sentinel -to -indicate -" -no -/ -/ -match -. -" -This -isn -' -t -problematic -so -long -as -our -haystack -doesn -' -t -have -/ -/ -a -maximal -length -. -Byte -slices -are -guaranteed -by -Rust -to -have -a -/ -/ -length -that -fits -into -isize -and -so -this -assert -should -always -pass -. -/ -/ -But -we -put -it -here -to -make -our -assumption -explicit -. -assert -! -( -input -. -haystack -( -) -. -len -( -) -< -core -: -: -usize -: -: -MAX -" -byte -slice -lengths -must -be -less -than -usize -MAX -" -) -; -instrument -! -( -| -c -| -c -. -reset -( -& -self -. -nfa -) -) -; -/ -/ -Whether -we -want -to -visit -all -match -states -instead -of -emulating -the -/ -/ -' -leftmost -' -semantics -of -typical -backtracking -regex -engines -. -let -allmatches -= -self -. -config -. -get_match_kind -( -) -. -continue_past_first_match -( -) -; -let -( -anchored -start_id -) -= -match -self -. -start_config -( -input -) -{ -None -= -> -return -None -Some -( -config -) -= -> -config -} -; -let -pre -= -if -anchored -{ -None -} -else -{ -self -. -get_config -( -) -. -get_prefilter -( -) -} -; -let -Cache -{ -ref -mut -stack -ref -mut -curr -ref -mut -next -} -= -cache -; -let -mut -hm -= -None -; -/ -/ -Yes -our -search -doesn -' -t -end -at -input -. -end -( -) -but -includes -it -. -This -/ -/ -is -necessary -because -matches -are -delayed -by -one -byte -just -like -/ -/ -how -the -DFA -engines -work -. -The -delay -is -used -to -handle -look -- -behind -/ -/ -assertions -. -In -the -case -of -the -PikeVM -the -delay -is -implemented -/ -/ -by -not -considering -a -match -to -exist -until -it -is -visited -in -/ -/ -' -steps -' -. -Technically -we -know -a -match -exists -in -the -previous -/ -/ -iteration -via -' -epsilon_closure -' -. -( -It -' -s -the -same -thing -in -NFA -- -to -- -DFA -/ -/ -determinization -. -We -don -' -t -mark -a -DFA -state -as -a -match -state -if -it -/ -/ -contains -an -NFA -match -state -but -rather -whether -the -DFA -state -was -/ -/ -generated -by -a -transition -from -a -DFA -state -that -contains -an -NFA -/ -/ -match -state -. -) -let -mut -at -= -input -. -start -( -) -; -while -at -< -= -input -. -end -( -) -{ -/ -/ -If -we -have -no -states -left -to -visit -then -there -are -some -cases -/ -/ -where -we -know -we -can -quit -early -or -even -skip -ahead -. -if -curr -. -set -. -is_empty -( -) -{ -/ -/ -We -have -a -match -and -we -haven -' -t -been -instructed -to -continue -/ -/ -on -even -after -finding -a -match -so -we -can -quit -. -if -hm -. -is_some -( -) -& -& -! -allmatches -{ -break -; -} -/ -/ -If -we -' -re -running -an -anchored -search -and -we -' -ve -advanced -/ -/ -beyond -the -start -position -with -no -other -states -to -try -then -/ -/ -we -will -never -observe -a -match -and -thus -can -stop -. -if -anchored -& -& -at -> -input -. -start -( -) -{ -break -; -} -/ -/ -If -there -no -states -left -to -explore -at -this -position -and -we -/ -/ -know -we -can -' -t -terminate -early -then -we -are -effectively -at -/ -/ -the -starting -state -of -the -NFA -. -If -we -fell -through -here -/ -/ -we -' -d -end -up -adding -our -' -( -? -s -- -u -: -. -) -* -? -' -prefix -and -it -would -be -/ -/ -the -only -thing -in -' -curr -' -. -So -we -might -as -well -just -skip -/ -/ -ahead -until -we -find -something -that -we -know -might -advance -us -/ -/ -forward -. -if -let -Some -( -ref -pre -) -= -pre -{ -let -span -= -Span -: -: -from -( -at -. -. -input -. -end -( -) -) -; -match -pre -. -find -( -input -. -haystack -( -) -span -) -{ -None -= -> -break -Some -( -ref -span -) -= -> -at -= -span -. -start -} -} -} -/ -/ -Instead -of -using -the -NFA -' -s -unanchored -start -state -we -actually -/ -/ -always -use -its -anchored -starting -state -. -As -a -result -when -doing -/ -/ -an -unanchored -search -we -need -to -simulate -our -own -' -( -? -s -- -u -: -. -) -* -? -' -/ -/ -prefix -to -permit -a -match -to -appear -anywhere -. -/ -/ -/ -/ -Now -we -don -' -t -* -have -* -to -do -things -this -way -. -We -could -use -the -/ -/ -NFA -' -s -unanchored -starting -state -and -do -one -' -epsilon_closure -' -/ -/ -call -from -that -starting -state -before -the -main -loop -here -. -And -/ -/ -that -is -just -as -correct -. -However -it -turns -out -to -be -slower -/ -/ -than -our -approach -here -because -it -slightly -increases -the -cost -/ -/ -of -processing -each -byte -by -requiring -us -to -visit -more -NFA -/ -/ -states -to -deal -with -the -additional -NFA -states -in -the -unanchored -/ -/ -prefix -. -By -simulating -it -explicitly -here -we -lower -those -costs -/ -/ -substantially -. -The -cost -is -itself -small -but -it -adds -up -for -/ -/ -large -haystacks -. -/ -/ -/ -/ -In -order -to -simulate -the -' -( -? -s -- -u -: -. -) -* -? -' -prefix -- -- -- -which -is -not -/ -/ -greedy -- -- -- -we -are -careful -not -to -perform -an -epsilon -closure -on -/ -/ -the -start -state -if -we -already -have -a -match -. -Namely -if -we -/ -/ -did -otherwise -we -would -never -reach -a -terminating -condition -/ -/ -because -there -would -always -be -additional -states -to -process -. -/ -/ -In -effect -the -exclusion -of -running -' -epsilon_closure -' -when -/ -/ -we -have -a -match -corresponds -to -the -" -dead -" -states -we -have -in -/ -/ -our -DFA -regex -engines -. -Namely -in -a -DFA -match -states -merely -/ -/ -instruct -the -search -execution -to -record -the -current -offset -as -/ -/ -the -most -recently -seen -match -. -It -is -the -dead -state -that -actually -/ -/ -indicates -when -to -stop -the -search -( -other -than -EOF -or -quit -/ -/ -states -) -. -/ -/ -/ -/ -However -when -' -allmatches -' -is -true -the -caller -has -asked -us -to -/ -/ -leave -in -every -possible -match -state -. -This -tends -not -to -make -a -/ -/ -whole -lot -of -sense -in -unanchored -searches -because -it -means -the -/ -/ -search -really -cannot -terminate -until -EOF -. -And -often -in -that -/ -/ -case -you -wind -up -skipping -over -a -bunch -of -matches -and -are -left -/ -/ -with -the -" -last -" -match -. -Arguably -it -just -doesn -' -t -make -a -lot -of -/ -/ -sense -to -run -a -' -leftmost -' -search -( -which -is -what -this -routine -is -) -/ -/ -with -' -allmatches -' -set -to -true -. -But -the -DFAs -support -it -and -this -/ -/ -matches -their -behavior -. -( -Generally -' -allmatches -' -is -useful -for -/ -/ -overlapping -searches -or -leftmost -anchored -searches -to -find -the -/ -/ -longest -possible -match -by -ignoring -match -priority -. -) -/ -/ -/ -/ -Additionally -when -we -' -re -running -an -anchored -search -this -/ -/ -epsilon -closure -should -only -be -computed -at -the -beginning -of -the -/ -/ -search -. -If -we -re -- -computed -it -at -every -position -we -would -be -/ -/ -simulating -an -unanchored -search -when -we -were -tasked -to -perform -/ -/ -an -anchored -search -. -if -( -! -hm -. -is_some -( -) -| -| -allmatches -) -& -& -( -! -anchored -| -| -at -= -= -input -. -start -( -) -) -{ -/ -/ -Since -we -are -adding -to -the -' -curr -' -active -states -and -since -/ -/ -this -is -for -the -start -ID -we -use -a -slots -slice -that -is -/ -/ -guaranteed -to -have -the -right -length -but -where -every -element -/ -/ -is -absent -. -This -is -exactly -what -we -want -because -this -/ -/ -epsilon -closure -is -responsible -for -simulating -an -unanchored -/ -/ -' -( -? -s -: -. -) -* -? -' -prefix -. -It -is -specifically -outside -of -any -/ -/ -capturing -groups -and -thus -using -slots -that -are -always -/ -/ -absent -is -correct -. -/ -/ -/ -/ -Note -though -that -we -can -' -t -just -use -' -& -mut -[ -] -' -here -since -/ -/ -this -epsilon -closure -may -traverse -through -' -Captures -' -epsilon -/ -/ -transitions -and -thus -must -be -able -to -write -offsets -to -the -/ -/ -slots -given -which -are -later -copied -to -slot -values -in -' -curr -' -. -let -slots -= -next -. -slot_table -. -all_absent -( -) -; -self -. -epsilon_closure -( -stack -slots -curr -input -at -start_id -) -; -} -if -let -Some -( -pid -) -= -self -. -nexts -( -stack -curr -next -input -at -slots -) -{ -hm -= -Some -( -HalfMatch -: -: -new -( -pid -at -) -) -; -} -/ -/ -Unless -the -caller -asked -us -to -return -early -we -need -to -mush -on -/ -/ -to -see -if -we -can -extend -our -match -. -( -But -note -that -' -nexts -' -will -/ -/ -quit -right -after -seeing -a -match -when -match_kind -= -= -LeftmostFirst -/ -/ -as -is -consistent -with -leftmost -- -first -match -priority -. -) -if -input -. -get_earliest -( -) -& -& -hm -. -is_some -( -) -{ -break -; -} -core -: -: -mem -: -: -swap -( -curr -next -) -; -next -. -set -. -clear -( -) -; -at -+ -= -1 -; -} -instrument -! -( -| -c -| -c -. -eprint -( -& -self -. -nfa -) -) -; -hm -} -/ -/ -/ -The -implementation -for -the -' -which_overlapping_matches -' -API -. -Basically -/ -/ -/ -we -do -a -single -scan -through -the -entire -haystack -( -unless -our -regex -/ -/ -/ -or -search -is -anchored -) -and -record -every -pattern -that -matched -. -In -/ -/ -/ -particular -when -MatchKind -: -: -All -is -used -this -supports -overlapping -/ -/ -/ -matches -. -So -if -we -have -the -regexes -' -sam -' -and -' -samwise -' -they -will -/ -/ -/ -* -both -* -be -reported -in -the -pattern -set -when -searching -the -haystack -/ -/ -/ -' -samwise -' -. -fn -which_overlapping_imp -( -& -self -cache -: -& -mut -Cache -input -: -& -Input -< -' -_ -> -patset -: -& -mut -PatternSet -) -{ -/ -/ -NOTE -: -This -is -effectively -a -copy -of -' -search_imp -' -above -but -with -no -/ -/ -captures -support -and -instead -writes -patterns -that -matched -directly -/ -/ -to -' -patset -' -. -See -that -routine -for -better -commentary -about -what -' -s -/ -/ -going -on -in -this -routine -. -We -probably -could -unify -the -routines -using -/ -/ -generics -or -more -helper -routines -but -I -' -m -not -sure -it -' -s -worth -it -. -/ -/ -/ -/ -NOTE -: -We -somewhat -go -out -of -our -way -here -to -support -things -like -/ -/ -' -input -. -get_earliest -( -) -' -and -' -leftmost -- -first -' -match -semantics -. -Neither -/ -/ -of -those -seem -particularly -relevant -to -this -routine -but -they -are -/ -/ -both -supported -by -the -DFA -analogs -of -this -routine -by -construction -/ -/ -and -composition -so -it -seems -like -good -sense -to -have -the -PikeVM -/ -/ -match -that -behavior -. -cache -. -setup_search -( -0 -) -; -if -input -. -is_done -( -) -{ -return -; -} -assert -! -( -input -. -haystack -( -) -. -len -( -) -< -core -: -: -usize -: -: -MAX -" -byte -slice -lengths -must -be -less -than -usize -MAX -" -) -; -instrument -! -( -| -c -| -c -. -reset -( -& -self -. -nfa -) -) -; -let -allmatches -= -self -. -config -. -get_match_kind -( -) -. -continue_past_first_match -( -) -; -let -( -anchored -start_id -) -= -match -self -. -start_config -( -input -) -{ -None -= -> -return -Some -( -config -) -= -> -config -} -; -let -Cache -{ -ref -mut -stack -ref -mut -curr -ref -mut -next -} -= -cache -; -for -at -in -input -. -start -( -) -. -. -= -input -. -end -( -) -{ -let -any_matches -= -! -patset -. -is_empty -( -) -; -if -curr -. -set -. -is_empty -( -) -{ -if -any_matches -& -& -! -allmatches -{ -break -; -} -if -anchored -& -& -at -> -input -. -start -( -) -{ -break -; -} -} -if -! -any_matches -| -| -allmatches -{ -let -slots -= -& -mut -[ -] -; -self -. -epsilon_closure -( -stack -slots -curr -input -at -start_id -) -; -} -self -. -nexts_overlapping -( -stack -curr -next -input -at -patset -) -; -/ -/ -If -we -found -a -match -and -filled -our -set -then -there -is -no -more -/ -/ -additional -info -that -we -can -provide -. -Thus -we -can -quit -. -We -also -/ -/ -quit -if -the -caller -asked -us -to -stop -at -the -earliest -point -that -/ -/ -we -know -a -match -exists -. -if -patset -. -is_full -( -) -| -| -input -. -get_earliest -( -) -{ -break -; -} -core -: -: -mem -: -: -swap -( -curr -next -) -; -next -. -set -. -clear -( -) -; -} -instrument -! -( -| -c -| -c -. -eprint -( -& -self -. -nfa -) -) -; -} -/ -/ -/ -Process -the -active -states -in -' -curr -' -to -find -the -states -( -written -to -/ -/ -/ -' -next -' -) -we -should -process -for -the -next -byte -in -the -haystack -. -/ -/ -/ -/ -/ -/ -' -stack -' -is -used -to -perform -a -depth -first -traversal -of -the -NFA -when -/ -/ -/ -computing -an -epsilon -closure -. -/ -/ -/ -/ -/ -/ -When -a -match -is -found -the -slots -for -that -match -state -( -in -' -curr -' -) -are -/ -/ -/ -copied -to -' -caps -' -. -Moreover -once -a -match -is -seen -processing -for -' -curr -' -/ -/ -/ -stops -( -unless -the -PikeVM -was -configured -with -MatchKind -: -: -All -semantics -) -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -nexts -( -& -self -stack -: -& -mut -Vec -< -FollowEpsilon -> -curr -: -& -mut -ActiveStates -next -: -& -mut -ActiveStates -input -: -& -Input -< -' -_ -> -at -: -usize -slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -) -- -> -Option -< -PatternID -> -{ -instrument -! -( -| -c -| -c -. -record_state_set -( -& -curr -. -set -) -) -; -let -mut -pid -= -None -; -let -ActiveStates -{ -ref -set -ref -mut -slot_table -} -= -* -curr -; -for -sid -in -set -. -iter -( -) -{ -pid -= -match -self -. -next -( -stack -slot_table -next -input -at -sid -) -{ -None -= -> -continue -Some -( -pid -) -= -> -Some -( -pid -) -} -; -slots -. -copy_from_slice -( -slot_table -. -for_state -( -sid -) -) -; -if -! -self -. -config -. -get_match_kind -( -) -. -continue_past_first_match -( -) -{ -break -; -} -} -pid -} -/ -/ -/ -Like -' -nexts -' -but -for -the -overlapping -case -. -This -doesn -' -t -write -any -/ -/ -/ -slots -and -instead -just -writes -which -pattern -matched -in -' -patset -' -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -nexts_overlapping -( -& -self -stack -: -& -mut -Vec -< -FollowEpsilon -> -curr -: -& -mut -ActiveStates -next -: -& -mut -ActiveStates -input -: -& -Input -< -' -_ -> -at -: -usize -patset -: -& -mut -PatternSet -) -{ -instrument -! -( -| -c -| -c -. -record_state_set -( -& -curr -. -set -) -) -; -let -utf8empty -= -self -. -get_nfa -( -) -. -has_empty -( -) -& -& -self -. -get_nfa -( -) -. -is_utf8 -( -) -; -let -ActiveStates -{ -ref -set -ref -mut -slot_table -} -= -* -curr -; -for -sid -in -set -. -iter -( -) -{ -let -pid -= -match -self -. -next -( -stack -slot_table -next -input -at -sid -) -{ -None -= -> -continue -Some -( -pid -) -= -> -pid -} -; -/ -/ -This -handles -the -case -of -finding -a -zero -- -width -match -that -splits -/ -/ -a -codepoint -. -Namely -if -we -' -re -in -UTF -- -8 -mode -AND -we -know -we -can -/ -/ -match -the -empty -string -then -the -only -valid -way -of -getting -to -/ -/ -this -point -with -an -offset -that -splits -a -codepoint -is -when -we -/ -/ -have -an -empty -match -. -Such -matches -in -UTF -- -8 -mode -must -not -be -/ -/ -reported -. -So -we -just -skip -them -here -and -pretend -as -if -we -did -/ -/ -not -see -a -match -. -if -utf8empty -& -& -! -input -. -is_char_boundary -( -at -) -{ -continue -; -} -let -_ -= -patset -. -try_insert -( -pid -) -; -if -! -self -. -config -. -get_match_kind -( -) -. -continue_past_first_match -( -) -{ -break -; -} -} -} -/ -/ -/ -Starting -from -' -sid -' -if -the -position -' -at -' -in -the -' -input -' -haystack -has -a -/ -/ -/ -transition -defined -out -of -' -sid -' -then -add -the -state -transitioned -to -and -/ -/ -/ -its -epsilon -closure -to -the -' -next -' -set -of -states -to -explore -. -/ -/ -/ -/ -/ -/ -' -stack -' -is -used -by -the -epsilon -closure -computation -to -perform -a -depth -/ -/ -/ -first -traversal -of -the -NFA -. -/ -/ -/ -/ -/ -/ -' -curr_slot_table -' -should -be -the -table -of -slots -for -the -current -set -of -/ -/ -/ -states -being -explored -. -If -there -is -a -transition -out -of -' -sid -' -then -/ -/ -/ -sid -' -s -row -in -the -slot -table -is -used -to -perform -the -epsilon -closure -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -next -( -& -self -stack -: -& -mut -Vec -< -FollowEpsilon -> -curr_slot_table -: -& -mut -SlotTable -next -: -& -mut -ActiveStates -input -: -& -Input -< -' -_ -> -at -: -usize -sid -: -StateID -) -- -> -Option -< -PatternID -> -{ -instrument -! -( -| -c -| -c -. -record_step -( -sid -) -) -; -match -* -self -. -nfa -. -state -( -sid -) -{ -State -: -: -Fail -| -State -: -: -Look -{ -. -. -} -| -State -: -: -Union -{ -. -. -} -| -State -: -: -BinaryUnion -{ -. -. -} -| -State -: -: -Capture -{ -. -. -} -= -> -None -State -: -: -ByteRange -{ -ref -trans -} -= -> -{ -if -trans -. -matches -( -input -. -haystack -( -) -at -) -{ -let -slots -= -curr_slot_table -. -for_state -( -sid -) -; -/ -/ -OK -because -' -at -< -= -haystack -. -len -( -) -< -usize -: -: -MAX -' -so -/ -/ -adding -1 -will -never -wrap -. -let -at -= -at -. -wrapping_add -( -1 -) -; -self -. -epsilon_closure -( -stack -slots -next -input -at -trans -. -next -) -; -} -None -} -State -: -: -Sparse -( -ref -sparse -) -= -> -{ -if -let -Some -( -next_sid -) -= -sparse -. -matches -( -input -. -haystack -( -) -at -) -{ -let -slots -= -curr_slot_table -. -for_state -( -sid -) -; -/ -/ -OK -because -' -at -< -= -haystack -. -len -( -) -< -usize -: -: -MAX -' -so -/ -/ -adding -1 -will -never -wrap -. -let -at -= -at -. -wrapping_add -( -1 -) -; -self -. -epsilon_closure -( -stack -slots -next -input -at -next_sid -) -; -} -None -} -State -: -: -Dense -( -ref -dense -) -= -> -{ -if -let -Some -( -next_sid -) -= -dense -. -matches -( -input -. -haystack -( -) -at -) -{ -let -slots -= -curr_slot_table -. -for_state -( -sid -) -; -/ -/ -OK -because -' -at -< -= -haystack -. -len -( -) -< -usize -: -: -MAX -' -so -/ -/ -adding -1 -will -never -wrap -. -let -at -= -at -. -wrapping_add -( -1 -) -; -self -. -epsilon_closure -( -stack -slots -next -input -at -next_sid -) -; -} -None -} -State -: -: -Match -{ -pattern_id -} -= -> -Some -( -pattern_id -) -} -} -/ -/ -/ -Compute -the -epsilon -closure -of -' -sid -' -writing -the -closure -into -' -next -' -/ -/ -/ -while -copying -slot -values -from -' -curr_slots -' -into -corresponding -states -/ -/ -/ -in -' -next -' -. -' -curr_slots -' -should -be -the -slot -values -corresponding -to -/ -/ -/ -' -sid -' -. -/ -/ -/ -/ -/ -/ -The -given -' -stack -' -is -used -to -perform -a -depth -first -traversal -of -the -/ -/ -/ -NFA -by -recursively -following -all -epsilon -transitions -out -of -' -sid -' -. -/ -/ -/ -Conditional -epsilon -transitions -are -followed -if -and -only -if -they -are -/ -/ -/ -satisfied -for -the -position -' -at -' -in -the -' -input -' -haystack -. -/ -/ -/ -/ -/ -/ -While -this -routine -may -write -to -' -curr_slots -' -once -it -returns -any -/ -/ -/ -writes -are -undone -and -the -original -values -( -even -if -absent -) -are -/ -/ -/ -restored -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -epsilon_closure -( -& -self -stack -: -& -mut -Vec -< -FollowEpsilon -> -curr_slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -next -: -& -mut -ActiveStates -input -: -& -Input -< -' -_ -> -at -: -usize -sid -: -StateID -) -{ -instrument -! -( -| -c -| -{ -c -. -record_closure -( -sid -) -; -c -. -record_stack_push -( -sid -) -; -} -) -; -stack -. -push -( -FollowEpsilon -: -: -Explore -( -sid -) -) -; -while -let -Some -( -frame -) -= -stack -. -pop -( -) -{ -match -frame -{ -FollowEpsilon -: -: -RestoreCapture -{ -slot -offset -: -pos -} -= -> -{ -curr_slots -[ -slot -] -= -pos -; -} -FollowEpsilon -: -: -Explore -( -sid -) -= -> -{ -self -. -epsilon_closure_explore -( -stack -curr_slots -next -input -at -sid -) -; -} -} -} -} -/ -/ -/ -Explore -all -of -the -epsilon -transitions -out -of -' -sid -' -. -This -is -mostly -/ -/ -/ -split -out -from -' -epsilon_closure -' -in -order -to -clearly -delineate -/ -/ -/ -the -actual -work -of -computing -an -epsilon -closure -from -the -stack -/ -/ -/ -book -- -keeping -. -/ -/ -/ -/ -/ -/ -This -will -push -any -additional -explorations -needed -on -to -' -stack -' -. -/ -/ -/ -/ -/ -/ -' -curr_slots -' -should -refer -to -the -slots -for -the -currently -active -NFA -/ -/ -/ -state -. -That -is -the -current -state -we -are -stepping -through -. -These -/ -/ -/ -slots -are -mutated -in -place -as -new -' -Captures -' -states -are -traversed -/ -/ -/ -during -epsilon -closure -but -the -slots -are -restored -to -their -original -/ -/ -/ -values -once -the -full -epsilon -closure -is -completed -. -The -ultimate -use -of -/ -/ -/ -' -curr_slots -' -is -to -copy -them -to -the -corresponding -' -next_slots -' -so -that -/ -/ -/ -the -capturing -group -spans -are -forwarded -from -the -currently -active -state -/ -/ -/ -to -the -next -. -/ -/ -/ -/ -/ -/ -' -next -' -refers -to -the -next -set -of -active -states -. -Computing -an -epsilon -/ -/ -/ -closure -may -increase -the -next -set -of -active -states -. -/ -/ -/ -/ -/ -/ -' -input -' -refers -to -the -caller -' -s -input -configuration -and -' -at -' -refers -to -/ -/ -/ -the -current -position -in -the -haystack -. -These -are -used -to -check -whether -/ -/ -/ -conditional -epsilon -transitions -( -like -look -- -around -) -are -satisfied -at -/ -/ -/ -the -current -position -. -If -they -aren -' -t -then -the -epsilon -closure -won -' -t -/ -/ -/ -include -them -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -epsilon_closure_explore -( -& -self -stack -: -& -mut -Vec -< -FollowEpsilon -> -curr_slots -: -& -mut -[ -Option -< -NonMaxUsize -> -] -next -: -& -mut -ActiveStates -input -: -& -Input -< -' -_ -> -at -: -usize -mut -sid -: -StateID -) -{ -/ -/ -We -can -avoid -pushing -some -state -IDs -on -to -our -stack -in -precisely -/ -/ -the -cases -where -a -' -push -( -x -) -' -would -be -immediately -followed -by -a -' -x -/ -/ -= -pop -( -) -' -. -This -is -achieved -by -this -outer -- -loop -. -We -simply -set -' -sid -' -/ -/ -to -be -the -next -state -ID -we -want -to -explore -once -we -' -re -done -with -/ -/ -our -initial -exploration -. -In -practice -this -avoids -a -lot -of -stack -/ -/ -thrashing -. -loop -{ -instrument -! -( -| -c -| -c -. -record_set_insert -( -sid -) -) -; -/ -/ -Record -this -state -as -part -of -our -next -set -of -active -states -. -If -/ -/ -we -' -ve -already -explored -it -then -no -need -to -do -it -again -. -if -! -next -. -set -. -insert -( -sid -) -{ -return -; -} -match -* -self -. -nfa -. -state -( -sid -) -{ -State -: -: -Fail -| -State -: -: -Match -{ -. -. -} -| -State -: -: -ByteRange -{ -. -. -} -| -State -: -: -Sparse -{ -. -. -} -| -State -: -: -Dense -{ -. -. -} -= -> -{ -next -. -slot_table -. -for_state -( -sid -) -. -copy_from_slice -( -curr_slots -) -; -return -; -} -State -: -: -Look -{ -look -next -} -= -> -{ -/ -/ -OK -because -we -don -' -t -permit -building -a -searcher -with -a -/ -/ -Unicode -word -boundary -if -the -requisite -Unicode -data -is -/ -/ -unavailable -. -if -! -self -. -nfa -. -look_matcher -( -) -. -matches_inline -( -look -input -. -haystack -( -) -at -) -{ -return -; -} -sid -= -next -; -} -State -: -: -Union -{ -ref -alternates -} -= -> -{ -sid -= -match -alternates -. -get -( -0 -) -{ -None -= -> -return -Some -( -& -sid -) -= -> -sid -} -; -instrument -! -( -| -c -| -{ -for -& -alt -in -& -alternates -[ -1 -. -. -] -{ -c -. -record_stack_push -( -alt -) -; -} -} -) -; -stack -. -extend -( -alternates -[ -1 -. -. -] -. -iter -( -) -. -copied -( -) -. -rev -( -) -. -map -( -FollowEpsilon -: -: -Explore -) -) -; -} -State -: -: -BinaryUnion -{ -alt1 -alt2 -} -= -> -{ -sid -= -alt1 -; -instrument -! -( -| -c -| -c -. -record_stack_push -( -sid -) -) -; -stack -. -push -( -FollowEpsilon -: -: -Explore -( -alt2 -) -) -; -} -State -: -: -Capture -{ -next -slot -. -. -} -= -> -{ -/ -/ -There -' -s -no -need -to -do -anything -with -slots -that -/ -/ -ultimately -won -' -t -be -copied -into -the -caller -- -provided -/ -/ -' -Captures -' -value -. -So -we -just -skip -dealing -with -them -at -/ -/ -all -. -if -slot -. -as_usize -( -) -< -curr_slots -. -len -( -) -{ -instrument -! -( -| -c -| -c -. -record_stack_push -( -sid -) -) -; -stack -. -push -( -FollowEpsilon -: -: -RestoreCapture -{ -slot -offset -: -curr_slots -[ -slot -] -} -) -; -/ -/ -OK -because -length -of -a -slice -must -fit -into -an -isize -. -curr_slots -[ -slot -] -= -Some -( -NonMaxUsize -: -: -new -( -at -) -. -unwrap -( -) -) -; -} -sid -= -next -; -} -} -} -} -/ -/ -/ -Return -the -starting -configuration -of -a -PikeVM -search -. -/ -/ -/ -/ -/ -/ -The -" -start -config -" -is -basically -whether -the -search -should -be -anchored -/ -/ -/ -or -not -and -the -NFA -state -ID -at -which -to -begin -the -search -. -The -state -ID -/ -/ -/ -returned -always -corresponds -to -an -anchored -starting -state -even -when -the -/ -/ -/ -search -is -unanchored -. -This -is -because -the -PikeVM -search -loop -deals -with -/ -/ -/ -unanchored -searches -with -an -explicit -epsilon -closure -out -of -the -start -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -This -routine -accounts -for -both -the -caller -' -s -Input -configuration -/ -/ -/ -and -the -pattern -itself -. -For -example -even -if -the -caller -asks -for -an -/ -/ -/ -unanchored -search -if -the -pattern -itself -is -anchored -then -this -will -/ -/ -/ -always -return -' -true -' -because -implementing -an -unanchored -search -in -that -/ -/ -/ -case -would -be -incorrect -. -/ -/ -/ -/ -/ -/ -Similarly -if -the -caller -requests -an -anchored -search -for -a -particular -/ -/ -/ -pattern -then -the -starting -state -ID -returned -will -reflect -that -. -/ -/ -/ -/ -/ -/ -If -a -pattern -ID -is -given -in -the -input -configuration -that -is -not -in -/ -/ -/ -this -regex -then -None -is -returned -. -fn -start_config -( -& -self -input -: -& -Input -< -' -_ -> -) -- -> -Option -< -( -bool -StateID -) -> -{ -match -input -. -get_anchored -( -) -{ -/ -/ -Only -way -we -' -re -unanchored -is -if -both -the -caller -asked -for -an -/ -/ -unanchored -search -* -and -* -the -pattern -is -itself -not -anchored -. -Anchored -: -: -No -= -> -Some -( -( -self -. -nfa -. -is_always_start_anchored -( -) -self -. -nfa -. -start_anchored -( -) -) -) -Anchored -: -: -Yes -= -> -Some -( -( -true -self -. -nfa -. -start_anchored -( -) -) -) -Anchored -: -: -Pattern -( -pid -) -= -> -{ -Some -( -( -true -self -. -nfa -. -start_pattern -( -pid -) -? -) -) -} -} -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -for -a -particular -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -Match -] -value -until -no -more -matches -could -be -found -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -PikeVM -. -/ -/ -/ -* -' -c -represents -the -lifetime -of -the -PikeVM -' -s -cache -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -PikeVM -: -: -find_iter -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -FindMatches -< -' -r -' -c -' -h -> -{ -re -: -& -' -r -PikeVM -cache -: -& -' -c -mut -Cache -caps -: -Captures -it -: -iter -: -: -Searcher -< -' -h -> -} -impl -< -' -r -' -c -' -h -> -Iterator -for -FindMatches -< -' -r -' -c -' -h -> -{ -type -Item -= -Match -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -/ -/ -Splitting -' -self -' -apart -seems -necessary -to -appease -borrowck -. -let -FindMatches -{ -re -ref -mut -cache -ref -mut -caps -ref -mut -it -} -= -* -self -; -/ -/ -' -advance -' -converts -errors -into -panics -which -is -OK -here -because -/ -/ -the -PikeVM -can -never -return -an -error -. -it -. -advance -( -| -input -| -{ -re -. -search -( -cache -input -caps -) -; -Ok -( -caps -. -get_match -( -) -) -} -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -leftmost -matches -with -their -capturing -/ -/ -/ -groups -for -a -particular -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -Captures -] -value -until -no -more -matches -could -be -/ -/ -/ -found -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -' -r -represents -the -lifetime -of -the -PikeVM -. -/ -/ -/ -* -' -c -represents -the -lifetime -of -the -PikeVM -' -s -cache -. -/ -/ -/ -* -' -h -represents -the -lifetime -of -the -haystack -being -searched -. -/ -/ -/ -/ -/ -/ -This -iterator -can -be -created -with -the -[ -PikeVM -: -: -captures_iter -] -method -. -# -[ -derive -( -Debug -) -] -pub -struct -CapturesMatches -< -' -r -' -c -' -h -> -{ -re -: -& -' -r -PikeVM -cache -: -& -' -c -mut -Cache -caps -: -Captures -it -: -iter -: -: -Searcher -< -' -h -> -} -impl -< -' -r -' -c -' -h -> -Iterator -for -CapturesMatches -< -' -r -' -c -' -h -> -{ -type -Item -= -Captures -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Captures -> -{ -/ -/ -Splitting -' -self -' -apart -seems -necessary -to -appease -borrowck -. -let -CapturesMatches -{ -re -ref -mut -cache -ref -mut -caps -ref -mut -it -} -= -* -self -; -/ -/ -' -advance -' -converts -errors -into -panics -which -is -OK -here -because -/ -/ -the -PikeVM -can -never -return -an -error -. -it -. -advance -( -| -input -| -{ -re -. -search -( -cache -input -caps -) -; -Ok -( -caps -. -get_match -( -) -) -} -) -; -if -caps -. -is_match -( -) -{ -Some -( -caps -. -clone -( -) -) -} -else -{ -None -} -} -} -/ -/ -/ -A -cache -represents -mutable -state -that -a -[ -PikeVM -] -requires -during -a -/ -/ -/ -search -. -/ -/ -/ -/ -/ -/ -For -a -given -[ -PikeVM -] -its -corresponding -cache -may -be -created -either -via -/ -/ -/ -[ -PikeVM -: -: -create_cache -] -or -via -[ -Cache -: -: -new -] -. -They -are -equivalent -in -/ -/ -/ -every -way -except -the -former -does -not -require -explicitly -importing -Cache -. -/ -/ -/ -/ -/ -/ -A -particular -Cache -is -coupled -with -the -[ -PikeVM -] -from -which -it -/ -/ -/ -was -created -. -It -may -only -be -used -with -that -PikeVM -. -A -cache -and -its -/ -/ -/ -allocations -may -be -re -- -purposed -via -[ -Cache -: -: -reset -] -in -which -case -it -can -/ -/ -/ -only -be -used -with -the -new -PikeVM -( -and -not -the -old -one -) -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Cache -{ -/ -/ -/ -Stack -used -while -computing -epsilon -closure -. -This -effectively -lets -us -/ -/ -/ -move -what -is -more -naturally -expressed -through -recursion -to -a -stack -/ -/ -/ -on -the -heap -. -stack -: -Vec -< -FollowEpsilon -> -/ -/ -/ -The -current -active -states -being -explored -for -the -current -byte -in -the -/ -/ -/ -haystack -. -curr -: -ActiveStates -/ -/ -/ -The -next -set -of -states -we -' -re -building -that -will -be -explored -for -the -/ -/ -/ -next -byte -in -the -haystack -. -next -: -ActiveStates -} -impl -Cache -{ -/ -/ -/ -Create -a -new -[ -PikeVM -] -cache -. -/ -/ -/ -/ -/ -/ -A -potentially -more -convenient -routine -to -create -a -cache -is -/ -/ -/ -[ -PikeVM -: -: -create_cache -] -as -it -does -not -require -also -importing -the -/ -/ -/ -Cache -type -. -/ -/ -/ -/ -/ -/ -If -you -want -to -reuse -the -returned -Cache -with -some -other -PikeVM -/ -/ -/ -then -you -must -call -[ -Cache -: -: -reset -] -with -the -desired -PikeVM -. -pub -fn -new -( -re -: -& -PikeVM -) -- -> -Cache -{ -Cache -{ -stack -: -vec -! -[ -] -curr -: -ActiveStates -: -: -new -( -re -) -next -: -ActiveStates -: -: -new -( -re -) -} -} -/ -/ -/ -Reset -this -cache -such -that -it -can -be -used -for -searching -with -a -/ -/ -/ -different -[ -PikeVM -] -. -/ -/ -/ -/ -/ -/ -A -cache -reset -permits -reusing -memory -already -allocated -in -this -cache -/ -/ -/ -with -a -different -PikeVM -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -re -- -purpose -a -cache -for -use -with -a -different -PikeVM -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re1 -= -PikeVM -: -: -new -( -r -" -\ -w -" -) -? -; -/ -/ -/ -let -re2 -= -PikeVM -: -: -new -( -r -" -\ -W -" -) -? -; -/ -/ -/ -/ -/ -/ -let -mut -cache -= -re1 -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -/ -/ -/ -re1 -. -find_iter -( -& -mut -cache -" -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -' -cache -' -with -re2 -is -not -allowed -. -It -may -result -in -panics -or -/ -/ -/ -/ -/ -incorrect -results -. -In -order -to -re -- -purpose -the -cache -we -must -reset -/ -/ -/ -/ -/ -it -with -the -PikeVM -we -' -d -like -to -use -it -with -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -/ -Similarly -after -this -reset -using -the -cache -with -' -re1 -' -is -also -not -/ -/ -/ -/ -/ -allowed -. -/ -/ -/ -cache -. -reset -( -& -re2 -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -0 -. -. -3 -) -) -/ -/ -/ -re2 -. -find_iter -( -& -mut -cache -" -" -) -. -next -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -reset -( -& -mut -self -re -: -& -PikeVM -) -{ -self -. -curr -. -reset -( -re -) -; -self -. -next -. -reset -( -re -) -; -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -of -this -cache -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -cache -. -To -/ -/ -/ -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -Cache -> -( -) -. -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -use -core -: -: -mem -: -: -size_of -; -( -self -. -stack -. -len -( -) -* -size_of -: -: -< -FollowEpsilon -> -( -) -) -+ -self -. -curr -. -memory_usage -( -) -+ -self -. -next -. -memory_usage -( -) -} -/ -/ -/ -Clears -this -cache -. -This -should -be -called -at -the -start -of -every -search -/ -/ -/ -to -ensure -we -start -with -a -clean -slate -. -/ -/ -/ -/ -/ -/ -This -also -sets -the -length -of -the -capturing -groups -used -in -the -current -/ -/ -/ -search -. -This -permits -an -optimization -where -by -' -SlotTable -: -: -for_state -' -/ -/ -/ -only -returns -the -number -of -slots -equivalent -to -the -number -of -slots -/ -/ -/ -given -in -the -' -Captures -' -value -. -This -may -be -less -than -the -total -number -/ -/ -/ -of -possible -slots -e -. -g -. -when -one -only -wants -to -track -overall -match -/ -/ -/ -offsets -. -This -in -turn -permits -less -copying -of -capturing -group -spans -/ -/ -/ -in -the -PikeVM -. -fn -setup_search -( -& -mut -self -captures_slot_len -: -usize -) -{ -self -. -stack -. -clear -( -) -; -self -. -curr -. -setup_search -( -captures_slot_len -) -; -self -. -next -. -setup_search -( -captures_slot_len -) -; -} -} -/ -/ -/ -A -set -of -active -states -used -to -" -simulate -" -the -execution -of -an -NFA -via -the -/ -/ -/ -PikeVM -. -/ -/ -/ -/ -/ -/ -There -are -two -sets -of -these -used -during -NFA -simulation -. -One -set -corresponds -/ -/ -/ -to -the -" -current -" -set -of -states -being -traversed -for -the -current -position -/ -/ -/ -in -a -haystack -. -The -other -set -corresponds -to -the -" -next -" -set -of -states -being -/ -/ -/ -built -which -will -become -the -new -" -current -" -set -for -the -next -position -in -the -/ -/ -/ -haystack -. -These -two -sets -correspond -to -CLIST -and -NLIST -in -Thompson -' -s -/ -/ -/ -original -paper -regexes -: -https -: -/ -/ -dl -. -acm -. -org -/ -doi -/ -pdf -/ -10 -. -1145 -/ -363347 -. -363387 -/ -/ -/ -/ -/ -/ -In -addition -to -representing -a -set -of -NFA -states -this -also -maintains -slot -/ -/ -/ -values -for -each -state -. -These -slot -values -are -what -turn -the -NFA -simulation -/ -/ -/ -into -the -" -Pike -VM -. -" -Namely -they -track -capturing -group -values -for -each -/ -/ -/ -state -. -During -the -computation -of -epsilon -closure -we -copy -slot -values -from -/ -/ -/ -states -in -the -" -current -" -set -to -the -" -next -" -set -. -Eventually -once -a -match -/ -/ -/ -is -found -the -slot -values -for -that -match -state -are -what -we -write -to -the -/ -/ -/ -caller -provided -' -Captures -' -value -. -# -[ -derive -( -Clone -Debug -) -] -struct -ActiveStates -{ -/ -/ -/ -The -set -of -active -NFA -states -. -This -set -preserves -insertion -order -which -/ -/ -/ -is -critical -for -simulating -the -match -semantics -of -backtracking -regex -/ -/ -/ -engines -. -set -: -SparseSet -/ -/ -/ -The -slots -for -every -NFA -state -where -each -slot -stores -a -( -possibly -/ -/ -/ -absent -) -offset -. -Every -capturing -group -has -two -slots -. -One -for -a -start -/ -/ -/ -offset -and -one -for -an -end -offset -. -slot_table -: -SlotTable -} -impl -ActiveStates -{ -/ -/ -/ -Create -a -new -set -of -active -states -for -the -given -PikeVM -. -The -active -/ -/ -/ -states -returned -may -only -be -used -with -the -given -PikeVM -. -( -Use -' -reset -' -/ -/ -/ -to -re -- -purpose -the -allocation -for -a -different -PikeVM -. -) -fn -new -( -re -: -& -PikeVM -) -- -> -ActiveStates -{ -let -mut -active -= -ActiveStates -{ -set -: -SparseSet -: -: -new -( -0 -) -slot_table -: -SlotTable -: -: -new -( -) -} -; -active -. -reset -( -re -) -; -active -} -/ -/ -/ -Reset -this -set -of -active -states -such -that -it -can -be -used -with -the -given -/ -/ -/ -PikeVM -( -and -only -that -PikeVM -) -. -fn -reset -( -& -mut -self -re -: -& -PikeVM -) -{ -self -. -set -. -resize -( -re -. -get_nfa -( -) -. -states -( -) -. -len -( -) -) -; -self -. -slot_table -. -reset -( -re -) -; -} -/ -/ -/ -Return -the -heap -memory -usage -in -bytes -used -by -this -set -of -active -/ -/ -/ -states -. -/ -/ -/ -/ -/ -/ -This -does -not -include -the -stack -size -of -this -value -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -set -. -memory_usage -( -) -+ -self -. -slot_table -. -memory_usage -( -) -} -/ -/ -/ -Setup -this -set -of -active -states -for -a -new -search -. -The -given -slot -/ -/ -/ -length -should -be -the -number -of -slots -in -a -caller -provided -' -Captures -' -/ -/ -/ -( -and -may -be -zero -) -. -fn -setup_search -( -& -mut -self -captures_slot_len -: -usize -) -{ -self -. -set -. -clear -( -) -; -self -. -slot_table -. -setup_search -( -captures_slot_len -) -; -} -} -/ -/ -/ -A -table -of -slots -where -each -row -represent -a -state -in -an -NFA -. -Thus -the -/ -/ -/ -table -has -room -for -storing -slots -for -every -single -state -in -an -NFA -. -/ -/ -/ -/ -/ -/ -This -table -is -represented -with -a -single -contiguous -allocation -. -In -general -/ -/ -/ -the -notion -of -" -capturing -group -" -doesn -' -t -really -exist -at -this -level -of -/ -/ -/ -abstraction -hence -the -name -" -slot -" -instead -. -( -Indeed -every -capturing -group -/ -/ -/ -maps -to -a -pair -of -slots -one -for -the -start -offset -and -one -for -the -end -/ -/ -/ -offset -. -) -Slots -are -indexed -by -the -' -Captures -' -NFA -state -. -/ -/ -/ -/ -/ -/ -N -. -B -. -Not -every -state -actually -needs -a -row -of -slots -. -Namely -states -that -/ -/ -/ -only -have -epsilon -transitions -currently -never -have -anything -written -to -/ -/ -/ -their -rows -in -this -table -. -Thus -the -table -is -somewhat -wasteful -in -its -heap -/ -/ -/ -usage -. -However -it -is -important -to -maintain -fast -random -access -by -state -/ -/ -/ -ID -which -means -one -giant -table -tends -to -work -well -. -RE2 -takes -a -different -/ -/ -/ -approach -here -and -allocates -each -row -as -its -own -reference -counted -thing -. -/ -/ -/ -I -explored -such -a -strategy -at -one -point -here -but -couldn -' -t -get -it -to -work -/ -/ -/ -well -using -entirely -safe -code -. -( -To -the -ambitious -reader -: -I -encourage -you -to -/ -/ -/ -re -- -litigate -that -experiment -. -) -I -very -much -wanted -to -stick -to -safe -code -but -/ -/ -/ -could -be -convinced -otherwise -if -there -was -a -solid -argument -and -the -safety -/ -/ -/ -was -encapsulated -well -. -# -[ -derive -( -Clone -Debug -) -] -struct -SlotTable -{ -/ -/ -/ -The -actual -table -of -offsets -. -table -: -Vec -< -Option -< -NonMaxUsize -> -> -/ -/ -/ -The -number -of -slots -per -state -i -. -e -. -the -table -' -s -stride -or -the -length -/ -/ -/ -of -each -row -. -slots_per_state -: -usize -/ -/ -/ -The -number -of -slots -in -the -caller -- -provided -' -Captures -' -value -for -the -/ -/ -/ -current -search -. -Setting -this -to -' -slots_per_state -' -is -always -correct -/ -/ -/ -but -may -be -wasteful -. -slots_for_captures -: -usize -} -impl -SlotTable -{ -/ -/ -/ -Create -a -new -slot -table -. -/ -/ -/ -/ -/ -/ -One -should -call -' -reset -' -with -the -corresponding -PikeVM -before -use -. -fn -new -( -) -- -> -SlotTable -{ -SlotTable -{ -table -: -vec -! -[ -] -slots_for_captures -: -0 -slots_per_state -: -0 -} -} -/ -/ -/ -Reset -this -slot -table -such -that -it -can -be -used -with -the -given -PikeVM -/ -/ -/ -( -and -only -that -PikeVM -) -. -fn -reset -( -& -mut -self -re -: -& -PikeVM -) -{ -let -nfa -= -re -. -get_nfa -( -) -; -self -. -slots_per_state -= -nfa -. -group_info -( -) -. -slot_len -( -) -; -/ -/ -This -is -always -correct -but -may -be -reduced -for -a -particular -search -/ -/ -if -a -' -Captures -' -has -fewer -slots -e -. -g -. -none -at -all -or -only -slots -/ -/ -for -tracking -the -overall -match -instead -of -all -slots -for -every -/ -/ -group -. -self -. -slots_for_captures -= -core -: -: -cmp -: -: -max -( -self -. -slots_per_state -nfa -. -pattern_len -( -) -. -checked_mul -( -2 -) -. -unwrap -( -) -) -; -let -len -= -nfa -. -states -( -) -. -len -( -) -. -checked_mul -( -self -. -slots_per_state -) -/ -/ -Add -space -to -account -for -scratch -space -used -during -a -search -. -. -and_then -( -| -x -| -x -. -checked_add -( -self -. -slots_for_captures -) -) -/ -/ -It -seems -like -this -could -actually -panic -on -legitimate -inputs -on -/ -/ -32 -- -bit -targets -and -very -likely -to -panic -on -16 -- -bit -. -Should -we -/ -/ -somehow -convert -this -to -an -error -? -What -about -something -similar -/ -/ -for -the -lazy -DFA -cache -? -If -you -' -re -tripping -this -assert -please -/ -/ -file -a -bug -. -. -expect -( -" -slot -table -length -doesn -' -t -overflow -" -) -; -/ -/ -This -happens -about -as -often -as -a -regex -is -compiled -so -it -probably -/ -/ -should -be -at -debug -level -but -I -found -it -quite -distracting -and -not -/ -/ -particularly -useful -. -trace -! -( -" -resizing -PikeVM -active -states -table -to -{ -} -entries -\ -( -slots_per_state -= -{ -} -) -" -len -self -. -slots_per_state -) -; -self -. -table -. -resize -( -len -None -) -; -} -/ -/ -/ -Return -the -heap -memory -usage -in -bytes -used -by -this -slot -table -. -/ -/ -/ -/ -/ -/ -This -does -not -include -the -stack -size -of -this -value -. -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -table -. -len -( -) -* -core -: -: -mem -: -: -size_of -: -: -< -Option -< -NonMaxUsize -> -> -( -) -} -/ -/ -/ -Perform -any -per -- -search -setup -for -this -slot -table -. -/ -/ -/ -/ -/ -/ -In -particular -this -sets -the -length -of -the -number -of -slots -used -in -the -/ -/ -/ -' -Captures -' -given -by -the -caller -( -if -any -at -all -) -. -This -number -may -be -/ -/ -/ -smaller -than -the -total -number -of -slots -available -e -. -g -. -when -the -caller -/ -/ -/ -is -only -interested -in -tracking -the -overall -match -and -not -the -spans -of -/ -/ -/ -every -matching -capturing -group -. -Only -tracking -the -overall -match -can -/ -/ -/ -save -a -substantial -amount -of -time -copying -capturing -spans -during -a -/ -/ -/ -search -. -fn -setup_search -( -& -mut -self -captures_slot_len -: -usize -) -{ -self -. -slots_for_captures -= -captures_slot_len -; -} -/ -/ -/ -Return -a -mutable -slice -of -the -slots -for -the -given -state -. -/ -/ -/ -/ -/ -/ -Note -that -the -length -of -the -slice -returned -may -be -less -than -the -total -/ -/ -/ -number -of -slots -available -for -this -state -. -In -particular -the -length -/ -/ -/ -always -matches -the -number -of -slots -indicated -via -' -setup_search -' -. -fn -for_state -( -& -mut -self -sid -: -StateID -) -- -> -& -mut -[ -Option -< -NonMaxUsize -> -] -{ -let -i -= -sid -. -as_usize -( -) -* -self -. -slots_per_state -; -& -mut -self -. -table -[ -i -. -. -i -+ -self -. -slots_for_captures -] -} -/ -/ -/ -Return -a -slice -of -slots -of -appropriate -length -where -every -slot -offset -/ -/ -/ -is -guaranteed -to -be -absent -. -This -is -useful -in -cases -where -you -need -to -/ -/ -/ -compute -an -epsilon -closure -outside -of -the -user -supplied -regex -and -thus -/ -/ -/ -never -want -it -to -have -any -capturing -slots -set -. -fn -all_absent -( -& -mut -self -) -- -> -& -mut -[ -Option -< -NonMaxUsize -> -] -{ -let -i -= -self -. -table -. -len -( -) -- -self -. -slots_for_captures -; -& -mut -self -. -table -[ -i -. -. -i -+ -self -. -slots_for_captures -] -} -} -/ -/ -/ -Represents -a -stack -frame -for -use -while -computing -an -epsilon -closure -. -/ -/ -/ -/ -/ -/ -( -An -" -epsilon -closure -" -refers -to -the -set -of -reachable -NFA -states -from -a -/ -/ -/ -single -state -without -consuming -any -input -. -That -is -the -set -of -all -epsilon -/ -/ -/ -transitions -not -only -from -that -single -state -but -from -every -other -state -/ -/ -/ -reachable -by -an -epsilon -transition -as -well -. -This -is -why -it -' -s -called -a -/ -/ -/ -" -closure -. -" -Computing -an -epsilon -closure -is -also -done -during -DFA -/ -/ -/ -determinization -! -Compare -and -contrast -the -epsilon -closure -here -in -this -/ -/ -/ -PikeVM -and -the -one -used -for -determinization -in -crate -: -: -util -: -: -determinize -. -) -/ -/ -/ -/ -/ -/ -Computing -the -epsilon -closure -in -a -Thompson -NFA -proceeds -via -a -depth -/ -/ -/ -first -traversal -over -all -epsilon -transitions -from -a -particular -state -. -/ -/ -/ -( -A -depth -first -traversal -is -important -because -it -emulates -the -same -priority -/ -/ -/ -of -matches -that -is -typically -found -in -backtracking -regex -engines -. -) -This -/ -/ -/ -depth -first -traversal -is -naturally -expressed -using -recursion -but -to -avoid -/ -/ -/ -a -call -stack -size -proportional -to -the -size -of -a -regex -we -put -our -stack -on -/ -/ -/ -the -heap -instead -. -/ -/ -/ -/ -/ -/ -This -stack -thus -consists -of -call -frames -. -The -typical -call -frame -is -/ -/ -/ -Explore -which -instructs -epsilon -closure -to -explore -the -epsilon -/ -/ -/ -transitions -from -that -state -. -( -Subsequent -epsilon -transitions -are -then -/ -/ -/ -pushed -on -to -the -stack -as -more -Explore -frames -. -) -If -the -state -ID -being -/ -/ -/ -explored -has -no -epsilon -transitions -then -the -capturing -group -slots -are -/ -/ -/ -copied -from -the -original -state -that -sparked -the -epsilon -closure -( -from -the -/ -/ -/ -' -step -' -routine -) -to -the -state -ID -being -explored -. -This -way -capturing -group -/ -/ -/ -slots -are -forwarded -from -the -previous -state -to -the -next -. -/ -/ -/ -/ -/ -/ -The -other -stack -frame -RestoreCaptures -instructs -the -epsilon -closure -to -/ -/ -/ -set -the -position -for -a -particular -slot -back -to -some -particular -offset -. -This -/ -/ -/ -frame -is -pushed -when -Explore -sees -a -Capture -transition -. -Explore -will -/ -/ -/ -set -the -offset -of -the -slot -indicated -in -Capture -to -the -current -offset -/ -/ -/ -and -then -push -the -old -offset -on -to -the -stack -as -a -RestoreCapture -frame -. -/ -/ -/ -Thus -the -new -offset -is -only -used -until -the -epsilon -closure -reverts -back -to -/ -/ -/ -the -RestoreCapture -frame -. -In -effect -this -gives -the -Capture -epsilon -/ -/ -/ -transition -its -" -scope -" -to -only -states -that -come -" -after -" -it -during -depth -/ -/ -/ -first -traversal -. -# -[ -derive -( -Clone -Debug -) -] -enum -FollowEpsilon -{ -/ -/ -/ -Explore -the -epsilon -transitions -from -a -state -ID -. -Explore -( -StateID -) -/ -/ -/ -Reset -the -given -slot -to -the -given -offset -( -which -might -be -None -) -. -RestoreCapture -{ -slot -: -SmallIndex -offset -: -Option -< -NonMaxUsize -> -} -} -/ -/ -/ -A -set -of -counters -that -" -instruments -" -a -PikeVM -search -. -To -enable -this -you -/ -/ -/ -must -enable -the -' -internal -- -instrument -- -pikevm -' -feature -. -Then -run -your -Rust -/ -/ -/ -program -with -RUST_LOG -= -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -= -trace -set -in -/ -/ -/ -the -environment -. -The -metrics -collected -will -be -dumped -automatically -for -/ -/ -/ -every -search -executed -by -the -PikeVM -. -/ -/ -/ -/ -/ -/ -NOTE -: -When -' -internal -- -instrument -- -pikevm -' -is -enabled -it -will -likely -cause -an -/ -/ -/ -absolute -decrease -in -wall -- -clock -performance -even -if -the -' -trace -' -log -level -/ -/ -/ -isn -' -t -enabled -. -( -Although -we -do -try -to -avoid -extra -costs -when -' -trace -' -isn -' -t -/ -/ -/ -enabled -. -) -The -main -point -of -instrumentation -is -to -get -counts -of -various -/ -/ -/ -events -that -occur -during -the -PikeVM -' -s -execution -. -/ -/ -/ -/ -/ -/ -This -is -a -somewhat -hacked -together -collection -of -metrics -that -are -useful -/ -/ -/ -to -gather -from -a -PikeVM -search -. -In -particular -it -lets -us -scrutinize -the -/ -/ -/ -performance -profile -of -a -search -beyond -what -general -purpose -profiling -tools -/ -/ -/ -give -us -. -Namely -we -orient -the -profiling -data -around -the -specific -states -of -/ -/ -/ -the -NFA -. -/ -/ -/ -/ -/ -/ -In -other -words -this -lets -us -see -which -parts -of -the -NFA -graph -are -most -/ -/ -/ -frequently -activated -. -This -then -provides -direction -for -optimization -/ -/ -/ -opportunities -. -/ -/ -/ -/ -/ -/ -The -really -sad -part -about -this -is -that -it -absolutely -clutters -up -the -PikeVM -/ -/ -/ -implementation -. -: -' -( -Another -approach -would -be -to -just -manually -add -this -/ -/ -/ -code -in -whenever -I -want -this -kind -of -profiling -data -but -it -' -s -complicated -/ -/ -/ -and -tedious -enough -that -I -went -with -this -approach -. -. -. -for -now -. -/ -/ -/ -/ -/ -/ -When -instrumentation -is -enabled -( -which -also -turns -on -' -logging -' -) -then -a -/ -/ -/ -Counters -is -initialized -for -every -search -and -trace -' -d -just -before -the -/ -/ -/ -search -returns -to -the -caller -. -/ -/ -/ -/ -/ -/ -Tip -: -When -debugging -performance -problems -with -the -PikeVM -it -' -s -best -to -try -/ -/ -/ -to -work -with -an -NFA -that -is -as -small -as -possible -. -Otherwise -the -state -graph -/ -/ -/ -is -likely -to -be -too -big -to -digest -. -# -[ -cfg -( -feature -= -" -internal -- -instrument -- -pikevm -" -) -] -# -[ -derive -( -Clone -Debug -) -] -struct -Counters -{ -/ -/ -/ -The -number -of -times -the -NFA -is -in -a -particular -permutation -of -states -. -state_sets -: -alloc -: -: -collections -: -: -BTreeMap -< -Vec -< -StateID -> -u64 -> -/ -/ -/ -The -number -of -times -' -step -' -is -called -for -a -particular -state -ID -( -which -/ -/ -/ -indexes -this -array -) -. -steps -: -Vec -< -u64 -> -/ -/ -/ -The -number -of -times -an -epsilon -closure -was -computed -for -a -state -. -closures -: -Vec -< -u64 -> -/ -/ -/ -The -number -of -times -a -particular -state -ID -is -pushed -on -to -a -stack -while -/ -/ -/ -computing -an -epsilon -closure -. -stack_pushes -: -Vec -< -u64 -> -/ -/ -/ -The -number -of -times -a -particular -state -ID -is -inserted -into -a -sparse -set -/ -/ -/ -while -computing -an -epsilon -closure -. -set_inserts -: -Vec -< -u64 -> -} -# -[ -cfg -( -feature -= -" -internal -- -instrument -- -pikevm -" -) -] -impl -Counters -{ -fn -empty -( -) -- -> -Counters -{ -Counters -{ -state_sets -: -alloc -: -: -collections -: -: -BTreeMap -: -: -new -( -) -steps -: -vec -! -[ -] -closures -: -vec -! -[ -] -stack_pushes -: -vec -! -[ -] -set_inserts -: -vec -! -[ -] -} -} -fn -reset -( -& -mut -self -nfa -: -& -NFA -) -{ -let -len -= -nfa -. -states -( -) -. -len -( -) -; -self -. -state_sets -. -clear -( -) -; -self -. -steps -. -clear -( -) -; -self -. -steps -. -resize -( -len -0 -) -; -self -. -closures -. -clear -( -) -; -self -. -closures -. -resize -( -len -0 -) -; -self -. -stack_pushes -. -clear -( -) -; -self -. -stack_pushes -. -resize -( -len -0 -) -; -self -. -set_inserts -. -clear -( -) -; -self -. -set_inserts -. -resize -( -len -0 -) -; -} -fn -eprint -( -& -self -nfa -: -& -NFA -) -{ -trace -! -( -" -= -= -= -= -= -START -PikeVM -Instrumentation -Output -= -= -= -= -= -" -) -; -/ -/ -We -take -the -top -- -K -most -occurring -state -sets -. -Otherwise -the -output -/ -/ -is -likely -to -be -overwhelming -. -And -we -probably -only -care -about -the -/ -/ -most -frequently -occurring -ones -anyway -. -const -LIMIT -: -usize -= -20 -; -let -mut -set_counts -= -self -. -state_sets -. -iter -( -) -. -collect -: -: -< -Vec -< -( -& -Vec -< -StateID -> -& -u64 -) -> -> -( -) -; -set_counts -. -sort_by_key -( -| -( -_ -& -count -) -| -core -: -: -cmp -: -: -Reverse -( -count -) -) -; -trace -! -( -" -# -# -PikeVM -frequency -of -state -sets -( -top -{ -} -) -" -LIMIT -) -; -for -( -set -count -) -in -set_counts -. -iter -( -) -. -take -( -LIMIT -) -{ -trace -! -( -" -{ -: -? -} -: -{ -} -" -set -count -) -; -} -if -set_counts -. -len -( -) -> -LIMIT -{ -trace -! -( -" -. -. -. -{ -} -sets -omitted -( -out -of -{ -} -total -) -" -set_counts -. -len -( -) -- -LIMIT -set_counts -. -len -( -) -) -; -} -trace -! -( -" -" -) -; -trace -! -( -" -# -# -PikeVM -total -frequency -of -events -" -) -; -trace -! -( -" -steps -: -{ -} -closures -: -{ -} -stack -- -pushes -: -{ -} -set -- -inserts -: -{ -} -" -self -. -steps -. -iter -( -) -. -copied -( -) -. -sum -: -: -< -u64 -> -( -) -self -. -closures -. -iter -( -) -. -copied -( -) -. -sum -: -: -< -u64 -> -( -) -self -. -stack_pushes -. -iter -( -) -. -copied -( -) -. -sum -: -: -< -u64 -> -( -) -self -. -set_inserts -. -iter -( -) -. -copied -( -) -. -sum -: -: -< -u64 -> -( -) -) -; -trace -! -( -" -" -) -; -trace -! -( -" -# -# -PikeVM -frequency -of -events -broken -down -by -state -" -) -; -for -sid -in -0 -. -. -self -. -steps -. -len -( -) -{ -trace -! -( -" -{ -: -06 -} -: -steps -: -{ -} -closures -: -{ -} -\ -stack -- -pushes -: -{ -} -set -- -inserts -: -{ -} -" -sid -self -. -steps -[ -sid -] -self -. -closures -[ -sid -] -self -. -stack_pushes -[ -sid -] -self -. -set_inserts -[ -sid -] -) -; -} -trace -! -( -" -" -) -; -trace -! -( -" -# -# -NFA -debug -display -" -) -; -trace -! -( -" -{ -: -? -} -" -nfa -) -; -trace -! -( -" -= -= -= -= -= -END -PikeVM -Instrumentation -Output -= -= -= -= -= -" -) -; -} -fn -record_state_set -( -& -mut -self -set -: -& -SparseSet -) -{ -let -set -= -set -. -iter -( -) -. -collect -: -: -< -Vec -< -StateID -> -> -( -) -; -* -self -. -state_sets -. -entry -( -set -) -. -or_insert -( -0 -) -+ -= -1 -; -} -fn -record_step -( -& -mut -self -sid -: -StateID -) -{ -self -. -steps -[ -sid -] -+ -= -1 -; -} -fn -record_closure -( -& -mut -self -sid -: -StateID -) -{ -self -. -closures -[ -sid -] -+ -= -1 -; -} -fn -record_stack_push -( -& -mut -self -sid -: -StateID -) -{ -self -. -stack_pushes -[ -sid -] -+ -= -1 -; -} -fn -record_set_insert -( -& -mut -self -sid -: -StateID -) -{ -self -. -set_inserts -[ -sid -] -+ -= -1 -; -} -} diff --git a/third_party/rust/regex-automata/src/nfa/thompson/range_trie.rs b/third_party/rust/regex-automata/src/nfa/thompson/range_trie.rs deleted file mode 100644 index 5674a288f1433..0000000000000 --- a/third_party/rust/regex-automata/src/nfa/thompson/range_trie.rs +++ /dev/null @@ -1,10597 +0,0 @@ -/ -* -I -' -ve -called -the -primary -data -structure -in -this -module -a -" -range -trie -. -" -As -far -as -I -can -tell -there -is -no -prior -art -on -a -data -structure -like -this -however -it -' -s -likely -someone -somewhere -has -built -something -like -it -. -Searching -for -" -range -trie -" -turns -up -the -paper -" -Range -Tries -for -Scalable -Address -Lookup -" -but -it -does -not -appear -relevant -. -The -range -trie -is -just -like -a -trie -in -that -it -is -a -special -case -of -a -deterministic -finite -state -machine -. -It -has -states -and -each -state -has -a -set -of -transitions -to -other -states -. -It -is -acyclic -and -like -a -normal -trie -it -makes -no -attempt -to -reuse -common -suffixes -among -its -elements -. -The -key -difference -between -a -normal -trie -and -a -range -trie -below -is -that -a -range -trie -operates -on -* -contiguous -sequences -* -of -bytes -instead -of -singleton -bytes -. -One -could -say -say -that -our -alphabet -is -ranges -of -bytes -instead -of -bytes -themselves -except -a -key -part -of -range -trie -construction -is -splitting -ranges -apart -to -ensure -there -is -at -most -one -transition -that -can -be -taken -for -any -byte -in -a -given -state -. -I -' -ve -tried -to -explain -the -details -of -how -the -range -trie -works -below -so -for -now -we -are -left -with -trying -to -understand -what -problem -we -' -re -trying -to -solve -. -Which -is -itself -fairly -involved -! -At -the -highest -level -here -' -s -what -we -want -to -do -. -We -want -to -convert -a -sequence -of -Unicode -codepoints -into -a -finite -state -machine -whose -transitions -are -over -* -bytes -* -and -* -not -* -Unicode -codepoints -. -We -want -this -because -it -makes -said -finite -state -machines -much -smaller -and -much -faster -to -execute -. -As -a -simple -example -consider -a -byte -oriented -automaton -for -all -Unicode -scalar -values -( -0x00 -through -0x10FFFF -not -including -surrogate -codepoints -) -: -[ -00 -- -7F -] -[ -C2 -- -DF -] -[ -80 -- -BF -] -[ -E0 -- -E0 -] -[ -A0 -- -BF -] -[ -80 -- -BF -] -[ -E1 -- -EC -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -ED -- -ED -] -[ -80 -- -9F -] -[ -80 -- -BF -] -[ -EE -- -EF -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -F0 -- -F0 -] -[ -90 -- -BF -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -F1 -- -F3 -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -F4 -- -F4 -] -[ -80 -- -8F -] -[ -80 -- -BF -] -[ -80 -- -BF -] -( -These -byte -ranges -are -generated -via -the -regex -- -syntax -: -: -utf8 -module -which -was -based -on -Russ -Cox -' -s -code -in -RE2 -which -was -in -turn -based -on -Ken -Thompson -' -s -implementation -of -the -same -idea -in -his -Plan9 -implementation -of -grep -. -) -It -should -be -fairly -straight -- -forward -to -see -how -one -could -compile -this -into -a -DFA -. -The -sequences -are -sorted -and -non -- -overlapping -. -Essentially -you -could -build -a -trie -from -this -fairly -easy -. -The -problem -comes -when -your -initial -range -( -in -this -case -0x00 -- -0x10FFFF -) -isn -' -t -so -nice -. -For -example -the -class -represented -by -' -\ -w -' -contains -only -a -tenth -of -the -codepoints -that -0x00 -- -0x10FFFF -contains -but -if -we -were -to -write -out -the -byte -based -ranges -as -we -did -above -the -list -would -stretch -to -892 -entries -! -This -turns -into -quite -a -large -NFA -with -a -few -thousand -states -. -Turning -this -beast -into -a -DFA -takes -quite -a -bit -of -time -. -We -are -thus -left -with -trying -to -trim -down -the -number -of -states -we -produce -as -early -as -possible -. -One -approach -( -used -by -RE2 -and -still -by -the -regex -crate -at -time -of -writing -) -is -to -try -to -find -common -suffixes -while -building -NFA -states -for -the -above -and -reuse -them -. -This -is -very -cheap -to -do -and -one -can -control -precisely -how -much -extra -memory -you -want -to -use -for -the -cache -. -Another -approach -however -is -to -reuse -an -algorithm -for -constructing -a -* -minimal -* -DFA -from -a -sorted -sequence -of -inputs -. -I -don -' -t -want -to -go -into -the -full -details -here -but -I -explain -it -in -more -depth -in -my -blog -post -on -FSTs -[ -1 -] -. -Note -that -the -algorithm -was -not -invented -by -me -but -was -published -in -paper -by -Daciuk -et -al -. -in -2000 -called -" -Incremental -Construction -of -MinimalAcyclic -Finite -- -State -Automata -. -" -Like -the -suffix -cache -approach -above -it -is -also -possible -to -control -the -amount -of -extra -memory -one -uses -although -this -usually -comes -with -the -cost -of -sacrificing -true -minimality -. -( -But -it -' -s -typically -close -enough -with -a -reasonably -sized -cache -of -states -. -) -The -catch -is -that -Daciuk -' -s -algorithm -only -works -if -you -add -your -keys -in -lexicographic -ascending -order -. -In -our -case -since -we -' -re -dealing -with -ranges -we -also -need -the -additional -requirement -that -ranges -are -either -equivalent -or -do -not -overlap -at -all -. -For -example -if -one -were -given -the -following -byte -ranges -: -[ -BC -- -BF -] -[ -80 -- -BF -] -[ -BC -- -BF -] -[ -90 -- -BF -] -Then -Daciuk -' -s -algorithm -would -not -work -since -there -is -nothing -to -handle -the -fact -that -the -ranges -overlap -. -They -would -need -to -be -split -apart -. -Thankfully -Thompson -' -s -algorithm -for -producing -byte -ranges -for -Unicode -codepoint -ranges -meets -both -of -our -requirements -. -( -A -proof -for -this -eludes -me -but -it -appears -true -. -) -. -. -. -however -we -would -also -like -to -be -able -to -compile -UTF -- -8 -automata -in -reverse -. -We -want -this -because -in -order -to -find -the -starting -location -of -a -match -using -a -DFA -we -need -to -run -a -second -DFA -- -- -- -a -reversed -version -of -the -forward -DFA -- -- -- -backwards -to -discover -the -match -location -. -Unfortunately -if -we -reverse -our -byte -sequences -for -0x00 -- -0x10FFFF -we -get -sequences -that -are -can -overlap -even -if -they -are -sorted -: -[ -00 -- -7F -] -[ -80 -- -BF -] -[ -80 -- -9F -] -[ -ED -- -ED -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -80 -- -8F -] -[ -F4 -- -F4 -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -F1 -- -F3 -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -90 -- -BF -] -[ -F0 -- -F0 -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -E1 -- -EC -] -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -EE -- -EF -] -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -E0 -- -E0 -] -[ -80 -- -BF -] -[ -C2 -- -DF -] -For -example -' -[ -80 -- -BF -] -[ -80 -- -BF -] -[ -EE -- -EF -] -' -and -' -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -E0 -- -E0 -] -' -have -overlapping -ranges -between -' -[ -80 -- -BF -] -' -and -' -[ -A0 -- -BF -] -' -. -Thus -there -is -no -simple -way -to -apply -Daciuk -' -s -algorithm -. -And -thus -the -range -trie -was -born -. -The -range -trie -' -s -only -purpose -is -to -take -sequences -of -byte -ranges -like -the -ones -above -collect -them -into -a -trie -and -then -spit -them -out -in -a -sorted -fashion -with -no -overlapping -ranges -. -For -example -0x00 -- -0x10FFFF -gets -translated -to -: -[ -0 -- -7F -] -[ -80 -- -BF -] -[ -80 -- -9F -] -[ -80 -- -8F -] -[ -F1 -- -F3 -] -[ -80 -- -BF -] -[ -80 -- -9F -] -[ -80 -- -8F -] -[ -F4 -] -[ -80 -- -BF -] -[ -80 -- -9F -] -[ -90 -- -BF -] -[ -F0 -] -[ -80 -- -BF -] -[ -80 -- -9F -] -[ -90 -- -BF -] -[ -F1 -- -F3 -] -[ -80 -- -BF -] -[ -80 -- -9F -] -[ -E1 -- -EC -] -[ -80 -- -BF -] -[ -80 -- -9F -] -[ -ED -] -[ -80 -- -BF -] -[ -80 -- -9F -] -[ -EE -- -EF -] -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -80 -- -8F -] -[ -F1 -- -F3 -] -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -80 -- -8F -] -[ -F4 -] -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -90 -- -BF -] -[ -F0 -] -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -90 -- -BF -] -[ -F1 -- -F3 -] -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -E0 -] -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -E1 -- -EC -] -[ -80 -- -BF -] -[ -A0 -- -BF -] -[ -EE -- -EF -] -[ -80 -- -BF -] -[ -C2 -- -DF -] -We -' -ve -thus -satisfied -our -requirements -for -running -Daciuk -' -s -algorithm -. -All -sequences -of -ranges -are -sorted -and -any -corresponding -ranges -are -either -exactly -equivalent -or -non -- -overlapping -. -In -effect -a -range -trie -is -building -a -DFA -from -a -sequence -of -arbitrary -byte -ranges -. -But -it -uses -an -algorithm -custom -tailored -to -its -input -so -it -is -not -as -costly -as -traditional -DFA -construction -. -While -it -is -still -quite -a -bit -more -costly -than -the -forward -case -( -which -only -needs -Daciuk -' -s -algorithm -) -it -winds -up -saving -a -substantial -amount -of -time -if -one -is -doing -a -full -DFA -powerset -construction -later -by -virtue -of -producing -a -much -much -smaller -NFA -. -[ -1 -] -- -https -: -/ -/ -blog -. -burntsushi -. -net -/ -transducers -/ -[ -2 -] -- -https -: -/ -/ -www -. -mitpressjournals -. -org -/ -doi -/ -pdfplus -/ -10 -. -1162 -/ -089120100561601 -* -/ -use -core -: -: -{ -cell -: -: -RefCell -convert -: -: -TryFrom -fmt -mem -ops -: -: -RangeInclusive -} -; -use -alloc -: -: -{ -format -string -: -: -String -vec -vec -: -: -Vec -} -; -use -regex_syntax -: -: -utf8 -: -: -Utf8Range -; -use -crate -: -: -util -: -: -primitives -: -: -StateID -; -/ -/ -/ -There -is -only -one -final -state -in -this -trie -. -Every -sequence -of -byte -ranges -/ -/ -/ -added -shares -the -same -final -state -. -const -FINAL -: -StateID -= -StateID -: -: -ZERO -; -/ -/ -/ -The -root -state -of -the -trie -. -const -ROOT -: -StateID -= -StateID -: -: -new_unchecked -( -1 -) -; -/ -/ -/ -A -range -trie -represents -an -ordered -set -of -sequences -of -bytes -. -/ -/ -/ -/ -/ -/ -A -range -trie -accepts -as -input -a -sequence -of -byte -ranges -and -merges -/ -/ -/ -them -into -the -existing -set -such -that -the -trie -can -produce -a -sorted -/ -/ -/ -non -- -overlapping -sequence -of -byte -ranges -. -The -sequence -emitted -corresponds -/ -/ -/ -precisely -to -the -sequence -of -bytes -matched -by -the -given -keys -although -the -/ -/ -/ -byte -ranges -themselves -may -be -split -at -different -boundaries -. -/ -/ -/ -/ -/ -/ -The -order -complexity -of -this -data -structure -seems -difficult -to -analyze -. -/ -/ -/ -If -the -size -of -a -byte -is -held -as -a -constant -then -insertion -is -clearly -/ -/ -/ -O -( -n -) -where -n -is -the -number -of -byte -ranges -in -the -input -key -. -However -if -/ -/ -/ -k -= -256 -is -our -alphabet -size -then -insertion -could -be -O -( -k -^ -2 -* -n -) -. -In -/ -/ -/ -particular -it -seems -possible -for -pathological -inputs -to -cause -insertion -/ -/ -/ -to -do -a -lot -of -work -. -However -for -what -we -use -this -data -structure -for -/ -/ -/ -there -should -be -no -pathological -inputs -since -the -ultimate -source -is -always -/ -/ -/ -a -sorted -set -of -Unicode -scalar -value -ranges -. -/ -/ -/ -/ -/ -/ -Internally -this -trie -is -setup -like -a -finite -state -machine -. -Note -though -/ -/ -/ -that -it -is -acyclic -. -# -[ -derive -( -Clone -) -] -pub -struct -RangeTrie -{ -/ -/ -/ -The -states -in -this -trie -. -The -first -is -always -the -shared -final -state -. -/ -/ -/ -The -second -is -always -the -root -state -. -Otherwise -there -is -no -/ -/ -/ -particular -order -. -states -: -Vec -< -State -> -/ -/ -/ -A -free -- -list -of -states -. -When -a -range -trie -is -cleared -all -of -its -states -/ -/ -/ -are -added -to -this -list -. -Creating -a -new -state -reuses -states -from -this -/ -/ -/ -list -before -allocating -a -new -one -. -free -: -Vec -< -State -> -/ -/ -/ -A -stack -for -traversing -this -trie -to -yield -sequences -of -byte -ranges -in -/ -/ -/ -lexicographic -order -. -iter_stack -: -RefCell -< -Vec -< -NextIter -> -> -/ -/ -/ -A -buffer -that -stores -the -current -sequence -during -iteration -. -iter_ranges -: -RefCell -< -Vec -< -Utf8Range -> -> -/ -/ -/ -A -stack -used -for -traversing -the -trie -in -order -to -( -deeply -) -duplicate -/ -/ -/ -a -state -. -States -are -recursively -duplicated -when -ranges -are -split -. -dupe_stack -: -Vec -< -NextDupe -> -/ -/ -/ -A -stack -used -for -traversing -the -trie -during -insertion -of -a -new -/ -/ -/ -sequence -of -byte -ranges -. -insert_stack -: -Vec -< -NextInsert -> -} -/ -/ -/ -A -single -state -in -this -trie -. -# -[ -derive -( -Clone -) -] -struct -State -{ -/ -/ -/ -A -sorted -sequence -of -non -- -overlapping -transitions -to -other -states -. -Each -/ -/ -/ -transition -corresponds -to -a -single -range -of -bytes -. -transitions -: -Vec -< -Transition -> -} -/ -/ -/ -A -transition -is -a -single -range -of -bytes -. -If -a -particular -byte -is -in -this -/ -/ -/ -range -then -the -corresponding -machine -may -transition -to -the -state -pointed -/ -/ -/ -to -by -next_id -. -# -[ -derive -( -Clone -) -] -struct -Transition -{ -/ -/ -/ -The -byte -range -. -range -: -Utf8Range -/ -/ -/ -The -next -state -to -transition -to -. -next_id -: -StateID -} -impl -RangeTrie -{ -/ -/ -/ -Create -a -new -empty -range -trie -. -pub -fn -new -( -) -- -> -RangeTrie -{ -let -mut -trie -= -RangeTrie -{ -states -: -vec -! -[ -] -free -: -vec -! -[ -] -iter_stack -: -RefCell -: -: -new -( -vec -! -[ -] -) -iter_ranges -: -RefCell -: -: -new -( -vec -! -[ -] -) -dupe_stack -: -vec -! -[ -] -insert_stack -: -vec -! -[ -] -} -; -trie -. -clear -( -) -; -trie -} -/ -/ -/ -Clear -this -range -trie -such -that -it -is -empty -. -Clearing -a -range -trie -/ -/ -/ -and -reusing -it -can -beneficial -because -this -may -reuse -allocations -. -pub -fn -clear -( -& -mut -self -) -{ -self -. -free -. -extend -( -self -. -states -. -drain -( -. -. -) -) -; -self -. -add_empty -( -) -; -/ -/ -final -self -. -add_empty -( -) -; -/ -/ -root -} -/ -/ -/ -Iterate -over -all -of -the -sequences -of -byte -ranges -in -this -trie -and -/ -/ -/ -call -the -provided -function -for -each -sequence -. -Iteration -occurs -in -/ -/ -/ -lexicographic -order -. -pub -fn -iter -< -E -F -: -FnMut -( -& -[ -Utf8Range -] -) -- -> -Result -< -( -) -E -> -> -( -& -self -mut -f -: -F -) -- -> -Result -< -( -) -E -> -{ -let -mut -stack -= -self -. -iter_stack -. -borrow_mut -( -) -; -stack -. -clear -( -) -; -let -mut -ranges -= -self -. -iter_ranges -. -borrow_mut -( -) -; -ranges -. -clear -( -) -; -/ -/ -We -do -iteration -in -a -way -that -permits -us -to -use -a -single -buffer -/ -/ -for -our -keys -. -We -iterate -in -a -depth -first -fashion -while -being -/ -/ -careful -to -expand -our -frontier -as -we -move -deeper -in -the -trie -. -stack -. -push -( -NextIter -{ -state_id -: -ROOT -tidx -: -0 -} -) -; -while -let -Some -( -NextIter -{ -mut -state_id -mut -tidx -} -) -= -stack -. -pop -( -) -{ -/ -/ -This -could -be -implemented -more -simply -without -an -inner -loop -/ -/ -here -but -at -the -cost -of -more -stack -pushes -. -loop -{ -let -state -= -self -. -state -( -state_id -) -; -/ -/ -If -we -' -ve -visited -all -transitions -in -this -state -then -pop -/ -/ -back -to -the -parent -state -. -if -tidx -> -= -state -. -transitions -. -len -( -) -{ -ranges -. -pop -( -) -; -break -; -} -let -t -= -& -state -. -transitions -[ -tidx -] -; -ranges -. -push -( -t -. -range -) -; -if -t -. -next_id -= -= -FINAL -{ -f -( -& -ranges -) -? -; -ranges -. -pop -( -) -; -tidx -+ -= -1 -; -} -else -{ -/ -/ -Expand -our -frontier -. -Once -we -come -back -to -this -state -/ -/ -via -the -stack -start -in -on -the -next -transition -. -stack -. -push -( -NextIter -{ -state_id -tidx -: -tidx -+ -1 -} -) -; -/ -/ -Otherwise -move -to -the -first -transition -of -the -next -/ -/ -state -. -state_id -= -t -. -next_id -; -tidx -= -0 -; -} -} -} -Ok -( -( -) -) -} -/ -/ -/ -Inserts -a -new -sequence -of -ranges -into -this -trie -. -/ -/ -/ -/ -/ -/ -The -sequence -given -must -be -non -- -empty -and -must -not -have -a -length -/ -/ -/ -exceeding -4 -. -pub -fn -insert -( -& -mut -self -ranges -: -& -[ -Utf8Range -] -) -{ -assert -! -( -! -ranges -. -is_empty -( -) -) -; -assert -! -( -ranges -. -len -( -) -< -= -4 -) -; -let -mut -stack -= -mem -: -: -replace -( -& -mut -self -. -insert_stack -vec -! -[ -] -) -; -stack -. -clear -( -) -; -stack -. -push -( -NextInsert -: -: -new -( -ROOT -ranges -) -) -; -while -let -Some -( -next -) -= -stack -. -pop -( -) -{ -let -( -state_id -ranges -) -= -( -next -. -state_id -( -) -next -. -ranges -( -) -) -; -assert -! -( -! -ranges -. -is_empty -( -) -) -; -let -( -mut -new -rest -) -= -( -ranges -[ -0 -] -& -ranges -[ -1 -. -. -] -) -; -/ -/ -i -corresponds -to -the -position -of -the -existing -transition -on -/ -/ -which -we -are -operating -. -Typically -the -result -is -to -remove -the -/ -/ -transition -and -replace -it -with -two -or -more -new -transitions -/ -/ -corresponding -to -the -partitions -generated -by -splitting -the -/ -/ -' -new -' -with -the -ith -transition -' -s -range -. -let -mut -i -= -self -. -state -( -state_id -) -. -find -( -new -) -; -/ -/ -In -this -case -there -is -no -overlap -* -and -* -the -new -range -is -greater -/ -/ -than -all -existing -ranges -. -So -we -can -just -add -it -to -the -end -. -if -i -= -= -self -. -state -( -state_id -) -. -transitions -. -len -( -) -{ -let -next_id -= -NextInsert -: -: -push -( -self -& -mut -stack -rest -) -; -self -. -add_transition -( -state_id -new -next_id -) -; -continue -; -} -/ -/ -The -need -for -this -loop -is -a -bit -subtle -buf -basically -after -/ -/ -we -' -ve -handled -the -partitions -from -our -initial -split -it -' -s -/ -/ -possible -that -there -will -be -a -partition -leftover -that -overlaps -/ -/ -with -a -subsequent -transition -. -If -so -then -we -have -to -repeat -/ -/ -the -split -process -again -with -the -leftovers -and -that -subsequent -/ -/ -transition -. -' -OUTER -: -loop -{ -let -old -= -self -. -state -( -state_id -) -. -transitions -[ -i -] -. -clone -( -) -; -let -split -= -match -Split -: -: -new -( -old -. -range -new -) -{ -Some -( -split -) -= -> -split -None -= -> -{ -let -next_id -= -NextInsert -: -: -push -( -self -& -mut -stack -rest -) -; -self -. -add_transition_at -( -i -state_id -new -next_id -) -; -continue -; -} -} -; -let -splits -= -split -. -as_slice -( -) -; -/ -/ -If -we -only -have -one -partition -then -the -ranges -must -be -/ -/ -equivalent -. -There -' -s -nothing -to -do -here -for -this -state -so -/ -/ -just -move -on -to -the -next -one -. -if -splits -. -len -( -) -= -= -1 -{ -/ -/ -. -. -. -but -only -if -we -have -anything -left -to -do -. -if -! -rest -. -is_empty -( -) -{ -stack -. -push -( -NextInsert -: -: -new -( -old -. -next_id -rest -) -) -; -} -break -; -} -/ -/ -At -this -point -we -know -that -' -split -' -is -non -- -empty -and -there -/ -/ -must -be -some -overlap -AND -that -the -two -ranges -are -not -/ -/ -equivalent -. -Therefore -the -existing -range -MUST -be -removed -/ -/ -and -split -up -somehow -. -Instead -of -actually -doing -the -removal -/ -/ -and -then -a -subsequent -insertion -- -- -- -with -all -the -memory -/ -/ -shuffling -that -entails -- -- -- -we -simply -overwrite -the -transition -/ -/ -at -position -i -for -the -first -new -transition -we -want -to -/ -/ -insert -. -After -that -we -' -re -forced -to -do -expensive -inserts -. -let -mut -first -= -true -; -let -mut -add_trans -= -| -trie -: -& -mut -RangeTrie -pos -from -range -to -| -{ -if -first -{ -trie -. -set_transition_at -( -pos -from -range -to -) -; -first -= -false -; -} -else -{ -trie -. -add_transition_at -( -pos -from -range -to -) -; -} -} -; -for -( -j -& -srange -) -in -splits -. -iter -( -) -. -enumerate -( -) -{ -match -srange -{ -SplitRange -: -: -Old -( -r -) -= -> -{ -/ -/ -Deep -clone -the -state -pointed -to -by -the -ith -/ -/ -transition -. -This -is -always -necessary -since -' -old -' -/ -/ -is -always -coupled -with -at -least -a -' -both -' -/ -/ -partition -. -We -don -' -t -want -any -new -changes -made -/ -/ -via -the -' -both -' -partition -to -impact -the -part -of -/ -/ -the -transition -that -doesn -' -t -overlap -with -the -/ -/ -new -range -. -let -dup_id -= -self -. -duplicate -( -old -. -next_id -) -; -add_trans -( -self -i -state_id -r -dup_id -) -; -} -SplitRange -: -: -New -( -r -) -= -> -{ -/ -/ -This -is -a -bit -subtle -but -if -this -happens -to -be -/ -/ -the -last -partition -in -our -split -it -is -possible -/ -/ -that -this -overlaps -with -a -subsequent -transition -. -/ -/ -If -it -does -then -we -must -repeat -the -whole -/ -/ -splitting -process -over -again -with -r -and -the -/ -/ -subsequent -transition -. -{ -let -trans -= -& -self -. -state -( -state_id -) -. -transitions -; -if -j -+ -1 -= -= -splits -. -len -( -) -& -& -i -< -trans -. -len -( -) -& -& -intersects -( -r -trans -[ -i -] -. -range -) -{ -new -= -r -; -continue -' -OUTER -; -} -} -/ -/ -. -. -. -otherwise -setup -exploration -for -a -new -/ -/ -empty -state -and -add -a -brand -new -transition -for -/ -/ -this -new -range -. -let -next_id -= -NextInsert -: -: -push -( -self -& -mut -stack -rest -) -; -add_trans -( -self -i -state_id -r -next_id -) -; -} -SplitRange -: -: -Both -( -r -) -= -> -{ -/ -/ -Continue -adding -the -remaining -ranges -on -this -/ -/ -path -and -update -the -transition -with -the -new -/ -/ -range -. -if -! -rest -. -is_empty -( -) -{ -stack -. -push -( -NextInsert -: -: -new -( -old -. -next_id -rest -) -) -; -} -add_trans -( -self -i -state_id -r -old -. -next_id -) -; -} -} -i -+ -= -1 -; -} -/ -/ -If -we -' -ve -reached -this -point -then -we -know -that -there -are -/ -/ -no -subsequent -transitions -with -any -overlap -. -Therefore -we -/ -/ -can -stop -processing -this -range -and -move -on -to -the -next -one -. -break -; -} -} -self -. -insert_stack -= -stack -; -} -pub -fn -add_empty -( -& -mut -self -) -- -> -StateID -{ -let -id -= -match -StateID -: -: -try_from -( -self -. -states -. -len -( -) -) -{ -Ok -( -id -) -= -> -id -Err -( -_ -) -= -> -{ -/ -/ -This -generally -should -not -happen -since -a -range -trie -is -/ -/ -only -ever -used -to -compile -a -single -sequence -of -Unicode -/ -/ -scalar -values -. -If -we -ever -got -to -this -point -we -would -at -/ -/ -* -minimum -* -be -using -96GB -in -just -the -range -trie -alone -. -panic -! -( -" -too -many -sequences -added -to -range -trie -" -) -; -} -} -; -/ -/ -If -we -have -some -free -states -available -then -use -them -to -avoid -/ -/ -more -allocations -. -if -let -Some -( -mut -state -) -= -self -. -free -. -pop -( -) -{ -state -. -clear -( -) -; -self -. -states -. -push -( -state -) -; -} -else -{ -self -. -states -. -push -( -State -{ -transitions -: -vec -! -[ -] -} -) -; -} -id -} -/ -/ -/ -Performs -a -deep -clone -of -the -given -state -and -returns -the -duplicate -' -s -/ -/ -/ -state -ID -. -/ -/ -/ -/ -/ -/ -A -" -deep -clone -" -in -this -context -means -that -the -state -given -along -with -/ -/ -/ -recursively -all -states -that -it -points -to -are -copied -. -Once -complete -/ -/ -/ -the -given -state -ID -and -the -returned -state -ID -share -nothing -. -/ -/ -/ -/ -/ -/ -This -is -useful -during -range -trie -insertion -when -a -new -range -overlaps -/ -/ -/ -with -an -existing -range -that -is -bigger -than -the -new -one -. -The -part -/ -/ -/ -of -the -existing -range -that -does -* -not -* -overlap -with -the -new -one -is -/ -/ -/ -duplicated -so -that -adding -the -new -range -to -the -overlap -doesn -' -t -disturb -/ -/ -/ -the -non -- -overlapping -portion -. -/ -/ -/ -/ -/ -/ -There -' -s -one -exception -: -if -old_id -is -the -final -state -then -it -is -not -/ -/ -/ -duplicated -and -the -same -final -state -is -returned -. -This -is -because -all -/ -/ -/ -final -states -in -this -trie -are -equivalent -. -fn -duplicate -( -& -mut -self -old_id -: -StateID -) -- -> -StateID -{ -if -old_id -= -= -FINAL -{ -return -FINAL -; -} -let -mut -stack -= -mem -: -: -replace -( -& -mut -self -. -dupe_stack -vec -! -[ -] -) -; -stack -. -clear -( -) -; -let -new_id -= -self -. -add_empty -( -) -; -/ -/ -old_id -is -the -state -we -' -re -cloning -and -new_id -is -the -ID -of -the -/ -/ -duplicated -state -for -old_id -. -stack -. -push -( -NextDupe -{ -old_id -new_id -} -) -; -while -let -Some -( -NextDupe -{ -old_id -new_id -} -) -= -stack -. -pop -( -) -{ -for -i -in -0 -. -. -self -. -state -( -old_id -) -. -transitions -. -len -( -) -{ -let -t -= -self -. -state -( -old_id -) -. -transitions -[ -i -] -. -clone -( -) -; -if -t -. -next_id -= -= -FINAL -{ -/ -/ -All -final -states -are -the -same -so -there -' -s -no -need -to -/ -/ -duplicate -it -. -self -. -add_transition -( -new_id -t -. -range -FINAL -) -; -continue -; -} -let -new_child_id -= -self -. -add_empty -( -) -; -self -. -add_transition -( -new_id -t -. -range -new_child_id -) -; -stack -. -push -( -NextDupe -{ -old_id -: -t -. -next_id -new_id -: -new_child_id -} -) -; -} -} -self -. -dupe_stack -= -stack -; -new_id -} -/ -/ -/ -Adds -the -given -transition -to -the -given -state -. -/ -/ -/ -/ -/ -/ -Callers -must -ensure -that -all -previous -transitions -in -this -state -/ -/ -/ -are -lexicographically -smaller -than -the -given -range -. -fn -add_transition -( -& -mut -self -from_id -: -StateID -range -: -Utf8Range -next_id -: -StateID -) -{ -self -. -state_mut -( -from_id -) -. -transitions -. -push -( -Transition -{ -range -next_id -} -) -; -} -/ -/ -/ -Like -add_transition -except -this -inserts -the -transition -just -before -/ -/ -/ -the -ith -transition -. -fn -add_transition_at -( -& -mut -self -i -: -usize -from_id -: -StateID -range -: -Utf8Range -next_id -: -StateID -) -{ -self -. -state_mut -( -from_id -) -. -transitions -. -insert -( -i -Transition -{ -range -next_id -} -) -; -} -/ -/ -/ -Overwrites -the -transition -at -position -i -with -the -given -transition -. -fn -set_transition_at -( -& -mut -self -i -: -usize -from_id -: -StateID -range -: -Utf8Range -next_id -: -StateID -) -{ -self -. -state_mut -( -from_id -) -. -transitions -[ -i -] -= -Transition -{ -range -next_id -} -; -} -/ -/ -/ -Return -an -immutable -borrow -for -the -state -with -the -given -ID -. -fn -state -( -& -self -id -: -StateID -) -- -> -& -State -{ -& -self -. -states -[ -id -] -} -/ -/ -/ -Return -a -mutable -borrow -for -the -state -with -the -given -ID -. -fn -state_mut -( -& -mut -self -id -: -StateID -) -- -> -& -mut -State -{ -& -mut -self -. -states -[ -id -] -} -} -impl -State -{ -/ -/ -/ -Find -the -position -at -which -the -given -range -should -be -inserted -in -this -/ -/ -/ -state -. -/ -/ -/ -/ -/ -/ -The -position -returned -is -always -in -the -inclusive -range -/ -/ -/ -[ -0 -transitions -. -len -( -) -] -. -If -' -transitions -. -len -( -) -' -is -returned -then -the -/ -/ -/ -given -range -overlaps -with -no -other -range -in -this -state -* -and -* -is -greater -/ -/ -/ -than -all -of -them -. -/ -/ -/ -/ -/ -/ -For -all -other -possible -positions -the -given -range -either -overlaps -/ -/ -/ -with -the -transition -at -that -position -or -is -otherwise -less -than -it -/ -/ -/ -with -no -overlap -( -and -is -greater -than -the -previous -transition -) -. -In -the -/ -/ -/ -former -case -careful -attention -must -be -paid -to -inserting -this -range -/ -/ -/ -as -a -new -transition -. -In -the -latter -case -the -range -can -be -inserted -as -/ -/ -/ -a -new -transition -at -the -given -position -without -disrupting -any -other -/ -/ -/ -transitions -. -fn -find -( -& -self -range -: -Utf8Range -) -- -> -usize -{ -/ -/ -/ -Returns -the -position -i -at -which -pred -( -xs -[ -i -] -) -first -returns -true -/ -/ -/ -such -that -for -all -j -> -= -i -pred -( -xs -[ -j -] -) -= -= -true -. -If -pred -never -/ -/ -/ -returns -true -then -xs -. -len -( -) -is -returned -. -/ -/ -/ -/ -/ -/ -We -roll -our -own -binary -search -because -it -doesn -' -t -seem -like -the -/ -/ -/ -standard -library -' -s -binary -search -can -be -used -here -. -Namely -if -/ -/ -/ -there -is -an -overlapping -range -then -we -want -to -find -the -first -such -/ -/ -/ -occurrence -but -there -may -be -many -. -Or -at -least -it -' -s -not -quite -/ -/ -/ -clear -to -me -how -to -do -it -. -fn -binary_search -< -T -F -> -( -xs -: -& -[ -T -] -mut -pred -: -F -) -- -> -usize -where -F -: -FnMut -( -& -T -) -- -> -bool -{ -let -( -mut -left -mut -right -) -= -( -0 -xs -. -len -( -) -) -; -while -left -< -right -{ -/ -/ -Overflow -is -impossible -because -xs -. -len -( -) -< -= -256 -. -let -mid -= -( -left -+ -right -) -/ -2 -; -if -pred -( -& -xs -[ -mid -] -) -{ -right -= -mid -; -} -else -{ -left -= -mid -+ -1 -; -} -} -left -} -/ -/ -Benchmarks -suggest -that -binary -search -is -just -a -bit -faster -than -/ -/ -straight -linear -search -. -Specifically -when -using -the -debug -tool -: -/ -/ -/ -/ -hyperfine -" -regex -- -cli -debug -nfa -thompson -- -- -quiet -- -- -reverse -' -\ -w -{ -90 -} -ecurB -' -" -binary_search -( -& -self -. -transitions -| -t -| -range -. -start -< -= -t -. -range -. -end -) -} -/ -/ -/ -Clear -this -state -such -that -it -has -zero -transitions -. -fn -clear -( -& -mut -self -) -{ -self -. -transitions -. -clear -( -) -; -} -} -/ -/ -/ -The -next -state -to -process -during -duplication -. -# -[ -derive -( -Clone -Debug -) -] -struct -NextDupe -{ -/ -/ -/ -The -state -we -want -to -duplicate -. -old_id -: -StateID -/ -/ -/ -The -ID -of -the -new -state -that -is -a -duplicate -of -old_id -. -new_id -: -StateID -} -/ -/ -/ -The -next -state -( -and -its -corresponding -transition -) -that -we -want -to -visit -/ -/ -/ -during -iteration -in -lexicographic -order -. -# -[ -derive -( -Clone -Debug -) -] -struct -NextIter -{ -state_id -: -StateID -tidx -: -usize -} -/ -/ -/ -The -next -state -to -process -during -insertion -and -any -remaining -ranges -that -we -/ -/ -/ -want -to -add -for -a -particular -sequence -of -ranges -. -The -first -such -instance -/ -/ -/ -is -always -the -root -state -along -with -all -ranges -given -. -# -[ -derive -( -Clone -Debug -) -] -struct -NextInsert -{ -/ -/ -/ -The -next -state -to -begin -inserting -ranges -. -This -state -should -be -the -/ -/ -/ -state -at -which -ranges -[ -0 -] -should -be -inserted -. -state_id -: -StateID -/ -/ -/ -The -ranges -to -insert -. -We -used -a -fixed -- -size -array -here -to -avoid -an -/ -/ -/ -allocation -. -ranges -: -[ -Utf8Range -; -4 -] -/ -/ -/ -The -number -of -valid -ranges -in -the -above -array -. -len -: -u8 -} -impl -NextInsert -{ -/ -/ -/ -Create -the -next -item -to -visit -. -The -given -state -ID -should -correspond -/ -/ -/ -to -the -state -at -which -the -first -range -in -the -given -slice -should -be -/ -/ -/ -inserted -. -The -slice -given -must -not -be -empty -and -it -must -be -no -longer -/ -/ -/ -than -4 -. -fn -new -( -state_id -: -StateID -ranges -: -& -[ -Utf8Range -] -) -- -> -NextInsert -{ -let -len -= -ranges -. -len -( -) -; -assert -! -( -len -> -0 -) -; -assert -! -( -len -< -= -4 -) -; -let -mut -tmp -= -[ -Utf8Range -{ -start -: -0 -end -: -0 -} -; -4 -] -; -tmp -[ -. -. -len -] -. -copy_from_slice -( -ranges -) -; -NextInsert -{ -state_id -ranges -: -tmp -len -: -u8 -: -: -try_from -( -len -) -. -unwrap -( -) -} -} -/ -/ -/ -Push -a -new -empty -state -to -visit -along -with -any -remaining -ranges -that -/ -/ -/ -still -need -to -be -inserted -. -The -ID -of -the -new -empty -state -is -returned -. -/ -/ -/ -/ -/ -/ -If -ranges -is -empty -then -no -new -state -is -created -and -FINAL -is -returned -. -fn -push -( -trie -: -& -mut -RangeTrie -stack -: -& -mut -Vec -< -NextInsert -> -ranges -: -& -[ -Utf8Range -] -) -- -> -StateID -{ -if -ranges -. -is_empty -( -) -{ -FINAL -} -else -{ -let -next_id -= -trie -. -add_empty -( -) -; -stack -. -push -( -NextInsert -: -: -new -( -next_id -ranges -) -) -; -next_id -} -} -/ -/ -/ -Return -the -ID -of -the -state -to -visit -. -fn -state_id -( -& -self -) -- -> -StateID -{ -self -. -state_id -} -/ -/ -/ -Return -the -remaining -ranges -to -insert -. -fn -ranges -( -& -self -) -- -> -& -[ -Utf8Range -] -{ -& -self -. -ranges -[ -. -. -usize -: -: -try_from -( -self -. -len -) -. -unwrap -( -) -] -} -} -/ -/ -/ -Split -represents -a -partitioning -of -two -ranges -into -one -or -more -ranges -. -This -/ -/ -/ -is -the -secret -sauce -that -makes -a -range -trie -work -as -it -' -s -what -tells -us -/ -/ -/ -how -to -deal -with -two -overlapping -but -unequal -ranges -during -insertion -. -/ -/ -/ -/ -/ -/ -Essentially -either -two -ranges -overlap -or -they -don -' -t -. -If -they -don -' -t -then -/ -/ -/ -handling -insertion -is -easy -: -just -insert -the -new -range -into -its -/ -/ -/ -lexicographically -correct -position -. -Since -it -does -not -overlap -with -anything -/ -/ -/ -else -no -other -transitions -are -impacted -by -the -new -range -. -/ -/ -/ -/ -/ -/ -If -they -do -overlap -though -there -are -generally -three -possible -cases -to -/ -/ -/ -handle -: -/ -/ -/ -/ -/ -/ -1 -. -The -part -where -the -two -ranges -actually -overlap -. -i -. -e -. -The -intersection -. -/ -/ -/ -2 -. -The -part -of -the -existing -range -that -is -not -in -the -the -new -range -. -/ -/ -/ -3 -. -The -part -of -the -new -range -that -is -not -in -the -old -range -. -/ -/ -/ -/ -/ -/ -( -1 -) -is -guaranteed -to -always -occur -since -all -overlapping -ranges -have -a -/ -/ -/ -non -- -empty -intersection -. -If -the -two -ranges -are -not -equivalent -then -at -/ -/ -/ -least -one -of -( -2 -) -or -( -3 -) -is -guaranteed -to -occur -as -well -. -In -some -cases -/ -/ -/ -e -. -g -. -[ -0 -- -4 -] -and -[ -4 -- -9 -] -all -three -cases -will -occur -. -/ -/ -/ -/ -/ -/ -This -Split -type -is -responsible -for -providing -( -1 -) -( -2 -) -and -( -3 -) -for -any -/ -/ -/ -possible -pair -of -byte -ranges -. -/ -/ -/ -/ -/ -/ -As -for -insertion -for -the -overlap -in -( -1 -) -the -remaining -ranges -to -insert -/ -/ -/ -should -be -added -by -following -the -corresponding -transition -. -However -this -/ -/ -/ -should -only -be -done -for -the -overlapping -parts -of -the -range -. -If -there -was -/ -/ -/ -a -part -of -the -existing -range -that -was -not -in -the -new -range -then -that -/ -/ -/ -existing -part -must -be -split -off -from -the -transition -and -duplicated -. -The -/ -/ -/ -remaining -parts -of -the -overlap -can -then -be -added -to -using -the -new -ranges -/ -/ -/ -without -disturbing -the -existing -range -. -/ -/ -/ -/ -/ -/ -Handling -the -case -for -the -part -of -a -new -range -that -is -not -in -an -existing -/ -/ -/ -range -is -seemingly -easy -. -Just -treat -it -as -if -it -were -a -non -- -overlapping -/ -/ -/ -range -. -The -problem -here -is -that -if -this -new -non -- -overlapping -range -occurs -/ -/ -/ -after -both -( -1 -) -and -( -2 -) -then -it -' -s -possible -that -it -can -overlap -with -the -/ -/ -/ -next -transition -in -the -current -state -. -If -it -does -then -the -whole -process -/ -/ -/ -must -be -repeated -! -/ -/ -/ -/ -/ -/ -# -Details -of -the -3 -cases -/ -/ -/ -/ -/ -/ -The -following -details -the -various -cases -that -are -implemented -in -code -/ -/ -/ -below -. -It -' -s -plausible -that -the -number -of -cases -is -not -actually -minimal -/ -/ -/ -but -it -' -s -important -for -this -code -to -remain -at -least -somewhat -readable -. -/ -/ -/ -/ -/ -/ -Given -[ -a -b -] -and -[ -x -y -] -where -a -< -= -b -x -< -= -y -b -< -256 -and -y -< -256 -we -define -/ -/ -/ -the -follow -distinct -relationships -where -at -least -one -must -apply -. -The -order -/ -/ -/ -of -these -matters -since -multiple -can -match -. -The -first -to -match -applies -. -/ -/ -/ -/ -/ -/ -1 -. -b -< -x -< -= -> -[ -a -b -] -< -[ -x -y -] -/ -/ -/ -2 -. -y -< -a -< -= -> -[ -x -y -] -< -[ -a -b -] -/ -/ -/ -/ -/ -/ -In -the -case -of -( -1 -) -and -( -2 -) -these -are -the -only -cases -where -there -is -no -/ -/ -/ -overlap -. -Or -otherwise -the -intersection -of -[ -a -b -] -and -[ -x -y -] -is -empty -. -In -/ -/ -/ -order -to -compute -the -intersection -one -can -do -[ -max -( -a -x -) -min -( -b -y -) -] -. -The -/ -/ -/ -intersection -in -all -of -the -following -cases -is -non -- -empty -. -/ -/ -/ -/ -/ -/ -3 -. -a -= -x -& -& -b -= -y -< -= -> -[ -a -b -] -= -= -[ -x -y -] -/ -/ -/ -4 -. -a -= -x -& -& -b -< -y -< -= -> -[ -x -y -] -right -- -extends -[ -a -b -] -/ -/ -/ -5 -. -b -= -y -& -& -a -> -x -< -= -> -[ -x -y -] -left -- -extends -[ -a -b -] -/ -/ -/ -6 -. -x -= -a -& -& -y -< -b -< -= -> -[ -a -b -] -right -- -extends -[ -x -y -] -/ -/ -/ -7 -. -y -= -b -& -& -x -> -a -< -= -> -[ -a -b -] -left -- -extends -[ -x -y -] -/ -/ -/ -8 -. -a -> -x -& -& -b -< -y -< -= -> -[ -x -y -] -covers -[ -a -b -] -/ -/ -/ -9 -. -x -> -a -& -& -y -< -b -< -= -> -[ -a -b -] -covers -[ -x -y -] -/ -/ -/ -10 -. -b -= -x -& -& -a -< -y -< -= -> -[ -a -b -] -is -left -- -adjacent -to -[ -x -y -] -/ -/ -/ -11 -. -y -= -a -& -& -x -< -b -< -= -> -[ -x -y -] -is -left -- -adjacent -to -[ -a -b -] -/ -/ -/ -12 -. -b -> -x -& -& -b -< -y -< -= -> -[ -a -b -] -left -- -overlaps -[ -x -y -] -/ -/ -/ -13 -. -y -> -a -& -& -y -< -b -< -= -> -[ -x -y -] -left -- -overlaps -[ -a -b -] -/ -/ -/ -/ -/ -/ -In -cases -3 -- -13 -we -can -form -rules -that -partition -the -ranges -into -a -/ -/ -/ -non -- -overlapping -ordered -sequence -of -ranges -: -/ -/ -/ -/ -/ -/ -3 -. -[ -a -b -] -/ -/ -/ -4 -. -[ -a -b -] -[ -b -+ -1 -y -] -/ -/ -/ -5 -. -[ -x -a -- -1 -] -[ -a -b -] -/ -/ -/ -6 -. -[ -x -y -] -[ -y -+ -1 -b -] -/ -/ -/ -7 -. -[ -a -x -- -1 -] -[ -x -y -] -/ -/ -/ -8 -. -[ -x -a -- -1 -] -[ -a -b -] -[ -b -+ -1 -y -] -/ -/ -/ -9 -. -[ -a -x -- -1 -] -[ -x -y -] -[ -y -+ -1 -b -] -/ -/ -/ -10 -. -[ -a -b -- -1 -] -[ -b -b -] -[ -b -+ -1 -y -] -/ -/ -/ -11 -. -[ -x -y -- -1 -] -[ -y -y -] -[ -y -+ -1 -b -] -/ -/ -/ -12 -. -[ -a -x -- -1 -] -[ -x -b -] -[ -b -+ -1 -y -] -/ -/ -/ -13 -. -[ -x -a -- -1 -] -[ -a -y -] -[ -y -+ -1 -b -] -/ -/ -/ -/ -/ -/ -In -the -code -below -we -go -a -step -further -and -identify -each -of -the -above -/ -/ -/ -outputs -as -belonging -either -to -the -overlap -of -the -two -ranges -or -to -one -/ -/ -/ -of -[ -a -b -] -or -[ -x -y -] -exclusively -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -struct -Split -{ -partitions -: -[ -SplitRange -; -3 -] -len -: -usize -} -/ -/ -/ -A -tagged -range -indicating -how -it -was -derived -from -a -pair -of -ranges -. -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -enum -SplitRange -{ -Old -( -Utf8Range -) -New -( -Utf8Range -) -Both -( -Utf8Range -) -} -impl -Split -{ -/ -/ -/ -Create -a -partitioning -of -the -given -ranges -. -/ -/ -/ -/ -/ -/ -If -the -given -ranges -have -an -empty -intersection -then -None -is -returned -. -fn -new -( -o -: -Utf8Range -n -: -Utf8Range -) -- -> -Option -< -Split -> -{ -let -range -= -| -r -: -RangeInclusive -< -u8 -> -| -Utf8Range -{ -start -: -* -r -. -start -( -) -end -: -* -r -. -end -( -) -} -; -let -old -= -| -r -| -SplitRange -: -: -Old -( -range -( -r -) -) -; -let -new -= -| -r -| -SplitRange -: -: -New -( -range -( -r -) -) -; -let -both -= -| -r -| -SplitRange -: -: -Both -( -range -( -r -) -) -; -/ -/ -Use -same -names -as -the -comment -above -to -make -it -easier -to -compare -. -let -( -a -b -x -y -) -= -( -o -. -start -o -. -end -n -. -start -n -. -end -) -; -if -b -< -x -| -| -y -< -a -{ -/ -/ -case -1 -case -2 -None -} -else -if -a -= -= -x -& -& -b -= -= -y -{ -/ -/ -case -3 -Some -( -Split -: -: -parts1 -( -both -( -a -. -. -= -b -) -) -) -} -else -if -a -= -= -x -& -& -b -< -y -{ -/ -/ -case -4 -Some -( -Split -: -: -parts2 -( -both -( -a -. -. -= -b -) -new -( -b -+ -1 -. -. -= -y -) -) -) -} -else -if -b -= -= -y -& -& -a -> -x -{ -/ -/ -case -5 -Some -( -Split -: -: -parts2 -( -new -( -x -. -. -= -a -- -1 -) -both -( -a -. -. -= -b -) -) -) -} -else -if -x -= -= -a -& -& -y -< -b -{ -/ -/ -case -6 -Some -( -Split -: -: -parts2 -( -both -( -x -. -. -= -y -) -old -( -y -+ -1 -. -. -= -b -) -) -) -} -else -if -y -= -= -b -& -& -x -> -a -{ -/ -/ -case -7 -Some -( -Split -: -: -parts2 -( -old -( -a -. -. -= -x -- -1 -) -both -( -x -. -. -= -y -) -) -) -} -else -if -a -> -x -& -& -b -< -y -{ -/ -/ -case -8 -Some -( -Split -: -: -parts3 -( -new -( -x -. -. -= -a -- -1 -) -both -( -a -. -. -= -b -) -new -( -b -+ -1 -. -. -= -y -) -) -) -} -else -if -x -> -a -& -& -y -< -b -{ -/ -/ -case -9 -Some -( -Split -: -: -parts3 -( -old -( -a -. -. -= -x -- -1 -) -both -( -x -. -. -= -y -) -old -( -y -+ -1 -. -. -= -b -) -) -) -} -else -if -b -= -= -x -& -& -a -< -y -{ -/ -/ -case -10 -Some -( -Split -: -: -parts3 -( -old -( -a -. -. -= -b -- -1 -) -both -( -b -. -. -= -b -) -new -( -b -+ -1 -. -. -= -y -) -) -) -} -else -if -y -= -= -a -& -& -x -< -b -{ -/ -/ -case -11 -Some -( -Split -: -: -parts3 -( -new -( -x -. -. -= -y -- -1 -) -both -( -y -. -. -= -y -) -old -( -y -+ -1 -. -. -= -b -) -) -) -} -else -if -b -> -x -& -& -b -< -y -{ -/ -/ -case -12 -Some -( -Split -: -: -parts3 -( -old -( -a -. -. -= -x -- -1 -) -both -( -x -. -. -= -b -) -new -( -b -+ -1 -. -. -= -y -) -) -) -} -else -if -y -> -a -& -& -y -< -b -{ -/ -/ -case -13 -Some -( -Split -: -: -parts3 -( -new -( -x -. -. -= -a -- -1 -) -both -( -a -. -. -= -y -) -old -( -y -+ -1 -. -. -= -b -) -) -) -} -else -{ -unreachable -! -( -) -} -} -/ -/ -/ -Create -a -new -split -with -a -single -partition -. -This -only -occurs -when -two -/ -/ -/ -ranges -are -equivalent -. -fn -parts1 -( -r1 -: -SplitRange -) -- -> -Split -{ -/ -/ -This -value -doesn -' -t -matter -since -it -is -never -accessed -. -let -nada -= -SplitRange -: -: -Old -( -Utf8Range -{ -start -: -0 -end -: -0 -} -) -; -Split -{ -partitions -: -[ -r1 -nada -nada -] -len -: -1 -} -} -/ -/ -/ -Create -a -new -split -with -two -partitions -. -fn -parts2 -( -r1 -: -SplitRange -r2 -: -SplitRange -) -- -> -Split -{ -/ -/ -This -value -doesn -' -t -matter -since -it -is -never -accessed -. -let -nada -= -SplitRange -: -: -Old -( -Utf8Range -{ -start -: -0 -end -: -0 -} -) -; -Split -{ -partitions -: -[ -r1 -r2 -nada -] -len -: -2 -} -} -/ -/ -/ -Create -a -new -split -with -three -partitions -. -fn -parts3 -( -r1 -: -SplitRange -r2 -: -SplitRange -r3 -: -SplitRange -) -- -> -Split -{ -Split -{ -partitions -: -[ -r1 -r2 -r3 -] -len -: -3 -} -} -/ -/ -/ -Return -the -partitions -in -this -split -as -a -slice -. -fn -as_slice -( -& -self -) -- -> -& -[ -SplitRange -] -{ -& -self -. -partitions -[ -. -. -self -. -len -] -} -} -impl -fmt -: -: -Debug -for -RangeTrie -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -writeln -! -( -f -" -" -) -? -; -for -( -i -state -) -in -self -. -states -. -iter -( -) -. -enumerate -( -) -{ -let -status -= -if -i -= -= -FINAL -. -as_usize -( -) -{ -' -* -' -} -else -{ -' -' -} -; -writeln -! -( -f -" -{ -} -{ -: -06 -} -: -{ -: -? -} -" -status -i -state -) -? -; -} -Ok -( -( -) -) -} -} -impl -fmt -: -: -Debug -for -State -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -let -rs -= -self -. -transitions -. -iter -( -) -. -map -( -| -t -| -format -! -( -" -{ -: -? -} -" -t -) -) -. -collect -: -: -< -Vec -< -String -> -> -( -) -. -join -( -" -" -) -; -write -! -( -f -" -{ -} -" -rs -) -} -} -impl -fmt -: -: -Debug -for -Transition -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -< -' -_ -> -) -- -> -fmt -: -: -Result -{ -if -self -. -range -. -start -= -= -self -. -range -. -end -{ -write -! -( -f -" -{ -: -02X -} -= -> -{ -: -02X -} -" -self -. -range -. -start -self -. -next_id -. -as_usize -( -) -) -} -else -{ -write -! -( -f -" -{ -: -02X -} -- -{ -: -02X -} -= -> -{ -: -02X -} -" -self -. -range -. -start -self -. -range -. -end -self -. -next_id -. -as_usize -( -) -) -} -} -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -ranges -intersect -. -fn -intersects -( -r1 -: -Utf8Range -r2 -: -Utf8Range -) -- -> -bool -{ -! -( -r1 -. -end -< -r2 -. -start -| -| -r2 -. -end -< -r1 -. -start -) -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -core -: -: -ops -: -: -RangeInclusive -; -use -regex_syntax -: -: -utf8 -: -: -Utf8Range -; -use -super -: -: -* -; -fn -r -( -range -: -RangeInclusive -< -u8 -> -) -- -> -Utf8Range -{ -Utf8Range -{ -start -: -* -range -. -start -( -) -end -: -* -range -. -end -( -) -} -} -fn -split_maybe -( -old -: -RangeInclusive -< -u8 -> -new -: -RangeInclusive -< -u8 -> -) -- -> -Option -< -Split -> -{ -Split -: -: -new -( -r -( -old -) -r -( -new -) -) -} -fn -split -( -old -: -RangeInclusive -< -u8 -> -new -: -RangeInclusive -< -u8 -> -) -- -> -Vec -< -SplitRange -> -{ -split_maybe -( -old -new -) -. -unwrap -( -) -. -as_slice -( -) -. -to_vec -( -) -} -# -[ -test -] -fn -no_splits -( -) -{ -/ -/ -case -1 -assert_eq -! -( -None -split_maybe -( -0 -. -. -= -1 -2 -. -. -= -3 -) -) -; -/ -/ -case -2 -assert_eq -! -( -None -split_maybe -( -2 -. -. -= -3 -0 -. -. -= -1 -) -) -; -} -# -[ -test -] -fn -splits -( -) -{ -let -range -= -| -r -: -RangeInclusive -< -u8 -> -| -Utf8Range -{ -start -: -* -r -. -start -( -) -end -: -* -r -. -end -( -) -} -; -let -old -= -| -r -| -SplitRange -: -: -Old -( -range -( -r -) -) -; -let -new -= -| -r -| -SplitRange -: -: -New -( -range -( -r -) -) -; -let -both -= -| -r -| -SplitRange -: -: -Both -( -range -( -r -) -) -; -/ -/ -case -3 -assert_eq -! -( -split -( -0 -. -. -= -0 -0 -. -. -= -0 -) -vec -! -[ -both -( -0 -. -. -= -0 -) -] -) -; -assert_eq -! -( -split -( -9 -. -. -= -9 -9 -. -. -= -9 -) -vec -! -[ -both -( -9 -. -. -= -9 -) -] -) -; -/ -/ -case -4 -assert_eq -! -( -split -( -0 -. -. -= -5 -0 -. -. -= -6 -) -vec -! -[ -both -( -0 -. -. -= -5 -) -new -( -6 -. -. -= -6 -) -] -) -; -assert_eq -! -( -split -( -0 -. -. -= -5 -0 -. -. -= -8 -) -vec -! -[ -both -( -0 -. -. -= -5 -) -new -( -6 -. -. -= -8 -) -] -) -; -assert_eq -! -( -split -( -5 -. -. -= -5 -5 -. -. -= -8 -) -vec -! -[ -both -( -5 -. -. -= -5 -) -new -( -6 -. -. -= -8 -) -] -) -; -/ -/ -case -5 -assert_eq -! -( -split -( -1 -. -. -= -5 -0 -. -. -= -5 -) -vec -! -[ -new -( -0 -. -. -= -0 -) -both -( -1 -. -. -= -5 -) -] -) -; -assert_eq -! -( -split -( -3 -. -. -= -5 -0 -. -. -= -5 -) -vec -! -[ -new -( -0 -. -. -= -2 -) -both -( -3 -. -. -= -5 -) -] -) -; -assert_eq -! -( -split -( -5 -. -. -= -5 -0 -. -. -= -5 -) -vec -! -[ -new -( -0 -. -. -= -4 -) -both -( -5 -. -. -= -5 -) -] -) -; -/ -/ -case -6 -assert_eq -! -( -split -( -0 -. -. -= -6 -0 -. -. -= -5 -) -vec -! -[ -both -( -0 -. -. -= -5 -) -old -( -6 -. -. -= -6 -) -] -) -; -assert_eq -! -( -split -( -0 -. -. -= -8 -0 -. -. -= -5 -) -vec -! -[ -both -( -0 -. -. -= -5 -) -old -( -6 -. -. -= -8 -) -] -) -; -assert_eq -! -( -split -( -5 -. -. -= -8 -5 -. -. -= -5 -) -vec -! -[ -both -( -5 -. -. -= -5 -) -old -( -6 -. -. -= -8 -) -] -) -; -/ -/ -case -7 -assert_eq -! -( -split -( -0 -. -. -= -5 -1 -. -. -= -5 -) -vec -! -[ -old -( -0 -. -. -= -0 -) -both -( -1 -. -. -= -5 -) -] -) -; -assert_eq -! -( -split -( -0 -. -. -= -5 -3 -. -. -= -5 -) -vec -! -[ -old -( -0 -. -. -= -2 -) -both -( -3 -. -. -= -5 -) -] -) -; -assert_eq -! -( -split -( -0 -. -. -= -5 -5 -. -. -= -5 -) -vec -! -[ -old -( -0 -. -. -= -4 -) -both -( -5 -. -. -= -5 -) -] -) -; -/ -/ -case -8 -assert_eq -! -( -split -( -3 -. -. -= -6 -2 -. -. -= -7 -) -vec -! -[ -new -( -2 -. -. -= -2 -) -both -( -3 -. -. -= -6 -) -new -( -7 -. -. -= -7 -) -] -) -; -assert_eq -! -( -split -( -3 -. -. -= -6 -1 -. -. -= -8 -) -vec -! -[ -new -( -1 -. -. -= -2 -) -both -( -3 -. -. -= -6 -) -new -( -7 -. -. -= -8 -) -] -) -; -/ -/ -case -9 -assert_eq -! -( -split -( -2 -. -. -= -7 -3 -. -. -= -6 -) -vec -! -[ -old -( -2 -. -. -= -2 -) -both -( -3 -. -. -= -6 -) -old -( -7 -. -. -= -7 -) -] -) -; -assert_eq -! -( -split -( -1 -. -. -= -8 -3 -. -. -= -6 -) -vec -! -[ -old -( -1 -. -. -= -2 -) -both -( -3 -. -. -= -6 -) -old -( -7 -. -. -= -8 -) -] -) -; -/ -/ -case -10 -assert_eq -! -( -split -( -3 -. -. -= -6 -6 -. -. -= -7 -) -vec -! -[ -old -( -3 -. -. -= -5 -) -both -( -6 -. -. -= -6 -) -new -( -7 -. -. -= -7 -) -] -) -; -assert_eq -! -( -split -( -3 -. -. -= -6 -6 -. -. -= -8 -) -vec -! -[ -old -( -3 -. -. -= -5 -) -both -( -6 -. -. -= -6 -) -new -( -7 -. -. -= -8 -) -] -) -; -assert_eq -! -( -split -( -5 -. -. -= -6 -6 -. -. -= -7 -) -vec -! -[ -old -( -5 -. -. -= -5 -) -both -( -6 -. -. -= -6 -) -new -( -7 -. -. -= -7 -) -] -) -; -/ -/ -case -11 -assert_eq -! -( -split -( -6 -. -. -= -7 -3 -. -. -= -6 -) -vec -! -[ -new -( -3 -. -. -= -5 -) -both -( -6 -. -. -= -6 -) -old -( -7 -. -. -= -7 -) -] -) -; -assert_eq -! -( -split -( -6 -. -. -= -8 -3 -. -. -= -6 -) -vec -! -[ -new -( -3 -. -. -= -5 -) -both -( -6 -. -. -= -6 -) -old -( -7 -. -. -= -8 -) -] -) -; -assert_eq -! -( -split -( -6 -. -. -= -7 -5 -. -. -= -6 -) -vec -! -[ -new -( -5 -. -. -= -5 -) -both -( -6 -. -. -= -6 -) -old -( -7 -. -. -= -7 -) -] -) -; -/ -/ -case -12 -assert_eq -! -( -split -( -3 -. -. -= -7 -5 -. -. -= -9 -) -vec -! -[ -old -( -3 -. -. -= -4 -) -both -( -5 -. -. -= -7 -) -new -( -8 -. -. -= -9 -) -] -) -; -assert_eq -! -( -split -( -3 -. -. -= -5 -4 -. -. -= -6 -) -vec -! -[ -old -( -3 -. -. -= -3 -) -both -( -4 -. -. -= -5 -) -new -( -6 -. -. -= -6 -) -] -) -; -/ -/ -case -13 -assert_eq -! -( -split -( -5 -. -. -= -9 -3 -. -. -= -7 -) -vec -! -[ -new -( -3 -. -. -= -4 -) -both -( -5 -. -. -= -7 -) -old -( -8 -. -. -= -9 -) -] -) -; -assert_eq -! -( -split -( -4 -. -. -= -6 -3 -. -. -= -5 -) -vec -! -[ -new -( -3 -. -. -= -3 -) -both -( -4 -. -. -= -5 -) -old -( -6 -. -. -= -6 -) -] -) -; -} -/ -/ -Arguably -there -should -be -more -tests -here -but -in -practice -this -data -/ -/ -structure -is -well -covered -by -the -huge -number -of -regex -tests -. -} diff --git a/third_party/rust/regex-automata/src/util/alphabet.rs b/third_party/rust/regex-automata/src/util/alphabet.rs deleted file mode 100644 index 1cb54270ef6b8..0000000000000 --- a/third_party/rust/regex-automata/src/util/alphabet.rs +++ /dev/null @@ -1,10518 +0,0 @@ -/ -* -! -This -module -provides -APIs -for -dealing -with -the -alphabets -of -finite -state -machines -. -There -are -two -principal -types -in -this -module -[ -ByteClasses -] -and -[ -Unit -] -. -The -former -defines -the -alphabet -of -a -finite -state -machine -while -the -latter -represents -an -element -of -that -alphabet -. -To -a -first -approximation -the -alphabet -of -all -automata -in -this -crate -is -just -a -u8 -. -Namely -every -distinct -byte -value -. -All -256 -of -them -. -In -practice -this -can -be -quite -wasteful -when -building -a -transition -table -for -a -DFA -since -it -requires -storing -a -state -identifier -for -each -element -in -the -alphabet -. -Instead -we -collapse -the -alphabet -of -an -automaton -down -into -equivalence -classes -where -every -byte -in -the -same -equivalence -class -never -discriminates -between -a -match -or -a -non -- -match -from -any -other -byte -in -the -same -class -. -For -example -in -the -regex -[ -a -- -z -] -+ -then -you -could -consider -it -having -an -alphabet -consisting -of -two -equivalence -classes -: -a -- -z -and -everything -else -. -In -terms -of -the -transitions -on -an -automaton -it -doesn -' -t -actually -require -representing -every -distinct -byte -. -Just -the -equivalence -classes -. -The -downside -of -equivalence -classes -is -that -of -course -searching -a -haystack -deals -with -individual -byte -values -. -Those -byte -values -need -to -be -mapped -to -their -corresponding -equivalence -class -. -This -is -what -ByteClasses -does -. -In -practice -doing -this -for -every -state -transition -has -negligible -impact -on -modern -CPUs -. -Moreover -it -helps -make -more -efficient -use -of -the -CPU -cache -by -( -possibly -considerably -) -shrinking -the -size -of -the -transition -table -. -One -last -hiccup -concerns -Unit -. -Namely -because -of -look -- -around -and -how -the -DFAs -in -this -crate -work -we -need -to -add -a -sentinel -value -to -our -alphabet -of -equivalence -classes -that -represents -the -" -end -" -of -a -search -. -We -call -that -sentinel -[ -Unit -: -: -eoi -] -or -" -end -of -input -. -" -Thus -a -Unit -is -either -an -equivalence -class -corresponding -to -a -set -of -bytes -or -it -is -a -special -" -end -of -input -" -sentinel -. -In -general -you -should -not -expect -to -need -either -of -these -types -unless -you -' -re -doing -lower -level -shenanigans -with -DFAs -or -even -building -your -own -DFAs -. -( -Although -you -don -' -t -have -to -use -these -types -to -build -your -own -DFAs -of -course -. -) -For -example -if -you -' -re -walking -a -DFA -' -s -state -graph -it -' -s -probably -useful -to -make -use -of -[ -ByteClasses -] -to -visit -each -element -in -the -DFA -' -s -alphabet -instead -of -just -visiting -every -distinct -u8 -value -. -The -latter -isn -' -t -necessarily -wrong -but -it -could -be -potentially -very -wasteful -. -* -/ -use -crate -: -: -util -: -: -{ -escape -: -: -DebugByte -wire -: -: -{ -self -DeserializeError -SerializeError -} -} -; -/ -/ -/ -Unit -represents -a -single -unit -of -haystack -for -DFA -based -regex -engines -. -/ -/ -/ -/ -/ -/ -It -is -not -expected -for -consumers -of -this -crate -to -need -to -use -this -type -/ -/ -/ -unless -they -are -implementing -their -own -DFA -. -And -even -then -it -' -s -not -/ -/ -/ -required -: -implementors -may -use -other -techniques -to -handle -haystack -units -. -/ -/ -/ -/ -/ -/ -Typically -a -single -unit -of -haystack -for -a -DFA -would -be -a -single -byte -. -/ -/ -/ -However -for -the -DFAs -in -this -crate -matches -are -delayed -by -a -single -byte -/ -/ -/ -in -order -to -handle -look -- -ahead -assertions -( -\ -b -and -\ -z -) -. -Thus -once -/ -/ -/ -we -have -consumed -the -haystack -we -must -run -the -DFA -through -one -additional -/ -/ -/ -transition -using -a -unit -that -indicates -the -haystack -has -ended -. -/ -/ -/ -/ -/ -/ -There -is -no -way -to -represent -a -sentinel -with -a -u8 -since -all -possible -/ -/ -/ -values -* -may -* -be -valid -haystack -units -to -a -DFA -therefore -this -type -/ -/ -/ -explicitly -adds -room -for -a -sentinel -value -. -/ -/ -/ -/ -/ -/ -The -sentinel -EOI -value -is -always -its -own -equivalence -class -and -is -/ -/ -/ -ultimately -represented -by -adding -1 -to -the -maximum -equivalence -class -value -. -/ -/ -/ -So -for -example -the -regex -^ -[ -a -- -z -] -+ -might -be -split -into -the -following -/ -/ -/ -equivalence -classes -: -/ -/ -/ -/ -/ -/ -text -/ -/ -/ -0 -= -> -[ -\ -x00 -- -] -/ -/ -/ -1 -= -> -[ -a -- -z -] -/ -/ -/ -2 -= -> -[ -{ -- -\ -xFF -] -/ -/ -/ -3 -= -> -[ -EOI -] -/ -/ -/ -/ -/ -/ -/ -/ -/ -Where -EOI -is -the -special -sentinel -value -that -is -always -in -its -own -/ -/ -/ -singleton -equivalence -class -. -# -[ -derive -( -Clone -Copy -Eq -PartialEq -PartialOrd -Ord -) -] -pub -struct -Unit -( -UnitKind -) -; -# -[ -derive -( -Clone -Copy -Eq -PartialEq -PartialOrd -Ord -) -] -enum -UnitKind -{ -/ -/ -/ -Represents -a -byte -value -or -more -typically -an -equivalence -class -/ -/ -/ -represented -as -a -byte -value -. -U8 -( -u8 -) -/ -/ -/ -Represents -the -" -end -of -input -" -sentinel -. -We -regretably -use -a -u16 -/ -/ -/ -here -since -the -maximum -sentinel -value -is -256 -. -Thankfully -we -don -' -t -/ -/ -/ -actually -store -a -Unit -anywhere -so -this -extra -space -shouldn -' -t -be -too -/ -/ -/ -bad -. -EOI -( -u16 -) -} -impl -Unit -{ -/ -/ -/ -Create -a -new -haystack -unit -from -a -byte -value -. -/ -/ -/ -/ -/ -/ -All -possible -byte -values -are -legal -. -However -when -creating -a -haystack -/ -/ -/ -unit -for -a -specific -DFA -one -should -be -careful -to -only -construct -units -/ -/ -/ -that -are -in -that -DFA -' -s -alphabet -. -Namely -one -way -to -compact -a -DFA -' -s -/ -/ -/ -in -- -memory -representation -is -to -collapse -its -transitions -to -a -set -of -/ -/ -/ -equivalence -classes -into -a -set -of -all -possible -byte -values -. -If -a -DFA -/ -/ -/ -uses -equivalence -classes -instead -of -byte -values -then -the -byte -given -/ -/ -/ -here -should -be -the -equivalence -class -. -pub -fn -u8 -( -byte -: -u8 -) -- -> -Unit -{ -Unit -( -UnitKind -: -: -U8 -( -byte -) -) -} -/ -/ -/ -Create -a -new -" -end -of -input -" -haystack -unit -. -/ -/ -/ -/ -/ -/ -The -value -given -is -the -sentinel -value -used -by -this -unit -to -represent -/ -/ -/ -the -" -end -of -input -. -" -The -value -should -be -the -total -number -of -equivalence -/ -/ -/ -classes -in -the -corresponding -alphabet -. -Its -maximum -value -is -256 -/ -/ -/ -which -occurs -when -every -byte -is -its -own -equivalence -class -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -num_byte_equiv_classes -is -greater -than -256 -. -pub -fn -eoi -( -num_byte_equiv_classes -: -usize -) -- -> -Unit -{ -assert -! -( -num_byte_equiv_classes -< -= -256 -" -max -number -of -byte -- -based -equivalent -classes -is -256 -but -got -{ -} -" -num_byte_equiv_classes -) -; -Unit -( -UnitKind -: -: -EOI -( -u16 -: -: -try_from -( -num_byte_equiv_classes -) -. -unwrap -( -) -) -) -} -/ -/ -/ -If -this -unit -is -not -an -" -end -of -input -" -sentinel -then -returns -its -/ -/ -/ -underlying -byte -value -. -Otherwise -return -None -. -pub -fn -as_u8 -( -self -) -- -> -Option -< -u8 -> -{ -match -self -. -0 -{ -UnitKind -: -: -U8 -( -b -) -= -> -Some -( -b -) -UnitKind -: -: -EOI -( -_ -) -= -> -None -} -} -/ -/ -/ -If -this -unit -is -an -" -end -of -input -" -sentinel -then -return -the -underlying -/ -/ -/ -sentinel -value -that -was -given -to -[ -Unit -: -: -eoi -] -. -Otherwise -return -/ -/ -/ -None -. -pub -fn -as_eoi -( -self -) -- -> -Option -< -u16 -> -{ -match -self -. -0 -{ -UnitKind -: -: -U8 -( -_ -) -= -> -None -UnitKind -: -: -EOI -( -sentinel -) -= -> -Some -( -sentinel -) -} -} -/ -/ -/ -Return -this -unit -as -a -usize -regardless -of -whether -it -is -a -byte -value -/ -/ -/ -or -an -" -end -of -input -" -sentinel -. -In -the -latter -case -the -underlying -/ -/ -/ -sentinel -value -given -to -[ -Unit -: -: -eoi -] -is -returned -. -pub -fn -as_usize -( -self -) -- -> -usize -{ -match -self -. -0 -{ -UnitKind -: -: -U8 -( -b -) -= -> -usize -: -: -from -( -b -) -UnitKind -: -: -EOI -( -eoi -) -= -> -usize -: -: -from -( -eoi -) -} -} -/ -/ -/ -Returns -true -if -and -only -of -this -unit -is -a -byte -value -equivalent -to -the -/ -/ -/ -byte -given -. -This -always -returns -false -when -this -is -an -" -end -of -input -" -/ -/ -/ -sentinel -. -pub -fn -is_byte -( -self -byte -: -u8 -) -- -> -bool -{ -self -. -as_u8 -( -) -. -map_or -( -false -| -b -| -b -= -= -byte -) -} -/ -/ -/ -Returns -true -when -this -unit -represents -an -" -end -of -input -" -sentinel -. -pub -fn -is_eoi -( -self -) -- -> -bool -{ -self -. -as_eoi -( -) -. -is_some -( -) -} -/ -/ -/ -Returns -true -when -this -unit -corresponds -to -an -ASCII -word -byte -. -/ -/ -/ -/ -/ -/ -This -always -returns -false -when -this -unit -represents -an -" -end -of -input -" -/ -/ -/ -sentinel -. -pub -fn -is_word_byte -( -self -) -- -> -bool -{ -self -. -as_u8 -( -) -. -map_or -( -false -crate -: -: -util -: -: -utf8 -: -: -is_word_byte -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -Unit -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -match -self -. -0 -{ -UnitKind -: -: -U8 -( -b -) -= -> -write -! -( -f -" -{ -: -? -} -" -DebugByte -( -b -) -) -UnitKind -: -: -EOI -( -_ -) -= -> -write -! -( -f -" -EOI -" -) -} -} -} -/ -/ -/ -A -representation -of -byte -oriented -equivalence -classes -. -/ -/ -/ -/ -/ -/ -This -is -used -in -a -DFA -to -reduce -the -size -of -the -transition -table -. -This -can -/ -/ -/ -have -a -particularly -large -impact -not -only -on -the -total -size -of -a -dense -DFA -/ -/ -/ -but -also -on -compile -times -. -/ -/ -/ -/ -/ -/ -The -essential -idea -here -is -that -the -alphabet -of -a -DFA -is -shrunk -from -the -/ -/ -/ -usual -256 -distinct -byte -values -down -to -a -set -of -equivalence -classes -. -The -/ -/ -/ -guarantee -you -get -is -that -any -byte -belonging -to -the -same -equivalence -class -/ -/ -/ -can -be -treated -as -if -it -were -any -other -byte -in -the -same -class -and -the -/ -/ -/ -result -of -a -search -wouldn -' -t -change -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -byte -classes -from -an -/ -/ -/ -[ -NFA -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -) -and -ask -for -the -class -of -various -bytes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -classes -= -nfa -. -byte_classes -( -) -; -/ -/ -/ -/ -/ -' -a -' -and -' -z -' -are -in -the -same -class -for -this -regex -. -/ -/ -/ -assert_eq -! -( -classes -. -get -( -b -' -a -' -) -classes -. -get -( -b -' -z -' -) -) -; -/ -/ -/ -/ -/ -But -' -a -' -and -' -A -' -are -not -. -/ -/ -/ -assert_ne -! -( -classes -. -get -( -b -' -a -' -) -classes -. -get -( -b -' -A -' -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Copy -) -] -pub -struct -ByteClasses -( -[ -u8 -; -256 -] -) -; -impl -ByteClasses -{ -/ -/ -/ -Creates -a -new -set -of -equivalence -classes -where -all -bytes -are -mapped -to -/ -/ -/ -the -same -class -. -# -[ -inline -] -pub -fn -empty -( -) -- -> -ByteClasses -{ -ByteClasses -( -[ -0 -; -256 -] -) -} -/ -/ -/ -Creates -a -new -set -of -equivalence -classes -where -each -byte -belongs -to -/ -/ -/ -its -own -equivalence -class -. -# -[ -inline -] -pub -fn -singletons -( -) -- -> -ByteClasses -{ -let -mut -classes -= -ByteClasses -: -: -empty -( -) -; -for -b -in -0 -. -. -= -255 -{ -classes -. -set -( -b -b -) -; -} -classes -} -/ -/ -/ -Deserializes -a -byte -class -map -from -the -given -slice -. -If -the -slice -is -of -/ -/ -/ -insufficient -length -or -otherwise -contains -an -impossible -mapping -then -/ -/ -/ -an -error -is -returned -. -Upon -success -the -number -of -bytes -read -along -with -/ -/ -/ -the -map -are -returned -. -The -number -of -bytes -read -is -always -a -multiple -of -/ -/ -/ -8 -. -pub -( -crate -) -fn -from_bytes -( -slice -: -& -[ -u8 -] -) -- -> -Result -< -( -ByteClasses -usize -) -DeserializeError -> -{ -wire -: -: -check_slice_len -( -slice -256 -" -byte -class -map -" -) -? -; -let -mut -classes -= -ByteClasses -: -: -empty -( -) -; -for -( -b -& -class -) -in -slice -[ -. -. -256 -] -. -iter -( -) -. -enumerate -( -) -{ -classes -. -set -( -u8 -: -: -try_from -( -b -) -. -unwrap -( -) -class -) -; -} -/ -/ -We -specifically -don -' -t -use -' -classes -. -iter -( -) -' -here -because -that -/ -/ -iterator -depends -on -' -classes -. -alphabet_len -( -) -' -being -correct -. -But -that -/ -/ -is -precisely -the -thing -we -' -re -trying -to -verify -below -! -for -& -b -in -classes -. -0 -. -iter -( -) -{ -if -usize -: -: -from -( -b -) -> -= -classes -. -alphabet_len -( -) -{ -return -Err -( -DeserializeError -: -: -generic -( -" -found -equivalence -class -greater -than -alphabet -len -" -) -) -; -} -} -Ok -( -( -classes -256 -) -) -} -/ -/ -/ -Writes -this -byte -class -map -to -the -given -byte -buffer -. -if -the -given -/ -/ -/ -buffer -is -too -small -then -an -error -is -returned -. -Upon -success -the -total -/ -/ -/ -number -of -bytes -written -is -returned -. -The -number -of -bytes -written -is -/ -/ -/ -guaranteed -to -be -a -multiple -of -8 -. -pub -( -crate -) -fn -write_to -( -& -self -mut -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -byte -class -map -" -) -) -; -} -for -b -in -0 -. -. -= -255 -{ -dst -[ -0 -] -= -self -. -get -( -b -) -; -dst -= -& -mut -dst -[ -1 -. -. -] -; -} -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -total -number -of -bytes -written -by -write_to -. -pub -( -crate -) -fn -write_to_len -( -& -self -) -- -> -usize -{ -256 -} -/ -/ -/ -Set -the -equivalence -class -for -the -given -byte -. -# -[ -inline -] -pub -fn -set -( -& -mut -self -byte -: -u8 -class -: -u8 -) -{ -self -. -0 -[ -usize -: -: -from -( -byte -) -] -= -class -; -} -/ -/ -/ -Get -the -equivalence -class -for -the -given -byte -. -# -[ -inline -] -pub -fn -get -( -& -self -byte -: -u8 -) -- -> -u8 -{ -self -. -0 -[ -usize -: -: -from -( -byte -) -] -} -/ -/ -/ -Get -the -equivalence -class -for -the -given -haystack -unit -and -return -the -/ -/ -/ -class -as -a -usize -. -# -[ -inline -] -pub -fn -get_by_unit -( -& -self -unit -: -Unit -) -- -> -usize -{ -match -unit -. -0 -{ -UnitKind -: -: -U8 -( -b -) -= -> -usize -: -: -from -( -self -. -get -( -b -) -) -UnitKind -: -: -EOI -( -b -) -= -> -usize -: -: -from -( -b -) -} -} -/ -/ -/ -Create -a -unit -that -represents -the -" -end -of -input -" -sentinel -based -on -the -/ -/ -/ -number -of -equivalence -classes -. -# -[ -inline -] -pub -fn -eoi -( -& -self -) -- -> -Unit -{ -/ -/ -The -alphabet -length -already -includes -the -EOI -sentinel -hence -why -/ -/ -we -subtract -1 -. -Unit -: -: -eoi -( -self -. -alphabet_len -( -) -. -checked_sub -( -1 -) -. -unwrap -( -) -) -} -/ -/ -/ -Return -the -total -number -of -elements -in -the -alphabet -represented -by -/ -/ -/ -these -equivalence -classes -. -Equivalently -this -returns -the -total -number -/ -/ -/ -of -equivalence -classes -. -# -[ -inline -] -pub -fn -alphabet_len -( -& -self -) -- -> -usize -{ -/ -/ -Add -one -since -the -number -of -equivalence -classes -is -one -bigger -than -/ -/ -the -last -one -. -But -add -another -to -account -for -the -final -EOI -class -/ -/ -that -isn -' -t -explicitly -represented -. -usize -: -: -from -( -self -. -0 -[ -255 -] -) -+ -1 -+ -1 -} -/ -/ -/ -Returns -the -stride -as -a -base -- -2 -exponent -required -for -these -/ -/ -/ -equivalence -classes -. -/ -/ -/ -/ -/ -/ -The -stride -is -always -the -smallest -power -of -2 -that -is -greater -than -or -/ -/ -/ -equal -to -the -alphabet -length -and -the -stride2 -returned -here -is -the -/ -/ -/ -exponent -applied -to -2 -to -get -the -smallest -power -. -This -is -done -so -that -/ -/ -/ -converting -between -premultiplied -state -IDs -and -indices -can -be -done -with -/ -/ -/ -shifts -alone -which -is -much -faster -than -integer -division -. -# -[ -inline -] -pub -fn -stride2 -( -& -self -) -- -> -usize -{ -let -zeros -= -self -. -alphabet_len -( -) -. -next_power_of_two -( -) -. -trailing_zeros -( -) -; -usize -: -: -try_from -( -zeros -) -. -unwrap -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -every -byte -in -this -class -maps -to -its -own -/ -/ -/ -equivalence -class -. -Equivalently -there -are -257 -equivalence -classes -/ -/ -/ -and -each -class -contains -either -exactly -one -byte -or -corresponds -to -the -/ -/ -/ -singleton -class -containing -the -" -end -of -input -" -sentinel -. -# -[ -inline -] -pub -fn -is_singleton -( -& -self -) -- -> -bool -{ -self -. -alphabet_len -( -) -= -= -257 -} -/ -/ -/ -Returns -an -iterator -over -all -equivalence -classes -in -this -set -. -# -[ -inline -] -pub -fn -iter -( -& -self -) -- -> -ByteClassIter -< -' -_ -> -{ -ByteClassIter -{ -classes -: -self -i -: -0 -} -} -/ -/ -/ -Returns -an -iterator -over -a -sequence -of -representative -bytes -from -each -/ -/ -/ -equivalence -class -within -the -range -of -bytes -given -. -/ -/ -/ -/ -/ -/ -When -the -given -range -is -unbounded -on -both -sides -the -iterator -yields -/ -/ -/ -exactly -N -items -where -N -is -equivalent -to -the -number -of -equivalence -/ -/ -/ -classes -. -Each -item -is -an -arbitrary -byte -drawn -from -each -equivalence -/ -/ -/ -class -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -one -is -determinizing -an -NFA -and -the -NFA -' -s -alphabet -/ -/ -/ -hasn -' -t -been -converted -to -equivalence -classes -. -Picking -an -arbitrary -byte -/ -/ -/ -from -each -equivalence -class -then -permits -a -full -exploration -of -the -NFA -/ -/ -/ -instead -of -using -every -possible -byte -value -and -thus -potentially -saves -/ -/ -/ -quite -a -lot -of -redundant -work -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -an -example -of -what -a -complete -sequence -of -representatives -/ -/ -/ -might -look -like -from -a -real -example -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -util -: -: -alphabet -: -: -Unit -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -classes -= -nfa -. -byte_classes -( -) -; -/ -/ -/ -let -reps -: -Vec -< -Unit -> -= -classes -. -representatives -( -. -. -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Note -that -the -specific -byte -values -yielded -are -not -guaranteed -! -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -Unit -: -: -u8 -( -b -' -\ -x00 -' -) -/ -/ -/ -Unit -: -: -u8 -( -b -' -a -' -) -/ -/ -/ -Unit -: -: -u8 -( -b -' -{ -' -) -/ -/ -/ -Unit -: -: -eoi -( -3 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -reps -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -though -that -you -can -ask -for -an -arbitrary -range -of -bytes -and -only -/ -/ -/ -representatives -for -that -range -will -be -returned -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -util -: -: -alphabet -: -: -Unit -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -classes -= -nfa -. -byte_classes -( -) -; -/ -/ -/ -let -reps -: -Vec -< -Unit -> -= -classes -. -representatives -( -b -' -A -' -. -. -= -b -' -z -' -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Note -that -the -specific -byte -values -yielded -are -not -guaranteed -! -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -Unit -: -: -u8 -( -b -' -A -' -) -/ -/ -/ -Unit -: -: -u8 -( -b -' -a -' -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -reps -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -representatives -< -R -: -core -: -: -ops -: -: -RangeBounds -< -u8 -> -> -( -& -self -range -: -R -) -- -> -ByteClassRepresentatives -< -' -_ -> -{ -use -core -: -: -ops -: -: -Bound -; -let -cur_byte -= -match -range -. -start_bound -( -) -{ -Bound -: -: -Included -( -& -i -) -= -> -usize -: -: -from -( -i -) -Bound -: -: -Excluded -( -& -i -) -= -> -usize -: -: -from -( -i -) -. -checked_add -( -1 -) -. -unwrap -( -) -Bound -: -: -Unbounded -= -> -0 -} -; -let -end_byte -= -match -range -. -end_bound -( -) -{ -Bound -: -: -Included -( -& -i -) -= -> -{ -Some -( -usize -: -: -from -( -i -) -. -checked_add -( -1 -) -. -unwrap -( -) -) -} -Bound -: -: -Excluded -( -& -i -) -= -> -Some -( -usize -: -: -from -( -i -) -) -Bound -: -: -Unbounded -= -> -None -} -; -assert_ne -! -( -cur_byte -usize -: -: -MAX -" -start -range -must -be -less -than -usize -: -: -MAX -" -) -; -ByteClassRepresentatives -{ -classes -: -self -cur_byte -end_byte -last_class -: -None -} -} -/ -/ -/ -Returns -an -iterator -of -the -bytes -in -the -given -equivalence -class -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -one -needs -to -know -the -actual -bytes -that -belong -to -/ -/ -/ -an -equivalence -class -. -For -example -conceptually -speaking -accelerating -/ -/ -/ -a -DFA -state -occurs -when -a -state -only -has -a -few -outgoing -transitions -. -/ -/ -/ -But -in -reality -what -is -required -is -that -there -are -only -a -small -/ -/ -/ -number -of -distinct -bytes -that -can -lead -to -an -outgoing -transition -. -The -/ -/ -/ -difference -is -that -any -one -transition -can -correspond -to -an -equivalence -/ -/ -/ -class -which -may -contains -many -bytes -. -Therefore -DFA -state -acceleration -/ -/ -/ -considers -the -actual -elements -in -each -equivalence -class -of -each -/ -/ -/ -outgoing -transition -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -an -example -of -how -to -get -all -of -the -elements -in -an -/ -/ -/ -equivalence -class -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -util -: -: -alphabet -: -: -Unit -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -classes -= -nfa -. -byte_classes -( -) -; -/ -/ -/ -let -elements -: -Vec -< -Unit -> -= -classes -. -elements -( -Unit -: -: -u8 -( -1 -) -) -. -collect -( -) -; -/ -/ -/ -let -expected -: -Vec -< -Unit -> -= -( -b -' -a -' -. -. -= -b -' -z -' -) -. -map -( -Unit -: -: -u8 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -elements -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -elements -( -& -self -class -: -Unit -) -- -> -ByteClassElements -{ -ByteClassElements -{ -classes -: -self -class -byte -: -0 -} -} -/ -/ -/ -Returns -an -iterator -of -byte -ranges -in -the -given -equivalence -class -. -/ -/ -/ -/ -/ -/ -That -is -a -sequence -of -contiguous -ranges -are -returned -. -Typically -every -/ -/ -/ -class -maps -to -a -single -contiguous -range -. -fn -element_ranges -( -& -self -class -: -Unit -) -- -> -ByteClassElementRanges -{ -ByteClassElementRanges -{ -elements -: -self -. -elements -( -class -) -range -: -None -} -} -} -impl -Default -for -ByteClasses -{ -fn -default -( -) -- -> -ByteClasses -{ -ByteClasses -: -: -singletons -( -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -ByteClasses -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -if -self -. -is_singleton -( -) -{ -write -! -( -f -" -ByteClasses -( -{ -{ -singletons -} -} -) -" -) -} -else -{ -write -! -( -f -" -ByteClasses -( -" -) -? -; -for -( -i -class -) -in -self -. -iter -( -) -. -enumerate -( -) -{ -if -i -> -0 -{ -write -! -( -f -" -" -) -? -; -} -write -! -( -f -" -{ -: -? -} -= -> -[ -" -class -. -as_usize -( -) -) -? -; -for -( -start -end -) -in -self -. -element_ranges -( -class -) -{ -if -start -= -= -end -{ -write -! -( -f -" -{ -: -? -} -" -start -) -? -; -} -else -{ -write -! -( -f -" -{ -: -? -} -- -{ -: -? -} -" -start -end -) -? -; -} -} -write -! -( -f -" -] -" -) -? -; -} -write -! -( -f -" -) -" -) -} -} -} -/ -/ -/ -An -iterator -over -each -equivalence -class -. -/ -/ -/ -/ -/ -/ -The -last -element -in -this -iterator -always -corresponds -to -[ -Unit -: -: -eoi -] -. -/ -/ -/ -/ -/ -/ -This -is -created -by -the -[ -ByteClasses -: -: -iter -] -method -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -byte -classes -that -this -/ -/ -/ -iterator -was -created -from -. -# -[ -derive -( -Debug -) -] -pub -struct -ByteClassIter -< -' -a -> -{ -classes -: -& -' -a -ByteClasses -i -: -usize -} -impl -< -' -a -> -Iterator -for -ByteClassIter -< -' -a -> -{ -type -Item -= -Unit -; -fn -next -( -& -mut -self -) -- -> -Option -< -Unit -> -{ -if -self -. -i -+ -1 -= -= -self -. -classes -. -alphabet_len -( -) -{ -self -. -i -+ -= -1 -; -Some -( -self -. -classes -. -eoi -( -) -) -} -else -if -self -. -i -< -self -. -classes -. -alphabet_len -( -) -{ -let -class -= -u8 -: -: -try_from -( -self -. -i -) -. -unwrap -( -) -; -self -. -i -+ -= -1 -; -Some -( -Unit -: -: -u8 -( -class -) -) -} -else -{ -None -} -} -} -/ -/ -/ -An -iterator -over -representative -bytes -from -each -equivalence -class -. -/ -/ -/ -/ -/ -/ -This -is -created -by -the -[ -ByteClasses -: -: -representatives -] -method -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -byte -classes -that -this -/ -/ -/ -iterator -was -created -from -. -# -[ -derive -( -Debug -) -] -pub -struct -ByteClassRepresentatives -< -' -a -> -{ -classes -: -& -' -a -ByteClasses -cur_byte -: -usize -end_byte -: -Option -< -usize -> -last_class -: -Option -< -u8 -> -} -impl -< -' -a -> -Iterator -for -ByteClassRepresentatives -< -' -a -> -{ -type -Item -= -Unit -; -fn -next -( -& -mut -self -) -- -> -Option -< -Unit -> -{ -while -self -. -cur_byte -< -self -. -end_byte -. -unwrap_or -( -256 -) -{ -let -byte -= -u8 -: -: -try_from -( -self -. -cur_byte -) -. -unwrap -( -) -; -let -class -= -self -. -classes -. -get -( -byte -) -; -self -. -cur_byte -+ -= -1 -; -if -self -. -last_class -! -= -Some -( -class -) -{ -self -. -last_class -= -Some -( -class -) -; -return -Some -( -Unit -: -: -u8 -( -byte -) -) -; -} -} -if -self -. -cur_byte -! -= -usize -: -: -MAX -& -& -self -. -end_byte -. -is_none -( -) -{ -/ -/ -Using -usize -: -: -MAX -as -a -sentinel -is -OK -because -we -ban -usize -: -: -MAX -/ -/ -from -appearing -as -a -start -bound -in -iterator -construction -. -But -/ -/ -why -do -it -this -way -? -Well -we -want -to -return -the -EOI -class -/ -/ -whenever -the -end -of -the -given -range -is -unbounded -because -EOI -/ -/ -isn -' -t -really -a -" -byte -" -per -se -so -the -only -way -it -should -be -/ -/ -excluded -is -if -there -is -a -bounded -end -to -the -range -. -Therefore -/ -/ -when -the -end -is -unbounded -we -just -need -to -know -whether -we -' -ve -/ -/ -reported -EOI -or -not -. -When -we -do -we -set -cur_byte -to -a -value -it -/ -/ -can -never -otherwise -be -. -self -. -cur_byte -= -usize -: -: -MAX -; -return -Some -( -self -. -classes -. -eoi -( -) -) -; -} -None -} -} -/ -/ -/ -An -iterator -over -all -elements -in -an -equivalence -class -. -/ -/ -/ -/ -/ -/ -This -is -created -by -the -[ -ByteClasses -: -: -elements -] -method -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -byte -classes -that -this -/ -/ -/ -iterator -was -created -from -. -# -[ -derive -( -Debug -) -] -pub -struct -ByteClassElements -< -' -a -> -{ -classes -: -& -' -a -ByteClasses -class -: -Unit -byte -: -usize -} -impl -< -' -a -> -Iterator -for -ByteClassElements -< -' -a -> -{ -type -Item -= -Unit -; -fn -next -( -& -mut -self -) -- -> -Option -< -Unit -> -{ -while -self -. -byte -< -256 -{ -let -byte -= -u8 -: -: -try_from -( -self -. -byte -) -. -unwrap -( -) -; -self -. -byte -+ -= -1 -; -if -self -. -class -. -is_byte -( -self -. -classes -. -get -( -byte -) -) -{ -return -Some -( -Unit -: -: -u8 -( -byte -) -) -; -} -} -if -self -. -byte -< -257 -{ -self -. -byte -+ -= -1 -; -if -self -. -class -. -is_eoi -( -) -{ -return -Some -( -Unit -: -: -eoi -( -256 -) -) -; -} -} -None -} -} -/ -/ -/ -An -iterator -over -all -elements -in -an -equivalence -class -expressed -as -a -/ -/ -/ -sequence -of -contiguous -ranges -. -# -[ -derive -( -Debug -) -] -struct -ByteClassElementRanges -< -' -a -> -{ -elements -: -ByteClassElements -< -' -a -> -range -: -Option -< -( -Unit -Unit -) -> -} -impl -< -' -a -> -Iterator -for -ByteClassElementRanges -< -' -a -> -{ -type -Item -= -( -Unit -Unit -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -Unit -Unit -) -> -{ -loop -{ -let -element -= -match -self -. -elements -. -next -( -) -{ -None -= -> -return -self -. -range -. -take -( -) -Some -( -element -) -= -> -element -} -; -match -self -. -range -. -take -( -) -{ -None -= -> -{ -self -. -range -= -Some -( -( -element -element -) -) -; -} -Some -( -( -start -end -) -) -= -> -{ -if -end -. -as_usize -( -) -+ -1 -! -= -element -. -as_usize -( -) -| -| -element -. -is_eoi -( -) -{ -self -. -range -= -Some -( -( -element -element -) -) -; -return -Some -( -( -start -end -) -) -; -} -self -. -range -= -Some -( -( -start -element -) -) -; -} -} -} -} -} -/ -/ -/ -A -partitioning -of -bytes -into -equivalence -classes -. -/ -/ -/ -/ -/ -/ -A -byte -class -set -keeps -track -of -an -* -approximation -* -of -equivalence -classes -/ -/ -/ -of -bytes -during -NFA -construction -. -That -is -every -byte -in -an -equivalence -/ -/ -/ -class -cannot -discriminate -between -a -match -and -a -non -- -match -. -/ -/ -/ -/ -/ -/ -For -example -in -the -regex -[ -ab -] -+ -the -bytes -a -and -b -would -be -in -the -/ -/ -/ -same -equivalence -class -because -it -never -matters -whether -an -a -or -a -b -is -/ -/ -/ -seen -and -no -combination -of -a -s -and -b -s -in -the -text -can -discriminate -a -/ -/ -/ -match -. -/ -/ -/ -/ -/ -/ -Note -though -that -this -does -not -compute -the -minimal -set -of -equivalence -/ -/ -/ -classes -. -For -example -in -the -regex -[ -ac -] -+ -both -a -and -c -are -in -the -/ -/ -/ -same -equivalence -class -for -the -same -reason -that -a -and -b -are -in -the -/ -/ -/ -same -equivalence -class -in -the -aforementioned -regex -. -However -in -this -/ -/ -/ -implementation -a -and -c -are -put -into -distinct -equivalence -classes -. -The -/ -/ -/ -reason -for -this -is -implementation -complexity -. -In -the -future -we -should -/ -/ -/ -endeavor -to -compute -the -minimal -equivalence -classes -since -they -can -have -a -/ -/ -/ -rather -large -impact -on -the -size -of -the -DFA -. -( -Doing -this -will -likely -require -/ -/ -/ -rethinking -how -equivalence -classes -are -computed -including -changing -the -/ -/ -/ -representation -here -which -is -only -able -to -group -contiguous -bytes -into -the -/ -/ -/ -same -equivalence -class -. -) -# -[ -cfg -( -feature -= -" -alloc -" -) -] -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -ByteClassSet -( -ByteSet -) -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -Default -for -ByteClassSet -{ -fn -default -( -) -- -> -ByteClassSet -{ -ByteClassSet -: -: -empty -( -) -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -ByteClassSet -{ -/ -/ -/ -Create -a -new -set -of -byte -classes -where -all -bytes -are -part -of -the -same -/ -/ -/ -equivalence -class -. -pub -( -crate -) -fn -empty -( -) -- -> -Self -{ -ByteClassSet -( -ByteSet -: -: -empty -( -) -) -} -/ -/ -/ -Indicate -the -the -range -of -byte -given -( -inclusive -) -can -discriminate -a -/ -/ -/ -match -between -it -and -all -other -bytes -outside -of -the -range -. -pub -( -crate -) -fn -set_range -( -& -mut -self -start -: -u8 -end -: -u8 -) -{ -debug_assert -! -( -start -< -= -end -) -; -if -start -> -0 -{ -self -. -0 -. -add -( -start -- -1 -) -; -} -self -. -0 -. -add -( -end -) -; -} -/ -/ -/ -Add -the -contiguous -ranges -in -the -set -given -to -this -byte -class -set -. -pub -( -crate -) -fn -add_set -( -& -mut -self -set -: -& -ByteSet -) -{ -for -( -start -end -) -in -set -. -iter_ranges -( -) -{ -self -. -set_range -( -start -end -) -; -} -} -/ -/ -/ -Convert -this -boolean -set -to -a -map -that -maps -all -byte -values -to -their -/ -/ -/ -corresponding -equivalence -class -. -The -last -mapping -indicates -the -largest -/ -/ -/ -equivalence -class -identifier -( -which -is -never -bigger -than -255 -) -. -pub -( -crate -) -fn -byte_classes -( -& -self -) -- -> -ByteClasses -{ -let -mut -classes -= -ByteClasses -: -: -empty -( -) -; -let -mut -class -= -0u8 -; -let -mut -b -= -0u8 -; -loop -{ -classes -. -set -( -b -class -) -; -if -b -= -= -255 -{ -break -; -} -if -self -. -0 -. -contains -( -b -) -{ -class -= -class -. -checked_add -( -1 -) -. -unwrap -( -) -; -} -b -= -b -. -checked_add -( -1 -) -. -unwrap -( -) -; -} -classes -} -} -/ -/ -/ -A -simple -set -of -bytes -that -is -reasonably -cheap -to -copy -and -allocation -free -. -# -[ -derive -( -Clone -Copy -Debug -Default -Eq -PartialEq -) -] -pub -( -crate -) -struct -ByteSet -{ -bits -: -BitSet -} -/ -/ -/ -The -representation -of -a -byte -set -. -Split -out -so -that -we -can -define -a -/ -/ -/ -convenient -Debug -impl -for -it -while -keeping -" -ByteSet -" -in -the -output -. -# -[ -derive -( -Clone -Copy -Default -Eq -PartialEq -) -] -struct -BitSet -( -[ -u128 -; -2 -] -) -; -impl -ByteSet -{ -/ -/ -/ -Create -an -empty -set -of -bytes -. -pub -( -crate -) -fn -empty -( -) -- -> -ByteSet -{ -ByteSet -{ -bits -: -BitSet -( -[ -0 -; -2 -] -) -} -} -/ -/ -/ -Add -a -byte -to -this -set -. -/ -/ -/ -/ -/ -/ -If -the -given -byte -already -belongs -to -this -set -then -this -is -a -no -- -op -. -pub -( -crate -) -fn -add -( -& -mut -self -byte -: -u8 -) -{ -let -bucket -= -byte -/ -128 -; -let -bit -= -byte -% -128 -; -self -. -bits -. -0 -[ -usize -: -: -from -( -bucket -) -] -| -= -1 -< -< -bit -; -} -/ -/ -/ -Remove -a -byte -from -this -set -. -/ -/ -/ -/ -/ -/ -If -the -given -byte -is -not -in -this -set -then -this -is -a -no -- -op -. -pub -( -crate -) -fn -remove -( -& -mut -self -byte -: -u8 -) -{ -let -bucket -= -byte -/ -128 -; -let -bit -= -byte -% -128 -; -self -. -bits -. -0 -[ -usize -: -: -from -( -bucket -) -] -& -= -! -( -1 -< -< -bit -) -; -} -/ -/ -/ -Return -true -if -and -only -if -the -given -byte -is -in -this -set -. -pub -( -crate -) -fn -contains -( -& -self -byte -: -u8 -) -- -> -bool -{ -let -bucket -= -byte -/ -128 -; -let -bit -= -byte -% -128 -; -self -. -bits -. -0 -[ -usize -: -: -from -( -bucket -) -] -& -( -1 -< -< -bit -) -> -0 -} -/ -/ -/ -Return -true -if -and -only -if -the -given -inclusive -range -of -bytes -is -in -/ -/ -/ -this -set -. -pub -( -crate -) -fn -contains_range -( -& -self -start -: -u8 -end -: -u8 -) -- -> -bool -{ -( -start -. -. -= -end -) -. -all -( -| -b -| -self -. -contains -( -b -) -) -} -/ -/ -/ -Returns -an -iterator -over -all -bytes -in -this -set -. -pub -( -crate -) -fn -iter -( -& -self -) -- -> -ByteSetIter -{ -ByteSetIter -{ -set -: -self -b -: -0 -} -} -/ -/ -/ -Returns -an -iterator -over -all -contiguous -ranges -of -bytes -in -this -set -. -pub -( -crate -) -fn -iter_ranges -( -& -self -) -- -> -ByteSetRangeIter -{ -ByteSetRangeIter -{ -set -: -self -b -: -0 -} -} -/ -/ -/ -Return -true -if -and -only -if -this -set -is -empty -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -bits -. -0 -= -= -[ -0 -0 -] -} -/ -/ -/ -Deserializes -a -byte -set -from -the -given -slice -. -If -the -slice -is -of -/ -/ -/ -incorrect -length -or -is -otherwise -malformed -then -an -error -is -returned -. -/ -/ -/ -Upon -success -the -number -of -bytes -read -along -with -the -set -are -returned -. -/ -/ -/ -The -number -of -bytes -read -is -always -a -multiple -of -8 -. -pub -( -crate -) -fn -from_bytes -( -slice -: -& -[ -u8 -] -) -- -> -Result -< -( -ByteSet -usize -) -DeserializeError -> -{ -use -core -: -: -mem -: -: -size_of -; -wire -: -: -check_slice_len -( -slice -2 -* -size_of -: -: -< -u128 -> -( -) -" -byte -set -" -) -? -; -let -mut -nread -= -0 -; -let -( -low -nr -) -= -wire -: -: -try_read_u128 -( -slice -" -byte -set -low -bucket -" -) -? -; -nread -+ -= -nr -; -let -( -high -nr -) -= -wire -: -: -try_read_u128 -( -slice -" -byte -set -high -bucket -" -) -? -; -nread -+ -= -nr -; -Ok -( -( -ByteSet -{ -bits -: -BitSet -( -[ -low -high -] -) -} -nread -) -) -} -/ -/ -/ -Writes -this -byte -set -to -the -given -byte -buffer -. -If -the -given -buffer -is -/ -/ -/ -too -small -then -an -error -is -returned -. -Upon -success -the -total -number -of -/ -/ -/ -bytes -written -is -returned -. -The -number -of -bytes -written -is -guaranteed -to -/ -/ -/ -be -a -multiple -of -8 -. -pub -( -crate -) -fn -write_to -< -E -: -crate -: -: -util -: -: -wire -: -: -Endian -> -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -use -core -: -: -mem -: -: -size_of -; -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -byte -set -" -) -) -; -} -let -mut -nw -= -0 -; -E -: -: -write_u128 -( -self -. -bits -. -0 -[ -0 -] -& -mut -dst -[ -nw -. -. -] -) -; -nw -+ -= -size_of -: -: -< -u128 -> -( -) -; -E -: -: -write_u128 -( -self -. -bits -. -0 -[ -1 -] -& -mut -dst -[ -nw -. -. -] -) -; -nw -+ -= -size_of -: -: -< -u128 -> -( -) -; -assert_eq -! -( -nwrite -nw -" -expected -to -write -certain -number -of -bytes -" -) -; -assert_eq -! -( -nw -% -8 -0 -" -expected -to -write -multiple -of -8 -bytes -for -byte -set -" -) -; -Ok -( -nw -) -} -/ -/ -/ -Returns -the -total -number -of -bytes -written -by -write_to -. -pub -( -crate -) -fn -write_to_len -( -& -self -) -- -> -usize -{ -2 -* -core -: -: -mem -: -: -size_of -: -: -< -u128 -> -( -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -BitSet -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -fmtd -= -f -. -debug_set -( -) -; -for -b -in -0u8 -. -. -= -255 -{ -if -( -ByteSet -{ -bits -: -* -self -} -) -. -contains -( -b -) -{ -fmtd -. -entry -( -& -b -) -; -} -} -fmtd -. -finish -( -) -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -ByteSetIter -< -' -a -> -{ -set -: -& -' -a -ByteSet -b -: -usize -} -impl -< -' -a -> -Iterator -for -ByteSetIter -< -' -a -> -{ -type -Item -= -u8 -; -fn -next -( -& -mut -self -) -- -> -Option -< -u8 -> -{ -while -self -. -b -< -= -255 -{ -let -b -= -u8 -: -: -try_from -( -self -. -b -) -. -unwrap -( -) -; -self -. -b -+ -= -1 -; -if -self -. -set -. -contains -( -b -) -{ -return -Some -( -b -) -; -} -} -None -} -} -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -ByteSetRangeIter -< -' -a -> -{ -set -: -& -' -a -ByteSet -b -: -usize -} -impl -< -' -a -> -Iterator -for -ByteSetRangeIter -< -' -a -> -{ -type -Item -= -( -u8 -u8 -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -u8 -u8 -) -> -{ -let -asu8 -= -| -n -: -usize -| -u8 -: -: -try_from -( -n -) -. -unwrap -( -) -; -while -self -. -b -< -= -255 -{ -let -start -= -asu8 -( -self -. -b -) -; -self -. -b -+ -= -1 -; -if -! -self -. -set -. -contains -( -start -) -{ -continue -; -} -let -mut -end -= -start -; -while -self -. -b -< -= -255 -& -& -self -. -set -. -contains -( -asu8 -( -self -. -b -) -) -{ -end -= -asu8 -( -self -. -b -) -; -self -. -b -+ -= -1 -; -} -return -Some -( -( -start -end -) -) -; -} -None -} -} -# -[ -cfg -( -all -( -test -feature -= -" -alloc -" -) -) -] -mod -tests -{ -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -super -: -: -* -; -# -[ -test -] -fn -byte_classes -( -) -{ -let -mut -set -= -ByteClassSet -: -: -empty -( -) -; -set -. -set_range -( -b -' -a -' -b -' -z -' -) -; -let -classes -= -set -. -byte_classes -( -) -; -assert_eq -! -( -classes -. -get -( -0 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -1 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -2 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -b -' -a -' -- -1 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -b -' -a -' -) -1 -) -; -assert_eq -! -( -classes -. -get -( -b -' -m -' -) -1 -) -; -assert_eq -! -( -classes -. -get -( -b -' -z -' -) -1 -) -; -assert_eq -! -( -classes -. -get -( -b -' -z -' -+ -1 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -254 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -255 -) -2 -) -; -let -mut -set -= -ByteClassSet -: -: -empty -( -) -; -set -. -set_range -( -0 -2 -) -; -set -. -set_range -( -4 -6 -) -; -let -classes -= -set -. -byte_classes -( -) -; -assert_eq -! -( -classes -. -get -( -0 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -1 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -2 -) -0 -) -; -assert_eq -! -( -classes -. -get -( -3 -) -1 -) -; -assert_eq -! -( -classes -. -get -( -4 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -5 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -6 -) -2 -) -; -assert_eq -! -( -classes -. -get -( -7 -) -3 -) -; -assert_eq -! -( -classes -. -get -( -255 -) -3 -) -; -} -# -[ -test -] -fn -full_byte_classes -( -) -{ -let -mut -set -= -ByteClassSet -: -: -empty -( -) -; -for -b -in -0u8 -. -. -= -255 -{ -set -. -set_range -( -b -b -) -; -} -assert_eq -! -( -set -. -byte_classes -( -) -. -alphabet_len -( -) -257 -) -; -} -# -[ -test -] -fn -elements_typical -( -) -{ -let -mut -set -= -ByteClassSet -: -: -empty -( -) -; -set -. -set_range -( -b -' -b -' -b -' -d -' -) -; -set -. -set_range -( -b -' -g -' -b -' -m -' -) -; -set -. -set_range -( -b -' -z -' -b -' -z -' -) -; -let -classes -= -set -. -byte_classes -( -) -; -/ -/ -class -0 -: -\ -x00 -- -a -/ -/ -class -1 -: -b -- -d -/ -/ -class -2 -: -e -- -f -/ -/ -class -3 -: -g -- -m -/ -/ -class -4 -: -n -- -y -/ -/ -class -5 -: -z -- -z -/ -/ -class -6 -: -\ -x7B -- -\ -xFF -/ -/ -class -7 -: -EOI -assert_eq -! -( -classes -. -alphabet_len -( -) -8 -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -0 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -. -len -( -) -98 -) -; -assert_eq -! -( -elements -[ -0 -] -Unit -: -: -u8 -( -b -' -\ -x00 -' -) -) -; -assert_eq -! -( -elements -[ -97 -] -Unit -: -: -u8 -( -b -' -a -' -) -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -1 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -vec -! -[ -Unit -: -: -u8 -( -b -' -b -' -) -Unit -: -: -u8 -( -b -' -c -' -) -Unit -: -: -u8 -( -b -' -d -' -) -] -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -2 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -vec -! -[ -Unit -: -: -u8 -( -b -' -e -' -) -Unit -: -: -u8 -( -b -' -f -' -) -] -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -3 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -vec -! -[ -Unit -: -: -u8 -( -b -' -g -' -) -Unit -: -: -u8 -( -b -' -h -' -) -Unit -: -: -u8 -( -b -' -i -' -) -Unit -: -: -u8 -( -b -' -j -' -) -Unit -: -: -u8 -( -b -' -k -' -) -Unit -: -: -u8 -( -b -' -l -' -) -Unit -: -: -u8 -( -b -' -m -' -) -] -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -4 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -. -len -( -) -12 -) -; -assert_eq -! -( -elements -[ -0 -] -Unit -: -: -u8 -( -b -' -n -' -) -) -; -assert_eq -! -( -elements -[ -11 -] -Unit -: -: -u8 -( -b -' -y -' -) -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -5 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -vec -! -[ -Unit -: -: -u8 -( -b -' -z -' -) -] -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -6 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -. -len -( -) -133 -) -; -assert_eq -! -( -elements -[ -0 -] -Unit -: -: -u8 -( -b -' -\ -x7B -' -) -) -; -assert_eq -! -( -elements -[ -132 -] -Unit -: -: -u8 -( -b -' -\ -xFF -' -) -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -eoi -( -7 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -vec -! -[ -Unit -: -: -eoi -( -256 -) -] -) -; -} -# -[ -test -] -fn -elements_singletons -( -) -{ -let -classes -= -ByteClasses -: -: -singletons -( -) -; -assert_eq -! -( -classes -. -alphabet_len -( -) -257 -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -b -' -a -' -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -vec -! -[ -Unit -: -: -u8 -( -b -' -a -' -) -] -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -eoi -( -5 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -vec -! -[ -Unit -: -: -eoi -( -256 -) -] -) -; -} -# -[ -test -] -fn -elements_empty -( -) -{ -let -classes -= -ByteClasses -: -: -empty -( -) -; -assert_eq -! -( -classes -. -alphabet_len -( -) -2 -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -u8 -( -0 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -. -len -( -) -256 -) -; -assert_eq -! -( -elements -[ -0 -] -Unit -: -: -u8 -( -b -' -\ -x00 -' -) -) -; -assert_eq -! -( -elements -[ -255 -] -Unit -: -: -u8 -( -b -' -\ -xFF -' -) -) -; -let -elements -= -classes -. -elements -( -Unit -: -: -eoi -( -1 -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -; -assert_eq -! -( -elements -vec -! -[ -Unit -: -: -eoi -( -256 -) -] -) -; -} -# -[ -test -] -fn -representatives -( -) -{ -let -mut -set -= -ByteClassSet -: -: -empty -( -) -; -set -. -set_range -( -b -' -b -' -b -' -d -' -) -; -set -. -set_range -( -b -' -g -' -b -' -m -' -) -; -set -. -set_range -( -b -' -z -' -b -' -z -' -) -; -let -classes -= -set -. -byte_classes -( -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -. -. -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -\ -x00 -' -) -Unit -: -: -u8 -( -b -' -b -' -) -Unit -: -: -u8 -( -b -' -e -' -) -Unit -: -: -u8 -( -b -' -g -' -) -Unit -: -: -u8 -( -b -' -n -' -) -Unit -: -: -u8 -( -b -' -z -' -) -Unit -: -: -u8 -( -b -' -\ -x7B -' -) -Unit -: -: -eoi -( -7 -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -. -. -0 -) -. -collect -( -) -; -assert -! -( -got -. -is_empty -( -) -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -1 -. -. -1 -) -. -collect -( -) -; -assert -! -( -got -. -is_empty -( -) -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -255 -. -. -255 -) -. -collect -( -) -; -assert -! -( -got -. -is_empty -( -) -) -; -/ -/ -A -weird -case -that -is -the -only -guaranteed -to -way -to -get -an -iterator -/ -/ -of -just -the -EOI -class -by -excluding -all -possible -byte -values -. -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -( -core -: -: -ops -: -: -Bound -: -: -Excluded -( -255 -) -core -: -: -ops -: -: -Bound -: -: -Unbounded -) -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -eoi -( -7 -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -. -. -= -255 -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -\ -x00 -' -) -Unit -: -: -u8 -( -b -' -b -' -) -Unit -: -: -u8 -( -b -' -e -' -) -Unit -: -: -u8 -( -b -' -g -' -) -Unit -: -: -u8 -( -b -' -n -' -) -Unit -: -: -u8 -( -b -' -z -' -) -Unit -: -: -u8 -( -b -' -\ -x7B -' -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -b -' -b -' -. -. -= -b -' -d -' -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -b -' -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -b -' -a -' -. -. -= -b -' -d -' -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -a -' -) -Unit -: -: -u8 -( -b -' -b -' -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -b -' -b -' -. -. -= -b -' -e -' -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -b -' -) -Unit -: -: -u8 -( -b -' -e -' -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -b -' -A -' -. -. -= -b -' -Z -' -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -A -' -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -b -' -A -' -. -. -= -b -' -z -' -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -A -' -) -Unit -: -: -u8 -( -b -' -b -' -) -Unit -: -: -u8 -( -b -' -e -' -) -Unit -: -: -u8 -( -b -' -g -' -) -Unit -: -: -u8 -( -b -' -n -' -) -Unit -: -: -u8 -( -b -' -z -' -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -b -' -z -' -. -. -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -z -' -) -Unit -: -: -u8 -( -b -' -\ -x7B -' -) -Unit -: -: -eoi -( -7 -) -] -; -assert_eq -! -( -expected -got -) -; -let -got -: -Vec -< -Unit -> -= -classes -. -representatives -( -b -' -z -' -. -. -= -0xFF -) -. -collect -( -) -; -let -expected -= -vec -! -[ -Unit -: -: -u8 -( -b -' -z -' -) -Unit -: -: -u8 -( -b -' -\ -x7B -' -) -] -; -assert_eq -! -( -expected -got -) -; -} -} diff --git a/third_party/rust/regex-automata/src/util/captures.rs b/third_party/rust/regex-automata/src/util/captures.rs deleted file mode 100644 index 2916ad010168f..0000000000000 --- a/third_party/rust/regex-automata/src/util/captures.rs +++ /dev/null @@ -1,27733 +0,0 @@ -/ -* -! -Provides -types -for -dealing -with -capturing -groups -. -Capturing -groups -refer -to -sub -- -patterns -of -regexes -that -some -regex -engines -can -report -matching -offsets -for -. -For -example -matching -[ -a -- -z -] -( -[ -0 -- -9 -] -+ -) -against -a789 -would -give -a789 -as -the -overall -match -( -for -the -implicit -capturing -group -at -index -0 -) -and -789 -as -the -match -for -the -capturing -group -( -[ -0 -- -9 -] -+ -) -( -an -explicit -capturing -group -at -index -1 -) -. -Not -all -regex -engines -can -report -match -offsets -for -capturing -groups -. -Indeed -to -a -first -approximation -regex -engines -that -can -report -capturing -group -offsets -tend -to -be -quite -a -bit -slower -than -regex -engines -that -can -' -t -. -This -is -because -tracking -capturing -groups -at -search -time -usually -requires -more -" -power -" -that -in -turn -adds -overhead -. -Other -regex -implementations -might -call -capturing -groups -" -submatches -. -" -# -Overview -The -main -types -in -this -module -are -: -* -[ -Captures -] -records -the -capturing -group -offsets -found -during -a -search -. -It -provides -convenience -routines -for -looking -up -capturing -group -offsets -by -either -index -or -name -. -* -[ -GroupInfo -] -records -the -mapping -between -capturing -groups -and -" -slots -" -where -the -latter -are -how -capturing -groups -are -recorded -during -a -regex -search -. -This -also -keeps -a -mapping -from -capturing -group -name -to -index -and -capture -group -index -to -name -. -A -GroupInfo -is -used -by -Captures -internally -to -provide -a -convenient -API -. -It -is -unlikely -that -you -' -ll -use -a -GroupInfo -directly -but -for -example -if -you -' -ve -compiled -an -Thompson -NFA -then -you -can -use -[ -thompson -: -: -NFA -: -: -group_info -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -: -: -group_info -) -to -get -its -underlying -GroupInfo -. -* -/ -use -alloc -: -: -{ -string -: -: -String -sync -: -: -Arc -vec -vec -: -: -Vec -} -; -use -crate -: -: -util -: -: -{ -interpolate -primitives -: -: -{ -NonMaxUsize -PatternID -PatternIDError -PatternIDIter -SmallIndex -} -search -: -: -{ -Match -Span -} -} -; -/ -/ -/ -The -span -offsets -of -capturing -groups -after -a -match -has -been -found -. -/ -/ -/ -/ -/ -/ -This -type -represents -the -output -of -regex -engines -that -can -report -the -/ -/ -/ -offsets -at -which -capturing -groups -matches -or -" -submatches -" -occur -. -For -/ -/ -/ -example -the -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -. -When -a -match -/ -/ -/ -occurs -it -will -at -minimum -contain -the -[ -PatternID -] -of -the -pattern -that -/ -/ -/ -matched -. -Depending -upon -how -it -was -constructed -it -may -also -contain -the -/ -/ -/ -start -/ -end -offsets -of -the -entire -match -of -the -pattern -and -the -start -/ -end -/ -/ -/ -offsets -of -each -capturing -group -that -participated -in -the -match -. -/ -/ -/ -/ -/ -/ -Values -of -this -type -are -always -created -for -a -specific -[ -GroupInfo -] -. -It -is -/ -/ -/ -unspecified -behavior -to -use -a -Captures -value -in -a -search -with -any -regex -/ -/ -/ -engine -that -has -a -different -GroupInfo -than -the -one -the -Captures -were -/ -/ -/ -created -with -. -/ -/ -/ -/ -/ -/ -# -Constructors -/ -/ -/ -/ -/ -/ -There -are -three -constructors -for -this -type -that -control -what -kind -of -/ -/ -/ -information -is -available -upon -a -match -: -/ -/ -/ -/ -/ -/ -* -[ -Captures -: -: -all -] -: -Will -store -overall -pattern -match -offsets -in -addition -/ -/ -/ -to -the -offsets -of -capturing -groups -that -participated -in -the -match -. -/ -/ -/ -* -[ -Captures -: -: -matches -] -: -Will -store -only -the -overall -pattern -/ -/ -/ -match -offsets -. -The -offsets -of -capturing -groups -( -even -ones -that -participated -/ -/ -/ -in -the -match -) -are -not -available -. -/ -/ -/ -* -[ -Captures -: -: -empty -] -: -Will -only -store -the -pattern -ID -that -matched -. -No -/ -/ -/ -match -offsets -are -available -at -all -. -/ -/ -/ -/ -/ -/ -If -you -aren -' -t -sure -which -to -choose -then -pick -the -first -one -. -The -first -one -/ -/ -/ -is -what -convenience -routines -like -/ -/ -/ -[ -PikeVM -: -: -create_captures -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -: -: -create_captures -) -/ -/ -/ -will -use -automatically -. -/ -/ -/ -/ -/ -/ -The -main -difference -between -these -choices -is -performance -. -Namely -if -you -/ -/ -/ -ask -for -_less_ -information -then -the -execution -of -regex -search -may -be -able -/ -/ -/ -to -run -more -quickly -. -/ -/ -/ -/ -/ -/ -# -Notes -/ -/ -/ -/ -/ -/ -It -is -worth -pointing -out -that -this -type -is -not -coupled -to -any -one -specific -/ -/ -/ -regex -engine -. -Instead -its -coupling -is -with -[ -GroupInfo -] -which -is -the -/ -/ -/ -thing -that -is -responsible -for -mapping -capturing -groups -to -" -slot -" -offsets -. -/ -/ -/ -Slot -offsets -are -indices -into -a -single -sequence -of -memory -at -which -matching -/ -/ -/ -haystack -offsets -for -the -corresponding -group -are -written -by -regex -engines -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -parse -a -simple -date -and -extract -the -components -of -/ -/ -/ -the -date -via -capturing -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -^ -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -2010 -- -03 -- -14 -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -4 -) -) -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -5 -. -. -7 -) -) -caps -. -get_group -( -2 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -8 -. -. -10 -) -) -caps -. -get_group -( -3 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -named -capturing -groups -/ -/ -/ -/ -/ -/ -This -example -is -like -the -one -above -but -leverages -the -ability -to -name -/ -/ -/ -capturing -groups -in -order -to -make -the -code -a -bit -clearer -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -^ -( -? -P -< -y -> -[ -0 -- -9 -] -{ -4 -} -) -- -( -? -P -< -m -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -P -< -d -> -[ -0 -- -9 -] -{ -2 -} -) -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -2010 -- -03 -- -14 -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -4 -) -) -caps -. -get_group_by_name -( -" -y -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -5 -. -. -7 -) -) -caps -. -get_group_by_name -( -" -m -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -8 -. -. -10 -) -) -caps -. -get_group_by_name -( -" -d -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -) -] -pub -struct -Captures -{ -/ -/ -/ -The -group -info -that -these -capture -groups -are -coupled -to -. -This -is -what -/ -/ -/ -gives -the -" -convenience -" -of -the -Captures -API -. -Namely -it -provides -the -/ -/ -/ -slot -mapping -and -the -name -| -- -- -> -index -mapping -for -capture -lookups -by -name -. -group_info -: -GroupInfo -/ -/ -/ -The -ID -of -the -pattern -that -matched -. -Regex -engines -must -set -this -to -/ -/ -/ -None -when -no -match -occurs -. -pid -: -Option -< -PatternID -> -/ -/ -/ -The -slot -values -i -. -e -. -submatch -offsets -. -/ -/ -/ -/ -/ -/ -In -theory -the -smallest -sequence -of -slots -would -be -something -like -/ -/ -/ -max -( -groups -( -pattern -) -for -pattern -in -regex -) -* -2 -but -instead -we -use -/ -/ -/ -sum -( -groups -( -pattern -) -for -pattern -in -regex -) -* -2 -. -Why -? -/ -/ -/ -/ -/ -/ -Well -the -former -could -be -used -in -theory -because -we -don -' -t -generally -/ -/ -/ -have -any -overlapping -APIs -that -involve -capturing -groups -. -Therefore -/ -/ -/ -there -' -s -technically -never -any -need -to -have -slots -set -for -multiple -/ -/ -/ -patterns -. -However -this -might -change -some -day -in -which -case -we -would -/ -/ -/ -need -to -have -slots -available -. -/ -/ -/ -/ -/ -/ -The -other -reason -is -that -during -the -execution -of -some -regex -engines -/ -/ -/ -there -exists -a -point -in -time -where -multiple -slots -for -different -/ -/ -/ -patterns -may -be -written -to -before -knowing -which -pattern -has -matched -. -/ -/ -/ -Therefore -the -regex -engines -themselves -in -order -to -support -multiple -/ -/ -/ -patterns -correctly -must -have -all -slots -available -. -If -Captures -/ -/ -/ -doesn -' -t -have -all -slots -available -then -regex -engines -can -' -t -write -/ -/ -/ -directly -into -the -caller -provided -Captures -and -must -instead -write -/ -/ -/ -into -some -other -storage -and -then -copy -the -slots -involved -in -the -match -/ -/ -/ -at -the -end -of -the -search -. -/ -/ -/ -/ -/ -/ -So -overall -at -least -as -of -the -time -of -writing -it -seems -like -the -path -/ -/ -/ -of -least -resistance -is -to -just -require -allocating -all -possible -slots -/ -/ -/ -instead -of -the -conceptual -minimum -. -Another -way -to -justify -this -is -that -/ -/ -/ -the -most -common -case -is -a -single -pattern -in -which -case -there -is -no -/ -/ -/ -inefficiency -here -since -the -' -max -' -and -' -sum -' -calculations -above -are -/ -/ -/ -equivalent -in -that -case -. -/ -/ -/ -/ -/ -/ -N -. -B -. -The -mapping -from -group -index -to -slot -is -maintained -by -GroupInfo -/ -/ -/ -and -is -considered -an -API -guarantee -. -See -GroupInfo -for -more -details -on -/ -/ -/ -that -mapping -. -/ -/ -/ -/ -/ -/ -N -. -B -. -Option -< -NonMaxUsize -> -has -the -same -size -as -a -usize -. -slots -: -Vec -< -Option -< -NonMaxUsize -> -> -} -impl -Captures -{ -/ -/ -/ -Create -new -storage -for -the -offsets -of -all -matching -capturing -groups -. -/ -/ -/ -/ -/ -/ -This -routine -provides -the -most -information -for -matches -- -- -- -namely -the -/ -/ -/ -spans -of -matching -capturing -groups -- -- -- -but -also -requires -the -regex -search -/ -/ -/ -routines -to -do -the -most -work -. -/ -/ -/ -/ -/ -/ -It -is -unspecified -behavior -to -use -the -returned -Captures -value -in -a -/ -/ -/ -search -with -a -GroupInfo -other -than -the -one -that -is -provided -to -this -/ -/ -/ -constructor -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -all -capturing -groups -- -- -- -but -only -ones -that -/ -/ -/ -participated -in -a -match -- -- -- -are -available -to -query -after -a -match -has -/ -/ -/ -been -found -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -captures -: -: -Captures -/ -/ -/ -Span -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -/ -/ -/ -r -" -^ -( -? -: -( -? -P -< -lower -> -[ -a -- -z -] -+ -) -| -( -? -P -< -upper -> -[ -A -- -Z -] -+ -) -) -( -? -P -< -digits -> -[ -0 -- -9 -] -+ -) -" -/ -/ -/ -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -Captures -: -: -all -( -re -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -ABC123 -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -6 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -The -' -lower -' -group -didn -' -t -match -so -it -won -' -t -have -any -offsets -. -/ -/ -/ -assert_eq -! -( -None -caps -. -get_group_by_name -( -" -lower -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -3 -) -) -caps -. -get_group_by_name -( -" -upper -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -3 -. -. -6 -) -) -caps -. -get_group_by_name -( -" -digits -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -all -( -group_info -: -GroupInfo -) -- -> -Captures -{ -let -slots -= -group_info -. -slot_len -( -) -; -Captures -{ -group_info -pid -: -None -slots -: -vec -! -[ -None -; -slots -] -} -} -/ -/ -/ -Create -new -storage -for -only -the -full -match -spans -of -a -pattern -. -This -/ -/ -/ -does -not -include -any -capturing -group -offsets -. -/ -/ -/ -/ -/ -/ -It -is -unspecified -behavior -to -use -the -returned -Captures -value -in -a -/ -/ -/ -search -with -a -GroupInfo -other -than -the -one -that -is -provided -to -this -/ -/ -/ -constructor -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -only -overall -match -offsets -are -reported -when -/ -/ -/ -this -constructor -is -used -. -Accessing -any -capturing -groups -other -than -/ -/ -/ -the -0th -will -always -return -None -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -captures -: -: -Captures -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -/ -/ -/ -r -" -^ -( -? -: -( -? -P -< -lower -> -[ -a -- -z -] -+ -) -| -( -? -P -< -upper -> -[ -A -- -Z -] -+ -) -) -( -? -P -< -digits -> -[ -0 -- -9 -] -+ -) -" -/ -/ -/ -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -Captures -: -: -matches -( -re -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -ABC123 -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -6 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -We -didn -' -t -ask -for -capturing -group -offsets -so -they -aren -' -t -available -. -/ -/ -/ -assert_eq -! -( -None -caps -. -get_group_by_name -( -" -lower -" -) -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_group_by_name -( -" -upper -" -) -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_group_by_name -( -" -digits -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -matches -( -group_info -: -GroupInfo -) -- -> -Captures -{ -/ -/ -This -is -OK -because -we -know -there -are -at -least -this -many -slots -/ -/ -and -GroupInfo -construction -guarantees -that -the -number -of -slots -fits -/ -/ -into -a -usize -. -let -slots -= -group_info -. -pattern_len -( -) -. -checked_mul -( -2 -) -. -unwrap -( -) -; -Captures -{ -group_info -pid -: -None -slots -: -vec -! -[ -None -; -slots -] -} -} -/ -/ -/ -Create -new -storage -for -only -tracking -which -pattern -matched -. -No -offsets -/ -/ -/ -are -stored -at -all -. -/ -/ -/ -/ -/ -/ -It -is -unspecified -behavior -to -use -the -returned -Captures -value -in -a -/ -/ -/ -search -with -a -GroupInfo -other -than -the -one -that -is -provided -to -this -/ -/ -/ -constructor -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -only -the -pattern -that -matched -can -be -accessed -/ -/ -/ -from -a -Captures -value -created -via -this -constructor -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -captures -: -: -Captures -/ -/ -/ -PatternID -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -r -" -[ -a -- -z -] -+ -" -r -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -Captures -: -: -empty -( -re -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -aABCz -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -0 -) -) -caps -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -We -didn -' -t -ask -for -any -offsets -so -they -aren -' -t -available -. -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -& -" -aABCz -" -[ -1 -. -. -] -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -caps -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -We -didn -' -t -ask -for -any -offsets -so -they -aren -' -t -available -. -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -empty -( -group_info -: -GroupInfo -) -- -> -Captures -{ -Captures -{ -group_info -pid -: -None -slots -: -vec -! -[ -] -} -} -/ -/ -/ -Returns -true -if -and -only -if -this -capturing -group -represents -a -match -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -caps -. -pattern -( -) -. -is_some -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -When -using -the -PikeVM -( -for -example -) -the -lightest -weight -way -of -/ -/ -/ -detecting -whether -a -match -exists -is -to -create -capturing -groups -that -/ -/ -/ -only -track -the -ID -of -the -pattern -that -match -( -if -any -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -captures -: -: -Captures -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -Captures -: -: -empty -( -re -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -aABCz -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -( -& -self -) -- -> -bool -{ -self -. -pid -. -is_some -( -) -} -/ -/ -/ -Returns -the -identifier -of -the -pattern -that -matched -when -this -/ -/ -/ -capturing -group -represents -a -match -. -If -no -match -was -found -then -this -/ -/ -/ -always -returns -None -. -/ -/ -/ -/ -/ -/ -This -returns -a -pattern -ID -in -precisely -the -cases -in -which -is_match -/ -/ -/ -returns -true -. -Similarly -the -pattern -ID -returned -is -always -the -/ -/ -/ -same -pattern -ID -found -in -the -Match -returned -by -get_match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -When -using -the -PikeVM -( -for -example -) -the -lightest -weight -way -of -/ -/ -/ -detecting -which -pattern -matched -is -to -create -capturing -groups -that -only -/ -/ -/ -track -the -ID -of -the -pattern -that -match -( -if -any -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -captures -: -: -Captures -/ -/ -/ -PatternID -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -r -" -[ -a -- -z -] -+ -" -r -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -Captures -: -: -empty -( -re -. -get_nfa -( -) -. -group_info -( -) -. -clone -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -ABC -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -caps -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -Recall -that -offsets -are -only -available -when -using -a -non -- -empty -/ -/ -/ -/ -/ -Captures -value -. -So -even -though -a -match -occurred -this -returns -None -! -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -pattern -( -& -self -) -- -> -Option -< -PatternID -> -{ -self -. -pid -} -/ -/ -/ -Returns -the -pattern -ID -and -the -span -of -the -match -if -one -occurred -. -/ -/ -/ -/ -/ -/ -This -always -returns -None -when -Captures -was -created -with -/ -/ -/ -[ -Captures -: -: -empty -] -even -if -a -match -was -found -. -/ -/ -/ -/ -/ -/ -If -this -routine -returns -a -non -- -None -value -then -is_match -is -/ -/ -/ -guaranteed -to -return -true -and -pattern -is -also -guaranteed -to -return -/ -/ -/ -a -non -- -None -value -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -the -full -match -from -a -search -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -r -" -[ -a -- -z -] -+ -" -r -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -ABC -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -0 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -get_match -( -& -self -) -- -> -Option -< -Match -> -{ -Some -( -Match -: -: -new -( -self -. -pattern -( -) -? -self -. -get_group -( -0 -) -? -) -) -} -/ -/ -/ -Returns -the -span -of -a -capturing -group -match -corresponding -to -the -group -/ -/ -/ -index -given -only -if -both -the -overall -pattern -matched -and -the -capturing -/ -/ -/ -group -participated -in -that -match -. -/ -/ -/ -/ -/ -/ -This -returns -None -if -index -is -invalid -. -index -is -valid -if -and -only -/ -/ -/ -if -it -' -s -less -than -[ -Captures -: -: -group_len -] -for -the -matching -pattern -. -/ -/ -/ -/ -/ -/ -This -always -returns -None -when -Captures -was -created -with -/ -/ -/ -[ -Captures -: -: -empty -] -even -if -a -match -was -found -. -This -also -always -/ -/ -/ -returns -None -for -any -index -> -0 -when -Captures -was -created -with -/ -/ -/ -[ -Captures -: -: -matches -] -. -/ -/ -/ -/ -/ -/ -If -this -routine -returns -a -non -- -None -value -then -is_match -is -/ -/ -/ -guaranteed -to -return -true -pattern -is -guaranteed -to -return -a -/ -/ -/ -non -- -None -value -and -get_match -is -guaranteed -to -return -a -non -- -None -/ -/ -/ -value -. -/ -/ -/ -/ -/ -/ -By -convention -the -0th -capture -group -will -always -return -the -same -/ -/ -/ -span -as -the -span -returned -by -get_match -. -This -is -because -the -0th -/ -/ -/ -capture -group -always -corresponds -to -the -entirety -of -the -pattern -' -s -/ -/ -/ -match -. -( -It -is -similarly -always -unnamed -because -it -is -implicit -. -) -This -/ -/ -/ -isn -' -t -necessarily -true -of -all -regex -engines -. -For -example -one -can -/ -/ -/ -hand -- -compile -a -[ -thompson -: -: -NFA -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -) -via -a -/ -/ -/ -[ -thompson -: -: -Builder -] -( -crate -: -: -nfa -: -: -thompson -: -: -Builder -) -which -isn -' -t -/ -/ -/ -technically -forced -to -make -the -0th -capturing -group -always -correspond -to -/ -/ -/ -the -entire -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -the -capturing -groups -by -index -from -a -/ -/ -/ -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -# -if -! -cfg -! -( -target_pointer_width -= -" -64 -" -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -see -# -1039 -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -^ -( -? -P -< -first -> -\ -pL -+ -) -\ -s -+ -( -? -P -< -last -> -\ -pL -+ -) -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -Bruce -Springsteen -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -17 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -5 -) -) -caps -. -get_group -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -6 -. -. -17 -) -) -caps -. -get_group -( -2 -) -) -; -/ -/ -/ -/ -/ -Looking -for -a -non -- -existent -capturing -group -will -return -None -: -/ -/ -/ -assert_eq -! -( -None -caps -. -get_group -( -3 -) -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_group -( -9944060567225171988 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -get_group -( -& -self -index -: -usize -) -- -> -Option -< -Span -> -{ -let -pid -= -self -. -pattern -( -) -? -; -/ -/ -There -' -s -a -little -bit -of -work -needed -to -map -captures -to -slots -in -the -/ -/ -fully -general -case -. -But -in -the -overwhelming -common -case -of -a -single -/ -/ -pattern -we -can -just -do -some -simple -arithmetic -. -let -( -slot_start -slot_end -) -= -if -self -. -group_info -( -) -. -pattern_len -( -) -= -= -1 -{ -( -index -. -checked_mul -( -2 -) -? -index -. -checked_mul -( -2 -) -? -. -checked_add -( -1 -) -? -) -} -else -{ -self -. -group_info -( -) -. -slots -( -pid -index -) -? -} -; -let -start -= -self -. -slots -. -get -( -slot_start -) -. -copied -( -) -? -? -; -let -end -= -self -. -slots -. -get -( -slot_end -) -. -copied -( -) -? -? -; -Some -( -Span -{ -start -: -start -. -get -( -) -end -: -end -. -get -( -) -} -) -} -/ -/ -/ -Returns -the -span -of -a -capturing -group -match -corresponding -to -the -group -/ -/ -/ -name -given -only -if -both -the -overall -pattern -matched -and -the -capturing -/ -/ -/ -group -participated -in -that -match -. -/ -/ -/ -/ -/ -/ -This -returns -None -if -name -does -not -correspond -to -a -valid -capturing -/ -/ -/ -group -for -the -pattern -that -matched -. -/ -/ -/ -/ -/ -/ -This -always -returns -None -when -Captures -was -created -with -/ -/ -/ -[ -Captures -: -: -empty -] -even -if -a -match -was -found -. -This -also -always -/ -/ -/ -returns -None -for -any -index -> -0 -when -Captures -was -created -with -/ -/ -/ -[ -Captures -: -: -matches -] -. -/ -/ -/ -/ -/ -/ -If -this -routine -returns -a -non -- -None -value -then -is_match -is -/ -/ -/ -guaranteed -to -return -true -pattern -is -guaranteed -to -return -a -/ -/ -/ -non -- -None -value -and -get_match -is -guaranteed -to -return -a -non -- -None -/ -/ -/ -value -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -the -capturing -groups -by -name -from -a -/ -/ -/ -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -Match -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -^ -( -? -P -< -first -> -\ -pL -+ -) -\ -s -+ -( -? -P -< -last -> -\ -pL -+ -) -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -Bruce -Springsteen -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -17 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -0 -. -. -5 -) -) -caps -. -get_group_by_name -( -" -first -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Span -: -: -from -( -6 -. -. -17 -) -) -caps -. -get_group_by_name -( -" -last -" -) -) -; -/ -/ -/ -/ -/ -Looking -for -a -non -- -existent -capturing -group -will -return -None -: -/ -/ -/ -assert_eq -! -( -None -caps -. -get_group_by_name -( -" -middle -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -get_group_by_name -( -& -self -name -: -& -str -) -- -> -Option -< -Span -> -{ -let -index -= -self -. -group_info -( -) -. -to_index -( -self -. -pattern -( -) -? -name -) -? -; -self -. -get_group -( -index -) -} -/ -/ -/ -Returns -an -iterator -of -possible -spans -for -every -capturing -group -in -the -/ -/ -/ -matching -pattern -. -/ -/ -/ -/ -/ -/ -If -this -Captures -value -does -not -correspond -to -a -match -then -the -/ -/ -/ -iterator -returned -yields -no -elements -. -/ -/ -/ -/ -/ -/ -Note -that -the -iterator -returned -yields -elements -of -type -Option -< -Span -> -. -/ -/ -/ -A -span -is -present -if -and -only -if -it -corresponds -to -a -capturing -group -/ -/ -/ -that -participated -in -a -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -collect -all -capturing -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -/ -/ -/ -/ -/ -Matches -first -/ -last -names -with -an -optional -middle -name -. -/ -/ -/ -r -" -^ -( -? -P -< -first -> -\ -pL -+ -) -\ -s -+ -( -? -: -( -? -P -< -middle -> -\ -pL -+ -) -\ -s -+ -) -? -( -? -P -< -last -> -\ -pL -+ -) -" -/ -/ -/ -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -Harry -James -Potter -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -let -groups -: -Vec -< -Option -< -Span -> -> -= -caps -. -iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -groups -vec -! -[ -/ -/ -/ -Some -( -Span -: -: -from -( -0 -. -. -18 -) -) -/ -/ -/ -Some -( -Span -: -: -from -( -0 -. -. -5 -) -) -/ -/ -/ -Some -( -Span -: -: -from -( -6 -. -. -11 -) -) -/ -/ -/ -Some -( -Span -: -: -from -( -12 -. -. -18 -) -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -uses -the -same -regex -as -the -previous -example -but -with -a -/ -/ -/ -haystack -that -omits -the -middle -name -. -This -results -in -a -capturing -group -/ -/ -/ -that -is -present -in -the -elements -yielded -by -the -iterator -but -without -a -/ -/ -/ -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Span -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -/ -/ -/ -/ -/ -Matches -first -/ -last -names -with -an -optional -middle -name -. -/ -/ -/ -r -" -^ -( -? -P -< -first -> -\ -pL -+ -) -\ -s -+ -( -? -: -( -? -P -< -middle -> -\ -pL -+ -) -\ -s -+ -) -? -( -? -P -< -last -> -\ -pL -+ -) -" -/ -/ -/ -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -Harry -Potter -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -let -groups -: -Vec -< -Option -< -Span -> -> -= -caps -. -iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -groups -vec -! -[ -/ -/ -/ -Some -( -Span -: -: -from -( -0 -. -. -12 -) -) -/ -/ -/ -Some -( -Span -: -: -from -( -0 -. -. -5 -) -) -/ -/ -/ -None -/ -/ -/ -Some -( -Span -: -: -from -( -6 -. -. -12 -) -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -iter -( -& -self -) -- -> -CapturesPatternIter -< -' -_ -> -{ -let -names -= -self -. -pattern -( -) -. -map_or -( -GroupInfoPatternNames -: -: -empty -( -) -. -enumerate -( -) -| -pid -| -{ -self -. -group_info -( -) -. -pattern_names -( -pid -) -. -enumerate -( -) -} -) -; -CapturesPatternIter -{ -caps -: -self -names -} -} -/ -/ -/ -Return -the -total -number -of -capturing -groups -for -the -matching -pattern -. -/ -/ -/ -/ -/ -/ -If -this -Captures -value -does -not -correspond -to -a -match -then -this -/ -/ -/ -always -returns -0 -. -/ -/ -/ -/ -/ -/ -This -always -returns -the -same -number -of -elements -yielded -by -/ -/ -/ -[ -Captures -: -: -iter -] -. -That -is -the -number -includes -capturing -groups -even -/ -/ -/ -if -they -don -' -t -participate -in -the -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -count -the -total -number -of -capturing -groups -/ -/ -/ -associated -with -a -pattern -. -Notice -that -it -includes -groups -that -did -not -/ -/ -/ -participate -in -a -match -( -just -like -Captures -: -: -iter -does -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -/ -/ -/ -/ -/ -Matches -first -/ -last -names -with -an -optional -middle -name -. -/ -/ -/ -r -" -^ -( -? -P -< -first -> -\ -pL -+ -) -\ -s -+ -( -? -: -( -? -P -< -middle -> -\ -pL -+ -) -\ -s -+ -) -? -( -? -P -< -last -> -\ -pL -+ -) -" -/ -/ -/ -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -Harry -Potter -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -4 -caps -. -group_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -group_len -( -& -self -) -- -> -usize -{ -let -pid -= -match -self -. -pattern -( -) -{ -None -= -> -return -0 -Some -( -pid -) -= -> -pid -} -; -self -. -group_info -( -) -. -group_len -( -pid -) -} -/ -/ -/ -Returns -a -reference -to -the -underlying -group -info -on -which -these -/ -/ -/ -captures -are -based -. -/ -/ -/ -/ -/ -/ -The -difference -between -GroupInfo -and -Captures -is -that -the -former -/ -/ -/ -defines -the -structure -of -capturing -groups -where -as -the -latter -is -what -/ -/ -/ -stores -the -actual -match -information -. -So -where -as -Captures -only -gives -/ -/ -/ -you -access -to -the -current -match -GroupInfo -lets -you -query -any -/ -/ -/ -information -about -all -capturing -groups -even -ones -for -patterns -that -/ -/ -/ -weren -' -t -involved -in -a -match -. -/ -/ -/ -/ -/ -/ -Note -that -a -GroupInfo -uses -reference -counting -internally -so -it -may -/ -/ -/ -be -cloned -cheaply -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -all -capturing -group -names -from -the -/ -/ -/ -underlying -GroupInfo -. -Notice -that -we -don -' -t -even -need -to -run -a -/ -/ -/ -search -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -( -? -P -< -foo -> -a -) -" -/ -/ -/ -r -" -( -a -) -( -b -) -" -/ -/ -/ -r -" -ab -" -/ -/ -/ -r -" -( -? -P -< -bar -> -a -) -( -? -P -< -quux -> -a -) -" -/ -/ -/ -r -" -( -? -P -< -foo -> -z -) -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -( -PatternID -: -: -must -( -0 -) -0 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -0 -) -1 -Some -( -" -foo -" -) -) -/ -/ -/ -( -PatternID -: -: -must -( -1 -) -0 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -1 -) -1 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -1 -) -2 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -2 -) -0 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -3 -) -0 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -3 -) -1 -Some -( -" -bar -" -) -) -/ -/ -/ -( -PatternID -: -: -must -( -3 -) -2 -Some -( -" -quux -" -) -) -/ -/ -/ -( -PatternID -: -: -must -( -4 -) -0 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -4 -) -1 -Some -( -" -foo -" -) -) -/ -/ -/ -] -; -/ -/ -/ -/ -/ -We -could -also -just -use -' -re -. -get_nfa -( -) -. -group_info -( -) -' -. -/ -/ -/ -let -got -: -Vec -< -( -PatternID -usize -Option -< -& -str -> -) -> -= -/ -/ -/ -caps -. -group_info -( -) -. -all_names -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -group_info -( -& -self -) -- -> -& -GroupInfo -{ -& -self -. -group_info -} -/ -/ -/ -Interpolates -the -capture -references -in -replacement -with -the -/ -/ -/ -corresponding -substrings -in -haystack -matched -by -each -reference -. -The -/ -/ -/ -interpolated -string -is -returned -. -/ -/ -/ -/ -/ -/ -See -the -[ -interpolate -module -] -( -interpolate -) -for -documentation -on -the -/ -/ -/ -format -of -the -replacement -string -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -interpolation -and -also -shows -how -it -/ -/ -/ -can -work -with -multi -- -pattern -regexes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -" -/ -/ -/ -r -" -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -replacement -= -" -year -= -year -month -= -month -day -= -day -" -; -/ -/ -/ -/ -/ -/ -/ -/ -This -matches -the -first -pattern -. -/ -/ -/ -let -hay -= -" -On -14 -- -03 -- -2010 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -let -result -= -caps -. -interpolate_string -( -hay -replacement -) -; -/ -/ -/ -assert_eq -! -( -" -year -= -2010 -month -= -03 -day -= -14 -" -result -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -this -matches -the -second -pattern -. -/ -/ -/ -let -hay -= -" -On -2010 -- -03 -- -14 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -let -result -= -caps -. -interpolate_string -( -hay -replacement -) -; -/ -/ -/ -assert_eq -! -( -" -year -= -2010 -month -= -03 -day -= -14 -" -result -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -interpolate_string -( -& -self -haystack -: -& -str -replacement -: -& -str -) -- -> -String -{ -let -mut -dst -= -String -: -: -new -( -) -; -self -. -interpolate_string_into -( -haystack -replacement -& -mut -dst -) -; -dst -} -/ -/ -/ -Interpolates -the -capture -references -in -replacement -with -the -/ -/ -/ -corresponding -substrings -in -haystack -matched -by -each -reference -. -The -/ -/ -/ -interpolated -string -is -written -to -dst -. -/ -/ -/ -/ -/ -/ -See -the -[ -interpolate -module -] -( -interpolate -) -for -documentation -on -the -/ -/ -/ -format -of -the -replacement -string -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -interpolation -and -also -shows -how -it -/ -/ -/ -can -work -with -multi -- -pattern -regexes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -" -/ -/ -/ -r -" -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -replacement -= -" -year -= -year -month -= -month -day -= -day -" -; -/ -/ -/ -/ -/ -/ -/ -/ -This -matches -the -first -pattern -. -/ -/ -/ -let -hay -= -" -On -14 -- -03 -- -2010 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -let -mut -dst -= -String -: -: -new -( -) -; -/ -/ -/ -caps -. -interpolate_string_into -( -hay -replacement -& -mut -dst -) -; -/ -/ -/ -assert_eq -! -( -" -year -= -2010 -month -= -03 -day -= -14 -" -dst -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -this -matches -the -second -pattern -. -/ -/ -/ -let -hay -= -" -On -2010 -- -03 -- -14 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -let -mut -dst -= -String -: -: -new -( -) -; -/ -/ -/ -caps -. -interpolate_string_into -( -hay -replacement -& -mut -dst -) -; -/ -/ -/ -assert_eq -! -( -" -year -= -2010 -month -= -03 -day -= -14 -" -dst -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -interpolate_string_into -( -& -self -haystack -: -& -str -replacement -: -& -str -dst -: -& -mut -String -) -{ -interpolate -: -: -string -( -replacement -| -index -dst -| -{ -let -span -= -match -self -. -get_group -( -index -) -{ -None -= -> -return -Some -( -span -) -= -> -span -} -; -dst -. -push_str -( -& -haystack -[ -span -] -) -; -} -| -name -| -self -. -group_info -( -) -. -to_index -( -self -. -pattern -( -) -? -name -) -dst -) -; -} -/ -/ -/ -Interpolates -the -capture -references -in -replacement -with -the -/ -/ -/ -corresponding -substrings -in -haystack -matched -by -each -reference -. -The -/ -/ -/ -interpolated -byte -string -is -returned -. -/ -/ -/ -/ -/ -/ -See -the -[ -interpolate -module -] -( -interpolate -) -for -documentation -on -the -/ -/ -/ -format -of -the -replacement -string -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -interpolation -and -also -shows -how -it -/ -/ -/ -can -work -with -multi -- -pattern -regexes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -" -/ -/ -/ -r -" -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -replacement -= -b -" -year -= -year -month -= -month -day -= -day -" -; -/ -/ -/ -/ -/ -/ -/ -/ -This -matches -the -first -pattern -. -/ -/ -/ -let -hay -= -b -" -On -14 -- -03 -- -2010 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -let -result -= -caps -. -interpolate_bytes -( -hay -replacement -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -year -= -2010 -month -= -03 -day -= -14 -" -[ -. -. -] -result -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -this -matches -the -second -pattern -. -/ -/ -/ -let -hay -= -b -" -On -2010 -- -03 -- -14 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -let -result -= -caps -. -interpolate_bytes -( -hay -replacement -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -year -= -2010 -month -= -03 -day -= -14 -" -[ -. -. -] -result -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -interpolate_bytes -( -& -self -haystack -: -& -[ -u8 -] -replacement -: -& -[ -u8 -] -) -- -> -Vec -< -u8 -> -{ -let -mut -dst -= -vec -! -[ -] -; -self -. -interpolate_bytes_into -( -haystack -replacement -& -mut -dst -) -; -dst -} -/ -/ -/ -Interpolates -the -capture -references -in -replacement -with -the -/ -/ -/ -corresponding -substrings -in -haystack -matched -by -each -reference -. -The -/ -/ -/ -interpolated -byte -string -is -written -to -dst -. -/ -/ -/ -/ -/ -/ -See -the -[ -interpolate -module -] -( -interpolate -) -for -documentation -on -the -/ -/ -/ -format -of -the -replacement -string -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -interpolation -and -also -shows -how -it -/ -/ -/ -can -work -with -multi -- -pattern -regexes -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -" -/ -/ -/ -r -" -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -replacement -= -b -" -year -= -year -month -= -month -day -= -day -" -; -/ -/ -/ -/ -/ -/ -/ -/ -This -matches -the -first -pattern -. -/ -/ -/ -let -hay -= -b -" -On -14 -- -03 -- -2010 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -let -mut -dst -= -vec -! -[ -] -; -/ -/ -/ -caps -. -interpolate_bytes_into -( -hay -replacement -& -mut -dst -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -year -= -2010 -month -= -03 -day -= -14 -" -[ -. -. -] -dst -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -this -matches -the -second -pattern -. -/ -/ -/ -let -hay -= -b -" -On -2010 -- -03 -- -14 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -let -mut -dst -= -vec -! -[ -] -; -/ -/ -/ -caps -. -interpolate_bytes_into -( -hay -replacement -& -mut -dst -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -year -= -2010 -month -= -03 -day -= -14 -" -[ -. -. -] -dst -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -interpolate_bytes_into -( -& -self -haystack -: -& -[ -u8 -] -replacement -: -& -[ -u8 -] -dst -: -& -mut -Vec -< -u8 -> -) -{ -interpolate -: -: -bytes -( -replacement -| -index -dst -| -{ -let -span -= -match -self -. -get_group -( -index -) -{ -None -= -> -return -Some -( -span -) -= -> -span -} -; -dst -. -extend_from_slice -( -& -haystack -[ -span -] -) -; -} -| -name -| -self -. -group_info -( -) -. -to_index -( -self -. -pattern -( -) -? -name -) -dst -) -; -} -/ -/ -/ -This -is -a -convenience -routine -for -extracting -the -substrings -/ -/ -/ -corresponding -to -matching -capture -groups -in -the -given -haystack -. -The -/ -/ -/ -haystack -should -be -the -same -substring -used -to -find -the -match -spans -in -/ -/ -/ -this -Captures -value -. -/ -/ -/ -/ -/ -/ -This -is -identical -to -[ -Captures -: -: -extract_bytes -] -except -it -works -with -/ -/ -/ -& -str -instead -of -& -[ -u8 -] -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -number -of -explicit -matching -groups -in -this -/ -/ -/ -Captures -value -is -less -than -N -. -This -also -panics -if -this -Captures -/ -/ -/ -value -does -not -correspond -to -a -match -. -/ -/ -/ -/ -/ -/ -Note -that -this -does -* -not -* -panic -if -the -number -of -explicit -matching -/ -/ -/ -groups -is -bigger -than -N -. -In -that -case -only -the -first -N -matching -/ -/ -/ -groups -are -extracted -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -hay -= -" -On -2010 -- -03 -- -14 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -let -( -full -[ -year -month -day -] -) -= -caps -. -extract -( -hay -) -; -/ -/ -/ -assert_eq -! -( -" -2010 -- -03 -- -14 -" -full -) -; -/ -/ -/ -assert_eq -! -( -" -2010 -" -year -) -; -/ -/ -/ -assert_eq -! -( -" -03 -" -month -) -; -/ -/ -/ -assert_eq -! -( -" -14 -" -day -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -can -also -ask -for -fewer -than -all -capture -groups -. -/ -/ -/ -let -( -full -[ -year -] -) -= -caps -. -extract -( -hay -) -; -/ -/ -/ -assert_eq -! -( -" -2010 -- -03 -- -14 -" -full -) -; -/ -/ -/ -assert_eq -! -( -" -2010 -" -year -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -extract -< -' -h -const -N -: -usize -> -( -& -self -haystack -: -& -' -h -str -) -- -> -( -& -' -h -str -[ -& -' -h -str -; -N -] -) -{ -let -mut -matched -= -self -. -iter -( -) -. -flatten -( -) -; -let -whole_match -= -& -haystack -[ -matched -. -next -( -) -. -expect -( -" -a -match -" -) -] -; -let -group_matches -= -[ -0 -; -N -] -. -map -( -| -_ -| -{ -let -sp -= -matched -. -next -( -) -. -expect -( -" -too -few -matching -groups -" -) -; -& -haystack -[ -sp -] -} -) -; -( -whole_match -group_matches -) -} -/ -/ -/ -This -is -a -convenience -routine -for -extracting -the -substrings -/ -/ -/ -corresponding -to -matching -capture -groups -in -the -given -haystack -. -The -/ -/ -/ -haystack -should -be -the -same -substring -used -to -find -the -match -spans -in -/ -/ -/ -this -Captures -value -. -/ -/ -/ -/ -/ -/ -This -is -identical -to -[ -Captures -: -: -extract -] -except -it -works -with -/ -/ -/ -& -[ -u8 -] -instead -of -& -str -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -number -of -explicit -matching -groups -in -this -/ -/ -/ -Captures -value -is -less -than -N -. -This -also -panics -if -this -Captures -/ -/ -/ -value -does -not -correspond -to -a -match -. -/ -/ -/ -/ -/ -/ -Note -that -this -does -* -not -* -panic -if -the -number -of -explicit -matching -/ -/ -/ -groups -is -bigger -than -N -. -In -that -case -only -the -first -N -matching -/ -/ -/ -groups -are -extracted -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -let -hay -= -b -" -On -2010 -- -03 -- -14 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -re -. -captures -( -& -mut -cache -hay -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -let -( -full -[ -year -month -day -] -) -= -caps -. -extract_bytes -( -hay -) -; -/ -/ -/ -assert_eq -! -( -b -" -2010 -- -03 -- -14 -" -full -) -; -/ -/ -/ -assert_eq -! -( -b -" -2010 -" -year -) -; -/ -/ -/ -assert_eq -! -( -b -" -03 -" -month -) -; -/ -/ -/ -assert_eq -! -( -b -" -14 -" -day -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -can -also -ask -for -fewer -than -all -capture -groups -. -/ -/ -/ -let -( -full -[ -year -] -) -= -caps -. -extract_bytes -( -hay -) -; -/ -/ -/ -assert_eq -! -( -b -" -2010 -- -03 -- -14 -" -full -) -; -/ -/ -/ -assert_eq -! -( -b -" -2010 -" -year -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -extract_bytes -< -' -h -const -N -: -usize -> -( -& -self -haystack -: -& -' -h -[ -u8 -] -) -- -> -( -& -' -h -[ -u8 -] -[ -& -' -h -[ -u8 -] -; -N -] -) -{ -let -mut -matched -= -self -. -iter -( -) -. -flatten -( -) -; -let -whole_match -= -& -haystack -[ -matched -. -next -( -) -. -expect -( -" -a -match -" -) -] -; -let -group_matches -= -[ -0 -; -N -] -. -map -( -| -_ -| -{ -let -sp -= -matched -. -next -( -) -. -expect -( -" -too -few -matching -groups -" -) -; -& -haystack -[ -sp -] -} -) -; -( -whole_match -group_matches -) -} -} -/ -/ -/ -Lower -level -" -slot -" -oriented -APIs -. -One -does -not -typically -need -to -use -these -/ -/ -/ -when -executing -a -search -. -They -are -instead -mostly -intended -for -folks -that -/ -/ -/ -are -writing -their -own -regex -engine -while -reusing -this -Captures -type -. -impl -Captures -{ -/ -/ -/ -Clear -this -Captures -value -. -/ -/ -/ -/ -/ -/ -After -clearing -all -slots -inside -this -Captures -value -will -be -set -to -/ -/ -/ -None -. -Similarly -any -pattern -ID -that -it -was -previously -associated -/ -/ -/ -with -( -for -a -match -) -is -erased -. -/ -/ -/ -/ -/ -/ -It -is -not -usually -necessary -to -call -this -routine -. -Namely -a -Captures -/ -/ -/ -value -only -provides -high -level -access -to -the -capturing -groups -of -the -/ -/ -/ -pattern -that -matched -and -only -low -level -access -to -individual -slots -. -/ -/ -/ -Thus -even -if -slots -corresponding -to -groups -that -aren -' -t -associated -/ -/ -/ -with -the -matching -pattern -are -set -then -it -won -' -t -impact -the -higher -/ -/ -/ -level -APIs -. -Namely -higher -level -APIs -like -[ -Captures -: -: -get_group -] -will -/ -/ -/ -return -None -if -no -pattern -ID -is -present -even -if -there -are -spans -set -/ -/ -/ -in -the -underlying -slots -. -/ -/ -/ -/ -/ -/ -Thus -to -" -clear -" -a -Captures -value -of -a -match -it -is -usually -only -/ -/ -/ -necessary -to -call -[ -Captures -: -: -set_pattern -] -with -None -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -what -happens -when -a -Captures -value -is -cleared -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -^ -( -? -P -< -first -> -\ -pL -+ -) -\ -s -+ -( -? -P -< -last -> -\ -pL -+ -) -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -Bruce -Springsteen -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -let -slots -: -Vec -< -Option -< -usize -> -> -= -/ -/ -/ -caps -. -slots -( -) -. -iter -( -) -. -map -( -| -s -| -s -. -map -( -| -x -| -x -. -get -( -) -) -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Note -that -the -following -ordering -is -considered -an -API -guarantee -. -/ -/ -/ -assert_eq -! -( -slots -vec -! -[ -/ -/ -/ -Some -( -0 -) -/ -/ -/ -Some -( -17 -) -/ -/ -/ -Some -( -0 -) -/ -/ -/ -Some -( -5 -) -/ -/ -/ -Some -( -6 -) -/ -/ -/ -Some -( -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -clear -the -slots -. -Everything -is -gone -and -it -is -no -longer -a -match -. -/ -/ -/ -caps -. -clear -( -) -; -/ -/ -/ -assert -! -( -! -caps -. -is_match -( -) -) -; -/ -/ -/ -let -slots -: -Vec -< -Option -< -usize -> -> -= -/ -/ -/ -caps -. -slots -( -) -. -iter -( -) -. -map -( -| -s -| -s -. -map -( -| -x -| -x -. -get -( -) -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -slots -vec -! -[ -/ -/ -/ -None -/ -/ -/ -None -/ -/ -/ -None -/ -/ -/ -None -/ -/ -/ -None -/ -/ -/ -None -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -clear -( -& -mut -self -) -{ -self -. -pid -= -None -; -for -slot -in -self -. -slots -. -iter_mut -( -) -{ -* -slot -= -None -; -} -} -/ -/ -/ -Set -the -pattern -on -this -Captures -value -. -/ -/ -/ -/ -/ -/ -When -the -pattern -ID -is -None -then -this -Captures -value -does -not -/ -/ -/ -correspond -to -a -match -( -is_match -will -return -false -) -. -Otherwise -it -/ -/ -/ -corresponds -to -a -match -. -/ -/ -/ -/ -/ -/ -This -is -useful -in -search -implementations -where -you -might -want -to -/ -/ -/ -initially -call -set_pattern -( -None -) -in -order -to -avoid -the -cost -of -/ -/ -/ -calling -clear -( -) -if -it -turns -out -to -not -be -necessary -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -set_pattern -merely -overwrites -the -pattern -ID -. -/ -/ -/ -It -does -not -actually -change -the -underlying -slot -values -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -^ -( -? -P -< -first -> -\ -pL -+ -) -\ -s -+ -( -? -P -< -last -> -\ -pL -+ -) -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -Bruce -Springsteen -" -& -mut -caps -) -; -/ -/ -/ -assert -! -( -caps -. -is_match -( -) -) -; -/ -/ -/ -assert -! -( -caps -. -pattern -( -) -. -is_some -( -) -) -; -/ -/ -/ -let -slots -: -Vec -< -Option -< -usize -> -> -= -/ -/ -/ -caps -. -slots -( -) -. -iter -( -) -. -map -( -| -s -| -s -. -map -( -| -x -| -x -. -get -( -) -) -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Note -that -the -following -ordering -is -considered -an -API -guarantee -. -/ -/ -/ -assert_eq -! -( -slots -vec -! -[ -/ -/ -/ -Some -( -0 -) -/ -/ -/ -Some -( -17 -) -/ -/ -/ -Some -( -0 -) -/ -/ -/ -Some -( -5 -) -/ -/ -/ -Some -( -6 -) -/ -/ -/ -Some -( -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -set -the -pattern -to -None -. -Note -that -the -slot -values -remain -. -/ -/ -/ -caps -. -set_pattern -( -None -) -; -/ -/ -/ -assert -! -( -! -caps -. -is_match -( -) -) -; -/ -/ -/ -assert -! -( -! -caps -. -pattern -( -) -. -is_some -( -) -) -; -/ -/ -/ -let -slots -: -Vec -< -Option -< -usize -> -> -= -/ -/ -/ -caps -. -slots -( -) -. -iter -( -) -. -map -( -| -s -| -s -. -map -( -| -x -| -x -. -get -( -) -) -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Note -that -the -following -ordering -is -considered -an -API -guarantee -. -/ -/ -/ -assert_eq -! -( -slots -vec -! -[ -/ -/ -/ -Some -( -0 -) -/ -/ -/ -Some -( -17 -) -/ -/ -/ -Some -( -0 -) -/ -/ -/ -Some -( -5 -) -/ -/ -/ -Some -( -6 -) -/ -/ -/ -Some -( -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -set_pattern -( -& -mut -self -pid -: -Option -< -PatternID -> -) -{ -self -. -pid -= -pid -; -} -/ -/ -/ -Returns -the -underlying -slots -where -each -slot -stores -a -single -offset -. -/ -/ -/ -/ -/ -/ -Every -matching -capturing -group -generally -corresponds -to -two -slots -: -one -/ -/ -/ -slot -for -the -starting -position -and -another -for -the -ending -position -. -/ -/ -/ -Typically -either -both -are -present -or -neither -are -. -( -The -weasel -word -/ -/ -/ -" -typically -" -is -used -here -because -it -really -depends -on -the -regex -engine -/ -/ -/ -implementation -. -Every -sensible -regex -engine -likely -adheres -to -this -/ -/ -/ -invariant -and -every -regex -engine -in -this -crate -is -sensible -. -) -/ -/ -/ -/ -/ -/ -Generally -speaking -callers -should -prefer -to -use -higher -level -routines -/ -/ -/ -like -[ -Captures -: -: -get_match -] -or -[ -Captures -: -: -get_group -] -. -/ -/ -/ -/ -/ -/ -An -important -note -here -is -that -a -regex -engine -may -not -reset -all -of -the -/ -/ -/ -slots -to -None -values -when -no -match -occurs -or -even -when -a -match -of -/ -/ -/ -a -different -pattern -occurs -. -But -this -depends -on -how -the -regex -engine -/ -/ -/ -implementation -deals -with -slots -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -the -underlying -slots -from -a -regex -match -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -primitives -: -: -{ -PatternID -NonMaxUsize -} -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -[ -a -- -z -] -+ -" -/ -/ -/ -r -" -[ -0 -- -9 -] -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -re -. -captures -( -& -mut -cache -" -123 -" -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -PatternID -: -: -must -( -1 -) -) -caps -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -Note -that -the -only -guarantee -we -have -here -is -that -slots -2 -and -3 -/ -/ -/ -/ -/ -are -set -to -correct -values -. -The -contents -of -the -first -two -slots -are -/ -/ -/ -/ -/ -unspecified -since -the -0th -pattern -did -not -match -. -/ -/ -/ -let -expected -= -& -[ -/ -/ -/ -None -/ -/ -/ -None -/ -/ -/ -NonMaxUsize -: -: -new -( -0 -) -/ -/ -/ -NonMaxUsize -: -: -new -( -3 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -slots -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -slots -( -& -self -) -- -> -& -[ -Option -< -NonMaxUsize -> -] -{ -& -self -. -slots -} -/ -/ -/ -Returns -the -underlying -slots -as -a -mutable -slice -where -each -slot -stores -/ -/ -/ -a -single -offset -. -/ -/ -/ -/ -/ -/ -This -tends -to -be -most -useful -for -regex -engine -implementations -for -/ -/ -/ -writing -offsets -for -matching -capturing -groups -to -slots -. -/ -/ -/ -/ -/ -/ -See -[ -Captures -: -: -slots -] -for -more -information -about -slots -. -# -[ -inline -] -pub -fn -slots_mut -( -& -mut -self -) -- -> -& -mut -[ -Option -< -NonMaxUsize -> -] -{ -& -mut -self -. -slots -} -} -impl -core -: -: -fmt -: -: -Debug -for -Captures -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -dstruct -= -f -. -debug_struct -( -" -Captures -" -) -; -dstruct -. -field -( -" -pid -" -& -self -. -pid -) -; -if -let -Some -( -pid -) -= -self -. -pid -{ -dstruct -. -field -( -" -spans -" -& -CapturesDebugMap -{ -pid -caps -: -self -} -) -; -} -dstruct -. -finish -( -) -} -} -/ -/ -/ -A -little -helper -type -to -provide -a -nice -map -- -like -debug -representation -for -/ -/ -/ -our -capturing -group -spans -. -struct -CapturesDebugMap -< -' -a -> -{ -pid -: -PatternID -caps -: -& -' -a -Captures -} -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -CapturesDebugMap -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -struct -Key -< -' -a -> -( -usize -Option -< -& -' -a -str -> -) -; -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -Key -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -} -" -self -. -0 -) -? -; -if -let -Some -( -name -) -= -self -. -1 -{ -write -! -( -f -" -/ -{ -: -? -} -" -name -) -? -; -} -Ok -( -( -) -) -} -} -let -mut -map -= -f -. -debug_map -( -) -; -let -names -= -self -. -caps -. -group_info -( -) -. -pattern_names -( -self -. -pid -) -; -for -( -group_index -maybe_name -) -in -names -. -enumerate -( -) -{ -let -key -= -Key -( -group_index -maybe_name -) -; -match -self -. -caps -. -get_group -( -group_index -) -{ -None -= -> -map -. -entry -( -& -key -& -None -: -: -< -( -) -> -) -Some -( -span -) -= -> -map -. -entry -( -& -key -& -span -) -} -; -} -map -. -finish -( -) -} -} -/ -/ -/ -An -iterator -over -all -capturing -groups -in -a -Captures -value -. -/ -/ -/ -/ -/ -/ -This -iterator -includes -capturing -groups -that -did -not -participate -in -a -/ -/ -/ -match -. -See -the -[ -Captures -: -: -iter -] -method -documentation -for -more -details -/ -/ -/ -and -examples -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameter -' -a -refers -to -the -lifetime -of -the -underlying -/ -/ -/ -Captures -value -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -CapturesPatternIter -< -' -a -> -{ -caps -: -& -' -a -Captures -names -: -core -: -: -iter -: -: -Enumerate -< -GroupInfoPatternNames -< -' -a -> -> -} -impl -< -' -a -> -Iterator -for -CapturesPatternIter -< -' -a -> -{ -type -Item -= -Option -< -Span -> -; -fn -next -( -& -mut -self -) -- -> -Option -< -Option -< -Span -> -> -{ -let -( -group_index -_ -) -= -self -. -names -. -next -( -) -? -; -Some -( -self -. -caps -. -get_group -( -group_index -) -) -} -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -names -. -size_hint -( -) -} -fn -count -( -self -) -- -> -usize -{ -self -. -names -. -count -( -) -} -} -impl -< -' -a -> -ExactSizeIterator -for -CapturesPatternIter -< -' -a -> -{ -} -impl -< -' -a -> -core -: -: -iter -: -: -FusedIterator -for -CapturesPatternIter -< -' -a -> -{ -} -/ -/ -/ -Represents -information -about -capturing -groups -in -a -compiled -regex -. -/ -/ -/ -/ -/ -/ -The -information -encapsulated -by -this -type -consists -of -the -following -. -For -/ -/ -/ -each -pattern -: -/ -/ -/ -/ -/ -/ -* -A -map -from -every -capture -group -name -to -its -corresponding -capture -group -/ -/ -/ -index -. -/ -/ -/ -* -A -map -from -every -capture -group -index -to -its -corresponding -capture -group -/ -/ -/ -name -. -/ -/ -/ -* -A -map -from -capture -group -index -to -its -corresponding -slot -index -. -A -slot -/ -/ -/ -refers -to -one -half -of -a -capturing -group -. -That -is -a -capture -slot -is -either -/ -/ -/ -the -start -or -end -of -a -capturing -group -. -A -slot -is -usually -the -mechanism -/ -/ -/ -by -which -a -regex -engine -records -offsets -for -each -capturing -group -during -a -/ -/ -/ -search -. -/ -/ -/ -/ -/ -/ -A -GroupInfo -uses -reference -counting -internally -and -is -thus -cheap -to -/ -/ -/ -clone -. -/ -/ -/ -/ -/ -/ -# -Mapping -from -capture -groups -to -slots -/ -/ -/ -/ -/ -/ -One -of -the -main -responsibilities -of -a -GroupInfo -is -to -build -a -mapping -/ -/ -/ -from -( -PatternID -u32 -) -( -where -the -u32 -is -a -capture -index -) -to -something -/ -/ -/ -called -a -" -slot -. -" -As -mentioned -above -a -slot -refers -to -one -half -of -a -/ -/ -/ -capturing -group -. -Both -combined -provide -the -start -and -end -offsets -of -/ -/ -/ -a -capturing -group -that -participated -in -a -match -. -/ -/ -/ -/ -/ -/ -* -* -The -mapping -between -group -indices -and -slots -is -an -API -guarantee -. -* -* -That -/ -/ -/ -is -the -mapping -won -' -t -change -within -a -semver -compatible -release -. -/ -/ -/ -/ -/ -/ -Slots -exist -primarily -because -this -is -a -convenient -mechanism -by -which -/ -/ -/ -regex -engines -report -group -offsets -at -search -time -. -For -example -the -/ -/ -/ -[ -nfa -: -: -thompson -: -: -State -: -: -Capture -] -( -crate -: -: -nfa -: -: -thompson -: -: -State -: -: -Capture -) -/ -/ -/ -NFA -state -includes -the -slot -index -. -When -a -regex -engine -transitions -through -/ -/ -/ -this -state -it -will -likely -use -the -slot -index -to -write -the -current -haystack -/ -/ -/ -offset -to -some -region -of -memory -. -When -a -match -is -found -those -slots -are -/ -/ -/ -then -reported -to -the -caller -typically -via -a -convenient -abstraction -like -a -/ -/ -/ -[ -Captures -] -value -. -/ -/ -/ -/ -/ -/ -Because -this -crate -provides -first -class -support -for -multi -- -pattern -regexes -/ -/ -/ -and -because -of -some -performance -related -reasons -the -mapping -between -/ -/ -/ -capturing -groups -and -slots -is -a -little -complex -. -However -in -the -case -of -a -/ -/ -/ -single -pattern -the -mapping -can -be -described -very -simply -: -for -all -capture -/ -/ -/ -group -indices -i -its -corresponding -slots -are -at -i -* -2 -and -i -* -2 -+ -1 -. -/ -/ -/ -Notice -that -the -pattern -ID -isn -' -t -involved -at -all -here -because -it -only -/ -/ -/ -applies -to -a -single -- -pattern -regex -it -is -therefore -always -0 -. -/ -/ -/ -/ -/ -/ -In -the -multi -- -pattern -case -the -mapping -is -a -bit -more -complicated -. -To -talk -/ -/ -/ -about -it -we -must -define -what -we -mean -by -" -implicit -" -vs -" -explicit -" -/ -/ -/ -capturing -groups -: -/ -/ -/ -/ -/ -/ -* -An -* -* -implicit -* -* -capturing -group -refers -to -the -capturing -group -that -is -/ -/ -/ -present -for -every -pattern -automatically -and -corresponds -to -the -overall -/ -/ -/ -match -of -a -pattern -. -Every -pattern -has -precisely -one -implicit -capturing -/ -/ -/ -group -. -It -is -always -unnamed -and -it -always -corresponds -to -the -capture -group -/ -/ -/ -index -0 -. -/ -/ -/ -* -An -* -* -explicit -* -* -capturing -group -refers -to -any -capturing -group -that -/ -/ -/ -appears -in -the -concrete -syntax -of -the -pattern -. -( -Or -if -an -NFA -was -hand -/ -/ -/ -built -without -any -concrete -syntax -it -refers -to -any -capturing -group -with -an -/ -/ -/ -index -greater -than -0 -. -) -/ -/ -/ -/ -/ -/ -Some -examples -: -/ -/ -/ -/ -/ -/ -* -\ -w -+ -has -one -implicit -capturing -group -and -zero -explicit -capturing -/ -/ -/ -groups -. -/ -/ -/ -* -( -\ -w -+ -) -has -one -implicit -group -and -one -explicit -group -. -/ -/ -/ -* -foo -( -\ -d -+ -) -( -? -: -\ -pL -+ -) -( -\ -d -+ -) -has -one -implicit -group -and -two -explicit -groups -. -/ -/ -/ -/ -/ -/ -Turning -back -to -the -slot -mapping -we -can -now -state -it -as -follows -: -/ -/ -/ -/ -/ -/ -* -Given -a -pattern -ID -pid -the -slots -for -its -implicit -group -are -always -/ -/ -/ -at -pid -* -2 -and -pid -* -2 -+ -1 -. -/ -/ -/ -* -Given -a -pattern -ID -0 -the -slots -for -its -explicit -groups -start -/ -/ -/ -at -group_info -. -pattern_len -( -) -* -2 -. -/ -/ -/ -* -Given -a -pattern -ID -pid -> -0 -the -slots -for -its -explicit -groups -start -/ -/ -/ -immediately -following -where -the -slots -for -the -explicit -groups -of -pid -- -1 -/ -/ -/ -end -. -/ -/ -/ -/ -/ -/ -In -particular -while -there -is -a -concrete -formula -one -can -use -to -determine -/ -/ -/ -where -the -slots -for -the -implicit -group -of -any -pattern -are -there -is -no -/ -/ -/ -general -formula -for -determining -where -the -slots -for -explicit -capturing -/ -/ -/ -groups -are -. -This -is -because -each -pattern -can -contain -a -different -number -/ -/ -/ -of -groups -. -/ -/ -/ -/ -/ -/ -The -intended -way -of -getting -the -slots -for -a -particular -capturing -group -/ -/ -/ -( -whether -implicit -or -explicit -) -is -via -the -[ -GroupInfo -: -: -slot -] -or -/ -/ -/ -[ -GroupInfo -: -: -slots -] -method -. -/ -/ -/ -/ -/ -/ -See -below -for -a -concrete -example -of -how -capturing -groups -get -mapped -to -/ -/ -/ -slots -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -new -GroupInfo -and -query -it -for -/ -/ -/ -information -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -{ -captures -: -: -GroupInfo -primitives -: -: -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -info -= -GroupInfo -: -: -new -( -vec -! -[ -/ -/ -/ -vec -! -[ -None -Some -( -" -foo -" -) -] -/ -/ -/ -vec -! -[ -None -] -/ -/ -/ -vec -! -[ -None -None -None -Some -( -" -bar -" -) -None -] -/ -/ -/ -vec -! -[ -None -None -Some -( -" -foo -" -) -] -/ -/ -/ -] -) -? -; -/ -/ -/ -/ -/ -The -number -of -patterns -being -tracked -. -/ -/ -/ -assert_eq -! -( -4 -info -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -We -can -query -the -number -of -groups -for -any -pattern -. -/ -/ -/ -assert_eq -! -( -2 -info -. -group_len -( -PatternID -: -: -must -( -0 -) -) -) -; -/ -/ -/ -assert_eq -! -( -1 -info -. -group_len -( -PatternID -: -: -must -( -1 -) -) -) -; -/ -/ -/ -assert_eq -! -( -5 -info -. -group_len -( -PatternID -: -: -must -( -2 -) -) -) -; -/ -/ -/ -assert_eq -! -( -3 -info -. -group_len -( -PatternID -: -: -must -( -3 -) -) -) -; -/ -/ -/ -/ -/ -An -invalid -pattern -always -has -zero -groups -. -/ -/ -/ -assert_eq -! -( -0 -info -. -group_len -( -PatternID -: -: -must -( -999 -) -) -) -; -/ -/ -/ -/ -/ -2 -slots -per -group -/ -/ -/ -assert_eq -! -( -22 -info -. -slot_len -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -can -map -a -group -index -for -a -particular -pattern -to -its -name -if -/ -/ -/ -/ -/ -one -exists -. -/ -/ -/ -assert_eq -! -( -Some -( -" -foo -" -) -info -. -to_name -( -PatternID -: -: -must -( -3 -) -2 -) -) -; -/ -/ -/ -assert_eq -! -( -None -info -. -to_name -( -PatternID -: -: -must -( -2 -) -4 -) -) -; -/ -/ -/ -/ -/ -Or -map -a -name -to -its -group -index -. -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -info -. -to_index -( -PatternID -: -: -must -( -0 -) -" -foo -" -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -info -. -to_index -( -PatternID -: -: -must -( -3 -) -" -foo -" -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -mapping -from -capture -groups -to -slots -/ -/ -/ -/ -/ -/ -This -example -shows -the -specific -mapping -from -capture -group -indices -for -/ -/ -/ -each -pattern -to -their -corresponding -slots -. -The -slot -values -shown -in -this -/ -/ -/ -example -are -considered -an -API -guarantee -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -{ -captures -: -: -GroupInfo -primitives -: -: -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -info -= -GroupInfo -: -: -new -( -vec -! -[ -/ -/ -/ -vec -! -[ -None -Some -( -" -foo -" -) -] -/ -/ -/ -vec -! -[ -None -] -/ -/ -/ -vec -! -[ -None -None -None -Some -( -" -bar -" -) -None -] -/ -/ -/ -vec -! -[ -None -None -Some -( -" -foo -" -) -] -/ -/ -/ -] -) -? -; -/ -/ -/ -/ -/ -/ -/ -/ -We -first -show -the -slots -for -each -pattern -' -s -implicit -group -. -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -1 -) -) -info -. -slots -( -PatternID -: -: -must -( -0 -) -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -2 -3 -) -) -info -. -slots -( -PatternID -: -: -must -( -1 -) -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -4 -5 -) -) -info -. -slots -( -PatternID -: -: -must -( -2 -) -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -6 -7 -) -) -info -. -slots -( -PatternID -: -: -must -( -3 -) -0 -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -now -we -show -the -slots -for -each -pattern -' -s -explicit -group -. -/ -/ -/ -assert_eq -! -( -Some -( -( -8 -9 -) -) -info -. -slots -( -PatternID -: -: -must -( -0 -) -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -10 -11 -) -) -info -. -slots -( -PatternID -: -: -must -( -2 -) -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -12 -13 -) -) -info -. -slots -( -PatternID -: -: -must -( -2 -) -2 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -14 -15 -) -) -info -. -slots -( -PatternID -: -: -must -( -2 -) -3 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -16 -17 -) -) -info -. -slots -( -PatternID -: -: -must -( -2 -) -4 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -18 -19 -) -) -info -. -slots -( -PatternID -: -: -must -( -3 -) -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -20 -21 -) -) -info -. -slots -( -PatternID -: -: -must -( -3 -) -2 -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Asking -for -the -slots -for -an -invalid -pattern -ID -or -even -for -an -invalid -/ -/ -/ -/ -/ -group -index -for -a -specific -pattern -will -return -None -. -So -for -example -/ -/ -/ -/ -/ -you -' -re -guaranteed -to -not -get -the -slots -for -a -different -pattern -than -the -/ -/ -/ -/ -/ -one -requested -. -/ -/ -/ -assert_eq -! -( -None -info -. -slots -( -PatternID -: -: -must -( -5 -) -0 -) -) -; -/ -/ -/ -assert_eq -! -( -None -info -. -slots -( -PatternID -: -: -must -( -1 -) -1 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -Default -) -] -pub -struct -GroupInfo -( -Arc -< -GroupInfoInner -> -) -; -impl -GroupInfo -{ -/ -/ -/ -Creates -a -new -group -info -from -a -sequence -of -patterns -where -each -/ -/ -/ -sequence -of -patterns -yields -a -sequence -of -possible -group -names -. -The -/ -/ -/ -index -of -each -pattern -in -the -sequence -corresponds -to -its -PatternID -/ -/ -/ -and -the -index -of -each -group -in -each -pattern -' -s -sequence -corresponds -to -/ -/ -/ -its -corresponding -group -index -. -/ -/ -/ -/ -/ -/ -While -this -constructor -is -very -generic -and -therefore -perhaps -hard -to -/ -/ -/ -chew -on -an -example -of -a -valid -concrete -type -that -can -be -passed -to -/ -/ -/ -this -constructor -is -Vec -< -Vec -< -Option -< -String -> -> -> -. -The -outer -Vec -/ -/ -/ -corresponds -to -the -patterns -i -. -e -. -one -Vec -< -Option -< -String -> -> -per -/ -/ -/ -pattern -. -The -inner -Vec -corresponds -to -the -capturing -groups -for -/ -/ -/ -each -pattern -. -The -Option -< -String -> -corresponds -to -the -name -of -the -/ -/ -/ -capturing -group -if -present -. -/ -/ -/ -/ -/ -/ -It -is -legal -to -pass -an -empty -iterator -to -this -constructor -. -It -will -/ -/ -/ -return -an -empty -group -info -with -zero -slots -. -An -empty -group -info -is -/ -/ -/ -useful -for -cases -where -you -have -no -patterns -or -for -cases -where -slots -/ -/ -/ -aren -' -t -being -used -at -all -( -e -. -g -. -for -most -DFAs -in -this -crate -) -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -constructor -returns -an -error -if -the -given -capturing -groups -are -/ -/ -/ -invalid -in -some -way -. -Those -reasons -include -but -are -not -necessarily -/ -/ -/ -limited -to -: -/ -/ -/ -/ -/ -/ -* -Too -many -patterns -( -i -. -e -. -PatternID -would -overflow -) -. -/ -/ -/ -* -Too -many -capturing -groups -( -e -. -g -. -u32 -would -overflow -) -. -/ -/ -/ -* -A -pattern -is -given -that -has -no -capturing -groups -. -( -All -patterns -must -/ -/ -/ -have -at -least -an -implicit -capturing -group -at -index -0 -. -) -/ -/ -/ -* -The -capturing -group -at -index -0 -has -a -name -. -It -must -be -unnamed -. -/ -/ -/ -* -There -are -duplicate -capturing -group -names -within -the -same -pattern -. -/ -/ -/ -( -Multiple -capturing -groups -with -the -same -name -may -exist -but -they -/ -/ -/ -must -be -in -different -patterns -. -) -/ -/ -/ -/ -/ -/ -An -example -below -shows -how -to -trigger -some -of -the -above -error -/ -/ -/ -conditions -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -new -GroupInfo -and -query -it -for -/ -/ -/ -information -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -captures -: -: -GroupInfo -; -/ -/ -/ -/ -/ -/ -let -info -= -GroupInfo -: -: -new -( -vec -! -[ -/ -/ -/ -vec -! -[ -None -Some -( -" -foo -" -) -] -/ -/ -/ -vec -! -[ -None -] -/ -/ -/ -vec -! -[ -None -None -None -Some -( -" -bar -" -) -None -] -/ -/ -/ -vec -! -[ -None -None -Some -( -" -foo -" -) -] -/ -/ -/ -] -) -? -; -/ -/ -/ -/ -/ -The -number -of -patterns -being -tracked -. -/ -/ -/ -assert_eq -! -( -4 -info -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -2 -slots -per -group -/ -/ -/ -assert_eq -! -( -22 -info -. -slot_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -empty -GroupInfo -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -new -GroupInfo -and -query -it -for -/ -/ -/ -information -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -captures -: -: -GroupInfo -; -/ -/ -/ -/ -/ -/ -let -info -= -GroupInfo -: -: -empty -( -) -; -/ -/ -/ -/ -/ -Everything -is -zero -. -/ -/ -/ -assert_eq -! -( -0 -info -. -pattern_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -0 -info -. -slot_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -error -conditions -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -provoke -some -of -the -ways -in -which -building -/ -/ -/ -a -GroupInfo -can -fail -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -captures -: -: -GroupInfo -; -/ -/ -/ -/ -/ -/ -/ -/ -Either -the -group -info -is -empty -or -all -patterns -must -have -at -least -/ -/ -/ -/ -/ -one -capturing -group -. -/ -/ -/ -assert -! -( -GroupInfo -: -: -new -( -vec -! -[ -/ -/ -/ -vec -! -[ -None -Some -( -" -a -" -) -] -/ -/ -ok -/ -/ -/ -vec -! -[ -None -] -/ -/ -ok -/ -/ -/ -vec -! -[ -] -/ -/ -not -ok -/ -/ -/ -] -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -Note -that -building -an -empty -group -info -is -OK -. -/ -/ -/ -assert -! -( -GroupInfo -: -: -new -( -Vec -: -: -< -Vec -< -Option -< -String -> -> -> -: -: -new -( -) -) -. -is_ok -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -first -group -in -each -pattern -must -correspond -to -an -implicit -/ -/ -/ -/ -/ -anonymous -group -. -i -. -e -. -One -that -is -not -named -. -By -convention -this -/ -/ -/ -/ -/ -group -corresponds -to -the -overall -match -of -a -regex -. -Every -other -group -/ -/ -/ -/ -/ -in -a -pattern -is -explicit -and -optional -. -/ -/ -/ -assert -! -( -GroupInfo -: -: -new -( -vec -! -[ -vec -! -[ -Some -( -" -foo -" -) -] -] -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -There -must -not -be -duplicate -group -names -within -the -same -pattern -. -/ -/ -/ -assert -! -( -GroupInfo -: -: -new -( -vec -! -[ -/ -/ -/ -vec -! -[ -None -Some -( -" -foo -" -) -Some -( -" -foo -" -) -] -/ -/ -/ -] -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -But -duplicate -names -across -distinct -patterns -is -OK -. -/ -/ -/ -assert -! -( -GroupInfo -: -: -new -( -vec -! -[ -/ -/ -/ -vec -! -[ -None -Some -( -" -foo -" -) -] -/ -/ -/ -vec -! -[ -None -Some -( -" -foo -" -) -] -/ -/ -/ -] -) -. -is_ok -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -There -are -other -ways -for -building -a -GroupInfo -to -fail -but -are -/ -/ -/ -difficult -to -show -. -For -example -if -the -number -of -patterns -given -would -/ -/ -/ -overflow -PatternID -. -pub -fn -new -< -P -G -N -> -( -pattern_groups -: -P -) -- -> -Result -< -GroupInfo -GroupInfoError -> -where -P -: -IntoIterator -< -Item -= -G -> -G -: -IntoIterator -< -Item -= -Option -< -N -> -> -N -: -AsRef -< -str -> -{ -let -mut -group_info -= -GroupInfoInner -{ -slot_ranges -: -vec -! -[ -] -name_to_index -: -vec -! -[ -] -index_to_name -: -vec -! -[ -] -memory_extra -: -0 -} -; -for -( -pattern_index -groups -) -in -pattern_groups -. -into_iter -( -) -. -enumerate -( -) -{ -/ -/ -If -we -can -' -t -convert -the -pattern -index -to -an -ID -then -the -caller -/ -/ -tried -to -build -capture -info -for -too -many -patterns -. -let -pid -= -PatternID -: -: -new -( -pattern_index -) -. -map_err -( -GroupInfoError -: -: -too_many_patterns -) -? -; -let -mut -groups_iter -= -groups -. -into_iter -( -) -. -enumerate -( -) -; -match -groups_iter -. -next -( -) -{ -None -= -> -return -Err -( -GroupInfoError -: -: -missing_groups -( -pid -) -) -Some -( -( -_ -Some -( -_ -) -) -) -= -> -{ -return -Err -( -GroupInfoError -: -: -first_must_be_unnamed -( -pid -) -) -} -Some -( -( -_ -None -) -) -= -> -{ -} -} -group_info -. -add_first_group -( -pid -) -; -/ -/ -Now -iterate -over -the -rest -which -correspond -to -all -of -the -/ -/ -( -conventionally -) -explicit -capture -groups -in -a -regex -pattern -. -for -( -group_index -maybe_name -) -in -groups_iter -{ -/ -/ -Just -like -for -patterns -if -the -group -index -can -' -t -be -/ -/ -converted -to -a -" -small -" -index -then -the -caller -has -given -too -/ -/ -many -groups -for -a -particular -pattern -. -let -group -= -SmallIndex -: -: -new -( -group_index -) -. -map_err -( -| -_ -| -{ -GroupInfoError -: -: -too_many_groups -( -pid -group_index -) -} -) -? -; -group_info -. -add_explicit_group -( -pid -group -maybe_name -) -? -; -} -} -group_info -. -fixup_slot_ranges -( -) -? -; -Ok -( -GroupInfo -( -Arc -: -: -new -( -group_info -) -) -) -} -/ -/ -/ -This -creates -an -empty -GroupInfo -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -calling -GroupInfo -: -: -new -with -an -/ -/ -/ -iterator -that -yields -no -elements -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -new -empty -GroupInfo -and -query -it -/ -/ -/ -for -information -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -captures -: -: -GroupInfo -; -/ -/ -/ -/ -/ -/ -let -info -= -GroupInfo -: -: -empty -( -) -; -/ -/ -/ -/ -/ -Everything -is -zero -. -/ -/ -/ -assert_eq -! -( -0 -info -. -pattern_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -0 -info -. -all_group_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -0 -info -. -slot_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -empty -( -) -- -> -GroupInfo -{ -GroupInfo -: -: -new -( -core -: -: -iter -: -: -empty -: -: -< -[ -Option -< -& -str -> -; -0 -] -> -( -) -) -. -expect -( -" -empty -group -info -is -always -valid -" -) -} -/ -/ -/ -Return -the -capture -group -index -corresponding -to -the -given -name -in -the -/ -/ -/ -given -pattern -. -If -no -such -capture -group -name -exists -in -the -given -/ -/ -/ -pattern -then -this -returns -None -. -/ -/ -/ -/ -/ -/ -If -the -given -pattern -ID -is -invalid -then -this -returns -None -. -/ -/ -/ -/ -/ -/ -This -also -returns -None -for -all -inputs -if -these -captures -are -empty -/ -/ -/ -( -e -. -g -. -built -from -an -empty -[ -GroupInfo -] -) -. -To -check -whether -captures -/ -/ -/ -are -are -present -for -a -specific -pattern -use -[ -GroupInfo -: -: -group_len -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -the -capture -index -for -the -given -pattern -/ -/ -/ -and -group -name -. -/ -/ -/ -/ -/ -/ -Remember -that -capture -indices -are -relative -to -the -pattern -such -that -/ -/ -/ -the -same -capture -index -value -may -refer -to -different -capturing -groups -/ -/ -/ -for -distinct -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -( -pid0 -pid1 -) -= -( -PatternID -: -: -must -( -0 -) -PatternID -: -: -must -( -1 -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -/ -/ -/ -r -" -a -( -? -P -< -quux -> -\ -w -+ -) -z -( -? -P -< -foo -> -\ -s -+ -) -" -/ -/ -/ -r -" -a -( -? -P -< -foo -> -\ -d -+ -) -z -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -groups -= -nfa -. -group_info -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -groups -. -to_index -( -pid0 -" -foo -" -) -) -; -/ -/ -/ -/ -/ -Recall -that -capture -index -0 -is -always -unnamed -and -refers -to -the -/ -/ -/ -/ -/ -entire -pattern -. -So -the -first -capturing -group -present -in -the -pattern -/ -/ -/ -/ -/ -itself -always -starts -at -index -1 -. -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -groups -. -to_index -( -pid1 -" -foo -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -if -a -name -does -not -exist -for -a -particular -pattern -None -is -/ -/ -/ -/ -/ -returned -. -/ -/ -/ -assert -! -( -groups -. -to_index -( -pid0 -" -quux -" -) -. -is_some -( -) -) -; -/ -/ -/ -assert -! -( -groups -. -to_index -( -pid1 -" -quux -" -) -. -is_none -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -to_index -( -& -self -pid -: -PatternID -name -: -& -str -) -- -> -Option -< -usize -> -{ -let -indices -= -self -. -0 -. -name_to_index -. -get -( -pid -. -as_usize -( -) -) -? -; -indices -. -get -( -name -) -. -cloned -( -) -. -map -( -| -i -| -i -. -as_usize -( -) -) -} -/ -/ -/ -Return -the -capture -name -for -the -given -index -and -given -pattern -. -If -the -/ -/ -/ -corresponding -group -does -not -have -a -name -then -this -returns -None -. -/ -/ -/ -/ -/ -/ -If -the -pattern -ID -is -invalid -then -this -returns -None -. -/ -/ -/ -/ -/ -/ -If -the -group -index -is -invalid -for -the -given -pattern -then -this -returns -/ -/ -/ -None -. -A -group -index -is -valid -for -a -pattern -pid -in -an -nfa -if -and -/ -/ -/ -only -if -index -< -nfa -. -pattern_capture_len -( -pid -) -. -/ -/ -/ -/ -/ -/ -This -also -returns -None -for -all -inputs -if -these -captures -are -empty -/ -/ -/ -( -e -. -g -. -built -from -an -empty -[ -GroupInfo -] -) -. -To -check -whether -captures -/ -/ -/ -are -are -present -for -a -specific -pattern -use -[ -GroupInfo -: -: -group_len -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -find -the -capture -group -name -for -the -given -/ -/ -/ -pattern -and -group -index -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -( -pid0 -pid1 -) -= -( -PatternID -: -: -must -( -0 -) -PatternID -: -: -must -( -1 -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -/ -/ -/ -r -" -a -( -? -P -< -foo -> -\ -w -+ -) -z -( -\ -s -+ -) -x -( -\ -d -+ -) -" -/ -/ -/ -r -" -a -( -\ -d -+ -) -z -( -? -P -< -foo -> -\ -s -+ -) -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -groups -= -nfa -. -group_info -( -) -; -/ -/ -/ -assert_eq -! -( -None -groups -. -to_name -( -pid0 -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -" -foo -" -) -groups -. -to_name -( -pid0 -1 -) -) -; -/ -/ -/ -assert_eq -! -( -None -groups -. -to_name -( -pid0 -2 -) -) -; -/ -/ -/ -assert_eq -! -( -None -groups -. -to_name -( -pid0 -3 -) -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -None -groups -. -to_name -( -pid1 -0 -) -) -; -/ -/ -/ -assert_eq -! -( -None -groups -. -to_name -( -pid1 -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -" -foo -" -) -groups -. -to_name -( -pid1 -2 -) -) -; -/ -/ -/ -/ -/ -' -3 -' -is -not -a -valid -capture -index -for -the -second -pattern -. -/ -/ -/ -assert_eq -! -( -None -groups -. -to_name -( -pid1 -3 -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -to_name -( -& -self -pid -: -PatternID -group_index -: -usize -) -- -> -Option -< -& -str -> -{ -let -pattern_names -= -self -. -0 -. -index_to_name -. -get -( -pid -. -as_usize -( -) -) -? -; -pattern_names -. -get -( -group_index -) -? -. -as_deref -( -) -} -/ -/ -/ -Return -an -iterator -of -all -capture -groups -and -their -names -( -if -present -) -/ -/ -/ -for -a -particular -pattern -. -/ -/ -/ -/ -/ -/ -If -the -given -pattern -ID -is -invalid -or -if -this -GroupInfo -is -empty -/ -/ -/ -then -the -iterator -yields -no -elements -. -/ -/ -/ -/ -/ -/ -The -number -of -elements -yielded -by -this -iterator -is -always -equal -to -/ -/ -/ -the -result -of -calling -[ -GroupInfo -: -: -group_len -] -with -the -same -/ -/ -/ -PatternID -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -a -list -of -all -capture -group -names -for -/ -/ -/ -a -particular -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -r -" -( -a -) -( -? -P -< -foo -> -b -) -( -c -) -( -d -) -( -? -P -< -bar -> -e -) -" -) -? -; -/ -/ -/ -/ -/ -The -first -is -the -implicit -group -that -is -always -unnammed -. -The -next -/ -/ -/ -/ -/ -5 -groups -are -the -explicit -groups -found -in -the -concrete -syntax -above -. -/ -/ -/ -let -expected -= -vec -! -[ -None -None -Some -( -" -foo -" -) -None -None -Some -( -" -bar -" -) -] -; -/ -/ -/ -let -got -: -Vec -< -Option -< -& -str -> -> -= -/ -/ -/ -nfa -. -group_info -( -) -. -pattern_names -( -PatternID -: -: -ZERO -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Using -an -invalid -pattern -ID -will -result -in -nothing -yielded -. -/ -/ -/ -let -got -= -nfa -. -group_info -( -) -. -pattern_names -( -PatternID -: -: -must -( -999 -) -) -. -count -( -) -; -/ -/ -/ -assert_eq -! -( -0 -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -pattern_names -( -& -self -pid -: -PatternID -) -- -> -GroupInfoPatternNames -< -' -_ -> -{ -GroupInfoPatternNames -{ -it -: -self -. -0 -. -index_to_name -. -get -( -pid -. -as_usize -( -) -) -. -map -( -| -indices -| -indices -. -iter -( -) -) -. -unwrap_or -( -[ -] -. -iter -( -) -) -} -} -/ -/ -/ -Return -an -iterator -of -all -capture -groups -for -all -patterns -supported -by -/ -/ -/ -this -GroupInfo -. -Each -item -yielded -is -a -triple -of -the -group -' -s -pattern -/ -/ -/ -ID -index -in -the -pattern -and -the -group -' -s -name -if -present -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -get -a -list -of -all -capture -groups -found -in -/ -/ -/ -one -NFA -potentially -spanning -multiple -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -/ -/ -/ -r -" -( -? -P -< -foo -> -a -) -" -/ -/ -/ -r -" -a -" -/ -/ -/ -r -" -( -a -) -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -( -PatternID -: -: -must -( -0 -) -0 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -0 -) -1 -Some -( -" -foo -" -) -) -/ -/ -/ -( -PatternID -: -: -must -( -1 -) -0 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -2 -) -0 -None -) -/ -/ -/ -( -PatternID -: -: -must -( -2 -) -1 -None -) -/ -/ -/ -] -; -/ -/ -/ -let -got -: -Vec -< -( -PatternID -usize -Option -< -& -str -> -) -> -= -/ -/ -/ -nfa -. -group_info -( -) -. -all_names -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Unlike -other -capturing -group -related -routines -this -routine -doesn -' -t -/ -/ -/ -panic -even -if -captures -aren -' -t -enabled -on -this -NFA -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -{ -NFA -WhichCaptures -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build_many -( -& -[ -/ -/ -/ -r -" -( -? -P -< -foo -> -a -) -" -/ -/ -/ -r -" -a -" -/ -/ -/ -r -" -( -a -) -" -/ -/ -/ -] -) -? -; -/ -/ -/ -/ -/ -When -captures -aren -' -t -enabled -there -' -s -nothing -to -return -. -/ -/ -/ -assert_eq -! -( -0 -nfa -. -group_info -( -) -. -all_names -( -) -. -count -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -all_names -( -& -self -) -- -> -GroupInfoAllNames -< -' -_ -> -{ -GroupInfoAllNames -{ -group_info -: -self -pids -: -PatternID -: -: -iter -( -self -. -pattern_len -( -) -) -current_pid -: -None -names -: -None -} -} -/ -/ -/ -Returns -the -starting -and -ending -slot -corresponding -to -the -given -/ -/ -/ -capturing -group -for -the -given -pattern -. -The -ending -slot -is -always -one -/ -/ -/ -more -than -the -starting -slot -returned -. -/ -/ -/ -/ -/ -/ -Note -that -this -is -like -[ -GroupInfo -: -: -slot -] -except -that -it -also -returns -/ -/ -/ -the -ending -slot -value -for -convenience -. -/ -/ -/ -/ -/ -/ -If -either -the -pattern -ID -or -the -capture -index -is -invalid -then -this -/ -/ -/ -returns -None -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -starting -slots -for -the -first -capturing -/ -/ -/ -group -of -each -pattern -are -distinct -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -a -" -" -b -" -] -) -? -; -/ -/ -/ -assert_ne -! -( -/ -/ -/ -nfa -. -group_info -( -) -. -slots -( -PatternID -: -: -must -( -0 -) -0 -) -/ -/ -/ -nfa -. -group_info -( -) -. -slots -( -PatternID -: -: -must -( -1 -) -0 -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Also -the -start -and -end -slot -values -are -never -equivalent -. -/ -/ -/ -let -( -start -end -) -= -nfa -. -group_info -( -) -. -slots -( -PatternID -: -: -ZERO -0 -) -. -unwrap -( -) -; -/ -/ -/ -assert_ne -! -( -start -end -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -slots -( -& -self -pid -: -PatternID -group_index -: -usize -) -- -> -Option -< -( -usize -usize -) -> -{ -/ -/ -Since -' -slot -' -only -even -returns -valid -starting -slots -we -know -that -/ -/ -there -must -also -be -an -end -slot -and -that -end -slot -is -always -one -more -/ -/ -than -the -start -slot -. -self -. -slot -( -pid -group_index -) -. -map -( -| -start -| -( -start -start -+ -1 -) -) -} -/ -/ -/ -Returns -the -starting -slot -corresponding -to -the -given -capturing -group -/ -/ -/ -for -the -given -pattern -. -The -ending -slot -is -always -one -more -than -the -/ -/ -/ -value -returned -. -/ -/ -/ -/ -/ -/ -If -either -the -pattern -ID -or -the -capture -index -is -invalid -then -this -/ -/ -/ -returns -None -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -starting -slots -for -the -first -capturing -/ -/ -/ -group -of -each -pattern -are -distinct -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -NFA -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -a -" -" -b -" -] -) -? -; -/ -/ -/ -assert_ne -! -( -/ -/ -/ -nfa -. -group_info -( -) -. -slot -( -PatternID -: -: -must -( -0 -) -0 -) -/ -/ -/ -nfa -. -group_info -( -) -. -slot -( -PatternID -: -: -must -( -1 -) -0 -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -slot -( -& -self -pid -: -PatternID -group_index -: -usize -) -- -> -Option -< -usize -> -{ -if -group_index -> -= -self -. -group_len -( -pid -) -{ -return -None -; -} -/ -/ -At -this -point -we -know -that -' -pid -' -refers -to -a -real -pattern -and -that -/ -/ -' -group_index -' -refers -to -a -real -group -. -We -therefore -also -know -that -/ -/ -the -pattern -and -group -can -be -combined -to -return -a -correct -slot -. -/ -/ -That -' -s -why -we -don -' -t -need -to -use -checked -arithmetic -below -. -if -group_index -= -= -0 -{ -Some -( -pid -. -as_usize -( -) -* -2 -) -} -else -{ -/ -/ -As -above -we -don -' -t -need -to -check -that -our -slot -is -less -than -the -/ -/ -end -of -our -range -since -we -already -know -the -group -index -is -a -/ -/ -valid -index -for -the -given -pattern -. -let -( -start -_ -) -= -self -. -0 -. -slot_ranges -[ -pid -] -; -Some -( -start -. -as_usize -( -) -+ -( -( -group_index -- -1 -) -* -2 -) -) -} -} -/ -/ -/ -Returns -the -total -number -of -patterns -in -this -GroupInfo -. -/ -/ -/ -/ -/ -/ -This -may -return -zero -if -the -GroupInfo -was -constructed -with -no -/ -/ -/ -patterns -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -be -no -bigger -than -[ -PatternID -: -: -LIMIT -] -because -/ -/ -/ -GroupInfo -construction -will -fail -if -too -many -patterns -are -added -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -nfa -: -: -thompson -: -: -NFA -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -[ -0 -- -9 -] -+ -" -" -[ -a -- -z -] -+ -" -" -[ -A -- -Z -] -+ -" -] -) -? -; -/ -/ -/ -assert_eq -! -( -3 -nfa -. -group_info -( -) -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -never_match -( -) -; -/ -/ -/ -assert_eq -! -( -0 -nfa -. -group_info -( -) -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -always_match -( -) -; -/ -/ -/ -assert_eq -! -( -1 -nfa -. -group_info -( -) -. -pattern_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -0 -. -pattern_len -( -) -} -/ -/ -/ -Return -the -number -of -capture -groups -in -a -pattern -. -/ -/ -/ -/ -/ -/ -If -the -pattern -ID -is -invalid -then -this -returns -0 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -the -values -returned -by -this -routine -may -vary -/ -/ -/ -for -different -patterns -and -NFA -configurations -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -WhichCaptures -} -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -r -" -( -a -) -( -b -) -( -c -) -" -) -? -; -/ -/ -/ -/ -/ -There -are -3 -explicit -groups -in -the -pattern -' -s -concrete -syntax -and -/ -/ -/ -/ -/ -1 -unnamed -and -implicit -group -spanning -the -entire -pattern -. -/ -/ -/ -assert_eq -! -( -4 -nfa -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -r -" -abc -" -) -? -; -/ -/ -/ -/ -/ -There -is -just -the -unnamed -implicit -group -. -/ -/ -/ -assert_eq -! -( -1 -nfa -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -r -" -abc -" -) -? -; -/ -/ -/ -/ -/ -We -disabled -capturing -groups -so -there -are -none -. -/ -/ -/ -assert_eq -! -( -0 -nfa -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -r -" -( -a -) -( -b -) -( -c -) -" -) -? -; -/ -/ -/ -/ -/ -We -disabled -capturing -groups -so -there -are -none -even -if -there -are -/ -/ -/ -/ -/ -explicit -groups -in -the -concrete -syntax -. -/ -/ -/ -assert_eq -! -( -0 -nfa -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -group_len -( -& -self -pid -: -PatternID -) -- -> -usize -{ -self -. -0 -. -group_len -( -pid -) -} -/ -/ -/ -Return -the -total -number -of -capture -groups -across -all -patterns -. -/ -/ -/ -/ -/ -/ -This -includes -implicit -groups -that -represent -the -entire -match -of -a -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -the -values -returned -by -this -routine -may -vary -/ -/ -/ -for -different -patterns -and -NFA -configurations -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -NFA -WhichCaptures -} -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -r -" -( -a -) -( -b -) -( -c -) -" -) -? -; -/ -/ -/ -/ -/ -There -are -3 -explicit -groups -in -the -pattern -' -s -concrete -syntax -and -/ -/ -/ -/ -/ -1 -unnamed -and -implicit -group -spanning -the -entire -pattern -. -/ -/ -/ -assert_eq -! -( -4 -nfa -. -group_info -( -) -. -all_group_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new -( -r -" -abc -" -) -? -; -/ -/ -/ -/ -/ -There -is -just -the -unnamed -implicit -group -. -/ -/ -/ -assert_eq -! -( -1 -nfa -. -group_info -( -) -. -all_group_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -new_many -( -& -[ -" -( -a -) -" -" -b -" -" -( -c -) -" -] -) -? -; -/ -/ -/ -/ -/ -Each -pattern -has -one -implicit -groups -and -two -/ -/ -/ -/ -/ -patterns -have -one -explicit -group -each -. -/ -/ -/ -assert_eq -! -( -5 -nfa -. -group_info -( -) -. -all_group_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -r -" -abc -" -) -? -; -/ -/ -/ -/ -/ -We -disabled -capturing -groups -so -there -are -none -. -/ -/ -/ -assert_eq -! -( -0 -nfa -. -group_info -( -) -. -all_group_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -nfa -= -NFA -: -: -compiler -( -) -/ -/ -/ -. -configure -( -NFA -: -: -config -( -) -. -which_captures -( -WhichCaptures -: -: -None -) -) -/ -/ -/ -. -build -( -r -" -( -a -) -( -b -) -( -c -) -" -) -? -; -/ -/ -/ -/ -/ -We -disabled -capturing -groups -so -there -are -none -even -if -there -are -/ -/ -/ -/ -/ -explicit -groups -in -the -concrete -syntax -. -/ -/ -/ -assert_eq -! -( -0 -nfa -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -all_group_len -( -& -self -) -- -> -usize -{ -self -. -slot_len -( -) -/ -2 -} -/ -/ -/ -Returns -the -total -number -of -slots -in -this -GroupInfo -across -all -/ -/ -/ -patterns -. -/ -/ -/ -/ -/ -/ -The -total -number -of -slots -is -always -twice -the -total -number -of -capturing -/ -/ -/ -groups -including -both -implicit -and -explicit -groups -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -relationship -between -the -number -of -capturing -/ -/ -/ -groups -and -slots -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -captures -: -: -GroupInfo -; -/ -/ -/ -/ -/ -/ -/ -/ -There -are -11 -total -groups -here -. -/ -/ -/ -let -info -= -GroupInfo -: -: -new -( -vec -! -[ -/ -/ -/ -vec -! -[ -None -Some -( -" -foo -" -) -] -/ -/ -/ -vec -! -[ -None -] -/ -/ -/ -vec -! -[ -None -None -None -Some -( -" -bar -" -) -None -] -/ -/ -/ -vec -! -[ -None -None -Some -( -" -foo -" -) -] -/ -/ -/ -] -) -? -; -/ -/ -/ -/ -/ -2 -slots -per -group -gives -us -11 -* -2 -= -22 -slots -. -/ -/ -/ -assert_eq -! -( -22 -info -. -slot_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -slot_len -( -& -self -) -- -> -usize -{ -self -. -0 -. -small_slot_len -( -) -. -as_usize -( -) -} -/ -/ -/ -Returns -the -total -number -of -slots -for -implicit -capturing -groups -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -GroupInfo -: -: -slot_len -] -except -it -doesn -' -t -include -the -/ -/ -/ -explicit -slots -for -each -pattern -. -Since -there -are -always -exactly -2 -/ -/ -/ -implicit -slots -for -each -pattern -the -number -of -implicit -slots -is -always -/ -/ -/ -equal -to -twice -the -number -of -patterns -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -relationship -between -the -number -of -capturing -/ -/ -/ -groups -implicit -slots -and -explicit -slots -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -captures -: -: -GroupInfo -; -/ -/ -/ -/ -/ -/ -/ -/ -There -are -11 -total -groups -here -. -/ -/ -/ -let -info -= -GroupInfo -: -: -new -( -vec -! -[ -vec -! -[ -None -Some -( -" -foo -" -) -Some -( -" -bar -" -) -] -] -) -? -; -/ -/ -/ -/ -/ -2 -slots -per -group -gives -us -11 -* -2 -= -22 -slots -. -/ -/ -/ -assert_eq -! -( -6 -info -. -slot_len -( -) -) -; -/ -/ -/ -/ -/ -2 -implicit -slots -per -pattern -gives -us -2 -implicit -slots -since -there -/ -/ -/ -/ -/ -is -1 -pattern -. -/ -/ -/ -assert_eq -! -( -2 -info -. -implicit_slot_len -( -) -) -; -/ -/ -/ -/ -/ -2 -explicit -capturing -groups -gives -us -2 -* -2 -= -4 -explicit -slots -. -/ -/ -/ -assert_eq -! -( -4 -info -. -explicit_slot_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -implicit_slot_len -( -& -self -) -- -> -usize -{ -self -. -pattern_len -( -) -* -2 -} -/ -/ -/ -Returns -the -total -number -of -slots -for -explicit -capturing -groups -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -GroupInfo -: -: -slot_len -] -except -it -doesn -' -t -include -the -/ -/ -/ -implicit -slots -for -each -pattern -. -( -There -are -always -2 -implicit -slots -for -/ -/ -/ -each -pattern -. -) -/ -/ -/ -/ -/ -/ -For -a -non -- -empty -GroupInfo -it -is -always -the -case -that -slot_len -is -/ -/ -/ -strictly -greater -than -explicit_slot_len -. -For -an -empty -GroupInfo -/ -/ -/ -both -the -total -number -of -slots -and -the -number -of -explicit -slots -is -/ -/ -/ -0 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -relationship -between -the -number -of -capturing -/ -/ -/ -groups -implicit -slots -and -explicit -slots -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -captures -: -: -GroupInfo -; -/ -/ -/ -/ -/ -/ -/ -/ -There -are -11 -total -groups -here -. -/ -/ -/ -let -info -= -GroupInfo -: -: -new -( -vec -! -[ -vec -! -[ -None -Some -( -" -foo -" -) -Some -( -" -bar -" -) -] -] -) -? -; -/ -/ -/ -/ -/ -2 -slots -per -group -gives -us -11 -* -2 -= -22 -slots -. -/ -/ -/ -assert_eq -! -( -6 -info -. -slot_len -( -) -) -; -/ -/ -/ -/ -/ -2 -implicit -slots -per -pattern -gives -us -2 -implicit -slots -since -there -/ -/ -/ -/ -/ -is -1 -pattern -. -/ -/ -/ -assert_eq -! -( -2 -info -. -implicit_slot_len -( -) -) -; -/ -/ -/ -/ -/ -2 -explicit -capturing -groups -gives -us -2 -* -2 -= -4 -explicit -slots -. -/ -/ -/ -assert_eq -! -( -4 -info -. -explicit_slot_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -explicit_slot_len -( -& -self -) -- -> -usize -{ -self -. -slot_len -( -) -. -saturating_sub -( -self -. -implicit_slot_len -( -) -) -} -/ -/ -/ -Returns -the -memory -usage -in -bytes -of -this -GroupInfo -. -/ -/ -/ -/ -/ -/ -This -does -* -* -not -* -* -include -the -stack -size -used -up -by -this -GroupInfo -. -/ -/ -/ -To -compute -that -use -std -: -: -mem -: -: -size_of -: -: -< -GroupInfo -> -( -) -. -# -[ -inline -] -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -use -core -: -: -mem -: -: -size_of -as -s -; -s -: -: -< -GroupInfoInner -> -( -) -+ -self -. -0 -. -slot_ranges -. -len -( -) -* -s -: -: -< -( -SmallIndex -SmallIndex -) -> -( -) -+ -self -. -0 -. -name_to_index -. -len -( -) -* -s -: -: -< -CaptureNameMap -> -( -) -+ -self -. -0 -. -index_to_name -. -len -( -) -* -s -: -: -< -Vec -< -Option -< -Arc -< -str -> -> -> -> -( -) -+ -self -. -0 -. -memory_extra -} -} -/ -/ -/ -A -map -from -capture -group -name -to -its -corresponding -capture -group -index -. -/ -/ -/ -/ -/ -/ -This -type -is -actually -wrapped -inside -a -Vec -indexed -by -pattern -ID -on -a -/ -/ -/ -GroupInfo -since -multiple -patterns -may -have -the -same -capture -group -name -. -/ -/ -/ -That -is -each -pattern -gets -its -own -namespace -of -capture -group -names -. -/ -/ -/ -/ -/ -/ -Perhaps -a -more -memory -efficient -representation -would -be -/ -/ -/ -HashMap -< -( -PatternID -Arc -< -str -> -) -usize -> -but -this -makes -it -difficult -to -look -/ -/ -/ -up -a -capture -index -by -name -without -producing -a -Arc -< -str -> -which -requires -/ -/ -/ -an -allocation -. -To -fix -this -I -think -we -' -d -need -to -define -our -own -unsized -/ -/ -/ -type -or -something -? -Anyway -I -didn -' -t -give -this -much -thought -since -it -/ -/ -/ -probably -doesn -' -t -matter -much -in -the -grand -scheme -of -things -. -But -it -did -/ -/ -/ -stand -out -to -me -as -mildly -wasteful -. -# -[ -cfg -( -feature -= -" -std -" -) -] -type -CaptureNameMap -= -std -: -: -collections -: -: -HashMap -< -Arc -< -str -> -SmallIndex -> -; -# -[ -cfg -( -not -( -feature -= -" -std -" -) -) -] -type -CaptureNameMap -= -alloc -: -: -collections -: -: -BTreeMap -< -Arc -< -str -> -SmallIndex -> -; -/ -/ -/ -The -inner -guts -of -GroupInfo -. -This -type -only -exists -so -that -it -can -/ -/ -/ -be -wrapped -in -an -Arc -to -make -GroupInfo -reference -counted -. -# -[ -derive -( -Debug -Default -) -] -struct -GroupInfoInner -{ -slot_ranges -: -Vec -< -( -SmallIndex -SmallIndex -) -> -name_to_index -: -Vec -< -CaptureNameMap -> -index_to_name -: -Vec -< -Vec -< -Option -< -Arc -< -str -> -> -> -> -memory_extra -: -usize -} -impl -GroupInfoInner -{ -/ -/ -/ -This -adds -the -first -unnamed -group -for -the -given -pattern -ID -. -The -given -/ -/ -/ -pattern -ID -must -be -zero -if -this -is -the -first -time -this -method -is -/ -/ -/ -called -or -must -be -exactly -one -more -than -the -pattern -ID -supplied -to -the -/ -/ -/ -previous -call -to -this -method -. -( -This -method -panics -if -this -rule -is -/ -/ -/ -violated -. -) -/ -/ -/ -/ -/ -/ -This -can -be -thought -of -as -initializing -the -GroupInfo -state -for -the -/ -/ -/ -given -pattern -and -closing -off -the -state -for -any -previous -pattern -. -fn -add_first_group -( -& -mut -self -pid -: -PatternID -) -{ -assert_eq -! -( -pid -. -as_usize -( -) -self -. -slot_ranges -. -len -( -) -) -; -assert_eq -! -( -pid -. -as_usize -( -) -self -. -name_to_index -. -len -( -) -) -; -assert_eq -! -( -pid -. -as_usize -( -) -self -. -index_to_name -. -len -( -) -) -; -/ -/ -This -is -the -start -of -our -slots -for -the -explicit -capturing -groups -. -/ -/ -Note -that -since -the -slots -for -the -0th -group -for -every -pattern -appear -/ -/ -before -any -slots -for -the -nth -group -( -where -n -> -0 -) -in -any -pattern -we -/ -/ -will -have -to -fix -up -the -slot -ranges -once -we -know -how -many -patterns -/ -/ -we -' -ve -added -capture -groups -for -. -let -slot_start -= -self -. -small_slot_len -( -) -; -self -. -slot_ranges -. -push -( -( -slot_start -slot_start -) -) -; -self -. -name_to_index -. -push -( -CaptureNameMap -: -: -new -( -) -) -; -self -. -index_to_name -. -push -( -vec -! -[ -None -] -) -; -self -. -memory_extra -+ -= -core -: -: -mem -: -: -size_of -: -: -< -Option -< -Arc -< -str -> -> -> -( -) -; -} -/ -/ -/ -Add -an -explicit -capturing -group -for -the -given -pattern -with -the -given -/ -/ -/ -index -. -If -the -group -has -a -name -then -that -must -be -given -as -well -. -/ -/ -/ -/ -/ -/ -Note -that -every -capturing -group -except -for -the -first -or -zeroth -group -is -/ -/ -/ -explicit -. -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -adding -this -group -would -result -in -overflowing -/ -/ -/ -slot -indices -or -if -a -capturing -group -with -the -same -name -for -this -/ -/ -/ -pattern -has -already -been -added -. -fn -add_explicit_group -< -N -: -AsRef -< -str -> -> -( -& -mut -self -pid -: -PatternID -group -: -SmallIndex -maybe_name -: -Option -< -N -> -) -- -> -Result -< -( -) -GroupInfoError -> -{ -/ -/ -We -also -need -to -check -that -the -slot -index -generated -for -/ -/ -this -group -is -also -valid -. -Although -this -is -a -little -weird -/ -/ -because -we -offset -these -indices -below -at -which -point -we -' -ll -/ -/ -have -to -recheck -them -. -Gosh -this -is -annoying -. -Note -that -/ -/ -the -' -+ -2 -' -below -is -OK -because -' -end -' -is -guaranteed -to -be -less -/ -/ -than -isize -: -: -MAX -. -let -end -= -& -mut -self -. -slot_ranges -[ -pid -] -. -1 -; -* -end -= -SmallIndex -: -: -new -( -end -. -as_usize -( -) -+ -2 -) -. -map_err -( -| -_ -| -{ -GroupInfoError -: -: -too_many_groups -( -pid -group -. -as_usize -( -) -) -} -) -? -; -if -let -Some -( -name -) -= -maybe_name -{ -let -name -= -Arc -: -: -< -str -> -: -: -from -( -name -. -as_ref -( -) -) -; -if -self -. -name_to_index -[ -pid -] -. -contains_key -( -& -* -name -) -{ -return -Err -( -GroupInfoError -: -: -duplicate -( -pid -& -name -) -) -; -} -let -len -= -name -. -len -( -) -; -self -. -name_to_index -[ -pid -] -. -insert -( -Arc -: -: -clone -( -& -name -) -group -) -; -self -. -index_to_name -[ -pid -] -. -push -( -Some -( -name -) -) -; -/ -/ -Adds -the -memory -used -by -the -Arc -< -str -> -in -both -maps -. -self -. -memory_extra -+ -= -2 -* -( -len -+ -core -: -: -mem -: -: -size_of -: -: -< -Option -< -Arc -< -str -> -> -> -( -) -) -; -/ -/ -And -also -the -value -entry -for -the -' -name_to_index -' -map -. -/ -/ -This -is -probably -an -underestimate -for -' -name_to_index -' -since -/ -/ -hashmaps -/ -btrees -likely -have -some -non -- -zero -overhead -but -we -/ -/ -assume -here -that -they -have -zero -overhead -. -self -. -memory_extra -+ -= -core -: -: -mem -: -: -size_of -: -: -< -SmallIndex -> -( -) -; -} -else -{ -self -. -index_to_name -[ -pid -] -. -push -( -None -) -; -self -. -memory_extra -+ -= -core -: -: -mem -: -: -size_of -: -: -< -Option -< -Arc -< -str -> -> -> -( -) -; -} -/ -/ -This -is -a -sanity -assert -that -checks -that -our -group -index -/ -/ -is -in -line -with -the -number -of -groups -added -so -far -for -this -/ -/ -pattern -. -assert_eq -! -( -group -. -one_more -( -) -self -. -group_len -( -pid -) -) -; -/ -/ -And -is -also -in -line -with -the -' -index_to_name -' -map -. -assert_eq -! -( -group -. -one_more -( -) -self -. -index_to_name -[ -pid -] -. -len -( -) -) -; -Ok -( -( -) -) -} -/ -/ -/ -This -corrects -the -slot -ranges -to -account -for -the -slots -corresponding -/ -/ -/ -to -the -zeroth -group -of -each -pattern -. -That -is -every -slot -range -is -/ -/ -/ -offset -by -' -pattern_len -( -) -* -2 -' -since -each -pattern -uses -two -slots -to -/ -/ -/ -represent -the -zeroth -group -. -fn -fixup_slot_ranges -( -& -mut -self -) -- -> -Result -< -( -) -GroupInfoError -> -{ -use -crate -: -: -util -: -: -primitives -: -: -IteratorIndexExt -; -/ -/ -Since -we -know -number -of -patterns -fits -in -PatternID -and -/ -/ -PatternID -: -: -MAX -< -isize -: -: -MAX -it -follows -that -multiplying -by -2 -will -/ -/ -never -overflow -usize -. -let -offset -= -self -. -pattern_len -( -) -. -checked_mul -( -2 -) -. -unwrap -( -) -; -for -( -pid -& -mut -( -ref -mut -start -ref -mut -end -) -) -in -self -. -slot_ranges -. -iter_mut -( -) -. -with_pattern_ids -( -) -{ -let -group_len -= -1 -+ -( -( -end -. -as_usize -( -) -- -start -. -as_usize -( -) -) -/ -2 -) -; -let -new_end -= -match -end -. -as_usize -( -) -. -checked_add -( -offset -) -{ -Some -( -new_end -) -= -> -new_end -None -= -> -{ -return -Err -( -GroupInfoError -: -: -too_many_groups -( -pid -group_len -) -) -} -} -; -* -end -= -SmallIndex -: -: -new -( -new_end -) -. -map_err -( -| -_ -| -{ -GroupInfoError -: -: -too_many_groups -( -pid -group_len -) -} -) -? -; -/ -/ -Since -start -< -= -end -if -end -is -valid -then -start -must -be -too -. -* -start -= -SmallIndex -: -: -new -( -start -. -as_usize -( -) -+ -offset -) -. -unwrap -( -) -; -} -Ok -( -( -) -) -} -/ -/ -/ -Return -the -total -number -of -patterns -represented -by -this -capture -slot -/ -/ -/ -info -. -fn -pattern_len -( -& -self -) -- -> -usize -{ -self -. -slot_ranges -. -len -( -) -} -/ -/ -/ -Return -the -total -number -of -capturing -groups -for -the -given -pattern -. -If -/ -/ -/ -the -given -pattern -isn -' -t -valid -for -this -capture -slot -info -then -0 -is -/ -/ -/ -returned -. -fn -group_len -( -& -self -pid -: -PatternID -) -- -> -usize -{ -let -( -start -end -) -= -match -self -. -slot_ranges -. -get -( -pid -. -as_usize -( -) -) -{ -None -= -> -return -0 -Some -( -range -) -= -> -range -} -; -/ -/ -The -difference -between -any -two -SmallIndex -values -always -fits -in -a -/ -/ -usize -since -we -know -that -SmallIndex -: -: -MAX -< -= -isize -: -: -MAX -- -1 -. -We -also -/ -/ -know -that -start -< -= -end -by -construction -and -that -the -number -of -groups -/ -/ -never -exceeds -SmallIndex -and -thus -never -overflows -usize -. -1 -+ -( -( -end -. -as_usize -( -) -- -start -. -as_usize -( -) -) -/ -2 -) -} -/ -/ -/ -Return -the -total -number -of -slots -in -this -capture -slot -info -as -a -/ -/ -/ -" -small -index -. -" -fn -small_slot_len -( -& -self -) -- -> -SmallIndex -{ -/ -/ -Since -slots -are -allocated -in -order -of -pattern -( -starting -at -0 -) -and -/ -/ -then -in -order -of -capture -group -it -follows -that -the -number -of -slots -/ -/ -is -the -end -of -the -range -of -slots -for -the -last -pattern -. -This -is -/ -/ -true -even -when -the -last -pattern -has -no -capturing -groups -since -/ -/ -' -slot_ranges -' -will -still -represent -it -explicitly -with -an -empty -/ -/ -range -. -self -. -slot_ranges -. -last -( -) -. -map_or -( -SmallIndex -: -: -ZERO -| -& -( -_ -end -) -| -end -) -} -} -/ -/ -/ -An -error -that -may -occur -when -building -a -GroupInfo -. -/ -/ -/ -/ -/ -/ -Building -a -GroupInfo -does -a -variety -of -checks -to -make -sure -the -/ -/ -/ -capturing -groups -satisfy -a -number -of -invariants -. -This -includes -but -is -not -/ -/ -/ -limited -to -ensuring -that -the -first -capturing -group -is -unnamed -and -that -/ -/ -/ -there -are -no -duplicate -capture -groups -for -a -specific -pattern -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -GroupInfoError -{ -kind -: -GroupInfoErrorKind -} -/ -/ -/ -The -kind -of -error -that -occurs -when -building -a -GroupInfo -fails -. -/ -/ -/ -/ -/ -/ -We -keep -this -un -- -exported -because -it -' -s -not -clear -how -useful -it -is -to -/ -/ -/ -export -it -. -# -[ -derive -( -Clone -Debug -) -] -enum -GroupInfoErrorKind -{ -/ -/ -/ -This -occurs -when -too -many -patterns -have -been -added -. -i -. -e -. -It -would -/ -/ -/ -otherwise -overflow -a -PatternID -. -TooManyPatterns -{ -err -: -PatternIDError -} -/ -/ -/ -This -occurs -when -too -many -capturing -groups -have -been -added -for -a -/ -/ -/ -particular -pattern -. -TooManyGroups -{ -/ -/ -/ -The -ID -of -the -pattern -that -had -too -many -groups -. -pattern -: -PatternID -/ -/ -/ -The -minimum -number -of -groups -that -the -caller -has -tried -to -add -for -/ -/ -/ -a -pattern -. -minimum -: -usize -} -/ -/ -/ -An -error -that -occurs -when -a -pattern -has -no -capture -groups -. -Either -the -/ -/ -/ -group -info -must -be -empty -or -all -patterns -must -have -at -least -one -group -/ -/ -/ -( -corresponding -to -the -unnamed -group -for -the -entire -pattern -) -. -MissingGroups -{ -/ -/ -/ -The -ID -of -the -pattern -that -had -no -capturing -groups -. -pattern -: -PatternID -} -/ -/ -/ -An -error -that -occurs -when -one -tries -to -provide -a -name -for -the -capture -/ -/ -/ -group -at -index -0 -. -This -capturing -group -must -currently -always -be -/ -/ -/ -unnamed -. -FirstMustBeUnnamed -{ -/ -/ -/ -The -ID -of -the -pattern -that -was -found -to -have -a -named -first -/ -/ -/ -capturing -group -. -pattern -: -PatternID -} -/ -/ -/ -An -error -that -occurs -when -duplicate -capture -group -names -for -the -same -/ -/ -/ -pattern -are -added -. -/ -/ -/ -/ -/ -/ -NOTE -: -At -time -of -writing -this -error -can -never -occur -if -you -' -re -using -/ -/ -/ -regex -- -syntax -since -the -parser -itself -will -reject -patterns -with -/ -/ -/ -duplicate -capture -group -names -. -This -error -can -only -occur -when -the -/ -/ -/ -builder -is -used -to -hand -construct -NFAs -. -Duplicate -{ -/ -/ -/ -The -pattern -in -which -the -duplicate -capture -group -name -was -found -. -pattern -: -PatternID -/ -/ -/ -The -duplicate -name -. -name -: -String -} -} -impl -GroupInfoError -{ -fn -too_many_patterns -( -err -: -PatternIDError -) -- -> -GroupInfoError -{ -GroupInfoError -{ -kind -: -GroupInfoErrorKind -: -: -TooManyPatterns -{ -err -} -} -} -fn -too_many_groups -( -pattern -: -PatternID -minimum -: -usize -) -- -> -GroupInfoError -{ -GroupInfoError -{ -kind -: -GroupInfoErrorKind -: -: -TooManyGroups -{ -pattern -minimum -} -} -} -fn -missing_groups -( -pattern -: -PatternID -) -- -> -GroupInfoError -{ -GroupInfoError -{ -kind -: -GroupInfoErrorKind -: -: -MissingGroups -{ -pattern -} -} -} -fn -first_must_be_unnamed -( -pattern -: -PatternID -) -- -> -GroupInfoError -{ -GroupInfoError -{ -kind -: -GroupInfoErrorKind -: -: -FirstMustBeUnnamed -{ -pattern -} -} -} -fn -duplicate -( -pattern -: -PatternID -name -: -& -str -) -- -> -GroupInfoError -{ -GroupInfoError -{ -kind -: -GroupInfoErrorKind -: -: -Duplicate -{ -pattern -name -: -String -: -: -from -( -name -) -} -} -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -GroupInfoError -{ -fn -source -( -& -self -) -- -> -Option -< -& -( -dyn -std -: -: -error -: -: -Error -+ -' -static -) -> -{ -match -self -. -kind -{ -GroupInfoErrorKind -: -: -TooManyPatterns -{ -. -. -} -| -GroupInfoErrorKind -: -: -TooManyGroups -{ -. -. -} -| -GroupInfoErrorKind -: -: -MissingGroups -{ -. -. -} -| -GroupInfoErrorKind -: -: -FirstMustBeUnnamed -{ -. -. -} -| -GroupInfoErrorKind -: -: -Duplicate -{ -. -. -} -= -> -None -} -} -} -impl -core -: -: -fmt -: -: -Display -for -GroupInfoError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -use -self -: -: -GroupInfoErrorKind -: -: -* -; -match -self -. -kind -{ -TooManyPatterns -{ -ref -err -} -= -> -{ -write -! -( -f -" -too -many -patterns -to -build -capture -info -: -{ -} -" -err -) -} -TooManyGroups -{ -pattern -minimum -} -= -> -{ -write -! -( -f -" -too -many -capture -groups -( -at -least -{ -} -) -were -\ -found -for -pattern -{ -} -" -minimum -pattern -. -as_usize -( -) -) -} -MissingGroups -{ -pattern -} -= -> -write -! -( -f -" -no -capturing -groups -found -for -pattern -{ -} -\ -( -either -all -patterns -have -zero -groups -or -all -patterns -have -\ -at -least -one -group -) -" -pattern -. -as_usize -( -) -) -FirstMustBeUnnamed -{ -pattern -} -= -> -write -! -( -f -" -first -capture -group -( -at -index -0 -) -for -pattern -{ -} -has -a -name -\ -( -it -must -be -unnamed -) -" -pattern -. -as_usize -( -) -) -Duplicate -{ -pattern -ref -name -} -= -> -write -! -( -f -" -duplicate -capture -group -name -' -{ -} -' -found -for -pattern -{ -} -" -name -pattern -. -as_usize -( -) -) -} -} -} -/ -/ -/ -An -iterator -over -capturing -groups -and -their -names -for -a -specific -pattern -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -GroupInfo -: -: -pattern_names -] -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameter -' -a -refers -to -the -lifetime -of -the -GroupInfo -/ -/ -/ -from -which -this -iterator -was -created -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -GroupInfoPatternNames -< -' -a -> -{ -it -: -core -: -: -slice -: -: -Iter -< -' -a -Option -< -Arc -< -str -> -> -> -} -impl -GroupInfoPatternNames -< -' -static -> -{ -fn -empty -( -) -- -> -GroupInfoPatternNames -< -' -static -> -{ -GroupInfoPatternNames -{ -it -: -[ -] -. -iter -( -) -} -} -} -impl -< -' -a -> -Iterator -for -GroupInfoPatternNames -< -' -a -> -{ -type -Item -= -Option -< -& -' -a -str -> -; -fn -next -( -& -mut -self -) -- -> -Option -< -Option -< -& -' -a -str -> -> -{ -self -. -it -. -next -( -) -. -map -( -| -x -| -x -. -as_deref -( -) -) -} -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -it -. -size_hint -( -) -} -fn -count -( -self -) -- -> -usize -{ -self -. -it -. -count -( -) -} -} -impl -< -' -a -> -ExactSizeIterator -for -GroupInfoPatternNames -< -' -a -> -{ -} -impl -< -' -a -> -core -: -: -iter -: -: -FusedIterator -for -GroupInfoPatternNames -< -' -a -> -{ -} -/ -/ -/ -An -iterator -over -capturing -groups -and -their -names -for -a -GroupInfo -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -GroupInfo -: -: -all_names -] -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameter -' -a -refers -to -the -lifetime -of -the -GroupInfo -/ -/ -/ -from -which -this -iterator -was -created -. -# -[ -derive -( -Debug -) -] -pub -struct -GroupInfoAllNames -< -' -a -> -{ -group_info -: -& -' -a -GroupInfo -pids -: -PatternIDIter -current_pid -: -Option -< -PatternID -> -names -: -Option -< -core -: -: -iter -: -: -Enumerate -< -GroupInfoPatternNames -< -' -a -> -> -> -} -impl -< -' -a -> -Iterator -for -GroupInfoAllNames -< -' -a -> -{ -type -Item -= -( -PatternID -usize -Option -< -& -' -a -str -> -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -PatternID -usize -Option -< -& -' -a -str -> -) -> -{ -/ -/ -If -the -group -info -has -no -captures -then -we -never -have -anything -/ -/ -to -yield -. -We -need -to -consider -this -case -explicitly -( -at -time -of -/ -/ -writing -) -because -' -pattern_capture_names -' -will -panic -if -captures -/ -/ -aren -' -t -enabled -. -if -self -. -group_info -. -0 -. -index_to_name -. -is_empty -( -) -{ -return -None -; -} -if -self -. -current_pid -. -is_none -( -) -{ -self -. -current_pid -= -Some -( -self -. -pids -. -next -( -) -? -) -; -} -let -pid -= -self -. -current_pid -. -unwrap -( -) -; -if -self -. -names -. -is_none -( -) -{ -self -. -names -= -Some -( -self -. -group_info -. -pattern_names -( -pid -) -. -enumerate -( -) -) -; -} -let -( -group_index -name -) -= -match -self -. -names -. -as_mut -( -) -. -unwrap -( -) -. -next -( -) -{ -Some -( -( -group_index -name -) -) -= -> -( -group_index -name -) -None -= -> -{ -self -. -current_pid -= -None -; -self -. -names -= -None -; -return -self -. -next -( -) -; -} -} -; -Some -( -( -pid -group_index -name -) -) -} -} diff --git a/third_party/rust/regex-automata/src/util/determinize/mod.rs b/third_party/rust/regex-automata/src/util/determinize/mod.rs deleted file mode 100644 index 58916876e128a..0000000000000 --- a/third_party/rust/regex-automata/src/util/determinize/mod.rs +++ /dev/null @@ -1,5644 +0,0 @@ -/ -* -! -This -module -contains -types -and -routines -for -implementing -determinization -. -In -this -crate -there -are -at -least -two -places -where -we -implement -determinization -: -fully -ahead -- -of -- -time -compiled -DFAs -in -the -dfa -module -and -lazily -compiled -DFAs -in -the -hybrid -module -. -The -stuff -in -this -module -corresponds -to -the -things -that -are -in -common -between -these -implementations -. -There -are -three -broad -things -that -our -implementations -of -determinization -have -in -common -as -defined -by -this -module -: -* -The -classification -of -start -states -. -That -is -whether -we -' -re -dealing -with -word -boundaries -line -boundaries -etc -. -is -all -the -same -. -This -also -includes -the -look -- -behind -assertions -that -are -satisfied -by -each -starting -state -classification -. -* -The -representation -of -DFA -states -as -sets -of -NFA -states -including -convenience -types -for -building -these -DFA -states -that -are -amenable -to -reusing -allocations -. -* -Routines -for -the -" -classical -" -parts -of -determinization -: -computing -the -epsilon -closure -tracking -match -states -( -with -corresponding -pattern -IDs -since -we -support -multi -- -pattern -finite -automata -) -and -of -course -computing -the -transition -function -between -states -for -units -of -input -. -I -did -consider -a -couple -of -alternatives -to -this -particular -form -of -code -reuse -: -1 -. -Don -' -t -do -any -code -reuse -. -The -problem -here -is -that -we -* -really -* -want -both -forms -of -determinization -to -do -exactly -identical -things -when -it -comes -to -their -handling -of -NFA -states -. -While -our -tests -generally -ensure -this -the -code -is -tricky -and -large -enough -where -not -reusing -code -is -a -pretty -big -bummer -. -2 -. -Implement -all -of -determinization -once -and -make -it -generic -over -fully -compiled -DFAs -and -lazily -compiled -DFAs -. -While -I -didn -' -t -actually -try -this -approach -my -instinct -is -that -it -would -be -more -complex -than -is -needed -here -. -And -the -interface -required -would -be -pretty -hairy -. -Instead -I -think -splitting -it -into -logical -sub -- -components -works -better -. -* -/ -use -alloc -: -: -vec -: -: -Vec -; -pub -( -crate -) -use -self -: -: -state -: -: -{ -State -StateBuilderEmpty -StateBuilderMatches -StateBuilderNFA -} -; -use -crate -: -: -{ -nfa -: -: -thompson -util -: -: -{ -alphabet -look -: -: -{ -Look -LookSet -} -primitives -: -: -StateID -search -: -: -MatchKind -sparse_set -: -: -{ -SparseSet -SparseSets -} -start -: -: -Start -utf8 -} -} -; -mod -state -; -/ -/ -/ -Compute -the -set -of -all -reachable -NFA -states -including -the -full -epsilon -/ -/ -/ -closure -from -a -DFA -state -for -a -single -unit -of -input -. -The -set -of -reachable -/ -/ -/ -states -is -returned -as -a -StateBuilderNFA -. -The -StateBuilderNFA -returned -/ -/ -/ -also -includes -any -look -- -behind -assertions -satisfied -by -unit -in -addition -/ -/ -/ -to -whether -it -is -a -match -state -. -For -multi -- -pattern -DFAs -the -builder -will -/ -/ -/ -also -include -the -pattern -IDs -that -match -( -in -the -order -seen -) -. -/ -/ -/ -/ -/ -/ -nfa -must -be -able -to -resolve -any -NFA -state -in -state -and -any -NFA -state -/ -/ -/ -reachable -via -the -epsilon -closure -of -any -NFA -state -in -state -. -sparses -/ -/ -/ -must -have -capacity -equivalent -to -nfa -. -len -( -) -. -/ -/ -/ -/ -/ -/ -match_kind -should -correspond -to -the -match -semantics -implemented -by -the -/ -/ -/ -DFA -being -built -. -Generally -speaking -for -leftmost -- -first -match -semantics -/ -/ -/ -states -that -appear -after -the -first -NFA -match -state -will -not -be -included -in -/ -/ -/ -the -StateBuilderNFA -returned -since -they -are -impossible -to -visit -. -/ -/ -/ -/ -/ -/ -sparses -is -used -as -scratch -space -for -NFA -traversal -. -Other -than -their -/ -/ -/ -capacity -requirements -( -detailed -above -) -there -are -no -requirements -on -what -' -s -/ -/ -/ -contained -within -them -( -if -anything -) -. -Similarly -what -' -s -inside -of -them -once -/ -/ -/ -this -routine -returns -is -unspecified -. -/ -/ -/ -/ -/ -/ -stack -must -have -length -0 -. -It -is -used -as -scratch -space -for -depth -first -/ -/ -/ -traversal -. -After -returning -it -is -guaranteed -that -stack -will -have -length -/ -/ -/ -0 -. -/ -/ -/ -/ -/ -/ -state -corresponds -to -the -current -DFA -state -on -which -one -wants -to -compute -/ -/ -/ -the -transition -for -the -input -unit -. -/ -/ -/ -/ -/ -/ -empty_builder -corresponds -to -the -builder -allocation -to -use -to -produce -a -/ -/ -/ -complete -StateBuilderNFA -state -. -If -the -state -is -not -needed -( -or -is -already -/ -/ -/ -cached -) -then -it -can -be -cleared -and -reused -without -needing -to -create -a -new -/ -/ -/ -State -. -The -StateBuilderNFA -state -returned -is -final -and -ready -to -be -/ -/ -/ -turned -into -a -State -if -necessary -. -pub -( -crate -) -fn -next -( -nfa -: -& -thompson -: -: -NFA -match_kind -: -MatchKind -sparses -: -& -mut -SparseSets -stack -: -& -mut -Vec -< -StateID -> -state -: -& -State -unit -: -alphabet -: -: -Unit -empty_builder -: -StateBuilderEmpty -) -- -> -StateBuilderNFA -{ -sparses -. -clear -( -) -; -/ -/ -Whether -the -NFA -is -matched -in -reverse -or -not -. -We -use -this -in -some -/ -/ -conditional -logic -for -dealing -with -the -exceptionally -annoying -CRLF -- -aware -/ -/ -line -anchors -. -let -rev -= -nfa -. -is_reverse -( -) -; -/ -/ -The -look -- -around -matcher -that -our -NFA -is -configured -with -. -We -don -' -t -/ -/ -actually -use -it -to -match -look -- -around -assertions -but -we -do -need -its -/ -/ -configuration -for -constructing -states -consistent -with -how -it -matches -. -let -lookm -= -nfa -. -look_matcher -( -) -; -/ -/ -Put -the -NFA -state -IDs -into -a -sparse -set -in -case -we -need -to -/ -/ -re -- -compute -their -epsilon -closure -. -/ -/ -/ -/ -Doing -this -state -shuffling -is -technically -not -necessary -unless -some -/ -/ -kind -of -look -- -around -is -used -in -the -DFA -. -Some -ad -hoc -experiments -/ -/ -suggested -that -avoiding -this -didn -' -t -lead -to -much -of -an -improvement -/ -/ -but -perhaps -more -rigorous -experimentation -should -be -done -. -And -in -/ -/ -particular -avoiding -this -check -requires -some -light -refactoring -of -/ -/ -the -code -below -. -state -. -iter_nfa_state_ids -( -| -nfa_id -| -{ -sparses -. -set1 -. -insert -( -nfa_id -) -; -} -) -; -/ -/ -Compute -look -- -ahead -assertions -originating -from -the -current -state -. -Based -/ -/ -on -the -input -unit -we -' -re -transitioning -over -some -additional -set -of -/ -/ -assertions -may -be -true -. -Thus -we -re -- -compute -this -state -' -s -epsilon -closure -/ -/ -( -but -only -if -necessary -) -. -Notably -when -we -build -a -DFA -state -initially -/ -/ -we -don -' -t -enable -any -look -- -ahead -assertions -because -we -don -' -t -know -whether -/ -/ -they -' -re -true -or -not -at -that -point -. -if -! -state -. -look_need -( -) -. -is_empty -( -) -{ -/ -/ -Add -look -- -ahead -assertions -that -are -now -true -based -on -the -current -/ -/ -input -unit -. -let -mut -look_have -= -state -. -look_have -( -) -. -clone -( -) -; -match -unit -. -as_u8 -( -) -{ -Some -( -b -' -\ -r -' -) -= -> -{ -if -! -rev -| -| -! -state -. -is_half_crlf -( -) -{ -look_have -= -look_have -. -insert -( -Look -: -: -EndCRLF -) -; -} -} -Some -( -b -' -\ -n -' -) -= -> -{ -if -rev -| -| -! -state -. -is_half_crlf -( -) -{ -look_have -= -look_have -. -insert -( -Look -: -: -EndCRLF -) -; -} -} -Some -( -_ -) -= -> -{ -} -None -= -> -{ -look_have -= -look_have -. -insert -( -Look -: -: -End -) -; -look_have -= -look_have -. -insert -( -Look -: -: -EndLF -) -; -look_have -= -look_have -. -insert -( -Look -: -: -EndCRLF -) -; -} -} -if -unit -. -is_byte -( -lookm -. -get_line_terminator -( -) -) -{ -look_have -= -look_have -. -insert -( -Look -: -: -EndLF -) -; -} -if -state -. -is_half_crlf -( -) -& -& -( -( -rev -& -& -! -unit -. -is_byte -( -b -' -\ -r -' -) -) -| -| -( -! -rev -& -& -! -unit -. -is_byte -( -b -' -\ -n -' -) -) -) -{ -look_have -= -look_have -. -insert -( -Look -: -: -StartCRLF -) -; -} -if -state -. -is_from_word -( -) -= -= -unit -. -is_word_byte -( -) -{ -look_have -= -look_have -. -insert -( -Look -: -: -WordUnicodeNegate -) -; -look_have -= -look_have -. -insert -( -Look -: -: -WordAsciiNegate -) -; -} -else -{ -look_have -= -look_have -. -insert -( -Look -: -: -WordUnicode -) -; -look_have -= -look_have -. -insert -( -Look -: -: -WordAscii -) -; -} -/ -/ -If -we -have -new -assertions -satisfied -that -are -among -the -set -of -/ -/ -assertions -that -exist -in -this -state -( -that -is -just -because -we -added -/ -/ -an -EndLF -assertion -above -doesn -' -t -mean -there -is -an -EndLF -conditional -/ -/ -epsilon -transition -in -this -state -) -then -we -re -- -compute -this -state -' -s -/ -/ -epsilon -closure -using -the -updated -set -of -assertions -. -/ -/ -/ -/ -Note -that -since -our -DFA -states -omit -unconditional -epsilon -/ -/ -transitions -this -check -is -necessary -for -correctness -. -If -we -re -- -did -/ -/ -the -epsilon -closure -below -needlessly -it -could -change -based -on -the -/ -/ -fact -that -we -omitted -epsilon -states -originally -. -if -! -look_have -. -subtract -( -state -. -look_have -( -) -) -. -intersect -( -state -. -look_need -( -) -) -. -is_empty -( -) -{ -for -nfa_id -in -sparses -. -set1 -. -iter -( -) -{ -epsilon_closure -( -nfa -nfa_id -look_have -stack -& -mut -sparses -. -set2 -) -; -} -sparses -. -swap -( -) -; -sparses -. -set2 -. -clear -( -) -; -} -} -/ -/ -Convert -our -empty -builder -into -one -that -can -record -assertions -and -match -/ -/ -pattern -IDs -. -let -mut -builder -= -empty_builder -. -into_matches -( -) -; -/ -/ -Set -whether -the -StartLF -look -- -behind -assertion -is -true -for -this -/ -/ -transition -or -not -. -The -look -- -behind -assertion -for -ASCII -word -boundaries -/ -/ -is -handled -below -. -if -nfa -. -look_set_any -( -) -. -contains_anchor_line -( -) -& -& -unit -. -is_byte -( -lookm -. -get_line_terminator -( -) -) -{ -/ -/ -Why -only -handle -StartLF -here -and -not -Start -? -That -' -s -because -Start -/ -/ -can -only -impact -the -starting -state -which -is -special -cased -in -/ -/ -start -state -handling -. -builder -. -set_look_have -( -| -have -| -have -. -insert -( -Look -: -: -StartLF -) -) -; -} -/ -/ -We -also -need -to -add -StartCRLF -to -our -assertions -too -if -we -can -. -This -/ -/ -is -unfortunately -a -bit -more -complicated -because -it -depends -on -the -/ -/ -direction -of -the -search -. -In -the -forward -direction -^ -matches -after -a -/ -/ -\ -n -but -in -the -reverse -direction -^ -only -matches -after -a -\ -r -. -( -This -is -/ -/ -further -complicated -by -the -fact -that -reverse -a -regex -means -changing -a -^ -/ -/ -to -a -and -vice -versa -. -) -if -nfa -. -look_set_any -( -) -. -contains_anchor_crlf -( -) -& -& -( -( -rev -& -& -unit -. -is_byte -( -b -' -\ -r -' -) -) -| -| -( -! -rev -& -& -unit -. -is_byte -( -b -' -\ -n -' -) -) -) -{ -builder -. -set_look_have -( -| -have -| -have -. -insert -( -Look -: -: -StartCRLF -) -) -; -} -for -nfa_id -in -sparses -. -set1 -. -iter -( -) -{ -match -* -nfa -. -state -( -nfa_id -) -{ -thompson -: -: -State -: -: -Union -{ -. -. -} -| -thompson -: -: -State -: -: -BinaryUnion -{ -. -. -} -| -thompson -: -: -State -: -: -Fail -| -thompson -: -: -State -: -: -Look -{ -. -. -} -| -thompson -: -: -State -: -: -Capture -{ -. -. -} -= -> -{ -} -thompson -: -: -State -: -: -Match -{ -pattern_id -} -= -> -{ -/ -/ -Notice -here -that -we -are -calling -the -NEW -state -a -match -/ -/ -state -if -the -OLD -state -we -are -transitioning -from -/ -/ -contains -an -NFA -match -state -. -This -is -precisely -how -we -/ -/ -delay -all -matches -by -one -byte -and -also -what -therefore -/ -/ -guarantees -that -starting -states -cannot -be -match -states -. -/ -/ -/ -/ -If -we -didn -' -t -delay -matches -by -one -byte -then -whether -/ -/ -a -DFA -is -a -matching -state -or -not -would -be -determined -/ -/ -by -whether -one -of -its -own -constituent -NFA -states -/ -/ -was -a -match -state -. -( -And -that -would -be -done -in -/ -/ -' -add_nfa_states -' -. -) -/ -/ -/ -/ -Also -' -add_match_pattern_id -' -requires -that -callers -never -/ -/ -pass -duplicative -pattern -IDs -. -We -do -in -fact -uphold -that -/ -/ -guarantee -here -but -it -' -s -subtle -. -In -particular -a -Thompson -/ -/ -NFA -guarantees -that -each -pattern -has -exactly -one -match -/ -/ -state -. -Moreover -since -we -' -re -iterating -over -the -NFA -state -/ -/ -IDs -in -a -set -we -are -guarateed -not -to -have -any -duplicative -/ -/ -match -states -. -Thus -it -is -impossible -to -add -the -same -pattern -/ -/ -ID -more -than -once -. -/ -/ -/ -/ -N -. -B -. -We -delay -matches -by -1 -byte -as -a -way -to -hack -1 -- -byte -/ -/ -look -- -around -into -DFA -searches -. -This -lets -us -support -^ -/ -/ -and -ASCII -- -only -\ -b -. -The -delay -is -also -why -we -need -a -special -/ -/ -" -end -- -of -- -input -" -( -EOI -) -sentinel -and -why -we -need -to -follow -the -/ -/ -EOI -sentinel -at -the -end -of -every -search -. -This -final -EOI -/ -/ -transition -is -necessary -to -report -matches -found -at -the -end -/ -/ -of -a -haystack -. -builder -. -add_match_pattern_id -( -pattern_id -) -; -if -! -match_kind -. -continue_past_first_match -( -) -{ -break -; -} -} -thompson -: -: -State -: -: -ByteRange -{ -ref -trans -} -= -> -{ -if -trans -. -matches_unit -( -unit -) -{ -epsilon_closure -( -nfa -trans -. -next -builder -. -look_have -( -) -stack -& -mut -sparses -. -set2 -) -; -} -} -thompson -: -: -State -: -: -Sparse -( -ref -sparse -) -= -> -{ -if -let -Some -( -next -) -= -sparse -. -matches_unit -( -unit -) -{ -epsilon_closure -( -nfa -next -builder -. -look_have -( -) -stack -& -mut -sparses -. -set2 -) -; -} -} -thompson -: -: -State -: -: -Dense -( -ref -dense -) -= -> -{ -if -let -Some -( -next -) -= -dense -. -matches_unit -( -unit -) -{ -epsilon_closure -( -nfa -next -builder -. -look_have -( -) -stack -& -mut -sparses -. -set2 -) -; -} -} -} -} -/ -/ -We -only -set -the -word -byte -if -there -' -s -a -word -boundary -look -- -around -/ -/ -anywhere -in -this -regex -. -Otherwise -there -' -s -no -point -in -bloating -the -/ -/ -number -of -states -if -we -don -' -t -have -one -. -/ -/ -/ -/ -We -also -only -set -it -when -the -state -has -a -non -- -zero -number -of -NFA -states -. -/ -/ -Otherwise -we -could -wind -up -with -states -that -* -should -* -be -DEAD -states -/ -/ -but -are -otherwise -distinct -from -DEAD -states -because -of -this -look -- -behind -/ -/ -assertion -being -set -. -While -this -can -' -t -technically -impact -correctness -* -in -/ -/ -theory -* -it -can -create -pathological -DFAs -that -consume -input -until -EOI -or -/ -/ -a -quit -byte -is -seen -. -Consuming -until -EOI -isn -' -t -a -correctness -problem -/ -/ -but -a -( -serious -) -perf -problem -. -Hitting -a -quit -byte -however -could -be -a -/ -/ -correctness -problem -since -it -could -cause -search -routines -to -report -an -/ -/ -error -instead -of -a -detected -match -once -the -quit -state -is -entered -. -( -The -/ -/ -search -routine -could -be -made -to -be -a -bit -smarter -by -reporting -a -match -/ -/ -if -one -was -detected -once -it -enters -a -quit -state -( -and -indeed -the -search -/ -/ -routines -in -this -crate -do -just -that -) -but -it -seems -better -to -prevent -/ -/ -these -things -by -construction -if -possible -. -) -if -! -sparses -. -set2 -. -is_empty -( -) -{ -if -nfa -. -look_set_any -( -) -. -contains_word -( -) -& -& -unit -. -is_word_byte -( -) -{ -builder -. -set_is_from_word -( -) -; -} -if -nfa -. -look_set_any -( -) -. -contains_anchor_crlf -( -) -& -& -( -( -rev -& -& -unit -. -is_byte -( -b -' -\ -n -' -) -) -| -| -( -! -rev -& -& -unit -. -is_byte -( -b -' -\ -r -' -) -) -) -{ -builder -. -set_is_half_crlf -( -) -; -} -} -let -mut -builder_nfa -= -builder -. -into_nfa -( -) -; -add_nfa_states -( -nfa -& -sparses -. -set2 -& -mut -builder_nfa -) -; -builder_nfa -} -/ -/ -/ -Compute -the -epsilon -closure -for -the -given -NFA -state -. -The -epsilon -closure -/ -/ -/ -consists -of -all -NFA -state -IDs -including -start_nfa_id -that -can -be -/ -/ -/ -reached -from -start_nfa_id -without -consuming -any -input -. -These -state -IDs -/ -/ -/ -are -written -to -set -in -the -order -they -are -visited -but -only -if -they -are -/ -/ -/ -not -already -in -set -. -start_nfa_id -must -be -a -valid -state -ID -for -the -NFA -/ -/ -/ -given -. -/ -/ -/ -/ -/ -/ -look_have -consists -of -the -satisfied -assertions -at -the -current -/ -/ -/ -position -. -For -conditional -look -- -around -epsilon -transitions -these -are -/ -/ -/ -only -followed -if -they -are -satisfied -by -look_have -. -/ -/ -/ -/ -/ -/ -stack -must -have -length -0 -. -It -is -used -as -scratch -space -for -depth -first -/ -/ -/ -traversal -. -After -returning -it -is -guaranteed -that -stack -will -have -length -/ -/ -/ -0 -. -pub -( -crate -) -fn -epsilon_closure -( -nfa -: -& -thompson -: -: -NFA -start_nfa_id -: -StateID -look_have -: -LookSet -stack -: -& -mut -Vec -< -StateID -> -set -: -& -mut -SparseSet -) -{ -assert -! -( -stack -. -is_empty -( -) -) -; -/ -/ -If -this -isn -' -t -an -epsilon -state -then -the -epsilon -closure -is -always -just -/ -/ -itself -so -there -' -s -no -need -to -spin -up -the -machinery -below -to -handle -it -. -if -! -nfa -. -state -( -start_nfa_id -) -. -is_epsilon -( -) -{ -set -. -insert -( -start_nfa_id -) -; -return -; -} -stack -. -push -( -start_nfa_id -) -; -while -let -Some -( -mut -id -) -= -stack -. -pop -( -) -{ -/ -/ -In -many -cases -we -can -avoid -stack -operations -when -an -NFA -state -only -/ -/ -adds -one -new -state -to -visit -. -In -that -case -we -just -set -our -ID -to -/ -/ -that -state -and -mush -on -. -We -only -use -the -stack -when -an -NFA -state -/ -/ -introduces -multiple -new -states -to -visit -. -loop -{ -/ -/ -Insert -this -NFA -state -and -if -it -' -s -already -in -the -set -and -thus -/ -/ -already -visited -then -we -can -move -on -to -the -next -one -. -if -! -set -. -insert -( -id -) -{ -break -; -} -match -* -nfa -. -state -( -id -) -{ -thompson -: -: -State -: -: -ByteRange -{ -. -. -} -| -thompson -: -: -State -: -: -Sparse -{ -. -. -} -| -thompson -: -: -State -: -: -Dense -{ -. -. -} -| -thompson -: -: -State -: -: -Fail -| -thompson -: -: -State -: -: -Match -{ -. -. -} -= -> -break -thompson -: -: -State -: -: -Look -{ -look -next -} -= -> -{ -if -! -look_have -. -contains -( -look -) -{ -break -; -} -id -= -next -; -} -thompson -: -: -State -: -: -Union -{ -ref -alternates -} -= -> -{ -id -= -match -alternates -. -get -( -0 -) -{ -None -= -> -break -Some -( -& -id -) -= -> -id -} -; -/ -/ -We -need -to -process -our -alternates -in -order -to -preserve -/ -/ -match -preferences -so -put -the -earliest -alternates -closer -/ -/ -to -the -top -of -the -stack -. -stack -. -extend -( -alternates -[ -1 -. -. -] -. -iter -( -) -. -rev -( -) -) -; -} -thompson -: -: -State -: -: -BinaryUnion -{ -alt1 -alt2 -} -= -> -{ -id -= -alt1 -; -stack -. -push -( -alt2 -) -; -} -thompson -: -: -State -: -: -Capture -{ -next -. -. -} -= -> -{ -id -= -next -; -} -} -} -} -} -/ -/ -/ -Add -the -NFA -state -IDs -in -the -given -set -to -the -given -DFA -builder -state -. -/ -/ -/ -The -order -in -which -states -are -added -corresponds -to -the -order -in -which -they -/ -/ -/ -were -added -to -set -. -/ -/ -/ -/ -/ -/ -The -DFA -builder -state -given -should -already -have -its -complete -set -of -match -/ -/ -/ -pattern -IDs -added -( -if -any -) -and -any -look -- -behind -assertions -( -StartLF -Start -/ -/ -/ -and -whether -this -state -is -being -generated -for -a -transition -over -a -word -byte -/ -/ -/ -when -applicable -) -that -are -true -immediately -prior -to -transitioning -into -this -/ -/ -/ -state -( -via -builder -. -look_have -( -) -) -. -The -match -pattern -IDs -should -correspond -/ -/ -/ -to -matches -that -occurred -on -the -previous -transition -since -all -matches -are -/ -/ -/ -delayed -by -one -byte -. -The -things -that -should -_not_ -be -set -are -look -- -ahead -/ -/ -/ -assertions -( -EndLF -End -and -whether -the -next -byte -is -a -word -byte -or -not -) -. -/ -/ -/ -The -builder -state -should -also -not -have -anything -in -look_need -set -as -this -/ -/ -/ -routine -will -compute -that -for -you -. -/ -/ -/ -/ -/ -/ -The -given -NFA -should -be -able -to -resolve -all -identifiers -in -set -to -a -/ -/ -/ -particular -NFA -state -. -Additionally -set -must -have -capacity -equivalent -/ -/ -/ -to -nfa -. -len -( -) -. -pub -( -crate -) -fn -add_nfa_states -( -nfa -: -& -thompson -: -: -NFA -set -: -& -SparseSet -builder -: -& -mut -StateBuilderNFA -) -{ -for -nfa_id -in -set -. -iter -( -) -{ -match -* -nfa -. -state -( -nfa_id -) -{ -thompson -: -: -State -: -: -ByteRange -{ -. -. -} -= -> -{ -builder -. -add_nfa_state_id -( -nfa_id -) -; -} -thompson -: -: -State -: -: -Sparse -{ -. -. -} -= -> -{ -builder -. -add_nfa_state_id -( -nfa_id -) -; -} -thompson -: -: -State -: -: -Dense -{ -. -. -} -= -> -{ -builder -. -add_nfa_state_id -( -nfa_id -) -; -} -thompson -: -: -State -: -: -Look -{ -look -. -. -} -= -> -{ -builder -. -add_nfa_state_id -( -nfa_id -) -; -builder -. -set_look_need -( -| -need -| -need -. -insert -( -look -) -) -; -} -thompson -: -: -State -: -: -Union -{ -. -. -} -| -thompson -: -: -State -: -: -BinaryUnion -{ -. -. -} -= -> -{ -/ -/ -Pure -epsilon -transitions -don -' -t -need -to -be -tracked -as -part -/ -/ -of -the -DFA -state -. -Tracking -them -is -actually -superfluous -; -/ -/ -they -won -' -t -cause -any -harm -other -than -making -determinization -/ -/ -slower -. -/ -/ -/ -/ -Why -aren -' -t -these -needed -? -Well -in -an -NFA -epsilon -/ -/ -transitions -are -really -just -jumping -points -to -other -states -. -/ -/ -So -once -you -hit -an -epsilon -transition -the -same -set -of -/ -/ -resulting -states -always -appears -. -Therefore -putting -them -in -/ -/ -a -DFA -' -s -set -of -ordered -NFA -states -is -strictly -redundant -. -/ -/ -/ -/ -Look -- -around -states -are -also -epsilon -transitions -but -/ -/ -they -are -* -conditional -* -. -So -their -presence -could -be -/ -/ -discriminatory -and -thus -they -are -tracked -above -. -/ -/ -/ -/ -But -wait -. -. -. -why -are -epsilon -states -in -our -set -in -the -first -/ -/ -place -? -Why -not -just -leave -them -out -? -They -' -re -in -our -set -/ -/ -because -it -was -generated -by -computing -an -epsilon -closure -/ -/ -and -we -want -to -keep -track -of -all -states -we -visited -to -avoid -/ -/ -re -- -visiting -them -. -In -exchange -we -have -to -do -this -second -/ -/ -iteration -over -our -collected -states -to -finalize -our -DFA -/ -/ -state -. -In -theory -we -could -avoid -this -second -iteration -if -/ -/ -we -maintained -two -sets -during -epsilon -closure -: -the -set -of -/ -/ -visited -states -( -to -avoid -cycles -) -and -the -set -of -states -that -/ -/ -will -actually -be -used -to -construct -the -next -DFA -state -. -/ -/ -/ -/ -Note -that -this -optimization -requires -that -we -re -- -compute -the -/ -/ -epsilon -closure -to -account -for -look -- -ahead -in -' -next -' -* -only -/ -/ -when -necessary -* -. -Namely -only -when -the -set -of -look -- -around -/ -/ -assertions -changes -and -only -when -those -changes -are -within -/ -/ -the -set -of -assertions -that -are -needed -in -order -to -step -/ -/ -through -the -closure -correctly -. -Otherwise -if -we -re -- -do -the -/ -/ -epsilon -closure -needlessly -it -could -change -based -on -the -/ -/ -fact -that -we -are -omitting -epsilon -states -here -. -/ -/ -/ -/ -- -- -- -- -- -/ -/ -/ -/ -Welp -scratch -the -above -. -It -turns -out -that -recording -these -/ -/ -is -in -fact -necessary -to -seemingly -handle -one -particularly -/ -/ -annoying -case -: -when -a -conditional -epsilon -transition -is -/ -/ -put -inside -of -a -repetition -operator -. -One -specific -case -I -/ -/ -ran -into -was -the -regex -( -? -: -\ -b -| -% -) -+ -on -the -haystack -z -% -. -/ -/ -The -correct -leftmost -first -matches -are -: -[ -0 -0 -] -and -[ -1 -1 -] -. -/ -/ -But -the -DFA -was -reporting -[ -0 -0 -] -and -[ -1 -2 -] -. -To -understand -/ -/ -why -this -happens -consider -the -NFA -for -the -aforementioned -/ -/ -regex -: -/ -/ -/ -/ -> -000000 -: -binary -- -union -( -4 -1 -) -/ -/ -000001 -: -\ -x00 -- -\ -xFF -= -> -0 -/ -/ -000002 -: -WordAscii -= -> -5 -/ -/ -000003 -: -% -= -> -5 -/ -/ -^ -000004 -: -binary -- -union -( -2 -3 -) -/ -/ -000005 -: -binary -- -union -( -4 -6 -) -/ -/ -000006 -: -MATCH -( -0 -) -/ -/ -/ -/ -The -problem -here -is -that -one -of -the -DFA -start -states -is -/ -/ -going -to -consist -of -the -NFA -states -[ -2 -3 -] -by -computing -the -/ -/ -epsilon -closure -of -state -4 -. -State -4 -isn -' -t -included -because -/ -/ -we -previously -were -not -keeping -track -of -union -states -. -But -/ -/ -only -a -subset -of -transitions -out -of -this -state -will -be -able -/ -/ -to -follow -WordAscii -and -in -those -cases -the -epsilon -closure -/ -/ -is -redone -. -The -only -problem -is -that -computing -the -epsilon -/ -/ -closure -from -[ -2 -3 -] -is -different -than -computing -the -epsilon -/ -/ -closure -from -[ -4 -] -. -In -the -former -case -assuming -the -WordAscii -/ -/ -assertion -is -satisfied -you -get -: -[ -2 -3 -6 -] -. -In -the -latter -/ -/ -case -you -get -: -[ -2 -6 -3 -] -. -Notice -that -' -6 -' -is -the -match -state -/ -/ -and -appears -AFTER -' -3 -' -in -the -former -case -. -This -leads -to -a -/ -/ -preferential -but -incorrect -match -of -' -% -' -before -returning -/ -/ -a -match -. -In -the -latter -case -the -match -is -preferred -over -/ -/ -continuing -to -accept -the -' -% -' -. -/ -/ -/ -/ -It -almost -feels -like -we -might -be -able -to -fix -the -NFA -states -/ -/ -to -avoid -this -or -to -at -least -only -keep -track -of -union -/ -/ -states -where -this -actually -matters -since -in -the -vast -/ -/ -majority -of -cases -this -doesn -' -t -matter -. -/ -/ -/ -/ -Another -alternative -would -be -to -define -a -new -HIR -property -/ -/ -called -" -assertion -is -repeated -anywhere -" -and -compute -it -/ -/ -inductively -over -the -entire -pattern -. -If -it -happens -anywhere -/ -/ -which -is -probably -pretty -rare -then -we -record -union -states -. -/ -/ -Otherwise -we -don -' -t -. -builder -. -add_nfa_state_id -( -nfa_id -) -; -} -/ -/ -Capture -states -we -definitely -do -not -need -to -record -since -they -/ -/ -are -unconditional -epsilon -transitions -with -no -branching -. -thompson -: -: -State -: -: -Capture -{ -. -. -} -= -> -{ -} -/ -/ -It -' -s -not -totally -clear -whether -we -need -to -record -fail -states -or -/ -/ -not -but -we -do -so -out -of -an -abundance -of -caution -. -Since -they -are -/ -/ -quite -rare -in -practice -there -isn -' -t -much -cost -to -recording -them -. -thompson -: -: -State -: -: -Fail -= -> -{ -builder -. -add_nfa_state_id -( -nfa_id -) -; -} -thompson -: -: -State -: -: -Match -{ -. -. -} -= -> -{ -/ -/ -Normally -the -NFA -match -state -doesn -' -t -actually -need -to -/ -/ -be -inside -the -DFA -state -. -But -since -we -delay -matches -by -/ -/ -one -byte -the -matching -DFA -state -corresponds -to -states -/ -/ -that -transition -from -the -one -we -' -re -building -here -. -And -/ -/ -the -way -we -detect -those -cases -is -by -looking -for -an -NFA -/ -/ -match -state -. -See -' -next -' -for -how -this -is -handled -. -builder -. -add_nfa_state_id -( -nfa_id -) -; -} -} -} -/ -/ -If -we -know -this -state -contains -no -look -- -around -assertions -then -/ -/ -there -' -s -no -reason -to -track -which -look -- -around -assertions -were -/ -/ -satisfied -when -this -state -was -created -. -if -builder -. -look_need -( -) -. -is_empty -( -) -{ -builder -. -set_look_have -( -| -_ -| -LookSet -: -: -empty -( -) -) -; -} -} -/ -/ -/ -Sets -the -appropriate -look -- -behind -assertions -on -the -given -state -based -on -/ -/ -/ -this -starting -configuration -. -pub -( -crate -) -fn -set_lookbehind_from_start -( -nfa -: -& -thompson -: -: -NFA -start -: -& -Start -builder -: -& -mut -StateBuilderMatches -) -{ -let -rev -= -nfa -. -is_reverse -( -) -; -let -lineterm -= -nfa -. -look_matcher -( -) -. -get_line_terminator -( -) -; -match -* -start -{ -Start -: -: -NonWordByte -= -> -{ -} -Start -: -: -WordByte -= -> -{ -builder -. -set_is_from_word -( -) -; -} -Start -: -: -Text -= -> -{ -builder -. -set_look_have -( -| -have -| -{ -have -. -insert -( -Look -: -: -Start -) -. -insert -( -Look -: -: -StartLF -) -. -insert -( -Look -: -: -StartCRLF -) -} -) -; -} -Start -: -: -LineLF -= -> -{ -if -rev -{ -builder -. -set_is_half_crlf -( -) -; -builder -. -set_look_have -( -| -have -| -have -. -insert -( -Look -: -: -StartLF -) -) -; -} -else -{ -builder -. -set_look_have -( -| -have -| -have -. -insert -( -Look -: -: -StartCRLF -) -) -; -} -if -lineterm -= -= -b -' -\ -n -' -{ -builder -. -set_look_have -( -| -have -| -have -. -insert -( -Look -: -: -StartLF -) -) -; -} -} -Start -: -: -LineCR -= -> -{ -if -rev -{ -builder -. -set_look_have -( -| -have -| -have -. -insert -( -Look -: -: -StartCRLF -) -) -; -} -else -{ -builder -. -set_is_half_crlf -( -) -; -} -if -lineterm -= -= -b -' -\ -r -' -{ -builder -. -set_look_have -( -| -have -| -have -. -insert -( -Look -: -: -StartLF -) -) -; -} -} -Start -: -: -CustomLineTerminator -= -> -{ -builder -. -set_look_have -( -| -have -| -have -. -insert -( -Look -: -: -StartLF -) -) -; -/ -/ -This -is -a -bit -of -a -tricky -case -but -if -the -line -terminator -was -/ -/ -set -to -a -word -byte -then -we -also -need -to -behave -as -if -the -start -/ -/ -configuration -is -Start -: -: -WordByte -. -That -is -we -need -to -mark -our -/ -/ -state -as -having -come -from -a -word -byte -. -if -utf8 -: -: -is_word_byte -( -lineterm -) -{ -builder -. -set_is_from_word -( -) -; -} -} -} -} diff --git a/third_party/rust/regex-automata/src/util/determinize/state.rs b/third_party/rust/regex-automata/src/util/determinize/state.rs deleted file mode 100644 index 2670b1fbfded2..0000000000000 --- a/third_party/rust/regex-automata/src/util/determinize/state.rs +++ /dev/null @@ -1,8205 +0,0 @@ -/ -* -! -This -module -defines -a -DFA -state -representation -and -builders -for -constructing -DFA -states -. -This -representation -is -specifically -for -use -in -implementations -of -NFA -- -to -- -DFA -conversion -via -powerset -construction -. -( -Also -called -" -determinization -" -in -this -crate -. -) -The -term -" -DFA -state -" -is -somewhat -overloaded -in -this -crate -. -In -some -cases -it -refers -to -the -set -of -transitions -over -an -alphabet -for -a -particular -state -. -In -other -cases -it -refers -to -a -set -of -NFA -states -. -The -former -is -really -about -the -final -representation -of -a -state -in -a -DFA -' -s -transition -table -where -as -the -latter -- -- -- -what -this -module -is -focused -on -- -- -- -is -closer -to -an -intermediate -form -that -is -used -to -help -eventually -build -the -transition -table -. -This -module -exports -four -types -. -All -four -types -represent -the -same -idea -: -an -ordered -set -of -NFA -states -. -This -ordered -set -represents -the -epsilon -closure -of -a -particular -NFA -state -where -the -" -epsilon -closure -" -is -the -set -of -NFA -states -that -can -be -transitioned -to -without -consuming -any -input -. -i -. -e -. -Follow -all -of -the -NFA -state -' -s -epsilon -transitions -. -In -addition -this -implementation -of -DFA -states -cares -about -two -other -things -: -the -ordered -set -of -pattern -IDs -corresponding -to -the -patterns -that -match -if -the -state -is -a -match -state -and -the -set -of -look -- -behind -assertions -that -were -true -when -the -state -was -created -. -The -first -State -is -a -frozen -representation -of -a -state -that -cannot -be -modified -. -It -may -be -cheaply -cloned -without -copying -the -state -itself -and -can -be -accessed -safely -from -multiple -threads -simultaneously -. -This -type -is -useful -for -when -one -knows -that -the -DFA -state -being -constructed -is -distinct -from -any -other -previously -constructed -states -. -Namely -powerset -construction -in -practice -requires -one -to -keep -a -cache -of -previously -created -DFA -states -. -Otherwise -the -number -of -DFA -states -created -in -memory -balloons -to -an -impractically -large -number -. -For -this -reason -equivalent -states -should -endeavor -to -have -an -equivalent -byte -- -level -representation -. -( -In -general -" -equivalency -" -here -means -" -equivalent -assertions -pattern -IDs -and -NFA -state -IDs -. -" -We -do -not -require -that -full -DFA -minimization -be -implemented -here -. -This -form -of -equivalency -is -only -surface -deep -and -is -more -- -or -- -less -a -practical -necessity -. -) -The -other -three -types -represent -different -phases -in -the -construction -of -a -DFA -state -. -Internally -these -three -types -( -and -State -) -all -use -the -same -byte -- -oriented -representation -. -That -means -one -can -use -any -of -the -builder -types -to -check -whether -the -state -it -represents -already -exists -or -not -. -If -it -does -then -there -is -no -need -to -freeze -it -into -a -State -( -which -requires -an -alloc -and -a -copy -) -. -Here -are -the -three -types -described -succinctly -: -* -StateBuilderEmpty -represents -a -state -with -no -pattern -IDs -no -assertions -and -no -NFA -states -. -Creating -a -StateBuilderEmpty -performs -no -allocs -. -A -StateBuilderEmpty -can -only -be -used -to -query -its -underlying -memory -capacity -or -to -convert -into -a -builder -for -recording -pattern -IDs -and -/ -or -assertions -. -* -StateBuilderMatches -represents -a -state -with -zero -or -more -pattern -IDs -zero -or -more -satisfied -assertions -and -zero -NFA -state -IDs -. -A -StateBuilderMatches -can -only -be -used -for -adding -pattern -IDs -and -recording -assertions -. -* -StateBuilderNFA -represents -a -state -with -zero -or -more -pattern -IDs -zero -or -more -satisfied -assertions -and -zero -or -more -NFA -state -IDs -. -A -StateBuilderNFA -can -only -be -used -for -adding -NFA -state -IDs -and -recording -some -assertions -. -The -expected -flow -here -is -to -use -the -above -builders -to -construct -a -candidate -DFA -state -to -check -if -it -already -exists -. -If -it -does -then -there -' -s -no -need -to -freeze -it -into -a -State -. -It -it -doesn -' -t -exist -then -StateBuilderNFA -: -: -to_state -can -be -called -to -freeze -the -builder -into -an -immutable -State -. -In -either -case -clear -should -be -called -on -the -builder -to -turn -it -back -into -a -StateBuilderEmpty -that -reuses -the -underlying -memory -. -The -main -purpose -for -splitting -the -builder -into -these -distinct -types -is -to -make -it -impossible -to -do -things -like -adding -a -pattern -ID -after -adding -an -NFA -state -ID -. -Namely -this -makes -it -simpler -to -use -a -space -- -and -- -time -efficient -binary -representation -for -the -state -. -( -The -format -is -documented -on -the -Repr -type -below -. -) -If -we -just -used -one -type -for -everything -it -would -be -possible -for -callers -to -use -an -incorrect -interleaving -of -calls -and -thus -result -in -a -corrupt -representation -. -I -chose -to -use -more -type -machinery -to -make -this -impossible -to -do -because -1 -) -determinization -is -itself -pretty -complex -and -it -wouldn -' -t -be -too -hard -to -foul -this -up -and -2 -) -there -isn -' -t -too -much -machinery -involved -and -it -' -s -well -contained -. -As -an -optimization -sometimes -states -won -' -t -have -certain -things -set -. -For -example -if -the -underlying -NFA -has -no -word -boundary -assertions -then -there -is -no -reason -to -set -a -state -' -s -look -- -behind -assertion -as -to -whether -it -was -generated -from -a -word -byte -or -not -. -Similarly -if -a -state -has -no -NFA -states -corresponding -to -look -- -around -assertions -then -there -is -no -reason -to -set -look_have -to -a -non -- -empty -set -. -Finally -callers -usually -omit -unconditional -epsilon -transitions -when -adding -NFA -state -IDs -since -they -aren -' -t -discriminatory -. -Finally -the -binary -representation -used -by -these -states -is -thankfully -not -serialized -anywhere -. -So -any -kind -of -change -can -be -made -with -reckless -abandon -as -long -as -everything -in -this -module -agrees -. -* -/ -use -core -: -: -{ -convert -: -: -TryFrom -mem -} -; -use -alloc -: -: -{ -sync -: -: -Arc -vec -: -: -Vec -} -; -use -crate -: -: -util -: -: -{ -int -: -: -{ -I32 -U32 -} -look -: -: -LookSet -primitives -: -: -{ -PatternID -StateID -} -wire -: -: -{ -self -Endian -} -} -; -/ -/ -/ -A -DFA -state -that -at -its -core -is -represented -by -an -ordered -set -of -NFA -/ -/ -/ -states -. -/ -/ -/ -/ -/ -/ -This -type -is -intended -to -be -used -only -in -NFA -- -to -- -DFA -conversion -via -powerset -/ -/ -/ -construction -. -/ -/ -/ -/ -/ -/ -It -may -be -cheaply -cloned -and -accessed -safely -from -multiple -threads -/ -/ -/ -simultaneously -. -# -[ -derive -( -Clone -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -pub -( -crate -) -struct -State -( -Arc -< -[ -u8 -] -> -) -; -/ -/ -/ -This -Borrow -impl -permits -us -to -lookup -any -state -in -a -map -by -its -byte -/ -/ -/ -representation -. -This -is -particularly -convenient -when -one -has -a -StateBuilder -/ -/ -/ -and -we -want -to -see -if -a -correspondingly -equivalent -state -already -exists -. -If -/ -/ -/ -one -does -exist -then -we -can -reuse -the -allocation -required -by -StateBuilder -/ -/ -/ -without -having -to -convert -it -into -a -State -first -. -impl -core -: -: -borrow -: -: -Borrow -< -[ -u8 -] -> -for -State -{ -fn -borrow -( -& -self -) -- -> -& -[ -u8 -] -{ -& -* -self -. -0 -} -} -impl -core -: -: -fmt -: -: -Debug -for -State -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -" -State -" -) -. -field -( -& -self -. -repr -( -) -) -. -finish -( -) -} -} -/ -/ -/ -For -docs -on -these -routines -see -the -internal -Repr -and -ReprVec -types -below -. -impl -State -{ -pub -( -crate -) -fn -dead -( -) -- -> -State -{ -StateBuilderEmpty -: -: -new -( -) -. -into_matches -( -) -. -into_nfa -( -) -. -to_state -( -) -} -pub -( -crate -) -fn -is_match -( -& -self -) -- -> -bool -{ -self -. -repr -( -) -. -is_match -( -) -} -pub -( -crate -) -fn -is_from_word -( -& -self -) -- -> -bool -{ -self -. -repr -( -) -. -is_from_word -( -) -} -pub -( -crate -) -fn -is_half_crlf -( -& -self -) -- -> -bool -{ -self -. -repr -( -) -. -is_half_crlf -( -) -} -pub -( -crate -) -fn -look_have -( -& -self -) -- -> -LookSet -{ -self -. -repr -( -) -. -look_have -( -) -} -pub -( -crate -) -fn -look_need -( -& -self -) -- -> -LookSet -{ -self -. -repr -( -) -. -look_need -( -) -} -pub -( -crate -) -fn -match_len -( -& -self -) -- -> -usize -{ -self -. -repr -( -) -. -match_len -( -) -} -pub -( -crate -) -fn -match_pattern -( -& -self -index -: -usize -) -- -> -PatternID -{ -self -. -repr -( -) -. -match_pattern -( -index -) -} -pub -( -crate -) -fn -match_pattern_ids -( -& -self -) -- -> -Option -< -Vec -< -PatternID -> -> -{ -self -. -repr -( -) -. -match_pattern_ids -( -) -} -# -[ -cfg -( -all -( -test -not -( -miri -) -) -) -] -pub -( -crate -) -fn -iter_match_pattern_ids -< -F -: -FnMut -( -PatternID -) -> -( -& -self -f -: -F -) -{ -self -. -repr -( -) -. -iter_match_pattern_ids -( -f -) -} -pub -( -crate -) -fn -iter_nfa_state_ids -< -F -: -FnMut -( -StateID -) -> -( -& -self -f -: -F -) -{ -self -. -repr -( -) -. -iter_nfa_state_ids -( -f -) -} -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -0 -. -len -( -) -} -fn -repr -( -& -self -) -- -> -Repr -< -' -_ -> -{ -Repr -( -& -* -self -. -0 -) -} -} -/ -/ -/ -A -state -builder -that -represents -an -empty -state -. -/ -/ -/ -/ -/ -/ -This -is -a -useful -" -initial -condition -" -for -state -construction -. -It -has -no -/ -/ -/ -NFA -state -IDs -no -assertions -set -and -no -pattern -IDs -. -No -allocations -are -/ -/ -/ -made -when -new -( -) -is -called -. -Its -main -use -is -for -being -converted -into -a -/ -/ -/ -builder -that -can -capture -assertions -and -pattern -IDs -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -StateBuilderEmpty -( -Vec -< -u8 -> -) -; -/ -/ -/ -For -docs -on -these -routines -see -the -internal -Repr -and -ReprVec -types -below -. -impl -StateBuilderEmpty -{ -pub -( -crate -) -fn -new -( -) -- -> -StateBuilderEmpty -{ -StateBuilderEmpty -( -alloc -: -: -vec -! -[ -] -) -} -pub -( -crate -) -fn -into_matches -( -mut -self -) -- -> -StateBuilderMatches -{ -self -. -0 -. -extend_from_slice -( -& -[ -0 -0 -0 -0 -0 -] -) -; -StateBuilderMatches -( -self -. -0 -) -} -fn -clear -( -& -mut -self -) -{ -self -. -0 -. -clear -( -) -; -} -pub -( -crate -) -fn -capacity -( -& -self -) -- -> -usize -{ -self -. -0 -. -capacity -( -) -} -} -/ -/ -/ -A -state -builder -that -collects -assertions -and -pattern -IDs -. -/ -/ -/ -/ -/ -/ -When -collecting -pattern -IDs -is -finished -this -can -be -converted -into -a -/ -/ -/ -builder -that -collects -NFA -state -IDs -. -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -StateBuilderMatches -( -Vec -< -u8 -> -) -; -impl -core -: -: -fmt -: -: -Debug -for -StateBuilderMatches -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -" -StateBuilderMatches -" -) -. -field -( -& -self -. -repr -( -) -) -. -finish -( -) -} -} -/ -/ -/ -For -docs -on -these -routines -see -the -internal -Repr -and -ReprVec -types -below -. -impl -StateBuilderMatches -{ -pub -( -crate -) -fn -into_nfa -( -mut -self -) -- -> -StateBuilderNFA -{ -self -. -repr_vec -( -) -. -close_match_pattern_ids -( -) -; -StateBuilderNFA -{ -repr -: -self -. -0 -prev_nfa_state_id -: -StateID -: -: -ZERO -} -} -pub -( -crate -) -fn -set_is_from_word -( -& -mut -self -) -{ -self -. -repr_vec -( -) -. -set_is_from_word -( -) -} -pub -( -crate -) -fn -set_is_half_crlf -( -& -mut -self -) -{ -self -. -repr_vec -( -) -. -set_is_half_crlf -( -) -} -pub -( -crate -) -fn -look_have -( -& -self -) -- -> -LookSet -{ -LookSet -: -: -read_repr -( -& -self -. -0 -[ -1 -. -. -] -) -} -pub -( -crate -) -fn -set_look_have -( -& -mut -self -set -: -impl -FnMut -( -LookSet -) -- -> -LookSet -) -{ -self -. -repr_vec -( -) -. -set_look_have -( -set -) -} -pub -( -crate -) -fn -add_match_pattern_id -( -& -mut -self -pid -: -PatternID -) -{ -self -. -repr_vec -( -) -. -add_match_pattern_id -( -pid -) -} -fn -repr -( -& -self -) -- -> -Repr -< -' -_ -> -{ -Repr -( -& -self -. -0 -) -} -fn -repr_vec -( -& -mut -self -) -- -> -ReprVec -< -' -_ -> -{ -ReprVec -( -& -mut -self -. -0 -) -} -} -/ -/ -/ -A -state -builder -that -collects -some -assertions -and -NFA -state -IDs -. -/ -/ -/ -/ -/ -/ -When -collecting -NFA -state -IDs -is -finished -this -can -be -used -to -build -a -/ -/ -/ -State -if -necessary -. -/ -/ -/ -/ -/ -/ -When -dont -with -building -a -state -( -regardless -of -whether -it -got -kept -or -not -) -/ -/ -/ -it -' -s -usually -a -good -idea -to -call -clear -to -get -an -empty -builder -back -so -/ -/ -/ -that -it -can -be -reused -to -build -the -next -state -. -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -StateBuilderNFA -{ -repr -: -Vec -< -u8 -> -prev_nfa_state_id -: -StateID -} -impl -core -: -: -fmt -: -: -Debug -for -StateBuilderNFA -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -" -StateBuilderNFA -" -) -. -field -( -& -self -. -repr -( -) -) -. -finish -( -) -} -} -/ -/ -/ -For -docs -on -these -routines -see -the -internal -Repr -and -ReprVec -types -below -. -impl -StateBuilderNFA -{ -pub -( -crate -) -fn -to_state -( -& -self -) -- -> -State -{ -State -( -Arc -: -: -from -( -& -* -self -. -repr -) -) -} -pub -( -crate -) -fn -clear -( -self -) -- -> -StateBuilderEmpty -{ -let -mut -builder -= -StateBuilderEmpty -( -self -. -repr -) -; -builder -. -clear -( -) -; -builder -} -pub -( -crate -) -fn -look_need -( -& -self -) -- -> -LookSet -{ -self -. -repr -( -) -. -look_need -( -) -} -pub -( -crate -) -fn -set_look_have -( -& -mut -self -set -: -impl -FnMut -( -LookSet -) -- -> -LookSet -) -{ -self -. -repr_vec -( -) -. -set_look_have -( -set -) -} -pub -( -crate -) -fn -set_look_need -( -& -mut -self -set -: -impl -FnMut -( -LookSet -) -- -> -LookSet -) -{ -self -. -repr_vec -( -) -. -set_look_need -( -set -) -} -pub -( -crate -) -fn -add_nfa_state_id -( -& -mut -self -sid -: -StateID -) -{ -ReprVec -( -& -mut -self -. -repr -) -. -add_nfa_state_id -( -& -mut -self -. -prev_nfa_state_id -sid -) -} -pub -( -crate -) -fn -as_bytes -( -& -self -) -- -> -& -[ -u8 -] -{ -& -self -. -repr -} -fn -repr -( -& -self -) -- -> -Repr -< -' -_ -> -{ -Repr -( -& -self -. -repr -) -} -fn -repr_vec -( -& -mut -self -) -- -> -ReprVec -< -' -_ -> -{ -ReprVec -( -& -mut -self -. -repr -) -} -} -/ -/ -/ -Repr -is -a -read -- -only -view -into -the -representation -of -a -DFA -state -. -/ -/ -/ -/ -/ -/ -Primarily -a -Repr -is -how -we -achieve -DRY -: -we -implement -decoding -the -format -/ -/ -/ -in -one -place -and -then -use -a -Repr -to -implement -the -various -methods -on -the -/ -/ -/ -public -state -types -. -/ -/ -/ -/ -/ -/ -The -format -is -as -follows -: -/ -/ -/ -/ -/ -/ -The -first -three -bytes -correspond -to -bitsets -. -/ -/ -/ -/ -/ -/ -Byte -0 -is -a -bitset -corresponding -to -miscellaneous -flags -associated -with -the -/ -/ -/ -state -. -Bit -0 -is -set -to -1 -if -the -state -is -a -match -state -. -Bit -1 -is -set -to -1 -/ -/ -/ -if -the -state -has -pattern -IDs -explicitly -written -to -it -. -( -This -is -a -flag -that -/ -/ -/ -is -not -meant -to -be -set -by -determinization -but -rather -is -used -as -part -of -/ -/ -/ -an -internal -space -- -saving -optimization -. -) -Bit -2 -is -set -to -1 -if -the -state -was -/ -/ -/ -generated -by -a -transition -over -a -" -word -" -byte -. -( -Callers -may -not -always -set -/ -/ -/ -this -. -For -example -if -the -NFA -has -no -word -boundary -assertion -then -needing -/ -/ -/ -to -track -whether -a -state -came -from -a -word -byte -or -not -is -superfluous -and -/ -/ -/ -wasteful -. -) -/ -/ -/ -/ -/ -/ -Byte -1 -corresponds -to -the -look -- -behind -assertions -that -were -satisfied -by -/ -/ -/ -the -transition -that -created -this -state -. -This -generally -only -includes -the -/ -/ -/ -StartLF -and -Start -assertions -. -( -Look -- -ahead -assertions -are -not -tracked -as -/ -/ -/ -part -of -states -. -Instead -these -are -applied -by -re -- -computing -the -epsilon -/ -/ -/ -closure -of -a -state -when -computing -the -transition -function -. -See -next -in -/ -/ -/ -the -parent -module -. -) -/ -/ -/ -/ -/ -/ -Byte -2 -corresponds -to -the -set -of -look -- -around -assertions -( -including -both -/ -/ -/ -look -- -behind -and -look -- -ahead -) -that -appear -somewhere -in -this -state -' -s -set -of -/ -/ -/ -NFA -state -IDs -. -This -is -used -to -determine -whether -this -state -' -s -epsilon -/ -/ -/ -closure -should -be -re -- -computed -when -computing -the -transition -function -. -/ -/ -/ -Namely -look -- -around -assertions -are -" -just -" -conditional -epsilon -transitions -/ -/ -/ -so -if -there -are -new -assertions -available -when -computing -the -transition -/ -/ -/ -function -we -should -only -re -- -compute -the -epsilon -closure -if -those -new -/ -/ -/ -assertions -are -relevant -to -this -particular -state -. -/ -/ -/ -/ -/ -/ -Bytes -3 -. -. -7 -correspond -to -a -32 -- -bit -native -- -endian -encoded -integer -/ -/ -/ -corresponding -to -the -number -of -patterns -encoded -in -this -state -. -If -the -state -/ -/ -/ -is -not -a -match -state -( -byte -0 -bit -0 -is -0 -) -or -if -it -' -s -only -pattern -ID -is -/ -/ -/ -PatternID -: -: -ZERO -then -no -integer -is -encoded -at -this -position -. -Instead -byte -/ -/ -/ -offset -3 -is -the -position -at -which -the -first -NFA -state -ID -is -encoded -. -/ -/ -/ -/ -/ -/ -For -a -match -state -with -at -least -one -non -- -ZERO -pattern -ID -the -next -bytes -/ -/ -/ -correspond -to -a -sequence -of -32 -- -bit -native -endian -encoded -integers -that -/ -/ -/ -represent -each -pattern -ID -in -order -that -this -match -state -represents -. -/ -/ -/ -/ -/ -/ -After -the -pattern -IDs -( -if -any -) -NFA -state -IDs -are -delta -encoded -as -/ -/ -/ -varints -. -[ -1 -] -The -first -NFA -state -ID -is -encoded -as -itself -and -each -/ -/ -/ -subsequent -NFA -state -ID -is -encoded -as -the -difference -between -itself -and -the -/ -/ -/ -previous -NFA -state -ID -. -/ -/ -/ -/ -/ -/ -[ -1 -] -- -https -: -/ -/ -developers -. -google -. -com -/ -protocol -- -buffers -/ -docs -/ -encoding -# -varints -struct -Repr -< -' -a -> -( -& -' -a -[ -u8 -] -) -; -impl -< -' -a -> -Repr -< -' -a -> -{ -/ -/ -/ -Returns -true -if -and -only -if -this -is -a -match -state -. -/ -/ -/ -/ -/ -/ -If -callers -have -added -pattern -IDs -to -this -state -then -callers -MUST -set -/ -/ -/ -this -state -as -a -match -state -explicitly -. -However -as -a -special -case -/ -/ -/ -states -that -are -marked -as -match -states -but -with -no -pattern -IDs -then -/ -/ -/ -the -state -is -treated -as -if -it -had -a -single -pattern -ID -equivalent -to -/ -/ -/ -PatternID -: -: -ZERO -. -fn -is_match -( -& -self -) -- -> -bool -{ -self -. -0 -[ -0 -] -& -( -1 -< -< -0 -) -> -0 -} -/ -/ -/ -Returns -true -if -and -only -if -this -state -has -had -at -least -one -pattern -/ -/ -/ -ID -added -to -it -. -/ -/ -/ -/ -/ -/ -This -is -an -internal -- -only -flag -that -permits -the -representation -to -save -/ -/ -/ -space -in -the -common -case -of -an -NFA -with -one -pattern -in -it -. -In -that -/ -/ -/ -case -a -match -state -can -only -ever -have -exactly -one -pattern -ID -: -/ -/ -/ -PatternID -: -: -ZERO -. -So -there -' -s -no -need -to -represent -it -. -fn -has_pattern_ids -( -& -self -) -- -> -bool -{ -self -. -0 -[ -0 -] -& -( -1 -< -< -1 -) -> -0 -} -/ -/ -/ -Returns -true -if -and -only -if -this -state -is -marked -as -having -been -created -/ -/ -/ -from -a -transition -over -a -word -byte -. -This -is -useful -for -checking -whether -/ -/ -/ -a -word -boundary -assertion -is -true -or -not -which -requires -look -- -behind -/ -/ -/ -( -whether -the -current -state -came -from -a -word -byte -or -not -) -and -look -- -ahead -/ -/ -/ -( -whether -the -transition -byte -is -a -word -byte -or -not -) -. -/ -/ -/ -/ -/ -/ -Since -states -with -this -set -are -distinct -from -states -that -don -' -t -have -/ -/ -/ -this -set -( -even -if -they -are -otherwise -equivalent -) -callers -should -not -/ -/ -/ -set -this -assertion -unless -the -underlying -NFA -has -at -least -one -word -/ -/ -/ -boundary -assertion -somewhere -. -Otherwise -a -superfluous -number -of -states -/ -/ -/ -may -be -created -. -fn -is_from_word -( -& -self -) -- -> -bool -{ -self -. -0 -[ -0 -] -& -( -1 -< -< -2 -) -> -0 -} -/ -/ -/ -Returns -true -if -and -only -if -this -state -is -marked -as -being -inside -of -a -/ -/ -/ -CRLF -terminator -. -In -the -forward -direction -this -means -the -state -was -/ -/ -/ -created -after -seeing -a -\ -r -. -In -the -reverse -direction -this -means -the -/ -/ -/ -state -was -created -after -seeing -a -\ -n -. -fn -is_half_crlf -( -& -self -) -- -> -bool -{ -self -. -0 -[ -0 -] -& -( -1 -< -< -3 -) -> -0 -} -/ -/ -/ -The -set -of -look -- -behind -assertions -that -were -true -in -the -transition -that -/ -/ -/ -created -this -state -. -/ -/ -/ -/ -/ -/ -Generally -this -should -be -empty -if -' -look_need -' -is -empty -since -there -is -/ -/ -/ -no -reason -to -track -which -look -- -behind -assertions -are -true -if -the -state -/ -/ -/ -has -no -conditional -epsilon -transitions -. -/ -/ -/ -/ -/ -/ -Satisfied -look -- -ahead -assertions -are -not -tracked -in -states -. -Instead -/ -/ -/ -these -are -re -- -computed -on -demand -via -epsilon -closure -when -computing -the -/ -/ -/ -transition -function -. -fn -look_have -( -& -self -) -- -> -LookSet -{ -LookSet -: -: -read_repr -( -& -self -. -0 -[ -1 -. -. -] -) -} -/ -/ -/ -The -set -of -look -- -around -( -both -behind -and -ahead -) -assertions -that -appear -/ -/ -/ -at -least -once -in -this -state -' -s -set -of -NFA -states -. -/ -/ -/ -/ -/ -/ -This -is -used -to -determine -whether -the -epsilon -closure -needs -to -be -/ -/ -/ -re -- -computed -when -computing -the -transition -function -. -Namely -if -the -/ -/ -/ -state -has -no -conditional -epsilon -transitions -then -there -is -no -need -/ -/ -/ -to -re -- -compute -the -epsilon -closure -. -fn -look_need -( -& -self -) -- -> -LookSet -{ -LookSet -: -: -read_repr -( -& -self -. -0 -[ -3 -. -. -] -) -} -/ -/ -/ -Returns -the -total -number -of -match -pattern -IDs -in -this -state -. -/ -/ -/ -/ -/ -/ -If -this -state -is -not -a -match -state -then -this -always -returns -0 -. -fn -match_len -( -& -self -) -- -> -usize -{ -if -! -self -. -is_match -( -) -{ -return -0 -; -} -else -if -! -self -. -has_pattern_ids -( -) -{ -1 -} -else -{ -self -. -encoded_pattern_len -( -) -} -} -/ -/ -/ -Returns -the -pattern -ID -for -this -match -state -at -the -given -index -. -/ -/ -/ -/ -/ -/ -If -the -given -index -is -greater -than -or -equal -to -match_len -( -) -for -this -/ -/ -/ -state -then -this -could -panic -or -return -incorrect -results -. -fn -match_pattern -( -& -self -index -: -usize -) -- -> -PatternID -{ -if -! -self -. -has_pattern_ids -( -) -{ -PatternID -: -: -ZERO -} -else -{ -let -offset -= -9 -+ -index -* -PatternID -: -: -SIZE -; -/ -/ -This -is -OK -since -we -only -ever -serialize -valid -PatternIDs -to -/ -/ -states -. -wire -: -: -read_pattern_id_unchecked -( -& -self -. -0 -[ -offset -. -. -] -) -. -0 -} -} -/ -/ -/ -Returns -a -copy -of -all -match -pattern -IDs -in -this -state -. -If -this -state -/ -/ -/ -is -not -a -match -state -then -this -returns -None -. -fn -match_pattern_ids -( -& -self -) -- -> -Option -< -Vec -< -PatternID -> -> -{ -if -! -self -. -is_match -( -) -{ -return -None -; -} -let -mut -pids -= -alloc -: -: -vec -! -[ -] -; -self -. -iter_match_pattern_ids -( -| -pid -| -pids -. -push -( -pid -) -) -; -Some -( -pids -) -} -/ -/ -/ -Calls -the -given -function -on -every -pattern -ID -in -this -state -. -fn -iter_match_pattern_ids -< -F -: -FnMut -( -PatternID -) -> -( -& -self -mut -f -: -F -) -{ -if -! -self -. -is_match -( -) -{ -return -; -} -/ -/ -As -an -optimization -for -a -very -common -case -when -this -is -a -match -/ -/ -state -for -an -NFA -with -only -one -pattern -we -don -' -t -actually -write -the -/ -/ -pattern -ID -to -the -state -representation -. -Instead -we -know -it -must -/ -/ -be -there -since -it -is -the -only -possible -choice -. -if -! -self -. -has_pattern_ids -( -) -{ -f -( -PatternID -: -: -ZERO -) -; -return -; -} -let -mut -pids -= -& -self -. -0 -[ -9 -. -. -self -. -pattern_offset_end -( -) -] -; -while -! -pids -. -is_empty -( -) -{ -let -pid -= -wire -: -: -read_u32 -( -pids -) -; -pids -= -& -pids -[ -PatternID -: -: -SIZE -. -. -] -; -/ -/ -This -is -OK -since -we -only -ever -serialize -valid -PatternIDs -to -/ -/ -states -. -And -since -pattern -IDs -can -never -exceed -a -usize -the -/ -/ -unwrap -is -OK -. -f -( -PatternID -: -: -new_unchecked -( -usize -: -: -try_from -( -pid -) -. -unwrap -( -) -) -) -; -} -} -/ -/ -/ -Calls -the -given -function -on -every -NFA -state -ID -in -this -state -. -fn -iter_nfa_state_ids -< -F -: -FnMut -( -StateID -) -> -( -& -self -mut -f -: -F -) -{ -let -mut -sids -= -& -self -. -0 -[ -self -. -pattern_offset_end -( -) -. -. -] -; -let -mut -prev -= -0i32 -; -while -! -sids -. -is_empty -( -) -{ -let -( -delta -nr -) -= -read_vari32 -( -sids -) -; -sids -= -& -sids -[ -nr -. -. -] -; -let -sid -= -prev -+ -delta -; -prev -= -sid -; -/ -/ -This -is -OK -since -we -only -ever -serialize -valid -StateIDs -to -/ -/ -states -. -And -since -state -IDs -can -never -exceed -an -isize -they -must -/ -/ -always -be -able -to -fit -into -a -usize -and -thus -cast -is -OK -. -f -( -StateID -: -: -new_unchecked -( -sid -. -as_usize -( -) -) -) -} -} -/ -/ -/ -Returns -the -offset -into -this -state -' -s -representation -where -the -pattern -/ -/ -/ -IDs -end -and -the -NFA -state -IDs -begin -. -fn -pattern_offset_end -( -& -self -) -- -> -usize -{ -let -encoded -= -self -. -encoded_pattern_len -( -) -; -if -encoded -= -= -0 -{ -return -5 -; -} -/ -/ -This -arithmetic -is -OK -since -we -were -able -to -address -this -many -bytes -/ -/ -when -writing -to -the -state -thus -it -must -fit -into -a -usize -. -encoded -. -checked_mul -( -4 -) -. -unwrap -( -) -. -checked_add -( -9 -) -. -unwrap -( -) -} -/ -/ -/ -Returns -the -total -number -of -* -encoded -* -pattern -IDs -in -this -state -. -/ -/ -/ -/ -/ -/ -This -may -return -0 -even -when -this -is -a -match -state -since -the -pattern -/ -/ -/ -ID -PatternID -: -: -ZERO -is -not -encoded -when -it -' -s -the -only -pattern -ID -in -/ -/ -/ -the -match -state -( -the -overwhelming -common -case -) -. -fn -encoded_pattern_len -( -& -self -) -- -> -usize -{ -if -! -self -. -has_pattern_ids -( -) -{ -return -0 -; -} -/ -/ -This -unwrap -is -OK -since -the -total -number -of -patterns -is -always -/ -/ -guaranteed -to -fit -into -a -usize -. -usize -: -: -try_from -( -wire -: -: -read_u32 -( -& -self -. -0 -[ -5 -. -. -9 -] -) -) -. -unwrap -( -) -} -} -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -Repr -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -nfa_ids -= -alloc -: -: -vec -! -[ -] -; -self -. -iter_nfa_state_ids -( -| -sid -| -nfa_ids -. -push -( -sid -) -) -; -f -. -debug_struct -( -" -Repr -" -) -. -field -( -" -is_match -" -& -self -. -is_match -( -) -) -. -field -( -" -is_from_word -" -& -self -. -is_from_word -( -) -) -. -field -( -" -is_half_crlf -" -& -self -. -is_half_crlf -( -) -) -. -field -( -" -look_have -" -& -self -. -look_have -( -) -) -. -field -( -" -look_need -" -& -self -. -look_need -( -) -) -. -field -( -" -match_pattern_ids -" -& -self -. -match_pattern_ids -( -) -) -. -field -( -" -nfa_state_ids -" -& -nfa_ids -) -. -finish -( -) -} -} -/ -/ -/ -ReprVec -is -a -write -- -only -view -into -the -representation -of -a -DFA -state -. -/ -/ -/ -/ -/ -/ -See -Repr -for -more -details -on -the -purpose -of -this -type -and -also -the -format -. -/ -/ -/ -/ -/ -/ -Note -that -not -all -possible -combinations -of -methods -may -be -called -. -This -is -/ -/ -/ -precisely -what -the -various -StateBuilder -types -encapsulate -: -they -only -/ -/ -/ -permit -valid -combinations -via -Rust -' -s -linear -typing -. -struct -ReprVec -< -' -a -> -( -& -' -a -mut -Vec -< -u8 -> -) -; -impl -< -' -a -> -ReprVec -< -' -a -> -{ -/ -/ -/ -Set -this -state -as -a -match -state -. -/ -/ -/ -/ -/ -/ -This -should -not -be -exposed -explicitly -outside -of -this -module -. -It -is -/ -/ -/ -set -automatically -when -a -pattern -ID -is -added -. -fn -set_is_match -( -& -mut -self -) -{ -self -. -0 -[ -0 -] -| -= -1 -< -< -0 -; -} -/ -/ -/ -Set -that -this -state -has -pattern -IDs -explicitly -written -to -it -. -/ -/ -/ -/ -/ -/ -This -should -not -be -exposed -explicitly -outside -of -this -module -. -This -is -/ -/ -/ -used -internally -as -a -space -saving -optimization -. -Namely -if -the -state -/ -/ -/ -is -a -match -state -but -does -not -have -any -pattern -IDs -written -to -it -/ -/ -/ -then -it -is -automatically -inferred -to -have -a -pattern -ID -of -ZERO -. -fn -set_has_pattern_ids -( -& -mut -self -) -{ -self -. -0 -[ -0 -] -| -= -1 -< -< -1 -; -} -/ -/ -/ -Set -this -state -as -being -built -from -a -transition -over -a -word -byte -. -/ -/ -/ -/ -/ -/ -Setting -this -is -only -necessary -when -one -needs -to -deal -with -word -/ -/ -/ -boundary -assertions -. -Therefore -if -the -underlying -NFA -has -no -word -/ -/ -/ -boundary -assertions -callers -should -not -set -this -. -fn -set_is_from_word -( -& -mut -self -) -{ -self -. -0 -[ -0 -] -| -= -1 -< -< -2 -; -} -/ -/ -/ -Set -this -state -as -having -seen -half -of -a -CRLF -terminator -. -/ -/ -/ -/ -/ -/ -In -the -forward -direction -this -should -be -set -when -a -\ -r -has -been -seen -. -/ -/ -/ -In -the -reverse -direction -this -should -be -set -when -a -\ -n -has -been -seen -. -fn -set_is_half_crlf -( -& -mut -self -) -{ -self -. -0 -[ -0 -] -| -= -1 -< -< -3 -; -} -/ -/ -/ -The -set -of -look -- -behind -assertions -that -were -true -in -the -transition -that -/ -/ -/ -created -this -state -. -fn -look_have -( -& -self -) -- -> -LookSet -{ -self -. -repr -( -) -. -look_have -( -) -} -/ -/ -/ -The -set -of -look -- -around -( -both -behind -and -ahead -) -assertions -that -appear -/ -/ -/ -at -least -once -in -this -state -' -s -set -of -NFA -states -. -fn -look_need -( -& -self -) -- -> -LookSet -{ -self -. -repr -( -) -. -look_need -( -) -} -/ -/ -/ -Mutate -the -set -of -look -- -behind -assertions -that -were -true -in -the -/ -/ -/ -transition -that -created -this -state -. -fn -set_look_have -( -& -mut -self -mut -set -: -impl -FnMut -( -LookSet -) -- -> -LookSet -) -{ -set -( -self -. -look_have -( -) -) -. -write_repr -( -& -mut -self -. -0 -[ -1 -. -. -] -) -; -} -/ -/ -/ -Mutate -the -set -of -look -- -around -( -both -behind -and -ahead -) -assertions -that -/ -/ -/ -appear -at -least -once -in -this -state -' -s -set -of -NFA -states -. -fn -set_look_need -( -& -mut -self -mut -set -: -impl -FnMut -( -LookSet -) -- -> -LookSet -) -{ -set -( -self -. -look_need -( -) -) -. -write_repr -( -& -mut -self -. -0 -[ -3 -. -. -] -) -; -} -/ -/ -/ -Add -a -pattern -ID -to -this -state -. -All -match -states -must -have -at -least -/ -/ -/ -one -pattern -ID -associated -with -it -. -/ -/ -/ -/ -/ -/ -Callers -must -never -add -duplicative -pattern -IDs -. -/ -/ -/ -/ -/ -/ -The -order -in -which -patterns -are -added -must -correspond -to -the -order -/ -/ -/ -in -which -patterns -are -reported -as -matches -. -fn -add_match_pattern_id -( -& -mut -self -pid -: -PatternID -) -{ -/ -/ -As -a -( -somewhat -small -) -space -saving -optimization -in -the -case -where -/ -/ -a -matching -state -has -exactly -one -pattern -ID -PatternID -: -: -ZERO -we -do -/ -/ -not -write -either -the -pattern -ID -or -the -number -of -patterns -encoded -. -/ -/ -Instead -all -we -do -is -set -the -' -is_match -' -bit -on -this -state -. -Overall -/ -/ -this -saves -8 -bytes -per -match -state -for -the -overwhelming -majority -of -/ -/ -match -states -. -/ -/ -/ -/ -In -order -to -know -whether -pattern -IDs -need -to -be -explicitly -read -or -/ -/ -not -we -use -another -internal -- -only -bit -' -has_pattern_ids -' -to -/ -/ -indicate -whether -they -have -been -explicitly -written -or -not -. -if -! -self -. -repr -( -) -. -has_pattern_ids -( -) -{ -if -pid -= -= -PatternID -: -: -ZERO -{ -self -. -set_is_match -( -) -; -return -; -} -/ -/ -Make -room -for -' -close_match_pattern_ids -' -to -write -the -total -/ -/ -number -of -pattern -IDs -written -. -self -. -0 -. -extend -( -core -: -: -iter -: -: -repeat -( -0 -) -. -take -( -PatternID -: -: -SIZE -) -) -; -self -. -set_has_pattern_ids -( -) -; -/ -/ -If -this -was -already -a -match -state -then -the -only -way -that -' -s -/ -/ -possible -when -the -state -doesn -' -t -have -pattern -IDs -is -if -/ -/ -PatternID -: -: -ZERO -was -added -by -the -caller -previously -. -In -this -/ -/ -case -we -are -now -adding -a -non -- -ZERO -pattern -ID -after -it -in -/ -/ -which -case -we -want -to -make -sure -to -represent -ZERO -explicitly -/ -/ -now -. -if -self -. -repr -( -) -. -is_match -( -) -{ -write_u32 -( -self -. -0 -0 -) -} -else -{ -/ -/ -Otherwise -just -make -sure -the -' -is_match -' -bit -is -set -. -self -. -set_is_match -( -) -; -} -} -write_u32 -( -self -. -0 -pid -. -as_u32 -( -) -) -; -} -/ -/ -/ -Indicate -that -no -more -pattern -IDs -will -be -added -to -this -state -. -/ -/ -/ -/ -/ -/ -Once -this -is -called -callers -must -not -call -it -or -' -add_match_pattern_id -' -/ -/ -/ -again -. -/ -/ -/ -/ -/ -/ -This -should -not -be -exposed -explicitly -outside -of -this -module -. -It -/ -/ -/ -should -be -called -only -when -converting -a -StateBuilderMatches -into -a -/ -/ -/ -StateBuilderNFA -. -fn -close_match_pattern_ids -( -& -mut -self -) -{ -/ -/ -If -we -never -wrote -any -pattern -IDs -then -there -' -s -nothing -to -do -here -. -if -! -self -. -repr -( -) -. -has_pattern_ids -( -) -{ -return -; -} -let -patsize -= -PatternID -: -: -SIZE -; -let -pattern_bytes -= -self -. -0 -. -len -( -) -- -9 -; -/ -/ -Every -pattern -ID -uses -4 -bytes -so -number -of -bytes -should -be -/ -/ -divisible -by -4 -. -assert_eq -! -( -pattern_bytes -% -patsize -0 -) -; -/ -/ -This -unwrap -is -OK -since -we -are -guaranteed -that -the -maximum -number -/ -/ -of -possible -patterns -fits -into -a -u32 -. -let -count32 -= -u32 -: -: -try_from -( -pattern_bytes -/ -patsize -) -. -unwrap -( -) -; -wire -: -: -NE -: -: -write_u32 -( -count32 -& -mut -self -. -0 -[ -5 -. -. -9 -] -) -; -} -/ -/ -/ -Add -an -NFA -state -ID -to -this -state -. -The -order -in -which -NFA -states -are -/ -/ -/ -added -matters -. -It -is -the -caller -' -s -responsibility -to -ensure -that -/ -/ -/ -duplicate -NFA -state -IDs -are -not -added -. -fn -add_nfa_state_id -( -& -mut -self -prev -: -& -mut -StateID -sid -: -StateID -) -{ -let -delta -= -sid -. -as_i32 -( -) -- -prev -. -as_i32 -( -) -; -write_vari32 -( -self -. -0 -delta -) -; -* -prev -= -sid -; -} -/ -/ -/ -Return -a -read -- -only -view -of -this -state -' -s -representation -. -fn -repr -( -& -self -) -- -> -Repr -< -' -_ -> -{ -Repr -( -self -. -0 -. -as_slice -( -) -) -} -} -/ -/ -/ -Write -a -signed -32 -- -bit -integer -using -zig -- -zag -encoding -. -/ -/ -/ -/ -/ -/ -https -: -/ -/ -developers -. -google -. -com -/ -protocol -- -buffers -/ -docs -/ -encoding -# -varints -fn -write_vari32 -( -data -: -& -mut -Vec -< -u8 -> -n -: -i32 -) -{ -let -mut -un -= -n -. -to_bits -( -) -< -< -1 -; -if -n -< -0 -{ -un -= -! -un -; -} -write_varu32 -( -data -un -) -} -/ -/ -/ -Read -a -signed -32 -- -bit -integer -using -zig -- -zag -encoding -. -Also -return -the -/ -/ -/ -number -of -bytes -read -. -/ -/ -/ -/ -/ -/ -https -: -/ -/ -developers -. -google -. -com -/ -protocol -- -buffers -/ -docs -/ -encoding -# -varints -fn -read_vari32 -( -data -: -& -[ -u8 -] -) -- -> -( -i32 -usize -) -{ -let -( -un -i -) -= -read_varu32 -( -data -) -; -let -mut -n -= -i32 -: -: -from_bits -( -un -> -> -1 -) -; -if -un -& -1 -! -= -0 -{ -n -= -! -n -; -} -( -n -i -) -} -/ -/ -/ -Write -an -unsigned -32 -- -bit -integer -as -a -varint -. -In -essence -n -is -written -/ -/ -/ -as -a -sequence -of -bytes -where -all -bytes -except -for -the -last -one -have -the -/ -/ -/ -most -significant -bit -set -. -The -least -significant -7 -bits -correspond -to -the -/ -/ -/ -actual -bits -of -n -. -So -in -the -worst -case -a -varint -uses -5 -bytes -but -in -/ -/ -/ -very -common -cases -it -uses -fewer -than -4 -. -/ -/ -/ -/ -/ -/ -https -: -/ -/ -developers -. -google -. -com -/ -protocol -- -buffers -/ -docs -/ -encoding -# -varints -fn -write_varu32 -( -data -: -& -mut -Vec -< -u8 -> -mut -n -: -u32 -) -{ -while -n -> -= -0b1000_0000 -{ -data -. -push -( -n -. -low_u8 -( -) -| -0b1000_0000 -) -; -n -> -> -= -7 -; -} -data -. -push -( -n -. -low_u8 -( -) -) -; -} -/ -/ -/ -Read -an -unsigned -32 -- -bit -varint -. -Also -return -the -number -of -bytes -read -. -/ -/ -/ -/ -/ -/ -https -: -/ -/ -developers -. -google -. -com -/ -protocol -- -buffers -/ -docs -/ -encoding -# -varints -fn -read_varu32 -( -data -: -& -[ -u8 -] -) -- -> -( -u32 -usize -) -{ -/ -/ -N -. -B -. -We -can -assume -correctness -here -since -we -know -that -all -varuints -are -/ -/ -written -with -write_varu32 -. -Hence -the -' -as -' -uses -and -unchecked -arithmetic -/ -/ -is -all -okay -. -let -mut -n -: -u32 -= -0 -; -let -mut -shift -: -u32 -= -0 -; -for -( -i -& -b -) -in -data -. -iter -( -) -. -enumerate -( -) -{ -if -b -< -0b1000_0000 -{ -return -( -n -| -( -u32 -: -: -from -( -b -) -< -< -shift -) -i -+ -1 -) -; -} -n -| -= -( -u32 -: -: -from -( -b -) -& -0b0111_1111 -) -< -< -shift -; -shift -+ -= -7 -; -} -( -0 -0 -) -} -/ -/ -/ -Push -a -native -- -endian -encoded -n -on -to -dst -. -fn -write_u32 -( -dst -: -& -mut -Vec -< -u8 -> -n -: -u32 -) -{ -use -crate -: -: -util -: -: -wire -: -: -NE -; -let -start -= -dst -. -len -( -) -; -dst -. -extend -( -core -: -: -iter -: -: -repeat -( -0 -) -. -take -( -mem -: -: -size_of -: -: -< -u32 -> -( -) -) -) -; -NE -: -: -write_u32 -( -n -& -mut -dst -[ -start -. -. -] -) -; -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -alloc -: -: -vec -; -use -quickcheck -: -: -quickcheck -; -use -super -: -: -* -; -# -[ -cfg -( -not -( -miri -) -) -] -quickcheck -! -{ -fn -prop_state_read_write_nfa_state_ids -( -sids -: -Vec -< -StateID -> -) -- -> -bool -{ -/ -/ -Builders -states -do -not -permit -duplicate -IDs -. -let -sids -= -dedup_state_ids -( -sids -) -; -let -mut -b -= -StateBuilderEmpty -: -: -new -( -) -. -into_matches -( -) -. -into_nfa -( -) -; -for -& -sid -in -& -sids -{ -b -. -add_nfa_state_id -( -sid -) -; -} -let -s -= -b -. -to_state -( -) -; -let -mut -got -= -vec -! -[ -] -; -s -. -iter_nfa_state_ids -( -| -sid -| -got -. -push -( -sid -) -) -; -got -= -= -sids -} -fn -prop_state_read_write_pattern_ids -( -pids -: -Vec -< -PatternID -> -) -- -> -bool -{ -/ -/ -Builders -states -do -not -permit -duplicate -IDs -. -let -pids -= -dedup_pattern_ids -( -pids -) -; -let -mut -b -= -StateBuilderEmpty -: -: -new -( -) -. -into_matches -( -) -; -for -& -pid -in -& -pids -{ -b -. -add_match_pattern_id -( -pid -) -; -} -let -s -= -b -. -into_nfa -( -) -. -to_state -( -) -; -let -mut -got -= -vec -! -[ -] -; -s -. -iter_match_pattern_ids -( -| -pid -| -got -. -push -( -pid -) -) -; -got -= -= -pids -} -fn -prop_state_read_write_nfa_state_and_pattern_ids -( -sids -: -Vec -< -StateID -> -pids -: -Vec -< -PatternID -> -) -- -> -bool -{ -/ -/ -Builders -states -do -not -permit -duplicate -IDs -. -let -sids -= -dedup_state_ids -( -sids -) -; -let -pids -= -dedup_pattern_ids -( -pids -) -; -let -mut -b -= -StateBuilderEmpty -: -: -new -( -) -. -into_matches -( -) -; -for -& -pid -in -& -pids -{ -b -. -add_match_pattern_id -( -pid -) -; -} -let -mut -b -= -b -. -into_nfa -( -) -; -for -& -sid -in -& -sids -{ -b -. -add_nfa_state_id -( -sid -) -; -} -let -s -= -b -. -to_state -( -) -; -let -mut -got_pids -= -vec -! -[ -] -; -s -. -iter_match_pattern_ids -( -| -pid -| -got_pids -. -push -( -pid -) -) -; -let -mut -got_sids -= -vec -! -[ -] -; -s -. -iter_nfa_state_ids -( -| -sid -| -got_sids -. -push -( -sid -) -) -; -got_pids -= -= -pids -& -& -got_sids -= -= -sids -} -} -quickcheck -! -{ -fn -prop_read_write_varu32 -( -n -: -u32 -) -- -> -bool -{ -let -mut -buf -= -vec -! -[ -] -; -write_varu32 -( -& -mut -buf -n -) -; -let -( -got -nread -) -= -read_varu32 -( -& -buf -) -; -nread -= -= -buf -. -len -( -) -& -& -got -= -= -n -} -fn -prop_read_write_vari32 -( -n -: -i32 -) -- -> -bool -{ -let -mut -buf -= -vec -! -[ -] -; -write_vari32 -( -& -mut -buf -n -) -; -let -( -got -nread -) -= -read_vari32 -( -& -buf -) -; -nread -= -= -buf -. -len -( -) -& -& -got -= -= -n -} -} -# -[ -cfg -( -not -( -miri -) -) -] -fn -dedup_state_ids -( -sids -: -Vec -< -StateID -> -) -- -> -Vec -< -StateID -> -{ -let -mut -set -= -alloc -: -: -collections -: -: -BTreeSet -: -: -new -( -) -; -let -mut -deduped -= -vec -! -[ -] -; -for -sid -in -sids -{ -if -set -. -contains -( -& -sid -) -{ -continue -; -} -set -. -insert -( -sid -) -; -deduped -. -push -( -sid -) -; -} -deduped -} -# -[ -cfg -( -not -( -miri -) -) -] -fn -dedup_pattern_ids -( -pids -: -Vec -< -PatternID -> -) -- -> -Vec -< -PatternID -> -{ -let -mut -set -= -alloc -: -: -collections -: -: -BTreeSet -: -: -new -( -) -; -let -mut -deduped -= -vec -! -[ -] -; -for -pid -in -pids -{ -if -set -. -contains -( -& -pid -) -{ -continue -; -} -set -. -insert -( -pid -) -; -deduped -. -push -( -pid -) -; -} -deduped -} -} diff --git a/third_party/rust/regex-automata/src/util/empty.rs b/third_party/rust/regex-automata/src/util/empty.rs deleted file mode 100644 index 11f6c308e7519..0000000000000 --- a/third_party/rust/regex-automata/src/util/empty.rs +++ /dev/null @@ -1,3001 +0,0 @@ -/ -* -! -This -module -provides -helper -routines -for -dealing -with -zero -- -width -matches -. -The -main -problem -being -solved -here -is -this -: -1 -. -The -caller -wants -to -search -something -that -they -know -is -valid -UTF -- -8 -such -as -a -Rust -& -str -. -2 -. -The -regex -used -by -the -caller -can -match -the -empty -string -. -For -example -a -* -. -3 -. -The -caller -should -never -get -match -offsets -returned -that -occur -within -the -encoding -of -a -UTF -- -8 -codepoint -. -It -is -logically -incorrect -and -also -means -that -e -. -g -. -slicing -the -& -str -at -those -offsets -will -lead -to -a -panic -. -So -the -question -here -is -how -do -we -prevent -the -caller -from -getting -match -offsets -that -split -a -codepoint -? -For -example -strictly -speaking -the -regex -a -* -matches -at -the -positions -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -and -[ -3 -3 -] -since -the -UTF -- -8 -encoding -of -is -\ -xE2 -\ -x98 -\ -x83 -. -In -particular -the -NFA -that -underlies -all -of -the -matching -engines -in -this -crate -doesn -' -t -have -anything -in -its -state -graph -that -prevents -matching -between -UTF -- -8 -code -units -. -Indeed -any -engine -derived -from -the -NFA -will -match -at -those -positions -by -virtue -of -the -fact -that -the -NFA -is -byte -oriented -. -That -is -its -transitions -are -defined -over -bytes -and -the -matching -engines -work -by -proceeding -one -byte -at -a -time -. -( -An -alternative -architecture -would -be -to -define -the -transitions -in -an -NFA -over -codepoints -or -char -. -And -then -make -the -matching -engines -proceed -by -decoding -one -codepoint -at -a -time -. -This -is -a -viable -strategy -but -it -doesn -' -t -work -for -DFA -matching -engines -because -designing -a -fast -and -memory -efficient -transition -table -for -an -alphabet -as -large -as -Unicode -is -quite -difficult -. -More -to -the -point -the -top -- -level -regex -crate -supports -matching -on -arbitrary -bytes -when -Unicode -mode -is -disabled -and -one -is -searching -a -& -[ -u8 -] -. -So -in -that -case -you -can -' -t -just -limit -yourself -to -decoding -codepoints -and -matching -those -. -You -really -do -need -to -be -able -to -follow -byte -oriented -transitions -on -the -NFA -. -) -In -an -older -version -of -the -regex -crate -we -handled -this -case -not -in -the -regex -engine -but -in -the -iterators -over -matches -. -Namely -since -this -case -only -arises -when -the -match -is -empty -we -" -just -" -incremented -the -next -starting -position -of -the -search -by -N -where -N -is -the -length -of -the -codepoint -encoded -at -the -current -position -. -The -alternative -or -more -" -natural -" -solution -of -just -incrementing -by -1 -would -result -in -executing -a -search -of -a -* -on -like -this -: -* -Start -search -at -0 -. -* -Found -match -at -[ -0 -0 -] -. -* -Next -start -position -is -0 -. -* -To -avoid -an -infinite -loop -since -it -' -s -an -empty -match -increment -by -1 -. -* -Start -search -at -1 -. -* -Found -match -at -[ -1 -1 -] -. -Oops -. -But -if -we -instead -incremented -by -3 -( -the -length -in -bytes -of -) -then -we -get -the -following -: -* -Start -search -at -0 -. -* -Found -match -at -[ -0 -0 -] -. -* -Next -start -position -is -0 -. -* -To -avoid -an -infinite -loop -since -it -' -s -an -empty -match -increment -by -3 -. -* -Start -search -at -3 -. -* -Found -match -at -[ -3 -3 -] -. -And -we -get -the -correct -result -. -But -does -this -technique -work -in -all -cases -? -Crucially -it -requires -that -a -zero -- -width -match -that -splits -a -codepoint -never -occurs -beyond -the -starting -position -of -the -search -. -Because -if -it -did -merely -incrementing -the -start -position -by -the -number -of -bytes -in -the -codepoint -at -the -current -position -wouldn -' -t -be -enough -. -A -zero -- -width -match -could -just -occur -anywhere -. -It -turns -out -that -it -is -_almost_ -true -. -We -can -convince -ourselves -by -looking -at -all -possible -patterns -that -can -match -the -empty -string -: -* -Patterns -like -a -* -a -{ -0 -} -( -? -: -) -a -| -and -| -a -all -unconditionally -match -the -empty -string -. -That -is -assuming -there -isn -' -t -an -a -at -the -current -position -they -will -all -match -the -empty -string -at -the -start -of -a -search -. -There -is -no -way -to -move -past -it -because -any -other -match -would -not -be -" -leftmost -. -" -* -^ -only -matches -at -the -beginning -of -the -haystack -where -the -start -position -is -0 -. -Since -we -know -we -' -re -searching -valid -UTF -- -8 -( -if -it -isn -' -t -valid -UTF -- -8 -then -this -entire -problem -goes -away -because -it -implies -your -string -type -supports -invalid -UTF -- -8 -and -thus -must -deal -with -offsets -that -not -only -split -a -codepoint -but -occur -in -entirely -invalid -UTF -- -8 -somehow -) -it -follows -that -^ -never -matches -between -the -code -units -of -a -codepoint -because -the -start -of -a -valid -UTF -- -8 -string -is -never -within -the -encoding -of -a -codepoint -. -* -basically -the -same -logic -as -^ -but -for -the -end -of -a -string -. -A -valid -UTF -- -8 -string -can -' -t -have -an -incomplete -codepoint -at -the -end -of -it -. -* -( -? -m -: -^ -) -follows -similarly -to -^ -but -it -can -match -immediately -following -a -\ -n -. -However -since -a -\ -n -is -always -a -codepoint -itself -and -can -never -appear -within -a -codepoint -it -follows -that -the -position -immediately -following -a -\ -n -in -a -string -that -is -valid -UTF -- -8 -is -guaranteed -to -not -be -between -the -code -units -of -another -codepoint -. -( -One -caveat -here -is -that -the -line -terminator -for -multi -- -line -anchors -can -now -be -changed -to -any -arbitrary -byte -including -things -like -\ -x98 -which -might -occur -within -a -codepoint -. -However -this -wasn -' -t -supported -by -the -old -regex -crate -. -If -it -was -it -pose -the -same -problems -as -( -? -- -u -: -\ -B -) -as -we -' -ll -discuss -below -. -) -* -( -? -m -: -) -a -similar -argument -as -for -( -? -m -: -^ -) -. -The -only -difference -is -that -a -( -? -m -: -) -matches -just -before -a -\ -n -. -But -the -same -argument -applies -. -* -( -? -Rm -: -^ -) -and -( -? -Rm -: -) -weren -' -t -supported -by -the -old -regex -crate -but -the -CRLF -aware -line -anchors -follow -a -similar -argument -as -for -( -? -m -: -^ -) -and -( -? -m -: -) -. -Namely -since -they -only -ever -match -at -a -boundary -where -one -side -is -either -a -\ -r -or -a -\ -n -neither -of -which -can -occur -within -a -codepoint -. -* -\ -b -only -matches -at -positions -where -both -sides -are -valid -codepoints -so -this -cannot -split -a -codepoint -. -* -\ -B -like -\ -b -also -only -matches -at -positions -where -both -sides -are -valid -codepoints -. -So -this -cannot -split -a -codepoint -either -. -* -( -? -- -u -: -\ -b -) -matches -only -at -positions -where -at -least -one -side -of -it -is -an -ASCII -word -byte -. -Since -ASCII -bytes -cannot -appear -as -code -units -in -non -- -ASCII -codepoints -( -one -of -the -many -amazing -qualities -of -UTF -- -8 -) -it -follows -that -this -too -cannot -split -a -codepoint -. -* -( -? -- -u -: -\ -B -) -finally -represents -a -problem -. -It -can -matches -between -* -any -* -two -bytes -that -are -either -both -word -bytes -or -non -- -word -bytes -. -Since -code -units -like -\ -xE2 -and -\ -x98 -( -from -the -UTF -- -8 -encoding -of -) -are -both -non -- -word -bytes -( -? -- -u -: -\ -B -) -will -match -at -the -position -between -them -. -Thus -our -approach -of -incrementing -one -codepoint -at -a -time -after -seeing -an -empty -match -is -flawed -because -( -? -- -u -: -\ -B -) -can -result -in -an -empty -match -that -splits -a -codepoint -at -a -position -past -the -starting -point -of -a -search -. -For -example -searching -( -? -- -u -: -\ -B -) -on -a -would -produce -the -following -matches -: -[ -2 -2 -] -[ -3 -3 -] -and -[ -4 -4 -] -. -The -positions -at -0 -and -1 -don -' -t -match -because -they -correspond -to -word -boundaries -since -a -is -an -ASCII -word -byte -. -So -what -did -the -old -regex -crate -do -to -avoid -this -? -It -banned -( -? -- -u -: -\ -B -) -from -regexes -that -could -match -& -str -. -That -might -sound -extreme -but -a -lot -of -other -things -were -banned -too -. -For -example -all -of -( -? -- -u -: -. -) -( -? -- -u -: -[ -^ -a -] -) -and -( -? -- -u -: -\ -W -) -can -match -invalid -UTF -- -8 -too -including -individual -code -units -with -a -codepoint -. -The -key -difference -is -that -those -expressions -could -never -produce -an -empty -match -. -That -ban -happens -when -translating -an -Ast -to -an -Hir -because -that -process -that -reason -about -whether -an -Hir -can -produce -* -non -- -empty -* -matches -at -invalid -UTF -- -8 -boundaries -. -Bottom -line -though -is -that -we -side -- -stepped -the -( -? -- -u -: -\ -B -) -issue -by -banning -it -. -If -banning -( -? -- -u -: -\ -B -) -were -the -only -issue -with -the -old -regex -crate -' -s -approach -then -I -probably -would -have -kept -it -. -\ -B -is -rarely -used -so -it -' -s -not -such -a -big -deal -to -have -to -work -- -around -it -. -However -the -problem -with -the -above -approach -is -that -it -doesn -' -t -compose -. -The -logic -for -avoiding -splitting -a -codepoint -only -lived -in -the -iterator -which -means -if -anyone -wants -to -implement -their -own -iterator -over -regex -matches -they -have -to -deal -with -this -extremely -subtle -edge -case -to -get -full -correctness -. -Instead -in -this -crate -we -take -the -approach -of -pushing -this -complexity -down -to -the -lowest -layers -of -each -regex -engine -. -The -approach -is -pretty -simple -: -* -If -this -corner -case -doesn -' -t -apply -don -' -t -do -anything -. -( -For -example -if -UTF -- -8 -mode -isn -' -t -enabled -or -if -the -regex -cannot -match -the -empty -string -. -) -* -If -an -empty -match -is -reported -explicitly -check -if -it -splits -a -codepoint -. -* -If -it -doesn -' -t -we -' -re -done -return -the -match -. -* -If -it -does -then -ignore -the -match -and -re -- -run -the -search -. -* -Repeat -the -above -process -until -the -end -of -the -haystack -is -reached -or -a -match -is -found -that -doesn -' -t -split -a -codepoint -or -isn -' -t -zero -width -. -And -that -' -s -pretty -much -what -this -module -provides -. -Every -regex -engine -uses -these -methods -in -their -lowest -level -public -APIs -but -just -above -the -layer -where -their -internal -engine -is -used -. -That -way -all -regex -engines -can -be -arbitrarily -composed -without -worrying -about -handling -this -case -and -iterators -don -' -t -need -to -handle -it -explicitly -. -( -It -turns -out -that -a -new -feature -I -added -support -for -changing -the -line -terminator -in -a -regex -to -any -arbitrary -byte -also -provokes -the -above -problem -. -Namely -the -byte -could -be -invalid -UTF -- -8 -or -a -UTF -- -8 -continuation -byte -. -So -that -support -would -need -to -be -limited -or -banned -when -UTF -- -8 -mode -is -enabled -just -like -we -did -for -( -? -- -u -: -\ -B -) -. -But -thankfully -our -more -robust -approach -in -this -crate -handles -that -case -just -fine -too -. -) -* -/ -use -crate -: -: -util -: -: -search -: -: -{ -Input -MatchError -} -; -# -[ -cold -] -# -[ -inline -( -never -) -] -pub -( -crate -) -fn -skip_splits_fwd -< -T -F -> -( -input -: -& -Input -< -' -_ -> -init_value -: -T -match_offset -: -usize -find -: -F -) -- -> -Result -< -Option -< -T -> -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -( -T -usize -) -> -MatchError -> -{ -skip_splits -( -true -input -init_value -match_offset -find -) -} -# -[ -cold -] -# -[ -inline -( -never -) -] -pub -( -crate -) -fn -skip_splits_rev -< -T -F -> -( -input -: -& -Input -< -' -_ -> -init_value -: -T -match_offset -: -usize -find -: -F -) -- -> -Result -< -Option -< -T -> -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -( -T -usize -) -> -MatchError -> -{ -skip_splits -( -false -input -init_value -match_offset -find -) -} -fn -skip_splits -< -T -F -> -( -forward -: -bool -input -: -& -Input -< -' -_ -> -init_value -: -T -mut -match_offset -: -usize -mut -find -: -F -) -- -> -Result -< -Option -< -T -> -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -( -T -usize -) -> -MatchError -> -{ -/ -/ -If -our -config -says -to -do -an -anchored -search -then -we -' -re -definitely -/ -/ -done -. -We -just -need -to -determine -whether -we -have -a -valid -match -or -/ -/ -not -. -If -we -don -' -t -then -we -' -re -not -allowed -to -continue -so -we -report -/ -/ -no -match -. -/ -/ -/ -/ -This -is -actually -quite -a -subtle -correctness -thing -. -The -key -here -is -/ -/ -that -if -we -got -an -empty -match -that -splits -a -codepoint -after -doing -an -/ -/ -anchored -search -in -UTF -- -8 -mode -then -that -implies -that -we -must -have -/ -/ -* -started -* -the -search -at -a -location -that -splits -a -codepoint -. -This -/ -/ -follows -from -the -fact -that -if -a -match -is -reported -from -an -anchored -/ -/ -search -then -the -start -offset -of -the -match -* -must -* -match -the -start -/ -/ -offset -of -the -search -. -/ -/ -/ -/ -It -also -follows -that -no -other -non -- -empty -match -is -possible -. -For -/ -/ -example -you -might -write -a -regex -like -' -( -? -: -) -| -SOMETHING -' -and -start -its -/ -/ -search -in -the -middle -of -a -codepoint -. -The -first -branch -is -an -empty -/ -/ -regex -that -will -bubble -up -a -match -at -the -first -position -and -then -/ -/ -get -rejected -here -and -report -no -match -. -But -what -if -' -SOMETHING -' -could -/ -/ -have -matched -? -We -reason -that -such -a -thing -is -impossible -because -/ -/ -if -it -does -it -must -report -a -match -that -starts -in -the -middle -of -a -/ -/ -codepoint -. -This -in -turn -implies -that -a -match -is -reported -whose -span -/ -/ -does -not -correspond -to -valid -UTF -- -8 -and -this -breaks -the -promise -/ -/ -made -when -UTF -- -8 -mode -is -enabled -. -( -That -promise -* -can -* -be -broken -for -/ -/ -example -by -enabling -UTF -- -8 -mode -but -building -an -by -hand -NFA -that -/ -/ -produces -non -- -empty -matches -that -span -invalid -UTF -- -8 -. -This -is -an -unchecked -/ -/ -but -documented -precondition -violation -of -UTF -- -8 -mode -and -is -documented -/ -/ -to -have -unspecified -behavior -. -) -/ -/ -/ -/ -I -believe -this -actually -means -that -if -an -anchored -search -is -run -and -/ -/ -UTF -- -8 -mode -is -enabled -and -the -start -position -splits -a -codepoint -/ -/ -then -it -is -correct -to -immediately -report -no -match -without -even -/ -/ -executing -the -regex -engine -. -But -it -doesn -' -t -really -seem -worth -writing -/ -/ -out -that -case -in -every -regex -engine -to -save -a -tiny -bit -of -work -in -an -/ -/ -extremely -pathological -case -so -we -just -handle -it -here -. -if -input -. -get_anchored -( -) -. -is_anchored -( -) -{ -return -Ok -( -if -input -. -is_char_boundary -( -match_offset -) -{ -Some -( -init_value -) -} -else -{ -None -} -) -; -} -/ -/ -Otherwise -we -have -an -unanchored -search -so -just -keep -looking -for -/ -/ -matches -until -we -have -one -that -does -not -split -a -codepoint -or -we -hit -/ -/ -EOI -. -let -mut -value -= -init_value -; -let -mut -input -= -input -. -clone -( -) -; -while -! -input -. -is_char_boundary -( -match_offset -) -{ -if -forward -{ -/ -/ -The -unwrap -is -OK -here -because -overflowing -usize -while -/ -/ -iterating -over -a -slice -is -impossible -at -it -would -require -/ -/ -a -slice -of -length -greater -than -isize -: -: -MAX -which -is -itself -/ -/ -impossible -. -input -. -set_start -( -input -. -start -( -) -. -checked_add -( -1 -) -. -unwrap -( -) -) -; -} -else -{ -input -. -set_end -( -match -input -. -end -( -) -. -checked_sub -( -1 -) -{ -None -= -> -return -Ok -( -None -) -Some -( -end -) -= -> -end -} -) -; -} -match -find -( -& -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -( -new_value -new_match_end -) -) -= -> -{ -value -= -new_value -; -match_offset -= -new_match_end -; -} -} -} -Ok -( -Some -( -value -) -) -} diff --git a/third_party/rust/regex-automata/src/util/escape.rs b/third_party/rust/regex-automata/src/util/escape.rs deleted file mode 100644 index d91060de07621..0000000000000 --- a/third_party/rust/regex-automata/src/util/escape.rs +++ /dev/null @@ -1,797 +0,0 @@ -/ -* -! -Provides -convenience -routines -for -escaping -raw -bytes -. -Since -this -crate -tends -to -deal -with -& -[ -u8 -] -everywhere -and -the -default -Debug -implementation -just -shows -decimal -integers -it -makes -debugging -those -representations -quite -difficult -. -This -module -provides -types -that -show -& -[ -u8 -] -as -if -it -were -a -string -with -invalid -UTF -- -8 -escaped -into -its -byte -- -by -- -byte -hex -representation -. -* -/ -use -crate -: -: -util -: -: -utf8 -; -/ -/ -/ -Provides -a -convenient -Debug -implementation -for -a -u8 -. -/ -/ -/ -/ -/ -/ -The -Debug -impl -treats -the -byte -as -an -ASCII -and -emits -a -human -readable -/ -/ -/ -representation -of -it -. -If -the -byte -isn -' -t -ASCII -then -it -' -s -emitted -as -a -hex -/ -/ -/ -escape -sequence -. -# -[ -derive -( -Clone -Copy -) -] -pub -struct -DebugByte -( -pub -u8 -) -; -impl -core -: -: -fmt -: -: -Debug -for -DebugByte -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -/ -/ -Special -case -ASCII -space -. -It -' -s -too -hard -to -read -otherwise -so -/ -/ -put -quotes -around -it -. -I -sometimes -wonder -whether -just -' -\ -x20 -' -would -/ -/ -be -better -. -. -. -if -self -. -0 -= -= -b -' -' -{ -return -write -! -( -f -" -' -' -" -) -; -} -/ -/ -10 -bytes -is -enough -to -cover -any -output -from -ascii -: -: -escape_default -. -let -mut -bytes -= -[ -0u8 -; -10 -] -; -let -mut -len -= -0 -; -for -( -i -mut -b -) -in -core -: -: -ascii -: -: -escape_default -( -self -. -0 -) -. -enumerate -( -) -{ -/ -/ -capitalize -\ -xab -to -\ -xAB -if -i -> -= -2 -& -& -b -' -a -' -< -= -b -& -& -b -< -= -b -' -f -' -{ -b -- -= -32 -; -} -bytes -[ -len -] -= -b -; -len -+ -= -1 -; -} -write -! -( -f -" -{ -} -" -core -: -: -str -: -: -from_utf8 -( -& -bytes -[ -. -. -len -] -) -. -unwrap -( -) -) -} -} -/ -/ -/ -Provides -a -convenient -Debug -implementation -for -& -[ -u8 -] -. -/ -/ -/ -/ -/ -/ -This -generally -works -best -when -the -bytes -are -presumed -to -be -mostly -UTF -- -8 -/ -/ -/ -but -will -work -for -anything -. -For -any -bytes -that -aren -' -t -UTF -- -8 -they -are -/ -/ -/ -emitted -as -hex -escape -sequences -. -pub -struct -DebugHaystack -< -' -a -> -( -pub -& -' -a -[ -u8 -] -) -; -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -DebugHaystack -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -\ -" -" -) -? -; -/ -/ -This -is -a -sad -re -- -implementation -of -a -similar -impl -found -in -bstr -. -let -mut -bytes -= -self -. -0 -; -while -let -Some -( -result -) -= -utf8 -: -: -decode -( -bytes -) -{ -let -ch -= -match -result -{ -Ok -( -ch -) -= -> -ch -Err -( -byte -) -= -> -{ -write -! -( -f -r -" -\ -x -{ -: -02x -} -" -byte -) -? -; -bytes -= -& -bytes -[ -1 -. -. -] -; -continue -; -} -} -; -bytes -= -& -bytes -[ -ch -. -len_utf8 -( -) -. -. -] -; -match -ch -{ -' -\ -0 -' -= -> -write -! -( -f -" -\ -\ -0 -" -) -? -/ -/ -ASCII -control -characters -except -\ -0 -\ -n -\ -r -\ -t -' -\ -x01 -' -. -. -= -' -\ -x08 -' -| -' -\ -x0b -' -| -' -\ -x0c -' -| -' -\ -x0e -' -. -. -= -' -\ -x19 -' -| -' -\ -x7f -' -= -> -{ -write -! -( -f -" -\ -\ -x -{ -: -02x -} -" -u32 -: -: -from -( -ch -) -) -? -; -} -' -\ -n -' -| -' -\ -r -' -| -' -\ -t -' -| -_ -= -> -{ -write -! -( -f -" -{ -} -" -ch -. -escape_debug -( -) -) -? -; -} -} -} -write -! -( -f -" -\ -" -" -) -? -; -Ok -( -( -) -) -} -} diff --git a/third_party/rust/regex-automata/src/util/int.rs b/third_party/rust/regex-automata/src/util/int.rs deleted file mode 100644 index 51e694cc27115..0000000000000 --- a/third_party/rust/regex-automata/src/util/int.rs +++ /dev/null @@ -1,1494 +0,0 @@ -/ -* -! -This -module -provides -several -integer -oriented -traits -for -converting -between -both -fixed -size -integers -and -integers -whose -size -varies -based -on -the -target -( -like -usize -) -. -The -driving -design -principle -of -this -module -is -to -attempt -to -centralize -as -many -as -casts -as -possible -here -. -And -in -particular -we -separate -casts -into -two -buckets -: -* -Casts -that -we -use -for -their -truncating -behavior -. -In -this -case -we -use -more -descriptive -names -like -low_u32 -and -high_u32 -. -* -Casts -that -we -use -for -converting -back -- -and -- -forth -between -usize -. -These -conversions -are -generally -necessary -because -we -often -store -indices -in -different -formats -to -save -on -memory -which -requires -converting -to -and -from -usize -. -In -this -case -we -very -specifically -do -not -want -to -overflow -and -so -the -methods -defined -here -will -panic -if -the -as -cast -would -be -lossy -in -debug -mode -. -( -A -normal -as -cast -will -never -panic -! -) -For -as -casts -between -raw -pointers -we -use -cast -so -as -isn -' -t -needed -there -. -For -regex -engines -floating -point -is -just -never -used -so -we -don -' -t -have -to -worry -about -as -casts -for -those -. -Otherwise -this -module -pretty -much -covers -all -of -our -as -needs -except -for -one -thing -: -const -contexts -. -There -are -a -select -few -places -in -this -crate -where -we -still -need -to -use -as -because -const -functions -on -traits -aren -' -t -stable -yet -. -If -we -wind -up -significantly -expanding -our -const -footprint -in -this -crate -it -might -be -worth -defining -free -functions -to -handle -those -cases -. -But -at -the -time -of -writing -that -just -seemed -like -too -much -ceremony -. -Instead -I -comment -each -such -use -of -as -in -a -const -context -with -a -" -fixme -" -notice -. -NOTE -: -for -simplicity -we -don -' -t -take -target -pointer -width -into -account -here -for -usize -conversions -. -Since -we -currently -only -panic -in -debug -mode -skipping -the -check -when -it -can -be -proven -it -isn -' -t -needed -at -compile -time -doesn -' -t -really -matter -. -Now -if -we -wind -up -wanting -to -do -as -many -checks -as -possible -in -release -mode -then -we -would -want -to -skip -those -when -we -know -the -conversions -are -always -non -- -lossy -. -NOTE -: -this -module -isn -' -t -an -exhaustive -API -. -For -example -we -still -use -things -like -u64 -: -: -from -where -possible -or -even -usize -: -: -try_from -( -) -for -when -we -do -explicitly -want -to -panic -or -when -we -want -to -return -an -error -for -overflow -. -* -/ -pub -( -crate -) -trait -U8 -{ -fn -as_usize -( -self -) -- -> -usize -; -} -impl -U8 -for -u8 -{ -fn -as_usize -( -self -) -- -> -usize -{ -usize -: -: -from -( -self -) -} -} -pub -( -crate -) -trait -U16 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -low_u8 -( -self -) -- -> -u8 -; -fn -high_u8 -( -self -) -- -> -u8 -; -} -impl -U16 -for -u16 -{ -fn -as_usize -( -self -) -- -> -usize -{ -usize -: -: -from -( -self -) -} -fn -low_u8 -( -self -) -- -> -u8 -{ -self -as -u8 -} -fn -high_u8 -( -self -) -- -> -u8 -{ -( -self -> -> -8 -) -as -u8 -} -} -pub -( -crate -) -trait -U32 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -low_u8 -( -self -) -- -> -u8 -; -fn -low_u16 -( -self -) -- -> -u16 -; -fn -high_u16 -( -self -) -- -> -u16 -; -} -impl -U32 -for -u32 -{ -fn -as_usize -( -self -) -- -> -usize -{ -# -[ -cfg -( -debug_assertions -) -] -{ -usize -: -: -try_from -( -self -) -. -expect -( -" -u32 -overflowed -usize -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -usize -} -} -fn -low_u8 -( -self -) -- -> -u8 -{ -self -as -u8 -} -fn -low_u16 -( -self -) -- -> -u16 -{ -self -as -u16 -} -fn -high_u16 -( -self -) -- -> -u16 -{ -( -self -> -> -16 -) -as -u16 -} -} -pub -( -crate -) -trait -U64 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -low_u8 -( -self -) -- -> -u8 -; -fn -low_u16 -( -self -) -- -> -u16 -; -fn -low_u32 -( -self -) -- -> -u32 -; -fn -high_u32 -( -self -) -- -> -u32 -; -} -impl -U64 -for -u64 -{ -fn -as_usize -( -self -) -- -> -usize -{ -# -[ -cfg -( -debug_assertions -) -] -{ -usize -: -: -try_from -( -self -) -. -expect -( -" -u64 -overflowed -usize -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -usize -} -} -fn -low_u8 -( -self -) -- -> -u8 -{ -self -as -u8 -} -fn -low_u16 -( -self -) -- -> -u16 -{ -self -as -u16 -} -fn -low_u32 -( -self -) -- -> -u32 -{ -self -as -u32 -} -fn -high_u32 -( -self -) -- -> -u32 -{ -( -self -> -> -32 -) -as -u32 -} -} -pub -( -crate -) -trait -I32 -{ -fn -as_usize -( -self -) -- -> -usize -; -fn -to_bits -( -self -) -- -> -u32 -; -fn -from_bits -( -n -: -u32 -) -- -> -i32 -; -} -impl -I32 -for -i32 -{ -fn -as_usize -( -self -) -- -> -usize -{ -# -[ -cfg -( -debug_assertions -) -] -{ -usize -: -: -try_from -( -self -) -. -expect -( -" -i32 -overflowed -usize -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -usize -} -} -fn -to_bits -( -self -) -- -> -u32 -{ -self -as -u32 -} -fn -from_bits -( -n -: -u32 -) -- -> -i32 -{ -n -as -i32 -} -} -pub -( -crate -) -trait -Usize -{ -fn -as_u8 -( -self -) -- -> -u8 -; -fn -as_u16 -( -self -) -- -> -u16 -; -fn -as_u32 -( -self -) -- -> -u32 -; -fn -as_u64 -( -self -) -- -> -u64 -; -} -impl -Usize -for -usize -{ -fn -as_u8 -( -self -) -- -> -u8 -{ -# -[ -cfg -( -debug_assertions -) -] -{ -u8 -: -: -try_from -( -self -) -. -expect -( -" -usize -overflowed -u8 -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -u8 -} -} -fn -as_u16 -( -self -) -- -> -u16 -{ -# -[ -cfg -( -debug_assertions -) -] -{ -u16 -: -: -try_from -( -self -) -. -expect -( -" -usize -overflowed -u16 -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -u16 -} -} -fn -as_u32 -( -self -) -- -> -u32 -{ -# -[ -cfg -( -debug_assertions -) -] -{ -u32 -: -: -try_from -( -self -) -. -expect -( -" -usize -overflowed -u32 -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -u32 -} -} -fn -as_u64 -( -self -) -- -> -u64 -{ -# -[ -cfg -( -debug_assertions -) -] -{ -u64 -: -: -try_from -( -self -) -. -expect -( -" -usize -overflowed -u64 -" -) -} -# -[ -cfg -( -not -( -debug_assertions -) -) -] -{ -self -as -u64 -} -} -} -/ -/ -Pointers -aren -' -t -integers -but -we -convert -pointers -to -integers -to -perform -/ -/ -offset -arithmetic -in -some -places -. -( -And -no -we -don -' -t -convert -the -integers -/ -/ -back -to -pointers -. -) -So -add -' -as_usize -' -conversions -here -too -for -completeness -. -/ -/ -/ -/ -These -' -as -' -casts -are -actually -okay -because -they -' -re -always -non -- -lossy -. -But -the -/ -/ -idea -here -is -to -just -try -and -remove -as -much -' -as -' -as -possible -particularly -/ -/ -in -this -crate -where -we -are -being -really -paranoid -about -offsets -and -making -/ -/ -sure -we -don -' -t -panic -on -inputs -that -might -be -untrusted -. -This -way -the -' -as -' -/ -/ -casts -become -easier -to -audit -if -they -' -re -all -in -one -place -even -when -some -of -/ -/ -them -are -actually -okay -100 -% -of -the -time -. -pub -( -crate -) -trait -Pointer -{ -fn -as_usize -( -self -) -- -> -usize -; -} -impl -< -T -> -Pointer -for -* -const -T -{ -fn -as_usize -( -self -) -- -> -usize -{ -self -as -usize -} -} -pub -( -crate -) -trait -PointerMut -{ -fn -as_usize -( -self -) -- -> -usize -; -} -impl -< -T -> -PointerMut -for -* -mut -T -{ -fn -as_usize -( -self -) -- -> -usize -{ -self -as -usize -} -} diff --git a/third_party/rust/regex-automata/src/util/interpolate.rs b/third_party/rust/regex-automata/src/util/interpolate.rs deleted file mode 100644 index c9b57f4704944..0000000000000 --- a/third_party/rust/regex-automata/src/util/interpolate.rs +++ /dev/null @@ -1,4331 +0,0 @@ -/ -* -! -Provides -routines -for -interpolating -capture -group -references -. -That -is -if -a -replacement -string -contains -references -like -foo -or -{ -foo1 -} -then -they -are -replaced -with -the -corresponding -capture -values -for -the -groups -named -foo -and -foo1 -respectively -. -Similarly -syntax -like -1 -and -{ -1 -} -is -supported -as -well -with -1 -corresponding -to -a -capture -group -index -and -not -a -name -. -This -module -provides -the -free -functions -[ -string -] -and -[ -bytes -] -which -interpolate -Rust -Unicode -strings -and -byte -strings -respectively -. -# -Format -These -routines -support -two -different -kinds -of -capture -references -: -unbraced -and -braced -. -For -the -unbraced -format -the -format -supported -is -ref -where -name -can -be -any -character -in -the -class -[ -0 -- -9A -- -Za -- -z_ -] -. -ref -is -always -the -longest -possible -parse -. -So -for -example -1a -corresponds -to -the -capture -group -named -1a -and -not -the -capture -group -at -index -1 -. -If -ref -matches -^ -[ -0 -- -9 -] -+ -then -it -is -treated -as -a -capture -group -index -itself -and -not -a -name -. -For -the -braced -format -the -format -supported -is -{ -ref -} -where -ref -can -be -any -sequence -of -bytes -except -for -} -. -If -no -closing -brace -occurs -then -it -is -not -considered -a -capture -reference -. -As -with -the -unbraced -format -if -ref -matches -^ -[ -0 -- -9 -] -+ -then -it -is -treated -as -a -capture -group -index -and -not -a -name -. -The -braced -format -is -useful -for -exerting -precise -control -over -the -name -of -the -capture -reference -. -For -example -{ -1 -} -a -corresponds -to -the -capture -group -reference -1 -followed -by -the -letter -a -where -as -1a -( -as -mentioned -above -) -corresponds -to -the -capture -group -reference -1a -. -The -braced -format -is -also -useful -for -expressing -capture -group -names -that -use -characters -not -supported -by -the -unbraced -format -. -For -example -{ -foo -[ -bar -] -. -baz -} -refers -to -the -capture -group -named -foo -[ -bar -] -. -baz -. -If -a -capture -group -reference -is -found -and -it -does -not -refer -to -a -valid -capture -group -then -it -will -be -replaced -with -the -empty -string -. -To -write -a -literal -use -. -To -be -clear -and -as -exhibited -via -the -type -signatures -in -the -routines -in -this -module -it -is -impossible -for -a -replacement -string -to -be -invalid -. -A -replacement -string -may -not -have -the -intended -semantics -but -the -interpolation -procedure -itself -can -never -fail -. -* -/ -use -alloc -: -: -{ -string -: -: -String -vec -: -: -Vec -} -; -use -crate -: -: -util -: -: -memchr -: -: -memchr -; -/ -/ -/ -Accepts -a -replacement -string -and -interpolates -capture -references -with -their -/ -/ -/ -corresponding -values -. -/ -/ -/ -/ -/ -/ -append -should -be -a -function -that -appends -the -string -value -of -a -capture -/ -/ -/ -group -at -a -particular -index -to -the -string -given -. -If -the -capture -group -/ -/ -/ -index -is -invalid -then -nothing -should -be -appended -. -/ -/ -/ -/ -/ -/ -name_to_index -should -be -a -function -that -maps -a -capture -group -name -to -a -/ -/ -/ -capture -group -index -. -If -the -given -name -doesn -' -t -exist -then -None -should -/ -/ -/ -be -returned -. -/ -/ -/ -/ -/ -/ -Finally -dst -is -where -the -final -interpolated -contents -should -be -written -. -/ -/ -/ -If -replacement -contains -no -capture -group -references -then -dst -will -be -/ -/ -/ -equivalent -to -replacement -. -/ -/ -/ -/ -/ -/ -See -the -[ -module -documentation -] -( -self -) -for -details -about -the -format -/ -/ -/ -supported -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -interpolate -; -/ -/ -/ -/ -/ -/ -let -mut -dst -= -String -: -: -new -( -) -; -/ -/ -/ -interpolate -: -: -string -( -/ -/ -/ -" -foo -bar -baz -" -/ -/ -/ -| -index -dst -| -{ -/ -/ -/ -if -index -= -= -0 -{ -/ -/ -/ -dst -. -push_str -( -" -BAR -" -) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -| -name -| -{ -/ -/ -/ -if -name -= -= -" -bar -" -{ -/ -/ -/ -Some -( -0 -) -/ -/ -/ -} -else -{ -/ -/ -/ -None -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -& -mut -dst -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -" -foo -BAR -baz -" -dst -) -; -/ -/ -/ -pub -fn -string -( -mut -replacement -: -& -str -mut -append -: -impl -FnMut -( -usize -& -mut -String -) -mut -name_to_index -: -impl -FnMut -( -& -str -) -- -> -Option -< -usize -> -dst -: -& -mut -String -) -{ -while -! -replacement -. -is_empty -( -) -{ -match -memchr -( -b -' -' -replacement -. -as_bytes -( -) -) -{ -None -= -> -break -Some -( -i -) -= -> -{ -dst -. -push_str -( -& -replacement -[ -. -. -i -] -) -; -replacement -= -& -replacement -[ -i -. -. -] -; -} -} -/ -/ -Handle -escaping -of -' -' -. -if -replacement -. -as_bytes -( -) -. -get -( -1 -) -. -map_or -( -false -| -& -b -| -b -= -= -b -' -' -) -{ -dst -. -push_str -( -" -" -) -; -replacement -= -& -replacement -[ -2 -. -. -] -; -continue -; -} -debug_assert -! -( -! -replacement -. -is_empty -( -) -) -; -let -cap_ref -= -match -find_cap_ref -( -replacement -. -as_bytes -( -) -) -{ -Some -( -cap_ref -) -= -> -cap_ref -None -= -> -{ -dst -. -push_str -( -" -" -) -; -replacement -= -& -replacement -[ -1 -. -. -] -; -continue -; -} -} -; -replacement -= -& -replacement -[ -cap_ref -. -end -. -. -] -; -match -cap_ref -. -cap -{ -Ref -: -: -Number -( -i -) -= -> -append -( -i -dst -) -Ref -: -: -Named -( -name -) -= -> -{ -if -let -Some -( -i -) -= -name_to_index -( -name -) -{ -append -( -i -dst -) -; -} -} -} -} -dst -. -push_str -( -replacement -) -; -} -/ -/ -/ -Accepts -a -replacement -byte -string -and -interpolates -capture -references -with -/ -/ -/ -their -corresponding -values -. -/ -/ -/ -/ -/ -/ -append -should -be -a -function -that -appends -the -byte -string -value -of -a -/ -/ -/ -capture -group -at -a -particular -index -to -the -byte -string -given -. -If -the -/ -/ -/ -capture -group -index -is -invalid -then -nothing -should -be -appended -. -/ -/ -/ -/ -/ -/ -name_to_index -should -be -a -function -that -maps -a -capture -group -name -to -a -/ -/ -/ -capture -group -index -. -If -the -given -name -doesn -' -t -exist -then -None -should -/ -/ -/ -be -returned -. -/ -/ -/ -/ -/ -/ -Finally -dst -is -where -the -final -interpolated -contents -should -be -written -. -/ -/ -/ -If -replacement -contains -no -capture -group -references -then -dst -will -be -/ -/ -/ -equivalent -to -replacement -. -/ -/ -/ -/ -/ -/ -See -the -[ -module -documentation -] -( -self -) -for -details -about -the -format -/ -/ -/ -supported -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -util -: -: -interpolate -; -/ -/ -/ -/ -/ -/ -let -mut -dst -= -vec -! -[ -] -; -/ -/ -/ -interpolate -: -: -bytes -( -/ -/ -/ -b -" -foo -bar -baz -" -/ -/ -/ -| -index -dst -| -{ -/ -/ -/ -if -index -= -= -0 -{ -/ -/ -/ -dst -. -extend_from_slice -( -b -" -BAR -" -) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -| -name -| -{ -/ -/ -/ -if -name -= -= -" -bar -" -{ -/ -/ -/ -Some -( -0 -) -/ -/ -/ -} -else -{ -/ -/ -/ -None -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -& -mut -dst -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -foo -BAR -baz -" -[ -. -. -] -dst -) -; -/ -/ -/ -pub -fn -bytes -( -mut -replacement -: -& -[ -u8 -] -mut -append -: -impl -FnMut -( -usize -& -mut -Vec -< -u8 -> -) -mut -name_to_index -: -impl -FnMut -( -& -str -) -- -> -Option -< -usize -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -while -! -replacement -. -is_empty -( -) -{ -match -memchr -( -b -' -' -replacement -) -{ -None -= -> -break -Some -( -i -) -= -> -{ -dst -. -extend_from_slice -( -& -replacement -[ -. -. -i -] -) -; -replacement -= -& -replacement -[ -i -. -. -] -; -} -} -/ -/ -Handle -escaping -of -' -' -. -if -replacement -. -get -( -1 -) -. -map_or -( -false -| -& -b -| -b -= -= -b -' -' -) -{ -dst -. -push -( -b -' -' -) -; -replacement -= -& -replacement -[ -2 -. -. -] -; -continue -; -} -debug_assert -! -( -! -replacement -. -is_empty -( -) -) -; -let -cap_ref -= -match -find_cap_ref -( -replacement -) -{ -Some -( -cap_ref -) -= -> -cap_ref -None -= -> -{ -dst -. -push -( -b -' -' -) -; -replacement -= -& -replacement -[ -1 -. -. -] -; -continue -; -} -} -; -replacement -= -& -replacement -[ -cap_ref -. -end -. -. -] -; -match -cap_ref -. -cap -{ -Ref -: -: -Number -( -i -) -= -> -append -( -i -dst -) -Ref -: -: -Named -( -name -) -= -> -{ -if -let -Some -( -i -) -= -name_to_index -( -name -) -{ -append -( -i -dst -) -; -} -} -} -} -dst -. -extend_from_slice -( -replacement -) -; -} -/ -/ -/ -CaptureRef -represents -a -reference -to -a -capture -group -inside -some -text -. -/ -/ -/ -The -reference -is -either -a -capture -group -name -or -a -number -. -/ -/ -/ -/ -/ -/ -It -is -also -tagged -with -the -position -in -the -text -following -the -/ -/ -/ -capture -reference -. -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -struct -CaptureRef -< -' -a -> -{ -cap -: -Ref -< -' -a -> -end -: -usize -} -/ -/ -/ -A -reference -to -a -capture -group -in -some -text -. -/ -/ -/ -/ -/ -/ -e -. -g -. -2 -foo -{ -foo -} -. -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -enum -Ref -< -' -a -> -{ -Named -( -& -' -a -str -) -Number -( -usize -) -} -impl -< -' -a -> -From -< -& -' -a -str -> -for -Ref -< -' -a -> -{ -fn -from -( -x -: -& -' -a -str -) -- -> -Ref -< -' -a -> -{ -Ref -: -: -Named -( -x -) -} -} -impl -From -< -usize -> -for -Ref -< -' -static -> -{ -fn -from -( -x -: -usize -) -- -> -Ref -< -' -static -> -{ -Ref -: -: -Number -( -x -) -} -} -/ -/ -/ -Parses -a -possible -reference -to -a -capture -group -name -in -the -given -text -/ -/ -/ -starting -at -the -beginning -of -replacement -. -/ -/ -/ -/ -/ -/ -If -no -such -valid -reference -could -be -found -None -is -returned -. -/ -/ -/ -/ -/ -/ -Note -that -this -returns -a -" -possible -" -reference -because -this -routine -doesn -' -t -/ -/ -/ -know -whether -the -reference -is -to -a -valid -group -or -not -. -If -it -winds -up -not -/ -/ -/ -being -a -valid -reference -then -it -should -be -replaced -with -the -empty -string -. -fn -find_cap_ref -( -replacement -: -& -[ -u8 -] -) -- -> -Option -< -CaptureRef -< -' -_ -> -> -{ -let -mut -i -= -0 -; -let -rep -: -& -[ -u8 -] -= -replacement -; -if -rep -. -len -( -) -< -= -1 -| -| -rep -[ -0 -] -! -= -b -' -' -{ -return -None -; -} -i -+ -= -1 -; -if -rep -[ -i -] -= -= -b -' -{ -' -{ -return -find_cap_ref_braced -( -rep -i -+ -1 -) -; -} -let -mut -cap_end -= -i -; -while -rep -. -get -( -cap_end -) -. -copied -( -) -. -map_or -( -false -is_valid_cap_letter -) -{ -cap_end -+ -= -1 -; -} -if -cap_end -= -= -i -{ -return -None -; -} -/ -/ -We -just -verified -that -the -range -0 -. -. -cap_end -is -valid -ASCII -so -it -must -/ -/ -therefore -be -valid -UTF -- -8 -. -If -we -really -cared -we -could -avoid -this -UTF -- -8 -/ -/ -check -via -an -unchecked -conversion -or -by -parsing -the -number -straight -from -/ -/ -& -[ -u8 -] -. -let -cap -= -core -: -: -str -: -: -from_utf8 -( -& -rep -[ -i -. -. -cap_end -] -) -. -expect -( -" -valid -UTF -- -8 -capture -name -" -) -; -Some -( -CaptureRef -{ -cap -: -match -cap -. -parse -: -: -< -usize -> -( -) -{ -Ok -( -i -) -= -> -Ref -: -: -Number -( -i -) -Err -( -_ -) -= -> -Ref -: -: -Named -( -cap -) -} -end -: -cap_end -} -) -} -/ -/ -/ -Looks -for -a -braced -reference -e -. -g -. -{ -foo1 -} -. -This -assumes -that -an -opening -/ -/ -/ -brace -has -been -found -at -i -- -1 -in -rep -. -This -then -looks -for -a -closing -/ -/ -/ -brace -and -returns -the -capture -reference -within -the -brace -. -fn -find_cap_ref_braced -( -rep -: -& -[ -u8 -] -mut -i -: -usize -) -- -> -Option -< -CaptureRef -< -' -_ -> -> -{ -assert_eq -! -( -b -' -{ -' -rep -[ -i -. -checked_sub -( -1 -) -. -unwrap -( -) -] -) -; -let -start -= -i -; -while -rep -. -get -( -i -) -. -map_or -( -false -| -& -b -| -b -! -= -b -' -} -' -) -{ -i -+ -= -1 -; -} -if -! -rep -. -get -( -i -) -. -map_or -( -false -| -& -b -| -b -= -= -b -' -} -' -) -{ -return -None -; -} -/ -/ -When -looking -at -braced -names -we -don -' -t -put -any -restrictions -on -the -name -/ -/ -so -it -' -s -possible -it -could -be -invalid -UTF -- -8 -. -But -a -capture -group -name -/ -/ -can -never -be -invalid -UTF -- -8 -so -if -we -have -invalid -UTF -- -8 -then -we -can -/ -/ -safely -return -None -. -let -cap -= -match -core -: -: -str -: -: -from_utf8 -( -& -rep -[ -start -. -. -i -] -) -{ -Err -( -_ -) -= -> -return -None -Ok -( -cap -) -= -> -cap -} -; -Some -( -CaptureRef -{ -cap -: -match -cap -. -parse -: -: -< -usize -> -( -) -{ -Ok -( -i -) -= -> -Ref -: -: -Number -( -i -) -Err -( -_ -) -= -> -Ref -: -: -Named -( -cap -) -} -end -: -i -+ -1 -} -) -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -byte -is -allowed -in -a -capture -name -/ -/ -/ -written -in -non -- -brace -form -. -fn -is_valid_cap_letter -( -b -: -u8 -) -- -> -bool -{ -match -b -{ -b -' -0 -' -. -. -= -b -' -9 -' -| -b -' -a -' -. -. -= -b -' -z -' -| -b -' -A -' -. -. -= -b -' -Z -' -| -b -' -_ -' -= -> -true -_ -= -> -false -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -alloc -: -: -{ -string -: -: -String -vec -vec -: -: -Vec -} -; -use -super -: -: -{ -find_cap_ref -CaptureRef -} -; -macro_rules -! -find -{ -( -name -: -ident -text -: -expr -) -= -> -{ -# -[ -test -] -fn -name -( -) -{ -assert_eq -! -( -None -find_cap_ref -( -text -. -as_bytes -( -) -) -) -; -} -} -; -( -name -: -ident -text -: -expr -capref -: -expr -) -= -> -{ -# -[ -test -] -fn -name -( -) -{ -assert_eq -! -( -Some -( -capref -) -find_cap_ref -( -text -. -as_bytes -( -) -) -) -; -} -} -; -} -macro_rules -! -c -{ -( -name_or_number -: -expr -pos -: -expr -) -= -> -{ -CaptureRef -{ -cap -: -name_or_number -. -into -( -) -end -: -pos -} -} -; -} -find -! -( -find_cap_ref1 -" -foo -" -c -! -( -" -foo -" -4 -) -) -; -find -! -( -find_cap_ref2 -" -{ -foo -} -" -c -! -( -" -foo -" -6 -) -) -; -find -! -( -find_cap_ref3 -" -0 -" -c -! -( -0 -2 -) -) -; -find -! -( -find_cap_ref4 -" -5 -" -c -! -( -5 -2 -) -) -; -find -! -( -find_cap_ref5 -" -10 -" -c -! -( -10 -3 -) -) -; -/ -/ -See -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -pull -/ -585 -/ -/ -for -more -on -characters -following -numbers -find -! -( -find_cap_ref6 -" -42a -" -c -! -( -" -42a -" -4 -) -) -; -find -! -( -find_cap_ref7 -" -{ -42 -} -a -" -c -! -( -42 -5 -) -) -; -find -! -( -find_cap_ref8 -" -{ -42 -" -) -; -find -! -( -find_cap_ref9 -" -{ -42 -" -) -; -find -! -( -find_cap_ref10 -" -0 -" -) -; -find -! -( -find_cap_ref11 -" -" -) -; -find -! -( -find_cap_ref12 -" -" -) -; -find -! -( -find_cap_ref13 -" -" -) -; -find -! -( -find_cap_ref14 -" -1 -- -2 -" -c -! -( -1 -2 -) -) -; -find -! -( -find_cap_ref15 -" -1_ -2 -" -c -! -( -" -1_ -" -3 -) -) -; -find -! -( -find_cap_ref16 -" -x -- -y -" -c -! -( -" -x -" -2 -) -) -; -find -! -( -find_cap_ref17 -" -x_ -y -" -c -! -( -" -x_ -" -3 -) -) -; -find -! -( -find_cap_ref18 -" -{ -# -} -" -c -! -( -" -# -" -4 -) -) -; -find -! -( -find_cap_ref19 -" -{ -Z -[ -} -" -c -! -( -" -Z -[ -" -5 -) -) -; -find -! -( -find_cap_ref20 -" -{ -} -" -c -! -( -" -" -5 -) -) -; -find -! -( -find_cap_ref21 -" -{ -a -} -" -c -! -( -" -a -" -6 -) -) -; -find -! -( -find_cap_ref22 -" -{ -a -} -" -c -! -( -" -a -" -6 -) -) -; -find -! -( -find_cap_ref23 -" -{ -} -" -c -! -( -" -" -6 -) -) -; -find -! -( -find_cap_ref24 -" -{ -a -} -" -c -! -( -" -a -" -7 -) -) -; -find -! -( -find_cap_ref25 -" -{ -a -} -" -c -! -( -" -a -" -7 -) -) -; -find -! -( -find_cap_ref26 -" -{ -} -" -c -! -( -" -" -9 -) -) -; -fn -interpolate_string -( -mut -name_to_index -: -Vec -< -( -& -' -static -str -usize -) -> -caps -: -Vec -< -& -' -static -str -> -replacement -: -& -str -) -- -> -String -{ -name_to_index -. -sort_by_key -( -| -x -| -x -. -0 -) -; -let -mut -dst -= -String -: -: -new -( -) -; -super -: -: -string -( -replacement -| -i -dst -| -{ -if -let -Some -( -& -s -) -= -caps -. -get -( -i -) -{ -dst -. -push_str -( -s -) -; -} -} -| -name -| -- -> -Option -< -usize -> -{ -name_to_index -. -binary_search_by_key -( -& -name -| -x -| -x -. -0 -) -. -ok -( -) -. -map -( -| -i -| -name_to_index -[ -i -] -. -1 -) -} -& -mut -dst -) -; -dst -} -fn -interpolate_bytes -( -mut -name_to_index -: -Vec -< -( -& -' -static -str -usize -) -> -caps -: -Vec -< -& -' -static -str -> -replacement -: -& -str -) -- -> -String -{ -name_to_index -. -sort_by_key -( -| -x -| -x -. -0 -) -; -let -mut -dst -= -vec -! -[ -] -; -super -: -: -bytes -( -replacement -. -as_bytes -( -) -| -i -dst -| -{ -if -let -Some -( -& -s -) -= -caps -. -get -( -i -) -{ -dst -. -extend_from_slice -( -s -. -as_bytes -( -) -) -; -} -} -| -name -| -- -> -Option -< -usize -> -{ -name_to_index -. -binary_search_by_key -( -& -name -| -x -| -x -. -0 -) -. -ok -( -) -. -map -( -| -i -| -name_to_index -[ -i -] -. -1 -) -} -& -mut -dst -) -; -String -: -: -from_utf8 -( -dst -) -. -unwrap -( -) -} -macro_rules -! -interp -{ -( -name -: -ident -map -: -expr -caps -: -expr -hay -: -expr -expected -: -expr -( -) -* -) -= -> -{ -# -[ -test -] -fn -name -( -) -{ -assert_eq -! -( -expected -interpolate_string -( -map -caps -hay -) -" -interpolate -: -: -string -failed -" -) -; -assert_eq -! -( -expected -interpolate_bytes -( -map -caps -hay -) -" -interpolate -: -: -bytes -failed -" -) -; -} -} -; -} -interp -! -( -interp1 -vec -! -[ -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -" -" -xxx -" -] -" -test -foo -test -" -" -test -xxx -test -" -) -; -interp -! -( -interp2 -vec -! -[ -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -" -" -xxx -" -] -" -test -footest -" -" -test -" -) -; -interp -! -( -interp3 -vec -! -[ -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -" -" -xxx -" -] -" -test -{ -foo -} -test -" -" -testxxxtest -" -) -; -interp -! -( -interp4 -vec -! -[ -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -" -" -xxx -" -] -" -test -2test -" -" -test -" -) -; -interp -! -( -interp5 -vec -! -[ -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -" -" -xxx -" -] -" -test -{ -2 -} -test -" -" -testxxxtest -" -) -; -interp -! -( -interp6 -vec -! -[ -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -" -" -xxx -" -] -" -test -foo -test -" -" -test -foo -test -" -) -; -interp -! -( -interp7 -vec -! -[ -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -" -" -xxx -" -] -" -test -foo -" -" -test -xxx -" -) -; -interp -! -( -interp8 -vec -! -[ -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -" -" -xxx -" -] -" -foo -test -" -" -xxx -test -" -) -; -interp -! -( -interp9 -vec -! -[ -( -" -bar -" -1 -) -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -yyy -" -" -xxx -" -] -" -test -bar -foo -" -" -test -yyyxxx -" -) -; -interp -! -( -interp10 -vec -! -[ -( -" -bar -" -1 -) -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -yyy -" -" -xxx -" -] -" -test -test -" -" -test -test -" -) -; -interp -! -( -interp11 -vec -! -[ -( -" -bar -" -1 -) -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -yyy -" -" -xxx -" -] -" -test -{ -} -test -" -" -test -test -" -) -; -interp -! -( -interp12 -vec -! -[ -( -" -bar -" -1 -) -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -yyy -" -" -xxx -" -] -" -test -{ -} -test -" -" -test -test -" -) -; -interp -! -( -interp13 -vec -! -[ -( -" -bar -" -1 -) -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -yyy -" -" -xxx -" -] -" -test -{ -a -b -} -test -" -" -test -test -" -) -; -interp -! -( -interp14 -vec -! -[ -( -" -bar -" -1 -) -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -yyy -" -" -xxx -" -] -" -test -{ -a -} -test -" -" -test -test -" -) -; -/ -/ -This -is -a -funny -case -where -a -braced -reference -is -never -closed -but -/ -/ -within -the -unclosed -braced -reference -there -is -an -unbraced -reference -. -/ -/ -In -this -case -the -braced -reference -is -just -treated -literally -and -the -/ -/ -unbraced -reference -is -found -. -interp -! -( -interp15 -vec -! -[ -( -" -bar -" -1 -) -( -" -foo -" -2 -) -] -vec -! -[ -" -" -" -yyy -" -" -xxx -" -] -" -test -{ -wat -bar -ok -" -" -test -{ -wat -yyy -ok -" -) -; -} diff --git a/third_party/rust/regex-automata/src/util/iter.rs b/third_party/rust/regex-automata/src/util/iter.rs deleted file mode 100644 index 7f84b1314e7e3..0000000000000 --- a/third_party/rust/regex-automata/src/util/iter.rs +++ /dev/null @@ -1,10124 +0,0 @@ -/ -* -! -Generic -helpers -for -iteration -of -matches -from -a -regex -engine -in -a -haystack -. -The -principle -type -in -this -module -is -a -[ -Searcher -] -. -A -Searcher -provides -its -own -lower -level -iterator -- -like -API -in -addition -to -methods -for -constructing -types -that -implement -Iterator -. -The -documentation -for -Searcher -explains -a -bit -more -about -why -these -different -APIs -exist -. -Currently -this -module -supports -iteration -over -any -regex -engine -that -works -with -the -[ -HalfMatch -] -[ -Match -] -or -[ -Captures -] -types -. -* -/ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -use -crate -: -: -util -: -: -captures -: -: -Captures -; -use -crate -: -: -util -: -: -search -: -: -{ -HalfMatch -Input -Match -MatchError -} -; -/ -/ -/ -A -searcher -for -creating -iterators -and -performing -lower -level -iteration -. -/ -/ -/ -/ -/ -/ -This -searcher -encapsulates -the -logic -required -for -finding -all -successive -/ -/ -/ -non -- -overlapping -matches -in -a -haystack -. -In -theory -iteration -would -look -/ -/ -/ -something -like -this -: -/ -/ -/ -/ -/ -/ -1 -. -Setting -the -start -position -to -0 -. -/ -/ -/ -2 -. -Execute -a -regex -search -. -If -no -match -end -iteration -. -/ -/ -/ -3 -. -Report -the -match -and -set -the -start -position -to -the -end -of -the -match -. -/ -/ -/ -4 -. -Go -back -to -( -2 -) -. -/ -/ -/ -/ -/ -/ -And -if -this -were -indeed -the -case -it -' -s -likely -that -Searcher -wouldn -' -t -/ -/ -/ -exist -. -Unfortunately -because -a -regex -may -match -the -empty -string -the -above -/ -/ -/ -logic -won -' -t -work -for -all -possible -regexes -. -Namely -if -an -empty -match -is -/ -/ -/ -found -then -step -( -3 -) -would -set -the -start -position -of -the -search -to -the -/ -/ -/ -position -it -was -at -. -Thus -iteration -would -never -end -. -/ -/ -/ -/ -/ -/ -Instead -a -Searcher -knows -how -to -detect -these -cases -and -forcefully -/ -/ -/ -advance -iteration -in -the -case -of -an -empty -match -that -overlaps -with -a -/ -/ -/ -previous -match -. -/ -/ -/ -/ -/ -/ -If -you -know -that -your -regex -cannot -match -any -empty -string -then -the -simple -/ -/ -/ -algorithm -described -above -will -work -correctly -. -/ -/ -/ -/ -/ -/ -When -possible -prefer -the -iterators -defined -on -the -regex -engine -you -' -re -/ -/ -/ -using -. -This -tries -to -abstract -over -the -regex -engine -and -is -thus -a -bit -more -/ -/ -/ -unwieldy -to -use -. -/ -/ -/ -/ -/ -/ -In -particular -a -Searcher -is -not -itself -an -iterator -. -Instead -it -provides -/ -/ -/ -advance -routines -that -permit -moving -the -search -along -explicitly -. -It -also -/ -/ -/ -provides -various -routines -like -[ -Searcher -: -: -into_matches_iter -] -that -/ -/ -/ -accept -a -closure -( -representing -how -a -regex -engine -executes -a -search -) -and -/ -/ -/ -returns -a -conventional -iterator -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -come -from -the -[ -Input -] -type -passed -to -/ -/ -/ -[ -Searcher -: -: -new -] -: -/ -/ -/ -/ -/ -/ -* -' -h -is -the -lifetime -of -the -underlying -haystack -. -/ -/ -/ -/ -/ -/ -# -Searcher -vs -Iterator -/ -/ -/ -/ -/ -/ -Why -does -a -search -type -with -" -advance -" -APIs -exist -at -all -when -we -also -have -/ -/ -/ -iterators -? -Unfortunately -the -reasoning -behind -this -split -is -a -complex -/ -/ -/ -combination -of -the -following -things -: -/ -/ -/ -/ -/ -/ -1 -. -While -many -of -the -regex -engines -expose -their -own -iterators -it -is -also -/ -/ -/ -nice -to -expose -this -lower -level -iteration -helper -because -it -permits -callers -/ -/ -/ -to -provide -their -own -Input -configuration -. -Moreover -a -Searcher -can -work -/ -/ -/ -with -_any_ -regex -engine -instead -of -only -the -ones -defined -in -this -crate -. -/ -/ -/ -This -way -everyone -benefits -from -a -shared -iteration -implementation -. -/ -/ -/ -2 -. -There -are -many -different -regex -engines -that -while -they -have -the -same -/ -/ -/ -match -semantics -they -have -slightly -different -APIs -. -Iteration -is -just -/ -/ -/ -complex -enough -to -want -to -share -code -and -so -we -need -a -way -of -abstracting -/ -/ -/ -over -those -different -regex -engines -. -While -we -could -define -a -new -trait -that -/ -/ -/ -describes -any -regex -engine -search -API -it -would -wind -up -looking -very -close -/ -/ -/ -to -a -closure -. -While -there -may -still -be -reasons -for -the -more -generic -trait -/ -/ -/ -to -exist -for -now -and -for -the -purposes -of -iteration -we -use -a -closure -. -/ -/ -/ -Closures -also -provide -a -lot -of -easy -flexibility -at -the -call -site -in -that -/ -/ -/ -they -permit -the -caller -to -borrow -any -kind -of -state -they -want -for -use -during -/ -/ -/ -each -search -call -. -/ -/ -/ -3 -. -As -a -result -of -using -closures -and -because -closures -are -anonymous -types -/ -/ -/ -that -cannot -be -named -it -is -difficult -to -encapsulate -them -without -both -/ -/ -/ -costs -to -speed -and -added -complexity -to -the -public -API -. -For -example -in -/ -/ -/ -defining -an -iterator -type -like -/ -/ -/ -[ -dfa -: -: -regex -: -: -FindMatches -] -( -crate -: -: -dfa -: -: -regex -: -: -FindMatches -) -/ -/ -/ -if -we -use -a -closure -internally -it -' -s -not -possible -to -name -this -type -in -the -/ -/ -/ -return -type -of -the -iterator -constructor -. -Thus -the -only -way -around -it -is -/ -/ -/ -to -erase -the -type -by -boxing -it -and -turning -it -into -a -Box -< -dyn -FnMut -. -. -. -> -. -/ -/ -/ -This -boxed -closure -is -unlikely -to -be -inlined -_and_ -it -infects -the -public -/ -/ -/ -API -in -subtle -ways -. -Namely -unless -you -declare -the -closure -as -implementing -/ -/ -/ -Send -and -Sync -then -the -resulting -iterator -type -won -' -t -implement -it -/ -/ -/ -either -. -But -there -are -practical -issues -with -requiring -the -closure -to -/ -/ -/ -implement -Send -and -Sync -that -result -in -other -API -complexities -that -/ -/ -/ -are -beyond -the -scope -of -this -already -long -exposition -. -/ -/ -/ -4 -. -Some -regex -engines -expose -more -complex -match -information -than -just -/ -/ -/ -" -which -pattern -matched -" -and -" -at -what -offsets -. -" -For -example -the -PikeVM -/ -/ -/ -exposes -match -spans -for -each -capturing -group -that -participated -in -the -/ -/ -/ -match -. -In -such -cases -it -can -be -quite -beneficial -to -reuse -the -capturing -/ -/ -/ -group -allocation -on -subsequent -searches -. -A -proper -iterator -doesn -' -t -permit -/ -/ -/ -this -API -due -to -its -interface -so -it -' -s -useful -to -have -something -a -bit -lower -/ -/ -/ -level -that -permits -callers -to -amortize -allocations -while -also -reusing -a -/ -/ -/ -shared -implementation -of -iteration -. -( -See -the -documentation -for -/ -/ -/ -[ -Searcher -: -: -advance -] -for -an -example -of -using -the -" -advance -" -API -with -the -/ -/ -/ -PikeVM -. -) -/ -/ -/ -/ -/ -/ -What -this -boils -down -to -is -that -there -are -" -advance -" -APIs -which -require -/ -/ -/ -handing -a -closure -to -it -for -every -call -and -there -are -also -APIs -to -create -/ -/ -/ -iterators -from -a -closure -. -The -former -are -useful -for -_implementing_ -/ -/ -/ -iterators -or -when -you -need -more -flexibility -while -the -latter -are -useful -/ -/ -/ -for -conveniently -writing -custom -iterators -on -- -the -- -fly -. -/ -/ -/ -/ -/ -/ -# -Example -: -iterating -with -captures -/ -/ -/ -/ -/ -/ -Several -regex -engines -in -this -crate -over -convenient -iterator -APIs -over -/ -/ -/ -[ -Captures -] -values -. -To -do -so -this -requires -allocating -a -new -Captures -/ -/ -/ -value -for -each -iteration -step -. -This -can -perhaps -be -more -costly -than -you -/ -/ -/ -might -want -. -Instead -of -implementing -your -own -iterator -to -avoid -that -/ -/ -/ -cost -( -which -can -be -a -little -subtle -if -you -want -to -handle -empty -matches -/ -/ -/ -correctly -) -you -can -use -this -Searcher -to -do -it -for -you -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -Input -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -" -foo -( -? -P -< -numbers -> -[ -0 -- -9 -] -+ -) -" -) -? -; -/ -/ -/ -let -haystack -= -" -foo1 -foo12 -foo123 -" -; -/ -/ -/ -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -let -mut -searcher -= -Searcher -: -: -new -( -Input -: -: -new -( -haystack -) -) -; -/ -/ -/ -while -let -Some -( -_ -) -= -searcher -. -advance -( -| -input -| -{ -/ -/ -/ -re -. -search -( -& -mut -cache -input -& -mut -caps -) -; -/ -/ -/ -Ok -( -caps -. -get_match -( -) -) -/ -/ -/ -} -) -{ -/ -/ -/ -/ -/ -The -unwrap -is -OK -since -' -numbers -' -matches -if -the -pattern -matches -. -/ -/ -/ -matches -. -push -( -caps -. -get_group_by_name -( -" -numbers -" -) -. -unwrap -( -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -Span -: -: -from -( -3 -. -. -4 -) -/ -/ -/ -Span -: -: -from -( -8 -. -. -10 -) -/ -/ -/ -Span -: -: -from -( -14 -. -. -17 -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Searcher -< -' -h -> -{ -/ -/ -/ -The -input -parameters -to -give -to -each -regex -engine -call -. -/ -/ -/ -/ -/ -/ -The -start -position -of -the -search -is -mutated -during -iteration -. -input -: -Input -< -' -h -> -/ -/ -/ -Records -the -end -offset -of -the -most -recent -match -. -This -is -necessary -to -/ -/ -/ -handle -a -corner -case -for -preventing -empty -matches -from -overlapping -with -/ -/ -/ -the -ending -bounds -of -a -prior -match -. -last_match_end -: -Option -< -usize -> -} -impl -< -' -h -> -Searcher -< -' -h -> -{ -/ -/ -/ -Create -a -new -fallible -non -- -overlapping -matches -iterator -. -/ -/ -/ -/ -/ -/ -The -given -input -provides -the -parameters -( -including -the -haystack -) -/ -/ -/ -while -the -finder -represents -a -closure -that -calls -the -underlying -regex -/ -/ -/ -engine -. -The -closure -may -borrow -any -additional -state -that -is -needed -/ -/ -/ -such -as -a -prefilter -scanner -. -pub -fn -new -( -input -: -Input -< -' -h -> -) -- -> -Searcher -< -' -h -> -{ -Searcher -{ -input -last_match_end -: -None -} -} -/ -/ -/ -Returns -the -current -Input -used -by -this -searcher -. -/ -/ -/ -/ -/ -/ -The -Input -returned -is -generally -equivalent -to -the -one -given -to -/ -/ -/ -[ -Searcher -: -: -new -] -but -its -start -position -may -be -different -to -reflect -/ -/ -/ -the -start -of -the -next -search -to -be -executed -. -pub -fn -input -< -' -s -> -( -& -' -s -self -) -- -> -& -' -s -Input -< -' -h -> -{ -& -self -. -input -} -/ -/ -/ -Return -the -next -half -match -for -an -infallible -search -if -one -exists -and -/ -/ -/ -advance -to -the -next -position -. -/ -/ -/ -/ -/ -/ -This -is -like -try_advance_half -except -errors -are -converted -into -/ -/ -/ -panics -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -given -closure -returns -an -error -then -this -panics -. -This -is -useful -/ -/ -/ -when -you -know -your -underlying -regex -engine -has -been -configured -to -not -/ -/ -/ -return -an -error -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -a -Searcher -to -iterate -over -all -matches -/ -/ -/ -when -using -a -DFA -which -only -provides -" -half -" -matches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -2010 -- -03 -- -14 -2016 -- -10 -- -08 -2020 -- -10 -- -22 -" -) -; -/ -/ -/ -let -mut -it -= -Searcher -: -: -new -( -input -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -10 -) -) -; -/ -/ -/ -let -got -= -it -. -advance_half -( -| -input -| -re -. -try_search_fwd -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -21 -) -) -; -/ -/ -/ -let -got -= -it -. -advance_half -( -| -input -| -re -. -try_search_fwd -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -32 -) -) -; -/ -/ -/ -let -got -= -it -. -advance_half -( -| -input -| -re -. -try_search_fwd -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -got -= -it -. -advance_half -( -| -input -| -re -. -try_search_fwd -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -correctly -moves -iteration -forward -even -when -an -empty -match -occurs -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -r -" -a -| -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -abba -" -) -; -/ -/ -/ -let -mut -it -= -Searcher -: -: -new -( -input -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -1 -) -) -; -/ -/ -/ -let -got -= -it -. -advance_half -( -| -input -| -re -. -try_search_fwd -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -2 -) -) -; -/ -/ -/ -let -got -= -it -. -advance_half -( -| -input -| -re -. -try_search_fwd -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -HalfMatch -: -: -must -( -0 -4 -) -) -; -/ -/ -/ -let -got -= -it -. -advance_half -( -| -input -| -re -. -try_search_fwd -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -got -= -it -. -advance_half -( -| -input -| -re -. -try_search_fwd -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -advance_half -< -F -> -( -& -mut -self -finder -: -F -) -- -> -Option -< -HalfMatch -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -match -self -. -try_advance_half -( -finder -) -{ -Ok -( -m -) -= -> -m -Err -( -err -) -= -> -panic -! -( -" -unexpected -regex -half -find -error -: -{ -} -\ -n -\ -to -handle -find -errors -use -' -try -' -or -' -search -' -methods -" -err -) -} -} -/ -/ -/ -Return -the -next -match -for -an -infallible -search -if -one -exists -and -/ -/ -/ -advance -to -the -next -position -. -/ -/ -/ -/ -/ -/ -The -search -is -advanced -even -in -the -presence -of -empty -matches -by -/ -/ -/ -forbidding -empty -matches -from -overlapping -with -any -other -match -. -/ -/ -/ -/ -/ -/ -This -is -like -try_advance -except -errors -are -converted -into -panics -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -the -given -closure -returns -an -error -then -this -panics -. -This -is -useful -/ -/ -/ -when -you -know -your -underlying -regex -engine -has -been -configured -to -not -/ -/ -/ -return -an -error -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -a -Searcher -to -iterate -over -all -matches -/ -/ -/ -when -using -a -regex -based -on -lazy -DFAs -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -regex -: -: -Regex -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -2010 -- -03 -- -14 -2016 -- -10 -- -08 -2020 -- -10 -- -22 -" -) -; -/ -/ -/ -let -mut -it -= -Searcher -: -: -new -( -input -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -10 -) -) -; -/ -/ -/ -let -got -= -it -. -advance -( -| -input -| -re -. -try_search -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -11 -. -. -21 -) -) -; -/ -/ -/ -let -got -= -it -. -advance -( -| -input -| -re -. -try_search -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -22 -. -. -32 -) -) -; -/ -/ -/ -let -got -= -it -. -advance -( -| -input -| -re -. -try_search -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -got -= -it -. -advance -( -| -input -| -re -. -try_search -( -& -mut -cache -input -) -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -the -same -as -above -but -with -the -PikeVM -. -This -example -/ -/ -/ -is -useful -because -it -shows -how -to -use -this -API -even -when -the -regex -/ -/ -/ -engine -doesn -' -t -directly -return -a -Match -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -2010 -- -03 -- -14 -2016 -- -10 -- -08 -2020 -- -10 -- -22 -" -) -; -/ -/ -/ -let -mut -it -= -Searcher -: -: -new -( -input -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -0 -. -. -10 -) -) -; -/ -/ -/ -let -got -= -it -. -advance -( -| -input -| -{ -/ -/ -/ -re -. -search -( -& -mut -cache -input -& -mut -caps -) -; -/ -/ -/ -Ok -( -caps -. -get_match -( -) -) -/ -/ -/ -} -) -; -/ -/ -/ -/ -/ -Note -that -if -we -wanted -to -extract -capturing -group -spans -we -could -/ -/ -/ -/ -/ -do -that -here -with -' -caps -' -. -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -11 -. -. -21 -) -) -; -/ -/ -/ -let -got -= -it -. -advance -( -| -input -| -{ -/ -/ -/ -re -. -search -( -& -mut -cache -input -& -mut -caps -) -; -/ -/ -/ -Ok -( -caps -. -get_match -( -) -) -/ -/ -/ -} -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -22 -. -. -32 -) -) -; -/ -/ -/ -let -got -= -it -. -advance -( -| -input -| -{ -/ -/ -/ -re -. -search -( -& -mut -cache -input -& -mut -caps -) -; -/ -/ -/ -Ok -( -caps -. -get_match -( -) -) -/ -/ -/ -} -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -let -got -= -it -. -advance -( -| -input -| -{ -/ -/ -/ -re -. -search -( -& -mut -cache -input -& -mut -caps -) -; -/ -/ -/ -Ok -( -caps -. -get_match -( -) -) -/ -/ -/ -} -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -advance -< -F -> -( -& -mut -self -finder -: -F -) -- -> -Option -< -Match -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -match -self -. -try_advance -( -finder -) -{ -Ok -( -m -) -= -> -m -Err -( -err -) -= -> -panic -! -( -" -unexpected -regex -find -error -: -{ -} -\ -n -\ -to -handle -find -errors -use -' -try -' -or -' -search -' -methods -" -err -) -} -} -/ -/ -/ -Return -the -next -half -match -for -a -fallible -search -if -one -exists -and -/ -/ -/ -advance -to -the -next -position -. -/ -/ -/ -/ -/ -/ -This -is -like -advance_half -except -it -permits -callers -to -handle -errors -/ -/ -/ -during -iteration -. -# -[ -inline -] -pub -fn -try_advance_half -< -F -> -( -& -mut -self -mut -finder -: -F -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -let -mut -m -= -match -finder -( -& -self -. -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -m -) -= -> -m -} -; -if -Some -( -m -. -offset -( -) -) -= -= -self -. -last_match_end -{ -m -= -match -self -. -handle_overlapping_empty_half_match -( -m -finder -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -m -) -= -> -m -} -; -} -self -. -input -. -set_start -( -m -. -offset -( -) -) -; -self -. -last_match_end -= -Some -( -m -. -offset -( -) -) -; -Ok -( -Some -( -m -) -) -} -/ -/ -/ -Return -the -next -match -for -a -fallible -search -if -one -exists -and -advance -/ -/ -/ -to -the -next -position -. -/ -/ -/ -/ -/ -/ -This -is -like -advance -except -it -permits -callers -to -handle -errors -/ -/ -/ -during -iteration -. -# -[ -inline -] -pub -fn -try_advance -< -F -> -( -& -mut -self -mut -finder -: -F -) -- -> -Result -< -Option -< -Match -> -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -let -mut -m -= -match -finder -( -& -self -. -input -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -m -) -= -> -m -} -; -if -m -. -is_empty -( -) -& -& -Some -( -m -. -end -( -) -) -= -= -self -. -last_match_end -{ -m -= -match -self -. -handle_overlapping_empty_match -( -m -finder -) -? -{ -None -= -> -return -Ok -( -None -) -Some -( -m -) -= -> -m -} -; -} -self -. -input -. -set_start -( -m -. -end -( -) -) -; -self -. -last_match_end -= -Some -( -m -. -end -( -) -) -; -Ok -( -Some -( -m -) -) -} -/ -/ -/ -Given -a -closure -that -executes -a -single -search -return -an -iterator -over -/ -/ -/ -all -successive -non -- -overlapping -half -matches -. -/ -/ -/ -/ -/ -/ -The -iterator -returned -yields -result -values -. -If -the -underlying -regex -/ -/ -/ -engine -is -configured -to -never -return -an -error -consider -calling -/ -/ -/ -[ -TryHalfMatchesIter -: -: -infallible -] -to -convert -errors -into -panics -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -a -Searcher -to -create -a -proper -/ -/ -/ -iterator -over -half -matches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -DFA -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -HalfMatch -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -2010 -- -03 -- -14 -2016 -- -10 -- -08 -2020 -- -10 -- -22 -" -) -; -/ -/ -/ -let -mut -it -= -Searcher -: -: -new -( -input -) -. -into_half_matches_iter -( -| -input -| -{ -/ -/ -/ -re -. -try_search_fwd -( -& -mut -cache -input -) -/ -/ -/ -} -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Ok -( -HalfMatch -: -: -must -( -0 -10 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Ok -( -HalfMatch -: -: -must -( -0 -21 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Ok -( -HalfMatch -: -: -must -( -0 -32 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -assert_eq -! -( -expected -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -into_half_matches_iter -< -F -> -( -self -finder -: -F -) -- -> -TryHalfMatchesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -TryHalfMatchesIter -{ -it -: -self -finder -} -} -/ -/ -/ -Given -a -closure -that -executes -a -single -search -return -an -iterator -over -/ -/ -/ -all -successive -non -- -overlapping -matches -. -/ -/ -/ -/ -/ -/ -The -iterator -returned -yields -result -values -. -If -the -underlying -regex -/ -/ -/ -engine -is -configured -to -never -return -an -error -consider -calling -/ -/ -/ -[ -TryMatchesIter -: -: -infallible -] -to -convert -errors -into -panics -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -a -Searcher -to -create -a -proper -/ -/ -/ -iterator -over -matches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -regex -: -: -Regex -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -2010 -- -03 -- -14 -2016 -- -10 -- -08 -2020 -- -10 -- -22 -" -) -; -/ -/ -/ -let -mut -it -= -Searcher -: -: -new -( -input -) -. -into_matches_iter -( -| -input -| -{ -/ -/ -/ -re -. -try_search -( -& -mut -cache -input -) -/ -/ -/ -} -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Ok -( -Match -: -: -must -( -0 -0 -. -. -10 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Ok -( -Match -: -: -must -( -0 -11 -. -. -21 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Ok -( -Match -: -: -must -( -0 -22 -. -. -32 -) -) -) -; -/ -/ -/ -assert_eq -! -( -expected -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -None -; -/ -/ -/ -assert_eq -! -( -expected -it -. -next -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -into_matches_iter -< -F -> -( -self -finder -: -F -) -- -> -TryMatchesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -TryMatchesIter -{ -it -: -self -finder -} -} -/ -/ -/ -Given -a -closure -that -executes -a -single -search -return -an -iterator -over -/ -/ -/ -all -successive -non -- -overlapping -Captures -values -. -/ -/ -/ -/ -/ -/ -The -iterator -returned -yields -result -values -. -If -the -underlying -regex -/ -/ -/ -engine -is -configured -to -never -return -an -error -consider -calling -/ -/ -/ -[ -TryCapturesIter -: -: -infallible -] -to -convert -errors -into -panics -. -/ -/ -/ -/ -/ -/ -Unlike -the -other -iterator -constructors -this -accepts -an -initial -/ -/ -/ -Captures -value -. -This -Captures -value -is -reused -for -each -search -and -/ -/ -/ -the -iterator -implementation -clones -it -before -returning -it -. -The -caller -/ -/ -/ -must -provide -this -value -because -the -iterator -is -purposely -ignorant -/ -/ -/ -of -the -underlying -regex -engine -and -thus -doesn -' -t -know -how -to -create -/ -/ -/ -one -itself -. -More -to -the -point -a -Captures -value -itself -has -a -few -/ -/ -/ -different -constructors -which -change -which -kind -of -information -is -/ -/ -/ -available -to -query -in -exchange -for -search -performance -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -a -Searcher -to -create -a -proper -iterator -/ -/ -/ -over -Captures -values -which -provides -access -to -all -capturing -group -/ -/ -/ -spans -for -each -match -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -iter -: -: -Searcher -/ -/ -/ -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -/ -/ -/ -r -" -( -? -P -< -y -> -[ -0 -- -9 -] -{ -4 -} -) -- -( -? -P -< -m -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -P -< -d -> -[ -0 -- -9 -] -{ -2 -} -) -" -/ -/ -/ -) -? -; -/ -/ -/ -let -( -mut -cache -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -2010 -- -03 -- -14 -2016 -- -10 -- -08 -2020 -- -10 -- -22 -" -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -; -/ -/ -/ -let -mut -it -= -Searcher -: -: -new -( -input -) -/ -/ -/ -. -into_captures_iter -( -caps -| -input -caps -| -{ -/ -/ -/ -re -. -search -( -& -mut -cache -input -caps -) -; -/ -/ -/ -Ok -( -( -) -) -/ -/ -/ -} -) -; -/ -/ -/ -/ -/ -/ -let -got -= -it -. -next -( -) -. -expect -( -" -first -date -" -) -? -; -/ -/ -/ -let -year -= -got -. -get_group_by_name -( -" -y -" -) -. -expect -( -" -must -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -2010 -" -& -haystack -[ -year -] -) -; -/ -/ -/ -/ -/ -/ -let -got -= -it -. -next -( -) -. -expect -( -" -second -date -" -) -? -; -/ -/ -/ -let -month -= -got -. -get_group_by_name -( -" -m -" -) -. -expect -( -" -must -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -10 -" -& -haystack -[ -month -] -) -; -/ -/ -/ -/ -/ -/ -let -got -= -it -. -next -( -) -. -expect -( -" -third -date -" -) -? -; -/ -/ -/ -let -day -= -got -. -get_group_by_name -( -" -d -" -) -. -expect -( -" -must -match -" -) -; -/ -/ -/ -assert_eq -! -( -" -22 -" -& -haystack -[ -day -] -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -it -. -next -( -) -. -is_none -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -# -[ -inline -] -pub -fn -into_captures_iter -< -F -> -( -self -caps -: -Captures -finder -: -F -) -- -> -TryCapturesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -& -mut -Captures -) -- -> -Result -< -( -) -MatchError -> -{ -TryCapturesIter -{ -it -: -self -caps -finder -} -} -/ -/ -/ -Handles -the -special -case -of -a -match -that -begins -where -the -previous -/ -/ -/ -match -ended -. -Without -this -special -handling -it -' -d -be -possible -to -get -/ -/ -/ -stuck -where -an -empty -match -never -results -in -forward -progress -. -This -/ -/ -/ -also -makes -it -more -consistent -with -how -presiding -general -purpose -regex -/ -/ -/ -engines -work -. -# -[ -cold -] -# -[ -inline -( -never -) -] -fn -handle_overlapping_empty_half_match -< -F -> -( -& -mut -self -_ -: -HalfMatch -mut -finder -: -F -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -/ -/ -Since -we -are -only -here -when -' -m -. -offset -( -) -' -matches -the -offset -of -the -/ -/ -last -match -it -follows -that -this -must -have -been -an -empty -match -. -/ -/ -Since -we -both -need -to -make -progress -* -and -* -prevent -overlapping -/ -/ -matches -we -discard -this -match -and -advance -the -search -by -1 -. -/ -/ -/ -/ -Note -that -this -may -start -a -search -in -the -middle -of -a -codepoint -. -The -/ -/ -regex -engines -themselves -are -expected -to -deal -with -that -and -not -/ -/ -report -any -matches -within -a -codepoint -if -they -are -configured -in -/ -/ -UTF -- -8 -mode -. -self -. -input -. -set_start -( -self -. -input -. -start -( -) -. -checked_add -( -1 -) -. -unwrap -( -) -) -; -finder -( -& -self -. -input -) -} -/ -/ -/ -Handles -the -special -case -of -an -empty -match -by -ensuring -that -1 -) -the -/ -/ -/ -iterator -always -advances -and -2 -) -empty -matches -never -overlap -with -other -/ -/ -/ -matches -. -/ -/ -/ -/ -/ -/ -( -1 -) -is -necessary -because -we -principally -make -progress -by -setting -the -/ -/ -/ -starting -location -of -the -next -search -to -the -ending -location -of -the -last -/ -/ -/ -match -. -But -if -a -match -is -empty -then -this -results -in -a -search -that -does -/ -/ -/ -not -advance -and -thus -does -not -terminate -. -/ -/ -/ -/ -/ -/ -( -2 -) -is -not -strictly -necessary -but -makes -intuitive -sense -and -matches -/ -/ -/ -the -presiding -behavior -of -most -general -purpose -regex -engines -. -The -/ -/ -/ -" -intuitive -sense -" -here -is -that -we -want -to -report -NON -- -overlapping -/ -/ -/ -matches -. -So -for -example -given -the -regex -' -a -| -( -? -: -) -' -against -the -haystack -/ -/ -/ -' -a -' -without -the -special -handling -you -' -d -get -the -matches -[ -0 -1 -) -and -[ -1 -/ -/ -/ -1 -) -where -the -latter -overlaps -with -the -end -bounds -of -the -former -. -/ -/ -/ -/ -/ -/ -Note -that -we -mark -this -cold -and -forcefully -prevent -inlining -because -/ -/ -/ -handling -empty -matches -like -this -is -extremely -rare -and -does -require -/ -/ -/ -quite -a -bit -of -code -comparatively -. -Keeping -this -code -out -of -the -main -/ -/ -/ -iterator -function -keeps -it -smaller -and -more -amenable -to -inlining -/ -/ -/ -itself -. -# -[ -cold -] -# -[ -inline -( -never -) -] -fn -handle_overlapping_empty_match -< -F -> -( -& -mut -self -m -: -Match -mut -finder -: -F -) -- -> -Result -< -Option -< -Match -> -MatchError -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -assert -! -( -m -. -is_empty -( -) -) -; -self -. -input -. -set_start -( -self -. -input -. -start -( -) -. -checked_add -( -1 -) -. -unwrap -( -) -) -; -finder -( -& -self -. -input -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -half -matches -for -a -fallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -Result -< -HalfMatch -MatchError -> -value -until -no -more -/ -/ -/ -matches -could -be -found -. -/ -/ -/ -/ -/ -/ -The -type -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -F -represents -the -type -of -a -closure -that -executes -the -search -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -come -from -the -[ -Input -] -type -: -/ -/ -/ -/ -/ -/ -* -' -h -is -the -lifetime -of -the -underlying -haystack -. -/ -/ -/ -/ -/ -/ -When -possible -prefer -the -iterators -defined -on -the -regex -engine -you -' -re -/ -/ -/ -using -. -This -tries -to -abstract -over -the -regex -engine -and -is -thus -a -bit -more -/ -/ -/ -unwieldy -to -use -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Searcher -: -: -into_half_matches_iter -] -. -pub -struct -TryHalfMatchesIter -< -' -h -F -> -{ -it -: -Searcher -< -' -h -> -finder -: -F -} -impl -< -' -h -F -> -TryHalfMatchesIter -< -' -h -F -> -{ -/ -/ -/ -Return -an -infallible -version -of -this -iterator -. -/ -/ -/ -/ -/ -/ -Any -item -yielded -that -corresponds -to -an -error -results -in -a -panic -. -This -/ -/ -/ -is -useful -if -your -underlying -regex -engine -is -configured -in -a -way -that -/ -/ -/ -it -is -guaranteed -to -never -return -an -error -. -pub -fn -infallible -( -self -) -- -> -HalfMatchesIter -< -' -h -F -> -{ -HalfMatchesIter -( -self -) -} -/ -/ -/ -Returns -the -current -Input -used -by -this -iterator -. -/ -/ -/ -/ -/ -/ -The -Input -returned -is -generally -equivalent -to -the -one -used -to -/ -/ -/ -construct -this -iterator -but -its -start -position -may -be -different -to -/ -/ -/ -reflect -the -start -of -the -next -search -to -be -executed -. -pub -fn -input -< -' -i -> -( -& -' -i -self -) -- -> -& -' -i -Input -< -' -h -> -{ -self -. -it -. -input -( -) -} -} -impl -< -' -h -F -> -Iterator -for -TryHalfMatchesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -type -Item -= -Result -< -HalfMatch -MatchError -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Result -< -HalfMatch -MatchError -> -> -{ -self -. -it -. -try_advance_half -( -& -mut -self -. -finder -) -. -transpose -( -) -} -} -impl -< -' -h -F -> -core -: -: -fmt -: -: -Debug -for -TryHalfMatchesIter -< -' -h -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -TryHalfMatchesIter -" -) -. -field -( -" -it -" -& -self -. -it -) -. -field -( -" -finder -" -& -" -< -closure -> -" -) -. -finish -( -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -half -matches -for -an -infallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -HalfMatch -] -value -until -no -more -matches -could -be -/ -/ -/ -found -. -/ -/ -/ -/ -/ -/ -The -type -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -F -represents -the -type -of -a -closure -that -executes -the -search -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -come -from -the -[ -Input -] -type -: -/ -/ -/ -/ -/ -/ -* -' -h -is -the -lifetime -of -the -underlying -haystack -. -/ -/ -/ -/ -/ -/ -When -possible -prefer -the -iterators -defined -on -the -regex -engine -you -' -re -/ -/ -/ -using -. -This -tries -to -abstract -over -the -regex -engine -and -is -thus -a -bit -more -/ -/ -/ -unwieldy -to -use -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Searcher -: -: -into_half_matches_iter -] -and -/ -/ -/ -then -calling -[ -TryHalfMatchesIter -: -: -infallible -] -. -# -[ -derive -( -Debug -) -] -pub -struct -HalfMatchesIter -< -' -h -F -> -( -TryHalfMatchesIter -< -' -h -F -> -) -; -impl -< -' -h -F -> -HalfMatchesIter -< -' -h -F -> -{ -/ -/ -/ -Returns -the -current -Input -used -by -this -iterator -. -/ -/ -/ -/ -/ -/ -The -Input -returned -is -generally -equivalent -to -the -one -used -to -/ -/ -/ -construct -this -iterator -but -its -start -position -may -be -different -to -/ -/ -/ -reflect -the -start -of -the -next -search -to -be -executed -. -pub -fn -input -< -' -i -> -( -& -' -i -self -) -- -> -& -' -i -Input -< -' -h -> -{ -self -. -0 -. -it -. -input -( -) -} -} -impl -< -' -h -F -> -Iterator -for -HalfMatchesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -HalfMatch -> -MatchError -> -{ -type -Item -= -HalfMatch -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -HalfMatch -> -{ -match -self -. -0 -. -next -( -) -? -{ -Ok -( -m -) -= -> -Some -( -m -) -Err -( -err -) -= -> -panic -! -( -" -unexpected -regex -half -find -error -: -{ -} -\ -n -\ -to -handle -find -errors -use -' -try -' -or -' -search -' -methods -" -err -) -} -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -for -a -fallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -Result -< -Match -MatchError -> -value -until -no -more -/ -/ -/ -matches -could -be -found -. -/ -/ -/ -/ -/ -/ -The -type -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -F -represents -the -type -of -a -closure -that -executes -the -search -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -come -from -the -[ -Input -] -type -: -/ -/ -/ -/ -/ -/ -* -' -h -is -the -lifetime -of -the -underlying -haystack -. -/ -/ -/ -/ -/ -/ -When -possible -prefer -the -iterators -defined -on -the -regex -engine -you -' -re -/ -/ -/ -using -. -This -tries -to -abstract -over -the -regex -engine -and -is -thus -a -bit -more -/ -/ -/ -unwieldy -to -use -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Searcher -: -: -into_matches_iter -] -. -pub -struct -TryMatchesIter -< -' -h -F -> -{ -it -: -Searcher -< -' -h -> -finder -: -F -} -impl -< -' -h -F -> -TryMatchesIter -< -' -h -F -> -{ -/ -/ -/ -Return -an -infallible -version -of -this -iterator -. -/ -/ -/ -/ -/ -/ -Any -item -yielded -that -corresponds -to -an -error -results -in -a -panic -. -This -/ -/ -/ -is -useful -if -your -underlying -regex -engine -is -configured -in -a -way -that -/ -/ -/ -it -is -guaranteed -to -never -return -an -error -. -pub -fn -infallible -( -self -) -- -> -MatchesIter -< -' -h -F -> -{ -MatchesIter -( -self -) -} -/ -/ -/ -Returns -the -current -Input -used -by -this -iterator -. -/ -/ -/ -/ -/ -/ -The -Input -returned -is -generally -equivalent -to -the -one -used -to -/ -/ -/ -construct -this -iterator -but -its -start -position -may -be -different -to -/ -/ -/ -reflect -the -start -of -the -next -search -to -be -executed -. -pub -fn -input -< -' -i -> -( -& -' -i -self -) -- -> -& -' -i -Input -< -' -h -> -{ -self -. -it -. -input -( -) -} -} -impl -< -' -h -F -> -Iterator -for -TryMatchesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -type -Item -= -Result -< -Match -MatchError -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Result -< -Match -MatchError -> -> -{ -self -. -it -. -try_advance -( -& -mut -self -. -finder -) -. -transpose -( -) -} -} -impl -< -' -h -F -> -core -: -: -fmt -: -: -Debug -for -TryMatchesIter -< -' -h -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -TryMatchesIter -" -) -. -field -( -" -it -" -& -self -. -it -) -. -field -( -" -finder -" -& -" -< -closure -> -" -) -. -finish -( -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -for -an -infallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -Match -] -value -until -no -more -matches -could -be -found -. -/ -/ -/ -/ -/ -/ -The -type -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -F -represents -the -type -of -a -closure -that -executes -the -search -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -come -from -the -[ -Input -] -type -: -/ -/ -/ -/ -/ -/ -* -' -h -is -the -lifetime -of -the -underlying -haystack -. -/ -/ -/ -/ -/ -/ -When -possible -prefer -the -iterators -defined -on -the -regex -engine -you -' -re -/ -/ -/ -using -. -This -tries -to -abstract -over -the -regex -engine -and -is -thus -a -bit -more -/ -/ -/ -unwieldy -to -use -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Searcher -: -: -into_matches_iter -] -and -/ -/ -/ -then -calling -[ -TryMatchesIter -: -: -infallible -] -. -# -[ -derive -( -Debug -) -] -pub -struct -MatchesIter -< -' -h -F -> -( -TryMatchesIter -< -' -h -F -> -) -; -impl -< -' -h -F -> -MatchesIter -< -' -h -F -> -{ -/ -/ -/ -Returns -the -current -Input -used -by -this -iterator -. -/ -/ -/ -/ -/ -/ -The -Input -returned -is -generally -equivalent -to -the -one -used -to -/ -/ -/ -construct -this -iterator -but -its -start -position -may -be -different -to -/ -/ -/ -reflect -the -start -of -the -next -search -to -be -executed -. -pub -fn -input -< -' -i -> -( -& -' -i -self -) -- -> -& -' -i -Input -< -' -h -> -{ -self -. -0 -. -it -. -input -( -) -} -} -impl -< -' -h -F -> -Iterator -for -MatchesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -) -- -> -Result -< -Option -< -Match -> -MatchError -> -{ -type -Item -= -Match -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -> -{ -match -self -. -0 -. -next -( -) -? -{ -Ok -( -m -) -= -> -Some -( -m -) -Err -( -err -) -= -> -panic -! -( -" -unexpected -regex -find -error -: -{ -} -\ -n -\ -to -handle -find -errors -use -' -try -' -or -' -search -' -methods -" -err -) -} -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -captures -for -a -fallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -Result -< -Captures -MatchError -> -value -until -no -more -/ -/ -/ -matches -could -be -found -. -/ -/ -/ -/ -/ -/ -The -type -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -F -represents -the -type -of -a -closure -that -executes -the -search -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -come -from -the -[ -Input -] -type -: -/ -/ -/ -/ -/ -/ -* -' -h -is -the -lifetime -of -the -underlying -haystack -. -/ -/ -/ -/ -/ -/ -When -possible -prefer -the -iterators -defined -on -the -regex -engine -you -' -re -/ -/ -/ -using -. -This -tries -to -abstract -over -the -regex -engine -and -is -thus -a -bit -more -/ -/ -/ -unwieldy -to -use -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Searcher -: -: -into_captures_iter -] -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -struct -TryCapturesIter -< -' -h -F -> -{ -it -: -Searcher -< -' -h -> -caps -: -Captures -finder -: -F -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -' -h -F -> -TryCapturesIter -< -' -h -F -> -{ -/ -/ -/ -Return -an -infallible -version -of -this -iterator -. -/ -/ -/ -/ -/ -/ -Any -item -yielded -that -corresponds -to -an -error -results -in -a -panic -. -This -/ -/ -/ -is -useful -if -your -underlying -regex -engine -is -configured -in -a -way -that -/ -/ -/ -it -is -guaranteed -to -never -return -an -error -. -pub -fn -infallible -( -self -) -- -> -CapturesIter -< -' -h -F -> -{ -CapturesIter -( -self -) -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -' -h -F -> -Iterator -for -TryCapturesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -& -mut -Captures -) -- -> -Result -< -( -) -MatchError -> -{ -type -Item -= -Result -< -Captures -MatchError -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Result -< -Captures -MatchError -> -> -{ -let -TryCapturesIter -{ -ref -mut -it -ref -mut -caps -ref -mut -finder -} -= -* -self -; -let -result -= -it -. -try_advance -( -| -input -| -{ -( -finder -) -( -input -caps -) -? -; -Ok -( -caps -. -get_match -( -) -) -} -) -. -transpose -( -) -? -; -match -result -{ -Ok -( -_ -) -= -> -Some -( -Ok -( -caps -. -clone -( -) -) -) -Err -( -err -) -= -> -Some -( -Err -( -err -) -) -} -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -' -h -F -> -core -: -: -fmt -: -: -Debug -for -TryCapturesIter -< -' -h -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -TryCapturesIter -" -) -. -field -( -" -it -" -& -self -. -it -) -. -field -( -" -caps -" -& -self -. -caps -) -. -field -( -" -finder -" -& -" -< -closure -> -" -) -. -finish -( -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -captures -for -an -infallible -search -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -a -[ -Captures -] -value -until -no -more -matches -could -be -/ -/ -/ -found -. -/ -/ -/ -/ -/ -/ -The -type -parameters -are -as -follows -: -/ -/ -/ -/ -/ -/ -* -F -represents -the -type -of -a -closure -that -executes -the -search -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameters -come -from -the -[ -Input -] -type -: -/ -/ -/ -/ -/ -/ -* -' -h -is -the -lifetime -of -the -underlying -haystack -. -/ -/ -/ -/ -/ -/ -When -possible -prefer -the -iterators -defined -on -the -regex -engine -you -' -re -/ -/ -/ -using -. -This -tries -to -abstract -over -the -regex -engine -and -is -thus -a -bit -more -/ -/ -/ -unwieldy -to -use -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Searcher -: -: -into_captures_iter -] -and -then -/ -/ -/ -calling -[ -TryCapturesIter -: -: -infallible -] -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -# -[ -derive -( -Debug -) -] -pub -struct -CapturesIter -< -' -h -F -> -( -TryCapturesIter -< -' -h -F -> -) -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -' -h -F -> -Iterator -for -CapturesIter -< -' -h -F -> -where -F -: -FnMut -( -& -Input -< -' -_ -> -& -mut -Captures -) -- -> -Result -< -( -) -MatchError -> -{ -type -Item -= -Captures -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Captures -> -{ -match -self -. -0 -. -next -( -) -? -{ -Ok -( -m -) -= -> -Some -( -m -) -Err -( -err -) -= -> -panic -! -( -" -unexpected -regex -captures -error -: -{ -} -\ -n -\ -to -handle -find -errors -use -' -try -' -or -' -search -' -methods -" -err -) -} -} -} diff --git a/third_party/rust/regex-automata/src/util/lazy.rs b/third_party/rust/regex-automata/src/util/lazy.rs deleted file mode 100644 index eb2f6dea4968d..0000000000000 --- a/third_party/rust/regex-automata/src/util/lazy.rs +++ /dev/null @@ -1,4452 +0,0 @@ -/ -* -! -A -lazily -initialized -value -for -safe -sharing -between -threads -. -The -principal -type -in -this -module -is -Lazy -which -makes -it -easy -to -construct -values -that -are -shared -safely -across -multiple -threads -simultaneously -. -* -/ -use -core -: -: -fmt -; -/ -/ -/ -A -lazily -initialized -value -that -implements -Deref -for -T -. -/ -/ -/ -/ -/ -/ -A -Lazy -takes -an -initialization -function -and -permits -callers -from -any -/ -/ -/ -thread -to -access -the -result -of -that -initialization -function -in -a -safe -/ -/ -/ -manner -. -In -effect -this -permits -one -- -time -initialization -of -global -resources -/ -/ -/ -in -a -( -possibly -) -multi -- -threaded -program -. -/ -/ -/ -/ -/ -/ -This -type -and -its -functionality -are -available -even -when -neither -the -alloc -/ -/ -/ -nor -the -std -features -are -enabled -. -In -exchange -a -Lazy -does -* -* -not -* -* -/ -/ -/ -guarantee -that -the -given -create -function -is -called -at -most -once -. -It -/ -/ -/ -might -be -called -multiple -times -. -Moreover -a -call -to -Lazy -: -: -get -( -either -/ -/ -/ -explicitly -or -implicitly -via -Lazy -' -s -Deref -impl -) -may -block -until -a -T -/ -/ -/ -is -available -. -/ -/ -/ -/ -/ -/ -This -is -very -similar -to -lazy_static -or -once_cell -except -it -doesn -' -t -/ -/ -/ -guarantee -that -the -initialization -function -will -be -run -once -and -it -works -/ -/ -/ -in -no -- -alloc -no -- -std -environments -. -With -that -said -if -you -need -stronger -/ -/ -/ -guarantees -or -a -more -flexible -API -then -it -is -recommended -to -use -either -/ -/ -/ -lazy_static -or -once_cell -. -/ -/ -/ -/ -/ -/ -# -Warning -: -may -use -a -spin -lock -/ -/ -/ -/ -/ -/ -When -this -crate -is -compiled -_without_ -the -alloc -feature -then -this -type -/ -/ -/ -may -used -a -spin -lock -internally -. -This -can -have -subtle -effects -that -may -/ -/ -/ -be -undesirable -. -See -[ -Spinlocks -Considered -Harmful -] -[ -spinharm -] -for -a -more -/ -/ -/ -thorough -treatment -of -this -topic -. -/ -/ -/ -/ -/ -/ -[ -spinharm -] -: -https -: -/ -/ -matklad -. -github -. -io -/ -2020 -/ -01 -/ -02 -/ -spinlocks -- -considered -- -harmful -. -html -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -type -is -useful -for -creating -regexes -once -and -then -using -them -from -/ -/ -/ -multiple -threads -simultaneously -without -worrying -about -synchronization -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -dfa -: -: -regex -: -: -Regex -util -: -: -lazy -: -: -Lazy -Match -} -; -/ -/ -/ -/ -/ -/ -static -RE -: -Lazy -< -Regex -> -= -Lazy -: -: -new -( -| -| -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -. -unwrap -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -3 -. -. -14 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -RE -. -find -( -b -" -zzzfoo12345barzzz -" -) -) -; -/ -/ -/ -pub -struct -Lazy -< -T -F -= -fn -( -) -- -> -T -> -( -lazy -: -: -Lazy -< -T -F -> -) -; -impl -< -T -F -> -Lazy -< -T -F -> -{ -/ -/ -/ -Create -a -new -Lazy -value -that -is -initialized -via -the -given -function -. -/ -/ -/ -/ -/ -/ -The -T -type -is -automatically -inferred -from -the -return -type -of -the -/ -/ -/ -create -function -given -. -pub -const -fn -new -( -create -: -F -) -- -> -Lazy -< -T -F -> -{ -Lazy -( -lazy -: -: -Lazy -: -: -new -( -create -) -) -} -} -impl -< -T -F -: -Fn -( -) -- -> -T -> -Lazy -< -T -F -> -{ -/ -/ -/ -Return -a -reference -to -the -lazily -initialized -value -. -/ -/ -/ -/ -/ -/ -This -routine -may -block -if -another -thread -is -initializing -a -T -. -/ -/ -/ -/ -/ -/ -Note -that -given -a -x -which -has -type -Lazy -this -must -be -called -via -/ -/ -/ -Lazy -: -: -get -( -x -) -and -not -x -. -get -( -) -. -This -routine -is -defined -this -way -/ -/ -/ -because -Lazy -impls -Deref -with -a -target -of -T -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -create -function -inside -this -lazy -value -panics -. -/ -/ -/ -If -the -panic -occurred -in -another -thread -then -this -routine -_may_ -also -/ -/ -/ -panic -( -but -is -not -guaranteed -to -do -so -) -. -pub -fn -get -( -this -: -& -Lazy -< -T -F -> -) -- -> -& -T -{ -this -. -0 -. -get -( -) -} -} -impl -< -T -F -: -Fn -( -) -- -> -T -> -core -: -: -ops -: -: -Deref -for -Lazy -< -T -F -> -{ -type -Target -= -T -; -fn -deref -( -& -self -) -- -> -& -T -{ -Lazy -: -: -get -( -self -) -} -} -impl -< -T -: -fmt -: -: -Debug -F -: -Fn -( -) -- -> -T -> -fmt -: -: -Debug -for -Lazy -< -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -) -- -> -fmt -: -: -Result -{ -self -. -0 -. -fmt -( -f -) -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -mod -lazy -{ -use -core -: -: -{ -fmt -marker -: -: -PhantomData -sync -: -: -atomic -: -: -{ -AtomicPtr -Ordering -} -} -; -use -alloc -: -: -boxed -: -: -Box -; -/ -/ -/ -A -non -- -std -lazy -initialized -value -. -/ -/ -/ -/ -/ -/ -This -might -run -the -initialization -function -more -than -once -but -will -/ -/ -/ -never -block -. -/ -/ -/ -/ -/ -/ -I -wish -I -could -get -these -semantics -into -the -non -- -alloc -non -- -std -Lazy -/ -/ -/ -type -below -but -I -' -m -not -sure -how -to -do -it -. -If -you -can -do -an -alloc -/ -/ -/ -then -the -implementation -becomes -very -simple -if -you -don -' -t -care -about -/ -/ -/ -redundant -work -precisely -because -a -pointer -can -be -atomically -swapped -. -/ -/ -/ -/ -/ -/ -Perhaps -making -this -approach -work -in -the -non -- -alloc -non -- -std -case -/ -/ -/ -requires -asking -the -caller -for -a -pointer -? -It -would -make -the -API -less -/ -/ -/ -convenient -I -think -. -pub -( -super -) -struct -Lazy -< -T -F -> -{ -data -: -AtomicPtr -< -T -> -create -: -F -/ -/ -This -indicates -to -the -compiler -that -this -type -can -drop -T -. -It -' -s -not -/ -/ -totally -clear -how -the -absence -of -this -marker -could -lead -to -trouble -/ -/ -but -putting -here -doesn -' -t -have -any -downsides -so -we -hedge -until -somone -/ -/ -can -from -the -Unsafe -Working -Group -can -tell -us -definitively -that -we -/ -/ -don -' -t -need -it -. -/ -/ -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -regex -- -automata -/ -issues -/ -30 -owned -: -PhantomData -< -Box -< -T -> -> -} -/ -/ -SAFETY -: -So -long -as -T -and -& -T -( -and -F -and -& -F -) -can -themselves -be -safely -/ -/ -shared -among -threads -so -to -can -a -Lazy -< -T -_ -> -. -Namely -the -Lazy -API -only -/ -/ -permits -accessing -a -& -T -and -initialization -is -free -of -data -races -. -So -if -T -/ -/ -is -thread -safe -then -so -to -is -Lazy -< -T -_ -> -. -/ -/ -/ -/ -We -specifically -require -that -T -: -Send -in -order -for -Lazy -< -T -> -to -be -Sync -. -/ -/ -Without -that -requirement -it -' -s -possible -to -send -a -T -from -one -thread -to -/ -/ -another -via -Lazy -' -s -destructor -. -/ -/ -/ -/ -It -' -s -not -clear -whether -we -need -F -: -Send -+ -Sync -for -Lazy -to -be -Sync -. -But -/ -/ -we -' -re -conservative -for -now -and -keep -both -. -unsafe -impl -< -T -: -Send -+ -Sync -F -: -Send -+ -Sync -> -Sync -for -Lazy -< -T -F -> -{ -} -impl -< -T -F -> -Lazy -< -T -F -> -{ -/ -/ -/ -Create -a -new -alloc -but -non -- -std -lazy -value -that -is -racily -/ -/ -/ -initialized -. -That -is -the -' -create -' -function -may -be -called -more -than -/ -/ -/ -once -. -pub -( -super -) -const -fn -new -( -create -: -F -) -- -> -Lazy -< -T -F -> -{ -Lazy -{ -data -: -AtomicPtr -: -: -new -( -core -: -: -ptr -: -: -null_mut -( -) -) -create -owned -: -PhantomData -} -} -} -impl -< -T -F -: -Fn -( -) -- -> -T -> -Lazy -< -T -F -> -{ -/ -/ -/ -Get -the -underlying -lazy -value -. -If -it -hasn -' -t -been -initialized -/ -/ -/ -yet -then -always -attempt -to -initialize -it -( -even -if -some -other -/ -/ -/ -thread -is -initializing -it -) -and -atomically -attach -it -to -this -lazy -/ -/ -/ -value -before -returning -it -. -pub -( -super -) -fn -get -( -& -self -) -- -> -& -T -{ -if -let -Some -( -data -) -= -self -. -poll -( -) -{ -return -data -; -} -let -data -= -( -self -. -create -) -( -) -; -let -mut -ptr -= -Box -: -: -into_raw -( -Box -: -: -new -( -data -) -) -; -/ -/ -We -attempt -to -stuff -our -initialized -value -into -our -atomic -/ -/ -pointer -. -Upon -success -we -don -' -t -need -to -do -anything -. -But -if -/ -/ -someone -else -beat -us -to -the -punch -then -we -need -to -make -sure -/ -/ -our -newly -created -value -is -dropped -. -let -result -= -self -. -data -. -compare_exchange -( -core -: -: -ptr -: -: -null_mut -( -) -ptr -Ordering -: -: -AcqRel -Ordering -: -: -Acquire -) -; -if -let -Err -( -old -) -= -result -{ -/ -/ -SAFETY -: -We -created -' -ptr -' -via -Box -: -: -into_raw -above -so -turning -/ -/ -it -back -into -a -Box -via -from_raw -is -safe -. -drop -( -unsafe -{ -Box -: -: -from_raw -( -ptr -) -} -) -; -ptr -= -old -; -} -/ -/ -SAFETY -: -We -just -set -the -pointer -above -to -a -non -- -null -value -even -/ -/ -in -the -error -case -and -set -it -to -a -fully -initialized -value -/ -/ -returned -by -' -create -' -. -unsafe -{ -& -* -ptr -} -} -/ -/ -/ -If -this -lazy -value -has -been -initialized -successfully -then -return -/ -/ -/ -that -value -. -Otherwise -return -None -immediately -. -This -never -attempts -/ -/ -/ -to -run -initialization -itself -. -fn -poll -( -& -self -) -- -> -Option -< -& -T -> -{ -let -ptr -= -self -. -data -. -load -( -Ordering -: -: -Acquire -) -; -if -ptr -. -is_null -( -) -{ -return -None -; -} -/ -/ -SAFETY -: -We -just -checked -that -the -pointer -is -not -null -. -Since -it -' -s -/ -/ -not -null -it -must -have -been -fully -initialized -by -' -get -' -at -some -/ -/ -point -. -Some -( -unsafe -{ -& -* -ptr -} -) -} -} -impl -< -T -: -fmt -: -: -Debug -F -: -Fn -( -) -- -> -T -> -fmt -: -: -Debug -for -Lazy -< -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -) -- -> -fmt -: -: -Result -{ -f -. -debug_struct -( -" -Lazy -" -) -. -field -( -" -data -" -& -self -. -poll -( -) -) -. -finish -( -) -} -} -impl -< -T -F -> -Drop -for -Lazy -< -T -F -> -{ -fn -drop -( -& -mut -self -) -{ -let -ptr -= -* -self -. -data -. -get_mut -( -) -; -if -! -ptr -. -is_null -( -) -{ -/ -/ -SAFETY -: -We -just -checked -that -' -ptr -' -is -not -null -. -And -since -/ -/ -we -have -exclusive -access -there -are -no -races -to -worry -about -. -drop -( -unsafe -{ -Box -: -: -from_raw -( -ptr -) -} -) -; -} -} -} -} -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -mod -lazy -{ -use -core -: -: -{ -cell -: -: -Cell -fmt -mem -: -: -MaybeUninit -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -sync -: -: -atomic -: -: -{ -AtomicU8 -Ordering -} -} -; -/ -/ -/ -Our -' -Lazy -' -value -can -be -in -one -of -three -states -: -/ -/ -/ -/ -/ -/ -* -INIT -is -where -it -starts -and -also -ends -up -back -here -if -the -/ -/ -/ -' -create -' -routine -panics -. -/ -/ -/ -* -BUSY -is -where -it -sits -while -initialization -is -running -in -exactly -/ -/ -/ -one -thread -. -/ -/ -/ -* -DONE -is -where -it -sits -after -' -create -' -has -completed -and -' -data -' -has -/ -/ -/ -been -fully -initialized -. -const -LAZY_STATE_INIT -: -u8 -= -0 -; -const -LAZY_STATE_BUSY -: -u8 -= -1 -; -const -LAZY_STATE_DONE -: -u8 -= -2 -; -/ -/ -/ -A -non -- -alloc -non -- -std -lazy -initialized -value -. -/ -/ -/ -/ -/ -/ -This -guarantees -initialization -only -happens -once -but -uses -a -spinlock -/ -/ -/ -to -block -in -the -case -of -simultaneous -access -. -Blocking -occurs -so -that -/ -/ -/ -one -thread -waits -while -another -thread -initializes -the -value -. -/ -/ -/ -/ -/ -/ -I -would -much -rather -have -the -semantics -of -the -' -alloc -' -Lazy -type -above -. -/ -/ -/ -Namely -that -we -might -run -the -initialization -function -more -than -once -/ -/ -/ -but -we -never -otherwise -block -. -However -I -don -' -t -know -how -to -do -that -in -/ -/ -/ -a -non -- -alloc -non -- -std -context -. -pub -( -super -) -struct -Lazy -< -T -F -> -{ -state -: -AtomicU8 -create -: -Cell -< -Option -< -F -> -> -data -: -Cell -< -MaybeUninit -< -T -> -> -} -/ -/ -SAFETY -: -So -long -as -T -and -& -T -( -and -F -and -& -F -) -can -themselves -be -safely -/ -/ -shared -among -threads -so -to -can -a -Lazy -< -T -_ -> -. -Namely -the -Lazy -API -only -/ -/ -permits -accessing -a -& -T -and -initialization -is -free -of -data -races -. -So -if -T -/ -/ -is -thread -safe -then -so -to -is -Lazy -< -T -_ -> -. -unsafe -impl -< -T -: -Send -+ -Sync -F -: -Send -+ -Sync -> -Sync -for -Lazy -< -T -F -> -{ -} -/ -/ -A -reference -to -a -Lazy -is -unwind -safe -because -we -specifically -take -/ -/ -precautions -to -poison -all -accesses -to -a -Lazy -if -the -caller -- -provided -/ -/ -' -create -' -function -panics -. -impl -< -T -: -UnwindSafe -F -: -UnwindSafe -+ -RefUnwindSafe -> -RefUnwindSafe -for -Lazy -< -T -F -> -{ -} -impl -< -T -F -> -Lazy -< -T -F -> -{ -/ -/ -/ -Create -a -new -non -- -alloc -non -- -std -lazy -value -that -is -initialized -/ -/ -/ -exactly -once -on -first -use -using -the -given -function -. -pub -( -super -) -const -fn -new -( -create -: -F -) -- -> -Lazy -< -T -F -> -{ -Lazy -{ -state -: -AtomicU8 -: -: -new -( -LAZY_STATE_INIT -) -create -: -Cell -: -: -new -( -Some -( -create -) -) -data -: -Cell -: -: -new -( -MaybeUninit -: -: -uninit -( -) -) -} -} -} -impl -< -T -F -: -FnOnce -( -) -- -> -T -> -Lazy -< -T -F -> -{ -/ -/ -/ -Get -the -underlying -lazy -value -. -If -it -isn -' -t -been -initialized -/ -/ -/ -yet -then -either -initialize -it -or -block -until -some -other -thread -/ -/ -/ -initializes -it -. -If -the -' -create -' -function -given -to -Lazy -: -: -new -panics -/ -/ -/ -( -even -in -another -thread -) -then -this -panics -too -. -pub -( -super -) -fn -get -( -& -self -) -- -> -& -T -{ -/ -/ -This -is -effectively -a -spinlock -. -We -loop -until -we -enter -a -DONE -/ -/ -state -and -if -possible -initialize -it -ourselves -. -The -only -way -/ -/ -we -exit -the -loop -is -if -' -create -' -panics -we -initialize -' -data -' -or -/ -/ -some -other -thread -initializes -' -data -' -. -/ -/ -/ -/ -Yes -I -have -read -spinlocks -considered -harmful -[ -1 -] -. -And -that -/ -/ -article -is -why -this -spinlock -is -only -active -when -' -alloc -' -isn -' -t -/ -/ -enabled -. -I -did -this -because -I -don -' -t -think -there -is -really -/ -/ -another -choice -without -' -alloc -' -other -than -not -providing -this -at -/ -/ -all -. -But -I -think -that -' -s -a -big -bummer -. -/ -/ -/ -/ -[ -1 -] -: -https -: -/ -/ -matklad -. -github -. -io -/ -2020 -/ -01 -/ -02 -/ -spinlocks -- -considered -- -harmful -. -html -while -self -. -state -. -load -( -Ordering -: -: -Acquire -) -! -= -LAZY_STATE_DONE -{ -/ -/ -Check -if -we -' -re -the -first -ones -to -get -here -. -If -so -we -' -ll -be -/ -/ -the -ones -who -initialize -. -let -result -= -self -. -state -. -compare_exchange -( -LAZY_STATE_INIT -LAZY_STATE_BUSY -Ordering -: -: -AcqRel -Ordering -: -: -Acquire -) -; -/ -/ -This -means -we -saw -the -INIT -state -and -nobody -else -can -. -So -we -/ -/ -must -take -responsibility -for -initializing -. -And -by -virtue -of -/ -/ -observing -INIT -we -have -also -told -anyone -else -trying -to -/ -/ -get -here -that -we -are -BUSY -. -If -someone -else -sees -BUSY -then -/ -/ -they -will -spin -until -we -finish -initialization -. -if -let -Ok -( -_ -) -= -result -{ -/ -/ -Since -we -are -guaranteed -to -be -the -only -ones -here -we -/ -/ -know -that -' -create -' -is -there -. -. -. -Unless -someone -else -got -/ -/ -here -before -us -and -' -create -' -panicked -. -In -which -case -/ -/ -' -self -. -create -' -is -now -' -None -' -and -we -forward -the -panic -/ -/ -to -the -caller -. -( -i -. -e -. -We -implement -poisoning -. -) -/ -/ -/ -/ -SAFETY -: -Our -use -of -' -self -. -state -' -guarantees -that -we -are -/ -/ -the -only -thread -executing -this -line -and -thus -there -are -/ -/ -no -races -. -let -create -= -unsafe -{ -( -* -self -. -create -. -as_ptr -( -) -) -. -take -( -) -. -expect -( -" -Lazy -' -s -create -function -panicked -\ -preventing -initialization -poisoning -current -thread -" -) -} -; -let -guard -= -Guard -{ -state -: -& -self -. -state -} -; -/ -/ -SAFETY -: -Our -use -of -' -self -. -state -' -guarantees -that -we -are -/ -/ -the -only -thread -executing -this -line -and -thus -there -are -/ -/ -no -races -. -unsafe -{ -( -* -self -. -data -. -as_ptr -( -) -) -. -as_mut_ptr -( -) -. -write -( -create -( -) -) -; -} -/ -/ -All -is -well -. -' -self -. -create -' -ran -successfully -so -we -/ -/ -forget -the -guard -. -core -: -: -mem -: -: -forget -( -guard -) -; -/ -/ -Everything -is -initialized -so -we -can -declare -success -. -self -. -state -. -store -( -LAZY_STATE_DONE -Ordering -: -: -Release -) -; -break -; -} -core -: -: -hint -: -: -spin_loop -( -) -; -} -/ -/ -We -only -get -here -if -data -is -fully -initialized -and -thus -poll -/ -/ -will -always -return -something -. -self -. -poll -( -) -. -unwrap -( -) -} -/ -/ -/ -If -this -lazy -value -has -been -initialized -successfully -then -return -/ -/ -/ -that -value -. -Otherwise -return -None -immediately -. -This -never -blocks -. -fn -poll -( -& -self -) -- -> -Option -< -& -T -> -{ -if -self -. -state -. -load -( -Ordering -: -: -Acquire -) -= -= -LAZY_STATE_DONE -{ -/ -/ -SAFETY -: -The -DONE -state -only -occurs -when -data -has -been -fully -/ -/ -initialized -. -Some -( -unsafe -{ -& -* -( -* -self -. -data -. -as_ptr -( -) -) -. -as_ptr -( -) -} -) -} -else -{ -None -} -} -} -impl -< -T -: -fmt -: -: -Debug -F -: -FnMut -( -) -- -> -T -> -fmt -: -: -Debug -for -Lazy -< -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -fmt -: -: -Formatter -) -- -> -fmt -: -: -Result -{ -f -. -debug_struct -( -" -Lazy -" -) -. -field -( -" -state -" -& -self -. -state -. -load -( -Ordering -: -: -Acquire -) -) -. -field -( -" -create -" -& -" -< -closure -> -" -) -. -field -( -" -data -" -& -self -. -poll -( -) -) -. -finish -( -) -} -} -impl -< -T -F -> -Drop -for -Lazy -< -T -F -> -{ -fn -drop -( -& -mut -self -) -{ -if -* -self -. -state -. -get_mut -( -) -= -= -LAZY_STATE_DONE -{ -/ -/ -SAFETY -: -state -is -DONE -if -and -only -if -data -has -been -fully -/ -/ -initialized -. -At -which -point -it -is -safe -to -drop -. -unsafe -{ -/ -/ -MSRV -( -1 -. -60 -) -: -Use -assume_init_drop -. -The -below -is -how -/ -/ -assume_init_drop -is -implemented -. -core -: -: -ptr -: -: -drop_in_place -( -( -* -self -. -data -. -as_ptr -( -) -) -. -as_mut_ptr -( -) -) -} -} -} -} -/ -/ -/ -A -guard -that -will -reset -a -Lazy -' -s -state -back -to -INIT -when -dropped -. -The -/ -/ -/ -idea -here -is -to -' -forget -' -this -guard -on -success -. -On -failure -( -when -a -/ -/ -/ -panic -occurs -) -the -Drop -impl -runs -and -causes -all -in -- -progress -and -future -/ -/ -/ -' -get -' -calls -to -panic -. -Without -this -guard -all -in -- -progress -and -future -/ -/ -/ -' -get -' -calls -would -spin -forever -. -Crashing -is -much -better -than -getting -/ -/ -/ -stuck -in -an -infinite -loop -. -struct -Guard -< -' -a -> -{ -state -: -& -' -a -AtomicU8 -} -impl -< -' -a -> -Drop -for -Guard -< -' -a -> -{ -fn -drop -( -& -mut -self -) -{ -/ -/ -We -force -ourselves -back -into -an -INIT -state -. -This -will -in -turn -/ -/ -cause -any -future -' -get -' -calls -to -attempt -calling -' -self -. -create -' -/ -/ -again -which -will -in -turn -panic -because -' -self -. -create -' -will -now -/ -/ -be -' -None -' -. -self -. -state -. -store -( -LAZY_STATE_INIT -Ordering -: -: -Release -) -; -} -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -super -: -: -* -; -fn -assert_send -< -T -: -Send -> -( -) -{ -} -fn -assert_sync -< -T -: -Sync -> -( -) -{ -} -fn -assert_unwind -< -T -: -core -: -: -panic -: -: -UnwindSafe -> -( -) -{ -} -fn -assert_refunwind -< -T -: -core -: -: -panic -: -: -RefUnwindSafe -> -( -) -{ -} -# -[ -test -] -fn -oibits -( -) -{ -assert_send -: -: -< -Lazy -< -u64 -> -> -( -) -; -assert_sync -: -: -< -Lazy -< -u64 -> -> -( -) -; -assert_unwind -: -: -< -Lazy -< -u64 -> -> -( -) -; -assert_refunwind -: -: -< -Lazy -< -u64 -> -> -( -) -; -} -/ -/ -This -is -a -regression -test -because -we -used -to -rely -on -the -inferred -Sync -/ -/ -impl -for -the -Lazy -type -defined -above -( -for -' -alloc -' -mode -) -. -In -the -/ -/ -inferred -impl -it -only -requires -that -T -: -Sync -for -Lazy -< -T -> -: -Sync -. -But -/ -/ -if -we -have -that -we -can -actually -make -use -of -the -fact -that -Lazy -< -T -> -drops -/ -/ -T -to -create -a -value -on -one -thread -and -drop -it -on -another -. -This -* -should -* -/ -/ -require -T -: -Send -but -our -missing -bounds -before -let -it -sneak -by -. -/ -/ -/ -/ -Basically -this -test -should -not -compile -so -we -. -. -. -comment -it -out -. -We -/ -/ -don -' -t -have -a -great -way -of -testing -compile -- -fail -tests -right -now -. -/ -/ -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -regex -- -automata -/ -issues -/ -30 -/ -* -# -[ -test -] -fn -sync_not_send -( -) -{ -# -[ -allow -( -dead_code -) -] -fn -inner -< -T -: -Sync -+ -Default -> -( -) -{ -let -lazy -= -Lazy -: -: -new -( -move -| -| -T -: -: -default -( -) -) -; -std -: -: -thread -: -: -scope -( -| -scope -| -{ -scope -. -spawn -( -| -| -{ -Lazy -: -: -get -( -& -lazy -) -; -/ -/ -We -create -T -in -this -thread -} -) -; -} -) -; -/ -/ -And -drop -in -this -thread -. -drop -( -lazy -) -; -/ -/ -So -we -have -send -a -! -Send -type -over -threads -. -( -with -some -more -/ -/ -legwork -its -possible -to -even -sneak -the -value -out -of -drop -/ -/ -through -thread -local -) -} -} -* -/ -} diff --git a/third_party/rust/regex-automata/src/util/look.rs b/third_party/rust/regex-automata/src/util/look.rs deleted file mode 100644 index 7995c58b1a254..0000000000000 --- a/third_party/rust/regex-automata/src/util/look.rs +++ /dev/null @@ -1,16152 +0,0 @@ -/ -* -! -Types -and -routines -for -working -with -look -- -around -assertions -. -This -module -principally -defines -two -types -: -* -[ -Look -] -enumerates -all -of -the -assertions -supported -by -this -crate -. -* -[ -LookSet -] -provides -a -way -to -efficiently -store -a -set -of -[ -Look -] -values -. -* -[ -LookMatcher -] -provides -routines -for -checking -whether -a -Look -or -a -LookSet -matches -at -a -particular -position -in -a -haystack -. -* -/ -/ -/ -LAMENTATION -: -Sadly -a -lot -of -the -API -of -Look -and -LookSet -were -basically -/ -/ -copied -verbatim -from -the -regex -- -syntax -crate -. -I -would -have -no -problems -using -/ -/ -the -regex -- -syntax -types -and -defining -the -matching -routines -( -only -found -/ -/ -in -this -crate -) -as -free -functions -except -the -Look -and -LookSet -types -/ -/ -are -used -in -lots -of -places -. -Including -in -places -we -expect -to -work -when -/ -/ -regex -- -syntax -is -* -not -* -enabled -such -as -in -the -definition -of -the -NFA -itself -. -/ -/ -/ -/ -Thankfully -the -code -we -copy -is -pretty -simple -and -there -isn -' -t -much -of -it -. -/ -/ -Otherwise -the -rest -of -this -module -deals -with -* -matching -* -the -assertions -/ -/ -which -is -not -something -that -regex -- -syntax -handles -. -use -crate -: -: -util -: -: -{ -escape -: -: -DebugByte -utf8 -} -; -/ -/ -/ -A -look -- -around -assertion -. -/ -/ -/ -/ -/ -/ -An -assertion -matches -at -a -position -between -characters -in -a -haystack -. -/ -/ -/ -Namely -it -does -not -actually -" -consume -" -any -input -as -most -parts -of -a -regular -/ -/ -/ -expression -do -. -Assertions -are -a -way -of -stating -that -some -property -must -be -/ -/ -/ -true -at -a -particular -point -during -matching -. -/ -/ -/ -/ -/ -/ -For -example -( -? -m -) -^ -[ -a -- -z -] -+ -is -a -pattern -that -: -/ -/ -/ -/ -/ -/ -* -Scans -the -haystack -for -a -position -at -which -( -? -m -: -^ -) -is -satisfied -. -That -/ -/ -/ -occurs -at -either -the -beginning -of -the -haystack -or -immediately -following -/ -/ -/ -a -\ -n -character -. -/ -/ -/ -* -Looks -for -one -or -more -occurrences -of -[ -a -- -z -] -. -/ -/ -/ -* -Once -[ -a -- -z -] -+ -has -matched -as -much -as -it -can -an -overall -match -is -only -/ -/ -/ -reported -when -[ -a -- -z -] -+ -stops -just -before -a -\ -n -. -/ -/ -/ -/ -/ -/ -So -in -this -case -abc -and -\ -nabc -\ -n -match -but -\ -nabc1 -\ -n -does -not -. -/ -/ -/ -/ -/ -/ -Assertions -are -also -called -" -look -- -around -" -" -look -- -behind -" -and -" -look -- -ahead -. -" -/ -/ -/ -Specifically -some -assertions -are -look -- -behind -( -like -^ -) -other -assertions -/ -/ -/ -are -look -- -ahead -( -like -) -and -yet -other -assertions -are -both -look -- -ahead -and -/ -/ -/ -look -- -behind -( -like -\ -b -) -. -/ -/ -/ -/ -/ -/ -# -Assertions -in -an -NFA -/ -/ -/ -/ -/ -/ -An -assertion -in -a -[ -thompson -: -: -NFA -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -) -can -be -/ -/ -/ -thought -of -as -a -conditional -epsilon -transition -. -That -is -a -matching -engine -/ -/ -/ -like -the -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -only -permits -/ -/ -/ -moving -through -conditional -epsilon -transitions -when -their -condition -/ -/ -/ -is -satisfied -at -whatever -position -the -PikeVM -is -currently -at -in -the -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -How -assertions -are -handled -in -a -DFA -is -trickier -since -a -DFA -does -not -/ -/ -/ -have -epsilon -transitions -at -all -. -In -this -case -they -are -compiled -into -the -/ -/ -/ -automaton -itself -at -the -expense -of -more -states -than -what -would -be -required -/ -/ -/ -without -an -assertion -. -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -Look -{ -/ -/ -/ -Match -the -beginning -of -text -. -Specifically -this -matches -at -the -starting -/ -/ -/ -position -of -the -input -. -Start -= -1 -< -< -0 -/ -/ -/ -Match -the -end -of -text -. -Specifically -this -matches -at -the -ending -/ -/ -/ -position -of -the -input -. -End -= -1 -< -< -1 -/ -/ -/ -Match -the -beginning -of -a -line -or -the -beginning -of -text -. -Specifically -/ -/ -/ -this -matches -at -the -starting -position -of -the -input -or -at -the -position -/ -/ -/ -immediately -following -a -\ -n -character -. -StartLF -= -1 -< -< -2 -/ -/ -/ -Match -the -end -of -a -line -or -the -end -of -text -. -Specifically -this -matches -/ -/ -/ -at -the -end -position -of -the -input -or -at -the -position -immediately -/ -/ -/ -preceding -a -\ -n -character -. -EndLF -= -1 -< -< -3 -/ -/ -/ -Match -the -beginning -of -a -line -or -the -beginning -of -text -. -Specifically -/ -/ -/ -this -matches -at -the -starting -position -of -the -input -or -at -the -position -/ -/ -/ -immediately -following -either -a -\ -r -or -\ -n -character -but -never -after -/ -/ -/ -a -\ -r -when -a -\ -n -follows -. -StartCRLF -= -1 -< -< -4 -/ -/ -/ -Match -the -end -of -a -line -or -the -end -of -text -. -Specifically -this -matches -/ -/ -/ -at -the -end -position -of -the -input -or -at -the -position -immediately -/ -/ -/ -preceding -a -\ -r -or -\ -n -character -but -never -before -a -\ -n -when -a -\ -r -/ -/ -/ -precedes -it -. -EndCRLF -= -1 -< -< -5 -/ -/ -/ -Match -an -ASCII -- -only -word -boundary -. -That -is -this -matches -a -position -/ -/ -/ -where -the -left -adjacent -character -and -right -adjacent -character -/ -/ -/ -correspond -to -a -word -and -non -- -word -or -a -non -- -word -and -word -character -. -WordAscii -= -1 -< -< -6 -/ -/ -/ -Match -an -ASCII -- -only -negation -of -a -word -boundary -. -WordAsciiNegate -= -1 -< -< -7 -/ -/ -/ -Match -a -Unicode -- -aware -word -boundary -. -That -is -this -matches -a -position -/ -/ -/ -where -the -left -adjacent -character -and -right -adjacent -character -/ -/ -/ -correspond -to -a -word -and -non -- -word -or -a -non -- -word -and -word -character -. -WordUnicode -= -1 -< -< -8 -/ -/ -/ -Match -a -Unicode -- -aware -negation -of -a -word -boundary -. -WordUnicodeNegate -= -1 -< -< -9 -} -impl -Look -{ -/ -/ -/ -Flip -the -look -- -around -assertion -to -its -equivalent -for -reverse -searches -. -/ -/ -/ -For -example -StartLF -gets -translated -to -EndLF -. -/ -/ -/ -/ -/ -/ -Some -assertions -such -as -WordUnicode -remain -the -same -since -they -/ -/ -/ -match -the -same -positions -regardless -of -the -direction -of -the -search -. -# -[ -inline -] -pub -const -fn -reversed -( -self -) -- -> -Look -{ -match -self -{ -Look -: -: -Start -= -> -Look -: -: -End -Look -: -: -End -= -> -Look -: -: -Start -Look -: -: -StartLF -= -> -Look -: -: -EndLF -Look -: -: -EndLF -= -> -Look -: -: -StartLF -Look -: -: -StartCRLF -= -> -Look -: -: -EndCRLF -Look -: -: -EndCRLF -= -> -Look -: -: -StartCRLF -Look -: -: -WordAscii -= -> -Look -: -: -WordAscii -Look -: -: -WordAsciiNegate -= -> -Look -: -: -WordAsciiNegate -Look -: -: -WordUnicode -= -> -Look -: -: -WordUnicode -Look -: -: -WordUnicodeNegate -= -> -Look -: -: -WordUnicodeNegate -} -} -/ -/ -/ -Return -the -underlying -representation -of -this -look -- -around -enumeration -/ -/ -/ -as -an -integer -. -Giving -the -return -value -to -the -[ -Look -: -: -from_repr -] -/ -/ -/ -constructor -is -guaranteed -to -return -the -same -look -- -around -variant -that -/ -/ -/ -one -started -with -within -a -semver -compatible -release -of -this -crate -. -# -[ -inline -] -pub -const -fn -as_repr -( -self -) -- -> -u16 -{ -/ -/ -AFAIK -' -as -' -is -the -only -way -to -zero -- -cost -convert -an -int -enum -to -an -/ -/ -actual -int -. -self -as -u16 -} -/ -/ -/ -Given -the -underlying -representation -of -a -Look -value -return -the -/ -/ -/ -corresponding -Look -value -if -the -representation -is -valid -. -Otherwise -/ -/ -/ -None -is -returned -. -# -[ -inline -] -pub -const -fn -from_repr -( -repr -: -u16 -) -- -> -Option -< -Look -> -{ -match -repr -{ -0b00_0000_0001 -= -> -Some -( -Look -: -: -Start -) -0b00_0000_0010 -= -> -Some -( -Look -: -: -End -) -0b00_0000_0100 -= -> -Some -( -Look -: -: -StartLF -) -0b00_0000_1000 -= -> -Some -( -Look -: -: -EndLF -) -0b00_0001_0000 -= -> -Some -( -Look -: -: -StartCRLF -) -0b00_0010_0000 -= -> -Some -( -Look -: -: -EndCRLF -) -0b00_0100_0000 -= -> -Some -( -Look -: -: -WordAscii -) -0b00_1000_0000 -= -> -Some -( -Look -: -: -WordAsciiNegate -) -0b01_0000_0000 -= -> -Some -( -Look -: -: -WordUnicode -) -0b10_0000_0000 -= -> -Some -( -Look -: -: -WordUnicodeNegate -) -_ -= -> -None -} -} -/ -/ -/ -Returns -a -convenient -single -codepoint -representation -of -this -/ -/ -/ -look -- -around -assertion -. -Each -assertion -is -guaranteed -to -be -represented -/ -/ -/ -by -a -distinct -character -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -succinctly -representing -a -look -- -around -assertion -in -/ -/ -/ -human -friendly -but -succinct -output -intended -for -a -programmer -working -on -/ -/ -/ -regex -internals -. -# -[ -inline -] -pub -const -fn -as_char -( -self -) -- -> -char -{ -match -self -{ -Look -: -: -Start -= -> -' -A -' -Look -: -: -End -= -> -' -z -' -Look -: -: -StartLF -= -> -' -^ -' -Look -: -: -EndLF -= -> -' -' -Look -: -: -StartCRLF -= -> -' -r -' -Look -: -: -EndCRLF -= -> -' -R -' -Look -: -: -WordAscii -= -> -' -b -' -Look -: -: -WordAsciiNegate -= -> -' -B -' -Look -: -: -WordUnicode -= -> -' -' -Look -: -: -WordUnicodeNegate -= -> -' -' -} -} -} -/ -/ -/ -LookSet -is -a -memory -- -efficient -set -of -look -- -around -assertions -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -efficiently -tracking -look -- -around -assertions -. -For -/ -/ -/ -example -a -[ -thompson -: -: -NFA -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -) -provides -properties -/ -/ -/ -that -return -LookSet -s -. -# -[ -derive -( -Clone -Copy -Default -Eq -PartialEq -) -] -pub -struct -LookSet -{ -/ -/ -/ -The -underlying -representation -this -set -is -exposed -to -make -it -possible -/ -/ -/ -to -store -it -somewhere -efficiently -. -The -representation -is -that -/ -/ -/ -of -a -bitset -where -each -assertion -occupies -bit -i -where -i -= -/ -/ -/ -Look -: -: -as_repr -( -) -. -/ -/ -/ -/ -/ -/ -Note -that -users -of -this -internal -representation -must -permit -the -full -/ -/ -/ -range -of -u16 -values -to -be -represented -. -For -example -even -if -the -/ -/ -/ -current -implementation -only -makes -use -of -the -10 -least -significant -bits -/ -/ -/ -it -may -use -more -bits -in -a -future -semver -compatible -release -. -pub -bits -: -u16 -} -impl -LookSet -{ -/ -/ -/ -Create -an -empty -set -of -look -- -around -assertions -. -# -[ -inline -] -pub -fn -empty -( -) -- -> -LookSet -{ -LookSet -{ -bits -: -0 -} -} -/ -/ -/ -Create -a -full -set -of -look -- -around -assertions -. -/ -/ -/ -/ -/ -/ -This -set -contains -all -possible -look -- -around -assertions -. -# -[ -inline -] -pub -fn -full -( -) -- -> -LookSet -{ -LookSet -{ -bits -: -! -0 -} -} -/ -/ -/ -Create -a -look -- -around -set -containing -the -look -- -around -assertion -given -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -creating -an -empty -set -and -inserting -/ -/ -/ -one -look -- -around -assertions -. -# -[ -inline -] -pub -fn -singleton -( -look -: -Look -) -- -> -LookSet -{ -LookSet -: -: -empty -( -) -. -insert -( -look -) -} -/ -/ -/ -Returns -the -total -number -of -look -- -around -assertions -in -this -set -. -# -[ -inline -] -pub -fn -len -( -self -) -- -> -usize -{ -/ -/ -OK -because -max -value -always -fits -in -a -u8 -which -in -turn -always -/ -/ -fits -in -a -usize -regardless -of -target -. -usize -: -: -try_from -( -self -. -bits -. -count_ones -( -) -) -. -unwrap -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -is -empty -. -# -[ -inline -] -pub -fn -is_empty -( -self -) -- -> -bool -{ -self -. -len -( -) -= -= -0 -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -look -- -around -assertion -is -in -this -/ -/ -/ -set -. -# -[ -inline -] -pub -fn -contains -( -self -look -: -Look -) -- -> -bool -{ -self -. -bits -& -look -. -as_repr -( -) -! -= -0 -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -anchor -assertions -. -/ -/ -/ -This -includes -both -" -start -/ -end -of -haystack -" -and -" -start -/ -end -of -line -. -" -# -[ -inline -] -pub -fn -contains_anchor -( -& -self -) -- -> -bool -{ -self -. -contains_anchor_haystack -( -) -| -| -self -. -contains_anchor_line -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -" -start -/ -end -of -/ -/ -/ -haystack -" -anchors -. -This -doesn -' -t -include -" -start -/ -end -of -line -" -anchors -. -# -[ -inline -] -pub -fn -contains_anchor_haystack -( -& -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -Start -) -| -| -self -. -contains -( -Look -: -: -End -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -" -start -/ -end -of -line -" -/ -/ -/ -anchors -. -This -doesn -' -t -include -" -start -/ -end -of -haystack -" -anchors -. -This -/ -/ -/ -includes -both -\ -n -line -anchors -and -CRLF -( -\ -r -\ -n -) -aware -line -anchors -. -# -[ -inline -] -pub -fn -contains_anchor_line -( -& -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -StartLF -) -| -| -self -. -contains -( -Look -: -: -EndLF -) -| -| -self -. -contains -( -Look -: -: -StartCRLF -) -| -| -self -. -contains -( -Look -: -: -EndCRLF -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -" -start -/ -end -of -line -" -/ -/ -/ -anchors -that -only -treat -\ -n -as -line -terminators -. -This -does -not -include -/ -/ -/ -haystack -anchors -or -CRLF -aware -line -anchors -. -# -[ -inline -] -pub -fn -contains_anchor_lf -( -& -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -StartLF -) -| -| -self -. -contains -( -Look -: -: -EndLF -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -" -start -/ -end -of -line -" -/ -/ -/ -anchors -that -are -CRLF -- -aware -. -This -doesn -' -t -include -" -start -/ -end -of -/ -/ -/ -haystack -" -or -" -start -/ -end -of -line -- -feed -" -anchors -. -# -[ -inline -] -pub -fn -contains_anchor_crlf -( -& -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -StartCRLF -) -| -| -self -. -contains -( -Look -: -: -EndCRLF -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -word -boundary -or -/ -/ -/ -negated -word -boundary -assertions -. -This -include -both -Unicode -and -ASCII -/ -/ -/ -word -boundaries -. -# -[ -inline -] -pub -fn -contains_word -( -self -) -- -> -bool -{ -self -. -contains_word_unicode -( -) -| -| -self -. -contains_word_ascii -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -Unicode -word -boundary -/ -/ -/ -or -negated -Unicode -word -boundary -assertions -. -# -[ -inline -] -pub -fn -contains_word_unicode -( -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -WordUnicode -) -| -| -self -. -contains -( -Look -: -: -WordUnicodeNegate -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -ASCII -word -boundary -/ -/ -/ -or -negated -ASCII -word -boundary -assertions -. -# -[ -inline -] -pub -fn -contains_word_ascii -( -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -WordAscii -) -| -| -self -. -contains -( -Look -: -: -WordAsciiNegate -) -} -/ -/ -/ -Returns -an -iterator -over -all -of -the -look -- -around -assertions -in -this -set -. -# -[ -inline -] -pub -fn -iter -( -self -) -- -> -LookSetIter -{ -LookSetIter -{ -set -: -self -} -} -/ -/ -/ -Return -a -new -set -that -is -equivalent -to -the -original -but -with -the -given -/ -/ -/ -assertion -added -to -it -. -If -the -assertion -is -already -in -the -set -then -the -/ -/ -/ -returned -set -is -equivalent -to -the -original -. -# -[ -inline -] -pub -fn -insert -( -self -look -: -Look -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -| -look -. -as_repr -( -) -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -inserting -the -given -/ -/ -/ -assertion -into -this -set -. -# -[ -inline -] -pub -fn -set_insert -( -& -mut -self -look -: -Look -) -{ -* -self -= -self -. -insert -( -look -) -; -} -/ -/ -/ -Return -a -new -set -that -is -equivalent -to -the -original -but -with -the -given -/ -/ -/ -assertion -removed -from -it -. -If -the -assertion -is -not -in -the -set -then -the -/ -/ -/ -returned -set -is -equivalent -to -the -original -. -# -[ -inline -] -pub -fn -remove -( -self -look -: -Look -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -& -! -look -. -as_repr -( -) -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -removing -the -given -/ -/ -/ -assertion -from -this -set -. -# -[ -inline -] -pub -fn -set_remove -( -& -mut -self -look -: -Look -) -{ -* -self -= -self -. -remove -( -look -) -; -} -/ -/ -/ -Returns -a -new -set -that -is -the -result -of -subtracting -the -given -set -from -/ -/ -/ -this -set -. -# -[ -inline -] -pub -fn -subtract -( -self -other -: -LookSet -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -& -! -other -. -bits -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -subtracting -the -given -set -/ -/ -/ -from -this -set -. -# -[ -inline -] -pub -fn -set_subtract -( -& -mut -self -other -: -LookSet -) -{ -* -self -= -self -. -subtract -( -other -) -; -} -/ -/ -/ -Returns -a -new -set -that -is -the -union -of -this -and -the -one -given -. -# -[ -inline -] -pub -fn -union -( -self -other -: -LookSet -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -| -other -. -bits -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -unioning -it -with -the -one -/ -/ -/ -given -. -# -[ -inline -] -pub -fn -set_union -( -& -mut -self -other -: -LookSet -) -{ -* -self -= -self -. -union -( -other -) -; -} -/ -/ -/ -Returns -a -new -set -that -is -the -intersection -of -this -and -the -one -given -. -# -[ -inline -] -pub -fn -intersect -( -self -other -: -LookSet -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -& -other -. -bits -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -intersecting -it -with -the -/ -/ -/ -one -given -. -# -[ -inline -] -pub -fn -set_intersect -( -& -mut -self -other -: -LookSet -) -{ -* -self -= -self -. -intersect -( -other -) -; -} -/ -/ -/ -Return -a -LookSet -from -the -slice -given -as -a -native -endian -16 -- -bit -/ -/ -/ -integer -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -slice -. -len -( -) -< -2 -. -# -[ -inline -] -pub -fn -read_repr -( -slice -: -& -[ -u8 -] -) -- -> -LookSet -{ -let -bits -= -u16 -: -: -from_ne_bytes -( -slice -[ -. -. -2 -] -. -try_into -( -) -. -unwrap -( -) -) -; -LookSet -{ -bits -} -} -/ -/ -/ -Write -a -LookSet -as -a -native -endian -16 -- -bit -integer -to -the -beginning -/ -/ -/ -of -the -slice -given -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -slice -. -len -( -) -< -2 -. -# -[ -inline -] -pub -fn -write_repr -( -self -slice -: -& -mut -[ -u8 -] -) -{ -let -raw -= -self -. -bits -. -to_ne_bytes -( -) -; -slice -[ -0 -] -= -raw -[ -0 -] -; -slice -[ -1 -] -= -raw -[ -1 -] -; -} -/ -/ -/ -Checks -that -all -assertions -in -this -set -can -be -matched -. -/ -/ -/ -/ -/ -/ -Some -assertions -such -as -Unicode -word -boundaries -require -optional -( -but -/ -/ -/ -enabled -by -default -) -tables -that -may -not -be -available -. -If -there -are -/ -/ -/ -assertions -in -this -set -that -require -tables -that -are -not -available -then -/ -/ -/ -this -will -return -an -error -. -/ -/ -/ -/ -/ -/ -Specifically -this -returns -an -error -when -the -the -/ -/ -/ -unicode -- -word -- -boundary -feature -is -_not_ -enabled -_and_ -this -set -/ -/ -/ -contains -a -Unicode -word -boundary -assertion -. -/ -/ -/ -/ -/ -/ -It -can -be -useful -to -use -this -on -the -result -of -/ -/ -/ -[ -NFA -: -: -look_set_any -] -( -crate -: -: -nfa -: -: -thompson -: -: -NFA -: -: -look_set_any -) -/ -/ -/ -when -building -a -matcher -engine -to -ensure -methods -like -/ -/ -/ -[ -LookMatcher -: -: -matches_set -] -do -not -panic -at -search -time -. -pub -fn -available -( -self -) -- -> -Result -< -( -) -UnicodeWordBoundaryError -> -{ -if -self -. -contains_word_unicode -( -) -{ -UnicodeWordBoundaryError -: -: -check -( -) -? -; -} -Ok -( -( -) -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -LookSet -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -if -self -. -is_empty -( -) -{ -return -write -! -( -f -" -" -) -; -} -for -look -in -self -. -iter -( -) -{ -write -! -( -f -" -{ -} -" -look -. -as_char -( -) -) -? -; -} -Ok -( -( -) -) -} -} -/ -/ -/ -An -iterator -over -all -look -- -around -assertions -in -a -[ -LookSet -] -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -LookSet -: -: -iter -] -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -LookSetIter -{ -set -: -LookSet -} -impl -Iterator -for -LookSetIter -{ -type -Item -= -Look -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Look -> -{ -if -self -. -set -. -is_empty -( -) -{ -return -None -; -} -/ -/ -We -' -ll -never -have -more -than -u8 -: -: -MAX -distinct -look -- -around -assertions -/ -/ -so -' -repr -' -will -always -fit -into -a -u16 -. -let -repr -= -u16 -: -: -try_from -( -self -. -set -. -bits -. -trailing_zeros -( -) -) -. -unwrap -( -) -; -let -look -= -Look -: -: -from_repr -( -1 -< -< -repr -) -? -; -self -. -set -= -self -. -set -. -remove -( -look -) -; -Some -( -look -) -} -} -/ -/ -/ -A -matcher -for -look -- -around -assertions -. -/ -/ -/ -/ -/ -/ -This -matcher -permits -configuring -aspects -of -how -look -- -around -assertions -are -/ -/ -/ -matched -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -A -LookMatcher -can -change -the -line -terminator -used -for -matching -multi -- -line -/ -/ -/ -anchors -such -as -( -? -m -: -^ -) -and -( -? -m -: -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -PikeVM -} -/ -/ -/ -util -: -: -look -: -: -LookMatcher -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -mut -lookm -= -LookMatcher -: -: -new -( -) -; -/ -/ -/ -lookm -. -set_line_terminator -( -b -' -\ -x00 -' -) -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -look_matcher -( -lookm -) -) -/ -/ -/ -. -build -( -r -" -( -? -m -) -^ -[ -a -- -z -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Multi -- -line -assertions -now -use -NUL -as -a -terminator -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -1 -. -. -4 -) -) -/ -/ -/ -re -. -find -( -& -mut -cache -b -" -\ -x00abc -\ -x00 -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -. -. -. -and -\ -n -is -no -longer -recognized -as -a -terminator -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -None -/ -/ -/ -re -. -find -( -& -mut -cache -b -" -\ -nabc -\ -n -" -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -LookMatcher -{ -lineterm -: -DebugByte -} -impl -LookMatcher -{ -/ -/ -/ -Creates -a -new -default -matcher -for -look -- -around -assertions -. -pub -fn -new -( -) -- -> -LookMatcher -{ -LookMatcher -{ -lineterm -: -DebugByte -( -b -' -\ -n -' -) -} -} -/ -/ -/ -Sets -the -line -terminator -for -use -with -( -? -m -: -^ -) -and -( -? -m -: -) -. -/ -/ -/ -/ -/ -/ -Namely -instead -of -^ -matching -after -\ -n -and -matching -immediately -/ -/ -/ -before -a -\ -n -this -will -cause -it -to -match -after -and -before -the -byte -/ -/ -/ -given -. -/ -/ -/ -/ -/ -/ -It -can -occasionally -be -useful -to -use -this -to -configure -the -line -/ -/ -/ -terminator -to -the -NUL -byte -when -searching -binary -data -. -/ -/ -/ -/ -/ -/ -Note -that -this -does -not -apply -to -CRLF -- -aware -line -anchors -such -as -/ -/ -/ -( -? -Rm -: -^ -) -and -( -? -Rm -: -) -. -CRLF -- -aware -line -anchors -are -hard -- -coded -to -/ -/ -/ -use -\ -r -and -\ -n -. -pub -fn -set_line_terminator -( -& -mut -self -byte -: -u8 -) -- -> -& -mut -LookMatcher -{ -self -. -lineterm -. -0 -= -byte -; -self -} -/ -/ -/ -Returns -the -line -terminator -that -was -configured -for -this -matcher -. -/ -/ -/ -/ -/ -/ -If -no -line -terminator -was -configured -then -this -returns -\ -n -. -/ -/ -/ -/ -/ -/ -Note -that -the -line -terminator -should -only -be -used -for -matching -( -? -m -: -^ -) -/ -/ -/ -and -( -? -m -: -) -assertions -. -It -specifically -should -_not_ -be -used -for -/ -/ -/ -matching -the -CRLF -aware -assertions -( -? -Rm -: -^ -) -and -( -? -Rm -: -) -. -pub -fn -get_line_terminator -( -& -self -) -- -> -u8 -{ -self -. -lineterm -. -0 -} -/ -/ -/ -Returns -true -when -the -position -at -in -haystack -satisfies -the -given -/ -/ -/ -look -- -around -assertion -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -testing -any -Unicode -word -boundary -assertion -in -this -/ -/ -/ -set -and -when -the -Unicode -word -data -is -not -available -. -Specifically -this -/ -/ -/ -only -occurs -when -the -unicode -- -word -- -boundary -feature -is -not -enabled -. -/ -/ -/ -/ -/ -/ -Since -it -' -s -generally -expected -that -this -routine -is -called -inside -of -/ -/ -/ -a -matching -engine -callers -should -check -the -error -condition -when -/ -/ -/ -building -the -matching -engine -. -If -there -is -a -Unicode -word -boundary -/ -/ -/ -in -the -matcher -and -the -data -isn -' -t -available -then -the -matcher -should -/ -/ -/ -fail -to -build -. -/ -/ -/ -/ -/ -/ -Callers -can -check -the -error -condition -with -[ -LookSet -: -: -available -] -. -/ -/ -/ -/ -/ -/ -This -also -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -matches -( -& -self -look -: -Look -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -self -. -matches_inline -( -look -haystack -at -) -} -/ -/ -/ -Like -matches -but -forcefully -inlined -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -matches_inline -( -& -self -look -: -Look -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -match -look -{ -Look -: -: -Start -= -> -self -. -is_start -( -haystack -at -) -Look -: -: -End -= -> -self -. -is_end -( -haystack -at -) -Look -: -: -StartLF -= -> -self -. -is_start_lf -( -haystack -at -) -Look -: -: -EndLF -= -> -self -. -is_end_lf -( -haystack -at -) -Look -: -: -StartCRLF -= -> -self -. -is_start_crlf -( -haystack -at -) -Look -: -: -EndCRLF -= -> -self -. -is_end_crlf -( -haystack -at -) -Look -: -: -WordAscii -= -> -self -. -is_word_ascii -( -haystack -at -) -Look -: -: -WordAsciiNegate -= -> -self -. -is_word_ascii_negate -( -haystack -at -) -Look -: -: -WordUnicode -= -> -self -. -is_word_unicode -( -haystack -at -) -. -unwrap -( -) -Look -: -: -WordUnicodeNegate -= -> -{ -self -. -is_word_unicode_negate -( -haystack -at -) -. -unwrap -( -) -} -} -} -/ -/ -/ -Returns -true -when -_all_ -of -the -assertions -in -the -given -set -match -at -the -/ -/ -/ -given -position -in -the -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -testing -any -Unicode -word -boundary -assertion -in -this -/ -/ -/ -set -and -when -the -Unicode -word -data -is -not -available -. -Specifically -this -/ -/ -/ -only -occurs -when -the -unicode -- -word -- -boundary -feature -is -not -enabled -. -/ -/ -/ -/ -/ -/ -Since -it -' -s -generally -expected -that -this -routine -is -called -inside -of -/ -/ -/ -a -matching -engine -callers -should -check -the -error -condition -when -/ -/ -/ -building -the -matching -engine -. -If -there -is -a -Unicode -word -boundary -/ -/ -/ -in -the -matcher -and -the -data -isn -' -t -available -then -the -matcher -should -/ -/ -/ -fail -to -build -. -/ -/ -/ -/ -/ -/ -Callers -can -check -the -error -condition -with -[ -LookSet -: -: -available -] -. -/ -/ -/ -/ -/ -/ -This -also -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -matches_set -( -& -self -set -: -LookSet -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -self -. -matches_set_inline -( -set -haystack -at -) -} -/ -/ -/ -Like -LookSet -: -: -matches -but -forcefully -inlined -for -perf -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -matches_set_inline -( -& -self -set -: -LookSet -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -/ -/ -This -used -to -luse -LookSet -: -: -iter -with -Look -: -: -matches -on -each -element -/ -/ -but -that -proved -to -be -quite -diastrous -for -perf -. -The -manual -" -if -/ -/ -the -set -has -this -assertion -check -it -" -turns -out -to -be -quite -a -bit -/ -/ -faster -. -if -set -. -contains -( -Look -: -: -Start -) -{ -if -! -self -. -is_start -( -haystack -at -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -End -) -{ -if -! -self -. -is_end -( -haystack -at -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -StartLF -) -{ -if -! -self -. -is_start_lf -( -haystack -at -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -EndLF -) -{ -if -! -self -. -is_end_lf -( -haystack -at -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -StartCRLF -) -{ -if -! -self -. -is_start_crlf -( -haystack -at -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -EndCRLF -) -{ -if -! -self -. -is_end_crlf -( -haystack -at -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -WordAscii -) -{ -if -! -self -. -is_word_ascii -( -haystack -at -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -WordAsciiNegate -) -{ -if -! -self -. -is_word_ascii_negate -( -haystack -at -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -WordUnicode -) -{ -if -! -self -. -is_word_unicode -( -haystack -at -) -. -unwrap -( -) -{ -return -false -; -} -} -if -set -. -contains -( -Look -: -: -WordUnicodeNegate -) -{ -if -! -self -. -is_word_unicode_negate -( -haystack -at -) -. -unwrap -( -) -{ -return -false -; -} -} -true -} -/ -/ -/ -Split -up -the -given -byte -classes -into -equivalence -classes -in -a -way -that -/ -/ -/ -is -consistent -with -this -look -- -around -assertion -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -( -crate -) -fn -add_to_byteset -( -& -self -look -: -Look -set -: -& -mut -crate -: -: -util -: -: -alphabet -: -: -ByteClassSet -) -{ -match -look -{ -Look -: -: -Start -| -Look -: -: -End -= -> -{ -} -Look -: -: -StartLF -| -Look -: -: -EndLF -= -> -{ -set -. -set_range -( -self -. -lineterm -. -0 -self -. -lineterm -. -0 -) -; -} -Look -: -: -StartCRLF -| -Look -: -: -EndCRLF -= -> -{ -set -. -set_range -( -b -' -\ -r -' -b -' -\ -r -' -) -; -set -. -set_range -( -b -' -\ -n -' -b -' -\ -n -' -) -; -} -Look -: -: -WordAscii -| -Look -: -: -WordAsciiNegate -| -Look -: -: -WordUnicode -| -Look -: -: -WordUnicodeNegate -= -> -{ -/ -/ -We -need -to -mark -all -ranges -of -bytes -whose -pairs -result -in -/ -/ -evaluating -\ -b -differently -. -This -isn -' -t -technically -correct -/ -/ -for -Unicode -word -boundaries -but -DFAs -can -' -t -handle -those -/ -/ -anyway -and -thus -the -byte -classes -don -' -t -need -to -either -/ -/ -since -they -are -themselves -only -used -in -DFAs -. -/ -/ -/ -/ -FIXME -: -It -seems -like -the -calls -to -' -set_range -' -here -are -/ -/ -completely -invariant -which -means -we -could -just -hard -- -code -/ -/ -them -here -without -needing -to -write -a -loop -. -And -we -only -need -/ -/ -to -do -this -dance -at -most -once -per -regex -. -/ -/ -/ -/ -FIXME -: -Is -this -correct -for -\ -B -? -let -iswb -= -utf8 -: -: -is_word_byte -; -/ -/ -This -unwrap -is -OK -because -we -guard -every -use -of -' -asu8 -' -with -/ -/ -a -check -that -the -input -is -< -= -255 -. -let -asu8 -= -| -b -: -u16 -| -u8 -: -: -try_from -( -b -) -. -unwrap -( -) -; -let -mut -b1 -: -u16 -= -0 -; -let -mut -b2 -: -u16 -; -while -b1 -< -= -255 -{ -b2 -= -b1 -+ -1 -; -while -b2 -< -= -255 -& -& -iswb -( -asu8 -( -b1 -) -) -= -= -iswb -( -asu8 -( -b2 -) -) -{ -b2 -+ -= -1 -; -} -/ -/ -The -guards -above -guarantee -that -b2 -can -never -get -any -/ -/ -bigger -. -assert -! -( -b2 -< -= -256 -) -; -/ -/ -Subtracting -1 -from -b2 -is -always -OK -because -it -is -always -/ -/ -at -least -1 -greater -than -b1 -and -the -assert -above -/ -/ -guarantees -that -the -asu8 -conversion -will -succeed -. -set -. -set_range -( -asu8 -( -b1 -) -asu8 -( -b2 -. -checked_sub -( -1 -) -. -unwrap -( -) -) -) -; -b1 -= -b2 -; -} -} -} -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -Start -] -is -satisfied -at -the -given -position -/ -/ -/ -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -is_start -( -& -self -_haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -at -= -= -0 -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -End -] -is -satisfied -at -the -given -position -in -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -is_end -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -at -= -= -haystack -. -len -( -) -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -StartLF -] -is -satisfied -at -the -given -/ -/ -/ -position -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -is_start_lf -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -self -. -is_start -( -haystack -at -) -| -| -haystack -[ -at -- -1 -] -= -= -self -. -lineterm -. -0 -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -EndLF -] -is -satisfied -at -the -given -position -/ -/ -/ -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -is_end_lf -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -self -. -is_end -( -haystack -at -) -| -| -haystack -[ -at -] -= -= -self -. -lineterm -. -0 -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -StartCRLF -] -is -satisfied -at -the -given -/ -/ -/ -position -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -is_start_crlf -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -self -. -is_start -( -haystack -at -) -| -| -haystack -[ -at -- -1 -] -= -= -b -' -\ -n -' -| -| -( -haystack -[ -at -- -1 -] -= -= -b -' -\ -r -' -& -& -( -at -> -= -haystack -. -len -( -) -| -| -haystack -[ -at -] -! -= -b -' -\ -n -' -) -) -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -EndCRLF -] -is -satisfied -at -the -given -/ -/ -/ -position -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -is_end_crlf -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -self -. -is_end -( -haystack -at -) -| -| -haystack -[ -at -] -= -= -b -' -\ -r -' -| -| -( -haystack -[ -at -] -= -= -b -' -\ -n -' -& -& -( -at -= -= -0 -| -| -haystack -[ -at -- -1 -] -! -= -b -' -\ -r -' -) -) -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -WordAscii -] -is -satisfied -at -the -given -/ -/ -/ -position -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -is_word_ascii -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -let -word_before -= -at -> -0 -& -& -utf8 -: -: -is_word_byte -( -haystack -[ -at -- -1 -] -) -; -let -word_after -= -at -< -haystack -. -len -( -) -& -& -utf8 -: -: -is_word_byte -( -haystack -[ -at -] -) -; -word_before -! -= -word_after -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -WordAsciiNegate -] -is -satisfied -at -the -given -/ -/ -/ -position -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -# -[ -inline -] -pub -fn -is_word_ascii_negate -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -bool -{ -! -self -. -is_word_ascii -( -haystack -at -) -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -WordUnicode -] -is -satisfied -at -the -given -/ -/ -/ -position -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -when -Unicode -word -boundary -tables -/ -/ -/ -are -not -available -. -Specifically -this -only -occurs -when -the -/ -/ -/ -unicode -- -word -- -boundary -feature -is -not -enabled -. -# -[ -inline -] -pub -fn -is_word_unicode -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Result -< -bool -UnicodeWordBoundaryError -> -{ -let -word_before -= -is_word_char -: -: -rev -( -haystack -at -) -? -; -let -word_after -= -is_word_char -: -: -fwd -( -haystack -at -) -? -; -Ok -( -word_before -! -= -word_after -) -} -/ -/ -/ -Returns -true -when -[ -Look -: -: -WordUnicodeNegate -] -is -satisfied -at -the -/ -/ -/ -given -position -in -haystack -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -may -panic -when -at -> -haystack -. -len -( -) -. -Note -that -at -= -= -/ -/ -/ -haystack -. -len -( -) -is -legal -and -guaranteed -not -to -panic -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -when -Unicode -word -boundary -tables -/ -/ -/ -are -not -available -. -Specifically -this -only -occurs -when -the -/ -/ -/ -unicode -- -word -- -boundary -feature -is -not -enabled -. -# -[ -inline -] -pub -fn -is_word_unicode_negate -( -& -self -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Result -< -bool -UnicodeWordBoundaryError -> -{ -/ -/ -This -is -pretty -subtle -. -Why -do -we -need -to -do -UTF -- -8 -decoding -here -? -/ -/ -Well -. -. -. -at -time -of -writing -the -is_word_char_ -{ -fwd -rev -} -routines -will -/ -/ -only -return -true -if -there -is -a -valid -UTF -- -8 -encoding -of -a -" -word -" -/ -/ -codepoint -and -false -in -every -other -case -( -including -invalid -UTF -- -8 -) -. -/ -/ -This -means -that -in -regions -of -invalid -UTF -- -8 -( -which -might -be -a -/ -/ -subset -of -valid -UTF -- -8 -! -) -it -would -result -in -\ -B -matching -. -While -this -/ -/ -would -be -questionable -in -the -context -of -truly -invalid -UTF -- -8 -it -is -/ -/ -* -certainly -* -wrong -to -report -match -boundaries -that -split -the -encoding -/ -/ -of -a -codepoint -. -So -to -work -around -this -we -ensure -that -we -can -decode -/ -/ -a -codepoint -on -either -side -of -at -. -If -either -direction -fails -then -/ -/ -we -don -' -t -permit -\ -B -to -match -at -all -. -/ -/ -/ -/ -Now -this -isn -' -t -exactly -optimal -from -a -perf -perspective -. -We -could -/ -/ -try -and -detect -this -in -is_word_char -: -: -{ -fwd -rev -} -but -it -' -s -not -clear -/ -/ -if -it -' -s -worth -it -. -\ -B -is -after -all -rarely -used -. -Even -worse -/ -/ -is_word_char -: -: -{ -fwd -rev -} -could -do -its -own -UTF -- -8 -decoding -and -so -this -/ -/ -will -wind -up -doing -UTF -- -8 -decoding -twice -. -Owch -. -We -could -fix -this -/ -/ -with -more -code -complexity -but -it -just -doesn -' -t -feel -worth -it -for -\ -B -. -/ -/ -/ -/ -And -in -particular -we -do -* -not -* -have -to -do -this -with -\ -b -because -\ -b -/ -/ -* -requires -* -that -at -least -one -side -of -at -be -a -" -word -" -codepoint -/ -/ -which -in -turn -implies -one -side -of -at -must -be -valid -UTF -- -8 -. -This -in -/ -/ -turn -implies -that -\ -b -can -never -split -a -valid -UTF -- -8 -encoding -of -a -/ -/ -codepoint -. -In -the -case -where -one -side -of -at -is -truly -invalid -UTF -- -8 -/ -/ -and -the -other -side -IS -a -word -codepoint -then -we -want -\ -b -to -match -/ -/ -since -it -represents -a -valid -UTF -- -8 -boundary -. -It -also -makes -sense -. -For -/ -/ -example -you -' -d -want -\ -b -\ -w -+ -\ -b -to -match -' -abc -' -in -' -\ -xFFabc -\ -xFF -' -. -/ -/ -/ -/ -Note -also -that -this -is -not -just -' -! -is_word_unicode -( -. -. -) -' -like -it -is -/ -/ -for -the -ASCII -case -. -For -example -neither -\ -b -nor -\ -B -is -satisfied -/ -/ -within -invalid -UTF -- -8 -sequences -. -let -word_before -= -at -> -0 -& -& -match -utf8 -: -: -decode_last -( -& -haystack -[ -. -. -at -] -) -{ -None -| -Some -( -Err -( -_ -) -) -= -> -return -Ok -( -false -) -Some -( -Ok -( -_ -) -) -= -> -is_word_char -: -: -rev -( -haystack -at -) -? -} -; -let -word_after -= -at -< -haystack -. -len -( -) -& -& -match -utf8 -: -: -decode -( -& -haystack -[ -at -. -. -] -) -{ -None -| -Some -( -Err -( -_ -) -) -= -> -return -Ok -( -false -) -Some -( -Ok -( -_ -) -) -= -> -is_word_char -: -: -fwd -( -haystack -at -) -? -} -; -Ok -( -word_before -= -= -word_after -) -} -} -impl -Default -for -LookMatcher -{ -fn -default -( -) -- -> -LookMatcher -{ -LookMatcher -: -: -new -( -) -} -} -/ -/ -/ -An -error -that -occurs -when -the -Unicode -- -aware -\ -w -class -is -unavailable -. -/ -/ -/ -/ -/ -/ -This -error -can -occur -when -the -data -tables -necessary -for -the -Unicode -aware -/ -/ -/ -Perl -character -class -\ -w -are -unavailable -. -The -\ -w -class -is -used -to -/ -/ -/ -determine -whether -a -codepoint -is -considered -a -word -character -or -not -when -/ -/ -/ -determining -whether -a -Unicode -aware -\ -b -( -or -\ -B -) -matches -at -a -particular -/ -/ -/ -position -. -/ -/ -/ -/ -/ -/ -This -error -can -only -occur -when -the -unicode -- -word -- -boundary -feature -is -/ -/ -/ -disabled -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -UnicodeWordBoundaryError -( -( -) -) -; -impl -UnicodeWordBoundaryError -{ -# -[ -cfg -( -not -( -feature -= -" -unicode -- -word -- -boundary -" -) -) -] -pub -( -crate -) -fn -new -( -) -- -> -UnicodeWordBoundaryError -{ -UnicodeWordBoundaryError -( -( -) -) -} -/ -/ -/ -Returns -an -error -if -and -only -if -Unicode -word -boundary -data -is -/ -/ -/ -unavailable -. -pub -fn -check -( -) -- -> -Result -< -( -) -UnicodeWordBoundaryError -> -{ -is_word_char -: -: -check -( -) -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -UnicodeWordBoundaryError -{ -} -impl -core -: -: -fmt -: -: -Display -for -UnicodeWordBoundaryError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -Unicode -- -aware -\ -\ -b -and -\ -\ -B -are -unavailable -because -the -\ -requisite -data -tables -are -missing -please -enable -the -\ -unicode -- -word -- -boundary -feature -" -) -} -} -/ -/ -Below -are -FOUR -different -ways -for -checking -whether -whether -a -" -word -" -/ -/ -codepoint -exists -at -a -particular -position -in -the -haystack -. -The -four -/ -/ -different -approaches -are -in -order -of -preference -: -/ -/ -/ -/ -1 -. -Parse -' -\ -w -' -convert -to -an -NFA -convert -to -a -fully -compiled -DFA -on -the -/ -/ -first -call -and -then -use -that -DFA -for -all -subsequent -calls -. -/ -/ -2 -. -Do -UTF -- -8 -decoding -and -use -regex_syntax -: -: -is_word_character -if -available -. -/ -/ -3 -. -Do -UTF -- -8 -decoding -and -use -our -own -' -perl_word -' -table -. -/ -/ -4 -. -Return -an -error -. -/ -/ -/ -/ -The -reason -for -all -of -these -approaches -is -a -combination -of -perf -and -/ -/ -permitting -one -to -build -regex -- -automata -without -the -Unicode -data -necessary -/ -/ -for -handling -Unicode -- -aware -word -boundaries -. -( -In -which -case -' -( -? -- -u -: -\ -b -) -' -would -/ -/ -still -work -. -) -/ -/ -/ -/ -The -DFA -approach -is -the -fastest -but -it -requires -the -regex -parser -the -/ -/ -NFA -compiler -the -DFA -builder -and -the -DFA -search -runtime -. -That -' -s -a -lot -to -/ -/ -bring -in -but -if -it -' -s -available -it -' -s -( -probably -) -the -best -we -can -do -. -/ -/ -/ -/ -Approaches -( -2 -) -and -( -3 -) -are -effectively -equivalent -but -( -2 -) -reuses -the -/ -/ -data -in -regex -- -syntax -and -avoids -duplicating -it -in -regex -- -automata -. -/ -/ -/ -/ -Finally -( -4 -) -unconditionally -returns -an -error -since -the -requisite -data -isn -' -t -/ -/ -available -anywhere -. -/ -/ -/ -/ -There -are -actually -more -approaches -possible -that -we -didn -' -t -implement -. -For -/ -/ -example -if -the -DFA -builder -is -available -but -the -syntax -parser -is -not -we -/ -/ -could -technically -hand -construct -our -own -NFA -from -the -' -perl_word -' -data -/ -/ -table -. -But -to -avoid -some -pretty -hairy -code -duplication -we -would -in -turn -/ -/ -need -to -pull -the -UTF -- -8 -compiler -out -of -the -NFA -compiler -. -Yikes -. -/ -/ -/ -/ -A -possibly -more -sensible -alternative -is -to -use -a -lazy -DFA -when -the -full -/ -/ -DFA -builder -isn -' -t -available -. -. -. -/ -/ -/ -/ -Yet -another -choice -would -be -to -build -the -full -DFA -and -then -embed -it -into -the -/ -/ -source -. -Then -we -' -d -only -need -to -bring -in -the -DFA -search -runtime -which -is -/ -/ -considerably -smaller -than -the -DFA -builder -code -. -The -problem -here -is -that -the -/ -/ -Debian -people -have -spooked -me -[ -1 -] -into -avoiding -cyclic -dependencies -. -Namely -/ -/ -we -' -d -need -to -build -regex -- -cli -which -depends -on -regex -- -automata -in -order -to -/ -/ -build -some -part -of -regex -- -automata -. -But -to -be -honest -something -like -this -has -/ -/ -to -be -allowed -somehow -? -I -just -don -' -t -know -what -the -right -process -is -. -/ -/ -/ -/ -There -are -perhaps -other -choices -as -well -. -Why -did -I -stop -at -these -4 -? -Because -/ -/ -I -wanted -to -preserve -my -sanity -. -I -suspect -I -' -ll -wind -up -adding -the -lazy -DFA -/ -/ -approach -eventually -as -the -benefits -of -the -DFA -approach -are -somewhat -/ -/ -compelling -. -The -' -boundary -- -words -- -holmes -' -benchmark -tests -this -: -/ -/ -/ -/ -regex -- -cli -bench -measure -- -f -boundary -- -words -- -holmes -- -e -pikevm -> -dfa -. -csv -/ -/ -/ -/ -Then -I -changed -the -code -below -so -that -the -util -/ -unicode_data -/ -perl_word -table -/ -/ -was -used -and -re -- -ran -the -benchmark -: -/ -/ -/ -/ -regex -- -cli -bench -measure -- -f -boundary -- -words -- -holmes -- -e -pikevm -> -table -. -csv -/ -/ -/ -/ -And -compared -them -: -/ -/ -/ -/ -regex -- -cli -bench -diff -dfa -. -csv -table -. -csv -/ -/ -benchmark -engine -dfa -table -/ -/ -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -/ -/ -internal -/ -count -/ -boundary -- -words -- -holmes -regex -/ -automata -/ -pikevm -18 -. -6 -MB -/ -s -12 -. -9 -MB -/ -s -/ -/ -/ -/ -Which -is -a -nice -improvement -. -/ -/ -/ -/ -UPDATE -: -It -turns -out -that -it -takes -approximately -22ms -to -build -the -reverse -/ -/ -DFA -for -\ -w -. -( -And -about -3ms -for -the -forward -DFA -. -) -It -' -s -probably -not -much -in -/ -/ -the -grand -scheme -things -but -that -is -a -significant -latency -cost -. -So -I -' -m -not -/ -/ -sure -that -' -s -a -good -idea -. -I -then -tried -using -a -lazy -DFA -instead -and -that -/ -/ -eliminated -the -overhead -but -since -the -lazy -DFA -requires -mutable -working -/ -/ -memory -that -requires -introducing -a -' -Cache -' -for -every -simultaneous -call -. -/ -/ -/ -/ -I -ended -up -deciding -for -now -to -just -keep -the -" -UTF -- -8 -decode -and -check -the -/ -/ -table -. -" -The -DFA -and -lazy -DFA -approaches -are -still -below -but -commented -out -. -/ -/ -/ -/ -[ -1 -] -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -ucd -- -generate -/ -issues -/ -11 -/ -* -/ -/ -/ -A -module -that -looks -for -word -codepoints -using -lazy -DFAs -. -# -[ -cfg -( -all -( -feature -= -" -unicode -- -word -- -boundary -" -feature -= -" -syntax -" -feature -= -" -unicode -- -perl -" -feature -= -" -hybrid -" -) -) -] -mod -is_word_char -{ -use -alloc -: -: -vec -: -: -Vec -; -use -crate -: -: -{ -hybrid -: -: -dfa -: -: -{ -Cache -DFA -} -nfa -: -: -thompson -: -: -NFA -util -: -: -{ -lazy -: -: -Lazy -pool -: -: -Pool -primitives -: -: -StateID -} -Anchored -Input -} -; -pub -( -super -) -fn -check -( -) -- -> -Result -< -( -) -super -: -: -UnicodeWordBoundaryError -> -{ -Ok -( -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -fwd -( -haystack -: -& -[ -u8 -] -mut -at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -static -WORD -: -Lazy -< -DFA -> -= -Lazy -: -: -new -( -| -| -DFA -: -: -new -( -r -" -\ -w -" -) -. -unwrap -( -) -) -; -static -CACHE -: -Lazy -< -Pool -< -Cache -> -> -= -Lazy -: -: -new -( -| -| -Pool -: -: -new -( -| -| -WORD -. -create_cache -( -) -) -) -; -let -dfa -= -Lazy -: -: -get -( -& -WORD -) -; -let -mut -cache -= -Lazy -: -: -get -( -& -CACHE -) -. -get -( -) -; -let -mut -sid -= -dfa -. -start_state_forward -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -. -anchored -( -Anchored -: -: -Yes -) -) -. -unwrap -( -) -; -while -at -< -haystack -. -len -( -) -{ -let -byte -= -haystack -[ -at -] -; -sid -= -dfa -. -next_state -( -& -mut -cache -sid -byte -) -. -unwrap -( -) -; -at -+ -= -1 -; -if -sid -. -is_tagged -( -) -{ -if -sid -. -is_match -( -) -{ -return -Ok -( -true -) -; -} -else -if -sid -. -is_dead -( -) -{ -return -Ok -( -false -) -; -} -} -} -Ok -( -dfa -. -next_eoi_state -( -& -mut -cache -sid -) -. -unwrap -( -) -. -is_match -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -rev -( -haystack -: -& -[ -u8 -] -mut -at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -static -WORD -: -Lazy -< -DFA -> -= -Lazy -: -: -new -( -| -| -{ -DFA -: -: -builder -( -) -. -thompson -( -NFA -: -: -config -( -) -. -reverse -( -true -) -) -. -build -( -r -" -\ -w -" -) -. -unwrap -( -) -} -) -; -static -CACHE -: -Lazy -< -Pool -< -Cache -> -> -= -Lazy -: -: -new -( -| -| -Pool -: -: -new -( -| -| -WORD -. -create_cache -( -) -) -) -; -let -dfa -= -Lazy -: -: -get -( -& -WORD -) -; -let -mut -cache -= -Lazy -: -: -get -( -& -CACHE -) -. -get -( -) -; -let -mut -sid -= -dfa -. -start_state_reverse -( -& -mut -cache -& -Input -: -: -new -( -" -" -) -. -anchored -( -Anchored -: -: -Yes -) -) -. -unwrap -( -) -; -while -at -> -0 -{ -at -- -= -1 -; -let -byte -= -haystack -[ -at -] -; -sid -= -dfa -. -next_state -( -& -mut -cache -sid -byte -) -. -unwrap -( -) -; -if -sid -. -is_tagged -( -) -{ -if -sid -. -is_match -( -) -{ -return -Ok -( -true -) -; -} -else -if -sid -. -is_dead -( -) -{ -return -Ok -( -false -) -; -} -} -} -Ok -( -dfa -. -next_eoi_state -( -& -mut -cache -sid -) -. -unwrap -( -) -. -is_match -( -) -) -} -} -* -/ -/ -* -/ -/ -/ -A -module -that -looks -for -word -codepoints -using -fully -compiled -DFAs -. -# -[ -cfg -( -all -( -feature -= -" -unicode -- -word -- -boundary -" -feature -= -" -syntax -" -feature -= -" -unicode -- -perl -" -feature -= -" -dfa -- -build -" -) -) -] -mod -is_word_char -{ -use -alloc -: -: -vec -: -: -Vec -; -use -crate -: -: -{ -dfa -: -: -{ -dense -: -: -DFA -Automaton -StartKind -} -nfa -: -: -thompson -: -: -NFA -util -: -: -{ -lazy -: -: -Lazy -primitives -: -: -StateID -} -Anchored -Input -} -; -pub -( -super -) -fn -check -( -) -- -> -Result -< -( -) -super -: -: -UnicodeWordBoundaryError -> -{ -Ok -( -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -fwd -( -haystack -: -& -[ -u8 -] -mut -at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -static -WORD -: -Lazy -< -( -DFA -< -Vec -< -u32 -> -> -StateID -) -> -= -Lazy -: -: -new -( -| -| -{ -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -start_kind -( -StartKind -: -: -Anchored -) -) -. -build -( -r -" -\ -w -" -) -. -unwrap -( -) -; -/ -/ -OK -because -our -regex -has -no -look -- -around -. -let -start_id -= -dfa -. -universal_start_state -( -Anchored -: -: -Yes -) -. -unwrap -( -) -; -( -dfa -start_id -) -} -) -; -let -& -( -ref -dfa -mut -sid -) -= -Lazy -: -: -get -( -& -WORD -) -; -while -at -< -haystack -. -len -( -) -{ -let -byte -= -haystack -[ -at -] -; -sid -= -dfa -. -next_state -( -sid -byte -) -; -at -+ -= -1 -; -if -dfa -. -is_special_state -( -sid -) -{ -if -dfa -. -is_match_state -( -sid -) -{ -return -Ok -( -true -) -; -} -else -if -dfa -. -is_dead_state -( -sid -) -{ -return -Ok -( -false -) -; -} -} -} -Ok -( -dfa -. -is_match_state -( -dfa -. -next_eoi_state -( -sid -) -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -rev -( -haystack -: -& -[ -u8 -] -mut -at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -static -WORD -: -Lazy -< -( -DFA -< -Vec -< -u32 -> -> -StateID -) -> -= -Lazy -: -: -new -( -| -| -{ -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -start_kind -( -StartKind -: -: -Anchored -) -) -/ -/ -From -ad -hoc -measurements -it -looks -like -setting -/ -/ -shrink -= -= -false -is -slightly -faster -than -shrink -= -= -true -. -I -kind -/ -/ -of -feel -like -this -indicates -that -shrinking -is -probably -a -/ -/ -failure -although -it -can -help -in -some -cases -. -Sigh -. -. -thompson -( -NFA -: -: -config -( -) -. -reverse -( -true -) -. -shrink -( -false -) -) -. -build -( -r -" -\ -w -" -) -. -unwrap -( -) -; -/ -/ -OK -because -our -regex -has -no -look -- -around -. -let -start_id -= -dfa -. -universal_start_state -( -Anchored -: -: -Yes -) -. -unwrap -( -) -; -( -dfa -start_id -) -} -) -; -let -& -( -ref -dfa -mut -sid -) -= -Lazy -: -: -get -( -& -WORD -) -; -while -at -> -0 -{ -at -- -= -1 -; -let -byte -= -haystack -[ -at -] -; -sid -= -dfa -. -next_state -( -sid -byte -) -; -if -dfa -. -is_special_state -( -sid -) -{ -if -dfa -. -is_match_state -( -sid -) -{ -return -Ok -( -true -) -; -} -else -if -dfa -. -is_dead_state -( -sid -) -{ -return -Ok -( -false -) -; -} -} -} -Ok -( -dfa -. -is_match_state -( -dfa -. -next_eoi_state -( -sid -) -) -) -} -} -* -/ -/ -/ -/ -A -module -that -looks -for -word -codepoints -using -regex -- -syntax -' -s -data -tables -. -# -[ -cfg -( -all -( -feature -= -" -unicode -- -word -- -boundary -" -feature -= -" -syntax -" -feature -= -" -unicode -- -perl -" -) -) -] -mod -is_word_char -{ -use -regex_syntax -: -: -try_is_word_character -; -use -crate -: -: -util -: -: -utf8 -; -pub -( -super -) -fn -check -( -) -- -> -Result -< -( -) -super -: -: -UnicodeWordBoundaryError -> -{ -Ok -( -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -fwd -( -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -Ok -( -match -utf8 -: -: -decode -( -& -haystack -[ -at -. -. -] -) -{ -None -| -Some -( -Err -( -_ -) -) -= -> -false -Some -( -Ok -( -ch -) -) -= -> -try_is_word_character -( -ch -) -. -expect -( -" -since -unicode -- -word -- -boundary -syntax -and -unicode -- -perl -\ -are -all -enabled -it -is -expected -that -\ -try_is_word_character -succeeds -" -) -} -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -rev -( -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -Ok -( -match -utf8 -: -: -decode_last -( -& -haystack -[ -. -. -at -] -) -{ -None -| -Some -( -Err -( -_ -) -) -= -> -false -Some -( -Ok -( -ch -) -) -= -> -try_is_word_character -( -ch -) -. -expect -( -" -since -unicode -- -word -- -boundary -syntax -and -unicode -- -perl -\ -are -all -enabled -it -is -expected -that -\ -try_is_word_character -succeeds -" -) -} -) -} -} -/ -/ -/ -A -module -that -looks -for -word -codepoints -using -regex -- -automata -' -s -data -tables -/ -/ -/ -( -which -are -only -compiled -when -regex -- -syntax -' -s -tables -aren -' -t -available -) -. -/ -/ -/ -/ -/ -/ -Note -that -the -cfg -should -match -the -one -in -src -/ -util -/ -unicode_data -/ -mod -. -rs -for -/ -/ -/ -perl_word -. -# -[ -cfg -( -all -( -feature -= -" -unicode -- -word -- -boundary -" -not -( -all -( -feature -= -" -syntax -" -feature -= -" -unicode -- -perl -" -) -) -) -) -] -mod -is_word_char -{ -use -crate -: -: -util -: -: -utf8 -; -pub -( -super -) -fn -check -( -) -- -> -Result -< -( -) -super -: -: -UnicodeWordBoundaryError -> -{ -Ok -( -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -fwd -( -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -Ok -( -match -utf8 -: -: -decode -( -& -haystack -[ -at -. -. -] -) -{ -None -| -Some -( -Err -( -_ -) -) -= -> -false -Some -( -Ok -( -ch -) -) -= -> -is_word_character -( -ch -) -} -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -rev -( -haystack -: -& -[ -u8 -] -at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -Ok -( -match -utf8 -: -: -decode_last -( -& -haystack -[ -. -. -at -] -) -{ -None -| -Some -( -Err -( -_ -) -) -= -> -false -Some -( -Ok -( -ch -) -) -= -> -is_word_character -( -ch -) -} -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_word_character -( -c -: -char -) -- -> -bool -{ -use -crate -: -: -util -: -: -{ -unicode_data -: -: -perl_word -: -: -PERL_WORD -utf8 -} -; -/ -/ -MSRV -( -1 -. -59 -) -: -Use -' -u8 -: -: -try_from -( -c -) -' -instead -. -if -u8 -: -: -try_from -( -u32 -: -: -from -( -c -) -) -. -map_or -( -false -utf8 -: -: -is_word_byte -) -{ -return -true -; -} -PERL_WORD -. -binary_search_by -( -| -& -( -start -end -) -| -{ -use -core -: -: -cmp -: -: -Ordering -; -if -start -< -= -c -& -& -c -< -= -end -{ -Ordering -: -: -Equal -} -else -if -start -> -c -{ -Ordering -: -: -Greater -} -else -{ -Ordering -: -: -Less -} -} -) -. -is_ok -( -) -} -} -/ -/ -/ -A -module -that -always -returns -an -error -if -Unicode -word -boundaries -are -/ -/ -/ -disabled -. -When -this -feature -is -disabled -then -regex -- -automata -will -not -/ -/ -/ -include -its -own -data -tables -even -if -regex -- -syntax -is -disabled -. -# -[ -cfg -( -not -( -feature -= -" -unicode -- -word -- -boundary -" -) -) -] -mod -is_word_char -{ -pub -( -super -) -fn -check -( -) -- -> -Result -< -( -) -super -: -: -UnicodeWordBoundaryError -> -{ -Err -( -super -: -: -UnicodeWordBoundaryError -: -: -new -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -fwd -( -_bytes -: -& -[ -u8 -] -_at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -Err -( -super -: -: -UnicodeWordBoundaryError -: -: -new -( -) -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -super -) -fn -rev -( -_bytes -: -& -[ -u8 -] -_at -: -usize -) -- -> -Result -< -bool -super -: -: -UnicodeWordBoundaryError -> -{ -Err -( -super -: -: -UnicodeWordBoundaryError -: -: -new -( -) -) -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -super -: -: -* -; -macro_rules -! -testlook -{ -( -look -: -expr -haystack -: -expr -at -: -expr -) -= -> -{ -LookMatcher -: -: -default -( -) -. -matches -( -look -haystack -. -as_bytes -( -) -at -) -} -; -} -# -[ -test -] -fn -look_matches_start_line -( -) -{ -let -look -= -Look -: -: -StartLF -; -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -n -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -n -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -na -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -\ -na -" -1 -) -) -; -} -# -[ -test -] -fn -look_matches_end_line -( -) -{ -let -look -= -Look -: -: -EndLF -; -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -n -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -na -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -na -" -2 -) -) -; -assert -! -( -testlook -! -( -look -" -a -\ -na -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -\ -na -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -\ -na -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -\ -na -" -2 -) -) -; -} -# -[ -test -] -fn -look_matches_start_text -( -) -{ -let -look -= -Look -: -: -Start -; -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -n -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -\ -n -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -\ -na -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -\ -na -" -1 -) -) -; -} -# -[ -test -] -fn -look_matches_end_text -( -) -{ -let -look -= -Look -: -: -End -; -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -n -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -\ -na -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -\ -na -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -\ -na -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -\ -na -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -\ -na -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -\ -na -" -2 -) -) -; -} -# -[ -test -] -# -[ -cfg -( -all -( -not -( -miri -) -feature -= -" -unicode -- -word -- -boundary -" -) -) -] -fn -look_matches_word_unicode -( -) -{ -let -look -= -Look -: -: -WordUnicode -; -/ -/ -\ -xF0 -\ -x9D -\ -x9B -\ -x83 -= -( -in -\ -w -) -/ -/ -\ -xF0 -\ -x90 -\ -x86 -\ -x80 -= -( -not -in -\ -w -) -/ -/ -Simple -ASCII -word -boundaries -. -assert -! -( -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -2 -) -) -; -/ -/ -Unicode -word -boundaries -with -a -non -- -ASCII -codepoint -. -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -" -4 -) -) -; -assert -! -( -testlook -! -( -look -" -" -4 -) -) -; -assert -! -( -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -" -5 -) -) -; -/ -/ -Unicode -word -boundaries -between -non -- -ASCII -codepoints -. -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -" -4 -) -) -; -/ -/ -Non -word -boundaries -for -ASCII -. -assert -! -( -! -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -ab -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -3 -) -) -; -/ -/ -Non -word -boundaries -with -a -non -- -ASCII -codepoint -. -assert -! -( -! -testlook -! -( -look -" -b -" -4 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -5 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -6 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -3 -) -) -; -/ -/ -Non -word -boundaries -with -non -- -ASCII -codepoints -. -assert -! -( -! -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -3 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -5 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -6 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -7 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -8 -) -) -; -} -# -[ -test -] -fn -look_matches_word_ascii -( -) -{ -let -look -= -Look -: -: -WordAscii -; -/ -/ -\ -xF0 -\ -x9D -\ -x9B -\ -x83 -= -( -in -\ -w -) -/ -/ -\ -xF0 -\ -x90 -\ -x86 -\ -x80 -= -( -not -in -\ -w -) -/ -/ -Simple -ASCII -word -boundaries -. -assert -! -( -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -2 -) -) -; -/ -/ -Unicode -word -boundaries -with -a -non -- -ASCII -codepoint -. -Since -this -is -/ -/ -an -ASCII -word -boundary -none -of -these -match -. -assert -! -( -! -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -4 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -4 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -5 -) -) -; -/ -/ -Unicode -word -boundaries -between -non -- -ASCII -codepoints -. -Again -since -/ -/ -this -is -an -ASCII -word -boundary -none -of -these -match -. -assert -! -( -! -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -4 -) -) -; -/ -/ -Non -word -boundaries -for -ASCII -. -assert -! -( -! -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -ab -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -3 -) -) -; -/ -/ -Non -word -boundaries -with -a -non -- -ASCII -codepoint -. -assert -! -( -testlook -! -( -look -" -b -" -4 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -5 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -6 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -3 -) -) -; -/ -/ -Non -word -boundaries -with -non -- -ASCII -codepoints -. -assert -! -( -! -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -3 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -5 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -6 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -7 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -8 -) -) -; -} -# -[ -test -] -# -[ -cfg -( -all -( -not -( -miri -) -feature -= -" -unicode -- -word -- -boundary -" -) -) -] -fn -look_matches_word_unicode_negate -( -) -{ -let -look -= -Look -: -: -WordUnicodeNegate -; -/ -/ -\ -xF0 -\ -x9D -\ -x9B -\ -x83 -= -( -in -\ -w -) -/ -/ -\ -xF0 -\ -x90 -\ -x86 -\ -x80 -= -( -not -in -\ -w -) -/ -/ -Simple -ASCII -word -boundaries -. -assert -! -( -! -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -2 -) -) -; -/ -/ -Unicode -word -boundaries -with -a -non -- -ASCII -codepoint -. -assert -! -( -! -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -4 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -4 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -5 -) -) -; -/ -/ -Unicode -word -boundaries -between -non -- -ASCII -codepoints -. -assert -! -( -! -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -4 -) -) -; -/ -/ -Non -word -boundaries -for -ASCII -. -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -ab -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -2 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -3 -) -) -; -/ -/ -Non -word -boundaries -with -a -non -- -ASCII -codepoint -. -assert -! -( -testlook -! -( -look -" -b -" -4 -) -) -; -assert -! -( -testlook -! -( -look -" -" -5 -) -) -; -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -" -6 -) -) -; -/ -/ -These -don -' -t -match -because -they -could -otherwise -return -an -offset -that -/ -/ -splits -the -UTF -- -8 -encoding -of -a -codepoint -. -assert -! -( -! -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -3 -) -) -; -/ -/ -Non -word -boundaries -with -non -- -ASCII -codepoints -. -These -also -don -' -t -/ -/ -match -because -they -could -otherwise -return -an -offset -that -splits -the -/ -/ -UTF -- -8 -encoding -of -a -codepoint -. -assert -! -( -! -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -2 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -3 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -5 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -6 -) -) -; -assert -! -( -! -testlook -! -( -look -" -" -7 -) -) -; -/ -/ -But -this -one -does -since -isn -' -t -a -word -codepoint -and -8 -is -the -end -/ -/ -of -the -haystack -. -So -the -" -end -" -of -the -haystack -isn -' -t -a -word -and -/ -/ -isn -' -t -a -word -thus -\ -B -matches -. -assert -! -( -testlook -! -( -look -" -" -8 -) -) -; -} -# -[ -test -] -fn -look_matches_word_ascii_negate -( -) -{ -let -look -= -Look -: -: -WordAsciiNegate -; -/ -/ -\ -xF0 -\ -x9D -\ -x9B -\ -x83 -= -( -in -\ -w -) -/ -/ -\ -xF0 -\ -x90 -\ -x86 -\ -x80 -= -( -not -in -\ -w -) -/ -/ -Simple -ASCII -word -boundaries -. -assert -! -( -! -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -1 -) -) -; -assert -! -( -! -testlook -! -( -look -" -a -" -2 -) -) -; -/ -/ -Unicode -word -boundaries -with -a -non -- -ASCII -codepoint -. -Since -this -is -/ -/ -an -ASCII -word -boundary -none -of -these -match -. -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -" -4 -) -) -; -assert -! -( -testlook -! -( -look -" -" -4 -) -) -; -assert -! -( -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -" -5 -) -) -; -/ -/ -Unicode -word -boundaries -between -non -- -ASCII -codepoints -. -Again -since -/ -/ -this -is -an -ASCII -word -boundary -none -of -these -match -. -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -" -4 -) -) -; -/ -/ -Non -word -boundaries -for -ASCII -. -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -ab -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -2 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -a -" -3 -) -) -; -/ -/ -Non -word -boundaries -with -a -non -- -ASCII -codepoint -. -assert -! -( -! -testlook -! -( -look -" -b -" -4 -) -) -; -assert -! -( -testlook -! -( -look -" -" -5 -) -) -; -assert -! -( -testlook -! -( -look -" -" -0 -) -) -; -assert -! -( -testlook -! -( -look -" -" -6 -) -) -; -assert -! -( -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -" -2 -) -) -; -assert -! -( -testlook -! -( -look -" -" -3 -) -) -; -/ -/ -Non -word -boundaries -with -non -- -ASCII -codepoints -. -assert -! -( -testlook -! -( -look -" -" -1 -) -) -; -assert -! -( -testlook -! -( -look -" -" -2 -) -) -; -assert -! -( -testlook -! -( -look -" -" -3 -) -) -; -assert -! -( -testlook -! -( -look -" -" -5 -) -) -; -assert -! -( -testlook -! -( -look -" -" -6 -) -) -; -assert -! -( -testlook -! -( -look -" -" -7 -) -) -; -assert -! -( -testlook -! -( -look -" -" -8 -) -) -; -} -# -[ -test -] -fn -look_set -( -) -{ -let -mut -f -= -LookSet -: -: -default -( -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -Start -) -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -End -) -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -StartLF -) -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -EndLF -) -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -WordUnicode -) -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -WordUnicodeNegate -) -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -WordAscii -) -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -WordAsciiNegate -) -) -; -f -= -f -. -insert -( -Look -: -: -Start -) -; -assert -! -( -f -. -contains -( -Look -: -: -Start -) -) -; -f -= -f -. -remove -( -Look -: -: -Start -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -Start -) -) -; -f -= -f -. -insert -( -Look -: -: -End -) -; -assert -! -( -f -. -contains -( -Look -: -: -End -) -) -; -f -= -f -. -remove -( -Look -: -: -End -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -End -) -) -; -f -= -f -. -insert -( -Look -: -: -StartLF -) -; -assert -! -( -f -. -contains -( -Look -: -: -StartLF -) -) -; -f -= -f -. -remove -( -Look -: -: -StartLF -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -StartLF -) -) -; -f -= -f -. -insert -( -Look -: -: -EndLF -) -; -assert -! -( -f -. -contains -( -Look -: -: -EndLF -) -) -; -f -= -f -. -remove -( -Look -: -: -EndLF -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -EndLF -) -) -; -f -= -f -. -insert -( -Look -: -: -StartCRLF -) -; -assert -! -( -f -. -contains -( -Look -: -: -StartCRLF -) -) -; -f -= -f -. -remove -( -Look -: -: -StartCRLF -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -StartCRLF -) -) -; -f -= -f -. -insert -( -Look -: -: -EndCRLF -) -; -assert -! -( -f -. -contains -( -Look -: -: -EndCRLF -) -) -; -f -= -f -. -remove -( -Look -: -: -EndCRLF -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -EndCRLF -) -) -; -f -= -f -. -insert -( -Look -: -: -WordUnicode -) -; -assert -! -( -f -. -contains -( -Look -: -: -WordUnicode -) -) -; -f -= -f -. -remove -( -Look -: -: -WordUnicode -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -WordUnicode -) -) -; -f -= -f -. -insert -( -Look -: -: -WordUnicodeNegate -) -; -assert -! -( -f -. -contains -( -Look -: -: -WordUnicodeNegate -) -) -; -f -= -f -. -remove -( -Look -: -: -WordUnicodeNegate -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -WordUnicodeNegate -) -) -; -f -= -f -. -insert -( -Look -: -: -WordAscii -) -; -assert -! -( -f -. -contains -( -Look -: -: -WordAscii -) -) -; -f -= -f -. -remove -( -Look -: -: -WordAscii -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -WordAscii -) -) -; -f -= -f -. -insert -( -Look -: -: -WordAsciiNegate -) -; -assert -! -( -f -. -contains -( -Look -: -: -WordAsciiNegate -) -) -; -f -= -f -. -remove -( -Look -: -: -WordAsciiNegate -) -; -assert -! -( -! -f -. -contains -( -Look -: -: -WordAsciiNegate -) -) -; -} -# -[ -test -] -fn -look_set_iter -( -) -{ -let -set -= -LookSet -: -: -empty -( -) -; -assert_eq -! -( -0 -set -. -iter -( -) -. -count -( -) -) -; -let -set -= -LookSet -: -: -full -( -) -; -assert_eq -! -( -10 -set -. -iter -( -) -. -count -( -) -) -; -let -set -= -LookSet -: -: -empty -( -) -. -insert -( -Look -: -: -StartLF -) -. -insert -( -Look -: -: -WordUnicode -) -; -assert_eq -! -( -2 -set -. -iter -( -) -. -count -( -) -) -; -let -set -= -LookSet -: -: -empty -( -) -. -insert -( -Look -: -: -StartLF -) -; -assert_eq -! -( -1 -set -. -iter -( -) -. -count -( -) -) -; -let -set -= -LookSet -: -: -empty -( -) -. -insert -( -Look -: -: -WordAsciiNegate -) -; -assert_eq -! -( -1 -set -. -iter -( -) -. -count -( -) -) -; -} -# -[ -test -] -# -[ -cfg -( -feature -= -" -alloc -" -) -] -fn -look_set_debug -( -) -{ -let -res -= -alloc -: -: -format -! -( -" -{ -: -? -} -" -LookSet -: -: -empty -( -) -) -; -assert_eq -! -( -" -" -res -) -; -let -res -= -alloc -: -: -format -! -( -" -{ -: -? -} -" -LookSet -: -: -full -( -) -) -; -assert_eq -! -( -" -Az -^ -rRbB -" -res -) -; -} -} diff --git a/third_party/rust/regex-automata/src/util/memchr.rs b/third_party/rust/regex-automata/src/util/memchr.rs deleted file mode 100644 index 338aebb16bb60..0000000000000 --- a/third_party/rust/regex-automata/src/util/memchr.rs +++ /dev/null @@ -1,836 +0,0 @@ -/ -* -! -This -module -defines -simple -wrapper -routines -for -the -memchr -functions -from -the -memchr -crate -. -Basically -when -the -memchr -crate -is -available -we -use -it -otherwise -we -use -a -naive -implementation -which -is -still -pretty -fast -. -* -/ -pub -( -crate -) -use -self -: -: -inner -: -: -* -; -# -[ -cfg -( -feature -= -" -perf -- -literal -- -substring -" -) -] -pub -( -super -) -mod -inner -{ -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memchr -( -n1 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -memchr -: -: -memchr -( -n1 -haystack -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memchr2 -( -n1 -: -u8 -n2 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -memchr -: -: -memchr2 -( -n1 -n2 -haystack -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memchr3 -( -n1 -: -u8 -n2 -: -u8 -n3 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -memchr -: -: -memchr3 -( -n1 -n2 -n3 -haystack -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memrchr -( -n1 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -memchr -: -: -memrchr -( -n1 -haystack -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memrchr2 -( -n1 -: -u8 -n2 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -memchr -: -: -memrchr2 -( -n1 -n2 -haystack -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memrchr3 -( -n1 -: -u8 -n2 -: -u8 -n3 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -memchr -: -: -memrchr3 -( -n1 -n2 -n3 -haystack -) -} -} -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -substring -" -) -) -] -pub -( -super -) -mod -inner -{ -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memchr -( -n1 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -haystack -. -iter -( -) -. -position -( -| -& -b -| -b -= -= -n1 -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memchr2 -( -n1 -: -u8 -n2 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -haystack -. -iter -( -) -. -position -( -| -& -b -| -b -= -= -n1 -| -| -b -= -= -n2 -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memchr3 -( -n1 -: -u8 -n2 -: -u8 -n3 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -haystack -. -iter -( -) -. -position -( -| -& -b -| -b -= -= -n1 -| -| -b -= -= -n2 -| -| -b -= -= -n3 -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memrchr -( -n1 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -haystack -. -iter -( -) -. -rposition -( -| -& -b -| -b -= -= -n1 -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memrchr2 -( -n1 -: -u8 -n2 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -haystack -. -iter -( -) -. -rposition -( -| -& -b -| -b -= -= -n1 -| -| -b -= -= -n2 -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -memrchr3 -( -n1 -: -u8 -n2 -: -u8 -n3 -: -u8 -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -haystack -. -iter -( -) -. -rposition -( -| -& -b -| -b -= -= -n1 -| -| -b -= -= -n2 -| -| -b -= -= -n3 -) -} -} diff --git a/third_party/rust/regex-automata/src/util/mod.rs b/third_party/rust/regex-automata/src/util/mod.rs deleted file mode 100644 index 964cf5dbc1eed..0000000000000 --- a/third_party/rust/regex-automata/src/util/mod.rs +++ /dev/null @@ -1,449 +0,0 @@ -/ -* -! -A -collection -of -modules -that -provide -APIs -that -are -useful -across -many -regex -engines -. -While -one -should -explore -the -sub -- -modules -directly -to -get -a -sense -of -what -' -s -there -here -are -some -highlights -that -tie -the -sub -- -modules -to -higher -level -use -cases -: -* -alphabet -contains -APIs -that -are -useful -if -you -' -re -doing -low -level -things -with -the -DFAs -in -this -crate -. -For -example -implementing -determinization -or -walking -its -state -graph -directly -. -* -captures -contains -APIs -for -dealing -with -capture -group -matches -and -their -mapping -to -" -slots -" -used -inside -an -NFA -graph -. -This -is -also -where -you -can -find -iterators -over -capture -group -names -. -* -escape -contains -types -for -pretty -- -printing -raw -byte -slices -as -strings -. -* -iter -contains -API -helpers -for -writing -regex -iterators -. -* -lazy -contains -a -no -- -std -and -no -- -alloc -variant -of -lazy_static -! -and -once_cell -. -* -look -contains -APIs -for -matching -and -configuring -look -- -around -assertions -. -* -pool -provides -a -way -to -reuse -mutable -memory -allocated -in -a -thread -safe -manner -. -* -prefilter -provides -APIs -for -building -prefilters -and -using -them -in -searches -. -* -primitives -are -what -you -might -use -if -you -' -re -doing -lower -level -work -on -automata -such -as -walking -an -NFA -state -graph -. -* -syntax -provides -some -higher -level -convenience -functions -for -interacting -with -the -regex -- -syntax -crate -. -* -wire -is -useful -if -you -' -re -working -with -DFA -serialization -. -* -/ -pub -mod -alphabet -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -mod -captures -; -pub -mod -escape -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -mod -interpolate -; -pub -mod -iter -; -pub -mod -lazy -; -pub -mod -look -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -mod -pool -; -pub -mod -prefilter -; -pub -mod -primitives -; -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -mod -syntax -; -pub -mod -wire -; -# -[ -cfg -( -any -( -feature -= -" -dfa -- -build -" -feature -= -" -hybrid -" -) -) -] -pub -( -crate -) -mod -determinize -; -pub -( -crate -) -mod -empty -; -pub -( -crate -) -mod -int -; -pub -( -crate -) -mod -memchr -; -pub -( -crate -) -mod -search -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -( -crate -) -mod -sparse_set -; -pub -( -crate -) -mod -start -; -pub -( -crate -) -mod -unicode_data -; -pub -( -crate -) -mod -utf8 -; diff --git a/third_party/rust/regex-automata/src/util/pool.rs b/third_party/rust/regex-automata/src/util/pool.rs deleted file mode 100644 index 73df5010e79f4..0000000000000 --- a/third_party/rust/regex-automata/src/util/pool.rs +++ /dev/null @@ -1,10318 +0,0 @@ -/ -/ -This -module -provides -a -relatively -simple -thread -- -safe -pool -of -reusable -/ -/ -objects -. -For -the -most -part -it -' -s -implemented -by -a -stack -represented -by -a -/ -/ -Mutex -< -Vec -< -T -> -> -. -It -has -one -small -trick -: -because -unlocking -a -mutex -is -somewhat -/ -/ -costly -in -the -case -where -a -pool -is -accessed -by -the -first -thread -that -tried -/ -/ -to -get -a -value -we -bypass -the -mutex -. -Here -are -some -benchmarks -showing -the -/ -/ -difference -. -/ -/ -/ -/ -2022 -- -10 -- -15 -: -These -benchmarks -are -from -the -old -regex -crate -and -they -aren -' -t -/ -/ -easy -to -reproduce -because -some -rely -on -older -implementations -of -Pool -that -/ -/ -are -no -longer -around -. -I -' -ve -left -the -results -here -for -posterity -but -any -/ -/ -enterprising -individual -should -feel -encouraged -to -re -- -litigate -the -way -Pool -/ -/ -works -. -I -am -not -at -all -certain -it -is -the -best -approach -. -/ -/ -/ -/ -1 -) -misc -: -: -anchored_literal_long_non_match -21 -( -18571 -MB -/ -s -) -/ -/ -2 -) -misc -: -: -anchored_literal_long_non_match -107 -( -3644 -MB -/ -s -) -/ -/ -3 -) -misc -: -: -anchored_literal_long_non_match -45 -( -8666 -MB -/ -s -) -/ -/ -4 -) -misc -: -: -anchored_literal_long_non_match -19 -( -20526 -MB -/ -s -) -/ -/ -/ -/ -( -1 -) -represents -our -baseline -: -the -master -branch -at -the -time -of -writing -when -/ -/ -using -the -' -thread_local -' -crate -to -implement -the -pool -below -. -/ -/ -/ -/ -( -2 -) -represents -a -naive -pool -implemented -completely -via -Mutex -< -Vec -< -T -> -> -. -There -/ -/ -is -no -special -trick -for -bypassing -the -mutex -. -/ -/ -/ -/ -( -3 -) -is -the -same -as -( -2 -) -except -it -uses -Mutex -< -Vec -< -Box -< -T -> -> -> -. -It -is -twice -as -/ -/ -fast -because -a -Box -< -T -> -is -much -smaller -than -the -T -we -use -with -a -Pool -in -this -/ -/ -crate -. -So -pushing -and -popping -a -Box -< -T -> -from -a -Vec -is -quite -a -bit -faster -/ -/ -than -for -T -. -/ -/ -/ -/ -( -4 -) -is -the -same -as -( -3 -) -but -with -the -trick -for -bypassing -the -mutex -in -the -/ -/ -case -of -the -first -- -to -- -get -thread -. -/ -/ -/ -/ -Why -move -off -of -thread_local -? -Even -though -( -4 -) -is -a -hair -faster -than -( -1 -) -/ -/ -above -this -was -not -the -main -goal -. -The -main -goal -was -to -move -off -of -/ -/ -thread_local -and -find -a -way -to -* -simply -* -re -- -capture -some -of -its -speed -for -/ -/ -regex -' -s -specific -case -. -So -again -why -move -off -of -it -? -The -* -primary -* -reason -is -/ -/ -because -of -memory -leaks -. -See -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -362 -/ -/ -for -example -. -( -Why -do -I -want -it -to -be -simple -? -Well -I -suppose -what -I -mean -is -/ -/ -" -use -as -much -safe -code -as -possible -to -minimize -risk -and -be -as -sure -as -I -can -/ -/ -be -that -it -is -correct -. -" -) -/ -/ -/ -/ -My -guess -is -that -the -thread_local -design -is -probably -not -appropriate -for -/ -/ -regex -since -its -memory -usage -scales -to -the -number -of -active -threads -that -/ -/ -have -used -a -regex -where -as -the -pool -below -scales -to -the -number -of -threads -/ -/ -that -simultaneously -use -a -regex -. -While -neither -case -permits -contraction -/ -/ -since -we -own -the -pool -data -structure -below -we -can -add -contraction -if -a -/ -/ -clear -use -case -pops -up -in -the -wild -. -More -pressingly -though -it -seems -that -/ -/ -there -are -at -least -some -use -case -patterns -where -one -might -have -many -threads -/ -/ -sitting -around -that -might -have -used -a -regex -at -one -point -. -While -thread_local -/ -/ -does -try -to -reuse -space -previously -used -by -a -thread -that -has -since -stopped -/ -/ -its -maximal -memory -usage -still -scales -with -the -total -number -of -active -/ -/ -threads -. -In -contrast -the -pool -below -scales -with -the -total -number -of -threads -/ -/ -* -simultaneously -* -using -the -pool -. -The -hope -is -that -this -uses -less -memory -/ -/ -overall -. -And -if -it -doesn -' -t -we -can -hopefully -tune -it -somehow -. -/ -/ -/ -/ -It -seems -that -these -sort -of -conditions -happen -frequently -/ -/ -in -FFI -inside -of -other -more -" -managed -" -languages -. -This -was -/ -/ -mentioned -in -the -issue -linked -above -and -also -mentioned -here -: -/ -/ -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -rure -- -go -/ -issues -/ -3 -. -And -in -particular -users -/ -/ -confirm -that -disabling -the -use -of -thread_local -resolves -the -leak -. -/ -/ -/ -/ -There -were -other -weaker -reasons -for -moving -off -of -thread_local -as -well -. -/ -/ -Namely -at -the -time -I -was -looking -to -reduce -dependencies -. -And -for -something -/ -/ -like -regex -maintenance -can -be -simpler -when -we -own -the -full -dependency -tree -. -/ -/ -/ -/ -Note -that -I -am -not -entirely -happy -with -this -pool -. -It -has -some -subtle -/ -/ -implementation -details -and -is -overall -still -observable -( -even -with -the -/ -/ -thread -owner -optimization -) -in -benchmarks -. -If -someone -wants -to -take -a -crack -/ -/ -at -building -something -better -please -file -an -issue -. -Even -if -it -means -a -/ -/ -different -API -. -The -API -exposed -by -this -pool -is -not -the -minimal -thing -that -/ -/ -something -like -a -' -Regex -' -actually -needs -. -It -could -adapt -to -for -example -/ -/ -an -API -more -like -what -is -found -in -the -' -thread_local -' -crate -. -However -we -do -/ -/ -really -need -to -support -the -no -- -std -alloc -- -only -context -or -else -the -regex -/ -/ -crate -wouldn -' -t -be -able -to -support -no -- -std -alloc -- -only -. -However -I -' -m -generally -/ -/ -okay -with -making -the -alloc -- -only -context -slower -( -as -it -is -here -) -although -I -/ -/ -do -find -it -unfortunate -. -/ -* -! -A -thread -safe -memory -pool -. -The -principal -type -in -this -module -is -a -[ -Pool -] -. -It -main -use -case -is -for -holding -a -thread -safe -collection -of -mutable -scratch -spaces -( -usually -called -Cache -in -this -crate -) -that -regex -engines -need -to -execute -a -search -. -This -then -permits -sharing -the -same -read -- -only -regex -object -across -multiple -threads -while -having -a -quick -way -of -reusing -scratch -space -in -a -thread -safe -way -. -This -avoids -needing -to -re -- -create -the -scratch -space -for -every -search -which -could -wind -up -being -quite -expensive -. -* -/ -/ -/ -/ -A -thread -safe -pool -that -works -in -an -alloc -- -only -context -. -/ -/ -/ -/ -/ -/ -Getting -a -value -out -comes -with -a -guard -. -When -that -guard -is -dropped -the -/ -/ -/ -value -is -automatically -put -back -in -the -pool -. -The -guard -provides -both -a -/ -/ -/ -Deref -and -a -DerefMut -implementation -for -easy -access -to -an -underlying -/ -/ -/ -T -. -/ -/ -/ -/ -/ -/ -A -Pool -impls -Sync -when -T -is -Send -( -even -if -T -is -not -Sync -) -. -This -/ -/ -/ -is -possible -because -a -pool -is -guaranteed -to -provide -a -value -to -exactly -one -/ -/ -/ -thread -at -any -time -. -/ -/ -/ -/ -/ -/ -Currently -a -pool -never -contracts -in -size -. -Its -size -is -proportional -to -the -/ -/ -/ -maximum -number -of -simultaneous -uses -. -This -may -change -in -the -future -. -/ -/ -/ -/ -/ -/ -A -Pool -is -a -particularly -useful -data -structure -for -this -crate -because -/ -/ -/ -many -of -the -regex -engines -require -a -mutable -" -cache -" -in -order -to -execute -/ -/ -/ -a -search -. -Since -regexes -themselves -tend -to -be -global -the -problem -is -then -: -/ -/ -/ -how -do -you -get -a -mutable -cache -to -execute -a -search -? -You -could -: -/ -/ -/ -/ -/ -/ -1 -. -Use -a -thread_local -! -which -requires -the -standard -library -and -requires -/ -/ -/ -that -the -regex -pattern -be -statically -known -. -/ -/ -/ -2 -. -Use -a -Pool -. -/ -/ -/ -3 -. -Make -the -cache -an -explicit -dependency -in -your -code -and -pass -it -around -. -/ -/ -/ -4 -. -Put -the -cache -state -in -a -Mutex -but -this -means -only -one -search -can -/ -/ -/ -execute -at -a -time -. -/ -/ -/ -5 -. -Create -a -new -cache -for -every -search -. -/ -/ -/ -/ -/ -/ -A -thread_local -! -is -perhaps -the -best -choice -if -it -works -for -your -use -case -. -/ -/ -/ -Putting -the -cache -in -a -mutex -or -creating -a -new -cache -for -every -search -are -/ -/ -/ -perhaps -the -worst -choices -. -Of -the -remaining -two -choices -whether -you -use -/ -/ -/ -this -Pool -or -thread -through -a -cache -explicitly -in -your -code -is -a -matter -/ -/ -/ -of -taste -and -depends -on -your -code -architecture -. -/ -/ -/ -/ -/ -/ -# -Warning -: -may -use -a -spin -lock -/ -/ -/ -/ -/ -/ -When -this -crate -is -compiled -_without_ -the -std -feature -then -this -type -/ -/ -/ -may -used -a -spin -lock -internally -. -This -can -have -subtle -effects -that -may -/ -/ -/ -be -undesirable -. -See -[ -Spinlocks -Considered -Harmful -] -[ -spinharm -] -for -a -more -/ -/ -/ -thorough -treatment -of -this -topic -. -/ -/ -/ -/ -/ -/ -[ -spinharm -] -: -https -: -/ -/ -matklad -. -github -. -io -/ -2020 -/ -01 -/ -02 -/ -spinlocks -- -considered -- -harmful -. -html -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -share -a -single -hybrid -regex -among -multiple -/ -/ -/ -threads -while -also -safely -getting -exclusive -access -to -a -hybrid -' -s -/ -/ -/ -[ -Cache -] -( -crate -: -: -hybrid -: -: -regex -: -: -Cache -) -without -preventing -other -searches -/ -/ -/ -from -running -while -your -thread -uses -the -Cache -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -regex -: -: -{ -Cache -Regex -} -/ -/ -/ -util -: -: -{ -lazy -: -: -Lazy -pool -: -: -Pool -} -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -static -RE -: -Lazy -< -Regex -> -= -/ -/ -/ -Lazy -: -: -new -( -| -| -Regex -: -: -new -( -" -foo -[ -0 -- -9 -] -+ -bar -" -) -. -unwrap -( -) -) -; -/ -/ -/ -static -CACHE -: -Lazy -< -Pool -< -Cache -> -> -= -/ -/ -/ -Lazy -: -: -new -( -| -| -Pool -: -: -new -( -| -| -RE -. -create_cache -( -) -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -3 -. -. -14 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -RE -. -find -( -& -mut -CACHE -. -get -( -) -b -" -zzzfoo12345barzzz -" -) -) -; -/ -/ -/ -pub -struct -Pool -< -T -F -= -fn -( -) -- -> -T -> -( -alloc -: -: -boxed -: -: -Box -< -inner -: -: -Pool -< -T -F -> -> -) -; -impl -< -T -F -> -Pool -< -T -F -> -{ -/ -/ -/ -Create -a -new -pool -. -The -given -closure -is -used -to -create -values -in -/ -/ -/ -the -pool -when -necessary -. -pub -fn -new -( -create -: -F -) -- -> -Pool -< -T -F -> -{ -Pool -( -alloc -: -: -boxed -: -: -Box -: -: -new -( -inner -: -: -Pool -: -: -new -( -create -) -) -) -} -} -impl -< -T -: -Send -F -: -Fn -( -) -- -> -T -> -Pool -< -T -F -> -{ -/ -/ -/ -Get -a -value -from -the -pool -. -The -caller -is -guaranteed -to -have -/ -/ -/ -exclusive -access -to -the -given -value -. -Namely -it -is -guaranteed -that -/ -/ -/ -this -will -never -return -a -value -that -was -returned -by -another -call -to -/ -/ -/ -get -but -was -not -put -back -into -the -pool -. -/ -/ -/ -/ -/ -/ -When -the -guard -goes -out -of -scope -and -its -destructor -is -called -then -/ -/ -/ -it -will -automatically -be -put -back -into -the -pool -. -Alternatively -/ -/ -/ -[ -PoolGuard -: -: -put -] -may -be -used -to -explicitly -put -it -back -in -the -pool -/ -/ -/ -without -relying -on -its -destructor -. -/ -/ -/ -/ -/ -/ -Note -that -there -is -no -guarantee -provided -about -which -value -in -the -/ -/ -/ -pool -is -returned -. -That -is -calling -get -dropping -the -guard -( -causing -/ -/ -/ -the -value -to -go -back -into -the -pool -) -and -then -calling -get -again -is -/ -/ -/ -* -not -* -guaranteed -to -return -the -same -value -received -in -the -first -get -/ -/ -/ -call -. -pub -fn -get -( -& -self -) -- -> -PoolGuard -< -' -_ -T -F -> -{ -PoolGuard -( -self -. -0 -. -get -( -) -) -} -} -impl -< -T -: -core -: -: -fmt -: -: -Debug -F -> -core -: -: -fmt -: -: -Debug -for -Pool -< -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -" -Pool -" -) -. -field -( -& -self -. -0 -) -. -finish -( -) -} -} -/ -/ -/ -A -guard -that -is -returned -when -a -caller -requests -a -value -from -the -pool -. -/ -/ -/ -/ -/ -/ -The -purpose -of -the -guard -is -to -use -RAII -to -automatically -put -the -value -/ -/ -/ -back -in -the -pool -once -it -' -s -dropped -. -pub -struct -PoolGuard -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -( -inner -: -: -PoolGuard -< -' -a -T -F -> -) -; -impl -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -PoolGuard -< -' -a -T -F -> -{ -/ -/ -/ -Consumes -this -guard -and -puts -it -back -into -the -pool -. -/ -/ -/ -/ -/ -/ -This -circumvents -the -guard -' -s -Drop -implementation -. -This -can -be -useful -/ -/ -/ -in -circumstances -where -the -automatic -Drop -results -in -poorer -codegen -/ -/ -/ -such -as -calling -non -- -inlined -functions -. -pub -fn -put -( -this -: -PoolGuard -< -' -_ -T -F -> -) -{ -inner -: -: -PoolGuard -: -: -put -( -this -. -0 -) -; -} -} -impl -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -core -: -: -ops -: -: -Deref -for -PoolGuard -< -' -a -T -F -> -{ -type -Target -= -T -; -fn -deref -( -& -self -) -- -> -& -T -{ -self -. -0 -. -value -( -) -} -} -impl -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -core -: -: -ops -: -: -DerefMut -for -PoolGuard -< -' -a -T -F -> -{ -fn -deref_mut -( -& -mut -self -) -- -> -& -mut -T -{ -self -. -0 -. -value_mut -( -) -} -} -impl -< -' -a -T -: -Send -+ -core -: -: -fmt -: -: -Debug -F -: -Fn -( -) -- -> -T -> -core -: -: -fmt -: -: -Debug -for -PoolGuard -< -' -a -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -" -PoolGuard -" -) -. -field -( -& -self -. -0 -) -. -finish -( -) -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -mod -inner -{ -use -core -: -: -{ -cell -: -: -UnsafeCell -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -sync -: -: -atomic -: -: -{ -AtomicUsize -Ordering -} -} -; -use -alloc -: -: -{ -boxed -: -: -Box -vec -vec -: -: -Vec -} -; -use -std -: -: -{ -sync -: -: -Mutex -thread_local -} -; -/ -/ -/ -An -atomic -counter -used -to -allocate -thread -IDs -. -/ -/ -/ -/ -/ -/ -We -specifically -start -our -counter -at -3 -so -that -we -can -use -the -values -/ -/ -/ -less -than -it -as -sentinels -. -static -COUNTER -: -AtomicUsize -= -AtomicUsize -: -: -new -( -3 -) -; -/ -/ -/ -A -thread -ID -indicating -that -there -is -no -owner -. -This -is -the -initial -/ -/ -/ -state -of -a -pool -. -Once -a -pool -has -an -owner -there -is -no -way -to -change -/ -/ -/ -it -. -static -THREAD_ID_UNOWNED -: -usize -= -0 -; -/ -/ -/ -A -thread -ID -indicating -that -the -special -owner -value -is -in -use -and -not -/ -/ -/ -available -. -This -state -is -useful -for -avoiding -a -case -where -the -owner -/ -/ -/ -of -a -pool -calls -get -before -putting -the -result -of -a -previous -get -/ -/ -/ -call -back -into -the -pool -. -static -THREAD_ID_INUSE -: -usize -= -1 -; -/ -/ -/ -This -sentinel -is -used -to -indicate -that -a -guard -has -already -been -dropped -/ -/ -/ -and -should -not -be -re -- -dropped -. -We -use -this -because -our -drop -code -can -be -/ -/ -/ -called -outside -of -Drop -and -thus -there -could -be -a -bug -in -the -internal -/ -/ -/ -implementation -that -results -in -trying -to -put -the -same -guard -back -into -/ -/ -/ -the -same -pool -multiple -times -and -* -that -* -could -result -in -UB -if -we -/ -/ -/ -didn -' -t -mark -the -guard -as -already -having -been -put -back -in -the -pool -. -/ -/ -/ -/ -/ -/ -So -this -isn -' -t -strictly -necessary -but -this -let -' -s -us -define -some -/ -/ -/ -routines -as -safe -( -like -PoolGuard -: -: -put_imp -) -that -we -couldn -' -t -otherwise -/ -/ -/ -do -. -static -THREAD_ID_DROPPED -: -usize -= -2 -; -thread_local -! -( -/ -/ -/ -A -thread -local -used -to -assign -an -ID -to -a -thread -. -static -THREAD_ID -: -usize -= -{ -let -next -= -COUNTER -. -fetch_add -( -1 -Ordering -: -: -Relaxed -) -; -/ -/ -SAFETY -: -We -cannot -permit -the -reuse -of -thread -IDs -since -reusing -a -/ -/ -thread -ID -might -result -in -more -than -one -thread -" -owning -" -a -pool -/ -/ -and -thus -permit -accessing -a -mutable -value -from -multiple -threads -/ -/ -simultaneously -without -synchronization -. -The -intent -of -this -panic -/ -/ -is -to -be -a -sanity -check -. -It -is -not -expected -that -the -thread -ID -/ -/ -space -will -actually -be -exhausted -in -practice -. -Even -on -a -32 -- -bit -/ -/ -system -it -would -require -spawning -2 -^ -32 -threads -( -although -they -/ -/ -wouldn -' -t -all -need -to -run -simultaneously -so -it -is -in -theory -/ -/ -possible -) -. -/ -/ -/ -/ -This -checks -that -the -counter -never -wraps -around -since -atomic -/ -/ -addition -wraps -around -on -overflow -. -if -next -= -= -0 -{ -panic -! -( -" -regex -: -thread -ID -allocation -space -exhausted -" -) -; -} -next -} -; -) -; -/ -/ -/ -A -thread -safe -pool -utilizing -std -- -only -features -. -/ -/ -/ -/ -/ -/ -The -main -difference -between -this -and -the -simplistic -alloc -- -only -pool -is -/ -/ -/ -the -use -of -std -: -: -sync -: -: -Mutex -and -an -" -owner -thread -" -optimization -that -/ -/ -/ -makes -accesses -by -the -owner -of -a -pool -faster -than -all -other -threads -. -/ -/ -/ -This -makes -the -common -case -of -running -a -regex -within -a -single -thread -/ -/ -/ -faster -by -avoiding -mutex -unlocking -. -pub -( -super -) -struct -Pool -< -T -F -> -{ -/ -/ -/ -A -stack -of -T -values -to -hand -out -. -These -are -used -when -a -Pool -is -/ -/ -/ -accessed -by -a -thread -that -didn -' -t -create -it -. -stack -: -Mutex -< -Vec -< -Box -< -T -> -> -> -/ -/ -/ -A -function -to -create -more -T -values -when -stack -is -empty -and -a -caller -/ -/ -/ -has -requested -a -T -. -create -: -F -/ -/ -/ -The -ID -of -the -thread -that -owns -this -pool -. -The -owner -is -the -thread -/ -/ -/ -that -makes -the -first -call -to -' -get -' -. -When -the -owner -calls -' -get -' -it -/ -/ -/ -gets -' -owner_val -' -directly -instead -of -returning -a -T -from -' -stack -' -. -/ -/ -/ -See -comments -elsewhere -for -details -but -this -is -intended -to -be -an -/ -/ -/ -optimization -for -the -common -case -that -makes -getting -a -T -faster -. -/ -/ -/ -/ -/ -/ -It -is -initialized -to -a -value -of -zero -( -an -impossible -thread -ID -) -as -a -/ -/ -/ -sentinel -to -indicate -that -it -is -unowned -. -owner -: -AtomicUsize -/ -/ -/ -A -value -to -return -when -the -caller -is -in -the -same -thread -that -/ -/ -/ -first -called -Pool -: -: -get -. -/ -/ -/ -/ -/ -/ -This -is -set -to -None -when -a -Pool -is -first -created -and -set -to -Some -/ -/ -/ -once -the -first -thread -calls -Pool -: -: -get -. -owner_val -: -UnsafeCell -< -Option -< -T -> -> -} -/ -/ -SAFETY -: -Since -we -want -to -use -a -Pool -from -multiple -threads -simultaneously -/ -/ -behind -an -Arc -we -need -for -it -to -be -Sync -. -In -cases -where -T -is -sync -/ -/ -Pool -< -T -> -would -be -Sync -. -However -since -we -use -a -Pool -to -store -mutable -/ -/ -scratch -space -we -wind -up -using -a -T -that -has -interior -mutability -and -is -/ -/ -thus -itself -not -Sync -. -So -what -we -* -really -* -want -is -for -our -Pool -< -T -> -to -by -/ -/ -Sync -even -when -T -is -not -Sync -( -but -is -at -least -Send -) -. -/ -/ -/ -/ -The -only -non -- -sync -aspect -of -a -Pool -is -its -' -owner_val -' -field -which -is -/ -/ -used -to -implement -faster -access -to -a -pool -value -in -the -common -case -of -/ -/ -a -pool -being -accessed -in -the -same -thread -in -which -it -was -created -. -The -/ -/ -' -stack -' -field -is -also -shared -but -a -Mutex -< -T -> -where -T -: -Send -is -already -/ -/ -Sync -. -So -we -only -need -to -worry -about -' -owner_val -' -. -/ -/ -/ -/ -The -key -is -to -guarantee -that -' -owner_val -' -can -only -ever -be -accessed -from -/ -/ -one -thread -. -In -our -implementation -below -we -guarantee -this -by -only -/ -/ -returning -the -' -owner_val -' -when -the -ID -of -the -current -thread -matches -the -/ -/ -ID -of -the -thread -that -first -called -' -Pool -: -: -get -' -. -Since -this -can -only -ever -/ -/ -be -one -thread -it -follows -that -only -one -thread -can -access -' -owner_val -' -at -/ -/ -any -point -in -time -. -Thus -it -is -safe -to -declare -that -Pool -< -T -> -is -Sync -when -/ -/ -T -is -Send -. -/ -/ -/ -/ -If -there -is -a -way -to -achieve -our -performance -goals -using -safe -code -then -/ -/ -I -would -very -much -welcome -a -patch -. -As -it -stands -the -implementation -/ -/ -below -tries -to -balance -safety -with -performance -. -The -case -where -a -Regex -/ -/ -is -used -from -multiple -threads -simultaneously -will -suffer -a -bit -since -/ -/ -getting -a -value -out -of -the -pool -will -require -unlocking -a -mutex -. -/ -/ -/ -/ -We -require -F -: -Send -+ -Sync -because -we -call -F -at -any -point -on -demand -/ -/ -potentially -from -multiple -threads -simultaneously -. -unsafe -impl -< -T -: -Send -F -: -Send -+ -Sync -> -Sync -for -Pool -< -T -F -> -{ -} -/ -/ -If -T -is -UnwindSafe -then -since -we -provide -exclusive -access -to -any -/ -/ -particular -value -in -the -pool -it -should -therefore -also -be -considered -/ -/ -RefUnwindSafe -. -Also -since -we -use -std -: -: -sync -: -: -Mutex -we -get -poisoning -/ -/ -from -it -if -another -thread -panics -while -the -lock -is -held -. -/ -/ -/ -/ -We -require -F -: -UnwindSafe -+ -RefUnwindSafe -because -we -call -F -at -any -/ -/ -point -on -demand -so -it -needs -to -be -unwind -safe -on -both -dimensions -for -/ -/ -the -entire -Pool -to -be -unwind -safe -. -impl -< -T -: -UnwindSafe -F -: -UnwindSafe -+ -RefUnwindSafe -> -RefUnwindSafe -for -Pool -< -T -F -> -{ -} -impl -< -T -F -> -Pool -< -T -F -> -{ -/ -/ -/ -Create -a -new -pool -. -The -given -closure -is -used -to -create -values -in -/ -/ -/ -the -pool -when -necessary -. -pub -( -super -) -fn -new -( -create -: -F -) -- -> -Pool -< -T -F -> -{ -/ -/ -MSRV -( -1 -. -63 -) -: -Mark -this -function -as -' -const -' -. -I -' -ve -arranged -the -/ -/ -code -such -that -it -should -" -just -work -. -" -Then -mark -the -public -/ -/ -' -Pool -: -: -new -' -method -as -' -const -' -too -. -( -The -alloc -- -only -Pool -: -: -new -/ -/ -is -already -' -const -' -so -that -should -" -just -work -" -too -. -) -The -only -/ -/ -thing -we -' -re -waiting -for -is -Mutex -: -: -new -to -be -const -. -let -owner -= -AtomicUsize -: -: -new -( -THREAD_ID_UNOWNED -) -; -let -owner_val -= -UnsafeCell -: -: -new -( -None -) -; -/ -/ -init -' -d -on -first -access -Pool -{ -stack -: -Mutex -: -: -new -( -vec -! -[ -] -) -create -owner -owner_val -} -} -} -impl -< -T -: -Send -F -: -Fn -( -) -- -> -T -> -Pool -< -T -F -> -{ -/ -/ -/ -Get -a -value -from -the -pool -. -This -may -block -if -another -thread -is -also -/ -/ -/ -attempting -to -retrieve -a -value -from -the -pool -. -pub -( -super -) -fn -get -( -& -self -) -- -> -PoolGuard -< -' -_ -T -F -> -{ -/ -/ -Our -fast -path -checks -if -the -caller -is -the -thread -that -" -owns -" -/ -/ -this -pool -. -Or -stated -differently -whether -it -is -the -first -thread -/ -/ -that -tried -to -extract -a -value -from -the -pool -. -If -it -is -then -we -/ -/ -can -return -a -T -to -the -caller -without -going -through -a -mutex -. -/ -/ -/ -/ -SAFETY -: -We -must -guarantee -that -only -one -thread -gets -access -/ -/ -to -this -value -. -Since -a -thread -is -uniquely -identified -by -the -/ -/ -THREAD_ID -thread -local -it -follows -that -if -the -caller -' -s -thread -/ -/ -ID -is -equal -to -the -owner -then -only -one -thread -may -receive -this -/ -/ -value -. -This -is -also -why -we -can -get -away -with -what -looks -like -a -/ -/ -racy -load -and -a -store -. -We -know -that -if -' -owner -= -= -caller -' -then -/ -/ -only -one -thread -can -be -here -so -we -don -' -t -need -to -worry -about -any -/ -/ -other -thread -setting -the -owner -to -something -else -. -let -caller -= -THREAD_ID -. -with -( -| -id -| -* -id -) -; -let -owner -= -self -. -owner -. -load -( -Ordering -: -: -Acquire -) -; -if -caller -= -= -owner -{ -self -. -owner -. -store -( -THREAD_ID_INUSE -Ordering -: -: -Release -) -; -return -self -. -guard_owned -( -caller -) -; -} -self -. -get_slow -( -caller -owner -) -} -/ -/ -/ -This -is -the -" -slow -" -version -that -goes -through -a -mutex -to -pop -an -/ -/ -/ -allocated -value -off -a -stack -to -return -to -the -caller -. -( -Or -if -the -/ -/ -/ -stack -is -empty -a -new -value -is -created -. -) -/ -/ -/ -/ -/ -/ -If -the -pool -has -no -owner -then -this -will -set -the -owner -. -# -[ -cold -] -fn -get_slow -( -& -self -caller -: -usize -owner -: -usize -) -- -> -PoolGuard -< -' -_ -T -F -> -{ -if -owner -= -= -THREAD_ID_UNOWNED -{ -/ -/ -This -sentinel -means -this -pool -is -not -yet -owned -. -We -try -to -/ -/ -atomically -set -the -owner -. -If -we -do -then -this -thread -becomes -/ -/ -the -owner -and -we -can -return -a -guard -that -represents -the -/ -/ -special -T -for -the -owner -. -/ -/ -/ -/ -Note -that -we -set -the -owner -to -a -different -sentinel -that -/ -/ -indicates -that -the -owned -value -is -in -use -. -The -owner -ID -will -/ -/ -get -updated -to -the -actual -ID -of -this -thread -once -the -guard -/ -/ -returned -by -this -function -is -put -back -into -the -pool -. -let -res -= -self -. -owner -. -compare_exchange -( -THREAD_ID_UNOWNED -THREAD_ID_INUSE -Ordering -: -: -AcqRel -Ordering -: -: -Acquire -) -; -if -res -. -is_ok -( -) -{ -/ -/ -SAFETY -: -A -successful -CAS -above -implies -this -thread -is -/ -/ -the -owner -and -that -this -is -the -only -such -thread -that -/ -/ -can -reach -here -. -Thus -there -is -no -data -race -. -unsafe -{ -* -self -. -owner_val -. -get -( -) -= -Some -( -( -self -. -create -) -( -) -) -; -} -return -self -. -guard_owned -( -caller -) -; -} -} -let -mut -stack -= -self -. -stack -. -lock -( -) -. -unwrap -( -) -; -let -value -= -match -stack -. -pop -( -) -{ -None -= -> -Box -: -: -new -( -( -self -. -create -) -( -) -) -Some -( -value -) -= -> -value -} -; -self -. -guard_stack -( -value -) -} -/ -/ -/ -Puts -a -value -back -into -the -pool -. -Callers -don -' -t -need -to -call -this -. -/ -/ -/ -Once -the -guard -that -' -s -returned -by -' -get -' -is -dropped -it -is -put -back -/ -/ -/ -into -the -pool -automatically -. -fn -put_value -( -& -self -value -: -Box -< -T -> -) -{ -let -mut -stack -= -self -. -stack -. -lock -( -) -. -unwrap -( -) -; -stack -. -push -( -value -) -; -} -/ -/ -/ -Create -a -guard -that -represents -the -special -owned -T -. -fn -guard_owned -( -& -self -caller -: -usize -) -- -> -PoolGuard -< -' -_ -T -F -> -{ -PoolGuard -{ -pool -: -self -value -: -Err -( -caller -) -} -} -/ -/ -/ -Create -a -guard -that -contains -a -value -from -the -pool -' -s -stack -. -fn -guard_stack -( -& -self -value -: -Box -< -T -> -) -- -> -PoolGuard -< -' -_ -T -F -> -{ -PoolGuard -{ -pool -: -self -value -: -Ok -( -value -) -} -} -} -impl -< -T -: -core -: -: -fmt -: -: -Debug -F -> -core -: -: -fmt -: -: -Debug -for -Pool -< -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -Pool -" -) -. -field -( -" -stack -" -& -self -. -stack -) -. -field -( -" -owner -" -& -self -. -owner -) -. -field -( -" -owner_val -" -& -self -. -owner_val -) -. -finish -( -) -} -} -/ -/ -/ -A -guard -that -is -returned -when -a -caller -requests -a -value -from -the -pool -. -pub -( -super -) -struct -PoolGuard -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -{ -/ -/ -/ -The -pool -that -this -guard -is -attached -to -. -pool -: -& -' -a -Pool -< -T -F -> -/ -/ -/ -This -is -Err -when -the -guard -represents -the -special -" -owned -" -value -. -/ -/ -/ -In -which -case -the -value -is -retrieved -from -' -pool -. -owner_val -' -. -And -/ -/ -/ -in -the -special -case -of -Err -( -THREAD_ID_DROPPED -) -it -means -the -/ -/ -/ -guard -has -been -put -back -into -the -pool -and -should -no -longer -be -used -. -value -: -Result -< -Box -< -T -> -usize -> -} -impl -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -PoolGuard -< -' -a -T -F -> -{ -/ -/ -/ -Return -the -underlying -value -. -pub -( -super -) -fn -value -( -& -self -) -- -> -& -T -{ -match -self -. -value -{ -Ok -( -ref -v -) -= -> -& -* -* -v -/ -/ -SAFETY -: -This -is -safe -because -the -only -way -a -PoolGuard -gets -/ -/ -created -for -self -. -value -= -Err -is -when -the -current -thread -/ -/ -corresponds -to -the -owning -thread -of -which -there -can -only -/ -/ -be -one -. -Thus -we -are -guaranteed -to -be -providing -exclusive -/ -/ -access -here -which -makes -this -safe -. -/ -/ -/ -/ -Also -since -' -owner_val -' -is -guaranteed -to -be -initialized -/ -/ -before -an -owned -PoolGuard -is -created -the -unchecked -unwrap -/ -/ -is -safe -. -Err -( -id -) -= -> -unsafe -{ -/ -/ -This -assert -is -* -not -* -necessary -for -safety -since -we -/ -/ -should -never -be -here -if -the -guard -had -been -put -back -into -/ -/ -the -pool -. -This -is -a -sanity -check -to -make -sure -we -didn -' -t -/ -/ -break -an -internal -invariant -. -debug_assert_ne -! -( -THREAD_ID_DROPPED -id -) -; -( -* -self -. -pool -. -owner_val -. -get -( -) -) -. -as_ref -( -) -. -unwrap_unchecked -( -) -} -} -} -/ -/ -/ -Return -the -underlying -value -as -a -mutable -borrow -. -pub -( -super -) -fn -value_mut -( -& -mut -self -) -- -> -& -mut -T -{ -match -self -. -value -{ -Ok -( -ref -mut -v -) -= -> -& -mut -* -* -v -/ -/ -SAFETY -: -This -is -safe -because -the -only -way -a -PoolGuard -gets -/ -/ -created -for -self -. -value -= -None -is -when -the -current -thread -/ -/ -corresponds -to -the -owning -thread -of -which -there -can -only -/ -/ -be -one -. -Thus -we -are -guaranteed -to -be -providing -exclusive -/ -/ -access -here -which -makes -this -safe -. -/ -/ -/ -/ -Also -since -' -owner_val -' -is -guaranteed -to -be -initialized -/ -/ -before -an -owned -PoolGuard -is -created -the -unwrap_unchecked -/ -/ -is -safe -. -Err -( -id -) -= -> -unsafe -{ -/ -/ -This -assert -is -* -not -* -necessary -for -safety -since -we -/ -/ -should -never -be -here -if -the -guard -had -been -put -back -into -/ -/ -the -pool -. -This -is -a -sanity -check -to -make -sure -we -didn -' -t -/ -/ -break -an -internal -invariant -. -debug_assert_ne -! -( -THREAD_ID_DROPPED -id -) -; -( -* -self -. -pool -. -owner_val -. -get -( -) -) -. -as_mut -( -) -. -unwrap_unchecked -( -) -} -} -} -/ -/ -/ -Consumes -this -guard -and -puts -it -back -into -the -pool -. -pub -( -super -) -fn -put -( -this -: -PoolGuard -< -' -_ -T -F -> -) -{ -/ -/ -Since -this -is -effectively -consuming -the -guard -and -putting -the -/ -/ -value -back -into -the -pool -there -' -s -no -reason -to -run -its -Drop -/ -/ -impl -after -doing -this -. -I -don -' -t -believe -there -is -a -correctness -/ -/ -problem -with -doing -so -but -there -' -s -definitely -a -perf -problem -/ -/ -by -redoing -this -work -. -So -we -avoid -it -. -let -mut -this -= -core -: -: -mem -: -: -ManuallyDrop -: -: -new -( -this -) -; -this -. -put_imp -( -) -; -} -/ -/ -/ -Puts -this -guard -back -into -the -pool -by -only -borrowing -the -guard -as -/ -/ -/ -mutable -. -This -should -be -called -at -most -once -. -# -[ -inline -( -always -) -] -fn -put_imp -( -& -mut -self -) -{ -match -core -: -: -mem -: -: -replace -( -& -mut -self -. -value -Err -( -THREAD_ID_DROPPED -) -) -{ -Ok -( -value -) -= -> -self -. -pool -. -put_value -( -value -) -/ -/ -If -this -guard -has -a -value -" -owned -" -by -the -thread -then -/ -/ -the -Pool -guarantees -that -this -is -the -ONLY -such -guard -. -/ -/ -Therefore -in -order -to -place -it -back -into -the -pool -and -make -/ -/ -it -available -we -need -to -change -the -owner -back -to -the -owning -/ -/ -thread -' -s -ID -. -But -note -that -we -use -the -ID -that -was -stored -in -/ -/ -the -guard -since -a -guard -can -be -moved -to -another -thread -and -/ -/ -dropped -. -( -A -previous -iteration -of -this -code -read -from -the -/ -/ -THREAD_ID -thread -local -which -uses -the -ID -of -the -current -/ -/ -thread -which -may -not -be -the -ID -of -the -owning -thread -! -This -/ -/ -also -avoids -the -TLS -access -which -is -likely -a -hair -faster -. -) -Err -( -owner -) -= -> -{ -/ -/ -If -we -hit -this -point -it -implies -' -put_imp -' -has -been -/ -/ -called -multiple -times -for -the -same -guard -which -in -turn -/ -/ -corresponds -to -a -bug -in -this -implementation -. -assert_ne -! -( -THREAD_ID_DROPPED -owner -) -; -self -. -pool -. -owner -. -store -( -owner -Ordering -: -: -Release -) -; -} -} -} -} -impl -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -Drop -for -PoolGuard -< -' -a -T -F -> -{ -fn -drop -( -& -mut -self -) -{ -self -. -put_imp -( -) -; -} -} -impl -< -' -a -T -: -Send -+ -core -: -: -fmt -: -: -Debug -F -: -Fn -( -) -- -> -T -> -core -: -: -fmt -: -: -Debug -for -PoolGuard -< -' -a -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -PoolGuard -" -) -. -field -( -" -pool -" -& -self -. -pool -) -. -field -( -" -value -" -& -self -. -value -) -. -finish -( -) -} -} -} -/ -/ -FUTURE -: -We -should -consider -using -Mara -Bos -' -s -nearly -- -lock -- -free -version -of -this -/ -/ -here -: -https -: -/ -/ -gist -. -github -. -com -/ -m -- -ou -- -se -/ -5fdcbdf7dcf4585199ce2de697f367a4 -. -/ -/ -/ -/ -One -reason -why -I -did -things -with -a -" -mutex -" -below -is -that -it -isolates -the -/ -/ -safety -concerns -to -just -the -Mutex -where -as -the -safety -of -Mara -' -s -pool -is -a -/ -/ -bit -more -sprawling -. -I -also -expect -this -code -to -not -be -used -that -much -and -/ -/ -so -is -unlikely -to -get -as -much -real -world -usage -with -which -to -test -it -. -That -/ -/ -means -the -" -obviously -correct -" -lever -is -an -important -one -. -/ -/ -/ -/ -The -specific -reason -to -use -Mara -' -s -pool -is -that -it -is -likely -faster -and -also -/ -/ -less -likely -to -hit -problems -with -spin -- -locks -although -it -is -not -completely -/ -/ -impervious -to -them -. -/ -/ -/ -/ -The -best -solution -to -this -problem -probably -is -a -truly -lock -free -pool -. -That -/ -/ -could -be -done -with -a -lock -free -linked -list -. -The -issue -is -the -ABA -problem -. -It -/ -/ -is -difficult -to -avoid -and -doing -so -is -complex -. -BUT -the -upshot -of -that -is -/ -/ -that -if -we -had -a -truly -lock -free -pool -then -we -could -also -use -it -above -in -/ -/ -the -' -std -' -pool -instead -of -a -Mutex -because -it -should -be -completely -free -the -/ -/ -problems -that -come -from -spin -- -locks -. -# -[ -cfg -( -not -( -feature -= -" -std -" -) -) -] -mod -inner -{ -use -core -: -: -{ -cell -: -: -UnsafeCell -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -sync -: -: -atomic -: -: -{ -AtomicBool -Ordering -} -} -; -use -alloc -: -: -{ -boxed -: -: -Box -vec -vec -: -: -Vec -} -; -/ -/ -/ -A -thread -safe -pool -utilizing -alloc -- -only -features -. -/ -/ -/ -/ -/ -/ -Unlike -the -std -version -it -doesn -' -t -seem -possible -( -? -) -to -implement -the -/ -/ -/ -" -thread -owner -" -optimization -because -alloc -- -only -doesn -' -t -have -any -concept -/ -/ -/ -of -threads -. -So -the -best -we -can -do -is -just -a -normal -stack -. -This -will -/ -/ -/ -increase -latency -in -alloc -- -only -environments -. -pub -( -super -) -struct -Pool -< -T -F -> -{ -/ -/ -/ -A -stack -of -T -values -to -hand -out -. -These -are -used -when -a -Pool -is -/ -/ -/ -accessed -by -a -thread -that -didn -' -t -create -it -. -stack -: -Mutex -< -Vec -< -Box -< -T -> -> -> -/ -/ -/ -A -function -to -create -more -T -values -when -stack -is -empty -and -a -caller -/ -/ -/ -has -requested -a -T -. -create -: -F -} -/ -/ -If -T -is -UnwindSafe -then -since -we -provide -exclusive -access -to -any -/ -/ -particular -value -in -the -pool -it -should -therefore -also -be -considered -/ -/ -RefUnwindSafe -. -impl -< -T -: -UnwindSafe -F -: -UnwindSafe -> -RefUnwindSafe -for -Pool -< -T -F -> -{ -} -impl -< -T -F -> -Pool -< -T -F -> -{ -/ -/ -/ -Create -a -new -pool -. -The -given -closure -is -used -to -create -values -in -/ -/ -/ -the -pool -when -necessary -. -pub -( -super -) -const -fn -new -( -create -: -F -) -- -> -Pool -< -T -F -> -{ -Pool -{ -stack -: -Mutex -: -: -new -( -vec -! -[ -] -) -create -} -} -} -impl -< -T -: -Send -F -: -Fn -( -) -- -> -T -> -Pool -< -T -F -> -{ -/ -/ -/ -Get -a -value -from -the -pool -. -This -may -block -if -another -thread -is -also -/ -/ -/ -attempting -to -retrieve -a -value -from -the -pool -. -pub -( -super -) -fn -get -( -& -self -) -- -> -PoolGuard -< -' -_ -T -F -> -{ -let -mut -stack -= -self -. -stack -. -lock -( -) -; -let -value -= -match -stack -. -pop -( -) -{ -None -= -> -Box -: -: -new -( -( -self -. -create -) -( -) -) -Some -( -value -) -= -> -value -} -; -PoolGuard -{ -pool -: -self -value -: -Some -( -value -) -} -} -fn -put -( -& -self -guard -: -PoolGuard -< -' -_ -T -F -> -) -{ -let -mut -guard -= -core -: -: -mem -: -: -ManuallyDrop -: -: -new -( -guard -) -; -if -let -Some -( -value -) -= -guard -. -value -. -take -( -) -{ -self -. -put_value -( -value -) -; -} -} -/ -/ -/ -Puts -a -value -back -into -the -pool -. -Callers -don -' -t -need -to -call -this -. -/ -/ -/ -Once -the -guard -that -' -s -returned -by -' -get -' -is -dropped -it -is -put -back -/ -/ -/ -into -the -pool -automatically -. -fn -put_value -( -& -self -value -: -Box -< -T -> -) -{ -let -mut -stack -= -self -. -stack -. -lock -( -) -; -stack -. -push -( -value -) -; -} -} -impl -< -T -: -core -: -: -fmt -: -: -Debug -F -> -core -: -: -fmt -: -: -Debug -for -Pool -< -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -Pool -" -) -. -field -( -" -stack -" -& -self -. -stack -) -. -finish -( -) -} -} -/ -/ -/ -A -guard -that -is -returned -when -a -caller -requests -a -value -from -the -pool -. -pub -( -super -) -struct -PoolGuard -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -{ -/ -/ -/ -The -pool -that -this -guard -is -attached -to -. -pool -: -& -' -a -Pool -< -T -F -> -/ -/ -/ -This -is -None -after -the -guard -has -been -put -back -into -the -pool -. -value -: -Option -< -Box -< -T -> -> -} -impl -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -PoolGuard -< -' -a -T -F -> -{ -/ -/ -/ -Return -the -underlying -value -. -pub -( -super -) -fn -value -( -& -self -) -- -> -& -T -{ -self -. -value -. -as_deref -( -) -. -unwrap -( -) -} -/ -/ -/ -Return -the -underlying -value -as -a -mutable -borrow -. -pub -( -super -) -fn -value_mut -( -& -mut -self -) -- -> -& -mut -T -{ -self -. -value -. -as_deref_mut -( -) -. -unwrap -( -) -} -/ -/ -/ -Consumes -this -guard -and -puts -it -back -into -the -pool -. -pub -( -super -) -fn -put -( -this -: -PoolGuard -< -' -_ -T -F -> -) -{ -/ -/ -Since -this -is -effectively -consuming -the -guard -and -putting -the -/ -/ -value -back -into -the -pool -there -' -s -no -reason -to -run -its -Drop -/ -/ -impl -after -doing -this -. -I -don -' -t -believe -there -is -a -correctness -/ -/ -problem -with -doing -so -but -there -' -s -definitely -a -perf -problem -/ -/ -by -redoing -this -work -. -So -we -avoid -it -. -let -mut -this -= -core -: -: -mem -: -: -ManuallyDrop -: -: -new -( -this -) -; -this -. -put_imp -( -) -; -} -/ -/ -/ -Puts -this -guard -back -into -the -pool -by -only -borrowing -the -guard -as -/ -/ -/ -mutable -. -This -should -be -called -at -most -once -. -# -[ -inline -( -always -) -] -fn -put_imp -( -& -mut -self -) -{ -if -let -Some -( -value -) -= -self -. -value -. -take -( -) -{ -self -. -pool -. -put_value -( -value -) -; -} -} -} -impl -< -' -a -T -: -Send -F -: -Fn -( -) -- -> -T -> -Drop -for -PoolGuard -< -' -a -T -F -> -{ -fn -drop -( -& -mut -self -) -{ -self -. -put_imp -( -) -; -} -} -impl -< -' -a -T -: -Send -+ -core -: -: -fmt -: -: -Debug -F -: -Fn -( -) -- -> -T -> -core -: -: -fmt -: -: -Debug -for -PoolGuard -< -' -a -T -F -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -PoolGuard -" -) -. -field -( -" -pool -" -& -self -. -pool -) -. -field -( -" -value -" -& -self -. -value -) -. -finish -( -) -} -} -/ -/ -/ -A -spin -- -lock -based -mutex -. -Yes -I -have -read -spinlocks -cosnidered -/ -/ -/ -harmful -[ -1 -] -and -if -there -' -s -a -reasonable -alternative -choice -I -' -ll -/ -/ -/ -happily -take -it -. -/ -/ -/ -/ -/ -/ -I -suspect -the -most -likely -alternative -here -is -a -Treiber -stack -but -/ -/ -/ -implementing -one -correctly -in -a -way -that -avoids -the -ABA -problem -looks -/ -/ -/ -subtle -enough -that -I -' -m -not -sure -I -want -to -attempt -that -. -But -otherwise -/ -/ -/ -we -only -need -a -mutex -in -order -to -implement -our -pool -so -if -there -' -s -/ -/ -/ -something -simpler -we -can -use -that -works -for -our -Pool -use -case -then -/ -/ -/ -that -would -be -great -. -/ -/ -/ -/ -/ -/ -Note -that -this -mutex -does -not -do -poisoning -. -/ -/ -/ -/ -/ -/ -[ -1 -] -: -https -: -/ -/ -matklad -. -github -. -io -/ -2020 -/ -01 -/ -02 -/ -spinlocks -- -considered -- -harmful -. -html -# -[ -derive -( -Debug -) -] -struct -Mutex -< -T -> -{ -locked -: -AtomicBool -data -: -UnsafeCell -< -T -> -} -/ -/ -SAFETY -: -Since -a -Mutex -guarantees -exclusive -access -as -long -as -we -can -/ -/ -send -it -across -threads -it -must -also -be -Sync -. -unsafe -impl -< -T -: -Send -> -Sync -for -Mutex -< -T -> -{ -} -impl -< -T -> -Mutex -< -T -> -{ -/ -/ -/ -Create -a -new -mutex -for -protecting -access -to -the -given -value -across -/ -/ -/ -multiple -threads -simultaneously -. -const -fn -new -( -value -: -T -) -- -> -Mutex -< -T -> -{ -Mutex -{ -locked -: -AtomicBool -: -: -new -( -false -) -data -: -UnsafeCell -: -: -new -( -value -) -} -} -/ -/ -/ -Lock -this -mutex -and -return -a -guard -providing -exclusive -access -to -/ -/ -/ -T -. -This -blocks -if -some -other -thread -has -already -locked -this -/ -/ -/ -mutex -. -fn -lock -( -& -self -) -- -> -MutexGuard -< -' -_ -T -> -{ -while -self -. -locked -. -compare_exchange -( -false -true -Ordering -: -: -AcqRel -Ordering -: -: -Acquire -) -. -is_err -( -) -{ -core -: -: -hint -: -: -spin_loop -( -) -; -} -/ -/ -SAFETY -: -The -only -way -we -' -re -here -is -if -we -successfully -set -/ -/ -' -locked -' -to -true -which -implies -we -must -be -the -only -thread -here -/ -/ -and -thus -have -exclusive -access -to -' -data -' -. -let -data -= -unsafe -{ -& -mut -* -self -. -data -. -get -( -) -} -; -MutexGuard -{ -locked -: -& -self -. -locked -data -} -} -} -/ -/ -/ -A -guard -that -derefs -to -& -T -and -& -mut -T -. -When -it -' -s -dropped -the -lock -is -/ -/ -/ -released -. -# -[ -derive -( -Debug -) -] -struct -MutexGuard -< -' -a -T -> -{ -locked -: -& -' -a -AtomicBool -data -: -& -' -a -mut -T -} -impl -< -' -a -T -> -core -: -: -ops -: -: -Deref -for -MutexGuard -< -' -a -T -> -{ -type -Target -= -T -; -fn -deref -( -& -self -) -- -> -& -T -{ -self -. -data -} -} -impl -< -' -a -T -> -core -: -: -ops -: -: -DerefMut -for -MutexGuard -< -' -a -T -> -{ -fn -deref_mut -( -& -mut -self -) -- -> -& -mut -T -{ -self -. -data -} -} -impl -< -' -a -T -> -Drop -for -MutexGuard -< -' -a -T -> -{ -fn -drop -( -& -mut -self -) -{ -/ -/ -Drop -means -' -data -' -is -no -longer -accessible -so -we -can -unlock -/ -/ -the -mutex -. -self -. -locked -. -store -( -false -Ordering -: -: -Release -) -; -} -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -core -: -: -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -; -use -alloc -: -: -{ -boxed -: -: -Box -vec -vec -: -: -Vec -} -; -use -super -: -: -* -; -# -[ -test -] -fn -oibits -( -) -{ -fn -assert_oitbits -< -T -: -Send -+ -Sync -+ -UnwindSafe -+ -RefUnwindSafe -> -( -) -{ -} -assert_oitbits -: -: -< -Pool -< -Vec -< -u32 -> -> -> -( -) -; -assert_oitbits -: -: -< -Pool -< -core -: -: -cell -: -: -RefCell -< -Vec -< -u32 -> -> -> -> -( -) -; -assert_oitbits -: -: -< -Pool -< -Vec -< -u32 -> -Box -< -dyn -Fn -( -) -- -> -Vec -< -u32 -> -+ -Send -+ -Sync -+ -UnwindSafe -+ -RefUnwindSafe -> -> -> -( -) -; -} -/ -/ -Tests -that -Pool -implements -the -" -single -owner -" -optimization -. -That -is -the -/ -/ -thread -that -first -accesses -the -pool -gets -its -own -copy -while -all -other -/ -/ -threads -get -distinct -copies -. -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -test -] -fn -thread_owner_optimization -( -) -{ -use -std -: -: -{ -cell -: -: -RefCell -sync -: -: -Arc -vec -} -; -let -pool -: -Arc -< -Pool -< -RefCell -< -Vec -< -char -> -> -> -> -= -Arc -: -: -new -( -Pool -: -: -new -( -| -| -RefCell -: -: -new -( -vec -! -[ -' -a -' -] -) -) -) -; -pool -. -get -( -) -. -borrow_mut -( -) -. -push -( -' -x -' -) -; -let -pool1 -= -pool -. -clone -( -) -; -let -t1 -= -std -: -: -thread -: -: -spawn -( -move -| -| -{ -let -guard -= -pool1 -. -get -( -) -; -guard -. -borrow_mut -( -) -. -push -( -' -y -' -) -; -} -) -; -let -pool2 -= -pool -. -clone -( -) -; -let -t2 -= -std -: -: -thread -: -: -spawn -( -move -| -| -{ -let -guard -= -pool2 -. -get -( -) -; -guard -. -borrow_mut -( -) -. -push -( -' -z -' -) -; -} -) -; -t1 -. -join -( -) -. -unwrap -( -) -; -t2 -. -join -( -) -. -unwrap -( -) -; -/ -/ -If -we -didn -' -t -implement -the -single -owner -optimization -then -one -of -/ -/ -the -threads -above -is -likely -to -have -mutated -the -[ -a -x -] -vec -that -/ -/ -we -stuffed -in -the -pool -before -spawning -the -threads -. -But -since -/ -/ -neither -thread -was -first -to -access -the -pool -and -because -of -the -/ -/ -optimization -we -should -be -guaranteed -that -neither -thread -mutates -/ -/ -the -special -owned -pool -value -. -/ -/ -/ -/ -( -Technically -this -is -an -implementation -detail -and -not -a -contract -of -/ -/ -Pool -' -s -API -. -) -assert_eq -! -( -vec -! -[ -' -a -' -' -x -' -] -* -pool -. -get -( -) -. -borrow -( -) -) -; -} -/ -/ -This -tests -that -if -the -" -owner -" -of -a -pool -asks -for -two -values -then -it -/ -/ -gets -two -distinct -values -and -not -the -same -one -. -This -test -failed -in -the -/ -/ -course -of -developing -the -pool -which -in -turn -resulted -in -UB -because -it -/ -/ -permitted -getting -aliasing -& -mut -borrows -to -the -same -place -in -memory -. -# -[ -test -] -fn -thread_owner_distinct -( -) -{ -let -pool -= -Pool -: -: -new -( -| -| -vec -! -[ -' -a -' -] -) -; -{ -let -mut -g1 -= -pool -. -get -( -) -; -let -v1 -= -& -mut -* -g1 -; -let -mut -g2 -= -pool -. -get -( -) -; -let -v2 -= -& -mut -* -g2 -; -v1 -. -push -( -' -b -' -) -; -v2 -. -push -( -' -c -' -) -; -assert_eq -! -( -& -mut -vec -! -[ -' -a -' -' -b -' -] -v1 -) -; -assert_eq -! -( -& -mut -vec -! -[ -' -a -' -' -c -' -] -v2 -) -; -} -/ -/ -This -isn -' -t -technically -guaranteed -but -we -/ -/ -expect -to -now -get -the -" -owned -" -value -( -the -first -/ -/ -call -to -' -get -( -) -' -above -) -now -that -it -' -s -back -in -/ -/ -the -pool -. -assert_eq -! -( -& -mut -vec -! -[ -' -a -' -' -b -' -] -& -mut -* -pool -. -get -( -) -) -; -} -/ -/ -This -tests -that -we -can -share -a -guard -with -another -thread -mutate -the -/ -/ -underlying -value -and -everything -works -. -This -failed -in -the -course -of -/ -/ -developing -a -pool -since -the -pool -permitted -' -get -( -) -' -to -return -the -same -/ -/ -value -to -the -owner -thread -even -before -the -previous -value -was -put -back -/ -/ -into -the -pool -. -This -in -turn -resulted -in -this -test -producing -a -data -race -. -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -test -] -fn -thread_owner_sync -( -) -{ -let -pool -= -Pool -: -: -new -( -| -| -vec -! -[ -' -a -' -] -) -; -{ -let -mut -g1 -= -pool -. -get -( -) -; -let -mut -g2 -= -pool -. -get -( -) -; -std -: -: -thread -: -: -scope -( -| -s -| -{ -s -. -spawn -( -| -| -{ -g1 -. -push -( -' -b -' -) -; -} -) -; -s -. -spawn -( -| -| -{ -g2 -. -push -( -' -c -' -) -; -} -) -; -} -) -; -let -v1 -= -& -mut -* -g1 -; -let -v2 -= -& -mut -* -g2 -; -assert_eq -! -( -& -mut -vec -! -[ -' -a -' -' -b -' -] -v1 -) -; -assert_eq -! -( -& -mut -vec -! -[ -' -a -' -' -c -' -] -v2 -) -; -} -/ -/ -This -isn -' -t -technically -guaranteed -but -we -/ -/ -expect -to -now -get -the -" -owned -" -value -( -the -first -/ -/ -call -to -' -get -( -) -' -above -) -now -that -it -' -s -back -in -/ -/ -the -pool -. -assert_eq -! -( -& -mut -vec -! -[ -' -a -' -' -b -' -] -& -mut -* -pool -. -get -( -) -) -; -} -/ -/ -This -tests -that -if -we -move -a -PoolGuard -that -is -owned -by -the -current -/ -/ -thread -to -another -thread -and -drop -it -then -the -thread -owner -doesn -' -t -/ -/ -change -. -During -development -of -the -pool -this -test -failed -because -the -/ -/ -PoolGuard -assumed -it -was -dropped -in -the -same -thread -from -which -it -was -/ -/ -created -and -thus -used -the -current -thread -' -s -ID -as -the -owner -which -could -/ -/ -be -different -than -the -actual -owner -of -the -pool -. -# -[ -cfg -( -feature -= -" -std -" -) -] -# -[ -test -] -fn -thread_owner_send_drop -( -) -{ -let -pool -= -Pool -: -: -new -( -| -| -vec -! -[ -' -a -' -] -) -; -/ -/ -Establishes -this -thread -as -the -owner -. -{ -pool -. -get -( -) -. -push -( -' -b -' -) -; -} -std -: -: -thread -: -: -scope -( -| -s -| -{ -/ -/ -Sanity -check -that -we -get -the -same -value -back -. -/ -/ -( -Not -technically -guaranteed -. -) -let -mut -g -= -pool -. -get -( -) -; -assert_eq -! -( -& -vec -! -[ -' -a -' -' -b -' -] -& -* -g -) -; -/ -/ -Now -push -it -to -another -thread -and -drop -it -. -s -. -spawn -( -move -| -| -{ -g -. -push -( -' -c -' -) -; -} -) -. -join -( -) -. -unwrap -( -) -; -} -) -; -/ -/ -Now -check -that -we -' -re -still -the -owner -. -This -is -not -technically -/ -/ -guaranteed -by -the -API -but -is -true -in -practice -given -the -thread -/ -/ -owner -optimization -. -assert_eq -! -( -& -vec -! -[ -' -a -' -' -b -' -' -c -' -] -& -* -pool -. -get -( -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/util/prefilter/aho_corasick.rs b/third_party/rust/regex-automata/src/util/prefilter/aho_corasick.rs deleted file mode 100644 index b508f9734a1a5..0000000000000 --- a/third_party/rust/regex-automata/src/util/prefilter/aho_corasick.rs +++ /dev/null @@ -1,1269 +0,0 @@ -use -crate -: -: -util -: -: -{ -prefilter -: -: -PrefilterI -search -: -: -{ -MatchKind -Span -} -} -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -AhoCorasick -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -_unused -: -( -) -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -ac -: -aho_corasick -: -: -AhoCorasick -} -impl -AhoCorasick -{ -pub -( -crate -) -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -AhoCorasick -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -None -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -/ -/ -We -used -to -use -aho_corasick -: -: -MatchKind -: -: -Standard -here -when -/ -/ -kind -was -MatchKind -: -: -All -but -this -is -not -correct -. -The -/ -/ -" -standard -" -Aho -- -Corasick -match -semantics -are -to -report -a -match -/ -/ -immediately -as -soon -as -it -is -seen -but -All -isn -' -t -like -that -. -/ -/ -In -particular -with -" -standard -" -semantics -given -the -needles -/ -/ -" -abc -" -and -" -b -" -and -the -haystack -" -abc -" -it -would -report -a -match -/ -/ -at -offset -1 -before -a -match -at -offset -0 -. -This -is -never -what -we -/ -/ -want -in -the -context -of -the -regex -engine -regardless -of -whether -/ -/ -we -have -leftmost -- -first -or -' -all -' -semantics -. -Namely -we -always -/ -/ -want -the -leftmost -match -. -let -ac_match_kind -= -match -kind -{ -MatchKind -: -: -LeftmostFirst -| -MatchKind -: -: -All -= -> -{ -aho_corasick -: -: -MatchKind -: -: -LeftmostFirst -} -} -; -/ -/ -This -is -kind -of -just -an -arbitrary -number -but -basically -if -we -/ -/ -have -a -small -enough -set -of -literals -then -we -try -to -use -the -VERY -/ -/ -memory -hungry -DFA -. -Otherwise -we -whimp -out -and -use -an -NFA -. -The -/ -/ -upshot -is -that -the -NFA -is -quite -lean -and -decently -fast -. -Faster -/ -/ -than -a -naive -Aho -- -Corasick -NFA -anyway -. -let -ac_kind -= -if -needles -. -len -( -) -< -= -500 -{ -aho_corasick -: -: -AhoCorasickKind -: -: -DFA -} -else -{ -aho_corasick -: -: -AhoCorasickKind -: -: -ContiguousNFA -} -; -let -result -= -aho_corasick -: -: -AhoCorasick -: -: -builder -( -) -. -kind -( -Some -( -ac_kind -) -) -. -match_kind -( -ac_match_kind -) -. -start_kind -( -aho_corasick -: -: -StartKind -: -: -Both -) -/ -/ -We -try -to -handle -all -of -the -prefilter -cases -in -the -super -/ -/ -module -and -only -use -Aho -- -Corasick -for -the -actual -automaton -. -/ -/ -The -aho -- -corasick -crate -does -have -some -extra -prefilters -/ -/ -namely -looking -for -rare -bytes -to -feed -to -memchr -{ -2 -3 -} -/ -/ -instead -of -just -the -first -byte -. -If -we -end -up -wanting -/ -/ -those -- -- -- -and -they -are -somewhat -tricky -to -implement -- -- -- -then -/ -/ -we -could -port -them -to -this -crate -. -/ -/ -/ -/ -The -main -reason -for -doing -things -this -way -is -so -we -have -a -/ -/ -complete -and -easy -to -understand -picture -of -which -prefilters -/ -/ -are -available -and -how -they -work -. -Otherwise -it -seems -too -/ -/ -easy -to -get -into -a -situation -where -we -have -a -prefilter -/ -/ -layered -on -top -of -prefilter -and -that -might -have -unintended -/ -/ -consequences -. -. -prefilter -( -false -) -. -build -( -needles -) -; -let -ac -= -match -result -{ -Ok -( -ac -) -= -> -ac -Err -( -_err -) -= -> -{ -debug -! -( -" -aho -- -corasick -prefilter -failed -to -build -: -{ -} -" -_err -) -; -return -None -; -} -} -; -Some -( -AhoCorasick -{ -ac -} -) -} -} -} -impl -PrefilterI -for -AhoCorasick -{ -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -let -input -= -aho_corasick -: -: -Input -: -: -new -( -haystack -) -. -span -( -span -. -start -. -. -span -. -end -) -; -self -. -ac -. -find -( -input -) -. -map -( -| -m -| -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -) -} -} -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -let -input -= -aho_corasick -: -: -Input -: -: -new -( -haystack -) -. -anchored -( -aho_corasick -: -: -Anchored -: -: -Yes -) -. -span -( -span -. -start -. -. -span -. -end -) -; -self -. -ac -. -find -( -input -) -. -map -( -| -m -| -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -) -} -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -self -. -ac -. -memory_usage -( -) -} -} -fn -is_fast -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -/ -/ -Aho -- -Corasick -is -never -considered -" -fast -" -because -it -' -s -never -/ -/ -going -to -be -even -close -to -an -order -of -magnitude -faster -than -the -/ -/ -regex -engine -itself -( -assuming -a -DFA -is -used -) -. -In -fact -it -is -/ -/ -usually -slower -. -The -magic -of -Aho -- -Corasick -is -that -it -can -search -/ -/ -a -* -large -* -number -of -literals -with -a -relatively -small -amount -of -/ -/ -memory -. -The -regex -engines -are -far -more -wasteful -. -/ -/ -/ -/ -Aho -- -Corasick -may -be -" -fast -" -when -the -regex -engine -corresponds -/ -/ -to -say -the -PikeVM -. -That -happens -when -the -lazy -DFA -couldn -' -t -be -/ -/ -built -or -used -for -some -reason -. -But -in -these -cases -the -regex -/ -/ -itself -is -likely -quite -big -and -we -' -re -probably -hosed -no -matter -/ -/ -what -we -do -. -( -In -this -case -the -best -bet -is -for -the -caller -to -/ -/ -increase -some -of -the -memory -limits -on -the -hybrid -cache -capacity -/ -/ -and -hope -that -' -s -enough -. -) -false -} -} -} diff --git a/third_party/rust/regex-automata/src/util/prefilter/byteset.rs b/third_party/rust/regex-automata/src/util/prefilter/byteset.rs deleted file mode 100644 index 6c8587f465431..0000000000000 --- a/third_party/rust/regex-automata/src/util/prefilter/byteset.rs +++ /dev/null @@ -1,371 +0,0 @@ -use -crate -: -: -util -: -: -{ -prefilter -: -: -PrefilterI -search -: -: -{ -MatchKind -Span -} -} -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -ByteSet -( -[ -bool -; -256 -] -) -; -impl -ByteSet -{ -pub -( -crate -) -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -_kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -ByteSet -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -None -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -let -mut -set -= -[ -false -; -256 -] -; -for -needle -in -needles -. -iter -( -) -{ -let -needle -= -needle -. -as_ref -( -) -; -if -needle -. -len -( -) -! -= -1 -{ -return -None -; -} -set -[ -usize -: -: -from -( -needle -[ -0 -] -) -] -= -true -; -} -Some -( -ByteSet -( -set -) -) -} -} -} -impl -PrefilterI -for -ByteSet -{ -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -haystack -[ -span -] -. -iter -( -) -. -position -( -| -& -b -| -self -. -0 -[ -usize -: -: -from -( -b -) -] -) -. -map -( -| -i -| -{ -let -start -= -span -. -start -+ -i -; -let -end -= -start -+ -1 -; -Span -{ -start -end -} -} -) -} -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -let -b -= -* -haystack -. -get -( -span -. -start -) -? -; -if -self -. -0 -[ -usize -: -: -from -( -b -) -] -{ -Some -( -Span -{ -start -: -span -. -start -end -: -span -. -start -+ -1 -} -) -} -else -{ -None -} -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -0 -} -fn -is_fast -( -& -self -) -- -> -bool -{ -false -} -} diff --git a/third_party/rust/regex-automata/src/util/prefilter/memchr.rs b/third_party/rust/regex-automata/src/util/prefilter/memchr.rs deleted file mode 100644 index 207062548a5db..0000000000000 --- a/third_party/rust/regex-automata/src/util/prefilter/memchr.rs +++ /dev/null @@ -1,1194 +0,0 @@ -use -crate -: -: -util -: -: -{ -prefilter -: -: -PrefilterI -search -: -: -{ -MatchKind -Span -} -} -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Memchr -( -u8 -) -; -impl -Memchr -{ -pub -( -crate -) -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -_kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -Memchr -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -None -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -substring -" -) -] -{ -if -needles -. -len -( -) -! -= -1 -{ -return -None -; -} -if -needles -[ -0 -] -. -as_ref -( -) -. -len -( -) -! -= -1 -{ -return -None -; -} -Some -( -Memchr -( -needles -[ -0 -] -. -as_ref -( -) -[ -0 -] -) -) -} -} -} -impl -PrefilterI -for -Memchr -{ -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -substring -" -) -] -{ -memchr -: -: -memchr -( -self -. -0 -& -haystack -[ -span -] -) -. -map -( -| -i -| -{ -let -start -= -span -. -start -+ -i -; -let -end -= -start -+ -1 -; -Span -{ -start -end -} -} -) -} -} -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -let -b -= -* -haystack -. -get -( -span -. -start -) -? -; -if -self -. -0 -= -= -b -{ -Some -( -Span -{ -start -: -span -. -start -end -: -span -. -start -+ -1 -} -) -} -else -{ -None -} -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -0 -} -fn -is_fast -( -& -self -) -- -> -bool -{ -true -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Memchr2 -( -u8 -u8 -) -; -impl -Memchr2 -{ -pub -( -crate -) -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -_kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -Memchr2 -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -None -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -substring -" -) -] -{ -if -needles -. -len -( -) -! -= -2 -{ -return -None -; -} -if -! -needles -. -iter -( -) -. -all -( -| -n -| -n -. -as_ref -( -) -. -len -( -) -= -= -1 -) -{ -return -None -; -} -let -b1 -= -needles -[ -0 -] -. -as_ref -( -) -[ -0 -] -; -let -b2 -= -needles -[ -1 -] -. -as_ref -( -) -[ -0 -] -; -Some -( -Memchr2 -( -b1 -b2 -) -) -} -} -} -impl -PrefilterI -for -Memchr2 -{ -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -substring -" -) -] -{ -memchr -: -: -memchr2 -( -self -. -0 -self -. -1 -& -haystack -[ -span -] -) -. -map -( -| -i -| -{ -let -start -= -span -. -start -+ -i -; -let -end -= -start -+ -1 -; -Span -{ -start -end -} -} -) -} -} -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -let -b -= -* -haystack -. -get -( -span -. -start -) -? -; -if -self -. -0 -= -= -b -| -| -self -. -1 -= -= -b -{ -Some -( -Span -{ -start -: -span -. -start -end -: -span -. -start -+ -1 -} -) -} -else -{ -None -} -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -0 -} -fn -is_fast -( -& -self -) -- -> -bool -{ -true -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Memchr3 -( -u8 -u8 -u8 -) -; -impl -Memchr3 -{ -pub -( -crate -) -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -_kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -Memchr3 -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -None -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -substring -" -) -] -{ -if -needles -. -len -( -) -! -= -3 -{ -return -None -; -} -if -! -needles -. -iter -( -) -. -all -( -| -n -| -n -. -as_ref -( -) -. -len -( -) -= -= -1 -) -{ -return -None -; -} -let -b1 -= -needles -[ -0 -] -. -as_ref -( -) -[ -0 -] -; -let -b2 -= -needles -[ -1 -] -. -as_ref -( -) -[ -0 -] -; -let -b3 -= -needles -[ -2 -] -. -as_ref -( -) -[ -0 -] -; -Some -( -Memchr3 -( -b1 -b2 -b3 -) -) -} -} -} -impl -PrefilterI -for -Memchr3 -{ -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -substring -" -) -] -{ -memchr -: -: -memchr3 -( -self -. -0 -self -. -1 -self -. -2 -& -haystack -[ -span -] -) -. -map -( -| -i -| -{ -let -start -= -span -. -start -+ -i -; -let -end -= -start -+ -1 -; -Span -{ -start -end -} -} -) -} -} -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -let -b -= -* -haystack -. -get -( -span -. -start -) -? -; -if -self -. -0 -= -= -b -| -| -self -. -1 -= -= -b -| -| -self -. -2 -= -= -b -{ -Some -( -Span -{ -start -: -span -. -start -end -: -span -. -start -+ -1 -} -) -} -else -{ -None -} -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -0 -} -fn -is_fast -( -& -self -) -- -> -bool -{ -true -} -} diff --git a/third_party/rust/regex-automata/src/util/prefilter/memmem.rs b/third_party/rust/regex-automata/src/util/prefilter/memmem.rs deleted file mode 100644 index 4d2c2d44322bc..0000000000000 --- a/third_party/rust/regex-automata/src/util/prefilter/memmem.rs +++ /dev/null @@ -1,663 +0,0 @@ -use -crate -: -: -util -: -: -{ -prefilter -: -: -PrefilterI -search -: -: -{ -MatchKind -Span -} -} -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Memmem -{ -# -[ -cfg -( -not -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -) -] -_unused -: -( -) -# -[ -cfg -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -] -finder -: -memchr -: -: -memmem -: -: -Finder -< -' -static -> -} -impl -Memmem -{ -pub -( -crate -) -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -_kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -Memmem -> -{ -# -[ -cfg -( -not -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -) -] -{ -None -} -# -[ -cfg -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -if -needles -. -len -( -) -! -= -1 -{ -return -None -; -} -let -needle -= -needles -[ -0 -] -. -as_ref -( -) -; -let -finder -= -memchr -: -: -memmem -: -: -Finder -: -: -new -( -needle -) -. -into_owned -( -) -; -Some -( -Memmem -{ -finder -} -) -} -} -} -impl -PrefilterI -for -Memmem -{ -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -self -. -finder -. -find -( -& -haystack -[ -span -] -) -. -map -( -| -i -| -{ -let -start -= -span -. -start -+ -i -; -let -end -= -start -+ -self -. -finder -. -needle -( -) -. -len -( -) -; -Span -{ -start -end -} -} -) -} -} -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -let -needle -= -self -. -finder -. -needle -( -) -; -if -haystack -[ -span -] -. -starts_with -( -needle -) -{ -Some -( -Span -{ -end -: -span -. -start -+ -needle -. -len -( -) -. -. -span -} -) -} -else -{ -None -} -} -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -not -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -self -. -finder -. -needle -( -) -. -len -( -) -} -} -fn -is_fast -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -not -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -all -( -feature -= -" -std -" -feature -= -" -perf -- -literal -- -substring -" -) -) -] -{ -true -} -} -} diff --git a/third_party/rust/regex-automata/src/util/prefilter/mod.rs b/third_party/rust/regex-automata/src/util/prefilter/mod.rs deleted file mode 100644 index a3b304822491b..0000000000000 --- a/third_party/rust/regex-automata/src/util/prefilter/mod.rs +++ /dev/null @@ -1,6623 +0,0 @@ -/ -* -! -Defines -a -prefilter -for -accelerating -regex -searches -. -A -prefilter -can -be -created -by -building -a -[ -Prefilter -] -value -. -A -prefilter -represents -one -of -the -most -important -optimizations -available -for -accelerating -regex -searches -. -The -idea -of -a -prefilter -is -to -very -quickly -find -candidate -locations -in -a -haystack -where -a -regex -_could_ -match -. -Once -a -candidate -is -found -it -is -then -intended -for -the -regex -engine -to -run -at -that -position -to -determine -whether -the -candidate -is -a -match -or -a -false -positive -. -In -the -aforementioned -description -of -the -prefilter -optimization -also -lay -its -demise -. -Namely -if -a -prefilter -has -a -high -false -positive -rate -and -it -produces -lots -of -candidates -then -a -prefilter -can -overall -make -a -regex -search -slower -. -It -can -run -more -slowly -because -more -time -is -spent -ping -- -ponging -between -the -prefilter -search -and -the -regex -engine -attempting -to -confirm -each -candidate -as -a -match -. -This -ping -- -ponging -has -overhead -that -adds -up -and -is -exacerbated -by -a -high -false -positive -rate -. -Nevertheless -the -optimization -is -still -generally -worth -performing -in -most -cases -. -Particularly -given -just -how -much -throughput -can -be -improved -. -( -It -is -not -uncommon -for -prefilter -optimizations -to -improve -throughput -by -one -or -two -orders -of -magnitude -. -) -Typically -a -prefilter -is -used -to -find -occurrences -of -literal -prefixes -from -a -regex -pattern -but -this -isn -' -t -required -. -A -prefilter -can -be -used -to -look -for -suffixes -or -even -inner -literals -. -Note -that -as -of -now -prefilters -throw -away -information -about -which -pattern -each -literal -comes -from -. -In -other -words -when -a -prefilter -finds -a -match -there -' -s -no -way -to -know -which -pattern -( -or -patterns -) -it -came -from -. -Therefore -in -order -to -confirm -a -match -you -' -ll -have -to -check -all -of -the -patterns -by -running -the -full -regex -engine -. -* -/ -mod -aho_corasick -; -mod -byteset -; -mod -memchr -; -mod -memmem -; -mod -teddy -; -use -core -: -: -{ -borrow -: -: -Borrow -fmt -: -: -Debug -panic -: -: -{ -RefUnwindSafe -UnwindSafe -} -} -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -use -alloc -: -: -sync -: -: -Arc -; -# -[ -cfg -( -feature -= -" -syntax -" -) -] -use -regex_syntax -: -: -hir -: -: -{ -literal -Hir -} -; -use -crate -: -: -util -: -: -search -: -: -{ -MatchKind -Span -} -; -pub -( -crate -) -use -crate -: -: -util -: -: -prefilter -: -: -{ -aho_corasick -: -: -AhoCorasick -byteset -: -: -ByteSet -memchr -: -: -{ -Memchr -Memchr2 -Memchr3 -} -memmem -: -: -Memmem -teddy -: -: -Teddy -} -; -/ -/ -/ -A -prefilter -for -accelerating -regex -searches -. -/ -/ -/ -/ -/ -/ -If -you -already -have -your -literals -that -you -want -to -search -with -/ -/ -/ -then -the -vanilla -[ -Prefilter -: -: -new -] -constructor -is -for -you -. -But -/ -/ -/ -if -you -have -an -[ -Hir -] -value -from -the -regex -- -syntax -crate -then -/ -/ -/ -[ -Prefilter -: -: -from_hir_prefix -] -might -be -more -convenient -. -Namely -it -uses -/ -/ -/ -the -[ -regex -- -syntax -: -: -hir -: -: -literal -] -( -regex_syntax -: -: -hir -: -: -literal -) -module -to -/ -/ -/ -extract -literal -prefixes -for -you -optimize -them -and -then -select -and -build -a -/ -/ -/ -prefilter -matcher -. -/ -/ -/ -/ -/ -/ -A -prefilter -must -have -* -* -zero -false -negatives -* -* -. -However -by -its -very -/ -/ -/ -nature -it -may -produce -false -positives -. -That -is -a -prefilter -will -never -/ -/ -/ -skip -over -a -position -in -the -haystack -that -corresponds -to -a -match -of -the -/ -/ -/ -original -regex -pattern -but -it -* -may -* -produce -a -match -for -a -position -/ -/ -/ -in -the -haystack -that -does -* -not -* -correspond -to -a -match -of -the -original -/ -/ -/ -regex -pattern -. -If -you -use -either -the -[ -Prefilter -: -: -from_hir_prefix -] -or -/ -/ -/ -[ -Prefilter -: -: -from_hirs_prefix -] -constructors -then -this -guarantee -is -/ -/ -/ -upheld -for -you -automatically -. -This -guarantee -is -not -preserved -if -you -use -/ -/ -/ -[ -Prefilter -: -: -new -] -though -since -it -is -up -to -the -caller -to -provide -correct -/ -/ -/ -literal -strings -with -respect -to -the -original -regex -pattern -. -/ -/ -/ -/ -/ -/ -# -Cloning -/ -/ -/ -/ -/ -/ -It -is -an -API -guarantee -that -cloning -a -prefilter -is -cheap -. -That -is -cloning -/ -/ -/ -it -will -not -duplicate -whatever -heap -memory -is -used -to -represent -the -/ -/ -/ -underlying -matcher -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -attach -a -Prefilter -to -the -/ -/ -/ -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -in -order -to -accelerate -/ -/ -/ -searches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Match -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -Bruce -" -] -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -configure -( -PikeVM -: -: -config -( -) -. -prefilter -( -Some -( -pre -) -) -) -/ -/ -/ -. -build -( -r -" -Bruce -\ -w -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Match -: -: -must -( -0 -6 -. -. -23 -) -) -/ -/ -/ -re -. -find -( -& -mut -cache -" -Hello -Bruce -Springsteen -! -" -) -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -But -note -that -if -you -get -your -prefilter -incorrect -it -could -lead -to -an -/ -/ -/ -incorrect -result -! -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -util -: -: -prefilter -: -: -Prefilter -/ -/ -/ -Match -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -This -prefilter -is -wrong -! -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -Patti -" -] -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -configure -( -PikeVM -: -: -config -( -) -. -prefilter -( -Some -( -pre -) -) -) -/ -/ -/ -. -build -( -r -" -Bruce -\ -w -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -/ -/ -We -find -no -match -even -though -the -regex -does -match -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -None -/ -/ -/ -re -. -find -( -& -mut -cache -" -Hello -Bruce -Springsteen -! -" -) -/ -/ -/ -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Prefilter -{ -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -_unused -: -( -) -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pre -: -Arc -< -dyn -PrefilterI -> -# -[ -cfg -( -feature -= -" -alloc -" -) -] -is_fast -: -bool -} -impl -Prefilter -{ -/ -/ -/ -Create -a -new -prefilter -from -a -sequence -of -needles -and -a -corresponding -/ -/ -/ -match -semantics -. -/ -/ -/ -/ -/ -/ -This -may -return -None -for -a -variety -of -reasons -for -example -if -/ -/ -/ -a -suitable -prefilter -could -not -be -constructed -. -That -might -occur -/ -/ -/ -if -they -are -unavailable -( -e -. -g -. -the -perf -- -literal -- -substring -and -/ -/ -/ -perf -- -literal -- -multisubstring -features -aren -' -t -enabled -) -or -it -might -/ -/ -/ -occur -because -of -heuristics -or -other -artifacts -of -how -the -prefilter -/ -/ -/ -works -. -/ -/ -/ -/ -/ -/ -Note -that -if -you -have -an -[ -Hir -] -expression -it -may -be -more -convenient -/ -/ -/ -to -use -[ -Prefilter -: -: -from_hir_prefix -] -. -It -will -automatically -handle -the -/ -/ -/ -task -of -extracting -prefix -literals -for -you -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -match -semantics -can -impact -the -matching -/ -/ -/ -algorithm -used -by -the -prefilter -. -For -this -reason -it -is -important -to -/ -/ -/ -ensure -that -the -match -semantics -given -here -are -consistent -with -the -/ -/ -/ -match -semantics -intended -for -the -regular -expression -that -the -literals -/ -/ -/ -were -extracted -from -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -/ -/ -/ -MatchKind -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -hay -= -" -Hello -samwise -" -; -/ -/ -/ -/ -/ -/ -/ -/ -With -leftmost -- -first -we -find -' -samwise -' -here -because -it -comes -/ -/ -/ -/ -/ -before -' -sam -' -in -the -sequence -we -give -it -. -. -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -samwise -" -" -sam -" -] -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Span -: -: -from -( -6 -. -. -13 -) -) -/ -/ -/ -pre -. -find -( -hay -. -as_bytes -( -) -Span -: -: -from -( -0 -. -. -hay -. -len -( -) -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -Still -with -leftmost -- -first -but -with -the -literals -reverse -now -' -sam -' -/ -/ -/ -/ -/ -will -match -instead -! -/ -/ -/ -let -pre -= -Prefilter -: -: -new -( -MatchKind -: -: -LeftmostFirst -& -[ -" -sam -" -" -samwise -" -] -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Span -: -: -from -( -6 -. -. -9 -) -) -/ -/ -/ -pre -. -find -( -hay -. -as_bytes -( -) -Span -: -: -from -( -0 -. -. -hay -. -len -( -) -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -Prefilter -> -{ -Choice -: -: -new -( -kind -needles -) -. -and_then -( -Prefilter -: -: -from_choice -) -} -/ -/ -/ -This -turns -a -prefilter -selection -into -a -Prefilter -. -That -is -in -turns -/ -/ -/ -the -enum -given -into -a -trait -object -. -fn -from_choice -( -choice -: -Choice -) -- -> -Option -< -Prefilter -> -{ -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -{ -None -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -{ -let -pre -: -Arc -< -dyn -PrefilterI -> -= -match -choice -{ -Choice -: -: -Memchr -( -p -) -= -> -Arc -: -: -new -( -p -) -Choice -: -: -Memchr2 -( -p -) -= -> -Arc -: -: -new -( -p -) -Choice -: -: -Memchr3 -( -p -) -= -> -Arc -: -: -new -( -p -) -Choice -: -: -Memmem -( -p -) -= -> -Arc -: -: -new -( -p -) -Choice -: -: -Teddy -( -p -) -= -> -Arc -: -: -new -( -p -) -Choice -: -: -ByteSet -( -p -) -= -> -Arc -: -: -new -( -p -) -Choice -: -: -AhoCorasick -( -p -) -= -> -Arc -: -: -new -( -p -) -} -; -let -is_fast -= -pre -. -is_fast -( -) -; -Some -( -Prefilter -{ -pre -is_fast -} -) -} -} -/ -/ -/ -This -attempts -to -extract -prefixes -from -the -given -Hir -expression -for -/ -/ -/ -the -given -match -semantics -and -if -possible -builds -a -prefilter -for -/ -/ -/ -them -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -prefilter -directly -from -an -[ -Hir -] -/ -/ -/ -expression -and -use -to -find -an -occurrence -of -a -prefix -from -the -regex -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -/ -/ -/ -MatchKind -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -syntax -: -: -parse -( -r -" -( -Bruce -| -Patti -) -\ -w -+ -" -) -? -; -/ -/ -/ -let -pre -= -Prefilter -: -: -from_hir_prefix -( -MatchKind -: -: -LeftmostFirst -& -hir -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -let -hay -= -" -Hello -Patti -Scialfa -! -" -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Span -: -: -from -( -6 -. -. -12 -) -) -/ -/ -/ -pre -. -find -( -hay -. -as_bytes -( -) -Span -: -: -from -( -0 -. -. -hay -. -len -( -) -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -from_hir_prefix -( -kind -: -MatchKind -hir -: -& -Hir -) -- -> -Option -< -Prefilter -> -{ -Prefilter -: -: -from_hirs_prefix -( -kind -& -[ -hir -] -) -} -/ -/ -/ -This -attempts -to -extract -prefixes -from -the -given -Hir -expressions -for -/ -/ -/ -the -given -match -semantics -and -if -possible -builds -a -prefilter -for -/ -/ -/ -them -. -/ -/ -/ -/ -/ -/ -Note -that -as -of -now -prefilters -throw -away -information -about -which -/ -/ -/ -pattern -each -literal -comes -from -. -In -other -words -when -a -prefilter -finds -/ -/ -/ -a -match -there -' -s -no -way -to -know -which -pattern -( -or -patterns -) -it -came -/ -/ -/ -from -. -Therefore -in -order -to -confirm -a -match -you -' -ll -have -to -check -all -/ -/ -/ -of -the -patterns -by -running -the -full -regex -engine -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -prefilter -directly -from -multiple -/ -/ -/ -Hir -expressions -expression -and -use -it -to -find -an -occurrence -of -a -/ -/ -/ -prefix -from -the -regex -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -/ -/ -/ -MatchKind -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -hirs -= -syntax -: -: -parse_many -( -& -[ -/ -/ -/ -r -" -( -Bruce -| -Patti -) -\ -w -+ -" -/ -/ -/ -r -" -Mrs -? -\ -. -Doubtfire -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -pre -= -Prefilter -: -: -from_hirs_prefix -( -MatchKind -: -: -LeftmostFirst -& -hirs -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -let -hay -= -" -Hello -Mrs -. -Doubtfire -" -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Span -: -: -from -( -6 -. -. -20 -) -) -/ -/ -/ -pre -. -find -( -hay -. -as_bytes -( -) -Span -: -: -from -( -0 -. -. -hay -. -len -( -) -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -fn -from_hirs_prefix -< -H -: -Borrow -< -Hir -> -> -( -kind -: -MatchKind -hirs -: -& -[ -H -] -) -- -> -Option -< -Prefilter -> -{ -prefixes -( -kind -hirs -) -. -literals -( -) -. -and_then -( -| -lits -| -Prefilter -: -: -new -( -kind -lits -) -) -} -/ -/ -/ -Run -this -prefilter -on -haystack -[ -span -. -start -. -. -end -] -and -return -a -matching -/ -/ -/ -span -if -one -exists -. -/ -/ -/ -/ -/ -/ -The -span -returned -is -guaranteed -to -have -a -start -position -greater -than -/ -/ -/ -or -equal -to -the -one -given -and -an -end -position -less -than -or -equal -to -/ -/ -/ -the -one -given -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -prefilter -directly -from -an -[ -Hir -] -/ -/ -/ -expression -and -use -it -to -find -an -occurrence -of -a -prefix -from -the -regex -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -/ -/ -/ -MatchKind -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -syntax -: -: -parse -( -r -" -Bruce -\ -w -+ -" -) -? -; -/ -/ -/ -let -pre -= -Prefilter -: -: -from_hir_prefix -( -MatchKind -: -: -LeftmostFirst -& -hir -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -let -hay -= -" -Hello -Bruce -Springsteen -! -" -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Span -: -: -from -( -6 -. -. -12 -) -) -/ -/ -/ -pre -. -find -( -hay -. -as_bytes -( -) -Span -: -: -from -( -0 -. -. -hay -. -len -( -) -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -{ -self -. -pre -. -find -( -haystack -span -) -} -} -/ -/ -/ -Returns -the -span -of -a -prefix -of -haystack -[ -span -. -start -. -. -span -. -end -] -if -/ -/ -/ -the -prefilter -matches -. -/ -/ -/ -/ -/ -/ -The -span -returned -is -guaranteed -to -have -a -start -position -equivalent -to -/ -/ -/ -the -one -given -and -an -end -position -less -than -or -equal -to -the -one -given -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -build -a -prefilter -directly -from -an -[ -Hir -] -/ -/ -/ -expression -and -use -it -to -find -an -occurrence -of -a -prefix -from -the -regex -/ -/ -/ -pattern -that -begins -at -the -start -of -a -haystack -only -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -/ -/ -/ -MatchKind -Span -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -syntax -: -: -parse -( -r -" -Bruce -\ -w -+ -" -) -? -; -/ -/ -/ -let -pre -= -Prefilter -: -: -from_hir_prefix -( -MatchKind -: -: -LeftmostFirst -& -hir -) -/ -/ -/ -. -expect -( -" -a -prefilter -" -) -; -/ -/ -/ -let -hay -= -" -Hello -Bruce -Springsteen -! -" -; -/ -/ -/ -/ -/ -Nothing -is -found -here -because -' -Bruce -' -does -/ -/ -/ -/ -/ -not -occur -at -the -beginning -of -our -search -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -None -/ -/ -/ -pre -. -prefix -( -hay -. -as_bytes -( -) -Span -: -: -from -( -0 -. -. -hay -. -len -( -) -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -But -if -we -change -where -we -start -the -search -/ -/ -/ -/ -/ -to -begin -where -' -Bruce -' -begins -then -a -/ -/ -/ -/ -/ -match -will -be -found -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -Span -: -: -from -( -6 -. -. -12 -) -) -/ -/ -/ -pre -. -prefix -( -hay -. -as_bytes -( -) -Span -: -: -from -( -6 -. -. -hay -. -len -( -) -) -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -{ -self -. -pre -. -prefix -( -haystack -span -) -} -} -/ -/ -/ -Returns -the -heap -memory -in -bytes -used -by -the -underlying -prefilter -. -# -[ -inline -] -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -{ -self -. -pre -. -memory_usage -( -) -} -} -/ -/ -/ -Implementations -might -return -true -here -if -they -believe -themselves -to -/ -/ -/ -be -" -fast -. -" -The -concept -of -" -fast -" -is -deliberately -left -vague -but -in -/ -/ -/ -practice -this -usually -corresponds -to -whether -it -' -s -believed -that -SIMD -/ -/ -/ -will -be -used -. -/ -/ -/ -/ -/ -/ -Why -do -we -care -about -this -? -Well -some -prefilter -tricks -tend -to -come -/ -/ -/ -with -their -own -bits -of -overhead -and -so -might -only -make -sense -if -we -/ -/ -/ -know -that -a -scan -will -be -* -much -* -faster -than -the -regex -engine -itself -. -/ -/ -/ -Otherwise -the -trick -may -not -be -worth -doing -. -Whether -something -is -/ -/ -/ -" -much -" -faster -than -the -regex -engine -generally -boils -down -to -whether -/ -/ -/ -SIMD -is -used -. -( -But -not -always -. -Even -a -SIMD -matcher -with -a -high -false -/ -/ -/ -positive -rate -can -become -quite -slow -. -) -/ -/ -/ -/ -/ -/ -Even -if -this -returns -true -it -is -still -possible -for -the -prefilter -to -/ -/ -/ -be -" -slow -. -" -Remember -prefilters -are -just -heuristics -. -We -can -' -t -really -/ -/ -/ -* -know -* -a -prefilter -will -be -fast -without -actually -trying -the -prefilter -. -/ -/ -/ -( -Which -of -course -we -cannot -afford -to -do -. -) -# -[ -inline -] -pub -( -crate -) -fn -is_fast -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -{ -self -. -is_fast -} -} -} -/ -/ -/ -A -trait -for -abstracting -over -prefilters -. -Basically -a -prefilter -is -/ -/ -/ -something -that -do -an -unanchored -* -and -* -an -anchored -search -in -a -haystack -/ -/ -/ -within -a -given -span -. -/ -/ -/ -/ -/ -/ -This -exists -pretty -much -only -so -that -we -can -use -prefilters -as -a -trait -/ -/ -/ -object -( -which -is -what -Prefilter -is -) -. -If -we -ever -move -off -of -trait -objects -/ -/ -/ -and -to -an -enum -then -it -' -s -likely -this -trait -could -be -removed -. -pub -( -crate -) -trait -PrefilterI -: -Debug -+ -Send -+ -Sync -+ -RefUnwindSafe -+ -UnwindSafe -+ -' -static -{ -/ -/ -/ -Run -this -prefilter -on -haystack -[ -span -. -start -. -. -end -] -and -return -a -matching -/ -/ -/ -span -if -one -exists -. -/ -/ -/ -/ -/ -/ -The -span -returned -is -guaranteed -to -have -a -start -position -greater -than -/ -/ -/ -or -equal -to -the -one -given -and -an -end -position -less -than -or -equal -to -/ -/ -/ -the -one -given -. -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -; -/ -/ -/ -Returns -the -span -of -a -prefix -of -haystack -[ -span -. -start -. -. -span -. -end -] -if -/ -/ -/ -the -prefilter -matches -. -/ -/ -/ -/ -/ -/ -The -span -returned -is -guaranteed -to -have -a -start -position -equivalent -to -/ -/ -/ -the -one -given -and -an -end -position -less -than -or -equal -to -the -one -given -. -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -; -/ -/ -/ -Returns -the -heap -memory -in -bytes -used -by -the -underlying -prefilter -. -fn -memory_usage -( -& -self -) -- -> -usize -; -/ -/ -/ -Implementations -might -return -true -here -if -they -believe -themselves -to -/ -/ -/ -be -" -fast -. -" -See -[ -Prefilter -: -: -is_fast -] -for -more -details -. -fn -is_fast -( -& -self -) -- -> -bool -; -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -P -: -PrefilterI -+ -? -Sized -> -PrefilterI -for -Arc -< -P -> -{ -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -( -& -* -* -self -) -. -find -( -haystack -span -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -( -& -* -* -self -) -. -prefix -( -haystack -span -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -memory_usage -( -& -self -) -- -> -usize -{ -( -& -* -* -self -) -. -memory_usage -( -) -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_fast -( -& -self -) -- -> -bool -{ -( -& -* -* -self -) -. -is_fast -( -) -} -} -/ -/ -/ -A -type -that -encapsulates -the -selection -of -a -prefilter -algorithm -from -a -/ -/ -/ -sequence -of -needles -. -/ -/ -/ -/ -/ -/ -The -existence -of -this -type -is -a -little -tricky -because -we -don -' -t -( -currently -) -/ -/ -/ -use -it -for -performing -a -search -. -Instead -we -really -only -consume -it -by -/ -/ -/ -converting -the -underlying -prefilter -into -a -trait -object -whether -that -be -/ -/ -/ -dyn -PrefilterI -or -dyn -Strategy -( -for -the -meta -regex -engine -) -. -In -order -/ -/ -/ -to -avoid -re -- -copying -the -prefilter -selection -logic -we -isolate -it -here -and -/ -/ -/ -then -force -anything -downstream -that -wants -to -convert -it -to -a -trait -object -/ -/ -/ -to -do -trivial -case -analysis -on -it -. -/ -/ -/ -/ -/ -/ -One -wonders -whether -we -* -should -* -use -an -enum -instead -of -a -trait -object -. -/ -/ -/ -At -time -of -writing -I -chose -trait -objects -based -on -instinct -because -1 -) -I -/ -/ -/ -knew -I -wasn -' -t -going -to -inline -anything -and -2 -) -there -would -potentially -be -/ -/ -/ -many -different -choices -. -However -as -of -time -of -writing -I -haven -' -t -actually -/ -/ -/ -compared -the -trait -object -approach -to -the -enum -approach -. -That -probably -/ -/ -/ -should -be -litigated -but -I -ran -out -of -steam -. -/ -/ -/ -/ -/ -/ -Note -that -if -the -alloc -feature -is -disabled -then -values -of -this -type -/ -/ -/ -are -( -and -should -) -never -be -constructed -. -Also -in -practice -for -any -of -the -/ -/ -/ -prefilters -to -be -selected -you -' -ll -need -at -least -one -of -the -perf -- -literal -- -* -/ -/ -/ -features -enabled -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -enum -Choice -{ -Memchr -( -Memchr -) -Memchr2 -( -Memchr2 -) -Memchr3 -( -Memchr3 -) -Memmem -( -Memmem -) -Teddy -( -Teddy -) -ByteSet -( -ByteSet -) -AhoCorasick -( -AhoCorasick -) -} -impl -Choice -{ -/ -/ -/ -Select -what -is -believed -to -be -the -best -prefilter -algorithm -for -the -/ -/ -/ -match -semantics -and -sequence -of -needles -given -. -/ -/ -/ -/ -/ -/ -This -selection -algorithm -uses -the -needles -as -given -without -any -/ -/ -/ -modification -. -For -example -if -[ -bar -] -is -given -then -this -doesn -' -t -/ -/ -/ -try -to -select -memchr -for -b -. -Instead -it -would -select -memmem -/ -/ -/ -for -bar -. -If -callers -would -want -memchr -selected -for -[ -bar -] -then -/ -/ -/ -callers -should -massages -the -literals -themselves -. -That -is -callers -are -/ -/ -/ -responsible -for -heuristics -surrounding -which -sequence -of -literals -is -/ -/ -/ -best -. -/ -/ -/ -/ -/ -/ -What -this -selection -algorithm -does -is -attempt -to -use -the -fastest -/ -/ -/ -prefilter -that -works -for -the -literals -given -. -So -if -[ -a -b -] -is -given -/ -/ -/ -then -memchr2 -is -selected -. -/ -/ -/ -/ -/ -/ -Of -course -which -prefilter -is -selected -is -also -subject -to -what -/ -/ -/ -is -available -. -For -example -if -alloc -isn -' -t -enabled -then -/ -/ -/ -that -limits -which -prefilters -can -be -selected -. -Similarly -if -/ -/ -/ -perf -- -literal -- -substring -isn -' -t -enabled -then -nothing -from -the -memchr -/ -/ -/ -crate -can -be -returned -. -pub -( -crate -) -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -Choice -> -{ -/ -/ -An -empty -set -means -the -regex -matches -nothing -so -no -sense -in -/ -/ -building -a -prefilter -. -if -needles -. -len -( -) -= -= -0 -{ -debug -! -( -" -prefilter -building -failed -: -found -empty -set -of -literals -" -) -; -return -None -; -} -/ -/ -If -the -regex -can -match -the -empty -string -then -the -prefilter -/ -/ -will -by -definition -match -at -every -position -. -This -is -obviously -/ -/ -completely -ineffective -. -if -needles -. -iter -( -) -. -any -( -| -n -| -n -. -as_ref -( -) -. -is_empty -( -) -) -{ -debug -! -( -" -prefilter -building -failed -: -literals -match -empty -string -" -) -; -return -None -; -} -/ -/ -BREADCRUMBS -: -Perhaps -the -literal -optimizer -should -special -case -/ -/ -sequences -of -length -two -or -three -if -the -leading -bytes -of -each -are -/ -/ -" -rare -" -? -Or -perhaps -if -there -are -two -or -three -total -possible -leading -/ -/ -bytes -regardless -of -the -number -of -literals -and -all -are -rare -. -. -. -/ -/ -Then -well -perhaps -we -should -use -memchr2 -or -memchr3 -in -those -cases -? -if -let -Some -( -pre -) -= -Memchr -: -: -new -( -kind -needles -) -{ -debug -! -( -" -prefilter -built -: -memchr -" -) -; -return -Some -( -Choice -: -: -Memchr -( -pre -) -) -; -} -if -let -Some -( -pre -) -= -Memchr2 -: -: -new -( -kind -needles -) -{ -debug -! -( -" -prefilter -built -: -memchr2 -" -) -; -return -Some -( -Choice -: -: -Memchr2 -( -pre -) -) -; -} -if -let -Some -( -pre -) -= -Memchr3 -: -: -new -( -kind -needles -) -{ -debug -! -( -" -prefilter -built -: -memchr3 -" -) -; -return -Some -( -Choice -: -: -Memchr3 -( -pre -) -) -; -} -if -let -Some -( -pre -) -= -Memmem -: -: -new -( -kind -needles -) -{ -debug -! -( -" -prefilter -built -: -memmem -" -) -; -return -Some -( -Choice -: -: -Memmem -( -pre -) -) -; -} -if -let -Some -( -pre -) -= -Teddy -: -: -new -( -kind -needles -) -{ -debug -! -( -" -prefilter -built -: -teddy -" -) -; -return -Some -( -Choice -: -: -Teddy -( -pre -) -) -; -} -if -let -Some -( -pre -) -= -ByteSet -: -: -new -( -kind -needles -) -{ -debug -! -( -" -prefilter -built -: -byteset -" -) -; -return -Some -( -Choice -: -: -ByteSet -( -pre -) -) -; -} -if -let -Some -( -pre -) -= -AhoCorasick -: -: -new -( -kind -needles -) -{ -debug -! -( -" -prefilter -built -: -aho -- -corasick -" -) -; -return -Some -( -Choice -: -: -AhoCorasick -( -pre -) -) -; -} -debug -! -( -" -prefilter -building -failed -: -no -strategy -could -be -found -" -) -; -None -} -} -/ -/ -/ -Extracts -all -of -the -prefix -literals -from -the -given -HIR -expressions -into -a -/ -/ -/ -single -Seq -. -The -literals -in -the -sequence -are -ordered -with -respect -to -the -/ -/ -/ -order -of -the -given -HIR -expressions -and -consistent -with -the -match -semantics -/ -/ -/ -given -. -/ -/ -/ -/ -/ -/ -The -sequence -returned -is -" -optimized -. -" -That -is -they -may -be -shrunk -or -even -/ -/ -/ -truncated -according -to -heuristics -with -the -intent -of -making -them -more -/ -/ -/ -useful -as -a -prefilter -. -( -Which -translates -to -both -using -faster -algorithms -/ -/ -/ -and -minimizing -the -false -positive -rate -. -) -/ -/ -/ -/ -/ -/ -Note -that -this -erases -any -connection -between -the -literals -and -which -pattern -/ -/ -/ -( -or -patterns -) -they -came -from -. -/ -/ -/ -/ -/ -/ -The -match -kind -given -must -correspond -to -the -match -semantics -of -the -regex -/ -/ -/ -that -is -represented -by -the -HIRs -given -. -The -match -semantics -may -change -the -/ -/ -/ -literal -sequence -returned -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -( -crate -) -fn -prefixes -< -H -> -( -kind -: -MatchKind -hirs -: -& -[ -H -] -) -- -> -literal -: -: -Seq -where -H -: -core -: -: -borrow -: -: -Borrow -< -Hir -> -{ -let -mut -extractor -= -literal -: -: -Extractor -: -: -new -( -) -; -extractor -. -kind -( -literal -: -: -ExtractKind -: -: -Prefix -) -; -let -mut -prefixes -= -literal -: -: -Seq -: -: -empty -( -) -; -for -hir -in -hirs -{ -prefixes -. -union -( -& -mut -extractor -. -extract -( -hir -. -borrow -( -) -) -) -; -} -debug -! -( -" -prefixes -( -len -= -{ -: -? -} -exact -= -{ -: -? -} -) -extracted -before -optimization -: -{ -: -? -} -" -prefixes -. -len -( -) -prefixes -. -is_exact -( -) -prefixes -) -; -match -kind -{ -MatchKind -: -: -All -= -> -{ -prefixes -. -sort -( -) -; -prefixes -. -dedup -( -) -; -} -MatchKind -: -: -LeftmostFirst -= -> -{ -prefixes -. -optimize_for_prefix_by_preference -( -) -; -} -} -debug -! -( -" -prefixes -( -len -= -{ -: -? -} -exact -= -{ -: -? -} -) -extracted -after -optimization -: -{ -: -? -} -" -prefixes -. -len -( -) -prefixes -. -is_exact -( -) -prefixes -) -; -prefixes -} -/ -/ -/ -Like -prefixes -but -for -all -suffixes -of -all -matches -for -the -given -HIRs -. -# -[ -cfg -( -feature -= -" -syntax -" -) -] -pub -( -crate -) -fn -suffixes -< -H -> -( -kind -: -MatchKind -hirs -: -& -[ -H -] -) -- -> -literal -: -: -Seq -where -H -: -core -: -: -borrow -: -: -Borrow -< -Hir -> -{ -let -mut -extractor -= -literal -: -: -Extractor -: -: -new -( -) -; -extractor -. -kind -( -literal -: -: -ExtractKind -: -: -Suffix -) -; -let -mut -suffixes -= -literal -: -: -Seq -: -: -empty -( -) -; -for -hir -in -hirs -{ -suffixes -. -union -( -& -mut -extractor -. -extract -( -hir -. -borrow -( -) -) -) -; -} -debug -! -( -" -suffixes -( -len -= -{ -: -? -} -exact -= -{ -: -? -} -) -extracted -before -optimization -: -{ -: -? -} -" -suffixes -. -len -( -) -suffixes -. -is_exact -( -) -suffixes -) -; -match -kind -{ -MatchKind -: -: -All -= -> -{ -suffixes -. -sort -( -) -; -suffixes -. -dedup -( -) -; -} -MatchKind -: -: -LeftmostFirst -= -> -{ -suffixes -. -optimize_for_suffix_by_preference -( -) -; -} -} -debug -! -( -" -suffixes -( -len -= -{ -: -? -} -exact -= -{ -: -? -} -) -extracted -after -optimization -: -{ -: -? -} -" -suffixes -. -len -( -) -suffixes -. -is_exact -( -) -suffixes -) -; -suffixes -} diff --git a/third_party/rust/regex-automata/src/util/prefilter/teddy.rs b/third_party/rust/regex-automata/src/util/prefilter/teddy.rs deleted file mode 100644 index d4760653b1193..0000000000000 --- a/third_party/rust/regex-automata/src/util/prefilter/teddy.rs +++ /dev/null @@ -1,1464 +0,0 @@ -use -crate -: -: -util -: -: -{ -prefilter -: -: -PrefilterI -search -: -: -{ -MatchKind -Span -} -} -; -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -Teddy -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -_unused -: -( -) -/ -/ -/ -The -actual -Teddy -searcher -. -/ -/ -/ -/ -/ -/ -Technically -it -' -s -possible -that -Teddy -doesn -' -t -actually -get -used -since -/ -/ -/ -Teddy -does -require -its -haystack -to -at -least -be -of -a -certain -size -/ -/ -/ -( -usually -around -the -size -of -whatever -vector -is -being -used -so -~ -16 -/ -/ -/ -or -~ -32 -bytes -) -. -For -haystacks -shorter -than -that -the -implementation -/ -/ -/ -currently -uses -Rabin -- -Karp -. -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -searcher -: -aho_corasick -: -: -packed -: -: -Searcher -/ -/ -/ -When -running -an -anchored -search -the -packed -searcher -can -' -t -handle -it -so -/ -/ -/ -we -defer -to -Aho -- -Corasick -itself -. -Kind -of -sad -but -changing -the -packed -/ -/ -/ -searchers -to -support -anchored -search -would -be -difficult -at -worst -and -/ -/ -/ -annoying -at -best -. -Since -packed -searchers -only -apply -to -small -numbers -of -/ -/ -/ -literals -we -content -ourselves -that -this -is -not -much -of -an -added -cost -. -/ -/ -/ -( -That -packed -searchers -only -work -with -a -small -number -of -literals -is -/ -/ -/ -also -why -we -use -a -DFA -here -. -Otherwise -the -memory -usage -of -a -DFA -would -/ -/ -/ -likely -be -unacceptable -. -) -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -anchored_ac -: -aho_corasick -: -: -dfa -: -: -DFA -/ -/ -/ -The -length -of -the -smallest -literal -we -look -for -. -/ -/ -/ -/ -/ -/ -We -use -this -as -a -heuristic -to -figure -out -whether -this -will -be -" -fast -" -or -/ -/ -/ -not -. -Generally -the -longer -the -better -because -longer -needles -are -more -/ -/ -/ -discriminating -and -thus -reduce -false -positive -rate -. -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -minimum_len -: -usize -} -impl -Teddy -{ -pub -( -crate -) -fn -new -< -B -: -AsRef -< -[ -u8 -] -> -> -( -kind -: -MatchKind -needles -: -& -[ -B -] -) -- -> -Option -< -Teddy -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -None -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -/ -/ -We -only -really -support -leftmost -- -first -semantics -. -In -/ -/ -theory -we -could -at -least -support -leftmost -- -longest -as -the -/ -/ -aho -- -corasick -crate -does -but -regex -- -automata -doesn -' -t -know -about -/ -/ -leftmost -- -longest -currently -. -/ -/ -/ -/ -And -like -the -aho -- -corasick -prefilter -if -we -' -re -using -All -/ -/ -semantics -then -we -can -still -use -leftmost -semantics -for -a -/ -/ -prefilter -. -( -This -might -be -a -suspicious -choice -for -the -literal -/ -/ -engine -which -uses -a -prefilter -as -a -regex -engine -directly -but -/ -/ -that -only -happens -when -using -leftmost -- -first -semantics -. -) -let -( -packed_match_kind -ac_match_kind -) -= -match -kind -{ -MatchKind -: -: -LeftmostFirst -| -MatchKind -: -: -All -= -> -( -aho_corasick -: -: -packed -: -: -MatchKind -: -: -LeftmostFirst -aho_corasick -: -: -MatchKind -: -: -LeftmostFirst -) -} -; -let -minimum_len -= -needles -. -iter -( -) -. -map -( -| -n -| -n -. -as_ref -( -) -. -len -( -) -) -. -min -( -) -. -unwrap_or -( -0 -) -; -let -packed -= -aho_corasick -: -: -packed -: -: -Config -: -: -new -( -) -. -match_kind -( -packed_match_kind -) -. -builder -( -) -. -extend -( -needles -) -. -build -( -) -? -; -let -anchored_ac -= -aho_corasick -: -: -dfa -: -: -DFA -: -: -builder -( -) -. -match_kind -( -ac_match_kind -) -. -start_kind -( -aho_corasick -: -: -StartKind -: -: -Anchored -) -. -prefilter -( -false -) -. -build -( -needles -) -. -ok -( -) -? -; -Some -( -Teddy -{ -searcher -: -packed -anchored_ac -minimum_len -} -) -} -} -} -impl -PrefilterI -for -Teddy -{ -fn -find -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -let -ac_span -= -aho_corasick -: -: -Span -{ -start -: -span -. -start -end -: -span -. -end -} -; -self -. -searcher -. -find_in -( -haystack -ac_span -) -. -map -( -| -m -| -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -) -} -} -fn -prefix -( -& -self -haystack -: -& -[ -u8 -] -span -: -Span -) -- -> -Option -< -Span -> -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -use -aho_corasick -: -: -automaton -: -: -Automaton -; -let -input -= -aho_corasick -: -: -Input -: -: -new -( -haystack -) -. -anchored -( -aho_corasick -: -: -Anchored -: -: -Yes -) -. -span -( -span -. -start -. -. -span -. -end -) -; -self -. -anchored_ac -. -try_find -( -& -input -) -/ -/ -OK -because -we -build -the -DFA -with -anchored -support -. -. -expect -( -" -aho -- -corasick -DFA -should -never -fail -" -) -. -map -( -| -m -| -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -) -} -} -fn -memory_usage -( -& -self -) -- -> -usize -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -use -aho_corasick -: -: -automaton -: -: -Automaton -; -self -. -searcher -. -memory_usage -( -) -+ -self -. -anchored_ac -. -memory_usage -( -) -} -} -fn -is_fast -( -& -self -) -- -> -bool -{ -# -[ -cfg -( -not -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -] -{ -unreachable -! -( -) -} -# -[ -cfg -( -feature -= -" -perf -- -literal -- -multisubstring -" -) -] -{ -/ -/ -Teddy -is -usually -quite -fast -but -I -have -seen -some -cases -where -/ -/ -a -large -number -of -literals -can -overwhelm -it -and -make -it -not -so -/ -/ -fast -. -We -make -an -educated -but -conservative -guess -at -a -limit -at -/ -/ -which -point -we -' -re -not -so -comfortable -thinking -Teddy -is -" -fast -. -" -/ -/ -/ -/ -Well -. -. -. -this -used -to -incorporate -a -" -limit -" -on -the -* -number -* -/ -/ -of -literals -but -I -have -since -changed -it -to -a -minimum -on -the -/ -/ -* -smallest -* -literal -. -Namely -when -there -is -a -very -small -literal -/ -/ -( -1 -or -2 -bytes -) -it -is -far -more -likely -that -it -leads -to -a -higher -/ -/ -false -positive -rate -. -( -Although -of -course -not -always -. -For -/ -/ -example -' -zq -' -is -likely -to -have -a -very -low -false -positive -rate -. -) -/ -/ -But -when -we -have -3 -bytes -we -have -a -really -good -chance -of -being -/ -/ -quite -discriminatory -and -thus -fast -. -/ -/ -/ -/ -We -may -still -want -to -add -some -kind -of -limit -on -the -number -of -/ -/ -literals -here -but -keep -in -mind -that -Teddy -already -has -its -own -/ -/ -somewhat -small -limit -( -64 -at -time -of -writing -) -. -The -main -issue -/ -/ -here -is -that -if -' -is_fast -' -is -false -it -opens -the -door -for -the -/ -/ -reverse -inner -optimization -to -kick -in -. -We -really -only -want -to -/ -/ -resort -to -the -reverse -inner -optimization -if -we -absolutely -must -. -self -. -minimum_len -> -= -3 -} -} -} diff --git a/third_party/rust/regex-automata/src/util/primitives.rs b/third_party/rust/regex-automata/src/util/primitives.rs deleted file mode 100644 index 8905ce4d34df4..0000000000000 --- a/third_party/rust/regex-automata/src/util/primitives.rs +++ /dev/null @@ -1,6255 +0,0 @@ -/ -* -! -Lower -level -primitive -types -that -are -useful -in -a -variety -of -circumstances -. -# -Overview -This -list -represents -the -principle -types -in -this -module -and -briefly -describes -when -you -might -want -to -use -them -. -* -[ -PatternID -] -- -A -type -that -represents -the -identifier -of -a -regex -pattern -. -This -is -probably -the -most -widely -used -type -in -this -module -( -which -is -why -it -' -s -also -re -- -exported -in -the -crate -root -) -. -* -[ -StateID -] -- -A -type -the -represents -the -identifier -of -a -finite -automaton -state -. -This -is -used -for -both -NFAs -and -DFAs -with -the -notable -exception -of -the -hybrid -NFA -/ -DFA -. -( -The -hybrid -NFA -/ -DFA -uses -a -special -purpose -" -lazy -" -state -identifier -. -) -* -[ -SmallIndex -] -- -The -internal -representation -of -both -a -PatternID -and -a -StateID -. -Its -purpose -is -to -serve -as -a -type -that -can -index -memory -without -being -as -big -as -a -usize -on -64 -- -bit -targets -. -The -main -idea -behind -this -type -is -that -there -are -many -things -in -regex -engines -that -will -in -practice -never -overflow -a -32 -- -bit -integer -. -( -For -example -like -the -number -of -patterns -in -a -regex -or -the -number -of -states -in -an -NFA -. -) -Thus -a -SmallIndex -can -be -used -to -index -memory -without -peppering -as -casts -everywhere -. -Moreover -it -forces -callers -to -handle -errors -in -the -case -where -somehow -the -value -would -otherwise -overflow -either -a -32 -- -bit -integer -or -a -usize -( -e -. -g -. -on -16 -- -bit -targets -) -. -* -[ -NonMaxUsize -] -- -Represents -a -usize -that -cannot -be -usize -: -: -MAX -. -As -a -result -Option -< -NonMaxUsize -> -has -the -same -size -in -memory -as -a -usize -. -This -useful -for -example -when -representing -the -offsets -of -submatches -since -it -reduces -memory -usage -by -a -factor -of -2 -. -It -is -a -legal -optimization -since -Rust -guarantees -that -slices -never -have -a -length -that -exceeds -isize -: -: -MAX -. -* -/ -use -core -: -: -num -: -: -NonZeroUsize -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -use -alloc -: -: -vec -: -: -Vec -; -use -crate -: -: -util -: -: -int -: -: -{ -Usize -U16 -U32 -U64 -} -; -/ -/ -/ -A -usize -that -can -never -be -usize -: -: -MAX -. -/ -/ -/ -/ -/ -/ -This -is -similar -to -core -: -: -num -: -: -NonZeroUsize -but -instead -of -not -permitting -/ -/ -/ -a -zero -value -this -does -not -permit -a -max -value -. -/ -/ -/ -/ -/ -/ -This -is -useful -in -certain -contexts -where -one -wants -to -optimize -the -memory -/ -/ -/ -usage -of -things -that -contain -match -offsets -. -Namely -since -Rust -slices -/ -/ -/ -are -guaranteed -to -never -have -a -length -exceeding -isize -: -: -MAX -we -can -use -/ -/ -/ -usize -: -: -MAX -as -a -sentinel -to -indicate -that -no -match -was -found -. -Indeed -/ -/ -/ -types -like -Option -< -NonMaxUsize -> -have -exactly -the -same -size -in -memory -as -a -/ -/ -/ -usize -. -/ -/ -/ -/ -/ -/ -This -type -is -defined -to -be -repr -( -transparent -) -for -/ -/ -/ -core -: -: -num -: -: -NonZeroUsize -which -is -in -turn -defined -to -be -/ -/ -/ -repr -( -transparent -) -for -usize -. -# -[ -derive -( -Clone -Copy -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -# -[ -repr -( -transparent -) -] -pub -struct -NonMaxUsize -( -NonZeroUsize -) -; -impl -NonMaxUsize -{ -/ -/ -/ -Create -a -new -NonMaxUsize -from -the -given -value -. -/ -/ -/ -/ -/ -/ -This -returns -None -only -when -the -given -value -is -equal -to -usize -: -: -MAX -. -# -[ -inline -] -pub -fn -new -( -value -: -usize -) -- -> -Option -< -NonMaxUsize -> -{ -NonZeroUsize -: -: -new -( -value -. -wrapping_add -( -1 -) -) -. -map -( -NonMaxUsize -) -} -/ -/ -/ -Return -the -underlying -usize -value -. -The -returned -value -is -guaranteed -/ -/ -/ -to -not -equal -usize -: -: -MAX -. -# -[ -inline -] -pub -fn -get -( -self -) -- -> -usize -{ -self -. -0 -. -get -( -) -. -wrapping_sub -( -1 -) -} -} -/ -/ -We -provide -our -own -Debug -impl -because -seeing -the -internal -repr -can -be -quite -/ -/ -surprising -if -you -aren -' -t -expecting -it -. -e -. -g -. -' -NonMaxUsize -( -5 -) -' -vs -just -' -5 -' -. -impl -core -: -: -fmt -: -: -Debug -for -NonMaxUsize -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -: -? -} -" -self -. -get -( -) -) -} -} -/ -/ -/ -A -type -that -represents -a -" -small -" -index -. -/ -/ -/ -/ -/ -/ -The -main -idea -of -this -type -is -to -provide -something -that -can -index -memory -/ -/ -/ -but -uses -less -memory -than -usize -on -64 -- -bit -systems -. -Specifically -its -/ -/ -/ -representation -is -always -a -u32 -and -has -repr -( -transparent -) -enabled -. -( -So -/ -/ -/ -it -is -safe -to -transmute -between -a -u32 -and -a -SmallIndex -. -) -/ -/ -/ -/ -/ -/ -A -small -index -is -typically -useful -in -cases -where -there -is -no -practical -way -/ -/ -/ -that -the -index -will -overflow -a -32 -- -bit -integer -. -A -good -example -of -this -is -/ -/ -/ -an -NFA -state -. -If -you -could -somehow -build -an -NFA -with -2 -^ -30 -states -its -/ -/ -/ -memory -usage -would -be -exorbitant -and -its -runtime -execution -would -be -so -/ -/ -/ -slow -as -to -be -completely -worthless -. -Therefore -this -crate -generally -deems -/ -/ -/ -it -acceptable -to -return -an -error -if -it -would -otherwise -build -an -NFA -that -/ -/ -/ -requires -a -slice -longer -than -what -a -32 -- -bit -integer -can -index -. -In -exchange -/ -/ -/ -we -can -use -32 -- -bit -indices -instead -of -64 -- -bit -indices -in -various -places -. -/ -/ -/ -/ -/ -/ -This -type -ensures -this -by -providing -a -constructor -that -will -return -an -error -/ -/ -/ -if -its -argument -cannot -fit -into -the -type -. -This -makes -it -much -easier -to -/ -/ -/ -handle -these -sorts -of -boundary -cases -that -are -otherwise -extremely -subtle -. -/ -/ -/ -/ -/ -/ -On -all -targets -this -type -guarantees -that -its -value -will -fit -in -a -u32 -/ -/ -/ -i32 -usize -and -an -isize -. -This -means -that -on -16 -- -bit -targets -for -/ -/ -/ -example -this -type -' -s -maximum -value -will -never -overflow -an -isize -/ -/ -/ -which -means -it -will -never -overflow -a -i16 -even -though -its -internal -/ -/ -/ -representation -is -still -a -u32 -. -/ -/ -/ -/ -/ -/ -The -purpose -for -making -the -type -fit -into -even -signed -integer -types -like -/ -/ -/ -isize -is -to -guarantee -that -the -difference -between -any -two -small -indices -/ -/ -/ -is -itself -also -a -small -index -. -This -is -useful -in -certain -contexts -e -. -g -. -/ -/ -/ -for -delta -encoding -. -/ -/ -/ -/ -/ -/ -# -Other -types -/ -/ -/ -/ -/ -/ -The -following -types -wrap -SmallIndex -to -provide -a -more -focused -use -case -: -/ -/ -/ -/ -/ -/ -* -[ -PatternID -] -is -for -representing -the -identifiers -of -patterns -. -/ -/ -/ -* -[ -StateID -] -is -for -representing -the -identifiers -of -states -in -finite -/ -/ -/ -automata -. -It -is -used -for -both -NFAs -and -DFAs -. -/ -/ -/ -/ -/ -/ -# -Representation -/ -/ -/ -/ -/ -/ -This -type -is -always -represented -internally -by -a -u32 -and -is -marked -as -/ -/ -/ -repr -( -transparent -) -. -Thus -this -type -always -has -the -same -representation -as -/ -/ -/ -a -u32 -. -It -is -thus -safe -to -transmute -between -a -u32 -and -a -SmallIndex -. -/ -/ -/ -/ -/ -/ -# -Indexing -/ -/ -/ -/ -/ -/ -For -convenience -callers -may -use -a -SmallIndex -to -index -slices -. -/ -/ -/ -/ -/ -/ -# -Safety -/ -/ -/ -/ -/ -/ -While -a -SmallIndex -is -meant -to -guarantee -that -its -value -fits -into -usize -/ -/ -/ -without -using -as -much -space -as -a -usize -on -all -targets -callers -must -/ -/ -/ -not -rely -on -this -property -for -safety -. -Callers -may -choose -to -rely -on -this -/ -/ -/ -property -for -correctness -however -. -For -example -creating -a -SmallIndex -with -/ -/ -/ -an -invalid -value -can -be -done -in -entirely -safe -code -. -This -may -in -turn -result -/ -/ -/ -in -panics -or -silent -logical -errors -. -# -[ -derive -( -Clone -Copy -Debug -Default -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -# -[ -repr -( -transparent -) -] -pub -struct -SmallIndex -( -u32 -) -; -impl -SmallIndex -{ -/ -/ -/ -The -maximum -index -value -. -# -[ -cfg -( -any -( -target_pointer_width -= -" -32 -" -target_pointer_width -= -" -64 -" -) -) -] -pub -const -MAX -: -SmallIndex -= -/ -/ -FIXME -: -Use -as_usize -( -) -once -const -functions -in -traits -are -stable -. -SmallIndex -: -: -new_unchecked -( -core -: -: -i32 -: -: -MAX -as -usize -- -1 -) -; -/ -/ -/ -The -maximum -index -value -. -# -[ -cfg -( -target_pointer_width -= -" -16 -" -) -] -pub -const -MAX -: -SmallIndex -= -SmallIndex -: -: -new_unchecked -( -core -: -: -isize -: -: -MAX -- -1 -) -; -/ -/ -/ -The -total -number -of -values -that -can -be -represented -as -a -small -index -. -pub -const -LIMIT -: -usize -= -SmallIndex -: -: -MAX -. -as_usize -( -) -+ -1 -; -/ -/ -/ -The -zero -index -value -. -pub -const -ZERO -: -SmallIndex -= -SmallIndex -: -: -new_unchecked -( -0 -) -; -/ -/ -/ -The -number -of -bytes -that -a -single -small -index -uses -in -memory -. -pub -const -SIZE -: -usize -= -core -: -: -mem -: -: -size_of -: -: -< -SmallIndex -> -( -) -; -/ -/ -/ -Create -a -new -small -index -. -/ -/ -/ -/ -/ -/ -If -the -given -index -exceeds -[ -SmallIndex -: -: -MAX -] -then -this -returns -/ -/ -/ -an -error -. -# -[ -inline -] -pub -fn -new -( -index -: -usize -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -SmallIndex -: -: -try_from -( -index -) -} -/ -/ -/ -Create -a -new -small -index -without -checking -whether -the -given -value -/ -/ -/ -exceeds -[ -SmallIndex -: -: -MAX -] -. -/ -/ -/ -/ -/ -/ -Using -this -routine -with -an -invalid -index -value -will -result -in -/ -/ -/ -unspecified -behavior -but -* -not -* -undefined -behavior -. -In -particular -an -/ -/ -/ -invalid -index -value -is -likely -to -cause -panics -or -possibly -even -silent -/ -/ -/ -logical -errors -. -/ -/ -/ -/ -/ -/ -Callers -must -never -rely -on -a -SmallIndex -to -be -within -a -certain -range -/ -/ -/ -for -memory -safety -. -# -[ -inline -] -pub -const -fn -new_unchecked -( -index -: -usize -) -- -> -SmallIndex -{ -/ -/ -FIXME -: -Use -as_u32 -( -) -once -const -functions -in -traits -are -stable -. -SmallIndex -( -index -as -u32 -) -} -/ -/ -/ -Like -[ -SmallIndex -: -: -new -] -but -panics -if -the -given -index -is -not -valid -. -# -[ -inline -] -pub -fn -must -( -index -: -usize -) -- -> -SmallIndex -{ -SmallIndex -: -: -new -( -index -) -. -expect -( -" -invalid -small -index -" -) -} -/ -/ -/ -Return -this -small -index -as -a -usize -. -This -is -guaranteed -to -never -/ -/ -/ -overflow -usize -. -# -[ -inline -] -pub -const -fn -as_usize -( -& -self -) -- -> -usize -{ -/ -/ -FIXME -: -Use -as_usize -( -) -once -const -functions -in -traits -are -stable -. -self -. -0 -as -usize -} -/ -/ -/ -Return -this -small -index -as -a -u64 -. -This -is -guaranteed -to -never -/ -/ -/ -overflow -. -# -[ -inline -] -pub -const -fn -as_u64 -( -& -self -) -- -> -u64 -{ -/ -/ -FIXME -: -Use -u64 -: -: -from -( -) -once -const -functions -in -traits -are -stable -. -self -. -0 -as -u64 -} -/ -/ -/ -Return -the -internal -u32 -of -this -small -index -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -u32 -. -# -[ -inline -] -pub -const -fn -as_u32 -( -& -self -) -- -> -u32 -{ -self -. -0 -} -/ -/ -/ -Return -the -internal -u32 -of -this -small -index -represented -as -an -i32 -. -/ -/ -/ -This -is -guaranteed -to -never -overflow -an -i32 -. -# -[ -inline -] -pub -const -fn -as_i32 -( -& -self -) -- -> -i32 -{ -/ -/ -This -is -OK -because -we -guarantee -that -our -max -value -is -< -= -i32 -: -: -MAX -. -self -. -0 -as -i32 -} -/ -/ -/ -Returns -one -more -than -this -small -index -as -a -usize -. -/ -/ -/ -/ -/ -/ -Since -a -small -index -has -constraints -on -its -maximum -value -adding -1 -to -/ -/ -/ -it -will -always -fit -in -a -usize -u32 -and -a -i32 -. -# -[ -inline -] -pub -fn -one_more -( -& -self -) -- -> -usize -{ -self -. -as_usize -( -) -+ -1 -} -/ -/ -/ -Decode -this -small -index -from -the -bytes -given -using -the -native -endian -/ -/ -/ -byte -order -for -the -current -target -. -/ -/ -/ -/ -/ -/ -If -the -decoded -integer -is -not -representable -as -a -small -index -for -the -/ -/ -/ -current -target -then -this -returns -an -error -. -# -[ -inline -] -pub -fn -from_ne_bytes -( -bytes -: -[ -u8 -; -4 -] -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -let -id -= -u32 -: -: -from_ne_bytes -( -bytes -) -; -if -id -> -SmallIndex -: -: -MAX -. -as_u32 -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -u64 -: -: -from -( -id -) -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -id -. -as_usize -( -) -) -) -} -/ -/ -/ -Decode -this -small -index -from -the -bytes -given -using -the -native -endian -/ -/ -/ -byte -order -for -the -current -target -. -/ -/ -/ -/ -/ -/ -This -is -analogous -to -[ -SmallIndex -: -: -new_unchecked -] -in -that -is -does -not -/ -/ -/ -check -whether -the -decoded -integer -is -representable -as -a -small -index -. -# -[ -inline -] -pub -fn -from_ne_bytes_unchecked -( -bytes -: -[ -u8 -; -4 -] -) -- -> -SmallIndex -{ -SmallIndex -: -: -new_unchecked -( -u32 -: -: -from_ne_bytes -( -bytes -) -. -as_usize -( -) -) -} -/ -/ -/ -Return -the -underlying -small -index -integer -as -raw -bytes -in -native -endian -/ -/ -/ -format -. -# -[ -inline -] -pub -fn -to_ne_bytes -( -& -self -) -- -> -[ -u8 -; -4 -] -{ -self -. -0 -. -to_ne_bytes -( -) -} -} -impl -< -T -> -core -: -: -ops -: -: -Index -< -SmallIndex -> -for -[ -T -] -{ -type -Output -= -T -; -# -[ -inline -] -fn -index -( -& -self -index -: -SmallIndex -) -- -> -& -T -{ -& -self -[ -index -. -as_usize -( -) -] -} -} -impl -< -T -> -core -: -: -ops -: -: -IndexMut -< -SmallIndex -> -for -[ -T -] -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -SmallIndex -) -- -> -& -mut -T -{ -& -mut -self -[ -index -. -as_usize -( -) -] -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -T -> -core -: -: -ops -: -: -Index -< -SmallIndex -> -for -Vec -< -T -> -{ -type -Output -= -T -; -# -[ -inline -] -fn -index -( -& -self -index -: -SmallIndex -) -- -> -& -T -{ -& -self -[ -index -. -as_usize -( -) -] -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -T -> -core -: -: -ops -: -: -IndexMut -< -SmallIndex -> -for -Vec -< -T -> -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -SmallIndex -) -- -> -& -mut -T -{ -& -mut -self -[ -index -. -as_usize -( -) -] -} -} -impl -From -< -u8 -> -for -SmallIndex -{ -fn -from -( -index -: -u8 -) -- -> -SmallIndex -{ -SmallIndex -: -: -new_unchecked -( -usize -: -: -from -( -index -) -) -} -} -impl -TryFrom -< -u16 -> -for -SmallIndex -{ -type -Error -= -SmallIndexError -; -fn -try_from -( -index -: -u16 -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -if -u32 -: -: -from -( -index -) -> -SmallIndex -: -: -MAX -. -as_u32 -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -u64 -: -: -from -( -index -) -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -index -. -as_usize -( -) -) -) -} -} -impl -TryFrom -< -u32 -> -for -SmallIndex -{ -type -Error -= -SmallIndexError -; -fn -try_from -( -index -: -u32 -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -if -index -> -SmallIndex -: -: -MAX -. -as_u32 -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -u64 -: -: -from -( -index -) -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -index -. -as_usize -( -) -) -) -} -} -impl -TryFrom -< -u64 -> -for -SmallIndex -{ -type -Error -= -SmallIndexError -; -fn -try_from -( -index -: -u64 -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -if -index -> -SmallIndex -: -: -MAX -. -as_u64 -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -index -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -index -. -as_usize -( -) -) -) -} -} -impl -TryFrom -< -usize -> -for -SmallIndex -{ -type -Error -= -SmallIndexError -; -fn -try_from -( -index -: -usize -) -- -> -Result -< -SmallIndex -SmallIndexError -> -{ -if -index -> -SmallIndex -: -: -MAX -. -as_usize -( -) -{ -return -Err -( -SmallIndexError -{ -attempted -: -index -. -as_u64 -( -) -} -) -; -} -Ok -( -SmallIndex -: -: -new_unchecked -( -index -) -) -} -} -# -[ -cfg -( -test -) -] -impl -quickcheck -: -: -Arbitrary -for -SmallIndex -{ -fn -arbitrary -( -gen -: -& -mut -quickcheck -: -: -Gen -) -- -> -SmallIndex -{ -use -core -: -: -cmp -: -: -max -; -let -id -= -max -( -i32 -: -: -MIN -+ -1 -i32 -: -: -arbitrary -( -gen -) -) -. -abs -( -) -; -if -id -> -SmallIndex -: -: -MAX -. -as_i32 -( -) -{ -SmallIndex -: -: -MAX -} -else -{ -SmallIndex -: -: -new -( -usize -: -: -try_from -( -id -) -. -unwrap -( -) -) -. -unwrap -( -) -} -} -} -/ -/ -/ -This -error -occurs -when -a -small -index -could -not -be -constructed -. -/ -/ -/ -/ -/ -/ -This -occurs -when -given -an -integer -exceeding -the -maximum -small -index -value -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -Error -trait -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -SmallIndexError -{ -attempted -: -u64 -} -impl -SmallIndexError -{ -/ -/ -/ -Returns -the -value -that -could -not -be -converted -to -a -small -index -. -pub -fn -attempted -( -& -self -) -- -> -u64 -{ -self -. -attempted -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -SmallIndexError -{ -} -impl -core -: -: -fmt -: -: -Display -for -SmallIndexError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -failed -to -create -small -index -from -{ -: -? -} -which -exceeds -{ -: -? -} -" -self -. -attempted -( -) -SmallIndex -: -: -MAX -) -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -SmallIndexIter -{ -rng -: -core -: -: -ops -: -: -Range -< -usize -> -} -impl -Iterator -for -SmallIndexIter -{ -type -Item -= -SmallIndex -; -fn -next -( -& -mut -self -) -- -> -Option -< -SmallIndex -> -{ -if -self -. -rng -. -start -> -= -self -. -rng -. -end -{ -return -None -; -} -let -next_id -= -self -. -rng -. -start -+ -1 -; -let -id -= -core -: -: -mem -: -: -replace -( -& -mut -self -. -rng -. -start -next_id -) -; -/ -/ -new_unchecked -is -OK -since -we -asserted -that -the -number -of -/ -/ -elements -in -this -iterator -will -fit -in -an -ID -at -construction -. -Some -( -SmallIndex -: -: -new_unchecked -( -id -) -) -} -} -macro_rules -! -index_type_impls -{ -( -name -: -ident -err -: -ident -iter -: -ident -withiter -: -ident -) -= -> -{ -impl -name -{ -/ -/ -/ -The -maximum -value -. -pub -const -MAX -: -name -= -name -( -SmallIndex -: -: -MAX -) -; -/ -/ -/ -The -total -number -of -values -that -can -be -represented -. -pub -const -LIMIT -: -usize -= -SmallIndex -: -: -LIMIT -; -/ -/ -/ -The -zero -value -. -pub -const -ZERO -: -name -= -name -( -SmallIndex -: -: -ZERO -) -; -/ -/ -/ -The -number -of -bytes -that -a -single -value -uses -in -memory -. -pub -const -SIZE -: -usize -= -SmallIndex -: -: -SIZE -; -/ -/ -/ -Create -a -new -value -that -is -represented -by -a -" -small -index -. -" -/ -/ -/ -/ -/ -/ -If -the -given -index -exceeds -the -maximum -allowed -value -then -this -/ -/ -/ -returns -an -error -. -# -[ -inline -] -pub -fn -new -( -value -: -usize -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -new -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -/ -/ -/ -Create -a -new -value -without -checking -whether -the -given -argument -/ -/ -/ -exceeds -the -maximum -. -/ -/ -/ -/ -/ -/ -Using -this -routine -with -an -invalid -value -will -result -in -/ -/ -/ -unspecified -behavior -but -* -not -* -undefined -behavior -. -In -/ -/ -/ -particular -an -invalid -ID -value -is -likely -to -cause -panics -or -/ -/ -/ -possibly -even -silent -logical -errors -. -/ -/ -/ -/ -/ -/ -Callers -must -never -rely -on -this -type -to -be -within -a -certain -/ -/ -/ -range -for -memory -safety -. -# -[ -inline -] -pub -const -fn -new_unchecked -( -value -: -usize -) -- -> -name -{ -name -( -SmallIndex -: -: -new_unchecked -( -value -) -) -} -/ -/ -/ -Like -new -but -panics -if -the -given -value -is -not -valid -. -# -[ -inline -] -pub -fn -must -( -value -: -usize -) -- -> -name -{ -name -: -: -new -( -value -) -. -expect -( -concat -! -( -" -invalid -" -stringify -! -( -name -) -" -value -" -) -) -} -/ -/ -/ -Return -the -internal -value -as -a -usize -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -usize -. -# -[ -inline -] -pub -const -fn -as_usize -( -& -self -) -- -> -usize -{ -self -. -0 -. -as_usize -( -) -} -/ -/ -/ -Return -the -internal -value -as -a -u64 -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -. -# -[ -inline -] -pub -const -fn -as_u64 -( -& -self -) -- -> -u64 -{ -self -. -0 -. -as_u64 -( -) -} -/ -/ -/ -Return -the -internal -value -as -a -u32 -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -u32 -. -# -[ -inline -] -pub -const -fn -as_u32 -( -& -self -) -- -> -u32 -{ -self -. -0 -. -as_u32 -( -) -} -/ -/ -/ -Return -the -internal -value -as -a -i32 -. -This -is -guaranteed -to -/ -/ -/ -never -overflow -an -i32 -. -# -[ -inline -] -pub -const -fn -as_i32 -( -& -self -) -- -> -i32 -{ -self -. -0 -. -as_i32 -( -) -} -/ -/ -/ -Returns -one -more -than -this -value -as -a -usize -. -/ -/ -/ -/ -/ -/ -Since -values -represented -by -a -" -small -index -" -have -constraints -/ -/ -/ -on -their -maximum -value -adding -1 -to -it -will -always -fit -in -a -/ -/ -/ -usize -u32 -and -a -i32 -. -# -[ -inline -] -pub -fn -one_more -( -& -self -) -- -> -usize -{ -self -. -0 -. -one_more -( -) -} -/ -/ -/ -Decode -this -value -from -the -bytes -given -using -the -native -endian -/ -/ -/ -byte -order -for -the -current -target -. -/ -/ -/ -/ -/ -/ -If -the -decoded -integer -is -not -representable -as -a -small -index -/ -/ -/ -for -the -current -target -then -this -returns -an -error -. -# -[ -inline -] -pub -fn -from_ne_bytes -( -bytes -: -[ -u8 -; -4 -] -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -from_ne_bytes -( -bytes -) -. -map -( -name -) -. -map_err -( -err -) -} -/ -/ -/ -Decode -this -value -from -the -bytes -given -using -the -native -endian -/ -/ -/ -byte -order -for -the -current -target -. -/ -/ -/ -/ -/ -/ -This -is -analogous -to -new_unchecked -in -that -is -does -not -check -/ -/ -/ -whether -the -decoded -integer -is -representable -as -a -small -index -. -# -[ -inline -] -pub -fn -from_ne_bytes_unchecked -( -bytes -: -[ -u8 -; -4 -] -) -- -> -name -{ -name -( -SmallIndex -: -: -from_ne_bytes_unchecked -( -bytes -) -) -} -/ -/ -/ -Return -the -underlying -integer -as -raw -bytes -in -native -endian -/ -/ -/ -format -. -# -[ -inline -] -pub -fn -to_ne_bytes -( -& -self -) -- -> -[ -u8 -; -4 -] -{ -self -. -0 -. -to_ne_bytes -( -) -} -/ -/ -/ -Returns -an -iterator -over -all -values -from -0 -up -to -and -not -/ -/ -/ -including -the -given -length -. -/ -/ -/ -/ -/ -/ -If -the -given -length -exceeds -this -type -' -s -limit -then -this -/ -/ -/ -panics -. -pub -( -crate -) -fn -iter -( -len -: -usize -) -- -> -iter -{ -iter -: -: -new -( -len -) -} -} -/ -/ -We -write -our -own -Debug -impl -so -that -we -get -things -like -PatternID -( -5 -) -/ -/ -instead -of -PatternID -( -SmallIndex -( -5 -) -) -. -impl -core -: -: -fmt -: -: -Debug -for -name -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -stringify -! -( -name -) -) -. -field -( -& -self -. -as_u32 -( -) -) -. -finish -( -) -} -} -impl -< -T -> -core -: -: -ops -: -: -Index -< -name -> -for -[ -T -] -{ -type -Output -= -T -; -# -[ -inline -] -fn -index -( -& -self -index -: -name -) -- -> -& -T -{ -& -self -[ -index -. -as_usize -( -) -] -} -} -impl -< -T -> -core -: -: -ops -: -: -IndexMut -< -name -> -for -[ -T -] -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -name -) -- -> -& -mut -T -{ -& -mut -self -[ -index -. -as_usize -( -) -] -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -T -> -core -: -: -ops -: -: -Index -< -name -> -for -Vec -< -T -> -{ -type -Output -= -T -; -# -[ -inline -] -fn -index -( -& -self -index -: -name -) -- -> -& -T -{ -& -self -[ -index -. -as_usize -( -) -] -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -T -> -core -: -: -ops -: -: -IndexMut -< -name -> -for -Vec -< -T -> -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -name -) -- -> -& -mut -T -{ -& -mut -self -[ -index -. -as_usize -( -) -] -} -} -impl -From -< -u8 -> -for -name -{ -fn -from -( -value -: -u8 -) -- -> -name -{ -name -( -SmallIndex -: -: -from -( -value -) -) -} -} -impl -TryFrom -< -u16 -> -for -name -{ -type -Error -= -err -; -fn -try_from -( -value -: -u16 -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -try_from -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -} -impl -TryFrom -< -u32 -> -for -name -{ -type -Error -= -err -; -fn -try_from -( -value -: -u32 -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -try_from -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -} -impl -TryFrom -< -u64 -> -for -name -{ -type -Error -= -err -; -fn -try_from -( -value -: -u64 -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -try_from -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -} -impl -TryFrom -< -usize -> -for -name -{ -type -Error -= -err -; -fn -try_from -( -value -: -usize -) -- -> -Result -< -name -err -> -{ -SmallIndex -: -: -try_from -( -value -) -. -map -( -name -) -. -map_err -( -err -) -} -} -# -[ -cfg -( -test -) -] -impl -quickcheck -: -: -Arbitrary -for -name -{ -fn -arbitrary -( -gen -: -& -mut -quickcheck -: -: -Gen -) -- -> -name -{ -name -( -SmallIndex -: -: -arbitrary -( -gen -) -) -} -} -/ -/ -/ -This -error -occurs -when -a -value -could -not -be -constructed -. -/ -/ -/ -/ -/ -/ -This -occurs -when -given -an -integer -exceeding -the -maximum -allowed -/ -/ -/ -value -. -/ -/ -/ -/ -/ -/ -When -the -std -feature -is -enabled -this -implements -the -Error -/ -/ -/ -trait -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -err -( -SmallIndexError -) -; -impl -err -{ -/ -/ -/ -Returns -the -value -that -could -not -be -converted -to -an -ID -. -pub -fn -attempted -( -& -self -) -- -> -u64 -{ -self -. -0 -. -attempted -( -) -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -err -{ -} -impl -core -: -: -fmt -: -: -Display -for -err -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -failed -to -create -{ -} -from -{ -: -? -} -which -exceeds -{ -: -? -} -" -stringify -! -( -name -) -self -. -attempted -( -) -name -: -: -MAX -) -} -} -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -iter -( -SmallIndexIter -) -; -impl -iter -{ -fn -new -( -len -: -usize -) -- -> -iter -{ -assert -! -( -len -< -= -name -: -: -LIMIT -" -cannot -create -iterator -for -{ -} -when -number -of -\ -elements -exceed -{ -: -? -} -" -stringify -! -( -name -) -name -: -: -LIMIT -) -; -iter -( -SmallIndexIter -{ -rng -: -0 -. -. -len -} -) -} -} -impl -Iterator -for -iter -{ -type -Item -= -name -; -fn -next -( -& -mut -self -) -- -> -Option -< -name -> -{ -self -. -0 -. -next -( -) -. -map -( -name -) -} -} -/ -/ -/ -An -iterator -adapter -that -is -like -std -: -: -iter -: -: -Enumerate -but -attaches -/ -/ -/ -small -index -values -instead -. -It -requires -ExactSizeIterator -. -At -/ -/ -/ -construction -it -ensures -that -the -index -of -each -element -in -the -/ -/ -/ -iterator -is -representable -in -the -corresponding -small -index -type -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -withiter -< -I -> -{ -it -: -I -ids -: -iter -} -impl -< -I -: -Iterator -+ -ExactSizeIterator -> -withiter -< -I -> -{ -fn -new -( -it -: -I -) -- -> -withiter -< -I -> -{ -let -ids -= -name -: -: -iter -( -it -. -len -( -) -) -; -withiter -{ -it -ids -} -} -} -impl -< -I -: -Iterator -+ -ExactSizeIterator -> -Iterator -for -withiter -< -I -> -{ -type -Item -= -( -name -I -: -: -Item -) -; -fn -next -( -& -mut -self -) -- -> -Option -< -( -name -I -: -: -Item -) -> -{ -let -item -= -self -. -it -. -next -( -) -? -; -/ -/ -Number -of -elements -in -this -iterator -must -match -according -/ -/ -to -contract -of -ExactSizeIterator -. -let -id -= -self -. -ids -. -next -( -) -. -unwrap -( -) -; -Some -( -( -id -item -) -) -} -} -} -; -} -/ -/ -/ -The -identifier -of -a -regex -pattern -represented -by -a -[ -SmallIndex -] -. -/ -/ -/ -/ -/ -/ -The -identifier -for -a -pattern -corresponds -to -its -relative -position -among -/ -/ -/ -other -patterns -in -a -single -finite -state -machine -. -Namely -when -building -/ -/ -/ -a -multi -- -pattern -regex -engine -one -must -supply -a -sequence -of -patterns -to -/ -/ -/ -match -. -The -position -( -starting -at -0 -) -of -each -pattern -in -that -sequence -/ -/ -/ -represents -its -identifier -. -This -identifier -is -in -turn -used -to -identify -and -/ -/ -/ -report -matches -of -that -pattern -in -various -APIs -. -/ -/ -/ -/ -/ -/ -See -the -[ -SmallIndex -] -type -for -more -information -about -what -it -means -for -/ -/ -/ -a -pattern -ID -to -be -a -" -small -index -. -" -/ -/ -/ -/ -/ -/ -Note -that -this -type -is -defined -in -the -/ -/ -/ -[ -util -: -: -primitives -] -( -crate -: -: -util -: -: -primitives -) -module -but -it -is -also -/ -/ -/ -re -- -exported -at -the -crate -root -due -to -how -common -it -is -. -# -[ -derive -( -Clone -Copy -Default -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -# -[ -repr -( -transparent -) -] -pub -struct -PatternID -( -SmallIndex -) -; -/ -/ -/ -The -identifier -of -a -finite -automaton -state -represented -by -a -/ -/ -/ -[ -SmallIndex -] -. -/ -/ -/ -/ -/ -/ -Most -regex -engines -in -this -crate -are -built -on -top -of -finite -automata -. -Each -/ -/ -/ -state -in -a -finite -automaton -defines -transitions -from -its -state -to -another -. -/ -/ -/ -Those -transitions -point -to -other -states -via -their -identifiers -i -. -e -. -a -/ -/ -/ -StateID -. -Since -finite -automata -tend -to -contain -many -transitions -it -is -/ -/ -/ -much -more -memory -efficient -to -define -state -IDs -as -small -indices -. -/ -/ -/ -/ -/ -/ -See -the -[ -SmallIndex -] -type -for -more -information -about -what -it -means -for -/ -/ -/ -a -state -ID -to -be -a -" -small -index -. -" -# -[ -derive -( -Clone -Copy -Default -Eq -Hash -PartialEq -PartialOrd -Ord -) -] -# -[ -repr -( -transparent -) -] -pub -struct -StateID -( -SmallIndex -) -; -index_type_impls -! -( -PatternID -PatternIDError -PatternIDIter -WithPatternIDIter -) -; -index_type_impls -! -( -StateID -StateIDError -StateIDIter -WithStateIDIter -) -; -/ -/ -/ -A -utility -trait -that -defines -a -couple -of -adapters -for -making -it -convenient -/ -/ -/ -to -access -indices -as -" -small -index -" -types -. -We -require -ExactSizeIterator -so -/ -/ -/ -that -iterator -construction -can -do -a -single -check -to -make -sure -the -index -of -/ -/ -/ -each -element -is -representable -by -its -small -index -type -. -pub -( -crate -) -trait -IteratorIndexExt -: -Iterator -{ -fn -with_pattern_ids -( -self -) -- -> -WithPatternIDIter -< -Self -> -where -Self -: -Sized -+ -ExactSizeIterator -{ -WithPatternIDIter -: -: -new -( -self -) -} -fn -with_state_ids -( -self -) -- -> -WithStateIDIter -< -Self -> -where -Self -: -Sized -+ -ExactSizeIterator -{ -WithStateIDIter -: -: -new -( -self -) -} -} -impl -< -I -: -Iterator -> -IteratorIndexExt -for -I -{ -} diff --git a/third_party/rust/regex-automata/src/util/search.rs b/third_party/rust/regex-automata/src/util/search.rs deleted file mode 100644 index ae8df6e29456c..0000000000000 --- a/third_party/rust/regex-automata/src/util/search.rs +++ /dev/null @@ -1,18998 +0,0 @@ -/ -* -! -Types -and -routines -that -support -the -search -APIs -of -most -regex -engines -. -This -sub -- -module -isn -' -t -exposed -directly -but -rather -its -contents -are -exported -at -the -crate -root -due -to -the -universality -of -most -of -the -types -and -routines -in -this -module -. -* -/ -use -core -: -: -ops -: -: -{ -Range -RangeBounds -} -; -use -crate -: -: -util -: -: -{ -escape -: -: -DebugByte -primitives -: -: -PatternID -utf8 -} -; -/ -/ -/ -The -parameters -for -a -regex -search -including -the -haystack -to -search -. -/ -/ -/ -/ -/ -/ -It -turns -out -that -regex -searches -have -a -few -parameters -and -in -most -cases -/ -/ -/ -those -parameters -have -defaults -that -work -in -the -vast -majority -of -cases -. -/ -/ -/ -This -Input -type -exists -to -make -that -common -case -seamnless -while -also -/ -/ -/ -providing -an -avenue -for -changing -the -parameters -of -a -search -. -In -particular -/ -/ -/ -this -type -enables -doing -so -without -a -combinatorial -explosion -of -different -/ -/ -/ -methods -and -/ -or -superfluous -parameters -in -the -common -cases -. -/ -/ -/ -/ -/ -/ -An -Input -permits -configuring -the -following -things -: -/ -/ -/ -/ -/ -/ -* -Search -only -a -substring -of -a -haystack -while -taking -the -broader -context -/ -/ -/ -into -account -for -resolving -look -- -around -assertions -. -/ -/ -/ -* -Indicating -whether -to -search -for -all -patterns -in -a -regex -or -to -/ -/ -/ -only -search -for -one -pattern -in -particular -. -/ -/ -/ -* -Whether -to -perform -an -anchored -on -unanchored -search -. -/ -/ -/ -* -Whether -to -report -a -match -as -early -as -possible -. -/ -/ -/ -/ -/ -/ -All -of -these -parameters -except -for -the -haystack -have -sensible -default -/ -/ -/ -values -. -This -means -that -the -minimal -search -configuration -is -simply -a -call -/ -/ -/ -to -[ -Input -: -: -new -] -with -your -haystack -. -Setting -any -other -parameter -is -/ -/ -/ -optional -. -/ -/ -/ -/ -/ -/ -Moreover -for -any -H -that -implements -AsRef -< -[ -u8 -] -> -there -exists -a -/ -/ -/ -From -< -H -> -for -Input -implementation -. -This -is -useful -because -many -of -the -/ -/ -/ -search -APIs -in -this -crate -accept -an -Into -< -Input -> -. -This -means -you -can -/ -/ -/ -provide -string -or -byte -strings -to -these -routines -directly -and -they -' -ll -/ -/ -/ -automatically -get -converted -into -an -Input -for -you -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameter -' -h -refers -to -the -lifetime -of -the -haystack -. -/ -/ -/ -/ -/ -/ -# -Organization -/ -/ -/ -/ -/ -/ -The -API -of -Input -is -split -into -a -few -different -parts -: -/ -/ -/ -/ -/ -/ -* -A -builder -- -like -API -that -transforms -a -Input -by -value -. -Examples -: -/ -/ -/ -[ -Input -: -: -span -] -and -[ -Input -: -: -anchored -] -. -/ -/ -/ -* -A -setter -API -that -permits -mutating -parameters -in -place -. -Examples -: -/ -/ -/ -[ -Input -: -: -set_span -] -and -[ -Input -: -: -set_anchored -] -. -/ -/ -/ -* -A -getter -API -that -permits -retrieving -any -of -the -search -parameters -. -/ -/ -/ -Examples -: -[ -Input -: -: -get_span -] -and -[ -Input -: -: -get_anchored -] -. -/ -/ -/ -* -A -few -convenience -getter -routines -that -don -' -t -conform -to -the -above -naming -/ -/ -/ -pattern -due -to -how -common -they -are -. -Examples -: -[ -Input -: -: -haystack -] -/ -/ -/ -[ -Input -: -: -start -] -and -[ -Input -: -: -end -] -. -/ -/ -/ -* -Miscellaneous -predicates -and -other -helper -routines -that -are -useful -/ -/ -/ -in -some -contexts -. -Examples -: -[ -Input -: -: -is_char_boundary -] -. -/ -/ -/ -/ -/ -/ -A -Input -exposes -so -much -because -it -is -meant -to -be -used -by -both -callers -of -/ -/ -/ -regex -engines -_and_ -implementors -of -regex -engines -. -A -constraining -factor -is -/ -/ -/ -that -regex -engines -should -accept -a -& -Input -as -its -lowest -level -API -which -/ -/ -/ -means -that -implementors -should -only -use -the -" -getter -" -APIs -of -a -Input -. -/ -/ -/ -/ -/ -/ -# -Valid -bounds -and -search -termination -/ -/ -/ -/ -/ -/ -An -Input -permits -setting -the -bounds -of -a -search -via -either -/ -/ -/ -[ -Input -: -: -span -] -or -[ -Input -: -: -range -] -. -The -bounds -set -must -be -valid -or -/ -/ -/ -else -a -panic -will -occur -. -Bounds -are -valid -if -and -only -if -: -/ -/ -/ -/ -/ -/ -* -The -bounds -represent -a -valid -range -into -the -input -' -s -haystack -. -/ -/ -/ -* -* -* -or -* -* -the -end -bound -is -a -valid -ending -bound -for -the -haystack -* -and -* -/ -/ -/ -the -start -bound -is -exactly -one -greater -than -the -start -bound -. -/ -/ -/ -/ -/ -/ -In -the -latter -case -[ -Input -: -: -is_done -] -will -return -true -and -indicates -any -/ -/ -/ -search -receiving -such -an -input -should -immediately -return -with -no -match -. -/ -/ -/ -/ -/ -/ -Note -that -while -Input -is -used -for -reverse -searches -in -this -crate -the -/ -/ -/ -Input -: -: -is_done -predicate -assumes -a -forward -search -. -Because -unsigned -/ -/ -/ -offsets -are -used -internally -there -is -no -way -to -tell -from -only -the -offsets -/ -/ -/ -whether -a -reverse -search -is -done -or -not -. -/ -/ -/ -/ -/ -/ -# -Regex -engine -support -/ -/ -/ -/ -/ -/ -Any -regex -engine -accepting -an -Input -must -support -at -least -the -following -/ -/ -/ -things -: -/ -/ -/ -/ -/ -/ -* -Searching -a -& -[ -u8 -] -for -matches -. -/ -/ -/ -* -Searching -a -substring -of -& -[ -u8 -] -for -a -match -such -that -any -match -/ -/ -/ -reported -must -appear -entirely -within -that -substring -. -/ -/ -/ -* -For -a -forwards -search -a -match -should -never -be -reported -when -/ -/ -/ -[ -Input -: -: -is_done -] -returns -true -. -( -For -reverse -searches -termination -should -/ -/ -/ -be -handled -outside -of -Input -. -) -/ -/ -/ -/ -/ -/ -Supporting -other -aspects -of -an -Input -are -optional -but -regex -engines -/ -/ -/ -should -handle -aspects -they -don -' -t -support -gracefully -. -How -this -is -done -is -/ -/ -/ -generally -up -to -the -regex -engine -. -This -crate -generally -treats -unsupported -/ -/ -/ -anchored -modes -as -an -error -to -report -for -example -but -for -simplicity -in -/ -/ -/ -the -meta -regex -engine -trying -to -search -with -an -invalid -pattern -ID -just -/ -/ -/ -results -in -no -match -being -reported -. -# -[ -derive -( -Clone -) -] -pub -struct -Input -< -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -span -: -Span -anchored -: -Anchored -earliest -: -bool -} -impl -< -' -h -> -Input -< -' -h -> -{ -/ -/ -/ -Create -a -new -search -configuration -for -the -given -haystack -. -# -[ -inline -] -pub -fn -new -< -H -: -? -Sized -+ -AsRef -< -[ -u8 -] -> -> -( -haystack -: -& -' -h -H -) -- -> -Input -< -' -h -> -{ -Input -{ -haystack -: -haystack -. -as_ref -( -) -span -: -Span -{ -start -: -0 -end -: -haystack -. -as_ref -( -) -. -len -( -) -} -anchored -: -Anchored -: -: -No -earliest -: -false -} -} -/ -/ -/ -Set -the -span -for -this -search -. -/ -/ -/ -/ -/ -/ -This -routine -does -not -panic -if -the -span -given -is -not -a -valid -range -for -/ -/ -/ -this -search -' -s -haystack -. -If -this -search -is -run -with -an -invalid -range -/ -/ -/ -then -the -most -likely -outcome -is -that -the -actual -search -execution -will -/ -/ -/ -panic -. -/ -/ -/ -/ -/ -/ -This -routine -is -generic -over -how -a -span -is -provided -. -While -/ -/ -/ -a -[ -Span -] -may -be -given -directly -one -may -also -provide -a -/ -/ -/ -std -: -: -ops -: -: -Range -< -usize -> -. -To -provide -anything -supported -by -range -/ -/ -/ -syntax -use -the -[ -Input -: -: -range -] -method -. -/ -/ -/ -/ -/ -/ -The -default -span -is -the -entire -haystack -. -/ -/ -/ -/ -/ -/ -Note -that -[ -Input -: -: -range -] -overrides -this -method -and -vice -versa -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -given -span -does -not -correspond -to -valid -bounds -in -/ -/ -/ -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -the -span -of -the -search -can -impact -whether -a -/ -/ -/ -match -is -reported -or -not -. -This -is -particularly -relevant -for -look -- -around -/ -/ -/ -operators -which -might -take -things -outside -of -the -span -into -account -/ -/ -/ -when -determining -whether -they -match -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Look -for -' -at -' -but -as -a -distinct -word -. -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -\ -bat -\ -b -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Our -haystack -contains -' -at -' -but -not -as -a -distinct -word -. -/ -/ -/ -let -haystack -= -" -batter -" -; -/ -/ -/ -/ -/ -/ -/ -/ -A -standard -search -finds -nothing -as -expected -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -wanted -to -search -starting -at -position -' -1 -' -we -might -/ -/ -/ -/ -/ -slice -the -haystack -. -If -we -do -this -it -' -s -impossible -for -the -\ -b -/ -/ -/ -/ -/ -anchors -to -take -the -surrounding -context -into -account -! -And -thus -/ -/ -/ -/ -/ -a -match -is -produced -. -/ -/ -/ -let -input -= -Input -: -: -new -( -& -haystack -[ -1 -. -. -3 -] -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -2 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -specify -the -span -of -the -search -instead -of -slicing -the -/ -/ -/ -/ -/ -haystack -then -the -regex -engine -can -" -see -" -outside -of -the -span -/ -/ -/ -/ -/ -and -resolve -the -anchors -correctly -. -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -1 -. -. -3 -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -may -seem -a -little -ham -- -fisted -but -this -scenario -tends -to -come -up -/ -/ -/ -if -some -other -regex -engine -found -the -match -span -and -now -you -need -to -/ -/ -/ -re -- -process -that -span -to -look -for -capturing -groups -. -( -e -. -g -. -Run -a -faster -/ -/ -/ -DFA -first -find -a -match -then -run -the -PikeVM -on -just -the -match -span -to -/ -/ -/ -resolve -capturing -groups -. -) -In -order -to -implement -that -sort -of -logic -/ -/ -/ -correctly -you -need -to -set -the -span -on -the -search -instead -of -slicing -/ -/ -/ -the -haystack -directly -. -/ -/ -/ -/ -/ -/ -The -other -advantage -of -using -this -routine -to -specify -the -bounds -of -the -/ -/ -/ -search -is -that -the -match -offsets -are -still -reported -in -terms -of -the -/ -/ -/ -original -haystack -. -For -example -the -second -search -in -the -example -above -/ -/ -/ -reported -a -match -at -position -0 -even -though -at -starts -at -offset -/ -/ -/ -1 -because -we -sliced -the -haystack -. -# -[ -inline -] -pub -fn -span -< -S -: -Into -< -Span -> -> -( -mut -self -span -: -S -) -- -> -Input -< -' -h -> -{ -self -. -set_span -( -span -) -; -self -} -/ -/ -/ -Like -Input -: -: -span -but -accepts -any -range -instead -. -/ -/ -/ -/ -/ -/ -This -routine -does -not -panic -if -the -range -given -is -not -a -valid -range -for -/ -/ -/ -this -search -' -s -haystack -. -If -this -search -is -run -with -an -invalid -range -/ -/ -/ -then -the -most -likely -outcome -is -that -the -actual -search -execution -will -/ -/ -/ -panic -. -/ -/ -/ -/ -/ -/ -The -default -range -is -the -entire -haystack -. -/ -/ -/ -/ -/ -/ -Note -that -[ -Input -: -: -span -] -overrides -this -method -and -vice -versa -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -will -panic -if -the -given -range -could -not -be -converted -/ -/ -/ -to -a -valid -[ -Range -] -. -For -example -this -would -panic -when -given -/ -/ -/ -0 -. -. -= -usize -: -: -MAX -since -it -cannot -be -represented -using -a -half -- -open -/ -/ -/ -interval -in -terms -of -usize -. -/ -/ -/ -/ -/ -/ -This -also -panics -if -the -given -range -does -not -correspond -to -valid -bounds -/ -/ -/ -in -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -. -range -( -2 -. -. -= -4 -) -; -/ -/ -/ -assert_eq -! -( -2 -. -. -5 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -range -< -R -: -RangeBounds -< -usize -> -> -( -mut -self -range -: -R -) -- -> -Input -< -' -h -> -{ -self -. -set_range -( -range -) -; -self -} -/ -/ -/ -Sets -the -anchor -mode -of -a -search -. -/ -/ -/ -/ -/ -/ -When -a -search -is -anchored -( -so -that -' -s -[ -Anchored -: -: -Yes -] -or -/ -/ -/ -[ -Anchored -: -: -Pattern -] -) -a -match -must -begin -at -the -start -of -a -search -. -/ -/ -/ -When -a -search -is -not -anchored -( -that -' -s -[ -Anchored -: -: -No -] -) -regex -engines -/ -/ -/ -will -behave -as -if -the -pattern -started -with -a -( -? -s -- -u -: -. -) -* -? -. -This -prefix -/ -/ -/ -permits -a -match -to -appear -anywhere -. -/ -/ -/ -/ -/ -/ -By -default -the -anchored -mode -is -[ -Anchored -: -: -No -] -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -this -is -subtly -different -than -using -a -^ -at -the -start -of -/ -/ -/ -your -regex -. -A -^ -forces -a -regex -to -match -exclusively -at -the -start -of -/ -/ -/ -a -haystack -regardless -of -where -you -begin -your -search -. -In -contrast -/ -/ -/ -anchoring -a -search -will -allow -your -regex -to -match -anywhere -in -your -/ -/ -/ -haystack -but -the -match -must -start -at -the -beginning -of -a -search -. -/ -/ -/ -/ -/ -/ -For -example -consider -the -haystack -aba -and -the -following -searches -: -/ -/ -/ -/ -/ -/ -1 -. -The -regex -^ -a -is -compiled -with -Anchored -: -: -No -and -searches -aba -/ -/ -/ -starting -at -position -2 -. -Since -^ -requires -the -match -to -start -at -/ -/ -/ -the -beginning -of -the -haystack -and -2 -> -0 -no -match -is -found -. -/ -/ -/ -2 -. -The -regex -a -is -compiled -with -Anchored -: -: -Yes -and -searches -aba -/ -/ -/ -starting -at -position -2 -. -This -reports -a -match -at -[ -2 -3 -] -since -/ -/ -/ -the -match -starts -where -the -search -started -. -Since -there -is -no -^ -/ -/ -/ -there -is -no -requirement -for -the -match -to -start -at -the -beginning -of -/ -/ -/ -the -haystack -. -/ -/ -/ -3 -. -The -regex -a -is -compiled -with -Anchored -: -: -Yes -and -searches -aba -/ -/ -/ -starting -at -position -1 -. -Since -b -corresponds -to -position -1 -and -/ -/ -/ -since -the -search -is -anchored -it -finds -no -match -. -While -the -regex -/ -/ -/ -matches -at -other -positions -configuring -the -search -to -be -anchored -/ -/ -/ -requires -that -it -only -report -a -match -that -begins -at -the -same -offset -/ -/ -/ -as -the -beginning -of -the -search -. -/ -/ -/ -4 -. -The -regex -a -is -compiled -with -Anchored -: -: -No -and -searches -aba -/ -/ -/ -starting -at -position -1 -. -Since -the -search -is -not -anchored -and -/ -/ -/ -the -regex -does -not -start -with -^ -the -search -executes -as -if -there -/ -/ -/ -is -a -( -? -s -: -. -) -* -? -prefix -that -permits -it -to -match -anywhere -. -Thus -it -/ -/ -/ -reports -a -match -at -[ -2 -3 -] -. -/ -/ -/ -/ -/ -/ -Note -that -the -[ -Anchored -: -: -Pattern -] -mode -is -like -Anchored -: -: -Yes -/ -/ -/ -except -it -only -reports -matches -for -a -particular -pattern -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -demonstrates -the -differences -between -an -anchored -search -and -/ -/ -/ -a -pattern -that -begins -with -^ -( -as -described -in -the -above -warning -/ -/ -/ -message -) -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -Anchored -Match -Input -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -haystack -= -" -aba -" -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -^ -a -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -2 -. -. -3 -) -. -anchored -( -Anchored -: -: -No -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -/ -/ -No -match -is -found -because -2 -is -not -the -beginning -of -the -haystack -/ -/ -/ -/ -/ -which -is -what -^ -requires -. -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -a -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -2 -. -. -3 -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -/ -/ -An -anchored -search -can -still -match -anywhere -in -the -haystack -it -just -/ -/ -/ -/ -/ -must -begin -at -the -start -of -the -search -which -is -' -2 -' -in -this -case -. -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -3 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -a -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -1 -. -. -3 -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -/ -/ -No -match -is -found -since -we -start -searching -at -offset -1 -which -/ -/ -/ -/ -/ -corresponds -to -' -b -' -. -Since -there -is -no -' -( -? -s -: -. -) -* -? -' -prefix -no -match -/ -/ -/ -/ -/ -is -found -. -/ -/ -/ -assert_eq -! -( -None -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -a -" -) -? -; -/ -/ -/ -let -( -mut -cache -mut -caps -) -= -( -re -. -create_cache -( -) -re -. -create_captures -( -) -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -1 -. -. -3 -) -. -anchored -( -Anchored -: -: -No -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -/ -/ -Since -anchored -= -no -an -implicit -' -( -? -s -: -. -) -* -? -' -prefix -was -added -to -the -/ -/ -/ -/ -/ -pattern -. -Even -though -the -search -starts -at -' -b -' -the -' -match -anything -' -/ -/ -/ -/ -/ -prefix -allows -the -search -to -match -' -a -' -. -/ -/ -/ -let -expected -= -Some -( -Match -: -: -must -( -0 -2 -. -. -3 -) -) -; -/ -/ -/ -assert_eq -! -( -expected -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -anchored -( -mut -self -mode -: -Anchored -) -- -> -Input -< -' -h -> -{ -self -. -set_anchored -( -mode -) -; -self -} -/ -/ -/ -Whether -to -execute -an -" -earliest -" -search -or -not -. -/ -/ -/ -/ -/ -/ -When -running -a -non -- -overlapping -search -an -" -earliest -" -search -will -return -/ -/ -/ -the -match -location -as -early -as -possible -. -For -example -given -a -pattern -/ -/ -/ -of -foo -[ -0 -- -9 -] -+ -and -a -haystack -of -foo12345 -a -normal -leftmost -search -/ -/ -/ -will -return -foo12345 -as -a -match -. -But -an -" -earliest -" -search -for -regex -/ -/ -/ -engines -that -support -" -earliest -" -semantics -will -return -foo1 -as -a -/ -/ -/ -match -since -as -soon -as -the -first -digit -following -foo -is -seen -it -is -/ -/ -/ -known -to -have -found -a -match -. -/ -/ -/ -/ -/ -/ -Note -that -" -earliest -" -semantics -generally -depend -on -the -regex -engine -. -/ -/ -/ -Different -regex -engines -may -determine -there -is -a -match -at -different -/ -/ -/ -points -. -So -there -is -no -guarantee -that -" -earliest -" -matches -will -always -/ -/ -/ -return -the -same -offsets -for -all -regex -engines -. -The -" -earliest -" -notion -/ -/ -/ -is -really -about -when -the -particular -regex -engine -determines -there -is -/ -/ -/ -a -match -rather -than -a -consistent -semantic -unto -itself -. -This -is -often -/ -/ -/ -useful -for -implementing -" -did -a -match -occur -or -not -" -predicates -but -/ -/ -/ -sometimes -the -offset -is -useful -as -well -. -/ -/ -/ -/ -/ -/ -This -is -disabled -by -default -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -difference -between -" -earliest -" -searching -and -/ -/ -/ -normal -searching -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -Match -Input -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new -( -r -" -foo -[ -0 -- -9 -] -+ -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -caps -= -re -. -create_captures -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -A -normal -search -implements -greediness -like -you -expect -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo12345 -" -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -8 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -When -' -earliest -' -is -enabled -and -the -regex -engine -supports -/ -/ -/ -/ -/ -it -the -search -will -bail -once -it -knows -a -match -has -been -/ -/ -/ -/ -/ -found -. -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foo12345 -" -) -. -earliest -( -true -) -; -/ -/ -/ -re -. -search -( -& -mut -cache -& -input -& -mut -caps -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -4 -) -) -caps -. -get_match -( -) -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -earliest -( -mut -self -yes -: -bool -) -- -> -Input -< -' -h -> -{ -self -. -set_earliest -( -yes -) -; -self -} -/ -/ -/ -Set -the -span -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -This -is -like -the -[ -Input -: -: -span -] -method -except -this -mutates -the -/ -/ -/ -span -in -place -. -/ -/ -/ -/ -/ -/ -This -routine -is -generic -over -how -a -span -is -provided -. -While -/ -/ -/ -a -[ -Span -] -may -be -given -directly -one -may -also -provide -a -/ -/ -/ -std -: -: -ops -: -: -Range -< -usize -> -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -given -span -does -not -correspond -to -valid -bounds -in -/ -/ -/ -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -input -. -set_span -( -2 -. -. -4 -) -; -/ -/ -/ -assert_eq -! -( -2 -. -. -4 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_span -< -S -: -Into -< -Span -> -> -( -& -mut -self -span -: -S -) -{ -let -span -= -span -. -into -( -) -; -assert -! -( -span -. -end -< -= -self -. -haystack -. -len -( -) -& -& -span -. -start -< -= -span -. -end -. -wrapping_add -( -1 -) -" -invalid -span -{ -: -? -} -for -haystack -of -length -{ -} -" -span -self -. -haystack -. -len -( -) -) -; -self -. -span -= -span -; -} -/ -/ -/ -Set -the -span -for -this -search -configuration -given -any -range -. -/ -/ -/ -/ -/ -/ -This -is -like -the -[ -Input -: -: -range -] -method -except -this -mutates -the -/ -/ -/ -span -in -place -. -/ -/ -/ -/ -/ -/ -This -routine -does -not -panic -if -the -range -given -is -not -a -valid -range -for -/ -/ -/ -this -search -' -s -haystack -. -If -this -search -is -run -with -an -invalid -range -/ -/ -/ -then -the -most -likely -outcome -is -that -the -actual -search -execution -will -/ -/ -/ -panic -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -will -panic -if -the -given -range -could -not -be -converted -/ -/ -/ -to -a -valid -[ -Range -] -. -For -example -this -would -panic -when -given -/ -/ -/ -0 -. -. -= -usize -: -: -MAX -since -it -cannot -be -represented -using -a -half -- -open -/ -/ -/ -interval -in -terms -of -usize -. -/ -/ -/ -/ -/ -/ -This -also -panics -if -the -given -span -does -not -correspond -to -valid -bounds -/ -/ -/ -in -the -haystack -or -the -termination -of -a -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -input -. -set_range -( -2 -. -. -= -4 -) -; -/ -/ -/ -assert_eq -! -( -2 -. -. -5 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_range -< -R -: -RangeBounds -< -usize -> -> -( -& -mut -self -range -: -R -) -{ -use -core -: -: -ops -: -: -Bound -; -/ -/ -It -' -s -a -little -weird -to -convert -ranges -into -spans -and -then -spans -/ -/ -back -into -ranges -when -we -actually -slice -the -haystack -. -Because -/ -/ -of -that -process -we -always -represent -everything -as -a -half -- -open -/ -/ -internal -. -Therefore -handling -things -like -m -. -. -= -n -is -a -little -awkward -. -let -start -= -match -range -. -start_bound -( -) -{ -Bound -: -: -Included -( -& -i -) -= -> -i -/ -/ -Can -this -case -ever -happen -? -Range -syntax -doesn -' -t -support -it -. -. -. -Bound -: -: -Excluded -( -& -i -) -= -> -i -. -checked_add -( -1 -) -. -unwrap -( -) -Bound -: -: -Unbounded -= -> -0 -} -; -let -end -= -match -range -. -end_bound -( -) -{ -Bound -: -: -Included -( -& -i -) -= -> -i -. -checked_add -( -1 -) -. -unwrap -( -) -Bound -: -: -Excluded -( -& -i -) -= -> -i -Bound -: -: -Unbounded -= -> -self -. -haystack -( -) -. -len -( -) -} -; -self -. -set_span -( -Span -{ -start -end -} -) -; -} -/ -/ -/ -Set -the -starting -offset -for -the -span -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -only -mutating -the -start -of -a -span -/ -/ -/ -without -having -to -set -the -entire -span -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -span -resulting -from -the -new -start -position -does -not -/ -/ -/ -correspond -to -valid -bounds -in -the -haystack -or -the -termination -of -a -/ -/ -/ -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -input -. -set_start -( -5 -) -; -/ -/ -/ -assert_eq -! -( -5 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_start -( -& -mut -self -start -: -usize -) -{ -self -. -set_span -( -Span -{ -start -. -. -self -. -get_span -( -) -} -) -; -} -/ -/ -/ -Set -the -ending -offset -for -the -span -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -only -mutating -the -end -of -a -span -/ -/ -/ -without -having -to -set -the -entire -span -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -span -resulting -from -the -new -end -position -does -not -/ -/ -/ -correspond -to -valid -bounds -in -the -haystack -or -the -termination -of -a -/ -/ -/ -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -input -. -set_end -( -5 -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -5 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_end -( -& -mut -self -end -: -usize -) -{ -self -. -set_span -( -Span -{ -end -. -. -self -. -get_span -( -) -} -) -; -} -/ -/ -/ -Set -the -anchor -mode -of -a -search -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Input -: -: -anchored -] -except -it -mutates -the -search -/ -/ -/ -configuration -in -place -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Anchored -Input -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -Anchored -: -: -No -input -. -get_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -let -pid -= -PatternID -: -: -must -( -5 -) -; -/ -/ -/ -input -. -set_anchored -( -Anchored -: -: -Pattern -( -pid -) -) -; -/ -/ -/ -assert_eq -! -( -Anchored -: -: -Pattern -( -pid -) -input -. -get_anchored -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_anchored -( -& -mut -self -mode -: -Anchored -) -{ -self -. -anchored -= -mode -; -} -/ -/ -/ -Set -whether -the -search -should -execute -in -" -earliest -" -mode -or -not -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Input -: -: -earliest -] -except -it -mutates -the -search -/ -/ -/ -configuration -in -place -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert -! -( -! -input -. -get_earliest -( -) -) -; -/ -/ -/ -input -. -set_earliest -( -true -) -; -/ -/ -/ -assert -! -( -input -. -get_earliest -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -set_earliest -( -& -mut -self -yes -: -bool -) -{ -self -. -earliest -= -yes -; -} -/ -/ -/ -Return -a -borrow -of -the -underlying -haystack -as -a -slice -of -bytes -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -b -" -foobar -" -input -. -haystack -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -haystack -( -& -self -) -- -> -& -[ -u8 -] -{ -self -. -haystack -} -/ -/ -/ -Return -the -start -position -of -this -search -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -search -. -get_span -( -) -. -start -( -) -. -/ -/ -/ -/ -/ -/ -When -[ -Input -: -: -is_done -] -is -false -this -is -guaranteed -to -return -/ -/ -/ -an -offset -that -is -less -than -or -equal -to -[ -Input -: -: -end -] -. -Otherwise -/ -/ -/ -the -offset -is -one -greater -than -[ -Input -: -: -end -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -input -. -start -( -) -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -. -span -( -2 -. -. -4 -) -; -/ -/ -/ -assert_eq -! -( -2 -input -. -start -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -start -( -& -self -) -- -> -usize -{ -self -. -get_span -( -) -. -start -} -/ -/ -/ -Return -the -end -position -of -this -search -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -search -. -get_span -( -) -. -end -( -) -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -return -an -offset -that -is -a -valid -exclusive -end -/ -/ -/ -bound -for -this -input -' -s -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -6 -input -. -end -( -) -) -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -. -span -( -2 -. -. -4 -) -; -/ -/ -/ -assert_eq -! -( -4 -input -. -end -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -end -( -& -self -) -- -> -usize -{ -self -. -get_span -( -) -. -end -} -/ -/ -/ -Return -the -span -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -If -one -was -not -explicitly -set -then -the -span -corresponds -to -the -entire -/ -/ -/ -range -of -the -haystack -. -/ -/ -/ -/ -/ -/ -When -[ -Input -: -: -is_done -] -is -false -the -span -returned -is -guaranteed -/ -/ -/ -to -correspond -to -valid -bounds -for -this -input -' -s -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Input -Span -} -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -Span -{ -start -: -0 -end -: -6 -} -input -. -get_span -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get_span -( -& -self -) -- -> -Span -{ -self -. -span -} -/ -/ -/ -Return -the -span -as -a -range -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -If -one -was -not -explicitly -set -then -the -span -corresponds -to -the -entire -/ -/ -/ -range -of -the -haystack -. -/ -/ -/ -/ -/ -/ -When -[ -Input -: -: -is_done -] -is -false -the -range -returned -is -guaranteed -/ -/ -/ -to -correspond -to -valid -bounds -for -this -input -' -s -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -6 -input -. -get_range -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get_range -( -& -self -) -- -> -Range -< -usize -> -{ -self -. -get_span -( -) -. -range -( -) -} -/ -/ -/ -Return -the -anchored -mode -for -this -search -configuration -. -/ -/ -/ -/ -/ -/ -If -no -anchored -mode -was -set -then -it -defaults -to -[ -Anchored -: -: -No -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Anchored -Input -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert_eq -! -( -Anchored -: -: -No -input -. -get_anchored -( -) -) -; -/ -/ -/ -/ -/ -/ -let -pid -= -PatternID -: -: -must -( -5 -) -; -/ -/ -/ -input -. -set_anchored -( -Anchored -: -: -Pattern -( -pid -) -) -; -/ -/ -/ -assert_eq -! -( -Anchored -: -: -Pattern -( -pid -) -input -. -get_anchored -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get_anchored -( -& -self -) -- -> -Anchored -{ -self -. -anchored -} -/ -/ -/ -Return -whether -this -search -should -execute -in -" -earliest -" -mode -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert -! -( -! -input -. -get_earliest -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get_earliest -( -& -self -) -- -> -bool -{ -self -. -earliest -} -/ -/ -/ -Return -true -if -and -only -if -this -search -can -never -return -any -other -/ -/ -/ -matches -. -/ -/ -/ -/ -/ -/ -This -occurs -when -the -start -position -of -this -search -is -greater -than -the -/ -/ -/ -end -position -of -the -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -mut -input -= -Input -: -: -new -( -" -foobar -" -) -; -/ -/ -/ -assert -! -( -! -input -. -is_done -( -) -) -; -/ -/ -/ -input -. -set_start -( -6 -) -; -/ -/ -/ -assert -! -( -! -input -. -is_done -( -) -) -; -/ -/ -/ -input -. -set_start -( -7 -) -; -/ -/ -/ -assert -! -( -input -. -is_done -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_done -( -& -self -) -- -> -bool -{ -self -. -get_span -( -) -. -start -> -self -. -get_span -( -) -. -end -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -offset -in -this -search -' -s -haystack -/ -/ -/ -falls -on -a -valid -UTF -- -8 -encoded -codepoint -boundary -. -/ -/ -/ -/ -/ -/ -If -the -haystack -is -not -valid -UTF -- -8 -then -the -behavior -of -this -routine -/ -/ -/ -is -unspecified -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -where -codepoint -boundaries -do -and -don -' -t -exist -in -valid -/ -/ -/ -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Input -; -/ -/ -/ -/ -/ -/ -let -input -= -Input -: -: -new -( -" -" -) -; -/ -/ -/ -assert -! -( -input -. -is_char_boundary -( -0 -) -) -; -/ -/ -/ -assert -! -( -! -input -. -is_char_boundary -( -1 -) -) -; -/ -/ -/ -assert -! -( -! -input -. -is_char_boundary -( -2 -) -) -; -/ -/ -/ -assert -! -( -input -. -is_char_boundary -( -3 -) -) -; -/ -/ -/ -assert -! -( -! -input -. -is_char_boundary -( -4 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_char_boundary -( -& -self -offset -: -usize -) -- -> -bool -{ -utf8 -: -: -is_boundary -( -self -. -haystack -( -) -offset -) -} -} -impl -< -' -h -> -core -: -: -fmt -: -: -Debug -for -Input -< -' -h -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -use -crate -: -: -util -: -: -escape -: -: -DebugHaystack -; -f -. -debug_struct -( -" -Input -" -) -. -field -( -" -haystack -" -& -DebugHaystack -( -self -. -haystack -( -) -) -) -. -field -( -" -span -" -& -self -. -span -) -. -field -( -" -anchored -" -& -self -. -anchored -) -. -field -( -" -earliest -" -& -self -. -earliest -) -. -finish -( -) -} -} -impl -< -' -h -H -: -? -Sized -+ -AsRef -< -[ -u8 -] -> -> -From -< -& -' -h -H -> -for -Input -< -' -h -> -{ -fn -from -( -haystack -: -& -' -h -H -) -- -> -Input -< -' -h -> -{ -Input -: -: -new -( -haystack -) -} -} -/ -/ -/ -A -representation -of -a -span -reported -by -a -regex -engine -. -/ -/ -/ -/ -/ -/ -A -span -corresponds -to -the -starting -and -ending -_byte -offsets_ -of -a -/ -/ -/ -contiguous -region -of -bytes -. -The -starting -offset -is -inclusive -while -the -/ -/ -/ -ending -offset -is -exclusive -. -That -is -a -span -is -a -half -- -open -interval -. -/ -/ -/ -/ -/ -/ -A -span -is -used -to -report -the -offsets -of -a -match -but -it -is -also -used -to -/ -/ -/ -convey -which -region -of -a -haystack -should -be -searched -via -routines -like -/ -/ -/ -[ -Input -: -: -span -] -. -/ -/ -/ -/ -/ -/ -This -is -basically -equivalent -to -a -std -: -: -ops -: -: -Range -< -usize -> -except -this -/ -/ -/ -type -implements -Copy -which -makes -it -more -ergonomic -to -use -in -the -context -/ -/ -/ -of -this -crate -. -Like -a -range -this -implements -Index -for -[ -u8 -] -and -str -/ -/ -/ -and -IndexMut -for -[ -u8 -] -. -For -convenience -this -also -impls -From -< -Range -> -/ -/ -/ -which -means -things -like -Span -: -: -from -( -5 -. -. -10 -) -work -. -# -[ -derive -( -Clone -Copy -Eq -Hash -PartialEq -) -] -pub -struct -Span -{ -/ -/ -/ -The -start -offset -of -the -span -inclusive -. -pub -start -: -usize -/ -/ -/ -The -end -offset -of -the -span -exclusive -. -pub -end -: -usize -} -impl -Span -{ -/ -/ -/ -Returns -this -span -as -a -range -. -# -[ -inline -] -pub -fn -range -( -& -self -) -- -> -Range -< -usize -> -{ -Range -: -: -from -( -* -self -) -} -/ -/ -/ -Returns -true -when -this -span -is -empty -. -That -is -when -start -> -= -end -. -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -start -> -= -self -. -end -} -/ -/ -/ -Returns -the -length -of -this -span -. -/ -/ -/ -/ -/ -/ -This -returns -0 -in -precisely -the -cases -that -is_empty -returns -true -. -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -end -. -saturating_sub -( -self -. -start -) -} -/ -/ -/ -Returns -true -when -the -given -offset -is -contained -within -this -span -. -/ -/ -/ -/ -/ -/ -Note -that -an -empty -span -contains -no -offsets -and -will -always -return -/ -/ -/ -false -. -# -[ -inline -] -pub -fn -contains -( -& -self -offset -: -usize -) -- -> -bool -{ -! -self -. -is_empty -( -) -& -& -self -. -start -< -= -offset -& -& -offset -< -= -self -. -end -} -/ -/ -/ -Returns -a -new -span -with -offset -added -to -this -span -' -s -start -and -end -/ -/ -/ -values -. -# -[ -inline -] -pub -fn -offset -( -& -self -offset -: -usize -) -- -> -Span -{ -Span -{ -start -: -self -. -start -+ -offset -end -: -self -. -end -+ -offset -} -} -} -impl -core -: -: -fmt -: -: -Debug -for -Span -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -} -. -. -{ -} -" -self -. -start -self -. -end -) -} -} -impl -core -: -: -ops -: -: -Index -< -Span -> -for -[ -u8 -] -{ -type -Output -= -[ -u8 -] -; -# -[ -inline -] -fn -index -( -& -self -index -: -Span -) -- -> -& -[ -u8 -] -{ -& -self -[ -index -. -range -( -) -] -} -} -impl -core -: -: -ops -: -: -IndexMut -< -Span -> -for -[ -u8 -] -{ -# -[ -inline -] -fn -index_mut -( -& -mut -self -index -: -Span -) -- -> -& -mut -[ -u8 -] -{ -& -mut -self -[ -index -. -range -( -) -] -} -} -impl -core -: -: -ops -: -: -Index -< -Span -> -for -str -{ -type -Output -= -str -; -# -[ -inline -] -fn -index -( -& -self -index -: -Span -) -- -> -& -str -{ -& -self -[ -index -. -range -( -) -] -} -} -impl -From -< -Range -< -usize -> -> -for -Span -{ -# -[ -inline -] -fn -from -( -range -: -Range -< -usize -> -) -- -> -Span -{ -Span -{ -start -: -range -. -start -end -: -range -. -end -} -} -} -impl -From -< -Span -> -for -Range -< -usize -> -{ -# -[ -inline -] -fn -from -( -span -: -Span -) -- -> -Range -< -usize -> -{ -Range -{ -start -: -span -. -start -end -: -span -. -end -} -} -} -impl -PartialEq -< -Range -< -usize -> -> -for -Span -{ -# -[ -inline -] -fn -eq -( -& -self -range -: -& -Range -< -usize -> -) -- -> -bool -{ -self -. -start -= -= -range -. -start -& -& -self -. -end -= -= -range -. -end -} -} -impl -PartialEq -< -Span -> -for -Range -< -usize -> -{ -# -[ -inline -] -fn -eq -( -& -self -span -: -& -Span -) -- -> -bool -{ -self -. -start -= -= -span -. -start -& -& -self -. -end -= -= -span -. -end -} -} -/ -/ -/ -A -representation -of -" -half -" -of -a -match -reported -by -a -DFA -. -/ -/ -/ -/ -/ -/ -This -is -called -a -" -half -" -match -because -it -only -includes -the -end -location -( -or -/ -/ -/ -start -location -for -a -reverse -search -) -of -a -match -. -This -corresponds -to -the -/ -/ -/ -information -that -a -single -DFA -scan -can -report -. -Getting -the -other -half -of -/ -/ -/ -the -match -requires -a -second -scan -with -a -reversed -DFA -. -/ -/ -/ -/ -/ -/ -A -half -match -also -includes -the -pattern -that -matched -. -The -pattern -is -/ -/ -/ -identified -by -an -ID -which -corresponds -to -its -position -( -starting -from -0 -) -/ -/ -/ -relative -to -other -patterns -used -to -construct -the -corresponding -DFA -. -If -only -/ -/ -/ -a -single -pattern -is -provided -to -the -DFA -then -all -matches -are -guaranteed -to -/ -/ -/ -have -a -pattern -ID -of -0 -. -# -[ -derive -( -Clone -Copy -Debug -Eq -Hash -PartialEq -) -] -pub -struct -HalfMatch -{ -/ -/ -/ -The -pattern -ID -. -pattern -: -PatternID -/ -/ -/ -The -offset -of -the -match -. -/ -/ -/ -/ -/ -/ -For -forward -searches -the -offset -is -exclusive -. -For -reverse -searches -/ -/ -/ -the -offset -is -inclusive -. -offset -: -usize -} -impl -HalfMatch -{ -/ -/ -/ -Create -a -new -half -match -from -a -pattern -ID -and -a -byte -offset -. -# -[ -inline -] -pub -fn -new -( -pattern -: -PatternID -offset -: -usize -) -- -> -HalfMatch -{ -HalfMatch -{ -pattern -offset -} -} -/ -/ -/ -Create -a -new -half -match -from -a -pattern -ID -and -a -byte -offset -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -HalfMatch -: -: -new -] -but -accepts -a -usize -instead -of -a -/ -/ -/ -[ -PatternID -] -. -This -panics -if -the -given -usize -is -not -representable -/ -/ -/ -as -a -PatternID -. -# -[ -inline -] -pub -fn -must -( -pattern -: -usize -offset -: -usize -) -- -> -HalfMatch -{ -HalfMatch -: -: -new -( -PatternID -: -: -new -( -pattern -) -. -unwrap -( -) -offset -) -} -/ -/ -/ -Returns -the -ID -of -the -pattern -that -matched -. -/ -/ -/ -/ -/ -/ -The -ID -of -a -pattern -is -derived -from -the -position -in -which -it -was -/ -/ -/ -originally -inserted -into -the -corresponding -DFA -. -The -first -pattern -has -/ -/ -/ -identifier -0 -and -each -subsequent -pattern -is -1 -2 -and -so -on -. -# -[ -inline -] -pub -fn -pattern -( -& -self -) -- -> -PatternID -{ -self -. -pattern -} -/ -/ -/ -The -position -of -the -match -. -/ -/ -/ -/ -/ -/ -If -this -match -was -produced -by -a -forward -search -then -the -offset -is -/ -/ -/ -exclusive -. -If -this -match -was -produced -by -a -reverse -search -then -the -/ -/ -/ -offset -is -inclusive -. -# -[ -inline -] -pub -fn -offset -( -& -self -) -- -> -usize -{ -self -. -offset -} -} -/ -/ -/ -A -representation -of -a -match -reported -by -a -regex -engine -. -/ -/ -/ -/ -/ -/ -A -match -has -two -essential -pieces -of -information -: -the -[ -PatternID -] -that -/ -/ -/ -matches -and -the -[ -Span -] -of -the -match -in -a -haystack -. -/ -/ -/ -/ -/ -/ -The -pattern -is -identified -by -an -ID -which -corresponds -to -its -position -/ -/ -/ -( -starting -from -0 -) -relative -to -other -patterns -used -to -construct -the -/ -/ -/ -corresponding -regex -engine -. -If -only -a -single -pattern -is -provided -then -all -/ -/ -/ -matches -are -guaranteed -to -have -a -pattern -ID -of -0 -. -/ -/ -/ -/ -/ -/ -Every -match -reported -by -a -regex -engine -guarantees -that -its -span -has -its -/ -/ -/ -start -offset -as -less -than -or -equal -to -its -end -offset -. -# -[ -derive -( -Clone -Copy -Debug -Eq -Hash -PartialEq -) -] -pub -struct -Match -{ -/ -/ -/ -The -pattern -ID -. -pattern -: -PatternID -/ -/ -/ -The -underlying -match -span -. -span -: -Span -} -impl -Match -{ -/ -/ -/ -Create -a -new -match -from -a -pattern -ID -and -a -span -. -/ -/ -/ -/ -/ -/ -This -constructor -is -generic -over -how -a -span -is -provided -. -While -/ -/ -/ -a -[ -Span -] -may -be -given -directly -one -may -also -provide -a -/ -/ -/ -std -: -: -ops -: -: -Range -< -usize -> -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -end -< -start -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -create -a -match -for -the -first -pattern -in -a -regex -/ -/ -/ -object -using -convenient -range -syntax -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Match -PatternID -} -; -/ -/ -/ -/ -/ -/ -let -m -= -Match -: -: -new -( -PatternID -: -: -ZERO -5 -. -. -10 -) -; -/ -/ -/ -assert_eq -! -( -0 -m -. -pattern -( -) -. -as_usize -( -) -) -; -/ -/ -/ -assert_eq -! -( -5 -m -. -start -( -) -) -; -/ -/ -/ -assert_eq -! -( -10 -m -. -end -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -new -< -S -: -Into -< -Span -> -> -( -pattern -: -PatternID -span -: -S -) -- -> -Match -{ -let -span -: -Span -= -span -. -into -( -) -; -assert -! -( -span -. -start -< -= -span -. -end -" -invalid -match -span -" -) -; -Match -{ -pattern -span -} -} -/ -/ -/ -Create -a -new -match -from -a -pattern -ID -and -a -byte -offset -span -. -/ -/ -/ -/ -/ -/ -This -constructor -is -generic -over -how -a -span -is -provided -. -While -/ -/ -/ -a -[ -Span -] -may -be -given -directly -one -may -also -provide -a -/ -/ -/ -std -: -: -ops -: -: -Range -< -usize -> -. -/ -/ -/ -/ -/ -/ -This -is -like -[ -Match -: -: -new -] -but -accepts -a -usize -instead -of -a -/ -/ -/ -[ -PatternID -] -. -This -panics -if -the -given -usize -is -not -representable -/ -/ -/ -as -a -PatternID -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -end -< -start -or -if -pattern -> -PatternID -: -: -MAX -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -create -a -match -for -the -third -pattern -in -a -regex -/ -/ -/ -object -using -convenient -range -syntax -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -Match -; -/ -/ -/ -/ -/ -/ -let -m -= -Match -: -: -must -( -3 -5 -. -. -10 -) -; -/ -/ -/ -assert_eq -! -( -3 -m -. -pattern -( -) -. -as_usize -( -) -) -; -/ -/ -/ -assert_eq -! -( -5 -m -. -start -( -) -) -; -/ -/ -/ -assert_eq -! -( -10 -m -. -end -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -must -< -S -: -Into -< -Span -> -> -( -pattern -: -usize -span -: -S -) -- -> -Match -{ -Match -: -: -new -( -PatternID -: -: -must -( -pattern -) -span -) -} -/ -/ -/ -Returns -the -ID -of -the -pattern -that -matched -. -/ -/ -/ -/ -/ -/ -The -ID -of -a -pattern -is -derived -from -the -position -in -which -it -was -/ -/ -/ -originally -inserted -into -the -corresponding -regex -engine -. -The -first -/ -/ -/ -pattern -has -identifier -0 -and -each -subsequent -pattern -is -1 -2 -and -/ -/ -/ -so -on -. -# -[ -inline -] -pub -fn -pattern -( -& -self -) -- -> -PatternID -{ -self -. -pattern -} -/ -/ -/ -The -starting -position -of -the -match -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -Match -: -: -span -( -) -. -start -. -# -[ -inline -] -pub -fn -start -( -& -self -) -- -> -usize -{ -self -. -span -( -) -. -start -} -/ -/ -/ -The -ending -position -of -the -match -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -Match -: -: -span -( -) -. -end -. -# -[ -inline -] -pub -fn -end -( -& -self -) -- -> -usize -{ -self -. -span -( -) -. -end -} -/ -/ -/ -Returns -the -match -span -as -a -range -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -Match -: -: -span -( -) -. -range -( -) -. -# -[ -inline -] -pub -fn -range -( -& -self -) -- -> -core -: -: -ops -: -: -Range -< -usize -> -{ -self -. -span -( -) -. -range -( -) -} -/ -/ -/ -Returns -the -span -for -this -match -. -# -[ -inline -] -pub -fn -span -( -& -self -) -- -> -Span -{ -self -. -span -} -/ -/ -/ -Returns -true -when -the -span -in -this -match -is -empty -. -/ -/ -/ -/ -/ -/ -An -empty -match -can -only -be -returned -when -the -regex -itself -can -match -/ -/ -/ -the -empty -string -. -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -span -( -) -. -is_empty -( -) -} -/ -/ -/ -Returns -the -length -of -this -match -. -/ -/ -/ -/ -/ -/ -This -returns -0 -in -precisely -the -cases -that -is_empty -returns -true -. -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -span -( -) -. -len -( -) -} -} -/ -/ -/ -A -set -of -PatternID -s -. -/ -/ -/ -/ -/ -/ -A -set -of -pattern -identifiers -is -useful -for -recording -which -patterns -have -/ -/ -/ -matched -a -particular -haystack -. -A -pattern -set -_only_ -includes -pattern -/ -/ -/ -identifiers -. -It -does -not -include -offset -information -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -basic -usage -of -a -set -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -PatternID -PatternSet -} -; -/ -/ -/ -/ -/ -/ -let -pid1 -= -PatternID -: -: -must -( -5 -) -; -/ -/ -/ -let -pid2 -= -PatternID -: -: -must -( -8 -) -; -/ -/ -/ -/ -/ -Create -a -new -empty -set -. -/ -/ -/ -let -mut -set -= -PatternSet -: -: -new -( -10 -) -; -/ -/ -/ -/ -/ -Insert -pattern -IDs -. -/ -/ -/ -set -. -insert -( -pid1 -) -; -/ -/ -/ -set -. -insert -( -pid2 -) -; -/ -/ -/ -/ -/ -Test -membership -. -/ -/ -/ -assert -! -( -set -. -contains -( -pid1 -) -) -; -/ -/ -/ -assert -! -( -set -. -contains -( -pid2 -) -) -; -/ -/ -/ -/ -/ -Get -all -members -. -/ -/ -/ -assert_eq -! -( -/ -/ -/ -vec -! -[ -5 -8 -] -/ -/ -/ -set -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -. -collect -: -: -< -Vec -< -usize -> -> -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -Clear -the -set -. -/ -/ -/ -set -. -clear -( -) -; -/ -/ -/ -/ -/ -Test -that -it -is -indeed -empty -. -/ -/ -/ -assert -! -( -set -. -is_empty -( -) -) -; -/ -/ -/ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -PatternSet -{ -/ -/ -/ -The -number -of -patterns -set -to -' -true -' -in -this -set -. -len -: -usize -/ -/ -/ -A -map -from -PatternID -to -boolean -of -whether -a -pattern -matches -or -not -. -/ -/ -/ -/ -/ -/ -This -should -probably -be -a -bitset -but -it -' -s -probably -unlikely -to -matter -/ -/ -/ -much -in -practice -. -/ -/ -/ -/ -/ -/ -The -main -downside -of -this -representation -( -and -similarly -for -a -bitset -) -/ -/ -/ -is -that -iteration -scales -with -the -capacity -of -the -set -instead -of -/ -/ -/ -the -length -of -the -set -. -This -doesn -' -t -seem -likely -to -be -a -problem -in -/ -/ -/ -practice -. -/ -/ -/ -/ -/ -/ -Another -alternative -is -to -just -use -a -' -SparseSet -' -for -this -. -It -does -use -/ -/ -/ -more -memory -( -quite -a -bit -more -) -but -that -seems -fine -I -think -compared -/ -/ -/ -to -the -memory -being -used -by -the -regex -engine -. -The -real -hiccup -with -/ -/ -/ -it -is -that -it -yields -pattern -IDs -in -the -order -they -were -inserted -. -/ -/ -/ -Which -is -actually -kind -of -nice -but -at -the -time -of -writing -pattern -/ -/ -/ -IDs -are -yielded -in -ascending -order -in -the -regex -crate -RegexSet -API -. -/ -/ -/ -If -we -did -change -to -' -SparseSet -' -we -could -provide -an -additional -/ -/ -/ -' -iter_match_order -' -iterator -but -keep -the -ascending -order -one -for -/ -/ -/ -compatibility -. -which -: -alloc -: -: -boxed -: -: -Box -< -[ -bool -] -> -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -PatternSet -{ -/ -/ -/ -Create -a -new -set -of -pattern -identifiers -with -the -given -capacity -. -/ -/ -/ -/ -/ -/ -The -given -capacity -typically -corresponds -to -( -at -least -) -the -number -of -/ -/ -/ -patterns -in -a -compiled -regex -object -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -given -capacity -exceeds -[ -PatternID -: -: -LIMIT -] -. -This -is -/ -/ -/ -impossible -if -you -use -the -pattern_len -( -) -method -as -defined -on -any -of -/ -/ -/ -the -regex -engines -in -this -crate -. -Namely -a -regex -will -fail -to -build -by -/ -/ -/ -returning -an -error -if -the -number -of -patterns -given -to -it -exceeds -the -/ -/ -/ -limit -. -Therefore -the -number -of -patterns -in -a -valid -regex -is -always -/ -/ -/ -a -correct -capacity -to -provide -here -. -pub -fn -new -( -capacity -: -usize -) -- -> -PatternSet -{ -assert -! -( -capacity -< -= -PatternID -: -: -LIMIT -" -pattern -set -capacity -exceeds -limit -of -{ -} -" -PatternID -: -: -LIMIT -) -; -PatternSet -{ -len -: -0 -which -: -alloc -: -: -vec -! -[ -false -; -capacity -] -. -into_boxed_slice -( -) -} -} -/ -/ -/ -Clear -this -set -such -that -it -contains -no -pattern -IDs -. -pub -fn -clear -( -& -mut -self -) -{ -self -. -len -= -0 -; -for -matched -in -self -. -which -. -iter_mut -( -) -{ -* -matched -= -false -; -} -} -/ -/ -/ -Return -true -if -and -only -if -the -given -pattern -identifier -is -in -this -set -. -pub -fn -contains -( -& -self -pid -: -PatternID -) -- -> -bool -{ -pid -. -as_usize -( -) -< -self -. -capacity -( -) -& -& -self -. -which -[ -pid -] -} -/ -/ -/ -Insert -the -given -pattern -identifier -into -this -set -and -return -true -if -/ -/ -/ -the -given -pattern -ID -was -not -previously -in -this -set -. -/ -/ -/ -/ -/ -/ -If -the -pattern -identifier -is -already -in -this -set -then -this -is -a -no -- -op -. -/ -/ -/ -/ -/ -/ -Use -[ -PatternSet -: -: -try_insert -] -for -a -fallible -version -of -this -routine -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -this -pattern -set -has -insufficient -capacity -to -/ -/ -/ -store -the -given -pattern -ID -. -pub -fn -insert -( -& -mut -self -pid -: -PatternID -) -- -> -bool -{ -self -. -try_insert -( -pid -) -. -expect -( -" -PatternSet -should -have -sufficient -capacity -" -) -} -/ -/ -/ -Insert -the -given -pattern -identifier -into -this -set -and -return -true -if -/ -/ -/ -the -given -pattern -ID -was -not -previously -in -this -set -. -/ -/ -/ -/ -/ -/ -If -the -pattern -identifier -is -already -in -this -set -then -this -is -a -no -- -op -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -This -returns -an -error -if -this -pattern -set -has -insufficient -capacity -to -/ -/ -/ -store -the -given -pattern -ID -. -pub -fn -try_insert -( -& -mut -self -pid -: -PatternID -) -- -> -Result -< -bool -PatternSetInsertError -> -{ -if -pid -. -as_usize -( -) -> -= -self -. -capacity -( -) -{ -return -Err -( -PatternSetInsertError -{ -attempted -: -pid -capacity -: -self -. -capacity -( -) -} -) -; -} -if -self -. -which -[ -pid -] -{ -return -Ok -( -false -) -; -} -self -. -len -+ -= -1 -; -self -. -which -[ -pid -] -= -true -; -Ok -( -true -) -} -/ -* -/ -/ -This -is -currently -commented -out -because -it -is -unused -and -it -is -unclear -/ -/ -whether -it -' -s -useful -or -not -. -What -' -s -the -harm -in -having -it -? -When -if -/ -/ -we -ever -wanted -to -change -our -representation -to -a -' -SparseSet -' -then -/ -/ -supporting -this -method -would -be -a -bit -tricky -. -So -in -order -to -keep -some -/ -/ -API -evolution -flexibility -we -leave -it -out -for -now -. -/ -/ -/ -Remove -the -given -pattern -identifier -from -this -set -. -/ -/ -/ -/ -/ -/ -If -the -pattern -identifier -was -not -previously -in -this -set -then -this -/ -/ -/ -does -not -change -the -set -and -returns -false -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -pid -exceeds -the -capacity -of -this -set -. -pub -fn -remove -( -& -mut -self -pid -: -PatternID -) -- -> -bool -{ -if -! -self -. -which -[ -pid -] -{ -return -false -; -} -self -. -len -- -= -1 -; -self -. -which -[ -pid -] -= -false -; -true -} -* -/ -/ -/ -/ -Return -true -if -and -only -if -this -set -has -no -pattern -identifiers -in -it -. -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -len -( -) -= -= -0 -} -/ -/ -/ -Return -true -if -and -only -if -this -set -has -the -maximum -number -of -pattern -/ -/ -/ -identifiers -in -the -set -. -This -occurs -precisely -when -PatternSet -: -: -len -( -) -/ -/ -/ -= -= -PatternSet -: -: -capacity -( -) -. -/ -/ -/ -/ -/ -/ -This -particular -property -is -useful -to -test -because -it -may -allow -one -to -/ -/ -/ -stop -a -search -earlier -than -you -might -otherwise -. -Namely -if -a -search -is -/ -/ -/ -only -reporting -which -patterns -match -a -haystack -and -if -you -know -all -of -/ -/ -/ -the -patterns -match -at -a -given -point -then -there -' -s -no -new -information -/ -/ -/ -that -can -be -learned -by -continuing -the -search -. -( -Because -a -pattern -set -/ -/ -/ -does -not -keep -track -of -offset -information -. -) -pub -fn -is_full -( -& -self -) -- -> -bool -{ -self -. -len -( -) -= -= -self -. -capacity -( -) -} -/ -/ -/ -Returns -the -total -number -of -pattern -identifiers -in -this -set -. -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -len -} -/ -/ -/ -Returns -the -total -number -of -pattern -identifiers -that -may -be -stored -/ -/ -/ -in -this -set -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -be -less -than -or -equal -to -[ -PatternID -: -: -LIMIT -] -. -/ -/ -/ -/ -/ -/ -Typically -the -capacity -of -a -pattern -set -matches -the -number -of -patterns -/ -/ -/ -in -a -regex -object -with -which -you -are -searching -. -pub -fn -capacity -( -& -self -) -- -> -usize -{ -self -. -which -. -len -( -) -} -/ -/ -/ -Returns -an -iterator -over -all -pattern -identifiers -in -this -set -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -pattern -identifiers -in -ascending -order -starting -/ -/ -/ -at -zero -. -pub -fn -iter -( -& -self -) -- -> -PatternSetIter -< -' -_ -> -{ -PatternSetIter -{ -it -: -self -. -which -. -iter -( -) -. -enumerate -( -) -} -} -} -/ -/ -/ -An -error -that -occurs -when -a -PatternID -failed -to -insert -into -a -/ -/ -/ -PatternSet -. -/ -/ -/ -/ -/ -/ -An -insert -fails -when -the -given -PatternID -exceeds -the -configured -capacity -/ -/ -/ -of -the -PatternSet -. -/ -/ -/ -/ -/ -/ -This -error -is -created -by -the -[ -PatternSet -: -: -try_insert -] -routine -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -# -[ -derive -( -Clone -Debug -) -] -pub -struct -PatternSetInsertError -{ -attempted -: -PatternID -capacity -: -usize -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -PatternSetInsertError -{ -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -core -: -: -fmt -: -: -Display -for -PatternSetInsertError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -failed -to -insert -pattern -ID -{ -} -into -pattern -set -\ -with -insufficiet -capacity -of -{ -} -" -self -. -attempted -. -as_usize -( -) -self -. -capacity -) -} -} -/ -/ -/ -An -iterator -over -all -pattern -identifiers -in -a -[ -PatternSet -] -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameter -' -a -refers -to -the -lifetime -of -the -pattern -set -being -/ -/ -/ -iterated -over -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -the -[ -PatternSet -: -: -iter -] -method -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -# -[ -derive -( -Clone -Debug -) -] -pub -struct -PatternSetIter -< -' -a -> -{ -it -: -core -: -: -iter -: -: -Enumerate -< -core -: -: -slice -: -: -Iter -< -' -a -bool -> -> -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -' -a -> -Iterator -for -PatternSetIter -< -' -a -> -{ -type -Item -= -PatternID -; -fn -next -( -& -mut -self -) -- -> -Option -< -PatternID -> -{ -while -let -Some -( -( -index -& -yes -) -) -= -self -. -it -. -next -( -) -{ -if -yes -{ -/ -/ -Only -valid -' -PatternID -' -values -can -be -inserted -into -the -set -/ -/ -and -construction -of -the -set -panics -if -the -capacity -would -/ -/ -permit -storing -invalid -pattern -IDs -. -Thus -' -yes -' -is -only -true -/ -/ -precisely -when -' -index -' -corresponds -to -a -valid -' -PatternID -' -. -return -Some -( -PatternID -: -: -new_unchecked -( -index -) -) -; -} -} -None -} -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -it -. -size_hint -( -) -} -} -# -[ -cfg -( -feature -= -" -alloc -" -) -] -impl -< -' -a -> -DoubleEndedIterator -for -PatternSetIter -< -' -a -> -{ -fn -next_back -( -& -mut -self -) -- -> -Option -< -PatternID -> -{ -while -let -Some -( -( -index -& -yes -) -) -= -self -. -it -. -next_back -( -) -{ -if -yes -{ -/ -/ -Only -valid -' -PatternID -' -values -can -be -inserted -into -the -set -/ -/ -and -construction -of -the -set -panics -if -the -capacity -would -/ -/ -permit -storing -invalid -pattern -IDs -. -Thus -' -yes -' -is -only -true -/ -/ -precisely -when -' -index -' -corresponds -to -a -valid -' -PatternID -' -. -return -Some -( -PatternID -: -: -new_unchecked -( -index -) -) -; -} -} -None -} -} -/ -/ -/ -The -type -of -anchored -search -to -perform -. -/ -/ -/ -/ -/ -/ -This -is -* -almost -* -a -boolean -option -. -That -is -you -can -either -do -an -unanchored -/ -/ -/ -search -for -any -pattern -in -a -regex -or -you -can -do -an -anchored -search -for -any -/ -/ -/ -pattern -in -a -regex -. -/ -/ -/ -/ -/ -/ -A -third -option -exists -that -assuming -the -regex -engine -supports -it -permits -/ -/ -/ -you -to -do -an -anchored -search -for -a -specific -pattern -. -/ -/ -/ -/ -/ -/ -Note -that -there -is -no -way -to -run -an -unanchored -search -for -a -specific -/ -/ -/ -pattern -. -If -you -need -that -you -' -ll -need -to -build -separate -regexes -for -each -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -If -a -regex -engine -does -not -support -the -anchored -mode -selected -then -the -/ -/ -/ -regex -engine -will -return -an -error -. -While -any -non -- -trivial -regex -engine -/ -/ -/ -should -support -at -least -one -of -the -available -anchored -modes -there -is -no -/ -/ -/ -singular -mode -that -is -guaranteed -to -be -universally -supported -. -Some -regex -/ -/ -/ -engines -might -only -support -unanchored -searches -( -DFAs -compiled -without -/ -/ -/ -anchored -starting -states -) -and -some -regex -engines -might -only -support -/ -/ -/ -anchored -searches -( -like -the -one -- -pass -DFA -) -. -/ -/ -/ -/ -/ -/ -The -specific -error -returned -is -a -[ -MatchError -] -with -a -/ -/ -/ -[ -MatchErrorKind -: -: -UnsupportedAnchored -] -kind -. -The -kind -includes -the -/ -/ -/ -Anchored -value -given -that -is -unsupported -. -/ -/ -/ -/ -/ -/ -Note -that -regex -engines -should -report -" -no -match -" -if -for -example -an -/ -/ -/ -Anchored -: -: -Pattern -is -provided -with -an -invalid -pattern -ID -_but_ -where -/ -/ -/ -anchored -searches -for -a -specific -pattern -are -supported -. -This -is -smooths -out -/ -/ -/ -behavior -such -that -it -' -s -possible -to -guarantee -that -an -error -never -occurs -/ -/ -/ -based -on -how -the -regex -engine -is -configured -. -All -regex -engines -in -this -/ -/ -/ -crate -report -" -no -match -" -when -searching -for -an -invalid -pattern -ID -but -where -/ -/ -/ -searching -for -a -valid -pattern -ID -is -otherwise -supported -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -the -various -Anchored -modes -to -run -a -/ -/ -/ -search -. -We -use -the -[ -PikeVM -] -( -crate -: -: -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -) -/ -/ -/ -because -it -supports -all -modes -unconditionally -. -Some -regex -engines -like -/ -/ -/ -the -[ -onepass -: -: -DFA -] -( -crate -: -: -dfa -: -: -onepass -: -: -DFA -) -cannot -support -unanchored -/ -/ -/ -searches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -if -cfg -! -( -miri -) -{ -return -Ok -( -( -) -) -; -} -/ -/ -miri -takes -too -long -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -Anchored -Input -Match -PatternID -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -Mrs -. -\ -w -+ -" -/ -/ -/ -r -" -Miss -\ -w -+ -" -/ -/ -/ -r -" -Mr -. -\ -w -+ -" -/ -/ -/ -r -" -Ms -. -\ -w -+ -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -hay -= -" -Hello -Mr -. -Springsteen -! -" -; -/ -/ -/ -/ -/ -/ -/ -/ -The -default -is -to -do -an -unanchored -search -. -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -6 -. -. -21 -) -) -re -. -find -( -& -mut -cache -hay -) -) -; -/ -/ -/ -/ -/ -Explicitly -ask -for -an -unanchored -search -. -Same -as -above -. -/ -/ -/ -let -input -= -Input -: -: -new -( -hay -) -. -anchored -( -Anchored -: -: -No -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -6 -. -. -21 -) -) -re -. -find -( -& -mut -cache -hay -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -try -an -anchored -search -. -Since -the -match -doesn -' -t -start -at -the -/ -/ -/ -/ -/ -beginning -of -the -haystack -no -match -is -found -! -/ -/ -/ -let -input -= -Input -: -: -new -( -hay -) -. -anchored -( -Anchored -: -: -Yes -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -& -mut -cache -input -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -We -can -try -an -anchored -search -again -but -move -the -location -of -where -/ -/ -/ -/ -/ -we -start -the -search -. -Note -that -the -offsets -reported -are -still -in -/ -/ -/ -/ -/ -terms -of -the -overall -haystack -and -not -relative -to -where -we -started -/ -/ -/ -/ -/ -the -search -. -/ -/ -/ -let -input -= -Input -: -: -new -( -hay -) -. -anchored -( -Anchored -: -: -Yes -) -. -range -( -6 -. -. -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -6 -. -. -21 -) -) -re -. -find -( -& -mut -cache -input -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -try -an -anchored -search -for -a -specific -pattern -. -We -specifically -/ -/ -/ -/ -/ -choose -a -pattern -that -we -know -doesn -' -t -match -to -prove -that -the -search -/ -/ -/ -/ -/ -only -looks -for -the -pattern -we -provide -. -/ -/ -/ -let -input -= -Input -: -: -new -( -hay -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -1 -) -) -) -/ -/ -/ -. -range -( -6 -. -. -) -; -/ -/ -/ -assert_eq -! -( -None -re -. -find -( -& -mut -cache -input -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -we -switch -it -to -the -pattern -that -we -know -matches -then -we -find -/ -/ -/ -/ -/ -the -match -. -/ -/ -/ -let -input -= -Input -: -: -new -( -hay -) -/ -/ -/ -. -anchored -( -Anchored -: -: -Pattern -( -PatternID -: -: -must -( -2 -) -) -) -/ -/ -/ -. -range -( -6 -. -. -) -; -/ -/ -/ -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -6 -. -. -21 -) -) -re -. -find -( -& -mut -cache -input -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -Anchored -{ -/ -/ -/ -Run -an -unanchored -search -. -This -means -a -match -may -occur -anywhere -at -or -/ -/ -/ -after -the -start -position -of -the -search -. -/ -/ -/ -/ -/ -/ -This -search -can -return -a -match -for -any -pattern -in -the -regex -. -No -/ -/ -/ -Run -an -anchored -search -. -This -means -that -a -match -must -begin -at -the -/ -/ -/ -start -position -of -the -search -. -/ -/ -/ -/ -/ -/ -This -search -can -return -a -match -for -any -pattern -in -the -regex -. -Yes -/ -/ -/ -Run -an -anchored -search -for -a -specific -pattern -. -This -means -that -a -match -/ -/ -/ -must -be -for -the -given -pattern -and -must -begin -at -the -start -position -of -/ -/ -/ -the -search -. -Pattern -( -PatternID -) -} -impl -Anchored -{ -/ -/ -/ -Returns -true -if -and -only -if -this -anchor -mode -corresponds -to -any -kind -of -/ -/ -/ -anchored -search -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -examples -shows -that -both -Anchored -: -: -Yes -and -Anchored -: -: -Pattern -/ -/ -/ -are -considered -anchored -searches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Anchored -PatternID -} -; -/ -/ -/ -/ -/ -/ -assert -! -( -! -Anchored -: -: -No -. -is_anchored -( -) -) -; -/ -/ -/ -assert -! -( -Anchored -: -: -Yes -. -is_anchored -( -) -) -; -/ -/ -/ -assert -! -( -Anchored -: -: -Pattern -( -PatternID -: -: -ZERO -) -. -is_anchored -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_anchored -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -Anchored -: -: -Yes -| -Anchored -: -: -Pattern -( -_ -) -) -} -/ -/ -/ -Returns -the -pattern -ID -associated -with -this -configuration -if -it -is -an -/ -/ -/ -anchored -search -for -a -specific -pattern -. -Otherwise -None -is -returned -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -Anchored -PatternID -} -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -None -Anchored -: -: -No -. -pattern -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -Anchored -: -: -Yes -. -pattern -( -) -) -; -/ -/ -/ -/ -/ -/ -let -pid -= -PatternID -: -: -must -( -5 -) -; -/ -/ -/ -assert_eq -! -( -Some -( -pid -) -Anchored -: -: -Pattern -( -pid -) -. -pattern -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -pattern -( -& -self -) -- -> -Option -< -PatternID -> -{ -match -* -self -{ -Anchored -: -: -Pattern -( -pid -) -= -> -Some -( -pid -) -_ -= -> -None -} -} -} -/ -/ -/ -The -kind -of -match -semantics -to -use -for -a -regex -pattern -. -/ -/ -/ -/ -/ -/ -The -default -match -kind -is -LeftmostFirst -and -this -corresponds -to -the -/ -/ -/ -match -semantics -used -by -most -backtracking -engines -such -as -Perl -. -/ -/ -/ -/ -/ -/ -# -Leftmost -first -or -" -preference -order -" -match -semantics -/ -/ -/ -/ -/ -/ -Leftmost -- -first -semantics -determine -which -match -to -report -when -there -are -/ -/ -/ -multiple -paths -through -a -regex -that -match -at -the -same -position -. -The -tie -is -/ -/ -/ -essentially -broken -by -how -a -backtracker -would -behave -. -For -example -consider -/ -/ -/ -running -the -regex -foofoofoo -| -foofoo -| -foo -on -the -haystack -foofoo -. -In -this -/ -/ -/ -case -both -the -foofoo -and -foo -branches -match -at -position -0 -. -So -should -/ -/ -/ -the -end -of -the -match -be -3 -or -6 -? -/ -/ -/ -/ -/ -/ -A -backtracker -will -conceptually -work -by -trying -foofoofoo -and -failing -. -/ -/ -/ -Then -it -will -try -foofoo -find -the -match -and -stop -there -. -Thus -the -/ -/ -/ -leftmost -- -first -match -position -is -6 -. -This -is -called -" -leftmost -- -first -" -or -/ -/ -/ -" -preference -order -" -because -the -order -of -the -branches -as -written -in -the -/ -/ -/ -regex -pattern -is -what -determines -how -to -break -the -tie -. -/ -/ -/ -/ -/ -/ -( -Note -that -leftmost -- -longest -match -semantics -which -break -ties -by -always -/ -/ -/ -taking -the -longest -matching -string -are -not -currently -supported -by -this -/ -/ -/ -crate -. -These -match -semantics -tend -to -be -found -in -POSIX -regex -engines -. -) -/ -/ -/ -/ -/ -/ -This -example -shows -how -leftmost -- -first -semantics -work -and -how -it -even -/ -/ -/ -applies -to -multi -- -pattern -regexes -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -new_many -( -& -[ -/ -/ -/ -r -" -foofoofoo -" -/ -/ -/ -r -" -foofoo -" -/ -/ -/ -r -" -foo -" -/ -/ -/ -] -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -got -: -Vec -< -Match -> -= -re -. -find_iter -( -& -mut -cache -" -foofoo -" -) -. -collect -( -) -; -/ -/ -/ -let -expected -= -vec -! -[ -Match -: -: -must -( -1 -0 -. -. -6 -) -] -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -All -matches -/ -/ -/ -/ -/ -/ -The -All -match -semantics -report -any -and -all -matches -and -generally -will -/ -/ -/ -attempt -to -match -as -much -as -possible -. -It -doesn -' -t -respect -any -sort -of -match -/ -/ -/ -priority -at -all -so -things -like -non -- -greedy -matching -don -' -t -work -in -this -/ -/ -/ -mode -. -/ -/ -/ -/ -/ -/ -The -fact -that -non -- -greedy -matching -doesn -' -t -work -generally -makes -most -forms -/ -/ -/ -of -unanchored -non -- -overlapping -searches -have -unintuitive -behavior -. -Namely -/ -/ -/ -unanchored -searches -behave -as -if -there -is -a -( -? -s -- -u -: -. -) -* -? -prefix -at -the -/ -/ -/ -beginning -of -the -pattern -which -is -specifically -non -- -greedy -. -Since -it -will -/ -/ -/ -be -treated -as -greedy -in -All -match -semantics -this -generally -means -that -/ -/ -/ -it -will -first -attempt -to -consume -all -of -the -haystack -and -is -likely -to -wind -/ -/ -/ -up -skipping -matches -. -/ -/ -/ -/ -/ -/ -Generally -speaking -All -should -only -be -used -in -two -circumstances -: -/ -/ -/ -/ -/ -/ -* -When -running -an -anchored -search -and -there -is -a -desire -to -match -as -much -as -/ -/ -/ -possible -. -For -example -when -building -a -reverse -regex -matcher -to -find -the -/ -/ -/ -start -of -a -match -after -finding -the -end -. -In -this -case -the -reverse -search -/ -/ -/ -is -anchored -to -the -end -of -the -match -found -by -the -forward -search -. -/ -/ -/ -* -When -running -overlapping -searches -. -Since -All -encodes -all -possible -/ -/ -/ -matches -this -is -generally -what -you -want -for -an -overlapping -search -. -If -you -/ -/ -/ -try -to -use -leftmost -- -first -in -an -overlapping -search -it -is -likely -to -produce -/ -/ -/ -counter -- -intuitive -results -since -leftmost -- -first -specifically -excludes -some -/ -/ -/ -matches -from -its -underlying -finite -state -machine -. -/ -/ -/ -/ -/ -/ -This -example -demonstrates -the -counter -- -intuitive -behavior -of -All -semantics -/ -/ -/ -when -using -a -standard -leftmost -unanchored -search -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -nfa -: -: -thompson -: -: -pikevm -: -: -PikeVM -/ -/ -/ -Match -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -PikeVM -: -: -builder -( -) -/ -/ -/ -. -configure -( -PikeVM -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build -( -" -foo -" -) -? -; -/ -/ -/ -let -hay -= -" -first -foo -second -foo -wat -" -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -got -: -Vec -< -Match -> -= -re -. -find_iter -( -& -mut -cache -hay -) -. -collect -( -) -; -/ -/ -/ -/ -/ -Notice -that -it -completely -skips -the -first -' -foo -' -! -/ -/ -/ -let -expected -= -vec -! -[ -Match -: -: -must -( -0 -17 -. -. -20 -) -] -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -second -example -shows -how -All -semantics -are -useful -for -an -overlapping -/ -/ -/ -search -. -Note -that -we -use -lower -level -lazy -DFA -APIs -here -since -the -NFA -/ -/ -/ -engines -only -currently -support -a -very -limited -form -of -overlapping -search -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_automata -: -: -{ -/ -/ -/ -hybrid -: -: -dfa -: -: -{ -DFA -OverlappingState -} -/ -/ -/ -HalfMatch -Input -MatchKind -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -re -= -DFA -: -: -builder -( -) -/ -/ -/ -/ -/ -If -we -didn -' -t -set -' -All -' -semantics -here -then -the -regex -would -only -/ -/ -/ -/ -/ -match -' -foo -' -at -offset -3 -and -nothing -else -. -Why -? -Because -the -state -/ -/ -/ -/ -/ -machine -implements -preference -order -and -knows -that -the -' -foofoo -' -and -/ -/ -/ -/ -/ -' -foofoofoo -' -branches -can -never -match -since -' -foo -' -will -always -match -/ -/ -/ -/ -/ -when -they -match -and -take -priority -. -/ -/ -/ -. -configure -( -DFA -: -: -config -( -) -. -match_kind -( -MatchKind -: -: -All -) -) -/ -/ -/ -. -build -( -r -" -foo -| -foofoo -| -foofoofoo -" -) -? -; -/ -/ -/ -let -mut -cache -= -re -. -create_cache -( -) -; -/ -/ -/ -let -mut -state -= -OverlappingState -: -: -start -( -) -; -/ -/ -/ -let -input -= -Input -: -: -new -( -" -foofoofoo -" -) -; -/ -/ -/ -let -mut -got -= -vec -! -[ -] -; -/ -/ -/ -loop -{ -/ -/ -/ -re -. -try_search_overlapping_fwd -( -& -mut -cache -& -input -& -mut -state -) -? -; -/ -/ -/ -let -m -= -match -state -. -get_match -( -) -{ -/ -/ -/ -None -= -> -break -/ -/ -/ -Some -( -m -) -= -> -m -/ -/ -/ -} -; -/ -/ -/ -got -. -push -( -m -) -; -/ -/ -/ -} -/ -/ -/ -let -expected -= -vec -! -[ -/ -/ -/ -HalfMatch -: -: -must -( -0 -3 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -6 -) -/ -/ -/ -HalfMatch -: -: -must -( -0 -9 -) -/ -/ -/ -] -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -non_exhaustive -] -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -MatchKind -{ -/ -/ -/ -Report -all -possible -matches -. -All -/ -/ -/ -Report -only -the -leftmost -matches -. -When -multiple -leftmost -matches -exist -/ -/ -/ -report -the -match -corresponding -to -the -part -of -the -regex -that -appears -/ -/ -/ -first -in -the -syntax -. -LeftmostFirst -/ -/ -There -is -prior -art -in -RE2 -that -shows -that -we -should -be -able -to -add -/ -/ -LeftmostLongest -too -. -The -tricky -part -of -it -is -supporting -ungreedy -/ -/ -repetitions -. -Instead -of -treating -all -NFA -states -as -having -equivalent -/ -/ -priority -( -as -in -' -All -' -) -or -treating -all -NFA -states -as -having -distinct -/ -/ -priority -based -on -order -( -as -in -' -LeftmostFirst -' -) -we -instead -group -NFA -/ -/ -states -into -sets -and -treat -members -of -each -set -as -having -equivalent -/ -/ -priority -but -having -greater -priority -than -all -following -members -/ -/ -of -different -sets -. -/ -/ -/ -/ -However -it -' -s -not -clear -whether -it -' -s -really -worth -adding -this -. -After -/ -/ -all -leftmost -- -longest -can -be -emulated -when -using -literals -by -using -/ -/ -leftmost -- -first -and -sorting -the -literals -by -length -in -descending -order -. -/ -/ -However -this -won -' -t -work -for -arbitrary -regexes -. -e -. -g -. -\ -w -| -\ -w -\ -w -will -/ -/ -always -match -a -in -ab -when -using -leftmost -- -first -but -leftmost -- -longest -/ -/ -would -match -ab -. -} -impl -MatchKind -{ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -( -crate -) -fn -continue_past_first_match -( -& -self -) -- -> -bool -{ -* -self -= -= -MatchKind -: -: -All -} -} -impl -Default -for -MatchKind -{ -fn -default -( -) -- -> -MatchKind -{ -MatchKind -: -: -LeftmostFirst -} -} -/ -/ -/ -An -error -indicating -that -a -search -stopped -before -reporting -whether -a -/ -/ -/ -match -exists -or -not -. -/ -/ -/ -/ -/ -/ -To -be -very -clear -this -error -type -implies -that -one -cannot -assume -that -no -/ -/ -/ -matches -occur -since -the -search -stopped -before -completing -. -That -is -if -/ -/ -/ -you -' -re -looking -for -information -about -where -a -search -determined -that -no -/ -/ -/ -match -can -occur -then -this -error -type -does -* -not -* -give -you -that -. -( -Indeed -at -/ -/ -/ -the -time -of -writing -if -you -need -such -a -thing -you -have -to -write -your -own -/ -/ -/ -search -routine -. -) -/ -/ -/ -/ -/ -/ -Normally -when -one -searches -for -something -the -response -is -either -an -/ -/ -/ -affirmative -" -it -was -found -at -this -location -" -or -a -negative -" -not -found -at -/ -/ -/ -all -. -" -However -in -some -cases -a -regex -engine -can -be -configured -to -stop -its -/ -/ -/ -search -before -concluding -whether -a -match -exists -or -not -. -When -this -happens -/ -/ -/ -it -may -be -important -for -the -caller -to -know -why -the -regex -engine -gave -up -and -/ -/ -/ -where -in -the -input -it -gave -up -at -. -This -error -type -exposes -the -' -why -' -and -the -/ -/ -/ -' -where -. -' -/ -/ -/ -/ -/ -/ -For -example -the -DFAs -provided -by -this -library -generally -cannot -correctly -/ -/ -/ -implement -Unicode -word -boundaries -. -Instead -they -provide -an -option -to -/ -/ -/ -eagerly -support -them -on -ASCII -text -( -since -Unicode -word -boundaries -are -/ -/ -/ -equivalent -to -ASCII -word -boundaries -when -searching -ASCII -text -) -but -will -/ -/ -/ -" -give -up -" -if -a -non -- -ASCII -byte -is -seen -. -In -such -cases -one -is -usually -/ -/ -/ -required -to -either -report -the -failure -to -the -caller -( -unergonomic -) -or -/ -/ -/ -otherwise -fall -back -to -some -other -regex -engine -( -ergonomic -but -potentially -/ -/ -/ -costly -) -. -/ -/ -/ -/ -/ -/ -More -generally -some -regex -engines -offer -the -ability -for -callers -to -specify -/ -/ -/ -certain -bytes -that -will -trigger -the -regex -engine -to -automatically -quit -if -/ -/ -/ -they -are -seen -. -/ -/ -/ -/ -/ -/ -Still -yet -there -may -be -other -reasons -for -a -failed -match -. -For -example -/ -/ -/ -the -hybrid -DFA -provided -by -this -crate -can -be -configured -to -give -up -if -it -/ -/ -/ -believes -that -it -is -not -efficient -. -This -in -turn -permits -callers -to -choose -a -/ -/ -/ -different -regex -engine -. -/ -/ -/ -/ -/ -/ -( -Note -that -DFAs -are -configured -by -default -to -never -quit -or -give -up -in -this -/ -/ -/ -fashion -. -For -example -by -default -a -DFA -will -fail -to -build -if -the -regex -/ -/ -/ -pattern -contains -a -Unicode -word -boundary -. -One -needs -to -opt -into -the -" -quit -" -/ -/ -/ -behavior -via -options -like -/ -/ -/ -[ -hybrid -: -: -dfa -: -: -Config -: -: -unicode_word_boundary -] -( -crate -: -: -hybrid -: -: -dfa -: -: -Config -: -: -unicode_word_boundary -) -. -) -/ -/ -/ -/ -/ -/ -There -are -a -couple -other -ways -a -search -/ -/ -/ -can -fail -. -For -example -when -using -the -/ -/ -/ -[ -BoundedBacktracker -] -( -crate -: -: -nfa -: -: -thompson -: -: -backtrack -: -: -BoundedBacktracker -) -/ -/ -/ -with -a -haystack -that -is -too -long -or -trying -to -run -an -unanchored -search -/ -/ -/ -with -a -[ -one -- -pass -DFA -] -( -crate -: -: -dfa -: -: -onepass -) -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -MatchError -( -# -[ -cfg -( -feature -= -" -alloc -" -) -] -alloc -: -: -boxed -: -: -Box -< -MatchErrorKind -> -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -MatchErrorKind -) -; -impl -MatchError -{ -/ -/ -/ -Create -a -new -error -value -with -the -given -kind -. -/ -/ -/ -/ -/ -/ -This -is -a -more -verbose -version -of -the -kind -- -specific -constructors -/ -/ -/ -e -. -g -. -MatchError -: -: -quit -. -pub -fn -new -( -kind -: -MatchErrorKind -) -- -> -MatchError -{ -# -[ -cfg -( -feature -= -" -alloc -" -) -] -{ -MatchError -( -alloc -: -: -boxed -: -: -Box -: -: -new -( -kind -) -) -} -# -[ -cfg -( -not -( -feature -= -" -alloc -" -) -) -] -{ -MatchError -( -kind -) -} -} -/ -/ -/ -Returns -a -reference -to -the -underlying -error -kind -. -pub -fn -kind -( -& -self -) -- -> -& -MatchErrorKind -{ -& -self -. -0 -} -/ -/ -/ -Create -a -new -" -quit -" -error -. -The -given -byte -corresponds -to -the -value -/ -/ -/ -that -tripped -a -search -' -s -quit -condition -and -offset -corresponds -to -the -/ -/ -/ -location -in -the -haystack -at -which -the -search -quit -. -/ -/ -/ -/ -/ -/ -This -is -the -same -as -calling -MatchError -: -: -new -with -a -/ -/ -/ -[ -MatchErrorKind -: -: -Quit -] -kind -. -pub -fn -quit -( -byte -: -u8 -offset -: -usize -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -Quit -{ -byte -offset -} -) -} -/ -/ -/ -Create -a -new -" -gave -up -" -error -. -The -given -offset -corresponds -to -the -/ -/ -/ -location -in -the -haystack -at -which -the -search -gave -up -. -/ -/ -/ -/ -/ -/ -This -is -the -same -as -calling -MatchError -: -: -new -with -a -/ -/ -/ -[ -MatchErrorKind -: -: -GaveUp -] -kind -. -pub -fn -gave_up -( -offset -: -usize -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -GaveUp -{ -offset -} -) -} -/ -/ -/ -Create -a -new -" -haystack -too -long -" -error -. -The -given -len -corresponds -to -/ -/ -/ -the -length -of -the -haystack -that -was -problematic -. -/ -/ -/ -/ -/ -/ -This -is -the -same -as -calling -MatchError -: -: -new -with -a -/ -/ -/ -[ -MatchErrorKind -: -: -HaystackTooLong -] -kind -. -pub -fn -haystack_too_long -( -len -: -usize -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -HaystackTooLong -{ -len -} -) -} -/ -/ -/ -Create -a -new -" -unsupported -anchored -" -error -. -This -occurs -when -the -caller -/ -/ -/ -requests -a -search -with -an -anchor -mode -that -is -not -supported -by -the -/ -/ -/ -regex -engine -. -/ -/ -/ -/ -/ -/ -This -is -the -same -as -calling -MatchError -: -: -new -with -a -/ -/ -/ -[ -MatchErrorKind -: -: -UnsupportedAnchored -] -kind -. -pub -fn -unsupported_anchored -( -mode -: -Anchored -) -- -> -MatchError -{ -MatchError -: -: -new -( -MatchErrorKind -: -: -UnsupportedAnchored -{ -mode -} -) -} -} -/ -/ -/ -The -underlying -kind -of -a -[ -MatchError -] -. -/ -/ -/ -/ -/ -/ -This -is -a -* -* -non -- -exhaustive -* -* -enum -. -That -means -new -variants -may -be -added -in -/ -/ -/ -a -semver -- -compatible -release -. -# -[ -non_exhaustive -] -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -enum -MatchErrorKind -{ -/ -/ -/ -The -search -saw -a -" -quit -" -byte -at -which -it -was -instructed -to -stop -/ -/ -/ -searching -. -Quit -{ -/ -/ -/ -The -" -quit -" -byte -that -was -observed -that -caused -the -search -to -stop -. -byte -: -u8 -/ -/ -/ -The -offset -at -which -the -quit -byte -was -observed -. -offset -: -usize -} -/ -/ -/ -The -search -based -on -heuristics -determined -that -it -would -be -better -/ -/ -/ -to -stop -typically -to -provide -the -caller -an -opportunity -to -use -an -/ -/ -/ -alternative -regex -engine -. -/ -/ -/ -/ -/ -/ -Currently -the -only -way -for -this -to -occur -is -via -the -lazy -DFA -and -/ -/ -/ -only -when -it -is -configured -to -do -so -( -it -will -not -return -this -error -by -/ -/ -/ -default -) -. -GaveUp -{ -/ -/ -/ -The -offset -at -which -the -search -stopped -. -This -corresponds -to -the -/ -/ -/ -position -immediately -following -the -last -byte -scanned -. -offset -: -usize -} -/ -/ -/ -This -error -occurs -if -the -haystack -given -to -the -regex -engine -was -too -/ -/ -/ -long -to -be -searched -. -This -occurs -for -example -with -regex -engines -/ -/ -/ -like -the -bounded -backtracker -that -have -a -configurable -fixed -amount -of -/ -/ -/ -capacity -that -is -tied -to -the -length -of -the -haystack -. -Anything -beyond -/ -/ -/ -that -configured -limit -will -result -in -an -error -at -search -time -. -HaystackTooLong -{ -/ -/ -/ -The -length -of -the -haystack -that -exceeded -the -limit -. -len -: -usize -} -/ -/ -/ -An -error -indicating -that -a -particular -type -of -anchored -search -was -/ -/ -/ -requested -but -that -the -regex -engine -does -not -support -it -. -/ -/ -/ -/ -/ -/ -Note -that -this -error -should -not -be -returned -by -a -regex -engine -simply -/ -/ -/ -because -the -pattern -ID -is -invalid -( -i -. -e -. -equal -to -or -exceeds -the -number -/ -/ -/ -of -patterns -in -the -regex -) -. -In -that -case -the -regex -engine -should -report -/ -/ -/ -a -non -- -match -. -UnsupportedAnchored -{ -/ -/ -/ -The -anchored -mode -given -that -is -unsupported -. -mode -: -Anchored -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -MatchError -{ -} -impl -core -: -: -fmt -: -: -Display -for -MatchError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -match -* -self -. -kind -( -) -{ -MatchErrorKind -: -: -Quit -{ -byte -offset -} -= -> -write -! -( -f -" -quit -search -after -observing -byte -{ -: -? -} -at -offset -{ -} -" -DebugByte -( -byte -) -offset -) -MatchErrorKind -: -: -GaveUp -{ -offset -} -= -> -{ -write -! -( -f -" -gave -up -searching -at -offset -{ -} -" -offset -) -} -MatchErrorKind -: -: -HaystackTooLong -{ -len -} -= -> -{ -write -! -( -f -" -haystack -of -length -{ -} -is -too -long -" -len -) -} -MatchErrorKind -: -: -UnsupportedAnchored -{ -mode -: -Anchored -: -: -Yes -} -= -> -{ -write -! -( -f -" -anchored -searches -are -not -supported -or -enabled -" -) -} -MatchErrorKind -: -: -UnsupportedAnchored -{ -mode -: -Anchored -: -: -No -} -= -> -{ -write -! -( -f -" -unanchored -searches -are -not -supported -or -enabled -" -) -} -MatchErrorKind -: -: -UnsupportedAnchored -{ -mode -: -Anchored -: -: -Pattern -( -pid -) -} -= -> -{ -write -! -( -f -" -anchored -searches -for -a -specific -pattern -( -{ -} -) -are -\ -not -supported -or -enabled -" -pid -. -as_usize -( -) -) -} -} -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -super -: -: -* -; -/ -/ -We -test -that -our -' -MatchError -' -type -is -the -size -we -expect -. -This -isn -' -t -an -/ -/ -API -guarantee -but -if -the -size -increases -we -really -want -to -make -sure -we -/ -/ -decide -to -do -that -intentionally -. -So -this -should -be -a -speed -bump -. -And -in -/ -/ -general -we -should -not -increase -the -size -without -a -very -good -reason -. -/ -/ -/ -/ -Why -? -Because -low -level -search -APIs -return -Result -< -. -. -MatchError -> -. -When -/ -/ -MatchError -gets -bigger -so -to -does -the -Result -type -. -/ -/ -/ -/ -Now -when -' -alloc -' -is -enabled -we -do -box -the -error -which -de -- -emphasizes -/ -/ -the -importance -of -keeping -a -small -error -type -. -But -without -' -alloc -' -we -/ -/ -still -want -things -to -be -small -. -# -[ -test -] -fn -match_error_size -( -) -{ -let -expected_size -= -if -cfg -! -( -feature -= -" -alloc -" -) -{ -core -: -: -mem -: -: -size_of -: -: -< -usize -> -( -) -} -else -{ -2 -* -core -: -: -mem -: -: -size_of -: -: -< -usize -> -( -) -} -; -assert_eq -! -( -expected_size -core -: -: -mem -: -: -size_of -: -: -< -MatchError -> -( -) -) -; -} -/ -/ -Same -as -above -but -for -the -underlying -match -error -kind -. -# -[ -cfg -( -target_pointer_width -= -" -64 -" -) -] -# -[ -test -] -fn -match_error_kind_size -( -) -{ -let -expected_size -= -2 -* -core -: -: -mem -: -: -size_of -: -: -< -usize -> -( -) -; -assert_eq -! -( -expected_size -core -: -: -mem -: -: -size_of -: -: -< -MatchErrorKind -> -( -) -) -; -} -# -[ -cfg -( -target_pointer_width -= -" -32 -" -) -] -# -[ -test -] -fn -match_error_kind_size -( -) -{ -let -expected_size -= -3 -* -core -: -: -mem -: -: -size_of -: -: -< -usize -> -( -) -; -assert_eq -! -( -expected_size -core -: -: -mem -: -: -size_of -: -: -< -MatchErrorKind -> -( -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/util/sparse_set.rs b/third_party/rust/regex-automata/src/util/sparse_set.rs deleted file mode 100644 index f4fc04db450c7..0000000000000 --- a/third_party/rust/regex-automata/src/util/sparse_set.rs +++ /dev/null @@ -1,2012 +0,0 @@ -/ -* -! -This -module -defines -a -sparse -set -data -structure -. -Its -most -interesting -properties -are -: -* -They -preserve -insertion -order -. -* -Set -membership -testing -is -done -in -constant -time -. -* -Set -insertion -is -done -in -constant -time -. -* -Clearing -the -set -is -done -in -constant -time -. -The -cost -for -doing -this -is -that -the -capacity -of -the -set -needs -to -be -known -up -front -and -the -elements -in -the -set -are -limited -to -state -identifiers -. -These -sets -are -principally -used -when -traversing -an -NFA -state -graph -. -This -happens -at -search -time -for -example -in -the -PikeVM -. -It -also -happens -during -DFA -determinization -. -* -/ -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -util -: -: -primitives -: -: -StateID -; -/ -/ -/ -A -pairse -of -sparse -sets -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -one -needs -to -compute -NFA -epsilon -closures -from -a -/ -/ -/ -previous -set -of -states -derived -from -an -epsilon -closure -. -One -set -can -be -the -/ -/ -/ -starting -states -where -as -the -other -set -can -be -the -destination -states -after -/ -/ -/ -following -the -transitions -for -a -particular -byte -of -input -. -/ -/ -/ -/ -/ -/ -There -is -no -significance -to -' -set1 -' -or -' -set2 -' -. -They -are -both -sparse -sets -of -/ -/ -/ -the -same -size -. -/ -/ -/ -/ -/ -/ -The -members -of -this -struct -are -exposed -so -that -callers -may -borrow -' -set1 -' -/ -/ -/ -and -' -set2 -' -individually -without -being -force -to -borrow -both -at -the -same -/ -/ -/ -time -. -# -[ -derive -( -Clone -Debug -) -] -pub -( -crate -) -struct -SparseSets -{ -pub -( -crate -) -set1 -: -SparseSet -pub -( -crate -) -set2 -: -SparseSet -} -impl -SparseSets -{ -/ -/ -/ -Create -a -new -pair -of -sparse -sets -where -each -set -has -the -given -capacity -. -/ -/ -/ -/ -/ -/ -This -panics -if -the -capacity -given -is -bigger -than -StateID -: -: -LIMIT -. -pub -( -crate -) -fn -new -( -capacity -: -usize -) -- -> -SparseSets -{ -SparseSets -{ -set1 -: -SparseSet -: -: -new -( -capacity -) -set2 -: -SparseSet -: -: -new -( -capacity -) -} -} -/ -/ -/ -Resizes -these -sparse -sets -to -have -the -new -capacity -given -. -/ -/ -/ -/ -/ -/ -The -sets -are -automatically -cleared -. -/ -/ -/ -/ -/ -/ -This -panics -if -the -capacity -given -is -bigger -than -StateID -: -: -LIMIT -. -# -[ -inline -] -pub -( -crate -) -fn -resize -( -& -mut -self -new_capacity -: -usize -) -{ -self -. -set1 -. -resize -( -new_capacity -) -; -self -. -set2 -. -resize -( -new_capacity -) -; -} -/ -/ -/ -Clear -both -sparse -sets -. -pub -( -crate -) -fn -clear -( -& -mut -self -) -{ -self -. -set1 -. -clear -( -) -; -self -. -set2 -. -clear -( -) -; -} -/ -/ -/ -Swap -set1 -with -set2 -. -pub -( -crate -) -fn -swap -( -& -mut -self -) -{ -core -: -: -mem -: -: -swap -( -& -mut -self -. -set1 -& -mut -self -. -set2 -) -; -} -/ -/ -/ -Returns -the -memory -usage -in -bytes -used -by -this -pair -of -sparse -sets -. -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -set1 -. -memory_usage -( -) -+ -self -. -set2 -. -memory_usage -( -) -} -} -/ -/ -/ -A -sparse -set -used -for -representing -ordered -NFA -states -. -/ -/ -/ -/ -/ -/ -This -supports -constant -time -addition -and -membership -testing -. -Clearing -an -/ -/ -/ -entire -set -can -also -be -done -in -constant -time -. -Iteration -yields -elements -/ -/ -/ -in -the -order -in -which -they -were -inserted -. -/ -/ -/ -/ -/ -/ -The -data -structure -is -based -on -: -https -: -/ -/ -research -. -swtch -. -com -/ -sparse -/ -/ -/ -Note -though -that -we -don -' -t -actually -use -uninitialized -memory -. -We -generally -/ -/ -/ -reuse -sparse -sets -so -the -initial -allocation -cost -is -bareable -. -However -its -/ -/ -/ -other -properties -listed -above -are -extremely -useful -. -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -SparseSet -{ -/ -/ -/ -The -number -of -elements -currently -in -this -set -. -len -: -usize -/ -/ -/ -Dense -contains -the -ids -in -the -order -in -which -they -were -inserted -. -dense -: -Vec -< -StateID -> -/ -/ -/ -Sparse -maps -ids -to -their -location -in -dense -. -/ -/ -/ -/ -/ -/ -A -state -ID -is -in -the -set -if -and -only -if -/ -/ -/ -sparse -[ -id -] -< -len -& -& -id -= -= -dense -[ -sparse -[ -id -] -] -. -/ -/ -/ -/ -/ -/ -Note -that -these -are -indices -into -' -dense -' -. -It -' -s -a -little -weird -to -use -/ -/ -/ -StateID -here -but -we -know -our -length -can -never -exceed -the -bounds -of -/ -/ -/ -StateID -( -enforced -by -' -resize -' -) -and -StateID -will -be -at -most -4 -bytes -/ -/ -/ -where -as -a -usize -is -likely -double -that -in -most -cases -. -sparse -: -Vec -< -StateID -> -} -impl -SparseSet -{ -/ -/ -/ -Create -a -new -sparse -set -with -the -given -capacity -. -/ -/ -/ -/ -/ -/ -Sparse -sets -have -a -fixed -size -and -they -cannot -grow -. -Attempting -to -/ -/ -/ -insert -more -distinct -elements -than -the -total -capacity -of -the -set -will -/ -/ -/ -result -in -a -panic -. -/ -/ -/ -/ -/ -/ -This -panics -if -the -capacity -given -is -bigger -than -StateID -: -: -LIMIT -. -# -[ -inline -] -pub -( -crate -) -fn -new -( -capacity -: -usize -) -- -> -SparseSet -{ -let -mut -set -= -SparseSet -{ -len -: -0 -dense -: -vec -! -[ -] -sparse -: -vec -! -[ -] -} -; -set -. -resize -( -capacity -) -; -set -} -/ -/ -/ -Resizes -this -sparse -set -to -have -the -new -capacity -given -. -/ -/ -/ -/ -/ -/ -This -set -is -automatically -cleared -. -/ -/ -/ -/ -/ -/ -This -panics -if -the -capacity -given -is -bigger -than -StateID -: -: -LIMIT -. -# -[ -inline -] -pub -( -crate -) -fn -resize -( -& -mut -self -new_capacity -: -usize -) -{ -assert -! -( -new_capacity -< -= -StateID -: -: -LIMIT -" -sparse -set -capacity -cannot -excced -{ -: -? -} -" -StateID -: -: -LIMIT -) -; -self -. -clear -( -) -; -self -. -dense -. -resize -( -new_capacity -StateID -: -: -ZERO -) -; -self -. -sparse -. -resize -( -new_capacity -StateID -: -: -ZERO -) -; -} -/ -/ -/ -Returns -the -capacity -of -this -set -. -/ -/ -/ -/ -/ -/ -The -capacity -represents -a -fixed -limit -on -the -number -of -distinct -/ -/ -/ -elements -that -are -allowed -in -this -set -. -The -capacity -cannot -be -changed -. -# -[ -inline -] -pub -( -crate -) -fn -capacity -( -& -self -) -- -> -usize -{ -self -. -dense -. -len -( -) -} -/ -/ -/ -Returns -the -number -of -elements -in -this -set -. -# -[ -inline -] -pub -( -crate -) -fn -len -( -& -self -) -- -> -usize -{ -self -. -len -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -is -empty -. -# -[ -inline -] -pub -( -crate -) -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -len -( -) -= -= -0 -} -/ -/ -/ -Insert -the -state -ID -value -into -this -set -and -return -true -if -the -given -/ -/ -/ -state -ID -was -not -previously -in -this -set -. -/ -/ -/ -/ -/ -/ -This -operation -is -idempotent -. -If -the -given -value -is -already -in -this -/ -/ -/ -set -then -this -is -a -no -- -op -. -/ -/ -/ -/ -/ -/ -If -more -than -capacity -ids -are -inserted -then -this -panics -. -/ -/ -/ -/ -/ -/ -This -is -marked -as -inline -( -always -) -since -the -compiler -won -' -t -inline -it -/ -/ -/ -otherwise -and -it -' -s -a -fairly -hot -piece -of -code -in -DFA -determinization -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -insert -( -& -mut -self -id -: -StateID -) -- -> -bool -{ -if -self -. -contains -( -id -) -{ -return -false -; -} -let -i -= -self -. -len -( -) -; -assert -! -( -i -< -self -. -capacity -( -) -" -{ -: -? -} -exceeds -capacity -of -{ -: -? -} -when -inserting -{ -: -? -} -" -i -self -. -capacity -( -) -id -) -; -/ -/ -OK -since -i -< -self -. -capacity -( -) -and -self -. -capacity -( -) -is -guaranteed -to -/ -/ -be -< -= -StateID -: -: -LIMIT -. -let -index -= -StateID -: -: -new_unchecked -( -i -) -; -self -. -dense -[ -index -] -= -id -; -self -. -sparse -[ -id -] -= -index -; -self -. -len -+ -= -1 -; -true -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -the -given -value -. -# -[ -inline -] -pub -( -crate -) -fn -contains -( -& -self -id -: -StateID -) -- -> -bool -{ -let -index -= -self -. -sparse -[ -id -] -; -index -. -as_usize -( -) -< -self -. -len -( -) -& -& -self -. -dense -[ -index -] -= -= -id -} -/ -/ -/ -Clear -this -set -such -that -it -has -no -members -. -# -[ -inline -] -pub -( -crate -) -fn -clear -( -& -mut -self -) -{ -self -. -len -= -0 -; -} -# -[ -inline -] -pub -( -crate -) -fn -iter -( -& -self -) -- -> -SparseSetIter -< -' -_ -> -{ -SparseSetIter -( -self -. -dense -[ -. -. -self -. -len -( -) -] -. -iter -( -) -) -} -/ -/ -/ -Returns -the -heap -memory -usage -in -bytes -used -by -this -sparse -set -. -# -[ -inline -] -pub -( -crate -) -fn -memory_usage -( -& -self -) -- -> -usize -{ -self -. -dense -. -len -( -) -* -StateID -: -: -SIZE -+ -self -. -sparse -. -len -( -) -* -StateID -: -: -SIZE -} -} -impl -core -: -: -fmt -: -: -Debug -for -SparseSet -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -elements -: -Vec -< -StateID -> -= -self -. -iter -( -) -. -collect -( -) -; -f -. -debug_tuple -( -" -SparseSet -" -) -. -field -( -& -elements -) -. -finish -( -) -} -} -/ -/ -/ -An -iterator -over -all -elements -in -a -sparse -set -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -set -being -iterated -over -. -# -[ -derive -( -Debug -) -] -pub -( -crate -) -struct -SparseSetIter -< -' -a -> -( -core -: -: -slice -: -: -Iter -< -' -a -StateID -> -) -; -impl -< -' -a -> -Iterator -for -SparseSetIter -< -' -a -> -{ -type -Item -= -StateID -; -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -next -( -& -mut -self -) -- -> -Option -< -StateID -> -{ -self -. -0 -. -next -( -) -. -map -( -| -& -id -| -id -) -} -} diff --git a/third_party/rust/regex-automata/src/util/start.rs b/third_party/rust/regex-automata/src/util/start.rs deleted file mode 100644 index 2338b7aff31c2..0000000000000 --- a/third_party/rust/regex-automata/src/util/start.rs +++ /dev/null @@ -1,2789 +0,0 @@ -/ -* -! -Provides -some -helpers -for -dealing -with -start -state -configurations -in -DFAs -. -[ -Start -] -represents -the -possible -starting -configurations -while -[ -StartByteMap -] -represents -a -way -to -retrieve -the -Start -configuration -for -a -given -position -in -a -haystack -. -* -/ -use -crate -: -: -util -: -: -{ -look -: -: -LookMatcher -search -: -: -Input -wire -: -: -{ -self -DeserializeError -SerializeError -} -} -; -/ -/ -/ -A -map -from -every -possible -byte -value -to -its -corresponding -starting -/ -/ -/ -configuration -. -/ -/ -/ -/ -/ -/ -This -map -is -used -in -order -to -lookup -the -start -configuration -for -a -particular -/ -/ -/ -position -in -a -haystack -. -This -start -configuration -is -then -used -in -/ -/ -/ -combination -with -things -like -the -anchored -mode -and -pattern -ID -to -fully -/ -/ -/ -determine -the -start -state -. -/ -/ -/ -/ -/ -/ -Generally -speaking -this -map -is -only -used -for -fully -compiled -DFAs -and -lazy -/ -/ -/ -DFAs -. -For -NFAs -( -including -the -one -- -pass -DFA -) -the -start -state -is -generally -/ -/ -/ -selected -by -virtue -of -traversing -the -NFA -state -graph -. -DFAs -do -the -same -/ -/ -/ -thing -but -at -build -time -and -not -search -time -. -( -Well -technically -the -lazy -/ -/ -/ -DFA -does -it -at -search -time -but -it -does -enough -work -to -cache -the -full -/ -/ -/ -result -of -the -epsilon -closure -that -the -NFA -engines -tend -to -need -to -do -. -) -# -[ -derive -( -Clone -) -] -pub -( -crate -) -struct -StartByteMap -{ -map -: -[ -Start -; -256 -] -} -impl -StartByteMap -{ -/ -/ -/ -Create -a -new -map -from -byte -values -to -their -corresponding -starting -/ -/ -/ -configurations -. -The -map -is -determined -in -part -by -how -look -- -around -/ -/ -/ -assertions -are -matched -via -the -matcher -given -. -pub -( -crate -) -fn -new -( -lookm -: -& -LookMatcher -) -- -> -StartByteMap -{ -let -mut -map -= -[ -Start -: -: -NonWordByte -; -256 -] -; -map -[ -usize -: -: -from -( -b -' -\ -n -' -) -] -= -Start -: -: -LineLF -; -map -[ -usize -: -: -from -( -b -' -\ -r -' -) -] -= -Start -: -: -LineCR -; -map -[ -usize -: -: -from -( -b -' -_ -' -) -] -= -Start -: -: -WordByte -; -let -mut -byte -= -b -' -0 -' -; -while -byte -< -= -b -' -9 -' -{ -map -[ -usize -: -: -from -( -byte -) -] -= -Start -: -: -WordByte -; -byte -+ -= -1 -; -} -byte -= -b -' -A -' -; -while -byte -< -= -b -' -Z -' -{ -map -[ -usize -: -: -from -( -byte -) -] -= -Start -: -: -WordByte -; -byte -+ -= -1 -; -} -byte -= -b -' -a -' -; -while -byte -< -= -b -' -z -' -{ -map -[ -usize -: -: -from -( -byte -) -] -= -Start -: -: -WordByte -; -byte -+ -= -1 -; -} -let -lineterm -= -lookm -. -get_line_terminator -( -) -; -/ -/ -If -our -line -terminator -is -normal -then -it -is -already -handled -by -/ -/ -the -LineLF -and -LineCR -configurations -. -But -if -it -' -s -weird -then -we -/ -/ -overwrite -whatever -was -there -before -for -that -terminator -with -a -/ -/ -special -configuration -. -The -trick -here -is -that -if -the -terminator -/ -/ -is -say -a -word -byte -like -a -then -callers -seeing -this -start -/ -/ -configuration -need -to -account -for -that -and -build -their -DFA -state -as -/ -/ -if -it -* -also -* -came -from -a -word -byte -. -if -lineterm -! -= -b -' -\ -r -' -& -& -lineterm -! -= -b -' -\ -n -' -{ -map -[ -usize -: -: -from -( -lineterm -) -] -= -Start -: -: -CustomLineTerminator -; -} -StartByteMap -{ -map -} -} -/ -/ -/ -Return -the -forward -starting -configuration -for -the -given -input -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -fwd -( -& -self -input -: -& -Input -) -- -> -Start -{ -match -input -. -start -( -) -. -checked_sub -( -1 -) -. -and_then -( -| -i -| -input -. -haystack -( -) -. -get -( -i -) -) -{ -None -= -> -Start -: -: -Text -Some -( -& -byte -) -= -> -self -. -get -( -byte -) -} -} -/ -/ -/ -Return -the -reverse -starting -configuration -for -the -given -input -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -rev -( -& -self -input -: -& -Input -) -- -> -Start -{ -match -input -. -haystack -( -) -. -get -( -input -. -end -( -) -) -{ -None -= -> -Start -: -: -Text -Some -( -& -byte -) -= -> -self -. -get -( -byte -) -} -} -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -get -( -& -self -byte -: -u8 -) -- -> -Start -{ -self -. -map -[ -usize -: -: -from -( -byte -) -] -} -/ -/ -/ -Deserializes -a -byte -class -map -from -the -given -slice -. -If -the -slice -is -of -/ -/ -/ -insufficient -length -or -otherwise -contains -an -impossible -mapping -then -/ -/ -/ -an -error -is -returned -. -Upon -success -the -number -of -bytes -read -along -with -/ -/ -/ -the -map -are -returned -. -The -number -of -bytes -read -is -always -a -multiple -of -/ -/ -/ -8 -. -pub -( -crate -) -fn -from_bytes -( -slice -: -& -[ -u8 -] -) -- -> -Result -< -( -StartByteMap -usize -) -DeserializeError -> -{ -wire -: -: -check_slice_len -( -slice -256 -" -start -byte -map -" -) -? -; -let -mut -map -= -[ -Start -: -: -NonWordByte -; -256 -] -; -for -( -i -& -repr -) -in -slice -[ -. -. -256 -] -. -iter -( -) -. -enumerate -( -) -{ -map -[ -i -] -= -match -Start -: -: -from_usize -( -usize -: -: -from -( -repr -) -) -{ -Some -( -start -) -= -> -start -None -= -> -{ -return -Err -( -DeserializeError -: -: -generic -( -" -found -invalid -starting -configuration -" -) -) -} -} -; -} -Ok -( -( -StartByteMap -{ -map -} -256 -) -) -} -/ -/ -/ -Writes -this -map -to -the -given -byte -buffer -. -if -the -given -buffer -is -too -/ -/ -/ -small -then -an -error -is -returned -. -Upon -success -the -total -number -of -/ -/ -/ -bytes -written -is -returned -. -The -number -of -bytes -written -is -guaranteed -to -/ -/ -/ -be -a -multiple -of -8 -. -pub -( -crate -) -fn -write_to -( -& -self -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -self -. -write_to_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -start -byte -map -" -) -) -; -} -for -( -i -& -start -) -in -self -. -map -. -iter -( -) -. -enumerate -( -) -{ -dst -[ -i -] -= -start -. -as_u8 -( -) -; -} -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -total -number -of -bytes -written -by -write_to -. -pub -( -crate -) -fn -write_to_len -( -& -self -) -- -> -usize -{ -256 -} -} -impl -core -: -: -fmt -: -: -Debug -for -StartByteMap -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -use -crate -: -: -util -: -: -escape -: -: -DebugByte -; -write -! -( -f -" -StartByteMap -{ -{ -" -) -? -; -for -byte -in -0 -. -. -= -255 -{ -if -byte -> -0 -{ -write -! -( -f -" -" -) -? -; -} -let -start -= -self -. -map -[ -usize -: -: -from -( -byte -) -] -; -write -! -( -f -" -{ -: -? -} -= -> -{ -: -? -} -" -DebugByte -( -byte -) -start -) -? -; -} -write -! -( -f -" -} -} -" -) -? -; -Ok -( -( -) -) -} -} -/ -/ -/ -Represents -the -six -possible -starting -configurations -of -a -DFA -search -. -/ -/ -/ -/ -/ -/ -The -starting -configuration -is -determined -by -inspecting -the -the -beginning -/ -/ -/ -of -the -haystack -( -up -to -1 -byte -) -. -Ultimately -this -along -with -a -pattern -ID -/ -/ -/ -( -if -specified -) -and -the -type -of -search -( -anchored -or -not -) -is -what -selects -the -/ -/ -/ -start -state -to -use -in -a -DFA -. -/ -/ -/ -/ -/ -/ -As -one -example -if -a -DFA -only -supports -unanchored -searches -and -does -not -/ -/ -/ -support -anchored -searches -for -each -pattern -then -it -will -have -at -most -6 -/ -/ -/ -distinct -start -states -. -( -Some -start -states -may -be -reused -if -determinization -/ -/ -/ -can -determine -that -they -will -be -equivalent -. -) -If -the -DFA -supports -both -/ -/ -/ -anchored -and -unanchored -searches -then -it -will -have -a -maximum -of -12 -/ -/ -/ -distinct -start -states -. -Finally -if -the -DFA -also -supports -anchored -searches -/ -/ -/ -for -each -pattern -then -it -can -have -up -to -12 -+ -( -N -* -6 -) -start -states -where -/ -/ -/ -N -is -the -number -of -patterns -. -/ -/ -/ -/ -/ -/ -Handling -each -of -these -starting -configurations -in -the -context -of -DFA -/ -/ -/ -determinization -can -be -* -quite -* -tricky -and -subtle -. -But -the -code -is -small -/ -/ -/ -and -can -be -found -at -crate -: -: -util -: -: -determinize -: -: -set_lookbehind_from_start -. -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -( -crate -) -enum -Start -{ -/ -/ -/ -This -occurs -when -the -starting -position -is -not -any -of -the -ones -below -. -NonWordByte -= -0 -/ -/ -/ -This -occurs -when -the -byte -immediately -preceding -the -start -of -the -search -/ -/ -/ -is -an -ASCII -word -byte -. -WordByte -= -1 -/ -/ -/ -This -occurs -when -the -starting -position -of -the -search -corresponds -to -the -/ -/ -/ -beginning -of -the -haystack -. -Text -= -2 -/ -/ -/ -This -occurs -when -the -byte -immediately -preceding -the -start -of -the -search -/ -/ -/ -is -a -line -terminator -. -Specifically -\ -n -. -LineLF -= -3 -/ -/ -/ -This -occurs -when -the -byte -immediately -preceding -the -start -of -the -search -/ -/ -/ -is -a -line -terminator -. -Specifically -\ -r -. -LineCR -= -4 -/ -/ -/ -This -occurs -when -a -custom -line -terminator -has -been -set -via -a -/ -/ -/ -LookMatcher -and -when -that -line -terminator -is -neither -a -\ -r -or -a -/ -/ -/ -\ -n -. -/ -/ -/ -/ -/ -/ -If -the -custom -line -terminator -is -a -word -byte -then -this -start -/ -/ -/ -configuration -is -still -selected -. -DFAs -that -implement -word -boundary -/ -/ -/ -assertions -will -likely -need -to -check -whether -the -custom -line -terminator -/ -/ -/ -is -a -word -byte -in -which -case -it -should -behave -as -if -the -byte -/ -/ -/ -satisfies -\ -b -in -addition -to -multi -- -line -anchors -. -CustomLineTerminator -= -5 -} -impl -Start -{ -/ -/ -/ -Return -the -starting -state -corresponding -to -the -given -integer -. -If -no -/ -/ -/ -starting -state -exists -for -the -given -integer -then -None -is -returned -. -pub -( -crate -) -fn -from_usize -( -n -: -usize -) -- -> -Option -< -Start -> -{ -match -n -{ -0 -= -> -Some -( -Start -: -: -NonWordByte -) -1 -= -> -Some -( -Start -: -: -WordByte -) -2 -= -> -Some -( -Start -: -: -Text -) -3 -= -> -Some -( -Start -: -: -LineLF -) -4 -= -> -Some -( -Start -: -: -LineCR -) -5 -= -> -Some -( -Start -: -: -CustomLineTerminator -) -_ -= -> -None -} -} -/ -/ -/ -Returns -the -total -number -of -starting -state -configurations -. -pub -( -crate -) -fn -len -( -) -- -> -usize -{ -6 -} -/ -/ -/ -Return -this -starting -configuration -as -u8 -integer -. -It -is -guaranteed -to -/ -/ -/ -be -less -than -Start -: -: -len -( -) -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -as_u8 -( -& -self -) -- -> -u8 -{ -/ -/ -AFAIK -' -as -' -is -the -only -way -to -zero -- -cost -convert -an -int -enum -to -an -/ -/ -actual -int -. -* -self -as -u8 -} -/ -/ -/ -Return -this -starting -configuration -as -a -usize -integer -. -It -is -/ -/ -/ -guaranteed -to -be -less -than -Start -: -: -len -( -) -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -as_usize -( -& -self -) -- -> -usize -{ -usize -: -: -from -( -self -. -as_u8 -( -) -) -} -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -super -: -: -* -; -# -[ -test -] -fn -start_fwd_done_range -( -) -{ -let -smap -= -StartByteMap -: -: -new -( -& -LookMatcher -: -: -default -( -) -) -; -assert_eq -! -( -Start -: -: -Text -smap -. -fwd -( -& -Input -: -: -new -( -" -" -) -. -range -( -1 -. -. -0 -) -) -) -; -} -# -[ -test -] -fn -start_rev_done_range -( -) -{ -let -smap -= -StartByteMap -: -: -new -( -& -LookMatcher -: -: -default -( -) -) -; -assert_eq -! -( -Start -: -: -Text -smap -. -rev -( -& -Input -: -: -new -( -" -" -) -. -range -( -1 -. -. -0 -) -) -) -; -} -# -[ -test -] -fn -start_fwd -( -) -{ -let -f -= -| -haystack -start -end -| -{ -let -smap -= -StartByteMap -: -: -new -( -& -LookMatcher -: -: -default -( -) -) -; -let -input -= -& -Input -: -: -new -( -haystack -) -. -range -( -start -. -. -end -) -; -smap -. -fwd -( -input -) -} -; -assert_eq -! -( -Start -: -: -Text -f -( -" -" -0 -0 -) -) -; -assert_eq -! -( -Start -: -: -Text -f -( -" -abc -" -0 -3 -) -) -; -assert_eq -! -( -Start -: -: -Text -f -( -" -\ -nabc -" -0 -3 -) -) -; -assert_eq -! -( -Start -: -: -LineLF -f -( -" -\ -nabc -" -1 -3 -) -) -; -assert_eq -! -( -Start -: -: -LineCR -f -( -" -\ -rabc -" -1 -3 -) -) -; -assert_eq -! -( -Start -: -: -WordByte -f -( -" -abc -" -1 -3 -) -) -; -assert_eq -! -( -Start -: -: -NonWordByte -f -( -" -abc -" -1 -3 -) -) -; -} -# -[ -test -] -fn -start_rev -( -) -{ -let -f -= -| -haystack -start -end -| -{ -let -smap -= -StartByteMap -: -: -new -( -& -LookMatcher -: -: -default -( -) -) -; -let -input -= -& -Input -: -: -new -( -haystack -) -. -range -( -start -. -. -end -) -; -smap -. -rev -( -input -) -} -; -assert_eq -! -( -Start -: -: -Text -f -( -" -" -0 -0 -) -) -; -assert_eq -! -( -Start -: -: -Text -f -( -" -abc -" -0 -3 -) -) -; -assert_eq -! -( -Start -: -: -Text -f -( -" -abc -\ -n -" -0 -4 -) -) -; -assert_eq -! -( -Start -: -: -LineLF -f -( -" -abc -\ -nz -" -0 -3 -) -) -; -assert_eq -! -( -Start -: -: -LineCR -f -( -" -abc -\ -rz -" -0 -3 -) -) -; -assert_eq -! -( -Start -: -: -WordByte -f -( -" -abc -" -0 -2 -) -) -; -assert_eq -! -( -Start -: -: -NonWordByte -f -( -" -abc -" -0 -3 -) -) -; -} -} diff --git a/third_party/rust/regex-automata/src/util/unicode_data/mod.rs b/third_party/rust/regex-automata/src/util/unicode_data/mod.rs deleted file mode 100644 index 8f681f1f32b71..0000000000000 --- a/third_party/rust/regex-automata/src/util/unicode_data/mod.rs +++ /dev/null @@ -1,174 +0,0 @@ -/ -/ -This -cfg -should -match -the -one -in -src -/ -util -/ -look -. -rs -that -uses -perl_word -. -# -[ -cfg -( -all -( -/ -/ -We -have -to -explicitly -want -to -support -Unicode -word -boundaries -. -feature -= -" -unicode -- -word -- -boundary -" -not -( -all -( -/ -/ -If -we -don -' -t -have -regex -- -syntax -at -all -then -we -definitely -need -to -/ -/ -bring -our -own -\ -w -data -table -. -feature -= -" -syntax -" -/ -/ -If -unicode -- -perl -is -enabled -then -regex -- -syntax -/ -unicode -- -perl -is -/ -/ -also -enabled -which -in -turn -means -we -can -use -regex -- -syntax -' -s -/ -/ -is_word_character -routine -( -and -thus -use -its -data -tables -) -. -But -if -/ -/ -unicode -- -perl -is -not -enabled -even -if -syntax -is -then -we -need -to -/ -/ -bring -our -own -. -feature -= -" -unicode -- -perl -" -) -) -) -) -] -pub -( -crate -) -mod -perl_word -; diff --git a/third_party/rust/regex-automata/src/util/unicode_data/perl_word.rs b/third_party/rust/regex-automata/src/util/unicode_data/perl_word.rs deleted file mode 100644 index a543c865c3958..0000000000000 --- a/third_party/rust/regex-automata/src/util/unicode_data/perl_word.rs +++ /dev/null @@ -1,6206 +0,0 @@ -/ -/ -DO -NOT -EDIT -THIS -FILE -. -IT -WAS -AUTOMATICALLY -GENERATED -BY -: -/ -/ -/ -/ -ucd -- -generate -perl -- -word -tmp -/ -ucd -- -15 -. -0 -. -0 -/ -- -- -chars -/ -/ -/ -/ -Unicode -version -: -15 -. -0 -. -0 -. -/ -/ -/ -/ -ucd -- -generate -0 -. -2 -. -15 -is -available -on -crates -. -io -. -pub -const -PERL_WORD -: -& -' -static -[ -( -char -char -) -] -= -& -[ -( -' -0 -' -' -9 -' -) -( -' -A -' -' -Z -' -) -( -' -_ -' -' -_ -' -) -( -' -a -' -' -z -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -300 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -483 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -591 -} -' -' -\ -u -{ -5bd -} -' -) -( -' -\ -u -{ -5bf -} -' -' -\ -u -{ -5bf -} -' -) -( -' -\ -u -{ -5c1 -} -' -' -\ -u -{ -5c2 -} -' -) -( -' -\ -u -{ -5c4 -} -' -' -\ -u -{ -5c5 -} -' -) -( -' -\ -u -{ -5c7 -} -' -' -\ -u -{ -5c7 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -610 -} -' -' -\ -u -{ -61a -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -6dc -} -' -) -( -' -\ -u -{ -6df -} -' -' -\ -u -{ -6e8 -} -' -) -( -' -\ -u -{ -6ea -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -74a -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -7fd -} -' -' -\ -u -{ -7fd -} -' -) -( -' -' -' -\ -u -{ -82d -} -' -) -( -' -' -' -\ -u -{ -85b -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -898 -} -' -' -\ -u -{ -8e1 -} -' -) -( -' -\ -u -{ -8e3 -} -' -' -\ -u -{ -963 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -9bc -} -' -' -\ -u -{ -9c4 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -9d7 -} -' -' -\ -u -{ -9d7 -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -9e3 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -9fe -} -' -' -\ -u -{ -9fe -} -' -) -( -' -\ -u -{ -a01 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -a3c -} -' -' -\ -u -{ -a3c -} -' -) -( -' -' -' -\ -u -{ -a42 -} -' -) -( -' -\ -u -{ -a47 -} -' -' -\ -u -{ -a48 -} -' -) -( -' -\ -u -{ -a4b -} -' -' -\ -u -{ -a4d -} -' -) -( -' -\ -u -{ -a51 -} -' -' -\ -u -{ -a51 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -a75 -} -' -) -( -' -\ -u -{ -a81 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -abc -} -' -' -\ -u -{ -ac5 -} -' -) -( -' -\ -u -{ -ac7 -} -' -' -' -) -( -' -' -' -\ -u -{ -acd -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -ae3 -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -aff -} -' -) -( -' -\ -u -{ -b01 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -b3c -} -' -' -\ -u -{ -b44 -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -b4d -} -' -) -( -' -\ -u -{ -b55 -} -' -' -\ -u -{ -b57 -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -b63 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -b82 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -bbe -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -bcd -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -bd7 -} -' -' -\ -u -{ -bd7 -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -c00 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -c3c -} -' -' -' -) -( -' -\ -u -{ -c46 -} -' -' -\ -u -{ -c48 -} -' -) -( -' -\ -u -{ -c4a -} -' -' -\ -u -{ -c4d -} -' -) -( -' -\ -u -{ -c55 -} -' -' -\ -u -{ -c56 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -c63 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -cbc -} -' -' -' -) -( -' -\ -u -{ -cc6 -} -' -' -' -) -( -' -' -' -\ -u -{ -ccd -} -' -) -( -' -\ -u -{ -cd5 -} -' -' -\ -u -{ -cd6 -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -ce3 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -d00 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -d44 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -d57 -} -' -) -( -' -' -' -\ -u -{ -d63 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -d81 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -dca -} -' -' -\ -u -{ -dca -} -' -) -( -' -\ -u -{ -dcf -} -' -' -\ -u -{ -dd4 -} -' -) -( -' -\ -u -{ -dd6 -} -' -' -\ -u -{ -dd6 -} -' -) -( -' -' -' -\ -u -{ -ddf -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -e3a -} -' -) -( -' -' -' -\ -u -{ -e4e -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -ec8 -} -' -' -\ -u -{ -ece -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -f18 -} -' -' -\ -u -{ -f19 -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -f35 -} -' -' -\ -u -{ -f35 -} -' -) -( -' -\ -u -{ -f37 -} -' -' -\ -u -{ -f37 -} -' -) -( -' -\ -u -{ -f39 -} -' -' -\ -u -{ -f39 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -f71 -} -' -' -\ -u -{ -f84 -} -' -) -( -' -\ -u -{ -f86 -} -' -' -\ -u -{ -f97 -} -' -) -( -' -\ -u -{ -f99 -} -' -' -\ -u -{ -fbc -} -' -) -( -' -\ -u -{ -fc6 -} -' -' -\ -u -{ -fc6 -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -109d -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -135d -} -' -' -\ -u -{ -135f -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -1753 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1772 -} -' -' -\ -u -{ -1773 -} -' -) -( -' -' -' -\ -u -{ -17d3 -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -17dd -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -180b -} -' -' -\ -u -{ -180d -} -' -) -( -' -\ -u -{ -180f -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1920 -} -' -' -' -) -( -' -' -' -\ -u -{ -193b -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -1a1b -} -' -) -( -' -' -' -\ -u -{ -1a5e -} -' -) -( -' -\ -u -{ -1a60 -} -' -' -\ -u -{ -1a7c -} -' -) -( -' -\ -u -{ -1a7f -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1ab0 -} -' -' -\ -u -{ -1ace -} -' -) -( -' -\ -u -{ -1b00 -} -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1b6b -} -' -' -\ -u -{ -1b73 -} -' -) -( -' -\ -u -{ -1b80 -} -' -' -' -) -( -' -' -' -\ -u -{ -1c37 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1cd0 -} -' -' -\ -u -{ -1cd2 -} -' -) -( -' -\ -u -{ -1cd4 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -200c -} -' -' -\ -u -{ -200d -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -20d0 -} -' -' -\ -u -{ -20f0 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -2d7f -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -2de0 -} -' -' -\ -u -{ -2dff -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -302f -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -3099 -} -' -' -\ -u -{ -309a -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -a672 -} -' -) -( -' -\ -u -{ -a674 -} -' -' -\ -u -{ -a67d -} -' -) -( -' -' -' -\ -u -{ -a6f1 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -a82c -} -' -' -\ -u -{ -a82c -} -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -a8c5 -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -a8e0 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -a92d -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -a980 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -aa36 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -aaf6 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -abed -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -fe00 -} -' -' -\ -u -{ -fe0f -} -' -) -( -' -\ -u -{ -fe20 -} -' -' -\ -u -{ -fe2f -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -101fd -} -' -' -\ -u -{ -101fd -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -102e0 -} -' -' -\ -u -{ -102e0 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -1037a -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -10a03 -} -' -) -( -' -\ -u -{ -10a05 -} -' -' -\ -u -{ -10a06 -} -' -) -( -' -\ -u -{ -10a0c -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -10a38 -} -' -' -\ -u -{ -10a3a -} -' -) -( -' -\ -u -{ -10a3f -} -' -' -\ -u -{ -10a3f -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -10ae6 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -10d27 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -10eab -} -' -' -\ -u -{ -10eac -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -10efd -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -10f50 -} -' -) -( -' -' -' -\ -u -{ -10f85 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -11046 -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1107f -} -' -' -\ -u -{ -110ba -} -' -) -( -' -\ -u -{ -110c2 -} -' -' -\ -u -{ -110c2 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -11100 -} -' -' -\ -u -{ -11134 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -11173 -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -11180 -} -' -' -' -) -( -' -\ -u -{ -111c9 -} -' -' -\ -u -{ -111cc -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -11237 -} -' -) -( -' -\ -u -{ -1123e -} -' -' -\ -u -{ -11241 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -112ea -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -11300 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1133b -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -11357 -} -' -' -\ -u -{ -11357 -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -11366 -} -' -' -\ -u -{ -1136c -} -' -) -( -' -\ -u -{ -11370 -} -' -' -\ -u -{ -11374 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1145e -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -115b5 -} -' -) -( -' -' -' -\ -u -{ -115c0 -} -' -) -( -' -' -' -\ -u -{ -115dd -} -' -) -( -' -' -' -\ -u -{ -11640 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1171d -} -' -' -\ -u -{ -1172b -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -1183a -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1193b -} -' -' -\ -u -{ -11943 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -119d7 -} -' -) -( -' -\ -u -{ -119da -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -11a3e -} -' -) -( -' -\ -u -{ -11a47 -} -' -' -\ -u -{ -11a47 -} -' -) -( -' -' -' -\ -u -{ -11a99 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -11c36 -} -' -) -( -' -\ -u -{ -11c38 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -11c92 -} -' -' -\ -u -{ -11ca7 -} -' -) -( -' -' -' -\ -u -{ -11cb6 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -11d36 -} -' -) -( -' -\ -u -{ -11d3a -} -' -' -\ -u -{ -11d3a -} -' -) -( -' -\ -u -{ -11d3c -} -' -' -\ -u -{ -11d3d -} -' -) -( -' -\ -u -{ -11d3f -} -' -' -\ -u -{ -11d47 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -11d90 -} -' -' -\ -u -{ -11d91 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -11f00 -} -' -' -' -) -( -' -' -' -\ -u -{ -11f3a -} -' -) -( -' -' -' -\ -u -{ -11f42 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -13440 -} -' -' -\ -u -{ -13455 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -16af0 -} -' -' -\ -u -{ -16af4 -} -' -) -( -' -' -' -\ -u -{ -16b36 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -16f4f -} -' -' -' -) -( -' -\ -u -{ -16f8f -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -16fe4 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1bc9d -} -' -' -\ -u -{ -1bc9e -} -' -) -( -' -\ -u -{ -1cf00 -} -' -' -\ -u -{ -1cf2d -} -' -) -( -' -\ -u -{ -1cf30 -} -' -' -\ -u -{ -1cf46 -} -' -) -( -' -\ -u -{ -1d165 -} -' -' -\ -u -{ -1d169 -} -' -) -( -' -' -' -\ -u -{ -1d172 -} -' -) -( -' -\ -u -{ -1d17b -} -' -' -\ -u -{ -1d182 -} -' -) -( -' -\ -u -{ -1d185 -} -' -' -\ -u -{ -1d18b -} -' -) -( -' -\ -u -{ -1d1aa -} -' -' -\ -u -{ -1d1ad -} -' -) -( -' -\ -u -{ -1d242 -} -' -' -\ -u -{ -1d244 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1da00 -} -' -' -\ -u -{ -1da36 -} -' -) -( -' -\ -u -{ -1da3b -} -' -' -\ -u -{ -1da6c -} -' -) -( -' -\ -u -{ -1da75 -} -' -' -\ -u -{ -1da75 -} -' -) -( -' -\ -u -{ -1da84 -} -' -' -\ -u -{ -1da84 -} -' -) -( -' -\ -u -{ -1da9b -} -' -' -\ -u -{ -1da9f -} -' -) -( -' -\ -u -{ -1daa1 -} -' -' -\ -u -{ -1daaf -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1e000 -} -' -' -\ -u -{ -1e006 -} -' -) -( -' -\ -u -{ -1e008 -} -' -' -\ -u -{ -1e018 -} -' -) -( -' -\ -u -{ -1e01b -} -' -' -\ -u -{ -1e021 -} -' -) -( -' -\ -u -{ -1e023 -} -' -' -\ -u -{ -1e024 -} -' -) -( -' -\ -u -{ -1e026 -} -' -' -\ -u -{ -1e02a -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1e08f -} -' -' -\ -u -{ -1e08f -} -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1e130 -} -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -\ -u -{ -1e2ae -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -1e8d0 -} -' -' -\ -u -{ -1e8d6 -} -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -( -' -\ -u -{ -e0100 -} -' -' -\ -u -{ -e01ef -} -' -) -] -; diff --git a/third_party/rust/regex-automata/src/util/utf8.rs b/third_party/rust/regex-automata/src/util/utf8.rs deleted file mode 100644 index 538604eddb763..0000000000000 --- a/third_party/rust/regex-automata/src/util/utf8.rs +++ /dev/null @@ -1,1924 +0,0 @@ -/ -* -! -Utilities -for -dealing -with -UTF -- -8 -. -This -module -provides -some -UTF -- -8 -related -helper -routines -including -an -incremental -decoder -. -* -/ -/ -/ -/ -Returns -true -if -and -only -if -the -given -byte -is -considered -a -word -character -. -/ -/ -/ -This -only -applies -to -ASCII -. -/ -/ -/ -/ -/ -/ -This -was -copied -from -regex -- -syntax -so -that -we -can -use -it -to -determine -the -/ -/ -/ -starting -DFA -state -while -searching -without -depending -on -regex -- -syntax -. -The -/ -/ -/ -definition -is -never -going -to -change -so -there -' -s -no -maintenance -/ -bit -- -rot -/ -/ -/ -hazard -here -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -is_word_byte -( -b -: -u8 -) -- -> -bool -{ -const -fn -mkwordset -( -) -- -> -[ -bool -; -256 -] -{ -/ -/ -FIXME -: -Use -as_usize -( -) -once -const -functions -in -traits -are -stable -. -let -mut -set -= -[ -false -; -256 -] -; -set -[ -b -' -_ -' -as -usize -] -= -true -; -let -mut -byte -= -b -' -0 -' -; -while -byte -< -= -b -' -9 -' -{ -set -[ -byte -as -usize -] -= -true -; -byte -+ -= -1 -; -} -byte -= -b -' -A -' -; -while -byte -< -= -b -' -Z -' -{ -set -[ -byte -as -usize -] -= -true -; -byte -+ -= -1 -; -} -byte -= -b -' -a -' -; -while -byte -< -= -b -' -z -' -{ -set -[ -byte -as -usize -] -= -true -; -byte -+ -= -1 -; -} -set -} -const -WORD -: -[ -bool -; -256 -] -= -mkwordset -( -) -; -WORD -[ -b -as -usize -] -} -/ -/ -/ -Decodes -the -next -UTF -- -8 -encoded -codepoint -from -the -given -byte -slice -. -/ -/ -/ -/ -/ -/ -If -no -valid -encoding -of -a -codepoint -exists -at -the -beginning -of -the -given -/ -/ -/ -byte -slice -then -the -first -byte -is -returned -instead -. -/ -/ -/ -/ -/ -/ -This -returns -None -if -and -only -if -bytes -is -empty -. -/ -/ -/ -/ -/ -/ -This -never -panics -. -/ -/ -/ -/ -/ -/ -* -WARNING -* -: -This -is -not -designed -for -performance -. -If -you -' -re -looking -for -a -/ -/ -/ -fast -UTF -- -8 -decoder -this -is -not -it -. -If -you -feel -like -you -need -one -in -this -/ -/ -/ -crate -then -please -file -an -issue -and -discuss -your -use -case -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -decode -( -bytes -: -& -[ -u8 -] -) -- -> -Option -< -Result -< -char -u8 -> -> -{ -if -bytes -. -is_empty -( -) -{ -return -None -; -} -let -len -= -match -len -( -bytes -[ -0 -] -) -{ -None -= -> -return -Some -( -Err -( -bytes -[ -0 -] -) -) -Some -( -len -) -if -len -> -bytes -. -len -( -) -= -> -return -Some -( -Err -( -bytes -[ -0 -] -) -) -Some -( -1 -) -= -> -return -Some -( -Ok -( -char -: -: -from -( -bytes -[ -0 -] -) -) -) -Some -( -len -) -= -> -len -} -; -match -core -: -: -str -: -: -from_utf8 -( -& -bytes -[ -. -. -len -] -) -{ -Ok -( -s -) -= -> -Some -( -Ok -( -s -. -chars -( -) -. -next -( -) -. -unwrap -( -) -) -) -Err -( -_ -) -= -> -Some -( -Err -( -bytes -[ -0 -] -) -) -} -} -/ -/ -/ -Decodes -the -last -UTF -- -8 -encoded -codepoint -from -the -given -byte -slice -. -/ -/ -/ -/ -/ -/ -If -no -valid -encoding -of -a -codepoint -exists -at -the -end -of -the -given -byte -/ -/ -/ -slice -then -the -last -byte -is -returned -instead -. -/ -/ -/ -/ -/ -/ -This -returns -None -if -and -only -if -bytes -is -empty -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -decode_last -( -bytes -: -& -[ -u8 -] -) -- -> -Option -< -Result -< -char -u8 -> -> -{ -if -bytes -. -is_empty -( -) -{ -return -None -; -} -let -mut -start -= -bytes -. -len -( -) -- -1 -; -let -limit -= -bytes -. -len -( -) -. -saturating_sub -( -4 -) -; -while -start -> -limit -& -& -! -is_leading_or_invalid_byte -( -bytes -[ -start -] -) -{ -start -- -= -1 -; -} -match -decode -( -& -bytes -[ -start -. -. -] -) -{ -None -= -> -None -Some -( -Ok -( -ch -) -) -= -> -Some -( -Ok -( -ch -) -) -Some -( -Err -( -_ -) -) -= -> -Some -( -Err -( -bytes -[ -bytes -. -len -( -) -- -1 -] -) -) -} -} -/ -/ -/ -Given -a -UTF -- -8 -leading -byte -this -returns -the -total -number -of -code -units -/ -/ -/ -in -the -following -encoded -codepoint -. -/ -/ -/ -/ -/ -/ -If -the -given -byte -is -not -a -valid -UTF -- -8 -leading -byte -then -this -returns -/ -/ -/ -None -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -len -( -byte -: -u8 -) -- -> -Option -< -usize -> -{ -if -byte -< -= -0x7F -{ -return -Some -( -1 -) -; -} -else -if -byte -& -0b1100_0000 -= -= -0b1000_0000 -{ -return -None -; -} -else -if -byte -< -= -0b1101_1111 -{ -Some -( -2 -) -} -else -if -byte -< -= -0b1110_1111 -{ -Some -( -3 -) -} -else -if -byte -< -= -0b1111_0111 -{ -Some -( -4 -) -} -else -{ -None -} -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -offset -in -the -given -bytes -falls -on -a -/ -/ -/ -valid -UTF -- -8 -encoded -codepoint -boundary -. -/ -/ -/ -/ -/ -/ -If -bytes -is -not -valid -UTF -- -8 -then -the -behavior -of -this -routine -is -/ -/ -/ -unspecified -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -is_boundary -( -bytes -: -& -[ -u8 -] -i -: -usize -) -- -> -bool -{ -match -bytes -. -get -( -i -) -{ -/ -/ -The -position -at -the -end -of -the -bytes -always -represents -an -empty -/ -/ -string -which -is -a -valid -boundary -. -But -anything -after -that -doesn -' -t -/ -/ -make -much -sense -to -call -valid -a -boundary -. -None -= -> -i -= -= -bytes -. -len -( -) -/ -/ -Other -than -ASCII -( -where -the -most -significant -bit -is -never -set -) -/ -/ -valid -starting -bytes -always -have -their -most -significant -two -bits -/ -/ -set -where -as -continuation -bytes -never -have -their -second -most -/ -/ -significant -bit -set -. -Therefore -this -only -returns -true -when -bytes -[ -i -] -/ -/ -corresponds -to -a -byte -that -begins -a -valid -UTF -- -8 -encoding -of -a -/ -/ -Unicode -scalar -value -. -Some -( -& -b -) -= -> -b -< -= -0b0111_1111 -| -| -b -> -= -0b1100_0000 -} -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -byte -is -either -a -valid -leading -UTF -- -8 -/ -/ -/ -byte -or -is -otherwise -an -invalid -byte -that -can -never -appear -anywhere -in -a -/ -/ -/ -valid -UTF -- -8 -sequence -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -fn -is_leading_or_invalid_byte -( -b -: -u8 -) -- -> -bool -{ -/ -/ -In -the -ASCII -case -the -most -significant -bit -is -never -set -. -The -leading -/ -/ -byte -of -a -2 -/ -3 -/ -4 -- -byte -sequence -always -has -the -top -two -most -significant -/ -/ -bits -set -. -For -bytes -that -can -never -appear -anywhere -in -valid -UTF -- -8 -this -/ -/ -also -returns -true -since -every -such -byte -has -its -two -most -significant -/ -/ -bits -set -: -/ -/ -/ -/ -\ -xC0 -: -: -11000000 -/ -/ -\ -xC1 -: -: -11000001 -/ -/ -\ -xF5 -: -: -11110101 -/ -/ -\ -xF6 -: -: -11110110 -/ -/ -\ -xF7 -: -: -11110111 -/ -/ -\ -xF8 -: -: -11111000 -/ -/ -\ -xF9 -: -: -11111001 -/ -/ -\ -xFA -: -: -11111010 -/ -/ -\ -xFB -: -: -11111011 -/ -/ -\ -xFC -: -: -11111100 -/ -/ -\ -xFD -: -: -11111101 -/ -/ -\ -xFE -: -: -11111110 -/ -/ -\ -xFF -: -: -11111111 -( -b -& -0b1100_0000 -) -! -= -0b1000_0000 -} -/ -* -/ -/ -/ -Returns -the -smallest -possible -index -of -the -next -valid -UTF -- -8 -sequence -/ -/ -/ -starting -after -i -. -/ -/ -/ -/ -/ -/ -For -all -inputs -including -invalid -UTF -- -8 -and -any -value -of -i -the -return -/ -/ -/ -value -is -guaranteed -to -be -greater -than -i -. -( -If -there -is -no -value -greater -/ -/ -/ -than -i -that -fits -in -usize -then -this -panics -. -) -/ -/ -/ -/ -/ -/ -Generally -speaking -this -should -only -be -called -on -text -when -it -is -/ -/ -/ -permitted -to -assume -that -it -is -valid -UTF -- -8 -and -where -either -i -> -= -/ -/ -/ -text -. -len -( -) -or -where -text -[ -i -] -is -a -leading -byte -of -a -UTF -- -8 -sequence -. -/ -/ -/ -/ -/ -/ -NOTE -: -This -method -was -used -in -a -previous -conception -of -iterators -where -we -/ -/ -/ -specifically -tried -to -skip -over -empty -matches -that -split -a -codepoint -by -/ -/ -/ -simply -requiring -that -our -next -search -begin -at -the -beginning -of -codepoint -. -/ -/ -/ -But -we -ended -up -changing -that -technique -to -always -advance -by -1 -byte -and -/ -/ -/ -then -filter -out -matches -that -split -a -codepoint -after -- -the -- -fact -. -Thus -we -no -/ -/ -/ -longer -use -this -method -. -But -I -' -ve -kept -it -around -in -case -we -want -to -switch -/ -/ -/ -back -to -this -approach -. -Its -guarantees -are -a -little -subtle -so -I -' -d -prefer -/ -/ -/ -not -to -rebuild -it -from -whole -cloth -. -pub -( -crate -) -fn -next -( -text -: -& -[ -u8 -] -i -: -usize -) -- -> -usize -{ -let -b -= -match -text -. -get -( -i -) -{ -None -= -> -return -i -. -checked_add -( -1 -) -. -unwrap -( -) -Some -( -& -b -) -= -> -b -} -; -/ -/ -For -cases -where -we -see -an -invalid -UTF -- -8 -byte -there -isn -' -t -much -we -can -do -/ -/ -other -than -just -start -at -the -next -byte -. -let -inc -= -len -( -b -) -. -unwrap_or -( -1 -) -; -i -. -checked_add -( -inc -) -. -unwrap -( -) -} -* -/ diff --git a/third_party/rust/regex-automata/src/util/wire.rs b/third_party/rust/regex-automata/src/util/wire.rs deleted file mode 100644 index 1d36e4e28d5b4..0000000000000 --- a/third_party/rust/regex-automata/src/util/wire.rs +++ /dev/null @@ -1,8615 +0,0 @@ -/ -* -! -Types -and -routines -that -support -the -wire -format -of -finite -automata -. -Currently -this -module -just -exports -a -few -error -types -and -some -small -helpers -for -deserializing -[ -dense -DFAs -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -using -correct -alignment -. -* -/ -/ -* -A -collection -of -helper -functions -types -and -traits -for -serializing -automata -. -This -crate -defines -its -own -bespoke -serialization -mechanism -for -some -structures -provided -in -the -public -API -namely -DFAs -. -A -bespoke -mechanism -was -developed -primarily -because -structures -like -automata -demand -a -specific -binary -format -. -Attempting -to -encode -their -rich -structure -in -an -existing -serialization -format -is -just -not -feasible -. -Moreover -the -format -for -each -structure -is -generally -designed -such -that -deserialization -is -cheap -. -More -specifically -that -deserialization -can -be -done -in -constant -time -. -( -The -idea -being -that -you -can -embed -it -into -your -binary -or -mmap -it -and -then -use -it -immediately -. -) -In -order -to -achieve -this -the -dense -and -sparse -DFAs -in -this -crate -use -an -in -- -memory -representation -that -very -closely -corresponds -to -its -binary -serialized -form -. -This -pervades -and -complicates -everything -and -in -some -cases -requires -dealing -with -alignment -and -reasoning -about -safety -. -This -technique -does -have -major -advantages -. -In -particular -it -permits -doing -the -potentially -costly -work -of -compiling -a -finite -state -machine -in -an -offline -manner -and -then -loading -it -at -runtime -not -only -without -having -to -re -- -compile -the -regex -but -even -without -the -code -required -to -do -the -compilation -. -This -for -example -permits -one -to -use -a -pre -- -compiled -DFA -not -only -in -environments -without -Rust -' -s -standard -library -but -also -in -environments -without -a -heap -. -In -the -code -below -whenever -we -insert -some -kind -of -padding -it -' -s -to -enforce -a -4 -- -byte -alignment -unless -otherwise -noted -. -Namely -u32 -is -the -only -state -ID -type -supported -. -( -In -a -previous -version -of -this -library -DFAs -were -generic -over -the -state -ID -representation -. -) -Also -serialization -generally -requires -the -caller -to -specify -endianness -where -as -deserialization -always -assumes -native -endianness -( -otherwise -cheap -deserialization -would -be -impossible -) -. -This -implies -that -serializing -a -structure -generally -requires -serializing -both -its -big -- -endian -and -little -- -endian -variants -and -then -loading -the -correct -one -based -on -the -target -' -s -endianness -. -* -/ -use -core -: -: -{ -cmp -convert -: -: -{ -TryFrom -TryInto -} -mem -: -: -size_of -} -; -# -[ -cfg -( -feature -= -" -alloc -" -) -] -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -util -: -: -{ -int -: -: -Pointer -primitives -: -: -{ -PatternID -PatternIDError -StateID -StateIDError -} -} -; -/ -/ -/ -A -hack -to -align -a -smaller -type -B -with -a -bigger -type -T -. -/ -/ -/ -/ -/ -/ -The -usual -use -of -this -is -with -B -= -[ -u8 -] -and -T -= -u32 -. -That -is -/ -/ -/ -it -permits -aligning -a -sequence -of -bytes -on -a -4 -- -byte -boundary -. -This -/ -/ -/ -is -useful -in -contexts -where -one -wants -to -embed -a -serialized -[ -dense -/ -/ -/ -DFA -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -) -into -a -Rust -a -program -while -guaranteeing -the -/ -/ -/ -alignment -required -for -the -DFA -. -/ -/ -/ -/ -/ -/ -See -[ -dense -: -: -DFA -: -: -from_bytes -] -( -crate -: -: -dfa -: -: -dense -: -: -DFA -: -: -from_bytes -) -for -an -/ -/ -/ -example -of -how -to -use -this -type -. -# -[ -repr -( -C -) -] -# -[ -derive -( -Debug -) -] -pub -struct -AlignAs -< -B -: -? -Sized -T -> -{ -/ -/ -/ -A -zero -- -sized -field -indicating -the -alignment -we -want -. -pub -_align -: -[ -T -; -0 -] -/ -/ -/ -A -possibly -non -- -sized -field -containing -a -sequence -of -bytes -. -pub -bytes -: -B -} -/ -/ -/ -An -error -that -occurs -when -serializing -an -object -from -this -crate -. -/ -/ -/ -/ -/ -/ -Serialization -as -used -in -this -crate -universally -refers -to -the -process -/ -/ -/ -of -transforming -a -structure -( -like -a -DFA -) -into -a -custom -binary -format -/ -/ -/ -represented -by -& -[ -u8 -] -. -To -this -end -serialization -is -generally -infallible -. -/ -/ -/ -However -it -can -fail -when -caller -provided -buffer -sizes -are -too -small -. -When -/ -/ -/ -that -occurs -a -serialization -error -is -reported -. -/ -/ -/ -/ -/ -/ -A -SerializeError -provides -no -introspection -capabilities -. -Its -only -/ -/ -/ -supported -operation -is -conversion -to -a -human -readable -error -message -. -/ -/ -/ -/ -/ -/ -This -error -type -implements -the -std -: -: -error -: -: -Error -trait -only -when -the -/ -/ -/ -std -feature -is -enabled -. -Otherwise -this -type -is -defined -in -all -/ -/ -/ -configurations -. -# -[ -derive -( -Debug -) -] -pub -struct -SerializeError -{ -/ -/ -/ -The -name -of -the -thing -that -a -buffer -is -too -small -for -. -/ -/ -/ -/ -/ -/ -Currently -the -only -kind -of -serialization -error -is -one -that -is -/ -/ -/ -committed -by -a -caller -: -providing -a -destination -buffer -that -is -too -/ -/ -/ -small -to -fit -the -serialized -object -. -This -makes -sense -conceptually -/ -/ -/ -since -every -valid -inhabitant -of -a -type -should -be -serializable -. -/ -/ -/ -/ -/ -/ -This -is -somewhat -exposed -in -the -public -API -of -this -crate -. -For -example -/ -/ -/ -the -to_bytes_ -{ -big -little -} -_endian -APIs -return -a -Vec -< -u8 -> -and -are -/ -/ -/ -guaranteed -to -never -panic -or -error -. -This -is -only -possible -because -the -/ -/ -/ -implementation -guarantees -that -it -will -allocate -a -Vec -< -u8 -> -that -is -/ -/ -/ -big -enough -. -/ -/ -/ -/ -/ -/ -In -summary -if -a -new -serialization -error -kind -needs -to -be -added -then -/ -/ -/ -it -will -need -careful -consideration -. -what -: -& -' -static -str -} -impl -SerializeError -{ -pub -( -crate -) -fn -buffer_too_small -( -what -: -& -' -static -str -) -- -> -SerializeError -{ -SerializeError -{ -what -} -} -} -impl -core -: -: -fmt -: -: -Display -for -SerializeError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -destination -buffer -is -too -small -to -write -{ -} -" -self -. -what -) -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -SerializeError -{ -} -/ -/ -/ -An -error -that -occurs -when -deserializing -an -object -defined -in -this -crate -. -/ -/ -/ -/ -/ -/ -Serialization -as -used -in -this -crate -universally -refers -to -the -process -/ -/ -/ -of -transforming -a -structure -( -like -a -DFA -) -into -a -custom -binary -format -/ -/ -/ -represented -by -& -[ -u8 -] -. -Deserialization -then -refers -to -the -process -of -/ -/ -/ -cheaply -converting -this -binary -format -back -to -the -object -' -s -in -- -memory -/ -/ -/ -representation -as -defined -in -this -crate -. -To -the -extent -possible -/ -/ -/ -deserialization -will -report -this -error -whenever -this -process -fails -. -/ -/ -/ -/ -/ -/ -A -DeserializeError -provides -no -introspection -capabilities -. -Its -only -/ -/ -/ -supported -operation -is -conversion -to -a -human -readable -error -message -. -/ -/ -/ -/ -/ -/ -This -error -type -implements -the -std -: -: -error -: -: -Error -trait -only -when -the -/ -/ -/ -std -feature -is -enabled -. -Otherwise -this -type -is -defined -in -all -/ -/ -/ -configurations -. -# -[ -derive -( -Debug -) -] -pub -struct -DeserializeError -( -DeserializeErrorKind -) -; -# -[ -derive -( -Debug -) -] -enum -DeserializeErrorKind -{ -Generic -{ -msg -: -& -' -static -str -} -BufferTooSmall -{ -what -: -& -' -static -str -} -InvalidUsize -{ -what -: -& -' -static -str -} -VersionMismatch -{ -expected -: -u32 -found -: -u32 -} -EndianMismatch -{ -expected -: -u32 -found -: -u32 -} -AlignmentMismatch -{ -alignment -: -usize -address -: -usize -} -LabelMismatch -{ -expected -: -& -' -static -str -} -ArithmeticOverflow -{ -what -: -& -' -static -str -} -PatternID -{ -err -: -PatternIDError -what -: -& -' -static -str -} -StateID -{ -err -: -StateIDError -what -: -& -' -static -str -} -} -impl -DeserializeError -{ -pub -( -crate -) -fn -generic -( -msg -: -& -' -static -str -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -Generic -{ -msg -} -) -} -pub -( -crate -) -fn -buffer_too_small -( -what -: -& -' -static -str -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -BufferTooSmall -{ -what -} -) -} -fn -invalid_usize -( -what -: -& -' -static -str -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -InvalidUsize -{ -what -} -) -} -fn -version_mismatch -( -expected -: -u32 -found -: -u32 -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -VersionMismatch -{ -expected -found -} -) -} -fn -endian_mismatch -( -expected -: -u32 -found -: -u32 -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -EndianMismatch -{ -expected -found -} -) -} -fn -alignment_mismatch -( -alignment -: -usize -address -: -usize -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -AlignmentMismatch -{ -alignment -address -} -) -} -fn -label_mismatch -( -expected -: -& -' -static -str -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -LabelMismatch -{ -expected -} -) -} -fn -arithmetic_overflow -( -what -: -& -' -static -str -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -ArithmeticOverflow -{ -what -} -) -} -fn -pattern_id_error -( -err -: -PatternIDError -what -: -& -' -static -str -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -PatternID -{ -err -what -} -) -} -pub -( -crate -) -fn -state_id_error -( -err -: -StateIDError -what -: -& -' -static -str -) -- -> -DeserializeError -{ -DeserializeError -( -DeserializeErrorKind -: -: -StateID -{ -err -what -} -) -} -} -# -[ -cfg -( -feature -= -" -std -" -) -] -impl -std -: -: -error -: -: -Error -for -DeserializeError -{ -} -impl -core -: -: -fmt -: -: -Display -for -DeserializeError -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -use -self -: -: -DeserializeErrorKind -: -: -* -; -match -self -. -0 -{ -Generic -{ -msg -} -= -> -write -! -( -f -" -{ -} -" -msg -) -BufferTooSmall -{ -what -} -= -> -{ -write -! -( -f -" -buffer -is -too -small -to -read -{ -} -" -what -) -} -InvalidUsize -{ -what -} -= -> -{ -write -! -( -f -" -{ -} -is -too -big -to -fit -in -a -usize -" -what -) -} -VersionMismatch -{ -expected -found -} -= -> -write -! -( -f -" -unsupported -version -: -\ -expected -version -{ -} -but -found -version -{ -} -" -expected -found -) -EndianMismatch -{ -expected -found -} -= -> -write -! -( -f -" -endianness -mismatch -: -expected -0x -{ -: -X -} -but -got -0x -{ -: -X -} -. -\ -( -Are -you -trying -to -load -an -object -serialized -with -a -\ -different -endianness -? -) -" -expected -found -) -AlignmentMismatch -{ -alignment -address -} -= -> -write -! -( -f -" -alignment -mismatch -: -slice -starts -at -address -\ -0x -{ -: -X -} -which -is -not -aligned -to -a -{ -} -byte -boundary -" -address -alignment -) -LabelMismatch -{ -expected -} -= -> -write -! -( -f -" -label -mismatch -: -start -of -serialized -object -should -\ -contain -a -NUL -terminated -{ -: -? -} -label -but -a -different -\ -label -was -found -" -expected -) -ArithmeticOverflow -{ -what -} -= -> -{ -write -! -( -f -" -arithmetic -overflow -for -{ -} -" -what -) -} -PatternID -{ -ref -err -what -} -= -> -{ -write -! -( -f -" -failed -to -read -pattern -ID -for -{ -} -: -{ -} -" -what -err -) -} -StateID -{ -ref -err -what -} -= -> -{ -write -! -( -f -" -failed -to -read -state -ID -for -{ -} -: -{ -} -" -what -err -) -} -} -} -} -/ -/ -/ -Safely -converts -a -& -[ -u32 -] -to -& -[ -StateID -] -with -zero -cost -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -u32s_to_state_ids -( -slice -: -& -[ -u32 -] -) -- -> -& -[ -StateID -] -{ -/ -/ -SAFETY -: -This -is -safe -because -StateID -is -defined -to -have -the -same -memory -/ -/ -representation -as -a -u32 -( -it -is -repr -( -transparent -) -) -. -While -not -every -u32 -/ -/ -is -a -" -valid -" -StateID -callers -are -not -permitted -to -rely -on -the -validity -/ -/ -of -StateIDs -for -memory -safety -. -It -can -only -lead -to -logical -errors -. -( -This -/ -/ -is -why -StateID -: -: -new_unchecked -is -safe -. -) -unsafe -{ -core -: -: -slice -: -: -from_raw_parts -( -slice -. -as_ptr -( -) -. -cast -: -: -< -StateID -> -( -) -slice -. -len -( -) -) -} -} -/ -/ -/ -Safely -converts -a -& -mut -[ -u32 -] -to -& -mut -[ -StateID -] -with -zero -cost -. -pub -( -crate -) -fn -u32s_to_state_ids_mut -( -slice -: -& -mut -[ -u32 -] -) -- -> -& -mut -[ -StateID -] -{ -/ -/ -SAFETY -: -This -is -safe -because -StateID -is -defined -to -have -the -same -memory -/ -/ -representation -as -a -u32 -( -it -is -repr -( -transparent -) -) -. -While -not -every -u32 -/ -/ -is -a -" -valid -" -StateID -callers -are -not -permitted -to -rely -on -the -validity -/ -/ -of -StateIDs -for -memory -safety -. -It -can -only -lead -to -logical -errors -. -( -This -/ -/ -is -why -StateID -: -: -new_unchecked -is -safe -. -) -unsafe -{ -core -: -: -slice -: -: -from_raw_parts_mut -( -slice -. -as_mut_ptr -( -) -. -cast -: -: -< -StateID -> -( -) -slice -. -len -( -) -) -} -} -/ -/ -/ -Safely -converts -a -& -[ -u32 -] -to -& -[ -PatternID -] -with -zero -cost -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -u32s_to_pattern_ids -( -slice -: -& -[ -u32 -] -) -- -> -& -[ -PatternID -] -{ -/ -/ -SAFETY -: -This -is -safe -because -PatternID -is -defined -to -have -the -same -/ -/ -memory -representation -as -a -u32 -( -it -is -repr -( -transparent -) -) -. -While -not -/ -/ -every -u32 -is -a -" -valid -" -PatternID -callers -are -not -permitted -to -rely -/ -/ -on -the -validity -of -PatternIDs -for -memory -safety -. -It -can -only -lead -to -/ -/ -logical -errors -. -( -This -is -why -PatternID -: -: -new_unchecked -is -safe -. -) -unsafe -{ -core -: -: -slice -: -: -from_raw_parts -( -slice -. -as_ptr -( -) -. -cast -: -: -< -PatternID -> -( -) -slice -. -len -( -) -) -} -} -/ -/ -/ -Checks -that -the -given -slice -has -an -alignment -that -matches -T -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -checking -that -a -slice -has -an -appropriate -alignment -/ -/ -/ -before -casting -it -to -a -& -[ -T -] -. -Note -though -that -alignment -is -not -itself -/ -/ -/ -sufficient -to -perform -the -cast -for -any -T -. -pub -( -crate -) -fn -check_alignment -< -T -> -( -slice -: -& -[ -u8 -] -) -- -> -Result -< -( -) -DeserializeError -> -{ -let -alignment -= -core -: -: -mem -: -: -align_of -: -: -< -T -> -( -) -; -let -address -= -slice -. -as_ptr -( -) -. -as_usize -( -) -; -if -address -% -alignment -= -= -0 -{ -return -Ok -( -( -) -) -; -} -Err -( -DeserializeError -: -: -alignment_mismatch -( -alignment -address -) -) -} -/ -/ -/ -Reads -a -possibly -empty -amount -of -padding -up -to -7 -bytes -from -the -beginning -/ -/ -/ -of -the -given -slice -. -All -padding -bytes -must -be -NUL -bytes -. -/ -/ -/ -/ -/ -/ -This -is -useful -because -it -can -be -theoretically -necessary -to -pad -the -/ -/ -/ -beginning -of -a -serialized -object -with -NUL -bytes -to -ensure -that -it -starts -/ -/ -/ -at -a -correctly -aligned -address -. -These -padding -bytes -should -come -immediately -/ -/ -/ -before -the -label -. -/ -/ -/ -/ -/ -/ -This -returns -the -number -of -bytes -read -from -the -given -slice -. -pub -( -crate -) -fn -skip_initial_padding -( -slice -: -& -[ -u8 -] -) -- -> -usize -{ -let -mut -nread -= -0 -; -while -nread -< -7 -& -& -nread -< -slice -. -len -( -) -& -& -slice -[ -nread -] -= -= -0 -{ -nread -+ -= -1 -; -} -nread -} -/ -/ -/ -Allocate -a -byte -buffer -of -the -given -size -along -with -some -initial -padding -/ -/ -/ -such -that -buf -[ -padding -. -. -] -has -the -same -alignment -as -T -where -the -/ -/ -/ -alignment -of -T -must -be -at -most -8 -. -In -particular -callers -should -treat -/ -/ -/ -the -first -N -bytes -( -second -return -value -) -as -padding -bytes -that -must -not -be -/ -/ -/ -overwritten -. -In -all -cases -the -following -identity -holds -: -/ -/ -/ -/ -/ -/ -ignore -/ -/ -/ -let -( -buf -padding -) -= -alloc_aligned_buffer -: -: -< -StateID -> -( -SIZE -) -; -/ -/ -/ -assert_eq -! -( -SIZE -buf -[ -padding -. -. -] -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -In -practice -padding -is -often -zero -. -/ -/ -/ -/ -/ -/ -The -requirement -for -8 -as -a -maximum -here -is -somewhat -arbitrary -. -In -/ -/ -/ -practice -we -never -need -anything -bigger -in -this -crate -and -so -this -function -/ -/ -/ -does -some -sanity -asserts -under -the -assumption -of -a -max -alignment -of -8 -. -# -[ -cfg -( -feature -= -" -alloc -" -) -] -pub -( -crate -) -fn -alloc_aligned_buffer -< -T -> -( -size -: -usize -) -- -> -( -Vec -< -u8 -> -usize -) -{ -/ -/ -NOTE -: -This -is -a -kludge -because -there -' -s -no -easy -way -to -allocate -a -Vec -< -u8 -> -/ -/ -with -an -alignment -guaranteed -to -be -greater -than -1 -. -We -could -create -a -/ -/ -Vec -< -u32 -> -but -this -cannot -be -safely -transmuted -to -a -Vec -< -u8 -> -without -/ -/ -concern -since -reallocing -or -dropping -the -Vec -< -u8 -> -is -UB -( -different -/ -/ -alignment -than -the -initial -allocation -) -. -We -could -define -a -wrapper -type -/ -/ -to -manage -this -for -us -but -it -seems -like -more -machinery -than -it -' -s -worth -. -let -buf -= -vec -! -[ -0 -; -size -] -; -let -align -= -core -: -: -mem -: -: -align_of -: -: -< -T -> -( -) -; -let -address -= -buf -. -as_ptr -( -) -. -as_usize -( -) -; -if -address -% -align -= -= -0 -{ -return -( -buf -0 -) -; -} -/ -/ -Let -' -s -try -this -again -. -We -have -to -create -a -totally -new -alloc -with -/ -/ -the -maximum -amount -of -bytes -we -might -need -. -We -can -' -t -just -extend -our -/ -/ -pre -- -existing -' -buf -' -because -that -might -create -a -new -alloc -with -a -/ -/ -different -alignment -. -let -extra -= -align -- -1 -; -let -mut -buf -= -vec -! -[ -0 -; -size -+ -extra -] -; -let -address -= -buf -. -as_ptr -( -) -. -as_usize -( -) -; -/ -/ -The -code -below -handles -the -case -where -' -address -' -is -aligned -to -T -so -if -/ -/ -we -got -lucky -and -' -address -' -is -now -aligned -to -T -( -when -it -previously -/ -/ -wasn -' -t -) -then -we -' -re -done -. -if -address -% -align -= -= -0 -{ -buf -. -truncate -( -size -) -; -return -( -buf -0 -) -; -} -let -padding -= -( -( -address -& -! -( -align -- -1 -) -) -. -checked_add -( -align -) -. -unwrap -( -) -) -. -checked_sub -( -address -) -. -unwrap -( -) -; -assert -! -( -padding -< -= -7 -" -padding -of -{ -} -is -bigger -than -7 -" -padding -) -; -assert -! -( -padding -< -= -extra -" -padding -of -{ -} -is -bigger -than -extra -{ -} -bytes -" -padding -extra -) -; -buf -. -truncate -( -size -+ -padding -) -; -assert_eq -! -( -size -+ -padding -buf -. -len -( -) -) -; -assert_eq -! -( -0 -buf -[ -padding -. -. -] -. -as_ptr -( -) -. -as_usize -( -) -% -align -" -expected -end -of -initial -padding -to -be -aligned -to -{ -} -" -align -) -; -( -buf -padding -) -} -/ -/ -/ -Reads -a -NUL -terminated -label -starting -at -the -beginning -of -the -given -slice -. -/ -/ -/ -/ -/ -/ -If -a -NUL -terminated -label -could -not -be -found -then -an -error -is -returned -. -/ -/ -/ -Similarly -if -a -label -is -found -but -doesn -' -t -match -the -expected -label -then -/ -/ -/ -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -Upon -success -the -total -number -of -bytes -read -( -including -padding -bytes -) -is -/ -/ -/ -returned -. -pub -( -crate -) -fn -read_label -( -slice -: -& -[ -u8 -] -expected_label -: -& -' -static -str -) -- -> -Result -< -usize -DeserializeError -> -{ -/ -/ -Set -an -upper -bound -on -how -many -bytes -we -scan -for -a -NUL -. -Since -no -label -/ -/ -in -this -crate -is -longer -than -256 -bytes -if -we -can -' -t -find -one -within -that -/ -/ -range -then -we -have -corrupted -data -. -let -first_nul -= -slice -[ -. -. -cmp -: -: -min -( -slice -. -len -( -) -256 -) -] -. -iter -( -) -. -position -( -| -& -b -| -b -= -= -0 -) -; -let -first_nul -= -match -first_nul -{ -Some -( -first_nul -) -= -> -first_nul -None -= -> -{ -return -Err -( -DeserializeError -: -: -generic -( -" -could -not -find -NUL -terminated -label -\ -at -start -of -serialized -object -" -) -) -; -} -} -; -let -len -= -first_nul -+ -padding_len -( -first_nul -) -; -if -slice -. -len -( -) -< -len -{ -return -Err -( -DeserializeError -: -: -generic -( -" -could -not -find -properly -sized -label -at -start -of -serialized -object -" -) -) -; -} -if -expected_label -. -as_bytes -( -) -! -= -& -slice -[ -. -. -first_nul -] -{ -return -Err -( -DeserializeError -: -: -label_mismatch -( -expected_label -) -) -; -} -Ok -( -len -) -} -/ -/ -/ -Writes -the -given -label -to -the -buffer -as -a -NUL -terminated -string -. -The -label -/ -/ -/ -given -must -not -contain -NUL -otherwise -this -will -panic -. -Similarly -the -label -/ -/ -/ -must -not -be -longer -than -255 -bytes -otherwise -this -will -panic -. -/ -/ -/ -/ -/ -/ -Additional -NUL -bytes -are -written -as -necessary -to -ensure -that -the -number -of -/ -/ -/ -bytes -written -is -always -a -multiple -of -4 -. -/ -/ -/ -/ -/ -/ -Upon -success -the -total -number -of -bytes -written -( -including -padding -) -is -/ -/ -/ -returned -. -pub -( -crate -) -fn -write_label -( -label -: -& -str -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -write_label_len -( -label -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -label -" -) -) -; -} -dst -[ -. -. -label -. -len -( -) -] -. -copy_from_slice -( -label -. -as_bytes -( -) -) -; -for -i -in -0 -. -. -( -nwrite -- -label -. -len -( -) -) -{ -dst -[ -label -. -len -( -) -+ -i -] -= -0 -; -} -assert_eq -! -( -nwrite -% -4 -0 -) -; -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -total -number -of -bytes -( -including -padding -) -that -would -be -written -/ -/ -/ -for -the -given -label -. -This -panics -if -the -given -label -contains -a -NUL -byte -or -/ -/ -/ -is -longer -than -255 -bytes -. -( -The -size -restriction -exists -so -that -searching -/ -/ -/ -for -a -label -during -deserialization -can -be -done -in -small -bounded -space -. -) -pub -( -crate -) -fn -write_label_len -( -label -: -& -str -) -- -> -usize -{ -if -label -. -len -( -) -> -255 -{ -panic -! -( -" -label -must -not -be -longer -than -255 -bytes -" -) -; -} -if -label -. -as_bytes -( -) -. -iter -( -) -. -position -( -| -& -b -| -b -= -= -0 -) -. -is_some -( -) -{ -panic -! -( -" -label -must -not -contain -NUL -bytes -" -) -; -} -let -label_len -= -label -. -len -( -) -+ -1 -; -/ -/ -+ -1 -for -the -NUL -terminator -label_len -+ -padding_len -( -label_len -) -} -/ -/ -/ -Reads -the -endianness -check -from -the -beginning -of -the -given -slice -and -/ -/ -/ -confirms -that -the -endianness -of -the -serialized -object -matches -the -expected -/ -/ -/ -endianness -. -If -the -slice -is -too -small -or -if -the -endianness -check -fails -/ -/ -/ -this -returns -an -error -. -/ -/ -/ -/ -/ -/ -Upon -success -the -total -number -of -bytes -read -is -returned -. -pub -( -crate -) -fn -read_endianness_check -( -slice -: -& -[ -u8 -] -) -- -> -Result -< -usize -DeserializeError -> -{ -let -( -n -nr -) -= -try_read_u32 -( -slice -" -endianness -check -" -) -? -; -assert_eq -! -( -nr -write_endianness_check_len -( -) -) -; -if -n -! -= -0xFEFF -{ -return -Err -( -DeserializeError -: -: -endian_mismatch -( -0xFEFF -n -) -) -; -} -Ok -( -nr -) -} -/ -/ -/ -Writes -0xFEFF -as -an -integer -using -the -given -endianness -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -writing -into -the -header -of -a -serialized -object -. -It -can -/ -/ -/ -be -read -during -deserialization -as -a -sanity -check -to -ensure -the -proper -/ -/ -/ -endianness -is -used -. -/ -/ -/ -/ -/ -/ -Upon -success -the -total -number -of -bytes -written -is -returned -. -pub -( -crate -) -fn -write_endianness_check -< -E -: -Endian -> -( -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -write_endianness_check_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -endianness -check -" -) -) -; -} -E -: -: -write_u32 -( -0xFEFF -dst -) -; -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -number -of -bytes -written -by -the -endianness -check -. -pub -( -crate -) -fn -write_endianness_check_len -( -) -- -> -usize -{ -size_of -: -: -< -u32 -> -( -) -} -/ -/ -/ -Reads -a -version -number -from -the -beginning -of -the -given -slice -and -confirms -/ -/ -/ -that -is -matches -the -expected -version -number -given -. -If -the -slice -is -too -/ -/ -/ -small -or -if -the -version -numbers -aren -' -t -equivalent -this -returns -an -error -. -/ -/ -/ -/ -/ -/ -Upon -success -the -total -number -of -bytes -read -is -returned -. -/ -/ -/ -/ -/ -/ -N -. -B -. -Currently -we -require -that -the -version -number -is -exactly -equivalent -. -/ -/ -/ -In -the -future -if -we -bump -the -version -number -without -a -semver -bump -then -/ -/ -/ -we -' -ll -need -to -relax -this -a -bit -and -support -older -versions -. -pub -( -crate -) -fn -read_version -( -slice -: -& -[ -u8 -] -expected_version -: -u32 -) -- -> -Result -< -usize -DeserializeError -> -{ -let -( -n -nr -) -= -try_read_u32 -( -slice -" -version -" -) -? -; -assert_eq -! -( -nr -write_version_len -( -) -) -; -if -n -! -= -expected_version -{ -return -Err -( -DeserializeError -: -: -version_mismatch -( -expected_version -n -) -) -; -} -Ok -( -nr -) -} -/ -/ -/ -Writes -the -given -version -number -to -the -beginning -of -the -given -slice -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -writing -into -the -header -of -a -serialized -object -. -It -can -/ -/ -/ -be -read -during -deserialization -as -a -sanity -check -to -ensure -that -the -library -/ -/ -/ -code -supports -the -format -of -the -serialized -object -. -/ -/ -/ -/ -/ -/ -Upon -success -the -total -number -of -bytes -written -is -returned -. -pub -( -crate -) -fn -write_version -< -E -: -Endian -> -( -version -: -u32 -dst -: -& -mut -[ -u8 -] -) -- -> -Result -< -usize -SerializeError -> -{ -let -nwrite -= -write_version_len -( -) -; -if -dst -. -len -( -) -< -nwrite -{ -return -Err -( -SerializeError -: -: -buffer_too_small -( -" -version -number -" -) -) -; -} -E -: -: -write_u32 -( -version -dst -) -; -Ok -( -nwrite -) -} -/ -/ -/ -Returns -the -number -of -bytes -written -by -writing -the -version -number -. -pub -( -crate -) -fn -write_version_len -( -) -- -> -usize -{ -size_of -: -: -< -u32 -> -( -) -} -/ -/ -/ -Reads -a -pattern -ID -from -the -given -slice -. -If -the -slice -has -insufficient -/ -/ -/ -length -then -this -panics -. -If -the -deserialized -integer -exceeds -the -pattern -/ -/ -/ -ID -limit -for -the -current -target -then -this -returns -an -error -. -/ -/ -/ -/ -/ -/ -Upon -success -this -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -read_pattern_id -( -slice -: -& -[ -u8 -] -what -: -& -' -static -str -) -- -> -Result -< -( -PatternID -usize -) -DeserializeError -> -{ -let -bytes -: -[ -u8 -; -PatternID -: -: -SIZE -] -= -slice -[ -. -. -PatternID -: -: -SIZE -] -. -try_into -( -) -. -unwrap -( -) -; -let -pid -= -PatternID -: -: -from_ne_bytes -( -bytes -) -. -map_err -( -| -err -| -DeserializeError -: -: -pattern_id_error -( -err -what -) -) -? -; -Ok -( -( -pid -PatternID -: -: -SIZE -) -) -} -/ -/ -/ -Reads -a -pattern -ID -from -the -given -slice -. -If -the -slice -has -insufficient -/ -/ -/ -length -then -this -panics -. -Otherwise -the -deserialized -integer -is -assumed -/ -/ -/ -to -be -a -valid -pattern -ID -. -/ -/ -/ -/ -/ -/ -This -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -read_pattern_id_unchecked -( -slice -: -& -[ -u8 -] -) -- -> -( -PatternID -usize -) -{ -let -pid -= -PatternID -: -: -from_ne_bytes_unchecked -( -slice -[ -. -. -PatternID -: -: -SIZE -] -. -try_into -( -) -. -unwrap -( -) -) -; -( -pid -PatternID -: -: -SIZE -) -} -/ -/ -/ -Write -the -given -pattern -ID -to -the -beginning -of -the -given -slice -of -bytes -/ -/ -/ -using -the -specified -endianness -. -The -given -slice -must -have -length -at -least -/ -/ -/ -PatternID -: -: -SIZE -or -else -this -panics -. -Upon -success -the -total -number -of -/ -/ -/ -bytes -written -is -returned -. -pub -( -crate -) -fn -write_pattern_id -< -E -: -Endian -> -( -pid -: -PatternID -dst -: -& -mut -[ -u8 -] -) -- -> -usize -{ -E -: -: -write_u32 -( -pid -. -as_u32 -( -) -dst -) -; -PatternID -: -: -SIZE -} -/ -/ -/ -Attempts -to -read -a -state -ID -from -the -given -slice -. -If -the -slice -has -an -/ -/ -/ -insufficient -number -of -bytes -or -if -the -state -ID -exceeds -the -limit -for -/ -/ -/ -the -current -target -then -this -returns -an -error -. -/ -/ -/ -/ -/ -/ -Upon -success -this -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -try_read_state_id -( -slice -: -& -[ -u8 -] -what -: -& -' -static -str -) -- -> -Result -< -( -StateID -usize -) -DeserializeError -> -{ -if -slice -. -len -( -) -< -StateID -: -: -SIZE -{ -return -Err -( -DeserializeError -: -: -buffer_too_small -( -what -) -) -; -} -read_state_id -( -slice -what -) -} -/ -/ -/ -Reads -a -state -ID -from -the -given -slice -. -If -the -slice -has -insufficient -/ -/ -/ -length -then -this -panics -. -If -the -deserialized -integer -exceeds -the -state -ID -/ -/ -/ -limit -for -the -current -target -then -this -returns -an -error -. -/ -/ -/ -/ -/ -/ -Upon -success -this -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -read_state_id -( -slice -: -& -[ -u8 -] -what -: -& -' -static -str -) -- -> -Result -< -( -StateID -usize -) -DeserializeError -> -{ -let -bytes -: -[ -u8 -; -StateID -: -: -SIZE -] -= -slice -[ -. -. -StateID -: -: -SIZE -] -. -try_into -( -) -. -unwrap -( -) -; -let -sid -= -StateID -: -: -from_ne_bytes -( -bytes -) -. -map_err -( -| -err -| -DeserializeError -: -: -state_id_error -( -err -what -) -) -? -; -Ok -( -( -sid -StateID -: -: -SIZE -) -) -} -/ -/ -/ -Reads -a -state -ID -from -the -given -slice -. -If -the -slice -has -insufficient -/ -/ -/ -length -then -this -panics -. -Otherwise -the -deserialized -integer -is -assumed -/ -/ -/ -to -be -a -valid -state -ID -. -/ -/ -/ -/ -/ -/ -This -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -read_state_id_unchecked -( -slice -: -& -[ -u8 -] -) -- -> -( -StateID -usize -) -{ -let -sid -= -StateID -: -: -from_ne_bytes_unchecked -( -slice -[ -. -. -StateID -: -: -SIZE -] -. -try_into -( -) -. -unwrap -( -) -) -; -( -sid -StateID -: -: -SIZE -) -} -/ -/ -/ -Write -the -given -state -ID -to -the -beginning -of -the -given -slice -of -bytes -/ -/ -/ -using -the -specified -endianness -. -The -given -slice -must -have -length -at -least -/ -/ -/ -StateID -: -: -SIZE -or -else -this -panics -. -Upon -success -the -total -number -of -/ -/ -/ -bytes -written -is -returned -. -pub -( -crate -) -fn -write_state_id -< -E -: -Endian -> -( -sid -: -StateID -dst -: -& -mut -[ -u8 -] -) -- -> -usize -{ -E -: -: -write_u32 -( -sid -. -as_u32 -( -) -dst -) -; -StateID -: -: -SIZE -} -/ -/ -/ -Try -to -read -a -u16 -as -a -usize -from -the -beginning -of -the -given -slice -in -/ -/ -/ -native -endian -format -. -If -the -slice -has -fewer -than -2 -bytes -or -if -the -/ -/ -/ -deserialized -number -cannot -be -represented -by -usize -then -this -returns -an -/ -/ -/ -error -. -The -error -message -will -include -the -what -description -of -what -is -/ -/ -/ -being -deserialized -for -better -error -messages -. -what -should -be -a -noun -in -/ -/ -/ -singular -form -. -/ -/ -/ -/ -/ -/ -Upon -success -this -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -try_read_u16_as_usize -( -slice -: -& -[ -u8 -] -what -: -& -' -static -str -) -- -> -Result -< -( -usize -usize -) -DeserializeError -> -{ -try_read_u16 -( -slice -what -) -. -and_then -( -| -( -n -nr -) -| -{ -usize -: -: -try_from -( -n -) -. -map -( -| -n -| -( -n -nr -) -) -. -map_err -( -| -_ -| -DeserializeError -: -: -invalid_usize -( -what -) -) -} -) -} -/ -/ -/ -Try -to -read -a -u32 -as -a -usize -from -the -beginning -of -the -given -slice -in -/ -/ -/ -native -endian -format -. -If -the -slice -has -fewer -than -4 -bytes -or -if -the -/ -/ -/ -deserialized -number -cannot -be -represented -by -usize -then -this -returns -an -/ -/ -/ -error -. -The -error -message -will -include -the -what -description -of -what -is -/ -/ -/ -being -deserialized -for -better -error -messages -. -what -should -be -a -noun -in -/ -/ -/ -singular -form -. -/ -/ -/ -/ -/ -/ -Upon -success -this -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -try_read_u32_as_usize -( -slice -: -& -[ -u8 -] -what -: -& -' -static -str -) -- -> -Result -< -( -usize -usize -) -DeserializeError -> -{ -try_read_u32 -( -slice -what -) -. -and_then -( -| -( -n -nr -) -| -{ -usize -: -: -try_from -( -n -) -. -map -( -| -n -| -( -n -nr -) -) -. -map_err -( -| -_ -| -DeserializeError -: -: -invalid_usize -( -what -) -) -} -) -} -/ -/ -/ -Try -to -read -a -u16 -from -the -beginning -of -the -given -slice -in -native -endian -/ -/ -/ -format -. -If -the -slice -has -fewer -than -2 -bytes -then -this -returns -an -error -. -/ -/ -/ -The -error -message -will -include -the -what -description -of -what -is -being -/ -/ -/ -deserialized -for -better -error -messages -. -what -should -be -a -noun -in -/ -/ -/ -singular -form -. -/ -/ -/ -/ -/ -/ -Upon -success -this -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -try_read_u16 -( -slice -: -& -[ -u8 -] -what -: -& -' -static -str -) -- -> -Result -< -( -u16 -usize -) -DeserializeError -> -{ -check_slice_len -( -slice -size_of -: -: -< -u16 -> -( -) -what -) -? -; -Ok -( -( -read_u16 -( -slice -) -size_of -: -: -< -u16 -> -( -) -) -) -} -/ -/ -/ -Try -to -read -a -u32 -from -the -beginning -of -the -given -slice -in -native -endian -/ -/ -/ -format -. -If -the -slice -has -fewer -than -4 -bytes -then -this -returns -an -error -. -/ -/ -/ -The -error -message -will -include -the -what -description -of -what -is -being -/ -/ -/ -deserialized -for -better -error -messages -. -what -should -be -a -noun -in -/ -/ -/ -singular -form -. -/ -/ -/ -/ -/ -/ -Upon -success -this -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -try_read_u32 -( -slice -: -& -[ -u8 -] -what -: -& -' -static -str -) -- -> -Result -< -( -u32 -usize -) -DeserializeError -> -{ -check_slice_len -( -slice -size_of -: -: -< -u32 -> -( -) -what -) -? -; -Ok -( -( -read_u32 -( -slice -) -size_of -: -: -< -u32 -> -( -) -) -) -} -/ -/ -/ -Try -to -read -a -u128 -from -the -beginning -of -the -given -slice -in -native -endian -/ -/ -/ -format -. -If -the -slice -has -fewer -than -16 -bytes -then -this -returns -an -error -. -/ -/ -/ -The -error -message -will -include -the -what -description -of -what -is -being -/ -/ -/ -deserialized -for -better -error -messages -. -what -should -be -a -noun -in -/ -/ -/ -singular -form -. -/ -/ -/ -/ -/ -/ -Upon -success -this -also -returns -the -number -of -bytes -read -. -pub -( -crate -) -fn -try_read_u128 -( -slice -: -& -[ -u8 -] -what -: -& -' -static -str -) -- -> -Result -< -( -u128 -usize -) -DeserializeError -> -{ -check_slice_len -( -slice -size_of -: -: -< -u128 -> -( -) -what -) -? -; -Ok -( -( -read_u128 -( -slice -) -size_of -: -: -< -u128 -> -( -) -) -) -} -/ -/ -/ -Read -a -u16 -from -the -beginning -of -the -given -slice -in -native -endian -format -. -/ -/ -/ -If -the -slice -has -fewer -than -2 -bytes -then -this -panics -. -/ -/ -/ -/ -/ -/ -Marked -as -inline -to -speed -up -sparse -searching -which -decodes -integers -from -/ -/ -/ -its -automaton -at -search -time -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -read_u16 -( -slice -: -& -[ -u8 -] -) -- -> -u16 -{ -let -bytes -: -[ -u8 -; -2 -] -= -slice -[ -. -. -size_of -: -: -< -u16 -> -( -) -] -. -try_into -( -) -. -unwrap -( -) -; -u16 -: -: -from_ne_bytes -( -bytes -) -} -/ -/ -/ -Read -a -u32 -from -the -beginning -of -the -given -slice -in -native -endian -format -. -/ -/ -/ -If -the -slice -has -fewer -than -4 -bytes -then -this -panics -. -/ -/ -/ -/ -/ -/ -Marked -as -inline -to -speed -up -sparse -searching -which -decodes -integers -from -/ -/ -/ -its -automaton -at -search -time -. -# -[ -cfg_attr -( -feature -= -" -perf -- -inline -" -inline -( -always -) -) -] -pub -( -crate -) -fn -read_u32 -( -slice -: -& -[ -u8 -] -) -- -> -u32 -{ -let -bytes -: -[ -u8 -; -4 -] -= -slice -[ -. -. -size_of -: -: -< -u32 -> -( -) -] -. -try_into -( -) -. -unwrap -( -) -; -u32 -: -: -from_ne_bytes -( -bytes -) -} -/ -/ -/ -Read -a -u128 -from -the -beginning -of -the -given -slice -in -native -endian -format -. -/ -/ -/ -If -the -slice -has -fewer -than -16 -bytes -then -this -panics -. -pub -( -crate -) -fn -read_u128 -( -slice -: -& -[ -u8 -] -) -- -> -u128 -{ -let -bytes -: -[ -u8 -; -16 -] -= -slice -[ -. -. -size_of -: -: -< -u128 -> -( -) -] -. -try_into -( -) -. -unwrap -( -) -; -u128 -: -: -from_ne_bytes -( -bytes -) -} -/ -/ -/ -Checks -that -the -given -slice -has -some -minimal -length -. -If -it -' -s -smaller -than -/ -/ -/ -the -bound -given -then -a -" -buffer -too -small -" -error -is -returned -with -what -/ -/ -/ -describing -what -the -buffer -represents -. -pub -( -crate -) -fn -check_slice_len -< -T -> -( -slice -: -& -[ -T -] -at_least_len -: -usize -what -: -& -' -static -str -) -- -> -Result -< -( -) -DeserializeError -> -{ -if -slice -. -len -( -) -< -at_least_len -{ -return -Err -( -DeserializeError -: -: -buffer_too_small -( -what -) -) -; -} -Ok -( -( -) -) -} -/ -/ -/ -Multiply -the -given -numbers -and -on -overflow -return -an -error -that -includes -/ -/ -/ -' -what -' -in -the -error -message -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -doing -arithmetic -with -untrusted -data -. -pub -( -crate -) -fn -mul -( -a -: -usize -b -: -usize -what -: -& -' -static -str -) -- -> -Result -< -usize -DeserializeError -> -{ -match -a -. -checked_mul -( -b -) -{ -Some -( -c -) -= -> -Ok -( -c -) -None -= -> -Err -( -DeserializeError -: -: -arithmetic_overflow -( -what -) -) -} -} -/ -/ -/ -Add -the -given -numbers -and -on -overflow -return -an -error -that -includes -/ -/ -/ -' -what -' -in -the -error -message -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -doing -arithmetic -with -untrusted -data -. -pub -( -crate -) -fn -add -( -a -: -usize -b -: -usize -what -: -& -' -static -str -) -- -> -Result -< -usize -DeserializeError -> -{ -match -a -. -checked_add -( -b -) -{ -Some -( -c -) -= -> -Ok -( -c -) -None -= -> -Err -( -DeserializeError -: -: -arithmetic_overflow -( -what -) -) -} -} -/ -/ -/ -Shift -a -left -by -b -and -on -overflow -return -an -error -that -includes -/ -/ -/ -' -what -' -in -the -error -message -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -doing -arithmetic -with -untrusted -data -. -pub -( -crate -) -fn -shl -( -a -: -usize -b -: -usize -what -: -& -' -static -str -) -- -> -Result -< -usize -DeserializeError -> -{ -let -amount -= -u32 -: -: -try_from -( -b -) -. -map_err -( -| -_ -| -DeserializeError -: -: -arithmetic_overflow -( -what -) -) -? -; -match -a -. -checked_shl -( -amount -) -{ -Some -( -c -) -= -> -Ok -( -c -) -None -= -> -Err -( -DeserializeError -: -: -arithmetic_overflow -( -what -) -) -} -} -/ -/ -/ -Returns -the -number -of -additional -bytes -required -to -add -to -the -given -length -/ -/ -/ -in -order -to -make -the -total -length -a -multiple -of -4 -. -The -return -value -is -/ -/ -/ -always -less -than -4 -. -pub -( -crate -) -fn -padding_len -( -non_padding_len -: -usize -) -- -> -usize -{ -( -4 -- -( -non_padding_len -& -0b11 -) -) -& -0b11 -} -/ -/ -/ -A -simple -trait -for -writing -code -generic -over -endianness -. -/ -/ -/ -/ -/ -/ -This -is -similar -to -what -byteorder -provides -but -we -only -need -a -very -small -/ -/ -/ -subset -. -pub -( -crate -) -trait -Endian -{ -/ -/ -/ -Writes -a -u16 -to -the -given -destination -buffer -in -a -particular -/ -/ -/ -endianness -. -If -the -destination -buffer -has -a -length -smaller -than -2 -then -/ -/ -/ -this -panics -. -fn -write_u16 -( -n -: -u16 -dst -: -& -mut -[ -u8 -] -) -; -/ -/ -/ -Writes -a -u32 -to -the -given -destination -buffer -in -a -particular -/ -/ -/ -endianness -. -If -the -destination -buffer -has -a -length -smaller -than -4 -then -/ -/ -/ -this -panics -. -fn -write_u32 -( -n -: -u32 -dst -: -& -mut -[ -u8 -] -) -; -/ -/ -/ -Writes -a -u64 -to -the -given -destination -buffer -in -a -particular -/ -/ -/ -endianness -. -If -the -destination -buffer -has -a -length -smaller -than -8 -then -/ -/ -/ -this -panics -. -fn -write_u64 -( -n -: -u64 -dst -: -& -mut -[ -u8 -] -) -; -/ -/ -/ -Writes -a -u128 -to -the -given -destination -buffer -in -a -particular -/ -/ -/ -endianness -. -If -the -destination -buffer -has -a -length -smaller -than -16 -/ -/ -/ -then -this -panics -. -fn -write_u128 -( -n -: -u128 -dst -: -& -mut -[ -u8 -] -) -; -} -/ -/ -/ -Little -endian -writing -. -pub -( -crate -) -enum -LE -{ -} -/ -/ -/ -Big -endian -writing -. -pub -( -crate -) -enum -BE -{ -} -# -[ -cfg -( -target_endian -= -" -little -" -) -] -pub -( -crate -) -type -NE -= -LE -; -# -[ -cfg -( -target_endian -= -" -big -" -) -] -pub -( -crate -) -type -NE -= -BE -; -impl -Endian -for -LE -{ -fn -write_u16 -( -n -: -u16 -dst -: -& -mut -[ -u8 -] -) -{ -dst -[ -. -. -2 -] -. -copy_from_slice -( -& -n -. -to_le_bytes -( -) -) -; -} -fn -write_u32 -( -n -: -u32 -dst -: -& -mut -[ -u8 -] -) -{ -dst -[ -. -. -4 -] -. -copy_from_slice -( -& -n -. -to_le_bytes -( -) -) -; -} -fn -write_u64 -( -n -: -u64 -dst -: -& -mut -[ -u8 -] -) -{ -dst -[ -. -. -8 -] -. -copy_from_slice -( -& -n -. -to_le_bytes -( -) -) -; -} -fn -write_u128 -( -n -: -u128 -dst -: -& -mut -[ -u8 -] -) -{ -dst -[ -. -. -16 -] -. -copy_from_slice -( -& -n -. -to_le_bytes -( -) -) -; -} -} -impl -Endian -for -BE -{ -fn -write_u16 -( -n -: -u16 -dst -: -& -mut -[ -u8 -] -) -{ -dst -[ -. -. -2 -] -. -copy_from_slice -( -& -n -. -to_be_bytes -( -) -) -; -} -fn -write_u32 -( -n -: -u32 -dst -: -& -mut -[ -u8 -] -) -{ -dst -[ -. -. -4 -] -. -copy_from_slice -( -& -n -. -to_be_bytes -( -) -) -; -} -fn -write_u64 -( -n -: -u64 -dst -: -& -mut -[ -u8 -] -) -{ -dst -[ -. -. -8 -] -. -copy_from_slice -( -& -n -. -to_be_bytes -( -) -) -; -} -fn -write_u128 -( -n -: -u128 -dst -: -& -mut -[ -u8 -] -) -{ -dst -[ -. -. -16 -] -. -copy_from_slice -( -& -n -. -to_be_bytes -( -) -) -; -} -} -# -[ -cfg -( -all -( -test -feature -= -" -alloc -" -) -) -] -mod -tests -{ -use -super -: -: -* -; -# -[ -test -] -fn -labels -( -) -{ -let -mut -buf -= -[ -0 -; -1024 -] -; -let -nwrite -= -write_label -( -" -fooba -" -& -mut -buf -) -. -unwrap -( -) -; -assert_eq -! -( -nwrite -8 -) -; -assert_eq -! -( -& -buf -[ -. -. -nwrite -] -b -" -fooba -\ -x00 -\ -x00 -\ -x00 -" -) -; -let -nread -= -read_label -( -& -buf -" -fooba -" -) -. -unwrap -( -) -; -assert_eq -! -( -nread -8 -) -; -} -# -[ -test -] -# -[ -should_panic -] -fn -bad_label_interior_nul -( -) -{ -/ -/ -interior -NULs -are -not -allowed -write_label -( -" -foo -\ -x00bar -" -& -mut -[ -0 -; -1024 -] -) -. -unwrap -( -) -; -} -# -[ -test -] -fn -bad_label_almost_too_long -( -) -{ -/ -/ -ok -write_label -( -& -" -z -" -. -repeat -( -255 -) -& -mut -[ -0 -; -1024 -] -) -. -unwrap -( -) -; -} -# -[ -test -] -# -[ -should_panic -] -fn -bad_label_too_long -( -) -{ -/ -/ -labels -longer -than -255 -bytes -are -banned -write_label -( -& -" -z -" -. -repeat -( -256 -) -& -mut -[ -0 -; -1024 -] -) -. -unwrap -( -) -; -} -# -[ -test -] -fn -padding -( -) -{ -assert_eq -! -( -0 -padding_len -( -8 -) -) -; -assert_eq -! -( -3 -padding_len -( -9 -) -) -; -assert_eq -! -( -2 -padding_len -( -10 -) -) -; -assert_eq -! -( -1 -padding_len -( -11 -) -) -; -assert_eq -! -( -0 -padding_len -( -12 -) -) -; -assert_eq -! -( -3 -padding_len -( -13 -) -) -; -assert_eq -! -( -2 -padding_len -( -14 -) -) -; -assert_eq -! -( -1 -padding_len -( -15 -) -) -; -assert_eq -! -( -0 -padding_len -( -16 -) -) -; -} -} diff --git a/third_party/rust/regex-automata/test b/third_party/rust/regex-automata/test deleted file mode 100644 index d49a035a28a3b..0000000000000 --- a/third_party/rust/regex-automata/test +++ /dev/null @@ -1,894 +0,0 @@ -# -! -/ -bin -/ -bash -# -This -is -a -script -that -attempts -to -* -approximately -* -exhaustively -run -the -test -# -suite -for -regex -- -automata -. -The -main -reason -for -why -' -cargo -test -' -isn -' -t -enough -# -is -because -of -crate -features -. -regex -- -automata -has -a -ton -of -them -. -This -script -# -tests -many -of -those -feature -combinations -( -although -not -all -) -to -try -to -get -# -decent -coverage -in -a -finite -amount -of -time -. -set -- -e -# -cd -to -the -directory -containing -this -crate -' -s -Cargo -. -toml -so -that -we -don -' -t -need -# -to -pass -- -- -manifest -- -path -to -every -cargo -command -. -cd -" -( -dirname -" -0 -" -) -" -echo -" -= -= -= -= -= -ALL -FEATURES -TEST -= -= -= -" -cargo -test -- -- -all -- -features -# -Man -I -don -' -t -* -want -* -to -have -this -many -crate -features -but -. -. -. -I -really -want -# -folks -to -be -able -to -slim -the -crate -down -to -just -the -things -they -want -. -But -# -the -main -downside -is -that -I -just -can -' -t -feasibly -test -every -combination -of -# -features -because -there -are -too -many -of -them -. -Sad -but -I -' -m -not -sure -if -there -# -is -a -better -alternative -. -features -= -( -" -" -" -unicode -- -word -- -boundary -" -" -unicode -- -word -- -boundary -syntax -unicode -- -perl -" -" -unicode -- -word -- -boundary -syntax -dfa -- -build -" -" -nfa -" -" -dfa -" -" -hybrid -" -" -nfa -dfa -" -" -nfa -hybrid -" -" -dfa -hybrid -" -" -dfa -- -onepass -" -" -nfa -- -pikevm -" -" -nfa -- -backtrack -" -" -std -" -" -alloc -" -" -syntax -" -" -syntax -nfa -- -pikevm -" -" -syntax -hybrid -" -" -perf -- -literal -- -substring -" -" -perf -- -literal -- -multisubstring -" -" -meta -" -" -meta -nfa -- -backtrack -" -" -meta -hybrid -" -" -meta -dfa -- -build -" -" -meta -dfa -- -onepass -" -" -meta -nfa -dfa -hybrid -nfa -- -backtrack -" -" -meta -nfa -dfa -hybrid -nfa -- -backtrack -perf -- -literal -- -substring -" -" -meta -nfa -dfa -hybrid -nfa -- -backtrack -perf -- -literal -- -multisubstring -" -) -for -f -in -" -{ -features -[ -] -} -" -; -do -echo -" -= -= -= -= -= -LIB -FEATURES -: -f -= -= -= -" -# -It -' -s -actually -important -to -do -a -standard -' -cargo -build -' -in -addition -to -a -# -' -cargo -test -' -. -In -particular -in -the -latter -case -the -dev -- -dependencies -may -# -wind -up -enabling -features -in -dependencies -( -like -memchr -) -that -make -it -look -# -like -everything -is -well -but -actually -isn -' -t -. -For -example -the -' -regex -- -test -' -# -dev -- -dependency -uses -' -bstr -' -and -enables -its -' -std -' -feature -which -in -turn -# -unconditionally -enables -' -memchr -' -s -' -std -' -feature -. -Since -we -' -re -specifically -# -looking -to -test -that -certain -feature -combinations -work -as -expected -this -# -can -lead -to -things -testing -okay -but -would -actually -fail -to -build -. -Yikes -. -cargo -build -- -- -no -- -default -- -features -- -- -lib -- -- -features -" -f -" -cargo -test -- -- -no -- -default -- -features -- -- -lib -- -- -features -" -f -" -done -# -We -can -also -run -the -integration -test -suite -on -stripped -down -features -too -. -# -But -the -test -suite -doesn -' -t -do -well -with -things -like -' -std -' -and -' -unicode -' -# -disabled -so -we -always -enable -them -. -features -= -( -" -std -unicode -syntax -nfa -- -pikevm -" -" -std -unicode -syntax -nfa -- -backtrack -" -" -std -unicode -syntax -hybrid -" -" -std -unicode -syntax -dfa -- -onepass -" -" -std -unicode -syntax -dfa -- -search -" -" -std -unicode -syntax -dfa -- -build -" -" -std -unicode -meta -" -# -This -one -is -a -little -tricky -because -it -causes -the -backtracker -to -get -used -# -in -more -instances -and -results -in -failing -tests -for -the -' -earliest -' -tests -. -# -The -actual -results -are -semantically -consistent -with -the -API -guarantee -# -( -the -backtracker -tends -to -report -greater -offsets -because -it -isn -' -t -an -FSM -) -# -but -our -tests -are -less -flexible -than -the -API -guarantee -and -demand -offsets -# -reported -by -FSM -regex -engines -. -( -Which -is -. -. -. -all -of -them -except -for -the -# -backtracker -. -) -# -" -std -unicode -meta -nfa -- -backtrack -" -" -std -unicode -meta -hybrid -" -" -std -unicode -meta -dfa -- -onepass -" -" -std -unicode -meta -dfa -- -build -" -" -std -unicode -meta -nfa -dfa -- -onepass -hybrid -" -) -for -f -in -" -{ -features -[ -] -} -" -; -do -echo -" -= -= -= -= -= -INTEGRATION -FEATURES -: -f -= -= -= -" -cargo -build -- -- -no -- -default -- -features -- -- -lib -- -- -features -" -f -" -cargo -test -- -- -no -- -default -- -features -- -- -test -integration -- -- -features -" -f -" -done diff --git a/third_party/rust/regex-automata/tests/dfa/api.rs b/third_party/rust/regex-automata/tests/dfa/api.rs deleted file mode 100644 index c814bfb8f15a5..0000000000000 --- a/third_party/rust/regex-automata/tests/dfa/api.rs +++ /dev/null @@ -1,587 +0,0 @@ -use -std -: -: -error -: -: -Error -; -use -regex_automata -: -: -{ -dfa -: -: -{ -dense -Automaton -OverlappingState -} -nfa -: -: -thompson -HalfMatch -Input -MatchError -} -; -/ -/ -Tests -that -quit -bytes -in -the -forward -direction -work -correctly -. -# -[ -test -] -fn -quit_fwd -( -) -- -> -Result -< -( -) -Box -< -dyn -Error -> -> -{ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -quit -( -b -' -x -' -true -) -) -. -build -( -" -[ -[ -: -word -: -] -] -+ -" -) -? -; -assert_eq -! -( -Err -( -MatchError -: -: -quit -( -b -' -x -' -3 -) -) -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -b -" -abcxyz -" -) -) -) -; -assert_eq -! -( -dfa -. -try_search_overlapping_fwd -( -& -Input -: -: -new -( -b -" -abcxyz -" -) -& -mut -OverlappingState -: -: -start -( -) -) -Err -( -MatchError -: -: -quit -( -b -' -x -' -3 -) -) -) -; -Ok -( -( -) -) -} -/ -/ -Tests -that -quit -bytes -in -the -reverse -direction -work -correctly -. -# -[ -test -] -fn -quit_rev -( -) -- -> -Result -< -( -) -Box -< -dyn -Error -> -> -{ -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -. -configure -( -dense -: -: -Config -: -: -new -( -) -. -quit -( -b -' -x -' -true -) -) -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -. -build -( -" -^ -[ -[ -: -word -: -] -] -+ -" -) -? -; -assert_eq -! -( -Err -( -MatchError -: -: -quit -( -b -' -x -' -3 -) -) -dfa -. -try_search_rev -( -& -Input -: -: -new -( -b -" -abcxyz -" -) -) -) -; -Ok -( -( -) -) -} -/ -/ -Tests -that -if -we -heuristically -enable -Unicode -word -boundaries -but -then -/ -/ -instruct -that -a -non -- -ASCII -byte -should -NOT -be -a -quit -byte -then -the -builder -/ -/ -will -panic -. -# -[ -test -] -# -[ -should_panic -] -fn -quit_panics -( -) -{ -dense -: -: -Config -: -: -new -( -) -. -unicode_word_boundary -( -true -) -. -quit -( -b -' -\ -xFF -' -false -) -; -} -/ -/ -This -tests -an -intesting -case -where -even -if -the -Unicode -word -boundary -option -/ -/ -is -disabled -setting -all -non -- -ASCII -bytes -to -be -quit -bytes -will -cause -Unicode -/ -/ -word -boundaries -to -be -enabled -. -# -[ -test -] -fn -unicode_word_implicitly_works -( -) -- -> -Result -< -( -) -Box -< -dyn -Error -> -> -{ -let -mut -config -= -dense -: -: -Config -: -: -new -( -) -; -for -b -in -0x80 -. -. -= -0xFF -{ -config -= -config -. -quit -( -b -true -) -; -} -let -dfa -= -dense -: -: -Builder -: -: -new -( -) -. -configure -( -config -) -. -build -( -r -" -\ -b -" -) -? -; -let -expected -= -HalfMatch -: -: -must -( -0 -1 -) -; -assert_eq -! -( -Ok -( -Some -( -expected -) -) -dfa -. -try_search_fwd -( -& -Input -: -: -new -( -b -" -a -" -) -) -) -; -Ok -( -( -) -) -} diff --git a/third_party/rust/regex-automata/tests/dfa/mod.rs b/third_party/rust/regex-automata/tests/dfa/mod.rs deleted file mode 100644 index 67a5898fadceb..0000000000000 --- a/third_party/rust/regex-automata/tests/dfa/mod.rs +++ /dev/null @@ -1,98 +0,0 @@ -# -[ -cfg -( -all -( -feature -= -" -dfa -- -build -" -feature -= -" -dfa -- -search -" -) -) -] -mod -api -; -# -[ -cfg -( -feature -= -" -dfa -- -onepass -" -) -] -mod -onepass -; -# -[ -cfg -( -all -( -feature -= -" -dfa -- -build -" -feature -= -" -dfa -- -search -" -) -) -] -mod -regression -; -# -[ -cfg -( -all -( -not -( -miri -) -feature -= -" -dfa -- -build -" -feature -= -" -dfa -- -search -" -) -) -] -mod -suite -; diff --git a/third_party/rust/regex-automata/tests/dfa/onepass/mod.rs b/third_party/rust/regex-automata/tests/dfa/onepass/mod.rs deleted file mode 100644 index f9d643965033c..0000000000000 --- a/third_party/rust/regex-automata/tests/dfa/onepass/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -# -[ -cfg -( -not -( -miri -) -) -] -mod -suite -; diff --git a/third_party/rust/regex-automata/tests/dfa/onepass/suite.rs b/third_party/rust/regex-automata/tests/dfa/onepass/suite.rs deleted file mode 100644 index 4af9b2cc72b15..0000000000000 --- a/third_party/rust/regex-automata/tests/dfa/onepass/suite.rs +++ /dev/null @@ -1,1613 +0,0 @@ -use -{ -anyhow -: -: -Result -regex_automata -: -: -{ -dfa -: -: -onepass -: -: -{ -self -DFA -} -nfa -: -: -thompson -util -: -: -{ -iter -syntax -} -} -regex_test -: -: -{ -CompiledRegex -Match -RegexTest -SearchKind -Span -TestResult -TestRunner -} -} -; -use -crate -: -: -{ -create_input -suite -testify_captures -untestify_kind -} -; -const -EXPANSIONS -: -& -[ -& -str -] -= -& -[ -" -is_match -" -" -find -" -" -captures -" -] -; -/ -/ -/ -Tests -the -default -configuration -of -the -hybrid -NFA -/ -DFA -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -DFA -: -: -builder -( -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -hybrid -NFA -/ -DFA -when -' -starts_for_each_pattern -' -is -enabled -for -all -/ -/ -/ -tests -. -# -[ -test -] -fn -starts_for_each_pattern -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -DFA -: -: -builder -( -) -; -builder -. -configure -( -DFA -: -: -config -( -) -. -starts_for_each_pattern -( -true -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -hybrid -NFA -/ -DFA -when -byte -classes -are -disabled -. -/ -/ -/ -/ -/ -/ -N -. -B -. -Disabling -byte -classes -doesn -' -t -avoid -any -indirection -at -search -time -. -/ -/ -/ -All -it -does -is -cause -every -byte -value -to -be -its -own -distinct -equivalence -/ -/ -/ -class -. -# -[ -test -] -fn -no_byte_classes -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -DFA -: -: -builder -( -) -; -builder -. -configure -( -DFA -: -: -config -( -) -. -byte_classes -( -false -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -compiler -( -mut -builder -: -onepass -: -: -Builder -) -- -> -impl -FnMut -( -& -RegexTest -& -[ -String -] -) -- -> -Result -< -CompiledRegex -> -{ -move -| -test -regexes -| -{ -/ -/ -Check -if -our -regex -contains -things -that -aren -' -t -supported -by -DFAs -. -/ -/ -That -is -Unicode -word -boundaries -when -searching -non -- -ASCII -text -. -if -! -configure_onepass_builder -( -test -& -mut -builder -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -let -re -= -match -builder -. -build_many -( -& -regexes -) -{ -Ok -( -re -) -= -> -re -Err -( -err -) -= -> -{ -let -msg -= -err -. -to_string -( -) -; -/ -/ -This -is -pretty -gross -but -when -a -regex -fails -to -compile -as -/ -/ -a -one -- -pass -regex -then -we -want -to -be -OK -with -that -and -just -/ -/ -skip -the -test -. -But -we -have -to -be -careful -to -only -skip -it -/ -/ -when -the -expected -result -is -that -the -regex -compiles -. -If -/ -/ -the -test -is -specifically -checking -that -the -regex -does -not -/ -/ -compile -then -we -should -bubble -up -that -error -and -allow -the -/ -/ -test -to -pass -. -/ -/ -/ -/ -Since -our -error -types -are -all -generally -opaque -we -just -/ -/ -look -for -an -error -string -. -Not -great -but -not -the -end -of -the -/ -/ -world -. -if -test -. -compiles -( -) -& -& -msg -. -contains -( -" -not -one -- -pass -" -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -return -Err -( -err -. -into -( -) -) -; -} -} -; -let -mut -cache -= -re -. -create_cache -( -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -& -mut -cache -test -) -} -) -) -} -} -fn -run_test -( -re -: -& -DFA -cache -: -& -mut -onepass -: -: -Cache -test -: -& -RegexTest -) -- -> -TestResult -{ -let -input -= -create_input -( -test -) -; -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -{ -TestResult -: -: -matched -( -re -. -is_match -( -cache -input -. -earliest -( -true -) -) -) -} -" -find -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Leftmost -= -> -{ -let -input -= -input -. -earliest -( -test -. -search_kind -( -) -= -= -SearchKind -: -: -Earliest -) -; -let -mut -caps -= -re -. -create_captures -( -) -; -let -it -= -iter -: -: -Searcher -: -: -new -( -input -) -. -into_matches_iter -( -| -input -| -{ -re -. -try_search -( -cache -input -& -mut -caps -) -? -; -Ok -( -caps -. -get_match -( -) -) -} -) -. -infallible -( -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -m -. -pattern -( -) -. -as_usize -( -) -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -; -TestResult -: -: -matches -( -it -) -} -SearchKind -: -: -Overlapping -= -> -{ -/ -/ -The -one -- -pass -DFA -does -not -support -any -kind -of -overlapping -/ -/ -search -. -This -is -not -just -a -matter -of -not -having -the -API -. -/ -/ -It -' -s -fundamentally -incompatible -with -the -one -- -pass -concept -. -/ -/ -If -overlapping -matches -were -possible -then -the -one -- -pass -DFA -/ -/ -would -fail -to -build -. -TestResult -: -: -skip -( -) -} -} -" -captures -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Leftmost -= -> -{ -let -input -= -input -. -earliest -( -test -. -search_kind -( -) -= -= -SearchKind -: -: -Earliest -) -; -let -it -= -iter -: -: -Searcher -: -: -new -( -input -) -. -into_captures_iter -( -re -. -create_captures -( -) -| -input -caps -| -{ -re -. -try_search -( -cache -input -caps -) -} -) -. -infallible -( -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -caps -| -testify_captures -( -& -caps -) -) -; -TestResult -: -: -captures -( -it -) -} -SearchKind -: -: -Overlapping -= -> -{ -/ -/ -The -one -- -pass -DFA -does -not -support -any -kind -of -overlapping -/ -/ -search -. -This -is -not -just -a -matter -of -not -having -the -API -. -/ -/ -It -' -s -fundamentally -incompatible -with -the -one -- -pass -concept -. -/ -/ -If -overlapping -matches -were -possible -then -the -one -- -pass -DFA -/ -/ -would -fail -to -build -. -TestResult -: -: -skip -( -) -} -} -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Configures -the -given -regex -builder -with -all -relevant -settings -on -the -given -/ -/ -/ -regex -test -. -/ -/ -/ -/ -/ -/ -If -the -regex -test -has -a -setting -that -is -unsupported -then -this -returns -/ -/ -/ -false -( -implying -the -test -should -be -skipped -) -. -fn -configure_onepass_builder -( -test -: -& -RegexTest -builder -: -& -mut -onepass -: -: -Builder -) -- -> -bool -{ -if -! -test -. -anchored -( -) -{ -return -false -; -} -let -match_kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -false -Some -( -k -) -= -> -k -} -; -let -config -= -DFA -: -: -config -( -) -. -match_kind -( -match_kind -) -; -builder -. -configure -( -config -) -. -syntax -( -config_syntax -( -test -) -) -. -thompson -( -config_thompson -( -test -) -) -; -true -} -/ -/ -/ -Configuration -of -a -Thompson -NFA -compiler -from -a -regex -test -. -fn -config_thompson -( -test -: -& -RegexTest -) -- -> -thompson -: -: -Config -{ -let -mut -lookm -= -regex_automata -: -: -util -: -: -look -: -: -LookMatcher -: -: -new -( -) -; -lookm -. -set_line_terminator -( -test -. -line_terminator -( -) -) -; -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -test -. -utf8 -( -) -) -. -look_matcher -( -lookm -) -} -/ -/ -/ -Configuration -of -the -regex -parser -from -a -regex -test -. -fn -config_syntax -( -test -: -& -RegexTest -) -- -> -syntax -: -: -Config -{ -syntax -: -: -Config -: -: -new -( -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -utf8 -( -test -. -utf8 -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -} diff --git a/third_party/rust/regex-automata/tests/dfa/regression.rs b/third_party/rust/regex-automata/tests/dfa/regression.rs deleted file mode 100644 index 37c4ff39476b0..0000000000000 --- a/third_party/rust/regex-automata/tests/dfa/regression.rs +++ /dev/null @@ -1,376 +0,0 @@ -/ -/ -A -regression -test -for -checking -that -minimization -correctly -translates -/ -/ -whether -a -state -is -a -match -state -or -not -. -Previously -it -was -possible -for -/ -/ -minimization -to -mark -a -non -- -matching -state -as -matching -. -# -[ -test -] -# -[ -cfg -( -not -( -miri -) -) -] -fn -minimize_sets_correct_match_states -( -) -{ -use -regex_automata -: -: -{ -dfa -: -: -{ -dense -: -: -DFA -Automaton -StartKind -} -Anchored -Input -} -; -let -pattern -= -/ -/ -This -is -a -subset -of -the -grapheme -matching -regex -. -I -couldn -' -t -seem -/ -/ -to -get -a -repro -any -smaller -than -this -unfortunately -. -r -" -( -? -x -) -( -? -: -\ -p -{ -gcb -= -Prepend -} -* -( -? -: -( -? -: -( -? -: -\ -p -{ -gcb -= -L -} -* -( -? -: -\ -p -{ -gcb -= -V -} -+ -| -\ -p -{ -gcb -= -LV -} -\ -p -{ -gcb -= -V -} -* -| -\ -p -{ -gcb -= -LVT -} -) -\ -p -{ -gcb -= -T -} -* -) -| -\ -p -{ -gcb -= -L -} -+ -| -\ -p -{ -gcb -= -T -} -+ -) -| -\ -p -{ -Extended_Pictographic -} -( -? -: -\ -p -{ -gcb -= -Extend -} -* -\ -p -{ -gcb -= -ZWJ -} -\ -p -{ -Extended_Pictographic -} -) -* -| -[ -^ -\ -p -{ -gcb -= -Control -} -\ -p -{ -gcb -= -CR -} -\ -p -{ -gcb -= -LF -} -] -) -[ -\ -p -{ -gcb -= -Extend -} -\ -p -{ -gcb -= -ZWJ -} -\ -p -{ -gcb -= -SpacingMark -} -] -* -) -" -; -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -start_kind -( -StartKind -: -: -Anchored -) -. -minimize -( -true -) -) -. -build -( -pattern -) -. -unwrap -( -) -; -let -input -= -Input -: -: -new -( -b -" -\ -xE2 -" -) -. -anchored -( -Anchored -: -: -Yes -) -; -assert_eq -! -( -Ok -( -None -) -dfa -. -try_search_fwd -( -& -input -) -) -; -} diff --git a/third_party/rust/regex-automata/tests/dfa/suite.rs b/third_party/rust/regex-automata/tests/dfa/suite.rs deleted file mode 100644 index 7777d89babbb5..0000000000000 --- a/third_party/rust/regex-automata/tests/dfa/suite.rs +++ /dev/null @@ -1,3890 +0,0 @@ -use -{ -anyhow -: -: -Result -regex_automata -: -: -{ -dfa -: -: -{ -self -dense -regex -: -: -Regex -sparse -Automaton -OverlappingState -StartKind -} -nfa -: -: -thompson -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -Anchored -Input -PatternSet -} -regex_syntax -: -: -hir -regex_test -: -: -{ -CompiledRegex -Match -RegexTest -SearchKind -Span -TestResult -TestRunner -} -} -; -use -crate -: -: -{ -create_input -suite -untestify_kind -} -; -const -EXPANSIONS -: -& -[ -& -str -] -= -& -[ -" -is_match -" -" -find -" -" -which -" -] -; -/ -/ -/ -Runs -the -test -suite -with -the -default -configuration -. -# -[ -test -] -fn -unminimized_default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -Regex -: -: -builder -( -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -dense_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Runs -the -test -suite -with -the -default -configuration -and -a -prefilter -enabled -/ -/ -/ -if -one -can -be -built -. -# -[ -test -] -fn -unminimized_prefilter -( -) -- -> -Result -< -( -) -> -{ -let -my_compiler -= -| -test -: -& -RegexTest -regexes -: -& -[ -String -] -| -{ -/ -/ -Parse -regexes -as -HIRs -so -we -can -get -literals -to -build -a -prefilter -. -let -mut -hirs -= -vec -! -[ -] -; -for -pattern -in -regexes -. -iter -( -) -{ -hirs -. -push -( -syntax -: -: -parse_with -( -pattern -& -config_syntax -( -test -) -) -? -) -; -} -let -kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -Some -( -kind -) -= -> -kind -} -; -let -pre -= -Prefilter -: -: -from_hirs_prefix -( -kind -& -hirs -) -; -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dense -( -dense -: -: -DFA -: -: -config -( -) -. -prefilter -( -pre -) -) -; -compiler -( -builder -| -_ -_ -re -| -{ -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -test -) -} -) -) -} -) -( -test -regexes -) -} -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -my_compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Runs -the -test -suite -with -start -states -specialized -. -# -[ -test -] -fn -unminimized_specialized_start_states -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dense -( -dense -: -: -Config -: -: -new -( -) -. -specialize_start_states -( -true -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -dense_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Runs -the -test -suite -with -byte -classes -disabled -. -# -[ -test -] -fn -unminimized_no_byte_class -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dense -( -dense -: -: -Config -: -: -new -( -) -. -byte_classes -( -false -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -dense_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Runs -the -test -suite -with -NFA -shrinking -enabled -. -# -[ -test -] -fn -unminimized_nfa_shrink -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -shrink -( -true -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -dense_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Runs -the -test -suite -on -a -minimized -DFA -with -an -otherwise -default -/ -/ -/ -configuration -. -# -[ -test -] -fn -minimized_default -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dense -( -dense -: -: -Config -: -: -new -( -) -. -minimize -( -true -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -dense_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Runs -the -test -suite -on -a -minimized -DFA -with -byte -classes -disabled -. -# -[ -test -] -fn -minimized_no_byte_class -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dense -( -dense -: -: -Config -: -: -new -( -) -. -minimize -( -true -) -. -byte_classes -( -false -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -dense_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Runs -the -test -suite -on -a -sparse -unminimized -DFA -. -# -[ -test -] -fn -sparse_unminimized_default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -Regex -: -: -builder -( -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -sparse_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Runs -the -test -suite -on -a -sparse -unminimized -DFA -with -prefilters -enabled -. -# -[ -test -] -fn -sparse_unminimized_prefilter -( -) -- -> -Result -< -( -) -> -{ -let -my_compiler -= -| -test -: -& -RegexTest -regexes -: -& -[ -String -] -| -{ -/ -/ -Parse -regexes -as -HIRs -so -we -can -get -literals -to -build -a -prefilter -. -let -mut -hirs -= -vec -! -[ -] -; -for -pattern -in -regexes -. -iter -( -) -{ -hirs -. -push -( -syntax -: -: -parse_with -( -pattern -& -config_syntax -( -test -) -) -? -) -; -} -let -kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -Some -( -kind -) -= -> -kind -} -; -let -pre -= -Prefilter -: -: -from_hirs_prefix -( -kind -& -hirs -) -; -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dense -( -dense -: -: -DFA -: -: -config -( -) -. -prefilter -( -pre -) -) -; -compiler -( -builder -| -builder -_ -re -| -{ -let -fwd -= -re -. -forward -( -) -. -to_sparse -( -) -? -; -let -rev -= -re -. -reverse -( -) -. -to_sparse -( -) -? -; -let -re -= -builder -. -build_from_dfas -( -fwd -rev -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -test -) -} -) -) -} -) -( -test -regexes -) -} -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -my_compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Another -basic -sanity -test -that -checks -we -can -serialize -and -then -deserialize -/ -/ -/ -a -regex -and -that -the -resulting -regex -can -be -used -for -searching -correctly -. -# -[ -test -] -fn -serialization_unminimized_default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -Regex -: -: -builder -( -) -; -let -my_compiler -= -| -builder -| -{ -compiler -( -builder -| -builder -_ -re -| -{ -let -builder -= -builder -. -clone -( -) -; -let -( -fwd_bytes -_ -) -= -re -. -forward -( -) -. -to_bytes_native_endian -( -) -; -let -( -rev_bytes -_ -) -= -re -. -reverse -( -) -. -to_bytes_native_endian -( -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -let -fwd -: -dense -: -: -DFA -< -& -[ -u32 -] -> -= -dense -: -: -DFA -: -: -from_bytes -( -& -fwd_bytes -) -. -unwrap -( -) -. -0 -; -let -rev -: -dense -: -: -DFA -< -& -[ -u32 -] -> -= -dense -: -: -DFA -: -: -from_bytes -( -& -rev_bytes -) -. -unwrap -( -) -. -0 -; -let -re -= -builder -. -build_from_dfas -( -fwd -rev -) -; -run_test -( -& -re -test -) -} -) -) -} -) -} -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -my_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -A -basic -sanity -test -that -checks -we -can -serialize -and -then -deserialize -a -/ -/ -/ -regex -using -sparse -DFAs -and -that -the -resulting -regex -can -be -used -for -/ -/ -/ -searching -correctly -. -# -[ -test -] -fn -sparse_serialization_unminimized_default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -Regex -: -: -builder -( -) -; -let -my_compiler -= -| -builder -| -{ -compiler -( -builder -| -builder -_ -re -| -{ -let -builder -= -builder -. -clone -( -) -; -let -fwd_bytes -= -re -. -forward -( -) -. -to_sparse -( -) -? -. -to_bytes_native_endian -( -) -; -let -rev_bytes -= -re -. -reverse -( -) -. -to_sparse -( -) -? -. -to_bytes_native_endian -( -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -let -fwd -: -sparse -: -: -DFA -< -& -[ -u8 -] -> -= -sparse -: -: -DFA -: -: -from_bytes -( -& -fwd_bytes -) -. -unwrap -( -) -. -0 -; -let -rev -: -sparse -: -: -DFA -< -& -[ -u8 -] -> -= -sparse -: -: -DFA -: -: -from_bytes -( -& -rev_bytes -) -. -unwrap -( -) -. -0 -; -let -re -= -builder -. -build_from_dfas -( -fwd -rev -) -; -run_test -( -& -re -test -) -} -) -) -} -) -} -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -blacklist -( -" -expensive -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -my_compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -dense_compiler -( -builder -: -dfa -: -: -regex -: -: -Builder -) -- -> -impl -FnMut -( -& -RegexTest -& -[ -String -] -) -- -> -Result -< -CompiledRegex -> -{ -compiler -( -builder -| -_ -_ -re -| -{ -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -test -) -} -) -) -} -) -} -fn -sparse_compiler -( -builder -: -dfa -: -: -regex -: -: -Builder -) -- -> -impl -FnMut -( -& -RegexTest -& -[ -String -] -) -- -> -Result -< -CompiledRegex -> -{ -compiler -( -builder -| -builder -_ -re -| -{ -let -fwd -= -re -. -forward -( -) -. -to_sparse -( -) -? -; -let -rev -= -re -. -reverse -( -) -. -to_sparse -( -) -? -; -let -re -= -builder -. -build_from_dfas -( -fwd -rev -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -test -) -} -) -) -} -) -} -fn -compiler -( -mut -builder -: -dfa -: -: -regex -: -: -Builder -mut -create_matcher -: -impl -FnMut -( -& -dfa -: -: -regex -: -: -Builder -Option -< -Prefilter -> -Regex -) -- -> -Result -< -CompiledRegex -> -) -- -> -impl -FnMut -( -& -RegexTest -& -[ -String -] -) -- -> -Result -< -CompiledRegex -> -{ -move -| -test -regexes -| -{ -/ -/ -Parse -regexes -as -HIRs -for -some -analysis -below -. -let -mut -hirs -= -vec -! -[ -] -; -for -pattern -in -regexes -. -iter -( -) -{ -hirs -. -push -( -syntax -: -: -parse_with -( -pattern -& -config_syntax -( -test -) -) -? -) -; -} -/ -/ -Get -a -prefilter -in -case -the -test -wants -it -. -let -kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -Some -( -kind -) -= -> -kind -} -; -let -pre -= -Prefilter -: -: -from_hirs_prefix -( -kind -& -hirs -) -; -/ -/ -Check -if -our -regex -contains -things -that -aren -' -t -supported -by -DFAs -. -/ -/ -That -is -Unicode -word -boundaries -when -searching -non -- -ASCII -text -. -if -! -test -. -haystack -( -) -. -is_ascii -( -) -{ -for -hir -in -hirs -. -iter -( -) -{ -let -looks -= -hir -. -properties -( -) -. -look_set -( -) -; -if -looks -. -contains -( -hir -: -: -Look -: -: -WordUnicode -) -| -| -looks -. -contains -( -hir -: -: -Look -: -: -WordUnicodeNegate -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -} -} -if -! -configure_regex_builder -( -test -& -mut -builder -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -create_matcher -( -& -builder -pre -builder -. -build_many -( -& -regexes -) -? -) -} -} -fn -run_test -< -A -: -Automaton -> -( -re -: -& -Regex -< -A -> -test -: -& -RegexTest -) -- -> -TestResult -{ -let -input -= -create_input -( -test -) -; -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -TestResult -: -: -matched -( -re -. -is_match -( -input -. -earliest -( -true -) -) -) -" -find -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Leftmost -= -> -{ -let -input -= -input -. -earliest -( -test -. -search_kind -( -) -= -= -SearchKind -: -: -Earliest -) -; -TestResult -: -: -matches -( -re -. -find_iter -( -input -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -m -. -pattern -( -) -. -as_usize -( -) -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -) -} -SearchKind -: -: -Overlapping -= -> -{ -try_search_overlapping -( -re -& -input -) -. -unwrap -( -) -} -} -" -which -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Leftmost -= -> -{ -/ -/ -There -are -no -" -which -" -APIs -for -standard -searches -. -TestResult -: -: -skip -( -) -} -SearchKind -: -: -Overlapping -= -> -{ -let -dfa -= -re -. -forward -( -) -; -let -mut -patset -= -PatternSet -: -: -new -( -dfa -. -pattern_len -( -) -) -; -dfa -. -try_which_overlapping_matches -( -& -input -& -mut -patset -) -. -unwrap -( -) -; -TestResult -: -: -which -( -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -) -} -} -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Configures -the -given -regex -builder -with -all -relevant -settings -on -the -given -/ -/ -/ -regex -test -. -/ -/ -/ -/ -/ -/ -If -the -regex -test -has -a -setting -that -is -unsupported -then -this -returns -/ -/ -/ -false -( -implying -the -test -should -be -skipped -) -. -fn -configure_regex_builder -( -test -: -& -RegexTest -builder -: -& -mut -dfa -: -: -regex -: -: -Builder -) -- -> -bool -{ -let -match_kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -false -Some -( -k -) -= -> -k -} -; -let -starts -= -if -test -. -anchored -( -) -{ -StartKind -: -: -Anchored -} -else -{ -StartKind -: -: -Unanchored -} -; -let -mut -dense_config -= -dense -: -: -Config -: -: -new -( -) -. -start_kind -( -starts -) -. -match_kind -( -match_kind -) -. -unicode_word_boundary -( -true -) -; -/ -/ -When -doing -an -overlapping -search -we -might -try -to -find -the -start -of -each -/ -/ -match -with -a -custom -search -routine -. -In -that -case -we -need -to -tell -the -/ -/ -reverse -search -( -for -the -start -offset -) -which -pattern -to -look -for -. -The -/ -/ -only -way -that -API -works -is -when -anchored -starting -states -are -compiled -/ -/ -for -each -pattern -. -This -does -technically -also -enable -it -for -the -forward -/ -/ -DFA -but -we -' -re -okay -with -that -. -if -test -. -search_kind -( -) -= -= -SearchKind -: -: -Overlapping -{ -dense_config -= -dense_config -. -starts_for_each_pattern -( -true -) -; -} -builder -. -syntax -( -config_syntax -( -test -) -) -. -thompson -( -config_thompson -( -test -) -) -. -dense -( -dense_config -) -; -true -} -/ -/ -/ -Configuration -of -a -Thompson -NFA -compiler -from -a -regex -test -. -fn -config_thompson -( -test -: -& -RegexTest -) -- -> -thompson -: -: -Config -{ -let -mut -lookm -= -regex_automata -: -: -util -: -: -look -: -: -LookMatcher -: -: -new -( -) -; -lookm -. -set_line_terminator -( -test -. -line_terminator -( -) -) -; -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -test -. -utf8 -( -) -) -. -look_matcher -( -lookm -) -} -/ -/ -/ -Configuration -of -the -regex -syntax -from -a -regex -test -. -fn -config_syntax -( -test -: -& -RegexTest -) -- -> -syntax -: -: -Config -{ -syntax -: -: -Config -: -: -new -( -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -utf8 -( -test -. -utf8 -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -} -/ -/ -/ -Execute -an -overlapping -search -and -for -each -match -found -also -find -its -/ -/ -/ -overlapping -starting -positions -. -/ -/ -/ -/ -/ -/ -N -. -B -. -This -routine -used -to -be -part -of -the -crate -API -but -1 -) -it -wasn -' -t -clear -/ -/ -/ -to -me -how -useful -it -was -and -2 -) -it -wasn -' -t -clear -to -me -what -its -semantics -/ -/ -/ -should -be -. -In -particular -a -potentially -surprising -footgun -of -this -routine -/ -/ -/ -that -it -is -worst -case -* -quadratic -* -in -the -size -of -the -haystack -. -Namely -it -' -s -/ -/ -/ -possible -to -report -a -match -at -every -position -and -for -every -such -position -/ -/ -/ -scan -all -the -way -to -the -beginning -of -the -haystack -to -find -the -starting -/ -/ -/ -position -. -Typical -leftmost -non -- -overlapping -searches -don -' -t -suffer -from -this -/ -/ -/ -because -well -matches -can -' -t -overlap -. -So -subsequent -searches -after -a -match -/ -/ -/ -is -found -don -' -t -revisit -previously -scanned -parts -of -the -haystack -. -/ -/ -/ -/ -/ -/ -Its -semantics -can -be -strange -for -other -reasons -too -. -For -example -given -/ -/ -/ -the -regex -' -. -* -' -and -the -haystack -' -zz -' -the -full -set -of -overlapping -matches -/ -/ -/ -is -: -[ -0 -0 -] -[ -1 -1 -] -[ -0 -1 -] -[ -2 -2 -] -[ -1 -2 -] -[ -0 -2 -] -. -The -ordering -of -/ -/ -/ -those -matches -is -quite -strange -but -makes -sense -when -you -think -about -the -/ -/ -/ -implementation -: -an -end -offset -is -found -left -- -to -- -right -and -then -one -or -more -/ -/ -/ -starting -offsets -are -found -right -- -to -- -left -. -/ -/ -/ -/ -/ -/ -Nevertheless -we -provide -this -routine -in -our -test -suite -because -it -' -s -/ -/ -/ -useful -to -test -the -low -level -DFA -overlapping -search -and -our -test -suite -/ -/ -/ -is -written -in -a -way -that -requires -starting -offsets -. -fn -try_search_overlapping -< -A -: -Automaton -> -( -re -: -& -Regex -< -A -> -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -TestResult -> -{ -let -mut -matches -= -vec -! -[ -] -; -let -mut -fwd_state -= -OverlappingState -: -: -start -( -) -; -let -( -fwd_dfa -rev_dfa -) -= -( -re -. -forward -( -) -re -. -reverse -( -) -) -; -while -let -Some -( -end -) -= -{ -fwd_dfa -. -try_search_overlapping_fwd -( -input -& -mut -fwd_state -) -? -; -fwd_state -. -get_match -( -) -} -{ -let -revsearch -= -input -. -clone -( -) -. -range -( -input -. -start -( -) -. -. -end -. -offset -( -) -) -. -anchored -( -Anchored -: -: -Pattern -( -end -. -pattern -( -) -) -) -. -earliest -( -false -) -; -let -mut -rev_state -= -OverlappingState -: -: -start -( -) -; -while -let -Some -( -start -) -= -{ -rev_dfa -. -try_search_overlapping_rev -( -& -revsearch -& -mut -rev_state -) -? -; -rev_state -. -get_match -( -) -} -{ -let -span -= -Span -{ -start -: -start -. -offset -( -) -end -: -end -. -offset -( -) -} -; -let -mat -= -Match -{ -id -: -end -. -pattern -( -) -. -as_usize -( -) -span -} -; -matches -. -push -( -mat -) -; -} -} -Ok -( -TestResult -: -: -matches -( -matches -) -) -} diff --git a/third_party/rust/regex-automata/tests/fuzz/dense.rs b/third_party/rust/regex-automata/tests/fuzz/dense.rs deleted file mode 100644 index 6e90ec72864b0..0000000000000 --- a/third_party/rust/regex-automata/tests/fuzz/dense.rs +++ /dev/null @@ -1,488 +0,0 @@ -/ -/ -This -test -was -found -by -a -fuzzer -input -that -crafted -a -way -to -provide -/ -/ -an -invalid -serialization -of -ByteClasses -that -passed -our -verification -. -/ -/ -Specifically -the -verification -step -in -the -deserialization -of -ByteClasses -/ -/ -used -an -iterator -that -depends -on -part -of -the -serialized -bytes -being -correct -. -/ -/ -( -Specifically -the -encoding -of -the -number -of -classes -. -) -# -[ -test -] -fn -invalid_byte_classes -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_dense_crash -- -9486fb7c8a93b12c12a62166b43d31640c0208a9 -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -# -[ -test -] -fn -invalid_byte_classes_min -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_dense_minimized -- -from -- -9486fb7c8a93b12c12a62166b43d31640c0208a9 -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -/ -/ -This -is -the -code -from -the -fuzz -target -. -Kind -of -sucks -to -duplicate -it -here -/ -/ -but -this -is -fundamentally -how -we -interpret -the -date -. -fn -fuzz_run -( -given_data -: -& -[ -u8 -] -) -- -> -Option -< -( -) -> -{ -use -regex_automata -: -: -dfa -: -: -Automaton -; -if -given_data -. -len -( -) -< -2 -{ -return -None -; -} -let -haystack_len -= -usize -: -: -from -( -given_data -[ -0 -] -) -; -let -haystack -= -given_data -. -get -( -1 -. -. -1 -+ -haystack_len -) -? -; -let -given_dfa_bytes -= -given_data -. -get -( -1 -+ -haystack_len -. -. -) -? -; -/ -/ -We -help -the -fuzzer -along -by -adding -a -preamble -to -the -bytes -that -should -/ -/ -at -least -make -these -first -parts -valid -. -The -preamble -expects -a -very -/ -/ -specific -sequence -of -bytes -so -it -makes -sense -to -just -force -this -. -let -label -= -" -rust -- -regex -- -automata -- -dfa -- -dense -\ -x00 -\ -x00 -\ -x00 -" -; -assert_eq -! -( -0 -label -. -len -( -) -% -4 -) -; -let -endianness_check -= -0xFEFFu32 -. -to_ne_bytes -( -) -. -to_vec -( -) -; -let -version_check -= -2u32 -. -to_ne_bytes -( -) -. -to_vec -( -) -; -let -mut -dfa_bytes -: -Vec -< -u8 -> -= -vec -! -[ -] -; -dfa_bytes -. -extend -( -label -. -as_bytes -( -) -) -; -dfa_bytes -. -extend -( -& -endianness_check -) -; -dfa_bytes -. -extend -( -& -version_check -) -; -dfa_bytes -. -extend -( -given_dfa_bytes -) -; -/ -/ -This -is -the -real -test -: -checking -that -any -input -we -give -to -/ -/ -DFA -: -: -from_bytes -will -never -result -in -a -panic -. -let -( -dfa -_ -) -= -regex_automata -: -: -dfa -: -: -dense -: -: -DFA -: -: -from_bytes -( -& -dfa_bytes -) -. -ok -( -) -? -; -let -_ -= -dfa -. -try_search_fwd -( -& -regex_automata -: -: -Input -: -: -new -( -haystack -) -) -; -Some -( -( -) -) -} diff --git a/third_party/rust/regex-automata/tests/fuzz/mod.rs b/third_party/rust/regex-automata/tests/fuzz/mod.rs deleted file mode 100644 index 262c06c1409ea..0000000000000 --- a/third_party/rust/regex-automata/tests/fuzz/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod -dense -; -mod -sparse -; diff --git a/third_party/rust/regex-automata/tests/fuzz/sparse.rs b/third_party/rust/regex-automata/tests/fuzz/sparse.rs deleted file mode 100644 index 4a69ba3dd0de0..0000000000000 --- a/third_party/rust/regex-automata/tests/fuzz/sparse.rs +++ /dev/null @@ -1,1245 +0,0 @@ -/ -/ -This -is -a -regression -test -for -a -bug -in -how -special -states -are -handled -. -The -/ -/ -fuzzer -found -a -case -where -a -state -returned -true -for -' -is_special_state -' -but -/ -/ -* -didn -' -t -* -return -true -for -' -is_dead_state -' -' -is_quit_state -' -' -is_match_state -' -/ -/ -' -is_start_state -' -or -' -is_accel_state -' -. -This -in -turn -tripped -a -debug -assertion -/ -/ -in -the -core -matching -loop -that -requires -' -is_special_state -' -being -true -to -/ -/ -imply -that -one -of -the -other -routines -returns -true -. -/ -/ -/ -/ -We -fixed -this -by -adding -some -validation -to -both -dense -and -sparse -DFAs -that -/ -/ -checks -that -this -property -is -true -for -every -state -ID -in -the -DFA -. -# -[ -test -] -fn -invalid_special_state -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_sparse_crash -- -a1b839d899ced76d5d7d0f78f9edb7a421505838 -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -/ -/ -This -is -an -interesting -case -where -a -fuzzer -generated -a -DFA -with -/ -/ -a -transition -to -a -state -ID -that -decoded -as -a -valid -state -but -/ -/ -where -the -ID -itself -did -not -point -to -one -of -the -two -existing -/ -/ -states -for -this -particular -DFA -. -This -combined -with -marking -this -/ -/ -transition -' -s -state -ID -as -special -but -without -actually -making -one -of -the -/ -/ -' -is_ -{ -dead -quit -match -start -accel -} -_state -' -predicates -return -true -ended -up -/ -/ -tripping -the -' -debug_assert -( -dfa -. -is_quit_state -( -sid -) -) -' -code -in -the -search -/ -/ -routine -. -/ -/ -/ -/ -We -fixed -this -in -alloc -mode -by -checking -that -every -transition -points -to -a -/ -/ -valid -state -ID -. -Technically -this -bug -still -exists -in -core -- -only -mode -but -/ -/ -it -' -s -not -clear -how -to -fix -it -. -And -it -' -s -worth -pointing -out -that -the -search -/ -/ -routine -won -' -t -panic -in -production -. -It -will -just -provide -invalid -results -. -And -/ -/ -that -' -s -acceptable -within -the -contract -of -DFA -: -: -from_bytes -. -# -[ -test -] -fn -transition_to_invalid_but_valid_state -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_sparse_crash -- -dbb8172d3984e7e7d03f4b5f8bb86ecd1460eff9 -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -/ -/ -Another -one -caught -by -the -fuzzer -where -it -generated -a -DFA -that -reported -a -/ -/ -start -state -as -a -match -state -. -Since -matches -are -always -delayed -by -one -byte -/ -/ -start -states -specifically -cannot -be -match -states -. -And -indeed -the -search -/ -/ -code -relies -on -this -. -# -[ -test -] -fn -start_state_is_not_match_state -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_sparse_crash -- -0da59c0434eaf35e5a6b470fa9244bb79c72b000 -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -/ -/ -This -is -variation -on -' -transition_to_invalid_but_valid_state -' -but -happens -/ -/ -to -a -start -state -. -Namely -the -fuzz -data -here -builds -a -DFA -with -a -start -/ -/ -state -ID -that -is -incorrect -but -points -to -a -sequence -of -bytes -that -satisfies -/ -/ -state -decoding -validation -. -This -errant -state -in -turn -has -a -non -- -zero -number -/ -/ -of -transitions -and -its -those -transitions -that -point -to -a -state -that -does -/ -/ -* -not -* -satisfy -state -decoding -validation -. -But -we -never -checked -those -. -So -the -/ -/ -fix -here -was -to -add -validation -of -the -transitions -off -of -the -start -state -. -# -[ -test -] -fn -start_state_has_valid_transitions -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_sparse_crash -- -61fd8e3003bf9d99f6c1e5a8488727eefd234b98 -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -/ -/ -This -fuzz -input -generated -a -DFA -with -a -state -whose -ID -was -in -the -match -state -/ -/ -ID -range -but -where -the -state -itself -was -encoded -with -zero -pattern -IDs -. -We -/ -/ -added -validation -code -to -check -this -case -. -# -[ -test -] -fn -match_state_inconsistency -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_sparse_crash -- -c383ae07ec5e191422eadc492117439011816570 -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -/ -/ -This -fuzz -input -generated -a -DFA -with -a -state -whose -ID -was -in -the -accelerator -/ -/ -range -but -who -didn -' -t -have -any -accelerators -. -This -violated -an -invariant -that -/ -/ -assumes -that -if -' -dfa -. -is_accel_state -( -sid -) -' -returns -true -then -the -state -must -/ -/ -have -some -accelerators -. -# -[ -test -] -fn -invalid_accelerators -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_sparse_crash -- -d07703ceb94b10dcd9e4acb809f2051420449e2b -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -/ -/ -This -fuzz -input -generated -a -DFA -with -a -state -whose -EOI -transition -led -to -/ -/ -a -quit -state -which -is -generally -considered -illegal -. -Why -? -Because -the -EOI -/ -/ -transition -is -defined -over -a -special -sentinel -alphabet -element -and -one -/ -/ -cannot -configure -a -DFA -to -" -quit -" -on -that -sentinel -. -# -[ -test -] -fn -eoi_transition_to_quit_state -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -deserialize_sparse_crash -- -18cfc246f2ddfc3dfc92b0c7893178c7cf65efa9 -" -) -; -let -_ -= -fuzz_run -( -data -) -; -} -/ -/ -This -is -the -code -from -the -fuzz -target -. -Kind -of -sucks -to -duplicate -it -here -/ -/ -but -this -is -fundamentally -how -we -interpret -the -date -. -fn -fuzz_run -( -given_data -: -& -[ -u8 -] -) -- -> -Option -< -( -) -> -{ -use -regex_automata -: -: -dfa -: -: -Automaton -; -if -given_data -. -len -( -) -< -2 -{ -return -None -; -} -let -haystack_len -= -usize -: -: -from -( -given_data -[ -0 -] -) -; -let -haystack -= -given_data -. -get -( -1 -. -. -1 -+ -haystack_len -) -? -; -let -given_dfa_bytes -= -given_data -. -get -( -1 -+ -haystack_len -. -. -) -? -; -/ -/ -We -help -the -fuzzer -along -by -adding -a -preamble -to -the -bytes -that -should -/ -/ -at -least -make -these -first -parts -valid -. -The -preamble -expects -a -very -/ -/ -specific -sequence -of -bytes -so -it -makes -sense -to -just -force -this -. -let -label -= -" -rust -- -regex -- -automata -- -dfa -- -sparse -\ -x00 -\ -x00 -" -; -assert_eq -! -( -0 -label -. -len -( -) -% -4 -) -; -let -endianness_check -= -0xFEFFu32 -. -to_ne_bytes -( -) -. -to_vec -( -) -; -let -version_check -= -2u32 -. -to_ne_bytes -( -) -. -to_vec -( -) -; -let -mut -dfa_bytes -: -Vec -< -u8 -> -= -vec -! -[ -] -; -dfa_bytes -. -extend -( -label -. -as_bytes -( -) -) -; -dfa_bytes -. -extend -( -& -endianness_check -) -; -dfa_bytes -. -extend -( -& -version_check -) -; -dfa_bytes -. -extend -( -given_dfa_bytes -) -; -/ -/ -This -is -the -real -test -: -checking -that -any -input -we -give -to -/ -/ -DFA -: -: -from_bytes -will -never -result -in -a -panic -. -let -( -dfa -_ -) -= -regex_automata -: -: -dfa -: -: -sparse -: -: -DFA -: -: -from_bytes -( -& -dfa_bytes -) -. -ok -( -) -? -; -let -_ -= -dfa -. -try_search_fwd -( -& -regex_automata -: -: -Input -: -: -new -( -haystack -) -) -; -Some -( -( -) -) -} diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_dense_crash-9486fb7c8a93b12c12a62166b43d31640c0208a9 b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_dense_crash-9486fb7c8a93b12c12a62166b43d31640c0208a9 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_dense_minimized-from-9486fb7c8a93b12c12a62166b43d31640c0208a9 b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_dense_minimized-from-9486fb7c8a93b12c12a62166b43d31640c0208a9 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-0da59c0434eaf35e5a6b470fa9244bb79c72b000 b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-0da59c0434eaf35e5a6b470fa9244bb79c72b000 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-18cfc246f2ddfc3dfc92b0c7893178c7cf65efa9 b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-18cfc246f2ddfc3dfc92b0c7893178c7cf65efa9 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-61fd8e3003bf9d99f6c1e5a8488727eefd234b98 b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-61fd8e3003bf9d99f6c1e5a8488727eefd234b98 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-a1b839d899ced76d5d7d0f78f9edb7a421505838 b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-a1b839d899ced76d5d7d0f78f9edb7a421505838 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-c383ae07ec5e191422eadc492117439011816570 b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-c383ae07ec5e191422eadc492117439011816570 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-d07703ceb94b10dcd9e4acb809f2051420449e2b b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-d07703ceb94b10dcd9e4acb809f2051420449e2b deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-dbb8172d3984e7e7d03f4b5f8bb86ecd1460eff9 b/third_party/rust/regex-automata/tests/fuzz/testdata/deserialize_sparse_crash-dbb8172d3984e7e7d03f4b5f8bb86ecd1460eff9 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/gen/README.md b/third_party/rust/regex-automata/tests/gen/README.md deleted file mode 100644 index 0bb3550b1df9e..0000000000000 --- a/third_party/rust/regex-automata/tests/gen/README.md +++ /dev/null @@ -1,522 +0,0 @@ -This -directory -contains -tests -for -serialized -objects -from -the -regex -- -automata -crate -. -Currently -there -are -only -two -supported -such -objects -: -dense -and -sparse -DFAs -. -The -idea -behind -these -tests -is -to -commit -some -serialized -objects -and -run -some -basic -tests -by -deserializing -them -and -running -searches -and -ensuring -they -are -correct -. -We -also -make -sure -these -are -run -under -Miri -since -deserialization -is -one -of -the -biggest -places -where -undefined -behavior -might -occur -in -this -crate -( -at -the -time -of -writing -) -. -The -main -thing -we -' -re -testing -is -that -the -* -current -* -code -can -still -deserialize -* -old -* -objects -correctly -. -Generally -speaking -compatibility -extends -to -semver -compatible -releases -of -this -crate -. -Beyond -that -no -promises -are -made -although -in -practice -callers -can -at -least -depend -on -errors -occurring -. -( -The -serialized -format -always -includes -a -version -number -and -incompatible -changes -increment -that -version -number -such -that -an -error -will -occur -if -an -unsupported -version -is -detected -. -) -To -generate -the -dense -DFAs -I -used -this -command -: -regex -- -cli -generate -serialize -dense -regex -\ -MULTI_PATTERN_V2 -\ -tests -/ -gen -/ -dense -/ -\ -- -- -rustfmt -\ -- -- -safe -\ -- -- -starts -- -for -- -each -- -pattern -\ -- -- -specialize -- -start -- -states -\ -- -- -start -- -kind -both -\ -- -- -unicode -- -word -- -boundary -\ -- -- -minimize -\ -' -\ -b -[ -a -- -zA -- -Z -] -+ -\ -b -' -\ -' -( -? -m -) -^ -\ -S -+ -' -\ -' -( -? -Rm -) -^ -\ -S -+ -' -And -to -generate -the -sparse -DFAs -I -used -this -command -which -is -the -same -as -above -but -with -s -/ -dense -/ -sparse -/ -g -. -regex -- -cli -generate -serialize -sparse -regex -\ -MULTI_PATTERN_V2 -\ -tests -/ -gen -/ -sparse -/ -\ -- -- -rustfmt -\ -- -- -safe -\ -- -- -starts -- -for -- -each -- -pattern -\ -- -- -specialize -- -start -- -states -\ -- -- -start -- -kind -both -\ -- -- -unicode -- -word -- -boundary -\ -- -- -minimize -\ -' -\ -b -[ -a -- -zA -- -Z -] -+ -\ -b -' -\ -' -( -? -m -) -^ -\ -S -+ -' -\ -' -( -? -Rm -) -^ -\ -S -+ -' -The -idea -is -to -try -to -enable -as -many -of -the -DFA -' -s -options -as -possible -in -order -to -test -that -serialization -works -for -all -of -them -. -Arguably -we -should -increase -test -coverage -here -but -this -is -a -start -. -Note -that -in -particular -this -does -not -need -to -test -that -serialization -and -deserialization -correctly -roundtrips -on -its -own -. -Indeed -the -normal -regex -test -suite -has -a -test -that -does -a -serialization -round -trip -for -every -test -supported -by -DFAs -. -So -that -has -very -good -coverage -. -What -we -' -re -interested -in -testing -here -is -our -compatibility -promise -: -do -DFAs -generated -with -an -older -revision -of -the -code -still -deserialize -correctly -? diff --git a/third_party/rust/regex-automata/tests/gen/dense/mod.rs b/third_party/rust/regex-automata/tests/gen/dense/mod.rs deleted file mode 100644 index 7268f89eb5858..0000000000000 --- a/third_party/rust/regex-automata/tests/gen/dense/mod.rs +++ /dev/null @@ -1,345 +0,0 @@ -use -regex_automata -: -: -{ -Input -Match -} -; -mod -multi_pattern_v2 -; -# -[ -test -] -fn -multi_pattern_v2 -( -) -{ -use -multi_pattern_v2 -: -: -MULTI_PATTERN_V2 -as -RE -; -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -4 -) -) -RE -. -find -( -" -abcd -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -6 -) -) -RE -. -find -( -" -abcd -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -0 -. -. -6 -) -) -RE -. -find -( -" -abcd -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -5 -) -) -RE -. -find -( -" -\ -nabcd -\ -n -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -5 -) -) -RE -. -find -( -" -\ -nabcd -wxyz -\ -n -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -1 -. -. -7 -) -) -RE -. -find -( -" -\ -n -abcd -\ -n -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -0 -. -. -6 -) -) -RE -. -find -( -" -abcd -\ -r -\ -n -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -2 -. -. -8 -) -) -RE -. -find -( -" -\ -r -\ -n -abcd -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -2 -. -. -8 -) -) -RE -. -find -( -" -\ -r -\ -n -abcd -\ -r -\ -n -" -) -) -; -/ -/ -Fails -because -we -have -heuristic -support -for -Unicode -word -boundaries -/ -/ -enabled -. -assert -! -( -RE -. -try_search -( -& -Input -: -: -new -( -b -" -\ -xFF -abcd -\ -xFF -" -) -) -. -is_err -( -) -) -; -} diff --git a/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2.rs b/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2.rs deleted file mode 100644 index cb3918c4d41ba..0000000000000 --- a/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2.rs +++ /dev/null @@ -1,395 +0,0 @@ -/ -/ -DO -NOT -EDIT -THIS -FILE -. -IT -WAS -AUTOMATICALLY -GENERATED -BY -: -/ -/ -/ -/ -regex -- -cli -generate -serialize -dense -regex -MULTI_PATTERN_V2 -tests -/ -gen -/ -dense -/ -- -- -rustfmt -- -- -safe -- -- -starts -- -for -- -each -- -pattern -- -- -specialize -- -start -- -states -- -- -start -- -kind -both -- -- -unicode -- -word -- -boundary -- -- -minimize -\ -b -[ -a -- -zA -- -Z -] -+ -\ -b -( -? -m -) -^ -\ -S -+ -( -? -Rm -) -^ -\ -S -+ -/ -/ -/ -/ -regex -- -cli -0 -. -0 -. -1 -is -available -on -crates -. -io -. -use -regex_automata -: -: -{ -dfa -: -: -{ -dense -: -: -DFA -regex -: -: -Regex -} -util -: -: -{ -lazy -: -: -Lazy -wire -: -: -AlignAs -} -} -; -pub -static -MULTI_PATTERN_V2 -: -Lazy -< -Regex -< -DFA -< -& -' -static -[ -u32 -] -> -> -> -= -Lazy -: -: -new -( -| -| -{ -let -dfafwd -= -{ -static -ALIGNED -: -& -AlignAs -< -[ -u8 -] -u32 -> -= -& -AlignAs -{ -_align -: -[ -] -# -[ -cfg -( -target_endian -= -" -big -" -) -] -bytes -: -* -include_bytes -! -( -" -multi_pattern_v2_fwd -. -bigendian -. -dfa -" -) -# -[ -cfg -( -target_endian -= -" -little -" -) -] -bytes -: -* -include_bytes -! -( -" -multi_pattern_v2_fwd -. -littleendian -. -dfa -" -) -} -; -DFA -: -: -from_bytes -( -& -ALIGNED -. -bytes -) -. -expect -( -" -serialized -forward -DFA -should -be -valid -" -) -. -0 -} -; -let -dfarev -= -{ -static -ALIGNED -: -& -AlignAs -< -[ -u8 -] -u32 -> -= -& -AlignAs -{ -_align -: -[ -] -# -[ -cfg -( -target_endian -= -" -big -" -) -] -bytes -: -* -include_bytes -! -( -" -multi_pattern_v2_rev -. -bigendian -. -dfa -" -) -# -[ -cfg -( -target_endian -= -" -little -" -) -] -bytes -: -* -include_bytes -! -( -" -multi_pattern_v2_rev -. -littleendian -. -dfa -" -) -} -; -DFA -: -: -from_bytes -( -& -ALIGNED -. -bytes -) -. -expect -( -" -serialized -reverse -DFA -should -be -valid -" -) -. -0 -} -; -Regex -: -: -builder -( -) -. -build_from_dfas -( -dfafwd -dfarev -) -} -) -; diff --git a/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_fwd.bigendian.dfa b/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_fwd.bigendian.dfa deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_fwd.littleendian.dfa b/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_fwd.littleendian.dfa deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_rev.bigendian.dfa b/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_rev.bigendian.dfa deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_rev.littleendian.dfa b/third_party/rust/regex-automata/tests/gen/dense/multi_pattern_v2_rev.littleendian.dfa deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/gen/mod.rs b/third_party/rust/regex-automata/tests/gen/mod.rs deleted file mode 100644 index 262c06c1409ea..0000000000000 --- a/third_party/rust/regex-automata/tests/gen/mod.rs +++ /dev/null @@ -1,6 +0,0 @@ -mod -dense -; -mod -sparse -; diff --git a/third_party/rust/regex-automata/tests/gen/sparse/mod.rs b/third_party/rust/regex-automata/tests/gen/sparse/mod.rs deleted file mode 100644 index 7268f89eb5858..0000000000000 --- a/third_party/rust/regex-automata/tests/gen/sparse/mod.rs +++ /dev/null @@ -1,345 +0,0 @@ -use -regex_automata -: -: -{ -Input -Match -} -; -mod -multi_pattern_v2 -; -# -[ -test -] -fn -multi_pattern_v2 -( -) -{ -use -multi_pattern_v2 -: -: -MULTI_PATTERN_V2 -as -RE -; -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -0 -. -. -4 -) -) -RE -. -find -( -" -abcd -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -2 -. -. -6 -) -) -RE -. -find -( -" -abcd -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -0 -. -. -6 -) -) -RE -. -find -( -" -abcd -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -5 -) -) -RE -. -find -( -" -\ -nabcd -\ -n -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -0 -1 -. -. -5 -) -) -RE -. -find -( -" -\ -nabcd -wxyz -\ -n -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -1 -. -. -7 -) -) -RE -. -find -( -" -\ -n -abcd -\ -n -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -0 -. -. -6 -) -) -RE -. -find -( -" -abcd -\ -r -\ -n -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -1 -2 -. -. -8 -) -) -RE -. -find -( -" -\ -r -\ -n -abcd -" -) -) -; -assert_eq -! -( -Some -( -Match -: -: -must -( -2 -2 -. -. -8 -) -) -RE -. -find -( -" -\ -r -\ -n -abcd -\ -r -\ -n -" -) -) -; -/ -/ -Fails -because -we -have -heuristic -support -for -Unicode -word -boundaries -/ -/ -enabled -. -assert -! -( -RE -. -try_search -( -& -Input -: -: -new -( -b -" -\ -xFF -abcd -\ -xFF -" -) -) -. -is_err -( -) -) -; -} diff --git a/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2.rs b/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2.rs deleted file mode 100644 index 8910301202f56..0000000000000 --- a/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2.rs +++ /dev/null @@ -1,377 +0,0 @@ -/ -/ -DO -NOT -EDIT -THIS -FILE -. -IT -WAS -AUTOMATICALLY -GENERATED -BY -: -/ -/ -/ -/ -regex -- -cli -generate -serialize -sparse -regex -MULTI_PATTERN_V2 -regex -- -automata -/ -tests -/ -gen -/ -sparse -/ -- -- -rustfmt -- -- -safe -- -- -starts -- -for -- -each -- -pattern -- -- -specialize -- -start -- -states -- -- -start -- -kind -both -- -- -unicode -- -word -- -boundary -- -- -minimize -\ -b -[ -a -- -zA -- -Z -] -+ -\ -b -( -? -m -) -^ -\ -S -+ -( -? -Rm -) -^ -\ -S -+ -/ -/ -/ -/ -regex -- -cli -0 -. -0 -. -1 -is -available -on -crates -. -io -. -use -regex_automata -: -: -{ -dfa -: -: -{ -regex -: -: -Regex -sparse -: -: -DFA -} -util -: -: -lazy -: -: -Lazy -} -; -pub -static -MULTI_PATTERN_V2 -: -Lazy -< -Regex -< -DFA -< -& -' -static -[ -u8 -] -> -> -> -= -Lazy -: -: -new -( -| -| -{ -let -dfafwd -= -{ -# -[ -cfg -( -target_endian -= -" -big -" -) -] -static -BYTES -: -& -' -static -[ -u8 -] -= -include_bytes -! -( -" -multi_pattern_v2_fwd -. -bigendian -. -dfa -" -) -; -# -[ -cfg -( -target_endian -= -" -little -" -) -] -static -BYTES -: -& -' -static -[ -u8 -] -= -include_bytes -! -( -" -multi_pattern_v2_fwd -. -littleendian -. -dfa -" -) -; -DFA -: -: -from_bytes -( -BYTES -) -. -expect -( -" -serialized -forward -DFA -should -be -valid -" -) -. -0 -} -; -let -dfarev -= -{ -# -[ -cfg -( -target_endian -= -" -big -" -) -] -static -BYTES -: -& -' -static -[ -u8 -] -= -include_bytes -! -( -" -multi_pattern_v2_rev -. -bigendian -. -dfa -" -) -; -# -[ -cfg -( -target_endian -= -" -little -" -) -] -static -BYTES -: -& -' -static -[ -u8 -] -= -include_bytes -! -( -" -multi_pattern_v2_rev -. -littleendian -. -dfa -" -) -; -DFA -: -: -from_bytes -( -BYTES -) -. -expect -( -" -serialized -reverse -DFA -should -be -valid -" -) -. -0 -} -; -Regex -: -: -builder -( -) -. -build_from_dfas -( -dfafwd -dfarev -) -} -) -; diff --git a/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_fwd.bigendian.dfa b/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_fwd.bigendian.dfa deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_fwd.littleendian.dfa b/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_fwd.littleendian.dfa deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_rev.bigendian.dfa b/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_rev.bigendian.dfa deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_rev.littleendian.dfa b/third_party/rust/regex-automata/tests/gen/sparse/multi_pattern_v2_rev.littleendian.dfa deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex-automata/tests/hybrid/api.rs b/third_party/rust/regex-automata/tests/hybrid/api.rs deleted file mode 100644 index 9655643fa299e..0000000000000 --- a/third_party/rust/regex-automata/tests/hybrid/api.rs +++ /dev/null @@ -1,1533 +0,0 @@ -use -std -: -: -error -: -: -Error -; -use -regex_automata -: -: -{ -hybrid -: -: -dfa -: -: -{ -OverlappingState -DFA -} -nfa -: -: -thompson -HalfMatch -Input -MatchError -} -; -/ -/ -Tests -that -too -many -cache -resets -cause -the -lazy -DFA -to -quit -. -/ -/ -/ -/ -We -only -test -this -on -64 -- -bit -because -the -test -is -gingerly -crafted -based -on -/ -/ -implementation -details -of -cache -sizes -. -It -' -s -not -a -great -test -because -of -/ -/ -that -but -it -does -check -some -interesting -properties -around -how -positions -are -/ -/ -reported -when -a -search -" -gives -up -. -" -/ -/ -/ -/ -NOTE -: -If -you -change -something -in -lazy -DFA -implementation -that -causes -this -/ -/ -test -to -fail -by -reporting -different -" -gave -up -" -positions -then -it -' -s -generally -/ -/ -okay -to -update -the -positions -in -the -test -below -as -long -as -you -' -re -sure -your -/ -/ -changes -are -correct -. -Namely -it -is -expected -that -if -there -are -changes -in -the -/ -/ -cache -size -( -or -changes -in -how -big -things -are -inside -the -cache -) -then -its -/ -/ -utilization -may -change -slightly -and -thus -impact -where -a -search -gives -up -. -/ -/ -Precisely -where -a -search -gives -up -is -not -an -API -guarantee -so -changing -the -/ -/ -offsets -here -is -OK -. -# -[ -test -] -# -[ -cfg -( -target_pointer_width -= -" -64 -" -) -] -# -[ -cfg -( -not -( -miri -) -) -] -fn -too_many_cache_resets_cause_quit -( -) -- -> -Result -< -( -) -Box -< -dyn -Error -> -> -{ -/ -/ -This -is -a -carefully -chosen -regex -. -The -idea -is -to -pick -one -that -requires -/ -/ -some -decent -number -of -states -( -hence -the -bounded -repetition -) -. -But -we -/ -/ -specifically -choose -to -create -a -class -with -an -ASCII -letter -and -a -/ -/ -non -- -ASCII -letter -so -that -we -can -check -that -no -new -states -are -created -/ -/ -once -the -cache -is -full -. -Namely -if -we -fill -up -the -cache -on -a -haystack -/ -/ -of -' -a -' -s -then -in -order -to -match -one -' -' -a -new -state -will -need -to -be -/ -/ -created -since -a -' -' -is -encoded -with -multiple -bytes -. -/ -/ -/ -/ -So -we -proceed -by -" -filling -" -up -the -cache -by -searching -a -haystack -of -just -/ -/ -' -a -' -s -. -The -cache -won -' -t -have -enough -room -to -add -enough -states -to -find -the -/ -/ -match -( -because -of -the -bounded -repetition -) -which -should -result -in -it -/ -/ -giving -up -before -it -finds -a -match -. -/ -/ -/ -/ -Since -there -' -s -now -no -more -room -to -create -states -we -search -a -haystack -/ -/ -of -' -' -and -confirm -that -it -gives -up -immediately -. -let -pattern -= -r -" -[ -a -] -{ -99 -} -" -; -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -/ -/ -Configure -it -so -that -we -have -the -minimum -cache -capacity -/ -/ -possible -. -And -that -if -any -resets -occur -the -search -quits -. -DFA -: -: -config -( -) -. -skip_cache_capacity_check -( -true -) -. -cache_capacity -( -0 -) -. -minimum_cache_clear_count -( -Some -( -0 -) -) -) -. -thompson -( -thompson -: -: -NFA -: -: -config -( -) -) -. -build -( -pattern -) -? -; -let -mut -cache -= -dfa -. -create_cache -( -) -; -let -haystack -= -" -a -" -. -repeat -( -101 -) -. -into_bytes -( -) -; -let -err -= -MatchError -: -: -gave_up -( -25 -) -; -/ -/ -Notice -that -we -make -the -same -amount -of -progress -in -each -search -! -That -' -s -/ -/ -because -the -cache -is -reused -and -already -has -states -to -handle -the -first -/ -/ -N -bytes -. -assert_eq -! -( -Err -( -err -. -clone -( -) -) -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -) -; -assert_eq -! -( -Err -( -err -. -clone -( -) -) -dfa -. -try_search_overlapping_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -& -mut -OverlappingState -: -: -start -( -) -) -) -; -let -haystack -= -" -" -. -repeat -( -101 -) -. -into_bytes -( -) -; -let -err -= -MatchError -: -: -gave_up -( -2 -) -; -assert_eq -! -( -Err -( -err -) -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -) -; -/ -/ -no -need -to -test -that -other -find -routines -quit -since -we -did -that -above -/ -/ -OK -if -we -reset -the -cache -then -we -should -be -able -to -create -more -states -/ -/ -and -make -more -progress -with -searching -for -betas -. -cache -. -reset -( -& -dfa -) -; -let -err -= -MatchError -: -: -gave_up -( -27 -) -; -assert_eq -! -( -Err -( -err -) -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -) -; -/ -/ -. -. -. -switching -back -to -ASCII -still -makes -progress -since -it -just -needs -to -/ -/ -set -transitions -on -existing -states -! -let -haystack -= -" -a -" -. -repeat -( -101 -) -. -into_bytes -( -) -; -let -err -= -MatchError -: -: -gave_up -( -13 -) -; -assert_eq -! -( -Err -( -err -) -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -& -haystack -) -) -) -; -Ok -( -( -) -) -} -/ -/ -Tests -that -quit -bytes -in -the -forward -direction -work -correctly -. -# -[ -test -] -fn -quit_fwd -( -) -- -> -Result -< -( -) -Box -< -dyn -Error -> -> -{ -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -quit -( -b -' -x -' -true -) -) -. -build -( -" -[ -[ -: -word -: -] -] -+ -" -) -? -; -let -mut -cache -= -dfa -. -create_cache -( -) -; -assert_eq -! -( -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -abcxyz -" -) -) -Err -( -MatchError -: -: -quit -( -b -' -x -' -3 -) -) -) -; -assert_eq -! -( -dfa -. -try_search_overlapping_fwd -( -& -mut -cache -& -Input -: -: -new -( -b -" -abcxyz -" -) -& -mut -OverlappingState -: -: -start -( -) -) -Err -( -MatchError -: -: -quit -( -b -' -x -' -3 -) -) -) -; -Ok -( -( -) -) -} -/ -/ -Tests -that -quit -bytes -in -the -reverse -direction -work -correctly -. -# -[ -test -] -fn -quit_rev -( -) -- -> -Result -< -( -) -Box -< -dyn -Error -> -> -{ -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -DFA -: -: -config -( -) -. -quit -( -b -' -x -' -true -) -) -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -reverse -( -true -) -) -. -build -( -" -^ -[ -[ -: -word -: -] -] -+ -" -) -? -; -let -mut -cache -= -dfa -. -create_cache -( -) -; -assert_eq -! -( -dfa -. -try_search_rev -( -& -mut -cache -& -Input -: -: -new -( -" -abcxyz -" -) -) -Err -( -MatchError -: -: -quit -( -b -' -x -' -3 -) -) -) -; -Ok -( -( -) -) -} -/ -/ -Tests -that -if -we -heuristically -enable -Unicode -word -boundaries -but -then -/ -/ -instruct -that -a -non -- -ASCII -byte -should -NOT -be -a -quit -byte -then -the -builder -/ -/ -will -panic -. -# -[ -test -] -# -[ -should_panic -] -fn -quit_panics -( -) -{ -DFA -: -: -config -( -) -. -unicode_word_boundary -( -true -) -. -quit -( -b -' -\ -xFF -' -false -) -; -} -/ -/ -This -tests -an -intesting -case -where -even -if -the -Unicode -word -boundary -option -/ -/ -is -disabled -setting -all -non -- -ASCII -bytes -to -be -quit -bytes -will -cause -Unicode -/ -/ -word -boundaries -to -be -enabled -. -# -[ -test -] -fn -unicode_word_implicitly_works -( -) -- -> -Result -< -( -) -Box -< -dyn -Error -> -> -{ -let -mut -config -= -DFA -: -: -config -( -) -; -for -b -in -0x80 -. -. -= -0xFF -{ -config -= -config -. -quit -( -b -true -) -; -} -let -dfa -= -DFA -: -: -builder -( -) -. -configure -( -config -) -. -build -( -r -" -\ -b -" -) -? -; -let -mut -cache -= -dfa -. -create_cache -( -) -; -let -expected -= -HalfMatch -: -: -must -( -0 -1 -) -; -assert_eq -! -( -Ok -( -Some -( -expected -) -) -dfa -. -try_search_fwd -( -& -mut -cache -& -Input -: -: -new -( -" -a -" -) -) -) -; -Ok -( -( -) -) -} diff --git a/third_party/rust/regex-automata/tests/hybrid/mod.rs b/third_party/rust/regex-automata/tests/hybrid/mod.rs deleted file mode 100644 index 7af58e2ac3c94..0000000000000 --- a/third_party/rust/regex-automata/tests/hybrid/mod.rs +++ /dev/null @@ -1,16 +0,0 @@ -mod -api -; -# -[ -cfg -( -not -( -miri -) -) -] -mod -suite -; diff --git a/third_party/rust/regex-automata/tests/hybrid/suite.rs b/third_party/rust/regex-automata/tests/hybrid/suite.rs deleted file mode 100644 index 88854b1399073..0000000000000 --- a/third_party/rust/regex-automata/tests/hybrid/suite.rs +++ /dev/null @@ -1,3143 +0,0 @@ -use -{ -anyhow -: -: -Result -regex_automata -: -: -{ -hybrid -: -: -{ -dfa -: -: -{ -OverlappingState -DFA -} -regex -: -: -{ -self -Regex -} -} -nfa -: -: -thompson -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -Anchored -Input -PatternSet -} -regex_test -: -: -{ -CompiledRegex -Match -RegexTest -SearchKind -Span -TestResult -TestRunner -} -} -; -use -crate -: -: -{ -create_input -suite -untestify_kind -} -; -const -EXPANSIONS -: -& -[ -& -str -] -= -& -[ -" -is_match -" -" -find -" -" -which -" -] -; -/ -/ -/ -Tests -the -default -configuration -of -the -hybrid -NFA -/ -DFA -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -Regex -: -: -builder -( -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -/ -/ -Without -NFA -shrinking -this -test -blows -the -default -cache -capacity -. -. -blacklist -( -" -expensive -/ -regression -- -many -- -repeat -- -no -- -stack -- -overflow -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -hybrid -NFA -/ -DFA -with -prefilters -enabled -. -# -[ -test -] -fn -prefilter -( -) -- -> -Result -< -( -) -> -{ -let -my_compiler -= -| -test -: -& -RegexTest -regexes -: -& -[ -String -] -| -{ -/ -/ -Parse -regexes -as -HIRs -so -we -can -get -literals -to -build -a -prefilter -. -let -mut -hirs -= -vec -! -[ -] -; -for -pattern -in -regexes -. -iter -( -) -{ -hirs -. -push -( -syntax -: -: -parse_with -( -pattern -& -config_syntax -( -test -) -) -? -) -; -} -let -kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -Some -( -kind -) -= -> -kind -} -; -let -pre -= -Prefilter -: -: -from_hirs_prefix -( -kind -& -hirs -) -; -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dfa -( -DFA -: -: -config -( -) -. -prefilter -( -pre -) -) -; -compiler -( -builder -) -( -test -regexes -) -} -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -/ -/ -Without -NFA -shrinking -this -test -blows -the -default -cache -capacity -. -. -blacklist -( -" -expensive -/ -regression -- -many -- -repeat -- -no -- -stack -- -overflow -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -my_compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -hybrid -NFA -/ -DFA -with -NFA -shrinking -enabled -. -/ -/ -/ -/ -/ -/ -This -is -* -usually -* -not -the -configuration -one -wants -for -a -lazy -DFA -. -NFA -/ -/ -/ -shrinking -is -mostly -only -advantageous -when -building -a -full -DFA -since -it -/ -/ -/ -can -sharply -decrease -the -amount -of -time -determinization -takes -. -But -NFA -/ -/ -/ -shrinking -is -itself -otherwise -fairly -expensive -currently -. -Since -a -lazy -DFA -/ -/ -/ -has -no -compilation -time -( -other -than -for -building -the -NFA -of -course -) -before -/ -/ -/ -executing -a -search -it -' -s -usually -worth -it -to -forgo -NFA -shrinking -. -/ -/ -/ -/ -/ -/ -Nevertheless -we -test -to -make -sure -everything -is -OK -with -NFA -shrinking -. -As -/ -/ -/ -a -bonus -there -are -some -tests -we -don -' -t -need -to -skip -because -they -now -fit -in -/ -/ -/ -the -default -cache -capacity -. -# -[ -test -] -fn -nfa_shrink -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -thompson -( -thompson -: -: -Config -: -: -new -( -) -. -shrink -( -true -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -hybrid -NFA -/ -DFA -when -' -starts_for_each_pattern -' -is -enabled -for -all -/ -/ -/ -tests -. -# -[ -test -] -fn -starts_for_each_pattern -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dfa -( -DFA -: -: -config -( -) -. -starts_for_each_pattern -( -true -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -/ -/ -Without -NFA -shrinking -this -test -blows -the -default -cache -capacity -. -. -blacklist -( -" -expensive -/ -regression -- -many -- -repeat -- -no -- -stack -- -overflow -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -hybrid -NFA -/ -DFA -when -' -specialize_start_states -' -is -enabled -. -# -[ -test -] -fn -specialize_start_states -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dfa -( -DFA -: -: -config -( -) -. -specialize_start_states -( -true -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -/ -/ -Without -NFA -shrinking -this -test -blows -the -default -cache -capacity -. -. -blacklist -( -" -expensive -/ -regression -- -many -- -repeat -- -no -- -stack -- -overflow -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -hybrid -NFA -/ -DFA -when -byte -classes -are -disabled -. -/ -/ -/ -/ -/ -/ -N -. -B -. -Disabling -byte -classes -doesn -' -t -avoid -any -indirection -at -search -time -. -/ -/ -/ -All -it -does -is -cause -every -byte -value -to -be -its -own -distinct -equivalence -/ -/ -/ -class -. -# -[ -test -] -fn -no_byte_classes -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dfa -( -DFA -: -: -config -( -) -. -byte_classes -( -false -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -/ -/ -Without -NFA -shrinking -this -test -blows -the -default -cache -capacity -. -. -blacklist -( -" -expensive -/ -regression -- -many -- -repeat -- -no -- -stack -- -overflow -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -that -hybrid -NFA -/ -DFA -never -clears -its -cache -for -any -test -with -the -/ -/ -/ -default -capacity -. -/ -/ -/ -/ -/ -/ -N -. -B -. -If -a -regex -suite -test -is -added -that -causes -the -cache -to -be -cleared -/ -/ -/ -then -this -should -just -skip -that -test -. -( -Which -can -be -done -by -calling -the -/ -/ -/ -' -blacklist -' -method -on -' -TestRunner -' -. -) -# -[ -test -] -fn -no_cache_clearing -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dfa -( -DFA -: -: -config -( -) -. -minimum_cache_clear_count -( -Some -( -0 -) -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -/ -/ -Without -NFA -shrinking -this -test -blows -the -default -cache -capacity -. -. -blacklist -( -" -expensive -/ -regression -- -many -- -repeat -- -no -- -stack -- -overflow -" -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -hybrid -NFA -/ -DFA -when -the -minimum -cache -capacity -is -set -. -# -[ -test -] -fn -min_cache_capacity -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -dfa -( -DFA -: -: -config -( -) -. -cache_capacity -( -0 -) -. -skip_cache_capacity_check -( -true -) -) -; -TestRunner -: -: -new -( -) -? -. -expand -( -EXPANSIONS -| -t -| -t -. -compiles -( -) -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -compiler -( -mut -builder -: -regex -: -: -Builder -) -- -> -impl -FnMut -( -& -RegexTest -& -[ -String -] -) -- -> -Result -< -CompiledRegex -> -{ -move -| -test -regexes -| -{ -/ -/ -Parse -regexes -as -HIRs -for -some -analysis -below -. -let -mut -hirs -= -vec -! -[ -] -; -for -pattern -in -regexes -. -iter -( -) -{ -hirs -. -push -( -syntax -: -: -parse_with -( -pattern -& -config_syntax -( -test -) -) -? -) -; -} -/ -/ -Check -if -our -regex -contains -things -that -aren -' -t -supported -by -DFAs -. -/ -/ -That -is -Unicode -word -boundaries -when -searching -non -- -ASCII -text -. -if -! -test -. -haystack -( -) -. -is_ascii -( -) -{ -for -hir -in -hirs -. -iter -( -) -{ -if -hir -. -properties -( -) -. -look_set -( -) -. -contains_word_unicode -( -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -} -} -if -! -configure_regex_builder -( -test -& -mut -builder -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -let -re -= -builder -. -build_many -( -& -regexes -) -? -; -let -mut -cache -= -re -. -create_cache -( -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -& -mut -cache -test -) -} -) -) -} -} -fn -run_test -( -re -: -& -Regex -cache -: -& -mut -regex -: -: -Cache -test -: -& -RegexTest -) -- -> -TestResult -{ -let -input -= -create_input -( -test -) -; -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -{ -TestResult -: -: -matched -( -re -. -is_match -( -cache -input -. -earliest -( -true -) -) -) -} -" -find -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Leftmost -= -> -{ -let -input -= -input -. -earliest -( -test -. -search_kind -( -) -= -= -SearchKind -: -: -Earliest -) -; -TestResult -: -: -matches -( -re -. -find_iter -( -cache -input -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -m -. -pattern -( -) -. -as_usize -( -) -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -) -} -SearchKind -: -: -Overlapping -= -> -{ -try_search_overlapping -( -re -cache -& -input -) -. -unwrap -( -) -} -} -" -which -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Leftmost -= -> -{ -/ -/ -There -are -no -" -which -" -APIs -for -standard -searches -. -TestResult -: -: -skip -( -) -} -SearchKind -: -: -Overlapping -= -> -{ -let -dfa -= -re -. -forward -( -) -; -let -cache -= -cache -. -as_parts_mut -( -) -. -0 -; -let -mut -patset -= -PatternSet -: -: -new -( -dfa -. -pattern_len -( -) -) -; -dfa -. -try_which_overlapping_matches -( -cache -& -input -& -mut -patset -) -. -unwrap -( -) -; -TestResult -: -: -which -( -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -) -} -} -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Configures -the -given -regex -builder -with -all -relevant -settings -on -the -given -/ -/ -/ -regex -test -. -/ -/ -/ -/ -/ -/ -If -the -regex -test -has -a -setting -that -is -unsupported -then -this -returns -/ -/ -/ -false -( -implying -the -test -should -be -skipped -) -. -fn -configure_regex_builder -( -test -: -& -RegexTest -builder -: -& -mut -regex -: -: -Builder -) -- -> -bool -{ -let -match_kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -false -Some -( -k -) -= -> -k -} -; -let -mut -dfa_config -= -DFA -: -: -config -( -) -. -match_kind -( -match_kind -) -. -unicode_word_boundary -( -true -) -; -/ -/ -When -doing -an -overlapping -search -we -might -try -to -find -the -start -of -each -/ -/ -match -with -a -custom -search -routine -. -In -that -case -we -need -to -tell -the -/ -/ -reverse -search -( -for -the -start -offset -) -which -pattern -to -look -for -. -The -/ -/ -only -way -that -API -works -is -when -anchored -starting -states -are -compiled -/ -/ -for -each -pattern -. -This -does -technically -also -enable -it -for -the -forward -/ -/ -DFA -but -we -' -re -okay -with -that -. -if -test -. -search_kind -( -) -= -= -SearchKind -: -: -Overlapping -{ -dfa_config -= -dfa_config -. -starts_for_each_pattern -( -true -) -; -} -builder -. -syntax -( -config_syntax -( -test -) -) -. -thompson -( -config_thompson -( -test -) -) -. -dfa -( -dfa_config -) -; -true -} -/ -/ -/ -Configuration -of -a -Thompson -NFA -compiler -from -a -regex -test -. -fn -config_thompson -( -test -: -& -RegexTest -) -- -> -thompson -: -: -Config -{ -let -mut -lookm -= -regex_automata -: -: -util -: -: -look -: -: -LookMatcher -: -: -new -( -) -; -lookm -. -set_line_terminator -( -test -. -line_terminator -( -) -) -; -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -test -. -utf8 -( -) -) -. -look_matcher -( -lookm -) -} -/ -/ -/ -Configuration -of -the -regex -parser -from -a -regex -test -. -fn -config_syntax -( -test -: -& -RegexTest -) -- -> -syntax -: -: -Config -{ -syntax -: -: -Config -: -: -new -( -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -utf8 -( -test -. -utf8 -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -} -/ -/ -/ -Execute -an -overlapping -search -and -for -each -match -found -also -find -its -/ -/ -/ -overlapping -starting -positions -. -/ -/ -/ -/ -/ -/ -N -. -B -. -This -routine -used -to -be -part -of -the -crate -API -but -1 -) -it -wasn -' -t -clear -/ -/ -/ -to -me -how -useful -it -was -and -2 -) -it -wasn -' -t -clear -to -me -what -its -semantics -/ -/ -/ -should -be -. -In -particular -a -potentially -surprising -footgun -of -this -routine -/ -/ -/ -that -it -is -worst -case -* -quadratic -* -in -the -size -of -the -haystack -. -Namely -it -' -s -/ -/ -/ -possible -to -report -a -match -at -every -position -and -for -every -such -position -/ -/ -/ -scan -all -the -way -to -the -beginning -of -the -haystack -to -find -the -starting -/ -/ -/ -position -. -Typical -leftmost -non -- -overlapping -searches -don -' -t -suffer -from -this -/ -/ -/ -because -well -matches -can -' -t -overlap -. -So -subsequent -searches -after -a -match -/ -/ -/ -is -found -don -' -t -revisit -previously -scanned -parts -of -the -haystack -. -/ -/ -/ -/ -/ -/ -Its -semantics -can -be -strange -for -other -reasons -too -. -For -example -given -/ -/ -/ -the -regex -' -. -* -' -and -the -haystack -' -zz -' -the -full -set -of -overlapping -matches -/ -/ -/ -is -: -[ -0 -0 -] -[ -1 -1 -] -[ -0 -1 -] -[ -2 -2 -] -[ -1 -2 -] -[ -0 -2 -] -. -The -ordering -of -/ -/ -/ -those -matches -is -quite -strange -but -makes -sense -when -you -think -about -the -/ -/ -/ -implementation -: -an -end -offset -is -found -left -- -to -- -right -and -then -one -or -more -/ -/ -/ -starting -offsets -are -found -right -- -to -- -left -. -/ -/ -/ -/ -/ -/ -Nevertheless -we -provide -this -routine -in -our -test -suite -because -it -' -s -/ -/ -/ -useful -to -test -the -low -level -DFA -overlapping -search -and -our -test -suite -/ -/ -/ -is -written -in -a -way -that -requires -starting -offsets -. -fn -try_search_overlapping -( -re -: -& -Regex -cache -: -& -mut -regex -: -: -Cache -input -: -& -Input -< -' -_ -> -) -- -> -Result -< -TestResult -> -{ -let -mut -matches -= -vec -! -[ -] -; -let -mut -fwd_state -= -OverlappingState -: -: -start -( -) -; -let -( -fwd_dfa -rev_dfa -) -= -( -re -. -forward -( -) -re -. -reverse -( -) -) -; -let -( -fwd_cache -rev_cache -) -= -cache -. -as_parts_mut -( -) -; -while -let -Some -( -end -) -= -{ -fwd_dfa -. -try_search_overlapping_fwd -( -fwd_cache -input -& -mut -fwd_state -) -? -; -fwd_state -. -get_match -( -) -} -{ -let -revsearch -= -input -. -clone -( -) -. -range -( -input -. -start -( -) -. -. -end -. -offset -( -) -) -. -anchored -( -Anchored -: -: -Pattern -( -end -. -pattern -( -) -) -) -. -earliest -( -false -) -; -let -mut -rev_state -= -OverlappingState -: -: -start -( -) -; -while -let -Some -( -start -) -= -{ -rev_dfa -. -try_search_overlapping_rev -( -rev_cache -& -revsearch -& -mut -rev_state -) -? -; -rev_state -. -get_match -( -) -} -{ -let -span -= -Span -{ -start -: -start -. -offset -( -) -end -: -end -. -offset -( -) -} -; -let -mat -= -Match -{ -id -: -end -. -pattern -( -) -. -as_usize -( -) -span -} -; -matches -. -push -( -mat -) -; -} -} -Ok -( -TestResult -: -: -matches -( -matches -) -) -} diff --git a/third_party/rust/regex-automata/tests/lib.rs b/third_party/rust/regex-automata/tests/lib.rs deleted file mode 100644 index be4028d96b8e6..0000000000000 --- a/third_party/rust/regex-automata/tests/lib.rs +++ /dev/null @@ -1,970 +0,0 @@ -/ -/ -We -have -a -similar -config -in -the -regex -- -automata -crate -root -. -Basically -it -is -/ -/ -just -too -annoying -to -deal -with -dead -code -when -a -subset -of -features -is -/ -/ -enabled -. -# -! -[ -cfg_attr -( -not -( -all -( -feature -= -" -std -" -feature -= -" -nfa -" -feature -= -" -dfa -" -feature -= -" -hybrid -" -feature -= -" -perf -- -literal -- -substring -" -feature -= -" -perf -- -literal -- -multisubstring -" -) -) -allow -( -dead_code -unused_imports -unused_variables -) -) -] -/ -/ -Similar -deal -with -Miri -. -Just -let -dead -code -warnings -be -. -# -! -[ -cfg_attr -( -miri -allow -( -dead_code -unused_imports -unused_variables -) -) -] -# -[ -cfg -( -any -( -feature -= -" -dfa -- -search -" -feature -= -" -dfa -- -onepass -" -) -) -] -mod -dfa -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -mod -fuzz -; -# -[ -cfg -( -feature -= -" -dfa -- -search -" -) -] -mod -gen -; -# -[ -cfg -( -feature -= -" -hybrid -" -) -] -mod -hybrid -; -# -[ -cfg -( -feature -= -" -meta -" -) -] -mod -meta -; -# -[ -cfg -( -any -( -feature -= -" -nfa -- -backtrack -" -feature -= -" -nfa -- -pikevm -" -) -) -] -mod -nfa -; -fn -suite -( -) -- -> -anyhow -: -: -Result -< -regex_test -: -: -RegexTests -> -{ -let -_ -= -env_logger -: -: -try_init -( -) -; -let -mut -tests -= -regex_test -: -: -RegexTests -: -: -new -( -) -; -macro_rules -! -load -{ -( -name -: -expr -) -= -> -{ -{ -const -DATA -: -& -[ -u8 -] -= -include_bytes -! -( -concat -! -( -" -. -. -/ -. -. -/ -testdata -/ -" -name -" -. -toml -" -) -) -; -tests -. -load_slice -( -name -DATA -) -? -; -} -} -; -} -load -! -( -" -anchored -" -) -; -load -! -( -" -bytes -" -) -; -load -! -( -" -crazy -" -) -; -load -! -( -" -crlf -" -) -; -load -! -( -" -earliest -" -) -; -load -! -( -" -empty -" -) -; -load -! -( -" -expensive -" -) -; -load -! -( -" -flags -" -) -; -load -! -( -" -iter -" -) -; -load -! -( -" -leftmost -- -all -" -) -; -load -! -( -" -line -- -terminator -" -) -; -load -! -( -" -misc -" -) -; -load -! -( -" -multiline -" -) -; -load -! -( -" -no -- -unicode -" -) -; -load -! -( -" -overlapping -" -) -; -load -! -( -" -regression -" -) -; -load -! -( -" -set -" -) -; -load -! -( -" -substring -" -) -; -load -! -( -" -unicode -" -) -; -load -! -( -" -utf8 -" -) -; -load -! -( -" -word -- -boundary -" -) -; -load -! -( -" -fowler -/ -basic -" -) -; -load -! -( -" -fowler -/ -nullsubexpr -" -) -; -load -! -( -" -fowler -/ -repetition -" -) -; -Ok -( -tests -) -} -/ -/ -/ -Configure -a -regex_automata -: -: -Input -with -the -given -test -configuration -. -fn -create_input -< -' -h -> -( -test -: -& -' -h -regex_test -: -: -RegexTest -) -- -> -regex_automata -: -: -Input -< -' -h -> -{ -use -regex_automata -: -: -Anchored -; -let -bounds -= -test -. -bounds -( -) -; -let -anchored -= -if -test -. -anchored -( -) -{ -Anchored -: -: -Yes -} -else -{ -Anchored -: -: -No -} -; -regex_automata -: -: -Input -: -: -new -( -test -. -haystack -( -) -) -. -range -( -bounds -. -start -. -. -bounds -. -end -) -. -anchored -( -anchored -) -} -/ -/ -/ -Convert -capture -matches -into -the -test -suite -' -s -capture -values -. -/ -/ -/ -/ -/ -/ -The -given -captures -must -represent -a -valid -match -where -the -first -capturing -/ -/ -/ -group -has -a -non -- -None -span -. -Otherwise -this -panics -. -fn -testify_captures -( -caps -: -& -regex_automata -: -: -util -: -: -captures -: -: -Captures -) -- -> -regex_test -: -: -Captures -{ -assert -! -( -caps -. -is_match -( -) -" -expected -captures -to -represent -a -match -" -) -; -let -spans -= -caps -. -iter -( -) -. -map -( -| -group -| -{ -group -. -map -( -| -m -| -regex_test -: -: -Span -{ -start -: -m -. -start -end -: -m -. -end -} -) -} -) -; -/ -/ -These -unwraps -are -OK -because -we -assume -our -' -caps -' -represents -a -match -/ -/ -and -a -match -always -gives -a -non -- -zero -number -of -groups -with -the -first -/ -/ -group -being -non -- -None -. -regex_test -: -: -Captures -: -: -new -( -caps -. -pattern -( -) -. -unwrap -( -) -. -as_usize -( -) -spans -) -. -unwrap -( -) -} -/ -/ -/ -Convert -a -test -harness -match -kind -to -a -regex -- -automata -match -kind -. -If -/ -/ -/ -regex -- -automata -doesn -' -t -support -the -harness -kind -then -None -is -returned -. -fn -untestify_kind -( -kind -: -regex_test -: -: -MatchKind -) -- -> -Option -< -regex_automata -: -: -MatchKind -> -{ -match -kind -{ -regex_test -: -: -MatchKind -: -: -All -= -> -Some -( -regex_automata -: -: -MatchKind -: -: -All -) -regex_test -: -: -MatchKind -: -: -LeftmostFirst -= -> -{ -Some -( -regex_automata -: -: -MatchKind -: -: -LeftmostFirst -) -} -regex_test -: -: -MatchKind -: -: -LeftmostLongest -= -> -None -} -} diff --git a/third_party/rust/regex-automata/tests/meta/mod.rs b/third_party/rust/regex-automata/tests/meta/mod.rs deleted file mode 100644 index f9d643965033c..0000000000000 --- a/third_party/rust/regex-automata/tests/meta/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -# -[ -cfg -( -not -( -miri -) -) -] -mod -suite -; diff --git a/third_party/rust/regex-automata/tests/meta/suite.rs b/third_party/rust/regex-automata/tests/meta/suite.rs deleted file mode 100644 index 7f06b41dd9d68..0000000000000 --- a/third_party/rust/regex-automata/tests/meta/suite.rs +++ /dev/null @@ -1,1681 +0,0 @@ -use -{ -anyhow -: -: -Result -regex_automata -: -: -{ -meta -: -: -{ -self -Regex -} -util -: -: -syntax -MatchKind -PatternSet -} -regex_test -: -: -{ -CompiledRegex -Match -RegexTest -SearchKind -Span -TestResult -TestRunner -} -} -; -use -crate -: -: -{ -create_input -suite -testify_captures -} -; -const -BLACKLIST -: -& -[ -& -str -] -= -& -[ -/ -/ -These -' -earliest -' -tests -are -blacklisted -because -the -meta -searcher -doesn -' -t -/ -/ -give -the -same -offsets -that -the -test -expects -. -This -is -legal -because -the -/ -/ -' -earliest -' -routines -don -' -t -guarantee -a -particular -match -offset -other -/ -/ -than -" -the -earliest -the -regex -engine -can -report -a -match -. -" -Some -regex -/ -/ -engines -will -quit -earlier -than -others -. -The -backtracker -for -example -/ -/ -can -' -t -really -quit -before -finding -the -full -leftmost -- -first -match -. -Many -of -/ -/ -the -literal -searchers -also -don -' -t -have -the -ability -to -quit -fully -or -it -' -s -/ -/ -otherwise -not -worth -doing -. -( -A -literal -searcher -not -quitting -as -early -as -/ -/ -possible -usually -means -looking -at -a -few -more -bytes -. -That -' -s -no -biggie -. -) -" -earliest -/ -" -] -; -/ -/ -/ -Tests -the -default -configuration -of -the -meta -regex -engine -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -Regex -: -: -builder -( -) -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -BLACKLIST -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -default -configuration -minus -the -full -DFA -. -# -[ -test -] -fn -no_dfa -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -configure -( -Regex -: -: -config -( -) -. -dfa -( -false -) -) -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -BLACKLIST -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -default -configuration -minus -the -full -DFA -and -lazy -DFA -. -# -[ -test -] -fn -no_dfa_hybrid -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -configure -( -Regex -: -: -config -( -) -. -dfa -( -false -) -. -hybrid -( -false -) -) -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -BLACKLIST -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -default -configuration -minus -the -full -DFA -lazy -DFA -and -one -- -pass -/ -/ -/ -DFA -. -# -[ -test -] -fn -no_dfa_hybrid_onepass -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -configure -( -Regex -: -: -config -( -) -. -dfa -( -false -) -. -hybrid -( -false -) -. -onepass -( -false -) -) -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -BLACKLIST -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -default -configuration -minus -the -full -DFA -lazy -DFA -one -- -pass -/ -/ -/ -DFA -and -backtracker -. -# -[ -test -] -fn -no_dfa_hybrid_onepass_backtrack -( -) -- -> -Result -< -( -) -> -{ -let -mut -builder -= -Regex -: -: -builder -( -) -; -builder -. -configure -( -Regex -: -: -config -( -) -. -dfa -( -false -) -. -hybrid -( -false -) -. -onepass -( -false -) -. -backtrack -( -false -) -) -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -BLACKLIST -) -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -compiler -( -mut -builder -: -meta -: -: -Builder -) -- -> -impl -FnMut -( -& -RegexTest -& -[ -String -] -) -- -> -Result -< -CompiledRegex -> -{ -move -| -test -regexes -| -{ -if -! -configure_meta_builder -( -test -& -mut -builder -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -let -re -= -builder -. -build_many -( -& -regexes -) -? -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -test -) -} -) -) -} -} -fn -run_test -( -re -: -& -Regex -test -: -& -RegexTest -) -- -> -TestResult -{ -let -input -= -create_input -( -test -) -; -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -TestResult -: -: -matched -( -re -. -is_match -( -input -) -) -" -find -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -= -> -TestResult -: -: -matches -( -re -. -find_iter -( -input -. -earliest -( -true -) -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -m -. -pattern -( -) -. -as_usize -( -) -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -) -SearchKind -: -: -Leftmost -= -> -TestResult -: -: -matches -( -re -. -find_iter -( -input -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -m -. -pattern -( -) -. -as_usize -( -) -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -) -SearchKind -: -: -Overlapping -= -> -{ -let -mut -patset -= -PatternSet -: -: -new -( -re -. -pattern_len -( -) -) -; -re -. -which_overlapping_matches -( -& -input -& -mut -patset -) -; -TestResult -: -: -which -( -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -) -} -} -" -captures -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -= -> -{ -let -it -= -re -. -captures_iter -( -input -. -earliest -( -true -) -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -caps -| -testify_captures -( -& -caps -) -) -; -TestResult -: -: -captures -( -it -) -} -SearchKind -: -: -Leftmost -= -> -{ -let -it -= -re -. -captures_iter -( -input -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -caps -| -testify_captures -( -& -caps -) -) -; -TestResult -: -: -captures -( -it -) -} -SearchKind -: -: -Overlapping -= -> -{ -/ -/ -There -is -no -overlapping -regex -API -that -supports -captures -. -TestResult -: -: -skip -( -) -} -} -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Configures -the -given -regex -builder -with -all -relevant -settings -on -the -given -/ -/ -/ -regex -test -. -/ -/ -/ -/ -/ -/ -If -the -regex -test -has -a -setting -that -is -unsupported -then -this -returns -/ -/ -/ -false -( -implying -the -test -should -be -skipped -) -. -fn -configure_meta_builder -( -test -: -& -RegexTest -builder -: -& -mut -meta -: -: -Builder -) -- -> -bool -{ -let -match_kind -= -match -test -. -match_kind -( -) -{ -regex_test -: -: -MatchKind -: -: -All -= -> -MatchKind -: -: -All -regex_test -: -: -MatchKind -: -: -LeftmostFirst -= -> -MatchKind -: -: -LeftmostFirst -regex_test -: -: -MatchKind -: -: -LeftmostLongest -= -> -return -false -} -; -let -meta_config -= -Regex -: -: -config -( -) -. -match_kind -( -match_kind -) -. -utf8_empty -( -test -. -utf8 -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -; -builder -. -configure -( -meta_config -) -. -syntax -( -config_syntax -( -test -) -) -; -true -} -/ -/ -/ -Configuration -of -the -regex -parser -from -a -regex -test -. -fn -config_syntax -( -test -: -& -RegexTest -) -- -> -syntax -: -: -Config -{ -syntax -: -: -Config -: -: -new -( -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -utf8 -( -test -. -utf8 -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -} diff --git a/third_party/rust/regex-automata/tests/nfa/mod.rs b/third_party/rust/regex-automata/tests/nfa/mod.rs deleted file mode 100644 index c22923ea28a72..0000000000000 --- a/third_party/rust/regex-automata/tests/nfa/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -mod -thompson -; diff --git a/third_party/rust/regex-automata/tests/nfa/thompson/backtrack/mod.rs b/third_party/rust/regex-automata/tests/nfa/thompson/backtrack/mod.rs deleted file mode 100644 index f9d643965033c..0000000000000 --- a/third_party/rust/regex-automata/tests/nfa/thompson/backtrack/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -# -[ -cfg -( -not -( -miri -) -) -] -mod -suite -; diff --git a/third_party/rust/regex-automata/tests/nfa/thompson/backtrack/suite.rs b/third_party/rust/regex-automata/tests/nfa/thompson/backtrack/suite.rs deleted file mode 100644 index cade7fa9d0e5e..0000000000000 --- a/third_party/rust/regex-automata/tests/nfa/thompson/backtrack/suite.rs +++ /dev/null @@ -1,1805 +0,0 @@ -use -{ -anyhow -: -: -Result -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -self -backtrack -: -: -{ -self -BoundedBacktracker -} -NFA -} -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -Input -} -regex_test -: -: -{ -CompiledRegex -Match -MatchKind -RegexTest -SearchKind -Span -TestResult -TestRunner -} -} -; -use -crate -: -: -{ -create_input -suite -testify_captures -} -; -/ -/ -/ -Tests -the -default -configuration -of -the -bounded -backtracker -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -BoundedBacktracker -: -: -builder -( -) -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -; -/ -/ -At -the -time -of -writing -every -regex -search -in -the -test -suite -fits -/ -/ -into -the -backtracker -' -s -default -visited -capacity -( -except -for -the -/ -/ -blacklisted -tests -below -) -. -If -regexes -are -added -that -blow -that -capacity -/ -/ -then -they -should -be -blacklisted -here -. -A -tempting -alternative -is -to -/ -/ -automatically -skip -them -by -checking -the -haystack -length -against -/ -/ -BoundedBacktracker -: -: -max_haystack_len -but -that -could -wind -up -hiding -/ -/ -interesting -failure -modes -. -e -. -g -. -If -the -visited -capacity -is -somehow -/ -/ -wrong -or -smaller -than -it -should -be -. -runner -. -blacklist -( -" -expensive -/ -backtrack -- -blow -- -visited -- -capacity -" -) -; -runner -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -backtracker -with -prefilters -enabled -. -# -[ -test -] -fn -prefilter -( -) -- -> -Result -< -( -) -> -{ -let -my_compiler -= -| -test -: -& -RegexTest -regexes -: -& -[ -String -] -| -{ -/ -/ -Parse -regexes -as -HIRs -so -we -can -get -literals -to -build -a -prefilter -. -let -mut -hirs -= -vec -! -[ -] -; -for -pattern -in -regexes -. -iter -( -) -{ -hirs -. -push -( -syntax -: -: -parse_with -( -pattern -& -config_syntax -( -test -) -) -? -) -; -} -/ -/ -We -can -always -select -leftmost -- -first -here -because -the -backtracker -/ -/ -only -supports -leftmost -- -first -matching -. -let -pre -= -Prefilter -: -: -from_hirs_prefix -( -regex_automata -: -: -MatchKind -: -: -LeftmostFirst -& -hirs -) -; -let -mut -builder -= -BoundedBacktracker -: -: -builder -( -) -; -builder -. -configure -( -BoundedBacktracker -: -: -config -( -) -. -prefilter -( -pre -) -) -; -compiler -( -builder -) -( -test -regexes -) -} -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -; -runner -. -blacklist -( -" -expensive -/ -backtrack -- -blow -- -visited -- -capacity -" -) -; -runner -. -test_iter -( -suite -( -) -? -. -iter -( -) -my_compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -bounded -backtracker -when -its -visited -capacity -is -set -to -its -/ -/ -/ -minimum -amount -. -# -[ -test -] -fn -min_visited_capacity -( -) -- -> -Result -< -( -) -> -{ -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -; -runner -. -test_iter -( -suite -( -) -? -. -iter -( -) -move -| -test -regexes -| -{ -let -nfa -= -NFA -: -: -compiler -( -) -. -configure -( -config_thompson -( -test -) -) -. -syntax -( -config_syntax -( -test -) -) -. -build_many -( -& -regexes -) -? -; -let -mut -builder -= -BoundedBacktracker -: -: -builder -( -) -; -if -! -configure_backtrack_builder -( -test -& -mut -builder -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -/ -/ -Setup -the -bounded -backtracker -so -that -its -visited -capacity -is -/ -/ -the -absolute -minimum -required -for -the -test -' -s -haystack -. -builder -. -configure -( -BoundedBacktracker -: -: -config -( -) -. -visited_capacity -( -backtrack -: -: -min_visited_capacity -( -& -nfa -& -Input -: -: -new -( -test -. -haystack -( -) -) -) -) -) -; -let -re -= -builder -. -build_from_nfa -( -nfa -) -? -; -let -mut -cache -= -re -. -create_cache -( -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -& -mut -cache -test -) -} -) -) -} -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -compiler -( -mut -builder -: -backtrack -: -: -Builder -) -- -> -impl -FnMut -( -& -RegexTest -& -[ -String -] -) -- -> -Result -< -CompiledRegex -> -{ -move -| -test -regexes -| -{ -if -! -configure_backtrack_builder -( -test -& -mut -builder -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -let -re -= -builder -. -build_many -( -& -regexes -) -? -; -let -mut -cache -= -re -. -create_cache -( -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -& -mut -cache -test -) -} -) -) -} -} -fn -run_test -( -re -: -& -BoundedBacktracker -cache -: -& -mut -backtrack -: -: -Cache -test -: -& -RegexTest -) -- -> -TestResult -{ -let -input -= -create_input -( -test -) -; -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Overlapping -= -> -{ -TestResult -: -: -skip -( -) -} -SearchKind -: -: -Leftmost -= -> -{ -let -input -= -input -. -earliest -( -true -) -; -TestResult -: -: -matched -( -re -. -try_is_match -( -cache -input -) -. -unwrap -( -) -) -} -} -" -find -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Overlapping -= -> -{ -TestResult -: -: -skip -( -) -} -SearchKind -: -: -Leftmost -= -> -TestResult -: -: -matches -( -re -. -try_find_iter -( -cache -input -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -result -| -result -. -unwrap -( -) -) -. -map -( -| -m -| -Match -{ -id -: -m -. -pattern -( -) -. -as_usize -( -) -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -) -} -" -captures -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -| -SearchKind -: -: -Overlapping -= -> -{ -TestResult -: -: -skip -( -) -} -SearchKind -: -: -Leftmost -= -> -TestResult -: -: -captures -( -re -. -try_captures_iter -( -cache -input -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -result -| -result -. -unwrap -( -) -) -. -map -( -| -caps -| -testify_captures -( -& -caps -) -) -) -} -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Configures -the -given -regex -builder -with -all -relevant -settings -on -the -given -/ -/ -/ -regex -test -. -/ -/ -/ -/ -/ -/ -If -the -regex -test -has -a -setting -that -is -unsupported -then -this -returns -/ -/ -/ -false -( -implying -the -test -should -be -skipped -) -. -fn -configure_backtrack_builder -( -test -: -& -RegexTest -builder -: -& -mut -backtrack -: -: -Builder -) -- -> -bool -{ -match -( -test -. -search_kind -( -) -test -. -match_kind -( -) -) -{ -/ -/ -For -testing -the -standard -search -APIs -. -This -is -the -only -supported -/ -/ -configuration -for -the -backtracker -. -( -SearchKind -: -: -Leftmost -MatchKind -: -: -LeftmostFirst -) -= -> -{ -} -/ -/ -Overlapping -APIs -not -supported -at -all -for -backtracker -. -( -SearchKind -: -: -Overlapping -_ -) -= -> -return -false -/ -/ -Backtracking -doesn -' -t -really -support -the -notion -of -' -earliest -' -. -/ -/ -Namely -backtracking -already -works -by -returning -as -soon -as -it -knows -/ -/ -it -has -found -a -match -. -It -just -so -happens -that -this -corresponds -to -/ -/ -the -standard -' -leftmost -' -formulation -. -/ -/ -/ -/ -The -' -earliest -' -definition -in -this -crate -does -indeed -permit -this -/ -/ -behavior -so -this -is -" -fine -" -but -our -test -suite -specifically -looks -/ -/ -for -the -earliest -position -at -which -a -match -is -known -which -our -/ -/ -finite -automata -based -regex -engines -have -no -problem -providing -. -So -/ -/ -for -backtracking -we -just -skip -these -tests -. -( -SearchKind -: -: -Earliest -_ -) -= -> -return -false -/ -/ -For -backtracking -' -all -' -semantics -don -' -t -really -make -sense -. -( -_ -MatchKind -: -: -All -) -= -> -return -false -/ -/ -Not -supported -at -all -in -regex -- -automata -. -( -_ -MatchKind -: -: -LeftmostLongest -) -= -> -return -false -} -; -let -backtrack_config -= -BoundedBacktracker -: -: -config -( -) -; -builder -. -configure -( -backtrack_config -) -. -syntax -( -config_syntax -( -test -) -) -. -thompson -( -config_thompson -( -test -) -) -; -true -} -/ -/ -/ -Configuration -of -a -Thompson -NFA -compiler -from -a -regex -test -. -fn -config_thompson -( -test -: -& -RegexTest -) -- -> -thompson -: -: -Config -{ -let -mut -lookm -= -regex_automata -: -: -util -: -: -look -: -: -LookMatcher -: -: -new -( -) -; -lookm -. -set_line_terminator -( -test -. -line_terminator -( -) -) -; -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -test -. -utf8 -( -) -) -. -look_matcher -( -lookm -) -} -/ -/ -/ -Configuration -of -the -regex -parser -from -a -regex -test -. -fn -config_syntax -( -test -: -& -RegexTest -) -- -> -syntax -: -: -Config -{ -syntax -: -: -Config -: -: -new -( -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -utf8 -( -test -. -utf8 -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -} diff --git a/third_party/rust/regex-automata/tests/nfa/thompson/mod.rs b/third_party/rust/regex-automata/tests/nfa/thompson/mod.rs deleted file mode 100644 index 70202b08442cf..0000000000000 --- a/third_party/rust/regex-automata/tests/nfa/thompson/mod.rs +++ /dev/null @@ -1,32 +0,0 @@ -# -[ -cfg -( -feature -= -" -nfa -- -backtrack -" -) -] -mod -backtrack -; -# -[ -cfg -( -feature -= -" -nfa -- -pikevm -" -) -] -mod -pikevm -; diff --git a/third_party/rust/regex-automata/tests/nfa/thompson/pikevm/mod.rs b/third_party/rust/regex-automata/tests/nfa/thompson/pikevm/mod.rs deleted file mode 100644 index f9d643965033c..0000000000000 --- a/third_party/rust/regex-automata/tests/nfa/thompson/pikevm/mod.rs +++ /dev/null @@ -1,13 +0,0 @@ -# -[ -cfg -( -not -( -miri -) -) -] -mod -suite -; diff --git a/third_party/rust/regex-automata/tests/nfa/thompson/pikevm/suite.rs b/third_party/rust/regex-automata/tests/nfa/thompson/pikevm/suite.rs deleted file mode 100644 index 998fd83609b89..0000000000000 --- a/third_party/rust/regex-automata/tests/nfa/thompson/pikevm/suite.rs +++ /dev/null @@ -1,1316 +0,0 @@ -use -{ -anyhow -: -: -Result -regex_automata -: -: -{ -nfa -: -: -thompson -: -: -{ -self -pikevm -: -: -{ -self -PikeVM -} -} -util -: -: -{ -prefilter -: -: -Prefilter -syntax -} -PatternSet -} -regex_test -: -: -{ -CompiledRegex -Match -RegexTest -SearchKind -Span -TestResult -TestRunner -} -} -; -use -crate -: -: -{ -create_input -suite -testify_captures -untestify_kind -} -; -/ -/ -/ -Tests -the -default -configuration -of -the -hybrid -NFA -/ -DFA -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -builder -= -PikeVM -: -: -builder -( -) -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -; -runner -. -test_iter -( -suite -( -) -? -. -iter -( -) -compiler -( -builder -) -) -. -assert -( -) -; -Ok -( -( -) -) -} -/ -/ -/ -Tests -the -PikeVM -with -prefilters -enabled -. -# -[ -test -] -fn -prefilter -( -) -- -> -Result -< -( -) -> -{ -let -my_compiler -= -| -test -: -& -RegexTest -regexes -: -& -[ -String -] -| -{ -/ -/ -Parse -regexes -as -HIRs -so -we -can -get -literals -to -build -a -prefilter -. -let -mut -hirs -= -vec -! -[ -] -; -for -pattern -in -regexes -. -iter -( -) -{ -hirs -. -push -( -syntax -: -: -parse_with -( -pattern -& -config_syntax -( -test -) -) -? -) -; -} -let -kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -Some -( -kind -) -= -> -kind -} -; -let -pre -= -Prefilter -: -: -from_hirs_prefix -( -kind -& -hirs -) -; -let -mut -builder -= -PikeVM -: -: -builder -( -) -; -builder -. -configure -( -PikeVM -: -: -config -( -) -. -prefilter -( -pre -) -) -; -compiler -( -builder -) -( -test -regexes -) -} -; -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -; -runner -. -test_iter -( -suite -( -) -? -. -iter -( -) -my_compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -compiler -( -mut -builder -: -pikevm -: -: -Builder -) -- -> -impl -FnMut -( -& -RegexTest -& -[ -String -] -) -- -> -Result -< -CompiledRegex -> -{ -move -| -test -regexes -| -{ -if -! -configure_pikevm_builder -( -test -& -mut -builder -) -{ -return -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -} -let -re -= -builder -. -build_many -( -& -regexes -) -? -; -let -mut -cache -= -re -. -create_cache -( -) -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -- -> -TestResult -{ -run_test -( -& -re -& -mut -cache -test -) -} -) -) -} -} -fn -run_test -( -re -: -& -PikeVM -cache -: -& -mut -pikevm -: -: -Cache -test -: -& -RegexTest -) -- -> -TestResult -{ -let -input -= -create_input -( -test -) -; -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -TestResult -: -: -matched -( -re -. -is_match -( -cache -input -) -) -" -find -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -= -> -{ -let -it -= -re -. -find_iter -( -cache -input -. -earliest -( -true -) -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -m -. -pattern -( -) -. -as_usize -( -) -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -; -TestResult -: -: -matches -( -it -) -} -SearchKind -: -: -Leftmost -= -> -{ -let -it -= -re -. -find_iter -( -cache -input -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -m -. -pattern -( -) -. -as_usize -( -) -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -; -TestResult -: -: -matches -( -it -) -} -SearchKind -: -: -Overlapping -= -> -{ -let -mut -patset -= -PatternSet -: -: -new -( -re -. -get_nfa -( -) -. -pattern_len -( -) -) -; -re -. -which_overlapping_matches -( -cache -& -input -& -mut -patset -) -; -TestResult -: -: -which -( -patset -. -iter -( -) -. -map -( -| -p -| -p -. -as_usize -( -) -) -) -} -} -" -captures -" -= -> -match -test -. -search_kind -( -) -{ -SearchKind -: -: -Earliest -= -> -{ -let -it -= -re -. -captures_iter -( -cache -input -. -earliest -( -true -) -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -caps -| -testify_captures -( -& -caps -) -) -; -TestResult -: -: -captures -( -it -) -} -SearchKind -: -: -Leftmost -= -> -{ -let -it -= -re -. -captures_iter -( -cache -input -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -caps -| -testify_captures -( -& -caps -) -) -; -TestResult -: -: -captures -( -it -) -} -SearchKind -: -: -Overlapping -= -> -{ -/ -/ -There -is -no -overlapping -PikeVM -API -that -supports -captures -. -TestResult -: -: -skip -( -) -} -} -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Configures -the -given -regex -builder -with -all -relevant -settings -on -the -given -/ -/ -/ -regex -test -. -/ -/ -/ -/ -/ -/ -If -the -regex -test -has -a -setting -that -is -unsupported -then -this -returns -/ -/ -/ -false -( -implying -the -test -should -be -skipped -) -. -fn -configure_pikevm_builder -( -test -: -& -RegexTest -builder -: -& -mut -pikevm -: -: -Builder -) -- -> -bool -{ -let -match_kind -= -match -untestify_kind -( -test -. -match_kind -( -) -) -{ -None -= -> -return -false -Some -( -k -) -= -> -k -} -; -let -pikevm_config -= -PikeVM -: -: -config -( -) -. -match_kind -( -match_kind -) -; -builder -. -configure -( -pikevm_config -) -. -syntax -( -config_syntax -( -test -) -) -. -thompson -( -config_thompson -( -test -) -) -; -true -} -/ -/ -/ -Configuration -of -a -Thompson -NFA -compiler -from -a -regex -test -. -fn -config_thompson -( -test -: -& -RegexTest -) -- -> -thompson -: -: -Config -{ -let -mut -lookm -= -regex_automata -: -: -util -: -: -look -: -: -LookMatcher -: -: -new -( -) -; -lookm -. -set_line_terminator -( -test -. -line_terminator -( -) -) -; -thompson -: -: -Config -: -: -new -( -) -. -utf8 -( -test -. -utf8 -( -) -) -. -look_matcher -( -lookm -) -} -/ -/ -/ -Configuration -of -the -regex -parser -from -a -regex -test -. -fn -config_syntax -( -test -: -& -RegexTest -) -- -> -syntax -: -: -Config -{ -syntax -: -: -Config -: -: -new -( -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -utf8 -( -test -. -utf8 -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -} diff --git a/third_party/rust/regex-syntax/.cargo-checksum.json b/third_party/rust/regex-syntax/.cargo-checksum.json index bcb7d1f2f352b..f17b7f63a15c6 100644 --- a/third_party/rust/regex-syntax/.cargo-checksum.json +++ b/third_party/rust/regex-syntax/.cargo-checksum.json @@ -11,7 +11,7 @@ toml " : " -cddce5fdfc6f46bbf659bda143f7b659487ed3912d66c86a1173735485316fbd +238d0bbc855edbecf9a6a6936efc20bd2759f36bc8fa4d53bdef33a1629a9a0f " " LICENSE @@ -38,7 +38,7 @@ md " : " -b2484aa7e66fb92d1378e9a7ce7605af18f77cb12c179866eaf92ba28cfec1d9 +67a3e673a9da6826fd4db5be6902841c821b52b98dc22c300f6e327872392b0a " " benches @@ -62,7 +62,7 @@ rs " : " -f3412bf62ca9976079fffbb42784491dd69215e6fa0e14340e8ad2c7bef18184 +91b277a9bb979f85a44a67e39f17f77bde033764eea1f1a93aad1b61f1250089 " " src @@ -75,7 +75,7 @@ rs " : " -27c666cc74931894a839ed4dd2191c4c33837320b24332d5c6c9564cf89f0afd +150b42e944f766fdca70d654dbe32f8a17498432729c78b9eb50b73ae7f91f86 " " src @@ -88,7 +88,7 @@ rs " : " -62d319cd0b7e6f437dc8dcaf798046a44afa03e9aeb6a384d5cffa448383af53 +d12f2cc75cd62f35623e1eb7a77ab8ac804b971752082700d2c4f550f834b249 " " src @@ -101,18 +101,7 @@ rs " : " -e97ca0a38aaa145dd928261e8e13d1ec7a6ae37534e92a24c93ea007b0c16a7d -" -" -src -/ -debug -. -rs -" -: -" -7a16cca02be9715fdc8c26a32279465774623cd12fab1ec59ac25a6e3047817f +1a7b473147e4f6b89623ef1744a9e87f665bcf160fe08a33ce8e35011811ba71 " " src @@ -134,7 +123,7 @@ rs " : " -01a67e3407b0d0d869119363e47a94d92158834bfe5936366c2e3f6f4ed13f36 +b3c5903a8937d2aff229a3ec65d4571d01ec4d9874c9a242ed6562c32702bcbd " " src @@ -147,7 +136,7 @@ rs " : " -2358e74b4d4aabfa62f79df855fd5d183779b86c4e14aae4ee42d8695bb3d010 +e767fed363bebe4bbda0d78b8f07e73f321eaf4f837e2d7bd14a1617387e9a89 " " src @@ -155,12 +144,14 @@ src hir / literal +/ +mod . rs " : " -2c8066c18ee1783343bb06ced01ca32f6b8a581ac020378965a57375c4832e88 +ffe9a0aff7827f97bffd29eb2f4ba96627b16953161dce6c50a2f760e76bbd98 " " src @@ -173,7 +164,7 @@ rs " : " -bf2bd12c4ab6d5420e131aee193c5885d465a15f1d91d67fcf773e6c9c2a23d8 +7f83c828223a54d236d348e48d5cedf015c904812110b6c38e9d52039c2b1572 " " src @@ -186,7 +177,7 @@ rs " : " -c24eab0e29db7547d3d7f86b8bf19239265d6b114244f5e71a9904e7ae9e9c67 +651b5d9776532a78612a5f9081372a57bad693890639ac19e3128b4defa96662 " " src @@ -199,7 +190,7 @@ rs " : " -c84d930e156883c5dbad3a0c4500e6659c1f3c55dd6e4caa28b157da681ddb7c +c7cd9693f73760263fd49a968714d27e7985ebe840211b2d83bca6686b0602a8 " " src @@ -212,7 +203,7 @@ rs " : " -71ca9c93aa48a5ed445399659fa6455093a1bbd9ef44b66bc7095c1b08b2ec1f +e5bf7f8c09f6155e59c9d676fe25437f7e3700f9bf5d91101d7e246a64c11d5a " " src @@ -223,7 +214,7 @@ rs " : " -d2891213d00edb99b26ab93bd53749a85f0a6b2a71a1addbed9d2c4969a7515f +a004f65196dd5745b3112e4acc8c467b18495cecac64a58d6608b35de67371cb " " src @@ -234,18 +225,7 @@ rs " : " -6b2f4f27e3331a01a25b87c89368dd2e54396bd425dac57941f9c1ebfd238ac8 -" -" -src -/ -rank -. -rs -" -: -" -ff3d58b0cc5ffa69e2e8c56fc7d9ef41dd399d59a639a253a51551b858cb5bbd +0dfb553a152e008b2755f115663e553ed99c4b8e6a4dcbcad1662737534de49d " " src @@ -256,7 +236,7 @@ rs " : " -9829458ef321b3bc22c21eae4b22805b33f8b5e67022928ffd9a9e0287bc7c31 +2ad48193433fefbede0837bd645f4288f6b39b1facb59dbb7d541bce7bf19109 " " src @@ -475,14 +455,14 @@ rs " : " -e9a13623a94295b81969c5483de17219ff74bb20768be13c527010351245acbd +de854b3bfb3f7dbefc422f6a25935aaeef55ead2c35386c712a1fe9bf81a7b6f " " test " : " -c7de5fbc0010d9b5b758cd49956375a64b88601c068167fd366808950257f108 +8a9bd1bd9fb389e08288f951319a9bbb0d4c5284a2ba63cbdab7f6afa2c2f76e " } " @@ -490,6 +470,6 @@ package " : " -dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da +456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848 " } diff --git a/third_party/rust/regex-syntax/Cargo.toml b/third_party/rust/regex-syntax/Cargo.toml index 476cb3c58e9b7..7497073827c5b 100644 --- a/third_party/rust/regex-syntax/Cargo.toml +++ b/third_party/rust/regex-syntax/Cargo.toml @@ -100,18 +100,7 @@ package edition = " -2021 -" -rust -- -version -= -" -1 -. -60 -. -0 +2018 " name = @@ -125,9 +114,9 @@ version " 0 . -7 +6 . -5 +28 " authors = @@ -138,16 +127,6 @@ Rust Project Developers " -" -Andrew -Gallant -< -jamslam -gmail -. -com -> -" ] description = @@ -158,6 +137,23 @@ expression parser . " +homepage += +" +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +" documentation = " @@ -207,93 +203,17 @@ rust lang / regex -/ -tree -/ -master -/ -regex -- -syntax -" -[ -package -. -metadata -. -docs -. -rs -] -all -- -features -= -true -rustdoc -- -args -= -[ -" -- -- -cfg " -" -docsrs -" -] [ -dependencies -. -arbitrary -] -version -= -" -1 -. -3 -. -0 -" features -= -[ -" -derive -" -] -optional -= -true -[ -features -] -arbitrary -= -[ -" -dep -: -arbitrary -" ] default = [ " -std -" -" unicode " ] -std -= -[ -] unicode = [ diff --git a/third_party/rust/regex-syntax/README.md b/third_party/rust/regex-syntax/README.md index c360aa4cf162d..d140b26c95b38 100644 --- a/third_party/rust/regex-syntax/README.md +++ b/third_party/rust/regex-syntax/README.md @@ -113,6 +113,58 @@ regex - syntax ) +[ +! +[ +Rust +] +( +https +: +/ +/ +img +. +shields +. +io +/ +badge +/ +rust +- +1 +. +28 +. +0 +% +2B +- +blue +. +svg +? +maxAge += +3600 +) +] +( +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +) # # # @@ -264,17 +316,30 @@ use regex_syntax : : -{ +Parser +; +use +regex_syntax +: +: hir : : +{ +self Hir -parse } ; let hir = +Parser +: +: +new +( +) +. parse ( " @@ -305,12 +370,17 @@ Hir : literal ( -" -a -" -. -as_bytes +hir +: +: +Literal +: +: +Unicode ( +' +a +' ) ) Hir @@ -318,12 +388,17 @@ Hir : literal ( -" -b -" -. -as_bytes +hir +: +: +Literal +: +: +Unicode ( +' +b +' ) ) ] diff --git a/third_party/rust/regex-syntax/src/ast/mod.rs b/third_party/rust/regex-syntax/src/ast/mod.rs index 885e48a27aaf5..36d5e19b3dc29 100644 --- a/third_party/rust/regex-syntax/src/ast/mod.rs +++ b/third_party/rust/regex-syntax/src/ast/mod.rs @@ -12,7 +12,7 @@ expressions * / use -core +std : : cmp @@ -21,24 +21,16 @@ cmp Ordering ; use -alloc -: -: -{ -boxed -: -: -Box -string +std : : -String -vec -vec +error +; +use +std : : -Vec -} +fmt ; pub use @@ -168,24 +160,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct Error @@ -516,41 +490,6 @@ building an AST . -/ -/ -/ -/ -/ -/ -This -error -type -is -marked -as -non_exhaustive -. -This -means -that -adding -a -/ -/ -/ -new -variant -is -not -considered -a -breaking -change -. -# -[ -non_exhaustive -] # [ derive @@ -561,24 +500,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum ErrorKind @@ -1540,22 +1461,70 @@ user experience . UnsupportedLookAround -} +/ +/ +/ +Hints +that +destructuring +should +not +be +exhaustive +. +/ +/ +/ +/ +/ +/ +This +enum +may +grow +additional +variants +so +this +makes +sure +clients +/ +/ +/ +don +' +t +count +on +exhaustive +matching +. +( +Otherwise +adding +a +new +variant +/ +/ +/ +could +break +existing +code +. +) # [ -cfg +doc ( -feature -= -" -std -" +hidden ) ] +__Nonexhaustive +} impl -std -: -: error : : @@ -1563,110 +1532,38 @@ Error for Error { -} -impl -core -: -: -fmt -: -: -Display -for -Error -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -crate -: -: -error -: -: -Formatter -: +/ +/ +TODO : -from -( -self -) +Remove +this +method +entirely +on +the +next +breaking +semver +release . -fmt +# +[ +allow ( -f +deprecated ) -} -} -impl -core -: -: -fmt -: -: -Display -for -ErrorKind -{ +] fn -fmt +description ( & self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> ) - > -core -: -: -fmt -: -: -Result +& +str { use self @@ -1678,85 +1575,42 @@ ErrorKind * ; match -* self +. +kind { CaptureLimitExceeded = > -write -! -( -f " +capture +group +limit exceeded -the -maximum -number -of -\ -capturing -groups -( -{ -} -) " -u32 -: -: -MAX -) ClassEscapeInvalid = > -{ -write -! -( -f " invalid escape sequence -found in character class " -) -} ClassRangeInvalid = > -write -! -( -f " invalid character class range -\ -the -start -must -be -< -= -the -end " -) ClassRangeLiteral = > -{ -write -! -( -f " invalid range @@ -1766,141 +1620,82 @@ be a literal " -) -} ClassUnclosed = > -write -! -( -f " unclosed character class " -) DecimalEmpty = > -write -! -( -f " +empty decimal literal -empty " -) DecimalInvalid = > -write -! -( -f " +invalid decimal literal -invalid " -) EscapeHexEmpty = > -write -! -( -f " +empty hexadecimal literal -empty " -) EscapeHexInvalid = > -{ -write -! -( -f " +invalid hexadecimal literal -is -not -a -Unicode -scalar -value " -) -} EscapeHexInvalidDigit = > -write -! -( -f " invalid hexadecimal digit " -) EscapeUnexpectedEof = > -write -! -( -f " -incomplete +unexpected +eof +( escape sequence -\ -reached -end -of -pattern -prematurely -" ) +" EscapeUnrecognized = > -write -! -( -f " unrecognized escape sequence " -) FlagDanglingNegation = > -{ -write -! -( -f " dangling flag negation operator " -) -} FlagDuplicate { . @@ -1908,15 +1703,10 @@ FlagDuplicate } = > -write -! -( -f " duplicate flag " -) FlagRepeatedNegation { . @@ -1924,50 +1714,27 @@ FlagRepeatedNegation } = > -{ -write -! -( -f " -flag -negation -operator repeated +negation " -) -} FlagUnexpectedEof = > -{ -write -! -( -f " -expected +unexpected +eof +( flag -but -got -end -of -regex -" ) -} +" FlagUnrecognized = > -write -! -( -f " unrecognized flag " -) GroupNameDuplicate { . @@ -1975,355 +1742,136 @@ GroupNameDuplicate } = > -{ -write -! -( -f " duplicate capture group name " -) -} GroupNameEmpty = > -write -! -( -f " empty capture group name " -) GroupNameInvalid = > -write -! -( -f " invalid capture group -character +name " -) GroupNameUnexpectedEof = > -write -! -( -f " unclosed capture group name " -) GroupUnclosed = > -write -! -( -f " unclosed group " -) GroupUnopened = > -write -! -( -f " unopened group " -) NestLimitExceeded ( -limit +_ ) = > -write -! -( -f -" -exceed -the -maximum -number -of -\ -nested -parentheses -/ -brackets -( -{ -} -) " +nest limit -) +exceeded +" RepetitionCountInvalid = > -write -! -( -f " invalid repetition count range -\ -the -start -must -be -< -= -the -end -" -) -RepetitionCountDecimalEmpty -= -> -{ -write -! -( -f -" -repetition -quantifier -expects -a -valid -decimal " -) -} RepetitionCountUnclosed = > -{ -write -! -( -f " unclosed counted repetition " -) -} RepetitionMissing = > -{ -write -! -( -f " repetition operator missing expression " -) -} UnicodeClassInvalid = > -{ -write -! -( -f " invalid Unicode character class " -) -} UnsupportedBackreference = > -{ -write -! -( -f " backreferences are not supported " -) -} UnsupportedLookAround = > -write -! -( -f " look - around -including -look -- -ahead -and -look -- -behind -\ is not supported " -) -} -} -} -/ -/ -/ -Span -represents -the -position -information -of -a -single -AST -item -. -/ -/ -/ -/ -/ -/ -All -span -positions -are -absolute -byte -offsets -that -can -be -used -on -the -/ -/ -/ -original -regular -expression -that -was -parsed -. -# -[ -derive -( -Clone -Copy -Eq -PartialEq -) -] -# -[ -cfg_attr -( -feature +_ = -" -arbitrary -" -derive +> +unreachable +! ( -arbitrary -: -: -Arbitrary -) ) -] -pub -struct -Span -{ -/ -/ -/ -The -start -byte -offset -. -pub -start -: -Position -/ -/ -/ -The -end -byte -offset -. -pub -end -: -Position +} +} } impl -core -: -: fmt : : -Debug +Display for -Span +Error { fn fmt @@ -2334,9 +1882,6 @@ f : & mut -core -: -: fmt : : @@ -2348,671 +1893,635 @@ _ ) - > -core -: -: fmt : : Result { -write -! -( -f -" -Span -( -{ +crate : -? -} -{ : -? -} -) -" -self -. -start +error +: +: +Formatter +: +: +from +( self +) . -end +fmt +( +f ) } } impl -Ord +fmt +: +: +Display for -Span +ErrorKind { fn -cmp +fmt ( & self -other +f : & -Span +mut +fmt +: +: +Formatter +< +' +_ +> ) - > -Ordering +fmt +: +: +Result { -( -& +use self -. -start -& +: +: +ErrorKind +: +: +* +; +match +* self -. -end -) -. -cmp +{ +CaptureLimitExceeded += +> +write +! ( -& +f +" +exceeded +the +maximum +number +of +\ +capturing +groups ( -& -other -. -start -& -other -. -end +{ +} ) +" +: +: +std +: +: +u32 +: +: +MAX ) -} -} -impl -PartialOrd -for -Span +ClassEscapeInvalid += +> { -fn -partial_cmp +write +! ( -& -self -other -: -& -Span +f +" +invalid +escape +sequence +found +in +character +class +" ) -- +} +ClassRangeInvalid += > -Option +write +! +( +f +" +invalid +character +class +range +\ +the +start +must +be < -Ordering += +the +end +" +) +ClassRangeLiteral += > { -Some -( -self -. -cmp +write +! ( -other -) +f +" +invalid +range +boundary +must +be +a +literal +" ) } -} -/ -/ -/ -A -single -position -in -a -regular -expression -. -/ -/ -/ -/ -/ -/ -A -position -encodes -one -half -of -a -span -and -include -the -byte -offset -line -/ -/ -/ -number -and -column -number -. -# -[ -derive +ClassUnclosed += +> +write +! ( -Clone -Copy -Eq -PartialEq +f +" +unclosed +character +class +" ) -] -# -[ -cfg_attr -( -feature +DecimalEmpty = +> +write +! +( +f " -arbitrary +decimal +literal +empty " -derive -( -arbitrary -: -: -Arbitrary ) -) -] -pub -struct -Position -{ -/ -/ -/ -The -absolute -offset -of -this -position -starting -at -0 -from -the -/ -/ -/ -beginning -of -the -regular -expression -pattern -string -. -pub -offset -: -usize -/ -/ -/ -The -line -number -starting -at -1 -. -pub -line -: -usize -/ -/ -/ -The -approximate -column -number -starting -at -1 -. -pub -column -: -usize -} -impl -core -: -: -fmt -: -: -Debug -for -Position -{ -fn -fmt +DecimalInvalid += +> +write +! ( -& -self f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> +" +decimal +literal +invalid +" ) -- +EscapeHexEmpty += > -core -: -: -fmt -: -: -Result -{ write ! ( f " -Position -( -o -: -{ -: -? -} -l -: -{ -: -? -} -c -: -{ -: -? -} -) +hexadecimal +literal +empty " -self -. -offset -self -. -line -self -. -column ) -} -} -impl -Ord -for -Position +EscapeHexInvalid += +> { -fn -cmp +write +! ( -& -self -other -: -& -Position +f +" +hexadecimal +literal +is +not +a +Unicode +scalar +value +" ) -- +} +EscapeHexInvalidDigit += > -Ordering -{ -self -. -offset -. -cmp +write +! ( -& -other -. -offset +f +" +invalid +hexadecimal +digit +" ) -} -} -impl -PartialOrd -for -Position -{ -fn -partial_cmp +EscapeUnexpectedEof += +> +write +! ( -& -self -other -: -& -Position +f +" +incomplete +escape +sequence +\ +reached +end +of +pattern +prematurely +" ) -- +EscapeUnrecognized += > -Option -< -Ordering +write +! +( +f +" +unrecognized +escape +sequence +" +) +FlagDanglingNegation += > { -Some -( -self -. -cmp +write +! ( -other -) +f +" +dangling +flag +negation +operator +" ) } -} -impl -Span +FlagDuplicate { -/ -/ -/ -Create -a -new -span -with -the -given -positions . -pub -fn -new +. +} += +> +write +! ( -start -: -Position -end -: -Position +f +" +duplicate +flag +" ) -- -> -Span -{ -Span +FlagRepeatedNegation { -start -end -} -} -/ -/ -/ -Create -a -new -span -using -the -given -position -as -the -start -and -end . -pub -fn -splat +. +} += +> +{ +write +! ( -pos -: -Position +f +" +flag +negation +operator +repeated +" ) -- +} +FlagUnexpectedEof += > -Span { -Span -: -: -new +write +! ( -pos -pos +f +" +expected +flag +but +got +end +of +regex +" ) } -/ -/ -/ -Create -a -new -span -by -replacing -the -starting -the -position -with -the -one -/ -/ -/ -given -. -pub -fn -with_start +FlagUnrecognized += +> +write +! ( -self -pos -: -Position +f +" +unrecognized +flag +" ) -- -> -Span -{ -Span +GroupNameDuplicate { -start -: -pos . . -self } += +> +{ +write +! +( +f +" +duplicate +capture +group +name +" +) } -/ -/ -/ -Create -a -new -span -by -replacing -the -ending -the -position -with -the -one -/ -/ -/ -given -. -pub -fn -with_end +GroupNameEmpty += +> +write +! ( -self -pos -: -Position +f +" +empty +capture +group +name +" ) -- +GroupNameInvalid += > -Span -{ -Span -{ -end -: -pos -. -. -self -} -} -/ -/ -/ -Returns -true -if -and -only -if -this -span -occurs -on -a -single -line -. -pub -fn -is_one_line +write +! ( -& -self +f +" +invalid +capture +group +character +" ) -- +GroupNameUnexpectedEof += > -bool -{ -self -. -start -. -line +write +! +( +f +" +unclosed +capture +group +name +" +) +GroupUnclosed = +> +write +! +( +f +" +unclosed +group +" +) +GroupUnopened = -self -. -end -. -line -} -/ -/ -/ -Returns -true -if -and -only -if -this -span -is -empty -. -That -is -it -points -to -/ -/ -/ -a -single -position -in +> +write +! +( +f +" +unopened +group +" +) +NestLimitExceeded +( +limit +) += +> +write +! +( +f +" +exceed the -concrete -syntax +maximum +number of -a -regular -expression -. -pub -fn -is_empty +\ +nested +parentheses +/ +brackets ( -& -self +{ +} ) -- +" +limit +) +RepetitionCountInvalid += > -bool -{ -self -. +write +! +( +f +" +invalid +repetition +count +range +\ +the start -. -offset -= +must +be +< = -self -. +the end -. -offset +" +) +RepetitionCountDecimalEmpty += +> +{ +write +! +( +f +" +repetition +quantifier +expects +a +valid +decimal +" +) } +RepetitionCountUnclosed += +> +{ +write +! +( +f +" +unclosed +counted +repetition +" +) } -impl -Position +RepetitionMissing += +> +{ +write +! +( +f +" +repetition +operator +missing +expression +" +) +} +UnicodeClassInvalid += +> +{ +write +! +( +f +" +invalid +Unicode +character +class +" +) +} +UnsupportedBackreference += +> { +write +! +( +f +" +backreferences +are +not +supported +" +) +} +UnsupportedLookAround += +> +write +! +( +f +" +look +- +around +including +look +- +ahead +and +look +- +behind +\ +is +not +supported +" +) +_ += +> +unreachable +! +( +) +} +} +} / / / -Create -a -new -position -with +Span +represents the -given +position information +of +a +single +AST +item . / / @@ -3020,105 +2529,216 @@ information / / / -offset -is -the +All +span +positions +are absolute -offset -of +byte +offsets +that +can +be +used +on the -position -starting -at -0 -from / / / -the -beginning -of -the +original regular expression -pattern -string +that +was +parsed . +# +[ +derive +( +Clone +Copy +Eq +PartialEq +) +] +pub +struct +Span +{ / / / -/ -/ -/ -line -is -the -line -number -starting -at -1 +The +start +byte +offset . +pub +start +: +Position / / / -/ -/ -/ -column -is -the -approximate -column -number -starting -at -1 +The +end +byte +offset . pub -fn -new -( -offset +end : -usize -line +Position +} +impl +fmt : -usize -column : -usize -) -- -> -Position +Debug +for +Span { -Position +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result { -offset -line -column +write +! +( +f +" +Span +( +{ +: +? +} +{ +: +? +} +) +" +self +. +start +self +. +end +) +} +} +impl +Ord +for +Span +{ +fn +cmp +( +& +self +other +: +& +Span +) +- +> +Ordering +{ +( +& +self +. +start +& +self +. +end +) +. +cmp +( +& +( +& +other +. +start +& +other +. +end +) +) +} } +impl +PartialOrd +for +Span +{ +fn +partial_cmp +( +& +self +other +: +& +Span +) +- +> +Option +< +Ordering +> +{ +Some +( +self +. +cmp +( +other +) +) } } / / / -An -abstract -syntax -tree -for +A +single +position +in a -singular +regular expression -along -with -comments -/ -/ -/ -found . / / @@ -3126,864 +2746,823 @@ found / / / -Comments -are -not -stored -in -the -tree -itself -to -avoid -complexity -. -Each -/ -/ -/ -comment -contains +A +position +encodes +one +half +of a span -of -precisely -where -it -occurred -in +and +include the -original +byte +offset +line / / / -regular -expression +number +and +column +number . # [ derive ( Clone -Debug +Copy Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct -WithComments +Position { / / / The -actual -ast -. -pub -ast -: -Ast +absolute +offset +of +this +position +starting +at +0 +from +the / / / -All -comments -found -in +beginning +of the -original regular expression +pattern +string . pub -comments +offset : -Vec -< -Comment -> -} -/ -/ -/ -A -comment -from -a -regular -expression -with -an -associated -span -. +usize / / / +The +line +number +starting +at +1 +. +pub +line +: +usize / / / -A -regular -expression -can -only -contain -comments -when -the -x -flag -is -/ -/ -/ -enabled +The +approximate +column +number +starting +at +1 . -# -[ -derive -( -Clone +pub +column +: +usize +} +impl +fmt +: +: Debug -Eq -PartialEq +for +Position +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> ) -] -# -[ -cfg_attr +- +> +fmt +: +: +Result +{ +write +! ( -feature -= +f " -arbitrary +Position +( +o +: +{ +: +? +} +l +: +{ +: +? +} +c +: +{ +: +? +} +) " -derive +self +. +offset +self +. +line +self +. +column +) +} +} +impl +Ord +for +Position +{ +fn +cmp ( -arbitrary +& +self +other : +& +Position +) +- +> +Ordering +{ +self +. +offset +. +cmp +( +& +other +. +offset +) +} +} +impl +PartialOrd +for +Position +{ +fn +partial_cmp +( +& +self +other : -Arbitrary +& +Position +) +- +> +Option +< +Ordering +> +{ +Some +( +self +. +cmp +( +other ) ) -] -pub -struct -Comment +} +} +impl +Span { / / / -The +Create +a +new span -of -this -comment -including +with the -beginning -# -and -ending -\ -n +given +positions . pub -span +fn +new +( +start : +Position +end +: +Position +) +- +> +Span +{ Span +{ +start +end +} +} / / / -The -comment -text -starting -with +Create +a +new +span +using the -first -character -following +given +position +as the -# -/ -/ -/ +start and -ending -with -the -last -character -preceding -the -\ -n +end . pub -comment -: -String +fn +splat +( +pos +: +Position +) +- +> +Span +{ +Span +: +: +new +( +pos +pos +) } / / / -An -abstract -syntax -tree -for +Create a -single -regular -expression -. -/ -/ -/ +new +span +by +replacing +the +starting +the +position +with +the +one / / / -An -Ast -' -s -fmt +given +. +pub +fn +with_start +( +self +pos : +Position +) +- +> +Span +{ +Span +{ +start : -Display -implementation -uses -constant -stack -space -and -heap +pos +. +. +self +} +} / / / -space -proportional -to +Create +a +new +span +by +replacing the -size -of +ending the -Ast -. -/ -/ -/ -/ -/ -/ -This -type -defines -its -own -destructor -that -uses -constant -stack -space -and +position +with +the +one / / / -heap -space -proportional -to -the -size -of -the -Ast +given . -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive +pub +fn +with_end ( -arbitrary -: +self +pos : -Arbitrary -) +Position ) -] -pub -enum -Ast +- +> +Span +{ +Span { +end +: +pos +. +. +self +} +} / / / -An -empty -regex -that -matches -everything +Returns +true +if +and +only +if +this +span +occurs +on +a +single +line . -Empty +pub +fn +is_one_line ( -Span +& +self ) -/ -/ -/ -A -set -of -flags -e +- +> +bool +{ +self . -g +start . -( -? -is -) +line += += +self . -Flags -( -SetFlags -) +end +. +line +} / / / -A -single -character -literal -which -includes -escape -sequences +Returns +true +if +and +only +if +this +span +is +empty . -Literal -( -Literal -) +That +is +it +points +to / / / -The -" -any -character -" -class +a +single +position +in +the +concrete +syntax +of +a +regular +expression . -Dot +pub +fn +is_empty ( -Span +& +self ) +- +> +bool +{ +self +. +start +. +offset += += +self +. +end +. +offset +} +} +impl +Position +{ / / / -A -single -zero -- -width -assertion +Create +a +new +position +with +the +given +information . -Assertion -( -Assertion -) / / / -A -single -character -class -. -This -includes -all -forms -of -character -classes / / / -except -for -. -. -e -. -g -. -\ -d -\ -pN -[ -a -- -z -] -and -[ -[ -: -alpha -: -] -] -. -Class -( -Class -) +offset +is +the +absolute +offset +of +the +position +starting +at +0 +from / / / -A -repetition -operator -applied -to -an -arbitrary +the +beginning +of +the regular expression +pattern +string . -Repetition -( -Repetition -) / / / -A -grouped -regular -expression -. -Group -( -Group -) / / / -An -alternation -of -regular -expressions +line +is +the +line +number +starting +at +1 . -Alternation -( -Alternation -) / / / -A -concatenation -of -regular -expressions -. -Concat -( -Concat -) -} -impl -Ast -{ / / / -Return +column +is the -span -of -this -abstract -syntax -tree +approximate +column +number +starting +at +1 . pub fn -span +new ( -& -self -) -- -> -& -Span -{ -match -* -self -{ -Ast -: +offset : -Empty -( -ref -span -) -= -> -span -Ast +usize +line : +usize +column : -Flags -( -ref -x +usize ) -= +- > -& -x +Position +{ +Position +{ +offset +line +column +} +} +} +/ +/ +/ +An +abstract +syntax +tree +for +a +singular +expression +along +with +comments +/ +/ +/ +found . -span -Ast -: -: -Literal -( -ref -x -) -= -> -& -x +/ +/ +/ +/ +/ +/ +Comments +are +not +stored +in +the +tree +itself +to +avoid +complexity . +Each +/ +/ +/ +comment +contains +a span -Ast -: -: -Dot -( -ref -span -) -= -> -span -Ast -: -: -Assertion -( -ref -x -) -= -> -& -x +of +precisely +where +it +occurred +in +the +original +/ +/ +/ +regular +expression . -span -Ast -: -: -Class +# +[ +derive ( -ref -x +Clone +Debug +Eq +PartialEq ) -= -> -x +] +pub +struct +WithComments +{ +/ +/ +/ +The +actual +ast . -span -( -) -Ast -: +pub +ast : -Repetition -( -ref -x -) -= -> -& -x -. -span Ast -: -: -Group -( -ref -x -) -= -> -& -x +/ +/ +/ +All +comments +found +in +the +original +regular +expression . -span -Ast -: +pub +comments : -Alternation -( -ref -x -) -= +Vec +< +Comment > -& -x -. +} +/ +/ +/ +A +comment +from +a +regular +expression +with +an +associated span -Ast -: -: -Concat -( -ref -x -) -= -> -& -x . -span -} -} / / / -Return -true -if -and +/ +/ +/ +A +regular +expression +can only -if -this -Ast +contain +comments +when +the +x +flag is -empty +/ +/ +/ +enabled . -pub -fn -is_empty +# +[ +derive ( -& -self +Clone +Debug +Eq +PartialEq ) -- -> -bool -{ -match -* -self +] +pub +struct +Comment { -Ast -: -: -Empty -( -_ -) -= -> -true -_ -= -> -false -} -} / / / -Returns -true -if -and -only -if +The +span +of this -AST -has -any -( +comment including -possibly -empty -) +the +beginning +# +and +ending +\ +n +. +pub +span +: +Span / / / -subexpressions +The +comment +text +starting +with +the +first +character +following +the +# +/ +/ +/ +and +ending +with +the +last +character +preceding +the +\ +n . -fn -has_subexprs -( -& -self -) -- -> -bool -{ -match -* -self -{ -Ast -: -: -Empty -( -_ -) -| -Ast -: -: -Flags -( -_ -) -| -Ast -: -: -Literal -( -_ -) -| -Ast -: -: -Dot -( -_ -) -| -Ast -: -: -Assertion -( -_ -) -= -> -false -Ast -: -: -Class -( -_ -) -| -Ast -: -: -Repetition -( -_ -) -| -Ast -: -: -Group -( -_ -) -| -Ast -: -: -Alternation -( -_ -) -| -Ast -: +pub +comment : -Concat -( -_ -) -= -> -true -} -} +String } / / / -Print +An +abstract +syntax +tree +for a -display -representation -of -this -Ast +single +regular +expression . / / @@ -3991,38 +3570,32 @@ Ast / / / -This -does -not -preserve -any -of -the -original -whitespace -formatting -that -may +An +Ast +' +s +fmt +: +: +Display +implementation +uses +constant +stack +space +and +heap / / / -have -originally -been -present -in +space +proportional +to +the +size +of the -concrete -syntax -from -which -this Ast -/ -/ -/ -was -generated . / / @@ -4031,18 +3604,23 @@ generated / / This -implementation +type +defines +its +own +destructor +that uses constant stack space and -heap -space -proportional / / / +heap +space +proportional to the size @@ -4050,461 +3628,549 @@ of the Ast . -impl -core -: -: -fmt -: -: -Display -for +# +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +enum Ast { -fn -fmt +/ +/ +/ +An +empty +regex +that +matches +everything +. +Empty ( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> +Span ) -- -> -core -: -: -fmt -: -: -Result -{ -use -crate -: -: -ast -: -: -print -: -: -Printer -; -Printer -: -: -new +/ +/ +/ +A +set +of +flags +e +. +g +. ( +? +is ) . -print +Flags ( -self -f +SetFlags ) -} -} / / / -An -alternation -of -regular -expressions +A +single +character +literal +which +includes +escape +sequences . -# -[ -derive +Literal ( -Clone -Debug -Eq -PartialEq +Literal ) -] -# -[ -cfg_attr -( -feature -= +/ +/ +/ +The " -arbitrary +any +character " -derive +class +. +Dot ( -arbitrary -: -: -Arbitrary +Span ) +/ +/ +/ +A +single +zero +- +width +assertion +. +Assertion +( +Assertion ) -] -pub -struct -Alternation -{ / / / -The -span -of -this -alternation +A +single +character +class . -pub -span -: -Span +This +includes +all +forms +of +character +classes / / / -The -alternate -regular -expressions +except +for . -pub -asts +. +e +. +g +. +\ +d +\ +pN +[ +a +- +z +] +and +[ +[ : -Vec -< -Ast -> -} -impl -Alternation -{ +alpha +: +] +] +. +Class +( +Class +) / / / -Return -this -alternation -as +A +repetition +operator +applied +to an -AST +arbitrary +regular +expression . +Repetition +( +Repetition +) / / / +A +grouped +regular +expression +. +Group +( +Group +) / / / -If -this +An alternation -contains -zero -ASTs -then -Ast -: -: -Empty -is +of +regular +expressions +. +Alternation +( +Alternation +) / / / -returned +A +concatenation +of +regular +expressions . -If -this -alternation -contains -exactly -1 -AST -then -the +Concat +( +Concat +) +} +impl +Ast +{ / / / -corresponding -AST -is -returned -. -Otherwise -Ast -: -: -Alternation -is -returned +Return +the +span +of +this +abstract +syntax +tree . pub fn -into_ast +span ( -mut +& self ) - > -Ast +& +Span { match +* self -. -asts -. -len +{ +Ast +: +: +Empty ( +ref +span ) -{ -0 = > +span Ast : : -Empty +Flags ( -self -. -span +ref +x ) -1 = > -self -. -asts +& +x . -pop +span +Ast +: +: +Literal ( +ref +x ) += +> +& +x . -unwrap +span +Ast +: +: +Dot ( +ref +span ) -_ = > +span Ast : : -Alternation +Assertion ( -self +ref +x ) -} -} -} -/ -/ -/ -A -concatenation -of -regular -expressions += +> +& +x . -# -[ -derive +span +Ast +: +: +Class ( -Clone -Debug -Eq -PartialEq +ref +x ) -] -# -[ -cfg_attr -( -feature = -" -arbitrary -" -derive +> +x +. +span ( -arbitrary +) +Ast : : -Arbitrary -) +Repetition +( +ref +x ) -] -pub -struct -Concat -{ -/ -/ -/ -The -span -of -this -concatenation += +> +& +x . -pub span +Ast : -Span -/ -/ -/ -The -concatenation -regular -expressions -. -pub -asts : -Vec -< +Group +( +ref +x +) += +> +& +x +. +span Ast +: +: +Alternation +( +ref +x +) += > -} -impl -Concat -{ -/ -/ -/ -Return -this -concatenation -as -an -AST +& +x . -/ -/ -/ -/ -/ -/ -If -this -concatenation -contains -zero -ASTs -then +span Ast : : -Empty -is -/ -/ -/ -returned +Concat +( +ref +x +) += +> +& +x . -If -this -concatenation -contains -exactly -1 -AST -then -the +span +} +} / / / -corresponding -AST -is -returned -. -Otherwise +Return +true +if +and +only +if +this Ast -: -: -Concat is -returned +empty . pub fn -into_ast +is_empty ( -mut +& self ) - > -Ast +bool { match +* self -. -asts -. -len -( -) { -0 -= -> Ast : : Empty ( -self -. -span +_ ) -1 = > -self -. -asts -. -pop +true +_ += +> +false +} +} +/ +/ +/ +Returns +true +if +and +only +if +this +AST +has +any ( +including +possibly +empty ) +/ +/ +/ +subexpressions . -unwrap +fn +has_subexprs +( +& +self +) +- +> +bool +{ +match +* +self +{ +Ast +: +: +Empty +( +_ +) +| +Ast +: +: +Flags +( +_ +) +| +Ast +: +: +Literal +( +_ +) +| +Ast +: +: +Dot ( +_ ) +| +Ast +: +: +Assertion +( _ +) = > +false +Ast +: +: +Class +( +_ +) +| +Ast +: +: +Repetition +( +_ +) +| +Ast +: +: +Group +( +_ +) +| +Ast +: +: +Alternation +( +_ +) +| Ast : : Concat ( -self +_ ) += +> +true } } } / / / -A -single -literal -expression +Print +a +display +representation +of +this +Ast . / / @@ -4512,218 +4178,304 @@ expression / / / -A -literal -corresponds -to -a -single -Unicode -scalar -value -. -Literals +This +does +not +preserve +any +of +the +original +whitespace +formatting +that may -be / / / -represented -in -their -literal -form -e -. -g -. -a -or +have +originally +been +present in -their -escaped -form +the +concrete +syntax +from +which +this +Ast / / / -e -. -g -. -\ -x61 +was +generated . -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] -pub -struct -Literal -{ -/ -/ / -The -span -of -this -literal -. -pub -span -: -Span / / / -The -kind -of -this -literal -. -pub -kind -: -LiteralKind +/ +/ +This +implementation +uses +constant +stack +space +and +heap +space +proportional / / / -The -Unicode -scalar -value -corresponding to +the +size +of +the +Ast +. +impl +fmt +: +: +Display +for +Ast +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +use +crate +: +: +ast +: +: +print +: +: +Printer +; +Printer +: +: +new +( +) +. +print +( +self +f +) +} +} +/ +/ +/ +An +alternation +of +regular +expressions +. +# +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +struct +Alternation +{ +/ +/ +/ +The +span +of this -literal +alternation . pub -c +span : -char +Span +/ +/ +/ +The +alternate +regular +expressions +. +pub +asts +: +Vec +< +Ast +> } impl -Literal +Alternation { / / / -If +Return this -literal -was -written +alternation as -a -\ -x -hex -escape -then +an +AST +. +/ +/ +/ +/ +/ +/ +If this -returns +alternation +contains +zero +ASTs +then +Ast +: +: +Empty +is / / / +returned +. +If +this +alternation +contains +exactly +1 +AST +then the +/ +/ +/ corresponding -byte -value +AST +is +returned . Otherwise -this -returns -None +Ast +: +: +Alternation +is +returned . pub fn -byte +into_ast ( -& +mut self ) - > -Option -< -u8 -> +Ast { match self . -kind -{ -LiteralKind -: -: -HexFixed +asts +. +len ( -HexLiteralKind -: -: -X ) +{ +0 = > -{ -u8 +Ast : : -try_from +Empty ( self . -c +span ) +1 += +> +self . -ok +asts +. +pop +( +) +. +unwrap ( ) -} _ = > -None +Ast +: +: +Alternation +( +self +) } } } / / / -The -kind +A +concatenation of -a -single -literal -expression +regular +expressions . # [ @@ -4735,293 +4487,375 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub -enum -LiteralKind +struct +Concat { / / / The -literal -is -written -verbatim -e -. -g -. -a -or +span +of +this +concatenation . -Verbatim +pub +span +: +Span / / / The -literal -is -written +concatenation +regular +expressions +. +pub +asts +: +Vec +< +Ast +> +} +impl +Concat +{ +/ +/ +/ +Return +this +concatenation as an -escape -because -it -is -otherwise -a -special +AST +. / / / -regex -meta -character -e -. -g -. -\ -* -or -\ -[ -. -Meta / / / -The -literal +If +this +concatenation +contains +zero +ASTs +then +Ast +: +: +Empty is -written -as -an -escape -despite -the -fact -that +/ +/ +/ +returned +. +If +this +concatenation +contains +exactly +1 +AST +then the -escape -is / / / -unnecessary -e +corresponding +AST +is +returned . -g +Otherwise +Ast +: +: +Concat +is +returned . -\ -% -or -\ -/ +pub +fn +into_ast +( +mut +self +) +- +> +Ast +{ +match +self +. +asts +. +len +( +) +{ +0 += +> +Ast +: +: +Empty +( +self +. +span +) +1 += +> +self . -Superfluous +asts +. +pop +( +) +. +unwrap +( +) +_ += +> +Ast +: +: +Concat +( +self +) +} +} +} / / / -The +A +single literal -is -written -as -an -octal -escape -e -. -g -. -\ -141 +expression . -Octal / / / -The +/ +/ +/ +A literal -is -written -as -a -hex -code -with +corresponds +to a -fixed -number -of -digits +single +Unicode +scalar +value +. +Literals +may +be / / / -depending -on -the -type -of -the -escape +represented +in +their +literal +form e . g . -\ -x61 -or -or -\ -u0061 +a or +in +their +escaped +form / / / +e +. +g +. \ -U00000061 +x61 . -HexFixed +# +[ +derive ( -HexLiteralKind +Clone +Debug +Eq +PartialEq ) +] +pub +struct +Literal +{ / / / The -literal -is -written -as -a -hex -code -with -a -bracketed -number +span of +this +literal +. +pub +span +: +Span / / / -digits -. The -only -restriction -is -that -the -bracketed -hex -code -must -refer +kind +of +this +literal +. +pub +kind +: +LiteralKind / / / -to -a -valid +The Unicode scalar value +corresponding +to +this +literal . -HexBrace -( -HexLiteralKind -) +pub +c +: +char +} +impl +Literal +{ / / / -The +If +this literal -is +was written as a -specially -recognized -escape -e -. -g -. \ -f +x +hex +escape +then +this +returns / / / -or -\ -n +the +corresponding +byte +value . -Special +Otherwise +this +returns +None +. +pub +fn +byte ( -SpecialLiteralKind +& +self +) +- +> +Option +< +u8 +> +{ +let +short_hex += +LiteralKind +: +: +HexFixed +( +HexLiteralKind +: +: +X +) +; +if +self +. +c +as +u32 +< += +255 +& +& +self +. +kind += += +short_hex +{ +Some +( +self +. +c +as +u8 ) } +else +{ +None +} +} +} / / / The -type +kind of a -special -literal -. -/ -/ -/ -/ -/ -/ -A -special +single literal -is -a -special -escape -sequence -recognized -by -the -regex -/ -/ -/ -parser -e -. -g -. -\ -f -or -\ -n +expression . # [ @@ -5033,59 +4867,284 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum -SpecialLiteralKind +LiteralKind { / / / -Bell -spelled -\ -a -( -\ -x07 -) +The +literal +is +written +verbatim +e . -Bell -/ -/ -/ -Form -feed -spelled -\ -f -( -\ -x0C -) +g . -FormFeed +a +or +. +Verbatim / / / -Tab +The +literal +is +written +as +an +escape +because +it +is +punctuation +e +. +g +. +/ +/ +/ +\ +* +or +\ +[ +. +Punctuation +/ +/ +/ +The +literal +is +written +as +an +octal +escape +e +. +g +. +\ +141 +. +Octal +/ +/ +/ +The +literal +is +written +as +a +hex +code +with +a +fixed +number +of +digits +/ +/ +/ +depending +on +the +type +of +the +escape +e +. +g +. +\ +x61 +or +or +\ +u0061 +or +/ +/ +/ +\ +U00000061 +. +HexFixed +( +HexLiteralKind +) +/ +/ +/ +The +literal +is +written +as +a +hex +code +with +a +bracketed +number +of +/ +/ +/ +digits +. +The +only +restriction +is +that +the +bracketed +hex +code +must +refer +/ +/ +/ +to +a +valid +Unicode +scalar +value +. +HexBrace +( +HexLiteralKind +) +/ +/ +/ +The +literal +is +written +as +a +specially +recognized +escape +e +. +g +. +\ +f +/ +/ +/ +or +\ +n +. +Special +( +SpecialLiteralKind +) +} +/ +/ +/ +The +type +of +a +special +literal +. +/ +/ +/ +/ +/ +/ +A +special +literal +is +a +special +escape +sequence +recognized +by +the +regex +/ +/ +/ +parser +e +. +g +. +\ +f +or +\ +n +. +# +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +enum +SpecialLiteralKind +{ +/ +/ +/ +Bell +spelled +\ +a +( +\ +x07 +) +. +Bell +/ +/ +/ +Form +feed +spelled +\ +f +( +\ +x0C +) +. +FormFeed +/ +/ +/ +Tab spelled \ t @@ -5227,24 +5286,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum HexLiteralKind @@ -5423,24 +5464,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum Class @@ -5633,24 +5656,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct ClassPerl @@ -5733,24 +5738,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum ClassPerlKind @@ -5794,24 +5781,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct ClassAscii @@ -5905,24 +5874,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum ClassAsciiKind @@ -6341,24 +6292,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct ClassUnicode @@ -6575,1116 +6508,181 @@ return false . pub -fn -is_negated -( -& -self -) -- -> -bool -{ -match -self -. -kind -{ -ClassUnicodeKind -: -: -NamedValue -{ -op -: -ClassUnicodeOpKind -: -: -NotEqual -. -. -} -= -> -! -self -. -negated -_ -= -> -self -. -negated -} -} -} -/ -/ -/ -The -available -forms -of -Unicode -character -classes -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -enum -ClassUnicodeKind -{ -/ -/ -/ -A -one -letter -abbreviated -class -e -. -g -. -\ -pN -. -OneLetter -( -char -) -/ -/ -/ -A -binary -property -general -category -or -script -. -The -string -may -be -/ -/ -/ -empty -. -Named -( -String -) -/ -/ -/ -A -property -name -and -an -associated -value -. -NamedValue -{ -/ -/ -/ -The -type -of -Unicode -op -used -to -associate -name -with -value -. -op -: -ClassUnicodeOpKind -/ -/ -/ -The -property -name -( -which -may -be -empty -) -. -name -: -String -/ -/ -/ -The -property -value -( -which -may -be -empty -) -. -value -: -String -} -} -# -[ -cfg -( -feature -= -" -arbitrary -" -) -] -impl -arbitrary -: -: -Arbitrary -< -' -_ -> -for -ClassUnicodeKind -{ -fn -arbitrary -( -u -: -& -mut -arbitrary -: -: -Unstructured -) -- -> -arbitrary -: -: -Result -< -ClassUnicodeKind -> -{ -# -[ -cfg -( -any -( -feature -= -" -unicode -- -age -" -feature -= -" -unicode -- -bool -" -feature -= -" -unicode -- -gencat -" -feature -= -" -unicode -- -perl -" -feature -= -" -unicode -- -script -" -feature -= -" -unicode -- -segment -" -) -) -] -{ -use -alloc -: -: -string -: -: -ToString -; -use -super -: -: -unicode_tables -: -: -{ -property_names -: -: -PROPERTY_NAMES -property_values -: -: -PROPERTY_VALUES -} -; -match -u -. -choose_index -( -3 -) -? -{ -0 -= -> -{ -let -all -= -PROPERTY_VALUES -. -iter -( -) -. -flat_map -( -| -e -| -e -. -1 -. -iter -( -) -) -. -filter -( -| -( -name -_ -) -| -name -. -len -( -) -= -= -1 -) -. -count -( -) -; -let -idx -= -u -. -choose_index -( -all -) -? -; -let -value -= -PROPERTY_VALUES -. -iter -( -) -. -flat_map -( -| -e -| -e -. -1 -. -iter -( -) -) -. -take -( -idx -+ -1 -) -. -last -( -) -. -unwrap -( -) -. -0 -. -chars -( -) -. -next -( -) -. -unwrap -( -) -; -Ok -( -ClassUnicodeKind -: -: -OneLetter -( -value -) -) -} -1 -= -> -{ -let -all -= -PROPERTY_VALUES -. -iter -( -) -. -map -( -| -e -| -e -. -1 -. -len -( -) -) -. -sum -: -: -< -usize -> -( -) -+ -PROPERTY_NAMES -. -len -( -) -; -let -idx -= -u -. -choose_index -( -all -) -? -; -let -name -= -PROPERTY_VALUES -. -iter -( -) -. -flat_map -( -| -e -| -e -. -1 -. -iter -( -) -) -. -chain -( -PROPERTY_NAMES -) -. -map -( -| -( -_ -e -) -| -e -) -. -take -( -idx -+ -1 -) -. -last -( -) -. -unwrap -( -) -; -Ok -( -ClassUnicodeKind -: -: -Named -( -name -. -to_string -( -) -) -) -} -2 -= -> -{ -let -all -= -PROPERTY_VALUES -. -iter -( -) -. -map -( -| -e -| -e -. -1 -. -len -( -) -) -. -sum -: -: -< -usize -> -( -) -; -let -idx -= -u -. -choose_index -( -all -) -? -; -let -( -prop -value -) -= -PROPERTY_VALUES -. -iter -( -) -. -flat_map -( -| -e -| -{ -e -. -1 -. -iter -( -) -. -map -( -| -( -_ -value -) -| -( -e -. -0 -value -) -) -} -) -. -take -( -idx -+ -1 -) -. -last -( -) -. -unwrap -( -) -; -Ok -( -ClassUnicodeKind -: -: -NamedValue -{ -op -: -u -. -arbitrary -( -) -? -name -: -prop -. -to_string -( -) -value -: -value -. -to_string -( -) -} -) -} -_ -= -> -unreachable -! -( -" -index -chosen -is -impossible -" -) -} -} -# -[ -cfg -( -not -( -any -( -feature -= -" -unicode -- -age -" -feature -= -" -unicode -- -bool -" -feature -= -" -unicode -- -gencat -" -feature -= -" -unicode -- -perl -" -feature -= -" -unicode -- -script -" -feature -= -" -unicode -- -segment -" -) -) -) -] -{ -match -u -. -choose_index -( -3 -) -? -{ -0 -= -> -Ok -( -ClassUnicodeKind -: -: -OneLetter -( -u -. -arbitrary -( -) -? -) -) -1 -= -> -Ok -( -ClassUnicodeKind -: -: -Named -( -u -. -arbitrary -( -) -? -) -) -2 -= -> -Ok -( -ClassUnicodeKind -: -: -NamedValue -{ -op -: -u -. -arbitrary -( -) -? -name -: -u -. -arbitrary -( -) -? -value -: -u -. -arbitrary -( -) -? -} -) -_ -= -> -unreachable -! -( -" -index -chosen -is -impossible -" -) -} -} -} -fn -size_hint -( -depth -: -usize -) -- -> -( -usize -Option -< -usize -> -) -{ -# -[ -cfg -( -any -( -feature -= -" -unicode -- -age -" -feature -= -" -unicode -- -bool -" -feature -= -" -unicode -- -gencat -" -feature -= -" -unicode -- -perl -" -feature -= -" -unicode -- -script -" -feature -= -" -unicode -- -segment -" -) -) -] -{ -arbitrary -: -: -size_hint -: -: -and_all -( -& -[ -usize -: -: -size_hint -( -depth -) -usize -: -: -size_hint -( -depth -) -arbitrary -: -: -size_hint -: -: -or -( -( -0 -Some -( -0 -) -) -ClassUnicodeOpKind -: -: -size_hint -( -depth -) -) -] -) -} -# -[ -cfg -( -not -( -any -( -feature -= -" -unicode -- -age -" -feature -= -" -unicode -- -bool -" -feature -= -" -unicode -- -gencat -" -feature -= -" -unicode -- -perl -" -feature -= -" -unicode -- -script -" -feature -= -" -unicode -- -segment -" -) -) +fn +is_negated +( +& +self ) -] +- +> +bool { -arbitrary -: -: -size_hint -: -: -and -( -usize -: +match +self +. +kind +{ +ClassUnicodeKind : -size_hint -( -depth -) -arbitrary : +NamedValue +{ +op : -size_hint +ClassUnicodeOpKind : : -or_all -( -& +NotEqual +. +. +} += +> +! +self +. +negated +_ += +> +self +. +negated +} +} +} +/ +/ +/ +The +available +forms +of +Unicode +character +classes +. +# [ -char -: -: -size_hint +derive ( -depth +Clone +Debug +Eq +PartialEq ) -String -: -: -size_hint +] +pub +enum +ClassUnicodeKind +{ +/ +/ +/ +A +one +letter +abbreviated +class +e +. +g +. +\ +pN +. +OneLetter ( -depth +char ) -arbitrary -: -: -size_hint -: -: -and_all +/ +/ +/ +A +binary +property +general +category +or +script +. +The +string +may +be +/ +/ +/ +empty +. +Named ( -& -[ String -: -: -size_hint -( -depth ) -String -: +/ +/ +/ +A +property +name +and +an +associated +value +. +NamedValue +{ +/ +/ +/ +The +type +of +Unicode +op +used +to +associate +name +with +value +. +op : -size_hint +ClassUnicodeOpKind +/ +/ +/ +The +property +name ( -depth +which +may +be +empty ) -ClassUnicodeOpKind -: +. +name : -size_hint +String +/ +/ +/ +The +property +value ( -depth -) -] -) -] -) +which +may +be +empty ) -} +. +value +: +String } } / @@ -7711,24 +6709,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum ClassUnicodeOpKind @@ -7891,24 +6871,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct ClassBracketed @@ -8089,24 +7051,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum ClassSet @@ -8331,28 +7275,10 @@ set [ derive ( -Clone -Debug -Eq -PartialEq -) -] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) +Clone +Debug +Eq +PartialEq ) ] pub @@ -8748,24 +7674,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct ClassSetRange @@ -8904,24 +7812,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct ClassSetUnion @@ -9311,24 +8201,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct ClassSetBinaryOp @@ -9488,24 +8360,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum ClassSetBinaryOpKind @@ -9626,24 +8480,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct Assertion @@ -9698,24 +8534,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum AssertionKind @@ -9776,24 +8594,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct Repetition @@ -9873,24 +8673,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct RepetitionOp @@ -9957,24 +8739,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum RepetitionKind @@ -10024,24 +8788,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum RepetitionRange @@ -10265,24 +9011,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct Group @@ -10446,10 +9174,9 @@ GroupKind : : CaptureName -{ -. -. -} +( +_ +) = > true @@ -10535,17 +9262,15 @@ GroupKind : : CaptureName -{ +( ref -name -. -. -} +x +) = > Some ( -name +x . index ) @@ -10581,24 +9306,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum GroupKind @@ -10611,65 +9318,23 @@ a ) CaptureIndex ( -u32 -) -/ -/ -/ -( -? -< -name -> -a -) -or -( -? -P -< -name -> -a -) -CaptureName -{ -/ -/ -/ -True -if -the -? -P -< -syntax -is -used -and -false -if -the -? -< -syntax -is -used -. -starts_with_p -: -bool +u32 +) / / / -The -capture -name -. +( +? +P +< name -: +> +a +) CaptureName -} +( +CaptureName +) / / / @@ -10727,299 +9392,59 @@ P < foo > -expr -) -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -CaptureName -{ -/ -/ -/ -The -span -of -this -capture -name -. -pub -span -: -Span -/ -/ -/ -The -capture -name -. -pub -name -: -String -/ -/ -/ -The -capture -index -. -pub -index -: -u32 -} -# -[ -cfg -( -feature -= -" -arbitrary -" -) -] -impl -arbitrary -: -: -Arbitrary -< -' -_ -> -for -CaptureName -{ -fn -arbitrary -( -u -: -& -mut -arbitrary -: -: -Unstructured -) -- -> -arbitrary -: -: -Result -< -CaptureName -> -{ -let -len -= -u -. -arbitrary_len -: -: -< -char -> -( -) -? -; -if -len -= -= -0 -{ -return -Err -( -arbitrary -: -: -Error -: -: -NotEnoughData -) -; -} -let -mut -name -: -String -= -String -: -: -new -( -) -; -for -_ -in -0 -. -. -len -{ -let -ch -: -char -= -u -. -arbitrary -( -) -? -; -let -cp -= -u32 -: -: -from -( -ch -) -; -let -ascii_letter_offset -= -u8 -: -: -try_from -( -cp -% -26 -) -. -unwrap -( -) -; -let -ascii_letter -= -b -' -a -' -+ -ascii_letter_offset -; -name -. -push -( -char -: -: -from -( -ascii_letter -) -) -; -} -Ok -( -CaptureName -{ -span -: -u -. -arbitrary -( -) -? -name -index -: -u -. -arbitrary -( -) -? -} -) -} -fn -size_hint -( -depth -: -usize -) -- -> -( -usize -Option -< -usize -> +expr ) -{ -arbitrary -: -: -size_hint -: -: -and_all -( -& +. +# [ -Span -: -: -size_hint +derive ( -depth +Clone +Debug +Eq +PartialEq ) -usize -: +] +pub +struct +CaptureName +{ +/ +/ +/ +The +span +of +this +capture +name +. +pub +span : -size_hint -( -depth -) -u32 +Span +/ +/ +/ +The +capture +name +. +pub +name : +String +/ +/ +/ +The +capture +index +. +pub +index : -size_hint -( -depth -) -] -) -} +u32 } / / @@ -11048,24 +9473,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct SetFlags @@ -11142,24 +9549,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct Flags @@ -11528,24 +9917,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub struct FlagsItem @@ -11601,24 +9972,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum FlagsItemKind @@ -11724,24 +10077,6 @@ Eq PartialEq ) ] -# -[ -cfg_attr -( -feature -= -" -arbitrary -" -derive -( -arbitrary -: -: -Arbitrary -) -) -] pub enum Flag @@ -11774,11 +10109,6 @@ Unicode / / / -R -CRLF -/ -/ -/ x IgnoreWhitespace } @@ -11828,7 +10158,7 @@ self ) { use -core +std : : mem @@ -12292,7 +10622,7 @@ self ) { use -core +std : : mem @@ -12940,156 +11270,6 @@ issue more easily . -/ -/ -/ -/ -NOTE -( -2023 -- -03 -- -21 -) -: -It -turns -out -that -some -platforms -( -like -FreeBSD -) -/ -/ -will -just -barf -with -very -small -stack -sizes -. -So -we -bump -this -up -a -bit -/ -/ -to -give -more -room -to -breath -. -When -I -did -this -I -confirmed -that -if -/ -/ -I -remove -the -custom -Drop -impl -for -Ast -then -this -test -does -/ -/ -indeed -still -fail -with -a -stack -overflow -. -( -At -the -time -of -writing -I -/ -/ -had -to -bump -it -all -the -way -up -to -32K -before -the -test -would -pass -even -/ -/ -without -the -custom -Drop -impl -. -So -16K -seems -like -a -safe -number -/ -/ -here -. -) -/ -/ -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -967 thread : : @@ -13102,7 +11282,7 @@ new . stack_size ( -16 +1 < < 10 diff --git a/third_party/rust/regex-syntax/src/ast/parse.rs b/third_party/rust/regex-syntax/src/ast/parse.rs index 2d6e10655e88c..90153f2e267ba 100644 --- a/third_party/rust/regex-syntax/src/ast/parse.rs +++ b/third_party/rust/regex-syntax/src/ast/parse.rs @@ -12,14 +12,18 @@ parser * / use -core +std : : -{ borrow : : Borrow +; +use +std +: +: cell : : @@ -27,37 +31,23 @@ cell Cell RefCell } -mem -} ; use -alloc +std : : -{ -boxed -: -: -Box -string -: -: -{ -String -ToString -} -vec -vec +mem +; +use +std : : -Vec -} +result ; use crate : : -{ ast : : @@ -67,13 +57,21 @@ Ast Position Span } +; +use +crate +: +: either : : Either -is_escapeable_character +; +use +crate +: +: is_meta_character -} ; type Result @@ -81,9 +79,6 @@ Result T > = -core -: -: result : : @@ -898,9 +893,6 @@ bool > bool { -if -first -{ c = = @@ -909,20 +901,28 @@ _ ' | | -c -. -is_alphabetic ( -) -} -else -{ -c +! +first +& +& +( +( +' +0 +' +< = +c +& +& +c +< = ' -_ +9 ' +) | | c @@ -947,15 +947,45 @@ c ' ] ' +) +) | | +( +' +A +' +< += c -. -is_alphanumeric +& +& +c +< += +' +Z +' +) +| +| ( +' +a +' +< += +c +& +& +c +< += +' +z +' ) } -} / / / @@ -1360,7 +1390,7 @@ checked until the entire -AST +Ast is parsed . @@ -1938,9 +1968,19 @@ more detail via a +/ +/ +/ [ ParserBuilder ] +( +struct +. +ParserBuilder +. +html +) . # [ @@ -2901,9 +2941,19 @@ on the parser use +/ +/ +/ [ ParserBuilder ] +( +struct +. +ParserBuilder +. +html +) . pub fn @@ -3301,6 +3351,10 @@ str self . pattern +. +borrow +( +) } / / @@ -10108,12 +10162,6 @@ span ( ) ; -let -mut -starts_with_p -= -true -; if self . @@ -10125,23 +10173,6 @@ P < " ) -| -| -{ -starts_with_p -= -false -; -self -. -bump_if -( -" -? -< -" -) -} { let capture_index @@ -10155,7 +10186,7 @@ open_span ? ; let -name +cap = self . @@ -10189,10 +10220,9 @@ GroupKind : : CaptureName -{ -starts_with_p -name -} +( +cap +) ast : Box @@ -11487,21 +11517,6 @@ Flag Unicode ) ' -R -' -= -> -Ok -( -ast -: -: -Flag -: -: -CRLF -) -' x ' = @@ -12384,42 +12399,7 @@ ast LiteralKind : : -Meta -c -} -) -) -; -} -if -is_escapeable_character -( -c -) -{ -return -Ok -( -Primitive -: -: -Literal -( -ast -: -: -Literal -{ -span -kind -: -ast -: -: -LiteralKind -: -: -Superfluous +Punctuation c } ) @@ -12583,6 +12563,30 @@ x0B ' ) ' +' +if +self +. +ignore_whitespace +( +) += +> +{ +special +( +ast +: +: +SpecialLiteralKind +: +: +Space +' +' +) +} +' A ' = @@ -12825,6 +12829,18 @@ ast : Literal { +use +std +: +: +char +; +use +std +: +: +u32 +; assert ! ( @@ -13423,6 +13439,18 @@ ast Literal > { +use +std +: +: +char +; +use +std +: +: +u32 +; let mut scratch @@ -13754,6 +13782,18 @@ ast Literal > { +use +std +: +: +char +; +use +std +: +: +u32 +; let mut scratch @@ -18011,6 +18051,11 @@ ErrorKind : NestLimitExceeded ( +: +: +std +: +: u32 : : @@ -19101,7 +19146,7 @@ mod tests { use -core +std : : ops @@ -19110,10 +19155,15 @@ ops Range ; use -alloc +super : : -format +{ +Parser +ParserBuilder +ParserI +Primitive +} ; use crate @@ -19129,12 +19179,6 @@ Position Span } ; -use -super -: -: -* -; / / Our @@ -20055,7 +20099,7 @@ len_utf8 / Create a -meta +punctuation literal starting at @@ -20064,7 +20108,7 @@ given position . fn -meta_lit +punct_lit ( c : @@ -20096,7 +20140,7 @@ ast LiteralKind : : -Meta +Punctuation c } ) @@ -22190,7 +22234,7 @@ concat vec ! [ -meta_lit +punct_lit ( ' \ @@ -22204,7 +22248,7 @@ span 2 ) ) -meta_lit +punct_lit ( ' . @@ -22217,7 +22261,7 @@ span 4 ) ) -meta_lit +punct_lit ( ' + @@ -22230,7 +22274,7 @@ span 6 ) ) -meta_lit +punct_lit ( ' * @@ -22243,7 +22287,7 @@ span 8 ) ) -meta_lit +punct_lit ( ' ? @@ -22256,7 +22300,7 @@ span 10 ) ) -meta_lit +punct_lit ( ' ( @@ -22269,7 +22313,7 @@ span 12 ) ) -meta_lit +punct_lit ( ' ) @@ -22282,7 +22326,7 @@ span 14 ) ) -meta_lit +punct_lit ( ' | @@ -22295,7 +22339,7 @@ span 16 ) ) -meta_lit +punct_lit ( ' [ @@ -22308,7 +22352,7 @@ span 18 ) ) -meta_lit +punct_lit ( ' ] @@ -22321,7 +22365,7 @@ span 20 ) ) -meta_lit +punct_lit ( ' { @@ -22334,7 +22378,7 @@ span 22 ) ) -meta_lit +punct_lit ( ' } @@ -22347,7 +22391,7 @@ span 24 ) ) -meta_lit +punct_lit ( ' ^ @@ -22360,7 +22404,7 @@ span 26 ) ) -meta_lit +punct_lit ( ' ' @@ -22372,7 +22416,7 @@ span 28 ) ) -meta_lit +punct_lit ( ' # @@ -22385,7 +22429,7 @@ span 30 ) ) -meta_lit +punct_lit ( ' & @@ -22398,7 +22442,7 @@ span 32 ) ) -meta_lit +punct_lit ( ' - @@ -22411,7 +22455,7 @@ span 34 ) ) -meta_lit +punct_lit ( ' ~ @@ -23088,12 +23132,7 @@ GroupKind : : CaptureName -{ -starts_with_p -: -true -name -: +( ast : : @@ -23121,7 +23160,7 @@ index : 1 } -} +) ast : Box @@ -23630,7 +23669,16 @@ ast LiteralKind : : -Superfluous +Special +( +ast +: +: +SpecialLiteralKind +: +: +Space +) c : ' @@ -23642,6 +23690,66 @@ c ) ) ; +/ +/ +. +. +. +but +only +when +x +mode +is +enabled +. +let +pat += +r +" +\ +" +; +assert_eq +! +( +parser +( +pat +) +. +parse +( +) +. +unwrap_err +( +) +TestError +{ +span +: +span_range +( +pat +0 +. +. +2 +) +kind +: +ast +: +: +ErrorKind +: +: +EscapeUnrecognized +} +) +; } # [ @@ -29898,6 +30006,7 @@ parser " ( ? +P < a > @@ -29928,7 +30037,7 @@ span 0 . . -7 +8 ) kind : @@ -29939,39 +30048,230 @@ GroupKind : : CaptureName +( +ast +: +: +CaptureName { -starts_with_p +span : -false +span +( +4 +. +. +5 +) name : +s +( +" +a +" +) +index +: +1 +} +) ast : +Box : -CaptureName +: +new +( +lit +( +' +z +' +6 +) +) +} +) +) +) +; +assert_eq +! +( +parser +( +" +( +? +P +< +abc +> +z +) +" +) +. +parse +( +) +Ok +( +Ast +: +: +Group +( +ast +: +: +Group { span : span ( -3 +0 . . +10 +) +kind +: +ast +: +: +GroupKind +: +: +CaptureName +( +ast +: +: +CaptureName +{ +span +: +span +( 4 +. +. +7 ) name : s ( " -a +abc " ) index : 1 } +) +ast +: +Box +: +: +new +( +lit +( +' +z +' +8 +) +) } +) +) +) +; +assert_eq +! +( +parser +( +" +( +? +P +< +a_1 +> +z +) +" +) +. +parse +( +) +Ok +( +Ast +: +: +Group +( +ast +: +: +Group +{ +span +: +span +( +0 +. +. +10 +) +kind +: +ast +: +: +GroupKind +: +: +CaptureName +( +ast +: +: +CaptureName +{ +span +: +span +( +4 +. +. +7 +) +name +: +s +( +" +a_1 +" +) +index +: +1 +} +) ast : Box @@ -29984,7 +30284,7 @@ lit ' z ' -5 +8 ) ) } @@ -30003,109 +30303,8 @@ parser P < a -> -z -) -" -) -. -parse -( -) -Ok -( -Ast -: -: -Group -( -ast -: -: -Group -{ -span -: -span -( -0 -. -. -8 -) -kind -: -ast -: -: -GroupKind -: -: -CaptureName -{ -starts_with_p -: -true -name -: -ast -: -: -CaptureName -{ -span -: -span -( -4 -. -. -5 -) -name -: -s -( -" -a -" -) -index -: -1 -} -} -ast -: -Box -: -: -new -( -lit -( -' -z -' -6 -) -) -} -) -) -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -abc +. +1 > z ) @@ -30145,220 +30344,7 @@ GroupKind : : CaptureName -{ -starts_with_p -: -true -name -: -ast -: -: -CaptureName -{ -span -: -span -( -4 -. -. -7 -) -name -: -s -( -" -abc -" -) -index -: -1 -} -} -ast -: -Box -: -: -new -( -lit -( -' -z -' -8 -) -) -} -) -) -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -a_1 -> -z -) -" -) -. -parse -( -) -Ok -( -Ast -: -: -Group -( -ast -: -: -Group -{ -span -: -span -( -0 -. -. -10 -) -kind -: -ast -: -: -GroupKind -: -: -CaptureName -{ -starts_with_p -: -true -name -: -ast -: -: -CaptureName -{ -span -: -span -( -4 -. -. -7 -) -name -: -s -( -" -a_1 -" -) -index -: -1 -} -} -ast -: -Box -: -: -new -( -lit ( -' -z -' -8 -) -) -} -) -) -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -a -. -1 -> -z -) -" -) -. -parse -( -) -Ok -( -Ast -: -: -Group -( -ast -: -: -Group -{ -span -: -span -( -0 -. -. -10 -) -kind -: -ast -: -: -GroupKind -: -: -CaptureName -{ -starts_with_p -: -true -name -: ast : : @@ -30387,7 +30373,7 @@ index : 1 } -} +) ast : Box @@ -30461,12 +30447,7 @@ GroupKind : : CaptureName -{ -starts_with_p -: -true -name -: +( ast : : @@ -30496,7 +30477,7 @@ index : 1 } -} +) ast : Box @@ -30527,322 +30508,6 @@ parser ? P < -a -> -) -" -) -. -parse -( -) -Ok -( -Ast -: -: -Group -( -ast -: -: -Group -{ -span -: -Span -: -: -new -( -Position -: -: -new -( -0 -1 -1 -) -Position -: -: -new -( -9 -1 -9 -) -) -kind -: -ast -: -: -GroupKind -: -: -CaptureName -{ -starts_with_p -: -true -name -: -ast -: -: -CaptureName -{ -span -: -Span -: -: -new -( -Position -: -: -new -( -4 -1 -5 -) -Position -: -: -new -( -7 -1 -7 -) -) -name -: -s -( -" -a -" -) -index -: -1 -} -} -ast -: -Box -: -: -new -( -Ast -: -: -Empty -( -Span -: -: -new -( -Position -: -: -new -( -8 -1 -8 -) -Position -: -: -new -( -8 -1 -8 -) -) -) -) -} -) -) -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -> -) -" -) -. -parse -( -) -Ok -( -Ast -: -: -Group -( -ast -: -: -Group -{ -span -: -Span -: -: -new -( -Position -: -: -new -( -0 -1 -1 -) -Position -: -: -new -( -12 -1 -9 -) -) -kind -: -ast -: -: -GroupKind -: -: -CaptureName -{ -starts_with_p -: -true -name -: -ast -: -: -CaptureName -{ -span -: -Span -: -: -new -( -Position -: -: -new -( -4 -1 -5 -) -Position -: -: -new -( -10 -1 -7 -) -) -name -: -s -( -" -" -) -index -: -1 -} -} -ast -: -Box -: -: -new -( -Ast -: -: -Empty -( -Span -: -: -new -( -Position -: -: -new -( -11 -1 -8 -) -Position -: -: -new -( -11 -1 -8 -) -) -) -) -} -) -) -) -; -assert_eq -! -( -parser -( -" -( -? -P -< " ) . @@ -31108,336 +30773,8 @@ parser ? P < -abc -~ -" -) -. -parse -( -) -. -unwrap_err -( -) -TestError -{ -span -: -span -( -7 -. -. -8 -) -kind -: -ast -: -: -ErrorKind -: -: -GroupNameInvalid -} -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -a -> -y -) -( -? -P -< -a -> -z -) -" -) -. -parse -( -) -. -unwrap_err -( -) -TestError -{ -span -: -span -( -12 -. -. -13 -) -kind -: -ast -: -: -ErrorKind -: -: -GroupNameDuplicate -{ -original -: -span -( -4 -. -. -5 -) -} -} -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -5 -> -) -" -) -. -parse -( -) -. -unwrap_err -( -) -TestError -{ -span -: -span -( -4 -. -. -5 -) -kind -: -ast -: -: -ErrorKind -: -: -GroupNameInvalid -} -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -5a -> -) -" -) -. -parse -( -) -. -unwrap_err -( -) -TestError -{ -span -: -span -( -4 -. -. -5 -) -kind -: -ast -: -: -ErrorKind -: -: -GroupNameInvalid -} -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -> -) -" -) -. -parse -( -) -. -unwrap_err -( -) -TestError -{ -span -: -Span -: -: -new -( -Position -: -: -new -( -4 -1 -5 -) -Position -: -: -new -( -6 -1 -6 -) -) -kind -: -ast -: -: -ErrorKind -: -: -GroupNameInvalid -} -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -a -> -) -" -) -. -parse -( -) -. -unwrap_err -( -) -TestError -{ -span -: -Span -: -: -new -( -Position -: -: -new -( -4 -1 -5 -) -Position -: -: -new -( -6 -1 -6 -) -) -kind -: -ast -: -: -ErrorKind -: -: -GroupNameInvalid -} -) -; -assert_eq -! -( -parser -( -" -( -? -P -< -> -) +abc +~ " ) . @@ -31452,29 +30789,12 @@ TestError { span : -Span -: -: -new -( -Position -: -: -new -( -4 -1 -5 -) -Position -: -: -new +span ( 7 -1 -6 -) +. +. +8 ) kind : @@ -31500,6 +30820,15 @@ P < a > +y +) +( +? +P +< +a +> +z ) " ) @@ -31515,29 +30844,12 @@ TestError { span : -Span -: -: -new -( -Position -: -: -new -( -5 -1 -6 -) -Position -: -: -new +span ( -8 -1 -7 -) +12 +. +. +13 ) kind : @@ -31547,7 +30859,18 @@ ast ErrorKind : : -GroupNameInvalid +GroupNameDuplicate +{ +original +: +span +( +4 +. +. +5 +) +} } ) ; @@ -32181,171 +31504,6 @@ assert_eq parser ( " -i -- -sR -: -" -) -. -parse_flags -( -) -Ok -( -ast -: -: -Flags -{ -span -: -span -( -0 -. -. -4 -) -items -: -vec -! -[ -ast -: -: -FlagsItem -{ -span -: -span -( -0 -. -. -1 -) -kind -: -ast -: -: -FlagsItemKind -: -: -Flag -( -ast -: -: -Flag -: -: -CaseInsensitive -) -} -ast -: -: -FlagsItem -{ -span -: -span -( -1 -. -. -2 -) -kind -: -ast -: -: -FlagsItemKind -: -: -Negation -} -ast -: -: -FlagsItem -{ -span -: -span -( -2 -. -. -3 -) -kind -: -ast -: -: -FlagsItemKind -: -: -Flag -( -ast -: -: -Flag -: -: -DotMatchesNewLine -) -} -ast -: -: -FlagsItem -{ -span -: -span -( -3 -. -. -4 -) -kind -: -ast -: -: -FlagsItemKind -: -: -Flag -( -ast -: -: -Flag -: -: -CRLF -) -} -] -} -) -) -; -assert_eq -! -( -parser -( -" isU " ) @@ -32795,31 +31953,6 @@ assert_eq parser ( " -R -" -) -. -parse_flag -( -) -Ok -( -ast -: -: -Flag -: -: -CRLF -) -) -; -assert_eq -! -( -parser -( -" x " ) @@ -33275,7 +32408,7 @@ ast LiteralKind : : -Meta +Punctuation c : ' @@ -33611,123 +32744,22 @@ ast AssertionKind : : -WordBoundary -} -) -) -) -; -assert_eq -! -( -parser -( -r -" -\ -B -" -) -. -parse_primitive -( -) -Ok -( -Primitive -: -: -Assertion -( -ast -: -: -Assertion -{ -span -: -span -( -0 -. -. -2 -) -kind -: -ast -: -: -AssertionKind -: -: -NotWordBoundary +WordBoundary } ) ) ) ; -/ -/ -We -also -support -superfluous -escapes -in -most -cases -now -too -. -for -c -in -[ -' -! -' -' -' -' -% -' -' -" -' -' -\ -' -' -' -/ -' -' -' -] -{ -let -pat -= -format +assert_eq ! ( +parser +( r " \ -{ -} +B " -c -) -; -assert_eq -! -( -parser -( -& -pat ) . parse_primitive @@ -33738,12 +32770,12 @@ Ok Primitive : : -Literal +Assertion ( ast : : -Literal +Assertion { span : @@ -33759,45 +32791,15 @@ kind ast : : -LiteralKind +AssertionKind : : -Superfluous -c +NotWordBoundary } ) ) ) ; -} -/ -/ -Some -superfluous -escapes -namely -[ -0 -- -9A -- -Za -- -z -] -are -still -banned -. -This -/ -/ -gives -flexibility -for -future -evolution -. assert_eq ! ( @@ -33806,7 +32808,6 @@ parser r " \ -e " ) . @@ -33826,7 +32827,7 @@ span 0 . . -2 +1 ) kind : @@ -33836,7 +32837,7 @@ ast ErrorKind : : -EscapeUnrecognized +EscapeUnexpectedEof } ) ; @@ -33882,174 +32883,6 @@ EscapeUnrecognized } ) ; -/ -/ -But -also -< -and -> -are -banned -so -that -we -may -evolve -them -into -/ -/ -start -/ -end -word -boundary -assertions -. -( -Not -sure -if -we -will -. -. -. -) -assert_eq -! -( -parser -( -r -" -\ -< -" -) -. -parse_escape -( -) -. -unwrap_err -( -) -TestError -{ -span -: -span -( -0 -. -. -2 -) -kind -: -ast -: -: -ErrorKind -: -: -EscapeUnrecognized -} -) -; -assert_eq -! -( -parser -( -r -" -\ -> -" -) -. -parse_escape -( -) -. -unwrap_err -( -) -TestError -{ -span -: -span -( -0 -. -. -2 -) -kind -: -ast -: -: -ErrorKind -: -: -EscapeUnrecognized -} -) -; -/ -/ -An -unfinished -escape -is -illegal -. -assert_eq -! -( -parser -( -r -" -\ -" -) -. -parse_escape -( -) -. -unwrap_err -( -) -TestError -{ -span -: -span -( -0 -. -. -1 -) -kind -: -ast -: -: -ErrorKind -: -: -EscapeUnexpectedEof -} -) -; } # [ @@ -34227,6 +33060,11 @@ LiteralKind Octal c : +: +: +std +: +: char : : @@ -34731,6 +33569,11 @@ X ) c : +: +: +std +: +: char : : @@ -34896,6 +33739,11 @@ let c = match +: +: +std +: +: char : : @@ -35271,6 +34119,11 @@ let c = match +: +: +std +: +: char : : @@ -38036,7 +36889,7 @@ ast LiteralKind : : -Meta +Punctuation c : ' @@ -38160,7 +37013,7 @@ ast LiteralKind : : -Meta +Punctuation c : ' @@ -39631,7 +38484,7 @@ ast LiteralKind : : -Meta +Punctuation c : ' @@ -39758,7 +38611,7 @@ ast LiteralKind : : -Meta +Punctuation c : ' @@ -40238,7 +39091,7 @@ ast LiteralKind : : -Meta +Punctuation c : ' @@ -40347,7 +39200,7 @@ ast LiteralKind : : -Meta +Punctuation c : ' diff --git a/third_party/rust/regex-syntax/src/ast/print.rs b/third_party/rust/regex-syntax/src/ast/print.rs index d969a92130d17..60303e96fd09f 100644 --- a/third_party/rust/regex-syntax/src/ast/print.rs +++ b/third_party/rust/regex-syntax/src/ast/print.rs @@ -14,7 +14,7 @@ Ast * / use -core +std : : fmt @@ -26,8 +26,6 @@ crate ast : : -{ -self visitor : : @@ -35,6 +33,16 @@ visitor self Visitor } +; +use +crate +: +: +ast +: +: +{ +self Ast } ; @@ -1154,43 +1162,25 @@ write_str " ) CaptureName -{ +( ref -name -starts_with_p -} +x +) = > { -let -start -= -if -starts_with_p -{ -" -( -? -P -< -" -} -else -{ -" -( -? -< -" -} -; self . wtr . write_str ( -start +" +( +? +P +< +" ) ? ; @@ -1201,7 +1191,7 @@ wtr write_str ( & -name +x . name ) @@ -1642,9 +1632,7 @@ ast . c ) -Meta -| -Superfluous +Punctuation = > write @@ -1680,15 +1668,11 @@ r o } " -u32 -: -: -from -( ast . c -) +as +u32 ) HexFixed ( @@ -1718,15 +1702,11 @@ x 02X } " -u32 -: -: -from -( ast . c -) +as +u32 ) } HexFixed @@ -1757,15 +1737,11 @@ u 04X } " -u32 -: -: -from -( ast . c -) +as +u32 ) } HexFixed @@ -1796,15 +1772,11 @@ U 08X } " -u32 -: -: -from -( ast . c -) +as +u32 ) } HexBrace @@ -1839,15 +1811,11 @@ X } } " -u32 -: -: -from -( ast . c -) +as +u32 ) } HexBrace @@ -1882,15 +1850,11 @@ X } } " -u32 -: -: -from -( ast . c -) +as +u32 ) } HexBrace @@ -1925,15 +1889,11 @@ X } } " -u32 -: -: -from -( ast . c -) +as +u32 ) } Special @@ -2464,22 +2424,6 @@ u Flag : : -CRLF -= -> -self -. -wtr -. -write_str -( -" -R -" -) -Flag -: -: IgnoreWhitespace = > @@ -3638,13 +3582,10 @@ mod tests { use -alloc -: -: -string +super : : -String +Printer ; use crate @@ -3658,12 +3599,6 @@ parse : ParserBuilder ; -use -super -: -: -* -; fn roundtrip ( @@ -4415,19 +4350,6 @@ roundtrip ( " ( -? -< -foo -> -a -) -" -) -; -roundtrip -( -" -( a ) " diff --git a/third_party/rust/regex-syntax/src/ast/visitor.rs b/third_party/rust/regex-syntax/src/ast/visitor.rs index 1a48bb0bed1e8..5cf58fd6ca288 100644 --- a/third_party/rust/regex-syntax/src/ast/visitor.rs +++ b/third_party/rust/regex-syntax/src/ast/visitor.rs @@ -1,14 +1,8 @@ use -alloc +std : : -{ -vec -vec -: -: -Vec -} +fmt ; use crate @@ -143,6 +137,13 @@ the [ visit ] +( +fn +. +visit +. +html +) function . / @@ -180,11 +181,14 @@ able to use the -much / / / +much simpler +/ +/ +/ [ high - @@ -193,14 +197,20 @@ intermediate representation ] ( -crate -: -: +. +. +/ hir -: -: +/ +struct +. Hir +. +html ) +/ +/ +/ and its / @@ -212,14 +222,20 @@ Visitor trait ] ( -crate -: -: +. +. +/ hir -: -: +/ +trait +. Visitor +. +html ) +/ +/ +/ instead . pub @@ -442,10 +458,11 @@ an Alternation ] ( -ast -: -: +struct +. Alternation +. +html ) . fn @@ -480,55 +497,20 @@ This method is called -between -child -nodes -of -a -concatenation -. -fn -visit_concat_in -( -& -mut -self -) -- -> -Result -< -( -) -Self -: -: -Err -> -{ -Ok -( -( -) -) -} +on +every / / / -This -method -is -called -on -every [ ClassSetItem ] ( -ast -: -: +enum +. ClassSetItem +. +html ) / / @@ -580,14 +562,18 @@ is called on every +/ +/ +/ [ ClassSetItem ] ( -ast -: -: +enum +. ClassSetItem +. +html ) / / @@ -646,17 +632,18 @@ every ClassSetBinaryOp ] ( -ast -: -: +struct +. ClassSetBinaryOp +. +html ) -before -descending -into / / / +before +descending +into child nodes . @@ -708,18 +695,19 @@ every ClassSetBinaryOp ] ( -ast -: -: +struct +. ClassSetBinaryOp +. +html ) +/ +/ +/ after descending into child -/ -/ -/ nodes . fn @@ -779,10 +767,11 @@ a ClassSetBinaryOp ] ( -ast -: -: +struct +. ClassSetBinaryOp +. +html ) . fn @@ -858,9 +847,19 @@ methods provided by the +/ +/ +/ [ Visitor ] +( +trait +. +Visitor +. +html +) trait . / @@ -2032,9 +2031,8 @@ pop frame ) { -match -x -{ +if +let Frame : : @@ -2044,7 +2042,7 @@ Alternation . } = -> +x { visitor . @@ -2054,31 +2052,6 @@ visit_alternation_in ? ; } -Frame -: -: -Concat -{ -. -. -} -= -> -{ -visitor -. -visit_concat_in -( -) -? -; -} -_ -= -> -{ -} -} ast = x @@ -3888,9 +3861,6 @@ impl ' a > -core -: -: fmt : : @@ -3911,9 +3881,6 @@ f : & mut -core -: -: fmt : : @@ -3925,9 +3892,6 @@ _ ) - > -core -: -: fmt : : @@ -4011,9 +3975,6 @@ impl ' a > -core -: -: fmt : : @@ -4034,9 +3995,6 @@ f : & mut -core -: -: fmt : : @@ -4048,9 +4006,6 @@ _ ) - > -core -: -: fmt : : diff --git a/third_party/rust/regex-syntax/src/debug.rs b/third_party/rust/regex-syntax/src/debug.rs deleted file mode 100644 index 164d19e5874be..0000000000000 --- a/third_party/rust/regex-syntax/src/debug.rs +++ /dev/null @@ -1,1012 +0,0 @@ -/ -/ -/ -A -type -that -wraps -a -single -byte -with -a -convenient -fmt -: -: -Debug -impl -that -/ -/ -/ -escapes -the -byte -. -pub -( -crate -) -struct -Byte -( -pub -( -crate -) -u8 -) -; -impl -core -: -: -fmt -: -: -Debug -for -Byte -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -/ -/ -Special -case -ASCII -space -. -It -' -s -too -hard -to -read -otherwise -so -/ -/ -put -quotes -around -it -. -I -sometimes -wonder -whether -just -' -\ -x20 -' -would -/ -/ -be -better -. -. -. -if -self -. -0 -= -= -b -' -' -{ -return -write -! -( -f -" -' -' -" -) -; -} -/ -/ -10 -bytes -is -enough -to -cover -any -output -from -ascii -: -: -escape_default -. -let -mut -bytes -= -[ -0u8 -; -10 -] -; -let -mut -len -= -0 -; -for -( -i -mut -b -) -in -core -: -: -ascii -: -: -escape_default -( -self -. -0 -) -. -enumerate -( -) -{ -/ -/ -capitalize -\ -xab -to -\ -xAB -if -i -> -= -2 -& -& -b -' -a -' -< -= -b -& -& -b -< -= -b -' -f -' -{ -b -- -= -32 -; -} -bytes -[ -len -] -= -b -; -len -+ -= -1 -; -} -write -! -( -f -" -{ -} -" -core -: -: -str -: -: -from_utf8 -( -& -bytes -[ -. -. -len -] -) -. -unwrap -( -) -) -} -} -/ -/ -/ -A -type -that -provides -a -human -readable -debug -impl -for -arbitrary -bytes -. -/ -/ -/ -/ -/ -/ -This -generally -works -best -when -the -bytes -are -presumed -to -be -mostly -UTF -- -8 -/ -/ -/ -but -will -work -for -anything -. -/ -/ -/ -/ -/ -/ -N -. -B -. -This -is -copied -nearly -verbatim -from -regex -- -automata -. -Sigh -. -pub -( -crate -) -struct -Bytes -< -' -a -> -( -pub -( -crate -) -& -' -a -[ -u8 -] -) -; -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -Bytes -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -\ -" -" -) -? -; -/ -/ -This -is -a -sad -re -- -implementation -of -a -similar -impl -found -in -bstr -. -let -mut -bytes -= -self -. -0 -; -while -let -Some -( -result -) -= -utf8_decode -( -bytes -) -{ -let -ch -= -match -result -{ -Ok -( -ch -) -= -> -ch -Err -( -byte -) -= -> -{ -write -! -( -f -r -" -\ -x -{ -: -02x -} -" -byte -) -? -; -bytes -= -& -bytes -[ -1 -. -. -] -; -continue -; -} -} -; -bytes -= -& -bytes -[ -ch -. -len_utf8 -( -) -. -. -] -; -match -ch -{ -' -\ -0 -' -= -> -write -! -( -f -" -\ -\ -0 -" -) -? -/ -/ -ASCII -control -characters -except -\ -0 -\ -n -\ -r -\ -t -' -\ -x01 -' -. -. -= -' -\ -x08 -' -| -' -\ -x0b -' -| -' -\ -x0c -' -| -' -\ -x0e -' -. -. -= -' -\ -x19 -' -| -' -\ -x7f -' -= -> -{ -write -! -( -f -" -\ -\ -x -{ -: -02x -} -" -u32 -: -: -from -( -ch -) -) -? -; -} -' -\ -n -' -| -' -\ -r -' -| -' -\ -t -' -| -_ -= -> -{ -write -! -( -f -" -{ -} -" -ch -. -escape_debug -( -) -) -? -; -} -} -} -write -! -( -f -" -\ -" -" -) -? -; -Ok -( -( -) -) -} -} -/ -/ -/ -Decodes -the -next -UTF -- -8 -encoded -codepoint -from -the -given -byte -slice -. -/ -/ -/ -/ -/ -/ -If -no -valid -encoding -of -a -codepoint -exists -at -the -beginning -of -the -given -/ -/ -/ -byte -slice -then -the -first -byte -is -returned -instead -. -/ -/ -/ -/ -/ -/ -This -returns -None -if -and -only -if -bytes -is -empty -. -pub -( -crate -) -fn -utf8_decode -( -bytes -: -& -[ -u8 -] -) -- -> -Option -< -Result -< -char -u8 -> -> -{ -fn -len -( -byte -: -u8 -) -- -> -Option -< -usize -> -{ -if -byte -< -= -0x7F -{ -return -Some -( -1 -) -; -} -else -if -byte -& -0b1100_0000 -= -= -0b1000_0000 -{ -return -None -; -} -else -if -byte -< -= -0b1101_1111 -{ -Some -( -2 -) -} -else -if -byte -< -= -0b1110_1111 -{ -Some -( -3 -) -} -else -if -byte -< -= -0b1111_0111 -{ -Some -( -4 -) -} -else -{ -None -} -} -if -bytes -. -is_empty -( -) -{ -return -None -; -} -let -len -= -match -len -( -bytes -[ -0 -] -) -{ -None -= -> -return -Some -( -Err -( -bytes -[ -0 -] -) -) -Some -( -len -) -if -len -> -bytes -. -len -( -) -= -> -return -Some -( -Err -( -bytes -[ -0 -] -) -) -Some -( -1 -) -= -> -return -Some -( -Ok -( -char -: -: -from -( -bytes -[ -0 -] -) -) -) -Some -( -len -) -= -> -len -} -; -match -core -: -: -str -: -: -from_utf8 -( -& -bytes -[ -. -. -len -] -) -{ -Ok -( -s -) -= -> -Some -( -Ok -( -s -. -chars -( -) -. -next -( -) -. -unwrap -( -) -) -) -Err -( -_ -) -= -> -Some -( -Err -( -bytes -[ -0 -] -) -) -} -} diff --git a/third_party/rust/regex-syntax/src/error.rs b/third_party/rust/regex-syntax/src/error.rs index 8182fbd84c91c..31947a710fb4a 100644 --- a/third_party/rust/regex-syntax/src/error.rs +++ b/third_party/rust/regex-syntax/src/error.rs @@ -1,86 +1,89 @@ use -alloc +std : : -{ -format -string +cmp +; +use +std : : -{ -String -ToString -} -vec -vec +error +; +use +std : : -Vec -} +fmt +; +use +std +: +: +result ; use crate : : -{ ast +; +use +crate +: +: hir -} ; / / / -This -error +A type -encompasses -any -error -that -can -be +alias +for +dealing +with +errors returned by this crate . -/ -/ -/ +pub +type +Result +< +T +> += +result +: +: +Result +< +T +Error +> +; / / / This error type -is -marked -as -non_exhaustive -. -This -means +encompasses +any +error that -adding -a -/ -/ -/ -new -variant -is -not -considered -a -breaking -change +can +be +returned +by +this +crate . # [ -non_exhaustive -] -# -[ derive ( Clone @@ -152,6 +155,68 @@ hir : Error ) +/ +/ +/ +Hints +that +destructuring +should +not +be +exhaustive +. +/ +/ +/ +/ +/ +/ +This +enum +may +grow +additional +variants +so +this +makes +sure +clients +/ +/ +/ +don +' +t +count +on +exhaustive +matching +. +( +Otherwise +adding +a +new +variant +/ +/ +/ +could +break +existing +code +. +) +# +[ +doc +( +hidden +) +] +__Nonexhaustive } impl From @@ -221,33 +286,92 @@ err ) } } +impl +error +: +: +Error +for +Error +{ +/ +/ +TODO +: +Remove +this +method +entirely +on +the +next +breaking +semver +release +. # [ -cfg +allow ( -feature -= -" -std -" +deprecated ) ] -impl -std +fn +description +( +& +self +) +- +> +& +str +{ +match +* +self +{ +Error : : -error +Parse +( +ref +x +) += +> +x +. +description +( +) +Error : : -Error -for -Error -{ +Translate +( +ref +x +) += +> +x +. +description +( +) +_ += +> +unreachable +! +( +) +} +} } impl -core -: -: fmt : : @@ -264,9 +388,6 @@ f : & mut -core -: -: fmt : : @@ -278,9 +399,6 @@ _ ) - > -core -: -: fmt : : @@ -322,6 +440,13 @@ fmt ( f ) +_ += +> +unreachable +! +( +) } } } @@ -660,17 +785,11 @@ impl e E : -core -: -: fmt : : Display > -core -: -: fmt : : @@ -692,9 +811,6 @@ f : & mut -core -: -: fmt : : @@ -706,9 +822,6 @@ _ ) - > -core -: -: fmt : : @@ -1362,9 +1475,6 @@ from_formatter e E : -core -: -: fmt : : @@ -2052,9 +2162,6 @@ in 0 . . -core -: -: cmp : : @@ -2264,7 +2371,9 @@ usize > String { -core +: +: +std : : iter @@ -2295,15 +2404,6 @@ mod tests { use -alloc -: -: -string -: -: -ToString -; -use crate : : diff --git a/third_party/rust/regex-syntax/src/hir/interval.rs b/third_party/rust/regex-syntax/src/hir/interval.rs index e3ccf15784a42..48e88708d01b8 100644 --- a/third_party/rust/regex-syntax/src/hir/interval.rs +++ b/third_party/rust/regex-syntax/src/hir/interval.rs @@ -1,25 +1,35 @@ use -core +std : : -{ char +; +use +std +: +: cmp +; +use +std +: +: fmt : : Debug -slice -} ; use -alloc +std : : -vec +slice +; +use +std : : -Vec +u8 ; use crate @@ -332,6 +342,8 @@ derive ( Clone Debug +Eq +PartialEq ) ] pub @@ -341,363 +353,12 @@ IntervalSet I > { -/ -/ -/ -A -sorted -set -of -non -- -overlapping -ranges -. ranges : Vec < I > -/ -/ -/ -While -not -required -at -all -for -correctness -we -keep -track -of -whether -an -/ -/ -/ -interval -set -has -been -case -folded -or -not -. -This -helps -us -avoid -doing -/ -/ -/ -redundant -work -if -for -example -a -set -has -already -been -cased -folded -. -/ -/ -/ -And -note -that -whether -a -set -is -folded -or -not -is -preserved -through -/ -/ -/ -all -of -the -pairwise -set -operations -. -That -is -if -both -interval -sets -/ -/ -/ -have -been -case -folded -then -any -of -difference -union -intersection -or -/ -/ -/ -symmetric -difference -all -produce -a -case -folded -set -. -/ -/ -/ -/ -/ -/ -Note -that -when -this -is -true -it -* -must -* -be -the -case -that -the -set -is -case -/ -/ -/ -folded -. -But -when -it -' -s -false -the -set -* -may -* -be -case -folded -. -In -other -/ -/ -/ -words -we -only -set -this -to -true -when -we -know -it -to -be -case -but -we -' -re -/ -/ -/ -okay -with -it -being -false -if -it -would -otherwise -be -costly -to -determine -/ -/ -/ -whether -it -should -be -true -. -This -means -code -cannot -assume -that -a -false -/ -/ -/ -value -necessarily -indicates -that -the -set -is -not -case -folded -. -/ -/ -/ -/ -/ -/ -Bottom -line -: -this -is -a -performance -optimization -. -folded -: -bool -} -impl -< -I -: -Interval -> -Eq -for -IntervalSet -< -I -> -{ -} -/ -/ -We -implement -PartialEq -manually -so -that -we -don -' -t -consider -the -set -' -s -internal -/ -/ -' -folded -' -property -to -be -part -of -its -identity -. -The -' -folded -' -property -is -/ -/ -strictly -an -optimization -. -impl -< -I -: -Interval -> -PartialEq -for -IntervalSet -< -I -> -{ -fn -eq -( -& -self -other -: -& -IntervalSet -< -I -> -) -- -> -bool -{ -self -. -ranges -. -eq -( -& -other -. -ranges -) -} } impl < @@ -793,13 +454,13 @@ I > { let +mut +set += +IntervalSet +{ ranges : -Vec -< -I -> -= intervals . into_iter @@ -809,33 +470,6 @@ into_iter collect ( ) -; -/ -/ -An -empty -set -is -case -folded -. -let -folded -= -ranges -. -is_empty -( -) -; -let -mut -set -= -IntervalSet -{ -ranges -folded } ; set @@ -908,51 +542,6 @@ canonicalize ( ) ; -/ -/ -We -don -' -t -know -whether -the -new -interval -added -here -is -considered -/ -/ -case -folded -so -we -conservatively -assume -that -the -entire -set -is -/ -/ -no -longer -case -folded -if -it -was -previously -. -self -. -folded -= -false -; } / / @@ -1155,19 +744,6 @@ unicode CaseFoldError > { -if -self -. -folded -{ -return -Ok -( -( -) -) -; -} let len = @@ -1235,12 +811,6 @@ canonicalize ( ) ; -self -. -folded -= -true -; Ok ( ( @@ -1264,40 +834,18 @@ pub fn union ( -& -mut -self -other -: -& -IntervalSet -< -I -> -) -{ -if -other -. -ranges -. -is_empty -( -) -| -| +& +mut self -. -ranges -= -= other -. -ranges +: +& +IntervalSet +< +I +> +) { -return -; -} / / This @@ -1327,19 +875,6 @@ canonicalize ( ) ; -self -. -folded -= -self -. -folded -& -& -other -. -folded -; } / / @@ -1399,21 +934,6 @@ clear ( ) ; -/ -/ -An -empty -set -is -case -folded -. -self -. -folded -= -true -; return ; } @@ -1658,19 +1178,6 @@ drain drain_end ) ; -self -. -folded -= -self -. -folded -& -& -other -. -folded -; } / / @@ -2541,19 +2048,6 @@ drain drain_end ) ; -self -. -folded -= -self -. -folded -& -& -other -. -folded -; } / / @@ -2818,22 +2312,6 @@ max ) ) ; -/ -/ -The -set -containing -everything -must -case -folded -. -self -. -folded -= -true -; return ; } @@ -3129,177 +2607,6 @@ drain drain_end ) ; -/ -/ -We -don -' -t -need -to -update -whether -this -set -is -folded -or -not -because -/ -/ -it -is -conservatively -preserved -through -negation -. -Namely -if -a -set -/ -/ -is -not -folded -then -it -is -possible -that -its -negation -is -folded -for -/ -/ -example -[ -^ -] -. -But -we -' -re -fine -with -assuming -that -the -set -is -not -/ -/ -folded -in -that -case -. -( -folded -permits -false -negatives -but -not -false -/ -/ -positives -. -) -/ -/ -/ -/ -But -what -about -when -a -set -is -folded -is -its -negation -also -/ -/ -necessarily -folded -? -Yes -. -Because -if -a -set -is -folded -then -for -every -/ -/ -character -in -the -set -it -necessarily -included -its -equivalence -class -/ -/ -of -case -folded -characters -. -Negating -it -in -turn -means -that -all -/ -/ -equivalence -classes -in -the -set -are -negated -and -any -equivalence -/ -/ -class -that -was -previously -not -in -the -set -is -now -entirely -in -the -set -. } / / @@ -4953,13 +4260,9 @@ self > u32 { -u32 -: -: -from -( self -) +as +u32 } fn increment @@ -5045,13 +4348,9 @@ self > u32 { -u32 -: -: -from -( self -) +as +u32 } fn increment @@ -5089,12 +4388,10 @@ char : from_u32 ( -u32 -: -: -from ( c +as +u32 ) . checked_add @@ -5148,12 +4445,10 @@ char : from_u32 ( -u32 -: -: -from ( c +as +u32 ) . checked_sub diff --git a/third_party/rust/regex-syntax/src/hir/literal.rs b/third_party/rust/regex-syntax/src/hir/literal.rs deleted file mode 100644 index 1d0da6169415b..0000000000000 --- a/third_party/rust/regex-syntax/src/hir/literal.rs +++ /dev/null @@ -1,30817 +0,0 @@ -/ -* -! -Provides -literal -extraction -from -Hir -expressions -. -An -[ -Extractor -] -pulls -literals -out -of -[ -Hir -] -expressions -and -returns -a -[ -Seq -] -of -[ -Literal -] -s -. -The -purpose -of -literal -extraction -is -generally -to -provide -avenues -for -optimizing -regex -searches -. -The -main -idea -is -that -substring -searches -can -be -an -order -of -magnitude -faster -than -a -regex -search -. -Therefore -if -one -can -execute -a -substring -search -to -find -candidate -match -locations -and -only -run -the -regex -search -at -those -locations -then -it -is -possible -for -huge -improvements -in -performance -to -be -realized -. -With -that -said -literal -optimizations -are -generally -a -black -art -because -even -though -substring -search -is -generally -faster -if -the -number -of -candidates -produced -is -high -then -it -can -create -a -lot -of -overhead -by -ping -- -ponging -between -the -substring -search -and -the -regex -search -. -Here -are -some -heuristics -that -might -be -used -to -help -increase -the -chances -of -effective -literal -optimizations -: -* -Stick -to -small -[ -Seq -] -s -. -If -you -search -for -too -many -literals -it -' -s -likely -to -lead -to -substring -search -that -is -only -a -little -faster -than -a -regex -search -and -thus -the -overhead -of -using -literal -optimizations -in -the -first -place -might -make -things -slower -overall -. -* -The -literals -in -your -[ -Seq -] -shouldn -' -t -be -too -short -. -In -general -longer -is -better -. -A -sequence -corresponding -to -single -bytes -that -occur -frequently -in -the -haystack -for -example -is -probably -a -bad -literal -optimization -because -it -' -s -likely -to -produce -many -false -positive -candidates -. -Longer -literals -are -less -likely -to -match -and -thus -probably -produce -fewer -false -positives -. -* -If -it -' -s -possible -to -estimate -the -approximate -frequency -of -each -byte -according -to -some -pre -- -computed -background -distribution -it -is -possible -to -compute -a -score -of -how -" -good -" -a -Seq -is -. -If -a -Seq -isn -' -t -good -enough -you -might -consider -skipping -the -literal -optimization -and -just -use -the -regex -engine -. -( -It -should -be -noted -that -there -are -always -pathological -cases -that -can -make -any -kind -of -literal -optimization -be -a -net -slower -result -. -This -is -why -it -might -be -a -good -idea -to -be -conservative -or -to -even -provide -a -means -for -literal -optimizations -to -be -dynamically -disabled -if -they -are -determined -to -be -ineffective -according -to -some -measure -. -) -You -' -re -encouraged -to -explore -the -methods -on -[ -Seq -] -which -permit -shrinking -the -size -of -sequences -in -a -preference -- -order -preserving -fashion -. -Finally -note -that -it -isn -' -t -strictly -necessary -to -use -an -[ -Extractor -] -. -Namely -an -Extractor -only -uses -public -APIs -of -the -[ -Seq -] -and -[ -Literal -] -types -so -it -is -possible -to -implement -your -own -extractor -. -For -example -for -n -- -grams -or -" -inner -" -literals -( -i -. -e -. -not -prefix -or -suffix -literals -) -. -The -Extractor -is -mostly -responsible -for -the -case -analysis -over -Hir -expressions -. -Much -of -the -" -trickier -" -parts -are -how -to -combine -literal -sequences -and -that -is -all -implemented -on -[ -Seq -] -. -* -/ -use -core -: -: -{ -cmp -mem -num -: -: -NonZeroUsize -} -; -use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use -crate -: -: -hir -: -: -{ -self -Hir -} -; -/ -/ -/ -Extracts -prefix -or -suffix -literal -sequences -from -[ -Hir -] -expressions -. -/ -/ -/ -/ -/ -/ -Literal -extraction -is -based -on -the -following -observations -: -/ -/ -/ -/ -/ -/ -* -Many -regexes -start -with -one -or -a -small -number -of -literals -. -/ -/ -/ -* -Substring -search -for -literals -is -often -much -faster -( -sometimes -by -an -order -/ -/ -/ -of -magnitude -) -than -a -regex -search -. -/ -/ -/ -/ -/ -/ -Thus -in -many -cases -one -can -search -for -literals -to -find -candidate -starting -/ -/ -/ -locations -of -a -match -and -then -only -run -the -full -regex -engine -at -each -such -/ -/ -/ -location -instead -of -over -the -full -haystack -. -/ -/ -/ -/ -/ -/ -The -main -downside -of -literal -extraction -is -that -it -can -wind -up -causing -a -/ -/ -/ -search -to -be -slower -overall -. -For -example -if -there -are -many -matches -or -if -/ -/ -/ -there -are -many -candidates -that -don -' -t -ultimately -lead -to -a -match -then -a -/ -/ -/ -lot -of -overhead -will -be -spent -in -shuffing -back -- -and -- -forth -between -substring -/ -/ -/ -search -and -the -regex -engine -. -This -is -the -fundamental -reason -why -literal -/ -/ -/ -optimizations -for -regex -patterns -is -sometimes -considered -a -" -black -art -. -" -/ -/ -/ -/ -/ -/ -# -Look -- -around -assertions -/ -/ -/ -/ -/ -/ -Literal -extraction -treats -all -look -- -around -assertions -as -- -if -they -match -every -/ -/ -/ -empty -string -. -So -for -example -the -regex -\ -bquux -\ -b -will -yield -a -sequence -/ -/ -/ -containing -a -single -exact -literal -quux -. -However -not -all -occurrences -/ -/ -/ -of -quux -correspond -to -a -match -a -of -the -regex -. -For -example -\ -bquux -\ -b -/ -/ -/ -does -not -match -ZquuxZ -anywhere -because -quux -does -not -fall -on -a -word -/ -/ -/ -boundary -. -/ -/ -/ -/ -/ -/ -In -effect -if -your -regex -contains -look -- -around -assertions -then -a -match -of -/ -/ -/ -an -exact -literal -does -not -necessarily -mean -the -regex -overall -matches -. -So -/ -/ -/ -you -may -still -need -to -run -the -regex -engine -in -such -cases -to -confirm -the -/ -/ -/ -match -. -/ -/ -/ -/ -/ -/ -The -precise -guarantee -you -get -from -a -literal -sequence -is -: -if -every -literal -/ -/ -/ -in -the -sequence -is -exact -and -the -original -regex -contains -zero -look -- -around -/ -/ -/ -assertions -then -a -preference -- -order -multi -- -substring -search -of -those -/ -/ -/ -literals -will -precisely -match -a -preference -- -order -search -of -the -original -/ -/ -/ -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -extract -prefixes -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -hir -: -: -literal -: -: -{ -Extractor -Literal -Seq -} -parse -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -parse -( -r -" -( -a -| -b -| -c -) -( -x -| -y -| -z -) -[ -A -- -Z -] -+ -foo -" -) -? -; -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -extract -( -& -hir -) -; -/ -/ -/ -/ -/ -All -literals -returned -are -" -inexact -" -because -none -of -them -reach -the -/ -/ -/ -/ -/ -match -state -. -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -ax -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -ay -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -az -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bx -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -by -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bz -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -cx -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -cy -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -cz -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -shows -how -to -extract -suffixes -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -/ -/ -/ -hir -: -: -literal -: -: -{ -Extractor -ExtractKind -Literal -Seq -} -/ -/ -/ -parse -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -parse -( -r -" -foo -| -[ -A -- -Z -] -+ -bar -" -) -? -; -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -kind -( -ExtractKind -: -: -Suffix -) -. -extract -( -& -hir -) -; -/ -/ -/ -/ -/ -Since -' -foo -' -gets -to -a -match -state -it -is -considered -exact -. -But -' -bar -' -/ -/ -/ -/ -/ -does -not -because -of -the -' -[ -A -- -Z -] -+ -' -and -thus -is -marked -inexact -. -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -Extractor -{ -kind -: -ExtractKind -limit_class -: -usize -limit_repeat -: -usize -limit_literal_len -: -usize -limit_total -: -usize -} -impl -Extractor -{ -/ -/ -/ -Create -a -new -extractor -with -a -default -configuration -. -/ -/ -/ -/ -/ -/ -The -extractor -can -be -optionally -configured -before -calling -/ -/ -/ -[ -Extractor -: -: -extract -] -to -get -a -literal -sequence -. -pub -fn -new -( -) -- -> -Extractor -{ -Extractor -{ -kind -: -ExtractKind -: -: -Prefix -limit_class -: -10 -limit_repeat -: -10 -limit_literal_len -: -100 -limit_total -: -250 -} -} -/ -/ -/ -Execute -the -extractor -and -return -a -sequence -of -literals -. -pub -fn -extract -( -& -self -hir -: -& -Hir -) -- -> -Seq -{ -use -crate -: -: -hir -: -: -HirKind -: -: -* -; -match -* -hir -. -kind -( -) -{ -Empty -| -Look -( -_ -) -= -> -Seq -: -: -singleton -( -self -: -: -Literal -: -: -exact -( -vec -! -[ -] -) -) -Literal -( -hir -: -: -Literal -( -ref -bytes -) -) -= -> -{ -let -mut -seq -= -Seq -: -: -singleton -( -self -: -: -Literal -: -: -exact -( -bytes -. -to_vec -( -) -) -) -; -self -. -enforce_literal_len -( -& -mut -seq -) -; -seq -} -Class -( -hir -: -: -Class -: -: -Unicode -( -ref -cls -) -) -= -> -{ -self -. -extract_class_unicode -( -cls -) -} -Class -( -hir -: -: -Class -: -: -Bytes -( -ref -cls -) -) -= -> -self -. -extract_class_bytes -( -cls -) -Repetition -( -ref -rep -) -= -> -self -. -extract_repetition -( -rep -) -Capture -( -hir -: -: -Capture -{ -ref -sub -. -. -} -) -= -> -self -. -extract -( -sub -) -Concat -( -ref -hirs -) -= -> -match -self -. -kind -{ -ExtractKind -: -: -Prefix -= -> -self -. -extract_concat -( -hirs -. -iter -( -) -) -ExtractKind -: -: -Suffix -= -> -self -. -extract_concat -( -hirs -. -iter -( -) -. -rev -( -) -) -} -Alternation -( -ref -hirs -) -= -> -{ -/ -/ -Unlike -concat -we -always -union -starting -from -the -beginning -/ -/ -since -the -beginning -corresponds -to -the -highest -preference -/ -/ -which -doesn -' -t -change -based -on -forwards -vs -reverse -. -self -. -extract_alternation -( -hirs -. -iter -( -) -) -} -} -} -/ -/ -/ -Set -the -kind -of -literal -sequence -to -extract -from -an -[ -Hir -] -expression -. -/ -/ -/ -/ -/ -/ -The -default -is -to -extract -prefixes -but -suffixes -can -be -selected -/ -/ -/ -instead -. -The -contract -for -prefixes -is -that -every -match -of -the -/ -/ -/ -corresponding -Hir -must -start -with -one -of -the -literals -in -the -sequence -/ -/ -/ -returned -. -Moreover -the -_order_ -of -the -sequence -returned -corresponds -to -/ -/ -/ -the -preference -order -. -/ -/ -/ -/ -/ -/ -Suffixes -satisfy -a -similar -contract -in -that -every -match -of -the -/ -/ -/ -corresponding -Hir -must -end -with -one -of -the -literals -in -the -sequence -/ -/ -/ -returned -. -However -there -is -no -guarantee -that -the -literals -are -in -/ -/ -/ -preference -order -. -/ -/ -/ -/ -/ -/ -Remember -that -a -sequence -can -be -infinite -. -For -example -unless -the -/ -/ -/ -limits -are -configured -to -be -impractically -large -attempting -to -extract -/ -/ -/ -prefixes -( -or -suffixes -) -for -the -pattern -[ -A -- -Z -] -will -return -an -infinite -/ -/ -/ -sequence -. -Generally -speaking -if -the -sequence -returned -is -infinite -/ -/ -/ -then -it -is -presumed -to -be -unwise -to -do -prefix -( -or -suffix -) -optimizations -/ -/ -/ -for -the -pattern -. -pub -fn -kind -( -& -mut -self -kind -: -ExtractKind -) -- -> -& -mut -Extractor -{ -self -. -kind -= -kind -; -self -} -/ -/ -/ -Configure -a -limit -on -the -length -of -the -sequence -that -is -permitted -for -/ -/ -/ -a -character -class -. -If -a -character -class -exceeds -this -limit -then -the -/ -/ -/ -sequence -returned -for -it -is -infinite -. -/ -/ -/ -/ -/ -/ -This -prevents -classes -like -[ -A -- -Z -] -or -\ -pL -from -getting -turned -into -/ -/ -/ -huge -and -likely -unproductive -sequences -of -literals -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -this -limit -can -be -lowered -to -decrease -the -tolerance -/ -/ -/ -for -character -classes -being -turned -into -literal -sequences -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -hir -: -: -literal -: -: -{ -Extractor -Seq -} -parse -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -parse -( -r -" -[ -0 -- -9 -] -" -) -? -; -/ -/ -/ -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -extract -( -& -hir -) -; -/ -/ -/ -let -expected -= -Seq -: -: -new -( -[ -/ -/ -/ -" -0 -" -" -1 -" -" -2 -" -" -3 -" -" -4 -" -" -5 -" -" -6 -" -" -7 -" -" -8 -" -" -9 -" -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -let -' -s -shrink -the -limit -and -see -how -that -changes -things -. -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -limit_class -( -4 -) -. -extract -( -& -hir -) -; -/ -/ -/ -let -expected -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -limit_class -( -& -mut -self -limit -: -usize -) -- -> -& -mut -Extractor -{ -self -. -limit_class -= -limit -; -self -} -/ -/ -/ -Configure -a -limit -on -the -total -number -of -repetitions -that -is -permitted -/ -/ -/ -before -literal -extraction -is -stopped -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -limiting -things -like -( -abcde -) -{ -50 -} -or -more -/ -/ -/ -insidiously -( -? -: -) -{ -1000000000 -} -. -This -limit -prevents -any -one -single -/ -/ -/ -repetition -from -adding -too -much -to -a -literal -sequence -. -/ -/ -/ -/ -/ -/ -With -this -limit -set -repetitions -that -exceed -it -will -be -stopped -and -any -/ -/ -/ -literals -extracted -up -to -that -point -will -be -made -inexact -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -decrease -the -limit -and -compares -it -with -the -default -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -hir -: -: -literal -: -: -{ -Extractor -Literal -Seq -} -parse -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -parse -( -r -" -( -abc -) -{ -8 -} -" -) -? -; -/ -/ -/ -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -extract -( -& -hir -) -; -/ -/ -/ -let -expected -= -Seq -: -: -new -( -[ -" -abcabcabcabcabcabcabcabc -" -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -let -' -s -shrink -the -limit -and -see -how -that -changes -things -. -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -limit_repeat -( -4 -) -. -extract -( -& -hir -) -; -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -abcabcabcabc -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -limit_repeat -( -& -mut -self -limit -: -usize -) -- -> -& -mut -Extractor -{ -self -. -limit_repeat -= -limit -; -self -} -/ -/ -/ -Configure -a -limit -on -the -maximum -length -of -any -literal -in -a -sequence -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -limiting -things -like -( -abcde -) -{ -5 -} -{ -5 -} -{ -5 -} -{ -5 -} -. -While -/ -/ -/ -each -repetition -or -literal -in -that -regex -is -small -when -all -the -/ -/ -/ -repetitions -are -applied -one -ends -up -with -a -literal -of -length -5 -^ -4 -= -/ -/ -/ -625 -. -/ -/ -/ -/ -/ -/ -With -this -limit -set -literals -that -exceed -it -will -be -made -inexact -and -/ -/ -/ -thus -prevented -from -growing -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -decrease -the -limit -and -compares -it -with -the -default -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -hir -: -: -literal -: -: -{ -Extractor -Literal -Seq -} -parse -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -parse -( -r -" -( -abc -) -{ -2 -} -{ -2 -} -{ -2 -} -" -) -? -; -/ -/ -/ -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -extract -( -& -hir -) -; -/ -/ -/ -let -expected -= -Seq -: -: -new -( -[ -" -abcabcabcabcabcabcabcabc -" -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -let -' -s -shrink -the -limit -and -see -how -that -changes -things -. -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -limit_literal_len -( -14 -) -. -extract -( -& -hir -) -; -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -abcabcabcabcab -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -limit_literal_len -( -& -mut -self -limit -: -usize -) -- -> -& -mut -Extractor -{ -self -. -limit_literal_len -= -limit -; -self -} -/ -/ -/ -Configure -a -limit -on -the -total -number -of -literals -that -will -be -/ -/ -/ -returned -. -/ -/ -/ -/ -/ -/ -This -is -useful -as -a -practical -measure -for -avoiding -the -creation -of -/ -/ -/ -large -sequences -of -literals -. -While -the -extractor -will -automatically -/ -/ -/ -handle -local -creations -of -large -sequences -( -for -example -[ -A -- -Z -] -yields -/ -/ -/ -an -infinite -sequence -by -default -) -large -sequences -can -be -created -/ -/ -/ -through -non -- -local -means -as -well -. -/ -/ -/ -/ -/ -/ -For -example -[ -ab -] -{ -3 -} -{ -3 -} -would -yield -a -sequence -of -length -512 -= -2 -^ -9 -/ -/ -/ -despite -each -of -the -repetitions -being -small -on -their -own -. -This -limit -/ -/ -/ -thus -represents -a -" -catch -all -" -for -avoiding -locally -small -sequences -from -/ -/ -/ -combining -into -large -sequences -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -reducing -the -limit -will -change -the -literal -/ -/ -/ -sequence -returned -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -hir -: -: -literal -: -: -{ -Extractor -Literal -Seq -} -parse -} -; -/ -/ -/ -/ -/ -/ -let -hir -= -parse -( -r -" -[ -ab -] -{ -2 -} -{ -2 -} -" -) -? -; -/ -/ -/ -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -extract -( -& -hir -) -; -/ -/ -/ -let -expected -= -Seq -: -: -new -( -[ -/ -/ -/ -" -aaaa -" -" -aaab -" -" -aaba -" -" -aabb -" -/ -/ -/ -" -abaa -" -" -abab -" -" -abba -" -" -abbb -" -/ -/ -/ -" -baaa -" -" -baab -" -" -baba -" -" -babb -" -/ -/ -/ -" -bbaa -" -" -bbab -" -" -bbba -" -" -bbbb -" -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -default -limit -is -not -too -big -but -big -enough -to -extract -all -/ -/ -/ -/ -/ -literals -from -' -[ -ab -] -{ -2 -} -{ -2 -} -' -. -If -we -shrink -the -limit -to -less -than -16 -/ -/ -/ -/ -/ -then -we -' -ll -get -a -truncated -set -. -Notice -that -it -returns -a -sequence -of -/ -/ -/ -/ -/ -length -4 -even -though -our -limit -was -10 -. -This -is -because -the -sequence -/ -/ -/ -/ -/ -is -difficult -to -increase -without -blowing -the -limit -. -Notice -also -/ -/ -/ -/ -/ -that -every -literal -in -the -sequence -is -now -inexact -because -they -were -/ -/ -/ -/ -/ -stripped -of -some -suffix -. -/ -/ -/ -let -got -= -Extractor -: -: -new -( -) -. -limit_total -( -10 -) -. -extract -( -& -hir -) -; -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -aa -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -ab -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -ba -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bb -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -got -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -limit_total -( -& -mut -self -limit -: -usize -) -- -> -& -mut -Extractor -{ -self -. -limit_total -= -limit -; -self -} -/ -/ -/ -Extract -a -sequence -from -the -given -concatenation -. -Sequences -from -each -of -/ -/ -/ -the -child -HIR -expressions -are -combined -via -cross -product -. -/ -/ -/ -/ -/ -/ -This -short -circuits -once -the -cross -product -turns -into -a -sequence -/ -/ -/ -containing -only -inexact -literals -. -fn -extract_concat -< -' -a -I -: -Iterator -< -Item -= -& -' -a -Hir -> -> -( -& -self -it -: -I -) -- -> -Seq -{ -let -mut -seq -= -Seq -: -: -singleton -( -self -: -: -Literal -: -: -exact -( -vec -! -[ -] -) -) -; -for -hir -in -it -{ -/ -/ -If -every -element -in -the -sequence -is -inexact -then -a -cross -/ -/ -product -will -always -be -a -no -- -op -. -Thus -there -is -nothing -else -we -/ -/ -can -add -to -it -and -can -quit -early -. -Note -that -this -also -includes -/ -/ -infinite -sequences -. -if -seq -. -is_inexact -( -) -{ -break -; -} -/ -/ -Note -that -' -cross -' -also -dispatches -based -on -whether -we -' -re -/ -/ -extracting -prefixes -or -suffixes -. -seq -= -self -. -cross -( -seq -& -mut -self -. -extract -( -hir -) -) -; -} -seq -} -/ -/ -/ -Extract -a -sequence -from -the -given -alternation -. -/ -/ -/ -/ -/ -/ -This -short -circuits -once -the -union -turns -into -an -infinite -sequence -. -fn -extract_alternation -< -' -a -I -: -Iterator -< -Item -= -& -' -a -Hir -> -> -( -& -self -it -: -I -) -- -> -Seq -{ -let -mut -seq -= -Seq -: -: -empty -( -) -; -for -hir -in -it -{ -/ -/ -Once -our -' -seq -' -is -infinite -every -subsequent -union -/ -/ -operation -on -it -will -itself -always -result -in -an -/ -/ -infinite -sequence -. -Thus -it -can -never -change -and -we -can -/ -/ -short -- -circuit -. -if -! -seq -. -is_finite -( -) -{ -break -; -} -seq -= -self -. -union -( -seq -& -mut -self -. -extract -( -hir -) -) -; -} -seq -} -/ -/ -/ -Extract -a -sequence -of -literals -from -the -given -repetition -. -We -do -our -/ -/ -/ -best -Some -examples -: -/ -/ -/ -/ -/ -/ -' -a -* -' -= -> -[ -inexact -( -a -) -exact -( -" -" -) -] -/ -/ -/ -' -a -* -? -' -= -> -[ -exact -( -" -" -) -inexact -( -a -) -] -/ -/ -/ -' -a -+ -' -= -> -[ -inexact -( -a -) -] -/ -/ -/ -' -a -{ -3 -} -' -= -> -[ -exact -( -aaa -) -] -/ -/ -/ -' -a -{ -3 -5 -} -= -> -[ -inexact -( -aaa -) -] -/ -/ -/ -/ -/ -/ -The -key -here -really -is -making -sure -we -get -the -' -inexact -' -vs -' -exact -' -/ -/ -/ -attributes -correct -on -each -of -the -literals -we -add -. -For -example -the -/ -/ -/ -fact -that -' -a -* -' -gives -us -an -inexact -' -a -' -and -an -exact -empty -string -means -/ -/ -/ -that -a -regex -like -' -ab -* -c -' -will -result -in -[ -inexact -( -ab -) -exact -( -ac -) -] -/ -/ -/ -literals -being -extracted -which -might -actually -be -a -better -prefilter -/ -/ -/ -than -just -' -a -' -. -fn -extract_repetition -( -& -self -rep -: -& -hir -: -: -Repetition -) -- -> -Seq -{ -let -mut -subseq -= -self -. -extract -( -& -rep -. -sub -) -; -match -* -rep -{ -hir -: -: -Repetition -{ -min -: -0 -max -greedy -. -. -} -= -> -{ -/ -/ -When -' -max -= -1 -' -we -can -retain -exactness -since -' -a -? -' -is -/ -/ -equivalent -to -' -a -| -' -. -Similarly -below -' -a -? -? -' -is -equivalent -to -/ -/ -' -| -a -' -. -if -max -! -= -Some -( -1 -) -{ -subseq -. -make_inexact -( -) -; -} -let -mut -empty -= -Seq -: -: -singleton -( -Literal -: -: -exact -( -vec -! -[ -] -) -) -; -if -! -greedy -{ -mem -: -: -swap -( -& -mut -subseq -& -mut -empty -) -; -} -self -. -union -( -subseq -& -mut -empty -) -} -hir -: -: -Repetition -{ -min -max -: -Some -( -max -) -. -. -} -if -min -= -= -max -= -> -{ -assert -! -( -min -> -0 -) -; -/ -/ -handled -above -let -limit -= -u32 -: -: -try_from -( -self -. -limit_repeat -) -. -unwrap_or -( -u32 -: -: -MAX -) -; -let -mut -seq -= -Seq -: -: -singleton -( -Literal -: -: -exact -( -vec -! -[ -] -) -) -; -for -_ -in -0 -. -. -cmp -: -: -min -( -min -limit -) -{ -if -seq -. -is_inexact -( -) -{ -break -; -} -seq -= -self -. -cross -( -seq -& -mut -subseq -. -clone -( -) -) -; -} -if -usize -: -: -try_from -( -min -) -. -is_err -( -) -| -| -min -> -limit -{ -seq -. -make_inexact -( -) -; -} -seq -} -hir -: -: -Repetition -{ -min -. -. -} -= -> -{ -assert -! -( -min -> -0 -) -; -/ -/ -handled -above -let -limit -= -u32 -: -: -try_from -( -self -. -limit_repeat -) -. -unwrap_or -( -u32 -: -: -MAX -) -; -let -mut -seq -= -Seq -: -: -singleton -( -Literal -: -: -exact -( -vec -! -[ -] -) -) -; -for -_ -in -0 -. -. -cmp -: -: -min -( -min -limit -) -{ -if -seq -. -is_inexact -( -) -{ -break -; -} -seq -= -self -. -cross -( -seq -& -mut -subseq -. -clone -( -) -) -; -} -seq -. -make_inexact -( -) -; -seq -} -} -} -/ -/ -/ -Convert -the -given -Unicode -class -into -a -sequence -of -literals -if -the -/ -/ -/ -class -is -small -enough -. -If -the -class -is -too -big -return -an -infinite -/ -/ -/ -sequence -. -fn -extract_class_unicode -( -& -self -cls -: -& -hir -: -: -ClassUnicode -) -- -> -Seq -{ -if -self -. -class_over_limit_unicode -( -cls -) -{ -return -Seq -: -: -infinite -( -) -; -} -let -mut -seq -= -Seq -: -: -empty -( -) -; -for -r -in -cls -. -iter -( -) -{ -for -ch -in -r -. -start -( -) -. -. -= -r -. -end -( -) -{ -seq -. -push -( -Literal -: -: -from -( -ch -) -) -; -} -} -self -. -enforce_literal_len -( -& -mut -seq -) -; -seq -} -/ -/ -/ -Convert -the -given -byte -class -into -a -sequence -of -literals -if -the -class -/ -/ -/ -is -small -enough -. -If -the -class -is -too -big -return -an -infinite -sequence -. -fn -extract_class_bytes -( -& -self -cls -: -& -hir -: -: -ClassBytes -) -- -> -Seq -{ -if -self -. -class_over_limit_bytes -( -cls -) -{ -return -Seq -: -: -infinite -( -) -; -} -let -mut -seq -= -Seq -: -: -empty -( -) -; -for -r -in -cls -. -iter -( -) -{ -for -b -in -r -. -start -( -) -. -. -= -r -. -end -( -) -{ -seq -. -push -( -Literal -: -: -from -( -b -) -) -; -} -} -self -. -enforce_literal_len -( -& -mut -seq -) -; -seq -} -/ -/ -/ -Returns -true -if -the -given -Unicode -class -exceeds -the -configured -limits -/ -/ -/ -on -this -extractor -. -fn -class_over_limit_unicode -( -& -self -cls -: -& -hir -: -: -ClassUnicode -) -- -> -bool -{ -let -mut -count -= -0 -; -for -r -in -cls -. -iter -( -) -{ -if -count -> -self -. -limit_class -{ -return -true -; -} -count -+ -= -r -. -len -( -) -; -} -count -> -self -. -limit_class -} -/ -/ -/ -Returns -true -if -the -given -byte -class -exceeds -the -configured -limits -on -/ -/ -/ -this -extractor -. -fn -class_over_limit_bytes -( -& -self -cls -: -& -hir -: -: -ClassBytes -) -- -> -bool -{ -let -mut -count -= -0 -; -for -r -in -cls -. -iter -( -) -{ -if -count -> -self -. -limit_class -{ -return -true -; -} -count -+ -= -r -. -len -( -) -; -} -count -> -self -. -limit_class -} -/ -/ -/ -Compute -the -cross -product -of -the -two -sequences -if -the -result -would -be -/ -/ -/ -within -configured -limits -. -Otherwise -make -seq2 -infinite -and -cross -the -/ -/ -/ -infinite -sequence -with -seq1 -. -fn -cross -( -& -self -mut -seq1 -: -Seq -seq2 -: -& -mut -Seq -) -- -> -Seq -{ -if -seq1 -. -max_cross_len -( -seq2 -) -. -map_or -( -false -| -len -| -len -> -self -. -limit_total -) -{ -seq2 -. -make_infinite -( -) -; -} -if -let -ExtractKind -: -: -Suffix -= -self -. -kind -{ -seq1 -. -cross_reverse -( -seq2 -) -; -} -else -{ -seq1 -. -cross_forward -( -seq2 -) -; -} -assert -! -( -seq1 -. -len -( -) -. -map_or -( -true -| -x -| -x -< -= -self -. -limit_total -) -) -; -self -. -enforce_literal_len -( -& -mut -seq1 -) -; -seq1 -} -/ -/ -/ -Union -the -two -sequences -if -the -result -would -be -within -configured -/ -/ -/ -limits -. -Otherwise -make -seq2 -infinite -and -union -the -infinite -sequence -/ -/ -/ -with -seq1 -. -fn -union -( -& -self -mut -seq1 -: -Seq -seq2 -: -& -mut -Seq -) -- -> -Seq -{ -if -seq1 -. -max_union_len -( -seq2 -) -. -map_or -( -false -| -len -| -len -> -self -. -limit_total -) -{ -/ -/ -We -try -to -trim -our -literal -sequences -to -see -if -we -can -make -/ -/ -room -for -more -literals -. -The -idea -is -that -we -' -d -rather -trim -down -/ -/ -literals -already -in -our -sequence -if -it -means -we -can -add -a -few -/ -/ -more -and -retain -a -finite -sequence -. -Otherwise -we -' -ll -union -with -/ -/ -an -infinite -sequence -and -that -infects -everything -and -effectively -/ -/ -stops -literal -extraction -in -its -tracks -. -/ -/ -/ -/ -We -do -we -keep -4 -bytes -here -? -Well -it -' -s -a -bit -of -an -abstraction -/ -/ -leakage -. -Downstream -the -literals -may -wind -up -getting -fed -to -/ -/ -the -Teddy -algorithm -which -supports -searching -literals -up -to -/ -/ -length -4 -. -So -that -' -s -why -we -pick -that -number -here -. -Arguably -this -/ -/ -should -be -a -tuneable -parameter -but -it -seems -a -little -tricky -to -/ -/ -describe -. -And -I -' -m -still -unsure -if -this -is -the -right -way -to -go -/ -/ -about -culling -literal -sequences -. -match -self -. -kind -{ -ExtractKind -: -: -Prefix -= -> -{ -seq1 -. -keep_first_bytes -( -4 -) -; -seq2 -. -keep_first_bytes -( -4 -) -; -} -ExtractKind -: -: -Suffix -= -> -{ -seq1 -. -keep_last_bytes -( -4 -) -; -seq2 -. -keep_last_bytes -( -4 -) -; -} -} -seq1 -. -dedup -( -) -; -seq2 -. -dedup -( -) -; -if -seq1 -. -max_union_len -( -seq2 -) -. -map_or -( -false -| -len -| -len -> -self -. -limit_total -) -{ -seq2 -. -make_infinite -( -) -; -} -} -seq1 -. -union -( -seq2 -) -; -assert -! -( -seq1 -. -len -( -) -. -map_or -( -true -| -x -| -x -< -= -self -. -limit_total -) -) -; -seq1 -} -/ -/ -/ -Applies -the -literal -length -limit -to -the -given -sequence -. -If -none -of -the -/ -/ -/ -literals -in -the -sequence -exceed -the -limit -then -this -is -a -no -- -op -. -fn -enforce_literal_len -( -& -self -seq -: -& -mut -Seq -) -{ -let -len -= -self -. -limit_literal_len -; -match -self -. -kind -{ -ExtractKind -: -: -Prefix -= -> -seq -. -keep_first_bytes -( -len -) -ExtractKind -: -: -Suffix -= -> -seq -. -keep_last_bytes -( -len -) -} -} -} -impl -Default -for -Extractor -{ -fn -default -( -) -- -> -Extractor -{ -Extractor -: -: -new -( -) -} -} -/ -/ -/ -The -kind -of -literals -to -extract -from -an -[ -Hir -] -expression -. -/ -/ -/ -/ -/ -/ -The -default -extraction -kind -is -Prefix -. -# -[ -non_exhaustive -] -# -[ -derive -( -Clone -Debug -) -] -pub -enum -ExtractKind -{ -/ -/ -/ -Extracts -only -prefix -literals -from -a -regex -. -Prefix -/ -/ -/ -Extracts -only -suffix -literals -from -a -regex -. -/ -/ -/ -/ -/ -/ -Note -that -the -sequence -returned -by -suffix -literals -currently -may -/ -/ -/ -not -correctly -represent -leftmost -- -first -or -" -preference -" -order -match -/ -/ -/ -semantics -. -Suffix -} -impl -ExtractKind -{ -/ -/ -/ -Returns -true -if -this -kind -is -the -Prefix -variant -. -pub -fn -is_prefix -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -ExtractKind -: -: -Prefix -) -} -/ -/ -/ -Returns -true -if -this -kind -is -the -Suffix -variant -. -pub -fn -is_suffix -( -& -self -) -- -> -bool -{ -matches -! -( -* -self -ExtractKind -: -: -Suffix -) -} -} -impl -Default -for -ExtractKind -{ -fn -default -( -) -- -> -ExtractKind -{ -ExtractKind -: -: -Prefix -} -} -/ -/ -/ -A -sequence -of -literals -. -/ -/ -/ -/ -/ -/ -A -Seq -is -very -much -like -a -set -in -that -it -represents -a -union -of -its -/ -/ -/ -members -. -That -is -it -corresponds -to -a -set -of -literals -where -at -least -one -/ -/ -/ -must -match -in -order -for -a -particular -[ -Hir -] -expression -to -match -. -( -Whether -/ -/ -/ -this -corresponds -to -the -entire -Hir -expression -a -prefix -of -it -or -a -suffix -/ -/ -/ -of -it -depends -on -how -the -Seq -was -extracted -from -the -Hir -. -) -/ -/ -/ -/ -/ -/ -It -is -also -unlike -a -set -in -that -multiple -identical -literals -may -appear -/ -/ -/ -and -that -the -order -of -the -literals -in -the -Seq -matters -. -For -example -if -/ -/ -/ -the -sequence -is -[ -sam -samwise -] -and -leftmost -- -first -matching -is -used -then -/ -/ -/ -samwise -can -never -match -and -the -sequence -is -equivalent -to -[ -sam -] -. -/ -/ -/ -/ -/ -/ -# -States -of -a -sequence -/ -/ -/ -/ -/ -/ -A -Seq -has -a -few -different -logical -states -to -consider -: -/ -/ -/ -/ -/ -/ -* -The -sequence -can -represent -" -any -" -literal -. -When -this -happens -the -set -does -/ -/ -/ -not -have -a -finite -size -. -The -purpose -of -this -state -is -to -inhibit -callers -/ -/ -/ -from -making -assumptions -about -what -literals -are -required -in -order -to -match -/ -/ -/ -a -particular -[ -Hir -] -expression -. -Generally -speaking -when -a -set -is -in -this -/ -/ -/ -state -literal -optimizations -are -inhibited -. -A -good -example -of -a -regex -that -/ -/ -/ -will -cause -this -sort -of -set -to -appear -is -[ -A -- -Za -- -z -] -. -The -character -class -/ -/ -/ -is -just -too -big -( -and -also -too -narrow -) -to -be -usefully -expanded -into -52 -/ -/ -/ -different -literals -. -( -Note -that -the -decision -for -when -a -seq -should -become -/ -/ -/ -infinite -is -determined -by -the -caller -. -A -seq -itself -has -no -hard -- -coded -/ -/ -/ -limits -. -) -/ -/ -/ -* -The -sequence -can -be -empty -in -which -case -it -is -an -affirmative -statement -/ -/ -/ -that -there -are -no -literals -that -can -match -the -corresponding -Hir -. -/ -/ -/ -Consequently -the -Hir -never -matches -any -input -. -For -example -[ -a -& -& -b -] -. -/ -/ -/ -* -The -sequence -can -be -non -- -empty -in -which -case -at -least -one -of -the -/ -/ -/ -literals -must -match -in -order -for -the -corresponding -Hir -to -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -literal -sequences -can -be -simplified -by -stripping -/ -/ -/ -suffixes -and -minimizing -while -maintaining -preference -order -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -/ -/ -/ -" -farm -" -/ -/ -/ -" -appliance -" -/ -/ -/ -" -faraway -" -/ -/ -/ -" -apple -" -/ -/ -/ -" -fare -" -/ -/ -/ -" -gap -" -/ -/ -/ -" -applicant -" -/ -/ -/ -" -applaud -" -/ -/ -/ -] -) -; -/ -/ -/ -seq -. -keep_first_bytes -( -3 -) -; -/ -/ -/ -seq -. -minimize_by_preference -( -) -; -/ -/ -/ -/ -/ -Notice -that -' -far -' -comes -before -' -app -' -which -matches -the -order -in -the -/ -/ -/ -/ -/ -original -sequence -. -This -guarantees -that -leftmost -- -first -semantics -are -/ -/ -/ -/ -/ -not -altered -by -simplifying -the -set -. -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -far -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -app -" -) -/ -/ -/ -Literal -: -: -exact -( -" -gap -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -seq -) -; -/ -/ -/ -# -[ -derive -( -Clone -Eq -PartialEq -) -] -pub -struct -Seq -{ -/ -/ -/ -The -members -of -this -seq -. -/ -/ -/ -/ -/ -/ -When -None -the -seq -represents -all -possible -literals -. -That -is -it -/ -/ -/ -prevents -one -from -making -assumptions -about -specific -literals -in -the -/ -/ -/ -seq -and -forces -one -to -treat -it -as -if -any -literal -might -be -in -the -seq -. -/ -/ -/ -/ -/ -/ -Note -that -Some -( -vec -! -[ -] -) -is -valid -and -corresponds -to -the -empty -seq -of -/ -/ -/ -literals -i -. -e -. -a -regex -that -can -never -match -. -For -example -[ -a -& -& -b -] -. -/ -/ -/ -It -is -distinct -from -Some -( -vec -! -[ -" -" -] -) -which -corresponds -to -the -seq -/ -/ -/ -containing -an -empty -string -which -matches -at -every -position -. -literals -: -Option -< -Vec -< -Literal -> -> -} -impl -Seq -{ -/ -/ -/ -Returns -an -empty -sequence -. -/ -/ -/ -/ -/ -/ -An -empty -sequence -matches -zero -literals -and -thus -corresponds -to -a -/ -/ -/ -regex -that -itself -can -never -match -. -# -[ -inline -] -pub -fn -empty -( -) -- -> -Seq -{ -Seq -{ -literals -: -Some -( -vec -! -[ -] -) -} -} -/ -/ -/ -Returns -a -sequence -of -literals -without -a -finite -size -and -may -contain -/ -/ -/ -any -literal -. -/ -/ -/ -/ -/ -/ -A -sequence -without -finite -size -does -not -reveal -anything -about -the -/ -/ -/ -characteristics -of -the -literals -in -its -set -. -There -are -no -fixed -prefixes -/ -/ -/ -or -suffixes -nor -are -lower -or -upper -bounds -on -the -length -of -the -literals -/ -/ -/ -in -the -set -known -. -/ -/ -/ -/ -/ -/ -This -is -useful -to -represent -constructs -in -a -regex -that -are -" -too -big -" -/ -/ -/ -to -useful -represent -as -a -sequence -of -literals -. -For -example -[ -A -- -Za -- -z -] -. -/ -/ -/ -When -sequences -get -too -big -they -lose -their -discriminating -nature -and -/ -/ -/ -are -more -likely -to -produce -false -positives -which -in -turn -makes -them -/ -/ -/ -less -likely -to -speed -up -searches -. -/ -/ -/ -/ -/ -/ -More -pragmatically -for -many -regexes -enumerating -all -possible -literals -/ -/ -/ -is -itself -not -possible -or -might -otherwise -use -too -many -resources -. -So -/ -/ -/ -constraining -the -size -of -sets -during -extraction -is -a -practical -trade -/ -/ -/ -off -to -make -. -# -[ -inline -] -pub -fn -infinite -( -) -- -> -Seq -{ -Seq -{ -literals -: -None -} -} -/ -/ -/ -Returns -a -sequence -containing -a -single -literal -. -# -[ -inline -] -pub -fn -singleton -( -lit -: -Literal -) -- -> -Seq -{ -Seq -{ -literals -: -Some -( -vec -! -[ -lit -] -) -} -} -/ -/ -/ -Returns -a -sequence -of -exact -literals -from -the -given -byte -strings -. -# -[ -inline -] -pub -fn -new -< -I -B -> -( -it -: -I -) -- -> -Seq -where -I -: -IntoIterator -< -Item -= -B -> -B -: -AsRef -< -[ -u8 -] -> -{ -it -. -into_iter -( -) -. -map -( -| -b -| -Literal -: -: -exact -( -b -. -as_ref -( -) -) -) -. -collect -( -) -} -/ -/ -/ -If -this -is -a -finite -sequence -return -its -members -as -a -slice -of -/ -/ -/ -literals -. -/ -/ -/ -/ -/ -/ -The -slice -returned -may -be -empty -in -which -case -there -are -no -literals -/ -/ -/ -that -can -match -this -sequence -. -# -[ -inline -] -pub -fn -literals -( -& -self -) -- -> -Option -< -& -[ -Literal -] -> -{ -self -. -literals -. -as_deref -( -) -} -/ -/ -/ -Push -a -literal -to -the -end -of -this -sequence -. -/ -/ -/ -/ -/ -/ -If -this -sequence -is -not -finite -then -this -is -a -no -- -op -. -/ -/ -/ -/ -/ -/ -Similarly -if -the -most -recently -added -item -of -this -sequence -is -/ -/ -/ -equivalent -to -the -literal -given -then -it -is -not -added -. -This -reflects -/ -/ -/ -a -Seq -' -s -" -set -like -" -behavior -and -represents -a -practical -trade -off -. -/ -/ -/ -Namely -there -is -never -any -need -to -have -two -adjacent -and -equivalent -/ -/ -/ -literals -in -the -same -sequence -_and_ -it -is -easy -to -detect -in -some -/ -/ -/ -cases -. -# -[ -inline -] -pub -fn -push -( -& -mut -self -lit -: -Literal -) -{ -let -lits -= -match -self -. -literals -{ -None -= -> -return -Some -( -ref -mut -lits -) -= -> -lits -} -; -if -lits -. -last -( -) -. -map_or -( -false -| -m -| -m -= -= -& -lit -) -{ -return -; -} -lits -. -push -( -lit -) -; -} -/ -/ -/ -Make -all -of -the -literals -in -this -sequence -inexact -. -/ -/ -/ -/ -/ -/ -This -is -a -no -- -op -if -this -sequence -is -not -finite -. -# -[ -inline -] -pub -fn -make_inexact -( -& -mut -self -) -{ -let -lits -= -match -self -. -literals -{ -None -= -> -return -Some -( -ref -mut -lits -) -= -> -lits -} -; -for -lit -in -lits -. -iter_mut -( -) -{ -lit -. -make_inexact -( -) -; -} -} -/ -/ -/ -Converts -this -sequence -to -an -infinite -sequence -. -/ -/ -/ -/ -/ -/ -This -is -a -no -- -op -if -the -sequence -is -already -infinite -. -# -[ -inline -] -pub -fn -make_infinite -( -& -mut -self -) -{ -self -. -literals -= -None -; -} -/ -/ -/ -Modify -this -sequence -to -contain -the -cross -product -between -it -and -the -/ -/ -/ -sequence -given -. -/ -/ -/ -/ -/ -/ -The -cross -product -only -considers -literals -in -this -sequence -that -are -/ -/ -/ -exact -. -That -is -inexact -literals -are -not -extended -. -/ -/ -/ -/ -/ -/ -The -literals -are -always -drained -from -other -even -if -none -are -used -. -/ -/ -/ -This -permits -callers -to -reuse -the -sequence -allocation -elsewhere -. -/ -/ -/ -/ -/ -/ -If -this -sequence -is -infinite -then -this -is -a -no -- -op -regardless -of -what -/ -/ -/ -other -contains -( -and -in -this -case -the -literals -are -still -drained -from -/ -/ -/ -other -) -. -If -other -is -infinite -and -this -sequence -is -finite -then -this -/ -/ -/ -is -a -no -- -op -unless -this -sequence -contains -a -zero -- -length -literal -. -In -/ -/ -/ -which -case -the -infiniteness -of -other -infects -this -sequence -and -this -/ -/ -/ -sequence -is -itself -made -infinite -. -/ -/ -/ -/ -/ -/ -Like -[ -Seq -: -: -union -] -this -may -attempt -to -deduplicate -literals -. -See -/ -/ -/ -[ -Seq -: -: -dedup -] -for -how -deduplication -deals -with -exact -and -inexact -/ -/ -/ -literals -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -basic -usage -and -how -exact -and -inexact -literals -/ -/ -/ -interact -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -quux -" -) -/ -/ -/ -Literal -: -: -exact -( -" -baz -" -) -/ -/ -/ -] -) -; -/ -/ -/ -seq1 -. -cross_forward -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -literals -are -pulled -out -of -seq2 -. -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -seq2 -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -fooquux -" -) -/ -/ -/ -Literal -: -: -exact -( -" -foobaz -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -seq1 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -the -behavior -of -when -other -is -an -infinite -/ -/ -/ -sequence -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -seq1 -. -cross_forward -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -When -seq2 -is -infinite -cross -product -doesn -' -t -add -anything -but -/ -/ -/ -/ -/ -ensures -all -members -of -seq1 -are -inexact -. -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -seq1 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -is -like -the -one -above -but -shows -what -happens -when -this -/ -/ -/ -sequence -contains -an -empty -string -. -In -this -case -an -infinite -other -/ -/ -/ -sequence -infects -this -sequence -( -because -the -empty -string -means -that -/ -/ -/ -there -are -no -finite -prefixes -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -exact -( -" -" -) -/ -/ -inexact -provokes -same -behavior -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -seq1 -. -cross_forward -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -seq1 -is -now -infinite -! -/ -/ -/ -assert -! -( -! -seq1 -. -is_finite -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -the -behavior -of -this -sequence -is -infinite -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -seq1 -. -cross_forward -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -seq1 -remains -unchanged -. -/ -/ -/ -assert -! -( -! -seq1 -. -is_finite -( -) -) -; -/ -/ -/ -/ -/ -Even -though -the -literals -in -seq2 -weren -' -t -used -it -was -still -drained -. -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -seq2 -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -cross_forward -( -& -mut -self -other -: -& -mut -Seq -) -{ -let -( -lits1 -lits2 -) -= -match -self -. -cross_preamble -( -other -) -{ -None -= -> -return -Some -( -( -lits1 -lits2 -) -) -= -> -( -lits1 -lits2 -) -} -; -let -newcap -= -lits1 -. -len -( -) -. -saturating_mul -( -lits2 -. -len -( -) -) -; -for -selflit -in -mem -: -: -replace -( -lits1 -Vec -: -: -with_capacity -( -newcap -) -) -{ -if -! -selflit -. -is_exact -( -) -{ -lits1 -. -push -( -selflit -) -; -continue -; -} -for -otherlit -in -lits2 -. -iter -( -) -{ -let -mut -newlit -= -Literal -: -: -exact -( -Vec -: -: -with_capacity -( -selflit -. -len -( -) -+ -otherlit -. -len -( -) -) -) -; -newlit -. -extend -( -& -selflit -) -; -newlit -. -extend -( -& -otherlit -) -; -if -! -otherlit -. -is_exact -( -) -{ -newlit -. -make_inexact -( -) -; -} -lits1 -. -push -( -newlit -) -; -} -} -lits2 -. -drain -( -. -. -) -; -self -. -dedup -( -) -; -} -/ -/ -/ -Modify -this -sequence -to -contain -the -cross -product -between -it -and -/ -/ -/ -the -sequence -given -where -the -sequences -are -treated -as -suffixes -/ -/ -/ -instead -of -prefixes -. -Namely -the -sequence -other -is -* -prepended -* -/ -/ -/ -to -self -( -as -opposed -to -other -being -* -appended -* -to -self -in -/ -/ -/ -[ -Seq -: -: -cross_forward -] -) -. -/ -/ -/ -/ -/ -/ -The -cross -product -only -considers -literals -in -this -sequence -that -are -/ -/ -/ -exact -. -That -is -inexact -literals -are -not -extended -. -/ -/ -/ -/ -/ -/ -The -literals -are -always -drained -from -other -even -if -none -are -used -. -/ -/ -/ -This -permits -callers -to -reuse -the -sequence -allocation -elsewhere -. -/ -/ -/ -/ -/ -/ -If -this -sequence -is -infinite -then -this -is -a -no -- -op -regardless -of -what -/ -/ -/ -other -contains -( -and -in -this -case -the -literals -are -still -drained -from -/ -/ -/ -other -) -. -If -other -is -infinite -and -this -sequence -is -finite -then -this -/ -/ -/ -is -a -no -- -op -unless -this -sequence -contains -a -zero -- -length -literal -. -In -/ -/ -/ -which -case -the -infiniteness -of -other -infects -this -sequence -and -this -/ -/ -/ -sequence -is -itself -made -infinite -. -/ -/ -/ -/ -/ -/ -Like -[ -Seq -: -: -union -] -this -may -attempt -to -deduplicate -literals -. -See -/ -/ -/ -[ -Seq -: -: -dedup -] -for -how -deduplication -deals -with -exact -and -inexact -/ -/ -/ -literals -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -basic -usage -and -how -exact -and -inexact -literals -/ -/ -/ -interact -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -quux -" -) -/ -/ -/ -Literal -: -: -exact -( -" -baz -" -) -/ -/ -/ -] -) -; -/ -/ -/ -seq1 -. -cross_reverse -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -literals -are -pulled -out -of -seq2 -. -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -seq2 -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -quuxfoo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -Literal -: -: -exact -( -" -bazfoo -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -seq1 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -the -behavior -of -when -other -is -an -infinite -/ -/ -/ -sequence -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -seq1 -. -cross_reverse -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -When -seq2 -is -infinite -cross -product -doesn -' -t -add -anything -but -/ -/ -/ -/ -/ -ensures -all -members -of -seq1 -are -inexact -. -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -inexact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -seq1 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -is -like -the -one -above -but -shows -what -happens -when -this -/ -/ -/ -sequence -contains -an -empty -string -. -In -this -case -an -infinite -other -/ -/ -/ -sequence -infects -this -sequence -( -because -the -empty -string -means -that -/ -/ -/ -there -are -no -finite -suffixes -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -exact -( -" -" -) -/ -/ -inexact -provokes -same -behavior -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -seq1 -. -cross_reverse -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -seq1 -is -now -infinite -! -/ -/ -/ -assert -! -( -! -seq1 -. -is_finite -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -the -behavior -when -this -sequence -is -infinite -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -bar -" -) -/ -/ -/ -] -) -; -/ -/ -/ -seq1 -. -cross_reverse -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -seq1 -remains -unchanged -. -/ -/ -/ -assert -! -( -! -seq1 -. -is_finite -( -) -) -; -/ -/ -/ -/ -/ -Even -though -the -literals -in -seq2 -weren -' -t -used -it -was -still -drained -. -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -seq2 -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -cross_reverse -( -& -mut -self -other -: -& -mut -Seq -) -{ -let -( -lits1 -lits2 -) -= -match -self -. -cross_preamble -( -other -) -{ -None -= -> -return -Some -( -( -lits1 -lits2 -) -) -= -> -( -lits1 -lits2 -) -} -; -/ -/ -We -basically -proceed -as -we -do -in -' -cross_forward -' -at -this -point -/ -/ -except -that -the -outer -loop -is -now -' -other -' -and -the -inner -loop -is -now -/ -/ -' -self -' -. -That -' -s -because -' -self -' -corresponds -to -suffixes -and -' -other -' -/ -/ -corresponds -to -the -sequence -we -want -to -* -prepend -* -to -the -suffixes -. -let -newcap -= -lits1 -. -len -( -) -. -saturating_mul -( -lits2 -. -len -( -) -) -; -let -selflits -= -mem -: -: -replace -( -lits1 -Vec -: -: -with_capacity -( -newcap -) -) -; -for -( -i -otherlit -) -in -lits2 -. -drain -( -. -. -) -. -enumerate -( -) -{ -for -selflit -in -selflits -. -iter -( -) -{ -if -! -selflit -. -is_exact -( -) -{ -/ -/ -If -the -suffix -isn -' -t -exact -then -we -can -' -t -prepend -/ -/ -anything -to -it -. -However -we -still -want -to -keep -it -. -But -/ -/ -we -only -want -to -keep -one -of -them -to -avoid -duplication -. -/ -/ -( -The -duplication -is -okay -from -a -correctness -perspective -/ -/ -but -wasteful -. -) -if -i -= -= -0 -{ -lits1 -. -push -( -selflit -. -clone -( -) -) -; -} -continue -; -} -let -mut -newlit -= -Literal -: -: -exact -( -Vec -: -: -with_capacity -( -otherlit -. -len -( -) -+ -selflit -. -len -( -) -) -) -; -newlit -. -extend -( -& -otherlit -) -; -newlit -. -extend -( -& -selflit -) -; -if -! -otherlit -. -is_exact -( -) -{ -newlit -. -make_inexact -( -) -; -} -lits1 -. -push -( -newlit -) -; -} -} -self -. -dedup -( -) -; -} -/ -/ -/ -A -helper -function -the -corresponds -to -the -subtle -preamble -for -both -/ -/ -/ -cross_forward -and -cross_reverse -. -In -effect -it -handles -the -cases -/ -/ -/ -of -infinite -sequences -for -both -self -and -other -as -well -as -ensuring -/ -/ -/ -that -literals -from -other -are -drained -even -if -they -aren -' -t -used -. -fn -cross_preamble -< -' -a -> -( -& -' -a -mut -self -other -: -& -' -a -mut -Seq -) -- -> -Option -< -( -& -' -a -mut -Vec -< -Literal -> -& -' -a -mut -Vec -< -Literal -> -) -> -{ -let -lits2 -= -match -other -. -literals -{ -None -= -> -{ -/ -/ -If -our -current -seq -contains -the -empty -string -and -the -seq -/ -/ -we -' -re -adding -matches -any -literal -then -it -follows -that -the -/ -/ -current -seq -must -now -also -match -any -literal -. -/ -/ -/ -/ -Otherwise -we -just -have -to -make -sure -everything -in -this -/ -/ -sequence -is -inexact -. -if -self -. -min_literal_len -( -) -= -= -Some -( -0 -) -{ -* -self -= -Seq -: -: -infinite -( -) -; -} -else -{ -self -. -make_inexact -( -) -; -} -return -None -; -} -Some -( -ref -mut -lits -) -= -> -lits -} -; -let -lits1 -= -match -self -. -literals -{ -None -= -> -{ -/ -/ -If -we -aren -' -t -going -to -make -it -to -the -end -of -this -routine -/ -/ -where -lits2 -is -drained -then -we -need -to -do -it -now -. -lits2 -. -drain -( -. -. -) -; -return -None -; -} -Some -( -ref -mut -lits -) -= -> -lits -} -; -Some -( -( -lits1 -lits2 -) -) -} -/ -/ -/ -Unions -the -other -sequence -into -this -one -. -/ -/ -/ -/ -/ -/ -The -literals -are -always -drained -out -of -the -given -other -sequence -/ -/ -/ -even -if -they -are -being -unioned -into -an -infinite -sequence -. -This -permits -/ -/ -/ -the -caller -to -reuse -the -other -sequence -in -another -context -. -/ -/ -/ -/ -/ -/ -Some -literal -deduping -may -be -performed -. -If -any -deduping -happens -/ -/ -/ -any -leftmost -- -first -or -" -preference -" -order -match -semantics -will -be -/ -/ -/ -preserved -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -basic -usage -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -Seq -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -new -( -& -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -new -( -& -[ -" -bar -" -" -quux -" -" -foo -" -] -) -; -/ -/ -/ -seq1 -. -union -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -literals -are -pulled -out -of -seq2 -. -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -seq2 -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Adjacent -literals -are -deduped -but -non -- -adjacent -literals -may -not -be -. -/ -/ -/ -assert_eq -! -( -Seq -: -: -new -( -& -[ -" -foo -" -" -bar -" -" -quux -" -" -foo -" -] -) -seq1 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -that -literals -are -drained -from -other -even -when -/ -/ -/ -they -aren -' -t -necessarily -used -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -Seq -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -/ -/ -Infinite -sequences -have -no -finite -length -. -/ -/ -/ -assert_eq -! -( -None -seq1 -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -new -( -& -[ -" -bar -" -" -quux -" -" -foo -" -] -) -; -/ -/ -/ -seq1 -. -union -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -seq1 -is -still -infinite -and -seq2 -has -been -drained -. -/ -/ -/ -assert_eq -! -( -None -seq1 -. -len -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -seq2 -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -union -( -& -mut -self -other -: -& -mut -Seq -) -{ -let -lits2 -= -match -other -. -literals -{ -None -= -> -{ -/ -/ -Unioning -with -an -infinite -sequence -always -results -in -an -/ -/ -infinite -sequence -. -self -. -make_infinite -( -) -; -return -; -} -Some -( -ref -mut -lits -) -= -> -lits -. -drain -( -. -. -) -} -; -let -lits1 -= -match -self -. -literals -{ -None -= -> -return -Some -( -ref -mut -lits -) -= -> -lits -} -; -lits1 -. -extend -( -lits2 -) -; -self -. -dedup -( -) -; -} -/ -/ -/ -Unions -the -other -sequence -into -this -one -by -splice -the -other -/ -/ -/ -sequence -at -the -position -of -the -first -zero -- -length -literal -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -preserving -preference -order -semantics -when -combining -/ -/ -/ -two -literal -sequences -. -For -example -in -the -regex -( -a -| -| -f -) -+ -foo -the -/ -/ -/ -correct -preference -order -prefix -sequence -is -[ -a -foo -f -] -. -/ -/ -/ -/ -/ -/ -The -literals -are -always -drained -out -of -the -given -other -sequence -/ -/ -/ -even -if -they -are -being -unioned -into -an -infinite -sequence -. -This -permits -/ -/ -/ -the -caller -to -reuse -the -other -sequence -in -another -context -. -Note -that -/ -/ -/ -the -literals -are -drained -even -if -no -union -is -performed -as -well -i -. -e -. -/ -/ -/ -when -this -sequence -does -not -contain -a -zero -- -length -literal -. -/ -/ -/ -/ -/ -/ -Some -literal -deduping -may -be -performed -. -If -any -deduping -happens -/ -/ -/ -any -leftmost -- -first -or -" -preference -" -order -match -semantics -will -be -/ -/ -/ -preserved -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -basic -usage -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -Seq -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -new -( -& -[ -" -a -" -" -" -" -f -" -" -" -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -new -( -& -[ -" -foo -" -] -) -; -/ -/ -/ -seq1 -. -union_into_empty -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -The -literals -are -pulled -out -of -seq2 -. -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -seq2 -. -len -( -) -) -; -/ -/ -/ -/ -/ -' -foo -' -gets -spliced -into -seq1 -where -the -first -empty -string -occurs -. -/ -/ -/ -assert_eq -! -( -Seq -: -: -new -( -& -[ -" -a -" -" -foo -" -" -f -" -] -) -seq1 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -that -literals -are -drained -from -other -even -when -/ -/ -/ -they -aren -' -t -necessarily -used -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -Seq -; -/ -/ -/ -/ -/ -/ -let -mut -seq1 -= -Seq -: -: -new -( -& -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -let -mut -seq2 -= -Seq -: -: -new -( -& -[ -" -bar -" -" -quux -" -" -foo -" -] -) -; -/ -/ -/ -seq1 -. -union_into_empty -( -& -mut -seq2 -) -; -/ -/ -/ -/ -/ -/ -/ -/ -seq1 -has -no -zero -length -literals -so -no -splicing -happens -. -/ -/ -/ -assert_eq -! -( -Seq -: -: -new -( -& -[ -" -foo -" -" -bar -" -] -) -seq1 -) -; -/ -/ -/ -/ -/ -Even -though -no -splicing -happens -seq2 -is -still -drained -. -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -seq2 -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -union_into_empty -( -& -mut -self -other -: -& -mut -Seq -) -{ -let -lits2 -= -other -. -literals -. -as_mut -( -) -. -map -( -| -lits -| -lits -. -drain -( -. -. -) -) -; -let -lits1 -= -match -self -. -literals -{ -None -= -> -return -Some -( -ref -mut -lits -) -= -> -lits -} -; -let -first_empty -= -match -lits1 -. -iter -( -) -. -position -( -| -m -| -m -. -is_empty -( -) -) -{ -None -= -> -return -Some -( -i -) -= -> -i -} -; -let -lits2 -= -match -lits2 -{ -None -= -> -{ -/ -/ -Note -that -we -are -only -here -if -we -' -ve -found -an -empty -literal -/ -/ -which -implies -that -an -infinite -sequence -infects -this -seq -and -/ -/ -also -turns -it -into -an -infinite -sequence -. -self -. -literals -= -None -; -return -; -} -Some -( -lits -) -= -> -lits -} -; -/ -/ -Clearing -out -the -empties -needs -to -come -before -the -splice -because -/ -/ -the -splice -might -add -more -empties -that -we -don -' -t -want -to -get -rid -/ -/ -of -. -Since -we -' -re -splicing -into -the -position -of -the -first -empty -the -/ -/ -' -first_empty -' -position -computed -above -is -still -correct -. -lits1 -. -retain -( -| -m -| -! -m -. -is_empty -( -) -) -; -lits1 -. -splice -( -first_empty -. -. -first_empty -lits2 -) -; -self -. -dedup -( -) -; -} -/ -/ -/ -Deduplicate -adjacent -equivalent -literals -in -this -sequence -. -/ -/ -/ -/ -/ -/ -If -adjacent -literals -are -equivalent -strings -but -one -is -exact -and -the -/ -/ -/ -other -inexact -the -inexact -literal -is -kept -and -the -exact -one -is -/ -/ -/ -removed -. -/ -/ -/ -/ -/ -/ -Deduping -an -infinite -sequence -is -a -no -- -op -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -literals -that -are -duplicate -byte -strings -but -/ -/ -/ -are -not -equivalent -with -respect -to -exactness -are -resolved -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -foo -" -) -/ -/ -/ -] -) -; -/ -/ -/ -seq -. -dedup -( -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Seq -: -: -from_iter -( -[ -Literal -: -: -inexact -( -" -foo -" -) -] -) -seq -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -dedup -( -& -mut -self -) -{ -if -let -Some -( -ref -mut -lits -) -= -self -. -literals -{ -lits -. -dedup_by -( -| -lit1 -lit2 -| -{ -if -lit1 -. -as_bytes -( -) -! -= -lit2 -. -as_bytes -( -) -{ -return -false -; -} -if -lit1 -. -is_exact -( -) -! -= -lit2 -. -is_exact -( -) -{ -lit1 -. -make_inexact -( -) -; -lit2 -. -make_inexact -( -) -; -} -true -} -) -; -} -} -/ -/ -/ -Sorts -this -sequence -of -literals -lexicographically -. -/ -/ -/ -/ -/ -/ -Note -that -if -before -sorting -if -a -literal -that -is -a -prefix -of -another -/ -/ -/ -literal -appears -after -it -then -after -sorting -the -sequence -will -not -/ -/ -/ -represent -the -same -preference -order -match -semantics -. -For -example -/ -/ -/ -sorting -the -sequence -[ -samwise -sam -] -yields -the -sequence -[ -sam -/ -/ -/ -samwise -] -. -Under -preference -order -semantics -the -latter -sequence -will -/ -/ -/ -never -match -samwise -where -as -the -first -sequence -can -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -basic -usage -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -Seq -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -" -foo -" -" -quux -" -" -bar -" -] -) -; -/ -/ -/ -seq -. -sort -( -) -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Seq -: -: -new -( -& -[ -" -bar -" -" -foo -" -" -quux -" -] -) -seq -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -sort -( -& -mut -self -) -{ -if -let -Some -( -ref -mut -lits -) -= -self -. -literals -{ -lits -. -sort -( -) -; -} -} -/ -/ -/ -Reverses -all -of -the -literals -in -this -sequence -. -/ -/ -/ -/ -/ -/ -The -order -of -the -sequence -itself -is -preserved -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -basic -usage -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -Seq -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -" -oof -" -" -rab -" -] -) -; -/ -/ -/ -seq -. -reverse_literals -( -) -; -/ -/ -/ -assert_eq -! -( -Seq -: -: -new -( -& -[ -" -foo -" -" -bar -" -] -) -seq -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -reverse_literals -( -& -mut -self -) -{ -if -let -Some -( -ref -mut -lits -) -= -self -. -literals -{ -for -lit -in -lits -. -iter_mut -( -) -{ -lit -. -reverse -( -) -; -} -} -} -/ -/ -/ -Shrinks -this -seq -to -its -minimal -size -while -respecting -the -preference -/ -/ -/ -order -of -its -literals -. -/ -/ -/ -/ -/ -/ -While -this -routine -will -remove -duplicate -literals -from -this -seq -it -/ -/ -/ -will -also -remove -literals -that -can -never -match -in -a -leftmost -- -first -or -/ -/ -/ -" -preference -order -" -search -. -Similar -to -[ -Seq -: -: -dedup -] -if -a -literal -is -/ -/ -/ -deduped -then -the -one -that -remains -is -made -inexact -. -/ -/ -/ -/ -/ -/ -This -is -a -no -- -op -on -seqs -that -are -empty -or -not -finite -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -difference -between -{ -sam -samwise -} -and -/ -/ -/ -{ -samwise -sam -} -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -/ -/ -If -' -sam -' -comes -before -' -samwise -' -and -a -preference -order -search -is -/ -/ -/ -/ -/ -executed -then -' -samwise -' -can -never -match -. -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -" -sam -" -" -samwise -" -] -) -; -/ -/ -/ -seq -. -minimize_by_preference -( -) -; -/ -/ -/ -assert_eq -! -( -Seq -: -: -from_iter -( -[ -Literal -: -: -inexact -( -" -sam -" -) -] -) -seq -) -; -/ -/ -/ -/ -/ -/ -/ -/ -But -if -they -are -reversed -then -it -' -s -possible -for -' -samwise -' -to -match -/ -/ -/ -/ -/ -since -it -is -given -higher -preference -. -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -" -samwise -" -" -sam -" -] -) -; -/ -/ -/ -seq -. -minimize_by_preference -( -) -; -/ -/ -/ -assert_eq -! -( -Seq -: -: -new -( -& -[ -" -samwise -" -" -sam -" -] -) -seq -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -that -if -an -empty -string -is -in -this -seq -then -/ -/ -/ -anything -that -comes -after -it -can -never -match -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -/ -/ -An -empty -string -is -a -prefix -of -all -strings -so -it -automatically -/ -/ -/ -/ -/ -inhibits -any -subsequent -strings -from -matching -. -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -" -foo -" -" -bar -" -" -" -" -quux -" -" -fox -" -] -) -; -/ -/ -/ -seq -. -minimize_by_preference -( -) -; -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -foo -" -) -/ -/ -/ -Literal -: -: -exact -( -" -bar -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -seq -) -; -/ -/ -/ -/ -/ -/ -/ -/ -And -of -course -if -it -' -s -at -the -beginning -then -it -makes -it -impossible -/ -/ -/ -/ -/ -for -anything -else -to -match -. -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -" -" -" -foo -" -" -quux -" -" -fox -" -] -) -; -/ -/ -/ -seq -. -minimize_by_preference -( -) -; -/ -/ -/ -assert_eq -! -( -Seq -: -: -from_iter -( -[ -Literal -: -: -inexact -( -" -" -) -] -) -seq -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -minimize_by_preference -( -& -mut -self -) -{ -if -let -Some -( -ref -mut -lits -) -= -self -. -literals -{ -PreferenceTrie -: -: -minimize -( -lits -false -) -; -} -} -/ -/ -/ -Trims -all -literals -in -this -seq -such -that -only -the -first -len -bytes -/ -/ -/ -remain -. -If -a -literal -has -less -than -or -equal -to -len -bytes -then -it -/ -/ -/ -remains -unchanged -. -Otherwise -it -is -trimmed -and -made -inexact -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -" -a -" -" -foo -" -" -quux -" -] -) -; -/ -/ -/ -seq -. -keep_first_bytes -( -2 -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -a -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -fo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -qu -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -seq -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -keep_first_bytes -( -& -mut -self -len -: -usize -) -{ -if -let -Some -( -ref -mut -lits -) -= -self -. -literals -{ -for -m -in -lits -. -iter_mut -( -) -{ -m -. -keep_first_bytes -( -len -) -; -} -} -} -/ -/ -/ -Trims -all -literals -in -this -seq -such -that -only -the -last -len -bytes -/ -/ -/ -remain -. -If -a -literal -has -less -than -or -equal -to -len -bytes -then -it -/ -/ -/ -remains -unchanged -. -Otherwise -it -is -trimmed -and -made -inexact -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Literal -Seq -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -" -a -" -" -foo -" -" -quux -" -] -) -; -/ -/ -/ -seq -. -keep_last_bytes -( -2 -) -; -/ -/ -/ -/ -/ -/ -let -expected -= -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -a -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -oo -" -) -/ -/ -/ -Literal -: -: -inexact -( -" -ux -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -expected -seq -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -keep_last_bytes -( -& -mut -self -len -: -usize -) -{ -if -let -Some -( -ref -mut -lits -) -= -self -. -literals -{ -for -m -in -lits -. -iter_mut -( -) -{ -m -. -keep_last_bytes -( -len -) -; -} -} -} -/ -/ -/ -Returns -true -if -this -sequence -is -finite -. -/ -/ -/ -/ -/ -/ -When -false -this -sequence -is -infinite -and -must -be -treated -as -if -it -/ -/ -/ -contains -every -possible -literal -. -# -[ -inline -] -pub -fn -is_finite -( -& -self -) -- -> -bool -{ -self -. -literals -. -is_some -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -sequence -is -finite -and -empty -. -/ -/ -/ -/ -/ -/ -An -empty -sequence -never -matches -anything -. -It -can -only -be -produced -by -/ -/ -/ -literal -extraction -when -the -corresponding -regex -itself -cannot -match -. -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -len -( -) -= -= -Some -( -0 -) -} -/ -/ -/ -Returns -the -number -of -literals -in -this -sequence -if -the -sequence -is -/ -/ -/ -finite -. -If -the -sequence -is -infinite -then -None -is -returned -. -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -literals -. -as_ref -( -) -. -map -( -| -lits -| -lits -. -len -( -) -) -} -/ -/ -/ -Returns -true -if -and -only -if -all -literals -in -this -sequence -are -exact -. -/ -/ -/ -/ -/ -/ -This -returns -false -if -the -sequence -is -infinite -. -# -[ -inline -] -pub -fn -is_exact -( -& -self -) -- -> -bool -{ -self -. -literals -( -) -. -map_or -( -false -| -lits -| -lits -. -iter -( -) -. -all -( -| -x -| -x -. -is_exact -( -) -) -) -} -/ -/ -/ -Returns -true -if -and -only -if -all -literals -in -this -sequence -are -inexact -. -/ -/ -/ -/ -/ -/ -This -returns -true -if -the -sequence -is -infinite -. -# -[ -inline -] -pub -fn -is_inexact -( -& -self -) -- -> -bool -{ -self -. -literals -( -) -. -map_or -( -true -| -lits -| -lits -. -iter -( -) -. -all -( -| -x -| -! -x -. -is_exact -( -) -) -) -} -/ -/ -/ -Return -the -maximum -length -of -the -sequence -that -would -result -from -/ -/ -/ -unioning -self -with -other -. -If -either -set -is -infinite -then -this -/ -/ -/ -returns -None -. -# -[ -inline -] -pub -fn -max_union_len -( -& -self -other -: -& -Seq -) -- -> -Option -< -usize -> -{ -let -len1 -= -self -. -len -( -) -? -; -let -len2 -= -other -. -len -( -) -? -; -Some -( -len1 -. -saturating_add -( -len2 -) -) -} -/ -/ -/ -Return -the -maximum -length -of -the -sequence -that -would -result -from -the -/ -/ -/ -cross -product -of -self -with -other -. -If -either -set -is -infinite -then -/ -/ -/ -this -returns -None -. -# -[ -inline -] -pub -fn -max_cross_len -( -& -self -other -: -& -Seq -) -- -> -Option -< -usize -> -{ -let -len1 -= -self -. -len -( -) -? -; -let -len2 -= -other -. -len -( -) -? -; -Some -( -len1 -. -saturating_mul -( -len2 -) -) -} -/ -/ -/ -Returns -the -length -of -the -shortest -literal -in -this -sequence -. -/ -/ -/ -/ -/ -/ -If -the -sequence -is -infinite -or -empty -then -this -returns -None -. -# -[ -inline -] -pub -fn -min_literal_len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -literals -. -as_ref -( -) -? -. -iter -( -) -. -map -( -| -x -| -x -. -len -( -) -) -. -min -( -) -} -/ -/ -/ -Returns -the -length -of -the -longest -literal -in -this -sequence -. -/ -/ -/ -/ -/ -/ -If -the -sequence -is -infinite -or -empty -then -this -returns -None -. -# -[ -inline -] -pub -fn -max_literal_len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -literals -. -as_ref -( -) -? -. -iter -( -) -. -map -( -| -x -| -x -. -len -( -) -) -. -max -( -) -} -/ -/ -/ -Returns -the -longest -common -prefix -from -this -seq -. -/ -/ -/ -/ -/ -/ -If -the -seq -matches -any -literal -or -other -contains -no -literals -then -/ -/ -/ -there -is -no -meaningful -prefix -and -this -returns -None -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -some -example -seqs -and -their -longest -common -prefix -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -Seq -; -/ -/ -/ -/ -/ -/ -let -seq -= -Seq -: -: -new -( -& -[ -" -foo -" -" -foobar -" -" -fo -" -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -fo -" -[ -. -. -] -) -seq -. -longest_common_prefix -( -) -) -; -/ -/ -/ -let -seq -= -Seq -: -: -new -( -& -[ -" -foo -" -" -foo -" -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -foo -" -[ -. -. -] -) -seq -. -longest_common_prefix -( -) -) -; -/ -/ -/ -let -seq -= -Seq -: -: -new -( -& -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -" -[ -. -. -] -) -seq -. -longest_common_prefix -( -) -) -; -/ -/ -/ -let -seq -= -Seq -: -: -new -( -& -[ -" -" -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -" -[ -. -. -] -) -seq -. -longest_common_prefix -( -) -) -; -/ -/ -/ -/ -/ -/ -let -seq -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -assert_eq -! -( -None -seq -. -longest_common_prefix -( -) -) -; -/ -/ -/ -let -seq -= -Seq -: -: -empty -( -) -; -/ -/ -/ -assert_eq -! -( -None -seq -. -longest_common_prefix -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -longest_common_prefix -( -& -self -) -- -> -Option -< -& -[ -u8 -] -> -{ -/ -/ -If -we -match -everything -or -match -nothing -then -there -' -s -no -meaningful -/ -/ -longest -common -prefix -. -let -lits -= -match -self -. -literals -{ -None -= -> -return -None -Some -( -ref -lits -) -= -> -lits -} -; -if -lits -. -len -( -) -= -= -0 -{ -return -None -; -} -let -base -= -lits -[ -0 -] -. -as_bytes -( -) -; -let -mut -len -= -base -. -len -( -) -; -for -m -in -lits -. -iter -( -) -. -skip -( -1 -) -{ -len -= -m -. -as_bytes -( -) -. -iter -( -) -. -zip -( -base -[ -. -. -len -] -. -iter -( -) -) -. -take_while -( -| -& -( -a -b -) -| -a -= -= -b -) -. -count -( -) -; -if -len -= -= -0 -{ -return -Some -( -& -[ -] -) -; -} -} -Some -( -& -base -[ -. -. -len -] -) -} -/ -/ -/ -Returns -the -longest -common -suffix -from -this -seq -. -/ -/ -/ -/ -/ -/ -If -the -seq -matches -any -literal -or -other -contains -no -literals -then -/ -/ -/ -there -is -no -meaningful -suffix -and -this -returns -None -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -some -example -seqs -and -their -longest -common -suffix -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -Seq -; -/ -/ -/ -/ -/ -/ -let -seq -= -Seq -: -: -new -( -& -[ -" -oof -" -" -raboof -" -" -of -" -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -of -" -[ -. -. -] -) -seq -. -longest_common_suffix -( -) -) -; -/ -/ -/ -let -seq -= -Seq -: -: -new -( -& -[ -" -foo -" -" -foo -" -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -foo -" -[ -. -. -] -) -seq -. -longest_common_suffix -( -) -) -; -/ -/ -/ -let -seq -= -Seq -: -: -new -( -& -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -" -[ -. -. -] -) -seq -. -longest_common_suffix -( -) -) -; -/ -/ -/ -let -seq -= -Seq -: -: -new -( -& -[ -" -" -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -" -[ -. -. -] -) -seq -. -longest_common_suffix -( -) -) -; -/ -/ -/ -/ -/ -/ -let -seq -= -Seq -: -: -infinite -( -) -; -/ -/ -/ -assert_eq -! -( -None -seq -. -longest_common_suffix -( -) -) -; -/ -/ -/ -let -seq -= -Seq -: -: -empty -( -) -; -/ -/ -/ -assert_eq -! -( -None -seq -. -longest_common_suffix -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -longest_common_suffix -( -& -self -) -- -> -Option -< -& -[ -u8 -] -> -{ -/ -/ -If -we -match -everything -or -match -nothing -then -there -' -s -no -meaningful -/ -/ -longest -common -suffix -. -let -lits -= -match -self -. -literals -{ -None -= -> -return -None -Some -( -ref -lits -) -= -> -lits -} -; -if -lits -. -len -( -) -= -= -0 -{ -return -None -; -} -let -base -= -lits -[ -0 -] -. -as_bytes -( -) -; -let -mut -len -= -base -. -len -( -) -; -for -m -in -lits -. -iter -( -) -. -skip -( -1 -) -{ -len -= -m -. -as_bytes -( -) -. -iter -( -) -. -rev -( -) -. -zip -( -base -[ -base -. -len -( -) -- -len -. -. -] -. -iter -( -) -. -rev -( -) -) -. -take_while -( -| -& -( -a -b -) -| -a -= -= -b -) -. -count -( -) -; -if -len -= -= -0 -{ -return -Some -( -& -[ -] -) -; -} -} -Some -( -& -base -[ -base -. -len -( -) -- -len -. -. -] -) -} -/ -/ -/ -Optimizes -this -seq -while -treating -its -literals -as -prefixes -and -/ -/ -/ -respecting -the -preference -order -of -its -literals -. -/ -/ -/ -/ -/ -/ -The -specific -way -" -optimization -" -works -is -meant -to -be -an -implementation -/ -/ -/ -detail -as -it -essentially -represents -a -set -of -heuristics -. -The -goal -/ -/ -/ -that -optimization -tries -to -accomplish -is -to -make -the -literals -in -this -/ -/ -/ -set -reflect -inputs -that -will -result -in -a -more -effective -prefilter -. -/ -/ -/ -Principally -by -reducing -the -false -positive -rate -of -candidates -found -by -/ -/ -/ -the -literals -in -this -sequence -. -That -is -when -a -match -of -a -literal -is -/ -/ -/ -found -we -would -like -it -to -be -a -strong -predictor -of -the -overall -match -/ -/ -/ -of -the -regex -. -If -it -isn -' -t -then -much -time -will -be -spent -starting -and -/ -/ -/ -stopping -the -prefilter -search -and -attempting -to -confirm -the -match -only -/ -/ -/ -to -have -it -fail -. -/ -/ -/ -/ -/ -/ -Some -of -those -heuristics -might -be -: -/ -/ -/ -/ -/ -/ -* -Identifying -a -common -prefix -from -a -larger -sequence -of -literals -and -/ -/ -/ -shrinking -the -sequence -down -to -that -single -common -prefix -. -/ -/ -/ -* -Rejecting -the -sequence -entirely -if -it -is -believed -to -result -in -very -/ -/ -/ -high -false -positive -rate -. -When -this -happens -the -sequence -is -made -/ -/ -/ -infinite -. -/ -/ -/ -* -Shrinking -the -sequence -to -a -smaller -number -of -literals -representing -/ -/ -/ -prefixes -but -not -shrinking -it -so -much -as -to -make -literals -too -short -. -/ -/ -/ -( -A -sequence -with -very -short -literals -of -1 -or -2 -bytes -will -typically -/ -/ -/ -result -in -a -higher -false -positive -rate -. -) -/ -/ -/ -/ -/ -/ -Optimization -should -only -be -run -once -extraction -is -complete -. -Namely -/ -/ -/ -optimization -may -make -assumptions -that -do -not -compose -with -other -/ -/ -/ -operations -in -the -middle -of -extraction -. -For -example -optimization -will -/ -/ -/ -reduce -[ -E -( -sam -) -E -( -samwise -) -] -to -[ -E -( -sam -) -] -but -such -a -transformation -/ -/ -/ -is -only -valid -if -no -other -extraction -will -occur -. -If -other -extraction -/ -/ -/ -may -occur -then -the -correct -transformation -would -be -to -[ -I -( -sam -) -] -. -/ -/ -/ -/ -/ -/ -The -[ -Seq -: -: -optimize_for_suffix_by_preference -] -does -the -same -thing -but -/ -/ -/ -for -suffixes -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -optimization -might -transform -a -sequence -. -Note -that -/ -/ -/ -the -specific -behavior -is -not -a -documented -guarantee -. -The -heuristics -/ -/ -/ -used -are -an -implementation -detail -and -may -change -over -time -in -semver -/ -/ -/ -compatible -releases -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Seq -Literal -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -/ -/ -/ -" -samantha -" -/ -/ -/ -" -sam -" -/ -/ -/ -" -samwise -" -/ -/ -/ -" -frodo -" -/ -/ -/ -] -) -; -/ -/ -/ -seq -. -optimize_for_prefix_by_preference -( -) -; -/ -/ -/ -assert_eq -! -( -Seq -: -: -from_iter -( -[ -/ -/ -/ -Literal -: -: -exact -( -" -samantha -" -) -/ -/ -/ -/ -/ -Kept -exact -even -though -' -samwise -' -got -pruned -/ -/ -/ -/ -/ -because -optimization -assumes -literal -extraction -/ -/ -/ -/ -/ -has -finished -. -/ -/ -/ -Literal -: -: -exact -( -" -sam -" -) -/ -/ -/ -Literal -: -: -exact -( -" -frodo -" -) -/ -/ -/ -] -) -seq -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -optimization -may -make -the -sequence -infinite -/ -/ -/ -/ -/ -/ -If -the -heuristics -deem -that -the -sequence -could -cause -a -very -high -false -/ -/ -/ -positive -rate -then -it -may -make -the -sequence -infinite -effectively -/ -/ -/ -disabling -its -use -as -a -prefilter -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Seq -Literal -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -/ -/ -/ -" -samantha -" -/ -/ -/ -/ -/ -An -empty -string -matches -at -every -position -/ -/ -/ -/ -/ -thus -rendering -the -prefilter -completely -/ -/ -/ -/ -/ -ineffective -. -/ -/ -/ -" -" -/ -/ -/ -" -sam -" -/ -/ -/ -" -samwise -" -/ -/ -/ -" -frodo -" -/ -/ -/ -] -) -; -/ -/ -/ -seq -. -optimize_for_prefix_by_preference -( -) -; -/ -/ -/ -assert -! -( -! -seq -. -is_finite -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Do -note -that -just -because -there -is -a -" -" -in -the -sequence -that -/ -/ -/ -doesn -' -t -mean -the -sequence -will -always -be -made -infinite -after -it -is -/ -/ -/ -optimized -. -Namely -if -the -sequence -is -considered -exact -( -any -match -/ -/ -/ -corresponds -to -an -overall -match -of -the -original -regex -) -then -any -match -/ -/ -/ -is -an -overall -match -and -so -the -false -positive -rate -is -always -0 -. -/ -/ -/ -/ -/ -/ -To -demonstrate -this -we -remove -samwise -from -our -sequence -. -This -/ -/ -/ -results -in -no -optimization -happening -and -all -literals -remain -exact -. -/ -/ -/ -Thus -the -entire -sequence -is -exact -and -it -is -kept -as -- -is -even -though -/ -/ -/ -one -is -an -ASCII -space -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -literal -: -: -{ -Seq -Literal -} -; -/ -/ -/ -/ -/ -/ -let -mut -seq -= -Seq -: -: -new -( -& -[ -/ -/ -/ -" -samantha -" -/ -/ -/ -" -" -/ -/ -/ -" -sam -" -/ -/ -/ -" -frodo -" -/ -/ -/ -] -) -; -/ -/ -/ -seq -. -optimize_for_prefix_by_preference -( -) -; -/ -/ -/ -assert -! -( -seq -. -is_finite -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -optimize_for_prefix_by_preference -( -& -mut -self -) -{ -self -. -optimize_by_preference -( -true -) -; -} -/ -/ -/ -Optimizes -this -seq -while -treating -its -literals -as -suffixes -and -/ -/ -/ -respecting -the -preference -order -of -its -literals -. -/ -/ -/ -/ -/ -/ -Optimization -should -only -be -run -once -extraction -is -complete -. -/ -/ -/ -/ -/ -/ -The -[ -Seq -: -: -optimize_for_prefix_by_preference -] -does -the -same -thing -but -/ -/ -/ -for -prefixes -. -See -its -documentation -for -more -explanation -. -# -[ -inline -] -pub -fn -optimize_for_suffix_by_preference -( -& -mut -self -) -{ -self -. -optimize_by_preference -( -false -) -; -} -fn -optimize_by_preference -( -& -mut -self -prefix -: -bool -) -{ -let -origlen -= -match -self -. -len -( -) -{ -None -= -> -return -Some -( -len -) -= -> -len -} -; -/ -/ -Just -give -up -now -if -our -sequence -contains -an -empty -string -. -if -self -. -min_literal_len -( -) -. -map_or -( -false -| -len -| -len -= -= -0 -) -{ -/ -/ -We -squash -the -sequence -so -that -nobody -else -gets -any -bright -/ -/ -ideas -to -try -and -use -it -. -An -empty -string -implies -a -match -at -/ -/ -every -position -. -A -prefilter -cannot -help -you -here -. -self -. -make_infinite -( -) -; -return -; -} -/ -/ -Make -sure -we -start -with -the -smallest -sequence -possible -. -We -use -a -/ -/ -special -version -of -preference -minimization -that -retains -exactness -. -/ -/ -This -is -legal -because -optimization -is -only -expected -to -occur -once -/ -/ -extraction -is -complete -. -if -prefix -{ -if -let -Some -( -ref -mut -lits -) -= -self -. -literals -{ -PreferenceTrie -: -: -minimize -( -lits -true -) -; -} -} -/ -/ -Look -for -a -common -prefix -( -or -suffix -) -. -If -we -found -one -of -those -and -/ -/ -it -' -s -long -enough -then -it -' -s -a -good -bet -that -it -will -be -our -fastest -/ -/ -possible -prefilter -since -single -- -substring -search -is -so -fast -. -let -fix -= -if -prefix -{ -self -. -longest_common_prefix -( -) -} -else -{ -self -. -longest_common_suffix -( -) -} -; -if -let -Some -( -fix -) -= -fix -{ -/ -/ -As -a -special -case -if -we -have -a -common -prefix -and -the -leading -/ -/ -byte -of -that -prefix -is -one -that -we -think -probably -occurs -rarely -/ -/ -then -strip -everything -down -to -just -that -single -byte -. -This -should -/ -/ -promote -the -use -of -memchr -. -/ -/ -/ -/ -. -. -. -we -only -do -this -though -if -our -sequence -has -more -than -one -/ -/ -literal -. -Otherwise -we -' -d -rather -just -stick -with -a -single -literal -/ -/ -scan -. -That -is -using -memchr -is -probably -better -than -looking -/ -/ -for -2 -or -more -literals -but -probably -not -as -good -as -a -straight -/ -/ -memmem -search -. -/ -/ -/ -/ -. -. -. -and -also -only -do -this -when -the -prefix -is -short -and -probably -/ -/ -not -too -discriminatory -anyway -. -If -it -' -s -longer -then -it -' -s -/ -/ -probably -quite -discriminatory -and -thus -is -likely -to -have -a -low -/ -/ -false -positive -rate -. -if -prefix -& -& -origlen -> -1 -& -& -fix -. -len -( -) -> -= -1 -& -& -fix -. -len -( -) -< -= -3 -& -& -rank -( -fix -[ -0 -] -) -< -200 -{ -self -. -keep_first_bytes -( -1 -) -; -self -. -dedup -( -) -; -return -; -} -/ -/ -We -only -strip -down -to -the -common -prefix -/ -suffix -if -we -think -/ -/ -the -existing -set -of -literals -isn -' -t -great -or -if -the -common -/ -/ -prefix -/ -suffix -is -expected -to -be -particularly -discriminatory -. -let -isfast -= -self -. -is_exact -( -) -& -& -self -. -len -( -) -. -map_or -( -false -| -len -| -len -< -= -16 -) -; -let -usefix -= -fix -. -len -( -) -> -4 -| -| -( -fix -. -len -( -) -> -1 -& -& -! -isfast -) -; -if -usefix -{ -/ -/ -If -we -keep -exactly -the -number -of -bytes -equal -to -the -length -/ -/ -of -the -prefix -( -or -suffix -) -then -by -the -definition -of -a -/ -/ -prefix -every -literal -in -the -sequence -will -be -equivalent -. -/ -/ -Thus -' -dedup -' -will -leave -us -with -one -literal -. -/ -/ -/ -/ -We -do -it -this -way -to -avoid -an -alloc -but -also -to -make -sure -/ -/ -the -exactness -of -literals -is -kept -( -or -not -) -. -if -prefix -{ -self -. -keep_first_bytes -( -fix -. -len -( -) -) -; -} -else -{ -self -. -keep_last_bytes -( -fix -. -len -( -) -) -; -} -self -. -dedup -( -) -; -assert_eq -! -( -Some -( -1 -) -self -. -len -( -) -) -; -/ -/ -We -still -fall -through -here -. -In -particular -we -want -our -/ -/ -longest -common -prefix -to -be -subject -to -the -poison -check -. -} -} -/ -/ -If -we -have -an -exact -sequence -we -* -probably -* -just -want -to -keep -it -/ -/ -as -- -is -. -But -there -are -some -cases -where -we -don -' -t -. -So -we -save -a -copy -of -/ -/ -the -exact -sequence -now -and -then -try -to -do -some -more -optimizations -/ -/ -below -. -If -those -don -' -t -work -out -we -go -back -to -this -exact -sequence -. -/ -/ -/ -/ -The -specific -motivation -for -this -is -that -we -sometimes -wind -up -with -/ -/ -an -exact -sequence -with -a -hefty -number -of -literals -. -Say -100 -. -If -we -/ -/ -stuck -with -that -it -would -be -too -big -for -Teddy -and -would -result -in -/ -/ -using -Aho -- -Corasick -. -Which -is -fine -. -. -. -but -the -lazy -DFA -is -plenty -/ -/ -suitable -in -such -cases -. -The -real -issue -is -that -we -will -wind -up -not -/ -/ -using -a -fast -prefilter -at -all -. -So -in -cases -like -this -even -though -/ -/ -we -have -an -exact -sequence -it -would -be -better -to -try -and -shrink -the -/ -/ -sequence -( -which -we -do -below -) -and -use -it -as -a -prefilter -that -can -/ -/ -produce -false -positive -matches -. -/ -/ -/ -/ -But -if -the -shrinking -below -results -in -a -sequence -that -" -sucks -" -then -/ -/ -we -don -' -t -want -to -use -that -because -we -already -have -an -exact -sequence -/ -/ -in -hand -. -let -exact -: -Option -< -Seq -> -= -if -self -. -is_exact -( -) -{ -Some -( -self -. -clone -( -) -) -} -else -{ -None -} -; -/ -/ -Now -we -attempt -to -shorten -the -sequence -. -The -idea -here -is -that -we -/ -/ -don -' -t -want -to -look -for -too -many -literals -but -we -want -to -shorten -/ -/ -our -sequence -enough -to -improve -our -odds -of -using -better -algorithms -/ -/ -downstream -( -such -as -Teddy -) -. -/ -/ -/ -/ -The -pair -of -numbers -in -this -list -corresponds -to -the -maximal -prefix -/ -/ -( -in -bytes -) -to -keep -for -all -literals -and -the -length -of -the -sequence -/ -/ -at -which -to -do -it -. -/ -/ -/ -/ -So -for -example -the -pair -( -3 -500 -) -would -mean -" -if -we -have -more -than -/ -/ -500 -literals -in -our -sequence -then -truncate -all -of -our -literals -/ -/ -such -that -they -are -at -most -3 -bytes -in -length -and -the -minimize -the -/ -/ -sequence -. -" -const -ATTEMPTS -: -[ -( -usize -usize -) -; -5 -] -= -[ -( -5 -10 -) -( -4 -10 -) -( -3 -64 -) -( -2 -64 -) -( -1 -10 -) -] -; -for -( -keep -limit -) -in -ATTEMPTS -{ -let -len -= -match -self -. -len -( -) -{ -None -= -> -break -Some -( -len -) -= -> -len -} -; -if -len -< -= -limit -{ -break -; -} -if -prefix -{ -self -. -keep_first_bytes -( -keep -) -; -} -else -{ -self -. -keep_last_bytes -( -keep -) -; -} -if -prefix -{ -if -let -Some -( -ref -mut -lits -) -= -self -. -literals -{ -PreferenceTrie -: -: -minimize -( -lits -true -) -; -} -} -} -/ -/ -Check -for -a -poison -literal -. -A -poison -literal -is -one -that -is -short -/ -/ -and -is -believed -to -have -a -very -high -match -count -. -These -poisons -/ -/ -generally -lead -to -a -prefilter -with -a -very -high -false -positive -rate -/ -/ -and -thus -overall -worse -performance -. -/ -/ -/ -/ -We -do -this -last -because -we -could -have -gone -from -a -non -- -poisonous -/ -/ -sequence -to -a -poisonous -one -. -Perhaps -we -should -add -some -code -to -/ -/ -prevent -such -transitions -in -the -first -place -but -then -again -we -/ -/ -likely -only -made -the -transition -in -the -first -place -if -the -sequence -/ -/ -was -itself -huge -. -And -huge -sequences -are -themselves -poisonous -. -So -. -. -. -if -let -Some -( -lits -) -= -self -. -literals -( -) -{ -if -lits -. -iter -( -) -. -any -( -| -lit -| -lit -. -is_poisonous -( -) -) -{ -self -. -make_infinite -( -) -; -} -} -/ -/ -OK -if -we -had -an -exact -sequence -before -attempting -more -optimizations -/ -/ -above -and -our -post -- -optimized -sequence -sucks -for -some -reason -or -/ -/ -another -then -we -go -back -to -the -exact -sequence -. -if -let -Some -( -exact -) -= -exact -{ -/ -/ -If -optimizing -resulted -in -dropping -our -literals -then -certainly -/ -/ -backup -and -use -the -exact -sequence -that -we -had -. -if -! -self -. -is_finite -( -) -{ -* -self -= -exact -; -return -; -} -/ -/ -If -our -optimized -sequence -contains -a -short -literal -then -it -' -s -/ -/ -* -probably -* -not -so -great -. -So -throw -it -away -and -revert -to -the -/ -/ -exact -sequence -. -if -self -. -min_literal_len -( -) -. -map_or -( -true -| -len -| -len -< -= -2 -) -{ -* -self -= -exact -; -return -; -} -/ -/ -Finally -if -our -optimized -sequence -is -" -big -" -( -i -. -e -. -can -' -t -use -/ -/ -Teddy -) -then -also -don -' -t -use -it -and -rely -on -the -exact -sequence -. -if -self -. -len -( -) -. -map_or -( -true -| -len -| -len -> -64 -) -{ -* -self -= -exact -; -return -; -} -} -} -} -impl -core -: -: -fmt -: -: -Debug -for -Seq -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -Seq -" -) -? -; -if -let -Some -( -lits -) -= -self -. -literals -( -) -{ -f -. -debug_list -( -) -. -entries -( -lits -. -iter -( -) -) -. -finish -( -) -} -else -{ -write -! -( -f -" -[ -] -" -) -} -} -} -impl -FromIterator -< -Literal -> -for -Seq -{ -fn -from_iter -< -T -: -IntoIterator -< -Item -= -Literal -> -> -( -it -: -T -) -- -> -Seq -{ -let -mut -seq -= -Seq -: -: -empty -( -) -; -for -literal -in -it -{ -seq -. -push -( -literal -) -; -} -seq -} -} -/ -/ -/ -A -single -literal -extracted -from -an -[ -Hir -] -expression -. -/ -/ -/ -/ -/ -/ -A -literal -is -composed -of -two -things -: -/ -/ -/ -/ -/ -/ -* -A -sequence -of -bytes -. -No -guarantees -with -respect -to -UTF -- -8 -are -provided -. -/ -/ -/ -In -particular -even -if -the -regex -a -literal -is -extracted -from -is -UTF -- -8 -the -/ -/ -/ -literal -extracted -may -not -be -valid -UTF -- -8 -. -( -For -example -if -an -[ -Extractor -] -/ -/ -/ -limit -resulted -in -trimming -a -literal -in -a -way -that -splits -a -codepoint -. -) -/ -/ -/ -* -Whether -the -literal -is -" -exact -" -or -not -. -An -" -exact -" -literal -means -that -it -/ -/ -/ -has -not -been -trimmed -and -may -continue -to -be -extended -. -If -a -literal -is -/ -/ -/ -" -exact -" -after -visiting -the -entire -Hir -expression -then -this -implies -that -/ -/ -/ -the -literal -leads -to -a -match -state -. -( -Although -it -doesn -' -t -necessarily -imply -/ -/ -/ -all -occurrences -of -the -literal -correspond -to -a -match -of -the -regex -since -/ -/ -/ -literal -extraction -ignores -look -- -around -assertions -. -) -# -[ -derive -( -Clone -Eq -PartialEq -PartialOrd -Ord -) -] -pub -struct -Literal -{ -bytes -: -Vec -< -u8 -> -exact -: -bool -} -impl -Literal -{ -/ -/ -/ -Returns -a -new -exact -literal -containing -the -bytes -given -. -# -[ -inline -] -pub -fn -exact -< -B -: -Into -< -Vec -< -u8 -> -> -> -( -bytes -: -B -) -- -> -Literal -{ -Literal -{ -bytes -: -bytes -. -into -( -) -exact -: -true -} -} -/ -/ -/ -Returns -a -new -inexact -literal -containing -the -bytes -given -. -# -[ -inline -] -pub -fn -inexact -< -B -: -Into -< -Vec -< -u8 -> -> -> -( -bytes -: -B -) -- -> -Literal -{ -Literal -{ -bytes -: -bytes -. -into -( -) -exact -: -false -} -} -/ -/ -/ -Returns -the -bytes -in -this -literal -. -# -[ -inline -] -pub -fn -as_bytes -( -& -self -) -- -> -& -[ -u8 -] -{ -& -self -. -bytes -} -/ -/ -/ -Yields -ownership -of -the -bytes -inside -this -literal -. -/ -/ -/ -/ -/ -/ -Note -that -this -throws -away -whether -the -literal -is -" -exact -" -or -not -. -# -[ -inline -] -pub -fn -into_bytes -( -self -) -- -> -Vec -< -u8 -> -{ -self -. -bytes -} -/ -/ -/ -Returns -the -length -of -this -literal -in -bytes -. -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -as_bytes -( -) -. -len -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -literal -has -zero -bytes -. -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -len -( -) -= -= -0 -} -/ -/ -/ -Returns -true -if -and -only -if -this -literal -is -exact -. -# -[ -inline -] -pub -fn -is_exact -( -& -self -) -- -> -bool -{ -self -. -exact -} -/ -/ -/ -Marks -this -literal -as -inexact -. -/ -/ -/ -/ -/ -/ -Inexact -literals -can -never -be -extended -. -For -example -/ -/ -/ -[ -Seq -: -: -cross_forward -] -will -not -extend -inexact -literals -. -# -[ -inline -] -pub -fn -make_inexact -( -& -mut -self -) -{ -self -. -exact -= -false -; -} -/ -/ -/ -Reverse -the -bytes -in -this -literal -. -# -[ -inline -] -pub -fn -reverse -( -& -mut -self -) -{ -self -. -bytes -. -reverse -( -) -; -} -/ -/ -/ -Extend -this -literal -with -the -literal -given -. -/ -/ -/ -/ -/ -/ -If -this -literal -is -inexact -then -this -is -a -no -- -op -. -# -[ -inline -] -pub -fn -extend -( -& -mut -self -lit -: -& -Literal -) -{ -if -! -self -. -is_exact -( -) -{ -return -; -} -self -. -bytes -. -extend_from_slice -( -& -lit -. -bytes -) -; -} -/ -/ -/ -Trims -this -literal -such -that -only -the -first -len -bytes -remain -. -If -/ -/ -/ -this -literal -has -fewer -than -len -bytes -then -it -remains -unchanged -. -/ -/ -/ -Otherwise -the -literal -is -marked -as -inexact -. -# -[ -inline -] -pub -fn -keep_first_bytes -( -& -mut -self -len -: -usize -) -{ -if -len -> -= -self -. -len -( -) -{ -return -; -} -self -. -make_inexact -( -) -; -self -. -bytes -. -truncate -( -len -) -; -} -/ -/ -/ -Trims -this -literal -such -that -only -the -last -len -bytes -remain -. -If -this -/ -/ -/ -literal -has -fewer -than -len -bytes -then -it -remains -unchanged -. -/ -/ -/ -Otherwise -the -literal -is -marked -as -inexact -. -# -[ -inline -] -pub -fn -keep_last_bytes -( -& -mut -self -len -: -usize -) -{ -if -len -> -= -self -. -len -( -) -{ -return -; -} -self -. -make_inexact -( -) -; -self -. -bytes -. -drain -( -. -. -self -. -len -( -) -- -len -) -; -} -/ -/ -/ -Returns -true -if -it -is -believe -that -this -literal -is -likely -to -match -very -/ -/ -/ -frequently -and -is -thus -not -a -good -candidate -for -a -prefilter -. -fn -is_poisonous -( -& -self -) -- -> -bool -{ -self -. -is_empty -( -) -| -| -( -self -. -len -( -) -= -= -1 -& -& -rank -( -self -. -as_bytes -( -) -[ -0 -] -) -> -= -250 -) -} -} -impl -From -< -u8 -> -for -Literal -{ -fn -from -( -byte -: -u8 -) -- -> -Literal -{ -Literal -: -: -exact -( -vec -! -[ -byte -] -) -} -} -impl -From -< -char -> -for -Literal -{ -fn -from -( -ch -: -char -) -- -> -Literal -{ -use -alloc -: -: -string -: -: -ToString -; -Literal -: -: -exact -( -ch -. -encode_utf8 -( -& -mut -[ -0 -; -4 -] -) -. -to_string -( -) -) -} -} -impl -AsRef -< -[ -u8 -] -> -for -Literal -{ -fn -as_ref -( -& -self -) -- -> -& -[ -u8 -] -{ -self -. -as_bytes -( -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -Literal -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -tag -= -if -self -. -exact -{ -" -E -" -} -else -{ -" -I -" -} -; -f -. -debug_tuple -( -tag -) -. -field -( -& -crate -: -: -debug -: -: -Bytes -( -self -. -as_bytes -( -) -) -) -. -finish -( -) -} -} -/ -/ -/ -A -" -preference -" -trie -that -rejects -literals -that -will -never -match -when -/ -/ -/ -executing -a -leftmost -first -or -" -preference -" -search -. -/ -/ -/ -/ -/ -/ -For -example -if -' -sam -' -is -inserted -then -trying -to -insert -' -samwise -' -will -be -/ -/ -/ -rejected -because -' -samwise -' -can -never -match -since -' -sam -' -will -always -take -/ -/ -/ -priority -. -However -if -' -samwise -' -is -inserted -first -then -inserting -' -sam -' -/ -/ -/ -after -it -is -accepted -. -In -this -case -either -' -samwise -' -or -' -sam -' -can -match -in -/ -/ -/ -a -" -preference -" -search -. -/ -/ -/ -/ -/ -/ -Note -that -we -only -use -this -trie -as -a -" -set -. -" -That -is -given -a -sequence -of -/ -/ -/ -literals -we -insert -each -one -in -order -. -An -insert -will -reject -a -literal -/ -/ -/ -if -a -prefix -of -that -literal -already -exists -in -the -trie -. -Thus -to -rebuild -/ -/ -/ -the -" -minimal -" -sequence -we -simply -only -keep -literals -that -were -successfully -/ -/ -/ -inserted -. -( -Since -we -don -' -t -need -traversal -one -wonders -whether -we -can -make -/ -/ -/ -some -simplifications -here -but -I -haven -' -t -given -it -a -ton -of -thought -and -I -' -ve -/ -/ -/ -never -seen -this -show -up -on -a -profile -. -Because -of -the -heuristic -limits -/ -/ -/ -imposed -on -literal -extractions -the -size -of -the -inputs -here -is -usually -/ -/ -/ -very -small -. -) -# -[ -derive -( -Debug -) -] -struct -PreferenceTrie -{ -/ -/ -/ -The -states -in -this -trie -. -The -index -of -a -state -in -this -vector -is -its -ID -. -states -: -Vec -< -State -> -/ -/ -/ -This -vec -indicates -which -states -are -match -states -. -It -always -has -/ -/ -/ -the -same -length -as -states -and -is -indexed -by -the -same -state -ID -. -/ -/ -/ -A -state -with -identifier -sid -is -a -match -state -if -and -only -if -/ -/ -/ -matches -[ -sid -] -. -is_some -( -) -. -The -option -contains -the -index -of -the -literal -/ -/ -/ -corresponding -to -the -match -. -The -index -is -offset -by -1 -so -that -it -fits -in -/ -/ -/ -a -NonZeroUsize -. -matches -: -Vec -< -Option -< -NonZeroUsize -> -> -/ -/ -/ -The -index -to -allocate -to -the -next -literal -added -to -this -trie -. -Starts -at -/ -/ -/ -1 -and -increments -by -1 -for -every -literal -successfully -added -to -the -trie -. -next_literal_index -: -usize -} -/ -/ -/ -A -single -state -in -a -trie -. -Uses -a -sparse -representation -for -its -transitions -. -# -[ -derive -( -Debug -Default -) -] -struct -State -{ -/ -/ -/ -Sparse -representation -of -the -transitions -out -of -this -state -. -Transitions -/ -/ -/ -are -sorted -by -byte -. -There -is -at -most -one -such -transition -for -any -/ -/ -/ -particular -byte -. -trans -: -Vec -< -( -u8 -usize -) -> -} -impl -PreferenceTrie -{ -/ -/ -/ -Minimizes -the -given -sequence -of -literals -while -preserving -preference -/ -/ -/ -order -semantics -. -/ -/ -/ -/ -/ -/ -When -keep_exact -is -true -the -exactness -of -every -literal -retained -is -/ -/ -/ -kept -. -This -is -useful -when -dealing -with -a -fully -extracted -Seq -that -/ -/ -/ -only -contains -exact -literals -. -In -that -case -we -can -keep -all -retained -/ -/ -/ -literals -as -exact -because -we -know -we -' -ll -never -need -to -match -anything -/ -/ -/ -after -them -and -because -any -removed -literals -are -guaranteed -to -never -/ -/ -/ -match -. -fn -minimize -( -literals -: -& -mut -Vec -< -Literal -> -keep_exact -: -bool -) -{ -use -core -: -: -cell -: -: -RefCell -; -/ -/ -MSRV -( -1 -. -61 -) -: -Use -retain_mut -here -to -avoid -interior -mutability -. -let -trie -= -RefCell -: -: -new -( -PreferenceTrie -{ -states -: -vec -! -[ -] -matches -: -vec -! -[ -] -next_literal_index -: -1 -} -) -; -let -mut -make_inexact -= -vec -! -[ -] -; -literals -. -retain -( -| -lit -| -{ -match -trie -. -borrow_mut -( -) -. -insert -( -lit -. -as_bytes -( -) -) -{ -Ok -( -_ -) -= -> -true -Err -( -i -) -= -> -{ -if -! -keep_exact -{ -make_inexact -. -push -( -i -. -checked_sub -( -1 -) -. -unwrap -( -) -) -; -} -false -} -} -} -) -; -for -i -in -make_inexact -{ -literals -[ -i -] -. -make_inexact -( -) -; -} -} -/ -/ -/ -Returns -Ok -if -the -given -byte -string -is -accepted -into -this -trie -and -/ -/ -/ -Err -otherwise -. -The -index -for -the -success -case -corresponds -to -the -/ -/ -/ -index -of -the -literal -added -. -The -index -for -the -error -case -corresponds -to -/ -/ -/ -the -index -of -the -literal -already -in -the -trie -that -prevented -the -given -/ -/ -/ -byte -string -from -being -added -. -( -Which -implies -it -is -a -prefix -of -the -one -/ -/ -/ -given -. -) -/ -/ -/ -/ -/ -/ -In -short -the -byte -string -given -is -accepted -into -the -trie -if -and -only -/ -/ -/ -if -it -is -possible -for -it -to -match -when -executing -a -preference -order -/ -/ -/ -search -. -fn -insert -( -& -mut -self -bytes -: -& -[ -u8 -] -) -- -> -Result -< -usize -usize -> -{ -let -mut -prev -= -self -. -root -( -) -; -if -let -Some -( -idx -) -= -self -. -matches -[ -prev -] -{ -return -Err -( -idx -. -get -( -) -) -; -} -for -& -b -in -bytes -. -iter -( -) -{ -match -self -. -states -[ -prev -] -. -trans -. -binary_search_by_key -( -& -b -| -t -| -t -. -0 -) -{ -Ok -( -i -) -= -> -{ -prev -= -self -. -states -[ -prev -] -. -trans -[ -i -] -. -1 -; -if -let -Some -( -idx -) -= -self -. -matches -[ -prev -] -{ -return -Err -( -idx -. -get -( -) -) -; -} -} -Err -( -i -) -= -> -{ -let -next -= -self -. -create_state -( -) -; -self -. -states -[ -prev -] -. -trans -. -insert -( -i -( -b -next -) -) -; -prev -= -next -; -} -} -} -let -idx -= -self -. -next_literal_index -; -self -. -next_literal_index -+ -= -1 -; -self -. -matches -[ -prev -] -= -NonZeroUsize -: -: -new -( -idx -) -; -Ok -( -idx -) -} -/ -/ -/ -Returns -the -root -state -ID -and -if -it -doesn -' -t -exist -creates -it -. -fn -root -( -& -mut -self -) -- -> -usize -{ -if -! -self -. -states -. -is_empty -( -) -{ -0 -} -else -{ -self -. -create_state -( -) -} -} -/ -/ -/ -Creates -a -new -empty -state -and -returns -its -ID -. -fn -create_state -( -& -mut -self -) -- -> -usize -{ -let -id -= -self -. -states -. -len -( -) -; -self -. -states -. -push -( -State -: -: -default -( -) -) -; -self -. -matches -. -push -( -None -) -; -id -} -} -/ -/ -/ -Returns -the -" -rank -" -of -the -given -byte -. -/ -/ -/ -/ -/ -/ -The -minimum -rank -value -is -0 -and -the -maximum -rank -value -is -255 -. -/ -/ -/ -/ -/ -/ -The -rank -of -a -byte -is -derived -from -a -heuristic -background -distribution -of -/ -/ -/ -relative -frequencies -of -bytes -. -The -heuristic -says -that -lower -the -rank -of -a -/ -/ -/ -byte -the -less -likely -that -byte -is -to -appear -in -any -arbitrary -haystack -. -pub -fn -rank -( -byte -: -u8 -) -- -> -u8 -{ -crate -: -: -rank -: -: -BYTE_FREQUENCIES -[ -usize -: -: -from -( -byte -) -] -} -# -[ -cfg -( -test -) -] -mod -tests -{ -use -super -: -: -* -; -fn -parse -( -pattern -: -& -str -) -- -> -Hir -{ -crate -: -: -ParserBuilder -: -: -new -( -) -. -utf8 -( -false -) -. -build -( -) -. -parse -( -pattern -) -. -unwrap -( -) -} -fn -prefixes -( -pattern -: -& -str -) -- -> -Seq -{ -Extractor -: -: -new -( -) -. -kind -( -ExtractKind -: -: -Prefix -) -. -extract -( -& -parse -( -pattern -) -) -} -fn -suffixes -( -pattern -: -& -str -) -- -> -Seq -{ -Extractor -: -: -new -( -) -. -kind -( -ExtractKind -: -: -Suffix -) -. -extract -( -& -parse -( -pattern -) -) -} -fn -e -( -pattern -: -& -str -) -- -> -( -Seq -Seq -) -{ -( -prefixes -( -pattern -) -suffixes -( -pattern -) -) -} -# -[ -allow -( -non_snake_case -) -] -fn -E -( -x -: -& -str -) -- -> -Literal -{ -Literal -: -: -exact -( -x -. -as_bytes -( -) -) -} -# -[ -allow -( -non_snake_case -) -] -fn -I -( -x -: -& -str -) -- -> -Literal -{ -Literal -: -: -inexact -( -x -. -as_bytes -( -) -) -} -fn -seq -< -I -: -IntoIterator -< -Item -= -Literal -> -> -( -it -: -I -) -- -> -Seq -{ -Seq -: -: -from_iter -( -it -) -} -fn -infinite -( -) -- -> -( -Seq -Seq -) -{ -( -Seq -: -: -infinite -( -) -Seq -: -: -infinite -( -) -) -} -fn -inexact -< -I1 -I2 -> -( -it1 -: -I1 -it2 -: -I2 -) -- -> -( -Seq -Seq -) -where -I1 -: -IntoIterator -< -Item -= -Literal -> -I2 -: -IntoIterator -< -Item -= -Literal -> -{ -( -Seq -: -: -from_iter -( -it1 -) -Seq -: -: -from_iter -( -it2 -) -) -} -fn -exact -< -B -: -AsRef -< -[ -u8 -] -> -I -: -IntoIterator -< -Item -= -B -> -> -( -it -: -I -) -- -> -( -Seq -Seq -) -{ -let -s1 -= -Seq -: -: -new -( -it -) -; -let -s2 -= -s1 -. -clone -( -) -; -( -s1 -s2 -) -} -fn -opt -< -B -: -AsRef -< -[ -u8 -] -> -I -: -IntoIterator -< -Item -= -B -> -> -( -it -: -I -) -- -> -( -Seq -Seq -) -{ -let -( -mut -p -mut -s -) -= -exact -( -it -) -; -p -. -optimize_for_prefix_by_preference -( -) -; -s -. -optimize_for_suffix_by_preference -( -) -; -( -p -s -) -} -# -[ -test -] -fn -literal -( -) -{ -assert_eq -! -( -exact -( -[ -" -a -" -] -) -e -( -" -a -" -) -) -; -assert_eq -! -( -exact -( -[ -" -aaaaa -" -] -) -e -( -" -aaaaa -" -) -) -; -assert_eq -! -( -exact -( -[ -" -A -" -" -a -" -] -) -e -( -" -( -? -i -- -u -) -a -" -) -) -; -assert_eq -! -( -exact -( -[ -" -AB -" -" -Ab -" -" -aB -" -" -ab -" -] -) -e -( -" -( -? -i -- -u -) -ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abC -" -" -abc -" -] -) -e -( -" -ab -( -? -i -- -u -) -c -" -) -) -; -assert_eq -! -( -exact -( -[ -b -" -\ -xFF -" -] -) -e -( -r -" -( -? -- -u -: -\ -xFF -) -" -) -) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -{ -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -" -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -" -( -? -i -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -" -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -" -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -" -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -" -" -] -) -e -( -" -( -? -i -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -" -" -] -) -e -( -" -( -? -i -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -S -" -" -s -" -" -" -] -) -e -( -" -( -? -i -) -S -" -) -) -; -assert_eq -! -( -exact -( -[ -" -S -" -" -s -" -" -" -] -) -e -( -" -( -? -i -) -s -" -) -) -; -assert_eq -! -( -exact -( -[ -" -S -" -" -s -" -" -" -] -) -e -( -" -( -? -i -) -" -) -) -; -} -let -letters -= -" -" -; -assert_eq -! -( -exact -( -[ -letters -] -) -e -( -letters -) -) -; -} -# -[ -test -] -fn -class -( -) -{ -assert_eq -! -( -exact -( -[ -" -a -" -" -b -" -" -c -" -] -) -e -( -" -[ -abc -] -" -) -) -; -assert_eq -! -( -exact -( -[ -" -a1b -" -" -a2b -" -" -a3b -" -] -) -e -( -" -a -[ -123 -] -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -" -" -] -) -e -( -" -[ -] -" -) -) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -{ -assert_eq -! -( -exact -( -[ -" -" -" -" -" -" -" -" -" -" -] -) -e -( -r -" -( -? -i -) -[ -] -" -) -) -; -} -} -# -[ -test -] -fn -look -( -) -{ -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -a -\ -Ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -a -\ -zb -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -a -( -? -m -: -^ -) -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -a -( -? -m -: -) -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -a -\ -bb -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -a -\ -Bb -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -a -( -? -- -u -: -\ -b -) -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -a -( -? -- -u -: -\ -B -) -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -^ -ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -( -? -m -: -^ -) -ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -( -? -m -: -) -ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -\ -bab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -\ -Bab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -( -? -- -u -: -\ -b -) -ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -( -? -- -u -: -\ -B -) -ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -^ -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -( -? -m -: -^ -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -( -? -m -: -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -\ -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -\ -B -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -( -? -- -u -: -\ -b -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -ab -( -? -- -u -: -\ -B -) -" -) -) -; -let -expected -= -( -seq -( -[ -I -( -" -aZ -" -) -E -( -" -ab -" -) -] -) -seq -( -[ -I -( -" -Zb -" -) -E -( -" -ab -" -) -] -) -) -; -assert_eq -! -( -expected -e -( -r -" -^ -aZ -* -b -" -) -) -; -} -# -[ -test -] -fn -repetition -( -) -{ -assert_eq -! -( -exact -( -[ -" -a -" -" -" -] -) -e -( -r -" -a -? -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -" -a -" -] -) -e -( -r -" -a -? -? -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -E -( -" -" -) -] -[ -I -( -" -a -" -) -E -( -" -" -) -] -) -e -( -r -" -a -* -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -" -) -I -( -" -a -" -) -] -[ -E -( -" -" -) -I -( -" -a -" -) -] -) -e -( -r -" -a -* -? -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -] -[ -I -( -" -a -" -) -] -) -e -( -r -" -a -+ -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -] -[ -I -( -" -a -" -) -] -) -e -( -r -" -( -a -+ -) -+ -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -] -) -e -( -r -" -aZ -{ -0 -} -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -aZb -" -" -ab -" -] -) -e -( -r -" -aZ -? -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -ab -" -" -aZb -" -] -) -e -( -r -" -aZ -? -? -b -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -aZ -" -) -E -( -" -ab -" -) -] -[ -I -( -" -Zb -" -) -E -( -" -ab -" -) -] -) -e -( -r -" -aZ -* -b -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -ab -" -) -I -( -" -aZ -" -) -] -[ -E -( -" -ab -" -) -I -( -" -Zb -" -) -] -) -e -( -r -" -aZ -* -? -b -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -aZ -" -) -] -[ -I -( -" -Zb -" -) -] -) -e -( -r -" -aZ -+ -b -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -aZ -" -) -] -[ -I -( -" -Zb -" -) -] -) -e -( -r -" -aZ -+ -? -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -aZZb -" -] -) -e -( -r -" -aZ -{ -2 -} -b -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -aZZ -" -) -] -[ -I -( -" -ZZb -" -) -] -) -e -( -r -" -aZ -{ -2 -3 -} -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abc -" -" -" -] -) -e -( -r -" -( -abc -) -? -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -" -abc -" -] -) -e -( -r -" -( -abc -) -? -? -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -E -( -" -b -" -) -] -[ -I -( -" -ab -" -) -E -( -" -b -" -) -] -) -e -( -r -" -a -* -b -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -b -" -) -I -( -" -a -" -) -] -[ -E -( -" -b -" -) -I -( -" -ab -" -) -] -) -e -( -r -" -a -* -? -b -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -ab -" -) -] -[ -I -( -" -b -" -) -] -) -e -( -r -" -ab -+ -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -] -[ -I -( -" -b -" -) -] -) -e -( -r -" -a -* -b -+ -" -) -) -; -/ -/ -FIXME -: -The -suffixes -for -this -don -' -t -look -quite -right -to -me -. -I -think -/ -/ -the -right -suffixes -would -be -: -[ -I -( -ac -) -I -( -bc -) -E -( -c -) -] -. -The -main -issue -I -/ -/ -think -is -that -suffixes -are -computed -by -iterating -over -concatenations -/ -/ -in -reverse -and -then -[ -bc -ac -c -] -ordering -is -indeed -correct -from -/ -/ -that -perspective -. -We -also -test -a -few -more -equivalent -regexes -and -/ -/ -we -get -the -same -result -so -it -is -consistent -at -least -I -suppose -. -/ -/ -/ -/ -The -reason -why -this -isn -' -t -an -issue -is -that -it -only -messes -up -/ -/ -preference -order -and -currently -suffixes -are -never -used -in -a -/ -/ -context -where -preference -order -matters -. -For -prefixes -it -matters -/ -/ -because -we -sometimes -want -to -use -prefilters -without -confirmation -/ -/ -when -all -of -the -literals -are -exact -( -and -there -' -s -no -look -- -around -) -. -But -/ -/ -we -never -do -that -for -suffixes -. -Any -time -we -use -suffixes -we -always -/ -/ -include -a -confirmation -step -. -If -that -ever -changes -then -it -' -s -likely -/ -/ -this -bug -will -need -to -be -fixed -but -last -time -I -looked -it -appears -/ -/ -hard -to -do -so -. -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -E -( -" -c -" -) -] -[ -I -( -" -bc -" -) -I -( -" -ac -" -) -E -( -" -c -" -) -] -) -e -( -r -" -a -* -b -* -c -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -E -( -" -c -" -) -] -[ -I -( -" -bc -" -) -I -( -" -ac -" -) -E -( -" -c -" -) -] -) -e -( -r -" -( -a -+ -) -? -( -b -+ -) -? -c -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -E -( -" -c -" -) -] -[ -I -( -" -bc -" -) -I -( -" -ac -" -) -E -( -" -c -" -) -] -) -e -( -r -" -( -a -+ -| -) -( -b -+ -| -) -c -" -) -) -; -/ -/ -A -few -more -similarish -but -not -identical -regexes -. -These -may -have -a -/ -/ -similar -problem -as -above -. -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -I -( -" -c -" -) -E -( -" -" -) -] -[ -I -( -" -c -" -) -I -( -" -b -" -) -I -( -" -a -" -) -E -( -" -" -) -] -) -e -( -r -" -a -* -b -* -c -* -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -I -( -" -c -" -) -] -[ -I -( -" -c -" -) -] -) -e -( -r -" -a -* -b -* -c -+ -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -] -[ -I -( -" -bc -" -) -] -) -e -( -r -" -a -* -b -+ -c -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -] -[ -I -( -" -c -" -) -I -( -" -b -" -) -] -) -e -( -r -" -a -* -b -+ -c -* -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -ab -" -) -E -( -" -a -" -) -] -[ -I -( -" -b -" -) -E -( -" -a -" -) -] -) -e -( -r -" -ab -* -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -ab -" -) -E -( -" -ac -" -) -] -[ -I -( -" -bc -" -) -E -( -" -ac -" -) -] -) -e -( -r -" -ab -* -c -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -ab -" -) -] -[ -I -( -" -b -" -) -] -) -e -( -r -" -ab -+ -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -ab -" -) -] -[ -I -( -" -bc -" -) -] -) -e -( -r -" -ab -+ -c -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -z -" -) -E -( -" -azb -" -) -] -[ -I -( -" -zazb -" -) -E -( -" -azb -" -) -] -) -e -( -r -" -z -* -azb -" -) -) -; -let -expected -= -exact -( -[ -" -aaa -" -" -aab -" -" -aba -" -" -abb -" -" -baa -" -" -bab -" -" -bba -" -" -bbb -" -] -) -; -assert_eq -! -( -expected -e -( -r -" -[ -ab -] -{ -3 -} -" -) -) -; -let -expected -= -inexact -( -[ -I -( -" -aaa -" -) -I -( -" -aab -" -) -I -( -" -aba -" -) -I -( -" -abb -" -) -I -( -" -baa -" -) -I -( -" -bab -" -) -I -( -" -bba -" -) -I -( -" -bbb -" -) -] -[ -I -( -" -aaa -" -) -I -( -" -aab -" -) -I -( -" -aba -" -) -I -( -" -abb -" -) -I -( -" -baa -" -) -I -( -" -bab -" -) -I -( -" -bba -" -) -I -( -" -bbb -" -) -] -) -; -assert_eq -! -( -expected -e -( -r -" -[ -ab -] -{ -3 -4 -} -" -) -) -; -} -# -[ -test -] -fn -concat -( -) -{ -let -empty -: -[ -& -str -; -0 -] -= -[ -] -; -assert_eq -! -( -exact -( -[ -" -abcxyz -" -] -) -e -( -r -" -abc -( -) -xyz -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abcxyz -" -] -) -e -( -r -" -( -abc -) -( -xyz -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abcmnoxyz -" -] -) -e -( -r -" -abc -( -) -mno -( -) -xyz -" -) -) -; -assert_eq -! -( -exact -( -empty -) -e -( -r -" -abc -[ -a -& -& -b -] -xyz -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abcxyz -" -] -) -e -( -r -" -abc -[ -a -& -& -b -] -* -xyz -" -) -) -; -} -# -[ -test -] -fn -alternation -( -) -{ -assert_eq -! -( -exact -( -[ -" -abc -" -" -mno -" -" -xyz -" -] -) -e -( -r -" -abc -| -mno -| -xyz -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -abc -" -) -I -( -" -mZ -" -) -E -( -" -mo -" -) -E -( -" -xyz -" -) -] -[ -E -( -" -abc -" -) -I -( -" -Zo -" -) -E -( -" -mo -" -) -E -( -" -xyz -" -) -] -) -e -( -r -" -abc -| -mZ -* -o -| -xyz -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abc -" -" -xyz -" -] -) -e -( -r -" -abc -| -M -[ -a -& -& -b -] -N -| -xyz -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abc -" -" -MN -" -" -xyz -" -] -) -e -( -r -" -abc -| -M -[ -a -& -& -b -] -* -N -| -xyz -" -) -) -; -assert_eq -! -( -exact -( -[ -" -aaa -" -" -aaaaa -" -] -) -e -( -r -" -( -? -: -| -aa -) -aaa -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -aaa -" -) -E -( -" -" -) -I -( -" -aaaaa -" -) -E -( -" -aa -" -) -] -[ -I -( -" -aaa -" -) -E -( -" -" -) -E -( -" -aa -" -) -] -) -e -( -r -" -( -? -: -| -aa -) -( -? -: -aaa -) -* -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -" -) -I -( -" -aaa -" -) -E -( -" -aa -" -) -I -( -" -aaaaa -" -) -] -[ -E -( -" -" -) -I -( -" -aaa -" -) -E -( -" -aa -" -) -] -) -e -( -r -" -( -? -: -| -aa -) -( -? -: -aaa -) -* -? -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -a -" -) -I -( -" -b -" -) -E -( -" -" -) -] -[ -E -( -" -a -" -) -I -( -" -b -" -) -E -( -" -" -) -] -) -e -( -r -" -a -| -b -* -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -a -" -) -I -( -" -b -" -) -] -[ -E -( -" -a -" -) -I -( -" -b -" -) -] -) -e -( -r -" -a -| -b -+ -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -E -( -" -b -" -) -E -( -" -c -" -) -] -[ -I -( -" -ab -" -) -E -( -" -b -" -) -E -( -" -c -" -) -] -) -e -( -r -" -a -* -b -| -c -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -a -" -) -E -( -" -b -" -) -I -( -" -c -" -) -E -( -" -" -) -] -[ -E -( -" -a -" -) -E -( -" -b -" -) -I -( -" -c -" -) -E -( -" -" -) -] -) -e -( -r -" -a -| -( -? -: -b -| -c -* -) -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -I -( -" -b -" -) -E -( -" -c -" -) -I -( -" -a -" -) -I -( -" -ab -" -) -E -( -" -c -" -) -] -[ -I -( -" -ac -" -) -I -( -" -bc -" -) -E -( -" -c -" -) -I -( -" -ac -" -) -I -( -" -abc -" -) -E -( -" -c -" -) -] -) -e -( -r -" -( -a -| -b -) -* -c -| -( -a -| -ab -) -* -c -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abef -" -" -abgh -" -" -cdef -" -" -cdgh -" -] -) -e -( -r -" -( -ab -| -cd -) -( -ef -| -gh -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -abefij -" -" -abefkl -" -" -abghij -" -" -abghkl -" -" -cdefij -" -" -cdefkl -" -" -cdghij -" -" -cdghkl -" -] -) -e -( -r -" -( -ab -| -cd -) -( -ef -| -gh -) -( -ij -| -kl -) -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -abab -" -) -] -[ -E -( -" -abab -" -) -] -) -e -( -r -" -( -ab -) -{ -2 -} -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -abab -" -) -] -[ -I -( -" -abab -" -) -] -) -e -( -r -" -( -ab -) -{ -2 -3 -} -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -abab -" -) -] -[ -I -( -" -abab -" -) -] -) -e -( -r -" -( -ab -) -{ -2 -} -" -) -) -; -} -# -[ -test -] -fn -impossible -( -) -{ -let -empty -: -[ -& -str -; -0 -] -= -[ -] -; -assert_eq -! -( -exact -( -empty -) -e -( -r -" -[ -a -& -& -b -] -" -) -) -; -assert_eq -! -( -exact -( -empty -) -e -( -r -" -a -[ -a -& -& -b -] -" -) -) -; -assert_eq -! -( -exact -( -empty -) -e -( -r -" -[ -a -& -& -b -] -b -" -) -) -; -assert_eq -! -( -exact -( -empty -) -e -( -r -" -a -[ -a -& -& -b -] -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -a -" -" -b -" -] -) -e -( -r -" -a -| -[ -a -& -& -b -] -| -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -a -" -" -b -" -] -) -e -( -r -" -a -| -c -[ -a -& -& -b -] -| -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -a -" -" -b -" -] -) -e -( -r -" -a -| -[ -a -& -& -b -] -d -| -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -a -" -" -b -" -] -) -e -( -r -" -a -| -c -[ -a -& -& -b -] -d -| -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -[ -a -& -& -b -] -* -" -) -) -; -assert_eq -! -( -exact -( -[ -" -MN -" -] -) -e -( -r -" -M -[ -a -& -& -b -] -* -N -" -) -) -; -} -/ -/ -This -tests -patterns -that -contain -something -that -defeats -literal -/ -/ -detection -usually -because -it -would -blow -some -limit -on -the -total -number -/ -/ -of -literals -that -can -be -returned -. -/ -/ -/ -/ -The -main -idea -is -that -when -literal -extraction -sees -something -that -/ -/ -it -knows -will -blow -a -limit -it -replaces -it -with -a -marker -that -says -/ -/ -" -any -literal -will -match -here -. -" -While -not -necessarily -true -the -/ -/ -over -- -estimation -is -just -fine -for -the -purposes -of -literal -extraction -/ -/ -because -the -imprecision -doesn -' -t -matter -: -too -big -is -too -big -. -/ -/ -/ -/ -This -is -one -of -the -trickier -parts -of -literal -extraction -since -we -need -/ -/ -to -make -sure -all -of -our -literal -extraction -operations -correctly -compose -/ -/ -with -the -markers -. -# -[ -test -] -fn -anything -( -) -{ -assert_eq -! -( -infinite -( -) -e -( -r -" -. -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -( -? -s -) -. -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -[ -A -- -Za -- -z -] -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -[ -A -- -Z -] -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -[ -A -- -Z -] -{ -0 -} -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -[ -A -- -Z -] -? -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -[ -A -- -Z -] -* -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -[ -A -- -Z -] -+ -" -) -) -; -assert_eq -! -( -( -seq -( -[ -I -( -" -1 -" -) -] -) -Seq -: -: -infinite -( -) -) -e -( -r -" -1 -[ -A -- -Z -] -" -) -) -; -assert_eq -! -( -( -seq -( -[ -I -( -" -1 -" -) -] -) -seq -( -[ -I -( -" -2 -" -) -] -) -) -e -( -r -" -1 -[ -A -- -Z -] -2 -" -) -) -; -assert_eq -! -( -( -Seq -: -: -infinite -( -) -seq -( -[ -I -( -" -123 -" -) -] -) -) -e -( -r -" -[ -A -- -Z -] -+ -123 -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -[ -A -- -Z -] -+ -123 -[ -A -- -Z -] -+ -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -1 -| -[ -A -- -Z -] -| -3 -" -) -) -; -assert_eq -! -( -( -seq -( -[ -E -( -" -1 -" -) -I -( -" -2 -" -) -E -( -" -3 -" -) -] -) -Seq -: -: -infinite -( -) -) -e -( -r -" -1 -| -2 -[ -A -- -Z -] -| -3 -" -) -) -; -assert_eq -! -( -( -Seq -: -: -infinite -( -) -seq -( -[ -E -( -" -1 -" -) -I -( -" -2 -" -) -E -( -" -3 -" -) -] -) -) -e -( -r -" -1 -| -[ -A -- -Z -] -2 -| -3 -" -) -) -; -assert_eq -! -( -( -seq -( -[ -E -( -" -1 -" -) -I -( -" -2 -" -) -E -( -" -4 -" -) -] -) -seq -( -[ -E -( -" -1 -" -) -I -( -" -3 -" -) -E -( -" -4 -" -) -] -) -) -e -( -r -" -1 -| -2 -[ -A -- -Z -] -3 -| -4 -" -) -) -; -assert_eq -! -( -( -Seq -: -: -infinite -( -) -seq -( -[ -I -( -" -2 -" -) -] -) -) -e -( -r -" -( -? -: -| -1 -) -[ -A -- -Z -] -2 -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -a -" -) -] -[ -I -( -" -z -" -) -] -) -e -( -r -" -a -. -z -" -) -) -; -} -/ -/ -Like -the -' -anything -' -test -but -it -uses -smaller -limits -in -order -to -test -/ -/ -the -logic -for -effectively -aborting -literal -extraction -when -the -seqs -get -/ -/ -too -big -. -# -[ -test -] -fn -anything_small_limits -( -) -{ -fn -prefixes -( -pattern -: -& -str -) -- -> -Seq -{ -Extractor -: -: -new -( -) -. -kind -( -ExtractKind -: -: -Prefix -) -. -limit_total -( -10 -) -. -extract -( -& -parse -( -pattern -) -) -} -fn -suffixes -( -pattern -: -& -str -) -- -> -Seq -{ -Extractor -: -: -new -( -) -. -kind -( -ExtractKind -: -: -Suffix -) -. -limit_total -( -10 -) -. -extract -( -& -parse -( -pattern -) -) -} -fn -e -( -pattern -: -& -str -) -- -> -( -Seq -Seq -) -{ -( -prefixes -( -pattern -) -suffixes -( -pattern -) -) -} -assert_eq -! -( -( -seq -( -[ -I -( -" -aaa -" -) -I -( -" -aab -" -) -I -( -" -aba -" -) -I -( -" -abb -" -) -I -( -" -baa -" -) -I -( -" -bab -" -) -I -( -" -bba -" -) -I -( -" -bbb -" -) -] -) -seq -( -[ -I -( -" -aaa -" -) -I -( -" -aab -" -) -I -( -" -aba -" -) -I -( -" -abb -" -) -I -( -" -baa -" -) -I -( -" -bab -" -) -I -( -" -bba -" -) -I -( -" -bbb -" -) -] -) -) -e -( -r -" -[ -ab -] -{ -3 -} -{ -3 -} -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -ab -| -cd -| -ef -| -gh -| -ij -| -kl -| -mn -| -op -| -qr -| -st -| -uv -| -wx -| -yz -" -) -) -; -} -# -[ -test -] -fn -empty -( -) -{ -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -^ -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -( -? -m -: -^ -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -( -? -m -: -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -\ -b -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -\ -B -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -( -? -- -u -: -\ -b -) -" -) -) -; -assert_eq -! -( -exact -( -[ -" -" -] -) -e -( -r -" -( -? -- -u -: -\ -B -) -" -) -) -; -} -# -[ -test -] -fn -odds_and_ends -( -) -{ -assert_eq -! -( -( -Seq -: -: -infinite -( -) -seq -( -[ -I -( -" -a -" -) -] -) -) -e -( -r -" -. -a -" -) -) -; -assert_eq -! -( -( -seq -( -[ -I -( -" -a -" -) -] -) -Seq -: -: -infinite -( -) -) -e -( -r -" -a -. -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -a -| -. -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -. -| -a -" -) -) -; -let -pat -= -r -" -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -" -; -let -expected -= -inexact -( -[ -" -Mo -' -am -" -" -Moam -" -" -Mu -' -am -" -" -Muam -" -] -. -map -( -I -) -[ -" -ddafi -" -" -ddafy -" -" -dhafi -" -" -dhafy -" -" -dzafi -" -" -dzafy -" -" -dafi -" -" -dafy -" -" -tdafi -" -" -tdafy -" -" -thafi -" -" -thafy -" -" -tzafi -" -" -tzafy -" -" -tafi -" -" -tafy -" -" -zdafi -" -" -zdafy -" -" -zhafi -" -" -zhafy -" -" -zzafi -" -" -zzafy -" -" -zafi -" -" -zafy -" -] -. -map -( -I -) -) -; -assert_eq -! -( -expected -e -( -pat -) -) -; -assert_eq -! -( -( -seq -( -[ -" -fn -is_ -" -" -fn -as_ -" -] -. -map -( -I -) -) -Seq -: -: -infinite -( -) -) -e -( -r -" -fn -is_ -( -[ -A -- -Z -] -+ -) -| -fn -as_ -( -[ -A -- -Z -] -+ -) -" -) -) -; -assert_eq -! -( -inexact -( -[ -I -( -" -foo -" -) -] -[ -I -( -" -quux -" -) -] -) -e -( -r -" -foo -[ -A -- -Z -] -+ -bar -[ -A -- -Z -] -+ -quux -" -) -) -; -assert_eq -! -( -infinite -( -) -e -( -r -" -[ -A -- -Z -] -+ -bar -[ -A -- -Z -] -+ -" -) -) -; -assert_eq -! -( -exact -( -[ -" -Sherlock -Holmes -" -] -) -e -( -r -" -( -? -m -) -^ -Sherlock -Holmes -| -Sherlock -Holmes -" -) -) -; -assert_eq -! -( -exact -( -[ -" -sa -" -" -sb -" -] -) -e -( -r -" -\ -bs -( -? -: -[ -ab -] -) -" -) -) -; -} -/ -/ -This -tests -a -specific -regex -along -with -some -heuristic -steps -to -reduce -/ -/ -the -sequences -extracted -. -This -is -meant -to -roughly -correspond -to -the -/ -/ -types -of -heuristics -used -to -shrink -literal -sets -in -practice -. -( -Shrinking -/ -/ -is -done -because -you -want -to -balance -" -spend -too -much -work -looking -for -/ -/ -too -many -literals -" -and -" -spend -too -much -work -processing -false -positive -/ -/ -matches -from -short -literals -. -" -) -# -[ -test -] -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -fn -holmes -( -) -{ -let -expected -= -inexact -( -[ -" -HOL -" -" -HOl -" -" -HoL -" -" -Hol -" -" -hOL -" -" -hOl -" -" -hoL -" -" -hol -" -] -. -map -( -I -) -[ -" -MES -" -" -MEs -" -" -E -" -" -MeS -" -" -Mes -" -" -e -" -" -mES -" -" -mEs -" -" -meS -" -" -mes -" -] -. -map -( -I -) -) -; -let -( -mut -prefixes -mut -suffixes -) -= -e -( -r -" -( -? -i -) -Holmes -" -) -; -prefixes -. -keep_first_bytes -( -3 -) -; -suffixes -. -keep_last_bytes -( -3 -) -; -prefixes -. -minimize_by_preference -( -) -; -suffixes -. -minimize_by_preference -( -) -; -assert_eq -! -( -expected -( -prefixes -suffixes -) -) -; -} -/ -/ -This -tests -that -we -get -some -kind -of -literals -extracted -for -a -beefier -/ -/ -alternation -with -case -insensitive -mode -enabled -. -At -one -point -during -/ -/ -development -this -returned -nothing -and -motivated -some -special -case -/ -/ -code -in -Extractor -: -: -union -to -try -and -trim -down -the -literal -sequences -/ -/ -if -the -union -would -blow -the -limits -set -. -# -[ -test -] -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -fn -holmes_alt -( -) -{ -let -mut -pre -= -prefixes -( -r -" -( -? -i -) -Sherlock -| -Holmes -| -Watson -| -Irene -| -Adler -| -John -| -Baker -" -) -; -assert -! -( -pre -. -len -( -) -. -unwrap -( -) -> -0 -) -; -pre -. -optimize_for_prefix_by_preference -( -) -; -assert -! -( -pre -. -len -( -) -. -unwrap -( -) -> -0 -) -; -} -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -security -/ -advisories -/ -GHSA -- -m5pq -- -gvj9 -- -9vr8 -/ -/ -See -: -CVE -- -2022 -- -24713 -/ -/ -/ -/ -We -test -this -here -to -ensure -literal -extraction -completes -in -reasonable -/ -/ -time -and -isn -' -t -materially -impacted -by -these -sorts -of -pathological -/ -/ -repeats -. -# -[ -test -] -fn -crazy_repeats -( -) -{ -assert_eq -! -( -inexact -( -[ -E -( -" -" -) -] -[ -E -( -" -" -) -] -) -e -( -r -" -( -? -: -) -{ -4294967295 -} -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -" -) -] -[ -E -( -" -" -) -] -) -e -( -r -" -( -? -: -) -{ -64 -} -{ -64 -} -{ -64 -} -{ -64 -} -{ -64 -} -{ -64 -} -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -" -) -] -[ -E -( -" -" -) -] -) -e -( -r -" -x -{ -0 -} -{ -4294967295 -} -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -" -) -] -[ -E -( -" -" -) -] -) -e -( -r -" -( -? -: -| -) -{ -4294967295 -} -" -) -) -; -assert_eq -! -( -inexact -( -[ -E -( -" -" -) -] -[ -E -( -" -" -) -] -) -e -( -r -" -( -? -: -) -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -" -) -) -; -let -repa -= -" -a -" -. -repeat -( -100 -) -; -assert_eq -! -( -inexact -( -[ -I -( -& -repa -) -] -[ -I -( -& -repa -) -] -) -e -( -r -" -a -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -{ -8 -} -" -) -) -; -} -# -[ -test -] -fn -huge -( -) -{ -let -pat -= -r -# -" -( -? -- -u -) -2 -( -? -: -[ -45 -] -\ -d -{ -3 -} -| -7 -( -? -: -1 -[ -0 -- -267 -] -| -2 -[ -0 -- -289 -] -| -3 -[ -0 -- -29 -] -| -4 -[ -01 -] -| -5 -[ -1 -- -3 -] -| -6 -[ -013 -] -| -7 -[ -0178 -] -| -91 -) -| -8 -( -? -: -0 -[ -125 -] -| -[ -139 -] -[ -1 -- -6 -] -| -2 -[ -0157 -- -9 -] -| -41 -| -6 -[ -1 -- -35 -] -| -7 -[ -1 -- -5 -] -| -8 -[ -1 -- -8 -] -| -90 -) -| -9 -( -? -: -0 -[ -0 -- -2 -] -| -1 -[ -0 -- -4 -] -| -2 -[ -568 -] -| -3 -[ -3 -- -6 -] -| -5 -[ -5 -- -7 -] -| -6 -[ -0167 -] -| -7 -[ -15 -] -| -8 -[ -0146 -- -9 -] -) -) -\ -d -{ -4 -} -| -3 -( -? -: -12 -? -[ -5 -- -7 -] -\ -d -{ -2 -} -| -0 -( -? -: -2 -( -? -: -[ -025 -- -79 -] -\ -d -| -[ -348 -] -\ -d -{ -1 -2 -} -) -| -3 -( -? -: -[ -2 -- -4 -] -\ -d -| -[ -56 -] -\ -d -? -) -) -| -2 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -[ -12 -] -\ -d -| -[ -35 -] -\ -d -{ -1 -2 -} -| -4 -\ -d -? -) -) -| -3 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -[ -2356 -] -\ -d -| -4 -\ -d -{ -1 -2 -} -) -) -| -4 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -2 -\ -d -{ -1 -2 -} -| -[ -47 -] -| -5 -\ -d -{ -2 -} -) -) -| -5 -( -? -: -1 -\ -d -{ -2 -} -| -29 -) -| -[ -67 -] -1 -\ -d -{ -2 -} -| -8 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -2 -\ -d -{ -2 -} -| -3 -| -4 -\ -d -) -) -) -\ -d -{ -3 -} -| -4 -( -? -: -0 -( -? -: -2 -( -? -: -[ -09 -] -\ -d -| -7 -) -| -33 -\ -d -{ -2 -} -) -| -1 -\ -d -{ -3 -} -| -2 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -[ -25 -] -\ -d -? -| -[ -348 -] -\ -d -| -[ -67 -] -\ -d -{ -1 -2 -} -) -) -| -3 -( -? -: -1 -\ -d -{ -2 -} -( -? -: -\ -d -{ -2 -} -) -? -| -2 -( -? -: -[ -045 -] -\ -d -| -[ -236 -- -9 -] -\ -d -{ -1 -2 -} -) -| -32 -\ -d -{ -2 -} -) -| -4 -( -? -: -[ -18 -] -\ -d -{ -2 -} -| -2 -( -? -: -[ -2 -- -46 -] -\ -d -{ -2 -} -| -3 -) -| -5 -[ -25 -] -\ -d -{ -2 -} -) -| -5 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -3 -\ -d -| -5 -) -) -| -6 -( -? -: -[ -18 -] -\ -d -{ -2 -} -| -2 -( -? -: -3 -( -? -: -\ -d -{ -2 -} -) -? -| -[ -46 -] -\ -d -{ -1 -2 -} -| -5 -\ -d -{ -2 -} -| -7 -\ -d -) -| -5 -( -? -: -3 -\ -d -? -| -4 -\ -d -| -[ -57 -] -\ -d -{ -1 -2 -} -| -6 -\ -d -{ -2 -} -| -8 -) -) -| -71 -\ -d -{ -2 -} -| -8 -( -? -: -[ -18 -] -\ -d -{ -2 -} -| -23 -\ -d -{ -2 -} -| -54 -\ -d -{ -2 -} -) -| -9 -( -? -: -[ -18 -] -\ -d -{ -2 -} -| -2 -[ -2 -- -5 -] -\ -d -{ -2 -} -| -53 -\ -d -{ -1 -2 -} -) -) -\ -d -{ -3 -} -| -5 -( -? -: -02 -[ -03489 -] -\ -d -{ -2 -} -| -1 -\ -d -{ -2 -} -| -2 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -2 -( -? -: -\ -d -{ -2 -} -) -? -| -[ -457 -] -\ -d -{ -2 -} -) -) -| -3 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -[ -37 -] -( -? -: -\ -d -{ -2 -} -) -? -| -[ -569 -] -\ -d -{ -2 -} -) -) -| -4 -( -? -: -1 -\ -d -{ -2 -} -| -2 -[ -46 -] -\ -d -{ -2 -} -) -| -5 -( -? -: -1 -\ -d -{ -2 -} -| -26 -\ -d -{ -1 -2 -} -) -| -6 -( -? -: -[ -18 -] -\ -d -{ -2 -} -| -2 -| -53 -\ -d -{ -2 -} -) -| -7 -( -? -: -1 -| -24 -) -\ -d -{ -2 -} -| -8 -( -? -: -1 -| -26 -) -\ -d -{ -2 -} -| -91 -\ -d -{ -2 -} -) -\ -d -{ -3 -} -| -6 -( -? -: -0 -( -? -: -1 -\ -d -{ -2 -} -| -2 -( -? -: -3 -\ -d -{ -2 -} -| -4 -\ -d -{ -1 -2 -} -) -) -| -2 -( -? -: -2 -[ -2 -- -5 -] -\ -d -{ -2 -} -| -5 -( -? -: -[ -3 -- -5 -] -\ -d -{ -2 -} -| -7 -) -| -8 -\ -d -{ -2 -} -) -| -3 -( -? -: -1 -| -2 -[ -3478 -] -) -\ -d -{ -2 -} -| -4 -( -? -: -1 -| -2 -[ -34 -] -) -\ -d -{ -2 -} -| -5 -( -? -: -1 -| -2 -[ -47 -] -) -\ -d -{ -2 -} -| -6 -( -? -: -[ -18 -] -\ -d -{ -2 -} -| -6 -( -? -: -2 -( -? -: -2 -\ -d -| -[ -34 -] -\ -d -{ -2 -} -) -| -5 -( -? -: -[ -24 -] -\ -d -{ -2 -} -| -3 -\ -d -| -5 -\ -d -{ -1 -2 -} -) -) -) -| -72 -[ -2 -- -5 -] -\ -d -{ -2 -} -| -8 -( -? -: -1 -\ -d -{ -2 -} -| -2 -[ -2 -- -5 -] -\ -d -{ -2 -} -) -| -9 -( -? -: -1 -\ -d -{ -2 -} -| -2 -[ -2 -- -6 -] -\ -d -{ -2 -} -) -) -\ -d -{ -3 -} -| -7 -( -? -: -( -? -: -02 -| -[ -3 -- -589 -] -1 -| -6 -[ -12 -] -| -72 -[ -24 -] -) -\ -d -{ -2 -} -| -21 -\ -d -{ -3 -} -| -32 -) -\ -d -{ -3 -} -| -8 -( -? -: -( -? -: -4 -[ -12 -] -| -[ -5 -- -7 -] -2 -| -1 -\ -d -? -) -| -( -? -: -0 -| -3 -[ -12 -] -| -[ -5 -- -7 -] -1 -| -217 -) -\ -d -) -\ -d -{ -4 -} -| -9 -( -? -: -[ -35 -] -1 -| -( -? -: -[ -024 -] -2 -| -81 -) -\ -d -| -( -? -: -1 -| -[ -24 -] -1 -) -\ -d -{ -2 -} -) -\ -d -{ -3 -} -" -# -; -/ -/ -TODO -: -This -is -a -good -candidate -of -a -seq -of -literals -that -could -be -/ -/ -shrunk -quite -a -bit -and -still -be -very -productive -with -respect -to -/ -/ -literal -optimizations -. -let -( -prefixes -suffixes -) -= -e -( -pat -) -; -assert -! -( -! -suffixes -. -is_finite -( -) -) -; -assert_eq -! -( -Some -( -243 -) -prefixes -. -len -( -) -) -; -} -# -[ -test -] -fn -optimize -( -) -{ -/ -/ -This -gets -a -common -prefix -that -isn -' -t -too -short -. -let -( -p -s -) -= -opt -( -[ -" -foobarfoobar -" -" -foobar -" -" -foobarzfoobar -" -" -foobarfoobar -" -] -) -; -assert_eq -! -( -seq -( -[ -I -( -" -foobar -" -) -] -) -p -) -; -assert_eq -! -( -seq -( -[ -I -( -" -foobar -" -) -] -) -s -) -; -/ -/ -This -also -finds -a -common -prefix -but -since -it -' -s -only -one -byte -it -/ -/ -prefers -the -multiple -literals -. -let -( -p -s -) -= -opt -( -[ -" -abba -" -" -akka -" -" -abccba -" -] -) -; -assert_eq -! -( -exact -( -[ -" -abba -" -" -akka -" -" -abccba -" -] -) -( -p -s -) -) -; -let -( -p -s -) -= -opt -( -[ -" -sam -" -" -samwise -" -] -) -; -assert_eq -! -( -( -seq -( -[ -E -( -" -sam -" -) -] -) -seq -( -[ -E -( -" -sam -" -) -E -( -" -samwise -" -) -] -) -) -( -p -s -) -) -; -/ -/ -The -empty -string -is -poisonous -so -our -seq -becomes -infinite -even -/ -/ -though -all -literals -are -exact -. -let -( -p -s -) -= -opt -( -[ -" -foobarfoo -" -" -foo -" -" -" -" -foozfoo -" -" -foofoo -" -] -) -; -assert -! -( -! -p -. -is_finite -( -) -) -; -assert -! -( -! -s -. -is_finite -( -) -) -; -/ -/ -A -space -is -also -poisonous -so -our -seq -becomes -infinite -. -But -this -/ -/ -only -gets -triggered -when -we -don -' -t -have -a -completely -exact -sequence -. -/ -/ -When -the -sequence -is -exact -spaces -are -okay -since -we -presume -that -/ -/ -any -prefilter -will -match -a -space -more -quickly -than -the -regex -engine -. -/ -/ -( -When -the -sequence -is -exact -there -' -s -a -chance -of -the -prefilter -being -/ -/ -used -without -needing -the -regex -engine -at -all -. -) -let -mut -p -= -seq -( -[ -E -( -" -foobarfoo -" -) -I -( -" -foo -" -) -E -( -" -" -) -E -( -" -foofoo -" -) -] -) -; -p -. -optimize_for_prefix_by_preference -( -) -; -assert -! -( -! -p -. -is_finite -( -) -) -; -} -} diff --git a/third_party/rust/regex-syntax/src/hir/literal/mod.rs b/third_party/rust/regex-syntax/src/hir/literal/mod.rs new file mode 100644 index 0000000000000..fc37f03c7cfab --- /dev/null +++ b/third_party/rust/regex-syntax/src/hir/literal/mod.rs @@ -0,0 +1,15256 @@ +/ +* +! +Provides +routines +for +extracting +literal +prefixes +and +suffixes +from +an +Hir +. +* +/ +use +std +: +: +cmp +; +use +std +: +: +fmt +; +use +std +: +: +iter +; +use +std +: +: +mem +; +use +std +: +: +ops +; +use +crate +: +: +hir +: +: +{ +self +Hir +HirKind +} +; +/ +/ +/ +A +set +of +literal +byte +strings +extracted +from +a +regular +expression +. +/ +/ +/ +/ +/ +/ +Every +member +of +the +set +is +a +Literal +which +is +represented +by +a +/ +/ +/ +Vec +< +u8 +> +. +( +Notably +it +may +contain +invalid +UTF +- +8 +. +) +Every +member +is +/ +/ +/ +said +to +be +either +* +complete +* +or +* +cut +* +. +A +complete +literal +means +that +/ +/ +/ +it +extends +until +the +beginning +( +or +end +) +of +the +regular +expression +. +In +/ +/ +/ +some +circumstances +this +can +be +used +to +indicate +a +match +in +the +regular +/ +/ +/ +expression +. +/ +/ +/ +/ +/ +/ +A +key +aspect +of +literal +extraction +is +knowing +when +to +stop +. +It +is +not +/ +/ +/ +feasible +to +blindly +extract +all +literals +from +a +regular +expression +even +if +/ +/ +/ +there +are +finitely +many +. +For +example +the +regular +expression +[ +0 +- +9 +] +{ +10 +} +/ +/ +/ +has +10 +^ +10 +distinct +literals +. +For +this +reason +literal +extraction +is +/ +/ +/ +bounded +to +some +low +number +by +default +using +heuristics +but +the +limits +can +/ +/ +/ +be +tweaked +. +/ +/ +/ +/ +/ +/ +* +* +WARNING +* +* +: +Literal +extraction +uses +stack +space +proportional +to +the +size +/ +/ +/ +of +the +Hir +expression +. +At +some +point +this +drawback +will +be +eliminated +. +/ +/ +/ +To +protect +yourself +set +a +reasonable +/ +/ +/ +[ +nest_limit +on +your +Parser +] +( +. +. +/ +. +. +/ +struct +. +ParserBuilder +. +html +# +method +. +nest_limit +) +. +/ +/ +/ +This +is +done +for +you +by +default +. +# +[ +derive +( +Clone +Eq +PartialEq +) +] +pub +struct +Literals +{ +lits +: +Vec +< +Literal +> +limit_size +: +usize +limit_class +: +usize +} +/ +/ +/ +A +single +member +of +a +set +of +literals +extracted +from +a +regular +expression +. +/ +/ +/ +/ +/ +/ +This +type +has +Deref +and +DerefMut +impls +to +Vec +< +u8 +> +so +that +all +slice +/ +/ +/ +and +Vec +operations +are +available +. +# +[ +derive +( +Clone +Eq +Ord +) +] +pub +struct +Literal +{ +v +: +Vec +< +u8 +> +cut +: +bool +} +impl +Literals +{ +/ +/ +/ +Returns +a +new +empty +set +of +literals +using +default +limits +. +pub +fn +empty +( +) +- +> +Literals +{ +Literals +{ +lits +: +vec +! +[ +] +limit_size +: +250 +limit_class +: +10 +} +} +/ +/ +/ +Returns +a +set +of +literal +prefixes +extracted +from +the +given +Hir +. +pub +fn +prefixes +( +expr +: +& +Hir +) +- +> +Literals +{ +let +mut +lits += +Literals +: +: +empty +( +) +; +lits +. +union_prefixes +( +expr +) +; +lits +} +/ +/ +/ +Returns +a +set +of +literal +suffixes +extracted +from +the +given +Hir +. +pub +fn +suffixes +( +expr +: +& +Hir +) +- +> +Literals +{ +let +mut +lits += +Literals +: +: +empty +( +) +; +lits +. +union_suffixes +( +expr +) +; +lits +} +/ +/ +/ +Get +the +approximate +size +limit +( +in +bytes +) +of +this +set +. +pub +fn +limit_size +( +& +self +) +- +> +usize +{ +self +. +limit_size +} +/ +/ +/ +Set +the +approximate +size +limit +( +in +bytes +) +of +this +set +. +/ +/ +/ +/ +/ +/ +If +extracting +a +literal +would +put +the +set +over +this +limit +then +/ +/ +/ +extraction +stops +. +/ +/ +/ +/ +/ +/ +The +new +limits +will +only +apply +to +additions +to +this +set +. +Existing +/ +/ +/ +members +remain +unchanged +even +if +the +set +exceeds +the +new +limit +. +pub +fn +set_limit_size +( +& +mut +self +size +: +usize +) +- +> +& +mut +Literals +{ +self +. +limit_size += +size +; +self +} +/ +/ +/ +Get +the +character +class +size +limit +for +this +set +. +pub +fn +limit_class +( +& +self +) +- +> +usize +{ +self +. +limit_class +} +/ +/ +/ +Limits +the +size +of +character +( +or +byte +) +classes +considered +. +/ +/ +/ +/ +/ +/ +A +value +of +0 +prevents +all +character +classes +from +being +considered +. +/ +/ +/ +/ +/ +/ +This +limit +also +applies +to +case +insensitive +literals +since +each +/ +/ +/ +character +in +the +case +insensitive +literal +is +converted +to +a +class +and +/ +/ +/ +then +case +folded +. +/ +/ +/ +/ +/ +/ +The +new +limits +will +only +apply +to +additions +to +this +set +. +Existing +/ +/ +/ +members +remain +unchanged +even +if +the +set +exceeds +the +new +limit +. +pub +fn +set_limit_class +( +& +mut +self +size +: +usize +) +- +> +& +mut +Literals +{ +self +. +limit_class += +size +; +self +} +/ +/ +/ +Returns +the +set +of +literals +as +a +slice +. +Its +order +is +unspecified +. +pub +fn +literals +( +& +self +) +- +> +& +[ +Literal +] +{ +& +self +. +lits +} +/ +/ +/ +Returns +the +length +of +the +smallest +literal +. +/ +/ +/ +/ +/ +/ +Returns +None +is +there +are +no +literals +in +the +set +. +pub +fn +min_len +( +& +self +) +- +> +Option +< +usize +> +{ +let +mut +min += +None +; +for +lit +in +& +self +. +lits +{ +match +min +{ +None += +> +min += +Some +( +lit +. +len +( +) +) +Some +( +m +) +if +lit +. +len +( +) +< +m += +> +min += +Some +( +lit +. +len +( +) +) +_ += +> +{ +} +} +} +min +} +/ +/ +/ +Returns +true +if +all +members +in +this +set +are +complete +. +pub +fn +all_complete +( +& +self +) +- +> +bool +{ +! +self +. +lits +. +is_empty +( +) +& +& +self +. +lits +. +iter +( +) +. +all +( +| +l +| +! +l +. +is_cut +( +) +) +} +/ +/ +/ +Returns +true +if +any +member +in +this +set +is +complete +. +pub +fn +any_complete +( +& +self +) +- +> +bool +{ +self +. +lits +. +iter +( +) +. +any +( +| +lit +| +! +lit +. +is_cut +( +) +) +} +/ +/ +/ +Returns +true +if +this +set +contains +an +empty +literal +. +pub +fn +contains_empty +( +& +self +) +- +> +bool +{ +self +. +lits +. +iter +( +) +. +any +( +| +lit +| +lit +. +is_empty +( +) +) +} +/ +/ +/ +Returns +true +if +this +set +is +empty +or +if +all +of +its +members +is +empty +. +pub +fn +is_empty +( +& +self +) +- +> +bool +{ +self +. +lits +. +is_empty +( +) +| +| +self +. +lits +. +iter +( +) +. +all +( +| +lit +| +lit +. +is_empty +( +) +) +} +/ +/ +/ +Returns +a +new +empty +set +of +literals +using +this +set +' +s +limits +. +pub +fn +to_empty +( +& +self +) +- +> +Literals +{ +let +mut +lits += +Literals +: +: +empty +( +) +; +lits +. +set_limit_size +( +self +. +limit_size +) +. +set_limit_class +( +self +. +limit_class +) +; +lits +} +/ +/ +/ +Returns +the +longest +common +prefix +of +all +members +in +this +set +. +pub +fn +longest_common_prefix +( +& +self +) +- +> +& +[ +u8 +] +{ +if +self +. +is_empty +( +) +{ +return +& +[ +] +; +} +let +lit0 += +& +* +self +. +lits +[ +0 +] +; +let +mut +len += +lit0 +. +len +( +) +; +for +lit +in +& +self +. +lits +[ +1 +. +. +] +{ +len += +cmp +: +: +min +( +len +lit +. +iter +( +) +. +zip +( +lit0 +) +. +take_while +( +| +& +( +a +b +) +| +a += += +b +) +. +count +( +) +) +; +} +& +self +. +lits +[ +0 +] +[ +. +. +len +] +} +/ +/ +/ +Returns +the +longest +common +suffix +of +all +members +in +this +set +. +pub +fn +longest_common_suffix +( +& +self +) +- +> +& +[ +u8 +] +{ +if +self +. +is_empty +( +) +{ +return +& +[ +] +; +} +let +lit0 += +& +* +self +. +lits +[ +0 +] +; +let +mut +len += +lit0 +. +len +( +) +; +for +lit +in +& +self +. +lits +[ +1 +. +. +] +{ +len += +cmp +: +: +min +( +len +lit +. +iter +( +) +. +rev +( +) +. +zip +( +lit0 +. +iter +( +) +. +rev +( +) +) +. +take_while +( +| +& +( +a +b +) +| +a += += +b +) +. +count +( +) +) +; +} +& +self +. +lits +[ +0 +] +[ +self +. +lits +[ +0 +] +. +len +( +) +- +len +. +. +] +} +/ +/ +/ +Returns +a +new +set +of +literals +with +the +given +number +of +bytes +trimmed +/ +/ +/ +from +the +suffix +of +each +literal +. +/ +/ +/ +/ +/ +/ +If +any +literal +would +be +cut +out +completely +by +trimming +then +None +is +/ +/ +/ +returned +. +/ +/ +/ +/ +/ +/ +Any +duplicates +that +are +created +as +a +result +of +this +transformation +are +/ +/ +/ +removed +. +pub +fn +trim_suffix +( +& +self +num_bytes +: +usize +) +- +> +Option +< +Literals +> +{ +if +self +. +min_len +( +) +. +map +( +| +len +| +len +< += +num_bytes +) +. +unwrap_or +( +true +) +{ +return +None +; +} +let +mut +new += +self +. +to_empty +( +) +; +for +mut +lit +in +self +. +lits +. +iter +( +) +. +cloned +( +) +{ +let +new_len += +lit +. +len +( +) +- +num_bytes +; +lit +. +truncate +( +new_len +) +; +lit +. +cut +( +) +; +new +. +lits +. +push +( +lit +) +; +} +new +. +lits +. +sort +( +) +; +new +. +lits +. +dedup +( +) +; +Some +( +new +) +} +/ +/ +/ +Returns +a +new +set +of +prefixes +of +this +set +of +literals +that +are +/ +/ +/ +guaranteed +to +be +unambiguous +. +/ +/ +/ +/ +/ +/ +Any +substring +match +with +a +member +of +the +set +is +returned +is +guaranteed +/ +/ +/ +to +never +overlap +with +a +substring +match +of +another +member +of +the +set +/ +/ +/ +at +the +same +starting +position +. +/ +/ +/ +/ +/ +/ +Given +any +two +members +of +the +returned +set +neither +is +a +substring +of +/ +/ +/ +the +other +. +pub +fn +unambiguous_prefixes +( +& +self +) +- +> +Literals +{ +if +self +. +lits +. +is_empty +( +) +{ +return +self +. +to_empty +( +) +; +} +let +mut +old += +self +. +lits +. +to_vec +( +) +; +let +mut +new += +self +. +to_empty +( +) +; +' +OUTER +: +while +let +Some +( +mut +candidate +) += +old +. +pop +( +) +{ +if +candidate +. +is_empty +( +) +{ +continue +; +} +if +new +. +lits +. +is_empty +( +) +{ +new +. +lits +. +push +( +candidate +) +; +continue +; +} +for +lit2 +in +& +mut +new +. +lits +{ +if +lit2 +. +is_empty +( +) +{ +continue +; +} +if +& +candidate += += +lit2 +{ +/ +/ +If +the +literal +is +already +in +the +set +then +we +can +/ +/ +just +drop +it +. +But +make +sure +that +cut +literals +are +/ +/ +infectious +! +candidate +. +cut += +candidate +. +cut +| +| +lit2 +. +cut +; +lit2 +. +cut += +candidate +. +cut +; +continue +' +OUTER +; +} +if +candidate +. +len +( +) +< +lit2 +. +len +( +) +{ +if +let +Some +( +i +) += +position +( +& +candidate +& +lit2 +) +{ +candidate +. +cut +( +) +; +let +mut +lit3 += +lit2 +. +clone +( +) +; +lit3 +. +truncate +( +i +) +; +lit3 +. +cut +( +) +; +old +. +push +( +lit3 +) +; +lit2 +. +clear +( +) +; +} +} +else +if +let +Some +( +i +) += +position +( +& +lit2 +& +candidate +) +{ +lit2 +. +cut +( +) +; +let +mut +new_candidate += +candidate +. +clone +( +) +; +new_candidate +. +truncate +( +i +) +; +new_candidate +. +cut +( +) +; +old +. +push +( +new_candidate +) +; +candidate +. +clear +( +) +; +} +/ +/ +Oops +the +candidate +is +already +represented +in +the +set +. +if +candidate +. +is_empty +( +) +{ +continue +' +OUTER +; +} +} +new +. +lits +. +push +( +candidate +) +; +} +new +. +lits +. +retain +( +| +lit +| +! +lit +. +is_empty +( +) +) +; +new +. +lits +. +sort +( +) +; +new +. +lits +. +dedup +( +) +; +new +} +/ +/ +/ +Returns +a +new +set +of +suffixes +of +this +set +of +literals +that +are +/ +/ +/ +guaranteed +to +be +unambiguous +. +/ +/ +/ +/ +/ +/ +Any +substring +match +with +a +member +of +the +set +is +returned +is +guaranteed +/ +/ +/ +to +never +overlap +with +a +substring +match +of +another +member +of +the +set +/ +/ +/ +at +the +same +ending +position +. +/ +/ +/ +/ +/ +/ +Given +any +two +members +of +the +returned +set +neither +is +a +substring +of +/ +/ +/ +the +other +. +pub +fn +unambiguous_suffixes +( +& +self +) +- +> +Literals +{ +/ +/ +This +is +a +touch +wasteful +. +. +. +let +mut +lits += +self +. +clone +( +) +; +lits +. +reverse +( +) +; +let +mut +unamb += +lits +. +unambiguous_prefixes +( +) +; +unamb +. +reverse +( +) +; +unamb +} +/ +/ +/ +Unions +the +prefixes +from +the +given +expression +to +this +set +. +/ +/ +/ +/ +/ +/ +If +prefixes +could +not +be +added +( +for +example +this +set +would +exceed +its +/ +/ +/ +size +limits +or +the +set +of +prefixes +from +expr +includes +the +empty +/ +/ +/ +string +) +then +false +is +returned +. +/ +/ +/ +/ +/ +/ +Note +that +prefix +literals +extracted +from +expr +are +said +to +be +complete +/ +/ +/ +if +and +only +if +the +literal +extends +from +the +beginning +of +expr +to +the +/ +/ +/ +end +of +expr +. +pub +fn +union_prefixes +( +& +mut +self +expr +: +& +Hir +) +- +> +bool +{ +let +mut +lits += +self +. +to_empty +( +) +; +prefixes +( +expr +& +mut +lits +) +; +! +lits +. +is_empty +( +) +& +& +! +lits +. +contains_empty +( +) +& +& +self +. +union +( +lits +) +} +/ +/ +/ +Unions +the +suffixes +from +the +given +expression +to +this +set +. +/ +/ +/ +/ +/ +/ +If +suffixes +could +not +be +added +( +for +example +this +set +would +exceed +its +/ +/ +/ +size +limits +or +the +set +of +suffixes +from +expr +includes +the +empty +/ +/ +/ +string +) +then +false +is +returned +. +/ +/ +/ +/ +/ +/ +Note +that +prefix +literals +extracted +from +expr +are +said +to +be +complete +/ +/ +/ +if +and +only +if +the +literal +extends +from +the +end +of +expr +to +the +/ +/ +/ +beginning +of +expr +. +pub +fn +union_suffixes +( +& +mut +self +expr +: +& +Hir +) +- +> +bool +{ +let +mut +lits += +self +. +to_empty +( +) +; +suffixes +( +expr +& +mut +lits +) +; +lits +. +reverse +( +) +; +! +lits +. +is_empty +( +) +& +& +! +lits +. +contains_empty +( +) +& +& +self +. +union +( +lits +) +} +/ +/ +/ +Unions +this +set +with +another +set +. +/ +/ +/ +/ +/ +/ +If +the +union +would +cause +the +set +to +exceed +its +limits +then +the +union +/ +/ +/ +is +skipped +and +it +returns +false +. +Otherwise +if +the +union +succeeds +it +/ +/ +/ +returns +true +. +pub +fn +union +( +& +mut +self +lits +: +Literals +) +- +> +bool +{ +if +self +. +num_bytes +( +) ++ +lits +. +num_bytes +( +) +> +self +. +limit_size +{ +return +false +; +} +if +lits +. +is_empty +( +) +{ +self +. +lits +. +push +( +Literal +: +: +empty +( +) +) +; +} +else +{ +self +. +lits +. +extend +( +lits +. +lits +) +; +} +true +} +/ +/ +/ +Extends +this +set +with +another +set +. +/ +/ +/ +/ +/ +/ +The +set +of +literals +is +extended +via +a +cross +product +. +/ +/ +/ +/ +/ +/ +If +a +cross +product +would +cause +this +set +to +exceed +its +limits +then +the +/ +/ +/ +cross +product +is +skipped +and +it +returns +false +. +Otherwise +if +the +cross +/ +/ +/ +product +succeeds +it +returns +true +. +pub +fn +cross_product +( +& +mut +self +lits +: +& +Literals +) +- +> +bool +{ +if +lits +. +is_empty +( +) +{ +return +true +; +} +/ +/ +Check +that +we +make +sure +we +stay +in +our +limits +. +let +mut +size_after +; +if +self +. +is_empty +( +) +| +| +! +self +. +any_complete +( +) +{ +size_after += +self +. +num_bytes +( +) +; +for +lits_lit +in +lits +. +literals +( +) +{ +size_after ++ += +lits_lit +. +len +( +) +; +} +} +else +{ +size_after += +self +. +lits +. +iter +( +) +. +fold +( +0 +| +accum +lit +| +{ +accum ++ +if +lit +. +is_cut +( +) +{ +lit +. +len +( +) +} +else +{ +0 +} +} +) +; +for +lits_lit +in +lits +. +literals +( +) +{ +for +self_lit +in +self +. +literals +( +) +{ +if +! +self_lit +. +is_cut +( +) +{ +size_after ++ += +self_lit +. +len +( +) ++ +lits_lit +. +len +( +) +; +} +} +} +} +if +size_after +> +self +. +limit_size +{ +return +false +; +} +let +mut +base += +self +. +remove_complete +( +) +; +if +base +. +is_empty +( +) +{ +base += +vec +! +[ +Literal +: +: +empty +( +) +] +; +} +for +lits_lit +in +lits +. +literals +( +) +{ +for +mut +self_lit +in +base +. +clone +( +) +{ +self_lit +. +extend +( +& +* +* +lits_lit +) +; +self_lit +. +cut += +lits_lit +. +cut +; +self +. +lits +. +push +( +self_lit +) +; +} +} +true +} +/ +/ +/ +Extends +each +literal +in +this +set +with +the +bytes +given +. +/ +/ +/ +/ +/ +/ +If +the +set +is +empty +then +the +given +literal +is +added +to +the +set +. +/ +/ +/ +/ +/ +/ +If +adding +any +number +of +bytes +to +all +members +of +this +set +causes +a +limit +/ +/ +/ +to +be +exceeded +then +no +bytes +are +added +and +false +is +returned +. +If +a +/ +/ +/ +prefix +of +bytes +can +be +fit +into +this +set +then +it +is +used +and +all +/ +/ +/ +resulting +literals +are +cut +. +pub +fn +cross_add +( +& +mut +self +bytes +: +& +[ +u8 +] +) +- +> +bool +{ +/ +/ +N +. +B +. +This +could +be +implemented +by +simply +calling +cross_product +with +/ +/ +a +literal +set +containing +just +bytes +but +we +can +be +smarter +about +/ +/ +taking +shorter +prefixes +of +bytes +if +they +' +ll +fit +. +if +bytes +. +is_empty +( +) +{ +return +true +; +} +if +self +. +lits +. +is_empty +( +) +{ +let +i += +cmp +: +: +min +( +self +. +limit_size +bytes +. +len +( +) +) +; +self +. +lits +. +push +( +Literal +: +: +new +( +bytes +[ +. +. +i +] +. +to_owned +( +) +) +) +; +self +. +lits +[ +0 +] +. +cut += +i +< +bytes +. +len +( +) +; +return +! +self +. +lits +[ +0 +] +. +is_cut +( +) +; +} +let +size += +self +. +num_bytes +( +) +; +if +size ++ +self +. +lits +. +len +( +) +> += +self +. +limit_size +{ +return +false +; +} +let +mut +i += +1 +; +while +size ++ +( +i +* +self +. +lits +. +len +( +) +) +< += +self +. +limit_size +& +& +i +< +bytes +. +len +( +) +{ +i ++ += +1 +; +} +for +lit +in +& +mut +self +. +lits +{ +if +! +lit +. +is_cut +( +) +{ +lit +. +extend +( +& +bytes +[ +. +. +i +] +) +; +if +i +< +bytes +. +len +( +) +{ +lit +. +cut +( +) +; +} +} +} +true +} +/ +/ +/ +Adds +the +given +literal +to +this +set +. +/ +/ +/ +/ +/ +/ +Returns +false +if +adding +this +literal +would +cause +the +class +to +be +too +/ +/ +/ +big +. +pub +fn +add +( +& +mut +self +lit +: +Literal +) +- +> +bool +{ +if +self +. +num_bytes +( +) ++ +lit +. +len +( +) +> +self +. +limit_size +{ +return +false +; +} +self +. +lits +. +push +( +lit +) +; +true +} +/ +/ +/ +Extends +each +literal +in +this +set +with +the +character +class +given +. +/ +/ +/ +/ +/ +/ +Returns +false +if +the +character +class +was +too +big +to +add +. +pub +fn +add_char_class +( +& +mut +self +cls +: +& +hir +: +: +ClassUnicode +) +- +> +bool +{ +self +. +_add_char_class +( +cls +false +) +} +/ +/ +/ +Extends +each +literal +in +this +set +with +the +character +class +given +/ +/ +/ +writing +the +bytes +of +each +character +in +reverse +. +/ +/ +/ +/ +/ +/ +Returns +false +if +the +character +class +was +too +big +to +add +. +fn +add_char_class_reverse +( +& +mut +self +cls +: +& +hir +: +: +ClassUnicode +) +- +> +bool +{ +self +. +_add_char_class +( +cls +true +) +} +fn +_add_char_class +( +& +mut +self +cls +: +& +hir +: +: +ClassUnicode +reverse +: +bool +) +- +> +bool +{ +use +std +: +: +char +; +if +self +. +class_exceeds_limits +( +cls_char_count +( +cls +) +) +{ +return +false +; +} +let +mut +base += +self +. +remove_complete +( +) +; +if +base +. +is_empty +( +) +{ +base += +vec +! +[ +Literal +: +: +empty +( +) +] +; +} +for +r +in +cls +. +iter +( +) +{ +let +( +s +e +) += +( +r +. +start +as +u32 +r +. +end +as +u32 ++ +1 +) +; +for +c +in +( +s +. +. +e +) +. +filter_map +( +char +: +: +from_u32 +) +{ +for +mut +lit +in +base +. +clone +( +) +{ +let +mut +bytes += +c +. +to_string +( +) +. +into_bytes +( +) +; +if +reverse +{ +bytes +. +reverse +( +) +; +} +lit +. +extend +( +& +bytes +) +; +self +. +lits +. +push +( +lit +) +; +} +} +} +true +} +/ +/ +/ +Extends +each +literal +in +this +set +with +the +byte +class +given +. +/ +/ +/ +/ +/ +/ +Returns +false +if +the +byte +class +was +too +big +to +add +. +pub +fn +add_byte_class +( +& +mut +self +cls +: +& +hir +: +: +ClassBytes +) +- +> +bool +{ +if +self +. +class_exceeds_limits +( +cls_byte_count +( +cls +) +) +{ +return +false +; +} +let +mut +base += +self +. +remove_complete +( +) +; +if +base +. +is_empty +( +) +{ +base += +vec +! +[ +Literal +: +: +empty +( +) +] +; +} +for +r +in +cls +. +iter +( +) +{ +let +( +s +e +) += +( +r +. +start +as +u32 +r +. +end +as +u32 ++ +1 +) +; +for +b +in +( +s +. +. +e +) +. +map +( +| +b +| +b +as +u8 +) +{ +for +mut +lit +in +base +. +clone +( +) +{ +lit +. +push +( +b +) +; +self +. +lits +. +push +( +lit +) +; +} +} +} +true +} +/ +/ +/ +Cuts +every +member +of +this +set +. +When +a +member +is +cut +it +can +never +/ +/ +/ +be +extended +. +pub +fn +cut +( +& +mut +self +) +{ +for +lit +in +& +mut +self +. +lits +{ +lit +. +cut +( +) +; +} +} +/ +/ +/ +Reverses +all +members +in +place +. +pub +fn +reverse +( +& +mut +self +) +{ +for +lit +in +& +mut +self +. +lits +{ +lit +. +reverse +( +) +; +} +} +/ +/ +/ +Clears +this +set +of +all +members +. +pub +fn +clear +( +& +mut +self +) +{ +self +. +lits +. +clear +( +) +; +} +/ +/ +/ +Pops +all +complete +literals +out +of +this +set +. +fn +remove_complete +( +& +mut +self +) +- +> +Vec +< +Literal +> +{ +let +mut +base += +vec +! +[ +] +; +for +lit +in +mem +: +: +replace +( +& +mut +self +. +lits +vec +! +[ +] +) +{ +if +lit +. +is_cut +( +) +{ +self +. +lits +. +push +( +lit +) +; +} +else +{ +base +. +push +( +lit +) +; +} +} +base +} +/ +/ +/ +Returns +the +total +number +of +bytes +in +this +set +. +fn +num_bytes +( +& +self +) +- +> +usize +{ +self +. +lits +. +iter +( +) +. +fold +( +0 +| +accum +lit +| +accum ++ +lit +. +len +( +) +) +} +/ +/ +/ +Returns +true +if +a +character +class +with +the +given +size +would +cause +this +/ +/ +/ +set +to +exceed +its +limits +. +/ +/ +/ +/ +/ +/ +The +size +given +should +correspond +to +the +number +of +items +in +the +class +. +fn +class_exceeds_limits +( +& +self +size +: +usize +) +- +> +bool +{ +if +size +> +self +. +limit_class +{ +return +true +; +} +/ +/ +This +is +an +approximation +since +codepoints +in +a +char +class +can +encode +/ +/ +to +1 +- +4 +bytes +. +let +new_byte_count += +if +self +. +lits +. +is_empty +( +) +{ +size +} +else +{ +self +. +lits +. +iter +( +) +. +fold +( +0 +| +accum +lit +| +{ +accum ++ +if +lit +. +is_cut +( +) +{ +/ +/ +If +the +literal +is +cut +then +we +' +ll +never +add +/ +/ +anything +to +it +so +don +' +t +count +it +. +0 +} +else +{ +( +lit +. +len +( +) ++ +1 +) +* +size +} +} +) +} +; +new_byte_count +> +self +. +limit_size +} +} +fn +prefixes +( +expr +: +& +Hir +lits +: +& +mut +Literals +) +{ +match +* +expr +. +kind +( +) +{ +HirKind +: +: +Literal +( +hir +: +: +Literal +: +: +Unicode +( +c +) +) += +> +{ +let +mut +buf += +[ +0 +; +4 +] +; +lits +. +cross_add +( +c +. +encode_utf8 +( +& +mut +buf +) +. +as_bytes +( +) +) +; +} +HirKind +: +: +Literal +( +hir +: +: +Literal +: +: +Byte +( +b +) +) += +> +{ +lits +. +cross_add +( +& +[ +b +] +) +; +} +HirKind +: +: +Class +( +hir +: +: +Class +: +: +Unicode +( +ref +cls +) +) += +> +{ +if +! +lits +. +add_char_class +( +cls +) +{ +lits +. +cut +( +) +; +} +} +HirKind +: +: +Class +( +hir +: +: +Class +: +: +Bytes +( +ref +cls +) +) += +> +{ +if +! +lits +. +add_byte_class +( +cls +) +{ +lits +. +cut +( +) +; +} +} +HirKind +: +: +Group +( +hir +: +: +Group +{ +ref +hir +. +. +} +) += +> +{ +prefixes +( +& +* +* +hir +lits +) +; +} +HirKind +: +: +Repetition +( +ref +x +) += +> +match +x +. +kind +{ +hir +: +: +RepetitionKind +: +: +ZeroOrOne += +> +{ +repeat_zero_or_one_literals +( +& +x +. +hir +lits +prefixes +) +; +} +hir +: +: +RepetitionKind +: +: +ZeroOrMore += +> +{ +repeat_zero_or_more_literals +( +& +x +. +hir +lits +prefixes +) +; +} +hir +: +: +RepetitionKind +: +: +OneOrMore += +> +{ +repeat_one_or_more_literals +( +& +x +. +hir +lits +prefixes +) +; +} +hir +: +: +RepetitionKind +: +: +Range +( +ref +rng +) += +> +{ +let +( +min +max +) += +match +* +rng +{ +hir +: +: +RepetitionRange +: +: +Exactly +( +m +) += +> +( +m +Some +( +m +) +) +hir +: +: +RepetitionRange +: +: +AtLeast +( +m +) += +> +( +m +None +) +hir +: +: +RepetitionRange +: +: +Bounded +( +m +n +) += +> +( +m +Some +( +n +) +) +} +; +repeat_range_literals +( +& +x +. +hir +min +max +x +. +greedy +lits +prefixes +) +} +} +HirKind +: +: +Concat +( +ref +es +) +if +es +. +is_empty +( +) += +> +{ +} +HirKind +: +: +Concat +( +ref +es +) +if +es +. +len +( +) += += +1 += +> +prefixes +( +& +es +[ +0 +] +lits +) +HirKind +: +: +Concat +( +ref +es +) += +> +{ +for +e +in +es +{ +if +let +HirKind +: +: +Anchor +( +hir +: +: +Anchor +: +: +StartText +) += +* +e +. +kind +( +) +{ +if +! +lits +. +is_empty +( +) +{ +lits +. +cut +( +) +; +break +; +} +lits +. +add +( +Literal +: +: +empty +( +) +) +; +continue +; +} +let +mut +lits2 += +lits +. +to_empty +( +) +; +prefixes +( +e +& +mut +lits2 +) +; +if +! +lits +. +cross_product +( +& +lits2 +) +| +| +! +lits2 +. +any_complete +( +) +{ +/ +/ +If +this +expression +couldn +' +t +yield +any +literal +that +/ +/ +could +be +extended +then +we +need +to +quit +. +Since +we +' +re +/ +/ +short +- +circuiting +we +also +need +to +freeze +every +member +. +lits +. +cut +( +) +; +break +; +} +} +} +HirKind +: +: +Alternation +( +ref +es +) += +> +{ +alternate_literals +( +es +lits +prefixes +) +; +} +_ += +> +lits +. +cut +( +) +} +} +fn +suffixes +( +expr +: +& +Hir +lits +: +& +mut +Literals +) +{ +match +* +expr +. +kind +( +) +{ +HirKind +: +: +Literal +( +hir +: +: +Literal +: +: +Unicode +( +c +) +) += +> +{ +let +mut +buf += +[ +0u8 +; +4 +] +; +let +i += +c +. +encode_utf8 +( +& +mut +buf +) +. +len +( +) +; +let +buf += +& +mut +buf +[ +. +. +i +] +; +buf +. +reverse +( +) +; +lits +. +cross_add +( +buf +) +; +} +HirKind +: +: +Literal +( +hir +: +: +Literal +: +: +Byte +( +b +) +) += +> +{ +lits +. +cross_add +( +& +[ +b +] +) +; +} +HirKind +: +: +Class +( +hir +: +: +Class +: +: +Unicode +( +ref +cls +) +) += +> +{ +if +! +lits +. +add_char_class_reverse +( +cls +) +{ +lits +. +cut +( +) +; +} +} +HirKind +: +: +Class +( +hir +: +: +Class +: +: +Bytes +( +ref +cls +) +) += +> +{ +if +! +lits +. +add_byte_class +( +cls +) +{ +lits +. +cut +( +) +; +} +} +HirKind +: +: +Group +( +hir +: +: +Group +{ +ref +hir +. +. +} +) += +> +{ +suffixes +( +& +* +* +hir +lits +) +; +} +HirKind +: +: +Repetition +( +ref +x +) += +> +match +x +. +kind +{ +hir +: +: +RepetitionKind +: +: +ZeroOrOne += +> +{ +repeat_zero_or_one_literals +( +& +x +. +hir +lits +suffixes +) +; +} +hir +: +: +RepetitionKind +: +: +ZeroOrMore += +> +{ +repeat_zero_or_more_literals +( +& +x +. +hir +lits +suffixes +) +; +} +hir +: +: +RepetitionKind +: +: +OneOrMore += +> +{ +repeat_one_or_more_literals +( +& +x +. +hir +lits +suffixes +) +; +} +hir +: +: +RepetitionKind +: +: +Range +( +ref +rng +) += +> +{ +let +( +min +max +) += +match +* +rng +{ +hir +: +: +RepetitionRange +: +: +Exactly +( +m +) += +> +( +m +Some +( +m +) +) +hir +: +: +RepetitionRange +: +: +AtLeast +( +m +) += +> +( +m +None +) +hir +: +: +RepetitionRange +: +: +Bounded +( +m +n +) += +> +( +m +Some +( +n +) +) +} +; +repeat_range_literals +( +& +x +. +hir +min +max +x +. +greedy +lits +suffixes +) +} +} +HirKind +: +: +Concat +( +ref +es +) +if +es +. +is_empty +( +) += +> +{ +} +HirKind +: +: +Concat +( +ref +es +) +if +es +. +len +( +) += += +1 += +> +suffixes +( +& +es +[ +0 +] +lits +) +HirKind +: +: +Concat +( +ref +es +) += +> +{ +for +e +in +es +. +iter +( +) +. +rev +( +) +{ +if +let +HirKind +: +: +Anchor +( +hir +: +: +Anchor +: +: +EndText +) += +* +e +. +kind +( +) +{ +if +! +lits +. +is_empty +( +) +{ +lits +. +cut +( +) +; +break +; +} +lits +. +add +( +Literal +: +: +empty +( +) +) +; +continue +; +} +let +mut +lits2 += +lits +. +to_empty +( +) +; +suffixes +( +e +& +mut +lits2 +) +; +if +! +lits +. +cross_product +( +& +lits2 +) +| +| +! +lits2 +. +any_complete +( +) +{ +/ +/ +If +this +expression +couldn +' +t +yield +any +literal +that +/ +/ +could +be +extended +then +we +need +to +quit +. +Since +we +' +re +/ +/ +short +- +circuiting +we +also +need +to +freeze +every +member +. +lits +. +cut +( +) +; +break +; +} +} +} +HirKind +: +: +Alternation +( +ref +es +) += +> +{ +alternate_literals +( +es +lits +suffixes +) +; +} +_ += +> +lits +. +cut +( +) +} +} +fn +repeat_zero_or_one_literals +< +F +: +FnMut +( +& +Hir +& +mut +Literals +) +> +( +e +: +& +Hir +lits +: +& +mut +Literals +mut +f +: +F +) +{ +f +( +& +Hir +: +: +repetition +( +hir +: +: +Repetition +{ +kind +: +hir +: +: +RepetitionKind +: +: +ZeroOrMore +/ +/ +FIXME +: +Our +literal +extraction +doesn +' +t +care +about +greediness +. +/ +/ +Which +is +partially +why +we +' +re +treating +' +e +? +' +as +' +e +* +' +. +Namely +/ +/ +' +ab +? +? +' +yields +[ +Complete +( +ab +) +Complete +( +a +) +] +but +it +should +yield +/ +/ +[ +Complete +( +a +) +Complete +( +ab +) +] +because +of +the +non +- +greediness +. +greedy +: +true +hir +: +Box +: +: +new +( +e +. +clone +( +) +) +} +) +lits +) +; +} +fn +repeat_zero_or_more_literals +< +F +: +FnMut +( +& +Hir +& +mut +Literals +) +> +( +e +: +& +Hir +lits +: +& +mut +Literals +mut +f +: +F +) +{ +let +( +mut +lits2 +mut +lits3 +) += +( +lits +. +clone +( +) +lits +. +to_empty +( +) +) +; +lits3 +. +set_limit_size +( +lits +. +limit_size +( +) +/ +2 +) +; +f +( +e +& +mut +lits3 +) +; +if +lits3 +. +is_empty +( +) +| +| +! +lits2 +. +cross_product +( +& +lits3 +) +{ +lits +. +cut +( +) +; +return +; +} +lits2 +. +cut +( +) +; +lits2 +. +add +( +Literal +: +: +empty +( +) +) +; +if +! +lits +. +union +( +lits2 +) +{ +lits +. +cut +( +) +; +} +} +fn +repeat_one_or_more_literals +< +F +: +FnMut +( +& +Hir +& +mut +Literals +) +> +( +e +: +& +Hir +lits +: +& +mut +Literals +mut +f +: +F +) +{ +f +( +e +lits +) +; +lits +. +cut +( +) +; +} +fn +repeat_range_literals +< +F +: +FnMut +( +& +Hir +& +mut +Literals +) +> +( +e +: +& +Hir +min +: +u32 +max +: +Option +< +u32 +> +greedy +: +bool +lits +: +& +mut +Literals +mut +f +: +F +) +{ +if +min += += +0 +{ +/ +/ +This +is +a +bit +conservative +. +If +max +is +set +then +we +could +/ +/ +treat +this +as +a +finite +set +of +alternations +. +For +now +we +/ +/ +just +treat +it +as +e +* +. +f +( +& +Hir +: +: +repetition +( +hir +: +: +Repetition +{ +kind +: +hir +: +: +RepetitionKind +: +: +ZeroOrMore +greedy +hir +: +Box +: +: +new +( +e +. +clone +( +) +) +} +) +lits +) +; +} +else +{ +if +min +> +0 +{ +let +n += +cmp +: +: +min +( +lits +. +limit_size +min +as +usize +) +; +let +es += +iter +: +: +repeat +( +e +. +clone +( +) +) +. +take +( +n +) +. +collect +( +) +; +f +( +& +Hir +: +: +concat +( +es +) +lits +) +; +if +n +< +min +as +usize +| +| +lits +. +contains_empty +( +) +{ +lits +. +cut +( +) +; +} +} +if +max +. +map_or +( +true +| +max +| +min +< +max +) +{ +lits +. +cut +( +) +; +} +} +} +fn +alternate_literals +< +F +: +FnMut +( +& +Hir +& +mut +Literals +) +> +( +es +: +& +[ +Hir +] +lits +: +& +mut +Literals +mut +f +: +F +) +{ +let +mut +lits2 += +lits +. +to_empty +( +) +; +for +e +in +es +{ +let +mut +lits3 += +lits +. +to_empty +( +) +; +lits3 +. +set_limit_size +( +lits +. +limit_size +( +) +/ +5 +) +; +f +( +e +& +mut +lits3 +) +; +if +lits3 +. +is_empty +( +) +| +| +! +lits2 +. +union +( +lits3 +) +{ +/ +/ +If +we +couldn +' +t +find +suffixes +for +* +any +* +of +the +/ +/ +alternates +then +the +entire +alternation +has +to +be +thrown +/ +/ +away +and +any +existing +members +must +be +frozen +. +Similarly +/ +/ +if +the +union +couldn +' +t +complete +stop +and +freeze +. +lits +. +cut +( +) +; +return +; +} +} +if +! +lits +. +cross_product +( +& +lits2 +) +{ +lits +. +cut +( +) +; +} +} +impl +fmt +: +: +Debug +for +Literals +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +f +. +debug_struct +( +" +Literals +" +) +. +field +( +" +lits +" +& +self +. +lits +) +. +field +( +" +limit_size +" +& +self +. +limit_size +) +. +field +( +" +limit_class +" +& +self +. +limit_class +) +. +finish +( +) +} +} +impl +Literal +{ +/ +/ +/ +Returns +a +new +complete +literal +with +the +bytes +given +. +pub +fn +new +( +bytes +: +Vec +< +u8 +> +) +- +> +Literal +{ +Literal +{ +v +: +bytes +cut +: +false +} +} +/ +/ +/ +Returns +a +new +complete +empty +literal +. +pub +fn +empty +( +) +- +> +Literal +{ +Literal +{ +v +: +vec +! +[ +] +cut +: +false +} +} +/ +/ +/ +Returns +true +if +this +literal +was +" +cut +. +" +pub +fn +is_cut +( +& +self +) +- +> +bool +{ +self +. +cut +} +/ +/ +/ +Cuts +this +literal +. +pub +fn +cut +( +& +mut +self +) +{ +self +. +cut += +true +; +} +} +impl +PartialEq +for +Literal +{ +fn +eq +( +& +self +other +: +& +Literal +) +- +> +bool +{ +self +. +v += += +other +. +v +} +} +impl +PartialOrd +for +Literal +{ +fn +partial_cmp +( +& +self +other +: +& +Literal +) +- +> +Option +< +cmp +: +: +Ordering +> +{ +self +. +v +. +partial_cmp +( +& +other +. +v +) +} +} +impl +fmt +: +: +Debug +for +Literal +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +if +self +. +is_cut +( +) +{ +write +! +( +f +" +Cut +( +{ +} +) +" +escape_unicode +( +& +self +. +v +) +) +} +else +{ +write +! +( +f +" +Complete +( +{ +} +) +" +escape_unicode +( +& +self +. +v +) +) +} +} +} +impl +AsRef +< +[ +u8 +] +> +for +Literal +{ +fn +as_ref +( +& +self +) +- +> +& +[ +u8 +] +{ +& +self +. +v +} +} +impl +ops +: +: +Deref +for +Literal +{ +type +Target += +Vec +< +u8 +> +; +fn +deref +( +& +self +) +- +> +& +Vec +< +u8 +> +{ +& +self +. +v +} +} +impl +ops +: +: +DerefMut +for +Literal +{ +fn +deref_mut +( +& +mut +self +) +- +> +& +mut +Vec +< +u8 +> +{ +& +mut +self +. +v +} +} +fn +position +( +needle +: +& +[ +u8 +] +mut +haystack +: +& +[ +u8 +] +) +- +> +Option +< +usize +> +{ +let +mut +i += +0 +; +while +haystack +. +len +( +) +> += +needle +. +len +( +) +{ +if +needle += += +& +haystack +[ +. +. +needle +. +len +( +) +] +{ +return +Some +( +i +) +; +} +i ++ += +1 +; +haystack += +& +haystack +[ +1 +. +. +] +; +} +None +} +fn +escape_unicode +( +bytes +: +& +[ +u8 +] +) +- +> +String +{ +let +show += +match +: +: +std +: +: +str +: +: +from_utf8 +( +bytes +) +{ +Ok +( +v +) += +> +v +. +to_string +( +) +Err +( +_ +) += +> +escape_bytes +( +bytes +) +} +; +let +mut +space_escaped += +String +: +: +new +( +) +; +for +c +in +show +. +chars +( +) +{ +if +c +. +is_whitespace +( +) +{ +let +escaped += +if +c +as +u32 +< += +0x7F +{ +escape_byte +( +c +as +u8 +) +} +else +if +c +as +u32 +< += +0xFFFF +{ +format +! +( +r +" +\ +u +{ +{ +{ +: +04x +} +} +} +" +c +as +u32 +) +} +else +{ +format +! +( +r +" +\ +U +{ +{ +{ +: +08x +} +} +} +" +c +as +u32 +) +} +; +space_escaped +. +push_str +( +& +escaped +) +; +} +else +{ +space_escaped +. +push +( +c +) +; +} +} +space_escaped +} +fn +escape_bytes +( +bytes +: +& +[ +u8 +] +) +- +> +String +{ +let +mut +s += +String +: +: +new +( +) +; +for +& +b +in +bytes +{ +s +. +push_str +( +& +escape_byte +( +b +) +) +; +} +s +} +fn +escape_byte +( +byte +: +u8 +) +- +> +String +{ +use +std +: +: +ascii +: +: +escape_default +; +let +escaped +: +Vec +< +u8 +> += +escape_default +( +byte +) +. +collect +( +) +; +String +: +: +from_utf8_lossy +( +& +escaped +) +. +into_owned +( +) +} +fn +cls_char_count +( +cls +: +& +hir +: +: +ClassUnicode +) +- +> +usize +{ +cls +. +iter +( +) +. +map +( +| +& +r +| +1 ++ +( +r +. +end +as +u32 +) +- +( +r +. +start +as +u32 +) +) +. +sum +: +: +< +u32 +> +( +) +as +usize +} +fn +cls_byte_count +( +cls +: +& +hir +: +: +ClassBytes +) +- +> +usize +{ +cls +. +iter +( +) +. +map +( +| +& +r +| +1 ++ +( +r +. +end +as +u32 +) +- +( +r +. +start +as +u32 +) +) +. +sum +: +: +< +u32 +> +( +) +as +usize +} +# +[ +cfg +( +test +) +] +mod +tests +{ +use +std +: +: +fmt +; +use +super +: +: +{ +escape_bytes +Literal +Literals +} +; +use +crate +: +: +hir +: +: +Hir +; +use +crate +: +: +ParserBuilder +; +/ +/ +To +make +test +failures +easier +to +read +. +# +[ +derive +( +Debug +Eq +PartialEq +) +] +struct +Bytes +( +Vec +< +ULiteral +> +) +; +# +[ +derive +( +Debug +Eq +PartialEq +) +] +struct +Unicode +( +Vec +< +ULiteral +> +) +; +fn +escape_lits +( +blits +: +& +[ +Literal +] +) +- +> +Vec +< +ULiteral +> +{ +let +mut +ulits += +vec +! +[ +] +; +for +blit +in +blits +{ +ulits +. +push +( +ULiteral +{ +v +: +escape_bytes +( +& +blit +) +cut +: +blit +. +is_cut +( +) +} +) +; +} +ulits +} +fn +create_lits +< +I +: +IntoIterator +< +Item += +Literal +> +> +( +it +: +I +) +- +> +Literals +{ +Literals +{ +lits +: +it +. +into_iter +( +) +. +collect +( +) +limit_size +: +0 +limit_class +: +0 +} +} +/ +/ +Needs +to +be +pub +for +1 +. +3 +? +# +[ +derive +( +Clone +Eq +PartialEq +) +] +pub +struct +ULiteral +{ +v +: +String +cut +: +bool +} +impl +ULiteral +{ +fn +is_cut +( +& +self +) +- +> +bool +{ +self +. +cut +} +} +impl +fmt +: +: +Debug +for +ULiteral +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +if +self +. +is_cut +( +) +{ +write +! +( +f +" +Cut +( +{ +} +) +" +self +. +v +) +} +else +{ +write +! +( +f +" +Complete +( +{ +} +) +" +self +. +v +) +} +} +} +impl +PartialEq +< +Literal +> +for +ULiteral +{ +fn +eq +( +& +self +other +: +& +Literal +) +- +> +bool +{ +self +. +v +. +as_bytes +( +) += += +& +* +other +. +v +& +& +self +. +is_cut +( +) += += +other +. +is_cut +( +) +} +} +impl +PartialEq +< +ULiteral +> +for +Literal +{ +fn +eq +( +& +self +other +: +& +ULiteral +) +- +> +bool +{ +& +* +self +. +v += += +other +. +v +. +as_bytes +( +) +& +& +self +. +is_cut +( +) += += +other +. +is_cut +( +) +} +} +# +[ +allow +( +non_snake_case +) +] +fn +C +( +s +: +& +' +static +str +) +- +> +ULiteral +{ +ULiteral +{ +v +: +s +. +to_owned +( +) +cut +: +true +} +} +# +[ +allow +( +non_snake_case +) +] +fn +M +( +s +: +& +' +static +str +) +- +> +ULiteral +{ +ULiteral +{ +v +: +s +. +to_owned +( +) +cut +: +false +} +} +fn +prefixes +( +lits +: +& +mut +Literals +expr +: +& +Hir +) +{ +lits +. +union_prefixes +( +expr +) +; +} +fn +suffixes +( +lits +: +& +mut +Literals +expr +: +& +Hir +) +{ +lits +. +union_suffixes +( +expr +) +; +} +macro_rules +! +assert_lit_eq +{ +( +which +: +ident +got_lits +: +expr +( +expected_lit +: +expr +) +* +) += +> +{ +{ +let +expected +: +Vec +< +ULiteral +> += +vec +! +[ +( +expected_lit +) +* +] +; +let +lits += +got_lits +; +assert_eq +! +( +which +( +expected +. +clone +( +) +) +which +( +escape_lits +( +lits +. +literals +( +) +) +) +) +; +assert_eq +! +( +! +expected +. +is_empty +( +) +& +& +expected +. +iter +( +) +. +all +( +| +l +| +! +l +. +is_cut +( +) +) +lits +. +all_complete +( +) +) +; +assert_eq +! +( +expected +. +iter +( +) +. +any +( +| +l +| +! +l +. +is_cut +( +) +) +lits +. +any_complete +( +) +) +; +} +} +; +} +macro_rules +! +test_lit +{ +( +name +: +ident +which +: +ident +re +: +expr +) += +> +{ +test_lit +! +( +name +which +re +) +; +} +; +( +name +: +ident +which +: +ident +re +: +expr +( +lit +: +expr +) +* +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +expr += +ParserBuilder +: +: +new +( +) +. +build +( +) +. +parse +( +re +) +. +unwrap +( +) +; +let +lits += +Literals +: +: +which +( +& +expr +) +; +assert_lit_eq +! +( +Unicode +lits +( +lit +) +* +) +; +let +expr += +ParserBuilder +: +: +new +( +) +. +allow_invalid_utf8 +( +true +) +. +unicode +( +false +) +. +build +( +) +. +parse +( +re +) +. +unwrap +( +) +; +let +lits += +Literals +: +: +which +( +& +expr +) +; +assert_lit_eq +! +( +Bytes +lits +( +lit +) +* +) +; +} +} +; +} +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Tests +for +prefix +literal +extraction +. +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Elementary +tests +. +test_lit +! +( +pfx_one_lit1 +prefixes +" +a +" +M +( +" +a +" +) +) +; +test_lit +! +( +pfx_one_lit2 +prefixes +" +abc +" +M +( +" +abc +" +) +) +; +test_lit +! +( +pfx_one_lit3 +prefixes +" +( +? +u +) +" +M +( +" +\ +\ +xe2 +\ +\ +x98 +\ +\ +x83 +" +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +test_lit +! +( +pfx_one_lit4 +prefixes +" +( +? +ui +) +" +M +( +" +\ +\ +xe2 +\ +\ +x98 +\ +\ +x83 +" +) +) +; +test_lit +! +( +pfx_class1 +prefixes +" +[ +1 +- +4 +] +" +M +( +" +1 +" +) +M +( +" +2 +" +) +M +( +" +3 +" +) +M +( +" +4 +" +) +) +; +test_lit +! +( +pfx_class2 +prefixes +" +( +? +u +) +[ +] +" +M +( +" +\ +\ +xe2 +\ +\ +x85 +\ +\ +xa0 +" +) +M +( +" +\ +\ +xe2 +\ +\ +x98 +\ +\ +x83 +" +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +test_lit +! +( +pfx_class3 +prefixes +" +( +? +ui +) +[ +] +" +M +( +" +\ +\ +xe2 +\ +\ +x85 +\ +\ +xa0 +" +) +M +( +" +\ +\ +xe2 +\ +\ +x85 +\ +\ +xb0 +" +) +M +( +" +\ +\ +xe2 +\ +\ +x98 +\ +\ +x83 +" +) +) +; +test_lit +! +( +pfx_one_lit_casei1 +prefixes +" +( +? +i +- +u +) +a +" +M +( +" +A +" +) +M +( +" +a +" +) +) +; +test_lit +! +( +pfx_one_lit_casei2 +prefixes +" +( +? +i +- +u +) +abc +" +M +( +" +ABC +" +) +M +( +" +aBC +" +) +M +( +" +AbC +" +) +M +( +" +abC +" +) +M +( +" +ABc +" +) +M +( +" +aBc +" +) +M +( +" +Abc +" +) +M +( +" +abc +" +) +) +; +test_lit +! +( +pfx_group1 +prefixes +" +( +a +) +" +M +( +" +a +" +) +) +; +test_lit +! +( +pfx_rep_zero_or_one1 +prefixes +" +a +? +" +) +; +test_lit +! +( +pfx_rep_zero_or_one2 +prefixes +" +( +? +: +abc +) +? +" +) +; +test_lit +! +( +pfx_rep_zero_or_one_cat1 +prefixes +" +ab +? +" +C +( +" +ab +" +) +M +( +" +a +" +) +) +; +/ +/ +FIXME +: +This +should +return +[ +M +( +" +a +" +) +M +( +" +ab +" +) +] +because +of +the +non +- +greedy +/ +/ +repetition +. +As +a +work +- +around +we +rewrite +ab +? +? +as +ab +* +? +and +thus +we +get +/ +/ +a +cut +literal +. +test_lit +! +( +pfx_rep_zero_or_one_cat2 +prefixes +" +ab +? +? +" +C +( +" +ab +" +) +M +( +" +a +" +) +) +; +test_lit +! +( +pfx_rep_zero_or_more1 +prefixes +" +a +* +" +) +; +test_lit +! +( +pfx_rep_zero_or_more2 +prefixes +" +( +? +: +abc +) +* +" +) +; +test_lit +! +( +pfx_rep_one_or_more1 +prefixes +" +a ++ +" +C +( +" +a +" +) +) +; +test_lit +! +( +pfx_rep_one_or_more2 +prefixes +" +( +? +: +abc +) ++ +" +C +( +" +abc +" +) +) +; +test_lit +! +( +pfx_rep_nested_one_or_more +prefixes +" +( +? +: +a ++ +) ++ +" +C +( +" +a +" +) +) +; +test_lit +! +( +pfx_rep_range1 +prefixes +" +a +{ +0 +} +" +) +; +test_lit +! +( +pfx_rep_range2 +prefixes +" +a +{ +0 +} +" +) +; +test_lit +! +( +pfx_rep_range3 +prefixes +" +a +{ +0 +1 +} +" +) +; +test_lit +! +( +pfx_rep_range4 +prefixes +" +a +{ +1 +} +" +M +( +" +a +" +) +) +; +test_lit +! +( +pfx_rep_range5 +prefixes +" +a +{ +2 +} +" +M +( +" +aa +" +) +) +; +test_lit +! +( +pfx_rep_range6 +prefixes +" +a +{ +1 +2 +} +" +C +( +" +a +" +) +) +; +test_lit +! +( +pfx_rep_range7 +prefixes +" +a +{ +2 +3 +} +" +C +( +" +aa +" +) +) +; +/ +/ +Test +regexes +with +concatenations +. +test_lit +! +( +pfx_cat1 +prefixes +" +( +? +: +a +) +( +? +: +b +) +" +M +( +" +ab +" +) +) +; +test_lit +! +( +pfx_cat2 +prefixes +" +[ +ab +] +z +" +M +( +" +az +" +) +M +( +" +bz +" +) +) +; +test_lit +! +( +pfx_cat3 +prefixes +" +( +? +i +- +u +) +[ +ab +] +z +" +M +( +" +AZ +" +) +M +( +" +BZ +" +) +M +( +" +aZ +" +) +M +( +" +bZ +" +) +M +( +" +Az +" +) +M +( +" +Bz +" +) +M +( +" +az +" +) +M +( +" +bz +" +) +) +; +test_lit +! +( +pfx_cat4 +prefixes +" +[ +ab +] +[ +yz +] +" +M +( +" +ay +" +) +M +( +" +by +" +) +M +( +" +az +" +) +M +( +" +bz +" +) +) +; +test_lit +! +( +pfx_cat5 +prefixes +" +a +* +b +" +C +( +" +a +" +) +M +( +" +b +" +) +) +; +test_lit +! +( +pfx_cat6 +prefixes +" +a +* +b +* +c +" +C +( +" +a +" +) +C +( +" +b +" +) +M +( +" +c +" +) +) +; +test_lit +! +( +pfx_cat7 +prefixes +" +a +* +b +* +c ++ +" +C +( +" +a +" +) +C +( +" +b +" +) +C +( +" +c +" +) +) +; +test_lit +! +( +pfx_cat8 +prefixes +" +a +* +b ++ +c +" +C +( +" +a +" +) +C +( +" +b +" +) +) +; +test_lit +! +( +pfx_cat9 +prefixes +" +a +* +b ++ +c +* +" +C +( +" +a +" +) +C +( +" +b +" +) +) +; +test_lit +! +( +pfx_cat10 +prefixes +" +ab +* +" +C +( +" +ab +" +) +M +( +" +a +" +) +) +; +test_lit +! +( +pfx_cat11 +prefixes +" +ab +* +c +" +C +( +" +ab +" +) +M +( +" +ac +" +) +) +; +test_lit +! +( +pfx_cat12 +prefixes +" +ab ++ +" +C +( +" +ab +" +) +) +; +test_lit +! +( +pfx_cat13 +prefixes +" +ab ++ +c +" +C +( +" +ab +" +) +) +; +test_lit +! +( +pfx_cat14 +prefixes +" +a +^ +" +C +( +" +a +" +) +) +; +test_lit +! +( +pfx_cat15 +prefixes +" +a +" +) +; +test_lit +! +( +pfx_cat16 +prefixes +r +" +ab +* +c +" +C +( +" +ab +" +) +M +( +" +ac +" +) +) +; +test_lit +! +( +pfx_cat17 +prefixes +r +" +ab ++ +c +" +C +( +" +ab +" +) +) +; +test_lit +! +( +pfx_cat18 +prefixes +r +" +z +* +azb +" +C +( +" +z +" +) +M +( +" +azb +" +) +) +; +test_lit +! +( +pfx_cat19 +prefixes +" +a +. +z +" +C +( +" +a +" +) +) +; +/ +/ +Test +regexes +with +alternations +. +test_lit +! +( +pfx_alt1 +prefixes +" +a +| +b +" +M +( +" +a +" +) +M +( +" +b +" +) +) +; +test_lit +! +( +pfx_alt2 +prefixes +" +[ +1 +- +3 +] +| +b +" +M +( +" +1 +" +) +M +( +" +2 +" +) +M +( +" +3 +" +) +M +( +" +b +" +) +) +; +test_lit +! +( +pfx_alt3 +prefixes +" +y +( +? +: +a +| +b +) +z +" +M +( +" +yaz +" +) +M +( +" +ybz +" +) +) +; +test_lit +! +( +pfx_alt4 +prefixes +" +a +| +b +* +" +) +; +test_lit +! +( +pfx_alt5 +prefixes +" +a +| +b ++ +" +M +( +" +a +" +) +C +( +" +b +" +) +) +; +test_lit +! +( +pfx_alt6 +prefixes +" +a +| +( +? +: +b +| +c +* +) +" +) +; +test_lit +! +( +pfx_alt7 +prefixes +" +( +a +| +b +) +* +c +| +( +a +| +ab +) +* +c +" +C +( +" +a +" +) +C +( +" +b +" +) +M +( +" +c +" +) +C +( +" +a +" +) +C +( +" +ab +" +) +M +( +" +c +" +) +) +; +test_lit +! +( +pfx_alt8 +prefixes +" +a +* +b +| +c +" +C +( +" +a +" +) +M +( +" +b +" +) +M +( +" +c +" +) +) +; +/ +/ +Test +regexes +with +empty +assertions +. +test_lit +! +( +pfx_empty1 +prefixes +" +^ +a +" +M +( +" +a +" +) +) +; +test_lit +! +( +pfx_empty2 +prefixes +" +a +{ +2 +} +" +C +( +" +a +" +) +) +; +test_lit +! +( +pfx_empty3 +prefixes +" +^ +abc +" +M +( +" +abc +" +) +) +; +test_lit +! +( +pfx_empty4 +prefixes +" +( +? +: +^ +abc +) +| +( +? +: +^ +z +) +" +M +( +" +abc +" +) +M +( +" +z +" +) +) +; +/ +/ +Make +sure +some +curious +regexes +have +no +prefixes +. +test_lit +! +( +pfx_nothing1 +prefixes +" +. +" +) +; +test_lit +! +( +pfx_nothing2 +prefixes +" +( +? +s +) +. +" +) +; +test_lit +! +( +pfx_nothing3 +prefixes +" +^ +" +) +; +test_lit +! +( +pfx_nothing4 +prefixes +" +" +) +; +test_lit +! +( +pfx_nothing6 +prefixes +" +( +? +m +) +" +) +; +test_lit +! +( +pfx_nothing7 +prefixes +r +" +\ +b +" +) +; +test_lit +! +( +pfx_nothing8 +prefixes +r +" +\ +B +" +) +; +/ +/ +Test +a +few +regexes +that +defeat +any +prefix +literal +detection +. +test_lit +! +( +pfx_defeated1 +prefixes +" +. +a +" +) +; +test_lit +! +( +pfx_defeated2 +prefixes +" +( +? +s +) +. +a +" +) +; +test_lit +! +( +pfx_defeated3 +prefixes +" +a +* +b +* +c +* +" +) +; +test_lit +! +( +pfx_defeated4 +prefixes +" +a +| +. +" +) +; +test_lit +! +( +pfx_defeated5 +prefixes +" +. +| +a +" +) +; +test_lit +! +( +pfx_defeated6 +prefixes +" +a +| +^ +" +) +; +test_lit +! +( +pfx_defeated7 +prefixes +" +. +( +? +: +a +( +? +: +b +) +( +? +: +c +) +) +" +) +; +test_lit +! +( +pfx_defeated8 +prefixes +" +a +" +) +; +test_lit +! +( +pfx_defeated9 +prefixes +" +( +? +m +) +a +" +) +; +test_lit +! +( +pfx_defeated10 +prefixes +r +" +\ +ba +" +) +; +test_lit +! +( +pfx_defeated11 +prefixes +r +" +\ +Ba +" +) +; +test_lit +! +( +pfx_defeated12 +prefixes +" +^ +* +a +" +) +; +test_lit +! +( +pfx_defeated13 +prefixes +" +^ ++ +a +" +) +; +test_lit +! +( +pfx_crazy1 +prefixes +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +C +( +" +Mo +\ +\ +' +" +) +C +( +" +Mu +\ +\ +' +" +) +C +( +" +Moam +" +) +C +( +" +Muam +" +) +) +; +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Tests +for +quiting +prefix +literal +search +. +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +macro_rules +! +test_exhausted +{ +( +name +: +ident +which +: +ident +re +: +expr +) += +> +{ +test_exhausted +! +( +name +which +re +) +; +} +; +( +name +: +ident +which +: +ident +re +: +expr +( +lit +: +expr +) +* +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +expr += +ParserBuilder +: +: +new +( +) +. +build +( +) +. +parse +( +re +) +. +unwrap +( +) +; +let +mut +lits += +Literals +: +: +empty +( +) +; +lits +. +set_limit_size +( +20 +) +. +set_limit_class +( +10 +) +; +which +( +& +mut +lits +& +expr +) +; +assert_lit_eq +! +( +Unicode +lits +( +lit +) +* +) +; +let +expr += +ParserBuilder +: +: +new +( +) +. +allow_invalid_utf8 +( +true +) +. +unicode +( +false +) +. +build +( +) +. +parse +( +re +) +. +unwrap +( +) +; +let +mut +lits += +Literals +: +: +empty +( +) +; +lits +. +set_limit_size +( +20 +) +. +set_limit_class +( +10 +) +; +which +( +& +mut +lits +& +expr +) +; +assert_lit_eq +! +( +Bytes +lits +( +lit +) +* +) +; +} +} +; +} +/ +/ +These +test +use +a +much +lower +limit +than +the +default +so +that +we +can +/ +/ +write +test +cases +of +reasonable +size +. +test_exhausted +! +( +pfx_exhausted1 +prefixes +" +[ +a +- +z +] +" +) +; +test_exhausted +! +( +pfx_exhausted2 +prefixes +" +[ +a +- +z +] +* +A +" +) +; +test_exhausted +! +( +pfx_exhausted3 +prefixes +" +A +[ +a +- +z +] +Z +" +C +( +" +A +" +) +) +; +test_exhausted +! +( +pfx_exhausted4 +prefixes +" +( +? +i +- +u +) +foobar +" +C +( +" +FO +" +) +C +( +" +fO +" +) +C +( +" +Fo +" +) +C +( +" +fo +" +) +) +; +test_exhausted +! +( +pfx_exhausted5 +prefixes +" +( +? +: +ab +) +{ +100 +} +" +C +( +" +abababababababababab +" +) +) +; +test_exhausted +! +( +pfx_exhausted6 +prefixes +" +( +? +: +( +? +: +ab +) +{ +100 +} +) +* +cd +" +C +( +" +ababababab +" +) +M +( +" +cd +" +) +) +; +test_exhausted +! +( +pfx_exhausted7 +prefixes +" +z +( +? +: +( +? +: +ab +) +{ +100 +} +) +* +cd +" +C +( +" +zababababab +" +) +M +( +" +zcd +" +) +) +; +test_exhausted +! +( +pfx_exhausted8 +prefixes +" +aaaaaaaaaaaaaaaaaaaaz +" +C +( +" +aaaaaaaaaaaaaaaaaaaa +" +) +) +; +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Tests +for +suffix +literal +extraction +. +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Elementary +tests +. +test_lit +! +( +sfx_one_lit1 +suffixes +" +a +" +M +( +" +a +" +) +) +; +test_lit +! +( +sfx_one_lit2 +suffixes +" +abc +" +M +( +" +abc +" +) +) +; +test_lit +! +( +sfx_one_lit3 +suffixes +" +( +? +u +) +" +M +( +" +\ +\ +xe2 +\ +\ +x98 +\ +\ +x83 +" +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +test_lit +! +( +sfx_one_lit4 +suffixes +" +( +? +ui +) +" +M +( +" +\ +\ +xe2 +\ +\ +x98 +\ +\ +x83 +" +) +) +; +test_lit +! +( +sfx_class1 +suffixes +" +[ +1 +- +4 +] +" +M +( +" +1 +" +) +M +( +" +2 +" +) +M +( +" +3 +" +) +M +( +" +4 +" +) +) +; +test_lit +! +( +sfx_class2 +suffixes +" +( +? +u +) +[ +] +" +M +( +" +\ +\ +xe2 +\ +\ +x85 +\ +\ +xa0 +" +) +M +( +" +\ +\ +xe2 +\ +\ +x98 +\ +\ +x83 +" +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +test_lit +! +( +sfx_class3 +suffixes +" +( +? +ui +) +[ +] +" +M +( +" +\ +\ +xe2 +\ +\ +x85 +\ +\ +xa0 +" +) +M +( +" +\ +\ +xe2 +\ +\ +x85 +\ +\ +xb0 +" +) +M +( +" +\ +\ +xe2 +\ +\ +x98 +\ +\ +x83 +" +) +) +; +test_lit +! +( +sfx_one_lit_casei1 +suffixes +" +( +? +i +- +u +) +a +" +M +( +" +A +" +) +M +( +" +a +" +) +) +; +test_lit +! +( +sfx_one_lit_casei2 +suffixes +" +( +? +i +- +u +) +abc +" +M +( +" +ABC +" +) +M +( +" +ABc +" +) +M +( +" +AbC +" +) +M +( +" +Abc +" +) +M +( +" +aBC +" +) +M +( +" +aBc +" +) +M +( +" +abC +" +) +M +( +" +abc +" +) +) +; +test_lit +! +( +sfx_group1 +suffixes +" +( +a +) +" +M +( +" +a +" +) +) +; +test_lit +! +( +sfx_rep_zero_or_one1 +suffixes +" +a +? +" +) +; +test_lit +! +( +sfx_rep_zero_or_one2 +suffixes +" +( +? +: +abc +) +? +" +) +; +test_lit +! +( +sfx_rep_zero_or_more1 +suffixes +" +a +* +" +) +; +test_lit +! +( +sfx_rep_zero_or_more2 +suffixes +" +( +? +: +abc +) +* +" +) +; +test_lit +! +( +sfx_rep_one_or_more1 +suffixes +" +a ++ +" +C +( +" +a +" +) +) +; +test_lit +! +( +sfx_rep_one_or_more2 +suffixes +" +( +? +: +abc +) ++ +" +C +( +" +abc +" +) +) +; +test_lit +! +( +sfx_rep_nested_one_or_more +suffixes +" +( +? +: +a ++ +) ++ +" +C +( +" +a +" +) +) +; +test_lit +! +( +sfx_rep_range1 +suffixes +" +a +{ +0 +} +" +) +; +test_lit +! +( +sfx_rep_range2 +suffixes +" +a +{ +0 +} +" +) +; +test_lit +! +( +sfx_rep_range3 +suffixes +" +a +{ +0 +1 +} +" +) +; +test_lit +! +( +sfx_rep_range4 +suffixes +" +a +{ +1 +} +" +M +( +" +a +" +) +) +; +test_lit +! +( +sfx_rep_range5 +suffixes +" +a +{ +2 +} +" +M +( +" +aa +" +) +) +; +test_lit +! +( +sfx_rep_range6 +suffixes +" +a +{ +1 +2 +} +" +C +( +" +a +" +) +) +; +test_lit +! +( +sfx_rep_range7 +suffixes +" +a +{ +2 +3 +} +" +C +( +" +aa +" +) +) +; +/ +/ +Test +regexes +with +concatenations +. +test_lit +! +( +sfx_cat1 +suffixes +" +( +? +: +a +) +( +? +: +b +) +" +M +( +" +ab +" +) +) +; +test_lit +! +( +sfx_cat2 +suffixes +" +[ +ab +] +z +" +M +( +" +az +" +) +M +( +" +bz +" +) +) +; +test_lit +! +( +sfx_cat3 +suffixes +" +( +? +i +- +u +) +[ +ab +] +z +" +M +( +" +AZ +" +) +M +( +" +Az +" +) +M +( +" +BZ +" +) +M +( +" +Bz +" +) +M +( +" +aZ +" +) +M +( +" +az +" +) +M +( +" +bZ +" +) +M +( +" +bz +" +) +) +; +test_lit +! +( +sfx_cat4 +suffixes +" +[ +ab +] +[ +yz +] +" +M +( +" +ay +" +) +M +( +" +az +" +) +M +( +" +by +" +) +M +( +" +bz +" +) +) +; +test_lit +! +( +sfx_cat5 +suffixes +" +a +* +b +" +C +( +" +ab +" +) +M +( +" +b +" +) +) +; +test_lit +! +( +sfx_cat6 +suffixes +" +a +* +b +* +c +" +C +( +" +bc +" +) +C +( +" +ac +" +) +M +( +" +c +" +) +) +; +test_lit +! +( +sfx_cat7 +suffixes +" +a +* +b +* +c ++ +" +C +( +" +c +" +) +) +; +test_lit +! +( +sfx_cat8 +suffixes +" +a +* +b ++ +c +" +C +( +" +bc +" +) +) +; +test_lit +! +( +sfx_cat9 +suffixes +" +a +* +b ++ +c +* +" +C +( +" +c +" +) +C +( +" +b +" +) +) +; +test_lit +! +( +sfx_cat10 +suffixes +" +ab +* +" +C +( +" +b +" +) +M +( +" +a +" +) +) +; +test_lit +! +( +sfx_cat11 +suffixes +" +ab +* +c +" +C +( +" +bc +" +) +M +( +" +ac +" +) +) +; +test_lit +! +( +sfx_cat12 +suffixes +" +ab ++ +" +C +( +" +b +" +) +) +; +test_lit +! +( +sfx_cat13 +suffixes +" +ab ++ +c +" +C +( +" +bc +" +) +) +; +test_lit +! +( +sfx_cat14 +suffixes +" +a +^ +" +) +; +test_lit +! +( +sfx_cat15 +suffixes +" +a +" +C +( +" +a +" +) +) +; +test_lit +! +( +sfx_cat16 +suffixes +r +" +ab +* +c +" +C +( +" +bc +" +) +M +( +" +ac +" +) +) +; +test_lit +! +( +sfx_cat17 +suffixes +r +" +ab ++ +c +" +C +( +" +bc +" +) +) +; +test_lit +! +( +sfx_cat18 +suffixes +r +" +z +* +azb +" +C +( +" +zazb +" +) +M +( +" +azb +" +) +) +; +test_lit +! +( +sfx_cat19 +suffixes +" +a +. +z +" +C +( +" +z +" +) +) +; +/ +/ +Test +regexes +with +alternations +. +test_lit +! +( +sfx_alt1 +suffixes +" +a +| +b +" +M +( +" +a +" +) +M +( +" +b +" +) +) +; +test_lit +! +( +sfx_alt2 +suffixes +" +[ +1 +- +3 +] +| +b +" +M +( +" +1 +" +) +M +( +" +2 +" +) +M +( +" +3 +" +) +M +( +" +b +" +) +) +; +test_lit +! +( +sfx_alt3 +suffixes +" +y +( +? +: +a +| +b +) +z +" +M +( +" +yaz +" +) +M +( +" +ybz +" +) +) +; +test_lit +! +( +sfx_alt4 +suffixes +" +a +| +b +* +" +) +; +test_lit +! +( +sfx_alt5 +suffixes +" +a +| +b ++ +" +M +( +" +a +" +) +C +( +" +b +" +) +) +; +test_lit +! +( +sfx_alt6 +suffixes +" +a +| +( +? +: +b +| +c +* +) +" +) +; +test_lit +! +( +sfx_alt7 +suffixes +" +( +a +| +b +) +* +c +| +( +a +| +ab +) +* +c +" +C +( +" +ac +" +) +C +( +" +bc +" +) +M +( +" +c +" +) +C +( +" +ac +" +) +C +( +" +abc +" +) +M +( +" +c +" +) +) +; +test_lit +! +( +sfx_alt8 +suffixes +" +a +* +b +| +c +" +C +( +" +ab +" +) +M +( +" +b +" +) +M +( +" +c +" +) +) +; +/ +/ +Test +regexes +with +empty +assertions +. +test_lit +! +( +sfx_empty1 +suffixes +" +a +" +M +( +" +a +" +) +) +; +test_lit +! +( +sfx_empty2 +suffixes +" +{ +2 +} +a +" +C +( +" +a +" +) +) +; +/ +/ +Make +sure +some +curious +regexes +have +no +suffixes +. +test_lit +! +( +sfx_nothing1 +suffixes +" +. +" +) +; +test_lit +! +( +sfx_nothing2 +suffixes +" +( +? +s +) +. +" +) +; +test_lit +! +( +sfx_nothing3 +suffixes +" +^ +" +) +; +test_lit +! +( +sfx_nothing4 +suffixes +" +" +) +; +test_lit +! +( +sfx_nothing6 +suffixes +" +( +? +m +) +" +) +; +test_lit +! +( +sfx_nothing7 +suffixes +r +" +\ +b +" +) +; +test_lit +! +( +sfx_nothing8 +suffixes +r +" +\ +B +" +) +; +/ +/ +Test +a +few +regexes +that +defeat +any +suffix +literal +detection +. +test_lit +! +( +sfx_defeated1 +suffixes +" +a +. +" +) +; +test_lit +! +( +sfx_defeated2 +suffixes +" +( +? +s +) +a +. +" +) +; +test_lit +! +( +sfx_defeated3 +suffixes +" +a +* +b +* +c +* +" +) +; +test_lit +! +( +sfx_defeated4 +suffixes +" +a +| +. +" +) +; +test_lit +! +( +sfx_defeated5 +suffixes +" +. +| +a +" +) +; +test_lit +! +( +sfx_defeated6 +suffixes +" +a +| +^ +" +) +; +test_lit +! +( +sfx_defeated7 +suffixes +" +( +? +: +a +( +? +: +b +) +( +? +: +c +) +) +. +" +) +; +test_lit +! +( +sfx_defeated8 +suffixes +" +a +^ +" +) +; +test_lit +! +( +sfx_defeated9 +suffixes +" +( +? +m +) +a +" +) +; +test_lit +! +( +sfx_defeated10 +suffixes +r +" +a +\ +b +" +) +; +test_lit +! +( +sfx_defeated11 +suffixes +r +" +a +\ +B +" +) +; +test_lit +! +( +sfx_defeated12 +suffixes +" +a +^ +* +" +) +; +test_lit +! +( +sfx_defeated13 +suffixes +" +a +^ ++ +" +) +; +/ +/ +These +test +use +a +much +lower +limit +than +the +default +so +that +we +can +/ +/ +write +test +cases +of +reasonable +size +. +test_exhausted +! +( +sfx_exhausted1 +suffixes +" +[ +a +- +z +] +" +) +; +test_exhausted +! +( +sfx_exhausted2 +suffixes +" +A +[ +a +- +z +] +* +" +) +; +test_exhausted +! +( +sfx_exhausted3 +suffixes +" +A +[ +a +- +z +] +Z +" +C +( +" +Z +" +) +) +; +test_exhausted +! +( +sfx_exhausted4 +suffixes +" +( +? +i +- +u +) +foobar +" +C +( +" +AR +" +) +C +( +" +Ar +" +) +C +( +" +aR +" +) +C +( +" +ar +" +) +) +; +test_exhausted +! +( +sfx_exhausted5 +suffixes +" +( +? +: +ab +) +{ +100 +} +" +C +( +" +abababababababababab +" +) +) +; +test_exhausted +! +( +sfx_exhausted6 +suffixes +" +cd +( +? +: +( +? +: +ab +) +{ +100 +} +) +* +" +C +( +" +ababababab +" +) +M +( +" +cd +" +) +) +; +test_exhausted +! +( +sfx_exhausted7 +suffixes +" +cd +( +? +: +( +? +: +ab +) +{ +100 +} +) +* +z +" +C +( +" +abababababz +" +) +M +( +" +cdz +" +) +) +; +test_exhausted +! +( +sfx_exhausted8 +suffixes +" +zaaaaaaaaaaaaaaaaaaaa +" +C +( +" +aaaaaaaaaaaaaaaaaaaa +" +) +) +; +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Tests +for +generating +unambiguous +literal +sets +. +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +macro_rules +! +test_unamb +{ +( +name +: +ident +given +: +expr +expected +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +given +: +Vec +< +Literal +> += +given +. +into_iter +( +) +. +map +( +| +ul +| +{ +let +cut += +ul +. +is_cut +( +) +; +Literal +{ +v +: +ul +. +v +. +into_bytes +( +) +cut +: +cut +} +} +) +. +collect +( +) +; +let +lits += +create_lits +( +given +) +; +let +got += +lits +. +unambiguous_prefixes +( +) +; +assert_eq +! +( +expected +escape_lits +( +got +. +literals +( +) +) +) +; +} +} +; +} +test_unamb +! +( +unambiguous1 +vec +! +[ +M +( +" +z +" +) +M +( +" +azb +" +) +] +vec +! +[ +C +( +" +a +" +) +C +( +" +z +" +) +] +) +; +test_unamb +! +( +unambiguous2 +vec +! +[ +M +( +" +zaaaaaa +" +) +M +( +" +aa +" +) +] +vec +! +[ +C +( +" +aa +" +) +C +( +" +z +" +) +] +) +; +test_unamb +! +( +unambiguous3 +vec +! +[ +M +( +" +Sherlock +" +) +M +( +" +Watson +" +) +] +vec +! +[ +M +( +" +Sherlock +" +) +M +( +" +Watson +" +) +] +) +; +test_unamb +! +( +unambiguous4 +vec +! +[ +M +( +" +abc +" +) +M +( +" +bc +" +) +] +vec +! +[ +C +( +" +a +" +) +C +( +" +bc +" +) +] +) +; +test_unamb +! +( +unambiguous5 +vec +! +[ +M +( +" +bc +" +) +M +( +" +abc +" +) +] +vec +! +[ +C +( +" +a +" +) +C +( +" +bc +" +) +] +) +; +test_unamb +! +( +unambiguous6 +vec +! +[ +M +( +" +a +" +) +M +( +" +aa +" +) +] +vec +! +[ +C +( +" +a +" +) +] +) +; +test_unamb +! +( +unambiguous7 +vec +! +[ +M +( +" +aa +" +) +M +( +" +a +" +) +] +vec +! +[ +C +( +" +a +" +) +] +) +; +test_unamb +! +( +unambiguous8 +vec +! +[ +M +( +" +ab +" +) +M +( +" +a +" +) +] +vec +! +[ +C +( +" +a +" +) +] +) +; +test_unamb +! +( +unambiguous9 +vec +! +[ +M +( +" +ac +" +) +M +( +" +bc +" +) +M +( +" +c +" +) +M +( +" +ac +" +) +M +( +" +abc +" +) +M +( +" +c +" +) +] +vec +! +[ +C +( +" +a +" +) +C +( +" +b +" +) +C +( +" +c +" +) +] +) +; +test_unamb +! +( +unambiguous10 +vec +! +[ +M +( +" +Mo +' +" +) +M +( +" +Mu +' +" +) +M +( +" +Mo +" +) +M +( +" +Mu +" +) +] +vec +! +[ +C +( +" +Mo +" +) +C +( +" +Mu +" +) +] +) +; +test_unamb +! +( +unambiguous11 +vec +! +[ +M +( +" +zazb +" +) +M +( +" +azb +" +) +] +vec +! +[ +C +( +" +a +" +) +C +( +" +z +" +) +] +) +; +test_unamb +! +( +unambiguous12 +vec +! +[ +M +( +" +foo +" +) +C +( +" +foo +" +) +] +vec +! +[ +C +( +" +foo +" +) +] +) +; +test_unamb +! +( +unambiguous13 +vec +! +[ +M +( +" +ABCX +" +) +M +( +" +CDAX +" +) +M +( +" +BCX +" +) +] +vec +! +[ +C +( +" +A +" +) +C +( +" +BCX +" +) +C +( +" +CD +" +) +] +) +; +test_unamb +! +( +unambiguous14 +vec +! +[ +M +( +" +IMGX +" +) +M +( +" +MVIX +" +) +M +( +" +MGX +" +) +M +( +" +DSX +" +) +] +vec +! +[ +M +( +" +DSX +" +) +C +( +" +I +" +) +C +( +" +MGX +" +) +C +( +" +MV +" +) +] +) +; +test_unamb +! +( +unambiguous15 +vec +! +[ +M +( +" +IMG_ +" +) +M +( +" +MG_ +" +) +M +( +" +CIMG +" +) +] +vec +! +[ +C +( +" +C +" +) +C +( +" +I +" +) +C +( +" +MG_ +" +) +] +) +; +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Tests +for +suffix +trimming +. +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +macro_rules +! +test_trim +{ +( +name +: +ident +trim +: +expr +given +: +expr +expected +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +given +: +Vec +< +Literal +> += +given +. +into_iter +( +) +. +map +( +| +ul +| +{ +let +cut += +ul +. +is_cut +( +) +; +Literal +{ +v +: +ul +. +v +. +into_bytes +( +) +cut +: +cut +} +} +) +. +collect +( +) +; +let +lits += +create_lits +( +given +) +; +let +got += +lits +. +trim_suffix +( +trim +) +. +unwrap +( +) +; +assert_eq +! +( +expected +escape_lits +( +got +. +literals +( +) +) +) +; +} +} +; +} +test_trim +! +( +trim1 +1 +vec +! +[ +M +( +" +ab +" +) +M +( +" +yz +" +) +] +vec +! +[ +C +( +" +a +" +) +C +( +" +y +" +) +] +) +; +test_trim +! +( +trim2 +1 +vec +! +[ +M +( +" +abc +" +) +M +( +" +abd +" +) +] +vec +! +[ +C +( +" +ab +" +) +] +) +; +test_trim +! +( +trim3 +2 +vec +! +[ +M +( +" +abc +" +) +M +( +" +abd +" +) +] +vec +! +[ +C +( +" +a +" +) +] +) +; +test_trim +! +( +trim4 +2 +vec +! +[ +M +( +" +abc +" +) +M +( +" +ghij +" +) +] +vec +! +[ +C +( +" +a +" +) +C +( +" +gh +" +) +] +) +; +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Tests +for +longest +common +prefix +. +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +macro_rules +! +test_lcp +{ +( +name +: +ident +given +: +expr +expected +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +given +: +Vec +< +Literal +> += +given +. +into_iter +( +) +. +map +( +| +s +: +& +str +| +Literal +{ +v +: +s +. +to_owned +( +) +. +into_bytes +( +) +cut +: +false +} +) +. +collect +( +) +; +let +lits += +create_lits +( +given +) +; +let +got += +lits +. +longest_common_prefix +( +) +; +assert_eq +! +( +expected +escape_bytes +( +got +) +) +; +} +} +; +} +test_lcp +! +( +lcp1 +vec +! +[ +" +a +" +] +" +a +" +) +; +test_lcp +! +( +lcp2 +vec +! +[ +] +" +" +) +; +test_lcp +! +( +lcp3 +vec +! +[ +" +a +" +" +b +" +] +" +" +) +; +test_lcp +! +( +lcp4 +vec +! +[ +" +ab +" +" +ab +" +] +" +ab +" +) +; +test_lcp +! +( +lcp5 +vec +! +[ +" +ab +" +" +a +" +] +" +a +" +) +; +test_lcp +! +( +lcp6 +vec +! +[ +" +a +" +" +ab +" +] +" +a +" +) +; +test_lcp +! +( +lcp7 +vec +! +[ +" +ab +" +" +b +" +] +" +" +) +; +test_lcp +! +( +lcp8 +vec +! +[ +" +b +" +" +ab +" +] +" +" +) +; +test_lcp +! +( +lcp9 +vec +! +[ +" +foobar +" +" +foobaz +" +] +" +fooba +" +) +; +test_lcp +! +( +lcp10 +vec +! +[ +" +foobar +" +" +foobaz +" +" +a +" +] +" +" +) +; +test_lcp +! +( +lcp11 +vec +! +[ +" +a +" +" +foobar +" +" +foobaz +" +] +" +" +) +; +test_lcp +! +( +lcp12 +vec +! +[ +" +foo +" +" +flub +" +" +flab +" +" +floo +" +] +" +f +" +) +; +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +/ +/ +Tests +for +longest +common +suffix +. +/ +/ +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +* +macro_rules +! +test_lcs +{ +( +name +: +ident +given +: +expr +expected +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +given +: +Vec +< +Literal +> += +given +. +into_iter +( +) +. +map +( +| +s +: +& +str +| +Literal +{ +v +: +s +. +to_owned +( +) +. +into_bytes +( +) +cut +: +false +} +) +. +collect +( +) +; +let +lits += +create_lits +( +given +) +; +let +got += +lits +. +longest_common_suffix +( +) +; +assert_eq +! +( +expected +escape_bytes +( +got +) +) +; +} +} +; +} +test_lcs +! +( +lcs1 +vec +! +[ +" +a +" +] +" +a +" +) +; +test_lcs +! +( +lcs2 +vec +! +[ +] +" +" +) +; +test_lcs +! +( +lcs3 +vec +! +[ +" +a +" +" +b +" +] +" +" +) +; +test_lcs +! +( +lcs4 +vec +! +[ +" +ab +" +" +ab +" +] +" +ab +" +) +; +test_lcs +! +( +lcs5 +vec +! +[ +" +ab +" +" +a +" +] +" +" +) +; +test_lcs +! +( +lcs6 +vec +! +[ +" +a +" +" +ab +" +] +" +" +) +; +test_lcs +! +( +lcs7 +vec +! +[ +" +ab +" +" +b +" +] +" +b +" +) +; +test_lcs +! +( +lcs8 +vec +! +[ +" +b +" +" +ab +" +] +" +b +" +) +; +test_lcs +! +( +lcs9 +vec +! +[ +" +barfoo +" +" +bazfoo +" +] +" +foo +" +) +; +test_lcs +! +( +lcs10 +vec +! +[ +" +barfoo +" +" +bazfoo +" +" +a +" +] +" +" +) +; +test_lcs +! +( +lcs11 +vec +! +[ +" +a +" +" +barfoo +" +" +bazfoo +" +] +" +" +) +; +test_lcs +! +( +lcs12 +vec +! +[ +" +flub +" +" +bub +" +" +boob +" +" +dub +" +] +" +b +" +) +; +} diff --git a/third_party/rust/regex-syntax/src/hir/mod.rs b/third_party/rust/regex-syntax/src/hir/mod.rs index dffb15fb8c2fd..241583b6ab065 100644 --- a/third_party/rust/regex-syntax/src/hir/mod.rs +++ b/third_party/rust/regex-syntax/src/hir/mod.rs @@ -7,231 +7,62 @@ high - level intermediate -( -HIR -) representation for regular expressions . -The -HIR -is -represented -by -the -[ -Hir -] -type -and -it -principally -constructed -via -[ -translation -] -( -translate -) -from -an -[ -Ast -] -( -crate -: -: -ast -: -: -Ast -) -. -Alternatively -users -may -use -the -smart -constructors -defined -on -Hir -to -build -their -own -by -hand -. -The -smart -constructors -simultaneously -simplify -and -" -optimize -" -the -HIR -and -are -also -the -same -routines -used -by -translation -. -Most -regex -engines -only -have -an -HIR -like -this -and -usually -construct -it -directly -from -the -concrete -syntax -. -This -crate -however -first -parses -the -concrete -syntax -into -an -Ast -and -only -then -creates -the -HIR -from -the -Ast -as -mentioned -above -. -It -' -s -done -this -way -to -facilitate -better -error -reporting -and -to -have -a -structured -representation -of -a -regex -that -faithfully -represents -its -concrete -syntax -. -Namely -while -an -Hir -value -can -be -converted -back -to -an -equivalent -regex -pattern -string -it -is -unlikely -to -look -like -the -original -due -to -its -simplified -structure -. * / use -core +std : : -{ char +; +use +std +: +: cmp -} ; use -alloc +std : : -{ -boxed +error +; +use +std : : -Box -format -string +fmt +; +use +std : : -{ -String -ToString -} -vec -vec +result +; +use +std : : -Vec -} +u8 ; use crate : : -{ ast : : Span +; +use +crate +: +: hir : : @@ -243,15 +74,18 @@ Interval IntervalSet IntervalSetIter } +; +use +crate +: +: unicode -} ; pub use crate : : -{ hir : : @@ -262,11 +96,16 @@ visitor visit Visitor } +; +pub +use +crate +: +: unicode : : CaseFoldError -} ; mod interval @@ -508,41 +347,6 @@ building an Hir . -/ -/ -/ -/ -/ -/ -This -error -type -is -marked -as -non_exhaustive -. -This -means -that -adding -a -/ -/ -/ -new -variant -is -not -considered -a -breaking -change -. -# -[ -non_exhaustive -] # [ derive @@ -621,47 +425,11 @@ UTF - 8 and -utf8 +allow_invalid_utf8 was -enabled -. -InvalidUtf8 -/ -/ -/ -This -error -occurs -when -one -uses -a -non -- -ASCII -byte -for -a -line -terminator -/ -/ -/ -but -where -Unicode -mode -is -enabled -and -UTF -- -8 -mode -is disabled . -InvalidLineTerminator +InvalidUtf8 / / / @@ -782,133 +550,149 @@ case insensitivity . UnicodeCaseUnavailable -} -# +/ +/ +/ +This +occurs +when +the +translator +attempts +to +construct +a +character +class +/ +/ +/ +that +is +empty +. +/ +/ +/ +/ +/ +/ +Note +that +this +restriction +in +the +translator +may +be +removed +in +the +/ +/ +/ +future +. +EmptyClassNotAllowed +/ +/ +/ +Hints +that +destructuring +should +not +be +exhaustive +. +/ +/ +/ +/ +/ +/ +This +enum +may +grow +additional +variants +so +this +makes +sure +clients +/ +/ +/ +don +' +t +count +on +exhaustive +matching +. +( +Otherwise +adding +a +new +variant +/ +/ +/ +could +break +existing +code +. +) +# [ -cfg +doc ( -feature -= -" -std -" +hidden ) ] -impl -std -: -: -error -: -: -Error -for -Error -{ +__Nonexhaustive } impl -core -: -: -fmt -: -: -Display -for -Error -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result +ErrorKind { -crate -: -: -error -: -: -Formatter -: +/ +/ +TODO : -from -( -self -) +Remove +this +method +entirely +on +the +next +breaking +semver +release . -fmt +# +[ +allow ( -f +deprecated ) -} -} -impl -core -: -: -fmt -: -: -Display -for -ErrorKind -{ +] fn -fmt +description ( & self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> ) - > -core -: -: -fmt -: -: -Result +& +str { use self @@ -919,9 +703,6 @@ ErrorKind : * ; -let -msg -= match * self @@ -947,17 +728,6 @@ UTF - 8 " -InvalidLineTerminator -= -> -" -invalid -line -terminator -must -be -ASCII -" UnicodePropertyNotFound = > @@ -1031,120 +801,211 @@ enabled ) " } -} -; -f -. -write_str +EmptyClassNotAllowed += +> +" +empty +character +classes +are +not +allowed +" +__Nonexhaustive += +> +unreachable +! ( -msg ) } } +} +impl +error +: +: +Error +for +Error +{ / / -/ -A -high -- -level -intermediate -representation -( -HIR -) -for -a -regular -expression +TODO +: +Remove +this +method +entirely +on +the +next +breaking +semver +release . -/ -/ -/ -/ -/ -/ -An -HIR -value -is -a -combination -of -a -[ -HirKind -] -and -a -set -of +# [ -Properties +allow +( +deprecated +) ] +fn +description +( +& +self +) +- +> +& +str +{ +self . -/ -/ -/ -An -HirKind -indicates -what kind -of -regular -expression -it -is +. +description ( -a -literal -/ -/ -/ -a -repetition -a -look +) +} +} +impl +fmt +: +: +Display +for +Error +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) - -around -assertion -etc +> +fmt +: +: +Result +{ +crate +: +: +error +: +: +Formatter +: +: +from +( +self +) . +fmt +( +f ) -where -as -a -Properties -/ +} +} +impl +fmt +: +: +Display +for +ErrorKind +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ / / -describes -various -facts -about +TODO +: +Remove +this +on the -regular -expression +next +breaking +semver +release . -For -example -whether +# +[ +allow +( +deprecated +) +] +f +. +write_str +( +self +. +description +( +) +) +} +} / / / -it -matches -UTF +A +high - -8 -or -if -it -matches -the -empty -string +level +intermediate +representation +( +HIR +) +for +a +regular +expression . / / @@ -1163,10 +1024,10 @@ an intermediate step between +its / / / -its abstract syntax ( @@ -1182,10 +1043,9 @@ and / / / -an -actual -regex -matcher +compiled +byte +codes . The purpose @@ -1296,15 +1156,14 @@ g . by translating -/ -/ -/ ( ? i -: -A ) +A +/ +/ +/ to [ aA @@ -1317,24 +1176,90 @@ aA / / / -The -specific -type -of -an +If +the HIR -expression -can -be -accessed -via -its -kind +was +produced +by +a +translator +that +disallows +invalid +UTF +- +8 +then / / / -or -into_kind +the +HIR +is +guaranteed +to +match +UTF +- +8 +exclusively +. +/ +/ +/ +/ +/ +/ +This +type +defines +its +own +destructor +that +uses +constant +stack +space +and +/ +/ +/ +heap +space +proportional +to +the +size +of +the +HIR +. +/ +/ +/ +/ +/ +/ +The +specific +type +of +an +HIR +expression +can +be +accessed +via +its +kind +/ +/ +/ +or +into_kind methods . This @@ -1370,10 +1295,10 @@ use the constructor methods -on / / / +on this Hir type @@ -1385,10 +1310,10 @@ HirKind values directly . -This / / / +This permits construction to @@ -1397,10 +1322,10 @@ invariants like " concatenations -always / / / +always consist of two @@ -1439,10 +1364,10 @@ construction process . For -example / / / +example one such attribute @@ -1454,13 +1379,13 @@ must match at the -beginning -of / / / +beginning +of the -haystack +text . / / @@ -1468,298 +1393,353 @@ haystack / / / -In -particular -if -you -have +Also an -HirKind -value -then -there -is -intentionally +Hir +' +s +fmt +: +: +Display +implementation +prints +an +HIR +as +a +regular / / / -no -way -to -build -an -Hir -value -from -it -. -You -instead -need -to -do -case +expression +pattern +string +and +uses +constant +stack +space +and +heap +space / / / -analysis -on +proportional +to the -HirKind -value -and -build +size +of the Hir -value -using -its -smart -/ -/ -/ -constructors . -/ -/ -/ -/ -/ -/ # -UTF -- -8 +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +struct +Hir +{ / / / +The +underlying +HIR +kind +. +kind +: +HirKind / / / -If -the +Analysis +info +about +this HIR -was -produced -by -a -translator -with +computed +during +construction +. +info +: +HirInfo +} / / / +The +kind +of +an +arbitrary +Hir +expression +. +# [ -TranslatorBuilder -: -: -utf8 -] +derive ( -translate -: -: -TranslatorBuilder -: -: -utf8 +Clone +Debug +Eq +PartialEq ) -enabled +] +pub +enum +HirKind +{ / / / -then -the -HIR -is -guaranteed -to -match -UTF -- -8 -exclusively -for -all -non -- +The empty -/ -/ -/ +regular +expression +which matches -. +everything +including +the / / / +empty +string +. +Empty / / / -For -empty +A +single +literal +character +that matches -those -can -occur -at -any -position +exactly +this +character . -It -is -the +Literal +( +Literal +) / / / -responsibility +A +single +character +class +that +matches +any of the -regex -engine -to -determine -whether -empty -matches -are +characters +in +the / / / -permitted -between -the -code -units -of -a -single -codepoint +class . +A +class +can +either +consist +of +Unicode +scalar +values +as / / / +characters +or +it +can +use +bytes +. +Class +( +Class +) / / / -# -Stack -space +An +anchor +assertion +. +An +anchor +assertion +match +always +has +zero +length +. +Anchor +( +Anchor +) / / / +A +word +boundary +assertion +which +may +or +may +not +be +Unicode +aware +. +A / / / -This -type -defines -its -own -destructor -that -uses -constant -stack -space -and +word +boundary +assertion +match +always +has +zero +length +. +WordBoundary +( +WordBoundary +) / / / -heap -space -proportional +A +repetition +operation +applied to -the -size +a +child +expression +. +Repetition +( +Repetition +) +/ +/ +/ +A +possibly +capturing +group +which +contains +a +child +expression +. +Group +( +Group +) +/ +/ +/ +A +concatenation of -the -HIR +expressions . +A +concatenation +always +has +at +least +two / / / +child +expressions +. / / / -Also -an -Hir -' -s -fmt -: -: -Display -implementation -prints -an -HIR -as -a -regular / / / +A +concatenation +matches +only +if +each +of +its +child expression -pattern -string -and -uses -constant -stack -space -and -heap -space +matches / / / -proportional -to -the -size -of +one +after the -Hir +other . -The -regex -it -prints -is -guaranteed -to +Concat +( +Vec +< +Hir +> +) / / / -be -_semantically_ -equivalent -to -the -original -concrete -syntax -but -it -may +An +alternation +of +expressions +. +An +alternation +always +has +at +least +two / / / -look -very -different -. -( -And -potentially -not -practically -readable -by -a -human +child +expressions . -) / / / @@ -1767,104 +1747,40 @@ human / / An -Hir -' -s -fmt -: -: -Debug -implementation -currently -does -not -use -constant +alternation +matches +only +if +at +least +one +of +its +child +expression / / / -stack -space +matches . -The -implementation -will -also -suppress -some -details -( -such -as -/ -/ -/ +If +multiple +expressions +match +then the -Properties -inlined -into -every -Hir -value -to -make -it -less -noisy -) +leftmost +is +preferred . -# -[ -derive +Alternation ( -Clone -Eq -PartialEq -) -] -pub -struct +Vec +< Hir -{ -/ -/ -/ -The -underlying -HIR -kind -. -kind -: -HirKind -/ -/ -/ -Analysis -info -about -this -HIR -computed -during -construction -. -props -: -Properties +> +) } -/ -/ -/ -Methods -for -accessing -the -underlying -HirKind -and -Properties -. impl Hir { @@ -1926,10 +1842,13 @@ self > HirKind { -core +use +std : : mem +; +mem : : replace @@ -1949,40 +1868,10 @@ Empty / / Returns -the -properties -computed -for -this -Hir -. -pub -fn -properties -( -& -self -) -- -> -& -Properties -{ -& -self -. -props -} -/ -/ -/ -Splits -this +an +empty HIR -into -its -constituent -parts +expression . / / @@ -1990,209 +1879,133 @@ parts / / / -This -is -useful -because -let -Hir -{ -kind -props -} -= -hir -; -does -not -work -/ -/ -/ -because -of -Hir -' -s -custom -Drop -implementation +An +empty +HIR +expression +always +matches +including +the +empty +string . +pub fn -into_parts +empty ( -mut -self ) - > -( -HirKind -Properties -) +Hir { -( -core -: -: -mem -: -: -replace -( -& +let mut -self -. -kind -HirKind +info += +HirInfo : : -Empty +new +( ) -core -: -: -mem -: -: -replace +; +info +. +set_always_utf8 ( -& -mut -self +true +) +; +info . -props -Properties -: -: -empty +set_all_assertions ( +true ) +; +info +. +set_anchored_start +( +false ) +; +info +. +set_anchored_end +( +false ) -} -} -/ -/ -/ -Smart -constructors -for -HIR -values +; +info . -/ -/ -/ -/ -/ -/ -These -constructors -are -called -" -smart -" -because -they -do -inductive -work -or -/ -/ -/ -simplifications +set_line_anchored_start +( +false +) +; +info . -For -example -calling -Hir -: -: -repetition -with -a -repetition -/ -/ -/ -like -a -{ -0 -} -will -actually -return -a -Hir -with -a -HirKind -: -: -Empty -kind -/ -/ -/ -since -it -is -equivalent -to -an -empty -regex +set_line_anchored_end +( +false +) +; +info . -Another -example -is -calling -/ -/ -/ -Hir -: -: -concat +set_any_anchored_start ( -vec -! -[ -expr -] +false ) +; +info . -Instead -of -getting -a +set_any_anchored_end +( +false +) +; +info +. +set_match_empty +( +true +) +; +info +. +set_literal +( +false +) +; +info +. +set_alternation_literal +( +false +) +; +Hir +{ +kind +: HirKind : : -Concat -you -' -ll +Empty +info +} +} / / / -just -get -back -the -original -expr -since -it -' -s -precisely -equivalent +Creates +a +literal +HIR +expression . / / @@ -2200,396 +2013,300 @@ equivalent / / / -Smart -constructors -enable -maintaining -invariants -about -the -HIR -data -type -/ -/ -/ -while -also -simulanteously -keeping +If the -representation -as -simple -as -possible -. -impl -Hir -{ -/ -/ -/ -Returns +given +literal +has +a +Byte +variant +with an -empty -HIR -expression -. +ASCII +byte +then +this / / / +method +panics +. +This +enforces +the +invariant +that +Byte +variants +are / / / -An -empty -HIR -expression -always -matches -including -the -empty -string +only +used +to +express +matching +of +invalid +UTF +- +8 . -# -[ -inline -] pub fn -empty +literal ( +lit +: +Literal ) - > Hir { +if let -props -= -Properties +Literal : : -empty +Byte ( +b ) -; -Hir += +lit { -kind -: -HirKind +assert +! +( +b +> +0x7F +) +; +} +let +mut +info += +HirInfo : : -Empty -props -} -} -/ -/ -/ -Returns -an -HIR -expression -that -can -never -match -anything +new +( +) +; +info . -That -is -/ -/ -/ -the -size -of -the -set -of -strings -in -the -language -described -by -the -HIR -/ -/ -/ -returned -is -0 +set_always_utf8 +( +lit . -/ -/ -/ -/ -/ -/ -This -is -distinct -from -[ -Hir -: -: -empty -] -in -that -the -empty -string -matches -/ -/ -/ -the -HIR -returned -by -Hir -: -: -empty +is_unicode +( +) +) +; +info . -That -is -the -set -of -strings -in -the -/ -/ -/ -language -describe -described -by -Hir -: -: -empty -is -non -- -empty +set_all_assertions +( +false +) +; +info . -/ -/ -/ -/ -/ -/ -Note -that -currently -the -HIR -returned -uses -an -empty -character -class -to -/ -/ -/ -indicate -that -nothing -can -match +set_anchored_start +( +false +) +; +info . -An -equivalent -expression -that -cannot -/ -/ -/ -match -is -an -empty -alternation -but -all -such -" -fail -" -expressions -are -/ -/ -/ -normalized +set_anchored_end ( -via -smart -constructors +false ) -to -empty -character -classes +; +info . -This -is -/ -/ -/ -because -empty -character -classes -can -be -spelled -in -the -concrete -syntax -/ -/ -/ -of -a -regex +set_line_anchored_start ( -e +false +) +; +info . -g +set_line_anchored_end +( +false +) +; +info . -\ -P -{ -any -} -or +set_any_anchored_start ( -? -- -u -: -[ -^ -\ -x00 -- -\ -xFF -] +false ) -or -[ -a -& -& -b -] +; +info +. +set_any_anchored_end +( +false ) -but +; +info +. +set_match_empty +( +false +) +; +info +. +set_literal +( +true +) +; +info +. +set_alternation_literal +( +true +) +; +Hir +{ +kind +: +HirKind +: +: +Literal +( +lit +) +info +} +} / / / -empty -alternations -cannot +Creates +a +class +HIR +expression . -# -[ -inline -] pub fn -fail +class ( +class +: +Class ) - > Hir { let -class +mut +info = -Class -: -: -Bytes -( -ClassBytes +HirInfo : : -empty +new ( ) -) ; -let -props -= -Properties -: -: -class +info +. +set_always_utf8 ( -& class +. +is_always_utf8 +( +) ) ; -/ -/ -We -can -' -t -just -call -Hir -: -: -class -here -because -it -defers -to -Hir -: -: -fail -/ -/ -in -order -to -canonicalize -the -Hir -value -used -to -represent -" -cannot -/ -/ -match +info . -" +set_all_assertions +( +false +) +; +info +. +set_anchored_start +( +false +) +; +info +. +set_anchored_end +( +false +) +; +info +. +set_line_anchored_start +( +false +) +; +info +. +set_line_anchored_end +( +false +) +; +info +. +set_any_anchored_start +( +false +) +; +info +. +set_any_anchored_end +( +false +) +; +info +. +set_match_empty +( +false +) +; +info +. +set_literal +( +false +) +; +info +. +set_alternation_literal +( +false +) +; Hir { kind @@ -2601,519 +2318,469 @@ Class ( class ) -props +info } } / / / Creates -a -literal +an +anchor +assertion HIR expression . -/ -/ -/ -/ -/ -/ -This -accepts -anything -that -can -be -converted -into -a -Box -< -[ -u8 -] +pub +fn +anchor +( +anchor +: +Anchor +) +- > +Hir +{ +let +mut +info += +HirInfo +: +: +new +( +) +; +info . -/ -/ -/ -/ -/ -/ -Note -that -there -is -no -mechanism -for -storing -a -char -or -a -Box -< -str -> -/ -/ -/ -in -an -HIR +set_always_utf8 +( +true +) +; +info . -Everything -is -" -just -bytes +set_all_assertions +( +true +) +; +info . -" -Whether -a -Literal +set_anchored_start ( -or -/ -/ -/ -any -HIR -node +false ) -matches -valid -UTF -- -8 -exclusively -can -be -queried -via -/ -/ -/ -[ -Properties +; +info +. +set_anchored_end +( +false +) +; +info +. +set_line_anchored_start +( +false +) +; +info +. +set_line_anchored_end +( +false +) +; +info +. +set_any_anchored_start +( +false +) +; +info +. +set_any_anchored_end +( +false +) +; +info +. +set_match_empty +( +true +) +; +info +. +set_literal +( +false +) +; +info +. +set_alternation_literal +( +false +) +; +if +let +Anchor : : -is_utf8 -] +StartText += +anchor +{ +info . -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -that -concatenations -of -Literal -HIR -values -will -/ -/ -/ -automatically -get -flattened -and -combined -together -. -So -for -example -even -/ -/ -/ -if -you -concat -multiple -Literal -values -that -are -themselves -not -valid -/ -/ -/ -UTF -- -8 -they -might -add -up -to -valid -UTF -- -8 +set_anchored_start +( +true +) +; +info . -This -also -demonstrates -just -/ -/ -/ -how -" -smart -" -Hir -' -s -smart -constructors -are +set_line_anchored_start +( +true +) +; +info . -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax +set_any_anchored_start +( +true +) +; +} +if +let +Anchor : : -hir +EndText += +anchor +{ +info +. +set_anchored_end +( +true +) +; +info +. +set_line_anchored_end +( +true +) +; +info +. +set_any_anchored_end +( +true +) +; +} +if +let +Anchor : : +StartLine += +anchor { -Hir -HirKind -Literal -} +info +. +set_line_anchored_start +( +true +) ; -/ -/ -/ -/ -/ -/ +} +if let -literals -= -vec -! -[ -/ -/ -/ -Hir +Anchor : : -literal +EndLine += +anchor +{ +info +. +set_line_anchored_end ( -[ -0xE2 -] +true ) -/ -/ -/ +; +} Hir +{ +kind +: +HirKind : : -literal +Anchor ( -[ -0x98 -] +anchor ) +info +} +} / / / +Creates +a +word +boundary +assertion +HIR +expression +. +pub +fn +word_boundary +( +word_boundary +: +WordBoundary +) +- +> Hir +{ +let +mut +info += +HirInfo : : -literal +new ( -[ -0x83 -] ) -/ -/ -/ -] ; -/ -/ -/ -/ -/ -Each -literal -on -its -own -is -invalid -UTF -- -8 +info . -/ -/ -/ -assert -! +set_always_utf8 ( -literals +true +) +; +info . -iter +set_all_assertions ( +true ) +; +info . -all +set_anchored_start ( -| -hir -| -! -hir +false +) +; +info . -properties +set_anchored_end ( +false ) +; +info . -is_utf8 +set_line_anchored_start ( +false ) +; +info +. +set_line_anchored_end +( +false ) +; +info +. +set_any_anchored_start +( +false ) ; -/ -/ -/ -/ -/ -/ -let -concat -= -Hir -: -: -concat +info +. +set_any_anchored_end ( -literals +false ) ; -/ -/ -/ -/ -/ -But -the -concatenation -is -valid -UTF -- -8 -! -/ -/ -/ -assert -! -( -concat +info . -properties +set_literal ( +false ) +; +info . -is_utf8 +set_alternation_literal ( -) +false ) ; / / +A +negated +word +boundary +matches +' +' +so +that +' +s +fine +. +But +\ +b +does +not / / -/ -/ -/ -/ -And -also -notice -that +match +\ +b +so +why +do +we +say +it +can +match the -literals -have -been -concatenated -into -a -/ +empty +string +? +Well / / +because +if +you +search +for +\ +b +against +' +a +' +it +will +report +[ +0 +0 +) +and / / -single -Literal +[ +1 +1 +) +as +matches +and +both +of +those +matches +correspond to the -point -where -there -is -no -explicit -Concat -! -/ +empty / / -let -expected -= -HirKind -: -: -Literal -( -Literal -( -Box -: -: -from -( -" -" +string . -as_bytes -( -) -) -) -) -; -/ +Thus +only +* +certain +* +empty +strings +match +\ +b +which +similarly / / -assert_eq -! -( -& -expected -concat +applies +to +\ +B . -kind +info +. +set_match_empty ( -) +true ) ; / / -/ -# -[ -inline -] -pub -fn -literal -< -B -: -Into -< -Box -< -[ -u8 -] -> -> -> -( -lit -: -B -) +Negated +ASCII +word +boundaries +can +match +invalid +UTF - -> -Hir -{ -let -bytes -= -lit +8 . -into -( -) -; if -bytes -. -is_empty -( -) -{ -return -Hir -: -: -empty -( -) -; -} -let -lit -= -Literal -( -bytes -) -; let -props -= -Properties +WordBoundary : : -literal +AsciiNegate += +word_boundary +{ +info +. +set_always_utf8 ( -& -lit +false ) ; +} Hir { kind @@ -3121,11 +2788,11 @@ kind HirKind : : -Literal +WordBoundary ( -lit +word_boundary ) -props +info } } / @@ -3133,127 +2800,220 @@ props / Creates a -class +repetition HIR expression . -The -class -may -either -be -defined -over -/ -/ -/ -ranges -of -Unicode -codepoints -or -ranges -of -raw -byte -values +pub +fn +repetition +( +rep +: +Repetition +) +- +> +Hir +{ +let +mut +info += +HirInfo +: +: +new +( +) +; +info . +set_always_utf8 +( +rep +. +hir +. +is_always_utf8 +( +) +) +; +info +. +set_all_assertions +( +rep +. +hir +. +is_all_assertions +( +) +) +; / / -/ -/ -/ -/ -Note -that -an -empty -class -is -permitted -. -An +If +this +operator +can +match +the empty -class -is -equivalent -to -/ +string +then +it +can +never / / -Hir -: -: -fail +be +anchored +. +info +. +set_anchored_start +( +! +rep +. +is_match_empty ( ) +& +& +rep . -# -[ -inline -] -pub -fn -class +hir +. +is_anchored_start ( -class -: -Class ) -- -> -Hir -{ -if -class +) +; +info . -is_empty +set_anchored_end +( +! +rep +. +is_match_empty ( ) -{ -return -Hir -: -: -fail +& +& +rep +. +hir +. +is_anchored_end ( ) +) ; -} -else -if -let -Some +info +. +set_line_anchored_start ( -bytes -) -= -class +! +rep . -literal +is_match_empty ( ) -{ -return -Hir -: -: -literal +& +& +rep +. +hir +. +is_anchored_start ( -bytes +) ) ; -} -let -props -= -Properties -: -: -class +info +. +set_line_anchored_end +( +! +rep +. +is_match_empty ( +) & -class +& +rep +. +hir +. +is_anchored_end +( +) +) +; +info +. +set_any_anchored_start +( +rep +. +hir +. +is_any_anchored_start +( +) +) +; +info +. +set_any_anchored_end +( +rep +. +hir +. +is_any_anchored_end +( +) +) +; +info +. +set_match_empty +( +rep +. +is_match_empty +( +) +| +| +rep +. +hir +. +is_match_empty +( +) +) +; +info +. +set_literal +( +false +) +; +info +. +set_alternation_literal +( +false ) ; Hir @@ -3263,11 +3023,11 @@ kind HirKind : : -Class +Repetition ( -class +rep ) -props +info } } / @@ -3275,38 +3035,162 @@ props / Creates a -look -- -around -assertion +group HIR expression . -# -[ -inline -] pub fn -look +group ( -look +group : -Look +Group ) - > Hir { let -props +mut +info = -Properties +HirInfo : : -look +new ( -look +) +; +info +. +set_always_utf8 +( +group +. +hir +. +is_always_utf8 +( +) +) +; +info +. +set_all_assertions +( +group +. +hir +. +is_all_assertions +( +) +) +; +info +. +set_anchored_start +( +group +. +hir +. +is_anchored_start +( +) +) +; +info +. +set_anchored_end +( +group +. +hir +. +is_anchored_end +( +) +) +; +info +. +set_line_anchored_start +( +group +. +hir +. +is_line_anchored_start +( +) +) +; +info +. +set_line_anchored_end +( +group +. +hir +. +is_line_anchored_end +( +) +) +; +info +. +set_any_anchored_start +( +group +. +hir +. +is_any_anchored_start +( +) +) +; +info +. +set_any_anchored_end +( +group +. +hir +. +is_any_anchored_end +( +) +) +; +info +. +set_match_empty +( +group +. +hir +. +is_match_empty +( +) +) +; +info +. +set_literal +( +false +) +; +info +. +set_alternation_literal +( +false ) ; Hir @@ -3316,1176 +3200,1058 @@ kind HirKind : : -Look +Group ( -look +group ) -props +info } } / / / -Creates -a -repetition -HIR -expression +Returns +the +concatenation +of +the +given +expressions +. +/ +/ +/ +/ +/ +/ +This +flattens +the +concatenation +as +appropriate . -# -[ -inline -] pub fn -repetition +concat ( mut -rep +exprs : -Repetition +Vec +< +Hir +> ) - > Hir { -/ -/ -If -the -sub -- -expression -of -a -repetition -can -only match -the +exprs +. +len +( +) +{ +0 += +> +Hir +: +: empty -/ -/ -string -then -we -force -its -maximum -to -be -at -most +( +) 1 += +> +exprs . -if -rep -. -sub -. -properties +pop ( ) . -maximum_len +unwrap ( ) +_ = -= -Some -( -0 -) +> { -rep -. -min +let +mut +info = -cmp +HirInfo : : -min +new ( -rep -. -min -1 ) ; -rep -. -max -= -rep -. -max +info . -map -( -| -n -| -cmp -: -: -min +set_always_utf8 ( -n -1 -) +true ) +; +info . -or -( -Some +set_all_assertions ( -1 +true ) +; +info +. +set_any_anchored_start +( +false ) ; -} -/ -/ -The -regex -' -a -{ -0 -} -' -is -always -equivalent -to -the -empty -regex +info . -This -is -/ -/ +set_any_anchored_end +( +false +) +; +info +. +set_match_empty +( true -even -when -' -a -' -is -an -expression -that -never -matches -anything -/ -/ +) +; +info +. +set_literal ( -like -' -\ -P -{ -any -} -' +true ) +; +info . +set_alternation_literal +( +true +) +; / / -/ -/ -Additionally -the -regex -' -a +Some +attributes +require +analyzing +all +sub +- +expressions +. +for +e +in +& +exprs { -1 -} -' -is -always -equivalent -to -' -a -' +let +x += +info . -if -rep +is_always_utf8 +( +) +& +& +e . -min -= +is_always_utf8 +( +) +; +info +. +set_always_utf8 +( +x +) +; +let +x = -0 +info +. +is_all_assertions +( +) & & -rep +e . -max -= +is_all_assertions +( +) +; +info +. +set_all_assertions +( +x +) +; +let +x = -Some +info +. +is_any_anchored_start ( -0 ) -{ -return -Hir -: -: -empty +| +| +e +. +is_any_anchored_start ( ) ; -} -else -if -rep +info . -min +set_any_anchored_start +( +x +) +; +let +x = +info +. +is_any_anchored_end +( +) +| +| +e +. +is_any_anchored_end +( +) +; +info +. +set_any_anchored_end +( +x +) +; +let +x = -1 +info +. +is_match_empty +( +) & & -rep +e . -max -= +is_match_empty +( +) +; +info +. +set_match_empty +( +x +) +; +let +x = -Some +info +. +is_literal ( -1 ) -{ -return -* -rep +& +& +e . -sub +is_literal +( +) +; +info +. +set_literal +( +x +) ; -} let -props +x = -Properties -: -: -repetition +info +. +is_alternation_literal ( +) & -rep +& +e +. +is_alternation_literal +( ) ; -Hir -{ -kind -: -HirKind -: -: -Repetition +info +. +set_alternation_literal ( -rep +x ) -props -} +; } / / -/ -Creates -a -capture -HIR -expression -. +Anchored +attributes +require +something +slightly +more / / +sophisticated +. +Normally +WLOG +to +determine +whether +an / / +expression +is +anchored +to +the +start +we +' +d +only +need +to +check / / -Note -that -there -is -no -explicit -HIR -value -for +the +first +expression +of a -non -- -capturing -group +concatenation . +However / / -/ -Since -a -non -- -capturing -group -only -exists +expressions +like +\ +b +^ +are +still +anchored to -override -precedence -in the +start / / +but +the +first +expression +in +the +concatenation +* +isn +' +t +* / -concrete -syntax -and -since -an -HIR -already -does -its -own -grouping -based -on / +anchored +to +the +start +. +So +the +" +first +" +expression +to +look +at / / -what is -parsed -there +actually +one +that +is +either +not +an +assertion +or is -no -need -to -explicitly -represent -non -- -capturing -/ / / -groups -in +specifically the -HIR +StartText +assertion . -# -[ -inline -] -pub -fn -capture +info +. +set_anchored_start +( +exprs +. +iter ( -capture -: -Capture ) -- -> -Hir +. +take_while +( +| +e +| { -let -props -= -Properties -: -: -capture +e +. +is_anchored_start ( -& -capture ) -; -Hir -{ -kind -: -HirKind -: -: -Capture +| +| +e +. +is_all_assertions ( -capture ) -props -} } +) +. +any +( +| +e +| +e +. +is_anchored_start +( +) +) +) +; / / -/ -Returns -the -concatenation -of +Similarly +for the -given -expressions +end +anchor +but +in +reverse . +info +. +set_anchored_end +( +exprs +. +iter +( +) +. +rev +( +) +. +take_while +( +| +e +| +{ +e +. +is_anchored_end +( +) +| +| +e +. +is_all_assertions +( +) +} +) +. +any +( +| +e +| +e +. +is_anchored_end +( +) +) +) +; / / -/ -/ -/ -/ -This -attempts -to -flatten -and -simplify +Repeat the -concatenation -as -appropriate +process +for +line +anchors . -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -simple -example -of -basic -flattening -of -both -concatenations -/ -/ -/ -and -literals +info . -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: -: -Hir +set_line_anchored_start +( +exprs +. +iter +( +) +. +take_while +( +| +e +| +{ +e +. +is_line_anchored_start +( +) +| +| +e +. +is_all_assertions +( +) +} +) +. +any +( +| +e +| +e +. +is_line_anchored_start +( +) +) +) ; -/ -/ -/ -/ -/ -/ -let -hir -= -Hir -: -: -concat +info +. +set_line_anchored_end ( -vec -! -[ -/ -/ -/ -Hir -: -: -concat +exprs +. +iter ( -vec -! -[ -/ -/ -/ -Hir -: -: -literal +) +. +rev ( -[ -b -' -a -' -] ) -/ -/ -/ -Hir -: -: -literal +. +take_while +( +| +e +| +{ +e +. +is_line_anchored_end ( -[ -b -' -b -' -] ) -/ -/ -/ +| +| +e +. +is_all_assertions +( +) +} +) +. +any +( +| +e +| +e +. +is_line_anchored_end +( +) +) +) +; Hir +{ +kind : +HirKind : -literal +: +Concat ( -[ -b -' -c -' -] +exprs ) +info +} +} +} +} / / / -] -) +Returns +the +alternation +of +the +given +expressions +. / / / -Hir -: -: -concat -( -vec -! -[ / / / -Hir -: -: -literal +This +flattens +the +alternation +as +appropriate +. +pub +fn +alternation ( -[ -b -' -x -' -] +mut +exprs +: +Vec +< +Hir +> ) -/ -/ -/ +- +> Hir -: -: -literal +{ +match +exprs +. +len ( -[ -b -' -y -' -] ) -/ -/ -/ +{ +0 += +> Hir : : -literal +empty ( -[ -b -' -z -' -] ) -/ -/ -/ -] +1 += +> +exprs +. +pop +( ) -/ -/ -/ -] +. +unwrap +( ) -; -/ -/ -/ +_ += +> +{ let -expected +mut +info = -Hir +HirInfo : : -literal +new ( -" -abcxyz -" +) +; +info . -as_bytes +set_always_utf8 ( -) +true ) ; -/ -/ -/ -assert_eq -! +info +. +set_all_assertions ( -expected -hir +true ) ; -/ -/ -/ -pub -fn -concat +info +. +set_anchored_start ( -subs -: -Vec -< -Hir -> +true ) -- -> -Hir -{ -/ -/ -We -rebuild -the -concatenation -by -simplifying -it -. -Would -be -nice -to -do -/ -/ -it -in -place -but -that -seems -a -little -tricky -? -let -mut -new -= -vec -! -[ -] ; -/ -/ -This -gobbles -up -any -adjacent -literals -in -a -concatenation -and -smushes -/ -/ -them -together -. -Basically -when -we -see -a -literal -we -add -its -bytes -/ -/ -to -' -prior_lit -' -and -whenever -we -see -anything -else -we -first -take -/ -/ -any -bytes -in -' -prior_lit -' -and -add -it -to -the -' -new -' -concatenation +info . -let -mut -prior_lit -: -Option -< -Vec -< -u8 -> -> -= -None +set_anchored_end +( +true +) ; -for -sub -in -subs -{ -let +info +. +set_line_anchored_start ( -kind -props +true ) -= -sub +; +info . -into_parts +set_line_anchored_end ( +true ) ; -match -kind -{ -HirKind -: -: -Literal +info +. +set_any_anchored_start ( -Literal +false +) +; +info +. +set_any_anchored_end ( -bytes +false ) +; +info +. +set_match_empty +( +false ) -= -> -{ -if -let -Some +; +info +. +set_literal ( -ref -mut -prior_bytes +false ) -= -prior_lit -{ -prior_bytes +; +info . -extend_from_slice +set_alternation_literal ( -& -bytes +true ) ; -} -else +/ +/ +Some +attributes +require +analyzing +all +sub +- +expressions +. +for +e +in +& +exprs { -prior_lit +let +x = -Some +info +. +is_always_utf8 ( -bytes +) +& +& +e . -to_vec +is_always_utf8 ( ) +; +info +. +set_always_utf8 +( +x ) ; -} -} -/ -/ -We -also -flatten -concats -that -are -direct -children -of -another -/ -/ -concat -. -We -only -need -to -do -this -one -level -deep -since -/ -/ -Hir -: -: -concat -is -the -only -way -to -build -concatenations -and -so -/ -/ -flattening -happens -inductively -. -HirKind -: -: -Concat -( -subs2 -) -= -> -{ -for -sub2 -in -subs2 -{ let +x += +info +. +is_all_assertions ( -kind2 -props2 ) -= -sub2 +& +& +e . -into_parts +is_all_assertions ( ) ; -match -kind2 -{ -HirKind -: -: -Literal -( -Literal +info +. +set_all_assertions ( -bytes -) +x ) -= -> -{ -if +; let -Some -( -ref -mut -prior_bytes -) +x = -prior_lit -{ -prior_bytes +info . -extend_from_slice +is_anchored_start ( +) & -bytes +& +e +. +is_anchored_start +( ) ; -} -else -{ -prior_lit -= -Some -( -bytes +info . -to_vec +set_anchored_start ( -) +x ) ; -} -} -kind2 -= -> -{ -if let -Some -( -prior_bytes -) +x = -prior_lit +info . -take +is_anchored_end ( ) -{ -new +& +& +e . -push -( -Hir -: -: -literal +is_anchored_end ( -prior_bytes -) ) ; -} -new +info . -push +set_anchored_end ( -Hir -{ -kind -: -kind2 -props -: -props2 -} +x ) ; -} -} -} -} -/ -/ -We -can -just -skip -empty -HIRs -. -HirKind -: -: -Empty -= -> -{ -} -kind -= -> -{ -if let -Some -( -prior_bytes -) +x = -prior_lit +info . -take +is_line_anchored_start ( ) -{ -new +& +& +e . -push +is_line_anchored_start ( -Hir -: -: -literal -( -prior_bytes -) ) ; -} -new +info . -push +set_line_anchored_start ( -Hir -{ -kind -props -} +x ) ; -} -} -} -if let -Some -( -prior_bytes -) +x = -prior_lit +info . -take +is_line_anchored_end ( ) -{ -new +& +& +e . -push -( -Hir -: -: -literal +is_line_anchored_end ( -prior_bytes ) +; +info +. +set_line_anchored_end +( +x ) ; -} -if -new +let +x += +info . -is_empty +is_any_anchored_start ( ) -{ -return -Hir -: -: -empty +| +| +e +. +is_any_anchored_start ( ) ; -} -else -if -new +info . -len +set_any_anchored_start ( +x ) +; +let +x = -= -1 -{ -return -new +info . -pop +is_any_anchored_end ( ) +| +| +e . -unwrap +is_any_anchored_end ( ) ; -} +info +. +set_any_anchored_end +( +x +) +; let -props +x = -Properties -: -: -concat +info +. +is_match_empty +( +) +| +| +e +. +is_match_empty +( +) +; +info +. +set_match_empty +( +x +) +; +let +x += +info +. +is_alternation_literal ( +) & -new +& +e +. +is_literal +( ) ; +info +. +set_alternation_literal +( +x +) +; +} Hir { kind @@ -4493,61 +4259,24 @@ kind HirKind : : -Concat +Alternation ( -new +exprs ) -props +info +} +} } } / / / -Returns -the -alternation -of -the -given -expressions -. -/ -/ -/ -/ -/ -/ -This -flattens -and -simplifies -the -alternation -as -appropriate +Build +an +HIR +expression +for . -This -may -/ -/ -/ -include -factoring -out -common -prefixes -or -even -rewriting -the -alternation -/ -/ -/ -as -a -character -class . / / @@ -4555,305 +4284,275 @@ class / / / -Note -that -an -empty -alternation -is -equivalent -to -Hir -: -: -fail -( -) +A . -( -It -/ -/ -/ -is -not -possible +expression +matches +any +character +except for -one -to -write -an -empty -alternation -or -even +\ +n +. +To +build an / / / -alternation -with -a -single -sub -- expression -in +that +matches +any +character +including +\ +n +use the -concrete -syntax -of -a +any / / / -regex +method . -) -/ -/ -/ -/ -/ -/ -# -Example / / / / / / -This +If +bytes is +true +then +this +assumes +characters +are +limited +to a -simple -example -showing -how -an -alternation -might -get / / / -simplified +single +byte . -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -hir -: +pub +fn +dot +( +bytes : -{ +bool +) +- +> Hir -Class -ClassUnicode -ClassUnicodeRange -} -; -/ -/ -/ -/ -/ -/ +{ +if +bytes +{ let -hir +mut +cls = -Hir +ClassBytes : : -alternation +empty ( -vec -! -[ -/ -/ -/ -Hir +) +; +cls +. +push +( +ClassBytesRange : : -literal +new ( -[ b ' -a +\ +0 ' -] -) -/ -/ -/ -Hir -: -: -literal -( -[ b ' -b +\ +x09 ' -] ) -/ -/ -/ -Hir +) +; +cls +. +push +( +ClassBytesRange : : -literal +new ( -[ b ' -c +\ +x0B ' -] -) -/ -/ -/ -Hir -: -: -literal -( -[ b ' -d +\ +xFF ' -] ) -/ -/ -/ +) +; Hir : : -literal +class ( -[ -b -' -e -' -] -) -/ -/ -/ -Hir +Class : : -literal +Bytes ( -[ -b -' -f -' -] +cls ) -/ -/ -/ -] ) -; -/ -/ -/ +} +else +{ let -expected +mut +cls = -Hir +ClassUnicode : : -class +empty ( -Class -: -: -Unicode +) +; +cls +. +push ( -ClassUnicode +ClassUnicodeRange : : new ( -[ -/ -/ -/ +' +\ +0 +' +' +\ +x09 +' +) +) +; +cls +. +push +( ClassUnicodeRange : : new ( ' -a +\ +x0B ' ' -f +\ +u +{ +10FFFF +} ' ) -/ -/ -/ -] ) +; +Hir +: +: +class +( +Class +: +: +Unicode +( +cls ) ) -; +} +} / / / -assert_eq -! +Build +an +HIR +expression +for ( -expected -hir +? +s ) -; +. +. / / / / / / +A +( +? +s +) +. +expression +matches +any +character +including +\ +n +. +To +build +an / / / -And -another -example -showing -how -common -prefixes -might -get -factored +expression +that +matches +any +character +except +for +\ +n +then +use +the / / / -out +dot +method . / / @@ -4861,70 +4560,72 @@ out / / / +If +bytes +is +true +then +this +assumes +characters +are +limited +to +a / / / -use -regex_syntax -: -: -hir -: +single +byte +. +pub +fn +any +( +bytes : -{ +bool +) +- +> Hir -Class -ClassUnicode -ClassUnicodeRange -} -; -/ -/ -/ -/ -/ -/ +{ +if +bytes +{ let -hir +mut +cls = -Hir +ClassBytes : : -alternation +empty ( -vec -! -[ -/ -/ -/ -Hir -: -: -concat +) +; +cls +. +push ( -vec -! -[ -/ -/ -/ -Hir +ClassBytesRange : : -literal -( -" -abc -" -. -as_bytes +new ( +b +' +\ +0 +' +b +' +\ +xFF +' ) ) -/ -/ -/ +; Hir : : @@ -4933,267 +4634,431 @@ class Class : : -Unicode +Bytes ( +cls +) +) +} +else +{ +let +mut +cls += ClassUnicode : : -new +empty +( +) +; +cls +. +push ( -[ -/ -/ -/ ClassUnicodeRange : : new ( ' -A +\ +0 ' ' -Z +\ +u +{ +10FFFF +} ' ) -/ -/ -/ -] -) -) -) -/ -/ -/ -] ) -/ -/ -/ +; Hir : : -concat +class ( -vec -! -[ -/ -/ -/ -Hir +Class : : -literal -( -" -abc -" -. -as_bytes +Unicode ( +cls ) ) +} +} / / / -Hir -: -: -class -( -Class -: -: -Unicode -( -ClassUnicode -: -: -new -( -[ +Return +true +if +and +only +if +this +HIR +will +always +match +valid +UTF +- +8 +. / / / -ClassUnicodeRange -: -: -new -( -' -a -' -' -z -' -) / / / -] -) +When +this +returns +false +then +it +is +possible +for +this +HIR +expression +/ +/ +/ +to +match +invalid +UTF +- +8 +. +pub +fn +is_always_utf8 +( +& +self ) +- +> +bool +{ +self +. +info +. +is_always_utf8 +( ) +} / / / -] -) +Returns +true +if +and +only +if +this +entire +HIR +expression +is +made +up +of / / / -] -) -; +zero +- +width +assertions +. / / / -let -expected -= -Hir -: -: -concat -( -vec -! -[ / / / -Hir -: -: -literal +This +includes +expressions +like +^ +\ +b +\ +A +\ +z +and +even ( -" -abc -" -. -as_bytes +( +\ +b +) ++ ( ) ) +* +^ +but / / / -Hir -: -: -alternation +not +^ +a +. +pub +fn +is_all_assertions ( -vec -! -[ +& +self +) +- +> +bool +{ +self +. +info +. +is_all_assertions +( +) +} / / / -Hir -: -: -class -( -Class -: -: -Unicode -( -ClassUnicode -: -: -new -( -[ +Return +true +if +and +only +if +this +HIR +is +required +to +match +from +the / / / -ClassUnicodeRange -: -: -new +beginning +of +text +. +This +includes +expressions +like +^ +foo +^ ( -' -A -' -' -Z -' +foo +| +bar ) / / / -] -) +^ +foo +| +^ +bar +but +not +^ +foo +| +bar +. +pub +fn +is_anchored_start +( +& +self ) +- +> +bool +{ +self +. +info +. +is_anchored_start +( ) +} / / / -Hir -: -: -class -( -Class -: -: -Unicode -( -ClassUnicode -: -: -new -( -[ +Return +true +if +and +only +if +this +HIR +is +required +to +match +at +the +end / / / -ClassUnicodeRange -: -: -new +of +text +. +This +includes +expressions +like +foo ( -' -a -' -' -z -' +foo +| +bar ) / / / -] -) +foo +| +bar +but +not +foo +| +bar +. +pub +fn +is_anchored_end +( +& +self ) +- +> +bool +{ +self +. +info +. +is_anchored_end +( ) +} / / / -] -) +Return +true +if +and +only +if +this +HIR +is +required +to +match +from +the / / / -] -) -; +beginning +of +text +or +the +beginning +of +a +line +. +This +includes +expressions / / / -assert_eq -! +like +^ +foo ( -expected -hir +? +m ) -; +^ +foo +^ +( +foo +| +bar +) +^ +( +foo +| +bar +) +( +? +m +) +^ +foo +| +^ +bar / / / +but +not +^ +foo +| +bar +or +( +? +m +) +^ +foo +| +bar +. / / / @@ -5202,771 +5067,726 @@ hir / Note that -these -sorts -of -simplifications -are -not -guaranteed +if +is_anchored_start +is +true +then +/ +/ +/ +is_line_anchored_start +will +also +be +true . -pub -fn -alternation +The +reverse +implication +/ +/ +/ +is +not +true +. +For +example ( -subs -: -Vec -< -Hir -> +? +m +) +^ +foo +is +line +anchored +but +not +/ +/ +/ +is_anchored_start +. +pub +fn +is_line_anchored_start +( +& +self ) - > -Hir +bool { +self +. +info +. +is_line_anchored_start +( +) +} / / -We -rebuild +/ +Return +true +if +and +only +if +this +HIR +is +required +to +match +at the -alternation -by -simplifying -it -. -We -proceed -similarly / / -as +/ +end +of +text +or the -concatenation -case +end +of +a +line . -But -in -this -case -there -' -s -no -literal +This +includes +expressions +like / / -simplification -happening -. -We -' -re -just -flattening -alternations -. -let -mut -new -= -Vec -: -: -with_capacity -( -subs -. -len +/ +foo ( +? +m ) +foo +( +foo +| +bar ) -; -for -sub -in -subs -{ -let ( -kind -props +? +m ) -= -sub -. -into_parts ( +foo +| +bar ) -; -match -kind -{ -HirKind -: -: -Alternation +foo +| +bar +/ +/ +/ ( -subs2 +? +m ) -= -> -{ -new -. -extend ( -subs2 +foo +| +bar ) -; -} -kind -= -> -{ -new -. -push +but +not +foo +| +bar +or ( -Hir -{ -kind -props -} +? +m ) -; -} -} -} +foo +| +bar +. +/ +/ +/ +/ +/ +/ +Note +that if -new +is_anchored_end +is +true +then +/ +/ +/ +is_line_anchored_end +will +also +be +true . -is_empty -( -) -{ -return -Hir -: -: -fail +The +reverse +implication +/ +/ +/ +is +not +true +. +For +example ( +? +m ) -; -} -else -if -new +foo +is +line +anchored +but +not +/ +/ +/ +is_anchored_end . -len +pub +fn +is_line_anchored_end ( +& +self ) -= -= -1 +- +> +bool { -return -new +self . -pop -( -) +info . -unwrap +is_line_anchored_end ( ) -; } / / -Now -that -it -' -s -completely -flattened -look -for -the -special -case -of -/ -/ -' -char1 -| -char2 -| -. -. -. -| -charN -' -and -collapse -that -into -a -class -. -Note -that -/ / -we -look -for -' -char -' -first -and -then -bytes -. -The -issue -here -is -that +Return +true if -/ -/ -we -find -both -non -- -ASCII -codepoints and -non +only +if +this +HIR +contains +any +sub - -ASCII -singleton -bytes +expression +that / / -then -it -isn -' -t -actually -possible +/ +is +required to -smush -them -into -a -single -class +match +at +the +beginning +of +text . +Specifically +this +/ / / +returns +true +if +the +^ +symbol ( -Because -classes -are -either -" -all -codepoints -" +when +multiline +mode +is +disabled +) or -" -all -bytes -. -" -You -/ +the / -can -have -a -class -that -both -matches -non -- -ASCII -but -valid -UTF -- -8 -and / / -invalid -UTF +\ +A +escape +appear +anywhere +in +the +regex +. +pub +fn +is_any_anchored_start +( +& +self +) - -8 +> +bool +{ +self +. +info . +is_any_anchored_start +( ) -So -we -look -for -all -chars -and -then -all -bytes +} +/ +/ +/ +Return +true +if and +only +if +this +HIR +contains +any +sub +- +expression +that +is / / -don -' -t -handle -anything -else +/ +required +to +match +at +the +end +of +text . +Specifically +this +returns +true +/ +/ +/ if -let -Some +the +symbol ( -singletons +when +multiline +mode +is +disabled ) -= -singleton_chars +or +the +\ +z +escape +/ +/ +/ +appear +anywhere +in +the +regex +. +pub +fn +is_any_anchored_end ( & -new +self ) +- +> +bool { -let -it -= -singletons +self . -into_iter -( -) +info . -map +is_any_anchored_end ( -| -ch -| -ClassUnicodeRange -{ -start -: -ch -end -: -ch -} ) -; -return -Hir -: -: -class -( -Class -: -: -Unicode -( -ClassUnicode -: -: -new -( -it -) -) -) -; } +/ +/ +/ +Return +true if -let -Some -( -singletons -) -= -singleton_bytes -( -& -new -) -{ -let -it -= -singletons -. -into_iter -( -) +and +only +if +the +empty +string +is +part +of +the +language +/ +/ +/ +matched +by +this +regular +expression . -map -( -| +/ +/ +/ +/ +/ +/ +This +includes +a +* +a +? b -| -ClassBytesRange +* +a { -start -: -b -end -: -b +0 } -) -; -return -Hir -: -: -class -( -Class -: -: -Bytes -( -ClassBytes -: -: -new ( -it -) ) +( ) -; -} -/ ++ +^ +a +| +b +? +\ +b / -Similar -to -singleton -chars -we -can -also -look -for -alternations -of / / -classes -. -Those -can -be -smushed -into +and +\ +B +but +not a -single -class +or +a ++ . -if -let -Some -( -cls -) -= -class_chars -( -& -new -) -{ -return -Hir -: -: -class -( -cls -) -; -} -if -let -Some -( -cls -) -= -class_bytes +pub +fn +is_match_empty ( & -new +self ) +- +> +bool { -return -Hir -: -: -class +self +. +info +. +is_match_empty ( -cls ) -; } / / -Factor -out -a -common -prefix -if -we -can -which -might -potentially -/ / -simplify -the -expression +Return +true +if and -unlock -other -optimizations -downstream +only +if +this +HIR +is +a +simple +literal . +This +is +only / / -It -also -might -generally -make -NFA -matching -and -DFA -construction +/ +true +when +this +HIR +expression +is +either +itself +a +Literal +or +a / / -faster -by -reducing -the -scope +/ +concatenation of -branching -in -the -regex +only +Literal +s . -new -= -match -lift_common_prefix -( -new -) -{ -Ok +/ +/ +/ +/ +/ +/ +For +example +f +and +foo +are +literals +but +f ++ ( -hir +foo ) -= -> -return -hir -Err +foo ( -unchanged ) -= -> -unchanged -} -; -let -props -= -Properties -: -: -alternation +/ +/ +/ +are +not +( +even +though +that +contain +sub +- +expressions +that +are +literals +) +. +pub +fn +is_literal ( & -new +self ) -; -Hir +- +> +bool { -kind -: -HirKind -: -: -Alternation +self +. +info +. +is_literal ( -new ) -props -} } / / / -Returns -an +Return +true +if +and +only +if +this HIR -expression -for -. -. +is +either +a +simple +literal +or +an / / / +alternation +of +simple +literals +. +This +is +only / / / -* -[ -Dot -: -: -AnyChar -] -maps -to -( -? -su -- -R -: -. -) -. +true +when +this +HIR +expression +is +either +itself +a +Literal +or +a / / / -* -[ -Dot -: -: -AnyByte -] -maps -to -( -? +concatenation +of +only +Literal +s +or +an +alternation +of +only +Literal s -- -Ru -: -. -) . / / / -* -[ -Dot -: -: -AnyCharExceptLF -] -maps -to -( -? -u -- -Rs -: -. -) -. / / / -* -[ -Dot -: -: -AnyCharExceptCRLF -] -maps -to -( -? -Ru -- -s -: -. -) -. +For +example +f +foo +a +| +b +| +c +and +foo +| +bar +| +baz +are +alternation / / / -* -[ -Dot -: -: -AnyByteExceptLF -] -maps -to +literals +but +f ++ +( +foo +) +foo ( -? -- -Rsu -: -. ) -. / / / -* -[ -Dot -: -: -AnyByteExceptCRLF -] -maps -to +are +not ( -? -R +even +though +that +contain +sub - -su -: +expressions +that +are +literals +) . +pub +fn +is_alternation_literal +( +& +self ) +- +> +bool +{ +self . +info +. +is_alternation_literal +( +) +} +} +impl +HirKind +{ / / / -/ -/ -/ -# -Example +Return +true +if +and +only +if +this +HIR +is +the +empty +regular +expression +. / / / @@ -5977,721 +5797,504 @@ Note that this is -a -convenience -routine -for -constructing -the -correct -/ -/ -/ -character -class -based -on -the -value -of -Dot +not +defined +inductively . -There +That is -no -explicit -" -dot -" +it +only +tests +if / / / -HIR -value -. -It +this +kind is -just -an -abbreviation -for -a -common -character -class +the +Empty +variant . -/ -/ -/ -/ -/ -/ +To +get +the +inductive +definition / / / use -regex_syntax -: -: -hir -: -: -{ -Hir -Dot -Class -ClassBytes -ClassBytesRange -} -; -/ -/ -/ -/ -/ -/ -let -hir -= +the +is_match_empty +method +on +[ Hir -: -: -dot +] ( -Dot -: -: -AnyByte -) -; -/ -/ -/ -let -expected -= +struct +. Hir -: -: -class -( -Class -: -: -Bytes +. +html +) +. +pub +fn +is_empty ( -ClassBytes +& +self +) +- +> +bool +{ +match +* +self +{ +HirKind : : -new -( -[ +Empty += +> +true +_ += +> +false +} +} / / / -ClassBytesRange -: -: -new +Returns +true +if +and +only +if +this +kind +has +any ( -0x00 -0xFF -) -/ -/ -/ -] -) -) -) -; +including +possibly / / / -assert_eq -! -( -expected -hir +empty ) -; -/ -/ -/ -# -[ -inline -] +subexpressions +. pub fn -dot +has_subexprs ( -dot -: -Dot +& +self ) - > -Hir +bool { match -dot +* +self { -Dot +HirKind : : -AnyChar -= -> -{ -let -mut -cls -= -ClassUnicode +Empty +| +HirKind : : -empty +Literal ( +_ ) -; -cls -. -push -( -ClassUnicodeRange +| +HirKind : : -new +Class ( -' -\ -0 -' -' -\ -u -{ -10FFFF -} -' -) +_ ) -; -Hir +| +HirKind : : -class +Anchor ( -Class +_ +) +| +HirKind : : -Unicode +WordBoundary ( -cls -) +_ ) -} -Dot -: -: -AnyByte = > -{ -let -mut -cls -= -ClassBytes +false +HirKind : : -empty +Group ( +_ ) -; -cls -. -push +| +HirKind +: +: +Repetition ( -ClassBytesRange +_ +) +| +HirKind : : -new +Concat ( -b -' -\ -0 -' -b -' -\ -xFF -' -) -) -; -Hir -: -: -class -( -Class -: -: -Bytes -( -cls -) +_ ) -} -Dot +| +HirKind : : -AnyCharExcept +Alternation ( -ch +_ ) = > -{ -let -mut -cls -= -ClassUnicode -: -: -new -( -[ -ClassUnicodeRange -: -: -new -( -ch -ch -) -] -) -; -cls +true +} +} +} +/ +/ +/ +Print +a +display +representation +of +this +Hir . -negate -( -) -; +/ +/ +/ +/ +/ +/ +The +result +of +this +is +a +valid +regular +expression +pattern +string +. +/ +/ +/ +/ +/ +/ +This +implementation +uses +constant +stack +space +and +heap +space +proportional +/ +/ +/ +to +the +size +of +the Hir +. +impl +fmt : : -class -( -Class -: -: -Unicode +Display +for +Hir +{ +fn +fmt ( -cls -) -) -} -Dot -: +& +self +f : -AnyCharExceptLF -= -> -{ -let +& mut -cls -= -ClassUnicode -: -: -empty -( -) -; -cls -. -push -( -ClassUnicodeRange +fmt : : -new -( -' -\ -0 -' -' -\ -x09 +Formatter +< ' +_ +> ) -) -; -cls -. -push -( -ClassUnicodeRange +- +> +fmt : : -new -( -' -\ -x0B -' -' -\ -u +Result { -10FFFF -} -' -) -) -; -Hir -: -: -class -( -Class +use +crate : : -Unicode -( -cls -) -) -} -Dot +hir : : -AnyCharExceptCRLF -= -> -{ -let -mut -cls -= -ClassUnicode +print : : -empty -( -) +Printer ; -cls -. -push -( -ClassUnicodeRange +Printer : : new ( -' -\ -0 -' -' -\ -x09 -' ) -) -; -cls . -push -( -ClassUnicodeRange -: -: -new +print ( -' -\ -x0B -' -' -\ -x0C -' -) +self +f ) -; -cls -. -push -( -ClassUnicodeRange -: -: -new -( -' -\ -x0E -' -' -\ -u -{ -10FFFF } -' -) -) -; -Hir -: -: -class -( -Class -: -: -Unicode -( -cls -) -) } -Dot -: -: -AnyByteExcept -( +/ +/ +/ +The +high +- +level +intermediate +representation +of +a +literal +. +/ +/ +/ +/ +/ +/ +A +literal +corresponds +to +a +single +character +where +a +character +is +either +/ +/ +/ +defined +by +a +Unicode +scalar +value +or +an +arbitrary byte -) -= -> -{ -let -mut -cls -= -ClassBytes -: -: -new -( +. +Unicode +characters +/ +/ +/ +are +preferred +whenever +possible +. +In +particular +a +Byte +variant +is +only +/ +/ +/ +ever +produced +when +it +could +match +invalid +UTF +- +8 +. +# [ -ClassBytesRange -: -: -new +derive ( -byte -byte +Clone +Debug +Eq +PartialEq ) ] +pub +enum +Literal +{ +/ +/ +/ +A +single +character +represented +by +a +Unicode +scalar +value +. +Unicode +( +char ) -; -cls +/ +/ +/ +A +single +character +represented +by +an +arbitrary +byte . -negate +Byte ( +u8 ) -; -Hir -: -: -class +} +impl +Literal +{ +/ +/ +/ +Returns +true +if +and +only +if +this +literal +corresponds +to +a +Unicode +/ +/ +/ +scalar +value +. +pub +fn +is_unicode ( -Class +& +self +) +- +> +bool +{ +match +* +self +{ +Literal : : -Bytes +Unicode ( -cls -) +_ ) -} -Dot -: -: -AnyByteExceptLF = > -{ -let -mut -cls -= -ClassBytes +true +Literal : : -empty +Byte ( +b ) -; -cls -. -push -( -ClassBytesRange +if +b +< += +0x7F += +> +true +Literal : : -new +Byte ( -b -' -\ -0 -' -b -' -\ -x09 -' -) -) -; -cls -. -push -( -ClassBytesRange -: -: -new -( -b -' -\ -x0B -' -b -' -\ -xFF -' -) -) -; -Hir -: -: -class -( -Class -: -: -Bytes -( -cls -) +_ ) -} -Dot -: -: -AnyByteExceptCRLF = > -{ -let -mut -cls -= -ClassBytes -: -: -empty -( -) -; -cls -. -push -( -ClassBytesRange -: -: -new -( -b -' -\ -0 -' -b -' -\ -x09 -' -) -) -; -cls -. -push -( -ClassBytesRange -: -: -new -( -b -' -\ -x0B -' -b -' -\ -x0C -' -) -) -; -cls -. -push -( -ClassBytesRange -: -: -new -( -b -' -\ -x0E -' -b -' -\ -xFF -' -) -) -; -Hir -: -: -class -( -Class -: -: -Bytes -( -cls -) -) -} +false } } } @@ -6699,15 +6302,15 @@ cls / / The -underlying -kind +high +- +level +intermediate +representation of -an -arbitrary -[ -Hir -] -expression +a +character +class . / / @@ -6715,329 +6318,294 @@ expression / / / -An -HirKind +A +character +class +corresponds +to +a +set +of +characters +. +A +character is -principally -useful -for -doing -case -analysis -on -the -type +either / / / -of +defined +by a -regular -expression +Unicode +scalar +value +or +a +byte . -If -you -' -re -looking -to -build -new -Hir -values +Unicode +characters +are +used / / / -then -you -_must_ -use +by +default +while +bytes +are +used +when +Unicode +mode +( +via the -smart -constructors -defined -on -Hir -like +u +flag +) +is / / / -[ -Hir -: -: -repetition -] -to -build -new -Hir -values +disabled . -The -API -intentionally -does / / / -not -expose -any -way +/ +/ +/ +A +character +class +regardless of -building -an -Hir -directly -from -an -HirKind -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -enum -HirKind -{ +its +character +type +is +represented +by +a / / / -The -empty -regular -expression -which -matches -everything -including -the +sequence +of +non +- +overlapping +non +- +adjacent +ranges +of +characters +. / / / -empty -string -. -Empty / / / -A -literalstring +Note that -matches -exactly -these -bytes -. +unlike +[ Literal +] ( +enum +. Literal +. +html ) +a +Bytes +variant +may / / / -A -single -character -class -that +be +produced +even +when +it +exclusively matches -any -of -the -characters -in -the -/ -/ -/ -class +valid +UTF +- +8 . -A -class -can -either -consist -of -Unicode -scalar -values -as +This +is +because / / / -characters -or -it -can -use -bytes -. +a +Bytes +variant +represents +an +intention +by +the +author +of +the +regular / / / +expression +to +disable +Unicode +mode +which +in +turn +impacts +the +semantics +of / / / -A -class -may -be -empty -. -In -which case -it -matches -nothing +insensitive +matching . -Class +For +example ( -Class +? +i +) +k +and +( +? +i +- +u ) +k +will +not / / / -A -look -- -around -assertion -. -A -look -- -around match -always -has -zero -length +the +same +set +of +strings . -Look +# +[ +derive ( -Look +Clone +Debug +Eq +PartialEq ) +] +pub +enum +Class +{ / / / A -repetition -operation -applied -to -a -sub -- -expression +set +of +characters +represented +by +Unicode +scalar +values . -Repetition +Unicode ( -Repetition +ClassUnicode ) / / / A -capturing -group -which -contains -a -sub -- -expression -. -Capture +set +of +characters +represented +by +arbitrary +bytes ( -Capture -) +one +byte +per / / / -A -concatenation -of -expressions +character +) . +Bytes +( +ClassBytes +) +} +impl +Class +{ / / / +Apply +Unicode +simple +case +folding +to +this +character +class +in +place +. / / / -A -concatenation -matches -only -if -each -of -its -sub -- -expressions -match -one -/ -/ -/ -after -the -other -. -/ -/ -/ -/ -/ -/ -Concatenations -are -guaranteed -by -Hir -' -s -smart -constructors +The +character +class +will +be +expanded to -always -/ -/ -/ -have -at -least -two -sub -- -expressions -. -Concat -( -Vec -< -Hir -> -) +include +all +simple +case +folded / / / -An -alternation -of -expressions +character +variants . / / @@ -7045,280 +6613,90 @@ expressions / / / -An -alternation -matches -only -if -at -least -one -of -its -sub -- -expressions -/ -/ -/ -match -. If -multiple -sub -- -expressions -match -then -the -leftmost +this is +a +byte +oriented +character +class +then +this +will +be +limited / / / -preferred -. -/ -/ -/ -/ -/ -/ -Alternations -are -guaranteed -by -Hir -' -s -smart -constructors to -always -/ -/ -/ -have -at -least -two -sub +the +ASCII +ranges +A - -expressions -. -Alternation -( -Vec -< -Hir -> -) -} -impl -HirKind -{ -/ -/ -/ -Returns +Z +and a -slice -of -this -kind -' -s -sub - -expressions -if -any +z . pub fn -subs +case_fold_simple ( & +mut self ) -- -> -& -[ -Hir -] { -use -core -: -: -slice -: -: -from_ref -; match * self { -HirKind -: -: -Empty -| -HirKind -: -: -Literal -( -_ -) -| -HirKind -: -: Class -( -_ -) -| -HirKind -: -: -Look -( -_ -) -= -> -& -[ -] -HirKind : : -Repetition +Unicode ( -Repetition -{ ref -sub -. -. -} +mut +x ) = > -from_ref -( -sub -) -HirKind -: -: -Capture -( -Capture -{ -ref -sub -. +x . -} -) -= -> -from_ref +case_fold_simple ( -sub ) -HirKind +Class : : -Concat +Bytes ( ref -subs +mut +x ) = > -subs -HirKind -: -: -Alternation +x +. +case_fold_simple ( -ref -subs -) -= -> -subs -} -} -} -impl -core -: -: -fmt -: -: -Debug -for -Hir -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -self -. -kind -. -fmt -( -f ) } } / / / -Print -a -display -representation -of +Negate this -Hir +character +class +in +place . / / @@ -7326,382 +6704,292 @@ Hir / / / -The -result -of +After +completion this -is -a -valid -regular -expression -pattern -string -. -/ -/ -/ -/ -/ -/ -This -implementation -uses -constant -stack -space -and -heap -space -proportional +character +class +will +contain +precisely +the / / / -to -the -size -of +characters +that +weren +' +t +previously +in the -Hir +class . -impl -core -: -: -fmt -: -: -Display -for -Hir -{ +pub fn -fmt +negate ( & -self -f -: -& mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> +self ) -- -> -core -: -: -fmt -: -: -Result { -crate -: -: -hir -: -: -print +match +* +self +{ +Class : : -Printer +Unicode +( +ref +mut +x +) += +> +x +. +negate +( +) +Class : : -new +Bytes ( +ref +mut +x ) += +> +x . -print +negate ( -self -f ) } } / / / -The -high -- -level -intermediate -representation -of -a -literal -. -/ -/ -/ +Returns +true +if +and +only +if +this +character +class +will +only +ever +match / / / -A -literal -corresponds -to -0 -or -more -bytes -that -should -be -matched +valid +UTF +- +8 +. / / / -literally -. -The -smart -constructors -defined -on -Hir -will -automatically / / / -concatenate -adjacent -literals -into -one -literal -and -will -even -automatically +A +character +class +can +match +invalid +UTF +- +8 +only +when +the +following / / / -replace -empty -literals -with -Hir -: +conditions +are +met : -empty -( -) -. / / / / / / -Note -that -despite -a -literal -being -represented -by -a -sequence -of -bytes -its +1 +. +The +translator +was +configured +to +permit +generating +an +expression / / / -Debug -implementation -will -attempt -to -print -it -as -a -normal -string +that +can +match +invalid +UTF +- +8 . ( -That +By +default +this +is +disabled +. +) / / / -is -not -a -sequence -of -decimal -numbers +2 . -) -# -[ -derive +Unicode +mode ( -Clone -Eq -PartialEq +via +the +u +flag ) -] -pub -struct -Literal -( +was +disabled +either +in +the +concrete +/ +/ +/ +syntax +or +in +the +parser +builder +. +By +default +Unicode +mode +is +/ +/ +/ +enabled +. pub -Box -< -[ -u8 -] -> -) -; -impl -core -: -: -fmt -: -: -Debug -for -Literal -{ fn -fmt +is_always_utf8 ( & self -f -: -& -mut -core -: -: -fmt -: -: -Formatter ) - > -core -: -: -fmt -: -: -Result +bool { -crate +match +* +self +{ +Class : : -debug +Unicode +( +_ +) += +> +true +Class : : Bytes ( -& -self -. -0 +ref +x ) += +> +x . -fmt +is_all_ascii ( -f ) } } -/ -/ -/ -The -high -- -level -intermediate -representation -of -a -character -class -. -/ -/ -/ +} / / / A -character -class -corresponds -to -a set of characters -. -A -character -is -either -/ -/ -/ -defined +represented by -a Unicode scalar -value -or -a -byte +values . -Unicode -characters -are -used -/ -/ -/ -by -default -while -bytes -are -used -when -Unicode -mode +# +[ +derive ( -via -the -u -flag +Clone +Debug +Eq +PartialEq ) -is +] +pub +struct +ClassUnicode +{ +set +: +IntervalSet +< +ClassUnicodeRange +> +} +impl +ClassUnicode +{ / / / -disabled +Create +a +new +class +from +a +sequence +of +ranges . / / @@ -7709,251 +6997,279 @@ disabled / / / -A -character -class -regardless -of -its -character -type -is -represented -by -a -/ -/ -/ -sequence -of -non -- -overlapping -non -- -adjacent +The +given ranges -of -characters -. -/ -/ -/ -/ -/ -/ -Note -that -Bytes -variant -may -be -produced -even -when -it -exclusively -matches -/ -/ -/ -valid -UTF -- -8 -. -This -is -because -a -Bytes -variant -represents -an -intention -by -/ -/ -/ -the -author -of -the -regular -expression +do +not +need to -disable -Unicode -mode -which +be in -turn +any +specific +order +and +ranges / / / -impacts -the -semantics -of -case -insensitive -matching +may +overlap . -For -example +pub +fn +new +< +I +> ( -? -i +ranges +: +I ) -k -/ -/ -/ -and -( -? -i - -u -) -k -will -not -match -the -same +> +ClassUnicode +where +I +: +IntoIterator +< +Item += +ClassUnicodeRange +> +{ +ClassUnicode +{ set -of -strings -. -# -[ -derive +: +IntervalSet +: +: +new ( -Clone -Eq -PartialEq +ranges ) -] -pub -enum -Class -{ +} +} / / / -A -set -of -characters -represented -by -Unicode -scalar -values +Create +a +new +class +with +no +ranges . -Unicode +pub +fn +empty ( +) +- +> ClassUnicode +{ +ClassUnicode +: +: +new +( +vec +! +[ +] ) +} / / / -A +Add +a +new +range +to +this set -of -characters -represented -by -arbitrary -bytes +. +pub +fn +push ( -one -byte -per -/ -/ -/ -character +& +mut +self +range +: +ClassUnicodeRange ) +{ +self . -Bytes +set +. +push ( -ClassBytes +range ) +; } -impl -Class -{ / / / -Apply -Unicode -simple -case -folding -to +Return +an +iterator +over +all +ranges +in this -character class -in -place . / / / +/ +/ +/ The -character -class -will -be -expanded -to -include -all -simple -case -folded +iterator +yields +ranges +in +ascending +order +. +pub +fn +iter +( +& +self +) +- +> +ClassUnicodeIter +< +' +_ +> +{ +ClassUnicodeIter +( +self +. +set +. +iter +( +) +) +} / / / -character -variants +Return +the +underlying +ranges +as +a +slice +. +pub +fn +ranges +( +& +self +) +- +> +& +[ +ClassUnicodeRange +] +{ +self +. +set . +intervals +( +) +} / / / +Expand +this +character +class +such +that +it +contains +all +case +folded +/ +/ +/ +characters +according +to +Unicode +' +s +" +simple +" +mapping +. +For +example +if / / / -If this -is -a -byte -oriented -character class +consists +of +the +range +a +- +z then -this +applying +case +folding will -be -limited / / / -to +result +in +the +class +containing +both the -ASCII ranges -A -- -Z -and a - z +and +A +- +Z . / / @@ -8003,13 +7319,6 @@ feature is not enabled -and -the -underlying -class -is -Unicode -oriented . / / @@ -8044,113 +7353,94 @@ mut self ) { -match -* self -{ -Class -: -: -Unicode -( -ref -mut -x -) -= -> -x +. +set . case_fold_simple ( ) -Class -: -: -Bytes -( -ref -mut -x -) -= -> -x . -case_fold_simple +expect ( +" +unicode +- +case +feature +must +be +enabled +" ) -} +; } / / / -Apply -Unicode -simple -case -folding -to +Expand this character class -in -place -. -/ -/ -/ -The -character -class -will -be -expanded -to -include +such +that +it +contains all -simple case folded / / / -character -variants +characters +according +to +Unicode +' +s +" +simple +" +mapping . +For +example +if / / / -/ -/ -/ -If this -is -a -byte -oriented -character class +consists +of +the +range +a +- +z then -this +applying +case +folding will -be -limited / / / -to +result +in +the +class +containing +both the -ASCII ranges -A +a - -Z +z and -a +A - -z +Z . / / @@ -8202,16 +7492,6 @@ feature is not enabled -and -the -underlying -class -is -/ -/ -/ -Unicode -oriented . pub fn @@ -8223,9 +7503,6 @@ self ) - > -core -: -: result : : @@ -8236,50 +7513,14 @@ Result CaseFoldError > { -match -* self -{ -Class -: -: -Unicode -( -ref -mut -x -) -= -> -x . -try_case_fold_simple -( -) -? -Class -: -: -Bytes -( -ref -mut -x -) -= -> -x +set . case_fold_simple ( ) } -Ok -( -( -) -) -} / / / @@ -8287,8 +7528,6 @@ Negate this character class -in -place . / / @@ -8296,27 +7535,35 @@ place / / / -After -completion +For +all +c +where +c +is +a +Unicode +scalar +value +if +c +was +in this -character -class -will -contain -precisely -the / / / -characters -that -weren -' -t -previously +set +then +it +will +not +be in -the -class +this +set +after +negation . pub fn @@ -8327,231 +7574,158 @@ mut self ) { -match -* self -{ -Class -: -: -Unicode -( -ref -mut -x -) -= -> -x . -negate -( -) -Class -: -: -Bytes -( -ref -mut -x -) -= -> -x +set . negate ( ) -} +; } / / / -Returns -true -if -and -only -if +Union this character class -will -only -ever -match -/ -/ -/ -valid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -A +with +the +given character class -can -match -invalid -UTF -- -8 -only -when -the -following -/ -/ -/ -conditions -are -met +in +place +. +pub +fn +union +( +& +mut +self +other : -/ -/ -/ -/ -/ -/ -1 +& +ClassUnicode +) +{ +self . -The -translator -was -configured -to -permit -generating -an -expression -/ -/ -/ -that -can -match -invalid -UTF -- -8 +set . +union ( -By -default -this -is -disabled +& +other . +set ) +; +} / / / -2 -. -Unicode -mode -( -via +Intersect +this +character +class +with the -u -flag -) -was -disabled -either +given +character +class in -the -concrete / / / -syntax -or -in -the -parser -builder -. -By -default -Unicode -mode -is -/ -/ -/ -enabled +place . pub fn -is_utf8 +intersect ( & +mut self +other +: +& +ClassUnicode ) -- -> -bool { -match -* self -{ -Class -: -: -Unicode +. +set +. +intersect ( -_ +& +other +. +set ) -= -> -true -Class -: -: -Bytes +; +} +/ +/ +/ +Subtract +the +given +character +class +from +this +character +class +in +place +. +pub +fn +difference ( -ref -x +& +mut +self +other +: +& +ClassUnicode ) -= -> -x +{ +self +. +set . -is_ascii +difference ( +& +other +. +set ) -} +; } / / / -Returns +Compute the -length -in -bytes +symmetric +difference of the -smallest -string -matched -by -this +given +character +classes +in / / / -character -class +place . / / @@ -8559,114 +7733,208 @@ class / / / -For -non -- -empty -byte -oriented +This +computes +the +symmetric +difference +of +two +character classes -this -always -returns -1 . -For +This / / / -non -- -empty -Unicode -oriented -classes +removes +all +elements +in this -can -return -1 -2 -3 -or +class +that +are +also +in +the +given +class / / / -4 -. -For -empty -classes -None -is -returned -. -It -is -impossible -for -0 -to +but +all +adds +all +elements +from +the +given +class +that +aren +' +t +in +this / / / -be -returned +class . +That +is +the +class +will +contain +all +elements +in +either +class / / / +but +will +not +contain +any +elements +that +are +in +both +classes +. +pub +fn +symmetric_difference +( +& +mut +self +other +: +& +ClassUnicode +) +{ +self +. +set +. +symmetric_difference +( +& +other +. +set +) +; +} / / / -# -Example +Returns +true +if +and +only +if +this +character +class +will +either +match / / / +nothing +or +only +ASCII +bytes +. +Stated +differently +this +returns +false / / / -This -example -shows -some -examples -of -regexes +if and -their -corresponding -/ -/ -/ -minimum -length +only if -any +this +class +contains +a +non +- +ASCII +codepoint . -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: +pub +fn +is_all_ascii +( +& +self +) +- +> +bool { -hir -: -: -Properties -parse +self +. +set +. +intervals +( +) +. +last +( +) +. +map_or +( +true +| +r +| +r +. +end +< += +' +\ +x7F +' +) } -; +} +/ / / +An +iterator +over +all +ranges +in +a +Unicode +character +class +. / / / @@ -8674,423 +7942,651 @@ parse / / The -empty -string -has +lifetime +' a -min -length +refers +to +the +lifetime of -0 +the +underlying +class . -/ -/ -/ -let -hir -= -parse +# +[ +derive ( -r -" -" +Debug ) -? -; -/ -/ -/ -assert_eq -! -( -Some +] +pub +struct +ClassUnicodeIter +< +' +a +> ( -0 +IntervalSetIter +< +' +a +ClassUnicodeRange +> ) -hir -. -properties +; +impl +< +' +a +> +Iterator +for +ClassUnicodeIter +< +' +a +> +{ +type +Item += +& +' +a +ClassUnicodeRange +; +fn +next ( +& +mut +self ) +- +> +Option +< +& +' +a +ClassUnicodeRange +> +{ +self +. +0 . -minimum_len +next ( ) -) -; -/ -/ +} +} / / / -As -do -other -types +A +single +range of -regexes -that -only -match -the -empty -string +characters +represented +by +Unicode +scalar +values . / / / -let -hir -= -parse -( -r -" -^ -\ -b -\ -B -" -) -? -; / / / -assert_eq -! -( -Some -( -0 -) -hir -. -properties -( -) +The +range +is +closed . -minimum_len -( -) -) -; -/ -/ +That +is +the +start +and +end +of +the +range +are +included / / / -A -regex -that -can -match +in the -empty -string -but -match -more -is -still -0 +range . -/ -/ -/ -let -hir -= -parse +# +[ +derive ( -r -" -a -* -" +Clone +Copy +Default +Eq +PartialEq +PartialOrd +Ord ) -? -; -/ -/ -/ -assert_eq -! +] +pub +struct +ClassUnicodeRange +{ +start +: +char +end +: +char +} +impl +fmt +: +: +Debug +for +ClassUnicodeRange +{ +fn +fmt ( -Some +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +let +start += +if +! +self +. +start +. +is_whitespace ( -0 ) -hir +& +& +! +self +. +start . -properties +is_control ( ) +{ +self +. +start . -minimum_len +to_string ( ) +} +else +{ +format +! +( +" +0x +{ +: +X +} +" +self +. +start +as +u32 ) +} ; -/ -/ -/ -/ -/ -A -regex -that -matches -nothing -has -no -minimum -defined -. -/ -/ -/ let -hir +end = -parse +if +! +self +. +end +. +is_whitespace ( -r -" -[ -a +) & & -b -] -" -) -? -; -/ -/ -/ -assert_eq ! -( -None -hir +self +. +end . -properties +is_control ( ) +{ +self +. +end . -minimum_len +to_string ( ) +} +else +{ +format +! +( +" +0x +{ +: +X +} +" +self +. +end +as +u32 ) +} ; -/ -/ -/ -/ -/ -Character -classes -usually -have -a -minimum -length -of -1 +f . -/ -/ -/ -let -hir -= -parse +debug_struct ( -r " -\ -w +ClassUnicodeRange " ) -? -; -/ -/ -/ -assert_eq -! -( -Some +. +field ( -1 +" +start +" +& +start ) -hir . -properties +field ( +" +end +" +& +end ) . -minimum_len +finish ( ) -) +} +} +impl +Interval +for +ClassUnicodeRange +{ +type +Bound += +char ; -/ -/ -/ -/ -/ -But -sometimes -Unicode -classes -might -be -bigger -! -/ -/ -/ -let -hir -= -parse +# +[ +inline +] +fn +lower ( -r -" -\ -p +& +self +) +- +> +char { -Cyrillic +self +. +start } -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some +# +[ +inline +] +fn +upper ( -2 +& +self ) -hir +- +> +char +{ +self . -properties +end +} +# +[ +inline +] +fn +set_lower ( +& +mut +self +bound +: +char ) +{ +self . -minimum_len +start += +bound +; +} +# +[ +inline +] +fn +set_upper ( +& +mut +self +bound +: +char ) -) +{ +self +. +end += +bound ; +} / / / +Apply +simple +case +folding +to +this +Unicode +scalar +value +range +. / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) / / / -pub +Additional +ranges +are +appended +to +the +given +vector +. +Canonical +ordering +/ +/ +/ +is +* +not +* +maintained +in +the +given +vector +. fn -minimum_len +case_fold_simple ( & self +ranges +: +& +mut +Vec +< +ClassUnicodeRange +> ) - > -Option +Result < -usize +( +) +unicode +: +: +CaseFoldError > { -match -* -self -{ -Class +if +! +unicode : : -Unicode +contains_simple_case_mapping +( +self +. +start +self +. +end +) +? +{ +return +Ok +( ( -ref -x ) +) +; +} +let +start = -> -x +self . -minimum_len +start +as +u32 +; +let +end += ( +self +. +end +as +u32 ) -Class -: -: -Bytes +. +saturating_add ( -ref -x +1 ) +; +let +mut +next_simple_cp = -> -x +None +; +for +cp +in +( +start +. +. +end +) . -minimum_len +filter_map ( +char +: +: +from_u32 ) -} -} -/ -/ -/ -Returns -the -length +{ +if +next_simple_cp +. +map_or +( +false +| +next +| +cp +< +next +) +{ +continue +; +} +let +it += +match +unicode +: +: +simple_fold +( +cp +) +? +{ +Ok +( +it +) += +> +it +Err +( +next +) += +> +{ +next_simple_cp += +next +; +continue +; +} +} +; +for +cp_folded in -bytes -of -the -longest -string -matched -by -this +it +{ +ranges +. +push +( +ClassUnicodeRange +: +: +new +( +cp_folded +cp_folded +) +) +; +} +} +Ok +( +( +) +) +} +} +impl +ClassUnicodeRange +{ / / / +Create +a +new +Unicode +scalar +value +range +for +a character class . @@ -9100,58 +8596,67 @@ class / / / -For -non -- -empty -byte -oriented -classes -this +The +returned +range +is always -returns -1 +in +a +canonical +form . -For -/ -/ -/ -non -- -empty -Unicode -oriented -classes -this -can -return -1 -2 -3 -or +That +is +the +range / / / -4 -. -For -empty -classes -None -is returned +always +satisfies +the +invariant +that +start +< += +end . -It -is -impossible -for -0 -to +pub +fn +new +( +start +: +char +end +: +char +) +- +> +ClassUnicodeRange +{ +ClassUnicodeRange +: +: +create +( +start +end +) +} / / / -be -returned +Return +the +start +of +this +range . / / @@ -9159,31 +8664,51 @@ returned / / / -# -Example +The +start +of +a +range +is +always +less +than +or +equal +to +the +end +of +the / / / +range +. +pub +fn +start +( +& +self +) +- +> +char +{ +self +. +start +} / / / -This -example -shows -some -examples +Return +the +end of -regexes -and -their -corresponding -/ -/ -/ -maximum -length -if -any +this +range . / / @@ -9191,505 +8716,633 @@ any / / / +The +end +of +a +range +is +always +greater +than +or +equal +to +the +start +of +the / / / -use -regex_syntax -: -: +range +. +pub +fn +end +( +& +self +) +- +> +char { -hir -: -: -Properties -parse +self +. +end +} } -; -/ -/ -/ -/ -/ / / / -The -empty -string -has -a -max -length +A +set of -0 -. -/ -/ -/ -let -hir -= -parse +characters +represented +by +arbitrary +bytes ( -r -" -" -) -? -; +where +one +byte / / / -assert_eq -! -( -Some -( -0 +corresponds +to +one +character ) -hir . -properties +# +[ +derive ( +Clone +Debug +Eq +PartialEq ) +] +pub +struct +ClassBytes +{ +set +: +IntervalSet +< +ClassBytesRange +> +} +impl +ClassBytes +{ +/ +/ +/ +Create +a +new +class +from +a +sequence +of +ranges . -maximum_len -( -) -) -; / / / / / -As +/ +The +given +ranges do -other -types -of -regexes -that -only -match -the -empty -string -. +not +need +to +be +in +any +specific +order +and +ranges / / / -let -hir +may +overlap +. +pub +fn +new +< +I +> +( +ranges +: +I +) +- +> +ClassBytes +where +I +: +IntoIterator +< +Item = -parse +ClassBytesRange +> +{ +ClassBytes +{ +set +: +IntervalSet +: +: +new ( -r -" -^ -\ -b -\ -B -" +ranges ) -? -; +} +} / / / -assert_eq -! +Create +a +new +class +with +no +ranges +. +pub +fn +empty ( -Some +) +- +> +ClassBytes +{ +ClassBytes +: +: +new ( -0 +vec +! +[ +] ) -hir +} +/ +/ +/ +Add +a +new +range +to +this +set . -properties +pub +fn +push ( +& +mut +self +range +: +ClassBytesRange ) +{ +self +. +set . -maximum_len +push ( -) +range ) ; +} / / / +Return +an +iterator +over +all +ranges +in +this +class +. / / -A -regex -that -matches -nothing -has -no -maximum -defined -. / / / -let -hir -= -parse +/ +The +iterator +yields +ranges +in +ascending +order +. +pub +fn +iter ( -r -" -[ -a -& & -b -] -" +self ) -? -; -/ -/ -/ -assert_eq -! +- +> +ClassBytesIter +< +' +_ +> +{ +ClassBytesIter ( -None -hir +self . -properties -( -) +set . -maximum_len +iter ( ) ) -; -/ -/ +} / / / -Bounded -repeats -work +Return +the +underlying +ranges as -you -expect +a +slice . -/ -/ -/ -let -hir -= -parse -( -r -" -x -{ -2 -10 -} -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some +pub +fn +ranges ( -10 +& +self ) -hir +- +> +& +[ +ClassBytesRange +] +{ +self . -properties -( -) +set . -maximum_len +intervals ( ) -) -; +} +/ / / +Expand +this +character +class +such +that +it +contains +all +case +folded / / / -An -unbounded -repeat -means -there -is -no -maximum +characters . +For +example +if +this +class +consists +of +the +range +a +- +z / / / -let -hir -= -parse -( -r -" -x -{ -2 -} -" -) -? -; +then +applying +case +folding +will +result +in +the +class +containing +both +the / / / -assert_eq -! -( -None -hir -. -properties -( -) +ranges +a +- +z +and +A +- +Z . -maximum_len -( -) -) -; -/ / / / / -With -Unicode -enabled -\ -w -can -match -up -to -4 -bytes -! -/ / / -let -hir -= -parse -( -r -" -\ -w -" -) -? -; +Note +that +this +only +applies +ASCII +case +folding +which +is +limited +to +the / / / -assert_eq -! -( -Some +characters +a +- +z +and +A +- +Z +. +pub +fn +case_fold_simple ( -4 +& +mut +self ) -hir +{ +self . -properties +set +. +case_fold_simple ( ) . -maximum_len +expect ( -) +" +ASCII +case +folding +never +fails +" ) ; +} / / / -/ -/ -Without -Unicode -enabled -\ -w -matches -at -most -1 +Negate +this byte +class . / / / -let -hir -= -parse -( -r -" -( -? -- -u -) -\ -w -" -) -? -; / / / -assert_eq -! -( -Some -( -1 -) -hir +For +all +b +where +b +is +a +any +byte +if +b +was +in +this +set +then +it +/ +/ +/ +will +not +be +in +this +set +after +negation . -properties +pub +fn +negate ( +& +mut +self ) +{ +self +. +set . -maximum_len +negate ( ) -) ; +} / / / -/ -/ -/ -# -Ok -: -: -< +Union +this +byte +class +with +the +given +byte +class +in +place +. +pub +fn +union ( -) -Box -< -dyn -std -: -: -error -: +& +mut +self +other : -Error -> -> -( -( +& +ClassBytes ) +{ +self +. +set +. +union +( +& +other +. +set ) +; +} / / / +Intersect +this +byte +class +with +the +given +byte +class +in +place +. pub fn -maximum_len +intersect ( & +mut self +other +: +& +ClassBytes ) -- -> -Option -< -usize -> { -match -* self -{ -Class -: -: -Unicode -( -ref -x -) -= -> -x . -maximum_len -( -) -Class -: -: -Bytes -( -ref -x -) -= -> -x +set . -maximum_len +intersect ( +& +other +. +set ) -} +; } / / / -Returns -true -if -and -only -if +Subtract +the +given +byte +class +from this -character +byte class -is -empty +in +place . -That -is +pub +fn +difference +( +& +mut +self +other +: +& +ClassBytes +) +{ +self +. +set +. +difference +( +& +other +. +set +) +; +} / / / -it -has -no -elements +Compute +the +symmetric +difference +of +the +given +byte +classes +in +place . / / @@ -9697,342 +9350,290 @@ elements / / / -An -empty -character -can -never -match -anything -including -an -empty -string +This +computes +the +symmetric +difference +of +two +byte +classes +. +This +/ +/ +/ +removes +all +elements +in +this +class +that +are +also +in +the +given +class +/ +/ +/ +but +all +adds +all +elements +from +the +given +class +that +aren +' +t +in +this +/ +/ +/ +class +. +That +is +the +class +will +contain +all +elements +in +either +class +/ +/ +/ +but +will +not +contain +any +elements +that +are +in +both +classes . pub fn -is_empty +symmetric_difference ( & +mut self +other +: +& +ClassBytes ) -- -> -bool { -match -* self -{ -Class -: -: -Unicode -( -ref -x -) -= -> -x -. -ranges -( -) . -is_empty -( -) -Class -: -: -Bytes -( -ref -x -) -= -> -x +set . -ranges +symmetric_difference ( -) +& +other . -is_empty -( +set ) -} +; } / / / -If +Returns +true +if +and +only +if this +character class -consists -of -exactly -one -element -( -whether -a -codepoint -or -a +will +either +match / / / -byte -) -then -return -it -as -a -literal -byte -string +nothing +or +only +ASCII +bytes . +Stated +differently +this +returns +false / / / -/ -/ -/ -If +if +and +only +if this class -is -empty -or contains -more -than -one -element -then -None -/ -/ -/ -is -returned +a +non +- +ASCII +byte . pub fn -literal +is_all_ascii ( & self ) - > -Option -< -Vec -< -u8 -> -> +bool { -match -* self -{ -Class -: -: -Unicode -( -ref -x -) -= -> -x . -literal +set +. +intervals ( ) -Class -: -: -Bytes +. +last ( -ref -x ) -= -> -x . -literal +map_or ( +true +| +r +| +r +. +end +< += +0x7F ) } } -} -impl -core -: -: -fmt -: -: -Debug -for -Class -{ -fn -fmt +/ +/ +/ +An +iterator +over +all +ranges +in +a +byte +character +class +. +/ +/ +/ +/ +/ +/ +The +lifetime +' +a +refers +to +the +lifetime +of +the +underlying +class +. +# +[ +derive ( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter +Debug ) -- +] +pub +struct +ClassBytesIter +< +' +a > -core -: -: -fmt -: -: -Result -{ -use -crate -: -: -debug -: -: -Byte -; -let -mut -fmter -= -f -. -debug_set ( +IntervalSetIter +< +' +a +ClassBytesRange +> ) ; -match -* -self -{ -Class -: -: -Unicode -( -ref -cls -) -= +impl +< +' +a > -{ +Iterator for -r -in -cls -. -ranges -( -) -. -iter -( -) +ClassBytesIter +< +' +a +> { -fmter -. -entry -( -& -( -r -. -start -. -. +type +Item = -r -. -end -) -) +& +' +a +ClassBytesRange ; -} -} -Class -: -: -Bytes +fn +next ( -ref -cls +& +mut +self ) -= +- > -{ -for -r -in -cls -. -ranges -( -) -. -iter -( -) -{ -fmter -. -entry -( +Option +< & -( -Byte -( -r -. -start -) -. -. -= -Byte -( -r +' +a +ClassBytesRange +> +{ +self . -end -) -) -) -; -} -} -} -fmter +0 . -finish +next ( ) } @@ -10041,235 +9642,185 @@ finish / / A -set +single +range of characters represented by -Unicode -scalar -values +arbitrary +bytes +. +/ +/ +/ +/ +/ +/ +The +range +is +closed +. +That +is +the +start +and +end +of +the +range +are +included +/ +/ +/ +in +the +range . # [ derive ( Clone -Debug +Copy +Default Eq PartialEq +PartialOrd +Ord ) ] pub struct -ClassUnicode +ClassBytesRange { -set +start : -IntervalSet -< -ClassUnicodeRange -> +u8 +end +: +u8 } impl -ClassUnicode +Interval +for +ClassBytesRange { -/ -/ -/ -Create -a -new -class -from -a -sequence -of -ranges -. -/ -/ -/ -/ -/ -/ -The -given -ranges -do -not -need -to -be -in -any -specific -order -and -ranges -/ -/ -/ -may -overlap -. -Ranges -will -automatically -be -sorted -into -a -canonical -/ -/ -/ -non -- -overlapping -order -. -pub +type +Bound += +u8 +; +# +[ +inline +] fn -new -< -I -> +lower ( -ranges -: -I +& +self ) - > -ClassUnicode -where -I -: -IntoIterator -< -Item -= -ClassUnicodeRange -> -{ -ClassUnicode +u8 { -set -: -IntervalSet -: -: -new -( -ranges -) -} -} -/ -/ -/ -Create -a -new -class -with -no -ranges -. -/ -/ -/ -/ -/ -/ -An -empty -class -matches -nothing +self . -That -is -it -is -equivalent -to -/ -/ -/ +start +} +# [ -Hir -: -: -fail +inline ] -. -pub fn -empty +upper ( +& +self ) - > -ClassUnicode +u8 { -ClassUnicode -: -: -new -( -vec -! +self +. +end +} +# [ +inline ] -) -} -/ -/ -/ -Add -a -new -range -to -this -set -. -pub fn -push +set_lower ( & mut self -range +bound : -ClassUnicodeRange +u8 ) { self . -set -. -push +start += +bound +; +} +# +[ +inline +] +fn +set_upper ( -range +& +mut +self +bound +: +u8 ) +{ +self +. +end += +bound ; } / / / -Return -an -iterator -over -all -ranges -in +Apply +simple +case +folding +to this -class +byte +range +. +Only +ASCII +case +mappings +/ +/ +/ +( +for +a +- +z +) +are +applied . / / @@ -10277,188 +9828,348 @@ class / / / -The -iterator -yields +Additional ranges -in -ascending -order -. -pub -fn -iter -( +are +appended +to +the +given +vector +. +Canonical +ordering +/ +/ +/ +is +* +not +* +maintained +in +the +given +vector +. +fn +case_fold_simple +( & self +ranges +: +& +mut +Vec +< +ClassBytesRange +> ) - > -ClassUnicodeIter +Result < -' -_ +( +) +unicode +: +: +CaseFoldError > { -ClassUnicodeIter +if +! +ClassBytesRange +: +: +new +( +b +' +a +' +b +' +z +' +) +. +is_intersection_empty +( +self +) +{ +let +lower += +cmp +: +: +max ( self . -set +start +b +' +a +' +) +; +let +upper += +cmp +: +: +min +( +self . -iter +end +b +' +z +' +) +; +ranges +. +push +( +ClassBytesRange +: +: +new ( +lower +- +32 +upper +- +32 ) ) +; } -/ -/ -/ -Return -the -underlying -ranges -as -a -slice +if +! +ClassBytesRange +: +: +new +( +b +' +A +' +b +' +Z +' +) . -pub -fn -ranges +is_intersection_empty ( -& self ) -- -> -& -[ -ClassUnicodeRange -] { +let +lower += +cmp +: +: +max +( self . -set +start +b +' +A +' +) +; +let +upper += +cmp +: +: +min +( +self . -intervals +end +b +' +Z +' +) +; +ranges +. +push +( +ClassBytesRange +: +: +new +( +lower ++ +32 +upper ++ +32 +) +) +; +} +Ok +( ( ) +) +} } +impl +ClassBytesRange +{ / / / -Expand -this +Create +a +new +byte +range +for +a character class -such -that -it -contains -all -case -folded +. / / / -characters -according -to -Unicode -' -s -" -simple -" -mapping -. -For -example -if / / / -this -class -consists -of -the +The +returned range +is +always +in a -- -z -then -applying -case -folding -will +canonical +form +. +That +is +the +range / / / -result -in -the -class -containing -both +returned +always +satisfies the -ranges -a -- -z -and -A -- -Z +invariant +that +start +< += +end . +pub +fn +new +( +start +: +u8 +end +: +u8 +) +- +> +ClassBytesRange +{ +ClassBytesRange +: +: +create +( +start +end +) +} / / / -/ -/ -/ -# -Panics +Return +the +start +of +this +range +. / / / / / / -This -routine -panics -when +The +start +of +a +range +is +always +less +than +or +equal +to +the +end +of the -case -mapping -data -necessary -for -this / / / -routine -to -complete -is -unavailable +range . -This -occurs -when -the -unicode +pub +fn +start +( +& +self +) - -case +> +u8 +{ +self +. +start +} / / / -feature -is -not -enabled +Return +the +end +of +this +range . / / @@ -10466,566 +10177,559 @@ enabled / / / -Callers -should -prefer -using -try_case_fold_simple -instead -which -will +The +end +of +a +range +is +always +greater +than +or +equal +to +the +start +of +the / / / -return -an -error -instead -of -panicking +range . pub fn -case_fold_simple +end ( & -mut self ) +- +> +u8 { self . -set -. -case_fold_simple +end +} +} +impl +fmt +: +: +Debug +for +ClassBytesRange +{ +fn +fmt ( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> ) +- +> +fmt +: +: +Result +{ +let +mut +debug += +f . -expect +debug_struct ( " -unicode -- -case -feature -must -be -enabled +ClassBytesRange " ) ; -} -/ -/ -/ -Expand -this -character -class -such -that -it -contains -all -case -folded -/ -/ -/ -characters -according -to -Unicode -' -s +if +self +. +start +< += +0x7F +{ +debug +. +field +( " -simple +start " -mapping +& +( +self . -For -example +start +as +char +) +) +; +} +else +{ +debug +. +field +( +" +start +" +& +self +. +start +) +; +} if +self +. +end +< += +0x7F +{ +debug +. +field +( +" +end +" +& +( +self +. +end +as +char +) +) +; +} +else +{ +debug +. +field +( +" +end +" +& +self +. +end +) +; +} +debug +. +finish +( +) +} +} / / / -this -class -consists -of -the -range -a +The +high - -z -then -applying -case -folding -will +level +intermediate +representation +for +an +anchor +assertion +. +/ +/ +/ / / / -result -in -the -class -containing -both -the -ranges -a -- -z -and A +matching +anchor +assertion +is +always +zero - -Z +length . +# +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +enum +Anchor +{ / / / +Match +the +beginning +of +a +line +or +the +beginning +of +text +. +Specifically / / / -# -Error +this +matches +at +the +starting +position +of +the +input +or +at +the +position / / / +immediately +following +a +\ +n +character +. +StartLine / / / -This -routine -returns -an -error -when +Match the -case -mapping -data -necessary +end +of +a +line +or +the +end +of +text +. +Specifically / / / -for this -routine -to -complete -is -unavailable -. -This -occurs -when +matches +at +the +end +position +of the +input +or +at +the +position / / / -unicode -- -case -feature -is -not -enabled -. -pub -fn -try_case_fold_simple -( -& -mut -self -) -- -> -core -: -: -result -: -: -Result -< -( -) -CaseFoldError -> -{ -self -. -set +immediately +preceding +a +\ +n +character . -case_fold_simple -( -) -} +EndLine / / / -Negate -this -character -class +Match +the +beginning +of +text . +Specifically +this +matches +at +the +starting / / / +position +of +the +input +. +StartText / / / -For -all -c -where -c -is -a -Unicode -scalar -value -if -c -was -in +Match +the +end +of +text +. +Specifically this +matches +at +the +ending / / / -set -then -it -will -not -be -in -this -set -after -negation -. -pub -fn -negate -( -& -mut -self -) -{ -self -. -set +position +of +the +input . -negate -( -) -; +EndText } / / / -Union -this -character -class -with -the -given -character -class -in -place -. -pub -fn -union -( -& -mut -self -other -: -& -ClassUnicode -) -{ -self -. -set -. -union -( -& -other +The +high +- +level +intermediate +representation +for +a +word +- +boundary +assertion . -set -) -; -} / / / -Intersect -this -character -class -with -the -given -character -class -in / / / -place +A +matching +word +boundary +assertion +is +always +zero +- +length . -pub -fn -intersect +# +[ +derive ( -& -mut -self -other -: -& -ClassUnicode +Clone +Debug +Eq +PartialEq ) +] +pub +enum +WordBoundary { -self -. -set -. -intersect -( -& -other -. -set -) -; -} / / / -Subtract -the -given -character -class -from -this -character -class -in -place -. -pub -fn -difference -( -& -mut -self -other -: -& -ClassUnicode -) -{ -self -. -set -. -difference -( -& -other +Match +a +Unicode +- +aware +word +boundary . -set -) -; -} +That +is +this +matches +a +position / / / -Compute -the -symmetric -difference -of +where the -given +left +adjacent +character +and +right +adjacent character -classes -in -/ -/ -/ -place -. -/ -/ -/ / / / -This -computes -the -symmetric -difference -of -two +correspond +to +a +word +and +non +- +word +or +a +non +- +word +and +word character -classes . -This -/ -/ -/ -removes -all -elements -in -this -class -that -are -also -in -the -given -class +Unicode / / / -but -all -adds -all -elements -from -the -given -class -that -aren -' -t -in -this +Match +a +Unicode +- +aware +negation +of +a +word +boundary +. +UnicodeNegate / / / -class +Match +an +ASCII +- +only +word +boundary . That is -the -class -will -contain -all -elements -in -either -class +this +matches +a +position / / / -but -will -not -contain -any -elements -that -are -in -both -classes -. -pub -fn -symmetric_difference -( -& -mut -self -other -: -& -ClassUnicode -) -{ -self -. -set -. -symmetric_difference -( -& -other -. -set -) -; -} +where +the +left +adjacent +character +and +right +adjacent +character / / / -Returns -true -if +correspond +to +a +word and -only -if -this +non +- +word +or +a +non +- +word +and +word character -class -will -either -match +. +Ascii / / / -nothing -or -only +Match +an ASCII -bytes +- +only +negation +of +a +word +boundary . -Stated -differently -this -returns -false +AsciiNegate +} +impl +WordBoundary +{ / / / +Returns +true if and only if this -class -contains -a -non -- -ASCII -codepoint +word +boundary +assertion +is +negated . pub fn -is_ascii +is_negated ( & self @@ -11034,246 +10738,243 @@ self > bool { +match +* self -. -set -. -intervals -( -) -. -last -( -) -. -map_or -( -true +{ +WordBoundary +: +: +Unicode | -r +WordBoundary +: +: +Ascii += +> +false +WordBoundary +: +: +UnicodeNegate | -r -. -end -< +WordBoundary +: +: +AsciiNegate = -' -\ -x7F -' -) +> +true +} +} } / / / -Returns -the -length -in -bytes -of -the -smallest -string -matched -by -this +The +high +- +level +intermediate +representation +for +a +group +. / / / -character -class -. / / / +This +represents +one +of +three +possible +group +types +: / / / -Returns -None -when -the -class -is -empty +/ +/ +/ +1 . -pub -fn -minimum_len -( -& -self -) +A +non - -> -Option -< -usize -> -{ -let -first -= -self -. -ranges +capturing +group ( -) +e +. +g . -get ( -0 -) ? -; +: +expr +) +) +. / / -Correct -because -c1 -< -c2 -implies -c1 +/ +2 . -len_utf8 +A +capturing +group ( -) -< -c2 +e +. +g . -len_utf8 ( +expr +) ) . -Some +/ +/ +/ +3 +. +A +named +capturing +group ( -first +e . -start +g . -len_utf8 ( +? +P +< +name +> +expr ) ) -} +. +# +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +struct +Group +{ / / / -Returns -the -length -in -bytes +The +kind of -the -longest -string -matched -by this +group +. +If +it +is +a +capturing +group +then +the +kind / / / -character -class -. +contains +the +capture +group +index +( +and +the +name +if +it +is +a +named / / / +group +) +. +pub +kind +: +GroupKind / / / -Returns -None -when +The +expression +inside the -class -is +capturing +group +which +may +be empty . pub -fn -maximum_len -( -& -self -) -- -> -Option +hir +: +Box < -usize +Hir > -{ -let -last -= -self -. -ranges -( -) -. -last -( -) -? -; -/ -/ -Correct -because -c1 -< -c2 -implies -c1 -. -len_utf8 -( -) -< -c2 -. -len_utf8 -( -) -. -Some -( -last -. -end -. -len_utf8 -( -) -) } / / / -If -this -class -consists +The +kind of -exactly -one -codepoint -then -return -it -as +group +. +# +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +enum +GroupKind +{ / / / -a -literal -byte -string +A +normal +unnamed +capturing +group . / / @@ -11281,264 +10982,80 @@ string / / / -If -this -class +The +value is -empty -or -contains -more -than -one -codepoint -then -None -/ -/ -/ -is -returned -. -pub -fn -literal -( -& -self -) -- -> -Option -< -Vec -< -u8 -> -> -{ -let -rs -= -self -. -ranges -( -) -; -if -rs -. -len -( -) -= -= -1 -& -& -rs -[ -0 -] -. -start -= -= -rs -[ -0 -] -. -end -{ -Some -( -rs -[ -0 -] -. -start -. -encode_utf8 -( -& -mut -[ -0 -; -4 -] -) +the +capture +index +of +the +group . -to_string +CaptureIndex ( +u32 ) +/ +/ +/ +A +named +capturing +group . -into_bytes -( -) -) -} -else +CaptureName { -None -} -} / / / -If -this -class -consists +The +name of -only -ASCII -ranges -then -return -its +the +group +. +name +: +String / / / -corresponding -and -equivalent -byte -class -. -pub -fn -to_byte_class -( -& -self -) -- -> -Option -< -ClassBytes -> -{ -if -! -self +The +capture +index +of +the +group . -is_ascii -( -) -{ -return -None -; -} -Some -( -ClassBytes -: +index : -new -( -self -. -ranges -( -) -. -iter -( -) -. -map -( -| -r -| -{ -/ +u32 +} / -Since -we -are -guaranteed -that -our -codepoint -range -is -ASCII -the / / -' -u8 -: -: -try_from -' -calls -below -are -guaranteed -to -be -correct -. -ClassBytesRange -{ -start -: -u8 -: -: -try_from -( -r -. -start -) -. -unwrap -( -) -end -: -u8 -: -: -try_from -( -r -. -end -) +A +non +- +capturing +group . -unwrap -( -) -} -} -) -) -) -} +NonCapturing } / / / -An -iterator -over -all -ranges -in +The +high +- +level +intermediate +representation +of a -Unicode -character -class +repetition +operator . / / @@ -11546,102 +11063,91 @@ class / / / -The -lifetime -' -a -refers -to +A +repetition +operator +permits the -lifetime +repetition of -the -underlying -class +an +arbitrary +/ +/ +/ +sub +- +expression . # [ derive ( +Clone Debug +Eq +PartialEq ) ] pub struct -ClassUnicodeIter -< -' -a -> -( -IntervalSetIter -< -' -a -ClassUnicodeRange -> -) -; -impl -< -' -a -> -Iterator -for -ClassUnicodeIter -< -' -a -> -{ -type -Item -= -& -' -a -ClassUnicodeRange -; -fn -next -( -& -mut -self -) -- -> -Option -< -& -' -a -ClassUnicodeRange -> +Repetition { -self +/ +/ +/ +The +kind +of +this +repetition +operator . -0 +pub +kind +: +RepetitionKind +/ +/ +/ +Whether +this +repetition +operator +is +greedy +or +not . -next -( -) -} -} +A +greedy +operator / / / +will +match +as +much +as +it +can +. A -single -range -of -characters -represented -by -Unicode -scalar -values +non +- +greedy +operator +will +match +as +/ +/ +/ +little +as +it +can . / / @@ -11649,15642 +11155,1166 @@ values / / / -The -range -is -closed -. -That -is -the -start +Typically +operators +are +greedy +by +default and -end -of -the -range are -included +only +non +- +greedy +when / / / -in -the -range -. -# -[ -derive -( -Clone -Copy -Default -Eq -PartialEq -PartialOrd -Ord -) -] -pub -struct -ClassUnicodeRange -{ -start -: -char -end -: -char -} -impl -core -: -: -fmt -: -: -Debug -for -ClassUnicodeRange -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -let -start -= -if -! -self -. -start -. -is_whitespace -( -) -& -& -! -self -. -start -. -is_control -( -) -{ -self -. -start -. -to_string -( -) -} -else -{ -format -! -( -" -0x -{ -: -X -} -" -u32 -: -: -from -( -self -. -start -) -) -} -; -let -end -= -if -! -self -. -end -. -is_whitespace -( -) -& -& -! -self -. -end -. -is_control -( -) -{ -self -. -end -. -to_string -( -) -} -else -{ -format -! -( -" -0x -{ -: -X -} -" -u32 -: -: -from -( -self -. -end -) -) -} -; -f -. -debug_struct -( -" -ClassUnicodeRange -" -) -. -field -( -" -start -" -& -start -) -. -field -( -" -end -" -& -end -) -. -finish -( -) -} -} -impl -Interval -for -ClassUnicodeRange -{ -type -Bound -= -char -; -# -[ -inline -] -fn -lower -( -& -self -) -- -> -char -{ -self -. -start -} -# -[ -inline -] -fn -upper -( -& -self -) -- -> -char -{ -self -. -end -} -# -[ -inline -] -fn -set_lower -( -& -mut -self -bound -: -char -) -{ -self -. -start -= -bound -; -} -# -[ -inline -] -fn -set_upper -( -& -mut -self -bound -: -char -) -{ -self -. -end -= -bound -; -} -/ -/ -/ -Apply -simple -case -folding -to -this -Unicode -scalar -value -range -. -/ -/ -/ -/ -/ -/ -Additional -ranges -are -appended -to -the -given -vector -. -Canonical -ordering -/ -/ -/ -is -* -not -* -maintained -in -the -given -vector -. -fn -case_fold_simple -( -& -self -ranges -: -& -mut -Vec -< -ClassUnicodeRange -> -) -- -> -Result -< -( -) -unicode -: -: -CaseFoldError -> -{ -let -mut -folder -= -unicode -: -: -SimpleCaseFolder -: -: -new -( -) -? -; -if -! -folder -. -overlaps -( -self -. -start -self -. -end -) -{ -return -Ok -( -( -) -) -; -} -let -( -start -end -) -= -( -u32 -: -: -from -( -self -. -start -) -u32 -: -: -from -( -self -. -end -) -) -; -for -cp -in -( -start -. -. -= -end -) -. -filter_map -( -char -: -: -from_u32 -) -{ -for -& -cp_folded -in -folder -. -mapping -( -cp -) -{ -ranges -. -push -( -ClassUnicodeRange -: -: -new -( -cp_folded -cp_folded -) -) -; -} -} -Ok -( -( -) -) -} -} -impl -ClassUnicodeRange -{ -/ -/ -/ -Create -a -new -Unicode -scalar -value -range -for -a -character -class -. -/ -/ -/ -/ -/ -/ -The -returned -range -is -always -in -a -canonical -form -. -That -is -the -range -/ -/ -/ -returned -always -satisfies -the -invariant -that -start -< -= -end -. -pub -fn -new -( -start -: -char -end -: -char -) -- -> -ClassUnicodeRange -{ -ClassUnicodeRange -: -: -create -( -start -end -) -} -/ -/ -/ -Return -the -start -of -this -range -. -/ -/ -/ -/ -/ -/ -The -start -of -a -range -is -always -less -than -or -equal -to -the -end -of -the -/ -/ -/ -range -. -pub -fn -start -( -& -self -) -- -> -char -{ -self -. -start -} -/ -/ -/ -Return -the -end -of -this -range -. -/ -/ -/ -/ -/ -/ -The -end -of -a -range -is -always -greater -than -or -equal -to -the -start -of -the -/ -/ -/ -range -. -pub -fn -end -( -& -self -) -- -> -char -{ -self -. -end -} -/ -/ -/ -Returns -the -number -of -codepoints -in -this -range -. -pub -fn -len -( -& -self -) -- -> -usize -{ -let -diff -= -1 -+ -u32 -: -: -from -( -self -. -end -) -- -u32 -: -: -from -( -self -. -start -) -; -/ -/ -This -is -likely -to -panic -in -16 -- -bit -targets -since -a -usize -can -only -fit -/ -/ -2 -^ -16 -. -It -' -s -not -clear -what -to -do -here -other -than -to -return -an -error -/ -/ -when -building -a -Unicode -class -that -contains -a -range -whose -length -/ -/ -overflows -usize -. -( -Which -to -be -honest -is -probably -quite -common -on -/ -/ -16 -- -bit -targets -. -For -example -this -would -imply -that -' -. -' -and -' -\ -p -{ -any -} -' -/ -/ -would -be -impossible -to -build -. -) -usize -: -: -try_from -( -diff -) -. -expect -( -" -char -class -len -fits -in -usize -" -) -} -} -/ -/ -/ -A -set -of -characters -represented -by -arbitrary -bytes -( -where -one -byte -/ -/ -/ -corresponds -to -one -character -) -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -ClassBytes -{ -set -: -IntervalSet -< -ClassBytesRange -> -} -impl -ClassBytes -{ -/ -/ -/ -Create -a -new -class -from -a -sequence -of -ranges -. -/ -/ -/ -/ -/ -/ -The -given -ranges -do -not -need -to -be -in -any -specific -order -and -ranges -/ -/ -/ -may -overlap -. -Ranges -will -automatically -be -sorted -into -a -canonical -/ -/ -/ -non -- -overlapping -order -. -pub -fn -new -< -I -> -( -ranges -: -I -) -- -> -ClassBytes -where -I -: -IntoIterator -< -Item -= -ClassBytesRange -> -{ -ClassBytes -{ -set -: -IntervalSet -: -: -new -( -ranges -) -} -} -/ -/ -/ -Create -a -new -class -with -no -ranges -. -/ -/ -/ -/ -/ -/ -An -empty -class -matches -nothing -. -That -is -it -is -equivalent -to -/ -/ -/ -[ -Hir -: -: -fail -] -. -pub -fn -empty -( -) -- -> -ClassBytes -{ -ClassBytes -: -: -new -( -vec -! -[ -] -) -} -/ -/ -/ -Add -a -new -range -to -this -set -. -pub -fn -push -( -& -mut -self -range -: -ClassBytesRange -) -{ -self -. -set -. -push -( -range -) -; -} -/ -/ -/ -Return -an -iterator -over -all -ranges -in -this -class -. -/ -/ -/ -/ -/ -/ -The -iterator -yields -ranges -in -ascending -order -. -pub -fn -iter -( -& -self -) -- -> -ClassBytesIter -< -' -_ -> -{ -ClassBytesIter -( -self -. -set -. -iter -( -) -) -} -/ -/ -/ -Return -the -underlying -ranges -as -a -slice -. -pub -fn -ranges -( -& -self -) -- -> -& -[ -ClassBytesRange -] -{ -self -. -set -. -intervals -( -) -} -/ -/ -/ -Expand -this -character -class -such -that -it -contains -all -case -folded -/ -/ -/ -characters -. -For -example -if -this -class -consists -of -the -range -a -- -z -/ -/ -/ -then -applying -case -folding -will -result -in -the -class -containing -both -the -/ -/ -/ -ranges -a -- -z -and -A -- -Z -. -/ -/ -/ -/ -/ -/ -Note -that -this -only -applies -ASCII -case -folding -which -is -limited -to -the -/ -/ -/ -characters -a -- -z -and -A -- -Z -. -pub -fn -case_fold_simple -( -& -mut -self -) -{ -self -. -set -. -case_fold_simple -( -) -. -expect -( -" -ASCII -case -folding -never -fails -" -) -; -} -/ -/ -/ -Negate -this -byte -class -. -/ -/ -/ -/ -/ -/ -For -all -b -where -b -is -a -any -byte -if -b -was -in -this -set -then -it -/ -/ -/ -will -not -be -in -this -set -after -negation -. -pub -fn -negate -( -& -mut -self -) -{ -self -. -set -. -negate -( -) -; -} -/ -/ -/ -Union -this -byte -class -with -the -given -byte -class -in -place -. -pub -fn -union -( -& -mut -self -other -: -& -ClassBytes -) -{ -self -. -set -. -union -( -& -other -. -set -) -; -} -/ -/ -/ -Intersect -this -byte -class -with -the -given -byte -class -in -place -. -pub -fn -intersect -( -& -mut -self -other -: -& -ClassBytes -) -{ -self -. -set -. -intersect -( -& -other -. -set -) -; -} -/ -/ -/ -Subtract -the -given -byte -class -from -this -byte -class -in -place -. -pub -fn -difference -( -& -mut -self -other -: -& -ClassBytes -) -{ -self -. -set -. -difference -( -& -other -. -set -) -; -} -/ -/ -/ -Compute -the -symmetric -difference -of -the -given -byte -classes -in -place -. -/ -/ -/ -/ -/ -/ -This -computes -the -symmetric -difference -of -two -byte -classes -. -This -/ -/ -/ -removes -all -elements -in -this -class -that -are -also -in -the -given -class -/ -/ -/ -but -all -adds -all -elements -from -the -given -class -that -aren -' -t -in -this -/ -/ -/ -class -. -That -is -the -class -will -contain -all -elements -in -either -class -/ -/ -/ -but -will -not -contain -any -elements -that -are -in -both -classes -. -pub -fn -symmetric_difference -( -& -mut -self -other -: -& -ClassBytes -) -{ -self -. -set -. -symmetric_difference -( -& -other -. -set -) -; -} -/ -/ -/ -Returns -true -if -and -only -if -this -character -class -will -either -match -/ -/ -/ -nothing -or -only -ASCII -bytes -. -Stated -differently -this -returns -false -/ -/ -/ -if -and -only -if -this -class -contains -a -non -- -ASCII -byte -. -pub -fn -is_ascii -( -& -self -) -- -> -bool -{ -self -. -set -. -intervals -( -) -. -last -( -) -. -map_or -( -true -| -r -| -r -. -end -< -= -0x7F -) -} -/ -/ -/ -Returns -the -length -in -bytes -of -the -smallest -string -matched -by -this -/ -/ -/ -character -class -. -/ -/ -/ -/ -/ -/ -Returns -None -when -the -class -is -empty -. -pub -fn -minimum_len -( -& -self -) -- -> -Option -< -usize -> -{ -if -self -. -ranges -( -) -. -is_empty -( -) -{ -None -} -else -{ -Some -( -1 -) -} -} -/ -/ -/ -Returns -the -length -in -bytes -of -the -longest -string -matched -by -this -/ -/ -/ -character -class -. -/ -/ -/ -/ -/ -/ -Returns -None -when -the -class -is -empty -. -pub -fn -maximum_len -( -& -self -) -- -> -Option -< -usize -> -{ -if -self -. -ranges -( -) -. -is_empty -( -) -{ -None -} -else -{ -Some -( -1 -) -} -} -/ -/ -/ -If -this -class -consists -of -exactly -one -byte -then -return -it -as -/ -/ -/ -a -literal -byte -string -. -/ -/ -/ -/ -/ -/ -If -this -class -is -empty -or -contains -more -than -one -byte -then -None -/ -/ -/ -is -returned -. -pub -fn -literal -( -& -self -) -- -> -Option -< -Vec -< -u8 -> -> -{ -let -rs -= -self -. -ranges -( -) -; -if -rs -. -len -( -) -= -= -1 -& -& -rs -[ -0 -] -. -start -= -= -rs -[ -0 -] -. -end -{ -Some -( -vec -! -[ -rs -[ -0 -] -. -start -] -) -} -else -{ -None -} -} -/ -/ -/ -If -this -class -consists -of -only -ASCII -ranges -then -return -its -/ -/ -/ -corresponding -and -equivalent -Unicode -class -. -pub -fn -to_unicode_class -( -& -self -) -- -> -Option -< -ClassUnicode -> -{ -if -! -self -. -is_ascii -( -) -{ -return -None -; -} -Some -( -ClassUnicode -: -: -new -( -self -. -ranges -( -) -. -iter -( -) -. -map -( -| -r -| -{ -/ -/ -Since -we -are -guaranteed -that -our -byte -range -is -ASCII -the -/ -/ -' -char -: -: -from -' -calls -below -are -correct -and -will -not -erroneously -/ -/ -convert -a -raw -byte -value -into -its -corresponding -codepoint -. -ClassUnicodeRange -{ -start -: -char -: -: -from -( -r -. -start -) -end -: -char -: -: -from -( -r -. -end -) -} -} -) -) -) -} -} -/ -/ -/ -An -iterator -over -all -ranges -in -a -byte -character -class -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -underlying -class -. -# -[ -derive -( -Debug -) -] -pub -struct -ClassBytesIter -< -' -a -> -( -IntervalSetIter -< -' -a -ClassBytesRange -> -) -; -impl -< -' -a -> -Iterator -for -ClassBytesIter -< -' -a -> -{ -type -Item -= -& -' -a -ClassBytesRange -; -fn -next -( -& -mut -self -) -- -> -Option -< -& -' -a -ClassBytesRange -> -{ -self -. -0 -. -next -( -) -} -} -/ -/ -/ -A -single -range -of -characters -represented -by -arbitrary -bytes -. -/ -/ -/ -/ -/ -/ -The -range -is -closed -. -That -is -the -start -and -end -of -the -range -are -included -/ -/ -/ -in -the -range -. -# -[ -derive -( -Clone -Copy -Default -Eq -PartialEq -PartialOrd -Ord -) -] -pub -struct -ClassBytesRange -{ -start -: -u8 -end -: -u8 -} -impl -Interval -for -ClassBytesRange -{ -type -Bound -= -u8 -; -# -[ -inline -] -fn -lower -( -& -self -) -- -> -u8 -{ -self -. -start -} -# -[ -inline -] -fn -upper -( -& -self -) -- -> -u8 -{ -self -. -end -} -# -[ -inline -] -fn -set_lower -( -& -mut -self -bound -: -u8 -) -{ -self -. -start -= -bound -; -} -# -[ -inline -] -fn -set_upper -( -& -mut -self -bound -: -u8 -) -{ -self -. -end -= -bound -; -} -/ -/ -/ -Apply -simple -case -folding -to -this -byte -range -. -Only -ASCII -case -mappings -/ -/ -/ -( -for -a -- -z -) -are -applied -. -/ -/ -/ -/ -/ -/ -Additional -ranges -are -appended -to -the -given -vector -. -Canonical -ordering -/ -/ -/ -is -* -not -* -maintained -in -the -given -vector -. -fn -case_fold_simple -( -& -self -ranges -: -& -mut -Vec -< -ClassBytesRange -> -) -- -> -Result -< -( -) -unicode -: -: -CaseFoldError -> -{ -if -! -ClassBytesRange -: -: -new -( -b -' -a -' -b -' -z -' -) -. -is_intersection_empty -( -self -) -{ -let -lower -= -cmp -: -: -max -( -self -. -start -b -' -a -' -) -; -let -upper -= -cmp -: -: -min -( -self -. -end -b -' -z -' -) -; -ranges -. -push -( -ClassBytesRange -: -: -new -( -lower -- -32 -upper -- -32 -) -) -; -} -if -! -ClassBytesRange -: -: -new -( -b -' -A -' -b -' -Z -' -) -. -is_intersection_empty -( -self -) -{ -let -lower -= -cmp -: -: -max -( -self -. -start -b -' -A -' -) -; -let -upper -= -cmp -: -: -min -( -self -. -end -b -' -Z -' -) -; -ranges -. -push -( -ClassBytesRange -: -: -new -( -lower -+ -32 -upper -+ -32 -) -) -; -} -Ok -( -( -) -) -} -} -impl -ClassBytesRange -{ -/ -/ -/ -Create -a -new -byte -range -for -a -character -class -. -/ -/ -/ -/ -/ -/ -The -returned -range -is -always -in -a -canonical -form -. -That -is -the -range -/ -/ -/ -returned -always -satisfies -the -invariant -that -start -< -= -end -. -pub -fn -new -( -start -: -u8 -end -: -u8 -) -- -> -ClassBytesRange -{ -ClassBytesRange -: -: -create -( -start -end -) -} -/ -/ -/ -Return -the -start -of -this -range -. -/ -/ -/ -/ -/ -/ -The -start -of -a -range -is -always -less -than -or -equal -to -the -end -of -the -/ -/ -/ -range -. -pub -fn -start -( -& -self -) -- -> -u8 -{ -self -. -start -} -/ -/ -/ -Return -the -end -of -this -range -. -/ -/ -/ -/ -/ -/ -The -end -of -a -range -is -always -greater -than -or -equal -to -the -start -of -the -/ -/ -/ -range -. -pub -fn -end -( -& -self -) -- -> -u8 -{ -self -. -end -} -/ -/ -/ -Returns -the -number -of -bytes -in -this -range -. -pub -fn -len -( -& -self -) -- -> -usize -{ -usize -: -: -from -( -self -. -end -. -checked_sub -( -self -. -start -) -. -unwrap -( -) -) -. -checked_add -( -1 -) -. -unwrap -( -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -ClassBytesRange -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -ClassBytesRange -" -) -. -field -( -" -start -" -& -crate -: -: -debug -: -: -Byte -( -self -. -start -) -) -. -field -( -" -end -" -& -crate -: -: -debug -: -: -Byte -( -self -. -end -) -) -. -finish -( -) -} -} -/ -/ -/ -The -high -- -level -intermediate -representation -for -a -look -- -around -assertion -. -/ -/ -/ -/ -/ -/ -An -assertion -match -is -always -zero -- -length -. -Also -called -an -" -empty -match -. -" -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -Look -{ -/ -/ -/ -Match -the -beginning -of -text -. -Specifically -this -matches -at -the -starting -/ -/ -/ -position -of -the -input -. -Start -= -1 -< -< -0 -/ -/ -/ -Match -the -end -of -text -. -Specifically -this -matches -at -the -ending -/ -/ -/ -position -of -the -input -. -End -= -1 -< -< -1 -/ -/ -/ -Match -the -beginning -of -a -line -or -the -beginning -of -text -. -Specifically -/ -/ -/ -this -matches -at -the -starting -position -of -the -input -or -at -the -position -/ -/ -/ -immediately -following -a -\ -n -character -. -StartLF -= -1 -< -< -2 -/ -/ -/ -Match -the -end -of -a -line -or -the -end -of -text -. -Specifically -this -matches -/ -/ -/ -at -the -end -position -of -the -input -or -at -the -position -immediately -/ -/ -/ -preceding -a -\ -n -character -. -EndLF -= -1 -< -< -3 -/ -/ -/ -Match -the -beginning -of -a -line -or -the -beginning -of -text -. -Specifically -/ -/ -/ -this -matches -at -the -starting -position -of -the -input -or -at -the -position -/ -/ -/ -immediately -following -either -a -\ -r -or -\ -n -character -but -never -after -/ -/ -/ -a -\ -r -when -a -\ -n -follows -. -StartCRLF -= -1 -< -< -4 -/ -/ -/ -Match -the -end -of -a -line -or -the -end -of -text -. -Specifically -this -matches -/ -/ -/ -at -the -end -position -of -the -input -or -at -the -position -immediately -/ -/ -/ -preceding -a -\ -r -or -\ -n -character -but -never -before -a -\ -n -when -a -\ -r -/ -/ -/ -precedes -it -. -EndCRLF -= -1 -< -< -5 -/ -/ -/ -Match -an -ASCII -- -only -word -boundary -. -That -is -this -matches -a -position -/ -/ -/ -where -the -left -adjacent -character -and -right -adjacent -character -/ -/ -/ -correspond -to -a -word -and -non -- -word -or -a -non -- -word -and -word -character -. -WordAscii -= -1 -< -< -6 -/ -/ -/ -Match -an -ASCII -- -only -negation -of -a -word -boundary -. -WordAsciiNegate -= -1 -< -< -7 -/ -/ -/ -Match -a -Unicode -- -aware -word -boundary -. -That -is -this -matches -a -position -/ -/ -/ -where -the -left -adjacent -character -and -right -adjacent -character -/ -/ -/ -correspond -to -a -word -and -non -- -word -or -a -non -- -word -and -word -character -. -WordUnicode -= -1 -< -< -8 -/ -/ -/ -Match -a -Unicode -- -aware -negation -of -a -word -boundary -. -WordUnicodeNegate -= -1 -< -< -9 -} -impl -Look -{ -/ -/ -/ -Flip -the -look -- -around -assertion -to -its -equivalent -for -reverse -searches -. -/ -/ -/ -For -example -StartLF -gets -translated -to -EndLF -. -/ -/ -/ -/ -/ -/ -Some -assertions -such -as -WordUnicode -remain -the -same -since -they -/ -/ -/ -match -the -same -positions -regardless -of -the -direction -of -the -search -. -# -[ -inline -] -pub -const -fn -reversed -( -self -) -- -> -Look -{ -match -self -{ -Look -: -: -Start -= -> -Look -: -: -End -Look -: -: -End -= -> -Look -: -: -Start -Look -: -: -StartLF -= -> -Look -: -: -EndLF -Look -: -: -EndLF -= -> -Look -: -: -StartLF -Look -: -: -StartCRLF -= -> -Look -: -: -EndCRLF -Look -: -: -EndCRLF -= -> -Look -: -: -StartCRLF -Look -: -: -WordAscii -= -> -Look -: -: -WordAscii -Look -: -: -WordAsciiNegate -= -> -Look -: -: -WordAsciiNegate -Look -: -: -WordUnicode -= -> -Look -: -: -WordUnicode -Look -: -: -WordUnicodeNegate -= -> -Look -: -: -WordUnicodeNegate -} -} -/ -/ -/ -Return -the -underlying -representation -of -this -look -- -around -enumeration -/ -/ -/ -as -an -integer -. -Giving -the -return -value -to -the -[ -Look -: -: -from_repr -] -/ -/ -/ -constructor -is -guaranteed -to -return -the -same -look -- -around -variant -that -/ -/ -/ -one -started -with -within -a -semver -compatible -release -of -this -crate -. -# -[ -inline -] -pub -const -fn -as_repr -( -self -) -- -> -u16 -{ -/ -/ -AFAIK -' -as -' -is -the -only -way -to -zero -- -cost -convert -an -int -enum -to -an -/ -/ -actual -int -. -self -as -u16 -} -/ -/ -/ -Given -the -underlying -representation -of -a -Look -value -return -the -/ -/ -/ -corresponding -Look -value -if -the -representation -is -valid -. -Otherwise -/ -/ -/ -None -is -returned -. -# -[ -inline -] -pub -const -fn -from_repr -( -repr -: -u16 -) -- -> -Option -< -Look -> -{ -match -repr -{ -0b00_0000_0001 -= -> -Some -( -Look -: -: -Start -) -0b00_0000_0010 -= -> -Some -( -Look -: -: -End -) -0b00_0000_0100 -= -> -Some -( -Look -: -: -StartLF -) -0b00_0000_1000 -= -> -Some -( -Look -: -: -EndLF -) -0b00_0001_0000 -= -> -Some -( -Look -: -: -StartCRLF -) -0b00_0010_0000 -= -> -Some -( -Look -: -: -EndCRLF -) -0b00_0100_0000 -= -> -Some -( -Look -: -: -WordAscii -) -0b00_1000_0000 -= -> -Some -( -Look -: -: -WordAsciiNegate -) -0b01_0000_0000 -= -> -Some -( -Look -: -: -WordUnicode -) -0b10_0000_0000 -= -> -Some -( -Look -: -: -WordUnicodeNegate -) -_ -= -> -None -} -} -/ -/ -/ -Returns -a -convenient -single -codepoint -representation -of -this -/ -/ -/ -look -- -around -assertion -. -Each -assertion -is -guaranteed -to -be -represented -/ -/ -/ -by -a -distinct -character -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -succinctly -representing -a -look -- -around -assertion -in -/ -/ -/ -human -friendly -but -succinct -output -intended -for -a -programmer -working -on -/ -/ -/ -regex -internals -. -# -[ -inline -] -pub -const -fn -as_char -( -self -) -- -> -char -{ -match -self -{ -Look -: -: -Start -= -> -' -A -' -Look -: -: -End -= -> -' -z -' -Look -: -: -StartLF -= -> -' -^ -' -Look -: -: -EndLF -= -> -' -' -Look -: -: -StartCRLF -= -> -' -r -' -Look -: -: -EndCRLF -= -> -' -R -' -Look -: -: -WordAscii -= -> -' -b -' -Look -: -: -WordAsciiNegate -= -> -' -B -' -Look -: -: -WordUnicode -= -> -' -' -Look -: -: -WordUnicodeNegate -= -> -' -' -} -} -} -/ -/ -/ -The -high -- -level -intermediate -representation -for -a -capturing -group -. -/ -/ -/ -/ -/ -/ -A -capturing -group -always -has -an -index -and -a -child -expression -. -It -may -/ -/ -/ -also -have -a -name -associated -with -it -( -e -. -g -. -( -? -P -< -foo -> -\ -w -) -) -but -it -' -s -not -/ -/ -/ -necessary -. -/ -/ -/ -/ -/ -/ -Note -that -there -is -no -explicit -representation -of -a -non -- -capturing -group -/ -/ -/ -in -a -Hir -. -Instead -non -- -capturing -grouping -is -handled -automatically -by -/ -/ -/ -the -recursive -structure -of -the -Hir -itself -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -Capture -{ -/ -/ -/ -The -capture -index -of -the -capture -. -pub -index -: -u32 -/ -/ -/ -The -name -of -the -capture -if -it -exists -. -pub -name -: -Option -< -Box -< -str -> -> -/ -/ -/ -The -expression -inside -the -capturing -group -which -may -be -empty -. -pub -sub -: -Box -< -Hir -> -} -/ -/ -/ -The -high -- -level -intermediate -representation -of -a -repetition -operator -. -/ -/ -/ -/ -/ -/ -A -repetition -operator -permits -the -repetition -of -an -arbitrary -/ -/ -/ -sub -- -expression -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -Repetition -{ -/ -/ -/ -The -minimum -range -of -the -repetition -. -/ -/ -/ -/ -/ -/ -Note -that -special -cases -like -? -+ -and -* -all -get -translated -into -/ -/ -/ -the -ranges -{ -0 -1 -} -{ -1 -} -and -{ -0 -} -respectively -. -/ -/ -/ -/ -/ -/ -When -min -is -zero -this -expression -can -match -the -empty -string -/ -/ -/ -regardless -of -what -its -sub -- -expression -is -. -pub -min -: -u32 -/ -/ -/ -The -maximum -range -of -the -repetition -. -/ -/ -/ -/ -/ -/ -Note -that -when -max -is -None -min -acts -as -a -lower -bound -but -where -/ -/ -/ -there -is -no -upper -bound -. -For -something -like -x -{ -5 -} -where -the -min -and -/ -/ -/ -max -are -equivalent -min -will -be -set -to -5 -and -max -will -be -set -to -/ -/ -/ -Some -( -5 -) -. -pub -max -: -Option -< -u32 -> -/ -/ -/ -Whether -this -repetition -operator -is -greedy -or -not -. -A -greedy -operator -/ -/ -/ -will -match -as -much -as -it -can -. -A -non -- -greedy -operator -will -match -as -/ -/ -/ -little -as -it -can -. -/ -/ -/ -/ -/ -/ -Typically -operators -are -greedy -by -default -and -are -only -non -- -greedy -when -/ -/ -/ -a -? -suffix -is -used -e -. -g -. -( -expr -) -* -is -greedy -while -( -expr -) -* -? -is -/ -/ -/ -not -. -However -this -can -be -inverted -via -the -U -" -ungreedy -" -flag -. -pub -greedy -: -bool -/ -/ -/ -The -expression -being -repeated -. -pub -sub -: -Box -< -Hir -> -} -impl -Repetition -{ -/ -/ -/ -Returns -a -new -repetition -with -the -same -min -max -and -greedy -/ -/ -/ -values -but -with -its -sub -- -expression -replaced -with -the -one -given -. -pub -fn -with -( -& -self -sub -: -Hir -) -- -> -Repetition -{ -Repetition -{ -min -: -self -. -min -max -: -self -. -max -greedy -: -self -. -greedy -sub -: -Box -: -: -new -( -sub -) -} -} -} -/ -/ -/ -A -type -describing -the -different -flavors -of -. -. -/ -/ -/ -/ -/ -/ -This -type -is -meant -to -be -used -with -[ -Hir -: -: -dot -] -which -is -a -convenience -/ -/ -/ -routine -for -building -HIR -values -derived -from -the -. -regex -. -# -[ -non_exhaustive -] -# -[ -derive -( -Clone -Copy -Debug -Eq -PartialEq -) -] -pub -enum -Dot -{ -/ -/ -/ -Matches -the -UTF -- -8 -encoding -of -any -Unicode -scalar -value -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -( -? -su -: -. -) -and -also -\ -p -{ -any -} -. -AnyChar -/ -/ -/ -Matches -any -byte -value -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -( -? -s -- -u -: -. -) -and -also -( -? -- -u -: -[ -\ -x00 -- -\ -xFF -] -) -. -AnyByte -/ -/ -/ -Matches -the -UTF -- -8 -encoding -of -any -Unicode -scalar -value -except -for -the -/ -/ -/ -char -given -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -using -( -? -u -- -s -: -. -) -with -the -line -terminator -set -/ -/ -/ -to -a -particular -ASCII -byte -. -( -Because -of -peculiarities -in -the -regex -/ -/ -/ -engines -a -line -terminator -must -be -a -single -byte -. -It -follows -that -when -/ -/ -/ -UTF -- -8 -mode -is -enabled -this -single -byte -must -also -be -a -Unicode -scalar -/ -/ -/ -value -. -That -is -ti -must -be -ASCII -. -) -/ -/ -/ -/ -/ -/ -( -This -and -AnyCharExceptLF -both -exist -because -of -legacy -reasons -. -/ -/ -/ -AnyCharExceptLF -will -be -dropped -in -the -next -breaking -change -release -. -) -AnyCharExcept -( -char -) -/ -/ -/ -Matches -the -UTF -- -8 -encoding -of -any -Unicode -scalar -value -except -for -\ -n -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -( -? -u -- -s -: -. -) -and -also -[ -\ -p -{ -any -} -- -- -\ -n -] -. -AnyCharExceptLF -/ -/ -/ -Matches -the -UTF -- -8 -encoding -of -any -Unicode -scalar -value -except -for -\ -r -/ -/ -/ -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -( -? -uR -- -s -: -. -) -and -also -[ -\ -p -{ -any -} -- -- -\ -r -\ -n -] -. -AnyCharExceptCRLF -/ -/ -/ -Matches -any -byte -value -except -for -the -u8 -given -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -using -( -? -- -us -: -. -) -with -the -line -terminator -set -/ -/ -/ -to -a -particular -ASCII -byte -. -( -Because -of -peculiarities -in -the -regex -/ -/ -/ -engines -a -line -terminator -must -be -a -single -byte -. -It -follows -that -when -/ -/ -/ -UTF -- -8 -mode -is -enabled -this -single -byte -must -also -be -a -Unicode -scalar -/ -/ -/ -value -. -That -is -ti -must -be -ASCII -. -) -/ -/ -/ -/ -/ -/ -( -This -and -AnyByteExceptLF -both -exist -because -of -legacy -reasons -. -/ -/ -/ -AnyByteExceptLF -will -be -dropped -in -the -next -breaking -change -release -. -) -AnyByteExcept -( -u8 -) -/ -/ -/ -Matches -any -byte -value -except -for -\ -n -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -( -? -- -su -: -. -) -and -also -( -? -- -u -: -[ -[ -\ -x00 -- -\ -xFF -] -- -- -\ -n -] -) -. -AnyByteExceptLF -/ -/ -/ -Matches -any -byte -value -except -for -\ -r -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -( -? -R -- -su -: -. -) -and -also -( -? -- -u -: -[ -[ -\ -x00 -- -\ -xFF -] -- -- -\ -r -\ -n -] -) -. -AnyByteExceptCRLF -} -/ -/ -/ -A -custom -Drop -impl -is -used -for -HirKind -such -that -it -uses -constant -stack -/ -/ -/ -space -but -heap -space -proportional -to -the -depth -of -the -total -Hir -. -impl -Drop -for -Hir -{ -fn -drop -( -& -mut -self -) -{ -use -core -: -: -mem -; -match -* -self -. -kind -( -) -{ -HirKind -: -: -Empty -| -HirKind -: -: -Literal -( -_ -) -| -HirKind -: -: -Class -( -_ -) -| -HirKind -: -: -Look -( -_ -) -= -> -return -HirKind -: -: -Capture -( -ref -x -) -if -x -. -sub -. -kind -. -subs -( -) -. -is_empty -( -) -= -> -return -HirKind -: -: -Repetition -( -ref -x -) -if -x -. -sub -. -kind -. -subs -( -) -. -is_empty -( -) -= -> -{ -return -} -HirKind -: -: -Concat -( -ref -x -) -if -x -. -is_empty -( -) -= -> -return -HirKind -: -: -Alternation -( -ref -x -) -if -x -. -is_empty -( -) -= -> -return -_ -= -> -{ -} -} -let -mut -stack -= -vec -! -[ -mem -: -: -replace -( -self -Hir -: -: -empty -( -) -) -] -; -while -let -Some -( -mut -expr -) -= -stack -. -pop -( -) -{ -match -expr -. -kind -{ -HirKind -: -: -Empty -| -HirKind -: -: -Literal -( -_ -) -| -HirKind -: -: -Class -( -_ -) -| -HirKind -: -: -Look -( -_ -) -= -> -{ -} -HirKind -: -: -Capture -( -ref -mut -x -) -= -> -{ -stack -. -push -( -mem -: -: -replace -( -& -mut -x -. -sub -Hir -: -: -empty -( -) -) -) -; -} -HirKind -: -: -Repetition -( -ref -mut -x -) -= -> -{ -stack -. -push -( -mem -: -: -replace -( -& -mut -x -. -sub -Hir -: -: -empty -( -) -) -) -; -} -HirKind -: -: -Concat -( -ref -mut -x -) -= -> -{ -stack -. -extend -( -x -. -drain -( -. -. -) -) -; -} -HirKind -: -: -Alternation -( -ref -mut -x -) -= -> -{ -stack -. -extend -( -x -. -drain -( -. -. -) -) -; -} -} -} -} -} -/ -/ -/ -A -type -that -collects -various -properties -of -an -HIR -value -. -/ -/ -/ -/ -/ -/ -Properties -are -always -scalar -values -and -represent -meta -data -that -is -/ -/ -/ -computed -inductively -on -an -HIR -value -. -Properties -are -defined -for -all -/ -/ -/ -HIR -values -. -/ -/ -/ -/ -/ -/ -All -methods -on -a -Properties -value -take -constant -time -and -are -meant -to -/ -/ -/ -be -cheap -to -call -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -pub -struct -Properties -( -Box -< -PropertiesI -> -) -; -/ -/ -/ -The -property -definition -. -It -is -split -out -so -that -we -can -box -it -and -/ -/ -/ -there -by -make -Properties -use -less -stack -size -. -This -is -kind -- -of -important -/ -/ -/ -because -every -HIR -value -has -a -Properties -attached -to -it -. -/ -/ -/ -/ -/ -/ -This -does -have -the -unfortunate -consequence -that -creating -any -HIR -value -/ -/ -/ -always -leads -to -at -least -one -alloc -for -properties -but -this -is -generally -/ -/ -/ -true -anyway -( -for -pretty -much -all -HirKinds -except -for -look -- -arounds -) -. -# -[ -derive -( -Clone -Debug -Eq -PartialEq -) -] -struct -PropertiesI -{ -minimum_len -: -Option -< -usize -> -maximum_len -: -Option -< -usize -> -look_set -: -LookSet -look_set_prefix -: -LookSet -look_set_suffix -: -LookSet -look_set_prefix_any -: -LookSet -look_set_suffix_any -: -LookSet -utf8 -: -bool -explicit_captures_len -: -usize -static_explicit_captures_len -: -Option -< -usize -> -literal -: -bool -alternation_literal -: -bool -} -impl -Properties -{ -/ -/ -/ -Returns -the -length -( -in -bytes -) -of -the -smallest -string -matched -by -this -/ -/ -/ -HIR -. -/ -/ -/ -/ -/ -/ -A -return -value -of -0 -is -possible -and -occurs -when -the -HIR -can -match -an -/ -/ -/ -empty -string -. -/ -/ -/ -/ -/ -/ -None -is -returned -when -there -is -no -minimum -length -. -This -occurs -in -/ -/ -/ -precisely -the -cases -where -the -HIR -matches -nothing -. -i -. -e -. -The -language -/ -/ -/ -the -regex -matches -is -empty -. -An -example -of -such -a -regex -is -\ -P -{ -any -} -. -# -[ -inline -] -pub -fn -minimum_len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -0 -. -minimum_len -} -/ -/ -/ -Returns -the -length -( -in -bytes -) -of -the -longest -string -matched -by -this -/ -/ -/ -HIR -. -/ -/ -/ -/ -/ -/ -A -return -value -of -0 -is -possible -and -occurs -when -nothing -longer -than -/ -/ -/ -the -empty -string -is -in -the -language -described -by -this -HIR -. -/ -/ -/ -/ -/ -/ -None -is -returned -when -there -is -no -longest -matching -string -. -This -/ -/ -/ -occurs -when -the -HIR -matches -nothing -or -when -there -is -no -upper -bound -on -/ -/ -/ -the -length -of -matching -strings -. -Example -of -such -regexes -are -\ -P -{ -any -} -/ -/ -/ -( -matches -nothing -) -and -a -+ -( -has -no -upper -bound -) -. -# -[ -inline -] -pub -fn -maximum_len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -0 -. -maximum_len -} -/ -/ -/ -Returns -a -set -of -all -look -- -around -assertions -that -appear -at -least -once -/ -/ -/ -in -this -HIR -value -. -# -[ -inline -] -pub -fn -look_set -( -& -self -) -- -> -LookSet -{ -self -. -0 -. -look_set -} -/ -/ -/ -Returns -a -set -of -all -look -- -around -assertions -that -appear -as -a -prefix -for -/ -/ -/ -this -HIR -value -. -That -is -the -set -returned -corresponds -to -the -set -of -/ -/ -/ -assertions -that -must -be -passed -before -matching -any -bytes -in -a -haystack -. -/ -/ -/ -/ -/ -/ -For -example -hir -. -look_set_prefix -( -) -. -contains -( -Look -: -: -Start -) -returns -true -/ -/ -/ -if -and -only -if -the -HIR -is -fully -anchored -at -the -start -. -# -[ -inline -] -pub -fn -look_set_prefix -( -& -self -) -- -> -LookSet -{ -self -. -0 -. -look_set_prefix -} -/ -/ -/ -Returns -a -set -of -all -look -- -around -assertions -that -appear -as -a -_possible_ -/ -/ -/ -prefix -for -this -HIR -value -. -That -is -the -set -returned -corresponds -to -the -/ -/ -/ -set -of -assertions -that -_may_ -be -passed -before -matching -any -bytes -in -a -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -For -example -hir -. -look_set_prefix_any -( -) -. -contains -( -Look -: -: -Start -) -returns -/ -/ -/ -true -if -and -only -if -it -' -s -possible -for -the -regex -to -match -through -a -/ -/ -/ -anchored -assertion -before -consuming -any -input -. -# -[ -inline -] -pub -fn -look_set_prefix_any -( -& -self -) -- -> -LookSet -{ -self -. -0 -. -look_set_prefix_any -} -/ -/ -/ -Returns -a -set -of -all -look -- -around -assertions -that -appear -as -a -suffix -for -/ -/ -/ -this -HIR -value -. -That -is -the -set -returned -corresponds -to -the -set -of -/ -/ -/ -assertions -that -must -be -passed -in -order -to -be -considered -a -match -after -/ -/ -/ -all -other -consuming -HIR -expressions -. -/ -/ -/ -/ -/ -/ -For -example -hir -. -look_set_suffix -( -) -. -contains -( -Look -: -: -End -) -returns -true -/ -/ -/ -if -and -only -if -the -HIR -is -fully -anchored -at -the -end -. -# -[ -inline -] -pub -fn -look_set_suffix -( -& -self -) -- -> -LookSet -{ -self -. -0 -. -look_set_suffix -} -/ -/ -/ -Returns -a -set -of -all -look -- -around -assertions -that -appear -as -a -_possible_ -/ -/ -/ -suffix -for -this -HIR -value -. -That -is -the -set -returned -corresponds -to -the -/ -/ -/ -set -of -assertions -that -_may_ -be -passed -before -matching -any -bytes -in -a -/ -/ -/ -haystack -. -/ -/ -/ -/ -/ -/ -For -example -hir -. -look_set_suffix_any -( -) -. -contains -( -Look -: -: -End -) -returns -/ -/ -/ -true -if -and -only -if -it -' -s -possible -for -the -regex -to -match -through -a -/ -/ -/ -anchored -assertion -at -the -end -of -a -match -without -consuming -any -input -. -# -[ -inline -] -pub -fn -look_set_suffix_any -( -& -self -) -- -> -LookSet -{ -self -. -0 -. -look_set_suffix_any -} -/ -/ -/ -Return -true -if -and -only -if -the -corresponding -HIR -will -always -match -/ -/ -/ -valid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -When -this -returns -false -then -it -is -possible -for -this -HIR -expression -to -/ -/ -/ -match -invalid -UTF -- -8 -including -by -matching -between -the -code -units -of -/ -/ -/ -a -single -UTF -- -8 -encoded -codepoint -. -/ -/ -/ -/ -/ -/ -Note -that -this -returns -true -even -when -the -corresponding -HIR -can -match -/ -/ -/ -the -empty -string -. -Since -an -empty -string -can -technically -appear -between -/ -/ -/ -UTF -- -8 -code -units -it -is -possible -for -a -match -to -be -reported -that -splits -/ -/ -/ -a -codepoint -which -could -in -turn -be -considered -matching -invalid -UTF -- -8 -. -/ -/ -/ -However -it -is -generally -assumed -that -such -empty -matches -are -handled -/ -/ -/ -specially -by -the -search -routine -if -it -is -absolutely -required -that -/ -/ -/ -matches -not -split -a -codepoint -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -code -example -shows -the -UTF -- -8 -property -of -a -variety -of -patterns -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -ParserBuilder -parse -} -; -/ -/ -/ -/ -/ -/ -/ -/ -Examples -of -' -is_utf8 -( -) -= -= -true -' -. -/ -/ -/ -assert -! -( -parse -( -r -" -a -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -parse -( -r -" -[ -^ -a -] -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -parse -( -r -" -. -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -parse -( -r -" -\ -W -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -parse -( -r -" -\ -b -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -parse -( -r -" -\ -B -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -parse -( -r -" -( -? -- -u -) -\ -b -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -parse -( -r -" -( -? -- -u -) -\ -B -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -/ -/ -Unicode -mode -is -enabled -by -default -and -in -/ -/ -/ -/ -/ -that -mode -all -\ -x -hex -escapes -are -treated -as -/ -/ -/ -/ -/ -codepoints -. -So -this -actually -matches -the -UTF -- -8 -/ -/ -/ -/ -/ -encoding -of -U -+ -00FF -. -/ -/ -/ -assert -! -( -parse -( -r -" -\ -xFF -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Now -we -show -examples -of -' -is_utf8 -( -) -= -= -false -' -. -/ -/ -/ -/ -/ -The -only -way -to -do -this -is -to -force -the -parser -/ -/ -/ -/ -/ -to -permit -invalid -UTF -- -8 -otherwise -all -of -these -/ -/ -/ -/ -/ -would -fail -to -parse -! -/ -/ -/ -let -parse -= -| -pattern -| -{ -/ -/ -/ -ParserBuilder -: -: -new -( -) -. -utf8 -( -false -) -. -build -( -) -. -parse -( -pattern -) -/ -/ -/ -} -; -/ -/ -/ -assert -! -( -! -parse -( -r -" -( -? -- -u -) -[ -^ -a -] -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -! -parse -( -r -" -( -? -- -u -) -. -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -assert -! -( -! -parse -( -r -" -( -? -- -u -) -\ -W -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -/ -/ -Conversely -to -the -equivalent -example -above -/ -/ -/ -/ -/ -when -Unicode -mode -is -disabled -\ -x -hex -escapes -/ -/ -/ -/ -/ -are -treated -as -their -raw -byte -values -. -/ -/ -/ -assert -! -( -! -parse -( -r -" -( -? -- -u -) -\ -xFF -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -/ -/ -Note -that -just -because -we -disabled -UTF -- -8 -in -the -/ -/ -/ -/ -/ -parser -doesn -' -t -mean -we -still -can -' -t -use -Unicode -. -/ -/ -/ -/ -/ -It -is -enabled -by -default -so -\ -xFF -is -still -/ -/ -/ -/ -/ -equivalent -to -matching -the -UTF -- -8 -encoding -of -/ -/ -/ -/ -/ -U -+ -00FF -by -default -. -/ -/ -/ -assert -! -( -parse -( -r -" -\ -xFF -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -/ -/ -Even -though -we -use -raw -bytes -that -individually -/ -/ -/ -/ -/ -are -not -valid -UTF -- -8 -when -combined -together -the -/ -/ -/ -/ -/ -overall -expression -* -does -* -match -valid -UTF -- -8 -! -/ -/ -/ -assert -! -( -parse -( -r -" -( -? -- -u -) -\ -xE2 -\ -x98 -\ -x83 -" -) -? -. -properties -( -) -. -is_utf8 -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -is_utf8 -( -& -self -) -- -> -bool -{ -self -. -0 -. -utf8 -} -/ -/ -/ -Returns -the -total -number -of -explicit -capturing -groups -in -the -/ -/ -/ -corresponding -HIR -. -/ -/ -/ -/ -/ -/ -Note -that -this -does -not -include -the -implicit -capturing -group -/ -/ -/ -corresponding -to -the -entire -match -that -is -typically -included -by -regex -/ -/ -/ -engines -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -method -will -return -0 -for -a -and -1 -for -( -a -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -parse -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -0 -parse -( -" -a -" -) -? -. -properties -( -) -. -explicit_captures_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -1 -parse -( -" -( -a -) -" -) -? -. -properties -( -) -. -explicit_captures_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -explicit_captures_len -( -& -self -) -- -> -usize -{ -self -. -0 -. -explicit_captures_len -} -/ -/ -/ -Returns -the -total -number -of -explicit -capturing -groups -that -appear -in -/ -/ -/ -every -possible -match -. -/ -/ -/ -/ -/ -/ -If -the -number -of -capture -groups -can -vary -depending -on -the -match -then -/ -/ -/ -this -returns -None -. -That -is -a -value -is -only -returned -when -the -number -/ -/ -/ -of -matching -groups -is -invariant -or -" -static -. -" -/ -/ -/ -/ -/ -/ -Note -that -this -does -not -include -the -implicit -capturing -group -/ -/ -/ -corresponding -to -the -entire -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -few -cases -where -a -static -number -of -capture -groups -is -/ -/ -/ -available -and -a -few -cases -where -it -is -not -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -parse -; -/ -/ -/ -/ -/ -/ -let -len -= -| -pattern -| -{ -/ -/ -/ -parse -( -pattern -) -. -map -( -| -h -| -{ -/ -/ -/ -h -. -properties -( -) -. -static_explicit_captures_len -( -) -/ -/ -/ -} -) -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -0 -) -len -( -" -a -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -len -( -" -( -a -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -len -( -" -( -a -) -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -a -) -( -b -) -| -( -c -) -( -d -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -( -a -) -| -b -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -a -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -( -b -) -* -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -len -( -" -( -b -) -+ -" -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -static_explicit_captures_len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -0 -. -static_explicit_captures_len -} -/ -/ -/ -Return -true -if -and -only -if -this -HIR -is -a -simple -literal -. -This -is -/ -/ -/ -only -true -when -this -HIR -expression -is -either -itself -a -Literal -or -a -/ -/ -/ -concatenation -of -only -Literal -s -. -/ -/ -/ -/ -/ -/ -For -example -f -and -foo -are -literals -but -f -+ -( -foo -) -foo -( -) -and -/ -/ -/ -the -empty -string -are -not -( -even -though -they -contain -sub -- -expressions -that -/ -/ -/ -are -literals -) -. -# -[ -inline -] -pub -fn -is_literal -( -& -self -) -- -> -bool -{ -self -. -0 -. -literal -} -/ -/ -/ -Return -true -if -and -only -if -this -HIR -is -either -a -simple -literal -or -an -/ -/ -/ -alternation -of -simple -literals -. -This -is -only -/ -/ -/ -true -when -this -HIR -expression -is -either -itself -a -Literal -or -a -/ -/ -/ -concatenation -of -only -Literal -s -or -an -alternation -of -only -Literal -s -. -/ -/ -/ -/ -/ -/ -For -example -f -foo -a -| -b -| -c -and -foo -| -bar -| -baz -are -alternation -/ -/ -/ -literals -but -f -+ -( -foo -) -foo -( -) -and -the -empty -pattern -are -not -/ -/ -/ -( -even -though -that -contain -sub -- -expressions -that -are -literals -) -. -# -[ -inline -] -pub -fn -is_alternation_literal -( -& -self -) -- -> -bool -{ -self -. -0 -. -alternation_literal -} -/ -/ -/ -Returns -the -total -amount -of -heap -memory -usage -in -bytes -used -by -this -/ -/ -/ -Properties -value -. -# -[ -inline -] -pub -fn -memory_usage -( -& -self -) -- -> -usize -{ -core -: -: -mem -: -: -size_of -: -: -< -PropertiesI -> -( -) -} -/ -/ -/ -Returns -a -new -set -of -properties -that -corresponds -to -the -union -of -the -/ -/ -/ -iterator -of -properties -given -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -one -has -multiple -Hir -expressions -and -wants -/ -/ -/ -to -combine -them -into -a -single -alternation -without -constructing -the -/ -/ -/ -corresponding -Hir -. -This -routine -provides -a -way -of -combining -the -/ -/ -/ -properties -of -each -Hir -expression -into -one -set -of -properties -/ -/ -/ -representing -the -union -of -those -expressions -. -/ -/ -/ -/ -/ -/ -# -Example -: -union -with -HIRs -that -never -match -/ -/ -/ -/ -/ -/ -This -example -shows -that -unioning -properties -together -with -one -that -/ -/ -/ -represents -a -regex -that -never -matches -will -" -poison -" -certain -attributes -/ -/ -/ -like -the -minimum -and -maximum -lengths -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -hir -: -: -Properties -parse -} -; -/ -/ -/ -/ -/ -/ -let -hir1 -= -parse -( -" -ab -? -c -? -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -hir1 -. -properties -( -) -. -minimum_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -hir1 -. -properties -( -) -. -maximum_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -hir2 -= -parse -( -r -" -[ -a -& -& -b -] -" -) -? -; -/ -/ -/ -assert_eq -! -( -None -hir2 -. -properties -( -) -. -minimum_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -hir2 -. -properties -( -) -. -maximum_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -hir3 -= -parse -( -r -" -wxy -? -z -? -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -hir3 -. -properties -( -) -. -minimum_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -4 -) -hir3 -. -properties -( -) -. -maximum_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -unioned -= -Properties -: -: -union -( -[ -/ -/ -/ -hir1 -. -properties -( -) -/ -/ -/ -hir2 -. -properties -( -) -/ -/ -/ -hir3 -. -properties -( -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -None -unioned -. -minimum_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -unioned -. -maximum_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -The -maximum -length -can -also -be -" -poisoned -" -by -a -pattern -that -has -no -/ -/ -/ -upper -bound -on -the -length -of -a -match -. -The -minimum -length -remains -/ -/ -/ -unaffected -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -{ -hir -: -: -Properties -parse -} -; -/ -/ -/ -/ -/ -/ -let -hir1 -= -parse -( -" -ab -? -c -? -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -hir1 -. -properties -( -) -. -minimum_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -hir1 -. -properties -( -) -. -maximum_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -hir2 -= -parse -( -r -" -a -+ -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -hir2 -. -properties -( -) -. -minimum_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -hir2 -. -properties -( -) -. -maximum_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -hir3 -= -parse -( -r -" -wxy -? -z -? -" -) -? -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -hir3 -. -properties -( -) -. -minimum_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -4 -) -hir3 -. -properties -( -) -. -maximum_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -unioned -= -Properties -: -: -union -( -[ -/ -/ -/ -hir1 -. -properties -( -) -/ -/ -/ -hir2 -. -properties -( -) -/ -/ -/ -hir3 -. -properties -( -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -unioned -. -minimum_len -( -) -) -; -/ -/ -/ -assert_eq -! -( -None -unioned -. -maximum_len -( -) -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -pub -fn -union -< -I -P -> -( -props -: -I -) -- -> -Properties -where -I -: -IntoIterator -< -Item -= -P -> -P -: -core -: -: -borrow -: -: -Borrow -< -Properties -> -{ -let -mut -it -= -props -. -into_iter -( -) -. -peekable -( -) -; -/ -/ -While -empty -alternations -aren -' -t -possible -we -still -behave -as -if -they -/ -/ -are -. -When -we -have -an -empty -alternate -then -clearly -the -look -- -around -/ -/ -prefix -and -suffix -is -empty -. -Otherwise -it -is -the -intersection -of -all -/ -/ -prefixes -and -suffixes -( -respectively -) -of -the -branches -. -let -fix -= -if -it -. -peek -( -) -. -is_none -( -) -{ -LookSet -: -: -empty -( -) -} -else -{ -LookSet -: -: -full -( -) -} -; -/ -/ -And -also -an -empty -alternate -means -we -have -0 -static -capture -groups -/ -/ -but -we -otherwise -start -with -the -number -corresponding -to -the -first -/ -/ -alternate -. -If -any -subsequent -alternate -has -a -different -number -of -/ -/ -static -capture -groups -then -we -overall -have -a -variation -and -not -a -/ -/ -static -number -of -groups -. -let -static_explicit_captures_len -= -it -. -peek -( -) -. -and_then -( -| -p -| -p -. -borrow -( -) -. -static_explicit_captures_len -( -) -) -; -/ -/ -The -base -case -is -an -empty -alternation -which -matches -nothing -. -/ -/ -Note -though -that -empty -alternations -aren -' -t -possible -because -the -/ -/ -Hir -: -: -alternation -smart -constructor -rewrites -those -as -empty -character -/ -/ -classes -. -let -mut -props -= -PropertiesI -{ -minimum_len -: -None -maximum_len -: -None -look_set -: -LookSet -: -: -empty -( -) -look_set_prefix -: -fix -look_set_suffix -: -fix -look_set_prefix_any -: -LookSet -: -: -empty -( -) -look_set_suffix_any -: -LookSet -: -: -empty -( -) -utf8 -: -true -explicit_captures_len -: -0 -static_explicit_captures_len -literal -: -false -alternation_literal -: -true -} -; -let -( -mut -min_poisoned -mut -max_poisoned -) -= -( -false -false -) -; -/ -/ -Handle -properties -that -need -to -visit -every -child -hir -. -for -prop -in -it -{ -let -p -= -prop -. -borrow -( -) -; -props -. -look_set -. -set_union -( -p -. -look_set -( -) -) -; -props -. -look_set_prefix -. -set_intersect -( -p -. -look_set_prefix -( -) -) -; -props -. -look_set_suffix -. -set_intersect -( -p -. -look_set_suffix -( -) -) -; -props -. -look_set_prefix_any -. -set_union -( -p -. -look_set_prefix_any -( -) -) -; -props -. -look_set_suffix_any -. -set_union -( -p -. -look_set_suffix_any -( -) -) -; -props -. -utf8 -= -props -. -utf8 -& -& -p -. -is_utf8 -( -) -; -props -. -explicit_captures_len -= -props -. -explicit_captures_len -. -saturating_add -( -p -. -explicit_captures_len -( -) -) -; -if -props -. -static_explicit_captures_len -! -= -p -. -static_explicit_captures_len -( -) -{ -props -. -static_explicit_captures_len -= -None -; -} -props -. -alternation_literal -= -props -. -alternation_literal -& -& -p -. -is_literal -( -) -; -if -! -min_poisoned -{ -if -let -Some -( -xmin -) -= -p -. -minimum_len -( -) -{ -if -props -. -minimum_len -. -map_or -( -true -| -pmin -| -xmin -< -pmin -) -{ -props -. -minimum_len -= -Some -( -xmin -) -; -} -} -else -{ -props -. -minimum_len -= -None -; -min_poisoned -= -true -; -} -} -if -! -max_poisoned -{ -if -let -Some -( -xmax -) -= -p -. -maximum_len -( -) -{ -if -props -. -maximum_len -. -map_or -( -true -| -pmax -| -xmax -> -pmax -) -{ -props -. -maximum_len -= -Some -( -xmax -) -; -} -} -else -{ -props -. -maximum_len -= -None -; -max_poisoned -= -true -; -} -} -} -Properties -( -Box -: -: -new -( -props -) -) -} -} -impl -Properties -{ -/ -/ -/ -Create -a -new -set -of -HIR -properties -for -an -empty -regex -. -fn -empty -( -) -- -> -Properties -{ -let -inner -= -PropertiesI -{ -minimum_len -: -Some -( -0 -) -maximum_len -: -Some -( -0 -) -look_set -: -LookSet -: -: -empty -( -) -look_set_prefix -: -LookSet -: -: -empty -( -) -look_set_suffix -: -LookSet -: -: -empty -( -) -look_set_prefix_any -: -LookSet -: -: -empty -( -) -look_set_suffix_any -: -LookSet -: -: -empty -( -) -/ -/ -It -is -debatable -whether -an -empty -regex -always -matches -at -valid -/ -/ -UTF -- -8 -boundaries -. -Strictly -speaking -at -a -byte -oriented -view -/ -/ -it -is -clearly -false -. -There -are -for -example -many -empty -strings -/ -/ -between -the -bytes -encoding -a -' -' -. -/ -/ -/ -/ -However -when -Unicode -mode -is -enabled -the -fundamental -atom -/ -/ -of -matching -is -really -a -codepoint -. -And -in -that -scenario -an -/ -/ -empty -regex -is -defined -to -only -match -at -valid -UTF -- -8 -boundaries -/ -/ -and -to -never -split -a -codepoint -. -It -just -so -happens -that -this -/ -/ -enforcement -is -somewhat -tricky -to -do -for -regexes -that -match -/ -/ -the -empty -string -inside -regex -engines -themselves -. -It -usually -/ -/ -requires -some -layer -above -the -regex -engine -to -filter -out -such -/ -/ -matches -. -/ -/ -/ -/ -In -any -case -' -true -' -is -really -the -only -coherent -option -. -If -it -/ -/ -were -false -for -example -then -' -a -* -' -would -also -need -to -be -false -/ -/ -since -it -too -can -match -the -empty -string -. -utf8 -: -true -explicit_captures_len -: -0 -static_explicit_captures_len -: -Some -( -0 -) -literal -: -false -alternation_literal -: -false -} -; -Properties -( -Box -: -: -new -( -inner -) -) -} -/ -/ -/ -Create -a -new -set -of -HIR -properties -for -a -literal -regex -. -fn -literal -( -lit -: -& -Literal -) -- -> -Properties -{ -let -inner -= -PropertiesI -{ -minimum_len -: -Some -( -lit -. -0 -. -len -( -) -) -maximum_len -: -Some -( -lit -. -0 -. -len -( -) -) -look_set -: -LookSet -: -: -empty -( -) -look_set_prefix -: -LookSet -: -: -empty -( -) -look_set_suffix -: -LookSet -: -: -empty -( -) -look_set_prefix_any -: -LookSet -: -: -empty -( -) -look_set_suffix_any -: -LookSet -: -: -empty -( -) -utf8 -: -core -: -: -str -: -: -from_utf8 -( -& -lit -. -0 -) -. -is_ok -( -) -explicit_captures_len -: -0 -static_explicit_captures_len -: -Some -( -0 -) -literal -: -true -alternation_literal -: -true -} -; -Properties -( -Box -: -: -new -( -inner -) -) -} -/ -/ -/ -Create -a -new -set -of -HIR -properties -for -a -character -class -. -fn -class -( -class -: -& -Class -) -- -> -Properties -{ -let -inner -= -PropertiesI -{ -minimum_len -: -class -. -minimum_len -( -) -maximum_len -: -class -. -maximum_len -( -) -look_set -: -LookSet -: -: -empty -( -) -look_set_prefix -: -LookSet -: -: -empty -( -) -look_set_suffix -: -LookSet -: -: -empty -( -) -look_set_prefix_any -: -LookSet -: -: -empty -( -) -look_set_suffix_any -: -LookSet -: -: -empty -( -) -utf8 -: -class -. -is_utf8 -( -) -explicit_captures_len -: -0 -static_explicit_captures_len -: -Some -( -0 -) -literal -: -false -alternation_literal -: -false -} -; -Properties -( -Box -: -: -new -( -inner -) -) -} -/ -/ -/ -Create -a -new -set -of -HIR -properties -for -a -look -- -around -assertion -. -fn -look -( -look -: -Look -) -- -> -Properties -{ -let -inner -= -PropertiesI -{ -minimum_len -: -Some -( -0 -) -maximum_len -: -Some -( -0 -) -look_set -: -LookSet -: -: -singleton -( -look -) -look_set_prefix -: -LookSet -: -: -singleton -( -look -) -look_set_suffix -: -LookSet -: -: -singleton -( -look -) -look_set_prefix_any -: -LookSet -: -: -singleton -( -look -) -look_set_suffix_any -: -LookSet -: -: -singleton -( -look -) -/ -/ -This -requires -a -little -explanation -. -Basically -we -don -' -t -consider -/ -/ -matching -an -empty -string -to -be -equivalent -to -matching -invalid -/ -/ -UTF -- -8 -even -though -technically -matching -every -empty -string -will -/ -/ -split -the -UTF -- -8 -encoding -of -a -single -codepoint -when -treating -a -/ -/ -UTF -- -8 -encoded -string -as -a -sequence -of -bytes -. -Our -defense -here -is -/ -/ -that -in -such -a -case -a -codepoint -should -logically -be -treated -as -/ -/ -the -fundamental -atom -for -matching -and -thus -the -only -valid -match -/ -/ -points -are -between -codepoints -and -not -bytes -. -/ -/ -/ -/ -More -practically -this -is -true -here -because -it -' -s -also -true -/ -/ -for -' -Hir -: -: -empty -( -) -' -otherwise -something -like -' -a -* -' -would -be -/ -/ -considered -to -match -invalid -UTF -- -8 -. -That -in -turn -makes -this -/ -/ -property -borderline -useless -. -utf8 -: -true -explicit_captures_len -: -0 -static_explicit_captures_len -: -Some -( -0 -) -literal -: -false -alternation_literal -: -false -} -; -Properties -( -Box -: -: -new -( -inner -) -) -} -/ -/ -/ -Create -a -new -set -of -HIR -properties -for -a -repetition -. -fn -repetition -( -rep -: -& -Repetition -) -- -> -Properties -{ -let -p -= -rep -. -sub -. -properties -( -) -; -let -minimum_len -= -p -. -minimum_len -( -) -. -map -( -| -child_min -| -{ -let -rep_min -= -usize -: -: -try_from -( -rep -. -min -) -. -unwrap_or -( -usize -: -: -MAX -) -; -child_min -. -saturating_mul -( -rep_min -) -} -) -; -let -maximum_len -= -rep -. -max -. -and_then -( -| -rep_max -| -{ -let -rep_max -= -usize -: -: -try_from -( -rep_max -) -. -ok -( -) -? -; -let -child_max -= -p -. -maximum_len -( -) -? -; -child_max -. -checked_mul -( -rep_max -) -} -) -; -let -mut -inner -= -PropertiesI -{ -minimum_len -maximum_len -look_set -: -p -. -look_set -( -) -look_set_prefix -: -LookSet -: -: -empty -( -) -look_set_suffix -: -LookSet -: -: -empty -( -) -look_set_prefix_any -: -p -. -look_set_prefix_any -( -) -look_set_suffix_any -: -p -. -look_set_suffix_any -( -) -utf8 -: -p -. -is_utf8 -( -) -explicit_captures_len -: -p -. -explicit_captures_len -( -) -static_explicit_captures_len -: -p -. -static_explicit_captures_len -( -) -literal -: -false -alternation_literal -: -false -} -; -/ -/ -If -the -repetition -operator -can -match -the -empty -string -then -its -/ -/ -lookset -prefix -and -suffixes -themselves -remain -empty -since -they -are -/ -/ -no -longer -required -to -match -. -if -rep -. -min -> -0 -{ -inner -. -look_set_prefix -= -p -. -look_set_prefix -( -) -; -inner -. -look_set_suffix -= -p -. -look_set_suffix -( -) -; -} -/ -/ -If -the -static -captures -len -of -the -sub -- -expression -is -not -known -or -/ -/ -is -greater -than -zero -then -it -automatically -propagates -to -the -/ -/ -repetition -regardless -of -the -repetition -. -Otherwise -it -might -/ -/ -change -but -only -when -the -repetition -can -match -0 -times -. -if -rep -. -min -= -= -0 -& -& -inner -. -static_explicit_captures_len -. -map_or -( -false -| -len -| -len -> -0 -) -{ -/ -/ -If -we -require -a -match -0 -times -then -our -captures -len -is -/ -/ -guaranteed -to -be -zero -. -Otherwise -if -we -* -can -* -match -the -empty -/ -/ -string -then -it -' -s -impossible -to -know -how -many -captures -will -be -/ -/ -in -the -resulting -match -. -if -rep -. -max -= -= -Some -( -0 -) -{ -inner -. -static_explicit_captures_len -= -Some -( -0 -) -; -} -else -{ -inner -. -static_explicit_captures_len -= -None -; -} -} -Properties -( -Box -: -: -new -( -inner -) -) -} -/ -/ -/ -Create -a -new -set -of -HIR -properties -for -a -capture -. -fn -capture -( -capture -: -& -Capture -) -- -> -Properties -{ -let -p -= -capture -. -sub -. -properties -( -) -; -Properties -( -Box -: -: -new -( -PropertiesI -{ -explicit_captures_len -: -p -. -explicit_captures_len -( -) -. -saturating_add -( -1 -) -static_explicit_captures_len -: -p -. -static_explicit_captures_len -( -) -. -map -( -| -len -| -len -. -saturating_add -( -1 -) -) -literal -: -false -alternation_literal -: -false -. -. -* -p -. -0 -. -clone -( -) -} -) -) -} -/ -/ -/ -Create -a -new -set -of -HIR -properties -for -a -concatenation -. -fn -concat -( -concat -: -& -[ -Hir -] -) -- -> -Properties -{ -/ -/ -The -base -case -is -an -empty -concatenation -which -matches -the -empty -/ -/ -string -. -Note -though -that -empty -concatenations -aren -' -t -possible -/ -/ -because -the -Hir -: -: -concat -smart -constructor -rewrites -those -as -/ -/ -Hir -: -: -empty -. -let -mut -props -= -PropertiesI -{ -minimum_len -: -Some -( -0 -) -maximum_len -: -Some -( -0 -) -look_set -: -LookSet -: -: -empty -( -) -look_set_prefix -: -LookSet -: -: -empty -( -) -look_set_suffix -: -LookSet -: -: -empty -( -) -look_set_prefix_any -: -LookSet -: -: -empty -( -) -look_set_suffix_any -: -LookSet -: -: -empty -( -) -utf8 -: -true -explicit_captures_len -: -0 -static_explicit_captures_len -: -Some -( -0 -) -literal -: -true -alternation_literal -: -true -} -; -/ -/ -Handle -properties -that -need -to -visit -every -child -hir -. -for -x -in -concat -. -iter -( -) -{ -let -p -= -x -. -properties -( -) -; -props -. -look_set -. -set_union -( -p -. -look_set -( -) -) -; -props -. -utf8 -= -props -. -utf8 -& -& -p -. -is_utf8 -( -) -; -props -. -explicit_captures_len -= -props -. -explicit_captures_len -. -saturating_add -( -p -. -explicit_captures_len -( -) -) -; -props -. -static_explicit_captures_len -= -p -. -static_explicit_captures_len -( -) -. -and_then -( -| -len1 -| -{ -Some -( -( -len1 -props -. -static_explicit_captures_len -? -) -) -} -) -. -and_then -( -| -( -len1 -len2 -) -| -Some -( -len1 -. -saturating_add -( -len2 -) -) -) -; -props -. -literal -= -props -. -literal -& -& -p -. -is_literal -( -) -; -props -. -alternation_literal -= -props -. -alternation_literal -& -& -p -. -is_alternation_literal -( -) -; -if -let -Some -( -minimum_len -) -= -props -. -minimum_len -{ -match -p -. -minimum_len -( -) -{ -None -= -> -props -. -minimum_len -= -None -Some -( -len -) -= -> -{ -/ -/ -We -use -saturating -arithmetic -here -because -the -/ -/ -minimum -is -just -a -lower -bound -. -We -can -' -t -go -any -/ -/ -higher -than -what -our -number -types -permit -. -props -. -minimum_len -= -Some -( -minimum_len -. -saturating_add -( -len -) -) -; -} -} -} -if -let -Some -( -maximum_len -) -= -props -. -maximum_len -{ -match -p -. -maximum_len -( -) -{ -None -= -> -props -. -maximum_len -= -None -Some -( -len -) -= -> -{ -props -. -maximum_len -= -maximum_len -. -checked_add -( -len -) -} -} -} -} -/ -/ -Handle -the -prefix -properties -which -only -requires -visiting -/ -/ -child -exprs -until -one -matches -more -than -the -empty -string -. -let -mut -it -= -concat -. -iter -( -) -; -while -let -Some -( -x -) -= -it -. -next -( -) -{ -props -. -look_set_prefix -. -set_union -( -x -. -properties -( -) -. -look_set_prefix -( -) -) -; -props -. -look_set_prefix_any -. -set_union -( -x -. -properties -( -) -. -look_set_prefix_any -( -) -) -; -if -x -. -properties -( -) -. -maximum_len -( -) -. -map_or -( -true -| -x -| -x -> -0 -) -{ -break -; -} -} -/ -/ -Same -thing -for -the -suffix -properties -but -in -reverse -. -let -mut -it -= -concat -. -iter -( -) -. -rev -( -) -; -while -let -Some -( -x -) -= -it -. -next -( -) -{ -props -. -look_set_suffix -. -set_union -( -x -. -properties -( -) -. -look_set_suffix -( -) -) -; -props -. -look_set_suffix_any -. -set_union -( -x -. -properties -( -) -. -look_set_suffix_any -( -) -) -; -if -x -. -properties -( -) -. -maximum_len -( -) -. -map_or -( -true -| -x -| -x -> -0 -) -{ -break -; -} -} -Properties -( -Box -: -: -new -( -props -) -) -} -/ -/ -/ -Create -a -new -set -of -HIR -properties -for -a -concatenation -. -fn -alternation -( -alts -: -& -[ -Hir -] -) -- -> -Properties -{ -Properties -: -: -union -( -alts -. -iter -( -) -. -map -( -| -hir -| -hir -. -properties -( -) -) -) -} -} -/ -/ -/ -A -set -of -look -- -around -assertions -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -efficiently -tracking -look -- -around -assertions -. -For -/ -/ -/ -example -an -[ -Hir -] -provides -properties -that -return -LookSet -s -. -# -[ -derive -( -Clone -Copy -Default -Eq -PartialEq -) -] -pub -struct -LookSet -{ -/ -/ -/ -The -underlying -representation -this -set -is -exposed -to -make -it -possible -/ -/ -/ -to -store -it -somewhere -efficiently -. -The -representation -is -that -/ -/ -/ -of -a -bitset -where -each -assertion -occupies -bit -i -where -i -= -/ -/ -/ -Look -: -: -as_repr -( -) -. -/ -/ -/ -/ -/ -/ -Note -that -users -of -this -internal -representation -must -permit -the -full -/ -/ -/ -range -of -u16 -values -to -be -represented -. -For -example -even -if -the -/ -/ -/ -current -implementation -only -makes -use -of -the -10 -least -significant -bits -/ -/ -/ -it -may -use -more -bits -in -a -future -semver -compatible -release -. -pub -bits -: -u16 -} -impl -LookSet -{ -/ -/ -/ -Create -an -empty -set -of -look -- -around -assertions -. -# -[ -inline -] -pub -fn -empty -( -) -- -> -LookSet -{ -LookSet -{ -bits -: -0 -} -} -/ -/ -/ -Create -a -full -set -of -look -- -around -assertions -. -/ -/ -/ -/ -/ -/ -This -set -contains -all -possible -look -- -around -assertions -. -# -[ -inline -] -pub -fn -full -( -) -- -> -LookSet -{ -LookSet -{ -bits -: -! -0 -} -} -/ -/ -/ -Create -a -look -- -around -set -containing -the -look -- -around -assertion -given -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -routine -for -creating -an -empty -set -and -inserting -/ -/ -/ -one -look -- -around -assertions -. -# -[ -inline -] -pub -fn -singleton -( -look -: -Look -) -- -> -LookSet -{ -LookSet -: -: -empty -( -) -. -insert -( -look -) -} -/ -/ -/ -Returns -the -total -number -of -look -- -around -assertions -in -this -set -. -# -[ -inline -] -pub -fn -len -( -self -) -- -> -usize -{ -/ -/ -OK -because -max -value -always -fits -in -a -u8 -which -in -turn -always -/ -/ -fits -in -a -usize -regardless -of -target -. -usize -: -: -try_from -( -self -. -bits -. -count_ones -( -) -) -. -unwrap -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -is -empty -. -# -[ -inline -] -pub -fn -is_empty -( -self -) -- -> -bool -{ -self -. -len -( -) -= -= -0 -} -/ -/ -/ -Returns -true -if -and -only -if -the -given -look -- -around -assertion -is -in -this -/ -/ -/ -set -. -# -[ -inline -] -pub -fn -contains -( -self -look -: -Look -) -- -> -bool -{ -self -. -bits -& -look -. -as_repr -( -) -! -= -0 -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -anchor -assertions -. -/ -/ -/ -This -includes -both -" -start -/ -end -of -haystack -" -and -" -start -/ -end -of -line -. -" -# -[ -inline -] -pub -fn -contains_anchor -( -& -self -) -- -> -bool -{ -self -. -contains_anchor_haystack -( -) -| -| -self -. -contains_anchor_line -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -" -start -/ -end -of -/ -/ -/ -haystack -" -anchors -. -This -doesn -' -t -include -" -start -/ -end -of -line -" -anchors -. -# -[ -inline -] -pub -fn -contains_anchor_haystack -( -& -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -Start -) -| -| -self -. -contains -( -Look -: -: -End -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -" -start -/ -end -of -line -" -/ -/ -/ -anchors -. -This -doesn -' -t -include -" -start -/ -end -of -haystack -" -anchors -. -This -/ -/ -/ -includes -both -\ -n -line -anchors -and -CRLF -( -\ -r -\ -n -) -aware -line -anchors -. -# -[ -inline -] -pub -fn -contains_anchor_line -( -& -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -StartLF -) -| -| -self -. -contains -( -Look -: -: -EndLF -) -| -| -self -. -contains -( -Look -: -: -StartCRLF -) -| -| -self -. -contains -( -Look -: -: -EndCRLF -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -" -start -/ -end -of -line -" -/ -/ -/ -anchors -that -only -treat -\ -n -as -line -terminators -. -This -does -not -include -/ -/ -/ -haystack -anchors -or -CRLF -aware -line -anchors -. -# -[ -inline -] -pub -fn -contains_anchor_lf -( -& -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -StartLF -) -| -| -self -. -contains -( -Look -: -: -EndLF -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -" -start -/ -end -of -line -" -/ -/ -/ -anchors -that -are -CRLF -- -aware -. -This -doesn -' -t -include -" -start -/ -end -of -/ -/ -/ -haystack -" -or -" -start -/ -end -of -line -- -feed -" -anchors -. -# -[ -inline -] -pub -fn -contains_anchor_crlf -( -& -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -StartCRLF -) -| -| -self -. -contains -( -Look -: -: -EndCRLF -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -word -boundary -or -/ -/ -/ -negated -word -boundary -assertions -. -This -include -both -Unicode -and -ASCII -/ -/ -/ -word -boundaries -. -# -[ -inline -] -pub -fn -contains_word -( -self -) -- -> -bool -{ -self -. -contains_word_unicode -( -) -| -| -self -. -contains_word_ascii -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -Unicode -word -boundary -/ -/ -/ -or -negated -Unicode -word -boundary -assertions -. -# -[ -inline -] -pub -fn -contains_word_unicode -( -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -WordUnicode -) -| -| -self -. -contains -( -Look -: -: -WordUnicodeNegate -) -} -/ -/ -/ -Returns -true -if -and -only -if -this -set -contains -any -ASCII -word -boundary -/ -/ -/ -or -negated -ASCII -word -boundary -assertions -. -# -[ -inline -] -pub -fn -contains_word_ascii -( -self -) -- -> -bool -{ -self -. -contains -( -Look -: -: -WordAscii -) -| -| -self -. -contains -( -Look -: -: -WordAsciiNegate -) -} -/ -/ -/ -Returns -an -iterator -over -all -of -the -look -- -around -assertions -in -this -set -. -# -[ -inline -] -pub -fn -iter -( -self -) -- -> -LookSetIter -{ -LookSetIter -{ -set -: -self -} -} -/ -/ -/ -Return -a -new -set -that -is -equivalent -to -the -original -but -with -the -given -/ -/ -/ -assertion -added -to -it -. -If -the -assertion -is -already -in -the -set -then -the -/ -/ -/ -returned -set -is -equivalent -to -the -original -. -# -[ -inline -] -pub -fn -insert -( -self -look -: -Look -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -| -look -. -as_repr -( -) -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -inserting -the -given -/ -/ -/ -assertion -into -this -set -. -# -[ -inline -] -pub -fn -set_insert -( -& -mut -self -look -: -Look -) -{ -* -self -= -self -. -insert -( -look -) -; -} -/ -/ -/ -Return -a -new -set -that -is -equivalent -to -the -original -but -with -the -given -/ -/ -/ -assertion -removed -from -it -. -If -the -assertion -is -not -in -the -set -then -the -/ -/ -/ -returned -set -is -equivalent -to -the -original -. -# -[ -inline -] -pub -fn -remove -( -self -look -: -Look -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -& -! -look -. -as_repr -( -) -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -removing -the -given -/ -/ -/ -assertion -from -this -set -. -# -[ -inline -] -pub -fn -set_remove -( -& -mut -self -look -: -Look -) -{ -* -self -= -self -. -remove -( -look -) -; -} -/ -/ -/ -Returns -a -new -set -that -is -the -result -of -subtracting -the -given -set -from -/ -/ -/ -this -set -. -# -[ -inline -] -pub -fn -subtract -( -self -other -: -LookSet -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -& -! -other -. -bits -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -subtracting -the -given -set -/ -/ -/ -from -this -set -. -# -[ -inline -] -pub -fn -set_subtract -( -& -mut -self -other -: -LookSet -) -{ -* -self -= -self -. -subtract -( -other -) -; -} -/ -/ -/ -Returns -a -new -set -that -is -the -union -of -this -and -the -one -given -. -# -[ -inline -] -pub -fn -union -( -self -other -: -LookSet -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -| -other -. -bits -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -unioning -it -with -the -one -/ -/ -/ -given -. -# -[ -inline -] -pub -fn -set_union -( -& -mut -self -other -: -LookSet -) -{ -* -self -= -self -. -union -( -other -) -; -} -/ -/ -/ -Returns -a -new -set -that -is -the -intersection -of -this -and -the -one -given -. -# -[ -inline -] -pub -fn -intersect -( -self -other -: -LookSet -) -- -> -LookSet -{ -LookSet -{ -bits -: -self -. -bits -& -other -. -bits -} -} -/ -/ -/ -Updates -this -set -in -place -with -the -result -of -intersecting -it -with -the -/ -/ -/ -one -given -. -# -[ -inline -] -pub -fn -set_intersect -( -& -mut -self -other -: -LookSet -) -{ -* -self -= -self -. -intersect -( -other -) -; -} -/ -/ -/ -Return -a -LookSet -from -the -slice -given -as -a -native -endian -16 -- -bit -/ -/ -/ -integer -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -slice -. -len -( -) -< -2 -. -# -[ -inline -] -pub -fn -read_repr -( -slice -: -& -[ -u8 -] -) -- -> -LookSet -{ -let -bits -= -u16 -: -: -from_ne_bytes -( -slice -[ -. -. -2 -] -. -try_into -( -) -. -unwrap -( -) -) -; -LookSet -{ -bits -} -} -/ -/ -/ -Write -a -LookSet -as -a -native -endian -16 -- -bit -integer -to -the -beginning -/ -/ -/ -of -the -slice -given -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -slice -. -len -( -) -< -2 -. -# -[ -inline -] -pub -fn -write_repr -( -self -slice -: -& -mut -[ -u8 -] -) -{ -let -raw -= -self -. -bits -. -to_ne_bytes -( -) -; -slice -[ -0 -] -= -raw -[ -0 -] -; -slice -[ -1 -] -= -raw -[ -1 -] -; -} -} -impl -core -: -: -fmt -: -: -Debug -for -LookSet -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -if -self -. -is_empty -( -) -{ -return -write -! -( -f -" -" -) -; -} -for -look -in -self -. -iter -( -) -{ -write -! -( -f -" -{ -} -" -look -. -as_char -( -) -) -? -; -} -Ok -( -( -) -) -} -} -/ -/ -/ -An -iterator -over -all -look -- -around -assertions -in -a -[ -LookSet -] -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -LookSet -: -: -iter -] -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -LookSetIter -{ -set -: -LookSet -} -impl -Iterator -for -LookSetIter -{ -type -Item -= -Look -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Look -> -{ -if -self -. -set -. -is_empty -( -) -{ -return -None -; -} -/ -/ -We -' -ll -never -have -more -than -u8 -: -: -MAX -distinct -look -- -around -assertions -/ -/ -so -' -repr -' -will -always -fit -into -a -u16 -. -let -repr -= -u16 -: -: -try_from -( -self -. -set -. -bits -. -trailing_zeros -( -) -) -. -unwrap -( -) -; -let -look -= -Look -: -: -from_repr -( -1 -< -< -repr -) -? -; -self -. -set -= -self -. -set -. -remove -( -look -) -; -Some -( -look -) -} -} -/ -/ -/ -Given -a -sequence -of -HIR -values -where -each -value -corresponds -to -a -Unicode -/ -/ -/ -class -( -or -an -all -- -ASCII -byte -class -) -return -a -single -Unicode -class -/ -/ -/ -corresponding -to -the -union -of -the -classes -found -. -fn -class_chars -( -hirs -: -& -[ -Hir -] -) -- -> -Option -< -Class -> -{ -let -mut -cls -= -ClassUnicode -: -: -new -( -vec -! -[ -] -) -; -for -hir -in -hirs -. -iter -( -) -{ -match -* -hir -. -kind -( -) -{ -HirKind -: -: -Class -( -Class -: -: -Unicode -( -ref -cls2 -) -) -= -> -{ -cls -. -union -( -cls2 -) -; -} -HirKind -: -: -Class -( -Class -: -: -Bytes -( -ref -cls2 -) -) -= -> -{ -cls -. -union -( -& -cls2 -. -to_unicode_class -( -) -? -) -; -} -_ -= -> -return -None -} -; -} -Some -( -Class -: -: -Unicode -( -cls -) -) -} -/ -/ -/ -Given -a -sequence -of -HIR -values -where -each -value -corresponds -to -a -byte -class -/ -/ -/ -( -or -an -all -- -ASCII -Unicode -class -) -return -a -single -byte -class -corresponding -/ -/ -/ -to -the -union -of -the -classes -found -. -fn -class_bytes -( -hirs -: -& -[ -Hir -] -) -- -> -Option -< -Class -> -{ -let -mut -cls -= -ClassBytes -: -: -new -( -vec -! -[ -] -) -; -for -hir -in -hirs -. -iter -( -) -{ -match -* -hir -. -kind -( -) -{ -HirKind -: -: -Class -( -Class -: -: -Unicode -( -ref -cls2 -) -) -= -> -{ -cls -. -union -( -& -cls2 -. -to_byte_class -( -) -? -) -; -} -HirKind -: -: -Class -( -Class -: -: -Bytes -( -ref -cls2 -) -) -= -> -{ -cls -. -union -( -cls2 -) -; -} -_ -= -> -return -None -} -; -} -Some -( -Class -: -: -Bytes -( -cls -) -) -} -/ -/ -/ -Given -a -sequence -of -HIR -values -where -each -value -corresponds -to -a -literal -/ -/ -/ -that -is a -single -char -return -that -sequence -of -char -s -. -Otherwise -return -/ -/ -/ -None -. -No -deduplication -is -done -. -fn -singleton_chars -( -hirs -: -& -[ -Hir -] -) -- -> -Option -< -Vec -< -char -> -> -{ -let -mut -singletons -= -vec -! -[ -] -; -for -hir -in -hirs -. -iter -( -) -{ -let -literal -= -match -* -hir -. -kind -( -) -{ -HirKind -: -: -Literal -( -Literal -( -ref -bytes -) -) -= -> -bytes -_ -= -> -return -None -} -; -let -ch -= -match -crate -: -: -debug -: -: -utf8_decode -( -literal -) -{ -None -= -> -return -None -Some -( -Err -( -_ -) -) -= -> -return -None -Some -( -Ok +? +suffix +is +used +e +. +g +. ( -ch +expr ) +* +is +greedy +while +( +expr ) -= +* +? +is +/ +/ +/ +not +. +However +this +can +be +inverted +via +the +U +" +ungreedy +" +flag +. +pub +greedy +: +bool +/ +/ +/ +The +expression +being +repeated +. +pub +hir +: +Box +< +Hir > -ch } -; +impl +Repetition +{ +/ +/ +/ +Returns +true if -literal -. -len -( -) -! -= -ch +and +only +if +this +repetition +operator +makes +it +possible +/ +/ +/ +to +match +the +empty +string . -len_utf8 -( -) -{ -return -None -; -} -singletons +/ +/ +/ +/ +/ +/ +Note +that +this +is +not +defined +inductively . -push +For +example +while +a +* +/ +/ +/ +will +report +true ( -ch ) -; -} -Some ++ +will +not +even +though ( -singletons ) -} +matches +the +empty / / / -Given -a -sequence +string +and +one +or +more +occurrences of -HIR -values -where -each -value -corresponds -to -a -literal +something +that +matches +the +empty / / / -that -is -a -single -byte -return -that -sequence -of -bytes +string +will +always +match +the +empty +string . -Otherwise -return +In +order +to +get +the / / / -None +inductive +definition +see +the +corresponding +method +on +/ +/ +/ +[ +Hir +] +( +struct . -No -deduplication -is -done +Hir . +html +) +. +pub fn -singleton_bytes +is_match_empty ( -hirs -: & -[ -Hir -] +self ) - > -Option -< -Vec -< -u8 -> -> -{ -let -mut -singletons -= -vec -! -[ -] -; -for -hir -in -hirs -. -iter -( -) +bool { -let -literal -= match -* -hir +self . kind +{ +RepetitionKind +: +: +ZeroOrOne += +> +true +RepetitionKind +: +: +ZeroOrMore += +> +true +RepetitionKind +: +: +OneOrMore += +> +false +RepetitionKind +: +: +Range ( +RepetitionRange +: +: +Exactly +( +m ) -{ -HirKind +) += +> +m += += +0 +RepetitionKind : : -Literal +Range ( -Literal +RepetitionRange +: +: +AtLeast ( -ref -bytes +m ) ) = > -bytes -_ +m = -> -return -None -} -; -if -literal -. -len += +0 +RepetitionKind +: +: +Range +( +RepetitionRange +: +: +Bounded ( +m +_ +) ) -! = -1 -{ -return -None -; -} -singletons -. -push -( -literal -[ +> +m += += 0 -] -) -; } -Some -( -singletons -) +} } / / / -Looks -for -a -common -prefix -in -the -list +The +kind of -alternation -branches -given +a +repetition +operator . -If -one +# +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +enum +RepetitionKind +{ / / / -is -found -then -an -equivalent -but -( -hopefully -) -simplified -Hir -is -returned +Matches +a +sub +- +expression +zero +or +one +times . +ZeroOrOne / / / -Otherwise -the -original -given -list -of -branches -is -returned -unmodified +Matches +a +sub +- +expression +zero +or +more +times . +ZeroOrMore / / / +Matches +a +sub +- +expression +one +or +more +times +. +OneOrMore / / / -This -is -not -quite -as -good -as -it -could -be +Matches +a +sub +- +expression +within +a +bounded +range +of +times . -Right -now -it -requires -that +Range +( +RepetitionRange +) +} / / / -all -branches -are -' -Concat -' -expressions +The +kind +of +a +counted +repetition +operator . -It -also -doesn -' -t -do -well -with +# +[ +derive +( +Clone +Debug +Eq +PartialEq +) +] +pub +enum +RepetitionRange +{ / / / -literals +Matches +a +sub +- +expression +exactly +this +many +times . -For -example -given -' -foofoo -| -foobar -' -it -will -not -refactor -it -to +Exactly +( +u32 +) / / / -' -foo +Matches +a +sub +- +expression +at +least +this +many +times +. +AtLeast ( -? -: -foo -| -bar +u32 ) -' -because -literals -are -flattened -into -their -own -special / / / -concatenation +Matches +a +sub +- +expression +at +least +m +times +and +at +most +n +times . +Bounded ( -One -wonders -if -perhaps -' -Literal -' -should -be -a -single -atom +u32 +u32 +) +} / / / -instead -of -a -string -of -bytes -because -of -this -. -Otherwise -handling -the +A +custom +Drop +impl +is +used +for +HirKind +such +that +it +uses +constant +stack / / / -current -representation -in -this -routine -will -be -pretty -gnarly +space +but +heap +space +proportional +to +the +depth +of +the +total +Hir . -Sigh +impl +Drop +for +Hir +{ +fn +drop +( +& +mut +self +) +{ +use +std +: +: +mem +; +match +* +self . +kind +( ) -fn -lift_common_prefix +{ +HirKind +: +: +Empty +| +HirKind +: +: +Literal ( -hirs +_ +) +| +HirKind : -Vec -< -Hir -> +: +Class +( +_ ) -- +| +HirKind +: +: +Anchor +( +_ +) +| +HirKind +: +: +WordBoundary +( +_ +) += > -Result -< -Hir -Vec -< -Hir +return +HirKind +: +: +Group +( +ref +x +) +if +! +x +. +hir +. +kind +. +has_subexprs +( +) += > +return +HirKind +: +: +Repetition +( +ref +x +) +if +! +x +. +hir +. +kind +. +has_subexprs +( +) += > -{ +return +HirKind +: +: +Concat +( +ref +x +) if -hirs +x . -len +is_empty ( ) -< = -1 -{ +> return -Err +HirKind +: +: +Alternation ( -hirs +ref +x ) -; +if +x +. +is_empty +( +) += +> +return +_ += +> +{ +} } let mut -prefix +stack = -match -hirs +vec +! [ -0 +mem +: +: +replace +( +self +Hir +: +: +empty +( +) +) ] +; +while +let +Some +( +mut +expr +) += +stack +. +pop +( +) +{ +match +expr . kind +{ +HirKind +: +: +Empty +| +HirKind +: +: +Literal +( +_ +) +| +HirKind +: +: +Class +( +_ +) +| +HirKind +: +: +Anchor +( +_ +) +| +HirKind +: +: +WordBoundary ( +_ ) += +> { +} HirKind : : -Concat +Group ( ref -xs +mut +x ) = > -& -* -* -xs -_ -= -> -return -Err +{ +stack +. +push ( -hirs -) -} -; -if -prefix +mem +: +: +replace +( +& +mut +x . -is_empty +hir +Hir +: +: +empty ( ) -{ -return -Err -( -hirs +) ) ; } -for -h -in -hirs -. -iter +HirKind +: +: +Repetition ( +ref +mut +x ) += +> +{ +stack . -skip +push ( -1 -) -{ -let -concat -= -match -h +mem +: +: +replace +( +& +mut +x . -kind +hir +Hir +: +: +empty ( ) -{ +) +) +; +} HirKind : : Concat ( ref -xs +mut +x ) = > -xs -_ -= -> -return -Err +{ +stack +. +extend +( +x +. +drain ( -hirs +. +. +) ) -} ; -let -common_len -= -prefix -. -iter +} +HirKind +: +: +Alternation ( +ref +mut +x ) += +> +{ +stack . -zip +extend ( -concat +x . -iter +drain ( +. +. ) ) +; +} +} +} +} +} +/ +/ +/ +A +type +that +documents +various +attributes +of +an +HIR +expression . -take_while +/ +/ +/ +/ +/ +/ +These +attributes +are +typically +defined +inductively +on +the +HIR +. +# +[ +derive ( -| +Clone +Debug +Eq +PartialEq +) +] +struct +HirInfo +{ +/ +/ +/ +Represent +yes +/ +no +questions +by +a +bitfield +to +conserve +space +since +/ +/ +/ +this +is +included +in +every +HIR +expression +. +/ +/ +/ +/ +/ +/ +If +more +attributes +need +to +be +added +it +is +OK +to +increase +the +size +of +/ +/ +/ +this +as +appropriate +. +bools +: +u16 +} +/ +/ +A +simple +macro +for +defining +bitfield +accessors +/ +mutators +. +macro_rules +! +define_bool +{ ( -x -y +bit +: +expr +is_fn_name +: +ident +set_fn_name +: +ident ) -| -x -= = -y +> +{ +fn +is_fn_name +( +& +self ) +- +> +bool +{ +self . -count +bools +& ( +0b1 +< +< +bit ) -; -prefix -= +> +0 +} +fn +set_fn_name +( & -prefix -[ -. +mut +self +yes +: +bool +) +{ +if +yes +{ +self . -common_len -] +bools +| += +1 +< +< +bit ; -if -prefix +} +else +{ +self . -is_empty +bools +& += +! ( +1 +< +< +bit ) +; +} +} +} +; +} +impl +HirInfo { -return -Err +fn +new ( -hirs ) -; +- +> +HirInfo +{ +HirInfo +{ +bools +: +0 } } -let -len -= -prefix -. -len +define_bool +! ( +0 +is_always_utf8 +set_always_utf8 ) ; -assert_ne +define_bool ! ( -0 -len +1 +is_all_assertions +set_all_assertions ) ; -let -mut -prefix_concat -= -vec +define_bool ! -[ -] +( +2 +is_anchored_start +set_anchored_start +) ; -let -mut -suffix_alts -= -vec +define_bool ! -[ -] -; -for -h -in -hirs -{ -let -mut -concat -= -match -h -. -into_kind ( +3 +is_anchored_end +set_anchored_end ) -{ -HirKind -: -: -Concat +; +define_bool +! ( -xs +4 +is_line_anchored_start +set_line_anchored_start ) -= -> -xs -/ -/ -We -required -all -sub -- -expressions -to -be -/ -/ -concats -above -so -we -' -re -only -here -if -we -/ -/ -have -a -concat -. -_ -= -> -unreachable +; +define_bool ! ( +5 +is_line_anchored_end +set_line_anchored_end ) -} ; -suffix_alts -. -push -( -Hir -: -: -concat -( -concat -. -split_off +define_bool +! ( -len -) -) +6 +is_any_anchored_start +set_any_anchored_start ) ; -if -prefix_concat -. -is_empty +define_bool +! ( +7 +is_any_anchored_end +set_any_anchored_end ) -{ -prefix_concat -= -concat -; -} -} -let -mut -concat -= -prefix_concat ; -concat -. -push -( -Hir -: -: -alternation +define_bool +! ( -suffix_alts -) +8 +is_match_empty +set_match_empty ) ; -Ok -( -Hir -: -: -concat +define_bool +! ( -concat +9 +is_literal +set_literal ) +; +define_bool +! +( +10 +is_alternation_literal +set_alternation_literal ) +; } # [ @@ -36273,6 +21303,37 @@ cls2 ) ; } +# +[ +test +] +# +[ +should_panic +] +fn +hir_byte_literal_non_ascii +( +) +{ +Hir +: +: +literal +( +Literal +: +: +Byte +( +b +' +a +' +) +) +; +} / / We @@ -36385,17 +21446,17 @@ expr Hir : : -capture +group ( -Capture +Group { -index +kind : -1 -name +GroupKind : -None -sub +: +NonCapturing +hir : Box : @@ -36416,19 +21477,16 @@ repetition ( Repetition { -min +kind : -0 -max +RepetitionKind : -Some -( -1 -) +: +ZeroOrOne greedy : true -sub +hir : Box : @@ -36457,12 +21515,12 @@ vec expr ] ) -props +info : -Properties +HirInfo : : -empty +new ( ) } @@ -36484,12 +21542,12 @@ vec expr ] ) -props +info : -Properties +HirInfo : : -empty +new ( ) } @@ -36499,20 +21557,13 @@ assert ! ( ! -matches -! -( -* expr . kind +. +is_empty ( ) -HirKind -: -: -Empty -) ) ; } @@ -36542,45 +21593,6 @@ issue more easily . -/ -/ -/ -/ -NOTE -( -2023 -- -03 -- -21 -) -: -See -the -corresponding -test -in -' -crate -: -: -ast -: -: -tests -' -/ -/ -for -context -on -the -specific -stack -size -chosen -here -. thread : : @@ -36593,7 +21605,7 @@ new . stack_size ( -16 +1 < < 10 @@ -36617,240 +21629,4 @@ unwrap ) ; } -# -[ -test -] -fn -look_set_iter -( -) -{ -let -set -= -LookSet -: -: -empty -( -) -; -assert_eq -! -( -0 -set -. -iter -( -) -. -count -( -) -) -; -let -set -= -LookSet -: -: -full -( -) -; -assert_eq -! -( -10 -set -. -iter -( -) -. -count -( -) -) -; -let -set -= -LookSet -: -: -empty -( -) -. -insert -( -Look -: -: -StartLF -) -. -insert -( -Look -: -: -WordUnicode -) -; -assert_eq -! -( -2 -set -. -iter -( -) -. -count -( -) -) -; -let -set -= -LookSet -: -: -empty -( -) -. -insert -( -Look -: -: -StartLF -) -; -assert_eq -! -( -1 -set -. -iter -( -) -. -count -( -) -) -; -let -set -= -LookSet -: -: -empty -( -) -. -insert -( -Look -: -: -WordAsciiNegate -) -; -assert_eq -! -( -1 -set -. -iter -( -) -. -count -( -) -) -; -} -# -[ -test -] -fn -look_set_debug -( -) -{ -let -res -= -format -! -( -" -{ -: -? -} -" -LookSet -: -: -empty -( -) -) -; -assert_eq -! -( -" -" -res -) -; -let -res -= -format -! -( -" -{ -: -? -} -" -LookSet -: -: -full -( -) -) -; -assert_eq -! -( -" -Az -^ -rRbB -" -res -) -; -} } diff --git a/third_party/rust/regex-syntax/src/hir/print.rs b/third_party/rust/regex-syntax/src/hir/print.rs index 26e4a9ae9fe3a..cab8ea996a406 100644 --- a/third_party/rust/regex-syntax/src/hir/print.rs +++ b/third_party/rust/regex-syntax/src/hir/print.rs @@ -14,7 +14,7 @@ Hir * / use -core +std : : fmt @@ -23,12 +23,9 @@ use crate : : -{ hir : : -{ -self visitor : : @@ -36,11 +33,25 @@ visitor self Visitor } +; +use +crate +: +: +hir +: +: +{ +self Hir HirKind } +; +use +crate +: +: is_meta_character -} ; / / @@ -596,97 +607,27 @@ HirKind : : Empty -= -> -{ -/ -/ -Technically -an -empty -sub -- -expression -could -be -" -printed -" -by -/ -/ -just -ignoring -it -but -in -practice -you -could -have -a -/ -/ -repetition -operator -attached -to -an -empty -expression -and -you -/ -/ -really -need -something -in -the -concrete -syntax -to -make -that -/ -/ -work -as -you -' -d -expect -. -self -. -wtr -. -write_str -( -r -" -( -? +| +HirKind : +: +Repetition +( +_ ) -" +| +HirKind +: +: +Concat +( +_ ) -? -; -} -/ -/ -Repetition -operators -are -strictly -suffix -oriented -. +| HirKind : : -Repetition +Alternation ( _ ) @@ -703,196 +644,72 @@ hir : : Literal +: +: +Unicode ( -ref -bytes +c ) ) = > { -/ -/ -See -the -comment -on -the -' -Concat -' -and -' -Alternation -' -case -below -/ -/ -for -why -we -put -parens -here -. -Literals -are -conceptually -/ -/ -a -special -case -of -concatenation -where -each -element -is -a -/ -/ -character -. -The -HIR -flattens -this -into -a -Box -< -[ -u8 -] -> -but -we -/ -/ -still -need -to -treat -it -like -a -concatenation -for -correct -/ -/ -printing -. -As -a -special -case -we -don -' -t -write -parens -if -there -/ -/ -is -only -one -character -. -One -character -means -there -is -no -/ -/ -concat -so -we -don -' -t -need -parens -. -Adding -parens -would -still -be -/ -/ -correct -but -we -drop -them -here -because -it -tends -to -create -/ -/ -rather -noisy -regexes -even -in -simple -cases +self . -let -result -= -core +write_literal_char +( +c +) +? +; +} +HirKind : : -str +Literal +( +hir +: +: +Literal : : -from_utf8 +Byte ( -bytes +b +) ) -; -let -len = -result -. -map_or -( -bytes +> +{ +self . -len +write_literal_byte ( +b ) -| -s -| -s -. -chars +? +; +} +HirKind +: +: +Class ( -) -. -count +hir +: +: +Class +: +: +Unicode ( +ref +cls ) ) -; -if -len += > -1 { self . @@ -900,218 +717,34 @@ wtr . write_str ( -r " -( -? -: +[ " ) ? ; -} -match -result -{ -Ok -( -string -) -= -> -{ for -c +range in -string +cls . -chars +iter ( ) { -self -. -write_literal_char -( -c -) -? -; -} -} -Err -( -_ -) -= -> -{ -for -& -b -in -bytes -. -iter -( -) -{ -self -. -write_literal_byte -( -b -) -? -; -} -} -} -if -len -> -1 -{ -self -. -wtr -. -write_str -( -r -" -) -" -) -? -; -} -} -HirKind -: -: -Class -( -hir -: -: -Class -: -: -Unicode -( -ref -cls -) -) -= -> -{ -if -cls -. -ranges -( -) -. -is_empty -( -) -{ -return -self -. -wtr -. -write_str -( -" -[ -a -& -& -b -] -" -) -; -} -self -. -wtr -. -write_str -( -" -[ -" -) -? -; -for -range -in -cls -. -iter -( -) -{ -if -range -. -start -( -) -= -= -range -. -end -( -) -{ -self -. -write_literal_char -( -range -. -start -( -) -) -? -; -} -else -if -u32 -: -: -from -( -range +if +range . start ( ) -) -+ -1 = = -u32 -: -: -from -( range . end ( ) -) { self . @@ -1125,18 +758,6 @@ start ) ? ; -self -. -write_literal_char -( -range -. -end -( -) -) -? -; } else { @@ -1211,35 +832,6 @@ cls = > { -if -cls -. -ranges -( -) -. -is_empty -( -) -{ -return -self -. -wtr -. -write_str -( -" -[ -a -& -& -b -] -" -) -; -} self . wtr @@ -1294,48 +886,6 @@ start ; } else -if -range -. -start -( -) -+ -1 -= -= -range -. -end -( -) -{ -self -. -write_literal_class_byte -( -range -. -start -( -) -) -? -; -self -. -write_literal_class_byte -( -range -. -end -( -) -) -? -; -} -else { self . @@ -1392,24 +942,16 @@ write_str HirKind : : -Look +Anchor ( -ref -look -) -= -> -match -* -look -{ hir : : -Look +Anchor : : -Start +StartLine +) = > { @@ -1419,22 +961,31 @@ wtr . write_str ( -r -" -\ -A +" +( +? +m +: +^ +) " ) ? ; } +HirKind +: +: +Anchor +( hir : : -Look +Anchor : : -End +EndLine +) = > { @@ -1444,22 +995,30 @@ wtr . write_str ( -r " -\ -z +( +? +m +: +) " ) ? ; } +HirKind +: +: +Anchor +( hir : : -Look +Anchor : : -StartLF +StartText +) = > { @@ -1469,25 +1028,28 @@ wtr . write_str ( +r " -( -? -m -: -^ -) +\ +A " ) ? ; } +HirKind +: +: +Anchor +( hir : : -Look +Anchor : : -EndLF +EndText +) = > { @@ -1497,24 +1059,28 @@ wtr . write_str ( +r " -( -? -m -: -) +\ +z " ) ? ; } +HirKind +: +: +WordBoundary +( hir : : -Look +WordBoundary : : -StartCRLF +Unicode +) = > { @@ -1524,25 +1090,28 @@ wtr . write_str ( +r " -( -? -mR -: -^ -) +\ +b " ) ? ; } +HirKind +: +: +WordBoundary +( hir : : -Look +WordBoundary : : -EndCRLF +UnicodeNegate +) = > { @@ -1552,24 +1121,28 @@ wtr . write_str ( +r " -( -? -mR -: -) +\ +B " ) ? ; } +HirKind +: +: +WordBoundary +( hir : : -Look +WordBoundary : : -WordAscii +Ascii +) = > { @@ -1594,13 +1167,19 @@ b ? ; } +HirKind +: +: +WordBoundary +( hir : : -Look +WordBoundary : : -WordAsciiNegate +AsciiNegate +) = > { @@ -1625,38 +1204,31 @@ B ? ; } -hir -: -: -Look +HirKind : : -WordUnicode +Group +( +ref +x +) = > -{ -self -. -wtr +match +x . -write_str -( -r -" -\ -b -" -) -? -; -} +kind +{ hir : : -Look +GroupKind : : -WordUnicodeNegate +CaptureIndex +( +_ +) = > { @@ -1666,355 +1238,146 @@ wtr . write_str ( -r " -\ -B +( " ) ? ; } -} -HirKind +hir : : -Capture -( -hir +GroupKind : : -Capture +CaptureName { ref name . . } -) = > { +write +! +( self . wtr -. -write_str -( " ( +? +P +< +{ +} +> " +name ) ? ; -if -let -Some -( -ref -name -) +} +hir +: +: +GroupKind +: +: +NonCapturing = -* -name +> { -write -! -( self . wtr +. +write_str +( " +( ? -P -< -{ -} -> +: " -name ) ? ; } } -/ -/ -Why -do -this -? -Wrapping -concats -and -alts -in -non -- -capturing -groups -/ -/ -is -not -* -always -* -necessary -but -is -sometimes -necessary -. -For -/ -/ -example -' -concat +} +Ok ( -a -alt ( -b -c ) ) -' -should -be -written -as -' -a +} +fn +visit_post ( -? +& +mut +self +hir : -b -| -c +& +Hir ) -' -/ -/ -and -not -' -ab -| -c -' +- +> +fmt +: +: +Result +{ +match +* +hir . -The -former -is -clearly -the -intended -meaning -but -/ -/ -the -latter -is -actually -' -alt -( -concat +kind ( -a -b -) -c ) -' -. -/ -/ -/ +{ / -It -would -be -possible -to -only -group -these -things -in -cases -where / -/ -it -' -s -strictly -necessary -but -it -requires -knowing -the -parent -/ -/ -expression -. -And -since -this -technique -is -simpler -and -always -/ -/ -correct -we -take -this -route -. -More -to -the -point -it -is -a -non -- -goal -/ -/ -of -an -HIR -printer -to -show -a -nice -easy -- -to -- -read -regex -. -Indeed -/ -/ -its -construction -forbids -it -from -doing -so -. -Therefore -inserting -/ -/ -extra -groups -where -they -aren -' -t -necessary -is -perfectly -okay -. +Handled +during +visit_pre HirKind : : -Concat -( -_ -) +Empty | HirKind : : -Alternation +Literal ( _ ) -= -> -{ -self -. -wtr -. -write_str -( -r -" -( -? -: -" -) -? -; -} -} -Ok -( -( -) -) -} -fn -visit_post -( -& -mut -self -hir -: -& -Hir -) -- -> -fmt +| +HirKind : : -Result -{ -match -* -hir -. -kind +Class ( +_ ) -{ -/ -/ -Handled -during -visit_pre +| HirKind : : -Empty +Anchor +( +_ +) | HirKind : : -Literal +WordBoundary ( _ ) @@ -2022,7 +1385,7 @@ _ HirKind : : -Class +Concat ( _ ) @@ -2030,7 +1393,7 @@ _ HirKind : : -Look +Alternation ( _ ) @@ -2050,22 +1413,17 @@ x > { match -( x . -min -x -. -max -) +kind { -( -0 -Some -( -1 -) -) +hir +: +: +RepetitionKind +: +: +ZeroOrOne = > { @@ -2082,10 +1440,13 @@ write_str ? ; } -( -0 -None -) +hir +: +: +RepetitionKind +: +: +ZeroOrMore = > { @@ -2102,10 +1463,13 @@ write_str ? ; } -( -1 -None -) +hir +: +: +RepetitionKind +: +: +OneOrMore = > { @@ -2122,51 +1486,32 @@ write_str ? ; } +hir +: +: +RepetitionKind +: +: +Range ( -1 -Some -( -1 -) +ref +x ) = > +match +* +x { -/ -/ -' -a -{ -1 -} -' -and -' -a -{ -1 -} -? -' -are -exactly -equivalent -to -' -a -' -. -return -Ok -( -( -) -) -; -} +hir +: +: +RepetitionRange +: +: +Exactly ( m -None ) = > @@ -2190,18 +1535,16 @@ m ? ; } +hir +: +: +RepetitionRange +: +: +AtLeast ( m -Some -( -n ) -) -if -m -= -= -n = > { @@ -2223,38 +1566,18 @@ m ) ? ; -/ -/ -a -{ -m -} -and -a -{ -m -} -? -are -always -exactly -equivalent -. -return -Ok -( -( -) -) -; } +hir +: +: +RepetitionRange +: +: +Bounded ( m -Some -( n ) -) = > { @@ -2281,6 +1604,7 @@ n ; } } +} if ! x @@ -2304,23 +1628,7 @@ write_str HirKind : : -Capture -( -_ -) -| -HirKind -: -: -Concat -( -_ -) -| -HirKind -: -: -Alternation +Group ( _ ) @@ -2333,7 +1641,6 @@ wtr . write_str ( -r " ) " @@ -2451,25 +1758,34 @@ fmt : Result { -if +let +c += b +as +char +; +if +c < = 0x7F +as +char & & ! -b +c . -is_ascii_control +is_control ( ) & & ! -b +c . -is_ascii_whitespace +is_whitespace ( ) { @@ -2477,17 +1793,7 @@ self . write_literal_char ( -char -: -: -try_from -( -b -) -. -unwrap -( -) +c ) } else @@ -2534,25 +1840,34 @@ fmt : Result { -if +let +c += b +as +char +; +if +c < = 0x7F +as +char & & ! -b +c . -is_ascii_control +is_control ( ) & & ! -b +c . -is_ascii_whitespace +is_whitespace ( ) { @@ -2560,17 +1875,7 @@ self . write_literal_char ( -char -: -: -try_from -( -b -) -. -unwrap -( -) +c ) } else @@ -2606,22 +1911,10 @@ mod tests { use -alloc -: -: -{ -boxed -: -: -Box -string +super : : -{ -String -ToString -} -} +Printer ; use crate @@ -2629,12 +1922,6 @@ crate : ParserBuilder ; -use -super -: -: -* -; fn roundtrip ( @@ -2679,9 +1966,9 @@ b | b . -utf8 +allow_invalid_utf8 ( -false +true ) given expected @@ -2933,22 +2220,8 @@ a " r " -a -" -) -; -roundtrip -( -r -" [ -ab -] -" -r -" -[ -ab +a ] " ) @@ -3020,11 +2293,13 @@ u ] " " +[ \ u { 0 } +] " ) ; @@ -3038,8 +2313,10 @@ r " r " +[ \ - +] " ) ; @@ -3074,32 +2351,13 @@ a " r " -a -" -) -; -roundtrip -( -r -" -( -? -- -u -) -[ -ab -] -" -r -" ( ? - u : [ -ab +a ] ) " @@ -3197,8 +2455,10 @@ r " r " +[ \ [ +] " ) ; @@ -3281,8 +2541,16 @@ u " r " +( +? +- +u +: +[ \ [ +] +) " ) ; @@ -3352,82 +2620,6 @@ _ " ) ; -/ -/ -This -tests -that -an -empty -character -class -is -correctly -roundtripped -. -# -[ -cfg -( -feature -= -" -unicode -- -gencat -" -) -] -roundtrip -( -r -" -\ -P -{ -any -} -" -r -" -[ -a -& -& -b -] -" -) -; -roundtrip_bytes -( -r -" -( -? -- -u -) -[ -^ -\ -x00 -- -\ -xFF -] -" -r -" -[ -a -& -& -b -] -" -) -; } # [ @@ -3740,21 +2932,8 @@ a " " a -" -) -; -roundtrip -( -" -a -{ -2 -} -" -" -a { -2 +1 } " ) @@ -3769,7 +2948,9 @@ a " " a -+ +{ +1 +} " ) ; @@ -3802,24 +2983,11 @@ a " " a -" -) -; -roundtrip -( -" -a { -2 +1 } ? " -" -a -{ -2 -} -" ) ; roundtrip @@ -3833,7 +3001,9 @@ a " " a -+ +{ +1 +} ? " ) @@ -3872,26 +3042,10 @@ a " " a -" -) -; -roundtrip -( -" -( -? -U -) -a -{ -2 -} -" -" -a { -2 +1 } +? " ) ; @@ -3909,7 +3063,9 @@ a " " a -+ +{ +1 +} ? " ) @@ -3937,135 +3093,6 @@ a " ) ; -/ -/ -Test -that -various -zero -- -length -repetitions -always -translate -to -an -/ -/ -empty -regex -. -This -is -more -a -property -of -HIR -' -s -smart -constructors -/ -/ -than -the -printer -though -. -roundtrip -( -" -a -{ -0 -} -" -" -( -? -: -) -" -) -; -roundtrip -( -" -( -? -: -ab -) -{ -0 -} -" -" -( -? -: -) -" -) -; -# -[ -cfg -( -feature -= -" -unicode -- -gencat -" -) -] -{ -roundtrip -( -r -" -\ -p -{ -any -} -{ -0 -} -" -" -( -? -: -) -" -) -; -roundtrip -( -r -" -\ -P -{ -any -} -{ -0 -} -" -" -( -? -: -) -" -) -; -} } # [ @@ -4084,10 +3111,6 @@ roundtrip " " ( -( -? -: -) ) " ) @@ -4110,10 +3133,6 @@ P < foo > -( -? -: -) ) " ) @@ -4182,7 +3201,11 @@ a ) " " +( +? +: a +) " ) ; @@ -4228,19 +3251,7 @@ roundtrip | " " -( -? -: -( -? -: -) | -( -? -: -) -) " ) ; @@ -4251,24 +3262,8 @@ roundtrip | " " -( -? -: -( -? -: -) | -( -? -: -) | -( -? -: -) -) " ) ; @@ -4280,35 +3275,9 @@ a b " " -[ -ab -] -" -) -; -roundtrip -( -" -ab -| -cd -" -" -( -? -: -( -? -: -ab -) +a | -( -? -: -cd -) -) +b " ) ; @@ -4322,45 +3291,11 @@ b c " " -[ a -- -c -] -" -) -; -roundtrip -( -" -ab -| -cd -| -ef -" -" -( -? -: -( -? -: -ab -) | -( -? -: -cd -) +b | -( -? -: -ef -) -) +c " ) ; @@ -4374,1259 +3309,13 @@ bar quux " " -( -? -: -( -? -: foo -) | -( -? -: bar -) | -( -? -: quux -) -) " ) ; } -/ -/ -This -is -a -regression -test -that -stresses -a -peculiarity -of -how -the -HIR -/ -/ -is -both -constructed -and -printed -. -Namely -it -is -legal -for -a -repetition -/ -/ -to -directly -contain -a -concatenation -. -This -particular -construct -isn -' -t -/ -/ -really -possible -to -build -from -the -concrete -syntax -directly -since -you -' -d -/ -/ -be -forced -to -put -the -concatenation -into -( -at -least -) -a -non -- -capturing -/ -/ -group -. -Concurrently -the -printer -doesn -' -t -consider -this -case -and -just -/ -/ -kind -of -naively -prints -the -child -expression -and -tacks -on -the -repetition -/ -/ -operator -. -/ -/ -/ -/ -As -a -result -if -you -attached -' -+ -' -to -a -' -concat -( -a -b -) -' -the -printer -gives -/ -/ -you -' -ab -+ -' -but -clearly -it -really -should -be -' -( -? -: -ab -) -+ -' -. -/ -/ -/ -/ -This -bug -isn -' -t -easy -to -surface -because -most -ways -of -building -an -HIR -/ -/ -come -directly -from -the -concrete -syntax -and -as -mentioned -above -it -just -/ -/ -isn -' -t -possible -to -build -this -kind -of -HIR -from -the -concrete -syntax -. -/ -/ -Nevertheless -this -is -definitely -a -bug -. -/ -/ -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -731 -# -[ -test -] -fn -regression_repetition_concat -( -) -{ -let -expr -= -Hir -: -: -concat -( -alloc -: -: -vec -! -[ -Hir -: -: -literal -( -" -x -" -. -as_bytes -( -) -) -Hir -: -: -repetition -( -hir -: -: -Repetition -{ -min -: -1 -max -: -None -greedy -: -true -sub -: -Box -: -: -new -( -Hir -: -: -literal -( -" -ab -" -. -as_bytes -( -) -) -) -} -) -Hir -: -: -literal -( -" -y -" -. -as_bytes -( -) -) -] -) -; -assert_eq -! -( -r -" -( -? -: -x -( -? -: -ab -) -+ -y -) -" -expr -. -to_string -( -) -) -; -let -expr -= -Hir -: -: -concat -( -alloc -: -: -vec -! -[ -Hir -: -: -look -( -hir -: -: -Look -: -: -Start -) -Hir -: -: -repetition -( -hir -: -: -Repetition -{ -min -: -1 -max -: -None -greedy -: -true -sub -: -Box -: -: -new -( -Hir -: -: -concat -( -alloc -: -: -vec -! -[ -Hir -: -: -look -( -hir -: -: -Look -: -: -Start -) -Hir -: -: -look -( -hir -: -: -Look -: -: -End -) -] -) -) -} -) -Hir -: -: -look -( -hir -: -: -Look -: -: -End -) -] -) -; -assert_eq -! -( -r -" -( -? -: -\ -A -\ -A -\ -z -\ -z -) -" -expr -. -to_string -( -) -) -; -} -/ -/ -Just -like -regression_repetition_concat -but -with -the -repetition -using -/ -/ -an -alternation -as -a -child -expression -instead -. -/ -/ -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -731 -# -[ -test -] -fn -regression_repetition_alternation -( -) -{ -let -expr -= -Hir -: -: -concat -( -alloc -: -: -vec -! -[ -Hir -: -: -literal -( -" -ab -" -. -as_bytes -( -) -) -Hir -: -: -repetition -( -hir -: -: -Repetition -{ -min -: -1 -max -: -None -greedy -: -true -sub -: -Box -: -: -new -( -Hir -: -: -alternation -( -alloc -: -: -vec -! -[ -Hir -: -: -literal -( -" -cd -" -. -as_bytes -( -) -) -Hir -: -: -literal -( -" -ef -" -. -as_bytes -( -) -) -] -) -) -} -) -Hir -: -: -literal -( -" -gh -" -. -as_bytes -( -) -) -] -) -; -assert_eq -! -( -r -" -( -? -: -( -? -: -ab -) -( -? -: -( -? -: -cd -) -| -( -? -: -ef -) -) -+ -( -? -: -gh -) -) -" -expr -. -to_string -( -) -) -; -let -expr -= -Hir -: -: -concat -( -alloc -: -: -vec -! -[ -Hir -: -: -look -( -hir -: -: -Look -: -: -Start -) -Hir -: -: -repetition -( -hir -: -: -Repetition -{ -min -: -1 -max -: -None -greedy -: -true -sub -: -Box -: -: -new -( -Hir -: -: -alternation -( -alloc -: -: -vec -! -[ -Hir -: -: -look -( -hir -: -: -Look -: -: -Start -) -Hir -: -: -look -( -hir -: -: -Look -: -: -End -) -] -) -) -} -) -Hir -: -: -look -( -hir -: -: -Look -: -: -End -) -] -) -; -assert_eq -! -( -r -" -( -? -: -\ -A -( -? -: -\ -A -| -\ -z -) -\ -z -) -" -expr -. -to_string -( -) -) -; -} -/ -/ -This -regression -test -is -very -similar -in -flavor -to -/ -/ -regression_repetition_concat -in -that -the -root -of -the -issue -lies -in -a -/ -/ -peculiarity -of -how -the -HIR -is -represented -and -how -the -printer -writes -it -/ -/ -out -. -Like -the -other -regression -this -one -is -also -rooted -in -the -fact -that -/ -/ -you -can -' -t -produce -the -peculiar -HIR -from -the -concrete -syntax -. -Namely -you -/ -/ -just -can -' -t -have -a -' -concat -( -a -alt -( -b -c -) -) -' -because -the -' -alt -' -will -normally -/ -/ -be -in -( -at -least -) -a -non -- -capturing -group -. -Why -? -Because -the -' -| -' -has -very -/ -/ -low -precedence -( -lower -that -concatenation -) -and -so -something -like -' -ab -| -c -' -/ -/ -is -actually -' -alt -( -ab -c -) -' -. -/ -/ -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -516 -# -[ -test -] -fn -regression_alternation_concat -( -) -{ -let -expr -= -Hir -: -: -concat -( -alloc -: -: -vec -! -[ -Hir -: -: -literal -( -" -ab -" -. -as_bytes -( -) -) -Hir -: -: -alternation -( -alloc -: -: -vec -! -[ -Hir -: -: -literal -( -" -mn -" -. -as_bytes -( -) -) -Hir -: -: -literal -( -" -xy -" -. -as_bytes -( -) -) -] -) -] -) -; -assert_eq -! -( -r -" -( -? -: -( -? -: -ab -) -( -? -: -( -? -: -mn -) -| -( -? -: -xy -) -) -) -" -expr -. -to_string -( -) -) -; -let -expr -= -Hir -: -: -concat -( -alloc -: -: -vec -! -[ -Hir -: -: -look -( -hir -: -: -Look -: -: -Start -) -Hir -: -: -alternation -( -alloc -: -: -vec -! -[ -Hir -: -: -look -( -hir -: -: -Look -: -: -Start -) -Hir -: -: -look -( -hir -: -: -Look -: -: -End -) -] -) -] -) -; -assert_eq -! -( -r -" -( -? -: -\ -A -( -? -: -\ -A -| -\ -z -) -) -" -expr -. -to_string -( -) -) -; -} } diff --git a/third_party/rust/regex-syntax/src/hir/translate.rs b/third_party/rust/regex-syntax/src/hir/translate.rs index a94dbbbde39dc..252ac7d03af23 100644 --- a/third_party/rust/regex-syntax/src/hir/translate.rs +++ b/third_party/rust/regex-syntax/src/hir/translate.rs @@ -15,7 +15,7 @@ Hir * / use -core +std : : cell @@ -27,30 +27,15 @@ RefCell } ; use -alloc +std : : -{ -boxed -: -: -Box -string -: -: -ToString -vec -vec -: -: -Vec -} +result ; use crate : : -{ ast : : @@ -60,10 +45,11 @@ Ast Span Visitor } -either +; +use +crate : : -Either hir : : @@ -72,8 +58,12 @@ self Error ErrorKind Hir -HirKind } +; +use +crate +: +: unicode : : @@ -81,7 +71,6 @@ unicode self ClassQuery } -} ; type Result @@ -89,9 +78,6 @@ Result T > = -core -: -: result : : @@ -127,12 +113,9 @@ pub struct TranslatorBuilder { -utf8 +allow_invalid_utf8 : bool -line_terminator -: -u8 flags : Flags @@ -186,16 +169,9 @@ TranslatorBuilder { TranslatorBuilder { -utf8 -: -true -line_terminator +allow_invalid_utf8 : -b -' -\ -n -' +false flags : Flags @@ -253,23 +229,18 @@ self . flags ) -utf8 -: -self -. -utf8 -line_terminator +allow_invalid_utf8 : self . -line_terminator +allow_invalid_utf8 } } / / / When -disabled +enabled translation will permit @@ -297,7 +268,7 @@ UTF / / When -enabled +disabled ( the default @@ -308,28 +279,16 @@ is guaranteed to produce -an / / / +an expression that -for -non -- -empty -matches will only ever -produce -spans -/ -/ -/ -that -are -entirely +match valid UTF - @@ -337,13 +296,13 @@ UTF ( otherwise the +/ +/ +/ translator will return an -/ -/ -/ error ) . @@ -356,22 +315,20 @@ error Perhaps surprisingly when +invalid UTF - 8 -is -enabled -an -empty -regex -or -even -/ -/ -/ +isn +' +t +allowed a negated ASCII +/ +/ +/ word boundary ( @@ -388,86 +345,88 @@ B in the concrete -/ -/ -/ syntax ) will -be -allowed -even -though -they -can -produce -matches -that -split +cause / / / +the +parser +to +return +an +error +. +Namely a +negated +ASCII +word +boundary +/ +/ +/ +can +result +in +matching +positions +that +aren +' +t +valid UTF - 8 -encoded -codepoint +boundaries . -This -only -applies -to -zero +pub +fn +allow_invalid_utf8 +( +& +mut +self +yes +: +bool +) - -width -or -" -empty -" +> +& +mut +TranslatorBuilder +{ +self +. +allow_invalid_utf8 += +yes +; +self +} / / / -matches -and -it -is -expected -that +Enable +or +disable the -regex -engine -itself -must -handle -/ -/ -/ -these -cases -if -necessary +case +insensitive +flag ( -perhaps -by -suppressing -any -zero -- -width -matches -/ -/ -/ -that -split -a -codepoint +i ) +by +default . pub fn -utf8 +case_insensitive ( & mut @@ -484,296 +443,114 @@ TranslatorBuilder { self . -utf8 +flags +. +case_insensitive = +if yes +{ +Some +( +true +) +} +else +{ +None +} ; self } / / / -Sets +Enable +or +disable the +multi +- line -terminator -for -use -with +matching +flag ( -? -u -- -s -: -. +m ) -and +by +default +. +pub +fn +multi_line ( -? -- -us +& +mut +self +yes : -. +bool ) +- +> +& +mut +TranslatorBuilder +{ +self . -/ -/ -/ -/ -/ -/ -Namely -instead -of +flags . +multi_line += +if +yes +{ +Some ( -by -default +true ) -matching -everything -except -for -\ -n -/ -/ -/ -this -will -cause -. -to -match -everything -except -for -the -byte -given -. -/ -/ -/ -/ -/ -/ -If -. -is -used -in -a -context -where -Unicode -mode -is -enabled -and -this -byte -/ -/ -/ -isn -' -t -ASCII -then -an -error -will -be -returned -. -When -Unicode -mode -is -/ -/ -/ -disabled -then -any -byte -is -permitted -but -will -return -an -error -if -UTF -- -8 -/ -/ -/ -mode -is -enabled -and -it -is -a -non -- -ASCII -byte -. -/ -/ -/ -/ -/ -/ -In -short -any -ASCII -value -for -a -line -terminator -is -always -okay -. -But -a -/ -/ -/ -non -- -ASCII -byte -might -result -in -an -error -depending -on -whether -Unicode +} +else +{ +None +} +; +self +} / / / -mode +Enable or -UTF -- -8 -mode -are -enabled -. -/ -/ -/ -/ -/ -/ -Note -that -if -R -mode -is -enabled -then -it -always -takes -precedence -and -/ -/ -/ -the -line -terminator -will -be -treated -as -\ -r -and -\ -n -simultaneously -. -/ -/ -/ -/ -/ -/ -Note -also -that -this -* -doesn -' -t -* -impact +disable the -look -- -around -assertions -/ -/ -/ -( -? -m -: -^ -) -and +" +dot +matches +any +character +" +flag ( -? -m -: -) -. -That -' s -usually -controlled +) by -additional / / / -configuration -in -the -regex -engine -itself +default . pub fn -line_terminator +dot_matches_new_line ( & mut self -byte +yes : -u8 +bool ) - > @@ -783,9 +560,22 @@ TranslatorBuilder { self . -line_terminator +flags +. +dot_matches_new_line = -byte +if +yes +{ +Some +( +true +) +} +else +{ +None +} ; self } @@ -796,18 +586,20 @@ Enable or disable the -case -insensitive +" +swap +greed +" flag ( -i +U ) by default . pub fn -case_insensitive +swap_greed ( & mut @@ -826,7 +618,7 @@ self . flags . -case_insensitive +swap_greed = if yes @@ -850,237 +642,10 @@ Enable or disable the -multi -- -line -matching +Unicode flag ( -m -) -by -default -. -pub -fn -multi_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -TranslatorBuilder -{ -self -. -flags -. -multi_line -= -if -yes -{ -Some -( -true -) -} -else -{ -None -} -; -self -} -/ -/ -/ -Enable -or -disable -the -" -dot -matches -any -character -" -flag -( -s -) -by -/ -/ -/ -default -. -pub -fn -dot_matches_new_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -TranslatorBuilder -{ -self -. -flags -. -dot_matches_new_line -= -if -yes -{ -Some -( -true -) -} -else -{ -None -} -; -self -} -/ -/ -/ -Enable -or -disable -the -CRLF -mode -flag -( -R -) -by -default -. -pub -fn -crlf -( -& -mut -self -yes -: -bool -) -- -> -& -mut -TranslatorBuilder -{ -self -. -flags -. -crlf -= -if -yes -{ -Some -( -true -) -} -else -{ -None -} -; -self -} -/ -/ -/ -Enable -or -disable -the -" -swap -greed -" -flag -( -U -) -by -default -. -pub -fn -swap_greed -( -& -mut -self -yes -: -bool -) -- -> -& -mut -TranslatorBuilder -{ -self -. -flags -. -swap_greed -= -if -yes -{ -Some -( -true -) -} -else -{ -None -} -; -self -} -/ -/ -/ -Enable -or -disable -the -Unicode -flag -( -u +u ) by default @@ -1192,6 +757,13 @@ a [ TranslatorBuilder ] +( +struct +. +TranslatorBuilder +. +html +) . # [ @@ -1256,23 +828,9 @@ match arbitrary bytes . -utf8 +allow_invalid_utf8 : bool -/ -/ -/ -The -line -terminator -to -use -for -. -. -line_terminator -: -u8 } impl Translator @@ -1579,119 +1137,18 @@ Hir / / A -literal -that -is -being -constructed -character -by +Unicode character -from -the -/ -/ -/ -AST -. -We -need -this -because -the -AST -gives -each -individual -character -its -/ -/ -/ -own -node -. -So -as -we -see -characters -we -peek -at -the -top -- -most -HirFrame -. -/ -/ -/ -If -it -' -s -a -literal -then -we -add -to -it -. -Otherwise -we -push -a -new -literal -. -/ -/ -/ -When -it -comes -time -to -pop -it -we -convert -it -to -an -Hir -via -Hir -: -: -literal -. -Literal -( -Vec -< -u8 -> -) -/ -/ -/ -A -Unicode -character -class -. -This -frame -is -mutated -as -we -descend -into +class +. +This +frame +is +mutated +as +we +descend +into / / / @@ -1787,9 +1244,9 @@ disabled / / If -utf8 +allow_invalid_utf8 is -enabled +disabled ( the default @@ -1797,12 +1254,12 @@ default then a byte -character -is -only / / / +character +is +only permitted to match @@ -1822,77 +1279,6 @@ ClassBytes This is pushed -whenever -a -repetition -is -observed -. -After -visiting -every -/ -/ -/ -sub -- -expression -in -the -repetition -the -translator -' -s -stack -is -expected -to -/ -/ -/ -have -this -sentinel -at -the -top -. -/ -/ -/ -/ -/ -/ -This -sentinel -only -exists -to -stop -other -things -( -like -flattening -/ -/ -/ -literals -) -from -reaching -across -repetition -operators -. -Repetition -/ -/ -/ -This -is -pushed on to the @@ -1903,7 +1289,7 @@ seeing any kind of -capture +group / / / @@ -2150,87 +1536,6 @@ Alternation frame . Alternation -/ -/ -/ -This -is -pushed -immediately -before -each -sub -- -expression -in -an -/ -/ -/ -alternation -. -This -separates -the -branches -of -an -alternation -on -the -/ -/ -/ -stack -and -prevents -literal -flattening -from -reaching -across -alternation -/ -/ -/ -branches -. -/ -/ -/ -/ -/ -/ -It -is -popped -after -each -expression -in -a -branch -until -an -' -Alternation -' -/ -/ -/ -frame -is -observed -when -doing -a -post -visit -on -an -alternation -. -AlternationBranch } impl HirFrame @@ -2274,22 +1579,6 @@ expr = > expr -HirFrame -: -: -Literal -( -lit -) -= -> -Hir -: -: -literal -( -lit -) _ = > @@ -2469,78 +1758,10 @@ stack frame is a -repetition -sentinel -. -If -it -/ -/ -/ -isn -' -t -then -panic -. -fn -unwrap_repetition -( -self -) -{ -match -self -{ -HirFrame -: -: -Repetition -= -> -{ -} -_ -= -> -{ -panic -! -( -" -tried -to -unwrap -repetition -from -HirFrame -got -: -{ -: -? -} -" -self -) -} -} -} -/ -/ -/ -Assert -that -the -current -stack -frame -is -a -group -indicator -and -return +group +indicator +and +return / / / @@ -2613,76 +1834,6 @@ self } } } -/ -/ -/ -Assert -that -the -current -stack -frame -is -an -alternation -pipe -sentinel -. -If -/ -/ -/ -it -isn -' -t -then -panic -. -fn -unwrap_alternation_pipe -( -self -) -{ -match -self -{ -HirFrame -: -: -AlternationBranch -= -> -{ -} -_ -= -> -{ -panic -! -( -" -tried -to -unwrap -alt -pipe -from -HirFrame -got -: -{ -: -? -} -" -self -) -} -} -} } impl < @@ -2890,24 +2041,6 @@ cls Ast : : -Repetition -( -_ -) -= -> -self -. -push -( -HirFrame -: -: -Repetition -) -Ast -: -: Group ( ref @@ -3044,16 +2177,6 @@ HirFrame Alternation ) ; -self -. -push -( -HirFrame -: -: -AlternationBranch -) -; } _ = @@ -3268,106 +2391,67 @@ x = > { -match self . -ast_literal_to_scalar +push ( -x -) -? -{ -Either +HirFrame : : -Right +Expr ( -byte -) -= -> self . -push_byte +hir_literal ( -byte +x +) +? +) ) -Either +; +} +Ast : : -Left +Dot ( -ch +span ) = > { -if -! self . -flags -( -) -. -unicode -( -) -& -& -ch -. -len_utf8 +push ( -) -> -1 -{ -return -Err +HirFrame +: +: +Expr ( self . -error +hir_dot ( -x -. span -ErrorKind -: -: -UnicodeNotAllowed +) +? ) ) ; } -match -self -. -case_fold_char +Ast +: +: +Assertion ( +ref x -. -span -ch -) -? -{ -None -= -> -self -. -push_char -( -ch -) -Some -( -expr ) = > +{ self . push @@ -3377,87 +2461,9 @@ HirFrame : Expr ( -expr -) -) -} -} -} -/ -/ self . -push -( -HirFrame -: -: -Expr -( -self -. -hir_literal -( -x -) -? -) -) -; -} -Ast -: -: -Dot -( -span -) -= -> -{ -self -. -push -( -HirFrame -: -: -Expr -( -self -. -hir_dot -( -span -) -? -) -) -; -} -Ast -: -: -Assertion -( -ref -x -) -= -> -{ -self -. -push -( -HirFrame -: -: -Expr -( -self -. -hir_assertion +hir_assertion ( x ) @@ -3553,7 +2559,6 @@ hir_perl_byte_class ( x ) -? ; let hcls @@ -3716,6 +2721,35 @@ cls ) ? ; +if +cls +. +ranges +( +) +. +is_empty +( +) +{ +return +Err +( +self +. +error +( +ast +. +span +ErrorKind +: +: +EmptyClassNotAllowed +) +) +; +} let expr = @@ -3787,6 +2821,35 @@ cls ) ? ; +if +cls +. +ranges +( +) +. +is_empty +( +) +{ +return +Err +( +self +. +error +( +ast +. +span +ErrorKind +: +: +EmptyClassNotAllowed +) +) +; +} let expr = @@ -3852,20 +2915,6 @@ unwrap_expr ; self . -pop -( -) -. -unwrap -( -) -. -unwrap_repetition -( -) -; -self -. push ( HirFrame @@ -3953,7 +3002,7 @@ Expr ( self . -hir_capture +hir_group ( x expr @@ -3985,30 +3034,31 @@ while let Some ( +HirFrame +: +: +Expr +( expr ) +) = self . -pop_concat_expr +pop ( ) { if ! -matches -! -( -* expr . kind ( ) -HirKind -: -: -Empty +. +is_empty +( ) { exprs @@ -4069,29 +3119,21 @@ while let Some ( +HirFrame +: +: +Expr +( expr ) -= -self -. -pop_alt_expr -( ) -{ += self . pop ( ) -. -unwrap -( -) -. -unwrap_alternation_pipe -( -) -; +{ exprs . push @@ -4134,37 +3176,6 @@ Ok ) } fn -visit_alternation_in -( -& -mut -self -) -- -> -Result -< -( -) -> -{ -self -. -push -( -HirFrame -: -: -AlternationBranch -) -; -Ok -( -( -) -) -} -fn visit_class_set_item_pre ( & @@ -4930,7 +3941,6 @@ hir_perl_byte_class ( x ) -? ; let mut @@ -5977,111 +4987,36 @@ frame / / / -Push +Pop the -given -literal -char -on -to +top +of the call stack . -/ -/ -/ -/ -/ -/ If the -top -- -most -element -of -the +call stack is -a -literal -then -the -char -/ -/ -/ -is -appended -to -the -end -of -that -literal -. -Otherwise -a -new -literal -/ -/ -/ -containing -just -the -given -char -is -pushed -to -the -top -of -the -stack +empty +return +None . fn -push_char +pop ( & self -ch -: -char ) +- +> +Option +< +HirFrame +> { -let -mut -buf -= -[ -0 -; -4 -] -; -let -bytes -= -ch -. -encode_utf8 -( -& -mut -buf -) -. -as_bytes -( -) -; -let -mut -stack -= self . trans @@ -6093,266 +5028,294 @@ stack borrow_mut ( ) -; -if -let -Some -( -HirFrame -: -: -Literal -( -ref -mut -literal -) -) -= -stack -. -last_mut -( -) -{ -literal . -extend_from_slice +pop ( -bytes ) -; } -else -{ -stack +/ +/ +/ +Create +a +new +error +with +the +given +span +and +error +type . -push +fn +error ( -HirFrame +& +self +span : +Span +kind : -Literal -( -bytes +ErrorKind +) +- +> +Error +{ +Error +{ +kind +pattern +: +self +. +pattern . -to_vec +to_string ( ) -) -) -; +span } } / / / -Push -the -given -literal -byte -on -to +Return +a +copy +of the -call -stack +active +flags . +fn +flags +( +& +self +) +- +> +Flags +{ +self +. +trans +( +) +. +flags +. +get +( +) +} / / / -/ -/ -/ -If +Set the -top -- -most -element +flags of +this +translator +from the -stack -is -a -literal -then -the -byte -/ -/ -/ -is -appended -to +flags +set +in the -end -of -that -literal +given +AST . -Otherwise -a -new -literal / / / -containing -just -the -given -byte -is -pushed -to -the -top -of +Then +return the -stack +old +flags . fn -push_byte +set_flags ( & self -byte +ast_flags : -u8 +& +ast +: +: +Flags ) +- +> +Flags { let -mut -stack +old_flags = self . -trans -( -) -. -stack -. -borrow_mut +flags ( ) ; -if let -Some -( -HirFrame +mut +new_flags += +Flags : : -Literal +from_ast ( -ref -mut -literal +ast_flags ) +; +new_flags +. +merge +( +& +old_flags ) -= -stack +; +self . -last_mut +trans ( ) -{ -literal . -push +flags +. +set ( -byte +new_flags ) ; +old_flags } -else +fn +hir_literal +( +& +self +lit +: +& +ast +: +: +Literal +) +- +> +Result +< +Hir +> { -stack +let +ch += +match +self . -push +literal_to_char ( -HirFrame +lit +) +? +{ +byte +hir : : Literal +: +: +Byte +( +_ +) += +> +return +Ok +( +Hir +: +: +literal ( -vec -! -[ byte -] ) ) -; -} -} -/ -/ -/ -Pop -the -top -of -the -call -stack -. -If -the -call -stack -is -empty -return -None -. -fn -pop +hir +: +: +Literal +: +: +Unicode ( -& -self +ch ) -- -> -Option -< -HirFrame += > -{ +ch +} +; +if self . -trans +flags ( ) . -stack +case_insensitive +( +) +{ +self . -borrow_mut +hir_from_char_case_insensitive ( +lit +. +span +ch ) +} +else +{ +self . -pop +hir_from_char ( +lit +. +span +ch ) } +} / / / -Pop +Convert an -HIR -expression -from -the -top -of -the -stack -for -a -concatenation +Ast +literal +to +its +scalar +representation . / / @@ -6360,2198 +5323,1807 @@ concatenation / / / -This +When +Unicode +mode +is +enabled +then +this +always +succeeds +and returns -None -if -the -stack +a +/ +/ +/ +char +( +Unicode +scalar +value +) +. +/ +/ +/ +/ +/ +/ +When +Unicode +mode is -empty -or -when +disabled +then a -concat -frame +raw +byte is -seen +returned . +If +that / / / -Otherwise -it -panics -if -it -could +byte +is not -find +ASCII +and +invalid +UTF +- +8 +is +not +allowed +then +this +returns +/ +/ +/ an -HIR -expression +error . fn -pop_concat_expr +literal_to_char ( & self +lit +: +& +ast +: +: +Literal ) - > -Option +Result < -Hir +hir +: +: +Literal > { -let -frame -= +if self . -pop +flags +( +) +. +unicode ( ) -? -; -match -frame { -HirFrame +return +Ok +( +hir : : -Concat -= -> -None -HirFrame +Literal : : -Expr +Unicode ( -expr +lit +. +c ) -= -> -Some -( -expr ) -HirFrame -: -: -Literal -( +; +} +let +byte += +match lit +. +byte +( ) +{ +None = > -Some +return +Ok ( -Hir +hir : : -literal +Literal +: +: +Unicode ( lit +. +c ) ) -HirFrame -: -: -ClassUnicode +Some ( -_ +byte ) = > +byte +} +; +if +byte +< += +0x7F { -unreachable -! +return +Ok ( -" -expected -expr -or -concat -got -Unicode -class -" -) -} -HirFrame +hir : : -ClassBytes -( -_ -) -= -> -{ -unreachable -! +Literal +: +: +Unicode ( -" -expected -expr -or -concat -got byte -class -" +as +char +) ) +; } -HirFrame -: -: -Repetition -= -> -{ -unreachable +if ! +self +. +trans ( -" -expected -expr -or -concat -got -repetition -" ) -} -HirFrame -: -: -Group -{ -. . -} -= -> +allow_invalid_utf8 { -unreachable -! +return +Err ( -" -expected -expr -or -concat -got -group -" -) -} -HirFrame +self +. +error +( +lit +. +span +ErrorKind : : -Alternation -= -> -{ -unreachable -! -( -" -expected -expr -or -concat -got -alt -marker -" +InvalidUtf8 +) ) +; } -HirFrame +Ok +( +hir : : -AlternationBranch -= -> -{ -unreachable -! +Literal +: +: +Byte ( -" -expected -expr -or -concat -got -alt -branch -marker -" +byte +) ) } -} -} -/ -/ -/ -Pop -an -HIR -expression -from -the -top -of -the -stack -for -an -alternation -. -/ -/ -/ -/ -/ -/ -This -returns -None -if -the -stack -is -empty -or -when -an -alternation -frame -is -/ -/ -/ -seen -. -Otherwise -it -panics -if -it -could -not -find -an -HIR -expression -. fn -pop_alt_expr +hir_from_char ( & self +span +: +Span +c +: +char ) - > -Option +Result < Hir > { -let -frame -= +if +! self . -pop +flags ( ) -? -; -match -frame -{ -HirFrame -: -: -Alternation -= -> -None -HirFrame -: -: -Expr +. +unicode ( -expr ) -= -> -Some -( -expr -) -HirFrame -: -: -Literal +& +& +c +. +len_utf8 ( -lit ) -= > -Some +1 +{ +return +Err ( -Hir -: -: -literal +self +. +error ( -lit -) -) -HirFrame +span +ErrorKind : : -ClassUnicode -( -_ +UnicodeNotAllowed ) -= -> -{ -unreachable -! -( -" -expected -expr -or -alt -got -Unicode -class -" ) +; } -HirFrame -: -: -ClassBytes -( -_ -) -= -> -{ -unreachable -! +Ok ( -" -expected -expr -or -alt -got -byte -class -" -) -} -HirFrame +Hir : : -Repetition -= -> -{ -unreachable -! +literal ( -" -expected -expr -or -alt -got -repetition -" -) -} -HirFrame +hir : : -Group -{ -. -. -} -= -> -{ -unreachable -! -( -" -expected -expr -or -alt -got -group -" -) -} -HirFrame +Literal : : -Concat -= -> -{ -unreachable -! +Unicode ( -" -expected -expr -or -alt -got -concat -marker -" +c +) ) -} -HirFrame -: -: -AlternationBranch -= -> -{ -unreachable -! -( -" -expected -expr -or -alt -got -alt -branch -marker -" ) } -} -} -/ -/ -/ -Create -a -new -error -with -the -given -span -and -error -type -. fn -error +hir_from_char_case_insensitive ( & self span : Span -kind +c : -ErrorKind +char ) - > -Error -{ -Error +Result +< +Hir +> { -kind -pattern -: +if self . -pattern +flags +( +) . -to_string +unicode ( ) -span -} -} -/ +{ / / -Return -a -copy -of -the -active -flags +If +case +folding +won +' +t +do +anything +then +don +' +t +bother +trying . -fn -flags +let +map += +unicode +: +: +contains_simple_case_mapping ( -& -self +c +c ) -- -> -Flags +. +map_err +( +| +_ +| { self . -trans +error ( +span +ErrorKind +: +: +UnicodeCaseUnavailable ) +} +) +? +; +if +! +map +{ +return +self . -flags -. -get +hir_from_char ( +span +c ) +; } -/ -/ -/ -Set -the -flags -of -this -translator -from -the -flags -set -in -the -given -AST +let +mut +cls += +hir +: +: +ClassUnicode +: +: +new +( +vec +! +[ +hir +: +: +ClassUnicodeRange +: +: +new +( +c +c +) +] +) +; +cls . -/ -/ -/ -Then -return -the -old -flags +try_case_fold_simple +( +) . -fn -set_flags +map_err ( -& +| +_ +| +{ self -ast_flags +. +error +( +span +ErrorKind : -& -ast : +UnicodeCaseUnavailable +) +} +) +? +; +Ok +( +Hir : -Flags +: +class +( +hir +: +: +Class +: +: +Unicode +( +cls +) +) +) +} +else +{ +if +c +. +len_utf8 +( ) -- > -Flags +1 { -let -old_flags -= +return +Err +( self . -flags +error ( +span +ErrorKind +: +: +UnicodeNotAllowed +) ) ; +} +/ +/ +If +case +folding +won +' +t +do +anything +then +don +' +t +bother +trying +. +match +c +{ +' +A +' +. +. += +' +Z +' +| +' +a +' +. +. += +' +z +' += +> +{ +} +_ += +> +return +self +. +hir_from_char +( +span +c +) +} let mut -new_flags +cls = -Flags +hir : : -from_ast +ClassBytes +: +: +new ( -ast_flags +vec +! +[ +hir +: +: +ClassBytesRange +: +: +new +( +c +as +u8 +c +as +u8 +) +] ) ; -new_flags +cls . -merge +case_fold_simple ( -& -old_flags ) ; -self -. -trans +Ok +( +Hir +: +: +class +( +hir +: +: +Class +: +: +Bytes +( +cls +) +) +) +} +} +fn +hir_dot ( +& +self +span +: +Span ) +- +> +Result +< +Hir +> +{ +let +unicode += +self . flags +( +) . -set +unicode ( -new_flags ) ; -old_flags -} -/ -/ -/ -Convert -an -Ast -literal -to -its -scalar -representation -. -/ -/ -/ -/ -/ -/ -When -Unicode -mode -is -enabled -then -this -always -succeeds -and -returns -a -/ -/ -/ -char -( -Unicode -scalar -value -) -. -/ -/ -/ -/ -/ -/ -When -Unicode -mode -is -disabled -then -a -char -will -still -be -returned -/ -/ -/ -whenever -possible -. -A -byte -is -returned -only -when -invalid -UTF -- -8 -is -/ -/ -/ -allowed -and -when -the -byte -is -not -ASCII -. -Otherwise -a -non -- -ASCII -byte -/ -/ -/ -will -result -in -an -error -when -invalid -UTF -- -8 -is -not -allowed -. -fn -ast_literal_to_scalar -( +if +! +unicode & -self -lit -: & -ast -: -: -Literal -) -- -> -Result -< -Either -< -char -u8 -> -> -{ -if +! self . -flags +trans ( ) . -unicode -( -) +allow_invalid_utf8 { return -Ok -( -Either -: -: -Left +Err ( -lit -. -c -) -) -; -} -let -byte -= -match -lit +self . -byte -( -) -{ -None -= -> -return -Ok +error ( -Either +span +ErrorKind : : -Left -( -lit -. -c -) +InvalidUtf8 ) -Some -( -byte ) -= -> -byte -} ; -if -byte -< -= -0x7F -{ -return +} Ok ( -Either -: -: -Left -( -char -: -: -try_from -( -byte -) -. -unwrap -( -) -) -) -; -} if self . -trans +flags ( ) . -utf8 -{ -return -Err -( -self -. -error +dot_matches_new_line ( -lit -. -span -ErrorKind +) +{ +Hir : : -InvalidUtf8 -) +any +( +! +unicode ) -; } -Ok -( -Either +else +{ +Hir : : -Right +dot ( -byte +! +unicode ) +} ) } fn -case_fold_char +hir_assertion ( & self -span +asst : -Span -c +& +ast : -char +: +Assertion ) - > Result < -Option -< Hir > -> { -if -! +let +unicode += self . flags ( ) . -case_insensitive -( -) -{ -return -Ok +unicode ( -None ) ; -} -if +let +multi_line += self . flags ( ) . -unicode +multi_line ( ) -{ -/ -/ -If -case -folding -won -' -t -do -anything -then -don -' -t -bother -trying +; +Ok +( +match +asst . -let -map -= -unicode +kind +{ +ast : : -SimpleCaseFolder +AssertionKind : : -new -( -) -. -map -( -| -f -| -f -. -overlaps -( -c -c -) -) -. -map_err +StartLine += +> +Hir +: +: +anchor ( -| -_ -| +if +multi_line { -self -. -error -( -span -ErrorKind +hir : : -UnicodeCaseUnavailable -) +Anchor +: +: +StartLine } -) -? -; -if -! -map +else { -return -Ok -( -None -) -; +hir +: +: +Anchor +: +: +StartText } -let -mut -cls +) +ast +: +: +AssertionKind +: +: +EndLine = +> +Hir +: +: +anchor +( +if +multi_line +{ hir : : -ClassUnicode +Anchor : : -new -( -vec -! -[ +EndLine +} +else +{ hir : : -ClassUnicodeRange +Anchor : : -new -( -c -c -) -] -) -; -cls -. -try_case_fold_simple -( +EndText +} ) -. -map_err -( -| -_ -| +ast +: +: +AssertionKind +: +: +StartText += +> { -self -. -error +Hir +: +: +anchor ( -span -ErrorKind +hir : : -UnicodeCaseUnavailable +Anchor +: +: +StartText ) } -) -? -; -Ok -( -Some +ast +: +: +AssertionKind +: +: +EndText += +> +Hir +: +: +anchor ( +hir +: +: +Anchor +: +: +EndText +) +ast +: +: +AssertionKind +: +: +WordBoundary += +> +{ Hir : : -class +word_boundary ( +if +unicode +{ hir : : -Class +WordBoundary : : Unicode -( -cls -) -) -) -) } else { -if -c -. -len_utf8 -( +hir +: +: +WordBoundary +: +: +Ascii +} ) +} +ast +: +: +AssertionKind +: +: +NotWordBoundary += > -1 { -return -Err -( -self -. -error -( -span -ErrorKind +Hir : : -UnicodeNotAllowed -) -) -; +word_boundary +( +if +unicode +{ +hir +: +: +WordBoundary +: +: +UnicodeNegate } +else +{ +/ +/ +It +is +possible +for +negated +ASCII +word +boundaries +to / / -If -case -folding -won -' -t -do -anything -then -don -' -t -bother -trying -. match -c -{ -' -A -' -. +at +invalid +UTF +- +8 +boundaries +even +when +searching +/ +/ +valid +UTF +- +8 . -= -' -Z -' -| -' -a -' +if +! +self . +trans +( +) . -= -' -z -' -= -> +allow_invalid_utf8 { -} -_ -= -> return -Ok +Err ( -None +self +. +error +( +asst +. +span +ErrorKind +: +: +InvalidUtf8 ) +) +; } -let -mut -cls -= hir : : -ClassBytes +WordBoundary : : -new +AsciiNegate +} +) +} +} +) +} +fn +hir_group ( -vec -! -[ -hir +& +self +group : +& +ast : -ClassBytesRange : +Group +expr : -new -( -/ -/ -OK -because -' -c -. -len_utf8 -( +Hir ) +- +> +Hir +{ +let +kind = -= -1 -' -which -in -turn -implies -/ -/ -that -' -c -' -is -ASCII +match +group . -u8 +kind +{ +ast +: +: +GroupKind : : -try_from +CaptureIndex ( -c +idx ) -. -unwrap += +> +{ +hir +: +: +GroupKind +: +: +CaptureIndex ( +idx ) -u8 +} +ast +: +: +GroupKind : : -try_from +CaptureName ( -c +ref +capname ) += +> +{ +hir +: +: +GroupKind +: +: +CaptureName +{ +name +: +capname . -unwrap +name +. +clone ( ) -) -] -) -; -cls +index +: +capname . -case_fold_simple +index +} +} +ast +: +: +GroupKind +: +: +NonCapturing ( +_ ) += +> +hir +: +: +GroupKind +: +: +NonCapturing +} ; -Ok -( -Some -( Hir : : -class +group ( hir : : -Class +Group +{ +kind +hir +: +Box : : -Bytes +new ( -cls -) -) -) +expr ) } +) } fn -hir_dot +hir_repetition ( & self -span +rep : -Span +& +ast +: +: +Repetition +expr +: +Hir ) - > -Result -< Hir -> { let -( -utf8 -lineterm -flags -) +kind = -( -self -. -trans -( -) -. -utf8 -self -. -trans -( -) -. -line_terminator -self -. -flags -( -) -) -; -if -utf8 -& -& -( -! -flags +match +rep . -unicode -( -) -| -| -! -lineterm +op . -is_ascii -( -) -) +kind { -return -Err -( -self -. -error -( -span -ErrorKind +ast : : -InvalidUtf8 -) -) -; -} -let -dot +RepetitionKind +: +: +ZeroOrOne = -if -flags -. -dot_matches_new_line -( -) -{ -if -flags -. -unicode -( -) -{ +> hir : : -Dot +RepetitionKind : : -AnyChar -} -else -{ +ZeroOrOne +ast +: +: +RepetitionKind +: +: +ZeroOrMore += +> hir : : -Dot +RepetitionKind : : -AnyByte -} -} -else -{ -if -flags -. -unicode +ZeroOrMore +ast +: +: +RepetitionKind +: +: +OneOrMore += +> +hir +: +: +RepetitionKind +: +: +OneOrMore +ast +: +: +RepetitionKind +: +: +Range ( -) -{ -if -flags -. -crlf +ast +: +: +RepetitionRange +: +: +Exactly ( +m ) +) += +> { hir : : -Dot +RepetitionKind : : -AnyCharExceptCRLF -} -else -{ -if -! -lineterm -. -is_ascii -( -) -{ -return -Err -( -self -. -error +Range ( -span -ErrorKind +hir : : -InvalidLineTerminator +RepetitionRange +: +: +Exactly +( +m ) ) -; } -hir +ast : : -Dot +RepetitionKind : : -AnyCharExcept +Range ( -char +ast : : -from +RepetitionRange +: +: +AtLeast ( -lineterm -) +m ) -} -} -else -{ -if -flags -. -crlf -( ) += +> { hir : : -Dot +RepetitionKind : : -AnyByteExceptCRLF -} -else -{ +Range +( hir : : -Dot +RepetitionRange : : -AnyByteExcept +AtLeast ( -lineterm +m +) ) } -} -} -; -Ok -( -Hir +ast : : -dot -( -dot -) -) -} -fn -hir_assertion -( -& -self -asst +RepetitionKind : -& +: +Range +( ast : : -Assertion +RepetitionRange +: +: +Bounded +( +m +n ) -- -> -Result -< -Hir +) += > { -let -unicode -= -self -. -flags -( -) -. -unicode +hir +: +: +RepetitionKind +: +: +Range ( -) -; -let -multi_line -= -self -. -flags +hir +: +: +RepetitionRange +: +: +Bounded ( +m +n ) -. -multi_line -( ) +} +} ; let -crlf +greedy = +if self . flags ( ) . -crlf +swap_greed ( ) -; -Ok -( -match -asst +{ +! +rep . -kind +greedy +} +else { -ast -: -: -AssertionKind -: -: -StartLine -= -> +rep +. +greedy +} +; Hir : : -look +repetition ( -if -multi_line -{ -if -crlf -{ hir : : -Look -: -: -StartCRLF -} -else +Repetition { +kind +greedy hir : -: -Look +Box : : -StartLF +new +( +expr +) } +) } -else -{ -hir -: -: -Look -: +fn +hir_unicode_class +( +& +self +ast_class : -Start -} -) +& ast : : -AssertionKind -: -: -EndLine -= +ClassUnicode +) +- > -Hir -: -: -look -( -if -multi_line -{ -if -crlf -{ +Result +< hir : : -Look -: -: -EndCRLF -} -else +ClassUnicode +> { -hir +use +crate : : -Look +ast : : -EndLF -} -} -else -{ -hir +ClassUnicodeKind : : -Look +* +; +if +! +self +. +flags +( +) +. +unicode +( +) +{ +return +Err +( +self +. +error +( +ast_class +. +span +ErrorKind : : -End +UnicodeNotAllowed +) +) +; } +let +query += +match +ast_class +. +kind +{ +OneLetter +( +name ) -ast -: -: -AssertionKind -: -: -StartText = > -Hir +ClassQuery : : -look +OneLetter ( -hir -: -: -Look -: -: -Start +name +) +Named +( +ref +name ) -ast -: -: -AssertionKind -: -: -EndText = > -Hir +ClassQuery : : -look +Binary ( -hir -: -: -Look -: -: -End +name ) -ast -: -: -AssertionKind -: -: -WordBoundary +NamedValue +{ +ref +name +ref +value +. +. +} = > -Hir +ClassQuery : : -look -( -if -unicode +ByValue { -hir -: -: -Look +property_name : +name +property_value : -WordUnicode +value } -else -{ -hir -: -: -Look -: -: -WordAscii } -) -ast -: -: -AssertionKind -: -: -NotWordBoundary +; +let +mut +result = -> -Hir +self +. +convert_unicode_class_error +( +& +ast_class +. +span +unicode : : -look +class ( +query +) +) +; if -unicode +let +Ok +( +ref +mut +class +) += +result { -hir -: -: -Look -: -: -WordUnicodeNegate -} -else +self +. +unicode_fold_and_negate +( +& +ast_class +. +span +ast_class +. +negated +class +) +? +; +if +class +. +ranges +( +) +. +is_empty +( +) { -hir -: -: -Look +let +err += +self +. +error +( +ast_class +. +span +ErrorKind : : -WordAsciiNegate -} +EmptyClassNotAllowed ) -} +; +return +Err +( +err ) +; +} +} +result } fn -hir_capture +hir_ascii_unicode_class ( & self -group +ast : & ast : : -Group -expr -: -Hir +ClassAscii ) - > -Hir +Result +< +hir +: +: +ClassUnicode +> { let -( -index -name -) +mut +cls = -match -group -. -kind -{ -ast +hir : : -GroupKind +ClassUnicode : : -CaptureIndex +new ( -index +ascii_class +( +& +ast +. +kind ) -= -> +. +iter ( -index -None ) -ast +. +map +( +| +& +( +s +e +) +| +hir : : -GroupKind +ClassUnicodeRange : : -CaptureName -{ -ref -name -. -. -} -= -> -{ +new ( -name +s +e +) +) +) +; +self . -index -Some +unicode_fold_and_negate ( -name +& +ast . -name +span +ast . -clone -( +negated +& +mut +cls ) -. -into_boxed_str +? +; +Ok ( -) -) +cls ) } -/ -/ -The -HIR -doesn -' -t -need -to -use -non -- -capturing -groups -since -the -way -/ -/ -in -which -the -data -type -is -defined -handles -this -automatically -. +fn +hir_ascii_byte_class +( +& +self ast : -: -GroupKind +& +ast : : -NonCapturing -( -_ +ClassAscii ) -= +- > -return -expr -} -; -Hir +Result +< +hir : : -capture -( +ClassBytes +> +{ +let +mut +cls += hir : : -Capture -{ -index -name -sub -: -Box +ClassBytes : : new ( -expr -) -} -) -} -fn -hir_repetition +ascii_class ( & -self -rep -: -& ast -: -: -Repetition -expr -: -Hir -) -- -> -Hir -{ -let -( -min -max -) -= -match -rep -. -op . kind -{ -ast -: -: -RepetitionKind -: -: -ZeroOrOne -= -> -( -0 -Some -( -1 -) -) -ast -: -: -RepetitionKind -: -: -ZeroOrMore -= -> -( -0 -None -) -ast -: -: -RepetitionKind -: -: -OneOrMore -= -> -( -1 -None -) -ast -: -: -RepetitionKind -: -: -Range -( -ast -: -: -RepetitionRange -: -: -Exactly -( -m ) -) -= -> -{ -( -m -Some +. +iter ( -m ) -) -} -ast -: -: -RepetitionKind -: -: -Range -( -ast -: -: -RepetitionRange -: -: -AtLeast +. +map ( -m -) -) -= -> -{ +| +& ( -m -None +s +e ) -} -ast -: -: -RepetitionKind -: -: -Range -( -ast +| +hir : : -RepetitionRange +ClassBytesRange : : -Bounded +new ( -m -n -) +s +as +u8 +e +as +u8 ) -= -> -( -m -Some -( -n ) ) -} ; -let -greedy -= -if self . -flags -( -) -. -swap_greed +bytes_fold_and_negate ( -) -{ -! -rep +& +ast . -greedy -} -else -{ -rep +span +ast . -greedy -} +negated +& +mut +cls +) +? ; -Hir -: -: -repetition -( -hir -: -: -Repetition -{ -min -max -greedy -sub -: -Box -: -: -new +Ok ( -expr -) -} +cls ) } fn -hir_unicode_class +hir_perl_unicode_class ( & self @@ -8561,7 +7133,7 @@ ast_class ast : : -ClassUnicode +ClassPerl ) - > @@ -8580,13 +7152,14 @@ crate ast : : -ClassUnicodeKind +ClassPerlKind : : * ; -if +assert ! +( self . flags @@ -8596,88 +7169,48 @@ flags unicode ( ) -{ -return -Err -( -self -. -error -( -ast_class -. -span -ErrorKind -: -: -UnicodeNotAllowed -) ) ; -} let -query +result = match ast_class . kind { -OneLetter -( -name -) +Digit = > -ClassQuery +unicode : : -OneLetter -( -name -) -Named +perl_digit ( -ref -name ) +Space = > -ClassQuery +unicode : : -Binary +perl_space ( -name ) -NamedValue -{ -ref -name -ref -value -. -. -} +Word = > -ClassQuery -: -: -ByValue -{ -property_name +unicode : -name -property_value : -value -} +perl_word +( +) } ; let mut -result +class = self . @@ -8687,319 +7220,152 @@ convert_unicode_class_error ast_class . span -unicode -: -: -class -( -query -) +result ) +? ; -if -let -Ok -( -ref -mut -class -) -= -result -{ -self -. -unicode_fold_and_negate -( -& -ast_class +/ +/ +We +needn +' +t +apply +case +folding +here +because +the +Perl +Unicode +classes +/ +/ +are +already +closed +under +Unicode +simple +case +folding . -span +if ast_class . negated +{ class +. +negate +( ) -? ; } -result +Ok +( +class +) } fn -hir_ascii_unicode_class +hir_perl_byte_class ( & self -ast +ast_class : & ast : : -ClassAscii +ClassPerl ) - > -Result -< hir : : -ClassUnicode -> +ClassBytes { -let -mut -cls -= -hir -: -: -ClassUnicode +use +crate : : -new -( -ascii_class_as_chars -( -& ast -. -kind -) -. -map -( -| -( -s -e -) -| -hir : : -ClassUnicodeRange +ClassPerlKind : : -new -( -s -e -) -) -) +* ; +assert +! +( +! self . -unicode_fold_and_negate +flags ( -& -ast -. -span -ast -. -negated -& -mut -cls ) -? -; -Ok +. +unicode ( -cls ) -} -fn -hir_ascii_byte_class +) +; +let +mut +class += +match +ast_class +. +kind +{ +Digit += +> +hir_ascii_class_bytes ( & -self -ast -: -& ast : : -ClassAscii -) -- -> -Result -< -hir +ClassAsciiKind : : -ClassBytes -> -{ -let -mut -cls +Digit +) +Space = -hir +> +hir_ascii_class_bytes +( +& +ast : : -ClassBytes +ClassAsciiKind : : -new -( -ascii_class +Space +) +Word += +> +hir_ascii_class_bytes ( & ast -. -kind -) -. -map -( -| -( -s -e -) -| -hir : : -ClassBytesRange +ClassAsciiKind : : -new -( -s -e -) -) +Word ) -; -self -. -bytes_fold_and_negate -( -& -ast -. -span -ast -. -negated -& -mut -cls -) -? -; -Ok -( -cls -) -} -fn -hir_perl_unicode_class -( -& -self -ast_class -: -& -ast -: -: -ClassPerl -) -- -> -Result -< -hir -: -: -ClassUnicode -> -{ -use -crate -: -: -ast -: -: -ClassPerlKind -: -: -* -; -assert -! -( -self -. -flags -( -) -. -unicode -( -) -) -; -let -result -= -match -ast_class -. -kind -{ -Digit -= -> -unicode -: -: -perl_digit -( -) -Space -= -> -unicode -: -: -perl_space -( -) -Word -= -> -unicode -: -: -perl_word -( -) -} -; -let -mut -class -= -self -. -convert_unicode_class_error -( -& -ast_class -. -span -result -) -? +} ; / / @@ -9014,18 +7380,19 @@ here because the Perl -Unicode +ASCII classes / / are already closed +( under -Unicode -simple +ASCII case folding +) . if ast_class @@ -9039,23 +7406,67 @@ negate ) ; } -Ok -( class -) } +/ +/ +/ +Converts +the +given +Unicode +specific +error +to +an +HIR +translation +error +. +/ +/ +/ +/ +/ +/ +The +span +given +should +approximate +the +position +at +which +an +error +would +/ +/ +/ +occur +. fn -hir_perl_byte_class +convert_unicode_class_error ( & self -ast_class +span : & -ast +Span +result +: +unicode : : -ClassPerl +Result +< +hir +: +: +ClassUnicode +> ) - > @@ -9064,319 +7475,45 @@ Result hir : : -ClassBytes +ClassUnicode > { -use -crate -: -: -ast -: -: -ClassPerlKind -: -: -* -; -assert -! -( -! -self +result . -flags +map_err ( -) +| +err +| +{ +let +sp += +span . -unicode +clone ( ) -) ; -let -mut -class -= match -ast_class -. -kind +err { -Digit -= -> -hir_ascii_class_bytes -( -& -ast +unicode : : -ClassAsciiKind +Error : : -Digit -) -Space +PropertyNotFound = > -hir_ascii_class_bytes +{ +self +. +error ( -& -ast -: -: -ClassAsciiKind -: -: -Space -) -Word -= -> -hir_ascii_class_bytes -( -& -ast -: -: -ClassAsciiKind -: -: -Word -) -} -; -/ -/ -We -needn -' -t -apply -case -folding -here -because -the -Perl -ASCII -classes -/ -/ -are -already -closed -( -under -ASCII -case -folding -) -. -if -ast_class -. -negated -{ -class -. -negate -( -) -; -} -/ -/ -Negating -a -Perl -byte -class -is -likely -to -cause -it -to -match -invalid -/ -/ -UTF -- -8 -. -That -' -s -only -OK -if -the -translator -is -configured -to -allow -such -/ -/ -things -. -if -self -. -trans -( -) -. -utf8 -& -& -! -class -. -is_ascii -( -) -{ -return -Err -( -self -. -error -( -ast_class -. -span -ErrorKind -: -: -InvalidUtf8 -) -) -; -} -Ok -( -class -) -} -/ -/ -/ -Converts -the -given -Unicode -specific -error -to -an -HIR -translation -error -. -/ -/ -/ -/ -/ -/ -The -span -given -should -approximate -the -position -at -which -an -error -would -/ -/ -/ -occur -. -fn -convert_unicode_class_error -( -& -self -span -: -& -Span -result -: -core -: -: -result -: -: -Result -< -hir -: -: -ClassUnicode -unicode -: -: -Error -> -) -- -> -Result -< -hir -: -: -ClassUnicode -> -{ -result -. -map_err -( -| -err -| -{ -let -sp -= -span -. -clone -( -) -; -match -err -{ -unicode -: -: -Error -: -: -PropertyNotFound -= -> -{ -self -. -error -( -sp -ErrorKind +sp +ErrorKind : : UnicodePropertyNotFound @@ -9485,7 +7622,7 @@ If we applied negation -first +field then / / @@ -9669,19 +7806,20 @@ negate ; } if +! self . trans ( ) . -utf8 +allow_invalid_utf8 & & ! class . -is_ascii +is_all_ascii ( ) { @@ -9757,16 +7895,19 @@ u8 match self . -ast_literal_to_scalar +literal_to_char ( ast ) ? { -Either +hir +: +: +Literal : : -Right +Byte ( byte ) @@ -9776,46 +7917,32 @@ Ok ( byte ) -Either +hir +: +: +Literal : : -Left +Unicode ( ch ) = > { -let -cp -= -u32 -: -: -from -( -ch -) -; if -cp +ch < = 0x7F +as +char { Ok ( +ch +as u8 -: -: -try_from -( -cp -) -. -unwrap -( -) ) } else @@ -9964,12 +8091,6 @@ Option < bool > -crlf -: -Option -< -bool -> / / Note @@ -10212,35 +8333,6 @@ ast Flag : : -CRLF -) -= -> -{ -flags -. -crlf -= -Some -( -enable -) -; -} -ast -: -: -FlagsItemKind -: -: -Flag -( -ast -: -: -Flag -: -: IgnoreWhitespace ) = @@ -10353,24 +8445,6 @@ previous unicode ; } -if -self -. -crlf -. -is_none -( -) -{ -self -. -crlf -= -previous -. -crlf -; -} } fn case_insensitive @@ -10467,25 +8541,6 @@ unwrap_or true ) } -fn -crlf -( -& -self -) -- -> -bool -{ -self -. -crlf -. -unwrap_or -( -false -) -} } fn hir_ascii_class_bytes @@ -10518,6 +8573,14 @@ ascii_class kind ) . +iter +( +) +. +cloned +( +) +. map ( | @@ -10535,7 +8598,11 @@ ClassBytesRange new ( s +as +u8 e +as +u8 ) ) . @@ -10567,16 +8634,15 @@ ClassAsciiKind ) - > -impl -Iterator -< -Item -= +& +' +static +[ ( -u8 -u8 +char +char ) -> +] { use crate @@ -10590,19 +8656,6 @@ ClassAsciiKind : * ; -let -slice -: -& -' -static -[ -( -u8 -u8 -) -] -= match * kind @@ -10613,31 +8666,25 @@ Alnum & [ ( -b ' 0 ' -b ' 9 ' ) ( -b ' A ' -b ' Z ' ) ( -b ' a ' -b ' z ' @@ -10649,21 +8696,17 @@ Alpha & [ ( -b ' A ' -b ' Z ' ) ( -b ' a ' -b ' z ' @@ -10675,12 +8718,10 @@ Ascii & [ ( -b ' \ x00 ' -b ' \ x7F @@ -10693,22 +8734,18 @@ Blank & [ ( -b ' \ t ' -b ' \ t ' ) ( -b ' ' -b ' ' ) @@ -10719,24 +8756,20 @@ Cntrl & [ ( -b ' \ x00 ' -b ' \ x1F ' ) ( -b ' \ x7F ' -b ' \ x7F @@ -10749,11 +8782,9 @@ Digit & [ ( -b ' 0 ' -b ' 9 ' @@ -10765,11 +8796,9 @@ Graph & [ ( -b ' ! ' -b ' ~ ' @@ -10781,11 +8810,9 @@ Lower & [ ( -b ' a ' -b ' z ' @@ -10797,10 +8824,8 @@ Print & [ ( -b ' ' -b ' ~ ' @@ -10812,39 +8837,31 @@ Punct & [ ( -b ' ! ' -b ' / ' ) ( -b ' : ' -b ' ' ) ( -b ' [ ' -b ' ' ) ( -b ' { ' -b ' ~ ' @@ -10856,70 +8873,58 @@ Space & [ ( -b ' \ t ' -b ' \ t ' ) ( -b ' \ n ' -b ' \ n ' ) ( -b ' \ x0B ' -b ' \ x0B ' ) ( -b ' \ x0C ' -b ' \ x0C ' ) ( -b ' \ r ' -b ' \ r ' ) ( -b ' ' -b ' ' ) @@ -10930,11 +8935,9 @@ Upper & [ ( -b ' A ' -b ' Z ' @@ -10946,41 +8949,33 @@ Word & [ ( -b ' 0 ' -b ' 9 ' ) ( -b ' A ' -b ' Z ' ) ( -b ' _ ' -b ' _ ' ) ( -b ' a ' -b ' z ' @@ -10992,102 +8987,31 @@ Xdigit & [ ( -b ' 0 ' -b ' 9 ' ) ( -b ' A ' -b ' F ' ) ( -b ' a ' -b ' f ' ) ] } -; -slice -. -iter -( -) -. -copied -( -) -} -fn -ascii_class_as_chars -( -kind -: -& -ast -: -: -ClassAsciiKind -) -- -> -impl -Iterator -< -Item -= -( -char -char -) -> -{ -ascii_class -( -kind -) -. -map -( -| -( -s -e -) -| -( -char -: -: -from -( -s -) -char -: -: -from -( -e -) -) -) } # [ @@ -11103,30 +9027,45 @@ use crate : : -{ ast : : -{ -self parse : : ParserBuilder -Ast -Position -Span -} -hir +; +use +crate +: +: +ast +: +: +{ +self +Ast +Position +Span +} +; +use +crate +: +: +hir : : { self Hir HirKind -Look -Properties } +; +use +crate +: +: unicode : : @@ -11134,13 +9073,15 @@ unicode self ClassQuery } -} ; use super : : -* +{ +ascii_class +TranslatorBuilder +} ; / / @@ -11362,9 +9303,9 @@ new ( ) . -utf8 +allow_invalid_utf8 ( -true +false ) . build @@ -11407,9 +9348,9 @@ new ( ) . -utf8 +allow_invalid_utf8 ( -true +false ) . build @@ -11449,9 +9390,9 @@ new ( ) . -utf8 +allow_invalid_utf8 ( -false +true ) . build @@ -11473,102 +9414,185 @@ unwrap ) } fn -props +hir_lit ( -pattern +s : & str ) - > -Properties +Hir { -t +match +s +. +len ( -pattern ) -. -properties +{ +0 += +> +Hir +: +: +empty ( ) +_ += +> +{ +let +lits += +s . -clone +chars ( ) -} -fn -props_bytes +. +map ( -pattern +hir : -& -str +: +Literal +: +: +Unicode ) -- -> -Properties -{ -t_bytes +. +map ( -pattern +Hir +: +: +literal ) . -properties +collect ( ) -. -clone +; +Hir +: +: +concat ( +lits ) } +} +} fn -hir_lit +hir_blit ( s : & -str +[ +u8 +] ) - > Hir { -hir_blit -( +match s . -as_bytes +len ( ) +{ +0 += +> +Hir +: +: +empty +( ) -} -fn -hir_blit +1 += +> +Hir +: +: +literal ( -s +hir : -& +: +Literal +: +: +Byte +( +s [ -u8 +0 ] ) -- +) +_ += > -Hir { +let +lits += +s +. +iter +( +) +. +cloned +( +) +. +map +( +hir +: +: +Literal +: +: +Byte +) +. +map +( Hir : : literal +) +. +collect ( -s +) +; +Hir +: +: +concat +( +lits ) } +} +} fn -hir_capture +hir_group ( -index +i : u32 expr @@ -11582,18 +9606,26 @@ Hir Hir : : -capture +group ( hir : : -Capture +Group { -index -name +kind +: +hir +: +: +GroupKind : -None -sub +: +CaptureIndex +( +i +) +hir : Box : @@ -11606,9 +9638,9 @@ expr ) } fn -hir_capture_name +hir_group_name ( -index +i : u32 name @@ -11626,25 +9658,35 @@ Hir Hir : : -capture +group ( hir : : -Capture +Group +{ +kind +: +hir +: +: +GroupKind +: +: +CaptureName { -index name : -Some -( name . -into +to_string ( ) -) -sub +index +: +i +} +hir : Box : @@ -11657,11 +9699,8 @@ expr ) } fn -hir_quest +hir_group_nocap ( -greedy -: -bool expr : Hir @@ -11673,24 +9712,23 @@ Hir Hir : : -repetition +group ( hir : : -Repetition +Group { -min +kind : -0 -max +hir +: +: +GroupKind : -Some -( -1 -) -greedy -sub +: +NonCapturing +hir : Box : @@ -11703,7 +9741,7 @@ expr ) } fn -hir_star +hir_quest ( greedy : @@ -11726,58 +9764,18 @@ hir : Repetition { -min +kind : -0 -max +hir : -None -greedy -sub : -Box +RepetitionKind : : -new -( -expr -) -} -) -} -fn -hir_plus -( +ZeroOrOne greedy -: -bool -expr -: -Hir -) -- -> -Hir -{ -Hir -: -: -repetition -( hir : -: -Repetition -{ -min -: -1 -max -: -None -greedy -sub -: Box : : @@ -11789,20 +9787,11 @@ expr ) } fn -hir_range +hir_star ( greedy : bool -min -: -u32 -max -: -Option -< -u32 -> expr : Hir @@ -11821,3300 +9810,1078 @@ hir : Repetition { -min -max -greedy -sub -: -Box -: -: -new -( -expr -) -} -) -} -fn -hir_alt -( -alts -: -Vec -< -Hir -> -) -- -> -Hir -{ -Hir -: -: -alternation -( -alts -) -} -fn -hir_cat -( -exprs -: -Vec -< -Hir -> -) -- -> -Hir -{ -Hir -: -: -concat -( -exprs -) -} -# -[ -allow -( -dead_code -) -] -fn -hir_uclass_query -( -query -: -ClassQuery -< -' -_ -> -) -- -> -Hir -{ -Hir -: -: -class -( -hir -: -: -Class -: -: -Unicode -( -unicode -: -: -class -( -query -) -. -unwrap -( -) -) -) -} -# -[ -allow -( -dead_code -) -] -fn -hir_uclass_perl_word -( -) -- -> -Hir -{ -Hir -: -: -class -( -hir -: -: -Class -: -: -Unicode -( -unicode -: -: -perl_word -( -) -. -unwrap -( -) -) -) -} -fn -hir_ascii_uclass -( kind : -& -ast -: -: -ClassAsciiKind -) -- -> -Hir -{ -Hir -: -: -class -( -hir -: -: -Class -: -: -Unicode -( hir : : -ClassUnicode +RepetitionKind : : -new -( -ascii_class_as_chars -( -kind -) -. -map -( -| -( -s -e -) -| +ZeroOrMore +greedy hir : -: -ClassUnicodeRange +Box : : new ( -s -e -) -) -) +expr ) +} ) } fn -hir_ascii_bclass +hir_plus ( -kind -: -& -ast +greedy : +bool +expr : -ClassAsciiKind +Hir ) - > -Hir -{ -Hir -: -: -class -( -hir -: -: -Class -: -: -Bytes -( -hir -: -: -ClassBytes -: -: -new -( -ascii_class -( -kind -) -. -map -( -| -( -s -e -) -| -hir -: -: -ClassBytesRange -: -: -new -( -s -e -) -) -) -) -) -} -fn -hir_uclass -( -ranges -: -& -[ -( -char -char -) -] -) -- -> -Hir -{ -Hir -: -: -class -( -uclass -( -ranges -) -) -} -fn -hir_bclass -( -ranges -: -& -[ -( -u8 -u8 -) -] -) -- -> -Hir -{ -Hir -: -: -class -( -bclass -( -ranges -) -) -} -fn -hir_case_fold -( -expr -: -Hir -) -- -> -Hir -{ -match -expr -. -into_kind -( -) -{ -HirKind -: -: -Class -( -mut -cls -) -= -> -{ -cls -. -case_fold_simple -( -) -; -Hir -: -: -class -( -cls -) -} -_ -= -> -panic -! -( -" -cannot -case -fold -non -- -class -Hir -expr -" -) -} -} -fn -hir_negate -( -expr -: -Hir -) -- -> -Hir -{ -match -expr -. -into_kind -( -) -{ -HirKind -: -: -Class -( -mut -cls -) -= -> -{ -cls -. -negate -( -) -; -Hir -: -: -class -( -cls -) -} -_ -= -> -panic -! -( -" -cannot -negate -non -- -class -Hir -expr -" -) -} -} -fn -uclass -( -ranges -: -& -[ -( -char -char -) -] -) -- -> -hir -: -: -Class -{ -let -ranges -: -Vec -< -hir -: -: -ClassUnicodeRange -> -= -ranges -. -iter -( -) -. -map -( -| -& -( -s -e -) -| -hir -: -: -ClassUnicodeRange -: -: -new -( -s -e -) -) -. -collect -( -) -; -hir -: -: -Class -: -: -Unicode -( -hir -: -: -ClassUnicode -: -: -new -( -ranges -) -) -} -fn -bclass -( -ranges -: -& -[ -( -u8 -u8 -) -] -) -- -> -hir -: -: -Class -{ -let -ranges -: -Vec -< -hir -: -: -ClassBytesRange -> -= -ranges -. -iter -( -) -. -map -( -| -& -( -s -e -) -| -hir -: -: -ClassBytesRange -: -: -new -( -s -e -) -) -. -collect -( -) -; -hir -: -: -Class -: -: -Bytes -( -hir -: -: -ClassBytes -: -: -new -( -ranges -) -) -} -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -fn -class_case_fold -( -mut -cls -: -hir -: -: -Class -) -- -> -Hir -{ -cls -. -case_fold_simple -( -) -; -Hir -: -: -class -( -cls -) -} -fn -class_negate -( -mut -cls -: -hir -: -: -Class -) -- -> -Hir -{ -cls -. -negate -( -) -; -Hir -: -: -class -( -cls -) -} -# -[ -allow -( -dead_code -) -] -fn -hir_union -( -expr1 -: -Hir -expr2 -: -Hir -) -- -> -Hir -{ -use -crate -: -: -hir -: -: -Class -: -: -{ -Bytes -Unicode -} -; -match -( -expr1 -. -into_kind -( -) -expr2 -. -into_kind -( -) -) -{ -( -HirKind -: -: -Class -( -Unicode -( -mut -c1 -) -) -HirKind -: -: -Class -( -Unicode -( -c2 -) -) -) -= -> -{ -c1 -. -union -( -& -c2 -) -; -Hir -: -: -class -( -hir -: -: -Class -: -: -Unicode -( -c1 -) -) -} -( -HirKind -: -: -Class -( -Bytes -( -mut -c1 -) -) -HirKind -: -: -Class -( -Bytes -( -c2 -) -) -) -= -> -{ -c1 -. -union -( -& -c2 -) -; -Hir -: -: -class -( -hir -: -: -Class -: -: -Bytes -( -c1 -) -) -} -_ -= -> -panic -! -( -" -cannot -union -non -- -class -Hir -exprs -" -) -} -} -# -[ -allow -( -dead_code -) -] -fn -hir_difference -( -expr1 -: -Hir -expr2 -: -Hir -) -- -> -Hir -{ -use -crate -: -: -hir -: -: -Class -: -: -{ -Bytes -Unicode -} -; -match -( -expr1 -. -into_kind -( -) -expr2 -. -into_kind -( -) -) -{ -( -HirKind -: -: -Class -( -Unicode -( -mut -c1 -) -) -HirKind -: -: -Class -( -Unicode -( -c2 -) -) -) -= -> -{ -c1 -. -difference -( -& -c2 -) -; -Hir -: -: -class -( -hir -: -: -Class -: -: -Unicode -( -c1 -) -) -} -( -HirKind -: -: -Class -( -Bytes -( -mut -c1 -) -) -HirKind -: -: -Class -( -Bytes -( -c2 -) -) -) -= -> -{ -c1 -. -difference -( -& -c2 -) -; -Hir -: -: -class -( -hir -: -: -Class -: -: -Bytes -( -c1 -) -) -} -_ -= -> -panic -! -( -" -cannot -difference -non -- -class -Hir -exprs -" -) -} -} -fn -hir_look -( -look -: -hir -: -: -Look -) -- -> -Hir -{ -Hir -: -: -look -( -look -) -} -# -[ -test -] -fn -empty -( -) -{ -assert_eq -! -( -t -( -" -" -) -Hir -: -: -empty -( -) -) -; -assert_eq -! -( -t -( -" -( -? -i -) -" -) -Hir -: -: -empty -( -) -) -; -assert_eq -! -( -t -( -" -( -) -" -) -hir_capture -( -1 -Hir -: -: -empty -( -) -) -) -; -assert_eq -! -( -t -( -" -( -? -: -) -" -) -Hir -: -: -empty -( -) -) -; -assert_eq -! -( -t -( -" -( -? -P -< -wat -> -) -" -) -hir_capture_name -( -1 -" -wat -" -Hir -: -: -empty -( -) -) -) -; -assert_eq -! -( -t -( -" -| -" -) -hir_alt -( -vec -! -[ -Hir -: -: -empty -( -) -Hir -: -: -empty -( -) -] -) -) -; -assert_eq -! -( -t -( -" -( -) -| -( -) -" -) -hir_alt -( -vec -! -[ -hir_capture -( -1 -Hir -: -: -empty -( -) -) -hir_capture -( -2 -Hir -: -: -empty -( -) -) -] -) -) -; -assert_eq -! -( -t -( -" -( -| -b -) -" -) -hir_capture -( -1 -hir_alt -( -vec -! -[ -Hir -: -: -empty -( -) -hir_lit -( -" -b -" -) -] -) -) -) -; -assert_eq -! -( -t -( -" -( -a -| -) -" -) -hir_capture -( -1 -hir_alt -( -vec -! -[ -hir_lit -( -" -a -" -) -Hir -: -: -empty -( -) -] -) -) -) -; -assert_eq -! -( -t -( -" -( -a -| -| -c -) -" -) -hir_capture -( -1 -hir_alt -( -vec -! -[ -hir_lit -( -" -a -" -) -Hir -: -: -empty -( -) -hir_lit -( -" -c -" -) -] -) -) -) -; -assert_eq -! -( -t -( -" -( -| -| -) -" -) -hir_capture -( -1 -hir_alt -( -vec -! -[ -Hir -: -: -empty -( -) -Hir -: -: -empty -( -) -Hir -: -: -empty -( -) -] -) -) -) -; -} -# -[ -test -] -fn -literal -( -) -{ -assert_eq -! -( -t -( -" -a -" -) -hir_lit -( -" -a -" -) -) -; -assert_eq -! -( -t -( -" -( -? -- -u -) -a -" -) -hir_lit -( -" -a -" -) -) -; -assert_eq -! -( -t -( -" -" -) -hir_lit -( -" -" -) -) -; -assert_eq -! -( -t -( -" -abcd -" -) -hir_lit -( -" -abcd -" -) -) -; -assert_eq -! -( -t_bytes -( -" -( -? -- -u -) -a -" -) -hir_lit -( -" -a -" -) -) -; -assert_eq -! -( -t_bytes -( -" -( -? -- -u -) -\ -x61 -" -) -hir_lit -( -" -a -" -) -) -; -assert_eq -! -( -t_bytes -( -r -" -( -? -- -u -) -\ -x61 -" -) -hir_lit -( -" -a -" -) -) -; -assert_eq -! -( -t_bytes -( -r -" -( -? -- -u -) -\ -xFF -" -) -hir_blit -( -b -" -\ -xFF -" -) -) -; -assert_eq -! -( -t_err -( -" -( -? -- -u -) -" -) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodeNotAllowed -span -: -Span -: -: -new -( -Position -: -: -new -( -5 -1 -6 -) -Position -: -: -new -( -8 -1 -7 -) -) -} -) -; -assert_eq -! -( -t_err -( -r -" -( -? -- -u -) -\ -xFF -" -) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -InvalidUtf8 -span -: -Span -: -: -new -( -Position -: -: -new -( -5 -1 -6 -) -Position -: -: -new -( -9 -1 -10 -) -) -} -) -; -} -# -[ -test -] -fn -literal_case_insensitive -( -) -{ -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -assert_eq -! -( -t -( -" -( -? -i -) -a -" -) -hir_uclass -( -& -[ -( -' -A -' -' -A -' -) -( -' -a -' -' -a -' -) -] -) -) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -assert_eq -! -( -t -( -" -( -? -i -: -a -) -" -) -hir_uclass -( -& -[ -( -' -A -' -' -A -' -) -( -' -a -' -' -a -' -) -] -) -) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -assert_eq -! -( -t -( -" -a -( -? -i -) -a -( -? -- -i -) -a -" -) -hir_cat -( -vec -! -[ -hir_lit -( -" -a -" -) -hir_uclass -( -& -[ -( -' -A -' -' -A -' -) -( -' -a -' -' -a -' -) -] -) -hir_lit -( -" -a -" -) -] -) -) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -assert_eq -! -( -t -( -" -( -? -i -) -ab -c -" -) -hir_cat -( -vec -! -[ -hir_uclass -( -& -[ -( -' -A -' -' -A -' -) -( -' -a -' -' -a -' -) -] -) -hir_uclass -( -& -[ -( -' -B -' -' -B -' -) -( -' -b -' -' -b -' -) -] -) -hir_lit -( -" -" -) -hir_uclass -( -& -[ -( -' -C -' -' -C -' -) -( -' -c -' -' -c -' -) -] -) -] -) -) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -assert_eq -! -( -t -( -" -( -? -i -) -" -) -hir_uclass -( -& -[ -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -] -) -) -; -assert_eq -! -( -t -( -" -( -? -i -- -u -) -a -" -) -hir_bclass -( -& -[ -( -b -' -A -' -b -' -A -' -) -( -b -' -a -' -b -' -a -' -) -] -) -) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] -assert_eq -! -( -t -( -" -( -? -- -u -) -a -( -? -i -) -a -( -? -- -i -) -a -" -) -hir_cat -( -vec -! -[ -hir_lit -( -" -a -" -) -hir_bclass -( -& -[ -( -b -' -A -' -b -' -A -' -) -( -b -' -a -' -b -' -a -' -) -] -) -hir_lit -( -" -a -" -) -] -) -) -; -assert_eq -! -( -t -( -" -( -? -i -- -u -) -ab -c -" -) -hir_cat -( -vec -! -[ -hir_bclass -( -& -[ -( -b -' -A -' -b -' -A -' -) -( -b -' -a -' -b -' -a -' -) -] -) -hir_bclass -( -& -[ -( -b -' -B -' -b -' -B -' -) -( -b -' -b -' -b -' -b -' -) -] -) -hir_lit -( -" -" -) -hir_bclass -( -& -[ -( -b -' -C -' -b -' -C -' -) -( -b -' -c -' -b -' -c -' -) -] -) -] -) -) -; -assert_eq -! -( -t_bytes -( -" -( -? -i -- -u -) -a -" -) -hir_bclass -( -& -[ -( -b -' -A -' -b -' -A -' -) -( -b -' -a -' -b -' -a -' -) -] -) -) -; -assert_eq -! -( -t_bytes -( -" -( -? -i -- -u -) -\ -x61 -" -) -hir_bclass -( -& -[ -( -b -' -A -' -b -' -A -' -) -( -b -' -a -' -b -' -a -' -) -] -) -) -; -assert_eq -! -( -t_bytes -( -r -" -( -? -i -- -u -) -\ -x61 -" -) -hir_bclass -( -& -[ -( -b -' -A -' -b -' -A -' -) -( -b -' -a -' -b -' -a -' -) -] -) -) -; -assert_eq -! -( -t_bytes -( -r -" -( -? -i -- -u -) -\ -xFF -" -) -hir_blit -( -b -" -\ -xFF -" -) -) -; -assert_eq -! -( -t_err -( -" -( -? -i -- -u -) -" -) -TestError +Hir +{ +Hir +: +: +repetition +( +hir +: +: +Repetition { kind : hir : : -ErrorKind +RepetitionKind : : -UnicodeNotAllowed -span +OneOrMore +greedy +hir : -Span +Box : : new ( -Position +expr +) +} +) +} +fn +hir_range +( +greedy : +bool +range : -new +hir +: +: +RepetitionRange +expr +: +Hir +) +- +> +Hir +{ +Hir +: +: +repetition ( -6 -1 -7 +hir +: +: +Repetition +{ +kind +: +hir +: +: +RepetitionKind +: +: +Range +( +range ) -Position +greedy +hir +: +Box : : new ( -8 -1 -8 -) +expr ) } ) -; } -# -[ -test -] fn -dot +hir_alt ( +alts +: +Vec +< +Hir +> ) +- +> +Hir { -assert_eq -! +Hir +: +: +alternation ( -t +alts +) +} +fn +hir_cat ( -" -. -" +exprs +: +Vec +< +Hir +> ) -hir_uclass +- +> +Hir +{ +Hir +: +: +concat ( -& +exprs +) +} +# [ +allow ( -' -\ -0 -' -' -\ -t -' +dead_code ) +] +fn +hir_uclass_query ( +query +: +ClassQuery +< ' -\ -x0B -' -' -\ -u -{ -10FFFF -} -' -) -] -) +_ +> ) -; -assert_eq -! +- +> +Hir +{ +Hir +: +: +class ( -t +hir +: +: +Class +: +: +Unicode ( -" +unicode +: +: +class ( -? -R +query ) . -" -) -hir_uclass -( -& -[ +unwrap ( -' -\ -0 -' -' -\ -t -' ) -( -' -\ -x0B -' -' -\ -x0C -' ) -( -' -\ -x0E -' -' -\ -u -{ -10FFFF +) } -' +# +[ +allow +( +dead_code ) ] -) -) -; -assert_eq -! +fn +hir_uclass_perl_word ( -t +) +- +> +Hir +{ +Hir +: +: +class ( -" +hir +: +: +Class +: +: +Unicode +( +unicode +: +: +perl_word ( -? -s ) . -" +unwrap +( ) +) +) +} +fn hir_uclass ( +ranges +: & [ ( -' -\ -0 -' -' -\ -u -{ -10FFFF -} -' +char +char ) ] ) -) -; -assert_eq -! -( -t -( -" +- +> +Hir +{ +let +ranges +: +Vec +< +hir +: +: +ClassUnicodeRange +> += +ranges +. +iter ( -? -Rs ) . -" -) -hir_uclass +map ( +| & -[ ( -' -\ -0 -' -' -\ -u -{ -10FFFF -} -' +s +e +) +| +hir +: +: +ClassUnicodeRange +: +: +new +( +s +e ) -] ) +. +collect +( ) ; -assert_eq -! +Hir +: +: +class ( -t_bytes +hir +: +: +Class +: +: +Unicode ( -" +hir +: +: +ClassUnicode +: +: +new ( -? -- -u +ranges +) ) -. -" ) +} +fn hir_bclass ( +ranges +: & [ ( -b -' -\ -0 -' -b -' -\ -t -' -) -( -b -' -\ -x0B -' -b -' -\ -xFF -' +u8 +u8 ) ] ) -) -; -assert_eq -! -( -t_bytes -( -" -( -? -R - -u -) +> +Hir +{ +let +ranges +: +Vec +< +hir +: +: +ClassBytesRange +> += +ranges . -" +iter +( ) -hir_bclass +. +map ( +| & -[ -( -b -' -\ -0 -' -b -' -\ -t -' -) ( -b -' -\ -x0B -' -b -' -\ -x0C -' +s +e ) +| +hir +: +: +ClassBytesRange +: +: +new ( -b -' -\ -x0E -' -b -' -\ -xFF -' +s +e ) -] ) +. +collect +( ) ; -assert_eq -! +Hir +: +: +class ( -t_bytes +hir +: +: +Class +: +: +Bytes ( -" +hir +: +: +ClassBytes +: +: +new ( -? -s -- -u +ranges ) -. -" ) -hir_bclass +) +} +fn +hir_bclass_from_char ( +ranges +: & [ ( -b -' -\ -0 -' -b -' -\ -xFF -' +char +char ) ] ) -) -; -assert_eq -! -( -t_bytes -( -" -( -? -Rs - -u -) +> +Hir +{ +let +ranges +: +Vec +< +hir +: +: +ClassBytesRange +> += +ranges . -" +iter +( ) -hir_bclass +. +map ( +| & -[ ( -b -' -\ -0 -' -b -' -\ -xFF -' -) -] +s +e ) +| +{ +assert +! +( +s +as +u32 +< += +0x7F ) ; -/ -/ -If -invalid -UTF -- -8 -isn -' -t -allowed -then -non -- -Unicode -. -isn -' -t -allowed -. -assert_eq +assert ! ( -t_err -( -" +e +as +u32 +< += +0x7F +) +; +hir +: +: +ClassBytesRange +: +: +new ( -? -- -u +s +as +u8 +e +as +u8 +) +} ) . -" +collect +( ) -TestError -{ -kind +; +Hir +: : +class +( hir : : -ErrorKind +Class : : -InvalidUtf8 -span +Bytes +( +hir : -Span +: +ClassBytes : : new ( -Position +ranges +) +) +) +} +fn +hir_case_fold +( +expr +: +Hir +) +- +> +Hir +{ +match +expr +. +into_kind +( +) +{ +HirKind : : -new +Class ( -5 -1 -6 +mut +cls ) -Position += +> +{ +cls +. +case_fold_simple +( +) +; +Hir : : -new +class ( -6 -1 -7 +cls +) +} +_ += +> +panic +! +( +" +cannot +case +fold +non +- +class +Hir +expr +" +) +} +} +fn +hir_negate +( +expr +: +Hir ) +- +> +Hir +{ +match +expr +. +into_kind +( +) +{ +HirKind +: +: +Class +( +mut +cls +) += +> +{ +cls +. +negate +( +) +; +Hir +: +: +class +( +cls ) } -) -; -assert_eq +_ += +> +panic ! ( -t_err -( " -( -? -R +cannot +negate +non - -u -) -. +class +Hir +expr " ) -TestError -{ -kind +} +} +# +[ +allow +( +dead_code +) +] +fn +hir_union +( +expr1 : -hir +Hir +expr2 : +Hir +) +- +> +Hir +{ +use +crate : -ErrorKind : +hir : -InvalidUtf8 -span : -Span +Class : : -new +{ +Bytes +Unicode +} +; +match ( -Position -: -: -new +expr1 +. +into_kind ( -6 -1 -7 ) -Position -: -: -new +expr2 +. +into_kind ( -7 -1 -8 ) ) -} -) -; -assert_eq -! +{ ( -t_err +HirKind +: +: +Class ( -" +Unicode ( -? -s -- -u +mut +c1 ) -. -" ) -TestError -{ -kind +HirKind : -hir : +Class +( +Unicode +( +c2 +) +) +) += +> +{ +c1 +. +union +( +& +c2 +) +; +Hir : -ErrorKind : +class +( +hir : -InvalidUtf8 -span : -Span +Class : : -new +Unicode ( -Position +c1 +) +) +} +( +HirKind : : -new +Class ( -6 -1 -7 +Bytes +( +mut +c1 ) -Position +) +HirKind : : -new +Class ( -7 -1 -8 -) +Bytes +( +c2 ) -} ) -; -assert_eq -! -( -t_err -( -" -( -? -Rs -- -u ) += +> +{ +c1 . -" +union +( +& +c2 ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -InvalidUtf8 -span -: -Span +; +Hir : : -new +class ( -Position +hir : : -new -( -7 -1 -8 -) -Position +Class : : -new +Bytes ( -8 -1 -9 +c1 ) ) } +_ += +> +panic +! +( +" +cannot +union +non +- +class +Hir +exprs +" ) -; +} } # [ -test -] -fn -assertions -( -) -{ -assert_eq -! -( -t +allow ( -" -^ -" +dead_code ) -hir_look +] +fn +hir_difference ( -hir +expr1 : +Hir +expr2 : -Look +Hir +) +- +> +Hir +{ +use +crate : : -Start -) -) -; -assert_eq -! -( -t -( -" -" -) -hir_look -( hir : : -Look +Class : : -End -) -) +{ +Bytes +Unicode +} ; -assert_eq -! +match ( -t +expr1 +. +into_kind ( -r -" -\ -A -" ) -hir_look +expr2 +. +into_kind ( -hir +) +) +{ +( +HirKind : : -Look +Class +( +Unicode +( +mut +c1 +) +) +HirKind : : -Start +Class +( +Unicode +( +c2 ) ) -; -assert_eq -! -( -t +) += +> +{ +c1 +. +difference ( -r -" -\ -z -" +& +c2 ) -hir_look +; +Hir +: +: +class ( hir : : -Look +Class : : -End +Unicode +( +c1 ) ) -; -assert_eq -! +} ( -t +HirKind +: +: +Class ( -" +Bytes ( -? -m +mut +c1 ) -^ -" ) -hir_look -( -hir -: -: -Look +HirKind : : -StartLF -) -) -; -assert_eq -! -( -t +Class ( -" +Bytes ( -? -m +c2 ) -" ) -hir_look +) += +> +{ +c1 +. +difference +( +& +c2 +) +; +Hir +: +: +class ( hir : : -Look +Class : : -EndLF +Bytes +( +c1 ) ) -; -assert_eq +} +_ += +> +panic ! ( -t -( -r " -( -? -m -) -\ -A +cannot +difference +non +- +class +Hir +exprs " ) -hir_look +} +} +fn +hir_anchor ( +anchor +: hir : : -Look +Anchor +) +- +> +Hir +{ +Hir : : -Start -) -) -; -assert_eq -! -( -t -( -r -" +anchor ( -? -m -) -\ -z -" +anchor ) -hir_look +} +fn +hir_word ( +wb +: hir : : -Look +WordBoundary +) +- +> +Hir +{ +Hir : : -End +word_boundary +( +wb ) +} +# +[ +test +] +fn +empty +( ) -; +{ assert_eq ! ( t ( -r " -\ -b " ) -hir_look -( -hir -: -: -Look +Hir : : -WordUnicode +empty +( ) ) ; @@ -15123,21 +10890,18 @@ assert_eq ( t ( -r " -\ -B +( +? +i +) " ) -hir_look -( -hir -: -: -Look +Hir : : -WordUnicodeNegate +empty +( ) ) ; @@ -15146,26 +10910,20 @@ assert_eq ( t ( -r " ( -? -- -u ) -\ -b " -) -hir_look -( -hir -: -: -Look +) +hir_group +( +1 +Hir : : -WordAscii +empty +( +) ) ) ; @@ -15174,39 +10932,24 @@ assert_eq ( t ( -r " ( ? -- -u +: ) -\ -B " ) -hir_look +hir_group_nocap ( -hir -: -: -Look +Hir : : -WordAsciiNegate +empty +( ) ) -; -} -# -[ -test -] -fn -group -( ) -{ +; assert_eq ! ( @@ -15214,18 +10957,25 @@ t ( " ( -a +? +P +< +wat +> ) " ) -hir_capture +hir_group_name ( 1 -hir_lit -( " -a +wat " +Hir +: +: +empty +( ) ) ) @@ -15236,38 +10986,25 @@ assert_eq t ( " -( -a -) -( -b -) +| " ) -hir_cat +hir_alt ( vec ! [ -hir_capture -( -1 -hir_lit +Hir +: +: +empty ( -" -a -" ) -) -hir_capture -( -2 -hir_lit +Hir +: +: +empty ( -" -b -" -) ) ] ) @@ -15280,11 +11017,9 @@ t ( " ( -a ) | ( -b ) " ) @@ -15293,24 +11028,24 @@ hir_alt vec ! [ -hir_capture +hir_group ( 1 -hir_lit +Hir +: +: +empty ( -" -a -" ) ) -hir_capture +hir_group ( 2 -hir_lit +Hir +: +: +empty ( -" -b -" ) ) ] @@ -15324,26 +11059,33 @@ t ( " ( -? -P -< -foo -> +| +b ) " ) -hir_capture_name +hir_group ( 1 -" -foo -" +hir_alt +( +vec +! +[ Hir : : empty ( ) +hir_lit +( +" +b +" +) +] +) ) ) ; @@ -15354,27 +11096,33 @@ t ( " ( -? -P -< -foo -> a +| ) " ) -hir_capture_name +hir_group ( 1 -" -foo -" +hir_alt +( +vec +! +[ hir_lit ( " a " ) +Hir +: +: +empty +( +) +] +) ) ) ; @@ -15385,57 +11133,43 @@ t ( " ( -? -P -< -foo -> a -) -( -? -P -< -bar -> -b +| +| +c ) " ) -hir_cat +hir_group +( +1 +hir_alt ( vec ! [ -hir_capture_name -( -1 -" -foo -" hir_lit ( " a " ) -) -hir_capture_name +Hir +: +: +empty ( -2 -" -bar -" +) hir_lit ( " -b +c " ) -) ] ) ) +) ; assert_eq ! @@ -15444,30 +11178,59 @@ t ( " ( -? -: +| +| ) " ) +hir_group +( +1 +hir_alt +( +vec +! +[ +Hir +: +: +empty +( +) +Hir +: +: +empty +( +) Hir : : empty ( ) +] +) +) ) ; +} +# +[ +test +] +fn +literal +( +) +{ assert_eq ! ( t ( " -( -? -: a -) " ) hir_lit @@ -15486,66 +11249,66 @@ t " ( ? -: -a -) -( -b +- +u ) +a " ) -hir_cat -( -vec -! -[ hir_lit ( " a " ) -hir_capture +) +; +assert_eq +! ( -1 +t +( +" +" +) hir_lit ( " -b " ) ) -] +; +assert_eq +! +( +t +( +" +abcd +" +) +hir_lit +( +" +abcd +" ) ) ; assert_eq ! ( -t +t_bytes ( " ( -a -) -( ? -: -b -) -( -c +- +u ) +a " ) -hir_cat -( -vec -! -[ -hir_capture -( -1 hir_lit ( " @@ -15553,56 +11316,46 @@ a " ) ) -hir_lit +; +assert_eq +! +( +t_bytes ( " -b +( +? +- +u +) +\ +x61 " ) -hir_capture -( -2 hir_lit ( " -c +a " ) ) -] -) -) ; assert_eq ! ( -t +t_bytes ( +r " ( -a -) -( ? -P -< -foo -> -b -) -( -c +- +u ) +\ +x61 " ) -hir_cat -( -vec -! -[ -hir_capture -( -1 hir_lit ( " @@ -15610,81 +11363,165 @@ a " ) ) -hir_capture_name +; +assert_eq +! ( -2 -" -foo -" -hir_lit +t_bytes ( +r " -b -" +( +? +- +u ) +\ +xFF +" ) -hir_capture -( -3 -hir_lit +hir_blit ( +b " -c +\ +xFF " ) ) -] -) -) ; assert_eq ! ( -t +t_err ( " ( +? +- +u ) " ) -hir_capture +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodeNotAllowed +span +: +Span +: +: +new ( +Position +: +: +new +( +5 1 -Hir +6 +) +Position : : -empty +new ( +8 +1 +7 ) ) +} ) ; assert_eq ! ( -t +t_err ( +r " ( -( ? -i -) +- +u ) +\ +xFF " ) -hir_capture +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +InvalidUtf8 +span +: +Span +: +: +new +( +Position +: +: +new ( +5 1 -Hir +6 +) +Position : : -empty +new ( +9 +1 +10 ) ) +} ) ; +} +# +[ +test +] +fn +literal_case_insensitive +( +) +{ +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( @@ -15692,25 +11529,49 @@ t ( " ( -( ? -x -) +i ) +a " ) -hir_capture +hir_uclass ( -1 -Hir -: -: -empty +& +[ +( +' +A +' +' +A +' +) ( +' +a +' +' +a +' ) +] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( @@ -15718,282 +11579,271 @@ t ( " ( -( -( ? -x -) -) +i +: +a ) " ) -hir_capture +hir_group_nocap ( -1 -hir_capture +hir_uclass +( +& +[ ( -2 -Hir -: -: -empty +' +A +' +' +A +' +) ( +' +a +' +' +a +' ) +] ) ) ) ; -} # [ -test -] -fn -line_anchors +cfg ( +feature += +" +unicode +- +case +" ) -{ +] assert_eq ! ( t ( " -^ -" +a +( +? +i ) -hir_look +a ( -hir -: -: -Look -: -: -Start +? +- +i ) +a +" ) -; -assert_eq -! +hir_cat ( -t +vec +! +[ +hir_lit ( " +a " ) -hir_look -( -hir -: -: -Look -: -: -End -) -) -; -assert_eq -! +hir_uclass ( -t +& +[ ( -r -" -\ +' A -" +' +' +A +' ) -hir_look ( -hir -: -: -Look -: -: -Start +' +a +' +' +a +' ) +] ) -; -assert_eq -! -( -t +hir_lit ( -r " -\ -z +a " ) -hir_look -( -hir -: -: -Look -: -: -End +] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( t ( -r " ( ? -m +i ) -\ -A +ab +c " ) -hir_look +hir_cat ( -hir -: -: -Look -: -: -Start -) -) -; -assert_eq +vec ! +[ +hir_uclass ( -t -( -r -" +& +[ ( -? -m -) -\ -z -" +' +A +' +' +A +' ) -hir_look ( -hir -: -: -Look -: -: -End +' +a +' +' +a +' ) +] ) -; -assert_eq -! +hir_uclass ( -t +& +[ ( -" +' +B +' +' +B +' +) ( -? -m +' +b +' +' +b +' ) -^ -" +] ) -hir_look +hir_lit ( -hir -: -: -Look -: -: -StartLF -) +" +" ) -; -assert_eq -! +hir_uclass ( -t +& +[ ( -" +' +C +' +' +C +' +) ( -? -m +' +c +' +' +c +' ) -" +] +) +] ) -hir_look -( -hir -: -: -Look -: -: -EndLF ) +; +# +[ +cfg +( +feature += +" +unicode +- +case +" ) -; +] assert_eq ! ( t ( -r " ( ? -R +i ) -\ -A " ) -hir_look -( -hir -: -: -Look -: -: -Start -) -) -; -assert_eq -! -( -t +hir_uclass ( -r -" +& +[ ( -? -R +' +' +' +' ) -\ -z -" +( +' +' +' +' ) -hir_look ( -hir -: -: -Look -: -: -End +' +' +' +' +) +] ) ) ; @@ -16005,23 +11855,54 @@ t " ( ? -R +i +- +u ) -^ +a " ) -hir_look +hir_bclass ( -hir -: -: -Look -: -: -Start +& +[ +( +b +' +A +' +b +' +A +' +) +( +b +' +a +' +b +' +a +' +) +] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( @@ -16030,73 +11911,67 @@ t " ( ? -R +- +u ) -" +a +( +? +i ) -hir_look +a ( -hir -: -: -Look -: -: -End +? +- +i ) +a +" ) -; -assert_eq -! +hir_cat ( -t +vec +! +[ +hir_lit ( -r " -( -? -Rm +a +" ) -\ +hir_bclass +( +& +[ +( +b +' A -" +' +b +' +A +' ) -hir_look ( -hir -: -: -Look -: -: -Start +b +' +a +' +b +' +a +' ) +] ) -; -assert_eq -! -( -t +hir_lit ( -r " -( -? -Rm -) -\ -z +a " ) -hir_look -( -hir -: -: -Look -: -: -End +] ) ) ; @@ -16108,118 +11983,102 @@ t " ( ? -Rm +i +- +u ) -^ +ab +c " ) -hir_look +hir_cat ( -hir -: -: -Look -: -: -StartCRLF -) -) -; -assert_eq +vec ! +[ +hir_bclass ( -t -( -" +& +[ ( -? -Rm -) -" +b +' +A +' +b +' +A +' ) -hir_look ( -hir -: -: -Look -: -: -EndCRLF +b +' +a +' +b +' +a +' ) +] ) -; -} -# +hir_bclass +( +& [ -test -] -fn -flags ( +b +' +B +' +b +' +B +' ) -{ -# -[ -cfg ( -feature -= -" -unicode -- -case -" +b +' +b +' +b +' +b +' ) ] -assert_eq -! -( -t +) +hir_lit ( " -( -? -i -: -a -) -a " ) -hir_cat -( -vec -! -[ -hir_uclass +hir_bclass ( & [ ( +b ' -A +C ' +b ' -A +C ' ) ( +b ' -a +c ' +b ' -a +c ' ) ] ) -hir_lit -( -" -a -" -) ] ) ) @@ -16227,7 +12086,7 @@ a assert_eq ! ( -t +t_bytes ( " ( @@ -16235,16 +12094,10 @@ t i - u -: -a ) +a " ) -hir_cat -( -vec -! -[ hir_bclass ( & @@ -16271,40 +12124,24 @@ a ) ] ) -hir_lit -( -" -" -) -] -) ) ; assert_eq ! ( -t +t_bytes ( " ( ? -: -( -? i - u ) -a -) -b +\ +x61 " ) -hir_cat -( -vec -! -[ hir_bclass ( & @@ -16331,42 +12168,25 @@ a ) ] ) -hir_lit -( -" -b -" -) -] -) ) ; assert_eq ! ( -t +t_bytes ( +r " ( -( ? i - u ) -a -) -b +\ +x61 " ) -hir_cat -( -vec -! -[ -hir_capture -( -1 hir_bclass ( & @@ -16394,167 +12214,138 @@ a ] ) ) -hir_lit +; +assert_eq +! ( +t_bytes +( +r " -b -" -) -] +( +? +i +- +u ) +\ +xFF +" ) -; -# -[ -cfg +hir_blit ( -feature -= +b " -unicode -- -case +\ +xFF " ) -] +) +; assert_eq ! ( -t +t_err ( " ( ? i -) -( -? - -i -: -a -) -a -" +u ) -hir_cat -( -vec -! -[ -hir_lit -( -" -a " ) -hir_uclass +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodeNotAllowed +span +: +Span +: +: +new ( -& -[ +Position +: +: +new ( -' -A -' -' -A -' +6 +1 +7 ) +Position +: +: +new ( -' -a -' -' -a -' -) -] +8 +1 +8 ) -] ) +} ) ; +} # [ -cfg +test +] +fn +dot ( -feature -= -" -unicode -- -case -" ) -] +{ assert_eq ! ( t ( " -( -? -im -) -a -^ +. " ) -hir_cat -( -vec -! -[ hir_uclass ( & [ ( ' -A +\ +0 ' ' -A +\ +t ' ) ( ' -a +\ +x0B ' ' -a +\ +u +{ +10FFFF +} ' ) ] ) -hir_look -( -hir -: -: -Look -: -: -StartLF -) -] -) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] assert_eq ! ( @@ -16563,453 +12354,440 @@ t " ( ? -im -) -a -^ -( -? -i -- -m +s ) -a -^ +. " ) -hir_cat -( -vec -! -[ hir_uclass ( & [ ( ' -A -' -' -A -' -) -( -' -a +\ +0 ' ' -a +\ +u +{ +10FFFF +} ' ) ] ) -hir_look +) +; +assert_eq +! ( -hir -: -: -Look -: -: -StartLF +t_bytes +( +" +( +? +- +u ) -hir_uclass +. +" +) +hir_bclass ( & [ ( +b ' -A +\ +0 ' +b ' -A +\ +t ' ) ( +b ' -a +\ +x0B ' +b ' -a +\ +xFF ' ) ] ) -hir_look -( -hir -: -: -Look -: -: -Start -) -] -) ) ; assert_eq ! ( -t +t_bytes ( " ( ? -U -) -a -* -a -* -? -( -? +s - -U +u ) -a -* -a -* -? +. " ) -hir_cat +hir_bclass ( -vec -! +& [ -hir_star ( -false -hir_lit -( -" -a -" +b +' +\ +0 +' +b +' +\ +xFF +' ) +] ) -hir_star +) +; +/ +/ +If +invalid +UTF +- +8 +isn +' +t +allowed +then +non +- +Unicode +. +isn +' +t +allowed +. +assert_eq +! ( -true -hir_lit +t_err ( " -a -" +( +? +- +u ) +. +" ) -hir_star +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +InvalidUtf8 +span +: +Span +: +: +new ( -true -hir_lit +Position +: +: +new ( -" -a -" +5 +1 +6 +) +Position +: +: +new +( +6 +1 +7 ) ) -hir_star +} +) +; +assert_eq +! ( -false -hir_lit +t_err ( " -a +( +? +s +- +u +) +. " ) +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +InvalidUtf8 +span +: +Span +: +: +new +( +Position +: +: +new +( +6 +1 +7 +) +Position +: +: +new +( +7 +1 +8 ) -] ) +} ) ; +} # [ -cfg +test +] +fn +assertions ( -feature -= -" -unicode -- -case -" ) -] +{ assert_eq ! ( t ( " +^ +" +) +hir_anchor ( -? +hir : -a -( -? -i -) -a +: +Anchor +: +: +StartText ) -a -" ) -hir_cat -( -vec +; +assert_eq ! -[ -hir_cat ( -vec -! -[ -hir_lit +t ( " -a " ) -hir_uclass -( -& -[ -( -' -A -' -' -A -' -) -( -' -a -' -' -a -' -) -] -) -] -) -hir_lit +hir_anchor ( -" -a -" -) -] +hir +: +: +Anchor +: +: +EndText ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] assert_eq ! ( t ( +r +" +\ +A " -( -? -i ) +hir_anchor ( -? +hir : -a -( -? -- -i -) -a +: +Anchor +: +: +StartText ) -a -" ) -hir_cat -( -vec -! -[ -hir_cat -( -vec +; +assert_eq ! -[ -hir_uclass -( -& -[ -( -' -A -' -' -A -' -) ( -' -a -' -' -a -' -) -] -) -hir_lit +t ( +r " -a +\ +z " ) -] -) -hir_uclass -( -& -[ -( -' -A -' -' -A -' -) +hir_anchor ( -' -a -' -' -a -' -) -] -) -] +hir +: +: +Anchor +: +: +EndText ) ) ; -} -# -[ -test -] -fn -escape -( -) -{ assert_eq ! ( t ( -r " -\ -\ -\ -. -\ -+ -\ -* -\ -? -\ ( -\ +? +m ) -\ -| -\ -[ -\ -] -\ -{ -\ -} -\ ^ -\ -\ -# " ) -hir_lit +hir_anchor ( -r -" -\ -. -+ -* -? +hir +: +: +Anchor +: +: +StartLine +) +) +; +assert_eq +! +( +t +( +" ( +? +m ) -| -[ -] -{ -} -^ -# " ) -) -; -} -# -[ -test -] -fn -repetition +hir_anchor ( +hir +: +: +Anchor +: +: +EndLine ) -{ +) +; assert_eq ! ( t ( +r " -a +( ? +m +) +\ +A " ) -hir_quest +hir_anchor ( -true -hir_lit +hir +: +: +Anchor +: +: +StartText +) +) +; +assert_eq +! +( +t ( +r " -a +( +? +m +) +\ +z " ) +hir_anchor +( +hir +: +: +Anchor +: +: +EndText ) ) ; @@ -17018,20 +12796,44 @@ assert_eq ( t ( +r " -a -* +\ +b " ) -hir_star +hir_word ( -true -hir_lit +hir +: +: +WordBoundary +: +: +Unicode +) +) +; +assert_eq +! +( +t ( +r " -a +\ +B " ) +hir_word +( +hir +: +: +WordBoundary +: +: +UnicodeNegate ) ) ; @@ -17040,60 +12842,137 @@ assert_eq ( t ( +r " -a -+ +( +? +- +u +) +\ +b " ) -hir_plus +hir_word ( -true -hir_lit +hir +: +: +WordBoundary +: +: +Ascii +) +) +; +assert_eq +! ( +t_bytes +( +r " -a +( +? +- +u +) +\ +B " ) +hir_word +( +hir +: +: +WordBoundary +: +: +AsciiNegate ) ) ; assert_eq ! ( -t +t_err ( +r " -a -? +( ? +- +u +) +\ +B " ) -hir_quest +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +InvalidUtf8 +span +: +Span +: +: +new ( -false -hir_lit +Position +: +: +new ( -" -a -" +5 +1 +6 +) +Position +: +: +new +( +7 +1 +8 ) ) +} ) ; +} +# +[ +test +] +fn +group +( +) +{ assert_eq ! ( t ( " +( a -* -? +) " ) -hir_star +hir_group ( -false +1 hir_lit ( " @@ -17109,14 +12988,22 @@ assert_eq t ( " +( a -+ -? +) +( +b +) " ) -hir_plus +hir_cat ( -false +vec +! +[ +hir_group +( +1 hir_lit ( " @@ -17124,6 +13011,18 @@ a " ) ) +hir_group +( +2 +hir_lit +( +" +b +" +) +) +] +) ) ; assert_eq @@ -17132,27 +13031,42 @@ assert_eq t ( " +( a -{ -1 -} +) +| +( +b +) " ) -hir_range +hir_alt ( -true -1 -Some +vec +! +[ +hir_group ( 1 +hir_lit +( +" +a +" ) +) +hir_group +( +2 hir_lit ( " -a +b " ) ) +] +) ) ; assert_eq @@ -17161,22 +13075,26 @@ assert_eq t ( " -a -{ -1 -} +( +? +P +< +foo +> +) " ) -hir_range +hir_group_name ( -true 1 -None -hir_lit -( " -a +foo " +Hir +: +: +empty +( ) ) ) @@ -17187,21 +13105,22 @@ assert_eq t ( " +( +? +P +< +foo +> a -{ -1 -2 -} +) " ) -hir_range +hir_group_name ( -true 1 -Some -( -2 -) +" +foo +" hir_lit ( " @@ -17217,21 +13136,35 @@ assert_eq t ( " +( +? +P +< +foo +> a -{ -1 -} +) +( ? +P +< +bar +> +b +) " ) -hir_range +hir_cat ( -false -1 -Some +vec +! +[ +hir_group_name ( 1 -) +" +foo +" hir_lit ( " @@ -17239,6 +13172,21 @@ a " ) ) +hir_group_name +( +2 +" +bar +" +hir_lit +( +" +b +" +) +) +] +) ) ; assert_eq @@ -17247,23 +13195,19 @@ assert_eq t ( " -a -{ -1 -} +( ? +: +) " ) -hir_range +hir_group_nocap ( -false -1 -None -hir_lit +Hir +: +: +empty ( -" -a -" ) ) ) @@ -17274,22 +13218,15 @@ assert_eq t ( " -a -{ -1 -2 -} +( ? +: +a +) " ) -hir_range -( -false -1 -Some +hir_group_nocap ( -2 -) hir_lit ( " @@ -17305,8 +13242,14 @@ assert_eq t ( " -ab +( ? +: +a +) +( +b +) " ) hir_cat @@ -17314,15 +13257,18 @@ hir_cat vec ! [ +hir_group_nocap +( hir_lit ( " a " ) -hir_quest +) +hir_group ( -true +1 hir_lit ( " @@ -17341,53 +13287,35 @@ t ( " ( -ab +a ) +( ? -" +: +b ) -hir_quest -( -true -hir_capture ( -1 -hir_lit -( -" -ab -" -) -) -) +c ) -; -assert_eq -! -( -t -( -" -a -| -b -? " ) -hir_alt +hir_cat ( vec ! [ +hir_group +( +1 hir_lit ( " a " ) -hir_quest +) +hir_group_nocap ( -true hir_lit ( " @@ -17395,82 +13323,18 @@ b " ) ) -] -) -) -; -} -# -[ -test -] -fn -cat_alt +hir_group ( -) -{ -let -a -= -| -| -hir_look +2 +hir_lit ( -hir -: -: -Look -: -: -Start +" +c +" ) -; -let -b -= -| -| -hir_look -( -hir -: -: -Look -: -: -End ) -; -let -c -= -| -| -hir_look -( -hir -: -: -Look -: -: -WordUnicode +] ) -; -let -d -= -| -| -hir_look -( -hir -: -: -Look -: -: -WordUnicodeNegate ) ; assert_eq @@ -17480,49 +13344,58 @@ t ( " ( -^ +a +) +( +? +P +< +foo +> +b +) +( +c ) " ) -hir_capture -( -1 hir_cat ( vec ! [ -a +hir_group ( -) -b +1 +hir_lit ( -) -] -) +" +a +" ) ) -; -assert_eq -! +hir_group_name ( -t +2 +" +foo +" +hir_lit ( " -^ -| +b " ) -hir_alt +) +hir_group ( -vec -! -[ -a +3 +hir_lit ( +" +c +" ) -b -( ) ] ) @@ -17533,30 +13406,20 @@ assert_eq ( t ( -r -" -^ -| -| -\ -b " -) -hir_alt -( -vec -! -[ -a ( ) -b -( +" ) -c +hir_group +( +1 +Hir +: +: +empty ( ) -] ) ) ; @@ -17565,64 +13428,50 @@ assert_eq ( t ( -r -" -^ -| -\ -b -| -\ -b -\ -B " -) -hir_alt -( -vec -! -[ -hir_cat ( -vec -! -[ -a ( +? +i ) -b -( ) -] +" ) -hir_cat +hir_group ( -vec -! -[ -b +1 +Hir +: +: +empty ( ) -c -( ) -] ) -hir_cat -( -vec +; +assert_eq ! -[ -c ( -) -d +t ( +" +( +( +? +x ) -] ) -] +" +) +hir_group +( +1 +Hir +: +: +empty +( +) ) ) ; @@ -17633,66 +13482,107 @@ t ( " ( -^ -| +( +( +? +x +) +) ) " ) -hir_capture +hir_group ( 1 -hir_alt -( -vec -! -[ -a +hir_group ( -) -b +2 +Hir +: +: +empty ( ) -] ) ) ) ; +} +# +[ +test +] +fn +flags +( +) +{ +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( t ( -r " ( -^ -| -| -\ -b +? +i +: +a ) +a " ) -hir_capture -( -1 -hir_alt +hir_cat ( vec ! [ -a +hir_group_nocap ( -) -b +hir_uclass +( +& +[ ( +' +A +' +' +A +' ) -c ( +' +a +' +' +a +' ) ] ) ) +hir_lit +( +" +a +" +) +] +) ) ; assert_eq @@ -17700,70 +13590,57 @@ assert_eq ( t ( -r -" -( -^ -| -\ -b -| -\ -b -\ -B -) " -) -hir_capture -( -1 -hir_alt -( -vec -! -[ -hir_cat ( -vec -! -[ +? +i +- +u +: a -( ) -b -( -) -] +" ) hir_cat ( vec ! [ -b -( -) -c +hir_group_nocap ( -) -] -) -hir_cat +hir_bclass ( -vec -! +& [ -c ( +b +' +A +' +b +' +A +' ) -d ( +b +' +a +' +b +' +a +' ) ] ) -] ) +hir_lit +( +" +" +) +] ) ) ; @@ -17772,207 +13649,175 @@ assert_eq ( t ( -r " ( -^ -| -( -\ -b -| +? +: ( -\ -b -\ -B -) +? +i +- +u ) +a ) +b " ) -hir_capture -( -1 -hir_alt +hir_cat ( vec ! [ -hir_cat +hir_group_nocap ( -vec -! +hir_bclass +( +& [ -a ( +b +' +A +' +b +' +A +' ) +( +b +' +a +' b +' +a +' +) +] +) +) +hir_lit ( +" +b +" ) ] ) -hir_capture +) +; +assert_eq +! ( -2 -hir_alt +t ( -vec -! -[ -hir_cat +" ( -vec -! -[ -b ( +? +i +- +u ) -c -( +a ) -] +b +" ) -hir_capture -( -3 hir_cat ( vec ! [ -c +hir_group +( +1 +hir_bclass +( +& +[ ( +b +' +A +' +b +' +A +' ) -d ( +b +' +a +' +b +' +a +' ) ] ) ) -] -) +hir_lit +( +" +b +" ) ] ) ) -) ; -} -/ -/ -Tests -the -HIR -transformation -of -things -like -' -[ -a -- -z -] -| -[ -A -- -Z -] -' -into -/ -/ -' +# [ -A -- -Za -- -z -] -' -. -In -other -words -an -alternation -of -just -classes -is -always -/ -/ -equivalent -to -a -single -class -corresponding -to -the -union -of -the -branches -/ -/ -in -that -class -. +cfg ( -Unless -some -branches -match -invalid -UTF -- -8 -and -others -/ -/ -match -non +feature += +" +unicode - -ASCII -Unicode -. +case +" ) -# -[ -test ] -fn -cat_class_flattened +assert_eq +! ( +t +( +" +( +? +i +) +( +? +- +i +: +a +) +a +" ) -{ -assert_eq +hir_cat +( +vec ! +[ +hir_group_nocap ( -t +hir_lit ( -r " -[ a -- -z -] -| -[ -A -- -Z -] " ) +) hir_uclass ( & @@ -17982,7 +13827,7 @@ hir_uclass A ' ' -Z +A ' ) ( @@ -17990,32 +13835,15 @@ Z a ' ' -z +a ' ) ] ) +] +) ) ; -/ -/ -Combining -all -of -the -letter -properties -should -give -us -the -one -giant -/ -/ -letter -property -. # [ cfg @@ -18025,7 +13853,7 @@ feature " unicode - -gencat +case " ) ] @@ -18034,107 +13862,16 @@ assert_eq ( t ( -r -" -( -? -x -) -\ -p -{ -Lowercase_Letter -} -| -\ -p -{ -Uppercase_Letter -} -| -\ -p -{ -Titlecase_Letter -} -| -\ -p -{ -Modifier_Letter -} -| -\ -p -{ -Other_Letter -} -" -) -hir_uclass_query -( -ClassQuery -: -: -Binary -( -" -letter -" -) -) -) -; -/ -/ -Byte -classes -that -can -truly -match -invalid -UTF -- -8 -cannot -be -combined -/ -/ -with -Unicode -classes -. -assert_eq -! -( -t_bytes -( -r " -[ -] -| ( ? -- -u -: -[ -\ -x90 -- -\ -xFF -] +im ) -| -[ -] +a +^ " ) -hir_alt +hir_cat ( vec ! @@ -18145,528 +13882,510 @@ hir_uclass [ ( ' +A ' ' +A ' ) ( ' +a ' ' +a ' ) ] ) -hir_bclass +hir_anchor ( -& +hir +: +: +Anchor +: +: +StartLine +) +] +) +) +; +# [ +cfg ( -b -' -\ -x90 -' -b -' -\ -xFF -' +feature += +" +unicode +- +case +" ) ] +assert_eq +! +( +t +( +" +( +? +im +) +a +^ +( +? +i +- +m +) +a +^ +" ) +hir_cat +( +vec +! +[ hir_uclass ( & [ ( ' +A ' ' +A ' ) ( ' +a ' ' +a ' ) ] ) -] -) -) -; -/ -/ -Byte -classes -on -their -own -can -be -combined -even -if -some -are -ASCII -/ -/ -and -others -are -invalid -UTF -- -8 -. -assert_eq -! -( -t_bytes -( -r -" -[ -a -- -z -] -| +hir_anchor ( -? -- -u -: -[ -\ -x90 -- -\ -xFF -] -) -| -[ -A -- -Z -] -" +hir +: +: +Anchor +: +: +StartLine ) -hir_bclass +hir_uclass ( & [ ( -b ' A ' -b ' -Z +A ' ) ( -b ' a ' -b ' -z +a ' ) +] +) +hir_anchor ( -b -' -\ -x90 -' -b -' -\ -xFF -' +hir +: +: +Anchor +: +: +StartText ) ] ) ) ; -} -# -[ -test -] -fn -class_ascii -( -) -{ assert_eq ! ( t ( " -[ -[ -: -alnum -: -] -] -" +( +? +U ) -hir_ascii_uclass +a +* +a +* +? ( -& -ast -: -: -ClassAsciiKind -: -: -Alnum +? +- +U ) +a +* +a +* +? +" ) -; -assert_eq +hir_cat +( +vec ! +[ +hir_star ( -t +false +hir_lit ( " -[ -[ -: -alpha -: -] -] +a " ) -hir_ascii_uclass -( -& -ast -: -: -ClassAsciiKind -: -: -Alpha -) ) -; -assert_eq -! +hir_star ( -t +true +hir_lit ( " -[ -[ -: -ascii -: -] -] +a " ) -hir_ascii_uclass +) +hir_star ( -& -ast -: -: -ClassAsciiKind -: -: -Ascii +true +hir_lit +( +" +a +" ) ) -; -assert_eq -! +hir_star ( -t +false +hir_lit ( " -[ -[ -: -blank -: -] -] +a " ) -hir_ascii_uclass -( -& -ast -: -: -ClassAsciiKind -: -: -Blank +) +] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( t ( " -[ -[ -: -cntrl -: -] -] -" -) -hir_ascii_uclass ( -& -ast -: -: -ClassAsciiKind -: +? : -Cntrl +a +( +? +i ) +a ) -; -assert_eq +a +" +) +hir_cat +( +vec ! +[ +hir_group_nocap ( -t +hir_cat ( -" -[ +vec +! [ -: -digit -: -] -] +hir_lit +( +" +a " ) -hir_ascii_uclass +hir_uclass ( & -ast -: -: -ClassAsciiKind -: -: -Digit -) -) -; -assert_eq -! +[ ( -t +' +A +' +' +A +' +) ( -" -[ -[ -: -graph -: +' +a +' +' +a +' +) ] +) ] -" ) -hir_ascii_uclass +) +hir_lit ( -& -ast -: -: -ClassAsciiKind -: -: -Graph +" +a +" +) +] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( t ( " -[ -[ -: -lower -: -] -] -" +( +? +i ) -hir_ascii_uclass ( -& -ast -: -: -ClassAsciiKind -: +? : -Lower +a +( +? +- +i ) +a ) -; -assert_eq +a +" +) +hir_cat +( +vec ! +[ +hir_group_nocap ( -t +hir_cat ( -" +vec +! [ +hir_uclass +( +& [ -: -print -: -] -] -" +( +' +A +' +' +A +' ) -hir_ascii_uclass ( -& -ast -: -: -ClassAsciiKind -: -: -Print +' +a +' +' +a +' ) +] ) -; -assert_eq -! -( -t +hir_lit ( " -[ -[ -: -punct -: -] -] +a " ) -hir_ascii_uclass +] +) +) +hir_uclass ( & -ast -: -: -ClassAsciiKind -: -: -Punct +[ +( +' +A +' +' +A +' +) +( +' +a +' +' +a +' +) +] +) +] ) ) ; +} +# +[ +test +] +fn +escape +( +) +{ assert_eq ! ( t ( +r " +\ +\ +\ +. +\ ++ +\ +* +\ +? +\ +( +\ +) +\ +| +\ [ -[ -: -space -: -] +\ ] +\ +{ +\ +} +\ +^ +\ +\ +# " ) -hir_ascii_uclass +hir_lit ( -& -ast -: -: -ClassAsciiKind -: -: -Space +r +" +\ +. ++ +* +? +( +) +| +[ +] +{ +} +^ +# +" ) ) ; +} +# +[ +test +] +fn +repetition +( +) +{ assert_eq ! ( t ( " -[ -[ -: -upper -: -] -] +a +? " ) -hir_ascii_uclass -( -& -ast -: -: -ClassAsciiKind -: -: -Upper -) -) -; -assert_eq -! +hir_quest ( -t +true +hir_lit ( " -[ -[ -: -word -: -] -] +a " ) -hir_ascii_uclass -( -& -ast -: -: -ClassAsciiKind -: -: -Word ) ) ; @@ -18676,25 +14395,19 @@ assert_eq t ( " -[ -[ -: -xdigit -: -] -] +a +* " ) -hir_ascii_uclass +hir_star ( -& -ast -: -: -ClassAsciiKind -: -: -Xdigit +true +hir_lit +( +" +a +" +) ) ) ; @@ -18704,117 +14417,65 @@ assert_eq t ( " -[ -[ -: -^ -lower -: -] -] +a ++ " ) -hir_negate +hir_plus ( -hir_ascii_uclass +true +hir_lit ( -& -ast -: -: -ClassAsciiKind -: -: -Lower +" +a +" ) ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] assert_eq ! ( t ( " -( +a +? ? -i -) -[ -[ -: -lower -: -] -] " ) -hir_uclass +hir_quest ( -& -[ +false +hir_lit ( -' -A -' -' -Z -' +" +a +" ) +) +) +; +assert_eq +! ( -' +t +( +" a -' -' -z -' +* +? +" ) +hir_star ( -' -\ -u -{ -17F -} -' -' -\ -u -{ -17F -} -' -) +false +hir_lit ( -' -\ -u -{ -212A -} -' -' -\ -u -{ -212A -} -' +" +a +" ) -] ) ) ; @@ -18824,30 +14485,20 @@ assert_eq t ( " -( +a ++ ? -- -u -) -[ -[ -: -lower -: -] -] " ) -hir_ascii_bclass +hir_plus ( -& -ast -: -: -ClassAsciiKind -: -: -Lower +false +hir_lit +( +" +a +" +) ) ) ; @@ -18857,33 +14508,30 @@ assert_eq t ( " -( -? -i -- -u -) -[ -[ -: -lower -: -] -] +a +{ +1 +} " ) -hir_case_fold -( -hir_ascii_bclass +hir_range ( -& -ast +true +hir : : -ClassAsciiKind +RepetitionRange : : -Lower +Exactly +( +1 +) +hir_lit +( +" +a +" ) ) ) @@ -18891,212 +14539,104 @@ Lower assert_eq ! ( -t_err +t ( " -( -? -- -u -) -[ -[ -: -^ -lower -: -] -] +a +{ +1 +} " ) -TestError -{ -kind -: +hir_range +( +true hir : : -ErrorKind -: -: -InvalidUtf8 -span -: -Span -: -: -new -( -Position +RepetitionRange : : -new +AtLeast ( -6 1 -7 ) -Position -: -: -new +hir_lit ( -16 -1 -17 +" +a +" ) ) -} ) ; assert_eq ! ( -t_err +t ( " -( -? -i -- -u -) -[ -[ -: -^ -lower -: -] -] +a +{ +1 +2 +} " ) -TestError -{ -kind -: +hir_range +( +true hir : : -ErrorKind -: -: -InvalidUtf8 -span -: -Span -: -: -new -( -Position +RepetitionRange : : -new +Bounded ( -7 1 -8 +2 ) -Position -: -: -new +hir_lit ( -17 -1 -18 +" +a +" ) ) -} ) ; -} -# -[ -test -] -fn -class_ascii_multiple -( -) -{ -/ -/ -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -680 assert_eq ! ( t ( " -[ -[ -: -alnum -: -] -[ -: -^ -ascii -: -] -] +a +{ +1 +} +? " ) -hir_union -( -hir_ascii_uclass +hir_range ( -& -ast +false +hir : : -ClassAsciiKind +RepetitionRange : : -Alnum -) -hir_uclass -( -& -[ +Exactly ( -' -\ -u -{ -80 -} -' -' -\ -u -{ -10FFFF -} -' +1 ) -] +hir_lit +( +" +a +" ) ) ) @@ -19104,101 +14644,70 @@ u assert_eq ! ( -t_bytes +t ( " -( +a +{ +1 +} ? -- -u -) -[ -[ -: -alnum -: -] -[ -: -^ -ascii -: -] -] " ) -hir_union -( -hir_ascii_bclass +hir_range ( -& -ast +false +hir : : -ClassAsciiKind +RepetitionRange : : -Alnum -) -hir_bclass -( -& -[ +AtLeast ( -0x80 -0xFF -) -] -) -) +1 ) -; -} -# -[ -test -] -# -[ -cfg +hir_lit ( -feature -= " -unicode -- -perl +a " ) -] -fn -class_perl_unicode -( ) -{ -/ -/ -Unicode +) +; assert_eq ! ( t ( -r " -\ -d +a +{ +1 +2 +} +? " ) -hir_uclass_query +hir_range ( -ClassQuery +false +hir : : -Binary +RepetitionRange +: +: +Bounded +( +1 +2 +) +hir_lit ( " -digit +a " ) ) @@ -19209,188 +14718,189 @@ assert_eq ( t ( -r " -\ -s +ab +? " ) -hir_uclass_query +hir_cat ( -ClassQuery -: -: -Binary +vec +! +[ +hir_lit ( " -space +a " ) -) -) -; -assert_eq -! +hir_quest ( -t +true +hir_lit ( -r " -\ -w +b " ) -hir_uclass_perl_word -( ) +] ) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" ) -] +; assert_eq ! ( t ( -r " ( -? -i +ab ) -\ -d +? " ) -hir_uclass_query +hir_quest ( -ClassQuery -: -: -Binary +true +hir_group +( +1 +hir_cat +( +vec +! +[ +hir_lit ( " -digit +a " ) -) -) -; -# -[ -cfg +hir_lit ( -feature -= " -unicode -- -case +b " ) ] +) +) +) +) +; assert_eq ! ( t ( -r " -( +a +| +b ? -i +" ) -\ -s +hir_alt +( +vec +! +[ +hir_lit +( +" +a " ) -hir_uclass_query +hir_quest ( -ClassQuery -: -: -Binary +true +hir_lit ( " -space +b " ) ) +] +) ) ; +} # [ -cfg +test +] +fn +cat_alt ( -feature -= -" -unicode -- -case -" ) -] +{ assert_eq ! ( t ( -r " ( -? -i +ab ) -\ -w " ) -hir_uclass_perl_word +hir_group +( +1 +hir_cat +( +vec +! +[ +hir_lit +( +" +a +" +) +hir_lit ( +" +b +" +) +] +) ) ) ; -/ -/ -Unicode -negated assert_eq ! ( t ( -r " -\ -D +a +| +b " ) -hir_negate -( -hir_uclass_query +hir_alt ( -ClassQuery -: -: -Binary +vec +! +[ +hir_lit ( " -digit +a " ) +hir_lit +( +" +b +" ) +] ) ) ; @@ -19399,26 +14909,38 @@ assert_eq ( t ( -r " -\ -S +a +| +b +| +c " ) -hir_negate +hir_alt ( -hir_uclass_query +vec +! +[ +hir_lit ( -ClassQuery -: -: -Binary +" +a +" +) +hir_lit ( " -space +b " ) +hir_lit +( +" +c +" ) +] ) ) ; @@ -19427,215 +14949,168 @@ assert_eq ( t ( -r " -\ -W +ab +| +bc +| +cd " ) -hir_negate +hir_alt ( -hir_uclass_perl_word +vec +! +[ +hir_lit ( +" +ab +" ) -) -) -; -# -[ -cfg +hir_lit ( -feature -= " -unicode -- -case +bc +" +) +hir_lit +( +" +cd " ) ] +) +) +; assert_eq ! ( t ( -r " ( -? -i +a +| +b ) -\ -D " ) -hir_negate +hir_group ( -hir_uclass_query +1 +hir_alt ( -ClassQuery -: -: -Binary +vec +! +[ +hir_lit ( " -digit +a " ) -) -) -) -; -# -[ -cfg +hir_lit ( -feature -= " -unicode -- -case +b " ) ] +) +) +) +; assert_eq ! ( t ( -r " ( -? -i +a +| +b +| +c ) -\ -S " ) -hir_negate +hir_group ( -hir_uclass_query +1 +hir_alt ( -ClassQuery -: -: -Binary +vec +! +[ +hir_lit ( " -space +a " ) -) -) -) -; -# -[ -cfg +hir_lit ( -feature -= " -unicode -- -case +b " ) -] -assert_eq -! -( -t +hir_lit ( -r " -( -? -i -) -\ -W +c " ) -hir_negate -( -hir_uclass_perl_word -( +] ) ) ) ; -} -# -[ -test -] -fn -class_perl_ascii -( -) -{ -/ -/ -ASCII -only assert_eq ! ( t ( -r " ( -? -- -u +ab +| +bc +| +cd ) -\ -d " ) -hir_ascii_bclass +hir_group ( -& -ast -: -: -ClassAsciiKind -: -: -Digit -) -) -; -assert_eq -! +1 +hir_alt ( -t +vec +! +[ +hir_lit ( -r " -( -? -- -u +ab +" ) -\ -s +hir_lit +( +" +bc " ) -hir_ascii_bclass +hir_lit ( -& -ast -: -: -ClassAsciiKind -: -: -Space +" +cd +" +) +] +) ) ) ; @@ -19644,108 +15119,94 @@ assert_eq ( t ( -r " ( -? -- -u +ab +| +( +bc +| +( +cd ) -\ -w -" ) -hir_ascii_bclass -( -& -ast -: -: -ClassAsciiKind -: -: -Word ) +" ) -; -assert_eq -! +hir_group ( -t +1 +hir_alt ( -r -" +vec +! +[ +hir_lit ( -? -i -- -u -) -\ -d +" +ab " ) -hir_ascii_bclass +hir_group ( -& -ast -: -: -ClassAsciiKind -: -: -Digit -) -) -; -assert_eq -! +2 +hir_alt ( -t +vec +! +[ +hir_lit ( -r " -( -? -i -- -u +bc +" ) -\ -s +hir_group +( +3 +hir_lit +( +" +cd " ) -hir_ascii_bclass -( -& -ast -: -: -ClassAsciiKind -: -: -Space +) +] +) +) +] +) ) ) ; +} +# +[ +test +] +fn +class_ascii +( +) +{ assert_eq ! ( t ( -r " -( -? -i -- -u -) -\ -w +[ +[ +: +alnum +: +] +] " ) -hir_ascii_bclass +hir_uclass +( +ascii_class ( & ast @@ -19754,34 +15215,29 @@ ast ClassAsciiKind : : -Word +Alnum +) ) ) ; -/ -/ -ASCII -only -negated assert_eq ! ( -t_bytes +t ( -r " -( -? -- -u -) -\ -D +[ +[ +: +alpha +: +] +] " ) -hir_negate +hir_uclass ( -hir_ascii_bclass +ascii_class ( & ast @@ -19790,7 +15246,7 @@ ast ClassAsciiKind : : -Digit +Alpha ) ) ) @@ -19798,22 +15254,21 @@ Digit assert_eq ! ( -t_bytes +t ( -r " -( -? -- -u -) -\ -S +[ +[ +: +ascii +: +] +] " ) -hir_negate +hir_uclass ( -hir_ascii_bclass +ascii_class ( & ast @@ -19822,7 +15277,7 @@ ast ClassAsciiKind : : -Space +Ascii ) ) ) @@ -19830,22 +15285,21 @@ Space assert_eq ! ( -t_bytes +t ( -r " -( -? -- -u -) -\ -W +[ +[ +: +blank +: +] +] " ) -hir_negate +hir_uclass ( -hir_ascii_bclass +ascii_class ( & ast @@ -19854,7 +15308,7 @@ ast ClassAsciiKind : : -Word +Blank ) ) ) @@ -19862,23 +15316,21 @@ Word assert_eq ! ( -t_bytes +t ( -r " -( -? -i -- -u -) -\ -D +[ +[ +: +cntrl +: +] +] " ) -hir_negate +hir_uclass ( -hir_ascii_bclass +ascii_class ( & ast @@ -19887,7 +15339,7 @@ ast ClassAsciiKind : : -Digit +Cntrl ) ) ) @@ -19895,23 +15347,21 @@ Digit assert_eq ! ( -t_bytes +t ( -r " -( -? -i -- -u -) -\ -S +[ +[ +: +digit +: +] +] " ) -hir_negate +hir_uclass ( -hir_ascii_bclass +ascii_class ( & ast @@ -19920,7 +15370,7 @@ ast ClassAsciiKind : : -Space +Digit ) ) ) @@ -19928,23 +15378,21 @@ Space assert_eq ! ( -t_bytes +t ( -r " -( -? -i -- -u -) -\ -W +[ +[ +: +graph +: +] +] " ) -hir_negate +hir_uclass ( -hir_ascii_bclass +ascii_class ( & ast @@ -19953,513 +15401,446 @@ ast ClassAsciiKind : : -Word +Graph ) ) ) ; -/ -/ -ASCII -only -negated -with -UTF -- -8 -mode -enabled -. -/ -/ -In -this -case -negating -any -Perl -class -results -in -an -error -because -/ -/ -all -such -classes -can -match -invalid -UTF -- -8 -. assert_eq ! ( -t_err -( -r -" +t ( -? -- -u -) -\ -D " -) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -InvalidUtf8 -span -: -Span +[ +[ : +lower : -new +] +] +" +) +hir_uclass ( -Position +ascii_class +( +& +ast : : -new -( -5 -1 -6 -) -Position +ClassAsciiKind : : -new -( -7 -1 -8 +Lower ) ) -} ) ; assert_eq ! ( -t_err -( -r -" +t ( -? -- -u -) -\ -S " -) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -InvalidUtf8 -span -: -Span +[ +[ : +print : -new +] +] +" +) +hir_uclass ( -Position +ascii_class +( +& +ast : : -new -( -5 -1 -6 -) -Position +ClassAsciiKind : : -new -( -7 -1 -8 +Print ) ) -} ) ; assert_eq ! ( -t_err -( -r -" +t ( -? -- -u -) -\ -W " -) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -InvalidUtf8 -span -: -Span +[ +[ : +punct : -new +] +] +" +) +hir_uclass ( -Position +ascii_class +( +& +ast : : -new -( -5 -1 -6 -) -Position +ClassAsciiKind : : -new -( -7 -1 -8 +Punct ) ) -} ) ; assert_eq ! ( -t_err -( -r -" +t ( -? -i -- -u -) -\ -D " -) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -InvalidUtf8 -span -: -Span +[ +[ : +space : -new +] +] +" +) +hir_uclass ( -Position +ascii_class +( +& +ast : : -new -( -6 -1 -7 -) -Position +ClassAsciiKind : : -new -( -8 -1 -9 +Space ) ) -} ) ; assert_eq ! ( -t_err -( -r -" +t ( -? -i -- -u -) -\ -S " -) -TestError -{ -kind -: -hir -: +[ +[ : -ErrorKind +upper : +] +] +" +) +hir_uclass +( +ascii_class +( +& +ast : -InvalidUtf8 -span : -Span +ClassAsciiKind : : -new +Upper +) +) +) +; +assert_eq +! ( -Position -: -: -new +t ( -6 -1 -7 -) -Position +" +[ +[ : +word : -new +] +] +" +) +hir_uclass ( -8 -1 -9 +ascii_class +( +& +ast +: +: +ClassAsciiKind +: +: +Word ) ) -} ) ; assert_eq ! ( -t_err -( -r -" +t ( -? -i -- -u -) -\ -W " -) -TestError -{ -kind +[ +[ : -hir +xdigit : +] +] +" +) +hir_uclass +( +ascii_class +( +& +ast : -ErrorKind : +ClassAsciiKind : -InvalidUtf8 -span : -Span +Xdigit +) +) +) +; +assert_eq +! +( +t +( +" +[ +[ : +^ +lower : -new +] +] +" +) +hir_negate ( -Position +hir_uclass +( +ascii_class +( +& +ast : : -new -( -6 -1 -7 -) -Position +ClassAsciiKind : : -new -( -8 -1 -9 +Lower +) ) ) -} ) ; -} -# -[ -test -] # [ cfg ( -not -( feature = " unicode - -perl +case " ) -) ] -fn -class_perl_word_disabled -( -) -{ assert_eq ! ( -t_err +t ( -r -" -\ -w " +( +? +i ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodePerlClassNotFound -span -: -Span +[ +[ : +lower : -new +] +] +" +) +hir_uclass ( -Position -: -: -new +& +[ ( -0 -1 -1 +' +A +' +' +Z +' ) -Position -: -: -new ( -2 -1 -3 -) +' +a +' +' +z +' ) +( +' +\ +u +{ +17F +} +' +' +\ +u +{ +17F } +' ) -; +( +' +\ +u +{ +212A } -# -[ -test +' +' +\ +u +{ +212A +} +' +) ] -# -[ -cfg -( -all +) +) +; +assert_eq +! ( -not +t ( -feature -= " -unicode +( +? - -perl +u +) +[ +[ +: +lower +: +] +] " ) -not +hir_bclass_from_char +( +ascii_class +( +& +ast +: +: +ClassAsciiKind +: +: +Lower +) +) +) +; +assert_eq +! +( +t ( -feature -= " -unicode +( +? +i - -bool +u +) +[ +[ +: +lower +: +] +] " ) +hir_case_fold +( +hir_bclass_from_char +( +ascii_class +( +& +ast +: +: +ClassAsciiKind +: +: +Lower ) ) -] -fn -class_perl_space_disabled -( ) -{ +) +; assert_eq ! ( t_err ( -r " -\ -s +( +? +- +u +) +[ +[ +: +^ +lower +: +] +] " ) TestError @@ -20472,7 +15853,7 @@ hir ErrorKind : : -UnicodePerlClassNotFound +InvalidUtf8 span : Span @@ -20485,71 +15866,43 @@ Position : new ( -0 -1 +6 1 +7 ) Position : : new ( -2 +16 1 -3 +17 ) ) } ) ; -} -# -[ -test -] -# -[ -cfg -( -all +assert_eq +! ( -not +t_err ( -feature -= -" -unicode -- -perl " -) -not ( -feature -= -" -unicode +? +i - -gencat -" -) -) +u ) +[ +[ +: +^ +lower +: +] ] -fn -class_perl_digit_disabled -( -) -{ -assert_eq -! -( -t_err -( -r -" -\ -d " ) TestError @@ -20562,7 +15915,7 @@ hir ErrorKind : : -UnicodePerlClassNotFound +InvalidUtf8 span : Span @@ -20575,18 +15928,18 @@ Position : new ( -0 -1 +7 1 +8 ) Position : : new ( -2 +17 1 -3 +18 ) ) } @@ -20597,128 +15950,90 @@ new [ test ] -# -[ -cfg -( -feature -= -" -unicode -- -gencat -" -) -] fn -class_unicode_gencat +class_ascii_multiple ( ) { -assert_eq -! -( -t -( -r -" -\ -pZ -" -) -hir_uclass_query -( -ClassQuery +/ +/ +See : +https : -Binary -( -" -Z -" -) -) -) -; +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +680 assert_eq ! ( t ( -r -" -\ -pz " -) -hir_uclass_query -( -ClassQuery +[ +[ : +alnum : -Binary -( -" -Z +] +[ +: +^ +ascii +: +] +] " ) -) -) -; -assert_eq -! +hir_union ( -t +hir_uclass ( -r -" -\ -p -{ -Separator -} -" -) -hir_uclass_query +ascii_class ( -ClassQuery +& +ast : : -Binary -( -" -Z -" -) +ClassAsciiKind +: +: +Alnum ) ) -; -assert_eq -! +hir_uclass ( -t +& +[ ( -r -" +' \ -p +u { -se -PaRa -ToR +80 } -" -) -hir_uclass_query -( -ClassQuery -: -: -Binary -( -" -Z -" +' +' +\ +u +{ +10FFFF +} +' +) +] ) ) ) @@ -20726,63 +16041,84 @@ Z assert_eq ! ( -t +t_bytes ( -r " -\ -p -{ -gc +( +? +- +u +) +[ +[ : -Separator -} +alnum +: +] +[ +: +^ +ascii +: +] +] " ) -hir_uclass_query +hir_union ( -ClassQuery +hir_bclass_from_char +( +ascii_class +( +& +ast : : -Binary +ClassAsciiKind +: +: +Alnum +) +) +hir_bclass ( -" -Z -" +& +[ +( +0x80 +0xFF +) +] ) ) ) ; -assert_eq -! -( -t -( -r -" -\ -p -{ -gc -= -Separator } -" -) -hir_uclass_query -( -ClassQuery -: -: -Binary +# +[ +test +] +# +[ +cfg ( +feature += " -Z +unicode +- +perl " ) +] +fn +class_perl +( ) -) -; +{ +/ +/ +Unicode assert_eq ! ( @@ -20791,10 +16127,7 @@ t r " \ -p -{ -Other -} +d " ) hir_uclass_query @@ -20805,7 +16138,7 @@ ClassQuery Binary ( " -Other +digit " ) ) @@ -20819,7 +16152,7 @@ t r " \ -pC +s " ) hir_uclass_query @@ -20830,7 +16163,7 @@ ClassQuery Binary ( " -Other +space " ) ) @@ -20844,26 +16177,27 @@ t r " \ -PZ +w " ) -hir_negate -( -hir_uclass_query +hir_uclass_perl_word ( -ClassQuery -: -: -Binary +) +) +; +# +[ +cfg ( +feature += " -Z +unicode +- +case " ) -) -) -) -; +] assert_eq ! ( @@ -20871,15 +16205,14 @@ t ( r " +( +? +i +) \ -P -{ -separator -} +d " ) -hir_negate -( hir_uclass_query ( ClassQuery @@ -20888,13 +16221,25 @@ ClassQuery Binary ( " -Z +digit " ) ) ) -) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( @@ -20902,18 +16247,14 @@ t ( r " +( +? +i +) \ -P -{ -gc -! -= -separator -} +s " ) -hir_negate -( hir_uclass_query ( ClassQuery @@ -20922,13 +16263,25 @@ ClassQuery Binary ( " -Z +space " ) ) ) -) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( @@ -20936,27 +16289,23 @@ t ( r " +( +? +i +) \ -p -{ -any -} +w " ) -hir_uclass_query -( -ClassQuery -: -: -Binary +hir_uclass_perl_word ( -" -Any -" -) ) ) ; +/ +/ +Unicode +negated assert_eq ! ( @@ -20965,12 +16314,11 @@ t r " \ -p -{ -assigned -} +D " ) +hir_negate +( hir_uclass_query ( ClassQuery @@ -20979,11 +16327,12 @@ ClassQuery Binary ( " -Assigned +digit " ) ) ) +) ; assert_eq ! @@ -20993,12 +16342,11 @@ t r " \ -p -{ -ascii -} +S " ) +hir_negate +( hir_uclass_query ( ClassQuery @@ -21007,11 +16355,12 @@ ClassQuery Binary ( " -ASCII +space " ) ) ) +) ; assert_eq ! @@ -21021,28 +16370,30 @@ t r " \ -p -{ -gc -: -any -} +W " ) -hir_uclass_query -( -ClassQuery -: -: -Binary +hir_negate +( +hir_uclass_perl_word ( -" -Any -" ) ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( @@ -21050,15 +16401,16 @@ t ( r " +( +? +i +) \ -p -{ -gc -: -assigned -} +D " ) +hir_negate +( hir_uclass_query ( ClassQuery @@ -21067,12 +16419,26 @@ ClassQuery Binary ( " -Assigned +digit " ) ) ) +) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( @@ -21080,15 +16446,16 @@ t ( r " +( +? +i +) \ -p -{ -gc -: -ascii -} +S " ) +hir_negate +( hir_uclass_query ( ClassQuery @@ -21097,72 +16464,57 @@ ClassQuery Binary ( " -ASCII +space " ) ) ) +) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( -t_err +t ( r " ( ? -- -u +i ) \ -pZ +W " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodeNotAllowed -span -: -Span -: -: -new -( -Position -: -: -new +hir_negate ( -5 -1 -6 -) -Position -: -: -new +hir_uclass_perl_word ( -8 -1 -9 ) ) -} ) ; +/ +/ +ASCII +only assert_eq ! ( -t_err +t ( r " @@ -21172,370 +16524,228 @@ r u ) \ -p -{ -Separator -} +d " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodeNotAllowed -span -: -Span -: -: -new +hir_bclass_from_char ( -Position +ascii_class +( +& +ast : : -new -( -5 -1 -6 -) -Position +ClassAsciiKind : : -new -( -18 -1 -19 +Digit ) ) -} ) ; assert_eq ! ( -t_err +t ( r " +( +? +- +u +) \ -pE +s " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodePropertyNotFound -span -: -Span -: -: -new +hir_bclass_from_char ( -Position +ascii_class +( +& +ast : : -new -( -0 -1 -1 -) -Position +ClassAsciiKind : : -new -( -3 -1 -4 +Space ) ) -} ) ; assert_eq ! ( -t_err +t ( r " +( +? +- +u +) \ -p -{ -Foo -} +w " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodePropertyNotFound -span -: -Span -: -: -new +hir_bclass_from_char ( -Position -: -: -new +ascii_class ( -0 -1 -1 -) -Position +& +ast : : -new -( -7 -1 -8 +ClassAsciiKind +: +: +Word ) ) -} ) ; assert_eq ! ( -t_err +t ( r " +( +? +i +- +u +) \ -p -{ -gc -: -Foo -} +d " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodePropertyValueNotFound -span -: -Span -: -: -new +hir_bclass_from_char ( -Position +ascii_class +( +& +ast : : -new -( -0 -1 -1 -) -Position +ClassAsciiKind : : -new -( -10 -1 -11 +Digit ) ) -} ) ; -} -# -[ -test -] -# -[ -cfg +assert_eq +! ( -not +t ( -feature -= +r " -unicode +( +? +i - -gencat -" +u ) +\ +s +" ) -] -fn -class_unicode_gencat_disabled +hir_bclass_from_char +( +ascii_class ( +& +ast +: +: +ClassAsciiKind +: +: +Space ) -{ +) +) +; assert_eq ! ( -t_err +t ( r " +( +? +i +- +u +) \ -p -{ -Separator -} +w " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodePropertyNotFound -span -: -Span -: -: -new +hir_bclass_from_char ( -Position +ascii_class +( +& +ast : : -new -( -0 -1 -1 -) -Position +ClassAsciiKind : : -new -( -13 -1 -14 +Word ) ) -} ) ; +/ +/ +ASCII +only +negated assert_eq ! ( -t_err +t ( r " +( +? +- +u +) \ -p -{ -Any -} +D " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodePropertyNotFound -span -: -Span -: -: -new +hir_negate ( -Position +hir_bclass_from_char +( +ascii_class +( +& +ast : : -new -( -0 -1 -1 -) -Position +ClassAsciiKind : : -new -( -7 -1 -8 -) +Digit ) -} ) -; -} -# -[ -test -] -# -[ -cfg -( -feature -= -" -unicode -- -script -" ) -] -fn -class_unicode_script -( ) -{ +; assert_eq ! ( @@ -21543,40 +16753,34 @@ t ( r " +( +? +- +u +) \ -p -{ -Greek -} +S " ) -hir_uclass_query +hir_negate ( -ClassQuery +hir_bclass_from_char +( +ascii_class +( +& +ast : : -Binary -( -" -Greek -" +ClassAsciiKind +: +: +Space ) ) ) -; -# -[ -cfg -( -feature -= -" -unicode -- -case -" ) -] +; assert_eq ! ( @@ -21586,45 +16790,32 @@ r " ( ? -i +- +u ) \ -p -{ -Greek -} +W " ) -hir_case_fold +hir_negate ( -hir_uclass_query +hir_bclass_from_char ( -ClassQuery +ascii_class +( +& +ast : : -Binary -( -" -Greek -" +ClassAsciiKind +: +: +Word ) ) ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] assert_eq ! ( @@ -21635,29 +16826,27 @@ r ( ? i +- +u ) \ -P -{ -Greek -} +D " ) hir_negate ( -hir_case_fold +hir_bclass_from_char ( -hir_uclass_query +ascii_class ( -ClassQuery +& +ast : : -Binary -( -" -Greek -" -) +ClassAsciiKind +: +: +Digit ) ) ) @@ -21666,113 +16855,73 @@ Greek assert_eq ! ( -t_err +t ( r " +( +? +i +- +u +) \ -p -{ -sc -: -Foo -} +S " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodePropertyValueNotFound -span -: -Span -: -: -new +hir_negate ( -Position +hir_bclass_from_char +( +ascii_class +( +& +ast : : -new -( -0 -1 -1 -) -Position +ClassAsciiKind : : -new -( -10 -1 -11 +Space +) ) ) -} ) ; assert_eq ! ( -t_err +t ( r " +( +? +i +- +u +) \ -p -{ -scx -: -Foo -} +W " ) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -UnicodePropertyValueNotFound -span -: -Span -: -: -new +hir_negate ( -Position +hir_bclass_from_char +( +ascii_class +( +& +ast : : -new -( -0 -1 -1 -) -Position +ClassAsciiKind : : -new -( -11 -1 -12 +Word +) ) ) -} ) ; } @@ -21791,70 +16940,16 @@ feature " unicode - -script +perl " ) ) ] fn -class_unicode_script_disabled -( -) -{ -assert_eq -! -( -t_err +class_perl_word_disabled ( -r -" -\ -p -{ -Greek -} -" ) -TestError { -kind -: -hir -: -: -ErrorKind -: -: -UnicodePropertyNotFound -span -: -Span -: -: -new -( -Position -: -: -new -( -0 -1 -1 -) -Position -: -: -new -( -9 -1 -10 -) -) -} -) -; assert_eq ! ( @@ -21863,12 +16958,7 @@ t_err r " \ -p -{ -scx -: -Greek -} +w " ) TestError @@ -21881,7 +16971,7 @@ hir ErrorKind : : -UnicodePropertyNotFound +UnicodePerlClassNotFound span : Span @@ -21903,9 +16993,9 @@ Position : new ( -13 +2 1 -14 +3 ) ) } @@ -21920,17 +17010,33 @@ test [ cfg ( +all +( +not +( feature = " unicode - -age +perl +" +) +not +( +feature += +" +unicode +- +bool " ) +) +) ] fn -class_unicode_age +class_perl_space_disabled ( ) { @@ -21942,12 +17048,7 @@ t_err r " \ -p -{ -age -: -Foo -} +s " ) TestError @@ -21960,7 +17061,7 @@ hir ErrorKind : : -UnicodePropertyValueNotFound +UnicodePerlClassNotFound span : Span @@ -21982,9 +17083,9 @@ Position : new ( -11 +2 1 -12 +3 ) ) } @@ -21999,51 +17100,18 @@ test [ cfg ( +all +( +not +( feature = " unicode - -gencat -" -) -] -fn -class_unicode_any_empty -( -) -{ -assert_eq -! -( -t -( -r -" -\ -P -{ -any -} +perl " ) -hir_uclass -( -& -[ -] -) -) -; -} -# -[ -test -] -# -[ -cfg -( not ( feature @@ -22051,13 +17119,14 @@ feature " unicode - -age +gencat " ) ) +) ] fn -class_unicode_age_disabled +class_perl_digit_disabled ( ) { @@ -22069,14 +17138,7 @@ t_err r " \ -p -{ -age -: -3 -. -0 -} +d " ) TestError @@ -22089,7 +17151,7 @@ hir ErrorKind : : -UnicodePropertyNotFound +UnicodePerlClassNotFound span : Span @@ -22111,9 +17173,9 @@ Position : new ( -11 +2 1 -12 +3 ) ) } @@ -22124,8 +17186,21 @@ new [ test ] +# +[ +cfg +( +feature += +" +unicode +- +gencat +" +) +] fn -class_bracketed +class_unicode_gencat ( ) { @@ -22134,44 +17209,48 @@ assert_eq ( t ( +r " -[ -a -] +\ +pZ " ) -hir_lit +hir_uclass_query +( +ClassQuery +: +: +Binary ( " -a +Z " ) ) +) ; assert_eq ! ( t ( +r " -[ -ab -] +\ +pz " ) -hir_uclass +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -a -' -' -b -' +" +Z +" ) -] ) ) ; @@ -22180,30 +17259,55 @@ assert_eq ( t ( +r " -[ -^ -[ -a -] -] +\ +p +{ +Separator +} " ) -class_negate +hir_uclass_query ( -uclass +ClassQuery +: +: +Binary ( -& -[ +" +Z +" +) +) +) +; +assert_eq +! ( -' -a -' -' -a -' +t +( +r +" +\ +p +{ +se +PaRa +ToR +} +" ) -] +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +Z +" ) ) ) @@ -22213,27 +17317,28 @@ assert_eq ( t ( +r " -[ -a -- -z -] +\ +p +{ +gc +: +Separator +} " ) -hir_uclass +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -a -' -' -z -' +" +Z +" ) -] ) ) ; @@ -22242,29 +17347,28 @@ assert_eq ( t ( +r " -[ -a -- -fd -- -h -] +\ +p +{ +gc += +Separator +} " ) -hir_uclass +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -a -' -' -h -' +" +Z +" ) -] ) ) ; @@ -22273,29 +17377,26 @@ assert_eq ( t ( +r " -[ -a -- -fg -- -m -] +\ +p +{ +Other +} " ) -hir_uclass +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -a -' -' -m -' +" +Other +" ) -] ) ) ; @@ -22306,27 +17407,21 @@ t ( r " -[ \ -x00 -] +pC " ) -hir_uclass +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -\ -0 -' -' -\ -0 -' +" +Other +" ) -] ) ) ; @@ -22337,27 +17432,24 @@ t ( r " -[ \ -n -] +PZ " ) -hir_uclass +hir_negate ( -& -[ +hir_uclass_query ( -' -\ -n -' -' -\ -n -' +ClassQuery +: +: +Binary +( +" +Z +" +) ) -] ) ) ; @@ -22366,54 +17458,66 @@ assert_eq ( t ( +r " -[ \ -n -] +P +{ +separator +} " ) -hir_uclass +hir_negate ( -& -[ +hir_uclass_query ( -' -\ -n -' -' -\ -n -' +ClassQuery +: +: +Binary +( +" +Z +" +) ) -] ) ) ; -# -[ -cfg +assert_eq +! ( -any +t ( -feature -= -" -unicode -- -perl +r " -feature +\ +P +{ +gc +! = +separator +} " -unicode -- -gencat +) +hir_negate +( +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +Z " ) ) -] +) +) +; assert_eq ! ( @@ -22421,10 +17525,11 @@ t ( r " -[ \ -d -] +p +{ +any +} " ) hir_uclass_query @@ -22435,25 +17540,12 @@ ClassQuery Binary ( " -digit +Any " ) ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -gencat -" -) -] assert_eq ! ( @@ -22461,10 +17553,11 @@ t ( r " -[ \ -pZ -] +p +{ +assigned +} " ) hir_uclass_query @@ -22475,25 +17568,12 @@ ClassQuery Binary ( " -separator +Assigned " ) ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -gencat -" -) -] assert_eq ! ( @@ -22501,13 +17581,11 @@ t ( r " -[ \ p { -separator +ascii } -] " ) hir_uclass_query @@ -22518,35 +17596,42 @@ ClassQuery Binary ( " -separator +ASCII " ) ) ) ; -# -[ -cfg +assert_eq +! ( -any +t ( -feature -= +r " -unicode -- -perl +\ +p +{ +gc +: +any +} " -feature -= +) +hir_uclass_query +( +ClassQuery +: +: +Binary +( " -unicode -- -gencat +Any " ) ) -] +) +; assert_eq ! ( @@ -22554,11 +17639,13 @@ t ( r " -[ -^ \ -D -] +p +{ +gc +: +assigned +} " ) hir_uclass_query @@ -22569,25 +17656,12 @@ ClassQuery Binary ( " -digit +Assigned " ) ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -gencat -" -) -] assert_eq ! ( @@ -22595,11 +17669,13 @@ t ( r " -[ -^ \ -PZ -] +p +{ +gc +: +ascii +} " ) hir_uclass_query @@ -22610,292 +17686,427 @@ ClassQuery Binary ( " -separator +ASCII " ) ) ) ; -# -[ -cfg +assert_eq +! ( -feature -= +t_err +( +r " -unicode +( +? - -gencat +u +) +\ +pZ " ) -] +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodeNotAllowed +span +: +Span +: +: +new +( +Position +: +: +new +( +5 +1 +6 +) +Position +: +: +new +( +8 +1 +9 +) +) +} +) +; assert_eq ! ( -t +t_err ( r " -[ -^ +( +? +- +u +) \ -P +p { -separator +Separator } -] " ) -hir_uclass_query +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodeNotAllowed +span +: +Span +: +: +new ( -ClassQuery +Position : : -Binary +new ( -" -separator -" +5 +1 +6 +) +Position +: +: +new +( +18 +1 +19 ) ) +} ) ; -# -[ -cfg +assert_eq +! ( -all +t_err ( -feature -= +r " -unicode -- -case +\ +pE " -any +) +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyNotFound +span +: +Span +: +: +new ( -feature -= -" -unicode -- -perl -" -feature -= +Position +: +: +new +( +0 +1 +1 +) +Position +: +: +new +( +3 +1 +4 +) +) +} +) +; +assert_eq +! +( +t_err +( +r " -unicode -- -gencat +\ +p +{ +Foo +} " ) +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyNotFound +span +: +Span +: +: +new +( +Position +: +: +new +( +0 +1 +1 +) +Position +: +: +new +( +7 +1 +8 +) ) +} ) -] +; assert_eq ! ( -t +t_err ( r " -( -? -i -) -[ -^ \ -D -] +p +{ +gc +: +Foo +} " ) -hir_uclass_query +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyValueNotFound +span +: +Span +: +: +new ( -ClassQuery +Position : : -Binary +new ( -" -digit -" +0 +1 +1 +) +Position +: +: +new +( +10 +1 +11 ) ) +} ) ; +} +# +[ +test +] # [ cfg ( -all +not ( feature = " unicode - -case -" -feature -= -" -unicode -- -script +gencat " ) ) ] +fn +class_unicode_gencat_disabled +( +) +{ assert_eq ! ( -t +t_err ( r " -( -? -i -) -[ -^ \ -P +p { -greek +Separator } -] " ) -hir_case_fold -( -hir_uclass_query -( -ClassQuery +TestError +{ +kind : +hir : -Binary -( -" -greek -" -) -) -) -) -; -assert_eq -! -( -t +: +ErrorKind +: +: +UnicodePropertyNotFound +span +: +Span +: +: +new ( -" +Position +: +: +new ( -? -- -u -) -[ -a -] -" +0 +1 +1 ) -hir_bclass -( -& -[ +Position +: +: +new ( -b -' -a -' -b -' -a -' +13 +1 +14 ) -] ) +} ) ; assert_eq ! ( -t +t_err ( r " -( -? -- -u -) -[ \ -x00 -] +p +{ +Any +} " ) -hir_bclass +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyNotFound +span +: +Span +: +: +new ( -& -[ +Position +: +: +new ( -b -' -\ -0 -' -b -' -\ 0 -' -) -] -) -) -; -assert_eq -! -( -t_bytes -( -r -" -( -? -- -u -) -[ -\ -xFF -] -" -) -hir_bclass -( -& -[ -( -b -' -\ -xFF -' -b -' -\ -xFF -' +1 +1 ) -] +Position +: +: +new +( +7 +1 +8 ) ) +} +) ; +} +# +[ +test +] # [ cfg @@ -22905,46 +18116,40 @@ feature " unicode - -case +script " ) ] +fn +class_unicode_script +( +) +{ assert_eq ! ( t ( +r " -( -? -i -) -[ -a -] +\ +p +{ +Greek +} " ) -hir_uclass -( -& -[ +hir_uclass_query ( -' -A -' -' -A -' -) +ClassQuery +: +: +Binary ( -' -a -' -' -a -' +" +Greek +" ) -] ) ) ; @@ -22966,53 +18171,33 @@ assert_eq ( t ( +r " ( ? i ) -[ -k -] +\ +p +{ +Greek +} " ) -hir_uclass +hir_case_fold ( -& -[ +hir_uclass_query ( -' -K -' -' -K -' -) +ClassQuery +: +: +Binary ( -' -k -' -' -k -' +" +Greek +" ) -( -' -\ -u -{ -212A -} -' -' -\ -u -{ -212A -} -' ) -] ) ) ; @@ -23034,113 +18219,35 @@ assert_eq ( t ( +r " ( ? i ) -[ -] -" -) -hir_uclass -( -& -[ -( -' -' -' -' -) -( -' -' -' -' -) -( -' -' -' -' -) -] -) -) -; -assert_eq -! -( -t -( -" -( -? -i -- -u -) -[ -k -] +\ +P +{ +Greek +} " ) -hir_bclass -( -& -[ +hir_negate ( -b -' -K -' -b -' -K -' -) +hir_case_fold ( -b -' -k -' -b -' -k -' -) -] -) -) -; -assert_eq -! +hir_uclass_query ( -t +ClassQuery +: +: +Binary ( " -[ -^ -a -] +Greek " ) -class_negate -( -uclass -( -& -[ -( -' -a -' -' -a -' ) -] ) ) ) @@ -23148,130 +18255,256 @@ a assert_eq ! ( -t +t_err ( r " -[ -^ \ -x00 -] +p +{ +sc +: +Foo +} " ) -class_negate -( -uclass -( -& -[ +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyValueNotFound +span +: +Span +: +: +new +( +Position +: +: +new ( -' -\ -0 -' -' -\ 0 -' +1 +1 ) -] +Position +: +: +new +( +10 +1 +11 ) ) +} ) ; assert_eq ! ( -t_bytes +t_err ( +r " -( -? -- -u -) -[ -^ -a -] +\ +p +{ +scx +: +Foo +} " ) -class_negate -( -bclass +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyValueNotFound +span +: +Span +: +: +new ( -& -[ +Position +: +: +new ( -b -' -a -' -b -' -a -' +0 +1 +1 ) -] +Position +: +: +new +( +11 +1 +12 ) ) +} ) ; +} +# +[ +test +] # [ cfg ( -any +not ( feature = " unicode - -perl -" -feature -= -" -unicode -- -gencat +script " ) ) ] +fn +class_unicode_script_disabled +( +) +{ assert_eq ! ( -t +t_err ( r " -[ -^ \ -d -] +p +{ +Greek +} " ) -hir_negate +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyNotFound +span +: +Span +: +: +new ( -hir_uclass_query +Position +: +: +new ( -ClassQuery +0 +1 +1 +) +Position : : -Binary +new ( +9 +1 +10 +) +) +} +) +; +assert_eq +! +( +t_err +( +r " -digit +\ +p +{ +scx +: +Greek +} " ) +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyNotFound +span +: +Span +: +: +new +( +Position +: +: +new +( +0 +1 +1 +) +Position +: +: +new +( +13 +1 +14 ) ) +} ) ; +} +# +[ +test +] # [ cfg @@ -23281,41 +18514,76 @@ feature " unicode - -gencat +age " ) ] +fn +class_unicode_age +( +) +{ assert_eq ! ( -t +t_err ( r " -[ -^ \ -pZ -] +p +{ +age +: +Foo +} " ) -hir_negate -( -hir_uclass_query +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyValueNotFound +span +: +Span +: +: +new ( -ClassQuery +Position : : -Binary +new ( -" -separator -" +0 +1 +1 ) +Position +: +: +new +( +11 +1 +12 ) ) +} ) ; +} +# +[ +test +] # [ cfg @@ -23329,184 +18597,260 @@ gencat " ) ] +fn +class_unicode_any_empty +( +) +{ assert_eq ! ( -t +t_err ( r " -[ -^ \ -p +P { -separator +any } -] " ) -hir_negate -( -hir_uclass_query +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +EmptyClassNotAllowed +span +: +Span +: +: +new ( -ClassQuery +Position : : -Binary +new ( -" -separator -" +0 +1 +1 ) +Position +: +: +new +( +7 +1 +8 ) ) +} ) ; +} +# +[ +test +] # [ cfg ( -all +not ( feature = " unicode - -case -" -feature -= -" -unicode -- -script +age " ) ) ] +fn +class_unicode_age_disabled +( +) +{ assert_eq ! ( -t +t_err ( r " -( -? -i -) -[ -^ \ p { -greek +age +: +3 +. +0 } -] " ) -hir_negate -( -hir_case_fold -( -hir_uclass_query +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +UnicodePropertyNotFound +span +: +Span +: +: +new ( -ClassQuery +Position : : -Binary +new ( -" -greek -" -) +0 +1 +1 ) +Position +: +: +new +( +11 +1 +12 ) ) +} ) ; +} # [ -cfg +test +] +fn +class_bracketed ( -all +) +{ +assert_eq +! +( +t ( -feature -= -" -unicode -- -case -" -feature -= " -unicode -- -script +[ +a +] " ) +hir_uclass +( +& +[ +( +' +a +' +' +a +' ) ] +) +) +; assert_eq ! ( t ( -r " -( -? -i -) [ -\ -P -{ -greek -} +^ +[ +a +] ] " ) hir_negate ( -hir_case_fold +hir_uclass ( -hir_uclass_query +& +[ ( -ClassQuery -: -: -Binary +' +a +' +' +a +' +) +] +) +) +) +; +assert_eq +! +( +t ( " -greek +[ +a +- +z +] " ) +hir_uclass +( +& +[ +( +' +a +' +' +z +' ) -) +] ) ) ; -/ -/ -Test -some -weird -cases -. assert_eq ! ( t ( -r " [ -\ -[ +a +- +fd +- +h ] " ) @@ -23516,10 +18860,10 @@ hir_uclass [ ( ' -[ +a ' ' -[ +h ' ) ] @@ -23531,10 +18875,13 @@ assert_eq ( t ( -r " [ -& +a +- +fg +- +m ] " ) @@ -23544,10 +18891,10 @@ hir_uclass [ ( ' -& +a ' ' -& +m ' ) ] @@ -23563,7 +18910,7 @@ r " [ \ -& +x00 ] " ) @@ -23573,10 +18920,12 @@ hir_uclass [ ( ' -& +\ +0 ' ' -& +\ +0 ' ) ] @@ -23592,9 +18941,7 @@ r " [ \ -& -\ -& +n ] " ) @@ -23604,10 +18951,12 @@ hir_uclass [ ( ' -& +\ +n ' ' -& +\ +n ' ) ] @@ -23619,13 +18968,10 @@ assert_eq ( t ( -r " [ \ -x00 -- -& +n ] " ) @@ -23636,16 +18982,40 @@ hir_uclass ( ' \ -0 +n ' ' -& +\ +n ' ) ] ) ) ; +# +[ +cfg +( +any +( +feature += +" +unicode +- +perl +" +feature += +" +unicode +- +gencat +" +) +) +] assert_eq ! ( @@ -23654,33 +19024,38 @@ t r " [ -& -- \ -xFF +d ] " ) -hir_uclass +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -& -' -' -\ -u -{ -FF -} -' +" +digit +" ) -] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +gencat +" +) +] assert_eq ! ( @@ -23689,26 +19064,38 @@ t r " [ -~ +\ +pZ ] " ) -hir_uclass +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -~ -' -' -~ -' +" +separator +" ) -] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +gencat +" +) +] assert_eq ! ( @@ -23718,26 +19105,91 @@ r " [ \ -~ +p +{ +separator +} ] " ) -hir_uclass +hir_uclass_query ( -& +ClassQuery +: +: +Binary +( +" +separator +" +) +) +) +; +# [ +cfg ( -' -~ -' -' -~ -' +any +( +feature += +" +unicode +- +perl +" +feature += +" +unicode +- +gencat +" ) +) +] +assert_eq +! +( +t +( +r +" +[ +^ +\ +D ] +" +) +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +digit +" +) ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +gencat +" +) +] assert_eq ! ( @@ -23746,29 +19198,39 @@ t r " [ +^ \ -~ -\ -~ +PZ ] " ) -hir_uclass +hir_uclass_query ( -& +ClassQuery +: +: +Binary +( +" +separator +" +) +) +) +; +# [ +cfg ( -' -~ -' -' -~ -' +feature += +" +unicode +- +gencat +" ) ] -) -) -; assert_eq ! ( @@ -23777,65 +19239,62 @@ t r " [ +^ \ -x00 -- -~ +P +{ +separator +} ] " ) -hir_uclass +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -\ -0 -' -' -~ -' +" +separator +" ) -] ) ) ; -assert_eq -! +# +[ +cfg ( -t +all ( -r +feature += " -[ -~ +unicode - -\ -xFF -] +case " -) -hir_uclass -( -& -[ +any ( -' -~ -' -' -\ -u -{ -FF -} -' +feature += +" +unicode +- +perl +" +feature += +" +unicode +- +gencat +" ) -] ) ) -; +] assert_eq ! ( @@ -23843,27 +19302,54 @@ t ( r " +( +? +i +) [ -- +^ +\ +D ] " ) -hir_uclass +hir_uclass_query ( -& +ClassQuery +: +: +Binary +( +" +digit +" +) +) +) +; +# [ +cfg ( -' +all +( +feature += +" +unicode - -' -' +case +" +feature += +" +unicode - -' -) -] +script +" ) ) -; +] assert_eq ! ( @@ -23871,25 +19357,34 @@ t ( r " +( +? +i +) [ +^ \ -- +P +{ +greek +} ] " ) -hir_uclass +hir_case_fold ( -& -[ +hir_uclass_query ( -' -- -' -' -- -' +ClassQuery +: +: +Binary +( +" +greek +" +) ) -] ) ) ; @@ -23898,26 +19393,29 @@ assert_eq ( t ( -r " -[ -\ -- -\ +( +? - +u +) +[ +a ] " ) -hir_uclass +hir_bclass ( & [ ( +b ' -- +a ' +b ' -- +a ' ) ] @@ -23931,26 +19429,31 @@ t ( r " +( +? +- +u +) [ \ x00 -- -\ -- ] " ) -hir_uclass +hir_bclass ( & [ ( +b ' \ 0 ' +b ' -- +\ +0 ' ) ] @@ -23960,132 +19463,118 @@ hir_uclass assert_eq ! ( -t +t_bytes ( r " -[ -\ -- +( +? - +u +) +[ \ xFF ] " ) -hir_uclass +hir_bclass ( & [ ( +b ' -- +\ +xFF ' +b ' \ -u -{ -FF -} +xFF ' ) ] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( -t_err +t ( " ( ? -- -u +i ) [ -^ a ] -" -) -TestError -{ -kind -: -hir -: -: -ErrorKind -: -: -InvalidUtf8 -span -: -Span -: -: -new +" +) +hir_uclass ( -Position -: -: -new +& +[ ( -5 -1 -6 +' +A +' +' +A +' ) -Position -: -: -new ( -9 -1 -10 +' +a +' +' +a +' ) +] ) -} ) ; # [ cfg ( -any -( -feature -= -" -unicode -- -perl -" feature = " unicode - -bool +case " ) -) ] assert_eq ! ( t ( -r " +( +? +i +) [ -^ -\ -s -\ -S +k ] " ) @@ -24093,6 +19582,38 @@ hir_uclass ( & [ +( +' +K +' +' +K +' +) +( +' +k +' +' +k +' +) +( +' +\ +u +{ +212A +} +' +' +\ +u +{ +212A +} +' +) ] ) ) @@ -24101,116 +19622,131 @@ hir_uclass [ cfg ( -any -( -feature -= -" -unicode -- -perl -" feature = " unicode - -bool +case " ) -) ] assert_eq ! ( -t_bytes +t ( -r " ( ? -- -u +i ) [ -^ -\ -s -\ -S ] " ) -hir_bclass +hir_uclass ( & [ -] +( +' +' +' +' ) +( +' +' +' +' ) -; -} -# -[ -test -] -fn -class_bracketed_union ( +' +' +' +' ) -{ +] +) +) +; assert_eq ! ( t ( " -[ -a -- -zA +( +? +i - -Z +u +) +[ +k ] " ) -hir_uclass +hir_bclass ( & [ ( +b ' -A +K ' +b ' -Z +K ' ) ( +b ' -a +k ' +b ' -z +k ' ) ] ) ) ; -# -[ -cfg +assert_eq +! +( +t ( -feature -= " -unicode -- -gencat +[ +^ +a +] " ) +hir_negate +( +hir_uclass +( +& +[ +( +' +a +' +' +a +' +) ] +) +) +) +; assert_eq ! ( @@ -24219,13 +19755,13 @@ t r " [ -a +^ \ -pZb +x00 ] " ) -hir_union +hir_negate ( hir_uclass ( @@ -24233,25 +19769,53 @@ hir_uclass [ ( ' -a +\ +0 ' ' -b +\ +0 ' ) ] ) -hir_uclass_query +) +) +; +assert_eq +! ( -ClassQuery -: -: -Binary +t_bytes ( " -separator +( +? +- +u +) +[ +^ +a +] " ) +hir_negate +( +hir_bclass +( +& +[ +( +b +' +a +' +b +' +a +' +) +] ) ) ) @@ -24260,21 +19824,21 @@ separator [ cfg ( -all +any ( feature = " unicode - -gencat +perl " feature = " unicode - -script +gencat " ) ) @@ -24287,30 +19851,14 @@ t r " [ +^ \ -pZ -\ -p -{ -Greek -} +d ] " ) -hir_union -( -hir_uclass_query -( -ClassQuery -: -: -Binary +hir_negate ( -" -greek -" -) -) hir_uclass_query ( ClassQuery @@ -24319,7 +19867,7 @@ ClassQuery Binary ( " -separator +digit " ) ) @@ -24330,15 +19878,6 @@ separator [ cfg ( -all -( -feature -= -" -unicode -- -age -" feature = " @@ -24346,14 +19885,6 @@ unicode - gencat " -feature -= -" -unicode -- -script -" -) ) ] assert_eq @@ -24364,62 +19895,14 @@ t r " [ -\ -p -{ -age -: -3 -. -0 -} +^ \ pZ -\ -p -{ -Greek -} ] " ) -hir_union -( -hir_uclass_query -( -ClassQuery -: -: -ByValue -{ -property_name -: -" -age -" -property_value -: -" -3 -. -0 -" -} -) -hir_union -( -hir_uclass_query -( -ClassQuery -: -: -Binary +hir_negate ( -" -greek -" -) -) hir_uclass_query ( ClassQuery @@ -24434,21 +19917,11 @@ separator ) ) ) -) ; # [ cfg ( -all -( -feature -= -" -unicode -- -age -" feature = " @@ -24456,14 +19929,6 @@ unicode - gencat " -feature -= -" -unicode -- -script -" -) ) ] assert_eq @@ -24474,87 +19939,17 @@ t r " [ -[ -[ -\ -p -{ -age -: -3 -. -0 -} -\ -pZ -] -\ -p -{ -Greek -} -] -[ +^ \ p { -Cyrillic +separator } ] -] -" -) -hir_union -( -hir_uclass_query -( -ClassQuery -: -: -ByValue -{ -property_name -: -" -age -" -property_value -: -" -3 -. -0 -" -} -) -hir_union -( -hir_uclass_query -( -ClassQuery -: -: -Binary -( -" -cyrillic " ) -) -hir_union -( -hir_uclass_query -( -ClassQuery -: -: -Binary +hir_negate ( -" -greek -" -) -) hir_uclass_query ( ClassQuery @@ -24569,8 +19964,6 @@ separator ) ) ) -) -) ; # [ @@ -24583,13 +19976,6 @@ feature " unicode - -age -" -feature -= -" -unicode -- case " feature @@ -24597,13 +19983,6 @@ feature " unicode - -gencat -" -feature -= -" -unicode -- script " ) @@ -24621,64 +20000,19 @@ r i ) [ +^ \ p { -age -: -3 -. -0 -} -\ -pZ -\ -p -{ -Greek +greek } ] " ) -hir_case_fold -( -hir_union -( -hir_uclass_query -( -ClassQuery -: -: -ByValue -{ -property_name -: -" -age -" -property_value -: -" -3 -. -0 -" -} -) -hir_union -( -hir_uclass_query -( -ClassQuery -: -: -Binary -( -" -greek -" -) -) +hir_negate +( +hir_case_fold +( hir_uclass_query ( ClassQuery @@ -24687,14 +20021,13 @@ ClassQuery Binary ( " -separator +greek " ) ) ) ) ) -) ; # [ @@ -24707,14 +20040,7 @@ feature " unicode - -age -" -feature -= -" -unicode -- -gencat +case " feature = @@ -24733,120 +20059,258 @@ t ( r " +( +? +i +) [ -^ -\ -p -{ -age -: -3 -. -0 -} -\ -pZ \ -p +P { -Greek +greek } ] " ) hir_negate ( -hir_union +hir_case_fold ( hir_uclass_query ( ClassQuery : : -ByValue -{ -property_name -: -" -age +Binary +( " -property_value -: +greek " -3 +) +) +) +) +) +; +/ +/ +Test +some +weird +cases . -0 +assert_eq +! +( +t +( +r +" +[ +\ +[ +] " -} ) -hir_union +hir_uclass ( -hir_uclass_query +& +[ ( -ClassQuery -: -: -Binary +' +[ +' +' +[ +' +) +] +) +) +; +assert_eq +! +( +t ( +r " -greek +[ +& +] " ) +hir_uclass +( +& +[ +( +' +& +' +' +& +' +) +] +) ) -hir_uclass_query +; +assert_eq +! ( -ClassQuery -: -: -Binary +t ( +r " -separator +[ +\ +& +] " ) +hir_uclass +( +& +[ +( +' +& +' +' +& +' ) -) -) +] ) ) ; -# -[ -cfg +assert_eq +! ( -all +t ( -feature -= +r " -unicode -- -age +[ +\ +& +\ +& +] " -feature -= +) +hir_uclass +( +& +[ +( +' +& +' +' +& +' +) +] +) +) +; +assert_eq +! +( +t +( +r " -unicode +[ +\ +x00 - -case +& +] " -feature -= +) +hir_uclass +( +& +[ +( +' +\ +0 +' +' +& +' +) +] +) +) +; +assert_eq +! +( +t +( +r " -unicode +[ +& - -gencat +\ +xFF +] " -feature -= +) +hir_uclass +( +& +[ +( +' +& +' +' +\ +u +{ +FF +} +' +) +] +) +) +; +assert_eq +! +( +t +( +r " -unicode -- -script +[ +~ +] " ) +hir_uclass +( +& +[ +( +' +~ +' +' +~ +' ) ] +) +) +; assert_eq ! ( @@ -24854,100 +20318,126 @@ t ( r " -( -? -i -) [ -^ -\ -p -{ -age -: -3 -. -0 -} -\ -pZ \ -p -{ -Greek -} +~ ] " ) -hir_negate +hir_uclass ( -hir_case_fold +& +[ ( -hir_union +' +~ +' +' +~ +' +) +] +) +) +; +assert_eq +! ( -hir_uclass_query +t ( -ClassQuery -: -: -ByValue -{ -property_name -: -" -age -" -property_value -: +r " -3 -. -0 +[ +\ +~ +\ +~ +] " -} ) -hir_union -( -hir_uclass_query +hir_uclass ( -ClassQuery -: -: -Binary +& +[ ( -" -greek -" +' +~ +' +' +~ +' +) +] ) ) -hir_uclass_query +; +assert_eq +! ( -ClassQuery -: -: -Binary +t ( +r " -separator +[ +\ +x00 +- +~ +] " ) +hir_uclass +( +& +[ +( +' +\ +0 +' +' +~ +' ) -) -) -) +] ) ) ; -} -# +assert_eq +! +( +t +( +r +" [ -test +~ +- +\ +xFF ] -fn -class_bracketed_nested -( +" ) +hir_uclass +( +& +[ +( +' +~ +' +' +\ +u { +FF +} +' +) +] +) +) +; assert_eq ! ( @@ -24956,32 +20446,25 @@ t r " [ -a -[ -^ -c -] +- ] " ) -class_negate -( -uclass +hir_uclass ( & [ ( ' -c +- ' ' -c +- ' ) ] ) ) -) ; assert_eq ! @@ -24991,34 +20474,26 @@ t r " [ -a +\ - -b -[ -^ -c -] ] " ) -class_negate -( -uclass +hir_uclass ( & [ ( ' -c +- ' ' -c +- ' ) ] ) ) -) ; assert_eq ! @@ -25028,24 +20503,26 @@ t r " [ -a +\ +- +\ - -c -[ -^ -c -] ] " ) -class_negate -( -uclass +hir_uclass ( & [ -] +( +' +- +' +' +- +' ) +] ) ) ; @@ -25057,12 +20534,11 @@ t r " [ -^ -a -[ -^ -c -] +\ +x00 +- +\ +- ] " ) @@ -25072,10 +20548,11 @@ hir_uclass [ ( ' -c +\ +0 ' ' -c +- ' ) ] @@ -25090,14 +20567,11 @@ t r " [ -^ -a +\ - -b -[ -^ -c -] +- +\ +xFF ] " ) @@ -25107,219 +20581,262 @@ hir_uclass [ ( ' -c +- ' ' -c +\ +u +{ +FF +} ' ) ] ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] assert_eq ! ( -t +t_err ( -r " ( ? -i +- +u ) [ -a -[ ^ -c -] +a ] " ) -hir_negate -( -class_case_fold -( -uclass +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +InvalidUtf8 +span +: +Span +: +: +new ( -& -[ +Position +: +: +new ( -' -c -' -' -c -' -) -] +5 +1 +6 ) +Position +: +: +new +( +9 +1 +10 ) ) +} ) ; # [ cfg ( +any +( feature = " unicode - -case +perl +" +feature += +" +unicode +- +bool " ) +) ] assert_eq ! ( -t +t_err ( r " -( -? -i -) -[ -a -- -b [ ^ -c -] +\ +s +\ +S ] " ) -hir_negate -( -class_case_fold -( -uclass +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +EmptyClassNotAllowed +span +: +Span +: +: +new ( -& -[ +Position +: +: +new ( -' -c -' -' -c -' -) -] +0 +1 +1 ) +Position +: +: +new +( +7 +1 +8 ) ) +} ) ; # [ cfg ( +any +( feature = " unicode - -case +perl +" +feature += +" +unicode +- +bool " ) +) ] assert_eq ! ( -t +t_err ( r " ( ? -i +- +u ) [ ^ -a -[ -^ -c -] +\ +s +\ +S ] " ) -hir_uclass +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +EmptyClassNotAllowed +span +: +Span +: +: +new ( -& -[ +Position +: +: +new ( -' -C -' -' -C -' +5 +1 +6 ) +Position +: +: +new ( -' -c -' -' -c -' +12 +1 +13 ) -] ) +} ) ; +} # [ -cfg +test +] +fn +class_bracketed_union ( -feature -= -" -unicode -- -case -" ) -] +{ assert_eq ! ( t ( -r " -( -? -i -) [ -^ a - -b -[ -^ -c -] +zA +- +Z ] " ) @@ -25329,24 +20846,37 @@ hir_uclass [ ( ' -C +A ' ' -C +Z ' ) ( ' -c +a ' ' -c +z ' ) ] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +gencat +" +) +] assert_eq ! ( @@ -25355,37 +20885,65 @@ t r " [ -^ a -- -c -[ -^ -c -] +\ +pZb ] " ) +hir_union +( hir_uclass ( & [ +( +' +a +' +' +b +' +) ] ) +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +separator +" +) +) +) ) ; # [ cfg ( +all +( feature = " unicode - -case +gencat +" +feature += +" +unicode +- +script " ) +) ] assert_eq ! @@ -25394,325 +20952,446 @@ t ( r " -( -? -i -) -[ -^ -a -- -c [ -^ -c -] +\ +pZ +\ +p +{ +Greek +} ] " ) -hir_uclass +hir_union ( -& -[ -] +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +greek +" +) +) +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +separator +" +) +) ) ) ; -} # [ -test -] -fn -class_bracketed_intersect +cfg +( +all ( +feature += +" +unicode +- +age +" +feature += +" +unicode +- +gencat +" +feature += +" +unicode +- +script +" ) -{ +) +] assert_eq ! ( t ( +r " [ -abc -& -& -b -- -c +\ +p +{ +age +: +3 +. +0 +} +\ +pZ +\ +p +{ +Greek +} ] " ) -hir_uclass +hir_union ( -& -[ +hir_uclass_query ( -' -b -' -' -c -' +ClassQuery +: +: +ByValue +{ +property_name +: +" +age +" +property_value +: +" +3 +. +0 +" +} ) -] +hir_union +( +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +greek +" ) ) -; -assert_eq -! +hir_uclass_query ( -t +ClassQuery +: +: +Binary ( " -[ -abc -& -& -[ -b -- -c -] -] +separator " ) -hir_uclass -( -& +) +) +) +) +; +# [ +cfg ( -' -b -' -' -c -' -) -] +all +( +feature += +" +unicode +- +age +" +feature += +" +unicode +- +gencat +" +feature += +" +unicode +- +script +" ) ) -; +] assert_eq ! ( t ( +r " [ [ -abc +[ +\ +p +{ +age +: +3 +. +0 +} +\ +pZ +] +\ +p +{ +Greek +} ] -& -& [ -b -- -c +\ +p +{ +Cyrillic +} ] ] " ) -hir_uclass +hir_union ( -& -[ +hir_uclass_query ( -' -b -' -' -c -' +ClassQuery +: +: +ByValue +{ +property_name +: +" +age +" +property_value +: +" +3 +. +0 +" +} ) -] +hir_union +( +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +cyrillic +" ) ) -; -assert_eq -! +hir_union ( -t +hir_uclass_query +( +ClassQuery +: +: +Binary ( " -[ -a -- -z -& -& -b -- -y -& -& -c -- -x -] +greek " ) -hir_uclass +) +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -c -' -' -x -' +" +separator +" +) +) +) ) -] ) ) ; -assert_eq -! +# +[ +cfg ( -t +all ( +feature += " -[ -c +unicode - -da +age +" +feature += +" +unicode - -b -& -& -a +case +" +feature += +" +unicode - -d -] +gencat +" +feature += +" +unicode +- +script " ) -hir_uclass -( -& -[ -( -' -a -' -' -d -' ) ] -) -) -; assert_eq ! ( t ( +r " +( +? +i +) [ -a -- -d -& -& -c -- -da -- -b +\ +p +{ +age +: +3 +. +0 +} +\ +pZ +\ +p +{ +Greek +} ] " ) -hir_uclass +hir_case_fold ( -& -[ +hir_union ( -' -a -' -' -d -' -) -] -) -) -; -assert_eq -! +hir_uclass_query +( +ClassQuery +: +: +ByValue +{ +property_name +: +" +age +" +property_value +: +" +3 +. +0 +" +} +) +hir_union ( -t +hir_uclass_query +( +ClassQuery +: +: +Binary ( -r " -[ -a -- -z -& -& -a -- -c -] +greek " ) -hir_uclass +) +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -' -a -' -' -c -' +" +separator +" +) +) +) ) -] ) ) ; -assert_eq -! +# +[ +cfg ( -t +all ( -r +feature += " -[ -[ -a +unicode - -z -& -& -a +age +" +feature += +" +unicode - -c -] -] +gencat +" +feature += +" +unicode +- +script " ) -hir_uclass -( -& -[ -( -' -a -' -' -c -' ) ] -) -) -; assert_eq ! ( @@ -25722,327 +21401,236 @@ r " [ ^ -[ -a -- -z -& -& -a -- -c -] +\ +p +{ +age +: +3 +. +0 +} +\ +pZ +\ +p +{ +Greek +} ] " ) hir_negate ( -hir_uclass -( -& -[ -( -' -a -' -' -c -' -) -] -) -) -) -; -assert_eq -! +hir_union ( -t +hir_uclass_query ( +ClassQuery +: +: +ByValue +{ +property_name +: " -( -? -- -u -) -[ -abc -& -& -b -- -c -] +age +" +property_value +: +" +3 +. +0 " +} ) -hir_bclass -( -& -[ +hir_union ( -b -' -b -' -b -' -c -' -) -] -) -) -; -assert_eq -! +hir_uclass_query ( -t +ClassQuery +: +: +Binary ( " -( -? -- -u -) -[ -abc -& -& -[ -b -- -c -] -] +greek " ) -hir_bclass -( -& -[ -( -b -' -b -' -b -' -c -' -) -] -) ) -; -assert_eq -! +hir_uclass_query ( -t +ClassQuery +: +: +Binary ( " -( -? -- -u -) -[ -[ -abc -] -& -& -[ -b -- -c -] -] +separator " ) -hir_bclass -( -& -[ -( -b -' -b -' -b -' -c -' ) -] +) +) ) ) ; -assert_eq -! +# +[ +cfg ( -t +all ( +feature += " -( -? +unicode - -u -) -[ -a +age +" +feature += +" +unicode - -z -& -& -b +case +" +feature += +" +unicode - -y -& -& -c +gencat +" +feature += +" +unicode - -x -] +script " ) -hir_bclass -( -& -[ -( -b -' -c -' -b -' -x -' ) ] -) -) -; assert_eq ! ( t ( +r " ( ? -- -u +i ) [ -c -- -da -- -b -& -& -a -- -d +^ +\ +p +{ +age +: +3 +. +0 +} +\ +pZ +\ +p +{ +Greek +} ] " ) -hir_bclass +hir_negate ( -& -[ +hir_case_fold ( -b -' -a -' -b -' -d -' -) -] -) -) -; -assert_eq -! +hir_union ( -t +hir_uclass_query ( +ClassQuery +: +: +ByValue +{ +property_name +: " -( -? -- -u +age +" +property_value +: +" +3 +. +0 +" +} ) -[ -a -- -d -& -& -c -- -da -- -b -] +hir_union +( +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +greek " ) -hir_bclass +) +hir_uclass_query ( -& -[ +ClassQuery +: +: +Binary ( -b -' -a -' -b -' -d -' +" +separator +" +) +) +) +) ) -] ) ) ; +} # [ -cfg +test +] +fn +class_bracketed_nested ( -feature -= -" -unicode -- -case -" ) -] +{ assert_eq ! ( t ( +r " -( -? -i -) [ -abc -& -& -b -- +a +[ +^ c ] +] " ) -hir_case_fold +hir_negate ( hir_uclass ( @@ -26050,7 +21638,7 @@ hir_uclass [ ( ' -b +c ' ' c @@ -26061,42 +21649,25 @@ c ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] assert_eq ! -( -t -( -" -( -? -i -) -[ -abc -& -& +( +t +( +r +" [ -b +a - +b +[ +^ c ] ] " ) -hir_case_fold +hir_negate ( hir_uclass ( @@ -26104,7 +21675,7 @@ hir_uclass [ ( ' -b +c ' ' c @@ -26115,52 +21686,59 @@ c ) ) ; -# -[ -cfg +assert_eq +! ( -feature -= +t +( +r " -unicode +[ +a - -case +c +[ +^ +c +] +] " ) +hir_negate +( +hir_uclass +( +& +[ ] +) +) +) +; assert_eq ! ( t ( +r " -( -? -i -) -[ [ -abc -] -& -& +^ +a [ -b -- +^ c ] ] " ) -hir_case_fold -( hir_uclass ( & [ ( ' -b +c ' ' c @@ -26169,50 +21747,26 @@ c ] ) ) -) ; -# -[ -cfg -( -feature -= -" -unicode -- -case -" -) -] assert_eq ! ( t ( +r " -( -? -i -) [ +^ a - -z -& -& b -- -y -& -& +[ +^ c -- -x +] ] " ) -hir_case_fold -( hir_uclass ( & @@ -26222,13 +21776,12 @@ hir_uclass c ' ' -x +c ' ) ] ) ) -) ; # [ @@ -26248,25 +21801,23 @@ assert_eq ( t ( +r " ( ? i ) [ -c -- -da -- -b -& -& a -- -d +[ +^ +c +] ] " ) +hir_negate +( hir_case_fold ( hir_uclass @@ -26275,16 +21826,17 @@ hir_uclass [ ( ' -a +c ' ' -d +c ' ) ] ) ) ) +) ; # [ @@ -26304,6 +21856,7 @@ assert_eq ( t ( +r " ( ? @@ -26312,17 +21865,16 @@ i [ a - -d -& -& -c -- -da -- b +[ +^ +c +] ] " ) +hir_negate +( hir_case_fold ( hir_uclass @@ -26331,96 +21883,68 @@ hir_uclass [ ( ' -a +c ' ' -d +c ' ) ] ) ) ) +) ; -assert_eq -! -( -t +# +[ +cfg ( +feature += " -( -? -i -- -u -) -[ -abc -& -& -b +unicode - -c -] +case " ) -hir_case_fold -( -hir_bclass -( -& -[ -( -b -' -b -' -b -' -c -' -) ] -) -) -) -; assert_eq ! ( t ( +r " ( ? i -- -u ) [ -abc -& -& +^ +a [ -b -- +^ c ] ] " ) -hir_case_fold -( -hir_bclass +hir_uclass ( & [ ( -b ' -b +C +' +' +C +' +) +( +' +c ' -b ' c ' @@ -26428,244 +21952,225 @@ c ] ) ) -) ; -assert_eq -! -( -t +# +[ +cfg ( +feature += " -( -? -i -- -u -) -[ -[ -abc -] -& -& -[ -b +unicode - -c -] -] -" -) -hir_case_fold -( -hir_bclass -( -& -[ -( -b -' -b -' -b -' -c -' +case +" ) ] -) -) -) -; assert_eq ! ( t ( +r " ( ? i -- -u ) [ +^ a - -z -& -& b -- -y -& -& +[ +^ c -- -x +] ] " ) -hir_case_fold -( -hir_bclass +hir_uclass ( & [ ( -b +' +C +' +' +C +' +) +( ' c ' -b ' -x +c ' ) ] ) ) -) ; assert_eq ! ( -t +t_err ( +r " -( -? -i -- -u -) [ -c -- -da -- -b -& -& +^ a - -d +c +[ +^ +c +] ] " ) -hir_case_fold -( -hir_bclass +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +EmptyClassNotAllowed +span +: +Span +: +: +new ( -& -[ +Position +: +: +new ( -b -' -a -' -b -' -d -' +0 +1 +1 ) -] +Position +: +: +new +( +10 +1 +11 ) ) +} ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( -t +t_err ( +r " ( ? i -- -u ) [ +^ a - -d -& -& c -- -da -- -b +[ +^ +c +] ] " ) -hir_case_fold -( -hir_bclass +TestError +{ +kind +: +hir +: +: +ErrorKind +: +: +EmptyClassNotAllowed +span +: +Span +: +: +new ( -& -[ +Position +: +: +new ( -b -' -a -' -b -' -d -' +4 +1 +5 ) -] +Position +: +: +new +( +14 +1 +15 ) ) +} ) ; -/ -/ -In +} +# [ -a -^ +test ] -^ -does -not -need -to -be -escaped -so -it -makes -sense -that -/ -/ -^ -is -also -allowed -to -be -unescaped -after -& -& -. +fn +class_bracketed_intersect +( +) +{ assert_eq ! ( t ( -r " [ -\ -^ +abc & & -^ +b +- +c ] " ) @@ -26675,48 +22180,30 @@ hir_uclass [ ( ' -^ +b ' ' -^ +c ' ) ] -) -) -; -/ -/ -] -needs -to -be -escaped -after -& -& -since -it -' -s -not -at -start -of -class -. +) +) +; assert_eq ! ( t ( -r " [ -] +abc & & -\ +[ +b +- +c ] ] " @@ -26727,10 +22214,10 @@ hir_uclass [ ( ' -] +b ' ' -] +c ' ) ] @@ -26742,13 +22229,18 @@ assert_eq ( t ( -r " [ -- +[ +abc +] & & +[ +b - +c +] ] " ) @@ -26758,10 +22250,10 @@ hir_uclass [ ( ' -- +b ' ' -- +c ' ) ] @@ -26773,14 +22265,21 @@ assert_eq ( t ( -r " [ -\ +a +- +z & & +b +- +y & & +c +- +x ] " ) @@ -26790,10 +22289,10 @@ hir_uclass [ ( ' -& +c ' ' -& +x ' ) ] @@ -26805,15 +22304,18 @@ assert_eq ( t ( -r " [ -\ -& -& +c +- +da +- +b & -\ & +a +- +d ] " ) @@ -26823,41 +22325,33 @@ hir_uclass [ ( ' -& +a ' ' -& +d ' ) ] ) ) ; -/ -/ -Test -precedence -. assert_eq ! ( t ( -r " [ a - -w +d & & -[ -^ c - -g -] -z +da +- +b ] " ) @@ -26870,44 +22364,13 @@ hir_uclass a ' ' -b -' -) -( -' -h -' -' -w +d ' ) ] ) ) ; -} -# -[ -test -] -fn -class_bracketed_intersect_negate -( -) -{ -# -[ -cfg -( -feature -= -" -unicode -- -perl -" -) -] assert_eq ! ( @@ -26916,30 +22379,30 @@ t r " [ -^ -\ -w +a +- +z & & -\ -d +a +- +c ] " ) -hir_negate -( -hir_uclass_query +hir_uclass ( -ClassQuery -: -: -Binary +& +[ ( -" -digit -" -) +' +a +' +' +c +' ) +] ) ) ; @@ -26951,7 +22414,6 @@ t r " [ -^ [ a - @@ -26965,8 +22427,6 @@ c ] " ) -hir_negate -( hir_uclass ( & @@ -26982,21 +22442,7 @@ c ] ) ) -) ; -# -[ -cfg -( -feature -= -" -unicode -- -perl -" -) -] assert_eq ! ( @@ -27007,146 +22453,165 @@ r [ ^ [ -\ -w +a +- +z & & -\ -d +a +- +c ] ] " ) hir_negate ( -hir_uclass_query +hir_uclass ( -ClassQuery -: -: -Binary +& +[ ( -" -digit -" +' +a +' +' +c +' ) +] ) ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -perl -" -) -] assert_eq ! ( t ( -r " +( +? +- +u +) [ -^ -[ -^ -\ -w +abc & & -\ -d -] +b +- +c ] " ) -hir_uclass_query +hir_bclass ( -ClassQuery -: -: -Binary +& +[ +( +b +' +b +' +b +' +c +' +) +] +) +) +; +assert_eq +! +( +t ( " -digit +( +? +- +u +) +[ +abc +& +& +[ +b +- +c +] +] " ) -) -) -; -# +hir_bclass +( +& [ -cfg ( -feature -= -" -unicode -- -perl -" +b +' +b +' +b +' +c +' ) ] +) +) +; assert_eq ! ( t ( -r " +( +? +- +u +) [ [ -[ -^ -\ -w +abc ] & & [ -^ -\ -d -] +b +- +c ] ] " ) -hir_negate +hir_bclass ( -hir_uclass_perl_word +& +[ ( +b +' +b +' +b +' +c +' ) +] ) ) ; -# -[ -cfg -( -feature -= -" -unicode -- -perl -" -) -] assert_eq ! ( -t_bytes +t ( -r " ( ? @@ -27154,38 +22619,45 @@ r u ) [ -^ -\ -w +a +- +z & & -\ -d +b +- +y +& +& +c +- +x ] " ) -hir_negate -( -hir_ascii_bclass +hir_bclass ( & -ast -: -: -ClassAsciiKind -: -: -Digit +[ +( +b +' +c +' +b +' +x +' ) +] ) ) ; assert_eq ! ( -t_bytes +t ( -r " ( ? @@ -27193,22 +22665,19 @@ r u ) [ -^ -[ -a +c - -z +da +- +b & & a - -c -] +d ] " ) -hir_negate -( hir_bclass ( & @@ -27220,20 +22689,18 @@ a ' b ' -c +d ' ) ] ) ) -) ; assert_eq ! ( -t_bytes +t ( -r " ( ? @@ -27241,129 +22708,143 @@ r u ) [ -^ -[ -\ -w +a +- +d & & -\ -d -] +c +- +da +- +b ] " ) -hir_negate -( -hir_ascii_bclass +hir_bclass ( & -ast -: -: -ClassAsciiKind -: -: -Digit +[ +( +b +' +a +' +b +' +d +' ) +] ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( -t_bytes +t ( -r " ( ? -- -u +i ) [ -^ -[ -^ -\ -w +abc & & -\ -d -] +b +- +c ] " ) -hir_ascii_bclass +hir_case_fold +( +hir_uclass ( & -ast -: -: -ClassAsciiKind -: -: -Digit +[ +( +' +b +' +' +c +' +) +] +) ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( -t_bytes +t ( -r " ( ? -- -u +i ) [ -[ -[ -^ -\ -w -] -& +abc & -[ -^ -\ -d -] +& +[ +b +- +c ] ] " ) -hir_negate +hir_case_fold ( -hir_ascii_bclass +hir_uclass ( & -ast -: -: -ClassAsciiKind -: -: -Word +[ +( +' +b +' +' +c +' ) +] ) ) -; -} -# -[ -test -] -fn -class_bracketed_difference -( ) -{ +; # [ cfg @@ -27373,7 +22854,7 @@ feature " unicode - -gencat +case " ) ] @@ -27382,47 +22863,37 @@ assert_eq ( t ( -r " +( +? +i +) [ -\ -pL -- -- [ -: -ascii -: +abc +] +& +& +[ +b +- +c ] ] " ) -hir_difference -( -hir_uclass_query -( -ClassQuery -: -: -Binary +hir_case_fold ( -" -letter -" -) -) hir_uclass ( & [ ( ' -\ -0 +b ' ' -\ -x7F +c ' ) ] @@ -27430,62 +22901,65 @@ x7F ) ) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( t ( -r " ( ? -- -u +i ) [ -[ -: -alpha -: -] +a - +z +& +& +b - -[ -: -lower -: -] +y +& +& +c +- +x ] " ) -hir_bclass +hir_case_fold +( +hir_uclass ( & [ ( -b ' -A +c ' -b ' -Z +x ' ) ] ) ) -; -} -# -[ -test -] -fn -class_bracketed_symmetric_difference -( ) -{ +; # [ cfg @@ -27495,7 +22969,7 @@ feature " unicode - -script +case " ) ] @@ -27504,151 +22978,124 @@ assert_eq ( t ( -r " +( +? +i +) [ -\ -p -{ -sc -: -Greek -} -~ -~ -\ -p -{ -scx -: -Greek -} +c +- +da +- +b +& +& +a +- +d ] " ) +hir_case_fold +( hir_uclass ( & [ ( ' -\ -u -{ -0342 -} -' -' -\ -u -{ -0342 -} -' -) -( -' -\ -u -{ -0345 -} -' -' -\ -u -{ -0345 -} -' -) -( -' -\ -u -{ -1DC0 -} +a ' ' -\ -u -{ -1DC1 -} +d ' ) ] ) ) +) ; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] assert_eq ! ( t ( -r " +( +? +i +) [ a - -g -~ -~ +d +& +& c - -j +da +- +b ] " ) -hir_uclass +hir_case_fold ( -& -[ +hir_uclass ( -' -a -' -' -b -' -) +& +[ ( ' -h +a ' ' -j +d ' ) ] ) ) +) ; assert_eq ! ( t ( -r " ( ? +i - u ) [ -a +abc +& +& +b - -g -~ -~ c -- -j ] " ) +hir_case_fold +( hir_bclass ( & @@ -27656,60 +23103,16 @@ hir_bclass ( b ' -a -' -b -' -b -' -) -( b ' -h -' b ' -j +c ' ) ] ) ) -; -} -# -[ -test -] -fn -ignore_whitespace -( -) -{ -assert_eq -! -( -t -( -r -" -( -? -x -) -\ -12 -3 -" -) -hir_lit -( -" -\ -n3 -" -) ) ; assert_eq @@ -27717,58 +23120,43 @@ assert_eq ( t ( -r " ( ? -x -) -\ -x -{ -53 -} -" +i +- +u ) -hir_lit -( -" -S +[ +abc +& +& +[ +b +- +c +] +] " ) -) -; -assert_eq -! +hir_case_fold ( -t +hir_bclass ( -r -" +& +[ ( -? -x +b +' +b +' +b +' +c +' ) -\ -x -# -comment -{ -# -comment -53 -# -comment -} -# -comment -" +] ) -hir_lit -( -" -S -" ) ) ; @@ -27777,50 +23165,45 @@ assert_eq ( t ( -r " ( ? -x -) -\ -x -53 -" +i +- +u ) -hir_lit -( -" -S +[ +[ +abc +] +& +& +[ +b +- +c +] +] " ) -) -; -assert_eq -! +hir_case_fold ( -t +hir_bclass ( -r -" +& +[ ( -? -x +b +' +b +' +b +' +c +' ) -\ -x -# -comment -53 -# -comment -" +] ) -hir_lit -( -" -S -" ) ) ; @@ -27829,74 +23212,47 @@ assert_eq ( t ( -r " ( ? -x -) -\ -x5 -3 -" -) -hir_lit -( -" -S -" -) +i +- +u ) -; -# [ -cfg -( -feature -= -" -unicode +a - -gencat -" -) -] -assert_eq -! -( -t -( -r -" -( -? -x -) -\ -p -# -comment -{ -# -comment -Separator -# -comment -} -# -comment +z +& +& +b +- +y +& +& +c +- +x +] " ) -hir_uclass_query +hir_case_fold ( -ClassQuery -: -: -Binary +hir_bclass ( -" -separator -" +& +[ +( +b +' +c +' +b +' +x +' +) +] ) ) ) @@ -27906,44 +23262,44 @@ assert_eq ( t ( -r " ( ? -x +i +- +u ) +[ +c +- +da +- +b +& +& a -# -comment -{ -# -comment -5 -# -comment -# -comment -10 -# -comment -} -# -comment +- +d +] " ) -hir_range +hir_case_fold ( -true -5 -Some +hir_bclass ( -10 -) -hir_lit +& +[ ( -" +b +' a -" +' +b +' +d +' +) +] ) ) ) @@ -27953,800 +23309,1147 @@ assert_eq ( t ( -r " ( ? -x +i +- +u ) +[ a -\ -# -hi -there +- +d +& +& +c +- +da +- +b +] " ) -hir_lit +hir_case_fold ( -" +hir_bclass +( +& +[ +( +b +' a -" +' +b +' +d +' +) +] +) ) ) ; -} -# +/ +/ +In [ -test +a +^ ] -fn -analysis_is_utf8 -( -) -{ +^ +does +not +need +to +be +escaped +so +it +makes +sense +that / / -Positive -examples +^ +is +also +allowed +to +be +unescaped +after +& +& . -assert +assert_eq ! ( -props_bytes +t ( r " -a +[ +\ +^ +& +& +^ +] " ) -. -is_utf8 +hir_uclass +( +& +[ ( +' +^ +' +' +^ +' +) +] ) ) ; -assert +/ +/ +] +needs +to +be +escaped +after +& +& +since +it +' +s +not +at +start +of +class +. +assert_eq ! ( -props_bytes +t ( r " -ab +[ +] +& +& +\ +] +] " ) -. -is_utf8 +hir_uclass +( +& +[ ( +' +] +' +' +] +' +) +] ) ) ; -assert +assert_eq ! ( -props_bytes +t ( r " -( -? +[ - -u -) -a +& +& +- +] " ) -. -is_utf8 -( -) -) -; -assert -! -( -props_bytes +hir_uclass ( -r -" +& +[ ( -? +' +- +' +' - -u -) -ab -" +' ) -. -is_utf8 -( +] ) ) ; -assert +assert_eq ! ( -props_bytes +t ( r " +[ \ -xFF +& +& +& +& +] " ) -. -is_utf8 +hir_uclass ( +& +[ +( +' +& +' +' +& +' +) +] ) ) ; -assert +assert_eq ! ( -props_bytes +t ( r " +[ \ -xFF +& +& +& \ -xFF +& +] " ) -. -is_utf8 +hir_uclass ( +& +[ +( +' +& +' +' +& +' +) +] ) ) ; -assert +/ +/ +Test +precedence +. +assert_eq ! ( -props_bytes +t ( r " [ -^ a +- +w +& +& +[ +^ +c +- +g +] +z ] " ) -. -is_utf8 -( -) -) -; -assert -! -( -props_bytes +hir_uclass ( -r -" +& [ -^ +( +' a +' +' +b +' +) +( +' +h +' +' +w +' +) ] +) +) +; +} +# [ -^ -a +test ] -" -) -. -is_utf8 +fn +class_bracketed_intersect_negate ( ) +{ +# +[ +cfg +( +feature += +" +unicode +- +perl +" ) -; -assert +] +assert_eq ! ( -props_bytes +t ( r " +[ +^ \ -b +w +& +& +\ +d +] " ) -. -is_utf8 +hir_negate ( -) -) -; -assert -! +hir_uclass_query ( -props_bytes +ClassQuery +: +: +Binary ( -r " -\ -B +digit " ) -. -is_utf8 -( +) ) ) ; -assert +assert_eq ! ( -props_bytes +t ( r " -( -? +[ +^ +[ +a - -u -) -\ -b +z +& +& +a +- +c +] +] " ) -. -is_utf8 +hir_negate ( +hir_uclass +( +& +[ +( +' +a +' +' +c +' +) +] +) ) ) ; -assert -! -( -props_bytes +# +[ +cfg ( -r +feature += " -( -? +unicode - -u -) -\ -B +perl " ) -. -is_utf8 -( -) -) -; -/ -/ -Negative -examples -. -assert +] +assert_eq ! ( -! -props_bytes +t ( r " -( -? -- -u -) +[ +^ +[ \ -xFF +w +& +& +\ +d +] +] +" +) +hir_negate +( +hir_uclass_query +( +ClassQuery +: +: +Binary +( +" +digit " ) -. -is_utf8 -( +) ) ) ; -assert -! -( -! -props_bytes +# +[ +cfg ( -r +feature += " -( -? +unicode - -u -) -\ -xFF -\ -xFF +perl " ) -. -is_utf8 -( -) -) -; -assert +] +assert_eq ! ( -! -props_bytes +t ( r " -( -? -- -u -) [ ^ -a +[ +^ +\ +w +& +& +\ +d +] ] " ) -. -is_utf8 +hir_uclass_query +( +ClassQuery +: +: +Binary ( +" +digit +" +) ) ) ; -assert -! +# +[ +cfg ( +feature += +" +unicode +- +perl +" +) +] +assert_eq ! -props_bytes +( +t ( r " -( -? -- -u -) +[ +[ [ ^ -a +\ +w ] +& +& [ ^ -a +\ +d +] +] ] " ) -. -is_utf8 +hir_negate +( +hir_uclass_perl_word ( ) ) +) ; -} # [ -test -] -fn -analysis_captures_len +cfg ( +feature += +" +unicode +- +perl +" ) -{ +] assert_eq ! ( -0 -props +t_bytes ( r " -a -" -) -. -explicit_captures_len ( +? +- +u ) +[ +^ +\ +w +& +& +\ +d +] +" ) -; -assert_eq -! +hir_negate ( -0 -props +hir_bclass_from_char ( -r -" +ascii_class ( -? +& +ast : -a +: +ClassAsciiKind +: +: +Digit ) -" ) -. -explicit_captures_len -( ) ) ; assert_eq ! ( -0 -props +t_bytes ( r " ( ? -i - u -: -a ) +[ +^ +[ +a +- +z +& +& +a +- +c +] +] " ) -. -explicit_captures_len +hir_negate +( +hir_bclass ( +& +[ +( +b +' +a +' +b +' +c +' +) +] +) ) ) ; assert_eq ! ( -0 -props +t_bytes ( r " ( ? -i - u ) -a +[ +^ +[ +\ +w +& +& +\ +d +] +] " ) -. -explicit_captures_len -( -) -) -; -assert_eq -! +hir_negate ( -1 -props +hir_bclass_from_char ( -r -" +ascii_class ( -a +& +ast +: +: +ClassAsciiKind +: +: +Digit ) -" ) -. -explicit_captures_len -( ) ) ; assert_eq ! ( -1 -props +t_bytes ( r " ( ? -P -< -foo -> -a +- +u ) +[ +^ +[ +^ +\ +w +& +& +\ +d +] +] " ) -. -explicit_captures_len -( +hir_bclass_from_char +( +ascii_class +( +& +ast +: +: +ClassAsciiKind +: +: +Digit +) ) ) ; assert_eq ! ( -1 -props +t_bytes ( r " ( +? +- +u ) +[ +[ +[ +^ +\ +w +] +& +& +[ +^ +\ +d +] +] +] " ) -. -explicit_captures_len +hir_negate +( +hir_bclass_from_char ( +ascii_class +( +& +ast +: +: +ClassAsciiKind +: +: +Word +) +) ) ) ; -assert_eq -! +} +# +[ +test +] +fn +class_bracketed_difference ( -1 -props +) +{ +# +[ +cfg ( -r +feature += " -( -) -a +unicode +- +gencat " ) -. -explicit_captures_len -( -) -) -; +] assert_eq ! ( -1 -props +t ( r " -( -a -) -+ +[ +\ +pL +- +- +[ +: +ascii +: +] +] " ) -. -explicit_captures_len +hir_difference ( -) -) -; -assert_eq -! +hir_uclass_query ( -2 -props +ClassQuery +: +: +Binary ( -r " -( -a +letter +" +) ) +hir_uclass ( -b +& +[ +( +' +\ +0 +' +' +\ +x7F +' ) -" +] ) -. -explicit_captures_len -( ) ) ; assert_eq ! ( -2 -props +t ( r " ( -a -) -| -( -b +? +- +u ) +[ +[ +: +alpha +: +] +- +- +[ +: +lower +: +] +] " ) -. -explicit_captures_len +hir_bclass +( +& +[ ( +b +' +A +' +b +' +Z +' +) +] ) ) ; -assert_eq -! +} +# +[ +test +] +fn +class_bracketed_symmetric_difference ( -2 -props +) +{ +# +[ +cfg ( -r +feature += " -( -( -a -) -) +unicode +- +script " ) -. -explicit_captures_len -( -) -) -; +] assert_eq ! ( -1 -props +t ( r " -( [ -a -& -& -b +\ +p +{ +sc +: +Greek +} +~ +~ +\ +p +{ +scx +: +Greek +} ] -) " ) -. -explicit_captures_len +hir_uclass ( -) -) -; -} -# +& [ -test -] -fn -analysis_static_captures_len ( +' +\ +u +{ +0342 +} +' +' +\ +u +{ +0342 +} +' ) +( +' +\ +u +{ +0345 +} +' +' +\ +u { -let -len -= -| -pattern -| -props -( -pattern +0345 +} +' ) -. -static_explicit_captures_len ( +' +\ +u +{ +1DC0 +} +' +' +\ +u +{ +1DC1 +} +' +) +] +) ) ; assert_eq ! ( -Some -( -0 -) -len +t ( r " +[ +a +- +g +~ +~ +c +- +j +] " ) -) -; -assert_eq -! +hir_uclass ( -Some +& +[ ( -0 +' +a +' +' +b +' ) -len ( -r -" -foo -| -bar -" +' +h +' +' +j +' +) +] ) ) ; assert_eq ! ( -None -len +t ( r " ( -foo +? +- +u ) -| -bar +[ +a +- +g +~ +~ +c +- +j +] " ) -) -; -assert_eq -! +hir_bclass ( -None -len +& +[ ( -r -" -foo -| +b +' +a +' +b +' +b +' +) ( -bar +b +' +h +' +b +' +j +' ) -" +] ) ) ; +} +# +[ +test +] +fn +ignore_whitespace +( +) +{ assert_eq ! ( -Some -( -1 -) -len +t ( r " ( -foo -| -bar +? +x ) +\ +12 +3 " ) -) -; -assert_eq -! -( -Some -( -1 -) -len +hir_lit ( -r " -( -a -| -b -| -c -| -d -| -e -| -f -) +\ +n3 " ) ) @@ -28754,37 +24457,25 @@ f assert_eq ! ( -Some -( -1 -) -len +t ( r " ( -a -) -| -( -b -) -| -( -c -) -| -( -d +? +x ) -| -( -e +\ +x +{ +53 +} +" ) -| +hir_lit ( -f -) +" +S " ) ) @@ -28792,34 +24483,33 @@ f assert_eq ! ( -Some -( -2 -) -len +t ( r " ( -a -) -( -b -) -| -( -c -) -( -d -) -| -( -e +? +x ) -( -f +\ +x +# +comment +{ +# +comment +53 +# +comment +} +# +comment +" ) +hir_lit +( +" +S " ) ) @@ -28827,32 +24517,51 @@ f assert_eq ! ( -Some -( -6 -) -len +t ( r " ( -a +? +x ) -( -b +\ +x +53 +" ) +hir_lit ( -c +" +S +" ) -( -d ) +; +assert_eq +! ( -e -) +t ( -f +r +" +( +? +x +) +\ +x +# +comment +53 +# +comment +" ) +hir_lit +( +" +S " ) ) @@ -28860,457 +24569,509 @@ f assert_eq ! ( -Some -( -3 -) -len +t ( r " ( -a -) -( -b +? +x ) -( -extra +\ +x5 +3 +" ) -| +hir_lit ( -a +" +S +" ) -( -b ) +; +# +[ +cfg ( -) +feature += +" +unicode +- +gencat " ) -) -; +] assert_eq ! ( -Some -( -3 -) -len +t ( r " ( -a +? +x ) -( -b +\ +p +# +comment +{ +# +comment +Separator +# +comment +} +# +comment +" ) +hir_uclass_query ( -( -? +ClassQuery : -extra -) -? -) +: +Binary +( +" +separator " ) ) +) ; assert_eq ! ( -None -len +t ( r " ( +? +x +) a +# +comment +{ +# +comment +5 +# +comment +# +comment +10 +# +comment +} +# +comment +" ) +hir_range ( -b -) +true +hir +: +: +RepetitionRange +: +: +Bounded ( -extra +5 +10 ) -? +hir_lit +( +" +a " ) ) +) ; assert_eq ! ( -Some -( -1 -) -len +t ( r " ( -foo +? +x ) -| -( -bar +a +\ +# +hi +there +" ) +hir_lit +( +" +a " ) ) ; -assert_eq -! -( -Some +} +# +[ +test +] +fn +analysis_is_always_utf8 ( -2 ) -len +{ +/ +/ +Positive +examples +. +assert +! +( +t_bytes ( r " -( -foo +a +" ) +. +is_always_utf8 ( -bar -) -" ) ) ; -assert_eq +assert ! ( -Some -( -2 -) -len +t_bytes ( r " -( -foo +ab +" ) -+ +. +is_always_utf8 ( -bar -) -" ) ) ; -assert_eq +assert ! ( -None -len +t_bytes ( r " ( -foo -) -* -( -bar +? +- +u ) +a " ) +. +is_always_utf8 +( +) ) ; -assert_eq +assert ! ( -Some -( -0 -) -len +t_bytes ( r " ( -foo -) ? -{ -0 -} +- +u +) +ab " ) +. +is_always_utf8 +( +) ) ; -assert_eq +assert ! ( -None -len +t_bytes ( r " -( -foo -) -? -{ -1 -} +\ +xFF " ) +. +is_always_utf8 +( +) ) ; -assert_eq +assert ! ( -Some -( -1 -) -len +t_bytes ( r " -( -foo -) -{ -1 -} +\ +xFF +\ +xFF " ) +. +is_always_utf8 +( +) ) ; -assert_eq +assert ! ( -Some -( -1 -) -len +t_bytes ( r " -( -foo -) -{ -1 -} +[ +^ +a +] " ) +. +is_always_utf8 +( +) ) ; -assert_eq +assert ! ( -Some -( -1 -) -len +t_bytes ( r " -( -foo -) -{ -1 -} -? +[ +^ +a +] +[ +^ +a +] " ) +. +is_always_utf8 +( +) ) ; -assert_eq +assert ! ( -None -len +t_bytes ( r " -( -foo -) -{ -1 -} -? -? +\ +b " ) +. +is_always_utf8 +( +) ) ; -assert_eq +assert ! ( -None -len +t_bytes ( r " -( -foo -) -{ -0 -} +\ +B " ) +. +is_always_utf8 +( +) ) ; -assert_eq +assert ! ( -Some -( -1 -) -len +t_bytes ( r " ( -foo -) -( ? -: -bar +- +u ) +\ +b " ) +. +is_always_utf8 +( +) ) ; -assert_eq +/ +/ +Negative +examples +. +assert ! ( -Some -( -2 -) -len +! +t_bytes ( r " ( -foo -( ? -: -bar +- +u ) -+ +\ +xFF +" ) +. +is_always_utf8 ( -? -: -baz -( -boo -) -) -" ) ) ; -assert_eq +assert ! ( -Some -( -2 -) -len +! +t_bytes ( r " ( ? -P -< -bar -> -foo +- +u ) -( -? -: -bar +\ +xFF +\ +xFF +" ) +. +is_always_utf8 ( -bal -| -loon -) -" ) ) ; -assert_eq +assert ! ( -Some -( -2 -) -len +! +t_bytes ( r -# " -< ( -a +? +- +u ) [ ^ -> +a ] -+ -href -= " +) +. +is_always_utf8 ( -[ -^ -" -] -+ ) +) +; +assert +! +( +! +t_bytes +( +r " -| -< ( -img +? +- +u ) [ ^ -> +a ] -+ -src -= -" -( [ ^ -" +a ] -+ +" +) +. +is_always_utf8 +( ) +) +; +assert +! +( +! +t_bytes +( +r " +( +? +- +u +) +\ +B " -# +) +. +is_always_utf8 +( ) ) ; @@ -29329,10 +25090,10 @@ analysis_is_all_assertions Positive examples . -let -p -= -props +assert +! +( +t ( r " @@ -29340,966 +25101,1169 @@ r b " ) +. +is_all_assertions +( +) +) ; assert ! ( -! -p -. -look_set +t ( +r +" +\ +B +" ) . -is_empty +is_all_assertions ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +^ +" ) -Some +. +is_all_assertions ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " -\ -B " ) +. +is_all_assertions +( +) +) ; assert ! ( -! -p -. -look_set +t ( +r +" +\ +A +" ) . -is_empty +is_all_assertions ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +\ +z +" ) -Some +. +is_all_assertions ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " ^ +\ +z +\ +A +\ +b +\ +B " ) +. +is_all_assertions +( +) +) ; assert ! ( -! -p -. -look_set +t ( +r +" +| +^ +| +\ +z +| +\ +A +| +\ +b +| +\ +B +" ) . -is_empty +is_all_assertions ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +^ +| +^ +" ) -Some +. +is_all_assertions ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " +( +( +\ +b +) ++ +( +) +) +* +^ " ) +. +is_all_assertions +( +) +) ; +/ +/ +Negative +examples +. assert ! ( ! -p -. -look_set +t ( +r +" +^ +a +" ) . -is_empty +is_all_assertions ( ) ) ; -assert_eq -! +} +# +[ +test +] +fn +analysis_is_anchored ( -p +) +{ +/ +/ +Positive +examples . -minimum_len +assert +! +( +t ( +r +" +^ +" ) -Some +. +is_anchored_start ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " -\ -A " ) +. +is_anchored_end +( +) +) ; assert ! ( -! -p +t +( +r +" +^ +" +) . -look_set +is_line_anchored_start +( +) +) +; +assert +! +( +t ( +r +" +" ) . -is_empty +is_line_anchored_end ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +^ +^ +" ) -Some +. +is_anchored_start ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " -\ -z " ) +. +is_anchored_end +( +) +) ; assert ! ( -! -p -. -look_set +t ( +r +" +^ +^ +" ) . -is_empty +is_line_anchored_start ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +" ) -Some +. +is_line_anchored_end ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " ^ -\ -z -\ -A -\ -b -\ -B " ) +. +is_anchored_start +( +) +) ; assert ! ( -! -p -. -look_set +t ( +r +" +^ +" ) . -is_empty +is_anchored_end ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +^ +" ) -Some +. +is_line_anchored_start ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " -| ^ -| -\ -z -| -\ -A -| -\ -b -| -\ -B " ) +. +is_line_anchored_end +( +) +) ; assert ! ( -! -p -. -look_set +t ( +r +" +^ +foo +" ) . -is_empty +is_anchored_start ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +foo +" ) -Some +. +is_anchored_end ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " ^ -| -^ +foo " ) +. +is_line_anchored_start +( +) +) ; assert ! ( -! -p -. -look_set +t ( +r +" +foo +" ) . -is_empty +is_line_anchored_end ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +^ +foo +| +^ +bar +" ) -Some +. +is_anchored_start ( -0 ) ) ; -let -p -= -props +assert +! +( +t ( r " -( -( -\ -b +foo +| +bar +" ) -+ +. +is_anchored_end ( ) ) -* -^ -" -) ; assert ! ( -! -p -. -look_set +t ( +r +" +^ +foo +| +^ +bar +" ) . -is_empty +is_line_anchored_start ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t ( +r +" +foo +| +bar +" ) -Some +. +is_line_anchored_end ( -0 ) ) ; -/ -/ -Negative -examples -. -let -p -= -props +assert +! +( +t ( r " ^ -a +( +foo +| +bar +) " ) +. +is_anchored_start +( +) +) ; assert ! ( -! -p -. -look_set +t +( +r +" ( +foo +| +bar +) +" ) . -is_empty +is_anchored_end ( ) ) ; -assert_eq +assert ! ( -p -. -minimum_len +t +( +r +" +^ ( +foo +| +bar ) -Some +" +) +. +is_line_anchored_start ( -1 ) ) ; -} -# -[ -test -] -fn -analysis_look_set_prefix_any +assert +! ( -) -{ -let -p -= -props +t ( r " ( -? -- -u -) -( -? -i -: -( -? -: -\ -b +foo | -_ +bar ) -win -( -? -: -32 -| -64 -| -dows +" ) -? +. +is_line_anchored_end ( -? -: -\ -b -| -_ -) ) -" ) ; assert ! ( -p -. -look_set_prefix_any +t ( +r +" +^ ++ +" ) . -contains +is_anchored_start ( -Look -: -: -WordAscii ) ) ; -} -# -[ -test -] -fn -analysis_is_anchored +assert +! ( -) -{ -let -is_start -= -| -p -| -props +t ( -p +r +" ++ +" ) . -look_set_prefix +is_anchored_end ( ) -. -contains -( -Look -: -: -Start ) ; -let -is_end -= -| -p -| -props +assert +! ( -p +t +( +r +" +^ ++ +" ) . -look_set_suffix +is_line_anchored_start +( +) +) +; +assert +! ( +t +( +r +" ++ +" ) . -contains +is_line_anchored_end ( -Look -: -: -End +) ) ; -/ -/ -Positive -examples -. assert ! ( -is_start +t ( r " ^ ++ ++ " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " ++ ++ " ) +. +is_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " ^ -^ ++ ++ " ) +. +is_line_anchored_start +( +) ) ; assert ! ( -props +t ( r " ++ ++ " ) . -look_set_suffix +is_line_anchored_end ( ) -. -contains -( -Look -: -: -End -) ) ; assert ! ( -is_start +t ( r " +( ^ +) ++ " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " -^ +( +) ++ " ) +. +is_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " +( ^ -foo +) ++ " ) +. +is_line_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " -foo +( +) ++ " ) +. +is_line_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " ^ -foo -| -^ -bar " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " -foo -| -bar +^ " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_start +t ( r " ^ -( -foo -| -bar -) " ) +. +is_line_anchored_end +( +) ) ; assert ! ( -is_end +t ( r " -( -foo -| -bar -) +^ " ) +. +is_line_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " ^ -+ +| +^ " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " -+ +^ +| +^ " ) +. +is_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " ^ -+ -+ +| +^ " ) +. +is_line_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " -+ -+ +^ +| +^ " ) +. +is_line_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " -( +\ +b ^ -) -+ " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " -( -) -+ +\ +b " ) +. +is_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " +\ +b ^ " ) +. +is_line_anchored_start +( +) ) ; assert ! ( -is_start +t ( r " -^ +\ +b " ) +. +is_line_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " ^ -| +( +? +m +: ^ +) " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " -^ -| -^ +( +? +m +: +) " ) +. +is_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " -\ -b ^ +( +? +m +: +^ +) " ) +. +is_line_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " -\ -b +( +? +m +: +) " ) +. +is_line_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " -^ ( ? m : ^ ) +^ " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " @@ -30310,12 +26274,16 @@ m ) " ) +. +is_anchored_end +( +) ) ; assert ! ( -is_start +t ( r " @@ -30328,12 +26296,16 @@ m ^ " ) +. +is_line_anchored_start +( +) ) ; assert ! ( -is_end +t ( r " @@ -30344,6 +26316,10 @@ m ) " ) +. +is_line_anchored_end +( +) ) ; / @@ -30355,7 +26331,7 @@ assert ! ( ! -is_start +t ( r " @@ -30366,13 +26342,17 @@ m ^ " ) +. +is_anchored_start +( +) ) ; assert ! ( ! -is_end +t ( r " @@ -30382,13 +26362,17 @@ m ) " ) +. +is_anchored_end +( +) ) ; assert ! ( ! -is_start +t ( r " @@ -30402,13 +26386,17 @@ m ^ " ) +. +is_anchored_start +( +) ) ; assert ! ( ! -is_end +t ( r " @@ -30422,13 +26410,17 @@ m ^ " ) +. +is_anchored_end +( +) ) ; assert ! ( ! -is_start +t ( r " @@ -30442,13 +26434,17 @@ m ) " ) +. +is_anchored_start +( +) ) ; assert ! ( ! -is_end +t ( r " @@ -30462,13 +26458,17 @@ m ) " ) +. +is_anchored_end +( +) ) ; assert ! ( ! -is_start +t ( r " @@ -30476,26 +26476,34 @@ a ^ " ) +. +is_anchored_start +( +) ) ; assert ! ( ! -is_start +t ( r " a " ) +. +is_anchored_start +( +) ) ; assert ! ( ! -is_end +t ( r " @@ -30503,49 +26511,44 @@ a ^ " ) +. +is_line_anchored_start +( +) ) ; assert ! ( ! -is_end +t ( r " a " ) +. +is_line_anchored_start +( +) ) ; assert ! ( ! -is_start +t ( r " +a ^ -foo -| -bar " ) -) -; -assert -! -( -! -is_end +. +is_anchored_end ( -r -" -foo -| -bar -" ) ) ; @@ -30553,26 +26556,16 @@ assert ! ( ! -is_start +t ( r " -^ -* +a " ) -) -; -assert -! -( -! -is_end +. +is_anchored_end ( -r -" -* -" ) ) ; @@ -30580,28 +26573,17 @@ assert ! ( ! -is_start +t ( r " +a ^ -* -+ " ) -) -; -assert -! -( -! -is_end +. +is_line_anchored_end ( -r -" -* -+ -" ) ) ; @@ -30609,28 +26591,16 @@ assert ! ( ! -is_start +t ( r " -^ -+ -* +a " ) -) -; -assert -! -( -! -is_end +. +is_line_anchored_end ( -r -" -+ -* -" ) ) ; @@ -30638,459 +26608,390 @@ assert ! ( ! -is_start +t ( r " -( ^ -) -* +foo +| +bar " ) +. +is_anchored_start +( +) ) ; assert ! ( ! -is_end +t ( r " -( -) -* -" -) -) -; -} -# -[ -test -] -fn -analysis_is_any_anchored -( -) -{ -let -is_start -= -| -p -| -props -( -p -) -. -look_set -( -) -. -contains -( -Look -: -: -Start -) -; -let -is_end -= -| -p +foo | -props -( -p +bar +" ) . -look_set +is_anchored_end ( ) -. -contains -( -Look -: -: -End ) ; -/ -/ -Positive -examples -. assert ! ( -is_start +! +t ( r " ^ +foo +| +bar " ) +. +is_line_anchored_start +( +) ) ; assert ! ( -is_end +! +t ( r " +foo +| +bar " ) +. +is_line_anchored_end +( +) ) ; assert ! ( -is_start +! +t ( r " -\ -A +^ +* " ) +. +is_anchored_start +( +) ) ; assert ! ( -is_end +! +t ( r " -\ -z +* " ) +. +is_anchored_end +( +) ) ; -/ -/ -Negative -examples -. assert ! ( ! -is_start +t ( r " -( -? -m -) ^ +* " ) +. +is_line_anchored_start +( +) ) ; assert ! ( ! -is_end +t ( r " -( -? -m -) +* " ) +. +is_line_anchored_end +( +) ) ; assert ! ( ! -is_start +t ( r " +^ +* ++ " ) +. +is_anchored_start +( +) ) ; assert ! ( ! -is_end +t ( r " -^ +* ++ " ) -) -; -} -# -[ -test -] -fn -analysis_can_empty -( -) -{ -/ -/ -Positive -examples -. -let -assert_empty -= -| -p -| -assert_eq -! -( -Some -( -0 -) -props_bytes -( -p -) . -minimum_len +is_anchored_end ( ) ) ; -assert_empty +assert +! ( -r -" -" -) -; -assert_empty +! +t ( r " -( -) +^ +* ++ " ) -; -assert_empty -( -r -" +. +is_line_anchored_start ( ) -* -" ) ; -assert_empty +assert +! +( +! +t ( r " -( -) +* + " ) -; -assert_empty -( -r -" +. +is_line_anchored_end ( ) -? -" ) ; -assert_empty +assert +! +( +! +t ( r " -a +^ ++ * " ) -; -assert_empty +. +is_anchored_start ( -r -" -a -? -" ) -; -assert_empty -( -r -" -a -{ -0 -} -" ) ; -assert_empty +assert +! ( -r -" -a -{ -0 -} -" -) -; -assert_empty +! +t ( r " -a -{ -0 -1 -} ++ +* " ) -; -assert_empty +. +is_anchored_end ( -r -" -a -{ -0 -10 -} -" +) ) ; -# -[ -cfg +assert +! ( -feature -= -" -unicode -- -gencat -" -) -] -assert_empty +! +t ( r " -\ -pL +^ ++ * " ) -; -assert_empty +. +is_line_anchored_start ( -r -" -a -* -| -b -" +) ) ; -assert_empty +assert +! +( +! +t ( r " -b -| -a ++ * " ) -; -assert_empty +. +is_line_anchored_end ( -r -" -a -| -" +) ) ; -assert_empty +assert +! +( +! +t ( r " -| -a +( +^ +) +* " ) -; -assert_empty +. +is_anchored_start ( -r -" -a -| -| -b -" +) ) ; -assert_empty +assert +! +( +! +t ( r " -a -* -a -? ( -abcd ) * " ) +. +is_anchored_end +( +) +) ; -assert_empty +assert +! +( +! +t ( r " +( ^ +) +* " ) +. +is_line_anchored_start +( +) +) ; -assert_empty +assert +! +( +! +t ( r " +( +) +* " ) +. +is_line_anchored_end +( +) +) ; -assert_empty +} +# +[ +test +] +fn +analysis_is_line_anchored +( +) +{ +assert +! +( +t ( r " @@ -31099,10 +27000,23 @@ r m ) ^ +( +foo +| +bar +) " ) +. +is_line_anchored_start +( +) +) ; -assert_empty +assert +! +( +t ( r " @@ -31110,231 +27024,195 @@ r ? m ) -" -) -; -assert_empty ( -r -" -\ -A -" +foo +| +bar ) -; -assert_empty -( -r -" -\ -z " ) -; -assert_empty +. +is_line_anchored_end ( -r -" -\ -B -" +) ) ; -assert_empty +assert +! +( +t ( r " ( ? -- -u +m ) -\ -B +^ +foo +| +^ +bar " ) -; -assert_empty +. +is_line_anchored_start ( -r -" -\ -b -" +) ) ; -assert_empty +assert +! +( +t ( r " ( ? -- -u -) -\ -b -" +m ) -; -/ -/ -Negative -examples -. -let -assert_non_empty -= -| -p +foo | -assert_ne -! -( -Some -( -0 -) -props_bytes -( -p +bar +" ) . -minimum_len +is_line_anchored_end ( ) ) ; -assert_non_empty +assert +! ( -r -" -a -+ -" -) -; -assert_non_empty +t ( r " -a -{ -1 -} +( +? +m +) +^ " ) -; -assert_non_empty +. +is_line_anchored_start ( -r -" -a -{ -1 -} -" +) ) ; -assert_non_empty +assert +! +( +t ( r " -a -{ -1 -2 -} +( +? +m +) " ) -; -assert_non_empty +. +is_line_anchored_end ( -r -" -a -{ -1 -10 -} -" +) ) ; -assert_non_empty +assert +! +( +t ( r " -b +( +? +m +: +^ +) | -a +^ " ) -; -assert_non_empty -( -r -" -a -* -a -+ +. +is_line_anchored_start ( -abcd ) -* -" ) ; -# -[ -cfg +assert +! ( -feature -= -" -unicode -- -gencat -" -) -] -assert_non_empty +t ( r " -\ -P -{ -any -} +( +? +m +: +^ +) +| +^ " ) +. +is_line_anchored_end +( +) +) ; -assert_non_empty +assert +! +( +t ( r " -[ -a -- -- -a -] +^ +| +( +? +m +: +^ +) " ) +. +is_line_anchored_start +( +) +) ; -assert_non_empty +assert +! +( +t ( r " -[ -a -& -& -b -] +^ +| +( +? +m +: +^ +) " ) +. +is_line_anchored_end +( +) +) ; } # @@ -31342,7 +27220,7 @@ b test ] fn -analysis_is_literal +analysis_is_any_anchored ( ) { @@ -31354,15 +27232,15 @@ examples assert ! ( -props +t ( r " -a +^ " ) . -is_literal +is_any_anchored_start ( ) ) @@ -31370,15 +27248,14 @@ is_literal assert ! ( -props +t ( r " -ab " ) . -is_literal +is_any_anchored_end ( ) ) @@ -31386,15 +27263,16 @@ is_literal assert ! ( -props +t ( r " -abc +\ +A " ) . -is_literal +is_any_anchored_start ( ) ) @@ -31402,39 +27280,42 @@ is_literal assert ! ( -props +t ( r " -( -? -m -) -abc +\ +z " ) . -is_literal +is_any_anchored_end ( ) ) ; +/ +/ +Negative +examples +. assert ! ( -props +! +t ( r " ( ? -: -a +m ) +^ " ) . -is_literal +is_any_anchored_start ( ) ) @@ -31442,20 +27323,19 @@ is_literal assert ! ( -props +! +t ( r " -foo ( ? -: -a +m ) " ) . -is_literal +is_any_anchored_end ( ) ) @@ -31463,20 +27343,15 @@ is_literal assert ! ( -props +! +t ( r " -( -? -: -a -) -foo " ) . -is_literal +is_any_anchored_start ( ) ) @@ -31484,38 +27359,46 @@ is_literal assert ! ( -props +! +t ( r " -[ -a -] +^ " ) . -is_literal +is_any_anchored_end ( ) ) ; +} +# +[ +test +] +fn +analysis_is_match_empty +( +) +{ / / -Negative +Positive examples . assert ! ( -! -props +t ( r " " ) . -is_literal +is_match_empty ( ) ) @@ -31523,35 +27406,16 @@ is_literal assert ! ( -! -props +t ( r " -^ -" -) -. -is_literal ( ) -) -; -assert -! -( -! -props -( -r -" -a -| -b " ) . -is_literal +is_match_empty ( ) ) @@ -31559,18 +27423,17 @@ is_literal assert ! ( -! -props +t ( r " ( -a ) +* " ) . -is_literal +is_match_empty ( ) ) @@ -31578,17 +27441,17 @@ is_literal assert ! ( -! -props +t ( r " -a +( +) + " ) . -is_literal +is_match_empty ( ) ) @@ -31596,19 +27459,17 @@ is_literal assert ! ( -! -props +t ( r " -foo ( -a ) +? " ) . -is_literal +is_match_empty ( ) ) @@ -31616,19 +27477,16 @@ is_literal assert ! ( -! -props +t ( r " -( a -) -foo +* " ) . -is_literal +is_match_empty ( ) ) @@ -31636,49 +27494,35 @@ is_literal assert ! ( -! -props +t ( r " -[ -ab -] +a +? " ) . -is_literal +is_match_empty ( ) ) ; -} -# -[ -test -] -fn -analysis_is_alternation_literal -( -) -{ -/ -/ -Positive -examples -. assert ! ( -props +t ( r " a +{ +0 +} " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31686,15 +27530,18 @@ is_alternation_literal assert ! ( -props +t ( r " -ab +a +{ +0 +} " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31702,15 +27549,19 @@ is_alternation_literal assert ! ( -props +t ( r " -abc +a +{ +0 +1 +} " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31718,57 +27569,50 @@ is_alternation_literal assert ! ( -props +t ( r " -( -? -m -) -abc +a +{ +0 +10 +} " ) . -is_alternation_literal +is_match_empty ( ) ) ; -assert -! -( -props +# +[ +cfg ( -r +feature += " -foo -| -bar +unicode +- +gencat " ) -. -is_alternation_literal -( -) -) -; +] assert ! ( -props +t ( r " -foo -| -bar -| -baz +\ +pL +* " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31776,17 +27620,18 @@ is_alternation_literal assert ! ( -props +t ( r " -[ a -] +* +| +b " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31794,21 +27639,18 @@ is_alternation_literal assert ! ( -props +t ( r " -( -? -: -ab -) +b | -cd +a +* " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31816,42 +27658,33 @@ is_alternation_literal assert ! ( -props +t ( r " -ab +a | -( -? -: -cd -) " ) . -is_alternation_literal +is_match_empty ( ) ) ; -/ -/ -Negative -examples -. assert ! ( -! -props +t ( r " +| +a " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31859,16 +27692,18 @@ is_alternation_literal assert ! ( -! -props +t ( r " -^ +a +| +| +b " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31876,18 +27711,22 @@ is_alternation_literal assert ! ( -! -props +t ( r " -( a +* +a +? +( +abcd ) +* " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31895,17 +27734,15 @@ is_alternation_literal assert ! ( -! -props +t ( r " -a -+ +^ " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31913,19 +27750,14 @@ is_alternation_literal assert ! ( -! -props +t ( r " -foo -( -a -) " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31933,19 +27765,19 @@ is_alternation_literal assert ! ( -! -props +t ( r " ( -a +? +m ) -foo +^ " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31953,18 +27785,18 @@ is_alternation_literal assert ! ( -! -props +t ( r " -[ -ab -] +( +? +m +) " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31972,20 +27804,16 @@ is_alternation_literal assert ! ( -! -props +t ( r " -[ -ab -] -| -b +\ +A " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -31993,20 +27821,16 @@ is_alternation_literal assert ! ( -! -props +t ( r " -a -| -[ -ab -] +\ +z " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -32014,20 +27838,16 @@ is_alternation_literal assert ! ( -! -props +t ( r " -( -a -) -| -b +\ +B " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -32035,20 +27855,21 @@ is_alternation_literal assert ! ( -! -props +t_bytes ( r " -a -| ( -b +? +- +u ) +\ +B " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -32056,18 +27877,16 @@ is_alternation_literal assert ! ( -! -props +t ( r " -a -| +\ b " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -32075,41 +27894,44 @@ is_alternation_literal assert ! ( -! -props +t ( r " -a -| +( +? +- +u +) +\ b -| -c " ) . -is_alternation_literal +is_match_empty ( ) ) ; +/ +/ +Negative +examples +. assert ! ( ! -props +t ( r " -[ a -] -| -b ++ " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -32118,19 +27940,18 @@ assert ! ( ! -props +t ( r " a -| -[ -b -] +{ +1 +} " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -32139,21 +27960,18 @@ assert ! ( ! -props +t ( r " -( -? -: a -) -| -b +{ +1 +} " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -32162,21 +27980,19 @@ assert ! ( ! -props +t ( r " a -| -( -? -: -b -) +{ +1 +2 +} " ) . -is_alternation_literal +is_match_empty ( ) ) @@ -32185,919 +28001,676 @@ assert ! ( ! -props -( -r -" -( -? -: -z -| -xx -) -| -xx -" -) -. -is_alternation_literal -( -) -) -; -} -/ -/ -This -tests -that -the -smart -Hir -: -: -repetition -constructors -does -some -basic -/ -/ -simplifications -. -# -[ -test -] -fn -smart_repetition -( -) -{ -assert_eq -! -( t ( r " a { -0 +1 +10 } " ) -Hir -: -: -empty +. +is_match_empty ( ) ) ; -assert_eq +assert ! ( +! t ( r " +b +| a -{ -1 -} " ) -hir_lit +. +is_match_empty ( -" -a -" ) ) ; -assert_eq +assert ! ( +! t ( r " -\ -B -{ -32111 -} +a +* +a ++ +( +abcd +) +* " ) -hir_look +. +is_match_empty ( -hir -: -: -Look -: -: -WordUnicodeNegate ) ) ; } -/ -/ -This -tests -that -the -smart -Hir -: -: -concat -constructor -simplifies -the -given -/ -/ -exprs -in -a -way -we -expect -. # [ test ] fn -smart_concat +analysis_is_literal ( ) { -assert_eq +/ +/ +Positive +examples +. +assert ! ( t ( +r " +a " ) -Hir -: -: -empty +. +is_literal ( ) ) ; -assert_eq +assert ! ( t ( +r " -( -? -: -) +ab " ) -Hir -: -: -empty +. +is_literal ( ) ) ; -assert_eq +assert ! ( t ( +r " abc " ) -hir_lit +. +is_literal ( -" -abc -" ) ) ; -assert_eq +assert ! ( t ( +r " ( ? -: -foo -) -( -? -: -bar +m ) +abc " ) -hir_lit +. +is_literal ( -" -foobar -" ) ) ; -assert_eq +/ +/ +Negative +examples +. +assert ! ( +! t ( +r +" " -quux -( -? -: -foo ) +. +is_literal ( -? -: -bar ) -baz -" ) -hir_lit +; +assert +! ( +! +t +( +r " -quuxfoobarbaz +^ " ) +. +is_literal +( +) ) ; -assert_eq +assert ! ( +! t ( +r " -foo +a +| +b +" +) +. +is_literal ( -? -: -bar -^ -baz ) -quux -" ) -hir_cat +; +assert +! ( -vec ! -[ -hir_lit +t ( +r " -foobar +( +a +) " ) -hir_look +. +is_literal ( -hir -: -: -Look -: -: -Start ) -hir_lit +) +; +assert +! +( +! +t ( +r " -bazquux +a ++ " ) -] +. +is_literal +( ) ) ; -assert_eq +assert ! ( +! t ( +r " foo ( -? -: -ba -( -? -: -r -^ -b -) -az +a ) -quux " ) -hir_cat +. +is_literal ( -vec +) +) +; +assert ! -[ -hir_lit ( +! +t +( +r " -foobar +( +a +) +foo " ) -hir_look +. +is_literal ( -hir -: -: -Look -: -: -Start ) -hir_lit +) +; +assert +! +( +! +t ( +r " -bazquux +[ +a +] " ) -] +. +is_literal +( ) ) ; } -/ -/ -This -tests -that -the -smart -Hir -: -: -alternation -constructor -simplifies -the -/ -/ -given -exprs -in -a -way -we -expect -. # [ test ] fn -smart_alternation +analysis_is_alternation_literal ( ) { -assert_eq +/ +/ +Positive +examples +. +assert ! ( t ( +r +" +a " -( -? -: -foo ) -| +. +is_alternation_literal ( -? -: -bar ) -" ) -hir_alt -( -vec +; +assert ! -[ -hir_lit ( -" -foo -" -) -hir_lit +t ( +r " -bar +ab " ) -] +. +is_alternation_literal +( ) ) ; -assert_eq +assert ! ( t ( +r " -quux -| -( -? -: abc -| -def -| -xyz -) -| -baz " ) -hir_alt +. +is_alternation_literal ( -vec +) +) +; +assert ! -[ -hir_lit ( -" -quux -" -) -hir_lit +t ( +r " -abc -" -) -hir_lit ( -" -def -" +? +m ) -hir_lit -( -" -xyz +abc " ) -hir_lit +. +is_alternation_literal ( -" -baz -" -) -] ) ) ; -assert_eq +assert ! ( t ( +r " -quux -| -( -? -: -abc -| -( -? -: -def -| -mno -) -| -xyz -) +a | -baz +b " ) -hir_alt +. +is_alternation_literal ( -vec +) +) +; +assert ! -[ -hir_lit ( -" -quux -" -) -hir_lit +t ( +r " -abc +a +| +b +| +c " ) -hir_lit +. +is_alternation_literal ( -" -def -" ) -hir_lit -( -" -mno -" ) -hir_lit +; +assert +! ( -" -xyz -" -) -hir_lit +t ( +r " -baz +foo +| +bar " ) -] +. +is_alternation_literal +( ) ) ; -assert_eq +assert ! ( t ( +r " -a -| -b -| -c -| -d -| -e -| -f -| -x +foo | -y +bar | -z +baz " ) -hir_uclass -( -& -[ -( -' -a -' -' -f -' -) +. +is_alternation_literal ( -' -x -' -' -z -' -) -] ) ) ; / / -Tests -that -we -lift -common -prefixes -out -of -an -alternation +Negative +examples . -assert_eq +assert ! ( +! t ( +r " -[ -A -- -Z -] -foo -| -[ -A -- -Z -] -quux " ) -hir_cat +. +is_alternation_literal ( -vec +) +) +; +assert ! -[ -hir_uclass ( -& -[ +! +t ( -' -A -' -' -Z -' +r +" +^ +" ) -] +. +is_alternation_literal +( ) -hir_alt +) +; +assert +! ( -vec ! -[ -hir_lit +t ( +r " -foo -" -) -hir_lit ( -" -quux -" +a ) -] +" ) -] +. +is_alternation_literal +( ) ) ; -assert_eq +assert ! ( +! t ( +r " -[ -A -- -Z -] -[ -A -- -Z -] -| -[ -A -- -Z -] -quux +a ++ " ) -hir_cat -( -vec -! -[ -hir_uclass -( -& -[ +. +is_alternation_literal ( -' -A -' -' -Z -' ) -] ) -hir_alt +; +assert +! ( -vec ! -[ -hir_uclass +t ( -& -[ +r +" +foo ( -' -A -' -' -Z -' -) -] +a ) -hir_lit -( -" -quux " ) -] -) -] +. +is_alternation_literal +( ) ) ; -assert_eq +assert ! ( +! t ( +r " -[ -A -- -Z -] -[ -A -- -Z -] -| -[ -A -- -Z -] -[ -A -- -Z -] -quux +( +a +) +foo " ) -hir_cat +. +is_alternation_literal ( -vec +) +) +; +assert ! -[ -hir_uclass ( -& -[ +! +t ( -' -A -' -' -Z -' -) +r +" +[ +a ] +" ) -hir_uclass -( -& -[ +. +is_alternation_literal ( -' -A -' -' -Z -' ) -] ) -hir_alt -( -vec +; +assert ! -[ -Hir -: -: -empty ( -) -hir_lit +! +t ( +r " -quux -" -) +[ +a ] +| +b +" ) -] +. +is_alternation_literal +( ) ) ; -assert_eq +assert ! ( +! t ( +r " -[ -A -- -Z -] -foo +a | [ -A -- -Z +b ] -foobar " ) -hir_cat -( -vec -! -[ -hir_uclass -( -& -[ +. +is_alternation_literal ( -' -A -' -' -Z -' ) -] ) -hir_alt +; +assert +! ( -vec ! -[ -hir_lit +t ( +r " -foo +( +a +) +| +b " ) -hir_lit +. +is_alternation_literal ( +) +) +; +assert +! +( +! +t +( +r " -foobar -" +a +| +( +b ) -] +" ) -] +. +is_alternation_literal +( ) ) ; diff --git a/third_party/rust/regex-syntax/src/hir/visitor.rs b/third_party/rust/regex-syntax/src/hir/visitor.rs index 2957837200646..9dfeffa7be6e6 100644 --- a/third_party/rust/regex-syntax/src/hir/visitor.rs +++ b/third_party/rust/regex-syntax/src/hir/visitor.rs @@ -1,16 +1,4 @@ use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use crate : : @@ -149,6 +137,13 @@ the [ visit ] +( +fn +. +visit +. +html +) function . pub @@ -391,45 +386,6 @@ Ok ) ) } -/ -/ -/ -This -method -is -called -between -child -nodes -of -a -concatenation -. -fn -visit_concat_in -( -& -mut -self -) -- -> -Result -< -( -) -Self -: -: -Err -> -{ -Ok -( -( -) -) -} } / / @@ -470,9 +426,19 @@ methods provided by the +/ +/ +/ [ Visitor ] +( +trait +. +Visitor +. +html +) trait . / @@ -790,7 +756,7 @@ before descending into a -capture +group ' s child @@ -799,7 +765,7 @@ child / node . -Capture +Group ( & ' @@ -807,7 +773,7 @@ a hir : : -Capture +Group ) / / @@ -1207,9 +1173,8 @@ pop frame ) { -match -x -{ +if +let Frame : : @@ -1219,7 +1184,7 @@ Alternation . } = -> +x { visitor . @@ -1229,31 +1194,6 @@ visit_alternation_in ? ; } -Frame -: -: -Concat -{ -. -. -} -= -> -{ -visitor -. -visit_concat_in -( -) -? -; -} -_ -= -> -{ -} -} hir = x @@ -1406,7 +1346,7 @@ x HirKind : : -Capture +Group ( ref x @@ -1418,7 +1358,7 @@ Some Frame : : -Capture +Group ( x ) @@ -1603,7 +1543,7 @@ None Frame : : -Capture +Group ( _ ) @@ -1777,20 +1717,20 @@ rep & rep . -sub +hir Frame : : -Capture +Group ( -capture +group ) = > & -capture +group . -sub +hir Frame : : diff --git a/third_party/rust/regex-syntax/src/lib.rs b/third_party/rust/regex-syntax/src/lib.rs index c93c5825b0e79..1bec853157c52 100644 --- a/third_party/rust/regex-syntax/src/lib.rs +++ b/third_party/rust/regex-syntax/src/lib.rs @@ -23,9 +23,12 @@ Ast ] ( ast -: -: +/ +enum +. Ast +. +html ) is the @@ -117,9 +120,12 @@ Hir ] ( hir -: -: +/ +struct +. Hir +. +html ) is the @@ -252,6 +258,17 @@ parse : Parser ] +( +ast +/ +parse +/ +struct +. +Parser +. +html +) converts concrete syntax @@ -267,9 +284,12 @@ Ast ] ( ast -: -: +/ +enum +. Ast +. +html ) . * @@ -283,6 +303,17 @@ translate : Translator ] +( +hir +/ +translate +/ +struct +. +Translator +. +html +) converts an [ @@ -290,9 +321,12 @@ Ast ] ( ast -: -: +/ +enum +. Ast +. +html ) to a @@ -301,9 +335,12 @@ Hir ] ( hir -: -: +/ +struct +. Hir +. +html ) . As @@ -326,6 +363,13 @@ level [ Parser ] +( +struct +. +Parser +. +html +) type . This @@ -347,21 +391,6 @@ to an Hir . -It -' -s -also -exposed -as -top -- -level -[ -parse -] -free -function -. # Example This @@ -381,17 +410,30 @@ use regex_syntax : : -{ +Parser +; +use +regex_syntax +: +: hir : : +{ +self Hir -parse } ; let hir = +Parser +: +: +new +( +) +. parse ( " @@ -400,7 +442,10 @@ a b " ) -? +. +unwrap +( +) ; assert_eq ! @@ -419,54 +464,41 @@ Hir : literal ( -" -a -" -. -as_bytes -( -) -) -Hir +hir : : -literal -( -" -b -" -. -as_bytes +Literal +: +: +Unicode ( +' +a +' ) ) -] -) -) -; -# -Ok +Hir : : -< +literal ( -) -Box -< -dyn -std +hir : : -error +Literal : : -Error -> -> -( +Unicode ( +' +b +' +) +) +] ) ) +; # Concrete syntax @@ -720,9 +752,14 @@ values ] ( hir -: -: +/ literal +/ +struct +. +Literals +. +html ) . Be @@ -730,6 +767,7 @@ warned that literal extraction +currently uses recursion and @@ -1010,57 +1048,6 @@ available * * * -std -* -* -- -Enables -support -for -the -standard -library -. -This -feature -is -enabled -by -default -. -When -disabled -only -core -and -alloc -are -used -. -Otherwise -enabling -std -generally -just -enables -std -: -: -error -: -: -Error -trait -impls -for -the -various -error -types -. -* -* -* unicode * * @@ -1262,7 +1249,7 @@ the data for [ -Unicode +Uncode general categories ] @@ -1504,77 +1491,22 @@ ATerm } . * -* -* -arbitrary -* -* -- -Enabling -this -feature -introduces -a -public -dependency -on -the -[ -arbitrary -] -( -https -: -/ -/ -crates -. -io / -crates -/ -arbitrary -) -crate -. -Namely -it -implements -the -Arbitrary -trait -from -that -crate -for -the +# +! [ -Ast -] +deny ( -crate -: -: -ast -: -: -Ast +missing_docs ) -type -. -This -feature -is -disabled -by -default -. -* -/ +] # ! [ -no_std +warn +( +missing_debug_implementations +) ] # ! @@ -1584,277 +1516,47 @@ forbid unsafe_code ) ] -# -! -[ -deny -( -missing_docs -rustdoc -: -: -broken_intra_doc_links -) -] -# -! -[ -warn -( -missing_debug_implementations -) -] -/ -/ -MSRV -( -1 -. -62 -) -: -Allow -unused -warnings -. -Needed -for -the -' -allow -' -below -/ -/ -since -the -warning -is -no -longer -triggered -in -newer -Rust -releases -. -/ -/ -Once -the -' -allow -( -mutable_borrow_reservation_conflict -) -' -can -be -/ -/ -removed -we -can -remove -the -' -allow -( -renamed_and_removed_lints -) -' -too -. -# -! -[ -allow -( -renamed_and_removed_lints -) -] -/ -/ -MSRV -( -1 -. -62 -) -: -This -gets -triggered -on -Rust -< -1 -. -62 -and -since -our -MSRV -/ -/ -is -Rust -1 -. -60 -at -the -time -of -writing -a -warning -is -displayed -. -But -/ -/ -the -lang -team -decided -the -code -pattern -flagged -by -this -warning -is -/ -/ -OK -so -the -warning -is -innocuous -. -We -can -remove -this -explicit -allow -/ -/ -once -we -get -to -a -Rust -release -where -the -warning -is -no -longer -/ -/ -triggered -. -I -believe -that -' -s -Rust -1 -. -62 -. -# -! -[ -allow -( -mutable_borrow_reservation_conflict -) -] -# -! -[ -cfg_attr -( -docsrs -feature -( -doc_auto_cfg -) -) -] -# -[ -cfg -( -any -( -test -feature -= -" -std -" -) -) -] -extern -crate -std -; -extern -crate -alloc -; pub use crate : : -{ error : : +{ Error +Result +} +; +pub +use +crate +: +: parser : : { -parse Parser ParserBuilder } -unicode -: -: -UnicodeWordError -} ; +pub use -alloc +crate : : -string +unicode : : -String +UnicodeWordError ; pub mod ast ; mod -debug -; -mod either ; mod @@ -1868,9 +1570,6 @@ mod parser ; mod -rank -; -mod unicode ; mod @@ -2084,1194 +1783,188 @@ regex / / / -Generally -speaking -these +These are the only characters -which -_must_ +that +are +allowed +to be escaped -/ -/ -/ -in -order -to -match -their -literal -meaning -. -For -example -to -match -a -literal -/ -/ -/ -| +with one -could -write -\ -| -. -Sometimes -escaping -isn -' -t -always -necessary -. -For -/ -/ -/ -example -- -is -treated -as -a -meta -character -because -of -its -significance -/ -/ -/ -for -writing -ranges -inside -of -character -classes -but -the -regex -- -will / / / -match -a -literal -- -because -- -has -no -special -meaning -outside -of +exception +: +an +ASCII +space character +may +be +escaped +when +extended +mode +( +with / / -/ -classes -. -/ -/ -/ -/ -/ -/ -In -order -to -determine -whether -a -character -may -be -escaped -at -all -the -/ -/ -/ -[ -is_escapeable_character -] -routine -should -be -used -. -The -difference -between -/ -/ -/ -is_meta_character -and -is_escapeable_character -is -that -the -latter -will -/ -/ -/ -return -true -for -some -characters -that -are -_not_ -meta -characters -. -For -/ -/ -/ -example -% -and -\ -% -both -match -a -literal -% -in -all -contexts -. -In -other -/ -/ -/ -words -is_escapeable_character -includes -" -superfluous -" -escapes -. -/ -/ -/ -/ -/ -/ -Note -that -the -set -of -characters -for -which -this -function -returns -true -or -/ -/ -/ -false -is -fixed -and -won -' -t -change -in -a -semver -compatible -release -. -( -In -this -/ -/ -/ -case -" -semver -compatible -release -" -actually -refers -to -the -regex -crate -/ -/ -/ -itself -since -reducing -or -expanding -the -set -of -meta -characters -would -be -a -/ -/ -/ -breaking -change -for -not -just -regex -- -syntax -but -also -regex -itself -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -is_meta_character -; -/ -/ -/ -/ -/ -/ -assert -! -( -is_meta_character -( -' -? -' -) -) -; -/ -/ -/ -assert -! -( -is_meta_character -( -' -- -' -) -) -; -/ -/ -/ -assert -! -( -is_meta_character -( -' -& -' -) -) -; -/ -/ -/ -assert -! -( -is_meta_character -( -' -# -' -) -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -! -is_meta_character -( -' -% -' -) -) -; -/ -/ -/ -assert -! -( -! -is_meta_character -( -' -/ -' -) -) -; -/ -/ -/ -assert -! -( -! -is_meta_character -( -' -! -' -) -) -; -/ -/ -/ -assert -! -( -! -is_meta_character -( -' -" -' -) -) -; -/ -/ -/ -assert -! -( -! -is_meta_character -( -' -e -' -) -) -; -/ -/ -/ -pub -fn -is_meta_character -( -c -: -char -) -- -> -bool -{ -match -c -{ -' -\ -\ -' -| -' -. -' -| -' -+ -' -| -' -* -' -| -' -? -' -| -' -( -' -| -' -) -' -| -' -| -' -| -' -[ -' -| -' -] -' -| -' -{ -' -| -' -} -' -| -' -^ -' -| -' -' -| -' -# -' -| -' -& -' -| -' -- -' -| -' -~ -' -= -> -true -_ -= -> -false -} -} -/ -/ -/ -Returns -true -if -the -given -character -can -be -escaped -in -a -regex -. -/ -/ -/ -/ -/ -/ -This -returns -true -in -all -cases -that -is_meta_character -returns -true -but -/ -/ -/ -also -returns -true -in -some -cases -where -is_meta_character -returns -false -. -/ -/ -/ -For -example -% -is -not -a -meta -character -but -it -is -escapeable -. -That -is -/ -/ -/ -% -and -\ -% -both -match -a -literal -% -in -all -contexts -. -/ -/ -/ -/ -/ -/ -The -purpose -of -this -routine -is -to -provide -knowledge -about -what -characters -/ -/ -/ -may -be -escaped -. -Namely -most -regex -engines -permit -" -superfluous -" -escapes -/ -/ -/ -where -characters -without -any -special -significance -may -be -escaped -even -/ -/ -/ -though -there -is -no -actual -_need_ -to -do -so -. -/ -/ -/ -/ -/ -/ -This -will -return -false -for -some -characters -. -For -example -e -is -not -/ -/ -/ -escapeable -. -Therefore -\ -e -will -either -result -in -a -parse -error -( -which -is -/ -/ -/ -true -today -) -or -it -could -backwards -compatibly -evolve -into -a -new -construct -/ -/ -/ -with -its -own -meaning -. -Indeed -that -is -the -purpose -of -banning -_some_ -/ -/ -/ -superfluous -escapes -: -it -provides -a -way -to -evolve -the -syntax -in -a -compatible -/ -/ -/ -manner -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex_syntax -: -: -is_escapeable_character -; -/ -/ -/ -/ -/ -/ -assert -! -( -is_escapeable_character -( -' -? -' -) -) -; -/ -/ -/ -assert -! -( -is_escapeable_character -( -' -- -' -) -) -; -/ -/ -/ -assert -! -( -is_escapeable_character -( -' -& -' -) -) -; -/ -/ -/ -assert -! -( -is_escapeable_character -( -' -# -' -) -) -; -/ -/ -/ -assert -! -( -is_escapeable_character -( -' -% -' -) -) -; -/ -/ -/ -assert -! -( -is_escapeable_character -( -' -/ -' -) -) -; -/ -/ -/ -assert -! -( -is_escapeable_character -( -' -! -' -) -) -; -/ -/ -/ -assert -! -( -is_escapeable_character -( -' -" -' -) -) -; -/ -/ -/ -/ -/ -/ -assert -! -( -! -is_escapeable_character -( -' -e -' -) -) -; -/ -/ -/ -pub -fn -is_escapeable_character -( -c -: -char -) -- -> -bool -{ -/ -/ -Certainly -escapeable -if -it -' -s -a -meta -character -. -if -is_meta_character -( -c -) -{ -return -true -; -} -/ -/ -Any -character -that -isn -' -t -ASCII +/ +the +x +flag +) is -definitely -not -escapeable +enabled . -There +In +particular +is_meta_character +( ' -s +' +) +returns +/ / / -no -real -need -to -allow -things -like -\ -right -? -if -! -c -. -is_ascii -( -) -{ -return false -; -} +. / / -Otherwise -we -basically -say -that -everything -is -escapeable -unless -it -' -s -a / / -letter -or -digit -. -Things -like -\ -3 -are -either -octal -( -when -enabled -) -or -an / / -error -and -we -should -keep -it +Note that -way -. -Otherwise -letters -are -reserved +the +set +of +characters +for +which +this +function +returns +true +or / / -for -adding -new -syntax +/ +false +is +fixed +and +won +' +t +change in a -backwards +semver compatible -way +release . +pub +fn +is_meta_character +( +c +: +char +) +- +> +bool +{ match c { ' -0 +\ +\ +' +| ' . -. -= ' -9 +| +' ++ ' | ' -A +* ' -. -. -= +| ' -Z +? ' | ' -a +( ' -. -. -= +| ' -z +) ' -= -> -false -/ -/ -While -not -currently -supported -we -keep -these -as -not -escapeable -to -/ -/ -give -us -some -flexibility -with -respect -to -supporting -the -\ -< -and -/ -/ -\ -> -word -boundary -assertions -in -the -future -. -By -rejecting -them -as -/ -/ -escapeable -\ -< -and -\ -> -will -result -in -a -parse -error -. -Thus -we -can -/ -/ -turn -them -into -something -else -in -the -future -without -it -being -a -/ -/ -backwards -incompatible -change -. +| ' -< +| ' | ' -> +[ +' +| +' +] +' +| +' +{ +' +| +' +} +' +| +' +^ +' +| +' +' +| +' +# +' +| +' +& +' +| +' +- +' +| +' +~ ' = > -false +true _ = > -true +false } } / @@ -3406,11 +2099,11 @@ enabled then this function +panics +. / / / -panics -. For this reason @@ -3426,6 +2119,16 @@ use [ try_is_word_character ] +( +fn +. +try_is_word_character +. +html +) +/ +/ +/ instead . pub @@ -3608,7 +2311,7 @@ char ) - > -core +std : : result @@ -3753,15 +2456,6 @@ mod tests { use -alloc -: -: -string -: -: -ToString -; -use super : : diff --git a/third_party/rust/regex-syntax/src/parser.rs b/third_party/rust/regex-syntax/src/parser.rs index c8bd92fa4c947..efec556648c57 100644 --- a/third_party/rust/regex-syntax/src/parser.rs +++ b/third_party/rust/regex-syntax/src/parser.rs @@ -2,184 +2,20 @@ use crate : : -{ ast -hir -Error -} ; -/ -/ -/ -A -convenience -routine -for -parsing -a -regex -using -default -options -. -/ -/ -/ -/ -/ -/ -This -is -equivalent -to -Parser -: -: -new -( -) -. -parse -( -pattern -) -. -/ -/ -/ -/ -/ -/ -If -you -need -to -set -non -- -default -options -then use -a -[ -ParserBuilder -] -. -/ -/ -/ -/ -/ -/ -This -routine -returns -an -[ -Hir -] -( -hir -: -: -Hir -) -value -. -Namely -it -automatically -/ -/ -/ -parses -the -pattern -as -an -[ -Ast -] -( -ast +crate : : -Ast -) -and -then -invokes -the -translator -/ -/ -/ -to -convert -the -Ast -into -an -Hir -. -If -you -need -access -to -the -Ast -then -/ -/ -/ -you -should +hir +; use -a -[ -ast -: -: -parse -: +crate : -Parser -] -. -pub -fn -parse -( -pattern : -& -str -) -- -> Result -< -hir -: -: -Hir -Error -> -{ -Parser -: -: -new -( -) -. -parse -( -pattern -) -} +; / / / @@ -222,39 +58,46 @@ options for both the -[ -AST / / / +[ +AST ParserBuilder ] ( ast -: -: +/ parse -: -: +/ +struct +. ParserBuilder +. +html ) +/ +/ +/ and the -[ -HIR / / / +[ +HIR TranslatorBuilder ] ( hir -: -: +/ translate -: -: +/ +struct +. TranslatorBuilder +. +html ) . # @@ -923,8 +766,9 @@ self / / When -disabled -translation +enabled +the +parser will permit the @@ -951,39 +795,27 @@ UTF / / When -enabled +disabled ( the default ) the -translator +parser is guaranteed to produce -an / / / +an expression that -for -non -- -empty -matches will only ever -produce -spans -/ -/ -/ -that -are -entirely +match valid UTF - @@ -991,13 +823,13 @@ UTF ( otherwise the -translator -will -return -an / / / +parser +will +return +an error ) . @@ -1010,22 +842,20 @@ error Perhaps surprisingly when +invalid UTF - 8 -is -enabled -an -empty -regex -or -even -/ -/ -/ +isn +' +t +allowed a negated ASCII +/ +/ +/ word boundary ( @@ -1042,86 +872,47 @@ B in the concrete -/ -/ -/ syntax ) will -be -allowed -even -though -they -can -produce -matches -that -split +cause / / / -a -UTF -- -8 -encoded -codepoint -. -This -only -applies +the +parser to -zero -- -width -or -" -empty -" -/ -/ -/ -matches -and -it -is -expected -that -the -regex -engine -itself -must -handle -/ -/ -/ -these -cases -if -necessary -( -perhaps -by -suppressing -any -zero -- -width -matches +return +an +error +. +Namely +a +negated +ASCII +word +boundary / / / +can +result +in +matching +positions that -split -a -codepoint -) +aren +' +t +valid +UTF +- +8 +boundaries . pub fn -utf8 +allow_invalid_utf8 ( & mut @@ -1140,7 +931,7 @@ self . hir . -utf8 +allow_invalid_utf8 ( yes ) @@ -1494,469 +1285,6 @@ Enable or disable the -CRLF -mode -flag -by -default -. -/ -/ -/ -/ -/ -/ -By -default -this -is -disabled -. -It -may -alternatively -be -selectively -/ -/ -/ -enabled -in -the -regular -expression -itself -via -the -R -flag -. -/ -/ -/ -/ -/ -/ -When -CRLF -mode -is -enabled -the -following -happens -: -/ -/ -/ -/ -/ -/ -* -Unless -dot_matches_new_line -is -enabled -. -will -match -any -character -/ -/ -/ -except -for -\ -r -and -\ -n -. -/ -/ -/ -* -When -multi_line -mode -is -enabled -^ -and -will -treat -\ -r -\ -n -/ -/ -/ -\ -r -and -\ -n -as -line -terminators -. -And -in -particular -neither -will -/ -/ -/ -match -between -a -\ -r -and -a -\ -n -. -pub -fn -crlf -( -& -mut -self -yes -: -bool -) -- -> -& -mut -ParserBuilder -{ -self -. -hir -. -crlf -( -yes -) -; -self -} -/ -/ -/ -Sets -the -line -terminator -for -use -with -( -? -u -- -s -: -. -) -and -( -? -- -us -: -. -) -. -/ -/ -/ -/ -/ -/ -Namely -instead -of -. -( -by -default -) -matching -everything -except -for -\ -n -/ -/ -/ -this -will -cause -. -to -match -everything -except -for -the -byte -given -. -/ -/ -/ -/ -/ -/ -If -. -is -used -in -a -context -where -Unicode -mode -is -enabled -and -this -byte -/ -/ -/ -isn -' -t -ASCII -then -an -error -will -be -returned -. -When -Unicode -mode -is -/ -/ -/ -disabled -then -any -byte -is -permitted -but -will -return -an -error -if -UTF -- -8 -/ -/ -/ -mode -is -enabled -and -it -is -a -non -- -ASCII -byte -. -/ -/ -/ -/ -/ -/ -In -short -any -ASCII -value -for -a -line -terminator -is -always -okay -. -But -a -/ -/ -/ -non -- -ASCII -byte -might -result -in -an -error -depending -on -whether -Unicode -/ -/ -/ -mode -or -UTF -- -8 -mode -are -enabled -. -/ -/ -/ -/ -/ -/ -Note -that -if -R -mode -is -enabled -then -it -always -takes -precedence -and -/ -/ -/ -the -line -terminator -will -be -treated -as -\ -r -and -\ -n -simultaneously -. -/ -/ -/ -/ -/ -/ -Note -also -that -this -* -doesn -' -t -* -impact -the -look -- -around -assertions -/ -/ -/ -( -? -m -: -^ -) -and -( -? -m -: -) -. -That -' -s -usually -controlled -by -additional -/ -/ -/ -configuration -in -the -regex -engine -itself -. -pub -fn -line_terminator -( -& -mut -self -byte -: -u8 -) -- -> -& -mut -ParserBuilder -{ -self -. -hir -. -line_terminator -( -byte -) -; -self -} -/ -/ -/ -Enable -or -disable -the " swap greed @@ -2083,21 +1411,21 @@ flag Note that unless -utf8 +allow_invalid_utf8 is -disabled +enabled ( it ' s -enabled +disabled by -default -) -a / / / +default +) +a regular expression will @@ -2108,12 +1436,12 @@ if Unicode mode is -disabled -and -a / / / +disabled +and +a sub - expression @@ -2299,6 +1627,15 @@ ast : parse ] +( +ast +/ +parse +/ +index +. +html +) module . / @@ -2317,9 +1654,19 @@ more detail via a +/ +/ +/ [ ParserBuilder ] +( +struct +. +ParserBuilder +. +html +) . # [ @@ -2417,9 +1764,19 @@ on the parser use +/ +/ +/ [ ParserBuilder ] +( +struct +. +ParserBuilder +. +html +) . pub fn @@ -2478,7 +1835,6 @@ hir : : Hir -Error > { let diff --git a/third_party/rust/regex-syntax/src/unicode.rs b/third_party/rust/regex-syntax/src/unicode.rs index 18db91c4cfa83..d6b778da0906a 100644 --- a/third_party/rust/regex-syntax/src/unicode.rs +++ b/third_party/rust/regex-syntax/src/unicode.rs @@ -1,20 +1,20 @@ use -alloc +std : : -{ -string +error +; +use +std : : -{ -String -ToString -} -vec +fmt +; +use +std : : -Vec -} +result ; use crate @@ -25,6 +25,37 @@ hir / / / +A +type +alias +for +errors +specific +to +Unicode +handling +of +classes +. +pub +type +Result +< +T +> += +result +: +: +Result +< +T +Error +> +; +/ +/ +/ An inclusive range @@ -143,6 +174,36 @@ PerlClassNotFound / / / +A +type +alias +for +errors +specific +to +Unicode +case +folding +. +pub +type +FoldResult +< +T +> += +result +: +: +Result +< +T +CaseFoldError +> +; +/ +/ +/ An error that @@ -222,21 +283,7 @@ CaseFoldError ) ) ; -# -[ -cfg -( -feature -= -" -std -" -) -] impl -std -: -: error : : @@ -246,9 +293,6 @@ CaseFoldError { } impl -core -: -: fmt : : @@ -265,9 +309,6 @@ f : & mut -core -: -: fmt : : @@ -279,9 +320,6 @@ _ ) - > -core -: -: fmt : : @@ -404,21 +442,7 @@ UnicodeWordError ) ) ; -# -[ -cfg -( -feature -= -" -std -" -) -] impl -std -: -: error : : @@ -428,9 +452,6 @@ UnicodeWordError { } impl -core -: -: fmt : : @@ -447,9 +468,6 @@ f : & mut -core -: -: fmt : : @@ -461,9 +479,6 @@ _ ) - > -core -: -: fmt : : @@ -504,52 +519,37 @@ enabled / / / -A -state -oriented -traverser -of +Return +an +iterator +over the +equivalence +class +of simple case -folding -table -. -/ -/ -/ +mappings / / / -A -case -folder -can -be -constructed -via -SimpleCaseFolder -: -: -new -( -) -which -will +for +the +given +codepoint +. +The +equivalence +class +does +not +include +the / / / -return -an -error -if -the -underlying -case -folding -table -is -unavailable +given +codepoint . / / @@ -557,293 +557,132 @@ unavailable / / / -After -construction -it +If +the +equivalence +class is -expected -that -callers -will -use +empty +then +this +returns +the +next +scalar / / / -SimpleCaseFolder -: -: -mapping -by -calling +value +that +has +a +non +- +empty +equivalence +class +if it -with -codepoints -in -strictly +exists +. +If +no +such / / / -increasing -order -. -For -example -calling -it -on -b -and +scalar +value +exists then -on -a +None is -illegal -/ -/ -/ -and -will -result -in -a -panic +returned . +The +point +of +this +behavior / / / +is +to +permit +callers +to +avoid +calling +simple_fold +more +than +they +need / / / -The -main -idea -of -this -type +to +since +there is -that -it -tries -hard +some +cost to -make -mapping -lookups +fetching +the +equivalence +class +. / / / -fast -by -exploiting -the -structure -of -the -underlying -table -and -the -ordering -/ -/ -/ -assumption -enables -this -. -# -[ -derive -( -Debug -) -] -pub -struct -SimpleCaseFolder -{ -/ -/ -/ -The -simple -case -fold -table -. -It -' -s -a -sorted -association -list -where -the -/ -/ -/ -keys -are -Unicode -scalar -values -and -the -values -are -the -corresponding -/ -/ -/ -equivalence -class -( -not -including -the -key -) -of -the -" -simple -" -case -folded -/ -/ -/ -Unicode -scalar -values -. -table -: -& -' -static -[ -( -char -& -' -static -[ -char -] -) -] -/ -/ -/ -The -last -codepoint -that -was -used -for -a -lookup -. -last -: -Option -< -char -> -/ -/ -/ -The -index -to -the -entry -in -table -corresponding -to -the -smallest -key -k -/ -/ -/ -such -that -k -> -k0 -where -k0 -is -the -most -recent -key -lookup -. -Note -that -/ -/ -/ -in -particular -k0 -may -not -be -in -the -table -! -next -: -usize -} -impl -SimpleCaseFolder -{ / / / -Create -a -new -simple -case -folder -returning +This +returns an error if the -underlying -/ -/ -/ +Unicode case folding -table -is -unavailable +tables +are +not +available . pub fn -new +simple_fold ( +c +: +char ) - > +FoldResult +< +result +: +: Result < -SimpleCaseFolder -CaseFoldError +impl +Iterator +< +Item += +char +> +Option +< +char +> +> > { # @@ -862,8 +701,62 @@ case ) ) ] +fn +imp +( +_ +: +char +) +- +> +FoldResult +< +result +: +: +Result +< +impl +Iterator +< +Item += +char +> +Option +< +char +> +> +> { +use +std +: +: +option +: +: +IntoIter +; Err +: +: +< +result +: +: +Result +< +IntoIter +< +char +> +_ +> +_ +> ( CaseFoldError ( @@ -885,409 +778,125 @@ case " ) ] -{ -Ok +fn +imp ( -SimpleCaseFolder -{ -table -: -crate -: -: -unicode_tables -: -: -case_folding_simple +c : +char +) +- +> +FoldResult +< +result : -CASE_FOLDING_SIMPLE -last -: -None -next -: -0 -} -) -} -} -/ -/ -/ -Return -the -equivalence -class -of -case -folded -codepoints -for -the -given -/ -/ -/ -codepoint -. -The -equivalence -class -returned -never -includes -the -codepoint -/ -/ -/ -given -. -If -the -given -codepoint -has -no -case -folded -codepoints -( -i -. -e -. -/ -/ -/ -no -entry -in -the -underlying -case -folding -table -) -then -this -returns -an -/ -/ -/ -empty -slice -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -called -with -a -c -that -is -less -than -or -equal -to -the -/ -/ -/ -previous -call -. -In -other -words -callers -need -to -use -this -method -with -/ -/ -/ -strictly -increasing -values -of -c -. -pub -fn -mapping -( -& -mut -self -c : +Result +< +impl +Iterator +< +Item += char -) -- > -& -' -static -[ -char -] -{ -if -let -Some -( -last -) -= -self -. -last -{ -assert -! -( -last +Option < -c -" -got -codepoint -U -+ +char +> +> +> { +use +crate : -X -} -which -occurs -before -\ -last -codepoint -U -+ -{ : -X -} -" -u32 +unicode_tables : : -from -( -c -) -u32 +case_folding_simple : : -from -( -last -) -) +CASE_FOLDING_SIMPLE ; -} -self -. -last -= -Some +Ok ( -c -) -; -if -self -. -next -> -= -self -. -table +CASE_FOLDING_SIMPLE . -len +binary_search_by_key ( -) -{ -return & -[ -] -; -} -let +c +| +& ( -k -v +c1 +_ +) +| +c1 ) -= -self . -table +map +( +| +i +| +CASE_FOLDING_SIMPLE [ -self -. -next +i ] -; -if -k -= -= -c -{ -self . -next -+ -= 1 -; -return -v -; -} -match -self . -get +iter ( -c ) -{ -Err +. +copied ( -i ) -= -> -{ -self +) . -next -= -i -; -& -[ -] -} -Ok +map_err ( +| i -) -= -> +| { -/ -/ -Since -we -require -lookups -to -proceed -/ -/ -in -order -anything -we -find -should -be -/ -/ -after -whatever -we -thought -might -be -/ -/ -next -. -Otherwise -the -caller -is -either -/ -/ -going -out -of -order -or -we -would -have -/ -/ -found -our -next -key -at -' -self -. -next -' -. -assert -! -( +if i > -self -. -next -) -; -self -. -next = -i -+ -1 -; -self +CASE_FOLDING_SIMPLE . -table +len +( +) +{ +None +} +else +{ +Some +( +CASE_FOLDING_SIMPLE [ i ] . -1 +0 +) } } +) +) +} +imp +( +c +) } / / @@ -1300,153 +909,49 @@ only if the given +( +inclusive +) range -overlaps -with -any -region -/ -/ -/ -of -the -underlying -case -folding -table -. -That -is -when -true -there -exists +contains +at +least / / / -at -least one -codepoint -in -the -inclusive -range -[ -start -end -] +Unicode +scalar +value that has -/ -/ -/ a non - +empty +non +- trivial -equivalence -class -of -case -folded -codepoints -. -Conversely -/ -/ -/ -when -this -returns -false -all -codepoints -in -the -range -[ -start -end -] -/ -/ -/ -correspond -to -the -trivial -equivalence -class -of +simple case -folded -codepoints -/ -/ -/ -i -. -e -. -itself -. -/ -/ -/ -/ -/ -/ -This -is -useful -to -call -before -iterating -over -the -codepoints -in -the / / / -range -and -looking -up -the mapping -for -each . -If -you -know -none -of -the / / / -mappings -will -return -anything -then -you -might -be -able -to -skip -doing -it / / / -altogether +This +function +panics +if +end +< +start . / / @@ -1454,40 +959,124 @@ altogether / / / -# -Panics -/ -/ -/ -/ -/ -/ This -panics -when -end -< -start +returns +an +error +if +the +Unicode +case +folding +tables +are +not +available . pub fn -overlaps +contains_simple_case_mapping +( +start +: +char +end +: +char +) +- +> +FoldResult +< +bool +> +{ +# +[ +cfg +( +not +( +feature += +" +unicode +- +case +" +) +) +] +fn +imp +( +_ +: +char +_ +: +char +) +- +> +FoldResult +< +bool +> +{ +Err +( +CaseFoldError +( +( +) +) +) +} +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +fn +imp ( -& -self start : char end : -char -) -- -> -bool -{ +char +) +- +> +FoldResult +< +bool +> +{ +use +crate +: +: +unicode_tables +: +: +case_folding_simple +: +: +CASE_FOLDING_SIMPLE +; use -core +std : : cmp @@ -1504,9 +1093,9 @@ start end ) ; -self -. -table +Ok +( +CASE_FOLDING_SIMPLE . binary_search_by ( @@ -1559,98 +1148,14 @@ Less is_ok ( ) -} -/ -/ -/ -Returns -the -index -at -which -c -occurs -in -the -simple -case -fold -table -. -If -/ -/ -/ -c -does -not -occur -then -this -returns -an -i -such -that -table -[ -i -- -1 -] -. -0 -< -/ -/ -/ -c -and -table -[ -i -] -. -0 -> -c -. -fn -get -( -& -self -c -: -char ) -- -> -Result -< -usize -usize -> -{ -self -. -table -. -binary_search_by_key -( -& -c -| -& +} +imp ( -c1 -_ -) -| -c1 +start +end ) } -} / / / @@ -2004,7 +1509,6 @@ self Result < CanonicalClassQuery -Error > { match @@ -2296,226 +1800,108 @@ str ) - > -Result -< -CanonicalClassQuery -Error -> -{ -let -norm -= -symbolic_name_normalize -( -name -) -; -/ -/ -This -is -a -special -case -where -' -cf -' -refers -to -the -' -Format -' -general -/ -/ -category -but -where -the -' -cf -' -abbreviation -is -also -an -abbreviation -/ -/ -for -the -' -Case_Folding -' -property -. -But -we -want -to -treat -it -as -/ -/ -a -general -category -. -( -Currently -we -don -' -t -even -support -the -/ -/ -' -Case_Folding -' -property -. -But -if -we -do -in -the -future -users -will -be -/ -/ -required -to -spell -it -out -. -) -/ -/ -/ -/ -Also -' -sc -' -refers -to -the -' -Currency_Symbol -' -general -category -but -is -/ -/ -also -the -abbreviation -for -the -' -Script -' -property -. -So -we -avoid -calling -/ -/ -' -canonical_prop -' -for -it -too -which -would -erroneously -normalize -it -/ -/ -to -' -Script -' -. -/ -/ +Result +< +CanonicalClassQuery +> +{ +let +norm += +symbolic_name_normalize +( +name +) +; / / -Another +This +is +a +special case -: +where ' -lc +cf ' -is -an -abbreviation -for +refers +to the ' -Cased_Letter +Format ' +general / / -general category but +where +the +' +cf +' +abbreviation is also an abbreviation +/ +/ for the ' -Lowercase_Mapping +Case_Folding ' +property +. +But +we +want +to +treat +it +as / / -property +a +general +category . -We +( +Currently +we don ' t -currently +even support the -latter -so -as -with -' -cf -' / / -above -we -treat -' -lc ' -as -' -Cased_Letter +Case_Folding ' +property +. +But +if +we +do +in +the +future +users +will +be +/ +/ +required +to +spell +it +out . +) if norm ! @@ -2523,22 +1909,6 @@ norm " cf " -& -& -norm -! -= -" -sc -" -& -& -norm -! -= -" -lc -" { if let @@ -2856,7 +2226,6 @@ hir : : ClassUnicode -Error > { use @@ -3091,7 +2460,6 @@ hir : : ClassUnicode -Error > { # @@ -3122,7 +2490,6 @@ hir : : ClassUnicode -Error > { Err @@ -3158,7 +2525,6 @@ hir : : ClassUnicode -Error > { use @@ -3230,7 +2596,6 @@ hir : : ClassUnicode -Error > { # @@ -3271,7 +2636,6 @@ hir : : ClassUnicode -Error > { Err @@ -3320,7 +2684,6 @@ hir : : ClassUnicode -Error > { use @@ -3368,7 +2731,6 @@ hir : : ClassUnicode -Error > { use @@ -3440,7 +2802,6 @@ hir : : ClassUnicode -Error > { # @@ -3481,7 +2842,6 @@ hir : : ClassUnicode -Error > { Err @@ -3530,7 +2890,6 @@ hir : : ClassUnicode -Error > { use @@ -3578,7 +2937,6 @@ hir : : ClassUnicode -Error > { use @@ -3746,6 +3104,9 @@ char ) - > +result +: +: Result < bool @@ -3777,6 +3138,9 @@ char ) - > +result +: +: Result < bool @@ -3814,6 +3178,9 @@ char ) - > +result +: +: Result < bool @@ -3824,8 +3191,12 @@ use crate : : -{ is_word_byte +; +use +crate +: +: unicode_tables : : @@ -3833,21 +3204,30 @@ perl_word : : PERL_WORD -} ; -if -u8 +use +std : : -try_from -( +cmp +: +: +Ordering +; +if c -) -. -map_or -( -false +< += +0x7F +as +char +& +& is_word_byte +( +c +as +u8 ) { return @@ -3871,15 +3251,6 @@ end ) | { -use -core -: -: -cmp -: -: -Ordering -; if start < @@ -4016,7 +3387,6 @@ Option static str > -Error > { Ok @@ -4104,7 +3474,6 @@ Option static str > -Error > { let @@ -4229,7 +3598,6 @@ Option static str > -Error > { # @@ -4305,7 +3673,6 @@ Option static str > -Error > { Err @@ -4386,7 +3753,6 @@ Option static str > -Error > { use @@ -4642,7 +4008,6 @@ Option < PropertyValues > -Error > { # @@ -4717,7 +4082,6 @@ Option < PropertyValues > -Error > { Err @@ -4797,7 +4161,6 @@ Option < PropertyValues > -Error > { use @@ -5051,7 +4414,6 @@ Item = Range > -Error > { # @@ -5089,11 +4451,10 @@ Item = Range > -Error > { use -core +std : : option @@ -5150,7 +4511,6 @@ Item = Range > -Error > { use @@ -5587,7 +4947,6 @@ hir : : ClassUnicode -Error > { # @@ -5624,7 +4983,6 @@ hir : : ClassUnicode -Error > { Err @@ -5666,7 +5024,6 @@ hir : : ClassUnicode -Error > { use @@ -5887,7 +5244,6 @@ hir : : ClassUnicode -Error > { # @@ -5924,7 +5280,6 @@ hir : : ClassUnicode -Error > { Err @@ -5966,7 +5321,6 @@ hir : : ClassUnicode -Error > { use @@ -6087,7 +5441,6 @@ hir : : ClassUnicode -Error > { # @@ -6124,7 +5477,6 @@ hir : : ClassUnicode -Error > { Err @@ -6166,7 +5518,6 @@ hir : : ClassUnicode -Error > { use @@ -6292,7 +5643,6 @@ hir : : ClassUnicode -Error > { # @@ -6329,7 +5679,6 @@ hir : : ClassUnicode -Error > { Err @@ -6371,7 +5720,6 @@ hir : : ClassUnicode -Error > { use @@ -6519,7 +5867,6 @@ hir : : ClassUnicode -Error > { # @@ -6556,7 +5903,6 @@ hir : : ClassUnicode -Error > { Err @@ -6598,7 +5944,6 @@ hir : : ClassUnicode -Error > { use @@ -6722,7 +6067,6 @@ hir : : ClassUnicode -Error > { # @@ -6759,7 +6103,6 @@ hir : : ClassUnicode -Error > { Err @@ -6801,7 +6144,6 @@ hir : : ClassUnicode -Error > { use @@ -6925,7 +6267,6 @@ hir : : ClassUnicode -Error > { # @@ -6962,7 +6303,6 @@ hir : : ClassUnicode -Error > { Err @@ -7004,7 +6344,6 @@ hir : : ClassUnicode -Error > { use @@ -7767,25 +7106,73 @@ slice [ . . -next_write -] -} -# -[ -cfg +next_write +] +} +# +[ +cfg +( +test +) +] +mod +tests +{ +use +super +: +: +{ +contains_simple_case_mapping +simple_fold +symbolic_name_normalize +symbolic_name_normalize_bytes +} +; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +fn +simple_fold_ok +( +c +: +char +) +- +> +impl +Iterator +< +Item += +char +> +{ +simple_fold +( +c +) +. +unwrap +( +) +. +unwrap ( -test ) -] -mod -tests -{ -use -super -: -: -* -; +} # [ cfg @@ -7800,7 +7187,7 @@ case ) ] fn -simple_fold_ok +simple_fold_err ( c : @@ -7808,37 +7195,45 @@ char ) - > -impl -Iterator +Option < -Item -= char > { -SimpleCaseFolder -: -: -new +match +simple_fold ( +c ) . unwrap ( ) -. -mapping +{ +Ok ( -c +_ ) -. -iter += +> +unreachable +! ( +" +simple_fold +returned +Ok +iterator +" ) -. -copied +Err ( +next ) += +> +next +} } # [ @@ -7867,22 +7262,15 @@ char > bool { -SimpleCaseFolder -: -: -new +contains_simple_case_mapping ( +start +end ) . unwrap ( ) -. -overlaps -( -start -end -) } # [ @@ -7929,9 +7317,6 @@ assert_eq ! ( xs -alloc -: -: vec ! [ @@ -7966,9 +7351,6 @@ assert_eq ! ( xs -alloc -: -: vec ! [ @@ -8002,9 +7384,6 @@ assert_eq ! ( xs -alloc -: -: vec ! [ @@ -8063,9 +7442,6 @@ assert_eq ! ( xs -alloc -: -: vec ! [ @@ -8098,9 +7474,6 @@ assert_eq ! ( xs -alloc -: -: vec ! [ @@ -8119,6 +7492,149 @@ test [ cfg ( +feature += +" +unicode +- +case +" +) +] +fn +simple_fold_empty +( +) +{ +assert_eq +! +( +Some +( +' +A +' +) +simple_fold_err +( +' +? +' +) +) +; +assert_eq +! +( +Some +( +' +A +' +) +simple_fold_err +( +' +' +) +) +; +assert_eq +! +( +Some +( +' +a +' +) +simple_fold_err +( +' +[ +' +) +) +; +assert_eq +! +( +Some +( +' +' +) +simple_fold_err +( +' +' +) +) +; +} +# +[ +test +] +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +fn +simple_fold_max +( +) +{ +assert_eq +! +( +None +simple_fold_err +( +' +\ +u +{ +10FFFE +} +' +) +) +; +assert_eq +! +( +None +simple_fold_err +( +' +\ +u +{ +10FFFF +} +' +) +) +; +} +# +[ +test +] +# +[ +cfg +( not ( feature @@ -8139,11 +7655,11 @@ simple_fold_disabled assert ! ( -SimpleCaseFolder -: -: -new +simple_fold ( +' +a +' ) . is_err @@ -8306,6 +7822,50 @@ test [ cfg ( +not +( +feature += +" +unicode +- +case +" +) +) +] +fn +range_contains_disabled +( +) +{ +assert +! +( +contains_simple_case_mapping +( +' +a +' +' +a +' +) +. +is_err +( +) +) +; +} +# +[ +test +] +# +[ +cfg +( feature = " diff --git a/third_party/rust/regex-syntax/src/utf8.rs b/third_party/rust/regex-syntax/src/utf8.rs index 8bc15a635c14e..184f302361f90 100644 --- a/third_party/rust/regex-syntax/src/utf8.rs +++ b/third_party/rust/regex-syntax/src/utf8.rs @@ -56,13 +56,16 @@ hir ClassUnicodeRange ] ( -crate -: -: +. +. +/ hir -: -: +/ +struct +. ClassUnicodeRange +. +html ) type . @@ -768,31 +771,40 @@ index . * / +# +! +[ +deny +( +missing_docs +) +] use -core +std : : -{ char +; +use +std +: +: fmt +; +use +std +: +: iter : : FusedIterator -slice -} ; use -alloc -: -: -{ -vec -vec +std : : -Vec -} +slice ; const MAX_UTF8_BYTES @@ -2773,20 +2785,12 @@ it . push ( -u32 -: -: -from -( start -) +as u32 -: -: -from -( end -) +as +u32 ) ; it @@ -2867,20 +2871,12 @@ self . push ( -u32 -: -: -from -( start -) +as u32 -: -: -from -( end -) +as +u32 ) ; } @@ -3567,49 +3563,23 @@ is_ascii ( ) { -let -start -= -u8 +Some +( +Utf8Range : : -try_from +new ( self . start -) -. -unwrap -( -) -; -let -end -= +as u8 -: -: -try_from -( self . end -) -. -unwrap -( -) -; -Some -( -Utf8Range -: -: -new -( -start -end +as +u8 ) ) } @@ -3885,24 +3855,12 @@ mod tests { use -core +std : : char ; use -alloc -: -: -{ -vec -vec -: -: -Vec -} -; -use crate : : @@ -4025,20 +3983,12 @@ bytes ? } " -u32 -: -: -from -( start -) +as u32 -: -: -from -( end -) +as +u32 r cp buf @@ -4716,10 +4666,6 @@ dst 0 ] = -u8 -: -: -try_from ( cp > @@ -4728,10 +4674,8 @@ cp & 0x0F ) -. -unwrap -( -) +as +u8 | TAG_THREE_B ; @@ -4740,10 +4684,6 @@ dst 1 ] = -u8 -: -: -try_from ( cp > @@ -4752,10 +4692,8 @@ cp & 0x3F ) -. -unwrap -( -) +as +u8 | TAG_CONT ; @@ -4764,19 +4702,13 @@ dst 2 ] = -u8 -: -: -try_from ( cp & 0x3F ) -. -unwrap -( -) +as +u8 | TAG_CONT ; diff --git a/third_party/rust/regex-syntax/test b/third_party/rust/regex-syntax/test index 957b4d9c9d38b..a8c024cab3d11 100644 --- a/third_party/rust/regex-syntax/test +++ b/third_party/rust/regex-syntax/test @@ -8,48 +8,6 @@ set - e # -cd -to -the -directory -containing -this -crate -' -s -Cargo -. -toml -so -that -we -don -' -t -need -# -to -pass -- -- -manifest -- -path -to -every -cargo -command -. -cd -" -( -dirname -" -0 -" -) -" -# This is a @@ -83,7 +41,6 @@ test features = ( -std unicode unicode - @@ -124,6 +81,8 @@ echo = = = += += FEATURE : f @@ -131,50 +90,6 @@ f = = " -# -We -only -run -library -tests -because -I -couldn -' -t -figure -out -how -to -easily -# -make -doc -tests -run -in -' -no_std -' -mode -. -In -particular -without -the -Error -# -trait -using -' -? -' -in -doc -tests -seems -tricky -. cargo test - @@ -186,9 +101,6 @@ default features - - -lib -- -- features " f diff --git a/third_party/rust/regex/.cargo-checksum.json b/third_party/rust/regex/.cargo-checksum.json index 38e7f7468519b..68cffa66789f0 100644 --- a/third_party/rust/regex/.cargo-checksum.json +++ b/third_party/rust/regex/.cargo-checksum.json @@ -11,1832 +11,207 @@ md " : " -920271ea6fdc901f01e8535d732370509714326874a4073ab75cd0c9d899fc14 +47b22859157339150c957dd72be9cf87aee341ebb3711efac5930efb10436368 " " Cargo . -toml -" -: -" -2913e983f1b366ef6be4ac7da62d3e2c8e4847cfea4257d5618a90e67363d26e -" -" -Cross -. -toml -" -: -" -4a11d6c63ecc919016b59fa0fe23674eb05682fb91ffbe677a4a7077e9e684ff -" -" -HACKING -. -md -" -: -" -17818f7a17723608f6bdbe6388ad0a913d4f96f76a16649aaf4e274b1fa0ea97 -" -" -LICENSE -- -APACHE -" -: -" -a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 -" -" -LICENSE -- -MIT -" -: -" -6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb -" -" -README -. -md -" -: -" -932f36c0fc3ac869fcca51018e6c87c75278665d42e51d22834fa52ceec2c95c -" -" -UNICODE -. -md -" -: -" -845fca1982e82e190109a784952579fce54faea120b702b7efd61164a12f601f -" -" -record -/ -README -. -md -" -: -" -02e6f85f8a43f18540e4a52a75d1001494df7aceac3873e9a13e3ceba190206d -" -" -record -/ -compile -- -test -/ -2023 -- -04 -- -19_1 -. -7 -. -3 -. -csv -" -: -" -460059ba2f10456175ff92bd75d4a365b14a1843e2b46e7b285d58da59e6d3ca -" -" -record -/ -compile -- -test -/ -2023 -- -04 -- -20_master -. -csv -" -: -" -6b94df278e4ed82a3fd0d4bfe92a4614714e00435e983c7649ee9f54925f906e -" -" -record -/ -compile -- -test -/ -2023 -- -07 -- -05 -. -csv -" -: -" -cf00b4981b8c12980113810dba40e2063a8400354ad4dab16f7c212ff0b5db74 -" -" -record -/ -compile -- -test -/ -README -. -md -" -: -" -ba2b606993edd8d705ad1677ec954862614e52b028407e1908bb5dfb07767f2d -" -" -record -/ -old -- -bench -- -log -/ -01 -- -lazy -- -dfa -/ -dynamic -" -: -" -dec9f74b8835403c71edc0c2d93bbdde0f5a0e37d46585e416c80496d5b14497 -" -" -record -/ -old -- -bench -- -log -/ -01 -- -lazy -- -dfa -/ -dynamic -- -no -- -lazy -- -dfa -" -: -" -c0ce02bef9ada8cd55672f0a9c3c5fc64f71e08bfb2b45978082a140b4fc111f -" -" -record -/ -old -- -bench -- -log -/ -01 -- -lazy -- -dfa -/ -native -" -: -" -9de61ff787e36f5c6f1eaec68b8bb0583e57b0aad23712afe8c0048988c761b8 -" -" -record -/ -old -- -bench -- -log -/ -01 -- -lazy -- -dfa -/ -nfa -" -: -" -38c0be44a00b2caef17101bc425410fec2958e4df6da25d2ba5b6664f8bccad9 -" -" -record -/ -old -- -bench -- -log -/ -01 -- -lazy -- -dfa -/ -pcre -" -: -" -3b38026c24e4ca487ff62de83cc093ccb46b918f4875663249ff84ce27636942 -" -" -record -/ -old -- -bench -- -log -/ -02 -- -set -/ -dynamic -" -: -" -8ef5c00f0ac42e5f008e4b6337669527b48fba38df94c50d3e683c6aac66a48c -" -" -record -/ -old -- -bench -- -log -/ -03 -- -bytes -/ -onig -" -: -" -f32347a6e0f25f46ad1b0aa736c29eca47c25f90d32c8823ea0d14204859a35b -" -" -record -/ -old -- -bench -- -log -/ -03 -- -bytes -/ -pcre -" -: -" -b90982575c0ad55617b2ce50c2e9853d090502bf07e1eb19edf9009d3c9f2987 -" -" -record -/ -old -- -bench -- -log -/ -03 -- -bytes -/ -rust -" -: -" -b1e70e5ae48a9c726d8cd8a98019c0efe5a1095563c61cf0ac75e24de32461b4 -" -" -record -/ -old -- -bench -- -log -/ -03 -- -bytes -/ -rust -- -bytes -" -: -" -fbf0e6cb8102c7ca8e59bd459bb0ae7f1feaf8103def70b8d4793c59e68e8736 -" -" -record -/ -old -- -bench -- -log -/ -04 -/ -onig -" -: -" -4e34e2ede0a806b8ee540e63e4babee38049e5a8ab3be99c4f5d8b02bbc653fd -" -" -record -/ -old -- -bench -- -log -/ -04 -/ -pcre1 -- -jit -" -: -" -736c4941e991ef94f76379cf2187d0ea2a41b052cf80c94d0dd0c9ea758a6491 -" -" -record -/ -old -- -bench -- -log -/ -04 -/ -pcre2 -- -jit -" -: -" -00e7bbf7749904fca8dff9b441d15bbe670f37b427e385ddf740f7a49de3b1fb -" -" -record -/ -old -- -bench -- -log -/ -04 -/ -re2 -" -: -" -b8b8595f6b68da127b56dc7c61a9fd15548251fda1be9d2c50c2d48382e887b6 -" -" -record -/ -old -- -bench -- -log -/ -04 -/ -rust -" -: -" -c5a6b918e815294f0c4e3d37267c444d49692ff131c5a08f7462c24d0721fcec -" -" -record -/ -old -- -bench -- -log -/ -04 -/ -tcl -" -: -" -c4d8d12b8cf48ff2017549e95e49dc95a90ea15483834cd70d2d7d7c237bbd32 -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -onig -" -: -" -70a4da9aafaefa6493cd09d3a529dd5d2d9eacf390bb093681bc7be28a1f926c -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -onig -- -vs -- -rust -" -: -" -b942a79735b7330241437776c15b18f4db3eff01d3e6c35494f4a8732e74a23a -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -pcre1 -" -: -" -b29b7efbe79b55ce0aaf24bbbecc376a865fa219a68d96124e3d95951cdb47f4 -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -pcre1 -- -vs -- -rust -" -: -" -a458e5c62f0500898e08757753c10981551649656432ec096f0c82b414ef8d82 -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -pcre2 -" -: -" -faa93937c3490cfdff88c32dc04e57f2ae881923b87781e5fe876535fd690770 -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -pcre2 -- -vs -- -rust -" -: -" -bf9faa6a679dd98e9452e52c0941d2eb84dcf0b6632c15507f8334ed7bc309da -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -re2 -" -: -" -692866b28e1bc368c7a59f519b8dfe1da50a135946ce153298a0ab228a5ee59d -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -re2 -- -vs -- -rust -" -: -" -55e4cb14c397574751aebe38068c429a4580a5e309857b2715047944903dca58 -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -rust -" -: -" -aac6acda9f63e51613712d0a33bb7fb46dfc7adc425f76b9b71195be8c8a42e7 -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -tcl -" -: -" -f03e39eccd3252162cc6099bb0426014df669d299ba0ef79e89b8401886a5172 -" -" -record -/ -old -- -bench -- -log -/ -05 -/ -tcl -- -vs -- -rust -" -: -" -ae6ac4668573bf5488cc235c5da16ad9358d07b7644207d9bcea88ba6f5514a6 -" -" -record -/ -old -- -bench -- -log -/ -06 -/ -dphobos -- -dmd -" -: -" -473328306be335a0320c690d9c2dbefdf7f2f5a80e4ca69443c7ed2e81bb093f -" -" -record -/ -old -- -bench -- -log -/ -06 -/ -dphobos -- -dmd -- -ct -" -: -" -60341c736382a6db21d9889369ea4617c521acbf30d4b3bf38bcd17f4f85b9b1 -" -" -record -/ -old -- -bench -- -log -/ -06 -/ -dphobos -- -ldc -" -: -" -ae60c2bed84afb89ae43615f26de4cc5d0042e179089b639507378518eed3252 -" -" -record -/ -old -- -bench -- -log -/ -06 -/ -dphobos -- -ldc -- -ct -" -: -" -a157ef450793b73de3a816fab1d93a6d11e90a817082bae5e3da02a66fcc833f -" -" -record -/ -old -- -bench -- -log -/ -06 -/ -pcre1 -" -: -" -ad10fd7db732e8670dd3d4eedb05f48f547b4782495aaadff8ec25a6ea1992a0 -" -" -record -/ -old -- -bench -- -log -/ -06 -/ -pcre2 -" -: -" -f789a73bd41a0bc401bdebe7f10a03a8aa587de48643d88507d16181a8fa39d3 -" -" -record -/ -old -- -bench -- -log -/ -06 -/ -re2 -" -: -" -203c273a110d71f5edf722630202a6142c39d6b7a9951686adf8b9c20c5db278 -" -" -record -/ -old -- -bench -- -log -/ -06 -/ -rust -" -: -" -6a642a16cd279c99ef5a580a25fb3a63ac6239cd73df9261c02912fa08145753 -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -boost -" -: -" -255bc652c4d9e9d20aa9b22d8d86e952e7ec6c8b9fcde0c3d6e38c967e04d40e -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -dphobos -- -dmd -" -: -" -fb3ac60037050858611145ca3e71412164688dcdec52c022787d33304e022260 -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -dphobos -- -dmd -- -ct -" -: -" -40a5088441f8ffe3dae0abaf31c105cedfbe3b56c06772f075947d504976d2ed -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -oniguruma -" -: -" -ae0cd60adb15845eb9ef706111d4ee0e6ad5a58f0276b787d68bd7d637f8f7c6 -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -pcre1 -" -: -" -a812d065ec248249f9bb3d6d970f15c18d342f6b443265ad4b07fa91b73575cc -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -pcre2 -" -: -" -88230663eccd0b382cf5be81ce1ae6cfa3fa835a65a31c1eba4369d2e8de5d27 -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -re2 -" -: -" -e330ef21ce44351afc3c43821d862e9c625877606569f3af0ddbadcd7b21c602 -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -rust -" -: -" -d8c6bd5c46f5df9d0ac222f7be7793527a8137d273c8826b3715c67e16209aac -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -rust -- -bytes -" -: -" -e21d02fa2ef1e5ed7204920b33ed24c9fb620e068ed47ed6879b72e76369a27e -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -stdcpp -" -: -" -9df02d89dc8232c700b8cf8bc6f1ece3ca7af84ab52e67a660039d6c9168aed4 -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -stdcpp -- -libcxx -" -: -" -f90849a0b5dc11dc0280ad97886e92e1d91c080403ad7a4ecd638a26fe5e8c5e -" -" -record -/ -old -- -bench -- -log -/ -07 -/ -tcl -" -: -" -7f6e347bb507f9c00ff664d3e627c0a9cf842b416eeb2af9f3b6cccd041c58e4 -" -" -record -/ -old -- -bench -- -log -/ -08 -- -new -- -memmem -/ -rust -- -after -- -01 -" -: -" -646c7d50aea9c560a35eb60116f301f4fb8d4b03fd5814d8b24adffd070332e3 -" -" -record -/ -old -- -bench -- -log -/ -08 -- -new -- -memmem -/ -rust -- -after -- -02 -" -: -" -14e7fb6c6faa85a8f90617528cef79ae382aeba07c2e5c253c68445902b060ba -" -" -record -/ -old -- -bench -- -log -/ -08 -- -new -- -memmem -/ -rust -- -before -- -01 -" -: -" -7e3b58de0f502c1a1bf6d27e0e85c654b1189716f7374cec4ed4dd365b13101f -" -" -record -/ -old -- -bench -- -log -/ -08 -- -new -- -memmem -/ -rust -- -before -- -02 -" -: -" -ab6d09529eeeca7ff0da945d59701dbbcfdec5e05581bb9bf154779d12a35e53 -" -" -record -/ -old -- -bench -- -log -/ -09 -- -new -- -baseline -/ -pcre2 -" -: -" -28df8e2762f267d1ea628906a6e4bbc21f99e6a445bd322c86d0ca483b21b5b3 -" -" -record -/ -old -- -bench -- -log -/ -09 -- -new -- -baseline -/ -re2 -" -: -" -421437193cc3f159c178479f98bde8dbe27883ec7757b1ddd8d745862f5899ff -" -" -record -/ -old -- -bench -- -log -/ -09 -- -new -- -baseline -/ -rust -" -: -" -6f932a769171b6cdb717c9d01e44a70762ef660c4045b9d2bb3797a9bdf65405 -" -" -record -/ -old -- -bench -- -log -/ -09 -- -new -- -baseline -/ -rust -- -bytes -" -: -" -9c5acd5c1eeac9acfe76d03588041f9b6d65b4351085c3510888ceeb83e8a7b5 -" -" -record -/ -old -- -bench -- -log -/ -10 -- -last -- -frontier -/ -rust -- -after -- -literal -. -log -" -: -" -02baef9b3b49acbbff43e81f48ea5a9287e30ff4fc298a3f3b48991d8374aabf -" -" -record -/ -old -- -bench -- -log -/ -10 -- -last -- -frontier -/ -rust -- -before -- -literal -. -log -" -: -" -e5a3bcc2b9e93cf3cb27bc9e6305b3bc03215751bbeef2a70fb25577d6b42874 -" -" -record -/ -old -- -bench -- -log -/ -10 -- -last -- -frontier -/ -rust -- -bytes -- -after -- -literal -. -log -" -: -" -29834c7a5396ac61acedd07c0b7ca60716865ec3e70f35fbaa7826a2309a79d9 -" -" -record -/ -old -- -bench -- -log -/ -10 -- -last -- -frontier -/ -rust -- -bytes -- -before -- -literal -. -log -" -: -" -4e7468a3e8629814bd4af91e2a8eb42d0899d352b5dff3058b801aa637046be2 -" -" -record -/ -old -- -bench -- -log -/ -11 -- -regex -- -1 -. -7 -. -3 -/ -rust +lock " : " -d7cc18a62070ea7a999e1ba2458f26cf94595f1af276c2b3e96cee638eccf3f0 +3445929e595d109e2f37d349ffad3dd6cb76e7203a029cf1955838d0438d68a4 " " -record -/ -old -- -bench -- -log -/ -11 -- -regex -- -1 -. -7 +Cargo . -3 -/ -rust -- -bytes +toml " : " -64c7458020139bd7a03d1cb0927b741e6972377b686626563acb86fbc66414ca +0abdf3ce883520254d94a04dcf831fb6f0b75bfda7bcf9c8500ca9a2d1f8ff44 " " -record -/ -old -- -bench -- -log -/ -12 -- -regex -- -1 -. -8 +HACKING . -1 -/ -rust +md " : " -a538c42e77e20956e81fb5a4e2e1e7d3fdf60da019d7e3df52d93f57367a3fbd +17818f7a17723608f6bdbe6388ad0a913d4f96f76a16649aaf4e274b1fa0ea97 " " -record -/ -old -- -bench -- -log -/ -12 -- -regex -- -1 -. -8 -. -1 -/ -rust +LICENSE - -bytes +APACHE " : " -fbb00fdf8f039ce312f5346a67dddaa5e129280a93a90d7aaf6b5a9a71d2f212 +a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2 " " -record -/ -old -- -bench -- -log -/ -13 -- -regex +LICENSE - -1 -. -9 -. -0 -/ -rust +MIT " : " -0ef62700ba3fc24887af74b7942490c90b4cd2814b8fda200f7376e43391bfce +6485b8ed310d3f0340bf1ad1f47645069ce4069dcc6bb46c7d5c6faf41de1fdb " " -record -/ -old -- -bench -- -log -/ -13 -- -regex -- -1 +PERFORMANCE . -9 -. -0 -/ -rust -- -bytes +md " : " -676d501d4667f0a945c88ebb56839176dd3a5a6b45af7708b1e870bf26d12603 +0d5ef3866386918dfdefb1aa9a28cfe33cb3c8ceeb79f3f8ba5b88253dd95991 " " -record -/ -old -- -bench -- -log -/ README . md " : " -d359f536fb4b8c1af9af3465a027c3522f62c3871aad44645a955b650d7deec0 -" -" -record -/ -old -- -bench -- -log -/ -old -/ -01 -- -before -" -: -" -c2ea2750fca8ac1742003fe2106e9422d49e92967d3fe0267f24b7ec830b07e3 -" -" -record -/ -old -- -bench -- -log -/ -old -/ -02 -- -new -- -syntax -- -crate -" -: -" -27fd8b3d35cf08d434035ff7d9f2e9e3c94a167e45ba655567c73ae96830f1d8 -" -" -record -/ -old -- -bench -- -log -/ -old -/ -03 -- -new -- -syntax -- -crate -" -: -" -d942a2b95c3a2d8f85f3f17934f258bdc84baa33e91986e8a6810ca8d6e9cc50 -" -" -record -/ -old -- -bench -- -log -/ -old -/ -04 -- -fixed -- -benchmark -" -: -" -0da29ef39ac07ece411c151ab479a76944946aba992547b15d90ec2d5484e85c -" -" -record -/ -old -- -bench -- -log -/ -old -/ -05 -- -thread -- -caching -" -: -" -e364d87131e43187d6757426839789d1b6b47b3f3af21280daa9193d5ab19f64 +f69204a0f446047d8f4d1f3d84b75f235adb5c26477f3a37b671411bc954d14c " " -record -/ -old -- -bench -- -log -/ -old -/ -06 -- -major -- -dynamic +UNICODE +. +md " : " -3bc2b8fd2714ae9f19b2e4f4219654982522daf01b5d3055b4aec0458afeaf13 +a8a8399540eed000d19420135a527f400247a04572e44d124c786b870f518776 " " -record +examples / -old +regexdna - -bench -- -log -/ -old -/ -06 -- -major -- -macro +input +. +txt " : " -d5617ed23e71d5298ed4d629eee257e401c352fd1c91a2048dfeb1677527d4e7 +156a49710bb3e1ed4bc2bbb0af0f383b747b3d0281453cfff39c296124c598f8 " " -record -/ -old -- -bench -- -log -/ -old +examples / -07 +regexdna - -prefix -- -improvements +output +. +txt " : " -9277d1392c85a38db215a9b69e3b0cd4a9901f8f1c72c706ca262e5f099b8819 +35e85b19b70a893d752fd43e54e1e9da08bac43559191cea85b33387c24c4cc1 " " -record +examples / -old +shootout - -bench -- -log -/ -old -/ -08 +regex - -case +dna - -fixes +bytes +. +rs " : " -f97cd3675cf5c967e4ca8841f2368e9eadf538b542bfe3035d31492afc5934bf +fa2daedb4e0a05f64f33f4af62fbb0176db998e3676f8637ab684b725367a7b4 " " -record -/ -old -- -bench -- -log +examples / -old -/ -09 +shootout - -before +regex - -compiler +dna - -rewrite +cheat +. +rs " : " -b928686819dbd9aeaa6639b01b63a48428653f2f676a4e15d61cddec421e0389 +1f871a6eaaf8372299fa3c762051112fa89a14235b03f734fc50ebd51ecaee72 " " -record +examples / -old +shootout - -bench -- -log -/ -old -/ -10 +regex - -compiler +dna - -rewrite +replace +. +rs " : " -697b295ee377a5cb287d403593bfb8c078270b4e19e8d61d0b95b06ee7c903ab +32ffdf13ac6c4ce3fc32116a048e9cc682aa34cdb8e5beaf565a22addbdcd9ab " " -record -/ -old -- -bench -- -log +examples / -old -/ -11 -- -compiler +shootout - -rewrite -" -: -" -3f0ba494a0d82e7419285a9686474dc7763d4da0dd3faaa3bec3f624bbede481 -" -" -record -/ -old +regex - -bench +dna - -log -/ -old -/ -12 +single - -executor +cheat +. +rs " : " -962e182f9a1cfddb8c0cd2d8c4681febef1430082c9a38e5373c9117b853e65e +809f75bf1e1917a53623eb6f1a3ce3b7d2ed98a6a1dbc0bd4853bec49a0c6f94 " " -record +examples / -old -- -bench +shootout - -log -/ -old -/ -12 +regex - -executor +dna - -bytes +single +. +rs " : " -e01a1e878b44c80724e9bf09bb11210eeb8f01518ac7f0e3e7f2ee241281e500 +1ab14f5703cd4be2e75a2e792e0ba1d322b9e4b14535d396805a4316d577f5bb " " -record +examples / -old +shootout - -bench -- -log -/ -old -/ -13 -- -cache -- -byte -- -range +regex - -suffixes +dna +. +rs " : " -1d67d58a39f9177a79c26f3c6c2a1caaf51f085ce137711ab9ba74071c14680c +20ea46ab63f91e3ac6a64e997eadd436a9cbc2f1bdade28e4512052f0e25bc34 " " rustfmt @@ -1850,285 +225,275 @@ toml " src / -builders +backtrack . rs " : " -67b4f07ba91794c1e076d092a55f9377301ef5fa8f0dcef13699842583c14865 +52987d80448f3d7f5d4e3545ddfc09f1f30de7602d9b5489961db4b215a377fd " " src / -bytes +compile . rs " : " -6a576b7cec3bc120b9a444f9d12378ac3f4c4f6443e44e4befce6c9c356d8d78 +79a59be2d2db650b5a322e15e9bf1d3227944410bc780fc6089da8f4d2609b77 " " src / -error +dfa . rs " : " -4ac8361e900627a87a2ac78e5d475be17c455fe6850d1515bf5b874837c4ae25 +10273980d1f08aaff495e11efa240249a2b2c08a4db7c49c8d6759bc65a3b174 " " src / -find_byte +error . rs " : " -e17cd3b765467685946707840b92ea4e37d3c11081fbf316174a15858cd4bd99 +71c85db839514f26ee024a689061743ea94a34eb7a3291e6c2b69b45a9682d09 " " src / -lib +exec . rs " : " -93cb2a92745dd656b00746b45bdec726cf0cdb0016384ba25ca816b870ca83c8 +21495ab6813598204a444aeea3a0121674081389fd0f07fc3443eb8858b1c677 " " src / -pattern +expand . rs " : " -5f37755a7c16902d861377645f57a20314961f86298d4b35ae6e1058ca4e9801 +71220309a3bac797f55129f49e79c03e96efec894ea338c735b78695367e04ca " " src / -regex -/ -bytes +find_byte . rs " : " -a32de892ae0eb5a68c54a83b0540b1d595e8263b4efe9f521e4ac7cd0f2efa6d +b387247b77e3269f057c3399aefe5a815032c3af918c876f80eb4b282e4eb95e " " src / -regex -/ -mod +freqs . rs " : " -c220b6dd7a5e1945f8e743d1dcd796c5f782c91b0c34eb9915c588174a517fe8 +255555f3d95b08a5bb3bc2f38d5a06cc100a39c0f0127fe4f50c33afa1cadc65 " " src / -regex -/ -string +input . rs " : " -4f7fea1a54c099fe79769e1e97ab9d4e4c5a569c48dbcab6db2b35a597953a04 +13f49c1bce2fadd04a45b421d374cd0f8b72bef83f7e8fda958962aaccbe799a " " src / -regexset -/ -bytes +lib . rs " : " -6290dd81f47fb6cdbaa358be2340398a2a640320373d334e4c977bf30b5a9220 +982fadba415c4c5b93f4d7d4a73a23ec88e2d96daaa03b679d14490ea0f63197 " " src / -regexset +literal / -mod +imp . rs " : " -c220b6dd7a5e1945f8e743d1dcd796c5f782c91b0c34eb9915c588174a517fe8 +b7f63a861c299bea4baaab17353a420ee339c2cf76d3858c95f39342bd4463e7 " " src / -regexset +literal / -string +mod . rs " : " -977bc167c48c7c99187599c5071ca197e61a56359d32a26b9dbc1b58a5ef1c4d +533f1d68af088e9485170145e27518368e541a0337fdb44f63249ebf97310300 " " -test +src +/ +pattern +. +rs " : " -c0122c20a2c9b7ba6e9a8aaeb2b7d9910315ef31063539949f28d9501ef3193c +993d8b6b4bcea5e02bee3c76e17c356a5a47f8fc53c5555edfd1ebb71c0878bf " " -testdata +src / -README +pikevm . -md +rs " : " -c0514501526560d7f6171eb6d982ad61b4527760cb38a4bfbe8e28036ff37b95 +6c0eaa7e878c945ac4c3c545c98f5706ad04846fc432a5086c8ee78eb030dfa7 " " -testdata +src / -anchored +pool . -toml +rs " : " -7a1b5cd81deed2099796a451bf764a3f9bd21f0d60c0fa46accd3a35666866f2 +942e991ae31ef349bd76efd78b2a712c01166dec965bf93742977ed0870d5a10 " " -testdata +src / -bytes +prog . -toml +rs " : " -1d84179165fd25f3b94bd2bfbeb43fc8a162041f7bf98b717e0f85cef7fb652b +bebb3e50745bbc05d6c8240d972ba55a1818c51b1161dc1c21f3fe13c11d4884 " " -testdata +src / -crazy +re_builder . -toml +rs " : " -a146e2d2e23f1a57168979d9b1fc193c2ba38dca66294b61140d6d2a2958ec86 +943344bf6e2fc90902ee04b11b741c32418ac6814b21b7982cc0a3a817713f3e " " -testdata +src / -crlf +re_bytes . -toml +rs " : " -d19cf22756434d145dd20946c00af01c102a556a252070405c3c8294129d9ece +63ee1db1637a3764addb10e27248129acffaf78bb0a69624add4d9d6f1e97040 " " -testdata +src / -earliest +re_set . -toml +rs " : " -d561e643623ee1889b5b049fdcf3c7cb71b0c746d7eb822ddbd09d0acda2620b +7921ac4a919b7a5deffe82d099a9ccaf5487aebd890dfb7a661e602c6ad3f1a9 " " -testdata +src / -empty +re_trait . -toml +rs " : " -738dbe92fbd8971385a1cf3affb0e956e5b692c858b9b48439d718f10801c08e +d237121b6f6b606836c72305cbcb3bbdbc54d1f6827d19a19cd0fbb4372e0145 " " -testdata +src / -expensive +re_unicode . -toml +rs " : " -5ce2f60209c99cdd2cdcb9d3069d1d5ca13d5e08a85e913efe57267b2f5f0e9d +4ca66d6e835df7c0f570c8cde52667ef90ba1687d5285f12fedef2e38ae925b4 " " -testdata +src / -flags +sparse . -toml +rs " : " -9a7e001808195c84f2a7d3e18bc0a82c7386e60f03a616e99af00c3f7f2c3fd4 +0da3ddb7972109869248a764dbb10254555f4bb51c375e89fb3fab9cafa47320 " " -testdata +src / -fowler +testdata / -basic -. -toml +LICENSE " : " -a82c7e233451cd7cfe0c3d817f3a1ab44478bb81ae62432efdd515fa8370275e +58cf078acc03da3e280a938c2bd9943f554fc9b6ced89ad93ba35ca436872899 " " -testdata -/ -fowler +src / -dat +testdata / README " : " -e53d6c37b5931cb26dc9ae4c40358eea63f7a469c4db6ca816c072a8ced6a61a +45f869e37f798905c773bfbe0ef19a5fb7e585cbf0b7c21b5b5a784e8cec3c14 " " -testdata -/ -fowler +src / -dat +testdata / basic . @@ -2136,14 +501,12 @@ dat " : " -b1126dda59075c08f574987090273c9977790115f1e1941d0708c0b82b256905 +b5b33aa89d48a61cd67cb1fbfd8f70e62c83e30b86256f9f915a5190dd38ff06 " " -testdata -/ -fowler +src / -dat +testdata / nullsubexpr . @@ -2151,14 +514,12 @@ dat " : " -e5cd4145dffa8bc66f2d39079950b2bb7bae21a521514b83b557b92f4a871a9e +496ac0278eec3b6d9170faace14554569032dd3d909618364d9326156de39ecf " " -testdata -/ -fowler +src / -dat +testdata / repetition . @@ -2166,484 +527,399 @@ dat " : " -2b8b2b191229a804fba49e6b888d8194bf488f7744057b550da9d95a2aa6617a -" -" -testdata -/ -fowler -/ -nullsubexpr -. -toml -" -: -" -cd812e7e8fa0469253b34f0db93b5883c9d8b9740fc4f7825a38e7df880a4eed +1f7959063015b284b18a4a2c1c8b416d438a2d6c4b1a362da43406b865f50e69 " " -testdata -/ -fowler +src / -repetition +utf8 . -toml +rs " : " -8c09164f064b3db81309c53483863bdcec493781644de162416e9f485e772615 +f85a356ff5d5b19e417b73ce1dd84581b21d283f6dddd195547c30af9c60bd1a " " -testdata -/ -iter -. -toml +test " : " -6875460302974a5b3073a7304a865c45aba9653c54afea2c4d26e1ea248a81f7 +0d62fdca7da12fc19ea5306b5de1d83e68d9365a029c043d524334da138b0304 " " -testdata +tests / -leftmost -- -all +api . -toml +rs " : " -903bfbeff888b7664296f4d5aa367ce53d1dafe249ab0a3359223ae94d596396 +7b2a0ef75e99b9776094967bd66e9cdeaa8e11359f5f0a12bd08ef0e8d0c11fc " " -testdata +tests / -line -- -terminator +api_str . -toml +rs " : " -3255c305687eaa8b39939855ce8e0379bdc0e70d7b0cd818856f65fb44a48c0f +2ae38c04e7e8fac008b609a820d0b1561ba75f39b0edc0987d6d3d06132da77f " " -testdata +tests / -misc +bytes . -toml +rs " : " -32c9591655c6fb118dfefcb4de49a04820a63cb960533dfc2538cdaabf4f4047 +edc50f526c5fee43df89d639ef18b237e4eb91e9d533bfc43f3cbab7417d38ba " " -testdata +tests / -multiline +consistent . -toml +rs " : " -eb07cf5427e6ddbcf61f4cc64c2d74ff41b5ef75ef857959651b20196f3cd157 +d69435154c09478076497216e43081a835ac65147181a4fbddad7bff469605b2 " " -testdata +tests / -no -- -unicode +crates_regex . -toml +rs " : " -d209da04506900fd5f69e48170cddaad0702355ac6176c3a75ab3ff96974457c +91a59d470e0700b4bcb3ff735d06799f3107b8ef4875a2e9904607b164be0326 " " -testdata +tests / -overlapping +crazy . -toml +rs " : " -5d96497a7233566d40b05ba22047e483fa8662e45515a9be86da45cf6c28703a +c0d56380dff19bdd5d7a3eb731d0e2dc564e169a1b73c81e1879b1e87f5f5f77 " " -testdata +tests / -regex -- -lite +flags . -toml +rs " : " -fecca7cc8c9cea2e1f84f846a89fd9b3ca7011c83698211a2eeda8924deb900c +05caace2c81a99d2168037f3a38035d4dffe9f85ef3ebd7ef18b1bc6612f1ea8 " " -testdata +tests / -regression +fowler . -toml +rs " : " -6af7b4ac5eb257af52bcf9647f0f7ecb02e87ce5e57306825f2b5ac800151758 +d78cf914de40b1e125cc92b65ccb444d462586bd07b5e05de4e4a1b5de16aa76 " " -testdata +tests / -set +macros . -toml +rs " : " -dfd265dc1aee80026e881616840df0236ae9abf12467d7ec0e141a52c236128c +6db70c16fc90df13e6b30d2b606f8b6dd4dc976697967f6ee001b15aab6d0b19 " " -testdata +tests / -substring +macros_bytes . -toml +rs " : " -48122d9f3477ed81f95e3ad42c06e9bb25f849b66994601a75ceae0693b81866 +a049f528a93173a1bb176cd46932dce1880679f4a1752e099be920f0e4546fd0 " " -testdata +tests / -unicode +macros_str . -toml +rs " : " -7e4b013039b0cdd85fa73f32d15d096182fe901643d4e40c0910087a736cd46d +e585b1461374c45a2eca44ca045bc3c1fe984b2b4212e432b0c695b420e708b7 " " -testdata +tests / -utf8 +misc . -toml +rs " : " -2eabce0582bcacb2073e08bbe7ca413f096d14d06e917b107949691e24f84b20 +395f52793fa022e4cdda78675b6a6fba1a3106b4b99c834c39f7801574054bd1 " " -testdata +tests / -word -- -boundary +multiline . -toml +rs " : " -51bc1c498ab825420340a2dd3e6623de4054937ba6d5020ff8cd14b1c1e45271 +1b1a3326ed976437c1357f01d81833ece7ea244f38826246eab55cacd5d0862a " " tests / -fuzz -/ -mod +noparse . rs " : " -7b01a803e1c0b5a45c062d493723553f263c57e269eade1475eb789694635d5c +12b6be0eff3d80779d33c6459396c74c0f6ebf4ddc9f1d33c3e747ea9e3bf268 " " tests / -fuzz -/ -testdata -/ -crash -- -7eb3351f0965e5d6c1cb98aa8585949ef96531ff +regression +. +rs " : " -be4f42497ac9358eb020bf17cd8fdb9743691824e01d744504613ea2bfb2f663 +1c965fefb8c7a2b1dfdab3e3fdeebaf47846555c50c8005e5537f96a52a3e252 " " tests / -fuzz -/ -testdata -/ -crash -- -8760b19b25d74e3603d4c643e9c7404fdd3631f9 +regression_fuzz +. +rs " : " -19df9a1e1b5a3c0f31cc038b9f2991b161d8577b4a0c8b2fc391cdfecdb6dd85 +a504ec563e0d23bd2039493b7b1767fe1f831d7d668f6f4b2ecd124fc7899bcd " " tests / -fuzz -/ -testdata -/ -crash -- -cd33b13df59ea9d74503986f9d32a270dd43cc04 +replace +. +rs " : " -2fde1668e9e3e60943c28d97c01c90dd3d3882f48475f060ccaf961c228069e8 +66f97532e40697934e2a77605b9002dfd22c46b6033ccb755e7660d855229f41 " " tests / -fuzz -/ -testdata -/ -minimized -- -from -- -8760b19b25d74e3603d4c643e9c7404fdd3631f9 +searcher +. +rs " : " -c9e00f7a31453708560900aa51e358dd5551df494439860594be97bb1fb933ba +ce35e47b0a276a7e8c9060c6a0b225ffba163aebc61fbc15555a6897fa0e552c " " tests / -fuzz -/ -testdata -/ -slow -- -unit -- -3ab758ea520027fefd3f00e1384d9aeef155739e +set +. +rs " : " -4433011f7af46e855e843635cf24a49713bd5705f67176ed928f04d24eda1857 +f1e2af6baeeaed3cc99ed347ff516fe7b2eb0027ef64b891502e1486598eaf8a " " tests / -fuzz -/ -testdata -/ -slow -- -unit -- -5345fccadf3812c53c3ccc7af5aa2741b7b2106c +shortest_match +. +rs " : " -95782a847fc64e9cccdf76e9540b0d16ce80db5d05157a88b958b763f9b8479b +a2c94390c0d61bc24796b4c1288c924e90c8c9c6156fdebb858175177a194a42 " " tests / -fuzz -/ -testdata -/ -slow -- -unit -- -6bd643eec330166e4ada91da2d3f284268481085 +suffix_reverse +. +rs " : " -8ddff12288f6f20cc9d65db76bd8187834f64f844aad48a340d082555ad5cb56 +b95f89397404871227d9efe6df23b9ded147f183db81597e608f693955c668b5 " " tests / -fuzz -/ -testdata -/ -slow -- -unit -- -93c73a43581f205f9aaffd9c17e52b34b17becd0 +test_backtrack +. +rs " : " -eea6919a75fde163634b890e2253a0918cf0ba092357fa617f368bbfa131ba30 +b70c5e5f1241efd76dd9f9dd4a4df8a7b38113bd407d1f5f56867f1176177a59 " " tests / -fuzz -/ -testdata -/ -slow -- -unit -- -9ca9cc9929fee1fcbb847a78384effb8b98ea18a +test_backtrack_bytes +. +rs " : " -a806f73b900046977267acceb83b105bac7ee21ede2edc2927afe1e1f0149f00 +b8a111d4b4109c8bba7e2afb650572c495a14d357fb1f743c1076fb001f704b5 " " tests / -fuzz -/ -testdata -/ -slow -- -unit -- -b8a052f4254802edbe5f569b6ce6e9b6c927e9d6 +test_backtrack_utf8bytes +. +rs " : " -9540cf58241cde3bc0db8364e0ccff67ff1ff9721c85b0d2ca27354c0cbf2650 +c0c279785d18beac2b4e178e7bf6c14ed235d65f00ca467cfd9c333d79487649 " " tests / -lib +test_crates_regex . rs " : " -33a37711d8677994f87b19be40b24a323d41de18fb161c850b4ccea9fe4c4156 +fd9525c2eef0e2f8cb7f787bc2b721bcd0b5d84f3bca49adfe48d657a99c721a " " tests / -misc +test_default . rs " : " -5ac5858325451e1d70f308ca0bcead5a354d095a7473800c11065231c319c456 +c2dfa0298896f86f1be2abf6b0c347a7ca12f95aeac92bf614dc3b86bdfff269 " " tests / -regression +test_default_bytes . rs " : " -3490aac99fdbf3f0949ba1f338d5184a84b505ebd96d0b6d6145c610587aa60b +831d3e6bfb882feb15f700e30304bd34328f888fb4c15c7169371e25024ce9a7 " " tests / -regression_fuzz +test_nfa . rs " : " -57e0bcba0fdfa7797865e35ae547cd7fe1c6132b80a7bfdfb06eb053a568b00d +f119fc43a018249c39c813d57096b0654ff69f337345f2bbd9b0e61cc9137285 " " tests / -replace +test_nfa_bytes . rs " : " -78ff9bf7f78783ad83a78041bb7ee0705c7efc85b4d12301581d0ce5b2a59325 +89eae3bef6a1d0bcea6b5de5be35ad72f613f2ceb8b58fe82a6c6ef2ccdc07d0 " " tests / -searcher +test_nfa_utf8bytes . rs " : " -04152e5c86431deec0c196d2564a11bc4ec36f14c77e8c16a2f9d1cbc9fc574e +7d830b4aa401887d7cf098b62fed4cd8017ef8b61f625c7c9a2159a6b4cfeb71 " " tests / -suite_bytes +unicode . rs " : " -7697b04e5b181aa78b3654bd2dbe1c792d9626197573ed8c649f1da8b481817d +1af9db7f09a6b0113b8a64733e06c8415fef720b2fdef227ae398d94332287cd " " tests / -suite_bytes_set +word_boundary . rs " : " -d970168fab57a9edc60ff26a2bb7d0cc714d4298e4ee9eadba9da44a6569f2bb +7081317ddcec1e82dd4a2090a571c6abf2ff4bbfa8cd10395e1eb3f386157fae " " tests / -suite_string +word_boundary_ascii . rs " : " -1be0cf8922171f8323f99e8ecedbbf1846d339620d0dc2fd490901cbbbd2622e +cd0be5b5b485de0ba7994b42e2864585556c3d2d8bf5eab05b58931d9aaf4b87 " " tests / -suite_string_set +word_boundary_unicode . rs " : " -22743107206d913521f9adb728482aed3a9625ff7b15a83df057bbf1f7050e03 +75dbcc35d3abc0f9795c2ea99e216dc227b0a5b58e9ca5eef767815ff0513921 " } " @@ -2651,6 +927,6 @@ package " : " -12de2eff854e5fa4b1295edd650e227e9d8fb0c9e90b12e7f36d6a6811791a29 +48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733 " } diff --git a/third_party/rust/regex/CHANGELOG.md b/third_party/rust/regex/CHANGELOG.md index 771db8c70864b..b3705179b46a7 100644 --- a/third_party/rust/regex/CHANGELOG.md +++ b/third_party/rust/regex/CHANGELOG.md @@ -1,4238 +1,5 @@ 1 . -9 -. -4 -( -2023 -- -08 -- -26 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -patch -release -that -fixes -a -bug -where -RegexSet -: -: -is_match -( -. -. -) -could -incorrectly -return -false -( -even -when -RegexSet -: -: -matches -( -. -. -) -. -matched_any -( -) -returns -true -) -. -Bug -fixes -: -* -[ -BUG -# -1070 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1070 -) -: -Fix -a -bug -where -a -prefilter -was -incorrectly -configured -for -a -RegexSet -. -1 -. -9 -. -3 -( -2023 -- -08 -- -05 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -patch -release -that -fixes -a -bug -where -some -searches -could -result -in -incorrect -match -offsets -being -reported -. -It -is -difficult -to -characterize -the -types -of -regexes -susceptible -to -this -bug -. -They -generally -involve -patterns -that -contain -no -prefix -or -suffix -literals -but -have -an -inner -literal -along -with -a -regex -prefix -that -can -conditionally -match -. -Bug -fixes -: -* -[ -BUG -# -1060 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1060 -) -: -Fix -a -bug -with -the -reverse -inner -literal -optimization -reporting -incorrect -match -offsets -. -1 -. -9 -. -2 -( -2023 -- -08 -- -05 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -patch -release -that -fixes -another -memory -usage -regression -. -This -particular -regression -occurred -only -when -using -a -RegexSet -. -In -some -cases -much -more -heap -memory -( -by -one -or -two -orders -of -magnitude -) -was -allocated -than -in -versions -prior -to -1 -. -9 -. -0 -. -Bug -fixes -: -* -[ -BUG -# -1059 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1059 -) -: -Fix -a -memory -usage -regression -when -using -a -RegexSet -. -1 -. -9 -. -1 -( -2023 -- -07 -- -07 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -patch -release -which -fixes -a -memory -usage -regression -. -In -the -regex -1 -. -9 -release -one -of -the -internal -engines -used -a -more -aggressive -allocation -strategy -than -what -was -done -previously -. -This -patch -release -reverts -to -the -prior -on -- -demand -strategy -. -Bug -fixes -: -* -[ -BUG -# -1027 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1027 -) -: -Change -the -allocation -strategy -for -the -backtracker -to -be -less -aggressive -. -1 -. -9 -. -0 -( -2023 -- -07 -- -05 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -release -marks -the -end -of -a -[ -years -long -rewrite -of -the -regex -crate -internals -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -656 -) -. -Since -this -is -such -a -big -release -please -report -any -issues -or -regressions -you -find -. -We -would -also -love -to -hear -about -improvements -as -well -. -In -addition -to -many -internal -improvements -that -should -hopefully -result -in -" -my -regex -searches -are -faster -" -there -have -also -been -a -few -API -additions -: -* -A -new -Captures -: -: -extract -method -for -quickly -accessing -the -substrings -that -match -each -capture -group -in -a -regex -. -* -A -new -inline -flag -R -which -enables -CRLF -mode -. -This -makes -. -match -any -Unicode -scalar -value -except -for -\ -r -and -\ -n -and -also -makes -( -? -m -: -^ -) -and -( -? -m -: -) -match -after -and -before -both -\ -r -and -\ -n -respectively -but -never -between -a -\ -r -and -\ -n -. -* -RegexBuilder -: -: -line_terminator -was -added -to -further -customize -the -line -terminator -used -by -( -? -m -: -^ -) -and -( -? -m -: -) -to -be -any -arbitrary -byte -. -* -The -std -Cargo -feature -is -now -actually -optional -. -That -is -the -regex -crate -can -be -used -without -the -standard -library -. -* -Because -regex -1 -. -9 -may -make -binary -size -and -compile -times -even -worse -a -new -experimental -crate -called -regex -- -lite -has -been -published -. -It -prioritizes -binary -size -and -compile -times -over -functionality -( -like -Unicode -) -and -performance -. -It -shares -no -code -with -the -regex -crate -. -New -features -: -* -[ -FEATURE -# -244 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -244 -) -: -One -can -opt -into -CRLF -mode -via -the -R -flag -. -e -. -g -. -( -? -mR -: -) -matches -just -before -\ -r -\ -n -. -* -[ -FEATURE -# -259 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -259 -) -: -Multi -- -pattern -searches -with -offsets -can -be -done -with -regex -- -automata -0 -. -3 -. -* -[ -FEATURE -# -476 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -476 -) -: -std -is -now -an -optional -feature -. -regex -may -be -used -with -only -alloc -. -* -[ -FEATURE -# -644 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -644 -) -: -RegexBuilder -: -: -line_terminator -configures -how -( -? -m -: -^ -) -and -( -? -m -: -) -behave -. -* -[ -FEATURE -# -675 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -675 -) -: -Anchored -search -APIs -are -now -available -in -regex -- -automata -0 -. -3 -. -* -[ -FEATURE -# -824 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -824 -) -: -Add -new -Captures -: -: -extract -method -for -easier -capture -group -access -. -* -[ -FEATURE -# -961 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -961 -) -: -Add -regex -- -lite -crate -with -smaller -binary -sizes -and -faster -compile -times -. -* -[ -FEATURE -# -1022 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -pull -/ -1022 -) -: -Add -TryFrom -implementations -for -the -Regex -type -. -Performance -improvements -: -* -[ -PERF -# -68 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -68 -) -: -Added -a -one -- -pass -DFA -engine -for -faster -capture -group -matching -. -* -[ -PERF -# -510 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -510 -) -: -Inner -literals -are -now -used -to -accelerate -searches -e -. -g -. -\ -w -+ -\ -w -+ -will -scan -for -. -* -[ -PERF -# -787 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -787 -) -[ -PERF -# -891 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -891 -) -: -Makes -literal -optimizations -apply -to -regexes -of -the -form -\ -b -( -foo -| -bar -| -quux -) -\ -b -. -( -There -are -many -more -performance -improvements -as -well -but -not -all -of -them -have -specific -issues -devoted -to -them -. -) -Bug -fixes -: -* -[ -BUG -# -429 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -) -: -Fix -matching -bugs -related -to -\ -B -and -inconsistencies -across -internal -engines -. -* -[ -BUG -# -517 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -517 -) -: -Fix -matching -bug -with -capture -groups -. -* -[ -BUG -# -579 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -579 -) -: -Fix -matching -bug -with -word -boundaries -. -* -[ -BUG -# -779 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -779 -) -: -Fix -bug -where -some -regexes -like -( -re -) -+ -were -not -equivalent -to -( -re -) -( -re -) -* -. -* -[ -BUG -# -850 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -850 -) -: -Fix -matching -bug -inconsistency -between -NFA -and -DFA -engines -. -* -[ -BUG -# -921 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -921 -) -: -Fix -matching -bug -where -literal -extraction -got -confused -by -. -* -[ -BUG -# -976 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -976 -) -: -Add -documentation -to -replacement -routines -about -dealing -with -fallibility -. -* -[ -BUG -# -1002 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1002 -) -: -Use -corpus -rejection -in -fuzz -testing -. -1 -. -8 -. -4 -( -2023 -- -06 -- -05 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -patch -release -that -fixes -a -bug -where -( -? -- -u -: -\ -B -) -was -allowed -in -Unicode -regexes -despite -the -fact -that -the -current -matching -engines -can -report -match -offsets -between -the -code -units -of -a -single -UTF -- -8 -encoded -codepoint -. -That -in -turn -means -that -match -offsets -that -split -a -codepoint -could -be -reported -which -in -turn -results -in -panicking -when -one -uses -them -to -slice -a -& -str -. -This -bug -occurred -in -the -transition -to -regex -1 -. -8 -because -the -underlying -syntactical -error -that -prevented -this -regex -from -compiling -was -intentionally -removed -. -That -' -s -because -( -? -- -u -: -\ -B -) -will -be -permitted -in -Unicode -regexes -in -regex -1 -. -9 -but -the -matching -engines -will -guarantee -to -never -report -match -offsets -that -split -a -codepoint -. -When -the -underlying -syntactical -error -was -removed -no -code -was -added -to -ensure -that -( -? -- -u -: -\ -B -) -didn -' -t -compile -in -the -regex -1 -. -8 -transition -release -. -This -release -regex -1 -. -8 -. -4 -adds -that -code -such -that -Regex -: -: -new -( -r -" -( -? -- -u -: -\ -B -) -" -) -returns -to -the -regex -< -1 -. -8 -behavior -of -not -compiling -. -( -A -bytes -: -: -Regex -can -still -of -course -compile -it -. -) -Bug -fixes -: -* -[ -BUG -# -1006 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1006 -) -: -Fix -a -bug -where -( -? -- -u -: -\ -B -) -was -allowed -in -Unicode -regexes -and -in -turn -could -lead -to -match -offsets -that -split -a -codepoint -in -& -str -. -1 -. -8 -. -3 -( -2023 -- -05 -- -25 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -patch -release -that -fixes -a -bug -where -the -regex -would -report -a -match -at -every -position -even -when -it -shouldn -' -t -. -This -could -occur -in -a -very -small -subset -of -regexes -usually -an -alternation -of -simple -literals -that -have -particular -properties -. -( -See -the -issue -linked -below -for -a -more -precise -description -. -) -Bug -fixes -: -* -[ -BUG -# -999 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -999 -) -: -Fix -a -bug -where -a -match -at -every -position -is -erroneously -reported -. -1 -. -8 -. -2 -( -2023 -- -05 -- -22 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -patch -release -that -fixes -a -bug -where -regex -compilation -could -panic -in -debug -mode -for -regexes -with -large -counted -repetitions -. -For -example -a -{ -2147483516 -} -{ -2147483416 -} -{ -5 -} -resulted -in -an -integer -overflow -that -wrapped -in -release -mode -but -panicking -in -debug -mode -. -Despite -the -unintended -wrapping -arithmetic -in -release -mode -it -didn -' -t -cause -any -other -logical -bugs -since -the -errant -code -was -for -new -analysis -that -wasn -' -t -used -yet -. -Bug -fixes -: -* -[ -BUG -# -995 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -995 -) -: -Fix -a -bug -where -regex -compilation -with -large -counted -repetitions -could -panic -. -1 -. -8 -. -1 -( -2023 -- -04 -- -21 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -patch -release -that -fixes -a -bug -where -a -regex -match -could -be -reported -where -none -was -found -. -Specifically -the -bug -occurs -when -a -pattern -contains -some -literal -prefixes -that -could -be -extracted -_and_ -an -optional -word -boundary -in -the -prefix -. -Bug -fixes -: -* -[ -BUG -# -981 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -981 -) -: -Fix -a -bug -where -a -word -boundary -could -interact -with -prefix -literal -optimizations -and -lead -to -a -false -positive -match -. -1 -. -8 -. -0 -( -2023 -- -04 -- -20 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -sizeable -release -that -will -be -soon -followed -by -another -sizeable -release -. -Both -of -them -will -combined -close -over -40 -existing -issues -and -PRs -. -This -first -release -despite -its -size -essentially -represents -preparatory -work -for -the -second -release -which -will -be -even -bigger -. -Namely -this -release -: -* -Increases -the -MSRV -to -Rust -1 -. -60 -. -0 -which -was -released -about -1 -year -ago -. -* -Upgrades -its -dependency -on -aho -- -corasick -to -the -recently -released -1 -. -0 -version -. -* -Upgrades -its -dependency -on -regex -- -syntax -to -the -simultaneously -released -0 -. -7 -version -. -The -changes -to -regex -- -syntax -principally -revolve -around -a -rewrite -of -its -literal -extraction -code -and -a -number -of -simplifications -and -optimizations -to -its -high -- -level -intermediate -representation -( -HIR -) -. -The -second -release -which -will -follow -~ -shortly -after -the -release -above -will -contain -a -soup -- -to -- -nuts -rewrite -of -every -regex -engine -. -This -will -be -done -by -bringing -[ -regex -- -automata -] -( -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -regex -- -automata -) -into -this -repository -and -then -changing -the -regex -crate -to -be -nothing -but -an -API -shim -layer -on -top -of -regex -- -automata -' -s -API -. -These -tandem -releases -are -the -culmination -of -about -3 -years -of -on -- -and -- -off -work -that -[ -began -in -earnest -in -March -2020 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -656 -) -. -Because -of -the -scale -of -changes -involved -in -these -releases -I -would -love -to -hear -about -your -experience -. -Especially -if -you -notice -undocumented -changes -in -behavior -or -performance -changes -( -positive -* -or -* -negative -) -. -Most -changes -in -the -first -release -are -listed -below -. -For -more -details -please -see -the -commit -log -which -reflects -a -linear -and -decently -documented -history -of -all -changes -. -New -features -: -* -[ -FEATURE -# -501 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -501 -) -: -Permit -many -more -characters -to -be -escaped -even -if -they -have -no -significance -. -More -specifically -any -ASCII -character -except -for -[ -0 -- -9A -- -Za -- -z -< -> -] -can -now -be -escaped -. -Also -a -new -routine -is_escapeable_character -has -been -added -to -regex -- -syntax -to -query -whether -a -character -is -escapeable -or -not -. -* -[ -FEATURE -# -547 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -547 -) -: -Add -Regex -: -: -captures_at -. -This -fills -a -hole -in -the -API -but -doesn -' -t -otherwise -introduce -any -new -expressive -power -. -* -[ -FEATURE -# -595 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -595 -) -: -Capture -group -names -are -now -Unicode -- -aware -. -They -can -now -begin -with -either -a -_ -or -any -" -alphabetic -" -codepoint -. -After -the -first -codepoint -subsequent -codepoints -can -be -any -sequence -of -alpha -- -numeric -codepoints -along -with -_ -. -[ -and -] -. -Note -that -replacement -syntax -has -not -changed -. -* -[ -FEATURE -# -810 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -810 -) -: -Add -Match -: -: -is_empty -and -Match -: -: -len -APIs -. -* -[ -FEATURE -# -905 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -905 -) -: -Add -an -impl -Default -for -RegexSet -with -the -default -being -the -empty -set -. -* -[ -FEATURE -# -908 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -908 -) -: -A -new -method -Regex -: -: -static_captures_len -has -been -added -which -returns -the -number -of -capture -groups -in -the -pattern -if -and -only -if -every -possible -match -always -contains -the -same -number -of -matching -groups -. -* -[ -FEATURE -# -955 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -955 -) -: -Named -captures -can -now -be -written -as -( -? -< -name -> -re -) -in -addition -to -( -? -P -< -name -> -re -) -. -* -FEATURE -: -regex -- -syntax -now -supports -empty -character -classes -. -* -FEATURE -: -regex -- -syntax -now -has -an -optional -std -feature -. -( -This -will -come -to -regex -in -the -second -release -. -) -* -FEATURE -: -The -Hir -type -in -regex -- -syntax -has -had -a -number -of -simplifications -made -to -it -. -* -FEATURE -: -regex -- -syntax -has -support -for -a -new -R -flag -for -enabling -CRLF -mode -. -This -will -be -supported -in -regex -proper -in -the -second -release -. -* -FEATURE -: -regex -- -syntax -now -has -proper -support -for -" -regex -that -never -matches -" -via -Hir -: -: -fail -( -) -. -* -FEATURE -: -The -hir -: -: -literal -module -of -regex -- -syntax -has -been -completely -re -- -worked -. -It -now -has -more -documentation -examples -and -advice -. -* -FEATURE -: -The -allow_invalid_utf8 -option -in -regex -- -syntax -has -been -renamed -to -utf8 -and -the -meaning -of -the -boolean -has -been -flipped -. -Performance -improvements -: -* -PERF -: -The -upgrade -to -aho -- -corasick -1 -. -0 -may -improve -performance -in -some -cases -. -It -' -s -difficult -to -characterize -exactly -which -patterns -this -might -impact -but -if -there -are -a -small -number -of -longish -( -> -= -4 -bytes -) -prefix -literals -then -it -might -be -faster -than -before -. -Bug -fixes -: -* -[ -BUG -# -514 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -514 -) -: -Improve -Debug -impl -for -Match -so -that -it -doesn -' -t -show -the -entire -haystack -. -* -BUGS -[ -# -516 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -516 -) -[ -# -731 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -731 -) -: -Fix -a -number -of -issues -with -printing -Hir -values -as -regex -patterns -. -* -[ -BUG -# -610 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -610 -) -: -Add -explicit -example -of -foo -| -bar -in -the -regex -syntax -docs -. -* -[ -BUG -# -625 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -625 -) -: -Clarify -that -SetMatches -: -: -len -does -not -( -regretably -) -refer -to -the -number -of -matches -in -the -set -. -* -[ -BUG -# -660 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -660 -) -: -Clarify -" -verbose -mode -" -in -regex -syntax -documentation -. -* -BUG -[ -# -738 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -738 -) -[ -# -950 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -950 -) -: -Fix -CaptureLocations -: -: -get -so -that -it -never -panics -. -* -[ -BUG -# -747 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -747 -) -: -Clarify -documentation -for -Regex -: -: -shortest_match -. -* -[ -BUG -# -835 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -835 -) -: -Fix -\ -p -{ -Sc -} -so -that -it -is -equivalent -to -\ -p -{ -Currency_Symbol -} -. -* -[ -BUG -# -846 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -846 -) -: -Add -more -clarifying -documentation -to -the -CompiledTooBig -error -variant -. -* -[ -BUG -# -854 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -854 -) -: -Clarify -that -regex -: -: -Regex -searches -as -if -the -haystack -is -a -sequence -of -Unicode -scalar -values -. -* -[ -BUG -# -884 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -884 -) -: -Replace -__Nonexhaustive -variants -with -# -[ -non_exhaustive -] -attribute -. -* -[ -BUG -# -893 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -pull -/ -893 -) -: -Optimize -case -folding -since -it -can -get -quite -slow -in -some -pathological -cases -. -* -[ -BUG -# -895 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -895 -) -: -Reject -( -? -- -u -: -\ -W -) -in -regex -: -: -Regex -APIs -. -* -[ -BUG -# -942 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -942 -) -: -Add -a -missing -void -keyword -to -indicate -" -no -parameters -" -in -C -API -. -* -[ -BUG -# -965 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -965 -) -: -Fix -\ -p -{ -Lc -} -so -that -it -is -equivalent -to -\ -p -{ -Cased_Letter -} -. -* -[ -BUG -# -975 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -975 -) -: -Clarify -documentation -for -\ -pX -syntax -. -1 -. -7 -. -3 -( -2023 -- -03 -- -24 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -small -release -that -fixes -a -bug -in -Regex -: -: -shortest_match_at -that -could -cause -it -to -panic -even -when -the -offset -given -is -valid -. -Bug -fixes -: -* -[ -BUG -# -969 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -969 -) -: -Fix -a -bug -in -how -the -reverse -DFA -was -called -for -Regex -: -: -shortest_match_at -. -1 -. -7 -. -2 -( -2023 -- -03 -- -21 -) -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -= -This -is -a -small -release -that -fixes -a -failing -test -on -FreeBSD -. -Bug -fixes -: -* -[ -BUG -# -967 -] -( -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -967 -) -: -Fix -" -no -stack -overflow -" -test -which -can -fail -due -to -the -small -stack -size -. -1 -. 7 . 1 @@ -11909,7 +7676,6 @@ over a year . -731 New features : diff --git a/third_party/rust/regex/Cargo.lock b/third_party/rust/regex/Cargo.lock new file mode 100644 index 0000000000000..c1f9abc412b07 --- /dev/null +++ b/third_party/rust/regex/Cargo.lock @@ -0,0 +1,638 @@ +# +This +file +is +automatically +generated +by +Cargo +. +# +It +is +not +intended +for +manual +editing +. +version += +3 +[ +[ +package +] +] +name += +" +aho +- +corasick +" +version += +" +0 +. +7 +. +20 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac +" +dependencies += +[ +" +memchr +" +] +[ +[ +package +] +] +name += +" +cfg +- +if +" +version += +" +1 +. +0 +. +0 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd +" +[ +[ +package +] +] +name += +" +getrandom +" +version += +" +0 +. +2 +. +8 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31 +" +dependencies += +[ +" +cfg +- +if +" +" +libc +" +" +wasi +" +] +[ +[ +package +] +] +name += +" +lazy_static +" +version += +" +1 +. +4 +. +0 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646 +" +[ +[ +package +] +] +name += +" +libc +" +version += +" +0 +. +2 +. +139 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79 +" +[ +[ +package +] +] +name += +" +memchr +" +version += +" +2 +. +5 +. +0 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d +" +[ +[ +package +] +] +name += +" +quickcheck +" +version += +" +1 +. +0 +. +3 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +588f6378e4dd99458b60ec275b4477add41ce4fa9f64dcba6f15adccb19b50d6 +" +dependencies += +[ +" +rand +" +] +[ +[ +package +] +] +name += +" +rand +" +version += +" +0 +. +8 +. +5 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404 +" +dependencies += +[ +" +rand_core +" +] +[ +[ +package +] +] +name += +" +rand_core +" +version += +" +0 +. +6 +. +4 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c +" +dependencies += +[ +" +getrandom +" +] +[ +[ +package +] +] +name += +" +regex +" +version += +" +1 +. +7 +. +1 +" +dependencies += +[ +" +aho +- +corasick +" +" +lazy_static +" +" +memchr +" +" +quickcheck +" +" +rand +" +" +regex +- +syntax +" +] +[ +[ +package +] +] +name += +" +regex +- +syntax +" +version += +" +0 +. +6 +. +28 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848 +" +[ +[ +package +] +] +name += +" +wasi +" +version += +" +0 +. +11 +. +0 ++ +wasi +- +snapshot +- +preview1 +" +source += +" +registry ++ +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +crates +. +io +- +index +" +checksum += +" +9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423 +" diff --git a/third_party/rust/regex/Cargo.toml b/third_party/rust/regex/Cargo.toml index 65cc204ab1e89..8daa9a1e04642 100644 --- a/third_party/rust/regex/Cargo.toml +++ b/third_party/rust/regex/Cargo.toml @@ -100,18 +100,7 @@ package edition = " -2021 -" -rust -- -version -= -" -1 -. -60 -. -0 +2018 " name = @@ -123,9 +112,9 @@ version " 1 . -9 +7 . -4 +1 " authors = @@ -136,16 +125,6 @@ Rust Project Developers " -" -Andrew -Gallant -< -jamslam -gmail -. -com -> -" ] exclude = @@ -272,75 +251,57 @@ lang regex " [ -package -. -metadata -. -docs +profile . -rs +bench ] -all -- -features +debug = true -rustdoc -- -args -= -[ -" -- -- -cfg -" -" -docsrs -" -] [ profile . -bench +release ] debug = -2 +true [ profile . -dev +test ] -opt -- -level -= -3 debug = -2 +true [ -profile -. -release +lib ] -debug +doctest = -2 +false +bench += +false +[ [ -profile -. test ] -opt -- -level +] +name = -3 -debug +" +default +" +path = -2 +" +tests +/ +test_default +. +rs +" [ [ test @@ -349,98 +310,168 @@ test name = " -integration +default +- +bytes " path = " tests / -lib +test_default_bytes . rs " [ -dependencies -. -aho -- -corasick +[ +test ] -version +] +name = " -1 -. -0 -. -0 +nfa " -optional +path = -true -[ -dependencies +" +tests +/ +test_nfa . -memchr +rs +" +[ +[ +test ] -version +] +name = " -2 -. -5 -. -0 +nfa +- +utf8bytes " -optional +path = -true -[ -dependencies +" +tests +/ +test_nfa_utf8bytes . -regex -- -automata +rs +" +[ +[ +test ] -version +] +name = " -0 -. -3 -. -7 +nfa +- +bytes " -features +path = +" +tests +/ +test_nfa_bytes +. +rs +" +[ [ +test +] +] +name += " -alloc +backtrack " +path += " -syntax +tests +/ +test_backtrack +. +rs " +[ +[ +test +] +] +name += " -meta +backtrack +- +utf8bytes " +path += " -nfa +tests +/ +test_backtrack_utf8bytes +. +rs +" +[ +[ +test +] +] +name += +" +backtrack - -pikevm +bytes +" +path += +" +tests +/ +test_backtrack_bytes +. +rs " +[ +[ +test ] -default +] +name += +" +crates - -features +regex +" +path = -false +" +tests +/ +test_crates_regex +. +rs +" [ dependencies . -regex +aho - -syntax +corasick ] version = @@ -449,74 +480,44 @@ version . 7 . -5 +18 " -default -- -features +optional = -false +true [ -dev -- dependencies . -anyhow +memchr ] version = " -1 -. -0 +2 . -69 -" -[ -dev -- -dependencies +4 . -doc -- -comment -] -version -= -" 0 -. -3 " +optional += +true [ -dev -- dependencies . -env_logger +regex +- +syntax ] version = " 0 . -9 +6 . -3 -" -features -= -[ -" -atty +27 " -" -humantime -" -" -termcolor -" -] default - features @@ -527,16 +528,12 @@ dev - dependencies . -once_cell +lazy_static ] version = " 1 -. -17 -. -1 " [ dev @@ -564,19 +561,32 @@ dev - dependencies . -regex -- -test +rand ] version = " 0 . -1 +8 . -0 +3 " +features += +[ +" +getrandom +" +" +small_rng +" +] +default +- +features += +false [ features ] @@ -600,25 +610,6 @@ syntax default " ] -logging -= -[ -" -aho -- -corasick -? -/ -logging -" -" -regex -- -automata -/ -logging -" -] pattern = [ @@ -639,16 +630,6 @@ dfa " perf - -onepass -" -" -perf -- -backtrack -" -" -perf -- inline " " @@ -659,21 +640,6 @@ literal ] perf - -backtrack -= -[ -" -regex -- -automata -/ -nfa -- -backtrack -" -] -perf -- cache = [ @@ -683,54 +649,12 @@ perf dfa = [ -" -regex -- -automata -/ -hybrid -" -] -perf -- -dfa -- -full -= -[ -" -regex -- -automata -/ -dfa -- -build -" -" -regex -- -automata -/ -dfa -- -search -" ] perf - inline = [ -" -regex -- -automata -/ -perf -- -inline -" ] perf - @@ -738,73 +662,17 @@ literal = [ " -dep -: aho - corasick " " -dep -: memchr " -" -regex -- -automata -/ -perf -- -literal -" -] -perf -- -onepass -= -[ -" -regex -- -automata -/ -dfa -- -onepass -" ] std = [ -" -aho -- -corasick -? -/ -std -" -" -memchr -? -/ -std -" -" -regex -- -automata -/ -std -" -" -regex -- -syntax -/ -std -" ] unicode = @@ -847,13 +715,6 @@ segment " regex - -automata -/ -unicode -" -" -regex -- syntax / unicode @@ -867,15 +728,6 @@ age " regex - -automata -/ -unicode -- -age -" -" -regex -- syntax / unicode @@ -891,15 +743,6 @@ bool " regex - -automata -/ -unicode -- -bool -" -" -regex -- syntax / unicode @@ -915,15 +758,6 @@ case " regex - -automata -/ -unicode -- -case -" -" -regex -- syntax / unicode @@ -939,15 +773,6 @@ gencat " regex - -automata -/ -unicode -- -gencat -" -" -regex -- syntax / unicode @@ -963,26 +788,6 @@ perl " regex - -automata -/ -unicode -- -perl -" -" -regex -- -automata -/ -unicode -- -word -- -boundary -" -" -regex -- syntax / unicode @@ -998,15 +803,6 @@ script " regex - -automata -/ -unicode -- -script -" -" -regex -- syntax / unicode @@ -1022,15 +818,6 @@ segment " regex - -automata -/ -unicode -- -segment -" -" -regex -- syntax / unicode diff --git a/third_party/rust/regex/Cross.toml b/third_party/rust/regex/Cross.toml deleted file mode 100644 index f6aa52335b908..0000000000000 --- a/third_party/rust/regex/Cross.toml +++ /dev/null @@ -1,21 +0,0 @@ -[ -build -. -env -] -passthrough -= -[ -" -RUST_BACKTRACE -" -" -RUST_LOG -" -" -REGEX_TEST -" -" -REGEX_TEST_VERBOSE -" -] diff --git a/third_party/rust/regex/PERFORMANCE.md b/third_party/rust/regex/PERFORMANCE.md new file mode 100644 index 0000000000000..75f610733bfb8 --- /dev/null +++ b/third_party/rust/regex/PERFORMANCE.md @@ -0,0 +1,2732 @@ +Your +friendly +guide +to +understanding +the +performance +characteristics +of +this +crate +. +This +guide +assumes +some +familiarity +with +the +public +API +of +this +crate +which +can +be +found +here +: +https +: +/ +/ +docs +. +rs +/ +regex +# +# +Theory +vs +. +Practice +One +of +the +design +goals +of +this +crate +is +to +provide +worst +case +linear +time +behavior +with +respect +to +the +text +searched +using +finite +state +automata +. +This +means +that +* +in +theory +* +the +performance +of +this +crate +is +much +better +than +most +regex +implementations +which +typically +use +backtracking +which +has +worst +case +exponential +time +. +For +example +try +opening +a +Python +interpreter +and +typing +this +: +> +> +> +import +re +> +> +> +re +. +search +( +' +( +a +* +) +* +c +' +' +a +' +* +30 +) +. +span +( +) +I +' +ll +wait +. +At +some +point +you +' +ll +figure +out +that +it +won +' +t +terminate +any +time +soon +. +^ +C +it +. +The +promise +of +this +crate +is +that +* +this +pathological +behavior +can +' +t +happen +* +. +With +that +said +just +because +we +have +protected +ourselves +against +worst +case +exponential +behavior +doesn +' +t +mean +we +are +immune +from +large +constant +factors +or +places +where +the +current +regex +engine +isn +' +t +quite +optimal +. +This +guide +will +detail +those +cases +and +provide +guidance +on +how +to +avoid +them +among +other +bits +of +general +advice +. +# +# +Thou +Shalt +Not +Compile +Regular +Expressions +In +A +Loop +* +* +Advice +* +* +: +Use +lazy_static +to +amortize +the +cost +of +Regex +compilation +. +Don +' +t +do +it +unless +you +really +don +' +t +mind +paying +for +it +. +Compiling +a +regular +expression +in +this +crate +is +quite +expensive +. +It +is +conceivable +that +it +may +get +faster +some +day +but +I +wouldn +' +t +hold +out +hope +for +say +an +order +of +magnitude +improvement +. +In +particular +compilation +can +take +any +where +from +a +few +dozen +microseconds +to +a +few +dozen +milliseconds +. +Yes +milliseconds +. +Unicode +character +classes +in +particular +have +the +largest +impact +on +compilation +performance +. +At +the +time +of +writing +for +example +\ +pL +{ +100 +} +takes +around +44ms +to +compile +. +This +is +because +\ +pL +corresponds +to +every +letter +in +Unicode +and +compilation +must +turn +it +into +a +proper +automaton +that +decodes +a +subset +of +UTF +- +8 +which +corresponds +to +those +letters +. +Compilation +also +spends +some +cycles +shrinking +the +size +of +the +automaton +. +This +means +that +in +order +to +realize +efficient +regex +matching +one +must +* +amortize +the +cost +of +compilation +* +. +Trivially +if +a +call +to +is_match +is +inside +a +loop +then +make +sure +your +call +to +Regex +: +: +new +is +* +outside +* +that +loop +. +In +many +programming +languages +regular +expressions +can +be +conveniently +defined +and +compiled +in +a +global +scope +and +code +can +reach +out +and +use +them +as +if +they +were +global +static +variables +. +In +Rust +there +is +really +no +concept +of +life +- +before +- +main +and +therefore +one +cannot +utter +this +: +static +MY_REGEX +: +Regex += +Regex +: +: +new +( +" +. +. +. +" +) +. +unwrap +( +) +; +Unfortunately +this +would +seem +to +imply +that +one +must +pass +Regex +objects +around +to +everywhere +they +are +used +which +can +be +especially +painful +depending +on +how +your +program +is +structured +. +Thankfully +the +[ +lazy_static +] +( +https +: +/ +/ +crates +. +io +/ +crates +/ +lazy_static +) +crate +provides +an +answer +that +works +well +: +use +lazy_static +: +: +lazy_static +; +use +regex +: +: +Regex +; +fn +some_helper_function +( +text +: +& +str +) +- +> +bool +{ +lazy_static +! +{ +static +ref +MY_REGEX +: +Regex += +Regex +: +: +new +( +" +. +. +. +" +) +. +unwrap +( +) +; +} +MY_REGEX +. +is_match +( +text +) +} +In +other +words +the +lazy_static +! +macro +enables +us +to +define +a +Regex +* +as +if +* +it +were +a +global +static +value +. +What +is +actually +happening +under +the +covers +is +that +the +code +inside +the +macro +( +i +. +e +. +Regex +: +: +new +( +. +. +. +) +) +is +run +on +* +first +use +* +of +MY_REGEX +via +a +Deref +impl +. +The +implementation +is +admittedly +magical +but +it +' +s +self +contained +and +everything +works +exactly +as +you +expect +. +In +particular +MY_REGEX +can +be +used +from +multiple +threads +without +wrapping +it +in +an +Arc +or +a +Mutex +. +On +that +note +. +. +. +# +# +Using +a +regex +from +multiple +threads +* +* +Advice +* +* +: +The +performance +impact +from +using +a +Regex +from +multiple +threads +is +likely +negligible +. +If +necessary +clone +the +Regex +so +that +each +thread +gets +its +own +copy +. +Cloning +a +regex +does +not +incur +any +additional +memory +overhead +than +what +would +be +used +by +using +a +Regex +from +multiple +threads +simultaneously +. +* +Its +only +cost +is +ergonomics +. +* +It +is +supported +and +encouraged +to +define +your +regexes +using +lazy_static +! +as +if +they +were +global +static +values +and +then +use +them +to +search +text +from +multiple +threads +simultaneously +. +One +might +imagine +that +this +is +possible +because +a +Regex +represents +a +* +compiled +* +program +so +that +any +allocation +or +mutation +is +already +done +and +is +therefore +read +- +only +. +Unfortunately +this +is +not +true +. +Each +type +of +search +strategy +in +this +crate +requires +some +kind +of +mutable +scratch +space +to +use +* +during +search +* +. +For +example +when +executing +a +DFA +its +states +are +computed +lazily +and +reused +on +subsequent +searches +. +Those +states +go +into +that +mutable +scratch +space +. +The +mutable +scratch +space +is +an +implementation +detail +and +in +general +its +mutation +should +not +be +observable +from +users +of +this +crate +. +Therefore +it +uses +interior +mutability +. +This +implies +that +Regex +can +either +only +be +used +from +one +thread +or +it +must +do +some +sort +of +synchronization +. +Either +choice +is +reasonable +but +this +crate +chooses +the +latter +in +particular +because +it +is +ergonomic +and +makes +use +with +lazy_static +! +straight +forward +. +Synchronization +implies +* +some +* +amount +of +overhead +. +When +a +Regex +is +used +from +a +single +thread +this +overhead +is +negligible +. +When +a +Regex +is +used +from +multiple +threads +simultaneously +it +is +possible +for +the +overhead +of +synchronization +from +contention +to +impact +performance +. +The +specific +cases +where +contention +may +happen +is +if +you +are +calling +any +of +these +methods +repeatedly +from +multiple +threads +simultaneously +: +* +shortest_match +* +is_match +* +find +* +captures +In +particular +every +invocation +of +one +of +these +methods +must +synchronize +with +other +threads +to +retrieve +its +mutable +scratch +space +before +searching +can +start +. +If +however +you +are +using +one +of +these +methods +: +* +find_iter +* +captures_iter +Then +you +may +not +suffer +from +contention +since +the +cost +of +synchronization +is +amortized +on +* +construction +of +the +iterator +* +. +That +is +the +mutable +scratch +space +is +obtained +when +the +iterator +is +created +and +retained +throughout +its +lifetime +. +# +# +Only +ask +for +what +you +need +* +* +Advice +* +* +: +Prefer +in +this +order +: +is_match +find +captures +. +There +are +three +primary +search +methods +on +a +Regex +: +* +is_match +* +find +* +captures +In +general +these +are +ordered +from +fastest +to +slowest +. +is_match +is +fastest +because +it +doesn +' +t +actually +need +to +find +the +start +or +the +end +of +the +leftmost +- +first +match +. +It +can +quit +immediately +after +it +knows +there +is +a +match +. +For +example +given +the +regex +a ++ +and +the +haystack +aaaaa +the +search +will +quit +after +examining +the +first +byte +. +In +contrast +find +must +return +both +the +start +and +end +location +of +the +leftmost +- +first +match +. +It +can +use +the +DFA +matcher +for +this +but +must +run +it +forwards +once +to +find +the +end +of +the +match +* +and +then +run +it +backwards +* +to +find +the +start +of +the +match +. +The +two +scans +and +the +cost +of +finding +the +real +end +of +the +leftmost +- +first +match +make +this +more +expensive +than +is_match +. +captures +is +the +most +expensive +of +them +all +because +it +must +do +what +find +does +and +then +run +either +the +bounded +backtracker +or +the +Pike +VM +to +fill +in +the +capture +group +locations +. +Both +of +these +are +simulations +of +an +NFA +which +must +spend +a +lot +of +time +shuffling +states +around +. +The +DFA +limits +the +performance +hit +somewhat +by +restricting +the +amount +of +text +that +must +be +searched +via +an +NFA +simulation +. +One +other +method +not +mentioned +is +shortest_match +. +This +method +has +precisely +the +same +performance +characteristics +as +is_match +except +it +will +return +the +end +location +of +when +it +discovered +a +match +. +For +example +given +the +regex +a ++ +and +the +haystack +aaaaa +shortest_match +may +return +1 +as +opposed +to +5 +the +latter +of +which +being +the +correct +end +location +of +the +leftmost +- +first +match +. +# +# +Literals +in +your +regex +may +make +it +faster +* +* +Advice +* +* +: +Literals +can +reduce +the +work +that +the +regex +engine +needs +to +do +. +Use +them +if +you +can +especially +as +prefixes +. +In +particular +if +your +regex +starts +with +a +prefix +literal +the +prefix +is +quickly +searched +before +entering +the +( +much +slower +) +regex +engine +. +For +example +given +the +regex +foo +\ +w ++ +the +literal +foo +will +be +searched +for +using +Boyer +- +Moore +. +If +there +' +s +no +match +then +no +regex +engine +is +ever +used +. +Only +when +there +' +s +a +match +is +the +regex +engine +invoked +at +the +location +of +the +match +which +effectively +permits +the +regex +engine +to +skip +large +portions +of +a +haystack +. +If +a +regex +is +comprised +entirely +of +literals +( +possibly +more +than +one +) +then +it +' +s +possible +that +the +regex +engine +can +be +avoided +entirely +even +when +there +' +s +a +match +. +When +one +literal +is +found +Boyer +- +Moore +is +used +. +When +multiple +literals +are +found +then +an +optimized +version +of +Aho +- +Corasick +is +used +. +This +optimization +is +in +particular +extended +quite +a +bit +in +this +crate +. +Here +are +a +few +examples +of +regexes +that +get +literal +prefixes +detected +: +* +( +foo +| +bar +) +detects +foo +and +bar +* +( +a +| +b +) +c +detects +ac +and +bc +* +[ +ab +] +foo +[ +yz +] +detects +afooy +afooz +bfooy +and +bfooz +* +a +? +b +detects +a +and +b +* +a +* +b +detects +a +and +b +* +( +ab +) +{ +3 +6 +} +detects +ababab +Literals +in +anchored +regexes +can +also +be +used +for +detecting +non +- +matches +very +quickly +. +For +example +^ +foo +\ +w ++ +and +\ +w ++ +foo +may +be +able +to +detect +a +non +- +match +just +by +examining +the +first +( +or +last +) +three +bytes +of +the +haystack +. +# +# +Unicode +word +boundaries +may +prevent +the +DFA +from +being +used +* +* +Advice +* +* +: +In +most +cases +\ +b +should +work +well +. +If +not +use +( +? +- +u +: +\ +b +) +instead +of +\ +b +if +you +care +about +consistent +performance +more +than +correctness +. +It +' +s +a +sad +state +of +the +current +implementation +. +At +the +moment +the +DFA +will +try +to +interpret +Unicode +word +boundaries +as +if +they +were +ASCII +word +boundaries +. +If +the +DFA +comes +across +any +non +- +ASCII +byte +it +will +quit +and +fall +back +to +an +alternative +matching +engine +that +can +handle +Unicode +word +boundaries +correctly +. +The +alternate +matching +engine +is +generally +quite +a +bit +slower +( +perhaps +by +an +order +of +magnitude +) +. +If +necessary +this +can +be +ameliorated +in +two +ways +. +The +first +way +is +to +add +some +number +of +literal +prefixes +to +your +regular +expression +. +Even +though +the +DFA +may +not +be +used +specialized +routines +will +still +kick +in +to +find +prefix +literals +quickly +which +limits +how +much +work +the +NFA +simulation +will +need +to +do +. +The +second +way +is +to +give +up +on +Unicode +and +use +an +ASCII +word +boundary +instead +. +One +can +use +an +ASCII +word +boundary +by +disabling +Unicode +support +. +That +is +instead +of +using +\ +b +use +( +? +- +u +: +\ +b +) +. +Namely +given +the +regex +\ +b +. ++ +\ +b +it +can +be +transformed +into +a +regex +that +uses +the +DFA +with +( +? +- +u +: +\ +b +) +. ++ +( +? +- +u +: +\ +b +) +. +It +is +important +to +limit +the +scope +of +disabling +the +u +flag +since +it +might +lead +to +a +syntax +error +if +the +regex +could +match +arbitrary +bytes +. +For +example +if +one +wrote +( +? +- +u +) +\ +b +. ++ +\ +b +then +a +syntax +error +would +be +returned +because +. +matches +any +* +byte +* +when +the +Unicode +flag +is +disabled +. +The +second +way +isn +' +t +appreciably +different +than +just +using +a +Unicode +word +boundary +in +the +first +place +since +the +DFA +will +speculatively +interpret +it +as +an +ASCII +word +boundary +anyway +. +The +key +difference +is +that +if +an +ASCII +word +boundary +is +used +explicitly +then +the +DFA +won +' +t +quit +in +the +presence +of +non +- +ASCII +UTF +- +8 +bytes +. +This +results +in +giving +up +correctness +in +exchange +for +more +consistent +performance +. +N +. +B +. +When +using +bytes +: +: +Regex +Unicode +support +is +disabled +by +default +so +one +can +simply +write +\ +b +to +get +an +ASCII +word +boundary +. +# +# +Excessive +counting +can +lead +to +exponential +state +blow +up +in +the +DFA +* +* +Advice +* +* +: +Don +' +t +write +regexes +that +cause +DFA +state +blow +up +if +you +care +about +match +performance +. +Wait +didn +' +t +I +say +that +this +crate +guards +against +exponential +worst +cases +? +Well +it +turns +out +that +the +process +of +converting +an +NFA +to +a +DFA +can +lead +to +an +exponential +blow +up +in +the +number +of +states +. +This +crate +specifically +guards +against +exponential +blow +up +by +doing +two +things +: +1 +. +The +DFA +is +computed +lazily +. +That +is +a +state +in +the +DFA +only +exists +in +memory +if +it +is +visited +. +In +particular +the +lazy +DFA +guarantees +that +* +at +most +* +one +state +is +created +for +every +byte +of +input +. +This +on +its +own +guarantees +linear +time +complexity +. +2 +. +Of +course +creating +a +new +state +for +* +every +* +byte +of +input +means +that +search +will +go +incredibly +slow +because +of +very +large +constant +factors +. +On +top +of +that +creating +a +state +for +every +byte +in +a +large +haystack +could +result +in +exorbitant +memory +usage +. +To +ameliorate +this +the +DFA +bounds +the +number +of +states +it +can +store +. +Once +it +reaches +its +limit +it +flushes +its +cache +. +This +prevents +reuse +of +states +that +it +already +computed +. +If +the +cache +is +flushed +too +frequently +then +the +DFA +will +give +up +and +execution +will +fall +back +to +one +of +the +NFA +simulations +. +In +effect +this +crate +will +detect +exponential +state +blow +up +and +fall +back +to +a +search +routine +with +fixed +memory +requirements +. +This +does +however +mean +that +searching +will +be +much +slower +than +one +might +expect +. +Regexes +that +rely +on +counting +in +particular +are +strong +aggravators +of +this +behavior +. +For +example +matching +[ +01 +] +* +1 +[ +01 +] +{ +20 +} +against +a +random +sequence +of +0 +s +and +1 +s +. +In +the +future +it +may +be +possible +to +increase +the +bound +that +the +DFA +uses +which +would +allow +the +caller +to +choose +how +much +memory +they +' +re +willing +to +spend +. +# +# +Resist +the +temptation +to +" +optimize +" +regexes +* +* +Advice +* +* +: +This +ain +' +t +a +backtracking +engine +. +An +entire +book +was +written +on +how +to +optimize +Perl +- +style +regular +expressions +. +Most +of +those +techniques +are +not +applicable +for +this +library +. +For +example +there +is +no +problem +with +using +non +- +greedy +matching +or +having +lots +of +alternations +in +your +regex +. diff --git a/third_party/rust/regex/README.md b/third_party/rust/regex/README.md index a9c03b1c4fd20..6584854f1c830 100644 --- a/third_party/rust/regex/README.md +++ b/third_party/rust/regex/README.md @@ -4,64 +4,34 @@ regex = = = -This -crate -provides -routines -for -searching -strings +A +Rust +library for -matches -of -a -[ +parsing +compiling +and +executing regular -expression -] -( -aka -" -regex -" -) +expressions . -The -regex +Its syntax -supported -by -this -crate is similar to -other -regex -engines +Perl +- +style +regular +expressions but -it lacks -several +a +few features -that -are -not -known -how -to -implement -efficiently -. -This -includes -but -is -not -limited -to +like look -- around and backreferences @@ -69,63 +39,50 @@ backreferences In exchange all -regex searches +execute in -this -crate -have -worst -case -O -( -m -* -n -) +linear time -complexity -where -m -is -proportional +with +respect to the size of the -regex +regular +expression and -n -is -proportional -to -the -size +search +text +. +Much of the -string -being -searched -. +syntax +and +implementation +is +inspired +by [ -regular -expression +RE2 ] -: +( https : / / -en -. -wikipedia +github . -org +com / -wiki +google / -Regular_expression +re2 +) +. [ ! [ @@ -213,6 +170,58 @@ crates / regex ) +[ +! +[ +Rust +] +( +https +: +/ +/ +img +. +shields +. +io +/ +badge +/ +rust +- +1 +. +41 +. +1 +% +2B +- +blue +. +svg +? +maxAge += +3600 +) +] +( +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +) # # # @@ -522,6 +531,35 @@ regex : Regex ; +const +TO_SEARCH +: +& +' +static +str += +" +On +2010 +- +03 +- +14 +foo +happened +. +On +2014 +- +10 +- +14 +bar +happened +. +" +; fn main ( @@ -567,113 +605,146 @@ unwrap ( ) ; -let -hay -= -" -On -2010 -- -03 -- -14 -foo -happened +for +caps +in +re . -On -2014 -- -10 -- -14 -bar -happened +captures_iter +( +TO_SEARCH +) +{ +/ +/ +Note +that +all +of +the +unwraps +are +actually +OK +for +this +regex +/ +/ +because +the +only +way +for +the +regex +to +match +is +if +all +of +the +/ +/ +capture +groups +match . -" -; -let -mut -dates -= -vec +This +is +not +true +in +general +though +! +println ! -[ -] -; -for ( -_ -[ +" year +: +{ +} month +: +{ +} day -] +: +{ +} +" +caps +. +get +( +1 ) -in -re . -captures_iter +unwrap ( -hay ) . -map +as_str ( -| -c -| -c +) +caps . -extract +get ( +2 ) +. +unwrap +( ) -{ -dates . -push +as_str ( +) +caps +. +get +( +3 +) +. +unwrap +( +) +. +as_str ( -year -month -day ) ) ; } -assert_eq -! -( -dates -vec -! -[ -( -" +} +This +example +outputs +: +text +year +: 2010 -" -" +month +: 03 -" -" +day +: 14 -" -) -( -" +year +: 2014 -" -" +month +: 10 -" -" +day +: 14 -" -) -] -) -; -} # # # @@ -783,7 +854,7 @@ recommend using the [ -once_cell +lazy_static ] ( https @@ -796,7 +867,7 @@ io / crates / -once_cell +lazy_static ) crate to @@ -813,25 +884,17 @@ For example : rust +ignore use -{ -once_cell -: -: -sync -: -: -Lazy regex : : Regex -} ; fn some_helper_function ( -haystack +text : & str @@ -840,75 +903,39 @@ str > bool { +lazy_static +! +{ static +ref RE : -Lazy -< Regex -> = -Lazy -: -: -new -( -| -| Regex : : new ( -r " . . . " ) -. -unwrap -( -) -) -; -RE -. -is_match -( -haystack -) -} -fn -main -( -) -{ -assert -! -( -some_helper_function -( -" -abc -" -) -) -; -assert -! -( -! -some_helper_function -( -" -ac -" -) +. +unwrap +( ) ; } +RE +. +is_match +( +text +) +} Specifically in this @@ -1043,52 +1070,16 @@ an & str . -The -& -[ -u8 -] -APIs -also -permit -disabling -Unicode -mode -in -the -regex -even -when -the -pattern -would -match -invalid -UTF -- -8 -. -For -example -( -? -- -u -: +By +default . -) -is -not -allowed -in -regex -: -: -Regex -but -is -allowed -in +will +match +any +* +byte +* +using regex : : @@ -1096,40 +1087,24 @@ bytes : : Regex -since -( -? -- -u -: -. -) -matches -any -byte -except -for -\ -n -. -Conversely +while . will match -the +any +* UTF - 8 -encoding -of -any +encoded Unicode scalar value -except -for -\ -n +* +using +the +main +API . This example @@ -1170,11 +1145,7 @@ r " ( ? -- -u -) -( -? +P < cstr > @@ -1201,7 +1172,7 @@ b " foo \ -xFFbar +x00bar \ x00baz \ @@ -1295,8 +1266,15 @@ vec b " foo -\ -xFFbar +" +[ +. +. +] +& +b +" +bar " [ . @@ -1334,18 +1312,6 @@ byte except for NUL -including -bytes -like -\ -xFF -which -are -not -valid -UTF -- -8 . When using @@ -1567,91 +1533,39 @@ matched # Usage : -regex -internals -as -a -library -The -[ -regex -- -automata -directory -] -( +enable +SIMD +optimizations +SIMD +optimizations +are +enabled +automatically +on +Rust +stable +1 . -/ -regex -- -automata -/ -) -contains -a -crate -that -exposes -all -of -the -internal -matching -engines -used -by -the -regex -crate +27 +and +newer . -The -idea -is -that -the -regex -crate -exposes -a -simple -API -for -99 -% -of -use -cases -but -regex -- -automata -exposes -oodles +For +nightly +versions of -customizable -behaviors -. -[ -Documentation -for -regex -- -automata -. -] -( -https -: -/ -/ -docs +Rust +this +requires +a +recent +version +with +the +SIMD +features +stabilized . -rs -/ -regex -- -automata -) # # # @@ -1734,7 +1648,6 @@ use . [ Documentation -for regex - syntax @@ -1874,48 +1787,18 @@ features = false # -Unless -you -have -a -specific -reason -not -to -it -' -s -good -sense -to -enable +regex +currently +requires +the standard -# library -support -. -It -enables -several -optimizations -and -avoids -spin -locks -. -It -# -also -shouldn -' -t -meaningfully -impact -compile -times -or -binary -size +you +must +re +- +enable +it . features = @@ -1934,16 +1817,14 @@ of regex down to -two -crates -: +a +single +crate +( regex - syntax -and -regex -- -automata +) . The full @@ -1977,8 +1858,6 @@ rs / regex / -1 -. * / # @@ -2005,11 +1884,17 @@ version is 1 . -60 +41 . -0 +1 . The +current +* +* +tentative +* +* policy is that @@ -2086,6 +1971,23 @@ version of Rust . +In +general +this +crate +will +be +conservative +with +respect +to +the +minimum +supported +version +of +Rust +. # # # diff --git a/third_party/rust/regex/UNICODE.md b/third_party/rust/regex/UNICODE.md index 66a735da3dc12..b5a5569c8f785 100644 --- a/third_party/rust/regex/UNICODE.md +++ b/third_party/rust/regex/UNICODE.md @@ -91,30 +91,6 @@ as a line boundary -by -default -. -One -can -opt -into -\ -r -\ -n -| -\ -r -| -\ -n -being -a -line -boundary -via -CRLF -mode . 2 . @@ -1950,32 +1926,6 @@ as a line boundary -by -default -. -One -can -also -opt -into -treating -\ -r -\ -n -| -\ -r -| -\ -n -as -a -line -boundary -via -CRLF -mode . This choice @@ -1998,6 +1948,34 @@ are subject to . +Ideally +it +would +be +nice +to +at +least +support +\ +r +\ +n +as +a +line +boundary +as +well +and +in +theory +this +could +be +done +efficiently +. # # RL1 diff --git a/third_party/rust/regex/examples/regexdna-input.txt b/third_party/rust/regex/examples/regexdna-input.txt new file mode 100644 index 0000000000000..9d30c6cb88abb --- /dev/null +++ b/third_party/rust/regex/examples/regexdna-input.txt @@ -0,0 +1,1683 @@ +> +ONE +Homo +sapiens +alu +GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA +TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT +AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG +GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG +CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT +GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA +GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA +TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG +AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA +GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT +AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC +AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG +GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC +CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG +AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT +TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA +TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT +GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG +TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT +CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG +CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG +TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA +CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG +AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG +GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC +TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA +TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA +GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT +GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC +ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT +TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC +CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG +CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG +GGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCC +CAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCT +GGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGC +GCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGA +GGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGA +GACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGA +GGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG +AAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT +CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCA +GTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAA +AAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGC +GGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCT +ACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGG +GAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATC +GCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGC +GGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGG +TCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAA +AAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAG +GAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACT +CCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCC +TGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAG +ACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGC +GTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGA +ACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGA +CAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCA +CTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCA +ACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCG +CCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGG +AGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTC +CGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCG +AGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACC +CCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAG +CTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAG +CCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGG +CCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAA +AAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGC +TGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCC +ACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGG +CTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGG +AGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATT +AGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAA +TCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGC +CTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAA +TCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAG +CCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGT +GGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCG +GGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAG +CGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTG +GGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATG +GTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGT +AATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTT +GCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCT +CAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCG +GGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTC +TCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACT +CGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAG +ATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGG +CGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTG +AGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATA +CAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGG +CAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGC +ACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCAC +GCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTC +GAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCG +GGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCT +TGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGG +CGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCA +GCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGG +CCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGC +GCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGG +CGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGA +CTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGG +CCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAA +ACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCC +CAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGT +GAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAA +AGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGG +ATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTAC +TAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGA +GGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGC +GCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGG +TGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTC +AGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAA +ATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGA +GAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCC +AGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTG +TAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGAC +CAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGT +GGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAAC +CCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACA +GAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACT +TTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAAC +ATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCC +TGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAG +GTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCG +TCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAG +GCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCC +GTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCT +ACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCC +GAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCC +GGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCAC +CTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAA +ATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTG +AGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCAC +TGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCT +CACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAG +TTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAG +CCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATC +GCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCT +GGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATC +CCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCC +TGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGG +CGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGG +AGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCG +AGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGG +AGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGT +GAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAA +TCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGC +AGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCA +AAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGG +CGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTC +TACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCG +GGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGAT +CGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCG +CGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAG +GTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACA +AAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCA +GGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCAC +TCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGC +CTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGA +GACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGG +CGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTG +AACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCG +ACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGC +ACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCC +AACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGC +GCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCG +GAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACT +CCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCC +GAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAAC +CCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCA +GCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGA +GCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAG +GCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGAT +CACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTA +AAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGG +CTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGC +CACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTG +GCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAG +GAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAAT +TAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGA +ATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAG +CCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTA +ATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCA +GCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGG +TGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCC +GGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGA +GCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTT +GGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACAT +GGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTG +TAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGT +TGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTC +TCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGC +GGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGT +CTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTAC +TCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGA +GATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGG +GCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCT +GAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAAT +ACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAG +GCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTG +CACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCA +CGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTT +CGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCC +GGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGC +TTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGG +GCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCC +AGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTG +GCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCG +CGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAG +GCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAG +ACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAG +GCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGA +AACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATC +CCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAG +TGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAA +AAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCG +GATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTA +CTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGG +AGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCG +CGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCG +GTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGT +CAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAA +AATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGG +AGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTC +CAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCT +GTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGA +CCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCG +TGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAA +CCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGAC +AGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCAC +TTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAA +CATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGC +CTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGA +GGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCC +GTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGA +GGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCC +CGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGC +TACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGC +CGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGC +CGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCA +CCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAA +AATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCT +GAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCA +CTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGC +TCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGA +GTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTA +GCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAAT +CGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCC +TGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAAT +CCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGC +CTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTG +GCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGG +GAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGC +GAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG +GAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGG +TGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTA +ATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTG +CAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTC +AAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGG +GCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCT +CTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTC +GGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGA +TCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGC +GCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGA +GGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATAC +AAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGC +AGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCA +CTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACG +CCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCG +AGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGG +GCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTT +GAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGC +GACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAG +CACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGC +CAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCG +CGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGC +GGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGAC +TCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGC +CGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAA +CCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCC +AGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTG +AGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAA +GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA +TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACT +AAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAG +GCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCG +CCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGT +GGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCA +GGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAA +TTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAG +AATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCA +GCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGT +AATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACC +AGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTG +GTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACC +CGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAG +AGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTT +TGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACA +TGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCT +GTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGG +TTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGT +CTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGG +CGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCG +TCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTA +CTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCG +AGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCG +GGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACC +TGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAA +TACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGA +GGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACT +GCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTC +ACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGT +TCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGC +CGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCG +CTTGAACCCGGGAGGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTG +GGCGACAGAGCGAGACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCC +CAGCACTTTGGGAGGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCT +GGCCAACATGGTGAAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGC +GCGCGCCTGTAATCCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGA +GGCGGAGGTTGCAGTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGA +GACTCCGTCTCAAAAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGA +GGCCGAGGCGGGCGGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTG +AAACCCCGTCTCTACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAAT +CCCAGCTACTCGGGAGGCTGAGGCAGGAGAATCGCTTGAACCCGGGAGGCGGAGGTTGCA +GTGAGCCGAGATCGCGCCACTGCACTCCAGCCTGGGCGACAGAGCGAGACTCCGTCTCAA +AAAGGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGC +GGATCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGTGAAACCCCGTCTCT +ACTAAAAATACAAAAATTAGCCGGGCGTGGTGGCGCGCGCCTGTAATCCCAGCTACTCGG +GAGGCTGAGGCAGGAGAATC +> +TWO +IUB +ambiguity +codes +cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg +tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa +NtactMcSMtYtcMgRtacttctWBacgaaatatagScDtttgaagacacatagtVgYgt +cattHWtMMWcStgttaggKtSgaYaaccWStcgBttgcgaMttBYatcWtgacaYcaga +gtaBDtRacttttcWatMttDBcatWtatcttactaBgaYtcttgttttttttYaaScYa +HgtgttNtSatcMtcVaaaStccRcctDaataataStcYtRDSaMtDttgttSagtRRca +tttHatSttMtWgtcgtatSSagactYaaattcaMtWatttaSgYttaRgKaRtccactt +tattRggaMcDaWaWagttttgacatgttctacaaaRaatataataaMttcgDacgaSSt +acaStYRctVaNMtMgtaggcKatcttttattaaaaagVWaHKYagtttttatttaacct +tacgtVtcVaattVMBcttaMtttaStgacttagattWWacVtgWYagWVRctDattBYt +gtttaagaagattattgacVatMaacattVctgtBSgaVtgWWggaKHaatKWcBScSWa +accRVacacaaactaccScattRatatKVtactatatttHttaagtttSKtRtacaaagt +RDttcaaaaWgcacatWaDgtDKacgaacaattacaRNWaatHtttStgttattaaMtgt +tgDcgtMgcatBtgcttcgcgaDWgagctgcgaggggVtaaScNatttacttaatgacag +cccccacatYScaMgtaggtYaNgttctgaMaacNaMRaacaaacaKctacatagYWctg +ttWaaataaaataRattagHacacaagcgKatacBttRttaagtatttccgatctHSaat +actcNttMaagtattMtgRtgaMgcataatHcMtaBSaRattagttgatHtMttaaKagg +YtaaBataSaVatactWtataVWgKgttaaaacagtgcgRatatacatVtHRtVYataSa +KtWaStVcNKHKttactatccctcatgWHatWaRcttactaggatctataDtDHBttata +aaaHgtacVtagaYttYaKcctattcttcttaataNDaaggaaaDYgcggctaaWSctBa +aNtgctggMBaKctaMVKagBaactaWaDaMaccYVtNtaHtVWtKgRtcaaNtYaNacg +gtttNattgVtttctgtBaWgtaattcaagtcaVWtactNggattctttaYtaaagccgc +tcttagHVggaYtgtNcDaVagctctctKgacgtatagYcctRYHDtgBattDaaDgccK +tcHaaStttMcctagtattgcRgWBaVatHaaaataYtgtttagMDMRtaataaggatMt +ttctWgtNtgtgaaaaMaatatRtttMtDgHHtgtcattttcWattRSHcVagaagtacg +ggtaKVattKYagactNaatgtttgKMMgYNtcccgSKttctaStatatNVataYHgtNa +BKRgNacaactgatttcctttaNcgatttctctataScaHtataRagtcRVttacDSDtt +aRtSatacHgtSKacYagttMHtWataggatgactNtatSaNctataVtttRNKtgRacc +tttYtatgttactttttcctttaaacatacaHactMacacggtWataMtBVacRaSaatc +cgtaBVttccagccBcttaRKtgtgcctttttRtgtcagcRttKtaaacKtaaatctcac +aattgcaNtSBaaccgggttattaaBcKatDagttactcttcattVtttHaaggctKKga +tacatcBggScagtVcacattttgaHaDSgHatRMaHWggtatatRgccDttcgtatcga +aacaHtaagttaRatgaVacttagattVKtaaYttaaatcaNatccRttRRaMScNaaaD +gttVHWgtcHaaHgacVaWtgttScactaagSgttatcttagggDtaccagWattWtRtg +ttHWHacgattBtgVcaYatcggttgagKcWtKKcaVtgaYgWctgYggVctgtHgaNcV +taBtWaaYatcDRaaRtSctgaHaYRttagatMatgcatttNattaDttaattgttctaa +ccctcccctagaWBtttHtBccttagaVaatMcBHagaVcWcagBVttcBtaYMccagat +gaaaaHctctaacgttagNWRtcggattNatcRaNHttcagtKttttgWatWttcSaNgg +gaWtactKKMaacatKatacNattgctWtatctaVgagctatgtRaHtYcWcttagccaa +tYttWttaWSSttaHcaaaaagVacVgtaVaRMgattaVcDactttcHHggHRtgNcctt +tYatcatKgctcctctatVcaaaaKaaaagtatatctgMtWtaaaacaStttMtcgactt +taSatcgDataaactaaacaagtaaVctaggaSccaatMVtaaSKNVattttgHccatca +cBVctgcaVatVttRtactgtVcaattHgtaaattaaattttYtatattaaRSgYtgBag +aHSBDgtagcacRHtYcBgtcacttacactaYcgctWtattgSHtSatcataaatataHt +cgtYaaMNgBaatttaRgaMaatatttBtttaaaHHKaatctgatWatYaacttMctctt +ttVctagctDaaagtaVaKaKRtaacBgtatccaaccactHHaagaagaaggaNaaatBW +attccgStaMSaMatBttgcatgRSacgttVVtaaDMtcSgVatWcaSatcttttVatag +ttactttacgatcaccNtaDVgSRcgVcgtgaacgaNtaNatatagtHtMgtHcMtagaa +attBgtataRaaaacaYKgtRccYtatgaagtaataKgtaaMttgaaRVatgcagaKStc +tHNaaatctBBtcttaYaBWHgtVtgacagcaRcataWctcaBcYacYgatDgtDHccta +aagacYRcaggattHaYgtKtaatgcVcaataMYacccatatcacgWDBtgaatcBaata +cKcttRaRtgatgaBDacggtaattaaYtataStgVHDtDctgactcaaatKtacaatgc +gYatBtRaDatHaactgtttatatDttttaaaKVccYcaaccNcBcgHaaVcattHctcg +attaaatBtatgcaaaaatYMctSactHatacgaWacattacMBgHttcgaatVaaaaca +BatatVtctgaaaaWtctRacgBMaatSgRgtgtcgactatcRtattaScctaStagKga +DcWgtYtDDWKRgRtHatRtggtcgaHgggcgtattaMgtcagccaBggWVcWctVaaat +tcgNaatcKWagcNaHtgaaaSaaagctcYctttRVtaaaatNtataaccKtaRgtttaM +tgtKaBtRtNaggaSattHatatWactcagtgtactaKctatttgRYYatKatgtccgtR +tttttatttaatatVgKtttgtatgtNtataRatWYNgtRtHggtaaKaYtKSDcatcKg +taaYatcSRctaVtSMWtVtRWHatttagataDtVggacagVcgKWagBgatBtaaagNc +aRtagcataBggactaacacRctKgttaatcctHgDgttKHHagttgttaatgHBtatHc +DaagtVaBaRccctVgtgDtacRHSctaagagcggWYaBtSaKtHBtaaactYacgNKBa +VYgtaacttagtVttcttaatgtBtatMtMtttaattaatBWccatRtttcatagVgMMt +agctStKctaMactacDNYgKYHgaWcgaHgagattacVgtttgtRaSttaWaVgataat +gtgtYtaStattattMtNgWtgttKaccaatagNYttattcgtatHcWtctaaaNVYKKt +tWtggcDtcgaagtNcagatacgcattaagaccWctgcagcttggNSgaNcHggatgtVt +catNtRaaBNcHVagagaaBtaaSggDaatWaatRccaVgggStctDaacataKttKatt +tggacYtattcSatcttagcaatgaVBMcttDattctYaaRgatgcattttNgVHtKcYR +aatRKctgtaaacRatVSagctgtWacBtKVatctgttttKcgtctaaDcaagtatcSat +aWVgcKKataWaYttcccSaatgaaaacccWgcRctWatNcWtBRttYaattataaNgac +acaatagtttVNtataNaYtaatRaVWKtBatKagtaatataDaNaaaaataMtaagaaS +tccBcaatNgaataWtHaNactgtcDtRcYaaVaaaaaDgtttRatctatgHtgttKtga +aNSgatactttcgagWaaatctKaaDaRttgtggKKagcDgataaattgSaacWaVtaNM +acKtcaDaaatttctRaaVcagNacaScRBatatctRatcctaNatWgRtcDcSaWSgtt +RtKaRtMtKaatgttBHcYaaBtgatSgaSWaScMgatNtctcctatttctYtatMatMt +RRtSaattaMtagaaaaStcgVgRttSVaScagtgDtttatcatcatacRcatatDctta +tcatVRtttataaHtattcYtcaaaatactttgVctagtaaYttagatagtSYacKaaac +gaaKtaaatagataatSatatgaaatSgKtaatVtttatcctgKHaatHattagaaccgt +YaaHactRcggSBNgtgctaaBagBttgtRttaaattYtVRaaaattgtaatVatttctc +ttcatgBcVgtgKgaHaaatattYatagWacNctgaaMcgaattStagWaSgtaaKagtt +ttaagaDgatKcctgtaHtcatggKttVDatcaaggtYcgccagNgtgcVttttagagat +gctaccacggggtNttttaSHaNtatNcctcatSaaVgtactgBHtagcaYggYVKNgta +KBcRttgaWatgaatVtagtcgattYgatgtaatttacDacSctgctaaaStttaWMagD +aaatcaVYctccgggcgaVtaaWtStaKMgDtttcaaMtVgBaatccagNaaatcYRMBg +gttWtaaScKttMWtYataRaDBMaDataatHBcacDaaKDactaMgagttDattaHatH +taYatDtattDcRNStgaatattSDttggtattaaNSYacttcDMgYgBatWtaMagact +VWttctttgYMaYaacRgHWaattgRtaagcattctMKVStatactacHVtatgatcBtV +NataaBttYtSttacKgggWgYDtgaVtYgatDaacattYgatggtRDaVDttNactaSa +MtgNttaacaaSaBStcDctaccacagacgcaHatMataWKYtaYattMcaMtgSttDag +cHacgatcaHttYaKHggagttccgatYcaatgatRaVRcaagatcagtatggScctata +ttaNtagcgacgtgKaaWaactSgagtMYtcttccaKtStaacggMtaagNttattatcg +tctaRcactctctDtaacWYtgaYaSaagaWtNtatttRacatgNaatgttattgWDDcN +aHcctgaaHacSgaataaRaataMHttatMtgaSDSKatatHHaNtacagtccaYatWtc +actaactatKDacSaStcggataHgYatagKtaatKagStaNgtatactatggRHacttg +tattatgtDVagDVaRctacMYattDgtttYgtctatggtKaRSttRccRtaaccttaga +gRatagSaaMaacgcaNtatgaaatcaRaagataatagatactcHaaYKBctccaagaRa +BaStNagataggcgaatgaMtagaatgtcaKttaaatgtaWcaBttaatRcggtgNcaca +aKtttScRtWtgcatagtttWYaagBttDKgcctttatMggNttattBtctagVtacata +aaYttacacaaRttcYtWttgHcaYYtaMgBaBatctNgcDtNttacgacDcgataaSat +YaSttWtcctatKaatgcagHaVaacgctgcatDtgttaSataaaaYSNttatagtaNYt +aDaaaNtggggacttaBggcHgcgtNtaaMcctggtVtaKcgNacNtatVaSWctWtgaW +cggNaBagctctgaYataMgaagatBSttctatacttgtgtKtaattttRagtDtacata +tatatgatNHVgBMtKtaKaNttDHaagatactHaccHtcatttaaagttVaMcNgHata +tKtaNtgYMccttatcaaNagctggacStttcNtggcaVtattactHaSttatgNMVatt +MMDtMactattattgWMSgtHBttStStgatatRaDaagattttctatMtaaaaaggtac +taaVttaSacNaatactgMttgacHaHRttgMacaaaatagttaatatWKRgacDgaRta +tatttattatcYttaWtgtBRtWatgHaaattHataagtVaDtWaVaWtgStcgtMSgaS +RgMKtaaataVacataatgtaSaatttagtcgaaHtaKaatgcacatcggRaggSKctDc +agtcSttcccStYtccRtctctYtcaaKcgagtaMttttcRaYDttgttatctaatcata +NctctgctatcaMatactataggDaHaaSttMtaDtcNatataattctMcStaaBYtaNa +gatgtaatHagagSttgWHVcttatKaYgDctcttggtgttMcRaVgSgggtagacaata +aDtaattSaDaNaHaBctattgNtaccaaRgaVtKNtaaYggHtaKKgHcatctWtctDt +ttctttggSDtNtaStagttataaacaattgcaBaBWggHgcaaaBtYgctaatgaaatW +cDcttHtcMtWWattBHatcatcaaatctKMagtDNatttWaBtHaaaNgMttaaStagt +tctctaatDtcRVaYttgttMtRtgtcaSaaYVgSWDRtaatagctcagDgcWWaaaBaa +RaBctgVgggNgDWStNaNBKcBctaaKtttDcttBaaggBttgaccatgaaaNgttttt +tttatctatgttataccaaDRaaSagtaVtDtcaWatBtacattaWacttaSgtattggD +gKaaatScaattacgWcagKHaaccaYcRcaRttaDttRtttHgaHVggcttBaRgtccc +tDatKaVtKtcRgYtaKttacgtatBtStaagcaattaagaRgBagSaattccSWYttta +ttVaataNctgHgttaaNBgcVYgtRtcccagWNaaaacaDNaBcaaaaRVtcWMgBagM +tttattacgDacttBtactatcattggaaatVccggttRttcatagttVYcatYaSHaHc +ttaaagcNWaHataaaRWtctVtRYtagHtaaaYMataHYtNBctNtKaatattStgaMc +BtRgctaKtgcScSttDgYatcVtggaaKtaagatWccHccgKYctaNNctacaWctttt +gcRtgtVcgaKttcMRHgctaHtVaataaDtatgKDcttatBtDttggNtacttttMtga +acRattaaNagaactcaaaBBVtcDtcgaStaDctgaaaSgttMaDtcgttcaccaaaag +gWtcKcgSMtcDtatgtttStaaBtatagDcatYatWtaaaBacaKgcaDatgRggaaYc +taRtccagattDaWtttggacBaVcHtHtaacDacYgtaatataMagaatgHMatcttat +acgtatttttatattacHactgttataMgStYaattYaccaattgagtcaaattaYtgta +tcatgMcaDcgggtcttDtKgcatgWRtataatatRacacNRBttcHtBgcRttgtgcgt +catacMtttBctatctBaatcattMttMYgattaaVYatgDaatVagtattDacaacDMa +tcMtHcccataagatgBggaccattVWtRtSacatgctcaaggggYtttDtaaNgNtaaB +atggaatgtctRtaBgBtcNYatatNRtagaacMgagSaSDDSaDcctRagtVWSHtVSR +ggaacaBVaccgtttaStagaacaMtactccagtttVctaaRaaHttNcttagcaattta +ttaatRtaaaatctaacDaBttggSagagctacHtaaRWgattcaaBtctRtSHaNtgta +cattVcaHaNaagtataccacaWtaRtaaVKgMYaWgttaKggKMtKcgWatcaDatYtK +SttgtacgaccNctSaattcDcatcttcaaaDKttacHtggttHggRRaRcaWacaMtBW +VHSHgaaMcKattgtaRWttScNattBBatYtaNRgcggaagacHSaattRtttcYgacc +BRccMacccKgatgaacttcgDgHcaaaaaRtatatDtatYVtttttHgSHaSaatagct +NYtaHYaVYttattNtttgaaaYtaKttWtctaNtgagaaaNctNDctaaHgttagDcRt +tatagccBaacgcaRBtRctRtggtaMYYttWtgataatcgaataattattataVaaaaa +ttacNRVYcaaMacNatRttcKatMctgaagactaattataaYgcKcaSYaatMNctcaa +cgtgatttttBacNtgatDccaattattKWWcattttatatatgatBcDtaaaagttgaa +VtaHtaHHtBtataRBgtgDtaataMttRtDgDcttattNtggtctatctaaBcatctaR +atgNacWtaatgaagtcMNaacNgHttatactaWgcNtaStaRgttaaHacccgaYStac +aaaatWggaYaWgaattattcMaactcBKaaaRVNcaNRDcYcgaBctKaacaaaaaSgc +tccYBBHYaVagaatagaaaacagYtctVccaMtcgtttVatcaatttDRtgWctagtac +RttMctgtDctttcKtWttttataaatgVttgBKtgtKWDaWagMtaaagaaattDVtag +gttacatcatttatgtcgMHaVcttaBtVRtcgtaYgBRHatttHgaBcKaYWaatcNSc +tagtaaaaatttacaatcactSWacgtaatgKttWattagttttNaggtctcaagtcact +attcttctaagKggaataMgtttcataagataaaaatagattatDgcBVHWgaBKttDgc +atRHaagcaYcRaattattatgtMatatattgHDtcaDtcaaaHctStattaatHaccga +cNattgatatattttgtgtDtRatagSacaMtcRtcattcccgacacSattgttKaWatt +NHcaacttccgtttSRtgtctgDcgctcaaMagVtBctBMcMcWtgtaacgactctcttR +ggRKSttgYtYatDccagttDgaKccacgVatWcataVaaagaataMgtgataaKYaaat +cHDaacgataYctRtcYatcgcaMgtNttaBttttgatttaRtStgcaacaaaataccVg +aaDgtVgDcStctatatttattaaaaRKDatagaaagaKaaYYcaYSgKStctccSttac +agtcNactttDVttagaaagMHttRaNcSaRaMgBttattggtttaRMggatggcKDgWR +tNaataataWKKacttcKWaaagNaBttaBatMHtccattaacttccccYtcBcYRtaga +ttaagctaaYBDttaNtgaaaccHcaRMtKtaaHMcNBttaNaNcVcgVttWNtDaBatg +ataaVtcWKcttRggWatcattgaRagHgaattNtatttctctattaattaatgaDaaMa +tacgttgggcHaYVaaNaDDttHtcaaHtcVVDgBVagcMacgtgttaaBRNtatRtcag +taagaggtttaagacaVaaggttaWatctccgtVtaDtcDatttccVatgtacNtttccg +tHttatKgScBatgtVgHtYcWagcaKtaMYaaHgtaattaSaHcgcagtWNaatNccNN +YcacgVaagaRacttctcattcccRtgtgtaattagcSttaaStWaMtctNNcSMacatt +ataaactaDgtatWgtagtttaagaaaattgtagtNagtcaataaatttgatMMYactaa +tatcggBWDtVcYttcDHtVttatacYaRgaMaacaStaatcRttttVtagaDtcacWat +ttWtgaaaagaaagNRacDtttStVatBaDNtaactatatcBSMcccaSttccggaMatg +attaaWatKMaBaBatttgataNctgttKtVaagtcagScgaaaDggaWgtgttttKtWt +atttHaatgtagttcactaaKMagttSYBtKtaYgaactcagagRtatagtVtatcaaaW +YagcgNtaDagtacNSaaYDgatBgtcgataacYDtaaactacagWDcYKaagtttatta +gcatcgagttKcatDaattgattatDtcagRtWSKtcgNtMaaaaacaMttKcaWcaaSV +MaaaccagMVtaMaDtMaHaBgaacataBBVtaatVYaNSWcSgNtDNaaKacacBttta +tKtgtttcaaHaMctcagtaacgtcgYtactDcgcctaNgagagcYgatattttaaattt +ccattttacatttDaaRctattttWctttacgtDatYtttcagacgcaaVttagtaaKaa +aRtgVtccataBggacttatttgtttaWNtgttVWtaWNVDaattgtatttBaagcBtaa +BttaaVatcHcaVgacattccNggtcgacKttaaaRtagRtctWagaYggtgMtataatM +tgaaRttattttgWcttNtDRRgMDKacagaaaaggaaaRStcccagtYccVattaNaaK +StNWtgacaVtagaagcttSaaDtcacaacgDYacWDYtgtttKatcVtgcMaDaSKStV +cgtagaaWaKaagtttcHaHgMgMtctataagBtKaaaKKcactggagRRttaagaBaaN +atVVcgRcKSttDaactagtSttSattgttgaaRYatggttVttaataaHttccaagDtg +atNWtaagHtgcYtaactRgcaatgMgtgtRaatRaNaacHKtagactactggaatttcg +ccataacgMctRgatgttaccctaHgtgWaYcactcacYaattcttaBtgacttaaacct +gYgaWatgBttcttVttcgttWttMcNYgtaaaatctYgMgaaattacNgaHgaacDVVM +tttggtHtctaaRgtacagacgHtVtaBMNBgattagcttaRcttacaHcRctgttcaaD +BggttKaacatgKtttYataVaNattccgMcgcgtagtRaVVaattaKaatggttRgaMc +agtatcWBttNtHagctaatctagaaNaaacaYBctatcgcVctBtgcaaagDgttVtga +HtactSNYtaaNccatgtgDacgaVtDcgKaRtacDcttgctaagggcagMDagggtBWR +tttSgccttttttaacgtcHctaVtVDtagatcaNMaVtcVacatHctDWNaataRgcgt +aVHaggtaaaaSgtttMtattDgBtctgatSgtRagagYtctSaKWaataMgattRKtaa +catttYcgtaacacattRWtBtcggtaaatMtaaacBatttctKagtcDtttgcBtKYYB +aKttctVttgttaDtgattttcttccacttgSaaacggaaaNDaattcYNNaWcgaaYat +tttMgcBtcatRtgtaaagatgaWtgaccaYBHgaatagataVVtHtttVgYBtMctaMt +cctgaDcYttgtccaaaRNtacagcMctKaaaggatttacatgtttaaWSaYaKttBtag +DacactagctMtttNaKtctttcNcSattNacttggaacaatDagtattRtgSHaataat +gccVgacccgatactatccctgtRctttgagaSgatcatatcgDcagWaaHSgctYYWta +tHttggttctttatVattatcgactaagtgtagcatVgtgHMtttgtttcgttaKattcM +atttgtttWcaaStNatgtHcaaaDtaagBaKBtRgaBgDtSagtatMtaacYaatYtVc +KatgtgcaacVaaaatactKcRgtaYtgtNgBBNcKtcttaccttKgaRaYcaNKtactt +tgagSBtgtRagaNgcaaaNcacagtVtttHWatgttaNatBgtttaatNgVtctgaata +tcaRtattcttttttttRaaKcRStctcggDgKagattaMaaaKtcaHacttaataataK +taRgDtKVBttttcgtKaggHHcatgttagHggttNctcgtatKKagVagRaaaggaaBt +NatttVKcRttaHctaHtcaaatgtaggHccaBataNaNaggttgcWaatctgatYcaaa +HaatWtaVgaaBttagtaagaKKtaaaKtRHatMaDBtBctagcatWtatttgWttVaaa +ScMNattRactttgtYtttaaaagtaagtMtaMaSttMBtatgaBtttaKtgaatgagYg +tNNacMtcNRacMMHcttWtgtRtctttaacaacattattcYaMagBaacYttMatcttK +cRMtgMNccattaRttNatHaHNaSaaHMacacaVaatacaKaSttHatattMtVatWga +ttttttaYctttKttHgScWaacgHtttcaVaaMgaacagNatcgttaacaaaaagtaca +HBNaattgttKtcttVttaaBtctgctacgBgcWtttcaggacacatMgacatcccagcg +gMgaVKaBattgacttaatgacacacaaaaaatRKaaBctacgtRaDcgtagcVBaacDS +BHaaaaSacatatacagacRNatcttNaaVtaaaataHattagtaaaaSWccgtatWatg +gDttaactattgcccatcttHaSgYataBttBaactattBtcHtgatcaataSttaBtat +KSHYttWggtcYtttBttaataccRgVatStaHaKagaatNtagRMNgtcttYaaSaact +cagDSgagaaYtMttDtMRVgWKWtgMaKtKaDttttgactatacataatcNtatNaHat +tVagacgYgatatatttttgtStWaaatctWaMgagaRttRatacgStgattcttaagaD +taWccaaatRcagcagaaNKagtaaDggcgccBtYtagSBMtactaaataMataBSacRM +gDgattMMgtcHtcaYDtRaDaacggttDaggcMtttatgttaNctaattaVacgaaMMt +aatDccSgtattgaRtWWaccaccgagtactMcgVNgctDctaMScatagcgtcaactat +acRacgHRttgctatttaatgaattataYKttgtaagWgtYttgcHgMtaMattWaWVta +RgcttgYgttBHtYataSccStBtgtagMgtDtggcVaaSBaatagDttgBgtctttctc +attttaNagtHKtaMWcYactVcgcgtatMVtttRacVagDaatcttgctBBcRDgcaac +KttgatSKtYtagBMagaRtcgBattHcBWcaactgatttaatttWDccatttatcgagS +KaWttataHactaHMttaatHtggaHtHagaatgtKtaaRactgtttMatacgatcaagD +gatKaDctataMggtHDtggHacctttRtatcttYattttgacttgaaSaataaatYcgB +aaaaccgNatVBttMacHaKaataagtatKgtcaagactcttaHttcggaattgttDtct +aaccHttttWaaatgaaatataaaWattccYDtKtaaaacggtgaggWVtctattagtga +ctattaagtMgtttaagcatttgSgaaatatccHaaggMaaaattttcWtatKctagDtY +tMcctagagHcactttactatacaaacattaacttaHatcVMYattYgVgtMttaaRtga +aataaDatcaHgtHHatKcDYaatcttMtNcgatYatgSaMaNtcttKcWataScKggta +tcttacgcttWaaagNatgMgHtctttNtaacVtgttcMaaRatccggggactcMtttaY +MtcWRgNctgNccKatcttgYDcMgattNYaRagatHaaHgKctcataRDttacatBatc +cattgDWttatttaWgtcggagaaaaatacaatacSNtgggtttccttacSMaagBatta +caMaNcactMttatgaRBacYcYtcaaaWtagctSaacttWgDMHgaggatgBVgcHaDt +ggaactttggtcNatNgtaKaBcccaNtaagttBaacagtatacDYttcctNgWgcgSMc +acatStctHatgRcNcgtacacaatRttMggaNKKggataaaSaYcMVcMgtaMaHtgat +tYMatYcggtcttcctHtcDccgtgRatcattgcgccgatatMaaYaataaYSggatagc +gcBtNtaaaScaKgttBgagVagttaKagagtatVaactaSacWactSaKatWccaKaaa +atBKgaaKtDMattttgtaaatcRctMatcaaMagMttDgVatggMaaWgttcgaWatga +aatttgRtYtattaWHKcRgctacatKttctaccaaHttRatctaYattaaWatVNccat +NgagtcKttKataStRaatatattcctRWatDctVagttYDgSBaatYgttttgtVaatt +taatagcagMatRaacttBctattgtMagagattaaactaMatVtHtaaatctRgaaaaa +aaatttWacaacaYccYDSaattMatgaccKtaBKWBattgtcaagcHKaagttMMtaat +ttcKcMagNaaKagattggMagaggtaatttYacatcWaaDgatMgKHacMacgcVaaca +DtaDatatYggttBcgtatgWgaSatttgtagaHYRVacaRtctHaaRtatgaactaata +tctSSBgggaaHMWtcaagatKgagtDaSatagttgattVRatNtctMtcSaagaSHaat +aNataataRaaRgattctttaataaagWaRHcYgcatgtWRcttgaaggaMcaataBRaa +ccagStaaacNtttcaatataYtaatatgHaDgcStcWttaacctaRgtYaRtataKtgM +ttttatgactaaaatttacYatcccRWtttHRtattaaatgtttatatttgttYaatMca +RcSVaaDatcgtaYMcatgtagacatgaaattgRtcaaYaaYtRBatKacttataccaNa +aattVaBtctggacaagKaaYaaatatWtMtatcYaaVNtcgHaactBaagKcHgtctac +aatWtaDtSgtaHcataHtactgataNctRgttMtDcDttatHtcgtacatcccaggStt +aBgtcacacWtccNMcNatMVaVgtccDYStatMaccDatggYaRKaaagataRatttHK +tSaaatDgataaacttaHgttgVBtcttVttHgDacgaKatgtatatNYataactctSat +atatattgcHRRYttStggaactHgttttYtttaWtatMcttttctatctDtagVHYgMR +BgtHttcctaatYRttKtaagatggaVRataKDctaMtKBNtMtHNtWtttYcVtattMc +gRaacMcctNSctcatttaaagDcaHtYccSgatgcaatYaaaaDcttcgtaWtaattct +cgttttScttggtaatctttYgtctaactKataHacctMctcttacHtKataacacagcN +RatgKatttttSaaatRYcgDttaMRcgaaattactMtgcgtaagcgttatBtttttaat +taagtNacatHgttcRgacKcBBtVgatKttcgaBaatactDRgtRtgaNacWtcacYtt +aaKcgttctHaKttaNaMgWgWaggtctRgaKgWttSttBtDcNtgtttacaaatYcDRt +gVtgcctattcNtctaaaDMNttttNtggctgagaVctDaacVtWccaagtaacacaNct +gaScattccDHcVBatcgatgtMtaatBgHaatDctMYgagaatgYWKcctaatNaStHa +aaKccgHgcgtYaaYtattgtStgtgcaaRtattaKatattagaWVtcaMtBagttatta +gNaWHcVgcaattttDcMtgtaRHVYtHtctgtaaaaHVtMKacatcgNaatttMatatg +ttgttactagWYtaRacgataKagYNKcattataNaRtgaacKaYgcaaYYacaNccHat +MatDcNgtHttRaWttagaaDcaaaaaatagggtKDtStaDaRtaVtHWKNtgtattVct +SVgRgataDaRaWataBgaagaaKtaataaYgDcaStaNgtaDaaggtattHaRaWMYaY +aWtggttHYgagVtgtgcttttcaaDKcagVcgttagacNaaWtagtaataDttctggtt +VcatcataaagtgKaaaNaMtaBBaattaatWaattgctHaVKaSgDaaVKaHtatatat +HatcatSBagNgHtatcHYMHgttDgtaHtBttWatcgtttaRaattgStKgSKNWKatc +agDtctcagatttctRtYtBatBgHHtKaWtgYBgacVVWaKtacKcDttKMaKaVcggt +gttataagaataaHaatattagtataatMHgttYgaRttagtaRtcaaVatacggtcMcg +agtaaRttacWgactKRYataaaagSattYaWgagatYagKagatgSaagKgttaatMgg +tataatgttWYttatgagaaacctNVataatHcccKtDctcctaatactggctHggaSag +gRtKHaWaattcgSatMatttagaggcYtctaMcgctcataSatatgRagacNaaDagga +VBagaYttKtacNaKgtSYtagttggaWcatcWttaatctatgaVtcgtgtMtatcaYcg +tRccaaYgDctgcMgtgtWgacWtgataacacgcgctBtgttaKtYDtatDcatcagKaV +MctaatcttgVcaaRgcRMtDcgattaHttcaNatgaatMtactacVgtRgatggaWttt +actaaKatgagSaaKggtaNtactVaYtaaKRagaacccacaMtaaMtKtatBcttgtaa +WBtMctaataaVcDaaYtcRHBtcgttNtaaHatttBNgRStVDattBatVtaagttaYa +tVattaagaBcacggtSgtVtatttaRattgatgtaHDKgcaatattKtggcctatgaWD +KRYcggattgRctatNgatacaatMNttctgtcRBYRaaaHctNYattcHtaWcaattct +BtMKtVgYataatMgYtcagcttMDataVtggRtKtgaatgccNcRttcaMtRgattaac +attRcagcctHtWMtgtDRagaKaBtgDttYaaaaKatKgatctVaaYaacWcgcatagB +VtaNtRtYRaggBaaBtgKgttacataagagcatgtRattccacttaccatRaaatgWgD +aMHaYVgVtaSctatcgKaatatattaDgacccYagtgtaYNaaatKcagtBRgagtcca +tgKgaaaccBgaagBtgSttWtacgatWHaYatcgatttRaaNRgcaNaKVacaNtDgat +tgHVaatcDaagcgtatgcNttaDataatcSataaKcaataaHWataBtttatBtcaKtK +tatagttaDgSaYctacaRatNtaWctSaatatttYaKaKtaccWtatcRagacttaYtt +VcKgSDcgagaagatccHtaattctSttatggtKYgtMaHagVaBRatttctgtRgtcta +tgggtaHKgtHacHtSYacgtacacHatacKaaBaVaccaDtatcSaataaHaagagaat +ScagactataaRttagcaaVcaHataKgDacatWccccaagcaBgagWatctaYttgaaa +tctVNcYtttWagHcgcgcDcVaaatgttKcHtNtcaatagtgtNRaactttttcaatgg +WgBcgDtgVgtttctacMtaaataaaRggaaacWaHttaRtNtgctaaRRtVBctYtVta +tDcattDtgaccYatagatYRKatNYKttNgcctagtaWtgaactaMVaacctgaStttc +tgaKVtaaVaRKDttVtVctaDNtataaaDtccccaagtWtcgatcactDgYaBcatcct +MtVtacDaaBtYtMaKNatNtcaNacgDatYcatcgcaRatWBgaacWttKttagYtaat +tcggttgSWttttDWctttacYtatatWtcatDtMgtBttgRtVDggttaacYtacgtac +atgaattgaaWcttMStaDgtatattgaDtcRBcattSgaaVBRgagccaaKtttcDgcg +aSMtatgWattaKttWtgDBMaggBBttBaatWttRtgcNtHcgttttHtKtcWtagHSt +aacagttgatatBtaWSaWggtaataaMttaKacDaatactcBttcaatatHttcBaaSa +aatYggtaRtatNtHcaatcaHtagVtgtattataNggaMtcttHtNagctaaaggtaga +YctMattNaMVNtcKtactBKcaHHcBttaSagaKacataYgctaKaYgttYcgacWVtt +WtSagcaacatcccHaccKtcttaacgaKttcacKtNtacHtatatRtaaatacactaBt +ttgaHaRttggttWtatYagcatYDatcggagagcWBataagRtacctataRKgtBgatg +aDatataSttagBaHtaatNtaDWcWtgtaattacagKttcNtMagtattaNgtctcgtc +ctcttBaHaKcKccgtRcaaYagSattaagtKataDatatatagtcDtaacaWHcaKttD +gaaRcgtgYttgtcatatNtatttttatggccHtgDtYHtWgttatYaacaattcaWtat +NgctcaaaSttRgctaatcaaatNatcgtttaBtNNVtgttataagcaaagattBacgtD +atttNatttaaaDcBgtaSKgacgtagataatttcHMVNttgttBtDtgtaWKaaRMcKM +tHtaVtagataWctccNNaSWtVaHatctcMgggDgtNHtDaDttatatVWttgttattt +aacctttcacaaggaSaDcggttttttatatVtctgVtaacaStDVaKactaMtttaSNa +gtgaaattaNacttSKctattcctctaSagKcaVttaagNaVcttaVaaRNaHaaHttat +gtHttgtgatMccaggtaDcgaccgtWgtWMtttaHcRtattgScctatttKtaaccaag +tYagaHgtWcHaatgccKNRtttagtMYSgaDatctgtgaWDtccMNcgHgcaaacNDaa +aRaStDWtcaaaaHKtaNBctagBtgtattaactaattttVctagaatggcWSatMaccc +ttHttaSgSgtgMRcatRVKtatctgaaaccDNatYgaaVHNgatMgHRtacttaaaRta +tStRtDtatDttYatattHggaBcttHgcgattgaKcKtttcRataMtcgaVttWacatN +catacctRataDDatVaWNcggttgaHtgtMacVtttaBHtgagVttMaataattatgtt +cttagtttgtgcDtSatttgBtcaacHattaaBagVWcgcaSYttMgcttacYKtVtatc +aYaKctgBatgcgggcYcaaaaacgNtctagKBtattatctttKtaVttatagtaYtRag +NtaYataaVtgaatatcHgcaaRataHtacacatgtaNtgtcgYatWMatttgaactacR +ctaWtWtatacaatctBatatgYtaagtatgtgtatSttactVatcttYtaBcKgRaSgg +RaaaaatgcagtaaaWgtaRgcgataatcBaataccgtatttttccatcNHtatWYgatH +SaaaDHttgctgtccHtggggcctaataatttttctatattYWtcattBtgBRcVttaVM +RSgctaatMagtYtttaaaaatBRtcBttcaaVtaacagctccSaaSttKNtHtKYcagc +agaaaccccRtttttaaDcDtaStatccaagcgctHtatcttaDRYgatDHtWcaaaBcW +gKWHttHataagHacgMNKttMKHccaYcatMVaacgttaKgYcaVaaBtacgcaacttt +MctaaHaatgtBatgagaSatgtatgSRgHgWaVWgataaatatttccKagVgataattW +aHNcYggaaatgctHtKtaDtctaaagtMaatVDVactWtSaaWaaMtaHtaSKtcBRaN +cttStggtBttacNagcatagRgtKtgcgaacaacBcgKaatgataagatgaaaattgta +ctgcgggtccHHWHaaNacaBttNKtKtcaaBatatgctaHNgtKcDWgtttatNgVDHg +accaacWctKaaggHttgaRgYaatHcaBacaatgagcaaattactgtaVaaYaDtagat +tgagNKggtggtgKtWKaatacagDRtatRaMRtgattDggtcaaYRtatttNtagaDtc +acaaSDctDtataatcgtactaHttatacaatYaacaaHttHatHtgcgatRRttNgcat +SVtacWWgaaggagtatVMaVaaattScDDKNcaYBYaDatHgtctatBagcaacaagaa +tgagaaRcataaKNaRtBDatcaaacgcattttttaaBtcSgtacaRggatgtMNaattg +gatatWtgagtattaaaVctgcaYMtatgatttttYgaHtgtcttaagWBttHttgtctt +attDtcgtatWtataataSgctaHagcDVcNtaatcaagtaBDaWaDgtttagYctaNcc +DtaKtaHcttaataacccaRKtacaVaatNgcWRaMgaattatgaBaaagattVYaHMDc +aDHtcRcgYtcttaaaWaaaVKgatacRtttRRKYgaatacaWVacVcRtatMacaBtac +tggMataaattttHggNagSctacHgtBagcgtcgtgattNtttgatSaaggMttctttc +ttNtYNagBtaaacaaatttMgaccttacataattgYtcgacBtVMctgStgMDtagtaR +ctHtatgttcatatVRNWataDKatWcgaaaaagttaaaagcacgHNacgtaatctttMR +tgacttttDacctataaacgaaatatgattagaactccSYtaBctttaataacWgaaaYa +tagatgWttcatKtNgatttttcaagHtaYgaaRaDaagtaggagcttatVtagtctttc +attaaaatcgKtattaRttacagVaDatgcatVgattgggtctttHVtagKaaRBtaHta +aggccccaaaaKatggtttaMWgtBtaaacttcactttKHtcgatctccctaYaBacMgt +cttBaBaNgcgaaacaatctagtHccHtKttcRtRVttccVctttcatacYagMVtMcag +aMaaacaataBctgYtaatRaaagattaaccatVRatHtaRagcgcaBcgDttStttttc +VtttaDtKgcaaWaaaaatSccMcVatgtKgtaKgcgatatgtagtSaaaDttatacaaa +catYaRRcVRHctKtcgacKttaaVctaDaatgttMggRcWaacttttHaDaKaDaBctg +taggcgtttaHBccatccattcNHtDaYtaataMttacggctNVaacDattgatatttta +cVttSaattacaaRtataNDgacVtgaacataVRttttaDtcaaacataYDBtttaatBa +DtttYDaDaMccMttNBttatatgagaaMgaNtattHccNataattcaHagtgaaggDga +tgtatatatgYatgaStcataaBStWacgtcccataRMaaDattggttaaattcMKtctM +acaBSactcggaatDDgatDgcWctaacaccgggaVcacWKVacggtaNatatacctMta +tgatagtgcaKagggVaDtgtaacttggagtcKatatcgMcttRaMagcattaBRaStct +YSggaHYtacaactMBaagDcaBDRaaacMYacaHaattagcattaaaHgcgctaaggSc +cKtgaaKtNaBtatDDcKBSaVtgatVYaagVtctSgMctacgttaacWaaattctSgtD +actaaStaaattgcagBBRVctaatatacctNttMcRggctttMttagacRaHcaBaacV +KgaataHttttMgYgattcYaNRgttMgcVaaacaVVcDHaatttgKtMYgtatBtVVct +WgVtatHtacaaHttcacgatagcagtaaNattBatatatttcVgaDagcggttMaagtc +ScHagaaatgcYNggcgtttttMtStggtRatctacttaaatVVtBacttHNttttaRca +aatcacagHgagagtMgatcSWaNRacagDtatactaaDKaSRtgattctccatSaaRtt +aaYctacacNtaRtaactggatgaccYtacactttaattaattgattYgttcagDtNKtt +agDttaaaaaaaBtttaaNaYWKMBaaaacVcBMtatWtgBatatgaacVtattMtYatM +NYDKNcKgDttDaVtaaaatgggatttctgtaaatWtctcWgtVVagtcgRgacttcccc +taDcacagcRcagagtgtWSatgtacatgttaaSttgtaaHcgatgggMagtgaacttat +RtttaVcaccaWaMgtactaatSSaHtcMgaaYtatcgaaggYgggcgtgaNDtgttMNg +aNDMtaattcgVttttaacatgVatgtWVMatatcaKgaaattcaBcctccWcttgaaWH +tWgHtcgNWgaRgctcBgSgaattgcaaHtgattgtgNagtDttHHgBttaaWcaaWagc +aSaHHtaaaVctRaaMagtaDaatHtDMtcVaWMtagSagcttHSattaacaaagtRacM +tRtctgttagcMtcaBatVKtKtKacgagaSNatSactgtatatcBctgagVtYactgta +aattaaaggcYgDHgtaacatSRDatMMccHatKgttaacgactKtgKagtcttcaaHRV +tccttKgtSataatttacaactggatDNgaacttcaRtVaagDcaWatcBctctHYatHa +DaaatttagYatSatccaWtttagaaatVaacBatHcatcgtacaatatcgcNYRcaata +YaRaYtgattVttgaatgaVaactcRcaNStgtgtattMtgaggtNttBaDRcgaaaagc +tNgBcWaWgtSaDcVtgVaatMKBtttcgtttctaaHctaaagYactgMtatBDtcStga +ccgtSDattYaataHctgggaYYttcggttaWaatctggtRagWMaDagtaacBccacta +cgHWMKaatgatWatcctgHcaBaSctVtcMtgtDttacctaVgatYcWaDRaaaaRtag +atcgaMagtggaRaWctctgMgcWttaagKBRtaaDaaWtctgtaagYMttactaHtaat +cttcataacggcacBtSgcgttNHtgtHccatgttttaaagtatcgaKtMttVcataYBB +aKtaMVaVgtattNDSataHcagtWMtaggtaSaaKgttgBtVtttgttatcatKcgHac +acRtctHatNVagSBgatgHtgaRaSgttRcctaacaaattDNttgacctaaYtBgaaaa +tagttattactcttttgatgtNNtVtgtatMgtcttRttcatttgatgacacttcHSaaa +ccaWWDtWagtaRDDVNacVaRatgttBccttaatHtgtaaacStcVNtcacaSRttcYa +gacagaMMttttgMcNttBcgWBtactgVtaRttctccaaYHBtaaagaBattaYacgat +ttacatctgtaaMKaRYtttttactaaVatWgctBtttDVttctggcDaHaggDaagtcg +aWcaagtagtWttHtgKtVataStccaMcWcaagataagatcactctHatgtcYgaKcat +cagatactaagNSStHcctRRNtattgtccttagttagMVgtatagactaactctVcaat +MctgtttgtgttgccttatWgtaBVtttctggMcaaKgDWtcgtaaYStgSactatttHg +atctgKagtagBtVacRaagRtMctatgggcaaaKaaaatacttcHctaRtgtDcttDat +taggaaatttcYHaRaaBttaatggcacKtgctHVcaDcaaaVDaaaVcgMttgtNagcg +taDWgtcgttaatDgKgagcSatatcSHtagtagttggtgtHaWtaHKtatagctgtVga +ttaBVaatgaataagtaatVatSttaHctttKtttgtagttaccttaatcgtagtcctgB +cgactatttVcMacHaaaggaatgDatggKtaHtgStatattaaSagctWcctccRtata +BaDYcgttgcNaagaggatRaaaYtaWgNtSMcaatttactaacatttaaWttHtatBat +tgtcgacaatNgattgcNgtMaaaKaBDattHacttggtRtttaYaacgVactBtaBaKt +gBttatgVttgtVttcaatcWcNctDBaaBgaDHacBttattNtgtDtatttVSaaacag +gatgcRatSgtaSaNtgBatagttcHBgcBBaaattaHgtDattatDaKaatBaaYaaMa +ataaataKtttYtagtBgMatNcatgtttgaNagtgttgtgKaNaSagtttgaSMaYBca +aaacDStagttVacaaaaactaaWttBaagtctgtgcgtMgtaattctcctacctcaNtt +taaccaaaaVtBcacataacaccccBcWMtatVtggaatgaWtcaaWaaaaaaaaWtDta +atatRcctDWtcctaccMtVVatKttaWaaKaaatataaagScHBagaggBaSMtaWaVt +atattactSaaaKNaactatNatccttgaYctattcaaaVgatttYHcRagattttaSat +aggttattcVtaaagaKgtattattKtRttNcggcRgtgtgtWYtaacHgKatKgatYta +cYagDtWcHBDctctgRaYKaYagcactKcacSaRtBttttBHKcMtNtcBatttatttt +tgSatVgaaagaWtcDtagDatatgMacaacRgatatatgtttgtKtNRaatatNatgYc +aHtgHataacKtgagtagtaacYttaNccaaatHcacaacaVDtagtaYtccagcattNt +acKtBtactaaagaBatVtKaaHBctgStgtBgtatgaSNtgDataaccctgtagcaBgt +gatcttaDataStgaMaccaSBBgWagtacKcgattgaDgNNaaaacacagtSatBacKD +gcgtataBKcatacactaSaatYtYcDaactHttcatRtttaatcaattataRtttgtaa +gMcgNttcatcBtYBagtNWNMtSHcattcRctttttRWgaKacKttgggagBcgttcgc +MaWHtaatactgtctctatttataVgtttaBScttttaBMaNaatMacactYtBMggtHa +cMagtaRtctgcatttaHtcaaaatttgagKtgNtactBacaHtcgtatttctMaSRagc +agttaatgtNtaaattgagagWcKtaNttagVtacgatttgaatttcgRtgtWcVatcgt +taaDVctgtttBWgaccagaaagtcSgtVtatagaBccttttcctaaattgHtatcggRa +ttttcaaggcYSKaagWaWtRactaaaacccBatMtttBaatYtaagaactSttcgaaSc +aatagtattgaccaagtgttttctaacatgtttNVaatcaaagagaaaNattaaRtttta +VaaaccgcaggNMtatattVctcaagaggaacgBgtttaacaagttcKcYaatatactaa +ccBaaaSggttcNtattctagttRtBacgScVctcaatttaatYtaaaaaaatgSaatga +tagaMBRatgRcMcgttgaWHtcaVYgaatYtaatctttYttatRaWtctgBtDcgatNa +tcKaBaDgatgtaNatWKctccgatattaacattNaaacDatgBgttctgtDtaaaMggt +gaBaSHataacgccSctaBtttaRBtcNHcDatcDcctagagtcRtaBgWttDRVHagat +tYatgtatcWtaHtttYcattWtaaagtctNgtStggRNcgcggagSSaaagaaaatYcH +DtcgctttaatgYcKBVSgtattRaYBaDaaatBgtatgaHtaaRaRgcaSWNtagatHa +acttNctBtcaccatctMcatattccaSatttgcgaDagDgtatYtaaaVDtaagtttWV +aagtagYatRttaagDcNgacKBcScagHtattatcDaDactaaaaaYgHttBcgaDttg +gataaaKSRcBMaBcgaBSttcWtgNBatRaccgattcatttataacggHVtaattcaca +agagVttaaRaatVVRKcgWtVgacctgDgYaaHaWtctttcacMagggatVgactagMa +aataKaaNWagKatagNaaWtaaaatttgaattttatttgctaaVgaHatBatcaaBWcB +gttcMatcgBaaNgttcgSNaggSaRtttgHtRtattaNttcDcatSaVttttcgaaaaa +ttgHatctaRaggSaNatMDaaatDcacgattttagaHgHaWtYgattaatHNSttatMS +gggNtcKtYatRggtttgtMWVtttaYtagcagBagHaYagttatatggtBacYcattaR +SataBatMtttaaatctHcaaaSaaaagttNSaaWcWRccRtKaagtBWtcaaattSttM +tattggaaaccttaacgttBtWatttatatWcDaatagattcctScacctaagggRaaYt +aNaatgVtBcttaaBaacaMVaaattatStYgRcctgtactatcMcVKatttcgSgatRH +MaaaHtagtaaHtVgcaaataatatcgKKtgccaatBNgaaWcVttgagttaKatagttc +aggKDatDtattgaKaVcaKtaataDataataHSaHcattagttaatRVYcNaHtaRcaa +ggtNHcgtcaaccaBaaagYtHWaaaRcKgaYaaDttgcWYtataRgaatatgtYtgcKt +aNttWacatYHctRaDtYtattcBttttatcSataYaYgttWaRagcacHMgtttHtYtt +YaatcggtatStttcgtRSattaaDaKMaatatactaNBaWgctacacYtgaYVgtgHta +aaRaaRgHtagtWattataaaSDaaWtgMattatcgaaaagtaYRSaWtSgNtBgagcRY +aMDtactaacttaWgtatctagacaagNtattHggataatYttYatcataDcgHgttBtt +ctttVttgccgaaWtaaaacgKgtatctaaaaaNtccDtaDatBMaMggaatNKtatBaa +atVtccRaHtaSacataHattgtttKVYattcataVaattWtcgtgMttcttKtgtctaa +cVtatctatatBRataactcgKatStatattcatHHRttKtccaacgtgggtgRgtgaMt +attattggctatcgtgacMtRcBDtcttgtactaatRHttttaagatcgVMDStattatY +BtttDttgtBtNttgRcMtYtgBacHaWaBaatDKctaagtgaaactaatgRaaKgatcc +aagNaaaatattaggWNtaagtatacttttKcgtcggSYtcttgRctataYcttatataa +agtatattaatttataVaacacaDHatctatttttKYVatHRactttaBHccaWagtact +BtcacgaVgcgttRtttttttSVgtSagtBaaattctgaHgactcttgMcattttagVta +agaattHctHtcaDaaNtaacRggWatagttcgtSttgaDatcNgNagctagDgatcNtt +KgttgtaDtctttRaaYStRatDtgMggactSttaDtagSaVtBDttgtDgccatcacaM +attaaaMtNacaVcgSWcVaaDatcaHaatgaattaMtatccVtctBtaattgtWattat +BRcWcaatgNNtactWYtDaKttaaatcactcagtRaaRgatggtKgcgccaaHgaggat +StattYcaNMtcaBttacttatgagDaNtaMgaaWtgtttcttctaHtMNgttatctaWW +atMtBtaaatagDVatgtBYtatcggcttaagacMRtaHScgatatYgRDtcattatSDa +HggaaataNgaWSRRaaaBaatagBattaDctttgHWNttacaataaaaaaatacggttt +gHgVtaHtWMttNtBtctagtMcgKMgHgYtataHaNagWtcaacYattaataYRgtaWK +gaBctataaccgatttaHaNBRaRaMtccggtNgacMtctcatttgcaattcWgMactta +caaDaaNtactWatVtttagccttMaatcagVaagtctVaaDaBtattaattaYtNaYtg +gattaKtaKctYaMtattYgatattataatKtVgDcttatatNBtcgttgtStttttMag +aggttaHYSttcKgtcKtDNtataagttataagSgttatDtRttattgttttSNggRtca +aKMNatgaatattgtBWtaMacctgggYgaSgaagYataagattacgagaatBtggtRcV +HtgYggaDgaYaKagWagctatagacgaaHgtWaNgacttHRatVaWacKYtgRVNgVcS +gRWctacatcKSactctgWYtBggtataagcttNRttVtgRcaWaaatDMatYattaact +ttcgaagRatSctgccttgcRKaccHtttSNVagtagHagBagttagaccaRtataBcca +taatSHatRtcHagacBWatagcaMtacaRtgtgaaBatctKRtScttccaNaatcNgta +atatWtcaMgactctBtWtaaNactHaaaaRctcgcatggctMcaaNtcagaaaaacaca +gtggggWttRttagtaagaVctVMtcgaatcttcMaaaHcaHBttcgattatgtcaDagc +YRtBtYcgacMgtDcagcgaNgttaataatagcagKYYtcgtaBtYctMaRtaRtDagaa +aacacatgYaBttgattattcgaaNttBctSataaMataWRgaHtttccgtDgaYtatgg +tDgHKgMtatttVtMtVagttaRatMattRagataaccctKctMtSttgaHagtcStcta +tttccSagatgttccacgaggYNttHRacgattcDatatDcataaaatBBttatcgaHtN +HaaatatDNaggctgaNcaaggagttBttMgRagVatBcRtaWgatgBtSgaKtcgHttt +gaatcaaDaHttcSBgHcagtVaaSttDcagccgttNBtgttHagYtattctttRWaaVt +SttcatatKaaRaaaNacaVtVctMtSDtDtRHRcgtaatgctcttaaatSacacaatcg +HattcaWcttaaaatHaaatcNctWttaNMcMtaKctVtcctaagYgatgatcYaaaRac +tctaRDaYagtaacgtDgaggaaatctcaaacatcaScttcKttNtaccatNtaNataca +tttHaaDHgcaDatMWaaBttcRggctMaagctVYcacgatcaDttatYtaatcKatWat +caatVYtNagatttgattgaYttttYgacttVtcKaRagaaaHVgDtaMatKYagagttN +atWttaccNtYtcDWgSatgaRgtMatgKtcgacaagWtacttaagtcgKtgatccttNc +ttatagMatHVggtagcgHctatagccctYttggtaattKNaacgaaYatatVctaataM +aaaYtgVtcKaYtaataacagaatHcacVagatYWHttagaaSMaatWtYtgtaaagNaa +acaVgaWtcacNWgataNttcaSagctMDaRttgNactaccgataMaaatgtttattDtc +aagacgctDHYYatggttcaagccNctccttcMctttagacBtaaWtaWVHggaaaaNat +ttaDtDtgctaaHHtMtatNtMtagtcatttgcaaaRatacagRHtatDNtgtDgaatVg +tVNtcaaatYBMaaaagcaKgtgatgatMgWWMaHttttMgMagatDtataaattaacca +actMtacataaattgRataatacgBtKtaataattRgtatDagDtcRDacctatRcagag +cSHatNtcaScNtttggacNtaaggaccgtgKNttgttNcttgaaRgYgRtNtcagttBc +ttttcHtKtgcttYaaNgYagtaaatgaatggWaMattBHtatctatSgtcYtgcHtaat +tHgaaMtHcagaaSatggtatgccaHBtYtcNattWtgtNgctttaggtttgtWatNtgH +tgcDttactttttttgcNtactKtWRaVcttcatagtgSNKaNccgaataaBttataata +YtSagctttaaatSttggctaaKSaatRccgWHgagDttaaatcatgagMtcgagtVtaD +ggaBtatttgDacataaacgtagYRagBWtgDStKDgatgaagttcattatttaKWcata +aatWRgatataRgttRacaaNKttNtKagaaYaStaactScattattaacgatttaaatg +DtaattagatHgaYataaactatggggatVHtgccgtNgatNYcaStRtagaccacWcaM +tatRagHgVactYtWHtcttcatgatWgagaKggagtatgaWtDtVtNaNtcgYYgtaaa +ctttaDtBactagtaDctatagtaatatttatatataacgHaaaRagKattSagttYtSt +> +THREE +Homo +sapiens +frequency +agagagacgatgaaaattaatcgtcaatacgctggcgaacactgagggggacccaatgct +cttctcggtctaaaaaggaatgtgtcagaaattggtcagttcaaaagtagaccggatctt +tgcggagaacaattcacggaacgtagcgttgggaaatatcctttctaccacacatcggat +tttcgccctctcccattatttattgtgttctcacatagaattattgtttagacatccctc +gttgtatggagagttgcccgagcgtaaaggcataatccatataccgccgggtgagtgacc +tgaaattgtttttagttgggatttcgctatggattagcttacacgaagagattctaatgg +tactataggataattataatgctgcgtggcgcagtacaccgttacaaacgtcgttcgcat +atgtggctaacacggtgaaaatacctacatcgtatttgcaatttcggtcgtttcatagag +cgcattgaattactcaaaaattatatatgttgattatttgattagactgcgtggaaagaa +ggggtactcaagccatttgtaaaagctgcatctcgcttaagtttgagagcttacattagt +ctatttcagtcttctaggaaatgtctgtgtgagtggttgtcgtccataggtcactggcat +atgcgattcatgacatgctaaactaagaaagtagattactattaccggcatgcctaatgc +gattgcactgctatgaaggtgcggacgtcgcgcccatgtagccctgataataccaatact +tacatttggtcagcaattctgacattatacctagcacccataaatttactcagacttgag +gacaggctcttggagtcgatcttctgtttgtatgcatgtgatcatatagatgaataagcg +atgcgactagttagggcatagtatagatctgtgtatacagttcagctgaacgtccgcgag +tggaagtacagctgagatctatcctaaaatgcaaccatatcgttcacacatgatatgaac +ccagggggaaacattgagttcagttaaattggcagcgaatcccccaagaagaaggcggag +tgacgttgaacgggcttatggtttttcagtacttcctccgtataagttgagcgaaatgta +aacagaataatcgttgtgttaacaacattaaaatcgcggaatatgatgagaatacacagt +gtgagcatttcacttgtaaaatatctttggtagaacttactttgctttaaatatgttaaa +ccgatctaataatctacaaaacggtagattttgcctagcacattgcgtccttctctattc +agatagaggcaatactcagaaggttttatccaaagcactgtgttgactaacctaagtttt +agtctaataatcatgattgattataggtgccgtggactacatgactcgtccacaaataat +acttagcagatcagcaattggccaagcacccgacttttatttaatggttgtgcaatagtc +cagattcgtattcgggactctttcaaataatagtttcctggcatctaagtaagaaaagct +cataaggaagcgatattatgacacgctcttccgccgctgttttgaaacttgagtattgct +cgtccgaaattgagggtcacttcaaaatttactgagaagacgaagatcgactaaagttaa +aatgctagtccacagttggtcaagttgaattcatccacgagttatatagctattttaatt +tatagtcgagtgtacaaaaaacatccacaataagatttatcttagaataacaacccccgt +atcatcgaaatcctccgttatggcctgactcctcgagcttatagcatttgtgctggcgct +cttgccaggaacttgctcgcgaggtggtgacgagtgagatgatcagtttcattatgatga +tacgattttatcgcgactagttaatcatcatagcaagtaaaatttgaattatgtcattat +catgctccattaacaggttatttaattgatactgacgaaattttttcacaatgggttttc +tagaatttaatatcagtaattgaagccttcataggggtcctactagtatcctacacgacg +caggtccgcagtatcctggagggacgtgttactgattaaaagggtcaaaggaatgaaggc +tcacaatgttacctgcttcaccatagtgagccgatgagttttacattagtactaaatccc +aaatcatactttacgatgaggcttgctagcgctaaagagaatacatacaccaccacatag +aattgttagcgatgatatcaaatagactcctggaagtgtcagggggaaactgttcaatat +ttcgtccacaggactgaccaggcatggaaaagactgacgttggaaactataccatctcac +gcccgacgcttcactaattgatgatccaaaaaatatagcccggattcctgattagcaaag +ggttcacagagaaagatattatcgacgtatatcccaaaaaacagacgtaatgtgcatctt +cgaatcgggatgaatacttgtatcataaaaatgtgacctctagtatacaggttaatgtta +gtgatacacaatactcgtgggccatgggttctcaaataaaatgtaatattgcgtcgatca +ctcacccacgtatttggtctaattatgttttatttagtgacaatccaatagataaccggt +cctattaagggctatatttttagcgaccacgcgtttaaacaaaggattgtatgtagatgg +taccagtttaattgccagtgggcaatcctaagcaaaatgagattctatcctaaagtttgg +gcttgatataagatttcggatgtatgggttttataatcgttggagagctcaatcatgagc +taatacatggatttcgctacctcaccgagagaccttgcatgaagaattctaaccaaaagt +ttaataggccggattggattgagttaattaagaccttgttcagtcatagtaaaaaccctt +aaattttaccgattgacaaagtgagcagtcgcaataccctatgcgaaacgcctcgatagt +gactaggtatacaaggtttttgagttcctttgaaatagttaactaatttaaaattaatta +acgacatggaaatcacagaacctaatgctttgtaggagttatttatgctgtttactgcct +ctacaaccctaataaagcagtcctaagaatgaaacgcatcttttagttcagaaagtggta +tccagggtggtcaatttaataaattcaacatcgggtctcaggatattcggtcatataatt +tattaagggctcttcgagtcttactctgagtgaaattggaaacagtcatccttttcgttg +tgaggcatcttacaccgctatcgatatacaatgcattccaccgcggtgtcccgtacacaa +ggaaacttgttaccttggggatataagaaaactcacacgtctcattattaaactgagtac +aatttttgcacgagaaagtaatgcaatacaatatgatgaaagccagctaatgaaaaggga +tggaacgcacctcggatctgttgcactggattaaaatccgattatttttaaaaatattca +gtgctagagcatatcaggtctacttttttatctggtatgtaaagcccacggagcgatagt +gagatccttacgactcaacgaaaagttataacataactcccgttagccaaagcccaatcc +cgattactgccctaccctaacgtctgccatctaaatatcgaacttgttatgatcaatgtg +actacctcccaccctttccccttcatttgttccactggggataagctagcgttttcagaa +tcaatgcaataagaatagccaattgtctcacttcatcagagctcttggcaattccaggcg +ctacgtggttctggaatatattcatttttcaaatagtaatacgtttagtgttgctattgt +ctacacgtttggatattacgttatgtgagcggacatcaatagttgtctaactctttagta +agccagagatagcactcttagcgaatggataccatcttccataagtttagttaatagtcc +gaaacaactgcttcgagcatatttgaacctccttgtaggcaaatagcctcttcaaagcaa +tcttactaatagatagagtttgttttaagggactactagaaatgggacaatcttaatagt +atgacctaaactgacatttaaagatatatccaggtggcaagcataaagatcattgcgcca +cctccaccgtgggattacttatcagtcgatatcctatatgctaagtttgcgacggcagaa +tacaaactaagctgagttgatgctaaccttacctatgataccccattggaccggttaaca +gccctacttattccaaataaaagaacttttatgctgtagaagctattatagtgatgcctg +gtaacttcagtatattaaaatgacacacatacgccatatagagctcctggaactttgaat +aatgagcgaacttcgaagttgaagagcaagaaaccatatgtcacggttgcctaaagcccg +gtaaccagacatgtgctatcattgatcattatcgaggttttcataaccttgacccattat +cggctgtgcgcggacaagtacttaaatcactagtttcttcacctgcttatcggtaagaaa +taaggttggcaaagaatcgcataagacggacgtagagccgcagcgttgtgcgagtccagg +tgcatgcgcagcaataggattttaaattttgttccatttttaatttagccgtaaggatgt +ccgtaaatgattgaaaattggattcaatctttgggcctatgctactggaacctgatcgac +aaaatttcaaacatacgttaactccgaaagaccgtatttttgcggctagaatagtcagtc +gcttggagccatataccttaccacttaaacgacgtgctcctgtagttgaaatataaacag +aacacaaagactaccgatcatatcaactgaagatctttgtaactttgaggcgaagcaccc +tcttcgagacaactaagagtaaagtaccgggcgccgcaaggagtcgattgggaccctaaa +tcttgacgaattgctaagaggctcagagctaccactgtaatttctctagagcccataata +aatgaacgatacatccgtaggtagcacctaagggattataatggaagccaaatgcagtta +ataatattatatactggcgtacacgattcgacggatctctcacatagtgattcacgaccc +ccccctttgattgacacagcgtcagcattttgcaagaacgatcttctgcatagggtgcgc +caccgtaaggatgacgtcgaagctacaactgggtataatttaccatgcttccctgatgct +gagtgcaatacactaagaatgagtttttaccccatatcaccagtatttgttctgttattg +cgaagaaatggctatgctgagttggcgactaaagtcacccatcctttttattaggtaacc +ccctcccttaaactaactgatttgctggagctgccctgcatacatatactttatcattta +tggacgtccgtgacgcttattatccaccatagtcgatatgctacacggattcattaatgg +atcgtaggagtttaagttatatttactaagatcggtctcggctactatcccgccttaccc +ggcgctatttacggccatttttaatatattgacggtaattattcctatggtttcgaccgc +acgtccttggacaagaaagaatggcaaaaaaaatgtaaaagaaaaaaaatattgagtccc +taccatcatataaaaaatatgtgatgagtaacttgacgaaatgttagtggttattaaaga +ctatctattacaccttttgttttctgtcgtagtatattaaagtctagaagccttacagga +aaatcagggttatacagccgatactccgcagcatgaatcatcgaggaggtgtcctaccat +cgcgccttgtaatcttgtctgtgtatactgtatttagaccttttatacaaagtaaatatc +tcggctttatgtgattgggaggggcctactcaaacatgatgacttgacctaataatcact +gtgcgggcgtcttatgactagctattccttgaaatccaccaccaaatggttaatatgtaa +aaactttgacgatgaaacaaggtgaatgtgtagttactttgtgtaattagctgcgtcgag +cattgcttgtaaaaccgtcaatcgcacacgttacttccataaaatttctacgaatacacc +cttcttaaaaaaaacgtaggaattcacgagtttaacaaacgataactgtataaagtggaa +gtccgaagaaagcagatgcccgaactactcgaagatgtttcgttttcttaaccatagggg +cttcttaatggcccactacgcacattttgttcaagcccgagagggacatccccattacgg +gagtattactaaaactgttccgtaatacgttcagcaagggatgaaaaaggccactgctca +agttattgacgtgggagtattacatcggaagcctgaatcccacactatgatggtctgtac +aggcctagggactgcgtctagacggtattaccggcttctaatcatacgatcgtgagtctt +aacgggaagtaaggctcacacctaccccaaaccatttatctatgtaagtataaaattgtg +cgtaagtgttcaaagtggacaataaagacgtggcaaaaacccccgcacataagccgcttt +agatttcacaaataccaatgcggttaaaaacatccttgagtcgtacatacaccatactcg +cgttaaacggatataacagaagataataaatccggatgtggagtcggtgtaactatagaa +agccaagtgaaataatgcttaccagtcatttagctatacggctttcatttcatgtcaaga +gggtggagtttgacctgtacagttgatatatcaccgatacttagaactcacctaaagcta +aaattgctcgcagcgtgtaatccgcatattacaaacaatagatgggattcattatacata +agacacgatgatctgctttttcaggttgcgagatgttgcctatcgtcaatcgagtcctgc +cttacaccacttaaacaaaagtattgacagggaacctattttcgaggtattatatagtcc +agcttgaatatcaatttgacagttaacctagtgaaaatcagtaagaggaaatacgccaca +ttctccagtgaaattctacgggttatcgtctagtccaactatcaattataactcacgaga +tataagtaaattctcgtacttggcctgatttttattatactttggatccttagtaaacag +gaagggagaaaccttcaacgaaaaacactggattttgttttactctcaaagctcttatat +gacggaaataccctgtcaagtcttaactttattactagactaatgaaatgggcttggggt +ggccagaatcatagtacaatttagcggatacactattcggactttcctatcggctgtctg +gttggataagtatggggactaataggctagacatacctatacttaaactatacaggcgtc +atctatctctgcaactttggagttccctgatgttctcccgccctttgggttcacatcttc +tataccgacacccctaataacgattagtttgtgggttagagtaaattaatacggttaata +ttaatgtatcgttgaaaagctggtgtcgccaataaggtaaccggctaggcagagtatatg +tcacgaagtataactaccctaatgataagctgtaggaataaaattaatgctgtctctaag +cgaagagatatttccgactctgttttaatgacgaatctcattacttctgacttgcaaatg +ttcaatatggcacggtttcacggcacctttgtgacgcatataatgaacttagaagattat +aacgacggaactttatatgataatccgttacgattaaagaatctgttaaatatcataatg +gcattcagttctagaccgtgcatcatggtaaacttactttctctgcatggcgacatacat +ttcgctattcaaattcgcgtgtggttacacccactcgcacctttggaatattaagagaag +atgatcagaaaatccattcgctcaatttttctgacgtacgtctaatttatcctaggagac +aaatcgttttatgtctctcacatttttgaagaaaggttcgagagacaatactcaggtcct +gaactgctagaagatactcggtggagcgtggcaacaatgaaaaactcgtgacataaatga +atgatacttttccaagttcagttaagtgaatatgtttaacatacccggcttttcgatctt +aagctgacgctggacgtgcgagtaatgtcagtctcttacatacactagtgactccaagtt +tcgtcaaaaacgccccctcccttctcgagcccactcacgctatgtattgacgcgaacttg +ttcgggatcagacttttcaggagttcggtcgcgtgtccctatgtgctaatatataagtta +gatcgcattagatgctaatctgaatacttatagacgaccttcaacgagaacgggtaccac +cttgaggctagagttaggtgtgaaacgacaggtagggacatataaaatttgagtgcggct +ttagttaagggtttaattacctactcaaacatcacgctcgcgcccttcgtacgtaatcga +ccatctagaggctaaggggactgtactaggtagtgattaatgatatcctagacgcacgtg +ccttagatcttcagactctgatggtccgcgatcaccgtaattgtagtcctccaactcgat +cactttgttggcgtcaaagaaattacgatatctaaatacttataatacaataaccaagga +tgagaatgactcatcgcgttggagttatattgcttgaagttctatggaatgaaagcacgt +tatctgccgtcccaatatctccagtgagctaattcattggacggtccactttgatcaatc +cccgaggagatgttcggacactttagtctgtaacacttagcgttgagaccacgaacaatt +gattactcagtcttgaaggtgttttccaaagttcattttaaataagactacgataggcct +ttcctattgatataaactacccggctctgttgttcgtgtgagtcgtacttctctgtgttt +ttctgattatagcaagattcgattcttagtgtaaacagcgatttttatttgacccgtcaa +tgagaagcgcataggatctaagcaaaattatcaagttgtgccacaaggtaagatctttcc +agttattgcaggtaggatgtatcccacgttgatagtatgaggtctgacgtcaactgtcta +ggagagttgaccgcgtgcgggtacaccggatttgcatcgatgttgagaacgcagaactcc +cactgtcgtggcggcgttcctgatatttagcaagaggcgttgataaagccctcatcatct +agatctcgacctcatctgccctcttgctccatcattttctacacagactactttcctatc +tacgttagtataattgctttctatcttagtatcatttagagcttctccgtcaacaggttc +gtgctattaaagttagtacgaaagggacaacttgtagcaacgcatttaatcggttttcga +ctacttcgcacaaaatcagataaagaagtttgtcattctattagacattgaattgcgcaa +ttgacttgtaccacttatgatcgaacactgaatcaagactgtgattaactaaaatagaca +agccactatatcaactaataaaaacgcccctggtggtcgaacatagttgactacaggata +attaattggactggagccattacattctctacaatcgtatcacttcccaagtagacaact +ttgaccttgtagtttcatgtacaaaaaaatgctttcgcaggagcacattggtagttcaat +agtttcatgggaacctcttgagccgtcttctgtgggtgtgttcggatagtaggtactgat +aaagtcgtgtcgctttcgatgagagggaattcaccggaaaacaccttggttaacaggata +gtctatgtaaacttcgagacatgtttaagagttaccagcttaatccacggtgctctacta +gtatcatcagctgtcttgcctcgcctagaaatatgcattctatcgttatcctatcaacgg +ttgccgtactgagcagccttattgtggaagagtaatatataaatgtagtcttgtctttac +gaagcagacgtaagtaataatgacttggaataccaaaactaaacatagtggattatcata +ctcaagaactctccagataaataacagtttttacgatacgtcaccaatgagcttaaagat +taggatcctcaaaactgatacaaacgctaattcatttgttattggatccagtatcagtta +aactgaatggagtgaagattgtagaatgttgttctggcctcgcatggggtctaggtgata +tacaatttctcatacttacacggtagtggaaatctgattctagcttcgtagctgactata +ctcaaggaaccactgctcaaggtaggagactagttccgaccctacagtcaaagtggccga +agcttaaactatagactagttgttaaatgctgatttcaagatatcatctatatacagttt +ggacaattatgtgtgcgaaactaaaattcatgctattcagatggatttcacttatgcctt +agaaacagatattgcccgagctcaatcaacagttttagccggaaacaatcgaagcatagg +gacaatgtatcttttcctaaattgccatgtgcagatttctgagtgtcacgaagcgcataa +tagaatcttgtgttgcctcaactcgttgaaaagtttaaaacaatcgcagcagtctttttg +gggtctactgtgtgtttgcaaaataactgaaagaaacgcttgaacaactctgaagtagct +cgagtactcattaaagtgtaacacattagtgaatatcggccaatgaaccaaacgcttccc +ggtacgctatctctctcatcgggaggcgatgtgcaggttatctacgaaagcatcccttta +cgttgagagtgtcgatgcatgaacctcattgtaacaatagcccagcaaattctcatacgt +gcctcagggtccgggcgtactcctccatggaagggcgcgcatctagtgttataccaactc +gctttttaactactatgctgtagttctacaggcatagtggccagtattttctaacttctc +tggatagatgctctcactcctcatccatcacggcttcagtttacgtcttacttgcttgtt +cagcaacggatggaggcattaagtatcttcactgttccctaaaattgctgttcaatatca +aagtaaggacgatacagggaaagctcaagcacactcattgaatactgccccagttgcaac +ctcacttaatctgacaaaaataatgactactctaagtgttgcggaagcagtctcttccac +gagcttgtctgtatcacttcgtataggcatgtaactcgatagacacgaacaccgagtgag +aaactatattcttgcttccgtgtgtgtgacaccaggtaattgatgcggatataagctgga +gatcactcacgcccacacaaggcgctgctacctctttattccaatgtgtaagaatttgct +aacttcatttctagaccgcagctttgcggtcataatttcacggtacggacccttgggtta +gagacttgataacacacttcgcagtttccaccgcgcacatgttttagtggcttctaacat +agaatttttgttgtgacataaagagtgcgtgggagacttgcccgaccgttaagccataat +caattgaaagccccgtgagtcacatctaattggttgtactgcgcatttagctatccttta +gctgactcgaagagattcgattcctaatataggttaattagatggctgccgcgcgaagta +aaacgtgaaaaacgtagtgcgcagatctgcataactcgcgcttaattacttatgagtagt +tccaagttcgctacgttatgagagagattggaattaagcaaatatgttttatggtgattt +tgggatgagaaggactgctaagtacggctactaaacaaatttctaaaaccgccatctacc +ttatcttggagacatttaagttgtatatgtcactagtctagcttttgtctgtgggacgcg +ttctcggaatgagggaaatgcaagagccgattcatcaaatgcttatctaagaaagtagtg +gactattacaccaagcacgaatgccagggaactgctttcttgctcaggacctcgcgacaa +ggtaccccgcataagtcctagaattacatttggtcagcaatgctgacatttgaccgtgaa +aacataattttaatcagaaggcagctcacccgcttgctctagatcttatctttgtatgaa +tgtcagaatttactgcaatatccgttccgaatagtgagggcttagtatagttctctgtat +acaggtcacatcaaactccccctgtcctagtacagctctgagctttaattaattgcatac +atttccttcaatcatcagatgaaaacaccgcgaatcatgctcttctcgtatagggcaaga +gaagcaacaaacaactagcccgactcacgttcatccgccgtatccttgttcagttcttac +tccgtattaggtcagcgaaatctaatcagaataatcggtcgcgtatcaaaattaaaatcc +cgcttgaggttgacaattaaaacgctgagcagttatcggctattagatagtggggtgaaa +gtaattggctggaattatgttaaaacgtgatattaagctaaaatacgctacttgttgccg +acctaattcagtcattcgatattcagttagagccaagaataacaagcttgtataaattga +acggggtgcactaaacgatgtgttactctaatattcagcttggagtatacctgaaggcga +attcatgtatcggccaataataagacgttgaagatcacaatttggactagcaaaagaagg +tgatttatgcgtggggattgagtccactgtacgagtacggtctctggaaaattataggtt +cagggaatataaggaagtaaagataattaccaagagatttttggtatcgctatgacccag +aggtgttctaacgtctgttttgatccgcagaatttctgcctcaatgcatatttgacggac +ttgaactagagcctctaaagttaaatggcgacgcaactgttcctaaacttcaattattac +tactctttttttcctagggtattgtagaggccagtggacaaaataaatcaaatttaagat +gtttcggacattaacatcccccgtagcatagaaatcatcagttatccaatctctcatcga +gcttttacaatttctgctggcgctatggacagcatatgccgcgagacctccgcaagactc +acttgatcactgtaagtatcttcattagaggttagagcctatagttaagctgctgaccta +gtaaaattggtattttctaattttattgctcaagttaaaggttagtgaagggataatgac +gttatttttgaacaatgggttgtattcaattttatatcacgaatggaacccttcattccc +ggcataatactagacgacacgaacaagctccgatctatcagccaggcacgtgttaaggtt +taattccggcaaaccaatgaagcatcaaaaggtgacctgatgcaacttagggtcacgatg +agtttttcaggactacttattacctattaataagttaacatgagccttcataccccgtaa +gacaatacatactccaccaattagaattctgagccatcttatctttttgtatcatcgaag +ggtatggccgaataggttaattagttactcctaacgtctctacaggcatgcatttgacgc +accttcgaaaatagtcaatctctcgccacacgcgtctagtatgcagcatcaaaaatatag +tccacggtttccggattaccaaacgcggcaaagagaaacattgtatcgacggagataact +taatacagaaggaaggggcatcttcgaatacggatgaataattctatctgtttattctga +catcttgttttcaggttaatcttacgcattcaaatgacgcctgccccatgcgtgcgcaat +tattttctaatattgacgagagcaatctcactccttttgggtctatttatgttttattga +ggcacaagcctatacagaacaggtactattaaggccgtgagtgtgagactcaaaccgtgg +aaacaaaggatgggttgttcttggtacaagttttagtgcatgtgggcaatccttaccaaa +atcagatgctatccttaactttgggctgcatttaagatggcggttggaggcctgtgagaa +tcctgcgtgtcatctttaatgaccgaattcatccatgtagattcagatcacacactcatt +ccttgatgttgtctaaacaaaagttgttgtggacgcattggagggagttaagtaacaact +tgggatcgcatacttataaaaattatatgttaaactttcacaaacgctgaagtccaaagt +aactagcccaaacgcctcgagagtcactaggtattaatggtgtttgagttcctgtgaaat +agtgttcgaaggtaaaatttatgtaccaaatcgaaagaacacttaataaggcttgcttgc +acggaggtatgatgtttactgactctacaaccctaattttccagtacgtacattcattcc +aataggttagttctcaaagtgctatacaggctcctcaattgatgatatgcttcagccgct +ctatggatattagctcattttatttaggaagcccgcttagaggcttactatgagggaaat +gccaaaatgtcatacttttcggtgtgtcccatatgacaccgctttacatagaatttgaat +taaaacgcgctctcccgttcactaccatacttggtaccgtgcgcatattacatatagata +taggatcattttttaaagctgtactaggtttgatcgacaatcttatgctatactatatga +tgtaaccctcataatcaataccgatcgtacgatcctagcataggtggcaagcgattttat +gccgattattgtgttaaatagtctgtgagtgtgattatcagggctacgttggtagagggg +ttgtatagacctcgcacacattgtgacatacttaacaatatacgaaaactgatataataa +atccccttacccaaacaccaatcccgttgaatcaactaccataacgtctcccatataaat +tgcctacttgtttgcataaatctgaatacataacaccattgcaccttcttgtgttccaat +cccgttaagattgccttgtcagatgatatgcaagaacaatagcatttgctagcaattatt +aacagctcttcgaattgcctccacataacgcgggagggtatattttaatttggcaaatac +taagtactgttggcgtcatatgctattaacggttggatattaagttatgtcagccgtaag +caagagtgggcgaaatattttgttacccagtgagagcactcttagagtttggatacaata +ggccatatgttgacttaagaggacgtaactacgccgtacaccattgttcaaccgacttct +tggcaaatagaatcgtattagcaatcttaagaatagagacacgttcgtgttagggtatac +tacaaatccgaaaatcttaagaggatcacctaaactgaaatttatacatatttcaacgtg +gatagatttaacataattcagccacctccaacctgggagtaattttcagtagatttacta +gatgattagtggcccaacgcacttgactatataagatctggggatcctaacctgacctat +gagacaaaattggaaacgttaacagcccttatgtgtacaaagaaaagtaagttgttgctg +ttcaacagatgatagtcatgacgcgtaacttcactatagtaaattgaaacaaatacgcaa +tttagacagaatggtacggtcatgaatgacagtaattcgaagtgctagaccaacttaaaa +taggtaaacgtgcccgaaaccccccttaacagaaagctgctatcatggtgcagtatcgac +gtgttcagaaacttgtaacttttgagcaggtccgagcacatggaagtatatcacgtgttt +ctgaaccggcttatccctaagatatatccgtcgcaaactttcgatttagtcccacgtaga +gcccaagcgttgtgcgactccacgtgcatgcccagaaatacgagtttaaatttggttaca +tggttaattttgaccgaagcatcgcactttatgattgataattggattcaatatgtcgcc +ctatgcgaatgcaacatgatccacaatttggctataagacgtttaatccgtatcacactt +tgtttgcggctagtatagtaacgcccgtgcaccaagagtcagtaacaattataagtactc +cgcaggtacttcaaatataaaaactaatcaaacacgacccatatgatcatctgaagatat +ttggaactttctcgacaaccaccctcgtactcaatacttacactaatcgacaggcacacg +caacgtgtacagtcgcaccatattgagtcaagatttgcttagtggcgatgagcgtacacg +cttatttctctagtcacaattagttatctacgagacatcacgagggagcaaataagcgat +gttatggctacacataggcacgtatgaatatgatataagccagttaaacagtcgaaccat +cgagcaaattctcatgcaccaacccacacgttgaggcacaaagagtaagctgtttgaatg +taacttcttctgctgagcgggccccaacgtaaggatcaactagaagagaaaactcggtat +tagtttaaatgcgtcacggagcatgagtgcatttcactaagaatgtctgtgtaaccaata +taacatctatttgttatctgattgcctacttatggctttgcggtcgtggcgactaatgtc +tccaatccttttgaggtcggtaccaactccctttaaattacgctgtgcaggctcatgcac +tgcatacatatacggtagcaggtagggacctcacgcacccttattataatcaatagtagt +tatcagtcaacgaggcaggaatgctgaggtcgaggtgttggtatattttctatgtgccgt +ctaggcgactatcacgcattaccaggcgagatttaagccaattttgaatatagtcaacgt +aatttttactatgggttccaccgaaacgccttgcacaactaagaatcccataaaatatcg +atatcaaataaaagattgtgtcaataccttcatatatattttttcggttgactaacgtga +actaaggttaggggttttgtatgtctatataggaaacagtttcttttctgtcctacttta +gtaaagtcttcaagccttactccaaaatcacggtgattaagccgttactcagcagcatga +ttctgcctgctcgggtcctaaaatccagccttgtaagagtcgctgtgtattagctaggga +gacctttgttaaaaaggatatatcgcggcgggatgtgagtgcgtggcgcatactcaatct +tcagctcgtgtcattataatatctctcccccacgcttttcactagatatgccgtgtaagc +aaacaccttatgcttaatttcgaaaatattggtacttgaaaaaagctgtaggggtactta +atgtctggtaggagatcaggagagaattgagtgtaaaaccgtaaagccctcacctgactt +catgtaaatggcttagaagactccatgatttaataaatactacgaaggaaagactggatc +taaagataactctagtaaggccaactcccttcaatgctgttgccagttataatccaagag +ctgtccttttctgaaccatagcggcttctgaagcgaactagaagcaaagttggttctagc +cagacagccacataccctgtacgggtgtattactaaaactggtccggtattagttcacca +agggaggaattaggcaaaggatctaggtatgcaagtcggagtattacatccctaccctga +atccatcaataggttcctctgtactggccttcgcaatgagtattcaaggttgtacagccg +tataataataagatagtgactatgaacgggaagtaacccgctcaccttccccaaaacatt +gttatatctaagtattaaagtctgccgtagtgttaatactcgaaaataaacaactggcaa +attacaccgcacttaagccgcttttgatttatatttttccaatgcgcttttaaaaataat +tcagtcctacatactaattaagacccttaaacggagatatcacaagttaagttttaacca +tctcgactaggtggaactatagatacccaactcaatttatcattacctgtaatgttccta +gaaggattgcatttcatgtcaagacggtggagtttcacagcgaaacttcagtgtgaacag +attctgagaaatcacctaaacctattagtcagagcacccggttagaaccagttgtcaaaa +aatagagcggttgcatgagacagaagtaacgatgagatccgttgtaacgttgagacatct +ggcctatcgtcaatacagtcctcccttaaaaatatttttaaatactaggcaaacccaaca +taggttagtcctatgtgatacgccacatggtatatcattttgtaacgttacctagggata +atcaggaagtggaattacgcaaaagtagacagtgaaatgcttagggttatagtctagtcc +aaagataaaggataaagcacgtcagagaactatattagccgaatgggaatcattgttagg +agactgtggatcatgtctaaaaagcaacgcagaaacagtcatcgaaaaaatctcgttttt +gtttgaatctaaaagagctttgatgaccgatagtacctgtatactagttactgtattacg +tgtctaatgatttcggattggggtccccagaatcagacgtcattgtagacgattcaagtt +taccaatttaatttcccagctctccttggagaactatcgccaataattgcagtcactttc +cttttctgaaacgataaagccgtcagagttctctgcaacgttggacttacctgaggttct +aacccactttcggttctaatagtagttaacgacacaacgaataacctttactgtggggct +ttcacgatattttttcgcttattattaatggttacgtcataagctggtgtccaaattaag +gttaccggcttcgcagagtagttgtatccaagtataacttccctaatcataagatcgagg +tagaaaattaatgctgtctctaaccgaacagatatgtcccactatgtggtatggacgttg +ctaattacttctgaagggaaattggtcattatggatacgtgtctaccatcaggtcggacg +cagatatggttctgtcttcagttgatccaccgttctttataggataataactgacgatta +aagattatggtaaatagattaagccaattctcttcttgtcagtgaagcatccttaactga +cttgctctgcagcccctcatacatttagctattcaaagtaccggctcgtttcaaactctc +ccacctttggaagaggttgtcaacttgataagtatatcatttacagcattttttcggacg +tacctctaatgtttcattgcagaaaattagttttttctatcgcacattttgcaagtaacg +ttagagacacaattatctgcgaatgaactgctagatctgacgaccgggagcctcgcaaat +atcaaaaaagactgacatatatcaaggagtcgttgacaagtgctggtaagtcaattggtt +tatctgtcccggcgtttcgatcttaagctgaccatgcacggcagagtaatgtcactctcg +ttcttacaagtctgtctccaagggtcggcaaaaaagacccctccattctcgagcccactc +acgatatgtagggacgacaacttgtgcggcttatgaattgtctggactgcgggcgagggt +ccatatctccgaagttagaagggacatacctttagatgataagatcaattcttattgacg +aaattcatccacaacggggaacaacttcaccctagacttacgtctgaaaagacacctagc +gtcttataaaaggtcagtgccccgtttcgtaaggctggaattacctacgcaaacttaaac +ctcgcgcccttccttacgtatcgacaagatagaggctatcgcgaatgtactacggaggca +tgaatcatatactagaaccaagtgcctgtgatattaacaagatgatccgacgcgagcacc +gtaattctaggcataaaactccagcaatttgggggccgaaaacaaatgacgttagctaat +taattatatgacatgatcaaaggaggtcaatcacgcatcgagttcgacgtatattcattg +aacttcgtgcgtttgaaagaaacttttatgaaggcaaaattgatcctgtctcctatttca +tgcgtacctcctagttgataattccccgagcagtggttaggacacttttgtcggtatcaa +gttccggtctcaaaacgtaaaattctgtaatctgtatggatggtctgtgaattagttaat +ttttatgaagtcgtcgagacgcagttcctattgatttattctaaacggagatgtgcttcg +tgggactcggaagtagatctgtgtttatgattattgctactttagatgctgactgttaac +tccgtgttgtttttcaaccgtatatcacaaccgaattggatagaacctatagtttcaagt +tctgccacaaggtatcatatttacagttagtgctggttgcttctttcaaacgtggtgagt +ttgtgctatcacgtcaacggtagagctcagtggaccgagtgcgcgttcaaccctgttcca +gagagggtgtgatagcacatataccacgctcgtcgaggcgttcatgatagtttgcaagag +ccggtgttaaacacatattattattgttatccaactaatcggacctatgcataaagcatt +gtctaaacagaataattgcctatatacggtagttttagtgatttatatcttagtatcagt +tagagcttcgaactcttcaggttcctcatatttaacgttcttcgaaagcgaaaacttcta +caaacgaatgtaagcggttttccaagtagtacctataaatcacagaaagatctgtctcag +tatagttgaaatggtattcagctagtgacgtgtaccaattatcatagttcactcaagcaa +gacgctcattaacgaatatagacaagacactatatcatataataaaaaagaacatggtgc +tcgaacatagttgaattcaccatattgaaggggaatgctgacatgtaattcgctactaga +cgatcaattccctacttgtcaaagttgaactggtacgttcttggaattaaatatgattgc +gctggaccaaattgcgacttcttgagtttcagggcaaacgattgagccggaggatgtccg +tctcttacctttcttgcttatgataaacgacggtccctgtacatcactgggaattctcag +caaaaataattgggtaaatcgagactcgatgtattcggccacaaaggtgttagacgttaa +agattattcaacggggcgataataggatcataaccggtatgcaagcgcattgaaagagcc +atgagatccttatccgataaacgctgcacggtatgtgcagccttattgtcgatcacgaat +ttataaatgtagtctgggctgtaagttgaagacctaagttataatgaagtgcaataccaa +atcgattcatagtggattatcagactcaagatatctcctgataaattacagttgttaaga +tacggataaaatgagatttaagattagcagcctctaatctgtttcaatcccgttggaatg +tggtatgcgatcaaggttaagttaaaatcaagcctgtcttcagtcttgattcttgttctg +ccatcgcatgcggtctacgtgagttaatatgtagcttacgttctagcttgtgctaatctg +agtatagattcgtagaggaatattatcaagcttccacgcctcaacgtacgtgtattggtc +acacaagacactaaaagtggaagtagcgtaaactatagtctagttgttaaatgctcagtt +cttgttatattcgatatactcttggctaatttatgtctgagtatataaaattaatgatat +taacttgcatttcacggatcccttagaaaaagattttgaccgagcgcattataaacggtt +acaccgaatcaatagaagcatacccaatagctttctttgaatttattgcctgcgcaactt +ggctgactctctagatccgaataattctatatggtcgtgacgaaactagttcattactgt +ttaaaatgccaacatgtcttttgggccgataatggctctttgcaaaattactcaatgata +cgattgatcaaagcggtagttgctagtggtagcatgtaagtctatcaaatgtctgattat +ccgaaaatcttccaaaagagtccacgtaccatatctatctcatagcgacgcgaggggaac +cttatctaactatcattccatttaccgggtgactctcgatgcaggatccgattgggataa +attgcccagaaatggctcattcctgactaagggtaaggccgttctcagcaagggaacccc +gcgaatctaggcttataccatctagattgttaactacttgcctgtagttctacagccata +ctggacagttgtttctaaatgatcgggattcatgctagcactcctctgaatgcaccgcgt +aagtttaactattacgtccgtgggcagataaggatggaggctgtatgtatcttaactgtt +acctaatatggctggtaattatcaaagtaaggaccttaatgccatagcgctagcaatcgc +tttgtatactgaccatgtgccaacctctcttaatctgtaaaatataatgtcttagctaac +tgtggacgatcatgtctctgcctagagcttcgctgtatcaattcctatagccagcgtact +agtgacacaacaacaccgtgtgagaaaagatattagtccttacgtctgtctctctacagc +ttattgatgaggattgaacatggacatatagctccccctcaaaagcagatgctacctctt +tattccattctcgaacatttgccgaacttaatttcgacaaacctgaggtcacgtcttaat +ttatcggtaacgtcacgtccctttgagactggataaatatattaccaggggccaacgagc +aattgttggaggcgcttctataatacaaggtgtcttgtcaaagaaagacggcgtgcgtct +cgtgcaactcacttaaccaatattaatgtgaaacccccctctctcacatcttatgcggtg +tactgccctggtacatttcctgtacaggactccaacagtgtagattcctaagatagctgt +tggagttgcctcacgccagatcgaaaaactgaataaactagtgagctgagctgcagaaat +accgcttaattacttatgactagttcaaagggacctacgtgatgtcagacattgcaagga +agaaattaggtttgtgcgtcattttggctggactagcactccttacttcccctactattc +aaatgtcgtaaacagcatgagacaggatcgtgctgacatttaaggtctattgggaacgag +gctacctttggtcgcgcgctcgcgttctccgaatgaccgaaatgcatgagcacagtatgc +aattgcttatagatctaaggtctggtcgttgaaaccaagcacgtaggcctgggaaatcag +ttcttcctcagcaactacacaaaagcgtccaagcattagtacttgtagtaaatgtccgaa +cctatgcgctcatttgaaagtcaaaaaatatttttaagcagtaggcacctaacccgattc +ctctacttagtagctttctttgattctcagaattgactgcaatatcactgcacaattctg +tgccattactagacttctctgtattaacgtctcatcttactaacactcgcctaggacaca +tctgagagtgaagtatttcaatacatttactgaaatcttcagttctaaaatccccgaata +aggctcttatcggtttggccaacacaagaaaaaaacttcttgcaccactcaccttcatac +gcaggagcctggggaacttagtaataactatttcggcagacaaagcttataacaagttgc +cggcgcgtataatatttaaaagaccccttgagctgctcaattaaaacgctcacctggtat +aggctattagatagtgccgtcttagtaaggggcgggaattatcggataaactgatatttt +gataaaataaccgacttgttcacgacataagtcactaaggagattttatctttctccaaa +gtatatcttccttggataatttcaaagcgctgcaatttaagttctgttactagtttatgc +tgctgggaggtgaccggaaggcgtagtaatctagaggcaaattataagaagttcatcata +tcattttcgactacaaaaacaaggtgttgtatgccggcgcattgtgtaaactggacgagt +accctagatggaaaattatacgttaagccaagatttcgatgtaatgataattacctacac +atttttgctatccataggaacaagagctgttctataggctcgtggcatacgaacatttgc +tgccgctatgaatattggaagctcttcaactacagactctattcttaattgccgtcgaaa +atgggccgaatcggctattattaatactcggtttttccgaggggattgttgtcgacagtc +gtaattattattaatattgatgttggtgaggtcatttaaatacaaccttgcagacaatga +ataagggatccaatctctcatactccttttacaattgctcatgcccctatgcaaacctta +tgccgccacacctccgcaactctctcttctgaactgtaagtagcttcattactggtttga +gactatactgaagctgatgacattctaaaatggctattttcgaatgtgattcataatgtt +tatcgtttgggatggcagaatcacgttatttttgatatagcccgggtattctattgtata +gaacgtatgctacaagtcattccccgaagaagactagaagtaaacaacatgcgaccatcg +ttaagccacgcaaggctgtagctttatttcccgataacctatcttccataaatagcggac +agcaggatactgacgctcaacatcagtggttatggtctaatttttaacttttaataaggt +aacttcagcaggcatacacagtaactctttaatttataatcaaattagaagtctgacact +tcttatatttttctatcatccaacgcgatcgcccattagcttattgtgttactaataacg +tatctaaaccaatccttttcaagctactgcctatattgtcaatatatacaaacaacagga +tagtaggctgcttaaaaaatattgtcaaccgtgtacgctttacaatacccggaaatcaca +aactttgtagacaacgagtgaaatttatacactacgaagggccagcgtacaagacccatg +aattaggcgatatgtttattctgacatattggtttatccttaatctgtcgctgtaaaatg +aagccgcccccatccctgcgaattttttttcgaagattcacgactgaaatataaatacgt +ttggctatatttatgttggagggaggcaatagcctttactgttaaccgaagatttagcca +gtgagtgtgacactaaaacactggaataaatgcaggcgttcttctgggtaaaaggtttag +tcaatctcgcctataagttcatatagctctggatataattatctggcccatgcatttatc +atggcgcttggtgccctgtgtgaagccggcctctcatattgaaggtccgaagtattccat +gtacattaagatcactctctcattcatgcatcttggcttaacaaatctggttgtccaagc +tttccaggcacgtatggtacaaattcggatcgaatacttataaaaatgatatgttaaact +gtctaaaacgctcatctacaaagtaaagtgcactaaccaatagagtctcaagaccgtgta +atgctggtgcactgaatgtgtaatacggttagaagggattagttatgttacaaatccatt +gaaaacttaagaagcattgcgtgctcggagggtgcatcttttatcaagagactaacatta +ttttcaacgacgtacatgctttacaatagggtacttatcaaacgccgagaaacgcgccta +tagtgatgttatgattatgacccgatatccattggaccgaattttatgtaggttcccagc +gtactcgcgtaatatctcggtattgccataatgtaatacttgtcggtctctcccagatga +aaaagcgttacagagtatttcaatgaaaaacagcgcgcaacgtcaatacctttaggggta +acggccgctgatttcatatagatatacgataagttggtatagctctactaggtggcatcc +acaatcgttgcatttactatagctggttacaatcataatctataccgttccttacatact +accatagcgggatagcgtttttttgccgttgattgggtttaagaggatgtcagtctcatt +atatccgattcggtgggagagccgttgttttcaaatcgcacactttgtgacataatgtac +aagataacaaaactgatataagatataaactgtcaatatcaccttgacacttgaatcaaa +gtaaattaactcgcaaatataatttgactaattgggtgcagatttctcaattaataaaaa +aatggcaccggatgggcttacaagccccttatcattcacttgtatcatgatttccaagaa +caatagaatttgctagcaagtatgaacagagattcgaattgcatccacagtacgccggag +cgtttattttaatgtggatatgacgatgtactgttggcggcatttgctagtaaccggtcc +ttatttacgtagcgcacacgtaagcatgtctgggagaaatatggtggtacaatctcagag +aaagattacagtttggtttaaataggacttatcgggtcggaagtggaacttaataagcag +tacacaattgggcaacagacgtcttgcctattacaataggattacaatgcgttagatttc +agacacgttcgtgtttggctattcgtcaattccctaaatagttagacgatcaactattat +caaagtgattctttgttcatcctccattcatgtaacagatggcacactacgcataacgcc +gaggaattttaacgagatttaagagagcagttcgggcacaacccacttgactttataaca +gctcggcagcataaacggtaatatgtgacaaatttccaaacgttataagaacgtatgtgt +acttagaaaactaagtggttcatgttcaacagatgtgacgcagcaagcctaacttatcta +ttggttttgctataaaagaacaaagttacacagaatcctaagggcttgtttcacacttat +gcctagtgcttcaccatcttaaaatagcgaaaccggcacgaatcaaaccttaaaacaatg +cgcagatattggtgatggtgactccgggtatgataatggtaactgttgaccagcgcccac +ctcatcgaagtatagaaagtggttaggataaggatgagaccgaacttatttccggccata +actttagattttctacctagtacacaacatcagggcggacacgaaaccgccatcacatca +tataccaggtttaatttgcttaatgggggaagtgtcaacgaaccttcgaactttagcagg +catatggccattatatatggccccagagcagaatgctacagcagacaaaatttggattta +tgtagtttaatacctatcaaacttggtgtgaccatacttgtctaacgacagtgcacaaag +tgtaagttacaattattactactcagcagcttctgcaatgataaaatcttatcatacacg +tcacatatgataatatctacttagggggaacgggctccacaacctacatagtactcaata +cttacactattcgacaggcacaccaaacctgtacagtcccaaaagattgagtcaactttg +cagtactgcagatcacagtaatagcttagttagcgagtcaaaattagttttctacgagac +tgcacgaccgtgcaaatttccgatgtgttggctacaaatagcaacgtatgaatttgtttg +aagccacgtaaactgtacaaccttagagataagtctcaggctactaaaaacacgttgtgg +cactaacaggatcatggttgattcttacttattcggctgaccggcccaataagtaacctt +caactagaacagaataatcgggagtagtttaattcagtcaaggtgcaggtctcattgtaa +ctaacaagctctgtgtaaccaagttaaaatcgttttcttagcggattccctacttatgga +tttgagctcgtccacaatattcgatacaagaagtttgtggtccgtaacaacgaaatttta +attacgctgtgcagcctcatccaaggaattaatagaaggttgatggtaggctccgaacgc +tccatgattataatcaagtggactgtgcagtaaacgaggaaggtatcctgacgtcgtggt +gttcgtttttgttatttgtgccctatacgagtagataaaccatgaacagcacagtgtgaa +cccatggttgattttaggctaccttatttttaatttccgttacacagaaacgaattccac +aactaacatgccattaatttttcgatatcttataaaagatggtcgaaattcattcattta +ttttttttcggttctcgaaagtcaactaagctgtcgcgttttgtttctctttagaggtaa +aagtggctttgatctcctacgtttggatactagtcaaccattactccatttgatccgtga +gtatcacctgtctaacatccagcattatgactcctcggcgaagaaaagacacacttctta +gagtcgatgtgtattagctagggacacagttgtttaatacgatagtgagcccagggaggg +cagtgcgtcccccagtagatttattcagctagtgtaagtataagatatctcacccacgag +gttcaagtgatatgcagtcttagaataatacttatcctgaatttcgatattatgggtact +tcaataatccgctagcgctactttatgtctcgttggacagcaggacacatggcagtctta +aacactaaagacatcacctgaatgaatgtaatgggattacaagaatcaatgaggtattat +atacgacgtaggaaactctggatatatacagtaatctagttacgccatcgcacttcattc +ctctggaaacttagaagacatcagctgtacgtggaggaaccagacccccgtatgtagcca +aatagaaccaaagttgcttatacaaacacacccaatgacaatggaccgctggagttcgta +aactcggaacgtagtactgcacaaacccagcatttagcaataggagctacgtatgcaact +cccacgtggtaataccttcaagctatcaatatataggtgcctagctaatcgcattcgcaa +gcagtattcaagcttgtaaaccagtataataattacagaggctctatgaaacccaacttt +ccagctaaaagtcccaattaaatggttatttcgtacttttaaagtcgcccgttctgttat +tacgcgaattgattctactccaaaattaaacacaaattatcaaccgtttcatttatattt +gtcaatgcagctgtttaaaataaggctctactaaattataattaagacacttattaccag +atttctctagttaagtttgaaccagctcgactaccgcgaaagatacattcccttctctat +ttttcagttcatctatgggtcagagaagcattgaatttattctattcaccctcgtcgttc +acagcgaatcgtcagtgtgatcagtgtatgagaaatatcctaaaccgtttagtcagacca +cacgcttagaacaagtggtctaaaaagactgccctggaaggagtaagaagtatacagctg +atccggtgtatccttcagtcatctgccctatactaattacacgacgcaaggaaaaatagg +tttattttctaggcaaacccttcataggtgactccgatgtgttacgaatcatgcttgaga +atgtgctatcgttaccgacggataataacgatctccaatgaaccaaatgtagaatgtcta +ttgattacccttttactattcgacttagagataggagatagaacctcagtgtactttttt +agccgaatgggaatctttgggaggtgaatggccataaggtcgtaaatccaaccctcttaa +agtcttccatattatatcgttgttcgtggaatcgataacagatttgttgacccatagtaa +atgtatactagtttatgttgtaagtgtagattgttttccgattgccgtccaaactttatg +tcgtaattgtagaccagtaaagttgaccaaggtaagtgcccagcgatcctgcgagatcga +tcgccaatttttccagtcactgtaagtgtaggtttagataaagccgtatgagttatatca +taagggcctcggaaagcagcttcgaaccaaagttcccttataatagtagtttaactataa +aagtatatactggtctgtcgccctttcacgatttgttttaccggtttatgaagcgttacg +tcattagagcggctccaatttaaggttaacggcttccatgtgtagttgtatacaaggata +acttaaagtatctgttcagcgagctagttaagttatcctcgatagaacacaactcagagg +tcccaagatcgggtttgcaacttgctaatttattctcaaggcaaattgggaattatcgat +acctgtataccataaggtcgctcgatgtgatgcttatgtcttctggtgatcctaccttag +ttagtgctgattaacggaacattaatgtttatcgttttgagatttagccaattctctgat +tctaactcaagatgccttatctgacgtgctatgcagcccctaagtattttacattgtaat +aggacacgctcctttaaaactcgccaaaaggtcgttgtggttctctactggttaactata +taatttacagctttgttgagctagttcctctttggtttaagtcctcaatattagttggtt +cgagcgataagttggctagttaccttagtcactatattagatccgaatgttatgcttcat +ctgaagaccgccaccctccaaaatttcttttaagactcacttattgcaaggtgtaggtga +attcggctcgtttctcaagtggtgtatctgtacacgagtttccatattttcatcaacagc +caccgcacacttatgtcactctaggtattaaaagtcgctctacaaggggacgcaattaag +aaacagacatgctagtcaaaaataaacatagcgaggcaccactaattcggccgcttatca +atgggatgctctgcgcgagacgcgccagagctcagtagttagttcggacatacatttact +tcagatgatcaattagttttctacaaatgcttactctaccccgaaaaaagtcaccagact +cttacgtctctttagtatccttccgtcttatataaggtcagtcccccgtttcggtaccct +ggaatttactaagaataatgaaacagcccccaaggacgtacgtttacaaatgatagacca +gatcgcctagcttattccgacgcatgttgcatagaattgaaccaacggaatgtgagagta +actagatgagccgaccacagcacccgtttgcgtcgcagaatacgcctgatagttcggcca +cgaaatcatatgtcctttgagtattaagtatttgtaatgatcaatcgagctcaagcaagc +ttacacttcctcggatattcagggaacttagtgcctttgaaagatacgttgatcaacgaa +aaattgataatggctcatatggaatgcctacctcatagtgctgaattaacacagcactgc +ggacctaacttttcgaggtttcaagttcacgtctcaaaacctaataggctggaatatgta +gggatcctcggtgaatttgtgattgggtttgttgtagtactgaccaagtgaatattcttt +ttttctaaaagcagatctgctgccgggcactacgaaggagatctctgtgtatcattattg +cttcttgacatgatgactcttaaatcactgtgggtgtgcaaaacgatagcacaacccaat +tcgatagtacatattgttgatacttcgcactaaaccgttcatatttaaaggttgtgctcc +ttccttcgttaaatactggtgacttggtcctatctactattagctagacctctggggaac +cacgcccccgtaaaacctgtgcaagagagggggtcatacatcttagacatcgcgcctcca +ccagggaagcattgggtgattgaccaggtgtgtaacaaatatgattattcttatactaat +attagcaaagatgcataatgatttgtattaaatgtataattgaattgataagggtctttt +agtcagtgatagagtagtataaggtagacattagaactcttaaccggacgcagatttttc +ggtcttagtaagccaattagtcgacaaaacaaggtaagagcggttactagtagtacctat +aatgcactgaatcttcggtcgaagtatagttctaatgctatgcagattgtgacggcgaca +aatgttcagacttatatcatgaaacaagctcttgtaagtattgacaaatgaaaagattga +atatttttaaatacaaaatgcgcctacttattaggggaattaaccagattgaaggccaat +cctcacatgtaatgagataatagacgataaatgaaattcttgtaatagttgaactgctac +gtgatgggtattatatatgattgagatcctccaattgccgacgtcttgtcttgatgccca +aaagattgtcaacgaggagctccctcgcgtacctgtcgtccgtatcataaacgacgcgac +atgtacagcactccgaagtataagcaataataatgcgggtaatccagactagatcttttc +ggactcaatgcggtttcacggtaaacatgattaataccggagagtagtcgagcttatcag +cgatgcaagcgaattcattgtgccaggagatacgttgcagataaaaccggcaacgtatgt +caacaagttttggcgatctcgttgtttgtattcgacgaggcgcgggaacttcaagaacta +tcgtatattcaagtccattaccttttagtttcagactggtggagctgactaaagttatat +catcattttgtacactggtttagttaacgataatttcagatttaacatgaccagacgata +atcgctgtatatccagttggaatgtggtttgccagaaaggttaacttataatcaagcctc +tcttcagtcttgattcgtcgtatcccatccattgcgctatacctcagtgtatttggagct +gtagttataccgtgtgctaagatcagtagacatgacgagagcaatattatctaccttaca +agcatcaacggacgtctagtcggaacaaaagactctaaaactcgaacttcaggttaatat +actatagttctgtattcagcagttattcttatattcgatattatcttgcctattggatgt +ctgactttagtatattaatcatagtatctgccatgtaaaggtgccagtactaaatctgtt +tcacagtgcgaattataaacggttacaaccattaaagacaacaagaccctatagctttat +ttgaattttgtcaatgcgcaacttggagctcgcgatacatcccaattagtctatagggtc +gggacgattctacggcatttctggttataatgacaacatggattgtggcccgagaatcgc +tctttcattaattaagcaatcattacagtcttataagcgctacttccgagtggtagcagg +taactcgatataaggtcgcatgagccgaatagcttaaaaaacaggccaccgaacattgat +agagaataccgaccacagcgcaacctttgattactttcattaaattgtacggctcactcg +acatcaagcttaagattgcgataatgtgaactcaaatggatcagtactgaagaaccgtaa +cccacttcgcagaaagcgtacccagagaagatacgctgttacaatatacagggtgaaatt +attgcctgttcttcgtaaccatttcgccaaacttggttagaaatgatagccattcatgat +agaaataagctgaatgataccagtatctttaactatgtagtcagggggaagataacgatg +gtccatgtatgtttctgatatgtgacagtattggccgcgtaatttgctaacgaagctact +taatgcctttgagcttcatatagatttctttaatcaaaatcggcaaaaagatagtatgag +ctataatatatgctagtagagaactctggaccatcatctatatgaatactgattcgagcg +tgcaattactttagcctgcgtactactgactctacaaaacactctgagataagtttgtag +tcagtaagtcgctctctataaaccttttggatgaccattgtacagccacttatagatccc +aataaatagcacaggagacagagtttttcaatgctcgatcatttgccgatagtattttcg +tctaacctcagggcacctattatttgatacctaacctaacggccctttcacaatggagaa +atatatgacatcgggacaaacacaaatggtgggtggccaggagatatgacatggtggcgt +ctctaagaaacacggactccctctaggcaaactcacgtaaccaattttaatgtcaaacaa +aacgctcgaaaagattttgccgtgtaatgacctggtacattgactggtcaggaatacatc +actgtagttgccgtagtgtcctgttggtgttccatcaagacacatcgtataacgcaattt +acgacggacatcagatcaagttatacagattatttaagtatcacgtgtgcattgggacat +aagggatctcacacatgccttggaacatttttgctttgtgccgctttttcgctgcactac +caatccttacttaccagtatattcaaaggtcgttaacagaatgagaaaggttagggctct +aagttatcgtcgattgggatagacgagacatttgcgagcgccctccacggatacgaatct +cccatatcaatgtgaactggatgctatgcagtttagttcttacgtctcctagtggtaaaa +atcaaagtagcactcgcatagcagttattcagaacctaatacacaaaaccgtcaaacatt +ttctaattctaggtatgggccgatcataggagctaaggtgaaactcataaatgttttgtt +agatctagcatcctaaaaagatgcatatactgagtagctggcgtgcattctctcaattgt +atcctttttaactgaactagtcggtcccatttcgtgactgagatctattaaccgataaga +ttaataacactcgcattcgtatcagctcagagtgaagtttttcaataatttgactgatat +attaacttctaaaataaccctttaagcctcggatccgtttcccaatcacatcaaaaattc +ttattccaactatctacggattaacaacgtgcatggggatcgtagtaagaacttgttccg +atcactttgagtatatcaagttgacggcccggttattattgaatagaaacattcacctgc +taaattaaataccgcacatcggatacccgatttcagagggccgtcttactaagggcaggc +tttgttcggtttaactgagatgttcattattttacagtatgcttcaactaatatgtaacg +aaggacagtggatctgtctccatagtagatcttcagtcgtgaatttcataccgctcctat +ttaagttcgcgttcgagttgttgatcatggcacgtgaaagcaacccctagtattctagac +gaaaattttttctagttcatctgataatttgccaattcaaaaacaaccgctggtttcccg +gcgcattctctaaaatggaagtcgaacctagagccattatttgtcggtaacccatgagtt +ccttcttttcagaagttaatacactgtggtcctatacagaggaaaaacagcggttatata +cgatcgtggcataacaacattggatcaagatagcaatttggctacctattctaattctca +ctagattcggtattccactacaatatcggcagattaggattggatgaataatcggtgttt +aagtccggttgcgtctccaatctcctaatttttattaatattgatcttggtgacctattg +taaataaaaacttcaagactttgaataacggtgaaaagatagaagactcatttgaaaatg +gatcatccacagatccaaacattagcaagacactaatccccaactagctattctgatcgc +gatcgtgctgcagtactcctgtcacaatagtctgttcatgatctaattctttttgggctt +tgttcgatggtgattcagaatctttatccggtcgcttccctgtagctactttgtggggat +attgcccggggattatagggttgagatcgtttcctaaaagtatttaaaccaagtagactt +caactaaactacatcagaacatcgtgaagacaccatacgcggtacctttatttaccgata +acatttcttcaagaaataccggtaagcagcataatgaccctaaacagctcggggtatcgt +cgtagttttaaattttatttaggttactgctcaaggaataaaaactaactatttaattta +taataatattacaaggctcacactgattagatttgtctataagacttcgcgatcccccat +taccggattgtcttaagaataaactagataaaccatgcattttctagataaggcctttag +tctaattagatacaaaaaacacgatagttgcatccttaatttattgtgtcaaacctggaa +ccttttaattacccgcaaatcactttatgtcgagactacctctgaaatttattatctacc +taccgcatgaggacttgaaccatcttgtaggagttatgtttattagctaagattcgttta +tcctgtagcggtccatgtatattcaacaagcaaaaagcactcagaattgtttttagttga +gtcaagactgatatataaataagtttccctagttttttcgtggtgggacgatattgaatt +gaatcttaaccgaagagtttcccactctgtcgcacaataatacacgccaatatttccagc +cctgcttatgccttaatcggttactcaatctcccattgaagttcattttgatctgcatag +aagtttcgggcccagccttttttctgccaccttcctccaagctctgtagacgcactctaa +gattgatgctcacatgtattaattctacattaacataaatatataagtcatgcatcttcg +agtaaaatatctggttctccaacatgtcctggcacgtatcgttataatgcccatacatgt +agtattaaaatgattgggttaactggatattaagatcatcgaaattgtaaagtcaaatta +acaatactgtctcaagaccgtgtattcctcgtgctcggaagggctattacgcttacttcc +gttttggtatcttaatatgactttcaaaaattaagttgcagtgagtcctacctgcgtgca +tcggttagcaagagtataaaagttgtttaaacgaactacttgctttacaataccggtcgt +atatatcgccgtgaatccagaagattgtcttctttggattatcaaccgagatcctgtgga +ccgatgttttgggaccttcacagaggactccaggtagagctcgcttttgcattaatctaa +gaattgtacctctctaaaagatctaaaacagtgaatgtgtatttcatggaaaaacacaga +gaaacgtaaattactttaggccgaaaggcacatgagttattatacatatacgagatggtg +gtatacatcgaattcggggcatacactatagttgcattgtatttagctgctttaaataat +atgatattaccttccttacataagacattaccggcataccctggttttcaacttgtgggg +ctttttgacgatcgcactctcatttgatccgagtagggcggtgacccctgcttttcaaat +acaaaaatttcgctatgaaggtaatagattacttttcgctgttatgatagaaacggtaaa +tttaaaattgaaacttctagaaaagtaaagtaacgagaaatgattttgtgaataatgcgg +tcatgattgcgcaagtaagaaaaaaaggcaaaaggatgcgcggaatagaaacttatcagt +cacgggtatcttgatttcattcttcttgtcaattgccgacataggatgaaatcagattcc +aatgcaatacacagtaacccccacccttgattgtaatgtcgatttgaagttgtacgcgtc +gacgaagtggatagtatacgggccttttgtacggtgcgatcaactatgaatctcggcgag +ttagatggtcgtacaatctcacacatagaggtcacttgcctgtaatgacgaattttcggc +taggtactcgaactttattagaagtaaaaatgtgggcaaaagaaggattccattttacaa +gacgattacaatgagttacatgtctctcaacgtagtctttccctagtagtctttgaacta +tttaggtactccagaaaattttagcaaagggtttctgtgtgaatccgccattcatgttta +tgatggaacaataagaataacgccctcgtatgttatcgacagtgaagtcagcagttcggc +caaaaacatattcaatttagtacagatccccagaagttaagctaagtgctctaaaatggc +ctaaacggttatcaaagtaggtctaattactatactaacgggtgcatcgtaataactgct +gtcgatgcaacactatatgatagtgtcgttttgctatatatgtacaatgtgacaaagaag +ccttagcgattcttgcaaacttaggacttcggattctcaatcttaaatgtccgaaaacgc +aaagattcaaaaatttaatctatgagcagatatgcctgatggtgactacgcgtatgttaa +ggctaaatgttgacaaccgcacacataatcgaactattgatagtcgggagcataaccagg +tgaacgtactttgttcacgacatttattgacatgttctaaatacgtctcaaaatcacggc +gcactagaaaacgcaatcaaatcattgtcctggtttaagggccgtaatgccggtagtgtc +aaacttcatgagaactttagctggcttttggccagtatttagggaccaagagcactagcc +ttaagctgaatattttgccatttatctactgttataactttaaaacttggtggcaccaga +cttgtcgatacacacgcatcaatctgtaacgtaaaaggtttactaagaacaagcgtagga +attgagtttatattatatttaaactaaaagatgatattagcttctgagggcgatagggct +ccaaatcataaagaggaatatattattacacgattagaaacccacaacatacctcgaatc +gcccaaaagtttgacgaaacttggcagtactccacatctcagtaatacagttgggagagt +ctcaaatgttgttttattactcaatgaaccaccctcataatttcactgctgttccattaa +atttgcaaacgatcatttgctttgaagaaacgtaaaatcgacaaaattacagataagtag +atgcataataaaaaaaactgctcgctataacacgatcatcgtgcattcttacttaggagc +atcacccgcacaataacgtaccttaaactacaacactattagaccgagtactgtaattca +cgaaagctcaagctcgcattgtaaagaacttgctctctcgtaaaatgtgataatagtttg +cggagaggattcaattattttccattgcacctactccactagattcgataaaagaaggtg +gtcctcccttaaaaagaaatgttaagtaacatcggaaccataagcaaagcatgtaagtga +accgtcatccttccctaagaaacataaaggtttttaataatgtcgactgtgaactataac +tgcatcctttcctgacctactccggttccttgttgttatttctgaacgagaccagtagat +aaacaatgtaaaccacagtgggtaccaatggtgcatgtgacgctaccgttgttttaagtg +cccgtacaaacataagaagtcataatcttacttgaaattaattttgccttttattttttt +tcaggctcgaaattaatgatttgttttttttgaccttctagttacgctaatatgcggtcg +cctgtggtttctattgagtcctataacgggatgggatctaatacgtttggttactagtaa +acaaggtataaatttgataccggagtatcaactgtataacatcaagctttatgactcata +cgcgaagtaatgacacaaggctttcaggagatcgcgagtacagagccactaaggggtgta +ttacgatagtgacaccaccgagcgcactcactccccaagtagatttatgatcctacgcta +agtattagatatataaccaaagaggttctagtcagtgcaactcttagaataataattagc +cggttttgcctttttaggcctaatgcaatattcagctagcccttatgtatctcgcgttcc +acagcaccactcatggcacgcgtttaaactaatcaaatataatctatgaatgttatgcca +gtacttgaataaatcaggttttttataagtccttgcatactctcgttatatactgttaga +gtcttaccccatagaaattctttcatctgcaaacttagaagaattctcagctacggggag +cataaagtccccaggatgttgacaaatacaacaaatgtggcttatacaaacactccatat +gaaaatcgaaccctcgtggtagttttagccgaaccttgtacggataaatccctccatttt +ccaatagcagatacctatcctactacctcgtggtattaaattaaagcttgaaatatagag +ctgcatagcttatccaattcccaagcacgagtctaccgtcgtaaccacgatttgatttac +agacgctagagcaaacccatctttaaacatataagtaaaaattaaagggtgagtgcgtac +gtgtttactagcaacttcgcttattaagacaattgtttataagccataattaaaaacata +tgttcaacaggttcattgatatttgtaattgcacaggtttttaataaggatctacgtaag +tataatgaacaaactttttaccagagttatattctgtactttgaaaatgctcctctaccg +ccttagagactttcaattagattttttgcagttaatctatgcgtaagtgaaccatgcaag +ggatgcgattcaaccgcctcgtgctaaccctatcgtctgtctcataactgtaggtctaat +ataattttcagttttcgaacacataaccctttgaaaatctgctatttaatgtctcacctg +catgcactatcttctatactgctcagaacggctatacgtcactatgctccaagtgacgat +ttaaacgaagcaaggaataataggtttattttagtgcaaaacaattaagtgcggactacg +tgctctttacaataagccttgtgattgggctataggttaagtcccatattaacgatctcc +aatgtacaaaatcgacaatcgctttgcattacccggttactagtcgaattacagatagct +gttagatactcactctaattttggacaacaatcccaatcttggggtcgtctatcgcctga +agctcgtaaatccttccatcttaaacgattacatattatagacttgttcggggtagagat +atcacagttgtgcaaacattgtaaatcgatactagtttatgttggtagtctagttgcttt +taccattccccgaaaaacttgatctactatttcgacaacagtaaacttgaactaggtaag +tgaaaacagagaatgcctcatagtgccactatttgtccactatatgtaagtgtagcttta +cataatccactatgactgagatcattacggcctaggaaagcagcgtagaaaaaaagggcc +cggatattacgactgtaactataaaactagttactggtagcgcgccatgtatagatttgt +tttaccggttgtggttgcgttaacgaatttcagccgcgaaaattgatccgttaaccagtc +catctcgacttctataaaacgataaagtaaagttgatgttcagcctccttcttatggttg +catcgagagtacactactcagtgggaaatagatcggggttcctacttcagattgtattat +ctaggcaattgccgattgtgccatacctggataaaataagctacctacatgtgatgctta +tctattatcgtcatactaccttagggtgtcctgttgaacgctacattaatctttagccgt +ttgagatgttccaatggataggagtctaacgcatgatgaagtttaggaaggcagagcatc +ccactaagtatgtgacagtgtatttcgaaacgagacgttataaatagaaaaaaggtcctt +ctggttctattctgctgaactattgaatggaaagattggttgacctacgtactatttgct +tgaagtcatcaatttgacggggtgagagacatatggtgcatactttacggactctatatt +ttagatcagaagcttagcagtcttctctacaccccctcacgacataattgcttttaagaa +tctatgtttgattcctctacgggaattcggatccgttcgcatgtgcggtttatctaaacc +aggggacatatgttcagctaaagcatacgaacactttgctaactagacgtatgtatagta +gctataaatcccgacgatatttacaaaaagaaatgagactcaaatatatacatagcgacc +ctacacttattcgcaccctgatctaggcgatcctagcacccacacccgaaagtgagcact +agtgtcttccgtattaaatttactgcagttgagattttagttgtctactaaggattactc +taacccgtaataaggatcaagactcggtactagctttactatcattccctatgtgttttc +ctaactcacaagggtacgtaccagcctatgtaattacaataatgataaagacacaaagga +agtaactttacaaatgagtctccagttacactagcttagtccctcccatcttgctttgaa +gtctaaatacgcaatctctgaggatatacagcagaagaacactcataacgttggagtcca +agaattagactcatagggcccccaacatttaatatgtactgtgagtttgaaggtgttcta +ttgttaattcctgctcttgatacatgacacgtactccgtgtttaaggcttcggactgact +ttctttcataagttgagcaacgaaaatttcagaatcgataagttggattcactaactaat +acggctgattgaaaactccactccggacctatatggtcgacctttatacgtaaccgatat +aaaacttataggctggtatatcgagccttcctagcgcaatttcggatggggtttcttcta +ctactcaacaacggaatagtctttgtttagtaaaccagagctcaggacgcccaatacgta +ggagagcgctgtggagcatgtgtcattatggactggagcactcttaaatcactctgcgtg +tgctaaacgatagatcataacatgtcctgagtaaattttcttgatacgtcgcaatatacc +gttattagttaaacgttctcatccgtcatgcgtgaaatacggctgtcgtgctcagatata +ctattagcgactcatctcgcctaacacgcacacgtataaactcggaatgactgccgctct +tacatattagaaatacagactacaccacggaagcattgggtcattctcaaccgctgtata +aaagatgattagtcttataataagattaccaaagaggcagaatcatgggtagtaaatcta +ttattcaagtgattaccgtcgtgtaggcagggagtgaggacgagatggtactcaggacaa +atattaaccggacgaagtggtttacgtcgtactttcactattagtagtaaatacaaggta +acaccggggaatagtactaaatataatgatatctatcttcgggagaacgagtcgtctatt +gctttgaacattctcaaggcgtaaaatgtgctgacttatagcatgatacaaccgattgtt +acttttgtctattcaaaagattgaatagttttttatacaaaagccgcatacttatgacgg +ctagtatacagtttcatcccctagcatcaatgctatggacagtattgaacttataggaaa +ttcttctaatagggcaaatccgtcgtgatgcctattttttttcagtcacatcctcaaatg +gcactagtattgtcgggatcccattaacaggctcaaccacgagctcacgcgaggacatgt +agtccgtatctttaacgaagcgacagcgacagaactcccatggataaccaattataaggc +ccgtaatcctctagacatcgtttaccaataaatccgctttctccgtaatcatgttgaata +ccccagagtagtccagatgataaccgatgaaacacaagtctttctcaatgcacttacggt +gaacttattaccgccaacgtagctcatcaaggttgcgacatctagttgtgtgtttgcgac +gagcccagcgaacttcatcaactttcgtatattcaacgccttgtaattttactttaagac +gcctggtgatgtagattcttagataatcagtttgttatcggctgtactttaccataattt +cacaggtttcaggtcaagaagattatagctgtatatacagttccatgctcggtgcacaga +aacgtgatcggataataatcaatcgcttatgtcgtctttaggcgtatccaatacatgccc +cgataccgcagtgtatttcgacatgtaggtataccgtcgcatttgagctcgagtcaggac +gtcagctagattagattccttaatagaatataccgacctctagtccgaactaaactatag +ataacgccaacttcaggttaattgtctagtcgtctgtttgcagatgggattcttagatga +gtgagtatcggccatattggttcgagcactttagtttttgatgcataggatatgcaatgt +atagctgaaagtactttatctgtttcaaactcacattgattaaaccggtaaacctttaaa +gactacaagaaaatattcagtgagggcaattttgtcaatcacaatcttccagctagagat +acttcacaatttgtcttgaggctacgcaacattagacggattttcgcgttttattgaaat +aatcgaggggcccaagagtatccatagttcattttgtaagatttctttacaggcttatta +cagcttcttcagactcctacatgcttacgagttatatgctagcatgtgaacaatagatta +atatacaggaaaacgtacattgagagagatgaccctacacagcgcaaccgttgagtactt +tcattaaagggtaacgctctcgagacagcatccttaagatggccttattgtcaaatcatt +tgcagaagtacgcaagatccctaaccaacgtagaagaatccctacaaacacatgagacgc +ggtgaaaatagacagggtgttagtattcaatcttcggagtatcaatttcgccaatcttgg +tgagaaagcataccctttcttcagagaaagaagatcaatcataacactatctttaacgag +gtacgcacgcgcatcattacctgcctccatggatctttaggatagcggaaagtattggca +gcgtattgtgatttcgttcctactttatcaatttcacattcatatacatgtcttttatca +aaatcgccaataagataggatgagctatattagatgctagtagagttcgcgccaacatca +tcgataggaatactcaggacagcgtgataggacttttcaatccctaatactctctataat +tataactctctcttaagtttggaggcagtaacgcgctctatataatcagtttgctgcacc +attcttcagcctctgatacatacaaataaattccacagcagtaagagggtttaattgaga +catcttgggaacttaggattttactctaacatcaccgaaacgattattggataccgtacc +taaacgaactttctcaaggcagtaatataggacatccgcaataacacaaatgctgcctcc +ccaggagttatgtcttcctggaggctatatcttacacccactcactataggcaaactaaa +gtttaaatgttgattgtctaaaaaaaagatagataagagttggccggcgtagcacatgcg +aaagtgaatcgtaagctataattctctggacttgaagttctgtcctgttcctctgcaaga +aacaaacttcctttaaagctatttacgacgcacatctcagcaagttataaacatgttgga +agtttctagtcggaattcccaaagaacggatctatctaatgcattcctacatttttcctg +tctgccgatggtgccatcctattcaaagaatttcttaaaagtagattaaatgggactttt +aacaatgagtaaccttacgcctctaagggttcctcgagtgccatacaccagtcaggtccg +agccacatacacggagaacattctaacatagcattctcaactcgatcatttgcaggttac +ttctttcctatcctagtgctaaaaatcatacttgcaatcccatagcacggattaagaacc +taagaaacaattcagtaaaacatgttcgaattcttggtatgggaacatcattgcagctat +ggtctaacgcattaatgtttgggtacatcttccatcatataaacaggaagagtctgacga +cagggagtgcttgcgatcatgtctatcattgtgaaatcaaattgtagctcacatgtcgtc +tatgagagcgtgtatccgataagatttagaaaaatagaagtcgtataagatctcactgaa +cttttgaatgaatgtgaagcatatatgatctgctttaataaaactttatccataggatac +gtttccaaatcaattcaataattattagtcaaaatagataaggatgaacaacctgaaggc +cgatcggacgtagaaagtggtcccatcactttgagttgatattgttgaaccacacgttat +tatggttttcaaacagtctcaggatattgtatatacagataatccgataccagttgtctg +acgcccctcttacgtaccccaccctttgtgacgtttaaagcagttgttcagtattttaaa +ctaggcggcaactaatttggaaagaagcacagtggatatgtctaaattcttgttattcag +gcctgaatttaatacaccgcatagttaacttcgcggtagagttgttcatcatgcctcctc +taagctaccacttctatgatacaccaatagttgttctacggaatctgataattggccaag +tcataaacttccgctgcgttcaacccccttgctcgaatatccaactcgaaaagacagcct +tttggtgtccggaacaaatcagttacttcttttctgatgttaattctctgtggtcagata +cagaccaaaaactccgcggatttaccatcctccaagaacaaatttgcatcaacatagcat +tttggctacatattctaagtctcaatagtttaggttttcaactacattatcccaacatta +ggattggaggaataatagctgggtaagtccccttgcgtctacaatcgactattttttatg +aatatgcttctgccgcacctatggttattaaaaaagtcatgactttgaagaaccctgaaa +agatagatgaatcaggtgtaatggcagcagccaaagagcatataattagcaacactctaa +gaacattatagatatgatgatagcgatcgtcatgatgttatccggtcacaatagtagctt +catcagctaattcgttttgccagtggtgacttgcgctggaagaatcgttatacggtccct +tccctcttgatacggtgggggcttattcaaccgcgtggattgggttgtcatacttgcatt +aaacgatgtaaaccatctagtagtcaactatactaaatcacaaaatagtgatcaatacat +acccgcttcatggttttaaccatttaattgattaaagatattccgctaagaaccattatc +tacctaaactgatcgccgtatcctagtagtttgaaatttgatgtaccgtaatgatcaacg +aagtaaaacgttatattgtatgtagaataataggtcttggagctaaatgatgtgattggt +agtgaagacttacccttacaactttaccggtttctcggaagaatatactagagaatcaat +gcatgggctacataagcactttagtctaatgagataaaaaatacacgagtcttccatcat +gaattttttgtcgaaaaactcgaacctggtaatttaaaccatatatctttatgtcgtcaa +taactctcatatgttttatataacttcccaatcacgacttgtaactgcttgttcgactga +gctgtttgagctatgaggccgggatccggttgagctacatctatttgctacaagaaaaat +gaaagcacatttgttgggagttctggctacactcatagagaaataagtggcccgagtggg +tgcggcctgcctccatattcaagtgtatcttaaaccaagtggttccaacgctcgcgctaa +agaattaaagcctttatttcctccacggagtagcccgtaatccggttcgaaagagaccat +tgaagttaattttcatatccagtgaagtttaggcacaagcatgtgttctgccacatgcct +caaagcgctcttcaaccaagatatgattcatcctaacttcgatgaatgcgtctgtaacat +aaatatagaaggaatgattcggcgagttaattttcgccttctccaacatggcatccctac +gttcgttataaggaccatacatgtaggttttaaaggtttgcggttaatcgatatttacat +catagaaattctatagtcaaatttacaagactctagatactcactcgttgcagccggcta +ggaagcgctttgtaccttacttcccttttcgttgcgtaatatgaatttcatatagtaagt +tcaaggcactcatacctccgtgaagagggtagatagactattaaagttgtttaatagtac +gtattgatggaaatgacccgtaggagatttaccactcaatccacaagattcgctgctgtg +cattatcaaaacagtgcatgtcgaaacatgggttgggtccttcaaacacgaatccaggta +gagatacctttgcaattttt diff --git a/third_party/rust/regex/examples/regexdna-output.txt b/third_party/rust/regex/examples/regexdna-output.txt new file mode 100644 index 0000000000000..5e06c2662d7b3 --- /dev/null +++ b/third_party/rust/regex/examples/regexdna-output.txt @@ -0,0 +1,99 @@ +agggtaaa +| +tttaccct +0 +[ +cgt +] +gggtaaa +| +tttaccc +[ +acg +] +3 +a +[ +act +] +ggtaaa +| +tttacc +[ +agt +] +t +9 +ag +[ +act +] +gtaaa +| +tttac +[ +agt +] +ct +8 +agg +[ +act +] +taaa +| +ttta +[ +agt +] +cct +10 +aggg +[ +acg +] +aaa +| +ttt +[ +cgt +] +ccct +3 +agggt +[ +cgt +] +aa +| +tt +[ +acg +] +accct +4 +agggta +[ +cgt +] +a +| +t +[ +acg +] +taccct +3 +agggtaa +[ +cgt +] +| +[ +acg +] +ttaccct +5 +101745 +100000 +133640 diff --git a/third_party/rust/regex/examples/shootout-regex-dna-bytes.rs b/third_party/rust/regex/examples/shootout-regex-dna-bytes.rs new file mode 100644 index 0000000000000..766fbc666183a --- /dev/null +++ b/third_party/rust/regex/examples/shootout-regex-dna-bytes.rs @@ -0,0 +1,785 @@ +/ +/ +The +Computer +Language +Benchmarks +Game +/ +/ +https +: +/ +/ +benchmarksgame +- +team +. +pages +. +debian +. +net +/ +benchmarksgame +/ +/ +/ +/ +/ +contributed +by +the +Rust +Project +Developers +/ +/ +contributed +by +TeXitoi +/ +/ +contributed +by +BurntSushi +use +std +: +: +io +: +: +{ +self +Read +} +; +use +std +: +: +sync +: +: +Arc +; +use +std +: +: +thread +; +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +: +: +regex +: +: +bytes +: +: +Regex +: +: +new +( +re +) +. +unwrap +( +) +} +; +} +fn +main +( +) +{ +let +mut +seq += +Vec +: +: +with_capacity +( +51 +* +( +1 +< +< +20 +) +) +; +io +: +: +stdin +( +) +. +read_to_end +( +& +mut +seq +) +. +unwrap +( +) +; +let +ilen += +seq +. +len +( +) +; +seq += +regex +! +( +" +> +[ +^ +\ +n +] +* +\ +n +| +\ +n +" +) +. +replace_all +( +& +seq +& +b +" +" +[ +. +. +] +) +. +into_owned +( +) +; +let +clen += +seq +. +len +( +) +; +let +seq_arc += +Arc +: +: +new +( +seq +. +clone +( +) +) +; +let +variants += +vec +! +[ +regex +! +( +" +agggtaaa +| +tttaccct +" +) +regex +! +( +" +[ +cgt +] +gggtaaa +| +tttaccc +[ +acg +] +" +) +regex +! +( +" +a +[ +act +] +ggtaaa +| +tttacc +[ +agt +] +t +" +) +regex +! +( +" +ag +[ +act +] +gtaaa +| +tttac +[ +agt +] +ct +" +) +regex +! +( +" +agg +[ +act +] +taaa +| +ttta +[ +agt +] +cct +" +) +regex +! +( +" +aggg +[ +acg +] +aaa +| +ttt +[ +cgt +] +ccct +" +) +regex +! +( +" +agggt +[ +cgt +] +aa +| +tt +[ +acg +] +accct +" +) +regex +! +( +" +agggta +[ +cgt +] +a +| +t +[ +acg +] +taccct +" +) +regex +! +( +" +agggtaa +[ +cgt +] +| +[ +acg +] +ttaccct +" +) +] +; +let +mut +counts += +vec +! +[ +] +; +for +variant +in +variants +{ +let +seq += +seq_arc +. +clone +( +) +; +let +restr += +variant +. +to_string +( +) +; +let +future += +thread +: +: +spawn +( +move +| +| +variant +. +find_iter +( +& +seq +) +. +count +( +) +) +; +counts +. +push +( +( +restr +future +) +) +; +} +let +substs += +vec +! +[ +( +regex +! +( +" +B +" +) +& +b +" +( +c +| +g +| +t +) +" +[ +. +. +] +) +( +regex +! +( +" +D +" +) +& +b +" +( +a +| +g +| +t +) +" +[ +. +. +] +) +( +regex +! +( +" +H +" +) +& +b +" +( +a +| +c +| +t +) +" +[ +. +. +] +) +( +regex +! +( +" +K +" +) +& +b +" +( +g +| +t +) +" +[ +. +. +] +) +( +regex +! +( +" +M +" +) +& +b +" +( +a +| +c +) +" +[ +. +. +] +) +( +regex +! +( +" +N +" +) +& +b +" +( +a +| +c +| +g +| +t +) +" +[ +. +. +] +) +( +regex +! +( +" +R +" +) +& +b +" +( +a +| +g +) +" +[ +. +. +] +) +( +regex +! +( +" +S +" +) +& +b +" +( +c +| +g +) +" +[ +. +. +] +) +( +regex +! +( +" +V +" +) +& +b +" +( +a +| +c +| +g +) +" +[ +. +. +] +) +( +regex +! +( +" +W +" +) +& +b +" +( +a +| +t +) +" +[ +. +. +] +) +( +regex +! +( +" +Y +" +) +& +b +" +( +c +| +t +) +" +[ +. +. +] +) +] +; +let +mut +seq += +seq +; +for +( +re +replacement +) +in +substs +{ +seq += +re +. +replace_all +( +& +seq +replacement +) +. +into_owned +( +) +; +} +for +( +variant +count +) +in +counts +{ +println +! +( +" +{ +} +{ +} +" +variant +count +. +join +( +) +. +unwrap +( +) +) +; +} +println +! +( +" +\ +n +{ +} +\ +n +{ +} +\ +n +{ +} +" +ilen +clen +seq +. +len +( +) +) +; +} diff --git a/third_party/rust/regex/examples/shootout-regex-dna-cheat.rs b/third_party/rust/regex/examples/shootout-regex-dna-cheat.rs new file mode 100644 index 0000000000000..63264aebad95c --- /dev/null +++ b/third_party/rust/regex/examples/shootout-regex-dna-cheat.rs @@ -0,0 +1,922 @@ +/ +/ +The +Computer +Language +Benchmarks +Game +/ +/ +https +: +/ +/ +benchmarksgame +- +team +. +pages +. +debian +. +net +/ +benchmarksgame +/ +/ +/ +/ +/ +contributed +by +the +Rust +Project +Developers +/ +/ +contributed +by +TeXitoi +/ +/ +contributed +by +BurntSushi +/ +/ +This +technically +solves +the +problem +posed +in +the +regex +- +dna +benchmark +but +/ +/ +it +cheats +by +combining +all +of +the +replacements +into +a +single +regex +and +/ +/ +replacing +them +with +a +single +linear +scan +. +i +. +e +. +it +re +- +implements +/ +/ +replace_all +. +As +a +result +this +is +around +25 +% +faster +. +- +- +- +AG +use +std +: +: +io +: +: +{ +self +Read +} +; +use +std +: +: +sync +: +: +Arc +; +use +std +: +: +thread +; +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +: +: +regex +: +: +Regex +: +: +new +( +re +) +. +unwrap +( +) +} +; +} +fn +main +( +) +{ +let +mut +seq += +String +: +: +with_capacity +( +50 +* +( +1 +< +< +20 +) +) +; +io +: +: +stdin +( +) +. +read_to_string +( +& +mut +seq +) +. +unwrap +( +) +; +let +ilen += +seq +. +len +( +) +; +seq += +regex +! +( +" +> +[ +^ +\ +n +] +* +\ +n +| +\ +n +" +) +. +replace_all +( +& +seq +" +" +) +. +into_owned +( +) +; +let +clen += +seq +. +len +( +) +; +let +seq_arc += +Arc +: +: +new +( +seq +. +clone +( +) +) +; +let +variants += +vec +! +[ +regex +! +( +" +agggtaaa +| +tttaccct +" +) +regex +! +( +" +[ +cgt +] +gggtaaa +| +tttaccc +[ +acg +] +" +) +regex +! +( +" +a +[ +act +] +ggtaaa +| +tttacc +[ +agt +] +t +" +) +regex +! +( +" +ag +[ +act +] +gtaaa +| +tttac +[ +agt +] +ct +" +) +regex +! +( +" +agg +[ +act +] +taaa +| +ttta +[ +agt +] +cct +" +) +regex +! +( +" +aggg +[ +acg +] +aaa +| +ttt +[ +cgt +] +ccct +" +) +regex +! +( +" +agggt +[ +cgt +] +aa +| +tt +[ +acg +] +accct +" +) +regex +! +( +" +agggta +[ +cgt +] +a +| +t +[ +acg +] +taccct +" +) +regex +! +( +" +agggtaa +[ +cgt +] +| +[ +acg +] +ttaccct +" +) +] +; +let +mut +counts += +vec +! +[ +] +; +for +variant +in +variants +{ +let +seq += +seq_arc +. +clone +( +) +; +let +restr += +variant +. +to_string +( +) +; +let +future += +thread +: +: +spawn +( +move +| +| +variant +. +find_iter +( +& +seq +) +. +count +( +) +) +; +counts +. +push +( +( +restr +future +) +) +; +} +let +substs += +vec +! +[ +( +b +' +B +' +" +( +c +| +g +| +t +) +" +) +( +b +' +D +' +" +( +a +| +g +| +t +) +" +) +( +b +' +H +' +" +( +a +| +c +| +t +) +" +) +( +b +' +K +' +" +( +g +| +t +) +" +) +( +b +' +M +' +" +( +a +| +c +) +" +) +( +b +' +N +' +" +( +a +| +c +| +g +| +t +) +" +) +( +b +' +R +' +" +( +a +| +g +) +" +) +( +b +' +S +' +" +( +c +| +g +) +" +) +( +b +' +V +' +" +( +a +| +c +| +g +) +" +) +( +b +' +W +' +" +( +a +| +t +) +" +) +( +b +' +Y +' +" +( +c +| +t +) +" +) +] +; +/ +/ +combined +into +one +regex +in +replace_all +let +seq += +replace_all +( +& +seq +substs +) +; +for +( +variant +count +) +in +counts +{ +println +! +( +" +{ +} +{ +} +" +variant +count +. +join +( +) +. +unwrap +( +) +) +; +} +println +! +( +" +\ +n +{ +} +\ +n +{ +} +\ +n +{ +} +" +ilen +clen +seq +. +len +( +) +) +; +} +fn +replace_all +( +text +: +& +str +substs +: +Vec +< +( +u8 +& +str +) +> +) +- +> +String +{ +let +mut +replacements += +vec +! +[ +" +" +; +256 +] +; +let +mut +alternates += +vec +! +[ +] +; +for +( +re +replacement +) +in +substs +{ +replacements +[ +re +as +usize +] += +replacement +; +alternates +. +push +( +( +re +as +char +) +. +to_string +( +) +) +; +} +let +re += +regex +! +( +& +alternates +. +join +( +" +| +" +) +) +; +let +mut +new += +String +: +: +with_capacity +( +text +. +len +( +) +) +; +let +mut +last_match += +0 +; +for +m +in +re +. +find_iter +( +text +) +{ +new +. +push_str +( +& +text +[ +last_match +. +. +m +. +start +( +) +] +) +; +new +. +push_str +( +replacements +[ +text +. +as_bytes +( +) +[ +m +. +start +( +) +] +as +usize +] +) +; +last_match += +m +. +end +( +) +; +} +new +. +push_str +( +& +text +[ +last_match +. +. +] +) +; +new +} diff --git a/third_party/rust/regex/examples/shootout-regex-dna-replace.rs b/third_party/rust/regex/examples/shootout-regex-dna-replace.rs new file mode 100644 index 0000000000000..f0bdee335d9b6 --- /dev/null +++ b/third_party/rust/regex/examples/shootout-regex-dna-replace.rs @@ -0,0 +1,163 @@ +use +std +: +: +io +: +: +{ +self +Read +} +; +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new +( +re +) +. +build +( +) +. +unwrap +( +) +. +into_regex +( +) +} +} +; +} +fn +main +( +) +{ +let +mut +seq += +String +: +: +with_capacity +( +50 +* +( +1 +< +< +20 +) +) +; +io +: +: +stdin +( +) +. +read_to_string +( +& +mut +seq +) +. +unwrap +( +) +; +let +ilen += +seq +. +len +( +) +; +seq += +regex +! +( +" +> +[ +^ +\ +n +] +* +\ +n +| +\ +n +" +) +. +replace_all +( +& +seq +" +" +) +. +into_owned +( +) +; +println +! +( +" +original +: +{ +} +replaced +: +{ +} +" +ilen +seq +. +len +( +) +) +; +} diff --git a/third_party/rust/regex/examples/shootout-regex-dna-single-cheat.rs b/third_party/rust/regex/examples/shootout-regex-dna-single-cheat.rs new file mode 100644 index 0000000000000..bbc5ac3d06287 --- /dev/null +++ b/third_party/rust/regex/examples/shootout-regex-dna-single-cheat.rs @@ -0,0 +1,762 @@ +/ +/ +The +Computer +Language +Benchmarks +Game +/ +/ +https +: +/ +/ +benchmarksgame +- +team +. +pages +. +debian +. +net +/ +benchmarksgame +/ +/ +/ +/ +/ +contributed +by +the +Rust +Project +Developers +/ +/ +contributed +by +TeXitoi +/ +/ +contributed +by +BurntSushi +use +std +: +: +io +: +: +{ +self +Read +} +; +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +: +: +regex +: +: +Regex +: +: +new +( +re +) +. +unwrap +( +) +} +; +} +fn +main +( +) +{ +let +mut +seq += +String +: +: +with_capacity +( +50 +* +( +1 +< +< +20 +) +) +; +io +: +: +stdin +( +) +. +read_to_string +( +& +mut +seq +) +. +unwrap +( +) +; +let +ilen += +seq +. +len +( +) +; +seq += +regex +! +( +" +> +[ +^ +\ +n +] +* +\ +n +| +\ +n +" +) +. +replace_all +( +& +seq +" +" +) +. +into_owned +( +) +; +let +clen += +seq +. +len +( +) +; +let +variants += +vec +! +[ +regex +! +( +" +agggtaaa +| +tttaccct +" +) +regex +! +( +" +[ +cgt +] +gggtaaa +| +tttaccc +[ +acg +] +" +) +regex +! +( +" +a +[ +act +] +ggtaaa +| +tttacc +[ +agt +] +t +" +) +regex +! +( +" +ag +[ +act +] +gtaaa +| +tttac +[ +agt +] +ct +" +) +regex +! +( +" +agg +[ +act +] +taaa +| +ttta +[ +agt +] +cct +" +) +regex +! +( +" +aggg +[ +acg +] +aaa +| +ttt +[ +cgt +] +ccct +" +) +regex +! +( +" +agggt +[ +cgt +] +aa +| +tt +[ +acg +] +accct +" +) +regex +! +( +" +agggta +[ +cgt +] +a +| +t +[ +acg +] +taccct +" +) +regex +! +( +" +agggtaa +[ +cgt +] +| +[ +acg +] +ttaccct +" +) +] +; +for +re +in +variants +{ +println +! +( +" +{ +} +{ +} +" +re +. +to_string +( +) +re +. +find_iter +( +& +seq +) +. +count +( +) +) +; +} +let +substs += +vec +! +[ +( +b +' +B +' +" +( +c +| +g +| +t +) +" +) +( +b +' +D +' +" +( +a +| +g +| +t +) +" +) +( +b +' +H +' +" +( +a +| +c +| +t +) +" +) +( +b +' +K +' +" +( +g +| +t +) +" +) +( +b +' +M +' +" +( +a +| +c +) +" +) +( +b +' +N +' +" +( +a +| +c +| +g +| +t +) +" +) +( +b +' +R +' +" +( +a +| +g +) +" +) +( +b +' +S +' +" +( +c +| +g +) +" +) +( +b +' +V +' +" +( +a +| +c +| +g +) +" +) +( +b +' +W +' +" +( +a +| +t +) +" +) +( +b +' +Y +' +" +( +c +| +t +) +" +) +] +; +/ +/ +combined +into +one +regex +in +replace_all +let +seq += +replace_all +( +& +seq +substs +) +; +println +! +( +" +\ +n +{ +} +\ +n +{ +} +\ +n +{ +} +" +ilen +clen +seq +. +len +( +) +) +; +} +fn +replace_all +( +text +: +& +str +substs +: +Vec +< +( +u8 +& +str +) +> +) +- +> +String +{ +let +mut +replacements += +vec +! +[ +" +" +; +256 +] +; +let +mut +alternates += +vec +! +[ +] +; +for +( +re +replacement +) +in +substs +{ +replacements +[ +re +as +usize +] += +replacement +; +alternates +. +push +( +( +re +as +char +) +. +to_string +( +) +) +; +} +let +re += +regex +! +( +& +alternates +. +join +( +" +| +" +) +) +; +let +mut +new += +String +: +: +with_capacity +( +text +. +len +( +) +) +; +let +mut +last_match += +0 +; +for +m +in +re +. +find_iter +( +text +) +{ +new +. +push_str +( +& +text +[ +last_match +. +. +m +. +start +( +) +] +) +; +new +. +push_str +( +replacements +[ +text +. +as_bytes +( +) +[ +m +. +start +( +) +] +as +usize +] +) +; +last_match += +m +. +end +( +) +; +} +new +. +push_str +( +& +text +[ +last_match +. +. +] +) +; +new +} diff --git a/third_party/rust/regex/examples/shootout-regex-dna-single.rs b/third_party/rust/regex/examples/shootout-regex-dna-single.rs new file mode 100644 index 0000000000000..151ae7f42189f --- /dev/null +++ b/third_party/rust/regex/examples/shootout-regex-dna-single.rs @@ -0,0 +1,616 @@ +/ +/ +The +Computer +Language +Benchmarks +Game +/ +/ +https +: +/ +/ +benchmarksgame +- +team +. +pages +. +debian +. +net +/ +benchmarksgame +/ +/ +/ +/ +/ +contributed +by +the +Rust +Project +Developers +/ +/ +contributed +by +TeXitoi +/ +/ +contributed +by +BurntSushi +use +std +: +: +io +: +: +{ +self +Read +} +; +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +: +: +regex +: +: +Regex +: +: +new +( +re +) +. +unwrap +( +) +} +; +} +fn +main +( +) +{ +let +mut +seq += +String +: +: +with_capacity +( +50 +* +( +1 +< +< +20 +) +) +; +io +: +: +stdin +( +) +. +read_to_string +( +& +mut +seq +) +. +unwrap +( +) +; +let +ilen += +seq +. +len +( +) +; +seq += +regex +! +( +" +> +[ +^ +\ +n +] +* +\ +n +| +\ +n +" +) +. +replace_all +( +& +seq +" +" +) +. +into_owned +( +) +; +let +clen += +seq +. +len +( +) +; +let +variants += +vec +! +[ +regex +! +( +" +agggtaaa +| +tttaccct +" +) +regex +! +( +" +[ +cgt +] +gggtaaa +| +tttaccc +[ +acg +] +" +) +regex +! +( +" +a +[ +act +] +ggtaaa +| +tttacc +[ +agt +] +t +" +) +regex +! +( +" +ag +[ +act +] +gtaaa +| +tttac +[ +agt +] +ct +" +) +regex +! +( +" +agg +[ +act +] +taaa +| +ttta +[ +agt +] +cct +" +) +regex +! +( +" +aggg +[ +acg +] +aaa +| +ttt +[ +cgt +] +ccct +" +) +regex +! +( +" +agggt +[ +cgt +] +aa +| +tt +[ +acg +] +accct +" +) +regex +! +( +" +agggta +[ +cgt +] +a +| +t +[ +acg +] +taccct +" +) +regex +! +( +" +agggtaa +[ +cgt +] +| +[ +acg +] +ttaccct +" +) +] +; +for +re +in +variants +{ +println +! +( +" +{ +} +{ +} +" +re +. +to_string +( +) +re +. +find_iter +( +& +seq +) +. +count +( +) +) +; +} +let +substs += +vec +! +[ +( +regex +! +( +" +B +" +) +" +( +c +| +g +| +t +) +" +) +( +regex +! +( +" +D +" +) +" +( +a +| +g +| +t +) +" +) +( +regex +! +( +" +H +" +) +" +( +a +| +c +| +t +) +" +) +( +regex +! +( +" +K +" +) +" +( +g +| +t +) +" +) +( +regex +! +( +" +M +" +) +" +( +a +| +c +) +" +) +( +regex +! +( +" +N +" +) +" +( +a +| +c +| +g +| +t +) +" +) +( +regex +! +( +" +R +" +) +" +( +a +| +g +) +" +) +( +regex +! +( +" +S +" +) +" +( +c +| +g +) +" +) +( +regex +! +( +" +V +" +) +" +( +a +| +c +| +g +) +" +) +( +regex +! +( +" +W +" +) +" +( +a +| +t +) +" +) +( +regex +! +( +" +Y +" +) +" +( +c +| +t +) +" +) +] +; +let +mut +seq += +seq +; +for +( +re +replacement +) +in +substs +{ +seq += +re +. +replace_all +( +& +seq +replacement +) +. +into_owned +( +) +; +} +println +! +( +" +\ +n +{ +} +\ +n +{ +} +\ +n +{ +} +" +ilen +clen +seq +. +len +( +) +) +; +} diff --git a/third_party/rust/regex/examples/shootout-regex-dna.rs b/third_party/rust/regex/examples/shootout-regex-dna.rs new file mode 100644 index 0000000000000..c7f5289327ccb --- /dev/null +++ b/third_party/rust/regex/examples/shootout-regex-dna.rs @@ -0,0 +1,710 @@ +/ +/ +The +Computer +Language +Benchmarks +Game +/ +/ +https +: +/ +/ +benchmarksgame +- +team +. +pages +. +debian +. +net +/ +benchmarksgame +/ +/ +/ +/ +/ +contributed +by +the +Rust +Project +Developers +/ +/ +contributed +by +TeXitoi +/ +/ +contributed +by +BurntSushi +use +std +: +: +io +: +: +{ +self +Read +} +; +use +std +: +: +sync +: +: +Arc +; +use +std +: +: +thread +; +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +: +: +regex +: +: +Regex +: +: +new +( +re +) +. +unwrap +( +) +} +; +} +fn +main +( +) +{ +let +mut +seq += +String +: +: +with_capacity +( +51 +* +( +1 +< +< +20 +) +) +; +io +: +: +stdin +( +) +. +read_to_string +( +& +mut +seq +) +. +unwrap +( +) +; +let +ilen += +seq +. +len +( +) +; +seq += +regex +! +( +" +> +[ +^ +\ +n +] +* +\ +n +| +\ +n +" +) +. +replace_all +( +& +seq +" +" +) +. +into_owned +( +) +; +let +clen += +seq +. +len +( +) +; +let +seq_arc += +Arc +: +: +new +( +seq +. +clone +( +) +) +; +let +variants += +vec +! +[ +regex +! +( +" +agggtaaa +| +tttaccct +" +) +regex +! +( +" +[ +cgt +] +gggtaaa +| +tttaccc +[ +acg +] +" +) +regex +! +( +" +a +[ +act +] +ggtaaa +| +tttacc +[ +agt +] +t +" +) +regex +! +( +" +ag +[ +act +] +gtaaa +| +tttac +[ +agt +] +ct +" +) +regex +! +( +" +agg +[ +act +] +taaa +| +ttta +[ +agt +] +cct +" +) +regex +! +( +" +aggg +[ +acg +] +aaa +| +ttt +[ +cgt +] +ccct +" +) +regex +! +( +" +agggt +[ +cgt +] +aa +| +tt +[ +acg +] +accct +" +) +regex +! +( +" +agggta +[ +cgt +] +a +| +t +[ +acg +] +taccct +" +) +regex +! +( +" +agggtaa +[ +cgt +] +| +[ +acg +] +ttaccct +" +) +] +; +let +mut +counts += +vec +! +[ +] +; +for +variant +in +variants +{ +let +seq += +seq_arc +. +clone +( +) +; +let +restr += +variant +. +to_string +( +) +; +let +future += +thread +: +: +spawn +( +move +| +| +variant +. +find_iter +( +& +seq +) +. +count +( +) +) +; +counts +. +push +( +( +restr +future +) +) +; +} +let +substs += +vec +! +[ +( +regex +! +( +" +B +" +) +" +( +c +| +g +| +t +) +" +) +( +regex +! +( +" +D +" +) +" +( +a +| +g +| +t +) +" +) +( +regex +! +( +" +H +" +) +" +( +a +| +c +| +t +) +" +) +( +regex +! +( +" +K +" +) +" +( +g +| +t +) +" +) +( +regex +! +( +" +M +" +) +" +( +a +| +c +) +" +) +( +regex +! +( +" +N +" +) +" +( +a +| +c +| +g +| +t +) +" +) +( +regex +! +( +" +R +" +) +" +( +a +| +g +) +" +) +( +regex +! +( +" +S +" +) +" +( +c +| +g +) +" +) +( +regex +! +( +" +V +" +) +" +( +a +| +c +| +g +) +" +) +( +regex +! +( +" +W +" +) +" +( +a +| +t +) +" +) +( +regex +! +( +" +Y +" +) +" +( +c +| +t +) +" +) +] +; +let +mut +seq += +seq +; +for +( +re +replacement +) +in +substs +{ +seq += +re +. +replace_all +( +& +seq +replacement +) +. +into_owned +( +) +; +} +for +( +variant +count +) +in +counts +{ +println +! +( +" +{ +} +{ +} +" +variant +count +. +join +( +) +. +unwrap +( +) +) +; +} +println +! +( +" +\ +n +{ +} +\ +n +{ +} +\ +n +{ +} +" +ilen +clen +seq +. +len +( +) +) +; +} diff --git a/third_party/rust/regex/record/README.md b/third_party/rust/regex/record/README.md deleted file mode 100644 index 2b65c5630ab72..0000000000000 --- a/third_party/rust/regex/record/README.md +++ /dev/null @@ -1,46 +0,0 @@ -This -directory -contains -various -recordings -of -results -. -These -are -committed -to -the -repository -so -that -they -can -be -compared -over -time -. -( -At -the -time -of -writing -there -is -no -tooling -for -facilitating -this -comparison -. -It -has -to -be -done -manually -. -) diff --git a/third_party/rust/regex/record/compile-test/2023-04-19_1.7.3.csv b/third_party/rust/regex/record/compile-test/2023-04-19_1.7.3.csv deleted file mode 100644 index f77c75dd76f90..0000000000000 --- a/third_party/rust/regex/record/compile-test/2023-04-19_1.7.3.csv +++ /dev/null @@ -1,107 +0,0 @@ -name -crate -revision -profile -duration -size -relative -- -size -regex__dev__std_perf_unicode -regex -9582040009 -dev -1 -. -824209152s -3434992 -3113064 -regex__dev__std -regex -9582040009 -dev -1 -. -206314935s -1362392 -1040464 -regex__dev__std_perf -regex -9582040009 -dev -1 -. -543583435s -2726384 -2404456 -regex__dev__std_unicode -regex -9582040009 -dev -1 -. -490095643s -2066904 -1744976 -regex__dev__std_unicode -- -case_unicode -- -perl -regex -9582040009 -dev -1 -. -292011694s -1812952 -1491024 -regex__release__std_perf_unicode -regex -9582040009 -release -2 -. -398133563s -1616216 -1294368 -regex__release__std -regex -9582040009 -release -1 -. -413680252s -694592 -372744 -regex__release__std_perf -regex -9582040009 -release -2 -. -341496191s -1124696 -802848 -regex__release__std_unicode -regex -9582040009 -release -1 -. -671407822s -1190208 -868360 -regex__release__std_unicode -- -case_unicode -- -perl -regex -9582040009 -release -1 -. -441712198s -932160 -610312 diff --git a/third_party/rust/regex/record/compile-test/2023-04-20_master.csv b/third_party/rust/regex/record/compile-test/2023-04-20_master.csv deleted file mode 100644 index 855c1e49e9860..0000000000000 --- a/third_party/rust/regex/record/compile-test/2023-04-20_master.csv +++ /dev/null @@ -1,107 +0,0 @@ -name -crate -revision -profile -duration -size -relative -- -size -regex__dev__std_perf_unicode -regex -f1f99af2bc -dev -1 -. -834267609s -3799536 -3477608 -regex__dev__std -regex -f1f99af2bc -dev -1 -. -263958602s -1427928 -1106000 -regex__dev__std_perf -regex -f1f99af2bc -dev -1 -. -631302845s -3234288 -2912360 -regex__dev__std_unicode -regex -f1f99af2bc -dev -1 -. -550536696s -1997272 -1675344 -regex__dev__std_unicode -- -case_unicode -- -perl -regex -f1f99af2bc -dev -1 -. -341622852s -1739224 -1417296 -regex__release__std_perf_unicode -regex -f1f99af2bc -release -2 -. -475080323s -1755480 -1433632 -regex__release__std -regex -f1f99af2bc -release -1 -. -45990031s -731456 -409608 -regex__release__std_perf -regex -f1f99af2bc -release -2 -. -421787211s -1259864 -938016 -regex__release__std_unicode -regex -f1f99af2bc -release -1 -. -693972619s -1227072 -905224 -regex__release__std_unicode -- -case_unicode -- -perl -regex -f1f99af2bc -release -1 -. -528003306s -969024 -647176 diff --git a/third_party/rust/regex/record/compile-test/2023-07-05.csv b/third_party/rust/regex/record/compile-test/2023-07-05.csv deleted file mode 100644 index 0418b9fbe9242..0000000000000 --- a/third_party/rust/regex/record/compile-test/2023-07-05.csv +++ /dev/null @@ -1,461 +0,0 @@ -name -crate -revision -profile -duration -size -relative -- -size -regex__dev__std_perf_unicode -regex -53786ce797 -dev -2 -. -414172223s -4143600 -3764328 -regex__dev__std_perf_unicode_perf -- -dfa -- -full -regex -53786ce797 -dev -2 -. -900927164s -4815368 -4436096 -regex__dev__std -regex -53786ce797 -dev -1 -. -662626059s -2062808 -1683536 -regex__dev__std_perf -regex -53786ce797 -dev -2 -. -136755026s -3574256 -3194984 -regex__dev__std_unicode -regex -53786ce797 -dev -1 -. -943953132s -2623960 -2244688 -regex__dev__std_unicode -- -case_unicode -- -perl -regex -53786ce797 -dev -1 -. -753222606s -2374104 -1994832 -regex -- -lite__dev__std_string -regex -53786ce797 -dev -498 -. -158769ms -727504 -348232 -regex -- -automata__dev__std_syntax_perf_unicode_meta_nfa_dfa_hybrid -regex -- -automata -53786ce797 -dev -2 -. -900832296s -4872712 -4493440 -regex -- -automata__dev__std_syntax_nfa -- -pikevm -regex -- -automata -53786ce797 -dev -1 -. -413429089s -1501648 -1122376 -regex -- -automata__dev__std_syntax_nfa -- -backtrack -regex -- -automata -53786ce797 -dev -1 -. -412429191s -1505744 -1126472 -regex -- -automata__dev__std_syntax_hybrid -regex -- -automata -53786ce797 -dev -1 -. -678331978s -1632720 -1253448 -regex -- -automata__dev__std_syntax_dfa -- -onepass -regex -- -automata -53786ce797 -dev -1 -. -594526299s -1526224 -1146952 -regex -- -automata__dev__std_syntax_unicode_meta_nfa_dfa_hybrid -regex -- -automata -53786ce797 -dev -2 -. -992024402s -3500504 -3121232 -regex -- -automata__dev__std_syntax_perf_unicode_meta_nfa_hybrid_dfa -- -onepass -regex -- -automata -53786ce797 -dev -2 -. -378489598s -4119024 -3739752 -regex -- -automata__dev__std_syntax_perf_meta_nfa_dfa_hybrid -regex -- -automata -53786ce797 -dev -2 -. -695475914s -4299272 -3920000 -regex -- -automata__dev__std_syntax_perf_meta_nfa_hybrid_dfa -- -onepass -regex -- -automata -53786ce797 -dev -2 -. -120929251s -3549680 -3170408 -regex -- -automata__dev__std_unicode_meta -regex -- -automata -53786ce797 -dev -1 -. -89728585s -2492888 -2113616 -regex -- -automata__dev__std_meta -regex -- -automata -53786ce797 -dev -1 -. -604628942s -1927640 -1548368 -regex__release__std_perf_unicode -regex -53786ce797 -release -3 -. -333636908s -2025816 -1650720 -regex__release__std_perf_unicode_perf -- -dfa -- -full -regex -53786ce797 -release -3 -. -805434309s -2210160 -1835064 -regex__release__std -regex -53786ce797 -release -1 -. -789749444s -932160 -557064 -regex__release__std_perf -regex -53786ce797 -release -2 -. -734249431s -1505624 -1130528 -regex__release__std_unicode -regex -53786ce797 -release -2 -. -04945845s -1431872 -1056776 -regex__release__std_unicode -- -case_unicode -- -perl -regex -53786ce797 -release -1 -. -893829903s -1173824 -798728 -regex -- -lite__release__std_string -regex -53786ce797 -release -648 -. -517079ms -473400 -98304 -regex -- -automata__release__std_syntax_perf_unicode_meta_nfa_dfa_hybrid -regex -- -automata -53786ce797 -release -3 -. -893237683s -2242928 -1867832 -regex -- -automata__release__std_syntax_nfa -- -pikevm -regex -- -automata -53786ce797 -release -1 -. -556952008s -780600 -405504 -regex -- -automata__release__std_syntax_nfa -- -backtrack -regex -- -automata -53786ce797 -release -1 -. -576471926s -768312 -393216 -regex -- -automata__release__std_syntax_hybrid -regex -- -automata -53786ce797 -release -1 -. -819539266s -813368 -438272 -regex -- -automata__release__std_syntax_dfa -- -onepass -regex -- -automata -53786ce797 -release -1 -. -672511482s -776504 -401408 -regex -- -automata__release__std_syntax_unicode_meta_nfa_dfa_hybrid -regex -- -automata -53786ce797 -release -3 -. -227157436s -1767744 -1392648 -regex -- -automata__release__std_syntax_perf_unicode_meta_nfa_hybrid_dfa -- -onepass -regex -- -automata -53786ce797 -release -3 -. -340235296s -2005336 -1630240 -regex -- -automata__release__std_syntax_perf_meta_nfa_dfa_hybrid -regex -- -automata -53786ce797 -release -3 -. -640335773s -1718640 -1343544 -regex -- -automata__release__std_syntax_perf_meta_nfa_hybrid_dfa -- -onepass -regex -- -automata -53786ce797 -release -2 -. -876306297s -1489240 -1114144 -regex -- -automata__release__std_unicode_meta -regex -- -automata -53786ce797 -release -1 -. -945654415s -1362240 -987144 -regex -- -automata__release__std_meta -regex -- -automata -53786ce797 -release -1 -. -740500411s -862528 -487432 diff --git a/third_party/rust/regex/record/compile-test/README.md b/third_party/rust/regex/record/compile-test/README.md deleted file mode 100644 index 9f51e9cc17f37..0000000000000 --- a/third_party/rust/regex/record/compile-test/README.md +++ /dev/null @@ -1,226 +0,0 @@ -This -directory -contains -the -results -of -compilation -tests -. -Specifically -the -results -are -from -testing -both -the -from -scratch -compilation -time -and -relative -binary -size -increases -of -various -features -for -both -the -regex -and -regex -- -automata -crates -. -Here -' -s -an -example -of -how -to -run -these -tests -for -just -the -regex -crate -. -You -' -ll -need -the -regex -- -cli -command -installed -which -can -be -found -in -the -regex -- -cli -directory -in -the -root -of -this -repository -. -This -must -be -run -in -the -root -of -a -checkout -of -this -repository -. -mkdir -/ -tmp -/ -regex -- -compile -- -test -regex -- -cli -compile -- -test -. -/ -/ -tmp -/ -regex -- -compile -- -test -| -tee -record -/ -compile -- -test -/ -2023 -- -04 -- -19_1 -. -7 -. -3 -. -csv -You -can -then -look -at -the -results -using -a -tool -like -[ -xsv -] -[ -xsv -] -: -xsv -table -record -/ -compile -- -test -/ -2023 -- -04 -- -19_1 -. -7 -. -3 -. -csv -Note -that -the -relative -binary -size -is -computed -by -building -a -" -baseline -" -hello -world -program -and -then -subtracting -that -from -the -size -of -a -binary -that -uses -the -regex -crate -. -[ -xsv -] -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -xsv diff --git a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/dynamic b/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/dynamic deleted file mode 100644 index 275bc8e9052f3..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/dynamic +++ /dev/null @@ -1,1747 +0,0 @@ -Running -target -/ -release -/ -dynamic -- -e87a67d7ea67f0eb -running -67 -tests -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -75 -ns -/ -iter -( -+ -/ -- -3 -) -= -5200 -MB -/ -s -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -2 -) -= -6393 -MB -/ -s -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -75 -ns -/ -iter -( -+ -/ -- -3 -) -= -346 -MB -/ -s -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -1 -) -= -426 -MB -/ -s -test -bench -: -: -easy0_1K -. -. -. -bench -: -196 -ns -/ -iter -( -+ -/ -- -8 -) -= -5224 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -255 -138 -ns -/ -iter -( -+ -/ -- -4 -820 -) -= -4109 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -71 -ns -/ -iter -( -+ -/ -- -2 -) -= -450 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -5 -392 -ns -/ -iter -( -+ -/ -- -108 -) -= -6077 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -241 -ns -/ -iter -( -+ -/ -- -37 -) -= -4248 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -334 -872 -ns -/ -iter -( -+ -/ -- -3 -433 -) -= -3131 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -65 -ns -/ -iter -( -+ -/ -- -2 -) -= -492 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -6 -139 -ns -/ -iter -( -+ -/ -- -703 -) -= -5337 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -4 -654 -ns -/ -iter -( -+ -/ -- -63 -) -= -220 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -4 -719 -487 -ns -/ -iter -( -+ -/ -- -71 -818 -) -= -222 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -199 -ns -/ -iter -( -+ -/ -- -8 -) -= -160 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -147 -389 -ns -/ -iter -( -+ -/ -- -4 -391 -) -= -222 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -4 -) -= -2550 -MB -/ -s -test -bench -: -: -match_class -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -4 -) -= -952 -MB -/ -s -test -bench -: -: -match_class_in_range -. -. -. -bench -: -32 -ns -/ -iter -( -+ -/ -- -3 -) -= -2531 -MB -/ -s -test -bench -: -: -match_class_unicode -. -. -. -bench -: -783 -ns -/ -iter -( -+ -/ -- -13 -) -= -205 -MB -/ -s -test -bench -: -: -medium_1K -. -. -. -bench -: -1 -334 -ns -/ -iter -( -+ -/ -- -154 -) -= -767 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -044 -757 -ns -/ -iter -( -+ -/ -- -72 -936 -) -= -512 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -99 -ns -/ -iter -( -+ -/ -- -18 -) -= -323 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -59 -603 -ns -/ -iter -( -+ -/ -- -13 -750 -) -= -549 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -553 -ns -/ -iter -( -+ -/ -- -150 -) -= -180 -MB -/ -s -test -bench -: -: -not_literal -. -. -. -bench -: -293 -ns -/ -iter -( -+ -/ -- -59 -) -= -174 -MB -/ -s -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -177 -ns -/ -iter -( -+ -/ -- -35 -) -= -146 -MB -/ -s -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -175 -ns -/ -iter -( -+ -/ -- -47 -) -= -148 -MB -/ -s -test -bench -: -: -one_pass_short -. -. -. -bench -: -134 -ns -/ -iter -( -+ -/ -- -34 -) -= -126 -MB -/ -s -test -bench -: -: -one_pass_short_not -. -. -. -bench -: -136 -ns -/ -iter -( -+ -/ -- -39 -) -= -125 -MB -/ -s -test -bench -: -: -replace_all -. -. -. -bench -: -153 -ns -/ -iter -( -+ -/ -- -17 -) -test -bench_dynamic_compile -: -: -compile_huge -. -. -. -bench -: -165 -209 -ns -/ -iter -( -+ -/ -- -4 -396 -) -test -bench_dynamic_compile -: -: -compile_huge_bytes -. -. -. -bench -: -18 -795 -770 -ns -/ -iter -( -+ -/ -- -2 -674 -909 -) -test -bench_dynamic_compile -: -: -compile_simple -. -. -. -bench -: -6 -883 -ns -/ -iter -( -+ -/ -- -391 -) -test -bench_dynamic_compile -: -: -compile_simple_bytes -. -. -. -bench -: -7 -281 -ns -/ -iter -( -+ -/ -- -751 -) -test -bench_dynamic_compile -: -: -compile_small -. -. -. -bench -: -9 -091 -ns -/ -iter -( -+ -/ -- -1 -125 -) -test -bench_dynamic_compile -: -: -compile_small_bytes -. -. -. -bench -: -182 -815 -ns -/ -iter -( -+ -/ -- -3 -814 -) -test -bench_dynamic_parse -: -: -parse_huge -. -. -. -bench -: -1 -233 -ns -/ -iter -( -+ -/ -- -123 -) -test -bench_dynamic_parse -: -: -parse_simple -. -. -. -bench -: -2 -015 -ns -/ -iter -( -+ -/ -- -108 -) -test -bench_dynamic_parse -: -: -parse_small -. -. -. -bench -: -2 -500 -ns -/ -iter -( -+ -/ -- -76 -) -test -bench_sherlock -: -: -before_holmes -. -. -. -bench -: -2 -741 -811 -ns -/ -iter -( -+ -/ -- -58 -389 -) -= -216 -MB -/ -s -test -bench_sherlock -: -: -everything_greedy -. -. -. -bench -: -7 -807 -696 -ns -/ -iter -( -+ -/ -- -328 -585 -) -= -76 -MB -/ -s -test -bench_sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -5 -424 -922 -ns -/ -iter -( -+ -/ -- -78 -937 -) -= -109 -MB -/ -s -test -bench_sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -266 -557 -ns -/ -iter -( -+ -/ -- -3 -832 -) -= -2231 -MB -/ -s -test -bench_sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -1 -327 -967 -ns -/ -iter -( -+ -/ -- -12 -773 -) -= -448 -MB -/ -s -test -bench_sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -690 -485 -ns -/ -iter -( -+ -/ -- -17 -393 -) -= -221 -MB -/ -s -test -bench_sherlock -: -: -name_alt1 -. -. -. -bench -: -77 -206 -ns -/ -iter -( -+ -/ -- -951 -) -= -7705 -MB -/ -s -test -bench_sherlock -: -: -name_alt2 -. -. -. -bench -: -303 -775 -ns -/ -iter -( -+ -/ -- -5 -030 -) -= -1958 -MB -/ -s -test -bench_sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -385 -153 -ns -/ -iter -( -+ -/ -- -15 -871 -) -= -429 -MB -/ -s -test -bench_sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -473 -833 -ns -/ -iter -( -+ -/ -- -9 -825 -) -= -403 -MB -/ -s -test -bench_sherlock -: -: -name_alt4 -. -. -. -bench -: -300 -912 -ns -/ -iter -( -+ -/ -- -3 -896 -) -= -1977 -MB -/ -s -test -bench_sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -421 -519 -ns -/ -iter -( -+ -/ -- -16 -246 -) -= -418 -MB -/ -s -test -bench_sherlock -: -: -name_holmes -. -. -. -bench -: -52 -027 -ns -/ -iter -( -+ -/ -- -785 -) -= -11435 -MB -/ -s -test -bench_sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -241 -204 -ns -/ -iter -( -+ -/ -- -16 -862 -) -= -479 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock -. -. -. -bench -: -34 -378 -ns -/ -iter -( -+ -/ -- -677 -) -= -17305 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -34 -463 -ns -/ -iter -( -+ -/ -- -580 -) -= -17262 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -281 -540 -ns -/ -iter -( -+ -/ -- -11 -054 -) -= -464 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -281 -293 -ns -/ -iter -( -+ -/ -- -13 -129 -) -= -464 -MB -/ -s -test -bench_sherlock -: -: -name_whitespace -. -. -. -bench -: -60 -463 -ns -/ -iter -( -+ -/ -- -815 -) -= -9839 -MB -/ -s -test -bench_sherlock -: -: -no_match_common -. -. -. -bench -: -568 -357 -ns -/ -iter -( -+ -/ -- -11 -237 -) -= -1046 -MB -/ -s -test -bench_sherlock -: -: -no_match_uncommon -. -. -. -bench -: -23 -656 -ns -/ -iter -( -+ -/ -- -340 -) -= -25149 -MB -/ -s -test -bench_sherlock -: -: -quotes -. -. -. -bench -: -977 -907 -ns -/ -iter -( -+ -/ -- -13 -926 -) -= -608 -MB -/ -s -test -bench_sherlock -: -: -the_lower -. -. -. -bench -: -794 -285 -ns -/ -iter -( -+ -/ -- -8 -513 -) -= -749 -MB -/ -s -test -bench_sherlock -: -: -the_nocase -. -. -. -bench -: -1 -837 -240 -ns -/ -iter -( -+ -/ -- -22 -738 -) -= -323 -MB -/ -s -test -bench_sherlock -: -: -the_upper -. -. -. -bench -: -54 -083 -ns -/ -iter -( -+ -/ -- -1 -153 -) -= -11000 -MB -/ -s -test -bench_sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -986 -579 -ns -/ -iter -( -+ -/ -- -9 -292 -) -= -299 -MB -/ -s -test -bench_sherlock -: -: -word_ending_n -. -. -. -bench -: -55 -205 -101 -ns -/ -iter -( -+ -/ -- -93 -542 -) -= -10 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -67 -measured diff --git a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/dynamic-no-lazy-dfa b/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/dynamic-no-lazy-dfa deleted file mode 100644 index 444cb783754e9..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/dynamic-no-lazy-dfa +++ /dev/null @@ -1,1977 +0,0 @@ -Compiling -regex -v0 -. -1 -. -48 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -) -src -/ -dfa -. -rs -: -73 -: -1 -: -94 -: -2 -warning -: -function -is -never -used -: -can_exec -# -[ -warn -( -dead_code -) -] -on -by -default -src -/ -dfa -. -rs -: -73 -pub -fn -can_exec -( -insts -: -& -Insts -) -- -> -bool -{ -src -/ -dfa -. -rs -: -74 -use -inst -: -: -EmptyLook -: -: -* -; -src -/ -dfa -. -rs -: -75 -/ -/ -If -for -some -reason -we -manage -to -allocate -a -regex -program -with -more -src -/ -dfa -. -rs -: -76 -/ -/ -than -2 -^ -32 -- -1 -instructions -then -we -can -' -t -execute -the -DFA -because -we -src -/ -dfa -. -rs -: -77 -/ -/ -use -32 -bit -pointers -. -src -/ -dfa -. -rs -: -78 -if -insts -. -len -( -) -> -: -: -std -: -: -u32 -: -: -MAX -as -usize -{ -. -. -. -src -/ -exec -. -rs -: -12 -: -11 -: -12 -: -15 -warning -: -unused -import -# -[ -warn -( -unused_imports -) -] -on -by -default -src -/ -exec -. -rs -: -12 -use -dfa -: -: -{ -self -Dfa -DfaResult -} -; -^ -~ -~ -~ -Running -target -/ -release -/ -dynamic -- -e87a67d7ea67f0eb -running -67 -tests -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -169 -ns -/ -iter -( -+ -/ -- -1 -) -= -2307 -MB -/ -s -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -0 -) -= -4588 -MB -/ -s -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -158 -ns -/ -iter -( -+ -/ -- -3 -) -= -164 -MB -/ -s -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -84 -ns -/ -iter -( -+ -/ -- -2 -) -= -309 -MB -/ -s -test -bench -: -: -easy0_1K -. -. -. -bench -: -318 -ns -/ -iter -( -+ -/ -- -2 -) -= -3220 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -257 -205 -ns -/ -iter -( -+ -/ -- -2 -448 -) -= -4076 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -82 -ns -/ -iter -( -+ -/ -- -1 -) -= -390 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -666 -ns -/ -iter -( -+ -/ -- -104 -) -= -3781 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -293 -ns -/ -iter -( -+ -/ -- -2 -) -= -3494 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -329 -774 -ns -/ -iter -( -+ -/ -- -6 -296 -) -= -3179 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -77 -ns -/ -iter -( -+ -/ -- -0 -) -= -415 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -8 -856 -ns -/ -iter -( -+ -/ -- -93 -) -= -3700 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -31 -888 -ns -/ -iter -( -+ -/ -- -83 -) -= -32 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -58 -435 -108 -ns -/ -iter -( -+ -/ -- -64 -537 -) -= -17 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -048 -ns -/ -iter -( -+ -/ -- -12 -) -= -30 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -033 -930 -ns -/ -iter -( -+ -/ -- -4 -224 -) -= -31 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -2550 -MB -/ -s -test -bench -: -: -match_class -. -. -. -bench -: -84 -ns -/ -iter -( -+ -/ -- -0 -) -= -964 -MB -/ -s -test -bench -: -: -match_class_in_range -. -. -. -bench -: -33 -ns -/ -iter -( -+ -/ -- -0 -) -= -2454 -MB -/ -s -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -218 -ns -/ -iter -( -+ -/ -- -8 -) -= -72 -MB -/ -s -test -bench -: -: -medium_1K -. -. -. -bench -: -1 -368 -ns -/ -iter -( -+ -/ -- -9 -) -= -748 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -034 -481 -ns -/ -iter -( -+ -/ -- -3 -608 -) -= -515 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -141 -ns -/ -iter -( -+ -/ -- -0 -) -= -226 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -59 -949 -ns -/ -iter -( -+ -/ -- -421 -) -= -546 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -336 -653 -ns -/ -iter -( -+ -/ -- -1 -757 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -247 -ns -/ -iter -( -+ -/ -- -5 -) -= -40 -MB -/ -s -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -264 -ns -/ -iter -( -+ -/ -- -2 -) -= -98 -MB -/ -s -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -267 -ns -/ -iter -( -+ -/ -- -1 -) -= -97 -MB -/ -s -test -bench -: -: -one_pass_short -. -. -. -bench -: -768 -ns -/ -iter -( -+ -/ -- -5 -) -= -22 -MB -/ -s -test -bench -: -: -one_pass_short_not -. -. -. -bench -: -797 -ns -/ -iter -( -+ -/ -- -20 -) -= -21 -MB -/ -s -test -bench -: -: -replace_all -. -. -. -bench -: -149 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench_dynamic_compile -: -: -compile_huge -. -. -. -bench -: -161 -349 -ns -/ -iter -( -+ -/ -- -1 -462 -) -test -bench_dynamic_compile -: -: -compile_huge_bytes -. -. -. -bench -: -18 -050 -519 -ns -/ -iter -( -+ -/ -- -105 -846 -) -test -bench_dynamic_compile -: -: -compile_simple -. -. -. -bench -: -6 -664 -ns -/ -iter -( -+ -/ -- -390 -) -test -bench_dynamic_compile -: -: -compile_simple_bytes -. -. -. -bench -: -7 -035 -ns -/ -iter -( -+ -/ -- -370 -) -test -bench_dynamic_compile -: -: -compile_small -. -. -. -bench -: -8 -914 -ns -/ -iter -( -+ -/ -- -347 -) -test -bench_dynamic_compile -: -: -compile_small_bytes -. -. -. -bench -: -186 -970 -ns -/ -iter -( -+ -/ -- -2 -134 -) -test -bench_dynamic_parse -: -: -parse_huge -. -. -. -bench -: -1 -238 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench_dynamic_parse -: -: -parse_simple -. -. -. -bench -: -2 -005 -ns -/ -iter -( -+ -/ -- -19 -) -test -bench_dynamic_parse -: -: -parse_small -. -. -. -bench -: -2 -494 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench_sherlock -: -: -before_holmes -. -. -. -bench -: -42 -005 -594 -ns -/ -iter -( -+ -/ -- -57 -752 -) -= -14 -MB -/ -s -test -bench_sherlock -: -: -everything_greedy -. -. -. -bench -: -38 -431 -063 -ns -/ -iter -( -+ -/ -- -28 -840 -) -= -15 -MB -/ -s -test -bench_sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -32 -003 -966 -ns -/ -iter -( -+ -/ -- -50 -270 -) -= -18 -MB -/ -s -test -bench_sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -1 -457 -068 -ns -/ -iter -( -+ -/ -- -3 -202 -) -= -408 -MB -/ -s -test -bench_sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -136 -035 -549 -ns -/ -iter -( -+ -/ -- -75 -381 -) -= -4 -MB -/ -s -test -bench_sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -33 -024 -291 -ns -/ -iter -( -+ -/ -- -67 -902 -) -= -18 -MB -/ -s -test -bench_sherlock -: -: -name_alt1 -. -. -. -bench -: -157 -989 -ns -/ -iter -( -+ -/ -- -917 -) -= -3765 -MB -/ -s -test -bench_sherlock -: -: -name_alt2 -. -. -. -bench -: -545 -254 -ns -/ -iter -( -+ -/ -- -1 -908 -) -= -1091 -MB -/ -s -test -bench_sherlock -: -: -name_alt3 -. -. -. -bench -: -2 -245 -964 -ns -/ -iter -( -+ -/ -- -2 -478 -) -= -264 -MB -/ -s -test -bench_sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -4 -792 -290 -ns -/ -iter -( -+ -/ -- -31 -760 -) -= -124 -MB -/ -s -test -bench_sherlock -: -: -name_alt4 -. -. -. -bench -: -584 -204 -ns -/ -iter -( -+ -/ -- -2 -084 -) -= -1018 -MB -/ -s -test -bench_sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -2 -318 -020 -ns -/ -iter -( -+ -/ -- -8 -493 -) -= -256 -MB -/ -s -test -bench_sherlock -: -: -name_holmes -. -. -. -bench -: -51 -880 -ns -/ -iter -( -+ -/ -- -299 -) -= -11467 -MB -/ -s -test -bench_sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -414 -500 -ns -/ -iter -( -+ -/ -- -2 -497 -) -= -420 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock -. -. -. -bench -: -34 -294 -ns -/ -iter -( -+ -/ -- -349 -) -= -17348 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -34 -531 -ns -/ -iter -( -+ -/ -- -199 -) -= -17228 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -692 -651 -ns -/ -iter -( -+ -/ -- -8 -846 -) -= -351 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -657 -413 -ns -/ -iter -( -+ -/ -- -5 -534 -) -= -358 -MB -/ -s -test -bench_sherlock -: -: -name_whitespace -. -. -. -bench -: -131 -372 -ns -/ -iter -( -+ -/ -- -605 -) -= -4528 -MB -/ -s -test -bench_sherlock -: -: -no_match_common -. -. -. -bench -: -567 -065 -ns -/ -iter -( -+ -/ -- -2 -763 -) -= -1049 -MB -/ -s -test -bench_sherlock -: -: -no_match_uncommon -. -. -. -bench -: -23 -782 -ns -/ -iter -( -+ -/ -- -85 -) -= -25016 -MB -/ -s -test -bench_sherlock -: -: -quotes -. -. -. -bench -: -11 -251 -366 -ns -/ -iter -( -+ -/ -- -24 -960 -) -= -52 -MB -/ -s -test -bench_sherlock -: -: -the_lower -. -. -. -bench -: -789 -781 -ns -/ -iter -( -+ -/ -- -2 -072 -) -= -753 -MB -/ -s -test -bench_sherlock -: -: -the_nocase -. -. -. -bench -: -1 -807 -509 -ns -/ -iter -( -+ -/ -- -4 -685 -) -= -329 -MB -/ -s -test -bench_sherlock -: -: -the_upper -. -. -. -bench -: -53 -542 -ns -/ -iter -( -+ -/ -- -198 -) -= -11111 -MB -/ -s -test -bench_sherlock -: -: -the_whitespace -. -. -. -bench -: -5 -410 -444 -ns -/ -iter -( -+ -/ -- -14 -766 -) -= -109 -MB -/ -s -test -bench_sherlock -: -: -word_ending_n -. -. -. -bench -: -56 -017 -874 -ns -/ -iter -( -+ -/ -- -60 -047 -) -= -10 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -67 -measured diff --git a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/native b/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/native deleted file mode 100644 index a876918693a81..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/native +++ /dev/null @@ -1,1614 +0,0 @@ -Compiling -regex_macros -v0 -. -1 -. -28 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -regex_macros -) -Running -regex_macros -/ -target -/ -release -/ -native -- -f2ffefeeda527264 -running -58 -tests -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -189 -ns -/ -iter -( -+ -/ -- -16 -) -= -2063 -MB -/ -s -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -47 -ns -/ -iter -( -+ -/ -- -1 -) -= -8297 -MB -/ -s -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -177 -ns -/ -iter -( -+ -/ -- -5 -) -= -146 -MB -/ -s -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -1 -) -= -565 -MB -/ -s -test -bench -: -: -easy0_1K -. -. -. -bench -: -26 -578 -ns -/ -iter -( -+ -/ -- -1 -140 -) -= -38 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -27 -229 -730 -ns -/ -iter -( -+ -/ -- -261 -126 -) -= -38 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -867 -ns -/ -iter -( -+ -/ -- -45 -) -= -36 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -847 -113 -ns -/ -iter -( -+ -/ -- -276 -910 -) -= -38 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -23 -525 -ns -/ -iter -( -+ -/ -- -278 -) -= -43 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -24 -075 -047 -ns -/ -iter -( -+ -/ -- -40 -396 -) -= -43 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -767 -ns -/ -iter -( -+ -/ -- -14 -) -= -41 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -752 -730 -ns -/ -iter -( -+ -/ -- -9 -284 -) -= -43 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -44 -053 -ns -/ -iter -( -+ -/ -- -513 -) -= -23 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -44 -982 -170 -ns -/ -iter -( -+ -/ -- -76 -683 -) -= -23 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -418 -ns -/ -iter -( -+ -/ -- -26 -) -= -22 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -407 -013 -ns -/ -iter -( -+ -/ -- -13 -426 -) -= -23 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -1 -202 -ns -/ -iter -( -+ -/ -- -16 -) -= -42 -MB -/ -s -test -bench -: -: -match_class -. -. -. -bench -: -2 -057 -ns -/ -iter -( -+ -/ -- -29 -) -= -39 -MB -/ -s -test -bench -: -: -match_class_in_range -. -. -. -bench -: -2 -060 -ns -/ -iter -( -+ -/ -- -34 -) -= -39 -MB -/ -s -test -bench -: -: -match_class_unicode -. -. -. -bench -: -12 -945 -ns -/ -iter -( -+ -/ -- -156 -) -= -12 -MB -/ -s -test -bench -: -: -medium_1K -. -. -. -bench -: -27 -874 -ns -/ -iter -( -+ -/ -- -315 -) -= -36 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -28 -614 -500 -ns -/ -iter -( -+ -/ -- -544 -256 -) -= -36 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -896 -ns -/ -iter -( -+ -/ -- -85 -) -= -35 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -892 -349 -ns -/ -iter -( -+ -/ -- -35 -511 -) -= -36 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -319 -270 -ns -/ -iter -( -+ -/ -- -19 -837 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -477 -ns -/ -iter -( -+ -/ -- -104 -) -= -34 -MB -/ -s -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -653 -ns -/ -iter -( -+ -/ -- -10 -) -= -39 -MB -/ -s -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -651 -ns -/ -iter -( -+ -/ -- -6 -) -= -39 -MB -/ -s -test -bench -: -: -one_pass_short -. -. -. -bench -: -1 -016 -ns -/ -iter -( -+ -/ -- -24 -) -= -16 -MB -/ -s -test -bench -: -: -one_pass_short_not -. -. -. -bench -: -1 -588 -ns -/ -iter -( -+ -/ -- -28 -) -= -10 -MB -/ -s -test -bench -: -: -replace_all -. -. -. -bench -: -1 -078 -ns -/ -iter -( -+ -/ -- -55 -) -test -bench_sherlock -: -: -before_holmes -. -. -. -bench -: -54 -264 -124 -ns -/ -iter -( -+ -/ -- -564 -692 -) -= -10 -MB -/ -s -test -bench_sherlock -: -: -everything_greedy -. -. -. -bench -: -22 -724 -158 -ns -/ -iter -( -+ -/ -- -44 -361 -) -= -26 -MB -/ -s -test -bench_sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -22 -168 -804 -ns -/ -iter -( -+ -/ -- -66 -296 -) -= -26 -MB -/ -s -test -bench_sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -24 -791 -824 -ns -/ -iter -( -+ -/ -- -37 -522 -) -= -23 -MB -/ -s -test -bench_sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -885 -999 -793 -ns -/ -iter -( -+ -/ -- -39 -704 -278 -) -test -bench_sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -25 -113 -805 -ns -/ -iter -( -+ -/ -- -672 -050 -) -= -23 -MB -/ -s -test -bench_sherlock -: -: -name_alt1 -. -. -. -bench -: -23 -382 -716 -ns -/ -iter -( -+ -/ -- -3 -696 -517 -) -= -25 -MB -/ -s -test -bench_sherlock -: -: -name_alt2 -. -. -. -bench -: -23 -585 -220 -ns -/ -iter -( -+ -/ -- -3 -724 -922 -) -= -25 -MB -/ -s -test -bench_sherlock -: -: -name_alt3 -. -. -. -bench -: -80 -283 -635 -ns -/ -iter -( -+ -/ -- -3 -165 -029 -) -= -7 -MB -/ -s -test -bench_sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -77 -357 -394 -ns -/ -iter -( -+ -/ -- -268 -133 -) -= -7 -MB -/ -s -test -bench_sherlock -: -: -name_alt4 -. -. -. -bench -: -22 -736 -520 -ns -/ -iter -( -+ -/ -- -43 -231 -) -= -26 -MB -/ -s -test -bench_sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -26 -921 -524 -ns -/ -iter -( -+ -/ -- -140 -162 -) -= -22 -MB -/ -s -test -bench_sherlock -: -: -name_holmes -. -. -. -bench -: -15 -145 -735 -ns -/ -iter -( -+ -/ -- -65 -980 -) -= -39 -MB -/ -s -test -bench_sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -16 -285 -042 -ns -/ -iter -( -+ -/ -- -71 -956 -) -= -36 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock -. -. -. -bench -: -16 -189 -653 -ns -/ -iter -( -+ -/ -- -99 -929 -) -= -36 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -14 -975 -742 -ns -/ -iter -( -+ -/ -- -118 -052 -) -= -39 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -16 -904 -928 -ns -/ -iter -( -+ -/ -- -201 -104 -) -= -35 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -16 -335 -907 -ns -/ -iter -( -+ -/ -- -118 -725 -) -= -36 -MB -/ -s -test -bench_sherlock -: -: -name_whitespace -. -. -. -bench -: -14 -837 -905 -ns -/ -iter -( -+ -/ -- -52 -201 -) -= -40 -MB -/ -s -test -bench_sherlock -: -: -no_match_common -. -. -. -bench -: -16 -036 -625 -ns -/ -iter -( -+ -/ -- -108 -268 -) -= -37 -MB -/ -s -test -bench_sherlock -: -: -no_match_uncommon -. -. -. -bench -: -15 -278 -356 -ns -/ -iter -( -+ -/ -- -81 -123 -) -= -38 -MB -/ -s -test -bench_sherlock -: -: -quotes -. -. -. -bench -: -21 -580 -801 -ns -/ -iter -( -+ -/ -- -198 -772 -) -= -27 -MB -/ -s -test -bench_sherlock -: -: -the_lower -. -. -. -bench -: -16 -059 -120 -ns -/ -iter -( -+ -/ -- -160 -640 -) -= -37 -MB -/ -s -test -bench_sherlock -: -: -the_nocase -. -. -. -bench -: -17 -376 -836 -ns -/ -iter -( -+ -/ -- -103 -371 -) -= -34 -MB -/ -s -test -bench_sherlock -: -: -the_upper -. -. -. -bench -: -15 -259 -087 -ns -/ -iter -( -+ -/ -- -93 -807 -) -= -38 -MB -/ -s -test -bench_sherlock -: -: -the_whitespace -. -. -. -bench -: -18 -835 -951 -ns -/ -iter -( -+ -/ -- -160 -674 -) -= -31 -MB -/ -s -test -bench_sherlock -: -: -word_ending_n -. -. -. -bench -: -59 -832 -390 -ns -/ -iter -( -+ -/ -- -4 -478 -911 -) -= -9 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -58 -measured diff --git a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/nfa b/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/nfa deleted file mode 100644 index b69a7bc82c241..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/nfa +++ /dev/null @@ -1,1778 +0,0 @@ -Compiling -regex -v0 -. -1 -. -48 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -) -Running -target -/ -release -/ -dynamic_nfa -- -1e40ce11bcb7c666 -running -67 -tests -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -306 -ns -/ -iter -( -+ -/ -- -6 -) -= -1274 -MB -/ -s -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -95 -ns -/ -iter -( -+ -/ -- -1 -) -= -4105 -MB -/ -s -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -315 -ns -/ -iter -( -+ -/ -- -2 -) -= -82 -MB -/ -s -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -96 -ns -/ -iter -( -+ -/ -- -2 -) -= -270 -MB -/ -s -test -bench -: -: -easy0_1K -. -. -. -bench -: -206 -ns -/ -iter -( -+ -/ -- -1 -) -= -4970 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -255 -834 -ns -/ -iter -( -+ -/ -- -1 -273 -) -= -4098 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -72 -ns -/ -iter -( -+ -/ -- -2 -) -= -444 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -5 -315 -ns -/ -iter -( -+ -/ -- -25 -) -= -6165 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -274 -ns -/ -iter -( -+ -/ -- -0 -) -= -3737 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -337 -047 -ns -/ -iter -( -+ -/ -- -1 -972 -) -= -3111 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -76 -ns -/ -iter -( -+ -/ -- -2 -) -= -421 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -6 -111 -ns -/ -iter -( -+ -/ -- -39 -) -= -5362 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -59 -596 -ns -/ -iter -( -+ -/ -- -264 -) -= -17 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -58 -947 -188 -ns -/ -iter -( -+ -/ -- -205 -874 -) -= -17 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -978 -ns -/ -iter -( -+ -/ -- -22 -) -= -16 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -846 -347 -ns -/ -iter -( -+ -/ -- -14 -253 -) -= -17 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -172 -ns -/ -iter -( -+ -/ -- -1 -) -= -296 -MB -/ -s -test -bench -: -: -match_class -. -. -. -bench -: -240 -ns -/ -iter -( -+ -/ -- -1 -) -= -337 -MB -/ -s -test -bench -: -: -match_class_in_range -. -. -. -bench -: -190 -ns -/ -iter -( -+ -/ -- -2 -) -= -426 -MB -/ -s -test -bench -: -: -match_class_unicode -. -. -. -bench -: -4 -145 -ns -/ -iter -( -+ -/ -- -24 -) -= -38 -MB -/ -s -test -bench -: -: -medium_1K -. -. -. -bench -: -1 -195 -ns -/ -iter -( -+ -/ -- -8 -) -= -856 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -028 -649 -ns -/ -iter -( -+ -/ -- -11 -235 -) -= -516 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -84 -ns -/ -iter -( -+ -/ -- -0 -) -= -380 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -56 -134 -ns -/ -iter -( -+ -/ -- -369 -) -= -583 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -536 -ns -/ -iter -( -+ -/ -- -4 -) -= -186 -MB -/ -s -test -bench -: -: -not_literal -. -. -. -bench -: -2 -428 -ns -/ -iter -( -+ -/ -- -31 -) -= -21 -MB -/ -s -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -756 -ns -/ -iter -( -+ -/ -- -2 -) -= -34 -MB -/ -s -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -756 -ns -/ -iter -( -+ -/ -- -12 -) -= -34 -MB -/ -s -test -bench -: -: -one_pass_short -. -. -. -bench -: -1 -813 -ns -/ -iter -( -+ -/ -- -5 -) -= -9 -MB -/ -s -test -bench -: -: -one_pass_short_not -. -. -. -bench -: -2 -588 -ns -/ -iter -( -+ -/ -- -8 -) -= -6 -MB -/ -s -test -bench -: -: -replace_all -. -. -. -bench -: -905 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench_dynamic_compile -: -: -compile_huge -. -. -. -bench -: -161 -517 -ns -/ -iter -( -+ -/ -- -1 -287 -) -test -bench_dynamic_compile -: -: -compile_huge_bytes -. -. -. -bench -: -18 -395 -715 -ns -/ -iter -( -+ -/ -- -98 -986 -) -test -bench_dynamic_compile -: -: -compile_simple -. -. -. -bench -: -6 -623 -ns -/ -iter -( -+ -/ -- -296 -) -test -bench_dynamic_compile -: -: -compile_simple_bytes -. -. -. -bench -: -7 -047 -ns -/ -iter -( -+ -/ -- -232 -) -test -bench_dynamic_compile -: -: -compile_small -. -. -. -bench -: -8 -948 -ns -/ -iter -( -+ -/ -- -526 -) -test -bench_dynamic_compile -: -: -compile_small_bytes -. -. -. -bench -: -186 -796 -ns -/ -iter -( -+ -/ -- -817 -) -test -bench_dynamic_parse -: -: -parse_huge -. -. -. -bench -: -1 -238 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench_dynamic_parse -: -: -parse_simple -. -. -. -bench -: -1 -977 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench_dynamic_parse -: -: -parse_small -. -. -. -bench -: -2 -502 -ns -/ -iter -( -+ -/ -- -18 -) -test -bench_sherlock -: -: -before_holmes -. -. -. -bench -: -45 -045 -123 -ns -/ -iter -( -+ -/ -- -261 -188 -) -= -13 -MB -/ -s -test -bench_sherlock -: -: -everything_greedy -. -. -. -bench -: -38 -685 -654 -ns -/ -iter -( -+ -/ -- -107 -136 -) -= -15 -MB -/ -s -test -bench_sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -36 -407 -787 -ns -/ -iter -( -+ -/ -- -160 -253 -) -= -16 -MB -/ -s -test -bench_sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -1 -417 -371 -ns -/ -iter -( -+ -/ -- -6 -533 -) -= -419 -MB -/ -s -test -bench_sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -139 -298 -695 -ns -/ -iter -( -+ -/ -- -154 -012 -) -= -4 -MB -/ -s -test -bench_sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -32 -734 -005 -ns -/ -iter -( -+ -/ -- -98 -729 -) -= -18 -MB -/ -s -test -bench_sherlock -: -: -name_alt1 -. -. -. -bench -: -153 -016 -ns -/ -iter -( -+ -/ -- -739 -) -= -3888 -MB -/ -s -test -bench_sherlock -: -: -name_alt2 -. -. -. -bench -: -534 -038 -ns -/ -iter -( -+ -/ -- -1 -909 -) -= -1114 -MB -/ -s -test -bench_sherlock -: -: -name_alt3 -. -. -. -bench -: -2 -220 -778 -ns -/ -iter -( -+ -/ -- -6 -374 -) -= -267 -MB -/ -s -test -bench_sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -4 -744 -134 -ns -/ -iter -( -+ -/ -- -11 -703 -) -= -125 -MB -/ -s -test -bench_sherlock -: -: -name_alt4 -. -. -. -bench -: -569 -971 -ns -/ -iter -( -+ -/ -- -2 -256 -) -= -1043 -MB -/ -s -test -bench_sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -2 -324 -966 -ns -/ -iter -( -+ -/ -- -3 -082 -) -= -255 -MB -/ -s -test -bench_sherlock -: -: -name_holmes -. -. -. -bench -: -268 -146 -ns -/ -iter -( -+ -/ -- -1 -238 -) -= -2218 -MB -/ -s -test -bench_sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -409 -583 -ns -/ -iter -( -+ -/ -- -2 -808 -) -= -422 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock -. -. -. -bench -: -95 -280 -ns -/ -iter -( -+ -/ -- -316 -) -= -6244 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -116 -097 -ns -/ -iter -( -+ -/ -- -461 -) -= -5124 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -691 -210 -ns -/ -iter -( -+ -/ -- -3 -712 -) -= -351 -MB -/ -s -test -bench_sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -651 -722 -ns -/ -iter -( -+ -/ -- -7 -070 -) -= -360 -MB -/ -s -test -bench_sherlock -: -: -name_whitespace -. -. -. -bench -: -130 -960 -ns -/ -iter -( -+ -/ -- -923 -) -= -4542 -MB -/ -s -test -bench_sherlock -: -: -no_match_common -. -. -. -bench -: -568 -008 -ns -/ -iter -( -+ -/ -- -1 -723 -) -= -1047 -MB -/ -s -test -bench_sherlock -: -: -no_match_uncommon -. -. -. -bench -: -23 -669 -ns -/ -iter -( -+ -/ -- -84 -) -= -25135 -MB -/ -s -test -bench_sherlock -: -: -quotes -. -. -. -bench -: -11 -055 -260 -ns -/ -iter -( -+ -/ -- -24 -883 -) -= -53 -MB -/ -s -test -bench_sherlock -: -: -the_lower -. -. -. -bench -: -2 -934 -498 -ns -/ -iter -( -+ -/ -- -4 -553 -) -= -202 -MB -/ -s -test -bench_sherlock -: -: -the_nocase -. -. -. -bench -: -4 -268 -193 -ns -/ -iter -( -+ -/ -- -8 -164 -) -= -139 -MB -/ -s -test -bench_sherlock -: -: -the_upper -. -. -. -bench -: -272 -832 -ns -/ -iter -( -+ -/ -- -1 -436 -) -= -2180 -MB -/ -s -test -bench_sherlock -: -: -the_whitespace -. -. -. -bench -: -5 -409 -934 -ns -/ -iter -( -+ -/ -- -7 -678 -) -= -109 -MB -/ -s -test -bench_sherlock -: -: -word_ending_n -. -. -. -bench -: -55 -252 -656 -ns -/ -iter -( -+ -/ -- -68 -442 -) -= -10 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -67 -measured diff --git a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/pcre b/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/pcre deleted file mode 100644 index 53b2f96868552..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/01-lazy-dfa/pcre +++ /dev/null @@ -1,1364 +0,0 @@ -Compiling -regex -v0 -. -1 -. -48 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -) -Running -target -/ -release -/ -pcre -- -781840b9a3e9c199 -running -53 -tests -test -anchored_literal_long_match -. -. -. -bench -: -90 -ns -/ -iter -( -+ -/ -- -7 -) -= -4333 -MB -/ -s -test -anchored_literal_long_non_match -. -. -. -bench -: -60 -ns -/ -iter -( -+ -/ -- -2 -) -= -6500 -MB -/ -s -test -anchored_literal_short_match -. -. -. -bench -: -87 -ns -/ -iter -( -+ -/ -- -6 -) -= -298 -MB -/ -s -test -anchored_literal_short_non_match -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -4 -) -= -448 -MB -/ -s -test -easy0_1K -. -. -. -bench -: -258 -ns -/ -iter -( -+ -/ -- -14 -) -= -3968 -MB -/ -s -test -easy0_1MB -. -. -. -bench -: -226 -139 -ns -/ -iter -( -+ -/ -- -1 -637 -) -= -4636 -MB -/ -s -test -easy0_32 -. -. -. -bench -: -60 -ns -/ -iter -( -+ -/ -- -7 -) -= -533 -MB -/ -s -test -easy0_32K -. -. -. -bench -: -7 -028 -ns -/ -iter -( -+ -/ -- -120 -) -= -4662 -MB -/ -s -test -easy1_1K -. -. -. -bench -: -794 -ns -/ -iter -( -+ -/ -- -20 -) -= -1289 -MB -/ -s -test -easy1_1MB -. -. -. -bench -: -751 -438 -ns -/ -iter -( -+ -/ -- -11 -372 -) -= -1395 -MB -/ -s -test -easy1_32 -. -. -. -bench -: -71 -ns -/ -iter -( -+ -/ -- -3 -) -= -450 -MB -/ -s -test -easy1_32K -. -. -. -bench -: -23 -042 -ns -/ -iter -( -+ -/ -- -1 -453 -) -= -1422 -MB -/ -s -test -hard_1K -. -. -. -bench -: -30 -841 -ns -/ -iter -( -+ -/ -- -1 -287 -) -= -33 -MB -/ -s -test -hard_1MB -. -. -. -bench -: -35 -239 -100 -ns -/ -iter -( -+ -/ -- -632 -179 -) -= -29 -MB -/ -s -test -hard_32 -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -11 -) -= -372 -MB -/ -s -test -hard_32K -. -. -. -bench -: -993 -011 -ns -/ -iter -( -+ -/ -- -63 -648 -) -= -32 -MB -/ -s -test -literal -. -. -. -bench -: -130 -ns -/ -iter -( -+ -/ -- -11 -) -= -392 -MB -/ -s -test -match_class -. -. -. -bench -: -183 -ns -/ -iter -( -+ -/ -- -33 -) -= -442 -MB -/ -s -test -match_class_in_range -. -. -. -bench -: -175 -ns -/ -iter -( -+ -/ -- -18 -) -= -462 -MB -/ -s -test -match_class_unicode -. -. -. -bench -: -513 -ns -/ -iter -( -+ -/ -- -8 -) -= -313 -MB -/ -s -test -medium_1K -. -. -. -bench -: -278 -ns -/ -iter -( -+ -/ -- -6 -) -= -3683 -MB -/ -s -test -medium_1MB -. -. -. -bench -: -240 -699 -ns -/ -iter -( -+ -/ -- -17 -344 -) -= -4356 -MB -/ -s -test -medium_32 -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -13 -) -= -524 -MB -/ -s -test -medium_32K -. -. -. -bench -: -7 -369 -ns -/ -iter -( -+ -/ -- -105 -) -= -4446 -MB -/ -s -test -not_literal -. -. -. -bench -: -274 -ns -/ -iter -( -+ -/ -- -17 -) -= -186 -MB -/ -s -test -one_pass_long_prefix -. -. -. -bench -: -87 -ns -/ -iter -( -+ -/ -- -19 -) -= -298 -MB -/ -s -test -one_pass_long_prefix_not -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -13 -) -= -302 -MB -/ -s -test -one_pass_short -. -. -. -bench -: -117 -ns -/ -iter -( -+ -/ -- -44 -) -= -145 -MB -/ -s -test -one_pass_short_not -. -. -. -bench -: -122 -ns -/ -iter -( -+ -/ -- -6 -) -= -139 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -14 -450 -308 -ns -/ -iter -( -+ -/ -- -617 -786 -) -= -41 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -546 -919 -ns -/ -iter -( -+ -/ -- -4 -880 -) -= -1087 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -194 -524 -ns -/ -iter -( -+ -/ -- -6 -230 -) -= -3058 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -457 -899 -ns -/ -iter -( -+ -/ -- -7 -781 -) -= -1299 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -496 -659 -ns -/ -iter -( -+ -/ -- -6 -529 -) -= -1197 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -983 -620 -ns -/ -iter -( -+ -/ -- -45 -359 -) -= -604 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -3 -500 -367 -ns -/ -iter -( -+ -/ -- -79 -807 -) -= -169 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -972 -128 -ns -/ -iter -( -+ -/ -- -22 -195 -) -= -611 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -877 -017 -ns -/ -iter -( -+ -/ -- -39 -079 -) -= -316 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -398 -258 -ns -/ -iter -( -+ -/ -- -4 -338 -) -= -1493 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -492 -292 -ns -/ -iter -( -+ -/ -- -4 -667 -) -= -1208 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -268 -891 -ns -/ -iter -( -+ -/ -- -18 -063 -) -= -2212 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -197 -067 -ns -/ -iter -( -+ -/ -- -8 -027 -) -= -3018 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -112 -501 -ns -/ -iter -( -+ -/ -- -44 -457 -) -= -534 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -332 -423 -ns -/ -iter -( -+ -/ -- -39 -227 -) -= -446 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -267 -257 -ns -/ -iter -( -+ -/ -- -964 -) -= -2226 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -595 -211 -ns -/ -iter -( -+ -/ -- -3 -739 -) -= -999 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -584 -057 -ns -/ -iter -( -+ -/ -- -6 -825 -) -= -1018 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -1 -208 -235 -ns -/ -iter -( -+ -/ -- -37 -629 -) -= -492 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -210 -851 -ns -/ -iter -( -+ -/ -- -35 -900 -) -= -491 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -1 -286 -611 -ns -/ -iter -( -+ -/ -- -35 -689 -) -= -462 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -776 -113 -ns -/ -iter -( -+ -/ -- -6 -236 -) -= -766 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -368 -468 -ns -/ -iter -( -+ -/ -- -135 -282 -) -= -434 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -12 -018 -618 -ns -/ -iter -( -+ -/ -- -266 -497 -) -= -49 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -53 -measured diff --git a/third_party/rust/regex/record/old-bench-log/02-set/dynamic b/third_party/rust/regex/record/old-bench-log/02-set/dynamic deleted file mode 100644 index 5ab09f9cc083c..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/02-set/dynamic +++ /dev/null @@ -1,1883 +0,0 @@ -Compiling -regex -v0 -. -1 -. -52 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -) -Running -target -/ -release -/ -dynamic -- -a76738dddf3bdc6b -running -71 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -74 -ns -/ -iter -( -+ -/ -- -8 -) -= -5270 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -0 -) -= -6724 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -73 -ns -/ -iter -( -+ -/ -- -0 -) -= -356 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -0 -) -= -448 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -214 -ns -/ -iter -( -+ -/ -- -2 -) -= -4785 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -247 -056 -ns -/ -iter -( -+ -/ -- -1 -777 -) -= -4244 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -64 -ns -/ -iter -( -+ -/ -- -0 -) -= -500 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -5 -281 -ns -/ -iter -( -+ -/ -- -29 -) -= -6204 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -278 -ns -/ -iter -( -+ -/ -- -5 -) -= -3683 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -320 -041 -ns -/ -iter -( -+ -/ -- -4 -243 -) -= -3276 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -65 -ns -/ -iter -( -+ -/ -- -0 -) -= -492 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -5 -885 -ns -/ -iter -( -+ -/ -- -83 -) -= -5568 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -4 -685 -ns -/ -iter -( -+ -/ -- -20 -) -= -218 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -4 -745 -020 -ns -/ -iter -( -+ -/ -- -19 -440 -) -= -220 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -197 -ns -/ -iter -( -+ -/ -- -1 -) -= -162 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -147 -409 -ns -/ -iter -( -+ -/ -- -656 -) -= -222 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -1 -) -= -2550 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -3 -) -= -941 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -32 -ns -/ -iter -( -+ -/ -- -2 -) -= -2531 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -801 -ns -/ -iter -( -+ -/ -- -36 -) -= -200 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -213 -ns -/ -iter -( -+ -/ -- -237 -) -= -844 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -1 -991 -418 -ns -/ -iter -( -+ -/ -- -239 -612 -) -= -526 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -100 -ns -/ -iter -( -+ -/ -- -8 -) -= -320 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -57 -080 -ns -/ -iter -( -+ -/ -- -709 -) -= -574 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -522 -ns -/ -iter -( -+ -/ -- -17 -) -= -191 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -290 -ns -/ -iter -( -+ -/ -- -6 -) -= -175 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -176 -ns -/ -iter -( -+ -/ -- -15 -) -= -147 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -183 -ns -/ -iter -( -+ -/ -- -28 -) -= -142 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -136 -ns -/ -iter -( -+ -/ -- -8 -) -= -125 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -135 -ns -/ -iter -( -+ -/ -- -14 -) -= -125 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -149 -ns -/ -iter -( -+ -/ -- -34 -) -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -158 -759 -ns -/ -iter -( -+ -/ -- -4 -546 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -17 -538 -290 -ns -/ -iter -( -+ -/ -- -1 -735 -383 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -5 -935 -ns -/ -iter -( -+ -/ -- -429 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -6 -682 -ns -/ -iter -( -+ -/ -- -293 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -7 -664 -ns -/ -iter -( -+ -/ -- -473 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -175 -272 -ns -/ -iter -( -+ -/ -- -4 -492 -) -test -rust_parse -: -: -parse_huge -. -. -. -bench -: -1 -199 -ns -/ -iter -( -+ -/ -- -38 -) -test -rust_parse -: -: -parse_simple -. -. -. -bench -: -1 -849 -ns -/ -iter -( -+ -/ -- -28 -) -test -rust_parse -: -: -parse_small -. -. -. -bench -: -2 -470 -ns -/ -iter -( -+ -/ -- -35 -) -test -sherlock -: -: -before_holmes -. -. -. -bench -: -2 -750 -028 -ns -/ -iter -( -+ -/ -- -21 -847 -) -= -216 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -7 -896 -337 -ns -/ -iter -( -+ -/ -- -68 -883 -) -= -75 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -5 -498 -247 -ns -/ -iter -( -+ -/ -- -65 -952 -) -= -108 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -260 -499 -ns -/ -iter -( -+ -/ -- -4 -984 -) -= -2283 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -1 -331 -443 -ns -/ -iter -( -+ -/ -- -34 -716 -) -= -446 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -60 -985 -848 -ns -/ -iter -( -+ -/ -- -592 -838 -) -= -9 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -59 -041 -695 -ns -/ -iter -( -+ -/ -- -186 -034 -) -= -10 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -4 -714 -214 -ns -/ -iter -( -+ -/ -- -35 -672 -) -= -126 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -730 -524 -ns -/ -iter -( -+ -/ -- -69 -565 -) -= -217 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -41 -866 -ns -/ -iter -( -+ -/ -- -682 -) -= -14210 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -194 -322 -ns -/ -iter -( -+ -/ -- -6 -628 -) -= -3061 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -252 -965 -ns -/ -iter -( -+ -/ -- -18 -828 -) -= -474 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -476 -169 -ns -/ -iter -( -+ -/ -- -14 -557 -) -= -403 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -298 -639 -ns -/ -iter -( -+ -/ -- -3 -905 -) -= -1992 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -426 -191 -ns -/ -iter -( -+ -/ -- -23 -584 -) -= -417 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -49 -719 -ns -/ -iter -( -+ -/ -- -811 -) -= -11965 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -191 -400 -ns -/ -iter -( -+ -/ -- -19 -175 -) -= -499 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -34 -091 -ns -/ -iter -( -+ -/ -- -877 -) -= -17451 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -33 -785 -ns -/ -iter -( -+ -/ -- -1 -207 -) -= -17609 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -235 -442 -ns -/ -iter -( -+ -/ -- -18 -023 -) -= -481 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -236 -252 -ns -/ -iter -( -+ -/ -- -26 -934 -) -= -481 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -60 -200 -ns -/ -iter -( -+ -/ -- -1 -873 -) -= -9882 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -559 -886 -ns -/ -iter -( -+ -/ -- -20 -306 -) -= -1062 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -23 -631 -ns -/ -iter -( -+ -/ -- -497 -) -= -25175 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -967 -379 -ns -/ -iter -( -+ -/ -- -12 -856 -) -= -614 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -766 -950 -ns -/ -iter -( -+ -/ -- -21 -944 -) -= -775 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -1 -706 -539 -ns -/ -iter -( -+ -/ -- -26 -003 -) -= -348 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -52 -529 -ns -/ -iter -( -+ -/ -- -1 -208 -) -= -11325 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -012 -952 -ns -/ -iter -( -+ -/ -- -26 -968 -) -= -295 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -55 -578 -841 -ns -/ -iter -( -+ -/ -- -537 -463 -) -= -10 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -19 -103 -327 -ns -/ -iter -( -+ -/ -- -102 -828 -) -= -31 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -71 -measured diff --git a/third_party/rust/regex/record/old-bench-log/03-bytes/onig b/third_party/rust/regex/record/old-bench-log/03-bytes/onig deleted file mode 100644 index 63828c49d7a48..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/03-bytes/onig +++ /dev/null @@ -1,1687 +0,0 @@ -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -benches -) -Running -benches -/ -target -/ -release -/ -onig -- -e3bc363aa56fb408 -running -61 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -70 -ns -/ -iter -( -+ -/ -- -1 -) -= -5571 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -424 -ns -/ -iter -( -+ -/ -- -4 -) -= -919 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -70 -ns -/ -iter -( -+ -/ -- -1 -) -= -371 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -0 -) -= -684 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -176 -ns -/ -iter -( -+ -/ -- -2 -) -= -5818 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -163 -547 -ns -/ -iter -( -+ -/ -- -1 -451 -) -= -6411 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -1 -) -= -1600 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -5 -056 -ns -/ -iter -( -+ -/ -- -64 -) -= -6481 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -4 -103 -ns -/ -iter -( -+ -/ -- -11 -) -= -249 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -4 -198 -406 -ns -/ -iter -( -+ -/ -- -62 -171 -) -= -249 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -139 -ns -/ -iter -( -+ -/ -- -1 -) -= -230 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -131 -083 -ns -/ -iter -( -+ -/ -- -1 -310 -) -= -249 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -163 -ns -/ -iter -( -+ -/ -- -3 -) -= -6282 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -163 -910 -ns -/ -iter -( -+ -/ -- -2 -368 -) -= -6397 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -1 -) -= -1600 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -5 -002 -ns -/ -iter -( -+ -/ -- -306 -) -= -6550 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -226 -ns -/ -iter -( -+ -/ -- -0 -) -= -225 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -337 -ns -/ -iter -( -+ -/ -- -2 -) -= -240 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -337 -ns -/ -iter -( -+ -/ -- -1 -) -= -240 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -2 -004 -ns -/ -iter -( -+ -/ -- -26 -) -= -80 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -191 -ns -/ -iter -( -+ -/ -- -2 -) -= -5361 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -164 -027 -ns -/ -iter -( -+ -/ -- -2 -494 -) -= -6392 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -1 -) -= -1454 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -4 -962 -ns -/ -iter -( -+ -/ -- -60 -) -= -6603 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -359 -ns -/ -iter -( -+ -/ -- -5 -) -= -142 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -94 -ns -/ -iter -( -+ -/ -- -3 -) -= -276 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -101 -ns -/ -iter -( -+ -/ -- -1 -) -= -257 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -332 -ns -/ -iter -( -+ -/ -- -6 -) -= -51 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -318 -ns -/ -iter -( -+ -/ -- -4 -) -= -53 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -70 -859 -542 -ns -/ -iter -( -+ -/ -- -594 -306 -) -= -8 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -5 -129 -894 -ns -/ -iter -( -+ -/ -- -33 -792 -) -= -115 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -2 -388 -047 -ns -/ -iter -( -+ -/ -- -19 -666 -) -= -249 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -28 -413 -935 -ns -/ -iter -( -+ -/ -- -800 -513 -) -= -20 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -2 -636 -327 -ns -/ -iter -( -+ -/ -- -66 -410 -) -= -225 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -26 -471 -724 -ns -/ -iter -( -+ -/ -- -872 -994 -) -= -22 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -26 -124 -489 -ns -/ -iter -( -+ -/ -- -556 -750 -) -= -22 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -11 -268 -144 -ns -/ -iter -( -+ -/ -- -338 -510 -) -= -52 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -195 -797 -ns -/ -iter -( -+ -/ -- -1 -621 -) -= -3038 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -2 -100 -763 -ns -/ -iter -( -+ -/ -- -16 -823 -) -= -283 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -2 -212 -816 -ns -/ -iter -( -+ -/ -- -17 -997 -) -= -268 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -3 -031 -567 -ns -/ -iter -( -+ -/ -- -35 -631 -) -= -196 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -39 -737 -911 -ns -/ -iter -( -+ -/ -- -166 -863 -) -= -14 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -2 -230 -681 -ns -/ -iter -( -+ -/ -- -18 -856 -) -= -266 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -8 -294 -698 -ns -/ -iter -( -+ -/ -- -36 -887 -) -= -71 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -402 -600 -ns -/ -iter -( -+ -/ -- -6 -232 -) -= -1477 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -4 -074 -155 -ns -/ -iter -( -+ -/ -- -23 -317 -) -= -146 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -270 -225 -ns -/ -iter -( -+ -/ -- -2 -815 -) -= -2201 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -196 -502 -ns -/ -iter -( -+ -/ -- -2 -168 -) -= -3027 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -4 -397 -347 -ns -/ -iter -( -+ -/ -- -28 -567 -) -= -135 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -4 -400 -574 -ns -/ -iter -( -+ -/ -- -25 -127 -) -= -135 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -274 -462 -ns -/ -iter -( -+ -/ -- -3 -180 -) -= -2167 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -596 -601 -ns -/ -iter -( -+ -/ -- -9 -285 -) -= -997 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -586 -258 -ns -/ -iter -( -+ -/ -- -7 -702 -) -= -1014 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -4 -069 -570 -ns -/ -iter -( -+ -/ -- -20 -372 -) -= -146 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -44 -936 -445 -ns -/ -iter -( -+ -/ -- -103 -467 -) -= -13 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -300 -513 -ns -/ -iter -( -+ -/ -- -12 -884 -) -= -457 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -5 -141 -237 -ns -/ -iter -( -+ -/ -- -25 -487 -) -= -115 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -821 -454 -ns -/ -iter -( -+ -/ -- -13 -420 -) -= -724 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -009 -530 -ns -/ -iter -( -+ -/ -- -14 -082 -) -= -296 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -27 -847 -316 -ns -/ -iter -( -+ -/ -- -47 -618 -) -= -21 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -21 -105 -627 -ns -/ -iter -( -+ -/ -- -33 -436 -) -= -28 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -61 -measured diff --git a/third_party/rust/regex/record/old-bench-log/03-bytes/pcre b/third_party/rust/regex/record/old-bench-log/03-bytes/pcre deleted file mode 100644 index ffa51277be6cb..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/03-bytes/pcre +++ /dev/null @@ -1,1623 +0,0 @@ -Running -benches -/ -target -/ -release -/ -pcre -- -855c18fb35cdf072 -running -60 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -12 -) -= -4431 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -1 -) -= -6724 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -1 -) -= -295 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -60 -ns -/ -iter -( -+ -/ -- -3 -) -= -433 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -266 -ns -/ -iter -( -+ -/ -- -1 -) -= -3849 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -227 -366 -ns -/ -iter -( -+ -/ -- -794 -) -= -4611 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -2 -) -= -516 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -7 -061 -ns -/ -iter -( -+ -/ -- -109 -) -= -4640 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -805 -ns -/ -iter -( -+ -/ -- -10 -) -= -1272 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -751 -948 -ns -/ -iter -( -+ -/ -- -6 -995 -) -= -1394 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -71 -ns -/ -iter -( -+ -/ -- -1 -) -= -450 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -23 -635 -ns -/ -iter -( -+ -/ -- -213 -) -= -1386 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -31 -008 -ns -/ -iter -( -+ -/ -- -299 -) -= -33 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -35 -078 -241 -ns -/ -iter -( -+ -/ -- -94 -197 -) -= -29 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -313 -ns -/ -iter -( -+ -/ -- -1 -) -= -102 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -995 -958 -ns -/ -iter -( -+ -/ -- -10 -945 -) -= -32 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -130 -ns -/ -iter -( -+ -/ -- -1 -) -= -392 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -176 -ns -/ -iter -( -+ -/ -- -2 -) -= -460 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -178 -ns -/ -iter -( -+ -/ -- -1 -) -= -455 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -511 -ns -/ -iter -( -+ -/ -- -6 -) -= -315 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -275 -ns -/ -iter -( -+ -/ -- -4 -) -= -3723 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -239 -603 -ns -/ -iter -( -+ -/ -- -1 -808 -) -= -4376 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -1 -) -= -516 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -7 -385 -ns -/ -iter -( -+ -/ -- -43 -) -= -4437 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -274 -ns -/ -iter -( -+ -/ -- -3 -) -= -186 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -87 -ns -/ -iter -( -+ -/ -- -1 -) -= -298 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -0 -) -= -295 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -115 -ns -/ -iter -( -+ -/ -- -0 -) -= -147 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -118 -ns -/ -iter -( -+ -/ -- -0 -) -= -144 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -14 -338 -348 -ns -/ -iter -( -+ -/ -- -23 -734 -) -= -41 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -547 -196 -ns -/ -iter -( -+ -/ -- -4 -100 -) -= -1087 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -6 -012 -620 -ns -/ -iter -( -+ -/ -- -51 -777 -) -= -98 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -6 -374 -577 -ns -/ -iter -( -+ -/ -- -46 -486 -) -= -93 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -28 -575 -184 -ns -/ -iter -( -+ -/ -- -65 -051 -) -= -20 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -25 -819 -606 -ns -/ -iter -( -+ -/ -- -180 -823 -) -= -23 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -3 -227 -381 -ns -/ -iter -( -+ -/ -- -11 -443 -) -= -184 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -193 -512 -ns -/ -iter -( -+ -/ -- -1 -316 -) -= -3074 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -454 -510 -ns -/ -iter -( -+ -/ -- -2 -721 -) -= -1308 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -499 -453 -ns -/ -iter -( -+ -/ -- -4 -692 -) -= -1191 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -085 -732 -ns -/ -iter -( -+ -/ -- -6 -841 -) -= -547 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -3 -194 -995 -ns -/ -iter -( -+ -/ -- -12 -655 -) -= -186 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -944 -353 -ns -/ -iter -( -+ -/ -- -12 -661 -) -= -629 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -646 -368 -ns -/ -iter -( -+ -/ -- -12 -376 -) -= -361 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -395 -019 -ns -/ -iter -( -+ -/ -- -3 -929 -) -= -1506 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -493 -327 -ns -/ -iter -( -+ -/ -- -7 -213 -) -= -1205 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -266 -400 -ns -/ -iter -( -+ -/ -- -1 -591 -) -= -2233 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -196 -357 -ns -/ -iter -( -+ -/ -- -1 -770 -) -= -3029 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -259 -747 -ns -/ -iter -( -+ -/ -- -4 -939 -) -= -472 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -128 -970 -ns -/ -iter -( -+ -/ -- -6 -730 -) -= -526 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -267 -323 -ns -/ -iter -( -+ -/ -- -1 -296 -) -= -2225 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -595 -372 -ns -/ -iter -( -+ -/ -- -5 -690 -) -= -999 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -585 -406 -ns -/ -iter -( -+ -/ -- -5 -719 -) -= -1016 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -1 -223 -528 -ns -/ -iter -( -+ -/ -- -6 -579 -) -= -486 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -6 -440 -584 -ns -/ -iter -( -+ -/ -- -20 -444 -) -= -92 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -220 -999 -ns -/ -iter -( -+ -/ -- -7 -595 -) -= -487 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -1 -263 -078 -ns -/ -iter -( -+ -/ -- -15 -321 -) -= -471 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -781 -141 -ns -/ -iter -( -+ -/ -- -15 -408 -) -= -761 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -383 -414 -ns -/ -iter -( -+ -/ -- -548 -289 -) -= -430 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -12 -709 -045 -ns -/ -iter -( -+ -/ -- -51 -420 -) -= -46 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -10 -798 -918 -ns -/ -iter -( -+ -/ -- -40 -027 -) -= -55 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -60 -measured diff --git a/third_party/rust/regex/record/old-bench-log/03-bytes/rust b/third_party/rust/regex/record/old-bench-log/03-bytes/rust deleted file mode 100644 index 8645284d850ed..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/03-bytes/rust +++ /dev/null @@ -1,2024 +0,0 @@ -Compiling -regex -- -syntax -v0 -. -2 -. -5 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -benches -) -Compiling -regex -v0 -. -1 -. -55 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -benches -) -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -benches -) -Running -benches -/ -target -/ -release -/ -rust -- -50db306d093e5666 -running -74 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -75 -ns -/ -iter -( -+ -/ -- -5 -) -= -5200 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -0 -) -= -6964 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -79 -ns -/ -iter -( -+ -/ -- -0 -) -= -329 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -1 -) -= -464 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -138 -ns -/ -iter -( -+ -/ -- -0 -) -= -7420 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -247 -159 -ns -/ -iter -( -+ -/ -- -724 -) -= -4242 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -71 -ns -/ -iter -( -+ -/ -- -0 -) -= -450 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -5 -474 -ns -/ -iter -( -+ -/ -- -34 -) -= -5986 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -273 -ns -/ -iter -( -+ -/ -- -1 -) -= -3750 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -317 -946 -ns -/ -iter -( -+ -/ -- -2 -512 -) -= -3297 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -67 -ns -/ -iter -( -+ -/ -- -0 -) -= -477 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -5 -882 -ns -/ -iter -( -+ -/ -- -32 -) -= -5570 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -4 -713 -ns -/ -iter -( -+ -/ -- -13 -) -= -217 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -4 -732 -901 -ns -/ -iter -( -+ -/ -- -6 -948 -) -= -221 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -201 -ns -/ -iter -( -+ -/ -- -0 -) -= -159 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -147 -994 -ns -/ -iter -( -+ -/ -- -900 -) -= -221 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -2684 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -0 -) -= -952 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -30 -ns -/ -iter -( -+ -/ -- -1 -) -= -2700 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -806 -ns -/ -iter -( -+ -/ -- -2 -) -= -199 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -384 -ns -/ -iter -( -+ -/ -- -10 -) -= -739 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -1 -974 -381 -ns -/ -iter -( -+ -/ -- -7 -383 -) -= -531 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -130 -ns -/ -iter -( -+ -/ -- -0 -) -= -246 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -52 -783 -ns -/ -iter -( -+ -/ -- -465 -) -= -620 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -536 -ns -/ -iter -( -+ -/ -- -13 -) -= -186 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -293 -ns -/ -iter -( -+ -/ -- -1 -) -= -174 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -179 -ns -/ -iter -( -+ -/ -- -1 -) -= -145 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -180 -ns -/ -iter -( -+ -/ -- -2 -) -= -144 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -139 -ns -/ -iter -( -+ -/ -- -1 -) -= -122 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -142 -ns -/ -iter -( -+ -/ -- -1 -) -= -119 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -171 -ns -/ -iter -( -+ -/ -- -1 -) -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -126 -158 -ns -/ -iter -( -+ -/ -- -1 -790 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -18 -088 -719 -ns -/ -iter -( -+ -/ -- -518 -980 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -6 -141 -ns -/ -iter -( -+ -/ -- -394 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -6 -669 -ns -/ -iter -( -+ -/ -- -306 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -7 -431 -ns -/ -iter -( -+ -/ -- -275 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -191 -002 -ns -/ -iter -( -+ -/ -- -1 -297 -) -test -rust_parse -: -: -parse_huge -. -. -. -bench -: -1 -204 -ns -/ -iter -( -+ -/ -- -9 -) -test -rust_parse -: -: -parse_simple -. -. -. -bench -: -1 -905 -ns -/ -iter -( -+ -/ -- -16 -) -test -rust_parse -: -: -parse_small -. -. -. -bench -: -2 -454 -ns -/ -iter -( -+ -/ -- -24 -) -test -sherlock -: -: -before_holmes -. -. -. -bench -: -2 -748 -082 -ns -/ -iter -( -+ -/ -- -11 -406 -) -= -216 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -7 -833 -414 -ns -/ -iter -( -+ -/ -- -42 -538 -) -= -75 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -5 -426 -141 -ns -/ -iter -( -+ -/ -- -31 -378 -) -= -109 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -262 -322 -ns -/ -iter -( -+ -/ -- -5 -243 -) -= -2267 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -1 -324 -677 -ns -/ -iter -( -+ -/ -- -21 -666 -) -= -449 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -3 -179 -928 -ns -/ -iter -( -+ -/ -- -40 -246 -) -= -187 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -3 -525 -004 -ns -/ -iter -( -+ -/ -- -37 -262 -) -= -168 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -60 -268 -445 -ns -/ -iter -( -+ -/ -- -1 -958 -610 -) -= -9 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -57 -743 -679 -ns -/ -iter -( -+ -/ -- -84 -675 -) -= -10 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -4 -549 -709 -ns -/ -iter -( -+ -/ -- -9 -312 -) -= -130 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -690 -794 -ns -/ -iter -( -+ -/ -- -2 -796 -) -= -221 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -42 -476 -ns -/ -iter -( -+ -/ -- -346 -) -= -14006 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -199 -058 -ns -/ -iter -( -+ -/ -- -1 -498 -) -= -2988 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -248 -439 -ns -/ -iter -( -+ -/ -- -3 -051 -) -= -476 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -463 -628 -ns -/ -iter -( -+ -/ -- -2 -799 -) -= -406 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -296 -390 -ns -/ -iter -( -+ -/ -- -798 -) -= -2007 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -415 -770 -ns -/ -iter -( -+ -/ -- -3 -400 -) -= -420 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -49 -713 -ns -/ -iter -( -+ -/ -- -317 -) -= -11967 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -181 -147 -ns -/ -iter -( -+ -/ -- -2 -842 -) -= -503 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -34 -263 -ns -/ -iter -( -+ -/ -- -136 -) -= -17363 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -34 -179 -ns -/ -iter -( -+ -/ -- -188 -) -= -17406 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -236 -384 -ns -/ -iter -( -+ -/ -- -5 -012 -) -= -481 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -232 -613 -ns -/ -iter -( -+ -/ -- -5 -009 -) -= -482 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -60 -024 -ns -/ -iter -( -+ -/ -- -187 -) -= -9911 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -558 -607 -ns -/ -iter -( -+ -/ -- -2 -595 -) -= -1065 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -24 -049 -ns -/ -iter -( -+ -/ -- -54 -) -= -24738 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -966 -792 -ns -/ -iter -( -+ -/ -- -2 -982 -) -= -615 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -84 -186 -484 -ns -/ -iter -( -+ -/ -- -66 -800 -) -= -7 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -773 -759 -ns -/ -iter -( -+ -/ -- -2 -759 -) -= -768 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -1 -705 -648 -ns -/ -iter -( -+ -/ -- -4 -604 -) -= -348 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -52 -729 -ns -/ -iter -( -+ -/ -- -209 -) -= -11282 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -981 -215 -ns -/ -iter -( -+ -/ -- -8 -080 -) -= -300 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -53 -482 -650 -ns -/ -iter -( -+ -/ -- -73 -844 -) -= -11 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -18 -961 -987 -ns -/ -iter -( -+ -/ -- -27 -794 -) -= -31 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -74 -measured diff --git a/third_party/rust/regex/record/old-bench-log/03-bytes/rust-bytes b/third_party/rust/regex/record/old-bench-log/03-bytes/rust-bytes deleted file mode 100644 index 4c9c7d616ab2f..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/03-bytes/rust-bytes +++ /dev/null @@ -1,1620 +0,0 @@ -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -benches -) -Running -benches -/ -target -/ -release -/ -rust_bytes -- -9f3b188bc741e04b -running -59 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -75 -ns -/ -iter -( -+ -/ -- -6 -) -= -5200 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -0 -) -= -7090 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -75 -ns -/ -iter -( -+ -/ -- -0 -) -= -346 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -0 -) -= -472 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -245 -ns -/ -iter -( -+ -/ -- -0 -) -= -4179 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -251 -614 -ns -/ -iter -( -+ -/ -- -1 -143 -) -= -4167 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -1 -) -= -516 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -5 -281 -ns -/ -iter -( -+ -/ -- -66 -) -= -6204 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -266 -ns -/ -iter -( -+ -/ -- -1 -) -= -3849 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -325 -060 -ns -/ -iter -( -+ -/ -- -2 -011 -) -= -3225 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -73 -ns -/ -iter -( -+ -/ -- -0 -) -= -438 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -5 -609 -ns -/ -iter -( -+ -/ -- -41 -) -= -5842 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -4 -678 -ns -/ -iter -( -+ -/ -- -38 -) -= -218 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -4 -736 -631 -ns -/ -iter -( -+ -/ -- -26 -227 -) -= -221 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -199 -ns -/ -iter -( -+ -/ -- -0 -) -= -160 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -148 -282 -ns -/ -iter -( -+ -/ -- -1 -353 -) -= -220 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -2833 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -83 -ns -/ -iter -( -+ -/ -- -0 -) -= -975 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -30 -ns -/ -iter -( -+ -/ -- -0 -) -= -2700 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -147 -ns -/ -iter -( -+ -/ -- -10 -) -= -892 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -1 -953 -230 -ns -/ -iter -( -+ -/ -- -10 -530 -) -= -536 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -99 -ns -/ -iter -( -+ -/ -- -0 -) -= -323 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -54 -705 -ns -/ -iter -( -+ -/ -- -349 -) -= -598 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -534 -ns -/ -iter -( -+ -/ -- -4 -) -= -187 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -292 -ns -/ -iter -( -+ -/ -- -3 -) -= -174 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -179 -ns -/ -iter -( -+ -/ -- -1 -) -= -145 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -180 -ns -/ -iter -( -+ -/ -- -2 -) -= -144 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -139 -ns -/ -iter -( -+ -/ -- -0 -) -= -122 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -139 -ns -/ -iter -( -+ -/ -- -0 -) -= -122 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -2 -778 -686 -ns -/ -iter -( -+ -/ -- -8 -735 -) -= -214 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -7 -884 -691 -ns -/ -iter -( -+ -/ -- -37 -268 -) -= -75 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -5 -406 -627 -ns -/ -iter -( -+ -/ -- -24 -707 -) -= -110 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -262 -175 -ns -/ -iter -( -+ -/ -- -1 -995 -) -= -2269 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -1 -299 -904 -ns -/ -iter -( -+ -/ -- -5 -090 -) -= -457 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -3 -202 -899 -ns -/ -iter -( -+ -/ -- -20 -810 -) -= -185 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -3 -367 -381 -ns -/ -iter -( -+ -/ -- -14 -143 -) -= -176 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -725 -593 -ns -/ -iter -( -+ -/ -- -10 -736 -) -= -218 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -42 -161 -ns -/ -iter -( -+ -/ -- -355 -) -= -14110 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -195 -390 -ns -/ -iter -( -+ -/ -- -1 -112 -) -= -3044 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -248 -432 -ns -/ -iter -( -+ -/ -- -3 -244 -) -= -476 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -3 -371 -906 -ns -/ -iter -( -+ -/ -- -42 -421 -) -= -176 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -296 -423 -ns -/ -iter -( -+ -/ -- -1 -812 -) -= -2007 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -753 -178 -ns -/ -iter -( -+ -/ -- -23 -269 -) -= -339 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -49 -554 -ns -/ -iter -( -+ -/ -- -261 -) -= -12005 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -347 -682 -ns -/ -iter -( -+ -/ -- -5 -678 -) -= -441 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -33 -937 -ns -/ -iter -( -+ -/ -- -208 -) -= -17530 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -33 -870 -ns -/ -iter -( -+ -/ -- -225 -) -= -17565 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -212 -233 -ns -/ -iter -( -+ -/ -- -5 -452 -) -= -490 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -190 -590 -ns -/ -iter -( -+ -/ -- -3 -248 -) -= -499 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -59 -434 -ns -/ -iter -( -+ -/ -- -253 -) -= -10009 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -565 -962 -ns -/ -iter -( -+ -/ -- -4 -601 -) -= -1051 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -23 -729 -ns -/ -iter -( -+ -/ -- -218 -) -= -25071 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -966 -904 -ns -/ -iter -( -+ -/ -- -7 -115 -) -= -615 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -121 -271 -073 -ns -/ -iter -( -+ -/ -- -242 -789 -) -= -4 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -778 -850 -ns -/ -iter -( -+ -/ -- -6 -781 -) -= -763 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -2 -876 -190 -ns -/ -iter -( -+ -/ -- -8 -611 -) -= -206 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -52 -617 -ns -/ -iter -( -+ -/ -- -315 -) -= -11306 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -982 -270 -ns -/ -iter -( -+ -/ -- -11 -079 -) -= -300 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -76 -442 -330 -ns -/ -iter -( -+ -/ -- -236 -690 -) -= -7 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -59 -measured diff --git a/third_party/rust/regex/record/old-bench-log/04/onig b/third_party/rust/regex/record/old-bench-log/04/onig deleted file mode 100644 index ae52501d1479d..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/04/onig +++ /dev/null @@ -1,1958 +0,0 @@ -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -bench -) -Running -target -/ -release -/ -bench -- -0d58c0af2e68ae0d -running -71 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -66 -ns -/ -iter -( -+ -/ -- -1 -) -= -5909 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -414 -ns -/ -iter -( -+ -/ -- -2 -) -= -942 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -66 -ns -/ -iter -( -+ -/ -- -1 -) -= -393 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -722 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -217 -ns -/ -iter -( -+ -/ -- -2 -) -= -4843 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -130 -657 -ns -/ -iter -( -+ -/ -- -365 -) -= -8025 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -84 -ns -/ -iter -( -+ -/ -- -1 -) -= -702 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -4 -092 -ns -/ -iter -( -+ -/ -- -25 -) -= -8014 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -3 -682 -ns -/ -iter -( -+ -/ -- -25 -) -= -283 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -3 -613 -381 -ns -/ -iter -( -+ -/ -- -5 -960 -) -= -290 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -237 -ns -/ -iter -( -+ -/ -- -2 -) -= -219 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -113 -040 -ns -/ -iter -( -+ -/ -- -303 -) -= -290 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -184 -299 -ns -/ -iter -( -+ -/ -- -2 -508 -) -= -5 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -198 -378 -531 -ns -/ -iter -( -+ -/ -- -150 -404 -) -= -5 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -5 -765 -ns -/ -iter -( -+ -/ -- -26 -) -= -10 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -6 -177 -362 -ns -/ -iter -( -+ -/ -- -21 -959 -) -= -5 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -219 -ns -/ -iter -( -+ -/ -- -1 -) -= -232 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -6 -978 -321 -ns -/ -iter -( -+ -/ -- -120 -792 -) -= -14 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -6 -981 -122 -ns -/ -iter -( -+ -/ -- -120 -371 -) -= -14 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -329 -ns -/ -iter -( -+ -/ -- -5 -) -= -246 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -332 -ns -/ -iter -( -+ -/ -- -1 -) -= -243 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -980 -ns -/ -iter -( -+ -/ -- -23 -) -= -81 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -232 -ns -/ -iter -( -+ -/ -- -0 -) -= -4534 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -130 -702 -ns -/ -iter -( -+ -/ -- -997 -) -= -8022 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -95 -ns -/ -iter -( -+ -/ -- -1 -) -= -631 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -4 -103 -ns -/ -iter -( -+ -/ -- -13 -) -= -7993 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -353 -ns -/ -iter -( -+ -/ -- -2 -) -= -144 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -89 -ns -/ -iter -( -+ -/ -- -1 -) -= -292 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -97 -ns -/ -iter -( -+ -/ -- -0 -) -= -268 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -329 -ns -/ -iter -( -+ -/ -- -4 -) -= -51 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -324 -ns -/ -iter -( -+ -/ -- -4 -) -= -52 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -563 -552 -ns -/ -iter -( -+ -/ -- -2 -559 -) -= -1 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -184 -200 -ns -/ -iter -( -+ -/ -- -553 -) -= -5 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -198 -336 -145 -ns -/ -iter -( -+ -/ -- -149 -796 -) -= -5 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -5 -766 -ns -/ -iter -( -+ -/ -- -16 -) -= -10 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -6 -174 -904 -ns -/ -iter -( -+ -/ -- -5 -491 -) -= -5 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -70 -476 -093 -ns -/ -iter -( -+ -/ -- -271 -168 -) -= -8 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -5 -175 -140 -ns -/ -iter -( -+ -/ -- -19 -413 -) -= -114 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -2 -379 -427 -ns -/ -iter -( -+ -/ -- -5 -816 -) -= -250 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -28 -275 -131 -ns -/ -iter -( -+ -/ -- -49 -569 -) -= -21 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -2 -648 -838 -ns -/ -iter -( -+ -/ -- -9 -247 -) -= -224 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -25 -940 -039 -ns -/ -iter -( -+ -/ -- -57 -724 -) -= -22 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -25 -680 -050 -ns -/ -iter -( -+ -/ -- -48 -209 -) -= -23 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -11 -122 -063 -ns -/ -iter -( -+ -/ -- -28 -302 -) -= -53 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -195 -903 -ns -/ -iter -( -+ -/ -- -1 -162 -) -= -3036 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -2 -100 -175 -ns -/ -iter -( -+ -/ -- -4 -251 -) -= -283 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -2 -210 -122 -ns -/ -iter -( -+ -/ -- -7 -514 -) -= -269 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -3 -025 -653 -ns -/ -iter -( -+ -/ -- -9 -375 -) -= -196 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -39 -475 -102 -ns -/ -iter -( -+ -/ -- -51 -488 -) -= -15 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -2 -225 -952 -ns -/ -iter -( -+ -/ -- -7 -340 -) -= -267 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -8 -227 -413 -ns -/ -iter -( -+ -/ -- -18 -088 -) -= -72 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -2 -300 -803 -ns -/ -iter -( -+ -/ -- -6 -325 -) -= -258 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -11 -488 -783 -ns -/ -iter -( -+ -/ -- -28 -880 -) -= -51 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -400 -760 -ns -/ -iter -( -+ -/ -- -907 -) -= -1484 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -4 -044 -850 -ns -/ -iter -( -+ -/ -- -11 -665 -) -= -147 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -269 -021 -ns -/ -iter -( -+ -/ -- -791 -) -= -2211 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -196 -161 -ns -/ -iter -( -+ -/ -- -899 -) -= -3032 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -4 -363 -621 -ns -/ -iter -( -+ -/ -- -5 -339 -) -= -136 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -4 -389 -375 -ns -/ -iter -( -+ -/ -- -11 -077 -) -= -135 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -273 -691 -ns -/ -iter -( -+ -/ -- -957 -) -= -2173 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -588 -744 -ns -/ -iter -( -+ -/ -- -1 -732 -) -= -1010 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -673 -335 -ns -/ -iter -( -+ -/ -- -1 -407 -) -= -883 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -578 -009 -ns -/ -iter -( -+ -/ -- -5 -111 -) -= -1029 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -4 -066 -005 -ns -/ -iter -( -+ -/ -- -10 -116 -) -= -146 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -43 -374 -733 -ns -/ -iter -( -+ -/ -- -48 -409 -) -= -13 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -275 -300 -ns -/ -iter -( -+ -/ -- -5 -351 -) -= -466 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -5 -100 -832 -ns -/ -iter -( -+ -/ -- -11 -024 -) -= -116 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -816 -606 -ns -/ -iter -( -+ -/ -- -3 -370 -) -= -728 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -079 -544 -ns -/ -iter -( -+ -/ -- -4 -585 -) -= -286 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -27 -699 -175 -ns -/ -iter -( -+ -/ -- -58 -998 -) -= -21 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -19 -460 -356 -ns -/ -iter -( -+ -/ -- -29 -406 -) -= -30 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -71 -measured diff --git a/third_party/rust/regex/record/old-bench-log/04/pcre1-jit b/third_party/rust/regex/record/old-bench-log/04/pcre1-jit deleted file mode 100644 index 5f3a1f0d05157..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/04/pcre1-jit +++ /dev/null @@ -1,1919 +0,0 @@ -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -bench -) -Running -target -/ -release -/ -bench -- -0d58c0af2e68ae0d -running -70 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -32 -ns -/ -iter -( -+ -/ -- -0 -) -= -12187 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -27 -ns -/ -iter -( -+ -/ -- -1 -) -= -14444 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -31 -ns -/ -iter -( -+ -/ -- -0 -) -= -838 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -27 -ns -/ -iter -( -+ -/ -- -2 -) -= -962 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -247 -ns -/ -iter -( -+ -/ -- -1 -) -= -4255 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -193 -485 -ns -/ -iter -( -+ -/ -- -906 -) -= -5419 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -1 -) -= -1072 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -6 -057 -ns -/ -iter -( -+ -/ -- -19 -) -= -5414 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -604 -ns -/ -iter -( -+ -/ -- -3 -) -= -1728 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -553 -893 -ns -/ -iter -( -+ -/ -- -1 -299 -) -= -1893 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -81 -ns -/ -iter -( -+ -/ -- -1 -) -= -641 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -17 -335 -ns -/ -iter -( -+ -/ -- -33 -) -= -1891 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -56 -956 -ns -/ -iter -( -+ -/ -- -148 -) -= -18 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -63 -576 -485 -ns -/ -iter -( -+ -/ -- -93 -278 -) -= -16 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -1 -744 -ns -/ -iter -( -+ -/ -- -10 -) -= -33 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -1 -931 -799 -ns -/ -iter -( -+ -/ -- -7 -752 -) -= -16 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -73 -ns -/ -iter -( -+ -/ -- -1 -) -= -698 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -532 -256 -ns -/ -iter -( -+ -/ -- -4 -633 -) -= -187 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -532 -131 -ns -/ -iter -( -+ -/ -- -3 -771 -) -= -187 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -120 -ns -/ -iter -( -+ -/ -- -0 -) -= -675 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -119 -ns -/ -iter -( -+ -/ -- -0 -) -= -680 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -456 -ns -/ -iter -( -+ -/ -- -2 -) -= -353 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -260 -ns -/ -iter -( -+ -/ -- -1 -) -= -4046 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -206 -175 -ns -/ -iter -( -+ -/ -- -983 -) -= -5085 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -0 -) -= -1034 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -6 -443 -ns -/ -iter -( -+ -/ -- -26 -) -= -5090 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -216 -ns -/ -iter -( -+ -/ -- -0 -) -= -236 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -31 -ns -/ -iter -( -+ -/ -- -0 -) -= -838 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -31 -ns -/ -iter -( -+ -/ -- -0 -) -= -838 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -59 -ns -/ -iter -( -+ -/ -- -0 -) -= -288 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -63 -ns -/ -iter -( -+ -/ -- -2 -) -= -269 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -96 -070 -ns -/ -iter -( -+ -/ -- -238 -) -= -10 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -60 -783 -ns -/ -iter -( -+ -/ -- -170 -) -= -17 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -60 -899 -076 -ns -/ -iter -( -+ -/ -- -483 -661 -) -= -17 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -1 -822 -ns -/ -iter -( -+ -/ -- -58 -) -= -32 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -1 -809 -770 -ns -/ -iter -( -+ -/ -- -45 -348 -) -= -18 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -14 -513 -309 -ns -/ -iter -( -+ -/ -- -146 -332 -) -= -40 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -543 -738 -ns -/ -iter -( -+ -/ -- -4 -549 -) -= -1094 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -5 -561 -653 -ns -/ -iter -( -+ -/ -- -44 -720 -) -= -106 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -6 -116 -112 -ns -/ -iter -( -+ -/ -- -91 -799 -) -= -97 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -15 -633 -185 -ns -/ -iter -( -+ -/ -- -313 -036 -) -= -38 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -15 -228 -423 -ns -/ -iter -( -+ -/ -- -290 -879 -) -= -39 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -3 -279 -472 -ns -/ -iter -( -+ -/ -- -48 -073 -) -= -181 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -192 -935 -ns -/ -iter -( -+ -/ -- -1 -405 -) -= -3083 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -452 -708 -ns -/ -iter -( -+ -/ -- -4 -728 -) -= -1314 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -477 -092 -ns -/ -iter -( -+ -/ -- -6 -192 -) -= -1246 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -959 -514 -ns -/ -iter -( -+ -/ -- -25 -214 -) -= -620 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -3 -478 -546 -ns -/ -iter -( -+ -/ -- -52 -300 -) -= -171 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -947 -187 -ns -/ -iter -( -+ -/ -- -9 -985 -) -= -628 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -852 -289 -ns -/ -iter -( -+ -/ -- -30 -616 -) -= -321 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -655 -616 -ns -/ -iter -( -+ -/ -- -9 -327 -) -= -907 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -957 -627 -ns -/ -iter -( -+ -/ -- -47 -271 -) -= -303 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -383 -813 -ns -/ -iter -( -+ -/ -- -1 -185 -) -= -1550 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -478 -335 -ns -/ -iter -( -+ -/ -- -4 -851 -) -= -1243 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -263 -611 -ns -/ -iter -( -+ -/ -- -875 -) -= -2256 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -193 -687 -ns -/ -iter -( -+ -/ -- -1 -070 -) -= -3071 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -258 -447 -ns -/ -iter -( -+ -/ -- -32 -369 -) -= -472 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -330 -069 -ns -/ -iter -( -+ -/ -- -36 -657 -) -= -447 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -264 -340 -ns -/ -iter -( -+ -/ -- -2 -723 -) -= -2250 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -589 -309 -ns -/ -iter -( -+ -/ -- -5 -038 -) -= -1009 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -683 -909 -ns -/ -iter -( -+ -/ -- -4 -987 -) -= -869 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -578 -309 -ns -/ -iter -( -+ -/ -- -2 -831 -) -= -1028 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -1 -184 -492 -ns -/ -iter -( -+ -/ -- -27 -247 -) -= -502 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -7 -208 -342 -ns -/ -iter -( -+ -/ -- -17 -978 -) -= -82 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -001 -754 -ns -/ -iter -( -+ -/ -- -6 -215 -) -= -593 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -1 -043 -260 -ns -/ -iter -( -+ -/ -- -10 -217 -) -= -570 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -753 -058 -ns -/ -iter -( -+ -/ -- -1 -640 -) -= -790 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -195 -227 -ns -/ -iter -( -+ -/ -- -9 -524 -) -= -497 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -11 -767 -448 -ns -/ -iter -( -+ -/ -- -15 -460 -) -= -50 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -7 -551 -361 -ns -/ -iter -( -+ -/ -- -25 -566 -) -= -78 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -70 -measured diff --git a/third_party/rust/regex/record/old-bench-log/04/pcre2-jit b/third_party/rust/regex/record/old-bench-log/04/pcre2-jit deleted file mode 100644 index c4dff0956d364..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/04/pcre2-jit +++ /dev/null @@ -1,1904 +0,0 @@ -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -bench -) -Running -target -/ -release -/ -bench -- -0d58c0af2e68ae0d -running -70 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -17727 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -27857 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -1238 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -1 -) -= -1857 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -235 -ns -/ -iter -( -+ -/ -- -2 -) -= -4472 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -193 -652 -ns -/ -iter -( -+ -/ -- -524 -) -= -5414 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -1372 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -6 -024 -ns -/ -iter -( -+ -/ -- -12 -) -= -5444 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -235 -ns -/ -iter -( -+ -/ -- -4 -) -= -4442 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -193 -685 -ns -/ -iter -( -+ -/ -- -617 -) -= -5413 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -45 -ns -/ -iter -( -+ -/ -- -0 -) -= -1155 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -6 -018 -ns -/ -iter -( -+ -/ -- -9 -) -= -5448 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -880 -ns -/ -iter -( -+ -/ -- -7 -) -= -559 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -1 -283 -101 -ns -/ -iter -( -+ -/ -- -4 -420 -) -= -817 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -119 -ns -/ -iter -( -+ -/ -- -2 -) -= -495 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -39 -919 -ns -/ -iter -( -+ -/ -- -95 -) -= -821 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -1 -) -= -2833 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -513 -050 -ns -/ -iter -( -+ -/ -- -2 -267 -) -= -194 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -518 -009 -ns -/ -iter -( -+ -/ -- -3 -066 -) -= -193 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -106 -ns -/ -iter -( -+ -/ -- -1 -) -= -764 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -1 -) -= -3375 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -370 -ns -/ -iter -( -+ -/ -- -2 -) -= -435 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -237 -ns -/ -iter -( -+ -/ -- -0 -) -= -4438 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -193 -478 -ns -/ -iter -( -+ -/ -- -540 -) -= -5419 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -0 -) -= -1304 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -6 -024 -ns -/ -iter -( -+ -/ -- -15 -) -= -5444 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -274 -ns -/ -iter -( -+ -/ -- -1 -) -= -186 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -1 -) -= -1368 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -1368 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -47 -ns -/ -iter -( -+ -/ -- -0 -) -= -361 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -2 -) -= -340 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -4 -959 -ns -/ -iter -( -+ -/ -- -34 -) -= -209 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -2 -145 -ns -/ -iter -( -+ -/ -- -17 -) -= -489 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -292 -683 -ns -/ -iter -( -+ -/ -- -3 -342 -) -= -811 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -124 -ns -/ -iter -( -+ -/ -- -4 -) -= -475 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -47 -263 -ns -/ -iter -( -+ -/ -- -173 -) -= -693 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -4 -706 -445 -ns -/ -iter -( -+ -/ -- -23 -483 -) -= -126 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -488 -613 -ns -/ -iter -( -+ -/ -- -2 -921 -) -= -1217 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -1 -886 -092 -ns -/ -iter -( -+ -/ -- -9 -951 -) -= -315 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -5 -091 -401 -ns -/ -iter -( -+ -/ -- -21 -315 -) -= -116 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -10 -082 -811 -ns -/ -iter -( -+ -/ -- -41 -989 -) -= -59 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -9 -640 -481 -ns -/ -iter -( -+ -/ -- -46 -499 -) -= -61 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -772 -105 -ns -/ -iter -( -+ -/ -- -8 -833 -) -= -335 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -192 -075 -ns -/ -iter -( -+ -/ -- -1 -043 -) -= -3097 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -447 -382 -ns -/ -iter -( -+ -/ -- -2 -142 -) -= -1329 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -447 -421 -ns -/ -iter -( -+ -/ -- -2 -077 -) -= -1329 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -963 -775 -ns -/ -iter -( -+ -/ -- -1 -684 -) -= -617 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -3 -152 -920 -ns -/ -iter -( -+ -/ -- -5 -757 -) -= -188 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -80 -204 -ns -/ -iter -( -+ -/ -- -379 -) -= -7417 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -665 -405 -ns -/ -iter -( -+ -/ -- -7 -134 -) -= -357 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -649 -701 -ns -/ -iter -( -+ -/ -- -1 -722 -) -= -915 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -773 -323 -ns -/ -iter -( -+ -/ -- -9 -648 -) -= -335 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -377 -003 -ns -/ -iter -( -+ -/ -- -3 -390 -) -= -1578 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -472 -947 -ns -/ -iter -( -+ -/ -- -1 -011 -) -= -1257 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -262 -237 -ns -/ -iter -( -+ -/ -- -1 -268 -) -= -2268 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -192 -306 -ns -/ -iter -( -+ -/ -- -520 -) -= -3093 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -318 -573 -ns -/ -iter -( -+ -/ -- -1 -462 -) -= -451 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -110 -629 -ns -/ -iter -( -+ -/ -- -13 -163 -) -= -535 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -262 -889 -ns -/ -iter -( -+ -/ -- -637 -) -= -2263 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -388 -869 -ns -/ -iter -( -+ -/ -- -1 -512 -) -= -1529 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -422 -058 -ns -/ -iter -( -+ -/ -- -1 -788 -) -= -1409 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -30 -594 -ns -/ -iter -( -+ -/ -- -166 -) -= -19446 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -569 -628 -ns -/ -iter -( -+ -/ -- -2 -052 -) -= -1044 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -6 -410 -128 -ns -/ -iter -( -+ -/ -- -19 -866 -) -= -92 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -648 -366 -ns -/ -iter -( -+ -/ -- -5 -142 -) -= -917 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -694 -035 -ns -/ -iter -( -+ -/ -- -4 -844 -) -= -857 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -54 -007 -ns -/ -iter -( -+ -/ -- -486 -) -= -11015 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -850 -430 -ns -/ -iter -( -+ -/ -- -9 -641 -) -= -699 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -5 -768 -961 -ns -/ -iter -( -+ -/ -- -20 -924 -) -= -103 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -5 -866 -550 -ns -/ -iter -( -+ -/ -- -34 -451 -) -= -101 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -70 -measured diff --git a/third_party/rust/regex/record/old-bench-log/04/re2 b/third_party/rust/regex/record/old-bench-log/04/re2 deleted file mode 100644 index 30892d1bc7e1b..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/04/re2 +++ /dev/null @@ -1,1972 +0,0 @@ -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -bench -) -Running -target -/ -release -/ -bench -- -0d58c0af2e68ae0d -running -72 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -119 -ns -/ -iter -( -+ -/ -- -2 -) -= -3277 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -45 -ns -/ -iter -( -+ -/ -- -0 -) -= -8666 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -120 -ns -/ -iter -( -+ -/ -- -1 -) -= -216 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -45 -ns -/ -iter -( -+ -/ -- -0 -) -= -577 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -187 -ns -/ -iter -( -+ -/ -- -0 -) -= -5620 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -39 -573 -ns -/ -iter -( -+ -/ -- -600 -) -= -26497 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -165 -ns -/ -iter -( -+ -/ -- -1 -) -= -357 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -971 -ns -/ -iter -( -+ -/ -- -20 -) -= -33774 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -175 -ns -/ -iter -( -+ -/ -- -1 -) -= -5965 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -39 -451 -ns -/ -iter -( -+ -/ -- -183 -) -= -26579 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -153 -ns -/ -iter -( -+ -/ -- -1 -) -= -339 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -942 -ns -/ -iter -( -+ -/ -- -24 -) -= -34806 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -2 -362 -ns -/ -iter -( -+ -/ -- -11 -) -= -444 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -2 -386 -627 -ns -/ -iter -( -+ -/ -- -12 -925 -) -= -439 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -228 -ns -/ -iter -( -+ -/ -- -1 -) -= -258 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -74 -482 -ns -/ -iter -( -+ -/ -- -190 -) -= -440 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -120 -ns -/ -iter -( -+ -/ -- -0 -) -= -425 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -184 -777 -ns -/ -iter -( -+ -/ -- -1 -644 -) -= -541 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -184 -685 -ns -/ -iter -( -+ -/ -- -289 -) -= -541 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -267 -ns -/ -iter -( -+ -/ -- -1 -) -= -303 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -267 -ns -/ -iter -( -+ -/ -- -1 -) -= -303 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -491 -ns -/ -iter -( -+ -/ -- -3 -) -= -327 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -2 -065 -ns -/ -iter -( -+ -/ -- -4 -) -= -509 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -1 -938 -951 -ns -/ -iter -( -+ -/ -- -11 -278 -) -= -540 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -302 -ns -/ -iter -( -+ -/ -- -149 -) -= -198 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -60 -766 -ns -/ -iter -( -+ -/ -- -1 -018 -) -= -539 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -203 -ns -/ -iter -( -+ -/ -- -2 -) -= -251 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -119 -ns -/ -iter -( -+ -/ -- -1 -) -= -218 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -161 -ns -/ -iter -( -+ -/ -- -0 -) -= -161 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -143 -ns -/ -iter -( -+ -/ -- -0 -) -= -118 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -145 -ns -/ -iter -( -+ -/ -- -1 -) -= -117 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -2 -030 -ns -/ -iter -( -+ -/ -- -22 -) -= -512 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -2 -362 -ns -/ -iter -( -+ -/ -- -18 -) -= -444 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -2 -386 -760 -ns -/ -iter -( -+ -/ -- -22 -075 -) -= -439 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -230 -ns -/ -iter -( -+ -/ -- -2 -) -= -256 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -74 -506 -ns -/ -iter -( -+ -/ -- -740 -) -= -440 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -1 -446 -270 -ns -/ -iter -( -+ -/ -- -5 -771 -) -= -411 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -9 -111 -570 -ns -/ -iter -( -+ -/ -- -54 -091 -) -= -65 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -2 -489 -649 -ns -/ -iter -( -+ -/ -- -23 -310 -) -= -238 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -1 -176 -642 -ns -/ -iter -( -+ -/ -- -2 -181 -) -= -505 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -1 -389 -000 -ns -/ -iter -( -+ -/ -- -258 -245 -) -= -428 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -3 -050 -918 -ns -/ -iter -( -+ -/ -- -16 -854 -) -= -195 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -954 -264 -ns -/ -iter -( -+ -/ -- -4 -656 -) -= -304 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -111 -162 -180 -ns -/ -iter -( -+ -/ -- -108 -719 -) -= -5 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -106 -751 -460 -ns -/ -iter -( -+ -/ -- -414 -985 -) -= -5 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -4 -705 -474 -ns -/ -iter -( -+ -/ -- -10 -913 -) -= -126 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -539 -425 -ns -/ -iter -( -+ -/ -- -5 -440 -) -= -234 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -77 -719 -ns -/ -iter -( -+ -/ -- -275 -) -= -7654 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -1 -319 -600 -ns -/ -iter -( -+ -/ -- -2 -771 -) -= -450 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -433 -629 -ns -/ -iter -( -+ -/ -- -2 -943 -) -= -414 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -748 -137 -ns -/ -iter -( -+ -/ -- -4 -343 -) -= -216 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -1 -354 -024 -ns -/ -iter -( -+ -/ -- -2 -312 -) -= -439 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -2 -018 -381 -ns -/ -iter -( -+ -/ -- -2 -442 -) -= -294 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -1 -348 -150 -ns -/ -iter -( -+ -/ -- -3 -870 -) -= -441 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -2 -114 -276 -ns -/ -iter -( -+ -/ -- -3 -365 -) -= -281 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -168 -436 -ns -/ -iter -( -+ -/ -- -1 -503 -) -= -3532 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -645 -658 -ns -/ -iter -( -+ -/ -- -3 -816 -) -= -361 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -59 -010 -ns -/ -iter -( -+ -/ -- -380 -) -= -10081 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -60 -467 -ns -/ -iter -( -+ -/ -- -179 -) -= -9838 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -539 -137 -ns -/ -iter -( -+ -/ -- -5 -506 -) -= -386 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -535 -058 -ns -/ -iter -( -+ -/ -- -3 -352 -) -= -387 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -62 -700 -ns -/ -iter -( -+ -/ -- -440 -) -= -9488 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -439 -560 -ns -/ -iter -( -+ -/ -- -1 -545 -) -= -1353 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -439 -333 -ns -/ -iter -( -+ -/ -- -1 -020 -) -= -1354 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -23 -882 -ns -/ -iter -( -+ -/ -- -134 -) -= -24911 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -1 -396 -564 -ns -/ -iter -( -+ -/ -- -2 -785 -) -= -425 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -2 -478 -251 -ns -/ -iter -( -+ -/ -- -5 -859 -) -= -240 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -3 -708 -713 -ns -/ -iter -( -+ -/ -- -6 -919 -) -= -160 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -232 -490 -ns -/ -iter -( -+ -/ -- -4 -478 -) -= -2558 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -286 -399 -ns -/ -iter -( -+ -/ -- -5 -006 -) -= -260 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -3 -295 -919 -ns -/ -iter -( -+ -/ -- -27 -810 -) -= -180 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -30 -375 -810 -ns -/ -iter -( -+ -/ -- -37 -415 -) -= -19 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -72 -measured diff --git a/third_party/rust/regex/record/old-bench-log/04/rust b/third_party/rust/regex/record/old-bench-log/04/rust deleted file mode 100644 index 5b2d2b459e47f..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/04/rust +++ /dev/null @@ -1,1995 +0,0 @@ -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -bench -) -Running -target -/ -release -/ -bench -- -0d58c0af2e68ae0d -running -74 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -1 -) -= -16250 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -18571 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -1 -) -= -1181 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -1238 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -6 -) -= -58388 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -4 -) -= -49933476 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -3470 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -9 -) -= -1821944 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -0 -) -= -20076 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -0 -) -= -19065381 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -1040 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -655760 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -66 -ns -/ -iter -( -+ -/ -- -0 -) -= -15924 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -70 -ns -/ -iter -( -+ -/ -- -1 -) -= -14980042 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -1 -) -= -951 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -1 -) -= -528951 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -3000 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -2 -359 -ns -/ -iter -( -+ -/ -- -37 -) -= -42391 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -634 -783 -ns -/ -iter -( -+ -/ -- -4 -313 -) -= -157 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -82 -ns -/ -iter -( -+ -/ -- -1 -) -= -987 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -30 -ns -/ -iter -( -+ -/ -- -15 -) -= -2700 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -317 -ns -/ -iter -( -+ -/ -- -2 -) -= -507 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -58444 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -47663818 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -3333 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1822000 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -115 -ns -/ -iter -( -+ -/ -- -0 -) -= -443 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -69 -ns -/ -iter -( -+ -/ -- -1 -) -= -376 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -68 -ns -/ -iter -( -+ -/ -- -0 -) -= -382 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -340 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -0 -) -= -326 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -1 -939 -ns -/ -iter -( -+ -/ -- -12 -) -= -536 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -964 -ns -/ -iter -( -+ -/ -- -7 -) -= -535 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -934 -967 -ns -/ -iter -( -+ -/ -- -4 -626 -) -= -541 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -130 -ns -/ -iter -( -+ -/ -- -0 -) -= -453 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -60 -581 -ns -/ -iter -( -+ -/ -- -176 -) -= -541 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -142 -ns -/ -iter -( -+ -/ -- -1 -) -test -sherlock -: -: -before_holmes -. -. -. -bench -: -1 -127 -747 -ns -/ -iter -( -+ -/ -- -2 -052 -) -= -527 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -598 -664 -ns -/ -iter -( -+ -/ -- -6 -137 -) -= -228 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -1 -202 -183 -ns -/ -iter -( -+ -/ -- -1 -965 -) -= -494 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -220 -378 -ns -/ -iter -( -+ -/ -- -1 -229 -) -= -2699 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -631 -731 -ns -/ -iter -( -+ -/ -- -2 -071 -) -= -941 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -1 -344 -980 -ns -/ -iter -( -+ -/ -- -1 -799 -) -= -442 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -286 -425 -ns -/ -iter -( -+ -/ -- -2 -965 -) -= -462 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -24 -356 -951 -ns -/ -iter -( -+ -/ -- -47 -224 -) -= -24 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -23 -816 -732 -ns -/ -iter -( -+ -/ -- -44 -203 -) -= -24 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -2 -051 -873 -ns -/ -iter -( -+ -/ -- -8 -712 -) -= -289 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -1 -102 -534 -ns -/ -iter -( -+ -/ -- -6 -071 -) -= -539 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -36 -474 -ns -/ -iter -( -+ -/ -- -308 -) -= -16311 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -185 -668 -ns -/ -iter -( -+ -/ -- -1 -023 -) -= -3204 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -152 -554 -ns -/ -iter -( -+ -/ -- -1 -991 -) -= -516 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -254 -885 -ns -/ -iter -( -+ -/ -- -5 -387 -) -= -474 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -228 -721 -ns -/ -iter -( -+ -/ -- -854 -) -= -2601 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -223 -457 -ns -/ -iter -( -+ -/ -- -2 -307 -) -= -486 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -317 -372 -ns -/ -iter -( -+ -/ -- -951 -) -= -1874 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -224 -434 -ns -/ -iter -( -+ -/ -- -3 -886 -) -= -485 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -42 -905 -ns -/ -iter -( -+ -/ -- -217 -) -= -13866 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -080 -290 -ns -/ -iter -( -+ -/ -- -5 -686 -) -= -550 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -70 -041 -ns -/ -iter -( -+ -/ -- -444 -) -= -8494 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -36 -092 -ns -/ -iter -( -+ -/ -- -189 -) -= -16483 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -156 -696 -ns -/ -iter -( -+ -/ -- -3 -922 -) -= -514 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -156 -088 -ns -/ -iter -( -+ -/ -- -2 -453 -) -= -514 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -79 -560 -ns -/ -iter -( -+ -/ -- -426 -) -= -7477 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -25 -940 -ns -/ -iter -( -+ -/ -- -119 -) -= -22934 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -364 -911 -ns -/ -iter -( -+ -/ -- -1 -302 -) -= -1630 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -25 -851 -ns -/ -iter -( -+ -/ -- -112 -) -= -23013 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -561 -575 -ns -/ -iter -( -+ -/ -- -2 -083 -) -= -1059 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -88 -961 -089 -ns -/ -iter -( -+ -/ -- -132 -661 -) -= -6 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -609 -891 -ns -/ -iter -( -+ -/ -- -1 -451 -) -= -975 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -1 -622 -541 -ns -/ -iter -( -+ -/ -- -6 -851 -) -= -366 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -48 -810 -ns -/ -iter -( -+ -/ -- -245 -) -= -12188 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -192 -755 -ns -/ -iter -( -+ -/ -- -4 -168 -) -= -498 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -991 -440 -ns -/ -iter -( -+ -/ -- -7 -313 -) -= -298 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -9 -688 -357 -ns -/ -iter -( -+ -/ -- -17 -267 -) -= -61 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -74 -measured diff --git a/third_party/rust/regex/record/old-bench-log/04/tcl b/third_party/rust/regex/record/old-bench-log/04/tcl deleted file mode 100644 index 79b5617865152..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/04/tcl +++ /dev/null @@ -1,1812 +0,0 @@ -Compiling -regex -- -benchmark -v0 -. -1 -. -0 -( -file -: -/ -/ -/ -home -/ -andrew -/ -data -/ -projects -/ -rust -/ -regex -/ -bench -) -Running -target -/ -release -/ -bench -- -0d58c0af2e68ae0d -running -65 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -925 -ns -/ -iter -( -+ -/ -- -16 -) -= -421 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -144 -ns -/ -iter -( -+ -/ -- -2 -) -= -2708 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -920 -ns -/ -iter -( -+ -/ -- -11 -) -= -28 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -144 -ns -/ -iter -( -+ -/ -- -1 -) -= -180 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -14 -228 -ns -/ -iter -( -+ -/ -- -204 -) -= -73 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -3 -728 -677 -ns -/ -iter -( -+ -/ -- -4 -564 -) -= -281 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -10 -023 -ns -/ -iter -( -+ -/ -- -156 -) -= -5 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -125 -851 -ns -/ -iter -( -+ -/ -- -287 -) -= -260 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -8 -797 -ns -/ -iter -( -+ -/ -- -90 -) -= -118 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -3 -722 -675 -ns -/ -iter -( -+ -/ -- -4 -912 -) -= -281 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -5 -189 -ns -/ -iter -( -+ -/ -- -77 -) -= -10 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -121 -106 -ns -/ -iter -( -+ -/ -- -694 -) -= -270 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -17 -111 -ns -/ -iter -( -+ -/ -- -251 -) -= -61 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -3 -743 -313 -ns -/ -iter -( -+ -/ -- -7 -634 -) -= -280 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -13 -489 -ns -/ -iter -( -+ -/ -- -220 -) -= -4 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -129 -358 -ns -/ -iter -( -+ -/ -- -257 -) -= -253 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -629 -ns -/ -iter -( -+ -/ -- -5 -) -= -81 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -21 -495 -182 -ns -/ -iter -( -+ -/ -- -41 -993 -) -= -4 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -21 -501 -034 -ns -/ -iter -( -+ -/ -- -34 -033 -) -= -4 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -732 -ns -/ -iter -( -+ -/ -- -3 -) -= -110 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -736 -ns -/ -iter -( -+ -/ -- -6 -) -= -110 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -14 -433 -ns -/ -iter -( -+ -/ -- -49 -) -= -72 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -3 -729 -861 -ns -/ -iter -( -+ -/ -- -4 -198 -) -= -281 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -10 -756 -ns -/ -iter -( -+ -/ -- -75 -) -= -5 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -126 -593 -ns -/ -iter -( -+ -/ -- -169 -) -= -259 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -2 -350 -ns -/ -iter -( -+ -/ -- -13 -) -= -21 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -9 -183 -ns -/ -iter -( -+ -/ -- -198 -) -= -2 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -8 -470 -ns -/ -iter -( -+ -/ -- -110 -) -= -3 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -956 -ns -/ -iter -( -+ -/ -- -4 -) -= -17 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -1 -042 -ns -/ -iter -( -+ -/ -- -13 -) -= -16 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -129 -563 -ns -/ -iter -( -+ -/ -- -336 -) -= -8 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -16 -656 -ns -/ -iter -( -+ -/ -- -152 -) -= -63 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -3 -744 -123 -ns -/ -iter -( -+ -/ -- -4 -556 -) -= -280 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -12 -910 -ns -/ -iter -( -+ -/ -- -112 -) -= -4 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -129 -293 -ns -/ -iter -( -+ -/ -- -301 -) -= -253 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -3 -593 -560 -ns -/ -iter -( -+ -/ -- -8 -574 -) -= -165 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -2 -906 -271 -ns -/ -iter -( -+ -/ -- -5 -153 -) -= -204 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -7 -016 -213 -ns -/ -iter -( -+ -/ -- -30 -321 -) -= -84 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -24 -592 -817 -ns -/ -iter -( -+ -/ -- -78 -720 -) -= -24 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -457 -984 -ns -/ -iter -( -+ -/ -- -3 -932 -) -= -242 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -2 -569 -156 -ns -/ -iter -( -+ -/ -- -5 -789 -) -= -231 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -3 -686 -183 -ns -/ -iter -( -+ -/ -- -13 -550 -) -= -161 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -6 -715 -311 -ns -/ -iter -( -+ -/ -- -15 -208 -) -= -88 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -9 -702 -060 -ns -/ -iter -( -+ -/ -- -32 -628 -) -= -61 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -3 -834 -029 -ns -/ -iter -( -+ -/ -- -3 -955 -) -= -155 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -4 -762 -730 -ns -/ -iter -( -+ -/ -- -751 -201 -) -= -124 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -4 -582 -303 -ns -/ -iter -( -+ -/ -- -8 -073 -) -= -129 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -5 -583 -652 -ns -/ -iter -( -+ -/ -- -14 -573 -) -= -106 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -2 -968 -764 -ns -/ -iter -( -+ -/ -- -6 -198 -) -= -200 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -3 -066 -080 -ns -/ -iter -( -+ -/ -- -8 -986 -) -= -194 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -2 -372 -708 -ns -/ -iter -( -+ -/ -- -3 -272 -) -= -250 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -2 -607 -914 -ns -/ -iter -( -+ -/ -- -3 -361 -) -= -228 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -2 -641 -260 -ns -/ -iter -( -+ -/ -- -9 -409 -) -= -225 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -2 -420 -591 -ns -/ -iter -( -+ -/ -- -11 -053 -) -= -245 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -2 -592 -553 -ns -/ -iter -( -+ -/ -- -3 -476 -) -= -229 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -2 -114 -367 -ns -/ -iter -( -+ -/ -- -1 -665 -) -= -281 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -2 -114 -835 -ns -/ -iter -( -+ -/ -- -2 -491 -) -= -281 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -2 -105 -274 -ns -/ -iter -( -+ -/ -- -1 -657 -) -= -282 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -10 -978 -890 -ns -/ -iter -( -+ -/ -- -30 -645 -) -= -54 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -69 -836 -043 -ns -/ -iter -( -+ -/ -- -117 -415 -) -= -8 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -9 -343 -518 -ns -/ -iter -( -+ -/ -- -29 -387 -) -= -63 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -9 -690 -676 -ns -/ -iter -( -+ -/ -- -42 -585 -) -= -61 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -2 -780 -398 -ns -/ -iter -( -+ -/ -- -6 -949 -) -= -213 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -11 -562 -612 -ns -/ -iter -( -+ -/ -- -78 -789 -) -= -51 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -64 -139 -234 -ns -/ -iter -( -+ -/ -- -491 -422 -) -= -9 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -65 -measured diff --git a/third_party/rust/regex/record/old-bench-log/05/onig b/third_party/rust/regex/record/old-bench-log/05/onig deleted file mode 100644 index 78a9696765b1a..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/onig +++ /dev/null @@ -1,2591 +0,0 @@ -running -94 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -158 -ns -/ -iter -( -+ -/ -- -4 -) -= -2468 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -495 -ns -/ -iter -( -+ -/ -- -7 -) -= -787 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -160 -ns -/ -iter -( -+ -/ -- -3 -) -= -162 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -4 -) -= -590 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -315 -ns -/ -iter -( -+ -/ -- -15 -) -= -3336 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -136 -864 -ns -/ -iter -( -+ -/ -- -5 -984 -) -= -7661 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -163 -ns -/ -iter -( -+ -/ -- -11 -) -= -361 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -4 -562 -ns -/ -iter -( -+ -/ -- -255 -) -= -7188 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -3 -947 -ns -/ -iter -( -+ -/ -- -199 -) -= -264 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -3 -920 -564 -ns -/ -iter -( -+ -/ -- -122 -902 -) -= -267 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -321 -ns -/ -iter -( -+ -/ -- -20 -) -= -161 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -121 -449 -ns -/ -iter -( -+ -/ -- -4 -899 -) -= -269 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -125 -960 -ns -/ -iter -( -+ -/ -- -7 -255 -) -= -8 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -134 -129 -947 -ns -/ -iter -( -+ -/ -- -4 -797 -942 -) -= -7 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -4 -044 -ns -/ -iter -( -+ -/ -- -227 -) -= -14 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -4 -183 -228 -ns -/ -iter -( -+ -/ -- -127 -808 -) -= -7 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -331 -ns -/ -iter -( -+ -/ -- -21 -) -= -154 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -5 -715 -563 -ns -/ -iter -( -+ -/ -- -250 -535 -) -= -17 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -5 -779 -968 -ns -/ -iter -( -+ -/ -- -195 -784 -) -= -17 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -431 -ns -/ -iter -( -+ -/ -- -5 -) -= -187 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -427 -ns -/ -iter -( -+ -/ -- -27 -) -= -189 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -946 -ns -/ -iter -( -+ -/ -- -88 -) -= -82 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -325 -ns -/ -iter -( -+ -/ -- -23 -) -= -3236 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -138 -022 -ns -/ -iter -( -+ -/ -- -5 -142 -) -= -7597 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -182 -ns -/ -iter -( -+ -/ -- -7 -) -= -329 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -4 -511 -ns -/ -iter -( -+ -/ -- -190 -) -= -7270 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -436 -ns -/ -iter -( -+ -/ -- -25 -) -= -116 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -168 -ns -/ -iter -( -+ -/ -- -6 -) -= -154 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -176 -ns -/ -iter -( -+ -/ -- -7 -) -= -147 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -325 -ns -/ -iter -( -+ -/ -- -16 -) -= -52 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -322 -ns -/ -iter -( -+ -/ -- -21 -) -= -52 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -289 -956 -ns -/ -iter -( -+ -/ -- -16 -350 -) -= -3 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -126 -089 -ns -/ -iter -( -+ -/ -- -5 -350 -) -= -8 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -133 -197 -312 -ns -/ -iter -( -+ -/ -- -3 -057 -491 -) -= -7 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -4 -060 -ns -/ -iter -( -+ -/ -- -11 -) -= -14 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -4 -215 -469 -ns -/ -iter -( -+ -/ -- -200 -526 -) -= -7 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -27 -622 -ns -/ -iter -( -+ -/ -- -778 -) -= -289 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -30 -503 -604 -ns -/ -iter -( -+ -/ -- -1 -120 -697 -) -= -166 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -23 -276 -552 -ns -/ -iter -( -+ -/ -- -1 -019 -308 -) -= -218 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -23 -199 -415 -ns -/ -iter -( -+ -/ -- -790 -938 -) -= -219 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -23 -138 -469 -ns -/ -iter -( -+ -/ -- -884 -700 -) -= -219 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -23 -076 -376 -ns -/ -iter -( -+ -/ -- -644 -391 -) -= -220 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -23 -115 -770 -ns -/ -iter -( -+ -/ -- -737 -666 -) -= -219 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -23 -093 -288 -ns -/ -iter -( -+ -/ -- -1 -003 -519 -) -= -220 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -23 -618 -534 -ns -/ -iter -( -+ -/ -- -773 -260 -) -= -215 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -23 -301 -581 -ns -/ -iter -( -+ -/ -- -679 -681 -) -= -218 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -23 -371 -339 -ns -/ -iter -( -+ -/ -- -714 -433 -) -= -217 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -23 -187 -513 -ns -/ -iter -( -+ -/ -- -863 -031 -) -= -219 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -23 -143 -027 -ns -/ -iter -( -+ -/ -- -890 -422 -) -= -219 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -104 -906 -982 -ns -/ -iter -( -+ -/ -- -3 -391 -942 -) -= -48 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -118 -326 -728 -ns -/ -iter -( -+ -/ -- -3 -378 -748 -) -= -42 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -109 -348 -596 -ns -/ -iter -( -+ -/ -- -3 -647 -056 -) -= -46 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -104 -574 -675 -ns -/ -iter -( -+ -/ -- -3 -236 -753 -) -= -48 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -102 -968 -132 -ns -/ -iter -( -+ -/ -- -2 -792 -754 -) -= -49 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -103 -783 -112 -ns -/ -iter -( -+ -/ -- -2 -851 -581 -) -= -48 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -103 -939 -805 -ns -/ -iter -( -+ -/ -- -3 -118 -277 -) -= -48 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -109 -722 -594 -ns -/ -iter -( -+ -/ -- -3 -739 -958 -) -= -46 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -128 -702 -724 -ns -/ -iter -( -+ -/ -- -3 -739 -103 -) -= -39 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -39 -219 -739 -ns -/ -iter -( -+ -/ -- -1 -622 -425 -) -= -15 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -37 -454 -934 -ns -/ -iter -( -+ -/ -- -1 -055 -140 -) -= -15 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -7 -341 -629 -ns -/ -iter -( -+ -/ -- -241 -072 -) -= -81 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -2 -298 -534 -ns -/ -iter -( -+ -/ -- -94 -224 -) -= -258 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -18 -533 -670 -ns -/ -iter -( -+ -/ -- -505 -855 -) -= -32 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -2 -419 -034 -ns -/ -iter -( -+ -/ -- -124 -616 -) -= -245 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -61 -910 -045 -ns -/ -iter -( -+ -/ -- -2 -122 -755 -) -= -9 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -60 -831 -022 -ns -/ -iter -( -+ -/ -- -2 -559 -720 -) -= -9 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -10 -747 -265 -ns -/ -iter -( -+ -/ -- -761 -147 -) -= -55 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -215 -376 -ns -/ -iter -( -+ -/ -- -13 -622 -) -= -2762 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -2 -282 -320 -ns -/ -iter -( -+ -/ -- -154 -104 -) -= -260 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -2 -206 -087 -ns -/ -iter -( -+ -/ -- -158 -376 -) -= -269 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -2 -771 -932 -ns -/ -iter -( -+ -/ -- -181 -216 -) -= -214 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -19 -198 -056 -ns -/ -iter -( -+ -/ -- -816 -668 -) -= -30 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -2 -254 -798 -ns -/ -iter -( -+ -/ -- -135 -379 -) -= -263 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -5 -734 -254 -ns -/ -iter -( -+ -/ -- -411 -596 -) -= -103 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -2 -276 -779 -ns -/ -iter -( -+ -/ -- -172 -557 -) -= -261 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -7 -314 -318 -ns -/ -iter -( -+ -/ -- -377 -963 -) -= -81 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -477 -888 -ns -/ -iter -( -+ -/ -- -37 -472 -) -= -1244 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -3 -487 -005 -ns -/ -iter -( -+ -/ -- -278 -896 -) -= -170 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -295 -313 -ns -/ -iter -( -+ -/ -- -16 -739 -) -= -2014 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -216 -522 -ns -/ -iter -( -+ -/ -- -15 -594 -) -= -2747 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -3 -480 -703 -ns -/ -iter -( -+ -/ -- -272 -332 -) -= -170 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -3 -511 -444 -ns -/ -iter -( -+ -/ -- -283 -013 -) -= -169 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -304 -043 -ns -/ -iter -( -+ -/ -- -19 -186 -) -= -1956 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -632 -615 -ns -/ -iter -( -+ -/ -- -44 -676 -) -= -940 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -727 -565 -ns -/ -iter -( -+ -/ -- -54 -169 -) -= -817 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -624 -061 -ns -/ -iter -( -+ -/ -- -37 -791 -) -= -953 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -3 -776 -688 -ns -/ -iter -( -+ -/ -- -186 -393 -) -= -157 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -34 -354 -179 -ns -/ -iter -( -+ -/ -- -1 -534 -267 -) -= -17 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -965 -787 -ns -/ -iter -( -+ -/ -- -137 -099 -) -= -302 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -4 -853 -843 -ns -/ -iter -( -+ -/ -- -259 -890 -) -= -122 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -949 -071 -ns -/ -iter -( -+ -/ -- -66 -016 -) -= -626 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -173 -683 -ns -/ -iter -( -+ -/ -- -142 -384 -) -= -273 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -19 -711 -057 -ns -/ -iter -( -+ -/ -- -942 -152 -) -= -30 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -21 -979 -387 -ns -/ -iter -( -+ -/ -- -1 -250 -588 -) -= -27 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -94 -measured diff --git a/third_party/rust/regex/record/old-bench-log/05/onig-vs-rust b/third_party/rust/regex/record/old-bench-log/05/onig-vs-rust deleted file mode 100644 index dbdbbef214dd6..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/onig-vs-rust +++ /dev/null @@ -1,2709 +0,0 @@ -name -onig -ns -/ -iter -rust -ns -/ -iter -diff -ns -/ -iter -diff -% -misc -: -: -anchored_literal_long_match -158 -( -2468 -MB -/ -s -) -24 -( -16250 -MB -/ -s -) -- -134 -- -84 -. -81 -% -misc -: -: -anchored_literal_long_non_match -495 -( -787 -MB -/ -s -) -27 -( -14444 -MB -/ -s -) -- -468 -- -94 -. -55 -% -misc -: -: -anchored_literal_short_match -160 -( -162 -MB -/ -s -) -22 -( -1181 -MB -/ -s -) -- -138 -- -86 -. -25 -% -misc -: -: -anchored_literal_short_non_match -44 -( -590 -MB -/ -s -) -24 -( -1083 -MB -/ -s -) -- -20 -- -45 -. -45 -% -misc -: -: -easy0_1K -315 -( -3336 -MB -/ -s -) -16 -( -65687 -MB -/ -s -) -- -299 -- -94 -. -92 -% -misc -: -: -easy0_1MB -136 -864 -( -7661 -MB -/ -s -) -20 -( -52430150 -MB -/ -s -) -- -136 -844 -- -99 -. -99 -% -misc -: -: -easy0_32 -163 -( -361 -MB -/ -s -) -16 -( -3687 -MB -/ -s -) -- -147 -- -90 -. -18 -% -misc -: -: -easy0_32K -4 -562 -( -7188 -MB -/ -s -) -16 -( -2049687 -MB -/ -s -) -- -4 -546 -- -99 -. -65 -% -misc -: -: -easy1_1K -3 -947 -( -264 -MB -/ -s -) -48 -( -21750 -MB -/ -s -) -- -3 -899 -- -98 -. -78 -% -misc -: -: -easy1_1MB -3 -920 -564 -( -267 -MB -/ -s -) -48 -( -21845750 -MB -/ -s -) -- -3 -920 -516 -- -100 -. -00 -% -misc -: -: -easy1_32 -321 -( -161 -MB -/ -s -) -46 -( -1130 -MB -/ -s -) -- -275 -- -85 -. -67 -% -misc -: -: -easy1_32K -121 -449 -( -269 -MB -/ -s -) -47 -( -697617 -MB -/ -s -) -- -121 -402 -- -99 -. -96 -% -misc -: -: -hard_1K -125 -960 -( -8 -MB -/ -s -) -58 -( -18120 -MB -/ -s -) -- -125 -902 -- -99 -. -95 -% -misc -: -: -hard_1MB -134 -129 -947 -( -7 -MB -/ -s -) -61 -( -17190213 -MB -/ -s -) -- -134 -129 -886 -- -100 -. -00 -% -misc -: -: -hard_32 -4 -044 -( -14 -MB -/ -s -) -58 -( -1017 -MB -/ -s -) -- -3 -986 -- -98 -. -57 -% -misc -: -: -hard_32K -4 -183 -228 -( -7 -MB -/ -s -) -56 -( -585625 -MB -/ -s -) -- -4 -183 -172 -- -100 -. -00 -% -misc -: -: -literal -331 -( -154 -MB -/ -s -) -16 -( -3187 -MB -/ -s -) -- -315 -- -95 -. -17 -% -misc -: -: -long_needle1 -5 -715 -563 -( -17 -MB -/ -s -) -2 -226 -( -44924 -MB -/ -s -) -- -5 -713 -337 -- -99 -. -96 -% -misc -: -: -long_needle2 -5 -779 -968 -( -17 -MB -/ -s -) -576 -997 -( -173 -MB -/ -s -) -- -5 -202 -971 -- -90 -. -02 -% -misc -: -: -match_class -431 -( -187 -MB -/ -s -) -65 -( -1246 -MB -/ -s -) -- -366 -- -84 -. -92 -% -misc -: -: -match_class_in_range -427 -( -189 -MB -/ -s -) -27 -( -3000 -MB -/ -s -) -- -400 -- -93 -. -68 -% -misc -: -: -match_class_unicode -1 -946 -( -82 -MB -/ -s -) -283 -( -568 -MB -/ -s -) -- -1 -663 -- -85 -. -46 -% -misc -: -: -medium_1K -325 -( -3236 -MB -/ -s -) -16 -( -65750 -MB -/ -s -) -- -309 -- -95 -. -08 -% -misc -: -: -medium_1MB -138 -022 -( -7597 -MB -/ -s -) -21 -( -49933523 -MB -/ -s -) -- -138 -001 -- -99 -. -98 -% -misc -: -: -medium_32 -182 -( -329 -MB -/ -s -) -17 -( -3529 -MB -/ -s -) -- -165 -- -90 -. -66 -% -misc -: -: -medium_32K -4 -511 -( -7270 -MB -/ -s -) -17 -( -1929176 -MB -/ -s -) -- -4 -494 -- -99 -. -62 -% -misc -: -: -not_literal -436 -( -116 -MB -/ -s -) -105 -( -485 -MB -/ -s -) -- -331 -- -75 -. -92 -% -misc -: -: -one_pass_long_prefix -168 -( -154 -MB -/ -s -) -68 -( -382 -MB -/ -s -) -- -100 -- -59 -. -52 -% -misc -: -: -one_pass_long_prefix_not -176 -( -147 -MB -/ -s -) -58 -( -448 -MB -/ -s -) -- -118 -- -67 -. -05 -% -misc -: -: -one_pass_short -325 -( -52 -MB -/ -s -) -45 -( -377 -MB -/ -s -) -- -280 -- -86 -. -15 -% -misc -: -: -one_pass_short_not -322 -( -52 -MB -/ -s -) -50 -( -340 -MB -/ -s -) -- -272 -- -84 -. -47 -% -misc -: -: -reallyhard2_1K -289 -956 -( -3 -MB -/ -s -) -83 -( -12530 -MB -/ -s -) -- -289 -873 -- -99 -. -97 -% -misc -: -: -reallyhard_1K -126 -089 -( -8 -MB -/ -s -) -1 -822 -( -576 -MB -/ -s -) -- -124 -267 -- -98 -. -55 -% -misc -: -: -reallyhard_1MB -133 -197 -312 -( -7 -MB -/ -s -) -1 -768 -327 -( -592 -MB -/ -s -) -- -131 -428 -985 -- -98 -. -67 -% -misc -: -: -reallyhard_32 -4 -060 -( -14 -MB -/ -s -) -121 -( -487 -MB -/ -s -) -- -3 -939 -- -97 -. -02 -% -misc -: -: -reallyhard_32K -4 -215 -469 -( -7 -MB -/ -s -) -56 -375 -( -581 -MB -/ -s -) -- -4 -159 -094 -- -98 -. -66 -% -misc -: -: -reverse_suffix_no_quadratic -27 -622 -( -289 -MB -/ -s -) -5 -803 -( -1378 -MB -/ -s -) -- -21 -819 -- -78 -. -99 -% -regexdna -: -: -find_new_lines -30 -503 -604 -( -166 -MB -/ -s -) -14 -818 -233 -( -343 -MB -/ -s -) -- -15 -685 -371 -- -51 -. -42 -% -regexdna -: -: -subst1 -23 -276 -552 -( -218 -MB -/ -s -) -896 -790 -( -5668 -MB -/ -s -) -- -22 -379 -762 -- -96 -. -15 -% -regexdna -: -: -subst10 -23 -199 -415 -( -219 -MB -/ -s -) -957 -325 -( -5310 -MB -/ -s -) -- -22 -242 -090 -- -95 -. -87 -% -regexdna -: -: -subst11 -23 -138 -469 -( -219 -MB -/ -s -) -917 -248 -( -5542 -MB -/ -s -) -- -22 -221 -221 -- -96 -. -04 -% -regexdna -: -: -subst2 -23 -076 -376 -( -220 -MB -/ -s -) -892 -129 -( -5698 -MB -/ -s -) -- -22 -184 -247 -- -96 -. -13 -% -regexdna -: -: -subst3 -23 -115 -770 -( -219 -MB -/ -s -) -929 -250 -( -5470 -MB -/ -s -) -- -22 -186 -520 -- -95 -. -98 -% -regexdna -: -: -subst4 -23 -093 -288 -( -220 -MB -/ -s -) -872 -581 -( -5825 -MB -/ -s -) -- -22 -220 -707 -- -96 -. -22 -% -regexdna -: -: -subst5 -23 -618 -534 -( -215 -MB -/ -s -) -875 -804 -( -5804 -MB -/ -s -) -- -22 -742 -730 -- -96 -. -29 -% -regexdna -: -: -subst6 -23 -301 -581 -( -218 -MB -/ -s -) -884 -639 -( -5746 -MB -/ -s -) -- -22 -416 -942 -- -96 -. -20 -% -regexdna -: -: -subst7 -23 -371 -339 -( -217 -MB -/ -s -) -872 -791 -( -5824 -MB -/ -s -) -- -22 -498 -548 -- -96 -. -27 -% -regexdna -: -: -subst8 -23 -187 -513 -( -219 -MB -/ -s -) -873 -833 -( -5817 -MB -/ -s -) -- -22 -313 -680 -- -96 -. -23 -% -regexdna -: -: -subst9 -23 -143 -027 -( -219 -MB -/ -s -) -886 -744 -( -5732 -MB -/ -s -) -- -22 -256 -283 -- -96 -. -17 -% -regexdna -: -: -variant1 -104 -906 -982 -( -48 -MB -/ -s -) -3 -699 -267 -( -1374 -MB -/ -s -) -- -101 -207 -715 -- -96 -. -47 -% -regexdna -: -: -variant2 -118 -326 -728 -( -42 -MB -/ -s -) -6 -760 -952 -( -751 -MB -/ -s -) -- -111 -565 -776 -- -94 -. -29 -% -regexdna -: -: -variant3 -109 -348 -596 -( -46 -MB -/ -s -) -8 -030 -646 -( -633 -MB -/ -s -) -- -101 -317 -950 -- -92 -. -66 -% -regexdna -: -: -variant4 -104 -574 -675 -( -48 -MB -/ -s -) -8 -077 -290 -( -629 -MB -/ -s -) -- -96 -497 -385 -- -92 -. -28 -% -regexdna -: -: -variant5 -102 -968 -132 -( -49 -MB -/ -s -) -6 -787 -242 -( -748 -MB -/ -s -) -- -96 -180 -890 -- -93 -. -41 -% -regexdna -: -: -variant6 -103 -783 -112 -( -48 -MB -/ -s -) -6 -577 -777 -( -772 -MB -/ -s -) -- -97 -205 -335 -- -93 -. -66 -% -regexdna -: -: -variant7 -103 -939 -805 -( -48 -MB -/ -s -) -6 -705 -580 -( -758 -MB -/ -s -) -- -97 -234 -225 -- -93 -. -55 -% -regexdna -: -: -variant8 -109 -722 -594 -( -46 -MB -/ -s -) -6 -818 -785 -( -745 -MB -/ -s -) -- -102 -903 -809 -- -93 -. -79 -% -regexdna -: -: -variant9 -128 -702 -724 -( -39 -MB -/ -s -) -6 -821 -453 -( -745 -MB -/ -s -) -- -121 -881 -271 -- -94 -. -70 -% -sherlock -: -: -before_after_holmes -39 -219 -739 -( -15 -MB -/ -s -) -1 -029 -866 -( -577 -MB -/ -s -) -- -38 -189 -873 -- -97 -. -37 -% -sherlock -: -: -before_holmes -37 -454 -934 -( -15 -MB -/ -s -) -76 -633 -( -7763 -MB -/ -s -) -- -37 -378 -301 -- -99 -. -80 -% -sherlock -: -: -everything_greedy -7 -341 -629 -( -81 -MB -/ -s -) -2 -375 -079 -( -250 -MB -/ -s -) -- -4 -966 -550 -- -67 -. -65 -% -sherlock -: -: -holmes_cochar_watson -2 -298 -534 -( -258 -MB -/ -s -) -144 -725 -( -4110 -MB -/ -s -) -- -2 -153 -809 -- -93 -. -70 -% -sherlock -: -: -ing_suffix -18 -533 -670 -( -32 -MB -/ -s -) -436 -202 -( -1363 -MB -/ -s -) -- -18 -097 -468 -- -97 -. -65 -% -sherlock -: -: -ing_suffix_limited_space -2 -419 -034 -( -245 -MB -/ -s -) -1 -182 -943 -( -502 -MB -/ -s -) -- -1 -236 -091 -- -51 -. -10 -% -sherlock -: -: -letters -61 -910 -045 -( -9 -MB -/ -s -) -24 -390 -452 -( -24 -MB -/ -s -) -- -37 -519 -593 -- -60 -. -60 -% -sherlock -: -: -letters_lower -60 -831 -022 -( -9 -MB -/ -s -) -23 -784 -108 -( -25 -MB -/ -s -) -- -37 -046 -914 -- -60 -. -90 -% -sherlock -: -: -letters_upper -10 -747 -265 -( -55 -MB -/ -s -) -1 -993 -838 -( -298 -MB -/ -s -) -- -8 -753 -427 -- -81 -. -45 -% -sherlock -: -: -line_boundary_sherlock_holmes -215 -376 -( -2762 -MB -/ -s -) -999 -414 -( -595 -MB -/ -s -) -784 -038 -364 -. -03 -% -sherlock -: -: -name_alt1 -2 -282 -320 -( -260 -MB -/ -s -) -34 -298 -( -17345 -MB -/ -s -) -- -2 -248 -022 -- -98 -. -50 -% -sherlock -: -: -name_alt2 -2 -206 -087 -( -269 -MB -/ -s -) -124 -226 -( -4789 -MB -/ -s -) -- -2 -081 -861 -- -94 -. -37 -% -sherlock -: -: -name_alt3 -2 -771 -932 -( -214 -MB -/ -s -) -137 -742 -( -4319 -MB -/ -s -) -- -2 -634 -190 -- -95 -. -03 -% -sherlock -: -: -name_alt3_nocase -19 -198 -056 -( -30 -MB -/ -s -) -1 -293 -763 -( -459 -MB -/ -s -) -- -17 -904 -293 -- -93 -. -26 -% -sherlock -: -: -name_alt4 -2 -254 -798 -( -263 -MB -/ -s -) -164 -900 -( -3607 -MB -/ -s -) -- -2 -089 -898 -- -92 -. -69 -% -sherlock -: -: -name_alt4_nocase -5 -734 -254 -( -103 -MB -/ -s -) -235 -023 -( -2531 -MB -/ -s -) -- -5 -499 -231 -- -95 -. -90 -% -sherlock -: -: -name_alt5 -2 -276 -779 -( -261 -MB -/ -s -) -127 -928 -( -4650 -MB -/ -s -) -- -2 -148 -851 -- -94 -. -38 -% -sherlock -: -: -name_alt5_nocase -7 -314 -318 -( -81 -MB -/ -s -) -659 -591 -( -901 -MB -/ -s -) -- -6 -654 -727 -- -90 -. -98 -% -sherlock -: -: -name_holmes -477 -888 -( -1244 -MB -/ -s -) -40 -902 -( -14545 -MB -/ -s -) -- -436 -986 -- -91 -. -44 -% -sherlock -: -: -name_holmes_nocase -3 -487 -005 -( -170 -MB -/ -s -) -198 -658 -( -2994 -MB -/ -s -) -- -3 -288 -347 -- -94 -. -30 -% -sherlock -: -: -name_sherlock -295 -313 -( -2014 -MB -/ -s -) -68 -924 -( -8631 -MB -/ -s -) -- -226 -389 -- -76 -. -66 -% -sherlock -: -: -name_sherlock_holmes -216 -522 -( -2747 -MB -/ -s -) -31 -640 -( -18803 -MB -/ -s -) -- -184 -882 -- -85 -. -39 -% -sherlock -: -: -name_sherlock_holmes_nocase -3 -480 -703 -( -170 -MB -/ -s -) -173 -522 -( -3428 -MB -/ -s -) -- -3 -307 -181 -- -95 -. -01 -% -sherlock -: -: -name_sherlock_nocase -3 -511 -444 -( -169 -MB -/ -s -) -170 -888 -( -3481 -MB -/ -s -) -- -3 -340 -556 -- -95 -. -13 -% -sherlock -: -: -name_whitespace -304 -043 -( -1956 -MB -/ -s -) -84 -314 -( -7056 -MB -/ -s -) -- -219 -729 -- -72 -. -27 -% -sherlock -: -: -no_match_common -632 -615 -( -940 -MB -/ -s -) -20 -727 -( -28703 -MB -/ -s -) -- -611 -888 -- -96 -. -72 -% -sherlock -: -: -no_match_really_common -727 -565 -( -817 -MB -/ -s -) -381 -476 -( -1559 -MB -/ -s -) -- -346 -089 -- -47 -. -57 -% -sherlock -: -: -no_match_uncommon -624 -061 -( -953 -MB -/ -s -) -20 -786 -( -28621 -MB -/ -s -) -- -603 -275 -- -96 -. -67 -% -sherlock -: -: -quotes -3 -776 -688 -( -157 -MB -/ -s -) -531 -487 -( -1119 -MB -/ -s -) -- -3 -245 -201 -- -85 -. -93 -% -sherlock -: -: -repeated_class_negation -34 -354 -179 -( -17 -MB -/ -s -) -85 -881 -944 -( -6 -MB -/ -s -) -51 -527 -765 -149 -. -99 -% -sherlock -: -: -the_lower -1 -965 -787 -( -302 -MB -/ -s -) -654 -110 -( -909 -MB -/ -s -) -- -1 -311 -677 -- -66 -. -73 -% -sherlock -: -: -the_nocase -4 -853 -843 -( -122 -MB -/ -s -) -474 -456 -( -1253 -MB -/ -s -) -- -4 -379 -387 -- -90 -. -23 -% -sherlock -: -: -the_upper -949 -071 -( -626 -MB -/ -s -) -43 -746 -( -13599 -MB -/ -s -) -- -905 -325 -- -95 -. -39 -% -sherlock -: -: -the_whitespace -2 -173 -683 -( -273 -MB -/ -s -) -1 -181 -974 -( -503 -MB -/ -s -) -- -991 -709 -- -45 -. -62 -% -sherlock -: -: -word_ending_n -19 -711 -057 -( -30 -MB -/ -s -) -1 -925 -578 -( -308 -MB -/ -s -) -- -17 -785 -479 -- -90 -. -23 -% -sherlock -: -: -words -21 -979 -387 -( -27 -MB -/ -s -) -9 -697 -201 -( -61 -MB -/ -s -) -- -12 -282 -186 -- -55 -. -88 -% diff --git a/third_party/rust/regex/record/old-bench-log/05/pcre1 b/third_party/rust/regex/record/old-bench-log/05/pcre1 deleted file mode 100644 index b7e63684dd43e..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/pcre1 +++ /dev/null @@ -1,2514 +0,0 @@ -running -93 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -30 -ns -/ -iter -( -+ -/ -- -0 -) -= -13000 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -1 -) -= -16250 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -29 -ns -/ -iter -( -+ -/ -- -1 -) -= -896 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -1 -) -= -1083 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -260 -ns -/ -iter -( -+ -/ -- -15 -) -= -4042 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -202 -849 -ns -/ -iter -( -+ -/ -- -7 -973 -) -= -5169 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -47 -ns -/ -iter -( -+ -/ -- -3 -) -= -1255 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -6 -378 -ns -/ -iter -( -+ -/ -- -236 -) -= -5141 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -248 -ns -/ -iter -( -+ -/ -- -15 -) -= -4209 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -203 -105 -ns -/ -iter -( -+ -/ -- -7 -590 -) -= -5162 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -1019 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -6 -508 -ns -/ -iter -( -+ -/ -- -160 -) -= -5038 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -324 -ns -/ -iter -( -+ -/ -- -46 -) -= -793 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -1 -134 -691 -ns -/ -iter -( -+ -/ -- -41 -296 -) -= -924 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -113 -ns -/ -iter -( -+ -/ -- -13 -) -= -522 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -42 -269 -ns -/ -iter -( -+ -/ -- -2 -298 -) -= -775 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -1821 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -547 -122 -ns -/ -iter -( -+ -/ -- -34 -029 -) -= -182 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -546 -018 -ns -/ -iter -( -+ -/ -- -24 -721 -) -= -183 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -97 -ns -/ -iter -( -+ -/ -- -5 -) -= -835 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -30 -ns -/ -iter -( -+ -/ -- -1 -) -= -2700 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -343 -ns -/ -iter -( -+ -/ -- -2 -) -= -469 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -253 -ns -/ -iter -( -+ -/ -- -15 -) -= -4158 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -202 -025 -ns -/ -iter -( -+ -/ -- -11 -252 -) -= -5190 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -2 -) -= -1176 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -6 -406 -ns -/ -iter -( -+ -/ -- -318 -) -= -5119 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -169 -ns -/ -iter -( -+ -/ -- -6 -) -= -301 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -1 -) -= -928 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -928 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -54 -ns -/ -iter -( -+ -/ -- -0 -) -= -314 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -3 -) -= -309 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -4 -664 -ns -/ -iter -( -+ -/ -- -123 -) -= -222 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -595 -ns -/ -iter -( -+ -/ -- -34 -) -= -658 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -377 -542 -ns -/ -iter -( -+ -/ -- -2 -203 -) -= -761 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -106 -ns -/ -iter -( -+ -/ -- -2 -) -= -556 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -43 -256 -ns -/ -iter -( -+ -/ -- -1 -230 -) -= -758 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -607 -ns -/ -iter -( -+ -/ -- -68 -) -= -1736 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -2 -840 -298 -ns -/ -iter -( -+ -/ -- -128 -040 -) -= -1789 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -1 -284 -283 -ns -/ -iter -( -+ -/ -- -39 -986 -) -= -3958 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -1 -269 -531 -ns -/ -iter -( -+ -/ -- -63 -116 -) -= -4004 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -1 -286 -171 -ns -/ -iter -( -+ -/ -- -49 -256 -) -= -3952 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -1 -303 -022 -ns -/ -iter -( -+ -/ -- -1 -553 -) -= -3901 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -1 -295 -961 -ns -/ -iter -( -+ -/ -- -57 -880 -) -= -3922 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -1 -313 -706 -ns -/ -iter -( -+ -/ -- -2 -115 -) -= -3869 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -1 -286 -339 -ns -/ -iter -( -+ -/ -- -2 -093 -) -= -3951 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -1 -385 -644 -ns -/ -iter -( -+ -/ -- -3 -387 -) -= -3668 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -1 -286 -743 -ns -/ -iter -( -+ -/ -- -2 -339 -) -= -3950 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -1 -306 -406 -ns -/ -iter -( -+ -/ -- -1 -686 -) -= -3891 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -1 -280 -365 -ns -/ -iter -( -+ -/ -- -52 -649 -) -= -3970 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -15 -271 -875 -ns -/ -iter -( -+ -/ -- -510 -399 -) -= -332 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -16 -704 -090 -ns -/ -iter -( -+ -/ -- -446 -145 -) -= -304 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -20 -745 -546 -ns -/ -iter -( -+ -/ -- -500 -573 -) -= -245 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -19 -285 -154 -ns -/ -iter -( -+ -/ -- -543 -793 -) -= -263 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -17 -234 -130 -ns -/ -iter -( -+ -/ -- -291 -232 -) -= -294 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -17 -462 -350 -ns -/ -iter -( -+ -/ -- -510 -036 -) -= -291 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -19 -671 -680 -ns -/ -iter -( -+ -/ -- -562 -610 -) -= -258 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -24 -515 -319 -ns -/ -iter -( -+ -/ -- -725 -298 -) -= -207 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -22 -623 -755 -ns -/ -iter -( -+ -/ -- -637 -538 -) -= -224 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -4 -510 -830 -ns -/ -iter -( -+ -/ -- -170 -864 -) -= -131 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -4 -706 -836 -ns -/ -iter -( -+ -/ -- -186 -202 -) -= -126 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -523 -122 -ns -/ -iter -( -+ -/ -- -988 -) -= -1137 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -2 -030 -438 -ns -/ -iter -( -+ -/ -- -9 -228 -) -= -293 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -4 -996 -956 -ns -/ -iter -( -+ -/ -- -197 -705 -) -= -119 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -13 -529 -105 -ns -/ -iter -( -+ -/ -- -496 -645 -) -= -43 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -13 -681 -607 -ns -/ -iter -( -+ -/ -- -448 -932 -) -= -43 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -904 -757 -ns -/ -iter -( -+ -/ -- -94 -484 -) -= -312 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -207 -695 -ns -/ -iter -( -+ -/ -- -8 -892 -) -= -2864 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -486 -857 -ns -/ -iter -( -+ -/ -- -21 -004 -) -= -1221 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -483 -926 -ns -/ -iter -( -+ -/ -- -26 -860 -) -= -1229 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -978 -827 -ns -/ -iter -( -+ -/ -- -43 -851 -) -= -607 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -986 -143 -ns -/ -iter -( -+ -/ -- -78 -155 -) -= -199 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -78 -104 -ns -/ -iter -( -+ -/ -- -4 -056 -) -= -7617 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -638 -351 -ns -/ -iter -( -+ -/ -- -62 -542 -) -= -363 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -685 -723 -ns -/ -iter -( -+ -/ -- -26 -092 -) -= -867 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -817 -760 -ns -/ -iter -( -+ -/ -- -80 -781 -) -= -327 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -411 -102 -ns -/ -iter -( -+ -/ -- -1 -887 -) -= -1447 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -516 -003 -ns -/ -iter -( -+ -/ -- -2 -295 -) -= -1152 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -284 -300 -ns -/ -iter -( -+ -/ -- -1 -117 -) -= -2092 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -209 -139 -ns -/ -iter -( -+ -/ -- -380 -) -= -2844 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -118 -324 -ns -/ -iter -( -+ -/ -- -1 -654 -) -= -531 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -126 -992 -ns -/ -iter -( -+ -/ -- -1 -180 -) -= -527 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -284 -672 -ns -/ -iter -( -+ -/ -- -510 -) -= -2089 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -439 -955 -ns -/ -iter -( -+ -/ -- -939 -) -= -1352 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -439 -266 -ns -/ -iter -( -+ -/ -- -3 -751 -) -= -1354 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -28 -872 -ns -/ -iter -( -+ -/ -- -31 -) -= -20605 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -522 -877 -ns -/ -iter -( -+ -/ -- -32 -723 -) -= -1137 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -5 -997 -745 -ns -/ -iter -( -+ -/ -- -209 -544 -) -= -99 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -747 -234 -ns -/ -iter -( -+ -/ -- -43 -110 -) -= -796 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -802 -320 -ns -/ -iter -( -+ -/ -- -27 -715 -) -= -741 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -58 -163 -ns -/ -iter -( -+ -/ -- -2 -202 -) -= -10228 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -920 -781 -ns -/ -iter -( -+ -/ -- -30 -609 -) -= -646 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -5 -703 -864 -ns -/ -iter -( -+ -/ -- -191 -007 -) -= -104 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -6 -786 -318 -ns -/ -iter -( -+ -/ -- -168 -049 -) -= -87 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -93 -measured diff --git a/third_party/rust/regex/record/old-bench-log/05/pcre1-vs-rust b/third_party/rust/regex/record/old-bench-log/05/pcre1-vs-rust deleted file mode 100644 index 10eba92a8b2f7..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/pcre1-vs-rust +++ /dev/null @@ -1,2587 +0,0 @@ -name -pcre1 -ns -/ -iter -rust -ns -/ -iter -diff -ns -/ -iter -diff -% -misc -: -: -anchored_literal_long_match -30 -( -13000 -MB -/ -s -) -24 -( -16250 -MB -/ -s -) -- -6 -- -20 -. -00 -% -misc -: -: -anchored_literal_long_non_match -24 -( -16250 -MB -/ -s -) -27 -( -14444 -MB -/ -s -) -3 -12 -. -50 -% -misc -: -: -anchored_literal_short_match -29 -( -896 -MB -/ -s -) -22 -( -1181 -MB -/ -s -) -- -7 -- -24 -. -14 -% -misc -: -: -anchored_literal_short_non_match -24 -( -1083 -MB -/ -s -) -24 -( -1083 -MB -/ -s -) -0 -0 -. -00 -% -misc -: -: -easy0_1K -260 -( -4042 -MB -/ -s -) -16 -( -65687 -MB -/ -s -) -- -244 -- -93 -. -85 -% -misc -: -: -easy0_1MB -202 -849 -( -5169 -MB -/ -s -) -20 -( -52430150 -MB -/ -s -) -- -202 -829 -- -99 -. -99 -% -misc -: -: -easy0_32 -47 -( -1255 -MB -/ -s -) -16 -( -3687 -MB -/ -s -) -- -31 -- -65 -. -96 -% -misc -: -: -easy0_32K -6 -378 -( -5141 -MB -/ -s -) -16 -( -2049687 -MB -/ -s -) -- -6 -362 -- -99 -. -75 -% -misc -: -: -easy1_1K -248 -( -4209 -MB -/ -s -) -48 -( -21750 -MB -/ -s -) -- -200 -- -80 -. -65 -% -misc -: -: -easy1_1MB -203 -105 -( -5162 -MB -/ -s -) -48 -( -21845750 -MB -/ -s -) -- -203 -057 -- -99 -. -98 -% -misc -: -: -easy1_32 -51 -( -1019 -MB -/ -s -) -46 -( -1130 -MB -/ -s -) -- -5 -- -9 -. -80 -% -misc -: -: -easy1_32K -6 -508 -( -5038 -MB -/ -s -) -47 -( -697617 -MB -/ -s -) -- -6 -461 -- -99 -. -28 -% -misc -: -: -hard_1K -1 -324 -( -793 -MB -/ -s -) -58 -( -18120 -MB -/ -s -) -- -1 -266 -- -95 -. -62 -% -misc -: -: -hard_1MB -1 -134 -691 -( -924 -MB -/ -s -) -61 -( -17190213 -MB -/ -s -) -- -1 -134 -630 -- -99 -. -99 -% -misc -: -: -hard_32 -113 -( -522 -MB -/ -s -) -58 -( -1017 -MB -/ -s -) -- -55 -- -48 -. -67 -% -misc -: -: -hard_32K -42 -269 -( -775 -MB -/ -s -) -56 -( -585625 -MB -/ -s -) -- -42 -213 -- -99 -. -87 -% -misc -: -: -literal -28 -( -1821 -MB -/ -s -) -16 -( -3187 -MB -/ -s -) -- -12 -- -42 -. -86 -% -misc -: -: -long_needle1 -547 -122 -( -182 -MB -/ -s -) -2 -226 -( -44924 -MB -/ -s -) -- -544 -896 -- -99 -. -59 -% -misc -: -: -long_needle2 -546 -018 -( -183 -MB -/ -s -) -576 -997 -( -173 -MB -/ -s -) -30 -979 -5 -. -67 -% -misc -: -: -match_class -97 -( -835 -MB -/ -s -) -65 -( -1246 -MB -/ -s -) -- -32 -- -32 -. -99 -% -misc -: -: -match_class_in_range -30 -( -2700 -MB -/ -s -) -27 -( -3000 -MB -/ -s -) -- -3 -- -10 -. -00 -% -misc -: -: -match_class_unicode -343 -( -469 -MB -/ -s -) -283 -( -568 -MB -/ -s -) -- -60 -- -17 -. -49 -% -misc -: -: -medium_1K -253 -( -4158 -MB -/ -s -) -16 -( -65750 -MB -/ -s -) -- -237 -- -93 -. -68 -% -misc -: -: -medium_1MB -202 -025 -( -5190 -MB -/ -s -) -21 -( -49933523 -MB -/ -s -) -- -202 -004 -- -99 -. -99 -% -misc -: -: -medium_32 -51 -( -1176 -MB -/ -s -) -17 -( -3529 -MB -/ -s -) -- -34 -- -66 -. -67 -% -misc -: -: -medium_32K -6 -406 -( -5119 -MB -/ -s -) -17 -( -1929176 -MB -/ -s -) -- -6 -389 -- -99 -. -73 -% -misc -: -: -not_literal -169 -( -301 -MB -/ -s -) -105 -( -485 -MB -/ -s -) -- -64 -- -37 -. -87 -% -misc -: -: -one_pass_long_prefix -28 -( -928 -MB -/ -s -) -68 -( -382 -MB -/ -s -) -40 -142 -. -86 -% -misc -: -: -one_pass_long_prefix_not -28 -( -928 -MB -/ -s -) -58 -( -448 -MB -/ -s -) -30 -107 -. -14 -% -misc -: -: -one_pass_short -54 -( -314 -MB -/ -s -) -45 -( -377 -MB -/ -s -) -- -9 -- -16 -. -67 -% -misc -: -: -one_pass_short_not -55 -( -309 -MB -/ -s -) -50 -( -340 -MB -/ -s -) -- -5 -- -9 -. -09 -% -misc -: -: -reallyhard2_1K -4 -664 -( -222 -MB -/ -s -) -83 -( -12530 -MB -/ -s -) -- -4 -581 -- -98 -. -22 -% -misc -: -: -reallyhard_1K -1 -595 -( -658 -MB -/ -s -) -1 -822 -( -576 -MB -/ -s -) -227 -14 -. -23 -% -misc -: -: -reallyhard_1MB -1 -377 -542 -( -761 -MB -/ -s -) -1 -768 -327 -( -592 -MB -/ -s -) -390 -785 -28 -. -37 -% -misc -: -: -reallyhard_32 -106 -( -556 -MB -/ -s -) -121 -( -487 -MB -/ -s -) -15 -14 -. -15 -% -misc -: -: -reallyhard_32K -43 -256 -( -758 -MB -/ -s -) -56 -375 -( -581 -MB -/ -s -) -13 -119 -30 -. -33 -% -misc -: -: -reverse_suffix_no_quadratic -4 -607 -( -1736 -MB -/ -s -) -5 -803 -( -1378 -MB -/ -s -) -1 -196 -25 -. -96 -% -regexdna -: -: -find_new_lines -2 -840 -298 -( -1789 -MB -/ -s -) -14 -818 -233 -( -343 -MB -/ -s -) -11 -977 -935 -421 -. -71 -% -regexdna -: -: -subst1 -1 -284 -283 -( -3958 -MB -/ -s -) -896 -790 -( -5668 -MB -/ -s -) -- -387 -493 -- -30 -. -17 -% -regexdna -: -: -subst10 -1 -269 -531 -( -4004 -MB -/ -s -) -957 -325 -( -5310 -MB -/ -s -) -- -312 -206 -- -24 -. -59 -% -regexdna -: -: -subst11 -1 -286 -171 -( -3952 -MB -/ -s -) -917 -248 -( -5542 -MB -/ -s -) -- -368 -923 -- -28 -. -68 -% -regexdna -: -: -subst2 -1 -303 -022 -( -3901 -MB -/ -s -) -892 -129 -( -5698 -MB -/ -s -) -- -410 -893 -- -31 -. -53 -% -regexdna -: -: -subst3 -1 -295 -961 -( -3922 -MB -/ -s -) -929 -250 -( -5470 -MB -/ -s -) -- -366 -711 -- -28 -. -30 -% -regexdna -: -: -subst4 -1 -313 -706 -( -3869 -MB -/ -s -) -872 -581 -( -5825 -MB -/ -s -) -- -441 -125 -- -33 -. -58 -% -regexdna -: -: -subst5 -1 -286 -339 -( -3951 -MB -/ -s -) -875 -804 -( -5804 -MB -/ -s -) -- -410 -535 -- -31 -. -91 -% -regexdna -: -: -subst6 -1 -385 -644 -( -3668 -MB -/ -s -) -884 -639 -( -5746 -MB -/ -s -) -- -501 -005 -- -36 -. -16 -% -regexdna -: -: -subst7 -1 -286 -743 -( -3950 -MB -/ -s -) -872 -791 -( -5824 -MB -/ -s -) -- -413 -952 -- -32 -. -17 -% -regexdna -: -: -subst8 -1 -306 -406 -( -3891 -MB -/ -s -) -873 -833 -( -5817 -MB -/ -s -) -- -432 -573 -- -33 -. -11 -% -regexdna -: -: -subst9 -1 -280 -365 -( -3970 -MB -/ -s -) -886 -744 -( -5732 -MB -/ -s -) -- -393 -621 -- -30 -. -74 -% -regexdna -: -: -variant1 -15 -271 -875 -( -332 -MB -/ -s -) -3 -699 -267 -( -1374 -MB -/ -s -) -- -11 -572 -608 -- -75 -. -78 -% -regexdna -: -: -variant2 -16 -704 -090 -( -304 -MB -/ -s -) -6 -760 -952 -( -751 -MB -/ -s -) -- -9 -943 -138 -- -59 -. -53 -% -regexdna -: -: -variant3 -20 -745 -546 -( -245 -MB -/ -s -) -8 -030 -646 -( -633 -MB -/ -s -) -- -12 -714 -900 -- -61 -. -29 -% -regexdna -: -: -variant4 -19 -285 -154 -( -263 -MB -/ -s -) -8 -077 -290 -( -629 -MB -/ -s -) -- -11 -207 -864 -- -58 -. -12 -% -regexdna -: -: -variant5 -17 -234 -130 -( -294 -MB -/ -s -) -6 -787 -242 -( -748 -MB -/ -s -) -- -10 -446 -888 -- -60 -. -62 -% -regexdna -: -: -variant6 -17 -462 -350 -( -291 -MB -/ -s -) -6 -577 -777 -( -772 -MB -/ -s -) -- -10 -884 -573 -- -62 -. -33 -% -regexdna -: -: -variant7 -19 -671 -680 -( -258 -MB -/ -s -) -6 -705 -580 -( -758 -MB -/ -s -) -- -12 -966 -100 -- -65 -. -91 -% -regexdna -: -: -variant8 -24 -515 -319 -( -207 -MB -/ -s -) -6 -818 -785 -( -745 -MB -/ -s -) -- -17 -696 -534 -- -72 -. -19 -% -regexdna -: -: -variant9 -22 -623 -755 -( -224 -MB -/ -s -) -6 -821 -453 -( -745 -MB -/ -s -) -- -15 -802 -302 -- -69 -. -85 -% -sherlock -: -: -before_after_holmes -4 -510 -830 -( -131 -MB -/ -s -) -1 -029 -866 -( -577 -MB -/ -s -) -- -3 -480 -964 -- -77 -. -17 -% -sherlock -: -: -before_holmes -4 -706 -836 -( -126 -MB -/ -s -) -76 -633 -( -7763 -MB -/ -s -) -- -4 -630 -203 -- -98 -. -37 -% -sherlock -: -: -holmes_cochar_watson -523 -122 -( -1137 -MB -/ -s -) -144 -725 -( -4110 -MB -/ -s -) -- -378 -397 -- -72 -. -33 -% -sherlock -: -: -ing_suffix -2 -030 -438 -( -293 -MB -/ -s -) -436 -202 -( -1363 -MB -/ -s -) -- -1 -594 -236 -- -78 -. -52 -% -sherlock -: -: -ing_suffix_limited_space -4 -996 -956 -( -119 -MB -/ -s -) -1 -182 -943 -( -502 -MB -/ -s -) -- -3 -814 -013 -- -76 -. -33 -% -sherlock -: -: -letters -13 -529 -105 -( -43 -MB -/ -s -) -24 -390 -452 -( -24 -MB -/ -s -) -10 -861 -347 -80 -. -28 -% -sherlock -: -: -letters_lower -13 -681 -607 -( -43 -MB -/ -s -) -23 -784 -108 -( -25 -MB -/ -s -) -10 -102 -501 -73 -. -84 -% -sherlock -: -: -letters_upper -1 -904 -757 -( -312 -MB -/ -s -) -1 -993 -838 -( -298 -MB -/ -s -) -89 -081 -4 -. -68 -% -sherlock -: -: -line_boundary_sherlock_holmes -207 -695 -( -2864 -MB -/ -s -) -999 -414 -( -595 -MB -/ -s -) -791 -719 -381 -. -19 -% -sherlock -: -: -name_alt1 -486 -857 -( -1221 -MB -/ -s -) -34 -298 -( -17345 -MB -/ -s -) -- -452 -559 -- -92 -. -96 -% -sherlock -: -: -name_alt2 -483 -926 -( -1229 -MB -/ -s -) -124 -226 -( -4789 -MB -/ -s -) -- -359 -700 -- -74 -. -33 -% -sherlock -: -: -name_alt3 -978 -827 -( -607 -MB -/ -s -) -137 -742 -( -4319 -MB -/ -s -) -- -841 -085 -- -85 -. -93 -% -sherlock -: -: -name_alt3_nocase -2 -986 -143 -( -199 -MB -/ -s -) -1 -293 -763 -( -459 -MB -/ -s -) -- -1 -692 -380 -- -56 -. -67 -% -sherlock -: -: -name_alt4 -78 -104 -( -7617 -MB -/ -s -) -164 -900 -( -3607 -MB -/ -s -) -86 -796 -111 -. -13 -% -sherlock -: -: -name_alt4_nocase -1 -638 -351 -( -363 -MB -/ -s -) -235 -023 -( -2531 -MB -/ -s -) -- -1 -403 -328 -- -85 -. -65 -% -sherlock -: -: -name_alt5 -685 -723 -( -867 -MB -/ -s -) -127 -928 -( -4650 -MB -/ -s -) -- -557 -795 -- -81 -. -34 -% -sherlock -: -: -name_alt5_nocase -1 -817 -760 -( -327 -MB -/ -s -) -659 -591 -( -901 -MB -/ -s -) -- -1 -158 -169 -- -63 -. -71 -% -sherlock -: -: -name_holmes -411 -102 -( -1447 -MB -/ -s -) -40 -902 -( -14545 -MB -/ -s -) -- -370 -200 -- -90 -. -05 -% -sherlock -: -: -name_holmes_nocase -516 -003 -( -1152 -MB -/ -s -) -198 -658 -( -2994 -MB -/ -s -) -- -317 -345 -- -61 -. -50 -% -sherlock -: -: -name_sherlock -284 -300 -( -2092 -MB -/ -s -) -68 -924 -( -8631 -MB -/ -s -) -- -215 -376 -- -75 -. -76 -% -sherlock -: -: -name_sherlock_holmes -209 -139 -( -2844 -MB -/ -s -) -31 -640 -( -18803 -MB -/ -s -) -- -177 -499 -- -84 -. -87 -% -sherlock -: -: -name_sherlock_holmes_nocase -1 -118 -324 -( -531 -MB -/ -s -) -173 -522 -( -3428 -MB -/ -s -) -- -944 -802 -- -84 -. -48 -% -sherlock -: -: -name_sherlock_nocase -1 -126 -992 -( -527 -MB -/ -s -) -170 -888 -( -3481 -MB -/ -s -) -- -956 -104 -- -84 -. -84 -% -sherlock -: -: -name_whitespace -284 -672 -( -2089 -MB -/ -s -) -84 -314 -( -7056 -MB -/ -s -) -- -200 -358 -- -70 -. -38 -% -sherlock -: -: -no_match_common -439 -955 -( -1352 -MB -/ -s -) -20 -727 -( -28703 -MB -/ -s -) -- -419 -228 -- -95 -. -29 -% -sherlock -: -: -no_match_really_common -439 -266 -( -1354 -MB -/ -s -) -381 -476 -( -1559 -MB -/ -s -) -- -57 -790 -- -13 -. -16 -% -sherlock -: -: -no_match_uncommon -28 -872 -( -20605 -MB -/ -s -) -20 -786 -( -28621 -MB -/ -s -) -- -8 -086 -- -28 -. -01 -% -sherlock -: -: -quotes -522 -877 -( -1137 -MB -/ -s -) -531 -487 -( -1119 -MB -/ -s -) -8 -610 -1 -. -65 -% -sherlock -: -: -repeated_class_negation -5 -997 -745 -( -99 -MB -/ -s -) -85 -881 -944 -( -6 -MB -/ -s -) -79 -884 -199 -1331 -. -90 -% -sherlock -: -: -the_lower -747 -234 -( -796 -MB -/ -s -) -654 -110 -( -909 -MB -/ -s -) -- -93 -124 -- -12 -. -46 -% -sherlock -: -: -the_nocase -802 -320 -( -741 -MB -/ -s -) -474 -456 -( -1253 -MB -/ -s -) -- -327 -864 -- -40 -. -86 -% -sherlock -: -: -the_upper -58 -163 -( -10228 -MB -/ -s -) -43 -746 -( -13599 -MB -/ -s -) -- -14 -417 -- -24 -. -79 -% -sherlock -: -: -the_whitespace -920 -781 -( -646 -MB -/ -s -) -1 -181 -974 -( -503 -MB -/ -s -) -261 -193 -28 -. -37 -% -sherlock -: -: -word_ending_n -5 -703 -864 -( -104 -MB -/ -s -) -1 -925 -578 -( -308 -MB -/ -s -) -- -3 -778 -286 -- -66 -. -24 -% -sherlock -: -: -words -6 -786 -318 -( -87 -MB -/ -s -) -9 -697 -201 -( -61 -MB -/ -s -) -2 -910 -883 -42 -. -89 -% diff --git a/third_party/rust/regex/record/old-bench-log/05/pcre2 b/third_party/rust/regex/record/old-bench-log/05/pcre2 deleted file mode 100644 index 66d90de35e3d4..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/pcre2 +++ /dev/null @@ -1,2507 +0,0 @@ -running -93 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -19500 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -26000 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -1 -) -= -1368 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -2000 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -241 -ns -/ -iter -( -+ -/ -- -9 -) -= -4360 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -207 -103 -ns -/ -iter -( -+ -/ -- -8 -557 -) -= -5063 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -0 -) -= -1512 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -6 -522 -ns -/ -iter -( -+ -/ -- -20 -) -= -5028 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -247 -ns -/ -iter -( -+ -/ -- -3 -) -= -4226 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -206 -893 -ns -/ -iter -( -+ -/ -- -9 -489 -) -= -5068 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -1268 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -6 -516 -ns -/ -iter -( -+ -/ -- -301 -) -= -5031 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -566 -ns -/ -iter -( -+ -/ -- -79 -) -= -671 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -1 -119 -234 -ns -/ -iter -( -+ -/ -- -38 -605 -) -= -936 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -95 -ns -/ -iter -( -+ -/ -- -4 -) -= -621 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -34 -411 -ns -/ -iter -( -+ -/ -- -1 -542 -) -= -953 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -2833 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -550 -340 -ns -/ -iter -( -+ -/ -- -30 -668 -) -= -181 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -553 -056 -ns -/ -iter -( -+ -/ -- -25 -618 -) -= -180 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -82 -ns -/ -iter -( -+ -/ -- -1 -) -= -987 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -1 -) -= -4050 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -351 -ns -/ -iter -( -+ -/ -- -14 -) -= -458 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -242 -ns -/ -iter -( -+ -/ -- -13 -) -= -4347 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -207 -290 -ns -/ -iter -( -+ -/ -- -1 -458 -) -= -5058 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -1463 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -6 -529 -ns -/ -iter -( -+ -/ -- -293 -) -= -5023 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -161 -ns -/ -iter -( -+ -/ -- -7 -) -= -316 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -1 -) -= -1529 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -1 -) -= -1444 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -45 -ns -/ -iter -( -+ -/ -- -2 -) -= -377 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -2 -) -= -346 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -4 -487 -ns -/ -iter -( -+ -/ -- -190 -) -= -231 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -260 -ns -/ -iter -( -+ -/ -- -46 -) -= -834 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -361 -796 -ns -/ -iter -( -+ -/ -- -46 -490 -) -= -770 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -93 -ns -/ -iter -( -+ -/ -- -8 -) -= -634 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -42 -503 -ns -/ -iter -( -+ -/ -- -1 -721 -) -= -771 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -559 -ns -/ -iter -( -+ -/ -- -171 -) -= -1754 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -1 -887 -325 -ns -/ -iter -( -+ -/ -- -74 -026 -) -= -2693 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -963 -089 -ns -/ -iter -( -+ -/ -- -3 -478 -) -= -5278 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -968 -221 -ns -/ -iter -( -+ -/ -- -5 -406 -) -= -5250 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -961 -661 -ns -/ -iter -( -+ -/ -- -45 -597 -) -= -5286 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -956 -430 -ns -/ -iter -( -+ -/ -- -32 -654 -) -= -5314 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -961 -204 -ns -/ -iter -( -+ -/ -- -48 -799 -) -= -5288 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -961 -897 -ns -/ -iter -( -+ -/ -- -50 -762 -) -= -5284 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -953 -412 -ns -/ -iter -( -+ -/ -- -69 -554 -) -= -5331 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -962 -362 -ns -/ -iter -( -+ -/ -- -42 -136 -) -= -5282 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -961 -694 -ns -/ -iter -( -+ -/ -- -100 -348 -) -= -5285 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -963 -230 -ns -/ -iter -( -+ -/ -- -10 -882 -) -= -5277 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -960 -246 -ns -/ -iter -( -+ -/ -- -27 -407 -) -= -5293 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -15 -553 -281 -ns -/ -iter -( -+ -/ -- -566 -810 -) -= -326 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -16 -563 -452 -ns -/ -iter -( -+ -/ -- -546 -097 -) -= -306 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -20 -405 -916 -ns -/ -iter -( -+ -/ -- -809 -236 -) -= -249 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -19 -489 -291 -ns -/ -iter -( -+ -/ -- -710 -721 -) -= -260 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -17 -406 -769 -ns -/ -iter -( -+ -/ -- -656 -024 -) -= -292 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -17 -412 -027 -ns -/ -iter -( -+ -/ -- -730 -347 -) -= -291 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -19 -509 -193 -ns -/ -iter -( -+ -/ -- -783 -850 -) -= -260 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -24 -295 -734 -ns -/ -iter -( -+ -/ -- -816 -832 -) -= -209 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -22 -541 -558 -ns -/ -iter -( -+ -/ -- -783 -104 -) -= -225 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -4 -583 -804 -ns -/ -iter -( -+ -/ -- -124 -057 -) -= -129 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -4 -640 -546 -ns -/ -iter -( -+ -/ -- -241 -311 -) -= -128 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -509 -088 -ns -/ -iter -( -+ -/ -- -25 -069 -) -= -1168 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -1 -865 -631 -ns -/ -iter -( -+ -/ -- -68 -625 -) -= -318 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -4 -922 -883 -ns -/ -iter -( -+ -/ -- -232 -825 -) -= -120 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -9 -848 -144 -ns -/ -iter -( -+ -/ -- -206 -915 -) -= -60 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -9 -723 -642 -ns -/ -iter -( -+ -/ -- -370 -000 -) -= -61 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -762 -773 -ns -/ -iter -( -+ -/ -- -86 -671 -) -= -337 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -206 -367 -ns -/ -iter -( -+ -/ -- -8 -874 -) -= -2882 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -485 -953 -ns -/ -iter -( -+ -/ -- -15 -036 -) -= -1224 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -483 -813 -ns -/ -iter -( -+ -/ -- -17 -822 -) -= -1229 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -903 -013 -ns -/ -iter -( -+ -/ -- -38 -445 -) -= -658 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -993 -633 -ns -/ -iter -( -+ -/ -- -131 -218 -) -= -198 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -78 -831 -ns -/ -iter -( -+ -/ -- -2 -012 -) -= -7546 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -647 -202 -ns -/ -iter -( -+ -/ -- -5 -838 -) -= -361 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -678 -798 -ns -/ -iter -( -+ -/ -- -1 -146 -) -= -876 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -792 -461 -ns -/ -iter -( -+ -/ -- -3 -532 -) -= -331 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -406 -138 -ns -/ -iter -( -+ -/ -- -1 -157 -) -= -1464 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -517 -884 -ns -/ -iter -( -+ -/ -- -8 -548 -) -= -1148 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -282 -357 -ns -/ -iter -( -+ -/ -- -13 -583 -) -= -2107 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -207 -894 -ns -/ -iter -( -+ -/ -- -1 -847 -) -= -2861 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -122 -583 -ns -/ -iter -( -+ -/ -- -52 -189 -) -= -529 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -092 -252 -ns -/ -iter -( -+ -/ -- -43 -130 -) -= -544 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -280 -360 -ns -/ -iter -( -+ -/ -- -12 -136 -) -= -2122 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -436 -303 -ns -/ -iter -( -+ -/ -- -19 -423 -) -= -1363 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -417 -686 -ns -/ -iter -( -+ -/ -- -15 -258 -) -= -1424 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -28 -504 -ns -/ -iter -( -+ -/ -- -1 -032 -) -= -20871 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -541 -513 -ns -/ -iter -( -+ -/ -- -21 -121 -) -= -1098 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -5 -489 -721 -ns -/ -iter -( -+ -/ -- -185 -165 -) -= -108 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -680 -710 -ns -/ -iter -( -+ -/ -- -29 -403 -) -= -873 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -737 -040 -ns -/ -iter -( -+ -/ -- -4 -391 -) -= -807 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -50 -026 -ns -/ -iter -( -+ -/ -- -205 -) -= -11892 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -885 -922 -ns -/ -iter -( -+ -/ -- -9 -145 -) -= -671 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -5 -424 -773 -ns -/ -iter -( -+ -/ -- -154 -353 -) -= -109 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -5 -753 -231 -ns -/ -iter -( -+ -/ -- -177 -890 -) -= -103 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -93 -measured diff --git a/third_party/rust/regex/record/old-bench-log/05/pcre2-vs-rust b/third_party/rust/regex/record/old-bench-log/05/pcre2-vs-rust deleted file mode 100644 index b5d2d9ff149e4..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/pcre2-vs-rust +++ /dev/null @@ -1,2566 +0,0 @@ -name -pcre2 -ns -/ -iter -rust -ns -/ -iter -diff -ns -/ -iter -diff -% -misc -: -: -anchored_literal_long_match -20 -( -19500 -MB -/ -s -) -24 -( -16250 -MB -/ -s -) -4 -20 -. -00 -% -misc -: -: -anchored_literal_long_non_match -15 -( -26000 -MB -/ -s -) -27 -( -14444 -MB -/ -s -) -12 -80 -. -00 -% -misc -: -: -anchored_literal_short_match -19 -( -1368 -MB -/ -s -) -22 -( -1181 -MB -/ -s -) -3 -15 -. -79 -% -misc -: -: -anchored_literal_short_non_match -13 -( -2000 -MB -/ -s -) -24 -( -1083 -MB -/ -s -) -11 -84 -. -62 -% -misc -: -: -easy0_1K -241 -( -4360 -MB -/ -s -) -16 -( -65687 -MB -/ -s -) -- -225 -- -93 -. -36 -% -misc -: -: -easy0_1MB -207 -103 -( -5063 -MB -/ -s -) -20 -( -52430150 -MB -/ -s -) -- -207 -083 -- -99 -. -99 -% -misc -: -: -easy0_32 -39 -( -1512 -MB -/ -s -) -16 -( -3687 -MB -/ -s -) -- -23 -- -58 -. -97 -% -misc -: -: -easy0_32K -6 -522 -( -5028 -MB -/ -s -) -16 -( -2049687 -MB -/ -s -) -- -6 -506 -- -99 -. -75 -% -misc -: -: -easy1_1K -247 -( -4226 -MB -/ -s -) -48 -( -21750 -MB -/ -s -) -- -199 -- -80 -. -57 -% -misc -: -: -easy1_1MB -206 -893 -( -5068 -MB -/ -s -) -48 -( -21845750 -MB -/ -s -) -- -206 -845 -- -99 -. -98 -% -misc -: -: -easy1_32 -41 -( -1268 -MB -/ -s -) -46 -( -1130 -MB -/ -s -) -5 -12 -. -20 -% -misc -: -: -easy1_32K -6 -516 -( -5031 -MB -/ -s -) -47 -( -697617 -MB -/ -s -) -- -6 -469 -- -99 -. -28 -% -misc -: -: -hard_1K -1 -566 -( -671 -MB -/ -s -) -58 -( -18120 -MB -/ -s -) -- -1 -508 -- -96 -. -30 -% -misc -: -: -hard_1MB -1 -119 -234 -( -936 -MB -/ -s -) -61 -( -17190213 -MB -/ -s -) -- -1 -119 -173 -- -99 -. -99 -% -misc -: -: -hard_32 -95 -( -621 -MB -/ -s -) -58 -( -1017 -MB -/ -s -) -- -37 -- -38 -. -95 -% -misc -: -: -hard_32K -34 -411 -( -953 -MB -/ -s -) -56 -( -585625 -MB -/ -s -) -- -34 -355 -- -99 -. -84 -% -misc -: -: -literal -18 -( -2833 -MB -/ -s -) -16 -( -3187 -MB -/ -s -) -- -2 -- -11 -. -11 -% -misc -: -: -long_needle1 -550 -340 -( -181 -MB -/ -s -) -2 -226 -( -44924 -MB -/ -s -) -- -548 -114 -- -99 -. -60 -% -misc -: -: -long_needle2 -553 -056 -( -180 -MB -/ -s -) -576 -997 -( -173 -MB -/ -s -) -23 -941 -4 -. -33 -% -misc -: -: -match_class -82 -( -987 -MB -/ -s -) -65 -( -1246 -MB -/ -s -) -- -17 -- -20 -. -73 -% -misc -: -: -match_class_in_range -20 -( -4050 -MB -/ -s -) -27 -( -3000 -MB -/ -s -) -7 -35 -. -00 -% -misc -: -: -match_class_unicode -351 -( -458 -MB -/ -s -) -283 -( -568 -MB -/ -s -) -- -68 -- -19 -. -37 -% -misc -: -: -medium_1K -242 -( -4347 -MB -/ -s -) -16 -( -65750 -MB -/ -s -) -- -226 -- -93 -. -39 -% -misc -: -: -medium_1MB -207 -290 -( -5058 -MB -/ -s -) -21 -( -49933523 -MB -/ -s -) -- -207 -269 -- -99 -. -99 -% -misc -: -: -medium_32 -41 -( -1463 -MB -/ -s -) -17 -( -3529 -MB -/ -s -) -- -24 -- -58 -. -54 -% -misc -: -: -medium_32K -6 -529 -( -5023 -MB -/ -s -) -17 -( -1929176 -MB -/ -s -) -- -6 -512 -- -99 -. -74 -% -misc -: -: -not_literal -161 -( -316 -MB -/ -s -) -105 -( -485 -MB -/ -s -) -- -56 -- -34 -. -78 -% -misc -: -: -one_pass_long_prefix -17 -( -1529 -MB -/ -s -) -68 -( -382 -MB -/ -s -) -51 -300 -. -00 -% -misc -: -: -one_pass_long_prefix_not -18 -( -1444 -MB -/ -s -) -58 -( -448 -MB -/ -s -) -40 -222 -. -22 -% -misc -: -: -one_pass_short -45 -( -377 -MB -/ -s -) -45 -( -377 -MB -/ -s -) -0 -0 -. -00 -% -misc -: -: -one_pass_short_not -49 -( -346 -MB -/ -s -) -50 -( -340 -MB -/ -s -) -1 -2 -. -04 -% -misc -: -: -reallyhard2_1K -4 -487 -( -231 -MB -/ -s -) -83 -( -12530 -MB -/ -s -) -- -4 -404 -- -98 -. -15 -% -misc -: -: -reallyhard_1K -1 -260 -( -834 -MB -/ -s -) -1 -822 -( -576 -MB -/ -s -) -562 -44 -. -60 -% -misc -: -: -reallyhard_1MB -1 -361 -796 -( -770 -MB -/ -s -) -1 -768 -327 -( -592 -MB -/ -s -) -406 -531 -29 -. -85 -% -misc -: -: -reallyhard_32 -93 -( -634 -MB -/ -s -) -121 -( -487 -MB -/ -s -) -28 -30 -. -11 -% -misc -: -: -reallyhard_32K -42 -503 -( -771 -MB -/ -s -) -56 -375 -( -581 -MB -/ -s -) -13 -872 -32 -. -64 -% -misc -: -: -reverse_suffix_no_quadratic -4 -559 -( -1754 -MB -/ -s -) -5 -803 -( -1378 -MB -/ -s -) -1 -244 -27 -. -29 -% -regexdna -: -: -find_new_lines -1 -887 -325 -( -2693 -MB -/ -s -) -14 -818 -233 -( -343 -MB -/ -s -) -12 -930 -908 -685 -. -14 -% -regexdna -: -: -subst1 -963 -089 -( -5278 -MB -/ -s -) -896 -790 -( -5668 -MB -/ -s -) -- -66 -299 -- -6 -. -88 -% -regexdna -: -: -subst10 -968 -221 -( -5250 -MB -/ -s -) -957 -325 -( -5310 -MB -/ -s -) -- -10 -896 -- -1 -. -13 -% -regexdna -: -: -subst11 -961 -661 -( -5286 -MB -/ -s -) -917 -248 -( -5542 -MB -/ -s -) -- -44 -413 -- -4 -. -62 -% -regexdna -: -: -subst2 -956 -430 -( -5314 -MB -/ -s -) -892 -129 -( -5698 -MB -/ -s -) -- -64 -301 -- -6 -. -72 -% -regexdna -: -: -subst3 -961 -204 -( -5288 -MB -/ -s -) -929 -250 -( -5470 -MB -/ -s -) -- -31 -954 -- -3 -. -32 -% -regexdna -: -: -subst4 -961 -897 -( -5284 -MB -/ -s -) -872 -581 -( -5825 -MB -/ -s -) -- -89 -316 -- -9 -. -29 -% -regexdna -: -: -subst5 -953 -412 -( -5331 -MB -/ -s -) -875 -804 -( -5804 -MB -/ -s -) -- -77 -608 -- -8 -. -14 -% -regexdna -: -: -subst6 -962 -362 -( -5282 -MB -/ -s -) -884 -639 -( -5746 -MB -/ -s -) -- -77 -723 -- -8 -. -08 -% -regexdna -: -: -subst7 -961 -694 -( -5285 -MB -/ -s -) -872 -791 -( -5824 -MB -/ -s -) -- -88 -903 -- -9 -. -24 -% -regexdna -: -: -subst8 -963 -230 -( -5277 -MB -/ -s -) -873 -833 -( -5817 -MB -/ -s -) -- -89 -397 -- -9 -. -28 -% -regexdna -: -: -subst9 -960 -246 -( -5293 -MB -/ -s -) -886 -744 -( -5732 -MB -/ -s -) -- -73 -502 -- -7 -. -65 -% -regexdna -: -: -variant1 -15 -553 -281 -( -326 -MB -/ -s -) -3 -699 -267 -( -1374 -MB -/ -s -) -- -11 -854 -014 -- -76 -. -22 -% -regexdna -: -: -variant2 -16 -563 -452 -( -306 -MB -/ -s -) -6 -760 -952 -( -751 -MB -/ -s -) -- -9 -802 -500 -- -59 -. -18 -% -regexdna -: -: -variant3 -20 -405 -916 -( -249 -MB -/ -s -) -8 -030 -646 -( -633 -MB -/ -s -) -- -12 -375 -270 -- -60 -. -65 -% -regexdna -: -: -variant4 -19 -489 -291 -( -260 -MB -/ -s -) -8 -077 -290 -( -629 -MB -/ -s -) -- -11 -412 -001 -- -58 -. -56 -% -regexdna -: -: -variant5 -17 -406 -769 -( -292 -MB -/ -s -) -6 -787 -242 -( -748 -MB -/ -s -) -- -10 -619 -527 -- -61 -. -01 -% -regexdna -: -: -variant6 -17 -412 -027 -( -291 -MB -/ -s -) -6 -577 -777 -( -772 -MB -/ -s -) -- -10 -834 -250 -- -62 -. -22 -% -regexdna -: -: -variant7 -19 -509 -193 -( -260 -MB -/ -s -) -6 -705 -580 -( -758 -MB -/ -s -) -- -12 -803 -613 -- -65 -. -63 -% -regexdna -: -: -variant8 -24 -295 -734 -( -209 -MB -/ -s -) -6 -818 -785 -( -745 -MB -/ -s -) -- -17 -476 -949 -- -71 -. -93 -% -regexdna -: -: -variant9 -22 -541 -558 -( -225 -MB -/ -s -) -6 -821 -453 -( -745 -MB -/ -s -) -- -15 -720 -105 -- -69 -. -74 -% -sherlock -: -: -before_after_holmes -4 -583 -804 -( -129 -MB -/ -s -) -1 -029 -866 -( -577 -MB -/ -s -) -- -3 -553 -938 -- -77 -. -53 -% -sherlock -: -: -before_holmes -4 -640 -546 -( -128 -MB -/ -s -) -76 -633 -( -7763 -MB -/ -s -) -- -4 -563 -913 -- -98 -. -35 -% -sherlock -: -: -holmes_cochar_watson -509 -088 -( -1168 -MB -/ -s -) -144 -725 -( -4110 -MB -/ -s -) -- -364 -363 -- -71 -. -57 -% -sherlock -: -: -ing_suffix -1 -865 -631 -( -318 -MB -/ -s -) -436 -202 -( -1363 -MB -/ -s -) -- -1 -429 -429 -- -76 -. -62 -% -sherlock -: -: -ing_suffix_limited_space -4 -922 -883 -( -120 -MB -/ -s -) -1 -182 -943 -( -502 -MB -/ -s -) -- -3 -739 -940 -- -75 -. -97 -% -sherlock -: -: -letters -9 -848 -144 -( -60 -MB -/ -s -) -24 -390 -452 -( -24 -MB -/ -s -) -14 -542 -308 -147 -. -67 -% -sherlock -: -: -letters_lower -9 -723 -642 -( -61 -MB -/ -s -) -23 -784 -108 -( -25 -MB -/ -s -) -14 -060 -466 -144 -. -60 -% -sherlock -: -: -letters_upper -1 -762 -773 -( -337 -MB -/ -s -) -1 -993 -838 -( -298 -MB -/ -s -) -231 -065 -13 -. -11 -% -sherlock -: -: -line_boundary_sherlock_holmes -206 -367 -( -2882 -MB -/ -s -) -999 -414 -( -595 -MB -/ -s -) -793 -047 -384 -. -29 -% -sherlock -: -: -name_alt1 -485 -953 -( -1224 -MB -/ -s -) -34 -298 -( -17345 -MB -/ -s -) -- -451 -655 -- -92 -. -94 -% -sherlock -: -: -name_alt2 -483 -813 -( -1229 -MB -/ -s -) -124 -226 -( -4789 -MB -/ -s -) -- -359 -587 -- -74 -. -32 -% -sherlock -: -: -name_alt3 -903 -013 -( -658 -MB -/ -s -) -137 -742 -( -4319 -MB -/ -s -) -- -765 -271 -- -84 -. -75 -% -sherlock -: -: -name_alt3_nocase -2 -993 -633 -( -198 -MB -/ -s -) -1 -293 -763 -( -459 -MB -/ -s -) -- -1 -699 -870 -- -56 -. -78 -% -sherlock -: -: -name_alt4 -78 -831 -( -7546 -MB -/ -s -) -164 -900 -( -3607 -MB -/ -s -) -86 -069 -109 -. -18 -% -sherlock -: -: -name_alt4_nocase -1 -647 -202 -( -361 -MB -/ -s -) -235 -023 -( -2531 -MB -/ -s -) -- -1 -412 -179 -- -85 -. -73 -% -sherlock -: -: -name_alt5 -678 -798 -( -876 -MB -/ -s -) -127 -928 -( -4650 -MB -/ -s -) -- -550 -870 -- -81 -. -15 -% -sherlock -: -: -name_alt5_nocase -1 -792 -461 -( -331 -MB -/ -s -) -659 -591 -( -901 -MB -/ -s -) -- -1 -132 -870 -- -63 -. -20 -% -sherlock -: -: -name_holmes -406 -138 -( -1464 -MB -/ -s -) -40 -902 -( -14545 -MB -/ -s -) -- -365 -236 -- -89 -. -93 -% -sherlock -: -: -name_holmes_nocase -517 -884 -( -1148 -MB -/ -s -) -198 -658 -( -2994 -MB -/ -s -) -- -319 -226 -- -61 -. -64 -% -sherlock -: -: -name_sherlock -282 -357 -( -2107 -MB -/ -s -) -68 -924 -( -8631 -MB -/ -s -) -- -213 -433 -- -75 -. -59 -% -sherlock -: -: -name_sherlock_holmes -207 -894 -( -2861 -MB -/ -s -) -31 -640 -( -18803 -MB -/ -s -) -- -176 -254 -- -84 -. -78 -% -sherlock -: -: -name_sherlock_holmes_nocase -1 -122 -583 -( -529 -MB -/ -s -) -173 -522 -( -3428 -MB -/ -s -) -- -949 -061 -- -84 -. -54 -% -sherlock -: -: -name_sherlock_nocase -1 -092 -252 -( -544 -MB -/ -s -) -170 -888 -( -3481 -MB -/ -s -) -- -921 -364 -- -84 -. -35 -% -sherlock -: -: -name_whitespace -280 -360 -( -2122 -MB -/ -s -) -84 -314 -( -7056 -MB -/ -s -) -- -196 -046 -- -69 -. -93 -% -sherlock -: -: -no_match_common -436 -303 -( -1363 -MB -/ -s -) -20 -727 -( -28703 -MB -/ -s -) -- -415 -576 -- -95 -. -25 -% -sherlock -: -: -no_match_really_common -417 -686 -( -1424 -MB -/ -s -) -381 -476 -( -1559 -MB -/ -s -) -- -36 -210 -- -8 -. -67 -% -sherlock -: -: -no_match_uncommon -28 -504 -( -20871 -MB -/ -s -) -20 -786 -( -28621 -MB -/ -s -) -- -7 -718 -- -27 -. -08 -% -sherlock -: -: -quotes -541 -513 -( -1098 -MB -/ -s -) -531 -487 -( -1119 -MB -/ -s -) -- -10 -026 -- -1 -. -85 -% -sherlock -: -: -repeated_class_negation -5 -489 -721 -( -108 -MB -/ -s -) -85 -881 -944 -( -6 -MB -/ -s -) -80 -392 -223 -1464 -. -41 -% -sherlock -: -: -the_lower -680 -710 -( -873 -MB -/ -s -) -654 -110 -( -909 -MB -/ -s -) -- -26 -600 -- -3 -. -91 -% -sherlock -: -: -the_nocase -737 -040 -( -807 -MB -/ -s -) -474 -456 -( -1253 -MB -/ -s -) -- -262 -584 -- -35 -. -63 -% -sherlock -: -: -the_upper -50 -026 -( -11892 -MB -/ -s -) -43 -746 -( -13599 -MB -/ -s -) -- -6 -280 -- -12 -. -55 -% -sherlock -: -: -the_whitespace -885 -922 -( -671 -MB -/ -s -) -1 -181 -974 -( -503 -MB -/ -s -) -296 -052 -33 -. -42 -% -sherlock -: -: -word_ending_n -5 -424 -773 -( -109 -MB -/ -s -) -1 -925 -578 -( -308 -MB -/ -s -) -- -3 -499 -195 -- -64 -. -50 -% -sherlock -: -: -words -5 -753 -231 -( -103 -MB -/ -s -) -9 -697 -201 -( -61 -MB -/ -s -) -3 -943 -970 -68 -. -55 -% diff --git a/third_party/rust/regex/record/old-bench-log/05/re2 b/third_party/rust/regex/record/old-bench-log/05/re2 deleted file mode 100644 index 023b065910994..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/re2 +++ /dev/null @@ -1,2621 +0,0 @@ -running -96 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -102 -ns -/ -iter -( -+ -/ -- -3 -) -= -3823 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -19500 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -95 -ns -/ -iter -( -+ -/ -- -8 -) -= -273 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -1529 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -149 -ns -/ -iter -( -+ -/ -- -10 -) -= -7053 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -29 -234 -ns -/ -iter -( -+ -/ -- -886 -) -= -35869 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -126 -ns -/ -iter -( -+ -/ -- -4 -) -= -468 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -1 -266 -ns -/ -iter -( -+ -/ -- -42 -) -= -25904 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -130 -ns -/ -iter -( -+ -/ -- -4 -) -= -8030 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -29 -218 -ns -/ -iter -( -+ -/ -- -791 -) -= -35888 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -112 -ns -/ -iter -( -+ -/ -- -7 -) -= -464 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -1 -251 -ns -/ -iter -( -+ -/ -- -45 -) -= -26209 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -2 -357 -ns -/ -iter -( -+ -/ -- -33 -) -= -445 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -2 -149 -909 -ns -/ -iter -( -+ -/ -- -151 -258 -) -= -487 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -195 -ns -/ -iter -( -+ -/ -- -16 -) -= -302 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -105 -137 -ns -/ -iter -( -+ -/ -- -6 -252 -) -= -311 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -89 -ns -/ -iter -( -+ -/ -- -3 -) -= -573 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -170 -090 -ns -/ -iter -( -+ -/ -- -5 -891 -) -= -587 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -174 -341 -ns -/ -iter -( -+ -/ -- -7 -949 -) -= -573 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -220 -ns -/ -iter -( -+ -/ -- -16 -) -= -368 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -215 -ns -/ -iter -( -+ -/ -- -16 -) -= -376 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -382 -ns -/ -iter -( -+ -/ -- -27 -) -= -421 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -939 -ns -/ -iter -( -+ -/ -- -153 -) -= -542 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -1 -775 -335 -ns -/ -iter -( -+ -/ -- -91 -241 -) -= -590 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -190 -ns -/ -iter -( -+ -/ -- -12 -) -= -315 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -83 -245 -ns -/ -iter -( -+ -/ -- -5 -385 -) -= -393 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -269 -ns -/ -iter -( -+ -/ -- -22 -) -= -371 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -167 -ns -/ -iter -( -+ -/ -- -13 -) -= -305 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -84 -ns -/ -iter -( -+ -/ -- -7 -) -= -309 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -137 -ns -/ -iter -( -+ -/ -- -12 -) -= -189 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -108 -ns -/ -iter -( -+ -/ -- -3 -) -= -157 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -105 -ns -/ -iter -( -+ -/ -- -6 -) -= -161 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -1 -811 -ns -/ -iter -( -+ -/ -- -44 -) -= -574 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -2 -324 -ns -/ -iter -( -+ -/ -- -223 -) -= -452 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -2 -033 -298 -ns -/ -iter -( -+ -/ -- -148 -939 -) -= -515 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -185 -ns -/ -iter -( -+ -/ -- -8 -) -= -318 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -83 -263 -ns -/ -iter -( -+ -/ -- -4 -231 -) -= -393 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -13 -501 -ns -/ -iter -( -+ -/ -- -1 -380 -) -= -592 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -31 -464 -067 -ns -/ -iter -( -+ -/ -- -2 -248 -457 -) -= -161 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -5 -257 -629 -ns -/ -iter -( -+ -/ -- -142 -910 -) -= -966 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -5 -189 -384 -ns -/ -iter -( -+ -/ -- -130 -525 -) -= -979 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -5 -261 -936 -ns -/ -iter -( -+ -/ -- -309 -355 -) -= -966 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -5 -268 -281 -ns -/ -iter -( -+ -/ -- -348 -592 -) -= -964 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -5 -245 -664 -ns -/ -iter -( -+ -/ -- -403 -198 -) -= -969 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -5 -264 -833 -ns -/ -iter -( -+ -/ -- -312 -063 -) -= -965 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -5 -181 -850 -ns -/ -iter -( -+ -/ -- -117 -306 -) -= -981 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -5 -200 -226 -ns -/ -iter -( -+ -/ -- -124 -723 -) -= -977 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -5 -233 -678 -ns -/ -iter -( -+ -/ -- -367 -749 -) -= -971 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -5 -242 -400 -ns -/ -iter -( -+ -/ -- -317 -859 -) -= -969 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -5 -325 -464 -ns -/ -iter -( -+ -/ -- -395 -485 -) -= -954 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -24 -377 -246 -ns -/ -iter -( -+ -/ -- -733 -355 -) -= -208 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -26 -405 -686 -ns -/ -iter -( -+ -/ -- -771 -755 -) -= -192 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -25 -130 -419 -ns -/ -iter -( -+ -/ -- -1 -245 -527 -) -= -202 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -32 -527 -780 -ns -/ -iter -( -+ -/ -- -5 -073 -721 -) -= -156 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -31 -081 -800 -ns -/ -iter -( -+ -/ -- -1 -256 -796 -) -= -163 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -28 -744 -478 -ns -/ -iter -( -+ -/ -- -1 -243 -565 -) -= -176 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -26 -693 -756 -ns -/ -iter -( -+ -/ -- -886 -566 -) -= -190 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -21 -478 -184 -ns -/ -iter -( -+ -/ -- -1 -374 -415 -) -= -236 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -18 -639 -814 -ns -/ -iter -( -+ -/ -- -519 -136 -) -= -272 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -1 -552 -265 -ns -/ -iter -( -+ -/ -- -105 -467 -) -= -383 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -1 -360 -446 -ns -/ -iter -( -+ -/ -- -111 -123 -) -= -437 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -6 -356 -610 -ns -/ -iter -( -+ -/ -- -343 -163 -) -= -93 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -2 -380 -946 -ns -/ -iter -( -+ -/ -- -36 -936 -) -= -249 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -1 -144 -439 -ns -/ -iter -( -+ -/ -- -25 -948 -) -= -519 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -1 -503 -311 -ns -/ -iter -( -+ -/ -- -99 -075 -) -= -395 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -3 -003 -144 -ns -/ -iter -( -+ -/ -- -239 -408 -) -= -198 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -721 -656 -ns -/ -iter -( -+ -/ -- -129 -795 -) -= -345 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -73 -833 -131 -ns -/ -iter -( -+ -/ -- -2 -542 -107 -) -= -8 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -72 -250 -289 -ns -/ -iter -( -+ -/ -- -1 -280 -826 -) -= -8 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -3 -397 -481 -ns -/ -iter -( -+ -/ -- -160 -294 -) -= -175 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -3 -694 -486 -ns -/ -iter -( -+ -/ -- -403 -679 -) -= -161 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -70 -121 -ns -/ -iter -( -+ -/ -- -3 -926 -) -= -8484 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -1 -120 -245 -ns -/ -iter -( -+ -/ -- -36 -040 -) -= -531 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -247 -630 -ns -/ -iter -( -+ -/ -- -127 -226 -) -= -476 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -894 -586 -ns -/ -iter -( -+ -/ -- -201 -023 -) -= -205 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -1 -142 -872 -ns -/ -iter -( -+ -/ -- -82 -896 -) -= -520 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -785 -266 -ns -/ -iter -( -+ -/ -- -166 -100 -) -= -333 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -1 -167 -553 -ns -/ -iter -( -+ -/ -- -91 -672 -) -= -509 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -2 -023 -732 -ns -/ -iter -( -+ -/ -- -74 -558 -) -= -293 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -126 -480 -ns -/ -iter -( -+ -/ -- -6 -959 -) -= -4703 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -420 -548 -ns -/ -iter -( -+ -/ -- -75 -407 -) -= -418 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -57 -090 -ns -/ -iter -( -+ -/ -- -1 -392 -) -= -10420 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -57 -965 -ns -/ -iter -( -+ -/ -- -2 -996 -) -= -10263 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -837 -721 -ns -/ -iter -( -+ -/ -- -66 -965 -) -= -323 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -672 -451 -ns -/ -iter -( -+ -/ -- -204 -590 -) -= -355 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -60 -342 -ns -/ -iter -( -+ -/ -- -3 -290 -) -= -9859 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -434 -496 -ns -/ -iter -( -+ -/ -- -35 -617 -) -= -1369 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -431 -778 -ns -/ -iter -( -+ -/ -- -11 -799 -) -= -1377 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -19 -313 -ns -/ -iter -( -+ -/ -- -1 -167 -) -= -30804 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -1 -301 -485 -ns -/ -iter -( -+ -/ -- -92 -772 -) -= -457 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -846 -403 -ns -/ -iter -( -+ -/ -- -39 -799 -) -= -322 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -2 -956 -115 -ns -/ -iter -( -+ -/ -- -136 -011 -) -= -201 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -165 -976 -ns -/ -iter -( -+ -/ -- -5 -838 -) -= -3584 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -816 -669 -ns -/ -iter -( -+ -/ -- -117 -437 -) -= -327 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -2 -601 -847 -ns -/ -iter -( -+ -/ -- -166 -024 -) -= -228 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -21 -137 -049 -ns -/ -iter -( -+ -/ -- -750 -253 -) -= -28 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -96 -measured diff --git a/third_party/rust/regex/record/old-bench-log/05/re2-vs-rust b/third_party/rust/regex/record/old-bench-log/05/re2-vs-rust deleted file mode 100644 index f67b0c5cad247..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/re2-vs-rust +++ /dev/null @@ -1,2729 +0,0 @@ -name -re2 -ns -/ -iter -rust -ns -/ -iter -diff -ns -/ -iter -diff -% -misc -: -: -anchored_literal_long_match -102 -( -3823 -MB -/ -s -) -24 -( -16250 -MB -/ -s -) -- -78 -- -76 -. -47 -% -misc -: -: -anchored_literal_long_non_match -20 -( -19500 -MB -/ -s -) -27 -( -14444 -MB -/ -s -) -7 -35 -. -00 -% -misc -: -: -anchored_literal_short_match -95 -( -273 -MB -/ -s -) -22 -( -1181 -MB -/ -s -) -- -73 -- -76 -. -84 -% -misc -: -: -anchored_literal_short_non_match -17 -( -1529 -MB -/ -s -) -24 -( -1083 -MB -/ -s -) -7 -41 -. -18 -% -misc -: -: -easy0_1K -149 -( -7053 -MB -/ -s -) -16 -( -65687 -MB -/ -s -) -- -133 -- -89 -. -26 -% -misc -: -: -easy0_1MB -29 -234 -( -35869 -MB -/ -s -) -20 -( -52430150 -MB -/ -s -) -- -29 -214 -- -99 -. -93 -% -misc -: -: -easy0_32 -126 -( -468 -MB -/ -s -) -16 -( -3687 -MB -/ -s -) -- -110 -- -87 -. -30 -% -misc -: -: -easy0_32K -1 -266 -( -25904 -MB -/ -s -) -16 -( -2049687 -MB -/ -s -) -- -1 -250 -- -98 -. -74 -% -misc -: -: -easy1_1K -130 -( -8030 -MB -/ -s -) -48 -( -21750 -MB -/ -s -) -- -82 -- -63 -. -08 -% -misc -: -: -easy1_1MB -29 -218 -( -35888 -MB -/ -s -) -48 -( -21845750 -MB -/ -s -) -- -29 -170 -- -99 -. -84 -% -misc -: -: -easy1_32 -112 -( -464 -MB -/ -s -) -46 -( -1130 -MB -/ -s -) -- -66 -- -58 -. -93 -% -misc -: -: -easy1_32K -1 -251 -( -26209 -MB -/ -s -) -47 -( -697617 -MB -/ -s -) -- -1 -204 -- -96 -. -24 -% -misc -: -: -hard_1K -2 -357 -( -445 -MB -/ -s -) -58 -( -18120 -MB -/ -s -) -- -2 -299 -- -97 -. -54 -% -misc -: -: -hard_1MB -2 -149 -909 -( -487 -MB -/ -s -) -61 -( -17190213 -MB -/ -s -) -- -2 -149 -848 -- -100 -. -00 -% -misc -: -: -hard_32 -195 -( -302 -MB -/ -s -) -58 -( -1017 -MB -/ -s -) -- -137 -- -70 -. -26 -% -misc -: -: -hard_32K -105 -137 -( -311 -MB -/ -s -) -56 -( -585625 -MB -/ -s -) -- -105 -081 -- -99 -. -95 -% -misc -: -: -literal -89 -( -573 -MB -/ -s -) -16 -( -3187 -MB -/ -s -) -- -73 -- -82 -. -02 -% -misc -: -: -long_needle1 -170 -090 -( -587 -MB -/ -s -) -2 -226 -( -44924 -MB -/ -s -) -- -167 -864 -- -98 -. -69 -% -misc -: -: -long_needle2 -174 -341 -( -573 -MB -/ -s -) -576 -997 -( -173 -MB -/ -s -) -402 -656 -230 -. -96 -% -misc -: -: -match_class -220 -( -368 -MB -/ -s -) -65 -( -1246 -MB -/ -s -) -- -155 -- -70 -. -45 -% -misc -: -: -match_class_in_range -215 -( -376 -MB -/ -s -) -27 -( -3000 -MB -/ -s -) -- -188 -- -87 -. -44 -% -misc -: -: -match_class_unicode -382 -( -421 -MB -/ -s -) -283 -( -568 -MB -/ -s -) -- -99 -- -25 -. -92 -% -misc -: -: -medium_1K -1 -939 -( -542 -MB -/ -s -) -16 -( -65750 -MB -/ -s -) -- -1 -923 -- -99 -. -17 -% -misc -: -: -medium_1MB -1 -775 -335 -( -590 -MB -/ -s -) -21 -( -49933523 -MB -/ -s -) -- -1 -775 -314 -- -100 -. -00 -% -misc -: -: -medium_32 -190 -( -315 -MB -/ -s -) -17 -( -3529 -MB -/ -s -) -- -173 -- -91 -. -05 -% -misc -: -: -medium_32K -83 -245 -( -393 -MB -/ -s -) -17 -( -1929176 -MB -/ -s -) -- -83 -228 -- -99 -. -98 -% -misc -: -: -no_exponential -269 -( -371 -MB -/ -s -) -394 -( -253 -MB -/ -s -) -125 -46 -. -47 -% -misc -: -: -not_literal -167 -( -305 -MB -/ -s -) -105 -( -485 -MB -/ -s -) -- -62 -- -37 -. -13 -% -misc -: -: -one_pass_long_prefix -84 -( -309 -MB -/ -s -) -68 -( -382 -MB -/ -s -) -- -16 -- -19 -. -05 -% -misc -: -: -one_pass_long_prefix_not -137 -( -189 -MB -/ -s -) -58 -( -448 -MB -/ -s -) -- -79 -- -57 -. -66 -% -misc -: -: -one_pass_short -108 -( -157 -MB -/ -s -) -45 -( -377 -MB -/ -s -) -- -63 -- -58 -. -33 -% -misc -: -: -one_pass_short_not -105 -( -161 -MB -/ -s -) -50 -( -340 -MB -/ -s -) -- -55 -- -52 -. -38 -% -misc -: -: -reallyhard2_1K -1 -811 -( -574 -MB -/ -s -) -83 -( -12530 -MB -/ -s -) -- -1 -728 -- -95 -. -42 -% -misc -: -: -reallyhard_1K -2 -324 -( -452 -MB -/ -s -) -1 -822 -( -576 -MB -/ -s -) -- -502 -- -21 -. -60 -% -misc -: -: -reallyhard_1MB -2 -033 -298 -( -515 -MB -/ -s -) -1 -768 -327 -( -592 -MB -/ -s -) -- -264 -971 -- -13 -. -03 -% -misc -: -: -reallyhard_32 -185 -( -318 -MB -/ -s -) -121 -( -487 -MB -/ -s -) -- -64 -- -34 -. -59 -% -misc -: -: -reallyhard_32K -83 -263 -( -393 -MB -/ -s -) -56 -375 -( -581 -MB -/ -s -) -- -26 -888 -- -32 -. -29 -% -misc -: -: -reverse_suffix_no_quadratic -13 -501 -( -592 -MB -/ -s -) -5 -803 -( -1378 -MB -/ -s -) -- -7 -698 -- -57 -. -02 -% -regexdna -: -: -find_new_lines -31 -464 -067 -( -161 -MB -/ -s -) -14 -818 -233 -( -343 -MB -/ -s -) -- -16 -645 -834 -- -52 -. -90 -% -regexdna -: -: -subst1 -5 -257 -629 -( -966 -MB -/ -s -) -896 -790 -( -5668 -MB -/ -s -) -- -4 -360 -839 -- -82 -. -94 -% -regexdna -: -: -subst10 -5 -189 -384 -( -979 -MB -/ -s -) -957 -325 -( -5310 -MB -/ -s -) -- -4 -232 -059 -- -81 -. -55 -% -regexdna -: -: -subst11 -5 -261 -936 -( -966 -MB -/ -s -) -917 -248 -( -5542 -MB -/ -s -) -- -4 -344 -688 -- -82 -. -57 -% -regexdna -: -: -subst2 -5 -268 -281 -( -964 -MB -/ -s -) -892 -129 -( -5698 -MB -/ -s -) -- -4 -376 -152 -- -83 -. -07 -% -regexdna -: -: -subst3 -5 -245 -664 -( -969 -MB -/ -s -) -929 -250 -( -5470 -MB -/ -s -) -- -4 -316 -414 -- -82 -. -29 -% -regexdna -: -: -subst4 -5 -264 -833 -( -965 -MB -/ -s -) -872 -581 -( -5825 -MB -/ -s -) -- -4 -392 -252 -- -83 -. -43 -% -regexdna -: -: -subst5 -5 -181 -850 -( -981 -MB -/ -s -) -875 -804 -( -5804 -MB -/ -s -) -- -4 -306 -046 -- -83 -. -10 -% -regexdna -: -: -subst6 -5 -200 -226 -( -977 -MB -/ -s -) -884 -639 -( -5746 -MB -/ -s -) -- -4 -315 -587 -- -82 -. -99 -% -regexdna -: -: -subst7 -5 -233 -678 -( -971 -MB -/ -s -) -872 -791 -( -5824 -MB -/ -s -) -- -4 -360 -887 -- -83 -. -32 -% -regexdna -: -: -subst8 -5 -242 -400 -( -969 -MB -/ -s -) -873 -833 -( -5817 -MB -/ -s -) -- -4 -368 -567 -- -83 -. -33 -% -regexdna -: -: -subst9 -5 -325 -464 -( -954 -MB -/ -s -) -886 -744 -( -5732 -MB -/ -s -) -- -4 -438 -720 -- -83 -. -35 -% -regexdna -: -: -variant1 -24 -377 -246 -( -208 -MB -/ -s -) -3 -699 -267 -( -1374 -MB -/ -s -) -- -20 -677 -979 -- -84 -. -82 -% -regexdna -: -: -variant2 -26 -405 -686 -( -192 -MB -/ -s -) -6 -760 -952 -( -751 -MB -/ -s -) -- -19 -644 -734 -- -74 -. -40 -% -regexdna -: -: -variant3 -25 -130 -419 -( -202 -MB -/ -s -) -8 -030 -646 -( -633 -MB -/ -s -) -- -17 -099 -773 -- -68 -. -04 -% -regexdna -: -: -variant4 -32 -527 -780 -( -156 -MB -/ -s -) -8 -077 -290 -( -629 -MB -/ -s -) -- -24 -450 -490 -- -75 -. -17 -% -regexdna -: -: -variant5 -31 -081 -800 -( -163 -MB -/ -s -) -6 -787 -242 -( -748 -MB -/ -s -) -- -24 -294 -558 -- -78 -. -16 -% -regexdna -: -: -variant6 -28 -744 -478 -( -176 -MB -/ -s -) -6 -577 -777 -( -772 -MB -/ -s -) -- -22 -166 -701 -- -77 -. -12 -% -regexdna -: -: -variant7 -26 -693 -756 -( -190 -MB -/ -s -) -6 -705 -580 -( -758 -MB -/ -s -) -- -19 -988 -176 -- -74 -. -88 -% -regexdna -: -: -variant8 -21 -478 -184 -( -236 -MB -/ -s -) -6 -818 -785 -( -745 -MB -/ -s -) -- -14 -659 -399 -- -68 -. -25 -% -regexdna -: -: -variant9 -18 -639 -814 -( -272 -MB -/ -s -) -6 -821 -453 -( -745 -MB -/ -s -) -- -11 -818 -361 -- -63 -. -40 -% -sherlock -: -: -before_after_holmes -1 -552 -265 -( -383 -MB -/ -s -) -1 -029 -866 -( -577 -MB -/ -s -) -- -522 -399 -- -33 -. -65 -% -sherlock -: -: -before_holmes -1 -360 -446 -( -437 -MB -/ -s -) -76 -633 -( -7763 -MB -/ -s -) -- -1 -283 -813 -- -94 -. -37 -% -sherlock -: -: -everything_greedy -6 -356 -610 -( -93 -MB -/ -s -) -2 -375 -079 -( -250 -MB -/ -s -) -- -3 -981 -531 -- -62 -. -64 -% -sherlock -: -: -everything_greedy_nl -2 -380 -946 -( -249 -MB -/ -s -) -916 -250 -( -649 -MB -/ -s -) -- -1 -464 -696 -- -61 -. -52 -% -sherlock -: -: -holmes_cochar_watson -1 -144 -439 -( -519 -MB -/ -s -) -144 -725 -( -4110 -MB -/ -s -) -- -999 -714 -- -87 -. -35 -% -sherlock -: -: -holmes_coword_watson -1 -503 -311 -( -395 -MB -/ -s -) -565 -247 -( -1052 -MB -/ -s -) -- -938 -064 -- -62 -. -40 -% -sherlock -: -: -ing_suffix -3 -003 -144 -( -198 -MB -/ -s -) -436 -202 -( -1363 -MB -/ -s -) -- -2 -566 -942 -- -85 -. -48 -% -sherlock -: -: -ing_suffix_limited_space -1 -721 -656 -( -345 -MB -/ -s -) -1 -182 -943 -( -502 -MB -/ -s -) -- -538 -713 -- -31 -. -29 -% -sherlock -: -: -letters -73 -833 -131 -( -8 -MB -/ -s -) -24 -390 -452 -( -24 -MB -/ -s -) -- -49 -442 -679 -- -66 -. -97 -% -sherlock -: -: -letters_lower -72 -250 -289 -( -8 -MB -/ -s -) -23 -784 -108 -( -25 -MB -/ -s -) -- -48 -466 -181 -- -67 -. -08 -% -sherlock -: -: -letters_upper -3 -397 -481 -( -175 -MB -/ -s -) -1 -993 -838 -( -298 -MB -/ -s -) -- -1 -403 -643 -- -41 -. -31 -% -sherlock -: -: -line_boundary_sherlock_holmes -3 -694 -486 -( -161 -MB -/ -s -) -999 -414 -( -595 -MB -/ -s -) -- -2 -695 -072 -- -72 -. -95 -% -sherlock -: -: -name_alt1 -70 -121 -( -8484 -MB -/ -s -) -34 -298 -( -17345 -MB -/ -s -) -- -35 -823 -- -51 -. -09 -% -sherlock -: -: -name_alt2 -1 -120 -245 -( -531 -MB -/ -s -) -124 -226 -( -4789 -MB -/ -s -) -- -996 -019 -- -88 -. -91 -% -sherlock -: -: -name_alt3 -1 -247 -630 -( -476 -MB -/ -s -) -137 -742 -( -4319 -MB -/ -s -) -- -1 -109 -888 -- -88 -. -96 -% -sherlock -: -: -name_alt3_nocase -2 -894 -586 -( -205 -MB -/ -s -) -1 -293 -763 -( -459 -MB -/ -s -) -- -1 -600 -823 -- -55 -. -30 -% -sherlock -: -: -name_alt4 -1 -142 -872 -( -520 -MB -/ -s -) -164 -900 -( -3607 -MB -/ -s -) -- -977 -972 -- -85 -. -57 -% -sherlock -: -: -name_alt4_nocase -1 -785 -266 -( -333 -MB -/ -s -) -235 -023 -( -2531 -MB -/ -s -) -- -1 -550 -243 -- -86 -. -84 -% -sherlock -: -: -name_alt5 -1 -167 -553 -( -509 -MB -/ -s -) -127 -928 -( -4650 -MB -/ -s -) -- -1 -039 -625 -- -89 -. -04 -% -sherlock -: -: -name_alt5_nocase -2 -023 -732 -( -293 -MB -/ -s -) -659 -591 -( -901 -MB -/ -s -) -- -1 -364 -141 -- -67 -. -41 -% -sherlock -: -: -name_holmes -126 -480 -( -4703 -MB -/ -s -) -40 -902 -( -14545 -MB -/ -s -) -- -85 -578 -- -67 -. -66 -% -sherlock -: -: -name_holmes_nocase -1 -420 -548 -( -418 -MB -/ -s -) -198 -658 -( -2994 -MB -/ -s -) -- -1 -221 -890 -- -86 -. -02 -% -sherlock -: -: -name_sherlock -57 -090 -( -10420 -MB -/ -s -) -68 -924 -( -8631 -MB -/ -s -) -11 -834 -20 -. -73 -% -sherlock -: -: -name_sherlock_holmes -57 -965 -( -10263 -MB -/ -s -) -31 -640 -( -18803 -MB -/ -s -) -- -26 -325 -- -45 -. -42 -% -sherlock -: -: -name_sherlock_holmes_nocase -1 -837 -721 -( -323 -MB -/ -s -) -173 -522 -( -3428 -MB -/ -s -) -- -1 -664 -199 -- -90 -. -56 -% -sherlock -: -: -name_sherlock_nocase -1 -672 -451 -( -355 -MB -/ -s -) -170 -888 -( -3481 -MB -/ -s -) -- -1 -501 -563 -- -89 -. -78 -% -sherlock -: -: -name_whitespace -60 -342 -( -9859 -MB -/ -s -) -84 -314 -( -7056 -MB -/ -s -) -23 -972 -39 -. -73 -% -sherlock -: -: -no_match_common -434 -496 -( -1369 -MB -/ -s -) -20 -727 -( -28703 -MB -/ -s -) -- -413 -769 -- -95 -. -23 -% -sherlock -: -: -no_match_really_common -431 -778 -( -1377 -MB -/ -s -) -381 -476 -( -1559 -MB -/ -s -) -- -50 -302 -- -11 -. -65 -% -sherlock -: -: -no_match_uncommon -19 -313 -( -30804 -MB -/ -s -) -20 -786 -( -28621 -MB -/ -s -) -1 -473 -7 -. -63 -% -sherlock -: -: -quotes -1 -301 -485 -( -457 -MB -/ -s -) -531 -487 -( -1119 -MB -/ -s -) -- -769 -998 -- -59 -. -16 -% -sherlock -: -: -the_lower -1 -846 -403 -( -322 -MB -/ -s -) -654 -110 -( -909 -MB -/ -s -) -- -1 -192 -293 -- -64 -. -57 -% -sherlock -: -: -the_nocase -2 -956 -115 -( -201 -MB -/ -s -) -474 -456 -( -1253 -MB -/ -s -) -- -2 -481 -659 -- -83 -. -95 -% -sherlock -: -: -the_upper -165 -976 -( -3584 -MB -/ -s -) -43 -746 -( -13599 -MB -/ -s -) -- -122 -230 -- -73 -. -64 -% -sherlock -: -: -the_whitespace -1 -816 -669 -( -327 -MB -/ -s -) -1 -181 -974 -( -503 -MB -/ -s -) -- -634 -695 -- -34 -. -94 -% -sherlock -: -: -word_ending_n -2 -601 -847 -( -228 -MB -/ -s -) -1 -925 -578 -( -308 -MB -/ -s -) -- -676 -269 -- -25 -. -99 -% -sherlock -: -: -words -21 -137 -049 -( -28 -MB -/ -s -) -9 -697 -201 -( -61 -MB -/ -s -) -- -11 -439 -848 -- -54 -. -12 -% diff --git a/third_party/rust/regex/record/old-bench-log/05/rust b/third_party/rust/regex/record/old-bench-log/05/rust deleted file mode 100644 index dc281147ef15e..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/rust +++ /dev/null @@ -1,2607 +0,0 @@ -running -98 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -16250 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -27 -ns -/ -iter -( -+ -/ -- -0 -) -= -14444 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -1181 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -1 -) -= -1083 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -65687 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -52430150 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -3687 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -2049687 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -2 -) -= -21750 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -2 -) -= -21845750 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -0 -) -= -1130 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -47 -ns -/ -iter -( -+ -/ -- -0 -) -= -697617 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -0 -) -= -18120 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -0 -) -= -17190213 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -0 -) -= -1017 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -2 -) -= -585625 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -3187 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -2 -226 -ns -/ -iter -( -+ -/ -- -139 -) -= -44924 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -576 -997 -ns -/ -iter -( -+ -/ -- -21 -660 -) -= -173 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -65 -ns -/ -iter -( -+ -/ -- -3 -) -= -1246 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -27 -ns -/ -iter -( -+ -/ -- -0 -) -= -3000 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -283 -ns -/ -iter -( -+ -/ -- -15 -) -= -568 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -65750 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -1 -) -= -49933523 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -3529 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -1929176 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -394 -ns -/ -iter -( -+ -/ -- -0 -) -= -253 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -105 -ns -/ -iter -( -+ -/ -- -0 -) -= -485 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -68 -ns -/ -iter -( -+ -/ -- -0 -) -= -382 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -3 -) -= -448 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -45 -ns -/ -iter -( -+ -/ -- -2 -) -= -377 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -16 -) -= -340 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -83 -ns -/ -iter -( -+ -/ -- -4 -) -= -12530 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -822 -ns -/ -iter -( -+ -/ -- -72 -) -= -576 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -768 -327 -ns -/ -iter -( -+ -/ -- -67 -421 -) -= -592 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -121 -ns -/ -iter -( -+ -/ -- -4 -) -= -487 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -56 -375 -ns -/ -iter -( -+ -/ -- -1 -404 -) -= -581 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -142 -ns -/ -iter -( -+ -/ -- -0 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -5 -803 -ns -/ -iter -( -+ -/ -- -6 -) -= -1378 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -14 -818 -233 -ns -/ -iter -( -+ -/ -- -430 -454 -) -= -343 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -896 -790 -ns -/ -iter -( -+ -/ -- -2 -273 -) -= -5668 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -957 -325 -ns -/ -iter -( -+ -/ -- -7 -490 -) -= -5310 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -917 -248 -ns -/ -iter -( -+ -/ -- -12 -886 -) -= -5542 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -892 -129 -ns -/ -iter -( -+ -/ -- -36 -230 -) -= -5698 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -929 -250 -ns -/ -iter -( -+ -/ -- -38 -312 -) -= -5470 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -872 -581 -ns -/ -iter -( -+ -/ -- -27 -431 -) -= -5825 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -875 -804 -ns -/ -iter -( -+ -/ -- -30 -611 -) -= -5804 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -884 -639 -ns -/ -iter -( -+ -/ -- -44 -927 -) -= -5746 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -872 -791 -ns -/ -iter -( -+ -/ -- -31 -810 -) -= -5824 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -873 -833 -ns -/ -iter -( -+ -/ -- -37 -335 -) -= -5817 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -886 -744 -ns -/ -iter -( -+ -/ -- -42 -880 -) -= -5732 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -3 -699 -267 -ns -/ -iter -( -+ -/ -- -134 -945 -) -= -1374 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -6 -760 -952 -ns -/ -iter -( -+ -/ -- -228 -082 -) -= -751 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -8 -030 -646 -ns -/ -iter -( -+ -/ -- -271 -204 -) -= -633 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -8 -077 -290 -ns -/ -iter -( -+ -/ -- -266 -264 -) -= -629 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -6 -787 -242 -ns -/ -iter -( -+ -/ -- -226 -071 -) -= -748 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -6 -577 -777 -ns -/ -iter -( -+ -/ -- -226 -332 -) -= -772 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -6 -705 -580 -ns -/ -iter -( -+ -/ -- -232 -953 -) -= -758 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -6 -818 -785 -ns -/ -iter -( -+ -/ -- -241 -075 -) -= -745 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -6 -821 -453 -ns -/ -iter -( -+ -/ -- -257 -044 -) -= -745 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -1 -029 -866 -ns -/ -iter -( -+ -/ -- -42 -662 -) -= -577 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -76 -633 -ns -/ -iter -( -+ -/ -- -1 -135 -) -= -7763 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -375 -079 -ns -/ -iter -( -+ -/ -- -102 -532 -) -= -250 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -916 -250 -ns -/ -iter -( -+ -/ -- -37 -950 -) -= -649 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -144 -725 -ns -/ -iter -( -+ -/ -- -8 -793 -) -= -4110 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -565 -247 -ns -/ -iter -( -+ -/ -- -24 -056 -) -= -1052 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -436 -202 -ns -/ -iter -( -+ -/ -- -19 -863 -) -= -1363 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -182 -943 -ns -/ -iter -( -+ -/ -- -38 -658 -) -= -502 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -24 -390 -452 -ns -/ -iter -( -+ -/ -- -869 -008 -) -= -24 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -23 -784 -108 -ns -/ -iter -( -+ -/ -- -796 -195 -) -= -25 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -993 -838 -ns -/ -iter -( -+ -/ -- -77 -697 -) -= -298 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -999 -414 -ns -/ -iter -( -+ -/ -- -31 -202 -) -= -595 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -34 -298 -ns -/ -iter -( -+ -/ -- -1 -091 -) -= -17345 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -124 -226 -ns -/ -iter -( -+ -/ -- -5 -579 -) -= -4789 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -137 -742 -ns -/ -iter -( -+ -/ -- -6 -496 -) -= -4319 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -293 -763 -ns -/ -iter -( -+ -/ -- -51 -097 -) -= -459 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -164 -900 -ns -/ -iter -( -+ -/ -- -10 -023 -) -= -3607 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -235 -023 -ns -/ -iter -( -+ -/ -- -14 -465 -) -= -2531 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -127 -928 -ns -/ -iter -( -+ -/ -- -6 -882 -) -= -4650 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -659 -591 -ns -/ -iter -( -+ -/ -- -20 -587 -) -= -901 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -40 -902 -ns -/ -iter -( -+ -/ -- -402 -) -= -14545 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -198 -658 -ns -/ -iter -( -+ -/ -- -3 -782 -) -= -2994 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -68 -924 -ns -/ -iter -( -+ -/ -- -1 -456 -) -= -8631 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -31 -640 -ns -/ -iter -( -+ -/ -- -383 -) -= -18803 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -173 -522 -ns -/ -iter -( -+ -/ -- -7 -812 -) -= -3428 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -170 -888 -ns -/ -iter -( -+ -/ -- -612 -) -= -3481 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -84 -314 -ns -/ -iter -( -+ -/ -- -508 -) -= -7056 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -20 -727 -ns -/ -iter -( -+ -/ -- -565 -) -= -28703 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -381 -476 -ns -/ -iter -( -+ -/ -- -2 -338 -) -= -1559 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -20 -786 -ns -/ -iter -( -+ -/ -- -717 -) -= -28621 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -531 -487 -ns -/ -iter -( -+ -/ -- -5 -517 -) -= -1119 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -85 -881 -944 -ns -/ -iter -( -+ -/ -- -4 -906 -514 -) -= -6 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -654 -110 -ns -/ -iter -( -+ -/ -- -34 -542 -) -= -909 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -474 -456 -ns -/ -iter -( -+ -/ -- -16 -549 -) -= -1253 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -43 -746 -ns -/ -iter -( -+ -/ -- -579 -) -= -13599 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -181 -974 -ns -/ -iter -( -+ -/ -- -3 -005 -) -= -503 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -925 -578 -ns -/ -iter -( -+ -/ -- -3 -811 -) -= -308 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -9 -697 -201 -ns -/ -iter -( -+ -/ -- -156 -772 -) -= -61 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -98 -measured diff --git a/third_party/rust/regex/record/old-bench-log/05/tcl b/third_party/rust/regex/record/old-bench-log/05/tcl deleted file mode 100644 index 1b8cc457ea168..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/tcl +++ /dev/null @@ -1,2464 +0,0 @@ -running -89 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -662 -ns -/ -iter -( -+ -/ -- -12 -) -= -589 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -133 -ns -/ -iter -( -+ -/ -- -1 -) -= -2932 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -616 -ns -/ -iter -( -+ -/ -- -18 -) -= -42 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -122 -ns -/ -iter -( -+ -/ -- -1 -) -= -213 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -11 -816 -ns -/ -iter -( -+ -/ -- -92 -) -= -88 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -3 -409 -439 -ns -/ -iter -( -+ -/ -- -94 -972 -) -= -307 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -8 -785 -ns -/ -iter -( -+ -/ -- -183 -) -= -6 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -115 -371 -ns -/ -iter -( -+ -/ -- -2 -279 -) -= -284 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -7 -038 -ns -/ -iter -( -+ -/ -- -145 -) -= -148 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -3 -396 -028 -ns -/ -iter -( -+ -/ -- -100 -173 -) -= -308 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -3 -687 -ns -/ -iter -( -+ -/ -- -44 -) -= -14 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -109 -689 -ns -/ -iter -( -+ -/ -- -3 -757 -) -= -298 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -14 -836 -ns -/ -iter -( -+ -/ -- -518 -) -= -70 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -3 -376 -015 -ns -/ -iter -( -+ -/ -- -95 -045 -) -= -310 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -11 -278 -ns -/ -iter -( -+ -/ -- -389 -) -= -5 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -115 -400 -ns -/ -iter -( -+ -/ -- -4 -738 -) -= -284 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -511 -ns -/ -iter -( -+ -/ -- -11 -) -= -99 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -18 -076 -901 -ns -/ -iter -( -+ -/ -- -523 -761 -) -= -5 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -18 -497 -725 -ns -/ -iter -( -+ -/ -- -465 -516 -) -= -5 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -620 -ns -/ -iter -( -+ -/ -- -23 -) -= -130 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -605 -ns -/ -iter -( -+ -/ -- -26 -) -= -133 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -12 -355 -ns -/ -iter -( -+ -/ -- -390 -) -= -85 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -3 -410 -978 -ns -/ -iter -( -+ -/ -- -112 -021 -) -= -307 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -9 -086 -ns -/ -iter -( -+ -/ -- -287 -) -= -6 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -116 -944 -ns -/ -iter -( -+ -/ -- -5 -654 -) -= -280 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -2 -379 -518 -ns -/ -iter -( -+ -/ -- -92 -628 -) -test -misc -: -: -not_literal -. -. -. -bench -: -1 -979 -ns -/ -iter -( -+ -/ -- -116 -) -= -25 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -6 -932 -ns -/ -iter -( -+ -/ -- -464 -) -= -3 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -6 -242 -ns -/ -iter -( -+ -/ -- -384 -) -= -4 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -630 -ns -/ -iter -( -+ -/ -- -42 -) -= -26 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -718 -ns -/ -iter -( -+ -/ -- -64 -) -= -23 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -108 -421 -ns -/ -iter -( -+ -/ -- -6 -489 -) -= -9 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -14 -330 -ns -/ -iter -( -+ -/ -- -814 -) -= -73 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -3 -287 -965 -ns -/ -iter -( -+ -/ -- -203 -546 -) -= -318 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -11 -193 -ns -/ -iter -( -+ -/ -- -683 -) -= -5 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -112 -731 -ns -/ -iter -( -+ -/ -- -5 -966 -) -= -290 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -26 -907 -ns -/ -iter -( -+ -/ -- -2 -396 -) -= -297 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -48 -223 -361 -ns -/ -iter -( -+ -/ -- -2 -855 -654 -) -= -105 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -27 -177 -359 -ns -/ -iter -( -+ -/ -- -1 -359 -987 -) -= -187 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -26 -722 -144 -ns -/ -iter -( -+ -/ -- -1 -090 -216 -) -= -190 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -27 -382 -875 -ns -/ -iter -( -+ -/ -- -1 -656 -754 -) -= -185 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -26 -957 -766 -ns -/ -iter -( -+ -/ -- -1 -433 -630 -) -= -188 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -27 -195 -925 -ns -/ -iter -( -+ -/ -- -1 -828 -460 -) -= -186 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -26 -342 -249 -ns -/ -iter -( -+ -/ -- -1 -949 -172 -) -= -192 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -26 -543 -675 -ns -/ -iter -( -+ -/ -- -2 -143 -336 -) -= -191 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -26 -185 -452 -ns -/ -iter -( -+ -/ -- -2 -199 -220 -) -= -194 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -26 -338 -573 -ns -/ -iter -( -+ -/ -- -2 -124 -778 -) -= -193 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -26 -468 -652 -ns -/ -iter -( -+ -/ -- -1 -923 -567 -) -= -192 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -26 -487 -784 -ns -/ -iter -( -+ -/ -- -1 -250 -319 -) -= -191 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -16 -325 -983 -ns -/ -iter -( -+ -/ -- -491 -000 -) -= -311 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -16 -845 -952 -ns -/ -iter -( -+ -/ -- -470 -062 -) -= -301 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -19 -258 -030 -ns -/ -iter -( -+ -/ -- -525 -045 -) -= -263 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -18 -018 -713 -ns -/ -iter -( -+ -/ -- -1 -235 -670 -) -= -282 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -19 -583 -528 -ns -/ -iter -( -+ -/ -- -1 -756 -762 -) -= -259 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -17 -630 -308 -ns -/ -iter -( -+ -/ -- -973 -191 -) -= -288 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -17 -121 -666 -ns -/ -iter -( -+ -/ -- -1 -274 -478 -) -= -296 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -17 -154 -863 -ns -/ -iter -( -+ -/ -- -425 -504 -) -= -296 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -17 -930 -482 -ns -/ -iter -( -+ -/ -- -587 -712 -) -= -283 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -2 -600 -503 -ns -/ -iter -( -+ -/ -- -383 -440 -) -= -228 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -3 -145 -648 -ns -/ -iter -( -+ -/ -- -37 -316 -) -= -189 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -2 -668 -355 -ns -/ -iter -( -+ -/ -- -193 -724 -) -= -222 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -5 -638 -296 -ns -/ -iter -( -+ -/ -- -69 -345 -) -= -105 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -22 -466 -946 -ns -/ -iter -( -+ -/ -- -659 -956 -) -= -26 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -251 -996 -ns -/ -iter -( -+ -/ -- -66 -639 -) -= -264 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -2 -276 -056 -ns -/ -iter -( -+ -/ -- -64 -088 -) -= -261 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -3 -196 -348 -ns -/ -iter -( -+ -/ -- -202 -979 -) -= -186 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -5 -260 -374 -ns -/ -iter -( -+ -/ -- -426 -028 -) -= -113 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -8 -529 -394 -ns -/ -iter -( -+ -/ -- -558 -731 -) -= -69 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -2 -787 -972 -ns -/ -iter -( -+ -/ -- -153 -839 -) -= -213 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -3 -370 -452 -ns -/ -iter -( -+ -/ -- -140 -385 -) -= -176 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -3 -795 -793 -ns -/ -iter -( -+ -/ -- -182 -240 -) -= -156 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -4 -691 -422 -ns -/ -iter -( -+ -/ -- -161 -515 -) -= -126 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -2 -513 -139 -ns -/ -iter -( -+ -/ -- -72 -157 -) -= -236 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -2 -636 -441 -ns -/ -iter -( -+ -/ -- -78 -402 -) -= -225 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -2 -015 -753 -ns -/ -iter -( -+ -/ -- -104 -000 -) -= -295 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -2 -180 -684 -ns -/ -iter -( -+ -/ -- -162 -201 -) -= -272 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -2 -306 -664 -ns -/ -iter -( -+ -/ -- -165 -960 -) -= -257 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -2 -065 -630 -ns -/ -iter -( -+ -/ -- -155 -223 -) -= -288 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -2 -266 -188 -ns -/ -iter -( -+ -/ -- -173 -380 -) -= -262 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -1 -881 -887 -ns -/ -iter -( -+ -/ -- -123 -883 -) -= -316 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -1 -804 -352 -ns -/ -iter -( -+ -/ -- -33 -396 -) -= -329 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -1 -809 -300 -ns -/ -iter -( -+ -/ -- -123 -888 -) -= -328 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -9 -682 -507 -ns -/ -iter -( -+ -/ -- -1 -200 -909 -) -= -61 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -68 -600 -251 -ns -/ -iter -( -+ -/ -- -2 -043 -582 -) -= -8 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -6 -849 -558 -ns -/ -iter -( -+ -/ -- -517 -709 -) -= -86 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -7 -354 -742 -ns -/ -iter -( -+ -/ -- -390 -834 -) -= -80 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -2 -442 -364 -ns -/ -iter -( -+ -/ -- -174 -452 -) -= -243 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -9 -210 -338 -ns -/ -iter -( -+ -/ -- -651 -675 -) -= -64 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -47 -863 -652 -ns -/ -iter -( -+ -/ -- -3 -536 -998 -) -= -12 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -89 -measured diff --git a/third_party/rust/regex/record/old-bench-log/05/tcl-vs-rust b/third_party/rust/regex/record/old-bench-log/05/tcl-vs-rust deleted file mode 100644 index d64d6ea3304d2..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/05/tcl-vs-rust +++ /dev/null @@ -1,2587 +0,0 @@ -name -tcl -ns -/ -iter -rust -ns -/ -iter -diff -ns -/ -iter -diff -% -misc -: -: -anchored_literal_long_match -662 -( -589 -MB -/ -s -) -24 -( -16250 -MB -/ -s -) -- -638 -- -96 -. -37 -% -misc -: -: -anchored_literal_long_non_match -133 -( -2932 -MB -/ -s -) -27 -( -14444 -MB -/ -s -) -- -106 -- -79 -. -70 -% -misc -: -: -anchored_literal_short_match -616 -( -42 -MB -/ -s -) -22 -( -1181 -MB -/ -s -) -- -594 -- -96 -. -43 -% -misc -: -: -anchored_literal_short_non_match -122 -( -213 -MB -/ -s -) -24 -( -1083 -MB -/ -s -) -- -98 -- -80 -. -33 -% -misc -: -: -easy0_1K -11 -816 -( -88 -MB -/ -s -) -16 -( -65687 -MB -/ -s -) -- -11 -800 -- -99 -. -86 -% -misc -: -: -easy0_1MB -3 -409 -439 -( -307 -MB -/ -s -) -20 -( -52430150 -MB -/ -s -) -- -3 -409 -419 -- -100 -. -00 -% -misc -: -: -easy0_32 -8 -785 -( -6 -MB -/ -s -) -16 -( -3687 -MB -/ -s -) -- -8 -769 -- -99 -. -82 -% -misc -: -: -easy0_32K -115 -371 -( -284 -MB -/ -s -) -16 -( -2049687 -MB -/ -s -) -- -115 -355 -- -99 -. -99 -% -misc -: -: -easy1_1K -7 -038 -( -148 -MB -/ -s -) -48 -( -21750 -MB -/ -s -) -- -6 -990 -- -99 -. -32 -% -misc -: -: -easy1_1MB -3 -396 -028 -( -308 -MB -/ -s -) -48 -( -21845750 -MB -/ -s -) -- -3 -395 -980 -- -100 -. -00 -% -misc -: -: -easy1_32 -3 -687 -( -14 -MB -/ -s -) -46 -( -1130 -MB -/ -s -) -- -3 -641 -- -98 -. -75 -% -misc -: -: -easy1_32K -109 -689 -( -298 -MB -/ -s -) -47 -( -697617 -MB -/ -s -) -- -109 -642 -- -99 -. -96 -% -misc -: -: -hard_1K -14 -836 -( -70 -MB -/ -s -) -58 -( -18120 -MB -/ -s -) -- -14 -778 -- -99 -. -61 -% -misc -: -: -hard_1MB -3 -376 -015 -( -310 -MB -/ -s -) -61 -( -17190213 -MB -/ -s -) -- -3 -375 -954 -- -100 -. -00 -% -misc -: -: -hard_32 -11 -278 -( -5 -MB -/ -s -) -58 -( -1017 -MB -/ -s -) -- -11 -220 -- -99 -. -49 -% -misc -: -: -hard_32K -115 -400 -( -284 -MB -/ -s -) -56 -( -585625 -MB -/ -s -) -- -115 -344 -- -99 -. -95 -% -misc -: -: -literal -511 -( -99 -MB -/ -s -) -16 -( -3187 -MB -/ -s -) -- -495 -- -96 -. -87 -% -misc -: -: -long_needle1 -18 -076 -901 -( -5 -MB -/ -s -) -2 -226 -( -44924 -MB -/ -s -) -- -18 -074 -675 -- -99 -. -99 -% -misc -: -: -long_needle2 -18 -497 -725 -( -5 -MB -/ -s -) -576 -997 -( -173 -MB -/ -s -) -- -17 -920 -728 -- -96 -. -88 -% -misc -: -: -match_class -620 -( -130 -MB -/ -s -) -65 -( -1246 -MB -/ -s -) -- -555 -- -89 -. -52 -% -misc -: -: -match_class_in_range -605 -( -133 -MB -/ -s -) -27 -( -3000 -MB -/ -s -) -- -578 -- -95 -. -54 -% -misc -: -: -medium_1K -12 -355 -( -85 -MB -/ -s -) -16 -( -65750 -MB -/ -s -) -- -12 -339 -- -99 -. -87 -% -misc -: -: -medium_1MB -3 -410 -978 -( -307 -MB -/ -s -) -21 -( -49933523 -MB -/ -s -) -- -3 -410 -957 -- -100 -. -00 -% -misc -: -: -medium_32 -9 -086 -( -6 -MB -/ -s -) -17 -( -3529 -MB -/ -s -) -- -9 -069 -- -99 -. -81 -% -misc -: -: -medium_32K -116 -944 -( -280 -MB -/ -s -) -17 -( -1929176 -MB -/ -s -) -- -116 -927 -- -99 -. -99 -% -misc -: -: -no_exponential -2 -379 -518 -394 -( -253 -MB -/ -s -) -- -2 -379 -124 -- -99 -. -98 -% -misc -: -: -not_literal -1 -979 -( -25 -MB -/ -s -) -105 -( -485 -MB -/ -s -) -- -1 -874 -- -94 -. -69 -% -misc -: -: -one_pass_long_prefix -6 -932 -( -3 -MB -/ -s -) -68 -( -382 -MB -/ -s -) -- -6 -864 -- -99 -. -02 -% -misc -: -: -one_pass_long_prefix_not -6 -242 -( -4 -MB -/ -s -) -58 -( -448 -MB -/ -s -) -- -6 -184 -- -99 -. -07 -% -misc -: -: -one_pass_short -630 -( -26 -MB -/ -s -) -45 -( -377 -MB -/ -s -) -- -585 -- -92 -. -86 -% -misc -: -: -one_pass_short_not -718 -( -23 -MB -/ -s -) -50 -( -340 -MB -/ -s -) -- -668 -- -93 -. -04 -% -misc -: -: -reallyhard2_1K -108 -421 -( -9 -MB -/ -s -) -83 -( -12530 -MB -/ -s -) -- -108 -338 -- -99 -. -92 -% -misc -: -: -reallyhard_1K -14 -330 -( -73 -MB -/ -s -) -1 -822 -( -576 -MB -/ -s -) -- -12 -508 -- -87 -. -29 -% -misc -: -: -reallyhard_1MB -3 -287 -965 -( -318 -MB -/ -s -) -1 -768 -327 -( -592 -MB -/ -s -) -- -1 -519 -638 -- -46 -. -22 -% -misc -: -: -reallyhard_32 -11 -193 -( -5 -MB -/ -s -) -121 -( -487 -MB -/ -s -) -- -11 -072 -- -98 -. -92 -% -misc -: -: -reallyhard_32K -112 -731 -( -290 -MB -/ -s -) -56 -375 -( -581 -MB -/ -s -) -- -56 -356 -- -49 -. -99 -% -misc -: -: -reverse_suffix_no_quadratic -26 -907 -( -297 -MB -/ -s -) -5 -803 -( -1378 -MB -/ -s -) -- -21 -104 -- -78 -. -43 -% -regexdna -: -: -find_new_lines -48 -223 -361 -( -105 -MB -/ -s -) -14 -818 -233 -( -343 -MB -/ -s -) -- -33 -405 -128 -- -69 -. -27 -% -regexdna -: -: -subst1 -27 -177 -359 -( -187 -MB -/ -s -) -896 -790 -( -5668 -MB -/ -s -) -- -26 -280 -569 -- -96 -. -70 -% -regexdna -: -: -subst10 -26 -722 -144 -( -190 -MB -/ -s -) -957 -325 -( -5310 -MB -/ -s -) -- -25 -764 -819 -- -96 -. -42 -% -regexdna -: -: -subst11 -27 -382 -875 -( -185 -MB -/ -s -) -917 -248 -( -5542 -MB -/ -s -) -- -26 -465 -627 -- -96 -. -65 -% -regexdna -: -: -subst2 -26 -957 -766 -( -188 -MB -/ -s -) -892 -129 -( -5698 -MB -/ -s -) -- -26 -065 -637 -- -96 -. -69 -% -regexdna -: -: -subst3 -27 -195 -925 -( -186 -MB -/ -s -) -929 -250 -( -5470 -MB -/ -s -) -- -26 -266 -675 -- -96 -. -58 -% -regexdna -: -: -subst4 -26 -342 -249 -( -192 -MB -/ -s -) -872 -581 -( -5825 -MB -/ -s -) -- -25 -469 -668 -- -96 -. -69 -% -regexdna -: -: -subst5 -26 -543 -675 -( -191 -MB -/ -s -) -875 -804 -( -5804 -MB -/ -s -) -- -25 -667 -871 -- -96 -. -70 -% -regexdna -: -: -subst6 -26 -185 -452 -( -194 -MB -/ -s -) -884 -639 -( -5746 -MB -/ -s -) -- -25 -300 -813 -- -96 -. -62 -% -regexdna -: -: -subst7 -26 -338 -573 -( -193 -MB -/ -s -) -872 -791 -( -5824 -MB -/ -s -) -- -25 -465 -782 -- -96 -. -69 -% -regexdna -: -: -subst8 -26 -468 -652 -( -192 -MB -/ -s -) -873 -833 -( -5817 -MB -/ -s -) -- -25 -594 -819 -- -96 -. -70 -% -regexdna -: -: -subst9 -26 -487 -784 -( -191 -MB -/ -s -) -886 -744 -( -5732 -MB -/ -s -) -- -25 -601 -040 -- -96 -. -65 -% -regexdna -: -: -variant1 -16 -325 -983 -( -311 -MB -/ -s -) -3 -699 -267 -( -1374 -MB -/ -s -) -- -12 -626 -716 -- -77 -. -34 -% -regexdna -: -: -variant2 -16 -845 -952 -( -301 -MB -/ -s -) -6 -760 -952 -( -751 -MB -/ -s -) -- -10 -085 -000 -- -59 -. -87 -% -regexdna -: -: -variant3 -19 -258 -030 -( -263 -MB -/ -s -) -8 -030 -646 -( -633 -MB -/ -s -) -- -11 -227 -384 -- -58 -. -30 -% -regexdna -: -: -variant4 -18 -018 -713 -( -282 -MB -/ -s -) -8 -077 -290 -( -629 -MB -/ -s -) -- -9 -941 -423 -- -55 -. -17 -% -regexdna -: -: -variant5 -19 -583 -528 -( -259 -MB -/ -s -) -6 -787 -242 -( -748 -MB -/ -s -) -- -12 -796 -286 -- -65 -. -34 -% -regexdna -: -: -variant6 -17 -630 -308 -( -288 -MB -/ -s -) -6 -577 -777 -( -772 -MB -/ -s -) -- -11 -052 -531 -- -62 -. -69 -% -regexdna -: -: -variant7 -17 -121 -666 -( -296 -MB -/ -s -) -6 -705 -580 -( -758 -MB -/ -s -) -- -10 -416 -086 -- -60 -. -84 -% -regexdna -: -: -variant8 -17 -154 -863 -( -296 -MB -/ -s -) -6 -818 -785 -( -745 -MB -/ -s -) -- -10 -336 -078 -- -60 -. -25 -% -regexdna -: -: -variant9 -17 -930 -482 -( -283 -MB -/ -s -) -6 -821 -453 -( -745 -MB -/ -s -) -- -11 -109 -029 -- -61 -. -96 -% -sherlock -: -: -before_after_holmes -2 -600 -503 -( -228 -MB -/ -s -) -1 -029 -866 -( -577 -MB -/ -s -) -- -1 -570 -637 -- -60 -. -40 -% -sherlock -: -: -before_holmes -3 -145 -648 -( -189 -MB -/ -s -) -76 -633 -( -7763 -MB -/ -s -) -- -3 -069 -015 -- -97 -. -56 -% -sherlock -: -: -holmes_cochar_watson -2 -668 -355 -( -222 -MB -/ -s -) -144 -725 -( -4110 -MB -/ -s -) -- -2 -523 -630 -- -94 -. -58 -% -sherlock -: -: -ing_suffix -5 -638 -296 -( -105 -MB -/ -s -) -436 -202 -( -1363 -MB -/ -s -) -- -5 -202 -094 -- -92 -. -26 -% -sherlock -: -: -ing_suffix_limited_space -22 -466 -946 -( -26 -MB -/ -s -) -1 -182 -943 -( -502 -MB -/ -s -) -- -21 -284 -003 -- -94 -. -73 -% -sherlock -: -: -line_boundary_sherlock_holmes -2 -251 -996 -( -264 -MB -/ -s -) -999 -414 -( -595 -MB -/ -s -) -- -1 -252 -582 -- -55 -. -62 -% -sherlock -: -: -name_alt1 -2 -276 -056 -( -261 -MB -/ -s -) -34 -298 -( -17345 -MB -/ -s -) -- -2 -241 -758 -- -98 -. -49 -% -sherlock -: -: -name_alt2 -3 -196 -348 -( -186 -MB -/ -s -) -124 -226 -( -4789 -MB -/ -s -) -- -3 -072 -122 -- -96 -. -11 -% -sherlock -: -: -name_alt3 -5 -260 -374 -( -113 -MB -/ -s -) -137 -742 -( -4319 -MB -/ -s -) -- -5 -122 -632 -- -97 -. -38 -% -sherlock -: -: -name_alt3_nocase -8 -529 -394 -( -69 -MB -/ -s -) -1 -293 -763 -( -459 -MB -/ -s -) -- -7 -235 -631 -- -84 -. -83 -% -sherlock -: -: -name_alt4 -2 -787 -972 -( -213 -MB -/ -s -) -164 -900 -( -3607 -MB -/ -s -) -- -2 -623 -072 -- -94 -. -09 -% -sherlock -: -: -name_alt4_nocase -3 -370 -452 -( -176 -MB -/ -s -) -235 -023 -( -2531 -MB -/ -s -) -- -3 -135 -429 -- -93 -. -03 -% -sherlock -: -: -name_alt5 -3 -795 -793 -( -156 -MB -/ -s -) -127 -928 -( -4650 -MB -/ -s -) -- -3 -667 -865 -- -96 -. -63 -% -sherlock -: -: -name_alt5_nocase -4 -691 -422 -( -126 -MB -/ -s -) -659 -591 -( -901 -MB -/ -s -) -- -4 -031 -831 -- -85 -. -94 -% -sherlock -: -: -name_holmes -2 -513 -139 -( -236 -MB -/ -s -) -40 -902 -( -14545 -MB -/ -s -) -- -2 -472 -237 -- -98 -. -37 -% -sherlock -: -: -name_holmes_nocase -2 -636 -441 -( -225 -MB -/ -s -) -198 -658 -( -2994 -MB -/ -s -) -- -2 -437 -783 -- -92 -. -46 -% -sherlock -: -: -name_sherlock -2 -015 -753 -( -295 -MB -/ -s -) -68 -924 -( -8631 -MB -/ -s -) -- -1 -946 -829 -- -96 -. -58 -% -sherlock -: -: -name_sherlock_holmes -2 -180 -684 -( -272 -MB -/ -s -) -31 -640 -( -18803 -MB -/ -s -) -- -2 -149 -044 -- -98 -. -55 -% -sherlock -: -: -name_sherlock_holmes_nocase -2 -306 -664 -( -257 -MB -/ -s -) -173 -522 -( -3428 -MB -/ -s -) -- -2 -133 -142 -- -92 -. -48 -% -sherlock -: -: -name_sherlock_nocase -2 -065 -630 -( -288 -MB -/ -s -) -170 -888 -( -3481 -MB -/ -s -) -- -1 -894 -742 -- -91 -. -73 -% -sherlock -: -: -name_whitespace -2 -266 -188 -( -262 -MB -/ -s -) -84 -314 -( -7056 -MB -/ -s -) -- -2 -181 -874 -- -96 -. -28 -% -sherlock -: -: -no_match_common -1 -881 -887 -( -316 -MB -/ -s -) -20 -727 -( -28703 -MB -/ -s -) -- -1 -861 -160 -- -98 -. -90 -% -sherlock -: -: -no_match_really_common -1 -804 -352 -( -329 -MB -/ -s -) -381 -476 -( -1559 -MB -/ -s -) -- -1 -422 -876 -- -78 -. -86 -% -sherlock -: -: -no_match_uncommon -1 -809 -300 -( -328 -MB -/ -s -) -20 -786 -( -28621 -MB -/ -s -) -- -1 -788 -514 -- -98 -. -85 -% -sherlock -: -: -quotes -9 -682 -507 -( -61 -MB -/ -s -) -531 -487 -( -1119 -MB -/ -s -) -- -9 -151 -020 -- -94 -. -51 -% -sherlock -: -: -repeated_class_negation -68 -600 -251 -( -8 -MB -/ -s -) -85 -881 -944 -( -6 -MB -/ -s -) -17 -281 -693 -25 -. -19 -% -sherlock -: -: -the_lower -6 -849 -558 -( -86 -MB -/ -s -) -654 -110 -( -909 -MB -/ -s -) -- -6 -195 -448 -- -90 -. -45 -% -sherlock -: -: -the_nocase -7 -354 -742 -( -80 -MB -/ -s -) -474 -456 -( -1253 -MB -/ -s -) -- -6 -880 -286 -- -93 -. -55 -% -sherlock -: -: -the_upper -2 -442 -364 -( -243 -MB -/ -s -) -43 -746 -( -13599 -MB -/ -s -) -- -2 -398 -618 -- -98 -. -21 -% -sherlock -: -: -the_whitespace -9 -210 -338 -( -64 -MB -/ -s -) -1 -181 -974 -( -503 -MB -/ -s -) -- -8 -028 -364 -- -87 -. -17 -% -sherlock -: -: -words -47 -863 -652 -( -12 -MB -/ -s -) -9 -697 -201 -( -61 -MB -/ -s -) -- -38 -166 -451 -- -79 -. -74 -% diff --git a/third_party/rust/regex/record/old-bench-log/06/dphobos-dmd b/third_party/rust/regex/record/old-bench-log/06/dphobos-dmd deleted file mode 100644 index 0037056561737..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/06/dphobos-dmd +++ /dev/null @@ -1,2597 +0,0 @@ -running -95 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -356 -ns -/ -iter -( -+ -/ -- -4 -) -= -1095 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -280 -ns -/ -iter -( -+ -/ -- -18 -) -= -1392 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -351 -ns -/ -iter -( -+ -/ -- -16 -) -= -74 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -274 -ns -/ -iter -( -+ -/ -- -17 -) -= -94 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -810 -ns -/ -iter -( -+ -/ -- -38 -) -= -1297 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -25 -296 -ns -/ -iter -( -+ -/ -- -3 -592 -) -= -41453 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -745 -ns -/ -iter -( -+ -/ -- -60 -) -= -79 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -1 -111 -ns -/ -iter -( -+ -/ -- -82 -) -= -29518 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -730 -ns -/ -iter -( -+ -/ -- -20 -) -= -1430 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -25 -442 -ns -/ -iter -( -+ -/ -- -2 -076 -) -= -41215 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -730 -ns -/ -iter -( -+ -/ -- -79 -) -= -71 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -1 -104 -ns -/ -iter -( -+ -/ -- -93 -) -= -29699 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -18 -238 -ns -/ -iter -( -+ -/ -- -1 -173 -) -= -57 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -19 -302 -344 -ns -/ -iter -( -+ -/ -- -2 -039 -538 -) -= -54 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -2 -508 -ns -/ -iter -( -+ -/ -- -119 -) -= -23 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -666 -948 -ns -/ -iter -( -+ -/ -- -58 -067 -) -= -49 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -196 -ns -/ -iter -( -+ -/ -- -17 -) -= -260 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -82 -532 -ns -/ -iter -( -+ -/ -- -4 -618 -) -= -1211 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -84 -079 -ns -/ -iter -( -+ -/ -- -5 -930 -) -= -1189 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -300 -ns -/ -iter -( -+ -/ -- -41 -) -= -270 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -258 -ns -/ -iter -( -+ -/ -- -16 -) -= -313 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -563 -ns -/ -iter -( -+ -/ -- -171 -) -= -103 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -541 -ns -/ -iter -( -+ -/ -- -127 -) -= -682 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -617 -650 -ns -/ -iter -( -+ -/ -- -59 -618 -) -= -1697 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -985 -ns -/ -iter -( -+ -/ -- -62 -) -= -60 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -19 -948 -ns -/ -iter -( -+ -/ -- -1 -388 -) -= -1644 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -430 -777 -ns -/ -iter -( -+ -/ -- -52 -435 -) -test -misc -: -: -not_literal -. -. -. -bench -: -1 -202 -ns -/ -iter -( -+ -/ -- -60 -) -= -42 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -630 -ns -/ -iter -( -+ -/ -- -45 -) -= -41 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -617 -ns -/ -iter -( -+ -/ -- -60 -) -= -42 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -1 -102 -ns -/ -iter -( -+ -/ -- -38 -) -= -15 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -1 -481 -ns -/ -iter -( -+ -/ -- -44 -) -= -11 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -40 -749 -ns -/ -iter -( -+ -/ -- -2 -027 -) -= -25 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -18 -987 -ns -/ -iter -( -+ -/ -- -1 -419 -) -= -55 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -19 -923 -786 -ns -/ -iter -( -+ -/ -- -1 -499 -750 -) -= -52 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -2 -369 -ns -/ -iter -( -+ -/ -- -115 -) -= -24 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -627 -664 -ns -/ -iter -( -+ -/ -- -30 -507 -) -= -52 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -933 -ns -/ -iter -( -+ -/ -- -700 -) -= -1621 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -28 -886 -666 -ns -/ -iter -( -+ -/ -- -1 -969 -669 -) -= -175 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -6 -722 -884 -ns -/ -iter -( -+ -/ -- -431 -722 -) -= -756 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -6 -923 -833 -ns -/ -iter -( -+ -/ -- -677 -840 -) -= -734 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -6 -917 -738 -ns -/ -iter -( -+ -/ -- -306 -829 -) -= -734 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -6 -914 -593 -ns -/ -iter -( -+ -/ -- -625 -342 -) -= -735 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -6 -582 -793 -ns -/ -iter -( -+ -/ -- -297 -052 -) -= -772 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -6 -528 -804 -ns -/ -iter -( -+ -/ -- -463 -331 -) -= -778 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -6 -886 -457 -ns -/ -iter -( -+ -/ -- -1 -015 -943 -) -= -738 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -6 -789 -493 -ns -/ -iter -( -+ -/ -- -573 -137 -) -= -748 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -6 -533 -609 -ns -/ -iter -( -+ -/ -- -372 -293 -) -= -778 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -6 -536 -845 -ns -/ -iter -( -+ -/ -- -290 -249 -) -= -777 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -6 -509 -834 -ns -/ -iter -( -+ -/ -- -402 -426 -) -= -780 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -5 -746 -639 -ns -/ -iter -( -+ -/ -- -205 -103 -) -= -884 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -7 -661 -372 -ns -/ -iter -( -+ -/ -- -145 -811 -) -= -663 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -12 -801 -668 -ns -/ -iter -( -+ -/ -- -337 -572 -) -= -397 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -11 -109 -679 -ns -/ -iter -( -+ -/ -- -357 -680 -) -= -457 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -11 -238 -093 -ns -/ -iter -( -+ -/ -- -1 -571 -929 -) -= -452 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -8 -453 -224 -ns -/ -iter -( -+ -/ -- -185 -044 -) -= -601 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -8 -784 -446 -ns -/ -iter -( -+ -/ -- -153 -626 -) -= -578 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -11 -151 -797 -ns -/ -iter -( -+ -/ -- -366 -593 -) -= -455 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -22 -206 -248 -ns -/ -iter -( -+ -/ -- -1 -143 -965 -) -= -228 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -23 -458 -512 -ns -/ -iter -( -+ -/ -- -1 -982 -069 -) -= -25 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -23 -040 -796 -ns -/ -iter -( -+ -/ -- -688 -881 -) -= -25 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -1 -035 -156 -ns -/ -iter -( -+ -/ -- -113 -881 -) -= -574 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -118 -126 -447 -ns -/ -iter -( -+ -/ -- -8 -394 -250 -) -= -5 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -16 -122 -434 -ns -/ -iter -( -+ -/ -- -236 -636 -) -= -36 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -22 -239 -435 -ns -/ -iter -( -+ -/ -- -364 -604 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -92 -002 -273 -ns -/ -iter -( -+ -/ -- -2 -056 -908 -) -= -6 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -90 -778 -580 -ns -/ -iter -( -+ -/ -- -4 -179 -255 -) -= -6 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -3 -392 -415 -ns -/ -iter -( -+ -/ -- -143 -338 -) -= -175 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -428 -636 -ns -/ -iter -( -+ -/ -- -14 -993 -) -= -1387 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -432 -574 -ns -/ -iter -( -+ -/ -- -13 -731 -) -= -1375 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -644 -165 -ns -/ -iter -( -+ -/ -- -15 -049 -) -= -923 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -176 -979 -ns -/ -iter -( -+ -/ -- -105 -694 -) -= -505 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -054 -990 -ns -/ -iter -( -+ -/ -- -91 -909 -) -= -289 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -712 -039 -ns -/ -iter -( -+ -/ -- -36 -911 -) -= -835 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -993 -415 -ns -/ -iter -( -+ -/ -- -27 -355 -) -= -598 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -757 -045 -ns -/ -iter -( -+ -/ -- -29 -126 -) -= -785 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -953 -821 -ns -/ -iter -( -+ -/ -- -37 -252 -) -= -623 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -186 -801 -ns -/ -iter -( -+ -/ -- -6 -676 -) -= -3184 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -539 -857 -ns -/ -iter -( -+ -/ -- -40 -614 -) -= -1102 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -56 -113 -ns -/ -iter -( -+ -/ -- -4 -566 -) -= -10602 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -67 -558 -ns -/ -iter -( -+ -/ -- -6 -746 -) -= -8806 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -429 -123 -ns -/ -iter -( -+ -/ -- -51 -647 -) -= -1386 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -396 -070 -ns -/ -iter -( -+ -/ -- -33 -934 -) -= -1502 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -84 -630 -ns -/ -iter -( -+ -/ -- -6 -285 -) -= -7029 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -292 -844 -ns -/ -iter -( -+ -/ -- -24 -013 -) -= -2031 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -290 -986 -ns -/ -iter -( -+ -/ -- -10 -163 -) -= -2044 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -14 -041 -ns -/ -iter -( -+ -/ -- -599 -) -= -42371 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -6 -489 -945 -ns -/ -iter -( -+ -/ -- -132 -983 -) -= -91 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -49 -479 -000 -ns -/ -iter -( -+ -/ -- -965 -144 -) -= -12 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -2 -268 -881 -ns -/ -iter -( -+ -/ -- -134 -889 -) -= -262 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -2 -906 -824 -ns -/ -iter -( -+ -/ -- -72 -615 -) -= -204 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -211 -138 -ns -/ -iter -( -+ -/ -- -9 -935 -) -= -2817 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -3 -488 -249 -ns -/ -iter -( -+ -/ -- -254 -294 -) -= -170 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -30 -917 -395 -ns -/ -iter -( -+ -/ -- -2 -298 -620 -) -= -19 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -39 -830 -572 -ns -/ -iter -( -+ -/ -- -2 -662 -348 -) -= -14 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -95 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/06/dphobos-dmd-ct b/third_party/rust/regex/record/old-bench-log/06/dphobos-dmd-ct deleted file mode 100644 index 1415dff4f18dc..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/06/dphobos-dmd-ct +++ /dev/null @@ -1,2566 +0,0 @@ -running -94 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -336 -ns -/ -iter -( -+ -/ -- -145 -) -= -1160 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -246 -ns -/ -iter -( -+ -/ -- -27 -) -= -1585 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -313 -ns -/ -iter -( -+ -/ -- -32 -) -= -83 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -248 -ns -/ -iter -( -+ -/ -- -31 -) -= -104 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -792 -ns -/ -iter -( -+ -/ -- -109 -) -= -1327 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -24 -706 -ns -/ -iter -( -+ -/ -- -812 -) -= -42443 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -793 -ns -/ -iter -( -+ -/ -- -77 -) -= -74 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -1 -179 -ns -/ -iter -( -+ -/ -- -55 -) -= -27815 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -720 -ns -/ -iter -( -+ -/ -- -85 -) -= -1450 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -24 -647 -ns -/ -iter -( -+ -/ -- -761 -) -= -42544 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -717 -ns -/ -iter -( -+ -/ -- -28 -) -= -72 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -1 -140 -ns -/ -iter -( -+ -/ -- -116 -) -= -28761 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -19 -153 -ns -/ -iter -( -+ -/ -- -2 -063 -) -= -54 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -19 -966 -822 -ns -/ -iter -( -+ -/ -- -1 -979 -640 -) -= -52 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -2 -617 -ns -/ -iter -( -+ -/ -- -354 -) -= -22 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -621 -150 -ns -/ -iter -( -+ -/ -- -24 -244 -) -= -52 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -194 -ns -/ -iter -( -+ -/ -- -28 -) -= -262 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -83 -293 -ns -/ -iter -( -+ -/ -- -3 -287 -) -= -1200 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -83 -214 -ns -/ -iter -( -+ -/ -- -3 -344 -) -= -1201 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -301 -ns -/ -iter -( -+ -/ -- -38 -) -= -269 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -258 -ns -/ -iter -( -+ -/ -- -27 -) -= -313 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -565 -ns -/ -iter -( -+ -/ -- -187 -) -= -102 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -572 -ns -/ -iter -( -+ -/ -- -230 -) -= -669 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -609 -944 -ns -/ -iter -( -+ -/ -- -23 -088 -) -= -1719 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -980 -ns -/ -iter -( -+ -/ -- -112 -) -= -61 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -20 -058 -ns -/ -iter -( -+ -/ -- -884 -) -= -1635 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -1 -218 -ns -/ -iter -( -+ -/ -- -67 -) -= -41 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -588 -ns -/ -iter -( -+ -/ -- -93 -) -= -44 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -595 -ns -/ -iter -( -+ -/ -- -77 -) -= -43 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -1 -114 -ns -/ -iter -( -+ -/ -- -52 -) -= -15 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -1 -481 -ns -/ -iter -( -+ -/ -- -183 -) -= -11 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -40 -858 -ns -/ -iter -( -+ -/ -- -1 -860 -) -= -25 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -18 -678 -ns -/ -iter -( -+ -/ -- -835 -) -= -56 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -19 -824 -750 -ns -/ -iter -( -+ -/ -- -354 -159 -) -= -52 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -2 -340 -ns -/ -iter -( -+ -/ -- -68 -) -= -25 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -621 -351 -ns -/ -iter -( -+ -/ -- -21 -369 -) -= -52 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -919 -ns -/ -iter -( -+ -/ -- -224 -) -= -1626 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -27 -265 -128 -ns -/ -iter -( -+ -/ -- -1 -416 -486 -) -= -186 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -6 -414 -636 -ns -/ -iter -( -+ -/ -- -696 -943 -) -= -792 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -6 -426 -829 -ns -/ -iter -( -+ -/ -- -206 -773 -) -= -790 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -6 -435 -800 -ns -/ -iter -( -+ -/ -- -439 -175 -) -= -789 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -6 -428 -455 -ns -/ -iter -( -+ -/ -- -214 -961 -) -= -790 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -6 -428 -692 -ns -/ -iter -( -+ -/ -- -681 -910 -) -= -790 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -6 -425 -781 -ns -/ -iter -( -+ -/ -- -129 -718 -) -= -791 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -6 -414 -376 -ns -/ -iter -( -+ -/ -- -151 -827 -) -= -792 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -6 -455 -032 -ns -/ -iter -( -+ -/ -- -423 -915 -) -= -787 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -6 -668 -649 -ns -/ -iter -( -+ -/ -- -686 -734 -) -= -762 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -6 -393 -791 -ns -/ -iter -( -+ -/ -- -172 -533 -) -= -795 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -6 -426 -100 -ns -/ -iter -( -+ -/ -- -175 -951 -) -= -791 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -5 -612 -507 -ns -/ -iter -( -+ -/ -- -128 -406 -) -= -905 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -7 -572 -661 -ns -/ -iter -( -+ -/ -- -159 -047 -) -= -671 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -12 -287 -183 -ns -/ -iter -( -+ -/ -- -378 -305 -) -= -413 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -11 -223 -976 -ns -/ -iter -( -+ -/ -- -1 -191 -250 -) -= -452 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -11 -016 -081 -ns -/ -iter -( -+ -/ -- -714 -537 -) -= -461 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -8 -198 -798 -ns -/ -iter -( -+ -/ -- -471 -338 -) -= -620 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -8 -895 -886 -ns -/ -iter -( -+ -/ -- -885 -690 -) -= -571 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -11 -000 -942 -ns -/ -iter -( -+ -/ -- -886 -538 -) -= -462 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -20 -761 -109 -ns -/ -iter -( -+ -/ -- -629 -876 -) -= -244 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -24 -417 -513 -ns -/ -iter -( -+ -/ -- -2 -359 -425 -) -= -24 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -24 -435 -196 -ns -/ -iter -( -+ -/ -- -2 -164 -187 -) -= -24 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -1 -025 -780 -ns -/ -iter -( -+ -/ -- -121 -876 -) -= -579 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -122 -988 -753 -ns -/ -iter -( -+ -/ -- -7 -606 -302 -) -= -4 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -16 -322 -427 -ns -/ -iter -( -+ -/ -- -321 -746 -) -= -36 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -21 -993 -282 -ns -/ -iter -( -+ -/ -- -434 -365 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -88 -877 -258 -ns -/ -iter -( -+ -/ -- -504 -024 -) -= -6 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -87 -709 -419 -ns -/ -iter -( -+ -/ -- -659 -859 -) -= -6 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -3 -299 -811 -ns -/ -iter -( -+ -/ -- -78 -850 -) -= -180 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -431 -548 -ns -/ -iter -( -+ -/ -- -54 -716 -) -= -1378 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -470 -052 -ns -/ -iter -( -+ -/ -- -49 -985 -) -= -1265 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -705 -694 -ns -/ -iter -( -+ -/ -- -45 -724 -) -= -843 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -148 -456 -ns -/ -iter -( -+ -/ -- -51 -018 -) -= -518 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -026 -355 -ns -/ -iter -( -+ -/ -- -220 -043 -) -= -293 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -699 -625 -ns -/ -iter -( -+ -/ -- -40 -361 -) -= -850 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -979 -151 -ns -/ -iter -( -+ -/ -- -41 -460 -) -= -607 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -751 -646 -ns -/ -iter -( -+ -/ -- -31 -601 -) -= -791 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -950 -701 -ns -/ -iter -( -+ -/ -- -102 -078 -) -= -625 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -184 -935 -ns -/ -iter -( -+ -/ -- -6 -633 -) -= -3216 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -532 -703 -ns -/ -iter -( -+ -/ -- -33 -919 -) -= -1116 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -55 -468 -ns -/ -iter -( -+ -/ -- -1 -776 -) -= -10725 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -67 -327 -ns -/ -iter -( -+ -/ -- -5 -464 -) -= -8836 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -417 -724 -ns -/ -iter -( -+ -/ -- -45 -520 -) -= -1424 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -392 -285 -ns -/ -iter -( -+ -/ -- -14 -778 -) -= -1516 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -77 -112 -ns -/ -iter -( -+ -/ -- -2 -785 -) -= -7715 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -291 -222 -ns -/ -iter -( -+ -/ -- -10 -477 -) -= -2042 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -291 -393 -ns -/ -iter -( -+ -/ -- -10 -834 -) -= -2041 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -14 -016 -ns -/ -iter -( -+ -/ -- -376 -) -= -42446 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -6 -557 -639 -ns -/ -iter -( -+ -/ -- -158 -929 -) -= -90 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -49 -697 -910 -ns -/ -iter -( -+ -/ -- -773 -749 -) -= -11 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -2 -236 -055 -ns -/ -iter -( -+ -/ -- -72 -024 -) -= -266 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -2 -892 -430 -ns -/ -iter -( -+ -/ -- -89 -222 -) -= -205 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -207 -035 -ns -/ -iter -( -+ -/ -- -8 -624 -) -= -2873 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -3 -435 -267 -ns -/ -iter -( -+ -/ -- -416 -560 -) -= -173 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -31 -751 -871 -ns -/ -iter -( -+ -/ -- -374 -472 -) -= -18 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -38 -793 -659 -ns -/ -iter -( -+ -/ -- -3 -022 -370 -) -= -15 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -94 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/06/dphobos-ldc b/third_party/rust/regex/record/old-bench-log/06/dphobos-ldc deleted file mode 100644 index 00a5db7c53215..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/06/dphobos-ldc +++ /dev/null @@ -1,2587 +0,0 @@ -running -95 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -203 -ns -/ -iter -( -+ -/ -- -13 -) -= -1921 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -126 -ns -/ -iter -( -+ -/ -- -5 -) -= -3095 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -204 -ns -/ -iter -( -+ -/ -- -4 -) -= -127 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -127 -ns -/ -iter -( -+ -/ -- -8 -) -= -204 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -571 -ns -/ -iter -( -+ -/ -- -44 -) -= -1840 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -25 -321 -ns -/ -iter -( -+ -/ -- -421 -) -= -41412 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -553 -ns -/ -iter -( -+ -/ -- -9 -) -= -106 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -971 -ns -/ -iter -( -+ -/ -- -29 -) -= -33774 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -508 -ns -/ -iter -( -+ -/ -- -22 -) -= -2055 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -24 -181 -ns -/ -iter -( -+ -/ -- -704 -) -= -43364 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -494 -ns -/ -iter -( -+ -/ -- -14 -) -= -105 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -892 -ns -/ -iter -( -+ -/ -- -82 -) -= -36757 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -15 -335 -ns -/ -iter -( -+ -/ -- -1 -224 -) -= -68 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -16 -105 -838 -ns -/ -iter -( -+ -/ -- -319 -567 -) -= -65 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -1 -798 -ns -/ -iter -( -+ -/ -- -79 -) -= -32 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -504 -123 -ns -/ -iter -( -+ -/ -- -44 -829 -) -= -65 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -74 -ns -/ -iter -( -+ -/ -- -9 -) -= -689 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -56 -853 -ns -/ -iter -( -+ -/ -- -3 -662 -) -= -1758 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -57 -038 -ns -/ -iter -( -+ -/ -- -2 -532 -) -= -1753 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -140 -ns -/ -iter -( -+ -/ -- -15 -) -= -578 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -126 -ns -/ -iter -( -+ -/ -- -17 -) -= -642 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -407 -ns -/ -iter -( -+ -/ -- -122 -) -= -114 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -199 -ns -/ -iter -( -+ -/ -- -80 -) -= -877 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -558 -323 -ns -/ -iter -( -+ -/ -- -20 -908 -) -= -1878 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -661 -ns -/ -iter -( -+ -/ -- -30 -) -= -90 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -18 -148 -ns -/ -iter -( -+ -/ -- -1 -038 -) -= -1807 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -334 -786 -ns -/ -iter -( -+ -/ -- -18 -234 -) -test -misc -: -: -not_literal -. -. -. -bench -: -1 -347 -ns -/ -iter -( -+ -/ -- -49 -) -= -37 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -499 -ns -/ -iter -( -+ -/ -- -59 -) -= -52 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -522 -ns -/ -iter -( -+ -/ -- -64 -) -= -49 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -804 -ns -/ -iter -( -+ -/ -- -37 -) -= -21 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -1 -260 -ns -/ -iter -( -+ -/ -- -130 -) -= -13 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -37 -726 -ns -/ -iter -( -+ -/ -- -1 -284 -) -= -27 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -15 -246 -ns -/ -iter -( -+ -/ -- -901 -) -= -68 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -16 -187 -692 -ns -/ -iter -( -+ -/ -- -1 -552 -760 -) -= -64 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -1 -882 -ns -/ -iter -( -+ -/ -- -237 -) -= -31 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -541 -567 -ns -/ -iter -( -+ -/ -- -64 -929 -) -= -60 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -576 -ns -/ -iter -( -+ -/ -- -185 -) -= -1748 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -14 -744 -849 -ns -/ -iter -( -+ -/ -- -1 -141 -621 -) -= -344 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -2 -801 -370 -ns -/ -iter -( -+ -/ -- -105 -875 -) -= -1814 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -3 -015 -410 -ns -/ -iter -( -+ -/ -- -446 -982 -) -= -1685 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -2 -923 -557 -ns -/ -iter -( -+ -/ -- -193 -230 -) -= -1738 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -2 -948 -002 -ns -/ -iter -( -+ -/ -- -306 -203 -) -= -1724 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -2 -899 -076 -ns -/ -iter -( -+ -/ -- -174 -958 -) -= -1753 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -2 -908 -685 -ns -/ -iter -( -+ -/ -- -221 -436 -) -= -1747 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -3 -780 -044 -ns -/ -iter -( -+ -/ -- -150 -740 -) -= -1344 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -2 -920 -193 -ns -/ -iter -( -+ -/ -- -142 -191 -) -= -1740 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -2 -918 -785 -ns -/ -iter -( -+ -/ -- -175 -109 -) -= -1741 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -2 -932 -075 -ns -/ -iter -( -+ -/ -- -152 -745 -) -= -1733 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -2 -914 -694 -ns -/ -iter -( -+ -/ -- -176 -327 -) -= -1744 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -5 -172 -617 -ns -/ -iter -( -+ -/ -- -269 -855 -) -= -982 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -6 -770 -702 -ns -/ -iter -( -+ -/ -- -474 -076 -) -= -750 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -11 -124 -754 -ns -/ -iter -( -+ -/ -- -649 -591 -) -= -456 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -9 -751 -982 -ns -/ -iter -( -+ -/ -- -460 -679 -) -= -521 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -9 -791 -229 -ns -/ -iter -( -+ -/ -- -461 -486 -) -= -519 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -7 -417 -031 -ns -/ -iter -( -+ -/ -- -275 -225 -) -= -685 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -7 -873 -097 -ns -/ -iter -( -+ -/ -- -451 -115 -) -= -645 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -9 -707 -683 -ns -/ -iter -( -+ -/ -- -418 -865 -) -= -523 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -18 -696 -520 -ns -/ -iter -( -+ -/ -- -742 -018 -) -= -271 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -22 -314 -084 -ns -/ -iter -( -+ -/ -- -888 -249 -) -= -26 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -22 -501 -540 -ns -/ -iter -( -+ -/ -- -892 -027 -) -= -26 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -929 -372 -ns -/ -iter -( -+ -/ -- -46 -859 -) -= -640 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -125 -548 -613 -ns -/ -iter -( -+ -/ -- -3 -297 -687 -) -= -4 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -18 -023 -803 -ns -/ -iter -( -+ -/ -- -1 -079 -960 -) -= -33 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -21 -809 -497 -ns -/ -iter -( -+ -/ -- -1 -259 -989 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -39 -512 -315 -ns -/ -iter -( -+ -/ -- -3 -309 -084 -) -= -15 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -37 -160 -354 -ns -/ -iter -( -+ -/ -- -3 -084 -525 -) -= -16 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -721 -867 -ns -/ -iter -( -+ -/ -- -66 -812 -) -= -345 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -378 -307 -ns -/ -iter -( -+ -/ -- -30 -914 -) -= -1572 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -381 -242 -ns -/ -iter -( -+ -/ -- -41 -954 -) -= -1560 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -503 -558 -ns -/ -iter -( -+ -/ -- -46 -044 -) -= -1181 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -912 -340 -ns -/ -iter -( -+ -/ -- -79 -787 -) -= -652 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -515 -048 -ns -/ -iter -( -+ -/ -- -74 -623 -) -= -392 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -580 -652 -ns -/ -iter -( -+ -/ -- -60 -407 -) -= -1024 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -826 -866 -ns -/ -iter -( -+ -/ -- -58 -485 -) -= -719 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -651 -281 -ns -/ -iter -( -+ -/ -- -64 -134 -) -= -913 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -808 -974 -ns -/ -iter -( -+ -/ -- -49 -119 -) -= -735 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -120 -010 -ns -/ -iter -( -+ -/ -- -9 -458 -) -= -4957 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -441 -316 -ns -/ -iter -( -+ -/ -- -56 -990 -) -= -1348 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -39 -935 -ns -/ -iter -( -+ -/ -- -4 -078 -) -= -14897 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -49 -126 -ns -/ -iter -( -+ -/ -- -3 -082 -) -= -12110 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -366 -865 -ns -/ -iter -( -+ -/ -- -18 -520 -) -= -1621 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -349 -337 -ns -/ -iter -( -+ -/ -- -18 -365 -) -= -1703 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -57 -076 -ns -/ -iter -( -+ -/ -- -6 -314 -) -= -10423 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -291 -022 -ns -/ -iter -( -+ -/ -- -30 -143 -) -= -2044 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -286 -214 -ns -/ -iter -( -+ -/ -- -15 -722 -) -= -2078 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -13 -963 -ns -/ -iter -( -+ -/ -- -759 -) -= -42607 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -5 -580 -378 -ns -/ -iter -( -+ -/ -- -295 -941 -) -= -106 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -52 -797 -981 -ns -/ -iter -( -+ -/ -- -2 -731 -805 -) -= -11 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -295 -105 -ns -/ -iter -( -+ -/ -- -62 -365 -) -= -459 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -1 -620 -713 -ns -/ -iter -( -+ -/ -- -73 -503 -) -= -367 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -112 -911 -ns -/ -iter -( -+ -/ -- -5 -843 -) -= -5269 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -441 -986 -ns -/ -iter -( -+ -/ -- -133 -012 -) -= -243 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -26 -478 -327 -ns -/ -iter -( -+ -/ -- -1 -361 -757 -) -= -22 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -23 -948 -872 -ns -/ -iter -( -+ -/ -- -2 -323 -993 -) -= -24 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -95 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/06/dphobos-ldc-ct b/third_party/rust/regex/record/old-bench-log/06/dphobos-ldc-ct deleted file mode 100644 index d9c942e346879..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/06/dphobos-ldc-ct +++ /dev/null @@ -1,2563 +0,0 @@ -running -94 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -189 -ns -/ -iter -( -+ -/ -- -23 -) -= -2063 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -128 -ns -/ -iter -( -+ -/ -- -14 -) -= -3046 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -191 -ns -/ -iter -( -+ -/ -- -20 -) -= -136 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -120 -ns -/ -iter -( -+ -/ -- -13 -) -= -216 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -536 -ns -/ -iter -( -+ -/ -- -49 -) -= -1960 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -24 -516 -ns -/ -iter -( -+ -/ -- -2 -181 -) -= -42772 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -551 -ns -/ -iter -( -+ -/ -- -36 -) -= -107 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -961 -ns -/ -iter -( -+ -/ -- -105 -) -= -34125 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -518 -ns -/ -iter -( -+ -/ -- -59 -) -= -2015 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -25 -352 -ns -/ -iter -( -+ -/ -- -2 -847 -) -= -41361 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -501 -ns -/ -iter -( -+ -/ -- -42 -) -= -103 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -919 -ns -/ -iter -( -+ -/ -- -69 -) -= -35677 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -16 -146 -ns -/ -iter -( -+ -/ -- -1 -124 -) -= -65 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -16 -482 -695 -ns -/ -iter -( -+ -/ -- -805 -077 -) -= -63 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -1 -807 -ns -/ -iter -( -+ -/ -- -173 -) -= -32 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -516 -772 -ns -/ -iter -( -+ -/ -- -33 -884 -) -= -63 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -77 -ns -/ -iter -( -+ -/ -- -9 -) -= -662 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -56 -900 -ns -/ -iter -( -+ -/ -- -3 -087 -) -= -1757 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -57 -364 -ns -/ -iter -( -+ -/ -- -4 -166 -) -= -1743 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -156 -ns -/ -iter -( -+ -/ -- -21 -) -= -519 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -121 -ns -/ -iter -( -+ -/ -- -12 -) -= -669 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -515 -ns -/ -iter -( -+ -/ -- -207 -) -= -106 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -186 -ns -/ -iter -( -+ -/ -- -120 -) -= -887 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -559 -677 -ns -/ -iter -( -+ -/ -- -59 -284 -) -= -1873 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -657 -ns -/ -iter -( -+ -/ -- -86 -) -= -91 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -18 -142 -ns -/ -iter -( -+ -/ -- -915 -) -= -1807 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -1 -319 -ns -/ -iter -( -+ -/ -- -128 -) -= -38 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -509 -ns -/ -iter -( -+ -/ -- -56 -) -= -51 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -517 -ns -/ -iter -( -+ -/ -- -38 -) -= -50 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -783 -ns -/ -iter -( -+ -/ -- -83 -) -= -21 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -1 -239 -ns -/ -iter -( -+ -/ -- -98 -) -= -13 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -40 -580 -ns -/ -iter -( -+ -/ -- -3 -041 -) -= -25 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -15 -162 -ns -/ -iter -( -+ -/ -- -652 -) -= -69 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -16 -065 -920 -ns -/ -iter -( -+ -/ -- -886 -245 -) -= -65 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -1 -829 -ns -/ -iter -( -+ -/ -- -90 -) -= -32 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -520 -572 -ns -/ -iter -( -+ -/ -- -88 -290 -) -= -62 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -423 -ns -/ -iter -( -+ -/ -- -493 -) -= -1808 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -14 -658 -357 -ns -/ -iter -( -+ -/ -- -1 -784 -941 -) -= -346 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -2 -984 -959 -ns -/ -iter -( -+ -/ -- -422 -186 -) -= -1703 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -2 -836 -747 -ns -/ -iter -( -+ -/ -- -274 -300 -) -= -1791 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -2 -809 -880 -ns -/ -iter -( -+ -/ -- -309 -516 -) -= -1809 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -2 -868 -765 -ns -/ -iter -( -+ -/ -- -435 -511 -) -= -1771 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -2 -837 -000 -ns -/ -iter -( -+ -/ -- -319 -135 -) -= -1791 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -2 -856 -540 -ns -/ -iter -( -+ -/ -- -320 -458 -) -= -1779 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -2 -820 -953 -ns -/ -iter -( -+ -/ -- -340 -996 -) -= -1802 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -3 -588 -607 -ns -/ -iter -( -+ -/ -- -462 -158 -) -= -1416 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -2 -896 -235 -ns -/ -iter -( -+ -/ -- -165 -525 -) -= -1755 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -2 -982 -961 -ns -/ -iter -( -+ -/ -- -315 -768 -) -= -1704 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -3 -024 -311 -ns -/ -iter -( -+ -/ -- -300 -274 -) -= -1680 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -5 -234 -342 -ns -/ -iter -( -+ -/ -- -269 -577 -) -= -971 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -6 -463 -683 -ns -/ -iter -( -+ -/ -- -532 -663 -) -= -786 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -10 -720 -523 -ns -/ -iter -( -+ -/ -- -414 -684 -) -= -474 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -9 -882 -647 -ns -/ -iter -( -+ -/ -- -297 -904 -) -= -514 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -9 -664 -151 -ns -/ -iter -( -+ -/ -- -659 -587 -) -= -526 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -7 -174 -368 -ns -/ -iter -( -+ -/ -- -322 -025 -) -= -708 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -7 -605 -668 -ns -/ -iter -( -+ -/ -- -411 -605 -) -= -668 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -9 -580 -481 -ns -/ -iter -( -+ -/ -- -373 -332 -) -= -530 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -18 -270 -186 -ns -/ -iter -( -+ -/ -- -986 -510 -) -= -278 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -21 -982 -853 -ns -/ -iter -( -+ -/ -- -1 -032 -853 -) -= -27 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -21 -947 -949 -ns -/ -iter -( -+ -/ -- -848 -014 -) -= -27 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -909 -691 -ns -/ -iter -( -+ -/ -- -48 -847 -) -= -653 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -124 -771 -191 -ns -/ -iter -( -+ -/ -- -8 -084 -768 -) -= -4 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -17 -864 -129 -ns -/ -iter -( -+ -/ -- -1 -343 -114 -) -= -33 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -21 -009 -249 -ns -/ -iter -( -+ -/ -- -452 -676 -) -= -28 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -37 -888 -421 -ns -/ -iter -( -+ -/ -- -2 -482 -541 -) -= -15 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -37 -029 -883 -ns -/ -iter -( -+ -/ -- -481 -280 -) -= -16 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -627 -107 -ns -/ -iter -( -+ -/ -- -51 -063 -) -= -365 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -370 -850 -ns -/ -iter -( -+ -/ -- -15 -384 -) -= -1604 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -371 -780 -ns -/ -iter -( -+ -/ -- -28 -486 -) -= -1600 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -506 -859 -ns -/ -iter -( -+ -/ -- -17 -553 -) -= -1173 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -915 -729 -ns -/ -iter -( -+ -/ -- -99 -429 -) -= -649 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -512 -050 -ns -/ -iter -( -+ -/ -- -186 -130 -) -= -393 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -578 -710 -ns -/ -iter -( -+ -/ -- -18 -089 -) -= -1028 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -752 -912 -ns -/ -iter -( -+ -/ -- -51 -342 -) -= -790 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -595 -803 -ns -/ -iter -( -+ -/ -- -15 -053 -) -= -998 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -730 -149 -ns -/ -iter -( -+ -/ -- -40 -662 -) -= -814 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -115 -596 -ns -/ -iter -( -+ -/ -- -4 -597 -) -= -5146 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -429 -765 -ns -/ -iter -( -+ -/ -- -16 -685 -) -= -1384 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -38 -985 -ns -/ -iter -( -+ -/ -- -2 -195 -) -= -15260 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -49 -610 -ns -/ -iter -( -+ -/ -- -2 -005 -) -= -11992 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -374 -335 -ns -/ -iter -( -+ -/ -- -37 -062 -) -= -1589 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -355 -559 -ns -/ -iter -( -+ -/ -- -40 -873 -) -= -1673 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -57 -616 -ns -/ -iter -( -+ -/ -- -5 -124 -) -= -10325 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -284 -228 -ns -/ -iter -( -+ -/ -- -29 -087 -) -= -2093 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -287 -263 -ns -/ -iter -( -+ -/ -- -22 -755 -) -= -2071 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -14 -030 -ns -/ -iter -( -+ -/ -- -526 -) -= -42404 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -5 -563 -019 -ns -/ -iter -( -+ -/ -- -537 -611 -) -= -106 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -54 -831 -275 -ns -/ -iter -( -+ -/ -- -5 -982 -214 -) -= -10 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -298 -205 -ns -/ -iter -( -+ -/ -- -73 -265 -) -= -458 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -1 -572 -579 -ns -/ -iter -( -+ -/ -- -63 -536 -) -= -378 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -112 -795 -ns -/ -iter -( -+ -/ -- -4 -179 -) -= -5274 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -630 -026 -ns -/ -iter -( -+ -/ -- -227 -760 -) -= -226 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -26 -975 -356 -ns -/ -iter -( -+ -/ -- -2 -531 -982 -) -= -22 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -23 -116 -326 -ns -/ -iter -( -+ -/ -- -458 -721 -) -= -25 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -94 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/06/pcre1 b/third_party/rust/regex/record/old-bench-log/06/pcre1 deleted file mode 100644 index ff60f179d9e5d..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/06/pcre1 +++ /dev/null @@ -1,2523 +0,0 @@ -running -93 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -32 -ns -/ -iter -( -+ -/ -- -38 -) -= -12187 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -1 -) -= -16956 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -30 -ns -/ -iter -( -+ -/ -- -1 -) -= -866 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -0 -) -= -1130 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -261 -ns -/ -iter -( -+ -/ -- -21 -) -= -4026 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -202 -218 -ns -/ -iter -( -+ -/ -- -16 -050 -) -= -5185 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -3 -) -= -1204 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -6 -305 -ns -/ -iter -( -+ -/ -- -448 -) -= -5201 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -245 -ns -/ -iter -( -+ -/ -- -5 -) -= -4261 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -198 -215 -ns -/ -iter -( -+ -/ -- -10 -461 -) -= -5290 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -1 -) -= -1061 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -6 -309 -ns -/ -iter -( -+ -/ -- -358 -) -= -5197 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -306 -ns -/ -iter -( -+ -/ -- -50 -) -= -804 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -1 -219 -034 -ns -/ -iter -( -+ -/ -- -92 -693 -) -= -860 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -95 -ns -/ -iter -( -+ -/ -- -7 -) -= -621 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -37 -713 -ns -/ -iter -( -+ -/ -- -948 -) -= -869 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -29 -ns -/ -iter -( -+ -/ -- -1 -) -= -1758 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -548 -012 -ns -/ -iter -( -+ -/ -- -26 -029 -) -= -182 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -538 -536 -ns -/ -iter -( -+ -/ -- -54 -612 -) -= -185 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -94 -ns -/ -iter -( -+ -/ -- -3 -) -= -861 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -29 -ns -/ -iter -( -+ -/ -- -1 -) -= -2793 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -370 -ns -/ -iter -( -+ -/ -- -19 -) -= -435 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -256 -ns -/ -iter -( -+ -/ -- -13 -) -= -4109 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -207 -655 -ns -/ -iter -( -+ -/ -- -9 -168 -) -= -5049 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -5 -) -= -1176 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -6 -144 -ns -/ -iter -( -+ -/ -- -327 -) -= -5337 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -166 -ns -/ -iter -( -+ -/ -- -14 -) -= -307 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -27 -ns -/ -iter -( -+ -/ -- -2 -) -= -962 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -29 -ns -/ -iter -( -+ -/ -- -1 -) -= -896 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -2 -) -= -309 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -3 -) -= -309 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -4 -404 -ns -/ -iter -( -+ -/ -- -346 -) -= -236 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -365 -ns -/ -iter -( -+ -/ -- -52 -) -= -769 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -118 -777 -ns -/ -iter -( -+ -/ -- -72 -209 -) -= -937 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -112 -ns -/ -iter -( -+ -/ -- -4 -) -= -526 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -41 -164 -ns -/ -iter -( -+ -/ -- -2 -351 -) -= -796 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -413 -ns -/ -iter -( -+ -/ -- -304 -) -= -1812 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -2 -802 -109 -ns -/ -iter -( -+ -/ -- -129 -768 -) -= -1814 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -1 -263 -401 -ns -/ -iter -( -+ -/ -- -54 -374 -) -= -4023 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -1 -254 -544 -ns -/ -iter -( -+ -/ -- -101 -656 -) -= -4051 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -1 -408 -321 -ns -/ -iter -( -+ -/ -- -121 -522 -) -= -3609 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -1 -364 -704 -ns -/ -iter -( -+ -/ -- -106 -508 -) -= -3724 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -1 -258 -687 -ns -/ -iter -( -+ -/ -- -84 -504 -) -= -4038 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -1 -301 -822 -ns -/ -iter -( -+ -/ -- -62 -866 -) -= -3904 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -1 -338 -338 -ns -/ -iter -( -+ -/ -- -313 -996 -) -= -3798 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -1 -349 -310 -ns -/ -iter -( -+ -/ -- -117 -181 -) -= -3767 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -1 -390 -090 -ns -/ -iter -( -+ -/ -- -210 -430 -) -= -3656 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -1 -293 -481 -ns -/ -iter -( -+ -/ -- -38 -532 -) -= -3930 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -1 -245 -652 -ns -/ -iter -( -+ -/ -- -58 -026 -) -= -4080 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -15 -239 -324 -ns -/ -iter -( -+ -/ -- -414 -621 -) -= -333 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -16 -489 -922 -ns -/ -iter -( -+ -/ -- -825 -229 -) -= -308 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -19 -945 -871 -ns -/ -iter -( -+ -/ -- -665 -046 -) -= -254 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -18 -604 -011 -ns -/ -iter -( -+ -/ -- -712 -670 -) -= -273 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -17 -084 -919 -ns -/ -iter -( -+ -/ -- -1 -379 -879 -) -= -297 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -16 -918 -130 -ns -/ -iter -( -+ -/ -- -975 -620 -) -= -300 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -19 -114 -194 -ns -/ -iter -( -+ -/ -- -857 -330 -) -= -265 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -23 -831 -138 -ns -/ -iter -( -+ -/ -- -878 -576 -) -= -213 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -21 -835 -777 -ns -/ -iter -( -+ -/ -- -1 -339 -143 -) -= -232 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -4 -401 -834 -ns -/ -iter -( -+ -/ -- -218 -696 -) -= -135 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -4 -436 -717 -ns -/ -iter -( -+ -/ -- -109 -324 -) -= -134 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -497 -667 -ns -/ -iter -( -+ -/ -- -19 -212 -) -= -1195 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -1 -852 -390 -ns -/ -iter -( -+ -/ -- -77 -888 -) -= -321 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -4 -775 -078 -ns -/ -iter -( -+ -/ -- -152 -556 -) -= -124 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -13 -888 -750 -ns -/ -iter -( -+ -/ -- -668 -831 -) -= -42 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -13 -452 -405 -ns -/ -iter -( -+ -/ -- -453 -184 -) -= -44 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -870 -502 -ns -/ -iter -( -+ -/ -- -57 -825 -) -= -318 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -198 -649 -ns -/ -iter -( -+ -/ -- -9 -080 -) -= -2994 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -464 -513 -ns -/ -iter -( -+ -/ -- -29 -935 -) -= -1280 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -470 -746 -ns -/ -iter -( -+ -/ -- -12 -931 -) -= -1263 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -874 -352 -ns -/ -iter -( -+ -/ -- -38 -618 -) -= -680 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -821 -106 -ns -/ -iter -( -+ -/ -- -113 -055 -) -= -210 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -78 -753 -ns -/ -iter -( -+ -/ -- -3 -111 -) -= -7554 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -596 -406 -ns -/ -iter -( -+ -/ -- -62 -919 -) -= -372 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -655 -870 -ns -/ -iter -( -+ -/ -- -32 -597 -) -= -907 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -732 -595 -ns -/ -iter -( -+ -/ -- -75 -827 -) -= -343 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -400 -037 -ns -/ -iter -( -+ -/ -- -16 -935 -) -= -1487 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -501 -467 -ns -/ -iter -( -+ -/ -- -20 -805 -) -= -1186 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -267 -873 -ns -/ -iter -( -+ -/ -- -10 -199 -) -= -2220 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -202 -107 -ns -/ -iter -( -+ -/ -- -10 -314 -) -= -2943 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -070 -780 -ns -/ -iter -( -+ -/ -- -43 -144 -) -= -555 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -074 -139 -ns -/ -iter -( -+ -/ -- -48 -270 -) -= -553 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -271 -978 -ns -/ -iter -( -+ -/ -- -10 -137 -) -= -2187 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -411 -484 -ns -/ -iter -( -+ -/ -- -13 -213 -) -= -1445 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -403 -709 -ns -/ -iter -( -+ -/ -- -12 -415 -) -= -1473 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -27 -730 -ns -/ -iter -( -+ -/ -- -928 -) -= -21454 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -515 -141 -ns -/ -iter -( -+ -/ -- -17 -799 -) -= -1154 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -5 -842 -243 -ns -/ -iter -( -+ -/ -- -282 -478 -) -= -101 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -725 -059 -ns -/ -iter -( -+ -/ -- -36 -233 -) -= -820 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -812 -888 -ns -/ -iter -( -+ -/ -- -34 -200 -) -= -731 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -56 -746 -ns -/ -iter -( -+ -/ -- -2 -186 -) -= -10484 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -920 -705 -ns -/ -iter -( -+ -/ -- -37 -325 -) -= -646 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -5 -625 -614 -ns -/ -iter -( -+ -/ -- -199 -408 -) -= -105 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -7 -122 -561 -ns -/ -iter -( -+ -/ -- -161 -013 -) -= -83 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -93 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/06/pcre2 b/third_party/rust/regex/record/old-bench-log/06/pcre2 deleted file mode 100644 index be6e25efaa5ce..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/06/pcre2 +++ /dev/null @@ -1,2511 +0,0 @@ -running -93 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -24375 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -1 -) -= -30000 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -1 -) -= -1625 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -1 -) -= -2000 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -104 -ns -/ -iter -( -+ -/ -- -5 -) -= -10105 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -64 -102 -ns -/ -iter -( -+ -/ -- -4 -103 -) -= -16358 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -32 -ns -/ -iter -( -+ -/ -- -4 -) -= -1843 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -2 -042 -ns -/ -iter -( -+ -/ -- -152 -) -= -16060 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -102 -ns -/ -iter -( -+ -/ -- -11 -) -= -10235 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -63 -117 -ns -/ -iter -( -+ -/ -- -4 -547 -) -= -16613 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -33 -ns -/ -iter -( -+ -/ -- -4 -) -= -1575 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -2 -019 -ns -/ -iter -( -+ -/ -- -181 -) -= -16239 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -236 -ns -/ -iter -( -+ -/ -- -82 -) -= -850 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -1 -041 -354 -ns -/ -iter -( -+ -/ -- -39 -123 -) -= -1006 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -8 -) -= -686 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -33 -054 -ns -/ -iter -( -+ -/ -- -1 -813 -) -= -992 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -2 -) -= -2550 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -501 -732 -ns -/ -iter -( -+ -/ -- -52 -173 -) -= -199 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -515 -127 -ns -/ -iter -( -+ -/ -- -48 -790 -) -= -194 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -7 -) -= -1472 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -2 -) -= -4263 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -342 -ns -/ -iter -( -+ -/ -- -60 -) -= -470 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -106 -ns -/ -iter -( -+ -/ -- -4 -) -= -9924 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -63 -011 -ns -/ -iter -( -+ -/ -- -4 -942 -) -= -16641 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -32 -ns -/ -iter -( -+ -/ -- -3 -) -= -1875 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -2 -068 -ns -/ -iter -( -+ -/ -- -189 -) -= -15858 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -147 -ns -/ -iter -( -+ -/ -- -13 -) -= -346 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -1 -) -= -1733 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -1 -) -= -1733 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -3 -) -= -404 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -5 -) -= -395 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -4 -356 -ns -/ -iter -( -+ -/ -- -499 -) -= -238 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -196 -ns -/ -iter -( -+ -/ -- -113 -) -= -878 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -070 -155 -ns -/ -iter -( -+ -/ -- -90 -895 -) -= -979 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -93 -ns -/ -iter -( -+ -/ -- -12 -) -= -634 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -33 -521 -ns -/ -iter -( -+ -/ -- -2 -663 -) -= -978 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -3 -065 -ns -/ -iter -( -+ -/ -- -393 -) -= -2610 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -1 -891 -736 -ns -/ -iter -( -+ -/ -- -232 -990 -) -= -2687 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -920 -853 -ns -/ -iter -( -+ -/ -- -75 -276 -) -= -5520 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -892 -533 -ns -/ -iter -( -+ -/ -- -77 -177 -) -= -5695 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -869 -335 -ns -/ -iter -( -+ -/ -- -75 -754 -) -= -5847 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -901 -876 -ns -/ -iter -( -+ -/ -- -75 -287 -) -= -5636 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -870 -185 -ns -/ -iter -( -+ -/ -- -53 -535 -) -= -5841 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -859 -924 -ns -/ -iter -( -+ -/ -- -63 -888 -) -= -5911 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -886 -748 -ns -/ -iter -( -+ -/ -- -87 -929 -) -= -5732 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -870 -428 -ns -/ -iter -( -+ -/ -- -47 -015 -) -= -5840 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -865 -513 -ns -/ -iter -( -+ -/ -- -41 -507 -) -= -5873 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -870 -030 -ns -/ -iter -( -+ -/ -- -110 -449 -) -= -5842 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -875 -649 -ns -/ -iter -( -+ -/ -- -32 -905 -) -= -5805 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -9 -234 -989 -ns -/ -iter -( -+ -/ -- -127 -076 -) -= -550 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -11 -759 -628 -ns -/ -iter -( -+ -/ -- -575 -788 -) -= -432 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -11 -229 -965 -ns -/ -iter -( -+ -/ -- -522 -759 -) -= -452 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -10 -040 -716 -ns -/ -iter -( -+ -/ -- -309 -357 -) -= -506 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -10 -052 -052 -ns -/ -iter -( -+ -/ -- -522 -338 -) -= -505 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -10 -719 -366 -ns -/ -iter -( -+ -/ -- -577 -988 -) -= -474 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -11 -076 -094 -ns -/ -iter -( -+ -/ -- -1 -291 -237 -) -= -458 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -11 -855 -290 -ns -/ -iter -( -+ -/ -- -667 -429 -) -= -428 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -12 -531 -240 -ns -/ -iter -( -+ -/ -- -606 -198 -) -= -405 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -4 -169 -656 -ns -/ -iter -( -+ -/ -- -222 -900 -) -= -142 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -4 -144 -394 -ns -/ -iter -( -+ -/ -- -170 -133 -) -= -143 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -74 -437 -ns -/ -iter -( -+ -/ -- -4 -266 -) -= -7992 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -1 -731 -507 -ns -/ -iter -( -+ -/ -- -162 -892 -) -= -343 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -4 -418 -194 -ns -/ -iter -( -+ -/ -- -240 -220 -) -= -134 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -8 -847 -041 -ns -/ -iter -( -+ -/ -- -392 -402 -) -= -67 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -8 -547 -432 -ns -/ -iter -( -+ -/ -- -304 -256 -) -= -69 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -584 -248 -ns -/ -iter -( -+ -/ -- -51 -331 -) -= -375 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -38 -057 -ns -/ -iter -( -+ -/ -- -1 -666 -) -= -15632 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -50 -415 -ns -/ -iter -( -+ -/ -- -3 -173 -) -= -11800 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -66 -062 -ns -/ -iter -( -+ -/ -- -2 -807 -) -= -9005 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -720 -097 -ns -/ -iter -( -+ -/ -- -32 -351 -) -= -826 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -591 -049 -ns -/ -iter -( -+ -/ -- -86 -537 -) -= -229 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -65 -860 -ns -/ -iter -( -+ -/ -- -2 -780 -) -= -9033 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -204 -839 -ns -/ -iter -( -+ -/ -- -41 -087 -) -= -493 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -615 -483 -ns -/ -iter -( -+ -/ -- -24 -177 -) -= -966 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -467 -461 -ns -/ -iter -( -+ -/ -- -71 -032 -) -= -405 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -48 -997 -ns -/ -iter -( -+ -/ -- -2 -471 -) -= -12142 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -88 -549 -ns -/ -iter -( -+ -/ -- -4 -814 -) -= -6718 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -38 -309 -ns -/ -iter -( -+ -/ -- -1 -354 -) -= -15529 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -39 -062 -ns -/ -iter -( -+ -/ -- -4 -253 -) -= -15230 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -713 -355 -ns -/ -iter -( -+ -/ -- -77 -990 -) -= -833 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -719 -747 -ns -/ -iter -( -+ -/ -- -85 -736 -) -= -826 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -39 -161 -ns -/ -iter -( -+ -/ -- -3 -678 -) -= -15191 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -35 -574 -ns -/ -iter -( -+ -/ -- -3 -433 -) -= -16723 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -56 -847 -ns -/ -iter -( -+ -/ -- -7 -068 -) -= -10465 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -36 -185 -ns -/ -iter -( -+ -/ -- -4 -938 -) -= -16441 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -454 -135 -ns -/ -iter -( -+ -/ -- -18 -816 -) -= -1310 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -5 -724 -068 -ns -/ -iter -( -+ -/ -- -342 -211 -) -= -103 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -256 -190 -ns -/ -iter -( -+ -/ -- -25 -452 -) -= -2322 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -284 -080 -ns -/ -iter -( -+ -/ -- -17 -165 -) -= -2094 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -56 -120 -ns -/ -iter -( -+ -/ -- -2 -826 -) -= -10601 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -456 -734 -ns -/ -iter -( -+ -/ -- -23 -405 -) -= -1302 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -5 -079 -288 -ns -/ -iter -( -+ -/ -- -214 -895 -) -= -117 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -5 -200 -092 -ns -/ -iter -( -+ -/ -- -250 -085 -) -= -114 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -93 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/06/re2 b/third_party/rust/regex/record/old-bench-log/06/re2 deleted file mode 100644 index d814121b7df50..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/06/re2 +++ /dev/null @@ -1,2622 +0,0 @@ -running -96 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -73 -ns -/ -iter -( -+ -/ -- -8 -) -= -5342 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -1 -) -= -24375 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -73 -ns -/ -iter -( -+ -/ -- -9 -) -= -356 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -1 -) -= -1625 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -119 -ns -/ -iter -( -+ -/ -- -11 -) -= -8831 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -25 -312 -ns -/ -iter -( -+ -/ -- -875 -) -= -41427 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -112 -ns -/ -iter -( -+ -/ -- -5 -) -= -526 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -534 -ns -/ -iter -( -+ -/ -- -43 -) -= -61413 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -109 -ns -/ -iter -( -+ -/ -- -9 -) -= -9577 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -23 -892 -ns -/ -iter -( -+ -/ -- -715 -) -= -43889 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -102 -ns -/ -iter -( -+ -/ -- -8 -) -= -509 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -519 -ns -/ -iter -( -+ -/ -- -54 -) -= -63175 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -859 -ns -/ -iter -( -+ -/ -- -202 -) -= -565 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -1 -871 -446 -ns -/ -iter -( -+ -/ -- -99 -961 -) -= -560 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -162 -ns -/ -iter -( -+ -/ -- -20 -) -= -364 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -57 -459 -ns -/ -iter -( -+ -/ -- -4 -672 -) -= -570 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -70 -ns -/ -iter -( -+ -/ -- -8 -) -= -728 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -130 -995 -ns -/ -iter -( -+ -/ -- -4 -935 -) -= -763 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -129 -668 -ns -/ -iter -( -+ -/ -- -8 -852 -) -= -771 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -195 -ns -/ -iter -( -+ -/ -- -16 -) -= -415 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -194 -ns -/ -iter -( -+ -/ -- -22 -) -= -417 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -630 -ns -/ -iter -( -+ -/ -- -61 -) -= -255 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -699 -ns -/ -iter -( -+ -/ -- -147 -) -= -619 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -1 -633 -131 -ns -/ -iter -( -+ -/ -- -65 -889 -) -= -642 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -169 -ns -/ -iter -( -+ -/ -- -18 -) -= -355 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -51 -313 -ns -/ -iter -( -+ -/ -- -1 -855 -) -= -639 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -216 -ns -/ -iter -( -+ -/ -- -13 -) -= -462 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -140 -ns -/ -iter -( -+ -/ -- -6 -) -= -364 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -71 -ns -/ -iter -( -+ -/ -- -2 -) -= -366 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -109 -ns -/ -iter -( -+ -/ -- -9 -) -= -238 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -99 -ns -/ -iter -( -+ -/ -- -7 -) -= -171 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -96 -ns -/ -iter -( -+ -/ -- -5 -) -= -177 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -1 -405 -ns -/ -iter -( -+ -/ -- -134 -) -= -740 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -875 -ns -/ -iter -( -+ -/ -- -168 -) -= -560 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -853 -207 -ns -/ -iter -( -+ -/ -- -103 -218 -) -= -565 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -157 -ns -/ -iter -( -+ -/ -- -11 -) -= -375 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -57 -880 -ns -/ -iter -( -+ -/ -- -5 -319 -) -= -566 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -12 -686 -ns -/ -iter -( -+ -/ -- -536 -) -= -630 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -28 -761 -913 -ns -/ -iter -( -+ -/ -- -1 -447 -326 -) -= -176 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -4 -629 -782 -ns -/ -iter -( -+ -/ -- -142 -214 -) -= -1097 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -4 -692 -819 -ns -/ -iter -( -+ -/ -- -156 -805 -) -= -1083 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -4 -652 -438 -ns -/ -iter -( -+ -/ -- -206 -457 -) -= -1092 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -4 -682 -943 -ns -/ -iter -( -+ -/ -- -176 -335 -) -= -1085 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -4 -646 -162 -ns -/ -iter -( -+ -/ -- -241 -873 -) -= -1094 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -4 -653 -380 -ns -/ -iter -( -+ -/ -- -188 -899 -) -= -1092 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -4 -770 -480 -ns -/ -iter -( -+ -/ -- -238 -930 -) -= -1065 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -4 -671 -427 -ns -/ -iter -( -+ -/ -- -286 -241 -) -= -1088 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -4 -658 -214 -ns -/ -iter -( -+ -/ -- -210 -723 -) -= -1091 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -4 -909 -600 -ns -/ -iter -( -+ -/ -- -417 -894 -) -= -1035 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -4 -910 -285 -ns -/ -iter -( -+ -/ -- -587 -024 -) -= -1035 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -20 -895 -772 -ns -/ -iter -( -+ -/ -- -2 -313 -771 -) -= -243 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -20 -465 -984 -ns -/ -iter -( -+ -/ -- -1 -913 -613 -) -= -248 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -19 -469 -527 -ns -/ -iter -( -+ -/ -- -1 -367 -226 -) -= -261 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -21 -662 -238 -ns -/ -iter -( -+ -/ -- -1 -489 -235 -) -= -234 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -21 -808 -098 -ns -/ -iter -( -+ -/ -- -2 -294 -522 -) -= -233 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -21 -208 -952 -ns -/ -iter -( -+ -/ -- -986 -848 -) -= -239 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -20 -289 -473 -ns -/ -iter -( -+ -/ -- -595 -084 -) -= -250 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -17 -765 -356 -ns -/ -iter -( -+ -/ -- -503 -529 -) -= -286 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -13 -222 -010 -ns -/ -iter -( -+ -/ -- -509 -278 -) -= -384 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -1 -313 -676 -ns -/ -iter -( -+ -/ -- -52 -992 -) -= -452 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -1 -337 -432 -ns -/ -iter -( -+ -/ -- -37 -054 -) -= -444 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -6 -080 -272 -ns -/ -iter -( -+ -/ -- -110 -011 -) -= -97 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -2 -395 -932 -ns -/ -iter -( -+ -/ -- -123 -521 -) -= -248 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -1 -052 -245 -ns -/ -iter -( -+ -/ -- -33 -929 -) -= -565 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -1 -063 -007 -ns -/ -iter -( -+ -/ -- -34 -462 -) -= -559 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -2 -703 -395 -ns -/ -iter -( -+ -/ -- -63 -263 -) -= -220 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -608 -756 -ns -/ -iter -( -+ -/ -- -42 -100 -) -= -369 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -68 -220 -129 -ns -/ -iter -( -+ -/ -- -3 -602 -216 -) -= -8 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -67 -390 -101 -ns -/ -iter -( -+ -/ -- -6 -032 -867 -) -= -8 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -3 -708 -482 -ns -/ -iter -( -+ -/ -- -235 -128 -) -= -160 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -816 -517 -ns -/ -iter -( -+ -/ -- -99 -081 -) -= -211 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -53 -193 -ns -/ -iter -( -+ -/ -- -1 -575 -) -= -11184 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -1 -133 -704 -ns -/ -iter -( -+ -/ -- -36 -634 -) -= -524 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -227 -785 -ns -/ -iter -( -+ -/ -- -31 -742 -) -= -484 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -451 -285 -ns -/ -iter -( -+ -/ -- -103 -766 -) -= -242 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -1 -168 -955 -ns -/ -iter -( -+ -/ -- -87 -785 -) -= -508 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -699 -899 -ns -/ -iter -( -+ -/ -- -91 -762 -) -= -349 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -1 -167 -232 -ns -/ -iter -( -+ -/ -- -51 -695 -) -= -509 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -805 -463 -ns -/ -iter -( -+ -/ -- -74 -631 -) -= -329 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -108 -195 -ns -/ -iter -( -+ -/ -- -3 -815 -) -= -5498 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -360 -092 -ns -/ -iter -( -+ -/ -- -60 -416 -) -= -437 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -40 -376 -ns -/ -iter -( -+ -/ -- -5 -104 -) -= -14734 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -41 -361 -ns -/ -iter -( -+ -/ -- -2 -553 -) -= -14383 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -317 -594 -ns -/ -iter -( -+ -/ -- -168 -248 -) -= -451 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -284 -026 -ns -/ -iter -( -+ -/ -- -92 -188 -) -= -463 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -44 -973 -ns -/ -iter -( -+ -/ -- -5 -888 -) -= -13228 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -341 -867 -ns -/ -iter -( -+ -/ -- -32 -045 -) -= -1740 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -331 -760 -ns -/ -iter -( -+ -/ -- -43 -608 -) -= -1793 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -14 -285 -ns -/ -iter -( -+ -/ -- -760 -) -= -41647 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -1 -342 -144 -ns -/ -iter -( -+ -/ -- -96 -471 -) -= -443 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -722 -919 -ns -/ -iter -( -+ -/ -- -83 -873 -) -= -345 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -2 -866 -258 -ns -/ -iter -( -+ -/ -- -117 -349 -) -= -207 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -151 -020 -ns -/ -iter -( -+ -/ -- -13 -454 -) -= -3939 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -597 -329 -ns -/ -iter -( -+ -/ -- -149 -689 -) -= -372 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -2 -193 -027 -ns -/ -iter -( -+ -/ -- -136 -408 -) -= -271 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -20 -721 -148 -ns -/ -iter -( -+ -/ -- -1 -968 -912 -) -= -28 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -96 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/06/rust b/third_party/rust/regex/record/old-bench-log/06/rust deleted file mode 100644 index d9f28163aa028..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/06/rust +++ /dev/null @@ -1,2872 +0,0 @@ -running -108 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -2 -) -= -17727 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -27 -ns -/ -iter -( -+ -/ -- -2 -) -= -14444 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -1 -) -= -1181 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -26 -ns -/ -iter -( -+ -/ -- -2 -) -= -1000 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -1 -) -= -65687 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -2 -) -= -55189631 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -1 -) -= -3933 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -2049687 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -2 -) -= -24279 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -45 -ns -/ -iter -( -+ -/ -- -4 -) -= -23302133 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -5 -) -= -1209 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -2 -) -= -762511 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -6 -) -= -19830 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -57 -ns -/ -iter -( -+ -/ -- -1 -) -= -18396543 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -4 -) -= -1113 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -6 -) -= -618773 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -1 -) -= -3923 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -203 -ns -/ -iter -( -+ -/ -- -55 -) -= -83126 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -149 -418 -ns -/ -iter -( -+ -/ -- -13 -825 -) -= -669 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -6 -) -= -1306 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -2 -) -= -3521 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -268 -ns -/ -iter -( -+ -/ -- -30 -) -= -600 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -65750 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -15 -) -= -52430200 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -2 -) -= -3750 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -1 -) -= -2049750 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -353 -ns -/ -iter -( -+ -/ -- -26 -) -= -283 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -97 -ns -/ -iter -( -+ -/ -- -9 -) -= -525 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -5 -) -= -448 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -60 -ns -/ -iter -( -+ -/ -- -6 -) -= -433 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -4 -) -= -395 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -2 -) -= -369 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -5 -) -= -16774 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -650 -ns -/ -iter -( -+ -/ -- -176 -) -= -636 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -635 -447 -ns -/ -iter -( -+ -/ -- -97 -611 -) -= -641 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -109 -ns -/ -iter -( -+ -/ -- -9 -) -= -541 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -50 -991 -ns -/ -iter -( -+ -/ -- -4 -031 -) -= -643 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -155 -ns -/ -iter -( -+ -/ -- -8 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -254 -ns -/ -iter -( -+ -/ -- -489 -) -= -1880 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -91 -124 -ns -/ -iter -( -+ -/ -- -4 -584 -) -= -87792 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -10 -681 -ns -/ -iter -( -+ -/ -- -420 -) -= -74900 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -3 -240 -ns -/ -iter -( -+ -/ -- -395 -) -= -24694 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -403 -ns -/ -iter -( -+ -/ -- -48 -) -= -19878 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -303 -ns -/ -iter -( -+ -/ -- -27 -) -= -2676 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -272 -ns -/ -iter -( -+ -/ -- -27 -) -= -334 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -264 -ns -/ -iter -( -+ -/ -- -32 -) -= -71 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -269 -ns -/ -iter -( -+ -/ -- -25 -) -= -100 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -264 -ns -/ -iter -( -+ -/ -- -26 -) -= -132 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -271 -ns -/ -iter -( -+ -/ -- -28 -) -= -158 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -13 -700 -405 -ns -/ -iter -( -+ -/ -- -647 -840 -) -= -371 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -806 -342 -ns -/ -iter -( -+ -/ -- -48 -014 -) -= -6304 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -794 -403 -ns -/ -iter -( -+ -/ -- -40 -393 -) -= -6399 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -801 -963 -ns -/ -iter -( -+ -/ -- -46 -164 -) -= -6338 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -779 -768 -ns -/ -iter -( -+ -/ -- -81 -505 -) -= -6519 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -777 -024 -ns -/ -iter -( -+ -/ -- -52 -795 -) -= -6542 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -769 -862 -ns -/ -iter -( -+ -/ -- -48 -980 -) -= -6603 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -779 -754 -ns -/ -iter -( -+ -/ -- -39 -784 -) -= -6519 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -769 -400 -ns -/ -iter -( -+ -/ -- -69 -980 -) -= -6606 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -771 -457 -ns -/ -iter -( -+ -/ -- -40 -490 -) -= -6589 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -808 -468 -ns -/ -iter -( -+ -/ -- -53 -093 -) -= -6287 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -771 -869 -ns -/ -iter -( -+ -/ -- -50 -966 -) -= -6585 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -3 -093 -422 -ns -/ -iter -( -+ -/ -- -222 -818 -) -= -1643 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -6 -520 -178 -ns -/ -iter -( -+ -/ -- -400 -704 -) -= -779 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -7 -297 -818 -ns -/ -iter -( -+ -/ -- -319 -866 -) -= -696 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -7 -356 -045 -ns -/ -iter -( -+ -/ -- -530 -375 -) -= -691 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -5 -977 -343 -ns -/ -iter -( -+ -/ -- -296 -375 -) -= -850 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -6 -045 -776 -ns -/ -iter -( -+ -/ -- -270 -954 -) -= -840 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -5 -447 -060 -ns -/ -iter -( -+ -/ -- -223 -542 -) -= -933 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -5 -615 -676 -ns -/ -iter -( -+ -/ -- -419 -756 -) -= -905 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -5 -457 -949 -ns -/ -iter -( -+ -/ -- -439 -821 -) -= -931 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -957 -660 -ns -/ -iter -( -+ -/ -- -96 -491 -) -= -621 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -65 -680 -ns -/ -iter -( -+ -/ -- -3 -085 -) -= -9058 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -151 -577 -ns -/ -iter -( -+ -/ -- -70 -114 -) -= -276 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -836 -942 -ns -/ -iter -( -+ -/ -- -81 -010 -) -= -710 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -137 -441 -ns -/ -iter -( -+ -/ -- -14 -157 -) -= -4328 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -514 -100 -ns -/ -iter -( -+ -/ -- -48 -210 -) -= -1157 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -409 -126 -ns -/ -iter -( -+ -/ -- -23 -370 -) -= -1454 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -117 -457 -ns -/ -iter -( -+ -/ -- -53 -545 -) -= -532 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -23 -152 -671 -ns -/ -iter -( -+ -/ -- -1 -002 -203 -) -= -25 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -22 -521 -833 -ns -/ -iter -( -+ -/ -- -1 -178 -375 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -841 -871 -ns -/ -iter -( -+ -/ -- -108 -471 -) -= -323 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -946 -126 -ns -/ -iter -( -+ -/ -- -53 -405 -) -= -628 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -25 -830 -ns -/ -iter -( -+ -/ -- -1 -054 -) -= -23032 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -116 -879 -ns -/ -iter -( -+ -/ -- -6 -000 -) -= -5090 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -125 -746 -ns -/ -iter -( -+ -/ -- -7 -121 -) -= -4731 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -203 -114 -ns -/ -iter -( -+ -/ -- -72 -037 -) -= -494 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -156 -208 -ns -/ -iter -( -+ -/ -- -5 -188 -) -= -3808 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -222 -618 -ns -/ -iter -( -+ -/ -- -30 -017 -) -= -2672 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -133 -440 -ns -/ -iter -( -+ -/ -- -14 -831 -) -= -4458 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -558 -482 -ns -/ -iter -( -+ -/ -- -22 -435 -) -= -1065 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -30 -800 -ns -/ -iter -( -+ -/ -- -2 -933 -) -= -19316 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -190 -736 -ns -/ -iter -( -+ -/ -- -24 -310 -) -= -3119 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -56 -238 -ns -/ -iter -( -+ -/ -- -3 -310 -) -= -10578 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -24 -129 -ns -/ -iter -( -+ -/ -- -2 -662 -) -= -24656 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -174 -649 -ns -/ -iter -( -+ -/ -- -13 -487 -) -= -3406 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -157 -674 -ns -/ -iter -( -+ -/ -- -7 -888 -) -= -3773 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -74 -637 -ns -/ -iter -( -+ -/ -- -6 -523 -) -= -7971 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -15 -140 -ns -/ -iter -( -+ -/ -- -969 -) -= -39295 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -305 -112 -ns -/ -iter -( -+ -/ -- -31 -314 -) -= -1949 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -15 -539 -ns -/ -iter -( -+ -/ -- -1 -269 -) -= -38286 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -482 -180 -ns -/ -iter -( -+ -/ -- -33 -736 -) -= -1233 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -78 -428 -426 -ns -/ -iter -( -+ -/ -- -6 -705 -217 -) -= -7 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -576 -511 -ns -/ -iter -( -+ -/ -- -21 -735 -) -= -1031 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -413 -565 -ns -/ -iter -( -+ -/ -- -42 -941 -) -= -1438 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -34 -491 -ns -/ -iter -( -+ -/ -- -1 -901 -) -= -17248 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -061 -365 -ns -/ -iter -( -+ -/ -- -66 -639 -) -= -560 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -763 -795 -ns -/ -iter -( -+ -/ -- -83 -031 -) -= -337 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -9 -281 -896 -ns -/ -iter -( -+ -/ -- -934 -308 -) -= -64 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -108 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/boost b/third_party/rust/regex/record/old-bench-log/07/boost deleted file mode 100644 index e0c70d71662c8..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/boost +++ /dev/null @@ -1,2502 +0,0 @@ -running -92 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -174 -ns -/ -iter -( -+ -/ -- -0 -) -= -2241 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -329 -ns -/ -iter -( -+ -/ -- -3 -) -= -1185 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -168 -ns -/ -iter -( -+ -/ -- -0 -) -= -154 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -121 -ns -/ -iter -( -+ -/ -- -0 -) -= -214 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -660 -ns -/ -iter -( -+ -/ -- -3 -) -= -1592 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -514 -707 -ns -/ -iter -( -+ -/ -- -2 -689 -) -= -2037 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -170 -ns -/ -iter -( -+ -/ -- -2 -) -= -347 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -16 -208 -ns -/ -iter -( -+ -/ -- -99 -) -= -2023 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -756 -ns -/ -iter -( -+ -/ -- -1 -) -= -1380 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -514 -816 -ns -/ -iter -( -+ -/ -- -2 -832 -) -= -2036 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -271 -ns -/ -iter -( -+ -/ -- -3 -) -= -191 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -16 -316 -ns -/ -iter -( -+ -/ -- -93 -) -= -2009 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -63 -089 -ns -/ -iter -( -+ -/ -- -594 -) -= -16 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -66 -537 -328 -ns -/ -iter -( -+ -/ -- -866 -695 -) -= -15 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -2 -125 -ns -/ -iter -( -+ -/ -- -8 -) -= -27 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -2 -075 -568 -ns -/ -iter -( -+ -/ -- -6 -634 -) -= -15 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -143 -ns -/ -iter -( -+ -/ -- -1 -) -= -356 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -6 -557 -839 -ns -/ -iter -( -+ -/ -- -27 -779 -) -= -15 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -6 -557 -332 -ns -/ -iter -( -+ -/ -- -101 -494 -) -= -15 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -157 -ns -/ -iter -( -+ -/ -- -0 -) -= -515 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -157 -ns -/ -iter -( -+ -/ -- -4 -) -= -515 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -665 -ns -/ -iter -( -+ -/ -- -2 -) -= -1581 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -514 -869 -ns -/ -iter -( -+ -/ -- -5 -832 -) -= -2036 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -167 -ns -/ -iter -( -+ -/ -- -1 -) -= -359 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -16 -253 -ns -/ -iter -( -+ -/ -- -74 -) -= -2017 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -1 -717 -ns -/ -iter -( -+ -/ -- -13 -) -= -58 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -1 -084 -ns -/ -iter -( -+ -/ -- -16 -) -= -47 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -169 -ns -/ -iter -( -+ -/ -- -2 -) -= -153 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -169 -ns -/ -iter -( -+ -/ -- -6 -) -= -153 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -1 -105 -ns -/ -iter -( -+ -/ -- -2 -) -= -15 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -1 -076 -ns -/ -iter -( -+ -/ -- -10 -) -= -15 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -4 -935 -ns -/ -iter -( -+ -/ -- -39 -) -= -210 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -63 -076 -ns -/ -iter -( -+ -/ -- -226 -) -= -16 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -68 -534 -102 -ns -/ -iter -( -+ -/ -- -125 -043 -) -= -15 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -2 -134 -ns -/ -iter -( -+ -/ -- -8 -) -= -27 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -2 -074 -582 -ns -/ -iter -( -+ -/ -- -5 -943 -) -= -15 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -001 -ns -/ -iter -( -+ -/ -- -5 -) -= -1999 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -942 -765 -ns -/ -iter -( -+ -/ -- -21 -828 -) -= -392 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -6 -241 -036 -ns -/ -iter -( -+ -/ -- -13 -806 -) -= -814 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -6 -247 -896 -ns -/ -iter -( -+ -/ -- -28 -406 -) -= -813 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -6 -240 -960 -ns -/ -iter -( -+ -/ -- -20 -660 -) -= -814 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -6 -245 -156 -ns -/ -iter -( -+ -/ -- -17 -639 -) -= -813 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -6 -276 -881 -ns -/ -iter -( -+ -/ -- -14 -851 -) -= -809 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -6 -249 -549 -ns -/ -iter -( -+ -/ -- -30 -600 -) -= -813 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -6 -251 -942 -ns -/ -iter -( -+ -/ -- -33 -889 -) -= -813 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -6 -244 -011 -ns -/ -iter -( -+ -/ -- -11 -642 -) -= -814 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -6 -283 -445 -ns -/ -iter -( -+ -/ -- -11 -693 -) -= -809 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -6 -247 -310 -ns -/ -iter -( -+ -/ -- -11 -590 -) -= -813 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -6 -249 -184 -ns -/ -iter -( -+ -/ -- -8 -159 -) -= -813 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -73 -947 -890 -ns -/ -iter -( -+ -/ -- -930 -039 -) -= -68 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -108 -486 -922 -ns -/ -iter -( -+ -/ -- -181 -287 -) -= -46 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -93 -241 -161 -ns -/ -iter -( -+ -/ -- -143 -224 -) -= -54 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -75 -615 -061 -ns -/ -iter -( -+ -/ -- -107 -918 -) -= -67 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -74 -484 -623 -ns -/ -iter -( -+ -/ -- -121 -807 -) -= -68 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -74 -594 -078 -ns -/ -iter -( -+ -/ -- -121 -252 -) -= -68 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -77 -064 -066 -ns -/ -iter -( -+ -/ -- -123 -262 -) -= -65 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -87 -267 -656 -ns -/ -iter -( -+ -/ -- -128 -639 -) -= -58 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -98 -197 -000 -ns -/ -iter -( -+ -/ -- -149 -379 -) -= -51 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -7 -100 -744 -ns -/ -iter -( -+ -/ -- -29 -939 -) -= -83 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -7 -120 -564 -ns -/ -iter -( -+ -/ -- -32 -659 -) -= -83 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -3 -777 -458 -ns -/ -iter -( -+ -/ -- -8 -802 -) -= -157 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -282 -ns -/ -iter -( -+ -/ -- -2 -) -= -2109691 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -389 -335 -ns -/ -iter -( -+ -/ -- -1 -472 -) -= -1528 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -6 -256 -416 -ns -/ -iter -( -+ -/ -- -8 -735 -) -= -95 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -7 -572 -167 -ns -/ -iter -( -+ -/ -- -15 -521 -) -= -78 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -343 -402 -ns -/ -iter -( -+ -/ -- -3 -693 -) -= -1732 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -347 -605 -ns -/ -iter -( -+ -/ -- -916 -) -= -1711 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -420 -500 -ns -/ -iter -( -+ -/ -- -2 -846 -) -= -1414 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -762 -684 -ns -/ -iter -( -+ -/ -- -3 -834 -) -= -780 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -9 -980 -804 -ns -/ -iter -( -+ -/ -- -49 -424 -) -= -59 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -431 -744 -ns -/ -iter -( -+ -/ -- -682 -) -= -1377 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -3 -464 -135 -ns -/ -iter -( -+ -/ -- -11 -476 -) -= -171 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -472 -923 -ns -/ -iter -( -+ -/ -- -846 -) -= -1257 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -4 -338 -924 -ns -/ -iter -( -+ -/ -- -31 -118 -) -= -137 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -378 -950 -ns -/ -iter -( -+ -/ -- -865 -) -= -1569 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -952 -035 -ns -/ -iter -( -+ -/ -- -8 -233 -) -= -304 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -324 -845 -ns -/ -iter -( -+ -/ -- -8 -376 -) -= -1831 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -324 -647 -ns -/ -iter -( -+ -/ -- -2 -901 -) -= -1832 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -870 -400 -ns -/ -iter -( -+ -/ -- -10 -609 -) -= -318 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -814 -172 -ns -/ -iter -( -+ -/ -- -16 -455 -) -= -327 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -326 -252 -ns -/ -iter -( -+ -/ -- -1 -557 -) -= -1823 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -1 -154 -445 -ns -/ -iter -( -+ -/ -- -8 -544 -) -= -515 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -1 -154 -314 -ns -/ -iter -( -+ -/ -- -5 -467 -) -= -515 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -295 -301 -ns -/ -iter -( -+ -/ -- -906 -) -= -2014 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -863 -138 -ns -/ -iter -( -+ -/ -- -3 -072 -) -= -689 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -13 -594 -294 -ns -/ -iter -( -+ -/ -- -40 -354 -) -= -43 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -2 -171 -731 -ns -/ -iter -( -+ -/ -- -7 -148 -) -= -273 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -3 -556 -278 -ns -/ -iter -( -+ -/ -- -7 -269 -) -= -167 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -404 -851 -ns -/ -iter -( -+ -/ -- -865 -) -= -1469 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -139 -597 -ns -/ -iter -( -+ -/ -- -7 -427 -) -= -278 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -7 -824 -965 -ns -/ -iter -( -+ -/ -- -30 -691 -) -= -76 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -18 -386 -285 -ns -/ -iter -( -+ -/ -- -34 -161 -) -= -32 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -92 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/dphobos-dmd b/third_party/rust/regex/record/old-bench-log/07/dphobos-dmd deleted file mode 100644 index 574bbe826265d..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/dphobos-dmd +++ /dev/null @@ -1,2575 +0,0 @@ -running -95 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -365 -ns -/ -iter -( -+ -/ -- -2 -) -= -1068 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -300 -ns -/ -iter -( -+ -/ -- -0 -) -= -1300 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -364 -ns -/ -iter -( -+ -/ -- -2 -) -= -71 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -306 -ns -/ -iter -( -+ -/ -- -9 -) -= -84 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -768 -ns -/ -iter -( -+ -/ -- -5 -) -= -1368 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -17 -062 -ns -/ -iter -( -+ -/ -- -252 -) -= -61458 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -759 -ns -/ -iter -( -+ -/ -- -7 -) -= -77 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -1 -095 -ns -/ -iter -( -+ -/ -- -20 -) -= -29949 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -723 -ns -/ -iter -( -+ -/ -- -1 -) -= -1443 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -17 -021 -ns -/ -iter -( -+ -/ -- -229 -) -= -61606 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -714 -ns -/ -iter -( -+ -/ -- -1 -) -= -72 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -1 -052 -ns -/ -iter -( -+ -/ -- -12 -) -= -31167 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -17 -044 -ns -/ -iter -( -+ -/ -- -176 -) -= -61 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -17 -965 -420 -ns -/ -iter -( -+ -/ -- -72 -226 -) -= -58 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -2 -171 -ns -/ -iter -( -+ -/ -- -2 -) -= -27 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -561 -207 -ns -/ -iter -( -+ -/ -- -5 -654 -) -= -58 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -240 -ns -/ -iter -( -+ -/ -- -0 -) -= -212 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -76 -640 -ns -/ -iter -( -+ -/ -- -1 -043 -) -= -1304 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -76 -747 -ns -/ -iter -( -+ -/ -- -3 -299 -) -= -1302 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -344 -ns -/ -iter -( -+ -/ -- -1 -) -= -235 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -306 -ns -/ -iter -( -+ -/ -- -9 -) -= -264 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -435 -ns -/ -iter -( -+ -/ -- -9 -) -= -112 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -480 -ns -/ -iter -( -+ -/ -- -16 -) -= -710 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -564 -378 -ns -/ -iter -( -+ -/ -- -18 -695 -) -= -1857 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -941 -ns -/ -iter -( -+ -/ -- -32 -) -= -63 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -18 -465 -ns -/ -iter -( -+ -/ -- -116 -) -= -1776 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -367 -476 -ns -/ -iter -( -+ -/ -- -15 -176 -) -test -misc -: -: -not_literal -. -. -. -bench -: -1 -165 -ns -/ -iter -( -+ -/ -- -9 -) -= -43 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -596 -ns -/ -iter -( -+ -/ -- -2 -) -= -43 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -602 -ns -/ -iter -( -+ -/ -- -6 -) -= -43 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -1 -068 -ns -/ -iter -( -+ -/ -- -3 -) -= -15 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -1 -434 -ns -/ -iter -( -+ -/ -- -11 -) -= -11 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -36 -539 -ns -/ -iter -( -+ -/ -- -281 -) -= -28 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -17 -086 -ns -/ -iter -( -+ -/ -- -94 -) -= -61 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -17 -973 -007 -ns -/ -iter -( -+ -/ -- -64 -010 -) -= -58 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -2 -200 -ns -/ -iter -( -+ -/ -- -16 -) -= -26 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -561 -371 -ns -/ -iter -( -+ -/ -- -8 -688 -) -= -58 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -606 -ns -/ -iter -( -+ -/ -- -16 -) -= -1736 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -31 -579 -756 -ns -/ -iter -( -+ -/ -- -121 -047 -) -= -160 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -7 -930 -333 -ns -/ -iter -( -+ -/ -- -27 -118 -) -= -641 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -7 -942 -534 -ns -/ -iter -( -+ -/ -- -36 -470 -) -= -640 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -7 -934 -646 -ns -/ -iter -( -+ -/ -- -42 -013 -) -= -640 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -7 -947 -802 -ns -/ -iter -( -+ -/ -- -53 -427 -) -= -639 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -7 -941 -691 -ns -/ -iter -( -+ -/ -- -122 -303 -) -= -640 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -7 -928 -228 -ns -/ -iter -( -+ -/ -- -30 -493 -) -= -641 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -7 -936 -901 -ns -/ -iter -( -+ -/ -- -37 -894 -) -= -640 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -7 -936 -211 -ns -/ -iter -( -+ -/ -- -46 -269 -) -= -640 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -7 -946 -477 -ns -/ -iter -( -+ -/ -- -62 -660 -) -= -639 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -7 -930 -830 -ns -/ -iter -( -+ -/ -- -31 -234 -) -= -640 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -7 -937 -951 -ns -/ -iter -( -+ -/ -- -36 -425 -) -= -640 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -5 -104 -224 -ns -/ -iter -( -+ -/ -- -26 -612 -) -= -995 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -6 -847 -162 -ns -/ -iter -( -+ -/ -- -31 -233 -) -= -742 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -11 -153 -739 -ns -/ -iter -( -+ -/ -- -114 -193 -) -= -455 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -9 -665 -797 -ns -/ -iter -( -+ -/ -- -47 -148 -) -= -525 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -9 -645 -193 -ns -/ -iter -( -+ -/ -- -35 -250 -) -= -527 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -7 -280 -069 -ns -/ -iter -( -+ -/ -- -21 -171 -) -= -698 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -7 -841 -177 -ns -/ -iter -( -+ -/ -- -20 -797 -) -= -648 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -9 -783 -978 -ns -/ -iter -( -+ -/ -- -35 -231 -) -= -519 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -19 -157 -329 -ns -/ -iter -( -+ -/ -- -445 -911 -) -= -265 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -20 -995 -307 -ns -/ -iter -( -+ -/ -- -258 -419 -) -= -28 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -20 -899 -416 -ns -/ -iter -( -+ -/ -- -122 -256 -) -= -28 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -904 -439 -ns -/ -iter -( -+ -/ -- -6 -934 -) -= -657 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -103 -706 -930 -ns -/ -iter -( -+ -/ -- -176 -711 -) -= -5 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -14 -927 -612 -ns -/ -iter -( -+ -/ -- -90 -346 -) -= -39 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -19 -743 -662 -ns -/ -iter -( -+ -/ -- -78 -506 -) -= -30 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -112 -708 -213 -ns -/ -iter -( -+ -/ -- -251 -690 -) -= -5 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -111 -058 -829 -ns -/ -iter -( -+ -/ -- -192 -793 -) -= -5 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -4 -072 -062 -ns -/ -iter -( -+ -/ -- -20 -273 -) -= -146 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -399 -796 -ns -/ -iter -( -+ -/ -- -4 -222 -) -= -1488 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -411 -415 -ns -/ -iter -( -+ -/ -- -2 -257 -) -= -1446 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -626 -671 -ns -/ -iter -( -+ -/ -- -5 -745 -) -= -949 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -086 -570 -ns -/ -iter -( -+ -/ -- -6 -105 -) -= -547 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -827 -028 -ns -/ -iter -( -+ -/ -- -12 -788 -) -= -325 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -687 -454 -ns -/ -iter -( -+ -/ -- -11 -421 -) -= -865 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -943 -925 -ns -/ -iter -( -+ -/ -- -4 -108 -) -= -630 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -734 -969 -ns -/ -iter -( -+ -/ -- -7 -215 -) -= -809 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -895 -903 -ns -/ -iter -( -+ -/ -- -5 -647 -) -= -664 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -199 -880 -ns -/ -iter -( -+ -/ -- -1 -654 -) -= -2976 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -529 -590 -ns -/ -iter -( -+ -/ -- -1 -288 -) -= -1123 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -57 -720 -ns -/ -iter -( -+ -/ -- -555 -) -= -10307 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -67 -596 -ns -/ -iter -( -+ -/ -- -580 -) -= -8801 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -393 -903 -ns -/ -iter -( -+ -/ -- -2 -700 -) -= -1510 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -373 -411 -ns -/ -iter -( -+ -/ -- -3 -264 -) -= -1593 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -79 -175 -ns -/ -iter -( -+ -/ -- -1 -288 -) -= -7514 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -276 -503 -ns -/ -iter -( -+ -/ -- -2 -155 -) -= -2151 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -276 -535 -ns -/ -iter -( -+ -/ -- -416 -) -= -2151 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -10 -535 -ns -/ -iter -( -+ -/ -- -105 -) -= -56472 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -5 -746 -202 -ns -/ -iter -( -+ -/ -- -33 -993 -) -= -103 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -46 -124 -528 -ns -/ -iter -( -+ -/ -- -125 -861 -) -= -12 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -2 -527 -960 -ns -/ -iter -( -+ -/ -- -12 -351 -) -= -235 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -3 -210 -112 -ns -/ -iter -( -+ -/ -- -10 -799 -) -= -185 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -240 -272 -ns -/ -iter -( -+ -/ -- -3 -902 -) -= -2476 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -3 -511 -711 -ns -/ -iter -( -+ -/ -- -17 -181 -) -= -169 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -29 -535 -089 -ns -/ -iter -( -+ -/ -- -95 -201 -) -= -20 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -43 -341 -782 -ns -/ -iter -( -+ -/ -- -110 -038 -) -= -13 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -95 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/dphobos-dmd-ct b/third_party/rust/regex/record/old-bench-log/07/dphobos-dmd-ct deleted file mode 100644 index 7c2de80809909..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/dphobos-dmd-ct +++ /dev/null @@ -1,2515 +0,0 @@ -running -93 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -354 -ns -/ -iter -( -+ -/ -- -25 -) -= -1101 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -314 -ns -/ -iter -( -+ -/ -- -3 -) -= -1242 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -331 -ns -/ -iter -( -+ -/ -- -0 -) -= -78 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -314 -ns -/ -iter -( -+ -/ -- -4 -) -= -82 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -430 -ns -/ -iter -( -+ -/ -- -2 -) -= -2444 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -16 -692 -ns -/ -iter -( -+ -/ -- -222 -) -= -62820 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -420 -ns -/ -iter -( -+ -/ -- -4 -) -= -140 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -755 -ns -/ -iter -( -+ -/ -- -5 -) -= -43437 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -407 -ns -/ -iter -( -+ -/ -- -10 -) -= -2565 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -16 -670 -ns -/ -iter -( -+ -/ -- -205 -) -= -62903 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -389 -ns -/ -iter -( -+ -/ -- -0 -) -= -133 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -732 -ns -/ -iter -( -+ -/ -- -6 -) -= -44792 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -35 -518 -ns -/ -iter -( -+ -/ -- -346 -) -= -29 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -31 -657 -473 -ns -/ -iter -( -+ -/ -- -512 -618 -) -= -33 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -1 -057 -ns -/ -iter -( -+ -/ -- -7 -) -= -55 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -950 -905 -ns -/ -iter -( -+ -/ -- -13 -239 -) -= -34 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -320 -ns -/ -iter -( -+ -/ -- -3 -) -= -159 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -73 -954 -ns -/ -iter -( -+ -/ -- -331 -) -= -1352 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -73 -915 -ns -/ -iter -( -+ -/ -- -199 -) -= -1352 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -374 -ns -/ -iter -( -+ -/ -- -3 -) -= -216 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -372 -ns -/ -iter -( -+ -/ -- -0 -) -= -217 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -631 -ns -/ -iter -( -+ -/ -- -8 -) -= -98 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -965 -ns -/ -iter -( -+ -/ -- -10 -) -= -1090 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -563 -242 -ns -/ -iter -( -+ -/ -- -6 -767 -) -= -1861 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -434 -ns -/ -iter -( -+ -/ -- -3 -) -= -138 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -17 -976 -ns -/ -iter -( -+ -/ -- -137 -) -= -1824 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -1 -063 -ns -/ -iter -( -+ -/ -- -2 -) -= -47 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -405 -ns -/ -iter -( -+ -/ -- -4 -) -= -64 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -410 -ns -/ -iter -( -+ -/ -- -2 -) -= -63 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -539 -ns -/ -iter -( -+ -/ -- -12 -) -= -31 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -534 -ns -/ -iter -( -+ -/ -- -1 -) -= -31 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -75 -108 -ns -/ -iter -( -+ -/ -- -699 -) -= -13 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -34 -681 -ns -/ -iter -( -+ -/ -- -268 -) -= -30 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -30 -579 -065 -ns -/ -iter -( -+ -/ -- -389 -443 -) -= -34 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -1 -025 -ns -/ -iter -( -+ -/ -- -22 -) -= -57 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -920 -515 -ns -/ -iter -( -+ -/ -- -26 -281 -) -= -35 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -607 -ns -/ -iter -( -+ -/ -- -36 -) -= -1736 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -34 -122 -227 -ns -/ -iter -( -+ -/ -- -842 -345 -) -= -148 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -9 -932 -271 -ns -/ -iter -( -+ -/ -- -86 -915 -) -= -511 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -9 -977 -738 -ns -/ -iter -( -+ -/ -- -51 -656 -) -= -509 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -9 -945 -085 -ns -/ -iter -( -+ -/ -- -53 -175 -) -= -511 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -9 -928 -284 -ns -/ -iter -( -+ -/ -- -32 -335 -) -= -512 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -9 -968 -901 -ns -/ -iter -( -+ -/ -- -41 -254 -) -= -509 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -9 -912 -463 -ns -/ -iter -( -+ -/ -- -28 -171 -) -= -512 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -9 -948 -128 -ns -/ -iter -( -+ -/ -- -22 -949 -) -= -510 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -9 -916 -200 -ns -/ -iter -( -+ -/ -- -28 -947 -) -= -512 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -9 -996 -277 -ns -/ -iter -( -+ -/ -- -37 -585 -) -= -508 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -9 -974 -849 -ns -/ -iter -( -+ -/ -- -41 -503 -) -= -509 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -9 -961 -948 -ns -/ -iter -( -+ -/ -- -28 -254 -) -= -510 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -3 -504 -049 -ns -/ -iter -( -+ -/ -- -15 -090 -) -= -1450 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -800 -264 -ns -/ -iter -( -+ -/ -- -12 -123 -) -= -1337 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -4 -932 -027 -ns -/ -iter -( -+ -/ -- -15 -553 -) -= -1030 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -4 -709 -109 -ns -/ -iter -( -+ -/ -- -15 -213 -) -= -1079 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -4 -918 -928 -ns -/ -iter -( -+ -/ -- -19 -196 -) -= -1033 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -4 -244 -250 -ns -/ -iter -( -+ -/ -- -24 -367 -) -= -1197 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -4 -245 -530 -ns -/ -iter -( -+ -/ -- -16 -178 -) -= -1197 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -4 -205 -036 -ns -/ -iter -( -+ -/ -- -10 -733 -) -= -1208 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -864 -771 -ns -/ -iter -( -+ -/ -- -11 -864 -) -= -1315 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -22 -490 -817 -ns -/ -iter -( -+ -/ -- -571 -510 -) -= -26 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -22 -603 -264 -ns -/ -iter -( -+ -/ -- -74 -703 -) -= -26 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -519 -710 -ns -/ -iter -( -+ -/ -- -5 -878 -) -= -1144 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -9 -237 -783 -ns -/ -iter -( -+ -/ -- -30 -188 -) -= -64 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -12 -074 -301 -ns -/ -iter -( -+ -/ -- -30 -860 -) -= -49 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -137 -678 -575 -ns -/ -iter -( -+ -/ -- -131 -761 -) -= -4 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -135 -414 -657 -ns -/ -iter -( -+ -/ -- -134 -307 -) -= -4 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -5 -004 -996 -ns -/ -iter -( -+ -/ -- -23 -224 -) -= -118 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -341 -556 -ns -/ -iter -( -+ -/ -- -1 -500 -) -= -1741 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -378 -291 -ns -/ -iter -( -+ -/ -- -1 -545 -) -= -1572 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -528 -403 -ns -/ -iter -( -+ -/ -- -2 -273 -) -= -1125 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -685 -634 -ns -/ -iter -( -+ -/ -- -17 -205 -) -= -867 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -825 -069 -ns -/ -iter -( -+ -/ -- -10 -490 -) -= -721 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -555 -717 -ns -/ -iter -( -+ -/ -- -3 -223 -) -= -1070 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -649 -913 -ns -/ -iter -( -+ -/ -- -4 -543 -) -= -915 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -570 -036 -ns -/ -iter -( -+ -/ -- -543 -) -= -1043 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -580 -445 -ns -/ -iter -( -+ -/ -- -2 -100 -) -= -1024 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -185 -140 -ns -/ -iter -( -+ -/ -- -2 -100 -) -= -3213 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -479 -902 -ns -/ -iter -( -+ -/ -- -5 -898 -) -= -1239 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -51 -053 -ns -/ -iter -( -+ -/ -- -491 -) -= -11653 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -50 -722 -ns -/ -iter -( -+ -/ -- -296 -) -= -11729 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -355 -142 -ns -/ -iter -( -+ -/ -- -1 -424 -) -= -1675 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -354 -932 -ns -/ -iter -( -+ -/ -- -1 -554 -) -= -1676 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -56 -972 -ns -/ -iter -( -+ -/ -- -271 -) -= -10442 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -274 -260 -ns -/ -iter -( -+ -/ -- -3 -092 -) -= -2169 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -273 -984 -ns -/ -iter -( -+ -/ -- -2 -202 -) -= -2171 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -10 -444 -ns -/ -iter -( -+ -/ -- -68 -) -= -56964 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -2 -755 -414 -ns -/ -iter -( -+ -/ -- -11 -488 -) -= -215 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -21 -585 -138 -ns -/ -iter -( -+ -/ -- -50 -347 -) -= -27 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -2 -835 -360 -ns -/ -iter -( -+ -/ -- -10 -083 -) -= -209 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -3 -060 -088 -ns -/ -iter -( -+ -/ -- -10 -321 -) -= -194 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -272 -416 -ns -/ -iter -( -+ -/ -- -3 -308 -) -= -2183 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -991 -214 -ns -/ -iter -( -+ -/ -- -27 -223 -) -= -198 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -30 -726 -303 -ns -/ -iter -( -+ -/ -- -83 -743 -) -= -19 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -42 -256 -710 -ns -/ -iter -( -+ -/ -- -88 -302 -) -= -14 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -93 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/oniguruma b/third_party/rust/regex/record/old-bench-log/07/oniguruma deleted file mode 100644 index bd95c64d21df3..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/oniguruma +++ /dev/null @@ -1,2568 +0,0 @@ -running -94 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -129 -ns -/ -iter -( -+ -/ -- -3 -) -= -3023 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -402 -ns -/ -iter -( -+ -/ -- -1 -) -= -970 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -130 -ns -/ -iter -( -+ -/ -- -1 -) -= -200 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -0 -) -= -530 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -281 -ns -/ -iter -( -+ -/ -- -3 -) -= -3740 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -119 -847 -ns -/ -iter -( -+ -/ -- -713 -) -= -8749 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -154 -ns -/ -iter -( -+ -/ -- -4 -) -= -383 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -3 -985 -ns -/ -iter -( -+ -/ -- -24 -) -= -8229 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -3 -472 -ns -/ -iter -( -+ -/ -- -11 -) -= -300 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -3 -385 -764 -ns -/ -iter -( -+ -/ -- -6 -630 -) -= -309 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -283 -ns -/ -iter -( -+ -/ -- -6 -) -= -183 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -105 -977 -ns -/ -iter -( -+ -/ -- -319 -) -= -309 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -106 -973 -ns -/ -iter -( -+ -/ -- -1 -091 -) -= -9 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -114 -602 -847 -ns -/ -iter -( -+ -/ -- -336 -051 -) -= -9 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -3 -569 -ns -/ -iter -( -+ -/ -- -3 -) -= -16 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -3 -570 -108 -ns -/ -iter -( -+ -/ -- -17 -057 -) -= -9 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -287 -ns -/ -iter -( -+ -/ -- -1 -) -= -177 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -5 -430 -190 -ns -/ -iter -( -+ -/ -- -271 -737 -) -= -18 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -5 -651 -748 -ns -/ -iter -( -+ -/ -- -260 -960 -) -= -17 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -369 -ns -/ -iter -( -+ -/ -- -0 -) -= -219 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -370 -ns -/ -iter -( -+ -/ -- -8 -) -= -218 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -1 -600 -ns -/ -iter -( -+ -/ -- -24 -) -= -100 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -295 -ns -/ -iter -( -+ -/ -- -4 -) -= -3566 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -119 -845 -ns -/ -iter -( -+ -/ -- -707 -) -= -8749 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -166 -ns -/ -iter -( -+ -/ -- -0 -) -= -361 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -3 -995 -ns -/ -iter -( -+ -/ -- -30 -) -= -8209 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -365 -ns -/ -iter -( -+ -/ -- -1 -) -= -139 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -155 -ns -/ -iter -( -+ -/ -- -0 -) -= -167 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -162 -ns -/ -iter -( -+ -/ -- -0 -) -= -160 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -279 -ns -/ -iter -( -+ -/ -- -0 -) -= -60 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -269 -ns -/ -iter -( -+ -/ -- -3 -) -= -63 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -227 -630 -ns -/ -iter -( -+ -/ -- -963 -) -= -4 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -106 -964 -ns -/ -iter -( -+ -/ -- -1 -199 -) -= -9 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -114 -622 -989 -ns -/ -iter -( -+ -/ -- -206 -430 -) -= -9 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -3 -477 -ns -/ -iter -( -+ -/ -- -13 -) -= -16 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -3 -580 -927 -ns -/ -iter -( -+ -/ -- -15 -784 -) -= -9 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -23 -518 -ns -/ -iter -( -+ -/ -- -105 -) -= -340 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -33 -300 -039 -ns -/ -iter -( -+ -/ -- -827 -837 -) -= -152 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -22 -829 -688 -ns -/ -iter -( -+ -/ -- -81 -653 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -22 -843 -694 -ns -/ -iter -( -+ -/ -- -94 -299 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -22 -827 -872 -ns -/ -iter -( -+ -/ -- -84 -129 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -22 -841 -925 -ns -/ -iter -( -+ -/ -- -84 -394 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -22 -885 -409 -ns -/ -iter -( -+ -/ -- -114 -277 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -22 -837 -475 -ns -/ -iter -( -+ -/ -- -58 -938 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -22 -835 -207 -ns -/ -iter -( -+ -/ -- -39 -862 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -22 -833 -199 -ns -/ -iter -( -+ -/ -- -77 -142 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -22 -851 -757 -ns -/ -iter -( -+ -/ -- -322 -186 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -22 -842 -892 -ns -/ -iter -( -+ -/ -- -86 -166 -) -= -222 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -22 -840 -862 -ns -/ -iter -( -+ -/ -- -105 -926 -) -= -222 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -91 -691 -325 -ns -/ -iter -( -+ -/ -- -194 -247 -) -= -55 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -105 -586 -659 -ns -/ -iter -( -+ -/ -- -320 -354 -) -= -48 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -94 -437 -485 -ns -/ -iter -( -+ -/ -- -277 -744 -) -= -53 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -90 -399 -600 -ns -/ -iter -( -+ -/ -- -184 -588 -) -= -56 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -90 -332 -232 -ns -/ -iter -( -+ -/ -- -174 -254 -) -= -56 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -90 -519 -504 -ns -/ -iter -( -+ -/ -- -227 -643 -) -= -56 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -90 -881 -562 -ns -/ -iter -( -+ -/ -- -221 -861 -) -= -55 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -96 -962 -980 -ns -/ -iter -( -+ -/ -- -180 -002 -) -= -52 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -109 -558 -711 -ns -/ -iter -( -+ -/ -- -166 -337 -) -= -46 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -31 -530 -493 -ns -/ -iter -( -+ -/ -- -112 -639 -) -= -18 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -30 -420 -729 -ns -/ -iter -( -+ -/ -- -114 -072 -) -= -19 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -6 -656 -677 -ns -/ -iter -( -+ -/ -- -167 -110 -) -= -89 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -1 -992 -839 -ns -/ -iter -( -+ -/ -- -8 -037 -) -= -298 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -15 -878 -331 -ns -/ -iter -( -+ -/ -- -150 -901 -) -= -37 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -2 -085 -471 -ns -/ -iter -( -+ -/ -- -8 -438 -) -= -285 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -89 -091 -241 -ns -/ -iter -( -+ -/ -- -182 -225 -) -= -6 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -55 -634 -237 -ns -/ -iter -( -+ -/ -- -115 -097 -) -= -10 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -10 -126 -641 -ns -/ -iter -( -+ -/ -- -36 -015 -) -= -58 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -191 -963 -ns -/ -iter -( -+ -/ -- -687 -) -= -3099 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -1 -983 -070 -ns -/ -iter -( -+ -/ -- -5 -863 -) -= -300 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -1 -972 -746 -ns -/ -iter -( -+ -/ -- -14 -082 -) -= -301 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -2 -424 -033 -ns -/ -iter -( -+ -/ -- -13 -209 -) -= -245 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -16 -876 -942 -ns -/ -iter -( -+ -/ -- -77 -218 -) -= -35 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -1 -986 -579 -ns -/ -iter -( -+ -/ -- -9 -195 -) -= -299 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -4 -992 -277 -ns -/ -iter -( -+ -/ -- -10 -882 -) -= -119 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -2 -033 -937 -ns -/ -iter -( -+ -/ -- -13 -627 -) -= -292 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -6 -292 -627 -ns -/ -iter -( -+ -/ -- -14 -666 -) -= -94 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -450 -290 -ns -/ -iter -( -+ -/ -- -1 -882 -) -= -1321 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -3 -032 -489 -ns -/ -iter -( -+ -/ -- -8 -728 -) -= -196 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -265 -379 -ns -/ -iter -( -+ -/ -- -865 -) -= -2241 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -201 -375 -ns -/ -iter -( -+ -/ -- -2 -146 -) -= -2954 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -3 -010 -059 -ns -/ -iter -( -+ -/ -- -7 -093 -) -= -197 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -3 -016 -713 -ns -/ -iter -( -+ -/ -- -11 -280 -) -= -197 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -266 -706 -ns -/ -iter -( -+ -/ -- -908 -) -= -2230 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -544 -428 -ns -/ -iter -( -+ -/ -- -7 -562 -) -= -1092 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -626 -986 -ns -/ -iter -( -+ -/ -- -2 -959 -) -= -948 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -534 -517 -ns -/ -iter -( -+ -/ -- -4 -342 -) -= -1113 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -3 -210 -614 -ns -/ -iter -( -+ -/ -- -15 -699 -) -= -185 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -31 -147 -103 -ns -/ -iter -( -+ -/ -- -117 -471 -) -= -19 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -2 -275 -468 -ns -/ -iter -( -+ -/ -- -19 -220 -) -= -261 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -4 -999 -086 -ns -/ -iter -( -+ -/ -- -20 -184 -) -= -119 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -893 -288 -ns -/ -iter -( -+ -/ -- -11 -368 -) -= -666 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -2 -364 -893 -ns -/ -iter -( -+ -/ -- -21 -124 -) -= -251 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -18 -221 -921 -ns -/ -iter -( -+ -/ -- -62 -927 -) -= -32 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -27 -552 -543 -ns -/ -iter -( -+ -/ -- -89 -437 -) -= -21 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -94 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/pcre1 b/third_party/rust/regex/record/old-bench-log/07/pcre1 deleted file mode 100644 index 2ad14f5f03792..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/pcre1 +++ /dev/null @@ -1,2514 +0,0 @@ -running -93 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -0 -) -= -16956 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -20526 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -0 -) -= -1130 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -1368 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -223 -ns -/ -iter -( -+ -/ -- -2 -) -= -4713 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -178 -098 -ns -/ -iter -( -+ -/ -- -3 -124 -) -= -5887 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -0 -) -= -1512 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -5 -600 -ns -/ -iter -( -+ -/ -- -27 -) -= -5856 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -210 -ns -/ -iter -( -+ -/ -- -7 -) -= -4971 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -178 -177 -ns -/ -iter -( -+ -/ -- -1 -024 -) -= -5885 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -0 -) -= -1300 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -5 -592 -ns -/ -iter -( -+ -/ -- -52 -) -= -5863 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -223 -ns -/ -iter -( -+ -/ -- -14 -) -= -859 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -983 -169 -ns -/ -iter -( -+ -/ -- -13 -398 -) -= -1066 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -99 -ns -/ -iter -( -+ -/ -- -0 -) -= -595 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -31 -422 -ns -/ -iter -( -+ -/ -- -326 -) -= -1043 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -0 -) -= -2217 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -464 -932 -ns -/ -iter -( -+ -/ -- -1 -869 -) -= -215 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -462 -587 -ns -/ -iter -( -+ -/ -- -6 -375 -) -= -216 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -73 -ns -/ -iter -( -+ -/ -- -0 -) -= -1109 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -3240 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -263 -ns -/ -iter -( -+ -/ -- -2 -) -= -612 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -213 -ns -/ -iter -( -+ -/ -- -3 -) -= -4938 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -178 -077 -ns -/ -iter -( -+ -/ -- -1 -844 -) -= -5888 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -0 -) -= -1250 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -5 -598 -ns -/ -iter -( -+ -/ -- -38 -) -= -5858 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -131 -ns -/ -iter -( -+ -/ -- -0 -) -= -389 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -1181 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -1181 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -0 -) -= -386 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -0 -) -= -386 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -3 -503 -ns -/ -iter -( -+ -/ -- -29 -) -= -296 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -276 -ns -/ -iter -( -+ -/ -- -14 -) -= -823 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -003 -152 -ns -/ -iter -( -+ -/ -- -10 -884 -) -= -1045 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -102 -ns -/ -iter -( -+ -/ -- -7 -) -= -578 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -31 -035 -ns -/ -iter -( -+ -/ -- -221 -) -= -1056 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -3 -924 -ns -/ -iter -( -+ -/ -- -23 -) -= -2038 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -2 -398 -578 -ns -/ -iter -( -+ -/ -- -28 -663 -) -= -2119 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -1 -073 -632 -ns -/ -iter -( -+ -/ -- -7 -567 -) -= -4734 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -1 -068 -696 -ns -/ -iter -( -+ -/ -- -14 -896 -) -= -4756 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -1 -071 -991 -ns -/ -iter -( -+ -/ -- -21 -623 -) -= -4742 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -1 -064 -244 -ns -/ -iter -( -+ -/ -- -22 -701 -) -= -4776 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -1 -081 -402 -ns -/ -iter -( -+ -/ -- -25 -919 -) -= -4700 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -1 -078 -319 -ns -/ -iter -( -+ -/ -- -8 -278 -) -= -4714 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -1 -067 -600 -ns -/ -iter -( -+ -/ -- -6 -079 -) -= -4761 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -1 -073 -509 -ns -/ -iter -( -+ -/ -- -8 -068 -) -= -4735 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -1 -075 -462 -ns -/ -iter -( -+ -/ -- -9 -145 -) -= -4726 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -1 -073 -592 -ns -/ -iter -( -+ -/ -- -10 -284 -) -= -4734 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -1 -074 -960 -ns -/ -iter -( -+ -/ -- -11 -802 -) -= -4728 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -14 -120 -901 -ns -/ -iter -( -+ -/ -- -85 -462 -) -= -359 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -15 -606 -152 -ns -/ -iter -( -+ -/ -- -128 -452 -) -= -325 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -18 -892 -502 -ns -/ -iter -( -+ -/ -- -82 -790 -) -= -269 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -17 -988 -621 -ns -/ -iter -( -+ -/ -- -50 -462 -) -= -282 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -15 -854 -890 -ns -/ -iter -( -+ -/ -- -54 -745 -) -= -320 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -16 -126 -069 -ns -/ -iter -( -+ -/ -- -76 -013 -) -= -315 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -17 -997 -470 -ns -/ -iter -( -+ -/ -- -94 -472 -) -= -282 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -23 -004 -949 -ns -/ -iter -( -+ -/ -- -81 -626 -) -= -220 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -20 -272 -633 -ns -/ -iter -( -+ -/ -- -99 -674 -) -= -250 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -3 -660 -138 -ns -/ -iter -( -+ -/ -- -41 -095 -) -= -162 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -3 -632 -955 -ns -/ -iter -( -+ -/ -- -25 -761 -) -= -163 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -458 -639 -ns -/ -iter -( -+ -/ -- -9 -185 -) -= -1297 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -1 -746 -052 -ns -/ -iter -( -+ -/ -- -31 -762 -) -= -340 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -4 -067 -141 -ns -/ -iter -( -+ -/ -- -12 -943 -) -= -146 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -11 -360 -188 -ns -/ -iter -( -+ -/ -- -22 -264 -) -= -52 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -11 -137 -940 -ns -/ -iter -( -+ -/ -- -35 -225 -) -= -53 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -505 -435 -ns -/ -iter -( -+ -/ -- -10 -318 -) -= -395 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -181 -084 -ns -/ -iter -( -+ -/ -- -3 -121 -) -= -3285 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -427 -474 -ns -/ -iter -( -+ -/ -- -1 -601 -) -= -1391 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -434 -858 -ns -/ -iter -( -+ -/ -- -6 -444 -) -= -1368 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -747 -274 -ns -/ -iter -( -+ -/ -- -7 -303 -) -= -796 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -574 -102 -ns -/ -iter -( -+ -/ -- -44 -203 -) -= -231 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -66 -428 -ns -/ -iter -( -+ -/ -- -336 -) -= -8956 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -333 -932 -ns -/ -iter -( -+ -/ -- -6 -683 -) -= -445 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -598 -062 -ns -/ -iter -( -+ -/ -- -4 -936 -) -= -994 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -496 -292 -ns -/ -iter -( -+ -/ -- -6 -595 -) -= -397 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -359 -203 -ns -/ -iter -( -+ -/ -- -6 -202 -) -= -1656 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -454 -624 -ns -/ -iter -( -+ -/ -- -2 -658 -) -= -1308 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -243 -450 -ns -/ -iter -( -+ -/ -- -2 -435 -) -= -2443 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -182 -407 -ns -/ -iter -( -+ -/ -- -878 -) -= -3261 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -940 -244 -ns -/ -iter -( -+ -/ -- -6 -064 -) -= -632 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -904 -285 -ns -/ -iter -( -+ -/ -- -9 -405 -) -= -657 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -244 -114 -ns -/ -iter -( -+ -/ -- -1 -875 -) -= -2437 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -358 -735 -ns -/ -iter -( -+ -/ -- -4 -090 -) -= -1658 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -348 -964 -ns -/ -iter -( -+ -/ -- -6 -060 -) -= -1704 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -21 -256 -ns -/ -iter -( -+ -/ -- -144 -) -= -27988 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -422 -149 -ns -/ -iter -( -+ -/ -- -1 -540 -) -= -1409 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -5 -232 -683 -ns -/ -iter -( -+ -/ -- -21 -609 -) -= -113 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -651 -539 -ns -/ -iter -( -+ -/ -- -1 -763 -) -= -913 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -693 -506 -ns -/ -iter -( -+ -/ -- -13 -143 -) -= -857 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -46 -904 -ns -/ -iter -( -+ -/ -- -657 -) -= -12684 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -788 -070 -ns -/ -iter -( -+ -/ -- -17 -403 -) -= -754 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -4 -545 -774 -ns -/ -iter -( -+ -/ -- -26 -965 -) -= -130 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -5 -493 -039 -ns -/ -iter -( -+ -/ -- -16 -767 -) -= -108 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -93 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/pcre2 b/third_party/rust/regex/record/old-bench-log/07/pcre2 deleted file mode 100644 index 3843e53d2abee..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/pcre2 +++ /dev/null @@ -1,2488 +0,0 @@ -running -93 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -26000 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -32500 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -1857 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -2363 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -81 -ns -/ -iter -( -+ -/ -- -4 -) -= -12975 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -60 -199 -ns -/ -iter -( -+ -/ -- -658 -) -= -17418 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -2107 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -1 -878 -ns -/ -iter -( -+ -/ -- -25 -) -= -17462 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -81 -ns -/ -iter -( -+ -/ -- -0 -) -= -12888 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -59 -222 -ns -/ -iter -( -+ -/ -- -598 -) -= -17706 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -1857 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -1 -819 -ns -/ -iter -( -+ -/ -- -6 -) -= -18025 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -147 -ns -/ -iter -( -+ -/ -- -13 -) -= -916 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -990 -924 -ns -/ -iter -( -+ -/ -- -6 -065 -) -= -1058 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -82 -ns -/ -iter -( -+ -/ -- -3 -) -= -719 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -32 -218 -ns -/ -iter -( -+ -/ -- -471 -) -= -1017 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -3400 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -464 -061 -ns -/ -iter -( -+ -/ -- -2 -241 -) -= -215 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -465 -191 -ns -/ -iter -( -+ -/ -- -823 -) -= -214 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -1 -) -= -1760 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -5062 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -246 -ns -/ -iter -( -+ -/ -- -0 -) -= -654 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -102 -ns -/ -iter -( -+ -/ -- -9 -) -= -10313 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -60 -042 -ns -/ -iter -( -+ -/ -- -585 -) -= -17464 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -29 -ns -/ -iter -( -+ -/ -- -1 -) -= -2068 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -1 -901 -ns -/ -iter -( -+ -/ -- -23 -) -= -17251 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -122 -ns -/ -iter -( -+ -/ -- -2 -) -= -418 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -2000 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -2000 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -472 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -472 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -3 -517 -ns -/ -iter -( -+ -/ -- -39 -) -= -295 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -123 -ns -/ -iter -( -+ -/ -- -12 -) -= -935 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -992 -521 -ns -/ -iter -( -+ -/ -- -13 -407 -) -= -1056 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -71 -ns -/ -iter -( -+ -/ -- -0 -) -= -830 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -30 -626 -ns -/ -iter -( -+ -/ -- -206 -) -= -1070 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -2 -824 -ns -/ -iter -( -+ -/ -- -21 -) -= -2832 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -1 -500 -377 -ns -/ -iter -( -+ -/ -- -8 -152 -) -= -3388 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -815 -769 -ns -/ -iter -( -+ -/ -- -14 -286 -) -= -6231 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -820 -459 -ns -/ -iter -( -+ -/ -- -57 -098 -) -= -6195 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -810 -986 -ns -/ -iter -( -+ -/ -- -4 -270 -) -= -6268 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -815 -568 -ns -/ -iter -( -+ -/ -- -35 -148 -) -= -6232 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -812 -590 -ns -/ -iter -( -+ -/ -- -6 -782 -) -= -6255 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -831 -679 -ns -/ -iter -( -+ -/ -- -12 -372 -) -= -6112 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -823 -207 -ns -/ -iter -( -+ -/ -- -12 -977 -) -= -6175 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -815 -506 -ns -/ -iter -( -+ -/ -- -11 -610 -) -= -6233 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -818 -104 -ns -/ -iter -( -+ -/ -- -4 -807 -) -= -6213 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -815 -265 -ns -/ -iter -( -+ -/ -- -21 -504 -) -= -6235 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -809 -236 -ns -/ -iter -( -+ -/ -- -7 -003 -) -= -6281 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -8 -375 -573 -ns -/ -iter -( -+ -/ -- -80 -345 -) -= -606 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -11 -207 -698 -ns -/ -iter -( -+ -/ -- -45 -582 -) -= -453 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -10 -505 -744 -ns -/ -iter -( -+ -/ -- -69 -756 -) -= -483 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -9 -276 -177 -ns -/ -iter -( -+ -/ -- -50 -904 -) -= -548 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -9 -333 -446 -ns -/ -iter -( -+ -/ -- -41 -108 -) -= -544 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -9 -865 -395 -ns -/ -iter -( -+ -/ -- -26 -010 -) -= -515 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -10 -033 -179 -ns -/ -iter -( -+ -/ -- -28 -272 -) -= -506 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -10 -752 -604 -ns -/ -iter -( -+ -/ -- -37 -714 -) -= -472 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -11 -397 -272 -ns -/ -iter -( -+ -/ -- -41 -200 -) -= -446 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -3 -627 -616 -ns -/ -iter -( -+ -/ -- -18 -202 -) -= -164 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -3 -614 -713 -ns -/ -iter -( -+ -/ -- -18 -191 -) -= -164 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -68 -419 -ns -/ -iter -( -+ -/ -- -918 -) -= -8695 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -1 -766 -571 -ns -/ -iter -( -+ -/ -- -16 -612 -) -= -336 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -4 -018 -396 -ns -/ -iter -( -+ -/ -- -11 -822 -) -= -148 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -8 -058 -390 -ns -/ -iter -( -+ -/ -- -39 -083 -) -= -73 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -8 -014 -051 -ns -/ -iter -( -+ -/ -- -33 -500 -) -= -74 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -452 -421 -ns -/ -iter -( -+ -/ -- -157 -023 -) -= -409 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -36 -248 -ns -/ -iter -( -+ -/ -- -252 -) -= -16412 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -45 -538 -ns -/ -iter -( -+ -/ -- -235 -) -= -13064 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -62 -202 -ns -/ -iter -( -+ -/ -- -892 -) -= -9564 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -623 -900 -ns -/ -iter -( -+ -/ -- -3 -139 -) -= -953 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -518 -464 -ns -/ -iter -( -+ -/ -- -31 -943 -) -= -236 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -62 -015 -ns -/ -iter -( -+ -/ -- -712 -) -= -9593 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -162 -489 -ns -/ -iter -( -+ -/ -- -14 -622 -) -= -511 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -589 -686 -ns -/ -iter -( -+ -/ -- -6 -775 -) -= -1008 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -359 -066 -ns -/ -iter -( -+ -/ -- -7 -487 -) -= -437 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -45 -993 -ns -/ -iter -( -+ -/ -- -812 -) -= -12935 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -82 -326 -ns -/ -iter -( -+ -/ -- -758 -) -= -7226 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -36 -848 -ns -/ -iter -( -+ -/ -- -50 -) -= -16145 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -36 -778 -ns -/ -iter -( -+ -/ -- -621 -) -= -16176 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -636 -825 -ns -/ -iter -( -+ -/ -- -2 -957 -) -= -934 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -635 -313 -ns -/ -iter -( -+ -/ -- -10 -776 -) -= -936 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -37 -360 -ns -/ -iter -( -+ -/ -- -132 -) -= -15924 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -34 -545 -ns -/ -iter -( -+ -/ -- -239 -) -= -17221 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -49 -019 -ns -/ -iter -( -+ -/ -- -590 -) -= -12136 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -34 -410 -ns -/ -iter -( -+ -/ -- -182 -) -= -17289 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -414 -599 -ns -/ -iter -( -+ -/ -- -3 -528 -) -= -1434 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -5 -106 -885 -ns -/ -iter -( -+ -/ -- -23 -660 -) -= -116 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -234 -135 -ns -/ -iter -( -+ -/ -- -3 -821 -) -= -2540 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -261 -765 -ns -/ -iter -( -+ -/ -- -2 -272 -) -= -2272 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -50 -816 -ns -/ -iter -( -+ -/ -- -583 -) -= -11707 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -408 -355 -ns -/ -iter -( -+ -/ -- -5 -463 -) -= -1456 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -4 -367 -721 -ns -/ -iter -( -+ -/ -- -55 -474 -) -= -136 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -4 -640 -171 -ns -/ -iter -( -+ -/ -- -20 -462 -) -= -128 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -93 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/re2 b/third_party/rust/regex/record/old-bench-log/07/re2 deleted file mode 100644 index 4f435f742a9fc..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/re2 +++ /dev/null @@ -1,2598 +0,0 @@ -running -96 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -69 -ns -/ -iter -( -+ -/ -- -0 -) -= -5652 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -26000 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -69 -ns -/ -iter -( -+ -/ -- -0 -) -= -376 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -1733 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -106 -ns -/ -iter -( -+ -/ -- -0 -) -= -9915 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -15 -311 -ns -/ -iter -( -+ -/ -- -113 -) -= -68486 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -100 -ns -/ -iter -( -+ -/ -- -3 -) -= -590 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -426 -ns -/ -iter -( -+ -/ -- -1 -) -= -76983 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -98 -ns -/ -iter -( -+ -/ -- -0 -) -= -10653 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -15 -299 -ns -/ -iter -( -+ -/ -- -136 -) -= -68540 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -91 -ns -/ -iter -( -+ -/ -- -0 -) -= -571 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -413 -ns -/ -iter -( -+ -/ -- -5 -) -= -79389 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -815 -ns -/ -iter -( -+ -/ -- -43 -) -= -579 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -1 -842 -293 -ns -/ -iter -( -+ -/ -- -10 -227 -) -= -569 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -146 -ns -/ -iter -( -+ -/ -- -4 -) -= -404 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -57 -638 -ns -/ -iter -( -+ -/ -- -481 -) -= -568 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -64 -ns -/ -iter -( -+ -/ -- -1 -) -= -796 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -122 -154 -ns -/ -iter -( -+ -/ -- -840 -) -= -818 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -122 -105 -ns -/ -iter -( -+ -/ -- -578 -) -= -818 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -178 -ns -/ -iter -( -+ -/ -- -0 -) -= -455 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -178 -ns -/ -iter -( -+ -/ -- -2 -) -= -455 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -293 -ns -/ -iter -( -+ -/ -- -2 -) -= -549 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -1 -610 -ns -/ -iter -( -+ -/ -- -26 -) -= -653 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -1 -537 -932 -ns -/ -iter -( -+ -/ -- -4 -134 -) -= -681 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -158 -ns -/ -iter -( -+ -/ -- -1 -) -= -379 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -48 -172 -ns -/ -iter -( -+ -/ -- -390 -) -= -680 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -216 -ns -/ -iter -( -+ -/ -- -1 -) -= -462 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -127 -ns -/ -iter -( -+ -/ -- -1 -) -= -401 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -64 -ns -/ -iter -( -+ -/ -- -0 -) -= -406 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -100 -ns -/ -iter -( -+ -/ -- -1 -) -= -260 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -0 -) -= -193 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -0 -) -= -197 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -1 -332 -ns -/ -iter -( -+ -/ -- -41 -) -= -780 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -815 -ns -/ -iter -( -+ -/ -- -16 -) -= -579 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -842 -206 -ns -/ -iter -( -+ -/ -- -9 -086 -) -= -569 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -149 -ns -/ -iter -( -+ -/ -- -1 -) -= -395 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -57 -591 -ns -/ -iter -( -+ -/ -- -101 -) -= -569 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -11 -753 -ns -/ -iter -( -+ -/ -- -130 -) -= -680 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -24 -330 -235 -ns -/ -iter -( -+ -/ -- -374 -274 -) -= -208 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -4 -079 -631 -ns -/ -iter -( -+ -/ -- -51 -348 -) -= -1246 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -4 -080 -803 -ns -/ -iter -( -+ -/ -- -30 -966 -) -= -1245 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -4 -154 -389 -ns -/ -iter -( -+ -/ -- -34 -825 -) -= -1223 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -4 -076 -784 -ns -/ -iter -( -+ -/ -- -102 -863 -) -= -1246 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -4 -074 -850 -ns -/ -iter -( -+ -/ -- -52 -106 -) -= -1247 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -4 -078 -456 -ns -/ -iter -( -+ -/ -- -12 -343 -) -= -1246 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -4 -075 -812 -ns -/ -iter -( -+ -/ -- -24 -524 -) -= -1247 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -4 -097 -009 -ns -/ -iter -( -+ -/ -- -13 -240 -) -= -1240 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -4 -069 -096 -ns -/ -iter -( -+ -/ -- -29 -794 -) -= -1249 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -4 -078 -838 -ns -/ -iter -( -+ -/ -- -20 -713 -) -= -1246 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -4 -116 -905 -ns -/ -iter -( -+ -/ -- -14 -130 -) -= -1234 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -21 -411 -252 -ns -/ -iter -( -+ -/ -- -568 -076 -) -= -237 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -21 -082 -571 -ns -/ -iter -( -+ -/ -- -92 -912 -) -= -241 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -20 -302 -954 -ns -/ -iter -( -+ -/ -- -118 -421 -) -= -250 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -21 -290 -669 -ns -/ -iter -( -+ -/ -- -102 -527 -) -= -238 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -21 -451 -671 -ns -/ -iter -( -+ -/ -- -99 -524 -) -= -236 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -21 -057 -017 -ns -/ -iter -( -+ -/ -- -530 -904 -) -= -241 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -20 -394 -037 -ns -/ -iter -( -+ -/ -- -128 -973 -) -= -249 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -17 -839 -069 -ns -/ -iter -( -+ -/ -- -122 -671 -) -= -284 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -12 -720 -049 -ns -/ -iter -( -+ -/ -- -76 -816 -) -= -399 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -1 -044 -129 -ns -/ -iter -( -+ -/ -- -4 -967 -) -= -569 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -1 -067 -879 -ns -/ -iter -( -+ -/ -- -11 -345 -) -= -557 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -5 -193 -222 -ns -/ -iter -( -+ -/ -- -10 -990 -) -= -114 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -2 -038 -599 -ns -/ -iter -( -+ -/ -- -18 -946 -) -= -291 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -909 -342 -ns -/ -iter -( -+ -/ -- -5 -295 -) -= -654 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -939 -154 -ns -/ -iter -( -+ -/ -- -6 -087 -) -= -633 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -2 -729 -081 -ns -/ -iter -( -+ -/ -- -15 -969 -) -= -217 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -373 -143 -ns -/ -iter -( -+ -/ -- -17 -068 -) -= -433 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -56 -266 -035 -ns -/ -iter -( -+ -/ -- -165 -398 -) -= -10 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -54 -590 -671 -ns -/ -iter -( -+ -/ -- -138 -842 -) -= -10 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -2 -702 -242 -ns -/ -iter -( -+ -/ -- -9 -889 -) -= -220 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -2 -430 -065 -ns -/ -iter -( -+ -/ -- -27 -756 -) -= -244 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -45 -514 -ns -/ -iter -( -+ -/ -- -403 -) -= -13071 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -975 -861 -ns -/ -iter -( -+ -/ -- -11 -553 -) -= -609 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -1 -070 -967 -ns -/ -iter -( -+ -/ -- -11 -065 -) -= -555 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -2 -574 -585 -ns -/ -iter -( -+ -/ -- -39 -816 -) -= -231 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -978 -776 -ns -/ -iter -( -+ -/ -- -25 -503 -) -= -607 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -1 -643 -230 -ns -/ -iter -( -+ -/ -- -27 -685 -) -= -362 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -998 -349 -ns -/ -iter -( -+ -/ -- -6 -658 -) -= -595 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -781 -006 -ns -/ -iter -( -+ -/ -- -22 -507 -) -= -334 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -92 -561 -ns -/ -iter -( -+ -/ -- -1 -358 -) -= -6427 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -1 -281 -827 -ns -/ -iter -( -+ -/ -- -7 -651 -) -= -464 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -31 -994 -ns -/ -iter -( -+ -/ -- -326 -) -= -18595 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -34 -272 -ns -/ -iter -( -+ -/ -- -445 -) -= -17359 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -218 -006 -ns -/ -iter -( -+ -/ -- -19 -301 -) -= -488 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -214 -744 -ns -/ -iter -( -+ -/ -- -11 -473 -) -= -489 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -35 -455 -ns -/ -iter -( -+ -/ -- -412 -) -= -16779 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -299 -771 -ns -/ -iter -( -+ -/ -- -7 -799 -) -= -1984 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -299 -595 -ns -/ -iter -( -+ -/ -- -926 -) -= -1985 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -9 -803 -ns -/ -iter -( -+ -/ -- -139 -) -= -60688 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -1 -033 -423 -ns -/ -iter -( -+ -/ -- -9 -177 -) -= -575 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -1 -454 -358 -ns -/ -iter -( -+ -/ -- -75 -304 -) -= -409 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -2 -486 -681 -ns -/ -iter -( -+ -/ -- -9 -026 -) -= -239 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -123 -989 -ns -/ -iter -( -+ -/ -- -1 -097 -) -= -4798 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -1 -454 -732 -ns -/ -iter -( -+ -/ -- -118 -006 -) -= -408 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -922 -008 -ns -/ -iter -( -+ -/ -- -15 -040 -) -= -309 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -16 -054 -888 -ns -/ -iter -( -+ -/ -- -90 -684 -) -= -37 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -96 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/rust b/third_party/rust/regex/record/old-bench-log/07/rust deleted file mode 100644 index 2a9b04b2b23b9..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/rust +++ /dev/null @@ -1,2850 +0,0 @@ -running -108 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -26000 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -24375 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -1857 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -1625 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -95545 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -69906866 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -5363 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -2981363 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -29000 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -0 -) -= -27594631 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -0 -) -= -1333 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -910777 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -0 -) -= -21895 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -0 -) -= -20560843 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -1 -) -= -1229 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -0 -) -= -683229 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -5100 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -956 -ns -/ -iter -( -+ -/ -- -14 -) -= -104603 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -538 -237 -ns -/ -iter -( -+ -/ -- -8 -739 -) -= -185 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -57 -ns -/ -iter -( -+ -/ -- -0 -) -= -1421 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -3681 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -245 -ns -/ -iter -( -+ -/ -- -4 -) -= -657 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -80923 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -69906933 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -5000 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -2733000 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -318 -ns -/ -iter -( -+ -/ -- -0 -) -= -314 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -0 -) -= -600 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -0 -) -= -541 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -0 -) -= -541 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -0 -) -= -500 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -0 -) -= -459 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -0 -) -= -20392 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -547 -ns -/ -iter -( -+ -/ -- -19 -) -= -679 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -533 -883 -ns -/ -iter -( -+ -/ -- -9 -553 -) -= -683 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -96 -ns -/ -iter -( -+ -/ -- -0 -) -= -614 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -47 -989 -ns -/ -iter -( -+ -/ -- -198 -) -= -683 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -136 -ns -/ -iter -( -+ -/ -- -0 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -016 -ns -/ -iter -( -+ -/ -- -21 -) -= -1992 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -64 -033 -ns -/ -iter -( -+ -/ -- -470 -) -= -124935 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -6 -472 -ns -/ -iter -( -+ -/ -- -44 -) -= -123611 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -1 -906 -ns -/ -iter -( -+ -/ -- -49 -) -= -41978 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -362 -ns -/ -iter -( -+ -/ -- -1 -) -= -22129 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -259 -ns -/ -iter -( -+ -/ -- -2 -) -= -3131 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -228 -ns -/ -iter -( -+ -/ -- -0 -) -= -399 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -223 -ns -/ -iter -( -+ -/ -- -2 -) -= -85 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -224 -ns -/ -iter -( -+ -/ -- -2 -) -= -120 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -221 -ns -/ -iter -( -+ -/ -- -2 -) -= -158 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -223 -ns -/ -iter -( -+ -/ -- -2 -) -= -192 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -11 -885 -905 -ns -/ -iter -( -+ -/ -- -23 -501 -) -= -427 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -712 -544 -ns -/ -iter -( -+ -/ -- -16 -100 -) -= -7134 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -709 -739 -ns -/ -iter -( -+ -/ -- -8 -467 -) -= -7162 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -714 -261 -ns -/ -iter -( -+ -/ -- -8 -495 -) -= -7117 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -711 -197 -ns -/ -iter -( -+ -/ -- -14 -736 -) -= -7147 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -718 -083 -ns -/ -iter -( -+ -/ -- -5 -050 -) -= -7079 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -725 -196 -ns -/ -iter -( -+ -/ -- -20 -044 -) -= -7009 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -709 -301 -ns -/ -iter -( -+ -/ -- -10 -961 -) -= -7166 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -715 -658 -ns -/ -iter -( -+ -/ -- -16 -431 -) -= -7103 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -707 -472 -ns -/ -iter -( -+ -/ -- -5 -764 -) -= -7185 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -707 -300 -ns -/ -iter -( -+ -/ -- -19 -545 -) -= -7187 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -709 -950 -ns -/ -iter -( -+ -/ -- -11 -319 -) -= -7160 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -498 -980 -ns -/ -iter -( -+ -/ -- -67 -933 -) -= -2034 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -5 -544 -923 -ns -/ -iter -( -+ -/ -- -31 -911 -) -= -916 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -6 -441 -568 -ns -/ -iter -( -+ -/ -- -20 -197 -) -= -789 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -6 -421 -276 -ns -/ -iter -( -+ -/ -- -161 -499 -) -= -791 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -5 -093 -567 -ns -/ -iter -( -+ -/ -- -18 -696 -) -= -998 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -5 -094 -859 -ns -/ -iter -( -+ -/ -- -22 -894 -) -= -997 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -4 -540 -111 -ns -/ -iter -( -+ -/ -- -11 -863 -) -= -1119 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -4 -636 -741 -ns -/ -iter -( -+ -/ -- -23 -448 -) -= -1096 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -4 -557 -500 -ns -/ -iter -( -+ -/ -- -16 -168 -) -= -1115 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -880 -959 -ns -/ -iter -( -+ -/ -- -3 -004 -) -= -675 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -54 -416 -ns -/ -iter -( -+ -/ -- -1 -099 -) -= -10933 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -736 -180 -ns -/ -iter -( -+ -/ -- -9 -410 -) -= -342 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -783 -848 -ns -/ -iter -( -+ -/ -- -19 -640 -) -= -758 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -90 -085 -ns -/ -iter -( -+ -/ -- -499 -) -= -6604 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -459 -431 -ns -/ -iter -( -+ -/ -- -830 -) -= -1294 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -348 -103 -ns -/ -iter -( -+ -/ -- -9 -052 -) -= -1709 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -017 -387 -ns -/ -iter -( -+ -/ -- -3 -906 -) -= -584 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -18 -265 -074 -ns -/ -iter -( -+ -/ -- -463 -241 -) -= -32 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -17 -846 -209 -ns -/ -iter -( -+ -/ -- -431 -089 -) -= -33 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -594 -743 -ns -/ -iter -( -+ -/ -- -3 -151 -) -= -373 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -873 -308 -ns -/ -iter -( -+ -/ -- -1 -379 -) -= -681 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -21 -144 -ns -/ -iter -( -+ -/ -- -315 -) -= -28137 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -71 -354 -ns -/ -iter -( -+ -/ -- -1 -432 -) -= -8337 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -79 -167 -ns -/ -iter -( -+ -/ -- -294 -) -= -7514 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -111 -300 -ns -/ -iter -( -+ -/ -- -4 -434 -) -= -535 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -100 -864 -ns -/ -iter -( -+ -/ -- -570 -) -= -5898 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -157 -266 -ns -/ -iter -( -+ -/ -- -4 -048 -) -= -3782 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -74 -375 -ns -/ -iter -( -+ -/ -- -576 -) -= -7999 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -467 -879 -ns -/ -iter -( -+ -/ -- -2 -115 -) -= -1271 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -26 -856 -ns -/ -iter -( -+ -/ -- -345 -) -= -22152 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -124 -140 -ns -/ -iter -( -+ -/ -- -1 -111 -) -= -4792 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -52 -330 -ns -/ -iter -( -+ -/ -- -316 -) -= -11368 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -19 -646 -ns -/ -iter -( -+ -/ -- -355 -) -= -30282 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -107 -973 -ns -/ -iter -( -+ -/ -- -508 -) -= -5510 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -105 -141 -ns -/ -iter -( -+ -/ -- -426 -) -= -5658 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -61 -149 -ns -/ -iter -( -+ -/ -- -350 -) -= -9729 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -11 -735 -ns -/ -iter -( -+ -/ -- -185 -) -= -50697 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -274 -089 -ns -/ -iter -( -+ -/ -- -617 -) -= -2170 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -11 -581 -ns -/ -iter -( -+ -/ -- -298 -) -= -51371 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -447 -749 -ns -/ -iter -( -+ -/ -- -1 -173 -) -= -1328 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -69 -119 -491 -ns -/ -iter -( -+ -/ -- -117 -739 -) -= -8 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -492 -559 -ns -/ -iter -( -+ -/ -- -1 -674 -) -= -1207 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -341 -445 -ns -/ -iter -( -+ -/ -- -6 -455 -) -= -1742 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -30 -555 -ns -/ -iter -( -+ -/ -- -168 -) -= -19470 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -950 -630 -ns -/ -iter -( -+ -/ -- -25 -179 -) -= -625 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -551 -930 -ns -/ -iter -( -+ -/ -- -17 -792 -) -= -383 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -7 -229 -870 -ns -/ -iter -( -+ -/ -- -25 -046 -) -= -82 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -108 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/rust-bytes b/third_party/rust/regex/record/old-bench-log/07/rust-bytes deleted file mode 100644 index 166f5963e7dda..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/rust-bytes +++ /dev/null @@ -1,2551 +0,0 @@ -running -96 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -24375 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -24375 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -1857 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -1625 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -95545 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -74900214 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -5363 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -2981363 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -29000 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -0 -) -= -27594631 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -1444 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -910777 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -0 -) -= -22847 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -0 -) -= -21400061 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -0 -) -= -1282 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -0 -) -= -712934 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -5100 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -119 -ns -/ -iter -( -+ -/ -- -22 -) -= -89366 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -535 -168 -ns -/ -iter -( -+ -/ -- -2 -976 -) -= -186 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -67 -ns -/ -iter -( -+ -/ -- -0 -) -= -1208 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -3857 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -87666 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -65537750 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -5000 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -2733000 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -320 -ns -/ -iter -( -+ -/ -- -3 -) -= -312 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -0 -) -= -593 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -0 -) -= -541 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -0 -) -= -541 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -0 -) -= -500 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -0 -) -= -459 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -20800 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -548 -ns -/ -iter -( -+ -/ -- -0 -) -= -678 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -534 -068 -ns -/ -iter -( -+ -/ -- -14 -813 -) -= -683 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -98 -ns -/ -iter -( -+ -/ -- -1 -) -= -602 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -48 -003 -ns -/ -iter -( -+ -/ -- -128 -) -= -683 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -015 -ns -/ -iter -( -+ -/ -- -11 -) -= -1992 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -11 -859 -603 -ns -/ -iter -( -+ -/ -- -22 -707 -) -= -428 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -717 -255 -ns -/ -iter -( -+ -/ -- -3 -261 -) -= -7087 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -719 -600 -ns -/ -iter -( -+ -/ -- -4 -712 -) -= -7064 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -708 -612 -ns -/ -iter -( -+ -/ -- -6 -314 -) -= -7173 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -715 -174 -ns -/ -iter -( -+ -/ -- -5 -097 -) -= -7107 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -711 -261 -ns -/ -iter -( -+ -/ -- -12 -051 -) -= -7147 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -761 -920 -ns -/ -iter -( -+ -/ -- -4 -924 -) -= -6671 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -740 -755 -ns -/ -iter -( -+ -/ -- -12 -762 -) -= -6862 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -713 -936 -ns -/ -iter -( -+ -/ -- -7 -103 -) -= -7120 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -710 -142 -ns -/ -iter -( -+ -/ -- -5 -377 -) -= -7158 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -712 -154 -ns -/ -iter -( -+ -/ -- -4 -485 -) -= -7138 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -713 -214 -ns -/ -iter -( -+ -/ -- -6 -830 -) -= -7127 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -448 -709 -ns -/ -iter -( -+ -/ -- -10 -799 -) -= -2075 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -5 -541 -606 -ns -/ -iter -( -+ -/ -- -26 -197 -) -= -917 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -6 -563 -736 -ns -/ -iter -( -+ -/ -- -163 -805 -) -= -774 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -6 -428 -096 -ns -/ -iter -( -+ -/ -- -38 -372 -) -= -790 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -5 -110 -667 -ns -/ -iter -( -+ -/ -- -141 -363 -) -= -994 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -5 -086 -936 -ns -/ -iter -( -+ -/ -- -25 -675 -) -= -999 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -4 -607 -360 -ns -/ -iter -( -+ -/ -- -31 -834 -) -= -1103 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -4 -636 -550 -ns -/ -iter -( -+ -/ -- -11 -143 -) -= -1096 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -4 -534 -765 -ns -/ -iter -( -+ -/ -- -18 -435 -) -= -1120 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -880 -980 -ns -/ -iter -( -+ -/ -- -1 -386 -) -= -675 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -56 -626 -ns -/ -iter -( -+ -/ -- -612 -) -= -10506 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -715 -022 -ns -/ -iter -( -+ -/ -- -7 -374 -) -= -346 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -778 -398 -ns -/ -iter -( -+ -/ -- -6 -195 -) -= -764 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -91 -093 -ns -/ -iter -( -+ -/ -- -266 -) -= -6531 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -457 -793 -ns -/ -iter -( -+ -/ -- -3 -094 -) -= -1299 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -348 -696 -ns -/ -iter -( -+ -/ -- -2 -174 -) -= -1706 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -017 -664 -ns -/ -iter -( -+ -/ -- -8 -581 -) -= -584 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -19 -098 -779 -ns -/ -iter -( -+ -/ -- -36 -233 -) -= -31 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -17 -748 -386 -ns -/ -iter -( -+ -/ -- -37 -835 -) -= -33 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -592 -729 -ns -/ -iter -( -+ -/ -- -2 -977 -) -= -373 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -873 -365 -ns -/ -iter -( -+ -/ -- -1 -399 -) -= -681 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -21 -965 -ns -/ -iter -( -+ -/ -- -336 -) -= -27085 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -73 -887 -ns -/ -iter -( -+ -/ -- -107 -) -= -8051 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -79 -186 -ns -/ -iter -( -+ -/ -- -274 -) -= -7513 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -111 -949 -ns -/ -iter -( -+ -/ -- -3 -589 -) -= -535 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -102 -493 -ns -/ -iter -( -+ -/ -- -959 -) -= -5804 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -158 -438 -ns -/ -iter -( -+ -/ -- -946 -) -= -3754 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -74 -362 -ns -/ -iter -( -+ -/ -- -139 -) -= -8000 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -469 -720 -ns -/ -iter -( -+ -/ -- -5 -941 -) -= -1266 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -28 -919 -ns -/ -iter -( -+ -/ -- -372 -) -= -20572 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -123 -251 -ns -/ -iter -( -+ -/ -- -786 -) -= -4827 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -53 -032 -ns -/ -iter -( -+ -/ -- -487 -) -= -11218 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -20 -566 -ns -/ -iter -( -+ -/ -- -280 -) -= -28927 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -108 -166 -ns -/ -iter -( -+ -/ -- -303 -) -= -5500 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -105 -034 -ns -/ -iter -( -+ -/ -- -797 -) -= -5664 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -60 -968 -ns -/ -iter -( -+ -/ -- -490 -) -= -9758 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -12 -191 -ns -/ -iter -( -+ -/ -- -128 -) -= -48801 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -274 -528 -ns -/ -iter -( -+ -/ -- -1 -101 -) -= -2167 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -12 -197 -ns -/ -iter -( -+ -/ -- -191 -) -= -48776 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -446 -264 -ns -/ -iter -( -+ -/ -- -5 -936 -) -= -1333 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -69 -728 -764 -ns -/ -iter -( -+ -/ -- -155 -104 -) -= -8 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -493 -734 -ns -/ -iter -( -+ -/ -- -5 -997 -) -= -1204 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -339 -088 -ns -/ -iter -( -+ -/ -- -3 -760 -) -= -1754 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -30 -957 -ns -/ -iter -( -+ -/ -- -313 -) -= -19218 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -921 -059 -ns -/ -iter -( -+ -/ -- -8 -102 -) -= -645 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -530 -899 -ns -/ -iter -( -+ -/ -- -18 -006 -) -= -388 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -6 -959 -355 -ns -/ -iter -( -+ -/ -- -31 -671 -) -= -85 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -96 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/stdcpp b/third_party/rust/regex/record/old-bench-log/07/stdcpp deleted file mode 100644 index 030bfbb89805f..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/stdcpp +++ /dev/null @@ -1,2259 +0,0 @@ -running -82 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -142 -ns -/ -iter -( -+ -/ -- -0 -) -= -2746 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -5 -504 -ns -/ -iter -( -+ -/ -- -20 -) -= -70 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -143 -ns -/ -iter -( -+ -/ -- -0 -) -= -181 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -471 -ns -/ -iter -( -+ -/ -- -1 -) -= -55 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -14 -534 -ns -/ -iter -( -+ -/ -- -87 -) -= -72 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -14 -554 -912 -ns -/ -iter -( -+ -/ -- -33 -264 -) -= -72 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -730 -ns -/ -iter -( -+ -/ -- -1 -) -= -80 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -454 -911 -ns -/ -iter -( -+ -/ -- -526 -) -= -72 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -14 -486 -ns -/ -iter -( -+ -/ -- -45 -) -= -72 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -14 -555 -850 -ns -/ -iter -( -+ -/ -- -108 -290 -) -= -72 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -692 -ns -/ -iter -( -+ -/ -- -1 -) -= -75 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -456 -269 -ns -/ -iter -( -+ -/ -- -2 -856 -) -= -71 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -299 -581 -ns -/ -iter -( -+ -/ -- -7 -493 -) -= -3 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -314 -289 -240 -ns -/ -iter -( -+ -/ -- -128 -869 -) -= -3 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -9 -202 -ns -/ -iter -( -+ -/ -- -17 -) -= -6 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -9 -777 -807 -ns -/ -iter -( -+ -/ -- -19 -451 -) -= -3 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -804 -ns -/ -iter -( -+ -/ -- -2 -) -= -63 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -15 -712 -941 -ns -/ -iter -( -+ -/ -- -23 -893 -) -= -6 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -15 -955 -109 -ns -/ -iter -( -+ -/ -- -26 -652 -) -= -6 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -1 -250 -ns -/ -iter -( -+ -/ -- -4 -) -= -64 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -1 -250 -ns -/ -iter -( -+ -/ -- -4 -) -= -64 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -14 -913 -ns -/ -iter -( -+ -/ -- -108 -) -= -70 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -14 -929 -542 -ns -/ -iter -( -+ -/ -- -38 -890 -) -= -70 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -736 -ns -/ -iter -( -+ -/ -- -0 -) -= -81 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -466 -504 -ns -/ -iter -( -+ -/ -- -1 -488 -) -= -70 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -1 -015 -ns -/ -iter -( -+ -/ -- -8 -) -= -50 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -262 -ns -/ -iter -( -+ -/ -- -0 -) -= -99 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -263 -ns -/ -iter -( -+ -/ -- -3 -) -= -98 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -502 -ns -/ -iter -( -+ -/ -- -2 -) -= -33 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -498 -ns -/ -iter -( -+ -/ -- -0 -) -= -34 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -304 -485 -ns -/ -iter -( -+ -/ -- -762 -) -= -3 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -292 -315 -ns -/ -iter -( -+ -/ -- -1 -985 -) -= -3 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -313 -208 -610 -ns -/ -iter -( -+ -/ -- -163 -013 -) -= -3 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -9 -232 -ns -/ -iter -( -+ -/ -- -21 -) -= -6 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -9 -952 -463 -ns -/ -iter -( -+ -/ -- -22 -317 -) -= -3 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -114 -029 -ns -/ -iter -( -+ -/ -- -734 -) -= -70 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -121 -481 -845 -ns -/ -iter -( -+ -/ -- -289 -966 -) -= -41 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -73 -580 -323 -ns -/ -iter -( -+ -/ -- -82 -998 -) -= -69 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -73 -588 -543 -ns -/ -iter -( -+ -/ -- -95 -250 -) -= -69 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -73 -592 -436 -ns -/ -iter -( -+ -/ -- -86 -358 -) -= -69 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -73 -581 -323 -ns -/ -iter -( -+ -/ -- -88 -210 -) -= -69 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -73 -577 -422 -ns -/ -iter -( -+ -/ -- -48 -215 -) -= -69 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -73 -586 -896 -ns -/ -iter -( -+ -/ -- -82 -117 -) -= -69 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -73 -652 -696 -ns -/ -iter -( -+ -/ -- -95 -155 -) -= -69 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -74 -633 -620 -ns -/ -iter -( -+ -/ -- -74 -754 -) -= -68 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -73 -586 -338 -ns -/ -iter -( -+ -/ -- -82 -645 -) -= -69 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -75 -009 -572 -ns -/ -iter -( -+ -/ -- -116 -800 -) -= -67 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -73 -581 -469 -ns -/ -iter -( -+ -/ -- -146 -286 -) -= -69 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -140 -768 -740 -ns -/ -iter -( -+ -/ -- -113 -580 -) -= -36 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -153 -330 -005 -ns -/ -iter -( -+ -/ -- -11 -581 -095 -) -= -33 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -145 -484 -512 -ns -/ -iter -( -+ -/ -- -150 -566 -) -= -34 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -141 -659 -767 -ns -/ -iter -( -+ -/ -- -123 -940 -) -= -35 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -145 -309 -207 -ns -/ -iter -( -+ -/ -- -129 -675 -) -= -34 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -141 -145 -017 -ns -/ -iter -( -+ -/ -- -164 -414 -) -= -36 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -141 -897 -206 -ns -/ -iter -( -+ -/ -- -212 -981 -) -= -35 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -150 -467 -139 -ns -/ -iter -( -+ -/ -- -120 -619 -) -= -33 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -151 -635 -430 -ns -/ -iter -( -+ -/ -- -128 -912 -) -= -33 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -36 -941 -681 -ns -/ -iter -( -+ -/ -- -36 -199 -) -= -16 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -36 -920 -860 -ns -/ -iter -( -+ -/ -- -38 -258 -) -= -16 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -9 -047 -684 -ns -/ -iter -( -+ -/ -- -18 -290 -) -= -65 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -12 -634 -723 -ns -/ -iter -( -+ -/ -- -36 -086 -) -= -47 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -30 -232 -323 -ns -/ -iter -( -+ -/ -- -49 -084 -) -= -19 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -18 -837 -733 -ns -/ -iter -( -+ -/ -- -39 -569 -) -= -31 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -12 -462 -918 -ns -/ -iter -( -+ -/ -- -17 -158 -) -= -47 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -12 -490 -419 -ns -/ -iter -( -+ -/ -- -26 -214 -) -= -47 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -33 -156 -941 -ns -/ -iter -( -+ -/ -- -47 -236 -) -= -17 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -12 -583 -828 -ns -/ -iter -( -+ -/ -- -26 -121 -) -= -47 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -16 -615 -345 -ns -/ -iter -( -+ -/ -- -22 -930 -) -= -35 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -8 -307 -917 -ns -/ -iter -( -+ -/ -- -17 -452 -) -= -71 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -8 -273 -395 -ns -/ -iter -( -+ -/ -- -25 -717 -) -= -71 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -8 -270 -000 -ns -/ -iter -( -+ -/ -- -19 -702 -) -= -71 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -8 -453 -784 -ns -/ -iter -( -+ -/ -- -19 -604 -) -= -70 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -8 -679 -069 -ns -/ -iter -( -+ -/ -- -27 -721 -) -= -68 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -8 -679 -099 -ns -/ -iter -( -+ -/ -- -17 -665 -) -= -68 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -8 -260 -259 -ns -/ -iter -( -+ -/ -- -147 -913 -) -= -72 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -10 -257 -367 -ns -/ -iter -( -+ -/ -- -25 -054 -) -= -58 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -25 -374 -678 -ns -/ -iter -( -+ -/ -- -23 -494 -) -= -23 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -9 -424 -206 -ns -/ -iter -( -+ -/ -- -23 -231 -) -= -63 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -8 -350 -015 -ns -/ -iter -( -+ -/ -- -23 -176 -) -= -71 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -9 -285 -991 -ns -/ -iter -( -+ -/ -- -16 -835 -) -= -64 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -69 -609 -427 -ns -/ -iter -( -+ -/ -- -52 -974 -) -= -8 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -20 -107 -601 -ns -/ -iter -( -+ -/ -- -36 -086 -) -= -29 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -82 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/stdcpp-libcxx b/third_party/rust/regex/record/old-bench-log/07/stdcpp-libcxx deleted file mode 100644 index 96743fb8bbe8c..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/stdcpp-libcxx +++ /dev/null @@ -1,2253 +0,0 @@ -running -82 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -162 -ns -/ -iter -( -+ -/ -- -0 -) -= -2407 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -21 -901 -ns -/ -iter -( -+ -/ -- -140 -) -= -17 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -162 -ns -/ -iter -( -+ -/ -- -0 -) -= -160 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -1 -501 -ns -/ -iter -( -+ -/ -- -1 -) -= -17 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -39 -405 -ns -/ -iter -( -+ -/ -- -250 -) -= -26 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -39 -706 -678 -ns -/ -iter -( -+ -/ -- -103 -211 -) -= -26 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -1 -415 -ns -/ -iter -( -+ -/ -- -3 -) -= -41 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -1 -241 -085 -ns -/ -iter -( -+ -/ -- -5 -625 -) -= -26 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -39 -421 -ns -/ -iter -( -+ -/ -- -275 -) -= -26 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -39 -725 -158 -ns -/ -iter -( -+ -/ -- -64 -488 -) -= -26 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -1 -421 -ns -/ -iter -( -+ -/ -- -8 -) -= -36 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -1 -240 -953 -ns -/ -iter -( -+ -/ -- -5 -794 -) -= -26 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -1 -263 -948 -ns -/ -iter -( -+ -/ -- -31 -771 -) -test -misc -: -: -hard_1MB -. -. -. -bench -: -1 -331 -000 -673 -ns -/ -iter -( -+ -/ -- -7 -401 -131 -) -test -misc -: -: -hard_32 -. -. -. -bench -: -37 -752 -ns -/ -iter -( -+ -/ -- -109 -) -= -1 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -41 -044 -286 -ns -/ -iter -( -+ -/ -- -57 -765 -) -test -misc -: -: -literal -. -. -. -bench -: -1 -980 -ns -/ -iter -( -+ -/ -- -7 -) -= -25 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -12 -425 -121 -ns -/ -iter -( -+ -/ -- -36 -611 -) -= -8 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -12 -568 -992 -ns -/ -iter -( -+ -/ -- -28 -513 -) -= -7 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -3 -918 -ns -/ -iter -( -+ -/ -- -67 -) -= -20 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -3 -534 -ns -/ -iter -( -+ -/ -- -11 -) -= -22 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -44 -910 -ns -/ -iter -( -+ -/ -- -167 -) -= -23 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -45 -558 -328 -ns -/ -iter -( -+ -/ -- -77 -166 -) -= -23 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -1 -599 -ns -/ -iter -( -+ -/ -- -12 -) -= -37 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -1 -423 -945 -ns -/ -iter -( -+ -/ -- -9 -468 -) -= -23 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -2 -051 -ns -/ -iter -( -+ -/ -- -16 -) -= -24 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -222 -ns -/ -iter -( -+ -/ -- -0 -) -= -117 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -223 -ns -/ -iter -( -+ -/ -- -0 -) -= -116 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -2 -002 -ns -/ -iter -( -+ -/ -- -37 -) -= -8 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -1 -990 -ns -/ -iter -( -+ -/ -- -6 -) -= -8 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -1 -335 -845 -ns -/ -iter -( -+ -/ -- -6 -233 -) -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -208 -846 -ns -/ -iter -( -+ -/ -- -6 -070 -) -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -291 -183 -401 -ns -/ -iter -( -+ -/ -- -4 -281 -775 -) -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -36 -521 -ns -/ -iter -( -+ -/ -- -157 -) -= -1 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -40 -131 -467 -ns -/ -iter -( -+ -/ -- -66 -846 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -506 -352 -ns -/ -iter -( -+ -/ -- -632 -) -= -15 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -510 -954 -670 -ns -/ -iter -( -+ -/ -- -1 -946 -366 -) -= -9 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -198 -786 -137 -ns -/ -iter -( -+ -/ -- -240 -963 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -198 -733 -597 -ns -/ -iter -( -+ -/ -- -770 -484 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -198 -734 -922 -ns -/ -iter -( -+ -/ -- -198 -116 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -198 -735 -715 -ns -/ -iter -( -+ -/ -- -235 -337 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -198 -736 -727 -ns -/ -iter -( -+ -/ -- -157 -633 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -198 -811 -880 -ns -/ -iter -( -+ -/ -- -1 -502 -214 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -198 -697 -281 -ns -/ -iter -( -+ -/ -- -211 -978 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -198 -714 -239 -ns -/ -iter -( -+ -/ -- -1 -187 -050 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -199 -021 -730 -ns -/ -iter -( -+ -/ -- -1 -555 -969 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -199 -033 -133 -ns -/ -iter -( -+ -/ -- -213 -859 -) -= -25 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -199 -466 -527 -ns -/ -iter -( -+ -/ -- -1 -394 -750 -) -= -25 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -403 -588 -578 -ns -/ -iter -( -+ -/ -- -493 -905 -) -= -12 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -440 -582 -945 -ns -/ -iter -( -+ -/ -- -305 -836 -) -= -11 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -417 -460 -804 -ns -/ -iter -( -+ -/ -- -1 -858 -105 -) -= -12 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -407 -209 -088 -ns -/ -iter -( -+ -/ -- -1 -374 -513 -) -= -12 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -408 -665 -895 -ns -/ -iter -( -+ -/ -- -338 -946 -) -= -12 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -408 -640 -565 -ns -/ -iter -( -+ -/ -- -1 -895 -287 -) -= -12 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -406 -340 -097 -ns -/ -iter -( -+ -/ -- -2 -309 -358 -) -= -12 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -413 -195 -331 -ns -/ -iter -( -+ -/ -- -2 -178 -194 -) -= -12 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -438 -844 -927 -ns -/ -iter -( -+ -/ -- -2 -589 -599 -) -= -11 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -165 -435 -560 -ns -/ -iter -( -+ -/ -- -165 -901 -) -= -3 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -164 -466 -984 -ns -/ -iter -( -+ -/ -- -178 -082 -) -= -3 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -34 -680 -745 -ns -/ -iter -( -+ -/ -- -862 -671 -) -= -17 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -59 -712 -596 -ns -/ -iter -( -+ -/ -- -85 -049 -) -= -9 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -135 -611 -524 -ns -/ -iter -( -+ -/ -- -383 -869 -) -= -4 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -73 -398 -446 -ns -/ -iter -( -+ -/ -- -112 -893 -) -= -8 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -42 -274 -906 -ns -/ -iter -( -+ -/ -- -60 -836 -) -= -14 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -42 -159 -449 -ns -/ -iter -( -+ -/ -- -56 -642 -) -= -14 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -121 -926 -811 -ns -/ -iter -( -+ -/ -- -624 -877 -) -= -4 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -58 -912 -788 -ns -/ -iter -( -+ -/ -- -101 -576 -) -= -10 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -63 -891 -303 -ns -/ -iter -( -+ -/ -- -79 -754 -) -= -9 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -22 -995 -759 -ns -/ -iter -( -+ -/ -- -45 -074 -) -= -25 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -23 -024 -135 -ns -/ -iter -( -+ -/ -- -86 -982 -) -= -25 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -23 -026 -357 -ns -/ -iter -( -+ -/ -- -42 -271 -) -= -25 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -32 -485 -572 -ns -/ -iter -( -+ -/ -- -77 -736 -) -= -18 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -23 -544 -207 -ns -/ -iter -( -+ -/ -- -590 -037 -) -= -25 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -23 -543 -480 -ns -/ -iter -( -+ -/ -- -51 -838 -) -= -25 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -23 -024 -692 -ns -/ -iter -( -+ -/ -- -78 -358 -) -= -25 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -42 -376 -602 -ns -/ -iter -( -+ -/ -- -49 -060 -) -= -14 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -92 -701 -274 -ns -/ -iter -( -+ -/ -- -208 -063 -) -= -6 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -23 -553 -163 -ns -/ -iter -( -+ -/ -- -61 -446 -) -= -25 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -23 -281 -951 -ns -/ -iter -( -+ -/ -- -35 -811 -) -= -25 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -33 -011 -779 -ns -/ -iter -( -+ -/ -- -65 -085 -) -= -18 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -64 -965 -762 -ns -/ -iter -( -+ -/ -- -106 -103 -) -= -9 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -47 -466 -153 -ns -/ -iter -( -+ -/ -- -773 -222 -) -= -12 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -82 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/07/tcl b/third_party/rust/regex/record/old-bench-log/07/tcl deleted file mode 100644 index 869c3e3896107..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/07/tcl +++ /dev/null @@ -1,2445 +0,0 @@ -running -89 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -452 -ns -/ -iter -( -+ -/ -- -6 -) -= -862 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -92 -ns -/ -iter -( -+ -/ -- -2 -) -= -4239 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -454 -ns -/ -iter -( -+ -/ -- -6 -) -= -57 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -92 -ns -/ -iter -( -+ -/ -- -1 -) -= -282 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -9 -231 -ns -/ -iter -( -+ -/ -- -59 -) -= -113 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -2 -828 -050 -ns -/ -iter -( -+ -/ -- -9 -104 -) -= -370 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -6 -527 -ns -/ -iter -( -+ -/ -- -78 -) -= -9 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -94 -825 -ns -/ -iter -( -+ -/ -- -410 -) -= -345 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -5 -420 -ns -/ -iter -( -+ -/ -- -54 -) -= -192 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -2 -823 -597 -ns -/ -iter -( -+ -/ -- -8 -534 -) -= -371 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -2 -727 -ns -/ -iter -( -+ -/ -- -80 -) -= -19 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -93 -382 -ns -/ -iter -( -+ -/ -- -108 -) -= -351 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -12 -046 -ns -/ -iter -( -+ -/ -- -88 -) -= -87 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -2 -831 -445 -ns -/ -iter -( -+ -/ -- -9 -713 -) -= -370 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -9 -257 -ns -/ -iter -( -+ -/ -- -63 -) -= -6 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -97 -613 -ns -/ -iter -( -+ -/ -- -533 -) -= -335 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -398 -ns -/ -iter -( -+ -/ -- -14 -) -= -128 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -18 -459 -088 -ns -/ -iter -( -+ -/ -- -162 -391 -) -= -5 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -18 -390 -595 -ns -/ -iter -( -+ -/ -- -96 -143 -) -= -5 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -480 -ns -/ -iter -( -+ -/ -- -1 -) -= -168 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -477 -ns -/ -iter -( -+ -/ -- -10 -) -= -169 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -9 -573 -ns -/ -iter -( -+ -/ -- -94 -) -= -109 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -2 -828 -512 -ns -/ -iter -( -+ -/ -- -28 -270 -) -= -370 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -6 -874 -ns -/ -iter -( -+ -/ -- -68 -) -= -8 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -95 -040 -ns -/ -iter -( -+ -/ -- -517 -) -= -345 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -1 -976 -788 -ns -/ -iter -( -+ -/ -- -20 -661 -) -test -misc -: -: -not_literal -. -. -. -bench -: -1 -548 -ns -/ -iter -( -+ -/ -- -15 -) -= -32 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -5 -063 -ns -/ -iter -( -+ -/ -- -76 -) -= -5 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -4 -933 -ns -/ -iter -( -+ -/ -- -62 -) -= -5 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -486 -ns -/ -iter -( -+ -/ -- -4 -) -= -34 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -579 -ns -/ -iter -( -+ -/ -- -3 -) -= -29 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -88 -153 -ns -/ -iter -( -+ -/ -- -2 -317 -) -= -11 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -12 -157 -ns -/ -iter -( -+ -/ -- -51 -) -= -86 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -2 -866 -126 -ns -/ -iter -( -+ -/ -- -71 -338 -) -= -365 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -9 -321 -ns -/ -iter -( -+ -/ -- -138 -) -= -6 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -97 -799 -ns -/ -iter -( -+ -/ -- -1 -087 -) -= -335 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -22 -679 -ns -/ -iter -( -+ -/ -- -293 -) -= -352 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -38 -700 -951 -ns -/ -iter -( -+ -/ -- -105 -197 -) -= -131 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -22 -123 -470 -ns -/ -iter -( -+ -/ -- -96 -738 -) -= -229 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -22 -125 -412 -ns -/ -iter -( -+ -/ -- -65 -856 -) -= -229 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -22 -178 -791 -ns -/ -iter -( -+ -/ -- -75 -853 -) -= -229 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -22 -348 -278 -ns -/ -iter -( -+ -/ -- -228 -790 -) -= -227 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -22 -187 -493 -ns -/ -iter -( -+ -/ -- -69 -149 -) -= -229 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -22 -134 -373 -ns -/ -iter -( -+ -/ -- -71 -979 -) -= -229 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -22 -183 -169 -ns -/ -iter -( -+ -/ -- -66 -220 -) -= -229 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -22 -263 -432 -ns -/ -iter -( -+ -/ -- -91 -605 -) -= -228 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -22 -256 -481 -ns -/ -iter -( -+ -/ -- -62 -794 -) -= -228 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -22 -134 -314 -ns -/ -iter -( -+ -/ -- -75 -199 -) -= -229 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -22 -144 -129 -ns -/ -iter -( -+ -/ -- -76 -744 -) -= -229 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -13 -846 -793 -ns -/ -iter -( -+ -/ -- -33 -520 -) -= -367 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -14 -248 -239 -ns -/ -iter -( -+ -/ -- -62 -252 -) -= -356 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -15 -702 -520 -ns -/ -iter -( -+ -/ -- -339 -738 -) -= -323 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -15 -143 -136 -ns -/ -iter -( -+ -/ -- -52 -300 -) -= -335 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -16 -324 -698 -ns -/ -iter -( -+ -/ -- -50 -942 -) -= -311 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -14 -508 -593 -ns -/ -iter -( -+ -/ -- -46 -251 -) -= -350 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -14 -443 -485 -ns -/ -iter -( -+ -/ -- -80 -444 -) -= -351 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -14 -430 -571 -ns -/ -iter -( -+ -/ -- -63 -143 -) -= -352 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -14 -883 -129 -ns -/ -iter -( -+ -/ -- -76 -837 -) -= -341 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -2 -227 -807 -ns -/ -iter -( -+ -/ -- -9 -119 -) -= -267 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -2 -700 -579 -ns -/ -iter -( -+ -/ -- -24 -875 -) -= -220 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -2 -211 -847 -ns -/ -iter -( -+ -/ -- -15 -027 -) -= -268 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -4 -398 -150 -ns -/ -iter -( -+ -/ -- -27 -219 -) -= -135 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -17 -992 -130 -ns -/ -iter -( -+ -/ -- -457 -978 -) -= -33 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -1 -845 -704 -ns -/ -iter -( -+ -/ -- -9 -382 -) -= -322 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -1 -890 -373 -ns -/ -iter -( -+ -/ -- -9 -971 -) -= -314 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -2 -626 -524 -ns -/ -iter -( -+ -/ -- -18 -261 -) -= -226 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -4 -468 -643 -ns -/ -iter -( -+ -/ -- -11 -946 -) -= -133 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -7 -226 -342 -ns -/ -iter -( -+ -/ -- -57 -220 -) -= -82 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -2 -395 -105 -ns -/ -iter -( -+ -/ -- -31 -101 -) -= -248 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -2 -895 -153 -ns -/ -iter -( -+ -/ -- -12 -446 -) -= -205 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -3 -253 -560 -ns -/ -iter -( -+ -/ -- -33 -725 -) -= -182 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -4 -008 -656 -ns -/ -iter -( -+ -/ -- -39 -415 -) -= -148 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -2 -076 -117 -ns -/ -iter -( -+ -/ -- -6 -376 -) -= -286 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -2 -157 -634 -ns -/ -iter -( -+ -/ -- -6 -494 -) -= -275 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -1 -757 -317 -ns -/ -iter -( -+ -/ -- -5 -935 -) -= -338 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -1 -897 -004 -ns -/ -iter -( -+ -/ -- -12 -012 -) -= -313 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -1 -939 -722 -ns -/ -iter -( -+ -/ -- -6 -273 -) -= -306 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -1 -801 -334 -ns -/ -iter -( -+ -/ -- -3 -179 -) -= -330 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -1 -910 -996 -ns -/ -iter -( -+ -/ -- -6 -429 -) -= -311 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -1 -601 -431 -ns -/ -iter -( -+ -/ -- -7 -131 -) -= -371 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -1 -601 -153 -ns -/ -iter -( -+ -/ -- -4 -375 -) -= -371 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -1 -600 -840 -ns -/ -iter -( -+ -/ -- -8 -348 -) -= -371 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -7 -620 -650 -ns -/ -iter -( -+ -/ -- -48 -467 -) -= -78 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -55 -564 -521 -ns -/ -iter -( -+ -/ -- -210 -324 -) -= -10 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -5 -628 -558 -ns -/ -iter -( -+ -/ -- -19 -934 -) -= -105 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -6 -063 -195 -ns -/ -iter -( -+ -/ -- -28 -534 -) -= -98 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -1 -992 -703 -ns -/ -iter -( -+ -/ -- -6 -736 -) -= -298 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -7 -159 -423 -ns -/ -iter -( -+ -/ -- -38 -306 -) -= -83 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -38 -358 -421 -ns -/ -iter -( -+ -/ -- -99 -230 -) -= -15 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -89 -measured -; -0 -filtered -out diff --git a/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-after-01 b/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-after-01 deleted file mode 100644 index 0367348395a78..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-after-01 +++ /dev/null @@ -1,3122 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -1 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -2 -) -= -20526 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -1 -) -= -1444 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -1368 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -2 -) -= -70066 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -47663772 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -2 -) -= -4214 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -1 -) -= -2186333 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -2 -) -= -26100 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -5 -) -= -23831727 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -5 -) -= -1333 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -3 -) -= -799707 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -7 -) -= -21020 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -6 -) -= -19065509 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -7 -) -= -1180 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -2 -) -= -655900 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -60 -ns -/ -iter -( -+ -/ -- -2 -) -= -416 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -1 -) -= -4250 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -3 -252 -ns -/ -iter -( -+ -/ -- -168 -) -= -30750 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -355 -576 -ns -/ -iter -( -+ -/ -- -34 -074 -) -= -281 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -67 -ns -/ -iter -( -+ -/ -- -2 -) -= -1208 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -5785 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -256 -ns -/ -iter -( -+ -/ -- -36 -) -= -628 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -458 -ns -/ -iter -( -+ -/ -- -65 -) -= -54 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -1 -) -= -70133 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -2 -) -= -45591478 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -4000 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -2186400 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -406 -ns -/ -iter -( -+ -/ -- -32 -) -= -246 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -90 -ns -/ -iter -( -+ -/ -- -12 -) -= -566 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -1 -) -= -490 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -7 -) -= -509 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -1 -) -= -459 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -5 -) -= -435 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -75 -ns -/ -iter -( -+ -/ -- -2 -) -= -13866 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -591 -ns -/ -iter -( -+ -/ -- -227 -) -= -660 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -576 -602 -ns -/ -iter -( -+ -/ -- -204 -573 -) -= -665 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -102 -ns -/ -iter -( -+ -/ -- -7 -) -= -578 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -49 -327 -ns -/ -iter -( -+ -/ -- -4 -812 -) -= -664 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -132 -ns -/ -iter -( -+ -/ -- -13 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -190 -ns -/ -iter -( -+ -/ -- -581 -) -= -1909 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -132 -982 -ns -/ -iter -( -+ -/ -- -18 -045 -) -= -60158 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -14 -720 -ns -/ -iter -( -+ -/ -- -946 -) -= -54348 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -5 -993 -ns -/ -iter -( -+ -/ -- -381 -) -= -13350 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -476 -ns -/ -iter -( -+ -/ -- -58 -) -= -16829 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -227 -ns -/ -iter -( -+ -/ -- -22 -) -= -3572 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -211 -ns -/ -iter -( -+ -/ -- -13 -) -= -431 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -204 -ns -/ -iter -( -+ -/ -- -29 -) -= -93 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -206 -ns -/ -iter -( -+ -/ -- -7 -) -= -131 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -212 -ns -/ -iter -( -+ -/ -- -16 -) -= -165 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -207 -ns -/ -iter -( -+ -/ -- -29 -) -= -207 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -053 -740 -ns -/ -iter -( -+ -/ -- -393 -644 -) -= -421 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -786 -112 -ns -/ -iter -( -+ -/ -- -91 -136 -) -= -6466 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -831 -353 -ns -/ -iter -( -+ -/ -- -67 -293 -) -= -6114 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -784 -021 -ns -/ -iter -( -+ -/ -- -28 -112 -) -= -6483 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -785 -838 -ns -/ -iter -( -+ -/ -- -108 -510 -) -= -6468 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -791 -789 -ns -/ -iter -( -+ -/ -- -37 -364 -) -= -6420 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -784 -224 -ns -/ -iter -( -+ -/ -- -23 -802 -) -= -6482 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -788 -368 -ns -/ -iter -( -+ -/ -- -75 -171 -) -= -6448 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -784 -730 -ns -/ -iter -( -+ -/ -- -48 -594 -) -= -6477 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -788 -067 -ns -/ -iter -( -+ -/ -- -88 -333 -) -= -6450 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -810 -784 -ns -/ -iter -( -+ -/ -- -111 -836 -) -= -6269 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -788 -854 -ns -/ -iter -( -+ -/ -- -66 -496 -) -= -6444 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -238 -677 -ns -/ -iter -( -+ -/ -- -144 -752 -) -= -2270 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -258 -761 -ns -/ -iter -( -+ -/ -- -205 -012 -) -= -1559 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -3 -818 -146 -ns -/ -iter -( -+ -/ -- -254 -877 -) -= -1331 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -3 -837 -323 -ns -/ -iter -( -+ -/ -- -349 -373 -) -= -1324 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -2 -698 -901 -ns -/ -iter -( -+ -/ -- -111 -145 -) -= -1883 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -2 -687 -854 -ns -/ -iter -( -+ -/ -- -184 -039 -) -= -1891 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -3 -291 -211 -ns -/ -iter -( -+ -/ -- -220 -992 -) -= -1544 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -3 -359 -262 -ns -/ -iter -( -+ -/ -- -185 -610 -) -= -1513 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -293 -953 -ns -/ -iter -( -+ -/ -- -245 -454 -) -= -1543 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -95 -142 -ns -/ -iter -( -+ -/ -- -10 -195 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -5 -650 -680 -ns -/ -iter -( -+ -/ -- -252 -936 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -10 -867 -986 -ns -/ -iter -( -+ -/ -- -275 -259 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -3 -751 -ns -/ -iter -( -+ -/ -- -310 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -3 -664 -ns -/ -iter -( -+ -/ -- -172 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -22 -078 -ns -/ -iter -( -+ -/ -- -3 -259 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -8 -499 -ns -/ -iter -( -+ -/ -- -942 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -151 -196 -ns -/ -iter -( -+ -/ -- -16 -322 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -309 -597 -ns -/ -iter -( -+ -/ -- -32 -622 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -917 -591 -ns -/ -iter -( -+ -/ -- -55 -643 -) -= -648 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -62 -726 -ns -/ -iter -( -+ -/ -- -8 -861 -) -= -9484 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -036 -050 -ns -/ -iter -( -+ -/ -- -152 -461 -) -= -292 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -796 -690 -ns -/ -iter -( -+ -/ -- -71 -089 -) -= -746 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -106 -258 -ns -/ -iter -( -+ -/ -- -8 -294 -) -= -5598 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -481 -086 -ns -/ -iter -( -+ -/ -- -60 -212 -) -= -1236 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -322 -033 -ns -/ -iter -( -+ -/ -- -8 -912 -) -= -1847 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -067 -523 -ns -/ -iter -( -+ -/ -- -89 -630 -) -= -557 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -22 -745 -932 -ns -/ -iter -( -+ -/ -- -428 -787 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -22 -228 -365 -ns -/ -iter -( -+ -/ -- -495 -287 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -775 -941 -ns -/ -iter -( -+ -/ -- -158 -985 -) -= -334 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -897 -327 -ns -/ -iter -( -+ -/ -- -49 -085 -) -= -663 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -32 -008 -ns -/ -iter -( -+ -/ -- -4 -011 -) -= -18587 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -86 -850 -ns -/ -iter -( -+ -/ -- -5 -463 -) -= -6850 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -98 -359 -ns -/ -iter -( -+ -/ -- -14 -052 -) -= -6048 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -381 -147 -ns -/ -iter -( -+ -/ -- -16 -996 -) -= -1560 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -121 -025 -ns -/ -iter -( -+ -/ -- -16 -654 -) -= -4915 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -188 -972 -ns -/ -iter -( -+ -/ -- -26 -145 -) -= -3148 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -91 -832 -ns -/ -iter -( -+ -/ -- -6 -188 -) -= -6478 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -351 -422 -ns -/ -iter -( -+ -/ -- -49 -084 -) -= -1692 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -33 -405 -ns -/ -iter -( -+ -/ -- -3 -113 -) -= -17809 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -134 -899 -ns -/ -iter -( -+ -/ -- -10 -883 -) -= -4410 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -22 -455 -ns -/ -iter -( -+ -/ -- -2 -027 -) -= -26494 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -22 -283 -ns -/ -iter -( -+ -/ -- -2 -281 -) -= -26698 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -97 -492 -ns -/ -iter -( -+ -/ -- -6 -496 -) -= -6102 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -95 -627 -ns -/ -iter -( -+ -/ -- -8 -442 -) -= -6221 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -30 -702 -ns -/ -iter -( -+ -/ -- -4 -194 -) -= -19377 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -19 -616 -ns -/ -iter -( -+ -/ -- -2 -677 -) -= -30328 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -25 -601 -ns -/ -iter -( -+ -/ -- -2 -506 -) -= -23238 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -19 -641 -ns -/ -iter -( -+ -/ -- -2 -175 -) -= -30290 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -369 -048 -ns -/ -iter -( -+ -/ -- -25 -898 -) -= -1612 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -75 -780 -396 -ns -/ -iter -( -+ -/ -- -1 -032 -817 -) -= -7 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -327 -762 -ns -/ -iter -( -+ -/ -- -48 -769 -) -= -1815 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -532 -075 -ns -/ -iter -( -+ -/ -- -40 -117 -) -= -1118 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -45 -197 -ns -/ -iter -( -+ -/ -- -1 -621 -) -= -13163 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -819 -239 -ns -/ -iter -( -+ -/ -- -81 -388 -) -= -726 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -716 -625 -ns -/ -iter -( -+ -/ -- -120 -247 -) -= -346 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -690 -764 -ns -/ -iter -( -+ -/ -- -322 -915 -) -= -68 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -114 -. -31s diff --git a/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-after-02 b/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-after-02 deleted file mode 100644 index 63643b4846f7d..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-after-02 +++ /dev/null @@ -1,3123 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -2 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -1 -) -= -20526 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -1 -) -= -1444 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -2 -) -= -1368 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -1 -) -= -70066 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -1 -) -= -47663772 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -1 -) -= -4214 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -1 -) -= -2186333 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -4 -) -= -26769 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -3 -) -= -24385953 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -4 -) -= -1333 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -3 -) -= -840717 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -5 -) -= -21020 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -7 -) -= -19065509 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -5 -) -= -1180 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -6 -) -= -655900 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -60 -ns -/ -iter -( -+ -/ -- -4 -) -= -416 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -4250 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -3 -251 -ns -/ -iter -( -+ -/ -- -333 -) -= -30760 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -355 -576 -ns -/ -iter -( -+ -/ -- -24 -612 -) -= -281 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -66 -ns -/ -iter -( -+ -/ -- -1 -) -= -1227 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -1 -) -= -5785 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -254 -ns -/ -iter -( -+ -/ -- -25 -) -= -633 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -456 -ns -/ -iter -( -+ -/ -- -17 -) -= -54 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -70133 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -2 -) -= -45591478 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -2 -) -= -4000 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -2 -) -= -2186400 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -403 -ns -/ -iter -( -+ -/ -- -55 -) -= -248 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -90 -ns -/ -iter -( -+ -/ -- -12 -) -= -566 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -7 -) -= -509 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -5 -) -= -509 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -5 -) -= -447 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -1 -) -= -435 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -75 -ns -/ -iter -( -+ -/ -- -2 -) -= -13866 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -592 -ns -/ -iter -( -+ -/ -- -148 -) -= -660 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -576 -299 -ns -/ -iter -( -+ -/ -- -142 -145 -) -= -665 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -103 -ns -/ -iter -( -+ -/ -- -8 -) -= -572 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -49 -326 -ns -/ -iter -( -+ -/ -- -3 -202 -) -= -664 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -132 -ns -/ -iter -( -+ -/ -- -16 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -168 -ns -/ -iter -( -+ -/ -- -227 -) -= -1919 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -132 -733 -ns -/ -iter -( -+ -/ -- -18 -141 -) -= -60271 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -14 -468 -ns -/ -iter -( -+ -/ -- -1 -777 -) -= -55295 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -6 -316 -ns -/ -iter -( -+ -/ -- -360 -) -= -12667 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -474 -ns -/ -iter -( -+ -/ -- -69 -) -= -16900 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -229 -ns -/ -iter -( -+ -/ -- -32 -) -= -3541 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -212 -ns -/ -iter -( -+ -/ -- -18 -) -= -429 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -205 -ns -/ -iter -( -+ -/ -- -28 -) -= -92 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -207 -ns -/ -iter -( -+ -/ -- -20 -) -= -130 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -213 -ns -/ -iter -( -+ -/ -- -7 -) -= -164 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -208 -ns -/ -iter -( -+ -/ -- -9 -) -= -206 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -050 -847 -ns -/ -iter -( -+ -/ -- -346 -484 -) -= -421 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -817 -689 -ns -/ -iter -( -+ -/ -- -104 -629 -) -= -6216 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -788 -728 -ns -/ -iter -( -+ -/ -- -66 -497 -) -= -6445 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -787 -188 -ns -/ -iter -( -+ -/ -- -49 -158 -) -= -6457 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -787 -143 -ns -/ -iter -( -+ -/ -- -108 -541 -) -= -6458 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -792 -452 -ns -/ -iter -( -+ -/ -- -32 -963 -) -= -6414 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -820 -043 -ns -/ -iter -( -+ -/ -- -71 -037 -) -= -6198 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -790 -043 -ns -/ -iter -( -+ -/ -- -39 -234 -) -= -6434 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -785 -007 -ns -/ -iter -( -+ -/ -- -18 -701 -) -= -6475 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -789 -393 -ns -/ -iter -( -+ -/ -- -51 -525 -) -= -6439 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -784 -190 -ns -/ -iter -( -+ -/ -- -90 -675 -) -= -6482 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -789 -021 -ns -/ -iter -( -+ -/ -- -88 -256 -) -= -6442 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -237 -592 -ns -/ -iter -( -+ -/ -- -146 -174 -) -= -2271 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -255 -382 -ns -/ -iter -( -+ -/ -- -179 -473 -) -= -1561 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -3 -812 -799 -ns -/ -iter -( -+ -/ -- -210 -786 -) -= -1333 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -3 -853 -476 -ns -/ -iter -( -+ -/ -- -263 -442 -) -= -1319 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -2 -696 -756 -ns -/ -iter -( -+ -/ -- -161 -353 -) -= -1885 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -2 -683 -221 -ns -/ -iter -( -+ -/ -- -149 -650 -) -= -1894 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -3 -289 -426 -ns -/ -iter -( -+ -/ -- -209 -217 -) -= -1545 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -3 -362 -858 -ns -/ -iter -( -+ -/ -- -274 -273 -) -= -1511 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -287 -253 -ns -/ -iter -( -+ -/ -- -188 -894 -) -= -1546 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -94 -912 -ns -/ -iter -( -+ -/ -- -12 -311 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -5 -534 -281 -ns -/ -iter -( -+ -/ -- -192 -069 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -10 -969 -970 -ns -/ -iter -( -+ -/ -- -312 -230 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -3 -523 -ns -/ -iter -( -+ -/ -- -525 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -3 -564 -ns -/ -iter -( -+ -/ -- -355 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -19 -887 -ns -/ -iter -( -+ -/ -- -1 -885 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -8 -294 -ns -/ -iter -( -+ -/ -- -1 -123 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -153 -070 -ns -/ -iter -( -+ -/ -- -20 -825 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -313 -318 -ns -/ -iter -( -+ -/ -- -28 -271 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -907 -585 -ns -/ -iter -( -+ -/ -- -86 -027 -) -= -655 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -62 -765 -ns -/ -iter -( -+ -/ -- -6 -413 -) -= -9478 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -033 -519 -ns -/ -iter -( -+ -/ -- -97 -963 -) -= -292 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -796 -514 -ns -/ -iter -( -+ -/ -- -48 -247 -) -= -746 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -107 -788 -ns -/ -iter -( -+ -/ -- -15 -545 -) -= -5519 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -482 -686 -ns -/ -iter -( -+ -/ -- -49 -033 -) -= -1232 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -322 -901 -ns -/ -iter -( -+ -/ -- -46 -329 -) -= -1842 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -067 -799 -ns -/ -iter -( -+ -/ -- -57 -022 -) -= -557 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -22 -823 -246 -ns -/ -iter -( -+ -/ -- -472 -094 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -22 -137 -278 -ns -/ -iter -( -+ -/ -- -443 -188 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -773 -598 -ns -/ -iter -( -+ -/ -- -96 -994 -) -= -335 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -897 -623 -ns -/ -iter -( -+ -/ -- -48 -509 -) -= -662 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -31 -882 -ns -/ -iter -( -+ -/ -- -3 -354 -) -= -18660 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -86 -500 -ns -/ -iter -( -+ -/ -- -7 -997 -) -= -6877 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -98 -159 -ns -/ -iter -( -+ -/ -- -6 -106 -) -= -6060 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -383 -858 -ns -/ -iter -( -+ -/ -- -19 -224 -) -= -1549 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -122 -489 -ns -/ -iter -( -+ -/ -- -17 -271 -) -= -4857 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -192 -081 -ns -/ -iter -( -+ -/ -- -10 -999 -) -= -3097 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -91 -396 -ns -/ -iter -( -+ -/ -- -6 -399 -) -= -6509 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -354 -804 -ns -/ -iter -( -+ -/ -- -26 -158 -) -= -1676 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -33 -569 -ns -/ -iter -( -+ -/ -- -4 -647 -) -= -17722 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -136 -387 -ns -/ -iter -( -+ -/ -- -14 -005 -) -= -4362 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -22 -468 -ns -/ -iter -( -+ -/ -- -1 -144 -) -= -26479 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -22 -279 -ns -/ -iter -( -+ -/ -- -1 -563 -) -= -26703 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -98 -003 -ns -/ -iter -( -+ -/ -- -10 -978 -) -= -6070 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -96 -130 -ns -/ -iter -( -+ -/ -- -4 -373 -) -= -6188 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -30 -532 -ns -/ -iter -( -+ -/ -- -3 -125 -) -= -19485 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -19 -644 -ns -/ -iter -( -+ -/ -- -2 -118 -) -= -30285 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -25 -374 -ns -/ -iter -( -+ -/ -- -1 -538 -) -= -23446 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -19 -602 -ns -/ -iter -( -+ -/ -- -427 -) -= -30350 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -369 -657 -ns -/ -iter -( -+ -/ -- -52 -406 -) -= -1609 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -76 -922 -839 -ns -/ -iter -( -+ -/ -- -1 -261 -770 -) -= -7 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -326 -221 -ns -/ -iter -( -+ -/ -- -35 -683 -) -= -1823 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -525 -254 -ns -/ -iter -( -+ -/ -- -26 -000 -) -= -1132 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -44 -702 -ns -/ -iter -( -+ -/ -- -5 -012 -) -= -13308 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -814 -494 -ns -/ -iter -( -+ -/ -- -66 -715 -) -= -730 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -705 -139 -ns -/ -iter -( -+ -/ -- -97 -420 -) -= -348 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -632 -437 -ns -/ -iter -( -+ -/ -- -278 -177 -) -= -68 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -106 -. -01s diff --git a/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-before-01 b/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-before-01 deleted file mode 100644 index ec139f2661c30..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-before-01 +++ /dev/null @@ -1,3123 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -1 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -1 -) -= -22941 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -2 -) -= -1625 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -2 -) -= -1529 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -1 -) -= -87583 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -69906866 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -5363 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -2 -) -= -2732916 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -5 -) -= -26769 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -6 -) -= -26214900 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -3 -) -= -1333 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -5 -) -= -840717 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -1 -) -= -21448 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -2 -) -= -20165442 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -2 -) -= -1204 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -3 -) -= -669285 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -59 -ns -/ -iter -( -+ -/ -- -2 -) -= -423 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -1 -) -= -4636 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -161 -ns -/ -iter -( -+ -/ -- -54 -) -= -86133 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -680 -687 -ns -/ -iter -( -+ -/ -- -63 -713 -) -= -146 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -69 -ns -/ -iter -( -+ -/ -- -4 -) -= -1173 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -6230 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -253 -ns -/ -iter -( -+ -/ -- -9 -) -= -636 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -453 -ns -/ -iter -( -+ -/ -- -65 -) -= -55 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -80923 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -2 -) -= -61682588 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -4615 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -2522769 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -330 -ns -/ -iter -( -+ -/ -- -47 -) -= -303 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -9 -) -= -579 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -7 -) -= -520 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -2 -) -= -520 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -4 -) -= -472 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -2 -) -= -435 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -7 -) -= -18909 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -590 -ns -/ -iter -( -+ -/ -- -225 -) -= -661 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -580 -163 -ns -/ -iter -( -+ -/ -- -224 -935 -) -= -663 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -100 -ns -/ -iter -( -+ -/ -- -6 -) -= -590 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -49 -318 -ns -/ -iter -( -+ -/ -- -6 -046 -) -= -664 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -127 -ns -/ -iter -( -+ -/ -- -14 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -240 -ns -/ -iter -( -+ -/ -- -117 -) -= -1886 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -89 -004 -ns -/ -iter -( -+ -/ -- -2 -927 -) -= -89883 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -10 -349 -ns -/ -iter -( -+ -/ -- -334 -) -= -77303 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -5 -835 -ns -/ -iter -( -+ -/ -- -700 -) -= -13712 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -563 -ns -/ -iter -( -+ -/ -- -33 -) -= -14229 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -260 -ns -/ -iter -( -+ -/ -- -21 -) -= -3119 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -221 -ns -/ -iter -( -+ -/ -- -31 -) -= -411 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -211 -ns -/ -iter -( -+ -/ -- -30 -) -= -90 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -213 -ns -/ -iter -( -+ -/ -- -19 -) -= -126 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -212 -ns -/ -iter -( -+ -/ -- -7 -) -= -165 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -221 -ns -/ -iter -( -+ -/ -- -26 -) -= -194 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -035 -248 -ns -/ -iter -( -+ -/ -- -362 -122 -) -= -422 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -787 -853 -ns -/ -iter -( -+ -/ -- -29 -667 -) -= -6452 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -750 -718 -ns -/ -iter -( -+ -/ -- -103 -118 -) -= -6771 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -749 -377 -ns -/ -iter -( -+ -/ -- -103 -312 -) -= -6783 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -748 -785 -ns -/ -iter -( -+ -/ -- -83 -175 -) -= -6788 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -755 -004 -ns -/ -iter -( -+ -/ -- -75 -589 -) -= -6732 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -747 -617 -ns -/ -iter -( -+ -/ -- -70 -600 -) -= -6799 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -752 -458 -ns -/ -iter -( -+ -/ -- -86 -154 -) -= -6755 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -749 -801 -ns -/ -iter -( -+ -/ -- -102 -642 -) -= -6779 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -760 -975 -ns -/ -iter -( -+ -/ -- -105 -159 -) -= -6680 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -749 -002 -ns -/ -iter -( -+ -/ -- -82 -082 -) -= -6786 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -751 -248 -ns -/ -iter -( -+ -/ -- -100 -152 -) -= -6766 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -211 -035 -ns -/ -iter -( -+ -/ -- -150 -147 -) -= -2299 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -210 -193 -ns -/ -iter -( -+ -/ -- -161 -942 -) -= -1583 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -3 -793 -641 -ns -/ -iter -( -+ -/ -- -203 -795 -) -= -1339 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -3 -799 -721 -ns -/ -iter -( -+ -/ -- -140 -933 -) -= -1337 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -2 -652 -750 -ns -/ -iter -( -+ -/ -- -185 -489 -) -= -1916 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -2 -633 -257 -ns -/ -iter -( -+ -/ -- -211 -323 -) -= -1930 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -3 -268 -111 -ns -/ -iter -( -+ -/ -- -176 -273 -) -= -1555 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -3 -331 -333 -ns -/ -iter -( -+ -/ -- -264 -431 -) -= -1525 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -268 -398 -ns -/ -iter -( -+ -/ -- -298 -223 -) -= -1555 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -94 -562 -ns -/ -iter -( -+ -/ -- -2 -194 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -5 -611 -428 -ns -/ -iter -( -+ -/ -- -202 -365 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -10 -933 -505 -ns -/ -iter -( -+ -/ -- -325 -078 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -3 -496 -ns -/ -iter -( -+ -/ -- -156 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -3 -572 -ns -/ -iter -( -+ -/ -- -389 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -20 -283 -ns -/ -iter -( -+ -/ -- -1 -894 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -8 -475 -ns -/ -iter -( -+ -/ -- -1 -008 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -157 -446 -ns -/ -iter -( -+ -/ -- -11 -319 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -316 -041 -ns -/ -iter -( -+ -/ -- -23 -620 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -906 -578 -ns -/ -iter -( -+ -/ -- -129 -507 -) -= -656 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -64 -715 -ns -/ -iter -( -+ -/ -- -9 -107 -) -= -9193 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -065 -017 -ns -/ -iter -( -+ -/ -- -156 -855 -) -= -288 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -810 -672 -ns -/ -iter -( -+ -/ -- -100 -547 -) -= -733 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -106 -124 -ns -/ -iter -( -+ -/ -- -10 -948 -) -= -5606 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -488 -503 -ns -/ -iter -( -+ -/ -- -63 -243 -) -= -1217 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -384 -936 -ns -/ -iter -( -+ -/ -- -25 -316 -) -= -1545 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -060 -294 -ns -/ -iter -( -+ -/ -- -152 -263 -) -= -561 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -22 -127 -059 -ns -/ -iter -( -+ -/ -- -413 -502 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -21 -535 -012 -ns -/ -iter -( -+ -/ -- -463 -835 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -758 -480 -ns -/ -iter -( -+ -/ -- -130 -352 -) -= -338 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -897 -329 -ns -/ -iter -( -+ -/ -- -96 -625 -) -= -663 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -31 -585 -ns -/ -iter -( -+ -/ -- -2 -796 -) -= -18835 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -86 -223 -ns -/ -iter -( -+ -/ -- -9 -553 -) -= -6899 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -97 -177 -ns -/ -iter -( -+ -/ -- -11 -479 -) -= -6122 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -381 -511 -ns -/ -iter -( -+ -/ -- -55 -025 -) -= -1559 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -121 -672 -ns -/ -iter -( -+ -/ -- -9 -253 -) -= -4889 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -187 -887 -ns -/ -iter -( -+ -/ -- -26 -932 -) -= -3166 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -90 -732 -ns -/ -iter -( -+ -/ -- -7 -251 -) -= -6557 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -352 -388 -ns -/ -iter -( -+ -/ -- -50 -408 -) -= -1688 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -33 -836 -ns -/ -iter -( -+ -/ -- -3 -388 -) -= -17582 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -133 -068 -ns -/ -iter -( -+ -/ -- -7 -602 -) -= -4470 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -62 -719 -ns -/ -iter -( -+ -/ -- -8 -927 -) -= -9485 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -24 -688 -ns -/ -iter -( -+ -/ -- -2 -482 -) -= -24098 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -97 -793 -ns -/ -iter -( -+ -/ -- -12 -078 -) -= -6083 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -95 -772 -ns -/ -iter -( -+ -/ -- -13 -713 -) -= -6211 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -70 -942 -ns -/ -iter -( -+ -/ -- -5 -565 -) -= -8386 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -14 -645 -ns -/ -iter -( -+ -/ -- -1 -430 -) -= -40623 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -239 -346 -ns -/ -iter -( -+ -/ -- -17 -292 -) -= -2485 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -14 -637 -ns -/ -iter -( -+ -/ -- -1 -360 -) -= -40645 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -367 -945 -ns -/ -iter -( -+ -/ -- -35 -370 -) -= -1616 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -74 -367 -046 -ns -/ -iter -( -+ -/ -- -1 -114 -875 -) -= -7 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -463 -888 -ns -/ -iter -( -+ -/ -- -67 -551 -) -= -1282 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -520 -822 -ns -/ -iter -( -+ -/ -- -76 -131 -) -= -1142 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -37 -354 -ns -/ -iter -( -+ -/ -- -4 -110 -) -= -15926 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -922 -312 -ns -/ -iter -( -+ -/ -- -95 -082 -) -= -645 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -679 -343 -ns -/ -iter -( -+ -/ -- -165 -580 -) -= -354 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -280 -082 -ns -/ -iter -( -+ -/ -- -290 -280 -) -= -71 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -113 -. -49s diff --git a/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-before-02 b/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-before-02 deleted file mode 100644 index 539dd76d5a191..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/08-new-memmem/rust-before-02 +++ /dev/null @@ -1,3121 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -22941 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -2 -) -= -1625 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -2 -) -= -1529 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -87583 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -1 -) -= -74900214 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -1 -) -= -5363 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -1 -) -= -2732916 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -5 -) -= -27473 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -5 -) -= -26214900 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -1 -) -= -1368 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -1 -) -= -862842 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -4 -) -= -21448 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -7 -) -= -20165442 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -1 -) -= -1204 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -49 -ns -/ -iter -( -+ -/ -- -6 -) -= -669285 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -59 -ns -/ -iter -( -+ -/ -- -2 -) -= -423 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -4636 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -179 -ns -/ -iter -( -+ -/ -- -92 -) -= -84818 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -680 -418 -ns -/ -iter -( -+ -/ -- -27 -142 -) -= -146 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -68 -ns -/ -iter -( -+ -/ -- -6 -) -= -1191 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -1 -) -= -6230 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -253 -ns -/ -iter -( -+ -/ -- -33 -) -= -636 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -453 -ns -/ -iter -( -+ -/ -- -65 -) -= -55 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -1 -) -= -80923 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -2 -) -= -61682588 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -4615 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -2522769 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -330 -ns -/ -iter -( -+ -/ -- -47 -) -= -303 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -12 -) -= -579 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -6 -) -= -520 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -7 -) -= -520 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -2 -) -= -472 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -5 -) -= -447 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -7 -) -= -18909 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -590 -ns -/ -iter -( -+ -/ -- -64 -) -= -661 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -581 -975 -ns -/ -iter -( -+ -/ -- -126 -709 -) -= -662 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -100 -ns -/ -iter -( -+ -/ -- -4 -) -= -590 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -49 -323 -ns -/ -iter -( -+ -/ -- -7 -063 -) -= -664 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -127 -ns -/ -iter -( -+ -/ -- -5 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -171 -ns -/ -iter -( -+ -/ -- -624 -) -= -1918 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -88 -960 -ns -/ -iter -( -+ -/ -- -7 -710 -) -= -89928 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -10 -193 -ns -/ -iter -( -+ -/ -- -952 -) -= -78486 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -5 -798 -ns -/ -iter -( -+ -/ -- -636 -) -= -13799 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -418 -ns -/ -iter -( -+ -/ -- -60 -) -= -19165 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -258 -ns -/ -iter -( -+ -/ -- -21 -) -= -3143 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -216 -ns -/ -iter -( -+ -/ -- -21 -) -= -421 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -205 -ns -/ -iter -( -+ -/ -- -29 -) -= -92 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -206 -ns -/ -iter -( -+ -/ -- -22 -) -= -131 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -205 -ns -/ -iter -( -+ -/ -- -29 -) -= -170 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -214 -ns -/ -iter -( -+ -/ -- -6 -) -= -200 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -039 -715 -ns -/ -iter -( -+ -/ -- -410 -515 -) -= -422 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -750 -454 -ns -/ -iter -( -+ -/ -- -65 -358 -) -= -6773 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -748 -321 -ns -/ -iter -( -+ -/ -- -93 -416 -) -= -6793 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -747 -906 -ns -/ -iter -( -+ -/ -- -92 -141 -) -= -6796 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -755 -082 -ns -/ -iter -( -+ -/ -- -88 -044 -) -= -6732 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -753 -496 -ns -/ -iter -( -+ -/ -- -70 -987 -) -= -6746 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -747 -103 -ns -/ -iter -( -+ -/ -- -102 -992 -) -= -6804 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -750 -805 -ns -/ -iter -( -+ -/ -- -72 -572 -) -= -6770 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -748 -419 -ns -/ -iter -( -+ -/ -- -47 -272 -) -= -6792 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -752 -556 -ns -/ -iter -( -+ -/ -- -95 -329 -) -= -6754 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -756 -009 -ns -/ -iter -( -+ -/ -- -78 -049 -) -= -6724 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -749 -278 -ns -/ -iter -( -+ -/ -- -70 -259 -) -= -6784 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -215 -182 -ns -/ -iter -( -+ -/ -- -114 -543 -) -= -2294 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -207 -983 -ns -/ -iter -( -+ -/ -- -184 -419 -) -= -1584 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -3 -791 -716 -ns -/ -iter -( -+ -/ -- -192 -185 -) -= -1340 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -3 -809 -934 -ns -/ -iter -( -+ -/ -- -222 -872 -) -= -1334 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -2 -651 -345 -ns -/ -iter -( -+ -/ -- -183 -673 -) -= -1917 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -2 -635 -566 -ns -/ -iter -( -+ -/ -- -170 -288 -) -= -1928 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -3 -265 -519 -ns -/ -iter -( -+ -/ -- -234 -923 -) -= -1556 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -3 -340 -830 -ns -/ -iter -( -+ -/ -- -183 -129 -) -= -1521 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -267 -141 -ns -/ -iter -( -+ -/ -- -185 -543 -) -= -1555 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -94 -368 -ns -/ -iter -( -+ -/ -- -13 -293 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -5 -616 -594 -ns -/ -iter -( -+ -/ -- -243 -462 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -10 -862 -100 -ns -/ -iter -( -+ -/ -- -260 -207 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -3 -463 -ns -/ -iter -( -+ -/ -- -350 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -3 -542 -ns -/ -iter -( -+ -/ -- -504 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -20 -562 -ns -/ -iter -( -+ -/ -- -3 -117 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -8 -325 -ns -/ -iter -( -+ -/ -- -641 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -153 -450 -ns -/ -iter -( -+ -/ -- -11 -174 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -315 -871 -ns -/ -iter -( -+ -/ -- -33 -828 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -906 -423 -ns -/ -iter -( -+ -/ -- -34 -801 -) -= -656 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -64 -457 -ns -/ -iter -( -+ -/ -- -8 -343 -) -= -9229 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -058 -675 -ns -/ -iter -( -+ -/ -- -208 -885 -) -= -288 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -810 -638 -ns -/ -iter -( -+ -/ -- -39 -955 -) -= -733 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -106 -048 -ns -/ -iter -( -+ -/ -- -8 -158 -) -= -5610 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -482 -243 -ns -/ -iter -( -+ -/ -- -30 -955 -) -= -1233 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -385 -767 -ns -/ -iter -( -+ -/ -- -24 -902 -) -= -1542 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -060 -762 -ns -/ -iter -( -+ -/ -- -94 -273 -) -= -560 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -22 -127 -007 -ns -/ -iter -( -+ -/ -- -467 -539 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -21 -719 -871 -ns -/ -iter -( -+ -/ -- -459 -587 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -753 -028 -ns -/ -iter -( -+ -/ -- -172 -914 -) -= -339 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -897 -091 -ns -/ -iter -( -+ -/ -- -109 -954 -) -= -663 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -31 -636 -ns -/ -iter -( -+ -/ -- -2 -323 -) -= -18805 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -85 -898 -ns -/ -iter -( -+ -/ -- -10 -486 -) -= -6926 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -97 -104 -ns -/ -iter -( -+ -/ -- -8 -851 -) -= -6126 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -381 -487 -ns -/ -iter -( -+ -/ -- -14 -829 -) -= -1559 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -121 -301 -ns -/ -iter -( -+ -/ -- -17 -178 -) -= -4904 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -187 -262 -ns -/ -iter -( -+ -/ -- -17 -478 -) -= -3177 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -90 -773 -ns -/ -iter -( -+ -/ -- -2 -791 -) -= -6554 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -351 -900 -ns -/ -iter -( -+ -/ -- -40 -408 -) -= -1690 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -34 -767 -ns -/ -iter -( -+ -/ -- -3 -334 -) -= -17112 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -132 -953 -ns -/ -iter -( -+ -/ -- -15 -747 -) -= -4474 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -66 -566 -ns -/ -iter -( -+ -/ -- -6 -822 -) -= -8937 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -24 -481 -ns -/ -iter -( -+ -/ -- -2 -330 -) -= -24301 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -97 -531 -ns -/ -iter -( -+ -/ -- -12 -331 -) -= -6099 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -95 -808 -ns -/ -iter -( -+ -/ -- -13 -250 -) -= -6209 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -71 -342 -ns -/ -iter -( -+ -/ -- -9 -877 -) -= -8339 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -14 -704 -ns -/ -iter -( -+ -/ -- -1 -241 -) -= -40460 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -238 -731 -ns -/ -iter -( -+ -/ -- -31 -179 -) -= -2492 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -14 -620 -ns -/ -iter -( -+ -/ -- -1 -250 -) -= -40693 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -367 -740 -ns -/ -iter -( -+ -/ -- -10 -107 -) -= -1617 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -76 -315 -217 -ns -/ -iter -( -+ -/ -- -940 -903 -) -= -7 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -464 -322 -ns -/ -iter -( -+ -/ -- -14 -654 -) -= -1281 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -519 -069 -ns -/ -iter -( -+ -/ -- -59 -161 -) -= -1146 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -37 -575 -ns -/ -iter -( -+ -/ -- -2 -455 -) -= -15833 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -939 -412 -ns -/ -iter -( -+ -/ -- -60 -941 -) -= -633 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -681 -192 -ns -/ -iter -( -+ -/ -- -156 -265 -) -= -353 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -213 -141 -ns -/ -iter -( -+ -/ -- -322 -533 -) -= -72 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -94 -. -52s diff --git a/third_party/rust/regex/record/old-bench-log/09-new-baseline/pcre2 b/third_party/rust/regex/record/old-bench-log/09-new-baseline/pcre2 deleted file mode 100644 index 64a9b90f5662d..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/09-new-baseline/pcre2 +++ /dev/null @@ -1,2494 +0,0 @@ -running -93 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -48750 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -55714 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -3250 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -3714 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -32 -ns -/ -iter -( -+ -/ -- -1 -) -= -32843 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -22 -160 -ns -/ -iter -( -+ -/ -- -3 -887 -) -= -47319 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -5900 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -651 -ns -/ -iter -( -+ -/ -- -2 -) -= -50376 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -1 -) -= -29000 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -22 -982 -ns -/ -iter -( -+ -/ -- -2 -839 -) -= -45626 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -4333 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -654 -ns -/ -iter -( -+ -/ -- -2 -) -= -50134 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -469 -ns -/ -iter -( -+ -/ -- -9 -) -= -2240 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -733 -962 -ns -/ -iter -( -+ -/ -- -28 -297 -) -= -1428 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -4 -) -= -1735 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -19 -567 -ns -/ -iter -( -+ -/ -- -363 -) -= -1676 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -6375 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -257 -858 -ns -/ -iter -( -+ -/ -- -646 -) -= -387 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -259 -045 -ns -/ -iter -( -+ -/ -- -2 -220 -) -= -386 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -1 -) -= -2382 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -9 -ns -/ -iter -( -+ -/ -- -0 -) -= -9000 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -125 -ns -/ -iter -( -+ -/ -- -3 -) -= -1288 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -35 -ns -/ -iter -( -+ -/ -- -3 -) -= -30057 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -21 -126 -ns -/ -iter -( -+ -/ -- -4 -036 -) -= -49635 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -6000 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -714 -ns -/ -iter -( -+ -/ -- -122 -) -= -45932 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -2 -) -= -822 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -3250 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -3250 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -1 -) -= -894 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -1 -) -= -894 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -1 -704 -ns -/ -iter -( -+ -/ -- -17 -) -= -610 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -495 -ns -/ -iter -( -+ -/ -- -9 -) -= -2123 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -682 -371 -ns -/ -iter -( -+ -/ -- -31 -284 -) -= -1536 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -2 -) -= -1735 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -17 -994 -ns -/ -iter -( -+ -/ -- -540 -) -= -1822 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -1 -507 -ns -/ -iter -( -+ -/ -- -10 -) -= -5308 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -849 -983 -ns -/ -iter -( -+ -/ -- -25 -898 -) -= -5980 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -520 -602 -ns -/ -iter -( -+ -/ -- -12 -170 -) -= -9764 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -517 -151 -ns -/ -iter -( -+ -/ -- -19 -060 -) -= -9829 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -519 -209 -ns -/ -iter -( -+ -/ -- -12 -477 -) -= -9790 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -513 -418 -ns -/ -iter -( -+ -/ -- -19 -803 -) -= -9901 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -514 -166 -ns -/ -iter -( -+ -/ -- -13 -019 -) -= -9886 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -517 -808 -ns -/ -iter -( -+ -/ -- -30 -655 -) -= -9817 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -516 -922 -ns -/ -iter -( -+ -/ -- -17 -204 -) -= -9834 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -509 -430 -ns -/ -iter -( -+ -/ -- -20 -608 -) -= -9978 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -519 -437 -ns -/ -iter -( -+ -/ -- -10 -537 -) -= -9786 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -520 -282 -ns -/ -iter -( -+ -/ -- -25 -742 -) -= -9770 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -512 -819 -ns -/ -iter -( -+ -/ -- -11 -443 -) -= -9912 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -5 -302 -526 -ns -/ -iter -( -+ -/ -- -158 -370 -) -= -958 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -7 -421 -107 -ns -/ -iter -( -+ -/ -- -105 -716 -) -= -684 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -7 -310 -968 -ns -/ -iter -( -+ -/ -- -103 -989 -) -= -695 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -6 -152 -891 -ns -/ -iter -( -+ -/ -- -144 -194 -) -= -826 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -5 -717 -515 -ns -/ -iter -( -+ -/ -- -42 -902 -) -= -889 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -5 -840 -938 -ns -/ -iter -( -+ -/ -- -47 -730 -) -= -870 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -6 -624 -859 -ns -/ -iter -( -+ -/ -- -37 -376 -) -= -767 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -7 -308 -342 -ns -/ -iter -( -+ -/ -- -58 -395 -) -= -695 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -7 -372 -260 -ns -/ -iter -( -+ -/ -- -76 -966 -) -= -689 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -2 -817 -108 -ns -/ -iter -( -+ -/ -- -18 -002 -) -= -211 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -2 -841 -515 -ns -/ -iter -( -+ -/ -- -14 -677 -) -= -209 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -33 -066 -ns -/ -iter -( -+ -/ -- -1 -766 -) -= -17992 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -1 -299 -382 -ns -/ -iter -( -+ -/ -- -19 -674 -) -= -457 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -2 -799 -189 -ns -/ -iter -( -+ -/ -- -33 -841 -) -= -212 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -4 -923 -399 -ns -/ -iter -( -+ -/ -- -111 -904 -) -= -120 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -5 -057 -224 -ns -/ -iter -( -+ -/ -- -102 -860 -) -= -117 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -874 -306 -ns -/ -iter -( -+ -/ -- -10 -587 -) -= -680 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -15 -876 -ns -/ -iter -( -+ -/ -- -58 -) -= -37473 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -19 -349 -ns -/ -iter -( -+ -/ -- -201 -) -= -30747 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -29 -916 -ns -/ -iter -( -+ -/ -- -581 -) -= -19886 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -461 -887 -ns -/ -iter -( -+ -/ -- -5 -337 -) -= -1288 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -1 -813 -574 -ns -/ -iter -( -+ -/ -- -27 -519 -) -= -328 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -30 -155 -ns -/ -iter -( -+ -/ -- -1 -407 -) -= -19729 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -822 -605 -ns -/ -iter -( -+ -/ -- -56 -624 -) -= -723 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -426 -318 -ns -/ -iter -( -+ -/ -- -12 -233 -) -= -1395 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -1 -012 -097 -ns -/ -iter -( -+ -/ -- -27 -806 -) -= -587 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -19 -833 -ns -/ -iter -( -+ -/ -- -499 -) -= -29997 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -40 -266 -ns -/ -iter -( -+ -/ -- -2 -089 -) -= -14775 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -14 -589 -ns -/ -iter -( -+ -/ -- -115 -) -= -40779 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -14 -213 -ns -/ -iter -( -+ -/ -- -81 -) -= -41858 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -602 -296 -ns -/ -iter -( -+ -/ -- -98 -066 -) -= -987 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -479 -745 -ns -/ -iter -( -+ -/ -- -18 -070 -) -= -1240 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -14 -584 -ns -/ -iter -( -+ -/ -- -44 -) -= -40793 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -13 -499 -ns -/ -iter -( -+ -/ -- -1 -090 -) -= -44072 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -12 -507 -ns -/ -iter -( -+ -/ -- -1 -238 -) -= -47568 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -11 -534 -ns -/ -iter -( -+ -/ -- -9 -) -= -51580 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -251 -867 -ns -/ -iter -( -+ -/ -- -11 -818 -) -= -2362 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -2 -969 -330 -ns -/ -iter -( -+ -/ -- -287 -150 -) -= -200 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -206 -513 -ns -/ -iter -( -+ -/ -- -3 -294 -) -= -2880 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -237 -655 -ns -/ -iter -( -+ -/ -- -6 -616 -) -= -2503 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -23 -922 -ns -/ -iter -( -+ -/ -- -510 -) -= -24869 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -326 -257 -ns -/ -iter -( -+ -/ -- -10 -038 -) -= -1823 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -3 -264 -085 -ns -/ -iter -( -+ -/ -- -57 -242 -) -= -182 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -3 -161 -731 -ns -/ -iter -( -+ -/ -- -45 -794 -) -= -188 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -93 -measured -; -0 -filtered -out -; -finished -in -184 -. -16s diff --git a/third_party/rust/regex/record/old-bench-log/09-new-baseline/re2 b/third_party/rust/regex/record/old-bench-log/09-new-baseline/re2 deleted file mode 100644 index 8b18eef5c0f71..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/09-new-baseline/re2 +++ /dev/null @@ -1,2572 +0,0 @@ -running -96 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -26 -ns -/ -iter -( -+ -/ -- -0 -) -= -15000 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -4 -ns -/ -iter -( -+ -/ -- -0 -) -= -97500 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -26 -ns -/ -iter -( -+ -/ -- -0 -) -= -1000 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -4 -ns -/ -iter -( -+ -/ -- -0 -) -= -6500 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -21020 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -0 -) -= -20560843 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -1180 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -655900 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -1 -) -= -24279 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -24385953 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -1 -) -= -1209 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -762511 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -21020 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -20972060 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -1180 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -50 -ns -/ -iter -( -+ -/ -- -0 -) -= -655900 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -2040 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -356 -319 -ns -/ -iter -( -+ -/ -- -680 -) -= -280 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -356 -384 -ns -/ -iter -( -+ -/ -- -3 -126 -) -= -280 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -94 -ns -/ -iter -( -+ -/ -- -0 -) -= -861 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -94 -ns -/ -iter -( -+ -/ -- -0 -) -= -861 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -168 -ns -/ -iter -( -+ -/ -- -1 -) -= -958 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -0 -) -= -20627 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -0 -) -= -20560862 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -0 -) -= -1176 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -643058 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -112 -ns -/ -iter -( -+ -/ -- -0 -) -= -892 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -66 -ns -/ -iter -( -+ -/ -- -0 -) -= -772 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -1040 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -0 -) -= -590 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -395 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -414 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -978 -ns -/ -iter -( -+ -/ -- -7 -) -= -1063 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -987 -ns -/ -iter -( -+ -/ -- -11 -) -= -1064 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -957 -501 -ns -/ -iter -( -+ -/ -- -8 -247 -) -= -1095 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -73 -ns -/ -iter -( -+ -/ -- -0 -) -= -808 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -30 -057 -ns -/ -iter -( -+ -/ -- -315 -) -= -1091 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -7 -368 -ns -/ -iter -( -+ -/ -- -105 -) -= -1085 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -15 -567 -882 -ns -/ -iter -( -+ -/ -- -48 -213 -) -= -326 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -2 -011 -288 -ns -/ -iter -( -+ -/ -- -23 -092 -) -= -2527 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -2 -013 -337 -ns -/ -iter -( -+ -/ -- -33 -388 -) -= -2524 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -2 -005 -968 -ns -/ -iter -( -+ -/ -- -25 -799 -) -= -2534 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -2 -022 -572 -ns -/ -iter -( -+ -/ -- -23 -311 -) -= -2513 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -2 -018 -386 -ns -/ -iter -( -+ -/ -- -32 -071 -) -= -2518 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -2 -013 -345 -ns -/ -iter -( -+ -/ -- -32 -599 -) -= -2524 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -2 -015 -871 -ns -/ -iter -( -+ -/ -- -25 -081 -) -= -2521 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -2 -008 -492 -ns -/ -iter -( -+ -/ -- -24 -502 -) -= -2530 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -2 -018 -804 -ns -/ -iter -( -+ -/ -- -38 -700 -) -= -2518 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -2 -010 -856 -ns -/ -iter -( -+ -/ -- -23 -695 -) -= -2527 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -2 -023 -767 -ns -/ -iter -( -+ -/ -- -17 -040 -) -= -2511 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -4 -688 -839 -ns -/ -iter -( -+ -/ -- -19 -258 -) -= -1084 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -4 -693 -463 -ns -/ -iter -( -+ -/ -- -31 -741 -) -= -1083 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -4 -674 -020 -ns -/ -iter -( -+ -/ -- -15 -755 -) -= -1087 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -4 -666 -017 -ns -/ -iter -( -+ -/ -- -16 -318 -) -= -1089 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -4 -682 -965 -ns -/ -iter -( -+ -/ -- -17 -552 -) -= -1085 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -4 -661 -825 -ns -/ -iter -( -+ -/ -- -21 -667 -) -= -1090 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -4 -697 -959 -ns -/ -iter -( -+ -/ -- -24 -282 -) -= -1082 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -4 -700 -703 -ns -/ -iter -( -+ -/ -- -21 -377 -) -= -1081 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -4 -665 -298 -ns -/ -iter -( -+ -/ -- -19 -086 -) -= -1089 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -560 -350 -ns -/ -iter -( -+ -/ -- -3 -852 -) -= -1061 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -574 -423 -ns -/ -iter -( -+ -/ -- -4 -638 -) -= -1035 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -688 -852 -ns -/ -iter -( -+ -/ -- -16 -320 -) -= -221 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -1 -206 -136 -ns -/ -iter -( -+ -/ -- -6 -173 -) -= -493 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -547 -910 -ns -/ -iter -( -+ -/ -- -7 -147 -) -= -1085 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -610 -803 -ns -/ -iter -( -+ -/ -- -1 -029 -) -= -974 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -777 -478 -ns -/ -iter -( -+ -/ -- -3 -028 -) -= -765 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -725 -653 -ns -/ -iter -( -+ -/ -- -4 -746 -) -= -819 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -25 -265 -004 -ns -/ -iter -( -+ -/ -- -120 -234 -) -= -23 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -24 -615 -621 -ns -/ -iter -( -+ -/ -- -134 -875 -) -= -24 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -485 -920 -ns -/ -iter -( -+ -/ -- -21 -446 -) -= -400 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -547 -229 -ns -/ -iter -( -+ -/ -- -3 -726 -) -= -1087 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -18 -148 -ns -/ -iter -( -+ -/ -- -131 -) -= -32782 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -586 -335 -ns -/ -iter -( -+ -/ -- -3 -679 -) -= -1014 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -601 -096 -ns -/ -iter -( -+ -/ -- -3 -781 -) -= -989 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -602 -319 -ns -/ -iter -( -+ -/ -- -7 -872 -) -= -987 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -586 -762 -ns -/ -iter -( -+ -/ -- -3 -465 -) -= -1013 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -595 -539 -ns -/ -iter -( -+ -/ -- -3 -240 -) -= -998 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -592 -474 -ns -/ -iter -( -+ -/ -- -6 -361 -) -= -1004 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -593 -214 -ns -/ -iter -( -+ -/ -- -4 -667 -) -= -1002 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -40 -236 -ns -/ -iter -( -+ -/ -- -514 -) -= -14786 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -215 -216 -ns -/ -iter -( -+ -/ -- -4 -822 -) -= -2764 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -14 -064 -ns -/ -iter -( -+ -/ -- -159 -) -= -42301 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -15 -727 -ns -/ -iter -( -+ -/ -- -166 -) -= -37828 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -552 -042 -ns -/ -iter -( -+ -/ -- -6 -395 -) -= -1077 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -552 -475 -ns -/ -iter -( -+ -/ -- -5 -365 -) -= -1076 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -16 -210 -ns -/ -iter -( -+ -/ -- -194 -) -= -36701 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -147 -489 -ns -/ -iter -( -+ -/ -- -602 -) -= -4033 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -157 -205 -ns -/ -iter -( -+ -/ -- -350 -) -= -3784 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -4 -849 -ns -/ -iter -( -+ -/ -- -5 -) -= -122691 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -619 -880 -ns -/ -iter -( -+ -/ -- -5 -189 -) -= -959 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -685 -396 -ns -/ -iter -( -+ -/ -- -12 -559 -) -= -868 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -771 -051 -ns -/ -iter -( -+ -/ -- -18 -470 -) -= -771 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -59 -139 -ns -/ -iter -( -+ -/ -- -1 -604 -) -= -10059 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -736 -147 -ns -/ -iter -( -+ -/ -- -7 -668 -) -= -808 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -200 -401 -ns -/ -iter -( -+ -/ -- -11 -206 -) -= -495 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -024 -768 -ns -/ -iter -( -+ -/ -- -93 -051 -) -= -74 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -96 -measured -; -0 -filtered -out -; -finished -in -86 -. -80s diff --git a/third_party/rust/regex/record/old-bench-log/09-new-baseline/rust b/third_party/rust/regex/record/old-bench-log/09-new-baseline/rust deleted file mode 100644 index 6be2b6a0ccaab..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/09-new-baseline/rust +++ /dev/null @@ -1,3103 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -55714 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -39000 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -3714 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -2600 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -131375 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -87383583 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -7375 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -4099375 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -41760 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -26 -ns -/ -iter -( -+ -/ -- -0 -) -= -40330615 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -2080 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -26 -ns -/ -iter -( -+ -/ -- -0 -) -= -1261076 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -33 -ns -/ -iter -( -+ -/ -- -0 -) -= -31848 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -33 -ns -/ -iter -( -+ -/ -- -0 -) -= -31775848 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -0 -) -= -1735 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -33 -ns -/ -iter -( -+ -/ -- -0 -) -= -993787 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -35 -ns -/ -iter -( -+ -/ -- -0 -) -= -714 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -7285 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -517 -ns -/ -iter -( -+ -/ -- -25 -) -= -65920 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -186 -131 -ns -/ -iter -( -+ -/ -- -1 -191 -) -= -537 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -0 -) -= -2189 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -11571 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -160 -ns -/ -iter -( -+ -/ -- -1 -) -= -1006 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -200 -ns -/ -iter -( -+ -/ -- -4 -) -= -125 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -131500 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -87383666 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -7500 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -4099500 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -262 -ns -/ -iter -( -+ -/ -- -6 -) -= -381 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -1 -) -= -1186 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -1 -) -= -1130 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -1 -) -= -1130 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -1062 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -944 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -1 -) -= -28888 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -155 -ns -/ -iter -( -+ -/ -- -11 -) -= -909 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -152 -983 -ns -/ -iter -( -+ -/ -- -6 -607 -) -= -909 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -2 -) -= -1134 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -36 -194 -ns -/ -iter -( -+ -/ -- -327 -) -= -906 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -81 -ns -/ -iter -( -+ -/ -- -5 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -2 -269 -ns -/ -iter -( -+ -/ -- -3 -) -= -3525 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -63 -956 -ns -/ -iter -( -+ -/ -- -209 -) -= -125086 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -5 -877 -ns -/ -iter -( -+ -/ -- -66 -) -= -136125 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -2 -414 -ns -/ -iter -( -+ -/ -- -10 -) -= -33144 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -195 -ns -/ -iter -( -+ -/ -- -11 -) -= -41082 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -96 -ns -/ -iter -( -+ -/ -- -7 -) -= -8447 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -8 -) -= -1070 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -6 -) -= -223 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -12 -) -= -313 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -22 -) -= -411 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -12 -) -= -505 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -6 -977 -678 -ns -/ -iter -( -+ -/ -- -90 -937 -) -= -728 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -423 -846 -ns -/ -iter -( -+ -/ -- -41 -460 -) -= -11993 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -424 -043 -ns -/ -iter -( -+ -/ -- -55 -743 -) -= -11987 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -418 -549 -ns -/ -iter -( -+ -/ -- -12 -106 -) -= -12145 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -430 -056 -ns -/ -iter -( -+ -/ -- -8 -862 -) -= -11820 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -429 -634 -ns -/ -iter -( -+ -/ -- -26 -807 -) -= -11831 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -419 -313 -ns -/ -iter -( -+ -/ -- -42 -070 -) -= -12123 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -425 -299 -ns -/ -iter -( -+ -/ -- -43 -161 -) -= -11952 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -420 -177 -ns -/ -iter -( -+ -/ -- -49 -394 -) -= -12098 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -425 -118 -ns -/ -iter -( -+ -/ -- -46 -952 -) -= -11957 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -420 -840 -ns -/ -iter -( -+ -/ -- -11 -623 -) -= -12079 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -420 -752 -ns -/ -iter -( -+ -/ -- -10 -186 -) -= -12081 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -1 -445 -103 -ns -/ -iter -( -+ -/ -- -29 -436 -) -= -3517 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -2 -234 -423 -ns -/ -iter -( -+ -/ -- -24 -502 -) -= -2275 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -2 -730 -972 -ns -/ -iter -( -+ -/ -- -26 -961 -) -= -1861 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -2 -708 -975 -ns -/ -iter -( -+ -/ -- -36 -517 -) -= -1876 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -1 -663 -458 -ns -/ -iter -( -+ -/ -- -39 -508 -) -= -3055 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -1 -673 -873 -ns -/ -iter -( -+ -/ -- -14 -846 -) -= -3036 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -2 -322 -347 -ns -/ -iter -( -+ -/ -- -33 -731 -) -= -2188 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -2 -350 -779 -ns -/ -iter -( -+ -/ -- -54 -976 -) -= -2162 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -2 -326 -741 -ns -/ -iter -( -+ -/ -- -20 -836 -) -= -2184 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -47 -700 -ns -/ -iter -( -+ -/ -- -230 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -2 -987 -898 -ns -/ -iter -( -+ -/ -- -32 -819 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -5 -705 -551 -ns -/ -iter -( -+ -/ -- -63 -483 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -1 -963 -ns -/ -iter -( -+ -/ -- -44 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -1 -970 -ns -/ -iter -( -+ -/ -- -32 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -9 -677 -ns -/ -iter -( -+ -/ -- -69 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -4 -501 -ns -/ -iter -( -+ -/ -- -70 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -75 -372 -ns -/ -iter -( -+ -/ -- -2 -007 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -151 -733 -ns -/ -iter -( -+ -/ -- -2 -378 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -655 -827 -ns -/ -iter -( -+ -/ -- -1 -426 -) -= -907 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -24 -653 -ns -/ -iter -( -+ -/ -- -224 -) -= -24132 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -026 -254 -ns -/ -iter -( -+ -/ -- -27 -926 -) -= -579 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -469 -676 -ns -/ -iter -( -+ -/ -- -62 -296 -) -= -1266 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -47 -578 -ns -/ -iter -( -+ -/ -- -1 -730 -) -= -12504 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -321 -318 -ns -/ -iter -( -+ -/ -- -3 -235 -) -= -1851 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -150 -908 -ns -/ -iter -( -+ -/ -- -3 -952 -) -= -3942 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -726 -848 -ns -/ -iter -( -+ -/ -- -5 -314 -) -= -818 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -9 -719 -997 -ns -/ -iter -( -+ -/ -- -67 -717 -) -= -61 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -9 -559 -105 -ns -/ -iter -( -+ -/ -- -79 -257 -) -= -62 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -066 -791 -ns -/ -iter -( -+ -/ -- -13 -193 -) -= -557 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -653 -228 -ns -/ -iter -( -+ -/ -- -881 -) -= -910 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -10 -663 -ns -/ -iter -( -+ -/ -- -76 -) -= -55794 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -33 -831 -ns -/ -iter -( -+ -/ -- -967 -) -= -17585 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -38 -061 -ns -/ -iter -( -+ -/ -- -1 -123 -) -= -15631 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -218 -691 -ns -/ -iter -( -+ -/ -- -2 -345 -) -= -2720 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -52 -408 -ns -/ -iter -( -+ -/ -- -1 -315 -) -= -11351 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -84 -212 -ns -/ -iter -( -+ -/ -- -2 -708 -) -= -7064 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -35 -272 -ns -/ -iter -( -+ -/ -- -1 -784 -) -= -16867 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -193 -585 -ns -/ -iter -( -+ -/ -- -5 -057 -) -= -3073 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -15 -018 -ns -/ -iter -( -+ -/ -- -440 -) -= -39614 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -60 -207 -ns -/ -iter -( -+ -/ -- -1 -046 -) -= -9881 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -10 -344 -ns -/ -iter -( -+ -/ -- -52 -) -= -57514 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -10 -374 -ns -/ -iter -( -+ -/ -- -98 -) -= -57348 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -42 -037 -ns -/ -iter -( -+ -/ -- -1 -363 -) -= -14152 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -41 -192 -ns -/ -iter -( -+ -/ -- -881 -) -= -14442 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -13 -893 -ns -/ -iter -( -+ -/ -- -55 -) -= -42822 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -8 -700 -ns -/ -iter -( -+ -/ -- -10 -) -= -68383 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -10 -368 -ns -/ -iter -( -+ -/ -- -123 -) -= -57381 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -8 -695 -ns -/ -iter -( -+ -/ -- -7 -) -= -68422 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -222 -526 -ns -/ -iter -( -+ -/ -- -5 -362 -) -= -2673 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -35 -869 -193 -ns -/ -iter -( -+ -/ -- -551 -212 -) -= -16 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -187 -208 -ns -/ -iter -( -+ -/ -- -4 -374 -) -= -3177 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -280 -625 -ns -/ -iter -( -+ -/ -- -10 -142 -) -= -2120 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -19 -742 -ns -/ -iter -( -+ -/ -- -692 -) -= -30135 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -396 -099 -ns -/ -iter -( -+ -/ -- -10 -400 -) -= -1501 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -055 -639 -ns -/ -iter -( -+ -/ -- -6 -627 -) -= -563 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -4 -280 -471 -ns -/ -iter -( -+ -/ -- -53 -841 -) -= -138 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -141 -. -25s diff --git a/third_party/rust/regex/record/old-bench-log/09-new-baseline/rust-bytes b/third_party/rust/regex/record/old-bench-log/09-new-baseline/rust-bytes deleted file mode 100644 index f1d2b7ac98639..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/09-new-baseline/rust-bytes +++ /dev/null @@ -1,2803 +0,0 @@ -running -107 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -55714 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -48750 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -3714 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -9 -ns -/ -iter -( -+ -/ -- -0 -) -= -2888 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -150142 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -1 -) -= -95327545 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -8428 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -4685000 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -61411 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -52429800 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -3058 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -1 -) -= -1928705 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -43791 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -27 -ns -/ -iter -( -+ -/ -- -0 -) -= -38837148 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -2458 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -1366458 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -35 -ns -/ -iter -( -+ -/ -- -0 -) -= -714 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -7285 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -325 -ns -/ -iter -( -+ -/ -- -18 -) -= -75472 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -186 -021 -ns -/ -iter -( -+ -/ -- -1 -157 -) -= -537 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -3 -) -= -2131 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -11571 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -172 -ns -/ -iter -( -+ -/ -- -4 -) -= -145 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -150285 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -87383666 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -7500 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -4685142 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -272 -ns -/ -iter -( -+ -/ -- -10 -) -= -367 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -1 -) -= -1214 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -1 -) -= -1130 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -1181 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -1133 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -944 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -36 -ns -/ -iter -( -+ -/ -- -0 -) -= -28888 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -152 -ns -/ -iter -( -+ -/ -- -14 -) -= -912 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -155 -496 -ns -/ -iter -( -+ -/ -- -7 -722 -) -= -907 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -1156 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -36 -202 -ns -/ -iter -( -+ -/ -- -167 -) -= -905 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -2 -269 -ns -/ -iter -( -+ -/ -- -2 -) -= -3525 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -6 -982 -142 -ns -/ -iter -( -+ -/ -- -70 -086 -) -= -728 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -425 -753 -ns -/ -iter -( -+ -/ -- -15 -075 -) -= -11939 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -431 -401 -ns -/ -iter -( -+ -/ -- -19 -346 -) -= -11783 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -427 -131 -ns -/ -iter -( -+ -/ -- -38 -166 -) -= -11901 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -423 -284 -ns -/ -iter -( -+ -/ -- -9 -016 -) -= -12009 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -425 -850 -ns -/ -iter -( -+ -/ -- -7 -324 -) -= -11937 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -426 -013 -ns -/ -iter -( -+ -/ -- -6 -922 -) -= -11932 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -426 -029 -ns -/ -iter -( -+ -/ -- -8 -697 -) -= -11932 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -427 -781 -ns -/ -iter -( -+ -/ -- -8 -166 -) -= -11883 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -426 -589 -ns -/ -iter -( -+ -/ -- -13 -274 -) -= -11916 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -424 -152 -ns -/ -iter -( -+ -/ -- -14 -879 -) -= -11984 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -428 -066 -ns -/ -iter -( -+ -/ -- -8 -773 -) -= -11875 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -1 -446 -630 -ns -/ -iter -( -+ -/ -- -53 -195 -) -= -3513 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -2 -241 -934 -ns -/ -iter -( -+ -/ -- -42 -563 -) -= -2267 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -2 -741 -736 -ns -/ -iter -( -+ -/ -- -28 -424 -) -= -1854 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -2 -725 -768 -ns -/ -iter -( -+ -/ -- -37 -801 -) -= -1864 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -1 -686 -366 -ns -/ -iter -( -+ -/ -- -25 -054 -) -= -3014 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -1 -689 -225 -ns -/ -iter -( -+ -/ -- -24 -479 -) -= -3009 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -2 -343 -567 -ns -/ -iter -( -+ -/ -- -34 -646 -) -= -2169 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -2 -363 -133 -ns -/ -iter -( -+ -/ -- -69 -696 -) -= -2151 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -2 -337 -512 -ns -/ -iter -( -+ -/ -- -32 -958 -) -= -2174 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -53 -055 -ns -/ -iter -( -+ -/ -- -88 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -2 -979 -724 -ns -/ -iter -( -+ -/ -- -43 -904 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -5 -825 -193 -ns -/ -iter -( -+ -/ -- -61 -322 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -1 -927 -ns -/ -iter -( -+ -/ -- -39 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -1 -924 -ns -/ -iter -( -+ -/ -- -29 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -9 -830 -ns -/ -iter -( -+ -/ -- -108 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -4 -569 -ns -/ -iter -( -+ -/ -- -70 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -74 -875 -ns -/ -iter -( -+ -/ -- -1 -337 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -151 -485 -ns -/ -iter -( -+ -/ -- -3 -063 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -655 -632 -ns -/ -iter -( -+ -/ -- -801 -) -= -907 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -24 -576 -ns -/ -iter -( -+ -/ -- -307 -) -= -24207 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -026 -410 -ns -/ -iter -( -+ -/ -- -57 -265 -) -= -579 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -424 -490 -ns -/ -iter -( -+ -/ -- -7 -188 -) -= -1401 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -46 -935 -ns -/ -iter -( -+ -/ -- -1 -007 -) -= -12675 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -322 -497 -ns -/ -iter -( -+ -/ -- -3 -680 -) -= -1844 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -149 -923 -ns -/ -iter -( -+ -/ -- -2 -936 -) -= -3968 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -732 -021 -ns -/ -iter -( -+ -/ -- -10 -242 -) -= -812 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -9 -716 -641 -ns -/ -iter -( -+ -/ -- -56 -270 -) -= -61 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -9 -541 -922 -ns -/ -iter -( -+ -/ -- -63 -715 -) -= -62 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -070 -240 -ns -/ -iter -( -+ -/ -- -10 -505 -) -= -555 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -652 -312 -ns -/ -iter -( -+ -/ -- -546 -) -= -912 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -10 -832 -ns -/ -iter -( -+ -/ -- -499 -) -= -54923 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -33 -528 -ns -/ -iter -( -+ -/ -- -484 -) -= -17744 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -37 -352 -ns -/ -iter -( -+ -/ -- -1 -173 -) -= -15927 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -217 -570 -ns -/ -iter -( -+ -/ -- -3 -401 -) -= -2734 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -52 -711 -ns -/ -iter -( -+ -/ -- -1 -257 -) -= -11286 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -81 -635 -ns -/ -iter -( -+ -/ -- -1 -740 -) -= -7287 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -34 -935 -ns -/ -iter -( -+ -/ -- -1 -190 -) -= -17029 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -194 -600 -ns -/ -iter -( -+ -/ -- -3 -742 -) -= -3057 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -14 -670 -ns -/ -iter -( -+ -/ -- -153 -) -= -40554 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -59 -906 -ns -/ -iter -( -+ -/ -- -898 -) -= -9931 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -10 -470 -ns -/ -iter -( -+ -/ -- -74 -) -= -56822 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -10 -291 -ns -/ -iter -( -+ -/ -- -29 -) -= -57810 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -41 -316 -ns -/ -iter -( -+ -/ -- -1 -350 -) -= -14399 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -40 -748 -ns -/ -iter -( -+ -/ -- -724 -) -= -14600 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -14 -682 -ns -/ -iter -( -+ -/ -- -52 -) -= -40521 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -8 -822 -ns -/ -iter -( -+ -/ -- -310 -) -= -67437 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -8 -990 -ns -/ -iter -( -+ -/ -- -129 -) -= -66177 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -8 -649 -ns -/ -iter -( -+ -/ -- -192 -) -= -68786 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -218 -225 -ns -/ -iter -( -+ -/ -- -4 -267 -) -= -2726 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -35 -771 -807 -ns -/ -iter -( -+ -/ -- -640 -817 -) -= -16 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -190 -205 -ns -/ -iter -( -+ -/ -- -9 -051 -) -= -3127 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -280 -386 -ns -/ -iter -( -+ -/ -- -5 -346 -) -= -2121 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -19 -325 -ns -/ -iter -( -+ -/ -- -695 -) -= -30785 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -409 -665 -ns -/ -iter -( -+ -/ -- -7 -657 -) -= -1452 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -066 -052 -ns -/ -iter -( -+ -/ -- -7 -072 -) -= -558 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -4 -330 -659 -ns -/ -iter -( -+ -/ -- -53 -403 -) -= -137 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -107 -measured -; -0 -filtered -out -; -finished -in -131 -. -99s diff --git a/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-after-literal.log b/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-after-literal.log deleted file mode 100644 index 2d4b300aa815e..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-after-literal.log +++ /dev/null @@ -1,3110 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -19500 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1444 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -1300 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -2 -) -= -20607 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -1 -) -= -18725053 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -0 -) -= -1156 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -1 -) -= -618773 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -25463 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -1 -) -= -23831727 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -1 -) -= -1300 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -1 -) -= -819700 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -2 -) -= -20607 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -1 -) -= -18725053 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -2 -) -= -1156 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -643039 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -2 -) -= -409 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -3923 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -3 -242 -ns -/ -iter -( -+ -/ -- -79 -) -= -30845 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -350 -572 -ns -/ -iter -( -+ -/ -- -6 -860 -) -= -285 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -6 -) -= -1306 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -5785 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -259 -ns -/ -iter -( -+ -/ -- -15 -) -= -621 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -462 -ns -/ -iter -( -+ -/ -- -9 -) -= -54 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -0 -) -= -19849 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -1 -) -= -18079379 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -1 -) -= -1132 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -1 -) -= -618792 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -423 -ns -/ -iter -( -+ -/ -- -13 -) -= -236 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -89 -ns -/ -iter -( -+ -/ -- -0 -) -= -573 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -0 -) -= -500 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -1 -) -= -500 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -1 -) -= -447 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -1 -) -= -414 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -81 -ns -/ -iter -( -+ -/ -- -1 -) -= -12839 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -592 -ns -/ -iter -( -+ -/ -- -1 -) -= -660 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -575 -822 -ns -/ -iter -( -+ -/ -- -39 -203 -) -= -665 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -102 -ns -/ -iter -( -+ -/ -- -0 -) -= -578 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -49 -328 -ns -/ -iter -( -+ -/ -- -2 -598 -) -= -664 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -132 -ns -/ -iter -( -+ -/ -- -3 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -171 -ns -/ -iter -( -+ -/ -- -134 -) -= -1918 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -132 -251 -ns -/ -iter -( -+ -/ -- -729 -) -= -60491 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -13 -184 -ns -/ -iter -( -+ -/ -- -408 -) -= -60680 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -6 -036 -ns -/ -iter -( -+ -/ -- -167 -) -= -13255 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -602 -ns -/ -iter -( -+ -/ -- -14 -) -= -13307 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -230 -ns -/ -iter -( -+ -/ -- -7 -) -= -3526 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -218 -ns -/ -iter -( -+ -/ -- -3 -) -= -417 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -210 -ns -/ -iter -( -+ -/ -- -8 -) -= -90 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -225 -ns -/ -iter -( -+ -/ -- -6 -) -= -120 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -211 -ns -/ -iter -( -+ -/ -- -8 -) -= -165 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -212 -ns -/ -iter -( -+ -/ -- -6 -) -= -202 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -245 -066 -ns -/ -iter -( -+ -/ -- -117 -141 -) -= -415 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -786 -357 -ns -/ -iter -( -+ -/ -- -14 -200 -) -= -6464 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -788 -550 -ns -/ -iter -( -+ -/ -- -26 -456 -) -= -6446 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -782 -161 -ns -/ -iter -( -+ -/ -- -15 -583 -) -= -6499 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -784 -902 -ns -/ -iter -( -+ -/ -- -23 -379 -) -= -6476 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -786 -640 -ns -/ -iter -( -+ -/ -- -27 -063 -) -= -6462 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -785 -591 -ns -/ -iter -( -+ -/ -- -20 -498 -) -= -6470 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -787 -447 -ns -/ -iter -( -+ -/ -- -20 -892 -) -= -6455 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -784 -994 -ns -/ -iter -( -+ -/ -- -19 -687 -) -= -6475 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -801 -921 -ns -/ -iter -( -+ -/ -- -15 -391 -) -= -6339 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -785 -541 -ns -/ -iter -( -+ -/ -- -11 -908 -) -= -6471 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -785 -848 -ns -/ -iter -( -+ -/ -- -28 -020 -) -= -6468 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -195 -058 -ns -/ -iter -( -+ -/ -- -44 -066 -) -= -2315 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -219 -968 -ns -/ -iter -( -+ -/ -- -59 -372 -) -= -1578 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -3 -776 -467 -ns -/ -iter -( -+ -/ -- -54 -326 -) -= -1346 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -3 -803 -674 -ns -/ -iter -( -+ -/ -- -95 -281 -) -= -1336 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -2 -661 -333 -ns -/ -iter -( -+ -/ -- -46 -408 -) -= -1910 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -2 -645 -716 -ns -/ -iter -( -+ -/ -- -38 -659 -) -= -1921 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -3 -228 -352 -ns -/ -iter -( -+ -/ -- -69 -155 -) -= -1574 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -3 -305 -563 -ns -/ -iter -( -+ -/ -- -59 -321 -) -= -1537 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -225 -039 -ns -/ -iter -( -+ -/ -- -49 -720 -) -= -1576 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -100 -381 -ns -/ -iter -( -+ -/ -- -2 -052 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -5 -899 -989 -ns -/ -iter -( -+ -/ -- -114 -363 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -11 -650 -995 -ns -/ -iter -( -+ -/ -- -172 -285 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -4 -082 -ns -/ -iter -( -+ -/ -- -88 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -4 -153 -ns -/ -iter -( -+ -/ -- -120 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -20 -414 -ns -/ -iter -( -+ -/ -- -1 -860 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -9 -114 -ns -/ -iter -( -+ -/ -- -216 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -183 -049 -ns -/ -iter -( -+ -/ -- -9 -917 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -361 -291 -ns -/ -iter -( -+ -/ -- -11 -045 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -907 -103 -ns -/ -iter -( -+ -/ -- -12 -165 -) -= -655 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -62 -501 -ns -/ -iter -( -+ -/ -- -1 -880 -) -= -9518 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -062 -116 -ns -/ -iter -( -+ -/ -- -41 -900 -) -= -288 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -894 -529 -ns -/ -iter -( -+ -/ -- -38 -723 -) -= -665 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -103 -305 -ns -/ -iter -( -+ -/ -- -3 -798 -) -= -5758 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -479 -423 -ns -/ -iter -( -+ -/ -- -13 -924 -) -= -1240 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -318 -300 -ns -/ -iter -( -+ -/ -- -6 -846 -) -= -1869 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -066 -300 -ns -/ -iter -( -+ -/ -- -19 -375 -) -= -557 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -21 -777 -358 -ns -/ -iter -( -+ -/ -- -230 -478 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -21 -152 -019 -ns -/ -iter -( -+ -/ -- -203 -617 -) -= -28 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -777 -626 -ns -/ -iter -( -+ -/ -- -26 -243 -) -= -334 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -897 -509 -ns -/ -iter -( -+ -/ -- -24 -983 -) -= -662 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -32 -255 -ns -/ -iter -( -+ -/ -- -681 -) -= -18444 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -86 -369 -ns -/ -iter -( -+ -/ -- -2 -494 -) -= -6888 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -97 -618 -ns -/ -iter -( -+ -/ -- -564 -) -= -6094 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -944 -848 -ns -/ -iter -( -+ -/ -- -31 -039 -) -= -629 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -122 -029 -ns -/ -iter -( -+ -/ -- -2 -716 -) -= -4875 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -225 -544 -ns -/ -iter -( -+ -/ -- -5 -783 -) -= -2637 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -91 -897 -ns -/ -iter -( -+ -/ -- -3 -796 -) -= -6473 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -936 -420 -ns -/ -iter -( -+ -/ -- -15 -092 -) -= -635 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -33 -448 -ns -/ -iter -( -+ -/ -- -959 -) -= -17786 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -115 -864 -ns -/ -iter -( -+ -/ -- -1 -645 -) -= -5134 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -22 -474 -ns -/ -iter -( -+ -/ -- -674 -) -= -26472 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -22 -184 -ns -/ -iter -( -+ -/ -- -497 -) -= -26818 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -99 -629 -ns -/ -iter -( -+ -/ -- -2 -398 -) -= -5971 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -99 -523 -ns -/ -iter -( -+ -/ -- -2 -674 -) -= -5977 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -30 -815 -ns -/ -iter -( -+ -/ -- -107 -) -= -19306 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -19 -661 -ns -/ -iter -( -+ -/ -- -656 -) -= -30259 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -27 -544 -ns -/ -iter -( -+ -/ -- -527 -) -= -21599 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -19 -553 -ns -/ -iter -( -+ -/ -- -31 -) -= -30426 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -369 -144 -ns -/ -iter -( -+ -/ -- -45 -316 -) -= -1611 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -68 -838 -857 -ns -/ -iter -( -+ -/ -- -330 -544 -) -= -8 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -321 -692 -ns -/ -iter -( -+ -/ -- -5 -418 -) -= -1849 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -507 -936 -ns -/ -iter -( -+ -/ -- -3 -080 -) -= -1171 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -43 -705 -ns -/ -iter -( -+ -/ -- -788 -) -= -13612 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -819 -179 -ns -/ -iter -( -+ -/ -- -20 -071 -) -= -726 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -700 -300 -ns -/ -iter -( -+ -/ -- -36 -623 -) -= -349 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -249 -767 -ns -/ -iter -( -+ -/ -- -75 -015 -) -= -72 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -111 -. -55s diff --git a/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-before-literal.log b/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-before-literal.log deleted file mode 100644 index dedfae392b9e0..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-before-literal.log +++ /dev/null @@ -1,3112 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1444 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1444 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -70066 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -49933476 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -3933 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -2342500 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -1 -) -= -26100 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -45 -ns -/ -iter -( -+ -/ -- -1 -) -= -23302133 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -5 -) -= -1300 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -1 -) -= -819700 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -20607 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -0 -) -= -18725053 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -3 -) -= -1156 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -643039 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -2 -) -= -409 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -3923 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -3 -259 -ns -/ -iter -( -+ -/ -- -86 -) -= -30684 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -350 -722 -ns -/ -iter -( -+ -/ -- -6 -984 -) -= -285 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -60 -ns -/ -iter -( -+ -/ -- -1 -) -= -1350 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -5785 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -255 -ns -/ -iter -( -+ -/ -- -0 -) -= -631 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -481 -ns -/ -iter -( -+ -/ -- -11 -) -= -51 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -70133 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -0 -) -= -47663818 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -4000 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -2186400 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -442 -ns -/ -iter -( -+ -/ -- -13 -) -= -226 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -89 -ns -/ -iter -( -+ -/ -- -1 -) -= -573 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -54 -ns -/ -iter -( -+ -/ -- -1 -) -= -481 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -1 -) -= -500 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -0 -) -= -435 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -404 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -83 -ns -/ -iter -( -+ -/ -- -6 -) -= -12530 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -592 -ns -/ -iter -( -+ -/ -- -4 -) -= -660 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -575 -691 -ns -/ -iter -( -+ -/ -- -29 -668 -) -= -665 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -101 -ns -/ -iter -( -+ -/ -- -5 -) -= -584 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -49 -325 -ns -/ -iter -( -+ -/ -- -1 -734 -) -= -664 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -134 -ns -/ -iter -( -+ -/ -- -2 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -189 -ns -/ -iter -( -+ -/ -- -274 -) -= -1909 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -132 -182 -ns -/ -iter -( -+ -/ -- -4 -966 -) -= -60522 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -13 -344 -ns -/ -iter -( -+ -/ -- -275 -) -= -59952 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -6 -119 -ns -/ -iter -( -+ -/ -- -285 -) -= -13075 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -617 -ns -/ -iter -( -+ -/ -- -15 -) -= -12983 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -230 -ns -/ -iter -( -+ -/ -- -7 -) -= -3526 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -207 -ns -/ -iter -( -+ -/ -- -8 -) -= -439 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -213 -ns -/ -iter -( -+ -/ -- -7 -) -= -89 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -206 -ns -/ -iter -( -+ -/ -- -6 -) -= -131 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -207 -ns -/ -iter -( -+ -/ -- -10 -) -= -169 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -208 -ns -/ -iter -( -+ -/ -- -7 -) -= -206 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -275 -804 -ns -/ -iter -( -+ -/ -- -145 -331 -) -= -414 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -793 -517 -ns -/ -iter -( -+ -/ -- -44 -203 -) -= -6406 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -794 -922 -ns -/ -iter -( -+ -/ -- -23 -459 -) -= -6394 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -790 -525 -ns -/ -iter -( -+ -/ -- -23 -010 -) -= -6430 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -790 -637 -ns -/ -iter -( -+ -/ -- -17 -962 -) -= -6429 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -793 -559 -ns -/ -iter -( -+ -/ -- -17 -575 -) -= -6405 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -792 -738 -ns -/ -iter -( -+ -/ -- -15 -237 -) -= -6412 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -795 -060 -ns -/ -iter -( -+ -/ -- -26 -172 -) -= -6393 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -792 -357 -ns -/ -iter -( -+ -/ -- -15 -067 -) -= -6415 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -797 -006 -ns -/ -iter -( -+ -/ -- -27 -928 -) -= -6378 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -790 -603 -ns -/ -iter -( -+ -/ -- -22 -754 -) -= -6429 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -793 -055 -ns -/ -iter -( -+ -/ -- -13 -202 -) -= -6409 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -204 -304 -ns -/ -iter -( -+ -/ -- -50 -669 -) -= -2306 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -224 -798 -ns -/ -iter -( -+ -/ -- -45 -705 -) -= -1576 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -3 -802 -774 -ns -/ -iter -( -+ -/ -- -86 -530 -) -= -1336 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -3 -805 -916 -ns -/ -iter -( -+ -/ -- -69 -737 -) -= -1335 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -2 -662 -373 -ns -/ -iter -( -+ -/ -- -61 -259 -) -= -1909 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -2 -654 -072 -ns -/ -iter -( -+ -/ -- -51 -095 -) -= -1915 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -3 -232 -369 -ns -/ -iter -( -+ -/ -- -67 -147 -) -= -1572 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -3 -311 -225 -ns -/ -iter -( -+ -/ -- -66 -086 -) -= -1535 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -241 -601 -ns -/ -iter -( -+ -/ -- -68 -394 -) -= -1568 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -100 -955 -ns -/ -iter -( -+ -/ -- -2 -466 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -5 -936 -732 -ns -/ -iter -( -+ -/ -- -126 -993 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -11 -880 -838 -ns -/ -iter -( -+ -/ -- -211 -387 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -4 -575 -ns -/ -iter -( -+ -/ -- -139 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -4 -653 -ns -/ -iter -( -+ -/ -- -122 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -20 -656 -ns -/ -iter -( -+ -/ -- -535 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -9 -613 -ns -/ -iter -( -+ -/ -- -992 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -188 -349 -ns -/ -iter -( -+ -/ -- -4 -733 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -341 -554 -ns -/ -iter -( -+ -/ -- -9 -774 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -907 -419 -ns -/ -iter -( -+ -/ -- -11 -645 -) -= -655 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -62 -036 -ns -/ -iter -( -+ -/ -- -1 -854 -) -= -9590 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -072 -694 -ns -/ -iter -( -+ -/ -- -45 -192 -) -= -287 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -884 -483 -ns -/ -iter -( -+ -/ -- -25 -710 -) -= -672 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -103 -873 -ns -/ -iter -( -+ -/ -- -1 -310 -) -= -5727 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -481 -491 -ns -/ -iter -( -+ -/ -- -11 -516 -) -= -1235 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -323 -119 -ns -/ -iter -( -+ -/ -- -7 -438 -) -= -1841 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -067 -293 -ns -/ -iter -( -+ -/ -- -18 -661 -) -= -557 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -21 -732 -526 -ns -/ -iter -( -+ -/ -- -253 -563 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -21 -187 -465 -ns -/ -iter -( -+ -/ -- -191 -023 -) -= -28 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -766 -003 -ns -/ -iter -( -+ -/ -- -17 -494 -) -= -336 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -897 -387 -ns -/ -iter -( -+ -/ -- -26 -674 -) -= -662 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -34 -183 -ns -/ -iter -( -+ -/ -- -885 -) -= -17404 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -87 -151 -ns -/ -iter -( -+ -/ -- -2 -139 -) -= -6826 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -99 -293 -ns -/ -iter -( -+ -/ -- -1 -938 -) -= -5991 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -379 -228 -ns -/ -iter -( -+ -/ -- -22 -539 -) -= -1568 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -123 -040 -ns -/ -iter -( -+ -/ -- -2 -676 -) -= -4835 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -186 -045 -ns -/ -iter -( -+ -/ -- -403 -) -= -3197 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -91 -679 -ns -/ -iter -( -+ -/ -- -2 -543 -) -= -6489 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -343 -668 -ns -/ -iter -( -+ -/ -- -6 -807 -) -= -1731 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -33 -802 -ns -/ -iter -( -+ -/ -- -936 -) -= -17600 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -136 -208 -ns -/ -iter -( -+ -/ -- -4 -317 -) -= -4367 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -22 -534 -ns -/ -iter -( -+ -/ -- -462 -) -= -26401 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -22 -514 -ns -/ -iter -( -+ -/ -- -697 -) -= -26425 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -97 -796 -ns -/ -iter -( -+ -/ -- -2 -037 -) -= -6083 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -95 -809 -ns -/ -iter -( -+ -/ -- -1 -538 -) -= -6209 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -30 -959 -ns -/ -iter -( -+ -/ -- -968 -) -= -19216 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -19 -568 -ns -/ -iter -( -+ -/ -- -616 -) -= -30403 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -26 -273 -ns -/ -iter -( -+ -/ -- -1 -143 -) -= -22644 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -19 -643 -ns -/ -iter -( -+ -/ -- -496 -) -= -30287 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -371 -876 -ns -/ -iter -( -+ -/ -- -2 -494 -) -= -1599 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -76 -963 -104 -ns -/ -iter -( -+ -/ -- -277 -311 -) -= -7 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -331 -250 -ns -/ -iter -( -+ -/ -- -8 -588 -) -= -1796 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -516 -528 -ns -/ -iter -( -+ -/ -- -40 -826 -) -= -1151 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -44 -206 -ns -/ -iter -( -+ -/ -- -1 -277 -) -= -13458 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -822 -577 -ns -/ -iter -( -+ -/ -- -23 -649 -) -= -723 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -685 -110 -ns -/ -iter -( -+ -/ -- -34 -615 -) -= -353 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -333 -499 -ns -/ -iter -( -+ -/ -- -152 -757 -) -= -71 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -124 -. -94s diff --git a/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-bytes-after-literal.log b/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-bytes-after-literal.log deleted file mode 100644 index 31ff33f06f71e..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-bytes-after-literal.log +++ /dev/null @@ -1,2815 +0,0 @@ -running -107 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -1 -) -= -19500 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1444 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -1300 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -54 -ns -/ -iter -( -+ -/ -- -2 -) -= -19462 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -1 -) -= -18725053 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -1156 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -2 -) -= -643039 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -1 -) -= -25463 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -1 -) -= -23831727 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -2 -) -= -1300 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -1 -) -= -819700 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -1 -) -= -20211 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -57 -ns -/ -iter -( -+ -/ -- -0 -) -= -18396543 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -0 -) -= -1156 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -3 -) -= -643039 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -2 -) -= -409 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -3642 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -3 -249 -ns -/ -iter -( -+ -/ -- -87 -) -= -30779 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -350 -559 -ns -/ -iter -( -+ -/ -- -7 -154 -) -= -285 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -4 -) -= -1327 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -5785 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -401 -ns -/ -iter -( -+ -/ -- -17 -) -= -62 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -0 -) -= -19849 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -58 -ns -/ -iter -( -+ -/ -- -0 -) -= -18079379 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -0 -) -= -1132 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -2 -) -= -618792 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -421 -ns -/ -iter -( -+ -/ -- -8 -) -= -237 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -90 -ns -/ -iter -( -+ -/ -- -0 -) -= -566 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -1 -) -= -490 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -0 -) -= -490 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -0 -) -= -447 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -3 -) -= -404 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -77 -ns -/ -iter -( -+ -/ -- -1 -) -= -13506 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -592 -ns -/ -iter -( -+ -/ -- -1 -) -= -660 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -575 -759 -ns -/ -iter -( -+ -/ -- -49 -997 -) -= -665 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -102 -ns -/ -iter -( -+ -/ -- -2 -) -= -578 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -49 -326 -ns -/ -iter -( -+ -/ -- -1 -055 -) -= -664 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -161 -ns -/ -iter -( -+ -/ -- -94 -) -= -1922 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -344 -799 -ns -/ -iter -( -+ -/ -- -188 -054 -) -= -411 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -780 -449 -ns -/ -iter -( -+ -/ -- -14 -474 -) -= -6513 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -795 -203 -ns -/ -iter -( -+ -/ -- -40 -742 -) -= -6392 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -816 -444 -ns -/ -iter -( -+ -/ -- -23 -334 -) -= -6226 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -777 -546 -ns -/ -iter -( -+ -/ -- -19 -625 -) -= -6537 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -783 -295 -ns -/ -iter -( -+ -/ -- -8 -266 -) -= -6489 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -775 -154 -ns -/ -iter -( -+ -/ -- -21 -350 -) -= -6557 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -781 -414 -ns -/ -iter -( -+ -/ -- -21 -057 -) -= -6505 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -783 -595 -ns -/ -iter -( -+ -/ -- -23 -835 -) -= -6487 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -821 -620 -ns -/ -iter -( -+ -/ -- -46 -131 -) -= -6187 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -818 -402 -ns -/ -iter -( -+ -/ -- -21 -350 -) -= -6211 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -779 -115 -ns -/ -iter -( -+ -/ -- -21 -335 -) -= -6524 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -189 -308 -ns -/ -iter -( -+ -/ -- -32 -528 -) -= -2321 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -217 -478 -ns -/ -iter -( -+ -/ -- -36 -011 -) -= -1579 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -3 -771 -330 -ns -/ -iter -( -+ -/ -- -74 -944 -) -= -1347 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -3 -787 -593 -ns -/ -iter -( -+ -/ -- -37 -825 -) -= -1342 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -2 -669 -799 -ns -/ -iter -( -+ -/ -- -69 -777 -) -= -1904 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -2 -651 -559 -ns -/ -iter -( -+ -/ -- -33 -895 -) -= -1917 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -3 -222 -991 -ns -/ -iter -( -+ -/ -- -41 -014 -) -= -1577 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -3 -298 -048 -ns -/ -iter -( -+ -/ -- -41 -331 -) -= -1541 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -218 -486 -ns -/ -iter -( -+ -/ -- -50 -318 -) -= -1579 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -100 -031 -ns -/ -iter -( -+ -/ -- -3 -464 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -5 -885 -102 -ns -/ -iter -( -+ -/ -- -130 -016 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -11 -641 -251 -ns -/ -iter -( -+ -/ -- -147 -700 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -4 -263 -ns -/ -iter -( -+ -/ -- -116 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -4 -236 -ns -/ -iter -( -+ -/ -- -91 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -22 -349 -ns -/ -iter -( -+ -/ -- -2 -085 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -9 -537 -ns -/ -iter -( -+ -/ -- -298 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -178 -561 -ns -/ -iter -( -+ -/ -- -3 -796 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -363 -343 -ns -/ -iter -( -+ -/ -- -9 -481 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -907 -022 -ns -/ -iter -( -+ -/ -- -19 -133 -) -= -655 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -63 -729 -ns -/ -iter -( -+ -/ -- -1 -830 -) -= -9335 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -181 -593 -ns -/ -iter -( -+ -/ -- -46 -002 -) -= -272 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -884 -811 -ns -/ -iter -( -+ -/ -- -26 -211 -) -= -672 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -105 -610 -ns -/ -iter -( -+ -/ -- -3 -120 -) -= -5633 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -480 -986 -ns -/ -iter -( -+ -/ -- -13 -228 -) -= -1236 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -322 -921 -ns -/ -iter -( -+ -/ -- -3 -555 -) -= -1842 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -065 -372 -ns -/ -iter -( -+ -/ -- -21 -242 -) -= -558 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -22 -109 -015 -ns -/ -iter -( -+ -/ -- -146 -243 -) -= -26 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -21 -686 -153 -ns -/ -iter -( -+ -/ -- -206 -041 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -778 -225 -ns -/ -iter -( -+ -/ -- -25 -935 -) -= -334 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -897 -355 -ns -/ -iter -( -+ -/ -- -26 -781 -) -= -662 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -31 -927 -ns -/ -iter -( -+ -/ -- -633 -) -= -18634 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -87 -040 -ns -/ -iter -( -+ -/ -- -1 -859 -) -= -6835 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -97 -715 -ns -/ -iter -( -+ -/ -- -2 -109 -) -= -6088 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -944 -955 -ns -/ -iter -( -+ -/ -- -26 -503 -) -= -629 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -120 -935 -ns -/ -iter -( -+ -/ -- -2 -399 -) -= -4919 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -228 -597 -ns -/ -iter -( -+ -/ -- -7 -137 -) -= -2602 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -91 -174 -ns -/ -iter -( -+ -/ -- -1 -096 -) -= -6525 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -937 -189 -ns -/ -iter -( -+ -/ -- -23 -839 -) -= -634 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -34 -020 -ns -/ -iter -( -+ -/ -- -752 -) -= -17487 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -117 -194 -ns -/ -iter -( -+ -/ -- -3 -444 -) -= -5076 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -22 -557 -ns -/ -iter -( -+ -/ -- -388 -) -= -26374 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -22 -428 -ns -/ -iter -( -+ -/ -- -683 -) -= -26526 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -99 -637 -ns -/ -iter -( -+ -/ -- -636 -) -= -5971 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -97 -895 -ns -/ -iter -( -+ -/ -- -1 -875 -) -= -6077 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -30 -772 -ns -/ -iter -( -+ -/ -- -1 -591 -) -= -19333 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -19 -665 -ns -/ -iter -( -+ -/ -- -296 -) -= -30253 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -27 -403 -ns -/ -iter -( -+ -/ -- -2 -507 -) -= -21710 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -19 -601 -ns -/ -iter -( -+ -/ -- -293 -) -= -30352 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -370 -323 -ns -/ -iter -( -+ -/ -- -1 -345 -) -= -1606 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -68 -414 -794 -ns -/ -iter -( -+ -/ -- -342 -428 -) -= -8 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -327 -767 -ns -/ -iter -( -+ -/ -- -5 -493 -) -= -1815 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -507 -818 -ns -/ -iter -( -+ -/ -- -1 -796 -) -= -1171 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -45 -045 -ns -/ -iter -( -+ -/ -- -1 -400 -) -= -13207 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -822 -080 -ns -/ -iter -( -+ -/ -- -16 -581 -) -= -723 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -690 -084 -ns -/ -iter -( -+ -/ -- -40 -361 -) -= -352 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -573 -617 -ns -/ -iter -( -+ -/ -- -143 -313 -) -= -69 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -107 -measured -; -0 -filtered -out -; -finished -in -110 -. -03s diff --git a/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-bytes-before-literal.log b/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-bytes-before-literal.log deleted file mode 100644 index d01dc770db35a..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/10-last-frontier/rust-bytes-before-literal.log +++ /dev/null @@ -1,2815 +0,0 @@ -running -107 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -21666 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -1 -) -= -20526 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1444 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -1300 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -75071 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -49933476 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -4214 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -2342500 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -25463 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -48 -ns -/ -iter -( -+ -/ -- -0 -) -= -21845750 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -1268 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -1 -) -= -799707 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -20607 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -2 -) -= -18725053 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -6 -) -= -1156 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -51 -ns -/ -iter -( -+ -/ -- -1 -) -= -643039 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -2 -) -= -403 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -3923 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -2 -825 -ns -/ -iter -( -+ -/ -- -57 -) -= -35398 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -350 -755 -ns -/ -iter -( -+ -/ -- -11 -905 -) -= -285 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -64 -ns -/ -iter -( -+ -/ -- -1 -) -= -1265 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -0 -) -= -6230 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -422 -ns -/ -iter -( -+ -/ -- -12 -) -= -59 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -70133 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -49933523 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -4000 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -= -2342571 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -443 -ns -/ -iter -( -+ -/ -- -12 -) -= -225 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -89 -ns -/ -iter -( -+ -/ -- -1 -) -= -573 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -1 -) -= -500 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -52 -ns -/ -iter -( -+ -/ -- -1 -) -= -500 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -1 -) -= -425 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -404 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -0 -) -= -13000 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -592 -ns -/ -iter -( -+ -/ -- -1 -) -= -660 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -575 -789 -ns -/ -iter -( -+ -/ -- -34 -236 -) -= -665 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -101 -ns -/ -iter -( -+ -/ -- -2 -) -= -584 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -49 -321 -ns -/ -iter -( -+ -/ -- -2 -718 -) -= -664 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -4 -158 -ns -/ -iter -( -+ -/ -- -93 -) -= -1924 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -12 -391 -732 -ns -/ -iter -( -+ -/ -- -180 -913 -) -= -410 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -781 -690 -ns -/ -iter -( -+ -/ -- -29 -637 -) -= -6503 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -778 -306 -ns -/ -iter -( -+ -/ -- -22 -706 -) -= -6531 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -777 -716 -ns -/ -iter -( -+ -/ -- -24 -635 -) -= -6536 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -791 -786 -ns -/ -iter -( -+ -/ -- -15 -778 -) -= -6420 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -783 -470 -ns -/ -iter -( -+ -/ -- -25 -543 -) -= -6488 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -814 -902 -ns -/ -iter -( -+ -/ -- -14 -146 -) -= -6238 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -781 -464 -ns -/ -iter -( -+ -/ -- -19 -532 -) -= -6504 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -780 -116 -ns -/ -iter -( -+ -/ -- -16 -558 -) -= -6516 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -795 -982 -ns -/ -iter -( -+ -/ -- -11 -254 -) -= -6386 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -781 -746 -ns -/ -iter -( -+ -/ -- -24 -996 -) -= -6502 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -783 -793 -ns -/ -iter -( -+ -/ -- -14 -943 -) -= -6485 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -2 -188 -940 -ns -/ -iter -( -+ -/ -- -42 -308 -) -= -2322 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -3 -218 -011 -ns -/ -iter -( -+ -/ -- -50 -700 -) -= -1579 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -3 -778 -907 -ns -/ -iter -( -+ -/ -- -90 -543 -) -= -1345 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -3 -803 -852 -ns -/ -iter -( -+ -/ -- -68 -319 -) -= -1336 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -2 -660 -949 -ns -/ -iter -( -+ -/ -- -55 -488 -) -= -1910 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -2 -647 -131 -ns -/ -iter -( -+ -/ -- -26 -846 -) -= -1920 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -3 -235 -032 -ns -/ -iter -( -+ -/ -- -37 -599 -) -= -1571 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -3 -305 -124 -ns -/ -iter -( -+ -/ -- -67 -109 -) -= -1538 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -3 -231 -033 -ns -/ -iter -( -+ -/ -- -55 -626 -) -= -1573 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -99 -387 -ns -/ -iter -( -+ -/ -- -2 -366 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -5 -865 -693 -ns -/ -iter -( -+ -/ -- -62 -255 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -11 -752 -845 -ns -/ -iter -( -+ -/ -- -195 -440 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -4 -117 -ns -/ -iter -( -+ -/ -- -141 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -4 -162 -ns -/ -iter -( -+ -/ -- -67 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -19 -955 -ns -/ -iter -( -+ -/ -- -622 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -9 -140 -ns -/ -iter -( -+ -/ -- -112 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -165 -990 -ns -/ -iter -( -+ -/ -- -5 -876 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -342 -897 -ns -/ -iter -( -+ -/ -- -13 -730 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -906 -789 -ns -/ -iter -( -+ -/ -- -13 -931 -) -= -656 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -62 -319 -ns -/ -iter -( -+ -/ -- -790 -) -= -9546 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -2 -175 -424 -ns -/ -iter -( -+ -/ -- -47 -720 -) -= -273 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -884 -406 -ns -/ -iter -( -+ -/ -- -22 -679 -) -= -672 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -105 -261 -ns -/ -iter -( -+ -/ -- -3 -536 -) -= -5651 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -479 -524 -ns -/ -iter -( -+ -/ -- -7 -749 -) -= -1240 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -321 -401 -ns -/ -iter -( -+ -/ -- -9 -123 -) -= -1851 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -1 -069 -722 -ns -/ -iter -( -+ -/ -- -16 -366 -) -= -556 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -21 -959 -896 -ns -/ -iter -( -+ -/ -- -204 -695 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -21 -462 -457 -ns -/ -iter -( -+ -/ -- -207 -449 -) -= -27 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -768 -026 -ns -/ -iter -( -+ -/ -- -41 -459 -) -= -336 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -897 -197 -ns -/ -iter -( -+ -/ -- -14 -349 -) -= -663 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -34 -037 -ns -/ -iter -( -+ -/ -- -719 -) -= -17479 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -86 -788 -ns -/ -iter -( -+ -/ -- -1 -203 -) -= -6855 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -98 -225 -ns -/ -iter -( -+ -/ -- -1 -589 -) -= -6056 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -377 -597 -ns -/ -iter -( -+ -/ -- -14 -840 -) -= -1575 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -122 -440 -ns -/ -iter -( -+ -/ -- -8 -123 -) -= -4858 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -187 -282 -ns -/ -iter -( -+ -/ -- -5 -176 -) -= -3176 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -91 -429 -ns -/ -iter -( -+ -/ -- -1 -944 -) -= -6507 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -348 -111 -ns -/ -iter -( -+ -/ -- -12 -721 -) -= -1709 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -33 -547 -ns -/ -iter -( -+ -/ -- -1 -119 -) -= -17734 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -132 -342 -ns -/ -iter -( -+ -/ -- -3 -974 -) -= -4495 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -22 -562 -ns -/ -iter -( -+ -/ -- -364 -) -= -26368 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -22 -313 -ns -/ -iter -( -+ -/ -- -579 -) -= -26663 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -97 -556 -ns -/ -iter -( -+ -/ -- -2 -092 -) -= -6098 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -95 -917 -ns -/ -iter -( -+ -/ -- -4 -054 -) -= -6202 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -30 -997 -ns -/ -iter -( -+ -/ -- -1 -039 -) -= -19193 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -19 -690 -ns -/ -iter -( -+ -/ -- -378 -) -= -30214 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -27 -629 -ns -/ -iter -( -+ -/ -- -465 -) -= -21532 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -19 -681 -ns -/ -iter -( -+ -/ -- -291 -) -= -30228 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -368 -290 -ns -/ -iter -( -+ -/ -- -1 -508 -) -= -1615 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -73 -004 -024 -ns -/ -iter -( -+ -/ -- -1 -040 -743 -) -= -8 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -320 -929 -ns -/ -iter -( -+ -/ -- -12 -287 -) -= -1853 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -514 -946 -ns -/ -iter -( -+ -/ -- -11 -241 -) -= -1155 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -43 -816 -ns -/ -iter -( -+ -/ -- -1 -719 -) -= -13577 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -825 -245 -ns -/ -iter -( -+ -/ -- -20 -797 -) -= -720 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -676 -908 -ns -/ -iter -( -+ -/ -- -40 -650 -) -= -354 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -8 -449 -099 -ns -/ -iter -( -+ -/ -- -123 -842 -) -= -70 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -107 -measured -; -0 -filtered -out -; -finished -in -128 -. -47s diff --git a/third_party/rust/regex/record/old-bench-log/11-regex-1.7.3/rust b/third_party/rust/regex/record/old-bench-log/11-regex-1.7.3/rust deleted file mode 100644 index eb5698310c1b2..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/11-regex-1.7.3/rust +++ /dev/null @@ -1,3103 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -55714 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -39000 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -3714 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -2600 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -150142 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -1 -) -= -95327545 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -8428 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -4685000 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -1 -) -= -61411 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -52429800 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -1 -) -= -2888 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1821555 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -43791 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -37450107 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -2458 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -1366458 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -0 -) -= -675 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -1 -) -= -6375 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -785 -ns -/ -iter -( -+ -/ -- -1 -) -= -56022 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -193 -595 -ns -/ -iter -( -+ -/ -- -1 -486 -) -= -516 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -1 -) -= -2189 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -10125 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -181 -ns -/ -iter -( -+ -/ -- -1 -) -= -889 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -216 -ns -/ -iter -( -+ -/ -- -9 -) -= -115 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -150285 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -1 -) -= -87383666 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -8571 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -4685142 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -283 -ns -/ -iter -( -+ -/ -- -7 -) -= -353 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -1 -) -= -962 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -2 -) -= -1083 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -2 -) -= -1083 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -1062 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -894 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -25365 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -208 -ns -/ -iter -( -+ -/ -- -2 -) -= -870 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -213 -959 -ns -/ -iter -( -+ -/ -- -7 -198 -) -= -863 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -0 -) -= -951 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -38 -231 -ns -/ -iter -( -+ -/ -- -354 -) -= -857 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -3 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -2 -351 -ns -/ -iter -( -+ -/ -- -31 -) -= -3402 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -91 -018 -ns -/ -iter -( -+ -/ -- -203 -) -= -87894 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -9 -277 -ns -/ -iter -( -+ -/ -- -40 -) -= -86235 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -2 -863 -ns -/ -iter -( -+ -/ -- -4 -) -= -27946 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -201 -ns -/ -iter -( -+ -/ -- -3 -) -= -39855 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -100 -ns -/ -iter -( -+ -/ -- -2 -) -= -8110 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -0 -) -= -1034 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -1 -) -= -220 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -87 -ns -/ -iter -( -+ -/ -- -0 -) -= -310 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -1 -) -= -397 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -1 -) -= -488 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -7 -348 -651 -ns -/ -iter -( -+ -/ -- -40 -559 -) -= -691 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -493 -624 -ns -/ -iter -( -+ -/ -- -10 -315 -) -= -10298 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -489 -573 -ns -/ -iter -( -+ -/ -- -18 -151 -) -= -10383 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -492 -501 -ns -/ -iter -( -+ -/ -- -11 -650 -) -= -10321 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -492 -283 -ns -/ -iter -( -+ -/ -- -12 -363 -) -= -10326 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -496 -795 -ns -/ -iter -( -+ -/ -- -20 -704 -) -= -10232 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -489 -245 -ns -/ -iter -( -+ -/ -- -10 -289 -) -= -10390 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -499 -701 -ns -/ -iter -( -+ -/ -- -11 -359 -) -= -10172 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -490 -460 -ns -/ -iter -( -+ -/ -- -8 -758 -) -= -10364 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -496 -398 -ns -/ -iter -( -+ -/ -- -18 -774 -) -= -10240 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -497 -077 -ns -/ -iter -( -+ -/ -- -24 -767 -) -= -10226 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -496 -763 -ns -/ -iter -( -+ -/ -- -12 -477 -) -= -10233 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -1 -454 -747 -ns -/ -iter -( -+ -/ -- -48 -995 -) -= -3494 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -2 -311 -001 -ns -/ -iter -( -+ -/ -- -63 -347 -) -= -2199 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -2 -832 -483 -ns -/ -iter -( -+ -/ -- -33 -976 -) -= -1794 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -2 -796 -710 -ns -/ -iter -( -+ -/ -- -56 -279 -) -= -1817 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -1 -708 -634 -ns -/ -iter -( -+ -/ -- -25 -749 -) -= -2975 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -1 -706 -259 -ns -/ -iter -( -+ -/ -- -22 -151 -) -= -2979 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -2 -400 -436 -ns -/ -iter -( -+ -/ -- -24 -655 -) -= -2117 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -2 -413 -765 -ns -/ -iter -( -+ -/ -- -50 -326 -) -= -2106 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -2 -402 -528 -ns -/ -iter -( -+ -/ -- -26 -150 -) -= -2115 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -51 -936 -ns -/ -iter -( -+ -/ -- -834 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -3 -294 -633 -ns -/ -iter -( -+ -/ -- -40 -585 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -6 -323 -294 -ns -/ -iter -( -+ -/ -- -66 -684 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -1 -992 -ns -/ -iter -( -+ -/ -- -25 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -2 -004 -ns -/ -iter -( -+ -/ -- -20 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -9 -697 -ns -/ -iter -( -+ -/ -- -68 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -4 -261 -ns -/ -iter -( -+ -/ -- -72 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -83 -908 -ns -/ -iter -( -+ -/ -- -1 -405 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -166 -152 -ns -/ -iter -( -+ -/ -- -3 -508 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -699 -767 -ns -/ -iter -( -+ -/ -- -6 -201 -) -= -850 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -29 -284 -ns -/ -iter -( -+ -/ -- -573 -) -= -20315 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -070 -812 -ns -/ -iter -( -+ -/ -- -18 -795 -) -= -555 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -445 -517 -ns -/ -iter -( -+ -/ -- -7 -760 -) -= -1335 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -43 -459 -ns -/ -iter -( -+ -/ -- -901 -) -= -13689 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -335 -772 -ns -/ -iter -( -+ -/ -- -6 -348 -) -= -1771 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -153 -546 -ns -/ -iter -( -+ -/ -- -3 -075 -) -= -3874 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -777 -388 -ns -/ -iter -( -+ -/ -- -8 -447 -) -= -765 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -10 -123 -374 -ns -/ -iter -( -+ -/ -- -90 -059 -) -= -58 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -9 -957 -916 -ns -/ -iter -( -+ -/ -- -63 -766 -) -= -59 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -123 -119 -ns -/ -iter -( -+ -/ -- -17 -972 -) -= -529 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -694 -714 -ns -/ -iter -( -+ -/ -- -7 -006 -) -= -856 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -13 -427 -ns -/ -iter -( -+ -/ -- -331 -) -= -44308 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -33 -171 -ns -/ -iter -( -+ -/ -- -1 -029 -) -= -17935 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -36 -816 -ns -/ -iter -( -+ -/ -- -1 -138 -) -= -16159 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -221 -185 -ns -/ -iter -( -+ -/ -- -3 -268 -) -= -2689 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -49 -883 -ns -/ -iter -( -+ -/ -- -1 -150 -) -= -11926 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -74 -967 -ns -/ -iter -( -+ -/ -- -1 -807 -) -= -7935 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -34 -675 -ns -/ -iter -( -+ -/ -- -1 -335 -) -= -17157 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -192 -109 -ns -/ -iter -( -+ -/ -- -6 -194 -) -= -3096 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -18 -355 -ns -/ -iter -( -+ -/ -- -389 -) -= -32412 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -58 -179 -ns -/ -iter -( -+ -/ -- -917 -) -= -10225 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -14 -307 -ns -/ -iter -( -+ -/ -- -74 -) -= -41583 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -14 -332 -ns -/ -iter -( -+ -/ -- -144 -) -= -41510 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -41 -336 -ns -/ -iter -( -+ -/ -- -736 -) -= -14392 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -40 -029 -ns -/ -iter -( -+ -/ -- -1 -393 -) -= -14862 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -17 -807 -ns -/ -iter -( -+ -/ -- -105 -) -= -33410 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -13 -625 -ns -/ -iter -( -+ -/ -- -15 -) -= -43664 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -13 -818 -ns -/ -iter -( -+ -/ -- -282 -) -= -43054 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -13 -628 -ns -/ -iter -( -+ -/ -- -27 -) -= -43655 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -232 -910 -ns -/ -iter -( -+ -/ -- -1 -883 -) -= -2554 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -36 -892 -964 -ns -/ -iter -( -+ -/ -- -629 -538 -) -= -16 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -203 -077 -ns -/ -iter -( -+ -/ -- -2 -574 -) -= -2929 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -290 -781 -ns -/ -iter -( -+ -/ -- -6 -597 -) -= -2045 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -22 -731 -ns -/ -iter -( -+ -/ -- -439 -) -= -26172 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -423 -983 -ns -/ -iter -( -+ -/ -- -10 -849 -) -= -1403 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -109 -013 -ns -/ -iter -( -+ -/ -- -12 -645 -) -= -536 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -4 -529 -451 -ns -/ -iter -( -+ -/ -- -44 -285 -) -= -131 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -164 -. -08s diff --git a/third_party/rust/regex/record/old-bench-log/11-regex-1.7.3/rust-bytes b/third_party/rust/regex/record/old-bench-log/11-regex-1.7.3/rust-bytes deleted file mode 100644 index 0826f6238a283..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/11-regex-1.7.3/rust-bytes +++ /dev/null @@ -1,2803 +0,0 @@ -running -107 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -48750 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -39000 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -3714 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -2600 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -150142 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -95327545 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -8428 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -4685000 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -17 -ns -/ -iter -( -+ -/ -- -0 -) -= -61411 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -20 -ns -/ -iter -( -+ -/ -- -0 -) -= -52429800 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -2888 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1821555 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -43791 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -37450107 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -2458 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -1366458 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -0 -) -= -675 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -7285 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -2 -186 -ns -/ -iter -( -+ -/ -- -19 -) -= -45746 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -210 -378 -ns -/ -iter -( -+ -/ -- -61 -574 -) -= -475 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -39 -ns -/ -iter -( -+ -/ -- -1 -) -= -2076 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -11571 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -176 -ns -/ -iter -( -+ -/ -- -12 -) -= -142 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -131500 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -87383666 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -7500 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -4099500 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -274 -ns -/ -iter -( -+ -/ -- -7 -) -= -364 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -0 -) -= -962 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -2 -) -= -1083 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -1 -) -= -1083 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -1 -) -= -1062 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -894 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -5 -) -= -27368 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -220 -ns -/ -iter -( -+ -/ -- -15 -) -= -861 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -215 -297 -ns -/ -iter -( -+ -/ -- -5 -229 -) -= -862 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -63 -ns -/ -iter -( -+ -/ -- -1 -) -= -936 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -38 -164 -ns -/ -iter -( -+ -/ -- -232 -) -= -859 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -2 -353 -ns -/ -iter -( -+ -/ -- -8 -) -= -3399 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -7 -346 -276 -ns -/ -iter -( -+ -/ -- -46 -149 -) -= -691 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -486 -203 -ns -/ -iter -( -+ -/ -- -21 -159 -) -= -10455 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -494 -356 -ns -/ -iter -( -+ -/ -- -6 -423 -) -= -10282 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -481 -930 -ns -/ -iter -( -+ -/ -- -19 -639 -) -= -10548 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -486 -672 -ns -/ -iter -( -+ -/ -- -22 -184 -) -= -10445 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -487 -152 -ns -/ -iter -( -+ -/ -- -19 -776 -) -= -10434 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -486 -534 -ns -/ -iter -( -+ -/ -- -23 -897 -) -= -10448 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -481 -412 -ns -/ -iter -( -+ -/ -- -26 -310 -) -= -10559 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -479 -498 -ns -/ -iter -( -+ -/ -- -20 -310 -) -= -10601 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -481 -960 -ns -/ -iter -( -+ -/ -- -18 -492 -) -= -10547 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -482 -282 -ns -/ -iter -( -+ -/ -- -22 -522 -) -= -10540 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -489 -224 -ns -/ -iter -( -+ -/ -- -25 -264 -) -= -10390 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -1 -470 -068 -ns -/ -iter -( -+ -/ -- -65 -563 -) -= -3457 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -2 -298 -112 -ns -/ -iter -( -+ -/ -- -27 -688 -) -= -2211 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -2 -818 -539 -ns -/ -iter -( -+ -/ -- -31 -432 -) -= -1803 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -2 -786 -226 -ns -/ -iter -( -+ -/ -- -30 -699 -) -= -1824 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -1 -716 -429 -ns -/ -iter -( -+ -/ -- -20 -264 -) -= -2961 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -1 -719 -420 -ns -/ -iter -( -+ -/ -- -23 -944 -) -= -2956 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -2 -391 -022 -ns -/ -iter -( -+ -/ -- -23 -192 -) -= -2126 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -2 -418 -744 -ns -/ -iter -( -+ -/ -- -44 -152 -) -= -2101 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -2 -400 -918 -ns -/ -iter -( -+ -/ -- -24 -041 -) -= -2117 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -57 -745 -ns -/ -iter -( -+ -/ -- -816 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -3 -346 -952 -ns -/ -iter -( -+ -/ -- -39 -488 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -6 -344 -293 -ns -/ -iter -( -+ -/ -- -53 -114 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -2 -040 -ns -/ -iter -( -+ -/ -- -32 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -2 -010 -ns -/ -iter -( -+ -/ -- -34 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -9 -632 -ns -/ -iter -( -+ -/ -- -464 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -4 -445 -ns -/ -iter -( -+ -/ -- -77 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -83 -791 -ns -/ -iter -( -+ -/ -- -1 -929 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -164 -948 -ns -/ -iter -( -+ -/ -- -2 -595 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -699 -996 -ns -/ -iter -( -+ -/ -- -6 -647 -) -= -849 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -28 -208 -ns -/ -iter -( -+ -/ -- -233 -) -= -21090 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -033 -048 -ns -/ -iter -( -+ -/ -- -9 -790 -) -= -575 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -424 -081 -ns -/ -iter -( -+ -/ -- -22 -574 -) -= -1402 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -43 -131 -ns -/ -iter -( -+ -/ -- -827 -) -= -13793 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -336 -678 -ns -/ -iter -( -+ -/ -- -6 -985 -) -= -1767 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -153 -589 -ns -/ -iter -( -+ -/ -- -3 -193 -) -= -3873 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -776 -911 -ns -/ -iter -( -+ -/ -- -8 -815 -) -= -765 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -10 -056 -702 -ns -/ -iter -( -+ -/ -- -49 -688 -) -= -59 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -9 -900 -568 -ns -/ -iter -( -+ -/ -- -76 -118 -) -= -60 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -120 -456 -ns -/ -iter -( -+ -/ -- -13 -538 -) -= -530 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -693 -727 -ns -/ -iter -( -+ -/ -- -6 -840 -) -= -857 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -11 -101 -ns -/ -iter -( -+ -/ -- -65 -) -= -53592 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -34 -003 -ns -/ -iter -( -+ -/ -- -966 -) -= -17496 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -37 -975 -ns -/ -iter -( -+ -/ -- -1 -313 -) -= -15666 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -214 -299 -ns -/ -iter -( -+ -/ -- -3 -026 -) -= -2776 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -50 -551 -ns -/ -iter -( -+ -/ -- -1 -377 -) -= -11768 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -74 -713 -ns -/ -iter -( -+ -/ -- -1 -359 -) -= -7962 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -35 -426 -ns -/ -iter -( -+ -/ -- -625 -) -= -16793 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -190 -521 -ns -/ -iter -( -+ -/ -- -4 -903 -) -= -3122 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -18 -070 -ns -/ -iter -( -+ -/ -- -763 -) -= -32923 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -58 -454 -ns -/ -iter -( -+ -/ -- -1 -228 -) -= -10177 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -14 -380 -ns -/ -iter -( -+ -/ -- -227 -) -= -41372 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -14 -491 -ns -/ -iter -( -+ -/ -- -116 -) -= -41055 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -40 -722 -ns -/ -iter -( -+ -/ -- -231 -) -= -14609 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -39 -937 -ns -/ -iter -( -+ -/ -- -623 -) -= -14896 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -17 -979 -ns -/ -iter -( -+ -/ -- -140 -) -= -33090 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -13 -650 -ns -/ -iter -( -+ -/ -- -112 -) -= -43584 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -13 -623 -ns -/ -iter -( -+ -/ -- -295 -) -= -43671 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -13 -641 -ns -/ -iter -( -+ -/ -- -55 -) -= -43613 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -232 -451 -ns -/ -iter -( -+ -/ -- -6 -555 -) -= -2559 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -36 -984 -199 -ns -/ -iter -( -+ -/ -- -623 -153 -) -= -16 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -189 -502 -ns -/ -iter -( -+ -/ -- -4 -870 -) -= -3139 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -294 -945 -ns -/ -iter -( -+ -/ -- -9 -381 -) -= -2017 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -21 -591 -ns -/ -iter -( -+ -/ -- -680 -) -= -27554 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -424 -862 -ns -/ -iter -( -+ -/ -- -7 -197 -) -= -1400 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -126 -768 -ns -/ -iter -( -+ -/ -- -13 -900 -) -= -527 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -4 -517 -167 -ns -/ -iter -( -+ -/ -- -55 -809 -) -= -131 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -107 -measured -; -0 -filtered -out -; -finished -in -150 -. -58s diff --git a/third_party/rust/regex/record/old-bench-log/12-regex-1.8.1/rust b/third_party/rust/regex/record/old-bench-log/12-regex-1.8.1/rust deleted file mode 100644 index 81b263ca7be4f..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/12-regex-1.8.1/rust +++ /dev/null @@ -1,3096 +0,0 @@ -running -119 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -48750 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -9 -ns -/ -iter -( -+ -/ -- -0 -) -= -43333 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -3714 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -9 -ns -/ -iter -( -+ -/ -- -0 -) -= -2888 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -1 -) -= -43791 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -37450107 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -2360 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -1366458 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -1 -) -= -58000 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -49933142 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -2888 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1821555 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -43791 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -29 -ns -/ -iter -( -+ -/ -- -0 -) -= -36158724 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -2458 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -1366458 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -0 -) -= -675 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -7285 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -802 -ns -/ -iter -( -+ -/ -- -6 -) -= -55494 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -207 -353 -ns -/ -iter -( -+ -/ -- -165 -) -= -482 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -2 -) -= -1975 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -11571 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -168 -ns -/ -iter -( -+ -/ -- -3 -) -= -958 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -210 -ns -/ -iter -( -+ -/ -- -5 -) -= -119 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -42080 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -29 -ns -/ -iter -( -+ -/ -- -0 -) -= -36158758 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -2400 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -1311840 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -268 -ns -/ -iter -( -+ -/ -- -7 -) -= -373 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -4 -) -= -1159 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -2 -) -= -1083 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -2 -) -= -1130 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -= -1062 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -894 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -1 -) -= -27368 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -215 -ns -/ -iter -( -+ -/ -- -12 -) -= -865 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -215 -907 -ns -/ -iter -( -+ -/ -- -6 -442 -) -= -862 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -2 -) -= -1113 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -38 -162 -ns -/ -iter -( -+ -/ -- -464 -) -= -859 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -5 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -2 -355 -ns -/ -iter -( -+ -/ -- -470 -) -= -3397 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -91 -039 -ns -/ -iter -( -+ -/ -- -157 -) -= -87874 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -7 -595 -ns -/ -iter -( -+ -/ -- -33 -) -= -105333 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -2 -865 -ns -/ -iter -( -+ -/ -- -9 -) -= -27927 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -211 -ns -/ -iter -( -+ -/ -- -2 -) -= -37966 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -98 -ns -/ -iter -( -+ -/ -- -3 -) -= -8275 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -92 -ns -/ -iter -( -+ -/ -- -4 -) -= -989 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -90 -ns -/ -iter -( -+ -/ -- -2 -) -= -211 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -88 -ns -/ -iter -( -+ -/ -- -3 -) -= -306 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -91 -ns -/ -iter -( -+ -/ -- -3 -) -= -384 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -90 -ns -/ -iter -( -+ -/ -- -3 -) -= -477 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -7 -323 -399 -ns -/ -iter -( -+ -/ -- -24 -661 -) -= -694 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -473 -671 -ns -/ -iter -( -+ -/ -- -16 -963 -) -= -10731 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -463 -672 -ns -/ -iter -( -+ -/ -- -13 -433 -) -= -10963 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -470 -891 -ns -/ -iter -( -+ -/ -- -28 -305 -) -= -10795 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -469 -218 -ns -/ -iter -( -+ -/ -- -26 -181 -) -= -10833 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -467 -417 -ns -/ -iter -( -+ -/ -- -30 -700 -) -= -10875 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -469 -373 -ns -/ -iter -( -+ -/ -- -17 -254 -) -= -10830 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -467 -035 -ns -/ -iter -( -+ -/ -- -30 -365 -) -= -10884 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -466 -540 -ns -/ -iter -( -+ -/ -- -18 -283 -) -= -10895 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -470 -291 -ns -/ -iter -( -+ -/ -- -23 -930 -) -= -10809 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -466 -425 -ns -/ -iter -( -+ -/ -- -27 -080 -) -= -10898 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -468 -192 -ns -/ -iter -( -+ -/ -- -17 -296 -) -= -10857 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -653 -471 -ns -/ -iter -( -+ -/ -- -8 -898 -) -= -7779 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -902 -852 -ns -/ -iter -( -+ -/ -- -12 -549 -) -= -5630 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -1 -158 -000 -ns -/ -iter -( -+ -/ -- -14 -075 -) -= -4389 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -1 -149 -520 -ns -/ -iter -( -+ -/ -- -13 -482 -) -= -4422 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -1 -132 -121 -ns -/ -iter -( -+ -/ -- -7 -624 -) -= -4490 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -1 -069 -227 -ns -/ -iter -( -+ -/ -- -13 -436 -) -= -4754 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -1 -150 -436 -ns -/ -iter -( -+ -/ -- -28 -302 -) -= -4418 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -1 -148 -923 -ns -/ -iter -( -+ -/ -- -49 -063 -) -= -4424 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -1 -190 -858 -ns -/ -iter -( -+ -/ -- -15 -044 -) -= -4268 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -52 -168 -ns -/ -iter -( -+ -/ -- -827 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -3 -330 -456 -ns -/ -iter -( -+ -/ -- -57 -242 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -6 -378 -126 -ns -/ -iter -( -+ -/ -- -85 -019 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -2 -291 -ns -/ -iter -( -+ -/ -- -39 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -2 -355 -ns -/ -iter -( -+ -/ -- -37 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -14 -581 -ns -/ -iter -( -+ -/ -- -103 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -10 -443 -ns -/ -iter -( -+ -/ -- -114 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -11 -269 -ns -/ -iter -( -+ -/ -- -150 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -14 -746 -ns -/ -iter -( -+ -/ -- -212 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -699 -736 -ns -/ -iter -( -+ -/ -- -6 -402 -) -= -850 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -28 -001 -ns -/ -iter -( -+ -/ -- -198 -) -= -21246 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -029 -174 -ns -/ -iter -( -+ -/ -- -33 -321 -) -= -578 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -460 -103 -ns -/ -iter -( -+ -/ -- -23 -290 -) -= -1293 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -57 -666 -ns -/ -iter -( -+ -/ -- -907 -) -= -10316 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -345 -016 -ns -/ -iter -( -+ -/ -- -4 -672 -) -= -1724 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -150 -499 -ns -/ -iter -( -+ -/ -- -4 -855 -) -= -3953 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -777 -723 -ns -/ -iter -( -+ -/ -- -8 -076 -) -= -764 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -10 -022 -203 -ns -/ -iter -( -+ -/ -- -77 -897 -) -= -59 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -9 -861 -816 -ns -/ -iter -( -+ -/ -- -76 -172 -) -= -60 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -134 -201 -ns -/ -iter -( -+ -/ -- -11 -926 -) -= -524 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -693 -533 -ns -/ -iter -( -+ -/ -- -6 -686 -) -= -857 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -11 -974 -ns -/ -iter -( -+ -/ -- -292 -) -= -49685 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -44 -708 -ns -/ -iter -( -+ -/ -- -573 -) -= -13307 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -49 -873 -ns -/ -iter -( -+ -/ -- -785 -) -= -11928 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -190 -194 -ns -/ -iter -( -+ -/ -- -2 -944 -) -= -3128 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -52 -028 -ns -/ -iter -( -+ -/ -- -1 -102 -) -= -11434 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -119 -891 -ns -/ -iter -( -+ -/ -- -921 -) -= -4962 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -47 -139 -ns -/ -iter -( -+ -/ -- -1 -617 -) -= -12620 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -200 -159 -ns -/ -iter -( -+ -/ -- -3 -992 -) -= -2972 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -17 -902 -ns -/ -iter -( -+ -/ -- -577 -) -= -33232 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -58 -219 -ns -/ -iter -( -+ -/ -- -1 -215 -) -= -10218 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -14 -314 -ns -/ -iter -( -+ -/ -- -45 -) -= -41563 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -14 -399 -ns -/ -iter -( -+ -/ -- -45 -) -= -41317 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -41 -418 -ns -/ -iter -( -+ -/ -- -591 -) -= -14364 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -39 -877 -ns -/ -iter -( -+ -/ -- -545 -) -= -14919 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -17 -883 -ns -/ -iter -( -+ -/ -- -151 -) -= -33268 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -13 -696 -ns -/ -iter -( -+ -/ -- -123 -) -= -43438 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -10 -157 -ns -/ -iter -( -+ -/ -- -222 -) -= -58573 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -13 -663 -ns -/ -iter -( -+ -/ -- -53 -) -= -43543 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -234 -890 -ns -/ -iter -( -+ -/ -- -4 -574 -) -= -2532 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -36 -406 -680 -ns -/ -iter -( -+ -/ -- -397 -378 -) -= -16 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -192 -028 -ns -/ -iter -( -+ -/ -- -5 -315 -) -= -3098 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -311 -087 -ns -/ -iter -( -+ -/ -- -6 -723 -) -= -1912 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -21 -710 -ns -/ -iter -( -+ -/ -- -1 -269 -) -= -27403 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -425 -246 -ns -/ -iter -( -+ -/ -- -7 -741 -) -= -1399 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -116 -412 -ns -/ -iter -( -+ -/ -- -11 -753 -) -= -532 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -4 -452 -805 -ns -/ -iter -( -+ -/ -- -84 -309 -) -= -133 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -119 -measured -; -0 -filtered -out -; -finished -in -142 -. -33s diff --git a/third_party/rust/regex/record/old-bench-log/12-regex-1.8.1/rust-bytes b/third_party/rust/regex/record/old-bench-log/12-regex-1.8.1/rust-bytes deleted file mode 100644 index 01fa8d61811d4..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/12-regex-1.8.1/rust-bytes +++ /dev/null @@ -1,2799 +0,0 @@ -running -107 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -55714 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -48750 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -3714 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -8 -ns -/ -iter -( -+ -/ -- -0 -) -= -3250 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -43791 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -37450107 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -2458 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -1366458 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -58000 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -21 -ns -/ -iter -( -+ -/ -- -0 -) -= -49933142 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -2 -) -= -2888 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -18 -ns -/ -iter -( -+ -/ -- -0 -) -= -1821555 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -43791 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -28 -ns -/ -iter -( -+ -/ -- -0 -) -= -37450107 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -2458 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -24 -ns -/ -iter -( -+ -/ -- -0 -) -= -1366458 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -37 -ns -/ -iter -( -+ -/ -- -0 -) -= -675 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -7285 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -801 -ns -/ -iter -( -+ -/ -- -2 -) -= -55525 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -212 -892 -ns -/ -iter -( -+ -/ -- -206 -) -= -469 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -0 -) -= -2025 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -7 -ns -/ -iter -( -+ -/ -- -0 -) -= -11571 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -174 -ns -/ -iter -( -+ -/ -- -2 -) -= -143 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -42080 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -29 -ns -/ -iter -( -+ -/ -- -0 -) -= -36158758 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -2400 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -25 -ns -/ -iter -( -+ -/ -- -0 -) -= -1311840 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -270 -ns -/ -iter -( -+ -/ -- -8 -) -= -370 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -44 -ns -/ -iter -( -+ -/ -- -1 -) -= -1159 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -0 -) -= -1130 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -0 -) -= -1130 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -1 -) -= -1062 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -19 -ns -/ -iter -( -+ -/ -- -0 -) -= -894 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -38 -ns -/ -iter -( -+ -/ -- -2 -) -= -27368 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -1 -215 -ns -/ -iter -( -+ -/ -- -15 -) -= -865 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -1 -217 -631 -ns -/ -iter -( -+ -/ -- -11 -216 -) -= -861 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -53 -ns -/ -iter -( -+ -/ -- -4 -) -= -1113 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -38 -251 -ns -/ -iter -( -+ -/ -- -364 -) -= -857 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -2 -353 -ns -/ -iter -( -+ -/ -- -4 -) -= -3399 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -7 -322 -463 -ns -/ -iter -( -+ -/ -- -37 -966 -) -= -694 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -466 -849 -ns -/ -iter -( -+ -/ -- -12 -252 -) -= -10888 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -465 -011 -ns -/ -iter -( -+ -/ -- -19 -693 -) -= -10931 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -457 -806 -ns -/ -iter -( -+ -/ -- -13 -453 -) -= -11103 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -456 -878 -ns -/ -iter -( -+ -/ -- -32 -828 -) -= -11126 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -465 -531 -ns -/ -iter -( -+ -/ -- -21 -786 -) -= -10919 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -454 -553 -ns -/ -iter -( -+ -/ -- -12 -698 -) -= -11183 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -456 -977 -ns -/ -iter -( -+ -/ -- -13 -155 -) -= -11123 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -466 -105 -ns -/ -iter -( -+ -/ -- -15 -667 -) -= -10906 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -462 -655 -ns -/ -iter -( -+ -/ -- -18 -871 -) -= -10987 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -456 -642 -ns -/ -iter -( -+ -/ -- -19 -218 -) -= -11132 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -456 -307 -ns -/ -iter -( -+ -/ -- -15 -369 -) -= -11140 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -655 -033 -ns -/ -iter -( -+ -/ -- -7 -901 -) -= -7760 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -902 -675 -ns -/ -iter -( -+ -/ -- -15 -165 -) -= -5631 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -1 -159 -521 -ns -/ -iter -( -+ -/ -- -14 -489 -) -= -4384 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -1 -147 -781 -ns -/ -iter -( -+ -/ -- -16 -536 -) -= -4428 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -1 -133 -068 -ns -/ -iter -( -+ -/ -- -13 -938 -) -= -4486 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -1 -061 -174 -ns -/ -iter -( -+ -/ -- -14 -478 -) -= -4790 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -1 -151 -637 -ns -/ -iter -( -+ -/ -- -35 -753 -) -= -4414 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -1 -137 -068 -ns -/ -iter -( -+ -/ -- -37 -678 -) -= -4470 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -1 -185 -082 -ns -/ -iter -( -+ -/ -- -14 -355 -) -= -4289 -MB -/ -s -test -rust_compile -: -: -compile_huge -. -. -. -bench -: -66 -894 -ns -/ -iter -( -+ -/ -- -2 -425 -) -test -rust_compile -: -: -compile_huge_bytes -. -. -. -bench -: -3 -331 -663 -ns -/ -iter -( -+ -/ -- -47 -261 -) -test -rust_compile -: -: -compile_huge_full -. -. -. -bench -: -6 -446 -254 -ns -/ -iter -( -+ -/ -- -65 -334 -) -test -rust_compile -: -: -compile_simple -. -. -. -bench -: -2 -351 -ns -/ -iter -( -+ -/ -- -71 -) -test -rust_compile -: -: -compile_simple_bytes -. -. -. -bench -: -2 -350 -ns -/ -iter -( -+ -/ -- -49 -) -test -rust_compile -: -: -compile_simple_full -. -. -. -bench -: -14 -460 -ns -/ -iter -( -+ -/ -- -144 -) -test -rust_compile -: -: -compile_small -. -. -. -bench -: -10 -350 -ns -/ -iter -( -+ -/ -- -120 -) -test -rust_compile -: -: -compile_small_bytes -. -. -. -bench -: -10 -993 -ns -/ -iter -( -+ -/ -- -89 -) -test -rust_compile -: -: -compile_small_full -. -. -. -bench -: -14 -201 -ns -/ -iter -( -+ -/ -- -139 -) -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -698 -092 -ns -/ -iter -( -+ -/ -- -6 -907 -) -= -852 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -29 -127 -ns -/ -iter -( -+ -/ -- -1 -001 -) -= -20425 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -026 -902 -ns -/ -iter -( -+ -/ -- -86 -299 -) -= -579 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -433 -157 -ns -/ -iter -( -+ -/ -- -10 -129 -) -= -1373 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -57 -103 -ns -/ -iter -( -+ -/ -- -509 -) -= -10418 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -344 -973 -ns -/ -iter -( -+ -/ -- -3 -288 -) -= -1724 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -158 -337 -ns -/ -iter -( -+ -/ -- -2 -492 -) -= -3757 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -776 -703 -ns -/ -iter -( -+ -/ -- -8 -000 -) -= -765 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -10 -179 -909 -ns -/ -iter -( -+ -/ -- -55 -188 -) -= -58 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -10 -007 -465 -ns -/ -iter -( -+ -/ -- -75 -168 -) -= -59 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -116 -201 -ns -/ -iter -( -+ -/ -- -11 -571 -) -= -532 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -693 -124 -ns -/ -iter -( -+ -/ -- -6 -540 -) -= -858 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -12 -079 -ns -/ -iter -( -+ -/ -- -192 -) -= -49253 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -44 -336 -ns -/ -iter -( -+ -/ -- -1 -424 -) -= -13418 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -49 -569 -ns -/ -iter -( -+ -/ -- -721 -) -= -12002 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -189 -812 -ns -/ -iter -( -+ -/ -- -2 -952 -) -= -3134 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -52 -132 -ns -/ -iter -( -+ -/ -- -1 -182 -) -= -11412 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -120 -591 -ns -/ -iter -( -+ -/ -- -2 -521 -) -= -4933 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -46 -956 -ns -/ -iter -( -+ -/ -- -545 -) -= -12670 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -199 -252 -ns -/ -iter -( -+ -/ -- -2 -212 -) -= -2985 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -17 -983 -ns -/ -iter -( -+ -/ -- -591 -) -= -33083 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -58 -139 -ns -/ -iter -( -+ -/ -- -919 -) -= -10232 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -14 -283 -ns -/ -iter -( -+ -/ -- -113 -) -= -41653 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -14 -587 -ns -/ -iter -( -+ -/ -- -82 -) -= -40785 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -40 -947 -ns -/ -iter -( -+ -/ -- -385 -) -= -14529 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -39 -607 -ns -/ -iter -( -+ -/ -- -567 -) -= -15020 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -18 -803 -ns -/ -iter -( -+ -/ -- -232 -) -= -31640 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -13 -704 -ns -/ -iter -( -+ -/ -- -73 -) -= -43413 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -14 -166 -ns -/ -iter -( -+ -/ -- -191 -) -= -41997 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -13 -702 -ns -/ -iter -( -+ -/ -- -36 -) -= -43419 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -232 -609 -ns -/ -iter -( -+ -/ -- -3 -217 -) -= -2557 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -36 -167 -769 -ns -/ -iter -( -+ -/ -- -592 -579 -) -= -16 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -188 -281 -ns -/ -iter -( -+ -/ -- -2 -966 -) -= -3159 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -312 -853 -ns -/ -iter -( -+ -/ -- -23 -145 -) -= -1901 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -20 -987 -ns -/ -iter -( -+ -/ -- -909 -) -= -28347 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -427 -154 -ns -/ -iter -( -+ -/ -- -6 -396 -) -= -1392 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -1 -112 -964 -ns -/ -iter -( -+ -/ -- -15 -393 -) -= -534 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -4 -513 -468 -ns -/ -iter -( -+ -/ -- -35 -410 -) -= -131 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -107 -measured -; -0 -filtered -out -; -finished -in -143 -. -96s diff --git a/third_party/rust/regex/record/old-bench-log/13-regex-1.9.0/rust b/third_party/rust/regex/record/old-bench-log/13-regex-1.9.0/rust deleted file mode 100644 index ccfc5e2e2cfbc..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/13-regex-1.9.0/rust +++ /dev/null @@ -1,2892 +0,0 @@ -running -110 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -26000 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -1 -) -= -32500 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -1733 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -1 -) -= -2166 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -25023 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -24966738 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -1404 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -762674 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -35 -ns -/ -iter -( -+ -/ -- -0 -) -= -29828 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -35 -ns -/ -iter -( -+ -/ -- -0 -) -= -29959885 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -35 -ns -/ -iter -( -+ -/ -- -0 -) -= -1485 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -35 -ns -/ -iter -( -+ -/ -- -0 -) -= -936800 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -24441 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -24966738 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -1404 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -780833 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -46 -ns -/ -iter -( -+ -/ -- -1 -) -= -543 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -9 -ns -/ -iter -( -+ -/ -- -0 -) -= -5666 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -801 -ns -/ -iter -( -+ -/ -- -24 -) -= -55525 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -194 -124 -ns -/ -iter -( -+ -/ -- -289 -) -= -515 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -22 -ns -/ -iter -( -+ -/ -- -1 -) -= -3681 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -8100 -MB -/ -s -test -misc -: -: -match_class_unicode -. -. -. -bench -: -196 -ns -/ -iter -( -+ -/ -- -0 -) -= -821 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -55 -ns -/ -iter -( -+ -/ -- -3 -) -= -454 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -24465 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -24386139 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -1395 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -762697 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -167 -ns -/ -iter -( -+ -/ -- -0 -) -= -598 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -26 -ns -/ -iter -( -+ -/ -- -1 -) -= -1961 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -0 -) -= -650 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -40 -ns -/ -iter -( -+ -/ -- -0 -) -= -650 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -30 -ns -/ -iter -( -+ -/ -- -0 -) -= -566 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -31 -ns -/ -iter -( -+ -/ -- -0 -) -= -548 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -67 -ns -/ -iter -( -+ -/ -- -1 -) -= -15522 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -78 -ns -/ -iter -( -+ -/ -- -1 -) -= -13474 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -19 -310 -ns -/ -iter -( -+ -/ -- -80 -) -= -54303 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -2 -) -= -951 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -543 -ns -/ -iter -( -+ -/ -- -4 -) -= -60395 -MB -/ -s -test -misc -: -: -replace_all -. -. -. -bench -: -151 -ns -/ -iter -( -+ -/ -- -13 -) -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -9 -302 -ns -/ -iter -( -+ -/ -- -25 -) -= -860 -MB -/ -s -test -misc -: -: -short_haystack_1000000x -. -. -. -bench -: -90 -868 -ns -/ -iter -( -+ -/ -- -354 -) -= -88039 -MB -/ -s -test -misc -: -: -short_haystack_100000x -. -. -. -bench -: -7 -215 -ns -/ -iter -( -+ -/ -- -18 -) -= -110881 -MB -/ -s -test -misc -: -: -short_haystack_10000x -. -. -. -bench -: -605 -ns -/ -iter -( -+ -/ -- -2 -) -= -132249 -MB -/ -s -test -misc -: -: -short_haystack_1000x -. -. -. -bench -: -148 -ns -/ -iter -( -+ -/ -- -2 -) -= -54128 -MB -/ -s -test -misc -: -: -short_haystack_100x -. -. -. -bench -: -83 -ns -/ -iter -( -+ -/ -- -3 -) -= -9771 -MB -/ -s -test -misc -: -: -short_haystack_10x -. -. -. -bench -: -89 -ns -/ -iter -( -+ -/ -- -1 -) -= -1022 -MB -/ -s -test -misc -: -: -short_haystack_1x -. -. -. -bench -: -79 -ns -/ -iter -( -+ -/ -- -1 -) -= -240 -MB -/ -s -test -misc -: -: -short_haystack_2x -. -. -. -bench -: -79 -ns -/ -iter -( -+ -/ -- -1 -) -= -341 -MB -/ -s -test -misc -: -: -short_haystack_3x -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -2 -) -= -437 -MB -/ -s -test -misc -: -: -short_haystack_4x -. -. -. -bench -: -79 -ns -/ -iter -( -+ -/ -- -1 -) -= -544 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -1 -748 -215 -ns -/ -iter -( -+ -/ -- -25 -793 -) -= -2907 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -486 -169 -ns -/ -iter -( -+ -/ -- -11 -425 -) -= -10456 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -479 -019 -ns -/ -iter -( -+ -/ -- -7 -468 -) -= -10612 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -481 -118 -ns -/ -iter -( -+ -/ -- -10 -305 -) -= -10565 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -484 -508 -ns -/ -iter -( -+ -/ -- -11 -753 -) -= -10491 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -481 -861 -ns -/ -iter -( -+ -/ -- -7 -991 -) -= -10549 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -477 -043 -ns -/ -iter -( -+ -/ -- -12 -101 -) -= -10656 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -483 -954 -ns -/ -iter -( -+ -/ -- -7 -728 -) -= -10503 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -479 -564 -ns -/ -iter -( -+ -/ -- -13 -514 -) -= -10600 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -481 -345 -ns -/ -iter -( -+ -/ -- -11 -205 -) -= -10560 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -479 -772 -ns -/ -iter -( -+ -/ -- -13 -266 -) -= -10595 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -480 -299 -ns -/ -iter -( -+ -/ -- -9 -997 -) -= -10583 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -693 -230 -ns -/ -iter -( -+ -/ -- -21 -808 -) -= -7332 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -936 -552 -ns -/ -iter -( -+ -/ -- -9 -916 -) -= -5427 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -1 -192 -921 -ns -/ -iter -( -+ -/ -- -11 -038 -) -= -4261 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -1 -170 -341 -ns -/ -iter -( -+ -/ -- -27 -745 -) -= -4343 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -1 -166 -877 -ns -/ -iter -( -+ -/ -- -8 -369 -) -= -4356 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -1 -085 -919 -ns -/ -iter -( -+ -/ -- -9 -594 -) -= -4681 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -1 -248 -718 -ns -/ -iter -( -+ -/ -- -13 -480 -) -= -4070 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -1 -216 -643 -ns -/ -iter -( -+ -/ -- -15 -505 -) -= -4178 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -1 -219 -951 -ns -/ -iter -( -+ -/ -- -14 -109 -) -= -4166 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -27 -363 -ns -/ -iter -( -+ -/ -- -604 -) -= -21742 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -31 -147 -ns -/ -iter -( -+ -/ -- -876 -) -= -19100 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -326 -354 -ns -/ -iter -( -+ -/ -- -22 -628 -) -= -448 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -801 -343 -ns -/ -iter -( -+ -/ -- -895 -) -= -742 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -56 -328 -ns -/ -iter -( -+ -/ -- -1 -009 -) -= -10561 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -301 -186 -ns -/ -iter -( -+ -/ -- -3 -615 -) -= -1975 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -176 -428 -ns -/ -iter -( -+ -/ -- -2 -182 -) -= -3372 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -173 -948 -ns -/ -iter -( -+ -/ -- -5 -073 -) -= -3420 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -7 -226 -608 -ns -/ -iter -( -+ -/ -- -261 -849 -) -= -82 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -7 -024 -589 -ns -/ -iter -( -+ -/ -- -145 -281 -) -= -84 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -004 -841 -ns -/ -iter -( -+ -/ -- -6 -857 -) -= -592 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -15 -978 -ns -/ -iter -( -+ -/ -- -90 -) -= -37234 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -11 -151 -ns -/ -iter -( -+ -/ -- -289 -) -= -53352 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -45 -441 -ns -/ -iter -( -+ -/ -- -960 -) -= -13092 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -51 -934 -ns -/ -iter -( -+ -/ -- -806 -) -= -11455 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -171 -844 -ns -/ -iter -( -+ -/ -- -4 -176 -) -= -3462 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -46 -611 -ns -/ -iter -( -+ -/ -- -1 -072 -) -= -12763 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -74 -956 -ns -/ -iter -( -+ -/ -- -2 -098 -) -= -7937 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -47 -595 -ns -/ -iter -( -+ -/ -- -595 -) -= -12499 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -100 -636 -ns -/ -iter -( -+ -/ -- -814 -) -= -5911 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -19 -293 -ns -/ -iter -( -+ -/ -- -687 -) -= -30836 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -52 -310 -ns -/ -iter -( -+ -/ -- -1 -024 -) -= -11373 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -16 -080 -ns -/ -iter -( -+ -/ -- -327 -) -= -36998 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -14 -605 -ns -/ -iter -( -+ -/ -- -120 -) -= -40734 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -38 -662 -ns -/ -iter -( -+ -/ -- -360 -) -= -15388 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -37 -650 -ns -/ -iter -( -+ -/ -- -316 -) -= -15801 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -16 -234 -ns -/ -iter -( -+ -/ -- -125 -) -= -36647 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -13 -709 -ns -/ -iter -( -+ -/ -- -72 -) -= -43397 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -9 -870 -ns -/ -iter -( -+ -/ -- -133 -) -= -60276 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -13 -735 -ns -/ -iter -( -+ -/ -- -57 -) -= -43315 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -189 -377 -ns -/ -iter -( -+ -/ -- -2 -105 -) -= -3141 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -29 -934 -ns -/ -iter -( -+ -/ -- -1 -249 -) -= -19874 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -213 -236 -ns -/ -iter -( -+ -/ -- -3 -823 -) -= -2790 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -322 -922 -ns -/ -iter -( -+ -/ -- -5 -946 -) -= -1842 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -23 -494 -ns -/ -iter -( -+ -/ -- -718 -) -= -25322 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -392 -113 -ns -/ -iter -( -+ -/ -- -6 -046 -) -= -1517 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -673 -618 -ns -/ -iter -( -+ -/ -- -12 -865 -) -= -883 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -3 -632 -096 -ns -/ -iter -( -+ -/ -- -56 -944 -) -= -163 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -110 -measured -; -0 -filtered -out -; -finished -in -117 -. -87s diff --git a/third_party/rust/regex/record/old-bench-log/13-regex-1.9.0/rust-bytes b/third_party/rust/regex/record/old-bench-log/13-regex-1.9.0/rust-bytes deleted file mode 100644 index e4401af957ca7..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/13-regex-1.9.0/rust-bytes +++ /dev/null @@ -1,2595 +0,0 @@ -running -98 -tests -test -misc -: -: -anchored_literal_long_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -26000 -MB -/ -s -test -misc -: -: -anchored_literal_long_non_match -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -32500 -MB -/ -s -test -misc -: -: -anchored_literal_short_match -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -= -1733 -MB -/ -s -test -misc -: -: -anchored_literal_short_non_match -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -= -2166 -MB -/ -s -test -misc -: -: -easy0_1K -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -25023 -MB -/ -s -test -misc -: -: -easy0_1MB -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -24966738 -MB -/ -s -test -misc -: -: -easy0_32 -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -1404 -MB -/ -s -test -misc -: -: -easy0_32K -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -780833 -MB -/ -s -test -misc -: -: -easy1_1K -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -1 -) -= -30705 -MB -/ -s -test -misc -: -: -easy1_1MB -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -0 -) -= -30841058 -MB -/ -s -test -misc -: -: -easy1_32 -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -0 -) -= -1529 -MB -/ -s -test -misc -: -: -easy1_32K -. -. -. -bench -: -34 -ns -/ -iter -( -+ -/ -- -0 -) -= -964352 -MB -/ -s -test -misc -: -: -hard_1K -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -25023 -MB -/ -s -test -misc -: -: -hard_1MB -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -24966738 -MB -/ -s -test -misc -: -: -hard_32 -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -1404 -MB -/ -s -test -misc -: -: -hard_32K -. -. -. -bench -: -42 -ns -/ -iter -( -+ -/ -- -0 -) -= -780833 -MB -/ -s -test -misc -: -: -is_match_set -. -. -. -bench -: -47 -ns -/ -iter -( -+ -/ -- -1 -) -= -531 -MB -/ -s -test -misc -: -: -literal -. -. -. -bench -: -10 -ns -/ -iter -( -+ -/ -- -0 -) -= -5100 -MB -/ -s -test -misc -: -: -long_needle1 -. -. -. -bench -: -1 -808 -ns -/ -iter -( -+ -/ -- -7 -) -= -55310 -MB -/ -s -test -misc -: -: -long_needle2 -. -. -. -bench -: -213 -106 -ns -/ -iter -( -+ -/ -- -416 -) -= -469 -MB -/ -s -test -misc -: -: -match_class -. -. -. -bench -: -23 -ns -/ -iter -( -+ -/ -- -1 -) -= -3521 -MB -/ -s -test -misc -: -: -match_class_in_range -. -. -. -bench -: -11 -ns -/ -iter -( -+ -/ -- -0 -) -= -7363 -MB -/ -s -test -misc -: -: -matches_set -. -. -. -bench -: -56 -ns -/ -iter -( -+ -/ -- -3 -) -= -446 -MB -/ -s -test -misc -: -: -medium_1K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -24465 -MB -/ -s -test -misc -: -: -medium_1MB -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -24386139 -MB -/ -s -test -misc -: -: -medium_32 -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -1395 -MB -/ -s -test -misc -: -: -medium_32K -. -. -. -bench -: -43 -ns -/ -iter -( -+ -/ -- -0 -) -= -762697 -MB -/ -s -test -misc -: -: -no_exponential -. -. -. -bench -: -162 -ns -/ -iter -( -+ -/ -- -4 -) -= -617 -MB -/ -s -test -misc -: -: -not_literal -. -. -. -bench -: -27 -ns -/ -iter -( -+ -/ -- -1 -) -= -1888 -MB -/ -s -test -misc -: -: -one_pass_long_prefix -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -634 -MB -/ -s -test -misc -: -: -one_pass_long_prefix_not -. -. -. -bench -: -41 -ns -/ -iter -( -+ -/ -- -0 -) -= -634 -MB -/ -s -test -misc -: -: -one_pass_short -. -. -. -bench -: -30 -ns -/ -iter -( -+ -/ -- -0 -) -= -566 -MB -/ -s -test -misc -: -: -one_pass_short_not -. -. -. -bench -: -31 -ns -/ -iter -( -+ -/ -- -0 -) -= -548 -MB -/ -s -test -misc -: -: -reallyhard2_1K -. -. -. -bench -: -70 -ns -/ -iter -( -+ -/ -- -1 -) -= -14857 -MB -/ -s -test -misc -: -: -reallyhard_1K -. -. -. -bench -: -78 -ns -/ -iter -( -+ -/ -- -3 -) -= -13474 -MB -/ -s -test -misc -: -: -reallyhard_1MB -. -. -. -bench -: -19 -850 -ns -/ -iter -( -+ -/ -- -345 -) -= -52826 -MB -/ -s -test -misc -: -: -reallyhard_32 -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -2 -) -= -967 -MB -/ -s -test -misc -: -: -reallyhard_32K -. -. -. -bench -: -546 -ns -/ -iter -( -+ -/ -- -8 -) -= -60064 -MB -/ -s -test -misc -: -: -reverse_suffix_no_quadratic -. -. -. -bench -: -9 -304 -ns -/ -iter -( -+ -/ -- -29 -) -= -859 -MB -/ -s -test -regexdna -: -: -find_new_lines -. -. -. -bench -: -1 -733 -767 -ns -/ -iter -( -+ -/ -- -66 -699 -) -= -2932 -MB -/ -s -test -regexdna -: -: -subst1 -. -. -. -bench -: -486 -442 -ns -/ -iter -( -+ -/ -- -11 -929 -) -= -10450 -MB -/ -s -test -regexdna -: -: -subst10 -. -. -. -bench -: -486 -073 -ns -/ -iter -( -+ -/ -- -12 -157 -) -= -10458 -MB -/ -s -test -regexdna -: -: -subst11 -. -. -. -bench -: -483 -485 -ns -/ -iter -( -+ -/ -- -11 -703 -) -= -10514 -MB -/ -s -test -regexdna -: -: -subst2 -. -. -. -bench -: -487 -298 -ns -/ -iter -( -+ -/ -- -9 -184 -) -= -10431 -MB -/ -s -test -regexdna -: -: -subst3 -. -. -. -bench -: -491 -219 -ns -/ -iter -( -+ -/ -- -9 -614 -) -= -10348 -MB -/ -s -test -regexdna -: -: -subst4 -. -. -. -bench -: -482 -668 -ns -/ -iter -( -+ -/ -- -9 -576 -) -= -10531 -MB -/ -s -test -regexdna -: -: -subst5 -. -. -. -bench -: -489 -673 -ns -/ -iter -( -+ -/ -- -8 -331 -) -= -10381 -MB -/ -s -test -regexdna -: -: -subst6 -. -. -. -bench -: -484 -707 -ns -/ -iter -( -+ -/ -- -5 -276 -) -= -10487 -MB -/ -s -test -regexdna -: -: -subst7 -. -. -. -bench -: -485 -109 -ns -/ -iter -( -+ -/ -- -9 -360 -) -= -10478 -MB -/ -s -test -regexdna -: -: -subst8 -. -. -. -bench -: -485 -790 -ns -/ -iter -( -+ -/ -- -9 -298 -) -= -10464 -MB -/ -s -test -regexdna -: -: -subst9 -. -. -. -bench -: -483 -255 -ns -/ -iter -( -+ -/ -- -12 -434 -) -= -10519 -MB -/ -s -test -regexdna -: -: -variant1 -. -. -. -bench -: -654 -757 -ns -/ -iter -( -+ -/ -- -8 -719 -) -= -7763 -MB -/ -s -test -regexdna -: -: -variant2 -. -. -. -bench -: -905 -052 -ns -/ -iter -( -+ -/ -- -9 -599 -) -= -5616 -MB -/ -s -test -regexdna -: -: -variant3 -. -. -. -bench -: -1 -161 -187 -ns -/ -iter -( -+ -/ -- -13 -798 -) -= -4377 -MB -/ -s -test -regexdna -: -: -variant4 -. -. -. -bench -: -1 -144 -656 -ns -/ -iter -( -+ -/ -- -15 -198 -) -= -4440 -MB -/ -s -test -regexdna -: -: -variant5 -. -. -. -bench -: -1 -136 -222 -ns -/ -iter -( -+ -/ -- -9 -112 -) -= -4473 -MB -/ -s -test -regexdna -: -: -variant6 -. -. -. -bench -: -1 -062 -124 -ns -/ -iter -( -+ -/ -- -12 -336 -) -= -4786 -MB -/ -s -test -regexdna -: -: -variant7 -. -. -. -bench -: -1 -144 -371 -ns -/ -iter -( -+ -/ -- -44 -700 -) -= -4442 -MB -/ -s -test -regexdna -: -: -variant8 -. -. -. -bench -: -1 -143 -064 -ns -/ -iter -( -+ -/ -- -53 -456 -) -= -4447 -MB -/ -s -test -regexdna -: -: -variant9 -. -. -. -bench -: -1 -187 -063 -ns -/ -iter -( -+ -/ -- -14 -341 -) -= -4282 -MB -/ -s -test -sherlock -: -: -before_after_holmes -. -. -. -bench -: -27 -804 -ns -/ -iter -( -+ -/ -- -598 -) -= -21397 -MB -/ -s -test -sherlock -: -: -before_holmes -. -. -. -bench -: -31 -197 -ns -/ -iter -( -+ -/ -- -933 -) -= -19070 -MB -/ -s -test -sherlock -: -: -everything_greedy -. -. -. -bench -: -1 -272 -335 -ns -/ -iter -( -+ -/ -- -12 -466 -) -= -467 -MB -/ -s -test -sherlock -: -: -everything_greedy_nl -. -. -. -bench -: -801 -469 -ns -/ -iter -( -+ -/ -- -955 -) -= -742 -MB -/ -s -test -sherlock -: -: -holmes_cochar_watson -. -. -. -bench -: -56 -790 -ns -/ -iter -( -+ -/ -- -1 -606 -) -= -10476 -MB -/ -s -test -sherlock -: -: -holmes_coword_watson -. -. -. -bench -: -300 -554 -ns -/ -iter -( -+ -/ -- -3 -460 -) -= -1979 -MB -/ -s -test -sherlock -: -: -ing_suffix -. -. -. -bench -: -179 -355 -ns -/ -iter -( -+ -/ -- -5 -486 -) -= -3317 -MB -/ -s -test -sherlock -: -: -ing_suffix_limited_space -. -. -. -bench -: -175 -703 -ns -/ -iter -( -+ -/ -- -2 -380 -) -= -3386 -MB -/ -s -test -sherlock -: -: -letters -. -. -. -bench -: -7 -197 -094 -ns -/ -iter -( -+ -/ -- -181 -502 -) -= -82 -MB -/ -s -test -sherlock -: -: -letters_lower -. -. -. -bench -: -7 -100 -979 -ns -/ -iter -( -+ -/ -- -155 -898 -) -= -83 -MB -/ -s -test -sherlock -: -: -letters_upper -. -. -. -bench -: -1 -018 -217 -ns -/ -iter -( -+ -/ -- -21 -695 -) -= -584 -MB -/ -s -test -sherlock -: -: -line_boundary_sherlock_holmes -. -. -. -bench -: -15 -931 -ns -/ -iter -( -+ -/ -- -140 -) -= -37344 -MB -/ -s -test -sherlock -: -: -name_alt1 -. -. -. -bench -: -10 -932 -ns -/ -iter -( -+ -/ -- -96 -) -= -54421 -MB -/ -s -test -sherlock -: -: -name_alt2 -. -. -. -bench -: -45 -580 -ns -/ -iter -( -+ -/ -- -829 -) -= -13052 -MB -/ -s -test -sherlock -: -: -name_alt3 -. -. -. -bench -: -51 -942 -ns -/ -iter -( -+ -/ -- -1 -418 -) -= -11453 -MB -/ -s -test -sherlock -: -: -name_alt3_nocase -. -. -. -bench -: -171 -749 -ns -/ -iter -( -+ -/ -- -1 -451 -) -= -3463 -MB -/ -s -test -sherlock -: -: -name_alt4 -. -. -. -bench -: -45 -705 -ns -/ -iter -( -+ -/ -- -1 -536 -) -= -13016 -MB -/ -s -test -sherlock -: -: -name_alt4_nocase -. -. -. -bench -: -73 -782 -ns -/ -iter -( -+ -/ -- -1 -679 -) -= -8063 -MB -/ -s -test -sherlock -: -: -name_alt5 -. -. -. -bench -: -48 -045 -ns -/ -iter -( -+ -/ -- -1 -261 -) -= -12382 -MB -/ -s -test -sherlock -: -: -name_alt5_nocase -. -. -. -bench -: -100 -307 -ns -/ -iter -( -+ -/ -- -553 -) -= -5931 -MB -/ -s -test -sherlock -: -: -name_holmes -. -. -. -bench -: -18 -916 -ns -/ -iter -( -+ -/ -- -662 -) -= -31451 -MB -/ -s -test -sherlock -: -: -name_holmes_nocase -. -. -. -bench -: -52 -714 -ns -/ -iter -( -+ -/ -- -774 -) -= -11286 -MB -/ -s -test -sherlock -: -: -name_sherlock -. -. -. -bench -: -14 -575 -ns -/ -iter -( -+ -/ -- -163 -) -= -40818 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes -. -. -. -bench -: -14 -625 -ns -/ -iter -( -+ -/ -- -166 -) -= -40679 -MB -/ -s -test -sherlock -: -: -name_sherlock_holmes_nocase -. -. -. -bench -: -39 -024 -ns -/ -iter -( -+ -/ -- -361 -) -= -15245 -MB -/ -s -test -sherlock -: -: -name_sherlock_nocase -. -. -. -bench -: -38 -025 -ns -/ -iter -( -+ -/ -- -418 -) -= -15645 -MB -/ -s -test -sherlock -: -: -name_whitespace -. -. -. -bench -: -16 -247 -ns -/ -iter -( -+ -/ -- -88 -) -= -36618 -MB -/ -s -test -sherlock -: -: -no_match_common -. -. -. -bench -: -13 -724 -ns -/ -iter -( -+ -/ -- -28 -) -= -43349 -MB -/ -s -test -sherlock -: -: -no_match_really_common -. -. -. -bench -: -13 -798 -ns -/ -iter -( -+ -/ -- -93 -) -= -43117 -MB -/ -s -test -sherlock -: -: -no_match_uncommon -. -. -. -bench -: -13 -671 -ns -/ -iter -( -+ -/ -- -80 -) -= -43517 -MB -/ -s -test -sherlock -: -: -quotes -. -. -. -bench -: -189 -359 -ns -/ -iter -( -+ -/ -- -2 -334 -) -= -3141 -MB -/ -s -test -sherlock -: -: -repeated_class_negation -. -. -. -bench -: -29 -083 -ns -/ -iter -( -+ -/ -- -708 -) -= -20456 -MB -/ -s -test -sherlock -: -: -the_lower -. -. -. -bench -: -204 -122 -ns -/ -iter -( -+ -/ -- -4 -256 -) -= -2914 -MB -/ -s -test -sherlock -: -: -the_nocase -. -. -. -bench -: -319 -388 -ns -/ -iter -( -+ -/ -- -6 -790 -) -= -1862 -MB -/ -s -test -sherlock -: -: -the_upper -. -. -. -bench -: -22 -706 -ns -/ -iter -( -+ -/ -- -961 -) -= -26201 -MB -/ -s -test -sherlock -: -: -the_whitespace -. -. -. -bench -: -386 -276 -ns -/ -iter -( -+ -/ -- -4 -950 -) -= -1540 -MB -/ -s -test -sherlock -: -: -word_ending_n -. -. -. -bench -: -690 -010 -ns -/ -iter -( -+ -/ -- -8 -516 -) -= -862 -MB -/ -s -test -sherlock -: -: -words -. -. -. -bench -: -3 -659 -990 -ns -/ -iter -( -+ -/ -- -104 -505 -) -= -162 -MB -/ -s -test -result -: -ok -. -0 -passed -; -0 -failed -; -0 -ignored -; -98 -measured -; -0 -filtered -out -; -finished -in -105 -. -65s diff --git a/third_party/rust/regex/record/old-bench-log/README.md b/third_party/rust/regex/record/old-bench-log/README.md deleted file mode 100644 index 5819562f3c018..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/README.md +++ /dev/null @@ -1,104 +0,0 @@ -These -represent -an -old -log -of -benchmarks -from -regex -1 -. -7 -. -3 -and -older -. -New -and -much -more -comprehensive -benchmarks -are -now -maintained -as -part -of -the -[ -rebar -] -project -. -We -keep -these -old -benchmark -recordings -for -posterity -but -they -may -be -removed -in -the -future -. -Measurements -can -be -compared -using -the -[ -cargo -- -benchcmp -] -[ -cargo -- -benchcmp -] -tool -. -[ -rebar -] -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -rebar -[ -cargo -- -benchcmp -] -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -cargo -- -benchcmp diff --git a/third_party/rust/regex/record/old-bench-log/old/01-before b/third_party/rust/regex/record/old-bench-log/old/01-before deleted file mode 100644 index 025263745f43c..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/01-before +++ /dev/null @@ -1,620 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -520 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -236 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -519 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -238 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -7742 -ns -/ -iter -( -+ -/ -- -97 -) -= -132 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -4989 -ns -/ -iter -( -+ -/ -- -20 -) -= -6 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -96347 -ns -/ -iter -( -+ -/ -- -997 -) -= -340 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -9805 -ns -/ -iter -( -+ -/ -- -1846 -) -= -104 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -4930 -ns -/ -iter -( -+ -/ -- -202 -) -= -6 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -163332 -ns -/ -iter -( -+ -/ -- -9207 -) -= -200 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -97455 -ns -/ -iter -( -+ -/ -- -1089 -) -= -10 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -8256 -ns -/ -iter -( -+ -/ -- -148 -) -= -3 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -2948095 -ns -/ -iter -( -+ -/ -- -11988 -) -= -11 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -371 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -match_class -. -. -. -bench -: -2168 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -2379 -ns -/ -iter -( -+ -/ -- -13 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -37073 -ns -/ -iter -( -+ -/ -- -1100 -) -= -27 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -6183 -ns -/ -iter -( -+ -/ -- -218 -) -= -5 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -1032000 -ns -/ -iter -( -+ -/ -- -8278 -) -= -31 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -727975 -ns -/ -iter -( -+ -/ -- -2970 -) -test -bench -: -: -not_literal -. -. -. -bench -: -4670 -ns -/ -iter -( -+ -/ -- -29 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -1562 -ns -/ -iter -( -+ -/ -- -24 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -1539 -ns -/ -iter -( -+ -/ -- -40 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -2688 -ns -/ -iter -( -+ -/ -- -21 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -4197 -ns -/ -iter -( -+ -/ -- -36 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -2198 -ns -/ -iter -( -+ -/ -- -22 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -3761 -ns -/ -iter -( -+ -/ -- -41 -) -test -bench -: -: -replace_all -. -. -. -bench -: -2874 -ns -/ -iter -( -+ -/ -- -25 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/02-new-syntax-crate b/third_party/rust/regex/record/old-bench-log/old/02-new-syntax-crate deleted file mode 100644 index 10f993bae5720..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/02-new-syntax-crate +++ /dev/null @@ -1,620 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -545 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -251 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -521 -ns -/ -iter -( -+ -/ -- -31 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -231 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -7465 -ns -/ -iter -( -+ -/ -- -102 -) -= -137 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -4995 -ns -/ -iter -( -+ -/ -- -27 -) -= -6 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -86985 -ns -/ -iter -( -+ -/ -- -755 -) -= -376 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -9493 -ns -/ -iter -( -+ -/ -- -1727 -) -= -107 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -4955 -ns -/ -iter -( -+ -/ -- -324 -) -= -6 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -155288 -ns -/ -iter -( -+ -/ -- -13016 -) -= -210 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -95925 -ns -/ -iter -( -+ -/ -- -1674 -) -= -10 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -8264 -ns -/ -iter -( -+ -/ -- -151 -) -= -3 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -2886440 -ns -/ -iter -( -+ -/ -- -25807 -) -= -11 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -365 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -match_class -. -. -. -bench -: -2313 -ns -/ -iter -( -+ -/ -- -8 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -2596 -ns -/ -iter -( -+ -/ -- -8 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -38136 -ns -/ -iter -( -+ -/ -- -941 -) -= -26 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -6178 -ns -/ -iter -( -+ -/ -- -147 -) -= -5 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -1065698 -ns -/ -iter -( -+ -/ -- -6815 -) -= -30 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -682461 -ns -/ -iter -( -+ -/ -- -2860 -) -test -bench -: -: -not_literal -. -. -. -bench -: -4525 -ns -/ -iter -( -+ -/ -- -67 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -1459 -ns -/ -iter -( -+ -/ -- -13 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -1463 -ns -/ -iter -( -+ -/ -- -8 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -2615 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -4066 -ns -/ -iter -( -+ -/ -- -48 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -2064 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -3502 -ns -/ -iter -( -+ -/ -- -24 -) -test -bench -: -: -replace_all -. -. -. -bench -: -2949 -ns -/ -iter -( -+ -/ -- -15 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/03-new-syntax-crate b/third_party/rust/regex/record/old-bench-log/old/03-new-syntax-crate deleted file mode 100644 index a586ebbfeea43..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/03-new-syntax-crate +++ /dev/null @@ -1,620 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -373 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -204 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -376 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -206 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -9136 -ns -/ -iter -( -+ -/ -- -177 -) -= -112 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -6641 -ns -/ -iter -( -+ -/ -- -86 -) -= -4 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -88826 -ns -/ -iter -( -+ -/ -- -1366 -) -= -368 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -10937 -ns -/ -iter -( -+ -/ -- -737 -) -= -93 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -7366 -ns -/ -iter -( -+ -/ -- -219 -) -= -4 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -122324 -ns -/ -iter -( -+ -/ -- -4628 -) -= -267 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -59998 -ns -/ -iter -( -+ -/ -- -965 -) -= -17 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -9058 -ns -/ -iter -( -+ -/ -- -123 -) -= -3 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1694326 -ns -/ -iter -( -+ -/ -- -27226 -) -= -19 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -336 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -match_class -. -. -. -bench -: -2109 -ns -/ -iter -( -+ -/ -- -27 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -2274 -ns -/ -iter -( -+ -/ -- -32 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -38317 -ns -/ -iter -( -+ -/ -- -1075 -) -= -26 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -7969 -ns -/ -iter -( -+ -/ -- -115 -) -= -4 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -1028260 -ns -/ -iter -( -+ -/ -- -12905 -) -= -31 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -257719 -ns -/ -iter -( -+ -/ -- -4939 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1699 -ns -/ -iter -( -+ -/ -- -31 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -750 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -747 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -1844 -ns -/ -iter -( -+ -/ -- -22 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -2395 -ns -/ -iter -( -+ -/ -- -21 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -1270 -ns -/ -iter -( -+ -/ -- -26 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -1869 -ns -/ -iter -( -+ -/ -- -25 -) -test -bench -: -: -replace_all -. -. -. -bench -: -3124 -ns -/ -iter -( -+ -/ -- -53 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/04-fixed-benchmark b/third_party/rust/regex/record/old-bench-log/old/04-fixed-benchmark deleted file mode 100644 index 58c99d53107d2..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/04-fixed-benchmark +++ /dev/null @@ -1,645 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -373 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -202 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -380 -ns -/ -iter -( -+ -/ -- -135 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -211 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -2 -723 -ns -/ -iter -( -+ -/ -- -101 -) -= -376 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -255 -ns -/ -iter -( -+ -/ -- -2 -) -= -125 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -81 -845 -ns -/ -iter -( -+ -/ -- -598 -) -= -400 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -3 -872 -ns -/ -iter -( -+ -/ -- -783 -) -= -264 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -287 -ns -/ -iter -( -+ -/ -- -143 -) -= -111 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -115 -340 -ns -/ -iter -( -+ -/ -- -4 -717 -) -= -284 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -52 -484 -ns -/ -iter -( -+ -/ -- -472 -) -= -19 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -923 -ns -/ -iter -( -+ -/ -- -49 -) -= -16 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -710 -214 -ns -/ -iter -( -+ -/ -- -9 -733 -) -= -19 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -337 -ns -/ -iter -( -+ -/ -- -13 -) -test -bench -: -: -match_class -. -. -. -bench -: -2 -141 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -2 -301 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -31 -696 -ns -/ -iter -( -+ -/ -- -961 -) -= -32 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -1 -155 -ns -/ -iter -( -+ -/ -- -71 -) -= -27 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -1 -016 -101 -ns -/ -iter -( -+ -/ -- -12 -090 -) -= -32 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -262 -801 -ns -/ -iter -( -+ -/ -- -1 -332 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -729 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -779 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -779 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -1 -943 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -2 -545 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -1 -364 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -2 -029 -ns -/ -iter -( -+ -/ -- -22 -) -test -bench -: -: -replace_all -. -. -. -bench -: -3 -185 -ns -/ -iter -( -+ -/ -- -12 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/05-thread-caching b/third_party/rust/regex/record/old-bench-log/old/05-thread-caching deleted file mode 100644 index c5464394c844e..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/05-thread-caching +++ /dev/null @@ -1,640 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -287 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -111 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -286 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -114 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -2562 -ns -/ -iter -( -+ -/ -- -94 -) -= -399 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -95 -ns -/ -iter -( -+ -/ -- -1 -) -= -336 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -81755 -ns -/ -iter -( -+ -/ -- -576 -) -= -400 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -3586 -ns -/ -iter -( -+ -/ -- -917 -) -= -285 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -155 -ns -/ -iter -( -+ -/ -- -132 -) -= -206 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -113980 -ns -/ -iter -( -+ -/ -- -9331 -) -= -287 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -54573 -ns -/ -iter -( -+ -/ -- -565 -) -= -18 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1806 -ns -/ -iter -( -+ -/ -- -44 -) -= -17 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1754465 -ns -/ -iter -( -+ -/ -- -7867 -) -= -18 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -299 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -match_class -. -. -. -bench -: -2399 -ns -/ -iter -( -+ -/ -- -23 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -2142 -ns -/ -iter -( -+ -/ -- -8 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2804 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -29536 -ns -/ -iter -( -+ -/ -- -537 -) -= -34 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -962 -ns -/ -iter -( -+ -/ -- -59 -) -= -33 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -946483 -ns -/ -iter -( -+ -/ -- -7106 -) -= -34 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -274301 -ns -/ -iter -( -+ -/ -- -552 -) -test -bench -: -: -not_literal -. -. -. -bench -: -2039 -ns -/ -iter -( -+ -/ -- -13 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -573 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -577 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -1951 -ns -/ -iter -( -+ -/ -- -29 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -2464 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -1301 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -1785 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -replace_all -. -. -. -bench -: -2168 -ns -/ -iter -( -+ -/ -- -152 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/06-major-dynamic b/third_party/rust/regex/record/old-bench-log/old/06-major-dynamic deleted file mode 100644 index d17451353f5f5..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/06-major-dynamic +++ /dev/null @@ -1,768 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -206 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -97 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -193 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -86 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -356 -ns -/ -iter -( -+ -/ -- -136 -) -= -2876 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -352 -434 -ns -/ -iter -( -+ -/ -- -7 -874 -) -= -2974 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -72 -ns -/ -iter -( -+ -/ -- -21 -) -= -444 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -11 -053 -ns -/ -iter -( -+ -/ -- -1 -388 -) -= -2964 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -331 -ns -/ -iter -( -+ -/ -- -162 -) -= -3093 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -353 -723 -ns -/ -iter -( -+ -/ -- -6 -836 -) -= -2964 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -73 -ns -/ -iter -( -+ -/ -- -20 -) -= -438 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -10 -297 -ns -/ -iter -( -+ -/ -- -1 -137 -) -= -3182 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -34 -951 -ns -/ -iter -( -+ -/ -- -171 -) -= -29 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -63 -323 -613 -ns -/ -iter -( -+ -/ -- -279 -582 -) -= -15 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -131 -ns -/ -iter -( -+ -/ -- -13 -) -= -28 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -099 -921 -ns -/ -iter -( -+ -/ -- -1 -338 -) -= -29 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -16 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class -. -. -. -bench -: -188 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -188 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -1 -940 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -5 -262 -ns -/ -iter -( -+ -/ -- -256 -) -= -194 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -5 -295 -539 -ns -/ -iter -( -+ -/ -- -9 -808 -) -= -197 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -217 -ns -/ -iter -( -+ -/ -- -19 -) -= -147 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -169 -169 -ns -/ -iter -( -+ -/ -- -1 -606 -) -= -193 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -293 -739 -ns -/ -iter -( -+ -/ -- -1 -632 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -371 -ns -/ -iter -( -+ -/ -- -136 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -337 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -341 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -1 -399 -ns -/ -iter -( -+ -/ -- -16 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -1 -229 -ns -/ -iter -( -+ -/ -- -13 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -844 -ns -/ -iter -( -+ -/ -- -24 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -849 -ns -/ -iter -( -+ -/ -- -45 -) -test -bench -: -: -replace_all -. -. -. -bench -: -579 -ns -/ -iter -( -+ -/ -- -3 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/06-major-macro b/third_party/rust/regex/record/old-bench-log/old/06-major-macro deleted file mode 100644 index 20aa8394e18a8..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/06-major-macro +++ /dev/null @@ -1,779 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -225 -ns -/ -iter -( -+ -/ -- -22 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -225 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -60 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -29 -984 -ns -/ -iter -( -+ -/ -- -190 -) -= -34 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -30 -641 -690 -ns -/ -iter -( -+ -/ -- -110 -535 -) -= -33 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -981 -ns -/ -iter -( -+ -/ -- -12 -) -= -32 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -957 -358 -ns -/ -iter -( -+ -/ -- -2 -633 -) -= -34 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -29 -636 -ns -/ -iter -( -+ -/ -- -150 -) -= -34 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -30 -295 -321 -ns -/ -iter -( -+ -/ -- -98 -181 -) -= -34 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -971 -ns -/ -iter -( -+ -/ -- -30 -) -= -32 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -947 -307 -ns -/ -iter -( -+ -/ -- -4 -258 -) -= -34 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -54 -856 -ns -/ -iter -( -+ -/ -- -209 -) -= -18 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -56 -126 -571 -ns -/ -iter -( -+ -/ -- -224 -163 -) -= -17 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -776 -ns -/ -iter -( -+ -/ -- -23 -) -= -18 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -753 -833 -ns -/ -iter -( -+ -/ -- -54 -427 -) -= -18 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -1 -516 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -match_class -. -. -. -bench -: -2 -429 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -2 -398 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -12 -915 -ns -/ -iter -( -+ -/ -- -29 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -31 -914 -ns -/ -iter -( -+ -/ -- -276 -) -= -32 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -32 -617 -173 -ns -/ -iter -( -+ -/ -- -68 -114 -) -= -31 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -1 -046 -ns -/ -iter -( -+ -/ -- -42 -) -= -30 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -1 -019 -516 -ns -/ -iter -( -+ -/ -- -3 -788 -) -= -32 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -303 -239 -ns -/ -iter -( -+ -/ -- -518 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -756 -ns -/ -iter -( -+ -/ -- -115 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -834 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -858 -ns -/ -iter -( -+ -/ -- -15 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -1 -597 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -1 -950 -ns -/ -iter -( -+ -/ -- -21 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -1 -077 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -1 -596 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -replace_all -. -. -. -bench -: -1 -288 -ns -/ -iter -( -+ -/ -- -13 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/07-prefix-improvements b/third_party/rust/regex/record/old-bench-log/old/07-prefix-improvements deleted file mode 100644 index a74bd8401ce17..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/07-prefix-improvements +++ /dev/null @@ -1,764 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -197 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -95 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -193 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -304 -ns -/ -iter -( -+ -/ -- -119 -) -= -3368 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -281 -912 -ns -/ -iter -( -+ -/ -- -5 -274 -) -= -3719 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -74 -ns -/ -iter -( -+ -/ -- -16 -) -= -432 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -909 -ns -/ -iter -( -+ -/ -- -667 -) -= -3678 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -300 -ns -/ -iter -( -+ -/ -- -111 -) -= -3413 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -282 -250 -ns -/ -iter -( -+ -/ -- -5 -556 -) -= -3714 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -98 -ns -/ -iter -( -+ -/ -- -17 -) -= -326 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -8 -105 -ns -/ -iter -( -+ -/ -- -593 -) -= -4042 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -34 -562 -ns -/ -iter -( -+ -/ -- -211 -) -= -29 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -64 -510 -947 -ns -/ -iter -( -+ -/ -- -308 -627 -) -= -15 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -139 -ns -/ -iter -( -+ -/ -- -26 -) -= -28 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -102 -562 -ns -/ -iter -( -+ -/ -- -1 -850 -) -= -29 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class -. -. -. -bench -: -105 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -105 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -270 -ns -/ -iter -( -+ -/ -- -185 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -2 -262 -ns -/ -iter -( -+ -/ -- -73 -) -= -452 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -185 -098 -ns -/ -iter -( -+ -/ -- -3 -007 -) -= -479 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -139 -ns -/ -iter -( -+ -/ -- -1 -) -= -230 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -72 -320 -ns -/ -iter -( -+ -/ -- -193 -) -= -453 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -300 -699 -ns -/ -iter -( -+ -/ -- -494 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -462 -ns -/ -iter -( -+ -/ -- -89 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -283 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -287 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -1 -131 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -1 -259 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -883 -ns -/ -iter -( -+ -/ -- -15 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -799 -ns -/ -iter -( -+ -/ -- -28 -) -test -bench -: -: -replace_all -. -. -. -bench -: -170 -ns -/ -iter -( -+ -/ -- -1 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/08-case-fixes b/third_party/rust/regex/record/old-bench-log/old/08-case-fixes deleted file mode 100644 index 0461c15b261df..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/08-case-fixes +++ /dev/null @@ -1,764 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -192 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -92 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -182 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -82 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -277 -ns -/ -iter -( -+ -/ -- -79 -) -= -3696 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -230 -829 -ns -/ -iter -( -+ -/ -- -5 -712 -) -= -4542 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -70 -ns -/ -iter -( -+ -/ -- -4 -) -= -457 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -444 -ns -/ -iter -( -+ -/ -- -492 -) -= -3880 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -272 -ns -/ -iter -( -+ -/ -- -98 -) -= -3764 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -273 -867 -ns -/ -iter -( -+ -/ -- -6 -351 -) -= -3828 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -72 -ns -/ -iter -( -+ -/ -- -15 -) -= -444 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -8 -109 -ns -/ -iter -( -+ -/ -- -540 -) -= -4040 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -31 -043 -ns -/ -iter -( -+ -/ -- -1 -237 -) -= -32 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -60 -077 -413 -ns -/ -iter -( -+ -/ -- -129 -611 -) -= -16 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -036 -ns -/ -iter -( -+ -/ -- -20 -) -= -30 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -996 -238 -ns -/ -iter -( -+ -/ -- -3 -181 -) -= -32 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -15 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class -. -. -. -bench -: -75 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -77 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -057 -ns -/ -iter -( -+ -/ -- -102 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -2 -252 -ns -/ -iter -( -+ -/ -- -63 -) -= -454 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -186 -091 -ns -/ -iter -( -+ -/ -- -7 -496 -) -= -479 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -132 -ns -/ -iter -( -+ -/ -- -2 -) -= -242 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -72 -394 -ns -/ -iter -( -+ -/ -- -342 -) -= -452 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -286 -662 -ns -/ -iter -( -+ -/ -- -1 -150 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -130 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -271 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -276 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -1 -147 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -901 -ns -/ -iter -( -+ -/ -- -8 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -887 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -777 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -replace_all -. -. -. -bench -: -154 -ns -/ -iter -( -+ -/ -- -0 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/09-before-compiler-rewrite b/third_party/rust/regex/record/old-bench-log/old/09-before-compiler-rewrite deleted file mode 100644 index 50384d2b9e3a0..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/09-before-compiler-rewrite +++ /dev/null @@ -1,764 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -156 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -145 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -76 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -269 -ns -/ -iter -( -+ -/ -- -63 -) -= -3806 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -232 -461 -ns -/ -iter -( -+ -/ -- -13 -022 -) -= -4509 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -63 -ns -/ -iter -( -+ -/ -- -6 -) -= -507 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -358 -ns -/ -iter -( -+ -/ -- -430 -) -= -3920 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -274 -ns -/ -iter -( -+ -/ -- -101 -) -= -3737 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -278 -949 -ns -/ -iter -( -+ -/ -- -11 -324 -) -= -3758 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -63 -ns -/ -iter -( -+ -/ -- -15 -) -= -507 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -7 -731 -ns -/ -iter -( -+ -/ -- -488 -) -= -4238 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -44 -685 -ns -/ -iter -( -+ -/ -- -661 -) -= -22 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -60 -108 -237 -ns -/ -iter -( -+ -/ -- -814 -810 -) -= -16 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -412 -ns -/ -iter -( -+ -/ -- -38 -) -= -22 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -363 -335 -ns -/ -iter -( -+ -/ -- -21 -316 -) -= -24 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -14 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class -. -. -. -bench -: -81 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -81 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -978 -ns -/ -iter -( -+ -/ -- -64 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -2 -239 -ns -/ -iter -( -+ -/ -- -68 -) -= -457 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -215 -729 -ns -/ -iter -( -+ -/ -- -20 -897 -) -= -472 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -124 -ns -/ -iter -( -+ -/ -- -2 -) -= -258 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -72 -486 -ns -/ -iter -( -+ -/ -- -1 -027 -) -= -452 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -282 -992 -ns -/ -iter -( -+ -/ -- -8 -102 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -526 -ns -/ -iter -( -+ -/ -- -32 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -307 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -311 -ns -/ -iter -( -+ -/ -- -8 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -623 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -920 -ns -/ -iter -( -+ -/ -- -19 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -554 -ns -/ -iter -( -+ -/ -- -13 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -740 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -replace_all -. -. -. -bench -: -155 -ns -/ -iter -( -+ -/ -- -5 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/10-compiler-rewrite b/third_party/rust/regex/record/old-bench-log/old/10-compiler-rewrite deleted file mode 100644 index e6f1ac4e4e8dc..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/10-compiler-rewrite +++ /dev/null @@ -1,763 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -145 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -92 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -129 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -72 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -268 -ns -/ -iter -( -+ -/ -- -88 -) -= -3820 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -234 -067 -ns -/ -iter -( -+ -/ -- -4 -663 -) -= -4479 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -64 -ns -/ -iter -( -+ -/ -- -4 -) -= -500 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -298 -ns -/ -iter -( -+ -/ -- -521 -) -= -3948 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -275 -ns -/ -iter -( -+ -/ -- -95 -) -= -3723 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -280 -466 -ns -/ -iter -( -+ -/ -- -5 -938 -) -= -3738 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -64 -ns -/ -iter -( -+ -/ -- -16 -) -= -500 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -7 -693 -ns -/ -iter -( -+ -/ -- -595 -) -= -4259 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -27 -844 -ns -/ -iter -( -+ -/ -- -1 -012 -) -= -36 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -52 -323 -489 -ns -/ -iter -( -+ -/ -- -1 -251 -665 -) -= -19 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -970 -ns -/ -iter -( -+ -/ -- -92 -) -= -32 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -896 -945 -ns -/ -iter -( -+ -/ -- -29 -977 -) -= -36 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -match_class -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -150 -ns -/ -iter -( -+ -/ -- -18 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -2 -241 -ns -/ -iter -( -+ -/ -- -55 -) -= -456 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -186 -354 -ns -/ -iter -( -+ -/ -- -9 -134 -) -= -479 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -125 -ns -/ -iter -( -+ -/ -- -1 -) -= -256 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -72 -156 -ns -/ -iter -( -+ -/ -- -145 -) -= -454 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -305 -034 -ns -/ -iter -( -+ -/ -- -1 -134 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -169 -ns -/ -iter -( -+ -/ -- -105 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -257 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -276 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -680 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -804 -ns -/ -iter -( -+ -/ -- -48 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -337 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -339 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -replace_all -. -. -. -bench -: -150 -ns -/ -iter -( -+ -/ -- -1 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/11-compiler-rewrite b/third_party/rust/regex/record/old-bench-log/old/11-compiler-rewrite deleted file mode 100644 index b2ea980a62e64..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/11-compiler-rewrite +++ /dev/null @@ -1,766 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -171 -ns -/ -iter -( -+ -/ -- -20 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -90 -ns -/ -iter -( -+ -/ -- -8 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -180 -ns -/ -iter -( -+ -/ -- -33 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -78 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -272 -ns -/ -iter -( -+ -/ -- -82 -) -= -3764 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -233 -014 -ns -/ -iter -( -+ -/ -- -22 -144 -) -= -4500 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -6 -) -= -516 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -490 -ns -/ -iter -( -+ -/ -- -905 -) -= -3859 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -273 -ns -/ -iter -( -+ -/ -- -100 -) -= -3750 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -279 -901 -ns -/ -iter -( -+ -/ -- -5 -598 -) -= -3746 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -62 -ns -/ -iter -( -+ -/ -- -6 -) -= -516 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -7 -713 -ns -/ -iter -( -+ -/ -- -566 -) -= -4248 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -38 -641 -ns -/ -iter -( -+ -/ -- -605 -) -= -26 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -56 -579 -116 -ns -/ -iter -( -+ -/ -- -1 -193 -231 -) -= -18 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -252 -ns -/ -iter -( -+ -/ -- -24 -) -= -25 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -247 -639 -ns -/ -iter -( -+ -/ -- -12 -774 -) -= -26 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -13 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -match_class -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -459 -ns -/ -iter -( -+ -/ -- -77 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -2 -244 -ns -/ -iter -( -+ -/ -- -63 -) -= -456 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -192 -052 -ns -/ -iter -( -+ -/ -- -21 -460 -) -= -478 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -122 -ns -/ -iter -( -+ -/ -- -3 -) -= -262 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -73 -167 -ns -/ -iter -( -+ -/ -- -15 -655 -) -= -447 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -289 -292 -ns -/ -iter -( -+ -/ -- -1 -488 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -480 -ns -/ -iter -( -+ -/ -- -18 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -324 -ns -/ -iter -( -+ -/ -- -15 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -337 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -1 -161 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -798 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -456 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -452 -ns -/ -iter -( -+ -/ -- -33 -) -test -bench -: -: -replace_all -. -. -. -bench -: -148 -ns -/ -iter -( -+ -/ -- -0 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/12-executor b/third_party/rust/regex/record/old-bench-log/old/12-executor deleted file mode 100644 index 009d95e7cc34b..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/12-executor +++ /dev/null @@ -1,805 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -179 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -90 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -164 -ns -/ -iter -( -+ -/ -- -16 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -79 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -compile_simple -. -. -. -bench -: -3 -708 -ns -/ -iter -( -+ -/ -- -225 -) -test -bench -: -: -compile_unicode -. -. -. -bench -: -5 -871 -ns -/ -iter -( -+ -/ -- -264 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -263 -ns -/ -iter -( -+ -/ -- -92 -) -= -3893 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -217 -835 -ns -/ -iter -( -+ -/ -- -4 -074 -) -= -4813 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -67 -ns -/ -iter -( -+ -/ -- -1 -) -= -477 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -204 -ns -/ -iter -( -+ -/ -- -426 -) -= -3994 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -276 -ns -/ -iter -( -+ -/ -- -100 -) -= -3710 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -284 -086 -ns -/ -iter -( -+ -/ -- -6 -516 -) -= -3691 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -70 -ns -/ -iter -( -+ -/ -- -15 -) -= -457 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -7 -844 -ns -/ -iter -( -+ -/ -- -556 -) -= -4177 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -30 -062 -ns -/ -iter -( -+ -/ -- -1 -684 -) -= -34 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -50 -839 -701 -ns -/ -iter -( -+ -/ -- -104 -343 -) -= -20 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -009 -ns -/ -iter -( -+ -/ -- -48 -) -= -31 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -965 -341 -ns -/ -iter -( -+ -/ -- -45 -075 -) -= -33 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -150 -ns -/ -iter -( -+ -/ -- -22 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -2 -262 -ns -/ -iter -( -+ -/ -- -66 -) -= -452 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -193 -428 -ns -/ -iter -( -+ -/ -- -6 -147 -) -= -478 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -129 -ns -/ -iter -( -+ -/ -- -1 -) -= -248 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -72 -629 -ns -/ -iter -( -+ -/ -- -348 -) -= -451 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -289 -043 -ns -/ -iter -( -+ -/ -- -2 -478 -) -test -bench -: -: -not_literal -. -. -. -bench -: -1 -195 -ns -/ -iter -( -+ -/ -- -10 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -265 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -270 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -730 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -712 -ns -/ -iter -( -+ -/ -- -4 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -445 -ns -/ -iter -( -+ -/ -- -49 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -406 -ns -/ -iter -( -+ -/ -- -72 -) -test -bench -: -: -replace_all -. -. -. -bench -: -136 -ns -/ -iter -( -+ -/ -- -2 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/12-executor-bytes b/third_party/rust/regex/record/old-bench-log/old/12-executor-bytes deleted file mode 100644 index 7cb42886941a3..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/12-executor-bytes +++ /dev/null @@ -1,808 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -190 -ns -/ -iter -( -+ -/ -- -12 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -85 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -147 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -74 -ns -/ -iter -( -+ -/ -- -5 -) -test -bench -: -: -compile_simple -. -. -. -bench -: -4 -218 -ns -/ -iter -( -+ -/ -- -201 -) -test -bench -: -: -compile_unicode -. -. -. -bench -: -402 -353 -ns -/ -iter -( -+ -/ -- -2 -642 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -253 -ns -/ -iter -( -+ -/ -- -79 -) -= -4047 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -215 -308 -ns -/ -iter -( -+ -/ -- -3 -474 -) -= -4870 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -64 -ns -/ -iter -( -+ -/ -- -4 -) -= -500 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -134 -ns -/ -iter -( -+ -/ -- -435 -) -= -4028 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -277 -ns -/ -iter -( -+ -/ -- -105 -) -= -3696 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -283 -435 -ns -/ -iter -( -+ -/ -- -5 -975 -) -= -3699 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -64 -ns -/ -iter -( -+ -/ -- -14 -) -= -500 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -7 -832 -ns -/ -iter -( -+ -/ -- -575 -) -= -4183 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -35 -380 -ns -/ -iter -( -+ -/ -- -772 -) -= -28 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -46 -639 -535 -ns -/ -iter -( -+ -/ -- -456 -010 -) -= -22 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -110 -ns -/ -iter -( -+ -/ -- -53 -) -= -28 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -146 -751 -ns -/ -iter -( -+ -/ -- -17 -290 -) -= -28 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -487 -088 -ns -/ -iter -( -+ -/ -- -103 -259 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -2 -253 -ns -/ -iter -( -+ -/ -- -52 -) -= -454 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -193 -344 -ns -/ -iter -( -+ -/ -- -7 -582 -) -= -478 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -119 -ns -/ -iter -( -+ -/ -- -5 -) -= -268 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -72 -569 -ns -/ -iter -( -+ -/ -- -283 -) -= -451 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -292 -840 -ns -/ -iter -( -+ -/ -- -2 -823 -) -test -bench -: -: -not_literal -. -. -. -bench -: -6 -417 -ns -/ -iter -( -+ -/ -- -26 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -304 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -943 -ns -/ -iter -( -+ -/ -- -44 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -688 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -687 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -589 -ns -/ -iter -( -+ -/ -- -6 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -357 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench -: -: -replace_all -. -. -. -bench -: -131 -ns -/ -iter -( -+ -/ -- -1 -) diff --git a/third_party/rust/regex/record/old-bench-log/old/13-cache-byte-range-suffixes b/third_party/rust/regex/record/old-bench-log/old/13-cache-byte-range-suffixes deleted file mode 100644 index 83762a2cb4ee7..0000000000000 --- a/third_party/rust/regex/record/old-bench-log/old/13-cache-byte-range-suffixes +++ /dev/null @@ -1,809 +0,0 @@ -test -bench -: -: -anchored_literal_long_match -. -. -. -bench -: -174 -ns -/ -iter -( -+ -/ -- -65 -) -test -bench -: -: -anchored_literal_long_non_match -. -. -. -bench -: -94 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_short_match -. -. -. -bench -: -142 -ns -/ -iter -( -+ -/ -- -1 -) -test -bench -: -: -anchored_literal_short_non_match -. -. -. -bench -: -82 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -compile_simple -. -. -. -bench -: -4 -878 -ns -/ -iter -( -+ -/ -- -207 -) -test -bench -: -: -compile_unicode -. -. -. -bench -: -679 -701 -ns -/ -iter -( -+ -/ -- -10 -264 -) -test -bench -: -: -easy0_1K -. -. -. -bench -: -257 -ns -/ -iter -( -+ -/ -- -83 -) -= -3984 -MB -/ -s -test -bench -: -: -easy0_1MB -. -. -. -bench -: -217 -698 -ns -/ -iter -( -+ -/ -- -3 -307 -) -= -4816 -MB -/ -s -test -bench -: -: -easy0_32 -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -3 -) -= -524 -MB -/ -s -test -bench -: -: -easy0_32K -. -. -. -bench -: -8 -144 -ns -/ -iter -( -+ -/ -- -449 -) -= -4023 -MB -/ -s -test -bench -: -: -easy1_1K -. -. -. -bench -: -276 -ns -/ -iter -( -+ -/ -- -106 -) -= -3710 -MB -/ -s -test -bench -: -: -easy1_1MB -. -. -. -bench -: -285 -518 -ns -/ -iter -( -+ -/ -- -4 -933 -) -= -3672 -MB -/ -s -test -bench -: -: -easy1_32 -. -. -. -bench -: -61 -ns -/ -iter -( -+ -/ -- -12 -) -= -524 -MB -/ -s -test -bench -: -: -easy1_32K -. -. -. -bench -: -7 -896 -ns -/ -iter -( -+ -/ -- -508 -) -= -4149 -MB -/ -s -test -bench -: -: -hard_1K -. -. -. -bench -: -35 -361 -ns -/ -iter -( -+ -/ -- -684 -) -= -28 -MB -/ -s -test -bench -: -: -hard_1MB -. -. -. -bench -: -48 -691 -236 -ns -/ -iter -( -+ -/ -- -2 -316 -446 -) -= -21 -MB -/ -s -test -bench -: -: -hard_32 -. -. -. -bench -: -1 -087 -ns -/ -iter -( -+ -/ -- -33 -) -= -29 -MB -/ -s -test -bench -: -: -hard_32K -. -. -. -bench -: -1 -147 -627 -ns -/ -iter -( -+ -/ -- -4 -982 -) -= -28 -MB -/ -s -test -bench -: -: -literal -. -. -. -bench -: -12 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_in_range -. -. -. -bench -: -80 -ns -/ -iter -( -+ -/ -- -0 -) -test -bench -: -: -match_class_unicode -. -. -. -bench -: -2 -431 -592 -ns -/ -iter -( -+ -/ -- -89 -268 -) -test -bench -: -: -medium_1K -. -. -. -bench -: -2 -245 -ns -/ -iter -( -+ -/ -- -93 -) -= -456 -MB -/ -s -test -bench -: -: -medium_1MB -. -. -. -bench -: -2 -192 -828 -ns -/ -iter -( -+ -/ -- -4 -343 -) -= -478 -MB -/ -s -test -bench -: -: -medium_32 -. -. -. -bench -: -120 -ns -/ -iter -( -+ -/ -- -2 -) -= -266 -MB -/ -s -test -bench -: -: -medium_32K -. -. -. -bench -: -72 -996 -ns -/ -iter -( -+ -/ -- -627 -) -= -448 -MB -/ -s -test -bench -: -: -no_exponential -. -. -. -bench -: -290 -775 -ns -/ -iter -( -+ -/ -- -1 -176 -) -test -bench -: -: -not_literal -. -. -. -bench -: -5 -282 -ns -/ -iter -( -+ -/ -- -199 -) -test -bench -: -: -one_pass_long_prefix -. -. -. -bench -: -294 -ns -/ -iter -( -+ -/ -- -3 -) -test -bench -: -: -one_pass_long_prefix_not -. -. -. -bench -: -315 -ns -/ -iter -( -+ -/ -- -7 -) -test -bench -: -: -one_pass_short_a -. -. -. -bench -: -708 -ns -/ -iter -( -+ -/ -- -21 -) -test -bench -: -: -one_pass_short_a_not -. -. -. -bench -: -861 -ns -/ -iter -( -+ -/ -- -9 -) -test -bench -: -: -one_pass_short_b -. -. -. -bench -: -607 -ns -/ -iter -( -+ -/ -- -2 -) -test -bench -: -: -one_pass_short_b_not -. -. -. -bench -: -344 -ns -/ -iter -( -+ -/ -- -11 -) -test -bench -: -: -replace_all -. -. -. -bench -: -135 -ns -/ -iter -( -+ -/ -- -1 -) diff --git a/third_party/rust/regex/src/backtrack.rs b/third_party/rust/regex/src/backtrack.rs new file mode 100644 index 0000000000000..27c977c582411 --- /dev/null +++ b/third_party/rust/regex/src/backtrack.rs @@ -0,0 +1,2298 @@ +/ +/ +This +is +the +backtracking +matching +engine +. +It +has +the +same +exact +capability +/ +/ +as +the +full +NFA +simulation +except +it +is +artificially +restricted +to +small +/ +/ +regexes +on +small +inputs +because +of +its +memory +requirements +. +/ +/ +/ +/ +In +particular +this +is +a +* +bounded +* +backtracking +engine +. +It +retains +worst +/ +/ +case +linear +time +by +keeping +track +of +the +states +that +it +has +visited +( +using +a +/ +/ +bitmap +) +. +Namely +once +a +state +is +visited +it +is +never +visited +again +. +Since +a +/ +/ +state +is +keyed +by +( +instruction +index +input +index +) +we +have +that +its +time +/ +/ +complexity +is +O +( +mn +) +( +i +. +e +. +linear +in +the +size +of +the +search +text +) +. +/ +/ +/ +/ +The +backtracking +engine +can +beat +out +the +NFA +simulation +on +small +/ +/ +regexes +/ +inputs +because +it +doesn +' +t +have +to +keep +track +of +multiple +copies +of +/ +/ +the +capture +groups +. +In +benchmarks +the +backtracking +engine +is +roughly +twice +/ +/ +as +fast +as +the +full +NFA +simulation +. +Note +though +that +its +performance +doesn +' +t +/ +/ +scale +even +if +you +' +re +willing +to +live +with +the +memory +requirements +. +Namely +/ +/ +the +bitset +has +to +be +zeroed +on +each +execution +which +becomes +quite +expensive +/ +/ +on +large +bitsets +. +use +crate +: +: +exec +: +: +ProgramCache +; +use +crate +: +: +input +: +: +{ +Input +InputAt +} +; +use +crate +: +: +prog +: +: +{ +InstPtr +Program +} +; +use +crate +: +: +re_trait +: +: +Slot +; +type +Bits += +u32 +; +const +BIT_SIZE +: +usize += +32 +; +const +MAX_SIZE_BYTES +: +usize += +256 +* +( +1 +< +< +10 +) +; +/ +/ +256 +KB +/ +/ +/ +Returns +true +iff +the +given +regex +and +input +should +be +executed +by +this +/ +/ +/ +engine +with +reasonable +memory +usage +. +pub +fn +should_exec +( +num_insts +: +usize +text_len +: +usize +) +- +> +bool +{ +/ +/ +Total +memory +usage +in +bytes +is +determined +by +: +/ +/ +/ +/ +( +( +len +( +insts +) +* +( +len +( +input +) ++ +1 +) ++ +bits +- +1 +) +/ +bits +) +* +( +size_of +( +u32 +) +) +/ +/ +/ +/ +The +actual +limit +picked +is +pretty +much +a +heuristic +. +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +215 +let +size += +( +( +num_insts +* +( +text_len ++ +1 +) ++ +BIT_SIZE +- +1 +) +/ +BIT_SIZE +) +* +4 +; +size +< += +MAX_SIZE_BYTES +} +/ +/ +/ +A +backtracking +matching +engine +. +# +[ +derive +( +Debug +) +] +pub +struct +Bounded +< +' +a +' +m +' +r +' +s +I +> +{ +prog +: +& +' +r +Program +input +: +I +matches +: +& +' +m +mut +[ +bool +] +slots +: +& +' +s +mut +[ +Slot +] +m +: +& +' +a +mut +Cache +} +/ +/ +/ +Shared +cached +state +between +multiple +invocations +of +a +backtracking +engine +/ +/ +/ +in +the +same +thread +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +Cache +{ +jobs +: +Vec +< +Job +> +visited +: +Vec +< +Bits +> +} +impl +Cache +{ +/ +/ +/ +Create +new +empty +cache +for +the +backtracking +engine +. +pub +fn +new +( +_prog +: +& +Program +) +- +> +Self +{ +Cache +{ +jobs +: +vec +! +[ +] +visited +: +vec +! +[ +] +} +} +} +/ +/ +/ +A +job +is +an +explicit +unit +of +stack +space +in +the +backtracking +engine +. +/ +/ +/ +/ +/ +/ +The +" +normal +" +representation +is +a +single +state +transition +which +corresponds +/ +/ +/ +to +an +NFA +state +and +a +character +in +the +input +. +However +the +backtracking +/ +/ +/ +engine +must +keep +track +of +old +capture +group +values +. +We +use +the +explicit +/ +/ +/ +stack +to +do +it +. +# +[ +derive +( +Clone +Copy +Debug +) +] +enum +Job +{ +Inst +{ +ip +: +InstPtr +at +: +InputAt +} +SaveRestore +{ +slot +: +usize +old_pos +: +Option +< +usize +> +} +} +impl +< +' +a +' +m +' +r +' +s +I +: +Input +> +Bounded +< +' +a +' +m +' +r +' +s +I +> +{ +/ +/ +/ +Execute +the +backtracking +matching +engine +. +/ +/ +/ +/ +/ +/ +If +there +' +s +a +match +exec +returns +true +and +populates +the +given +/ +/ +/ +captures +accordingly +. +pub +fn +exec +( +prog +: +& +' +r +Program +cache +: +& +ProgramCache +matches +: +& +' +m +mut +[ +bool +] +slots +: +& +' +s +mut +[ +Slot +] +input +: +I +start +: +usize +end +: +usize +) +- +> +bool +{ +let +mut +cache += +cache +. +borrow_mut +( +) +; +let +cache += +& +mut +cache +. +backtrack +; +let +start += +input +. +at +( +start +) +; +let +mut +b += +Bounded +{ +prog +input +matches +slots +m +: +cache +} +; +b +. +exec_ +( +start +end +) +} +/ +/ +/ +Clears +the +cache +such +that +the +backtracking +engine +can +be +executed +/ +/ +/ +on +some +input +of +fixed +length +. +fn +clear +( +& +mut +self +) +{ +/ +/ +Reset +the +job +memory +so +that +we +start +fresh +. +self +. +m +. +jobs +. +clear +( +) +; +/ +/ +Now +we +need +to +clear +the +bit +state +set +. +/ +/ +We +do +this +by +figuring +out +how +much +space +we +need +to +keep +track +/ +/ +of +the +states +we +' +ve +visited +. +/ +/ +Then +we +reset +all +existing +allocated +space +to +0 +. +/ +/ +Finally +we +request +more +space +if +we +need +it +. +/ +/ +/ +/ +This +is +all +a +little +circuitous +but +doing +this +using +unchecked +/ +/ +operations +doesn +' +t +seem +to +have +a +measurable +impact +on +performance +. +/ +/ +( +Probably +because +backtracking +is +limited +to +such +small +/ +/ +inputs +/ +regexes +in +the +first +place +. +) +let +visited_len += +( +self +. +prog +. +len +( +) +* +( +self +. +input +. +len +( +) ++ +1 +) ++ +BIT_SIZE +- +1 +) +/ +BIT_SIZE +; +self +. +m +. +visited +. +truncate +( +visited_len +) +; +for +v +in +& +mut +self +. +m +. +visited +{ +* +v += +0 +; +} +if +visited_len +> +self +. +m +. +visited +. +len +( +) +{ +let +len += +self +. +m +. +visited +. +len +( +) +; +self +. +m +. +visited +. +reserve_exact +( +visited_len +- +len +) +; +for +_ +in +0 +. +. +( +visited_len +- +len +) +{ +self +. +m +. +visited +. +push +( +0 +) +; +} +} +} +/ +/ +/ +Start +backtracking +at +the +given +position +in +the +input +but +also +look +/ +/ +/ +for +literal +prefixes +. +fn +exec_ +( +& +mut +self +mut +at +: +InputAt +end +: +usize +) +- +> +bool +{ +self +. +clear +( +) +; +/ +/ +If +this +is +an +anchored +regex +at +the +beginning +of +the +input +then +/ +/ +we +' +re +either +already +done +or +we +only +need +to +try +backtracking +once +. +if +self +. +prog +. +is_anchored_start +{ +return +if +! +at +. +is_start +( +) +{ +false +} +else +{ +self +. +backtrack +( +at +) +} +; +} +let +mut +matched += +false +; +loop +{ +if +! +self +. +prog +. +prefixes +. +is_empty +( +) +{ +at += +match +self +. +input +. +prefix_at +( +& +self +. +prog +. +prefixes +at +) +{ +None += +> +break +Some +( +at +) += +> +at +} +; +} +matched += +self +. +backtrack +( +at +) +| +| +matched +; +if +matched +& +& +self +. +prog +. +matches +. +len +( +) += += +1 +{ +return +true +; +} +if +at +. +pos +( +) +> += +end +{ +break +; +} +at += +self +. +input +. +at +( +at +. +next_pos +( +) +) +; +} +matched +} +/ +/ +/ +The +main +backtracking +loop +starting +at +the +given +input +position +. +fn +backtrack +( +& +mut +self +start +: +InputAt +) +- +> +bool +{ +/ +/ +N +. +B +. +We +use +an +explicit +stack +to +avoid +recursion +. +/ +/ +To +avoid +excessive +pushing +and +popping +most +transitions +are +handled +/ +/ +in +the +step +helper +function +which +only +pushes +to +the +stack +when +/ +/ +there +' +s +a +capture +or +a +branch +. +let +mut +matched += +false +; +self +. +m +. +jobs +. +push +( +Job +: +: +Inst +{ +ip +: +0 +at +: +start +} +) +; +while +let +Some +( +job +) += +self +. +m +. +jobs +. +pop +( +) +{ +match +job +{ +Job +: +: +Inst +{ +ip +at +} += +> +{ +if +self +. +step +( +ip +at +) +{ +/ +/ +Only +quit +if +we +' +re +matching +one +regex +. +/ +/ +If +we +' +re +matching +a +regex +set +then +mush +on +and +/ +/ +try +to +find +other +matches +( +if +we +want +them +) +. +if +self +. +prog +. +matches +. +len +( +) += += +1 +{ +return +true +; +} +matched += +true +; +} +} +Job +: +: +SaveRestore +{ +slot +old_pos +} += +> +{ +if +slot +< +self +. +slots +. +len +( +) +{ +self +. +slots +[ +slot +] += +old_pos +; +} +} +} +} +matched +} +fn +step +( +& +mut +self +mut +ip +: +InstPtr +mut +at +: +InputAt +) +- +> +bool +{ +use +crate +: +: +prog +: +: +Inst +: +: +* +; +loop +{ +/ +/ +This +loop +is +an +optimization +to +avoid +constantly +pushing +/ +popping +/ +/ +from +the +stack +. +Namely +if +we +' +re +pushing +a +job +only +to +run +it +/ +/ +next +avoid +the +push +and +just +mutate +ip +( +and +possibly +at +) +/ +/ +in +place +. +if +self +. +has_visited +( +ip +at +) +{ +return +false +; +} +match +self +. +prog +[ +ip +] +{ +Match +( +slot +) += +> +{ +if +slot +< +self +. +matches +. +len +( +) +{ +self +. +matches +[ +slot +] += +true +; +} +return +true +; +} +Save +( +ref +inst +) += +> +{ +if +let +Some +( +& +old_pos +) += +self +. +slots +. +get +( +inst +. +slot +) +{ +/ +/ +If +this +path +doesn +' +t +work +out +then +we +save +the +old +/ +/ +capture +index +( +if +one +exists +) +in +an +alternate +/ +/ +job +. +If +the +next +path +fails +then +the +alternate +/ +/ +job +is +popped +and +the +old +capture +index +is +restored +. +self +. +m +. +jobs +. +push +( +Job +: +: +SaveRestore +{ +slot +: +inst +. +slot +old_pos +} +) +; +self +. +slots +[ +inst +. +slot +] += +Some +( +at +. +pos +( +) +) +; +} +ip += +inst +. +goto +; +} +Split +( +ref +inst +) += +> +{ +self +. +m +. +jobs +. +push +( +Job +: +: +Inst +{ +ip +: +inst +. +goto2 +at +} +) +; +ip += +inst +. +goto1 +; +} +EmptyLook +( +ref +inst +) += +> +{ +if +self +. +input +. +is_empty_match +( +at +inst +) +{ +ip += +inst +. +goto +; +} +else +{ +return +false +; +} +} +Char +( +ref +inst +) += +> +{ +if +inst +. +c += += +at +. +char +( +) +{ +ip += +inst +. +goto +; +at += +self +. +input +. +at +( +at +. +next_pos +( +) +) +; +} +else +{ +return +false +; +} +} +Ranges +( +ref +inst +) += +> +{ +if +inst +. +matches +( +at +. +char +( +) +) +{ +ip += +inst +. +goto +; +at += +self +. +input +. +at +( +at +. +next_pos +( +) +) +; +} +else +{ +return +false +; +} +} +Bytes +( +ref +inst +) += +> +{ +if +let +Some +( +b +) += +at +. +byte +( +) +{ +if +inst +. +matches +( +b +) +{ +ip += +inst +. +goto +; +at += +self +. +input +. +at +( +at +. +next_pos +( +) +) +; +continue +; +} +} +return +false +; +} +} +} +} +fn +has_visited +( +& +mut +self +ip +: +InstPtr +at +: +InputAt +) +- +> +bool +{ +let +k += +ip +* +( +self +. +input +. +len +( +) ++ +1 +) ++ +at +. +pos +( +) +; +let +k1 += +k +/ +BIT_SIZE +; +let +k2 += +usize_to_u32 +( +1 +< +< +( +k +& +( +BIT_SIZE +- +1 +) +) +) +; +if +self +. +m +. +visited +[ +k1 +] +& +k2 += += +0 +{ +self +. +m +. +visited +[ +k1 +] +| += +k2 +; +false +} +else +{ +true +} +} +} +fn +usize_to_u32 +( +n +: +usize +) +- +> +u32 +{ +if +( +n +as +u64 +) +> +( +: +: +std +: +: +u32 +: +: +MAX +as +u64 +) +{ +panic +! +( +" +BUG +: +{ +} +is +too +big +to +fit +into +u32 +" +n +) +} +n +as +u32 +} diff --git a/third_party/rust/regex/src/builders.rs b/third_party/rust/regex/src/builders.rs deleted file mode 100644 index 77f477925b3db..0000000000000 --- a/third_party/rust/regex/src/builders.rs +++ /dev/null @@ -1,25034 +0,0 @@ -# -! -[ -allow -( -warnings -) -] -/ -/ -This -module -defines -an -internal -builder -that -encapsulates -all -interaction -/ -/ -with -meta -: -: -Regex -construction -and -then -4 -public -API -builders -that -wrap -/ -/ -around -it -. -The -docs -are -essentially -repeated -on -each -of -the -4 -public -/ -/ -builders -with -tweaks -to -the -examples -as -needed -. -/ -/ -/ -/ -The -reason -why -there -are -so -many -builders -is -partially -because -of -a -misstep -/ -/ -in -the -initial -API -design -: -the -builder -constructor -takes -in -the -pattern -/ -/ -strings -instead -of -using -the -build -method -to -accept -the -pattern -strings -. -/ -/ -This -means -new -has -a -different -signature -for -each -builder -. -It -probably -/ -/ -would -have -been -nicer -to -to -use -one -builder -with -fn -new -( -) -and -then -add -/ -/ -build -( -pat -) -and -build_many -( -pats -) -constructors -. -/ -/ -/ -/ -The -other -reason -is -because -I -think -the -bytes -module -should -probably -/ -/ -have -its -own -builder -type -. -That -way -it -is -completely -isolated -from -the -/ -/ -top -- -level -API -. -/ -/ -/ -/ -If -I -could -do -it -again -I -' -d -probably -have -a -regex -: -: -Builder -and -a -/ -/ -regex -: -: -bytes -: -: -Builder -. -Each -would -have -build -and -build_set -( -or -/ -/ -build_many -) -methods -for -constructing -a -single -pattern -Regex -and -a -/ -/ -multi -- -pattern -RegexSet -respectively -. -use -alloc -: -: -{ -string -: -: -{ -String -ToString -} -sync -: -: -Arc -vec -vec -: -: -Vec -} -; -use -regex_automata -: -: -{ -meta -nfa -: -: -thompson -: -: -WhichCaptures -util -: -: -syntax -MatchKind -} -; -use -crate -: -: -error -: -: -Error -; -/ -/ -/ -A -builder -for -constructing -a -Regex -bytes -: -: -Regex -RegexSet -or -a -/ -/ -/ -bytes -: -: -RegexSet -. -/ -/ -/ -/ -/ -/ -This -is -essentially -the -implementation -of -the -four -different -builder -types -/ -/ -/ -in -the -public -API -: -RegexBuilder -bytes -: -: -RegexBuilder -RegexSetBuilder -/ -/ -/ -and -bytes -: -: -RegexSetBuilder -. -# -[ -derive -( -Clone -Debug -) -] -struct -Builder -{ -pats -: -Vec -< -String -> -metac -: -meta -: -: -Config -syntaxc -: -syntax -: -: -Config -} -impl -Default -for -Builder -{ -fn -default -( -) -- -> -Builder -{ -let -metac -= -meta -: -: -Config -: -: -new -( -) -. -nfa_size_limit -( -Some -( -10 -* -( -1 -< -< -20 -) -) -) -. -hybrid_cache_capacity -( -2 -* -( -1 -< -< -20 -) -) -; -Builder -{ -pats -: -vec -! -[ -] -metac -syntaxc -: -syntax -: -: -Config -: -: -default -( -) -} -} -} -impl -Builder -{ -fn -new -< -I -S -> -( -patterns -: -I -) -- -> -Builder -where -S -: -AsRef -< -str -> -I -: -IntoIterator -< -Item -= -S -> -{ -let -mut -b -= -Builder -: -: -default -( -) -; -b -. -pats -. -extend -( -patterns -. -into_iter -( -) -. -map -( -| -p -| -p -. -as_ref -( -) -. -to_string -( -) -) -) -; -b -} -fn -build_one_string -( -& -self -) -- -> -Result -< -crate -: -: -Regex -Error -> -{ -assert_eq -! -( -1 -self -. -pats -. -len -( -) -) -; -let -metac -= -self -. -metac -. -clone -( -) -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -. -utf8_empty -( -true -) -; -let -syntaxc -= -self -. -syntaxc -. -clone -( -) -. -utf8 -( -true -) -; -let -pattern -= -Arc -: -: -from -( -self -. -pats -[ -0 -] -. -as_str -( -) -) -; -meta -: -: -Builder -: -: -new -( -) -. -configure -( -metac -) -. -syntax -( -syntaxc -) -. -build -( -& -pattern -) -. -map -( -| -meta -| -crate -: -: -Regex -{ -meta -pattern -} -) -. -map_err -( -Error -: -: -from_meta_build_error -) -} -fn -build_one_bytes -( -& -self -) -- -> -Result -< -crate -: -: -bytes -: -: -Regex -Error -> -{ -assert_eq -! -( -1 -self -. -pats -. -len -( -) -) -; -let -metac -= -self -. -metac -. -clone -( -) -. -match_kind -( -MatchKind -: -: -LeftmostFirst -) -. -utf8_empty -( -false -) -; -let -syntaxc -= -self -. -syntaxc -. -clone -( -) -. -utf8 -( -false -) -; -let -pattern -= -Arc -: -: -from -( -self -. -pats -[ -0 -] -. -as_str -( -) -) -; -meta -: -: -Builder -: -: -new -( -) -. -configure -( -metac -) -. -syntax -( -syntaxc -) -. -build -( -& -pattern -) -. -map -( -| -meta -| -crate -: -: -bytes -: -: -Regex -{ -meta -pattern -} -) -. -map_err -( -Error -: -: -from_meta_build_error -) -} -fn -build_many_string -( -& -self -) -- -> -Result -< -crate -: -: -RegexSet -Error -> -{ -let -metac -= -self -. -metac -. -clone -( -) -. -match_kind -( -MatchKind -: -: -All -) -. -utf8_empty -( -true -) -. -which_captures -( -WhichCaptures -: -: -None -) -; -let -syntaxc -= -self -. -syntaxc -. -clone -( -) -. -utf8 -( -true -) -; -let -patterns -= -Arc -: -: -from -( -self -. -pats -. -as_slice -( -) -) -; -meta -: -: -Builder -: -: -new -( -) -. -configure -( -metac -) -. -syntax -( -syntaxc -) -. -build_many -( -& -patterns -) -. -map -( -| -meta -| -crate -: -: -RegexSet -{ -meta -patterns -} -) -. -map_err -( -Error -: -: -from_meta_build_error -) -} -fn -build_many_bytes -( -& -self -) -- -> -Result -< -crate -: -: -bytes -: -: -RegexSet -Error -> -{ -let -metac -= -self -. -metac -. -clone -( -) -. -match_kind -( -MatchKind -: -: -All -) -. -utf8_empty -( -false -) -. -which_captures -( -WhichCaptures -: -: -None -) -; -let -syntaxc -= -self -. -syntaxc -. -clone -( -) -. -utf8 -( -false -) -; -let -patterns -= -Arc -: -: -from -( -self -. -pats -. -as_slice -( -) -) -; -meta -: -: -Builder -: -: -new -( -) -. -configure -( -metac -) -. -syntax -( -syntaxc -) -. -build_many -( -& -patterns -) -. -map -( -| -meta -| -crate -: -: -bytes -: -: -RegexSet -{ -meta -patterns -} -) -. -map_err -( -Error -: -: -from_meta_build_error -) -} -fn -case_insensitive -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -case_insensitive -( -yes -) -; -self -} -fn -multi_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -multi_line -( -yes -) -; -self -} -fn -dot_matches_new_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -dot_matches_new_line -( -yes -) -; -self -} -fn -crlf -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -crlf -( -yes -) -; -self -} -fn -line_terminator -( -& -mut -self -byte -: -u8 -) -- -> -& -mut -Builder -{ -self -. -metac -= -self -. -metac -. -clone -( -) -. -line_terminator -( -byte -) -; -self -. -syntaxc -= -self -. -syntaxc -. -line_terminator -( -byte -) -; -self -} -fn -swap_greed -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -swap_greed -( -yes -) -; -self -} -fn -ignore_whitespace -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -ignore_whitespace -( -yes -) -; -self -} -fn -unicode -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -unicode -( -yes -) -; -self -} -fn -octal -( -& -mut -self -yes -: -bool -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -octal -( -yes -) -; -self -} -fn -size_limit -( -& -mut -self -limit -: -usize -) -- -> -& -mut -Builder -{ -self -. -metac -= -self -. -metac -. -clone -( -) -. -nfa_size_limit -( -Some -( -limit -) -) -; -self -} -fn -dfa_size_limit -( -& -mut -self -limit -: -usize -) -- -> -& -mut -Builder -{ -self -. -metac -= -self -. -metac -. -clone -( -) -. -hybrid_cache_capacity -( -limit -) -; -self -} -fn -nest_limit -( -& -mut -self -limit -: -u32 -) -- -> -& -mut -Builder -{ -self -. -syntaxc -= -self -. -syntaxc -. -nest_limit -( -limit -) -; -self -} -} -pub -( -crate -) -mod -string -{ -use -crate -: -: -{ -error -: -: -Error -Regex -RegexSet -} -; -use -super -: -: -Builder -; -/ -/ -/ -A -configurable -builder -for -a -[ -Regex -] -. -/ -/ -/ -/ -/ -/ -This -builder -can -be -used -to -programmatically -set -flags -such -as -i -/ -/ -/ -( -case -insensitive -) -and -x -( -for -verbose -mode -) -. -This -builder -can -also -be -/ -/ -/ -used -to -configure -things -like -the -line -terminator -and -a -size -limit -on -/ -/ -/ -the -compiled -regular -expression -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -RegexBuilder -{ -builder -: -Builder -} -impl -RegexBuilder -{ -/ -/ -/ -Create -a -new -builder -with -a -default -configuration -for -the -given -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -If -the -pattern -is -invalid -or -exceeds -the -configured -size -limits -/ -/ -/ -then -an -error -will -be -returned -when -[ -RegexBuilder -: -: -build -] -is -/ -/ -/ -called -. -pub -fn -new -( -pattern -: -& -str -) -- -> -RegexBuilder -{ -RegexBuilder -{ -builder -: -Builder -: -: -new -( -[ -pattern -] -) -} -} -/ -/ -/ -Compiles -the -pattern -given -to -RegexBuilder -: -: -new -with -the -/ -/ -/ -configuration -set -on -this -builder -. -/ -/ -/ -/ -/ -/ -If -the -pattern -isn -' -t -a -valid -regex -or -if -a -configured -size -limit -/ -/ -/ -was -exceeded -then -an -error -is -returned -. -pub -fn -build -( -& -self -) -- -> -Result -< -Regex -Error -> -{ -self -. -builder -. -build_one_string -( -) -} -/ -/ -/ -This -configures -Unicode -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Enabling -Unicode -mode -does -a -number -of -things -: -/ -/ -/ -/ -/ -/ -* -Most -fundamentally -it -causes -the -fundamental -atom -of -matching -/ -/ -/ -to -be -a -single -codepoint -. -When -Unicode -mode -is -disabled -it -' -s -a -/ -/ -/ -single -byte -. -For -example -when -Unicode -mode -is -enabled -. -will -/ -/ -/ -match -once -where -as -it -will -match -4 -times -when -Unicode -mode -/ -/ -/ -is -disabled -. -( -Since -the -UTF -- -8 -encoding -of -is -4 -bytes -long -. -) -/ -/ -/ -* -Case -insensitive -matching -uses -Unicode -simple -case -folding -rules -. -/ -/ -/ -* -Unicode -character -classes -like -\ -p -{ -Letter -} -and -\ -p -{ -Greek -} -are -/ -/ -/ -available -. -/ -/ -/ -* -Perl -character -classes -are -Unicode -aware -. -That -is -\ -w -\ -s -and -/ -/ -/ -\ -d -. -/ -/ -/ -* -The -word -boundary -assertions -\ -b -and -\ -B -use -the -Unicode -/ -/ -/ -definition -of -a -word -character -. -/ -/ -/ -/ -/ -/ -Note -that -if -Unicode -mode -is -disabled -then -the -regex -will -fail -to -/ -/ -/ -compile -if -it -could -match -invalid -UTF -- -8 -. -For -example -when -Unicode -/ -/ -/ -mode -is -disabled -then -since -. -matches -any -byte -( -except -for -/ -/ -/ -\ -n -) -then -it -can -match -invalid -UTF -- -8 -and -thus -building -a -regex -/ -/ -/ -from -it -will -fail -. -Another -example -is -\ -w -and -\ -W -. -Since -\ -w -can -/ -/ -/ -only -match -ASCII -bytes -when -Unicode -mode -is -disabled -it -' -s -allowed -. -/ -/ -/ -But -\ -W -can -match -more -than -ASCII -bytes -including -invalid -UTF -- -8 -/ -/ -/ -and -so -it -is -not -allowed -. -This -restriction -can -be -lifted -only -by -/ -/ -/ -using -a -[ -bytes -: -: -Regex -] -( -crate -: -: -bytes -: -: -Regex -) -. -/ -/ -/ -/ -/ -/ -For -more -details -on -the -Unicode -support -in -this -crate -see -the -/ -/ -/ -[ -Unicode -section -] -( -crate -# -unicode -) -in -this -crate -' -s -top -- -level -/ -/ -/ -documentation -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -true -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -\ -w -" -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -greek -letters -would -be -included -in -\ -w -but -since -/ -/ -/ -/ -/ -Unicode -mode -is -disabled -it -only -matches -ASCII -letters -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -" -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -s -" -) -/ -/ -/ -. -case_insensitive -( -true -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -' -' -is -included -when -searching -for -' -s -' -case -/ -/ -/ -/ -/ -insensitively -due -to -Unicode -' -s -simple -case -folding -rules -. -But -/ -/ -/ -/ -/ -when -Unicode -mode -is -disabled -only -ASCII -case -insensitive -rules -/ -/ -/ -/ -/ -are -used -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -" -) -) -; -/ -/ -/ -pub -fn -unicode -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -unicode -( -yes -) -; -self -} -/ -/ -/ -This -configures -whether -to -enable -case -insensitive -matching -for -the -/ -/ -/ -entire -pattern -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -i -/ -/ -/ -in -the -pattern -. -For -example -( -? -i -: -foo -) -matches -foo -case -/ -/ -/ -insensitively -while -( -? -- -i -: -foo -) -matches -foo -case -sensitively -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -foo -( -? -- -i -: -bar -) -quux -" -) -/ -/ -/ -. -case_insensitive -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -FoObarQuUx -" -) -) -; -/ -/ -/ -/ -/ -Even -though -case -insensitive -matching -is -enabled -in -the -builder -/ -/ -/ -/ -/ -it -can -be -locally -disabled -within -the -pattern -. -In -this -case -/ -/ -/ -/ -/ -bar -is -matched -case -sensitively -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -fooBARquux -" -) -) -; -/ -/ -/ -pub -fn -case_insensitive -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -case_insensitive -( -yes -) -; -self -} -/ -/ -/ -This -configures -multi -- -line -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Enabling -multi -- -line -mode -changes -the -behavior -of -the -^ -and -/ -/ -/ -anchor -assertions -. -Instead -of -only -matching -at -the -beginning -and -/ -/ -/ -end -of -a -haystack -respectively -multi -- -line -mode -causes -them -to -/ -/ -/ -match -at -the -beginning -and -end -of -a -line -* -in -addition -* -to -the -/ -/ -/ -beginning -and -end -of -a -haystack -. -More -precisely -^ -will -match -at -/ -/ -/ -the -position -immediately -following -a -\ -n -and -will -match -at -the -/ -/ -/ -position -immediately -preceding -a -\ -n -. -/ -/ -/ -/ -/ -/ -The -behavior -of -this -option -can -be -impacted -by -other -settings -too -: -/ -/ -/ -/ -/ -/ -* -The -[ -RegexBuilder -: -: -line_terminator -] -option -changes -\ -n -above -/ -/ -/ -to -any -ASCII -byte -. -/ -/ -/ -* -The -[ -RegexBuilder -: -: -crlf -] -option -changes -the -line -terminator -to -/ -/ -/ -be -either -\ -r -or -\ -n -but -never -at -the -position -between -a -\ -r -/ -/ -/ -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -m -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -^ -foo -" -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -. -. -4 -) -re -. -find -( -" -\ -nfoo -\ -n -" -) -. -map -( -| -m -| -m -. -range -( -) -) -) -; -/ -/ -/ -pub -fn -multi_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -multi_line -( -yes -) -; -self -} -/ -/ -/ -This -configures -dot -- -matches -- -new -- -line -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Perhaps -surprisingly -the -default -behavior -for -. -is -not -to -match -/ -/ -/ -any -character -but -rather -to -match -any -character -except -for -the -/ -/ -/ -line -terminator -( -which -is -\ -n -by -default -) -. -When -this -mode -is -/ -/ -/ -enabled -the -behavior -changes -such -that -. -truly -matches -any -/ -/ -/ -character -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -s -in -/ -/ -/ -the -pattern -. -For -example -( -? -s -: -. -) -and -\ -p -{ -any -} -are -equivalent -/ -/ -/ -regexes -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -foo -. -bar -" -) -/ -/ -/ -. -dot_matches_new_line -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -foo -\ -nbar -" -; -/ -/ -/ -assert_eq -! -( -Some -( -" -foo -\ -nbar -" -) -re -. -find -( -hay -) -. -map -( -| -m -| -m -. -as_str -( -) -) -) -; -/ -/ -/ -pub -fn -dot_matches_new_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -dot_matches_new_line -( -yes -) -; -self -} -/ -/ -/ -This -configures -CRLF -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -When -CRLF -mode -is -enabled -both -\ -r -( -" -carriage -return -" -or -CR -for -/ -/ -/ -short -) -and -\ -n -( -" -line -feed -" -or -LF -for -short -) -are -treated -as -line -/ -/ -/ -terminators -. -This -results -in -the -following -: -/ -/ -/ -/ -/ -/ -* -Unless -dot -- -matches -- -new -- -line -mode -is -enabled -. -will -now -match -/ -/ -/ -any -character -except -for -\ -n -and -\ -r -. -/ -/ -/ -* -When -multi -- -line -mode -is -enabled -^ -will -match -immediately -/ -/ -/ -following -a -\ -n -or -a -\ -r -. -Similarly -will -match -immediately -/ -/ -/ -preceding -a -\ -n -or -a -\ -r -. -Neither -^ -nor -will -ever -match -/ -/ -/ -between -\ -r -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -R -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -^ -foo -" -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -crlf -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -\ -r -\ -nfoo -\ -r -\ -n -" -; -/ -/ -/ -/ -/ -If -CRLF -mode -weren -' -t -enabled -here -then -' -' -wouldn -' -t -match -/ -/ -/ -/ -/ -immediately -after -' -foo -' -and -thus -no -match -would -be -found -. -/ -/ -/ -assert_eq -! -( -Some -( -" -foo -" -) -re -. -find -( -hay -) -. -map -( -| -m -| -m -. -as_str -( -) -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -demonstrates -that -^ -will -never -match -at -a -position -/ -/ -/ -between -\ -r -and -\ -n -. -( -will -similarly -not -match -between -a -\ -r -/ -/ -/ -and -a -\ -n -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -^ -" -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -crlf -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -\ -r -\ -n -\ -r -\ -n -" -; -/ -/ -/ -let -ranges -: -Vec -< -_ -> -= -re -. -find_iter -( -hay -) -. -map -( -| -m -| -m -. -range -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -ranges -vec -! -[ -0 -. -. -0 -2 -. -. -2 -4 -. -. -4 -] -) -; -/ -/ -/ -pub -fn -crlf -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -crlf -( -yes -) -; -self -} -/ -/ -/ -Configures -the -line -terminator -to -be -used -by -the -regex -. -/ -/ -/ -/ -/ -/ -The -line -terminator -is -relevant -in -two -ways -for -a -particular -regex -: -/ -/ -/ -/ -/ -/ -* -When -dot -- -matches -- -new -- -line -mode -is -* -not -* -enabled -( -the -default -) -/ -/ -/ -then -. -will -match -any -character -except -for -the -configured -line -/ -/ -/ -terminator -. -/ -/ -/ -* -When -multi -- -line -mode -is -enabled -( -not -the -default -) -then -^ -and -/ -/ -/ -will -match -immediately -after -and -before -respectively -a -line -/ -/ -/ -terminator -. -/ -/ -/ -/ -/ -/ -In -both -cases -if -CRLF -mode -is -enabled -in -a -particular -context -/ -/ -/ -then -it -takes -precedence -over -any -configured -line -terminator -. -/ -/ -/ -/ -/ -/ -This -option -cannot -be -configured -from -within -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -line -terminator -is -\ -n -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -treat -the -NUL -byte -as -a -line -terminator -. -This -can -/ -/ -/ -be -a -useful -heuristic -when -searching -binary -data -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -^ -foo -" -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -line_terminator -( -b -' -\ -x00 -' -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -\ -x00foo -\ -x00 -" -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -. -. -4 -) -re -. -find -( -hay -) -. -map -( -| -m -| -m -. -range -( -) -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -behavior -of -. -is -impacted -by -this -/ -/ -/ -setting -as -well -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -. -" -) -/ -/ -/ -. -line_terminator -( -b -' -\ -x00 -' -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -\ -n -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -\ -x00 -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -shows -that -building -a -regex -will -fail -if -the -byte -given -/ -/ -/ -is -not -ASCII -and -the -pattern -could -result -in -matching -invalid -/ -/ -/ -UTF -- -8 -. -This -is -because -any -singular -non -- -ASCII -byte -is -not -valid -/ -/ -/ -UTF -- -8 -and -it -is -not -permitted -for -a -[ -Regex -] -to -match -invalid -/ -/ -/ -UTF -- -8 -. -( -It -is -permissible -to -use -a -non -- -ASCII -byte -when -building -a -/ -/ -/ -[ -bytes -: -: -Regex -] -( -crate -: -: -bytes -: -: -Regex -) -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -assert -! -( -RegexBuilder -: -: -new -( -r -" -. -" -) -. -line_terminator -( -0x80 -) -. -build -( -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -Note -that -using -a -non -- -ASCII -byte -isn -' -t -enough -on -its -own -to -/ -/ -/ -/ -/ -cause -regex -compilation -to -fail -. -You -actually -have -to -make -use -/ -/ -/ -/ -/ -of -it -in -the -regex -in -a -way -that -leads -to -matching -invalid -/ -/ -/ -/ -/ -UTF -- -8 -. -If -you -don -' -t -then -regex -compilation -will -succeed -! -/ -/ -/ -assert -! -( -RegexBuilder -: -: -new -( -r -" -a -" -) -. -line_terminator -( -0x80 -) -. -build -( -) -. -is_ok -( -) -) -; -/ -/ -/ -pub -fn -line_terminator -( -& -mut -self -byte -: -u8 -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -line_terminator -( -byte -) -; -self -} -/ -/ -/ -This -configures -swap -- -greed -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -When -swap -- -greed -mode -is -enabled -patterns -like -a -+ -will -become -/ -/ -/ -non -- -greedy -and -patterns -like -a -+ -? -will -become -greedy -. -In -other -/ -/ -/ -words -the -meanings -of -a -+ -and -a -+ -? -are -switched -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -U -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -a -+ -" -) -/ -/ -/ -. -swap_greed -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -" -a -" -) -re -. -find -( -" -aaa -" -) -. -map -( -| -m -| -m -. -as_str -( -) -) -) -; -/ -/ -/ -pub -fn -swap_greed -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -swap_greed -( -yes -) -; -self -} -/ -/ -/ -This -configures -verbose -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -When -enabled -whitespace -will -treated -as -insignifcant -in -the -/ -/ -/ -pattern -and -# -can -be -used -to -start -a -comment -until -the -next -new -/ -/ -/ -line -. -/ -/ -/ -/ -/ -/ -Normally -in -most -places -in -a -pattern -whitespace -is -treated -/ -/ -/ -literally -. -For -example -+ -will -match -one -or -more -ASCII -whitespace -/ -/ -/ -characters -. -/ -/ -/ -/ -/ -/ -When -verbose -mode -is -enabled -\ -# -can -be -used -to -match -a -literal -/ -/ -/ -# -and -\ -can -be -used -to -match -a -literal -ASCII -whitespace -/ -/ -/ -character -. -/ -/ -/ -/ -/ -/ -Verbose -mode -is -useful -for -permitting -regexes -to -be -formatted -and -/ -/ -/ -broken -up -more -nicely -. -This -may -make -them -more -easily -readable -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -x -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -pat -= -r -" -/ -/ -/ -\ -b -/ -/ -/ -( -? -< -first -> -\ -p -{ -Uppercase -} -\ -w -* -) -# -always -start -with -uppercase -letter -/ -/ -/ -[ -\ -s -- -- -\ -n -] -+ -# -whitespace -should -separate -names -/ -/ -/ -( -? -: -# -middle -name -can -be -an -initial -! -/ -/ -/ -( -? -: -( -? -< -initial -> -\ -p -{ -Uppercase -} -) -\ -. -| -( -? -< -middle -> -\ -p -{ -Uppercase -} -\ -w -* -) -) -/ -/ -/ -[ -\ -s -- -- -\ -n -] -+ -/ -/ -/ -) -? -/ -/ -/ -( -? -< -last -> -\ -p -{ -Uppercase -} -\ -w -* -) -/ -/ -/ -\ -b -/ -/ -/ -" -; -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -pat -) -/ -/ -/ -. -ignore_whitespace -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -re -. -captures -( -" -Harry -Potter -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -" -Harry -" -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -assert_eq -! -( -" -Potter -" -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -re -. -captures -( -" -Harry -J -. -Potter -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -" -Harry -" -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -/ -/ -Since -a -middle -name -/ -initial -isn -' -t -required -for -an -overall -match -/ -/ -/ -/ -/ -we -can -' -t -assume -that -' -initial -' -or -' -middle -' -will -be -populated -! -/ -/ -/ -assert_eq -! -( -Some -( -" -J -" -) -caps -. -name -( -" -initial -" -) -. -map -( -| -m -| -m -. -as_str -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -name -( -" -middle -" -) -. -map -( -| -m -| -m -. -as_str -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -" -Potter -" -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -re -. -captures -( -" -Harry -James -Potter -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -" -Harry -" -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -/ -/ -Since -a -middle -name -/ -initial -isn -' -t -required -for -an -overall -match -/ -/ -/ -/ -/ -we -can -' -t -assume -that -' -initial -' -or -' -middle -' -will -be -populated -! -/ -/ -/ -assert_eq -! -( -None -caps -. -name -( -" -initial -" -) -. -map -( -| -m -| -m -. -as_str -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -" -James -" -) -caps -. -name -( -" -middle -" -) -. -map -( -| -m -| -m -. -as_str -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -" -Potter -" -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -pub -fn -ignore_whitespace -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -ignore_whitespace -( -yes -) -; -self -} -/ -/ -/ -This -configures -octal -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Octal -syntax -is -a -little -- -known -way -of -uttering -Unicode -codepoints -/ -/ -/ -in -a -pattern -. -For -example -a -\ -x61 -\ -u0061 -and -\ -141 -are -all -/ -/ -/ -equivalent -patterns -where -the -last -example -shows -octal -syntax -. -/ -/ -/ -/ -/ -/ -While -supporting -octal -syntax -isn -' -t -in -and -of -itself -a -problem -/ -/ -/ -it -does -make -good -error -messages -harder -. -That -is -in -PCRE -based -/ -/ -/ -regex -engines -syntax -like -\ -1 -invokes -a -backreference -which -is -/ -/ -/ -explicitly -unsupported -this -library -. -However -many -users -expect -/ -/ -/ -backreferences -to -be -supported -. -Therefore -when -octal -support -/ -/ -/ -is -disabled -the -error -message -will -explicitly -mention -that -/ -/ -/ -backreferences -aren -' -t -supported -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -/ -/ -Normally -this -pattern -would -not -compile -with -an -error -message -/ -/ -/ -/ -/ -about -backreferences -not -being -supported -. -But -with -octal -mode -/ -/ -/ -/ -/ -enabled -octal -escape -sequences -work -. -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -\ -141 -" -) -/ -/ -/ -. -octal -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -a -" -) -) -; -/ -/ -/ -pub -fn -octal -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -octal -( -yes -) -; -self -} -/ -/ -/ -Sets -the -approximate -size -limit -in -bytes -of -the -compiled -regex -. -/ -/ -/ -/ -/ -/ -This -roughly -corresponds -to -the -number -of -heap -memory -in -/ -/ -/ -bytes -occupied -by -a -single -regex -. -If -the -regex -would -otherwise -/ -/ -/ -approximately -exceed -this -limit -then -compiling -that -regex -will -/ -/ -/ -fail -. -/ -/ -/ -/ -/ -/ -The -main -utility -of -a -method -like -this -is -to -avoid -compiling -/ -/ -/ -regexes -that -use -an -unexpected -amount -of -resources -such -as -/ -/ -/ -time -and -memory -. -Even -if -the -memory -usage -of -a -large -regex -is -/ -/ -/ -acceptable -its -search -time -may -not -be -. -Namely -worst -case -time -/ -/ -/ -complexity -for -search -is -O -( -m -* -n -) -where -m -~ -len -( -pattern -) -and -/ -/ -/ -n -~ -len -( -haystack -) -. -That -is -search -time -depends -in -part -on -the -/ -/ -/ -size -of -the -compiled -regex -. -This -means -that -putting -a -limit -on -the -/ -/ -/ -size -of -the -regex -limits -how -much -a -regex -can -impact -search -time -. -/ -/ -/ -/ -/ -/ -For -more -information -about -regex -size -limits -see -the -section -on -/ -/ -/ -[ -untrusted -inputs -] -( -crate -# -untrusted -- -input -) -in -the -top -- -level -crate -/ -/ -/ -documentation -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -some -reasonable -number -that -permits -most -/ -/ -/ -patterns -to -compile -successfully -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -/ -/ -It -may -surprise -you -how -big -some -seemingly -small -patterns -can -/ -/ -/ -/ -/ -be -! -Since -\ -w -is -Unicode -aware -this -generates -a -regex -that -can -/ -/ -/ -/ -/ -match -approximately -140 -000 -distinct -codepoints -. -/ -/ -/ -assert -! -( -RegexBuilder -: -: -new -( -r -" -\ -w -" -) -. -size_limit -( -45_000 -) -. -build -( -) -. -is_err -( -) -) -; -/ -/ -/ -pub -fn -size_limit -( -& -mut -self -bytes -: -usize -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -size_limit -( -bytes -) -; -self -} -/ -/ -/ -Set -the -approximate -capacity -in -bytes -of -the -cache -of -transitions -/ -/ -/ -used -by -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -While -the -lazy -DFA -isn -' -t -always -used -in -tends -to -be -the -most -/ -/ -/ -commonly -use -regex -engine -in -default -configurations -. -It -tends -to -/ -/ -/ -adopt -the -performance -profile -of -a -fully -build -DFA -but -without -the -/ -/ -/ -downside -of -taking -worst -case -exponential -time -to -build -. -/ -/ -/ -/ -/ -/ -The -downside -is -that -it -needs -to -keep -a -cache -of -transitions -and -/ -/ -/ -states -that -are -built -while -running -a -search -and -this -cache -/ -/ -/ -can -fill -up -. -When -it -fills -up -the -cache -will -reset -itself -. -Any -/ -/ -/ -previously -generated -states -and -transitions -will -then -need -to -be -/ -/ -/ -re -- -generated -. -If -this -happens -too -many -times -then -this -library -/ -/ -/ -will -bail -out -of -using -the -lazy -DFA -and -switch -to -a -different -regex -/ -/ -/ -engine -. -/ -/ -/ -/ -/ -/ -If -your -regex -provokes -this -particular -downside -of -the -lazy -DFA -/ -/ -/ -then -it -may -be -beneficial -to -increase -its -cache -capacity -. -This -will -/ -/ -/ -potentially -reduce -the -frequency -of -cache -resetting -( -ideally -to -/ -/ -/ -0 -) -. -While -it -won -' -t -fix -all -potential -performance -problems -with -/ -/ -/ -the -lazy -DFA -increasing -the -cache -capacity -does -fix -some -. -/ -/ -/ -/ -/ -/ -There -is -no -easy -way -to -determine -a -priori -whether -increasing -/ -/ -/ -this -cache -capacity -will -help -. -In -general -the -larger -your -regex -/ -/ -/ -the -more -cache -it -' -s -likely -to -use -. -But -that -isn -' -t -an -ironclad -rule -. -/ -/ -/ -For -example -a -regex -like -[ -01 -] -* -1 -[ -01 -] -{ -N -} -would -normally -produce -a -/ -/ -/ -fully -build -DFA -that -is -exponential -in -size -with -respect -to -N -. -/ -/ -/ -The -lazy -DFA -will -prevent -exponential -space -blow -- -up -but -it -cache -/ -/ -/ -is -likely -to -fill -up -even -when -it -' -s -large -and -even -for -smallish -/ -/ -/ -values -of -N -. -/ -/ -/ -/ -/ -/ -If -you -aren -' -t -sure -whether -this -helps -or -not -it -is -sensible -to -/ -/ -/ -set -this -to -some -arbitrarily -large -number -in -testing -such -as -/ -/ -/ -usize -: -: -MAX -. -Namely -this -represents -the -amount -of -capacity -that -/ -/ -/ -* -may -* -be -used -. -It -' -s -probably -not -a -good -idea -to -use -usize -: -: -MAX -in -/ -/ -/ -production -though -since -it -implies -there -are -no -controls -on -heap -/ -/ -/ -memory -used -by -this -library -during -a -search -. -In -effect -set -it -to -/ -/ -/ -whatever -you -' -re -willing -to -allocate -for -a -single -regex -search -. -pub -fn -dfa_size_limit -( -& -mut -self -bytes -: -usize -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -dfa_size_limit -( -bytes -) -; -self -} -/ -/ -/ -Set -the -nesting -limit -for -this -parser -. -/ -/ -/ -/ -/ -/ -The -nesting -limit -controls -how -deep -the -abstract -syntax -tree -is -/ -/ -/ -allowed -to -be -. -If -the -AST -exceeds -the -given -limit -( -e -. -g -. -with -too -/ -/ -/ -many -nested -groups -) -then -an -error -is -returned -by -the -parser -. -/ -/ -/ -/ -/ -/ -The -purpose -of -this -limit -is -to -act -as -a -heuristic -to -prevent -stack -/ -/ -/ -overflow -for -consumers -that -do -structural -induction -on -an -AST -using -/ -/ -/ -explicit -recursion -. -While -this -crate -never -does -this -( -instead -using -/ -/ -/ -constant -stack -space -and -moving -the -call -stack -to -the -heap -) -other -/ -/ -/ -crates -may -. -/ -/ -/ -/ -/ -/ -This -limit -is -not -checked -until -the -entire -AST -is -parsed -. -/ -/ -/ -Therefore -if -callers -want -to -put -a -limit -on -the -amount -of -heap -/ -/ -/ -space -used -then -they -should -impose -a -limit -on -the -length -in -/ -/ -/ -bytes -of -the -concrete -pattern -string -. -In -particular -this -is -/ -/ -/ -viable -since -this -parser -implementation -will -limit -itself -to -heap -/ -/ -/ -space -proportional -to -the -length -of -the -pattern -string -. -See -also -/ -/ -/ -the -[ -untrusted -inputs -] -( -crate -# -untrusted -- -input -) -section -in -the -/ -/ -/ -top -- -level -crate -documentation -for -more -information -about -this -. -/ -/ -/ -/ -/ -/ -Note -that -a -nest -limit -of -0 -will -return -a -nest -limit -error -for -/ -/ -/ -most -patterns -but -not -all -. -For -example -a -nest -limit -of -0 -permits -/ -/ -/ -a -but -not -ab -since -ab -requires -an -explicit -concatenation -/ -/ -/ -which -results -in -a -nest -depth -of -1 -. -In -general -a -nest -limit -is -/ -/ -/ -not -something -that -manifests -in -an -obvious -way -in -the -concrete -/ -/ -/ -syntax -therefore -it -should -not -be -used -in -a -granular -way -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -assert -! -( -RegexBuilder -: -: -new -( -r -" -a -" -) -. -nest_limit -( -0 -) -. -build -( -) -. -is_ok -( -) -) -; -/ -/ -/ -assert -! -( -RegexBuilder -: -: -new -( -r -" -ab -" -) -. -nest_limit -( -0 -) -. -build -( -) -. -is_err -( -) -) -; -/ -/ -/ -pub -fn -nest_limit -( -& -mut -self -limit -: -u32 -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -nest_limit -( -limit -) -; -self -} -} -/ -/ -/ -A -configurable -builder -for -a -[ -RegexSet -] -. -/ -/ -/ -/ -/ -/ -This -builder -can -be -used -to -programmatically -set -flags -such -as -/ -/ -/ -i -( -case -insensitive -) -and -x -( -for -verbose -mode -) -. -This -builder -/ -/ -/ -can -also -be -used -to -configure -things -like -the -line -terminator -/ -/ -/ -and -a -size -limit -on -the -compiled -regular -expression -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -RegexSetBuilder -{ -builder -: -Builder -} -impl -RegexSetBuilder -{ -/ -/ -/ -Create -a -new -builder -with -a -default -configuration -for -the -given -/ -/ -/ -patterns -. -/ -/ -/ -/ -/ -/ -If -the -patterns -are -invalid -or -exceed -the -configured -size -limits -/ -/ -/ -then -an -error -will -be -returned -when -[ -RegexSetBuilder -: -: -build -] -is -/ -/ -/ -called -. -pub -fn -new -< -I -S -> -( -patterns -: -I -) -- -> -RegexSetBuilder -where -I -: -IntoIterator -< -Item -= -S -> -S -: -AsRef -< -str -> -{ -RegexSetBuilder -{ -builder -: -Builder -: -: -new -( -patterns -) -} -} -/ -/ -/ -Compiles -the -patterns -given -to -RegexSetBuilder -: -: -new -with -the -/ -/ -/ -configuration -set -on -this -builder -. -/ -/ -/ -/ -/ -/ -If -the -patterns -aren -' -t -valid -regexes -or -if -a -configured -size -limit -/ -/ -/ -was -exceeded -then -an -error -is -returned -. -pub -fn -build -( -& -self -) -- -> -Result -< -RegexSet -Error -> -{ -self -. -builder -. -build_many_string -( -) -} -/ -/ -/ -This -configures -Unicode -mode -for -the -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -Enabling -Unicode -mode -does -a -number -of -things -: -/ -/ -/ -/ -/ -/ -* -Most -fundamentally -it -causes -the -fundamental -atom -of -matching -/ -/ -/ -to -be -a -single -codepoint -. -When -Unicode -mode -is -disabled -it -' -s -a -/ -/ -/ -single -byte -. -For -example -when -Unicode -mode -is -enabled -. -will -/ -/ -/ -match -once -where -as -it -will -match -4 -times -when -Unicode -mode -/ -/ -/ -is -disabled -. -( -Since -the -UTF -- -8 -encoding -of -is -4 -bytes -long -. -) -/ -/ -/ -* -Case -insensitive -matching -uses -Unicode -simple -case -folding -rules -. -/ -/ -/ -* -Unicode -character -classes -like -\ -p -{ -Letter -} -and -\ -p -{ -Greek -} -are -/ -/ -/ -available -. -/ -/ -/ -* -Perl -character -classes -are -Unicode -aware -. -That -is -\ -w -\ -s -and -/ -/ -/ -\ -d -. -/ -/ -/ -* -The -word -boundary -assertions -\ -b -and -\ -B -use -the -Unicode -/ -/ -/ -definition -of -a -word -character -. -/ -/ -/ -/ -/ -/ -Note -that -if -Unicode -mode -is -disabled -then -the -regex -will -fail -to -/ -/ -/ -compile -if -it -could -match -invalid -UTF -- -8 -. -For -example -when -Unicode -/ -/ -/ -mode -is -disabled -then -since -. -matches -any -byte -( -except -for -/ -/ -/ -\ -n -) -then -it -can -match -invalid -UTF -- -8 -and -thus -building -a -regex -/ -/ -/ -from -it -will -fail -. -Another -example -is -\ -w -and -\ -W -. -Since -\ -w -can -/ -/ -/ -only -match -ASCII -bytes -when -Unicode -mode -is -disabled -it -' -s -allowed -. -/ -/ -/ -But -\ -W -can -match -more -than -ASCII -bytes -including -invalid -UTF -- -8 -/ -/ -/ -and -so -it -is -not -allowed -. -This -restriction -can -be -lifted -only -by -/ -/ -/ -using -a -[ -bytes -: -: -RegexSet -] -( -crate -: -: -bytes -: -: -RegexSet -) -. -/ -/ -/ -/ -/ -/ -For -more -details -on -the -Unicode -support -in -this -crate -see -the -/ -/ -/ -[ -Unicode -section -] -( -crate -# -unicode -) -in -this -crate -' -s -top -- -level -/ -/ -/ -documentation -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -true -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -\ -w -" -] -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -greek -letters -would -be -included -in -\ -w -but -since -/ -/ -/ -/ -/ -Unicode -mode -is -disabled -it -only -matches -ASCII -letters -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -" -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -s -" -] -) -/ -/ -/ -. -case_insensitive -( -true -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -' -' -is -included -when -searching -for -' -s -' -case -/ -/ -/ -/ -/ -insensitively -due -to -Unicode -' -s -simple -case -folding -rules -. -But -/ -/ -/ -/ -/ -when -Unicode -mode -is -disabled -only -ASCII -case -insensitive -rules -/ -/ -/ -/ -/ -are -used -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -" -) -) -; -/ -/ -/ -pub -fn -unicode -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -unicode -( -yes -) -; -self -} -/ -/ -/ -This -configures -whether -to -enable -case -insensitive -matching -for -all -/ -/ -/ -of -the -patterns -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -i -/ -/ -/ -in -the -pattern -. -For -example -( -? -i -: -foo -) -matches -foo -case -/ -/ -/ -insensitively -while -( -? -- -i -: -foo -) -matches -foo -case -sensitively -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -foo -( -? -- -i -: -bar -) -quux -" -] -) -/ -/ -/ -. -case_insensitive -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -FoObarQuUx -" -) -) -; -/ -/ -/ -/ -/ -Even -though -case -insensitive -matching -is -enabled -in -the -builder -/ -/ -/ -/ -/ -it -can -be -locally -disabled -within -the -pattern -. -In -this -case -/ -/ -/ -/ -/ -bar -is -matched -case -sensitively -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -fooBARquux -" -) -) -; -/ -/ -/ -pub -fn -case_insensitive -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -case_insensitive -( -yes -) -; -self -} -/ -/ -/ -This -configures -multi -- -line -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -Enabling -multi -- -line -mode -changes -the -behavior -of -the -^ -and -/ -/ -/ -anchor -assertions -. -Instead -of -only -matching -at -the -beginning -and -/ -/ -/ -end -of -a -haystack -respectively -multi -- -line -mode -causes -them -to -/ -/ -/ -match -at -the -beginning -and -end -of -a -line -* -in -addition -* -to -the -/ -/ -/ -beginning -and -end -of -a -haystack -. -More -precisely -^ -will -match -at -/ -/ -/ -the -position -immediately -following -a -\ -n -and -will -match -at -the -/ -/ -/ -position -immediately -preceding -a -\ -n -. -/ -/ -/ -/ -/ -/ -The -behavior -of -this -option -can -be -impacted -by -other -settings -too -: -/ -/ -/ -/ -/ -/ -* -The -[ -RegexSetBuilder -: -: -line_terminator -] -option -changes -\ -n -/ -/ -/ -above -to -any -ASCII -byte -. -/ -/ -/ -* -The -[ -RegexSetBuilder -: -: -crlf -] -option -changes -the -line -terminator -/ -/ -/ -to -be -either -\ -r -or -\ -n -but -never -at -the -position -between -a -\ -r -/ -/ -/ -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -m -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -^ -foo -" -] -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -\ -nfoo -\ -n -" -) -) -; -/ -/ -/ -pub -fn -multi_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -multi_line -( -yes -) -; -self -} -/ -/ -/ -This -configures -dot -- -matches -- -new -- -line -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Perhaps -surprisingly -the -default -behavior -for -. -is -not -to -match -/ -/ -/ -any -character -but -rather -to -match -any -character -except -for -the -/ -/ -/ -line -terminator -( -which -is -\ -n -by -default -) -. -When -this -mode -is -/ -/ -/ -enabled -the -behavior -changes -such -that -. -truly -matches -any -/ -/ -/ -character -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -s -in -/ -/ -/ -the -pattern -. -For -example -( -? -s -: -. -) -and -\ -p -{ -any -} -are -equivalent -/ -/ -/ -regexes -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -foo -. -bar -" -] -) -/ -/ -/ -. -dot_matches_new_line -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -foo -\ -nbar -" -; -/ -/ -/ -assert -! -( -re -. -is_match -( -hay -) -) -; -/ -/ -/ -pub -fn -dot_matches_new_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -dot_matches_new_line -( -yes -) -; -self -} -/ -/ -/ -This -configures -CRLF -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -When -CRLF -mode -is -enabled -both -\ -r -( -" -carriage -return -" -or -CR -for -/ -/ -/ -short -) -and -\ -n -( -" -line -feed -" -or -LF -for -short -) -are -treated -as -line -/ -/ -/ -terminators -. -This -results -in -the -following -: -/ -/ -/ -/ -/ -/ -* -Unless -dot -- -matches -- -new -- -line -mode -is -enabled -. -will -now -match -/ -/ -/ -any -character -except -for -\ -n -and -\ -r -. -/ -/ -/ -* -When -multi -- -line -mode -is -enabled -^ -will -match -immediately -/ -/ -/ -following -a -\ -n -or -a -\ -r -. -Similarly -will -match -immediately -/ -/ -/ -preceding -a -\ -n -or -a -\ -r -. -Neither -^ -nor -will -ever -match -/ -/ -/ -between -\ -r -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -R -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -^ -foo -" -] -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -crlf -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -\ -r -\ -nfoo -\ -r -\ -n -" -; -/ -/ -/ -/ -/ -If -CRLF -mode -weren -' -t -enabled -here -then -' -' -wouldn -' -t -match -/ -/ -/ -/ -/ -immediately -after -' -foo -' -and -thus -no -match -would -be -found -. -/ -/ -/ -assert -! -( -re -. -is_match -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -demonstrates -that -^ -will -never -match -at -a -position -/ -/ -/ -between -\ -r -and -\ -n -. -( -will -similarly -not -match -between -a -\ -r -/ -/ -/ -and -a -\ -n -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -^ -\ -n -" -] -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -crlf -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -\ -r -\ -n -" -) -) -; -/ -/ -/ -pub -fn -crlf -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -crlf -( -yes -) -; -self -} -/ -/ -/ -Configures -the -line -terminator -to -be -used -by -the -regex -. -/ -/ -/ -/ -/ -/ -The -line -terminator -is -relevant -in -two -ways -for -a -particular -regex -: -/ -/ -/ -/ -/ -/ -* -When -dot -- -matches -- -new -- -line -mode -is -* -not -* -enabled -( -the -default -) -/ -/ -/ -then -. -will -match -any -character -except -for -the -configured -line -/ -/ -/ -terminator -. -/ -/ -/ -* -When -multi -- -line -mode -is -enabled -( -not -the -default -) -then -^ -and -/ -/ -/ -will -match -immediately -after -and -before -respectively -a -line -/ -/ -/ -terminator -. -/ -/ -/ -/ -/ -/ -In -both -cases -if -CRLF -mode -is -enabled -in -a -particular -context -/ -/ -/ -then -it -takes -precedence -over -any -configured -line -terminator -. -/ -/ -/ -/ -/ -/ -This -option -cannot -be -configured -from -within -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -line -terminator -is -\ -n -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -treat -the -NUL -byte -as -a -line -terminator -. -This -can -/ -/ -/ -be -a -useful -heuristic -when -searching -binary -data -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -^ -foo -" -] -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -line_terminator -( -b -' -\ -x00 -' -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -\ -x00foo -\ -x00 -" -; -/ -/ -/ -assert -! -( -re -. -is_match -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -behavior -of -. -is -impacted -by -this -/ -/ -/ -setting -as -well -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -. -" -] -) -/ -/ -/ -. -line_terminator -( -b -' -\ -x00 -' -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -\ -n -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -\ -x00 -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -shows -that -building -a -regex -will -fail -if -the -byte -given -/ -/ -/ -is -not -ASCII -and -the -pattern -could -result -in -matching -invalid -/ -/ -/ -UTF -- -8 -. -This -is -because -any -singular -non -- -ASCII -byte -is -not -valid -/ -/ -/ -UTF -- -8 -and -it -is -not -permitted -for -a -[ -RegexSet -] -to -match -invalid -/ -/ -/ -UTF -- -8 -. -( -It -is -permissible -to -use -a -non -- -ASCII -byte -when -building -a -/ -/ -/ -[ -bytes -: -: -RegexSet -] -( -crate -: -: -bytes -: -: -RegexSet -) -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -assert -! -( -/ -/ -/ -RegexSetBuilder -: -: -new -( -[ -r -" -. -" -] -) -/ -/ -/ -. -line_terminator -( -0x80 -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -is_err -( -) -/ -/ -/ -) -; -/ -/ -/ -/ -/ -Note -that -using -a -non -- -ASCII -byte -isn -' -t -enough -on -its -own -to -/ -/ -/ -/ -/ -cause -regex -compilation -to -fail -. -You -actually -have -to -make -use -/ -/ -/ -/ -/ -of -it -in -the -regex -in -a -way -that -leads -to -matching -invalid -/ -/ -/ -/ -/ -UTF -- -8 -. -If -you -don -' -t -then -regex -compilation -will -succeed -! -/ -/ -/ -assert -! -( -/ -/ -/ -RegexSetBuilder -: -: -new -( -[ -r -" -a -" -] -) -/ -/ -/ -. -line_terminator -( -0x80 -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -is_ok -( -) -/ -/ -/ -) -; -/ -/ -/ -pub -fn -line_terminator -( -& -mut -self -byte -: -u8 -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -line_terminator -( -byte -) -; -self -} -/ -/ -/ -This -configures -swap -- -greed -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -When -swap -- -greed -mode -is -enabled -patterns -like -a -+ -will -become -/ -/ -/ -non -- -greedy -and -patterns -like -a -+ -? -will -become -greedy -. -In -other -/ -/ -/ -words -the -meanings -of -a -+ -and -a -+ -? -are -switched -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -U -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -Note -that -this -is -generally -not -useful -for -a -RegexSet -since -a -/ -/ -/ -RegexSet -can -only -report -whether -a -pattern -matches -or -not -. -Since -/ -/ -/ -greediness -never -impacts -whether -a -match -is -found -or -not -( -only -the -/ -/ -/ -offsets -of -the -match -) -it -follows -that -whether -parts -of -a -pattern -/ -/ -/ -are -greedy -or -not -doesn -' -t -matter -for -a -RegexSet -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -pub -fn -swap_greed -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -swap_greed -( -yes -) -; -self -} -/ -/ -/ -This -configures -verbose -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -When -enabled -whitespace -will -treated -as -insignifcant -in -the -/ -/ -/ -pattern -and -# -can -be -used -to -start -a -comment -until -the -next -new -/ -/ -/ -line -. -/ -/ -/ -/ -/ -/ -Normally -in -most -places -in -a -pattern -whitespace -is -treated -/ -/ -/ -literally -. -For -example -+ -will -match -one -or -more -ASCII -whitespace -/ -/ -/ -characters -. -/ -/ -/ -/ -/ -/ -When -verbose -mode -is -enabled -\ -# -can -be -used -to -match -a -literal -/ -/ -/ -# -and -\ -can -be -used -to -match -a -literal -ASCII -whitespace -/ -/ -/ -character -. -/ -/ -/ -/ -/ -/ -Verbose -mode -is -useful -for -permitting -regexes -to -be -formatted -and -/ -/ -/ -broken -up -more -nicely -. -This -may -make -them -more -easily -readable -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -x -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -pat -= -r -" -/ -/ -/ -\ -b -/ -/ -/ -( -? -< -first -> -\ -p -{ -Uppercase -} -\ -w -* -) -# -always -start -with -uppercase -letter -/ -/ -/ -[ -\ -s -- -- -\ -n -] -+ -# -whitespace -should -separate -names -/ -/ -/ -( -? -: -# -middle -name -can -be -an -initial -! -/ -/ -/ -( -? -: -( -? -< -initial -> -\ -p -{ -Uppercase -} -) -\ -. -| -( -? -< -middle -> -\ -p -{ -Uppercase -} -\ -w -* -) -) -/ -/ -/ -[ -\ -s -- -- -\ -n -] -+ -/ -/ -/ -) -? -/ -/ -/ -( -? -< -last -> -\ -p -{ -Uppercase -} -\ -w -* -) -/ -/ -/ -\ -b -/ -/ -/ -" -; -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -pat -] -) -/ -/ -/ -. -ignore_whitespace -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -Harry -Potter -" -) -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -Harry -J -. -Potter -" -) -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -Harry -James -Potter -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -harry -J -. -Potter -" -) -) -; -/ -/ -/ -pub -fn -ignore_whitespace -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -ignore_whitespace -( -yes -) -; -self -} -/ -/ -/ -This -configures -octal -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -Octal -syntax -is -a -little -- -known -way -of -uttering -Unicode -codepoints -/ -/ -/ -in -a -pattern -. -For -example -a -\ -x61 -\ -u0061 -and -\ -141 -are -all -/ -/ -/ -equivalent -patterns -where -the -last -example -shows -octal -syntax -. -/ -/ -/ -/ -/ -/ -While -supporting -octal -syntax -isn -' -t -in -and -of -itself -a -problem -/ -/ -/ -it -does -make -good -error -messages -harder -. -That -is -in -PCRE -based -/ -/ -/ -regex -engines -syntax -like -\ -1 -invokes -a -backreference -which -is -/ -/ -/ -explicitly -unsupported -this -library -. -However -many -users -expect -/ -/ -/ -backreferences -to -be -supported -. -Therefore -when -octal -support -/ -/ -/ -is -disabled -the -error -message -will -explicitly -mention -that -/ -/ -/ -backreferences -aren -' -t -supported -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -/ -/ -Normally -this -pattern -would -not -compile -with -an -error -message -/ -/ -/ -/ -/ -about -backreferences -not -being -supported -. -But -with -octal -mode -/ -/ -/ -/ -/ -enabled -octal -escape -sequences -work -. -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -\ -141 -" -] -) -/ -/ -/ -. -octal -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -" -a -" -) -) -; -/ -/ -/ -pub -fn -octal -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -octal -( -yes -) -; -self -} -/ -/ -/ -Sets -the -approximate -size -limit -in -bytes -of -the -compiled -regex -. -/ -/ -/ -/ -/ -/ -This -roughly -corresponds -to -the -number -of -heap -memory -in -/ -/ -/ -bytes -occupied -by -a -single -regex -. -If -the -regex -would -otherwise -/ -/ -/ -approximately -exceed -this -limit -then -compiling -that -regex -will -/ -/ -/ -fail -. -/ -/ -/ -/ -/ -/ -The -main -utility -of -a -method -like -this -is -to -avoid -compiling -/ -/ -/ -regexes -that -use -an -unexpected -amount -of -resources -such -as -/ -/ -/ -time -and -memory -. -Even -if -the -memory -usage -of -a -large -regex -is -/ -/ -/ -acceptable -its -search -time -may -not -be -. -Namely -worst -case -time -/ -/ -/ -complexity -for -search -is -O -( -m -* -n -) -where -m -~ -len -( -pattern -) -and -/ -/ -/ -n -~ -len -( -haystack -) -. -That -is -search -time -depends -in -part -on -the -/ -/ -/ -size -of -the -compiled -regex -. -This -means -that -putting -a -limit -on -the -/ -/ -/ -size -of -the -regex -limits -how -much -a -regex -can -impact -search -time -. -/ -/ -/ -/ -/ -/ -For -more -information -about -regex -size -limits -see -the -section -on -/ -/ -/ -[ -untrusted -inputs -] -( -crate -# -untrusted -- -input -) -in -the -top -- -level -crate -/ -/ -/ -documentation -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -some -reasonable -number -that -permits -most -/ -/ -/ -patterns -to -compile -successfully -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -/ -/ -It -may -surprise -you -how -big -some -seemingly -small -patterns -can -/ -/ -/ -/ -/ -be -! -Since -\ -w -is -Unicode -aware -this -generates -a -regex -that -can -/ -/ -/ -/ -/ -match -approximately -140 -000 -distinct -codepoints -. -/ -/ -/ -assert -! -( -/ -/ -/ -RegexSetBuilder -: -: -new -( -[ -r -" -\ -w -" -] -) -/ -/ -/ -. -size_limit -( -45_000 -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -is_err -( -) -/ -/ -/ -) -; -/ -/ -/ -pub -fn -size_limit -( -& -mut -self -bytes -: -usize -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -size_limit -( -bytes -) -; -self -} -/ -/ -/ -Set -the -approximate -capacity -in -bytes -of -the -cache -of -transitions -/ -/ -/ -used -by -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -While -the -lazy -DFA -isn -' -t -always -used -in -tends -to -be -the -most -/ -/ -/ -commonly -use -regex -engine -in -default -configurations -. -It -tends -to -/ -/ -/ -adopt -the -performance -profile -of -a -fully -build -DFA -but -without -the -/ -/ -/ -downside -of -taking -worst -case -exponential -time -to -build -. -/ -/ -/ -/ -/ -/ -The -downside -is -that -it -needs -to -keep -a -cache -of -transitions -and -/ -/ -/ -states -that -are -built -while -running -a -search -and -this -cache -/ -/ -/ -can -fill -up -. -When -it -fills -up -the -cache -will -reset -itself -. -Any -/ -/ -/ -previously -generated -states -and -transitions -will -then -need -to -be -/ -/ -/ -re -- -generated -. -If -this -happens -too -many -times -then -this -library -/ -/ -/ -will -bail -out -of -using -the -lazy -DFA -and -switch -to -a -different -regex -/ -/ -/ -engine -. -/ -/ -/ -/ -/ -/ -If -your -regex -provokes -this -particular -downside -of -the -lazy -DFA -/ -/ -/ -then -it -may -be -beneficial -to -increase -its -cache -capacity -. -This -will -/ -/ -/ -potentially -reduce -the -frequency -of -cache -resetting -( -ideally -to -/ -/ -/ -0 -) -. -While -it -won -' -t -fix -all -potential -performance -problems -with -/ -/ -/ -the -lazy -DFA -increasing -the -cache -capacity -does -fix -some -. -/ -/ -/ -/ -/ -/ -There -is -no -easy -way -to -determine -a -priori -whether -increasing -/ -/ -/ -this -cache -capacity -will -help -. -In -general -the -larger -your -regex -/ -/ -/ -the -more -cache -it -' -s -likely -to -use -. -But -that -isn -' -t -an -ironclad -rule -. -/ -/ -/ -For -example -a -regex -like -[ -01 -] -* -1 -[ -01 -] -{ -N -} -would -normally -produce -a -/ -/ -/ -fully -build -DFA -that -is -exponential -in -size -with -respect -to -N -. -/ -/ -/ -The -lazy -DFA -will -prevent -exponential -space -blow -- -up -but -it -cache -/ -/ -/ -is -likely -to -fill -up -even -when -it -' -s -large -and -even -for -smallish -/ -/ -/ -values -of -N -. -/ -/ -/ -/ -/ -/ -If -you -aren -' -t -sure -whether -this -helps -or -not -it -is -sensible -to -/ -/ -/ -set -this -to -some -arbitrarily -large -number -in -testing -such -as -/ -/ -/ -usize -: -: -MAX -. -Namely -this -represents -the -amount -of -capacity -that -/ -/ -/ -* -may -* -be -used -. -It -' -s -probably -not -a -good -idea -to -use -usize -: -: -MAX -in -/ -/ -/ -production -though -since -it -implies -there -are -no -controls -on -heap -/ -/ -/ -memory -used -by -this -library -during -a -search -. -In -effect -set -it -to -/ -/ -/ -whatever -you -' -re -willing -to -allocate -for -a -single -regex -search -. -pub -fn -dfa_size_limit -( -& -mut -self -bytes -: -usize -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -dfa_size_limit -( -bytes -) -; -self -} -/ -/ -/ -Set -the -nesting -limit -for -this -parser -. -/ -/ -/ -/ -/ -/ -The -nesting -limit -controls -how -deep -the -abstract -syntax -tree -is -/ -/ -/ -allowed -to -be -. -If -the -AST -exceeds -the -given -limit -( -e -. -g -. -with -too -/ -/ -/ -many -nested -groups -) -then -an -error -is -returned -by -the -parser -. -/ -/ -/ -/ -/ -/ -The -purpose -of -this -limit -is -to -act -as -a -heuristic -to -prevent -stack -/ -/ -/ -overflow -for -consumers -that -do -structural -induction -on -an -AST -using -/ -/ -/ -explicit -recursion -. -While -this -crate -never -does -this -( -instead -using -/ -/ -/ -constant -stack -space -and -moving -the -call -stack -to -the -heap -) -other -/ -/ -/ -crates -may -. -/ -/ -/ -/ -/ -/ -This -limit -is -not -checked -until -the -entire -AST -is -parsed -. -/ -/ -/ -Therefore -if -callers -want -to -put -a -limit -on -the -amount -of -heap -/ -/ -/ -space -used -then -they -should -impose -a -limit -on -the -length -in -/ -/ -/ -bytes -of -the -concrete -pattern -string -. -In -particular -this -is -/ -/ -/ -viable -since -this -parser -implementation -will -limit -itself -to -heap -/ -/ -/ -space -proportional -to -the -length -of -the -pattern -string -. -See -also -/ -/ -/ -the -[ -untrusted -inputs -] -( -crate -# -untrusted -- -input -) -section -in -the -/ -/ -/ -top -- -level -crate -documentation -for -more -information -about -this -. -/ -/ -/ -/ -/ -/ -Note -that -a -nest -limit -of -0 -will -return -a -nest -limit -error -for -/ -/ -/ -most -patterns -but -not -all -. -For -example -a -nest -limit -of -0 -permits -/ -/ -/ -a -but -not -ab -since -ab -requires -an -explicit -concatenation -/ -/ -/ -which -results -in -a -nest -depth -of -1 -. -In -general -a -nest -limit -is -/ -/ -/ -not -something -that -manifests -in -an -obvious -way -in -the -concrete -/ -/ -/ -syntax -therefore -it -should -not -be -used -in -a -granular -way -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -assert -! -( -RegexSetBuilder -: -: -new -( -[ -r -" -a -" -] -) -. -nest_limit -( -0 -) -. -build -( -) -. -is_ok -( -) -) -; -/ -/ -/ -assert -! -( -RegexSetBuilder -: -: -new -( -[ -r -" -ab -" -] -) -. -nest_limit -( -0 -) -. -build -( -) -. -is_err -( -) -) -; -/ -/ -/ -pub -fn -nest_limit -( -& -mut -self -limit -: -u32 -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -nest_limit -( -limit -) -; -self -} -} -} -pub -( -crate -) -mod -bytes -{ -use -crate -: -: -{ -bytes -: -: -{ -Regex -RegexSet -} -error -: -: -Error -} -; -use -super -: -: -Builder -; -/ -/ -/ -A -configurable -builder -for -a -[ -Regex -] -. -/ -/ -/ -/ -/ -/ -This -builder -can -be -used -to -programmatically -set -flags -such -as -i -/ -/ -/ -( -case -insensitive -) -and -x -( -for -verbose -mode -) -. -This -builder -can -also -be -/ -/ -/ -used -to -configure -things -like -the -line -terminator -and -a -size -limit -on -/ -/ -/ -the -compiled -regular -expression -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -RegexBuilder -{ -builder -: -Builder -} -impl -RegexBuilder -{ -/ -/ -/ -Create -a -new -builder -with -a -default -configuration -for -the -given -/ -/ -/ -pattern -. -/ -/ -/ -/ -/ -/ -If -the -pattern -is -invalid -or -exceeds -the -configured -size -limits -/ -/ -/ -then -an -error -will -be -returned -when -[ -RegexBuilder -: -: -build -] -is -/ -/ -/ -called -. -pub -fn -new -( -pattern -: -& -str -) -- -> -RegexBuilder -{ -RegexBuilder -{ -builder -: -Builder -: -: -new -( -[ -pattern -] -) -} -} -/ -/ -/ -Compiles -the -pattern -given -to -RegexBuilder -: -: -new -with -the -/ -/ -/ -configuration -set -on -this -builder -. -/ -/ -/ -/ -/ -/ -If -the -pattern -isn -' -t -a -valid -regex -or -if -a -configured -size -limit -/ -/ -/ -was -exceeded -then -an -error -is -returned -. -pub -fn -build -( -& -self -) -- -> -Result -< -Regex -Error -> -{ -self -. -builder -. -build_one_bytes -( -) -} -/ -/ -/ -This -configures -Unicode -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Enabling -Unicode -mode -does -a -number -of -things -: -/ -/ -/ -/ -/ -/ -* -Most -fundamentally -it -causes -the -fundamental -atom -of -matching -/ -/ -/ -to -be -a -single -codepoint -. -When -Unicode -mode -is -disabled -it -' -s -a -/ -/ -/ -single -byte -. -For -example -when -Unicode -mode -is -enabled -. -will -/ -/ -/ -match -once -where -as -it -will -match -4 -times -when -Unicode -mode -/ -/ -/ -is -disabled -. -( -Since -the -UTF -- -8 -encoding -of -is -4 -bytes -long -. -) -/ -/ -/ -* -Case -insensitive -matching -uses -Unicode -simple -case -folding -rules -. -/ -/ -/ -* -Unicode -character -classes -like -\ -p -{ -Letter -} -and -\ -p -{ -Greek -} -are -/ -/ -/ -available -. -/ -/ -/ -* -Perl -character -classes -are -Unicode -aware -. -That -is -\ -w -\ -s -and -/ -/ -/ -\ -d -. -/ -/ -/ -* -The -word -boundary -assertions -\ -b -and -\ -B -use -the -Unicode -/ -/ -/ -definition -of -a -word -character -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -the -top -- -level -Regex -for -searching -& -str -it -/ -/ -/ -is -permitted -to -disable -Unicode -mode -even -if -the -resulting -pattern -/ -/ -/ -could -match -invalid -UTF -- -8 -. -For -example -( -? -- -u -: -. -) -is -not -a -valid -/ -/ -/ -pattern -for -a -top -- -level -Regex -but -is -valid -for -a -bytes -: -: -Regex -. -/ -/ -/ -/ -/ -/ -For -more -details -on -the -Unicode -support -in -this -crate -see -the -/ -/ -/ -[ -Unicode -section -] -( -crate -# -unicode -) -in -this -crate -' -s -top -- -level -/ -/ -/ -documentation -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -true -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -\ -w -" -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -greek -letters -would -be -included -in -\ -w -but -since -/ -/ -/ -/ -/ -Unicode -mode -is -disabled -it -only -matches -ASCII -letters -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -" -. -as_bytes -( -) -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -s -" -) -/ -/ -/ -. -case_insensitive -( -true -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -' -' -is -included -when -searching -for -' -s -' -case -/ -/ -/ -/ -/ -insensitively -due -to -Unicode -' -s -simple -case -folding -rules -. -But -/ -/ -/ -/ -/ -when -Unicode -mode -is -disabled -only -ASCII -case -insensitive -rules -/ -/ -/ -/ -/ -are -used -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -" -. -as_bytes -( -) -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Since -this -builder -is -for -constructing -a -[ -bytes -: -: -Regex -] -( -Regex -) -/ -/ -/ -one -can -disable -Unicode -mode -even -if -it -would -match -invalid -UTF -- -8 -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -. -" -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -greek -letters -would -be -included -in -\ -w -but -since -/ -/ -/ -/ -/ -Unicode -mode -is -disabled -it -only -matches -ASCII -letters -. -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -\ -xFF -" -) -) -; -/ -/ -/ -pub -fn -unicode -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -unicode -( -yes -) -; -self -} -/ -/ -/ -This -configures -whether -to -enable -case -insensitive -matching -for -the -/ -/ -/ -entire -pattern -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -i -/ -/ -/ -in -the -pattern -. -For -example -( -? -i -: -foo -) -matches -foo -case -/ -/ -/ -insensitively -while -( -? -- -i -: -foo -) -matches -foo -case -sensitively -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -foo -( -? -- -i -: -bar -) -quux -" -) -/ -/ -/ -. -case_insensitive -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -FoObarQuUx -" -) -) -; -/ -/ -/ -/ -/ -Even -though -case -insensitive -matching -is -enabled -in -the -builder -/ -/ -/ -/ -/ -it -can -be -locally -disabled -within -the -pattern -. -In -this -case -/ -/ -/ -/ -/ -bar -is -matched -case -sensitively -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -b -" -fooBARquux -" -) -) -; -/ -/ -/ -pub -fn -case_insensitive -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -case_insensitive -( -yes -) -; -self -} -/ -/ -/ -This -configures -multi -- -line -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Enabling -multi -- -line -mode -changes -the -behavior -of -the -^ -and -/ -/ -/ -anchor -assertions -. -Instead -of -only -matching -at -the -beginning -and -/ -/ -/ -end -of -a -haystack -respectively -multi -- -line -mode -causes -them -to -/ -/ -/ -match -at -the -beginning -and -end -of -a -line -* -in -addition -* -to -the -/ -/ -/ -beginning -and -end -of -a -haystack -. -More -precisely -^ -will -match -at -/ -/ -/ -the -position -immediately -following -a -\ -n -and -will -match -at -the -/ -/ -/ -position -immediately -preceding -a -\ -n -. -/ -/ -/ -/ -/ -/ -The -behavior -of -this -option -can -be -impacted -by -other -settings -too -: -/ -/ -/ -/ -/ -/ -* -The -[ -RegexBuilder -: -: -line_terminator -] -option -changes -\ -n -above -/ -/ -/ -to -any -ASCII -byte -. -/ -/ -/ -* -The -[ -RegexBuilder -: -: -crlf -] -option -changes -the -line -terminator -to -/ -/ -/ -be -either -\ -r -or -\ -n -but -never -at -the -position -between -a -\ -r -/ -/ -/ -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -m -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -^ -foo -" -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -. -. -4 -) -re -. -find -( -b -" -\ -nfoo -\ -n -" -) -. -map -( -| -m -| -m -. -range -( -) -) -) -; -/ -/ -/ -pub -fn -multi_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -multi_line -( -yes -) -; -self -} -/ -/ -/ -This -configures -dot -- -matches -- -new -- -line -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Perhaps -surprisingly -the -default -behavior -for -. -is -not -to -match -/ -/ -/ -any -character -but -rather -to -match -any -character -except -for -the -/ -/ -/ -line -terminator -( -which -is -\ -n -by -default -) -. -When -this -mode -is -/ -/ -/ -enabled -the -behavior -changes -such -that -. -truly -matches -any -/ -/ -/ -character -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -s -in -/ -/ -/ -the -pattern -. -For -example -( -? -s -: -. -) -and -\ -p -{ -any -} -are -equivalent -/ -/ -/ -regexes -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -foo -. -bar -" -) -/ -/ -/ -. -dot_matches_new_line -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -foo -\ -nbar -" -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -foo -\ -nbar -" -[ -. -. -] -) -re -. -find -( -hay -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -) -; -/ -/ -/ -pub -fn -dot_matches_new_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -dot_matches_new_line -( -yes -) -; -self -} -/ -/ -/ -This -configures -CRLF -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -When -CRLF -mode -is -enabled -both -\ -r -( -" -carriage -return -" -or -CR -for -/ -/ -/ -short -) -and -\ -n -( -" -line -feed -" -or -LF -for -short -) -are -treated -as -line -/ -/ -/ -terminators -. -This -results -in -the -following -: -/ -/ -/ -/ -/ -/ -* -Unless -dot -- -matches -- -new -- -line -mode -is -enabled -. -will -now -match -/ -/ -/ -any -character -except -for -\ -n -and -\ -r -. -/ -/ -/ -* -When -multi -- -line -mode -is -enabled -^ -will -match -immediately -/ -/ -/ -following -a -\ -n -or -a -\ -r -. -Similarly -will -match -immediately -/ -/ -/ -preceding -a -\ -n -or -a -\ -r -. -Neither -^ -nor -will -ever -match -/ -/ -/ -between -\ -r -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -R -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -^ -foo -" -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -crlf -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -\ -r -\ -nfoo -\ -r -\ -n -" -; -/ -/ -/ -/ -/ -If -CRLF -mode -weren -' -t -enabled -here -then -' -' -wouldn -' -t -match -/ -/ -/ -/ -/ -immediately -after -' -foo -' -and -thus -no -match -would -be -found -. -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -foo -" -[ -. -. -] -) -re -. -find -( -hay -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -demonstrates -that -^ -will -never -match -at -a -position -/ -/ -/ -between -\ -r -and -\ -n -. -( -will -similarly -not -match -between -a -\ -r -/ -/ -/ -and -a -\ -n -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -^ -" -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -crlf -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -\ -r -\ -n -\ -r -\ -n -" -; -/ -/ -/ -let -ranges -: -Vec -< -_ -> -= -re -. -find_iter -( -hay -) -. -map -( -| -m -| -m -. -range -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -ranges -vec -! -[ -0 -. -. -0 -2 -. -. -2 -4 -. -. -4 -] -) -; -/ -/ -/ -pub -fn -crlf -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -crlf -( -yes -) -; -self -} -/ -/ -/ -Configures -the -line -terminator -to -be -used -by -the -regex -. -/ -/ -/ -/ -/ -/ -The -line -terminator -is -relevant -in -two -ways -for -a -particular -regex -: -/ -/ -/ -/ -/ -/ -* -When -dot -- -matches -- -new -- -line -mode -is -* -not -* -enabled -( -the -default -) -/ -/ -/ -then -. -will -match -any -character -except -for -the -configured -line -/ -/ -/ -terminator -. -/ -/ -/ -* -When -multi -- -line -mode -is -enabled -( -not -the -default -) -then -^ -and -/ -/ -/ -will -match -immediately -after -and -before -respectively -a -line -/ -/ -/ -terminator -. -/ -/ -/ -/ -/ -/ -In -both -cases -if -CRLF -mode -is -enabled -in -a -particular -context -/ -/ -/ -then -it -takes -precedence -over -any -configured -line -terminator -. -/ -/ -/ -/ -/ -/ -This -option -cannot -be -configured -from -within -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -line -terminator -is -\ -n -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -treat -the -NUL -byte -as -a -line -terminator -. -This -can -/ -/ -/ -be -a -useful -heuristic -when -searching -binary -data -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -^ -foo -" -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -line_terminator -( -b -' -\ -x00 -' -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -\ -x00foo -\ -x00 -" -; -/ -/ -/ -assert_eq -! -( -Some -( -1 -. -. -4 -) -re -. -find -( -hay -) -. -map -( -| -m -| -m -. -range -( -) -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -behavior -of -. -is -impacted -by -this -/ -/ -/ -setting -as -well -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -. -" -) -/ -/ -/ -. -line_terminator -( -b -' -\ -x00 -' -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -\ -n -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -b -" -\ -x00 -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -shows -that -building -a -regex -will -work -even -when -the -byte -/ -/ -/ -given -is -not -ASCII -. -This -is -unlike -the -top -- -level -Regex -API -where -/ -/ -/ -matching -invalid -UTF -- -8 -is -not -allowed -. -/ -/ -/ -/ -/ -/ -Note -though -that -you -must -disable -Unicode -mode -. -This -is -required -/ -/ -/ -because -Unicode -mode -requires -matching -one -codepoint -at -a -time -/ -/ -/ -and -there -is -no -way -to -match -a -non -- -ASCII -byte -as -if -it -were -a -/ -/ -/ -codepoint -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -assert -! -( -/ -/ -/ -RegexBuilder -: -: -new -( -r -" -. -" -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -line_terminator -( -0x80 -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -is_ok -( -) -/ -/ -/ -) -; -/ -/ -/ -pub -fn -line_terminator -( -& -mut -self -byte -: -u8 -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -line_terminator -( -byte -) -; -self -} -/ -/ -/ -This -configures -swap -- -greed -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -When -swap -- -greed -mode -is -enabled -patterns -like -a -+ -will -become -/ -/ -/ -non -- -greedy -and -patterns -like -a -+ -? -will -become -greedy -. -In -other -/ -/ -/ -words -the -meanings -of -a -+ -and -a -+ -? -are -switched -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -U -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -a -+ -" -) -/ -/ -/ -. -swap_greed -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -& -b -" -a -" -[ -. -. -] -) -re -. -find -( -b -" -aaa -" -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -) -; -/ -/ -/ -pub -fn -swap_greed -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -swap_greed -( -yes -) -; -self -} -/ -/ -/ -This -configures -verbose -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -When -enabled -whitespace -will -treated -as -insignifcant -in -the -/ -/ -/ -pattern -and -# -can -be -used -to -start -a -comment -until -the -next -new -/ -/ -/ -line -. -/ -/ -/ -/ -/ -/ -Normally -in -most -places -in -a -pattern -whitespace -is -treated -/ -/ -/ -literally -. -For -example -+ -will -match -one -or -more -ASCII -whitespace -/ -/ -/ -characters -. -/ -/ -/ -/ -/ -/ -When -verbose -mode -is -enabled -\ -# -can -be -used -to -match -a -literal -/ -/ -/ -# -and -\ -can -be -used -to -match -a -literal -ASCII -whitespace -/ -/ -/ -character -. -/ -/ -/ -/ -/ -/ -Verbose -mode -is -useful -for -permitting -regexes -to -be -formatted -and -/ -/ -/ -broken -up -more -nicely -. -This -may -make -them -more -easily -readable -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -x -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -let -pat -= -r -" -/ -/ -/ -\ -b -/ -/ -/ -( -? -< -first -> -\ -p -{ -Uppercase -} -\ -w -* -) -# -always -start -with -uppercase -letter -/ -/ -/ -[ -\ -s -- -- -\ -n -] -+ -# -whitespace -should -separate -names -/ -/ -/ -( -? -: -# -middle -name -can -be -an -initial -! -/ -/ -/ -( -? -: -( -? -< -initial -> -\ -p -{ -Uppercase -} -) -\ -. -| -( -? -< -middle -> -\ -p -{ -Uppercase -} -\ -w -* -) -) -/ -/ -/ -[ -\ -s -- -- -\ -n -] -+ -/ -/ -/ -) -? -/ -/ -/ -( -? -< -last -> -\ -p -{ -Uppercase -} -\ -w -* -) -/ -/ -/ -\ -b -/ -/ -/ -" -; -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -pat -) -/ -/ -/ -. -ignore_whitespace -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -re -. -captures -( -b -" -Harry -Potter -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -Harry -" -[ -. -. -] -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -Potter -" -[ -. -. -] -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -re -. -captures -( -b -" -Harry -J -. -Potter -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -Harry -" -[ -. -. -] -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -/ -/ -Since -a -middle -name -/ -initial -isn -' -t -required -for -an -overall -match -/ -/ -/ -/ -/ -we -can -' -t -assume -that -' -initial -' -or -' -middle -' -will -be -populated -! -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -& -b -" -J -" -[ -. -. -] -) -/ -/ -/ -caps -. -name -( -" -initial -" -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -None -caps -. -name -( -" -middle -" -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -Potter -" -[ -. -. -] -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -re -. -captures -( -b -" -Harry -James -Potter -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -Harry -" -[ -. -. -] -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -/ -/ -Since -a -middle -name -/ -initial -isn -' -t -required -for -an -overall -match -/ -/ -/ -/ -/ -we -can -' -t -assume -that -' -initial -' -or -' -middle -' -will -be -populated -! -/ -/ -/ -assert_eq -! -( -None -caps -. -name -( -" -initial -" -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -) -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Some -( -& -b -" -James -" -[ -. -. -] -) -/ -/ -/ -caps -. -name -( -" -middle -" -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -/ -/ -/ -) -; -/ -/ -/ -assert_eq -! -( -& -b -" -Potter -" -[ -. -. -] -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -pub -fn -ignore_whitespace -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -ignore_whitespace -( -yes -) -; -self -} -/ -/ -/ -This -configures -octal -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Octal -syntax -is -a -little -- -known -way -of -uttering -Unicode -codepoints -/ -/ -/ -in -a -pattern -. -For -example -a -\ -x61 -\ -u0061 -and -\ -141 -are -all -/ -/ -/ -equivalent -patterns -where -the -last -example -shows -octal -syntax -. -/ -/ -/ -/ -/ -/ -While -supporting -octal -syntax -isn -' -t -in -and -of -itself -a -problem -/ -/ -/ -it -does -make -good -error -messages -harder -. -That -is -in -PCRE -based -/ -/ -/ -regex -engines -syntax -like -\ -1 -invokes -a -backreference -which -is -/ -/ -/ -explicitly -unsupported -this -library -. -However -many -users -expect -/ -/ -/ -backreferences -to -be -supported -. -Therefore -when -octal -support -/ -/ -/ -is -disabled -the -error -message -will -explicitly -mention -that -/ -/ -/ -backreferences -aren -' -t -supported -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -/ -/ -Normally -this -pattern -would -not -compile -with -an -error -message -/ -/ -/ -/ -/ -about -backreferences -not -being -supported -. -But -with -octal -mode -/ -/ -/ -/ -/ -enabled -octal -escape -sequences -work -. -/ -/ -/ -let -re -= -RegexBuilder -: -: -new -( -r -" -\ -141 -" -) -/ -/ -/ -. -octal -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -a -" -) -) -; -/ -/ -/ -pub -fn -octal -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -octal -( -yes -) -; -self -} -/ -/ -/ -Sets -the -approximate -size -limit -in -bytes -of -the -compiled -regex -. -/ -/ -/ -/ -/ -/ -This -roughly -corresponds -to -the -number -of -heap -memory -in -/ -/ -/ -bytes -occupied -by -a -single -regex -. -If -the -regex -would -otherwise -/ -/ -/ -approximately -exceed -this -limit -then -compiling -that -regex -will -/ -/ -/ -fail -. -/ -/ -/ -/ -/ -/ -The -main -utility -of -a -method -like -this -is -to -avoid -compiling -/ -/ -/ -regexes -that -use -an -unexpected -amount -of -resources -such -as -/ -/ -/ -time -and -memory -. -Even -if -the -memory -usage -of -a -large -regex -is -/ -/ -/ -acceptable -its -search -time -may -not -be -. -Namely -worst -case -time -/ -/ -/ -complexity -for -search -is -O -( -m -* -n -) -where -m -~ -len -( -pattern -) -and -/ -/ -/ -n -~ -len -( -haystack -) -. -That -is -search -time -depends -in -part -on -the -/ -/ -/ -size -of -the -compiled -regex -. -This -means -that -putting -a -limit -on -the -/ -/ -/ -size -of -the -regex -limits -how -much -a -regex -can -impact -search -time -. -/ -/ -/ -/ -/ -/ -For -more -information -about -regex -size -limits -see -the -section -on -/ -/ -/ -[ -untrusted -inputs -] -( -crate -# -untrusted -- -input -) -in -the -top -- -level -crate -/ -/ -/ -documentation -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -some -reasonable -number -that -permits -most -/ -/ -/ -patterns -to -compile -successfully -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -/ -/ -It -may -surprise -you -how -big -some -seemingly -small -patterns -can -/ -/ -/ -/ -/ -be -! -Since -\ -w -is -Unicode -aware -this -generates -a -regex -that -can -/ -/ -/ -/ -/ -match -approximately -140 -000 -distinct -codepoints -. -/ -/ -/ -assert -! -( -RegexBuilder -: -: -new -( -r -" -\ -w -" -) -. -size_limit -( -45_000 -) -. -build -( -) -. -is_err -( -) -) -; -/ -/ -/ -pub -fn -size_limit -( -& -mut -self -bytes -: -usize -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -size_limit -( -bytes -) -; -self -} -/ -/ -/ -Set -the -approximate -capacity -in -bytes -of -the -cache -of -transitions -/ -/ -/ -used -by -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -While -the -lazy -DFA -isn -' -t -always -used -in -tends -to -be -the -most -/ -/ -/ -commonly -use -regex -engine -in -default -configurations -. -It -tends -to -/ -/ -/ -adopt -the -performance -profile -of -a -fully -build -DFA -but -without -the -/ -/ -/ -downside -of -taking -worst -case -exponential -time -to -build -. -/ -/ -/ -/ -/ -/ -The -downside -is -that -it -needs -to -keep -a -cache -of -transitions -and -/ -/ -/ -states -that -are -built -while -running -a -search -and -this -cache -/ -/ -/ -can -fill -up -. -When -it -fills -up -the -cache -will -reset -itself -. -Any -/ -/ -/ -previously -generated -states -and -transitions -will -then -need -to -be -/ -/ -/ -re -- -generated -. -If -this -happens -too -many -times -then -this -library -/ -/ -/ -will -bail -out -of -using -the -lazy -DFA -and -switch -to -a -different -regex -/ -/ -/ -engine -. -/ -/ -/ -/ -/ -/ -If -your -regex -provokes -this -particular -downside -of -the -lazy -DFA -/ -/ -/ -then -it -may -be -beneficial -to -increase -its -cache -capacity -. -This -will -/ -/ -/ -potentially -reduce -the -frequency -of -cache -resetting -( -ideally -to -/ -/ -/ -0 -) -. -While -it -won -' -t -fix -all -potential -performance -problems -with -/ -/ -/ -the -lazy -DFA -increasing -the -cache -capacity -does -fix -some -. -/ -/ -/ -/ -/ -/ -There -is -no -easy -way -to -determine -a -priori -whether -increasing -/ -/ -/ -this -cache -capacity -will -help -. -In -general -the -larger -your -regex -/ -/ -/ -the -more -cache -it -' -s -likely -to -use -. -But -that -isn -' -t -an -ironclad -rule -. -/ -/ -/ -For -example -a -regex -like -[ -01 -] -* -1 -[ -01 -] -{ -N -} -would -normally -produce -a -/ -/ -/ -fully -build -DFA -that -is -exponential -in -size -with -respect -to -N -. -/ -/ -/ -The -lazy -DFA -will -prevent -exponential -space -blow -- -up -but -it -cache -/ -/ -/ -is -likely -to -fill -up -even -when -it -' -s -large -and -even -for -smallish -/ -/ -/ -values -of -N -. -/ -/ -/ -/ -/ -/ -If -you -aren -' -t -sure -whether -this -helps -or -not -it -is -sensible -to -/ -/ -/ -set -this -to -some -arbitrarily -large -number -in -testing -such -as -/ -/ -/ -usize -: -: -MAX -. -Namely -this -represents -the -amount -of -capacity -that -/ -/ -/ -* -may -* -be -used -. -It -' -s -probably -not -a -good -idea -to -use -usize -: -: -MAX -in -/ -/ -/ -production -though -since -it -implies -there -are -no -controls -on -heap -/ -/ -/ -memory -used -by -this -library -during -a -search -. -In -effect -set -it -to -/ -/ -/ -whatever -you -' -re -willing -to -allocate -for -a -single -regex -search -. -pub -fn -dfa_size_limit -( -& -mut -self -bytes -: -usize -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -dfa_size_limit -( -bytes -) -; -self -} -/ -/ -/ -Set -the -nesting -limit -for -this -parser -. -/ -/ -/ -/ -/ -/ -The -nesting -limit -controls -how -deep -the -abstract -syntax -tree -is -/ -/ -/ -allowed -to -be -. -If -the -AST -exceeds -the -given -limit -( -e -. -g -. -with -too -/ -/ -/ -many -nested -groups -) -then -an -error -is -returned -by -the -parser -. -/ -/ -/ -/ -/ -/ -The -purpose -of -this -limit -is -to -act -as -a -heuristic -to -prevent -stack -/ -/ -/ -overflow -for -consumers -that -do -structural -induction -on -an -AST -using -/ -/ -/ -explicit -recursion -. -While -this -crate -never -does -this -( -instead -using -/ -/ -/ -constant -stack -space -and -moving -the -call -stack -to -the -heap -) -other -/ -/ -/ -crates -may -. -/ -/ -/ -/ -/ -/ -This -limit -is -not -checked -until -the -entire -AST -is -parsed -. -/ -/ -/ -Therefore -if -callers -want -to -put -a -limit -on -the -amount -of -heap -/ -/ -/ -space -used -then -they -should -impose -a -limit -on -the -length -in -/ -/ -/ -bytes -of -the -concrete -pattern -string -. -In -particular -this -is -/ -/ -/ -viable -since -this -parser -implementation -will -limit -itself -to -heap -/ -/ -/ -space -proportional -to -the -length -of -the -pattern -string -. -See -also -/ -/ -/ -the -[ -untrusted -inputs -] -( -crate -# -untrusted -- -input -) -section -in -the -/ -/ -/ -top -- -level -crate -documentation -for -more -information -about -this -. -/ -/ -/ -/ -/ -/ -Note -that -a -nest -limit -of -0 -will -return -a -nest -limit -error -for -/ -/ -/ -most -patterns -but -not -all -. -For -example -a -nest -limit -of -0 -permits -/ -/ -/ -a -but -not -ab -since -ab -requires -an -explicit -concatenation -/ -/ -/ -which -results -in -a -nest -depth -of -1 -. -In -general -a -nest -limit -is -/ -/ -/ -not -something -that -manifests -in -an -obvious -way -in -the -concrete -/ -/ -/ -syntax -therefore -it -should -not -be -used -in -a -granular -way -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexBuilder -; -/ -/ -/ -/ -/ -/ -assert -! -( -RegexBuilder -: -: -new -( -r -" -a -" -) -. -nest_limit -( -0 -) -. -build -( -) -. -is_ok -( -) -) -; -/ -/ -/ -assert -! -( -RegexBuilder -: -: -new -( -r -" -ab -" -) -. -nest_limit -( -0 -) -. -build -( -) -. -is_err -( -) -) -; -/ -/ -/ -pub -fn -nest_limit -( -& -mut -self -limit -: -u32 -) -- -> -& -mut -RegexBuilder -{ -self -. -builder -. -nest_limit -( -limit -) -; -self -} -} -/ -/ -/ -A -configurable -builder -for -a -[ -RegexSet -] -. -/ -/ -/ -/ -/ -/ -This -builder -can -be -used -to -programmatically -set -flags -such -as -i -/ -/ -/ -( -case -insensitive -) -and -x -( -for -verbose -mode -) -. -This -builder -can -also -be -/ -/ -/ -used -to -configure -things -like -the -line -terminator -and -a -size -limit -on -/ -/ -/ -the -compiled -regular -expression -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -RegexSetBuilder -{ -builder -: -Builder -} -impl -RegexSetBuilder -{ -/ -/ -/ -Create -a -new -builder -with -a -default -configuration -for -the -given -/ -/ -/ -patterns -. -/ -/ -/ -/ -/ -/ -If -the -patterns -are -invalid -or -exceed -the -configured -size -limits -/ -/ -/ -then -an -error -will -be -returned -when -[ -RegexSetBuilder -: -: -build -] -is -/ -/ -/ -called -. -pub -fn -new -< -I -S -> -( -patterns -: -I -) -- -> -RegexSetBuilder -where -I -: -IntoIterator -< -Item -= -S -> -S -: -AsRef -< -str -> -{ -RegexSetBuilder -{ -builder -: -Builder -: -: -new -( -patterns -) -} -} -/ -/ -/ -Compiles -the -patterns -given -to -RegexSetBuilder -: -: -new -with -the -/ -/ -/ -configuration -set -on -this -builder -. -/ -/ -/ -/ -/ -/ -If -the -patterns -aren -' -t -valid -regexes -or -if -a -configured -size -limit -/ -/ -/ -was -exceeded -then -an -error -is -returned -. -pub -fn -build -( -& -self -) -- -> -Result -< -RegexSet -Error -> -{ -self -. -builder -. -build_many_bytes -( -) -} -/ -/ -/ -This -configures -Unicode -mode -for -the -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -Enabling -Unicode -mode -does -a -number -of -things -: -/ -/ -/ -/ -/ -/ -* -Most -fundamentally -it -causes -the -fundamental -atom -of -matching -/ -/ -/ -to -be -a -single -codepoint -. -When -Unicode -mode -is -disabled -it -' -s -a -/ -/ -/ -single -byte -. -For -example -when -Unicode -mode -is -enabled -. -will -/ -/ -/ -match -once -where -as -it -will -match -4 -times -when -Unicode -mode -/ -/ -/ -is -disabled -. -( -Since -the -UTF -- -8 -encoding -of -is -4 -bytes -long -. -) -/ -/ -/ -* -Case -insensitive -matching -uses -Unicode -simple -case -folding -rules -. -/ -/ -/ -* -Unicode -character -classes -like -\ -p -{ -Letter -} -and -\ -p -{ -Greek -} -are -/ -/ -/ -available -. -/ -/ -/ -* -Perl -character -classes -are -Unicode -aware -. -That -is -\ -w -\ -s -and -/ -/ -/ -\ -d -. -/ -/ -/ -* -The -word -boundary -assertions -\ -b -and -\ -B -use -the -Unicode -/ -/ -/ -definition -of -a -word -character -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -the -top -- -level -RegexSet -for -searching -& -str -/ -/ -/ -it -is -permitted -to -disable -Unicode -mode -even -if -the -resulting -/ -/ -/ -pattern -could -match -invalid -UTF -- -8 -. -For -example -( -? -- -u -: -. -) -is -not -/ -/ -/ -a -valid -pattern -for -a -top -- -level -RegexSet -but -is -valid -for -a -/ -/ -/ -bytes -: -: -RegexSet -. -/ -/ -/ -/ -/ -/ -For -more -details -on -the -Unicode -support -in -this -crate -see -the -/ -/ -/ -[ -Unicode -section -] -( -crate -# -unicode -) -in -this -crate -' -s -top -- -level -/ -/ -/ -documentation -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -true -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -\ -w -" -] -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -greek -letters -would -be -included -in -\ -w -but -since -/ -/ -/ -/ -/ -Unicode -mode -is -disabled -it -only -matches -ASCII -letters -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -" -. -as_bytes -( -) -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -s -" -] -) -/ -/ -/ -. -case_insensitive -( -true -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -' -' -is -included -when -searching -for -' -s -' -case -/ -/ -/ -/ -/ -insensitively -due -to -Unicode -' -s -simple -case -folding -rules -. -But -/ -/ -/ -/ -/ -when -Unicode -mode -is -disabled -only -ASCII -case -insensitive -rules -/ -/ -/ -/ -/ -are -used -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -" -" -. -as_bytes -( -) -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Since -this -builder -is -for -constructing -a -/ -/ -/ -[ -bytes -: -: -RegexSet -] -( -RegexSet -) -one -can -disable -Unicode -mode -even -if -/ -/ -/ -it -would -match -invalid -UTF -- -8 -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -. -" -] -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Normally -greek -letters -would -be -included -in -\ -w -but -since -/ -/ -/ -/ -/ -Unicode -mode -is -disabled -it -only -matches -ASCII -letters -. -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -\ -xFF -" -) -) -; -/ -/ -/ -pub -fn -unicode -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -unicode -( -yes -) -; -self -} -/ -/ -/ -This -configures -whether -to -enable -case -insensitive -matching -for -all -/ -/ -/ -of -the -patterns -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -i -/ -/ -/ -in -the -pattern -. -For -example -( -? -i -: -foo -) -matches -foo -case -/ -/ -/ -insensitively -while -( -? -- -i -: -foo -) -matches -foo -case -sensitively -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -foo -( -? -- -i -: -bar -) -quux -" -] -) -/ -/ -/ -. -case_insensitive -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -FoObarQuUx -" -) -) -; -/ -/ -/ -/ -/ -Even -though -case -insensitive -matching -is -enabled -in -the -builder -/ -/ -/ -/ -/ -it -can -be -locally -disabled -within -the -pattern -. -In -this -case -/ -/ -/ -/ -/ -bar -is -matched -case -sensitively -. -/ -/ -/ -assert -! -( -! -re -. -is_match -( -b -" -fooBARquux -" -) -) -; -/ -/ -/ -pub -fn -case_insensitive -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -case_insensitive -( -yes -) -; -self -} -/ -/ -/ -This -configures -multi -- -line -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -Enabling -multi -- -line -mode -changes -the -behavior -of -the -^ -and -/ -/ -/ -anchor -assertions -. -Instead -of -only -matching -at -the -beginning -and -/ -/ -/ -end -of -a -haystack -respectively -multi -- -line -mode -causes -them -to -/ -/ -/ -match -at -the -beginning -and -end -of -a -line -* -in -addition -* -to -the -/ -/ -/ -beginning -and -end -of -a -haystack -. -More -precisely -^ -will -match -at -/ -/ -/ -the -position -immediately -following -a -\ -n -and -will -match -at -the -/ -/ -/ -position -immediately -preceding -a -\ -n -. -/ -/ -/ -/ -/ -/ -The -behavior -of -this -option -can -be -impacted -by -other -settings -too -: -/ -/ -/ -/ -/ -/ -* -The -[ -RegexSetBuilder -: -: -line_terminator -] -option -changes -\ -n -/ -/ -/ -above -to -any -ASCII -byte -. -/ -/ -/ -* -The -[ -RegexSetBuilder -: -: -crlf -] -option -changes -the -line -terminator -/ -/ -/ -to -be -either -\ -r -or -\ -n -but -never -at -the -position -between -a -\ -r -/ -/ -/ -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -m -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -^ -foo -" -] -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -\ -nfoo -\ -n -" -) -) -; -/ -/ -/ -pub -fn -multi_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -multi_line -( -yes -) -; -self -} -/ -/ -/ -This -configures -dot -- -matches -- -new -- -line -mode -for -the -entire -pattern -. -/ -/ -/ -/ -/ -/ -Perhaps -surprisingly -the -default -behavior -for -. -is -not -to -match -/ -/ -/ -any -character -but -rather -to -match -any -character -except -for -the -/ -/ -/ -line -terminator -( -which -is -\ -n -by -default -) -. -When -this -mode -is -/ -/ -/ -enabled -the -behavior -changes -such -that -. -truly -matches -any -/ -/ -/ -character -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -s -in -/ -/ -/ -the -pattern -. -For -example -( -? -s -: -. -) -and -\ -p -{ -any -} -are -equivalent -/ -/ -/ -regexes -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -foo -. -bar -" -] -) -/ -/ -/ -. -dot_matches_new_line -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -foo -\ -nbar -" -; -/ -/ -/ -assert -! -( -re -. -is_match -( -hay -) -) -; -/ -/ -/ -pub -fn -dot_matches_new_line -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -dot_matches_new_line -( -yes -) -; -self -} -/ -/ -/ -This -configures -CRLF -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -When -CRLF -mode -is -enabled -both -\ -r -( -" -carriage -return -" -or -CR -for -/ -/ -/ -short -) -and -\ -n -( -" -line -feed -" -or -LF -for -short -) -are -treated -as -line -/ -/ -/ -terminators -. -This -results -in -the -following -: -/ -/ -/ -/ -/ -/ -* -Unless -dot -- -matches -- -new -- -line -mode -is -enabled -. -will -now -match -/ -/ -/ -any -character -except -for -\ -n -and -\ -r -. -/ -/ -/ -* -When -multi -- -line -mode -is -enabled -^ -will -match -immediately -/ -/ -/ -following -a -\ -n -or -a -\ -r -. -Similarly -will -match -immediately -/ -/ -/ -preceding -a -\ -n -or -a -\ -r -. -Neither -^ -nor -will -ever -match -/ -/ -/ -between -\ -r -and -\ -n -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -R -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -^ -foo -" -] -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -crlf -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -\ -r -\ -nfoo -\ -r -\ -n -" -; -/ -/ -/ -/ -/ -If -CRLF -mode -weren -' -t -enabled -here -then -' -' -wouldn -' -t -match -/ -/ -/ -/ -/ -immediately -after -' -foo -' -and -thus -no -match -would -be -found -. -/ -/ -/ -assert -! -( -re -. -is_match -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -demonstrates -that -^ -will -never -match -at -a -position -/ -/ -/ -between -\ -r -and -\ -n -. -( -will -similarly -not -match -between -a -\ -r -/ -/ -/ -and -a -\ -n -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -^ -\ -n -" -] -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -crlf -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -b -" -\ -r -\ -n -" -) -) -; -/ -/ -/ -pub -fn -crlf -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -crlf -( -yes -) -; -self -} -/ -/ -/ -Configures -the -line -terminator -to -be -used -by -the -regex -. -/ -/ -/ -/ -/ -/ -The -line -terminator -is -relevant -in -two -ways -for -a -particular -regex -: -/ -/ -/ -/ -/ -/ -* -When -dot -- -matches -- -new -- -line -mode -is -* -not -* -enabled -( -the -default -) -/ -/ -/ -then -. -will -match -any -character -except -for -the -configured -line -/ -/ -/ -terminator -. -/ -/ -/ -* -When -multi -- -line -mode -is -enabled -( -not -the -default -) -then -^ -and -/ -/ -/ -will -match -immediately -after -and -before -respectively -a -line -/ -/ -/ -terminator -. -/ -/ -/ -/ -/ -/ -In -both -cases -if -CRLF -mode -is -enabled -in -a -particular -context -/ -/ -/ -then -it -takes -precedence -over -any -configured -line -terminator -. -/ -/ -/ -/ -/ -/ -This -option -cannot -be -configured -from -within -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -line -terminator -is -\ -n -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -to -treat -the -NUL -byte -as -a -line -terminator -. -This -can -/ -/ -/ -be -a -useful -heuristic -when -searching -binary -data -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -^ -foo -" -] -) -/ -/ -/ -. -multi_line -( -true -) -/ -/ -/ -. -line_terminator -( -b -' -\ -x00 -' -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -\ -x00foo -\ -x00 -" -; -/ -/ -/ -assert -! -( -re -. -is_match -( -hay -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -example -shows -that -the -behavior -of -. -is -impacted -by -this -/ -/ -/ -setting -as -well -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -. -" -] -) -/ -/ -/ -. -line_terminator -( -b -' -\ -x00 -' -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -\ -n -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -b -" -\ -x00 -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -shows -that -building -a -regex -will -work -even -when -the -byte -given -/ -/ -/ -is -not -ASCII -. -This -is -unlike -the -top -- -level -RegexSet -API -where -/ -/ -/ -matching -invalid -UTF -- -8 -is -not -allowed -. -/ -/ -/ -/ -/ -/ -Note -though -that -you -must -disable -Unicode -mode -. -This -is -required -/ -/ -/ -because -Unicode -mode -requires -matching -one -codepoint -at -a -time -/ -/ -/ -and -there -is -no -way -to -match -a -non -- -ASCII -byte -as -if -it -were -a -/ -/ -/ -codepoint -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -assert -! -( -/ -/ -/ -RegexSetBuilder -: -: -new -( -[ -r -" -. -" -] -) -/ -/ -/ -. -unicode -( -false -) -/ -/ -/ -. -line_terminator -( -0x80 -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -is_ok -( -) -/ -/ -/ -) -; -/ -/ -/ -pub -fn -line_terminator -( -& -mut -self -byte -: -u8 -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -line_terminator -( -byte -) -; -self -} -/ -/ -/ -This -configures -swap -- -greed -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -When -swap -- -greed -mode -is -enabled -patterns -like -a -+ -will -become -/ -/ -/ -non -- -greedy -and -patterns -like -a -+ -? -will -become -greedy -. -In -other -/ -/ -/ -words -the -meanings -of -a -+ -and -a -+ -? -are -switched -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -U -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -Note -that -this -is -generally -not -useful -for -a -RegexSet -since -a -/ -/ -/ -RegexSet -can -only -report -whether -a -pattern -matches -or -not -. -Since -/ -/ -/ -greediness -never -impacts -whether -a -match -is -found -or -not -( -only -the -/ -/ -/ -offsets -of -the -match -) -it -follows -that -whether -parts -of -a -pattern -/ -/ -/ -are -greedy -or -not -doesn -' -t -matter -for -a -RegexSet -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -pub -fn -swap_greed -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -swap_greed -( -yes -) -; -self -} -/ -/ -/ -This -configures -verbose -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -When -enabled -whitespace -will -treated -as -insignifcant -in -the -/ -/ -/ -pattern -and -# -can -be -used -to -start -a -comment -until -the -next -new -/ -/ -/ -line -. -/ -/ -/ -/ -/ -/ -Normally -in -most -places -in -a -pattern -whitespace -is -treated -/ -/ -/ -literally -. -For -example -+ -will -match -one -or -more -ASCII -whitespace -/ -/ -/ -characters -. -/ -/ -/ -/ -/ -/ -When -verbose -mode -is -enabled -\ -# -can -be -used -to -match -a -literal -/ -/ -/ -# -and -\ -can -be -used -to -match -a -literal -ASCII -whitespace -/ -/ -/ -character -. -/ -/ -/ -/ -/ -/ -Verbose -mode -is -useful -for -permitting -regexes -to -be -formatted -and -/ -/ -/ -broken -up -more -nicely -. -This -may -make -them -more -easily -readable -. -/ -/ -/ -/ -/ -/ -This -setting -can -also -be -configured -using -the -inline -flag -x -in -/ -/ -/ -the -pattern -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -let -pat -= -r -" -/ -/ -/ -\ -b -/ -/ -/ -( -? -< -first -> -\ -p -{ -Uppercase -} -\ -w -* -) -# -always -start -with -uppercase -letter -/ -/ -/ -[ -\ -s -- -- -\ -n -] -+ -# -whitespace -should -separate -names -/ -/ -/ -( -? -: -# -middle -name -can -be -an -initial -! -/ -/ -/ -( -? -: -( -? -< -initial -> -\ -p -{ -Uppercase -} -) -\ -. -| -( -? -< -middle -> -\ -p -{ -Uppercase -} -\ -w -* -) -) -/ -/ -/ -[ -\ -s -- -- -\ -n -] -+ -/ -/ -/ -) -? -/ -/ -/ -( -? -< -last -> -\ -p -{ -Uppercase -} -\ -w -* -) -/ -/ -/ -\ -b -/ -/ -/ -" -; -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -pat -] -) -/ -/ -/ -. -ignore_whitespace -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -Harry -Potter -" -) -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -Harry -J -. -Potter -" -) -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -Harry -James -Potter -" -) -) -; -/ -/ -/ -assert -! -( -! -re -. -is_match -( -b -" -harry -J -. -Potter -" -) -) -; -/ -/ -/ -pub -fn -ignore_whitespace -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -ignore_whitespace -( -yes -) -; -self -} -/ -/ -/ -This -configures -octal -mode -for -all -of -the -patterns -. -/ -/ -/ -/ -/ -/ -Octal -syntax -is -a -little -- -known -way -of -uttering -Unicode -codepoints -/ -/ -/ -in -a -pattern -. -For -example -a -\ -x61 -\ -u0061 -and -\ -141 -are -all -/ -/ -/ -equivalent -patterns -where -the -last -example -shows -octal -syntax -. -/ -/ -/ -/ -/ -/ -While -supporting -octal -syntax -isn -' -t -in -and -of -itself -a -problem -/ -/ -/ -it -does -make -good -error -messages -harder -. -That -is -in -PCRE -based -/ -/ -/ -regex -engines -syntax -like -\ -1 -invokes -a -backreference -which -is -/ -/ -/ -explicitly -unsupported -this -library -. -However -many -users -expect -/ -/ -/ -backreferences -to -be -supported -. -Therefore -when -octal -support -/ -/ -/ -is -disabled -the -error -message -will -explicitly -mention -that -/ -/ -/ -backreferences -aren -' -t -supported -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -false -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -/ -/ -Normally -this -pattern -would -not -compile -with -an -error -message -/ -/ -/ -/ -/ -about -backreferences -not -being -supported -. -But -with -octal -mode -/ -/ -/ -/ -/ -enabled -octal -escape -sequences -work -. -/ -/ -/ -let -re -= -RegexSetBuilder -: -: -new -( -[ -r -" -\ -141 -" -] -) -/ -/ -/ -. -octal -( -true -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -re -. -is_match -( -b -" -a -" -) -) -; -/ -/ -/ -pub -fn -octal -( -& -mut -self -yes -: -bool -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -octal -( -yes -) -; -self -} -/ -/ -/ -Sets -the -approximate -size -limit -in -bytes -of -the -compiled -regex -. -/ -/ -/ -/ -/ -/ -This -roughly -corresponds -to -the -number -of -heap -memory -in -/ -/ -/ -bytes -occupied -by -a -single -regex -. -If -the -regex -would -otherwise -/ -/ -/ -approximately -exceed -this -limit -then -compiling -that -regex -will -/ -/ -/ -fail -. -/ -/ -/ -/ -/ -/ -The -main -utility -of -a -method -like -this -is -to -avoid -compiling -/ -/ -/ -regexes -that -use -an -unexpected -amount -of -resources -such -as -/ -/ -/ -time -and -memory -. -Even -if -the -memory -usage -of -a -large -regex -is -/ -/ -/ -acceptable -its -search -time -may -not -be -. -Namely -worst -case -time -/ -/ -/ -complexity -for -search -is -O -( -m -* -n -) -where -m -~ -len -( -pattern -) -and -/ -/ -/ -n -~ -len -( -haystack -) -. -That -is -search -time -depends -in -part -on -the -/ -/ -/ -size -of -the -compiled -regex -. -This -means -that -putting -a -limit -on -the -/ -/ -/ -size -of -the -regex -limits -how -much -a -regex -can -impact -search -time -. -/ -/ -/ -/ -/ -/ -For -more -information -about -regex -size -limits -see -the -section -on -/ -/ -/ -[ -untrusted -inputs -] -( -crate -# -untrusted -- -input -) -in -the -top -- -level -crate -/ -/ -/ -documentation -. -/ -/ -/ -/ -/ -/ -The -default -for -this -is -some -reasonable -number -that -permits -most -/ -/ -/ -patterns -to -compile -successfully -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -/ -/ -It -may -surprise -you -how -big -some -seemingly -small -patterns -can -/ -/ -/ -/ -/ -be -! -Since -\ -w -is -Unicode -aware -this -generates -a -regex -that -can -/ -/ -/ -/ -/ -match -approximately -140 -000 -distinct -codepoints -. -/ -/ -/ -assert -! -( -/ -/ -/ -RegexSetBuilder -: -: -new -( -[ -r -" -\ -w -" -] -) -/ -/ -/ -. -size_limit -( -45_000 -) -/ -/ -/ -. -build -( -) -/ -/ -/ -. -is_err -( -) -/ -/ -/ -) -; -/ -/ -/ -pub -fn -size_limit -( -& -mut -self -bytes -: -usize -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -size_limit -( -bytes -) -; -self -} -/ -/ -/ -Set -the -approximate -capacity -in -bytes -of -the -cache -of -transitions -/ -/ -/ -used -by -the -lazy -DFA -. -/ -/ -/ -/ -/ -/ -While -the -lazy -DFA -isn -' -t -always -used -in -tends -to -be -the -most -/ -/ -/ -commonly -use -regex -engine -in -default -configurations -. -It -tends -to -/ -/ -/ -adopt -the -performance -profile -of -a -fully -build -DFA -but -without -the -/ -/ -/ -downside -of -taking -worst -case -exponential -time -to -build -. -/ -/ -/ -/ -/ -/ -The -downside -is -that -it -needs -to -keep -a -cache -of -transitions -and -/ -/ -/ -states -that -are -built -while -running -a -search -and -this -cache -/ -/ -/ -can -fill -up -. -When -it -fills -up -the -cache -will -reset -itself -. -Any -/ -/ -/ -previously -generated -states -and -transitions -will -then -need -to -be -/ -/ -/ -re -- -generated -. -If -this -happens -too -many -times -then -this -library -/ -/ -/ -will -bail -out -of -using -the -lazy -DFA -and -switch -to -a -different -regex -/ -/ -/ -engine -. -/ -/ -/ -/ -/ -/ -If -your -regex -provokes -this -particular -downside -of -the -lazy -DFA -/ -/ -/ -then -it -may -be -beneficial -to -increase -its -cache -capacity -. -This -will -/ -/ -/ -potentially -reduce -the -frequency -of -cache -resetting -( -ideally -to -/ -/ -/ -0 -) -. -While -it -won -' -t -fix -all -potential -performance -problems -with -/ -/ -/ -the -lazy -DFA -increasing -the -cache -capacity -does -fix -some -. -/ -/ -/ -/ -/ -/ -There -is -no -easy -way -to -determine -a -priori -whether -increasing -/ -/ -/ -this -cache -capacity -will -help -. -In -general -the -larger -your -regex -/ -/ -/ -the -more -cache -it -' -s -likely -to -use -. -But -that -isn -' -t -an -ironclad -rule -. -/ -/ -/ -For -example -a -regex -like -[ -01 -] -* -1 -[ -01 -] -{ -N -} -would -normally -produce -a -/ -/ -/ -fully -build -DFA -that -is -exponential -in -size -with -respect -to -N -. -/ -/ -/ -The -lazy -DFA -will -prevent -exponential -space -blow -- -up -but -it -cache -/ -/ -/ -is -likely -to -fill -up -even -when -it -' -s -large -and -even -for -smallish -/ -/ -/ -values -of -N -. -/ -/ -/ -/ -/ -/ -If -you -aren -' -t -sure -whether -this -helps -or -not -it -is -sensible -to -/ -/ -/ -set -this -to -some -arbitrarily -large -number -in -testing -such -as -/ -/ -/ -usize -: -: -MAX -. -Namely -this -represents -the -amount -of -capacity -that -/ -/ -/ -* -may -* -be -used -. -It -' -s -probably -not -a -good -idea -to -use -usize -: -: -MAX -in -/ -/ -/ -production -though -since -it -implies -there -are -no -controls -on -heap -/ -/ -/ -memory -used -by -this -library -during -a -search -. -In -effect -set -it -to -/ -/ -/ -whatever -you -' -re -willing -to -allocate -for -a -single -regex -search -. -pub -fn -dfa_size_limit -( -& -mut -self -bytes -: -usize -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -dfa_size_limit -( -bytes -) -; -self -} -/ -/ -/ -Set -the -nesting -limit -for -this -parser -. -/ -/ -/ -/ -/ -/ -The -nesting -limit -controls -how -deep -the -abstract -syntax -tree -is -/ -/ -/ -allowed -to -be -. -If -the -AST -exceeds -the -given -limit -( -e -. -g -. -with -too -/ -/ -/ -many -nested -groups -) -then -an -error -is -returned -by -the -parser -. -/ -/ -/ -/ -/ -/ -The -purpose -of -this -limit -is -to -act -as -a -heuristic -to -prevent -stack -/ -/ -/ -overflow -for -consumers -that -do -structural -induction -on -an -AST -using -/ -/ -/ -explicit -recursion -. -While -this -crate -never -does -this -( -instead -using -/ -/ -/ -constant -stack -space -and -moving -the -call -stack -to -the -heap -) -other -/ -/ -/ -crates -may -. -/ -/ -/ -/ -/ -/ -This -limit -is -not -checked -until -the -entire -AST -is -parsed -. -/ -/ -/ -Therefore -if -callers -want -to -put -a -limit -on -the -amount -of -heap -/ -/ -/ -space -used -then -they -should -impose -a -limit -on -the -length -in -/ -/ -/ -bytes -of -the -concrete -pattern -string -. -In -particular -this -is -/ -/ -/ -viable -since -this -parser -implementation -will -limit -itself -to -heap -/ -/ -/ -space -proportional -to -the -length -of -the -pattern -string -. -See -also -/ -/ -/ -the -[ -untrusted -inputs -] -( -crate -# -untrusted -- -input -) -section -in -the -/ -/ -/ -top -- -level -crate -documentation -for -more -information -about -this -. -/ -/ -/ -/ -/ -/ -Note -that -a -nest -limit -of -0 -will -return -a -nest -limit -error -for -/ -/ -/ -most -patterns -but -not -all -. -For -example -a -nest -limit -of -0 -permits -/ -/ -/ -a -but -not -ab -since -ab -requires -an -explicit -concatenation -/ -/ -/ -which -results -in -a -nest -depth -of -1 -. -In -general -a -nest -limit -is -/ -/ -/ -not -something -that -manifests -in -an -obvious -way -in -the -concrete -/ -/ -/ -syntax -therefore -it -should -not -be -used -in -a -granular -way -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSetBuilder -; -/ -/ -/ -/ -/ -/ -assert -! -( -RegexSetBuilder -: -: -new -( -[ -r -" -a -" -] -) -. -nest_limit -( -0 -) -. -build -( -) -. -is_ok -( -) -) -; -/ -/ -/ -assert -! -( -RegexSetBuilder -: -: -new -( -[ -r -" -ab -" -] -) -. -nest_limit -( -0 -) -. -build -( -) -. -is_err -( -) -) -; -/ -/ -/ -pub -fn -nest_limit -( -& -mut -self -limit -: -u32 -) -- -> -& -mut -RegexSetBuilder -{ -self -. -builder -. -nest_limit -( -limit -) -; -self -} -} -} diff --git a/third_party/rust/regex/src/bytes.rs b/third_party/rust/regex/src/bytes.rs deleted file mode 100644 index df5e4298d3356..0000000000000 --- a/third_party/rust/regex/src/bytes.rs +++ /dev/null @@ -1,972 +0,0 @@ -/ -* -! -Search -for -regex -matches -in -& -[ -u8 -] -haystacks -. -This -module -provides -a -nearly -identical -API -via -[ -Regex -] -to -the -one -found -in -the -top -- -level -of -this -crate -. -There -are -two -important -differences -: -1 -. -Matching -is -done -on -& -[ -u8 -] -instead -of -& -str -. -Additionally -Vec -< -u8 -> -is -used -where -String -would -have -been -used -in -the -top -- -level -API -. -2 -. -Unicode -support -can -be -disabled -even -when -disabling -it -would -result -in -matching -invalid -UTF -- -8 -bytes -. -# -Example -: -match -null -terminated -string -This -shows -how -to -find -all -null -- -terminated -strings -in -a -slice -of -bytes -. -This -works -even -if -a -C -string -contains -invalid -UTF -- -8 -. -rust -use -regex -: -: -bytes -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -( -? -- -u -) -( -? -< -cstr -> -[ -^ -\ -x00 -] -+ -) -\ -x00 -" -) -. -unwrap -( -) -; -let -hay -= -b -" -foo -\ -x00qu -\ -xFFux -\ -x00baz -\ -x00 -" -; -/ -/ -Extract -all -of -the -strings -without -the -NUL -terminator -from -each -match -. -/ -/ -The -unwrap -is -OK -here -since -a -match -requires -the -cstr -capture -to -match -. -let -cstrs -: -Vec -< -& -[ -u8 -] -> -= -re -. -captures_iter -( -hay -) -. -map -( -| -c -| -c -. -name -( -" -cstr -" -) -. -unwrap -( -) -. -as_bytes -( -) -) -. -collect -( -) -; -assert_eq -! -( -cstrs -vec -! -[ -& -b -" -foo -" -[ -. -. -] -& -b -" -qu -\ -xFFux -" -[ -. -. -] -& -b -" -baz -" -[ -. -. -] -] -) -; -# -Example -: -selectively -enable -Unicode -support -This -shows -how -to -match -an -arbitrary -byte -pattern -followed -by -a -UTF -- -8 -encoded -string -( -e -. -g -. -to -extract -a -title -from -a -Matroska -file -) -: -rust -use -regex -: -: -bytes -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -( -? -- -u -) -\ -x7b -\ -xa9 -( -? -: -[ -\ -x80 -- -\ -xfe -] -| -[ -\ -x40 -- -\ -xff -] -. -) -( -? -u -: -( -. -* -) -) -" -) -. -unwrap -( -) -; -let -hay -= -b -" -\ -x12 -\ -xd0 -\ -x3b -\ -x5f -\ -x7b -\ -xa9 -\ -x85 -\ -xe2 -\ -x98 -\ -x83 -\ -x80 -\ -x98 -\ -x54 -\ -x76 -\ -x68 -\ -x65 -" -; -/ -/ -Notice -that -despite -the -. -* -at -the -end -it -will -only -match -valid -UTF -- -8 -/ -/ -because -Unicode -mode -was -enabled -with -the -u -flag -. -Without -the -u -flag -/ -/ -the -. -* -would -match -the -rest -of -the -bytes -regardless -of -whether -they -were -/ -/ -valid -UTF -- -8 -. -let -( -_ -[ -title -] -) -= -re -. -captures -( -hay -) -. -unwrap -( -) -. -extract -( -) -; -assert_eq -! -( -title -b -" -\ -xE2 -\ -x98 -\ -x83 -" -) -; -/ -/ -We -can -UTF -- -8 -decode -the -title -now -. -And -the -unwrap -here -/ -/ -is -correct -because -the -existence -of -a -match -guarantees -/ -/ -that -title -is -valid -UTF -- -8 -. -let -title -= -std -: -: -str -: -: -from_utf8 -( -title -) -. -unwrap -( -) -; -assert_eq -! -( -title -" -" -) -; -In -general -if -the -Unicode -flag -is -enabled -in -a -capture -group -and -that -capture -is -part -of -the -overall -match -then -the -capture -is -* -guaranteed -* -to -be -valid -UTF -- -8 -. -# -Syntax -The -supported -syntax -is -pretty -much -the -same -as -the -syntax -for -Unicode -regular -expressions -with -a -few -changes -that -make -sense -for -matching -arbitrary -bytes -: -1 -. -The -u -flag -can -be -disabled -even -when -disabling -it -might -cause -the -regex -to -match -invalid -UTF -- -8 -. -When -the -u -flag -is -disabled -the -regex -is -said -to -be -in -" -ASCII -compatible -" -mode -. -2 -. -In -ASCII -compatible -mode -neither -Unicode -scalar -values -nor -Unicode -character -classes -are -allowed -. -3 -. -In -ASCII -compatible -mode -Perl -character -classes -( -\ -w -\ -d -and -\ -s -) -revert -to -their -typical -ASCII -definition -. -\ -w -maps -to -[ -[ -: -word -: -] -] -\ -d -maps -to -[ -[ -: -digit -: -] -] -and -\ -s -maps -to -[ -[ -: -space -: -] -] -. -4 -. -In -ASCII -compatible -mode -word -boundaries -use -the -ASCII -compatible -\ -w -to -determine -whether -a -byte -is -a -word -byte -or -not -. -5 -. -Hexadecimal -notation -can -be -used -to -specify -arbitrary -bytes -instead -of -Unicode -codepoints -. -For -example -in -ASCII -compatible -mode -\ -xFF -matches -the -literal -byte -\ -xFF -while -in -Unicode -mode -\ -xFF -is -the -Unicode -codepoint -U -+ -00FF -that -matches -its -UTF -- -8 -encoding -of -\ -xC3 -\ -xBF -. -Similarly -for -octal -notation -when -enabled -. -6 -. -In -ASCII -compatible -mode -. -matches -any -* -byte -* -except -for -\ -n -. -When -the -s -flag -is -additionally -enabled -. -matches -any -byte -. -# -Performance -In -general -one -should -expect -performance -on -& -[ -u8 -] -to -be -roughly -similar -to -performance -on -& -str -. -* -/ -pub -use -crate -: -: -{ -builders -: -: -bytes -: -: -* -regex -: -: -bytes -: -: -* -regexset -: -: -bytes -: -: -* -} -; diff --git a/third_party/rust/regex/src/compile.rs b/third_party/rust/regex/src/compile.rs new file mode 100644 index 0000000000000..2b477fafdd731 --- /dev/null +++ b/third_party/rust/regex/src/compile.rs @@ -0,0 +1,10089 @@ +use +std +: +: +collections +: +: +HashMap +; +use +std +: +: +fmt +; +use +std +: +: +iter +; +use +std +: +: +result +; +use +std +: +: +sync +: +: +Arc +; +use +regex_syntax +: +: +hir +: +: +{ +self +Hir +} +; +use +regex_syntax +: +: +is_word_byte +; +use +regex_syntax +: +: +utf8 +: +: +{ +Utf8Range +Utf8Sequence +Utf8Sequences +} +; +use +crate +: +: +prog +: +: +{ +EmptyLook +Inst +InstBytes +InstChar +InstEmptyLook +InstPtr +InstRanges +InstSave +InstSplit +Program +} +; +use +crate +: +: +Error +; +type +Result += +result +: +: +Result +< +Patch +Error +> +; +type +ResultOrEmpty += +result +: +: +Result +< +Option +< +Patch +> +Error +> +; +# +[ +derive +( +Debug +) +] +struct +Patch +{ +hole +: +Hole +entry +: +InstPtr +} +/ +/ +/ +A +compiler +translates +a +regular +expression +AST +to +a +sequence +of +/ +/ +/ +instructions +. +The +sequence +of +instructions +represents +an +NFA +. +/ +/ +Compiler +is +only +public +via +the +internal +module +so +avoid +deriving +/ +/ +Debug +. +# +[ +allow +( +missing_debug_implementations +) +] +pub +struct +Compiler +{ +insts +: +Vec +< +MaybeInst +> +compiled +: +Program +capture_name_idx +: +HashMap +< +String +usize +> +num_exprs +: +usize +size_limit +: +usize +suffix_cache +: +SuffixCache +utf8_seqs +: +Option +< +Utf8Sequences +> +byte_classes +: +ByteClassSet +/ +/ +This +keeps +track +of +extra +bytes +allocated +while +compiling +the +regex +/ +/ +program +. +Currently +this +corresponds +to +two +things +. +First +is +the +heap +/ +/ +memory +allocated +by +Unicode +character +classes +( +' +InstRanges +' +) +. +Second +is +/ +/ +a +" +fake +" +amount +of +memory +used +by +empty +sub +- +expressions +so +that +enough +/ +/ +empty +sub +- +expressions +will +ultimately +trigger +the +compiler +to +bail +/ +/ +because +of +a +size +limit +restriction +. +( +That +empty +sub +- +expressions +don +' +t +/ +/ +add +to +heap +memory +usage +is +more +- +or +- +less +an +implementation +detail +. +) +In +/ +/ +the +second +case +if +we +don +' +t +bail +then +an +excessively +large +repetition +/ +/ +on +an +empty +sub +- +expression +can +result +in +the +compiler +using +a +very +large +/ +/ +amount +of +CPU +time +. +extra_inst_bytes +: +usize +} +impl +Compiler +{ +/ +/ +/ +Create +a +new +regular +expression +compiler +. +/ +/ +/ +/ +/ +/ +Various +options +can +be +set +before +calling +compile +on +an +expression +. +pub +fn +new +( +) +- +> +Self +{ +Compiler +{ +insts +: +vec +! +[ +] +compiled +: +Program +: +: +new +( +) +capture_name_idx +: +HashMap +: +: +new +( +) +num_exprs +: +0 +size_limit +: +10 +* +( +1 +< +< +20 +) +suffix_cache +: +SuffixCache +: +: +new +( +1000 +) +utf8_seqs +: +Some +( +Utf8Sequences +: +: +new +( +' +\ +x00 +' +' +\ +x00 +' +) +) +byte_classes +: +ByteClassSet +: +: +new +( +) +extra_inst_bytes +: +0 +} +} +/ +/ +/ +The +size +of +the +resulting +program +is +limited +by +size_limit +. +If +/ +/ +/ +the +program +approximately +exceeds +the +given +size +( +in +bytes +) +then +/ +/ +/ +compilation +will +stop +and +return +an +error +. +pub +fn +size_limit +( +mut +self +size_limit +: +usize +) +- +> +Self +{ +self +. +size_limit += +size_limit +; +self +} +/ +/ +/ +If +bytes +is +true +then +the +program +is +compiled +as +a +byte +based +/ +/ +/ +automaton +which +incorporates +UTF +- +8 +decoding +into +the +machine +. +If +it +' +s +/ +/ +/ +false +then +the +automaton +is +Unicode +scalar +value +based +e +. +g +. +an +/ +/ +/ +engine +utilizing +such +an +automaton +is +responsible +for +UTF +- +8 +decoding +. +/ +/ +/ +/ +/ +/ +The +specific +invariant +is +that +when +returning +a +byte +based +machine +/ +/ +/ +the +neither +the +Char +nor +Ranges +instructions +are +produced +. +/ +/ +/ +Conversely +when +producing +a +Unicode +scalar +value +machine +the +Bytes +/ +/ +/ +instruction +is +never +produced +. +/ +/ +/ +/ +/ +/ +Note +that +dfa +( +true +) +implies +bytes +( +true +) +. +pub +fn +bytes +( +mut +self +yes +: +bool +) +- +> +Self +{ +self +. +compiled +. +is_bytes += +yes +; +self +} +/ +/ +/ +When +disabled +the +program +compiled +may +match +arbitrary +bytes +. +/ +/ +/ +/ +/ +/ +When +enabled +( +the +default +) +all +compiled +programs +exclusively +match +/ +/ +/ +valid +UTF +- +8 +bytes +. +pub +fn +only_utf8 +( +mut +self +yes +: +bool +) +- +> +Self +{ +self +. +compiled +. +only_utf8 += +yes +; +self +} +/ +/ +/ +When +set +the +machine +returned +is +suitable +for +use +in +the +DFA +matching +/ +/ +/ +engine +. +/ +/ +/ +/ +/ +/ +In +particular +this +ensures +that +if +the +regex +is +not +anchored +in +the +/ +/ +/ +beginning +then +a +preceding +. +* +? +is +included +in +the +program +. +( +The +NFA +/ +/ +/ +based +engines +handle +the +preceding +. +* +? +explicitly +which +is +difficult +/ +/ +/ +or +impossible +in +the +DFA +engine +. +) +pub +fn +dfa +( +mut +self +yes +: +bool +) +- +> +Self +{ +self +. +compiled +. +is_dfa += +yes +; +self +} +/ +/ +/ +When +set +the +machine +returned +is +suitable +for +matching +text +in +/ +/ +/ +reverse +. +In +particular +all +concatenations +are +flipped +. +pub +fn +reverse +( +mut +self +yes +: +bool +) +- +> +Self +{ +self +. +compiled +. +is_reverse += +yes +; +self +} +/ +/ +/ +Compile +a +regular +expression +given +its +AST +. +/ +/ +/ +/ +/ +/ +The +compiler +is +guaranteed +to +succeed +unless +the +program +exceeds +the +/ +/ +/ +specified +size +limit +. +If +the +size +limit +is +exceeded +then +compilation +/ +/ +/ +stops +and +returns +an +error +. +pub +fn +compile +( +mut +self +exprs +: +& +[ +Hir +] +) +- +> +result +: +: +Result +< +Program +Error +> +{ +debug_assert +! +( +! +exprs +. +is_empty +( +) +) +; +self +. +num_exprs += +exprs +. +len +( +) +; +if +exprs +. +len +( +) += += +1 +{ +self +. +compile_one +( +& +exprs +[ +0 +] +) +} +else +{ +self +. +compile_many +( +exprs +) +} +} +fn +compile_one +( +mut +self +expr +: +& +Hir +) +- +> +result +: +: +Result +< +Program +Error +> +{ +/ +/ +If +we +' +re +compiling +a +forward +DFA +and +we +aren +' +t +anchored +then +/ +/ +add +a +. +* +? +before +the +first +capture +group +. +/ +/ +Other +matching +engines +handle +this +by +baking +the +logic +into +the +/ +/ +matching +engine +itself +. +let +mut +dotstar_patch += +Patch +{ +hole +: +Hole +: +: +None +entry +: +0 +} +; +self +. +compiled +. +is_anchored_start += +expr +. +is_anchored_start +( +) +; +self +. +compiled +. +is_anchored_end += +expr +. +is_anchored_end +( +) +; +if +self +. +compiled +. +needs_dotstar +( +) +{ +dotstar_patch += +self +. +c_dotstar +( +) +? +; +self +. +compiled +. +start += +dotstar_patch +. +entry +; +} +self +. +compiled +. +captures += +vec +! +[ +None +] +; +let +patch += +self +. +c_capture +( +0 +expr +) +? +. +unwrap_or_else +( +| +| +self +. +next_inst +( +) +) +; +if +self +. +compiled +. +needs_dotstar +( +) +{ +self +. +fill +( +dotstar_patch +. +hole +patch +. +entry +) +; +} +else +{ +self +. +compiled +. +start += +patch +. +entry +; +} +self +. +fill_to_next +( +patch +. +hole +) +; +self +. +compiled +. +matches += +vec +! +[ +self +. +insts +. +len +( +) +] +; +self +. +push_compiled +( +Inst +: +: +Match +( +0 +) +) +; +self +. +compile_finish +( +) +} +fn +compile_many +( +mut +self +exprs +: +& +[ +Hir +] +) +- +> +result +: +: +Result +< +Program +Error +> +{ +debug_assert +! +( +exprs +. +len +( +) +> +1 +) +; +self +. +compiled +. +is_anchored_start += +exprs +. +iter +( +) +. +all +( +| +e +| +e +. +is_anchored_start +( +) +) +; +self +. +compiled +. +is_anchored_end += +exprs +. +iter +( +) +. +all +( +| +e +| +e +. +is_anchored_end +( +) +) +; +let +mut +dotstar_patch += +Patch +{ +hole +: +Hole +: +: +None +entry +: +0 +} +; +if +self +. +compiled +. +needs_dotstar +( +) +{ +dotstar_patch += +self +. +c_dotstar +( +) +? +; +self +. +compiled +. +start += +dotstar_patch +. +entry +; +} +else +{ +self +. +compiled +. +start += +0 +; +/ +/ +first +instruction +is +always +split +} +self +. +fill_to_next +( +dotstar_patch +. +hole +) +; +let +mut +prev_hole += +Hole +: +: +None +; +for +( +i +expr +) +in +exprs +[ +0 +. +. +exprs +. +len +( +) +- +1 +] +. +iter +( +) +. +enumerate +( +) +{ +self +. +fill_to_next +( +prev_hole +) +; +let +split += +self +. +push_split_hole +( +) +; +let +Patch +{ +hole +entry +} += +self +. +c_capture +( +0 +expr +) +? +. +unwrap_or_else +( +| +| +self +. +next_inst +( +) +) +; +self +. +fill_to_next +( +hole +) +; +self +. +compiled +. +matches +. +push +( +self +. +insts +. +len +( +) +) +; +self +. +push_compiled +( +Inst +: +: +Match +( +i +) +) +; +prev_hole += +self +. +fill_split +( +split +Some +( +entry +) +None +) +; +} +let +i += +exprs +. +len +( +) +- +1 +; +let +Patch +{ +hole +entry +} += +self +. +c_capture +( +0 +& +exprs +[ +i +] +) +? +. +unwrap_or_else +( +| +| +self +. +next_inst +( +) +) +; +self +. +fill +( +prev_hole +entry +) +; +self +. +fill_to_next +( +hole +) +; +self +. +compiled +. +matches +. +push +( +self +. +insts +. +len +( +) +) +; +self +. +push_compiled +( +Inst +: +: +Match +( +i +) +) +; +self +. +compile_finish +( +) +} +fn +compile_finish +( +mut +self +) +- +> +result +: +: +Result +< +Program +Error +> +{ +self +. +compiled +. +insts += +self +. +insts +. +into_iter +( +) +. +map +( +| +inst +| +inst +. +unwrap +( +) +) +. +collect +( +) +; +self +. +compiled +. +byte_classes += +self +. +byte_classes +. +byte_classes +( +) +; +self +. +compiled +. +capture_name_idx += +Arc +: +: +new +( +self +. +capture_name_idx +) +; +Ok +( +self +. +compiled +) +} +/ +/ +/ +Compile +expr +into +self +. +insts +returning +a +patch +on +success +/ +/ +/ +or +an +error +if +we +run +out +of +memory +. +/ +/ +/ +/ +/ +/ +All +of +the +c_ +* +methods +of +the +compiler +share +the +contract +outlined +/ +/ +/ +here +. +/ +/ +/ +/ +/ +/ +The +main +thing +that +a +c_ +* +method +does +is +mutate +self +. +insts +/ +/ +/ +to +add +a +list +of +mostly +compiled +instructions +required +to +execute +/ +/ +/ +the +given +expression +. +self +. +insts +contains +MaybeInsts +rather +than +/ +/ +/ +Insts +because +there +is +some +backpatching +required +. +/ +/ +/ +/ +/ +/ +The +Patch +value +returned +by +each +c_ +* +method +provides +metadata +/ +/ +/ +about +the +compiled +instructions +emitted +to +self +. +insts +. +The +/ +/ +/ +entry +member +of +the +patch +refers +to +the +first +instruction +/ +/ +/ +( +the +entry +point +) +while +the +hole +member +contains +zero +or +/ +/ +/ +more +offsets +to +partial +instructions +that +need +to +be +backpatched +. +/ +/ +/ +The +c_ +* +routine +can +' +t +know +where +its +list +of +instructions +are +going +to +/ +/ +/ +jump +to +after +execution +so +it +is +up +to +the +caller +to +patch +/ +/ +/ +these +jumps +to +point +to +the +right +place +. +So +compiling +some +/ +/ +/ +expression +e +we +would +end +up +with +a +situation +that +looked +like +: +/ +/ +/ +/ +/ +/ +text +/ +/ +/ +self +. +insts += +[ +. +. +. +i1 +i2 +. +. +. +iexit1 +. +. +. +iexitn +. +. +. +] +/ +/ +/ +^ +^ +^ +/ +/ +/ +| +\ +/ +/ +/ +/ +entry +\ +/ +/ +/ +/ +hole +/ +/ +/ +/ +/ +/ +/ +/ +/ +To +compile +two +expressions +e1 +and +e2 +concatenated +together +we +/ +/ +/ +would +do +: +/ +/ +/ +/ +/ +/ +ignore +/ +/ +/ +let +patch1 += +self +. +c +( +e1 +) +; +/ +/ +/ +let +patch2 += +self +. +c +( +e2 +) +; +/ +/ +/ +/ +/ +/ +/ +/ +/ +while +leaves +us +with +a +situation +that +looks +like +/ +/ +/ +/ +/ +/ +text +/ +/ +/ +self +. +insts += +[ +. +. +. +i1 +. +. +. +iexit1 +. +. +. +i2 +. +. +. +iexit2 +] +/ +/ +/ +^ +^ +^ +^ +/ +/ +/ +| +| +| +| +/ +/ +/ +entry1 +hole1 +entry2 +hole2 +/ +/ +/ +/ +/ +/ +/ +/ +/ +Then +to +merge +the +two +patches +together +into +one +we +would +backpatch +/ +/ +/ +hole1 +with +entry2 +and +return +a +new +patch +that +enters +at +entry1 +/ +/ +/ +and +has +hole2 +for +a +hole +. +In +fact +if +you +look +at +the +c_concat +/ +/ +/ +method +you +will +see +that +it +does +exactly +this +though +it +handles +/ +/ +/ +a +list +of +expressions +rather +than +just +the +two +that +we +use +for +/ +/ +/ +an +example +. +/ +/ +/ +/ +/ +/ +Ok +( +None +) +is +returned +when +an +expression +is +compiled +to +no +/ +/ +/ +instruction +and +so +no +patch +. +entry +value +makes +sense +. +fn +c +( +& +mut +self +expr +: +& +Hir +) +- +> +ResultOrEmpty +{ +use +crate +: +: +prog +; +use +regex_syntax +: +: +hir +: +: +HirKind +: +: +* +; +self +. +check_size +( +) +? +; +match +* +expr +. +kind +( +) +{ +Empty += +> +self +. +c_empty +( +) +Literal +( +hir +: +: +Literal +: +: +Unicode +( +c +) +) += +> +self +. +c_char +( +c +) +Literal +( +hir +: +: +Literal +: +: +Byte +( +b +) +) += +> +{ +assert +! +( +self +. +compiled +. +uses_bytes +( +) +) +; +self +. +c_byte +( +b +) +} +Class +( +hir +: +: +Class +: +: +Unicode +( +ref +cls +) +) += +> +self +. +c_class +( +cls +. +ranges +( +) +) +Class +( +hir +: +: +Class +: +: +Bytes +( +ref +cls +) +) += +> +{ +if +self +. +compiled +. +uses_bytes +( +) +{ +self +. +c_class_bytes +( +cls +. +ranges +( +) +) +} +else +{ +assert +! +( +cls +. +is_all_ascii +( +) +) +; +let +mut +char_ranges += +vec +! +[ +] +; +for +r +in +cls +. +iter +( +) +{ +let +( +s +e +) += +( +r +. +start +( +) +as +char +r +. +end +( +) +as +char +) +; +char_ranges +. +push +( +hir +: +: +ClassUnicodeRange +: +: +new +( +s +e +) +) +; +} +self +. +c_class +( +& +char_ranges +) +} +} +Anchor +( +hir +: +: +Anchor +: +: +StartLine +) +if +self +. +compiled +. +is_reverse += +> +{ +self +. +byte_classes +. +set_range +( +b +' +\ +n +' +b +' +\ +n +' +) +; +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +EndLine +) +} +Anchor +( +hir +: +: +Anchor +: +: +StartLine +) += +> +{ +self +. +byte_classes +. +set_range +( +b +' +\ +n +' +b +' +\ +n +' +) +; +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +StartLine +) +} +Anchor +( +hir +: +: +Anchor +: +: +EndLine +) +if +self +. +compiled +. +is_reverse += +> +{ +self +. +byte_classes +. +set_range +( +b +' +\ +n +' +b +' +\ +n +' +) +; +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +StartLine +) +} +Anchor +( +hir +: +: +Anchor +: +: +EndLine +) += +> +{ +self +. +byte_classes +. +set_range +( +b +' +\ +n +' +b +' +\ +n +' +) +; +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +EndLine +) +} +Anchor +( +hir +: +: +Anchor +: +: +StartText +) +if +self +. +compiled +. +is_reverse += +> +{ +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +EndText +) +} +Anchor +( +hir +: +: +Anchor +: +: +StartText +) += +> +{ +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +StartText +) +} +Anchor +( +hir +: +: +Anchor +: +: +EndText +) +if +self +. +compiled +. +is_reverse += +> +{ +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +StartText +) +} +Anchor +( +hir +: +: +Anchor +: +: +EndText +) += +> +{ +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +EndText +) +} +WordBoundary +( +hir +: +: +WordBoundary +: +: +Unicode +) += +> +{ +if +! +cfg +! +( +feature += +" +unicode +- +perl +" +) +{ +return +Err +( +Error +: +: +Syntax +( +" +Unicode +word +boundaries +are +unavailable +when +\ +the +unicode +- +perl +feature +is +disabled +" +. +to_string +( +) +) +) +; +} +self +. +compiled +. +has_unicode_word_boundary += +true +; +self +. +byte_classes +. +set_word_boundary +( +) +; +/ +/ +We +also +make +sure +that +all +ASCII +bytes +are +in +a +different +/ +/ +class +from +non +- +ASCII +bytes +. +Otherwise +it +' +s +possible +for +/ +/ +ASCII +bytes +to +get +lumped +into +the +same +class +as +non +- +ASCII +/ +/ +bytes +. +This +in +turn +may +cause +the +lazy +DFA +to +falsely +start +/ +/ +when +it +sees +an +ASCII +byte +that +maps +to +a +byte +class +with +/ +/ +non +- +ASCII +bytes +. +This +ensures +that +never +happens +. +self +. +byte_classes +. +set_range +( +0 +0x7F +) +; +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +WordBoundary +) +} +WordBoundary +( +hir +: +: +WordBoundary +: +: +UnicodeNegate +) += +> +{ +if +! +cfg +! +( +feature += +" +unicode +- +perl +" +) +{ +return +Err +( +Error +: +: +Syntax +( +" +Unicode +word +boundaries +are +unavailable +when +\ +the +unicode +- +perl +feature +is +disabled +" +. +to_string +( +) +) +) +; +} +self +. +compiled +. +has_unicode_word_boundary += +true +; +self +. +byte_classes +. +set_word_boundary +( +) +; +/ +/ +See +comments +above +for +why +we +set +the +ASCII +range +here +. +self +. +byte_classes +. +set_range +( +0 +0x7F +) +; +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +NotWordBoundary +) +} +WordBoundary +( +hir +: +: +WordBoundary +: +: +Ascii +) += +> +{ +self +. +byte_classes +. +set_word_boundary +( +) +; +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +WordBoundaryAscii +) +} +WordBoundary +( +hir +: +: +WordBoundary +: +: +AsciiNegate +) += +> +{ +self +. +byte_classes +. +set_word_boundary +( +) +; +self +. +c_empty_look +( +prog +: +: +EmptyLook +: +: +NotWordBoundaryAscii +) +} +Group +( +ref +g +) += +> +match +g +. +kind +{ +hir +: +: +GroupKind +: +: +NonCapturing += +> +self +. +c +( +& +g +. +hir +) +hir +: +: +GroupKind +: +: +CaptureIndex +( +index +) += +> +{ +if +index +as +usize +> += +self +. +compiled +. +captures +. +len +( +) +{ +self +. +compiled +. +captures +. +push +( +None +) +; +} +self +. +c_capture +( +2 +* +index +as +usize +& +g +. +hir +) +} +hir +: +: +GroupKind +: +: +CaptureName +{ +index +ref +name +} += +> +{ +if +index +as +usize +> += +self +. +compiled +. +captures +. +len +( +) +{ +let +n += +name +. +to_string +( +) +; +self +. +compiled +. +captures +. +push +( +Some +( +n +. +clone +( +) +) +) +; +self +. +capture_name_idx +. +insert +( +n +index +as +usize +) +; +} +self +. +c_capture +( +2 +* +index +as +usize +& +g +. +hir +) +} +} +Concat +( +ref +es +) += +> +{ +if +self +. +compiled +. +is_reverse +{ +self +. +c_concat +( +es +. +iter +( +) +. +rev +( +) +) +} +else +{ +self +. +c_concat +( +es +) +} +} +Alternation +( +ref +es +) += +> +self +. +c_alternate +( +& +* +* +es +) +Repetition +( +ref +rep +) += +> +self +. +c_repeat +( +rep +) +} +} +fn +c_empty +( +& +mut +self +) +- +> +ResultOrEmpty +{ +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +security +/ +advisories +/ +GHSA +- +m5pq +- +gvj9 +- +9vr8 +/ +/ +See +: +CVE +- +2022 +- +24713 +/ +/ +/ +/ +Since +' +empty +' +sub +- +expressions +don +' +t +increase +the +size +of +/ +/ +the +actual +compiled +object +we +" +fake +" +an +increase +in +its +/ +/ +size +so +that +our +' +check_size_limit +' +routine +will +eventually +/ +/ +stop +compilation +if +there +are +too +many +empty +sub +- +expressions +/ +/ +( +e +. +g +. +via +a +large +repetition +) +. +self +. +extra_inst_bytes ++ += +std +: +: +mem +: +: +size_of +: +: +< +Inst +> +( +) +; +Ok +( +None +) +} +fn +c_capture +( +& +mut +self +first_slot +: +usize +expr +: +& +Hir +) +- +> +ResultOrEmpty +{ +if +self +. +num_exprs +> +1 +| +| +self +. +compiled +. +is_dfa +{ +/ +/ +Don +' +t +ever +compile +Save +instructions +for +regex +sets +because +/ +/ +they +are +never +used +. +They +are +also +never +used +in +DFA +programs +/ +/ +because +DFAs +can +' +t +handle +captures +. +self +. +c +( +expr +) +} +else +{ +let +entry += +self +. +insts +. +len +( +) +; +let +hole += +self +. +push_hole +( +InstHole +: +: +Save +{ +slot +: +first_slot +} +) +; +let +patch += +self +. +c +( +expr +) +? +. +unwrap_or_else +( +| +| +self +. +next_inst +( +) +) +; +self +. +fill +( +hole +patch +. +entry +) +; +self +. +fill_to_next +( +patch +. +hole +) +; +let +hole += +self +. +push_hole +( +InstHole +: +: +Save +{ +slot +: +first_slot ++ +1 +} +) +; +Ok +( +Some +( +Patch +{ +hole +entry +} +) +) +} +} +fn +c_dotstar +( +& +mut +self +) +- +> +Result +{ +Ok +( +if +! +self +. +compiled +. +only_utf8 +( +) +{ +self +. +c +( +& +Hir +: +: +repetition +( +hir +: +: +Repetition +{ +kind +: +hir +: +: +RepetitionKind +: +: +ZeroOrMore +greedy +: +false +hir +: +Box +: +: +new +( +Hir +: +: +any +( +true +) +) +} +) +) +? +. +unwrap +( +) +} +else +{ +self +. +c +( +& +Hir +: +: +repetition +( +hir +: +: +Repetition +{ +kind +: +hir +: +: +RepetitionKind +: +: +ZeroOrMore +greedy +: +false +hir +: +Box +: +: +new +( +Hir +: +: +any +( +false +) +) +} +) +) +? +. +unwrap +( +) +} +) +} +fn +c_char +( +& +mut +self +c +: +char +) +- +> +ResultOrEmpty +{ +if +self +. +compiled +. +uses_bytes +( +) +{ +if +c +. +is_ascii +( +) +{ +let +b += +c +as +u8 +; +let +hole += +self +. +push_hole +( +InstHole +: +: +Bytes +{ +start +: +b +end +: +b +} +) +; +self +. +byte_classes +. +set_range +( +b +b +) +; +Ok +( +Some +( +Patch +{ +hole +entry +: +self +. +insts +. +len +( +) +- +1 +} +) +) +} +else +{ +self +. +c_class +( +& +[ +hir +: +: +ClassUnicodeRange +: +: +new +( +c +c +) +] +) +} +} +else +{ +let +hole += +self +. +push_hole +( +InstHole +: +: +Char +{ +c +} +) +; +Ok +( +Some +( +Patch +{ +hole +entry +: +self +. +insts +. +len +( +) +- +1 +} +) +) +} +} +fn +c_class +( +& +mut +self +ranges +: +& +[ +hir +: +: +ClassUnicodeRange +] +) +- +> +ResultOrEmpty +{ +use +std +: +: +mem +: +: +size_of +; +assert +! +( +! +ranges +. +is_empty +( +) +) +; +if +self +. +compiled +. +uses_bytes +( +) +{ +Ok +( +Some +( +CompileClass +{ +c +: +self +ranges +} +. +compile +( +) +? +) +) +} +else +{ +let +ranges +: +Vec +< +( +char +char +) +> += +ranges +. +iter +( +) +. +map +( +| +r +| +( +r +. +start +( +) +r +. +end +( +) +) +) +. +collect +( +) +; +let +hole += +if +ranges +. +len +( +) += += +1 +& +& +ranges +[ +0 +] +. +0 += += +ranges +[ +0 +] +. +1 +{ +self +. +push_hole +( +InstHole +: +: +Char +{ +c +: +ranges +[ +0 +] +. +0 +} +) +} +else +{ +self +. +extra_inst_bytes ++ += +ranges +. +len +( +) +* +( +size_of +: +: +< +char +> +( +) +* +2 +) +; +self +. +push_hole +( +InstHole +: +: +Ranges +{ +ranges +} +) +} +; +Ok +( +Some +( +Patch +{ +hole +entry +: +self +. +insts +. +len +( +) +- +1 +} +) +) +} +} +fn +c_byte +( +& +mut +self +b +: +u8 +) +- +> +ResultOrEmpty +{ +self +. +c_class_bytes +( +& +[ +hir +: +: +ClassBytesRange +: +: +new +( +b +b +) +] +) +} +fn +c_class_bytes +( +& +mut +self +ranges +: +& +[ +hir +: +: +ClassBytesRange +] +) +- +> +ResultOrEmpty +{ +debug_assert +! +( +! +ranges +. +is_empty +( +) +) +; +let +first_split_entry += +self +. +insts +. +len +( +) +; +let +mut +holes += +vec +! +[ +] +; +let +mut +prev_hole += +Hole +: +: +None +; +for +r +in +& +ranges +[ +0 +. +. +ranges +. +len +( +) +- +1 +] +{ +self +. +fill_to_next +( +prev_hole +) +; +let +split += +self +. +push_split_hole +( +) +; +let +next += +self +. +insts +. +len +( +) +; +self +. +byte_classes +. +set_range +( +r +. +start +( +) +r +. +end +( +) +) +; +holes +. +push +( +self +. +push_hole +( +InstHole +: +: +Bytes +{ +start +: +r +. +start +( +) +end +: +r +. +end +( +) +} +) +) +; +prev_hole += +self +. +fill_split +( +split +Some +( +next +) +None +) +; +} +let +next += +self +. +insts +. +len +( +) +; +let +r += +& +ranges +[ +ranges +. +len +( +) +- +1 +] +; +self +. +byte_classes +. +set_range +( +r +. +start +( +) +r +. +end +( +) +) +; +holes +. +push +( +self +. +push_hole +( +InstHole +: +: +Bytes +{ +start +: +r +. +start +( +) +end +: +r +. +end +( +) +} +) +) +; +self +. +fill +( +prev_hole +next +) +; +Ok +( +Some +( +Patch +{ +hole +: +Hole +: +: +Many +( +holes +) +entry +: +first_split_entry +} +) +) +} +fn +c_empty_look +( +& +mut +self +look +: +EmptyLook +) +- +> +ResultOrEmpty +{ +let +hole += +self +. +push_hole +( +InstHole +: +: +EmptyLook +{ +look +} +) +; +Ok +( +Some +( +Patch +{ +hole +entry +: +self +. +insts +. +len +( +) +- +1 +} +) +) +} +fn +c_concat +< +' +a +I +> +( +& +mut +self +exprs +: +I +) +- +> +ResultOrEmpty +where +I +: +IntoIterator +< +Item += +& +' +a +Hir +> +{ +let +mut +exprs += +exprs +. +into_iter +( +) +; +let +Patch +{ +mut +hole +entry +} += +loop +{ +match +exprs +. +next +( +) +{ +None += +> +return +self +. +c_empty +( +) +Some +( +e +) += +> +{ +if +let +Some +( +p +) += +self +. +c +( +e +) +? +{ +break +p +; +} +} +} +} +; +for +e +in +exprs +{ +if +let +Some +( +p +) += +self +. +c +( +e +) +? +{ +self +. +fill +( +hole +p +. +entry +) +; +hole += +p +. +hole +; +} +} +Ok +( +Some +( +Patch +{ +hole +entry +} +) +) +} +fn +c_alternate +( +& +mut +self +exprs +: +& +[ +Hir +] +) +- +> +ResultOrEmpty +{ +debug_assert +! +( +exprs +. +len +( +) +> += +2 +" +alternates +must +have +at +least +2 +exprs +" +) +; +/ +/ +Initial +entry +point +is +always +the +first +split +. +let +first_split_entry += +self +. +insts +. +len +( +) +; +/ +/ +Save +up +all +of +the +holes +from +each +alternate +. +They +will +all +get +/ +/ +patched +to +point +to +the +same +location +. +let +mut +holes += +vec +! +[ +] +; +/ +/ +true +indicates +that +the +hole +is +a +split +where +we +want +to +fill +/ +/ +the +second +branch +. +let +mut +prev_hole += +( +Hole +: +: +None +false +) +; +for +e +in +& +exprs +[ +0 +. +. +exprs +. +len +( +) +- +1 +] +{ +if +prev_hole +. +1 +{ +let +next += +self +. +insts +. +len +( +) +; +self +. +fill_split +( +prev_hole +. +0 +None +Some +( +next +) +) +; +} +else +{ +self +. +fill_to_next +( +prev_hole +. +0 +) +; +} +let +split += +self +. +push_split_hole +( +) +; +if +let +Some +( +Patch +{ +hole +entry +} +) += +self +. +c +( +e +) +? +{ +holes +. +push +( +hole +) +; +prev_hole += +( +self +. +fill_split +( +split +Some +( +entry +) +None +) +false +) +; +} +else +{ +let +( +split1 +split2 +) += +split +. +dup_one +( +) +; +holes +. +push +( +split1 +) +; +prev_hole += +( +split2 +true +) +; +} +} +if +let +Some +( +Patch +{ +hole +entry +} +) += +self +. +c +( +& +exprs +[ +exprs +. +len +( +) +- +1 +] +) +? +{ +holes +. +push +( +hole +) +; +if +prev_hole +. +1 +{ +self +. +fill_split +( +prev_hole +. +0 +None +Some +( +entry +) +) +; +} +else +{ +self +. +fill +( +prev_hole +. +0 +entry +) +; +} +} +else +{ +/ +/ +We +ignore +prev_hole +. +1 +. +When +it +' +s +true +it +means +we +have +two +/ +/ +empty +branches +both +pushing +prev_hole +. +0 +into +holes +so +both +/ +/ +branches +will +go +to +the +same +place +anyway +. +holes +. +push +( +prev_hole +. +0 +) +; +} +Ok +( +Some +( +Patch +{ +hole +: +Hole +: +: +Many +( +holes +) +entry +: +first_split_entry +} +) +) +} +fn +c_repeat +( +& +mut +self +rep +: +& +hir +: +: +Repetition +) +- +> +ResultOrEmpty +{ +use +regex_syntax +: +: +hir +: +: +RepetitionKind +: +: +* +; +match +rep +. +kind +{ +ZeroOrOne += +> +self +. +c_repeat_zero_or_one +( +& +rep +. +hir +rep +. +greedy +) +ZeroOrMore += +> +self +. +c_repeat_zero_or_more +( +& +rep +. +hir +rep +. +greedy +) +OneOrMore += +> +self +. +c_repeat_one_or_more +( +& +rep +. +hir +rep +. +greedy +) +Range +( +hir +: +: +RepetitionRange +: +: +Exactly +( +min_max +) +) += +> +{ +self +. +c_repeat_range +( +& +rep +. +hir +rep +. +greedy +min_max +min_max +) +} +Range +( +hir +: +: +RepetitionRange +: +: +AtLeast +( +min +) +) += +> +{ +self +. +c_repeat_range_min_or_more +( +& +rep +. +hir +rep +. +greedy +min +) +} +Range +( +hir +: +: +RepetitionRange +: +: +Bounded +( +min +max +) +) += +> +{ +self +. +c_repeat_range +( +& +rep +. +hir +rep +. +greedy +min +max +) +} +} +} +fn +c_repeat_zero_or_one +( +& +mut +self +expr +: +& +Hir +greedy +: +bool +) +- +> +ResultOrEmpty +{ +let +split_entry += +self +. +insts +. +len +( +) +; +let +split += +self +. +push_split_hole +( +) +; +let +Patch +{ +hole +: +hole_rep +entry +: +entry_rep +} += +match +self +. +c +( +expr +) +? +{ +Some +( +p +) += +> +p +None += +> +return +self +. +pop_split_hole +( +) +} +; +let +split_hole += +if +greedy +{ +self +. +fill_split +( +split +Some +( +entry_rep +) +None +) +} +else +{ +self +. +fill_split +( +split +None +Some +( +entry_rep +) +) +} +; +let +holes += +vec +! +[ +hole_rep +split_hole +] +; +Ok +( +Some +( +Patch +{ +hole +: +Hole +: +: +Many +( +holes +) +entry +: +split_entry +} +) +) +} +fn +c_repeat_zero_or_more +( +& +mut +self +expr +: +& +Hir +greedy +: +bool +) +- +> +ResultOrEmpty +{ +let +split_entry += +self +. +insts +. +len +( +) +; +let +split += +self +. +push_split_hole +( +) +; +let +Patch +{ +hole +: +hole_rep +entry +: +entry_rep +} += +match +self +. +c +( +expr +) +? +{ +Some +( +p +) += +> +p +None += +> +return +self +. +pop_split_hole +( +) +} +; +self +. +fill +( +hole_rep +split_entry +) +; +let +split_hole += +if +greedy +{ +self +. +fill_split +( +split +Some +( +entry_rep +) +None +) +} +else +{ +self +. +fill_split +( +split +None +Some +( +entry_rep +) +) +} +; +Ok +( +Some +( +Patch +{ +hole +: +split_hole +entry +: +split_entry +} +) +) +} +fn +c_repeat_one_or_more +( +& +mut +self +expr +: +& +Hir +greedy +: +bool +) +- +> +ResultOrEmpty +{ +let +Patch +{ +hole +: +hole_rep +entry +: +entry_rep +} += +match +self +. +c +( +expr +) +? +{ +Some +( +p +) += +> +p +None += +> +return +Ok +( +None +) +} +; +self +. +fill_to_next +( +hole_rep +) +; +let +split += +self +. +push_split_hole +( +) +; +let +split_hole += +if +greedy +{ +self +. +fill_split +( +split +Some +( +entry_rep +) +None +) +} +else +{ +self +. +fill_split +( +split +None +Some +( +entry_rep +) +) +} +; +Ok +( +Some +( +Patch +{ +hole +: +split_hole +entry +: +entry_rep +} +) +) +} +fn +c_repeat_range_min_or_more +( +& +mut +self +expr +: +& +Hir +greedy +: +bool +min +: +u32 +) +- +> +ResultOrEmpty +{ +let +min += +u32_to_usize +( +min +) +; +/ +/ +Using +next_inst +( +) +is +ok +because +we +can +' +t +return +it +( +concat +would +/ +/ +have +to +return +Some +( +_ +) +while +c_repeat_range_min_or_more +returns +/ +/ +None +) +. +let +patch_concat += +self +. +c_concat +( +iter +: +: +repeat +( +expr +) +. +take +( +min +) +) +? +. +unwrap_or_else +( +| +| +self +. +next_inst +( +) +) +; +if +let +Some +( +patch_rep +) += +self +. +c_repeat_zero_or_more +( +expr +greedy +) +? +{ +self +. +fill +( +patch_concat +. +hole +patch_rep +. +entry +) +; +Ok +( +Some +( +Patch +{ +hole +: +patch_rep +. +hole +entry +: +patch_concat +. +entry +} +) +) +} +else +{ +Ok +( +None +) +} +} +fn +c_repeat_range +( +& +mut +self +expr +: +& +Hir +greedy +: +bool +min +: +u32 +max +: +u32 +) +- +> +ResultOrEmpty +{ +let +( +min +max +) += +( +u32_to_usize +( +min +) +u32_to_usize +( +max +) +) +; +debug_assert +! +( +min +< += +max +) +; +let +patch_concat += +self +. +c_concat +( +iter +: +: +repeat +( +expr +) +. +take +( +min +) +) +? +; +if +min += += +max +{ +return +Ok +( +patch_concat +) +; +} +/ +/ +Same +reasoning +as +in +c_repeat_range_min_or_more +( +we +know +that +min +< +/ +/ +max +at +this +point +) +. +let +patch_concat += +patch_concat +. +unwrap_or_else +( +| +| +self +. +next_inst +( +) +) +; +let +initial_entry += +patch_concat +. +entry +; +/ +/ +It +is +much +simpler +to +compile +e +. +g +. +a +{ +2 +5 +} +as +: +/ +/ +/ +/ +aaa +? +a +? +a +? +/ +/ +/ +/ +But +you +end +up +with +a +sequence +of +instructions +like +this +: +/ +/ +/ +/ +0 +: +' +a +' +/ +/ +1 +: +' +a +' +/ +/ +2 +: +split +( +3 +4 +) +/ +/ +3 +: +' +a +' +/ +/ +4 +: +split +( +5 +6 +) +/ +/ +5 +: +' +a +' +/ +/ +6 +: +split +( +7 +8 +) +/ +/ +7 +: +' +a +' +/ +/ +8 +: +MATCH +/ +/ +/ +/ +This +is +* +incredibly +* +inefficient +because +the +splits +end +/ +/ +up +forming +a +chain +which +has +to +be +resolved +everything +a +/ +/ +transition +is +followed +. +let +mut +holes += +vec +! +[ +] +; +let +mut +prev_hole += +patch_concat +. +hole +; +for +_ +in +min +. +. +max +{ +self +. +fill_to_next +( +prev_hole +) +; +let +split += +self +. +push_split_hole +( +) +; +let +Patch +{ +hole +entry +} += +match +self +. +c +( +expr +) +? +{ +Some +( +p +) += +> +p +None += +> +return +self +. +pop_split_hole +( +) +} +; +prev_hole += +hole +; +if +greedy +{ +holes +. +push +( +self +. +fill_split +( +split +Some +( +entry +) +None +) +) +; +} +else +{ +holes +. +push +( +self +. +fill_split +( +split +None +Some +( +entry +) +) +) +; +} +} +holes +. +push +( +prev_hole +) +; +Ok +( +Some +( +Patch +{ +hole +: +Hole +: +: +Many +( +holes +) +entry +: +initial_entry +} +) +) +} +/ +/ +/ +Can +be +used +as +a +default +value +for +the +c_ +* +functions +when +the +call +to +/ +/ +/ +c_function +is +followed +by +inserting +at +least +one +instruction +that +is +/ +/ +/ +always +executed +after +the +ones +written +by +the +c +* +function +. +fn +next_inst +( +& +self +) +- +> +Patch +{ +Patch +{ +hole +: +Hole +: +: +None +entry +: +self +. +insts +. +len +( +) +} +} +fn +fill +( +& +mut +self +hole +: +Hole +goto +: +InstPtr +) +{ +match +hole +{ +Hole +: +: +None += +> +{ +} +Hole +: +: +One +( +pc +) += +> +{ +self +. +insts +[ +pc +] +. +fill +( +goto +) +; +} +Hole +: +: +Many +( +holes +) += +> +{ +for +hole +in +holes +{ +self +. +fill +( +hole +goto +) +; +} +} +} +} +fn +fill_to_next +( +& +mut +self +hole +: +Hole +) +{ +let +next += +self +. +insts +. +len +( +) +; +self +. +fill +( +hole +next +) +; +} +fn +fill_split +( +& +mut +self +hole +: +Hole +goto1 +: +Option +< +InstPtr +> +goto2 +: +Option +< +InstPtr +> +) +- +> +Hole +{ +match +hole +{ +Hole +: +: +None += +> +Hole +: +: +None +Hole +: +: +One +( +pc +) += +> +match +( +goto1 +goto2 +) +{ +( +Some +( +goto1 +) +Some +( +goto2 +) +) += +> +{ +self +. +insts +[ +pc +] +. +fill_split +( +goto1 +goto2 +) +; +Hole +: +: +None +} +( +Some +( +goto1 +) +None +) += +> +{ +self +. +insts +[ +pc +] +. +half_fill_split_goto1 +( +goto1 +) +; +Hole +: +: +One +( +pc +) +} +( +None +Some +( +goto2 +) +) += +> +{ +self +. +insts +[ +pc +] +. +half_fill_split_goto2 +( +goto2 +) +; +Hole +: +: +One +( +pc +) +} +( +None +None +) += +> +unreachable +! +( +" +at +least +one +of +the +split +\ +holes +must +be +filled +" +) +} +Hole +: +: +Many +( +holes +) += +> +{ +let +mut +new_holes += +vec +! +[ +] +; +for +hole +in +holes +{ +new_holes +. +push +( +self +. +fill_split +( +hole +goto1 +goto2 +) +) +; +} +if +new_holes +. +is_empty +( +) +{ +Hole +: +: +None +} +else +if +new_holes +. +len +( +) += += +1 +{ +new_holes +. +pop +( +) +. +unwrap +( +) +} +else +{ +Hole +: +: +Many +( +new_holes +) +} +} +} +} +fn +push_compiled +( +& +mut +self +inst +: +Inst +) +{ +self +. +insts +. +push +( +MaybeInst +: +: +Compiled +( +inst +) +) +; +} +fn +push_hole +( +& +mut +self +inst +: +InstHole +) +- +> +Hole +{ +let +hole += +self +. +insts +. +len +( +) +; +self +. +insts +. +push +( +MaybeInst +: +: +Uncompiled +( +inst +) +) +; +Hole +: +: +One +( +hole +) +} +fn +push_split_hole +( +& +mut +self +) +- +> +Hole +{ +let +hole += +self +. +insts +. +len +( +) +; +self +. +insts +. +push +( +MaybeInst +: +: +Split +) +; +Hole +: +: +One +( +hole +) +} +fn +pop_split_hole +( +& +mut +self +) +- +> +ResultOrEmpty +{ +self +. +insts +. +pop +( +) +; +Ok +( +None +) +} +fn +check_size +( +& +self +) +- +> +result +: +: +Result +< +( +) +Error +> +{ +use +std +: +: +mem +: +: +size_of +; +let +size += +self +. +extra_inst_bytes ++ +( +self +. +insts +. +len +( +) +* +size_of +: +: +< +Inst +> +( +) +) +; +if +size +> +self +. +size_limit +{ +Err +( +Error +: +: +CompiledTooBig +( +self +. +size_limit +) +) +} +else +{ +Ok +( +( +) +) +} +} +} +# +[ +derive +( +Debug +) +] +enum +Hole +{ +None +One +( +InstPtr +) +Many +( +Vec +< +Hole +> +) +} +impl +Hole +{ +fn +dup_one +( +self +) +- +> +( +Self +Self +) +{ +match +self +{ +Hole +: +: +One +( +pc +) += +> +( +Hole +: +: +One +( +pc +) +Hole +: +: +One +( +pc +) +) +Hole +: +: +None +| +Hole +: +: +Many +( +_ +) += +> +{ +unreachable +! +( +" +must +be +called +on +single +hole +" +) +} +} +} +} +# +[ +derive +( +Clone +Debug +) +] +enum +MaybeInst +{ +Compiled +( +Inst +) +Uncompiled +( +InstHole +) +Split +Split1 +( +InstPtr +) +Split2 +( +InstPtr +) +} +impl +MaybeInst +{ +fn +fill +( +& +mut +self +goto +: +InstPtr +) +{ +let +maybeinst += +match +* +self +{ +MaybeInst +: +: +Split += +> +MaybeInst +: +: +Split1 +( +goto +) +MaybeInst +: +: +Uncompiled +( +ref +inst +) += +> +{ +MaybeInst +: +: +Compiled +( +inst +. +fill +( +goto +) +) +} +MaybeInst +: +: +Split1 +( +goto1 +) += +> +{ +MaybeInst +: +: +Compiled +( +Inst +: +: +Split +( +InstSplit +{ +goto1 +goto2 +: +goto +} +) +) +} +MaybeInst +: +: +Split2 +( +goto2 +) += +> +{ +MaybeInst +: +: +Compiled +( +Inst +: +: +Split +( +InstSplit +{ +goto1 +: +goto +goto2 +} +) +) +} +_ += +> +unreachable +! +( +" +not +all +instructions +were +compiled +! +\ +found +uncompiled +instruction +: +{ +: +? +} +" +self +) +} +; +* +self += +maybeinst +; +} +fn +fill_split +( +& +mut +self +goto1 +: +InstPtr +goto2 +: +InstPtr +) +{ +let +filled += +match +* +self +{ +MaybeInst +: +: +Split += +> +Inst +: +: +Split +( +InstSplit +{ +goto1 +goto2 +} +) +_ += +> +unreachable +! +( +" +must +be +called +on +Split +instruction +\ +instead +it +was +called +on +: +{ +: +? +} +" +self +) +} +; +* +self += +MaybeInst +: +: +Compiled +( +filled +) +; +} +fn +half_fill_split_goto1 +( +& +mut +self +goto1 +: +InstPtr +) +{ +let +half_filled += +match +* +self +{ +MaybeInst +: +: +Split += +> +goto1 +_ += +> +unreachable +! +( +" +must +be +called +on +Split +instruction +\ +instead +it +was +called +on +: +{ +: +? +} +" +self +) +} +; +* +self += +MaybeInst +: +: +Split1 +( +half_filled +) +; +} +fn +half_fill_split_goto2 +( +& +mut +self +goto2 +: +InstPtr +) +{ +let +half_filled += +match +* +self +{ +MaybeInst +: +: +Split += +> +goto2 +_ += +> +unreachable +! +( +" +must +be +called +on +Split +instruction +\ +instead +it +was +called +on +: +{ +: +? +} +" +self +) +} +; +* +self += +MaybeInst +: +: +Split2 +( +half_filled +) +; +} +fn +unwrap +( +self +) +- +> +Inst +{ +match +self +{ +MaybeInst +: +: +Compiled +( +inst +) += +> +inst +_ += +> +unreachable +! +( +" +must +be +called +on +a +compiled +instruction +\ +instead +it +was +called +on +: +{ +: +? +} +" +self +) +} +} +} +# +[ +derive +( +Clone +Debug +) +] +enum +InstHole +{ +Save +{ +slot +: +usize +} +EmptyLook +{ +look +: +EmptyLook +} +Char +{ +c +: +char +} +Ranges +{ +ranges +: +Vec +< +( +char +char +) +> +} +Bytes +{ +start +: +u8 +end +: +u8 +} +} +impl +InstHole +{ +fn +fill +( +& +self +goto +: +InstPtr +) +- +> +Inst +{ +match +* +self +{ +InstHole +: +: +Save +{ +slot +} += +> +Inst +: +: +Save +( +InstSave +{ +goto +slot +} +) +InstHole +: +: +EmptyLook +{ +look +} += +> +{ +Inst +: +: +EmptyLook +( +InstEmptyLook +{ +goto +look +} +) +} +InstHole +: +: +Char +{ +c +} += +> +Inst +: +: +Char +( +InstChar +{ +goto +c +} +) +InstHole +: +: +Ranges +{ +ref +ranges +} += +> +Inst +: +: +Ranges +( +InstRanges +{ +goto +ranges +: +ranges +. +clone +( +) +. +into_boxed_slice +( +) +} +) +InstHole +: +: +Bytes +{ +start +end +} += +> +{ +Inst +: +: +Bytes +( +InstBytes +{ +goto +start +end +} +) +} +} +} +} +struct +CompileClass +< +' +a +' +b +> +{ +c +: +& +' +a +mut +Compiler +ranges +: +& +' +b +[ +hir +: +: +ClassUnicodeRange +] +} +impl +< +' +a +' +b +> +CompileClass +< +' +a +' +b +> +{ +fn +compile +( +mut +self +) +- +> +Result +{ +let +mut +holes += +vec +! +[ +] +; +let +mut +initial_entry += +None +; +let +mut +last_split += +Hole +: +: +None +; +let +mut +utf8_seqs += +self +. +c +. +utf8_seqs +. +take +( +) +. +unwrap +( +) +; +self +. +c +. +suffix_cache +. +clear +( +) +; +for +( +i +range +) +in +self +. +ranges +. +iter +( +) +. +enumerate +( +) +{ +let +is_last_range += +i ++ +1 += += +self +. +ranges +. +len +( +) +; +utf8_seqs +. +reset +( +range +. +start +( +) +range +. +end +( +) +) +; +let +mut +it += +( +& +mut +utf8_seqs +) +. +peekable +( +) +; +loop +{ +let +utf8_seq += +match +it +. +next +( +) +{ +None += +> +break +Some +( +utf8_seq +) += +> +utf8_seq +} +; +if +is_last_range +& +& +it +. +peek +( +) +. +is_none +( +) +{ +let +Patch +{ +hole +entry +} += +self +. +c_utf8_seq +( +& +utf8_seq +) +? +; +holes +. +push +( +hole +) +; +self +. +c +. +fill +( +last_split +entry +) +; +last_split += +Hole +: +: +None +; +if +initial_entry +. +is_none +( +) +{ +initial_entry += +Some +( +entry +) +; +} +} +else +{ +if +initial_entry +. +is_none +( +) +{ +initial_entry += +Some +( +self +. +c +. +insts +. +len +( +) +) +; +} +self +. +c +. +fill_to_next +( +last_split +) +; +last_split += +self +. +c +. +push_split_hole +( +) +; +let +Patch +{ +hole +entry +} += +self +. +c_utf8_seq +( +& +utf8_seq +) +? +; +holes +. +push +( +hole +) +; +last_split += +self +. +c +. +fill_split +( +last_split +Some +( +entry +) +None +) +; +} +} +} +self +. +c +. +utf8_seqs += +Some +( +utf8_seqs +) +; +Ok +( +Patch +{ +hole +: +Hole +: +: +Many +( +holes +) +entry +: +initial_entry +. +unwrap +( +) +} +) +} +fn +c_utf8_seq +( +& +mut +self +seq +: +& +Utf8Sequence +) +- +> +Result +{ +if +self +. +c +. +compiled +. +is_reverse +{ +self +. +c_utf8_seq_ +( +seq +) +} +else +{ +self +. +c_utf8_seq_ +( +seq +. +into_iter +( +) +. +rev +( +) +) +} +} +fn +c_utf8_seq_ +< +' +r +I +> +( +& +mut +self +seq +: +I +) +- +> +Result +where +I +: +IntoIterator +< +Item += +& +' +r +Utf8Range +> +{ +/ +/ +The +initial +instruction +for +each +UTF +- +8 +sequence +should +be +the +same +. +let +mut +from_inst += +: +: +std +: +: +usize +: +: +MAX +; +let +mut +last_hole += +Hole +: +: +None +; +for +byte_range +in +seq +{ +let +key += +SuffixCacheKey +{ +from_inst +start +: +byte_range +. +start +end +: +byte_range +. +end +} +; +{ +let +pc += +self +. +c +. +insts +. +len +( +) +; +if +let +Some +( +cached_pc +) += +self +. +c +. +suffix_cache +. +get +( +key +pc +) +{ +from_inst += +cached_pc +; +continue +; +} +} +self +. +c +. +byte_classes +. +set_range +( +byte_range +. +start +byte_range +. +end +) +; +if +from_inst += += +: +: +std +: +: +usize +: +: +MAX +{ +last_hole += +self +. +c +. +push_hole +( +InstHole +: +: +Bytes +{ +start +: +byte_range +. +start +end +: +byte_range +. +end +} +) +; +} +else +{ +self +. +c +. +push_compiled +( +Inst +: +: +Bytes +( +InstBytes +{ +goto +: +from_inst +start +: +byte_range +. +start +end +: +byte_range +. +end +} +) +) +; +} +from_inst += +self +. +c +. +insts +. +len +( +) +. +checked_sub +( +1 +) +. +unwrap +( +) +; +debug_assert +! +( +from_inst +< +: +: +std +: +: +usize +: +: +MAX +) +; +} +debug_assert +! +( +from_inst +< +: +: +std +: +: +usize +: +: +MAX +) +; +Ok +( +Patch +{ +hole +: +last_hole +entry +: +from_inst +} +) +} +} +/ +/ +/ +SuffixCache +is +a +simple +bounded +hash +map +for +caching +suffix +entries +in +/ +/ +/ +UTF +- +8 +automata +. +For +example +consider +the +Unicode +range +\ +u +{ +0 +} +- +\ +u +{ +FFFF +} +. +/ +/ +/ +The +set +of +byte +ranges +looks +like +this +: +/ +/ +/ +/ +/ +/ +[ +0 +- +7F +] +/ +/ +/ +[ +C2 +- +DF +] +[ +80 +- +BF +] +/ +/ +/ +[ +E0 +] +[ +A0 +- +BF +] +[ +80 +- +BF +] +/ +/ +/ +[ +E1 +- +EC +] +[ +80 +- +BF +] +[ +80 +- +BF +] +/ +/ +/ +[ +ED +] +[ +80 +- +9F +] +[ +80 +- +BF +] +/ +/ +/ +[ +EE +- +EF +] +[ +80 +- +BF +] +[ +80 +- +BF +] +/ +/ +/ +/ +/ +/ +Each +line +above +translates +to +one +alternate +in +the +compiled +regex +program +. +/ +/ +/ +However +all +but +one +of +the +alternates +end +in +the +same +suffix +which +is +/ +/ +/ +a +waste +of +an +instruction +. +The +suffix +cache +facilitates +reusing +them +across +/ +/ +/ +alternates +. +/ +/ +/ +/ +/ +/ +Note +that +a +HashMap +could +be +trivially +used +for +this +but +we +don +' +t +need +its +/ +/ +/ +overhead +. +Some +small +bounded +space +( +LRU +style +) +is +more +than +enough +. +/ +/ +/ +/ +/ +/ +This +uses +similar +idea +to +[ +SparseSet +] +( +. +. +/ +sparse +/ +struct +. +SparseSet +. +html +) +/ +/ +/ +except +it +uses +hashes +as +original +indices +and +then +compares +full +keys +for +/ +/ +/ +validation +against +dense +array +. +# +[ +derive +( +Debug +) +] +struct +SuffixCache +{ +sparse +: +Box +< +[ +usize +] +> +dense +: +Vec +< +SuffixCacheEntry +> +} +# +[ +derive +( +Clone +Copy +Debug +Default +Eq +Hash +PartialEq +) +] +struct +SuffixCacheEntry +{ +key +: +SuffixCacheKey +pc +: +InstPtr +} +# +[ +derive +( +Clone +Copy +Debug +Default +Eq +Hash +PartialEq +) +] +struct +SuffixCacheKey +{ +from_inst +: +InstPtr +start +: +u8 +end +: +u8 +} +impl +SuffixCache +{ +fn +new +( +size +: +usize +) +- +> +Self +{ +SuffixCache +{ +sparse +: +vec +! +[ +0usize +; +size +] +. +into +( +) +dense +: +Vec +: +: +with_capacity +( +size +) +} +} +fn +get +( +& +mut +self +key +: +SuffixCacheKey +pc +: +InstPtr +) +- +> +Option +< +InstPtr +> +{ +let +hash += +self +. +hash +( +& +key +) +; +let +pos += +& +mut +self +. +sparse +[ +hash +] +; +if +let +Some +( +entry +) += +self +. +dense +. +get +( +* +pos +) +{ +if +entry +. +key += += +key +{ +return +Some +( +entry +. +pc +) +; +} +} +* +pos += +self +. +dense +. +len +( +) +; +self +. +dense +. +push +( +SuffixCacheEntry +{ +key +pc +} +) +; +None +} +fn +clear +( +& +mut +self +) +{ +self +. +dense +. +clear +( +) +; +} +fn +hash +( +& +self +suffix +: +& +SuffixCacheKey +) +- +> +usize +{ +/ +/ +Basic +FNV +- +1a +hash +as +described +: +/ +/ +https +: +/ +/ +en +. +wikipedia +. +org +/ +wiki +/ +Fowler +% +E2 +% +80 +% +93Noll +% +E2 +% +80 +% +93Vo_hash_function +const +FNV_PRIME +: +u64 += +1_099_511_628_211 +; +let +mut +h += +14_695_981_039_346_656_037 +; +h += +( +h +^ +( +suffix +. +from_inst +as +u64 +) +) +. +wrapping_mul +( +FNV_PRIME +) +; +h += +( +h +^ +( +suffix +. +start +as +u64 +) +) +. +wrapping_mul +( +FNV_PRIME +) +; +h += +( +h +^ +( +suffix +. +end +as +u64 +) +) +. +wrapping_mul +( +FNV_PRIME +) +; +( +h +as +usize +) +% +self +. +sparse +. +len +( +) +} +} +struct +ByteClassSet +( +[ +bool +; +256 +] +) +; +impl +ByteClassSet +{ +fn +new +( +) +- +> +Self +{ +ByteClassSet +( +[ +false +; +256 +] +) +} +fn +set_range +( +& +mut +self +start +: +u8 +end +: +u8 +) +{ +debug_assert +! +( +start +< += +end +) +; +if +start +> +0 +{ +self +. +0 +[ +start +as +usize +- +1 +] += +true +; +} +self +. +0 +[ +end +as +usize +] += +true +; +} +fn +set_word_boundary +( +& +mut +self +) +{ +/ +/ +We +need +to +mark +all +ranges +of +bytes +whose +pairs +result +in +/ +/ +evaluating +\ +b +differently +. +let +iswb += +is_word_byte +; +let +mut +b1 +: +u16 += +0 +; +let +mut +b2 +: +u16 +; +while +b1 +< += +255 +{ +b2 += +b1 ++ +1 +; +while +b2 +< += +255 +& +& +iswb +( +b1 +as +u8 +) += += +iswb +( +b2 +as +u8 +) +{ +b2 ++ += +1 +; +} +self +. +set_range +( +b1 +as +u8 +( +b2 +- +1 +) +as +u8 +) +; +b1 += +b2 +; +} +} +fn +byte_classes +( +& +self +) +- +> +Vec +< +u8 +> +{ +/ +/ +N +. +B +. +If +you +' +re +debugging +the +DFA +it +' +s +useful +to +simply +return +/ +/ +( +0 +. +. +256 +) +. +collect +( +) +which +effectively +removes +the +byte +classes +/ +/ +and +makes +the +transitions +easier +to +read +. +/ +/ +( +0usize +. +. +256 +) +. +map +( +| +x +| +x +as +u8 +) +. +collect +( +) +let +mut +byte_classes += +vec +! +[ +0 +; +256 +] +; +let +mut +class += +0u8 +; +let +mut +i += +0 +; +loop +{ +byte_classes +[ +i +] += +class +as +u8 +; +if +i +> += +255 +{ +break +; +} +if +self +. +0 +[ +i +] +{ +class += +class +. +checked_add +( +1 +) +. +unwrap +( +) +; +} +i ++ += +1 +; +} +byte_classes +} +} +impl +fmt +: +: +Debug +for +ByteClassSet +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +f +. +debug_tuple +( +" +ByteClassSet +" +) +. +field +( +& +& +self +. +0 +[ +. +. +] +) +. +finish +( +) +} +} +fn +u32_to_usize +( +n +: +u32 +) +- +> +usize +{ +/ +/ +In +case +usize +is +less +than +32 +bits +we +need +to +guard +against +overflow +. +/ +/ +On +most +platforms +this +compiles +to +nothing +. +/ +/ +TODO +Use +std +: +: +convert +: +: +TryFrom +once +it +' +s +stable +. +if +( +n +as +u64 +) +> +( +: +: +std +: +: +usize +: +: +MAX +as +u64 +) +{ +panic +! +( +" +BUG +: +{ +} +is +too +big +to +be +pointer +sized +" +n +) +} +n +as +usize +} +# +[ +cfg +( +test +) +] +mod +tests +{ +use +super +: +: +ByteClassSet +; +# +[ +test +] +fn +byte_classes +( +) +{ +let +mut +set += +ByteClassSet +: +: +new +( +) +; +set +. +set_range +( +b +' +a +' +b +' +z +' +) +; +let +classes += +set +. +byte_classes +( +) +; +assert_eq +! +( +classes +[ +0 +] +0 +) +; +assert_eq +! +( +classes +[ +1 +] +0 +) +; +assert_eq +! +( +classes +[ +2 +] +0 +) +; +assert_eq +! +( +classes +[ +b +' +a +' +as +usize +- +1 +] +0 +) +; +assert_eq +! +( +classes +[ +b +' +a +' +as +usize +] +1 +) +; +assert_eq +! +( +classes +[ +b +' +m +' +as +usize +] +1 +) +; +assert_eq +! +( +classes +[ +b +' +z +' +as +usize +] +1 +) +; +assert_eq +! +( +classes +[ +b +' +z +' +as +usize ++ +1 +] +2 +) +; +assert_eq +! +( +classes +[ +254 +] +2 +) +; +assert_eq +! +( +classes +[ +255 +] +2 +) +; +let +mut +set += +ByteClassSet +: +: +new +( +) +; +set +. +set_range +( +0 +2 +) +; +set +. +set_range +( +4 +6 +) +; +let +classes += +set +. +byte_classes +( +) +; +assert_eq +! +( +classes +[ +0 +] +0 +) +; +assert_eq +! +( +classes +[ +1 +] +0 +) +; +assert_eq +! +( +classes +[ +2 +] +0 +) +; +assert_eq +! +( +classes +[ +3 +] +1 +) +; +assert_eq +! +( +classes +[ +4 +] +2 +) +; +assert_eq +! +( +classes +[ +5 +] +2 +) +; +assert_eq +! +( +classes +[ +6 +] +2 +) +; +assert_eq +! +( +classes +[ +7 +] +3 +) +; +assert_eq +! +( +classes +[ +255 +] +3 +) +; +} +# +[ +test +] +fn +full_byte_classes +( +) +{ +let +mut +set += +ByteClassSet +: +: +new +( +) +; +for +i +in +0 +. +. +256u16 +{ +set +. +set_range +( +i +as +u8 +i +as +u8 +) +; +} +assert_eq +! +( +set +. +byte_classes +( +) +. +len +( +) +256 +) +; +} +} diff --git a/third_party/rust/aho-corasick/src/nfa/noncontiguous.rs b/third_party/rust/regex/src/dfa.rs similarity index 52% rename from third_party/rust/aho-corasick/src/nfa/noncontiguous.rs rename to third_party/rust/regex/src/dfa.rs index c054ccc82e898..178ad3963d2b2 100644 --- a/third_party/rust/aho-corasick/src/nfa/noncontiguous.rs +++ b/third_party/rust/regex/src/dfa.rs @@ -1,521 +1,552 @@ / * ! -Provides +The +DFA +matching +engine +. +A +DFA +provides +faster +matching +because +the +engine +is +in +exactly +one +state +at +any +point +in +time +. +In +the +NFA +there +may +be +multiple +active +states +and +considerable +CPU +cycles +are +spent +shuffling +them +around +. +In +finite +automata +speak +the +DFA +follows +epsilon +transitions +in +the +regex +far +less +than +the +NFA +. +A +DFA +is a -noncontiguous +classic +trade +off +between +time +and +space +. +The NFA -implementation +is +slower +but +its +memory +requirements +are +typically +small +and +predictable +. +The +DFA +is +faster +but +given +the +right +regex +and +the +right +input +the +number of -Aho -- -Corasick +states +in +the +DFA +can +grow +exponentially . -This +To +mitigate +this +space +problem +we +do +two +things +: +1 +. +We +implement +an +* +online +* +DFA +. +That +is +the +DFA is +constructed +from +the +NFA +during a -low -- -level -API +search +. +When +a +new +state +is +computed +it +is +stored +in +a +cache +so that -generally -only -needs -to +it +may be -used -in -niche -circumstances +reused . -When -possible -prefer -using -[ -AhoCorasick -] -( -crate -: -: -AhoCorasick -) -instead +An +important +consequence of +this +implementation +is +that +states +that +are +never +reached +for a -noncontiguous -NFA -directly +particular +input +are +never +computed . -Using -an -NFA -directly +( +This is -typically -only -necessary -when -one +impossible +in +an +" +offline +" +DFA +which needs -access to +compute +all +possible +states +up +front +. +) +2 +. +If the -[ -Automaton -] -trait -implementation +cache +gets +too +big +we +wipe +it +and +continue +matching . -* -/ -use -alloc -: -: -{ -collections -: -: -{ -BTreeSet -VecDeque -} -vec -vec -: -: -Vec -} -; -use -crate -: -: -{ -automaton -: -: -Automaton -util -: -: -{ -alphabet -: -: -{ -ByteClassSet -ByteClasses -} -error -: -: -{ -BuildError -MatchError -} -prefilter -: -: -{ -self -opposite_ascii_case -Prefilter -} -primitives -: -: -{ -IteratorIndexExt -PatternID -SmallIndex -StateID -} -remapper -: -: -Remapper -search -: -: -{ -Anchored -MatchKind -} -special -: -: -Special -} -} -; -/ -/ -/ -A -noncontiguous -NFA -implementation +In +pathological +cases +a +new +state +can +be +created +for +every +byte of -Aho -- -Corasick +input . -/ -/ -/ -/ -/ -/ -When -possible -prefer -using -[ -AhoCorasick -] ( -crate -: -: -AhoCorasick +e +. +g +. +The +regex +( +a +| +b ) -instead +* +a +( +a +| +b +) +{ +20 +} +on +a +long +sequence of -/ -/ -/ -this -type -directly +a +' +s +and +b +' +s . -Using -an +) +In +this +case +performance +regresses +to +slightly +slower +than +the +full NFA -directly +simulation +in +large +part +because +the +cache +becomes +useless +. +If +the +cache is -typically -only -necessary -/ -/ -/ -when -one -needs -access +wiped +too +frequently +the +DFA +quits +and +control +falls +back to +one +of the -[ -Automaton -] -trait -implementation -. -/ -/ -/ -/ -/ -/ -This NFA -represents +simulations +. +Because +of the " -core +lazy " -implementation +nature of -Aho -- -Corasick -in -this -/ -/ -/ -crate -. -Namely -constructing this -NFA -involving -building -a -trie -and -then -/ -/ -/ -filling -in +DFA the -failure -transitions -between -states -similar -to -what +inner +matching +loop is -/ -/ -/ -described -in -any -standard -textbook -description +considerably +more +complex +than +one +might +expect +out of -Aho -- -Corasick +a +DFA . -/ -/ -/ -/ -/ -/ -In -order -to -minimize -heap -usage -and +A +number +of +tricks +are +employed to -avoid -additional -construction -costs -/ -/ -/ +make +it +fast +. +Tread +carefully +. +N +. +B +. +While this implementation -represents -the -transitions -of -all -states -as -distinct -/ -/ -/ -sparse -memory -allocations -. -This is -where -it -gets -its -name -from -. -That +heavily +commented +Russ +Cox +' +s +series +of +articles +on +regexes is +strongly +recommended +: +< +https +: / / -/ -this -NFA -has -no -contiguous -memory -allocation -for -its -transition -table -. -Each -/ -/ -/ -state -gets -its -own -allocation +swtch . +com / +~ +rsc / +regexp / -/ -/ -/ -While -the -sparse -representation -keeps -memory -usage -to -somewhat -reasonable -/ -/ -/ -levels -it +> +( +As is -still -quite -large -and -also -results +the +DFA +implementation in -somewhat -mediocre -/ -/ -/ -search -performance -. -For +RE2 +which +heavily +influenced this -reason -it -is -almost -always -a -good -idea -to -/ -/ +implementation +. +) +* / use -a -[ -contiguous +std +: +: +collections +: +: +HashMap +; +use +std +: +: +fmt +; +use +std : : -NFA -] -( +iter +: +: +repeat +; +use +std +: +: +mem +; +use +std +: +: +sync +: +: +Arc +; +use crate : : -nfa +exec +: : +ProgramCache +; +use +crate : -contiguous : +prog : -NFA -) -instead -. -It -is +: +{ +Inst +Program +} +; +use +crate +: +: +sparse +: +: +SparseSet +; / / / -marginally -slower -to -build -but -has -higher -throughput +Return +true +if and +only +if +the +given +program can -sometimes -use +be +executed +by +a +DFA +. / / / -an -order -of -magnitude -less -memory -. -The -main -reason -to -use -a -noncontiguous / / / -NFA +Generally +a +DFA is -when -you -need -the -fastest +always possible -construction -time -or -when -a +. +A +pathological +case +where +it +is +not / / / -contiguous -NFA -does -not -have +possible +is +if the -desired -capacity -. -( -The -total number of NFA -/ -/ -/ states -it -can -have -is -fewer -than -a -noncontiguous -NFA -. -) -/ -/ -/ +exceeds +u32 +: +: +MAX +in +which +case / / / -# -Example +this +function +will +return +false +. / / / @@ -523,544 +554,545 @@ Example / / This -example -shows -how -to -build -an -NFA -directly -and -use -it -to -execute -/ -/ -/ -[ -Automaton -: -: -try_find -] -: -/ -/ -/ -/ -/ -/ +function +will +also +return +false +if +the +given +program +has +any +Unicode / / / -use -aho_corasick -: +instructions +( +Char +or +Ranges +) +since +the +DFA +operates +on +bytes +only +. +pub +fn +can_exec +( +insts : +& +Program +) +- +> +bool { -/ -/ -/ -automaton +use +crate : : -Automaton -/ -/ -/ -nfa +prog : : -noncontiguous +Inst : : -NFA -/ -/ -/ -Input -Match -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -& -[ -" -b -" -" -abc -" -" -abcd -" -] -; -/ -/ -/ -let -haystack -= -" -abcd -" +* ; / / +If +for +some +reason +we +manage +to +allocate +a +regex +program +with +more / / -/ -/ -let -nfa -= -NFA +than +i32 : : -new -( -patterns -) -. -unwrap -( -) -; +MAX +instructions +then +we +can +' +t +execute +the +DFA +because +we / / +use +32 +bit +instruction +pointer +deltas +for +memory +savings +. / -assert_eq -! -( / +If +i32 +: +: +MAX +is +the +largest +positive +delta / / -Some -( -Match +then +- +i32 : : -must -( -0 +MAX += += +i32 +: +: +MIN ++ 1 -. -. -2 -) -) -/ +is +the +largest +negative +delta / / -nfa +and +we +are +OK +to +use +32 +bits . -try_find -( -& -Input -: -: -new +if +insts +. +dfa_size_limit += += +0 +| +| +insts +. +len ( -haystack ) -) -? -/ -/ -/ -) -; -/ -/ -/ -# -Ok +> : : -< -( -) -Box -< -dyn std : : -error +i32 : : -Error -> +MAX +as +usize +{ +return +false +; +} +for +inst +in +insts +{ +match +* +inst +{ +Char +( +_ +) +| +Ranges +( +_ +) += > +return +false +EmptyLook +( +_ +) +| +Match ( +_ +) +| +Save ( +_ ) +| +Split +( +_ ) -/ -/ -/ -/ -/ -/ -/ -/ -/ -It -is -also -possible -to -implement -your -own -version -of -try_find -. -See -the -/ -/ -/ -[ -Automaton -] -documentation -for -an -example -. -# -[ -derive +| +Bytes ( -Clone +_ ) -] -pub -struct -NFA += +> { -/ -/ -/ -The -match -semantics -built -into -this -NFA -. -match_kind -: -MatchKind +} +} +} +true +} / / / A -set +reusable +cache of +DFA states . -Each -state -defines -its -own -transitions -a -fail -/ -/ -/ -transition -and -a -set -of -indices -corresponding -to -matches -. / / / / / / -The -first -state -is -always -the -fail -state -which +This +cache is -used -only -as -a -/ -/ -/ -sentinel -. -Namely -in -the -final -NFA -no -transition -into -the -fail -state -/ -/ -/ -exists -. -( -Well -they -do -but -they -aren -' -t -followed -. -Instead +reused +between +multiple +invocations +of the -state -' -s +same +regex / / / -failure -transition +program +. +( +It is -followed +not +shared +simultaneously +between +threads . -) +If +there +is / / / +contention +then +new +caches +are +created +. +) +# +[ +derive +( +Debug +) +] +pub +struct +Cache +{ / / / -The -second -state -( -index -1 -) -is -always -the -dead +Group +persistent +DFA +related +cache state +together . -Dead -states -are +The +sparse +sets / / / -in -every -automaton -but -only +listed +below +are used -when -leftmost -- -{ -first -longest -} -match +as +scratch +space +while +computing +uncached +states +. +inner +: +CacheInner / / / -semantics +qcur +and +qnext are -enabled -. -Specifically -they -instruct -search -to -stop +ordered +sets +with +constant +time / / / -at -specific -points -in -order -to -report -the -correct -match -location +addition +/ +membership +/ +clearing +- +whole +- +set +and +linear +time +iteration . -In +They / / / -the -standard -Aho -- -Corasick -construction -there are -no -transitions +used to +manage +the +sets +of +NFA +states +in +DFA +states +when +computing / / / -the -dead -state +cached +DFA +states . +In +particular +the +order +of +the +NFA +states +matters / / / +for +leftmost +- +first +style +matching +. +Namely +when +computing +a +cached / / / -The -third state -( -index -2 -) -is -generally -intended -to -be the -starting -or +set +of +NFA +states +stops +growing +as +soon +as +the +first +Match / / / -" -root -" -state +instruction +is +observed . -states +qcur : -Vec -< -State -> +SparseSet +qnext +: +SparseSet +} / / / -Transitions -stored -in -a -sparse -representation -via +CacheInner +is +logically +just a -linked -list -. +part +of +Cache +but +groups +together +fields / / / +that +aren +' +t +passed +as +function +parameters +throughout +search +. +( +This +split / / / -Each -transition -contains -three -pieces +is +mostly +an +artifact of -information -: the -byte -it +borrow +checker +. +It +is +happily +paid +. +) +# +[ +derive +( +Debug +) +] +struct +CacheInner +{ / / / -is -defined -for -the -state -it -transitions -to -and -a -link -to +A +cache +of +pre +- +compiled +DFA +states +keyed +by the -next +set +of +NFA +states / / / -transition +and +the +set +of +empty +- +width +flags +set +at +the +byte in the -same -state -( -or -StateID -: -: -ZERO -if -it -is +input +when the -last / / / -transition -) +state +was +observed . / / @@ -1068,104 +1100,75 @@ transition / / / -The -first -transition -for -each -state +A +StatePtr is -determined -by +effectively +a +* State -: -: -sparse -. +but +to +avoid +various +inconvenient / / / +things +we +just +pass +indexes +around +manually +. +The +performance +impact +of / / / -Note -that this -contains -a -complete -set -of -all -transitions +is +probably +an +instruction +or +two in -this -NFA -/ -/ -/ -including -states -that -have -a -dense -representation -for -transitions +the +inner +loop . +However +on / / / -( -Adding -dense -transitions -for +64 +bit +each +StatePtr +is +half +the +size +of a -state -doesn -' -t -remove -its -sparse -/ -/ -/ -transitions -since -deleting -transitions -from -this -particular -sparse -/ -/ -/ -representation -would -be -fairly -expensive +* +State . -) -sparse +compiled : -Vec -< -Transition -> +StateMap / / / -Transitions -stored -in -a -dense -representation +The +transition +table . / / @@ -1173,65 +1176,62 @@ representation / / / -A -state -has -a -row -in -this +The +transition table -if -and -only -if -State -: -: -dense is +laid +out +in +row +- +major +order +where +states +are / / / -not -equal -to -StateID -: -: -ZERO -. -When -not -zero -there +rows +and +the +transitions +for +each +state are -precisely +columns +. +At +a +high +level / / / -NFA -: -: -byte_classes -: -: -alphabet_len -( -) -entries -beginning +given +state +s +and +byte +b +the +next +state +can +be +found at -State -: -: -dense +index / / / -in -this -table +s +* +256 ++ +b . / / @@ -1239,343 +1239,394 @@ table / / / -Generally -a -very -small -minority +This +is of -states -have +course a -dense -representation -/ -/ -/ -since -it -uses -so -much -memory +lie . -dense -: -Vec -< -StateID -> +A +StatePtr +is +actually +a +pointer +to +the / / / -Matches -stored +* +start +* +of +a +row in -linked -list -for -each -state +this +table . +When +indexing +in +the +DFA +' +s +inner +loop / / -/ -/ -/ -/ -Like -sparse -transitions -each -match -has -a -link +/ +this +removes +the +need to +multiply the -next -match -in +StatePtr +by the +stride +. +Yes +it / / / -state +matters . +This +reduces +the +number +of +states +we +can +store +but +: +the / / / +stride +is +rarely +256 +since +we +define +transitions +in +terms +of / / / -The -first -match -for -each -state -is -determined -by -State -: -: -matches +* +equivalence +classes +* +of +bytes . -matches -: -Vec -< -Match -> +Each +class +corresponds +to +a +set +of / / / -The -length -in bytes -of +that +never +discriminate +a +distinct +path +through +the +DFA +from each -pattern -in -this -NFA -. -This -slice -is / / / -indexed -by -PatternID +other . +trans +: +Transitions / / / +A +set +of +cached +start +states +which +are +limited +to +the +number +of / / / -The -number +permutations of -entries -in -this -vector -corresponds -to +flags +set +just +before the -total -number +initial +byte of +input +. +( +The / / / -patterns -in +index +into this -automaton +vec +is +a +EmptyFlags . -pattern_lens -: -Vec -< -SmallIndex -> +) / / / -A -prefilter -for -quickly -skipping -to -candidate -matches -if -pertinent -. -prefilter -: -Option -< -Prefilter -> / / / +N +. +B +. A -set -of -equivalence -classes -in -terms -of -bytes +start +state +can +be +" +dead +" +( +i . -We -compute -this -while +e +. +no +possible +match +) +so +we / / / -building -the -NFA -but -don -' -t -use +represent it -in -the -NFA -' -s -states +with +a +StatePtr . -Instead -we +start_states +: +Vec +< +StatePtr +> / / / -use -this -for -building -the -DFA -. -We -store -it -on +Stack +scratch +space +used +to +follow +epsilon +transitions +in the NFA -since -it -' -s -easy +. / / / +( +This +permits +us to -compute -while -visiting -the -patterns +avoid +recursion . -byte_classes -: -ByteClasses +) +/ +/ +/ / / / The -length -in -bytes -of +maximum +stack +size +is the -shortest -pattern -in -this -automaton +number +of +NFA +states . -This +stack +: +Vec +< +InstPtr +> / / / -information -is -useful -for -detecting -whether -an -automaton -matches +The +total +number +of +times +this +cache +has +been +flushed +by the +DFA / / / -empty -string -or -not +because +of +space +constraints . -min_pattern_len +flush_count : -usize +u64 / / / The -length -in -bytes +total +heap +size of the -longest -pattern -in +DFA +' +s +cache +. +We +use this -automaton +to +determine +when +/ +/ +/ +we +should +flush +the +cache . -This +size +: +usize / / / -information -is -useful -for -keeping -correct -buffer -sizes +Scratch +space +used when -searching +building +instruction +pointer +lists +for +new / / / -on -streams +states . -max_pattern_len +This +helps +amortize +allocation +. +insts_scratch_space : -usize +Vec +< +u8 +> +} / / / The -information -required -to -deduce -which -states -are -" -special -" +transition +table +. +/ +/ +/ +/ +/ +/ +It +is +laid +out in -this +row +- +major +order +with +states +as +rows +and +byte +class / / / -NFA +transitions +as +columns . / / @@ -1583,441 +1634,469 @@ NFA / / / -Since -the -DEAD -and -FAIL -states -are -always -the -first -two -states -and +The +transition +table +is +responsible +for +producing +valid +StatePtrs +. +A / / / -there -are -only -ever -two +StatePtr +points +to +the start -states -( -which -follow -all of -the -match +a +particular +row +in +this +table +. +When / / / -states -) -it -follows -that -we -can -determine -whether -a +indexing +to +find +the +next state -is +this +allows +us +to +avoid a -fail +multiplication / / / -dead -match -or -start -with -just -a -few -comparisons -on +when +computing +an +index +into the -ID -itself -: +table +. +# +[ +derive +( +Clone +) +] +struct +Transitions +{ / / / +The +table +. +table +: +Vec +< +StatePtr +> / / / -is_dead -( -sid -) -: -sid -= -= -NFA -: +The +stride +. +num_byte_classes : -DEAD +usize +} / / / -is_fail +Fsm +encapsulates +the +actual +execution +of +the +DFA +. +# +[ +derive ( -sid +Debug ) -: -sid -= -= +] +pub +struct +Fsm +< +' +a +> +{ +/ +/ +/ +prog +contains +the NFA +instruction +opcodes +. +DFA +execution +uses +either +/ +/ +/ +the +dfa +instructions +or +the +dfa_reverse +instructions +from +/ +/ +/ +exec : : -FAIL +ExecReadOnly +. +( +It +never +uses +ExecReadOnly +. +nfa +which +may +have / / / -is_match -( -sid +Unicode +opcodes +that +cannot +be +executed +by +the +DFA +. ) +prog : -NFA -: -: -FAIL -< -sid -& & -sid -< -= -max_match_id +' +a +Program / / / -is_start -( -sid -) -: -sid -= -= -start_unanchored_id -| -| -sid -= -= -start_anchored_id +The +start +state +. +We +record +it +here +because +the +pointer +may +change / / / +when +the +cache +is +wiped +. +start +: +StatePtr / / / -Note -that -this -only -applies -to +The +current +position +in the -NFA -after -it -has -been -constructed +input . +at +: +usize / / / -During -construction -the -start -states -are +Should +we +quit +after +seeing the first -ones -added -and +match +? +e +. +g +. +When the +caller / / / -match -states -are -inter -- -leaved -with -non -- -match -states +uses +is_match +or +shortest_match . -Once -all -of -the +quit_after_match +: +bool / / / -states -have -been -added -the -states -are -shuffled -such +The +last +state that -the -above +matched +. +/ / / / -predicates -hold +/ +/ +When +no +match +has +occurred +this +is +set +to +STATE_UNKNOWN . -special -: -Special -} -impl -NFA -{ / / / -Create -a -new -Aho -- -Corasick -noncontiguous -NFA -using -the -default / / / -configuration +This +is +only +useful +when +matching +regex +sets . +The +last +match +state / / / +is +useful +because +it +contains +all +of +the +match +instructions +seen / / / -Use -a -[ -Builder -] -if -you -want +thereby +allowing +us to -change +enumerate +which +regexes +in the -configuration +set +matched . -pub -fn -new -< -I -P -> -( -patterns -: -I -) -- -> -Result -< -NFA -BuildError -> -where -I +last_match_si : -IntoIterator -< -Item -= -P -> -P -: -AsRef -< -[ -u8 -] -> -{ -NFA -: -: -builder -( -) -. -build -( -patterns -) -} -/ -/ -/ -A -convenience -method -for -returning -a -new -Aho -- -Corasick -noncontiguous -NFA +StatePtr / / / -builder +The +input +position +of +the +last +cache +flush . +We +use +this +to +determine / / / +if +we +' +re +thrashing +in +the +cache +too +often +. +If +so +the +DFA +quits +so / / / -This -usually -permits -one +that +we +can +fall +back to -just -import the NFA -type +algorithm . -pub -fn -builder -( -) -- -> -Builder -{ -Builder +last_cache_flush : +usize +/ +/ +/ +All +cached +DFA +information +that +is +persisted +between +searches +. +cache : -new -( -) -} +& +' +a +mut +CacheInner } -impl -NFA -{ / / / The -DEAD -state -is -a -sentinel -state -like +result +of +running the -FAIL -state +DFA . -The -DEAD -state / / / -instructs -any -search -to -stop -and -return -any -currently -recorded -match / / / -or -no -match -otherwise -. Generally -speaking -it +the +result is -impossible -for -an +either +a +match +or +not +a +match +but +sometimes +the / / / -unanchored -standard -search -to -enter -a -DEAD -state +DFA +runs +too +slowly +because +the +cache +size +is +too +small . -But -an -anchored +In +that +case +it / / / -search -can -and -so +gives +up +with +the +intent +of +falling +back to -can -a -leftmost -search +the +NFA +algorithm . / / @@ -2025,267 +2104,362 @@ search / / / -We -put -DEAD -before -FAIL -so -that -DEAD -is -always -0 -. -We -repeat -this +The +DFA +can +also +give +up +if +it +runs +out +of +room +to +create +new +states +or +if / / / -decision -across -the -other -Aho +it +sees +non - -Corasicm -automata -so -that -DEAD -/ -/ -/ -states -there -are -always -0 -too -. -It -' -s -not -that -we -need -all -of +ASCII +bytes +in the +presence +of +a +Unicode +word +boundary +. +# +[ +derive +( +Clone +Debug +) +] +pub +enum +Result +< +T +> +{ +Match +( +T +) +NoMatch +( +usize +) +Quit +} +impl +< +T +> +Result +< +T +> +{ / / / -implementations +Returns +true +if +this +result +corresponds to -agree -but -rather -the -contiguous -NFA -and -the -DFA -/ -/ -/ -use a -sort -of -" -premultiplied -" -state -identifier -where -the -only -state +match +. +pub +fn +is_match +( +& +self +) +- +> +bool +{ +match +* +self +{ +Result +: +: +Match +( +_ +) += +> +true +Result +: +: +NoMatch +( +_ +) +| +Result +: +: +Quit += +> +false +} +} / / / -whose -ID -is -always -known +Maps +the +given +function +onto +T and -constant -is +returns the -first -state +result . -Subsequent / / / -state -IDs -depend -on -how -much -space -has -already -been -used -in -the / / / -transition -table +If +this +isn +' +t +a +match +then +this +is +a +no +- +op . +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] pub +fn +map +< +U +F +: +FnMut ( -crate +T ) -const -DEAD +- +> +U +> +( +self +mut +f +: +F +) +- +> +Result +< +U +> +{ +match +self +{ +Result +: : -StateID +Match +( +t +) = -StateID +> +Result : : -new_unchecked +Match ( -0 +f +( +t ) -; +) +Result +: +: +NoMatch +( +x +) += +> +Result +: +: +NoMatch +( +x +) +Result +: +: +Quit += +> +Result +: +: +Quit +} +} / / / -The -FAIL -state -mostly -just -corresponds -to +Sets the -ID -of -any -transition -on -a -/ -/ -/ -state -that -isn -' -t -explicitly -defined +non +- +match +position . -When -one -transitions -into -the -FAIL / / / -state -one -must -follow -the -previous -state -' -s -failure -transition -before / / / -doing -the -next -state -lookup -. -In +If this -way -FAIL -is -more -of -a -sentinel -/ -/ -/ -than +isn +' +t a -state -that -one -actually -transitions -into -. -In -particular -it +non +- +match +then +this is -/ -/ -/ -never -exposed -in -the -Automaton -interface +a +no +- +op . -pub +fn +set_non_match ( -crate +self +at +: +usize ) -const -FAIL +- +> +Result +< +T +> +{ +match +self +{ +Result : -StateID +: +NoMatch +( +_ +) = -StateID +> +Result : : -new_unchecked +NoMatch ( -1 +at ) -; +r += +> +r +} +} +} / / / -Returns -the -equivalence -classes -of -bytes -found -while -constructing +State +is +a +DFA +state +. +It +contains +an +ordered +set +of +NFA +states +( +not / / / -this -NFA +necessarily +complete +) +and +a +smattering +of +flags . / / @@ -2293,1234 +2467,858 @@ NFA / / / -Note -that +The +flags +are +packed +into the -NFA -doesn -' -t -actually -make -use +first +byte of -these -equivalence +data +. / / / -classes +/ +/ +/ +States +don +' +t +carry +their +transitions . Instead -these +transitions are -useful -for -building -the -DFA -when -desired -. -pub -( -crate -) -fn -byte_classes -( -& -self -) -- -> -& -ByteClasses -{ -& -self -. -byte_classes -} +stored +in / / / -Returns a -slice -containing -the -length -of -each -pattern -in -this -searcher +single +row +- +major +table . / / / -It +/ +/ +/ +Delta +encoding is -indexed -by -PatternID -and -has -length -NFA -: -: -patterns_len +used +to +store +the +instruction +pointers . / / / +The +first +instruction +pointer +is +stored +directly +starting / / / -This +at +data +[ +1 +] +and +each +following +pointer is -exposed -for -convenience -when -building +stored +as +an +offset +/ +/ +/ +to +the +previous +one +. +If a -contiguous -NFA +delta +is +in +the +range +- +127 . -But -it +. +127 / / / -can -be -reconstructed -from +it +is +packed +into +a +single +byte +; +Otherwise the -Automaton -API -if -necessary -. -pub +byte +128 ( -crate +- +128 +as +an +i8 ) -fn -pattern_lens_raw +/ +/ +/ +is +coded +as +a +flag +followed +by +4 +bytes +encoding +the +delta +. +# +[ +derive ( -& -self +Clone +Eq +Hash +PartialEq ) -- -> -& -[ -SmallIndex ] +struct +State { -& -self -. -pattern_lens +data +: +Arc +< +[ +u8 +] +> } / / / -Returns +InstPtr +is +a +32 +bit +pointer +into a -slice +sequence of -all -states -in -this -non -- -contiguous -NFA -. -pub -( -crate -) -fn -states +opcodes ( -& -self -) -- -> -& -[ -State -] -{ -& -self +i . -states -} +e +. +it +indexes / / / -Returns -the -underlying -" -special -" -state -information -for -this +an NFA -. -pub -( -crate -) -fn -special -( -& -self +state ) -- -> -& -Special -{ -& -self . -special -} / / / -Swaps -the -states -at -id1 -and -id2 -. / / / +Throughout +this +library +this +is +usually +set +to +usize +but +we +force +a / / / -This -does -not -update -the -transitions -of -any -state -to -account +u32 +here for the +DFA +to +save +on +space +. +type +InstPtr += +u32 +; / / / -state -swap -. -pub -( -crate -) -fn -swap_states -( -& -mut -self -id1 -: -StateID -id2 -: -StateID -) -{ -self -. -states -. -swap -( -id1 -. -as_usize -( -) -id2 +Adds +ip +to +data +using +delta +encoding +with +respect +to +prev . -as_usize -( -) -) -; -} / / / -Re -- -maps -all -state -IDs -in -this -NFA -according -to -the -map -function / / / -given +After +completion +data +will +contain +ip +and +prev +will +be +set +to +ip . -pub -( -crate -) fn -remap +push_inst_ptr ( +data +: & mut -self -map -: -impl -Fn -( -StateID -) -- +Vec +< +u8 > -StateID +prev +: +& +mut +InstPtr +ip +: +InstPtr ) { let -alphabet_len +delta = -self -. -byte_classes -. -alphabet_len -( -) -; -for -state -in -self -. -states -. -iter_mut ( +ip +as +i32 ) -{ -state -. -fail -= -map +- ( -state -. -fail +* +prev +as +i32 ) ; -let -mut -link -= -state -. -sparse -; -while -link -! -= -StateID -: -: -ZERO -{ -let -t -= -& -mut -self -. -sparse -[ -link -] -; -t -. -next -= -map +write_vari32 ( -t -. -next +data +delta ) ; -link +* +prev = -t -. -link +ip ; } -if -state -. -dense -! -= -StateID +struct +InstPtrs +< +' +a +> +{ +base : +usize +data : -ZERO -{ -let -start -= -state -. -dense -. -as_usize -( -) -; -for -next -in -self -. -dense -[ -start -. -. -] +& +' +a [ -. -. -alphabet_len +u8 ] -. -iter_mut -( -) -{ -* -next -= -map -( -* -next -) -; -} -} -} } -/ -/ -/ -Iterate -over -all -of -the -transitions +impl +< +' +a +> +Iterator for -the -given -state -ID -. -pub -( -crate -) +InstPtrs +< +' +a +> +{ +type +Item += +usize +; fn -iter_trans +next ( & +mut self -sid -: -StateID ) - > -impl -Iterator +Option < -Item -= -Transition +usize > -+ -' -_ { -let -mut -link -= +if self . -states -[ -sid -] +data . -sparse -; -core -: -: -iter -: -: -from_fn +is_empty ( -move -| -| -{ -if -link -= -= -StateID -: -: -ZERO +) { return None ; } let -t +( +delta +nread +) = +read_vari32 +( self . -sparse -[ -link -] +data +) ; -link +let +base = -t +self . -link +base +as +i32 ++ +delta ; -Some +debug_assert +! ( -t -) -} +base +> += +0 ) -} -/ -/ -/ -Iterate -over -all -of -the -matches -for -the -given -state -ID -. -pub +; +debug_assert +! ( -crate +nread +> +0 ) -fn -iter_matches -( -& +; self -sid -: -StateID -) -- -> -impl -Iterator -< -Item -= -PatternID -> -+ -' -_ -{ -let -mut -link +. +data = +& self . -states +data [ -sid -] +nread . -matches -; -core -: -: -iter -: -: -from_fn -( -move -| -| -{ -if -link -= -= -StateID -: -: -ZERO -{ -return -None -; -} -let -m -= -self . -matches -[ -link ] ; -link -= -m +self . -link +base += +base +as +usize ; Some ( -m +self . -pid +base ) } -) } -/ -/ -/ -Return -the -link -following -the -one -given -. -If -the -one -given -is -the -last -/ -/ -/ -link -for -the -given -state -then -return -None -. -/ -/ -/ -/ -/ -/ -If -no -previous -link -is -given -then -this -returns -the -first -link -in -the -/ -/ -/ -state -if -one -exists -. -/ -/ -/ -/ -/ -/ -This -is -useful -for -manually -iterating -over -the -transitions -in -a -single -/ -/ -/ -state -without -borrowing -the -NFA -. -This -permits -mutating -other -parts -of -/ -/ -/ -the -NFA -during -iteration -. -Namely -one -can -access -the -transition -pointed -/ -/ -/ -to -by -the -link -via +impl +State +{ +fn +flags +( +& +self +) +- +> +StateFlags +{ +StateFlags +( self . -sparse +data [ -link +0 ] -. +) +} fn -next_link +inst_ptrs ( & self -sid -: -StateID -prev -: -Option -< -StateID -> ) - > -Option +InstPtrs < -StateID +' +_ > { -let -link -= -prev -. -map_or -( +InstPtrs +{ +base +: +0 +data +: +& self . -states +data [ -sid -] +1 . -sparse -| -p -| -self . -sparse -[ -p ] -. -link -) -; -if -link -= -= -StateID -: -: -ZERO -{ -None } -else -{ -Some -( -link -) } } / / / -Follow -the -transition -for +StatePtr +is +a +32 +bit +pointer +to the -given -byte +start +of +a +row in the -given -state +transition +/ +/ +/ +table . -If -no -such / / / -transition -exists -then -the -FAIL -state -ID -is -returned +/ +/ +/ +It +has +many +special +values . -# -[ -inline -( -always -) -] -fn -follow_transition -( -& -self -sid -: -StateID -byte +There +are +two +types +of +special +values : -u8 -) -- -> -StateID -{ -let -s -= -& -self +/ +/ +/ +sentinels +and +flags . -states -[ -sid -] -; / / -This -is -a +/ +/ +/ +/ +Sentinels +corresponds +to special -case +states that -targets -starting +carry +some +kind +of +/ +/ +/ +significance +. +There +are +three +such states +: +unknown +dead and +quit +states +. +/ +/ +/ +/ +/ +/ +Unknown +states +are states +that +haven +' +t +been +computed +yet +. +They +indicate +/ / / -near +that a -start +transition +should +be +filled +in +that +points +to +either +an +existing +/ +/ +/ +cached +state +or +a +new state +altogether . -Namely -after +In +general +an +unknown +state +means +/ +/ +/ +" +follow the -initial -trie -is -constructed +NFA +' +s +epsilon +transitions +. +" / / -we -look -for +/ +/ +/ +/ +Dead states -close -to -the -start -state -to -convert +are +states +that +can +never +lead to a -dense +match +no +matter +what +/ +/ +/ +subsequent +input +is +observed +. +This +means +that +the +DFA +should +quit +/ +/ +/ +immediately +and +return +the +longest +match +it +has +found +thus +far +. / / -representation -for -their -transitions -. -This -winds -up -using -a -lot -more / / -memory -per -state -in -exchange -for -faster -transition -lookups -. -But / / -since -we -only -do -this -for -a -small -number -of +Quit states -( -by -default -) +are +states +that +imply the -/ -/ -memory -usage +DFA is -usually -minimal -. -/ +not +capable +of +matching +the / / / -This -has -* -massive -* -benefit +regex +correctly +. +Currently +this +is +only +used when -executing -searches -because -the +a +Unicode +word +boundary / / -unanchored -starting -state -is -by -far +/ +exists +in the -hottest -state +regex +* and +* +a +non +- +ASCII +byte is +observed +. / / -frequently -visited -. -Moreover -the -' -for -' -loop -below -that -works / / -decently -on -an -actually -sparse +/ +/ +The +other +type +of state +pointer is -disastrous -on a state -that +pointer +with +special +flag +bits +. / / -is -nearly -or -completely -dense -. -if -s -. -dense -= -= -StateID -: -: -ZERO -{ -self -. -follow_transition_sparse -( -sid -byte -) -} -else -{ -let -class -= -usize -: +/ +There +are +two +flags : -from -( -self -. -byte_classes -. -get -( -byte -) -) -; -self -. -dense -[ -s -. -dense +a +start +flag +and +a +match +flag . -as_usize -( -) -+ -class -] -} -} +The +lower +bits +of +both / / / -Like -follow_transition -but -always -uses -the -sparse -representation -. -# -[ -inline -( +kinds always -) -] -fn -follow_transition_sparse -( -& -self -sid -: -StateID -byte -: -u8 -) -- -> -StateID -{ -for -t -in -self -. -iter_trans +contain +a +" +valid +" +StatePtr ( -sid +indicated +by +the +STATE_MAX +/ +/ +/ +mask ) -{ -if -byte -< -= -t -. -byte -{ -if -byte -= -= -t -. -byte -{ -return -t . -next -; -} -break -; -} -} -NFA -: -: -FAIL -} / / / -Set -the -transition -for -the -given -byte +/ +/ +/ +The +start +flag +means +that +the +state +is +a +start +state +and +therefore +may +be +/ +/ +/ +subject to -the -state -ID -given +special +prefix +scanning +optimizations . / / @@ -3528,503 +3326,324 @@ given / / / -Note +The +match +flag +means that -one -should -not -set -transitions -to the -FAIL state -. -It is -not -/ -/ -/ -technically -incorrect -but -it -wastes -space -. -If a -transition -is -not +match +state +and +therefore +the / / / -defined -then -it -is -automatically -assumed -to -lead -to +current +position +in the -FAIL -state -. -fn -add_transition -( -& -mut -self -prev -: -StateID -byte -: -u8 -next -: -StateID -) -- -> -Result -< -( -) -BuildError -> -{ -if -self -. -states -[ -prev -] -. -dense -! -= -StateID -: -: -ZERO -{ -let -dense -= -self -. -states -[ -prev -] -. -dense -; -let -class -= -usize -: -: -from -( -self -. -byte_classes -. -get -( -byte -) -) -; -self -. -dense -[ -dense -. -as_usize -( -) -+ -class -] -= -next -; -} -let -head -= -self -. -states -[ -prev -] -. -sparse -; -if -head -= -= -StateID -: -: -ZERO -| -| -byte -< -self -. -sparse -[ -head -] -. -byte -{ -let -new_link -= -self -. -alloc_transition -( -) -? -; -self -. -sparse -[ -new_link -] -= -Transition -{ -byte -next -link -: -head -} -; -self -. -states -[ -prev -] -. -sparse -= -new_link -; -return -Ok -( +input ( +while +searching ) -) -; -} -else -if -byte -= -= -self -. -sparse -[ -head -] -. -byte -{ -self -. -sparse -[ -head -] +should +be +recorded . -next -= -next -; -return -Ok -( -( -) -) -; -} / / -We -handled -the -only -cases -where -the -beginning -of -the -transition / / -chain -needs -to -change -. -At -this -point -we -now -know -that -there -is / / -at -least -one -entry +The +above +exists +mostly in the -transition -chain -and +service +of +making the -byte -for -that +inner +loop +fast +. / / -transition -is -less -than -the -byte -for +/ +In +particular the -transition -we -' -re -adding -. -let -( -mut -link_prev -mut -link_next -) +inner +* +inner +* +loop +looks +something +like +this +: +/ +/ +/ +/ +/ +/ +ignore +/ +/ +/ +while +state +< = +STATE_MAX +and +i +< +len ( -head -self -. -sparse -[ -head -] -. -link +text ) -; -while -link_next -! -= -StateID : -: -ZERO -& -& -byte -> -self -. -sparse -[ -link_next -] -. -byte -{ -link_prev -= -link_next -; -link_next +/ +/ +/ +state = -self +state . -sparse +next [ -link_next +i ] -. -link -; -} +/ +/ +/ +/ +/ +/ +/ +/ +/ +This +is +nice +because +it +lets +us +execute +a +lazy +DFA +as if -link_next -= -= -StateID -: -: -ZERO -| -| -byte -< -self -. -sparse -[ -link_next -] +it +were +an +/ +/ +/ +entirely +offline +DFA +( +i . -byte -{ -let -link -= -self +e . -alloc_transition -( +with +very +few +instructions ) -? -; -self -. -sparse -[ -link -] -= -Transition -{ -byte -next -link -: -link_next -} -; -self . -sparse -[ -link_prev -] +The +loop +will +/ +/ +/ +quit +only +when +we +need +to +examine +a +case +that +needs +special +attention . -link +type +StatePtr = -link +u32 ; -} -else -{ -assert_eq -! -( -byte -self -. -sparse -[ -link_next -] +/ +/ +/ +An +unknown +state +means +that +the +state +has +not +been +computed +yet +and +that +/ +/ +/ +the +only +way +to +progress +is +to +compute +it . -byte -) +const +STATE_UNKNOWN +: +StatePtr += +1 +< +< +31 ; -self -. -sparse -[ -link_next -] +/ +/ +/ +A +dead +state +means +that +the +state +has +been +computed +and +it +is +known +that +/ +/ +/ +once +it +is +entered +no +future +match +can +ever +occur . -next +const +STATE_DEAD +: +StatePtr = -next +STATE_UNKNOWN ++ +1 ; -} -Ok -( -( -) -) -} / / / -This -sets -every -possible -transition -( -all -255 -of -them -) -for +A +quit +state +means +that the -given +DFA +came +across +some +input +that +it +doesn +' +t / / / -state +know +how to -the -name -next -value +process +correctly . +The +DFA +should +quit +and +another +matching / / / +engine +should +be +run +in +its +place +. +const +STATE_QUIT +: +StatePtr += +STATE_DEAD ++ +1 +; / / / -This +A +start +state is -useful -for -efficiently -initializing +a +state +that +the +DFA +can start -/ -dead -states +in . / / @@ -4032,6216 +3651,6160 @@ states / / / -# -Panics -/ -/ -/ +Note +that +start +states +have +their +lower +bits +set +to +a +state +pointer +. +const +STATE_START +: +StatePtr += +1 +< +< +30 +; / / / -This -requires +A +match +state +means that the -state +regex has -no -transitions -added -to -it -already +successfully +matched . / / / -If -it -has -any -transitions -then -this -panics -. -It -will -also -panic -if / / / -the -state -has -been -densified -prior -to -calling -this -. -fn -init_full_state -( -& -mut -self -prev -: -StateID -next -: -StateID -) -- -> -Result -< -( -) -BuildError -> -{ -assert_eq -! -( -StateID -: -: -ZERO -self -. -states -[ -prev -] -. -dense -" -state -must -not -be -dense -yet -" -) -; -assert_eq -! -( -StateID -: -: -ZERO -self -. +Note +that +match states -[ -prev -] -. -sparse -" -state -must have -zero -transitions -" -) -; -let -mut -prev_link -= -StateID -: -: -ZERO -; -for -byte -in -0 -. -. -= -255 -{ -let -new_link -= -self -. -alloc_transition -( -) -? -; -self -. -sparse -[ -new_link -] -= -Transition -{ -byte -next -link -: -StateID -: -: -ZERO -} -; -if -prev_link -= -= -StateID -: -: -ZERO -{ -self -. -states -[ -prev -] +their +lower +bits +set +to +a +state +pointer . -sparse +const +STATE_MATCH +: +StatePtr = -new_link +1 +< +< +29 ; -} -else -{ -self -. -sparse -[ -prev_link -] +/ +/ +/ +The +maximum +state +pointer . -link -= -new_link -; -} -prev_link -= -new_link -; -} -Ok -( -( -) -) -} +This +is +useful +to +mask +out +the +" +valid +" +state / / / -Add +pointer +from a -match -for +state +with the -given -pattern -ID +" +start +" +or +" +match +" +bits +set +. +/ +/ +/ +/ +/ +/ +It +doesn +' +t +make +sense to -the +use +this +with +unknown +dead +or +quit state -for -the -given -ID +/ +/ +/ +pointers +since +those +pointers +are +sentinels +and +never +have +their +lower +/ +/ +/ +bits +set +to +anything +meaningful . -fn -add_match -( -& -mut -self -sid -: -StateID -pid +const +STATE_MAX : -PatternID -) -- -> -Result -< -( -) -BuildError -> -{ -let -head +StatePtr = -self -. -states -[ -sid -] -. -matches -; -let -mut -link -= -head +STATE_MATCH +- +1 ; -while -self -. -matches -[ -link -] -. -link -! -= -StateID -: -: -ZERO -{ -link -= -self +/ +/ +/ +Byte +is +a +u8 +in +spirit +but +a +u16 +in +practice +so +that +we +can +represent +the +/ +/ +/ +special +EOF +sentinel +value . -matches +# [ -link -] -. -link -; -} -let -new_match_link -= -self -. -alloc_match +derive ( +Copy +Clone +Debug ) -? -; -self -. -matches -[ -new_match_link -] -. -pid -= -pid -; -if -link -= -= -StateID -: -: -ZERO -{ -self -. -states -[ -sid -] -. -matches -= -new_match_link -; -} -else -{ -self -. -matches -[ -link ] -. -link -= -new_match_link -; -} -Ok -( +struct +Byte ( +u16 ) -) -} +; / / / -Copy -matches -from -the -src -state -to -the -dst -state +A +set +of +flags +for +zero +- +width +assertions . -This -is -useful +# +[ +derive +( +Clone +Copy +Eq +Debug +Default +Hash +PartialEq +) +] +struct +EmptyFlags +{ +start +: +bool +end +: +bool +start_line +: +bool +end_line +: +bool +word_boundary +: +bool +not_word_boundary +: +bool +} / / / -when +A +set +of +flags +describing +various +configurations +of a -match +DFA state -can -be -reached -via -a -failure -transition . -In -which +This +is / / / -case -you -' -ll -want -to -copy -the -matches +represented +by +a +u8 +so +that +it +is +compact +. +# +[ +derive ( -if -any +Clone +Copy +Eq +Default +Hash +PartialEq ) -from -the -state -reached +] +struct +StateFlags +( +u8 +) +; +impl +Cache +{ / / / -by -the -failure -transition -to +Create +new +empty +cache +for the -original -state -you -were -at +DFA +engine . +pub fn -copy_matches +new ( -& -mut -self -src +prog : -StateID -dst -: -StateID +& +Program ) - > -Result -< -( -) -BuildError -> +Self { +/ +/ +We +add +1 +to +account +for +the +special +EOF +byte +. let -head_dst +num_byte_classes = -self +( +prog . -states +byte_classes [ -dst +255 ] -. -matches +as +usize ++ +1 +) ++ +1 ; let -mut -link_dst +starts = -head_dst -; -while -self -. -matches -[ -link_dst -] -. -link +vec ! -= -StateID -: -: -ZERO -{ -link_dst -= -self -. -matches [ -link_dst +STATE_UNKNOWN +; +256 ] -. -link ; -} let mut -link_src +cache = -self -. -states +Cache +{ +inner +: +CacheInner +{ +compiled +: +StateMap +: +: +new +( +num_byte_classes +) +trans +: +Transitions +: +: +new +( +num_byte_classes +) +start_states +: +starts +stack +: +vec +! [ -src ] -. -matches -; -while -link_src -! -= -StateID +flush_count : +0 +size : -ZERO -{ -let -new_match_link -= -StateID +0 +insts_scratch_space +: +vec +! +[ +] +} +qcur +: +SparseSet : : new ( -self +prog . -matches +insts . len ( ) ) -. -map_err -( -| -e -| -{ -BuildError -: +qnext : -state_id_overflow -( -StateID +SparseSet : : -MAX -. -as_u64 +new ( -) -e +prog . -attempted +insts +. +len ( ) ) } +; +cache +. +inner +. +reset_size +( ) -? ; +cache +} +} +impl +CacheInner +{ +/ +/ +/ +Resets +the +cache +size +to +account +for +fixed +costs +such +as +the +program +/ +/ +/ +and +stack +sizes +. +fn +reset_size +( +& +mut +self +) +{ self . -matches +size += +( +self . -push +start_states +. +len ( -Match -{ -pid +) +* +mem +: +: +size_of +: : +< +StatePtr +> +( +) +) ++ +( self . -matches -[ -link_src -] +stack . -pid -link -: -StateID +len +( +) +* +mem : : -ZERO -} -) -; -if -link_dst -= -= -StateID +size_of : : -ZERO -{ -self -. -states -[ -dst -] -. -matches -= -new_match_link +< +InstPtr +> +( +) +) ; } -else -{ -self -. -matches -[ -link_dst -] -. -link -= -new_match_link -; } -link_dst -= -new_match_link -; -link_src -= -self -. -matches +impl +< +' +a +> +Fsm +< +' +a +> +{ +# [ -link_src -] -. -link -; -} -Ok +cfg_attr ( +feature += +" +perf +- +inline +" +inline ( +always ) ) -} -/ -/ -/ -Create +] +pub +fn +forward +( +prog +: +& +' a -new -entry -in -NFA +Program +cache : +& +ProgramCache +quit_after_match +: +bool +text : -trans -if -there -' -s -room -and -return -that -/ -/ -/ -entry -' -s -ID -. -If -there -' -s -no -room -then -an -error -is -returned -. -fn -alloc_transition -( & -mut -self +[ +u8 +] +at +: +usize ) - > Result < -StateID -BuildError +usize > { let -id +mut +cache = -StateID -: -: -new -( -self -. -sparse +cache . -len +borrow_mut ( ) -) +; +let +cache += +& +mut +cache . -map_err -( -| -e -| +dfa +; +let +mut +dfa += +Fsm { -BuildError +prog +start : +0 +/ +/ +filled +in +below +at +quit_after_match +last_match_si : -state_id_overflow -( -StateID +STATE_UNKNOWN +last_cache_flush : +at +cache : -MAX +& +mut +cache . -as_u64 +inner +} +; +let ( +empty_flags +state_flags ) -e += +dfa . -attempted +start_flags ( +text +at ) -) -} -) -? ; -self +dfa . -sparse +start += +match +dfa . -push +start_state ( -Transition +& +mut +cache +. +qcur +empty_flags +state_flags +) +{ +None += +> +return +Result : : -default +Quit +Some +( +STATE_DEAD +) += +> +return +Result +: +: +NoMatch ( +at ) +Some +( +si ) += +> +si +} ; -Ok +debug_assert +! ( -id +dfa +. +start +! += +STATE_UNKNOWN ) -} -/ -/ -/ -Create -a -new -entry -in -NFA -: -: -matches -if -there -' -s -room -and -return -that -/ -/ -/ -entry -' -s -ID +; +dfa . -If -there -' -s -no -room -then -an -error -is -returned +exec_at +( +& +mut +cache +. +qcur +& +mut +cache . +qnext +text +) +} +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +pub fn -alloc_match +reverse ( +prog +: & -mut -self +' +a +Program +cache +: +& +ProgramCache +quit_after_match +: +bool +text +: +& +[ +u8 +] +at +: +usize ) - > Result < -StateID -BuildError +usize > { let -id +mut +cache = -StateID -: -: -new -( -self -. -matches +cache . -len +borrow_mut ( ) -) +; +let +cache += +& +mut +cache . -map_err -( -| -e -| +dfa_reverse +; +let +mut +dfa += +Fsm { -BuildError +prog +start : +0 +/ +/ +filled +in +below +at +quit_after_match +last_match_si : -state_id_overflow -( -StateID +STATE_UNKNOWN +last_cache_flush : +at +cache : -MAX +& +mut +cache . -as_u64 +inner +} +; +let ( +empty_flags +state_flags ) -e += +dfa . -attempted +start_flags_reverse ( +text +at ) -) -} -) -? ; -self +dfa . -matches +start += +match +dfa . -push +start_state ( -Match +& +mut +cache +. +qcur +empty_flags +state_flags +) +{ +None += +> +return +Result : : -default +Quit +Some ( +STATE_DEAD ) += +> +return +Result +: +: +NoMatch +( +at ) -; -Ok +Some ( -id +si ) += +> +si } -/ -/ -/ -Create -a -new -set -of -N -transitions -in -this -NFA -' -s -dense -transition -/ -/ -/ -table +; +debug_assert +! +( +dfa . -The -ID -return -corresponds -to -the -index -at -which -the -N -/ -/ -/ -transitions -begin +start +! += +STATE_UNKNOWN +) +; +dfa . -So -id -+ -0 -is -the -first -transition -and -id -+ +exec_at_reverse ( -N +& +mut +cache +. +qcur +& +mut +cache +. +qnext +text +) +} +# +[ +cfg_attr +( +feature += +" +perf - -1 +inline +" +inline +( +always ) -is -/ -/ -/ -the -last -. -/ -/ -/ -/ -/ -/ -N -is -determined -via -NFA -: +) +] +pub +fn +forward_many +( +prog : -byte_classes +& +' +a +Program +cache : +& +ProgramCache +matches : -alphabet_len -. -fn -alloc_dense_state -( & mut -self +[ +bool +] +text +: +& +[ +u8 +] +at +: +usize ) - > Result < -StateID -BuildError +usize > { -let -id -= -StateID -: -: -new +debug_assert +! ( -self +matches +. +len +( +) += += +prog . -dense +matches . len ( ) ) +; +let +mut +cache += +cache +. +borrow_mut +( +) +; +let +cache += +& +mut +cache . -map_err -( -| -e -| +dfa +; +let +mut +dfa += +Fsm { -BuildError +prog +start : +0 +/ +/ +filled +in +below +at +quit_after_match : -state_id_overflow -( -StateID +false +last_match_si : +STATE_UNKNOWN +last_cache_flush : -MAX +at +cache +: +& +mut +cache . -as_u64 +inner +} +; +let ( +empty_flags +state_flags ) -e += +dfa . -attempted +start_flags ( +text +at ) -) -} -) -? ; -/ -/ -We -use -FAIL -because -it -' -s -the -correct -default -. -If -a -state -doesn -' -t -/ -/ -have -a -transition -defined -for -every -possible -byte -value -then -the -/ -/ -transition -function -should -return -NFA -: -: -FAIL -. -self +dfa . -dense +start += +match +dfa . -extend +start_state ( -core -: -: -iter +& +mut +cache +. +qcur +empty_flags +state_flags +) +{ +None += +> +return +Result : : -repeat +Quit +Some ( -NFA +STATE_DEAD +) += +> +return +Result : : -FAIL -) -. -take +NoMatch ( -self -. -byte_classes -. -alphabet_len -( -) -) +at ) -; -Ok +Some ( -id +si ) += +> +si } -/ -/ -/ -Allocate -and -add -a -fresh -state -to -the -underlying -NFA -and -return -its -/ -/ -/ -ID +; +debug_assert +! ( -guaranteed -to -be -one -more -than -the -ID -of -the -previously -allocated -/ -/ -/ -state -) +dfa . -If -the -ID -would -overflow -StateID -then -this -returns -an -error +start +! += +STATE_UNKNOWN +) +; +let +result += +dfa . -fn -alloc_state +exec_at ( & mut -self -depth -: -usize +cache +. +qcur +& +mut +cache +. +qnext +text ) -- -> -Result -< -StateID -BuildError -> -{ -/ -/ -This -is -OK -because -we -error -when -building -the -trie +; if -we -see -a -/ -/ -pattern -whose -length -cannot -fit -into -a -' -SmallIndex -' -and -the -longest -/ -/ -possible -depth -corresponds -to -the -length -of -the -longest -pattern +result . -let -depth -= -SmallIndex -: -: -new +is_match ( -depth ) +{ +if +matches . -expect +len ( -" -patterns -longer -than -SmallIndex -: -: -MAX -are -not -allowed -" ) += += +1 +{ +matches +[ +0 +] += +true ; -let -id +} +else +{ +debug_assert +! +( +dfa +. +last_match_si +! = -StateID -: -: -new +STATE_UNKNOWN +) +; +debug_assert +! ( -self +dfa . -states +last_match_si +! += +STATE_DEAD +) +; +for +ip +in +dfa . -len +state ( -) +dfa +. +last_match_si ) . -map_err +inst_ptrs ( -| -e -| +) { -BuildError -: -: -state_id_overflow -( -StateID +if +let +Inst : : -MAX -. -as_u64 -( -) -e -. -attempted +Match ( +slot ) -) -} -) -? -; -self -. -states += +dfa . -push -( -State +prog +[ +ip +] { -sparse -: -StateID -: -: -ZERO -dense -: -StateID -: -: -ZERO matches -: -StateID -: -: -ZERO -fail -: -self -. -special -. -start_unanchored_id -depth -} -) +[ +slot +] += +true ; -Ok -( -id -) } } +} +} +result +} / / -SAFETY -: -' -start_state -' -always -returns -a -valid -state -ID -' -next_state -' -always -/ / -returns -a -valid -state -ID -given +Executes +the +DFA +on a -valid -state -ID +forward +NFA . -We -otherwise -claim -that / / -all -other -methods +/ +/ +/ +/ +{ +qcur +qnext +} are -correct -as -well +scratch +ordered +sets +which +may +be +non +- +empty . -unsafe -impl -Automaton -for -NFA -{ # [ +cfg_attr +( +feature += +" +perf +- +inline +" inline ( always ) +) ] fn -start_state +exec_at ( & +mut self -anchored +qcur +: +& +mut +SparseSet +qnext +: +& +mut +SparseSet +text : -Anchored +& +[ +u8 +] ) - > Result < -StateID -MatchError +usize > { -match -anchored -{ -Anchored -: +/ +/ +For +the +most +part +the +DFA +is +basically : -No +/ +/ +/ +/ +last_match = -> -Ok -( -self -. -special -. -start_unanchored_id -) -Anchored -: +null +/ +/ +while +current_byte +! += +EOF : -Yes +/ +/ +si = -> -Ok -( -self -. -special +current_state . -start_anchored_id -) -} -} -# +next [ -inline -( -always -) +current_byte ] -fn -next_state -( -& -self -anchored -: -Anchored -mut -sid -: -StateID -byte +/ +/ +if +si +is +match +/ +/ +last_match += +si +/ +/ +return +last_match +/ +/ +/ +/ +However +we +need +to +deal +with +a +few +things : -u8 -) -- -> -StateID -{ / / +/ +/ +1 +. This -terminates -since -: +is +an +* +online +* +DFA +so +the +current +state +' +s +next +list / / +may +not +point +to +anywhere +yet +so +we +must +go +out +and +compute / / -1 -. -state +them . -fail -never -points -to +( +They +are +then +cached +into the -FAIL +current state +' +s +next +list +/ +/ +to +avoid +re +- +computation . +) / / 2 . -All +If +we +come +across +a state +that +is +known +to +be +dead +( +i . -fail -values -point +e +. +never +/ +/ +leads to a -state -closer -to -the -start -state +match +) +then +we +can +quit +early . / / 3 . -The -start -state -has -no -transitions -to +If the -FAIL -state -. -loop -{ -let -next -= -self -. -follow_transition -( -sid -byte -) -; +caller +just +wants +to +know if -next -! -= -NFA -: -: -FAIL -{ -return -next -; -} +a +match +occurs +then +we / / -For -an -anchored -search +can +quit +as +soon +as we -never -follow -failure -transitions +know +we +have +a +match +. +( +Full +leftmost / / -because -failure -transitions -lead -us -down -a -path -to -matching +first +semantics +require +continuing +on +. +) / / -a -* -proper -* -suffix -of +4 +. +If +we +' +re +in the -path +start +state +then we -were -on -. -Thus -it can -only +use +a +pre +- +computed +set / / -produce -matches -that -appear -after -the -beginning of -the -search -. -if -anchored -. -is_anchored -( -) -{ -return -NFA -: -: -DEAD -; -} -sid -= -self -. -states -[ -sid -] -. -fail -( -) -; -} -} -# -[ -inline -( -always -) -] -fn -is_special -( -& -self -sid -: -StateID -) -- -> -bool -{ -sid -< -= -self -. -special -. -max_special_id -} -# -[ -inline -( -always -) -] -fn -is_dead -( -& -self -sid -: -StateID -) -- -> -bool -{ -sid -= -= -NFA -: -: -DEAD -} -# -[ -inline -( -always -) -] -fn -is_match -( -& -self -sid -: -StateID -) -- -> -bool -{ +prefix +literals +to +skip +quickly +along +the +input +. / / -N +5 . -B +After +the +input +is +exhausted +we +run +the +DFA +on +one +symbol +/ +/ +that +stands +for +EOF . This -returns -true -when -sid -= -= -NFA -: -: -FAIL -but -that -' -s -okay -because +is +useful +for +handling +empty +width / / -NFA -: -: -FAIL -is -not +assertions +. +/ +/ +6 +. +We +can +' +t actually -a -valid +do state -ID -from -the -perspective -of +. +next +[ +byte +] +. +Instead +we +have +to +do / / -the -Automaton -trait +state . -Namely -it -is -never -returned -by -' -start_state -' +next +[ +byte_classes +[ +byte +] +] +which +permits +us +to +keep +the / / -or -by ' -next_state +next ' +list +very +small . -So -we -don +/ +/ +/ +/ +Since +there ' -t +s +a +bunch +of +extra +stuff +we need to -care -about -it -here +consider +we +do +some +/ +/ +pretty +hairy +tricks +to +get +the +inner +loop +to +run +as +fast +as +/ +/ +possible . +debug_assert ! -self -. -is_dead -( -sid -) -& -& -sid -< -= -self -. -special -. -max_match_id -} -# -[ -inline -( -always -) -] -fn -is_start ( -& -self -sid -: -StateID -) -- -> -bool -{ -sid -= -= -self -. -special -. -start_unanchored_id -| -| -sid -= -= +! self . -special +prog . -start_anchored_id -} -# -[ -inline -( -always -) -] -fn -match_kind -( -& -self +is_reverse ) -- -> -MatchKind -{ -self +; +/ +/ +The +last +match +is +the +currently +known +ending +match +position . -match_kind -} -# -[ -inline -( +It +is +/ +/ +reported +as +an +index +to +the +most +recent +byte +that +resulted +in +a +/ +/ +transition +to +a +match +state +and +is always -) -] -fn -patterns_len -( -& -self -) -- -> -usize -{ -self +stored +in +capture +slot +1 +/ +/ +when +searching +forwards . -pattern_lens +Its +maximum +value +is +text . len ( ) -} -# -[ -inline -( -always -) -] -fn -pattern_len -( -& -self -pid +. +let +mut +result += +Result : -PatternID -) -- -> -usize -{ +: +NoMatch +( self . -pattern_lens -[ -pid -] -. -as_usize -( +at ) -} -# -[ -inline +; +let ( -always +mut +prev_si +mut +next_si ) -] -fn -min_pattern_len += ( -& -self -) -- -> -usize -{ self . -min_pattern_len -} -# -[ -inline -( -always -) -] -fn -max_pattern_len -( -& +start self +. +start ) -- -> -usize -{ +; +let +mut +at += self . -max_pattern_len -} -# -[ -inline -( -always -) -] -fn -match_len +at +; +while +at +< +text +. +len ( -& -self -sid -: -StateID ) -- -> -usize { -self +/ +/ +This +is +the +real +inner +loop . -iter_matches -( -sid -) +We +take +advantage +of +special +bits +/ +/ +set +in +the +state +pointer +to +determine +whether +a +state +is +in +the +/ +/ +" +common +" +case +or +not . -count -( -) -} -# -[ -inline -( -always -) -] -fn -match_pattern -( -& -self -sid -: -StateID -index -: -usize -) +Specifically +the +common +case +is +a +/ +/ +non - -> -PatternID -{ -self +match +non +- +start +non +- +dead +state +that +has +already +been +/ +/ +computed . -iter_matches -( -sid -) +So +long +as +we +remain +in +the +common +case +this +inner +/ +/ +loop +will +chew +through +the +input . -nth -( -index -) +/ +/ +/ +/ +We +also +unroll +the +loop +4 +times +to +amortize +the +cost +of +checking +/ +/ +whether +we +' +ve +consumed +the +entire +input . -unwrap -( -) -} -# -[ -inline -( +We +are +also +careful +/ +/ +to +make +sure +that +prev_si always -) -] -fn -memory_usage -( -& -self -) -- -> -usize -{ -self +represents +the +previous +state +/ +/ +and +next_si +always +represents +the +next +state +after +the +loop +/ +/ +exits +even +if +it +isn +' +t +always +true +inside +the +loop . -states +while +next_si +< += +STATE_MAX +& +& +at +< +text . len ( ) -* -core -: -: -mem -: -: -size_of -: -: -< -State -> -( -) -+ -self +{ +/ +/ +Argument +for +safety +is +in +the +definition +of +next_si . -sparse +prev_si += +unsafe +{ +self . -len +next_si ( +next_si +text +at ) -* -core -: -: -mem -: -: -size_of -: -: -< -Transition +} +; +at ++ += +1 +; +if +prev_si > -( -) +STATE_MAX +| +| +at + -self -. -matches +2 +> += +text . len ( ) -* -core -: -: +{ mem : : -size_of -: -: -< -Match -> +swap ( +& +mut +prev_si +& +mut +next_si ) -+ +; +break +; +} +next_si += +unsafe +{ self . -dense -. -len +next_si ( +prev_si +text +at ) -* -StateID -: -: -SIZE +} +; +at + += +1 +; +if +next_si +> +STATE_MAX +{ +break +; +} +prev_si += +unsafe +{ self . -pattern_lens -. -len +next_si ( +next_si +text +at ) -* -SmallIndex +} +; +at ++ += +1 +; +if +prev_si +> +STATE_MAX +{ +mem : : -SIZE -+ -self -. -prefilter -. -as_ref -( -) -. -map_or -( -0 -| -p -| -p -. -memory_usage -( -) -) -} -# -[ -inline -( -always -) -] -fn -prefilter +swap ( & -self -) -- -> -Option -< +mut +prev_si & -Prefilter -> -{ -self -. -prefilter -. -as_ref -( +mut +next_si ) +; +break +; } -} -/ -/ -/ -A -representation -of -a -sparse -NFA -state -for -an -Aho -- -Corasick -automaton -. -/ -/ -/ -/ -/ -/ -It -contains -the -transitions -to -the -next -state -a -failure -transition -for -/ -/ -/ -cases -where -there -exists -no -other -transition -for -the -current -input -byte -/ -/ -/ -and -the -matches -implied -by -visiting -this -state -( -if -any -) -. -# -[ -derive -( -Clone -Debug -) -] -pub +next_si += +unsafe +{ +self +. +next_si ( -crate +prev_si +text +at ) -struct -State +} +; +at ++ += +1 +; +} +if +next_si +& +STATE_MATCH +> +0 { / / -/ A -pointer -to -NFA -: -: -trans -corresponding -to -the -head -of -a -linked -list -/ -/ -/ -containing -all +match +state +is +outside of the -transitions -for -this -state -. -/ -/ +common +case +because +it +needs / / +special +case +analysis +. +In +particular +we +need +to +record +the / / -This -is -StateID -: -: -ZERO -if +last +position +as +having +matched and -only +possibly +quit +the +DFA if -this -state -has -zero -transitions -. -sparse -: -StateID -/ / / -A -pointer +we +don +' +t +need to -a -row -of -N -transitions -in -NFA +keep +matching +. +next_si +& += +! +STATE_MATCH +; +result += +Result : : -dense +Match +( +at +- +1 +) +; +if +self . -These -/ -/ -/ -transitions -correspond -precisely -to -what -is -obtained -by -traversing -/ +quit_after_match +{ +return +result +; +} +self +. +last_match_si += +next_si +; +prev_si += +next_si +; / / -sparse -but +This permits -constant -time -lookup +short +- +circuiting +when +matching +a +regex +set . / / -/ -/ -/ -/ -When +In +particular +if this -is -zero -( -which -is -true -for -most +DFA +state +contains +only +match states -in -the -default / / +then +it +' +s +impossible +to +extend +the +set +of +matches +since +/ / -configuration +match +states +are +final +. +Therefore +we +can +quit +. +if +self +. +prog +. +matches +. +len +( ) -then -this +> +1 +{ +let state -has -no -dense -representation += +self . -/ -/ -/ -/ -/ -/ -Note -that -N -is -equal -to -NFA -: -: -byte_classes -: -: -alphabet_len +state ( +next_si ) +; +let +just_matches += +state . -This -is -/ -/ -/ -typically -much -less -than -256 +inst_ptrs +( +) +. +all +( +| +ip +| +self +. +prog +[ +ip +] +. +is_match ( -the -maximum -value ) -. -dense -: -StateID -/ +) +; +if +just_matches +{ +return +result +; +} +} / / -A -pointer -to -NFA -: -: -matches -corresponding -to +Another +inner +loop +! +If the -head -of -a -linked -list -/ +DFA +stays +in +this +particular / / -containing +match +state +then +we +can +rip +through all of the -matches -for -this -state -. +input / / +very +quickly +and +only +recording +the +match +location +once / / +we +' +ve +left +this +particular +state +. +let +cur += +at +; +while +( +next_si +& +! +STATE_MATCH +) += += +prev_si +& +& +at ++ +2 +< +text +. +len +( +) +{ / / -This +Argument +for +safety is -StateID +in +the +definition +of +next_si +. +next_si += +unsafe +{ +self +. +next_si +( +next_si +& +! +STATE_MATCH +text +at +) +} +; +at ++ += +1 +; +} +if +at +> +cur +{ +result += +Result : : -ZERO -if -and -only +Match +( +at +- +2 +) +; +} +} +else if -this -state -is -not -a -match -state -. -matches -: -StateID -/ +next_si +& +STATE_START +> +0 +{ / / -The +A +start state -that -should -be -transitioned -to -if -the -current -byte +isn +' +t in the +common +case +because +we +may / / +want +to +do +quick +prefix +scanning +. +If +the +program +doesn +' +t +/ / -haystack -does -not have a -corresponding -transition -defined -in -this -/ +detected +prefix +then +start +states +are +actually / / -state +considered +common +and +this +case +is +never +reached . -fail +debug_assert +! +( +self +. +has_prefix +( +) +) +; +next_si +& += +! +STATE_START +; +prev_si += +next_si +; +at += +match +self +. +prefix_at +( +text +at +) +{ +None += +> +return +Result +: +: +NoMatch +( +text +. +len +( +) +) +Some +( +i +) += +> +i +} +; +} +else +if +next_si +> += +STATE_UNKNOWN +{ +if +next_si += += +STATE_QUIT +{ +return +Result : -StateID -/ +: +Quit +; +} / / -The -depth -of -this -state -. -Specifically +Finally this -is +corresponds +to the -distance -from -this -/ +case +where +the +transition / / +entered +a state +that +can +never +lead to -the -starting +a +match +or +a state -. -( -For -the -special -sentinel -states -DEAD -and -/ / / -FAIL -their -depth -is -always -0 +that +hasn +' +t +been +computed +yet . -) The -depth -of -a -starting -state -is -0 -. -/ -/ -/ -/ +latter +being +the +" +slow +" / / -Note -that -depth -is -currently -not -used -in -this -non -- -contiguous -NFA +path . -It -/ +let +byte += +Byte +: +: +byte +( +text +[ +at +- +1 +] +) +; / / -may -in +We +no +longer +care +about the -future -but -it -is -used +special +bits in the -contiguous -NFA -. -Namely -it -/ -/ -/ -permits -an -optimization -where -states -near -the -starting state -have -their -/ -/ -/ -transitions -stored -in -a -dense -fashion -but -all -other -states -have -their -/ / / -transitions -stored -in -a -sparse -fashion +pointer . -( -This -non -- -contiguous -NFA -uses -/ +prev_si +& += +STATE_MAX +; / / -a -sparse -representation -for -all -states -unconditionally +Record +where +we +are . -) -In -any -case -/ -/ -/ -this +This is -really -the -only -convenient -place +used to -compute -and -store -this -/ +track +progress +for / / -information -which +determining +whether we -need -when -building +should +quit +if +we +' +ve +flushed the -contiguous -NFA -. -depth -: -SmallIndex -} -impl -State -{ -/ / / -Return -true -if -and -only -if -this -state -is -a +cache +too +much +. +self +. +at += +at +; +next_si += match -state +self . -pub +next_state ( -crate +qcur +qnext +prev_si +byte ) -fn -is_match +{ +None += +> +return +Result +: +: +Quit +Some +( +STATE_DEAD +) += +> +return +result +. +set_non_match +( +at +) +Some +( +si +) += +> +si +} +; +debug_assert +! ( -& -self +next_si +! += +STATE_UNKNOWN ) -- +; +if +next_si +& +STATE_MATCH > -bool +0 { -self -. -matches +next_si +& += ! +STATE_MATCH +; +result = -StateID +Result : : -ZERO -} -/ -/ -/ -Returns -the -failure -transition -for -this -state -. -pub +Match ( -crate +at +- +1 ) -fn -fail -( -& +; +if self -) -- -> -StateID +. +quit_after_match { +return +result +; +} self . -fail +last_match_si += +next_si +; +} +prev_si += +next_si +; +} +else +{ +prev_si += +next_si +; +} } / / -/ -Returns +Run the -depth -of -this -state -. -That -is +DFA +once +more +on the -number -of -transitions -/ +special +EOF +sentinel +value +. / / -this -state -is -from +We +don +' +t +care +about +the +special +bits +in the -start state +pointer +any +more +/ +/ +so +get +rid of -the -NFA +them . -pub +prev_si +& += +STATE_MAX +; +prev_si += +match +self +. +next_state +( +qcur +qnext +prev_si +Byte +: +: +eof ( -crate ) -fn -depth +) +{ +None += +> +return +Result +: +: +Quit +Some ( -& -self +STATE_DEAD ) -- += > -SmallIndex -{ -self +return +result . -depth -} -} -/ -/ -/ -A -single -transition -in -a -non -- -contiguous -NFA +set_non_match +( +text . -# -[ -derive +len ( -Clone -Copy -Default ) -] -# -[ -repr +) +Some ( -packed +si ) -] -pub += +> +si +& +! +STATE_START +} +; +debug_assert +! ( -crate +prev_si +! += +STATE_UNKNOWN ) -struct -Transition +; +if +prev_si +& +STATE_MATCH +> +0 { -byte -: -u8 -next +prev_si +& += +! +STATE_MATCH +; +self +. +last_match_si += +prev_si +; +result += +Result : -StateID -link : -StateID +Match +( +text +. +len +( +) +) +; +} +result } -impl -Transition -{ / / / -Return +Executes the -byte -for -which -this -transition -is -defined +DFA +on +a +reverse +NFA . -pub +# +[ +cfg_attr ( -crate +feature += +" +perf +- +inline +" +inline +( +always +) ) +] fn -byte +exec_at_reverse ( & +mut self +qcur +: +& +mut +SparseSet +qnext +: +& +mut +SparseSet +text +: +& +[ +u8 +] ) - > -u8 +Result +< +usize +> { -self +/ +/ +The +comments +in +exec_at +above +mostly +apply +here +too . -byte -} +The +main / / +difference +is +that +we +move +backwards +over +the +input +and +we +look +for +/ / -Return the -ID +longest +possible +match +instead of the -state -that -this -transition -points +leftmost +- +first +match +. +/ +/ +/ +/ +N +. +B +. +The +code +duplication +here +is +regrettable +. +Efforts to +improve +/ +/ +it +without +sacrificing +performance +are +welcome . -pub +- +- +- +AG +debug_assert +! ( -crate +self +. +prog +. +is_reverse ) -fn -next +; +let +mut +result += +Result +: +: +NoMatch ( -& self +. +at ) -- -> -StateID -{ +; +let +( +mut +prev_si +mut +next_si +) += +( self . -next -} -/ +start +self +. +start +) +; +let +mut +at += +self +. +at +; +while +at +> +0 +{ +while +next_si +< += +STATE_MAX +& +& +at +> +0 +{ / / -Return +Argument +for +safety +is +in the -ID +definition of -the -next -transition +next_si . -fn -link -( -& -self -) +at - -> -StateID += +1 +; +prev_si += +unsafe { self . -link -} +next_si +( +next_si +text +at +) } -impl -core -: -: -fmt +; +if +prev_si +> +STATE_MAX +| +| +at +< += +4 +{ +mem : : -Debug -for -Transition -{ -fn -fmt +swap ( & -self -f -: +mut +prev_si & mut -core -: -: -fmt -: -: -Formatter +next_si ) +; +break +; +} +at - -> -core -: -: -fmt -: -: -Result += +1 +; +next_si += +unsafe { -write -! -( -f -" -Transition +self +. +next_si ( -byte -: -{ -: -X -? +prev_si +text +at +) } -next -: +; +if +next_si +> +STATE_MAX { -: -? +break +; } -link -: +at +- += +1 +; +prev_si += +unsafe { -: -? -} -) -" -self -. -byte -self -. -next -( -) -. -as_usize -( -) self . -link +next_si ( +next_si +text +at ) -. -as_usize +} +; +if +prev_si +> +STATE_MAX +{ +mem +: +: +swap ( +& +mut +prev_si +& +mut +next_si ) -) -} +; +break +; } -/ -/ -/ -A -single -match -in -a -non +at - -contiguous -NFA += +1 +; +next_si += +unsafe +{ +self . -# -[ -derive +next_si ( -Clone -Copy -Default +prev_si +text +at ) -] -struct -Match +} +; +} +if +next_si +& +STATE_MATCH +> +0 { -pid +next_si +& += +! +STATE_MATCH +; +result += +Result : -PatternID -link : -StateID -} -impl Match -{ -/ -/ -/ -Return -the -pattern -ID -for -this -match -. -pub ( -crate +at ++ +1 ) -fn -pattern +; +if +self +. +quit_after_match +{ +return +result +; +} +self +. +last_match_si += +next_si +; +prev_si += +next_si +; +let +cur += +at +; +while ( +next_si & -self +! +STATE_MATCH ) -- += += +prev_si +& +& +at > -PatternID += +2 { -self -. -pid -} / / -/ -Return +Argument +for +safety +is +in the -ID +definition of -the -next -match +next_si . -fn -link -( -& -self -) +at - -> -StateID += +1 +; +next_si += +unsafe { self . -link +next_si +( +next_si +& +! +STATE_MATCH +text +at +) } +; } -impl -core -: -: -fmt +if +at +< +cur +{ +result += +Result : : -Debug -for Match -{ -fn -fmt ( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter +at ++ +2 ) -- +; +} +} +else +if +next_si > -core -: -: -fmt -: -: -Result += +STATE_UNKNOWN { -write -! -( -f -" -Match -( -pid -: +if +next_si += += +STATE_QUIT { +return +Result : -? +: +Quit +; } -link +let +byte += +Byte : -{ : -? -} -) -" -self -. -pattern -( -) -. -as_usize -( -) -self -. -link -( -) -. -as_usize +byte ( -) -) -} -} -/ -/ -/ -A -builder -for -configuring -an -Aho -- -Corasick -noncontiguous -NFA -. -/ -/ -/ -/ -/ -/ -This -builder -has -a -subset -of -the -options -available -to -a -/ -/ -/ +text [ -AhoCorasickBuilder +at ] -( -crate -: -: -AhoCorasickBuilder ) +; +prev_si +& += +STATE_MAX +; +self . -Of -the -shared -options -/ -/ -/ -their -behavior -is -identical +at += +at +; +next_si += +match +self . -# -[ -derive +next_state ( -Clone -Debug +qcur +qnext +prev_si +byte ) -] -pub -struct -Builder { -match_kind -: -MatchKind -prefilter -: -bool -ascii_case_insensitive +None += +> +return +Result : -bool -dense_depth : -usize -} -impl -Default -for -Builder -{ -fn -default +Quit +Some ( +STATE_DEAD ) -- += > -Builder -{ -Builder -{ -match_kind -: -MatchKind -: -: -default +return +result +. +set_non_match ( +at ) -prefilter -: -true -ascii_case_insensitive -: -false -dense_depth -: -3 -} -} +Some +( +si +) += +> +si } -impl -Builder -{ -/ -/ -/ -Create -a -new -builder -for -configuring -an -Aho -- -Corasick -noncontiguous -NFA -. -pub -fn -new +; +debug_assert +! ( +next_si +! += +STATE_UNKNOWN ) -- +; +if +next_si +& +STATE_MATCH > -Builder +0 { -Builder +next_si +& += +! +STATE_MATCH +; +result += +Result : : -default +Match ( +at ++ +1 ) +; +if +self +. +quit_after_match +{ +return +result +; } -/ -/ -/ -Build -an -Aho -- -Corasick -noncontiguous -NFA -from -the -given -iterator -of -/ -/ -/ -patterns +self . +last_match_si += +next_si +; +} +prev_si += +next_si +; +} +else +{ +prev_si += +next_si +; +} +} / / -/ -/ -/ -/ -A -builder -may -be -reused -to -create +Run +the +DFA +once more -NFAs +on +the +special +EOF +sentinel +value . -pub -fn -build -< -I -P -> -( -& +prev_si += +match self -patterns +. +next_state +( +qcur +qnext +prev_si +Byte +: : -I +eof +( ) -- +) +{ +None += > +return Result -< -NFA -BuildError -> -where -I : -IntoIterator -< -Item -= -P -> -P : -AsRef -< -[ -u8 -] -> -{ -debug -! +Quit +Some ( -" -building -non -- -contiguous -NFA -" +STATE_DEAD ) -; -let -nfa = -Compiler -: -: -new +> +return +result +. +set_non_match ( -self +0 ) -? -. -compile +Some ( -patterns +si ) -? += +> +si +} ; -debug +debug_assert ! ( -" -non -- -contiguous -NFA -built -< -states -: +prev_si +! += +STATE_UNKNOWN +) +; +if +prev_si +& +STATE_MATCH +> +0 { +prev_si +& += +! +STATE_MATCH +; +self +. +last_match_si += +prev_si +; +result += +Result : -? -} -size -: -{ : -? -} -> -" -nfa -. -states -. -len -( -) -nfa -. -memory_usage +Match ( -) +0 ) ; -Ok -( -nfa -) +} +result } / / / -Set +next_si +transitions +to the -desired -match -semantics -. +next +state +where +the +transition +input / / / +corresponds +to +text +[ +i +] +. / / / -See / / / +This +elides +bounds +checks +and +is +therefore +not +safe +. +# [ -AhoCorasickBuilder -: -: -match_kind -] +cfg_attr ( -crate -: -: -AhoCorasickBuilder -: -: -match_kind +feature += +" +perf +- +inline +" +inline +( +always ) -/ -/ -/ -for -more -documentation -and -examples -. -pub +) +] +unsafe fn -match_kind +next_si ( & -mut self -kind +si +: +StatePtr +text +: +& +[ +u8 +] +i : -MatchKind +usize ) - > -& -mut -Builder +StatePtr { -self -. -match_kind -= -kind -; -self -} -/ / / -Enable -ASCII -- -aware -case -insensitive -matching -. -/ +What +is +the +argument +for +safety +here +? / / +We +have +three +unchecked +accesses +that +could +possibly +violate +safety +: / / / -See / +1 +. +The +given +byte +of +input +( +text +[ +i +] +) +. / / +2 +. +The +class +of +the +byte +of +input +( +classes [ -AhoCorasickBuilder -: -: -ascii_case_insensitive +text +[ +i +] ] -( -crate -: -: -AhoCorasickBuilder -: -: -ascii_case_insensitive ) +. / / -/ -for -more -documentation -and -examples +3 . -pub -fn -ascii_case_insensitive +The +transition +for +the +class ( -& -mut -self -yes -: -bool +trans +[ +si ++ +cls +] ) -- -> -& -mut -Builder -{ -self . -ascii_case_insensitive -= -yes -; -self -} / / / -Set -the -limit -on -how -many -states -use -a -dense -representation -for -their / +( +1 +) +is +only +safe +when +calling +next_si +is +guarded +by / / -transitions +i +< +text . -Other -states -will -generally -use -a -sparse -representation +len +( +) . / / / / -/ -/ -See -/ -/ -/ -[ -AhoCorasickBuilder -: -: -dense_depth -] ( -crate -: -: -AhoCorasickBuilder -: -: -dense_depth +2 ) +is +the +easiest +case +to +guarantee +since +text +[ +i +] +is +always +a / / -/ -for -more -documentation +u8 and -examples -. -pub -fn -dense_depth -( -& -mut -self -depth -: -usize -) -- -> -& -mut -Builder -{ self . -dense_depth -= -depth -; -self -} -/ -/ -/ -Enable -heuristic -prefilter -optimizations +prog +. +byte_classes +always +has +length +u8 +: +: +MAX . / / -/ -/ -/ -/ +( See +ByteClassSet +. +byte_classes +in +compile +. +rs +. +) +/ / / / -[ -AhoCorasickBuilder -: -: -prefilter -] ( -crate -: -: -AhoCorasickBuilder -: -: -prefilter +3 ) -/ -/ -/ -for -more -documentation -and -examples -. -pub -fn -prefilter +is +only +safe +if ( -& -mut -self -yes -: -bool +1 ) -- -> -& -mut -Builder -{ -self ++ +( +2 +) +are +safe . -prefilter -= -yes -; -self -} -} -/ -/ -/ -A -compiler -uses -a -builder -configuration -and -builds -up +Namely the -NFA -formulation -/ +transitions / / of -an -Aho -- -Corasick -automaton -. -This -roughly -corresponds +every +state +are +defined +to +have +length +equal to the -standard -/ +number +of / / -formulation -described +byte +classes in -textbooks -with -some -tweaks +the +program +. +Therefore +a +valid +class +leads to -support -leftmost -/ +a / / -searching +valid +transition . -# -[ -derive -( -Debug -) -] -struct -Compiler -< -' -a -> -{ -builder -: -& -' -a -Builder -prefilter -: -prefilter -: -: -Builder -nfa -: -NFA -byteset -: -ByteClassSet -} -impl -< -' -a -> -Compiler -< -' -a -> -{ -fn -new ( -builder -: -& -' +All +possible +transitions +are +valid +lookups +even +/ +/ +if +it +points +to a -Builder -) -- -> -Result -< -Compiler -< +state +that +hasn ' -a -> -BuildError -> -{ -let -prefilter -= -prefilter -: -: -Builder -: -: -new -( -builder +t +been +computed +yet . -match_kind ) -. -ascii_case_insensitive ( -builder -. -ascii_case_insensitive +3 ) -; -Ok -( -Compiler -{ -builder -prefilter -nfa -: -NFA -{ -match_kind -: -builder +also +/ +/ +relies +on +si +being +correct +but +StatePtrs +should +only +ever +be +/ +/ +retrieved +from +the +transition +table +which +ensures +they +are +correct . -match_kind -states -: -vec -! -[ -] -sparse -: -vec -! -[ -] -dense -: -vec -! -[ -] -matches -: -vec -! -[ -] -pattern_lens -: -vec +debug_assert ! -[ -] -prefilter -: -None -byte_classes -: -ByteClasses -: -: -singletons +( +i +< +text +. +len ( ) -min_pattern_len -: -usize -: -: -MAX -max_pattern_len -: -0 -special -: -Special -: -: -zero -( ) -} -byteset -: -ByteClassSet -: -: -empty +; +let +b += +* +text +. +get_unchecked ( +i ) -} -) -} -fn -compile -< -I -P -> +; +debug_assert +! ( -mut -self -patterns -: -I +( +b +as +usize ) -- -> -Result -< -NFA -BuildError -> -where -I -: -IntoIterator -< -Item -= -P -> -P -: -AsRef < -[ -u8 -] -> -{ -/ -/ -Add -dummy -transition -/ -match -links -so -that -no -valid -link -will -point -/ -/ -to -another -link -at -index -0 -. self . -nfa +prog . -sparse +byte_classes . -push -( -Transition -: -: -default +len ( ) ) ; +let +cls += +* self . -nfa +prog . -matches +byte_classes . -push +get_unchecked ( -Match -: -: -default +b +as +usize +) +; +self +. +cache +. +trans +. +next_unchecked ( +si +cls +as +usize ) +} +/ +/ +/ +Computes +the +next +state +given +the +current +state +and +the +current +input +/ +/ +/ +byte +( +which +may +be +EOF ) -; +. / / -Add -a -dummy -dense +/ +/ +/ +/ +If +STATE_DEAD +is +returned +then +there +is +no +valid +state transition -so +. +/ +/ +/ +This +implies that no -states +permutation +of +future +input can -have -dense -= -= -0 +lead +to +a +match / / -represent -a -valid -pointer -to -dense -transitions +/ +state . -This -permits / / -dense -= -= -0 -to +/ +/ +/ +/ +STATE_UNKNOWN +can +never be +returned +. +fn +exec_byte +( +& +mut +self +qcur +: +& +mut +SparseSet +qnext +: +& +mut +SparseSet +mut +si +: +StatePtr +b +: +Byte +) +- +> +Option +< +StatePtr +> +{ +use +crate +: +: +prog +: +: +Inst +: +: +* +; +/ +/ +Initialize a -sentinel -indicating -" -no -dense -transitions +queue +with +the +current +DFA +state +' +s +NFA +states . -" +qcur +. +clear +( +) +; +for +ip +in self . -nfa +state +( +si +) . -dense +inst_ptrs +( +) +{ +qcur . -push +insert ( -NFA -: -: -DEAD +ip ) ; +} / / +Before +inspecting the -dead -state -only -used -for -leftmost -and -fixed +current +byte +we +may +need to -id -= -= -0 -self -. -nfa -. -alloc_state -( -0 -) -? -; +also +inspect / / +whether the -fail +position +immediately +preceding +the +current +byte +/ +/ +satisfies +the +empty +assertions +found +in +the +current state -which -is -never -entered -and -fixed -to -id -= -= -1 -self -. -nfa . -alloc_state -( -0 -) -? -; / / -unanchored -start -state -initially -fixed -to -id -= -= -2 -but -later -shuffled / / +We +only +need to -appear -after -all -non -- -start -match -states +do +this +step +if +there +are +any +empty +assertions +in +/ +/ +the +current +state . +let +is_word_last += self . -nfa +state +( +si +) . -special +flags +( +) . -start_unanchored_id +is_word +( +) +; +let +is_word = +b +. +is_ascii_word +( +) +; +if self . -nfa +state +( +si +) . -alloc_state +flags ( -0 ) -? -; +. +has_empty +( +) +{ / / -anchored -start -state -initially -fixed -to -id -= -= -3 -but -later -shuffled +Compute +the +flags +immediately +preceding +the +current +byte +. / / -to -appear -after -unanchored +This +means +we +only +care +about +the +" +end +" +or +" +end +line +" +flags +. +/ +/ +( +The +" start -state +" +flags +are +computed +immediately +following +the +/ +/ +current +byte +and +are +handled +below . -self +) +let +mut +flags += +EmptyFlags +: +: +default +( +) +; +if +b . -nfa +is_eof +( +) +{ +flags . -special +end += +true +; +flags . -start_anchored_id +end_line = -self +true +; +} +else +if +b . -nfa +as_byte +( +) . -alloc_state +map_or ( -0 +false +| +b +| +b += += +b +' +\ +n +' ) -? +{ +flags +. +end_line += +true ; -/ -/ -Initialize -the -unanchored -starting -state -in -order -to -make -it -dense -/ -/ -and -thus -make -transition -lookups -on -this -state -faster +} +if +is_word_last += += +is_word +{ +flags . -self +not_word_boundary += +true +; +} +else +{ +flags . -init_unanchored_start_state -( -) -? +word_boundary += +true ; +} / / -Set -all +Now +follow +epsilon transitions -on -the -DEAD -state -to -point -to -itself -. -This -way -/ -/ -the -DEAD +from +every +NFA state -can -never -be -escaped -. -It -MUST -be -used -as -a -sentinel +but +make / / -in -any -correct -search +sure +we +only +follow +transitions +that +satisfy +our +flags . -self +qnext . -add_dead_state_loop +clear ( ) -? ; -/ -/ -Build -the -base -trie -from -the -given -patterns -. +for +& +ip +in +& +* +qcur +{ self . -build_trie +follow_epsilons ( -patterns +usize_to_u32 +( +ip +) +qnext +flags ) -? ; -self -. -nfa -. -states -. -shrink_to_fit +} +mem +: +: +swap ( +qcur +qnext ) ; +} / / -Turn -our +Now +we set -of -bytes -into -equivalent -classes +flags +for +immediately +after +the +current +byte . -This -NFA +Since +start / / -implementation -uses -byte -classes +states +are +processed +separately +and +are +the only -for states that -use -a -dense -/ -/ -representation -of -transitions -. -( -And -that -' -s -why -this -comes -before +can / / -self -. -densify -( -) -as +have the -byte -classes +StartText +flag +set +we +therefore +only need to -be -set -first -. -) -self -. -nfa -. -byte_classes -= -self -. -byteset -. -byte_classes -( -) -; +worry +about / / -Add -transitions -( -and -maybe -matches -) -to the -anchored -starting -state +StartLine +flag +here . / / -The -anchored -starting -state -is -used -for -anchored -searches -. -The -only / / -mechanical -difference -between -it -and -the -unanchored -start +We +do +also +keep +track +of +whether +this +DFA state -is -/ -/ -that -missing -transitions -map -to -the -DEAD +contains +a +NFA state -instead -of -the -FAIL / / +that +is +a +matching state . -self -. -set_anchored_start_state -( -) -? -; +This +is +precisely +how +we +delay +the +DFA / / -Rewrite -transitions +matching +by +one +byte +in +order to +process the -FAIL -state -on -the -unanchored -start +special +EOF +sentinel +/ +/ +byte +. +Namely +if +this +DFA +state +containing +a +matching +NFA state / / -as -self -- -transitions -. -This -keeps +then +it +is the -start +* +next +* +DFA state -active -at -all -times -. -self +that +is +marked +as +a +match . -add_unanchored_start_state_loop +let +mut +empty_flags += +EmptyFlags +: +: +default ( ) ; -/ -/ -Make -some +let +mut +state_flags += +StateFlags +: +: +default ( -possibly -zero ) -states -use -a -dense -representation -for -/ -/ -transitions +; +empty_flags . -It -' -s -important -to -do -this -right -after -the -states -/ -/ -and -non -- -failure -transitions -are -solidified +start_line += +b . -That -way -subsequent -/ -/ -accesses +as_byte ( -particularly -fill_failure_transitions ) -will -benefit -from -/ -/ -the -faster -transition -lookup -in -densified -states . -self +map_or +( +false +| +b +| +b += += +b +' +\ +n +' +) +; +if +b . -densify +is_ascii_word +( +) +{ +state_flags +. +set_word ( ) -? ; +} / / -The -meat -of -the -Aho -- -Corasick -algorithm -: -compute -and -write -failure +Now +follow +all +epsilon +transitions +again +but +only +after +consuming / / -transitions +the +current +byte . -i +qnext . -e +clear +( +) +; +for +& +ip +in +& +* +qcur +{ +match +self . -the -state -to -move -to -when -a -transition -isn -' -t +prog +[ +ip +as +usize +] +{ / / -defined +These +states +never +happen in -the -current -state +a +byte +- +based +program . +Char +( +_ +) +| +Ranges +( +_ +) += +> +unreachable +! +( +) +/ +/ These +states are +handled +when +following epsilon transitions -and -thus -/ -/ -make -this -formulation -an -NFA . -self +Save +( +_ +) +| +Split +( +_ +) +| +EmptyLook +( +_ +) += +> +{ +} +Match +( +_ +) += +> +{ +state_flags . -fill_failure_transitions +set_match ( ) -? ; -/ -/ -Handle -a -special -case -under -leftmost -semantics -when -at -least -one -/ -/ -of -the -patterns -is -the -empty -string +if +! +self . +continue_past_first_match +( +) +{ +break +; +} +else +if self . -close_start_state_loop_for_leftmost -( -) -; -/ -/ -Shuffle -states -so -that -we -have -DEAD -FAIL -MATCH +prog . +matches . +len +( +) +> +1 +& +& +! +qnext . -START -START +contains +( +ip +as +usize +) +{ / / -NON -- -MATCH -. -. -. -This -permits -us +If +we +are +continuing +on to -very -quickly -query -the -type -of +find +other +matches / / +then +keep +a +record +of the -state +match +states we ' -re -currently -in -during -a -search +ve +seen . -self +qnext . -shuffle +insert ( +ip ) ; -self -. -nfa -. -prefilter +} +} +Bytes +( +ref +inst +) = -self -. -prefilter +> +{ +if +b . -build +as_byte ( ) -; -/ -/ -Store -the -maximum -ID -of -all -* -relevant -* -special -states -. -Start -states -/ -/ -are -only -relevant -when -we -have -a -prefilter -otherwise -there -is -zero -/ -/ -reason -to -care -about -whether -a -state -is -a -start -state -or -not -during -/ -/ -a -search . -Indeed -without -a -prefilter -we -are -careful -to -explicitly -/ -/ -NOT -care -about -start -states -otherwise -the -search -can -ping -pong -/ -/ -between -the -unrolled -loop -and -the -handling -of -special -- -status -states -/ -/ -and -destroy -perf +map_or +( +false +| +b +| +inst . +matches +( +b +) +) +{ self . -nfa -. -special +follow_epsilons +( +inst . -max_special_id +goto +as +InstPtr +qnext +empty_flags +) +; +} +} +} +} +let +cache = if +b +. +is_eof +( +) +& +& self . -nfa +prog . -prefilter +matches . -is_some +len ( ) +> +1 { / / -Why +If +we +' +re +processing the -anchored -starting -state -? -Because +last +byte +of +the +input +and we -always -put -it +' +re / / -after +matching +a +regex +set +then +make the -unanchored -starting +next state -and -it -is -therefore +contain the / / -maximum +previous +states +transitions . -Why -put -unanchored -followed -by -anchored -? -No -particular -/ -/ -reason -but +We +do +this +so that -' -s -how the -states -are -logically -organized -in +main +/ +/ +matching +loop +can +extract +all +of the -/ -/ -Thompson -NFA -implementation -found -in -regex -- -automata +match +instructions . -\ -_ +mem +: +: +swap ( +qcur +qnext ) -_ +; / -self -. -nfa -. -special +/ +And +don +' +t +cache +this +state +because +it +' +s +totally +bunk . -start_anchored_id +false } else { -self -. -nfa -. -special -. -max_match_id +true } ; -self -. -nfa -. -sparse -. -shrink_to_fit -( -) -; -self -. -nfa -. -dense -. -shrink_to_fit -( -) -; -self -. -nfa -. -matches -. -shrink_to_fit -( -) -; -self -. -nfa -. -pattern_lens -. -shrink_to_fit -( -) -; -Ok -( -self -. -nfa -) -} / / -/ -This -sets +We +' +ve +now +built up the -initial -prefix -trie +set +of +NFA +states that -makes -up +ought +to +comprise the -Aho -- -Corasick -/ / / -automaton -. -Effectively +next +DFA +state +so +try +to +find it -creates -the -basic -structure -of +in the +cache +and +if +it +doesn +' +t / / +exist +cache +it +. / -automaton -where -every -pattern -given -has -a -path -from -the -start -state -to / / / +N +. +B +. +We +pass +& +mut +si +here +because the -end +cache +may +clear +itself +if +/ +/ +it +has +gotten +too +full +. +When +that +happens +the +location of the -pattern +/ +/ +current +state +may +change . -fn -build_trie -< -I -P -> +let +mut +next += +match +self +. +cached_state +( +qnext +state_flags +Some ( & mut -self -patterns -: -I +si ) -- -> -Result -< -( ) -BuildError -> -where -I -: -IntoIterator -< -Item +{ +None = -P -> -P -: -AsRef -< -[ -u8 -] > -{ -' -PATTERNS -: -for +return +None +Some ( -i -pat +next ) -in -patterns -. -into_iter += +> +next +} +; +if ( -) +self . -enumerate -( +start +& +! +STATE_START ) -{ -let -pid = -PatternID -: -: -new -( -i -) -. -map_err -( -| -e -| += +next { -BuildError -: -: -pattern_id_overflow +/ +/ +Start +states +can +never +be +match +states +since +all +matches +are +/ +/ +delayed +by +one +byte +. +debug_assert +! ( -PatternID -: -: -MAX +! +self . -as_u64 +state ( +next ) -e . -attempted +flags ( ) +. +is_match +( ) -} ) -? ; -let -pat +next = -pat +self . -as_ref +start_ptr ( +next ) ; -let -patlen +} +if +next +< = -SmallIndex -: -: -new -( -pat +STATE_MAX +& +& +self . -len +state ( -) +next ) . -map_err -( -| -_ -| -BuildError -: -: -pattern_too_long +flags ( -pid -pat +) . -len +is_match ( ) +{ +next +| += +STATE_MATCH +; +} +debug_assert +! +( +next +! += +STATE_UNKNOWN ) -) -? ; -self -. -nfa +/ +/ +And +now +store +our +state +in +the +current +state +' +s +next +list . -min_pattern_len +if +cache +{ +let +cls = -core -: -: -cmp -: -: -min -( self . -nfa -. -min_pattern_len -pat -. -len +byte_class ( -) +b ) ; self . -nfa -. -max_pattern_len -= -core -: -: -cmp -: -: -max -( -self -. -nfa +cache . -max_pattern_len -pat +trans . -len +set_next ( -) +si +cls +next ) ; -assert_eq -! -( -i -self -. -nfa -. -pattern_lens -. -len +} +Some ( +next ) -" -expected -number -of -patterns -to -match -pattern -ID -" +} +/ +/ +/ +Follows +the +epsilon +transitions +starting +at +( +and +including ) -; -self +ip . -nfa -. -pattern_lens +The +/ +/ +/ +resulting +states +are +inserted +into +the +ordered +set +q . -push +/ +/ +/ +/ +/ +/ +Conditional +epsilon +transitions ( -patlen +i +. +e +. +empty +width +assertions ) -; +are +only / / -We -add +/ +followed +if +they +are +satisfied +by +the +given +flags +which +should +/ +/ +/ +represent +the +flags +set +at +the +current +location +in +the +input +. +/ +/ +/ +/ +/ +/ +If +the +current +location +corresponds +to +the +empty +string +then +only +the +/ +/ +/ +end +line +and +/ +or +end +text +flags +may +be +set +. +If +the +current +location +/ +/ +/ +corresponds +to +a +real +byte +in +the +input +then +only the -pattern +start +line +/ +/ +/ +and +/ +or +start +text +flags +may +be +set +. +/ +/ +/ +/ +/ +/ +As +an +exception to the -prefilter -here -because +above +when +finding the -pattern +initial +state +any +of +/ / / -ID -in -the -prefilter -is -determined -with -respect -to the -patterns +above +flags +may +be +set +: / / -added -to -the -prefilter -. -That -is -it -isn -' -t -the -ID -we -have -here / / -but +/ +/ +If +matching +starts +at the -one -determined -by -its -own -accounting +beginning of -patterns -. +the +input +then +start +text +and / / -To -ensure -they +/ +start line -up -we -add -every -pattern -we -see -to +should +be +set +. +If the +input +is +empty +then +end +text +and +end / / -prefilter -even -if -some -patterns -ultimately -are -impossible -to -/ / -match -( -in -leftmost -- -first -semantics -specifically -) +line +should +also +be +set . / / / / -Another -way +/ +/ +If +matching +starts +after +the +beginning of -doing -this -would -be -to -expose -an -API -in the +input +then +only +start / / -prefilter -to -permit -setting -your -own -pattern -IDs +/ +line +should +be +set +if +the +preceding +byte +is +\ +n . -Or -to -just -use +End +line +should +never / / -our -own -map -and -go -between -them -. -But +/ +be +set +in this case +. +( +Even +if +the +following +byte is -sufficiently +a +\ +n +it +will / / -rare -that -we -don -' -t -bother -and -just -make -sure -they -' -re +/ +be +handled in -sync -. -if -self -. -builder -. -prefilter -{ -self -. -prefilter +a +subsequent +DFA +state . -add -( -pat ) -; -} -let +fn +follow_epsilons +( +& mut -prev -= self -. -nfa -. -special -. -start_unanchored_id -; -let -mut -saw_match -= -false -; -for -( -depth +ip +: +InstPtr +q +: & -b -) -in -pat -. -iter -( -) -. -enumerate -( +mut +SparseSet +flags +: +EmptyFlags ) { +use +crate +: +: +prog +: +: +EmptyLook +: +: +* +; +use +crate +: +: +prog +: +: +Inst +: +: +* +; / / -When -leftmost -- -first -match -semantics -are -requested -we -/ -/ -specifically -stop -adding -patterns -when -a -previously -added -/ -/ -pattern -is -a -prefix -of -it -. We -avoid -adding -it -because -/ -/ -leftmost -- -first -semantics -imply -that -the -pattern -can -never -/ -/ -match -. -This -is -not -just -an -optimization +need to -save -space -! -It -/ -/ -is -necessary -for -correctness -. -In -fact -this -is -the -only -/ -/ -difference -in -the -automaton -between +traverse the -implementations -for +NFA +to +follow +epsilon +transitions +so +avoid / / -leftmost -- -first -and -leftmost -- -longest +recursion +with +an +explicit +stack . -saw_match -= -saw_match -| -| self . -nfa +cache . -states -[ -prev -] +stack . -is_match +push ( +ip ) ; -if +while +let +Some +( +mut +ip +) += self . -builder +cache . -match_kind +stack . -is_leftmost_first +pop ( ) -& -& -saw_match { / / -Skip +Try to -the -next -pattern -immediately -. -This -avoids -/ +munch +through +as +many +states +as +possible +without / -incorrectly -adding -a -match -after -this -loop -terminates -. -continue -' -PATTERNS -; -} / +pushes / -Add -this -byte +pops to -our -equivalence -classes -. -These -don -' -t -/ -/ -get -used -while -building the -trie -but -other -Aho -- -Corasick +stack +. +loop +{ / / -implementations -may -use -them +Don +' +t +visit +states +we +' +ve +already +added . -self +if +q . -byteset +contains +( +ip +as +usize +) +{ +break +; +} +q . -set_range +insert ( -b -b +ip +as +usize ) ; -if +match self . -builder -. -ascii_case_insensitive +prog +[ +ip +as +usize +] { -let -b +Char +( +_ +) +| +Ranges +( +_ +) = -opposite_ascii_case +> +unreachable +! ( -b ) -; -self -. -byteset -. -set_range +Match ( -b -b +_ ) -; -} -/ -/ -If -the -transition -from -prev -using -the -current -byte -already -/ -/ -exists -then -just -move -through -it -. -Otherwise -add -a -new -/ -/ -state -. -We -track -the -depth -here -so -that -we -can -determine -/ -/ -how -to -represent -transitions -. -States -near -the -start -state -/ -/ -use -a -dense -representation -that -uses -more -memory -but -is +| +Bytes +( +_ +) += +> +{ +break +; +} +EmptyLook +( +ref +inst +) += +> +{ / / -faster -. -Other +Only +follow +empty +assertion states -use -a -sparse -representation -that -uses +if +our +flags / / -less -memory -but -is -slower +satisfy +the +assertion . -let -next -= -self +match +inst . -nfa +look +{ +StartLine +if +flags . -follow_transition -( -prev -b -) +start_line += +> +{ +ip += +inst +. +goto +as +InstPtr ; +} +EndLine if -next -! +flags +. +end_line = -NFA -: -: -FAIL +> { -prev +ip = -next +inst +. +goto +as +InstPtr ; } -else +StartText +if +flags +. +start += +> { -let -next +ip = -self +inst . -nfa +goto +as +InstPtr +; +} +EndText +if +flags . -alloc_state -( -depth -) -? +end += +> +{ +ip += +inst +. +goto +as +InstPtr ; -self +} +WordBoundaryAscii +if +flags . -nfa +word_boundary += +> +{ +ip += +inst . -add_transition -( -prev -b -next -) -? +goto +as +InstPtr ; +} +NotWordBoundaryAscii if -self +flags . -builder +not_word_boundary += +> +{ +ip += +inst +. +goto +as +InstPtr +; +} +WordBoundary +if +flags . -ascii_case_insensitive +word_boundary += +> { -let -b +ip = -opposite_ascii_case -( -b -) +inst +. +goto +as +InstPtr ; -self +} +NotWordBoundary +if +flags . -nfa +not_word_boundary += +> +{ +ip += +inst . -add_transition -( -prev -b -next -) -? +goto +as +InstPtr ; } -prev +StartLine +| +EndLine +| +StartText +| +EndText +| +WordBoundaryAscii +| +NotWordBoundaryAscii +| +WordBoundary +| +NotWordBoundary = -next +> +{ +break ; } } -/ -/ -Once -the -pattern -has -been -added -log -the -match -in -the -final -/ -/ -state -that -it -reached -. -self -. -nfa -. -add_match +} +Save ( -prev -pid +ref +inst ) -? += +> +{ +ip += +inst +. +goto +as +InstPtr ; } -Ok -( +Split ( +ref +inst ) -) -} -/ -/ -/ -This -routine -creates -failure -transitions -according -to -the -standard -/ -/ -/ -textbook -formulation -of -the -Aho -- -Corasick -algorithm -with -a -couple -small -/ -/ -/ -tweaks -to -support -" -leftmost -" -semantics += +> +{ +self . -/ -/ -/ -/ -/ -/ -Building -failure -transitions -is -the -most -interesting -part -of -building -/ -/ -/ -the -Aho -- -Corasick -automaton -because -they -are -what -allow -searches -to -/ -/ -/ -be -performed -in -linear -time +cache +. +stack +. +push +( +inst +. +goto2 +as +InstPtr +) +; +ip += +inst . -Specifically -a -failure -transition -is +goto1 +as +InstPtr +; +} +} +} +} +} / / / +Find a -single -transition -associated -with -each +previously +computed state -that -points -back -to +matching +the +given +set +of +instructions / / / -the -longest -proper -suffix -of -the -pattern -being -searched +and +is_match +bool . -The -failure / / / -transition -is -followed -whenever -there -exists -no -transition -on -the / / / -current +The +given +set +of +instructions +should +represent +a +single state -for +in the -current -input -byte -. -If -there -is -no -other -proper / / / -suffix -then -the -failure -transition -points -back -to -the -starting -state +NFA +along +with +all +states +reachable +without +consuming +any +input . / / @@ -10249,193 +9812,88 @@ state / / / -For -example -let -' -s -say -we -built -an -Aho -- -Corasick -automaton -with +The +is_match +bool +should +be +true +if +and +only +if the +preceding +DFA +state / / / -following -patterns -: -' -abcd -' -and -' -cef -' +contains +an +NFA +matching +state . The -trie -looks -like -this -: -/ -/ -/ -/ -/ -/ -ignore +cached +state +produced +here +will / / / +then +signify a -- -S1 -- -b -- -S2 -- -c -- -S3 -- -d -- -S4 -* -/ -/ -/ -/ -/ -/ -/ -S0 -- -c -- -S5 -- -e -- -S6 -- -f -- -S7 -* -/ -/ -/ -/ -/ -/ -/ -/ -/ -At -this -point -it -should -be -fairly -straight -- -forward +match +. +( +This +enables +us to -see -how -this -/ -/ -/ -trie -can -be -used -in +delay a -simplistic -way -. -At -any -given -position -in -the +match +by +one +byte / / / -text -we -' -re -searching -( -called +in +order +to +account +for the -" -subject -" -string +EOF +sentinel +byte +. ) -all -we -need -to -do / / / -is -follow -the -transitions -in -the -trie -by -consuming -one -transition -for / / / -each -byte -in -the -subject -string -. If -we -reach -a -match -state +the +cache +is +full then -we -can -/ -/ -/ -report -that -location -as +it +is +wiped +before +caching a -match +new +state . / / @@ -10444,1044 +9902,1815 @@ match / / The -trick -comes -when -searching -a -subject -string -like -' -abcef -' -. -We -' -ll +current +state +should +be +specified +if +it +exists +since +it +will +need / / / -initially -follow -the -transition -from -S0 to -S1 -and -wind -up -in -S3 -after -/ -/ -/ -observng +be +preserved +if the -' -c -' -byte +cache +clears +itself . -At -this -point -the -next -byte -is -' -e -' -but -state +( +Start +states +are / / / -S3 -has -no -transition -for -' -e -' +always +saved so -the -search -fails +they +should +not +be +passed +here . -We -then -would -need +) +It +takes +a +mutable / / / +pointer to -restart the -search -at +index +because +if the -next -position -in -' -abcef +cache +is +cleared +the +state ' -which +s / / / -corresponds -to -' -b -' +location +may +change . -The -match -would -fail -but -the -next -search -starting -/ +fn +cached_state +( +& +mut +self +q +: +& +SparseSet +mut +state_flags +: +StateFlags +current_state +: +Option +< +& +mut +StatePtr +> +) +- +> +Option +< +StatePtr +> +{ / / -at -' -c +If +we +couldn ' -would -finally -succeed -. -The -problem +t +come +up with +a +non +- +empty +key +to +represent this -approach +state +/ +/ +then +it is +dead +and +can +never +lead +to +a +match +. +/ +/ +/ +/ +Note that +inst_flags +represent +the +set +of +empty +width +assertions +/ / +in +q +. +We +use +this +as +an +optimization +in +exec_byte +to +determine +when / / we -wind -up -searching +should +follow +epsilon +transitions +at the -subject +empty string -potentially -many -times -. -In -/ +preceding / / -effect -this -makes the -algorithm -have -worst -case -O +current +byte +. +let +key += +match +self +. +cached_state_key ( -n -* -m +q +& +mut +state_flags ) -complexity -/ +{ +None += +> +return +Some +( +STATE_DEAD +) +Some +( +v +) += +> +v +} +; / / -where -n -~ -len +In +the +cache +? +Cool +. +Done +. +if +let +Some +( +si +) += +self +. +cache +. +compiled +. +get_ptr ( -subject +& +key ) -and -m -~ -len +{ +return +Some ( -all -patterns +si ) -. -We -would -instead -/ +; +} / / -like -to -achieve -a -O +If +the +cache +has +gotten +too +big +wipe +it +. +if +self +. +approximate_size ( -n -+ -m ) -worst -case -complexity +> +self . +prog +. +dfa_size_limit +& +& +! +self +. +clear_cache_and_save +( +current_state +) +{ / / -/ -/ -/ -/ -This +Ooops +. +DFA is -where -failure -transitions -come -in +giving +up . -Instead -of -dying -at -S3 -in -/ +return +None +; +} / / -the -first -search -the -automaton -can -instruct -the -search -to -move -to +Allocate +room +for +our +state +and +add +it +. +self +. +add_state +( +key +) +} / / / -another -part -of -the -automaton -that -corresponds -to +Produces a -suffix -of -what -/ -/ -/ -we -' -ve -seen -so -far -. -Recall -that -we -' -ve -seen -' -abc -' +key +suitable +for +describing +a +state in the -subject -string -/ -/ -/ -and -the -automaton -does -indeed -have -a -non -- -empty -suffix -' -c -' -that -could -/ -/ -/ -potentially -lead -to -another -match +DFA +cache . -Thus -the -actual -Aho -- -Corasick / / / -automaton -for -our -patterns -in -this -case -looks -like -this -: / / / +The +key +invariant +here +is +that +equivalent +keys +are +produced +for +any +two / / / -ignore +sets +of +ordered +NFA +states +( +and +toggling +of +whether +the +previous +NFA / / / +states +contain a -- -S1 -- -b -- -S2 -- -c -- -S3 -- -d -- -S4 -* -/ -/ +match +state +) +that +do +not +discriminate +a +match +for +any / / / +input +. / / / / -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- / / +Specifically +q +should +be +an +ordered +set +of +NFA +states +and +is_match / / / +should +be +true +if +and +only +if +the +previous +NFA +states +contained +a +match / / / -S0 -- -c -- -S5 -- -e -- -S6 -- -f +state +. +fn +cached_state_key +( +& +mut +self +q +: +& +SparseSet +state_flags +: +& +mut +StateFlags +) - -S7 +> +Option +< +State +> +{ +use +crate +: +: +prog +: +: +Inst +: +: * +; / / +We +need +to +build +up +enough +information +to +recognize +pre +- +built +states / / +in +the +DFA +. +Generally +speaking +this +includes +every +instruction / / +except +for +those +which +are +purely +epsilon +transitions +e +. +g +. +the / / +Save +and +Split +instructions +. / -That -is -we -have -a -failure -transition -from -S3 -to -S5 -which -is -followed / / / -exactly -in -cases -when -we +Empty +width +assertions are -in -state -S3 +also +epsilon +transitions but -see -any -byte -other -than -/ +since +they / / -' -d -' -( -that -is +are +conditional we -' -ve -" -failed -" +need to -find +make +them +part +of a -match +state +' +s +key in -this -portion -of -our +the +/ / +cache +. +let +mut +insts += +mem +: +: +replace +( +& +mut +self +. +cache +. +insts_scratch_space +vec +! +[ +] +) +; +insts +. +clear +( +) +; / / -trie +Reserve +1 +byte +for +flags +. +insts +. +push +( +0 +) +; +let +mut +prev += +0 +; +for +& +ip +in +q +{ +let +ip += +usize_to_u32 +( +ip ) +; +match +self . -We -know +prog +[ +ip +as +usize +] +{ +Char +( +_ +) +| +Ranges +( +_ +) += +> +unreachable +! +( +) +Save +( +_ +) +| +Split +( +_ +) += +> +{ +} +Bytes +( +_ +) += +> +push_inst_ptr +( +& +mut +insts +& +mut +prev +ip +) +EmptyLook +( +_ +) += +> +{ +state_flags +. +set_empty +( +) +; +push_inst_ptr +( +& +mut +insts +& +mut +prev +ip +) +} +Match +( +_ +) += +> +{ +push_inst_ptr +( +& +mut +insts +& +mut +prev +ip +) +; +if +! +self +. +continue_past_first_match +( +) +{ +break +; +} +} +} +} +/ +/ +If we -can +couldn +' +t transition -back to -S5 -because +any +other +instructions +and we +didn ' -ve -already -seen -/ +t / / +see a -' -c -' -byte -so -we -don -' -t -need -to -re -- -scan -it -. -We -can +match +when +expanding +NFA +states +previously then -pick -back -up -/ +this +is +a / / -with -the -search -starting -at -S5 +dead +state and -complete -our -match +no +amount +of +additional +input +can +transition +out +/ +/ +of +this +state +. +let +opt_state += +if +insts +. +len +( +) += += +1 +& +& +! +state_flags +. +is_match +( +) +{ +None +} +else +{ +let +StateFlags +( +f +) += +* +state_flags +; +insts +[ +0 +] += +f +; +Some +( +State +{ +data +: +Arc +: +: +from +( +& +* +insts +) +} +) +} +; +self +. +cache . +insts_scratch_space += +insts +; +opt_state +} / / / +Clears +the +cache +but +saves +and +restores +current_state +if +it +is +not / / / -Adding -failure -transitions -to -a -trie -is -fairly -simple -but -subtle +none . -The / / / -key -issue -is -that -you -might -have -multiple -failure -transition -that -you / / / -need -to -follow -. -For -example -look -at -the -trie -for +The +current +state +must +be +provided +here +in +case +its +location +in the -patterns / / / -' -abcd -' -' -b -' -' -bcd -' -and -' -cd -' -: +cache +changes +. / / / / / / -ignore +This +returns +false +if +the +cache +is +not +cleared +and +the +DFA +should / / / +give +up +. +fn +clear_cache_and_save +( +& +mut +self +current_state +: +Option +< +& +mut +StatePtr +> +) - -a -- -S1 -- -b -- -S2 -* -- -c -- -S3 -- -d -- -S4 -* +> +bool +{ +if +self +. +cache +. +compiled +. +is_empty +( +) +{ / / +Nothing +to +clear +. +. +. +return +true +; +} +match +current_state +{ +None += +> +self +. +clear_cache +( +) +Some +( +si +) += +> +{ +let +cur += +self +. +state +( +* +si +) +. +clone +( +) +; +if +! +self +. +clear_cache +( +) +{ +return +false +; +} +/ / +The +unwrap +is +OK +because +we +just +cleared +the +cache +and / / +therefore +know +that +the +next +state +pointer +won +' +t +exceed / / +STATE_MAX +. +* +si += +self +. +restore_state +( +cur +) +. +unwrap +( +) +; +true +} +} +} / / / -- -- -- -- -- -- -- -- -- -- -- -- -- -- +Wipes +the +state +cache +but +saves +and +restores +the +current +start +state +. / / / / / / +This +returns +false +if +the +cache +is +not +cleared +and +the +DFA +should / / / -S0 -- -- -- -b -- -S5 -* -- -c -- -S6 -- -d +give +up +. +fn +clear_cache +( +& +mut +self +) - -S7 -* +> +bool +{ / / +Bail +out +of +the +DFA +if +we +' +re +moving +too +" +slowly +. +" / -\ / +A +heuristic +from +RE2 +: +assume +the +DFA +is +too +slow +if +it +is +processing / / +10 +or +fewer +bytes +per +state +. / -\ -- -- -- -- -- -- -- -- / +Additionally +we +permit +the +cache +to +be +flushed +a +few +times +before / / -\ +caling +it +quits +. +let +nstates += +self +. +cache +. +compiled +. +len +( +) +; +if +self +. +cache +. +flush_count +> += +3 +& +& +self +. +at +> += +self +. +last_cache_flush +& +& +( +self +. +at +- +self +. +last_cache_flush +) +< += +10 +* +nstates +{ +return +false +; +} / / +Update +statistics +tracking +cache +flushes +. +self +. +last_cache_flush += +self +. +at +; +self +. +cache +. +flush_count ++ += +1 +; / / -- -c -- -S8 -- -d -- -S9 +OK +actually +flush +the +cache +. +let +start += +self +. +state +( +self +. +start +& +! +STATE_START +) +. +clone +( +) +; +let +last_match += +if +self +. +last_match_si +< += +STATE_MAX +{ +Some +( +self +. +state +( +self +. +last_match_si +) +. +clone +( +) +) +} +else +{ +None +} +; +self +. +cache +. +reset_size +( +) +; +self +. +cache +. +trans +. +clear +( +) +; +self +. +cache +. +compiled +. +clear +( +) +; +for +s +in +& +mut +self +. +cache +. +start_states +{ * -/ -/ -/ -/ -/ -/ -/ +s += +STATE_UNKNOWN +; +} / / The -failure -transitions -for -this -trie +unwraps are -defined -from -S2 -to -S5 -/ -/ -/ -S3 -to -S6 +OK +because +we +just +cleared +the +cache and -S6 -to -S8 -. -Moreover -state -S2 -needs -to -track -that -it -/ -/ -/ -corresponds -to -a -match -since -its -failure -transition -to -S5 -is -itself -/ +therefore / / -a -match +know +that +the +next state +pointer +won +' +t +exceed +STATE_MAX +. +let +start_ptr += +self +. +restore_state +( +start +) +. +unwrap +( +) +; +self +. +start += +self +. +start_ptr +( +start_ptr +) +; +if +let +Some +( +last_match +) += +last_match +{ +self +. +last_match_si += +self . +restore_state +( +last_match +) +. +unwrap +( +) +; +} +true +} / / / +Restores +the +given +state +back +into +the +cache +and +returns +a +pointer / / / -Perhaps -simplest -way to -think -about -adding -these -failure -transitions -/ +it +. +fn +restore_state +( +& +mut +self +state +: +State +) +- +> +Option +< +StatePtr +> +{ / / -is -recursively +If +we +' +ve +already +stored +this +state +just +return +a +pointer +to +it . -That -is -if -you -know -the -failure -transitions -for -every / / -/ -possible -previous -state -that -could +None +will be -visited +the +wiser +. +if +let +Some ( -e +si +) += +self . -g +cache . -when -computing -the -/ -/ -/ -failure -transition -for -S3 -you -already -know -the -failure -transitions -/ -/ -/ -for -S0 -S1 -and -S2 +compiled +. +get_ptr +( +& +state ) -then -you -can -simply -follow -the -failure -transition +{ +return +Some +( +si +) +; +} +self +. +add_state +( +state +) +} / / / -of +Returns +the +next +state +given the -previous +current state +si and -check -whether -the -incoming -transition -is +current +byte / / / -defined -after -following -the -failure -transition +b . +{ +qcur +qnext +} +are +used +as +scratch +space +for +storing +ordered +NFA / / / +states +. / / / -For -example -when -determining -the -failure -state -for -S3 -by -our / / / -assumptions -we -already -know -that -there -is -a -failure -transition +This +tries +to +fetch +the +next +state from +the +cache +but +if +that +fails / / / -S2 -( +it +computes the -previous +next state -) +caches +it +and +returns +a +pointer to -S5 +it . -So -we -follow -that -transition -and -check / / / -whether -the -transition -connecting -S2 +/ +/ +/ +The +pointer +can +be to -S3 -is -defined -. -Indeed +a +real +state +or it -is +can +be +STATE_DEAD +. / / / -as -there -is -a -transition -from -S5 -to -S6 -for -the -byte -' -c -' +STATE_UNKNOWN +cannot +be +returned . -If -no -such / / / -transition -existed -we -could -keep -following -the -failure -transitions / / / -until -we -reach -the -start -state -which +None is +returned +if +a +new +state +could +not +be +allocated +( +i +. +e +. the -failure -transition -for +DFA / / / -every -state -that -has -no -corresponding -proper -suffix +ran +out +of +space +and +thinks +it +' +s +running +too +slowly +) +. +fn +next_state +( +& +mut +self +qcur +: +& +mut +SparseSet +qnext +: +& +mut +SparseSet +si +: +StatePtr +b +: +Byte +) +- +> +Option +< +StatePtr +> +{ +if +si += += +STATE_DEAD +{ +return +Some +( +STATE_DEAD +) +; +} +match +self +. +cache +. +trans +. +next +( +si +self +. +byte_class +( +b +) +) +{ +STATE_UNKNOWN += +> +self . +exec_byte +( +qcur +qnext +si +b +) +STATE_QUIT += +> +None +nsi += +> +Some +( +nsi +) +} +} / / / +Computes +and +returns +the +start +state +where +searching +begins +at / / / -We -don -' -t -actually -use -recursion -to -implement -this -but -instead -use -a +position +at +in +text +. +If +the +state +has +already +been +computed / / / -breadth -first -search -of +then +it +is +pulled +from the -automaton +cache . -Our -base -case -is +If the -start +state +hasn +' +t +been +cached / / / -state -whose -failure -transition +then +it is -just +computed +cached +and a -transition +pointer to -itself +it +is +returned . / / @@ -11489,1481 +11718,1414 @@ itself / / / -When -building -a -leftmost -automaton -we -proceed -as -above +This +may +return +STATE_DEAD but -only -/ +never +STATE_UNKNOWN +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +start_state +( +& +mut +self +q +: +& +mut +SparseSet +empty_flags +: +EmptyFlags +state_flags +: +StateFlags +) +- +> +Option +< +StatePtr +> +{ / / -include -a -subset +Compute +an +index +into +our +cache of -failure -transitions -. -Namely -we -omit -any -failure +start +states +based +on +the +set / / +of +empty / -transitions -that -appear -after -a -match state +flags +set +at +the +current +position in the -trie +input . -This -is -/ -/ -/ -because -failure -transitions -always -point -back -to -a -proper -suffix -of -/ +We / / -what -has -been -seen -so -far +don +' +t +use +every +flag +since +not +all +flags +matter . -Thus -following -a -failure -transition -after -/ +For +example +since / / -a -match -implies -looking -for -a -match -that -starts -after -the +matches +are +delayed +by one -that -has -/ +byte +start +states +can +never +be +match / / -already -been -seen -which -is -of -course -therefore -not -the -leftmost +states +. +let +flagi += +{ +( +( +( +empty_flags +. +start +as +u8 +) +< +< +0 +) +| +( +( +empty_flags +. +end +as +u8 +) +< +< +1 +) +| +( +( +empty_flags +. +start_line +as +u8 +) +< +< +2 +) +| +( +( +empty_flags +. +end_line +as +u8 +) +< +< +3 +) +| +( +( +empty_flags +. +word_boundary +as +u8 +) +< +< +4 +) +| +( +( +empty_flags +. +not_word_boundary +as +u8 +) +< +< +5 +) +| +( +( +state_flags +. +is_word +( +) +as +u8 +) +< +< +6 +) +) +as +usize +} +; match +self . -/ -/ -/ -/ -/ -/ -N +cache . -B +start_states +[ +flagi +] +{ +STATE_UNKNOWN += +> +{ +} +si += +> +return +Some +( +si +) +} +q . -I -came -up -with -this -algorithm -on -my -own -and -after -scouring -all -of -/ -/ -/ -the -other -AC -implementations -I -know -of +clear ( -Perl -Snort -many -on -GitHub ) +; +let +start += +usize_to_u32 +( +self . -/ -/ -/ -I -couldn -' -t -find -any -that -implement -leftmost -semantics -like -this +prog +. +start +) +; +self . +follow_epsilons +( +start +q +empty_flags +) +; / / +Start +states +can +never +be +match +states +because +we +delay +every +match / -Perl -of -course -needs -leftmost -- -first -semantics -but -they -implement -it / +by +one +byte +. +Given +an +empty +string +and +an +empty +match +the +match / / -with -a -seeming -hack -at -* -search -* -time -instead -of -encoding -it -into +won +' +t +actually +occur +until the +DFA +processes +the +special +EOF / / -/ -automaton +sentinel +byte . -There -are -also -a -couple -Java -libraries -that -support -leftmost -/ -/ -/ -longest -semantics -but -they -do -it -by -building -a -queue -of -matches -at -/ -/ -/ -search -time -which -is -even -worse -than -what -Perl -is -doing +let +sp += +match +self . -- -- -- -AG -fn -fill_failure_transitions +cached_state ( -& -mut -self +q +state_flags +None ) -- +{ +None += > -Result -< +return +None +Some ( +sp ) -BuildError -> -{ -let -is_leftmost = +> self . -builder -. -match_kind -. -is_leftmost +start_ptr ( +sp ) +} ; -let -start_uid -= self . -nfa -. -special +cache . -start_unanchored_id +start_states +[ +flagi +] += +sp ; +Some +( +sp +) +} / / -Initialize -the -queue -for -breadth -first -search -with -all -transitions -/ / -out +Computes +the +set of +starting +flags +for the -start -state +given +position +in +text . -We -handle -the -start -state -specially -because / / -we +/ +/ +/ +/ +This +should only -want -to -follow -non -- -self -transitions -. -If -we -followed -self +be +used +when +executing +the +DFA +forwards +over +the / / -transitions -then -this -would -never -terminate +/ +input . +fn +start_flags +( +& +self +text +: +& +[ +u8 +] +at +: +usize +) +- +> +( +EmptyFlags +StateFlags +) +{ let mut -queue +empty_flags = -VecDeque +EmptyFlags : : -new +default ( ) ; let mut -seen +state_flags = -self -. -queued_set +StateFlags +: +: +default ( ) ; -let -mut -prev_link +empty_flags +. +start = -None +at += += +0 ; -while -let -Some +empty_flags +. +end += +text +. +is_empty ( -link ) +; +empty_flags +. +start_line = -self +at += += +0 +| +| +text +[ +at +- +1 +] += += +b +' +\ +n +' +; +empty_flags . -nfa +end_line += +text . -next_link +is_empty ( -start_uid -prev_link ) -{ -prev_link +; +let +is_word_last = -Some +at +> +0 +& +& +Byte +: +: +byte +( +text +[ +at +- +1 +] +) +. +is_ascii_word ( -link ) ; let -t +is_word = -self -. -nfa +at +< +text . -sparse +len +( +) +& +& +Byte +: +: +byte +( +text [ -link +at ] -; -/ -/ -Skip -anything -we -' -ve -seen -before -and -any -self -- -transitions -on -the -/ -/ -start -state -. -if -start_uid -= -= -t +) . -next +is_ascii_word ( ) -| -| -seen +; +if +is_word_last +{ +state_flags . -contains +set_word ( -t -. -next ) -{ -continue ; } -queue -. -push_back -( -t +if +is_word += += +is_word_last +{ +empty_flags . -next -) +not_word_boundary += +true ; -seen +} +else +{ +empty_flags . -insert +word_boundary += +true +; +} ( -t -. -next +empty_flags +state_flags ) -; -/ +} / -Under -leftmost -semantics -if -a -state -immediately -following / / +Computes the -start -state -is -a -match -state -then -we -never -want -to -/ -/ -follow -its -failure -transition -since +set +of +starting +flags +for the -failure -transition -/ +given +position +in +text +. / -necessarily -leads -back -to -the -start -state -which -we -never / / -want -to -do -for -leftmost -matching -after -a -match -has -been / / -found -. / +This +should +only +be +used +when +executing +the +DFA +in +reverse +over +the / / / -We -apply -the -same -logic -to -non -- -start -states -below -as -well +input . -if -is_leftmost -& +fn +start_flags_reverse +( & self -. -nfa -. -states +text +: +& [ -t -. -next +u8 ] -. -is_match +at +: +usize +) +- +> ( +EmptyFlags +StateFlags ) { -self -. -nfa -. -states -[ -t -. -next -] -. -fail +let +mut +empty_flags = -NFA +EmptyFlags : : -DEAD +default +( +) ; -} -} -while let -Some +mut +state_flags += +StateFlags +: +: +default ( -id ) +; +empty_flags +. +start = -queue +at += += +text . -pop_front +len ( ) -{ -let -mut -prev_link -= -None ; -while -let -Some +empty_flags +. +end += +text +. +is_empty ( -link ) -= -self +; +empty_flags . -nfa +start_line += +at += += +text . -next_link +len ( -id -prev_link ) -{ -prev_link +| +| +text +[ +at +] = -Some += +b +' +\ +n +' +; +empty_flags +. +end_line += +text +. +is_empty ( -link ) ; let -t +is_word_last = -self +at +< +text . -nfa +len +( +) +& +& +Byte +: +: +byte +( +text +[ +at +] +) . -sparse +is_ascii_word +( +) +; +let +is_word += +at +> +0 +& +& +Byte +: +: +byte +( +text [ -link +at +- +1 ] +) +. +is_ascii_word +( +) ; if -seen +is_word_last +{ +state_flags . -contains +set_word ( -t -. -next ) +; +} +if +is_word += += +is_word_last +{ +empty_flags +. +not_word_boundary += +true +; +} +else { +empty_flags +. +word_boundary += +true +; +} +( +empty_flags +state_flags +) +} / / -The -only -way +/ +Returns +a +reference to -visit a -duplicate -state -in +State +given a -transition -/ -/ -list -is -when -ASCII -case -insensitivity -is -enabled -. -In -/ -/ -this -case -we -want +pointer to -skip -it -since -it -' -s -redundant -work -. -/ -/ -But it -would -also -end -up -duplicating -matches -which -/ -/ -results -in -reporting -duplicate -matches -in -some -cases . -/ -/ -See -the -' -acasei010 -' -regression -test +fn +state +( +& +self +si +: +StatePtr +) +- +> +& +State +{ +self . -continue -; -} -queue +cache . -push_back -( -t +compiled . -next +get_state +( +si ) -; -seen . -insert +unwrap ( -t -. -next ) -; +} / / -As -above -for -start -states -under -leftmost -semantics -once +/ +Adds +the +given +state +to +the +DFA +. / / -we -see -a -match -all -subsequent -states -should -have -no -failure / / -transitions -because -failure -transitions -always -imply -looking / / +This +allocates +room for -a -match -that -is -a -suffix +transitions +out of -what -has -been -seen -so -far -/ +this +state +in / -( -where -" -seen -so -far -" -corresponds -to -the -string -formed -by / / -following -the +self +. +cache +. +trans +. +The transitions -from -the -start -state -to +can +be +set +with the +returned / / -current -state -) -. -Under -leftmost -semantics -we -specifically -do -/ -/ -not -want -to -allow -this -to -happen -because -we -always -want -to -/ / -report -the -match -found -at -the -leftmost -position +StatePtr . / / / / -The -difference -between -leftmost -- -first -and -leftmost -- -longest / / -occurs -previously -while -we -build +If +None +is +returned +then the -trie -. -For +state +limit +was +reached +and +the +DFA / / -leftmost +/ +should +quit +. +fn +add_state +( +& +mut +self +state +: +State +) - -first -we -simply -omit -any -entries -that -would +> +Option +< +StatePtr +> +{ / / -otherwise -require -passing -through -a -match +This +will +fail +if +the +next state +pointer +exceeds +STATE_PTR . +In / / -/ -/ -Note -that -for -correctness +practice the -failure -transition -has -to -be +cache +limit +will +prevent +us +from +ever +getting +here / / +but +maybe +callers +will set -to the -dead -state -for -ALL -states -following -a +cache +size +to +something +ridiculous +. +. +. +let +si += match -not +self +. +cache +. +trans +. +add +( +) +{ +None += +> +return +None +Some +( +si +) += +> +si +} +; / / -just -the -match -state -itself -. -However -by -setting +If the -failure +program +has +a +Unicode +word +boundary +then +set +any +transitions / / -transition +for +non +- +ASCII +bytes to +STATE_QUIT +. +If the -dead -state -on -all -match -states -the -dead +DFA +stumbles +over +such +a / / -state +transition +then +it will -automatically -propagate -to -all -subsequent -states +quit +and +an +alternative +matching +engine / / -via -the -failure -state -computation -below +will +take +over . if -is_leftmost -& -& self . -nfa -. -states -[ -t -. -next -] +prog . -is_match -( -) +has_unicode_word_boundary { -self -. -nfa -. -states -[ -t +for +b +in +128 . -next -] . -fail -= -NFA -: -: -DEAD -; -continue -; -} +256 +{ let -mut -fail +cls = self . -nfa -. -states -[ -id -] -. -fail -; -while -self -. -nfa -. -follow_transition +byte_class ( -fail -t -. -byte -) -= -= -NFA +Byte : : -FAIL -{ -fail -= -self -. -nfa -. -states -[ -fail -] -. -fail -; -} -fail -= -self -. -nfa -. -follow_transition -( -fail -t -. byte +( +b +as +u8 +) ) ; self . -nfa -. -states -[ -t -. -next -] -. -fail -= -fail -; -self +cache . -nfa +trans . -copy_matches +set_next ( -fail -t -. -next +si +cls +STATE_QUIT ) -? ; } +} / / -If -the -start -state -is -a -match -state -then -this -automaton -can -/ -/ -match -the -empty -string -. -This -implies -all -states -are -match -states -/ -/ -since -every -position -matches -the -empty -string -so -copy -the -/ -/ -matches -from -the -start -state -to -every -state -. -Strictly -speaking -/ -/ -this -is -only -necessary -for -overlapping -matches -since -each -/ -/ -non -- -empty -non -- -start -match -state -needs -to -report -empty -matches -/ -/ -in -addition -to -its -own -. -For -the -non -- -overlapping -case -such -/ -/ -states -only -report -the -first -match -which -is -never -empty -since +Finally +put +our +actual +state +on +to +our +heap +of +states +and +index +it / / +so +we +can +find it -isn -' -t -a -start -state +later . -if -! -is_leftmost -{ self . -nfa +cache . -copy_matches -( +size ++ += self . -nfa +cache . -special +trans . -start_unanchored_id -id +state_heap_size +( ) -? -; -} -} -Ok ++ +state +. +data +. +len +( +) ++ ( +2 +* +mem +: +: +size_of +: +: +< +State +> ( ) ) -} -/ -/ -/ -Shuffle -the -states -so -that -they -appear -in -this -sequence ++ +mem : -/ -/ -/ -/ -/ -/ -DEAD -FAIL -MATCH -. -. -. -START -START -NON -- -MATCH +: +size_of +: +: +< +StatePtr +> +( +) +; +self . +cache . +compiled . +insert +( +state +si +) +; / / -/ -/ -/ -/ -The -idea -here -is -that -if -we -know -how -special -states -are -laid -out -in -our -/ -/ -/ -transition +Transition table -then -we -can -determine -what -" -kind -" +and +set of -state -we -' -re +states +and +map +should +all +be in -/ -/ -/ -just -by -comparing -our -current -state -ID -with -a -particular -value +sync . -In -this -/ -/ -/ -way -we -avoid -doing -extra -memory -lookups +debug_assert +! +( +self . -/ -/ -/ -/ -/ -/ -Before -shuffling -begins -our -states -look -something -like -this -: -/ -/ -/ -/ -/ -/ -DEAD -FAIL -START -START +cache +. +compiled +. +len ( -MATCH -| -NON -- -MATCH ) += += +self . +cache . +trans . +num_states +( +) +) +; +Some +( +si +) +} / / / +Quickly +finds +the +next +occurrence +of +any +literal +prefixes +in +the +regex +. / / / -So -all -we -need -to -do -is -move -all -of +If +there +are +no +literal +prefixes +then the -MATCH -states -so -that -they +current +position +is / / / -all -appear -before -any -NON -- -MATCH -state -like -so -: +returned +. +If +there +are +literal +prefixes +and +one +could +not +be +found / / / +then +None +is +returned +. / / / -DEAD -FAIL -START -START -MATCH +/ +/ +/ +This +should +only +be +called +when +the +DFA +is +in +a +start +state +. +fn +prefix_at +( +& +self +text +: +& +[ +u8 +] +at +: +usize +) +- +> +Option +< +usize +> +{ +self . +prog . +prefixes . -NON -- -MATCH +find +( +& +text +[ +at . . +] +) . +map +( +| +( +s +_ +) +| +at ++ +s +) +} / / / -/ -/ -/ -Then -it -' -s -just -a -simple -matter -of -swapping +Returns the -two -START -states -with +number +of +byte +classes +required +to +discriminate +transitions / / / -the -last -two -MATCH -states +in +each +state . / / @@ -12971,990 +13133,1018 @@ states / / / +invariant +: +num_byte_classes ( -This -is -the -same -technique -used -for -fully -compiled -DFAs -in -/ -/ -/ -regex -- -automata +) += += +len +( +State . +next ) fn -shuffle +num_byte_classes ( & -mut self ) +- +> +usize { -let -old_start_uid -= -self -. -nfa -. +/ +/ +We +add +1 +to +account +for +the special +EOF +byte . -start_unanchored_id -; -let -old_start_aid -= +( self . -nfa -. -special -. -start_anchored_id -; -assert -! -( -old_start_uid -< -old_start_aid -) -; -assert_eq -! -( -3 -old_start_aid +prog . -as_usize -( -) -" -anchored -start -state -should -be -at -index -3 -" +byte_classes +[ +255 +] +as +usize ++ +1 ) -; -/ -/ -We -implement -shuffling -by -a -sequence -of -pairwise -swaps -of -states -. ++ +1 +} / / -Since -we -have -a -number -of -things -referencing -states -via -their / +Given +an +input +byte +or +the +special +EOF +sentinel +return +its / -IDs -and -swapping -them -changes -their -IDs -we -need -to -record -every / / -swap -we -make -so -that -we -can -remap -IDs +corresponding +byte +class +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +byte_class +( +& +self +b +: +Byte +) +- +> +usize +{ +match +b . -The -remapper -handles -this +as_byte +( +) +{ +None += +> +self +. +num_byte_classes +( +) +- +1 +Some +( +b +) += +> +self +. +u8_class +( +b +) +} +} / / -book -- -keeping +/ +Like +byte_class +but +explicitly for -us +u8s . -let -mut -remapper +# +[ +cfg_attr +( +feature = -Remapper -: -: -new +" +perf +- +inline +" +inline +( +always +) +) +] +fn +u8_class ( & self -. -nfa -0 +b +: +u8 ) -; +- +> +usize +{ +self +. +prog +. +byte_classes +[ +b +as +usize +] +as +usize +} / / -The -way -we -proceed -here -is -by -moving -all +/ +Returns +true +if +the +DFA +should +continue +searching +past +the +first match -states -so -that +. / / -they -directly -follow +/ +/ +/ +/ +Leftmost +first +semantics +in the -start -states -. -So -it -will -go -: -DEAD -FAIL +DFA +are +preserved +by +not +following +NFA / / -START -- -UNANCHORED -START -- -ANCHORED -MATCH -. -. -. -NON -- -MATCH -. -. +/ +transitions +after +the +first +match +is +seen . / / / / -To -do -that -we -proceed -forward -through -all -states -after / / -START -- -ANCHORED -and -swap -match -states -so -that -they -appear -before -all +On +occasion +we +want +to +avoid +leftmost +first +semantics +to +find +either / / -non -- +/ +the +longest match -states -. -let -mut -next_avail -= -StateID -: -: -from ( -4u8 +for +reverse +search ) -; +or +all +possible +matches +( for -i -in -next_avail +/ +/ +/ +regex +sets +) . -as_usize +fn +continue_past_first_match ( +& +self ) +- +> +bool +{ +self . +prog . +is_reverse +| +| self . -nfa +prog . -states +matches . len ( ) -{ -let -sid -= -StateID -: -: -new -( -i -) +> +1 +} +/ +/ +/ +Returns +true +if +there +is +a +prefix +we +can +quickly +search +for . -unwrap +fn +has_prefix ( +& +self ) -; -if +- +> +bool +{ +! +self +. +prog +. +is_reverse +& +& ! self . -nfa +prog . -states -[ -sid -] +prefixes . -is_match +is_empty ( ) -{ -continue -; -} -remapper -. -swap -( & -mut +& +! self . -nfa -sid -next_avail -) -; +prog +. +is_anchored_start +} / / -The -key -invariant -here -is -that +/ +Sets +the +STATE_START +bit +in +the +given +state +pointer +if +and only -non -- -match -states -exist +if / / -between -' -next_avail -' -and +/ +we +have +a +prefix +to +scan +for +. +/ +/ +/ +/ +/ +/ +If +there ' -sid +s +no +prefix +then +it ' -( -with -them -being -potentially +s +a +waste +to +treat +the +start +state / / -equivalent +/ +specially +. +fn +start_ptr +( +& +self +si +: +StatePtr ) +- +> +StatePtr +{ +if +self . -Thus -incrementing -' -next_avail -' +has_prefix +( +) +{ +si +| +STATE_START +} +else +{ +si +} +} +/ +/ +/ +Approximate +size +returns +the +approximate +heap +space +currently +used by -1 -is -guaranteed / / +/ +the +DFA +. +It +is +used to -land -on +determine +whether the -leftmost -non -- -match +DFA +' +s state +cache +needs +to +/ +/ +/ +be +wiped . -( -Unless -' -next_avail -' +Namely +it +is +possible +that +for +certain +regexes +on +certain / / -and -' -sid -' -are -equivalent -in -which -case +/ +inputs a -swap -will -occur -but +new +state +could +be +created +for +every +byte +of +input +. +( +This +is / / +/ +bad +for +memory +use +so +we +bound it -is +with a -no -- -op +cache . ) -next_avail -= -StateID -: -: -new -( -next_avail -. -one_more +fn +approximate_size ( +& +self ) -) +- +> +usize +{ +self . -unwrap +cache +. +size ++ +self +. +prog +. +approximate_size ( ) -; +} } / / -Now -we -' -d -like -to -move -the -start -states -to -immediately -following -the -/ / -match +An +abstraction +for +representing +a +map +of states . -( The -start -states -may -themselves -be -match -states -but -/ -/ -we -' -ll -handle -that -later -. -) -We -arrange -the -states -this -way -so -that -we +map +supports +two / / -don -' -t -necessarily -need -to -check -whether -a +/ +different +ways +of state +lookup +. +One is +fast +constant +time +access +via a -start -state -or / / -not -before -checking -whether -a +/ state +pointer +. +The +other is a -match -state -. -For -example +hashmap +lookup +based +on +the +DFA +' +s / / -we -' -d -like -to -be -able -to -write -this -as -our -state -machine -loop -: / +constituent +NFA +states +. / / / -sid -= -start -( -) / / -for -byte -in -haystack -: / +A +DFA +state +internally +uses +an +Arc +such +that +we +only +need +to +store +the / -sid -= -next -( -sid -byte -) / / -if -sid -< -= -nfa -. -max_start_id -: +set +of +NFA +states +on +the +heap +once +even +though +we +support +looking +up / / -if -sid -< -= -nfa +/ +states +by +two +different +means . -max_dead_id -: +A +more +natural +way +to +express +this +might / / -# -search -complete / +use +raw +pointers +but +an +Arc +is +safe +and +effectively +achieves +the +same / -elif -sid -< -= -nfa -. -max_match_id -: / / +thing +. # -found -match -/ +[ +derive +( +Debug +) +] +struct +StateMap +{ / / / The -important -context -here -is -that -we -might +keys +are not -want +actually +static +but +rely +on +always +pointing to -look -for +a / / -start +/ +buffer +in states -at -all -. -Namely -if -a -searcher -doesn -' -t -have -a -prefilter +which +will +never +be +moved +except +when +clearing / / -then -there -is -no -reason -to -care -about -whether -we -' -re +/ +the +map +or +on +drop in -a -start -state +which +case +the +keys +of +this +map +will +be / / -or -not +/ +removed +before +map +: +HashMap +< +State +StatePtr +> +/ +/ +/ +Our +set +of +states . -And -indeed -if -we -did -check -for -it -this -very -hot -loop -would +Note +that +StatePtr / +num_byte_classes +indexes / -ping -pong -between -the -special -state -handling -and -the -main -state / / -transition -logic -. -This +this +Vec +rather +than +just +a +StatePtr +. +states +: +Vec +< +State +> +/ +/ +/ +The +number +of +byte +classes in -turn -stalls the -CPU -by -killing -branch -/ -/ -prediction +DFA . -/ -/ -/ -/ -So -essentially -we -really -want -to -be -able +Used to -" -forget -" -that -start -/ -/ +index states -even -exist -and -this -is -why -we -put -them -at -the -end . -let -new_start_aid -= -StateID -: +num_byte_classes : +usize +} +impl +StateMap +{ +fn new ( -next_avail -. -as_usize -( -) -. -checked_sub -( -1 -) -. -unwrap -( -) +num_byte_classes +: +usize ) -. -unwrap +- +> +StateMap +{ +StateMap +{ +map +: +HashMap +: +: +new ( ) -; -remapper -. -swap +states +: +vec +! +[ +] +num_byte_classes +} +} +fn +len ( & -mut self -. -nfa -old_start_aid -new_start_aid ) -; -let -new_start_uid -= -StateID -: -: -new -( -next_avail +- +> +usize +{ +self . -as_usize -( -) +states . -checked_sub +len ( -2 ) -. -unwrap +} +fn +is_empty ( +& +self ) -) +- +> +bool +{ +self . -unwrap +states +. +is_empty ( ) -; -remapper -. -swap +} +fn +get_ptr ( & -mut self -. -nfa -old_start_uid -new_start_uid -) -; -let -new_max_match_id -= -StateID -: +state : -new -( -next_avail -. -as_usize -( +& +State ) +- +> +Option +< +StatePtr +> +{ +self . -checked_sub -( -3 -) +map . -unwrap +get ( -) +state ) . -unwrap +cloned ( ) -; -self -. -nfa -. -special -. -max_match_id -= -new_max_match_id -; +} +fn +get_state +( +& self -. -nfa -. -special -. -start_unanchored_id -= -new_start_uid -; +si +: +StatePtr +) +- +> +Option +< +& +State +> +{ self . -nfa -. -special +states . -start_anchored_id -= -new_start_aid -; -/ +get +( +si +as +usize / -If -one -start -state -is -a -match -state -then -they -both -are -. -if -self -. -nfa -. -states -[ self . -nfa -. -special -. -start_anchored_id -] -. -is_match +num_byte_classes +) +} +fn +insert ( +& +mut +self +state +: +State +si +: +StatePtr ) { self . -nfa +map . -special +insert +( +state . -max_match_id -= +clone +( +) +si +) +; self . -nfa -. -special +states . -start_anchored_id +push +( +state +) ; } -remapper -. -remap +fn +clear ( & mut self +) +{ +self . -nfa +map +. +clear +( ) ; -} -/ -/ -/ -Attempts -to -convert -the -transition -representation -of -a -subset -of +self +. states -/ -/ -/ -in -this -NFA -from -sparse -to -dense . -This -can -greatly -improve -search +clear +( +) +; +} +} +impl +Transitions +{ / / / -performance -since -states -with +Create a -higher -number -of -transitions -tend -to -/ -/ -/ -correlate -with -very -active -states +new +transition +table . / / @@ -13962,107 +14152,101 @@ states / / / -We -generally -only -densify -states -that -are -close -to -the -start -state -. -/ -/ -/ -These -tend +The +number +of +byte +classes +corresponds to -be the -most -active -states -and -thus -benefit -from -a -dense -/ -/ -/ -representation -more -than -other -states +stride . +Every +state +will / / / -/ -/ -/ -This -tends -to -best -balance -between -memory -usage -and -performance +have +num_byte_classes +slots +for +transitions . -In +fn +new +( +num_byte_classes +: +usize +) +- +> +Transitions +{ +Transitions +{ +table +: +vec +! +[ +] +num_byte_classes +} +} / / / -particular +Returns the -* -vast -majority -* +total +number of -all states +currently in -a -typical -Aho +this +table +. +fn +num_states +( +& +self +) - -Corasick -/ -/ +> +usize +{ +self +. +table +. +len +( +) / -automaton -have -only -1 -transition -and -are -usually -farther -from -the -start +self +. +num_byte_classes +} / / / +Allocates +room +for +one +additional state and -thus -don -' -t -get -densified +returns +a +pointer +to +it . / / @@ -14070,2402 +14254,2155 @@ densified / / / -Note -that -this -doesn +If +there ' -t -remove -the -sparse -representation -of -transitions -/ -/ -/ -for -states -that -are -densified +s +no +more +room +None +is +returned +. +fn +add +( +& +mut +self +) +- +> +Option +< +StatePtr +> +{ +let +si += +self +. +table +. +len +( +) +; +if +si +> +STATE_MAX +as +usize +{ +return +None +; +} +self +. +table +. +extend +( +repeat +( +STATE_UNKNOWN +) +. +take +( +self . -It -could -be -done -but -actually -removing +num_byte_classes +) +) +; +Some +( +usize_to_u32 +( +si +) +) +} / / / -entries -from -NFA -: -: -sparse -is -likely -more -expensive -than -it -' -s -worth +Clears +the +table +of +all +states . fn -densify +clear ( & mut self ) -- -> -Result -< -( -) -BuildError -> { -for -i -in -0 -. -. self . -nfa -. -states -. -len -( -) -{ -let -sid -= -StateID -: -: -new -( -i -) +table . -unwrap +clear ( ) ; +} / / -Don -' -t -bother -densifying -states -that -are -only -used -as -sentinels +/ +Sets +the +transition +from +( +si +cls +) +to +next . -if -sid -= -= -NFA -: +fn +set_next +( +& +mut +self +si : -DEAD -| -| -sid -= -= -NFA +StatePtr +cls : +usize +next : -FAIL +StatePtr +) { -continue +self +. +table +[ +si +as +usize ++ +cls +] += +next ; } / / -Only -densify -states -that -are -" -close -enough -" -to +/ +Returns the -start -state +transition +corresponding +to +( +si +cls +) . -if +fn +next +( +& +self +si +: +StatePtr +cls +: +usize +) +- +> +StatePtr +{ self . -nfa -. -states +table [ -sid +si +as +usize ++ +cls ] +} +/ +/ +/ +The +heap +size +in +bytes +of +a +single +state +in +the +transition +table . -depth -. -as_usize +fn +state_heap_size ( +& +self ) +- > -= -self -. -builder -. -dense_depth +usize { -continue -; -} -let -dense -= self . -nfa -. -alloc_dense_state -( -) -? -; -let -mut -prev_link -= -None -; -while -let -Some +num_byte_classes +* +mem +: +: +size_of +: +: +< +StatePtr +> ( -link ) -= -self -. -nfa +} +/ +/ +/ +Like +next +but +uses +unchecked +access +and +is +therefore +not +safe . -next_link -( -sid -prev_link -) -{ -prev_link -= -Some +unsafe +fn +next_unchecked ( -link -) -; -let -t -= +& self -. -nfa -. -sparse -[ -link -] -; -let -class -= -usize +si : +StatePtr +cls : -from +usize +) +- +> +StatePtr +{ +debug_assert +! ( +( +si +as +usize +) +< self . -nfa -. -byte_classes +table . -get +len ( -t -. -byte ) ) ; -let -index -= -dense -. -as_usize +debug_assert +! ( -) -+ -class -; +cls +< self . -nfa -. -dense -[ -index -] -= -t -. -next +num_byte_classes +) ; -} +* self . -nfa -. -states -[ -sid -] +table . -dense -= -dense -; -} -Ok -( +get_unchecked ( -) +si +as +usize ++ +cls ) } -/ -/ -/ -Returns -a -set -that -tracked -queued -states -. -/ -/ -/ -/ -/ -/ -This -is -only -necessary -when -ASCII -case -insensitivity -is -enabled -since -/ -/ -/ -it -is -the -only -way -to -visit -the -same -state -twice -. -Otherwise -this -/ -/ -/ -returns -an -inert -set -that -nevers -adds -anything -and -always -reports -/ -/ -/ -false -for -every -member -test -. +} +impl +StateFlags +{ fn -queued_set +is_match ( & self ) - > -QueuedSet +bool { -if self . -builder -. -ascii_case_insensitive -{ -QueuedSet -: -: -active +0 +& +0b0000_0001 +> +0 +} +fn +set_match ( +& +mut +self ) -} -else { -QueuedSet -: -: -inert +self +. +0 +| += +0b0000_0001 +; +} +fn +is_word ( +& +self ) -} -} -/ -/ -/ -Initializes -the -unanchored -start -state -by -making -it -dense -. -This -is -/ -/ -/ -achieved -by -explicitly -setting -every -transition -to -the -FAIL -state -. -/ -/ -/ -This -isn -' -t -necessary -for -correctness -since -any -missing -transition -is -/ -/ -/ -automatically -assumed -to -be -mapped -to -the -FAIL -state -. -We -do -this -to -/ -/ -/ -make -the -unanchored -starting -state -dense -and -thus -in -turn -make -/ -/ -/ -transition -lookups -on -it -faster +- +> +bool +{ +self . +0 +& +0b0000_0010 +> +0 +} +fn +set_word ( -Which -is -worth -doing -because -it -' -s -/ -/ -/ -the -most -active -state -. +& +mut +self ) +{ +self +. +0 +| += +0b0000_0010 +; +} fn -init_unanchored_start_state +has_empty ( & -mut self ) - > -Result -< +bool +{ +self +. +0 +& +0b0000_0100 +> +0 +} +fn +set_empty ( +& +mut +self ) -BuildError -> { -let -start_uid -= self . -nfa -. -special -. -start_unanchored_id -; -let -start_aid +0 +| = -self -. -nfa -. -special -. -start_anchored_id +0b0000_0100 ; -self -. -nfa -. -init_full_state +} +} +impl +Byte +{ +fn +byte ( -start_uid -NFA -: +b : -FAIL +u8 ) -? -; -self -. -nfa -. -init_full_state +- +> +Self +{ +Byte ( -start_aid -NFA -: -: -FAIL +b +as +u16 ) -? -; -Ok -( +} +fn +eof ( ) +- +> +Self +{ +Byte +( +256 ) } -/ -/ -/ -Setup -the -anchored -start -state -by -copying -all -of -the -transitions -and -/ -/ -/ -matches -from -the -unanchored -starting -state -with -one -change -: -the -failure -/ -/ -/ -transition -is -changed -to -the -DEAD -state -so -that -for -any -undefined -/ -/ -/ -transitions -the -search -will -stop -. fn -set_anchored_start_state +is_eof ( & -mut self ) - > -Result -< +bool +{ +self +. +0 += += +256 +} +fn +is_ascii_word ( +& +self ) -BuildError +- > +bool { let -start_uid -= -self -. -nfa -. -special -. -start_unanchored_id -; -let -start_aid +b = +match self . -nfa -. -special -. -start_anchored_id -; -let +as_byte ( -mut -uprev_link -mut -aprev_link ) +{ +None = +> +return +false +Some ( -None -None +b ) += +> +b +} ; -loop +match +b { -let -unext +b +' +A +' +. +. = -self +b +' +Z +' +| +b +' +a +' . -nfa . -next_link -( -start_uid -uprev_link -) -; -let -anext = -self +b +' +z +' +| +b +' +0 +' . -nfa . -next_link -( -start_aid -aprev_link -) -; -let -( -ulink -alink -) = -match +b +' +9 +' +| +b +' +_ +' += +> +true +_ += +> +false +} +} +fn +as_byte ( -unext -anext +& +self ) +- +> +Option +< +u8 +> { +if +self +. +is_eof ( -Some -( -ulink ) +{ +None +} +else +{ Some ( -alink -) +self +. +0 +as +u8 ) -= +} +} +} +impl +fmt +: +: +Debug +for +State +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ > -( -ulink -alink -) -( -None -None ) -= +- > -break -_ -= +fmt +: +: +Result +{ +let +ips +: +Vec +< +usize > -unreachable -! -( -) -} -; -uprev_link = -Some +self +. +inst_ptrs ( -ulink ) -; -aprev_link -= -Some +. +collect ( -alink ) ; -self -. -nfa -. -sparse -[ -alink -] -. -next -= -self -. -nfa -. -sparse -[ -ulink -] -. -next -; -} -self -. -nfa +f . -copy_matches +debug_struct ( -start_uid -start_aid +" +State +" ) -? -; -/ -/ -This -is -the -main -difference -between -the -unanchored -and -anchored -/ -/ -starting -states -. -If -a -lookup -on -an -anchored -starting -state -fails -/ -/ -then -the -search -should -stop -. -/ -/ -/ -/ -N -. -B -. -This -assumes -that -the -loop -on -the -unanchored -starting -state -/ -/ -hasn -' -t -been -created -yet . +field +( +" +flags +" +& self . -nfa -. -states -[ -start_aid -] -. -fail -= -NFA -: -: -DEAD -; -Ok -( +flags ( ) ) -} -/ -/ -/ -Set -the -failure -transitions -on -the -start -state -to -loop -back -to -the -/ -/ -/ -start -state . -This -effectively -permits -the -Aho -- -Corasick -automaton -to -/ -/ -/ -match -at -any -position +field +( +" +insts +" +& +ips +) . -This -is -also -required +finish +( +) +} +} +impl +fmt +: +: +Debug for -finding -the -next -/ -/ -/ -state -to -terminate -namely -finding -the -next -state -should -never -return -/ -/ -/ -a -fail_id -. -/ -/ -/ -/ -/ -/ -This -must -be -done -after -building -the -initial -trie -since -trie -/ -/ -/ -construction -depends -on -transitions -to -fail_id -to -determine -whether -a -/ -/ -/ -state -already -exists -or -not -. +Transitions +{ fn -add_unanchored_start_state_loop +fmt ( & -mut self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> ) +- +> +fmt +: +: +Result { let -start_uid -= -self -. -nfa -. -special -. -start_unanchored_id -; -let mut -prev_link +fmtd = -None -; -while -let -Some +f +. +debug_map ( -link ) -= -self +; +for +si +in +0 . -nfa . -next_link +self +. +num_states ( -start_uid -prev_link ) { -prev_link +let +s = -Some -( -link -) +si +* +self +. +num_byte_classes ; -if +let +e += +s ++ self . -nfa +num_byte_classes +; +fmtd . -sparse -[ -link -] +entry +( +& +si . -next +to_string ( ) -= -= -NFA -: -: -FAIL -{ +& +TransitionsRow +( +& self . -nfa -. -sparse +table [ -link -] +s . -next -= -start_uid +. +e +] +) +) ; } +fmtd +. +finish +( +) } } -/ -/ -/ -Remove -the -start -state -loop -by -rewriting -any -transitions -on -the -start -/ -/ -/ -state -back -to -the -start -state -with -transitions -to -the -dead -state -. -/ -/ -/ -/ -/ -/ -The -loop -is -only -closed -when -two -conditions -are -met -: -the -start -state -/ -/ -/ -is +struct +TransitionsRow +< +' a -match -state -and -the -match -kind -is -leftmost -- -first -or -/ -/ -/ -leftmost -- -longest -. -/ -/ -/ -/ -/ -/ -The -reason -for -this -is -that -under -leftmost -semantics +> +( +& +' a -start -state -/ -/ -/ -that -is -also +[ +StatePtr +] +) +; +impl +< +' a -match -implies -that -we -should -never -restart -the -search -/ -/ -/ -process -. -We -allow -normal -transitions -out -of -the -start -state -but -if -/ -/ -/ -none -exist -we -transition -to -the -dead -state -which -signals -that -/ -/ -/ -searching -should -stop -. +> +fmt +: +: +Debug +for +TransitionsRow +< +' +a +> +{ fn -close_start_state_loop_for_leftmost +fmt ( & -mut self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> ) +- +> +fmt +: +: +Result { let -start_uid -= -self -. -nfa -. -special -. -start_unanchored_id -; -let -start -= -& mut -self -. -nfa -. -states -[ -start_uid -] -; -let -dense +fmtd = -start +f . -dense +debug_map +( +) ; -if +for +( +b +si +) +in self . -builder -. -match_kind +0 . -is_leftmost +iter ( ) -& -& -start . -is_match +enumerate ( ) { -let -mut -prev_link +match +* +si +{ +STATE_UNKNOWN = -None -; -while -let -Some +> +{ +} +STATE_DEAD += +> +{ +fmtd +. +entry ( -link +& +vb +( +b +as +usize +) +& +" +DEAD +" ) +; +} +si = -self +> +{ +fmtd . -nfa +entry +( +& +vb +( +b +as +usize +) +& +si +. +to_string +( +) +) +; +} +} +} +fmtd . -next_link +finish ( -start_uid -prev_link ) +} +} +impl +fmt +: +: +Debug +for +StateFlags { -prev_link -= -Some +fn +fmt ( -link +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> ) -; -if +- +> +fmt +: +: +Result +{ +f +. +debug_struct +( +" +StateFlags +" +) +. +field +( +" +is_match +" +& self . -nfa +is_match +( +) +) . -sparse -[ -link -] +field +( +" +is_word +" +& +self . -next +is_word ( ) -= -= -start_uid -{ +) +. +field +( +" +has_empty +" +& self . -nfa +has_empty +( +) +) . -sparse -[ -link -] +finish +( +) +} +} +/ +/ +/ +Helper +function +for +formatting +a +byte +as +a +nice +- +to +- +read +escaped +string . -next -= -NFA +fn +vb +( +b +: +usize +) +- +> +String +{ +use +std : : -DEAD +ascii +: +: +escape_default ; if -dense -! -= -StateID +b +> +: +: +std : : -ZERO +u8 +: +: +MAX +as +usize { -let -b -= -self -. -nfa -. -sparse -[ -link -] +" +EOF +" . -byte -; +to_owned +( +) +} +else +{ let -class +escaped = -usize -: -: -from +escape_default ( -self -. -nfa -. -byte_classes +b +as +u8 +) . -get +collect +: +: +< +Vec +< +u8 +> +> ( -b -) ) ; -self -. -nfa -. -dense -[ -dense +String +: +: +from_utf8_lossy +( +& +escaped +) . -as_usize +into_owned ( ) -+ -class -] -= -NFA -: -: -DEAD -; -} } } -} -} -/ -/ -/ -Sets -all -transitions -on -the -dead -state -to -point -back -to -the -dead -state -. -/ -/ -/ -Normally -missing -transitions -map -back -to -the -failure -state -but -the -/ -/ -/ -point -of -the -dead -state -is -to -act -as -a -sink -that -can -never -be -escaped -. fn -add_dead_state_loop +usize_to_u32 ( -& -mut -self +n +: +usize ) - > -Result -< +u32 +{ +if ( +n +as +u64 ) -BuildError > -{ -self -. -nfa -. -init_full_state ( -NFA : : -DEAD -NFA +std : : -DEAD +u32 +: +: +MAX +as +u64 ) -? -; -Ok -( +{ +panic +! ( -) +" +BUG +: +{ +} +is +too +big +to +fit +into +u32 +" +n ) } +n +as +u32 } +# +[ +allow +( +dead_code +) +] / / -/ -A -set -of -state -identifiers -used -to -avoid -revisiting -the -same -state -multiple -/ -/ -/ -times -when -filling -in -failure -transitions -. -/ -/ -/ -/ -/ -/ -This -set -has -an +useful +for +debugging +fn +show_state_ptr +( +si +: +StatePtr +) +- +> +String +{ +let +mut +s += +format +! +( " -inert +{ +: +? +} " -and -an +si +& +STATE_MAX +) +; +if +si += += +STATE_UNKNOWN +{ +s += +format +! +( " -active +{ +} +( +unknown +) " -mode -. -When -inert -the -set -never -/ -/ -/ -stores -anything -and -always -returns -false -for -every -member -test -. -This -is -/ -/ -/ -useful -to -avoid -the -performance -and -memory -overhead -of -maintaining -this -/ -/ -/ -set -when -it -is -not -needed -. -# -[ -derive +s +) +; +} +if +si += += +STATE_DEAD +{ +s += +format +! +( +" +{ +} ( -Debug +dead ) -] -struct -QueuedSet -{ -set -: -Option -< -BTreeSet -< -StateID -> -> +" +s +) +; } -impl -QueuedSet +if +si += += +STATE_QUIT { -/ -/ -/ -Return -an -inert -set -that -returns -false -for -every -state -ID -membership -/ -/ -/ -test -. -fn -inert +s += +format +! +( +" +{ +} ( +quit ) -- +" +s +) +; +} +if +si +& +STATE_START > -QueuedSet +0 { -QueuedSet +s += +format +! +( +" { -set -: -None -} } -/ -/ -/ -Return -an -active -set -that -tracks -state -ID -membership -. -fn -active ( +start ) -- +" +s +) +; +} +if +si +& +STATE_MATCH > -QueuedSet -{ -QueuedSet +0 { -set -: -Some +s += +format +! ( -BTreeSet -: -: -new +" +{ +} ( +match ) +" +s ) +; } +s } / / / -Inserts -the -given -state -ID -into -this -set -. -( -If -the -set -is -inert -then +https +: / / +developers +. +google +. +com / -this -is -a -no +protocol - -op -. -) +buffers +/ +docs +/ +encoding +# +varints fn -insert +write_vari32 ( +data +: & mut -self -state_id +Vec +< +u8 +> +n : -StateID +i32 ) { -if let -Some -( -ref mut -set +un += +( +n +as +u32 ) +< +< +1 +; +if +n +< +0 +{ +un = -self +! +un +; +} +write_varu32 +( +data +un +) +} +/ +/ +/ +https +: +/ +/ +developers . -set -{ -set +google . -insert +com +/ +protocol +- +buffers +/ +docs +/ +encoding +# +varints +fn +read_vari32 +( +data +: +& +[ +u8 +] +) +- +> +( +i32 +usize +) +{ +let +( +un +i +) += +read_varu32 +( +data +) +; +let +mut +n += ( -state_id +un +> +> +1 ) +as +i32 +; +if +un +& +1 +! += +0 +{ +n += +! +n ; } +( +n +i +) } / / / -Returns -true -if -and -only -if -the -given -state -ID -is -in -this -set -. -If -the -/ +https +: / / -set -is -inert -this -always -returns -false +developers +. +google . +com +/ +protocol +- +buffers +/ +docs +/ +encoding +# +varints fn -contains +write_varu32 ( +data +: & -self -state_id +mut +Vec +< +u8 +> +mut +n : -StateID +u32 ) -- +{ +while +n > -bool += +0b1000_0000 { -match -self +data . -set -{ -None -= -> -false -Some +push ( -ref -set +( +n +as +u8 ) -= +| +0b1000_0000 +) +; +n > -set +> += +7 +; +} +data . -contains +push ( -& -state_id +n +as +u8 ) +; } -} -} -impl -core -: -: -fmt -: +/ +/ +/ +https : -Debug -for -NFA -{ +/ +/ +developers +. +google +. +com +/ +protocol +- +buffers +/ +docs +/ +encoding +# +varints fn -fmt +read_varu32 ( -& -self -f +data : & -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> +[ +u8 +] ) - > -core -: -: -fmt -: -: -Result -{ -use -crate -: -: -{ -automaton -: -: +( +u32 +usize +) { -fmt_state_indicator -sparse_transitions -} -util -: -: -debug -: +let +mut +n : -DebugByte -} +u32 += +0 ; -writeln -! -( -f -" -noncontiguous -: +let +mut +shift : -NFA -( -" -) -? +u32 += +0 ; for ( -sid -state +i +& +b ) in -self -. -states +data . iter ( ) . -with_state_ids +enumerate ( ) { -/ -/ -The -FAIL -state -doesn -' -t -actually -have -space -for -a -state -allocated -/ -/ -for -it -so -we -have -to -treat -it -as -a -special -case -. if -sid -= -= -NFA -: -: -FAIL +b +< +0b1000_0000 { -writeln -! +return +( +n +| ( -f -" -F -{ -: -06 -} -: -" -sid -. -as_usize ( +b +as +u32 ) +< +< +shift +) +i ++ +1 ) -? -; -continue ; } -fmt_state_indicator +n +| += ( -f -self -sid +( +b +as +u32 ) -? +& +0b0111_1111 +) +< +< +shift ; -write -! +shift ++ += +7 +; +} ( -f -" -{ -: -06 +0 +0 +) } +# +[ +cfg ( +test +) +] +mod +tests { +use +super : -06 +: +{ +push_inst_ptr +read_vari32 +read_varu32 +write_vari32 +write_varu32 +State +StateFlags } -) +; +use +quickcheck : -" -sid -. -as_usize -( -) -state -. -fail -. -as_usize -( -) -) -? +: +{ +quickcheck +Gen +QuickCheck +} ; -let -it -= -sparse_transitions -( -self -. -iter_trans +use +std +: +: +sync +: +: +Arc +; +# +[ +test +] +fn +prop_state_encode_decode ( -sid ) -. -map -( -| -t -| +{ +fn +p ( +mut +ips +: +Vec +< +u32 +> +flags +: +u8 +) +- +> +bool +{ +/ +/ +It +looks +like +our +encoding +scheme +can +' t +handle +instruction +/ +/ +pointers +at +or +above +2 +* +* +31 . -byte -t +We +should +fix +that +but +it +seems +/ +/ +unlikely +to +occur +in +real +code +due +to +the +amount +of +memory +/ +/ +required +for +such +a +state +machine . -next -) -) -) +So +for +now +we +just +clamp +/ +/ +our +test +data . -enumerate -( -) -; for -( -i -( -start -end -sid -) -) +ip in -it +& +mut +ips { if -i +* +ip > -0 += +1 +< +< +31 { -write -! +* +ip += ( -f -" -" +1 +< +< +31 ) -? +- +1 ; } -if -start -= +} +let +mut +data = -end -{ -write +vec ! -( -f -" -{ -: -? -} +[ +flags +] +; +let +mut +prev = -> -{ -: -? -} -" -DebugByte -( -start -) -sid +0 +; +for +& +ip +in +ips . -as_usize +iter ( ) +{ +push_inst_ptr +( +& +mut +data +& +mut +prev +ip ) -? ; } -else -{ -write -! -( -f -" +let +state += +State { +data : -? -} -- -{ +Arc : -? -} -= -> -{ : -? -} -" -DebugByte -( -start -) -DebugByte +from ( -end -) -sid +& +data +[ . -as_usize -( -) +. +] ) -? -; } -} -write -! +; +let +expected +: +Vec +< +usize +> += +ips +. +into_iter ( -f -" -\ -n -" ) -? -; -if -self . -is_match +map ( -sid +| +ip +| +ip +as +usize ) -{ -write -! +. +collect ( -f -" -matches -: -" ) -? ; -for +let +got +: +Vec +< +usize +> += +state +. +inst_ptrs ( -i -pid ) -in -self . -iter_matches +collect ( -sid ) +; +expected += += +got +& +& +state . -enumerate +flags ( ) -{ -if -i -> -0 -{ -write -! += += +StateFlags ( -f -" -" +flags ) -? -; } -write -! +QuickCheck +: +: +new ( -f -" -{ -} -" -pid +) . -as_usize +gen +( +Gen +: +: +new ( +10_000 ) ) -? -; -} -write -! +. +quickcheck ( -f -" -\ -n -" +p +as +fn +( +Vec +< +u32 +> +u8 +) +- +> +bool ) -? ; } -} -writeln -! +# +[ +test +] +fn +prop_read_write_u32 ( -f -" -match -kind -: +) { +fn +p +( +n : -? -} -" -self -. -match_kind +u32 ) -? -; -writeln +- +> +bool +{ +let +mut +buf += +vec ! +[ +] +; +write_varu32 ( -f -" -prefilter -: -{ -: -? -} -" -self -. -prefilter -. -is_some +& +mut +buf +n +) +; +let ( +got +nread ) += +read_varu32 +( +& +buf ) -? ; -writeln -! -( -f -" -state -length -: -{ -: -? -} -" -self -. -states +nread += += +buf . len ( ) -) -? -; -writeln -! -( -f -" -pattern -length -: -{ -: -? +& +& +got += += +n } -" -self -. -patterns_len +quickcheck +( +p +as +fn ( +u32 ) +- +> +bool ) -? ; -writeln -! +} +# +[ +test +] +fn +prop_read_write_i32 ( -f -" -shortest -pattern -length -: +) { +fn +p +( +n : -? -} -" -self -. -min_pattern_len +i32 ) -? -; -writeln +- +> +bool +{ +let +mut +buf += +vec ! +[ +] +; +write_vari32 ( -f -" -longest -pattern -length -: -{ -: -? -} -" -self -. -max_pattern_len +& +mut +buf +n ) -? ; -writeln -! -( -f -" -memory -usage -: -{ -: -? -} -" -self -. -memory_usage +let ( +got +nread ) += +read_vari32 +( +& +buf ) -? ; -writeln -! +nread += += +buf +. +len ( -f -" -) -" ) -? -; -Ok +& +& +got += += +n +} +quickcheck ( +p +as +fn ( +i32 ) +- +> +bool ) +; } } diff --git a/third_party/rust/regex/src/error.rs b/third_party/rust/regex/src/error.rs index fff761f83fecc..ddc8f2b9ad941 100644 --- a/third_party/rust/regex/src/error.rs +++ b/third_party/rust/regex/src/error.rs @@ -1,20 +1,17 @@ use -alloc -: -: -string +std : : -{ -String -ToString -} +fmt ; use -regex_automata +std +: +: +iter : : -meta +repeat ; / / @@ -33,10 +30,6 @@ expression . # [ -non_exhaustive -] -# -[ derive ( Clone @@ -68,11 +61,11 @@ exceeded the set size +limit +. / / / -limit -. The argument is @@ -80,503 +73,77 @@ the size limit imposed -by -/ -/ -/ -[ -RegexBuilder -: -: -size_limit -] +. +CompiledTooBig ( -crate -: -: -RegexBuilder -: -: -size_limit +usize ) -. -Even -/ -/ -/ -when -not -configured -explicitly -it -defaults -to -a -reasonable -limit -. -/ -/ -/ / / / -If -you -' -re -getting -this -error -it -occurred -because -your -regex -has -been -/ -/ -/ -compiled -to -an -intermediate -state +Hints that -is -too -big +destructuring +should +not +be +exhaustive . -It -is -important -to / / / -note -that -exceeding -this -limit -does -_not_ -mean -the -regex -is -too -big -to / / / -_work_ -but -rather -the -regex -is -big -enough -that -it +This +enum may -wind -up -being -/ -/ -/ -surprisingly -slow -when -used -in -a -search -. -In -other -words -this -error -is -/ -/ -/ -meant -to -be -a -practical -heuristic -for -avoiding -a -performance -footgun -/ -/ -/ -and -especially +grow +additional +variants so -for -the -case -where -the -regex -pattern -is -coming -from -/ -/ -/ -an -untrusted -source -. -/ -/ -/ -/ -/ -/ -There -are -generally -two -ways -to -move -forward -if -you -hit this -error -. -/ +makes +sure +clients / / -The -first -is -to -find -some -way -to -use -a -smaller -regex -. -The -second -is -to -/ / -/ -increase -the -size -limit -via -RegexBuilder -: -: -size_limit -. -However -if -/ -/ -/ -your -regex -pattern -is -not -from -a -trusted -source -then -neither -of -these -/ -/ -/ -approaches -may -be -appropriate -. -Instead -you +don ' -ll -have -to -determine -just -/ -/ -/ -how -big -of -a -regex -you -want -to -allow -. -CompiledTooBig -( -usize -) -} -impl -Error -{ -pub -( -crate -) -fn -from_meta_build_error -( -err -: -meta -: -: -BuildError -) -- -> -Error -{ -if -let -Some -( -size_limit -) -= -err -. -size_limit -( -) -{ -Error -: -: -CompiledTooBig -( -size_limit -) -} -else -if -let -Some -( -ref -err -) -= -err -. -syntax_error -( -) -{ -Error -: -: -Syntax -( -err +t +count +on +exhaustive +matching . -to_string ( -) -) -} -else -{ -/ -/ -This -is -a -little -suspect -. -Technically -there -are -more -ways -for -/ -/ -a -meta -regex -to -fail -to -build -other -than -" -exceeded -size -limit -" -/ -/ -and -" -syntax -error -. -" -For -example -if -there -are -too -many -states -/ -/ -or -even -too -many -patterns -. -But -in -practice -this -is -probably -/ -/ -good -enough -. -The -worst -thing -that -happens -is -that -Error -: -: -Syntax -/ -/ -represents -an -error -that -isn -' -t -technically +Otherwise +adding a -syntax -error -but -/ -/ -the -actual -message -will -still -be -shown -. -So -. -. -. -it -' -s -not -too -bad -. -/ -/ -/ +new +variant / -We -really -should -have -made -the -Error -type -in -the -regex -crate / / -completely -opaque -. -Rookie -mistake -. -Error -: -: -Syntax -( -err +could +break +existing +code . -to_string -( ) -) -} -} -} # [ -cfg +doc ( -feature -= -" -std -" +hidden ) ] +__Nonexhaustive +} impl +: +: std : : @@ -650,13 +217,20 @@ program too big " +Error +: +: +__Nonexhaustive += +> +unreachable +! +( +) } } } impl -core -: -: fmt : : @@ -673,9 +247,6 @@ f : & mut -core -: -: fmt : : @@ -687,9 +258,6 @@ _ ) - > -core -: -: fmt : : @@ -742,6 +310,16 @@ bytes " limit ) +Error +: +: +__Nonexhaustive += +> +unreachable +! +( +) } } } @@ -809,9 +387,6 @@ it nicely . impl -core -: -: fmt : : @@ -828,9 +403,6 @@ f : & mut -core -: -: fmt : : @@ -842,9 +414,6 @@ _ ) - > -core -: -: fmt : : @@ -870,12 +439,6 @@ hr : String = -core -: -: -iter -: -: repeat ( ' @@ -984,6 +547,26 @@ finish ( ) } +Error +: +: +__Nonexhaustive += +> +{ +f +. +debug_tuple +( +" +__Nonexhaustive +" +) +. +finish +( +) +} } } } diff --git a/third_party/rust/regex/src/exec.rs b/third_party/rust/regex/src/exec.rs new file mode 100644 index 0000000000000..e2d0b6d319e59 --- /dev/null +++ b/third_party/rust/regex/src/exec.rs @@ -0,0 +1,12111 @@ +use +std +: +: +cell +: +: +RefCell +; +use +std +: +: +collections +: +: +HashMap +; +use +std +: +: +panic +: +: +AssertUnwindSafe +; +use +std +: +: +sync +: +: +Arc +; +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +use +aho_corasick +: +: +{ +AhoCorasick +AhoCorasickBuilder +MatchKind +} +; +use +regex_syntax +: +: +hir +: +: +literal +: +: +Literals +; +use +regex_syntax +: +: +hir +: +: +Hir +; +use +regex_syntax +: +: +ParserBuilder +; +use +crate +: +: +backtrack +; +use +crate +: +: +compile +: +: +Compiler +; +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +use +crate +: +: +dfa +; +use +crate +: +: +error +: +: +Error +; +use +crate +: +: +input +: +: +{ +ByteInput +CharInput +} +; +use +crate +: +: +literal +: +: +LiteralSearcher +; +use +crate +: +: +pikevm +; +use +crate +: +: +pool +: +: +{ +Pool +PoolGuard +} +; +use +crate +: +: +prog +: +: +Program +; +use +crate +: +: +re_builder +: +: +RegexOptions +; +use +crate +: +: +re_bytes +; +use +crate +: +: +re_set +; +use +crate +: +: +re_trait +: +: +{ +Locations +RegularExpression +Slot +} +; +use +crate +: +: +re_unicode +; +use +crate +: +: +utf8 +: +: +next_utf8 +; +/ +/ +/ +Exec +manages +the +execution +of +a +regular +expression +. +/ +/ +/ +/ +/ +/ +In +particular +this +manages +the +various +compiled +forms +of +a +single +regular +/ +/ +/ +expression +and +the +choice +of +which +matching +engine +to +use +to +execute +a +/ +/ +/ +regular +expression +. +# +[ +derive +( +Debug +) +] +pub +struct +Exec +{ +/ +/ +/ +All +read +only +state +. +ro +: +Arc +< +ExecReadOnly +> +/ +/ +/ +A +pool +of +reusable +values +for +the +various +matching +engines +. +/ +/ +/ +/ +/ +/ +Note +that +boxing +this +value +is +not +strictly +necessary +but +it +is +an +/ +/ +/ +easy +way +to +ensure +that +T +does +not +bloat +the +stack +sized +used +by +a +pool +/ +/ +/ +in +the +case +where +T +is +big +. +And +this +turns +out +to +be +the +case +at +the +/ +/ +/ +time +of +writing +for +regex +' +s +use +of +this +pool +. +At +the +time +of +writing +/ +/ +/ +the +size +of +a +Regex +on +the +stack +is +856 +bytes +. +Boxing +this +value +/ +/ +/ +reduces +that +size +to +16 +bytes +. +pool +: +Box +< +Pool +< +ProgramCache +> +> +} +/ +/ +/ +ExecNoSync +is +like +Exec +except +it +embeds +a +reference +to +a +cache +. +This +/ +/ +/ +means +it +is +no +longer +Sync +but +we +can +now +avoid +the +overhead +of +/ +/ +/ +synchronization +to +fetch +the +cache +. +# +[ +derive +( +Debug +) +] +pub +struct +ExecNoSync +< +' +c +> +{ +/ +/ +/ +All +read +only +state +. +ro +: +& +' +c +Arc +< +ExecReadOnly +> +/ +/ +/ +Caches +for +the +various +matching +engines +. +cache +: +PoolGuard +< +' +c +ProgramCache +> +} +/ +/ +/ +ExecNoSyncStr +is +like +ExecNoSync +but +matches +on +& +str +instead +of +& +[ +u8 +] +. +# +[ +derive +( +Debug +) +] +pub +struct +ExecNoSyncStr +< +' +c +> +( +ExecNoSync +< +' +c +> +) +; +/ +/ +/ +ExecReadOnly +comprises +all +read +only +state +for +a +regex +. +Namely +all +such +/ +/ +/ +state +is +determined +at +compile +time +and +never +changes +during +search +. +# +[ +derive +( +Debug +) +] +struct +ExecReadOnly +{ +/ +/ +/ +The +original +regular +expressions +given +by +the +caller +to +compile +. +res +: +Vec +< +String +> +/ +/ +/ +A +compiled +program +that +is +used +in +the +NFA +simulation +and +backtracking +. +/ +/ +/ +It +can +be +byte +- +based +or +Unicode +codepoint +based +. +/ +/ +/ +/ +/ +/ +N +. +B +. +It +is +not +possibly +to +make +this +byte +- +based +from +the +public +API +. +/ +/ +/ +It +is +only +used +for +testing +byte +based +programs +in +the +NFA +simulations +. +nfa +: +Program +/ +/ +/ +A +compiled +byte +based +program +for +DFA +execution +. +This +is +only +used +/ +/ +/ +if +a +DFA +can +be +executed +. +( +Currently +only +word +boundary +assertions +are +/ +/ +/ +not +supported +. +) +Note +that +this +program +contains +an +embedded +. +* +? +/ +/ +/ +preceding +the +first +capture +group +unless +the +regex +is +anchored +at +the +/ +/ +/ +beginning +. +dfa +: +Program +/ +/ +/ +The +same +as +above +except +the +program +is +reversed +( +and +there +is +no +/ +/ +/ +preceding +. +* +? +) +. +This +is +used +by +the +DFA +to +find +the +starting +location +/ +/ +/ +of +matches +. +dfa_reverse +: +Program +/ +/ +/ +A +set +of +suffix +literals +extracted +from +the +regex +. +/ +/ +/ +/ +/ +/ +Prefix +literals +are +stored +on +the +Program +since +they +are +used +inside +/ +/ +/ +the +matching +engines +. +suffixes +: +LiteralSearcher +/ +/ +/ +An +Aho +- +Corasick +automaton +with +leftmost +- +first +match +semantics +. +/ +/ +/ +/ +/ +/ +This +is +only +set +when +the +entire +regex +is +a +simple +unanchored +/ +/ +/ +alternation +of +literals +. +We +could +probably +use +it +more +circumstances +/ +/ +/ +but +this +is +already +hacky +enough +in +this +architecture +. +/ +/ +/ +/ +/ +/ +N +. +B +. +We +use +u32 +as +a +state +ID +representation +under +the +assumption +that +/ +/ +/ +if +we +were +to +exhaust +the +ID +space +we +probably +would +have +long +/ +/ +/ +surpassed +the +compilation +size +limit +. +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +ac +: +Option +< +AhoCorasick +< +u32 +> +> +/ +/ +/ +match_type +encodes +as +much +upfront +knowledge +about +how +we +' +re +going +to +/ +/ +/ +execute +a +search +as +possible +. +match_type +: +MatchType +} +/ +/ +/ +Facilitates +the +construction +of +an +executor +by +exposing +various +knobs +/ +/ +/ +to +control +how +a +regex +is +executed +and +what +kinds +of +resources +it +' +s +/ +/ +/ +permitted +to +use +. +/ +/ +ExecBuilder +is +only +public +via +the +internal +module +so +avoid +deriving +/ +/ +Debug +. +# +[ +allow +( +missing_debug_implementations +) +] +pub +struct +ExecBuilder +{ +options +: +RegexOptions +match_type +: +Option +< +MatchType +> +bytes +: +bool +only_utf8 +: +bool +} +/ +/ +/ +Parsed +represents +a +set +of +parsed +regular +expressions +and +their +detected +/ +/ +/ +literals +. +struct +Parsed +{ +exprs +: +Vec +< +Hir +> +prefixes +: +Literals +suffixes +: +Literals +bytes +: +bool +} +impl +ExecBuilder +{ +/ +/ +/ +Create +a +regex +execution +builder +. +/ +/ +/ +/ +/ +/ +This +uses +default +settings +for +everything +except +the +regex +itself +/ +/ +/ +which +must +be +provided +. +Further +knobs +can +be +set +by +calling +methods +/ +/ +/ +and +then +finally +build +to +actually +create +the +executor +. +pub +fn +new +( +re +: +& +str +) +- +> +Self +{ +Self +: +: +new_many +( +& +[ +re +] +) +} +/ +/ +/ +Like +new +but +compiles +the +union +of +the +given +regular +expressions +. +/ +/ +/ +/ +/ +/ +Note +that +when +compiling +2 +or +more +regular +expressions +capture +groups +/ +/ +/ +are +completely +unsupported +. +( +This +means +both +find +and +captures +/ +/ +/ +won +' +t +work +. +) +pub +fn +new_many +< +I +S +> +( +res +: +I +) +- +> +Self +where +S +: +AsRef +< +str +> +I +: +IntoIterator +< +Item += +S +> +{ +let +mut +opts += +RegexOptions +: +: +default +( +) +; +opts +. +pats += +res +. +into_iter +( +) +. +map +( +| +s +| +s +. +as_ref +( +) +. +to_owned +( +) +) +. +collect +( +) +; +Self +: +: +new_options +( +opts +) +} +/ +/ +/ +Create +a +regex +execution +builder +. +pub +fn +new_options +( +opts +: +RegexOptions +) +- +> +Self +{ +ExecBuilder +{ +options +: +opts +match_type +: +None +bytes +: +false +only_utf8 +: +true +} +} +/ +/ +/ +Set +the +matching +engine +to +be +automatically +determined +. +/ +/ +/ +/ +/ +/ +This +is +the +default +state +and +will +apply +whatever +optimizations +are +/ +/ +/ +possible +such +as +running +a +DFA +. +/ +/ +/ +/ +/ +/ +This +overrides +whatever +was +previously +set +via +the +nfa +or +/ +/ +/ +bounded_backtracking +methods +. +pub +fn +automatic +( +mut +self +) +- +> +Self +{ +self +. +match_type += +None +; +self +} +/ +/ +/ +Sets +the +matching +engine +to +use +the +NFA +algorithm +no +matter +what +/ +/ +/ +optimizations +are +possible +. +/ +/ +/ +/ +/ +/ +This +overrides +whatever +was +previously +set +via +the +automatic +or +/ +/ +/ +bounded_backtracking +methods +. +pub +fn +nfa +( +mut +self +) +- +> +Self +{ +self +. +match_type += +Some +( +MatchType +: +: +Nfa +( +MatchNfaType +: +: +PikeVM +) +) +; +self +} +/ +/ +/ +Sets +the +matching +engine +to +use +a +bounded +backtracking +engine +no +/ +/ +/ +matter +what +optimizations +are +possible +. +/ +/ +/ +/ +/ +/ +One +must +use +this +with +care +since +the +bounded +backtracking +engine +/ +/ +/ +uses +memory +proportion +to +len +( +regex +) +* +len +( +text +) +. +/ +/ +/ +/ +/ +/ +This +overrides +whatever +was +previously +set +via +the +automatic +or +/ +/ +/ +nfa +methods +. +pub +fn +bounded_backtracking +( +mut +self +) +- +> +Self +{ +self +. +match_type += +Some +( +MatchType +: +: +Nfa +( +MatchNfaType +: +: +Backtrack +) +) +; +self +} +/ +/ +/ +Compiles +byte +based +programs +for +use +with +the +NFA +matching +engines +. +/ +/ +/ +/ +/ +/ +By +default +the +NFA +engines +match +on +Unicode +scalar +values +. +They +can +/ +/ +/ +be +made +to +use +byte +based +programs +instead +. +In +general +the +byte +based +/ +/ +/ +programs +are +slower +because +of +a +less +efficient +encoding +of +character +/ +/ +/ +classes +. +/ +/ +/ +/ +/ +/ +Note +that +this +does +not +impact +DFA +matching +engines +which +always +/ +/ +/ +execute +on +bytes +. +pub +fn +bytes +( +mut +self +yes +: +bool +) +- +> +Self +{ +self +. +bytes += +yes +; +self +} +/ +/ +/ +When +disabled +the +program +compiled +may +match +arbitrary +bytes +. +/ +/ +/ +/ +/ +/ +When +enabled +( +the +default +) +all +compiled +programs +exclusively +match +/ +/ +/ +valid +UTF +- +8 +bytes +. +pub +fn +only_utf8 +( +mut +self +yes +: +bool +) +- +> +Self +{ +self +. +only_utf8 += +yes +; +self +} +/ +/ +/ +Set +the +Unicode +flag +. +pub +fn +unicode +( +mut +self +yes +: +bool +) +- +> +Self +{ +self +. +options +. +unicode += +yes +; +self +} +/ +/ +/ +Parse +the +current +set +of +patterns +into +their +AST +and +extract +literals +. +fn +parse +( +& +self +) +- +> +Result +< +Parsed +Error +> +{ +let +mut +exprs += +Vec +: +: +with_capacity +( +self +. +options +. +pats +. +len +( +) +) +; +let +mut +prefixes += +Some +( +Literals +: +: +empty +( +) +) +; +let +mut +suffixes += +Some +( +Literals +: +: +empty +( +) +) +; +let +mut +bytes += +false +; +let +is_set += +self +. +options +. +pats +. +len +( +) +> +1 +; +/ +/ +If +we +' +re +compiling +a +regex +set +and +that +set +has +any +anchored +/ +/ +expressions +then +disable +all +literal +optimizations +. +for +pat +in +& +self +. +options +. +pats +{ +let +mut +parser += +ParserBuilder +: +: +new +( +) +. +octal +( +self +. +options +. +octal +) +. +case_insensitive +( +self +. +options +. +case_insensitive +) +. +multi_line +( +self +. +options +. +multi_line +) +. +dot_matches_new_line +( +self +. +options +. +dot_matches_new_line +) +. +swap_greed +( +self +. +options +. +swap_greed +) +. +ignore_whitespace +( +self +. +options +. +ignore_whitespace +) +. +unicode +( +self +. +options +. +unicode +) +. +allow_invalid_utf8 +( +! +self +. +only_utf8 +) +. +nest_limit +( +self +. +options +. +nest_limit +) +. +build +( +) +; +let +expr += +parser +. +parse +( +pat +) +. +map_err +( +| +e +| +Error +: +: +Syntax +( +e +. +to_string +( +) +) +) +? +; +bytes += +bytes +| +| +! +expr +. +is_always_utf8 +( +) +; +if +cfg +! +( +feature += +" +perf +- +literal +" +) +{ +if +! +expr +. +is_anchored_start +( +) +& +& +expr +. +is_any_anchored_start +( +) +{ +/ +/ +Partial +anchors +unfortunately +make +it +hard +to +use +/ +/ +prefixes +so +disable +them +. +prefixes += +None +; +} +else +if +is_set +& +& +expr +. +is_anchored_start +( +) +{ +/ +/ +Regex +sets +with +anchors +do +not +go +well +with +literal +/ +/ +optimizations +. +prefixes += +None +; +} +prefixes += +prefixes +. +and_then +( +| +mut +prefixes +| +{ +if +! +prefixes +. +union_prefixes +( +& +expr +) +{ +None +} +else +{ +Some +( +prefixes +) +} +} +) +; +if +! +expr +. +is_anchored_end +( +) +& +& +expr +. +is_any_anchored_end +( +) +{ +/ +/ +Partial +anchors +unfortunately +make +it +hard +to +use +/ +/ +suffixes +so +disable +them +. +suffixes += +None +; +} +else +if +is_set +& +& +expr +. +is_anchored_end +( +) +{ +/ +/ +Regex +sets +with +anchors +do +not +go +well +with +literal +/ +/ +optimizations +. +suffixes += +None +; +} +suffixes += +suffixes +. +and_then +( +| +mut +suffixes +| +{ +if +! +suffixes +. +union_suffixes +( +& +expr +) +{ +None +} +else +{ +Some +( +suffixes +) +} +} +) +; +} +exprs +. +push +( +expr +) +; +} +Ok +( +Parsed +{ +exprs +prefixes +: +prefixes +. +unwrap_or_else +( +Literals +: +: +empty +) +suffixes +: +suffixes +. +unwrap_or_else +( +Literals +: +: +empty +) +bytes +} +) +} +/ +/ +/ +Build +an +executor +that +can +run +a +regular +expression +. +pub +fn +build +( +self +) +- +> +Result +< +Exec +Error +> +{ +/ +/ +Special +case +when +we +have +no +patterns +to +compile +. +/ +/ +This +can +happen +when +compiling +a +regex +set +. +if +self +. +options +. +pats +. +is_empty +( +) +{ +let +ro += +Arc +: +: +new +( +ExecReadOnly +{ +res +: +vec +! +[ +] +nfa +: +Program +: +: +new +( +) +dfa +: +Program +: +: +new +( +) +dfa_reverse +: +Program +: +: +new +( +) +suffixes +: +LiteralSearcher +: +: +empty +( +) +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +ac +: +None +match_type +: +MatchType +: +: +Nothing +} +) +; +let +pool += +ExecReadOnly +: +: +new_pool +( +& +ro +) +; +return +Ok +( +Exec +{ +ro +pool +} +) +; +} +let +parsed += +self +. +parse +( +) +? +; +let +mut +nfa += +Compiler +: +: +new +( +) +. +size_limit +( +self +. +options +. +size_limit +) +. +bytes +( +self +. +bytes +| +| +parsed +. +bytes +) +. +only_utf8 +( +self +. +only_utf8 +) +. +compile +( +& +parsed +. +exprs +) +? +; +let +mut +dfa += +Compiler +: +: +new +( +) +. +size_limit +( +self +. +options +. +size_limit +) +. +dfa +( +true +) +. +only_utf8 +( +self +. +only_utf8 +) +. +compile +( +& +parsed +. +exprs +) +? +; +let +mut +dfa_reverse += +Compiler +: +: +new +( +) +. +size_limit +( +self +. +options +. +size_limit +) +. +dfa +( +true +) +. +only_utf8 +( +self +. +only_utf8 +) +. +reverse +( +true +) +. +compile +( +& +parsed +. +exprs +) +? +; +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +let +ac += +self +. +build_aho_corasick +( +& +parsed +) +; +nfa +. +prefixes += +LiteralSearcher +: +: +prefixes +( +parsed +. +prefixes +) +; +dfa +. +prefixes += +nfa +. +prefixes +. +clone +( +) +; +dfa +. +dfa_size_limit += +self +. +options +. +dfa_size_limit +; +dfa_reverse +. +dfa_size_limit += +self +. +options +. +dfa_size_limit +; +let +mut +ro += +ExecReadOnly +{ +res +: +self +. +options +. +pats +nfa +dfa +dfa_reverse +suffixes +: +LiteralSearcher +: +: +suffixes +( +parsed +. +suffixes +) +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +ac +match_type +: +MatchType +: +: +Nothing +} +; +ro +. +match_type += +ro +. +choose_match_type +( +self +. +match_type +) +; +let +ro += +Arc +: +: +new +( +ro +) +; +let +pool += +ExecReadOnly +: +: +new_pool +( +& +ro +) +; +Ok +( +Exec +{ +ro +pool +} +) +} +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +fn +build_aho_corasick +( +& +self +parsed +: +& +Parsed +) +- +> +Option +< +AhoCorasick +< +u32 +> +> +{ +if +parsed +. +exprs +. +len +( +) +! += +1 +{ +return +None +; +} +let +lits += +match +alternation_literals +( +& +parsed +. +exprs +[ +0 +] +) +{ +None += +> +return +None +Some +( +lits +) += +> +lits +} +; +/ +/ +If +we +have +a +small +number +of +literals +then +let +Teddy +handle +/ +/ +things +( +see +literal +/ +mod +. +rs +) +. +if +lits +. +len +( +) +< += +32 +{ +return +None +; +} +Some +( +AhoCorasickBuilder +: +: +new +( +) +. +match_kind +( +MatchKind +: +: +LeftmostFirst +) +. +auto_configure +( +& +lits +) +. +build_with_size +: +: +< +u32 +_ +_ +> +( +& +lits +) +/ +/ +This +should +never +happen +because +we +' +d +long +exceed +the +/ +/ +compilation +limit +for +regexes +first +. +. +expect +( +" +AC +automaton +too +big +" +) +) +} +} +impl +< +' +c +> +RegularExpression +for +ExecNoSyncStr +< +' +c +> +{ +type +Text += +str +; +fn +slots_len +( +& +self +) +- +> +usize +{ +self +. +0 +. +slots_len +( +) +} +fn +next_after_empty +( +& +self +text +: +& +str +i +: +usize +) +- +> +usize +{ +next_utf8 +( +text +. +as_bytes +( +) +i +) +} +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +shortest_match_at +( +& +self +text +: +& +str +start +: +usize +) +- +> +Option +< +usize +> +{ +self +. +0 +. +shortest_match_at +( +text +. +as_bytes +( +) +start +) +} +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +is_match_at +( +& +self +text +: +& +str +start +: +usize +) +- +> +bool +{ +self +. +0 +. +is_match_at +( +text +. +as_bytes +( +) +start +) +} +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +find_at +( +& +self +text +: +& +str +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +self +. +0 +. +find_at +( +text +. +as_bytes +( +) +start +) +} +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +captures_read_at +( +& +self +locs +: +& +mut +Locations +text +: +& +str +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +self +. +0 +. +captures_read_at +( +locs +text +. +as_bytes +( +) +start +) +} +} +impl +< +' +c +> +RegularExpression +for +ExecNoSync +< +' +c +> +{ +type +Text += +[ +u8 +] +; +/ +/ +/ +Returns +the +number +of +capture +slots +in +the +regular +expression +. +( +There +/ +/ +/ +are +two +slots +for +every +capture +group +corresponding +to +possibly +empty +/ +/ +/ +start +and +end +locations +of +the +capture +. +) +fn +slots_len +( +& +self +) +- +> +usize +{ +self +. +ro +. +nfa +. +captures +. +len +( +) +* +2 +} +fn +next_after_empty +( +& +self +_text +: +& +[ +u8 +] +i +: +usize +) +- +> +usize +{ +i ++ +1 +} +/ +/ +/ +Returns +the +end +of +a +match +location +possibly +occurring +before +the +/ +/ +/ +end +location +of +the +correct +leftmost +- +first +match +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +shortest_match_at +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +usize +> +{ +if +! +self +. +is_anchor_end_match +( +text +) +{ +return +None +; +} +match +self +. +ro +. +match_type +{ +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +MatchType +: +: +Literal +( +ty +) += +> +{ +self +. +find_literals +( +ty +text +start +) +. +map +( +| +( +_ +e +) +| +e +) +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +Dfa +| +MatchType +: +: +DfaMany += +> +{ +match +self +. +shortest_dfa +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +end +) += +> +Some +( +end +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +self +. +shortest_nfa +( +text +start +) +} +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +DfaAnchoredReverse += +> +{ +match +dfa +: +: +Fsm +: +: +reverse +( +& +self +. +ro +. +dfa_reverse +self +. +cache +. +value +( +) +true +& +text +[ +start +. +. +] +text +. +len +( +) +) +{ +dfa +: +: +Result +: +: +Match +( +_ +) += +> +Some +( +text +. +len +( +) +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +self +. +shortest_nfa +( +text +start +) +} +} +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +MatchType +: +: +DfaSuffix += +> +{ +match +self +. +shortest_dfa_reverse_suffix +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +e +) += +> +Some +( +e +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +self +. +shortest_nfa +( +text +start +) +} +} +MatchType +: +: +Nfa +( +ty +) += +> +self +. +shortest_nfa_type +( +ty +text +start +) +MatchType +: +: +Nothing += +> +None +} +} +/ +/ +/ +Returns +true +if +and +only +if +the +regex +matches +text +. +/ +/ +/ +/ +/ +/ +For +single +regular +expressions +this +is +equivalent +to +calling +/ +/ +/ +shortest_match +( +. +. +. +) +. +is_some +( +) +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +is_match_at +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +bool +{ +if +! +self +. +is_anchor_end_match +( +text +) +{ +return +false +; +} +/ +/ +We +need +to +do +this +dance +because +shortest_match +relies +on +the +NFA +/ +/ +filling +in +captures +[ +1 +] +but +a +RegexSet +has +no +captures +. +In +other +/ +/ +words +a +RegexSet +can +' +t +( +currently +) +use +shortest_match +. +- +- +- +AG +match +self +. +ro +. +match_type +{ +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +MatchType +: +: +Literal +( +ty +) += +> +{ +self +. +find_literals +( +ty +text +start +) +. +is_some +( +) +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +Dfa +| +MatchType +: +: +DfaMany += +> +{ +match +self +. +shortest_dfa +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +_ +) += +> +true +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +false +dfa +: +: +Result +: +: +Quit += +> +self +. +match_nfa +( +text +start +) +} +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +DfaAnchoredReverse += +> +{ +match +dfa +: +: +Fsm +: +: +reverse +( +& +self +. +ro +. +dfa_reverse +self +. +cache +. +value +( +) +true +& +text +[ +start +. +. +] +text +. +len +( +) +) +{ +dfa +: +: +Result +: +: +Match +( +_ +) += +> +true +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +false +dfa +: +: +Result +: +: +Quit += +> +self +. +match_nfa +( +text +start +) +} +} +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +MatchType +: +: +DfaSuffix += +> +{ +match +self +. +shortest_dfa_reverse_suffix +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +_ +) += +> +true +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +false +dfa +: +: +Result +: +: +Quit += +> +self +. +match_nfa +( +text +start +) +} +} +MatchType +: +: +Nfa +( +ty +) += +> +self +. +match_nfa_type +( +ty +text +start +) +MatchType +: +: +Nothing += +> +false +} +} +/ +/ +/ +Finds +the +start +and +end +location +of +the +leftmost +- +first +match +starting +/ +/ +/ +at +the +given +location +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +find_at +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +if +! +self +. +is_anchor_end_match +( +text +) +{ +return +None +; +} +match +self +. +ro +. +match_type +{ +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +MatchType +: +: +Literal +( +ty +) += +> +self +. +find_literals +( +ty +text +start +) +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +Dfa += +> +match +self +. +find_dfa_forward +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +( +s +e +) +) += +> +Some +( +( +s +e +) +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +{ +self +. +find_nfa +( +MatchNfaType +: +: +Auto +text +start +) +} +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +DfaAnchoredReverse += +> +{ +match +self +. +find_dfa_anchored_reverse +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +( +s +e +) +) += +> +Some +( +( +s +e +) +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +{ +self +. +find_nfa +( +MatchNfaType +: +: +Auto +text +start +) +} +} +} +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +MatchType +: +: +DfaSuffix += +> +{ +match +self +. +find_dfa_reverse_suffix +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +( +s +e +) +) += +> +Some +( +( +s +e +) +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +{ +self +. +find_nfa +( +MatchNfaType +: +: +Auto +text +start +) +} +} +} +MatchType +: +: +Nfa +( +ty +) += +> +self +. +find_nfa +( +ty +text +start +) +MatchType +: +: +Nothing += +> +None +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +DfaMany += +> +{ +unreachable +! +( +" +BUG +: +RegexSet +cannot +be +used +with +find +" +) +} +} +} +/ +/ +/ +Finds +the +start +and +end +location +of +the +leftmost +- +first +match +and +also +/ +/ +/ +fills +in +all +matching +capture +groups +. +/ +/ +/ +/ +/ +/ +The +number +of +capture +slots +given +should +be +equal +to +the +total +number +/ +/ +/ +of +capture +slots +in +the +compiled +program +. +/ +/ +/ +/ +/ +/ +Note +that +the +first +two +slots +always +correspond +to +the +start +and +end +/ +/ +/ +locations +of +the +overall +match +. +fn +captures_read_at +( +& +self +locs +: +& +mut +Locations +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +let +slots += +locs +. +as_slots +( +) +; +for +slot +in +slots +. +iter_mut +( +) +{ +* +slot += +None +; +} +/ +/ +If +the +caller +unnecessarily +uses +this +then +we +try +to +save +them +/ +/ +from +themselves +. +match +slots +. +len +( +) +{ +0 += +> +return +self +. +find_at +( +text +start +) +2 += +> +{ +return +self +. +find_at +( +text +start +) +. +map +( +| +( +s +e +) +| +{ +slots +[ +0 +] += +Some +( +s +) +; +slots +[ +1 +] += +Some +( +e +) +; +( +s +e +) +} +) +; +} +_ += +> +{ +} +/ +/ +fallthrough +} +if +! +self +. +is_anchor_end_match +( +text +) +{ +return +None +; +} +match +self +. +ro +. +match_type +{ +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +MatchType +: +: +Literal +( +ty +) += +> +{ +self +. +find_literals +( +ty +text +start +) +. +and_then +( +| +( +s +e +) +| +{ +self +. +captures_nfa_type +( +MatchNfaType +: +: +Auto +slots +text +s +e +) +} +) +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +Dfa += +> +{ +if +self +. +ro +. +nfa +. +is_anchored_start +{ +self +. +captures_nfa +( +slots +text +start +) +} +else +{ +match +self +. +find_dfa_forward +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +( +s +e +) +) += +> +self +. +captures_nfa_type +( +MatchNfaType +: +: +Auto +slots +text +s +e +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +{ +self +. +captures_nfa +( +slots +text +start +) +} +} +} +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +DfaAnchoredReverse += +> +{ +match +self +. +find_dfa_anchored_reverse +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +( +s +e +) +) += +> +self +. +captures_nfa_type +( +MatchNfaType +: +: +Auto +slots +text +s +e +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +self +. +captures_nfa +( +slots +text +start +) +} +} +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +MatchType +: +: +DfaSuffix += +> +{ +match +self +. +find_dfa_reverse_suffix +( +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +( +s +e +) +) += +> +self +. +captures_nfa_type +( +MatchNfaType +: +: +Auto +slots +text +s +e +) +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +None +dfa +: +: +Result +: +: +Quit += +> +self +. +captures_nfa +( +slots +text +start +) +} +} +MatchType +: +: +Nfa +( +ty +) += +> +{ +self +. +captures_nfa_type +( +ty +slots +text +start +text +. +len +( +) +) +} +MatchType +: +: +Nothing += +> +None +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +MatchType +: +: +DfaMany += +> +{ +unreachable +! +( +" +BUG +: +RegexSet +cannot +be +used +with +captures +" +) +} +} +} +} +impl +< +' +c +> +ExecNoSync +< +' +c +> +{ +/ +/ +/ +Finds +the +leftmost +- +first +match +using +only +literal +search +. +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +find_literals +( +& +self +ty +: +MatchLiteralType +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +use +self +: +: +MatchLiteralType +: +: +* +; +match +ty +{ +Unanchored += +> +{ +let +lits += +& +self +. +ro +. +nfa +. +prefixes +; +lits +. +find +( +& +text +[ +start +. +. +] +) +. +map +( +| +( +s +e +) +| +( +start ++ +s +start ++ +e +) +) +} +AnchoredStart += +> +{ +let +lits += +& +self +. +ro +. +nfa +. +prefixes +; +if +start += += +0 +| +| +! +self +. +ro +. +nfa +. +is_anchored_start +{ +lits +. +find_start +( +& +text +[ +start +. +. +] +) +. +map +( +| +( +s +e +) +| +( +start ++ +s +start ++ +e +) +) +} +else +{ +None +} +} +AnchoredEnd += +> +{ +let +lits += +& +self +. +ro +. +suffixes +; +lits +. +find_end +( +& +text +[ +start +. +. +] +) +. +map +( +| +( +s +e +) +| +( +start ++ +s +start ++ +e +) +) +} +AhoCorasick += +> +self +. +ro +. +ac +. +as_ref +( +) +. +unwrap +( +) +. +find +( +& +text +[ +start +. +. +] +) +. +map +( +| +m +| +( +start ++ +m +. +start +( +) +start ++ +m +. +end +( +) +) +) +} +} +/ +/ +/ +Finds +the +leftmost +- +first +match +( +start +and +end +) +using +only +the +DFA +. +/ +/ +/ +/ +/ +/ +If +the +result +returned +indicates +that +the +DFA +quit +then +another +/ +/ +/ +matching +engine +should +be +used +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +find_dfa_forward +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +dfa +: +: +Result +< +( +usize +usize +) +> +{ +use +crate +: +: +dfa +: +: +Result +: +: +* +; +let +end += +match +dfa +: +: +Fsm +: +: +forward +( +& +self +. +ro +. +dfa +self +. +cache +. +value +( +) +false +text +start +) +{ +NoMatch +( +i +) += +> +return +NoMatch +( +i +) +Quit += +> +return +Quit +Match +( +end +) +if +start += += +end += +> +return +Match +( +( +start +start +) +) +Match +( +end +) += +> +end +} +; +/ +/ +Now +run +the +DFA +in +reverse +to +find +the +start +of +the +match +. +match +dfa +: +: +Fsm +: +: +reverse +( +& +self +. +ro +. +dfa_reverse +self +. +cache +. +value +( +) +false +& +text +[ +start +. +. +] +end +- +start +) +{ +Match +( +s +) += +> +Match +( +( +start ++ +s +end +) +) +NoMatch +( +i +) += +> +NoMatch +( +i +) +Quit += +> +Quit +} +} +/ +/ +/ +Finds +the +leftmost +- +first +match +( +start +and +end +) +using +only +the +DFA +/ +/ +/ +but +assumes +the +regex +is +anchored +at +the +end +and +therefore +starts +at +/ +/ +/ +the +end +of +the +regex +and +matches +in +reverse +. +/ +/ +/ +/ +/ +/ +If +the +result +returned +indicates +that +the +DFA +quit +then +another +/ +/ +/ +matching +engine +should +be +used +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +find_dfa_anchored_reverse +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +dfa +: +: +Result +< +( +usize +usize +) +> +{ +use +crate +: +: +dfa +: +: +Result +: +: +* +; +match +dfa +: +: +Fsm +: +: +reverse +( +& +self +. +ro +. +dfa_reverse +self +. +cache +. +value +( +) +false +& +text +[ +start +. +. +] +text +. +len +( +) +- +start +) +{ +Match +( +s +) += +> +Match +( +( +start ++ +s +text +. +len +( +) +) +) +NoMatch +( +i +) += +> +NoMatch +( +i +) +Quit += +> +Quit +} +} +/ +/ +/ +Finds +the +end +of +the +shortest +match +using +only +the +DFA +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +shortest_dfa +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +dfa +: +: +Result +< +usize +> +{ +dfa +: +: +Fsm +: +: +forward +( +& +self +. +ro +. +dfa +self +. +cache +. +value +( +) +true +text +start +) +} +/ +/ +/ +Finds +the +end +of +the +shortest +match +using +only +the +DFA +by +scanning +for +/ +/ +/ +suffix +literals +. +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +shortest_dfa_reverse_suffix +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +dfa +: +: +Result +< +usize +> +{ +match +self +. +exec_dfa_reverse_suffix +( +text +start +) +{ +None += +> +self +. +shortest_dfa +( +text +start +) +Some +( +r +) += +> +r +. +map +( +| +( +_ +end +) +| +end +) +} +} +/ +/ +/ +Finds +the +end +of +the +shortest +match +using +only +the +DFA +by +scanning +for +/ +/ +/ +suffix +literals +. +It +also +reports +the +start +of +the +match +. +/ +/ +/ +/ +/ +/ +Note +that +if +None +is +returned +then +the +optimization +gave +up +to +avoid +/ +/ +/ +worst +case +quadratic +behavior +. +A +forward +scanning +DFA +should +be +tried +/ +/ +/ +next +. +/ +/ +/ +/ +/ +/ +If +a +match +is +returned +and +the +full +leftmost +- +first +match +is +desired +/ +/ +/ +then +a +forward +scan +starting +from +the +beginning +of +the +match +must +be +/ +/ +/ +done +. +/ +/ +/ +/ +/ +/ +If +the +result +returned +indicates +that +the +DFA +quit +then +another +/ +/ +/ +matching +engine +should +be +used +. +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +exec_dfa_reverse_suffix +( +& +self +text +: +& +[ +u8 +] +original_start +: +usize +) +- +> +Option +< +dfa +: +: +Result +< +( +usize +usize +) +> +> +{ +use +crate +: +: +dfa +: +: +Result +: +: +* +; +let +lcs += +self +. +ro +. +suffixes +. +lcs +( +) +; +debug_assert +! +( +lcs +. +len +( +) +> += +1 +) +; +let +mut +start += +original_start +; +let +mut +end += +start +; +let +mut +last_literal += +start +; +while +end +< += +text +. +len +( +) +{ +last_literal ++ += +match +lcs +. +find +( +& +text +[ +last_literal +. +. +] +) +{ +None += +> +return +Some +( +NoMatch +( +text +. +len +( +) +) +) +Some +( +i +) += +> +i +} +; +end += +last_literal ++ +lcs +. +len +( +) +; +match +dfa +: +: +Fsm +: +: +reverse +( +& +self +. +ro +. +dfa_reverse +self +. +cache +. +value +( +) +false +& +text +[ +start +. +. +end +] +end +- +start +) +{ +Match +( +0 +) +| +NoMatch +( +0 +) += +> +return +None +Match +( +i +) += +> +return +Some +( +Match +( +( +start ++ +i +end +) +) +) +NoMatch +( +i +) += +> +{ +start ++ += +i +; +last_literal ++ += +1 +; +continue +; +} +Quit += +> +return +Some +( +Quit +) +} +; +} +Some +( +NoMatch +( +text +. +len +( +) +) +) +} +/ +/ +/ +Finds +the +leftmost +- +first +match +( +start +and +end +) +using +only +the +DFA +/ +/ +/ +by +scanning +for +suffix +literals +. +/ +/ +/ +/ +/ +/ +If +the +result +returned +indicates +that +the +DFA +quit +then +another +/ +/ +/ +matching +engine +should +be +used +. +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +find_dfa_reverse_suffix +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +dfa +: +: +Result +< +( +usize +usize +) +> +{ +use +crate +: +: +dfa +: +: +Result +: +: +* +; +let +match_start += +match +self +. +exec_dfa_reverse_suffix +( +text +start +) +{ +None += +> +return +self +. +find_dfa_forward +( +text +start +) +Some +( +Match +( +( +start +_ +) +) +) += +> +start +Some +( +r +) += +> +return +r +} +; +/ +/ +At +this +point +we +' +ve +found +a +match +. +The +only +way +to +quit +now +/ +/ +without +a +match +is +if +the +DFA +gives +up +( +seems +unlikely +) +. +/ +/ +/ +/ +Now +run +the +DFA +forwards +to +find +the +proper +end +of +the +match +. +/ +/ +( +The +suffix +literal +match +can +only +indicate +the +earliest +/ +/ +possible +end +location +which +may +appear +before +the +end +of +the +/ +/ +leftmost +- +first +match +. +) +match +dfa +: +: +Fsm +: +: +forward +( +& +self +. +ro +. +dfa +self +. +cache +. +value +( +) +false +text +match_start +) +{ +NoMatch +( +_ +) += +> +panic +! +( +" +BUG +: +reverse +match +implies +forward +match +" +) +Quit += +> +Quit +Match +( +e +) += +> +Match +( +( +match_start +e +) +) +} +} +/ +/ +/ +Executes +the +NFA +engine +to +return +whether +there +is +a +match +or +not +. +/ +/ +/ +/ +/ +/ +Ideally +we +could +use +shortest_nfa +( +. +. +. +) +. +is_some +( +) +and +get +the +same +/ +/ +/ +performance +characteristics +but +regex +sets +don +' +t +have +captures +which +/ +/ +/ +shortest_nfa +depends +on +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +fn +match_nfa +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +bool +{ +self +. +match_nfa_type +( +MatchNfaType +: +: +Auto +text +start +) +} +/ +/ +/ +Like +match_nfa +but +allows +specification +of +the +type +of +NFA +engine +. +fn +match_nfa_type +( +& +self +ty +: +MatchNfaType +text +: +& +[ +u8 +] +start +: +usize +) +- +> +bool +{ +self +. +exec_nfa +( +ty +& +mut +[ +false +] +& +mut +[ +] +true +false +text +start +text +. +len +( +) +) +} +/ +/ +/ +Finds +the +shortest +match +using +an +NFA +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +fn +shortest_nfa +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +usize +> +{ +self +. +shortest_nfa_type +( +MatchNfaType +: +: +Auto +text +start +) +} +/ +/ +/ +Like +shortest_nfa +but +allows +specification +of +the +type +of +NFA +engine +. +fn +shortest_nfa_type +( +& +self +ty +: +MatchNfaType +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +usize +> +{ +let +mut +slots += +[ +None +None +] +; +if +self +. +exec_nfa +( +ty +& +mut +[ +false +] +& +mut +slots +true +true +text +start +text +. +len +( +) +) +{ +slots +[ +1 +] +} +else +{ +None +} +} +/ +/ +/ +Like +find +but +executes +an +NFA +engine +. +fn +find_nfa +( +& +self +ty +: +MatchNfaType +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +let +mut +slots += +[ +None +None +] +; +if +self +. +exec_nfa +( +ty +& +mut +[ +false +] +& +mut +slots +false +false +text +start +text +. +len +( +) +) +{ +match +( +slots +[ +0 +] +slots +[ +1 +] +) +{ +( +Some +( +s +) +Some +( +e +) +) += +> +Some +( +( +s +e +) +) +_ += +> +None +} +} +else +{ +None +} +} +/ +/ +/ +Like +find_nfa +but +fills +in +captures +. +/ +/ +/ +/ +/ +/ +slots +should +have +length +equal +to +2 +* +nfa +. +captures +. +len +( +) +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +fn +captures_nfa +( +& +self +slots +: +& +mut +[ +Slot +] +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +self +. +captures_nfa_type +( +MatchNfaType +: +: +Auto +slots +text +start +text +. +len +( +) +) +} +/ +/ +/ +Like +captures_nfa +but +allows +specification +of +type +of +NFA +engine +. +fn +captures_nfa_type +( +& +self +ty +: +MatchNfaType +slots +: +& +mut +[ +Slot +] +text +: +& +[ +u8 +] +start +: +usize +end +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +if +self +. +exec_nfa +( +ty +& +mut +[ +false +] +slots +false +false +text +start +end +) +{ +match +( +slots +[ +0 +] +slots +[ +1 +] +) +{ +( +Some +( +s +) +Some +( +e +) +) += +> +Some +( +( +s +e +) +) +_ += +> +None +} +} +else +{ +None +} +} +fn +exec_nfa +( +& +self +mut +ty +: +MatchNfaType +matches +: +& +mut +[ +bool +] +slots +: +& +mut +[ +Slot +] +quit_after_match +: +bool +quit_after_match_with_pos +: +bool +text +: +& +[ +u8 +] +start +: +usize +end +: +usize +) +- +> +bool +{ +use +self +: +: +MatchNfaType +: +: +* +; +if +let +Auto += +ty +{ +if +backtrack +: +: +should_exec +( +self +. +ro +. +nfa +. +len +( +) +text +. +len +( +) +) +{ +ty += +Backtrack +; +} +else +{ +ty += +PikeVM +; +} +} +/ +/ +The +backtracker +can +' +t +return +the +shortest +match +position +as +it +is +/ +/ +implemented +today +. +So +if +someone +calls +shortest_match +and +we +need +/ +/ +to +run +an +NFA +then +use +the +PikeVM +. +if +quit_after_match_with_pos +| +| +ty += += +PikeVM +{ +self +. +exec_pikevm +( +matches +slots +quit_after_match +text +start +end +) +} +else +{ +self +. +exec_backtrack +( +matches +slots +text +start +end +) +} +} +/ +/ +/ +Always +run +the +NFA +algorithm +. +fn +exec_pikevm +( +& +self +matches +: +& +mut +[ +bool +] +slots +: +& +mut +[ +Slot +] +quit_after_match +: +bool +text +: +& +[ +u8 +] +start +: +usize +end +: +usize +) +- +> +bool +{ +if +self +. +ro +. +nfa +. +uses_bytes +( +) +{ +pikevm +: +: +Fsm +: +: +exec +( +& +self +. +ro +. +nfa +self +. +cache +. +value +( +) +matches +slots +quit_after_match +ByteInput +: +: +new +( +text +self +. +ro +. +nfa +. +only_utf8 +) +start +end +) +} +else +{ +pikevm +: +: +Fsm +: +: +exec +( +& +self +. +ro +. +nfa +self +. +cache +. +value +( +) +matches +slots +quit_after_match +CharInput +: +: +new +( +text +) +start +end +) +} +} +/ +/ +/ +Always +runs +the +NFA +using +bounded +backtracking +. +fn +exec_backtrack +( +& +self +matches +: +& +mut +[ +bool +] +slots +: +& +mut +[ +Slot +] +text +: +& +[ +u8 +] +start +: +usize +end +: +usize +) +- +> +bool +{ +if +self +. +ro +. +nfa +. +uses_bytes +( +) +{ +backtrack +: +: +Bounded +: +: +exec +( +& +self +. +ro +. +nfa +self +. +cache +. +value +( +) +matches +slots +ByteInput +: +: +new +( +text +self +. +ro +. +nfa +. +only_utf8 +) +start +end +) +} +else +{ +backtrack +: +: +Bounded +: +: +exec +( +& +self +. +ro +. +nfa +self +. +cache +. +value +( +) +matches +slots +CharInput +: +: +new +( +text +) +start +end +) +} +} +/ +/ +/ +Finds +which +regular +expressions +match +the +given +text +. +/ +/ +/ +/ +/ +/ +matches +should +have +length +equal +to +the +number +of +regexes +being +/ +/ +/ +searched +. +/ +/ +/ +/ +/ +/ +This +is +only +useful +when +one +wants +to +know +which +regexes +in +a +set +/ +/ +/ +match +some +text +. +pub +fn +many_matches_at +( +& +self +matches +: +& +mut +[ +bool +] +text +: +& +[ +u8 +] +start +: +usize +) +- +> +bool +{ +use +self +: +: +MatchType +: +: +* +; +if +! +self +. +is_anchor_end_match +( +text +) +{ +return +false +; +} +match +self +. +ro +. +match_type +{ +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +Literal +( +ty +) += +> +{ +debug_assert_eq +! +( +matches +. +len +( +) +1 +) +; +matches +[ +0 +] += +self +. +find_literals +( +ty +text +start +) +. +is_some +( +) +; +matches +[ +0 +] +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +Dfa +| +DfaAnchoredReverse +| +DfaMany += +> +{ +match +dfa +: +: +Fsm +: +: +forward_many +( +& +self +. +ro +. +dfa +self +. +cache +. +value +( +) +matches +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +_ +) += +> +true +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +false +dfa +: +: +Result +: +: +Quit += +> +self +. +exec_nfa +( +MatchNfaType +: +: +Auto +matches +& +mut +[ +] +false +false +text +start +text +. +len +( +) +) +} +} +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +DfaSuffix += +> +{ +match +dfa +: +: +Fsm +: +: +forward_many +( +& +self +. +ro +. +dfa +self +. +cache +. +value +( +) +matches +text +start +) +{ +dfa +: +: +Result +: +: +Match +( +_ +) += +> +true +dfa +: +: +Result +: +: +NoMatch +( +_ +) += +> +false +dfa +: +: +Result +: +: +Quit += +> +self +. +exec_nfa +( +MatchNfaType +: +: +Auto +matches +& +mut +[ +] +false +false +text +start +text +. +len +( +) +) +} +} +Nfa +( +ty +) += +> +self +. +exec_nfa +( +ty +matches +& +mut +[ +] +false +false +text +start +text +. +len +( +) +) +Nothing += +> +false +} +} +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +is_anchor_end_match +( +& +self +text +: +& +[ +u8 +] +) +- +> +bool +{ +# +[ +cfg +( +not +( +feature += +" +perf +- +literal +" +) +) +] +fn +imp +( +_ +: +& +ExecReadOnly +_ +: +& +[ +u8 +] +) +- +> +bool +{ +true +} +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +fn +imp +( +ro +: +& +ExecReadOnly +text +: +& +[ +u8 +] +) +- +> +bool +{ +/ +/ +Only +do +this +check +if +the +haystack +is +big +( +> +1MB +) +. +if +text +. +len +( +) +> +( +1 +< +< +20 +) +& +& +ro +. +nfa +. +is_anchored_end +{ +let +lcs += +ro +. +suffixes +. +lcs +( +) +; +if +lcs +. +len +( +) +> += +1 +& +& +! +lcs +. +is_suffix +( +text +) +{ +return +false +; +} +} +true +} +imp +( +& +self +. +ro +text +) +} +pub +fn +capture_name_idx +( +& +self +) +- +> +& +Arc +< +HashMap +< +String +usize +> +> +{ +& +self +. +ro +. +nfa +. +capture_name_idx +} +} +impl +< +' +c +> +ExecNoSyncStr +< +' +c +> +{ +pub +fn +capture_name_idx +( +& +self +) +- +> +& +Arc +< +HashMap +< +String +usize +> +> +{ +self +. +0 +. +capture_name_idx +( +) +} +} +impl +Exec +{ +/ +/ +/ +Get +a +searcher +that +isn +' +t +Sync +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +pub +fn +searcher +( +& +self +) +- +> +ExecNoSync +< +' +_ +> +{ +ExecNoSync +{ +ro +: +& +self +. +ro +/ +/ +a +clone +is +too +expensive +here +! +( +and +not +needed +) +cache +: +self +. +pool +. +get +( +) +} +} +/ +/ +/ +Get +a +searcher +that +isn +' +t +Sync +and +can +match +on +& +str +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +pub +fn +searcher_str +( +& +self +) +- +> +ExecNoSyncStr +< +' +_ +> +{ +ExecNoSyncStr +( +self +. +searcher +( +) +) +} +/ +/ +/ +Build +a +Regex +from +this +executor +. +pub +fn +into_regex +( +self +) +- +> +re_unicode +: +: +Regex +{ +re_unicode +: +: +Regex +: +: +from +( +self +) +} +/ +/ +/ +Build +a +RegexSet +from +this +executor +. +pub +fn +into_regex_set +( +self +) +- +> +re_set +: +: +unicode +: +: +RegexSet +{ +re_set +: +: +unicode +: +: +RegexSet +: +: +from +( +self +) +} +/ +/ +/ +Build +a +Regex +from +this +executor +that +can +match +arbitrary +bytes +. +pub +fn +into_byte_regex +( +self +) +- +> +re_bytes +: +: +Regex +{ +re_bytes +: +: +Regex +: +: +from +( +self +) +} +/ +/ +/ +Build +a +RegexSet +from +this +executor +that +can +match +arbitrary +bytes +. +pub +fn +into_byte_regex_set +( +self +) +- +> +re_set +: +: +bytes +: +: +RegexSet +{ +re_set +: +: +bytes +: +: +RegexSet +: +: +from +( +self +) +} +/ +/ +/ +The +original +regular +expressions +given +by +the +caller +that +were +/ +/ +/ +compiled +. +pub +fn +regex_strings +( +& +self +) +- +> +& +[ +String +] +{ +& +self +. +ro +. +res +} +/ +/ +/ +Return +a +slice +of +capture +names +. +/ +/ +/ +/ +/ +/ +Any +capture +that +isn +' +t +named +is +None +. +pub +fn +capture_names +( +& +self +) +- +> +& +[ +Option +< +String +> +] +{ +& +self +. +ro +. +nfa +. +captures +} +/ +/ +/ +Return +a +reference +to +named +groups +mapping +( +from +group +name +to +/ +/ +/ +group +position +) +. +pub +fn +capture_name_idx +( +& +self +) +- +> +& +Arc +< +HashMap +< +String +usize +> +> +{ +& +self +. +ro +. +nfa +. +capture_name_idx +} +} +impl +Clone +for +Exec +{ +fn +clone +( +& +self +) +- +> +Exec +{ +let +pool += +ExecReadOnly +: +: +new_pool +( +& +self +. +ro +) +; +Exec +{ +ro +: +self +. +ro +. +clone +( +) +pool +} +} +} +impl +ExecReadOnly +{ +fn +choose_match_type +( +& +self +hint +: +Option +< +MatchType +> +) +- +> +MatchType +{ +if +let +Some +( +MatchType +: +: +Nfa +( +_ +) +) += +hint +{ +return +hint +. +unwrap +( +) +; +} +/ +/ +If +the +NFA +is +empty +then +we +' +ll +never +match +anything +. +if +self +. +nfa +. +insts +. +is_empty +( +) +{ +return +MatchType +: +: +Nothing +; +} +if +let +Some +( +literalty +) += +self +. +choose_literal_match_type +( +) +{ +return +literalty +; +} +if +let +Some +( +dfaty +) += +self +. +choose_dfa_match_type +( +) +{ +return +dfaty +; +} +/ +/ +We +' +re +so +totally +hosed +. +MatchType +: +: +Nfa +( +MatchNfaType +: +: +Auto +) +} +/ +/ +/ +If +a +plain +literal +scan +can +be +used +then +a +corresponding +literal +/ +/ +/ +search +type +is +returned +. +fn +choose_literal_match_type +( +& +self +) +- +> +Option +< +MatchType +> +{ +# +[ +cfg +( +not +( +feature += +" +perf +- +literal +" +) +) +] +fn +imp +( +_ +: +& +ExecReadOnly +) +- +> +Option +< +MatchType +> +{ +None +} +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +fn +imp +( +ro +: +& +ExecReadOnly +) +- +> +Option +< +MatchType +> +{ +/ +/ +If +our +set +of +prefixes +is +complete +then +we +can +use +it +to +find +/ +/ +a +match +in +lieu +of +a +regex +engine +. +This +doesn +' +t +quite +work +well +/ +/ +in +the +presence +of +multiple +regexes +so +only +do +it +when +there +' +s +/ +/ +one +. +/ +/ +/ +/ +TODO +( +burntsushi +) +: +Also +don +' +t +try +to +match +literals +if +the +regex +/ +/ +is +partially +anchored +. +We +could +technically +do +it +but +we +' +d +need +/ +/ +to +create +two +sets +of +literals +: +all +of +them +and +then +the +subset +/ +/ +that +aren +' +t +anchored +. +We +would +then +only +search +for +all +of +them +/ +/ +when +at +the +beginning +of +the +input +and +use +the +subset +in +all +/ +/ +other +cases +. +if +ro +. +res +. +len +( +) +! += +1 +{ +return +None +; +} +if +ro +. +ac +. +is_some +( +) +{ +return +Some +( +MatchType +: +: +Literal +( +MatchLiteralType +: +: +AhoCorasick +) +) +; +} +if +ro +. +nfa +. +prefixes +. +complete +( +) +{ +return +if +ro +. +nfa +. +is_anchored_start +{ +Some +( +MatchType +: +: +Literal +( +MatchLiteralType +: +: +AnchoredStart +) +) +} +else +{ +Some +( +MatchType +: +: +Literal +( +MatchLiteralType +: +: +Unanchored +) +) +} +; +} +if +ro +. +suffixes +. +complete +( +) +{ +return +if +ro +. +nfa +. +is_anchored_end +{ +Some +( +MatchType +: +: +Literal +( +MatchLiteralType +: +: +AnchoredEnd +) +) +} +else +{ +/ +/ +This +case +shouldn +' +t +happen +. +When +the +regex +isn +' +t +/ +/ +anchored +then +complete +prefixes +should +imply +complete +/ +/ +suffixes +. +Some +( +MatchType +: +: +Literal +( +MatchLiteralType +: +: +Unanchored +) +) +} +; +} +None +} +imp +( +self +) +} +/ +/ +/ +If +a +DFA +scan +can +be +used +then +choose +the +appropriate +DFA +strategy +. +fn +choose_dfa_match_type +( +& +self +) +- +> +Option +< +MatchType +> +{ +# +[ +cfg +( +not +( +feature += +" +perf +- +dfa +" +) +) +] +fn +imp +( +_ +: +& +ExecReadOnly +) +- +> +Option +< +MatchType +> +{ +None +} +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +fn +imp +( +ro +: +& +ExecReadOnly +) +- +> +Option +< +MatchType +> +{ +if +! +dfa +: +: +can_exec +( +& +ro +. +dfa +) +{ +return +None +; +} +/ +/ +Regex +sets +require +a +slightly +specialized +path +. +if +ro +. +res +. +len +( +) +> += +2 +{ +return +Some +( +MatchType +: +: +DfaMany +) +; +} +/ +/ +If +the +regex +is +anchored +at +the +end +but +not +the +start +then +/ +/ +just +match +in +reverse +from +the +end +of +the +haystack +. +if +! +ro +. +nfa +. +is_anchored_start +& +& +ro +. +nfa +. +is_anchored_end +{ +return +Some +( +MatchType +: +: +DfaAnchoredReverse +) +; +} +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +{ +/ +/ +If +there +' +s +a +longish +suffix +literal +then +it +might +be +faster +/ +/ +to +look +for +that +first +. +if +ro +. +should_suffix_scan +( +) +{ +return +Some +( +MatchType +: +: +DfaSuffix +) +; +} +} +/ +/ +Fall +back +to +your +garden +variety +forward +searching +lazy +DFA +. +Some +( +MatchType +: +: +Dfa +) +} +imp +( +self +) +} +/ +/ +/ +Returns +true +if +the +program +is +amenable +to +suffix +scanning +. +/ +/ +/ +/ +/ +/ +When +this +is +true +as +a +heuristic +we +assume +it +is +OK +to +quickly +scan +/ +/ +/ +for +suffix +literals +and +then +do +a +* +reverse +* +DFA +match +from +any +matches +/ +/ +/ +produced +by +the +literal +scan +. +( +And +then +followed +by +a +forward +DFA +/ +/ +/ +search +since +the +previously +found +suffix +literal +maybe +not +actually +be +/ +/ +/ +the +end +of +a +match +. +) +/ +/ +/ +/ +/ +/ +This +is +a +bit +of +a +specialized +optimization +but +can +result +in +pretty +/ +/ +/ +big +performance +wins +if +1 +) +there +are +no +prefix +literals +and +2 +) +the +/ +/ +/ +suffix +literals +are +pretty +rare +in +the +text +. +( +1 +) +is +obviously +easy +to +/ +/ +/ +account +for +but +( +2 +) +is +harder +. +As +a +proxy +we +assume +that +longer +/ +/ +/ +strings +are +generally +rarer +so +we +only +enable +this +optimization +when +/ +/ +/ +we +have +a +meaty +suffix +. +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +fn +should_suffix_scan +( +& +self +) +- +> +bool +{ +if +self +. +suffixes +. +is_empty +( +) +{ +return +false +; +} +let +lcs_len += +self +. +suffixes +. +lcs +( +) +. +char_len +( +) +; +lcs_len +> += +3 +& +& +lcs_len +> +self +. +dfa +. +prefixes +. +lcp +( +) +. +char_len +( +) +} +fn +new_pool +( +ro +: +& +Arc +< +ExecReadOnly +> +) +- +> +Box +< +Pool +< +ProgramCache +> +> +{ +let +ro += +ro +. +clone +( +) +; +Box +: +: +new +( +Pool +: +: +new +( +Box +: +: +new +( +move +| +| +{ +AssertUnwindSafe +( +RefCell +: +: +new +( +ProgramCacheInner +: +: +new +( +& +ro +) +) +) +} +) +) +) +} +} +# +[ +derive +( +Clone +Copy +Debug +) +] +enum +MatchType +{ +/ +/ +/ +A +single +or +multiple +literal +search +. +This +is +only +used +when +the +regex +/ +/ +/ +can +be +decomposed +into +a +literal +search +. +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +Literal +( +MatchLiteralType +) +/ +/ +/ +A +normal +DFA +search +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +Dfa +/ +/ +/ +A +reverse +DFA +search +starting +from +the +end +of +a +haystack +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +DfaAnchoredReverse +/ +/ +/ +A +reverse +DFA +search +with +suffix +literal +scanning +. +# +[ +cfg +( +all +( +feature += +" +perf +- +dfa +" +feature += +" +perf +- +literal +" +) +) +] +DfaSuffix +/ +/ +/ +Use +the +DFA +on +two +or +more +regular +expressions +. +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +DfaMany +/ +/ +/ +An +NFA +variant +. +Nfa +( +MatchNfaType +) +/ +/ +/ +No +match +is +ever +possible +so +don +' +t +ever +try +to +search +. +Nothing +} +# +[ +derive +( +Clone +Copy +Debug +) +] +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +enum +MatchLiteralType +{ +/ +/ +/ +Match +literals +anywhere +in +text +. +Unanchored +/ +/ +/ +Match +literals +only +at +the +start +of +text +. +AnchoredStart +/ +/ +/ +Match +literals +only +at +the +end +of +text +. +AnchoredEnd +/ +/ +/ +Use +an +Aho +- +Corasick +automaton +. +This +requires +ac +to +be +Some +on +/ +/ +/ +ExecReadOnly +. +AhoCorasick +} +# +[ +derive +( +Clone +Copy +Debug +Eq +PartialEq +) +] +enum +MatchNfaType +{ +/ +/ +/ +Choose +between +Backtrack +and +PikeVM +. +Auto +/ +/ +/ +NFA +bounded +backtracking +. +/ +/ +/ +/ +/ +/ +( +This +is +only +set +by +tests +since +it +never +makes +sense +to +always +want +/ +/ +/ +backtracking +. +) +Backtrack +/ +/ +/ +The +Pike +VM +. +/ +/ +/ +/ +/ +/ +( +This +is +only +set +by +tests +since +it +never +makes +sense +to +always +want +/ +/ +/ +the +Pike +VM +. +) +PikeVM +} +/ +/ +/ +ProgramCache +maintains +reusable +allocations +for +each +matching +engine +/ +/ +/ +available +to +a +particular +program +. +/ +/ +/ +/ +/ +/ +We +declare +this +as +unwind +safe +since +it +' +s +a +cache +that +' +s +only +used +for +/ +/ +/ +performance +purposes +. +If +a +panic +occurs +it +is +( +or +should +be +) +always +safe +/ +/ +/ +to +continue +using +the +same +regex +object +. +pub +type +ProgramCache += +AssertUnwindSafe +< +RefCell +< +ProgramCacheInner +> +> +; +# +[ +derive +( +Debug +) +] +pub +struct +ProgramCacheInner +{ +pub +pikevm +: +pikevm +: +: +Cache +pub +backtrack +: +backtrack +: +: +Cache +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +pub +dfa +: +dfa +: +: +Cache +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +pub +dfa_reverse +: +dfa +: +: +Cache +} +impl +ProgramCacheInner +{ +fn +new +( +ro +: +& +ExecReadOnly +) +- +> +Self +{ +ProgramCacheInner +{ +pikevm +: +pikevm +: +: +Cache +: +: +new +( +& +ro +. +nfa +) +backtrack +: +backtrack +: +: +Cache +: +: +new +( +& +ro +. +nfa +) +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +dfa +: +dfa +: +: +Cache +: +: +new +( +& +ro +. +dfa +) +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] +dfa_reverse +: +dfa +: +: +Cache +: +: +new +( +& +ro +. +dfa_reverse +) +} +} +} +/ +/ +/ +Alternation +literals +checks +if +the +given +HIR +is +a +simple +alternation +of +/ +/ +/ +literals +and +if +so +returns +them +. +Otherwise +this +returns +None +. +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +fn +alternation_literals +( +expr +: +& +Hir +) +- +> +Option +< +Vec +< +Vec +< +u8 +> +> +> +{ +use +regex_syntax +: +: +hir +: +: +{ +HirKind +Literal +} +; +/ +/ +This +is +pretty +hacky +but +basically +if +is_alternation_literal +is +/ +/ +true +then +we +can +make +several +assumptions +about +the +structure +of +our +/ +/ +HIR +. +This +is +what +justifies +the +unreachable +! +statements +below +. +/ +/ +/ +/ +This +code +should +be +refactored +once +we +overhaul +this +crate +' +s +/ +/ +optimization +pipeline +because +this +is +a +terribly +inflexible +way +to +go +/ +/ +about +things +. +if +! +expr +. +is_alternation_literal +( +) +{ +return +None +; +} +let +alts += +match +* +expr +. +kind +( +) +{ +HirKind +: +: +Alternation +( +ref +alts +) += +> +alts +_ += +> +return +None +/ +/ +one +literal +isn +' +t +worth +it +} +; +let +extendlit += +| +lit +: +& +Literal +dst +: +& +mut +Vec +< +u8 +> +| +match +* +lit +{ +Literal +: +: +Unicode +( +c +) += +> +{ +let +mut +buf += +[ +0 +; +4 +] +; +dst +. +extend_from_slice +( +c +. +encode_utf8 +( +& +mut +buf +) +. +as_bytes +( +) +) +; +} +Literal +: +: +Byte +( +b +) += +> +{ +dst +. +push +( +b +) +; +} +} +; +let +mut +lits += +vec +! +[ +] +; +for +alt +in +alts +{ +let +mut +lit += +vec +! +[ +] +; +match +* +alt +. +kind +( +) +{ +HirKind +: +: +Literal +( +ref +x +) += +> +extendlit +( +x +& +mut +lit +) +HirKind +: +: +Concat +( +ref +exprs +) += +> +{ +for +e +in +exprs +{ +match +* +e +. +kind +( +) +{ +HirKind +: +: +Literal +( +ref +x +) += +> +extendlit +( +x +& +mut +lit +) +_ += +> +unreachable +! +( +" +expected +literal +got +{ +: +? +} +" +e +) +} +} +} +_ += +> +unreachable +! +( +" +expected +literal +or +concat +got +{ +: +? +} +" +alt +) +} +lits +. +push +( +lit +) +; +} +Some +( +lits +) +} +# +[ +cfg +( +test +) +] +mod +test +{ +# +[ +test +] +fn +uppercut_s_backtracking_bytes_default_bytes_mismatch +( +) +{ +use +crate +: +: +internal +: +: +ExecBuilder +; +let +backtrack_bytes_re += +ExecBuilder +: +: +new +( +" +^ +S +" +) +. +bounded_backtracking +( +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_byte_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +. +unwrap +( +) +; +let +default_bytes_re += +ExecBuilder +: +: +new +( +" +^ +S +" +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_byte_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +. +unwrap +( +) +; +let +input += +vec +! +[ +83 +83 +] +; +let +s1 += +backtrack_bytes_re +. +split +( +& +input +) +; +let +s2 += +default_bytes_re +. +split +( +& +input +) +; +for +( +chunk1 +chunk2 +) +in +s1 +. +zip +( +s2 +) +{ +assert_eq +! +( +chunk1 +chunk2 +) +; +} +} +# +[ +test +] +fn +unicode_lit_star_backtracking_utf8bytes_default_utf8bytes_mismatch +( +) +{ +use +crate +: +: +internal +: +: +ExecBuilder +; +let +backtrack_bytes_re += +ExecBuilder +: +: +new +( +r +" +^ +( +? +u +: +\ +* +) +" +) +. +bounded_backtracking +( +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +. +unwrap +( +) +; +let +default_bytes_re += +ExecBuilder +: +: +new +( +r +" +^ +( +? +u +: +\ +* +) +" +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +. +unwrap +( +) +; +let +input += +" +* +* +" +; +let +s1 += +backtrack_bytes_re +. +split +( +input +) +; +let +s2 += +default_bytes_re +. +split +( +input +) +; +for +( +chunk1 +chunk2 +) +in +s1 +. +zip +( +s2 +) +{ +assert_eq +! +( +chunk1 +chunk2 +) +; +} +} +} diff --git a/third_party/rust/regex/src/expand.rs b/third_party/rust/regex/src/expand.rs new file mode 100644 index 0000000000000..a6c6396af4ed0 --- /dev/null +++ b/third_party/rust/regex/src/expand.rs @@ -0,0 +1,1931 @@ +use +std +: +: +str +; +use +crate +: +: +find_byte +: +: +find_byte +; +use +crate +: +: +re_bytes +; +use +crate +: +: +re_unicode +; +pub +fn +expand_str +( +caps +: +& +re_unicode +: +: +Captures +< +' +_ +> +mut +replacement +: +& +str +dst +: +& +mut +String +) +{ +while +! +replacement +. +is_empty +( +) +{ +match +find_byte +( +b +' +' +replacement +. +as_bytes +( +) +) +{ +None += +> +break +Some +( +i +) += +> +{ +dst +. +push_str +( +& +replacement +[ +. +. +i +] +) +; +replacement += +& +replacement +[ +i +. +. +] +; +} +} +if +replacement +. +as_bytes +( +) +. +get +( +1 +) +. +map_or +( +false +| +& +b +| +b += += +b +' +' +) +{ +dst +. +push_str +( +" +" +) +; +replacement += +& +replacement +[ +2 +. +. +] +; +continue +; +} +debug_assert +! +( +! +replacement +. +is_empty +( +) +) +; +let +cap_ref += +match +find_cap_ref +( +replacement +. +as_bytes +( +) +) +{ +Some +( +cap_ref +) += +> +cap_ref +None += +> +{ +dst +. +push_str +( +" +" +) +; +replacement += +& +replacement +[ +1 +. +. +] +; +continue +; +} +} +; +replacement += +& +replacement +[ +cap_ref +. +end +. +. +] +; +match +cap_ref +. +cap +{ +Ref +: +: +Number +( +i +) += +> +{ +dst +. +push_str +( +caps +. +get +( +i +) +. +map +( +| +m +| +m +. +as_str +( +) +) +. +unwrap_or +( +" +" +) +) +; +} +Ref +: +: +Named +( +name +) += +> +{ +dst +. +push_str +( +caps +. +name +( +name +) +. +map +( +| +m +| +m +. +as_str +( +) +) +. +unwrap_or +( +" +" +) +) +; +} +} +} +dst +. +push_str +( +replacement +) +; +} +pub +fn +expand_bytes +( +caps +: +& +re_bytes +: +: +Captures +< +' +_ +> +mut +replacement +: +& +[ +u8 +] +dst +: +& +mut +Vec +< +u8 +> +) +{ +while +! +replacement +. +is_empty +( +) +{ +match +find_byte +( +b +' +' +replacement +) +{ +None += +> +break +Some +( +i +) += +> +{ +dst +. +extend +( +& +replacement +[ +. +. +i +] +) +; +replacement += +& +replacement +[ +i +. +. +] +; +} +} +if +replacement +. +get +( +1 +) +. +map_or +( +false +| +& +b +| +b += += +b +' +' +) +{ +dst +. +push +( +b +' +' +) +; +replacement += +& +replacement +[ +2 +. +. +] +; +continue +; +} +debug_assert +! +( +! +replacement +. +is_empty +( +) +) +; +let +cap_ref += +match +find_cap_ref +( +replacement +) +{ +Some +( +cap_ref +) += +> +cap_ref +None += +> +{ +dst +. +push +( +b +' +' +) +; +replacement += +& +replacement +[ +1 +. +. +] +; +continue +; +} +} +; +replacement += +& +replacement +[ +cap_ref +. +end +. +. +] +; +match +cap_ref +. +cap +{ +Ref +: +: +Number +( +i +) += +> +{ +dst +. +extend +( +caps +. +get +( +i +) +. +map +( +| +m +| +m +. +as_bytes +( +) +) +. +unwrap_or +( +b +" +" +) +) +; +} +Ref +: +: +Named +( +name +) += +> +{ +dst +. +extend +( +caps +. +name +( +name +) +. +map +( +| +m +| +m +. +as_bytes +( +) +) +. +unwrap_or +( +b +" +" +) +) +; +} +} +} +dst +. +extend +( +replacement +) +; +} +/ +/ +/ +CaptureRef +represents +a +reference +to +a +capture +group +inside +some +text +. +/ +/ +/ +The +reference +is +either +a +capture +group +name +or +a +number +. +/ +/ +/ +/ +/ +/ +It +is +also +tagged +with +the +position +in +the +text +following +the +/ +/ +/ +capture +reference +. +# +[ +derive +( +Clone +Copy +Debug +Eq +PartialEq +) +] +struct +CaptureRef +< +' +a +> +{ +cap +: +Ref +< +' +a +> +end +: +usize +} +/ +/ +/ +A +reference +to +a +capture +group +in +some +text +. +/ +/ +/ +/ +/ +/ +e +. +g +. +2 +foo +{ +foo +} +. +# +[ +derive +( +Clone +Copy +Debug +Eq +PartialEq +) +] +enum +Ref +< +' +a +> +{ +Named +( +& +' +a +str +) +Number +( +usize +) +} +impl +< +' +a +> +From +< +& +' +a +str +> +for +Ref +< +' +a +> +{ +fn +from +( +x +: +& +' +a +str +) +- +> +Ref +< +' +a +> +{ +Ref +: +: +Named +( +x +) +} +} +impl +From +< +usize +> +for +Ref +< +' +static +> +{ +fn +from +( +x +: +usize +) +- +> +Ref +< +' +static +> +{ +Ref +: +: +Number +( +x +) +} +} +/ +/ +/ +Parses +a +possible +reference +to +a +capture +group +name +in +the +given +text +/ +/ +/ +starting +at +the +beginning +of +replacement +. +/ +/ +/ +/ +/ +/ +If +no +such +valid +reference +could +be +found +None +is +returned +. +fn +find_cap_ref +( +replacement +: +& +[ +u8 +] +) +- +> +Option +< +CaptureRef +< +' +_ +> +> +{ +let +mut +i += +0 +; +let +rep +: +& +[ +u8 +] += +replacement +; +if +rep +. +len +( +) +< += +1 +| +| +rep +[ +0 +] +! += +b +' +' +{ +return +None +; +} +i ++ += +1 +; +if +rep +[ +i +] += += +b +' +{ +' +{ +return +find_cap_ref_braced +( +rep +i ++ +1 +) +; +} +let +mut +cap_end += +i +; +while +rep +. +get +( +cap_end +) +. +copied +( +) +. +map_or +( +false +is_valid_cap_letter +) +{ +cap_end ++ += +1 +; +} +if +cap_end += += +i +{ +return +None +; +} +/ +/ +We +just +verified +that +the +range +0 +. +. +cap_end +is +valid +ASCII +so +it +must +/ +/ +therefore +be +valid +UTF +- +8 +. +If +we +really +cared +we +could +avoid +this +UTF +- +8 +/ +/ +check +via +an +unchecked +conversion +or +by +parsing +the +number +straight +from +/ +/ +& +[ +u8 +] +. +let +cap += +str +: +: +from_utf8 +( +& +rep +[ +i +. +. +cap_end +] +) +. +expect +( +" +valid +UTF +- +8 +capture +name +" +) +; +Some +( +CaptureRef +{ +cap +: +match +cap +. +parse +: +: +< +u32 +> +( +) +{ +Ok +( +i +) += +> +Ref +: +: +Number +( +i +as +usize +) +Err +( +_ +) += +> +Ref +: +: +Named +( +cap +) +} +end +: +cap_end +} +) +} +fn +find_cap_ref_braced +( +rep +: +& +[ +u8 +] +mut +i +: +usize +) +- +> +Option +< +CaptureRef +< +' +_ +> +> +{ +let +start += +i +; +while +rep +. +get +( +i +) +. +map_or +( +false +| +& +b +| +b +! += +b +' +} +' +) +{ +i ++ += +1 +; +} +if +! +rep +. +get +( +i +) +. +map_or +( +false +| +& +b +| +b += += +b +' +} +' +) +{ +return +None +; +} +/ +/ +When +looking +at +braced +names +we +don +' +t +put +any +restrictions +on +the +name +/ +/ +so +it +' +s +possible +it +could +be +invalid +UTF +- +8 +. +But +a +capture +group +name +/ +/ +can +never +be +invalid +UTF +- +8 +so +if +we +have +invalid +UTF +- +8 +then +we +can +/ +/ +safely +return +None +. +let +cap += +match +str +: +: +from_utf8 +( +& +rep +[ +start +. +. +i +] +) +{ +Err +( +_ +) += +> +return +None +Ok +( +cap +) += +> +cap +} +; +Some +( +CaptureRef +{ +cap +: +match +cap +. +parse +: +: +< +u32 +> +( +) +{ +Ok +( +i +) += +> +Ref +: +: +Number +( +i +as +usize +) +Err +( +_ +) += +> +Ref +: +: +Named +( +cap +) +} +end +: +i ++ +1 +} +) +} +/ +/ +/ +Returns +true +if +and +only +if +the +given +byte +is +allowed +in +a +capture +name +. +fn +is_valid_cap_letter +( +b +: +u8 +) +- +> +bool +{ +match +b +{ +b +' +0 +' +. +. += +b +' +9 +' +| +b +' +a +' +. +. += +b +' +z +' +| +b +' +A +' +. +. += +b +' +Z +' +| +b +' +_ +' += +> +true +_ += +> +false +} +} +# +[ +cfg +( +test +) +] +mod +tests +{ +use +super +: +: +{ +find_cap_ref +CaptureRef +} +; +macro_rules +! +find +{ +( +name +: +ident +text +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +assert_eq +! +( +None +find_cap_ref +( +text +. +as_bytes +( +) +) +) +; +} +} +; +( +name +: +ident +text +: +expr +capref +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +assert_eq +! +( +Some +( +capref +) +find_cap_ref +( +text +. +as_bytes +( +) +) +) +; +} +} +; +} +macro_rules +! +c +{ +( +name_or_number +: +expr +pos +: +expr +) += +> +{ +CaptureRef +{ +cap +: +name_or_number +. +into +( +) +end +: +pos +} +} +; +} +find +! +( +find_cap_ref1 +" +foo +" +c +! +( +" +foo +" +4 +) +) +; +find +! +( +find_cap_ref2 +" +{ +foo +} +" +c +! +( +" +foo +" +6 +) +) +; +find +! +( +find_cap_ref3 +" +0 +" +c +! +( +0 +2 +) +) +; +find +! +( +find_cap_ref4 +" +5 +" +c +! +( +5 +2 +) +) +; +find +! +( +find_cap_ref5 +" +10 +" +c +! +( +10 +3 +) +) +; +/ +/ +See +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +pull +/ +585 +/ +/ +for +more +on +characters +following +numbers +find +! +( +find_cap_ref6 +" +42a +" +c +! +( +" +42a +" +4 +) +) +; +find +! +( +find_cap_ref7 +" +{ +42 +} +a +" +c +! +( +42 +5 +) +) +; +find +! +( +find_cap_ref8 +" +{ +42 +" +) +; +find +! +( +find_cap_ref9 +" +{ +42 +" +) +; +find +! +( +find_cap_ref10 +" +0 +" +) +; +find +! +( +find_cap_ref11 +" +" +) +; +find +! +( +find_cap_ref12 +" +" +) +; +find +! +( +find_cap_ref13 +" +" +) +; +find +! +( +find_cap_ref14 +" +1 +- +2 +" +c +! +( +1 +2 +) +) +; +find +! +( +find_cap_ref15 +" +1_ +2 +" +c +! +( +" +1_ +" +3 +) +) +; +find +! +( +find_cap_ref16 +" +x +- +y +" +c +! +( +" +x +" +2 +) +) +; +find +! +( +find_cap_ref17 +" +x_ +y +" +c +! +( +" +x_ +" +3 +) +) +; +find +! +( +find_cap_ref18 +" +{ +# +} +" +c +! +( +" +# +" +4 +) +) +; +find +! +( +find_cap_ref19 +" +{ +Z +[ +} +" +c +! +( +" +Z +[ +" +5 +) +) +; +} diff --git a/third_party/rust/regex/src/find_byte.rs b/third_party/rust/regex/src/find_byte.rs index e13f4080860ea..08e00be25f9e6 100644 --- a/third_party/rust/regex/src/find_byte.rs +++ b/third_party/rust/regex/src/find_byte.rs @@ -52,9 +52,6 @@ time implementation . pub -( -crate -) fn find_byte ( @@ -162,10 +159,13 @@ Option usize > { +use memchr : : memchr +; +memchr ( needle haystack diff --git a/third_party/rust/regex-syntax/src/rank.rs b/third_party/rust/regex/src/freqs.rs similarity index 97% rename from third_party/rust/regex-syntax/src/rank.rs rename to third_party/rust/regex/src/freqs.rs index 8c987d227afb7..9caf6f3568e8a 100644 --- a/third_party/rust/regex-syntax/src/rank.rs +++ b/third_party/rust/regex/src/freqs.rs @@ -1,7 +1,27 @@ +/ +/ +NOTE +: +The +following +code +was +generated +by +" +scripts +/ +frequencies +. +py +" +do +not +/ +/ +edit +directly pub -( -crate -) const BYTE_FREQUENCIES : diff --git a/third_party/rust/regex/src/input.rs b/third_party/rust/regex/src/input.rs new file mode 100644 index 0000000000000..02753678ceb17 --- /dev/null +++ b/third_party/rust/regex/src/input.rs @@ -0,0 +1,3100 @@ +use +std +: +: +char +; +use +std +: +: +cmp +: +: +Ordering +; +use +std +: +: +fmt +; +use +std +: +: +ops +; +use +std +: +: +u32 +; +use +crate +: +: +literal +: +: +LiteralSearcher +; +use +crate +: +: +prog +: +: +InstEmptyLook +; +use +crate +: +: +utf8 +: +: +{ +decode_last_utf8 +decode_utf8 +} +; +/ +/ +/ +Represents +a +location +in +the +input +. +# +[ +derive +( +Clone +Copy +Debug +) +] +pub +struct +InputAt +{ +pos +: +usize +c +: +Char +byte +: +Option +< +u8 +> +len +: +usize +} +impl +InputAt +{ +/ +/ +/ +Returns +true +iff +this +position +is +at +the +beginning +of +the +input +. +pub +fn +is_start +( +& +self +) +- +> +bool +{ +self +. +pos += += +0 +} +/ +/ +/ +Returns +true +iff +this +position +is +past +the +end +of +the +input +. +pub +fn +is_end +( +& +self +) +- +> +bool +{ +self +. +c +. +is_none +( +) +& +& +self +. +byte +. +is_none +( +) +} +/ +/ +/ +Returns +the +character +at +this +position +. +/ +/ +/ +/ +/ +/ +If +this +position +is +just +before +or +after +the +input +then +an +absent +/ +/ +/ +character +is +returned +. +pub +fn +char +( +& +self +) +- +> +Char +{ +self +. +c +} +/ +/ +/ +Returns +the +byte +at +this +position +. +pub +fn +byte +( +& +self +) +- +> +Option +< +u8 +> +{ +self +. +byte +} +/ +/ +/ +Returns +the +UTF +- +8 +width +of +the +character +at +this +position +. +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +len +} +/ +/ +/ +Returns +whether +the +UTF +- +8 +width +of +the +character +at +this +position +/ +/ +/ +is +zero +. +pub +fn +is_empty +( +& +self +) +- +> +bool +{ +self +. +len += += +0 +} +/ +/ +/ +Returns +the +byte +offset +of +this +position +. +pub +fn +pos +( +& +self +) +- +> +usize +{ +self +. +pos +} +/ +/ +/ +Returns +the +byte +offset +of +the +next +position +in +the +input +. +pub +fn +next_pos +( +& +self +) +- +> +usize +{ +self +. +pos ++ +self +. +len +} +} +/ +/ +/ +An +abstraction +over +input +used +in +the +matching +engines +. +pub +trait +Input +: +fmt +: +: +Debug +{ +/ +/ +/ +Return +an +encoding +of +the +position +at +byte +offset +i +. +fn +at +( +& +self +i +: +usize +) +- +> +InputAt +; +/ +/ +/ +Return +the +Unicode +character +occurring +next +to +at +. +/ +/ +/ +/ +/ +/ +If +no +such +character +could +be +decoded +then +Char +is +absent +. +fn +next_char +( +& +self +at +: +InputAt +) +- +> +Char +; +/ +/ +/ +Return +the +Unicode +character +occurring +previous +to +at +. +/ +/ +/ +/ +/ +/ +If +no +such +character +could +be +decoded +then +Char +is +absent +. +fn +previous_char +( +& +self +at +: +InputAt +) +- +> +Char +; +/ +/ +/ +Return +true +if +the +given +empty +width +instruction +matches +at +the +/ +/ +/ +input +position +given +. +fn +is_empty_match +( +& +self +at +: +InputAt +empty +: +& +InstEmptyLook +) +- +> +bool +; +/ +/ +/ +Scan +the +input +for +a +matching +prefix +. +fn +prefix_at +( +& +self +prefixes +: +& +LiteralSearcher +at +: +InputAt +) +- +> +Option +< +InputAt +> +; +/ +/ +/ +The +number +of +bytes +in +the +input +. +fn +len +( +& +self +) +- +> +usize +; +/ +/ +/ +Whether +the +input +is +empty +. +fn +is_empty +( +& +self +) +- +> +bool +{ +self +. +len +( +) += += +0 +} +/ +/ +/ +Return +the +given +input +as +a +sequence +of +bytes +. +fn +as_bytes +( +& +self +) +- +> +& +[ +u8 +] +; +} +impl +< +' +a +T +: +Input +> +Input +for +& +' +a +T +{ +fn +at +( +& +self +i +: +usize +) +- +> +InputAt +{ +( +* +* +self +) +. +at +( +i +) +} +fn +next_char +( +& +self +at +: +InputAt +) +- +> +Char +{ +( +* +* +self +) +. +next_char +( +at +) +} +fn +previous_char +( +& +self +at +: +InputAt +) +- +> +Char +{ +( +* +* +self +) +. +previous_char +( +at +) +} +fn +is_empty_match +( +& +self +at +: +InputAt +empty +: +& +InstEmptyLook +) +- +> +bool +{ +( +* +* +self +) +. +is_empty_match +( +at +empty +) +} +fn +prefix_at +( +& +self +prefixes +: +& +LiteralSearcher +at +: +InputAt +) +- +> +Option +< +InputAt +> +{ +( +* +* +self +) +. +prefix_at +( +prefixes +at +) +} +fn +len +( +& +self +) +- +> +usize +{ +( +* +* +self +) +. +len +( +) +} +fn +as_bytes +( +& +self +) +- +> +& +[ +u8 +] +{ +( +* +* +self +) +. +as_bytes +( +) +} +} +/ +/ +/ +An +input +reader +over +characters +. +# +[ +derive +( +Clone +Copy +Debug +) +] +pub +struct +CharInput +< +' +t +> +( +& +' +t +[ +u8 +] +) +; +impl +< +' +t +> +CharInput +< +' +t +> +{ +/ +/ +/ +Return +a +new +character +input +reader +for +the +given +string +. +pub +fn +new +( +s +: +& +' +t +[ +u8 +] +) +- +> +CharInput +< +' +t +> +{ +CharInput +( +s +) +} +} +impl +< +' +t +> +ops +: +: +Deref +for +CharInput +< +' +t +> +{ +type +Target += +[ +u8 +] +; +fn +deref +( +& +self +) +- +> +& +[ +u8 +] +{ +self +. +0 +} +} +impl +< +' +t +> +Input +for +CharInput +< +' +t +> +{ +fn +at +( +& +self +i +: +usize +) +- +> +InputAt +{ +if +i +> += +self +. +len +( +) +{ +InputAt +{ +pos +: +self +. +len +( +) +c +: +None +. +into +( +) +byte +: +None +len +: +0 +} +} +else +{ +let +c += +decode_utf8 +( +& +self +[ +i +. +. +] +) +. +map +( +| +( +c +_ +) +| +c +) +. +into +( +) +; +InputAt +{ +pos +: +i +c +byte +: +None +len +: +c +. +len_utf8 +( +) +} +} +} +fn +next_char +( +& +self +at +: +InputAt +) +- +> +Char +{ +at +. +char +( +) +} +fn +previous_char +( +& +self +at +: +InputAt +) +- +> +Char +{ +decode_last_utf8 +( +& +self +[ +. +. +at +. +pos +( +) +] +) +. +map +( +| +( +c +_ +) +| +c +) +. +into +( +) +} +fn +is_empty_match +( +& +self +at +: +InputAt +empty +: +& +InstEmptyLook +) +- +> +bool +{ +use +crate +: +: +prog +: +: +EmptyLook +: +: +* +; +match +empty +. +look +{ +StartLine += +> +{ +let +c += +self +. +previous_char +( +at +) +; +at +. +pos +( +) += += +0 +| +| +c += += +' +\ +n +' +} +EndLine += +> +{ +let +c += +self +. +next_char +( +at +) +; +at +. +pos +( +) += += +self +. +len +( +) +| +| +c += += +' +\ +n +' +} +StartText += +> +at +. +pos +( +) += += +0 +EndText += +> +at +. +pos +( +) += += +self +. +len +( +) +WordBoundary += +> +{ +let +( +c1 +c2 +) += +( +self +. +previous_char +( +at +) +self +. +next_char +( +at +) +) +; +c1 +. +is_word_char +( +) +! += +c2 +. +is_word_char +( +) +} +NotWordBoundary += +> +{ +let +( +c1 +c2 +) += +( +self +. +previous_char +( +at +) +self +. +next_char +( +at +) +) +; +c1 +. +is_word_char +( +) += += +c2 +. +is_word_char +( +) +} +WordBoundaryAscii += +> +{ +let +( +c1 +c2 +) += +( +self +. +previous_char +( +at +) +self +. +next_char +( +at +) +) +; +c1 +. +is_word_byte +( +) +! += +c2 +. +is_word_byte +( +) +} +NotWordBoundaryAscii += +> +{ +let +( +c1 +c2 +) += +( +self +. +previous_char +( +at +) +self +. +next_char +( +at +) +) +; +c1 +. +is_word_byte +( +) += += +c2 +. +is_word_byte +( +) +} +} +} +fn +prefix_at +( +& +self +prefixes +: +& +LiteralSearcher +at +: +InputAt +) +- +> +Option +< +InputAt +> +{ +prefixes +. +find +( +& +self +[ +at +. +pos +( +) +. +. +] +) +. +map +( +| +( +s +_ +) +| +self +. +at +( +at +. +pos +( +) ++ +s +) +) +} +fn +len +( +& +self +) +- +> +usize +{ +self +. +0 +. +len +( +) +} +fn +as_bytes +( +& +self +) +- +> +& +[ +u8 +] +{ +self +. +0 +} +} +/ +/ +/ +An +input +reader +over +bytes +. +# +[ +derive +( +Clone +Copy +Debug +) +] +pub +struct +ByteInput +< +' +t +> +{ +text +: +& +' +t +[ +u8 +] +only_utf8 +: +bool +} +impl +< +' +t +> +ByteInput +< +' +t +> +{ +/ +/ +/ +Return +a +new +byte +- +based +input +reader +for +the +given +string +. +pub +fn +new +( +text +: +& +' +t +[ +u8 +] +only_utf8 +: +bool +) +- +> +ByteInput +< +' +t +> +{ +ByteInput +{ +text +only_utf8 +} +} +} +impl +< +' +t +> +ops +: +: +Deref +for +ByteInput +< +' +t +> +{ +type +Target += +[ +u8 +] +; +fn +deref +( +& +self +) +- +> +& +[ +u8 +] +{ +self +. +text +} +} +impl +< +' +t +> +Input +for +ByteInput +< +' +t +> +{ +fn +at +( +& +self +i +: +usize +) +- +> +InputAt +{ +if +i +> += +self +. +len +( +) +{ +InputAt +{ +pos +: +self +. +len +( +) +c +: +None +. +into +( +) +byte +: +None +len +: +0 +} +} +else +{ +InputAt +{ +pos +: +i +c +: +None +. +into +( +) +byte +: +self +. +get +( +i +) +. +cloned +( +) +len +: +1 +} +} +} +fn +next_char +( +& +self +at +: +InputAt +) +- +> +Char +{ +decode_utf8 +( +& +self +[ +at +. +pos +( +) +. +. +] +) +. +map +( +| +( +c +_ +) +| +c +) +. +into +( +) +} +fn +previous_char +( +& +self +at +: +InputAt +) +- +> +Char +{ +decode_last_utf8 +( +& +self +[ +. +. +at +. +pos +( +) +] +) +. +map +( +| +( +c +_ +) +| +c +) +. +into +( +) +} +fn +is_empty_match +( +& +self +at +: +InputAt +empty +: +& +InstEmptyLook +) +- +> +bool +{ +use +crate +: +: +prog +: +: +EmptyLook +: +: +* +; +match +empty +. +look +{ +StartLine += +> +{ +let +c += +self +. +previous_char +( +at +) +; +at +. +pos +( +) += += +0 +| +| +c += += +' +\ +n +' +} +EndLine += +> +{ +let +c += +self +. +next_char +( +at +) +; +at +. +pos +( +) += += +self +. +len +( +) +| +| +c += += +' +\ +n +' +} +StartText += +> +at +. +pos +( +) += += +0 +EndText += +> +at +. +pos +( +) += += +self +. +len +( +) +WordBoundary += +> +{ +let +( +c1 +c2 +) += +( +self +. +previous_char +( +at +) +self +. +next_char +( +at +) +) +; +c1 +. +is_word_char +( +) +! += +c2 +. +is_word_char +( +) +} +NotWordBoundary += +> +{ +let +( +c1 +c2 +) += +( +self +. +previous_char +( +at +) +self +. +next_char +( +at +) +) +; +c1 +. +is_word_char +( +) += += +c2 +. +is_word_char +( +) +} +WordBoundaryAscii += +> +{ +let +( +c1 +c2 +) += +( +self +. +previous_char +( +at +) +self +. +next_char +( +at +) +) +; +if +self +. +only_utf8 +{ +/ +/ +If +we +must +match +UTF +- +8 +then +we +can +' +t +match +word +/ +/ +boundaries +at +invalid +UTF +- +8 +. +if +c1 +. +is_none +( +) +& +& +! +at +. +is_start +( +) +{ +return +false +; +} +if +c2 +. +is_none +( +) +& +& +! +at +. +is_end +( +) +{ +return +false +; +} +} +c1 +. +is_word_byte +( +) +! += +c2 +. +is_word_byte +( +) +} +NotWordBoundaryAscii += +> +{ +let +( +c1 +c2 +) += +( +self +. +previous_char +( +at +) +self +. +next_char +( +at +) +) +; +if +self +. +only_utf8 +{ +/ +/ +If +we +must +match +UTF +- +8 +then +we +can +' +t +match +word +/ +/ +boundaries +at +invalid +UTF +- +8 +. +if +c1 +. +is_none +( +) +& +& +! +at +. +is_start +( +) +{ +return +false +; +} +if +c2 +. +is_none +( +) +& +& +! +at +. +is_end +( +) +{ +return +false +; +} +} +c1 +. +is_word_byte +( +) += += +c2 +. +is_word_byte +( +) +} +} +} +fn +prefix_at +( +& +self +prefixes +: +& +LiteralSearcher +at +: +InputAt +) +- +> +Option +< +InputAt +> +{ +prefixes +. +find +( +& +self +[ +at +. +pos +( +) +. +. +] +) +. +map +( +| +( +s +_ +) +| +self +. +at +( +at +. +pos +( +) ++ +s +) +) +} +fn +len +( +& +self +) +- +> +usize +{ +self +. +text +. +len +( +) +} +fn +as_bytes +( +& +self +) +- +> +& +[ +u8 +] +{ +self +. +text +} +} +/ +/ +/ +An +inline +representation +of +Option +< +char +> +. +/ +/ +/ +/ +/ +/ +This +eliminates +the +need +to +do +case +analysis +on +Option +< +char +> +to +determine +/ +/ +/ +ordinality +with +other +characters +. +/ +/ +/ +/ +/ +/ +( +The +Option +< +char +> +is +not +related +to +encoding +. +Instead +it +is +used +in +the +/ +/ +/ +matching +engines +to +represent +the +beginning +and +ending +boundaries +of +the +/ +/ +/ +search +text +. +) +# +[ +derive +( +Clone +Copy +Hash +PartialEq +Eq +PartialOrd +Ord +) +] +pub +struct +Char +( +u32 +) +; +impl +fmt +: +: +Debug +for +Char +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +match +char +: +: +from_u32 +( +self +. +0 +) +{ +None += +> +write +! +( +f +" +Empty +" +) +Some +( +c +) += +> +write +! +( +f +" +{ +: +? +} +" +c +) +} +} +} +impl +Char +{ +/ +/ +/ +Returns +true +iff +the +character +is +absent +. +# +[ +inline +] +pub +fn +is_none +( +self +) +- +> +bool +{ +self +. +0 += += +u32 +: +: +MAX +} +/ +/ +/ +Returns +the +length +of +the +character +' +s +UTF +- +8 +encoding +. +/ +/ +/ +/ +/ +/ +If +the +character +is +absent +then +1 +is +returned +. +# +[ +inline +] +pub +fn +len_utf8 +( +self +) +- +> +usize +{ +char +: +: +from_u32 +( +self +. +0 +) +. +map_or +( +1 +| +c +| +c +. +len_utf8 +( +) +) +} +/ +/ +/ +Returns +true +iff +the +character +is +a +word +character +. +/ +/ +/ +/ +/ +/ +If +the +character +is +absent +then +false +is +returned +. +pub +fn +is_word_char +( +self +) +- +> +bool +{ +/ +/ +is_word_character +can +panic +if +the +Unicode +data +for +\ +w +isn +' +t +/ +/ +available +. +However +our +compiler +ensures +that +if +a +Unicode +word +/ +/ +boundary +is +used +then +the +data +must +also +be +available +. +If +it +isn +' +t +/ +/ +then +the +compiler +returns +an +error +. +char +: +: +from_u32 +( +self +. +0 +) +. +map_or +( +false +regex_syntax +: +: +is_word_character +) +} +/ +/ +/ +Returns +true +iff +the +byte +is +a +word +byte +. +/ +/ +/ +/ +/ +/ +If +the +byte +is +absent +then +false +is +returned +. +pub +fn +is_word_byte +( +self +) +- +> +bool +{ +match +char +: +: +from_u32 +( +self +. +0 +) +{ +Some +( +c +) +if +c +< += +' +\ +u +{ +7F +} +' += +> +regex_syntax +: +: +is_word_byte +( +c +as +u8 +) +None +| +Some +( +_ +) += +> +false +} +} +} +impl +From +< +char +> +for +Char +{ +fn +from +( +c +: +char +) +- +> +Char +{ +Char +( +c +as +u32 +) +} +} +impl +From +< +Option +< +char +> +> +for +Char +{ +fn +from +( +c +: +Option +< +char +> +) +- +> +Char +{ +c +. +map_or +( +Char +( +u32 +: +: +MAX +) +| +c +| +c +. +into +( +) +) +} +} +impl +PartialEq +< +char +> +for +Char +{ +# +[ +inline +] +fn +eq +( +& +self +other +: +& +char +) +- +> +bool +{ +self +. +0 += += +* +other +as +u32 +} +} +impl +PartialEq +< +Char +> +for +char +{ +# +[ +inline +] +fn +eq +( +& +self +other +: +& +Char +) +- +> +bool +{ +* +self +as +u32 += += +other +. +0 +} +} +impl +PartialOrd +< +char +> +for +Char +{ +# +[ +inline +] +fn +partial_cmp +( +& +self +other +: +& +char +) +- +> +Option +< +Ordering +> +{ +self +. +0 +. +partial_cmp +( +& +( +* +other +as +u32 +) +) +} +} +impl +PartialOrd +< +Char +> +for +char +{ +# +[ +inline +] +fn +partial_cmp +( +& +self +other +: +& +Char +) +- +> +Option +< +Ordering +> +{ +( +* +self +as +u32 +) +. +partial_cmp +( +& +other +. +0 +) +} +} diff --git a/third_party/rust/regex/src/lib.rs b/third_party/rust/regex/src/lib.rs index 505c56ebbfa61..9bb4f115293c7 100644 --- a/third_party/rust/regex/src/lib.rs +++ b/third_party/rust/regex/src/lib.rs @@ -4,61 +4,33 @@ This crate provides -routines -for -searching -strings -for -matches -of a -[ +library +for +parsing +compiling +and +executing regular -expression -] -( -aka -" -regex -" -) +expressions . -The -regex +Its syntax -supported -by -this -crate is similar to -other -regex -engines +Perl +- +style +regular +expressions but -it lacks -several +a +few features -that -are -not -known -how -to -implement -efficiently -. -This -includes -but -is -not -limited -to +like look -- around and backreferences @@ -66,98 +38,174 @@ backreferences In exchange all -regex searches +execute in -this -crate -have -worst -case -O -( -m -* -n -) +linear time -complexity -where -m -is -proportional +with +respect to the size of the -regex +regular +expression and -n -is -proportional -to +search +text +. +This +crate +' +s +documentation +provides +some +simple +examples +describes +[ +Unicode +support +] +( +# +unicode +) +and +exhaustively +lists the -size -of +[ +supported +syntax +] +( +# +syntax +) +. +For +more +specific +details +on the -string -being -searched +API +for +regular +expressions +please +see +the +documentation +for +the +[ +Regex +] +( +struct +. +Regex . +html +) +type +. +# +Usage +This +crate +is [ -regular -expression +on +crates +. +io ] -: +( https : / / -en -. -wikipedia +crates . -org +io / -wiki +crates / -Regular_expression -If -you -just -want -API -documentation -then -skip +regex +) +and +can +be +used +by +adding +regex to -the -[ -Regex -] -type -. -Otherwise -here +your +dependencies +in +your +project ' s +Cargo +. +toml +. +toml +[ +dependencies +] +regex += +" +1 +" +# +Example +: +find a -quick -example -showing -one -way -of -parsing -the -output +date +General +use of +regular +expressions +in +this +package +involves +compiling +an +expression +and +then +using +it +to +search +split +or +replace +text +. +For +example +to +confirm +that +some +text +resembles a -grep -- -like -program +date : rust use @@ -176,32 +224,24 @@ new ( r " -( -? -m -) -^ -( -[ ^ -: -] -+ -) -: -( -[ -0 -- -9 -] -+ -) -: -( -. -+ -) +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} " ) . @@ -209,1203 +249,692 @@ unwrap ( ) ; -let -hay -= -" -\ -path -/ -to -/ -foo -: -54 -: -Blue -Harvest -path -/ -to -/ -bar -: -90 -: -Something -Something -Something -Dark -Side -path -/ -to -/ -baz -: -3 -: -It -' -s -a -Trap -! -" -; -let -mut -results -= -vec +assert ! -[ -] -; -for ( -_ -[ -path -lineno -line -] -) -in re . -captures_iter -( -hay -) -. -map -( -| -c -| -c -. -extract +is_match ( +" +2014 +- +01 +- +01 +" ) ) -{ -results +; +Notice +the +use +of +the +^ +and +anchors . -push -( -( -path -lineno +In +this +crate +every +expression +is +executed +with +an +implicit . -parse -: -: -< -u64 -> -( -) +* ? -line -) -) -; -} -assert_eq -! -( -results -vec -! +at +the +beginning +and +end +which +allows +it +to +match +anywhere +in +the +text +. +Anchors +can +be +used +to +ensure +that +the +full +text +matches +an +expression +. +This +example +also +demonstrates +the +utility +of [ +raw +strings +] ( -" -path +https +: / -to / -foo -" -54 -" -Blue -Harvest -" -) -( -" -path +doc +. +rust +- +lang +. +org / -to +stable / -bar -" -90 -" -Something -Something -Something -Dark -Side -" +reference +/ +tokens +. +html +# +raw +- +string +- +literals ) -( +in +Rust +which +are +just +like +regular +strings +except +they +are +prefixed +with +an +r +and +do +not +process +any +escape +sequences +. +For +example " -path -/ -to -/ -baz +\ +\ +d " -3 +is +the +same +expression +as +r " -It -' -s -a -Trap -! +\ +d " -) -] -) -; +. # -Ok -: +Example : -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -# -Overview -The -primary -type +Avoid +compiling +the +same +regex in -this -crate +a +loop +It is +an +anti +- +pattern +to +compile +the +same +regular +expression +in a -[ -Regex -] +loop +since +compilation +is +typically +expensive . -Its -most -important -methods -are -as -follows -: -* -[ -Regex -: -: -new -] -compiles +( +It +takes +anywhere +from a +few +microseconds +to +a +few +* +* +milliseconds +* +* +depending +on +the +size +of +the regex -using +. +) +Not +only +is +compilation +itself +expensive +but +this +also +prevents +optimizations +that +reuse +allocations +internally +to the -default -configuration +matching +engines . -A -[ -RegexBuilder -] -permits -setting +In +Rust +it +can +sometimes +be a -non -- -default -configuration +pain +to +pass +regular +expressions +around +if +they +' +re +used +from +inside +a +helper +function . +Instead +we +recommend +using +the +[ +lazy_static +] ( -For -example -case -insensitive -matching -verbose -mode -and -others +https +: +/ +/ +crates . +io +/ +crates +/ +lazy_static ) -* -[ -Regex +crate +to +ensure +that +regular +expressions +are +compiled +exactly +once +. +For +example : +rust +use +lazy_static : -is_match -] -reports -whether -a -match -exists -in -a -particular -haystack -. -* -[ -Regex +: +lazy_static +; +use +regex : : -find -] -reports -the -byte -offsets -of -a -match -in -a -haystack -if -one -exists -. -[ Regex +; +fn +some_helper_function +( +text : +& +str +) +- +> +bool +{ +lazy_static +! +{ +static +ref +RE : -find_iter -] -returns -an -iterator -over -all -such -matches -. -* -[ +Regex += Regex : : -captures -] -returns -a -[ -Captures -] -which -reports -both -the -byte -offsets -of -a -match -in -a -haystack -and -the -byte -offsets -of -each -matching -capture -group -from +new +( +" +. +. +. +" +) +. +unwrap +( +) +; +} +RE +. +is_match +( +text +) +} +fn +main +( +) +{ +} +Specifically +in +this +example the regex -in +will +be +compiled +when +it +is +used +for +the +first +time +. +On +subsequent +uses +it +will +reuse the -haystack +previous +compilation . -[ -Regex -: +# +Example : -captures_iter -] -returns -an -iterator +iterating over -all -such -matches -. -There -is -also -a -[ -RegexSet -] -which -permits -searching +capture +groups +This +crate +provides +convenient +iterators for -multiple -regex -patterns -simultaneously -in +matching +an +expression +repeatedly +against a -single search +string +to +find +successive +non +- +overlapping +matches . -However -it -currently -only -reports -which -patterns -match -and -* -not -* -the -byte -offsets -of +For +example +to +find +all +dates +in a -match -. -Otherwise -this -top -- -level -crate -documentation -is -organized -as -follows +string +and +be +able +to +access +them +by +their +component +pieces : -* -[ -Usage -] -( +rust # -usage -) -shows -how -to -add -the +use regex -crate -to -your -Rust -project -. -* -[ -Examples -] -( +: +: +Regex +; # -examples +fn +main +( ) -provides -a -limited -selection -of -regex -search -examples -. -* -[ -Performance -] +{ +let +re += +Regex +: +: +new ( -# -performance +r +" +( +\ +d +{ +4 +} ) -provides -a -brief -summary -of -how -to -optimize -regex -searching -speed -. -* -[ -Unicode -] +- ( -# -unicode +\ +d +{ +2 +} ) -discusses -support -for -non - -ASCII -patterns -. -* -[ -Syntax -] ( -# -syntax +\ +d +{ +2 +} +) +" ) -enumerates -the -specific -regex -syntax -supported -by -this -crate . -* -[ -Untrusted -input -] +unwrap ( -# -untrusted -- -input ) -discusses -how -this -crate -deals -with -regex -patterns -or -haystacks -that -are -untrusted -. -* -[ -Crate -features -] -( -# -crate +; +let +text += +" +2012 - -features -) -documents -the -Cargo -features -that -can -be -enabled -or -disabled -for -this -crate -. -* -[ -Other -crates -] -( -# -other +03 - -crates -) -links -to -other -crates -in -the -regex -family -. -# -Usage -The -regex -crate -is -[ -on -crates -. -io -] -( -https -: -/ -/ -crates -. -io -/ -crates -/ -regex -) -and -can -be -used -by -adding -regex -to -your -dependencies -in -your -project -' -s -Cargo -. -toml -. -Or -more -simply -just -run -cargo -add -regex -. -Here -is -a -complete -example -that -creates -a -new -Rust -project -adds -a -dependency -on -regex -creates -the -source -code -for -a -regex -search -and -then -runs -the -program -. -First -create -the -project -in -a -new -directory -: -text -mkdir -regex +14 +2013 - -example -cd -regex +01 - -example -cargo -init -Second -add -a -dependency -on -regex -: -text -cargo -add -regex -Third -edit -src -/ -main -. -rs -. -Delete -what -' -s -there +01 and -replace -it -with -this -: -use -regex -: -: -Regex -; -fn -main -( -) -{ -let -re -= -Regex -: -: -new -( -r -" -Hello -( -? -< -name -> -\ -w -+ -) -! +2014 +- +07 +- +05 " -) -. -unwrap -( -) ; -let -Some -( -caps -) -= +for +cap +in re . -captures +captures_iter ( -" -Hello -Murphy -! -" +text ) -else { println ! ( " -no -match -! -" -) -; -return -; +Month +: +{ } -; -println -! -( -" -The -name -is +Day +: +{ +} +Year : { } " & -caps +cap [ -" -name -" +2 ] -) -; -} -Fourth -run -it -with -cargo -run -: -text -cargo -run -Compiling -memchr -v2 -. -5 -. -0 -Compiling -regex -- -syntax -v0 -. -7 -. -1 -Compiling -aho -- -corasick -v1 -. -0 -. -1 -Compiling -regex -v1 -. -8 -. -1 -Compiling -regex -- -example -v0 -. -1 -. -0 -( -/ -tmp -/ -regex -- -example -) -Finished -dev +& +cap [ -unoptimized -+ -debuginfo +3 +] +& +cap +[ +1 ] -target -( -s ) -in -4 -. -22s -Running -target +; +} / -debug / -regex -- -example -The -name -is +Output : -Murphy -The -first -time -you -run +/ +/ +Month +: +03 +Day +: +14 +Year +: +2012 +/ +/ +Month +: +01 +Day +: +01 +Year +: +2013 +/ +/ +Month +: +07 +Day +: +05 +Year +: +2014 +# +} +Notice +that the -program -will -show -more -output -like -above -. -But -subsequent -runs -shouldn -' -t -have -to -re -- -compile +year +is +in the -dependencies +capture +group +indexed +at +1 . -# -Examples This -section -provides -a -few -examples -in -tutorial -style -showing -how -to -search -a -haystack -with -a -regex -. -There -are -more -examples -throughout +is +because the -API -documentation -. -Before -starting -though -it -' -s -worth -defining -a -few -terms -: -* -A -* -* -regex * +entire +match * is -a -Rust -value -whose -type -is -Regex -. -We -use -re -as -a -variable -name -for -a -regex +stored +in +the +capture +group +at +index +0 . -* -A -* -* -pattern -* -* -is +# +Example +: +replacement +with +named +capture +groups +Building +on the -string -that -is -used +previous +example +perhaps +we +' +d +like to -build -a -regex +rearrange +the +date +formats . -We -use -pat -as -a -variable -name -for -a -pattern +This +can +be +done +with +text +replacement . +But +to +make +the +code +clearer +we +can * -A -* -* -haystack -* +name * -is -the -string -that -is -searched -by -a -regex -. -We +our +capture +groups +and use -hay +those +names as -a -variable -name -for -a -haystack -. -Sometimes -the -words -" -regex -" -and -" -pattern -" -are -used -interchangeably -. -General -use -of -regular -expressions +variables in -this -crate -proceeds -by -compiling -a -* -* -pattern -* -* -into -a -* -* -regex -* -* -and -then -using -that -regex -to -search -split -or -replace -parts -of -a -* -* -haystack -* -* -. -# -# -# -Example -: -find -a -middle -initial -We -' -ll -start -off -with -a -very -simple -example +our +replacement +text : -a -regex -that -looks -for -a -specific -name -but -uses -a -wildcard -to -match -a -middle -initial -. -Our -pattern -serves -as -something -like -a -template -that -will -match -a -particular -name -with -* -any -* -middle -initial -. rust +# use regex : : Regex ; -/ -/ -We -use -' -unwrap +# +fn +main ( ) -' -here -because -it -would -be -a -bug -in -our -program -if -the -/ -/ -pattern -failed -to -compile -to -a -regex -. -Panicking -in -the -presence -of -a -bug -/ -/ -is -okay -. +{ let re = @@ -1416,13 +945,44 @@ new ( r " -Homer ( -. +? +P +< +y +> +\ +d +{ +4 +} ) +- +( +? +P +< +m +> \ -. -Simpson +d +{ +2 +} +) +- +( +? +P +< +d +> +\ +d +{ +2 +} +) " ) . @@ -1431,702 +991,786 @@ unwrap ) ; let -hay +before = " -Homer -J -. -Simpson +2012 +- +03 +- +14 +2013 +- +01 +- +01 +and +2014 +- +07 +- +05 " ; let -Some -( -caps -) +after = re . -captures +replace_all ( -hay +before +" +m +/ +d +/ +y +" ) -else -{ -return -} ; assert_eq ! ( +after " -J +03 +/ +14 +/ +2012 +01 +/ +01 +/ +2013 +and +07 +/ +05 +/ +2014 " -& -caps -[ -1 -] ) ; -There +# +} +The +replace +methods are -a -few -things -worth -noticing -here +actually +polymorphic in -our -first -example -: -* -The -. +the +replacement +which +provides +more +flexibility +than is -a -special -pattern -meta -character -that -means -" -match -any -single -character -except -for -new -lines +seen +here . -" ( -More -precisely -in -this -crate -it -means -" -match -any -UTF -- -8 -encoding -of -any -Unicode -scalar -value -other -than -\ -n +See +the +documentation +for +Regex +: +: +replace +for +more +details . -" ) -* -We +Note +that +if +your +regex +gets +complicated +you can -match -an -actual -. -literally -by -escaping -it -i -. -e -. -\ -. -. -* -We use -Rust -' -s -[ -raw -strings -] -to -avoid -needing -to -deal -with -escape -sequences -in -both the -regex -pattern -syntax -and -in -Rust -' -s -string -literal -syntax -. -If -we -didn -' -t -use -raw -strings -here -we -would -have -had +x +flag to +enable +insignificant +whitespace +mode +which +also +lets +you +write +comments +: +rust +# use -\ -\ -. -to -match -a -literal -. -character -. -That -is +regex +: +: +Regex +; +# +fn +main +( +) +{ +let +re += +Regex +: +: +new +( r " +( +? +x +) +( +? +P +< +y +> +\ +d +{ +4 +} +) +# +the +year +- +( +? +P +< +m +> +\ +d +{ +2 +} +) +# +the +month +- +( +? +P +< +d +> \ +d +{ +2 +} +) +# +the +day +" +) . +unwrap +( +) +; +let +before += " +2012 +- +03 +- +14 +2013 +- +01 +- +01 and +2014 +- +07 +- +05 " -\ -\ +; +let +after += +re . +replace_all +( +before " -are -equivalent -patterns -. -* -We -put -our -wildcard -. -instruction -in -parentheses -. -These -parentheses -have -a -special -meaning -that -says +m +/ +d +/ +y " -make -whatever -part -of -the -haystack -matches -within -these -parentheses -available -as -a -capturing -group -. +) +; +assert_eq +! +( +after " -After -finding -a -match -we -access -this -capture -group -with -& -caps -[ -1 -] -. -[ -raw -strings -] -: -https -: +03 / +14 / -doc -. -rust -- -lang -. -org +2012 +01 / -stable +01 / -reference +2013 +and +07 / -tokens -. -html -# -raw -- -string -- -literals -Otherwise -we -execute -a -search -using -re -. -captures -( -hay +05 +/ +2014 +" ) -and -return -from -our -function -if -no -match -occurred -. -We -then -reference -the -middle -initial -by -asking -for -the -part -of -the -haystack -that -matched -the -capture -group -indexed -at -1 -. -( -The -capture -group -at -index -0 -is -implicit -and -always -corresponds +; +# +} +If +you +wish to -the -entire match -. -In +against +whitespace +in this -case -that -' +mode +you +can +still +use +\ s -Homer -J +\ +n +\ +t +etc +. +For +escaping +a +single +space +character +you +can +escape +it +directly +with +\ +use +its +hex +character +code +\ +x20 +or +temporarily +disable +the +x +flag +e . -Simpson +g . +( +? +- +x +: ) -# -# +. # Example : -named -capture -groups -Continuing -from -our -middle -initial -example -above -we -can -tweak -the -pattern -slightly +match +multiple +regular +expressions +simultaneously +This +demonstrates +how to -give +use a -name +RegexSet to +match +multiple +( +possibly +overlapping +) +regular +expressions +in +a +single +scan +of the -group -that -matches -the -middle -initial +search +text : rust use regex : : -Regex +RegexSet ; -/ -/ -Note -that -( -? -P -< -middle -> -. -) -is -a -different -way -to -spell -the -same -thing -. let -re +set = -Regex +RegexSet : : new ( +& +[ r " -Homer -( -? -< -middle -> -. -) \ -. -Simpson +w ++ " -) -. -unwrap -( +r +" +\ +d ++ +" +r +" +\ +pL ++ +" +r +" +foo +" +r +" +bar +" +r +" +barfoo +" +r +" +foobar +" +] +) +. +unwrap +( ) ; +/ +/ +Iterate +over +and +collect +all +of +the +matches +. let -hay +matches +: +Vec +< +_ +> = -" -Homer -J +set . -Simpson +matches +( " -; -let -Some +foobar +" +) +. +into_iter ( -caps ) -= -re . -captures +collect ( -hay ) -else -{ -return -} ; assert_eq ! ( -" -J -" -& -caps +matches +vec +! [ -" -middle -" +0 +2 +3 +4 +6 ] ) ; -Giving -a -name -to -a -group +/ +/ +You can -be -useful -when -there -are -multiple -groups -in -a -pattern -. -It -makes -the -code -referring -to -those -groups -a -bit -easier -to -understand -. -# -# -# -Example -: -validating -a -particular -date -format -This -examples -shows -how -to -confirm +also +test whether a -haystack -in -its -entirety -matches -a particular -date -format -: -rust -use regex +matched : -: -Regex -; let -re +matches = -Regex -: -: -new +set +. +matches ( -r " -^ -\ -d -{ -4 -} -- -\ -d -{ -2 -} -- -\ -d -{ -2 -} +foobar " ) +; +assert +! +( +! +matches . -unwrap +matched ( +5 +) ) ; assert ! ( -re +matches . -is_match +matched ( -" -2010 -- -03 -- -14 -" +6 ) ) ; -Notice -the +# +Pay +for +what +you use -of -the -^ -and -anchors -. -In -this -crate -every -regex -search -is -run +With +respect +to +searching +text with -an -implicit -( -? -s +a +regular +expression +there +are +three +questions +that +can +be +asked : +1 . -) -* -? -at -the -beginning -of -its -pattern -which -allows +Does the -regex -to +text match -anywhere -in -a -haystack +this +expression +? +2 . -Anchors -as -above -can -be -used +If +so +where +does +it +match +? +3 +. +Where +did +the +capturing +groups +match +? +Generally +speaking +this +crate +could +provide +a +function to -ensure -that +answer +only +# +3 +which +would +subsume +# +1 +and +# +2 +automatically +. +However +it +can +be +significantly +more +expensive +to +compute the -full -haystack +location +of +capturing +group +matches +so +it +' +s +best +not +to +do +it +if +you +don +' +t +need +to +. +Therefore +only +use +what +you +need +. +For +example +don +' +t +use +find +if +you +only +need +to +test +if +an +expression matches a -pattern +string +. +( +Use +is_match +instead . +) +# +Unicode This -crate +implementation +executes +regular +expressions +* +* +only +* +* +on +valid +UTF +- +8 +while +exposing +match +locations +as +byte +indices +into +the +search +string +. +( +To +relax +this +restriction +use +the +[ +bytes +] +( +bytes +/ +index +. +html +) +sub +- +module +. +) +Only +simple +case +folding is -also -Unicode -aware +supported +. +Namely +when +matching +case +- +insensitively +the +characters +are +first +mapped +using +the +" +simple +" +case +folding +rules +defined by -default -which +Unicode +. +Regular +expressions +themselves +are +* +* +only +* +* +interpreted +as +a +sequence +of +Unicode +scalar +values +. +This means -that -\ -d -might -match -more -than you -might -expect -it -to -. -For -example +can +use +Unicode +characters +directly +in +your +expression : rust +# use regex : : Regex ; +# +fn +main +( +) +{ let re = @@ -2137,24 +1781,11 @@ new ( r " -^ -\ -d -{ -4 -} -- -\ -d -{ -2 -} -- -\ -d -{ -2 -} +( +? +i +) ++ " ) . @@ -2162,370 +1793,239 @@ unwrap ( ) ; -assert -! -( +let +mat += re . -is_match +find ( " -- -- " ) -) +. +unwrap +( +) ; -To -only -match -an -ASCII -decimal -digit -all +assert_eq +! +( +( +mat +. +start +( +) +mat +. +end +( +) +) +( +0 +6 +) +) +; +# +} +Most +features of the -following +regular +expressions +in +this +crate +are +Unicode +aware +. +Here are -equivalent +some +examples : * -[ -0 +. +will +match +any +valid +UTF - -9 -] -* +8 +encoded +Unicode +scalar +value +except +for +\ +n +. +( +To +also +match +\ +n +enable +the +s +flag +e +. +g +. ( ? -- -u +s : -\ -d +. +) +. ) * -[ -[ -: -digit -: -] -] -* -[ +\ +w \ d -& -& +and \ -p -{ -ascii -} -] -# -# -# -Example -: -finding -dates -in -a -haystack -In -the -previous +s +are +Unicode +aware +. +For example -we -showed -how -one -might -validate -that -a -haystack -in -its -entirety -corresponded -to +\ +s +will +match +all +forms +of +whitespace +categorized +by +Unicode +. +* +\ +b +matches a -particular -date -format +Unicode +word +boundary . -But -what -if -we -wanted -to -extract -all -things -that -look +* +Negated +character +classes like -dates -in -a -specific -format -from +[ +^ a -haystack -? -To -do -this -we -can -use -an -iterator -API -to -find +] +match all -matches -( -notice -that -we -' -ve -removed -the -anchors -and -switched -to -looking +Unicode +scalar +values +except for -ASCII +a +. +* +^ +and +are +* +* +not +* +* +Unicode +aware +in +multi - +line +mode +. +Namely +they only -digits -) -: -rust -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -[ -0 -- -9 -] -{ -4 -} -- -[ -0 -- -9 -] -{ -2 -} -- -[ -0 -- -9 -] -{ -2 -} -" -) -. -unwrap -( -) -; -let -hay -= -" -What -do -1865 -- -04 -- -14 -1881 -- -07 -- -02 -1901 -- -09 -- -06 -and -1963 -- -11 -- -22 -have -in -common -? -" -; -/ -/ -' -m -' -is -a -' -Match -' +recognize +\ +n and -' -as_str -( -) -' -returns -the -matching -part +not +any of the -haystack -. -let -dates -: -Vec -< -& -str -> -= -re -. -find_iter -( -hay -) -. -map -( -| -m -| -m +other +forms +of +line +terminators +defined +by +Unicode . -as_str -( -) -) +Unicode +general +categories +scripts +script +extensions +ages +and +a +smattering +of +boolean +properties +are +available +as +character +classes . -collect -( -) -; -assert_eq -! -( -dates -vec -! -[ -" -1865 -- -04 -- -14 -" -" -1881 -- -07 -- -02 -" -" -1901 -- -09 -- -06 -" -" -1963 -- -11 -- -22 -" -] -) -; -We +For +example +you can -also -iterate -over -[ -Captures -] -values -instead -of -[ -Match -] -values -and -that -in -turn -permits -accessing -each -component +match +a +sequence of -the -date -via -capturing -groups +numerals +Greek +or +Cherokee +letters : rust +# use regex : : Regex ; +# +fn +main +( +) +{ let re = @@ -2536,50 +2036,21 @@ new ( r " -( -? -< -y -> [ -0 -- -9 -] +\ +pN +\ +p { -4 +Greek } -) -- -( -? -< -m -> -[ -0 -- -9 -] +\ +p { -2 +Cherokee } -) -- -( -? -< -d -> -[ -0 -- -9 ] -{ -2 -} -) ++ " ) . @@ -2588,1790 +2059,1774 @@ unwrap ) ; let -hay +mat = +re +. +find +( " -What -do -1865 -- -04 -- -14 -1881 -- -07 -- -02 -1901 -- -09 -- -06 -and -1963 -- -11 -- -22 -have -in -common -? +abc +xyz " -; -/ -/ -' -m -' -is -a -' -Match -' -and -' -as_str -( ) -' -returns -the -matching -part -of -the -haystack . -let -dates -: -Vec -< +unwrap ( -& -str -& -str -& -str ) -> -= -re +; +assert_eq +! +( +( +mat . -captures_iter +start ( -hay ) +mat . -map +end ( -| -caps -| -{ +) +) +( +3 +23 +) +) +; +# +} +For +a +more +detailed +breakdown +of +Unicode +support +with +respect +to +[ +UTS +# +18 +] +( +https +: / / -The -unwraps -are -okay -because -every -capture -group -must -match -if +unicode +. +org +/ +reports +/ +tr18 +/ +) +please +see the -whole +[ +UNICODE +] +( +https +: / / -regex -matches -and -in -this -context -we -know -we -have -a -match +github . +com / +rust +- +lang / +regex / +blob / -Note -that -we -use -caps -. -name -( -" -y -" -) +master +/ +UNICODE . -unwrap -( +md ) +document +in +the +root +of +the +regex +repository . -as_str -( -) -instead +# +Opt +out of -/ -/ +Unicode +support +The +bytes +sub +- +module +provides +a +Regex +type +that +can +be +used +to +match +on & -caps [ -" -y -" +u8 ] -because -the -lifetime -of -the -former +. +By +default +text is -the -same +interpreted as +UTF +- +8 +just +like +it +is +with the -/ -/ -lifetime -of -hay -above -but +main +Regex +type +. +However +this +behavior +can +be +disabled +by +turning +off the -lifetime -of +u +flag +even +if +doing +so +could +result +in +matching +invalid +UTF +- +8 +. +For +example +when the -latter +u +flag is -tied -to -the -/ -/ -lifetime +disabled +. +will +match +any +byte +instead of -caps -due -to -how +any +Unicode +scalar +value +. +Disabling the -Index -trait +u +flag is -defined -. -let -year -= -caps -. -name -( -" -y -" -) +also +possible +with +the +standard +& +str +- +based +Regex +type +but +it +is +only +allowed +where +the +UTF +- +8 +invariant +is +maintained . -unwrap +For +example ( +? +- +u +: +\ +w ) -. -as_str +is +an +ASCII +- +only +\ +w +character +class +and +is +legal +in +an +& +str +- +based +Regex +but ( +? +- +u +: +\ +xFF ) -; -let -month -= -caps +will +attempt +to +match +the +raw +byte +\ +xFF +which +is +invalid +UTF +- +8 +and +therefore +is +illegal +in +& +str +- +based +regexes . -name -( -" -m -" -) +Finally +since +Unicode +support +requires +bundling +large +Unicode +data +tables +this +crate +exposes +knobs +to +disable +the +compilation +of +those +data +tables +which +can +be +useful +for +shrinking +binary +size +and +reducing +compilation +times . -unwrap +For +details +on +how +to +do +that +see +the +section +on +[ +crate +features +] ( +# +crate +- +features ) . -as_str +# +Syntax +The +syntax +supported +in +this +crate +is +documented +below +. +Note +that +the +regular +expression +parser +and +abstract +syntax +are +exposed +in +a +separate +crate +[ +regex +- +syntax +] ( +https +: +/ +/ +docs +. +rs +/ +regex +- +syntax ) -; -let -day -= -caps . -name -( +# +# +Matching +one +character +< +pre +class += " -d +rust " -) -. -unwrap -( -) +> . -as_str +any +character +except +new +line ( +includes +new +line +with +s +flag ) -; +\ +d +digit ( -year -month -day -) +\ +p +{ +Nd } ) -. -collect -( -) -; -assert_eq -! -( -dates -vec -! -[ -( -" -1865 -" -" -04 -" -" -14 -" -) +\ +D +not +digit +\ +pN +One +- +letter +name +Unicode +character +class +\ +p +{ +Greek +} +Unicode +character +class ( -" -1881 -" -" -07 -" -" -02 -" +general +category +or +script ) +\ +PN +Negated +one +- +letter +name +Unicode +character +class +\ +P +{ +Greek +} +negated +Unicode +character +class ( -" -1901 -" -" -09 -" -" -06 -" +general +category +or +script ) -( -" -1963 -" -" -11 -" +< +/ +pre +> +# +# +# +Character +classes +< +pre +class += " -22 +rust " -) +> +[ +xyz ] +A +character +class +matching +either +x +y +or +z +( +union ) -; -# -# -# -Example -: -simpler -capture -group -extraction -One -can -use +. [ -Captures -: -: -extract +^ +xyz ] -to -make -the -code -from -the -previous -example +A +character +class +matching +any +character +except +x +y +and +z +. +[ a -bit -simpler +- +z +] +A +character +class +matching +any +character in -this -case -: -rust -use -regex -: -: -Regex -; -let -re -= -Regex +range +a +- +z +. +[ +[ : +alpha : -new -( -r -" +] +] +ASCII +character +class ( [ -0 +A - -9 +Za +- +z ] -{ -4 -} ) -- +[ +[ +: +^ +alpha +: +] +] +Negated +ASCII +character +class ( [ -0 +^ +A - -9 +Za +- +z ] -{ -2 -} ) +[ +x +[ +^ +xyz +] +] +Nested +/ +grouping +character +class +( +matching +any +character +except +y +and +z +) +[ +a - +y +& +& +xyz +] +Intersection ( +matching +x +or +y +) [ 0 - 9 -] -{ -2 -} -) -" -) -. -unwrap +& +& +[ +^ +4 +] +] +Subtraction +using +intersection +and +negation ( +matching +0 +- +9 +except +4 ) -; -let -hay -= -" -What -do -1865 +[ +0 - -04 +9 - -14 -1881 - -07 +4 +] +Direct +subtraction +( +matching +0 - -02 -1901 +9 +except +4 +) +[ +a - -09 +g +~ +~ +b - -06 +h +] +Symmetric +difference +( +matching +a and -1963 -- -11 -- -22 -have +h +only +) +[ +\ +[ +\ +] +] +Escaping in -common -? -" -; -let -dates -: -Vec -< +character +classes ( -& -str -& -str -& -str +matching +[ +or +] ) +< +/ +pre > -= -re +Any +named +character +class +may +appear +inside +a +bracketed +[ +. . -captures_iter -( -hay -) . -map -( -| -caps -| -{ -let -( -_ -[ -year -month -day ] -) -= -caps +character +class . -extract -( -) -; -( -year -month -day -) +For +example +[ +\ +p +{ +Greek } -) -. -collect -( -) -; -assert_eq -! -( -dates -vec -! [ -( -" -1865 -" -" -04 -" -" -14 -" -) -( -" -1881 -" -" -07 -" -" -02 -" -) -( -" -1901 -" -" -09 -" -" -06 -" -) -( -" -1963 -" -" -11 -" -" -22 -" -) -] -) -; -Captures : +digit : -extract -works -by -ensuring -that -the -number -of -matching -groups -match -the -number -of -groups -requested -via -the +] +] +matches +any +Greek +or +ASCII +digit +. [ -year -month -day +\ +p +{ +Greek +} +& +& +\ +pL ] -syntax +matches +Greek +letters . -If -they -do -then -the -substrings -for -each -corresponding -capture -group -are -automatically -returned +Precedence in -an -appropriately -sized -array -. -Rust -' -s -syntax -for -pattern -matching -arrays -does -the -rest +character +classes +from +most +binding +to +least +: +1 . -# -# -# -Example +Ranges : -replacement -with -named -capture -groups -Building -on -the -previous -example -perhaps -we -' +a +- +cd += += +[ +a +- +c +] d -like -to -rearrange -the -date -formats -. -This -can -be -done -by -finding -each -match -and -replacing -it -with -something -different +2 . -The -[ -Regex -: +Union : -replace_all +ab +& +& +bc += += +[ +ab ] -routine -provides -a -convenient -way -to -do -this -including -by -supporting -references -to -named -groups -in -the -replacement -string -: -rust -use -regex -: +& +& +[ +bc +] +3 +. +Intersection : -Regex -; -let -re +^ +a +- +z +& +& +b += += +^ +[ +a +- +z +& +& +b +] +4 +. +Negation +# +# +Composites +< +pre +class = -Regex -: -: -new -( -r " +rust +" +> +xy +concatenation ( -? -< +x +followed +by y -> -\ -d -{ -4 -} ) -- +x +| +y +alternation ( -? -< -m -> -\ -d -{ -2 -} +x +or +y +prefer +x ) -- -( -? < -d +/ +pre > -\ -d -{ -2 -} -) -" -) -. -unwrap -( -) -; -let -before +# +# +Repetitions +< +pre +class = " -1973 -- -01 -- -05 -1975 -- -08 -- -25 -and -1980 -- -10 -- -18 +rust " -; -let -after -= -re -. -replace_all +> +x +* +zero +or +more +of +x ( -before -" -m -/ -d -/ -y -" +greedy ) -; -assert_eq -! +x ++ +one +or +more +of +x ( -after -" -01 -/ -05 -/ -1973 -08 -/ -25 -/ -1975 -and -10 -/ -18 -/ -1980 -" -) -; -The -replace -methods -are -actually -polymorphic -in -the -replacement -which -provides -more -flexibility -than -is -seen -here -. -( -See -the -documentation -for -[ -Regex -: -: -replace -] -for -more -details -. +greedy ) -# -# -# -Example -: -verbose -mode -When -your -regex -gets -complicated -you -might -consider -using -something -other -than -regex -. -But -if -you -stick -with -regex -you -can -use -the x -flag -to -enable -insignificant -whitespace -mode +? +zero or -" -verbose -mode -. -" -In -this -mode -whitespace -is -treated -as -insignificant -and one -may -write -comments -. -This -may -make -your -patterns -easier -to -comprehend -. -rust -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" +of +x ( +greedy +) +x +* ? +zero +or +more +of x +( +ungreedy +/ +lazy ) +x ++ +? +one +or +more +of +x ( +ungreedy +/ +lazy +) +x ? -P -< -y -> -\ -d +? +zero +or +one +of +x +( +ungreedy +/ +lazy +) +x { -4 +n +m } +at +least +n +x +and +at +most +m +x +( +greedy ) -# -the -year -including -all -Unicode -digits -- +x +{ +n +} +at +least +n +x ( +greedy +) +x +{ +n +} +exactly +n +x +x +{ +n +m +} ? -P -< +at +least +n +x +and +at +most m -> -\ -d +x +( +ungreedy +/ +lazy +) +x { -2 +n } -) -# -the -month -including -all -Unicode -digits -- +? +at +least +n +x ( +ungreedy +/ +lazy +) +x +{ +n +} ? -P +exactly +n +x < -d +/ +pre > -\ -d -{ -2 -} -) # -the -day -including -all -Unicode -digits -" -) -. -unwrap -( -) -; -let -before +# +Empty +matches +< +pre +class = " -1973 +rust +" +> +^ +the +beginning +of +text +( +or +start - -01 +of - -05 -1975 +line +with +multi - -08 +line +mode +) +the +end +of +text +( +or +end - -25 -and -1980 +of - -10 +line +with +multi - -18 -" -; -let -after -= -re -. -replace_all -( -before -" -m -/ -d -/ -y -" +line +mode ) -; -assert_eq -! +\ +A +only +the +beginning +of +text ( -after -" -01 -/ -05 -/ -1973 -08 -/ -25 -/ -1975 -and -10 -/ -18 -/ -1980 -" -) -; -If -you -wish -to -match -against -whitespace -in -this +even +with +multi +- +line mode -you -can -still -use -\ -s +enabled +) \ -n +z +only +the +end +of +text +( +even +with +multi +- +line +mode +enabled +) \ -t -etc -. -For -escaping +b a -single -space -character -you -can -escape -it -directly -with +Unicode +word +boundary +( \ -use -its -hex -character -code +w +on +one +side +and \ -x20 +W +\ +A or -temporarily -disable +\ +z +on +other +) +\ +B +not +a +Unicode +word +boundary +< +/ +pre +> +The +empty +regex +is +valid +and +matches the -x -flag -e -. -g +empty +string . -( -? -- -x -: -) +For +example +the +empty +regex +matches +abc +at +positions +0 +1 +2 +and +3 . # # -# -Example -: -match -multiple -regular -expressions -simultaneously -This -demonstrates -how -to -use -a -[ -RegexSet -] -to -match -multiple +Grouping +and +flags +< +pre +class += +" +rust +" +> ( -possibly -overlapping +exp +) +numbered +capture +group +( +indexed +by +opening +parenthesis ) -regexes -in -a -single -scan -of -a -haystack -: -rust -use -regex -: -: -RegexSet -; -let -set -= -RegexSet -: -: -new ( +? +P +& +lt +; +name & +gt +; +exp +) +named +( +also +numbered +) +capture +group +( +allowed +chars +: [ -r -" -\ -w -+ -" -r -" +_0 +- +9a +- +zA +- +Z +. \ -d -+ -" -r -" +[ \ -pL -+ -" -r -" -foo -" -r -" -bar -" -r -" -barfoo -" -r -" -foobar -" +] ] ) -. -unwrap ( -) -; -/ -/ -Iterate -over -and -collect -all -of -the -matches -. -Each -match -corresponds -to -the -/ -/ -ID -of -the -matching -pattern -. -let -matches +? : -Vec -< -_ -> -= -set -. -matches -( -" -foobar -" +exp ) -. -into_iter +non +- +capturing +group ( +? +flags ) -. -collect +set +flags +within +current +group ( +? +flags +: +exp ) -; -assert_eq -! +set +flags +for +exp ( -matches -vec -! -[ -0 -2 -3 -4 -6 -] +non +- +capturing ) -; -/ +< / -You -can -also -test -whether +pre +> +Flags +are +each a -particular -regex -matched -: -let -matches -= -set +single +character . -matches +For +example ( -" -foobar -" +? +x ) -; -assert -! -( -! -matches -. -matched +sets +the +flag +x +and ( -5 -) +? +- +x ) -; -assert -! -( -matches +clears +the +flag +x . -matched +Multiple +flags +can +be +set +or +cleared +at +the +same +time +: ( -6 -) +? +xy ) -; -# -Performance -This -section -briefly -discusses -a -few -concerns -regarding -the -speed +sets +both +the +x and -resource -usage -of -regexes +y +flags +and +( +? +x +- +y +) +sets +the +x +flag +and +clears +the +y +flag . -# -# -# -Only -ask -for -what -you -need -When -running -a -search -with -a -regex -there +All +flags are -generally -three -different -types -of -information -one -can -ask -for -: -1 +by +default +disabled +unless +stated +otherwise . -Does -a -regex +They +are +: +< +pre +class += +" +rust +" +> +i +case +- +insensitive +: +letters match -in -a -haystack -? -2 -. -Where -does -a -regex +both +upper +and +lower +case +m +multi +- +line +mode +: +^ +and match -in -a -haystack -? -3 -. -Where -do -each +begin +/ +end of -the -capturing -groups +line +s +allow +. +to match -in -a -haystack +\ +n +U +swap +the +meaning +of +x +* +and +x +* ? -Generally -speaking -this -crate -could -provide -a -function -to -answer -only -# -3 -which -would -subsume -# -1 +u +Unicode +support +( +enabled +by +default +) +x +ignore +whitespace and +allow +line +comments +( +starting +with # -2 -automatically -. -However -it +) +< +/ +pre +> +Flags can be -significantly -more -expensive -to -compute -the -location -of -capturing -group -matches -so -it +toggled +within +a +pattern +. +Here ' s -best -not -to -do -it -if -you -don -' -t -need -to -. -Therefore -only -ask -for -what -you -need -. -For +an example -don -' -t +that +matches +case +- +insensitively +for +the +first +part +but +case +- +sensitively +for +the +second +part +: +rust +# use -[ +regex +: +: +Regex +; +# +fn +main +( +) +{ +let +re += Regex : : -find -] -if -you -only -need -to -test -if -a -regex -matches +new +( +r +" +( +? +i +) a -haystack ++ +( +? +- +i +) +b ++ +" +) . -Use +unwrap +( +) +; +let +cap += +re +. +captures +( +" +AaAaAbbBBBb +" +) +. +unwrap +( +) +; +assert_eq +! +( +& +cap [ -Regex -: -: -is_match +0 ] -instead -. -# -# +" +AaAaAbb +" +) +; # -Unicode -can -impact -memory -usage -and -search -speed -This -crate -has -first -class -support -for -Unicode -and -it -is -* -* -enabled -by -default -* -* -. -In -many -cases +} +Notice +that the -extra -memory -required -to -support -it -will -be -negligible -and -it -typically -won -' -t -impact -search -speed -. -But -it -can -in -some -cases +a ++ +matches +either +a +or +A +but +the +b ++ +only +matches +b . -With -respect -to -memory -usage +Multi +- +line +mode +means +^ +and +no +longer +match +just +at the -impact +beginning +/ +end of -Unicode -principally -manifests -through the -use +input +but +at +the +beginning +/ +end of -Unicode -character -classes -. -Unicode -character -classes -tend -to -be -quite -large -. -For -example +lines +: +# +use +regex +: +: +Regex +; +let +re += +Regex +: +: +new +( +r +" +( +? +m +) +^ +line \ -w -by -default -matches -around -140 -000 -distinct -codepoints +d ++ +" +) . -This -requires -additional -memory -and -tends -to -slow -down -regex -compilation +unwrap +( +) +; +let +m += +re . -While -a +find +( +" +line +one \ -w -here -and -there -is -unlikely -to -be -noticed -writing +nline +2 \ -w -{ -100 -} -will -for -example -result -in -quite -a -large -regex -by -default +n +" +) . -Indeed -\ -w -is -considerably -larger -than -its -ASCII -- -only -version -so -if -your -requirements -are -satisfied -by -ASCII -it -' -s -probably -a -good -idea -to -stick -to -ASCII -classes -. -The -ASCII -- -only -version -of -\ -w -can -be -spelled -in -a -number -of -ways +unwrap +( +) +; +assert_eq +! +( +m . -All -of +as_str +( +) +" +line +2 +" +) +; +Note +that +^ +matches +after +new +lines +even +at the -following -are -equivalent +end +of +input : -* -[ -0 -- -9A -- -Za -- -z_ -] -* -( -? -- -u +# +use +regex : -\ -w -) -* -[ -[ : -word +Regex +; +let +re += +Regex : -] -] -* -[ -\ -w -& -& +: +new +( +r +" +( +? +m +) +^ +" +) +. +unwrap +( +) +; +let +m += +re +. +find_iter +( +" +test \ -p -{ -ascii -} -] -With -respect -to -search -speed -Unicode -tends -to -be -handled -pretty -well -even -when -using -large -Unicode -character -classes +n +" +) . -However -some -of -the -faster -internal -regex -engines -cannot -handle -a -Unicode -aware +last +( +) +. +unwrap +( +) +; +assert_eq +! +( +( +m +. +start +( +) +m +. +end +( +) +) +( +5 +5 +) +) +; +Here +is +an +example +that +uses +an +ASCII word boundary -assertion -. -So -if -you -don -' -t -need +instead +of +a Unicode -- -aware word boundary -assertions -you -might -consider -using +: +rust +# +use +regex +: +: +Regex +; +# +fn +main +( +) +{ +let +re += +Regex +: +: +new +( +r +" ( ? - @@ -4380,9431 +3835,3221 @@ u \ b ) -instead -of -\ -b -where -the -former -uses -an -ASCII +. ++ +( +? - -only -definition -of -a -word -character +u +: +\ +b +) +" +) +. +unwrap +( +) +; +let +cap += +re +. +captures +( +" +abc +" +) . +unwrap +( +) +; +assert_eq +! +( +& +cap +[ +0 +] +" +abc +" +) +; # +} # # -Literals -might -accelerate -searches -This -crate -tends -to -be -quite -good -at -recognizing -literals -in -a -regex -pattern -and -using -them -to -accelerate -a -search -. -If -it -is -at -all -possible -to -include -some -kind -of +Escape +sequences +< +pre +class += +" +rust +" +> +\ +* literal -in -your -pattern -then -it -might -make -search -substantially -faster -. -For -example -in -the -regex +* +works +for +any +punctuation +character +: \ -w +. + +* +? +( +) +| +[ +] +{ +} +^ \ -w -+ -the -engine -will -look -for -occurrences -of -and -then -try a -reverse -match -for +bell +( \ -w -+ -to -find -the -start -position -. -# -# -# -Avoid -re -- -compiling -regexes -especially -in -a -loop -It -is -an -anti -- -pattern +x07 +) +\ +f +form +feed +( +\ +x0C +) +\ +t +horizontal +tab +\ +n +new +line +\ +r +carriage +return +\ +v +vertical +tab +( +\ +x0B +) +\ +123 +octal +character +code +( +up to -compile -the -same -pattern -in -a -loop -since -regex -compilation -is -typically -expensive -. +three +digits +) ( -It -takes -anywhere -from -a -few -microseconds +when +enabled +) +\ +x7F +hex +character +code +( +exactly +two +digits +) +\ +x +{ +10FFFF +} +any +hex +character +code +corresponding to a -few -* -* -milliseconds -* -* -depending -on -the -size -of -the -pattern -. +Unicode +code +point +\ +u007F +hex +character +code +( +exactly +four +digits ) -Not -only -is -compilation -itself -expensive -but -this -also -prevents -optimizations -that -reuse -allocations -internally +\ +u +{ +7F +} +any +hex +character +code +corresponding to -the -regex -engine -. -In -Rust -it -can -sometimes -be a -pain +Unicode +code +point +\ +U0000007F +hex +character +code +( +exactly +eight +digits +) +\ +U +{ +7F +} +any +hex +character +code +corresponding to -pass -regexes -around -if -they -' -re -used -from -inside a -helper -function -. -Instead -we -recommend -using -crates -like -[ -once_cell -] -and -[ -lazy_static -] -to -ensure -that -patterns +Unicode +code +point +< +/ +pre +> +# +# +Perl +character +classes +( +Unicode +friendly +) +These +classes are -compiled -exactly -once -. +based +on +the +definitions +provided +in [ -once_cell +UTS +# +18 ] -: +( https : / / -crates +www . -io -/ -crates -/ -once_cell -[ -lazy_static -] -: -https -: -/ -/ -crates +unicode . -io +org / -crates +reports / -lazy_static -This -example -shows -how -to -use -once_cell -: -rust -use -{ -once_cell -: -: -sync -: -: -Lazy -regex -: -: -Regex -} -; -fn -some_helper_function -( -haystack -: -& -str +tr18 +/ +# +Compatibility_Properties ) -- -> -bool -{ -static -RE : -Lazy < -Regex -> +pre +class = -Lazy -: -: -new -( -| -| -Regex -: -: -new -( -r " -. -. -. +rust " -) -. -unwrap -( -) -) -; -RE -. -is_match -( -haystack -) -} -fn -main +> +\ +d +digit ( -) +\ +p { -assert -! -( -some_helper_function -( -" -abc -" -) +Nd +} ) -; -assert -! -( -! -some_helper_function -( -" -ac -" -) -) -; -} -Specifically -in -this -example -the -regex -will -be -compiled -when -it -is -used -for -the -first -time -. -On -subsequent -uses -it -will -reuse -the -previously -built -Regex -. -Notice -how -one -can -define -the -Regex -locally -to -a -specific -function -. -# -# -# -Sharing -a -regex -across -threads -can -result -in -contention -While -a -single -Regex -can -be -freely -used -from -multiple -threads -simultaneously -there -is -a -small -synchronization -cost -that -must -be -paid -. -Generally -speaking -one -shouldn -' -t -expect -to -observe -this -unless -the -principal -task -in -each -thread -is -searching -with -the -regex -* -and -* -most -searches -are -on -short -haystacks -. -In -this -case -internal -contention -on -shared -resources -can -spike -and -increase -latency -which -in -turn -may -slow -down -each -individual -search -. -One -can -work -around -this -by -cloning -each -Regex -before -sending -it -to -another -thread -. -The -cloned -regexes -will -still -share -the -same -internal -read -- -only -portion -of -its -compiled -state -( -it -' -s -reference -counted -) -but -each -thread -will -get -optimized -access -to -the -mutable -space -that -is -used -to -run -a -search -. -In -general -there -is -no -additional -cost -in -memory -to -doing -this -. -The -only -cost -is -the -added -code -complexity -required -to -explicitly -clone -the -regex -. -( -If -you -share -the -same -Regex -across -multiple -threads -each -thread -still -gets -its -own -mutable -space -but -accessing -that -space -is -slower -. -) -# -Unicode -This -section -discusses -what -kind -of -Unicode -support -this -regex -library -has -. -Before -showing -some -examples -we -' -ll -summarize -the -relevant -points -: -* -This -crate -almost -fully -implements -" -Basic -Unicode -Support -" -( -Level -1 -) -as -specified -by -the -[ -Unicode -Technical -Standard -# -18 -] -[ -UTS18 -] -. -The -full -details -of -what -is -supported -are -documented -in -[ -UNICODE -. -md -] -in -the -root -of -the -regex -crate -repository -. -There -is -virtually -no -support -for -" -Extended -Unicode -Support -" -( -Level -2 -) -from -UTS -# -18 -. -* -The -top -- -level -[ -Regex -] -runs -searches -* -as -if -* -iterating -over -each -of -the -codepoints -in -the -haystack -. -That -is -the -fundamental -atom -of -matching -is -a -single -codepoint -. -* -[ -bytes -: -: -Regex -] -in -contrast -permits -disabling -Unicode -mode -for -part -of -all -of -your -pattern -in -all -cases -. -When -Unicode -mode -is -disabled -then -a -search -is -run -* -as -if -* -iterating -over -each -byte -in -the -haystack -. -That -is -the -fundamental -atom -of -matching -is -a -single -byte -. -( -A -top -- -level -Regex -also -permits -disabling -Unicode -and -thus -matching -* -as -if -* -it -were -one -byte -at -a -time -but -only -when -doing -so -wouldn -' -t -permit -matching -invalid -UTF -- -8 -. -) -* -When -Unicode -mode -is -enabled -( -the -default -) -. -will -match -an -entire -Unicode -scalar -value -even -when -it -is -encoded -using -multiple -bytes -. -When -Unicode -mode -is -disabled -( -e -. -g -. -( -? -- -u -: -. -) -) -then -. -will -match -a -single -byte -in -all -cases -. -* -The -character -classes -\ -w -\ -d -and -\ -s -are -all -Unicode -- -aware -by -default -. -Use -( -? -- -u -: -\ -w -) -( -? -- -u -: -\ -d -) -and -( -? -- -u -: -\ -s -) -to -get -their -ASCII -- -only -definitions -. -* -Similarly -\ -b -and -\ -B -use -a -Unicode -definition -of -a -" -word -" -character -. -To -get -ASCII -- -only -word -boundaries -use -( -? -- -u -: -\ -b -) -and -( -? -- -u -: -\ -B -) -. -* -^ -and -are -* -* -not -* -* -Unicode -- -aware -in -multi -- -line -mode -. -Namely -they -only -recognize -\ -n -( -assuming -CRLF -mode -is -not -enabled -) -and -not -any -of -the -other -forms -of -line -terminators -defined -by -Unicode -. -* -Case -insensitive -searching -is -Unicode -- -aware -and -uses -simple -case -folding -. -* -Unicode -general -categories -scripts -and -many -boolean -properties -are -available -by -default -via -the -\ -p -{ -property -name -} -syntax -. -* -In -all -cases -matches -are -reported -using -byte -offsets -. -Or -more -precisely -UTF -- -8 -code -unit -offsets -. -This -permits -constant -time -indexing -and -slicing -of -the -haystack -. -[ -UTS18 -] -: -https -: -/ -/ -unicode -. -org -/ -reports -/ -tr18 -/ -[ -UNICODE -. -md -] -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -blob -/ -master -/ -UNICODE -. -md -Patterns -themselves -are -* -* -only -* -* -interpreted -as -a -sequence -of -Unicode -scalar -values -. -This -means -you -can -use -Unicode -characters -directly -in -your -pattern -: -rust -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -( -? -i -) -+ -" -) -. -unwrap -( -) -; -let -m -= -re -. -find -( -" -" -) -. -unwrap -( -) -; -assert_eq -! -( -( -0 -6 -) -( -m -. -start -( -) -m -. -end -( -) -) -) -; -/ -/ -alternatively -: -assert_eq -! -( -0 -. -. -6 -m -. -range -( -) -) -; -As -noted -above -Unicode -general -categories -scripts -script -extensions -ages -and -a -smattering -of -boolean -properties -are -available -as -character -classes -. -For -example -you -can -match -a -sequence -of -numerals -Greek -or -Cherokee -letters -: -rust -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -[ -\ -pN -\ -p -{ -Greek -} -\ -p -{ -Cherokee -} -] -+ -" -) -. -unwrap -( -) -; -let -m -= -re -. -find -( -" -abc -xyz -" -) -. -unwrap -( -) -; -assert_eq -! -( -3 -. -. -23 -m -. -range -( -) -) -; -While -not -specific -to -Unicode -this -library -also -supports -character -class -set -operations -. -Namely -one -can -nest -character -classes -arbitrarily -and -perform -set -operations -on -them -. -Those -set -operations -are -union -( -the -default -) -intersection -difference -and -symmetric -difference -. -These -set -operations -tend -to -be -most -useful -with -Unicode -character -classes -. -For -example -to -match -any -codepoint -that -is -both -in -the -Greek -script -and -in -the -Letter -general -category -: -rust -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -[ -\ -p -{ -Greek -} -& -& -\ -pL -] -+ -" -) -. -unwrap -( -) -; -let -subs -: -Vec -< -& -str -> -= -re -. -find_iter -( -" -" -) -. -map -( -| -m -| -m -. -as_str -( -) -) -. -collect -( -) -; -assert_eq -! -( -subs -vec -! -[ -" -" -" -" -] -) -; -/ -/ -If -we -just -matches -on -Greek -then -all -codepoints -would -match -! -let -re -= -Regex -: -: -new -( -r -" -\ -p -{ -Greek -} -+ -" -) -. -unwrap -( -) -; -let -subs -: -Vec -< -& -str -> -= -re -. -find_iter -( -" -" -) -. -map -( -| -m -| -m -. -as_str -( -) -) -. -collect -( -) -; -assert_eq -! -( -subs -vec -! -[ -" -" -] -) -; -# -# -# -Opt -out -of -Unicode -support -The -[ -bytes -: -: -Regex -] -type -that -can -be -used -to -search -& -[ -u8 -] -haystacks -. -By -default -haystacks -are -conventionally -treated -as -UTF -- -8 -just -like -it -is -with -the -main -Regex -type -. -However -this -behavior -can -be -disabled -by -turning -off -the -u -flag -even -if -doing -so -could -result -in -matching -invalid -UTF -- -8 -. -For -example -when -the -u -flag -is -disabled -. -will -match -any -byte -instead -of -any -Unicode -scalar -value -. -Disabling -the -u -flag -is -also -possible -with -the -standard -& -str -- -based -Regex -type -but -it -is -only -allowed -where -the -UTF -- -8 -invariant -is -maintained -. -For -example -( -? -- -u -: -\ -w -) -is -an -ASCII -- -only -\ -w -character -class -and -is -legal -in -an -& -str -- -based -Regex -but -( -? -- -u -: -\ -W -) -will -attempt -to -match -* -any -byte -* -that -isn -' -t -in -( -? -- -u -: -\ -w -) -which -in -turn -includes -bytes -that -are -invalid -UTF -- -8 -. -Similarly -( -? -- -u -: -\ -xFF -) -will -attempt -to -match -the -raw -byte -\ -xFF -( -instead -of -U -+ -00FF -) -which -is -invalid -UTF -- -8 -and -therefore -is -illegal -in -& -str -- -based -regexes -. -Finally -since -Unicode -support -requires -bundling -large -Unicode -data -tables -this -crate -exposes -knobs -to -disable -the -compilation -of -those -data -tables -which -can -be -useful -for -shrinking -binary -size -and -reducing -compilation -times -. -For -details -on -how -to -do -that -see -the -section -on -[ -crate -features -] -( -# -crate -- -features -) -. -# -Syntax -The -syntax -supported -in -this -crate -is -documented -below -. -Note -that -the -regular -expression -parser -and -abstract -syntax -are -exposed -in -a -separate -crate -[ -regex -- -syntax -] -( -https -: -/ -/ -docs -. -rs -/ -regex -- -syntax -) -. -# -# -# -Matching -one -character -< -pre -class -= -" -rust -" -> -. -any -character -except -new -line -( -includes -new -line -with -s -flag -) -[ -0 -- -9 -] -any -ASCII -digit -\ -d -digit -( -\ -p -{ -Nd -} -) -\ -D -not -digit -\ -pX -Unicode -character -class -identified -by -a -one -- -letter -name -\ -p -{ -Greek -} -Unicode -character -class -( -general -category -or -script -) -\ -PX -Negated -Unicode -character -class -identified -by -a -one -- -letter -name -\ -P -{ -Greek -} -negated -Unicode -character -class -( -general -category -or -script -) -< -/ -pre -> -# -# -# -Character -classes -< -pre -class -= -" -rust -" -> -[ -xyz -] -A -character -class -matching -either -x -y -or -z -( -union -) -. -[ -^ -xyz -] -A -character -class -matching -any -character -except -x -y -and -z -. -[ -a -- -z -] -A -character -class -matching -any -character -in -range -a -- -z -. -[ -[ -: -alpha -: -] -] -ASCII -character -class -( -[ -A -- -Za -- -z -] -) -[ -[ -: -^ -alpha -: -] -] -Negated -ASCII -character -class -( -[ -^ -A -- -Za -- -z -] -) -[ -x -[ -^ -xyz -] -] -Nested -/ -grouping -character -class -( -matching -any -character -except -y -and -z -) -[ -a -- -y -& -& -xyz -] -Intersection -( -matching -x -or -y -) -[ -0 -- -9 -& -& -[ -^ -4 -] -] -Subtraction -using -intersection -and -negation -( -matching -0 -- -9 -except -4 -) -[ -0 -- -9 -- -- -4 -] -Direct -subtraction -( -matching -0 -- -9 -except -4 -) -[ -a -- -g -~ -~ -b -- -h -] -Symmetric -difference -( -matching -a -and -h -only -) -[ -\ -[ -\ -] -] -Escaping -in -character -classes -( -matching -[ -or -] -) -[ -a -& -& -b -] -An -empty -character -class -matching -nothing -< -/ -pre -> -Any -named -character -class -may -appear -inside -a -bracketed -[ -. -. -. -] -character -class -. -For -example -[ -\ -p -{ -Greek -} -[ -: -digit -: -] -] -matches -any -ASCII -digit -or -any -codepoint -in -the -Greek -script -. -[ -\ -p -{ -Greek -} -& -& -\ -pL -] -matches -Greek -letters -. -Precedence -in -character -classes -from -most -binding -to -least -: -1 -. -Ranges -: -[ -a -- -cd -] -= -= -[ -[ -a -- -c -] -d -] -2 -. -Union -: -[ -ab -& -& -bc -] -= -= -[ -[ -ab -] -& -& -[ -bc -] -] -3 -. -Intersection -difference -symmetric -difference -. -All -three -have -equivalent -precedence -and -are -evaluated -in -left -- -to -- -right -order -. -For -example -[ -\ -pL -- -- -\ -p -{ -Greek -} -& -& -\ -p -{ -Uppercase -} -] -= -= -[ -[ -\ -pL -- -- -\ -p -{ -Greek -} -] -& -& -\ -p -{ -Uppercase -} -] -. -4 -. -Negation -: -[ -^ -a -- -z -& -& -b -] -= -= -[ -^ -[ -a -- -z -& -& -b -] -] -. -# -# -# -Composites -< -pre -class -= -" -rust -" -> -xy -concatenation -( -x -followed -by -y -) -x -| -y -alternation -( -x -or -y -prefer -x -) -< -/ -pre -> -This -example -shows -how -an -alternation -works -and -what -it -means -to -prefer -a -branch -in -the -alternation -over -subsequent -branches -. -use -regex -: -: -Regex -; -let -haystack -= -" -samwise -" -; -/ -/ -If -' -samwise -' -comes -first -in -our -alternation -then -it -is -/ -/ -preferred -as -a -match -even -if -the -regex -engine -could -/ -/ -technically -detect -that -' -sam -' -led -to -a -match -earlier -. -let -re -= -Regex -: -: -new -( -r -" -samwise -| -sam -" -) -. -unwrap -( -) -; -assert_eq -! -( -" -samwise -" -re -. -find -( -haystack -) -. -unwrap -( -) -. -as_str -( -) -) -; -/ -/ -But -if -' -sam -' -comes -first -then -it -will -match -instead -. -/ -/ -In -this -case -it -is -impossible -for -' -samwise -' -to -match -/ -/ -because -' -sam -' -is -a -prefix -of -it -. -let -re -= -Regex -: -: -new -( -r -" -sam -| -samwise -" -) -. -unwrap -( -) -; -assert_eq -! -( -" -sam -" -re -. -find -( -haystack -) -. -unwrap -( -) -. -as_str -( -) -) -; -# -# -# -Repetitions -< -pre -class -= -" -rust -" -> -x -* -zero -or -more -of -x -( -greedy -) -x -+ -one -or -more -of -x -( -greedy -) -x -? -zero -or -one -of -x -( -greedy -) -x -* -? -zero -or -more -of -x -( -ungreedy -/ -lazy -) -x -+ -? -one -or -more -of -x -( -ungreedy -/ -lazy -) -x -? -? -zero -or -one -of -x -( -ungreedy -/ -lazy -) -x -{ -n -m -} -at -least -n -x -and -at -most -m -x -( -greedy -) -x -{ -n -} -at -least -n -x -( -greedy -) -x -{ -n -} -exactly -n -x -x -{ -n -m -} -? -at -least -n -x -and -at -most -m -x -( -ungreedy -/ -lazy -) -x -{ -n -} -? -at -least -n -x -( -ungreedy -/ -lazy -) -x -{ -n -} -? -exactly -n -x -< -/ -pre -> -# -# -# -Empty -matches -< -pre -class -= -" -rust -" -> -^ -the -beginning -of -a -haystack -( -or -start -- -of -- -line -with -multi -- -line -mode -) -the -end -of -a -haystack -( -or -end -- -of -- -line -with -multi -- -line -mode -) -\ -A -only -the -beginning -of -a -haystack -( -even -with -multi -- -line -mode -enabled -) -\ -z -only -the -end -of -a -haystack -( -even -with -multi -- -line -mode -enabled -) -\ -b -a -Unicode -word -boundary -( -\ -w -on -one -side -and -\ -W -\ -A -or -\ -z -on -other -) -\ -B -not -a -Unicode -word -boundary -< -/ -pre -> -The -empty -regex -is -valid -and -matches -the -empty -string -. -For -example -the -empty -regex -matches -abc -at -positions -0 -1 -2 -and -3 -. -When -using -the -top -- -level -[ -Regex -] -on -& -str -haystacks -an -empty -match -that -splits -a -codepoint -is -guaranteed -to -never -be -returned -. -However -such -matches -are -permitted -when -using -a -[ -bytes -: -: -Regex -] -. -For -example -: -rust -let -re -= -regex -: -: -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -let -ranges -: -Vec -< -_ -> -= -re -. -find_iter -( -" -" -) -. -map -( -| -m -| -m -. -range -( -) -) -. -collect -( -) -; -assert_eq -! -( -ranges -vec -! -[ -0 -. -. -0 -4 -. -. -4 -] -) -; -let -re -= -regex -: -: -bytes -: -: -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -let -ranges -: -Vec -< -_ -> -= -re -. -find_iter -( -" -" -. -as_bytes -( -) -) -. -map -( -| -m -| -m -. -range -( -) -) -. -collect -( -) -; -assert_eq -! -( -ranges -vec -! -[ -0 -. -. -0 -1 -. -. -1 -2 -. -. -2 -3 -. -. -3 -4 -. -. -4 -] -) -; -Note -that -an -empty -regex -is -distinct -from -a -regex -that -can -never -match -. -For -example -the -regex -[ -a -& -& -b -] -is -a -character -class -that -represents -the -intersection -of -a -and -b -. -That -intersection -is -empty -which -means -the -character -class -is -empty -. -Since -nothing -is -in -the -empty -set -[ -a -& -& -b -] -matches -nothing -not -even -the -empty -string -. -# -# -# -Grouping -and -flags -< -pre -class -= -" -rust -" -> -( -exp -) -numbered -capture -group -( -indexed -by -opening -parenthesis -) -( -? -P -& -lt -; -name -& -gt -; -exp -) -named -( -also -numbered -) -capture -group -( -names -must -be -alpha -- -numeric -) -( -? -& -lt -; -name -& -gt -; -exp -) -named -( -also -numbered -) -capture -group -( -names -must -be -alpha -- -numeric -) -( -? -: -exp -) -non -- -capturing -group -( -? -flags -) -set -flags -within -current -group -( -? -flags -: -exp -) -set -flags -for -exp -( -non -- -capturing -) -< -/ -pre -> -Capture -group -names -must -be -any -sequence -of -alpha -- -numeric -Unicode -codepoints -in -addition -to -. -_ -[ -and -] -. -Names -must -start -with -either -an -_ -or -an -alphabetic -codepoint -. -Alphabetic -codepoints -correspond -to -the -Alphabetic -Unicode -property -while -numeric -codepoints -correspond -to -the -union -of -the -Decimal_Number -Letter_Number -and -Other_Number -general -categories -. -Flags -are -each -a -single -character -. -For -example -( -? -x -) -sets -the -flag -x -and -( -? -- -x -) -clears -the -flag -x -. -Multiple -flags -can -be -set -or -cleared -at -the -same -time -: -( -? -xy -) -sets -both -the -x -and -y -flags -and -( -? -x -- -y -) -sets -the -x -flag -and -clears -the -y -flag -. -All -flags -are -by -default -disabled -unless -stated -otherwise -. -They -are -: -< -pre -class -= -" -rust -" -> -i -case -- -insensitive -: -letters -match -both -upper -and -lower -case -m -multi -- -line -mode -: -^ -and -match -begin -/ -end -of -line -s -allow -. -to -match -\ -n -R -enables -CRLF -mode -: -when -multi -- -line -mode -is -enabled -\ -r -\ -n -is -used -U -swap -the -meaning -of -x -* -and -x -* -? -u -Unicode -support -( -enabled -by -default -) -x -verbose -mode -ignores -whitespace -and -allow -line -comments -( -starting -with -# -) -< -/ -pre -> -Note -that -in -verbose -mode -whitespace -is -ignored -everywhere -including -within -character -classes -. -To -insert -whitespace -use -its -escaped -form -or -a -hex -literal -. -For -example -\ -or -\ -x20 -for -an -ASCII -space -. -Flags -can -be -toggled -within -a -pattern -. -Here -' -s -an -example -that -matches -case -- -insensitively -for -the -first -part -but -case -- -sensitively -for -the -second -part -: -rust -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -( -? -i -) -a -+ -( -? -- -i -) -b -+ -" -) -. -unwrap -( -) -; -let -m -= -re -. -find -( -" -AaAaAbbBBBb -" -) -. -unwrap -( -) -; -assert_eq -! -( -m -. -as_str -( -) -" -AaAaAbb -" -) -; -Notice -that -the -a -+ -matches -either -a -or -A -but -the -b -+ -only -matches -b -. -Multi -- -line -mode -means -^ -and -no -longer -match -just -at -the -beginning -/ -end -of -the -input -but -also -at -the -beginning -/ -end -of -lines -: -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -line -\ -d -+ -" -) -. -unwrap -( -) -; -let -m -= -re -. -find -( -" -line -one -\ -nline -2 -\ -n -" -) -. -unwrap -( -) -; -assert_eq -! -( -m -. -as_str -( -) -" -line -2 -" -) -; -Note -that -^ -matches -after -new -lines -even -at -the -end -of -input -: -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -" -) -. -unwrap -( -) -; -let -m -= -re -. -find_iter -( -" -test -\ -n -" -) -. -last -( -) -. -unwrap -( -) -; -assert_eq -! -( -( -m -. -start -( -) -m -. -end -( -) -) -( -5 -5 -) -) -; -When -both -CRLF -mode -and -multi -- -line -mode -are -enabled -then -^ -and -will -match -either -\ -r -and -\ -n -but -never -in -the -middle -of -a -\ -r -\ -n -: -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -( -? -mR -) -^ -foo -" -) -. -unwrap -( -) -; -let -m -= -re -. -find -( -" -\ -r -\ -nfoo -\ -r -\ -n -" -) -. -unwrap -( -) -; -assert_eq -! -( -m -. -as_str -( -) -" -foo -" -) -; -Unicode -mode -can -also -be -selectively -disabled -although -only -when -the -result -* -would -not -* -match -invalid -UTF -- -8 -. -One -good -example -of -this -is -using -an -ASCII -word -boundary -instead -of -a -Unicode -word -boundary -which -might -make -some -regex -searches -run -faster -: -rust -use -regex -: -: -Regex -; -let -re -= -Regex -: -: -new -( -r -" -( -? -- -u -: -\ -b -) -. -+ -( -? -- -u -: -\ -b -) -" -) -. -unwrap -( -) -; -let -m -= -re -. -find -( -" -abc -" -) -. -unwrap -( -) -; -assert_eq -! -( -m -. -as_str -( -) -" -abc -" -) -; -# -# -# -Escape -sequences -Note -that -this -includes -all -possible -escape -sequences -even -ones -that -are -documented -elsewhere -. -< -pre -class -= -" -rust -" -> -\ -* -literal -* -applies -to -all -ASCII -except -[ -0 -- -9A -- -Za -- -z -< -> -] -\ -a -bell -( -\ -x07 -) -\ -f -form -feed -( -\ -x0C -) -\ -t -horizontal -tab -\ -n -new -line -\ -r -carriage -return -\ -v -vertical -tab -( -\ -x0B -) -\ -A -matches -at -the -beginning -of -a -haystack -\ -z -matches -at -the -end -of -a -haystack -\ -b -word -boundary -assertion -\ -B -negated -word -boundary -assertion -\ -123 -octal -character -code -up -to -three -digits -( -when -enabled -) -\ -x7F -hex -character -code -( -exactly -two -digits -) -\ -x -{ -10FFFF -} -any -hex -character -code -corresponding -to -a -Unicode -code -point -\ -u007F -hex -character -code -( -exactly -four -digits -) -\ -u -{ -7F -} -any -hex -character -code -corresponding -to -a -Unicode -code -point -\ -U0000007F -hex -character -code -( -exactly -eight -digits -) -\ -U -{ -7F -} -any -hex -character -code -corresponding -to -a -Unicode -code -point -\ -p -{ -Letter -} -Unicode -character -class -\ -P -{ -Letter -} -negated -Unicode -character -class -\ -d -\ -s -\ -w -Perl -character -class -\ -D -\ -S -\ -W -negated -Perl -character -class -< -/ -pre -> -# -# -# -Perl -character -classes -( -Unicode -friendly -) -These -classes -are -based -on -the -definitions -provided -in -[ -UTS -# -18 -] -( -https -: -/ -/ -www -. -unicode -. -org -/ -reports -/ -tr18 -/ -# -Compatibility_Properties -) -: -< -pre -class -= -" -rust -" -> -\ -d -digit -( -\ -p -{ -Nd -} -) -\ -D -not -digit -\ -s -whitespace -( -\ -p -{ -White_Space -} -) -\ -S -not -whitespace -\ -w -word -character -( -\ -p -{ -Alphabetic -} -+ -\ -p -{ -M -} -+ -\ -d -+ -\ -p -{ -Pc -} -+ -\ -p -{ -Join_Control -} -) -\ -W -not -word -character -< -/ -pre -> -# -# -# -ASCII -character -classes -These -classes -are -based -on -the -definitions -provided -in -[ -UTS -# -18 -] -( -https -: -/ -/ -www -. -unicode -. -org -/ -reports -/ -tr18 -/ -# -Compatibility_Properties -) -: -< -pre -class -= -" -rust -" -> -[ -[ -: -alnum -: -] -] -alphanumeric -( -[ -0 -- -9A -- -Za -- -z -] -) -[ -[ -: -alpha -: -] -] -alphabetic -( -[ -A -- -Za -- -z -] -) -[ -[ -: -ascii -: -] -] -ASCII -( -[ -\ -x00 -- -\ -x7F -] -) -[ -[ -: -blank -: -] -] -blank -( -[ -\ -t -] -) -[ -[ -: -cntrl -: -] -] -control -( -[ -\ -x00 -- -\ -x1F -\ -x7F -] -) -[ -[ -: -digit -: -] -] -digits -( -[ -0 -- -9 -] -) -[ -[ -: -graph -: -] -] -graphical -( -[ -! -- -~ -] -) -[ -[ -: -lower -: -] -] -lower -case -( -[ -a -- -z -] -) -[ -[ -: -print -: -] -] -printable -( -[ -- -~ -] -) -[ -[ -: -punct -: -] -] -punctuation -( -[ -! -- -/ -: -- -\ -[ -- -{ -- -~ -] -) -[ -[ -: -space -: -] -] -whitespace -( -[ -\ -t -\ -n -\ -v -\ -f -\ -r -] -) -[ -[ -: -upper -: -] -] -upper -case -( -[ -A -- -Z -] -) -[ -[ -: -word -: -] -] -word -characters -( -[ -0 -- -9A -- -Za -- -z_ -] -) -[ -[ -: -xdigit -: -] -] -hex -digit -( -[ -0 -- -9A -- -Fa -- -f -] -) -< -/ -pre -> -# -Untrusted -input -This -crate -is -meant -to -be -able -to -run -regex -searches -on -untrusted -haystacks -without -fear -of -[ -ReDoS -] -. -This -crate -also -to -a -certain -extent -supports -untrusted -patterns -. -[ -ReDoS -] -: -https -: -/ -/ -en -. -wikipedia -. -org -/ -wiki -/ -ReDoS -This -crate -differs -from -most -( -but -not -all -) -other -regex -engines -in -that -it -doesn -' -t -use -unbounded -backtracking -to -run -a -regex -search -. -In -those -cases -one -generally -cannot -use -untrusted -patterns -* -or -* -untrusted -haystacks -because -it -can -be -very -difficult -to -know -whether -a -particular -pattern -will -result -in -catastrophic -backtracking -or -not -. -We -' -ll -first -discuss -how -this -crate -deals -with -untrusted -inputs -and -then -wrap -it -up -with -a -realistic -discussion -about -what -practice -really -looks -like -. -# -# -# -Panics -Outside -of -clearly -documented -cases -most -APIs -in -this -crate -are -intended -to -never -panic -regardless -of -the -inputs -given -to -them -. -For -example -Regex -: -: -new -Regex -: -: -is_match -Regex -: -: -find -and -Regex -: -: -captures -should -never -panic -. -That -is -it -is -an -API -promise -that -those -APIs -will -never -panic -no -matter -what -inputs -are -given -to -them -. -With -that -said -regex -engines -are -complicated -beasts -and -providing -a -rock -solid -guarantee -that -these -APIs -literally -never -panic -is -essentially -equivalent -to -saying -" -there -are -no -bugs -in -this -library -. -" -That -is -a -bold -claim -and -not -really -one -that -can -be -feasibly -made -with -a -straight -face -. -Don -' -t -get -the -wrong -impression -here -. -This -crate -is -extensively -tested -not -just -with -unit -and -integration -tests -but -also -via -fuzz -testing -. -For -example -this -crate -is -part -of -the -[ -OSS -- -fuzz -project -] -. -Panics -should -be -incredibly -rare -but -it -is -possible -for -bugs -to -exist -and -thus -possible -for -a -panic -to -occur -. -If -you -need -a -rock -solid -guarantee -against -panics -then -you -should -wrap -calls -into -this -library -with -[ -std -: -: -panic -: -: -catch_unwind -] -. -It -' -s -also -worth -pointing -out -that -this -library -will -* -generally -* -panic -when -other -regex -engines -would -commit -undefined -behavior -. -When -undefined -behavior -occurs -your -program -might -continue -as -if -nothing -bad -has -happened -but -it -also -might -mean -your -program -is -open -to -the -worst -kinds -of -exploits -. -In -contrast -the -worst -thing -a -panic -can -do -is -a -denial -of -service -. -[ -OSS -- -fuzz -project -] -: -https -: -/ -/ -android -. -googlesource -. -com -/ -platform -/ -external -/ -oss -- -fuzz -/ -+ -/ -refs -/ -tags -/ -android -- -t -- -preview -- -1 -/ -projects -/ -rust -- -regex -/ -[ -std -: -: -panic -: -: -catch_unwind -] -: -https -: -/ -/ -doc -. -rust -- -lang -. -org -/ -std -/ -panic -/ -fn -. -catch_unwind -. -html -# -# -# -Untrusted -patterns -The -principal -way -this -crate -deals -with -them -is -by -limiting -their -size -by -default -. -The -size -limit -can -be -configured -via -[ -RegexBuilder -: -: -size_limit -] -. -The -idea -of -a -size -limit -is -that -compiling -a -pattern -into -a -Regex -will -fail -if -it -becomes -" -too -big -. -" -Namely -while -* -most -* -resources -consumed -by -compiling -a -regex -are -approximately -proportional -( -albeit -with -some -high -constant -factors -in -some -cases -such -as -with -Unicode -character -classes -) -to -the -length -of -the -pattern -itself -there -is -one -particular -exception -to -this -: -counted -repetitions -. -Namely -this -pattern -: -text -a -{ -5 -} -{ -5 -} -{ -5 -} -{ -5 -} -{ -5 -} -{ -5 -} -Is -equivalent -to -this -pattern -: -text -a -{ -15625 -} -In -both -of -these -cases -the -actual -pattern -string -is -quite -small -but -the -resulting -Regex -value -is -quite -large -. -Indeed -as -the -first -pattern -shows -it -isn -' -t -enough -to -locally -limit -the -size -of -each -repetition -because -they -can -be -stacked -in -a -way -that -results -in -exponential -growth -. -To -provide -a -bit -more -context -a -simplified -view -of -regex -compilation -looks -like -this -: -* -The -pattern -string -is -parsed -into -a -structured -representation -called -an -AST -. -Counted -repetitions -are -not -expanded -and -Unicode -character -classes -are -not -looked -up -in -this -stage -. -That -is -the -size -of -the -AST -is -proportional -to -the -size -of -the -pattern -with -" -reasonable -" -constant -factors -. -In -other -words -one -can -reasonably -limit -the -memory -used -by -an -AST -by -limiting -the -length -of -the -pattern -string -. -* -The -AST -is -translated -into -an -HIR -. -Counted -repetitions -are -still -* -not -* -expanded -at -this -stage -but -Unicode -character -classes -are -embedded -into -the -HIR -. -The -memory -usage -of -a -HIR -is -still -proportional -to -the -length -of -the -original -pattern -string -but -the -constant -factors -- -- -- -mostly -as -a -result -of -Unicode -character -classes -- -- -- -can -be -quite -high -. -Still -though -the -memory -used -by -an -HIR -can -be -reasonably -limited -by -limiting -the -length -of -the -pattern -string -. -* -The -HIR -is -compiled -into -a -[ -Thompson -NFA -] -. -This -is -the -stage -at -which -something -like -\ -w -{ -5 -} -is -rewritten -to -\ -w -\ -w -\ -w -\ -w -\ -w -. -Thus -this -is -the -stage -at -which -[ -RegexBuilder -: -: -size_limit -] -is -enforced -. -If -the -NFA -exceeds -the -configured -size -then -this -stage -will -fail -. -[ -Thompson -NFA -] -: -https -: -/ -/ -en -. -wikipedia -. -org -/ -wiki -/ -Thompson -% -27s_construction -The -size -limit -helps -avoid -two -different -kinds -of -exorbitant -resource -usage -: -* -It -avoids -permitting -exponential -memory -usage -based -on -the -size -of -the -pattern -string -. -* -It -avoids -long -search -times -. -This -will -be -discussed -in -more -detail -in -the -next -section -but -worst -case -search -time -* -is -* -dependent -on -the -size -of -the -regex -. -So -keeping -regexes -limited -to -a -reasonable -size -is -also -a -way -of -keeping -search -times -reasonable -. -Finally -it -' -s -worth -pointing -out -that -regex -compilation -is -guaranteed -to -take -worst -case -O -( -m -) -time -where -m -is -proportional -to -the -size -of -regex -. -The -size -of -the -regex -here -is -* -after -* -the -counted -repetitions -have -been -expanded -. -* -* -Advice -for -those -using -untrusted -regexes -* -* -: -limit -the -pattern -length -to -something -small -and -expand -it -as -needed -. -Configure -[ -RegexBuilder -: -: -size_limit -] -to -something -small -and -then -expand -it -as -needed -. -# -# -# -Untrusted -haystacks -The -main -way -this -crate -guards -against -searches -from -taking -a -long -time -is -by -using -algorithms -that -guarantee -a -O -( -m -* -n -) -worst -case -time -and -space -bound -. -Namely -: -* -m -is -proportional -to -the -size -of -the -regex -where -the -size -of -the -regex -includes -the -expansion -of -all -counted -repetitions -. -( -See -the -previous -section -on -untrusted -patterns -. -) -* -n -is -proportional -to -the -length -in -bytes -of -the -haystack -. -In -other -words -if -you -consider -m -to -be -a -constant -( -for -example -the -regex -pattern -is -a -literal -in -the -source -code -) -then -the -search -can -be -said -to -run -in -" -linear -time -. -" -Or -equivalently -" -linear -time -with -respect -to -the -size -of -the -haystack -. -" -But -the -m -factor -here -is -important -not -to -ignore -. -If -a -regex -is -particularly -big -the -search -times -can -get -quite -slow -. -This -is -why -in -part -[ -RegexBuilder -: -: -size_limit -] -exists -. -* -* -Advice -for -those -searching -untrusted -haystacks -* -* -: -As -long -as -your -regexes -are +\ +D not -enormous -you -should -expect -to -be -able -to -search -untrusted -haystacks -without -fear -. -If -you -aren -' -t -sure -you -should -benchmark -it -. -Unlike -backtracking -engines -if -your -regex -is -so -big -that -it -' +digit +\ s -likely -to -result -in -slow -searches -this -is -probably -something -you -' -ll -be -able -to -observe -regardless -of -what -the -haystack -is -made -up -of -. -# -# -# -Iterating -over -matches -One -thing -that -is -perhaps -easy -to -miss -is -that -the -worst -case -time -complexity -bound -of -O -( -m -* -n -) -applies -to -methods -like -[ -Regex -: -: -is_match -] -[ -Regex -: -: -find -] -and -[ -Regex -: -: -captures -] -. -It -does -* -* -not -* -* -apply -to -[ -Regex -: -: -find_iter -] -or -[ -Regex -: -: -captures_iter -] -. -Namely -since -iterating -over -all -matches -can -execute -many -searches -and -each -search -can -scan -the -entire -haystack -the -worst -case -time -complexity -for -iterators -is -O -( -m -* -n -^ -2 -) -. -One -example -of -where -this -occurs -is -when -a -pattern -consists -of -an -alternation -where -an -earlier -branch -of -the -alternation -requires -scanning -the -entire -haystack -only -to -discover -that -there -is -no -match -. -It -also -requires -a -later -branch -of -the -alternation -to -have -matched -at -the -beginning -of -the -search -. -For -example -consider -the -pattern -. -* +whitespace +( +\ +p +{ +White_Space +} +) +\ +S +not +whitespace +\ +w +word +character +( +\ +p +{ +Alphabetic +} ++ +\ +p +{ +M +} ++ +\ +d ++ +\ +p +{ +Pc +} ++ +\ +p +{ +Join_Control +} +) +\ +W +not +word +character +< +/ +pre +> +# +# +ASCII +character +classes +< +pre +class += +" +rust +" +> [ -^ -A -- -Z +[ +: +alnum +: ] -| +] +alphanumeric +( [ -A +0 - -Z +9A +- +Za +- +z ] -and -the -haystack -AAAAA -. -The -first -search -will -scan -to -the -end -looking -for -matches -of -. -* +) [ -^ -A -- -Z +[ +: +alpha +: ] -even -though -a -finite -automata -engine +] +alphabetic ( -as -in -this -crate -) -knows -that [ A - -Z -] -has -already -matched -the -first -character -of -the -haystack -. -This -is -due -to -the -greedy -nature -of -regex -searching -. -That -first -search -will -report -a -match -at -the -first -A -only -after -scanning -to -the -end -to -discover -that -no -other -match -exists -. -The -next -search -then -begins -at -the -second -A -and -the -behavior -repeats -. -There -is -no -way -to -avoid -this -. -This -means -that -if -both -patterns -and -haystacks -are -untrusted -and -you -' -re -iterating -over -all -matches -you -' -re -susceptible -to -worst -case -quadratic -time -complexity -. -One -possible -way -to -mitigate -this -is -to -drop -down -to -the -lower -level -regex +Za - -automata -crate -and -use -its -meta +z +] +) +[ +[ : +ascii : -Regex -iterator -APIs -. -There -you -can -configure -the -search -to -operate -in -" -earliest -" -mode -by -passing -a -Input +] +] +ASCII +( +[ +\ +x00 +- +\ +x7F +] +) +[ +[ : +blank : -new +] +] +blank ( -haystack +[ +\ +t +] ) -. -earliest +[ +[ +: +cntrl +: +] +] +control ( -true +[ +\ +x00 +- +\ +x1F +\ +x7F +] ) -to -meta +[ +[ : +digit : -Regex +] +] +digits +( +[ +0 +- +9 +] +) +[ +[ : +graph : -find_iter +] +] +graphical ( -for -example +[ +! +- +~ +] ) -. -By -enabling -this -mode -you -give -up -the -normal -greedy -match -semantics -of -regex -searches -and -instead -ask -the -regex -engine -to -immediately -stop -as -soon -as -a -match -has -been -found -. -Enabling -this -mode -will -thus -restore -the -worst +[ +[ +: +lower +: +] +] +lower case -O ( -m -* -n -) -time -complexity -bound -but -at -the -cost -of -different -semantics -. -# -# -# -Untrusted -inputs -in -practice -While -providing +[ a -O -( -m -* -n +- +z +] ) -worst -case -time -bound -on -all -searches -goes -a -long -way -toward -preventing [ -ReDoS -] -that -doesn -' -t -mean -every -search -you -can -possibly -run -will -complete -without -burning -CPU -time -. -In -general -there -are -a -few -ways -for -the -m -* -n -time -bound -to -still -bite -you +[ : -* -You -are -searching -an -exceptionally -long -haystack -. -No -matter -how -you -slice -it -a -longer -haystack -will -take -more -time -to -search -. -This -crate -may -often -make -very -quick -work -of -even -long -haystacks -because -of -its -literal -optimizations -but -those -aren -' -t -available -for -all -regexes -. -* -Unicode -character -classes -can -cause -searches -to -be -quite -slow -in -some -cases -. -This -is -especially -true -when -they -are -combined -with -counted -repetitions -. -While -the -regex -size -limit -above -will -protect -you -from -the -most -egregious -cases -the -default -size -limit -still -permits -pretty -big -regexes -that -can -execute -more -slowly -than -one -might -expect -. -* -While -routines -like +print +: +] +] +printable +( +[ +- +~ +] +) +[ [ -Regex : +punct : -find ] -and +] +punctuation +( +[ +! +- +/ +: +- +\ +[ +- +{ +- +~ +] +) +[ [ -Regex : +space : -captures ] -guarantee -worst -case -O +] +whitespace ( -m -* +[ +\ +t +\ n +\ +v +\ +f +\ +r +] ) -search -time -routines -like [ -Regex +[ : +upper : -find_iter ] -and +] +upper +case +( +[ +A +- +Z +] +) +[ [ -Regex : +word : -captures_iter ] -actually -have -worst -case -O +] +word +characters ( -m -* -n -^ -2 +[ +0 +- +9A +- +Za +- +z_ +] ) -search -time +[ +[ +: +xdigit +: +] +] +hex +digit +( +[ +0 +- +9A +- +Fa +- +f +] +) +< +/ +pre +> +# +Crate +features +By +default +this +crate +tries +pretty +hard +to +make +regex +matching +both +as +fast +as +possible +and +as +correct +as +it +can +be +within +reason . This +means +that +there is -because -find_iter -runs -many -searches +a +lot +of +code +dedicated +to +performance +the +handling +of +Unicode +data and -each -search -takes -worst -case -O -( -m -* -n -) -time +the +Unicode +data +itself +. +Overall +this +leads +to +more +dependencies +larger +binaries +and +longer +compile +times +. +This +trade +off +may +not +be +appropriate +in +all +cases +and +indeed +even +when +all +Unicode +and +performance +features +are +disabled +one +is +still +left +with +a +perfectly +serviceable +regex +engine +that +will +work +well +in +many +cases +. +This +crate +exposes +a +number +of +features +for +controlling +that +trade +off +. +Some +of +these +features +are +strictly +performance +oriented +such +that +disabling +them +won +' +t +result +in +a +loss +of +functionality +but +may +result +in +worse +performance . -Thus -iteration +Other +features +such +as +the +ones +controlling +the +presence +or +absence of -all -matches +Unicode +data +can +result in a -haystack -has -worst +loss +of +functionality +. +For +example +if +one +disables +the +unicode +- case -O +feature ( -m -* -n -^ -2 +described +below ) -. -A -good -example -of -a -pattern -that -exhibits -this -is +then +compiling +the +regex ( ? -: -A -+ +i ) -{ -1000 -} -| -or -even +a +will +fail +since +Unicode +case +insensitivity +is +enabled +by +default . -* -[ -^ -A -- -Z -] -| -[ -A +Instead +callers +must +use +( +? +i - -Z -] -. -In -general -unstrusted -haystacks -are -easier -to -stomach -than -untrusted -patterns -. -Untrusted -patterns -give +u +) a -lot -more -control +instead to +disable +Unicode +case +folding +. +Stated +differently +enabling +or +disabling +any +of the -caller -to -impact +features +below +can +only +add +or +subtract +from the -performance +total +set of -a -search +valid +regular +expressions . -In -many -cases +Enabling +or +disabling a -regex -search +feature will -actually -execute -in -average -case -O -( -n -) -time -( -i -. -e -. -not -dependent -on +never +modify the -size +match +semantics of -the +a +regular +expression +. +All +features +below +are +enabled +by +default +. +# +# +# +Ecosystem +features +* +* +* +std +* +* +- +When +enabled +this +will +cause regex -) -but +to +use +the +standard +library +. +Currently +disabling this -can -' -t -be -guaranteed +feature +will +always +result in -general -. -Therefore -permitting -untrusted -patterns -means -that -your -only -line -of -defense -is -to -put a -limit -on -how -big -m -( -and -perhaps -also -n -) -can -be +compilation +error +. +It +is +intended +to +add +alloc +- +only +support +to +regex in -O -( -m +the +future +. +# +# +# +Performance +features * -n -) +* +* +perf +* +* +- +Enables +all +performance +related +features . -n +This +feature is -limited +enabled by -simply -inspecting -the -length -of +default +and +will +always +cover +all +features +that +improve +performance +even +if +more +are +added +in the -haystack -while -m -is -limited -by +future +. * -both * -applying -a -limit -to -the -length -of -the -pattern * -and +perf +- +dfa * -a -limit -on +* +- +Enables the -compiled -size +use of -the -regex -via -[ -RegexBuilder -: -: -size_limit -] -. -It -bears -repeating -: -if -you -' -re -accepting -untrusted -patterns -it -would -be a -good -idea -to -start -with -conservative -limits -on -m -and -n -and -then -carefully -increase -them -as -needed +lazy +DFA +for +matching . -# -Crate -features -By -default -this -crate -tries -pretty -hard +The +lazy +DFA +is +used to -make +compile +portions +of +a regex -matching -both -as +to +a +very fast +DFA +on +an as -possible -and -as -correct -as -it -can -be +- +needed +basis . This -means -that -there -is -a -lot -of -code -dedicated -to -performance -the -handling +can +result +in +substantial +speedups +usually +by +an +order of -Unicode -data -and -the -Unicode -data -itself -. -Overall -this -leads -to -more -dependencies -larger -binaries -and -longer -compile -times +magnitude +on +large +haystacks . -This -trade -off -may +The +lazy +DFA +does not -be -appropriate -in -all -cases -and -indeed -even -when -all -Unicode -and -performance -features -are -disabled -one -is -still -left -with -a -perfectly -serviceable -regex -engine -that -will -work -well +bring in -many -cases +any +new +dependencies +but +it +can +make +compile +times +longer . -( -Note -that -code -is -not -arbitrarily -reducible -and -for -this -reason -the -[ -regex +* +* +* +perf - -lite -] -( -https -: -/ -/ -docs -. -rs -/ -regex +inline +* +* - -lite -) -crate -exists -to -provide -an -even -more -minimal -experience -by -cutting -out -Unicode -and -performance -but -still -maintaining +Enables the -linear -search -time -bound +use +of +aggressive +inlining +inside +match +routines . -) This -crate -exposes -a -number +reduces +the +overhead of -features -for -controlling -that -trade -off +each +match . -Some -of -these -features -are -strictly -performance -oriented -such -that -disabling -them -won -' -t -result -in -a -loss -of -functionality -but -may -result -in -worse -performance +The +aggressive +inlining +however +increases +compile +times +and +binary +size . -Other -features -such -as -the -ones -controlling +* +* +* +perf +- +literal +* +* +- +Enables the -presence -or -absence +use of -Unicode -data +literal +optimizations +for +speeding +up +matches +. +In +some +cases +literal +optimizations can result in -a -loss +speedups of -functionality +_several_ +orders +of +magnitude . -For -example -if -one -disables +Disabling +this +drops the -unicode +aho - -case -feature -( -described -below -) -then -compiling -the -regex -( -? -i -) -a -will -fail -since -Unicode -case -insensitivity -is -enabled -by -default +corasick +and +memchr +dependencies . -Instead -callers -must -use -( -? -i +* +* +* +perf - -u -) -a +cache +* +* +- +This +feature +used to -disable -Unicode -case -folding -. -Stated -differently -enabling -or -disabling -any -of -the -features -below -can -only -add -or -subtract -from -the -total -set -of -valid -regular -expressions -. -Enabling -or -disabling +enable a -feature -will -never -modify +faster +internal +cache +at the -match -semantics +cost of -a -regular -expression +using +additional +dependencies +but +this +is +no +longer +an +option . -Most -features -below -are -enabled -by -default +A +fast +internal +cache +is +now +used +unconditionally +with +no +additional +dependencies . -Features -that -aren -' -t -enabled -by -default -are -noted +This +may +change +in +the +future . # # # -Ecosystem +Unicode features * * * -std +unicode * * - -When +Enables +all +Unicode +features +. +This +feature +is enabled -this +by +default +and will -cause -regex -to -use +always +cover +all +Unicode +features +even +if +more +are +added +in the -standard -library +future . -In -terms -of -APIs -std -causes -error -types -to -implement +* +* +* +unicode +- +age +* +* +- +Provide the -std -: -: -error +data +for +the +[ +Unicode +Age +property +] +( +https : +/ +/ +www +. +unicode +. +org +/ +reports +/ +tr44 +/ +tr44 +- +24 +. +html +# +Character_Age +) +. +This +makes +it +possible +to +use +classes +like +\ +p +{ +Age : -Error -trait +6 . -Enabling -std -will -also -result +0 +} +to +refer +to +all +codepoints +first +introduced in -performance -optimizations -including -SIMD -and -faster -synchronization -primitives +Unicode +6 . -Notably +0 * * -disabling -the -std -feature -will -result -in -the -use -of -spin -locks +* +unicode +- +bool * * +- +Provide +the +data +for +numerous +Unicode +boolean +properties . -To -use -a -regex -engine -without -std +The +full +list +is +not +included +here +but +contains +properties +like +Alphabetic +Emoji +Lowercase +Math +Uppercase and -without -spin -locks -you -' -ll -need -to -drop -down -to +White_Space +. +* +* +* +unicode +- +case +* +* +- +Provide the +data +for +case +insensitive +matching +using [ -regex -- -automata +Unicode +' +s +" +simple +loose +matches +" +specification ] ( https : / / -docs -. -rs +www +. +unicode +. +org +/ +reports +/ +tr18 / -regex -- -automata +# +Simple_Loose_Matches ) -crate . * * * -logging +unicode +- +gencat * * - -When -enabled +Provide the -log -crate -is -used -to -emit -messages -about -regex -compilation -and -search -strategies -. -This -is -* -* -disabled -by -default -* -* +data +for +[ +Unicode +general +categories +] +( +https +: +/ +/ +www . -This -is -typically -only -useful -to -someone -working -on -this -crate -' -s -internals -but -might -be -useful -if -you -' -re -doing -some -rabbit -hole -performance -hacking +unicode . -Or -if -you -' -re -just -interested -in -the -kinds -of -decisions -being -made -by -the -regex -engine +org +/ +reports +/ +tr44 +/ +tr44 +- +24 . +html # -# -# -Performance -features -* -* -* -perf -* -* -- -Enables -all -performance -related -features -except -for -perf -- -dfa -- -full +General_Category_Values +) . This -feature -is -enabled -by -default +includes +but is -intended +not +limited to -cover -all -reasonable -features -that -improve -performance -even -if -more -are -added -in -the -future +Decimal_Number +Letter +Math_Symbol +Number +and +Punctuation . * * * -perf +unicode - -dfa +perl * * - -Enables +Provide the -use -of -a -lazy -DFA +data for -matching -. -The -lazy -DFA -is -used -to -compile -portions -of -a -regex -to -a -very -fast -DFA -on -an -as +supporting +the +Unicode - -needed -basis +aware +Perl +character +classes +corresponding +to +\ +w +\ +s +and +\ +d . This -can -result -in -substantial -speedups -usually -by -an -order -of -magnitude -on -large -haystacks +is +also +necessary +for +using +Unicode +- +aware +word +boundary +assertions . -The -lazy -DFA -does -not -bring -in -any -new -dependencies -but -it -can -make -compile -times -longer +Note +that +if +this +feature +is +disabled +the +\ +s +and +\ +d +character +classes +are +still +available +if +the +unicode +- +bool +and +unicode +- +gencat +features +are +enabled +respectively . * * * -perf -- -dfa +unicode - -full +script * * - -Enables +Provide the -use -of -a -full -DFA +data for -matching -. -Full -DFAs -are -problematic -because -they -have -worst -case -O +[ +Unicode +scripts +and +script +extensions +] ( -2 -^ -n -) -construction -time +https +: +/ +/ +www . -For -this -reason -when -this -feature -is -enabled -full -DFAs -are -only -used -for -very -small -regexes -and -a -very -small -space -bound -is -used -during -determinization -to -avoid -the -DFA -from -blowing -up +unicode +. +org +/ +reports +/ +tr24 +/ +) . This -feature +includes +but is not -enabled -by -default -even -as -part -of -perf -because -it -results -in -fairly -sizeable -increases -in -binary -size -and -compilation -time -. -It -can -result -in -faster -search -times -but -they -tend -to -be -more -modest -and limited to -non -- -Unicode -regexes +Arabic +Cyrillic +Hebrew +Latin +and +Thai . * * * -perf +unicode - -onepass +segment * * - -Enables +Provide the -use -of -a -one -- -pass -DFA -for -extracting +data +necessary +to +provide the -positions -of -capture -groups +properties +used +to +implement +the +[ +Unicode +text +segmentation +algorithms +] +( +https +: +/ +/ +www +. +unicode +. +org +/ +reports +/ +tr29 +/ +) . This -optimization -applies -to -a -subset -of -certain -types -of -NFAs +enables +using +classes +like +\ +p +{ +gcb += +Extend +} +\ +p +{ +wb += +Katakana +} +and +\ +p +{ +sb += +ATerm +} +. +# +Untrusted +input +This +crate +can +handle +both +untrusted +regular +expressions and -represents +untrusted +search +text +. +Untrusted +regular +expressions +are +handled +by +capping the -fastest -engine -in +size +of +a +compiled +regular +expression +. +( +See +[ +RegexBuilder +: +: +size_limit +] +( +struct +. +RegexBuilder +. +html +# +method +. +size_limit +) +. +) +Without this -crate +it +would +be +trivial for -dealing +an +attacker +to +exhaust +your +system +' +s +memory with -capture -groups -. -* -* -* -perf -- -backtrack -* -* -- -Enables -the -use -of +expressions +like a -bounded -backtracking -algorithm -for -extracting -the -positions -of -capture -groups +{ +100 +} +{ +100 +} +{ +100 +} . -This -usually -sits -between +Untrusted +search +text +is +allowed +because the -slowest +matching engine ( -the -PikeVM +s ) -and -the -fastest -engine +in +this +crate +have +time +complexity +O ( -one -- -pass -DFA +mn ) -for -extracting -capture -groups -. -It +( +with +m +~ +regex +and +n +~ +search +text +) +which +means +there ' s -used -whenever -the -regex -is -not -one +no +way +to +cause +exponential +blow - -pass -and -is -small -enough +up +like +with +some +other +regular +expression +engines . -* -* -* -perf -- -inline -* -* +( +We +pay +for +this +by +disallowing +features +like +arbitrary +look - -Enables -the -use -of -aggressive -inlining -inside -match -routines -. -This -reduces -the -overhead -of -each -match -. -The -aggressive -inlining -however -increases -compile -times +ahead and -binary -size +backreferences . -* -* -* -perf -- -literal -* -* +) +When +a +DFA +is +used +pathological +cases +with +exponential +state +blow - -Enables -the -use -of -literal -optimizations -for -speeding up -matches +are +avoided +by +constructing +the +DFA +lazily +or +in +an +" +online +" +manner . -In -some -cases -literal -optimizations +Therefore +at +most +one +new +state can -result -in -speedups -of -_several_ -orders +be +created +for +each +byte of -magnitude -. -Disabling -this -drops -the -aho -- -corasick -and -memchr -dependencies +input . -* -* -* -perf -- -cache -* -* -- This -feature -used +satisfies +our +time +complexity +guarantees +but +can +lead to -enable +memory +growth +proportional +to +the +size +of +the +input +. +As a -faster -internal -cache -at +stopgap the -cost +DFA +is +only +allowed +to +store +a +fixed +number of -using -additional -dependencies -but -this +states +. +When +the +limit is -no -longer -an -option +reached +its +states +are +wiped +and +continues +on +possibly +duplicating +previous +work . -A -fast -internal -cache +If +the +limit is -now -used -unconditionally +reached +too +frequently +it +gives +up +and +hands +control +off +to +another +matching +engine with -no -additional -dependencies +fixed +memory +requirements . -This -may -change -in -the -future +( +The +DFA +size +limit +can +also +be +tweaked +. +See +[ +RegexBuilder +: +: +dfa_size_limit +] +( +struct +. +RegexBuilder . +html # +method +. +dfa_size_limit +) +. +) +* +/ # +! +[ +deny +( +missing_docs +) +] # -Unicode -features -* -* -* -unicode -* -* -- -Enables -all -Unicode -features -. -This +! +[ +cfg_attr +( +feature += +" +pattern +" +feature +( +pattern +) +) +] +# +! +[ +warn +( +missing_debug_implementations +) +] +# +[ +cfg +( +not +( +feature += +" +std +" +) +) +] +compile_error +! +( +" +std feature is -enabled -by -default -and -will -always -cover -all -Unicode -features -even -if -more -are -added -in +currently +required +to +build +this +crate +" +) +; +/ +/ +To +check +README +' +s +example +/ +/ +TODO +: +Re +- +enable +this +once the -future +MSRV +is +1 . -* -* -* -unicode +43 +or +greater +. +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust - -age -* -* +lang +/ +regex +/ +issues +/ +684 +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust - -Provide -the -data -for -the +lang +/ +regex +/ +issues +/ +685 +/ +/ +# [ -Unicode -Age -property +cfg +( +doctest +) ] -( -https -: / / -www +doc_comment +: +: +doctest +! +( +" . -unicode . -org -/ -reports -/ -tr44 / -tr44 -- -24 +README . -html +md +" +) +; # -Character_Age +[ +cfg +( +feature += +" +std +" ) -. -This -makes -it -possible -to +] +pub use -classes -like -\ -p -{ -Age +crate +: +: +error +: +: +Error +; +# +[ +cfg +( +feature += +" +std +" +) +] +pub +use +crate +: +: +re_builder +: +: +set_unicode +: : -6 -. -0 -} -to -refer -to -all -codepoints -first -introduced -in -Unicode -6 -. -0 -* -* -* -unicode -- -bool -* -* -- -Provide -the -data -for -numerous -Unicode -boolean -properties -. -The -full -list -is -not -included -here -but -contains -properties -like -Alphabetic -Emoji -Lowercase -Math -Uppercase -and -White_Space -. -* -* * +; +# +[ +cfg +( +feature += +" +std +" +) +] +pub +use +crate +: +: +re_builder +: +: unicode -- -case -* +: +: * -- -Provide -the -data -for -case -insensitive -matching -using +; +# [ -Unicode -' -s +cfg +( +feature += " -simple -loose -matches +std " -specification +) ] -( -https +pub +use +crate +: +: +re_set +: : -/ -/ -www -. unicode -. -org -/ -reports -/ -tr18 -/ +: +: +* +; # -Simple_Loose_Matches +[ +cfg +( +feature += +" +std +" ) -. -* -* -* -unicode -- -gencat +] +pub +use +crate +: +: +re_unicode +: +: +{ +escape +CaptureLocations +CaptureMatches +CaptureNames +Captures +Locations +Match +Matches +NoExpand +Regex +Replacer +ReplacerRef +Split +SplitN +SubCaptureMatches +} +; +/ * * -- -Provide +Match +regular +expressions +on +arbitrary +bytes +. +This +module +provides +a +nearly +identical +API +to the -data -for +one +found +in +the +top +- +level +of +this +crate +. +There +are +two +important +differences +: +1 +. +Matching +is +done +on +& [ -Unicode -general -categories +u8 ] -( -https -: -/ -/ -www +instead +of +& +str . -unicode +Additionally +Vec +< +u8 +> +is +used +where +String +would +have +been +used . -org -/ -reports -/ -tr44 -/ -tr44 +2 +. +Unicode +support +can +be +disabled +even +when +disabling +it +would +result +in +matching +invalid +UTF - -24 +8 +bytes . -html # -General_Category_Values -) -. +Example +: +match +null +terminated +string This -includes -but -is -not -limited +shows +how to -Decimal_Number -Letter -Math_Symbol -Number -and -Punctuation -. -* -* -* -unicode -- -perl -* -* +find +all +null - -Provide -the -data -for -supporting -the -Unicode +terminated +strings +in +a +slice +of +bytes +: +rust +# +use +regex +: +: +bytes +: +: +Regex +; +let +re += +Regex +: +: +new +( +r +" +( +? - -aware -Perl -character -classes -corresponding -to -\ -w +u +) +( +? +P +< +cstr +> +[ +^ \ -s -and +x00 +] ++ +) \ -d -. -This -is -also -necessary -for -using -Unicode -- -aware -word -boundary -assertions +x00 +" +) . -Note -that -if -this -feature -is -disabled -the +unwrap +( +) +; +let +text += +b +" +foo \ -s -and +x00bar \ -d -character -classes -are -still -available -if +x00baz +\ +x00 +" +; +/ +/ +Extract +all +of the -unicode -- -bool -and -unicode -- -gencat -features -are -enabled -respectively +strings +without +the +null +terminator +from +each +match . -* -* -* -unicode -- -script -* -* -- -Provide +/ +/ +The +unwrap +is +OK +here +since +a +match +requires the -data -for +cstr +capture +to +match +. +let +cstrs +: +Vec +< +& [ -Unicode -scripts -and -script -extensions +u8 ] +> += +re +. +captures_iter ( -https -: -/ -/ -www +text +) . -unicode +map +( +| +c +| +c . -org -/ -reports -/ -tr24 -/ +name +( +" +cstr +" +) +. +unwrap +( +) +. +as_bytes +( +) +) +. +collect +( ) +; +assert_eq +! +( +vec +! +[ +& +b +" +foo +" +[ +. +. +] +& +b +" +bar +" +[ +. +. +] +& +b +" +baz +" +[ . +. +] +] +cstrs +) +; +# +Example +: +selectively +enable +Unicode +support This -includes -but -is -not -limited +shows +how to -Arabic -Cyrillic -Hebrew -Latin -and -Thai +match +an +arbitrary +byte +pattern +followed +by +a +UTF +- +8 +encoded +string +( +e . -* -* -* -unicode +g +. +to +extract +a +title +from +a +Matroska +file +) +: +rust +# +use +std +: +: +str +; +# +use +regex +: +: +bytes +: +: +Regex +; +let +re += +Regex +: +: +new +( +r +" +( +? - -segment -* -* +u +) +\ +x7b +\ +xa9 +( +? +: +[ +\ +x80 - -Provide -the -data -necessary -to -provide -the -properties -used -to -implement -the +\ +xfe +] +| [ -Unicode -text -segmentation -algorithms +\ +x40 +- +\ +xff ] +. +) ( -https +? +u : -/ -/ -www -. -unicode +( . -org -/ -reports -/ -tr29 -/ +* +) +) +" ) . -This -enables -using -classes -like -\ -p -{ -gcb +unwrap +( +) +; +let +text = -Extend -} +b +" +\ +x12 +\ +xd0 +\ +x3b +\ +x5f +\ +x7b +\ +xa9 +\ +x85 +\ +xe2 +\ +x98 +\ +x83 +\ +x80 +\ +x98 +\ +x54 +\ +x76 \ -p -{ -wb -= -Katakana -} -and +x68 \ -p -{ -sb +x65 +" +; +let +caps = -ATerm -} +re . -# -Other -crates -This -crate -has -two -required -dependencies -and -several -optional -dependencies +captures +( +text +) . -This -section -briefly -describes -them -with +unwrap +( +) +; +/ +/ +Notice +that +despite the -goal -of -raising -awareness -of -how -different -components -of -this -crate -may -be -used -independently . -It -is -somewhat -unusual -for -a -regex -engine -to -have -dependencies -as -most -regex -libraries -are -self -contained -units +* +at +the +end +it +will +only +match +valid +UTF +- +8 +/ +/ +because +Unicode +mode +was +enabled with -no -dependencies -other -than -a -particular -environment -' -s -standard -library -. -Indeed -for -other -similarly -optimized -regex -engines -most -or -all -of the -code -in +u +flag +. +Without the -dependencies -of -this -crate -would -normally -just -be -unseparable -or -coupled -parts -of +u +flag +/ +/ the -crate -itself . -But -since -Rust -and -its -tooling -ecosystem -make +* +would +match the -use -of -dependencies -so -easy -it -made -sense -to -spend -some -effort -de -- -coupling -parts +rest of -this -crate -and -making -them -independently -useful +the +bytes . -We -only -briefly -describe -each -crate -here +let +mat += +caps . -* -[ -regex -- -lite -] +get ( -https -: -/ -/ -docs -. -rs -/ -regex -- -lite +1 ) -is -not -a -dependency -of -regex -but -rather -a -standalone -zero -- -dependency -simpler -version -of -regex -that -prioritizes -compile -times -and -binary -size . -In -exchange -it -eschews -Unicode -support -and -performance +unwrap +( +) +; +assert_eq +! +( +( +7 +10 +) +( +mat . -Its -match -semantics -are -as -identical -as -possible -to -the -regex -crate -and -for -the -things -it -supports -its -APIs -are -identical -to -the -APIs -in -this -crate +start +( +) +mat . -In -other -words -for -a -lot -of -use -cases -it -is +end +( +) +) +) +; +/ +/ +If +there +was a -drop +match +Unicode +mode +guarantees +that +title +is +valid +UTF - -in -replacement +8 . -* +let +title += +str +: +: +from_utf8 +( +& +caps [ -regex -- -syntax +1 ] -( -https -: -/ -/ -docs +) . -rs -/ -regex -- -syntax +unwrap +( ) -provides +; +assert_eq +! +( +" +" +title +) +; +In +general +if +the +Unicode +flag +is +enabled +in a -regular -expression -parser -via -Ast +capture +group and -Hir -types +that +capture +is +part +of +the +overall +match +then +the +capture +is +* +guaranteed +* +to +be +valid +UTF +- +8 . -It -also -provides -routines +# +Syntax +The +supported +syntax +is +pretty +much +the +same +as +the +syntax for -extracting -literals -from +Unicode +regular +expressions +with a -pattern +few +changes +that +make +sense +for +matching +arbitrary +bytes +: +1 . -Folks +The +u +flag can -use -this -crate -to -do -analysis -or +be +disabled even -to -build -their -own +when +disabling +it +might +cause +the regex -engine -without -having to -worry -about -writing -a -parser -. -* -[ -regex +match +invalid +UTF - -automata -] -( -https -: -/ -/ -docs +8 . -rs -/ -regex -- -automata -) -provides +When the -regex -engines -themselves -. -One -of +u +flag +is +disabled the -downsides -of -finite -automata -based regex -engines is -that -they -often -need -multiple -internal -engines -in -order +said to -have -similar -or -better -performance -than -an -unbounded -backtracking -engine +be in -practice +" +ASCII +compatible +" +mode . -regex -- -automata -in -particular -provides -public -APIs -for -a -PikeVM -a -bounded -backtracker -a -one -- -pass -DFA -a -lazy -DFA -a -fully -compiled -DFA -and -a -meta -regex -engine -that -combines -all -them -together +2 . -It -also -has -native -multi -- -pattern -support -and -provides -a -way -to -compile -and -serialize -full -DFAs -such -that -they -can -be -loaded +In +ASCII +compatible +mode +neither +Unicode +scalar +values +nor +Unicode +character +classes +are +allowed +. +3 +. +In +ASCII +compatible +mode +Perl +character +classes +( +\ +w +\ +d and -searched -in -a -no -- -std -no -- -alloc -environment +\ +s +) +revert +to +their +typical +ASCII +definition . -regex -- -automata -itself -doesn -' -t -even -have -a -required -dependency -on -regex -- -syntax -! -* +\ +w +maps +to [ -memchr +[ +: +word +: ] -( -https +] +\ +d +maps +to +[ +[ : -/ -/ -docs +digit +: +] +] +and +\ +s +maps +to +[ +[ +: +space +: +] +] . -rs -/ -memchr -) -provides -low -level -SIMD -vectorized -routines -for -quickly -finding +4 +. +In +ASCII +compatible +mode +word +boundaries +use the -location -of -single -bytes -or -even -substrings -in +ASCII +compatible +\ +w +to +determine +whether +a +byte +is a -haystack +word +byte +or +not . -In -other -words -it -provides -fast -memchr -and -memmem -routines +5 . -These -are +Hexadecimal +notation +can +be used -by -this -crate -in -literal -optimizations -. -* -[ -aho -- -corasick -] -( -https -: -/ -/ -docs -. -rs -/ -aho -- -corasick -) -provides -multi -- -substring -search +to +specify +arbitrary +bytes +instead +of +Unicode +codepoints . -It -also -provides -SIMD -vectorized -routines +For +example in +ASCII +compatible +mode +\ +xFF +matches the -case -where -the -number -of -substrings -to -search -for +literal +byte +\ +xFF +while +in +Unicode +mode +\ +xFF is -relatively -small +a +Unicode +codepoint +that +matches +its +UTF +- +8 +encoding +of +\ +xC3 +\ +xBF . -The -regex -crate -also -uses -this +Similarly for -literal -optimizations +octal +notation +when +enabled +. +6 +. +In +ASCII +compatible +mode . +matches +any * -/ -# -! -[ -no_std -] -# -! -[ -deny -( -missing_docs -) -] -# -! -[ -cfg_attr -( -feature -= -" -pattern -" -feature -( -pattern -) -) -] -# -! -[ -warn -( -missing_debug_implementations -) -] +byte +* +except +for +\ +n +. +When +the +s +flag +is +additionally +enabled +. +matches +any +byte +. # +Performance +In +general +one +should +expect +performance +on +& [ -cfg -( -doctest -) +u8 ] -doc_comment -: -: -doctest -! -( -" -. +to +be +roughly +similar +to +performance +on +& +str . +* / -README -. -md -" -) -; -extern -crate -alloc -; # [ cfg ( -any -( -test feature = " std " ) -) ] -extern -crate -std -; +pub +mod +bytes +{ pub use crate : : -error +re_builder : : -Error +bytes +: +: +* ; pub use crate : : -{ -builders +re_builder : : -string +set_bytes : : * -regex +; +pub +use +crate : : -string +re_bytes : : * -regexset +; +pub +use +crate : : -string +re_set +: +: +bytes : : * +; } +mod +backtrack ; mod -builders +compile ; -pub +# +[ +cfg +( +feature += +" +perf +- +dfa +" +) +] mod -bytes +dfa ; mod error ; mod +exec +; +mod +expand +; +mod find_byte ; +mod +input +; +mod +literal +; # [ cfg @@ -13820,71 +7065,150 @@ mod pattern ; mod -regex +pikevm ; mod -regexset +pool +; +mod +prog +; +mod +re_builder +; +mod +re_bytes +; +mod +re_set +; +mod +re_trait +; +mod +re_unicode +; +mod +sparse +; +mod +utf8 ; / / / -Escapes -all -regular -expression -meta -characters -in -pattern -. -/ -/ -/ +The +internal +module +exists +to +support +suspicious +activity +such +as / / / -The -string -returned -may -be -safely -used -as -a -literal -in -a -regular +testing +different +matching +engines +and +supporting +the +regex +- +debug +CLI / / / -expression +utility . -pub -fn -escape +# +[ +doc ( -pattern -: -& -str +hidden ) -- -> -alloc +] +# +[ +cfg +( +feature += +" +std +" +) +] +pub +mod +internal +{ +pub +use +crate : : -string +compile +: +: +Compiler +; +pub +use +crate +: +: +exec +: +: +{ +Exec +ExecBuilder +} +; +pub +use +crate +: +: +input : : -String { -regex_syntax +Char +CharInput +Input +InputAt +} +; +pub +use +crate : : -escape -( -pattern -) +literal +: +: +LiteralSearcher +; +pub +use +crate +: +: +prog +: +: +{ +EmptyLook +Inst +InstRanges +Program +} +; } diff --git a/third_party/rust/regex/src/literal/imp.rs b/third_party/rust/regex/src/literal/imp.rs new file mode 100644 index 0000000000000..60e4c33798cdc --- /dev/null +++ b/third_party/rust/regex/src/literal/imp.rs @@ -0,0 +1,3040 @@ +use +std +: +: +mem +; +use +aho_corasick +: +: +{ +self +packed +AhoCorasick +AhoCorasickBuilder +} +; +use +memchr +: +: +{ +memchr +memchr2 +memchr3 +memmem +} +; +use +regex_syntax +: +: +hir +: +: +literal +: +: +{ +Literal +Literals +} +; +/ +/ +/ +A +prefix +extracted +from +a +compiled +regular +expression +. +/ +/ +/ +/ +/ +/ +A +regex +prefix +is +a +set +of +literal +strings +that +* +must +* +be +matched +at +the +/ +/ +/ +beginning +of +a +regex +in +order +for +the +entire +regex +to +match +. +Similarly +/ +/ +/ +for +a +regex +suffix +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +LiteralSearcher +{ +complete +: +bool +lcp +: +Memmem +lcs +: +Memmem +matcher +: +Matcher +} +# +[ +derive +( +Clone +Debug +) +] +enum +Matcher +{ +/ +/ +/ +No +literals +. +( +Never +advances +through +the +input +. +) +Empty +/ +/ +/ +A +set +of +four +or +more +single +byte +literals +. +Bytes +( +SingleByteSet +) +/ +/ +/ +A +single +substring +using +vector +accelerated +routines +when +available +. +Memmem +( +Memmem +) +/ +/ +/ +An +Aho +- +Corasick +automaton +. +AC +{ +ac +: +AhoCorasick +< +u32 +> +lits +: +Vec +< +Literal +> +} +/ +/ +/ +A +packed +multiple +substring +searcher +using +SIMD +. +/ +/ +/ +/ +/ +/ +Note +that +Aho +- +Corasick +will +actually +use +this +packed +searcher +/ +/ +/ +internally +automatically +however +there +is +some +overhead +associated +/ +/ +/ +with +going +through +the +Aho +- +Corasick +machinery +. +So +using +the +packed +/ +/ +/ +searcher +directly +results +in +some +gains +. +Packed +{ +s +: +packed +: +: +Searcher +lits +: +Vec +< +Literal +> +} +} +impl +LiteralSearcher +{ +/ +/ +/ +Returns +a +matcher +that +never +matches +and +never +advances +the +input +. +pub +fn +empty +( +) +- +> +Self +{ +Self +: +: +new +( +Literals +: +: +empty +( +) +Matcher +: +: +Empty +) +} +/ +/ +/ +Returns +a +matcher +for +literal +prefixes +from +the +given +set +. +pub +fn +prefixes +( +lits +: +Literals +) +- +> +Self +{ +let +matcher += +Matcher +: +: +prefixes +( +& +lits +) +; +Self +: +: +new +( +lits +matcher +) +} +/ +/ +/ +Returns +a +matcher +for +literal +suffixes +from +the +given +set +. +pub +fn +suffixes +( +lits +: +Literals +) +- +> +Self +{ +let +matcher += +Matcher +: +: +suffixes +( +& +lits +) +; +Self +: +: +new +( +lits +matcher +) +} +fn +new +( +lits +: +Literals +matcher +: +Matcher +) +- +> +Self +{ +let +complete += +lits +. +all_complete +( +) +; +LiteralSearcher +{ +complete +lcp +: +Memmem +: +: +new +( +lits +. +longest_common_prefix +( +) +) +lcs +: +Memmem +: +: +new +( +lits +. +longest_common_suffix +( +) +) +matcher +} +} +/ +/ +/ +Returns +true +if +all +matches +comprise +the +entire +regular +expression +. +/ +/ +/ +/ +/ +/ +This +does +not +necessarily +mean +that +a +literal +match +implies +a +match +/ +/ +/ +of +the +regular +expression +. +For +example +the +regular +expression +^ +a +/ +/ +/ +is +comprised +of +a +single +complete +literal +a +but +the +regular +/ +/ +/ +expression +demands +that +it +only +match +at +the +beginning +of +a +string +. +pub +fn +complete +( +& +self +) +- +> +bool +{ +self +. +complete +& +& +! +self +. +is_empty +( +) +} +/ +/ +/ +Find +the +position +of +a +literal +in +haystack +if +it +exists +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +pub +fn +find +( +& +self +haystack +: +& +[ +u8 +] +) +- +> +Option +< +( +usize +usize +) +> +{ +use +self +: +: +Matcher +: +: +* +; +match +self +. +matcher +{ +Empty += +> +Some +( +( +0 +0 +) +) +Bytes +( +ref +sset +) += +> +sset +. +find +( +haystack +) +. +map +( +| +i +| +( +i +i ++ +1 +) +) +Memmem +( +ref +s +) += +> +s +. +find +( +haystack +) +. +map +( +| +i +| +( +i +i ++ +s +. +len +( +) +) +) +AC +{ +ref +ac +. +. +} += +> +{ +ac +. +find +( +haystack +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +} +Packed +{ +ref +s +. +. +} += +> +{ +s +. +find +( +haystack +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +} +} +} +/ +/ +/ +Like +find +except +matches +must +start +at +index +0 +. +pub +fn +find_start +( +& +self +haystack +: +& +[ +u8 +] +) +- +> +Option +< +( +usize +usize +) +> +{ +for +lit +in +self +. +iter +( +) +{ +if +lit +. +len +( +) +> +haystack +. +len +( +) +{ +continue +; +} +if +lit += += +& +haystack +[ +0 +. +. +lit +. +len +( +) +] +{ +return +Some +( +( +0 +lit +. +len +( +) +) +) +; +} +} +None +} +/ +/ +/ +Like +find +except +matches +must +end +at +index +haystack +. +len +( +) +. +pub +fn +find_end +( +& +self +haystack +: +& +[ +u8 +] +) +- +> +Option +< +( +usize +usize +) +> +{ +for +lit +in +self +. +iter +( +) +{ +if +lit +. +len +( +) +> +haystack +. +len +( +) +{ +continue +; +} +if +lit += += +& +haystack +[ +haystack +. +len +( +) +- +lit +. +len +( +) +. +. +] +{ +return +Some +( +( +haystack +. +len +( +) +- +lit +. +len +( +) +haystack +. +len +( +) +) +) +; +} +} +None +} +/ +/ +/ +Returns +an +iterator +over +all +literals +to +be +matched +. +pub +fn +iter +( +& +self +) +- +> +LiteralIter +< +' +_ +> +{ +match +self +. +matcher +{ +Matcher +: +: +Empty += +> +LiteralIter +: +: +Empty +Matcher +: +: +Bytes +( +ref +sset +) += +> +LiteralIter +: +: +Bytes +( +& +sset +. +dense +) +Matcher +: +: +Memmem +( +ref +s +) += +> +LiteralIter +: +: +Single +( +& +s +. +finder +. +needle +( +) +) +Matcher +: +: +AC +{ +ref +lits +. +. +} += +> +LiteralIter +: +: +AC +( +lits +) +Matcher +: +: +Packed +{ +ref +lits +. +. +} += +> +LiteralIter +: +: +Packed +( +lits +) +} +} +/ +/ +/ +Returns +a +matcher +for +the +longest +common +prefix +of +this +matcher +. +pub +fn +lcp +( +& +self +) +- +> +& +Memmem +{ +& +self +. +lcp +} +/ +/ +/ +Returns +a +matcher +for +the +longest +common +suffix +of +this +matcher +. +pub +fn +lcs +( +& +self +) +- +> +& +Memmem +{ +& +self +. +lcs +} +/ +/ +/ +Returns +true +iff +this +prefix +is +empty +. +pub +fn +is_empty +( +& +self +) +- +> +bool +{ +self +. +len +( +) += += +0 +} +/ +/ +/ +Returns +the +number +of +prefixes +in +this +machine +. +pub +fn +len +( +& +self +) +- +> +usize +{ +use +self +: +: +Matcher +: +: +* +; +match +self +. +matcher +{ +Empty += +> +0 +Bytes +( +ref +sset +) += +> +sset +. +dense +. +len +( +) +Memmem +( +_ +) += +> +1 +AC +{ +ref +ac +. +. +} += +> +ac +. +pattern_count +( +) +Packed +{ +ref +lits +. +. +} += +> +lits +. +len +( +) +} +} +/ +/ +/ +Return +the +approximate +heap +usage +of +literals +in +bytes +. +pub +fn +approximate_size +( +& +self +) +- +> +usize +{ +use +self +: +: +Matcher +: +: +* +; +match +self +. +matcher +{ +Empty += +> +0 +Bytes +( +ref +sset +) += +> +sset +. +approximate_size +( +) +Memmem +( +ref +single +) += +> +single +. +approximate_size +( +) +AC +{ +ref +ac +. +. +} += +> +ac +. +heap_bytes +( +) +Packed +{ +ref +s +. +. +} += +> +s +. +heap_bytes +( +) +} +} +} +impl +Matcher +{ +fn +prefixes +( +lits +: +& +Literals +) +- +> +Self +{ +let +sset += +SingleByteSet +: +: +prefixes +( +lits +) +; +Matcher +: +: +new +( +lits +sset +) +} +fn +suffixes +( +lits +: +& +Literals +) +- +> +Self +{ +let +sset += +SingleByteSet +: +: +suffixes +( +lits +) +; +Matcher +: +: +new +( +lits +sset +) +} +fn +new +( +lits +: +& +Literals +sset +: +SingleByteSet +) +- +> +Self +{ +if +lits +. +literals +( +) +. +is_empty +( +) +{ +return +Matcher +: +: +Empty +; +} +if +sset +. +dense +. +len +( +) +> += +26 +{ +/ +/ +Avoid +trying +to +match +a +large +number +of +single +bytes +. +/ +/ +This +is +* +very +* +sensitive +to +a +frequency +analysis +comparison +/ +/ +between +the +bytes +in +sset +and +the +composition +of +the +haystack +. +/ +/ +No +matter +the +size +of +sset +if +its +members +all +are +rare +in +the +/ +/ +haystack +then +it +' +d +be +worth +using +it +. +How +to +tune +this +. +. +. +IDK +. +/ +/ +- +- +- +AG +return +Matcher +: +: +Empty +; +} +if +sset +. +complete +{ +return +Matcher +: +: +Bytes +( +sset +) +; +} +if +lits +. +literals +( +) +. +len +( +) += += +1 +{ +return +Matcher +: +: +Memmem +( +Memmem +: +: +new +( +& +lits +. +literals +( +) +[ +0 +] +) +) +; +} +let +pats += +lits +. +literals +( +) +. +to_owned +( +) +; +let +is_aho_corasick_fast += +sset +. +dense +. +len +( +) +< += +1 +& +& +sset +. +all_ascii +; +if +lits +. +literals +( +) +. +len +( +) +< += +100 +& +& +! +is_aho_corasick_fast +{ +let +mut +builder += +packed +: +: +Config +: +: +new +( +) +. +match_kind +( +packed +: +: +MatchKind +: +: +LeftmostFirst +) +. +builder +( +) +; +if +let +Some +( +s +) += +builder +. +extend +( +& +pats +) +. +build +( +) +{ +return +Matcher +: +: +Packed +{ +s +lits +: +pats +} +; +} +} +let +ac += +AhoCorasickBuilder +: +: +new +( +) +. +match_kind +( +aho_corasick +: +: +MatchKind +: +: +LeftmostFirst +) +. +dfa +( +true +) +. +build_with_size +: +: +< +u32 +_ +_ +> +( +& +pats +) +. +unwrap +( +) +; +Matcher +: +: +AC +{ +ac +lits +: +pats +} +} +} +# +[ +derive +( +Debug +) +] +pub +enum +LiteralIter +< +' +a +> +{ +Empty +Bytes +( +& +' +a +[ +u8 +] +) +Single +( +& +' +a +[ +u8 +] +) +AC +( +& +' +a +[ +Literal +] +) +Packed +( +& +' +a +[ +Literal +] +) +} +impl +< +' +a +> +Iterator +for +LiteralIter +< +' +a +> +{ +type +Item += +& +' +a +[ +u8 +] +; +fn +next +( +& +mut +self +) +- +> +Option +< +Self +: +: +Item +> +{ +match +* +self +{ +LiteralIter +: +: +Empty += +> +None +LiteralIter +: +: +Bytes +( +ref +mut +many +) += +> +{ +if +many +. +is_empty +( +) +{ +None +} +else +{ +let +next += +& +many +[ +0 +. +. +1 +] +; +* +many += +& +many +[ +1 +. +. +] +; +Some +( +next +) +} +} +LiteralIter +: +: +Single +( +ref +mut +one +) += +> +{ +if +one +. +is_empty +( +) +{ +None +} +else +{ +let +next += +& +one +[ +. +. +] +; +* +one += +& +[ +] +; +Some +( +next +) +} +} +LiteralIter +: +: +AC +( +ref +mut +lits +) += +> +{ +if +lits +. +is_empty +( +) +{ +None +} +else +{ +let +next += +& +lits +[ +0 +] +; +* +lits += +& +lits +[ +1 +. +. +] +; +Some +( +& +* +* +next +) +} +} +LiteralIter +: +: +Packed +( +ref +mut +lits +) += +> +{ +if +lits +. +is_empty +( +) +{ +None +} +else +{ +let +next += +& +lits +[ +0 +] +; +* +lits += +& +lits +[ +1 +. +. +] +; +Some +( +& +* +* +next +) +} +} +} +} +} +# +[ +derive +( +Clone +Debug +) +] +struct +SingleByteSet +{ +sparse +: +Vec +< +bool +> +dense +: +Vec +< +u8 +> +complete +: +bool +all_ascii +: +bool +} +impl +SingleByteSet +{ +fn +new +( +) +- +> +SingleByteSet +{ +SingleByteSet +{ +sparse +: +vec +! +[ +false +; +256 +] +dense +: +vec +! +[ +] +complete +: +true +all_ascii +: +true +} +} +fn +prefixes +( +lits +: +& +Literals +) +- +> +SingleByteSet +{ +let +mut +sset += +SingleByteSet +: +: +new +( +) +; +for +lit +in +lits +. +literals +( +) +{ +sset +. +complete += +sset +. +complete +& +& +lit +. +len +( +) += += +1 +; +if +let +Some +( +& +b +) += +lit +. +get +( +0 +) +{ +if +! +sset +. +sparse +[ +b +as +usize +] +{ +if +b +> +0x7F +{ +sset +. +all_ascii += +false +; +} +sset +. +dense +. +push +( +b +) +; +sset +. +sparse +[ +b +as +usize +] += +true +; +} +} +} +sset +} +fn +suffixes +( +lits +: +& +Literals +) +- +> +SingleByteSet +{ +let +mut +sset += +SingleByteSet +: +: +new +( +) +; +for +lit +in +lits +. +literals +( +) +{ +sset +. +complete += +sset +. +complete +& +& +lit +. +len +( +) += += +1 +; +if +let +Some +( +& +b +) += +lit +. +get +( +lit +. +len +( +) +. +checked_sub +( +1 +) +. +unwrap +( +) +) +{ +if +! +sset +. +sparse +[ +b +as +usize +] +{ +if +b +> +0x7F +{ +sset +. +all_ascii += +false +; +} +sset +. +dense +. +push +( +b +) +; +sset +. +sparse +[ +b +as +usize +] += +true +; +} +} +} +sset +} +/ +/ +/ +Faster +find +that +special +cases +certain +sizes +to +use +memchr +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +find +( +& +self +text +: +& +[ +u8 +] +) +- +> +Option +< +usize +> +{ +match +self +. +dense +. +len +( +) +{ +0 += +> +None +1 += +> +memchr +( +self +. +dense +[ +0 +] +text +) +2 += +> +memchr2 +( +self +. +dense +[ +0 +] +self +. +dense +[ +1 +] +text +) +3 += +> +memchr3 +( +self +. +dense +[ +0 +] +self +. +dense +[ +1 +] +self +. +dense +[ +2 +] +text +) +_ += +> +self +. +_find +( +text +) +} +} +/ +/ +/ +Generic +find +that +works +on +any +sized +set +. +fn +_find +( +& +self +haystack +: +& +[ +u8 +] +) +- +> +Option +< +usize +> +{ +for +( +i +& +b +) +in +haystack +. +iter +( +) +. +enumerate +( +) +{ +if +self +. +sparse +[ +b +as +usize +] +{ +return +Some +( +i +) +; +} +} +None +} +fn +approximate_size +( +& +self +) +- +> +usize +{ +( +self +. +dense +. +len +( +) +* +mem +: +: +size_of +: +: +< +u8 +> +( +) +) ++ +( +self +. +sparse +. +len +( +) +* +mem +: +: +size_of +: +: +< +bool +> +( +) +) +} +} +/ +/ +/ +A +simple +wrapper +around +the +memchr +crate +' +s +memmem +implementation +. +/ +/ +/ +/ +/ +/ +The +API +this +exposes +mirrors +the +API +of +previous +substring +searchers +that +/ +/ +/ +this +supplanted +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +Memmem +{ +finder +: +memmem +: +: +Finder +< +' +static +> +char_len +: +usize +} +impl +Memmem +{ +fn +new +( +pat +: +& +[ +u8 +] +) +- +> +Memmem +{ +Memmem +{ +finder +: +memmem +: +: +Finder +: +: +new +( +pat +) +. +into_owned +( +) +char_len +: +char_len_lossy +( +pat +) +} +} +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +pub +fn +find +( +& +self +haystack +: +& +[ +u8 +] +) +- +> +Option +< +usize +> +{ +self +. +finder +. +find +( +haystack +) +} +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +pub +fn +is_suffix +( +& +self +text +: +& +[ +u8 +] +) +- +> +bool +{ +if +text +. +len +( +) +< +self +. +len +( +) +{ +return +false +; +} +& +text +[ +text +. +len +( +) +- +self +. +len +( +) +. +. +] += += +self +. +finder +. +needle +( +) +} +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +finder +. +needle +( +) +. +len +( +) +} +pub +fn +char_len +( +& +self +) +- +> +usize +{ +self +. +char_len +} +fn +approximate_size +( +& +self +) +- +> +usize +{ +self +. +finder +. +needle +( +) +. +len +( +) +* +mem +: +: +size_of +: +: +< +u8 +> +( +) +} +} +fn +char_len_lossy +( +bytes +: +& +[ +u8 +] +) +- +> +usize +{ +String +: +: +from_utf8_lossy +( +bytes +) +. +chars +( +) +. +count +( +) +} diff --git a/third_party/rust/regex/src/literal/mod.rs b/third_party/rust/regex/src/literal/mod.rs new file mode 100644 index 0000000000000..415b69e735a0a --- /dev/null +++ b/third_party/rust/regex/src/literal/mod.rs @@ -0,0 +1,272 @@ +pub +use +self +: +: +imp +: +: +* +; +# +[ +cfg +( +feature += +" +perf +- +literal +" +) +] +mod +imp +; +# +[ +allow +( +missing_docs +) +] +# +[ +cfg +( +not +( +feature += +" +perf +- +literal +" +) +) +] +mod +imp +{ +use +regex_syntax +: +: +hir +: +: +literal +: +: +Literals +; +# +[ +derive +( +Clone +Debug +) +] +pub +struct +LiteralSearcher +( +( +) +) +; +impl +LiteralSearcher +{ +pub +fn +empty +( +) +- +> +Self +{ +LiteralSearcher +( +( +) +) +} +pub +fn +prefixes +( +_ +: +Literals +) +- +> +Self +{ +LiteralSearcher +( +( +) +) +} +pub +fn +suffixes +( +_ +: +Literals +) +- +> +Self +{ +LiteralSearcher +( +( +) +) +} +pub +fn +complete +( +& +self +) +- +> +bool +{ +false +} +pub +fn +find +( +& +self +_ +: +& +[ +u8 +] +) +- +> +Option +< +( +usize +usize +) +> +{ +unreachable +! +( +) +} +pub +fn +find_start +( +& +self +_ +: +& +[ +u8 +] +) +- +> +Option +< +( +usize +usize +) +> +{ +unreachable +! +( +) +} +pub +fn +find_end +( +& +self +_ +: +& +[ +u8 +] +) +- +> +Option +< +( +usize +usize +) +> +{ +unreachable +! +( +) +} +pub +fn +is_empty +( +& +self +) +- +> +bool +{ +true +} +pub +fn +len +( +& +self +) +- +> +usize +{ +0 +} +pub +fn +approximate_size +( +& +self +) +- +> +usize +{ +0 +} +} +} diff --git a/third_party/rust/regex/src/pattern.rs b/third_party/rust/regex/src/pattern.rs index 0498a1c8cbac3..61cdb482e38bc 100644 --- a/third_party/rust/regex/src/pattern.rs +++ b/third_party/rust/regex/src/pattern.rs @@ -1,5 +1,5 @@ use -core +std : : str @@ -18,6 +18,9 @@ use crate : : +re_unicode +: +: { Matches Regex diff --git a/third_party/rust/regex/src/pikevm.rs b/third_party/rust/regex/src/pikevm.rs new file mode 100644 index 0000000000000..65be200a249d2 --- /dev/null +++ b/third_party/rust/regex/src/pikevm.rs @@ -0,0 +1,2578 @@ +/ +/ +This +module +implements +the +Pike +VM +. +That +is +it +guarantees +linear +time +/ +/ +search +of +a +regex +on +any +text +with +memory +use +proportional +to +the +size +of +/ +/ +the +regex +. +/ +/ +/ +/ +It +is +equal +in +power +to +the +backtracking +engine +in +this +crate +except +the +/ +/ +backtracking +engine +is +typically +faster +on +small +regexes +/ +texts +at +the +/ +/ +expense +of +a +bigger +memory +footprint +. +/ +/ +/ +/ +It +can +do +more +than +the +DFA +can +( +specifically +record +capture +locations +/ +/ +and +execute +Unicode +word +boundary +assertions +) +but +at +a +slower +speed +. +/ +/ +Specifically +the +Pike +VM +executes +a +DFA +implicitly +by +repeatedly +expanding +/ +/ +epsilon +transitions +. +That +is +the +Pike +VM +engine +can +be +in +multiple +states +/ +/ +at +once +where +as +the +DFA +is +only +ever +in +one +state +at +a +time +. +/ +/ +/ +/ +Therefore +the +Pike +VM +is +generally +treated +as +the +fallback +when +the +other +/ +/ +matching +engines +either +aren +' +t +feasible +to +run +or +are +insufficient +. +use +std +: +: +mem +; +use +crate +: +: +exec +: +: +ProgramCache +; +use +crate +: +: +input +: +: +{ +Input +InputAt +} +; +use +crate +: +: +prog +: +: +{ +InstPtr +Program +} +; +use +crate +: +: +re_trait +: +: +Slot +; +use +crate +: +: +sparse +: +: +SparseSet +; +/ +/ +/ +An +NFA +simulation +matching +engine +. +# +[ +derive +( +Debug +) +] +pub +struct +Fsm +< +' +r +I +> +{ +/ +/ +/ +The +sequence +of +opcodes +( +among +other +things +) +that +is +actually +executed +. +/ +/ +/ +/ +/ +/ +The +program +may +be +byte +oriented +or +Unicode +codepoint +oriented +. +prog +: +& +' +r +Program +/ +/ +/ +An +explicit +stack +used +for +following +epsilon +transitions +. +( +This +is +/ +/ +/ +borrowed +from +the +cache +. +) +stack +: +& +' +r +mut +Vec +< +FollowEpsilon +> +/ +/ +/ +The +input +to +search +. +input +: +I +} +/ +/ +/ +A +cached +allocation +that +can +be +reused +on +each +execution +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +Cache +{ +/ +/ +/ +A +pair +of +ordered +sets +for +tracking +NFA +states +. +clist +: +Threads +nlist +: +Threads +/ +/ +/ +An +explicit +stack +used +for +following +epsilon +transitions +. +stack +: +Vec +< +FollowEpsilon +> +} +/ +/ +/ +An +ordered +set +of +NFA +states +and +their +captures +. +# +[ +derive +( +Clone +Debug +) +] +struct +Threads +{ +/ +/ +/ +An +ordered +set +of +opcodes +( +each +opcode +is +an +NFA +state +) +. +set +: +SparseSet +/ +/ +/ +Captures +for +every +NFA +state +. +/ +/ +/ +/ +/ +/ +It +is +stored +in +row +- +major +order +where +the +columns +are +the +capture +/ +/ +/ +slots +and +the +rows +are +the +states +. +caps +: +Vec +< +Slot +> +/ +/ +/ +The +number +of +capture +slots +stored +per +thread +. +( +Every +capture +has +/ +/ +/ +two +slots +. +) +slots_per_thread +: +usize +} +/ +/ +/ +A +representation +of +an +explicit +stack +frame +when +following +epsilon +/ +/ +/ +transitions +. +This +is +used +to +avoid +recursion +. +# +[ +derive +( +Clone +Debug +) +] +enum +FollowEpsilon +{ +/ +/ +/ +Follow +transitions +at +the +given +instruction +pointer +. +IP +( +InstPtr +) +/ +/ +/ +Restore +the +capture +slot +with +the +given +position +in +the +input +. +Capture +{ +slot +: +usize +pos +: +Slot +} +} +impl +Cache +{ +/ +/ +/ +Create +a +new +allocation +used +by +the +NFA +machine +to +record +execution +/ +/ +/ +and +captures +. +pub +fn +new +( +_prog +: +& +Program +) +- +> +Self +{ +Cache +{ +clist +: +Threads +: +: +new +( +) +nlist +: +Threads +: +: +new +( +) +stack +: +vec +! +[ +] +} +} +} +impl +< +' +r +I +: +Input +> +Fsm +< +' +r +I +> +{ +/ +/ +/ +Execute +the +NFA +matching +engine +. +/ +/ +/ +/ +/ +/ +If +there +' +s +a +match +exec +returns +true +and +populates +the +given +/ +/ +/ +captures +accordingly +. +pub +fn +exec +( +prog +: +& +' +r +Program +cache +: +& +ProgramCache +matches +: +& +mut +[ +bool +] +slots +: +& +mut +[ +Slot +] +quit_after_match +: +bool +input +: +I +start +: +usize +end +: +usize +) +- +> +bool +{ +let +mut +cache += +cache +. +borrow_mut +( +) +; +let +cache += +& +mut +cache +. +pikevm +; +cache +. +clist +. +resize +( +prog +. +len +( +) +prog +. +captures +. +len +( +) +) +; +cache +. +nlist +. +resize +( +prog +. +len +( +) +prog +. +captures +. +len +( +) +) +; +let +at += +input +. +at +( +start +) +; +Fsm +{ +prog +stack +: +& +mut +cache +. +stack +input +} +. +exec_ +( +& +mut +cache +. +clist +& +mut +cache +. +nlist +matches +slots +quit_after_match +at +end +) +} +fn +exec_ +( +& +mut +self +mut +clist +: +& +mut +Threads +mut +nlist +: +& +mut +Threads +matches +: +& +mut +[ +bool +] +slots +: +& +mut +[ +Slot +] +quit_after_match +: +bool +mut +at +: +InputAt +end +: +usize +) +- +> +bool +{ +let +mut +matched += +false +; +let +mut +all_matched += +false +; +clist +. +set +. +clear +( +) +; +nlist +. +set +. +clear +( +) +; +' +LOOP +: +loop +{ +if +clist +. +set +. +is_empty +( +) +{ +/ +/ +Three +ways +to +bail +out +when +our +current +set +of +threads +is +/ +/ +empty +. +/ +/ +/ +/ +1 +. +We +have +a +match +- +- +- +so +we +' +re +done +exploring +any +possible +/ +/ +alternatives +. +Time +to +quit +. +( +We +can +' +t +do +this +if +we +' +re +/ +/ +looking +for +matches +for +multiple +regexes +unless +we +know +/ +/ +they +all +matched +. +) +/ +/ +/ +/ +2 +. +If +the +expression +starts +with +a +' +^ +' +we +can +terminate +as +/ +/ +soon +as +the +last +thread +dies +. +if +( +matched +& +& +matches +. +len +( +) +< += +1 +) +| +| +all_matched +| +| +( +! +at +. +is_start +( +) +& +& +self +. +prog +. +is_anchored_start +) +{ +break +; +} +/ +/ +3 +. +If +there +' +s +a +literal +prefix +for +the +program +try +to +/ +/ +jump +ahead +quickly +. +If +it +can +' +t +be +found +then +we +can +/ +/ +bail +out +early +. +if +! +self +. +prog +. +prefixes +. +is_empty +( +) +{ +at += +match +self +. +input +. +prefix_at +( +& +self +. +prog +. +prefixes +at +) +{ +None += +> +break +Some +( +at +) += +> +at +} +; +} +} +/ +/ +This +simulates +a +preceding +' +. +* +? +' +for +every +regex +by +adding +/ +/ +a +state +starting +at +the +current +position +in +the +input +for +the +/ +/ +beginning +of +the +program +only +if +we +don +' +t +already +have +a +match +. +if +clist +. +set +. +is_empty +( +) +| +| +( +! +self +. +prog +. +is_anchored_start +& +& +! +all_matched +) +{ +self +. +add +( +& +mut +clist +slots +0 +at +) +; +} +/ +/ +The +previous +call +to +" +add +" +actually +inspects +the +position +just +/ +/ +before +the +current +character +. +For +stepping +through +the +machine +/ +/ +we +can +to +look +at +the +current +character +so +we +advance +the +/ +/ +input +. +let +at_next += +self +. +input +. +at +( +at +. +next_pos +( +) +) +; +for +i +in +0 +. +. +clist +. +set +. +len +( +) +{ +let +ip += +clist +. +set +[ +i +] +; +if +self +. +step +( +& +mut +nlist +matches +slots +clist +. +caps +( +ip +) +ip +at +at_next +) +{ +matched += +true +; +all_matched += +all_matched +| +| +matches +. +iter +( +) +. +all +( +| +& +b +| +b +) +; +if +quit_after_match +{ +/ +/ +If +we +only +care +if +a +match +occurs +( +not +its +/ +/ +position +) +then +we +can +quit +right +now +. +break +' +LOOP +; +} +if +self +. +prog +. +matches +. +len +( +) += += +1 +{ +/ +/ +We +don +' +t +need +to +check +the +rest +of +the +threads +/ +/ +in +this +set +because +we +' +ve +matched +something +/ +/ +( +" +leftmost +- +first +" +) +. +However +we +still +need +to +check +/ +/ +threads +in +the +next +set +to +support +things +like +/ +/ +greedy +matching +. +/ +/ +/ +/ +This +is +only +true +on +normal +regexes +. +For +regex +sets +/ +/ +we +need +to +mush +on +to +observe +other +matches +. +break +; +} +} +} +if +at +. +pos +( +) +> += +end +{ +break +; +} +at += +at_next +; +mem +: +: +swap +( +clist +nlist +) +; +nlist +. +set +. +clear +( +) +; +} +matched +} +/ +/ +/ +Step +through +the +input +one +token +( +byte +or +codepoint +) +at +a +time +. +/ +/ +/ +/ +/ +/ +nlist +is +the +set +of +states +that +will +be +processed +on +the +next +token +/ +/ +/ +in +the +input +. +/ +/ +/ +/ +/ +/ +caps +is +the +set +of +captures +passed +by +the +caller +of +the +NFA +. +They +are +/ +/ +/ +written +to +only +when +a +match +state +is +visited +. +/ +/ +/ +/ +/ +/ +thread_caps +is +the +set +of +captures +set +for +the +current +NFA +state +ip +. +/ +/ +/ +/ +/ +/ +at +and +at_next +are +the +current +and +next +positions +in +the +input +. +at +or +/ +/ +/ +at_next +may +be +EOF +. +fn +step +( +& +mut +self +nlist +: +& +mut +Threads +matches +: +& +mut +[ +bool +] +slots +: +& +mut +[ +Slot +] +thread_caps +: +& +mut +[ +Option +< +usize +> +] +ip +: +usize +at +: +InputAt +at_next +: +InputAt +) +- +> +bool +{ +use +crate +: +: +prog +: +: +Inst +: +: +* +; +match +self +. +prog +[ +ip +] +{ +Match +( +match_slot +) += +> +{ +if +match_slot +< +matches +. +len +( +) +{ +matches +[ +match_slot +] += +true +; +} +for +( +slot +val +) +in +slots +. +iter_mut +( +) +. +zip +( +thread_caps +. +iter +( +) +) +{ +* +slot += +* +val +; +} +true +} +Char +( +ref +inst +) += +> +{ +if +inst +. +c += += +at +. +char +( +) +{ +self +. +add +( +nlist +thread_caps +inst +. +goto +at_next +) +; +} +false +} +Ranges +( +ref +inst +) += +> +{ +if +inst +. +matches +( +at +. +char +( +) +) +{ +self +. +add +( +nlist +thread_caps +inst +. +goto +at_next +) +; +} +false +} +Bytes +( +ref +inst +) += +> +{ +if +let +Some +( +b +) += +at +. +byte +( +) +{ +if +inst +. +matches +( +b +) +{ +self +. +add +( +nlist +thread_caps +inst +. +goto +at_next +) +; +} +} +false +} +EmptyLook +( +_ +) +| +Save +( +_ +) +| +Split +( +_ +) += +> +false +} +} +/ +/ +/ +Follows +epsilon +transitions +and +adds +them +for +processing +to +nlist +/ +/ +/ +starting +at +and +including +ip +. +fn +add +( +& +mut +self +nlist +: +& +mut +Threads +thread_caps +: +& +mut +[ +Option +< +usize +> +] +ip +: +usize +at +: +InputAt +) +{ +self +. +stack +. +push +( +FollowEpsilon +: +: +IP +( +ip +) +) +; +while +let +Some +( +frame +) += +self +. +stack +. +pop +( +) +{ +match +frame +{ +FollowEpsilon +: +: +IP +( +ip +) += +> +{ +self +. +add_step +( +nlist +thread_caps +ip +at +) +; +} +FollowEpsilon +: +: +Capture +{ +slot +pos +} += +> +{ +thread_caps +[ +slot +] += +pos +; +} +} +} +} +/ +/ +/ +A +helper +function +for +add +that +avoids +excessive +pushing +to +the +stack +. +fn +add_step +( +& +mut +self +nlist +: +& +mut +Threads +thread_caps +: +& +mut +[ +Option +< +usize +> +] +mut +ip +: +usize +at +: +InputAt +) +{ +/ +/ +Instead +of +pushing +and +popping +to +the +stack +we +mutate +ip +as +we +/ +/ +traverse +the +set +of +states +. +We +only +push +to +the +stack +when +we +/ +/ +absolutely +need +recursion +( +restoring +captures +or +following +a +/ +/ +branch +) +. +use +crate +: +: +prog +: +: +Inst +: +: +* +; +loop +{ +/ +/ +Don +' +t +visit +states +we +' +ve +already +added +. +if +nlist +. +set +. +contains +( +ip +) +{ +return +; +} +nlist +. +set +. +insert +( +ip +) +; +match +self +. +prog +[ +ip +] +{ +EmptyLook +( +ref +inst +) += +> +{ +if +self +. +input +. +is_empty_match +( +at +inst +) +{ +ip += +inst +. +goto +; +} +} +Save +( +ref +inst +) += +> +{ +if +inst +. +slot +< +thread_caps +. +len +( +) +{ +self +. +stack +. +push +( +FollowEpsilon +: +: +Capture +{ +slot +: +inst +. +slot +pos +: +thread_caps +[ +inst +. +slot +] +} +) +; +thread_caps +[ +inst +. +slot +] += +Some +( +at +. +pos +( +) +) +; +} +ip += +inst +. +goto +; +} +Split +( +ref +inst +) += +> +{ +self +. +stack +. +push +( +FollowEpsilon +: +: +IP +( +inst +. +goto2 +) +) +; +ip += +inst +. +goto1 +; +} +Match +( +_ +) +| +Char +( +_ +) +| +Ranges +( +_ +) +| +Bytes +( +_ +) += +> +{ +let +t += +& +mut +nlist +. +caps +( +ip +) +; +for +( +slot +val +) +in +t +. +iter_mut +( +) +. +zip +( +thread_caps +. +iter +( +) +) +{ +* +slot += +* +val +; +} +return +; +} +} +} +} +} +impl +Threads +{ +fn +new +( +) +- +> +Self +{ +Threads +{ +set +: +SparseSet +: +: +new +( +0 +) +caps +: +vec +! +[ +] +slots_per_thread +: +0 +} +} +fn +resize +( +& +mut +self +num_insts +: +usize +ncaps +: +usize +) +{ +if +num_insts += += +self +. +set +. +capacity +( +) +{ +return +; +} +self +. +slots_per_thread += +ncaps +* +2 +; +self +. +set += +SparseSet +: +: +new +( +num_insts +) +; +self +. +caps += +vec +! +[ +None +; +self +. +slots_per_thread +* +num_insts +] +; +} +fn +caps +( +& +mut +self +pc +: +usize +) +- +> +& +mut +[ +Option +< +usize +> +] +{ +let +i += +pc +* +self +. +slots_per_thread +; +& +mut +self +. +caps +[ +i +. +. +i ++ +self +. +slots_per_thread +] +} +} diff --git a/third_party/rust/regex/src/pool.rs b/third_party/rust/regex/src/pool.rs new file mode 100644 index 0000000000000..d7666c5749426 --- /dev/null +++ b/third_party/rust/regex/src/pool.rs @@ -0,0 +1,3628 @@ +/ +/ +This +module +provides +a +relatively +simple +thread +- +safe +pool +of +reusable +/ +/ +objects +. +For +the +most +part +it +' +s +implemented +by +a +stack +represented +by +a +/ +/ +Mutex +< +Vec +< +T +> +> +. +It +has +one +small +trick +: +because +unlocking +a +mutex +is +somewhat +/ +/ +costly +in +the +case +where +a +pool +is +accessed +by +the +first +thread +that +tried +/ +/ +to +get +a +value +we +bypass +the +mutex +. +Here +are +some +benchmarks +showing +the +/ +/ +difference +. +/ +/ +/ +/ +1 +) +misc +: +: +anchored_literal_long_non_match +21 +( +18571 +MB +/ +s +) +/ +/ +2 +) +misc +: +: +anchored_literal_long_non_match +107 +( +3644 +MB +/ +s +) +/ +/ +3 +) +misc +: +: +anchored_literal_long_non_match +45 +( +8666 +MB +/ +s +) +/ +/ +4 +) +misc +: +: +anchored_literal_long_non_match +19 +( +20526 +MB +/ +s +) +/ +/ +/ +/ +( +1 +) +represents +our +baseline +: +the +master +branch +at +the +time +of +writing +when +/ +/ +using +the +' +thread_local +' +crate +to +implement +the +pool +below +. +/ +/ +/ +/ +( +2 +) +represents +a +naive +pool +implemented +completely +via +Mutex +< +Vec +< +T +> +> +. +There +/ +/ +is +no +special +trick +for +bypassing +the +mutex +. +/ +/ +/ +/ +( +3 +) +is +the +same +as +( +2 +) +except +it +uses +Mutex +< +Vec +< +Box +< +T +> +> +> +. +It +is +twice +as +/ +/ +fast +because +a +Box +< +T +> +is +much +smaller +than +the +T +we +use +with +a +Pool +in +this +/ +/ +crate +. +So +pushing +and +popping +a +Box +< +T +> +from +a +Vec +is +quite +a +bit +faster +/ +/ +than +for +T +. +/ +/ +/ +/ +( +4 +) +is +the +same +as +( +3 +) +but +with +the +trick +for +bypassing +the +mutex +in +the +/ +/ +case +of +the +first +- +to +- +get +thread +. +/ +/ +/ +/ +Why +move +off +of +thread_local +? +Even +though +( +4 +) +is +a +hair +faster +than +( +1 +) +/ +/ +above +this +was +not +the +main +goal +. +The +main +goal +was +to +move +off +of +/ +/ +thread_local +and +find +a +way +to +* +simply +* +re +- +capture +some +of +its +speed +for +/ +/ +regex +' +s +specific +case +. +So +again +why +move +off +of +it +? +The +* +primary +* +reason +is +/ +/ +because +of +memory +leaks +. +See +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +362 +/ +/ +for +example +. +( +Why +do +I +want +it +to +be +simple +? +Well +I +suppose +what +I +mean +is +/ +/ +" +use +as +much +safe +code +as +possible +to +minimize +risk +and +be +as +sure +as +I +can +/ +/ +be +that +it +is +correct +. +" +) +/ +/ +/ +/ +My +guess +is +that +the +thread_local +design +is +probably +not +appropriate +for +/ +/ +regex +since +its +memory +usage +scales +to +the +number +of +active +threads +that +/ +/ +have +used +a +regex +where +as +the +pool +below +scales +to +the +number +of +threads +/ +/ +that +simultaneously +use +a +regex +. +While +neither +case +permits +contraction +/ +/ +since +we +own +the +pool +data +structure +below +we +can +add +contraction +if +a +/ +/ +clear +use +case +pops +up +in +the +wild +. +More +pressingly +though +it +seems +that +/ +/ +there +are +at +least +some +use +case +patterns +where +one +might +have +many +threads +/ +/ +sitting +around +that +might +have +used +a +regex +at +one +point +. +While +thread_local +/ +/ +does +try +to +reuse +space +previously +used +by +a +thread +that +has +since +stopped +/ +/ +its +maximal +memory +usage +still +scales +with +the +total +number +of +active +/ +/ +threads +. +In +contrast +the +pool +below +scales +with +the +total +number +of +threads +/ +/ +* +simultaneously +* +using +the +pool +. +The +hope +is +that +this +uses +less +memory +/ +/ +overall +. +And +if +it +doesn +' +t +we +can +hopefully +tune +it +somehow +. +/ +/ +/ +/ +It +seems +that +these +sort +of +conditions +happen +frequently +/ +/ +in +FFI +inside +of +other +more +" +managed +" +languages +. +This +was +/ +/ +mentioned +in +the +issue +linked +above +and +also +mentioned +here +: +/ +/ +https +: +/ +/ +github +. +com +/ +BurntSushi +/ +rure +- +go +/ +issues +/ +3 +. +And +in +particular +users +/ +/ +confirm +that +disabling +the +use +of +thread_local +resolves +the +leak +. +/ +/ +/ +/ +There +were +other +weaker +reasons +for +moving +off +of +thread_local +as +well +. +/ +/ +Namely +at +the +time +I +was +looking +to +reduce +dependencies +. +And +for +something +/ +/ +like +regex +maintenance +can +be +simpler +when +we +own +the +full +dependency +tree +. +use +std +: +: +panic +: +: +{ +RefUnwindSafe +UnwindSafe +} +; +use +std +: +: +sync +: +: +atomic +: +: +{ +AtomicUsize +Ordering +} +; +use +std +: +: +sync +: +: +Mutex +; +/ +/ +/ +An +atomic +counter +used +to +allocate +thread +IDs +. +static +COUNTER +: +AtomicUsize += +AtomicUsize +: +: +new +( +1 +) +; +thread_local +! +( +/ +/ +/ +A +thread +local +used +to +assign +an +ID +to +a +thread +. +static +THREAD_ID +: +usize += +{ +let +next += +COUNTER +. +fetch_add +( +1 +Ordering +: +: +Relaxed +) +; +/ +/ +SAFETY +: +We +cannot +permit +the +reuse +of +thread +IDs +since +reusing +a +/ +/ +thread +ID +might +result +in +more +than +one +thread +" +owning +" +a +pool +/ +/ +and +thus +permit +accessing +a +mutable +value +from +multiple +threads +/ +/ +simultaneously +without +synchronization +. +The +intent +of +this +panic +is +/ +/ +to +be +a +sanity +check +. +It +is +not +expected +that +the +thread +ID +space +/ +/ +will +actually +be +exhausted +in +practice +. +/ +/ +/ +/ +This +checks +that +the +counter +never +wraps +around +since +atomic +/ +/ +addition +wraps +around +on +overflow +. +if +next += += +0 +{ +panic +! +( +" +regex +: +thread +ID +allocation +space +exhausted +" +) +; +} +next +} +; +) +; +/ +/ +/ +The +type +of +the +function +used +to +create +values +in +a +pool +when +the +pool +is +/ +/ +/ +empty +and +the +caller +requests +one +. +type +CreateFn +< +T +> += +Box +< +dyn +Fn +( +) +- +> +T ++ +Send ++ +Sync ++ +UnwindSafe ++ +RefUnwindSafe ++ +' +static +> +; +/ +/ +/ +A +simple +thread +safe +pool +for +reusing +values +. +/ +/ +/ +/ +/ +/ +Getting +a +value +out +comes +with +a +guard +. +When +that +guard +is +dropped +the +/ +/ +/ +value +is +automatically +put +back +in +the +pool +. +/ +/ +/ +/ +/ +/ +A +Pool +< +T +> +impls +Sync +when +T +is +Send +( +even +if +it +' +s +not +Sync +) +. +This +means +/ +/ +/ +that +T +can +use +interior +mutability +. +This +is +possible +because +a +pool +is +/ +/ +/ +guaranteed +to +provide +a +value +to +exactly +one +thread +at +any +time +. +/ +/ +/ +/ +/ +/ +Currently +a +pool +never +contracts +in +size +. +Its +size +is +proportional +to +the +/ +/ +/ +number +of +simultaneous +uses +. +pub +struct +Pool +< +T +> +{ +/ +/ +/ +A +stack +of +T +values +to +hand +out +. +These +are +used +when +a +Pool +is +/ +/ +/ +accessed +by +a +thread +that +didn +' +t +create +it +. +stack +: +Mutex +< +Vec +< +Box +< +T +> +> +> +/ +/ +/ +A +function +to +create +more +T +values +when +stack +is +empty +and +a +caller +/ +/ +/ +has +requested +a +T +. +create +: +CreateFn +< +T +> +/ +/ +/ +The +ID +of +the +thread +that +owns +this +pool +. +The +owner +is +the +thread +/ +/ +/ +that +makes +the +first +call +to +' +get +' +. +When +the +owner +calls +' +get +' +it +/ +/ +/ +gets +' +owner_val +' +directly +instead +of +returning +a +T +from +' +stack +' +. +/ +/ +/ +See +comments +elsewhere +for +details +but +this +is +intended +to +be +an +/ +/ +/ +optimization +for +the +common +case +that +makes +getting +a +T +faster +. +/ +/ +/ +/ +/ +/ +It +is +initialized +to +a +value +of +zero +( +an +impossible +thread +ID +) +as +a +/ +/ +/ +sentinel +to +indicate +that +it +is +unowned +. +owner +: +AtomicUsize +/ +/ +/ +A +value +to +return +when +the +caller +is +in +the +same +thread +that +created +/ +/ +/ +the +Pool +. +owner_val +: +T +} +/ +/ +SAFETY +: +Since +we +want +to +use +a +Pool +from +multiple +threads +simultaneously +/ +/ +behind +an +Arc +we +need +for +it +to +be +Sync +. +In +cases +where +T +is +sync +Pool +< +T +> +/ +/ +would +be +Sync +. +However +since +we +use +a +Pool +to +store +mutable +scratch +space +/ +/ +we +wind +up +using +a +T +that +has +interior +mutability +and +is +thus +itself +not +/ +/ +Sync +. +So +what +we +* +really +* +want +is +for +our +Pool +< +T +> +to +by +Sync +even +when +T +is +/ +/ +not +Sync +( +but +is +at +least +Send +) +. +/ +/ +/ +/ +The +only +non +- +sync +aspect +of +a +Pool +is +its +' +owner_val +' +field +which +is +used +/ +/ +to +implement +faster +access +to +a +pool +value +in +the +common +case +of +a +pool +/ +/ +being +accessed +in +the +same +thread +in +which +it +was +created +. +The +' +stack +' +field +/ +/ +is +also +shared +but +a +Mutex +< +T +> +where +T +: +Send +is +already +Sync +. +So +we +only +/ +/ +need +to +worry +about +' +owner_val +' +. +/ +/ +/ +/ +The +key +is +to +guarantee +that +' +owner_val +' +can +only +ever +be +accessed +from +one +/ +/ +thread +. +In +our +implementation +below +we +guarantee +this +by +only +returning +the +/ +/ +' +owner_val +' +when +the +ID +of +the +current +thread +matches +the +ID +of +the +thread +/ +/ +that +created +the +Pool +. +Since +this +can +only +ever +be +one +thread +it +follows +/ +/ +that +only +one +thread +can +access +' +owner_val +' +at +any +point +in +time +. +Thus +it +/ +/ +is +safe +to +declare +that +Pool +< +T +> +is +Sync +when +T +is +Send +. +/ +/ +/ +/ +NOTE +: +It +would +also +be +possible +to +make +the +owning +thread +be +the +* +first +* +/ +/ +thread +that +tries +to +get +a +value +out +of +a +Pool +. +However +the +current +/ +/ +implementation +is +a +little +simpler +and +it +' +s +not +clear +if +making +the +first +/ +/ +thread +( +rather +than +the +creating +thread +) +is +meaningfully +better +. +/ +/ +/ +/ +If +there +is +a +way +to +achieve +our +performance +goals +using +safe +code +then +/ +/ +I +would +very +much +welcome +a +patch +. +As +it +stands +the +implementation +below +/ +/ +tries +to +balance +safety +with +performance +. +The +case +where +a +Regex +is +used +/ +/ +from +multiple +threads +simultaneously +will +suffer +a +bit +since +getting +a +cache +/ +/ +will +require +unlocking +a +mutex +. +unsafe +impl +< +T +: +Send +> +Sync +for +Pool +< +T +> +{ +} +impl +< +T +: +: +: +std +: +: +fmt +: +: +Debug +> +: +: +std +: +: +fmt +: +: +Debug +for +Pool +< +T +> +{ +fn +fmt +( +& +self +f +: +& +mut +: +: +std +: +: +fmt +: +: +Formatter +< +' +_ +> +) +- +> +: +: +std +: +: +fmt +: +: +Result +{ +f +. +debug_struct +( +" +Pool +" +) +. +field +( +" +stack +" +& +self +. +stack +) +. +field +( +" +owner +" +& +self +. +owner +) +. +field +( +" +owner_val +" +& +self +. +owner_val +) +. +finish +( +) +} +} +/ +/ +/ +A +guard +that +is +returned +when +a +caller +requests +a +value +from +the +pool +. +/ +/ +/ +/ +/ +/ +The +purpose +of +the +guard +is +to +use +RAII +to +automatically +put +the +value +back +/ +/ +/ +in +the +pool +once +it +' +s +dropped +. +# +[ +derive +( +Debug +) +] +pub +struct +PoolGuard +< +' +a +T +: +Send +> +{ +/ +/ +/ +The +pool +that +this +guard +is +attached +to +. +pool +: +& +' +a +Pool +< +T +> +/ +/ +/ +This +is +None +when +the +guard +represents +the +special +" +owned +" +value +. +In +/ +/ +/ +which +case +the +value +is +retrieved +from +' +pool +. +owner_val +' +. +value +: +Option +< +Box +< +T +> +> +} +impl +< +T +: +Send +> +Pool +< +T +> +{ +/ +/ +/ +Create +a +new +pool +. +The +given +closure +is +used +to +create +values +in +the +/ +/ +/ +pool +when +necessary +. +pub +fn +new +( +create +: +CreateFn +< +T +> +) +- +> +Pool +< +T +> +{ +let +owner += +AtomicUsize +: +: +new +( +0 +) +; +let +owner_val += +create +( +) +; +Pool +{ +stack +: +Mutex +: +: +new +( +vec +! +[ +] +) +create +owner +owner_val +} +} +/ +/ +/ +Get +a +value +from +the +pool +. +The +caller +is +guaranteed +to +have +exclusive +/ +/ +/ +access +to +the +given +value +. +/ +/ +/ +/ +/ +/ +Note +that +there +is +no +guarantee +provided +about +which +value +in +the +/ +/ +/ +pool +is +returned +. +That +is +calling +get +dropping +the +guard +( +causing +/ +/ +/ +the +value +to +go +back +into +the +pool +) +and +then +calling +get +again +is +NOT +/ +/ +/ +guaranteed +to +return +the +same +value +received +in +the +first +get +call +. +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +pub +fn +get +( +& +self +) +- +> +PoolGuard +< +' +_ +T +> +{ +/ +/ +Our +fast +path +checks +if +the +caller +is +the +thread +that +" +owns +" +this +/ +/ +pool +. +Or +stated +differently +whether +it +is +the +first +thread +that +/ +/ +tried +to +extract +a +value +from +the +pool +. +If +it +is +then +we +can +return +/ +/ +a +T +to +the +caller +without +going +through +a +mutex +. +/ +/ +/ +/ +SAFETY +: +We +must +guarantee +that +only +one +thread +gets +access +to +this +/ +/ +value +. +Since +a +thread +is +uniquely +identified +by +the +THREAD_ID +thread +/ +/ +local +it +follows +that +is +the +caller +' +s +thread +ID +is +equal +to +the +/ +/ +owner +then +only +one +thread +may +receive +this +value +. +let +caller += +THREAD_ID +. +with +( +| +id +| +* +id +) +; +let +owner += +self +. +owner +. +load +( +Ordering +: +: +Relaxed +) +; +if +caller += += +owner +{ +return +self +. +guard_owned +( +) +; +} +self +. +get_slow +( +caller +owner +) +} +/ +/ +/ +This +is +the +" +slow +" +version +that +goes +through +a +mutex +to +pop +an +/ +/ +/ +allocated +value +off +a +stack +to +return +to +the +caller +. +( +Or +if +the +stack +/ +/ +/ +is +empty +a +new +value +is +created +. +) +/ +/ +/ +/ +/ +/ +If +the +pool +has +no +owner +then +this +will +set +the +owner +. +# +[ +cold +] +fn +get_slow +( +& +self +caller +: +usize +owner +: +usize +) +- +> +PoolGuard +< +' +_ +T +> +{ +use +std +: +: +sync +: +: +atomic +: +: +Ordering +: +: +Relaxed +; +if +owner += += +0 +{ +/ +/ +The +sentinel +0 +value +means +this +pool +is +not +yet +owned +. +We +/ +/ +try +to +atomically +set +the +owner +. +If +we +do +then +this +thread +/ +/ +becomes +the +owner +and +we +can +return +a +guard +that +represents +/ +/ +the +special +T +for +the +owner +. +let +res += +self +. +owner +. +compare_exchange +( +0 +caller +Relaxed +Relaxed +) +; +if +res +. +is_ok +( +) +{ +return +self +. +guard_owned +( +) +; +} +} +let +mut +stack += +self +. +stack +. +lock +( +) +. +unwrap +( +) +; +let +value += +match +stack +. +pop +( +) +{ +None += +> +Box +: +: +new +( +( +self +. +create +) +( +) +) +Some +( +value +) += +> +value +} +; +self +. +guard_stack +( +value +) +} +/ +/ +/ +Puts +a +value +back +into +the +pool +. +Callers +don +' +t +need +to +call +this +. +Once +/ +/ +/ +the +guard +that +' +s +returned +by +' +get +' +is +dropped +it +is +put +back +into +the +/ +/ +/ +pool +automatically +. +fn +put +( +& +self +value +: +Box +< +T +> +) +{ +let +mut +stack += +self +. +stack +. +lock +( +) +. +unwrap +( +) +; +stack +. +push +( +value +) +; +} +/ +/ +/ +Create +a +guard +that +represents +the +special +owned +T +. +fn +guard_owned +( +& +self +) +- +> +PoolGuard +< +' +_ +T +> +{ +PoolGuard +{ +pool +: +self +value +: +None +} +} +/ +/ +/ +Create +a +guard +that +contains +a +value +from +the +pool +' +s +stack +. +fn +guard_stack +( +& +self +value +: +Box +< +T +> +) +- +> +PoolGuard +< +' +_ +T +> +{ +PoolGuard +{ +pool +: +self +value +: +Some +( +value +) +} +} +} +impl +< +' +a +T +: +Send +> +PoolGuard +< +' +a +T +> +{ +/ +/ +/ +Return +the +underlying +value +. +pub +fn +value +( +& +self +) +- +> +& +T +{ +match +self +. +value +{ +None += +> +& +self +. +pool +. +owner_val +Some +( +ref +v +) += +> +& +* +* +v +} +} +} +impl +< +' +a +T +: +Send +> +Drop +for +PoolGuard +< +' +a +T +> +{ +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +drop +( +& +mut +self +) +{ +if +let +Some +( +value +) += +self +. +value +. +take +( +) +{ +self +. +pool +. +put +( +value +) +; +} +} +} +# +[ +cfg +( +test +) +] +mod +tests +{ +use +std +: +: +panic +: +: +{ +RefUnwindSafe +UnwindSafe +} +; +use +super +: +: +* +; +# +[ +test +] +fn +oibits +( +) +{ +use +crate +: +: +exec +: +: +ProgramCache +; +fn +has_oibits +< +T +: +Send ++ +Sync ++ +UnwindSafe ++ +RefUnwindSafe +> +( +) +{ +} +has_oibits +: +: +< +Pool +< +ProgramCache +> +> +( +) +; +} +/ +/ +Tests +that +Pool +implements +the +" +single +owner +" +optimization +. +That +is +the +/ +/ +thread +that +first +accesses +the +pool +gets +its +own +copy +while +all +other +/ +/ +threads +get +distinct +copies +. +# +[ +test +] +fn +thread_owner_optimization +( +) +{ +use +std +: +: +cell +: +: +RefCell +; +use +std +: +: +sync +: +: +Arc +; +let +pool +: +Arc +< +Pool +< +RefCell +< +Vec +< +char +> +> +> +> += +Arc +: +: +new +( +Pool +: +: +new +( +Box +: +: +new +( +| +| +RefCell +: +: +new +( +vec +! +[ +' +a +' +] +) +) +) +) +; +pool +. +get +( +) +. +value +( +) +. +borrow_mut +( +) +. +push +( +' +x +' +) +; +let +pool1 += +pool +. +clone +( +) +; +let +t1 += +std +: +: +thread +: +: +spawn +( +move +| +| +{ +let +guard += +pool1 +. +get +( +) +; +let +v += +guard +. +value +( +) +; +v +. +borrow_mut +( +) +. +push +( +' +y +' +) +; +} +) +; +let +pool2 += +pool +. +clone +( +) +; +let +t2 += +std +: +: +thread +: +: +spawn +( +move +| +| +{ +let +guard += +pool2 +. +get +( +) +; +let +v += +guard +. +value +( +) +; +v +. +borrow_mut +( +) +. +push +( +' +z +' +) +; +} +) +; +t1 +. +join +( +) +. +unwrap +( +) +; +t2 +. +join +( +) +. +unwrap +( +) +; +/ +/ +If +we +didn +' +t +implement +the +single +owner +optimization +then +one +of +/ +/ +the +threads +above +is +likely +to +have +mutated +the +[ +a +x +] +vec +that +/ +/ +we +stuffed +in +the +pool +before +spawning +the +threads +. +But +since +/ +/ +neither +thread +was +first +to +access +the +pool +and +because +of +the +/ +/ +optimization +we +should +be +guaranteed +that +neither +thread +mutates +/ +/ +the +special +owned +pool +value +. +/ +/ +/ +/ +( +Technically +this +is +an +implementation +detail +and +not +a +contract +of +/ +/ +Pool +' +s +API +. +) +assert_eq +! +( +vec +! +[ +' +a +' +' +x +' +] +* +pool +. +get +( +) +. +value +( +) +. +borrow +( +) +) +; +} +} diff --git a/third_party/rust/regex/src/prog.rs b/third_party/rust/regex/src/prog.rs new file mode 100644 index 0000000000000..35495a70590d6 --- /dev/null +++ b/third_party/rust/regex/src/prog.rs @@ -0,0 +1,3489 @@ +use +std +: +: +cmp +: +: +Ordering +; +use +std +: +: +collections +: +: +HashMap +; +use +std +: +: +fmt +; +use +std +: +: +mem +; +use +std +: +: +ops +: +: +Deref +; +use +std +: +: +slice +; +use +std +: +: +sync +: +: +Arc +; +use +crate +: +: +input +: +: +Char +; +use +crate +: +: +literal +: +: +LiteralSearcher +; +/ +/ +/ +InstPtr +represents +the +index +of +an +instruction +in +a +regex +program +. +pub +type +InstPtr += +usize +; +/ +/ +/ +Program +is +a +sequence +of +instructions +and +various +facts +about +thos +/ +/ +/ +instructions +. +# +[ +derive +( +Clone +) +] +pub +struct +Program +{ +/ +/ +/ +A +sequence +of +instructions +that +represents +an +NFA +. +pub +insts +: +Vec +< +Inst +> +/ +/ +/ +Pointers +to +each +Match +instruction +in +the +sequence +. +/ +/ +/ +/ +/ +/ +This +is +always +length +1 +unless +this +program +represents +a +regex +set +. +pub +matches +: +Vec +< +InstPtr +> +/ +/ +/ +The +ordered +sequence +of +all +capture +groups +extracted +from +the +AST +. +/ +/ +/ +Unnamed +groups +are +None +. +pub +captures +: +Vec +< +Option +< +String +> +> +/ +/ +/ +Pointers +to +all +named +capture +groups +into +captures +. +pub +capture_name_idx +: +Arc +< +HashMap +< +String +usize +> +> +/ +/ +/ +A +pointer +to +the +start +instruction +. +This +can +vary +depending +on +how +/ +/ +/ +the +program +was +compiled +. +For +example +programs +for +use +with +the +DFA +/ +/ +/ +engine +have +a +. +* +? +inserted +at +the +beginning +of +unanchored +regular +/ +/ +/ +expressions +. +The +actual +starting +point +of +the +program +is +after +the +/ +/ +/ +. +* +? +. +pub +start +: +InstPtr +/ +/ +/ +A +set +of +equivalence +classes +for +discriminating +bytes +in +the +compiled +/ +/ +/ +program +. +pub +byte_classes +: +Vec +< +u8 +> +/ +/ +/ +When +true +this +program +can +only +match +valid +UTF +- +8 +. +pub +only_utf8 +: +bool +/ +/ +/ +When +true +this +program +uses +byte +range +instructions +instead +of +Unicode +/ +/ +/ +range +instructions +. +pub +is_bytes +: +bool +/ +/ +/ +When +true +the +program +is +compiled +for +DFA +matching +. +For +example +this +/ +/ +/ +implies +is_bytes +and +also +inserts +a +preceding +. +* +? +for +unanchored +/ +/ +/ +regexes +. +pub +is_dfa +: +bool +/ +/ +/ +When +true +the +program +matches +text +in +reverse +( +for +use +only +in +the +/ +/ +/ +DFA +) +. +pub +is_reverse +: +bool +/ +/ +/ +Whether +the +regex +must +match +from +the +start +of +the +input +. +pub +is_anchored_start +: +bool +/ +/ +/ +Whether +the +regex +must +match +at +the +end +of +the +input +. +pub +is_anchored_end +: +bool +/ +/ +/ +Whether +this +program +contains +a +Unicode +word +boundary +instruction +. +pub +has_unicode_word_boundary +: +bool +/ +/ +/ +A +possibly +empty +machine +for +very +quickly +matching +prefix +literals +. +pub +prefixes +: +LiteralSearcher +/ +/ +/ +A +limit +on +the +size +of +the +cache +that +the +DFA +is +allowed +to +use +while +/ +/ +/ +matching +. +/ +/ +/ +/ +/ +/ +The +cache +limit +specifies +approximately +how +much +space +we +' +re +willing +to +/ +/ +/ +give +to +the +state +cache +. +Once +the +state +cache +exceeds +the +size +it +is +/ +/ +/ +wiped +and +all +states +must +be +re +- +computed +. +/ +/ +/ +/ +/ +/ +Note +that +this +value +does +not +impact +correctness +. +It +can +be +set +to +0 +/ +/ +/ +and +the +DFA +will +run +just +fine +. +( +It +will +only +ever +store +exactly +one +/ +/ +/ +state +in +the +cache +and +will +likely +run +very +slowly +but +it +will +work +. +) +/ +/ +/ +/ +/ +/ +Also +note +that +this +limit +is +* +per +thread +of +execution +* +. +That +is +/ +/ +/ +if +the +same +regex +is +used +to +search +text +across +multiple +threads +/ +/ +/ +simultaneously +then +the +DFA +cache +is +not +shared +. +Instead +copies +are +/ +/ +/ +made +. +pub +dfa_size_limit +: +usize +} +impl +Program +{ +/ +/ +/ +Creates +an +empty +instruction +sequence +. +Fields +are +given +default +/ +/ +/ +values +. +pub +fn +new +( +) +- +> +Self +{ +Program +{ +insts +: +vec +! +[ +] +matches +: +vec +! +[ +] +captures +: +vec +! +[ +] +capture_name_idx +: +Arc +: +: +new +( +HashMap +: +: +new +( +) +) +start +: +0 +byte_classes +: +vec +! +[ +0 +; +256 +] +only_utf8 +: +true +is_bytes +: +false +is_dfa +: +false +is_reverse +: +false +is_anchored_start +: +false +is_anchored_end +: +false +has_unicode_word_boundary +: +false +prefixes +: +LiteralSearcher +: +: +empty +( +) +dfa_size_limit +: +2 +* +( +1 +< +< +20 +) +} +} +/ +/ +/ +If +pc +is +an +index +to +a +no +- +op +instruction +( +like +Save +) +then +return +the +/ +/ +/ +next +pc +that +is +not +a +no +- +op +instruction +. +pub +fn +skip +( +& +self +mut +pc +: +usize +) +- +> +usize +{ +loop +{ +match +self +[ +pc +] +{ +Inst +: +: +Save +( +ref +i +) += +> +pc += +i +. +goto +_ += +> +return +pc +} +} +} +/ +/ +/ +Return +true +if +and +only +if +an +execution +engine +at +instruction +pc +will +/ +/ +/ +always +lead +to +a +match +. +pub +fn +leads_to_match +( +& +self +pc +: +usize +) +- +> +bool +{ +if +self +. +matches +. +len +( +) +> +1 +{ +/ +/ +If +we +have +a +regex +set +then +we +have +more +than +one +ending +/ +/ +state +so +leading +to +one +of +those +states +is +generally +/ +/ +meaningless +. +return +false +; +} +match +self +[ +self +. +skip +( +pc +) +] +{ +Inst +: +: +Match +( +_ +) += +> +true +_ += +> +false +} +} +/ +/ +/ +Returns +true +if +the +current +configuration +demands +that +an +implicit +/ +/ +/ +. +* +? +be +prepended +to +the +instruction +sequence +. +pub +fn +needs_dotstar +( +& +self +) +- +> +bool +{ +self +. +is_dfa +& +& +! +self +. +is_reverse +& +& +! +self +. +is_anchored_start +} +/ +/ +/ +Returns +true +if +this +program +uses +Byte +instructions +instead +of +/ +/ +/ +Char +/ +Range +instructions +. +pub +fn +uses_bytes +( +& +self +) +- +> +bool +{ +self +. +is_bytes +| +| +self +. +is_dfa +} +/ +/ +/ +Returns +true +if +this +program +exclusively +matches +valid +UTF +- +8 +bytes +. +/ +/ +/ +/ +/ +/ +That +is +if +an +invalid +UTF +- +8 +byte +is +seen +then +no +match +is +possible +. +pub +fn +only_utf8 +( +& +self +) +- +> +bool +{ +self +. +only_utf8 +} +/ +/ +/ +Return +the +approximate +heap +usage +of +this +instruction +sequence +in +/ +/ +/ +bytes +. +pub +fn +approximate_size +( +& +self +) +- +> +usize +{ +/ +/ +The +only +instruction +that +uses +heap +space +is +Ranges +( +for +/ +/ +Unicode +codepoint +programs +) +to +store +non +- +overlapping +codepoint +/ +/ +ranges +. +To +keep +this +operation +constant +time +we +ignore +them +. +( +self +. +len +( +) +* +mem +: +: +size_of +: +: +< +Inst +> +( +) +) ++ +( +self +. +matches +. +len +( +) +* +mem +: +: +size_of +: +: +< +InstPtr +> +( +) +) ++ +( +self +. +captures +. +len +( +) +* +mem +: +: +size_of +: +: +< +Option +< +String +> +> +( +) +) ++ +( +self +. +capture_name_idx +. +len +( +) +* +( +mem +: +: +size_of +: +: +< +String +> +( +) ++ +mem +: +: +size_of +: +: +< +usize +> +( +) +) +) ++ +( +self +. +byte_classes +. +len +( +) +* +mem +: +: +size_of +: +: +< +u8 +> +( +) +) ++ +self +. +prefixes +. +approximate_size +( +) +} +} +impl +Deref +for +Program +{ +type +Target += +[ +Inst +] +; +# +[ +cfg_attr +( +feature += +" +perf +- +inline +" +inline +( +always +) +) +] +fn +deref +( +& +self +) +- +> +& +Self +: +: +Target +{ +& +* +self +. +insts +} +} +impl +fmt +: +: +Debug +for +Program +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +use +self +: +: +Inst +: +: +* +; +fn +with_goto +( +cur +: +usize +goto +: +usize +fmtd +: +String +) +- +> +String +{ +if +goto += += +cur ++ +1 +{ +fmtd +} +else +{ +format +! +( +" +{ +} +( +goto +: +{ +} +) +" +fmtd +goto +) +} +} +fn +visible_byte +( +b +: +u8 +) +- +> +String +{ +use +std +: +: +ascii +: +: +escape_default +; +let +escaped += +escape_default +( +b +) +. +collect +: +: +< +Vec +< +u8 +> +> +( +) +; +String +: +: +from_utf8_lossy +( +& +escaped +) +. +into_owned +( +) +} +for +( +pc +inst +) +in +self +. +iter +( +) +. +enumerate +( +) +{ +match +* +inst +{ +Match +( +slot +) += +> +write +! +( +f +" +{ +: +04 +} +Match +( +{ +: +? +} +) +" +pc +slot +) +? +Save +( +ref +inst +) += +> +{ +let +s += +format +! +( +" +{ +: +04 +} +Save +( +{ +} +) +" +pc +inst +. +slot +) +; +write +! +( +f +" +{ +} +" +with_goto +( +pc +inst +. +goto +s +) +) +? +; +} +Split +( +ref +inst +) += +> +{ +write +! +( +f +" +{ +: +04 +} +Split +( +{ +} +{ +} +) +" +pc +inst +. +goto1 +inst +. +goto2 +) +? +; +} +EmptyLook +( +ref +inst +) += +> +{ +let +s += +format +! +( +" +{ +: +? +} +" +inst +. +look +) +; +write +! +( +f +" +{ +: +04 +} +{ +} +" +pc +with_goto +( +pc +inst +. +goto +s +) +) +? +; +} +Char +( +ref +inst +) += +> +{ +let +s += +format +! +( +" +{ +: +? +} +" +inst +. +c +) +; +write +! +( +f +" +{ +: +04 +} +{ +} +" +pc +with_goto +( +pc +inst +. +goto +s +) +) +? +; +} +Ranges +( +ref +inst +) += +> +{ +let +ranges += +inst +. +ranges +. +iter +( +) +. +map +( +| +r +| +format +! +( +" +{ +: +? +} +- +{ +: +? +} +" +r +. +0 +r +. +1 +) +) +. +collect +: +: +< +Vec +< +String +> +> +( +) +. +join +( +" +" +) +; +write +! +( +f +" +{ +: +04 +} +{ +} +" +pc +with_goto +( +pc +inst +. +goto +ranges +) +) +? +; +} +Bytes +( +ref +inst +) += +> +{ +let +s += +format +! +( +" +Bytes +( +{ +} +{ +} +) +" +visible_byte +( +inst +. +start +) +visible_byte +( +inst +. +end +) +) +; +write +! +( +f +" +{ +: +04 +} +{ +} +" +pc +with_goto +( +pc +inst +. +goto +s +) +) +? +; +} +} +if +pc += += +self +. +start +{ +write +! +( +f +" +( +start +) +" +) +? +; +} +writeln +! +( +f +) +? +; +} +Ok +( +( +) +) +} +} +impl +< +' +a +> +IntoIterator +for +& +' +a +Program +{ +type +Item += +& +' +a +Inst +; +type +IntoIter += +slice +: +: +Iter +< +' +a +Inst +> +; +fn +into_iter +( +self +) +- +> +Self +: +: +IntoIter +{ +self +. +iter +( +) +} +} +/ +/ +/ +Inst +is +an +instruction +code +in +a +Regex +program +. +/ +/ +/ +/ +/ +/ +Regrettably +a +regex +program +either +contains +Unicode +codepoint +/ +/ +/ +instructions +( +Char +and +Ranges +) +or +it +contains +byte +instructions +( +Bytes +) +. +/ +/ +/ +A +regex +program +can +never +contain +both +. +/ +/ +/ +/ +/ +/ +It +would +be +worth +investigating +splitting +this +into +two +distinct +types +and +/ +/ +/ +then +figuring +out +how +to +make +the +matching +engines +polymorphic +over +those +/ +/ +/ +types +without +sacrificing +performance +. +/ +/ +/ +/ +/ +/ +Other +than +the +benefit +of +moving +invariants +into +the +type +system +another +/ +/ +/ +benefit +is +the +decreased +size +. +If +we +remove +the +Char +and +Ranges +/ +/ +/ +instructions +from +the +Inst +enum +then +its +size +shrinks +from +32 +bytes +to +/ +/ +/ +24 +bytes +. +( +This +is +because +of +the +removal +of +a +Box +< +[ +] +> +in +the +Ranges +/ +/ +/ +variant +. +) +Given +that +byte +based +machines +are +typically +much +bigger +than +/ +/ +/ +their +Unicode +analogues +( +because +they +can +decode +UTF +- +8 +directly +) +this +ends +/ +/ +/ +up +being +a +pretty +significant +savings +. +# +[ +derive +( +Clone +Debug +) +] +pub +enum +Inst +{ +/ +/ +/ +Match +indicates +that +the +program +has +reached +a +match +state +. +/ +/ +/ +/ +/ +/ +The +number +in +the +match +corresponds +to +the +Nth +logical +regular +/ +/ +/ +expression +in +this +program +. +This +index +is +always +0 +for +normal +regex +/ +/ +/ +programs +. +Values +greater +than +0 +appear +when +compiling +regex +sets +and +/ +/ +/ +each +match +instruction +gets +its +own +unique +value +. +The +value +corresponds +/ +/ +/ +to +the +Nth +regex +in +the +set +. +Match +( +usize +) +/ +/ +/ +Save +causes +the +program +to +save +the +current +location +of +the +input +in +/ +/ +/ +the +slot +indicated +by +InstSave +. +Save +( +InstSave +) +/ +/ +/ +Split +causes +the +program +to +diverge +to +one +of +two +paths +in +the +/ +/ +/ +program +preferring +goto1 +in +InstSplit +. +Split +( +InstSplit +) +/ +/ +/ +EmptyLook +represents +a +zero +- +width +assertion +in +a +regex +program +. +A +/ +/ +/ +zero +- +width +assertion +does +not +consume +any +of +the +input +text +. +EmptyLook +( +InstEmptyLook +) +/ +/ +/ +Char +requires +the +regex +program +to +match +the +character +in +InstChar +at +/ +/ +/ +the +current +position +in +the +input +. +Char +( +InstChar +) +/ +/ +/ +Ranges +requires +the +regex +program +to +match +the +character +at +the +current +/ +/ +/ +position +in +the +input +with +one +of +the +ranges +specified +in +InstRanges +. +Ranges +( +InstRanges +) +/ +/ +/ +Bytes +is +like +Ranges +except +it +expresses +a +single +byte +range +. +It +is +/ +/ +/ +used +in +conjunction +with +Split +instructions +to +implement +multi +- +byte +/ +/ +/ +character +classes +. +Bytes +( +InstBytes +) +} +impl +Inst +{ +/ +/ +/ +Returns +true +if +and +only +if +this +is +a +match +instruction +. +pub +fn +is_match +( +& +self +) +- +> +bool +{ +match +* +self +{ +Inst +: +: +Match +( +_ +) += +> +true +_ += +> +false +} +} +} +/ +/ +/ +Representation +of +the +Save +instruction +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +InstSave +{ +/ +/ +/ +The +next +location +to +execute +in +the +program +. +pub +goto +: +InstPtr +/ +/ +/ +The +capture +slot +( +there +are +two +slots +for +every +capture +in +a +regex +/ +/ +/ +including +the +zeroth +capture +for +the +entire +match +) +. +pub +slot +: +usize +} +/ +/ +/ +Representation +of +the +Split +instruction +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +InstSplit +{ +/ +/ +/ +The +first +instruction +to +try +. +A +match +resulting +from +following +goto1 +/ +/ +/ +has +precedence +over +a +match +resulting +from +following +goto2 +. +pub +goto1 +: +InstPtr +/ +/ +/ +The +second +instruction +to +try +. +A +match +resulting +from +following +goto1 +/ +/ +/ +has +precedence +over +a +match +resulting +from +following +goto2 +. +pub +goto2 +: +InstPtr +} +/ +/ +/ +Representation +of +the +EmptyLook +instruction +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +InstEmptyLook +{ +/ +/ +/ +The +next +location +to +execute +in +the +program +if +this +instruction +/ +/ +/ +succeeds +. +pub +goto +: +InstPtr +/ +/ +/ +The +type +of +zero +- +width +assertion +to +check +. +pub +look +: +EmptyLook +} +/ +/ +/ +The +set +of +zero +- +width +match +instructions +. +# +[ +derive +( +Clone +Copy +Debug +PartialEq +Eq +) +] +pub +enum +EmptyLook +{ +/ +/ +/ +Start +of +line +or +input +. +StartLine +/ +/ +/ +End +of +line +or +input +. +EndLine +/ +/ +/ +Start +of +input +. +StartText +/ +/ +/ +End +of +input +. +EndText +/ +/ +/ +Word +character +on +one +side +and +non +- +word +character +on +other +. +WordBoundary +/ +/ +/ +Word +character +on +both +sides +or +non +- +word +character +on +both +sides +. +NotWordBoundary +/ +/ +/ +ASCII +word +boundary +. +WordBoundaryAscii +/ +/ +/ +Not +ASCII +word +boundary +. +NotWordBoundaryAscii +} +/ +/ +/ +Representation +of +the +Char +instruction +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +InstChar +{ +/ +/ +/ +The +next +location +to +execute +in +the +program +if +this +instruction +/ +/ +/ +succeeds +. +pub +goto +: +InstPtr +/ +/ +/ +The +character +to +test +. +pub +c +: +char +} +/ +/ +/ +Representation +of +the +Ranges +instruction +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +InstRanges +{ +/ +/ +/ +The +next +location +to +execute +in +the +program +if +this +instruction +/ +/ +/ +succeeds +. +pub +goto +: +InstPtr +/ +/ +/ +The +set +of +Unicode +scalar +value +ranges +to +test +. +pub +ranges +: +Box +< +[ +( +char +char +) +] +> +} +impl +InstRanges +{ +/ +/ +/ +Tests +whether +the +given +input +character +matches +this +instruction +. +pub +fn +matches +( +& +self +c +: +Char +) +- +> +bool +{ +/ +/ +This +speeds +up +the +match_class_unicode +benchmark +by +checking +/ +/ +some +common +cases +quickly +without +binary +search +. +e +. +g +. +Matching +/ +/ +a +Unicode +class +on +predominantly +ASCII +text +. +for +r +in +self +. +ranges +. +iter +( +) +. +take +( +4 +) +{ +if +c +< +r +. +0 +{ +return +false +; +} +if +c +< += +r +. +1 +{ +return +true +; +} +} +self +. +ranges +. +binary_search_by +( +| +r +| +{ +if +r +. +1 +< +c +{ +Ordering +: +: +Less +} +else +if +r +. +0 +> +c +{ +Ordering +: +: +Greater +} +else +{ +Ordering +: +: +Equal +} +} +) +. +is_ok +( +) +} +/ +/ +/ +Return +the +number +of +distinct +characters +represented +by +all +of +the +/ +/ +/ +ranges +. +pub +fn +num_chars +( +& +self +) +- +> +usize +{ +self +. +ranges +. +iter +( +) +. +map +( +| +& +( +s +e +) +| +1 ++ +( +e +as +u32 +) +- +( +s +as +u32 +) +) +. +sum +: +: +< +u32 +> +( +) +as +usize +} +} +/ +/ +/ +Representation +of +the +Bytes +instruction +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +InstBytes +{ +/ +/ +/ +The +next +location +to +execute +in +the +program +if +this +instruction +/ +/ +/ +succeeds +. +pub +goto +: +InstPtr +/ +/ +/ +The +start +( +inclusive +) +of +this +byte +range +. +pub +start +: +u8 +/ +/ +/ +The +end +( +inclusive +) +of +this +byte +range +. +pub +end +: +u8 +} +impl +InstBytes +{ +/ +/ +/ +Returns +true +if +and +only +if +the +given +byte +is +in +this +range +. +pub +fn +matches +( +& +self +byte +: +u8 +) +- +> +bool +{ +self +. +start +< += +byte +& +& +byte +< += +self +. +end +} +} +# +[ +cfg +( +test +) +] +mod +test +{ +# +[ +test +] +# +[ +cfg +( +target_pointer_width += +" +64 +" +) +] +fn +test_size_of_inst +( +) +{ +use +std +: +: +mem +: +: +size_of +; +use +super +: +: +Inst +; +assert_eq +! +( +32 +size_of +: +: +< +Inst +> +( +) +) +; +} +} diff --git a/third_party/rust/regex-automata/src/util/syntax.rs b/third_party/rust/regex/src/re_builder.rs similarity index 52% rename from third_party/rust/regex-automata/src/util/syntax.rs rename to third_party/rust/regex/src/re_builder.rs index c169dea6f34e5..4b78a5abe193b 100644 --- a/third_party/rust/regex-automata/src/util/syntax.rs +++ b/third_party/rust/regex/src/re_builder.rs @@ -1,160 +1,219 @@ / -* -! -Utilities -for -dealing -with -the -syntax +/ +/ +The +set of -a -regular -expression +user +configurable +options +for +compiling +zero +or +more +regexes . -This -module -currently -only -exposes -a +# [ -Config +derive +( +Clone +Debug +) ] -type -that -itself -represents -a -wrapper -around -the -configuration -for -a +# [ -regex -- -syntax +allow +( +missing_docs +) +] +pub +struct +RegexOptions +{ +pub +pats : +Vec +< +String +> +pub +size_limit : -ParserBuilder -] -( -regex_syntax +usize +pub +dfa_size_limit +: +usize +pub +nest_limit +: +u32 +pub +case_insensitive +: +bool +pub +multi_line +: +bool +pub +dot_matches_new_line +: +bool +pub +swap_greed +: +bool +pub +ignore_whitespace +: +bool +pub +unicode : +bool +pub +octal : -ParserBuilder +bool +} +impl +Default +for +RegexOptions +{ +fn +default +( ) -. -The -purpose -of -this -wrapper -is -to -make -configuring -syntax -options -very -similar -to -how -other -configuration -is -done -throughout -this -crate -. -Namely -instead -of -duplicating -syntax -options -across -every -builder +- +> +Self +{ +RegexOptions +{ +pats +: +vec +! +[ +] +size_limit +: +10 +* ( -of -which -there -are -many +1 +< +< +20 ) -we -instead -create -small -config -objects -like -this -one -that -can -be -passed -around -and -composed -. +dfa_size_limit +: +2 * -/ -use -alloc +( +1 +< +< +20 +) +nest_limit : +250 +case_insensitive : -{ -vec -vec +false +multi_line : +false +dot_matches_new_line : -Vec +false +swap_greed +: +false +ignore_whitespace +: +false +unicode +: +true +octal +: +false +} } +} +macro_rules +! +define_builder +{ +( +name +: +ident +regex_mod +: +ident +only_utf8 +: +expr +) += +> +{ +pub +mod +name +{ +use +super +: +: +RegexOptions ; use -regex_syntax +crate : : -{ -ast -hir +error : : -{ -self -Hir -} Error -ParserBuilder -} +; +use +crate +: +: +exec +: +: +ExecBuilder +; +use +crate +: +: +regex_mod +: +: +Regex ; / / / A -convenience -routine +configurable +builder for -parsing a -pattern -into -an -HIR -value -with -the -/ -/ -/ -default -configuration +regular +expression . / / @@ -162,449 +221,635 @@ configuration / / / -# -Example -/ -/ +A +builder +can +be +used +to +configure +how +the +regex +is +built +for +example +by / / / -/ -This -shows -how -to -parse -a -pattern -into -an -HIR -value -: +setting +the +default +flags +( +which +can +be +overridden +in +the +expression / / / +itself +) +or +setting +various +limits +. +# +[ +derive +( +Debug +) +] +pub +struct +RegexBuilder +( +RegexOptions +) +; +impl +RegexBuilder +{ / / / +Create +a +new +regular +expression +builder +with +the +given +pattern +. / / / -use -regex_automata -: -: -util -: -: -syntax -; / / / +If +the +pattern +is +invalid +then +an +error +will +be +returned +when / / / +build +is +called +. +pub +fn +new +( +pattern +: +& +str +) +- +> +RegexBuilder +{ let -hir +mut +builder = -syntax +RegexBuilder +( +RegexOptions : : -parse -( -r -" -( -[ -a -- -z -] -+ -) -| +default ( -[ -0 -- -9 -] -+ ) -" ) -? ; -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -hir +builder . -properties +0 +. +pats +. +push ( -) +pattern . -static_explicit_captures_len +to_owned ( ) ) ; +builder +} / / / +Consume +the +builder +and +compile +the +regular +expression +. +/ +/ / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) +/ +Note +that +calling +as_str +on +the +resulting +Regex +will +produce +the +/ +/ +/ +pattern +given +to +new +verbatim +. +Notably +it +will +not +incorporate +any / / / +of +the +flags +set +on +this +builder +. pub fn -parse +build ( -pattern -: & -str +self ) - > Result < -Hir +Regex Error > { -parse_with -( -pattern -& -Config +ExecBuilder : : -default +new_options +( +self +. +0 +. +clone +( +) +) +. +only_utf8 +( +only_utf8 +) +. +build ( ) +. +map +( +Regex +: +: +from ) } / / / -A -convenience -routine -for -parsing -many -patterns -into -HIR +Set +the value -with +for the +case +insensitive +( +i +) +flag +. / / / -default -configuration -. / / / +When +enabled +letters +in +the +pattern +will +match +both +upper +case +and / / / -# -Example +lower +case +variants +. +pub +fn +case_insensitive +( +& +mut +self +yes +: +bool +) +- +> +& +mut +RegexBuilder +{ +self +. +0 +. +case_insensitive += +yes +; +self +} / / / +Set +the +value +for +the +multi +- +line +matching +( +m +) +flag +. +/ / / / -This -shows -how -to -parse -many -patterns -into -an -corresponding -HIR -values -: / / +When +enabled +^ +matches +the +beginning +of +lines +and +matches +the / / / +end +of +lines +. / / / / -use -{ / / +By +default +they +match +beginning / -regex_automata -: -: -util -: +end +of +the +input +. +pub +fn +multi_line +( +& +mut +self +yes : -syntax +bool +) +- +> +& +mut +RegexBuilder +{ +self +. +0 +. +multi_line += +yes +; +self +} / / / -regex_syntax -: -: -hir -: -: -Properties +Set +the +value +for +the +any +character +( +s +) +flag +where +in +. +matches / / / -} -; +anything +when +s +is +set +and +matches +anything +except +for +new +line +when / / / +it +is +not +set +( +the +default +) +. / / / -let -hirs -= -syntax -: -: -parse_many -( -& -[ / / / -r +N +. +B +. " -( -[ -a -- -z -] -+ -) -| -( -[ -0 -- -9 -] -+ -) +matches +anything +" +means +" +any +byte " +when +Unicode +is +disabled +and / / / -r +means " -foo -( -A +any +valid +UTF - -Z -] -+ -) -bar +8 +encoding +of +any +Unicode +scalar +value " +when / / / -] -) -? -; -/ -/ -/ -let -props -= -Properties -: -: -union -( -hirs +Unicode +is +enabled . -iter +pub +fn +dot_matches_new_line ( +& +mut +self +yes +: +bool ) +- +> +& +mut +RegexBuilder +{ +self . -map -( -| -h -| -h +0 . -properties -( -) -) -) +dot_matches_new_line += +yes ; +self +} / / / -assert_eq -! -( -Some +Set +the +value +for +the +greedy +swap ( -1 +U ) -props +flag . -static_explicit_captures_len -( -) -) -; / / / / / / -# -Ok -: -: -< +When +enabled +a +pattern +like +a +* +is +lazy ( +tries +to +find +shortest +/ +/ +/ +match ) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( +and +a +* +? +is +greedy ( +tries +to +find +longest +match ) -) +. / / / -pub -fn -parse_many -< -P -: -AsRef -< -str -> -> -( -patterns -: +/ +/ +/ +By +default +a +* +is +greedy +and +a +* +? +is +lazy +. +pub +fn +swap_greed +( & -[ -P -] +mut +self +yes +: +bool ) - > -Result -< -Vec -< -Hir -> -Error -> -{ -parse_many_with -( -patterns & -Config -: -: -default -( -) -) +mut +RegexBuilder +{ +self +. +0 +. +swap_greed += +yes +; +self } / / / -A -convenience -routine -for -parsing -a -pattern -into -an -HIR +Set +the value -using -a -/ -/ -/ -Config +for +the +ignore +whitespace +( +x +) +flag . / / @@ -612,233 +857,210 @@ Config / / / -# -Example -/ -/ -/ +When +enabled +whitespace +such +as +new +lines +and +spaces +will +be +ignored / / / -This -shows -how -to -parse -a +between +expressions +of +the pattern -into -an -HIR -value -with +and +# +can +be +used +to +start a -non -- -default -/ -/ -/ -configuration -: -/ -/ -/ / / / -/ -/ -/ -use -regex_automata -: -: -util -: +comment +until +the +next +new +line +. +pub +fn +ignore_whitespace +( +& +mut +self +yes : -syntax +bool +) +- +> +& +mut +RegexBuilder +{ +self +. +0 +. +ignore_whitespace += +yes ; +self +} / / / +Set +the +value +for +the +Unicode +( +u +) +flag +. / / / -let -hir -= -syntax -: -: -parse_with -( / / / -r -" -^ -[ -a -- -z -] -+ -" +Enabled +by +default +. +When +disabled +character +classes +such +as +\ +w +only / / / +match +ASCII +word +characters +instead +of +all +Unicode +word +characters +. +pub +fn +unicode +( & -syntax -: -: -Config -: +mut +self +yes : -new -( +bool ) +- +> +& +mut +RegexBuilder +{ +self . -multi_line -( -true -) +0 . -crlf -( -true -) -/ -/ -/ -) -? +unicode += +yes ; +self +} / / / -assert -! -( -hir -. -properties -( -) -. -look_set -( -) +Whether +to +support +octal +syntax +or +not . -contains_anchor_crlf -( -) -) -; / / / / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) +Octal +syntax +is +a +little +- +known +way +of +uttering +Unicode +codepoints +in / / / -pub -fn -parse_with -( -pattern -: -& -str -config -: -& -Config -) -- -> -Result -< -Hir -Error -> -{ -let -mut -builder -= -ParserBuilder -: -: -new -( -) -; -config -. -apply -( -& -mut -builder -) -; -builder -. -build -( -) +a +regular +expression . -parse -( -pattern -) -} +For +example +a +\ +x61 +\ +u0061 +and / / / -A -convenience -routine -for -parsing -many -patterns -into -HIR -values -using -a +\ +141 +are +all +equivalent +regular +expressions +where +the +last +example / / / -Config +shows +octal +syntax . / / @@ -846,369 +1068,408 @@ Config / / / -# -Example +While +supporting +octal +syntax +isn +' +t +in +and +of +itself +a +problem +it +does / / / +make +good +error +messages +harder +. +That +is +in +PCRE +based +regex +engines / / / -This -shows -how -to -parse -many -patterns -into -an -corresponding -HIR -values +syntax +like +\ +0 +invokes +a +backreference +which +is +explicitly / / / -with -a -non -- -default -configuration -: +unsupported +in +Rust +' +s +regex +engine +. +However +many +users +expect +it +to / / / +be +supported +. +Therefore +when +octal +support +is +disabled +the +error / / / +message +will +explicitly +mention +that +backreferences +aren +' +t +supported +. / / / -use -{ / / / -regex_automata -: -: -util -: -: +Octal syntax +is +disabled +by +default +. +pub +fn +octal +( +& +mut +self +yes +: +bool +) +- +> +& +mut +RegexBuilder +{ +self +. +0 +. +octal += +yes +; +self +} / / / -regex_syntax -: -: -hir -: -: -Properties +Set +the +approximate +size +limit +of +the +compiled +regular +expression +. / / / -} -; / / / +This +roughly +corresponds +to +the +number +of +bytes +occupied +by +a +single / / / -let -patterns -= -& -[ +compiled +program +. +If +the +program +exceeds +this +number +then +a / / / -r -" +compilation +error +is +returned +. +pub +fn +size_limit ( -[ -a -- -z -] -+ +& +mut +self +limit +: +usize ) -| -( -[ -0 - -9 -] -+ -) -" +> +& +mut +RegexBuilder +{ +self +. +0 +. +size_limit += +limit +; +self +} / / / -r -" -\ -W -" +Set +the +approximate +size +of +the +cache +used +by +the +DFA +. / / / -r -" -foo -( -A -- -Z -] -+ -) -bar -" / / / -] -; +This +roughly +corresponds +to +the +number +of +bytes +that +the +DFA +will / / / -let -config -= -syntax -: -: -Config -: -: -new -( -) -. -unicode -( -false -) +use +while +searching . -utf8 -( -false -) -; / / / -let -hirs -= -syntax -: -: -parse_many_with -( -patterns -& -config -) -? -; / / / -let -props -= -Properties -: -: -union -( -hirs -. -iter -( -) -. -map -( -| -h -| -h +Note +that +this +is +a +* +per +thread +* +limit . -properties -( -) -) -) -; +There +is +no +way +to +set +a +global / / / -assert -! -( -! -props +limit . -is_utf8 -( -) -) -; -/ -/ -/ +In +particular +if +a +regex +is +used +from +multiple +threads / / / -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) +simultaneously +then +each +thread +may +use +up +to +the +number +of +bytes / / / +specified +here +. pub fn -parse_many_with -< -P -: -AsRef -< -str -> -> +dfa_size_limit ( -patterns -: & -[ -P -] -config +mut +self +limit : -& -Config +usize ) - > -Result -< -Vec -< -Hir -> -Error -> -{ -let -mut -builder -= -ParserBuilder -: -: -new -( -) -; -config -. -apply -( & mut -builder -) -; -let -mut -hirs +RegexBuilder +{ +self +. +0 +. +dfa_size_limit = -vec -! -[ -] +limit ; +self +} +/ +/ +/ +Set +the +nesting +limit for -p -in -patterns -. -iter -( -) -{ -hirs +this +parser . -push -( -builder +/ +/ +/ +/ +/ +/ +The +nesting +limit +controls +how +deep +the +abstract +syntax +tree +is +allowed +/ +/ +/ +to +be . -build +If +the +AST +exceeds +the +given +limit ( -) +e . -parse -( -p +g . -as_ref -( -) -) -? -) -; -} -Ok -( -hirs -) -} +with +too +many +nested / / / -A -common -set -of -configuration -options -that -apply -to +groups +) +then +an +error +is +returned +by the -syntax -of -a -regex +parser . / / @@ -1216,110 +1477,159 @@ regex / / / -This -represents -a -group +The +purpose of -configuration -options +this +limit +is +to +act +as +a +heuristic +to +prevent +stack +/ +/ +/ +overflow +for +consumers that -specifically -apply +do +structural +induction +on +an +Ast +using / / / -to -how -the -concrete -syntax -of -a -regular -expression -is -interpreted +explicit +recursion . -In +While +this +crate +never +does +this +( +instead +using / / / -particular -they -are -generally -forwarded +constant +stack +space +and +moving +the +call +stack to the +heap +) +other / / / -[ -ParserBuilder -] -( -https -: +crates +may +. / / -docs -. -rs / -regex -- -syntax / -* / -regex_syntax / -struct -. -ParserBuilder +This +limit +is +not +checked +until +the +entire +Ast +is +parsed . -html -) +Therefore / / / -in +if +callers +want +to +put +a +limit +on the +amount +of +heap +space +used +then / / / -[ -regex -- -syntax -] -( -https -: +they +should +impose +a +limit +on +the +length +in +bytes +of +the +concrete / / -docs +/ +pattern +string . -rs +In +particular +this +is +viable +since +this +parser / -regex -- -syntax -) +/ +/ +implementation +will +limit +itself +to +heap +space +proportional +to +the / / / -crate -when -building -a -regex -from -its -concrete -syntax -directly +length +of +the +pattern +string . / / @@ -1327,187 +1637,214 @@ directly / / / -These -options -are -defined -as +Note +that a -group -since -they -apply -to -every -regex -engine +nest +limit +of +0 +will +return +a +nest +limit +error +for +most / / / -in -this -crate +patterns +but +not +all . -Instead -of -re -- -defining -them -on -every -engine -' -s -builder -they +For +example +a +nest +limit +of +0 +permits +a +but / / / -are -instead -provided -here -as -one -cohesive -unit -. -# -[ -derive -( -Clone -Copy -Debug -) -] -pub -struct -Config -{ -case_insensitive -: -bool -multi_line -: -bool -dot_matches_new_line -: -bool -crlf -: -bool -line_terminator -: -u8 -swap_greed -: -bool -ignore_whitespace -: -bool -unicode -: -bool -utf8 -: -bool -nest_limit -: -u32 -octal -: -bool -} -impl -Config -{ +not +ab +since +ab +requires +a +concatenation +which +results +in +a +nest / / / -Return +depth +of +1 +. +In +general a -new -default +nest +limit +is +not +something +that +manifests +/ +/ +/ +in +an +obvious +way +in +the +concrete syntax -configuration +therefore +it +should +not +be +/ +/ +/ +used +in +a +granular +way . pub fn -new +nest_limit ( +& +mut +self +limit +: +u32 ) - > -Config +& +mut +RegexBuilder { -/ -/ -These -defaults -match -the -ones -used -in -regex -- -syntax +self +. +0 . -Config +nest_limit += +limit +; +self +} +} +} +} +; +} +define_builder +! +( +bytes +re_bytes +false +) +; +define_builder +! +( +unicode +re_unicode +true +) +; +macro_rules +! +define_set_builder { -case_insensitive +( +name : -false -multi_line +ident +regex_mod : -false -dot_matches_new_line +ident +only_utf8 : -false -crlf +expr +) += +> +{ +pub +mod +name +{ +use +super : -false -line_terminator : -b -' -\ -n -' -swap_greed +RegexOptions +; +use +crate : -false -ignore_whitespace : -false -unicode +error : -true -utf8 : -true -nest_limit +Error +; +use +crate : -250 -octal : -false -} -} +exec +: +: +ExecBuilder +; +use +crate +: +: +re_set +: +: +regex_mod +: +: +RegexSet +; / / / -Enable -or -disable -the -case -insensitive -flag -by -default +A +configurable +builder +for +a +set +of +regular +expressions . / / @@ -1515,39 +1852,76 @@ default / / / -When -Unicode -mode -is -enabled -case -insensitivity -is -Unicode -- -aware -. -/ -/ -/ -Specifically -it -will -apply +A +builder +can +be +used +to +configure +how the -" -simple -" -case -folding -rules -as +regexes +are +built +for +example / / / -specified by -Unicode +setting +the +default +flags +( +which +can +be +overridden +in +the +expression +/ +/ +/ +itself +) +or +setting +various +limits +. +# +[ +derive +( +Debug +) +] +pub +struct +RegexSetBuilder +( +RegexOptions +) +; +impl +RegexSetBuilder +{ +/ +/ +/ +Create +a +new +regular +expression +builder +with +the +given +pattern . / / @@ -1555,35 +1929,178 @@ Unicode / / / -By -default -this +If +the +pattern is -disabled -. -It -may -alternatively +invalid +then +an +error +will be -selectively +returned +when / / / -enabled +build +is +called +. +pub +fn +new +< +I +S +> +( +patterns +: +I +) +- +> +RegexSetBuilder +where +S +: +AsRef +< +str +> +I +: +IntoIterator +< +Item += +S +> +{ +let +mut +builder += +RegexSetBuilder +( +RegexOptions +: +: +default +( +) +) +; +for +pat in +patterns +{ +builder +. +0 +. +pats +. +push +( +pat +. +as_ref +( +) +. +to_owned +( +) +) +; +} +builder +} +/ +/ +/ +Consume +the +builder +and +compile the regular -expression -itself -via +expressions +into +a +set +. +pub +fn +build +( +& +self +) +- +> +Result +< +RegexSet +Error +> +{ +ExecBuilder +: +: +new_options +( +self +. +0 +. +clone +( +) +) +. +only_utf8 +( +only_utf8 +) +. +build +( +) +. +map +( +RegexSet +: +: +from +) +} +/ +/ +/ +Set the +value +for +the +case +insensitive +( i +) flag . pub fn case_insensitive ( +& mut self yes @@ -1592,10 +2109,14 @@ bool ) - > -Config +& +mut +RegexSetBuilder { self . +0 +. case_insensitive = yes @@ -1605,126 +2126,189 @@ self / / / -Enable -or -disable +Set +the +value +for the multi - line matching +( +m +) flag -by -default . +pub +fn +multi_line +( +& +mut +self +yes +: +bool +) +- +> +& +mut +RegexSetBuilder +{ +self +. +0 +. +multi_line += +yes +; +self +} / / / +Set +the +value +for +the +any +character +( +s +) +flag +where +in +. +matches / / / -When -this +anything +when +s is -enabled -the -^ +set and -look -- -around -assertions -will +matches +anything +except +for +new +line +when / / / -match -immediately -after -and -immediately -before -a -new -line -character -/ -/ -/ -respectively -. -Note -that +it +is +not +set +( the -\ -A -and -\ -z -look -- -around -assertions -are +default +) +. / / / -unaffected -by -this -setting -and -always -correspond -to -matching -at -the / / / -beginning -and -end -of -the -input +N . +B +. +" +matches +anything +" +means +" +any +byte +" +for +regex +: +: +bytes +: +: +RegexSet / / / +expressions +and +means +" +any +Unicode +scalar +value +" +for +regex +: +: +RegexSet / / / -By -default -this -is -disabled +expressions . -It -may -alternatively -be -selectively +pub +fn +dot_matches_new_line +( +& +mut +self +yes +: +bool +) +- +> +& +mut +RegexSetBuilder +{ +self +. +0 +. +dot_matches_new_line += +yes +; +self +} / / / -enabled -in +Set the -regular -expression -itself -via +value +for the -m +greedy +swap +( +U +) flag . pub fn -multi_line +swap_greed ( +& mut self yes @@ -1733,11 +2317,15 @@ bool ) - > -Config +& +mut +RegexSetBuilder { self . -multi_line +0 +. +swap_greed = yes ; @@ -1746,224 +2334,265 @@ self / / / -Enable -or -disable +Set the -" -dot -matches -any -character -" +value +for +the +ignore +whitespace +( +x +) flag -by -default . -/ -/ -/ -/ -/ -/ -When -this -is -enabled +pub +fn +ignore_whitespace +( +& +mut +self +yes +: +bool +) +- +> +& +mut +RegexSetBuilder +{ +self . -will -match -any -character +0 . -When -it -' -s -disabled +ignore_whitespace += +yes +; +self +} / / / -then -. -will -match -any -character -except +Set +the +value for -a -new -line -character +the +Unicode +( +u +) +flag +. +pub +fn +unicode +( +& +mut +self +yes +: +bool +) +- +> +& +mut +RegexSetBuilder +{ +self . +0 +. +unicode += +yes +; +self +} / / / +Whether +to +support +octal +syntax +or +not +. / / / -Note -that -. -is -impacted -by -whether -the -" -unicode -" -setting -is -enabled / / / -or -not -. -When -Unicode +Octal +syntax is -enabled -( -the -default -) -. -will -match -any -UTF +a +little - -8 +known +way +of +uttering +Unicode +codepoints +in / / / -encoding -of -any -Unicode -scalar -value -( -sans a -new -line -depending -on +regular +expression +. +For +example +a +\ +x61 +\ +u0061 +and / / / -whether -this -" -dot -matches -new -line -" -option -is -enabled -) -. -When -Unicode +\ +141 +are +all +equivalent +regular +expressions +where +the +last +example / / / -mode -is -disabled -. -will -match -any -byte -instead +shows +octal +syntax . -Because +/ +/ +/ +/ +/ +/ +While +supporting +octal +syntax +isn +' +t +in +and of -this +itself +a +problem +it +does / / / -when -Unicode -mode -is -disabled +make +good +error +messages +harder . -can -only -be -used -when -the -" -allow +That +is +in +PCRE +based +regex +engines / / / -invalid -UTF -- -8 -" -option +syntax +like +\ +0 +invokes +a +backreference +which is -enabled -since -. -could -otherwise -match +explicitly / / / -invalid -UTF -- -8 +unsupported +in +Rust +' +s +regex +engine . +However +many +users +expect +it +to / / / +be +supported +. +Therefore +when +octal +support +is +disabled +the +error / / / -By -default -this -is -disabled +message +will +explicitly +mention +that +backreferences +aren +' +t +supported . -It -may -alternatively -be -selectively / / / -enabled -in -the -regular -expression -itself -via -the -s -flag +/ +/ +/ +Octal +syntax +is +disabled +by +default . pub fn -dot_matches_new_line +octal ( +& mut self yes @@ -1972,11 +2601,15 @@ bool ) - > -Config +& +mut +RegexSetBuilder { self . -dot_matches_new_line +0 +. +octal = yes ; @@ -1985,48 +2618,16 @@ self / / / -Enable -or -disable +Set the -" -CRLF -mode -" -flag -by -default -. -/ -/ -/ -/ -/ -/ -By -default -this -is -disabled -. -It -may -alternatively -be -selectively -/ -/ -/ -enabled -in +approximate +size +limit +of the +compiled regular expression -itself -via -the -R -flag . / / @@ -2034,137 +2635,81 @@ flag / / / -When -CRLF -mode -is -enabled +This +roughly +corresponds +to the -following -happens -: -/ -/ +number +of +bytes +occupied +by +a +single / / / -/ -* -Unless -dot_matches_new_line -is -enabled -. -will -match -any -character -/ -/ -/ -except -for -\ -r -and -\ -n +compiled +program . +If +the +program +exceeds +this +number +then +a / / / -* -When -multi_line -mode +compilation +error is -enabled -^ -and -will -treat -\ -r -\ -n -/ -/ -/ -\ -r -and -\ -n -as -line -terminators -. -And -in -particular -neither -will -/ -/ -/ -match -between -a -\ -r -and -a -\ -n +returned . pub fn -crlf +size_limit ( +& mut self -yes +limit : -bool +usize ) - > -Config +& +mut +RegexSetBuilder { self . -crlf +0 +. +size_limit = -yes +limit ; self } / / / -Sets +Set the -line -terminator -for -use -with -( -? -u -- -s -: -. -) -and -( -? -- -us -: -. -) +approximate +size +of +the +cache +used +by +the +DFA . / / @@ -2172,35 +2717,24 @@ us / / / -Namely -instead +This +roughly +corresponds +to +the +number of -. -( -by -default -) -matching -everything -except -for -\ -n +bytes +that +the +DFA +will / / / -this -will -cause -. -to -match -everything -except -for -the -byte -given +use +while +searching . / / @@ -2208,247 +2742,152 @@ given / / / -If -. +Note +that +this is -used -in a -context -where -Unicode -mode +* +per +thread +* +limit +. +There is -enabled -and -this -byte +no +way +to +set +a +global / / / -isn -' -t -ASCII -then -an -error -will -be -returned +limit . -When -Unicode -mode +In +particular +if +a +regex is +used +from +multiple +threads / / / -disabled +simultaneously then -any -byte -is -permitted -but -will -return -an -error -if -UTF -- -8 +each +thread +may +use +up +to +the +number +of +bytes / / / -mode -is -enabled -and -it -is -a -non +specified +here +. +pub +fn +dfa_size_limit +( +& +mut +self +limit +: +usize +) - -ASCII -byte +> +& +mut +RegexSetBuilder +{ +self . +0 +. +dfa_size_limit += +limit +; +self +} / / / -/ -/ -/ -In -short -any -ASCII -value +Set +the +nesting +limit for -a -line -terminator -is -always -okay +this +parser . -But -a -/ -/ -/ -non -- -ASCII -byte -might -result -in -an -error -depending -on -whether -Unicode -/ / / -mode -or -UTF -- -8 -mode -are -enabled -. -/ / / / / -/ -Note -that -if -R -mode +The +nesting +limit +controls +how +deep +the +abstract +syntax +tree is -enabled -then -it -always -takes -precedence -and +allowed / / / -the -line -terminator -will +to be -treated -as -\ -r -and -\ -n -simultaneously . -/ -/ -/ -/ -/ -/ -Note -also -that -this -* -doesn -' -t -* -impact +If the -look -- -around -assertions -/ -/ -/ -( -? -m -: -^ -) -and -( -? -m -: -) -. -That -' -s -usually -controlled -by -additional -/ -/ -/ -configuration -in +AST +exceeds the -regex -engine -itself -. -pub -fn -line_terminator +given +limit ( -mut -self -byte -: -u8 -) -- -> -Config -{ -self +e . -line_terminator -= -byte -; -self -} +g +. +with +too +many +nested / / / -Enable -or -disable -the -" -swap -greed -" -flag +groups +) +then +an +error +is +returned by -default +the +parser . / / @@ -2456,93 +2895,70 @@ default / / / -When +The +purpose +of this +limit is -enabled -. -* -( -for -example -) -will -become -ungreedy -and -. -* -? -/ -/ -/ -will -become -greedy -. +to +act +as +a +heuristic +to +prevent +stack / / / +overflow +for +consumers +that +do +structural +induction +on +an +Ast +using / / / -By -default -this -is -disabled +explicit +recursion . -It -may -alternatively -be -selectively +While +this +crate +never +does +this +( +instead +using / / / -enabled -in +constant +stack +space +and +moving the -regular -expression -itself -via +call +stack +to the -U -flag -. -pub -fn -swap_greed -( -mut -self -yes -: -bool +heap ) -- -> -Config -{ -self -. -swap_greed -= -yes -; -self -} +other / / / -Enable -verbose -mode -in -the -regular -expression +crates +may . / / @@ -2550,150 +2966,88 @@ expression / / / -When -enabled -verbose -mode -permits -insigificant -whitespace -in -many -/ -/ -/ -places -in +This +limit +is +not +checked +until the -regular -expression -as -well -as -comments +entire +Ast +is +parsed . -Comments -are +Therefore / / / -started -using -# -and -continue -until +if +callers +want +to +put +a +limit +on the -end +amount of -the -line -. -/ -/ -/ +heap +space +used +then / / / -By -default -this -is -disabled -. -It -may -be -selectively -enabled +they +should +impose +a +limit +on +the +length in +bytes +of the +concrete / / / -regular -expression -by -using -the -x -flag -regardless -of -this -setting -. -pub -fn -ignore_whitespace -( -mut -self -yes -: -bool -) -- -> -Config -{ -self +pattern +string . -ignore_whitespace -= -yes -; -self -} +In +particular +this +is +viable +since +this +parser / / / -Enable -or -disable +implementation +will +limit +itself +to +heap +space +proportional +to the -Unicode -flag -( -u -) -by -default -. -/ -/ -/ -/ -/ -/ -By -default -this -is -* -* -enabled -* -* -. -It -may -alternatively -be -selectively / / / -disabled -in -the -regular -expression -itself -via +length +of the -u -flag +pattern +string . / / @@ -2703,1485 +3057,139 @@ flag / Note that -unless -" -allow -invalid -UTF -- -8 -" -is -enabled -( -it -' -s -disabled -by -/ -/ -/ -default -) a -regular -expression +nest +limit +of +0 will -fail -to -parse -if -Unicode -mode -is -/ -/ -/ -disabled -and +return a -sub -- -expression -could -possibly -match -invalid -UTF -- -8 -. -/ -/ -/ +nest +limit +error +for +most / / / -* -* -WARNING -* -* -: -Unicode -mode -can -greatly -increase -the -size +patterns +but +not +all +. +For +example +a +nest +limit of -the -compiled +0 +permits +a +but / / / -DFA +not +ab +since +ab +requires +a +concatenation which -can -noticeably -impact -both -memory -usage -and -compilation +results +in +a +nest / / / -time +depth +of +1 . -This +In +general +a +nest +limit is -especially -noticeable -if -your -regex -contains -character +not +something +that +manifests / / / -classes -like -\ -w -that -are -impacted -by -whether -Unicode -is -enabled -or +in +an +obvious +way +in +the +concrete +syntax +therefore +it +should +not +be / / / -not -. -If -Unicode -is -not -necessary -you -are -encouraged -to -disable -it +used +in +a +granular +way . pub fn -unicode -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -unicode -= -yes -; -self -} -/ -/ -/ -When -disabled -the -builder -will -permit -the -construction -of -a -regular -/ -/ -/ -expression -that -may -match -invalid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -For -example -when -[ -Config -: -: -unicode -] -is -disabled -then -/ -/ -/ -expressions -like -[ -^ -a -] -may -match -invalid -UTF -- -8 -since -they -can -match -/ -/ -/ -any -single -byte -that -is -not -a -. -By -default -these -sub -- -expressions -/ -/ -/ -are -disallowed -to -avoid -returning -offsets -that -split -a -UTF -- -8 -/ -/ -/ -encoded -codepoint -. -However -in -cases -where -matching -at -arbitrary -/ -/ -/ -locations -is -desired -this -option -can -be -disabled -to -permit -all -such -/ -/ -/ -sub -- -expressions -. -/ -/ -/ -/ -/ -/ -When -enabled -( -the -default -) -the -builder -is -guaranteed -to -produce -a -/ -/ -/ -regex -that -will -only -ever -match -valid -UTF -- -8 -( -otherwise -the -builder -/ -/ -/ -will -return -an -error -) -. -pub -fn -utf8 -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -utf8 -= -yes -; -self -} -/ -/ -/ -Set -the -nesting -limit -used -for -the -regular -expression -parser -. -/ -/ -/ -/ -/ -/ -The -nesting -limit -controls -how -deep -the -abstract -syntax -tree -is -allowed -/ -/ -/ -to -be -. -If -the -AST -exceeds -the -given -limit -( -e -. -g -. -with -too -many -nested -/ -/ -/ -groups -) -then -an -error -is -returned -by -the -parser -. -/ -/ -/ -/ -/ -/ -The -purpose -of -this -limit -is -to -act -as -a -heuristic -to -prevent -stack -/ -/ -/ -overflow -when -building -a -finite -automaton -from -a -regular -expression -' -s -/ -/ -/ -abstract -syntax -tree -. -In -particular -construction -currently -uses -/ -/ -/ -recursion -. -In -the -future -the -implementation -may -stop -using -recursion -/ -/ -/ -and -this -option -will -no -longer -be -necessary -. -/ -/ -/ -/ -/ -/ -This -limit -is -not -checked -until -the -entire -AST -is -parsed -. -Therefore -/ -/ -/ -if -callers -want -to -put -a -limit -on -the -amount -of -heap -space -used -then -/ -/ -/ -they -should -impose -a -limit -on -the -length -in -bytes -of -the -concrete -/ -/ -/ -pattern -string -. -In -particular -this -is -viable -since -the -parser -will -/ -/ -/ -limit -itself -to -heap -space -proportional -to -the -length -of -the -pattern -/ -/ -/ -string -. -/ -/ -/ -/ -/ -/ -Note -that -a -nest -limit -of -0 -will -return -a -nest -limit -error -for -most -/ -/ -/ -patterns -but -not -all -. -For -example -a -nest -limit -of -0 -permits -a -but -/ -/ -/ -not -ab -since -ab -requires -a -concatenation -AST -item -which -results -/ -/ -/ -in -a -nest -depth -of -1 -. -In -general -a -nest -limit -is -not -something -that -/ -/ -/ -manifests -in -an -obvious -way -in -the -concrete -syntax -therefore -it -/ -/ -/ -should -not -be -used -in -a -granular -way -. -pub -fn -nest_limit -( -mut -self -limit -: -u32 -) -- -> -Config -{ -self -. -nest_limit -= -limit -; -self -} -/ -/ -/ -Whether -to -support -octal -syntax -or -not -. -/ -/ -/ -/ -/ -/ -Octal -syntax -is -a -little -- -known -way -of -uttering -Unicode -codepoints -in -/ -/ -/ -a -regular -expression -. -For -example -a -\ -x61 -\ -u0061 -and -/ -/ -/ -\ -141 -are -all -equivalent -regular -expressions -where -the -last -example -/ -/ -/ -shows -octal -syntax -. -/ -/ -/ -/ -/ -/ -While -supporting -octal -syntax -isn -' -t -in -and -of -itself -a -problem -it -does -/ -/ -/ -make -good -error -messages -harder -. -That -is -in -PCRE -based -regex -engines -/ -/ -/ -syntax -like -\ -1 -invokes -a -backreference -which -is -explicitly -/ -/ -/ -unsupported -in -Rust -' -s -regex -engine -. -However -many -users -expect -it -to -/ -/ -/ -be -supported -. -Therefore -when -octal -support -is -disabled -the -error -/ -/ -/ -message -will -explicitly -mention -that -backreferences -aren -' -t -supported -. -/ -/ -/ -/ -/ -/ -Octal -syntax -is -disabled -by -default -. -pub -fn -octal -( -mut -self -yes -: -bool -) -- -> -Config -{ -self -. -octal -= -yes -; -self -} -/ -/ -/ -Returns -whether -" -unicode -" -mode -is -enabled -. -pub -fn -get_unicode -( -& -self -) -- -> -bool -{ -self -. -unicode -} -/ -/ -/ -Returns -whether -" -case -insensitive -" -mode -is -enabled -. -pub -fn -get_case_insensitive -( -& -self -) -- -> -bool -{ -self -. -case_insensitive -} -/ -/ -/ -Returns -whether -" -multi -line -" -mode -is -enabled -. -pub -fn -get_multi_line -( -& -self -) -- -> -bool -{ -self -. -multi_line -} -/ -/ -/ -Returns -whether -" -dot -matches -new -line -" -mode -is -enabled -. -pub -fn -get_dot_matches_new_line -( -& -self -) -- -> -bool -{ -self -. -dot_matches_new_line -} -/ -/ -/ -Returns -whether -" -CRLF -" -mode -is -enabled -. -pub -fn -get_crlf -( -& -self -) -- -> -bool -{ -self -. -crlf -} -/ -/ -/ -Returns -the -line -terminator -in -this -syntax -configuration -. -pub -fn -get_line_terminator -( -& -self -) -- -> -u8 -{ -self -. -line_terminator -} -/ -/ -/ -Returns -whether -" -swap -greed -" -mode -is -enabled -. -pub -fn -get_swap_greed -( -& -self -) -- -> -bool -{ -self -. -swap_greed -} -/ -/ -/ -Returns -whether -" -ignore -whitespace -" -mode -is -enabled -. -pub -fn -get_ignore_whitespace -( -& -self -) -- -> -bool -{ -self -. -ignore_whitespace -} -/ -/ -/ -Returns -whether -UTF -- -8 -mode -is -enabled -. -pub -fn -get_utf8 -( -& -self -) -- -> -bool -{ -self -. -utf8 -} -/ -/ -/ -Returns -the -" -nest -limit -" -setting -. -pub -fn -get_nest_limit -( -& -self -) -- -> -u32 -{ -self -. -nest_limit -} -/ -/ -/ -Returns -whether -" -octal -" -mode -is -enabled -. -pub -fn -get_octal -( -& -self -) -- -> -bool -{ -self -. -octal -} -/ -/ -/ -Applies -this -configuration -to -the -given -parser -. -pub -( -crate -) -fn -apply -( -& -self -builder -: -& -mut -ParserBuilder -) -{ -builder -. -unicode -( -self -. -unicode -) -. -case_insensitive -( -self -. -case_insensitive -) -. -multi_line -( -self -. -multi_line -) -. -dot_matches_new_line -( -self -. -dot_matches_new_line -) -. -crlf -( -self -. -crlf -) -. -line_terminator -( -self -. -line_terminator -) -. -swap_greed -( -self -. -swap_greed -) -. -ignore_whitespace -( -self -. -ignore_whitespace -) -. -utf8 -( -self -. -utf8 -) -. nest_limit ( -self -. -nest_limit -) -. -octal -( -self -. -octal -) -; -} -/ -/ -/ -Applies -this -configuration -to -the -given -AST -parser -. -pub -( -crate -) -fn -apply_ast -( & +mut self -builder +limit : +u32 +) +- +> & mut -ast -: -: -parse -: -: -ParserBuilder -) +RegexSetBuilder { -builder -. -ignore_whitespace -( self . -ignore_whitespace -) -. -nest_limit -( -self +0 . nest_limit -) -. -octal -( += +limit +; self -. -octal -) +} +} +} +} ; } -/ -/ -/ -Applies -this -configuration -to -the -given -AST -- -to -- -HIR -translator -. -pub -( -crate -) -fn -apply_hir +define_set_builder +! ( -& -self -builder -: -& -mut -hir -: -: -translate -: -: -TranslatorBuilder +set_bytes +bytes +false ) -{ -builder -. -unicode +; +define_set_builder +! ( -self -. +set_unicode unicode -) -. -case_insensitive -( -self -. -case_insensitive -) -. -multi_line -( -self -. -multi_line -) -. -crlf -( -self -. -crlf -) -. -dot_matches_new_line -( -self -. -dot_matches_new_line -) -. -line_terminator -( -self -. -line_terminator -) -. -swap_greed -( -self -. -swap_greed -) -. -utf8 -( -self -. -utf8 +true ) ; -} -} -impl -Default -for -Config -{ -fn -default -( -) -- -> -Config -{ -Config -: -: -new -( -) -} -} diff --git a/third_party/rust/regex/src/re_bytes.rs b/third_party/rust/regex/src/re_bytes.rs new file mode 100644 index 0000000000000..4927e3dd32b21 --- /dev/null +++ b/third_party/rust/regex/src/re_bytes.rs @@ -0,0 +1,12094 @@ +use +std +: +: +borrow +: +: +Cow +; +use +std +: +: +collections +: +: +HashMap +; +use +std +: +: +fmt +; +use +std +: +: +iter +: +: +FusedIterator +; +use +std +: +: +ops +: +: +{ +Index +Range +} +; +use +std +: +: +str +: +: +FromStr +; +use +std +: +: +sync +: +: +Arc +; +use +crate +: +: +find_byte +: +: +find_byte +; +use +crate +: +: +error +: +: +Error +; +use +crate +: +: +exec +: +: +{ +Exec +ExecNoSync +} +; +use +crate +: +: +expand +: +: +expand_bytes +; +use +crate +: +: +re_builder +: +: +bytes +: +: +RegexBuilder +; +use +crate +: +: +re_trait +: +: +{ +self +RegularExpression +SubCapturesPosIter +} +; +/ +/ +/ +Match +represents +a +single +match +of +a +regex +in +a +haystack +. +/ +/ +/ +/ +/ +/ +The +lifetime +parameter +' +t +refers +to +the +lifetime +of +the +matched +text +. +# +[ +derive +( +Copy +Clone +Debug +Eq +PartialEq +) +] +pub +struct +Match +< +' +t +> +{ +text +: +& +' +t +[ +u8 +] +start +: +usize +end +: +usize +} +impl +< +' +t +> +Match +< +' +t +> +{ +/ +/ +/ +Returns +the +starting +byte +offset +of +the +match +in +the +haystack +. +# +[ +inline +] +pub +fn +start +( +& +self +) +- +> +usize +{ +self +. +start +} +/ +/ +/ +Returns +the +ending +byte +offset +of +the +match +in +the +haystack +. +# +[ +inline +] +pub +fn +end +( +& +self +) +- +> +usize +{ +self +. +end +} +/ +/ +/ +Returns +the +range +over +the +starting +and +ending +byte +offsets +of +the +/ +/ +/ +match +in +the +haystack +. +# +[ +inline +] +pub +fn +range +( +& +self +) +- +> +Range +< +usize +> +{ +self +. +start +. +. +self +. +end +} +/ +/ +/ +Returns +the +matched +text +. +# +[ +inline +] +pub +fn +as_bytes +( +& +self +) +- +> +& +' +t +[ +u8 +] +{ +& +self +. +text +[ +self +. +range +( +) +] +} +/ +/ +/ +Creates +a +new +match +from +the +given +haystack +and +byte +offsets +. +# +[ +inline +] +fn +new +( +haystack +: +& +' +t +[ +u8 +] +start +: +usize +end +: +usize +) +- +> +Match +< +' +t +> +{ +Match +{ +text +: +haystack +start +end +} +} +} +impl +< +' +t +> +From +< +Match +< +' +t +> +> +for +Range +< +usize +> +{ +fn +from +( +m +: +Match +< +' +t +> +) +- +> +Range +< +usize +> +{ +m +. +range +( +) +} +} +/ +/ +/ +A +compiled +regular +expression +for +matching +arbitrary +bytes +. +/ +/ +/ +/ +/ +/ +It +can +be +used +to +search +split +or +replace +text +. +All +searching +is +done +with +/ +/ +/ +an +implicit +. +* +? +at +the +beginning +and +end +of +an +expression +. +To +force +an +/ +/ +/ +expression +to +match +the +whole +string +( +or +a +prefix +or +a +suffix +) +you +must +/ +/ +/ +use +an +anchor +like +^ +or +( +or +\ +A +and +\ +z +) +. +/ +/ +/ +/ +/ +/ +Like +the +Regex +type +in +the +parent +module +matches +with +this +regex +return +/ +/ +/ +byte +offsets +into +the +search +text +. +* +* +Unlike +* +* +the +parent +Regex +type +/ +/ +/ +these +byte +offsets +may +not +correspond +to +UTF +- +8 +sequence +boundaries +since +/ +/ +/ +the +regexes +in +this +module +can +match +arbitrary +bytes +. +# +[ +derive +( +Clone +) +] +pub +struct +Regex +( +Exec +) +; +impl +fmt +: +: +Display +for +Regex +{ +/ +/ +/ +Shows +the +original +regular +expression +. +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +write +! +( +f +" +{ +} +" +self +. +as_str +( +) +) +} +} +impl +fmt +: +: +Debug +for +Regex +{ +/ +/ +/ +Shows +the +original +regular +expression +. +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +fmt +: +: +Display +: +: +fmt +( +self +f +) +} +} +/ +/ +/ +A +constructor +for +Regex +from +an +Exec +. +/ +/ +/ +/ +/ +/ +This +is +hidden +because +Exec +isn +' +t +actually +part +of +the +public +API +. +# +[ +doc +( +hidden +) +] +impl +From +< +Exec +> +for +Regex +{ +fn +from +( +exec +: +Exec +) +- +> +Regex +{ +Regex +( +exec +) +} +} +impl +FromStr +for +Regex +{ +type +Err += +Error +; +/ +/ +/ +Attempts +to +parse +a +string +into +a +regular +expression +fn +from_str +( +s +: +& +str +) +- +> +Result +< +Regex +Error +> +{ +Regex +: +: +new +( +s +) +} +} +/ +/ +/ +Core +regular +expression +methods +. +impl +Regex +{ +/ +/ +/ +Compiles +a +regular +expression +. +Once +compiled +it +can +be +used +repeatedly +/ +/ +/ +to +search +split +or +replace +text +in +a +string +. +/ +/ +/ +/ +/ +/ +If +an +invalid +expression +is +given +then +an +error +is +returned +. +pub +fn +new +( +re +: +& +str +) +- +> +Result +< +Regex +Error +> +{ +RegexBuilder +: +: +new +( +re +) +. +build +( +) +} +/ +/ +/ +Returns +true +if +and +only +if +there +is +a +match +for +the +regex +in +the +/ +/ +/ +string +given +. +/ +/ +/ +/ +/ +/ +It +is +recommended +to +use +this +method +if +all +you +need +to +do +is +test +/ +/ +/ +a +match +since +the +underlying +matching +engine +may +be +able +to +do +less +/ +/ +/ +work +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Test +if +some +text +contains +at +least +one +word +with +exactly +13 +ASCII +word +/ +/ +/ +bytes +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +text += +b +" +I +categorically +deny +having +triskaidekaphobia +. +" +; +/ +/ +/ +assert +! +( +Regex +: +: +new +( +r +" +\ +b +\ +w +{ +13 +} +\ +b +" +) +. +unwrap +( +) +. +is_match +( +text +) +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +is_match +( +& +self +text +: +& +[ +u8 +] +) +- +> +bool +{ +self +. +is_match_at +( +text +0 +) +} +/ +/ +/ +Returns +the +start +and +end +byte +range +of +the +leftmost +- +first +match +in +/ +/ +/ +text +. +If +no +match +exists +then +None +is +returned +. +/ +/ +/ +/ +/ +/ +Note +that +this +should +only +be +used +if +you +want +to +discover +the +position +/ +/ +/ +of +the +match +. +Testing +the +existence +of +a +match +is +faster +if +you +use +/ +/ +/ +is_match +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Find +the +start +and +end +location +of +the +first +word +with +exactly +13 +/ +/ +/ +ASCII +word +bytes +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +text += +b +" +I +categorically +deny +having +triskaidekaphobia +. +" +; +/ +/ +/ +let +mat += +Regex +: +: +new +( +r +" +\ +b +\ +w +{ +13 +} +\ +b +" +) +. +unwrap +( +) +. +find +( +text +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +( +mat +. +start +( +) +mat +. +end +( +) +) +( +2 +15 +) +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +find +< +' +t +> +( +& +self +text +: +& +' +t +[ +u8 +] +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +find_at +( +text +0 +) +} +/ +/ +/ +Returns +an +iterator +for +each +successive +non +- +overlapping +match +in +/ +/ +/ +text +returning +the +start +and +end +byte +indices +with +respect +to +/ +/ +/ +text +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Find +the +start +and +end +location +of +every +word +with +exactly +13 +ASCII +/ +/ +/ +word +bytes +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +text += +b +" +Retroactively +relinquishing +remunerations +is +reprehensible +. +" +; +/ +/ +/ +for +mat +in +Regex +: +: +new +( +r +" +\ +b +\ +w +{ +13 +} +\ +b +" +) +. +unwrap +( +) +. +find_iter +( +text +) +{ +/ +/ +/ +println +! +( +" +{ +: +? +} +" +mat +) +; +/ +/ +/ +} +/ +/ +/ +# +} +/ +/ +/ +pub +fn +find_iter +< +' +r +' +t +> +( +& +' +r +self +text +: +& +' +t +[ +u8 +] +) +- +> +Matches +< +' +r +' +t +> +{ +Matches +( +self +. +0 +. +searcher +( +) +. +find_iter +( +text +) +) +} +/ +/ +/ +Returns +the +capture +groups +corresponding +to +the +leftmost +- +first +/ +/ +/ +match +in +text +. +Capture +group +0 +always +corresponds +to +the +entire +/ +/ +/ +match +. +If +no +match +is +found +then +None +is +returned +. +/ +/ +/ +/ +/ +/ +You +should +only +use +captures +if +you +need +access +to +the +location +of +/ +/ +/ +capturing +group +matches +. +Otherwise +find +is +faster +for +discovering +/ +/ +/ +the +location +of +the +overall +match +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Say +you +have +some +text +with +movie +names +and +their +release +years +/ +/ +/ +like +" +' +Citizen +Kane +' +( +1941 +) +" +. +It +' +d +be +nice +if +we +could +search +for +text +/ +/ +/ +looking +like +that +while +also +extracting +the +movie +name +and +its +release +/ +/ +/ +year +separately +. +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +' +( +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +\ +d +{ +4 +} +) +\ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +text += +b +" +Not +my +favorite +movie +: +' +Citizen +Kane +' +( +1941 +) +. +" +; +/ +/ +/ +let +caps += +re +. +captures +( +text +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +caps +. +get +( +1 +) +. +unwrap +( +) +. +as_bytes +( +) +& +b +" +Citizen +Kane +" +[ +. +. +] +) +; +/ +/ +/ +assert_eq +! +( +caps +. +get +( +2 +) +. +unwrap +( +) +. +as_bytes +( +) +& +b +" +1941 +" +[ +. +. +] +) +; +/ +/ +/ +assert_eq +! +( +caps +. +get +( +0 +) +. +unwrap +( +) +. +as_bytes +( +) +& +b +" +' +Citizen +Kane +' +( +1941 +) +" +[ +. +. +] +) +; +/ +/ +/ +/ +/ +You +can +also +access +the +groups +by +index +using +the +Index +notation +. +/ +/ +/ +/ +/ +Note +that +this +will +panic +on +an +invalid +index +. +/ +/ +/ +assert_eq +! +( +& +caps +[ +1 +] +b +" +Citizen +Kane +" +) +; +/ +/ +/ +assert_eq +! +( +& +caps +[ +2 +] +b +" +1941 +" +) +; +/ +/ +/ +assert_eq +! +( +& +caps +[ +0 +] +b +" +' +Citizen +Kane +' +( +1941 +) +" +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +Note +that +the +full +match +is +at +capture +group +0 +. +Each +subsequent +/ +/ +/ +capture +group +is +indexed +by +the +order +of +its +opening +( +. +/ +/ +/ +/ +/ +/ +We +can +make +this +example +a +bit +clearer +by +using +* +named +* +capture +groups +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +/ +/ +/ +. +unwrap +( +) +; +/ +/ +/ +let +text += +b +" +Not +my +favorite +movie +: +' +Citizen +Kane +' +( +1941 +) +. +" +; +/ +/ +/ +let +caps += +re +. +captures +( +text +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +caps +. +name +( +" +title +" +) +. +unwrap +( +) +. +as_bytes +( +) +b +" +Citizen +Kane +" +) +; +/ +/ +/ +assert_eq +! +( +caps +. +name +( +" +year +" +) +. +unwrap +( +) +. +as_bytes +( +) +b +" +1941 +" +) +; +/ +/ +/ +assert_eq +! +( +caps +. +get +( +0 +) +. +unwrap +( +) +. +as_bytes +( +) +& +b +" +' +Citizen +Kane +' +( +1941 +) +" +[ +. +. +] +) +; +/ +/ +/ +/ +/ +You +can +also +access +the +groups +by +name +using +the +Index +notation +. +/ +/ +/ +/ +/ +Note +that +this +will +panic +on +an +invalid +group +name +. +/ +/ +/ +assert_eq +! +( +& +caps +[ +" +title +" +] +b +" +Citizen +Kane +" +) +; +/ +/ +/ +assert_eq +! +( +& +caps +[ +" +year +" +] +b +" +1941 +" +) +; +/ +/ +/ +assert_eq +! +( +& +caps +[ +0 +] +b +" +' +Citizen +Kane +' +( +1941 +) +" +) +; +/ +/ +/ +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +Here +we +name +the +capture +groups +which +we +can +access +with +the +name +/ +/ +/ +method +or +the +Index +notation +with +a +& +str +. +Note +that +the +named +/ +/ +/ +capture +groups +are +still +accessible +with +get +or +the +Index +notation +/ +/ +/ +with +a +usize +. +/ +/ +/ +/ +/ +/ +The +0 +th +capture +group +is +always +unnamed +so +it +must +always +be +/ +/ +/ +accessed +with +get +( +0 +) +or +[ +0 +] +. +pub +fn +captures +< +' +t +> +( +& +self +text +: +& +' +t +[ +u8 +] +) +- +> +Option +< +Captures +< +' +t +> +> +{ +let +mut +locs += +self +. +capture_locations +( +) +; +self +. +captures_read_at +( +& +mut +locs +text +0 +) +. +map +( +move +| +_ +| +Captures +{ +text +locs +: +locs +. +0 +named_groups +: +self +. +0 +. +capture_name_idx +( +) +. +clone +( +) +} +) +} +/ +/ +/ +Returns +an +iterator +over +all +the +non +- +overlapping +capture +groups +matched +/ +/ +/ +in +text +. +This +is +operationally +the +same +as +find_iter +except +it +/ +/ +/ +yields +information +about +capturing +group +matches +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +We +can +use +this +to +find +all +movie +titles +and +their +release +years +in +/ +/ +/ +some +text +where +the +movie +is +formatted +like +" +' +Title +' +( +xxxx +) +" +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +std +: +: +str +; +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +/ +/ +/ +. +unwrap +( +) +; +/ +/ +/ +let +text += +b +" +' +Citizen +Kane +' +( +1941 +) +' +The +Wizard +of +Oz +' +( +1939 +) +' +M +' +( +1931 +) +. +" +; +/ +/ +/ +for +caps +in +re +. +captures_iter +( +text +) +{ +/ +/ +/ +let +title += +str +: +: +from_utf8 +( +& +caps +[ +" +title +" +] +) +. +unwrap +( +) +; +/ +/ +/ +let +year += +str +: +: +from_utf8 +( +& +caps +[ +" +year +" +] +) +. +unwrap +( +) +; +/ +/ +/ +println +! +( +" +Movie +: +{ +: +? +} +Released +: +{ +: +? +} +" +title +year +) +; +/ +/ +/ +} +/ +/ +/ +/ +/ +Output +: +/ +/ +/ +/ +/ +Movie +: +Citizen +Kane +Released +: +1941 +/ +/ +/ +/ +/ +Movie +: +The +Wizard +of +Oz +Released +: +1939 +/ +/ +/ +/ +/ +Movie +: +M +Released +: +1931 +/ +/ +/ +# +} +/ +/ +/ +pub +fn +captures_iter +< +' +r +' +t +> +( +& +' +r +self +text +: +& +' +t +[ +u8 +] +) +- +> +CaptureMatches +< +' +r +' +t +> +{ +CaptureMatches +( +self +. +0 +. +searcher +( +) +. +captures_iter +( +text +) +) +} +/ +/ +/ +Returns +an +iterator +of +substrings +of +text +delimited +by +a +match +of +the +/ +/ +/ +regular +expression +. +Namely +each +element +of +the +iterator +corresponds +to +/ +/ +/ +text +that +* +isn +' +t +* +matched +by +the +regular +expression +. +/ +/ +/ +/ +/ +/ +This +method +will +* +not +* +copy +the +text +given +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +To +split +a +string +delimited +by +arbitrary +amounts +of +spaces +or +tabs +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +[ +\ +t +] ++ +" +) +. +unwrap +( +) +; +/ +/ +/ +let +fields +: +Vec +< +& +[ +u8 +] +> += +re +. +split +( +b +" +a +b +\ +t +c +\ +td +e +" +) +. +collect +( +) +; +/ +/ +/ +assert_eq +! +( +fields +vec +! +[ +/ +/ +/ +& +b +" +a +" +[ +. +. +] +& +b +" +b +" +[ +. +. +] +& +b +" +c +" +[ +. +. +] +& +b +" +d +" +[ +. +. +] +& +b +" +e +" +[ +. +. +] +/ +/ +/ +] +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +split +< +' +r +' +t +> +( +& +' +r +self +text +: +& +' +t +[ +u8 +] +) +- +> +Split +< +' +r +' +t +> +{ +Split +{ +finder +: +self +. +find_iter +( +text +) +last +: +0 +} +} +/ +/ +/ +Returns +an +iterator +of +at +most +limit +substrings +of +text +delimited +/ +/ +/ +by +a +match +of +the +regular +expression +. +( +A +limit +of +0 +will +return +no +/ +/ +/ +substrings +. +) +Namely +each +element +of +the +iterator +corresponds +to +text +/ +/ +/ +that +* +isn +' +t +* +matched +by +the +regular +expression +. +The +remainder +of +the +/ +/ +/ +string +that +is +not +split +will +be +the +last +element +in +the +iterator +. +/ +/ +/ +/ +/ +/ +This +method +will +* +not +* +copy +the +text +given +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Get +the +first +two +words +in +some +text +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +\ +W ++ +" +) +. +unwrap +( +) +; +/ +/ +/ +let +fields +: +Vec +< +& +[ +u8 +] +> += +re +. +splitn +( +b +" +Hey +! +How +are +you +? +" +3 +) +. +collect +( +) +; +/ +/ +/ +assert_eq +! +( +fields +vec +! +[ +& +b +" +Hey +" +[ +. +. +] +& +b +" +How +" +[ +. +. +] +& +b +" +are +you +? +" +[ +. +. +] +] +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +splitn +< +' +r +' +t +> +( +& +' +r +self +text +: +& +' +t +[ +u8 +] +limit +: +usize +) +- +> +SplitN +< +' +r +' +t +> +{ +SplitN +{ +splits +: +self +. +split +( +text +) +n +: +limit +} +} +/ +/ +/ +Replaces +the +leftmost +- +first +match +with +the +replacement +provided +. +The +/ +/ +/ +replacement +can +be +a +regular +byte +string +( +where +N +and +name +are +/ +/ +/ +expanded +to +match +capture +groups +) +or +a +function +that +takes +the +matches +' +/ +/ +/ +Captures +and +returns +the +replaced +byte +string +. +/ +/ +/ +/ +/ +/ +If +no +match +is +found +then +a +copy +of +the +byte +string +is +returned +/ +/ +/ +unchanged +. +/ +/ +/ +/ +/ +/ +# +Replacement +string +syntax +/ +/ +/ +/ +/ +/ +All +instances +of +name +in +the +replacement +text +is +replaced +with +the +/ +/ +/ +corresponding +capture +group +name +. +/ +/ +/ +/ +/ +/ +name +may +be +an +integer +corresponding +to +the +index +of +the +/ +/ +/ +capture +group +( +counted +by +order +of +opening +parenthesis +where +0 +is +the +/ +/ +/ +entire +match +) +or +it +can +be +a +name +( +consisting +of +letters +digits +or +/ +/ +/ +underscores +) +corresponding +to +a +named +capture +group +. +/ +/ +/ +/ +/ +/ +If +name +isn +' +t +a +valid +capture +group +( +whether +the +name +doesn +' +t +exist +/ +/ +/ +or +isn +' +t +a +valid +index +) +then +it +is +replaced +with +the +empty +string +. +/ +/ +/ +/ +/ +/ +The +longest +possible +name +is +used +. +e +. +g +. +1a +looks +up +the +capture +/ +/ +/ +group +named +1a +and +not +the +capture +group +at +index +1 +. +To +exert +more +/ +/ +/ +precise +control +over +the +name +use +braces +e +. +g +. +{ +1 +} +a +. +/ +/ +/ +/ +/ +/ +To +write +a +literal +use +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Note +that +this +function +is +polymorphic +with +respect +to +the +replacement +. +/ +/ +/ +In +typical +usage +this +can +just +be +a +normal +byte +string +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +" +[ +^ +01 +] ++ +" +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +re +. +replace +( +b +" +1078910 +" +& +b +" +" +[ +. +. +] +) +& +b +" +1010 +" +[ +. +. +] +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +But +anything +satisfying +the +Replacer +trait +will +work +. +For +example +a +/ +/ +/ +closure +of +type +| +& +Captures +| +- +> +Vec +< +u8 +> +provides +direct +access +to +the +/ +/ +/ +captures +corresponding +to +a +match +. +This +allows +one +to +access +capturing +/ +/ +/ +group +matches +easily +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Captures +; +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +( +[ +^ +\ +s +] ++ +) +\ +s ++ +( +\ +S ++ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +result += +re +. +replace +( +b +" +Springsteen +Bruce +" +| +caps +: +& +Captures +| +{ +/ +/ +/ +let +mut +replacement += +caps +[ +2 +] +. +to_owned +( +) +; +/ +/ +/ +replacement +. +push +( +b +' +' +) +; +/ +/ +/ +replacement +. +extend +( +& +caps +[ +1 +] +) +; +/ +/ +/ +replacement +/ +/ +/ +} +) +; +/ +/ +/ +assert_eq +! +( +result +& +b +" +Bruce +Springsteen +" +[ +. +. +] +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +But +this +is +a +bit +cumbersome +to +use +all +the +time +. +Instead +a +simple +/ +/ +/ +syntax +is +supported +that +expands +name +into +the +corresponding +capture +/ +/ +/ +group +. +Here +' +s +the +last +example +but +using +this +expansion +technique +/ +/ +/ +with +named +capture +groups +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +( +? +P +< +last +> +[ +^ +\ +s +] ++ +) +\ +s ++ +( +? +P +< +first +> +\ +S ++ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +result += +re +. +replace +( +b +" +Springsteen +Bruce +" +& +b +" +first +last +" +[ +. +. +] +) +; +/ +/ +/ +assert_eq +! +( +result +& +b +" +Bruce +Springsteen +" +[ +. +. +] +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +Note +that +using +2 +instead +of +first +or +1 +instead +of +last +/ +/ +/ +would +produce +the +same +result +. +To +write +a +literal +use +. +/ +/ +/ +/ +/ +/ +Sometimes +the +replacement +string +requires +use +of +curly +braces +to +/ +/ +/ +delineate +a +capture +group +replacement +and +surrounding +literal +text +. +/ +/ +/ +For +example +if +we +wanted +to +join +two +words +together +with +an +/ +/ +/ +underscore +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +( +? +P +< +first +> +\ +w ++ +) +\ +s ++ +( +? +P +< +second +> +\ +w ++ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +result += +re +. +replace +( +b +" +deep +fried +" +& +b +" +{ +first +} +_ +second +" +[ +. +. +] +) +; +/ +/ +/ +assert_eq +! +( +result +& +b +" +deep_fried +" +[ +. +. +] +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +Without +the +curly +braces +the +capture +group +name +first_ +would +be +/ +/ +/ +used +and +since +it +doesn +' +t +exist +it +would +be +replaced +with +the +empty +/ +/ +/ +string +. +/ +/ +/ +/ +/ +/ +Finally +sometimes +you +just +want +to +replace +a +literal +string +with +no +/ +/ +/ +regard +for +capturing +group +expansion +. +This +can +be +done +by +wrapping +a +/ +/ +/ +byte +string +with +NoExpand +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +use +regex +: +: +bytes +: +: +NoExpand +; +/ +/ +/ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +( +? +P +< +last +> +[ +^ +\ +s +] ++ +) +\ +s ++ +( +\ +S ++ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +result += +re +. +replace +( +b +" +Springsteen +Bruce +" +NoExpand +( +b +" +2 +last +" +) +) +; +/ +/ +/ +assert_eq +! +( +result +& +b +" +2 +last +" +[ +. +. +] +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +replace +< +' +t +R +: +Replacer +> +( +& +self +text +: +& +' +t +[ +u8 +] +rep +: +R +) +- +> +Cow +< +' +t +[ +u8 +] +> +{ +self +. +replacen +( +text +1 +rep +) +} +/ +/ +/ +Replaces +all +non +- +overlapping +matches +in +text +with +the +replacement +/ +/ +/ +provided +. +This +is +the +same +as +calling +replacen +with +limit +set +to +/ +/ +/ +0 +. +/ +/ +/ +/ +/ +/ +See +the +documentation +for +replace +for +details +on +how +to +access +/ +/ +/ +capturing +group +matches +in +the +replacement +text +. +pub +fn +replace_all +< +' +t +R +: +Replacer +> +( +& +self +text +: +& +' +t +[ +u8 +] +rep +: +R +) +- +> +Cow +< +' +t +[ +u8 +] +> +{ +self +. +replacen +( +text +0 +rep +) +} +/ +/ +/ +Replaces +at +most +limit +non +- +overlapping +matches +in +text +with +the +/ +/ +/ +replacement +provided +. +If +limit +is +0 +then +all +non +- +overlapping +matches +/ +/ +/ +are +replaced +. +/ +/ +/ +/ +/ +/ +See +the +documentation +for +replace +for +details +on +how +to +access +/ +/ +/ +capturing +group +matches +in +the +replacement +text +. +pub +fn +replacen +< +' +t +R +: +Replacer +> +( +& +self +text +: +& +' +t +[ +u8 +] +limit +: +usize +mut +rep +: +R +) +- +> +Cow +< +' +t +[ +u8 +] +> +{ +if +let +Some +( +rep +) += +rep +. +no_expansion +( +) +{ +let +mut +it += +self +. +find_iter +( +text +) +. +enumerate +( +) +. +peekable +( +) +; +if +it +. +peek +( +) +. +is_none +( +) +{ +return +Cow +: +: +Borrowed +( +text +) +; +} +let +mut +new += +Vec +: +: +with_capacity +( +text +. +len +( +) +) +; +let +mut +last_match += +0 +; +for +( +i +m +) +in +it +{ +new +. +extend_from_slice +( +& +text +[ +last_match +. +. +m +. +start +( +) +] +) +; +new +. +extend_from_slice +( +& +rep +) +; +last_match += +m +. +end +( +) +; +if +limit +> +0 +& +& +i +> += +limit +- +1 +{ +break +; +} +} +new +. +extend_from_slice +( +& +text +[ +last_match +. +. +] +) +; +return +Cow +: +: +Owned +( +new +) +; +} +/ +/ +The +slower +path +which +we +use +if +the +replacement +needs +access +to +/ +/ +capture +groups +. +let +mut +it += +self +. +captures_iter +( +text +) +. +enumerate +( +) +. +peekable +( +) +; +if +it +. +peek +( +) +. +is_none +( +) +{ +return +Cow +: +: +Borrowed +( +text +) +; +} +let +mut +new += +Vec +: +: +with_capacity +( +text +. +len +( +) +) +; +let +mut +last_match += +0 +; +for +( +i +cap +) +in +it +{ +/ +/ +unwrap +on +0 +is +OK +because +captures +only +reports +matches +let +m += +cap +. +get +( +0 +) +. +unwrap +( +) +; +new +. +extend_from_slice +( +& +text +[ +last_match +. +. +m +. +start +( +) +] +) +; +rep +. +replace_append +( +& +cap +& +mut +new +) +; +last_match += +m +. +end +( +) +; +if +limit +> +0 +& +& +i +> += +limit +- +1 +{ +break +; +} +} +new +. +extend_from_slice +( +& +text +[ +last_match +. +. +] +) +; +Cow +: +: +Owned +( +new +) +} +} +/ +/ +/ +Advanced +or +" +lower +level +" +search +methods +. +impl +Regex +{ +/ +/ +/ +Returns +the +end +location +of +a +match +in +the +text +given +. +/ +/ +/ +/ +/ +/ +This +method +may +have +the +same +performance +characteristics +as +/ +/ +/ +is_match +except +it +provides +an +end +location +for +a +match +. +In +/ +/ +/ +particular +the +location +returned +* +may +be +shorter +* +than +the +proper +end +/ +/ +/ +of +the +leftmost +- +first +match +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Typically +a ++ +would +match +the +entire +first +sequence +of +a +in +some +/ +/ +/ +text +but +shortest_match +can +give +up +as +soon +as +it +sees +the +first +/ +/ +/ +a +. +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +text += +b +" +aaaaa +" +; +/ +/ +/ +let +pos += +Regex +: +: +new +( +r +" +a ++ +" +) +. +unwrap +( +) +. +shortest_match +( +text +) +; +/ +/ +/ +assert_eq +! +( +pos +Some +( +1 +) +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +shortest_match +( +& +self +text +: +& +[ +u8 +] +) +- +> +Option +< +usize +> +{ +self +. +shortest_match_at +( +text +0 +) +} +/ +/ +/ +Returns +the +same +as +shortest_match +but +starts +the +search +at +the +given +/ +/ +/ +offset +. +/ +/ +/ +/ +/ +/ +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding +/ +/ +/ +context +into +consideration +. +For +example +the +\ +A +anchor +can +only +/ +/ +/ +match +when +start += += +0 +. +pub +fn +shortest_match_at +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +Option +< +usize +> +{ +self +. +0 +. +searcher +( +) +. +shortest_match_at +( +text +start +) +} +/ +/ +/ +Returns +the +same +as +is_match +but +starts +the +search +at +the +given +/ +/ +/ +offset +. +/ +/ +/ +/ +/ +/ +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding +/ +/ +/ +context +into +consideration +. +For +example +the +\ +A +anchor +can +only +/ +/ +/ +match +when +start += += +0 +. +pub +fn +is_match_at +( +& +self +text +: +& +[ +u8 +] +start +: +usize +) +- +> +bool +{ +self +. +0 +. +searcher +( +) +. +is_match_at +( +text +start +) +} +/ +/ +/ +Returns +the +same +as +find +but +starts +the +search +at +the +given +/ +/ +/ +offset +. +/ +/ +/ +/ +/ +/ +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding +/ +/ +/ +context +into +consideration +. +For +example +the +\ +A +anchor +can +only +/ +/ +/ +match +when +start += += +0 +. +pub +fn +find_at +< +' +t +> +( +& +self +text +: +& +' +t +[ +u8 +] +start +: +usize +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +0 +. +searcher +( +) +. +find_at +( +text +start +) +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +text +s +e +) +) +} +/ +/ +/ +This +is +like +captures +but +uses +/ +/ +/ +[ +CaptureLocations +] +( +struct +. +CaptureLocations +. +html +) +/ +/ +/ +instead +of +/ +/ +/ +[ +Captures +] +( +struct +. +Captures +. +html +) +in +order +to +amortize +allocations +. +/ +/ +/ +/ +/ +/ +To +create +a +CaptureLocations +value +use +the +/ +/ +/ +Regex +: +: +capture_locations +method +. +/ +/ +/ +/ +/ +/ +This +returns +the +overall +match +if +this +was +successful +which +is +always +/ +/ +/ +equivalence +to +the +0 +th +capture +group +. +pub +fn +captures_read +< +' +t +> +( +& +self +locs +: +& +mut +CaptureLocations +text +: +& +' +t +[ +u8 +] +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +captures_read_at +( +locs +text +0 +) +} +/ +/ +/ +Returns +the +same +as +captures_read +but +starts +the +search +at +the +given +/ +/ +/ +offset +and +populates +the +capture +locations +given +. +/ +/ +/ +/ +/ +/ +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding +/ +/ +/ +context +into +consideration +. +For +example +the +\ +A +anchor +can +only +/ +/ +/ +match +when +start += += +0 +. +pub +fn +captures_read_at +< +' +t +> +( +& +self +locs +: +& +mut +CaptureLocations +text +: +& +' +t +[ +u8 +] +start +: +usize +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +0 +. +searcher +( +) +. +captures_read_at +( +& +mut +locs +. +0 +text +start +) +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +text +s +e +) +) +} +/ +/ +/ +An +undocumented +alias +for +captures_read_at +. +/ +/ +/ +/ +/ +/ +The +regex +- +capi +crate +previously +used +this +routine +so +to +avoid +/ +/ +/ +breaking +that +crate +we +continue +to +provide +the +name +as +an +undocumented +/ +/ +/ +alias +. +# +[ +doc +( +hidden +) +] +pub +fn +read_captures_at +< +' +t +> +( +& +self +locs +: +& +mut +CaptureLocations +text +: +& +' +t +[ +u8 +] +start +: +usize +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +captures_read_at +( +locs +text +start +) +} +} +/ +/ +/ +Auxiliary +methods +. +impl +Regex +{ +/ +/ +/ +Returns +the +original +string +of +this +regex +. +pub +fn +as_str +( +& +self +) +- +> +& +str +{ +& +self +. +0 +. +regex_strings +( +) +[ +0 +] +} +/ +/ +/ +Returns +an +iterator +over +the +capture +names +. +pub +fn +capture_names +( +& +self +) +- +> +CaptureNames +< +' +_ +> +{ +CaptureNames +( +self +. +0 +. +capture_names +( +) +. +iter +( +) +) +} +/ +/ +/ +Returns +the +number +of +captures +. +pub +fn +captures_len +( +& +self +) +- +> +usize +{ +self +. +0 +. +capture_names +( +) +. +len +( +) +} +/ +/ +/ +Returns +an +empty +set +of +capture +locations +that +can +be +reused +in +/ +/ +/ +multiple +calls +to +captures_read +or +captures_read_at +. +pub +fn +capture_locations +( +& +self +) +- +> +CaptureLocations +{ +CaptureLocations +( +self +. +0 +. +searcher +( +) +. +locations +( +) +) +} +/ +/ +/ +An +alias +for +capture_locations +to +preserve +backward +compatibility +. +/ +/ +/ +/ +/ +/ +The +regex +- +capi +crate +uses +this +method +so +to +avoid +breaking +that +/ +/ +/ +crate +we +continue +to +export +it +as +an +undocumented +API +. +# +[ +doc +( +hidden +) +] +pub +fn +locations +( +& +self +) +- +> +CaptureLocations +{ +CaptureLocations +( +self +. +0 +. +searcher +( +) +. +locations +( +) +) +} +} +/ +/ +/ +An +iterator +over +all +non +- +overlapping +matches +for +a +particular +string +. +/ +/ +/ +/ +/ +/ +The +iterator +yields +a +tuple +of +integers +corresponding +to +the +start +and +end +/ +/ +/ +of +the +match +. +The +indices +are +byte +offsets +. +The +iterator +stops +when +no +more +/ +/ +/ +matches +can +be +found +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +and +' +t +is +the +/ +/ +/ +lifetime +of +the +matched +byte +string +. +# +[ +derive +( +Debug +) +] +pub +struct +Matches +< +' +r +' +t +> +( +re_trait +: +: +Matches +< +' +t +ExecNoSync +< +' +r +> +> +) +; +impl +< +' +r +' +t +> +Iterator +for +Matches +< +' +r +' +t +> +{ +type +Item += +Match +< +' +t +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Match +< +' +t +> +> +{ +let +text += +self +. +0 +. +text +( +) +; +self +. +0 +. +next +( +) +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +text +s +e +) +) +} +} +impl +< +' +r +' +t +> +FusedIterator +for +Matches +< +' +r +' +t +> +{ +} +/ +/ +/ +An +iterator +that +yields +all +non +- +overlapping +capture +groups +matching +a +/ +/ +/ +particular +regular +expression +. +/ +/ +/ +/ +/ +/ +The +iterator +stops +when +no +more +matches +can +be +found +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +and +' +t +is +the +/ +/ +/ +lifetime +of +the +matched +byte +string +. +# +[ +derive +( +Debug +) +] +pub +struct +CaptureMatches +< +' +r +' +t +> +( +re_trait +: +: +CaptureMatches +< +' +t +ExecNoSync +< +' +r +> +> +) +; +impl +< +' +r +' +t +> +Iterator +for +CaptureMatches +< +' +r +' +t +> +{ +type +Item += +Captures +< +' +t +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Captures +< +' +t +> +> +{ +self +. +0 +. +next +( +) +. +map +( +| +locs +| +Captures +{ +text +: +self +. +0 +. +text +( +) +locs +named_groups +: +self +. +0 +. +regex +( +) +. +capture_name_idx +( +) +. +clone +( +) +} +) +} +} +impl +< +' +r +' +t +> +FusedIterator +for +CaptureMatches +< +' +r +' +t +> +{ +} +/ +/ +/ +Yields +all +substrings +delimited +by +a +regular +expression +match +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +and +' +t +is +the +/ +/ +/ +lifetime +of +the +byte +string +being +split +. +# +[ +derive +( +Debug +) +] +pub +struct +Split +< +' +r +' +t +> +{ +finder +: +Matches +< +' +r +' +t +> +last +: +usize +} +impl +< +' +r +' +t +> +Iterator +for +Split +< +' +r +' +t +> +{ +type +Item += +& +' +t +[ +u8 +] +; +fn +next +( +& +mut +self +) +- +> +Option +< +& +' +t +[ +u8 +] +> +{ +let +text += +self +. +finder +. +0 +. +text +( +) +; +match +self +. +finder +. +next +( +) +{ +None += +> +{ +if +self +. +last +> +text +. +len +( +) +{ +None +} +else +{ +let +s += +& +text +[ +self +. +last +. +. +] +; +self +. +last += +text +. +len +( +) ++ +1 +; +/ +/ +Next +call +will +return +None +Some +( +s +) +} +} +Some +( +m +) += +> +{ +let +matched += +& +text +[ +self +. +last +. +. +m +. +start +( +) +] +; +self +. +last += +m +. +end +( +) +; +Some +( +matched +) +} +} +} +} +impl +< +' +r +' +t +> +FusedIterator +for +Split +< +' +r +' +t +> +{ +} +/ +/ +/ +Yields +at +most +N +substrings +delimited +by +a +regular +expression +match +. +/ +/ +/ +/ +/ +/ +The +last +substring +will +be +whatever +remains +after +splitting +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +and +' +t +is +the +/ +/ +/ +lifetime +of +the +byte +string +being +split +. +# +[ +derive +( +Debug +) +] +pub +struct +SplitN +< +' +r +' +t +> +{ +splits +: +Split +< +' +r +' +t +> +n +: +usize +} +impl +< +' +r +' +t +> +Iterator +for +SplitN +< +' +r +' +t +> +{ +type +Item += +& +' +t +[ +u8 +] +; +fn +next +( +& +mut +self +) +- +> +Option +< +& +' +t +[ +u8 +] +> +{ +if +self +. +n += += +0 +{ +return +None +; +} +self +. +n +- += +1 +; +if +self +. +n +> +0 +{ +return +self +. +splits +. +next +( +) +; +} +let +text += +self +. +splits +. +finder +. +0 +. +text +( +) +; +if +self +. +splits +. +last +> +text +. +len +( +) +{ +/ +/ +We +' +ve +already +returned +all +substrings +. +None +} +else +{ +/ +/ +self +. +n += += +0 +so +future +calls +will +return +None +immediately +Some +( +& +text +[ +self +. +splits +. +last +. +. +] +) +} +} +fn +size_hint +( +& +self +) +- +> +( +usize +Option +< +usize +> +) +{ +( +0 +Some +( +self +. +n +) +) +} +} +impl +< +' +r +' +t +> +FusedIterator +for +SplitN +< +' +r +' +t +> +{ +} +/ +/ +/ +An +iterator +over +the +names +of +all +possible +captures +. +/ +/ +/ +/ +/ +/ +None +indicates +an +unnamed +capture +; +the +first +element +( +capture +0 +the +/ +/ +/ +whole +matched +region +) +is +always +unnamed +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +CaptureNames +< +' +r +> +( +: +: +std +: +: +slice +: +: +Iter +< +' +r +Option +< +String +> +> +) +; +impl +< +' +r +> +Iterator +for +CaptureNames +< +' +r +> +{ +type +Item += +Option +< +& +' +r +str +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Option +< +& +' +r +str +> +> +{ +self +. +0 +. +next +( +) +. +as_ref +( +) +. +map +( +| +slot +| +slot +. +as_ref +( +) +. +map +( +| +name +| +name +. +as_ref +( +) +) +) +} +fn +size_hint +( +& +self +) +- +> +( +usize +Option +< +usize +> +) +{ +self +. +0 +. +size_hint +( +) +} +fn +count +( +self +) +- +> +usize +{ +self +. +0 +. +count +( +) +} +} +impl +< +' +r +> +ExactSizeIterator +for +CaptureNames +< +' +r +> +{ +} +impl +< +' +r +> +FusedIterator +for +CaptureNames +< +' +r +> +{ +} +/ +/ +/ +CaptureLocations +is +a +low +level +representation +of +the +raw +offsets +of +each +/ +/ +/ +submatch +. +/ +/ +/ +/ +/ +/ +You +can +think +of +this +as +a +lower +level +/ +/ +/ +[ +Captures +] +( +struct +. +Captures +. +html +) +where +this +type +does +not +support +/ +/ +/ +named +capturing +groups +directly +and +it +does +not +borrow +the +text +that +these +/ +/ +/ +offsets +were +matched +on +. +/ +/ +/ +/ +/ +/ +Primarily +this +type +is +useful +when +using +the +lower +level +Regex +APIs +/ +/ +/ +such +as +read_captures +which +permits +amortizing +the +allocation +in +which +/ +/ +/ +capture +match +locations +are +stored +. +/ +/ +/ +/ +/ +/ +In +order +to +build +a +value +of +this +type +you +' +ll +need +to +call +the +/ +/ +/ +capture_locations +method +on +the +Regex +being +used +to +execute +the +search +. +/ +/ +/ +The +value +returned +can +then +be +reused +in +subsequent +searches +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +CaptureLocations +( +re_trait +: +: +Locations +) +; +/ +/ +/ +A +type +alias +for +CaptureLocations +for +backwards +compatibility +. +/ +/ +/ +/ +/ +/ +Previously +we +exported +CaptureLocations +as +Locations +in +an +/ +/ +/ +undocumented +API +. +To +prevent +breaking +that +code +( +e +. +g +. +in +regex +- +capi +) +/ +/ +/ +we +continue +re +- +exporting +the +same +undocumented +API +. +# +[ +doc +( +hidden +) +] +pub +type +Locations += +CaptureLocations +; +impl +CaptureLocations +{ +/ +/ +/ +Returns +the +start +and +end +positions +of +the +Nth +capture +group +. +Returns +/ +/ +/ +None +if +i +is +not +a +valid +capture +group +or +if +the +capture +group +did +/ +/ +/ +not +match +anything +. +The +positions +returned +are +* +always +* +byte +indices +/ +/ +/ +with +respect +to +the +original +string +matched +. +# +[ +inline +] +pub +fn +get +( +& +self +i +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +self +. +0 +. +pos +( +i +) +} +/ +/ +/ +Returns +the +total +number +of +capture +groups +( +even +if +they +didn +' +t +match +) +. +/ +/ +/ +/ +/ +/ +This +is +always +at +least +1 +since +every +regex +has +at +least +1 +/ +/ +/ +capturing +group +that +corresponds +to +the +entire +match +. +# +[ +inline +] +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +0 +. +len +( +) +} +/ +/ +/ +An +alias +for +the +get +method +for +backwards +compatibility +. +/ +/ +/ +/ +/ +/ +Previously +we +exported +get +as +pos +in +an +undocumented +API +. +To +/ +/ +/ +prevent +breaking +that +code +( +e +. +g +. +in +regex +- +capi +) +we +continue +/ +/ +/ +re +- +exporting +the +same +undocumented +API +. +# +[ +doc +( +hidden +) +] +# +[ +inline +] +pub +fn +pos +( +& +self +i +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +self +. +get +( +i +) +} +} +/ +/ +/ +Captures +represents +a +group +of +captured +byte +strings +for +a +single +match +. +/ +/ +/ +/ +/ +/ +The +0th +capture +always +corresponds +to +the +entire +match +. +Each +subsequent +/ +/ +/ +index +corresponds +to +the +next +capture +group +in +the +regex +. +If +a +capture +/ +/ +/ +group +is +named +then +the +matched +byte +string +is +* +also +* +available +via +the +/ +/ +/ +name +method +. +( +Note +that +the +0th +capture +is +always +unnamed +and +so +must +be +/ +/ +/ +accessed +with +the +get +method +. +) +/ +/ +/ +/ +/ +/ +Positions +returned +from +a +capture +group +are +always +byte +indices +. +/ +/ +/ +/ +/ +/ +' +t +is +the +lifetime +of +the +matched +text +. +pub +struct +Captures +< +' +t +> +{ +text +: +& +' +t +[ +u8 +] +locs +: +re_trait +: +: +Locations +named_groups +: +Arc +< +HashMap +< +String +usize +> +> +} +impl +< +' +t +> +Captures +< +' +t +> +{ +/ +/ +/ +Returns +the +match +associated +with +the +capture +group +at +index +i +. +If +/ +/ +/ +i +does +not +correspond +to +a +capture +group +or +if +the +capture +group +/ +/ +/ +did +not +participate +in +the +match +then +None +is +returned +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Get +the +text +of +the +match +with +a +default +of +an +empty +string +if +this +/ +/ +/ +group +didn +' +t +participate +in +the +match +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +bytes +: +: +Regex +; +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +[ +a +- +z +] ++ +( +? +: +( +[ +0 +- +9 +] ++ +) +| +( +[ +A +- +Z +] ++ +) +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +caps += +re +. +captures +( +b +" +abc123 +" +) +. +unwrap +( +) +; +/ +/ +/ +/ +/ +/ +let +text1 += +caps +. +get +( +1 +) +. +map_or +( +& +b +" +" +[ +. +. +] +| +m +| +m +. +as_bytes +( +) +) +; +/ +/ +/ +let +text2 += +caps +. +get +( +2 +) +. +map_or +( +& +b +" +" +[ +. +. +] +| +m +| +m +. +as_bytes +( +) +) +; +/ +/ +/ +assert_eq +! +( +text1 +& +b +" +123 +" +[ +. +. +] +) +; +/ +/ +/ +assert_eq +! +( +text2 +& +b +" +" +[ +. +. +] +) +; +/ +/ +/ +pub +fn +get +( +& +self +i +: +usize +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +locs +. +pos +( +i +) +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +self +. +text +s +e +) +) +} +/ +/ +/ +Returns +the +match +for +the +capture +group +named +name +. +If +name +isn +' +t +a +/ +/ +/ +valid +capture +group +or +didn +' +t +match +anything +then +None +is +returned +. +pub +fn +name +( +& +self +name +: +& +str +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +named_groups +. +get +( +name +) +. +and_then +( +| +& +i +| +self +. +get +( +i +) +) +} +/ +/ +/ +An +iterator +that +yields +all +capturing +matches +in +the +order +in +which +/ +/ +/ +they +appear +in +the +regex +. +If +a +particular +capture +group +didn +' +t +/ +/ +/ +participate +in +the +match +then +None +is +yielded +for +that +capture +. +/ +/ +/ +/ +/ +/ +The +first +match +always +corresponds +to +the +overall +match +of +the +regex +. +pub +fn +iter +< +' +c +> +( +& +' +c +self +) +- +> +SubCaptureMatches +< +' +c +' +t +> +{ +SubCaptureMatches +{ +caps +: +self +it +: +self +. +locs +. +iter +( +) +} +} +/ +/ +/ +Expands +all +instances +of +name +in +replacement +to +the +corresponding +/ +/ +/ +capture +group +name +and +writes +them +to +the +dst +buffer +given +. +/ +/ +/ +/ +/ +/ +name +may +be +an +integer +corresponding +to +the +index +of +the +capture +/ +/ +/ +group +( +counted +by +order +of +opening +parenthesis +where +0 +is +the +/ +/ +/ +entire +match +) +or +it +can +be +a +name +( +consisting +of +letters +digits +or +/ +/ +/ +underscores +) +corresponding +to +a +named +capture +group +. +/ +/ +/ +/ +/ +/ +If +name +isn +' +t +a +valid +capture +group +( +whether +the +name +doesn +' +t +exist +/ +/ +/ +or +isn +' +t +a +valid +index +) +then +it +is +replaced +with +the +empty +string +. +/ +/ +/ +/ +/ +/ +The +longest +possible +name +consisting +of +the +characters +[ +_0 +- +9A +- +Za +- +z +] +/ +/ +/ +is +used +. +e +. +g +. +1a +looks +up +the +capture +group +named +1a +and +not +the +/ +/ +/ +capture +group +at +index +1 +. +To +exert +more +precise +control +over +the +/ +/ +/ +name +or +to +refer +to +a +capture +group +name +that +uses +characters +outside +/ +/ +/ +of +[ +_0 +- +9A +- +Za +- +z +] +use +braces +e +. +g +. +{ +1 +} +a +or +{ +foo +[ +bar +] +. +baz +} +. +When +/ +/ +/ +using +braces +any +sequence +of +valid +UTF +- +8 +bytes +is +permitted +. +If +the +/ +/ +/ +sequence +does +not +refer +to +a +capture +group +name +in +the +corresponding +/ +/ +/ +regex +then +it +is +replaced +with +an +empty +string +. +/ +/ +/ +/ +/ +/ +To +write +a +literal +use +. +pub +fn +expand +( +& +self +replacement +: +& +[ +u8 +] +dst +: +& +mut +Vec +< +u8 +> +) +{ +expand_bytes +( +self +replacement +dst +) +} +/ +/ +/ +Returns +the +total +number +of +capture +groups +( +even +if +they +didn +' +t +match +) +. +/ +/ +/ +/ +/ +/ +This +is +always +at +least +1 +since +every +regex +has +at +least +one +capture +/ +/ +/ +group +that +corresponds +to +the +full +match +. +# +[ +inline +] +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +locs +. +len +( +) +} +} +impl +< +' +t +> +fmt +: +: +Debug +for +Captures +< +' +t +> +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +f +. +debug_tuple +( +" +Captures +" +) +. +field +( +& +CapturesDebug +( +self +) +) +. +finish +( +) +} +} +struct +CapturesDebug +< +' +c +' +t +> +( +& +' +c +Captures +< +' +t +> +) +; +impl +< +' +c +' +t +> +fmt +: +: +Debug +for +CapturesDebug +< +' +c +' +t +> +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +fn +escape_bytes +( +bytes +: +& +[ +u8 +] +) +- +> +String +{ +let +mut +s += +String +: +: +new +( +) +; +for +& +b +in +bytes +{ +s +. +push_str +( +& +escape_byte +( +b +) +) +; +} +s +} +fn +escape_byte +( +byte +: +u8 +) +- +> +String +{ +use +std +: +: +ascii +: +: +escape_default +; +let +escaped +: +Vec +< +u8 +> += +escape_default +( +byte +) +. +collect +( +) +; +String +: +: +from_utf8_lossy +( +& +escaped +) +. +into_owned +( +) +} +/ +/ +We +' +d +like +to +show +something +nice +here +even +if +it +means +an +/ +/ +allocation +to +build +a +reverse +index +. +let +slot_to_name +: +HashMap +< +& +usize +& +String +> += +self +. +0 +. +named_groups +. +iter +( +) +. +map +( +| +( +a +b +) +| +( +b +a +) +) +. +collect +( +) +; +let +mut +map += +f +. +debug_map +( +) +; +for +( +slot +m +) +in +self +. +0 +. +locs +. +iter +( +) +. +enumerate +( +) +{ +let +m += +m +. +map +( +| +( +s +e +) +| +escape_bytes +( +& +self +. +0 +. +text +[ +s +. +. +e +] +) +) +; +if +let +Some +( +name +) += +slot_to_name +. +get +( +& +slot +) +{ +map +. +entry +( +& +name +& +m +) +; +} +else +{ +map +. +entry +( +& +slot +& +m +) +; +} +} +map +. +finish +( +) +} +} +/ +/ +/ +Get +a +group +by +index +. +/ +/ +/ +/ +/ +/ +' +t +is +the +lifetime +of +the +matched +text +. +/ +/ +/ +/ +/ +/ +The +text +can +' +t +outlive +the +Captures +object +if +this +method +is +/ +/ +/ +used +because +of +how +Index +is +defined +( +normally +a +[ +i +] +is +part +/ +/ +/ +of +a +and +can +' +t +outlive +it +) +; +to +do +that +use +get +( +) +instead +. +/ +/ +/ +/ +/ +/ +# +Panics +/ +/ +/ +/ +/ +/ +If +there +is +no +group +at +the +given +index +. +impl +< +' +t +> +Index +< +usize +> +for +Captures +< +' +t +> +{ +type +Output += +[ +u8 +] +; +fn +index +( +& +self +i +: +usize +) +- +> +& +[ +u8 +] +{ +self +. +get +( +i +) +. +map +( +| +m +| +m +. +as_bytes +( +) +) +. +unwrap_or_else +( +| +| +panic +! +( +" +no +group +at +index +' +{ +} +' +" +i +) +) +} +} +/ +/ +/ +Get +a +group +by +name +. +/ +/ +/ +/ +/ +/ +' +t +is +the +lifetime +of +the +matched +text +and +' +i +is +the +lifetime +/ +/ +/ +of +the +group +name +( +the +index +) +. +/ +/ +/ +/ +/ +/ +The +text +can +' +t +outlive +the +Captures +object +if +this +method +is +/ +/ +/ +used +because +of +how +Index +is +defined +( +normally +a +[ +i +] +is +part +/ +/ +/ +of +a +and +can +' +t +outlive +it +) +; +to +do +that +use +name +instead +. +/ +/ +/ +/ +/ +/ +# +Panics +/ +/ +/ +/ +/ +/ +If +there +is +no +group +named +by +the +given +value +. +impl +< +' +t +' +i +> +Index +< +& +' +i +str +> +for +Captures +< +' +t +> +{ +type +Output += +[ +u8 +] +; +fn +index +< +' +a +> +( +& +' +a +self +name +: +& +' +i +str +) +- +> +& +' +a +[ +u8 +] +{ +self +. +name +( +name +) +. +map +( +| +m +| +m +. +as_bytes +( +) +) +. +unwrap_or_else +( +| +| +panic +! +( +" +no +group +named +' +{ +} +' +" +name +) +) +} +} +/ +/ +/ +An +iterator +that +yields +all +capturing +matches +in +the +order +in +which +they +/ +/ +/ +appear +in +the +regex +. +/ +/ +/ +/ +/ +/ +If +a +particular +capture +group +didn +' +t +participate +in +the +match +then +None +/ +/ +/ +is +yielded +for +that +capture +. +The +first +match +always +corresponds +to +the +/ +/ +/ +overall +match +of +the +regex +. +/ +/ +/ +/ +/ +/ +The +lifetime +' +c +corresponds +to +the +lifetime +of +the +Captures +value +and +/ +/ +/ +the +lifetime +' +t +corresponds +to +the +originally +matched +text +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +SubCaptureMatches +< +' +c +' +t +> +{ +caps +: +& +' +c +Captures +< +' +t +> +it +: +SubCapturesPosIter +< +' +c +> +} +impl +< +' +c +' +t +> +Iterator +for +SubCaptureMatches +< +' +c +' +t +> +{ +type +Item += +Option +< +Match +< +' +t +> +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Option +< +Match +< +' +t +> +> +> +{ +self +. +it +. +next +( +) +. +map +( +| +cap +| +cap +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +self +. +caps +. +text +s +e +) +) +) +} +} +impl +< +' +c +' +t +> +FusedIterator +for +SubCaptureMatches +< +' +c +' +t +> +{ +} +/ +/ +/ +Replacer +describes +types +that +can +be +used +to +replace +matches +in +a +byte +/ +/ +/ +string +. +/ +/ +/ +/ +/ +/ +In +general +users +of +this +crate +shouldn +' +t +need +to +implement +this +trait +/ +/ +/ +since +implementations +are +already +provided +for +& +[ +u8 +] +along +with +other +/ +/ +/ +variants +of +bytes +types +and +FnMut +( +& +Captures +) +- +> +Vec +< +u8 +> +( +or +any +/ +/ +/ +FnMut +( +& +Captures +) +- +> +T +where +T +: +AsRef +< +[ +u8 +] +> +) +which +covers +most +use +cases +. +pub +trait +Replacer +{ +/ +/ +/ +Appends +text +to +dst +to +replace +the +current +match +. +/ +/ +/ +/ +/ +/ +The +current +match +is +represented +by +caps +which +is +guaranteed +to +/ +/ +/ +have +a +match +at +capture +group +0 +. +/ +/ +/ +/ +/ +/ +For +example +a +no +- +op +replacement +would +be +/ +/ +/ +dst +. +extend +( +& +caps +[ +0 +] +) +. +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +; +/ +/ +/ +Return +a +fixed +unchanging +replacement +byte +string +. +/ +/ +/ +/ +/ +/ +When +doing +replacements +if +access +to +Captures +is +not +needed +( +e +. +g +. +/ +/ +/ +the +replacement +byte +string +does +not +need +expansion +) +then +it +can +/ +/ +/ +be +beneficial +to +avoid +finding +sub +- +captures +. +/ +/ +/ +/ +/ +/ +In +general +this +is +called +once +for +every +call +to +replacen +. +fn +no_expansion +< +' +r +> +( +& +' +r +mut +self +) +- +> +Option +< +Cow +< +' +r +[ +u8 +] +> +> +{ +None +} +/ +/ +/ +Return +a +Replacer +that +borrows +and +wraps +this +Replacer +. +/ +/ +/ +/ +/ +/ +This +is +useful +when +you +want +to +take +a +generic +Replacer +( +which +might +/ +/ +/ +not +be +cloneable +) +and +use +it +without +consuming +it +so +it +can +be +used +/ +/ +/ +more +than +once +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +/ +/ +/ +use +regex +: +: +bytes +: +: +{ +Regex +Replacer +} +; +/ +/ +/ +/ +/ +/ +fn +replace_all_twice +< +R +: +Replacer +> +( +/ +/ +/ +re +: +Regex +/ +/ +/ +src +: +& +[ +u8 +] +/ +/ +/ +mut +rep +: +R +/ +/ +/ +) +- +> +Vec +< +u8 +> +{ +/ +/ +/ +let +dst += +re +. +replace_all +( +src +rep +. +by_ref +( +) +) +; +/ +/ +/ +let +dst += +re +. +replace_all +( +& +dst +rep +. +by_ref +( +) +) +; +/ +/ +/ +dst +. +into_owned +( +) +/ +/ +/ +} +/ +/ +/ +fn +by_ref +< +' +r +> +( +& +' +r +mut +self +) +- +> +ReplacerRef +< +' +r +Self +> +{ +ReplacerRef +( +self +) +} +} +/ +/ +/ +By +- +reference +adaptor +for +a +Replacer +/ +/ +/ +/ +/ +/ +Returned +by +[ +Replacer +: +: +by_ref +] +( +trait +. +Replacer +. +html +# +method +. +by_ref +) +. +# +[ +derive +( +Debug +) +] +pub +struct +ReplacerRef +< +' +a +R +: +? +Sized +> +( +& +' +a +mut +R +) +; +impl +< +' +a +R +: +Replacer ++ +? +Sized ++ +' +a +> +Replacer +for +ReplacerRef +< +' +a +R +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +{ +self +. +0 +. +replace_append +( +caps +dst +) +} +fn +no_expansion +< +' +r +> +( +& +' +r +mut +self +) +- +> +Option +< +Cow +< +' +r +[ +u8 +] +> +> +{ +self +. +0 +. +no_expansion +( +) +} +} +impl +< +' +a +> +Replacer +for +& +' +a +[ +u8 +] +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +{ +caps +. +expand +( +* +self +dst +) +; +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +[ +u8 +] +> +> +{ +no_expansion +( +self +) +} +} +impl +< +' +a +> +Replacer +for +& +' +a +Vec +< +u8 +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +{ +caps +. +expand +( +* +self +dst +) +; +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +[ +u8 +] +> +> +{ +no_expansion +( +self +) +} +} +impl +Replacer +for +Vec +< +u8 +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +{ +caps +. +expand +( +self +dst +) +; +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +[ +u8 +] +> +> +{ +no_expansion +( +self +) +} +} +impl +< +' +a +> +Replacer +for +Cow +< +' +a +[ +u8 +] +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +{ +caps +. +expand +( +self +. +as_ref +( +) +dst +) +; +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +[ +u8 +] +> +> +{ +no_expansion +( +self +) +} +} +impl +< +' +a +> +Replacer +for +& +' +a +Cow +< +' +a +[ +u8 +] +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +{ +caps +. +expand +( +self +. +as_ref +( +) +dst +) +; +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +[ +u8 +] +> +> +{ +no_expansion +( +self +) +} +} +fn +no_expansion +< +T +: +AsRef +< +[ +u8 +] +> +> +( +t +: +& +T +) +- +> +Option +< +Cow +< +' +_ +[ +u8 +] +> +> +{ +let +s += +t +. +as_ref +( +) +; +match +find_byte +( +b +' +' +s +) +{ +Some +( +_ +) += +> +None +None += +> +Some +( +Cow +: +: +Borrowed +( +s +) +) +} +} +impl +< +F +T +> +Replacer +for +F +where +F +: +FnMut +( +& +Captures +< +' +_ +> +) +- +> +T +T +: +AsRef +< +[ +u8 +] +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +{ +dst +. +extend_from_slice +( +( +* +self +) +( +caps +) +. +as_ref +( +) +) +; +} +} +/ +/ +/ +NoExpand +indicates +literal +byte +string +replacement +. +/ +/ +/ +/ +/ +/ +It +can +be +used +with +replace +and +replace_all +to +do +a +literal +byte +string +/ +/ +/ +replacement +without +expanding +name +to +their +corresponding +capture +/ +/ +/ +groups +. +This +can +be +both +convenient +( +to +avoid +escaping +for +example +) +/ +/ +/ +and +performant +( +since +capture +groups +don +' +t +need +to +be +found +) +. +/ +/ +/ +/ +/ +/ +' +t +is +the +lifetime +of +the +literal +text +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +NoExpand +< +' +t +> +( +pub +& +' +t +[ +u8 +] +) +; +impl +< +' +t +> +Replacer +for +NoExpand +< +' +t +> +{ +fn +replace_append +( +& +mut +self +_ +: +& +Captures +< +' +_ +> +dst +: +& +mut +Vec +< +u8 +> +) +{ +dst +. +extend_from_slice +( +self +. +0 +) +; +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +[ +u8 +] +> +> +{ +Some +( +Cow +: +: +Borrowed +( +self +. +0 +) +) +} +} diff --git a/third_party/rust/regex/src/regexset/string.rs b/third_party/rust/regex/src/re_set.rs similarity index 65% rename from third_party/rust/regex/src/regexset/string.rs rename to third_party/rust/regex/src/re_set.rs index 855f3c4ebccd7..0696a9b40f673 100644 --- a/third_party/rust/regex/src/regexset/string.rs +++ b/third_party/rust/regex/src/re_set.rs @@ -1,45 +1,115 @@ +macro_rules +! +define_set +{ +( +name +: +ident +builder_mod +: +ident +text_ty +: +ty +as_bytes +: +expr +( +# +[ +doc_regexset_example +: +meta +] +) +* +) += +> +{ +pub +mod +name +{ use -alloc +std : : -string +fmt +; +use +std : : -String +iter ; use -regex_automata +std : : -{ -meta -Input -PatternID -PatternSet -PatternSetIter -} +slice +; +use +std +: +: +vec ; use crate : : -{ +error +: +: Error +; +use +crate +: +: +exec +: +: +Exec +; +use +crate +: +: +re_builder +: +: +builder_mod +: +: RegexSetBuilder -} +; +use +crate +: +: +re_trait +: +: +RegularExpression ; / / / Match multiple +( possibly overlapping -regexes +) +regular +expressions in a single -search +scan . / / @@ -55,7 +125,7 @@ to the union of -zero +two or more regular @@ -71,9 +141,8 @@ regex set will match -a -haystack -when +text +where at least one @@ -83,7 +152,8 @@ its / / constituent -regexes +regular +expressions matches . A @@ -93,11 +163,11 @@ as its formulated here -provides -a / / / +provides +a touch more power @@ -110,12 +180,12 @@ report which * regular -expressions -in -the / / / +expressions +in +the set match . @@ -126,13 +196,13 @@ the key difference between +/ +/ +/ regex sets and a -/ -/ -/ single Regex with @@ -141,13 +211,13 @@ alternates since only one +/ +/ +/ alternate can match at -/ -/ -/ a time . @@ -225,7 +295,7 @@ regexes then searching the -haystack +text / / / @@ -265,7 +335,7 @@ two searches over the -haystack +text . The key @@ -276,11 +346,11 @@ a regex set is +that +it / / / -that -it will report the @@ -293,12 +363,12 @@ single pass through the +text +* +. / / / -haystack -* -. If one has @@ -310,13 +380,13 @@ regexes to match repeatedly -/ -/ -/ ( like a URL +/ +/ +/ router for a @@ -329,16 +399,14 @@ user agent matcher ) -/ -/ -/ then a regex +/ +/ +/ set -* can -* realize huge performance @@ -351,122 +419,332 @@ gains / / # -Limitations +Example / / / / / / -Regex -sets -are -limited -to -answering +This +shows +how the -following +above two -questions -: -/ -/ -/ +regexes +( +for +matching +email +addresses +and / / / -1 -. -Does -any -regex -in -the -set -match -? +domains +) +might +work +: / / / -2 -. -If -so -which -regexes -in -the -set -match -? +( +# +[ +doc_regexset_example +] +) +* / / / / / / -As -with -the -main -[ -Regex -] -[ -crate -: -: -Regex -] -type +Note +that it -is -cheaper +would +be +possible to -ask -( -1 -) +adapt +the +above +example +to +using +Regex / / / -instead -of -( -2 -) -since -the -matching -engines -can -stop -after -the -first -match +with +an +expression +like +: / / / -is -found -. / / / +text / / / -You -cannot -directly -extract +( +? +P +< +email +> [ -Match +a +- +z ] -[ -crate -: ++ +( +? +P +< +email_domain +> +[ +a +- +z +] ++ +[ +. +] +( +com +| +org +| +net +) +) +) +| +( +? +P +< +domain +> +[ +a +- +z +] ++ +[ +. +] +( +com +| +org +| +net +) +) +/ +/ +/ +/ +/ +/ +/ +/ +/ +After +a +match +one +could +then +inspect +the +capture +groups +to +figure +out +/ +/ +/ +which +alternates +matched +. +The +problem +is +that +it +is +hard +to +make +this +/ +/ +/ +approach +scale +when +there +are +many +regexes +since +the +overlap +between +each +/ +/ +/ +alternate +isn +' +t +always +obvious +to +reason +about +. +/ +/ +/ +/ +/ +/ +# +Limitations +/ +/ +/ +/ +/ +/ +Regex +sets +are +limited +to +answering +the +following +two +questions +: +/ +/ +/ +/ +/ +/ +1 +. +Does +any +regex +in +the +set +match +? +/ +/ +/ +2 +. +If +so +which +regexes +in +the +set +match +? +/ +/ +/ +/ +/ +/ +As +with +the +main +[ +Regex +] +[ +crate +: +: +Regex +] +type +it +is +cheaper +to +ask +( +1 +) +/ +/ +/ +instead +of +( +2 +) +since +the +matching +engines +can +stop +after +the +first +match +/ +/ +/ +is +found +. +/ +/ +/ +/ +/ +/ +You +cannot +directly +extract +[ +Match +] +[ +crate +: : Match ] @@ -517,7 +795,7 @@ scan the exact same -haystack +input a second time @@ -536,6 +814,7 @@ patterns / / / +rust / / / @@ -585,7 +864,7 @@ string / / let -hay +text = " barfoo @@ -619,6 +898,7 @@ RegexSet : new ( +& patterns ) . @@ -648,16 +928,10 @@ _ > = set -/ -/ -/ . patterns ( ) -/ -/ -/ . iter ( @@ -730,17 +1004,11 @@ str > = set -/ -/ -/ . matches ( -hay +text ) -/ -/ -/ . into_iter ( @@ -773,12 +1041,12 @@ pattern map ( | -index +match_idx | & regexes [ -index +match_idx ] ) / @@ -799,15 +1067,15 @@ then have to search -the / / / / / +the exact same -haystack +text again using our @@ -823,13 +1091,13 @@ pattern map ( | -re +pat | -re +pat . find ( -hay +text ) . unwrap @@ -878,7 +1146,7 @@ they appear in the -haystack +input . / / @@ -934,9 +1202,7 @@ search takes O ( -m -* -n +mn ) time where @@ -962,60 +1228,87 @@ the length of the -haystack +search +text . +# +[ +derive +( +Clone +) +] +pub +struct +RegexSet +( +Exec +) +; +impl +RegexSet +{ / / / -/ -/ -/ -# -Trait -implementations +Create +a +new +regex +set +with +the +given +regular +expressions +. / / / / / / -The -Default -trait +This +takes +an +iterator +of +S +where +S is -implemented -for -RegexSet -. -The -default -value +something +that +can +produce / / / -is -an -empty -set +a +& +str . -An -empty -set -can -also -be -explicitly -constructed -via +If +any +of +the +strings +in +the +iterator +are +not +valid +regular / / / -[ -RegexSet -: -: -empty -] +expressions +then +an +error +is +returned . / / @@ -1031,26 +1324,16 @@ Example / / / -This -shows -how -the -above -two -regexes -( -for -matching -email -addresses -and -/ -/ -/ -domains -) -might -work +Create +a +new +regex +set +from +an +iterator +of +strings : / / @@ -1058,9 +1341,11 @@ work / / / +rust / / / +# use regex : @@ -1070,9 +1355,6 @@ RegexSet / / / -/ -/ -/ let set = @@ -1083,57 +1365,18 @@ new ( & [ -/ -/ -/ r " -[ -a -- -z -] -+ -[ -a -- -z -] -+ \ -. -( -com -| -org -| -net -) +w ++ " -/ -/ -/ r " -[ -a -- -z -] -+ \ -. -( -com -| -org -| -net -) +d ++ " -/ -/ -/ ] ) . @@ -1144,23 +1387,6 @@ unwrap / / / -/ -/ -/ -/ -/ -Ask -whether -any -regexes -in -the -set -match -. -/ -/ -/ assert ! ( @@ -1170,9 +1396,6 @@ is_match ( " foo -example -. -com " ) ) @@ -1180,504 +1403,338 @@ com / / / +pub +fn +new +< +I +S +> +( +exprs +: +I +) +- +> +Result +< +RegexSet +Error +> +where +S +: +AsRef +< +str +> +I +: +IntoIterator +< +Item += +S +> +{ +RegexSetBuilder +: +: +new +( +exprs +) +. +build +( +) +} / / / +Create +a +new +empty +regex +set +. / / -Identify -which -regexes -in -the -set -match -. / / / -let -matches -: -Vec -< -_ -> -= -set -. -matches -( -" -foo -example -. -com -" -) -. -into_iter -( -) -. -collect -( -) -; -/ / +# +Example / -assert_eq -! -( -vec -! -[ -0 -1 -] -matches -) -; / / / / / +rust / / / -Try -again -but -with -a -haystack -that -only -matches -one -of -the -regexes -. +# +use +regex +: +: +RegexSet +; / / / let -matches -: -Vec -< -_ -> -= set -. -matches -( -" -example -. -com -" -) -. -into_iter -( -) -. -collect += +RegexSet +: +: +empty ( ) ; / / / -assert_eq +assert ! ( -vec -! -[ -1 -] -matches -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Try -again -but -with -a -haystack -that -doesn -' -t -match -any -regex -in -the set . +is_empty +( +) +) +; / / / -let -matches -: -Vec -< -_ +pub +fn +empty +( +) +- > -= -set -. -matches +RegexSet +{ +RegexSetBuilder +: +: +new ( +& +[ " -example " +; +0 +] ) . -into_iter +build ( ) . -collect +unwrap ( ) -; +} / / / -assert -! -( +Returns +true +if +and +only +if +one +of +the +regexes +in +this +set matches -. -is_empty -( -) -) -; / / / +the +text +given +. / / / / / / -Note -that -it -would +This +method +should be -possible -to -adapt -the -above -example +preferred +if +you +only +need to -using -Regex -/ -/ -/ -with -an -expression -like -: +test +whether +any / / / +of +the +regexes +in +the +set +should +match +but +don +' +t +care +about +* +which +* / / / -text +regexes +matched +. +This +is +because +the +underlying +matching +engine +will / / / -( -? -P -< -email -> -[ -a -- -z -] -+ -( -? -P -< -email_domain -> -[ -a -- -z -] -+ -[ -. -] -( -com -| -org -| -net -) -) -) -| -( -? -P -< -domain -> -[ -a -- -z -] -+ -[ -. -] -( -com -| -org -| -net -) -) +quit +immediately +after +seeing +the +first +match +instead +of +continuing +to / / / +find +all +matches +. / / / / / / -After -a -match -one -could -then -inspect +Note +that +as +with +searches +using +Regex the -capture -groups -to -figure -out +expression +is +unanchored / / / -which -alternates -matched +by +default . -The -problem -is -that -it +That is -hard -to -make -this +if +the +regex +does +not +start +with +^ +or +\ +A +or / / / -approach -scale -when -there -are -many -regexes -since +end +with +or +\ +z +then +it +is +permitted +to +match +anywhere +in the -overlap -between -each / / / -alternate -isn -' -t -always -obvious -to -reason -about +text . -# -[ -derive -( -Clone -) -] -pub -struct -RegexSet -{ -pub -( -crate -) -meta -: -meta -: -: -Regex -pub -( -crate -) -patterns -: -alloc -: -: -sync -: -: -Arc -< -[ -String -] -> -} -impl -RegexSet -{ / / / -Create -a -new -regex -set -with -the -given -regular -expressions -. / / / +# +Example / / / -This -takes -an -iterator -of -S -where -S -is -something -that -can -produce / / / +Tests +whether a -& -str -. -If -any -of -the -strings -in -the -iterator -are -not -valid -regular +set +matches +some +text +: / / / -expressions -then -an -error -is -returned -. / / / +rust / / / # -Example -/ -/ -/ -/ -/ -/ -Create -a -new -regex -set -from -an -iterator -of -strings -: -/ -/ -/ -/ -/ -/ -/ -/ -/ use regex : @@ -1687,9 +1744,6 @@ RegexSet / / / -/ -/ -/ let set = @@ -1698,6 +1752,7 @@ RegexSet : new ( +& [ r " @@ -1737,62 +1792,63 @@ foo / / / +assert +! +( +! +set +. +is_match +( +" +" +) +) +; +/ +/ +/ pub fn -new -< -I -S -> +is_match ( -exprs +& +self +text : -I +text_ty ) - > -Result -< -RegexSet -Error -> -where -S -: -AsRef -< -str -> -I -: -IntoIterator -< -Item -= -S -> +bool { -RegexSetBuilder -: -: -new -( -exprs -) +self . -build +is_match_at ( +text +0 ) } / / / -Create -a -new -empty -regex -set +Returns +the +same +as +is_match +but +starts +the +search +at +the +given +/ +/ +/ +offset . / / @@ -1800,49 +1856,99 @@ set / / / -An -empty -regex -never -matches -anything -. +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding / / / +context +into +consideration +. +For +example +the +\ +A +anchor +can +only / / / -This -is -a -convenience -function -for -RegexSet +match +when +start += += +0 +. +# +[ +doc +( +hidden +) +] +pub +fn +is_match_at +( +& +self +text : +text_ty +start : -new +usize +) +- +> +bool +{ +self +. +0 +. +searcher ( -[ -] ) -but -doesn -' -t +. +is_match_at +( +as_bytes +( +text +) +start +) +} / / / -require -one -to -specify +Returns the -type +set of +regular +expressions +that +match +in the -input +given +text . / / @@ -1850,216 +1956,65 @@ input / / / -# -Example -/ -/ -/ +The +set +returned +contains +the +index +of +each +regular +expression +that / / / +matches +in +the +given +text +. +The +index +is +in +correspondence +with +the / / / -use -regex -: -: +order +of +regular +expressions +given +to RegexSet -; +' +s +constructor +. / / / / / / -let +The set -= -RegexSet -: -: -empty -( -) -; -/ -/ -/ -assert -! -( -set -. -is_empty -( -) -) -; -/ -/ -/ -/ -/ -an -empty -set -matches -nothing -/ -/ -/ -assert -! -( -! -set -. -is_match -( -" -" -) -) -; -/ -/ -/ -pub -fn -empty -( -) -- -> -RegexSet -{ -let -empty -: -[ -& -str -; -0 -] -= -[ -] -; -RegexSetBuilder -: -: -new -( -empty -) -. -build -( -) -. -unwrap -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -one -of -the -regexes -in -this -set -matches -/ -/ -/ -the -haystack -given -. -/ -/ -/ -/ -/ -/ -This -method -should +can +also be -preferred -if -you -only -need +used to -test -whether -any -/ -/ -/ -of -the -regexes -in +iterate +over the -set -should -match -but -don -' -t -care -about -* -which -* -/ -/ -/ -regexes matched -. -This -is -because -the -underlying -matching -engine -will -/ -/ -/ -quit -immediately -after -seeing -the -first -match -instead -of -continuing -to -/ -/ -/ -find -all -matches +indices . / / @@ -2073,22 +2028,14 @@ as with searches using -[ -Regex -] -( -crate -: -: Regex -) the -/ -/ -/ expression is unanchored +/ +/ +/ by default . @@ -2099,9 +2046,6 @@ the regex does not -/ -/ -/ start with ^ @@ -2109,6 +2053,9 @@ or \ A or +/ +/ +/ end with or @@ -2118,15 +2065,15 @@ then it is permitted -/ -/ -/ to match anywhere in the -haystack +/ +/ +/ +text . / / @@ -2143,14 +2090,13 @@ Example / / Tests -whether -a -set -matches -somewhere -in -a -haystack +which +regular +expressions +match +the +given +text : / / @@ -2158,9 +2104,11 @@ haystack / / / +rust / / / +# use regex : @@ -2170,9 +2118,6 @@ RegexSet / / / -/ -/ -/ let set = @@ -2181,118 +2126,270 @@ RegexSet : new ( +& [ +/ +/ +/ r " \ w + " +/ +/ +/ r " \ d + " -] -) -. -unwrap -( -) -; / / / -assert -! -( -set -. -is_match -( +r " -foo +\ +pL ++ " -) -) -; / / / -assert -! -( -! +r +" +foo +" +/ +/ +/ +r +" +bar +" +/ +/ +/ +r +" +barfoo +" +/ +/ +/ +r +" +foobar +" +/ +/ +/ +] +) +. +unwrap +( +) +; +/ +/ +/ +let +matches +: +Vec +< +_ +> += set . -is_match +matches ( " +foobar " ) +. +into_iter +( +) +. +collect +( ) ; / / / -# +assert_eq +! +( +matches +vec +! [ -inline +0 +2 +3 +4 +6 ] +) +; +/ +/ +/ +/ +/ +/ +/ +/ +You +can +also +test +whether +a +particular +regex +matched +: +/ +/ +/ +let +matches += +set +. +matches +( +" +foobar +" +) +; +/ +/ +/ +assert +! +( +! +matches +. +matched +( +5 +) +) +; +/ +/ +/ +assert +! +( +matches +. +matched +( +6 +) +) +; +/ +/ +/ pub fn -is_match +matches ( & self -haystack +text : -& -str +text_ty ) - > -bool +SetMatches { +let +mut +matches += +vec +! +[ +false +; self . -is_match_at +0 +. +regex_strings +( +) +. +len +( +) +] +; +let +any += +self +. +read_matches_at ( -haystack +& +mut +matches +text 0 ) +; +SetMatches +{ +matched_any +: +any +matches +: +matches +} } / / / Returns -true -if -and -only -if -one -of the -regexes -in -this -set +same +as matches +but +starts the +search +at +the +given / / / -haystack -given -with +offset +and +stores the -search -starting -at +matches +into the -offset +slice given . / @@ -2344,112 +2441,253 @@ start / / / -# -Panics +matches +must +have +a +length +that +is +at +least +the +number +of +regexes / / / +in +this +set +. / / / -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. / / / +This +method +returns +true +if +and +only +if +at +least +one +member +of / / / +matches +is +true +after +executing +the +set +against +text +. # -Example +[ +doc +( +hidden +) +] +pub +fn +read_matches_at +( +& +self +matches +: +& +mut +[ +bool +] +text +: +text_ty +start +: +usize +) +- +> +bool +{ +self +. +0 +. +searcher +( +) +. +many_matches_at +( +matches +as_bytes +( +text +) +start +) +} +/ +/ +/ +Returns +the +total +number +of +regular +expressions +in +this +set +. +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +0 +. +regex_strings +( +) +. +len +( +) +} / / / +Returns +true +if +this +set +contains +no +regular +expressions +. +pub +fn +is_empty +( +& +self +) +- +> +bool +{ +self +. +0 +. +regex_strings +( +) +. +is_empty +( +) +} / / / -This -example -shows +Returns the -significance -of -start +patterns +that +this +set +will +match +on . -Namely -consider -a / / / -haystack -foobar -and -a -desire -to -execute -a -search -starting -at -offset / / / -3 -. -You -could -search -a -substring -explicitly -but -then +This +function +can +be +used +to +determine the -look -- -around +pattern +for +a +match +. +The / / / -assertions -won -' -t -work -correctly -. -Instead -you -can -use -this -method +slice +returned +has +exactly +as +many +patterns +givens to +this +regex +set / / / -specify +and the -start -position +order of -a -search +the +slice +is +the +same +as +the +order +of +the +patterns +/ +/ +/ +provided +to +the +set . / / @@ -2457,9 +2695,19 @@ search / / / +# +Example +/ +/ +/ / / / +rust +/ +/ +/ +# use regex : @@ -2469,9 +2717,6 @@ RegexSet / / / -/ -/ -/ let set = @@ -2480,176 +2725,266 @@ RegexSet : new ( +& [ +/ +/ +/ r " \ -bbar -\ -b +w ++ " +/ +/ +/ r " -( -? -m -) -^ -bar +\ +d ++ " -] -) -. -unwrap -( -) -; / / / -let -hay -= +r " -foobar +\ +pL ++ " -; / / / +r +" +foo +" / / -We -get -a -match -here -but -it -' -s -probably -not -intended -. +/ +r +" +bar +" +/ +/ +/ +r +" +barfoo +" +/ +/ +/ +r +" +foobar +" / / / -assert -! -( -set -. -is_match -( -& -hay -[ -3 -. -. ] ) +. +unwrap +( ) ; / / / +let +matches +: +Vec +< +_ +> += +set +/ / / -No -match -because -the -assertions -take -the -context -into -account . +matches +( +" +foobar +" +) / / / -assert -! +. +into_iter ( -! +) +/ +/ +/ +. +map +( +| +match_idx +| +& set . -is_match_at +patterns ( -hay -3 ) +[ +match_idx +] +) +/ +/ +/ +. +collect +( ) ; / / / -# +assert_eq +! +( +matches +vec +! [ -inline +r +" +\ +w ++ +" +r +" +\ +pL ++ +" +r +" +foo +" +r +" +bar +" +r +" +foobar +" ] +) +; +/ +/ +/ pub fn -is_match_at +patterns ( & self -haystack -: -& -str -start -: -usize ) - > -bool +& +[ +String +] { self . -meta +0 . -is_match -( -Input -: -: -new +regex_strings ( -haystack ) +} +} +/ +/ +/ +A +set +of +matches +returned +by +a +regex +set . -span +# +[ +derive ( -start -. -. -haystack +Clone +Debug +) +] +pub +struct +SetMatches +{ +matched_any +: +bool +matches +: +Vec +< +bool +> +} +impl +SetMatches +{ +/ +/ +/ +Whether +this +set +contains +any +matches . -len +pub +fn +matched_any ( +& +self ) -) -) +- +> +bool +{ +self +. +matched_any } / / / -Returns +Whether the -set -of -regexes -that -match -in +regex +at the given -haystack +index +matched . / / @@ -2658,418 +2993,311 @@ haystack / / The -set -returned -contains -the index -of -each +for +a regex -that -matches -in +is +determined +by +its +insertion +order +upon +the / / / -the -given -haystack -. -The -index -is -in -correspondence -with -the -order +initial +construction of +a +RegexSet +starting +at +0 +. / / / -regular -expressions -given -to -RegexSet -' -s -constructor -. / / / +# +Panics / / / -The -set -can -also -be -used -to -iterate -over -the -matched -indices -. -The -order / / / -of -iteration +If +regex_index is -always -ascending -with -respect +greater +than +or +equal to -the -matching -indices +self . -/ -/ -/ -/ -/ -/ -Note -that -as -with -searches -using -[ -Regex -] +len ( -crate -: +) +. +pub +fn +matched +( +& +self +regex_index : -Regex +usize ) -the -/ -/ -/ -expression -is -unanchored -by -default +- +> +bool +{ +self . -That -is -if -the -regex -does -not -/ -/ -/ -start -with -^ -or -\ -A -or -end -with -or -\ -z -then -it -is -permitted +matches +[ +regex_index +] +} / / / -to -match -anywhere +The +total +number +of +regexes in the -haystack +set +that +created +these +matches . +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +matches +. +len +( +) +} / / / -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Tests -which -regular -expressions -match +Returns +an +iterator +over +indexes +in the -given -haystack -: +regex +that +matched +. / / / / / / +This +will +always +produces +matches +in +ascending +order +of +index +where / / / -use +the +index +corresponds +to +the +index +of +the regex -: -: -RegexSet -; -/ -/ -/ +that +matched +with / / / -let +respect +to +its +position +when +initially +building +the set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -\ -w -+ -" -/ -/ -/ -r -" -\ -d -+ -" -/ -/ -/ -r -" -\ -pL -+ -" -/ -/ -/ -r -" -foo -" -/ -/ -/ -r -" -bar -" -/ -/ -/ -r -" -barfoo -" -/ -/ -/ -r -" -foobar -" -/ -/ -/ -] -) -. -unwrap +. +pub +fn +iter ( +& +self ) -; -/ -/ -/ -let -matches -: -Vec +- +> +SetMatchesIter < +' _ > -= -set +{ +SetMatchesIter +( +( +& +* +self . matches -( -" -foobar -" ) . into_iter ( ) . -collect +enumerate ( ) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -0 -2 -3 -4 -6 -] ) +} +} +impl +IntoIterator +for +SetMatches +{ +type +IntoIter += +SetMatchesIntoIter ; -/ -/ -/ -/ -/ -/ -/ -/ -You -can -also -test -whether -a -particular -regex -matched -: -/ -/ -/ -let -matches +type +Item = -set -. -matches +usize +; +fn +into_iter ( -" -foobar -" +self ) -; -/ -/ -/ -assert -! +- +> +Self +: +: +IntoIter +{ +SetMatchesIntoIter ( -! +self +. matches . -matched +into_iter ( -5 -) ) -; -/ -/ -/ -assert -! -( -matches . -matched +enumerate ( -6 ) ) +} +} +impl +< +' +a +> +IntoIterator +for +& +' +a +SetMatches +{ +type +IntoIter += +SetMatchesIter +< +' +a +> +; +type +Item += +usize ; -/ -/ -/ -# -[ -inline -] -pub fn -matches +into_iter ( -& self -haystack -: -& -str ) - > -SetMatches +Self +: +: +IntoIter { self . -matches_at +iter ( -haystack -0 ) } +} / / / -Returns +An +owned +iterator +over the set of -regexes -that -match -in -the -given -haystack +matches +from +a +regex +set . / / @@ -3077,2337 +3305,22 @@ haystack / / / -The -set -returned -contains -the -index -of -each -regex -that +This +will +always +produces matches in +ascending +order +of +index +where +the / / / -the -given -haystack -. -The index -is -in -correspondence -with -the -order -of -/ -/ -/ -regular -expressions -given -to -RegexSet -' -s -constructor -. -/ -/ -/ -/ -/ -/ -The -set -can -also -be -used -to -iterate -over -the -matched -indices -. -The -order -/ -/ -/ -of -iteration -is -always -ascending -with -respect -to -the -matching -indices -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Tests -which -regular -expressions -match -the -given -haystack -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -r -" -\ -bbar -\ -b -" -r -" -( -? -m -) -^ -bar -" -] -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -foobar -" -; -/ -/ -/ -/ -/ -We -get -matches -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches -( -& -hay -[ -3 -. -. -] -) -. -into_iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -0 -1 -] -) -; -/ -/ -/ -/ -/ -No -matches -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches_at -( -hay -3 -) -. -into_iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -matches_at -( -& -self -haystack -: -& -str -start -: -usize -) -- -> -SetMatches -{ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -let -mut -patset -= -PatternSet -: -: -new -( -self -. -meta -. -pattern_len -( -) -) -; -self -. -meta -. -which_overlapping_matches -( -& -input -& -mut -patset -) -; -SetMatches -( -patset -) -} -/ -/ -/ -Returns -the -same -as -matches -but -starts -the -search -at -the -given -/ -/ -/ -offset -and -stores -the -matches -into -the -slice -given -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -matches -must -have -a -length -that -is -at -least -the -number -of -regexes -/ -/ -/ -in -this -set -. -/ -/ -/ -/ -/ -/ -This -method -returns -true -if -and -only -if -at -least -one -member -of -/ -/ -/ -matches -is -true -after -executing -the -set -against -haystack -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -matches_read_at -( -& -self -matches -: -& -mut -[ -bool -] -haystack -: -& -str -start -: -usize -) -- -> -bool -{ -/ -/ -This -is -pretty -dumb -. -We -should -try -to -fix -this -but -the -/ -/ -regex -- -automata -API -doesn -' -t -provide -a -way -to -store -matches -in -an -/ -/ -arbitrary -& -mut -[ -bool -] -. -Thankfully -this -API -is -is -doc -( -hidden -) -and -/ -/ -thus -not -public -. -. -. -But -regex -- -capi -currently -uses -it -. -We -should -/ -/ -fix -regex -- -capi -to -use -a -PatternSet -maybe -? -Not -sure -. -. -. -PatternSet -/ -/ -is -in -regex -- -automata -not -regex -. -So -maybe -we -should -just -accept -a -/ -/ -' -SetMatches -' -which -is -basically -just -a -newtype -around -PatternSet -. -let -mut -patset -= -PatternSet -: -: -new -( -self -. -meta -. -pattern_len -( -) -) -; -let -mut -input -= -Input -: -: -new -( -haystack -) -; -input -. -set_start -( -start -) -; -self -. -meta -. -which_overlapping_matches -( -& -input -& -mut -patset -) -; -for -pid -in -patset -. -iter -( -) -{ -matches -[ -pid -] -= -true -; -} -! -patset -. -is_empty -( -) -} -/ -/ -/ -An -alias -for -matches_read_at -to -preserve -backward -compatibility -. -/ -/ -/ -/ -/ -/ -The -regex -- -capi -crate -used -this -method -so -to -avoid -breaking -that -/ -/ -/ -crate -we -continue -to -export -it -as -an -undocumented -API -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -read_matches_at -( -& -self -matches -: -& -mut -[ -bool -] -haystack -: -& -str -start -: -usize -) -- -> -bool -{ -self -. -matches_read_at -( -matches -haystack -start -) -} -/ -/ -/ -Returns -the -total -number -of -regexes -in -this -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -0 -RegexSet -: -: -empty -( -) -. -len -( -) -) -; -/ -/ -/ -assert_eq -! -( -1 -RegexSet -: -: -new -( -[ -r -" -[ -0 -- -9 -] -" -] -) -. -unwrap -( -) -. -len -( -) -) -; -/ -/ -/ -assert_eq -! -( -2 -RegexSet -: -: -new -( -[ -r -" -[ -0 -- -9 -] -" -r -" -[ -a -- -z -] -" -] -) -. -unwrap -( -) -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -meta -. -pattern_len -( -) -} -/ -/ -/ -Returns -true -if -this -set -contains -no -regexes -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -assert -! -( -RegexSet -: -: -empty -( -) -. -is_empty -( -) -) -; -/ -/ -/ -assert -! -( -! -RegexSet -: -: -new -( -[ -r -" -[ -0 -- -9 -] -" -] -) -. -unwrap -( -) -. -is_empty -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -meta -. -pattern_len -( -) -= -= -0 -} -/ -/ -/ -Returns -the -regex -patterns -that -this -regex -set -was -constructed -from -. -/ -/ -/ -/ -/ -/ -This -function -can -be -used -to -determine -the -pattern -for -a -match -. -The -/ -/ -/ -slice -returned -has -exactly -as -many -patterns -givens -to -this -regex -set -/ -/ -/ -and -the -order -of -the -slice -is -the -same -as -the -order -of -the -patterns -/ -/ -/ -provided -to -the -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -& -[ -/ -/ -/ -r -" -\ -w -+ -" -/ -/ -/ -r -" -\ -d -+ -" -/ -/ -/ -r -" -\ -pL -+ -" -/ -/ -/ -r -" -foo -" -/ -/ -/ -r -" -bar -" -/ -/ -/ -r -" -barfoo -" -/ -/ -/ -r -" -foobar -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -/ -/ -/ -. -matches -( -" -foobar -" -) -/ -/ -/ -. -into_iter -( -) -/ -/ -/ -. -map -( -| -index -| -& -set -. -patterns -( -) -[ -index -] -) -/ -/ -/ -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -r -" -\ -w -+ -" -r -" -\ -pL -+ -" -r -" -foo -" -r -" -bar -" -r -" -foobar -" -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -patterns -( -& -self -) -- -> -& -[ -String -] -{ -& -self -. -patterns -} -} -impl -Default -for -RegexSet -{ -fn -default -( -) -- -> -Self -{ -RegexSet -: -: -empty -( -) -} -} -/ -/ -/ -A -set -of -matches -returned -by -a -regex -set -. -/ -/ -/ -/ -/ -/ -Values -of -this -type -are -constructed -by -[ -RegexSet -: -: -matches -] -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -SetMatches -( -PatternSet -) -; -impl -SetMatches -{ -/ -/ -/ -Whether -this -set -contains -any -matches -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -& -[ -/ -/ -/ -r -" -[ -a -- -z -] -+ -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -r -" -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -= -set -. -matches -( -" -foo -example -. -com -" -) -; -/ -/ -/ -assert -! -( -matches -. -matched_any -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -matched_any -( -& -self -) -- -> -bool -{ -! -self -. -0 -. -is_empty -( -) -} -/ -/ -/ -Whether -the -regex -at -the -given -index -matched -. -/ -/ -/ -/ -/ -/ -The -index -for -a -regex -is -determined -by -its -insertion -order -upon -the -/ -/ -/ -initial -construction -of -a -RegexSet -starting -at -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -index -is -greater -than -or -equal -to -the -number -of -regexes -in -the -/ -/ -/ -original -set -that -produced -these -matches -. -Equivalently -when -index -/ -/ -/ -is -greater -than -or -equal -to -[ -SetMatches -: -: -len -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -[ -a -- -z -] -+ -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -r -" -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -= -set -. -matches -( -" -example -. -com -" -) -; -/ -/ -/ -assert -! -( -! -matches -. -matched -( -0 -) -) -; -/ -/ -/ -assert -! -( -matches -. -matched -( -1 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -matched -( -& -self -index -: -usize -) -- -> -bool -{ -self -. -0 -. -contains -( -PatternID -: -: -new_unchecked -( -index -) -) -} -/ -/ -/ -The -total -number -of -regexes -in -the -set -that -created -these -matches -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -This -always -returns -the -same -value -as -[ -RegexSet -: -: -len -] -. -/ -/ -/ -In -particular -it -does -* -not -* -return -the -number -of -elements -yielded -by -/ -/ -/ -[ -SetMatches -: -: -iter -] -. -The -only -way -to -determine -the -total -number -of -/ -/ -/ -matched -regexes -is -to -iterate -over -them -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Notice -that -this -method -returns -the -total -number -of -regexes -in -the -/ -/ -/ -original -set -and -* -not -* -the -total -number -of -regexes -that -matched -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -[ -a -- -z -] -+ -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -r -" -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -= -set -. -matches -( -" -example -. -com -" -) -; -/ -/ -/ -/ -/ -Total -number -of -patterns -that -matched -. -/ -/ -/ -assert_eq -! -( -1 -matches -. -iter -( -) -. -count -( -) -) -; -/ -/ -/ -/ -/ -Total -number -of -patterns -in -the -set -. -/ -/ -/ -assert_eq -! -( -2 -matches -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -0 -. -capacity -( -) -} -/ -/ -/ -Returns -an -iterator -over -the -indices -of -the -regexes -that -matched -. -/ -/ -/ -/ -/ -/ -This -will -always -produces -matches -in -ascending -order -where -the -index -/ -/ -/ -yielded corresponds to the @@ -5419,10 +3332,10 @@ that matched with respect +to / / / -to its position when @@ -5431,413 +3344,485 @@ building the set . -/ -/ -/ -/ -/ -/ # -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex +[ +derive +( +Debug +) +] +pub +struct +SetMatchesIntoIter +( +iter : : -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet +Enumerate +< +vec : : -new +IntoIter +< +bool +> +> +) +; +impl +Iterator +for +SetMatchesIntoIter +{ +type +Item += +usize +; +fn +next ( -[ -/ -/ -/ -r -" -[ -0 -- -9 -] -" -/ -/ -/ -r -" -[ -a -- -z -] -" -/ -/ -/ -r -" -[ -A +& +mut +self +) - -Z -] -" -/ -/ -/ -r -" -\ -p +> +Option +< +usize +> { -Greek -} -" -/ -/ -/ -] -) +loop +{ +match +self . -unwrap +0 +. +next ( ) -; -/ -/ -/ -let -hay +{ +None = -" -a1 -" -; -/ -/ -/ -let -matches -: -Vec -< +> +return +None +Some +( +( _ +false +) +) += > +{ +} +Some +( +( +i +true +) +) = -set +> +return +Some +( +i +) +} +} +} +fn +size_hint +( +& +self +) +- +> +( +usize +Option +< +usize +> +) +{ +self +. +0 +. +size_hint +( +) +} +} +impl +DoubleEndedIterator +for +SetMatchesIntoIter +{ +fn +next_back +( +& +mut +self +) +- +> +Option +< +usize +> +{ +loop +{ +match +self . -matches +0 +. +next_back ( -hay ) -. -iter +{ +None += +> +return +None +Some +( ( +_ +false ) -. -collect +) += +> +{ +} +Some +( ( +i +true ) -; -/ -/ -/ -assert_eq -! +) += +> +return +Some ( -matches -vec -! -[ -0 -1 -3 -] +i ) -; +} +} +} +} +impl +iter +: +: +FusedIterator +for +SetMatchesIntoIter +{ +} / / / +A +borrowed +iterator +over +the +set +of +matches +from +a +regex +set +. / / / / / / -Note -that -SetMatches -also -implemnets +The +lifetime +' +a +refers +to the -IntoIterator -trait -so -/ -/ -/ -this -method -is -not -always -needed +lifetime +of +a +SetMatches +value . -For -example -: / / / / / / +This +will +always +produces +matches +in +ascending +order +of +index +where +the / / / -use +index +corresponds +to +the +index +of +the regex -: -: -RegexSet -; -/ -/ -/ +that +matched +with +respect +to / / / -let +its +position +when +initially +building +the set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" +. +# [ -0 -- -9 +derive +( +Clone +Debug +) ] -" -/ -/ -/ -r -" -[ +pub +struct +SetMatchesIter +< +' a -- -z -] -" -/ -/ -/ -r -" -[ -A -- -Z -] -" -/ -/ -/ -r -" -\ -p -{ -Greek -} -" -/ -/ -/ -] -) -. -unwrap +> ( +iter +: +: +Enumerate +< +slice +: +: +Iter +< +' +a +bool +> +> ) ; -/ -/ -/ -let -hay -= -" -a1 -" -; -/ -/ -/ -let -mut -matches +impl +< +' +a +> +Iterator +for +SetMatchesIter +< +' +a +> +{ +type +Item = -vec -! -[ -] +usize ; -/ -/ -/ -for -index -in -set -. -matches +fn +next ( -hay +& +mut +self ) +- +> +Option +< +usize +> { -/ -/ -/ -matches +loop +{ +match +self +. +0 . -push +next ( -index ) -; -/ -/ -/ +{ +None += +> +return +None +Some +( +( +_ +& +false +) +) += +> +{ } -/ -/ -/ -assert_eq -! +Some ( -matches -vec -! -[ -0 -1 -3 -] +( +i +& +true ) -; -/ -/ -/ -# -[ -inline -] -pub +) += +> +return +Some +( +i +) +} +} +} fn -iter +size_hint ( & self ) - > -SetMatchesIter +( +usize +Option < -' -_ +usize > +) { -SetMatchesIter -( self . 0 . -iter +size_hint ( ) -) } } impl -IntoIterator +< +' +a +> +DoubleEndedIterator for -SetMatches +SetMatchesIter +< +' +a +> { -type -IntoIter -= -SetMatchesIntoIter -; -type -Item -= -usize -; fn -into_iter +next_back ( +& +mut self ) - > -Self -: -: -IntoIter +Option +< +usize +> { -let -it -= -0 -. -. +loop +{ +match self . 0 . -capacity +next_back ( ) -; -SetMatchesIntoIter { -patset -: -self -. -0 -it +None += +> +return +None +Some +( +( +_ +& +false +) +) += +> +{ +} +Some +( +( +i +& +true +) +) += +> +return +Some +( +i +) +} } } } @@ -5846,156 +3831,179 @@ impl ' a > -IntoIterator +iter +: +: +FusedIterator for -& -' -a -SetMatches -{ -type -IntoIter -= SetMatchesIter < ' a > -; -type -Item -= -usize -; +{ +} +# +[ +doc +( +hidden +) +] +impl +From +< +Exec +> +for +RegexSet +{ fn -into_iter +from +( +exec +: +Exec +) +- +> +Self +{ +RegexSet +( +exec +) +} +} +impl +fmt +: +: +Debug +for +RegexSet +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +write +! +( +f +" +RegexSet ( +{ +: +? +} +) +" self +. +0 +. +regex_strings +( +) +) +} +} +# +[ +allow +( +dead_code +) +] +fn +as_bytes_str +( +text +: +& +str ) - > -Self -: -: -IntoIter +& +[ +u8 +] { -self +text . -iter +as_bytes ( ) } -} -/ -/ -/ -An -owned -iterator -over -the -set -of -matches -from -a -regex -set -. -/ -/ -/ -/ -/ -/ -This -will -always -produces -matches -in -ascending -order -of -index -where -the -/ -/ -/ -index -corresponds -to -the -index -of -the -regex -that -matched -with -respect -to -/ -/ -/ -its -position -when -initially -building -the -set -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -calling -SetMatches -: +# +[ +allow +( +dead_code +) +] +fn +as_bytes_bytes +( +text : -into_iter -via -the -/ -/ -/ -IntoIterator -trait -. -This -is -automatically -done -in -for -loops -. +& +[ +u8 +] +) +- +> +& +[ +u8 +] +{ +text +} +} +} +} +define_set +! +{ +unicode +set_unicode +& +str +as_bytes_str / / / +rust / / / # -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ use regex : @@ -6005,9 +4013,6 @@ RegexSet / / / -/ -/ -/ let set = @@ -6016,6 +4021,7 @@ RegexSet : new ( +& [ / / @@ -6023,21 +4029,26 @@ new r " [ -0 +a - -9 +z ] -" -/ -/ -/ -r -" ++ [ a - z ] ++ +\ +. +( +com +| +org +| +net +) " / / @@ -6045,21 +4056,20 @@ z r " [ -A +a - -Z +z ] -" -/ -/ -/ -r -" ++ \ -p -{ -Greek -} +. +( +com +| +org +| +net +) " / / @@ -6074,592 +4084,566 @@ unwrap / / / -let -hay -= +/ +/ +/ +/ +/ +Ask +whether +any +regexes +in +the +set +match +. +/ +/ +/ +assert +! +( +set +. +is_match +( " -a1 +foo +example +. +com " +) +) ; / / / -let -mut -matches -= -vec -! -[ -] -; / / / -for -index -in +/ +/ +Identify +which +regexes +in +the +set +match +. +/ +/ +/ +let +matches +: +Vec +< +_ +> += set . matches ( -hay +" +foo +example +. +com +" +) +. +into_iter +( ) -{ -/ -/ -/ -matches . -push +collect ( -index ) ; / / / -} -/ -/ -/ assert_eq ! ( -matches vec ! [ 0 1 -3 ] +matches ) ; / / / -# -[ -derive -( -Debug -) -] -pub -struct -SetMatchesIntoIter -{ -patset -: -PatternSet -it -: -core -: -: -ops -: +/ +/ +/ +/ +/ +Try +again +but +with +text +that +only +matches +one +of +the +regexes +. +/ +/ +/ +let +matches : -Range -< -usize -> -} -impl -Iterator -for -SetMatchesIntoIter -{ -type -Item -= -usize -; -fn -next -( -& -mut -self -) -- -> -Option +Vec < -usize +_ > -{ -loop -{ -let -id = -self -. -it +set . -next +matches ( -) -? -; -if -self +" +example . -patset +com +" +) . -contains -( -PatternID -: -: -new_unchecked +into_iter ( -id -) ) -{ -return -Some +. +collect ( -id ) ; -} -} -} -fn -size_hint +/ +/ +/ +assert_eq +! ( -& -self +vec +! +[ +1 +] +matches ) -- -> -( -usize -Option +; +/ +/ +/ +/ +/ +/ +/ +/ +Try +again +but +with +text +that +doesn +' +t +match +any +regex +in +the +set +. +/ +/ +/ +let +matches +: +Vec < -usize +_ > -) -{ -self -. -it += +set . -size_hint +matches ( +" +example +" ) -} -} -impl -DoubleEndedIterator -for -SetMatchesIntoIter -{ -fn -next_back +. +into_iter ( -& -mut -self ) -- -> -Option -< -usize -> -{ -loop -{ -let -id -= -self -. -it . -next_back +collect ( ) -? ; -if -self -. -patset -. -contains -( -PatternID -: -: -new_unchecked +/ +/ +/ +assert +! ( -id -) -) -{ -return -Some +matches +. +is_empty ( -id +) ) ; +/ +/ +/ } -} -} -} -impl -core +define_set +! +{ +bytes +set_bytes +& +[ +u8 +] +as_bytes_bytes +/ +/ +/ +rust +/ +/ +/ +# +use +regex : : -iter +bytes : : -FusedIterator -for -SetMatchesIntoIter -{ -} +RegexSet +; / / / -A -borrowed -iterator -over -the -set -of -matches -from -a -regex +let set -. += +RegexSet +: +: +new +( +& +[ / / / +r +" +[ +a +- +z +] ++ +[ +a +- +z +] ++ +\ +. +( +com +| +org +| +net +) +" / / / -The -lifetime -' -a -refers -to -the -lifetime -of -the +r +" [ -SetMatches +a +- +z ] -value -that ++ +\ +. +( +com +| +org +| +net +) +" / / / -created -this -iterator +] +) . +unwrap +( +) +; / / / / / / -This -will -always -produces -matches -in -ascending -order -where -the -index -/ / / -corresponds -to -the -index -of +Ask +whether +any +regexes +in the -regex -that -matched -with -respect -to -its +set +match +. / / / -position -when -initially -building -the +assert +! +( set . +is_match +( +b +" +foo +example +. +com +" +) +) +; / / / / / / -This -iterator -is -created -by +/ +/ +Identify +which +regexes +in the -[ -SetMatches -: -: -iter -] -method +set +match . -# -[ -derive -( -Clone -Debug -) -] -pub -struct -SetMatchesIter -< -' -a -> -( -PatternSetIter -< -' -a -> -) -; -impl -< -' -a -> -Iterator -for -SetMatchesIter +/ +/ +/ +let +matches +: +Vec < -' -a +_ > -{ -type -Item = -usize -; -fn -next -( -& -mut -self -) -- -> -Option -< -usize -> -{ -self -. -0 -. -next -( -) -. -map -( -| -pid -| -pid +set . -as_usize -( -) -) -} -fn -size_hint +matches ( -& -self +b +" +foo +example +. +com +" ) -- -> +. +into_iter ( -usize -Option -< -usize -> ) -{ -self . -0 -. -size_hint +collect ( ) -} -} -impl -< -' -a -> -DoubleEndedIterator -for -SetMatchesIter -< -' -a -> -{ -fn -next_back +; +/ +/ +/ +assert_eq +! ( -& -mut -self +vec +! +[ +0 +1 +] +matches ) -- -> -Option +; +/ +/ +/ +/ +/ +/ +/ +/ +Try +again +but +with +text +that +only +matches +one +of +the +regexes +. +/ +/ +/ +let +matches +: +Vec < -usize +_ > -{ -self -. -0 += +set . -next_back +matches ( +b +" +example +. +com +" ) . -map +into_iter ( -| -pid -| -pid +) . -as_usize +collect ( ) +; +/ +/ +/ +assert_eq +! +( +vec +! +[ +1 +] +matches ) -} -} -impl -< -' -a -> -core -: -: -iter -: -: -FusedIterator -for -SetMatchesIter -< +; +/ +/ +/ +/ +/ +/ +/ +/ +Try +again +but +with +text +that +doesn ' -a -> -{ -} -impl -core -: -: -fmt -: -: -Debug -for -RegexSet -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: +t +match +any +regex +in +the +set +. +/ +/ +/ +let +matches : -Formatter +Vec < -' _ > -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! += +set +. +matches ( -f +b " -RegexSet +example +" +) +. +into_iter ( -{ -: -? -} ) -" -self . -patterns +collect +( +) +; +/ +/ +/ +assert +! +( +matches +. +is_empty ( ) ) -} +; +/ +/ +/ } diff --git a/third_party/rust/regex/src/re_trait.rs b/third_party/rust/regex/src/re_trait.rs new file mode 100644 index 0000000000000..f51f2fcb8330d --- /dev/null +++ b/third_party/rust/regex/src/re_trait.rs @@ -0,0 +1,2171 @@ +use +std +: +: +fmt +; +use +std +: +: +iter +: +: +FusedIterator +; +/ +/ +/ +Slot +is +a +single +saved +capture +location +. +Note +that +there +are +two +slots +for +/ +/ +/ +every +capture +in +a +regular +expression +( +one +slot +each +for +the +start +and +end +/ +/ +/ +of +the +capture +) +. +pub +type +Slot += +Option +< +usize +> +; +/ +/ +/ +Locations +represents +the +offsets +of +each +capturing +group +in +a +regex +for +/ +/ +/ +a +single +match +. +/ +/ +/ +/ +/ +/ +Unlike +Captures +a +Locations +value +only +stores +offsets +. +# +[ +doc +( +hidden +) +] +# +[ +derive +( +Clone +Debug +) +] +pub +struct +Locations +( +Vec +< +Slot +> +) +; +impl +Locations +{ +/ +/ +/ +Returns +the +start +and +end +positions +of +the +Nth +capture +group +. +Returns +/ +/ +/ +None +if +i +is +not +a +valid +capture +group +or +if +the +capture +group +did +/ +/ +/ +not +match +anything +. +The +positions +returned +are +* +always +* +byte +indices +/ +/ +/ +with +respect +to +the +original +string +matched +. +pub +fn +pos +( +& +self +i +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +let +( +s +e +) += +( +i +* +2 +i +* +2 ++ +1 +) +; +match +( +self +. +0 +. +get +( +s +) +self +. +0 +. +get +( +e +) +) +{ +( +Some +( +& +Some +( +s +) +) +Some +( +& +Some +( +e +) +) +) += +> +Some +( +( +s +e +) +) +_ += +> +None +} +} +/ +/ +/ +Creates +an +iterator +of +all +the +capture +group +positions +in +order +of +/ +/ +/ +appearance +in +the +regular +expression +. +Positions +are +byte +indices +/ +/ +/ +in +terms +of +the +original +string +matched +. +pub +fn +iter +( +& +self +) +- +> +SubCapturesPosIter +< +' +_ +> +{ +SubCapturesPosIter +{ +idx +: +0 +locs +: +self +} +} +/ +/ +/ +Returns +the +total +number +of +capturing +groups +. +/ +/ +/ +/ +/ +/ +This +is +always +at +least +1 +since +every +regex +has +at +least +1 +/ +/ +/ +capturing +group +that +corresponds +to +the +entire +match +. +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +0 +. +len +( +) +/ +2 +} +/ +/ +/ +Return +the +individual +slots +as +a +slice +. +pub +( +crate +) +fn +as_slots +( +& +mut +self +) +- +> +& +mut +[ +Slot +] +{ +& +mut +self +. +0 +} +} +/ +/ +/ +An +iterator +over +capture +group +positions +for +a +particular +match +of +a +/ +/ +/ +regular +expression +. +/ +/ +/ +/ +/ +/ +Positions +are +byte +indices +in +terms +of +the +original +string +matched +. +/ +/ +/ +/ +/ +/ +' +c +is +the +lifetime +of +the +captures +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +SubCapturesPosIter +< +' +c +> +{ +idx +: +usize +locs +: +& +' +c +Locations +} +impl +< +' +c +> +Iterator +for +SubCapturesPosIter +< +' +c +> +{ +type +Item += +Option +< +( +usize +usize +) +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Option +< +( +usize +usize +) +> +> +{ +if +self +. +idx +> += +self +. +locs +. +len +( +) +{ +return +None +; +} +let +x += +match +self +. +locs +. +pos +( +self +. +idx +) +{ +None += +> +Some +( +None +) +Some +( +( +s +e +) +) += +> +Some +( +Some +( +( +s +e +) +) +) +} +; +self +. +idx ++ += +1 +; +x +} +fn +size_hint +( +& +self +) +- +> +( +usize +Option +< +usize +> +) +{ +let +len += +self +. +locs +. +len +( +) +- +self +. +idx +; +( +len +Some +( +len +) +) +} +fn +count +( +self +) +- +> +usize +{ +self +. +len +( +) +} +} +impl +< +' +c +> +ExactSizeIterator +for +SubCapturesPosIter +< +' +c +> +{ +} +impl +< +' +c +> +FusedIterator +for +SubCapturesPosIter +< +' +c +> +{ +} +/ +/ +/ +RegularExpression +describes +types +that +can +implement +regex +searching +. +/ +/ +/ +/ +/ +/ +This +trait +is +my +attempt +at +reducing +code +duplication +and +to +standardize +/ +/ +/ +the +internal +API +. +Specific +duplication +that +is +avoided +are +the +find +/ +/ +/ +and +capture +iterators +which +are +slightly +tricky +. +/ +/ +/ +/ +/ +/ +It +' +s +not +clear +whether +this +trait +is +worth +it +and +it +also +isn +' +t +/ +/ +/ +clear +whether +it +' +s +useful +as +a +public +trait +or +not +. +Methods +like +/ +/ +/ +next_after_empty +reak +of +bad +design +but +the +rest +of +the +methods +seem +/ +/ +/ +somewhat +reasonable +. +One +particular +thing +this +trait +would +expose +would +be +/ +/ +/ +the +ability +to +start +the +search +of +a +regex +anywhere +in +a +haystack +which +/ +/ +/ +isn +' +t +possible +in +the +current +public +API +. +pub +trait +RegularExpression +: +Sized ++ +fmt +: +: +Debug +{ +/ +/ +/ +The +type +of +the +haystack +. +type +Text +: +? +Sized ++ +fmt +: +: +Debug +; +/ +/ +/ +The +number +of +capture +slots +in +the +compiled +regular +expression +. +This +is +/ +/ +/ +always +two +times +the +number +of +capture +groups +( +two +slots +per +group +) +. +fn +slots_len +( +& +self +) +- +> +usize +; +/ +/ +/ +Allocates +fresh +space +for +all +capturing +groups +in +this +regex +. +fn +locations +( +& +self +) +- +> +Locations +{ +Locations +( +vec +! +[ +None +; +self +. +slots_len +( +) +] +) +} +/ +/ +/ +Returns +the +position +of +the +next +character +after +i +. +/ +/ +/ +/ +/ +/ +For +example +a +haystack +with +type +& +[ +u8 +] +probably +returns +i ++ +1 +/ +/ +/ +whereas +a +haystack +with +type +& +str +probably +returns +i +plus +the +/ +/ +/ +length +of +the +next +UTF +- +8 +sequence +. +fn +next_after_empty +( +& +self +text +: +& +Self +: +: +Text +i +: +usize +) +- +> +usize +; +/ +/ +/ +Returns +the +location +of +the +shortest +match +. +fn +shortest_match_at +( +& +self +text +: +& +Self +: +: +Text +start +: +usize +) +- +> +Option +< +usize +> +; +/ +/ +/ +Returns +whether +the +regex +matches +the +text +given +. +fn +is_match_at +( +& +self +text +: +& +Self +: +: +Text +start +: +usize +) +- +> +bool +; +/ +/ +/ +Returns +the +leftmost +- +first +match +location +if +one +exists +. +fn +find_at +( +& +self +text +: +& +Self +: +: +Text +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +; +/ +/ +/ +Returns +the +leftmost +- +first +match +location +if +one +exists +and +also +/ +/ +/ +fills +in +any +matching +capture +slot +locations +. +fn +captures_read_at +( +& +self +locs +: +& +mut +Locations +text +: +& +Self +: +: +Text +start +: +usize +) +- +> +Option +< +( +usize +usize +) +> +; +/ +/ +/ +Returns +an +iterator +over +all +non +- +overlapping +successive +leftmost +- +first +/ +/ +/ +matches +. +fn +find_iter +( +self +text +: +& +Self +: +: +Text +) +- +> +Matches +< +' +_ +Self +> +{ +Matches +{ +re +: +self +text +last_end +: +0 +last_match +: +None +} +} +/ +/ +/ +Returns +an +iterator +over +all +non +- +overlapping +successive +leftmost +- +first +/ +/ +/ +matches +with +captures +. +fn +captures_iter +( +self +text +: +& +Self +: +: +Text +) +- +> +CaptureMatches +< +' +_ +Self +> +{ +CaptureMatches +( +self +. +find_iter +( +text +) +) +} +} +/ +/ +/ +An +iterator +over +all +non +- +overlapping +successive +leftmost +- +first +matches +. +# +[ +derive +( +Debug +) +] +pub +struct +Matches +< +' +t +R +> +where +R +: +RegularExpression +R +: +: +Text +: +' +t +{ +re +: +R +text +: +& +' +t +R +: +: +Text +last_end +: +usize +last_match +: +Option +< +usize +> +} +impl +< +' +t +R +> +Matches +< +' +t +R +> +where +R +: +RegularExpression +R +: +: +Text +: +' +t +{ +/ +/ +/ +Return +the +text +being +searched +. +pub +fn +text +( +& +self +) +- +> +& +' +t +R +: +: +Text +{ +self +. +text +} +/ +/ +/ +Return +the +underlying +regex +. +pub +fn +regex +( +& +self +) +- +> +& +R +{ +& +self +. +re +} +} +impl +< +' +t +R +> +Iterator +for +Matches +< +' +t +R +> +where +R +: +RegularExpression +R +: +: +Text +: +' +t ++ +AsRef +< +[ +u8 +] +> +{ +type +Item += +( +usize +usize +) +; +fn +next +( +& +mut +self +) +- +> +Option +< +( +usize +usize +) +> +{ +if +self +. +last_end +> +self +. +text +. +as_ref +( +) +. +len +( +) +{ +return +None +; +} +let +( +s +e +) += +match +self +. +re +. +find_at +( +self +. +text +self +. +last_end +) +{ +None += +> +return +None +Some +( +( +s +e +) +) += +> +( +s +e +) +} +; +if +s += += +e +{ +/ +/ +This +is +an +empty +match +. +To +ensure +we +make +progress +start +/ +/ +the +next +search +at +the +smallest +possible +starting +position +/ +/ +of +the +next +match +following +this +one +. +self +. +last_end += +self +. +re +. +next_after_empty +( +self +. +text +e +) +; +/ +/ +Don +' +t +accept +empty +matches +immediately +following +a +match +. +/ +/ +Just +move +on +to +the +next +match +. +if +Some +( +e +) += += +self +. +last_match +{ +return +self +. +next +( +) +; +} +} +else +{ +self +. +last_end += +e +; +} +self +. +last_match += +Some +( +e +) +; +Some +( +( +s +e +) +) +} +} +impl +< +' +t +R +> +FusedIterator +for +Matches +< +' +t +R +> +where +R +: +RegularExpression +R +: +: +Text +: +' +t ++ +AsRef +< +[ +u8 +] +> +{ +} +/ +/ +/ +An +iterator +over +all +non +- +overlapping +successive +leftmost +- +first +matches +with +/ +/ +/ +captures +. +# +[ +derive +( +Debug +) +] +pub +struct +CaptureMatches +< +' +t +R +> +( +Matches +< +' +t +R +> +) +where +R +: +RegularExpression +R +: +: +Text +: +' +t +; +impl +< +' +t +R +> +CaptureMatches +< +' +t +R +> +where +R +: +RegularExpression +R +: +: +Text +: +' +t +{ +/ +/ +/ +Return +the +text +being +searched +. +pub +fn +text +( +& +self +) +- +> +& +' +t +R +: +: +Text +{ +self +. +0 +. +text +( +) +} +/ +/ +/ +Return +the +underlying +regex +. +pub +fn +regex +( +& +self +) +- +> +& +R +{ +self +. +0 +. +regex +( +) +} +} +impl +< +' +t +R +> +Iterator +for +CaptureMatches +< +' +t +R +> +where +R +: +RegularExpression +R +: +: +Text +: +' +t ++ +AsRef +< +[ +u8 +] +> +{ +type +Item += +Locations +; +fn +next +( +& +mut +self +) +- +> +Option +< +Locations +> +{ +if +self +. +0 +. +last_end +> +self +. +0 +. +text +. +as_ref +( +) +. +len +( +) +{ +return +None +; +} +let +mut +locs += +self +. +0 +. +re +. +locations +( +) +; +let +( +s +e +) += +match +self +. +0 +. +re +. +captures_read_at +( +& +mut +locs +self +. +0 +. +text +self +. +0 +. +last_end +) +{ +None += +> +return +None +Some +( +( +s +e +) +) += +> +( +s +e +) +} +; +if +s += += +e +{ +self +. +0 +. +last_end += +self +. +0 +. +re +. +next_after_empty +( +self +. +0 +. +text +e +) +; +if +Some +( +e +) += += +self +. +0 +. +last_match +{ +return +self +. +next +( +) +; +} +} +else +{ +self +. +0 +. +last_end += +e +; +} +self +. +0 +. +last_match += +Some +( +e +) +; +Some +( +locs +) +} +} +impl +< +' +t +R +> +FusedIterator +for +CaptureMatches +< +' +t +R +> +where +R +: +RegularExpression +R +: +: +Text +: +' +t ++ +AsRef +< +[ +u8 +] +> +{ +} diff --git a/third_party/rust/regex/src/re_unicode.rs b/third_party/rust/regex/src/re_unicode.rs new file mode 100644 index 0000000000000..8c393609dd2fb --- /dev/null +++ b/third_party/rust/regex/src/re_unicode.rs @@ -0,0 +1,12297 @@ +use +std +: +: +borrow +: +: +Cow +; +use +std +: +: +collections +: +: +HashMap +; +use +std +: +: +fmt +; +use +std +: +: +iter +: +: +FusedIterator +; +use +std +: +: +ops +: +: +{ +Index +Range +} +; +use +std +: +: +str +: +: +FromStr +; +use +std +: +: +sync +: +: +Arc +; +use +crate +: +: +find_byte +: +: +find_byte +; +use +crate +: +: +error +: +: +Error +; +use +crate +: +: +exec +: +: +{ +Exec +ExecNoSyncStr +} +; +use +crate +: +: +expand +: +: +expand_str +; +use +crate +: +: +re_builder +: +: +unicode +: +: +RegexBuilder +; +use +crate +: +: +re_trait +: +: +{ +self +RegularExpression +SubCapturesPosIter +} +; +/ +/ +/ +Escapes +all +regular +expression +meta +characters +in +text +. +/ +/ +/ +/ +/ +/ +The +string +returned +may +be +safely +used +as +a +literal +in +a +regular +/ +/ +/ +expression +. +pub +fn +escape +( +text +: +& +str +) +- +> +String +{ +regex_syntax +: +: +escape +( +text +) +} +/ +/ +/ +Match +represents +a +single +match +of +a +regex +in +a +haystack +. +/ +/ +/ +/ +/ +/ +The +lifetime +parameter +' +t +refers +to +the +lifetime +of +the +matched +text +. +# +[ +derive +( +Copy +Clone +Debug +Eq +PartialEq +) +] +pub +struct +Match +< +' +t +> +{ +text +: +& +' +t +str +start +: +usize +end +: +usize +} +impl +< +' +t +> +Match +< +' +t +> +{ +/ +/ +/ +Returns +the +starting +byte +offset +of +the +match +in +the +haystack +. +# +[ +inline +] +pub +fn +start +( +& +self +) +- +> +usize +{ +self +. +start +} +/ +/ +/ +Returns +the +ending +byte +offset +of +the +match +in +the +haystack +. +# +[ +inline +] +pub +fn +end +( +& +self +) +- +> +usize +{ +self +. +end +} +/ +/ +/ +Returns +the +range +over +the +starting +and +ending +byte +offsets +of +the +/ +/ +/ +match +in +the +haystack +. +# +[ +inline +] +pub +fn +range +( +& +self +) +- +> +Range +< +usize +> +{ +self +. +start +. +. +self +. +end +} +/ +/ +/ +Returns +the +matched +text +. +# +[ +inline +] +pub +fn +as_str +( +& +self +) +- +> +& +' +t +str +{ +& +self +. +text +[ +self +. +range +( +) +] +} +/ +/ +/ +Creates +a +new +match +from +the +given +haystack +and +byte +offsets +. +# +[ +inline +] +fn +new +( +haystack +: +& +' +t +str +start +: +usize +end +: +usize +) +- +> +Match +< +' +t +> +{ +Match +{ +text +: +haystack +start +end +} +} +} +impl +< +' +t +> +From +< +Match +< +' +t +> +> +for +& +' +t +str +{ +fn +from +( +m +: +Match +< +' +t +> +) +- +> +& +' +t +str +{ +m +. +as_str +( +) +} +} +impl +< +' +t +> +From +< +Match +< +' +t +> +> +for +Range +< +usize +> +{ +fn +from +( +m +: +Match +< +' +t +> +) +- +> +Range +< +usize +> +{ +m +. +range +( +) +} +} +/ +/ +/ +A +compiled +regular +expression +for +matching +Unicode +strings +. +/ +/ +/ +/ +/ +/ +It +is +represented +as +either +a +sequence +of +bytecode +instructions +( +dynamic +) +/ +/ +/ +or +as +a +specialized +Rust +function +( +native +) +. +It +can +be +used +to +search +split +/ +/ +/ +or +replace +text +. +All +searching +is +done +with +an +implicit +. +* +? +at +the +/ +/ +/ +beginning +and +end +of +an +expression +. +To +force +an +expression +to +match +the +/ +/ +/ +whole +string +( +or +a +prefix +or +a +suffix +) +you +must +use +an +anchor +like +^ +or +/ +/ +/ +( +or +\ +A +and +\ +z +) +. +/ +/ +/ +/ +/ +/ +While +this +crate +will +handle +Unicode +strings +( +whether +in +the +regular +/ +/ +/ +expression +or +in +the +search +text +) +all +positions +returned +are +* +* +byte +/ +/ +/ +indices +* +* +. +Every +byte +index +is +guaranteed +to +be +at +a +Unicode +code +point +/ +/ +/ +boundary +. +/ +/ +/ +/ +/ +/ +The +lifetimes +' +r +and +' +t +in +this +crate +correspond +to +the +lifetime +of +a +/ +/ +/ +compiled +regular +expression +and +text +to +search +respectively +. +/ +/ +/ +/ +/ +/ +The +only +methods +that +allocate +new +strings +are +the +string +replacement +/ +/ +/ +methods +. +All +other +methods +( +searching +and +splitting +) +return +borrowed +/ +/ +/ +pointers +into +the +string +given +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Find +the +location +of +a +US +phone +number +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +let +re += +Regex +: +: +new +( +" +[ +0 +- +9 +] +{ +3 +} +- +[ +0 +- +9 +] +{ +3 +} +- +[ +0 +- +9 +] +{ +4 +} +" +) +. +unwrap +( +) +; +/ +/ +/ +let +mat += +re +. +find +( +" +phone +: +111 +- +222 +- +3333 +" +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +( +mat +. +start +( +) +mat +. +end +( +) +) +( +7 +19 +) +) +; +/ +/ +/ +/ +/ +/ +/ +/ +/ +# +Using +the +std +: +: +str +: +: +pattern +methods +with +Regex +/ +/ +/ +/ +/ +/ +> +* +* +Note +* +* +: +This +section +requires +that +this +crate +is +compiled +with +the +/ +/ +/ +> +pattern +Cargo +feature +enabled +which +* +* +requires +nightly +Rust +* +* +. +/ +/ +/ +/ +/ +/ +Since +Regex +implements +Pattern +you +can +use +regexes +with +methods +/ +/ +/ +defined +on +& +str +. +For +example +is_match +find +find_iter +/ +/ +/ +and +split +can +be +replaced +with +str +: +: +contains +str +: +: +find +/ +/ +/ +str +: +: +match_indices +and +str +: +: +split +. +/ +/ +/ +/ +/ +/ +Here +are +some +examples +: +/ +/ +/ +/ +/ +/ +rust +ignore +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +\ +d ++ +" +) +. +unwrap +( +) +; +/ +/ +/ +let +haystack += +" +a111b222c +" +; +/ +/ +/ +/ +/ +/ +assert +! +( +haystack +. +contains +( +& +re +) +) +; +/ +/ +/ +assert_eq +! +( +haystack +. +find +( +& +re +) +Some +( +1 +) +) +; +/ +/ +/ +assert_eq +! +( +haystack +. +match_indices +( +& +re +) +. +collect +: +: +< +Vec +< +_ +> +> +( +) +/ +/ +/ +vec +! +[ +( +1 +" +111 +" +) +( +5 +" +222 +" +) +] +) +; +/ +/ +/ +assert_eq +! +( +haystack +. +split +( +& +re +) +. +collect +: +: +< +Vec +< +_ +> +> +( +) +vec +! +[ +" +a +" +" +b +" +" +c +" +] +) +; +/ +/ +/ +# +[ +derive +( +Clone +) +] +pub +struct +Regex +( +Exec +) +; +impl +fmt +: +: +Display +for +Regex +{ +/ +/ +/ +Shows +the +original +regular +expression +. +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +write +! +( +f +" +{ +} +" +self +. +as_str +( +) +) +} +} +impl +fmt +: +: +Debug +for +Regex +{ +/ +/ +/ +Shows +the +original +regular +expression +. +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +fmt +: +: +Display +: +: +fmt +( +self +f +) +} +} +# +[ +doc +( +hidden +) +] +impl +From +< +Exec +> +for +Regex +{ +fn +from +( +exec +: +Exec +) +- +> +Regex +{ +Regex +( +exec +) +} +} +impl +FromStr +for +Regex +{ +type +Err += +Error +; +/ +/ +/ +Attempts +to +parse +a +string +into +a +regular +expression +fn +from_str +( +s +: +& +str +) +- +> +Result +< +Regex +Error +> +{ +Regex +: +: +new +( +s +) +} +} +/ +/ +/ +Core +regular +expression +methods +. +impl +Regex +{ +/ +/ +/ +Compiles +a +regular +expression +. +Once +compiled +it +can +be +used +repeatedly +/ +/ +/ +to +search +split +or +replace +text +in +a +string +. +/ +/ +/ +/ +/ +/ +If +an +invalid +expression +is +given +then +an +error +is +returned +. +pub +fn +new +( +re +: +& +str +) +- +> +Result +< +Regex +Error +> +{ +RegexBuilder +: +: +new +( +re +) +. +build +( +) +} +/ +/ +/ +Returns +true +if +and +only +if +there +is +a +match +for +the +regex +in +the +/ +/ +/ +string +given +. +/ +/ +/ +/ +/ +/ +It +is +recommended +to +use +this +method +if +all +you +need +to +do +is +test +/ +/ +/ +a +match +since +the +underlying +matching +engine +may +be +able +to +do +less +/ +/ +/ +work +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Test +if +some +text +contains +at +least +one +word +with +exactly +13 +/ +/ +/ +Unicode +word +characters +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +text += +" +I +categorically +deny +having +triskaidekaphobia +. +" +; +/ +/ +/ +assert +! +( +Regex +: +: +new +( +r +" +\ +b +\ +w +{ +13 +} +\ +b +" +) +. +unwrap +( +) +. +is_match +( +text +) +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +is_match +( +& +self +text +: +& +str +) +- +> +bool +{ +self +. +is_match_at +( +text +0 +) +} +/ +/ +/ +Returns +the +start +and +end +byte +range +of +the +leftmost +- +first +match +in +/ +/ +/ +text +. +If +no +match +exists +then +None +is +returned +. +/ +/ +/ +/ +/ +/ +Note +that +this +should +only +be +used +if +you +want +to +discover +the +position +/ +/ +/ +of +the +match +. +Testing +the +existence +of +a +match +is +faster +if +you +use +/ +/ +/ +is_match +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Find +the +start +and +end +location +of +the +first +word +with +exactly +13 +/ +/ +/ +Unicode +word +characters +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +text += +" +I +categorically +deny +having +triskaidekaphobia +. +" +; +/ +/ +/ +let +mat += +Regex +: +: +new +( +r +" +\ +b +\ +w +{ +13 +} +\ +b +" +) +. +unwrap +( +) +. +find +( +text +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +mat +. +start +( +) +2 +) +; +/ +/ +/ +assert_eq +! +( +mat +. +end +( +) +15 +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +find +< +' +t +> +( +& +self +text +: +& +' +t +str +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +find_at +( +text +0 +) +} +/ +/ +/ +Returns +an +iterator +for +each +successive +non +- +overlapping +match +in +/ +/ +/ +text +returning +the +start +and +end +byte +indices +with +respect +to +/ +/ +/ +text +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Find +the +start +and +end +location +of +every +word +with +exactly +13 +Unicode +/ +/ +/ +word +characters +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +text += +" +Retroactively +relinquishing +remunerations +is +reprehensible +. +" +; +/ +/ +/ +for +mat +in +Regex +: +: +new +( +r +" +\ +b +\ +w +{ +13 +} +\ +b +" +) +. +unwrap +( +) +. +find_iter +( +text +) +{ +/ +/ +/ +println +! +( +" +{ +: +? +} +" +mat +) +; +/ +/ +/ +} +/ +/ +/ +# +} +/ +/ +/ +pub +fn +find_iter +< +' +r +' +t +> +( +& +' +r +self +text +: +& +' +t +str +) +- +> +Matches +< +' +r +' +t +> +{ +Matches +( +self +. +0 +. +searcher_str +( +) +. +find_iter +( +text +) +) +} +/ +/ +/ +Returns +the +capture +groups +corresponding +to +the +leftmost +- +first +/ +/ +/ +match +in +text +. +Capture +group +0 +always +corresponds +to +the +entire +/ +/ +/ +match +. +If +no +match +is +found +then +None +is +returned +. +/ +/ +/ +/ +/ +/ +You +should +only +use +captures +if +you +need +access +to +the +location +of +/ +/ +/ +capturing +group +matches +. +Otherwise +find +is +faster +for +discovering +/ +/ +/ +the +location +of +the +overall +match +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Say +you +have +some +text +with +movie +names +and +their +release +years +/ +/ +/ +like +" +' +Citizen +Kane +' +( +1941 +) +" +. +It +' +d +be +nice +if +we +could +search +for +text +/ +/ +/ +looking +like +that +while +also +extracting +the +movie +name +and +its +release +/ +/ +/ +year +separately +. +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +' +( +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +\ +d +{ +4 +} +) +\ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +text += +" +Not +my +favorite +movie +: +' +Citizen +Kane +' +( +1941 +) +. +" +; +/ +/ +/ +let +caps += +re +. +captures +( +text +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +caps +. +get +( +1 +) +. +unwrap +( +) +. +as_str +( +) +" +Citizen +Kane +" +) +; +/ +/ +/ +assert_eq +! +( +caps +. +get +( +2 +) +. +unwrap +( +) +. +as_str +( +) +" +1941 +" +) +; +/ +/ +/ +assert_eq +! +( +caps +. +get +( +0 +) +. +unwrap +( +) +. +as_str +( +) +" +' +Citizen +Kane +' +( +1941 +) +" +) +; +/ +/ +/ +/ +/ +You +can +also +access +the +groups +by +index +using +the +Index +notation +. +/ +/ +/ +/ +/ +Note +that +this +will +panic +on +an +invalid +index +. +/ +/ +/ +assert_eq +! +( +& +caps +[ +1 +] +" +Citizen +Kane +" +) +; +/ +/ +/ +assert_eq +! +( +& +caps +[ +2 +] +" +1941 +" +) +; +/ +/ +/ +assert_eq +! +( +& +caps +[ +0 +] +" +' +Citizen +Kane +' +( +1941 +) +" +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +Note +that +the +full +match +is +at +capture +group +0 +. +Each +subsequent +/ +/ +/ +capture +group +is +indexed +by +the +order +of +its +opening +( +. +/ +/ +/ +/ +/ +/ +We +can +make +this +example +a +bit +clearer +by +using +* +named +* +capture +groups +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +/ +/ +/ +. +unwrap +( +) +; +/ +/ +/ +let +text += +" +Not +my +favorite +movie +: +' +Citizen +Kane +' +( +1941 +) +. +" +; +/ +/ +/ +let +caps += +re +. +captures +( +text +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +caps +. +name +( +" +title +" +) +. +unwrap +( +) +. +as_str +( +) +" +Citizen +Kane +" +) +; +/ +/ +/ +assert_eq +! +( +caps +. +name +( +" +year +" +) +. +unwrap +( +) +. +as_str +( +) +" +1941 +" +) +; +/ +/ +/ +assert_eq +! +( +caps +. +get +( +0 +) +. +unwrap +( +) +. +as_str +( +) +" +' +Citizen +Kane +' +( +1941 +) +" +) +; +/ +/ +/ +/ +/ +You +can +also +access +the +groups +by +name +using +the +Index +notation +. +/ +/ +/ +/ +/ +Note +that +this +will +panic +on +an +invalid +group +name +. +/ +/ +/ +assert_eq +! +( +& +caps +[ +" +title +" +] +" +Citizen +Kane +" +) +; +/ +/ +/ +assert_eq +! +( +& +caps +[ +" +year +" +] +" +1941 +" +) +; +/ +/ +/ +assert_eq +! +( +& +caps +[ +0 +] +" +' +Citizen +Kane +' +( +1941 +) +" +) +; +/ +/ +/ +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +Here +we +name +the +capture +groups +which +we +can +access +with +the +name +/ +/ +/ +method +or +the +Index +notation +with +a +& +str +. +Note +that +the +named +/ +/ +/ +capture +groups +are +still +accessible +with +get +or +the +Index +notation +/ +/ +/ +with +a +usize +. +/ +/ +/ +/ +/ +/ +The +0 +th +capture +group +is +always +unnamed +so +it +must +always +be +/ +/ +/ +accessed +with +get +( +0 +) +or +[ +0 +] +. +pub +fn +captures +< +' +t +> +( +& +self +text +: +& +' +t +str +) +- +> +Option +< +Captures +< +' +t +> +> +{ +let +mut +locs += +self +. +capture_locations +( +) +; +self +. +captures_read_at +( +& +mut +locs +text +0 +) +. +map +( +move +| +_ +| +Captures +{ +text +locs +: +locs +. +0 +named_groups +: +self +. +0 +. +capture_name_idx +( +) +. +clone +( +) +} +) +} +/ +/ +/ +Returns +an +iterator +over +all +the +non +- +overlapping +capture +groups +matched +/ +/ +/ +in +text +. +This +is +operationally +the +same +as +find_iter +except +it +/ +/ +/ +yields +information +about +capturing +group +matches +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +We +can +use +this +to +find +all +movie +titles +and +their +release +years +in +/ +/ +/ +some +text +where +the +movie +is +formatted +like +" +' +Title +' +( +xxxx +) +" +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +/ +/ +/ +. +unwrap +( +) +; +/ +/ +/ +let +text += +" +' +Citizen +Kane +' +( +1941 +) +' +The +Wizard +of +Oz +' +( +1939 +) +' +M +' +( +1931 +) +. +" +; +/ +/ +/ +for +caps +in +re +. +captures_iter +( +text +) +{ +/ +/ +/ +println +! +( +" +Movie +: +{ +: +? +} +Released +: +{ +: +? +} +" +/ +/ +/ +& +caps +[ +" +title +" +] +& +caps +[ +" +year +" +] +) +; +/ +/ +/ +} +/ +/ +/ +/ +/ +Output +: +/ +/ +/ +/ +/ +Movie +: +Citizen +Kane +Released +: +1941 +/ +/ +/ +/ +/ +Movie +: +The +Wizard +of +Oz +Released +: +1939 +/ +/ +/ +/ +/ +Movie +: +M +Released +: +1931 +/ +/ +/ +# +} +/ +/ +/ +pub +fn +captures_iter +< +' +r +' +t +> +( +& +' +r +self +text +: +& +' +t +str +) +- +> +CaptureMatches +< +' +r +' +t +> +{ +CaptureMatches +( +self +. +0 +. +searcher_str +( +) +. +captures_iter +( +text +) +) +} +/ +/ +/ +Returns +an +iterator +of +substrings +of +text +delimited +by +a +match +of +the +/ +/ +/ +regular +expression +. +Namely +each +element +of +the +iterator +corresponds +to +/ +/ +/ +text +that +* +isn +' +t +* +matched +by +the +regular +expression +. +/ +/ +/ +/ +/ +/ +This +method +will +* +not +* +copy +the +text +given +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +To +split +a +string +delimited +by +arbitrary +amounts +of +spaces +or +tabs +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +[ +\ +t +] ++ +" +) +. +unwrap +( +) +; +/ +/ +/ +let +fields +: +Vec +< +& +str +> += +re +. +split +( +" +a +b +\ +t +c +\ +td +e +" +) +. +collect +( +) +; +/ +/ +/ +assert_eq +! +( +fields +vec +! +[ +" +a +" +" +b +" +" +c +" +" +d +" +" +e +" +] +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +split +< +' +r +' +t +> +( +& +' +r +self +text +: +& +' +t +str +) +- +> +Split +< +' +r +' +t +> +{ +Split +{ +finder +: +self +. +find_iter +( +text +) +last +: +0 +} +} +/ +/ +/ +Returns +an +iterator +of +at +most +limit +substrings +of +text +delimited +/ +/ +/ +by +a +match +of +the +regular +expression +. +( +A +limit +of +0 +will +return +no +/ +/ +/ +substrings +. +) +Namely +each +element +of +the +iterator +corresponds +to +text +/ +/ +/ +that +* +isn +' +t +* +matched +by +the +regular +expression +. +The +remainder +of +the +/ +/ +/ +string +that +is +not +split +will +be +the +last +element +in +the +iterator +. +/ +/ +/ +/ +/ +/ +This +method +will +* +not +* +copy +the +text +given +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Get +the +first +two +words +in +some +text +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +\ +W ++ +" +) +. +unwrap +( +) +; +/ +/ +/ +let +fields +: +Vec +< +& +str +> += +re +. +splitn +( +" +Hey +! +How +are +you +? +" +3 +) +. +collect +( +) +; +/ +/ +/ +assert_eq +! +( +fields +vec +! +( +" +Hey +" +" +How +" +" +are +you +? +" +) +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +splitn +< +' +r +' +t +> +( +& +' +r +self +text +: +& +' +t +str +limit +: +usize +) +- +> +SplitN +< +' +r +' +t +> +{ +SplitN +{ +splits +: +self +. +split +( +text +) +n +: +limit +} +} +/ +/ +/ +Replaces +the +leftmost +- +first +match +with +the +replacement +provided +. +/ +/ +/ +The +replacement +can +be +a +regular +string +( +where +N +and +name +are +/ +/ +/ +expanded +to +match +capture +groups +) +or +a +function +that +takes +the +matches +' +/ +/ +/ +Captures +and +returns +the +replaced +string +. +/ +/ +/ +/ +/ +/ +If +no +match +is +found +then +a +copy +of +the +string +is +returned +unchanged +. +/ +/ +/ +/ +/ +/ +# +Replacement +string +syntax +/ +/ +/ +/ +/ +/ +All +instances +of +name +in +the +replacement +text +is +replaced +with +the +/ +/ +/ +corresponding +capture +group +name +. +/ +/ +/ +/ +/ +/ +name +may +be +an +integer +corresponding +to +the +index +of +the +/ +/ +/ +capture +group +( +counted +by +order +of +opening +parenthesis +where +0 +is +the +/ +/ +/ +entire +match +) +or +it +can +be +a +name +( +consisting +of +letters +digits +or +/ +/ +/ +underscores +) +corresponding +to +a +named +capture +group +. +/ +/ +/ +/ +/ +/ +If +name +isn +' +t +a +valid +capture +group +( +whether +the +name +doesn +' +t +exist +/ +/ +/ +or +isn +' +t +a +valid +index +) +then +it +is +replaced +with +the +empty +string +. +/ +/ +/ +/ +/ +/ +The +longest +possible +name +is +used +. +e +. +g +. +1a +looks +up +the +capture +/ +/ +/ +group +named +1a +and +not +the +capture +group +at +index +1 +. +To +exert +more +/ +/ +/ +precise +control +over +the +name +use +braces +e +. +g +. +{ +1 +} +a +. +/ +/ +/ +/ +/ +/ +To +write +a +literal +use +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Note +that +this +function +is +polymorphic +with +respect +to +the +replacement +. +/ +/ +/ +In +typical +usage +this +can +just +be +a +normal +string +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +" +[ +^ +01 +] ++ +" +) +. +unwrap +( +) +; +/ +/ +/ +assert_eq +! +( +re +. +replace +( +" +1078910 +" +" +" +) +" +1010 +" +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +But +anything +satisfying +the +Replacer +trait +will +work +. +For +example +/ +/ +/ +a +closure +of +type +| +& +Captures +| +- +> +String +provides +direct +access +to +the +/ +/ +/ +captures +corresponding +to +a +match +. +This +allows +one +to +access +/ +/ +/ +capturing +group +matches +easily +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +use +regex +: +: +Captures +; +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +( +[ +^ +\ +s +] ++ +) +\ +s ++ +( +\ +S ++ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +result += +re +. +replace +( +" +Springsteen +Bruce +" +| +caps +: +& +Captures +| +{ +/ +/ +/ +format +! +( +" +{ +} +{ +} +" +& +caps +[ +2 +] +& +caps +[ +1 +] +) +/ +/ +/ +} +) +; +/ +/ +/ +assert_eq +! +( +result +" +Bruce +Springsteen +" +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +But +this +is +a +bit +cumbersome +to +use +all +the +time +. +Instead +a +simple +/ +/ +/ +syntax +is +supported +that +expands +name +into +the +corresponding +capture +/ +/ +/ +group +. +Here +' +s +the +last +example +but +using +this +expansion +technique +/ +/ +/ +with +named +capture +groups +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +( +? +P +< +last +> +[ +^ +\ +s +] ++ +) +\ +s ++ +( +? +P +< +first +> +\ +S ++ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +result += +re +. +replace +( +" +Springsteen +Bruce +" +" +first +last +" +) +; +/ +/ +/ +assert_eq +! +( +result +" +Bruce +Springsteen +" +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +Note +that +using +2 +instead +of +first +or +1 +instead +of +last +/ +/ +/ +would +produce +the +same +result +. +To +write +a +literal +use +. +/ +/ +/ +/ +/ +/ +Sometimes +the +replacement +string +requires +use +of +curly +braces +to +/ +/ +/ +delineate +a +capture +group +replacement +and +surrounding +literal +text +. +/ +/ +/ +For +example +if +we +wanted +to +join +two +words +together +with +an +/ +/ +/ +underscore +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +( +? +P +< +first +> +\ +w ++ +) +\ +s ++ +( +? +P +< +second +> +\ +w ++ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +result += +re +. +replace +( +" +deep +fried +" +" +{ +first +} +_ +second +" +) +; +/ +/ +/ +assert_eq +! +( +result +" +deep_fried +" +) +; +/ +/ +/ +# +} +/ +/ +/ +/ +/ +/ +/ +/ +/ +Without +the +curly +braces +the +capture +group +name +first_ +would +be +/ +/ +/ +used +and +since +it +doesn +' +t +exist +it +would +be +replaced +with +the +empty +/ +/ +/ +string +. +/ +/ +/ +/ +/ +/ +Finally +sometimes +you +just +want +to +replace +a +literal +string +with +no +/ +/ +/ +regard +for +capturing +group +expansion +. +This +can +be +done +by +wrapping +a +/ +/ +/ +byte +string +with +NoExpand +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +use +regex +: +: +NoExpand +; +/ +/ +/ +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +( +? +P +< +last +> +[ +^ +\ +s +] ++ +) +\ +s ++ +( +\ +S ++ +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +result += +re +. +replace +( +" +Springsteen +Bruce +" +NoExpand +( +" +2 +last +" +) +) +; +/ +/ +/ +assert_eq +! +( +result +" +2 +last +" +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +replace +< +' +t +R +: +Replacer +> +( +& +self +text +: +& +' +t +str +rep +: +R +) +- +> +Cow +< +' +t +str +> +{ +self +. +replacen +( +text +1 +rep +) +} +/ +/ +/ +Replaces +all +non +- +overlapping +matches +in +text +with +the +replacement +/ +/ +/ +provided +. +This +is +the +same +as +calling +replacen +with +limit +set +to +/ +/ +/ +0 +. +/ +/ +/ +/ +/ +/ +See +the +documentation +for +replace +for +details +on +how +to +access +/ +/ +/ +capturing +group +matches +in +the +replacement +string +. +pub +fn +replace_all +< +' +t +R +: +Replacer +> +( +& +self +text +: +& +' +t +str +rep +: +R +) +- +> +Cow +< +' +t +str +> +{ +self +. +replacen +( +text +0 +rep +) +} +/ +/ +/ +Replaces +at +most +limit +non +- +overlapping +matches +in +text +with +the +/ +/ +/ +replacement +provided +. +If +limit +is +0 +then +all +non +- +overlapping +matches +/ +/ +/ +are +replaced +. +/ +/ +/ +/ +/ +/ +See +the +documentation +for +replace +for +details +on +how +to +access +/ +/ +/ +capturing +group +matches +in +the +replacement +string +. +pub +fn +replacen +< +' +t +R +: +Replacer +> +( +& +self +text +: +& +' +t +str +limit +: +usize +mut +rep +: +R +) +- +> +Cow +< +' +t +str +> +{ +/ +/ +If +we +know +that +the +replacement +doesn +' +t +have +any +capture +expansions +/ +/ +then +we +can +use +the +fast +path +. +The +fast +path +can +make +a +tremendous +/ +/ +difference +: +/ +/ +/ +/ +1 +) +We +use +find_iter +instead +of +captures_iter +. +Not +asking +for +/ +/ +captures +generally +makes +the +regex +engines +faster +. +/ +/ +2 +) +We +don +' +t +need +to +look +up +all +of +the +capture +groups +and +do +/ +/ +replacements +inside +the +replacement +string +. +We +just +push +it +/ +/ +at +each +match +and +be +done +with +it +. +if +let +Some +( +rep +) += +rep +. +no_expansion +( +) +{ +let +mut +it += +self +. +find_iter +( +text +) +. +enumerate +( +) +. +peekable +( +) +; +if +it +. +peek +( +) +. +is_none +( +) +{ +return +Cow +: +: +Borrowed +( +text +) +; +} +let +mut +new += +String +: +: +with_capacity +( +text +. +len +( +) +) +; +let +mut +last_match += +0 +; +for +( +i +m +) +in +it +{ +new +. +push_str +( +& +text +[ +last_match +. +. +m +. +start +( +) +] +) +; +new +. +push_str +( +& +rep +) +; +last_match += +m +. +end +( +) +; +if +limit +> +0 +& +& +i +> += +limit +- +1 +{ +break +; +} +} +new +. +push_str +( +& +text +[ +last_match +. +. +] +) +; +return +Cow +: +: +Owned +( +new +) +; +} +/ +/ +The +slower +path +which +we +use +if +the +replacement +needs +access +to +/ +/ +capture +groups +. +let +mut +it += +self +. +captures_iter +( +text +) +. +enumerate +( +) +. +peekable +( +) +; +if +it +. +peek +( +) +. +is_none +( +) +{ +return +Cow +: +: +Borrowed +( +text +) +; +} +let +mut +new += +String +: +: +with_capacity +( +text +. +len +( +) +) +; +let +mut +last_match += +0 +; +for +( +i +cap +) +in +it +{ +/ +/ +unwrap +on +0 +is +OK +because +captures +only +reports +matches +let +m += +cap +. +get +( +0 +) +. +unwrap +( +) +; +new +. +push_str +( +& +text +[ +last_match +. +. +m +. +start +( +) +] +) +; +rep +. +replace_append +( +& +cap +& +mut +new +) +; +last_match += +m +. +end +( +) +; +if +limit +> +0 +& +& +i +> += +limit +- +1 +{ +break +; +} +} +new +. +push_str +( +& +text +[ +last_match +. +. +] +) +; +Cow +: +: +Owned +( +new +) +} +} +/ +/ +/ +Advanced +or +" +lower +level +" +search +methods +. +impl +Regex +{ +/ +/ +/ +Returns +the +end +location +of +a +match +in +the +text +given +. +/ +/ +/ +/ +/ +/ +This +method +may +have +the +same +performance +characteristics +as +/ +/ +/ +is_match +except +it +provides +an +end +location +for +a +match +. +In +/ +/ +/ +particular +the +location +returned +* +may +be +shorter +* +than +the +proper +end +/ +/ +/ +of +the +leftmost +- +first +match +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +Typically +a ++ +would +match +the +entire +first +sequence +of +a +in +some +/ +/ +/ +text +but +shortest_match +can +give +up +as +soon +as +it +sees +the +first +/ +/ +/ +a +. +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +# +fn +main +( +) +{ +/ +/ +/ +let +text += +" +aaaaa +" +; +/ +/ +/ +let +pos += +Regex +: +: +new +( +r +" +a ++ +" +) +. +unwrap +( +) +. +shortest_match +( +text +) +; +/ +/ +/ +assert_eq +! +( +pos +Some +( +1 +) +) +; +/ +/ +/ +# +} +/ +/ +/ +pub +fn +shortest_match +( +& +self +text +: +& +str +) +- +> +Option +< +usize +> +{ +self +. +shortest_match_at +( +text +0 +) +} +/ +/ +/ +Returns +the +same +as +shortest_match +but +starts +the +search +at +the +given +/ +/ +/ +offset +. +/ +/ +/ +/ +/ +/ +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding +/ +/ +/ +context +into +consideration +. +For +example +the +\ +A +anchor +can +only +/ +/ +/ +match +when +start += += +0 +. +pub +fn +shortest_match_at +( +& +self +text +: +& +str +start +: +usize +) +- +> +Option +< +usize +> +{ +self +. +0 +. +searcher_str +( +) +. +shortest_match_at +( +text +start +) +} +/ +/ +/ +Returns +the +same +as +is_match +but +starts +the +search +at +the +given +/ +/ +/ +offset +. +/ +/ +/ +/ +/ +/ +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding +/ +/ +/ +context +into +consideration +. +For +example +the +\ +A +anchor +can +only +/ +/ +/ +match +when +start += += +0 +. +pub +fn +is_match_at +( +& +self +text +: +& +str +start +: +usize +) +- +> +bool +{ +self +. +0 +. +searcher_str +( +) +. +is_match_at +( +text +start +) +} +/ +/ +/ +Returns +the +same +as +find +but +starts +the +search +at +the +given +/ +/ +/ +offset +. +/ +/ +/ +/ +/ +/ +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding +/ +/ +/ +context +into +consideration +. +For +example +the +\ +A +anchor +can +only +/ +/ +/ +match +when +start += += +0 +. +pub +fn +find_at +< +' +t +> +( +& +self +text +: +& +' +t +str +start +: +usize +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +0 +. +searcher_str +( +) +. +find_at +( +text +start +) +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +text +s +e +) +) +} +/ +/ +/ +This +is +like +captures +but +uses +/ +/ +/ +[ +CaptureLocations +] +( +struct +. +CaptureLocations +. +html +) +/ +/ +/ +instead +of +/ +/ +/ +[ +Captures +] +( +struct +. +Captures +. +html +) +in +order +to +amortize +allocations +. +/ +/ +/ +/ +/ +/ +To +create +a +CaptureLocations +value +use +the +/ +/ +/ +Regex +: +: +capture_locations +method +. +/ +/ +/ +/ +/ +/ +This +returns +the +overall +match +if +this +was +successful +which +is +always +/ +/ +/ +equivalence +to +the +0 +th +capture +group +. +pub +fn +captures_read +< +' +t +> +( +& +self +locs +: +& +mut +CaptureLocations +text +: +& +' +t +str +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +captures_read_at +( +locs +text +0 +) +} +/ +/ +/ +Returns +the +same +as +captures +but +starts +the +search +at +the +given +/ +/ +/ +offset +and +populates +the +capture +locations +given +. +/ +/ +/ +/ +/ +/ +The +significance +of +the +starting +point +is +that +it +takes +the +surrounding +/ +/ +/ +context +into +consideration +. +For +example +the +\ +A +anchor +can +only +/ +/ +/ +match +when +start += += +0 +. +pub +fn +captures_read_at +< +' +t +> +( +& +self +locs +: +& +mut +CaptureLocations +text +: +& +' +t +str +start +: +usize +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +0 +. +searcher_str +( +) +. +captures_read_at +( +& +mut +locs +. +0 +text +start +) +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +text +s +e +) +) +} +/ +/ +/ +An +undocumented +alias +for +captures_read_at +. +/ +/ +/ +/ +/ +/ +The +regex +- +capi +crate +previously +used +this +routine +so +to +avoid +/ +/ +/ +breaking +that +crate +we +continue +to +provide +the +name +as +an +undocumented +/ +/ +/ +alias +. +# +[ +doc +( +hidden +) +] +pub +fn +read_captures_at +< +' +t +> +( +& +self +locs +: +& +mut +CaptureLocations +text +: +& +' +t +str +start +: +usize +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +captures_read_at +( +locs +text +start +) +} +} +/ +/ +/ +Auxiliary +methods +. +impl +Regex +{ +/ +/ +/ +Returns +the +original +string +of +this +regex +. +pub +fn +as_str +( +& +self +) +- +> +& +str +{ +& +self +. +0 +. +regex_strings +( +) +[ +0 +] +} +/ +/ +/ +Returns +an +iterator +over +the +capture +names +. +pub +fn +capture_names +( +& +self +) +- +> +CaptureNames +< +' +_ +> +{ +CaptureNames +( +self +. +0 +. +capture_names +( +) +. +iter +( +) +) +} +/ +/ +/ +Returns +the +number +of +captures +. +pub +fn +captures_len +( +& +self +) +- +> +usize +{ +self +. +0 +. +capture_names +( +) +. +len +( +) +} +/ +/ +/ +Returns +an +empty +set +of +capture +locations +that +can +be +reused +in +/ +/ +/ +multiple +calls +to +captures_read +or +captures_read_at +. +pub +fn +capture_locations +( +& +self +) +- +> +CaptureLocations +{ +CaptureLocations +( +self +. +0 +. +searcher_str +( +) +. +locations +( +) +) +} +/ +/ +/ +An +alias +for +capture_locations +to +preserve +backward +compatibility +. +/ +/ +/ +/ +/ +/ +The +regex +- +capi +crate +uses +this +method +so +to +avoid +breaking +that +/ +/ +/ +crate +we +continue +to +export +it +as +an +undocumented +API +. +# +[ +doc +( +hidden +) +] +pub +fn +locations +( +& +self +) +- +> +CaptureLocations +{ +CaptureLocations +( +self +. +0 +. +searcher_str +( +) +. +locations +( +) +) +} +} +/ +/ +/ +An +iterator +over +the +names +of +all +possible +captures +. +/ +/ +/ +/ +/ +/ +None +indicates +an +unnamed +capture +; +the +first +element +( +capture +0 +the +/ +/ +/ +whole +matched +region +) +is +always +unnamed +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +CaptureNames +< +' +r +> +( +: +: +std +: +: +slice +: +: +Iter +< +' +r +Option +< +String +> +> +) +; +impl +< +' +r +> +Iterator +for +CaptureNames +< +' +r +> +{ +type +Item += +Option +< +& +' +r +str +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Option +< +& +' +r +str +> +> +{ +self +. +0 +. +next +( +) +. +as_ref +( +) +. +map +( +| +slot +| +slot +. +as_ref +( +) +. +map +( +| +name +| +name +. +as_ref +( +) +) +) +} +fn +size_hint +( +& +self +) +- +> +( +usize +Option +< +usize +> +) +{ +self +. +0 +. +size_hint +( +) +} +fn +count +( +self +) +- +> +usize +{ +self +. +0 +. +count +( +) +} +} +impl +< +' +r +> +ExactSizeIterator +for +CaptureNames +< +' +r +> +{ +} +impl +< +' +r +> +FusedIterator +for +CaptureNames +< +' +r +> +{ +} +/ +/ +/ +Yields +all +substrings +delimited +by +a +regular +expression +match +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +and +' +t +is +the +/ +/ +/ +lifetime +of +the +string +being +split +. +# +[ +derive +( +Debug +) +] +pub +struct +Split +< +' +r +' +t +> +{ +finder +: +Matches +< +' +r +' +t +> +last +: +usize +} +impl +< +' +r +' +t +> +Iterator +for +Split +< +' +r +' +t +> +{ +type +Item += +& +' +t +str +; +fn +next +( +& +mut +self +) +- +> +Option +< +& +' +t +str +> +{ +let +text += +self +. +finder +. +0 +. +text +( +) +; +match +self +. +finder +. +next +( +) +{ +None += +> +{ +if +self +. +last +> +text +. +len +( +) +{ +None +} +else +{ +let +s += +& +text +[ +self +. +last +. +. +] +; +self +. +last += +text +. +len +( +) ++ +1 +; +/ +/ +Next +call +will +return +None +Some +( +s +) +} +} +Some +( +m +) += +> +{ +let +matched += +& +text +[ +self +. +last +. +. +m +. +start +( +) +] +; +self +. +last += +m +. +end +( +) +; +Some +( +matched +) +} +} +} +} +impl +< +' +r +' +t +> +FusedIterator +for +Split +< +' +r +' +t +> +{ +} +/ +/ +/ +Yields +at +most +N +substrings +delimited +by +a +regular +expression +match +. +/ +/ +/ +/ +/ +/ +The +last +substring +will +be +whatever +remains +after +splitting +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +and +' +t +is +the +/ +/ +/ +lifetime +of +the +string +being +split +. +# +[ +derive +( +Debug +) +] +pub +struct +SplitN +< +' +r +' +t +> +{ +splits +: +Split +< +' +r +' +t +> +n +: +usize +} +impl +< +' +r +' +t +> +Iterator +for +SplitN +< +' +r +' +t +> +{ +type +Item += +& +' +t +str +; +fn +next +( +& +mut +self +) +- +> +Option +< +& +' +t +str +> +{ +if +self +. +n += += +0 +{ +return +None +; +} +self +. +n +- += +1 +; +if +self +. +n +> +0 +{ +return +self +. +splits +. +next +( +) +; +} +let +text += +self +. +splits +. +finder +. +0 +. +text +( +) +; +if +self +. +splits +. +last +> +text +. +len +( +) +{ +/ +/ +We +' +ve +already +returned +all +substrings +. +None +} +else +{ +/ +/ +self +. +n += += +0 +so +future +calls +will +return +None +immediately +Some +( +& +text +[ +self +. +splits +. +last +. +. +] +) +} +} +fn +size_hint +( +& +self +) +- +> +( +usize +Option +< +usize +> +) +{ +( +0 +Some +( +self +. +n +) +) +} +} +impl +< +' +r +' +t +> +FusedIterator +for +SplitN +< +' +r +' +t +> +{ +} +/ +/ +/ +CaptureLocations +is +a +low +level +representation +of +the +raw +offsets +of +each +/ +/ +/ +submatch +. +/ +/ +/ +/ +/ +/ +You +can +think +of +this +as +a +lower +level +/ +/ +/ +[ +Captures +] +( +struct +. +Captures +. +html +) +where +this +type +does +not +support +/ +/ +/ +named +capturing +groups +directly +and +it +does +not +borrow +the +text +that +these +/ +/ +/ +offsets +were +matched +on +. +/ +/ +/ +/ +/ +/ +Primarily +this +type +is +useful +when +using +the +lower +level +Regex +APIs +/ +/ +/ +such +as +read_captures +which +permits +amortizing +the +allocation +in +which +/ +/ +/ +capture +match +locations +are +stored +. +/ +/ +/ +/ +/ +/ +In +order +to +build +a +value +of +this +type +you +' +ll +need +to +call +the +/ +/ +/ +capture_locations +method +on +the +Regex +being +used +to +execute +the +search +. +/ +/ +/ +The +value +returned +can +then +be +reused +in +subsequent +searches +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +CaptureLocations +( +re_trait +: +: +Locations +) +; +/ +/ +/ +A +type +alias +for +CaptureLocations +for +backwards +compatibility +. +/ +/ +/ +/ +/ +/ +Previously +we +exported +CaptureLocations +as +Locations +in +an +/ +/ +/ +undocumented +API +. +To +prevent +breaking +that +code +( +e +. +g +. +in +regex +- +capi +) +/ +/ +/ +we +continue +re +- +exporting +the +same +undocumented +API +. +# +[ +doc +( +hidden +) +] +pub +type +Locations += +CaptureLocations +; +impl +CaptureLocations +{ +/ +/ +/ +Returns +the +start +and +end +positions +of +the +Nth +capture +group +. +Returns +/ +/ +/ +None +if +i +is +not +a +valid +capture +group +or +if +the +capture +group +did +/ +/ +/ +not +match +anything +. +The +positions +returned +are +* +always +* +byte +indices +/ +/ +/ +with +respect +to +the +original +string +matched +. +# +[ +inline +] +pub +fn +get +( +& +self +i +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +self +. +0 +. +pos +( +i +) +} +/ +/ +/ +Returns +the +total +number +of +capture +groups +( +even +if +they +didn +' +t +match +) +. +/ +/ +/ +/ +/ +/ +This +is +always +at +least +1 +since +every +regex +has +at +least +1 +/ +/ +/ +capturing +group +that +corresponds +to +the +entire +match +. +# +[ +inline +] +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +0 +. +len +( +) +} +/ +/ +/ +An +alias +for +the +get +method +for +backwards +compatibility +. +/ +/ +/ +/ +/ +/ +Previously +we +exported +get +as +pos +in +an +undocumented +API +. +To +/ +/ +/ +prevent +breaking +that +code +( +e +. +g +. +in +regex +- +capi +) +we +continue +/ +/ +/ +re +- +exporting +the +same +undocumented +API +. +# +[ +doc +( +hidden +) +] +# +[ +inline +] +pub +fn +pos +( +& +self +i +: +usize +) +- +> +Option +< +( +usize +usize +) +> +{ +self +. +get +( +i +) +} +} +/ +/ +/ +Captures +represents +a +group +of +captured +strings +for +a +single +match +. +/ +/ +/ +/ +/ +/ +The +0th +capture +always +corresponds +to +the +entire +match +. +Each +subsequent +/ +/ +/ +index +corresponds +to +the +next +capture +group +in +the +regex +. +If +a +capture +/ +/ +/ +group +is +named +then +the +matched +string +is +* +also +* +available +via +the +name +/ +/ +/ +method +. +( +Note +that +the +0th +capture +is +always +unnamed +and +so +must +be +/ +/ +/ +accessed +with +the +get +method +. +) +/ +/ +/ +/ +/ +/ +Positions +returned +from +a +capture +group +are +always +byte +indices +. +/ +/ +/ +/ +/ +/ +' +t +is +the +lifetime +of +the +matched +text +. +pub +struct +Captures +< +' +t +> +{ +text +: +& +' +t +str +locs +: +re_trait +: +: +Locations +named_groups +: +Arc +< +HashMap +< +String +usize +> +> +} +impl +< +' +t +> +Captures +< +' +t +> +{ +/ +/ +/ +Returns +the +match +associated +with +the +capture +group +at +index +i +. +If +/ +/ +/ +i +does +not +correspond +to +a +capture +group +or +if +the +capture +group +/ +/ +/ +did +not +participate +in +the +match +then +None +is +returned +. +/ +/ +/ +/ +/ +/ +# +Examples +/ +/ +/ +/ +/ +/ +Get +the +text +of +the +match +with +a +default +of +an +empty +string +if +this +/ +/ +/ +group +didn +' +t +participate +in +the +match +: +/ +/ +/ +/ +/ +/ +rust +/ +/ +/ +# +use +regex +: +: +Regex +; +/ +/ +/ +let +re += +Regex +: +: +new +( +r +" +[ +a +- +z +] ++ +( +? +: +( +[ +0 +- +9 +] ++ +) +| +( +[ +A +- +Z +] ++ +) +) +" +) +. +unwrap +( +) +; +/ +/ +/ +let +caps += +re +. +captures +( +" +abc123 +" +) +. +unwrap +( +) +; +/ +/ +/ +/ +/ +/ +let +text1 += +caps +. +get +( +1 +) +. +map_or +( +" +" +| +m +| +m +. +as_str +( +) +) +; +/ +/ +/ +let +text2 += +caps +. +get +( +2 +) +. +map_or +( +" +" +| +m +| +m +. +as_str +( +) +) +; +/ +/ +/ +assert_eq +! +( +text1 +" +123 +" +) +; +/ +/ +/ +assert_eq +! +( +text2 +" +" +) +; +/ +/ +/ +pub +fn +get +( +& +self +i +: +usize +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +locs +. +pos +( +i +) +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +self +. +text +s +e +) +) +} +/ +/ +/ +Returns +the +match +for +the +capture +group +named +name +. +If +name +isn +' +t +a +/ +/ +/ +valid +capture +group +or +didn +' +t +match +anything +then +None +is +returned +. +pub +fn +name +( +& +self +name +: +& +str +) +- +> +Option +< +Match +< +' +t +> +> +{ +self +. +named_groups +. +get +( +name +) +. +and_then +( +| +& +i +| +self +. +get +( +i +) +) +} +/ +/ +/ +An +iterator +that +yields +all +capturing +matches +in +the +order +in +which +/ +/ +/ +they +appear +in +the +regex +. +If +a +particular +capture +group +didn +' +t +/ +/ +/ +participate +in +the +match +then +None +is +yielded +for +that +capture +. +/ +/ +/ +/ +/ +/ +The +first +match +always +corresponds +to +the +overall +match +of +the +regex +. +pub +fn +iter +< +' +c +> +( +& +' +c +self +) +- +> +SubCaptureMatches +< +' +c +' +t +> +{ +SubCaptureMatches +{ +caps +: +self +it +: +self +. +locs +. +iter +( +) +} +} +/ +/ +/ +Expands +all +instances +of +name +in +replacement +to +the +corresponding +/ +/ +/ +capture +group +name +and +writes +them +to +the +dst +buffer +given +. +/ +/ +/ +/ +/ +/ +name +may +be +an +integer +corresponding +to +the +index +of +the +capture +/ +/ +/ +group +( +counted +by +order +of +opening +parenthesis +where +0 +is +the +/ +/ +/ +entire +match +) +or +it +can +be +a +name +( +consisting +of +letters +digits +or +/ +/ +/ +underscores +) +corresponding +to +a +named +capture +group +. +/ +/ +/ +/ +/ +/ +If +name +isn +' +t +a +valid +capture +group +( +whether +the +name +doesn +' +t +exist +/ +/ +/ +or +isn +' +t +a +valid +index +) +then +it +is +replaced +with +the +empty +string +. +/ +/ +/ +/ +/ +/ +The +longest +possible +name +consisting +of +the +characters +[ +_0 +- +9A +- +Za +- +z +] +/ +/ +/ +is +used +. +e +. +g +. +1a +looks +up +the +capture +group +named +1a +and +not +the +/ +/ +/ +capture +group +at +index +1 +. +To +exert +more +precise +control +over +the +/ +/ +/ +name +or +to +refer +to +a +capture +group +name +that +uses +characters +outside +/ +/ +/ +of +[ +_0 +- +9A +- +Za +- +z +] +use +braces +e +. +g +. +{ +1 +} +a +or +{ +foo +[ +bar +] +. +baz +} +. +When +/ +/ +/ +using +braces +any +sequence +of +characters +is +permitted +. +If +the +sequence +/ +/ +/ +does +not +refer +to +a +capture +group +name +in +the +corresponding +regex +then +/ +/ +/ +it +is +replaced +with +an +empty +string +. +/ +/ +/ +/ +/ +/ +To +write +a +literal +use +. +pub +fn +expand +( +& +self +replacement +: +& +str +dst +: +& +mut +String +) +{ +expand_str +( +self +replacement +dst +) +} +/ +/ +/ +Returns +the +total +number +of +capture +groups +( +even +if +they +didn +' +t +match +) +. +/ +/ +/ +/ +/ +/ +This +is +always +at +least +1 +since +every +regex +has +at +least +one +capture +/ +/ +/ +group +that +corresponds +to +the +full +match +. +# +[ +inline +] +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +locs +. +len +( +) +} +} +impl +< +' +t +> +fmt +: +: +Debug +for +Captures +< +' +t +> +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +f +. +debug_tuple +( +" +Captures +" +) +. +field +( +& +CapturesDebug +( +self +) +) +. +finish +( +) +} +} +struct +CapturesDebug +< +' +c +' +t +> +( +& +' +c +Captures +< +' +t +> +) +; +impl +< +' +c +' +t +> +fmt +: +: +Debug +for +CapturesDebug +< +' +c +' +t +> +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +/ +/ +We +' +d +like +to +show +something +nice +here +even +if +it +means +an +/ +/ +allocation +to +build +a +reverse +index +. +let +slot_to_name +: +HashMap +< +& +usize +& +String +> += +self +. +0 +. +named_groups +. +iter +( +) +. +map +( +| +( +a +b +) +| +( +b +a +) +) +. +collect +( +) +; +let +mut +map += +f +. +debug_map +( +) +; +for +( +slot +m +) +in +self +. +0 +. +locs +. +iter +( +) +. +enumerate +( +) +{ +let +m += +m +. +map +( +| +( +s +e +) +| +& +self +. +0 +. +text +[ +s +. +. +e +] +) +; +if +let +Some +( +name +) += +slot_to_name +. +get +( +& +slot +) +{ +map +. +entry +( +& +name +& +m +) +; +} +else +{ +map +. +entry +( +& +slot +& +m +) +; +} +} +map +. +finish +( +) +} +} +/ +/ +/ +Get +a +group +by +index +. +/ +/ +/ +/ +/ +/ +' +t +is +the +lifetime +of +the +matched +text +. +/ +/ +/ +/ +/ +/ +The +text +can +' +t +outlive +the +Captures +object +if +this +method +is +/ +/ +/ +used +because +of +how +Index +is +defined +( +normally +a +[ +i +] +is +part +/ +/ +/ +of +a +and +can +' +t +outlive +it +) +; +to +do +that +use +get +( +) +instead +. +/ +/ +/ +/ +/ +/ +# +Panics +/ +/ +/ +/ +/ +/ +If +there +is +no +group +at +the +given +index +. +impl +< +' +t +> +Index +< +usize +> +for +Captures +< +' +t +> +{ +type +Output += +str +; +fn +index +( +& +self +i +: +usize +) +- +> +& +str +{ +self +. +get +( +i +) +. +map +( +| +m +| +m +. +as_str +( +) +) +. +unwrap_or_else +( +| +| +panic +! +( +" +no +group +at +index +' +{ +} +' +" +i +) +) +} +} +/ +/ +/ +Get +a +group +by +name +. +/ +/ +/ +/ +/ +/ +' +t +is +the +lifetime +of +the +matched +text +and +' +i +is +the +lifetime +/ +/ +/ +of +the +group +name +( +the +index +) +. +/ +/ +/ +/ +/ +/ +The +text +can +' +t +outlive +the +Captures +object +if +this +method +is +/ +/ +/ +used +because +of +how +Index +is +defined +( +normally +a +[ +i +] +is +part +/ +/ +/ +of +a +and +can +' +t +outlive +it +) +; +to +do +that +use +name +instead +. +/ +/ +/ +/ +/ +/ +# +Panics +/ +/ +/ +/ +/ +/ +If +there +is +no +group +named +by +the +given +value +. +impl +< +' +t +' +i +> +Index +< +& +' +i +str +> +for +Captures +< +' +t +> +{ +type +Output += +str +; +fn +index +< +' +a +> +( +& +' +a +self +name +: +& +' +i +str +) +- +> +& +' +a +str +{ +self +. +name +( +name +) +. +map +( +| +m +| +m +. +as_str +( +) +) +. +unwrap_or_else +( +| +| +panic +! +( +" +no +group +named +' +{ +} +' +" +name +) +) +} +} +/ +/ +/ +An +iterator +that +yields +all +capturing +matches +in +the +order +in +which +they +/ +/ +/ +appear +in +the +regex +. +/ +/ +/ +/ +/ +/ +If +a +particular +capture +group +didn +' +t +participate +in +the +match +then +None +/ +/ +/ +is +yielded +for +that +capture +. +The +first +match +always +corresponds +to +the +/ +/ +/ +overall +match +of +the +regex +. +/ +/ +/ +/ +/ +/ +The +lifetime +' +c +corresponds +to +the +lifetime +of +the +Captures +value +and +/ +/ +/ +the +lifetime +' +t +corresponds +to +the +originally +matched +text +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +SubCaptureMatches +< +' +c +' +t +> +{ +caps +: +& +' +c +Captures +< +' +t +> +it +: +SubCapturesPosIter +< +' +c +> +} +impl +< +' +c +' +t +> +Iterator +for +SubCaptureMatches +< +' +c +' +t +> +{ +type +Item += +Option +< +Match +< +' +t +> +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Option +< +Match +< +' +t +> +> +> +{ +self +. +it +. +next +( +) +. +map +( +| +cap +| +cap +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +self +. +caps +. +text +s +e +) +) +) +} +fn +size_hint +( +& +self +) +- +> +( +usize +Option +< +usize +> +) +{ +self +. +it +. +size_hint +( +) +} +fn +count +( +self +) +- +> +usize +{ +self +. +it +. +count +( +) +} +} +impl +< +' +c +' +t +> +ExactSizeIterator +for +SubCaptureMatches +< +' +c +' +t +> +{ +} +impl +< +' +c +' +t +> +FusedIterator +for +SubCaptureMatches +< +' +c +' +t +> +{ +} +/ +/ +/ +An +iterator +that +yields +all +non +- +overlapping +capture +groups +matching +a +/ +/ +/ +particular +regular +expression +. +/ +/ +/ +/ +/ +/ +The +iterator +stops +when +no +more +matches +can +be +found +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +and +' +t +is +the +/ +/ +/ +lifetime +of +the +matched +string +. +# +[ +derive +( +Debug +) +] +pub +struct +CaptureMatches +< +' +r +' +t +> +( +re_trait +: +: +CaptureMatches +< +' +t +ExecNoSyncStr +< +' +r +> +> +) +; +impl +< +' +r +' +t +> +Iterator +for +CaptureMatches +< +' +r +' +t +> +{ +type +Item += +Captures +< +' +t +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Captures +< +' +t +> +> +{ +self +. +0 +. +next +( +) +. +map +( +| +locs +| +Captures +{ +text +: +self +. +0 +. +text +( +) +locs +named_groups +: +self +. +0 +. +regex +( +) +. +capture_name_idx +( +) +. +clone +( +) +} +) +} +} +impl +< +' +r +' +t +> +FusedIterator +for +CaptureMatches +< +' +r +' +t +> +{ +} +/ +/ +/ +An +iterator +over +all +non +- +overlapping +matches +for +a +particular +string +. +/ +/ +/ +/ +/ +/ +The +iterator +yields +a +Match +value +. +The +iterator +stops +when +no +more +/ +/ +/ +matches +can +be +found +. +/ +/ +/ +/ +/ +/ +' +r +is +the +lifetime +of +the +compiled +regular +expression +and +' +t +is +the +/ +/ +/ +lifetime +of +the +matched +string +. +# +[ +derive +( +Debug +) +] +pub +struct +Matches +< +' +r +' +t +> +( +re_trait +: +: +Matches +< +' +t +ExecNoSyncStr +< +' +r +> +> +) +; +impl +< +' +r +' +t +> +Iterator +for +Matches +< +' +r +' +t +> +{ +type +Item += +Match +< +' +t +> +; +fn +next +( +& +mut +self +) +- +> +Option +< +Match +< +' +t +> +> +{ +let +text += +self +. +0 +. +text +( +) +; +self +. +0 +. +next +( +) +. +map +( +| +( +s +e +) +| +Match +: +: +new +( +text +s +e +) +) +} +} +impl +< +' +r +' +t +> +FusedIterator +for +Matches +< +' +r +' +t +> +{ +} +/ +/ +/ +Replacer +describes +types +that +can +be +used +to +replace +matches +in +a +string +. +/ +/ +/ +/ +/ +/ +In +general +users +of +this +crate +shouldn +' +t +need +to +implement +this +trait +/ +/ +/ +since +implementations +are +already +provided +for +& +str +along +with +other +/ +/ +/ +variants +of +string +types +and +FnMut +( +& +Captures +) +- +> +String +( +or +any +/ +/ +/ +FnMut +( +& +Captures +) +- +> +T +where +T +: +AsRef +< +str +> +) +which +covers +most +use +cases +. +pub +trait +Replacer +{ +/ +/ +/ +Appends +text +to +dst +to +replace +the +current +match +. +/ +/ +/ +/ +/ +/ +The +current +match +is +represented +by +caps +which +is +guaranteed +to +/ +/ +/ +have +a +match +at +capture +group +0 +. +/ +/ +/ +/ +/ +/ +For +example +a +no +- +op +replacement +would +be +/ +/ +/ +dst +. +push_str +( +caps +. +get +( +0 +) +. +unwrap +( +) +. +as_str +( +) +) +. +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +; +/ +/ +/ +Return +a +fixed +unchanging +replacement +string +. +/ +/ +/ +/ +/ +/ +When +doing +replacements +if +access +to +Captures +is +not +needed +( +e +. +g +. +/ +/ +/ +the +replacement +byte +string +does +not +need +expansion +) +then +it +can +/ +/ +/ +be +beneficial +to +avoid +finding +sub +- +captures +. +/ +/ +/ +/ +/ +/ +In +general +this +is +called +once +for +every +call +to +replacen +. +fn +no_expansion +< +' +r +> +( +& +' +r +mut +self +) +- +> +Option +< +Cow +< +' +r +str +> +> +{ +None +} +/ +/ +/ +Return +a +Replacer +that +borrows +and +wraps +this +Replacer +. +/ +/ +/ +/ +/ +/ +This +is +useful +when +you +want +to +take +a +generic +Replacer +( +which +might +/ +/ +/ +not +be +cloneable +) +and +use +it +without +consuming +it +so +it +can +be +used +/ +/ +/ +more +than +once +. +/ +/ +/ +/ +/ +/ +# +Example +/ +/ +/ +/ +/ +/ +/ +/ +/ +use +regex +: +: +{ +Regex +Replacer +} +; +/ +/ +/ +/ +/ +/ +fn +replace_all_twice +< +R +: +Replacer +> +( +/ +/ +/ +re +: +Regex +/ +/ +/ +src +: +& +str +/ +/ +/ +mut +rep +: +R +/ +/ +/ +) +- +> +String +{ +/ +/ +/ +let +dst += +re +. +replace_all +( +src +rep +. +by_ref +( +) +) +; +/ +/ +/ +let +dst += +re +. +replace_all +( +& +dst +rep +. +by_ref +( +) +) +; +/ +/ +/ +dst +. +into_owned +( +) +/ +/ +/ +} +/ +/ +/ +fn +by_ref +< +' +r +> +( +& +' +r +mut +self +) +- +> +ReplacerRef +< +' +r +Self +> +{ +ReplacerRef +( +self +) +} +} +/ +/ +/ +By +- +reference +adaptor +for +a +Replacer +/ +/ +/ +/ +/ +/ +Returned +by +[ +Replacer +: +: +by_ref +] +( +trait +. +Replacer +. +html +# +method +. +by_ref +) +. +# +[ +derive +( +Debug +) +] +pub +struct +ReplacerRef +< +' +a +R +: +? +Sized +> +( +& +' +a +mut +R +) +; +impl +< +' +a +R +: +Replacer ++ +? +Sized ++ +' +a +> +Replacer +for +ReplacerRef +< +' +a +R +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +{ +self +. +0 +. +replace_append +( +caps +dst +) +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +str +> +> +{ +self +. +0 +. +no_expansion +( +) +} +} +impl +< +' +a +> +Replacer +for +& +' +a +str +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +{ +caps +. +expand +( +* +self +dst +) +; +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +str +> +> +{ +no_expansion +( +self +) +} +} +impl +< +' +a +> +Replacer +for +& +' +a +String +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +{ +self +. +as_str +( +) +. +replace_append +( +caps +dst +) +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +str +> +> +{ +no_expansion +( +self +) +} +} +impl +Replacer +for +String +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +{ +self +. +as_str +( +) +. +replace_append +( +caps +dst +) +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +str +> +> +{ +no_expansion +( +self +) +} +} +impl +< +' +a +> +Replacer +for +Cow +< +' +a +str +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +{ +self +. +as_ref +( +) +. +replace_append +( +caps +dst +) +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +str +> +> +{ +no_expansion +( +self +) +} +} +impl +< +' +a +> +Replacer +for +& +' +a +Cow +< +' +a +str +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +{ +self +. +as_ref +( +) +. +replace_append +( +caps +dst +) +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +str +> +> +{ +no_expansion +( +self +) +} +} +fn +no_expansion +< +T +: +AsRef +< +str +> +> +( +t +: +& +T +) +- +> +Option +< +Cow +< +' +_ +str +> +> +{ +let +s += +t +. +as_ref +( +) +; +match +find_byte +( +b +' +' +s +. +as_bytes +( +) +) +{ +Some +( +_ +) += +> +None +None += +> +Some +( +Cow +: +: +Borrowed +( +s +) +) +} +} +impl +< +F +T +> +Replacer +for +F +where +F +: +FnMut +( +& +Captures +< +' +_ +> +) +- +> +T +T +: +AsRef +< +str +> +{ +fn +replace_append +( +& +mut +self +caps +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +{ +dst +. +push_str +( +( +* +self +) +( +caps +) +. +as_ref +( +) +) +; +} +} +/ +/ +/ +NoExpand +indicates +literal +string +replacement +. +/ +/ +/ +/ +/ +/ +It +can +be +used +with +replace +and +replace_all +to +do +a +literal +string +/ +/ +/ +replacement +without +expanding +name +to +their +corresponding +capture +/ +/ +/ +groups +. +This +can +be +both +convenient +( +to +avoid +escaping +for +example +) +/ +/ +/ +and +performant +( +since +capture +groups +don +' +t +need +to +be +found +) +. +/ +/ +/ +/ +/ +/ +' +t +is +the +lifetime +of +the +literal +text +. +# +[ +derive +( +Clone +Debug +) +] +pub +struct +NoExpand +< +' +t +> +( +pub +& +' +t +str +) +; +impl +< +' +t +> +Replacer +for +NoExpand +< +' +t +> +{ +fn +replace_append +( +& +mut +self +_ +: +& +Captures +< +' +_ +> +dst +: +& +mut +String +) +{ +dst +. +push_str +( +self +. +0 +) +; +} +fn +no_expansion +( +& +mut +self +) +- +> +Option +< +Cow +< +' +_ +str +> +> +{ +Some +( +Cow +: +: +Borrowed +( +self +. +0 +) +) +} +} diff --git a/third_party/rust/regex/src/regex/bytes.rs b/third_party/rust/regex/src/regex/bytes.rs deleted file mode 100644 index 2a762e7cac505..0000000000000 --- a/third_party/rust/regex/src/regex/bytes.rs +++ /dev/null @@ -1,28334 +0,0 @@ -use -alloc -: -: -{ -borrow -: -: -Cow -string -: -: -String -sync -: -: -Arc -vec -: -: -Vec -} -; -use -regex_automata -: -: -{ -meta -util -: -: -captures -Input -PatternID -} -; -use -crate -: -: -{ -bytes -: -: -RegexBuilder -error -: -: -Error -} -; -/ -/ -/ -A -compiled -regular -expression -for -searching -Unicode -haystacks -. -/ -/ -/ -/ -/ -/ -A -Regex -can -be -used -to -search -haystacks -split -haystacks -into -substrings -/ -/ -/ -or -replace -substrings -in -a -haystack -with -a -different -substring -. -All -/ -/ -/ -searching -is -done -with -an -implicit -( -? -s -: -. -) -* -? -at -the -beginning -and -end -of -/ -/ -/ -an -pattern -. -To -force -an -expression -to -match -the -whole -string -( -or -a -prefix -/ -/ -/ -or -a -suffix -) -you -must -use -an -anchor -like -^ -or -( -or -\ -A -and -\ -z -) -. -/ -/ -/ -/ -/ -/ -Like -the -Regex -type -in -the -parent -module -matches -with -this -regex -return -/ -/ -/ -byte -offsets -into -the -haystack -. -* -* -Unlike -* -* -the -parent -Regex -type -these -/ -/ -/ -byte -offsets -may -not -correspond -to -UTF -- -8 -sequence -boundaries -since -the -/ -/ -/ -regexes -in -this -module -can -match -arbitrary -bytes -. -/ -/ -/ -/ -/ -/ -The -only -methods -that -allocate -new -byte -strings -are -the -string -replacement -/ -/ -/ -methods -. -All -other -methods -( -searching -and -splitting -) -return -borrowed -/ -/ -/ -references -into -the -haystack -given -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Find -the -offsets -of -a -US -phone -number -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -[ -0 -- -9 -] -{ -3 -} -- -[ -0 -- -9 -] -{ -3 -} -- -[ -0 -- -9 -] -{ -4 -} -" -) -. -unwrap -( -) -; -/ -/ -/ -let -m -= -re -. -find -( -b -" -phone -: -111 -- -222 -- -3333 -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -7 -. -. -19 -m -. -range -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -extracting -capture -groups -/ -/ -/ -/ -/ -/ -A -common -way -to -use -regexes -is -with -capture -groups -. -That -is -instead -of -/ -/ -/ -just -looking -for -matches -of -an -entire -regex -parentheses -are -used -to -create -/ -/ -/ -groups -that -represent -part -of -the -match -. -/ -/ -/ -/ -/ -/ -For -example -consider -a -haystack -with -multiple -lines -and -each -line -has -/ -/ -/ -three -whitespace -delimited -fields -where -the -second -field -is -expected -to -be -/ -/ -/ -a -number -and -the -third -field -a -boolean -. -To -make -this -convenient -we -use -/ -/ -/ -the -[ -Captures -: -: -extract -] -API -to -put -the -strings -that -match -each -group -/ -/ -/ -into -a -fixed -size -array -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -hay -= -b -" -/ -/ -/ -rabbit -54 -true -/ -/ -/ -groundhog -2 -true -/ -/ -/ -does -not -match -/ -/ -/ -fox -109 -false -/ -/ -/ -" -; -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -\ -s -* -( -\ -S -+ -) -\ -s -+ -( -[ -0 -- -9 -] -+ -) -\ -s -+ -( -true -| -false -) -\ -s -* -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -fields -: -Vec -< -( -& -[ -u8 -] -i64 -bool -) -> -= -vec -! -[ -] -; -/ -/ -/ -for -( -_ -[ -f1 -f2 -f3 -] -) -in -re -. -captures_iter -( -hay -) -. -map -( -| -caps -| -caps -. -extract -( -) -) -{ -/ -/ -/ -/ -/ -These -unwraps -are -OK -because -our -pattern -is -written -in -a -way -where -/ -/ -/ -/ -/ -all -matches -for -f2 -and -f3 -will -be -valid -UTF -- -8 -. -/ -/ -/ -let -f2 -= -std -: -: -str -: -: -from_utf8 -( -f2 -) -. -unwrap -( -) -; -/ -/ -/ -let -f3 -= -std -: -: -str -: -: -from_utf8 -( -f3 -) -. -unwrap -( -) -; -/ -/ -/ -fields -. -push -( -( -f1 -f2 -. -parse -( -) -? -f3 -. -parse -( -) -? -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -fields -vec -! -[ -/ -/ -/ -( -& -b -" -rabbit -" -[ -. -. -] -54 -true -) -/ -/ -/ -( -& -b -" -groundhog -" -[ -. -. -] -2 -true -) -/ -/ -/ -( -& -b -" -fox -" -[ -. -. -] -109 -false -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -matching -invalid -UTF -- -8 -/ -/ -/ -/ -/ -/ -One -of -the -reasons -for -searching -& -[ -u8 -] -haystacks -is -that -the -& -[ -u8 -] -/ -/ -/ -might -not -be -valid -UTF -- -8 -. -Indeed -with -a -bytes -: -: -Regex -patterns -that -/ -/ -/ -match -invalid -UTF -- -8 -are -explicitly -allowed -. -Here -' -s -one -example -that -looks -/ -/ -/ -for -valid -UTF -- -8 -fields -that -might -be -separated -by -invalid -UTF -- -8 -. -In -this -/ -/ -/ -case -we -use -( -? -s -- -u -: -. -) -which -matches -any -byte -. -Attempting -to -use -it -in -a -/ -/ -/ -top -- -level -Regex -will -result -in -the -regex -failing -to -compile -. -Notice -also -/ -/ -/ -that -we -use -. -with -Unicode -mode -enabled -in -which -case -only -valid -UTF -- -8 -/ -/ -/ -is -matched -. -In -this -way -we -can -build -one -pattern -where -some -parts -only -/ -/ -/ -match -valid -UTF -- -8 -while -other -parts -are -more -permissive -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -/ -/ -F0 -9F -92 -A9 -is -the -UTF -- -8 -encoding -for -a -Pile -of -Poo -. -/ -/ -/ -let -hay -= -b -" -\ -xFF -\ -xFFfoo -\ -xFF -\ -xFF -\ -xFF -\ -xF0 -\ -x9F -\ -x92 -\ -xA9 -\ -xFF -" -; -/ -/ -/ -/ -/ -An -equivalent -to -' -( -? -s -- -u -: -. -) -' -is -' -( -? -- -u -: -[ -\ -x00 -- -\ -xFF -] -) -' -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -s -) -( -? -- -u -: -. -) -* -? -( -? -< -f1 -> -. -+ -) -( -? -- -u -: -. -) -* -? -( -? -< -f2 -> -. -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -f1 -" -] -& -b -" -foo -" -[ -. -. -] -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -f2 -" -] -" -" -. -as_bytes -( -) -) -; -/ -/ -/ -# -[ -derive -( -Clone -) -] -pub -struct -Regex -{ -pub -( -crate -) -meta -: -meta -: -: -Regex -pub -( -crate -) -pattern -: -Arc -< -str -> -} -impl -core -: -: -fmt -: -: -Display -for -Regex -{ -/ -/ -/ -Shows -the -original -regular -expression -. -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -} -" -self -. -as_str -( -) -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -Regex -{ -/ -/ -/ -Shows -the -original -regular -expression -. -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -" -Regex -" -) -. -field -( -& -self -. -as_str -( -) -) -. -finish -( -) -} -} -impl -core -: -: -str -: -: -FromStr -for -Regex -{ -type -Err -= -Error -; -/ -/ -/ -Attempts -to -parse -a -string -into -a -regular -expression -fn -from_str -( -s -: -& -str -) -- -> -Result -< -Regex -Error -> -{ -Regex -: -: -new -( -s -) -} -} -impl -TryFrom -< -& -str -> -for -Regex -{ -type -Error -= -Error -; -/ -/ -/ -Attempts -to -parse -a -string -into -a -regular -expression -fn -try_from -( -s -: -& -str -) -- -> -Result -< -Regex -Error -> -{ -Regex -: -: -new -( -s -) -} -} -impl -TryFrom -< -String -> -for -Regex -{ -type -Error -= -Error -; -/ -/ -/ -Attempts -to -parse -a -string -into -a -regular -expression -fn -try_from -( -s -: -String -) -- -> -Result -< -Regex -Error -> -{ -Regex -: -: -new -( -& -s -) -} -} -/ -/ -/ -Core -regular -expression -methods -. -impl -Regex -{ -/ -/ -/ -Compiles -a -regular -expression -. -Once -compiled -it -can -be -used -repeatedly -/ -/ -/ -to -search -split -or -replace -substrings -in -a -haystack -. -/ -/ -/ -/ -/ -/ -Note -that -regex -compilation -tends -to -be -a -somewhat -expensive -process -/ -/ -/ -and -unlike -higher -level -environments -compilation -is -not -automatically -/ -/ -/ -cached -for -you -. -One -should -endeavor -to -compile -a -regex -once -and -then -/ -/ -/ -reuse -it -. -For -example -it -' -s -a -bad -idea -to -compile -the -same -regex -/ -/ -/ -repeatedly -in -a -loop -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -If -an -invalid -pattern -is -given -then -an -error -is -returned -. -/ -/ -/ -An -error -is -also -returned -if -the -pattern -is -valid -but -would -/ -/ -/ -produce -a -regex -that -is -bigger -than -the -configured -size -limit -via -/ -/ -/ -[ -RegexBuilder -: -: -size_limit -] -. -( -A -reasonable -size -limit -is -enabled -by -/ -/ -/ -default -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -/ -/ -An -Invalid -pattern -because -of -an -unclosed -parenthesis -/ -/ -/ -assert -! -( -Regex -: -: -new -( -r -" -foo -( -bar -" -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -An -invalid -pattern -because -the -regex -would -be -too -big -/ -/ -/ -/ -/ -because -Unicode -tends -to -inflate -things -. -/ -/ -/ -assert -! -( -Regex -: -: -new -( -r -" -\ -w -{ -1000 -} -" -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -Disabling -Unicode -can -make -the -regex -much -smaller -/ -/ -/ -/ -/ -potentially -by -up -to -or -more -than -an -order -of -magnitude -. -/ -/ -/ -assert -! -( -Regex -: -: -new -( -r -" -( -? -- -u -: -\ -w -) -{ -1000 -} -" -) -. -is_ok -( -) -) -; -/ -/ -/ -pub -fn -new -( -re -: -& -str -) -- -> -Result -< -Regex -Error -> -{ -RegexBuilder -: -: -new -( -re -) -. -build -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -there -is -a -match -for -the -regex -anywhere -/ -/ -/ -in -the -haystack -given -. -/ -/ -/ -/ -/ -/ -It -is -recommended -to -use -this -method -if -all -you -need -to -do -is -test -/ -/ -/ -whether -a -match -exists -since -the -underlying -matching -engine -may -be -/ -/ -/ -able -to -do -less -work -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Test -if -some -haystack -contains -at -least -one -word -with -exactly -13 -/ -/ -/ -Unicode -word -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -b -\ -w -{ -13 -} -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -I -categorically -deny -having -triskaidekaphobia -. -" -; -/ -/ -/ -assert -! -( -re -. -is_match -( -hay -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -( -& -self -haystack -: -& -[ -u8 -] -) -- -> -bool -{ -self -. -is_match_at -( -haystack -0 -) -} -/ -/ -/ -This -routine -searches -for -the -first -match -of -this -regex -in -the -/ -/ -/ -haystack -given -and -if -found -returns -a -[ -Match -] -. -The -Match -/ -/ -/ -provides -access -to -both -the -byte -offsets -of -the -match -and -the -actual -/ -/ -/ -substring -that -matched -. -/ -/ -/ -/ -/ -/ -Note -that -this -should -only -be -used -if -you -want -to -find -the -entire -/ -/ -/ -match -. -If -instead -you -just -want -to -test -the -existence -of -a -match -/ -/ -/ -it -' -s -potentially -faster -to -use -Regex -: -: -is_match -( -hay -) -instead -of -/ -/ -/ -Regex -: -: -find -( -hay -) -. -is_some -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Find -the -first -word -with -exactly -13 -Unicode -word -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -b -\ -w -{ -13 -} -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -I -categorically -deny -having -triskaidekaphobia -. -" -; -/ -/ -/ -let -mat -= -re -. -find -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -2 -. -. -15 -mat -. -range -( -) -) -; -/ -/ -/ -assert_eq -! -( -b -" -categorically -" -mat -. -as_bytes -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -find -< -' -h -> -( -& -self -haystack -: -& -' -h -[ -u8 -] -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -find_at -( -haystack -0 -) -} -/ -/ -/ -Returns -an -iterator -that -yields -successive -non -- -overlapping -matches -in -/ -/ -/ -the -given -haystack -. -The -iterator -yields -values -of -type -[ -Match -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -find_iter -runs -potentially -many -searches -on -the -/ -/ -/ -haystack -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -/ -/ -/ -complexity -the -overall -worst -case -time -complexity -for -iteration -is -/ -/ -/ -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Find -every -word -with -exactly -13 -Unicode -word -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -b -\ -w -{ -13 -} -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -Retroactively -relinquishing -remunerations -is -reprehensible -. -" -; -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -re -. -find_iter -( -hay -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -& -b -" -Retroactively -" -[ -. -. -] -/ -/ -/ -& -b -" -relinquishing -" -[ -. -. -] -/ -/ -/ -& -b -" -remunerations -" -[ -. -. -] -/ -/ -/ -& -b -" -reprehensible -" -[ -. -. -] -/ -/ -/ -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -find_iter -< -' -r -' -h -> -( -& -' -r -self -haystack -: -& -' -h -[ -u8 -] -) -- -> -Matches -< -' -r -' -h -> -{ -Matches -{ -haystack -it -: -self -. -meta -. -find_iter -( -haystack -) -} -} -/ -/ -/ -This -routine -searches -for -the -first -match -of -this -regex -in -the -haystack -/ -/ -/ -given -and -if -found -returns -not -only -the -overall -match -but -also -the -/ -/ -/ -matches -of -each -capture -group -in -the -regex -. -If -no -match -is -found -then -/ -/ -/ -None -is -returned -. -/ -/ -/ -/ -/ -/ -Capture -group -0 -always -corresponds -to -an -implicit -unnamed -group -that -/ -/ -/ -includes -the -entire -match -. -If -a -match -is -found -this -group -is -always -/ -/ -/ -present -. -Subsequent -groups -may -be -named -and -are -numbered -starting -/ -/ -/ -at -1 -by -the -order -in -which -the -opening -parenthesis -appears -in -the -/ -/ -/ -pattern -. -For -example -in -the -pattern -( -? -< -a -> -. -( -? -< -b -> -. -) -) -( -? -< -c -> -. -) -a -/ -/ -/ -b -and -c -correspond -to -capture -group -indices -1 -2 -and -3 -/ -/ -/ -respectively -. -/ -/ -/ -/ -/ -/ -You -should -only -use -captures -if -you -need -access -to -the -capture -group -/ -/ -/ -matches -. -Otherwise -[ -Regex -: -: -find -] -is -generally -faster -for -discovering -/ -/ -/ -just -the -overall -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Say -you -have -some -haystack -with -movie -names -and -their -release -years -/ -/ -/ -like -" -' -Citizen -Kane -' -( -1941 -) -" -. -It -' -d -be -nice -if -we -could -search -for -/ -/ -/ -strings -looking -like -that -while -also -extracting -the -movie -name -and -its -/ -/ -/ -release -year -separately -. -The -example -below -shows -how -to -do -that -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -\ -d -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -Not -my -favorite -movie -: -' -Citizen -Kane -' -( -1941 -) -. -" -; -/ -/ -/ -let -caps -= -re -. -captures -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -caps -. -get -( -0 -) -. -unwrap -( -) -. -as_bytes -( -) -b -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -caps -. -get -( -1 -) -. -unwrap -( -) -. -as_bytes -( -) -b -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -caps -. -get -( -2 -) -. -unwrap -( -) -. -as_bytes -( -) -b -" -1941 -" -) -; -/ -/ -/ -/ -/ -You -can -also -access -the -groups -by -index -using -the -Index -notation -. -/ -/ -/ -/ -/ -Note -that -this -will -panic -on -an -invalid -index -. -In -this -case -these -/ -/ -/ -/ -/ -accesses -are -always -correct -because -the -overall -regex -will -only -/ -/ -/ -/ -/ -match -when -these -capture -groups -match -. -/ -/ -/ -assert_eq -! -( -& -caps -[ -0 -] -b -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -1 -] -b -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -2 -] -b -" -1941 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -the -full -match -is -at -capture -group -0 -. -Each -subsequent -/ -/ -/ -capture -group -is -indexed -by -the -order -of -its -opening -( -. -/ -/ -/ -/ -/ -/ -We -can -make -this -example -a -bit -clearer -by -using -* -named -* -capture -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -? -< -title -> -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -? -< -year -> -\ -d -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -Not -my -favorite -movie -: -' -Citizen -Kane -' -( -1941 -) -. -" -; -/ -/ -/ -let -caps -= -re -. -captures -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -caps -. -get -( -0 -) -. -unwrap -( -) -. -as_bytes -( -) -b -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -caps -. -name -( -" -title -" -) -. -unwrap -( -) -. -as_bytes -( -) -b -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -caps -. -name -( -" -year -" -) -. -unwrap -( -) -. -as_bytes -( -) -b -" -1941 -" -) -; -/ -/ -/ -/ -/ -You -can -also -access -the -groups -by -name -using -the -Index -notation -. -/ -/ -/ -/ -/ -Note -that -this -will -panic -on -an -invalid -group -name -. -In -this -case -/ -/ -/ -/ -/ -these -accesses -are -always -correct -because -the -overall -regex -will -/ -/ -/ -/ -/ -only -match -when -these -capture -groups -match -. -/ -/ -/ -assert_eq -! -( -& -caps -[ -0 -] -b -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -title -" -] -b -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -year -" -] -b -" -1941 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Here -we -name -the -capture -groups -which -we -can -access -with -the -name -/ -/ -/ -method -or -the -Index -notation -with -a -& -str -. -Note -that -the -named -/ -/ -/ -capture -groups -are -still -accessible -with -get -or -the -Index -notation -/ -/ -/ -with -a -usize -. -/ -/ -/ -/ -/ -/ -The -0 -th -capture -group -is -always -unnamed -so -it -must -always -be -/ -/ -/ -accessed -with -get -( -0 -) -or -[ -0 -] -. -/ -/ -/ -/ -/ -/ -Finally -one -other -way -to -to -get -the -matched -substrings -is -with -the -/ -/ -/ -[ -Captures -: -: -extract -] -API -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -\ -d -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -Not -my -favorite -movie -: -' -Citizen -Kane -' -( -1941 -) -. -" -; -/ -/ -/ -let -( -full -[ -title -year -] -) -= -re -. -captures -( -hay -) -. -unwrap -( -) -. -extract -( -) -; -/ -/ -/ -assert_eq -! -( -full -b -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -title -b -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -year -b -" -1941 -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures -< -' -h -> -( -& -self -haystack -: -& -' -h -[ -u8 -] -) -- -> -Option -< -Captures -< -' -h -> -> -{ -self -. -captures_at -( -haystack -0 -) -} -/ -/ -/ -Returns -an -iterator -that -yields -successive -non -- -overlapping -matches -in -/ -/ -/ -the -given -haystack -. -The -iterator -yields -values -of -type -[ -Captures -] -. -/ -/ -/ -/ -/ -/ -This -is -the -same -as -[ -Regex -: -: -find_iter -] -but -instead -of -only -providing -/ -/ -/ -access -to -the -overall -match -each -value -yield -includes -access -to -the -/ -/ -/ -matches -of -all -capture -groups -in -the -regex -. -Reporting -this -extra -match -/ -/ -/ -data -is -potentially -costly -so -callers -should -only -use -captures_iter -/ -/ -/ -over -find_iter -when -they -actually -need -access -to -the -capture -group -/ -/ -/ -matches -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -captures_iter -runs -potentially -many -searches -on -the -/ -/ -/ -haystack -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -/ -/ -/ -complexity -the -overall -worst -case -time -complexity -for -iteration -is -/ -/ -/ -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -We -can -use -this -to -find -all -movie -titles -and -their -release -years -in -/ -/ -/ -some -haystack -where -the -movie -is -formatted -like -" -' -Title -' -( -xxxx -) -" -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -[ -0 -- -9 -] -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -' -Citizen -Kane -' -( -1941 -) -' -The -Wizard -of -Oz -' -( -1939 -) -' -M -' -( -1931 -) -. -" -; -/ -/ -/ -let -mut -movies -= -vec -! -[ -] -; -/ -/ -/ -for -( -_ -[ -title -year -] -) -in -re -. -captures_iter -( -hay -) -. -map -( -| -c -| -c -. -extract -( -) -) -{ -/ -/ -/ -/ -/ -OK -because -[ -0 -- -9 -] -{ -4 -} -can -only -match -valid -UTF -- -8 -. -/ -/ -/ -let -year -= -std -: -: -str -: -: -from_utf8 -( -year -) -. -unwrap -( -) -; -/ -/ -/ -movies -. -push -( -( -title -year -. -parse -: -: -< -i64 -> -( -) -? -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -movies -vec -! -[ -/ -/ -/ -( -& -b -" -Citizen -Kane -" -[ -. -. -] -1941 -) -/ -/ -/ -( -& -b -" -The -Wizard -of -Oz -" -[ -. -. -] -1939 -) -/ -/ -/ -( -& -b -" -M -" -[ -. -. -] -1931 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Or -with -named -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -? -< -title -> -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -' -Citizen -Kane -' -( -1941 -) -' -The -Wizard -of -Oz -' -( -1939 -) -' -M -' -( -1931 -) -. -" -; -/ -/ -/ -let -mut -it -= -re -. -captures_iter -( -hay -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -it -. -next -( -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -title -" -] -b -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -year -" -] -b -" -1941 -" -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -it -. -next -( -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -title -" -] -b -" -The -Wizard -of -Oz -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -year -" -] -b -" -1939 -" -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -it -. -next -( -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -title -" -] -b -" -M -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -year -" -] -b -" -1931 -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_iter -< -' -r -' -h -> -( -& -' -r -self -haystack -: -& -' -h -[ -u8 -] -) -- -> -CaptureMatches -< -' -r -' -h -> -{ -CaptureMatches -{ -haystack -it -: -self -. -meta -. -captures_iter -( -haystack -) -} -} -/ -/ -/ -Returns -an -iterator -of -substrings -of -the -haystack -given -delimited -by -a -/ -/ -/ -match -of -the -regex -. -Namely -each -element -of -the -iterator -corresponds -to -/ -/ -/ -a -part -of -the -haystack -that -* -isn -' -t -* -matched -by -the -regular -expression -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Since -iterators -over -all -matches -requires -running -potentially -many -/ -/ -/ -searches -on -the -haystack -and -since -each -search -has -worst -case -/ -/ -/ -O -( -m -* -n -) -time -complexity -the -overall -worst -case -time -complexity -for -/ -/ -/ -this -routine -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -To -split -a -string -delimited -by -arbitrary -amounts -of -spaces -or -tabs -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -\ -t -] -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -a -b -\ -t -c -\ -td -e -" -; -/ -/ -/ -let -fields -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -fields -vec -! -[ -/ -/ -/ -& -b -" -a -" -[ -. -. -] -& -b -" -b -" -[ -. -. -] -& -b -" -c -" -[ -. -. -] -& -b -" -d -" -[ -. -. -] -& -b -" -e -" -[ -. -. -] -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -more -cases -/ -/ -/ -/ -/ -/ -Basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -Mary -had -a -little -lamb -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -& -b -" -Mary -" -[ -. -. -] -& -b -" -had -" -[ -. -. -] -& -b -" -a -" -[ -. -. -] -& -b -" -little -" -[ -. -. -] -& -b -" -lamb -" -[ -. -. -] -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -lionXXtigerXleopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -& -b -" -lion -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -tiger -" -[ -. -. -] -& -b -" -leopard -" -[ -. -. -] -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -: -: -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -lion -: -: -tiger -: -: -leopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -lion -" -[ -. -. -] -& -b -" -tiger -" -[ -. -. -] -& -b -" -leopard -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -If -a -haystack -contains -multiple -contiguous -matches -you -will -end -up -/ -/ -/ -with -empty -spans -yielded -by -the -iterator -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -XXXXaXXbXc -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -& -b -" -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -" -[ -. -. -] -/ -/ -/ -& -b -" -a -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -b -" -[ -. -. -] -& -b -" -c -" -[ -. -. -] -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -/ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -( -/ -/ -/ -) -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -( -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -) -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Separators -at -the -start -or -end -of -a -haystack -are -neighbored -by -empty -/ -/ -/ -substring -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -0 -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -010 -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -" -[ -. -. -] -& -b -" -1 -" -[ -. -. -] -& -b -" -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -When -the -regex -can -match -the -empty -string -it -splits -at -every -byte -/ -/ -/ -position -in -the -haystack -. -This -includes -between -all -UTF -- -8 -code -units -. -/ -/ -/ -( -The -top -- -level -[ -Regex -: -: -split -] -( -crate -: -: -Regex -: -: -split -) -will -only -split -/ -/ -/ -at -valid -UTF -- -8 -boundaries -. -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -" -. -as_bytes -( -) -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -& -[ -] -[ -. -. -] -& -[ -b -' -\ -xE2 -' -] -[ -. -. -] -& -[ -b -' -\ -x98 -' -] -[ -. -. -] -& -[ -b -' -\ -x83 -' -] -[ -. -. -] -& -[ -] -[ -. -. -] -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Contiguous -separators -( -commonly -shows -up -with -whitespace -) -can -lead -to -/ -/ -/ -possibly -surprising -behavior -. -For -example -this -code -is -correct -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -a -b -c -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -/ -/ -/ -& -b -" -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -" -[ -. -. -] -/ -/ -/ -& -b -" -a -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -b -" -[ -. -. -] -& -b -" -c -" -[ -. -. -] -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -It -does -* -not -* -give -you -[ -" -a -" -" -b -" -" -c -" -] -. -For -that -behavior -you -' -d -want -/ -/ -/ -to -match -contiguous -space -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -a -b -c -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -/ -/ -N -. -B -. -This -does -still -include -a -leading -empty -span -because -' -+ -' -/ -/ -/ -/ -/ -matches -at -the -beginning -of -the -haystack -. -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -" -[ -. -. -] -& -b -" -a -" -[ -. -. -] -& -b -" -b -" -[ -. -. -] -& -b -" -c -" -[ -. -. -] -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -split -< -' -r -' -h -> -( -& -' -r -self -haystack -: -& -' -h -[ -u8 -] -) -- -> -Split -< -' -r -' -h -> -{ -Split -{ -haystack -it -: -self -. -meta -. -split -( -haystack -) -} -} -/ -/ -/ -Returns -an -iterator -of -at -most -limit -substrings -of -the -haystack -/ -/ -/ -given -delimited -by -a -match -of -the -regex -. -( -A -limit -of -0 -will -return -/ -/ -/ -no -substrings -. -) -Namely -each -element -of -the -iterator -corresponds -to -a -/ -/ -/ -part -of -the -haystack -that -* -isn -' -t -* -matched -by -the -regular -expression -. -/ -/ -/ -The -remainder -of -the -haystack -that -is -not -split -will -be -the -last -/ -/ -/ -element -in -the -iterator -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Since -iterators -over -all -matches -requires -running -potentially -many -/ -/ -/ -searches -on -the -haystack -and -since -each -search -has -worst -case -/ -/ -/ -O -( -m -* -n -) -time -complexity -the -overall -worst -case -time -complexity -for -/ -/ -/ -this -routine -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -Although -note -that -the -worst -case -time -here -has -an -upper -bound -given -/ -/ -/ -by -the -limit -parameter -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Get -the -first -two -words -in -some -haystack -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -W -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -Hey -! -How -are -you -? -" -; -/ -/ -/ -let -fields -: -Vec -< -& -[ -u8 -] -> -= -re -. -splitn -( -hay -3 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -fields -vec -! -[ -& -b -" -Hey -" -[ -. -. -] -& -b -" -How -" -[ -. -. -] -& -b -" -are -you -? -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Examples -: -more -cases -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -Mary -had -a -little -lamb -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -splitn -( -hay -3 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -Mary -" -[ -. -. -] -& -b -" -had -" -[ -. -. -] -& -b -" -a -little -lamb -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -splitn -( -hay -3 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -lionXXtigerXleopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -splitn -( -hay -3 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -lion -" -[ -. -. -] -& -b -" -" -[ -. -. -] -& -b -" -tigerXleopard -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -: -: -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -lion -: -: -tiger -: -: -leopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -splitn -( -hay -2 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -lion -" -[ -. -. -] -& -b -" -tiger -: -: -leopard -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -abcXdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -splitn -( -hay -1 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -abcXdef -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -abcdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -splitn -( -hay -2 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -& -b -" -abcdef -" -[ -. -. -] -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -abcXdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -[ -u8 -] -> -= -re -. -splitn -( -hay -0 -) -. -collect -( -) -; -/ -/ -/ -assert -! -( -got -. -is_empty -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -splitn -< -' -r -' -h -> -( -& -' -r -self -haystack -: -& -' -h -[ -u8 -] -limit -: -usize -) -- -> -SplitN -< -' -r -' -h -> -{ -SplitN -{ -haystack -it -: -self -. -meta -. -splitn -( -haystack -limit -) -} -} -/ -/ -/ -Replaces -the -leftmost -- -first -match -in -the -given -haystack -with -the -/ -/ -/ -replacement -provided -. -The -replacement -can -be -a -regular -string -( -where -/ -/ -/ -N -and -name -are -expanded -to -match -capture -groups -) -or -a -function -/ -/ -/ -that -takes -a -[ -Captures -] -and -returns -the -replaced -string -. -/ -/ -/ -/ -/ -/ -If -no -match -is -found -then -the -haystack -is -returned -unchanged -. -In -that -/ -/ -/ -case -this -implementation -will -likely -return -a -Cow -: -: -Borrowed -value -/ -/ -/ -such -that -no -allocation -is -performed -. -/ -/ -/ -/ -/ -/ -# -Replacement -string -syntax -/ -/ -/ -/ -/ -/ -All -instances -of -ref -in -the -replacement -string -are -replaced -with -/ -/ -/ -the -substring -corresponding -to -the -capture -group -identified -by -ref -. -/ -/ -/ -/ -/ -/ -ref -may -be -an -integer -corresponding -to -the -index -of -the -capture -group -/ -/ -/ -( -counted -by -order -of -opening -parenthesis -where -0 -is -the -entire -match -) -/ -/ -/ -or -it -can -be -a -name -( -consisting -of -letters -digits -or -underscores -) -/ -/ -/ -corresponding -to -a -named -capture -group -. -/ -/ -/ -/ -/ -/ -If -ref -isn -' -t -a -valid -capture -group -( -whether -the -name -doesn -' -t -exist -or -/ -/ -/ -isn -' -t -a -valid -index -) -then -it -is -replaced -with -the -empty -string -. -/ -/ -/ -/ -/ -/ -The -longest -possible -name -is -used -. -For -example -1a -looks -up -the -/ -/ -/ -capture -group -named -1a -and -not -the -capture -group -at -index -1 -. -To -/ -/ -/ -exert -more -precise -control -over -the -name -use -braces -e -. -g -. -{ -1 -} -a -. -/ -/ -/ -/ -/ -/ -To -write -a -literal -use -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Note -that -this -function -is -polymorphic -with -respect -to -the -replacement -. -/ -/ -/ -In -typical -usage -this -can -just -be -a -normal -string -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -^ -01 -] -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -re -. -replace -( -b -" -1078910 -" -b -" -" -) -& -b -" -1010 -" -[ -. -. -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -But -anything -satisfying -the -[ -Replacer -] -trait -will -work -. -For -example -/ -/ -/ -a -closure -of -type -| -& -Captures -| -- -> -String -provides -direct -access -to -the -/ -/ -/ -captures -corresponding -to -a -match -. -This -allows -one -to -access -capturing -/ -/ -/ -group -matches -easily -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -{ -Captures -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -[ -^ -\ -s -] -+ -) -\ -s -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -b -" -Springsteen -Bruce -" -| -caps -: -& -Captures -| -{ -/ -/ -/ -let -mut -buf -= -vec -! -[ -] -; -/ -/ -/ -buf -. -extend_from_slice -( -& -caps -[ -2 -] -) -; -/ -/ -/ -buf -. -push -( -b -' -' -) -; -/ -/ -/ -buf -. -extend_from_slice -( -& -caps -[ -1 -] -) -; -/ -/ -/ -buf -/ -/ -/ -} -) -; -/ -/ -/ -assert_eq -! -( -result -& -b -" -Bruce -Springsteen -" -[ -. -. -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -But -this -is -a -bit -cumbersome -to -use -all -the -time -. -Instead -a -simple -/ -/ -/ -syntax -is -supported -( -as -described -above -) -that -expands -name -into -the -/ -/ -/ -corresponding -capture -group -. -Here -' -s -the -last -example -but -using -this -/ -/ -/ -expansion -technique -with -named -capture -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -last -> -[ -^ -\ -s -] -+ -) -\ -s -+ -( -? -< -first -> -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -b -" -Springsteen -Bruce -" -b -" -first -last -" -) -; -/ -/ -/ -assert_eq -! -( -result -& -b -" -Bruce -Springsteen -" -[ -. -. -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -using -2 -instead -of -first -or -1 -instead -of -last -/ -/ -/ -would -produce -the -same -result -. -To -write -a -literal -use -. -/ -/ -/ -/ -/ -/ -Sometimes -the -replacement -string -requires -use -of -curly -braces -to -/ -/ -/ -delineate -a -capture -group -replacement -when -it -is -adjacent -to -some -other -/ -/ -/ -literal -text -. -For -example -if -we -wanted -to -join -two -words -together -with -/ -/ -/ -an -underscore -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -+ -) -\ -s -+ -( -? -< -second -> -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -b -" -deep -fried -" -b -" -{ -first -} -_ -second -" -) -; -/ -/ -/ -assert_eq -! -( -result -& -b -" -deep_fried -" -[ -. -. -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Without -the -curly -braces -the -capture -group -name -first_ -would -be -/ -/ -/ -used -and -since -it -doesn -' -t -exist -it -would -be -replaced -with -the -empty -/ -/ -/ -string -. -/ -/ -/ -/ -/ -/ -Finally -sometimes -you -just -want -to -replace -a -literal -string -with -no -/ -/ -/ -regard -for -capturing -group -expansion -. -This -can -be -done -by -wrapping -a -/ -/ -/ -string -with -[ -NoExpand -] -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -{ -NoExpand -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -last -> -[ -^ -\ -s -] -+ -) -\ -s -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -b -" -Springsteen -Bruce -" -NoExpand -( -b -" -2 -last -" -) -) -; -/ -/ -/ -assert_eq -! -( -result -& -b -" -2 -last -" -[ -. -. -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Using -NoExpand -may -also -be -faster -since -the -replacement -string -won -' -t -/ -/ -/ -need -to -be -parsed -for -the -syntax -. -# -[ -inline -] -pub -fn -replace -< -' -h -R -: -Replacer -> -( -& -self -haystack -: -& -' -h -[ -u8 -] -rep -: -R -) -- -> -Cow -< -' -h -[ -u8 -] -> -{ -self -. -replacen -( -haystack -1 -rep -) -} -/ -/ -/ -Replaces -all -non -- -overlapping -matches -in -the -haystack -with -the -/ -/ -/ -replacement -provided -. -This -is -the -same -as -calling -replacen -with -/ -/ -/ -limit -set -to -0 -. -/ -/ -/ -/ -/ -/ -The -documentation -for -[ -Regex -: -: -replace -] -goes -into -more -detail -about -/ -/ -/ -what -kinds -of -replacement -strings -are -supported -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Since -iterators -over -all -matches -requires -running -potentially -many -/ -/ -/ -searches -on -the -haystack -and -since -each -search -has -worst -case -/ -/ -/ -O -( -m -* -n -) -time -complexity -the -overall -worst -case -time -complexity -for -/ -/ -/ -this -routine -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -# -Fallibility -/ -/ -/ -/ -/ -/ -If -you -need -to -write -a -replacement -routine -where -any -individual -/ -/ -/ -replacement -might -" -fail -" -doing -so -with -this -API -isn -' -t -really -feasible -/ -/ -/ -because -there -' -s -no -way -to -stop -the -search -process -if -a -replacement -/ -/ -/ -fails -. -Instead -if -you -need -this -functionality -you -should -consider -/ -/ -/ -implementing -your -own -replacement -routine -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -{ -Captures -Regex -} -; -/ -/ -/ -/ -/ -/ -fn -replace_all -< -E -> -( -/ -/ -/ -re -: -& -Regex -/ -/ -/ -haystack -: -& -[ -u8 -] -/ -/ -/ -replacement -: -impl -Fn -( -& -Captures -) -- -> -Result -< -Vec -< -u8 -> -E -> -/ -/ -/ -) -- -> -Result -< -Vec -< -u8 -> -E -> -{ -/ -/ -/ -let -mut -new -= -Vec -: -: -with_capacity -( -haystack -. -len -( -) -) -; -/ -/ -/ -let -mut -last_match -= -0 -; -/ -/ -/ -for -caps -in -re -. -captures_iter -( -haystack -) -{ -/ -/ -/ -let -m -= -caps -. -get -( -0 -) -. -unwrap -( -) -; -/ -/ -/ -new -. -extend_from_slice -( -& -haystack -[ -last_match -. -. -m -. -start -( -) -] -) -; -/ -/ -/ -new -. -extend_from_slice -( -& -replacement -( -& -caps -) -? -) -; -/ -/ -/ -last_match -= -m -. -end -( -) -; -/ -/ -/ -} -/ -/ -/ -new -. -extend_from_slice -( -& -haystack -[ -last_match -. -. -] -) -; -/ -/ -/ -Ok -( -new -) -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -Let -' -s -replace -each -word -with -the -number -of -bytes -in -that -word -. -/ -/ -/ -/ -/ -But -if -we -see -a -word -that -is -" -too -long -" -we -' -ll -give -up -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -w -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -replacement -= -| -caps -: -& -Captures -| -- -> -Result -< -Vec -< -u8 -> -& -' -static -str -> -{ -/ -/ -/ -if -caps -[ -0 -] -. -len -( -) -> -= -5 -{ -/ -/ -/ -return -Err -( -" -word -too -long -" -) -; -/ -/ -/ -} -/ -/ -/ -Ok -( -caps -[ -0 -] -. -len -( -) -. -to_string -( -) -. -into_bytes -( -) -) -/ -/ -/ -} -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Ok -( -b -" -2 -3 -3 -3 -? -" -. -to_vec -( -) -) -/ -/ -/ -replace_all -( -& -re -b -" -hi -how -are -you -? -" -& -replacement -) -/ -/ -/ -) -; -/ -/ -/ -assert -! -( -replace_all -( -& -re -b -" -hi -there -" -& -replacement -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -flip -the -order -of -whitespace -( -excluding -line -/ -/ -/ -terminators -) -delimited -fields -and -normalizes -the -whitespace -that -/ -/ -/ -delimits -the -fields -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -( -\ -S -+ -) -[ -\ -s -- -- -\ -r -\ -n -] -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -/ -/ -/ -Greetings -1973 -/ -/ -/ -Wild -\ -t1973 -/ -/ -/ -BornToRun -\ -t -\ -t -\ -t -\ -t1975 -/ -/ -/ -Darkness -1978 -/ -/ -/ -TheRiver -1980 -/ -/ -/ -" -; -/ -/ -/ -let -new -= -re -. -replace_all -( -hay -b -" -2 -1 -" -) -; -/ -/ -/ -assert_eq -! -( -new -& -b -" -/ -/ -/ -1973 -Greetings -/ -/ -/ -1973 -Wild -/ -/ -/ -1975 -BornToRun -/ -/ -/ -1978 -Darkness -/ -/ -/ -1980 -TheRiver -/ -/ -/ -" -[ -. -. -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -replace_all -< -' -h -R -: -Replacer -> -( -& -self -haystack -: -& -' -h -[ -u8 -] -rep -: -R -) -- -> -Cow -< -' -h -[ -u8 -] -> -{ -self -. -replacen -( -haystack -0 -rep -) -} -/ -/ -/ -Replaces -at -most -limit -non -- -overlapping -matches -in -the -haystack -with -/ -/ -/ -the -replacement -provided -. -If -limit -is -0 -then -all -non -- -overlapping -/ -/ -/ -matches -are -replaced -. -That -is -Regex -: -: -replace_all -( -hay -rep -) -is -/ -/ -/ -equivalent -to -Regex -: -: -replacen -( -hay -0 -rep -) -. -/ -/ -/ -/ -/ -/ -The -documentation -for -[ -Regex -: -: -replace -] -goes -into -more -detail -about -/ -/ -/ -what -kinds -of -replacement -strings -are -supported -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Since -iterators -over -all -matches -requires -running -potentially -many -/ -/ -/ -searches -on -the -haystack -and -since -each -search -has -worst -case -/ -/ -/ -O -( -m -* -n -) -time -complexity -the -overall -worst -case -time -complexity -for -/ -/ -/ -this -routine -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -Although -note -that -the -worst -case -time -here -has -an -upper -bound -given -/ -/ -/ -by -the -limit -parameter -. -/ -/ -/ -/ -/ -/ -# -Fallibility -/ -/ -/ -/ -/ -/ -See -the -corresponding -section -in -the -docs -for -[ -Regex -: -: -replace_all -] -/ -/ -/ -for -tips -on -how -to -deal -with -a -replacement -routine -that -can -fail -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -flip -the -order -of -whitespace -( -excluding -line -/ -/ -/ -terminators -) -delimited -fields -and -normalizes -the -whitespace -that -/ -/ -/ -delimits -the -fields -. -But -we -only -do -it -for -the -first -two -matches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -( -\ -S -+ -) -[ -\ -s -- -- -\ -r -\ -n -] -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -/ -/ -/ -Greetings -1973 -/ -/ -/ -Wild -\ -t1973 -/ -/ -/ -BornToRun -\ -t -\ -t -\ -t -\ -t1975 -/ -/ -/ -Darkness -1978 -/ -/ -/ -TheRiver -1980 -/ -/ -/ -" -; -/ -/ -/ -let -new -= -re -. -replacen -( -hay -2 -b -" -2 -1 -" -) -; -/ -/ -/ -assert_eq -! -( -new -& -b -" -/ -/ -/ -1973 -Greetings -/ -/ -/ -1973 -Wild -/ -/ -/ -BornToRun -\ -t -\ -t -\ -t -\ -t1975 -/ -/ -/ -Darkness -1978 -/ -/ -/ -TheRiver -1980 -/ -/ -/ -" -[ -. -. -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -replacen -< -' -h -R -: -Replacer -> -( -& -self -haystack -: -& -' -h -[ -u8 -] -limit -: -usize -mut -rep -: -R -) -- -> -Cow -< -' -h -[ -u8 -] -> -{ -/ -/ -If -we -know -that -the -replacement -doesn -' -t -have -any -capture -expansions -/ -/ -then -we -can -use -the -fast -path -. -The -fast -path -can -make -a -tremendous -/ -/ -difference -: -/ -/ -/ -/ -1 -) -We -use -find_iter -instead -of -captures_iter -. -Not -asking -for -/ -/ -captures -generally -makes -the -regex -engines -faster -. -/ -/ -2 -) -We -don -' -t -need -to -look -up -all -of -the -capture -groups -and -do -/ -/ -replacements -inside -the -replacement -string -. -We -just -push -it -/ -/ -at -each -match -and -be -done -with -it -. -if -let -Some -( -rep -) -= -rep -. -no_expansion -( -) -{ -let -mut -it -= -self -. -find_iter -( -haystack -) -. -enumerate -( -) -. -peekable -( -) -; -if -it -. -peek -( -) -. -is_none -( -) -{ -return -Cow -: -: -Borrowed -( -haystack -) -; -} -let -mut -new -= -Vec -: -: -with_capacity -( -haystack -. -len -( -) -) -; -let -mut -last_match -= -0 -; -for -( -i -m -) -in -it -{ -new -. -extend_from_slice -( -& -haystack -[ -last_match -. -. -m -. -start -( -) -] -) -; -new -. -extend_from_slice -( -& -rep -) -; -last_match -= -m -. -end -( -) -; -if -limit -> -0 -& -& -i -> -= -limit -- -1 -{ -break -; -} -} -new -. -extend_from_slice -( -& -haystack -[ -last_match -. -. -] -) -; -return -Cow -: -: -Owned -( -new -) -; -} -/ -/ -The -slower -path -which -we -use -if -the -replacement -needs -access -to -/ -/ -capture -groups -. -let -mut -it -= -self -. -captures_iter -( -haystack -) -. -enumerate -( -) -. -peekable -( -) -; -if -it -. -peek -( -) -. -is_none -( -) -{ -return -Cow -: -: -Borrowed -( -haystack -) -; -} -let -mut -new -= -Vec -: -: -with_capacity -( -haystack -. -len -( -) -) -; -let -mut -last_match -= -0 -; -for -( -i -cap -) -in -it -{ -/ -/ -unwrap -on -0 -is -OK -because -captures -only -reports -matches -let -m -= -cap -. -get -( -0 -) -. -unwrap -( -) -; -new -. -extend_from_slice -( -& -haystack -[ -last_match -. -. -m -. -start -( -) -] -) -; -rep -. -replace_append -( -& -cap -& -mut -new -) -; -last_match -= -m -. -end -( -) -; -if -limit -> -0 -& -& -i -> -= -limit -- -1 -{ -break -; -} -} -new -. -extend_from_slice -( -& -haystack -[ -last_match -. -. -] -) -; -Cow -: -: -Owned -( -new -) -} -} -/ -/ -/ -A -group -of -advanced -or -" -lower -level -" -search -methods -. -Some -methods -permit -/ -/ -/ -starting -the -search -at -a -position -greater -than -0 -in -the -haystack -. -Other -/ -/ -/ -methods -permit -reusing -allocations -for -example -when -extracting -the -/ -/ -/ -matches -for -capture -groups -. -impl -Regex -{ -/ -/ -/ -Returns -the -end -byte -offset -of -the -first -match -in -the -haystack -given -. -/ -/ -/ -/ -/ -/ -This -method -may -have -the -same -performance -characteristics -as -/ -/ -/ -is_match -. -Behaviorlly -it -doesn -' -t -just -report -whether -it -match -/ -/ -/ -occurs -but -also -the -end -offset -for -a -match -. -In -particular -the -offset -/ -/ -/ -returned -* -may -be -shorter -* -than -the -proper -end -of -the -leftmost -- -first -/ -/ -/ -match -that -you -would -find -via -[ -Regex -: -: -find -] -. -/ -/ -/ -/ -/ -/ -Note -that -it -is -not -guaranteed -that -this -routine -finds -the -shortest -or -/ -/ -/ -" -earliest -" -possible -match -. -Instead -the -main -idea -of -this -API -is -that -/ -/ -/ -it -returns -the -offset -at -the -point -at -which -the -internal -regex -engine -/ -/ -/ -has -determined -that -a -match -has -occurred -. -This -may -vary -depending -on -/ -/ -/ -which -internal -regex -engine -is -used -and -thus -the -offset -itself -may -/ -/ -/ -change -based -on -internal -heuristics -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Typically -a -+ -would -match -the -entire -first -sequence -of -a -in -some -/ -/ -/ -haystack -but -shortest_match -* -may -* -give -up -as -soon -as -it -sees -the -/ -/ -/ -first -a -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -a -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -offset -= -re -. -shortest_match -( -b -" -aaaaa -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -offset -1 -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -shortest_match -( -& -self -haystack -: -& -[ -u8 -] -) -- -> -Option -< -usize -> -{ -self -. -shortest_match_at -( -haystack -0 -) -} -/ -/ -/ -Returns -the -same -as -shortest_match -but -starts -the -search -at -the -/ -/ -/ -given -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -match -/ -/ -/ -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -If -a -match -is -found -the -offset -returned -is -relative -to -the -beginning -/ -/ -/ -of -the -haystack -not -the -beginning -of -the -search -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -eschew -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert_eq -! -( -re -. -shortest_match -( -& -hay -[ -2 -. -. -] -) -Some -( -4 -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert_eq -! -( -re -. -shortest_match_at -( -hay -2 -) -None -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -shortest_match_at -( -& -self -haystack -: -& -[ -u8 -] -start -: -usize -) -- -> -Option -< -usize -> -{ -let -input -= -Input -: -: -new -( -haystack -) -. -earliest -( -true -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -self -. -meta -. -search_half -( -& -input -) -. -map -( -| -hm -| -hm -. -offset -( -) -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -is_match -] -but -starts -the -search -at -the -/ -/ -/ -given -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -eschew -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert -! -( -re -. -is_match -( -& -hay -[ -2 -. -. -] -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert -! -( -! -re -. -is_match_at -( -hay -2 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_match_at -( -& -self -haystack -: -& -[ -u8 -] -start -: -usize -) -- -> -bool -{ -self -. -meta -. -is_match -( -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -find -] -but -starts -the -search -at -the -given -/ -/ -/ -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -eschew -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert_eq -! -( -re -. -find -( -& -hay -[ -2 -. -. -] -) -. -map -( -| -m -| -m -. -range -( -) -) -Some -( -0 -. -. -4 -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert_eq -! -( -re -. -find_at -( -hay -2 -) -None -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -find_at -< -' -h -> -( -& -self -haystack -: -& -' -h -[ -u8 -] -start -: -usize -) -- -> -Option -< -Match -< -' -h -> -> -{ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -self -. -meta -. -find -( -input -) -. -map -( -| -m -| -Match -: -: -new -( -haystack -m -. -start -( -) -m -. -end -( -) -) -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -captures -] -but -starts -the -search -at -the -/ -/ -/ -given -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -eschew -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert_eq -! -( -& -re -. -captures -( -& -hay -[ -2 -. -. -] -) -. -unwrap -( -) -[ -0 -] -b -" -chew -" -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert -! -( -re -. -captures_at -( -hay -2 -) -. -is_none -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_at -< -' -h -> -( -& -self -haystack -: -& -' -h -[ -u8 -] -start -: -usize -) -- -> -Option -< -Captures -< -' -h -> -> -{ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -let -mut -caps -= -self -. -meta -. -create_captures -( -) -; -self -. -meta -. -captures -( -input -& -mut -caps -) -; -if -caps -. -is_match -( -) -{ -let -static_captures_len -= -self -. -static_captures_len -( -) -; -Some -( -Captures -{ -haystack -caps -static_captures_len -} -) -} -else -{ -None -} -} -/ -/ -/ -This -is -like -[ -Regex -: -: -captures -] -but -writes -the -byte -offsets -of -each -/ -/ -/ -capture -group -match -into -the -locations -given -. -/ -/ -/ -/ -/ -/ -A -[ -CaptureLocations -] -stores -the -same -byte -offsets -as -a -[ -Captures -] -/ -/ -/ -but -does -* -not -* -store -a -reference -to -the -haystack -. -This -makes -its -API -/ -/ -/ -a -bit -lower -level -and -less -convenient -. -But -in -exchange -callers -/ -/ -/ -may -allocate -their -own -CaptureLocations -and -reuse -it -for -multiple -/ -/ -/ -searches -. -This -may -be -helpful -if -allocating -a -Captures -shows -up -in -a -/ -/ -/ -profile -as -too -costly -. -/ -/ -/ -/ -/ -/ -To -create -a -CaptureLocations -value -use -the -/ -/ -/ -[ -Regex -: -: -capture_locations -] -method -. -/ -/ -/ -/ -/ -/ -This -also -returns -the -overall -match -if -one -was -found -. -When -a -match -is -/ -/ -/ -found -its -offsets -are -also -always -stored -in -locs -at -index -0 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -^ -( -[ -a -- -z -] -+ -) -= -( -\ -S -* -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert -! -( -re -. -captures_read -( -& -mut -locs -b -" -id -= -foo123 -" -) -. -is_some -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -9 -) -) -locs -. -get -( -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -2 -) -) -locs -. -get -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -3 -9 -) -) -locs -. -get -( -2 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_read -< -' -h -> -( -& -self -locs -: -& -mut -CaptureLocations -haystack -: -& -' -h -[ -u8 -] -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -captures_read_at -( -locs -haystack -0 -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -captures_read -] -but -starts -the -search -at -/ -/ -/ -the -given -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -eschew -" -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert -! -( -re -. -captures_read -( -& -mut -locs -& -hay -[ -2 -. -. -] -) -. -is_some -( -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert -! -( -re -. -captures_read_at -( -& -mut -locs -hay -2 -) -. -is_none -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_read_at -< -' -h -> -( -& -self -locs -: -& -mut -CaptureLocations -haystack -: -& -' -h -[ -u8 -] -start -: -usize -) -- -> -Option -< -Match -< -' -h -> -> -{ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -self -. -meta -. -search_captures -( -& -input -& -mut -locs -. -0 -) -; -locs -. -0 -. -get_match -( -) -. -map -( -| -m -| -Match -: -: -new -( -haystack -m -. -start -( -) -m -. -end -( -) -) -) -} -/ -/ -/ -An -undocumented -alias -for -captures_read_at -. -/ -/ -/ -/ -/ -/ -The -regex -- -capi -crate -previously -used -this -routine -so -to -avoid -/ -/ -/ -breaking -that -crate -we -continue -to -provide -the -name -as -an -undocumented -/ -/ -/ -alias -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -read_captures_at -< -' -h -> -( -& -self -locs -: -& -mut -CaptureLocations -haystack -: -& -' -h -[ -u8 -] -start -: -usize -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -captures_read_at -( -locs -haystack -start -) -} -} -/ -/ -/ -Auxiliary -methods -. -impl -Regex -{ -/ -/ -/ -Returns -the -original -string -of -this -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -foo -\ -w -+ -bar -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -re -. -as_str -( -) -r -" -foo -\ -w -+ -bar -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -as_str -( -& -self -) -- -> -& -str -{ -& -self -. -pattern -} -/ -/ -/ -Returns -an -iterator -over -the -capture -names -in -this -regex -. -/ -/ -/ -/ -/ -/ -The -iterator -returned -yields -elements -of -type -Option -< -& -str -> -. -That -is -/ -/ -/ -the -iterator -yields -values -for -all -capture -groups -even -ones -that -are -/ -/ -/ -unnamed -. -The -order -of -the -groups -corresponds -to -the -order -of -the -group -' -s -/ -/ -/ -corresponding -opening -parenthesis -. -/ -/ -/ -/ -/ -/ -The -first -element -of -the -iterator -always -yields -the -group -corresponding -/ -/ -/ -to -the -overall -match -and -this -group -is -always -unnamed -. -Therefore -the -/ -/ -/ -iterator -always -yields -at -least -one -group -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -basic -usage -with -a -mix -of -named -and -unnamed -capture -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -a -> -. -( -? -< -b -> -. -) -) -( -. -) -( -? -: -. -) -( -? -< -c -> -. -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -names -= -re -. -capture_names -( -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -None -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -Some -( -" -a -" -) -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -Some -( -" -b -" -) -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -None -) -) -; -/ -/ -/ -/ -/ -the -' -( -? -: -. -) -' -group -is -non -- -capturing -and -so -doesn -' -t -appear -here -! -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -Some -( -" -c -" -) -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -None -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -The -iterator -always -yields -at -least -one -element -even -for -regexes -with -/ -/ -/ -no -capture -groups -and -even -for -regexes -that -can -never -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -names -= -re -. -capture_names -( -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -None -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -None -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -& -& -b -] -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -names -= -re -. -capture_names -( -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -None -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -None -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -capture_names -( -& -self -) -- -> -CaptureNames -< -' -_ -> -{ -CaptureNames -( -self -. -meta -. -group_info -( -) -. -pattern_names -( -PatternID -: -: -ZERO -) -) -} -/ -/ -/ -Returns -the -number -of -captures -groups -in -this -regex -. -/ -/ -/ -/ -/ -/ -This -includes -all -named -and -unnamed -groups -including -the -implicit -/ -/ -/ -unnamed -group -that -is -always -present -and -corresponds -to -the -entire -/ -/ -/ -match -. -/ -/ -/ -/ -/ -/ -Since -the -implicit -unnamed -group -is -always -included -in -this -length -the -/ -/ -/ -length -returned -is -guaranteed -to -be -greater -than -zero -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -foo -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -1 -re -. -captures_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -foo -) -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -2 -re -. -captures_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -a -> -. -( -? -< -b -> -. -) -) -( -. -) -( -? -: -. -) -( -? -< -c -> -. -) -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -5 -re -. -captures_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -& -& -b -] -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -1 -re -. -captures_len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_len -( -& -self -) -- -> -usize -{ -self -. -meta -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -} -/ -/ -/ -Returns -the -total -number -of -capturing -groups -that -appear -in -every -/ -/ -/ -possible -match -. -/ -/ -/ -/ -/ -/ -If -the -number -of -capture -groups -can -vary -depending -on -the -match -then -/ -/ -/ -this -returns -None -. -That -is -a -value -is -only -returned -when -the -number -/ -/ -/ -of -matching -groups -is -invariant -or -" -static -. -" -/ -/ -/ -/ -/ -/ -Note -that -like -[ -Regex -: -: -captures_len -] -this -* -* -does -* -* -include -the -/ -/ -/ -implicit -capturing -group -corresponding -to -the -entire -match -. -Therefore -/ -/ -/ -when -a -non -- -None -value -is -returned -it -is -guaranteed -to -be -at -least -1 -. -/ -/ -/ -Stated -differently -a -return -value -of -Some -( -0 -) -is -impossible -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -few -cases -where -a -static -number -of -capture -groups -is -/ -/ -/ -available -and -a -few -cases -where -it -is -not -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -len -= -| -pattern -| -{ -/ -/ -/ -Regex -: -: -new -( -pattern -) -. -map -( -| -re -| -re -. -static_captures_len -( -) -) -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -len -( -" -a -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -a -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -a -) -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -len -( -" -( -a -) -( -b -) -| -( -c -) -( -d -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -( -a -) -| -b -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -a -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -( -b -) -* -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -b -) -+ -" -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -static_captures_len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -meta -. -static_captures_len -( -) -} -/ -/ -/ -Returns -a -fresh -allocated -set -of -capture -locations -that -can -/ -/ -/ -be -reused -in -multiple -calls -to -[ -Regex -: -: -captures_read -] -or -/ -/ -/ -[ -Regex -: -: -captures_read_at -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -. -) -( -. -) -( -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert -! -( -re -. -captures_read -( -& -mut -locs -b -" -Padron -" -) -. -is_some -( -) -) -; -/ -/ -/ -assert_eq -! -( -locs -. -get -( -0 -) -Some -( -( -0 -6 -) -) -) -; -/ -/ -/ -assert_eq -! -( -locs -. -get -( -1 -) -Some -( -( -0 -1 -) -) -) -; -/ -/ -/ -assert_eq -! -( -locs -. -get -( -2 -) -Some -( -( -1 -2 -) -) -) -; -/ -/ -/ -assert_eq -! -( -locs -. -get -( -3 -) -Some -( -( -2 -6 -) -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -capture_locations -( -& -self -) -- -> -CaptureLocations -{ -CaptureLocations -( -self -. -meta -. -create_captures -( -) -) -} -/ -/ -/ -An -alias -for -capture_locations -to -preserve -backward -compatibility -. -/ -/ -/ -/ -/ -/ -The -regex -- -capi -crate -uses -this -method -so -to -avoid -breaking -that -/ -/ -/ -crate -we -continue -to -export -it -as -an -undocumented -API -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -locations -( -& -self -) -- -> -CaptureLocations -{ -self -. -capture_locations -( -) -} -} -/ -/ -/ -Represents -a -single -match -of -a -regex -in -a -haystack -. -/ -/ -/ -/ -/ -/ -A -Match -contains -both -the -start -and -end -byte -offsets -of -the -match -and -the -/ -/ -/ -actual -substring -corresponding -to -the -range -of -those -byte -offsets -. -It -is -/ -/ -/ -guaranteed -that -start -< -= -end -. -When -start -= -= -end -the -match -is -empty -. -/ -/ -/ -/ -/ -/ -Unlike -the -top -- -level -Match -type -this -Match -type -is -produced -by -APIs -/ -/ -/ -that -search -& -[ -u8 -] -haystacks -. -This -means -that -the -offsets -in -a -Match -can -/ -/ -/ -point -to -anywhere -in -the -haystack -including -in -a -place -that -splits -the -/ -/ -/ -UTF -- -8 -encoding -of -a -Unicode -scalar -value -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameter -' -h -refers -to -the -lifetime -of -the -matched -of -the -/ -/ -/ -haystack -that -this -match -was -produced -from -. -/ -/ -/ -/ -/ -/ -# -Numbering -/ -/ -/ -/ -/ -/ -The -byte -offsets -in -a -Match -form -a -half -- -open -interval -. -That -is -the -/ -/ -/ -start -of -the -range -is -inclusive -and -the -end -of -the -range -is -exclusive -. -/ -/ -/ -For -example -given -a -haystack -abcFOOxyz -and -a -match -of -FOO -its -byte -/ -/ -/ -offset -range -starts -at -3 -and -ends -at -6 -. -3 -corresponds -to -F -and -/ -/ -/ -6 -corresponds -to -x -which -is -one -past -the -end -of -the -match -. -This -/ -/ -/ -corresponds -to -the -same -kind -of -slicing -that -Rust -uses -. -/ -/ -/ -/ -/ -/ -For -more -on -why -this -was -chosen -over -other -schemes -( -aside -from -being -/ -/ -/ -consistent -with -how -Rust -the -language -works -) -see -[ -this -discussion -] -and -/ -/ -/ -[ -Dijkstra -' -s -note -on -a -related -topic -] -[ -note -] -. -/ -/ -/ -/ -/ -/ -[ -this -discussion -] -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -discussions -/ -866 -/ -/ -/ -[ -note -] -: -https -: -/ -/ -www -. -cs -. -utexas -. -edu -/ -users -/ -EWD -/ -transcriptions -/ -EWD08xx -/ -EWD831 -. -html -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -value -of -each -of -the -methods -on -Match -for -a -/ -/ -/ -particular -search -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -p -{ -Greek -} -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Greek -: -" -. -as_bytes -( -) -; -/ -/ -/ -let -m -= -re -. -find -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -7 -m -. -start -( -) -) -; -/ -/ -/ -assert_eq -! -( -15 -m -. -end -( -) -) -; -/ -/ -/ -assert -! -( -! -m -. -is_empty -( -) -) -; -/ -/ -/ -assert_eq -! -( -8 -m -. -len -( -) -) -; -/ -/ -/ -assert_eq -! -( -7 -. -. -15 -m -. -range -( -) -) -; -/ -/ -/ -assert_eq -! -( -" -" -. -as_bytes -( -) -m -. -as_bytes -( -) -) -; -/ -/ -/ -# -[ -derive -( -Copy -Clone -Eq -PartialEq -) -] -pub -struct -Match -< -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -start -: -usize -end -: -usize -} -impl -< -' -h -> -Match -< -' -h -> -{ -/ -/ -/ -Returns -the -byte -offset -of -the -start -of -the -match -in -the -haystack -. -The -/ -/ -/ -start -of -the -match -corresponds -to -the -position -where -the -match -begins -/ -/ -/ -and -includes -the -first -byte -in -the -match -. -/ -/ -/ -/ -/ -/ -It -is -guaranteed -that -Match -: -: -start -( -) -< -= -Match -: -: -end -( -) -. -/ -/ -/ -/ -/ -/ -Unlike -the -top -- -level -Match -type -the -start -offset -may -appear -anywhere -/ -/ -/ -in -the -haystack -. -This -includes -between -the -code -units -of -a -UTF -- -8 -/ -/ -/ -encoded -Unicode -scalar -value -. -# -[ -inline -] -pub -fn -start -( -& -self -) -- -> -usize -{ -self -. -start -} -/ -/ -/ -Returns -the -byte -offset -of -the -end -of -the -match -in -the -haystack -. -The -/ -/ -/ -end -of -the -match -corresponds -to -the -byte -immediately -following -the -last -/ -/ -/ -byte -in -the -match -. -This -means -that -& -slice -[ -start -. -. -end -] -works -as -one -/ -/ -/ -would -expect -. -/ -/ -/ -/ -/ -/ -It -is -guaranteed -that -Match -: -: -start -( -) -< -= -Match -: -: -end -( -) -. -/ -/ -/ -/ -/ -/ -Unlike -the -top -- -level -Match -type -the -start -offset -may -appear -anywhere -/ -/ -/ -in -the -haystack -. -This -includes -between -the -code -units -of -a -UTF -- -8 -/ -/ -/ -encoded -Unicode -scalar -value -. -# -[ -inline -] -pub -fn -end -( -& -self -) -- -> -usize -{ -self -. -end -} -/ -/ -/ -Returns -true -if -and -only -if -this -match -has -a -length -of -zero -. -/ -/ -/ -/ -/ -/ -Note -that -an -empty -match -can -only -occur -when -the -regex -itself -can -/ -/ -/ -match -the -empty -string -. -Here -are -some -examples -of -regexes -that -can -/ -/ -/ -all -match -the -empty -string -: -^ -^ -\ -b -a -? -a -* -a -{ -0 -} -/ -/ -/ -( -foo -| -\ -d -+ -| -quux -) -? -. -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -start -= -= -self -. -end -} -/ -/ -/ -Returns -the -length -in -bytes -of -this -match -. -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -end -- -self -. -start -} -/ -/ -/ -Returns -the -range -over -the -starting -and -ending -byte -offsets -of -the -/ -/ -/ -match -in -the -haystack -. -# -[ -inline -] -pub -fn -range -( -& -self -) -- -> -core -: -: -ops -: -: -Range -< -usize -> -{ -self -. -start -. -. -self -. -end -} -/ -/ -/ -Returns -the -substring -of -the -haystack -that -matched -. -# -[ -inline -] -pub -fn -as_bytes -( -& -self -) -- -> -& -' -h -[ -u8 -] -{ -& -self -. -haystack -[ -self -. -range -( -) -] -} -/ -/ -/ -Creates -a -new -match -from -the -given -haystack -and -byte -offsets -. -# -[ -inline -] -fn -new -( -haystack -: -& -' -h -[ -u8 -] -start -: -usize -end -: -usize -) -- -> -Match -< -' -h -> -{ -Match -{ -haystack -start -end -} -} -} -impl -< -' -h -> -core -: -: -fmt -: -: -Debug -for -Match -< -' -h -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -fmt -= -f -. -debug_struct -( -" -Match -" -) -; -fmt -. -field -( -" -start -" -& -self -. -start -) -. -field -( -" -end -" -& -self -. -end -) -; -if -let -Ok -( -s -) -= -core -: -: -str -: -: -from_utf8 -( -self -. -as_bytes -( -) -) -{ -fmt -. -field -( -" -bytes -" -& -s -) -; -} -else -{ -/ -/ -FIXME -: -It -would -be -nice -if -this -could -be -printed -as -a -string -/ -/ -with -invalid -UTF -- -8 -replaced -with -hex -escapes -. -A -alloc -would -/ -/ -probably -okay -if -that -makes -it -easier -but -regex -- -automata -does -/ -/ -( -at -time -of -writing -) -have -internal -routines -that -do -this -. -So -/ -/ -maybe -we -should -expose -them -. -fmt -. -field -( -" -bytes -" -& -self -. -as_bytes -( -) -) -; -} -fmt -. -finish -( -) -} -} -impl -< -' -h -> -From -< -Match -< -' -h -> -> -for -& -' -h -[ -u8 -] -{ -fn -from -( -m -: -Match -< -' -h -> -) -- -> -& -' -h -[ -u8 -] -{ -m -. -as_bytes -( -) -} -} -impl -< -' -h -> -From -< -Match -< -' -h -> -> -for -core -: -: -ops -: -: -Range -< -usize -> -{ -fn -from -( -m -: -Match -< -' -h -> -) -- -> -core -: -: -ops -: -: -Range -< -usize -> -{ -m -. -range -( -) -} -} -/ -/ -/ -Represents -the -capture -groups -for -a -single -match -. -/ -/ -/ -/ -/ -/ -Capture -groups -refer -to -parts -of -a -regex -enclosed -in -parentheses -. -They -can -/ -/ -/ -be -optionally -named -. -The -purpose -of -capture -groups -is -to -be -able -to -/ -/ -/ -reference -different -parts -of -a -match -based -on -the -original -pattern -. -For -/ -/ -/ -example -say -you -want -to -match -the -individual -letters -in -a -5 -- -letter -word -: -/ -/ -/ -/ -/ -/ -text -/ -/ -/ -( -? -< -first -> -\ -w -) -( -\ -w -) -( -? -: -\ -w -) -\ -w -( -? -< -last -> -\ -w -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -regex -has -4 -capture -groups -: -/ -/ -/ -/ -/ -/ -* -The -group -at -index -0 -corresponds -to -the -overall -match -. -It -is -always -/ -/ -/ -present -in -every -match -and -never -has -a -name -. -/ -/ -/ -* -The -group -at -index -1 -with -name -first -corresponding -to -the -first -/ -/ -/ -letter -. -/ -/ -/ -* -The -group -at -index -2 -with -no -name -corresponding -to -the -second -letter -. -/ -/ -/ -* -The -group -at -index -3 -with -name -last -corresponding -to -the -fifth -and -/ -/ -/ -last -letter -. -/ -/ -/ -/ -/ -/ -Notice -that -( -? -: -\ -w -) -was -not -listed -above -as -a -capture -group -despite -it -/ -/ -/ -being -enclosed -in -parentheses -. -That -' -s -because -( -? -: -pattern -) -is -a -special -/ -/ -/ -syntax -that -permits -grouping -but -* -without -* -capturing -. -The -reason -for -not -/ -/ -/ -treating -it -as -a -capture -is -that -tracking -and -reporting -capture -groups -/ -/ -/ -requires -additional -state -that -may -lead -to -slower -searches -. -So -using -as -few -/ -/ -/ -capture -groups -as -possible -can -help -performance -. -( -Although -the -difference -/ -/ -/ -in -performance -of -a -couple -of -capture -groups -is -likely -immaterial -. -) -/ -/ -/ -/ -/ -/ -Values -with -this -type -are -created -by -[ -Regex -: -: -captures -] -or -/ -/ -/ -[ -Regex -: -: -captures_iter -] -. -/ -/ -/ -/ -/ -/ -' -h -is -the -lifetime -of -the -haystack -that -these -captures -were -matched -from -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -) -( -\ -w -) -( -? -: -\ -w -) -\ -w -( -? -< -last -> -\ -w -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -b -" -toady -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -b -" -toady -" -& -caps -[ -0 -] -) -; -/ -/ -/ -assert_eq -! -( -b -" -t -" -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -assert_eq -! -( -b -" -o -" -& -caps -[ -2 -] -) -; -/ -/ -/ -assert_eq -! -( -b -" -y -" -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -pub -struct -Captures -< -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -caps -: -captures -: -: -Captures -static_captures_len -: -Option -< -usize -> -} -impl -< -' -h -> -Captures -< -' -h -> -{ -/ -/ -/ -Returns -the -Match -associated -with -the -capture -group -at -index -i -. -If -/ -/ -/ -i -does -not -correspond -to -a -capture -group -or -if -the -capture -group -did -/ -/ -/ -not -participate -in -the -match -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -When -i -= -= -0 -this -is -guaranteed -to -return -a -non -- -None -value -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Get -the -substring -that -matched -with -a -default -of -an -empty -string -if -the -/ -/ -/ -group -didn -' -t -participate -in -the -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -- -z -] -+ -( -? -: -( -[ -0 -- -9 -] -+ -) -| -( -[ -A -- -Z -] -+ -) -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -b -" -abc123 -" -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -substr1 -= -caps -. -get -( -1 -) -. -map_or -( -& -b -" -" -[ -. -. -] -| -m -| -m -. -as_bytes -( -) -) -; -/ -/ -/ -let -substr2 -= -caps -. -get -( -2 -) -. -map_or -( -& -b -" -" -[ -. -. -] -| -m -| -m -. -as_bytes -( -) -) -; -/ -/ -/ -assert_eq -! -( -substr1 -b -" -123 -" -) -; -/ -/ -/ -assert_eq -! -( -substr2 -b -" -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get -( -& -self -i -: -usize -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -caps -. -get_group -( -i -) -. -map -( -| -sp -| -Match -: -: -new -( -self -. -haystack -sp -. -start -sp -. -end -) -) -} -/ -/ -/ -Returns -the -Match -associated -with -the -capture -group -named -name -. -If -/ -/ -/ -name -isn -' -t -a -valid -capture -group -or -it -refers -to -a -group -that -didn -' -t -/ -/ -/ -match -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -caps -[ -" -name -" -] -this -returns -a -Match -whose -lifetime -/ -/ -/ -matches -the -lifetime -of -the -haystack -in -this -Captures -value -. -/ -/ -/ -Conversely -the -substring -returned -by -caps -[ -" -name -" -] -has -a -lifetime -/ -/ -/ -of -the -Captures -value -which -is -likely -shorter -than -the -lifetime -of -/ -/ -/ -the -haystack -. -In -some -cases -it -may -be -necessary -to -use -this -method -to -/ -/ -/ -access -the -matching -substring -instead -of -the -caps -[ -" -name -" -] -notation -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Get -the -substring -that -matched -with -a -default -of -an -empty -string -if -the -/ -/ -/ -group -didn -' -t -participate -in -the -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -/ -/ -/ -r -" -[ -a -- -z -] -+ -( -? -: -( -? -< -numbers -> -[ -0 -- -9 -] -+ -) -| -( -? -< -letters -> -[ -A -- -Z -] -+ -) -) -" -/ -/ -/ -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -b -" -abc123 -" -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -numbers -= -caps -. -name -( -" -numbers -" -) -. -map_or -( -& -b -" -" -[ -. -. -] -| -m -| -m -. -as_bytes -( -) -) -; -/ -/ -/ -let -letters -= -caps -. -name -( -" -letters -" -) -. -map_or -( -& -b -" -" -[ -. -. -] -| -m -| -m -. -as_bytes -( -) -) -; -/ -/ -/ -assert_eq -! -( -numbers -b -" -123 -" -) -; -/ -/ -/ -assert_eq -! -( -letters -b -" -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -name -( -& -self -name -: -& -str -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -caps -. -get_group_by_name -( -name -) -. -map -( -| -sp -| -Match -: -: -new -( -self -. -haystack -sp -. -start -sp -. -end -) -) -} -/ -/ -/ -This -is -a -convenience -routine -for -extracting -the -substrings -/ -/ -/ -corresponding -to -matching -capture -groups -. -/ -/ -/ -/ -/ -/ -This -returns -a -tuple -where -the -first -element -corresponds -to -the -full -/ -/ -/ -substring -of -the -haystack -that -matched -the -regex -. -The -second -element -is -/ -/ -/ -an -array -of -substrings -with -each -corresponding -to -the -to -the -substring -/ -/ -/ -that -matched -for -a -particular -capture -group -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -number -of -possible -matching -groups -in -this -/ -/ -/ -Captures -value -is -not -fixed -to -N -in -all -circumstances -. -/ -/ -/ -More -precisely -this -routine -only -works -when -N -is -equivalent -to -/ -/ -/ -[ -Regex -: -: -static_captures_len -] -. -/ -/ -/ -/ -/ -/ -Stated -more -plainly -if -the -number -of -matching -capture -groups -in -a -/ -/ -/ -regex -can -vary -from -match -to -match -then -this -function -always -panics -. -/ -/ -/ -/ -/ -/ -For -example -( -a -) -( -b -) -| -( -c -) -could -produce -two -matching -capture -groups -/ -/ -/ -or -one -matching -capture -group -for -any -given -match -. -Therefore -one -/ -/ -/ -cannot -use -extract -with -such -a -pattern -. -/ -/ -/ -/ -/ -/ -But -a -pattern -like -( -a -) -( -b -) -| -( -c -) -( -d -) -can -be -used -with -extract -because -/ -/ -/ -the -number -of -capture -groups -in -every -match -is -always -equivalent -/ -/ -/ -even -if -the -capture -_indices_ -in -each -match -are -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -On -2010 -- -03 -- -14 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -let -Some -( -( -full -[ -year -month -day -] -) -) -= -/ -/ -/ -re -. -captures -( -hay -) -. -map -( -| -caps -| -caps -. -extract -( -) -) -else -{ -return -} -; -/ -/ -/ -assert_eq -! -( -b -" -2010 -- -03 -- -14 -" -full -) -; -/ -/ -/ -assert_eq -! -( -b -" -2010 -" -year -) -; -/ -/ -/ -assert_eq -! -( -b -" -03 -" -month -) -; -/ -/ -/ -assert_eq -! -( -b -" -14 -" -day -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -iteration -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -this -method -when -iterating -over -all -/ -/ -/ -Captures -matches -in -a -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -1973 -- -01 -- -05 -1975 -- -08 -- -25 -and -1980 -- -10 -- -18 -" -; -/ -/ -/ -/ -/ -/ -let -mut -dates -: -Vec -< -( -& -[ -u8 -] -& -[ -u8 -] -& -[ -u8 -] -) -> -= -vec -! -[ -] -; -/ -/ -/ -for -( -_ -[ -y -m -d -] -) -in -re -. -captures_iter -( -hay -) -. -map -( -| -c -| -c -. -extract -( -) -) -{ -/ -/ -/ -dates -. -push -( -( -y -m -d -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -dates -vec -! -[ -/ -/ -/ -( -& -b -" -1973 -" -[ -. -. -] -& -b -" -01 -" -[ -. -. -] -& -b -" -05 -" -[ -. -. -] -) -/ -/ -/ -( -& -b -" -1975 -" -[ -. -. -] -& -b -" -08 -" -[ -. -. -] -& -b -" -25 -" -[ -. -. -] -) -/ -/ -/ -( -& -b -" -1980 -" -[ -. -. -] -& -b -" -10 -" -[ -. -. -] -& -b -" -18 -" -[ -. -. -] -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -parsing -different -formats -/ -/ -/ -/ -/ -/ -This -API -is -particularly -useful -when -you -need -to -extract -a -particular -/ -/ -/ -value -that -might -occur -in -a -different -format -. -Consider -for -example -/ -/ -/ -an -identifier -that -might -be -in -double -quotes -or -single -quotes -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -# -" -id -: -( -? -: -" -( -[ -^ -" -] -+ -) -" -| -' -( -[ -^ -' -] -+ -) -' -) -" -# -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -br -# -" -The -first -is -id -: -" -foo -" -and -the -second -is -id -: -' -bar -' -. -" -# -; -/ -/ -/ -let -mut -ids -= -vec -! -[ -] -; -/ -/ -/ -for -( -_ -[ -id -] -) -in -re -. -captures_iter -( -hay -) -. -map -( -| -c -| -c -. -extract -( -) -) -{ -/ -/ -/ -ids -. -push -( -id -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -ids -vec -! -[ -b -" -foo -" -b -" -bar -" -] -) -; -/ -/ -/ -pub -fn -extract -< -const -N -: -usize -> -( -& -self -) -- -> -( -& -' -h -[ -u8 -] -[ -& -' -h -[ -u8 -] -; -N -] -) -{ -let -len -= -self -. -static_captures_len -. -expect -( -" -number -of -capture -groups -can -vary -in -a -match -" -) -. -checked_sub -( -1 -) -. -expect -( -" -number -of -groups -is -always -greater -than -zero -" -) -; -assert_eq -! -( -N -len -" -asked -for -{ -} -groups -but -must -ask -for -{ -} -" -N -len -) -; -/ -/ -The -regex -- -automata -variant -of -extract -is -a -bit -more -permissive -. -/ -/ -It -doesn -' -t -require -the -number -of -matching -capturing -groups -to -be -/ -/ -static -and -you -can -even -request -fewer -groups -than -what -' -s -there -. -So -/ -/ -this -is -guaranteed -to -never -panic -because -we -' -ve -asserted -above -that -/ -/ -the -user -has -requested -precisely -the -number -of -groups -that -must -be -/ -/ -present -in -any -match -for -this -regex -. -self -. -caps -. -extract_bytes -( -self -. -haystack -) -} -/ -/ -/ -Expands -all -instances -of -ref -in -replacement -to -the -corresponding -/ -/ -/ -capture -group -and -writes -them -to -the -dst -buffer -given -. -A -ref -can -/ -/ -/ -be -a -capture -group -index -or -a -name -. -If -ref -doesn -' -t -refer -to -a -capture -/ -/ -/ -group -that -participated -in -the -match -then -it -is -replaced -with -the -/ -/ -/ -empty -string -. -/ -/ -/ -/ -/ -/ -# -Format -/ -/ -/ -/ -/ -/ -The -format -of -the -replacement -string -supports -two -different -kinds -of -/ -/ -/ -capture -references -: -unbraced -and -braced -. -/ -/ -/ -/ -/ -/ -For -the -unbraced -format -the -format -supported -is -ref -where -name -/ -/ -/ -can -be -any -character -in -the -class -[ -0 -- -9A -- -Za -- -z_ -] -. -ref -is -always -/ -/ -/ -the -longest -possible -parse -. -So -for -example -1a -corresponds -to -the -/ -/ -/ -capture -group -named -1a -and -not -the -capture -group -at -index -1 -. -If -/ -/ -/ -ref -matches -^ -[ -0 -- -9 -] -+ -then -it -is -treated -as -a -capture -group -index -/ -/ -/ -itself -and -not -a -name -. -/ -/ -/ -/ -/ -/ -For -the -braced -format -the -format -supported -is -{ -ref -} -where -ref -can -/ -/ -/ -be -any -sequence -of -bytes -except -for -} -. -If -no -closing -brace -occurs -/ -/ -/ -then -it -is -not -considered -a -capture -reference -. -As -with -the -unbraced -/ -/ -/ -format -if -ref -matches -^ -[ -0 -- -9 -] -+ -then -it -is -treated -as -a -capture -/ -/ -/ -group -index -and -not -a -name -. -/ -/ -/ -/ -/ -/ -The -braced -format -is -useful -for -exerting -precise -control -over -the -name -/ -/ -/ -of -the -capture -reference -. -For -example -{ -1 -} -a -corresponds -to -the -/ -/ -/ -capture -group -reference -1 -followed -by -the -letter -a -where -as -1a -/ -/ -/ -( -as -mentioned -above -) -corresponds -to -the -capture -group -reference -1a -. -/ -/ -/ -The -braced -format -is -also -useful -for -expressing -capture -group -names -/ -/ -/ -that -use -characters -not -supported -by -the -unbraced -format -. -For -example -/ -/ -/ -{ -foo -[ -bar -] -. -baz -} -refers -to -the -capture -group -named -foo -[ -bar -] -. -baz -. -/ -/ -/ -/ -/ -/ -If -a -capture -group -reference -is -found -and -it -does -not -refer -to -a -valid -/ -/ -/ -capture -group -then -it -will -be -replaced -with -the -empty -string -. -/ -/ -/ -/ -/ -/ -To -write -a -literal -use -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -/ -/ -/ -r -" -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -" -/ -/ -/ -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -On -14 -- -03 -- -2010 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -let -caps -= -re -. -captures -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -dst -= -vec -! -[ -] -; -/ -/ -/ -caps -. -expand -( -b -" -year -= -year -month -= -month -day -= -day -" -& -mut -dst -) -; -/ -/ -/ -assert_eq -! -( -dst -b -" -year -= -2010 -month -= -03 -day -= -14 -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -expand -( -& -self -replacement -: -& -[ -u8 -] -dst -: -& -mut -Vec -< -u8 -> -) -{ -self -. -caps -. -interpolate_bytes_into -( -self -. -haystack -replacement -dst -) -; -} -/ -/ -/ -Returns -an -iterator -over -all -capture -groups -. -This -includes -both -/ -/ -/ -matching -and -non -- -matching -groups -. -/ -/ -/ -/ -/ -/ -The -iterator -always -yields -at -least -one -matching -group -: -the -first -group -/ -/ -/ -( -at -index -0 -) -with -no -name -. -Subsequent -groups -are -returned -in -the -order -/ -/ -/ -of -their -opening -parenthesis -in -the -regex -. -/ -/ -/ -/ -/ -/ -The -elements -yielded -have -type -Option -< -Match -< -' -h -> -> -where -a -non -- -None -/ -/ -/ -value -is -present -if -the -capture -group -matches -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -\ -w -) -( -\ -d -) -? -( -\ -w -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -b -" -AZ -" -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -caps -. -iter -( -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -. -unwrap -( -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -Some -( -& -b -" -AZ -" -[ -. -. -] -) -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -. -unwrap -( -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -Some -( -& -b -" -A -" -[ -. -. -] -) -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -. -unwrap -( -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -None -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -. -unwrap -( -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -Some -( -& -b -" -Z -" -[ -. -. -] -) -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -None -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -iter -< -' -c -> -( -& -' -c -self -) -- -> -SubCaptureMatches -< -' -c -' -h -> -{ -SubCaptureMatches -{ -haystack -: -self -. -haystack -it -: -self -. -caps -. -iter -( -) -} -} -/ -/ -/ -Returns -the -total -number -of -capture -groups -. -This -includes -both -/ -/ -/ -matching -and -non -- -matching -groups -. -/ -/ -/ -/ -/ -/ -The -length -returned -is -always -equivalent -to -the -number -of -elements -/ -/ -/ -yielded -by -[ -Captures -: -: -iter -] -. -Consequently -the -length -is -always -/ -/ -/ -greater -than -zero -since -every -Captures -value -always -includes -the -/ -/ -/ -match -for -the -entire -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -\ -w -) -( -\ -d -) -? -( -\ -w -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -b -" -AZ -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -caps -. -len -( -) -4 -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -caps -. -group_len -( -) -} -} -impl -< -' -h -> -core -: -: -fmt -: -: -Debug -for -Captures -< -' -h -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -/ -/ -/ -A -little -helper -type -to -provide -a -nice -map -- -like -debug -/ -/ -/ -representation -for -our -capturing -group -spans -. -/ -/ -/ -/ -/ -/ -regex -- -automata -has -something -similar -but -it -includes -the -pattern -/ -/ -/ -ID -in -its -debug -output -which -is -confusing -. -It -also -doesn -' -t -include -/ -/ -/ -that -strings -that -match -because -a -regex -- -automata -Captures -doesn -' -t -/ -/ -/ -borrow -the -haystack -. -struct -CapturesDebugMap -< -' -a -> -{ -caps -: -& -' -a -Captures -< -' -a -> -} -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -CapturesDebugMap -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -map -= -f -. -debug_map -( -) -; -let -names -= -self -. -caps -. -caps -. -group_info -( -) -. -pattern_names -( -PatternID -: -: -ZERO -) -; -for -( -group_index -maybe_name -) -in -names -. -enumerate -( -) -{ -let -key -= -Key -( -group_index -maybe_name -) -; -match -self -. -caps -. -get -( -group_index -) -{ -None -= -> -map -. -entry -( -& -key -& -None -: -: -< -( -) -> -) -Some -( -mat -) -= -> -map -. -entry -( -& -key -& -Value -( -mat -) -) -} -; -} -map -. -finish -( -) -} -} -struct -Key -< -' -a -> -( -usize -Option -< -& -' -a -str -> -) -; -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -Key -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -} -" -self -. -0 -) -? -; -if -let -Some -( -name -) -= -self -. -1 -{ -write -! -( -f -" -/ -{ -: -? -} -" -name -) -? -; -} -Ok -( -( -) -) -} -} -struct -Value -< -' -a -> -( -Match -< -' -a -> -) -; -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -Value -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -use -regex_automata -: -: -util -: -: -escape -: -: -DebugHaystack -; -write -! -( -f -" -{ -} -. -. -{ -} -/ -{ -: -? -} -" -self -. -0 -. -start -( -) -self -. -0 -. -end -( -) -DebugHaystack -( -self -. -0 -. -as_bytes -( -) -) -) -} -} -f -. -debug_tuple -( -" -Captures -" -) -. -field -( -& -CapturesDebugMap -{ -caps -: -self -} -) -. -finish -( -) -} -} -/ -/ -/ -Get -a -matching -capture -group -' -s -haystack -substring -by -index -. -/ -/ -/ -/ -/ -/ -The -haystack -substring -returned -can -' -t -outlive -the -Captures -object -if -this -/ -/ -/ -method -is -used -because -of -how -Index -is -defined -( -normally -a -[ -i -] -is -part -/ -/ -/ -of -a -and -can -' -t -outlive -it -) -. -To -work -around -this -limitation -do -that -use -/ -/ -/ -[ -Captures -: -: -get -] -instead -. -/ -/ -/ -/ -/ -/ -' -h -is -the -lifetime -of -the -matched -haystack -but -the -lifetime -of -the -/ -/ -/ -& -str -returned -by -this -implementation -is -the -lifetime -of -the -Captures -/ -/ -/ -value -itself -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -there -is -no -matching -group -at -the -given -index -. -impl -< -' -h -> -core -: -: -ops -: -: -Index -< -usize -> -for -Captures -< -' -h -> -{ -type -Output -= -[ -u8 -] -; -/ -/ -The -lifetime -is -written -out -to -make -it -clear -that -the -& -str -returned -/ -/ -does -NOT -have -a -lifetime -equivalent -to -' -h -. -fn -index -< -' -a -> -( -& -' -a -self -i -: -usize -) -- -> -& -' -a -[ -u8 -] -{ -self -. -get -( -i -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -. -unwrap_or_else -( -| -| -panic -! -( -" -no -group -at -index -' -{ -} -' -" -i -) -) -} -} -/ -/ -/ -Get -a -matching -capture -group -' -s -haystack -substring -by -name -. -/ -/ -/ -/ -/ -/ -The -haystack -substring -returned -can -' -t -outlive -the -Captures -object -if -this -/ -/ -/ -method -is -used -because -of -how -Index -is -defined -( -normally -a -[ -i -] -is -part -/ -/ -/ -of -a -and -can -' -t -outlive -it -) -. -To -work -around -this -limitation -do -that -use -/ -/ -/ -[ -Captures -: -: -get -] -instead -. -/ -/ -/ -/ -/ -/ -' -h -is -the -lifetime -of -the -matched -haystack -but -the -lifetime -of -the -/ -/ -/ -& -str -returned -by -this -implementation -is -the -lifetime -of -the -Captures -/ -/ -/ -value -itself -. -/ -/ -/ -/ -/ -/ -' -n -is -the -lifetime -of -the -group -name -used -to -index -the -Captures -value -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -there -is -no -matching -group -at -the -given -name -. -impl -< -' -h -' -n -> -core -: -: -ops -: -: -Index -< -& -' -n -str -> -for -Captures -< -' -h -> -{ -type -Output -= -[ -u8 -] -; -fn -index -< -' -a -> -( -& -' -a -self -name -: -& -' -n -str -) -- -> -& -' -a -[ -u8 -] -{ -self -. -name -( -name -) -. -map -( -| -m -| -m -. -as_bytes -( -) -) -. -unwrap_or_else -( -| -| -panic -! -( -" -no -group -named -' -{ -} -' -" -name -) -) -} -} -/ -/ -/ -A -low -level -representation -of -the -byte -offsets -of -each -capture -group -. -/ -/ -/ -/ -/ -/ -You -can -think -of -this -as -a -lower -level -[ -Captures -] -where -this -type -does -/ -/ -/ -not -support -named -capturing -groups -directly -and -it -does -not -borrow -the -/ -/ -/ -haystack -that -these -offsets -were -matched -on -. -/ -/ -/ -/ -/ -/ -Primarily -this -type -is -useful -when -using -the -lower -level -Regex -APIs -such -/ -/ -/ -as -[ -Regex -: -: -captures_read -] -which -permits -amortizing -the -allocation -in -/ -/ -/ -which -capture -match -offsets -are -stored -. -/ -/ -/ -/ -/ -/ -In -order -to -build -a -value -of -this -type -you -' -ll -need -to -call -the -/ -/ -/ -[ -Regex -: -: -capture_locations -] -method -. -The -value -returned -can -then -be -reused -/ -/ -/ -in -subsequent -searches -for -that -regex -. -Using -it -for -other -regexes -may -/ -/ -/ -result -in -a -panic -or -otherwise -incorrect -results -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -create -and -use -CaptureLocations -in -a -search -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -+ -) -\ -s -+ -( -? -< -last -> -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -let -m -= -re -. -captures_read -( -& -mut -locs -b -" -Bruce -Springsteen -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -17 -m -. -range -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -17 -) -) -locs -. -get -( -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -5 -) -) -locs -. -get -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -6 -17 -) -) -locs -. -get -( -2 -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Asking -for -an -invalid -capture -group -always -returns -None -. -/ -/ -/ -assert_eq -! -( -None -locs -. -get -( -3 -) -) -; -/ -/ -/ -assert_eq -! -( -None -locs -. -get -( -34973498648 -) -) -; -/ -/ -/ -assert_eq -! -( -None -locs -. -get -( -9944060567225171988 -) -) -; -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -CaptureLocations -( -captures -: -: -Captures -) -; -/ -/ -/ -A -type -alias -for -CaptureLocations -for -backwards -compatibility -. -/ -/ -/ -/ -/ -/ -Previously -we -exported -CaptureLocations -as -Locations -in -an -/ -/ -/ -undocumented -API -. -To -prevent -breaking -that -code -( -e -. -g -. -in -regex -- -capi -) -/ -/ -/ -we -continue -re -- -exporting -the -same -undocumented -API -. -# -[ -doc -( -hidden -) -] -pub -type -Locations -= -CaptureLocations -; -impl -CaptureLocations -{ -/ -/ -/ -Returns -the -start -and -end -byte -offsets -of -the -capture -group -at -index -/ -/ -/ -i -. -This -returns -None -if -i -is -not -a -valid -capture -group -or -if -the -/ -/ -/ -capture -group -did -not -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -+ -) -\ -s -+ -( -? -< -last -> -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -re -. -captures_read -( -& -mut -locs -b -" -Bruce -Springsteen -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -17 -) -) -locs -. -get -( -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -5 -) -) -locs -. -get -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -6 -17 -) -) -locs -. -get -( -2 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get -( -& -self -i -: -usize -) -- -> -Option -< -( -usize -usize -) -> -{ -self -. -0 -. -get_group -( -i -) -. -map -( -| -sp -| -( -sp -. -start -sp -. -end -) -) -} -/ -/ -/ -Returns -the -total -number -of -capture -groups -( -even -if -they -didn -' -t -match -) -. -/ -/ -/ -That -is -the -length -returned -is -unaffected -by -the -result -of -a -search -. -/ -/ -/ -/ -/ -/ -This -is -always -at -least -1 -since -every -regex -has -at -least -1 -/ -/ -/ -capturing -group -that -corresponds -to -the -entire -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -+ -) -\ -s -+ -( -? -< -last -> -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert_eq -! -( -3 -locs -. -len -( -) -) -; -/ -/ -/ -re -. -captures_read -( -& -mut -locs -b -" -Bruce -Springsteen -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -3 -locs -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -the -length -is -always -at -least -1 -regardless -of -the -regex -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert_eq -! -( -1 -locs -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -[ -a -& -& -b -] -is -a -regex -that -never -matches -anything -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -& -& -b -] -" -) -. -unwrap -( -) -; -/ -/ -/ -let -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert_eq -! -( -1 -locs -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -/ -/ -self -. -0 -. -group_len -( -) -returns -0 -if -the -underlying -captures -doesn -' -t -/ -/ -represent -a -match -but -the -behavior -guaranteed -for -this -method -is -/ -/ -that -the -length -doesn -' -t -change -based -on -a -match -or -not -. -self -. -0 -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -} -/ -/ -/ -An -alias -for -the -get -method -for -backwards -compatibility -. -/ -/ -/ -/ -/ -/ -Previously -we -exported -get -as -pos -in -an -undocumented -API -. -To -/ -/ -/ -prevent -breaking -that -code -( -e -. -g -. -in -regex -- -capi -) -we -continue -/ -/ -/ -re -- -exporting -the -same -undocumented -API -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -pos -( -& -self -i -: -usize -) -- -> -Option -< -( -usize -usize -) -> -{ -self -. -get -( -i -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -in -a -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -[ -Match -] -values -. -The -iterator -stops -when -no -more -/ -/ -/ -matches -can -be -found -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -and -' -h -is -the -/ -/ -/ -lifetime -of -the -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -find_iter -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -an -iterator -runs -potentially -many -searches -on -the -haystack -/ -/ -/ -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -complexity -the -/ -/ -/ -overall -worst -case -time -complexity -for -iteration -is -O -( -m -* -n -^ -2 -) -. -# -[ -derive -( -Debug -) -] -pub -struct -Matches -< -' -r -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -it -: -meta -: -: -FindMatches -< -' -r -' -h -> -} -impl -< -' -r -' -h -> -Iterator -for -Matches -< -' -r -' -h -> -{ -type -Item -= -Match -< -' -h -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -it -. -next -( -) -. -map -( -| -sp -| -Match -: -: -new -( -self -. -haystack -sp -. -start -( -) -sp -. -end -( -) -) -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -/ -/ -This -can -actually -be -up -to -2x -faster -than -calling -next -( -) -until -/ -/ -completion -because -counting -matches -when -using -a -DFA -only -requires -/ -/ -finding -the -end -of -each -match -. -But -returning -a -Match -via -next -( -) -/ -/ -requires -the -start -of -each -match -which -with -a -DFA -requires -a -/ -/ -reverse -forward -scan -to -find -it -. -self -. -it -. -count -( -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -Matches -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -capture -matches -in -a -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -[ -Captures -] -values -. -The -iterator -stops -when -no -more -/ -/ -/ -matches -can -be -found -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -and -' -h -is -the -/ -/ -/ -lifetime -of -the -matched -string -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -captures_iter -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -an -iterator -runs -potentially -many -searches -on -the -haystack -/ -/ -/ -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -complexity -the -/ -/ -/ -overall -worst -case -time -complexity -for -iteration -is -O -( -m -* -n -^ -2 -) -. -# -[ -derive -( -Debug -) -] -pub -struct -CaptureMatches -< -' -r -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -it -: -meta -: -: -CapturesMatches -< -' -r -' -h -> -} -impl -< -' -r -' -h -> -Iterator -for -CaptureMatches -< -' -r -' -h -> -{ -type -Item -= -Captures -< -' -h -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Captures -< -' -h -> -> -{ -let -static_captures_len -= -self -. -it -. -regex -( -) -. -static_captures_len -( -) -; -self -. -it -. -next -( -) -. -map -( -| -caps -| -Captures -{ -haystack -: -self -. -haystack -caps -static_captures_len -} -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -/ -/ -This -can -actually -be -up -to -2x -faster -than -calling -next -( -) -until -/ -/ -completion -because -counting -matches -when -using -a -DFA -only -requires -/ -/ -finding -the -end -of -each -match -. -But -returning -a -Match -via -next -( -) -/ -/ -requires -the -start -of -each -match -which -with -a -DFA -requires -a -/ -/ -reverse -forward -scan -to -find -it -. -self -. -it -. -count -( -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -CaptureMatches -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -all -substrings -delimited -by -a -regex -match -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -and -' -h -is -the -/ -/ -/ -lifetime -of -the -byte -string -being -split -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -split -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -an -iterator -runs -potentially -many -searches -on -the -haystack -/ -/ -/ -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -complexity -the -/ -/ -/ -overall -worst -case -time -complexity -for -iteration -is -O -( -m -* -n -^ -2 -) -. -# -[ -derive -( -Debug -) -] -pub -struct -Split -< -' -r -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -it -: -meta -: -: -Split -< -' -r -' -h -> -} -impl -< -' -r -' -h -> -Iterator -for -Split -< -' -r -' -h -> -{ -type -Item -= -& -' -h -[ -u8 -] -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -& -' -h -[ -u8 -] -> -{ -self -. -it -. -next -( -) -. -map -( -| -span -| -& -self -. -haystack -[ -span -] -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -Split -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -at -most -N -substrings -delimited -by -a -regex -match -. -/ -/ -/ -/ -/ -/ -The -last -substring -yielded -by -this -iterator -will -be -whatever -remains -after -/ -/ -/ -N -- -1 -splits -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -and -' -h -is -the -/ -/ -/ -lifetime -of -the -byte -string -being -split -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -splitn -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -an -iterator -runs -potentially -many -searches -on -the -haystack -/ -/ -/ -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -complexity -the -/ -/ -/ -overall -worst -case -time -complexity -for -iteration -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -Although -note -that -the -worst -case -time -here -has -an -upper -bound -given -/ -/ -/ -by -the -limit -parameter -to -[ -Regex -: -: -splitn -] -. -# -[ -derive -( -Debug -) -] -pub -struct -SplitN -< -' -r -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -it -: -meta -: -: -SplitN -< -' -r -' -h -> -} -impl -< -' -r -' -h -> -Iterator -for -SplitN -< -' -r -' -h -> -{ -type -Item -= -& -' -h -[ -u8 -] -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -& -' -h -[ -u8 -] -> -{ -self -. -it -. -next -( -) -. -map -( -| -span -| -& -self -. -haystack -[ -span -] -) -} -# -[ -inline -] -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -it -. -size_hint -( -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -SplitN -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -the -names -of -all -capture -groups -in -a -regex -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -values -of -type -Option -< -& -str -> -in -order -of -the -opening -/ -/ -/ -capture -group -parenthesis -in -the -regex -pattern -. -None -is -yielded -for -/ -/ -/ -groups -with -no -name -. -The -first -element -always -corresponds -to -the -implicit -/ -/ -/ -and -unnamed -group -for -the -overall -match -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -capture_names -] -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -CaptureNames -< -' -r -> -( -captures -: -: -GroupInfoPatternNames -< -' -r -> -) -; -impl -< -' -r -> -Iterator -for -CaptureNames -< -' -r -> -{ -type -Item -= -Option -< -& -' -r -str -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Option -< -& -' -r -str -> -> -{ -self -. -0 -. -next -( -) -} -# -[ -inline -] -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -0 -. -size_hint -( -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -self -. -0 -. -count -( -) -} -} -impl -< -' -r -> -ExactSizeIterator -for -CaptureNames -< -' -r -> -{ -} -impl -< -' -r -> -core -: -: -iter -: -: -FusedIterator -for -CaptureNames -< -' -r -> -{ -} -/ -/ -/ -An -iterator -over -all -group -matches -in -a -[ -Captures -] -value -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -values -of -type -Option -< -Match -< -' -h -> -> -where -' -h -is -the -/ -/ -/ -lifetime -of -the -haystack -that -the -matches -are -for -. -The -order -of -elements -/ -/ -/ -yielded -corresponds -to -the -order -of -the -opening -parenthesis -for -the -group -/ -/ -/ -in -the -regex -pattern -. -None -is -yielded -for -groups -that -did -not -participate -/ -/ -/ -in -the -match -. -/ -/ -/ -/ -/ -/ -The -first -element -always -corresponds -to -the -implicit -group -for -the -overall -/ -/ -/ -match -. -Since -this -iterator -is -created -by -a -[ -Captures -] -value -and -a -/ -/ -/ -Captures -value -is -only -created -when -a -match -occurs -it -follows -that -the -/ -/ -/ -first -element -yielded -by -this -iterator -is -guaranteed -to -be -non -- -None -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -c -corresponds -to -the -lifetime -of -the -Captures -value -that -/ -/ -/ -created -this -iterator -and -the -lifetime -' -h -corresponds -to -the -originally -/ -/ -/ -matched -haystack -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -SubCaptureMatches -< -' -c -' -h -> -{ -haystack -: -& -' -h -[ -u8 -] -it -: -captures -: -: -CapturesPatternIter -< -' -c -> -} -impl -< -' -c -' -h -> -Iterator -for -SubCaptureMatches -< -' -c -' -h -> -{ -type -Item -= -Option -< -Match -< -' -h -> -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Option -< -Match -< -' -h -> -> -> -{ -self -. -it -. -next -( -) -. -map -( -| -group -| -{ -group -. -map -( -| -sp -| -Match -: -: -new -( -self -. -haystack -sp -. -start -sp -. -end -) -) -} -) -} -# -[ -inline -] -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -it -. -size_hint -( -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -self -. -it -. -count -( -) -} -} -impl -< -' -c -' -h -> -ExactSizeIterator -for -SubCaptureMatches -< -' -c -' -h -> -{ -} -impl -< -' -c -' -h -> -core -: -: -iter -: -: -FusedIterator -for -SubCaptureMatches -< -' -c -' -h -> -{ -} -/ -/ -/ -A -trait -for -types -that -can -be -used -to -replace -matches -in -a -haystack -. -/ -/ -/ -/ -/ -/ -In -general -users -of -this -crate -shouldn -' -t -need -to -implement -this -trait -/ -/ -/ -since -implementations -are -already -provided -for -& -[ -u8 -] -along -with -other -/ -/ -/ -variants -of -byte -string -types -as -well -as -FnMut -( -& -Captures -) -- -> -Vec -< -u8 -> -( -or -/ -/ -/ -any -FnMut -( -& -Captures -) -- -> -T -where -T -: -AsRef -< -[ -u8 -] -> -) -. -Those -cover -most -use -/ -/ -/ -cases -but -callers -can -implement -this -trait -directly -if -necessary -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -basic -implementation -of -the -Replacer -trait -. -This -can -/ -/ -/ -be -done -much -more -simply -using -the -replacement -byte -string -interpolation -/ -/ -/ -support -( -e -. -g -. -first -last -) -but -this -approach -avoids -needing -to -parse -/ -/ -/ -the -replacement -byte -string -at -all -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -{ -Captures -Regex -Replacer -} -; -/ -/ -/ -/ -/ -/ -struct -NameSwapper -; -/ -/ -/ -/ -/ -/ -impl -Replacer -for -NameSwapper -{ -/ -/ -/ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -/ -/ -/ -dst -. -extend_from_slice -( -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -dst -. -extend_from_slice -( -b -" -" -) -; -/ -/ -/ -dst -. -extend_from_slice -( -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -last -> -[ -^ -\ -s -] -+ -) -\ -s -+ -( -? -< -first -> -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -b -" -Springsteen -Bruce -" -NameSwapper -) -; -/ -/ -/ -assert_eq -! -( -result -& -b -" -Bruce -Springsteen -" -[ -. -. -] -) -; -/ -/ -/ -pub -trait -Replacer -{ -/ -/ -/ -Appends -possibly -empty -data -to -dst -to -replace -the -current -match -. -/ -/ -/ -/ -/ -/ -The -current -match -is -represented -by -caps -which -is -guaranteed -to -have -/ -/ -/ -a -match -at -capture -group -0 -. -/ -/ -/ -/ -/ -/ -For -example -a -no -- -op -replacement -would -be -/ -/ -/ -dst -. -extend_from_slice -( -& -caps -[ -0 -] -) -. -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -; -/ -/ -/ -Return -a -fixed -unchanging -replacement -byte -string -. -/ -/ -/ -/ -/ -/ -When -doing -replacements -if -access -to -[ -Captures -] -is -not -needed -( -e -. -g -. -/ -/ -/ -the -replacement -byte -string -does -not -need -expansion -) -then -it -can -/ -/ -/ -be -beneficial -to -avoid -finding -sub -- -captures -. -/ -/ -/ -/ -/ -/ -In -general -this -is -called -once -for -every -call -to -a -replacement -routine -/ -/ -/ -such -as -[ -Regex -: -: -replace_all -] -. -fn -no_expansion -< -' -r -> -( -& -' -r -mut -self -) -- -> -Option -< -Cow -< -' -r -[ -u8 -] -> -> -{ -None -} -/ -/ -/ -Returns -a -type -that -implements -Replacer -but -that -borrows -and -wraps -/ -/ -/ -this -Replacer -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -you -want -to -take -a -generic -Replacer -( -which -might -/ -/ -/ -not -be -cloneable -) -and -use -it -without -consuming -it -so -it -can -be -used -/ -/ -/ -more -than -once -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -{ -Regex -Replacer -} -; -/ -/ -/ -/ -/ -/ -fn -replace_all_twice -< -R -: -Replacer -> -( -/ -/ -/ -re -: -Regex -/ -/ -/ -src -: -& -[ -u8 -] -/ -/ -/ -mut -rep -: -R -/ -/ -/ -) -- -> -Vec -< -u8 -> -{ -/ -/ -/ -let -dst -= -re -. -replace_all -( -src -rep -. -by_ref -( -) -) -; -/ -/ -/ -let -dst -= -re -. -replace_all -( -& -dst -rep -. -by_ref -( -) -) -; -/ -/ -/ -dst -. -into_owned -( -) -/ -/ -/ -} -/ -/ -/ -fn -by_ref -< -' -r -> -( -& -' -r -mut -self -) -- -> -ReplacerRef -< -' -r -Self -> -{ -ReplacerRef -( -self -) -} -} -impl -< -' -a -const -N -: -usize -> -Replacer -for -& -' -a -[ -u8 -; -N -] -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -caps -. -expand -( -& -* -* -self -dst -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -no_expansion -( -self -) -} -} -impl -< -const -N -: -usize -> -Replacer -for -[ -u8 -; -N -] -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -caps -. -expand -( -& -* -self -dst -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -no_expansion -( -self -) -} -} -impl -< -' -a -> -Replacer -for -& -' -a -[ -u8 -] -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -caps -. -expand -( -* -self -dst -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -no_expansion -( -self -) -} -} -impl -< -' -a -> -Replacer -for -& -' -a -Vec -< -u8 -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -caps -. -expand -( -* -self -dst -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -no_expansion -( -self -) -} -} -impl -Replacer -for -Vec -< -u8 -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -caps -. -expand -( -self -dst -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -no_expansion -( -self -) -} -} -impl -< -' -a -> -Replacer -for -Cow -< -' -a -[ -u8 -] -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -caps -. -expand -( -self -. -as_ref -( -) -dst -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -no_expansion -( -self -) -} -} -impl -< -' -a -> -Replacer -for -& -' -a -Cow -< -' -a -[ -u8 -] -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -caps -. -expand -( -self -. -as_ref -( -) -dst -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -no_expansion -( -self -) -} -} -impl -< -F -T -> -Replacer -for -F -where -F -: -FnMut -( -& -Captures -< -' -_ -> -) -- -> -T -T -: -AsRef -< -[ -u8 -] -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -dst -. -extend_from_slice -( -( -* -self -) -( -caps -) -. -as_ref -( -) -) -; -} -} -/ -/ -/ -A -by -- -reference -adaptor -for -a -[ -Replacer -] -. -/ -/ -/ -/ -/ -/ -This -permits -reusing -the -same -Replacer -value -in -multiple -calls -to -a -/ -/ -/ -replacement -routine -like -[ -Regex -: -: -replace_all -] -. -/ -/ -/ -/ -/ -/ -This -type -is -created -by -[ -Replacer -: -: -by_ref -] -. -# -[ -derive -( -Debug -) -] -pub -struct -ReplacerRef -< -' -a -R -: -? -Sized -> -( -& -' -a -mut -R -) -; -impl -< -' -a -R -: -Replacer -+ -? -Sized -+ -' -a -> -Replacer -for -ReplacerRef -< -' -a -R -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -self -. -0 -. -replace_append -( -caps -dst -) -} -fn -no_expansion -< -' -r -> -( -& -' -r -mut -self -) -- -> -Option -< -Cow -< -' -r -[ -u8 -] -> -> -{ -self -. -0 -. -no_expansion -( -) -} -} -/ -/ -/ -A -helper -type -for -forcing -literal -string -replacement -. -/ -/ -/ -/ -/ -/ -It -can -be -used -with -routines -like -[ -Regex -: -: -replace -] -and -/ -/ -/ -[ -Regex -: -: -replace_all -] -to -do -a -literal -string -replacement -without -expanding -/ -/ -/ -name -to -their -corresponding -capture -groups -. -This -can -be -both -convenient -/ -/ -/ -( -to -avoid -escaping -for -example -) -and -faster -( -since -capture -groups -/ -/ -/ -don -' -t -need -to -be -found -) -. -/ -/ -/ -/ -/ -/ -' -s -is -the -lifetime -of -the -literal -string -to -use -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -{ -NoExpand -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -last -> -[ -^ -\ -s -] -+ -) -\ -s -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -b -" -Springsteen -Bruce -" -NoExpand -( -b -" -2 -last -" -) -) -; -/ -/ -/ -assert_eq -! -( -result -& -b -" -2 -last -" -[ -. -. -] -) -; -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -NoExpand -< -' -s -> -( -pub -& -' -s -[ -u8 -] -) -; -impl -< -' -s -> -Replacer -for -NoExpand -< -' -s -> -{ -fn -replace_append -( -& -mut -self -_ -: -& -Captures -< -' -_ -> -dst -: -& -mut -Vec -< -u8 -> -) -{ -dst -. -extend_from_slice -( -self -. -0 -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -Some -( -Cow -: -: -Borrowed -( -self -. -0 -) -) -} -} -/ -/ -/ -Quickly -checks -the -given -replacement -string -for -whether -interpolation -/ -/ -/ -should -be -done -on -it -. -It -returns -None -if -a -was -found -anywhere -in -the -/ -/ -/ -given -string -which -suggests -interpolation -needs -to -be -done -. -But -if -there -' -s -/ -/ -/ -no -anywhere -then -interpolation -definitely -does -not -need -to -be -done -. -In -/ -/ -/ -that -case -the -given -string -is -returned -as -a -borrowed -Cow -. -/ -/ -/ -/ -/ -/ -This -is -meant -to -be -used -to -implement -the -Replacer -: -: -no_expandsion -method -/ -/ -/ -in -its -various -trait -impls -. -fn -no_expansion -< -T -: -AsRef -< -[ -u8 -] -> -> -( -replacement -: -& -T -) -- -> -Option -< -Cow -< -' -_ -[ -u8 -] -> -> -{ -let -replacement -= -replacement -. -as_ref -( -) -; -match -crate -: -: -find_byte -: -: -find_byte -( -b -' -' -replacement -) -{ -Some -( -_ -) -= -> -None -None -= -> -Some -( -Cow -: -: -Borrowed -( -replacement -) -) -} -} diff --git a/third_party/rust/regex/src/regex/mod.rs b/third_party/rust/regex/src/regex/mod.rs deleted file mode 100644 index a31dfcb1251ab..0000000000000 --- a/third_party/rust/regex/src/regex/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub -( -crate -) -mod -bytes -; -pub -( -crate -) -mod -string -; diff --git a/third_party/rust/regex/src/regex/string.rs b/third_party/rust/regex/src/regex/string.rs deleted file mode 100644 index 3a6960ca88df3..0000000000000 --- a/third_party/rust/regex/src/regex/string.rs +++ /dev/null @@ -1,27011 +0,0 @@ -use -alloc -: -: -{ -borrow -: -: -Cow -string -: -: -String -sync -: -: -Arc -} -; -use -regex_automata -: -: -{ -meta -util -: -: -captures -Input -PatternID -} -; -use -crate -: -: -{ -error -: -: -Error -RegexBuilder -} -; -/ -/ -/ -A -compiled -regular -expression -for -searching -Unicode -haystacks -. -/ -/ -/ -/ -/ -/ -A -Regex -can -be -used -to -search -haystacks -split -haystacks -into -substrings -/ -/ -/ -or -replace -substrings -in -a -haystack -with -a -different -substring -. -All -/ -/ -/ -searching -is -done -with -an -implicit -( -? -s -: -. -) -* -? -at -the -beginning -and -end -of -/ -/ -/ -an -pattern -. -To -force -an -expression -to -match -the -whole -string -( -or -a -prefix -/ -/ -/ -or -a -suffix -) -you -must -use -an -anchor -like -^ -or -( -or -\ -A -and -\ -z -) -. -/ -/ -/ -/ -/ -/ -While -this -crate -will -handle -Unicode -strings -( -whether -in -the -regular -/ -/ -/ -expression -or -in -the -haystack -) -all -positions -returned -are -* -* -byte -/ -/ -/ -offsets -* -* -. -Every -byte -offset -is -guaranteed -to -be -at -a -Unicode -code -point -/ -/ -/ -boundary -. -That -is -all -offsets -returned -by -the -Regex -API -are -guaranteed -/ -/ -/ -to -be -ranges -that -can -slice -a -& -str -without -panicking -. -If -you -want -to -/ -/ -/ -relax -this -requirement -then -you -must -search -& -[ -u8 -] -haystacks -with -a -/ -/ -/ -[ -bytes -: -: -Regex -] -( -crate -: -: -bytes -: -: -Regex -) -. -/ -/ -/ -/ -/ -/ -The -only -methods -that -allocate -new -strings -are -the -string -replacement -/ -/ -/ -methods -. -All -other -methods -( -searching -and -splitting -) -return -borrowed -/ -/ -/ -references -into -the -haystack -given -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Find -the -offsets -of -a -US -phone -number -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -" -[ -0 -- -9 -] -{ -3 -} -- -[ -0 -- -9 -] -{ -3 -} -- -[ -0 -- -9 -] -{ -4 -} -" -) -. -unwrap -( -) -; -/ -/ -/ -let -m -= -re -. -find -( -" -phone -: -111 -- -222 -- -3333 -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -7 -. -. -19 -m -. -range -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -extracting -capture -groups -/ -/ -/ -/ -/ -/ -A -common -way -to -use -regexes -is -with -capture -groups -. -That -is -instead -of -/ -/ -/ -just -looking -for -matches -of -an -entire -regex -parentheses -are -used -to -create -/ -/ -/ -groups -that -represent -part -of -the -match -. -/ -/ -/ -/ -/ -/ -For -example -consider -a -haystack -with -multiple -lines -and -each -line -has -/ -/ -/ -three -whitespace -delimited -fields -where -the -second -field -is -expected -to -be -/ -/ -/ -a -number -and -the -third -field -a -boolean -. -To -make -this -convenient -we -use -/ -/ -/ -the -[ -Captures -: -: -extract -] -API -to -put -the -strings -that -match -each -group -/ -/ -/ -into -a -fixed -size -array -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -hay -= -" -/ -/ -/ -rabbit -54 -true -/ -/ -/ -groundhog -2 -true -/ -/ -/ -does -not -match -/ -/ -/ -fox -109 -false -/ -/ -/ -" -; -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -\ -s -* -( -\ -S -+ -) -\ -s -+ -( -[ -0 -- -9 -] -+ -) -\ -s -+ -( -true -| -false -) -\ -s -* -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -fields -: -Vec -< -( -& -str -i64 -bool -) -> -= -vec -! -[ -] -; -/ -/ -/ -for -( -_ -[ -f1 -f2 -f3 -] -) -in -re -. -captures_iter -( -hay -) -. -map -( -| -caps -| -caps -. -extract -( -) -) -{ -/ -/ -/ -fields -. -push -( -( -f1 -f2 -. -parse -( -) -? -f3 -. -parse -( -) -? -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -fields -vec -! -[ -/ -/ -/ -( -" -rabbit -" -54 -true -) -/ -/ -/ -( -" -groundhog -" -2 -true -) -/ -/ -/ -( -" -fox -" -109 -false -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -searching -with -the -Pattern -trait -/ -/ -/ -/ -/ -/ -* -* -Note -* -* -: -This -section -requires -that -this -crate -is -compiled -with -the -/ -/ -/ -pattern -Cargo -feature -enabled -which -* -* -requires -nightly -Rust -* -* -. -/ -/ -/ -/ -/ -/ -Since -Regex -implements -Pattern -from -the -standard -library -one -can -/ -/ -/ -use -regexes -with -methods -defined -on -& -str -. -For -example -is_match -/ -/ -/ -find -find_iter -and -split -can -in -some -cases -be -replaced -with -/ -/ -/ -str -: -: -contains -str -: -: -find -str -: -: -match_indices -and -str -: -: -split -. -/ -/ -/ -/ -/ -/ -Here -are -some -examples -: -/ -/ -/ -/ -/ -/ -ignore -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -d -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -a111b222c -" -; -/ -/ -/ -/ -/ -/ -assert -! -( -hay -. -contains -( -& -re -) -) -; -/ -/ -/ -assert_eq -! -( -hay -. -find -( -& -re -) -Some -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -hay -. -match_indices -( -& -re -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -vec -! -[ -/ -/ -/ -( -1 -" -111 -" -) -/ -/ -/ -( -5 -" -222 -" -) -/ -/ -/ -] -) -; -/ -/ -/ -assert_eq -! -( -hay -. -split -( -& -re -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) -vec -! -[ -" -a -" -" -b -" -" -c -" -] -) -; -/ -/ -/ -# -[ -derive -( -Clone -) -] -pub -struct -Regex -{ -pub -( -crate -) -meta -: -meta -: -: -Regex -pub -( -crate -) -pattern -: -Arc -< -str -> -} -impl -core -: -: -fmt -: -: -Display -for -Regex -{ -/ -/ -/ -Shows -the -original -regular -expression -. -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -} -" -self -. -as_str -( -) -) -} -} -impl -core -: -: -fmt -: -: -Debug -for -Regex -{ -/ -/ -/ -Shows -the -original -regular -expression -. -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_tuple -( -" -Regex -" -) -. -field -( -& -self -. -as_str -( -) -) -. -finish -( -) -} -} -impl -core -: -: -str -: -: -FromStr -for -Regex -{ -type -Err -= -Error -; -/ -/ -/ -Attempts -to -parse -a -string -into -a -regular -expression -fn -from_str -( -s -: -& -str -) -- -> -Result -< -Regex -Error -> -{ -Regex -: -: -new -( -s -) -} -} -impl -TryFrom -< -& -str -> -for -Regex -{ -type -Error -= -Error -; -/ -/ -/ -Attempts -to -parse -a -string -into -a -regular -expression -fn -try_from -( -s -: -& -str -) -- -> -Result -< -Regex -Error -> -{ -Regex -: -: -new -( -s -) -} -} -impl -TryFrom -< -String -> -for -Regex -{ -type -Error -= -Error -; -/ -/ -/ -Attempts -to -parse -a -string -into -a -regular -expression -fn -try_from -( -s -: -String -) -- -> -Result -< -Regex -Error -> -{ -Regex -: -: -new -( -& -s -) -} -} -/ -/ -/ -Core -regular -expression -methods -. -impl -Regex -{ -/ -/ -/ -Compiles -a -regular -expression -. -Once -compiled -it -can -be -used -repeatedly -/ -/ -/ -to -search -split -or -replace -substrings -in -a -haystack -. -/ -/ -/ -/ -/ -/ -Note -that -regex -compilation -tends -to -be -a -somewhat -expensive -process -/ -/ -/ -and -unlike -higher -level -environments -compilation -is -not -automatically -/ -/ -/ -cached -for -you -. -One -should -endeavor -to -compile -a -regex -once -and -then -/ -/ -/ -reuse -it -. -For -example -it -' -s -a -bad -idea -to -compile -the -same -regex -/ -/ -/ -repeatedly -in -a -loop -. -/ -/ -/ -/ -/ -/ -# -Errors -/ -/ -/ -/ -/ -/ -If -an -invalid -pattern -is -given -then -an -error -is -returned -. -/ -/ -/ -An -error -is -also -returned -if -the -pattern -is -valid -but -would -/ -/ -/ -produce -a -regex -that -is -bigger -than -the -configured -size -limit -via -/ -/ -/ -[ -RegexBuilder -: -: -size_limit -] -. -( -A -reasonable -size -limit -is -enabled -by -/ -/ -/ -default -. -) -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -/ -/ -An -Invalid -pattern -because -of -an -unclosed -parenthesis -/ -/ -/ -assert -! -( -Regex -: -: -new -( -r -" -foo -( -bar -" -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -An -invalid -pattern -because -the -regex -would -be -too -big -/ -/ -/ -/ -/ -because -Unicode -tends -to -inflate -things -. -/ -/ -/ -assert -! -( -Regex -: -: -new -( -r -" -\ -w -{ -1000 -} -" -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -Disabling -Unicode -can -make -the -regex -much -smaller -/ -/ -/ -/ -/ -potentially -by -up -to -or -more -than -an -order -of -magnitude -. -/ -/ -/ -assert -! -( -Regex -: -: -new -( -r -" -( -? -- -u -: -\ -w -) -{ -1000 -} -" -) -. -is_ok -( -) -) -; -/ -/ -/ -pub -fn -new -( -re -: -& -str -) -- -> -Result -< -Regex -Error -> -{ -RegexBuilder -: -: -new -( -re -) -. -build -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -there -is -a -match -for -the -regex -anywhere -/ -/ -/ -in -the -haystack -given -. -/ -/ -/ -/ -/ -/ -It -is -recommended -to -use -this -method -if -all -you -need -to -do -is -test -/ -/ -/ -whether -a -match -exists -since -the -underlying -matching -engine -may -be -/ -/ -/ -able -to -do -less -work -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Test -if -some -haystack -contains -at -least -one -word -with -exactly -13 -/ -/ -/ -Unicode -word -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -b -\ -w -{ -13 -} -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -I -categorically -deny -having -triskaidekaphobia -. -" -; -/ -/ -/ -assert -! -( -re -. -is_match -( -hay -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -( -& -self -haystack -: -& -str -) -- -> -bool -{ -self -. -is_match_at -( -haystack -0 -) -} -/ -/ -/ -This -routine -searches -for -the -first -match -of -this -regex -in -the -/ -/ -/ -haystack -given -and -if -found -returns -a -[ -Match -] -. -The -Match -/ -/ -/ -provides -access -to -both -the -byte -offsets -of -the -match -and -the -actual -/ -/ -/ -substring -that -matched -. -/ -/ -/ -/ -/ -/ -Note -that -this -should -only -be -used -if -you -want -to -find -the -entire -/ -/ -/ -match -. -If -instead -you -just -want -to -test -the -existence -of -a -match -/ -/ -/ -it -' -s -potentially -faster -to -use -Regex -: -: -is_match -( -hay -) -instead -of -/ -/ -/ -Regex -: -: -find -( -hay -) -. -is_some -( -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Find -the -first -word -with -exactly -13 -Unicode -word -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -b -\ -w -{ -13 -} -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -I -categorically -deny -having -triskaidekaphobia -. -" -; -/ -/ -/ -let -mat -= -re -. -find -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -2 -. -. -15 -mat -. -range -( -) -) -; -/ -/ -/ -assert_eq -! -( -" -categorically -" -mat -. -as_str -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -find -< -' -h -> -( -& -self -haystack -: -& -' -h -str -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -find_at -( -haystack -0 -) -} -/ -/ -/ -Returns -an -iterator -that -yields -successive -non -- -overlapping -matches -in -/ -/ -/ -the -given -haystack -. -The -iterator -yields -values -of -type -[ -Match -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -find_iter -runs -potentially -many -searches -on -the -/ -/ -/ -haystack -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -/ -/ -/ -complexity -the -overall -worst -case -time -complexity -for -iteration -is -/ -/ -/ -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Find -every -word -with -exactly -13 -Unicode -word -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -b -\ -w -{ -13 -} -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Retroactively -relinquishing -remunerations -is -reprehensible -. -" -; -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -re -. -find_iter -( -hay -) -. -map -( -| -m -| -m -. -as_str -( -) -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -/ -/ -/ -" -Retroactively -" -/ -/ -/ -" -relinquishing -" -/ -/ -/ -" -remunerations -" -/ -/ -/ -" -reprehensible -" -/ -/ -/ -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -find_iter -< -' -r -' -h -> -( -& -' -r -self -haystack -: -& -' -h -str -) -- -> -Matches -< -' -r -' -h -> -{ -Matches -{ -haystack -it -: -self -. -meta -. -find_iter -( -haystack -) -} -} -/ -/ -/ -This -routine -searches -for -the -first -match -of -this -regex -in -the -haystack -/ -/ -/ -given -and -if -found -returns -not -only -the -overall -match -but -also -the -/ -/ -/ -matches -of -each -capture -group -in -the -regex -. -If -no -match -is -found -then -/ -/ -/ -None -is -returned -. -/ -/ -/ -/ -/ -/ -Capture -group -0 -always -corresponds -to -an -implicit -unnamed -group -that -/ -/ -/ -includes -the -entire -match -. -If -a -match -is -found -this -group -is -always -/ -/ -/ -present -. -Subsequent -groups -may -be -named -and -are -numbered -starting -/ -/ -/ -at -1 -by -the -order -in -which -the -opening -parenthesis -appears -in -the -/ -/ -/ -pattern -. -For -example -in -the -pattern -( -? -< -a -> -. -( -? -< -b -> -. -) -) -( -? -< -c -> -. -) -a -/ -/ -/ -b -and -c -correspond -to -capture -group -indices -1 -2 -and -3 -/ -/ -/ -respectively -. -/ -/ -/ -/ -/ -/ -You -should -only -use -captures -if -you -need -access -to -the -capture -group -/ -/ -/ -matches -. -Otherwise -[ -Regex -: -: -find -] -is -generally -faster -for -discovering -/ -/ -/ -just -the -overall -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Say -you -have -some -haystack -with -movie -names -and -their -release -years -/ -/ -/ -like -" -' -Citizen -Kane -' -( -1941 -) -" -. -It -' -d -be -nice -if -we -could -search -for -/ -/ -/ -substrings -looking -like -that -while -also -extracting -the -movie -name -and -/ -/ -/ -its -release -year -separately -. -The -example -below -shows -how -to -do -that -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -\ -d -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Not -my -favorite -movie -: -' -Citizen -Kane -' -( -1941 -) -. -" -; -/ -/ -/ -let -caps -= -re -. -captures -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -caps -. -get -( -0 -) -. -unwrap -( -) -. -as_str -( -) -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -caps -. -get -( -1 -) -. -unwrap -( -) -. -as_str -( -) -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -caps -. -get -( -2 -) -. -unwrap -( -) -. -as_str -( -) -" -1941 -" -) -; -/ -/ -/ -/ -/ -You -can -also -access -the -groups -by -index -using -the -Index -notation -. -/ -/ -/ -/ -/ -Note -that -this -will -panic -on -an -invalid -index -. -In -this -case -these -/ -/ -/ -/ -/ -accesses -are -always -correct -because -the -overall -regex -will -only -/ -/ -/ -/ -/ -match -when -these -capture -groups -match -. -/ -/ -/ -assert_eq -! -( -& -caps -[ -0 -] -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -1 -] -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -2 -] -" -1941 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -the -full -match -is -at -capture -group -0 -. -Each -subsequent -/ -/ -/ -capture -group -is -indexed -by -the -order -of -its -opening -( -. -/ -/ -/ -/ -/ -/ -We -can -make -this -example -a -bit -clearer -by -using -* -named -* -capture -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -? -< -title -> -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -? -< -year -> -\ -d -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Not -my -favorite -movie -: -' -Citizen -Kane -' -( -1941 -) -. -" -; -/ -/ -/ -let -caps -= -re -. -captures -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -caps -. -get -( -0 -) -. -unwrap -( -) -. -as_str -( -) -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -caps -. -name -( -" -title -" -) -. -unwrap -( -) -. -as_str -( -) -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -caps -. -name -( -" -year -" -) -. -unwrap -( -) -. -as_str -( -) -" -1941 -" -) -; -/ -/ -/ -/ -/ -You -can -also -access -the -groups -by -name -using -the -Index -notation -. -/ -/ -/ -/ -/ -Note -that -this -will -panic -on -an -invalid -group -name -. -In -this -case -/ -/ -/ -/ -/ -these -accesses -are -always -correct -because -the -overall -regex -will -/ -/ -/ -/ -/ -only -match -when -these -capture -groups -match -. -/ -/ -/ -assert_eq -! -( -& -caps -[ -0 -] -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -title -" -] -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -year -" -] -" -1941 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Here -we -name -the -capture -groups -which -we -can -access -with -the -name -/ -/ -/ -method -or -the -Index -notation -with -a -& -str -. -Note -that -the -named -/ -/ -/ -capture -groups -are -still -accessible -with -get -or -the -Index -notation -/ -/ -/ -with -a -usize -. -/ -/ -/ -/ -/ -/ -The -0 -th -capture -group -is -always -unnamed -so -it -must -always -be -/ -/ -/ -accessed -with -get -( -0 -) -or -[ -0 -] -. -/ -/ -/ -/ -/ -/ -Finally -one -other -way -to -to -get -the -matched -substrings -is -with -the -/ -/ -/ -[ -Captures -: -: -extract -] -API -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -\ -d -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Not -my -favorite -movie -: -' -Citizen -Kane -' -( -1941 -) -. -" -; -/ -/ -/ -let -( -full -[ -title -year -] -) -= -re -. -captures -( -hay -) -. -unwrap -( -) -. -extract -( -) -; -/ -/ -/ -assert_eq -! -( -full -" -' -Citizen -Kane -' -( -1941 -) -" -) -; -/ -/ -/ -assert_eq -! -( -title -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -year -" -1941 -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures -< -' -h -> -( -& -self -haystack -: -& -' -h -str -) -- -> -Option -< -Captures -< -' -h -> -> -{ -self -. -captures_at -( -haystack -0 -) -} -/ -/ -/ -Returns -an -iterator -that -yields -successive -non -- -overlapping -matches -in -/ -/ -/ -the -given -haystack -. -The -iterator -yields -values -of -type -[ -Captures -] -. -/ -/ -/ -/ -/ -/ -This -is -the -same -as -[ -Regex -: -: -find_iter -] -but -instead -of -only -providing -/ -/ -/ -access -to -the -overall -match -each -value -yield -includes -access -to -the -/ -/ -/ -matches -of -all -capture -groups -in -the -regex -. -Reporting -this -extra -match -/ -/ -/ -data -is -potentially -costly -so -callers -should -only -use -captures_iter -/ -/ -/ -over -find_iter -when -they -actually -need -access -to -the -capture -group -/ -/ -/ -matches -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -captures_iter -runs -potentially -many -searches -on -the -/ -/ -/ -haystack -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -/ -/ -/ -complexity -the -overall -worst -case -time -complexity -for -iteration -is -/ -/ -/ -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -We -can -use -this -to -find -all -movie -titles -and -their -release -years -in -/ -/ -/ -some -haystack -where -the -movie -is -formatted -like -" -' -Title -' -( -xxxx -) -" -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -[ -0 -- -9 -] -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -' -Citizen -Kane -' -( -1941 -) -' -The -Wizard -of -Oz -' -( -1939 -) -' -M -' -( -1931 -) -. -" -; -/ -/ -/ -let -mut -movies -= -vec -! -[ -] -; -/ -/ -/ -for -( -_ -[ -title -year -] -) -in -re -. -captures_iter -( -hay -) -. -map -( -| -c -| -c -. -extract -( -) -) -{ -/ -/ -/ -movies -. -push -( -( -title -year -. -parse -: -: -< -i64 -> -( -) -? -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -movies -vec -! -[ -/ -/ -/ -( -" -Citizen -Kane -" -1941 -) -/ -/ -/ -( -" -The -Wizard -of -Oz -" -1939 -) -/ -/ -/ -( -" -M -" -1931 -) -/ -/ -/ -] -) -; -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -Or -with -named -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -' -( -? -< -title -> -[ -^ -' -] -+ -) -' -\ -s -+ -\ -( -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -\ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -' -Citizen -Kane -' -( -1941 -) -' -The -Wizard -of -Oz -' -( -1939 -) -' -M -' -( -1931 -) -. -" -; -/ -/ -/ -let -mut -it -= -re -. -captures_iter -( -hay -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -it -. -next -( -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -title -" -] -" -Citizen -Kane -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -year -" -] -" -1941 -" -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -it -. -next -( -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -title -" -] -" -The -Wizard -of -Oz -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -year -" -] -" -1939 -" -) -; -/ -/ -/ -/ -/ -/ -let -caps -= -it -. -next -( -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -title -" -] -" -M -" -) -; -/ -/ -/ -assert_eq -! -( -& -caps -[ -" -year -" -] -" -1931 -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_iter -< -' -r -' -h -> -( -& -' -r -self -haystack -: -& -' -h -str -) -- -> -CaptureMatches -< -' -r -' -h -> -{ -CaptureMatches -{ -haystack -it -: -self -. -meta -. -captures_iter -( -haystack -) -} -} -/ -/ -/ -Returns -an -iterator -of -substrings -of -the -haystack -given -delimited -by -a -/ -/ -/ -match -of -the -regex -. -Namely -each -element -of -the -iterator -corresponds -to -/ -/ -/ -a -part -of -the -haystack -that -* -isn -' -t -* -matched -by -the -regular -expression -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Since -iterators -over -all -matches -requires -running -potentially -many -/ -/ -/ -searches -on -the -haystack -and -since -each -search -has -worst -case -/ -/ -/ -O -( -m -* -n -) -time -complexity -the -overall -worst -case -time -complexity -for -/ -/ -/ -this -routine -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -To -split -a -string -delimited -by -arbitrary -amounts -of -spaces -or -tabs -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -\ -t -] -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -a -b -\ -t -c -\ -td -e -" -; -/ -/ -/ -let -fields -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -fields -vec -! -[ -" -a -" -" -b -" -" -c -" -" -d -" -" -e -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -more -cases -/ -/ -/ -/ -/ -/ -Basic -usage -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Mary -had -a -little -lamb -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -Mary -" -" -had -" -" -a -" -" -little -" -" -lamb -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -lionXXtigerXleopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -lion -" -" -" -" -tiger -" -" -leopard -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -: -: -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -lion -: -: -tiger -: -: -leopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -lion -" -" -tiger -" -" -leopard -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -If -a -haystack -contains -multiple -contiguous -matches -you -will -end -up -/ -/ -/ -with -empty -spans -yielded -by -the -iterator -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -XXXXaXXbXc -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -" -" -" -" -" -" -a -" -" -" -" -b -" -" -c -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -/ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -( -/ -/ -/ -) -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -( -" -" -" -" -" -" -) -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Separators -at -the -start -or -end -of -a -haystack -are -neighbored -by -empty -/ -/ -/ -substring -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -0 -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -010 -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -1 -" -" -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -When -the -empty -string -is -used -as -a -regex -it -splits -at -every -valid -/ -/ -/ -UTF -- -8 -boundary -by -default -( -which -includes -the -beginning -and -end -of -the -/ -/ -/ -haystack -) -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -rust -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -r -" -" -u -" -" -s -" -" -t -" -" -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Splitting -by -an -empty -string -is -UTF -- -8 -aware -by -default -! -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -" -" -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Contiguous -separators -( -commonly -shows -up -with -whitespace -) -can -lead -to -/ -/ -/ -possibly -surprising -behavior -. -For -example -this -code -is -correct -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -a -b -c -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -" -" -" -" -" -" -a -" -" -" -" -b -" -" -c -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -It -does -* -not -* -give -you -[ -" -a -" -" -b -" -" -c -" -] -. -For -that -behavior -you -' -d -want -/ -/ -/ -to -match -contiguous -space -characters -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -a -b -c -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -split -( -hay -) -. -collect -( -) -; -/ -/ -/ -/ -/ -N -. -B -. -This -does -still -include -a -leading -empty -span -because -' -+ -' -/ -/ -/ -/ -/ -matches -at -the -beginning -of -the -haystack -. -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -" -a -" -" -b -" -" -c -" -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -split -< -' -r -' -h -> -( -& -' -r -self -haystack -: -& -' -h -str -) -- -> -Split -< -' -r -' -h -> -{ -Split -{ -haystack -it -: -self -. -meta -. -split -( -haystack -) -} -} -/ -/ -/ -Returns -an -iterator -of -at -most -limit -substrings -of -the -haystack -/ -/ -/ -given -delimited -by -a -match -of -the -regex -. -( -A -limit -of -0 -will -return -/ -/ -/ -no -substrings -. -) -Namely -each -element -of -the -iterator -corresponds -to -a -/ -/ -/ -part -of -the -haystack -that -* -isn -' -t -* -matched -by -the -regular -expression -. -/ -/ -/ -The -remainder -of -the -haystack -that -is -not -split -will -be -the -last -/ -/ -/ -element -in -the -iterator -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Since -iterators -over -all -matches -requires -running -potentially -many -/ -/ -/ -searches -on -the -haystack -and -since -each -search -has -worst -case -/ -/ -/ -O -( -m -* -n -) -time -complexity -the -overall -worst -case -time -complexity -for -/ -/ -/ -this -routine -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -Although -note -that -the -worst -case -time -here -has -an -upper -bound -given -/ -/ -/ -by -the -limit -parameter -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Get -the -first -two -words -in -some -haystack -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -W -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Hey -! -How -are -you -? -" -; -/ -/ -/ -let -fields -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -3 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -fields -vec -! -[ -" -Hey -" -" -How -" -" -are -you -? -" -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Examples -: -more -cases -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Mary -had -a -little -lamb -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -3 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -Mary -" -" -had -" -" -a -little -lamb -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -3 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -lionXXtigerXleopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -3 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -lion -" -" -" -" -tigerXleopard -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -: -: -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -lion -: -: -tiger -: -: -leopard -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -2 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -lion -" -" -tiger -: -: -leopard -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -abcXdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -1 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -abcXdef -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -abcdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -2 -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -got -vec -! -[ -" -abcdef -" -] -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -X -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -abcXdef -" -; -/ -/ -/ -let -got -: -Vec -< -& -str -> -= -re -. -splitn -( -hay -0 -) -. -collect -( -) -; -/ -/ -/ -assert -! -( -got -. -is_empty -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -splitn -< -' -r -' -h -> -( -& -' -r -self -haystack -: -& -' -h -str -limit -: -usize -) -- -> -SplitN -< -' -r -' -h -> -{ -SplitN -{ -haystack -it -: -self -. -meta -. -splitn -( -haystack -limit -) -} -} -/ -/ -/ -Replaces -the -leftmost -- -first -match -in -the -given -haystack -with -the -/ -/ -/ -replacement -provided -. -The -replacement -can -be -a -regular -string -( -where -/ -/ -/ -N -and -name -are -expanded -to -match -capture -groups -) -or -a -function -/ -/ -/ -that -takes -a -[ -Captures -] -and -returns -the -replaced -string -. -/ -/ -/ -/ -/ -/ -If -no -match -is -found -then -the -haystack -is -returned -unchanged -. -In -that -/ -/ -/ -case -this -implementation -will -likely -return -a -Cow -: -: -Borrowed -value -/ -/ -/ -such -that -no -allocation -is -performed -. -/ -/ -/ -/ -/ -/ -# -Replacement -string -syntax -/ -/ -/ -/ -/ -/ -All -instances -of -ref -in -the -replacement -string -are -replaced -with -/ -/ -/ -the -substring -corresponding -to -the -capture -group -identified -by -ref -. -/ -/ -/ -/ -/ -/ -ref -may -be -an -integer -corresponding -to -the -index -of -the -capture -group -/ -/ -/ -( -counted -by -order -of -opening -parenthesis -where -0 -is -the -entire -match -) -/ -/ -/ -or -it -can -be -a -name -( -consisting -of -letters -digits -or -underscores -) -/ -/ -/ -corresponding -to -a -named -capture -group -. -/ -/ -/ -/ -/ -/ -If -ref -isn -' -t -a -valid -capture -group -( -whether -the -name -doesn -' -t -exist -or -/ -/ -/ -isn -' -t -a -valid -index -) -then -it -is -replaced -with -the -empty -string -. -/ -/ -/ -/ -/ -/ -The -longest -possible -name -is -used -. -For -example -1a -looks -up -the -/ -/ -/ -capture -group -named -1a -and -not -the -capture -group -at -index -1 -. -To -/ -/ -/ -exert -more -precise -control -over -the -name -use -braces -e -. -g -. -{ -1 -} -a -. -/ -/ -/ -/ -/ -/ -To -write -a -literal -use -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Note -that -this -function -is -polymorphic -with -respect -to -the -replacement -. -/ -/ -/ -In -typical -usage -this -can -just -be -a -normal -string -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -^ -01 -] -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -re -. -replace -( -" -1078910 -" -" -" -) -" -1010 -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -But -anything -satisfying -the -[ -Replacer -] -trait -will -work -. -For -example -/ -/ -/ -a -closure -of -type -| -& -Captures -| -- -> -String -provides -direct -access -to -the -/ -/ -/ -captures -corresponding -to -a -match -. -This -allows -one -to -access -capturing -/ -/ -/ -group -matches -easily -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -{ -Captures -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -[ -^ -\ -s -] -+ -) -\ -s -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -" -Springsteen -Bruce -" -| -caps -: -& -Captures -| -{ -/ -/ -/ -format -! -( -" -{ -} -{ -} -" -& -caps -[ -2 -] -& -caps -[ -1 -] -) -/ -/ -/ -} -) -; -/ -/ -/ -assert_eq -! -( -result -" -Bruce -Springsteen -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -But -this -is -a -bit -cumbersome -to -use -all -the -time -. -Instead -a -simple -/ -/ -/ -syntax -is -supported -( -as -described -above -) -that -expands -name -into -the -/ -/ -/ -corresponding -capture -group -. -Here -' -s -the -last -example -but -using -this -/ -/ -/ -expansion -technique -with -named -capture -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -last -> -[ -^ -\ -s -] -+ -) -\ -s -+ -( -? -< -first -> -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -" -Springsteen -Bruce -" -" -first -last -" -) -; -/ -/ -/ -assert_eq -! -( -result -" -Bruce -Springsteen -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -using -2 -instead -of -first -or -1 -instead -of -last -/ -/ -/ -would -produce -the -same -result -. -To -write -a -literal -use -. -/ -/ -/ -/ -/ -/ -Sometimes -the -replacement -string -requires -use -of -curly -braces -to -/ -/ -/ -delineate -a -capture -group -replacement -when -it -is -adjacent -to -some -other -/ -/ -/ -literal -text -. -For -example -if -we -wanted -to -join -two -words -together -with -/ -/ -/ -an -underscore -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -+ -) -\ -s -+ -( -? -< -second -> -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -" -deep -fried -" -" -{ -first -} -_ -second -" -) -; -/ -/ -/ -assert_eq -! -( -result -" -deep_fried -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Without -the -curly -braces -the -capture -group -name -first_ -would -be -/ -/ -/ -used -and -since -it -doesn -' -t -exist -it -would -be -replaced -with -the -empty -/ -/ -/ -string -. -/ -/ -/ -/ -/ -/ -Finally -sometimes -you -just -want -to -replace -a -literal -string -with -no -/ -/ -/ -regard -for -capturing -group -expansion -. -This -can -be -done -by -wrapping -a -/ -/ -/ -string -with -[ -NoExpand -] -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -{ -NoExpand -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -last -> -[ -^ -\ -s -] -+ -) -\ -s -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -" -Springsteen -Bruce -" -NoExpand -( -" -2 -last -" -) -) -; -/ -/ -/ -assert_eq -! -( -result -" -2 -last -" -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Using -NoExpand -may -also -be -faster -since -the -replacement -string -won -' -t -/ -/ -/ -need -to -be -parsed -for -the -syntax -. -# -[ -inline -] -pub -fn -replace -< -' -h -R -: -Replacer -> -( -& -self -haystack -: -& -' -h -str -rep -: -R -) -- -> -Cow -< -' -h -str -> -{ -self -. -replacen -( -haystack -1 -rep -) -} -/ -/ -/ -Replaces -all -non -- -overlapping -matches -in -the -haystack -with -the -/ -/ -/ -replacement -provided -. -This -is -the -same -as -calling -replacen -with -/ -/ -/ -limit -set -to -0 -. -/ -/ -/ -/ -/ -/ -The -documentation -for -[ -Regex -: -: -replace -] -goes -into -more -detail -about -/ -/ -/ -what -kinds -of -replacement -strings -are -supported -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Since -iterators -over -all -matches -requires -running -potentially -many -/ -/ -/ -searches -on -the -haystack -and -since -each -search -has -worst -case -/ -/ -/ -O -( -m -* -n -) -time -complexity -the -overall -worst -case -time -complexity -for -/ -/ -/ -this -routine -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -# -Fallibility -/ -/ -/ -/ -/ -/ -If -you -need -to -write -a -replacement -routine -where -any -individual -/ -/ -/ -replacement -might -" -fail -" -doing -so -with -this -API -isn -' -t -really -feasible -/ -/ -/ -because -there -' -s -no -way -to -stop -the -search -process -if -a -replacement -/ -/ -/ -fails -. -Instead -if -you -need -this -functionality -you -should -consider -/ -/ -/ -implementing -your -own -replacement -routine -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -{ -Captures -Regex -} -; -/ -/ -/ -/ -/ -/ -fn -replace_all -< -E -> -( -/ -/ -/ -re -: -& -Regex -/ -/ -/ -haystack -: -& -str -/ -/ -/ -replacement -: -impl -Fn -( -& -Captures -) -- -> -Result -< -String -E -> -/ -/ -/ -) -- -> -Result -< -String -E -> -{ -/ -/ -/ -let -mut -new -= -String -: -: -with_capacity -( -haystack -. -len -( -) -) -; -/ -/ -/ -let -mut -last_match -= -0 -; -/ -/ -/ -for -caps -in -re -. -captures_iter -( -haystack -) -{ -/ -/ -/ -let -m -= -caps -. -get -( -0 -) -. -unwrap -( -) -; -/ -/ -/ -new -. -push_str -( -& -haystack -[ -last_match -. -. -m -. -start -( -) -] -) -; -/ -/ -/ -new -. -push_str -( -& -replacement -( -& -caps -) -? -) -; -/ -/ -/ -last_match -= -m -. -end -( -) -; -/ -/ -/ -} -/ -/ -/ -new -. -push_str -( -& -haystack -[ -last_match -. -. -] -) -; -/ -/ -/ -Ok -( -new -) -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -/ -/ -Let -' -s -replace -each -word -with -the -number -of -bytes -in -that -word -. -/ -/ -/ -/ -/ -But -if -we -see -a -word -that -is -" -too -long -" -we -' -ll -give -up -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -w -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -replacement -= -| -caps -: -& -Captures -| -- -> -Result -< -String -& -' -static -str -> -{ -/ -/ -/ -if -caps -[ -0 -] -. -len -( -) -> -= -5 -{ -/ -/ -/ -return -Err -( -" -word -too -long -" -) -; -/ -/ -/ -} -/ -/ -/ -Ok -( -caps -[ -0 -] -. -len -( -) -. -to_string -( -) -) -/ -/ -/ -} -; -/ -/ -/ -assert_eq -! -( -/ -/ -/ -Ok -( -" -2 -3 -3 -3 -? -" -. -to_string -( -) -) -/ -/ -/ -replace_all -( -& -re -" -hi -how -are -you -? -" -& -replacement -) -/ -/ -/ -) -; -/ -/ -/ -assert -! -( -replace_all -( -& -re -" -hi -there -" -& -replacement -) -. -is_err -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -flip -the -order -of -whitespace -( -excluding -line -/ -/ -/ -terminators -) -delimited -fields -and -normalizes -the -whitespace -that -/ -/ -/ -delimits -the -fields -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -( -\ -S -+ -) -[ -\ -s -- -- -\ -r -\ -n -] -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -/ -/ -/ -Greetings -1973 -/ -/ -/ -Wild -\ -t1973 -/ -/ -/ -BornToRun -\ -t -\ -t -\ -t -\ -t1975 -/ -/ -/ -Darkness -1978 -/ -/ -/ -TheRiver -1980 -/ -/ -/ -" -; -/ -/ -/ -let -new -= -re -. -replace_all -( -hay -" -2 -1 -" -) -; -/ -/ -/ -assert_eq -! -( -new -" -/ -/ -/ -1973 -Greetings -/ -/ -/ -1973 -Wild -/ -/ -/ -1975 -BornToRun -/ -/ -/ -1978 -Darkness -/ -/ -/ -1980 -TheRiver -/ -/ -/ -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -replace_all -< -' -h -R -: -Replacer -> -( -& -self -haystack -: -& -' -h -str -rep -: -R -) -- -> -Cow -< -' -h -str -> -{ -self -. -replacen -( -haystack -0 -rep -) -} -/ -/ -/ -Replaces -at -most -limit -non -- -overlapping -matches -in -the -haystack -with -/ -/ -/ -the -replacement -provided -. -If -limit -is -0 -then -all -non -- -overlapping -/ -/ -/ -matches -are -replaced -. -That -is -Regex -: -: -replace_all -( -hay -rep -) -is -/ -/ -/ -equivalent -to -Regex -: -: -replacen -( -hay -0 -rep -) -. -/ -/ -/ -/ -/ -/ -The -documentation -for -[ -Regex -: -: -replace -] -goes -into -more -detail -about -/ -/ -/ -what -kinds -of -replacement -strings -are -supported -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Since -iterators -over -all -matches -requires -running -potentially -many -/ -/ -/ -searches -on -the -haystack -and -since -each -search -has -worst -case -/ -/ -/ -O -( -m -* -n -) -time -complexity -the -overall -worst -case -time -complexity -for -/ -/ -/ -this -routine -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -Although -note -that -the -worst -case -time -here -has -an -upper -bound -given -/ -/ -/ -by -the -limit -parameter -. -/ -/ -/ -/ -/ -/ -# -Fallibility -/ -/ -/ -/ -/ -/ -See -the -corresponding -section -in -the -docs -for -[ -Regex -: -: -replace_all -] -/ -/ -/ -for -tips -on -how -to -deal -with -a -replacement -routine -that -can -fail -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -flip -the -order -of -whitespace -( -excluding -line -/ -/ -/ -terminators -) -delimited -fields -and -normalizes -the -whitespace -that -/ -/ -/ -delimits -the -fields -. -But -we -only -do -it -for -the -first -two -matches -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -m -) -^ -( -\ -S -+ -) -[ -\ -s -- -- -\ -r -\ -n -] -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -/ -/ -/ -Greetings -1973 -/ -/ -/ -Wild -\ -t1973 -/ -/ -/ -BornToRun -\ -t -\ -t -\ -t -\ -t1975 -/ -/ -/ -Darkness -1978 -/ -/ -/ -TheRiver -1980 -/ -/ -/ -" -; -/ -/ -/ -let -new -= -re -. -replacen -( -hay -2 -" -2 -1 -" -) -; -/ -/ -/ -assert_eq -! -( -new -" -/ -/ -/ -1973 -Greetings -/ -/ -/ -1973 -Wild -/ -/ -/ -BornToRun -\ -t -\ -t -\ -t -\ -t1975 -/ -/ -/ -Darkness -1978 -/ -/ -/ -TheRiver -1980 -/ -/ -/ -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -replacen -< -' -h -R -: -Replacer -> -( -& -self -haystack -: -& -' -h -str -limit -: -usize -mut -rep -: -R -) -- -> -Cow -< -' -h -str -> -{ -/ -/ -If -we -know -that -the -replacement -doesn -' -t -have -any -capture -expansions -/ -/ -then -we -can -use -the -fast -path -. -The -fast -path -can -make -a -tremendous -/ -/ -difference -: -/ -/ -/ -/ -1 -) -We -use -find_iter -instead -of -captures_iter -. -Not -asking -for -/ -/ -captures -generally -makes -the -regex -engines -faster -. -/ -/ -2 -) -We -don -' -t -need -to -look -up -all -of -the -capture -groups -and -do -/ -/ -replacements -inside -the -replacement -string -. -We -just -push -it -/ -/ -at -each -match -and -be -done -with -it -. -if -let -Some -( -rep -) -= -rep -. -no_expansion -( -) -{ -let -mut -it -= -self -. -find_iter -( -haystack -) -. -enumerate -( -) -. -peekable -( -) -; -if -it -. -peek -( -) -. -is_none -( -) -{ -return -Cow -: -: -Borrowed -( -haystack -) -; -} -let -mut -new -= -String -: -: -with_capacity -( -haystack -. -len -( -) -) -; -let -mut -last_match -= -0 -; -for -( -i -m -) -in -it -{ -new -. -push_str -( -& -haystack -[ -last_match -. -. -m -. -start -( -) -] -) -; -new -. -push_str -( -& -rep -) -; -last_match -= -m -. -end -( -) -; -if -limit -> -0 -& -& -i -> -= -limit -- -1 -{ -break -; -} -} -new -. -push_str -( -& -haystack -[ -last_match -. -. -] -) -; -return -Cow -: -: -Owned -( -new -) -; -} -/ -/ -The -slower -path -which -we -use -if -the -replacement -may -need -access -to -/ -/ -capture -groups -. -let -mut -it -= -self -. -captures_iter -( -haystack -) -. -enumerate -( -) -. -peekable -( -) -; -if -it -. -peek -( -) -. -is_none -( -) -{ -return -Cow -: -: -Borrowed -( -haystack -) -; -} -let -mut -new -= -String -: -: -with_capacity -( -haystack -. -len -( -) -) -; -let -mut -last_match -= -0 -; -for -( -i -cap -) -in -it -{ -/ -/ -unwrap -on -0 -is -OK -because -captures -only -reports -matches -let -m -= -cap -. -get -( -0 -) -. -unwrap -( -) -; -new -. -push_str -( -& -haystack -[ -last_match -. -. -m -. -start -( -) -] -) -; -rep -. -replace_append -( -& -cap -& -mut -new -) -; -last_match -= -m -. -end -( -) -; -if -limit -> -0 -& -& -i -> -= -limit -- -1 -{ -break -; -} -} -new -. -push_str -( -& -haystack -[ -last_match -. -. -] -) -; -Cow -: -: -Owned -( -new -) -} -} -/ -/ -/ -A -group -of -advanced -or -" -lower -level -" -search -methods -. -Some -methods -permit -/ -/ -/ -starting -the -search -at -a -position -greater -than -0 -in -the -haystack -. -Other -/ -/ -/ -methods -permit -reusing -allocations -for -example -when -extracting -the -/ -/ -/ -matches -for -capture -groups -. -impl -Regex -{ -/ -/ -/ -Returns -the -end -byte -offset -of -the -first -match -in -the -haystack -given -. -/ -/ -/ -/ -/ -/ -This -method -may -have -the -same -performance -characteristics -as -/ -/ -/ -is_match -. -Behaviorlly -it -doesn -' -t -just -report -whether -it -match -/ -/ -/ -occurs -but -also -the -end -offset -for -a -match -. -In -particular -the -offset -/ -/ -/ -returned -* -may -be -shorter -* -than -the -proper -end -of -the -leftmost -- -first -/ -/ -/ -match -that -you -would -find -via -[ -Regex -: -: -find -] -. -/ -/ -/ -/ -/ -/ -Note -that -it -is -not -guaranteed -that -this -routine -finds -the -shortest -or -/ -/ -/ -" -earliest -" -possible -match -. -Instead -the -main -idea -of -this -API -is -that -/ -/ -/ -it -returns -the -offset -at -the -point -at -which -the -internal -regex -engine -/ -/ -/ -has -determined -that -a -match -has -occurred -. -This -may -vary -depending -on -/ -/ -/ -which -internal -regex -engine -is -used -and -thus -the -offset -itself -may -/ -/ -/ -change -based -on -internal -heuristics -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Typically -a -+ -would -match -the -entire -first -sequence -of -a -in -some -/ -/ -/ -haystack -but -shortest_match -* -may -* -give -up -as -soon -as -it -sees -the -/ -/ -/ -first -a -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -a -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -offset -= -re -. -shortest_match -( -" -aaaaa -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -offset -1 -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -shortest_match -( -& -self -haystack -: -& -str -) -- -> -Option -< -usize -> -{ -self -. -shortest_match_at -( -haystack -0 -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -shortest_match -] -but -starts -the -search -at -/ -/ -/ -the -given -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -match -/ -/ -/ -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -If -a -match -is -found -the -offset -returned -is -relative -to -the -beginning -/ -/ -/ -of -the -haystack -not -the -beginning -of -the -search -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -eschew -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert_eq -! -( -re -. -shortest_match -( -& -hay -[ -2 -. -. -] -) -Some -( -4 -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert_eq -! -( -re -. -shortest_match_at -( -hay -2 -) -None -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -shortest_match_at -( -& -self -haystack -: -& -str -start -: -usize -) -- -> -Option -< -usize -> -{ -let -input -= -Input -: -: -new -( -haystack -) -. -earliest -( -true -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -self -. -meta -. -search_half -( -& -input -) -. -map -( -| -hm -| -hm -. -offset -( -) -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -is_match -] -but -starts -the -search -at -the -/ -/ -/ -given -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -eschew -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert -! -( -re -. -is_match -( -& -hay -[ -2 -. -. -] -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert -! -( -! -re -. -is_match_at -( -hay -2 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_match_at -( -& -self -haystack -: -& -str -start -: -usize -) -- -> -bool -{ -let -input -= -Input -: -: -new -( -haystack -) -. -earliest -( -true -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -self -. -meta -. -search_half -( -& -input -) -. -is_some -( -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -find -] -but -starts -the -search -at -the -given -/ -/ -/ -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -eschew -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert_eq -! -( -re -. -find -( -& -hay -[ -2 -. -. -] -) -. -map -( -| -m -| -m -. -range -( -) -) -Some -( -0 -. -. -4 -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert_eq -! -( -re -. -find_at -( -hay -2 -) -None -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -find_at -< -' -h -> -( -& -self -haystack -: -& -' -h -str -start -: -usize -) -- -> -Option -< -Match -< -' -h -> -> -{ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -self -. -meta -. -search -( -& -input -) -. -map -( -| -m -| -Match -: -: -new -( -haystack -m -. -start -( -) -m -. -end -( -) -) -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -captures -] -but -starts -the -search -at -the -/ -/ -/ -given -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -eschew -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert_eq -! -( -& -re -. -captures -( -& -hay -[ -2 -. -. -] -) -. -unwrap -( -) -[ -0 -] -" -chew -" -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert -! -( -re -. -captures_at -( -hay -2 -) -. -is_none -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_at -< -' -h -> -( -& -self -haystack -: -& -' -h -str -start -: -usize -) -- -> -Option -< -Captures -< -' -h -> -> -{ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -let -mut -caps -= -self -. -meta -. -create_captures -( -) -; -self -. -meta -. -search_captures -( -& -input -& -mut -caps -) -; -if -caps -. -is_match -( -) -{ -let -static_captures_len -= -self -. -static_captures_len -( -) -; -Some -( -Captures -{ -haystack -caps -static_captures_len -} -) -} -else -{ -None -} -} -/ -/ -/ -This -is -like -[ -Regex -: -: -captures -] -but -writes -the -byte -offsets -of -each -/ -/ -/ -capture -group -match -into -the -locations -given -. -/ -/ -/ -/ -/ -/ -A -[ -CaptureLocations -] -stores -the -same -byte -offsets -as -a -[ -Captures -] -/ -/ -/ -but -does -* -not -* -store -a -reference -to -the -haystack -. -This -makes -its -API -/ -/ -/ -a -bit -lower -level -and -less -convenient -. -But -in -exchange -callers -/ -/ -/ -may -allocate -their -own -CaptureLocations -and -reuse -it -for -multiple -/ -/ -/ -searches -. -This -may -be -helpful -if -allocating -a -Captures -shows -up -in -a -/ -/ -/ -profile -as -too -costly -. -/ -/ -/ -/ -/ -/ -To -create -a -CaptureLocations -value -use -the -/ -/ -/ -[ -Regex -: -: -capture_locations -] -method -. -/ -/ -/ -/ -/ -/ -This -also -returns -the -overall -match -if -one -was -found -. -When -a -match -is -/ -/ -/ -found -its -offsets -are -also -always -stored -in -locs -at -index -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -routine -may -panic -if -the -given -CaptureLocations -was -not -created -/ -/ -/ -by -this -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -^ -( -[ -a -- -z -] -+ -) -= -( -\ -S -* -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert -! -( -re -. -captures_read -( -& -mut -locs -" -id -= -foo123 -" -) -. -is_some -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -9 -) -) -locs -. -get -( -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -2 -) -) -locs -. -get -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -3 -9 -) -) -locs -. -get -( -2 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_read -< -' -h -> -( -& -self -locs -: -& -mut -CaptureLocations -haystack -: -& -' -h -str -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -captures_read_at -( -locs -haystack -0 -) -} -/ -/ -/ -Returns -the -same -as -[ -Regex -: -: -captures_read -] -but -starts -the -search -at -/ -/ -/ -the -given -offset -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -This -routine -may -also -panic -if -the -given -CaptureLocations -was -not -/ -/ -/ -created -by -this -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -by -demonstrating -how -it -/ -/ -/ -can -be -used -to -permit -look -- -around -assertions -in -a -regex -to -take -the -/ -/ -/ -surrounding -context -into -account -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -bchew -\ -b -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -eschew -" -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert -! -( -re -. -captures_read -( -& -mut -locs -& -hay -[ -2 -. -. -] -) -. -is_some -( -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert -! -( -re -. -captures_read_at -( -& -mut -locs -hay -2 -) -. -is_none -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_read_at -< -' -h -> -( -& -self -locs -: -& -mut -CaptureLocations -haystack -: -& -' -h -str -start -: -usize -) -- -> -Option -< -Match -< -' -h -> -> -{ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -self -. -meta -. -search_captures -( -& -input -& -mut -locs -. -0 -) -; -locs -. -0 -. -get_match -( -) -. -map -( -| -m -| -Match -: -: -new -( -haystack -m -. -start -( -) -m -. -end -( -) -) -) -} -/ -/ -/ -An -undocumented -alias -for -captures_read_at -. -/ -/ -/ -/ -/ -/ -The -regex -- -capi -crate -previously -used -this -routine -so -to -avoid -/ -/ -/ -breaking -that -crate -we -continue -to -provide -the -name -as -an -undocumented -/ -/ -/ -alias -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -read_captures_at -< -' -h -> -( -& -self -locs -: -& -mut -CaptureLocations -haystack -: -& -' -h -str -start -: -usize -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -captures_read_at -( -locs -haystack -start -) -} -} -/ -/ -/ -Auxiliary -methods -. -impl -Regex -{ -/ -/ -/ -Returns -the -original -string -of -this -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -foo -\ -w -+ -bar -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -re -. -as_str -( -) -r -" -foo -\ -w -+ -bar -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -as_str -( -& -self -) -- -> -& -str -{ -& -self -. -pattern -} -/ -/ -/ -Returns -an -iterator -over -the -capture -names -in -this -regex -. -/ -/ -/ -/ -/ -/ -The -iterator -returned -yields -elements -of -type -Option -< -& -str -> -. -That -is -/ -/ -/ -the -iterator -yields -values -for -all -capture -groups -even -ones -that -are -/ -/ -/ -unnamed -. -The -order -of -the -groups -corresponds -to -the -order -of -the -group -' -s -/ -/ -/ -corresponding -opening -parenthesis -. -/ -/ -/ -/ -/ -/ -The -first -element -of -the -iterator -always -yields -the -group -corresponding -/ -/ -/ -to -the -overall -match -and -this -group -is -always -unnamed -. -Therefore -the -/ -/ -/ -iterator -always -yields -at -least -one -group -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -basic -usage -with -a -mix -of -named -and -unnamed -capture -groups -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -a -> -. -( -? -< -b -> -. -) -) -( -. -) -( -? -: -. -) -( -? -< -c -> -. -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -names -= -re -. -capture_names -( -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -None -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -Some -( -" -a -" -) -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -Some -( -" -b -" -) -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -None -) -) -; -/ -/ -/ -/ -/ -the -' -( -? -: -. -) -' -group -is -non -- -capturing -and -so -doesn -' -t -appear -here -! -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -Some -( -" -c -" -) -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -None -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -The -iterator -always -yields -at -least -one -element -even -for -regexes -with -/ -/ -/ -no -capture -groups -and -even -for -regexes -that -can -never -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -names -= -re -. -capture_names -( -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -None -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -None -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -& -& -b -] -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -names -= -re -. -capture_names -( -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -Some -( -None -) -) -; -/ -/ -/ -assert_eq -! -( -names -. -next -( -) -None -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -capture_names -( -& -self -) -- -> -CaptureNames -< -' -_ -> -{ -CaptureNames -( -self -. -meta -. -group_info -( -) -. -pattern_names -( -PatternID -: -: -ZERO -) -) -} -/ -/ -/ -Returns -the -number -of -captures -groups -in -this -regex -. -/ -/ -/ -/ -/ -/ -This -includes -all -named -and -unnamed -groups -including -the -implicit -/ -/ -/ -unnamed -group -that -is -always -present -and -corresponds -to -the -entire -/ -/ -/ -match -. -/ -/ -/ -/ -/ -/ -Since -the -implicit -unnamed -group -is -always -included -in -this -length -the -/ -/ -/ -length -returned -is -guaranteed -to -be -greater -than -zero -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -foo -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -1 -re -. -captures_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -foo -) -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -2 -re -. -captures_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -a -> -. -( -? -< -b -> -. -) -) -( -. -) -( -? -: -. -) -( -? -< -c -> -. -) -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -5 -re -. -captures_len -( -) -) -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -& -& -b -] -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -1 -re -. -captures_len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -captures_len -( -& -self -) -- -> -usize -{ -self -. -meta -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -} -/ -/ -/ -Returns -the -total -number -of -capturing -groups -that -appear -in -every -/ -/ -/ -possible -match -. -/ -/ -/ -/ -/ -/ -If -the -number -of -capture -groups -can -vary -depending -on -the -match -then -/ -/ -/ -this -returns -None -. -That -is -a -value -is -only -returned -when -the -number -/ -/ -/ -of -matching -groups -is -invariant -or -" -static -. -" -/ -/ -/ -/ -/ -/ -Note -that -like -[ -Regex -: -: -captures_len -] -this -* -* -does -* -* -include -the -/ -/ -/ -implicit -capturing -group -corresponding -to -the -entire -match -. -Therefore -/ -/ -/ -when -a -non -- -None -value -is -returned -it -is -guaranteed -to -be -at -least -1 -. -/ -/ -/ -Stated -differently -a -return -value -of -Some -( -0 -) -is -impossible -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -a -few -cases -where -a -static -number -of -capture -groups -is -/ -/ -/ -available -and -a -few -cases -where -it -is -not -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -len -= -| -pattern -| -{ -/ -/ -/ -Regex -: -: -new -( -pattern -) -. -map -( -| -re -| -re -. -static_captures_len -( -) -) -/ -/ -/ -} -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -Some -( -1 -) -len -( -" -a -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -a -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -a -) -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -3 -) -len -( -" -( -a -) -( -b -) -| -( -c -) -( -d -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -( -a -) -| -b -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -a -| -( -b -) -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -None -len -( -" -( -b -) -* -" -) -? -) -; -/ -/ -/ -assert_eq -! -( -Some -( -2 -) -len -( -" -( -b -) -+ -" -) -? -) -; -/ -/ -/ -/ -/ -/ -# -Ok -: -: -< -( -) -Box -< -dyn -std -: -: -error -: -: -Error -> -> -( -( -) -) -/ -/ -/ -# -[ -inline -] -pub -fn -static_captures_len -( -& -self -) -- -> -Option -< -usize -> -{ -self -. -meta -. -static_captures_len -( -) -} -/ -/ -/ -Returns -a -fresh -allocated -set -of -capture -locations -that -can -/ -/ -/ -be -reused -in -multiple -calls -to -[ -Regex -: -: -captures_read -] -or -/ -/ -/ -[ -Regex -: -: -captures_read_at -] -. -/ -/ -/ -/ -/ -/ -The -returned -locations -can -be -used -for -any -subsequent -search -for -this -/ -/ -/ -particular -regex -. -There -is -no -guarantee -that -it -is -correct -to -use -for -/ -/ -/ -other -regexes -even -if -they -have -the -same -number -of -capture -groups -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -. -) -( -. -) -( -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert -! -( -re -. -captures_read -( -& -mut -locs -" -Padron -" -) -. -is_some -( -) -) -; -/ -/ -/ -assert_eq -! -( -locs -. -get -( -0 -) -Some -( -( -0 -6 -) -) -) -; -/ -/ -/ -assert_eq -! -( -locs -. -get -( -1 -) -Some -( -( -0 -1 -) -) -) -; -/ -/ -/ -assert_eq -! -( -locs -. -get -( -2 -) -Some -( -( -1 -2 -) -) -) -; -/ -/ -/ -assert_eq -! -( -locs -. -get -( -3 -) -Some -( -( -2 -6 -) -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -capture_locations -( -& -self -) -- -> -CaptureLocations -{ -CaptureLocations -( -self -. -meta -. -create_captures -( -) -) -} -/ -/ -/ -An -alias -for -capture_locations -to -preserve -backward -compatibility -. -/ -/ -/ -/ -/ -/ -The -regex -- -capi -crate -used -this -method -so -to -avoid -breaking -that -/ -/ -/ -crate -we -continue -to -export -it -as -an -undocumented -API -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -locations -( -& -self -) -- -> -CaptureLocations -{ -self -. -capture_locations -( -) -} -} -/ -/ -/ -Represents -a -single -match -of -a -regex -in -a -haystack -. -/ -/ -/ -/ -/ -/ -A -Match -contains -both -the -start -and -end -byte -offsets -of -the -match -and -the -/ -/ -/ -actual -substring -corresponding -to -the -range -of -those -byte -offsets -. -It -is -/ -/ -/ -guaranteed -that -start -< -= -end -. -When -start -= -= -end -the -match -is -empty -. -/ -/ -/ -/ -/ -/ -Since -this -Match -can -only -be -produced -by -the -top -- -level -Regex -APIs -/ -/ -/ -that -only -support -searching -UTF -- -8 -encoded -strings -the -byte -offsets -for -a -/ -/ -/ -Match -are -guaranteed -to -fall -on -valid -UTF -- -8 -codepoint -boundaries -. -That -/ -/ -/ -is -slicing -a -& -str -with -[ -Match -: -: -range -] -is -guaranteed -to -never -panic -. -/ -/ -/ -/ -/ -/ -Values -with -this -type -are -created -by -[ -Regex -: -: -find -] -or -/ -/ -/ -[ -Regex -: -: -find_iter -] -. -Other -APIs -can -create -Match -values -too -. -For -/ -/ -/ -example -[ -Captures -: -: -get -] -. -/ -/ -/ -/ -/ -/ -The -lifetime -parameter -' -h -refers -to -the -lifetime -of -the -matched -of -the -/ -/ -/ -haystack -that -this -match -was -produced -from -. -/ -/ -/ -/ -/ -/ -# -Numbering -/ -/ -/ -/ -/ -/ -The -byte -offsets -in -a -Match -form -a -half -- -open -interval -. -That -is -the -/ -/ -/ -start -of -the -range -is -inclusive -and -the -end -of -the -range -is -exclusive -. -/ -/ -/ -For -example -given -a -haystack -abcFOOxyz -and -a -match -of -FOO -its -byte -/ -/ -/ -offset -range -starts -at -3 -and -ends -at -6 -. -3 -corresponds -to -F -and -/ -/ -/ -6 -corresponds -to -x -which -is -one -past -the -end -of -the -match -. -This -/ -/ -/ -corresponds -to -the -same -kind -of -slicing -that -Rust -uses -. -/ -/ -/ -/ -/ -/ -For -more -on -why -this -was -chosen -over -other -schemes -( -aside -from -being -/ -/ -/ -consistent -with -how -Rust -the -language -works -) -see -[ -this -discussion -] -and -/ -/ -/ -[ -Dijkstra -' -s -note -on -a -related -topic -] -[ -note -] -. -/ -/ -/ -/ -/ -/ -[ -this -discussion -] -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -discussions -/ -866 -/ -/ -/ -[ -note -] -: -https -: -/ -/ -www -. -cs -. -utexas -. -edu -/ -users -/ -EWD -/ -transcriptions -/ -EWD08xx -/ -EWD831 -. -html -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -value -of -each -of -the -methods -on -Match -for -a -/ -/ -/ -particular -search -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -\ -p -{ -Greek -} -+ -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -Greek -: -" -; -/ -/ -/ -let -m -= -re -. -find -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -7 -m -. -start -( -) -) -; -/ -/ -/ -assert_eq -! -( -15 -m -. -end -( -) -) -; -/ -/ -/ -assert -! -( -! -m -. -is_empty -( -) -) -; -/ -/ -/ -assert_eq -! -( -8 -m -. -len -( -) -) -; -/ -/ -/ -assert_eq -! -( -7 -. -. -15 -m -. -range -( -) -) -; -/ -/ -/ -assert_eq -! -( -" -" -m -. -as_str -( -) -) -; -/ -/ -/ -# -[ -derive -( -Copy -Clone -Eq -PartialEq -) -] -pub -struct -Match -< -' -h -> -{ -haystack -: -& -' -h -str -start -: -usize -end -: -usize -} -impl -< -' -h -> -Match -< -' -h -> -{ -/ -/ -/ -Returns -the -byte -offset -of -the -start -of -the -match -in -the -haystack -. -The -/ -/ -/ -start -of -the -match -corresponds -to -the -position -where -the -match -begins -/ -/ -/ -and -includes -the -first -byte -in -the -match -. -/ -/ -/ -/ -/ -/ -It -is -guaranteed -that -Match -: -: -start -( -) -< -= -Match -: -: -end -( -) -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -fall -on -a -valid -UTF -- -8 -codepoint -boundary -. -That -/ -/ -/ -is -it -will -never -be -an -offset -that -appears -between -the -UTF -- -8 -code -/ -/ -/ -units -of -a -UTF -- -8 -encoded -Unicode -scalar -value -. -Consequently -it -is -/ -/ -/ -always -safe -to -slice -the -corresponding -haystack -using -this -offset -. -# -[ -inline -] -pub -fn -start -( -& -self -) -- -> -usize -{ -self -. -start -} -/ -/ -/ -Returns -the -byte -offset -of -the -end -of -the -match -in -the -haystack -. -The -/ -/ -/ -end -of -the -match -corresponds -to -the -byte -immediately -following -the -last -/ -/ -/ -byte -in -the -match -. -This -means -that -& -slice -[ -start -. -. -end -] -works -as -one -/ -/ -/ -would -expect -. -/ -/ -/ -/ -/ -/ -It -is -guaranteed -that -Match -: -: -start -( -) -< -= -Match -: -: -end -( -) -. -/ -/ -/ -/ -/ -/ -This -is -guaranteed -to -fall -on -a -valid -UTF -- -8 -codepoint -boundary -. -That -/ -/ -/ -is -it -will -never -be -an -offset -that -appears -between -the -UTF -- -8 -code -/ -/ -/ -units -of -a -UTF -- -8 -encoded -Unicode -scalar -value -. -Consequently -it -is -/ -/ -/ -always -safe -to -slice -the -corresponding -haystack -using -this -offset -. -# -[ -inline -] -pub -fn -end -( -& -self -) -- -> -usize -{ -self -. -end -} -/ -/ -/ -Returns -true -if -and -only -if -this -match -has -a -length -of -zero -. -/ -/ -/ -/ -/ -/ -Note -that -an -empty -match -can -only -occur -when -the -regex -itself -can -/ -/ -/ -match -the -empty -string -. -Here -are -some -examples -of -regexes -that -can -/ -/ -/ -all -match -the -empty -string -: -^ -^ -\ -b -a -? -a -* -a -{ -0 -} -/ -/ -/ -( -foo -| -\ -d -+ -| -quux -) -? -. -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -start -= -= -self -. -end -} -/ -/ -/ -Returns -the -length -in -bytes -of -this -match -. -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -end -- -self -. -start -} -/ -/ -/ -Returns -the -range -over -the -starting -and -ending -byte -offsets -of -the -/ -/ -/ -match -in -the -haystack -. -/ -/ -/ -/ -/ -/ -It -is -always -correct -to -slice -the -original -haystack -searched -with -this -/ -/ -/ -range -. -That -is -because -the -offsets -are -guaranteed -to -fall -on -valid -/ -/ -/ -UTF -- -8 -boundaries -the -range -returned -is -always -valid -. -# -[ -inline -] -pub -fn -range -( -& -self -) -- -> -core -: -: -ops -: -: -Range -< -usize -> -{ -self -. -start -. -. -self -. -end -} -/ -/ -/ -Returns -the -substring -of -the -haystack -that -matched -. -# -[ -inline -] -pub -fn -as_str -( -& -self -) -- -> -& -' -h -str -{ -& -self -. -haystack -[ -self -. -range -( -) -] -} -/ -/ -/ -Creates -a -new -match -from -the -given -haystack -and -byte -offsets -. -# -[ -inline -] -fn -new -( -haystack -: -& -' -h -str -start -: -usize -end -: -usize -) -- -> -Match -< -' -h -> -{ -Match -{ -haystack -start -end -} -} -} -impl -< -' -h -> -core -: -: -fmt -: -: -Debug -for -Match -< -' -h -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -f -. -debug_struct -( -" -Match -" -) -. -field -( -" -start -" -& -self -. -start -) -. -field -( -" -end -" -& -self -. -end -) -. -field -( -" -string -" -& -self -. -as_str -( -) -) -. -finish -( -) -} -} -impl -< -' -h -> -From -< -Match -< -' -h -> -> -for -& -' -h -str -{ -fn -from -( -m -: -Match -< -' -h -> -) -- -> -& -' -h -str -{ -m -. -as_str -( -) -} -} -impl -< -' -h -> -From -< -Match -< -' -h -> -> -for -core -: -: -ops -: -: -Range -< -usize -> -{ -fn -from -( -m -: -Match -< -' -h -> -) -- -> -core -: -: -ops -: -: -Range -< -usize -> -{ -m -. -range -( -) -} -} -/ -/ -/ -Represents -the -capture -groups -for -a -single -match -. -/ -/ -/ -/ -/ -/ -Capture -groups -refer -to -parts -of -a -regex -enclosed -in -parentheses -. -They -can -/ -/ -/ -be -optionally -named -. -The -purpose -of -capture -groups -is -to -be -able -to -/ -/ -/ -reference -different -parts -of -a -match -based -on -the -original -pattern -. -For -/ -/ -/ -example -say -you -want -to -match -the -individual -letters -in -a -5 -- -letter -word -: -/ -/ -/ -/ -/ -/ -text -/ -/ -/ -( -? -< -first -> -\ -w -) -( -\ -w -) -( -? -: -\ -w -) -\ -w -( -? -< -last -> -\ -w -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -This -regex -has -4 -capture -groups -: -/ -/ -/ -/ -/ -/ -* -The -group -at -index -0 -corresponds -to -the -overall -match -. -It -is -always -/ -/ -/ -present -in -every -match -and -never -has -a -name -. -/ -/ -/ -* -The -group -at -index -1 -with -name -first -corresponding -to -the -first -/ -/ -/ -letter -. -/ -/ -/ -* -The -group -at -index -2 -with -no -name -corresponding -to -the -second -letter -. -/ -/ -/ -* -The -group -at -index -3 -with -name -last -corresponding -to -the -fifth -and -/ -/ -/ -last -letter -. -/ -/ -/ -/ -/ -/ -Notice -that -( -? -: -\ -w -) -was -not -listed -above -as -a -capture -group -despite -it -/ -/ -/ -being -enclosed -in -parentheses -. -That -' -s -because -( -? -: -pattern -) -is -a -special -/ -/ -/ -syntax -that -permits -grouping -but -* -without -* -capturing -. -The -reason -for -not -/ -/ -/ -treating -it -as -a -capture -is -that -tracking -and -reporting -capture -groups -/ -/ -/ -requires -additional -state -that -may -lead -to -slower -searches -. -So -using -as -few -/ -/ -/ -capture -groups -as -possible -can -help -performance -. -( -Although -the -difference -/ -/ -/ -in -performance -of -a -couple -of -capture -groups -is -likely -immaterial -. -) -/ -/ -/ -/ -/ -/ -Values -with -this -type -are -created -by -[ -Regex -: -: -captures -] -or -/ -/ -/ -[ -Regex -: -: -captures_iter -] -. -/ -/ -/ -/ -/ -/ -' -h -is -the -lifetime -of -the -haystack -that -these -captures -were -matched -from -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -) -( -\ -w -) -( -? -: -\ -w -) -\ -w -( -? -< -last -> -\ -w -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -" -toady -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -" -toady -" -& -caps -[ -0 -] -) -; -/ -/ -/ -assert_eq -! -( -" -t -" -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -assert_eq -! -( -" -o -" -& -caps -[ -2 -] -) -; -/ -/ -/ -assert_eq -! -( -" -y -" -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -pub -struct -Captures -< -' -h -> -{ -haystack -: -& -' -h -str -caps -: -captures -: -: -Captures -static_captures_len -: -Option -< -usize -> -} -impl -< -' -h -> -Captures -< -' -h -> -{ -/ -/ -/ -Returns -the -Match -associated -with -the -capture -group -at -index -i -. -If -/ -/ -/ -i -does -not -correspond -to -a -capture -group -or -if -the -capture -group -did -/ -/ -/ -not -participate -in -the -match -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -When -i -= -= -0 -this -is -guaranteed -to -return -a -non -- -None -value -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Get -the -substring -that -matched -with -a -default -of -an -empty -string -if -the -/ -/ -/ -group -didn -' -t -participate -in -the -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -- -z -] -+ -( -? -: -( -[ -0 -- -9 -] -+ -) -| -( -[ -A -- -Z -] -+ -) -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -" -abc123 -" -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -substr1 -= -caps -. -get -( -1 -) -. -map_or -( -" -" -| -m -| -m -. -as_str -( -) -) -; -/ -/ -/ -let -substr2 -= -caps -. -get -( -2 -) -. -map_or -( -" -" -| -m -| -m -. -as_str -( -) -) -; -/ -/ -/ -assert_eq -! -( -substr1 -" -123 -" -) -; -/ -/ -/ -assert_eq -! -( -substr2 -" -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get -( -& -self -i -: -usize -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -caps -. -get_group -( -i -) -. -map -( -| -sp -| -Match -: -: -new -( -self -. -haystack -sp -. -start -sp -. -end -) -) -} -/ -/ -/ -Returns -the -Match -associated -with -the -capture -group -named -name -. -If -/ -/ -/ -name -isn -' -t -a -valid -capture -group -or -it -refers -to -a -group -that -didn -' -t -/ -/ -/ -match -then -None -is -returned -. -/ -/ -/ -/ -/ -/ -Note -that -unlike -caps -[ -" -name -" -] -this -returns -a -Match -whose -lifetime -/ -/ -/ -matches -the -lifetime -of -the -haystack -in -this -Captures -value -. -/ -/ -/ -Conversely -the -substring -returned -by -caps -[ -" -name -" -] -has -a -lifetime -/ -/ -/ -of -the -Captures -value -which -is -likely -shorter -than -the -lifetime -of -/ -/ -/ -the -haystack -. -In -some -cases -it -may -be -necessary -to -use -this -method -to -/ -/ -/ -access -the -matching -substring -instead -of -the -caps -[ -" -name -" -] -notation -. -/ -/ -/ -/ -/ -/ -# -Examples -/ -/ -/ -/ -/ -/ -Get -the -substring -that -matched -with -a -default -of -an -empty -string -if -the -/ -/ -/ -group -didn -' -t -participate -in -the -match -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -/ -/ -/ -r -" -[ -a -- -z -] -+ -( -? -: -( -? -< -numbers -> -[ -0 -- -9 -] -+ -) -| -( -? -< -letters -> -[ -A -- -Z -] -+ -) -) -" -/ -/ -/ -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -" -abc123 -" -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -numbers -= -caps -. -name -( -" -numbers -" -) -. -map_or -( -" -" -| -m -| -m -. -as_str -( -) -) -; -/ -/ -/ -let -letters -= -caps -. -name -( -" -letters -" -) -. -map_or -( -" -" -| -m -| -m -. -as_str -( -) -) -; -/ -/ -/ -assert_eq -! -( -numbers -" -123 -" -) -; -/ -/ -/ -assert_eq -! -( -letters -" -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -name -( -& -self -name -: -& -str -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -caps -. -get_group_by_name -( -name -) -. -map -( -| -sp -| -Match -: -: -new -( -self -. -haystack -sp -. -start -sp -. -end -) -) -} -/ -/ -/ -This -is -a -convenience -routine -for -extracting -the -substrings -/ -/ -/ -corresponding -to -matching -capture -groups -. -/ -/ -/ -/ -/ -/ -This -returns -a -tuple -where -the -first -element -corresponds -to -the -full -/ -/ -/ -substring -of -the -haystack -that -matched -the -regex -. -The -second -element -is -/ -/ -/ -an -array -of -substrings -with -each -corresponding -to -the -to -the -substring -/ -/ -/ -that -matched -for -a -particular -capture -group -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -if -the -number -of -possible -matching -groups -in -this -/ -/ -/ -Captures -value -is -not -fixed -to -N -in -all -circumstances -. -/ -/ -/ -More -precisely -this -routine -only -works -when -N -is -equivalent -to -/ -/ -/ -[ -Regex -: -: -static_captures_len -] -. -/ -/ -/ -/ -/ -/ -Stated -more -plainly -if -the -number -of -matching -capture -groups -in -a -/ -/ -/ -regex -can -vary -from -match -to -match -then -this -function -always -panics -. -/ -/ -/ -/ -/ -/ -For -example -( -a -) -( -b -) -| -( -c -) -could -produce -two -matching -capture -groups -/ -/ -/ -or -one -matching -capture -group -for -any -given -match -. -Therefore -one -/ -/ -/ -cannot -use -extract -with -such -a -pattern -. -/ -/ -/ -/ -/ -/ -But -a -pattern -like -( -a -) -( -b -) -| -( -c -) -( -d -) -can -be -used -with -extract -because -/ -/ -/ -the -number -of -capture -groups -in -every -match -is -always -equivalent -/ -/ -/ -even -if -the -capture -_indices_ -in -each -match -are -not -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -On -2010 -- -03 -- -14 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -let -Some -( -( -full -[ -year -month -day -] -) -) -= -/ -/ -/ -re -. -captures -( -hay -) -. -map -( -| -caps -| -caps -. -extract -( -) -) -else -{ -return -} -; -/ -/ -/ -assert_eq -! -( -" -2010 -- -03 -- -14 -" -full -) -; -/ -/ -/ -assert_eq -! -( -" -2010 -" -year -) -; -/ -/ -/ -assert_eq -! -( -" -03 -" -month -) -; -/ -/ -/ -assert_eq -! -( -" -14 -" -day -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -iteration -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -use -this -method -when -iterating -over -all -/ -/ -/ -Captures -matches -in -a -haystack -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -[ -0 -- -9 -] -{ -4 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -- -( -[ -0 -- -9 -] -{ -2 -} -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -1973 -- -01 -- -05 -1975 -- -08 -- -25 -and -1980 -- -10 -- -18 -" -; -/ -/ -/ -/ -/ -/ -let -mut -dates -: -Vec -< -( -& -str -& -str -& -str -) -> -= -vec -! -[ -] -; -/ -/ -/ -for -( -_ -[ -y -m -d -] -) -in -re -. -captures_iter -( -hay -) -. -map -( -| -c -| -c -. -extract -( -) -) -{ -/ -/ -/ -dates -. -push -( -( -y -m -d -) -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -dates -vec -! -[ -/ -/ -/ -( -" -1973 -" -" -01 -" -" -05 -" -) -/ -/ -/ -( -" -1975 -" -" -08 -" -" -25 -" -) -/ -/ -/ -( -" -1980 -" -" -10 -" -" -18 -" -) -/ -/ -/ -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Example -: -parsing -different -formats -/ -/ -/ -/ -/ -/ -This -API -is -particularly -useful -when -you -need -to -extract -a -particular -/ -/ -/ -value -that -might -occur -in -a -different -format -. -Consider -for -example -/ -/ -/ -an -identifier -that -might -be -in -double -quotes -or -single -quotes -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -# -" -id -: -( -? -: -" -( -[ -^ -" -] -+ -) -" -| -' -( -[ -^ -' -] -+ -) -' -) -" -# -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -r -# -" -The -first -is -id -: -" -foo -" -and -the -second -is -id -: -' -bar -' -. -" -# -; -/ -/ -/ -let -mut -ids -= -vec -! -[ -] -; -/ -/ -/ -for -( -_ -[ -id -] -) -in -re -. -captures_iter -( -hay -) -. -map -( -| -c -| -c -. -extract -( -) -) -{ -/ -/ -/ -ids -. -push -( -id -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -ids -vec -! -[ -" -foo -" -" -bar -" -] -) -; -/ -/ -/ -pub -fn -extract -< -const -N -: -usize -> -( -& -self -) -- -> -( -& -' -h -str -[ -& -' -h -str -; -N -] -) -{ -let -len -= -self -. -static_captures_len -. -expect -( -" -number -of -capture -groups -can -vary -in -a -match -" -) -. -checked_sub -( -1 -) -. -expect -( -" -number -of -groups -is -always -greater -than -zero -" -) -; -assert_eq -! -( -N -len -" -asked -for -{ -} -groups -but -must -ask -for -{ -} -" -N -len -) -; -/ -/ -The -regex -- -automata -variant -of -extract -is -a -bit -more -permissive -. -/ -/ -It -doesn -' -t -require -the -number -of -matching -capturing -groups -to -be -/ -/ -static -and -you -can -even -request -fewer -groups -than -what -' -s -there -. -So -/ -/ -this -is -guaranteed -to -never -panic -because -we -' -ve -asserted -above -that -/ -/ -the -user -has -requested -precisely -the -number -of -groups -that -must -be -/ -/ -present -in -any -match -for -this -regex -. -self -. -caps -. -extract -( -self -. -haystack -) -} -/ -/ -/ -Expands -all -instances -of -ref -in -replacement -to -the -corresponding -/ -/ -/ -capture -group -and -writes -them -to -the -dst -buffer -given -. -A -ref -can -/ -/ -/ -be -a -capture -group -index -or -a -name -. -If -ref -doesn -' -t -refer -to -a -capture -/ -/ -/ -group -that -participated -in -the -match -then -it -is -replaced -with -the -/ -/ -/ -empty -string -. -/ -/ -/ -/ -/ -/ -# -Format -/ -/ -/ -/ -/ -/ -The -format -of -the -replacement -string -supports -two -different -kinds -of -/ -/ -/ -capture -references -: -unbraced -and -braced -. -/ -/ -/ -/ -/ -/ -For -the -unbraced -format -the -format -supported -is -ref -where -name -/ -/ -/ -can -be -any -character -in -the -class -[ -0 -- -9A -- -Za -- -z_ -] -. -ref -is -always -/ -/ -/ -the -longest -possible -parse -. -So -for -example -1a -corresponds -to -the -/ -/ -/ -capture -group -named -1a -and -not -the -capture -group -at -index -1 -. -If -/ -/ -/ -ref -matches -^ -[ -0 -- -9 -] -+ -then -it -is -treated -as -a -capture -group -index -/ -/ -/ -itself -and -not -a -name -. -/ -/ -/ -/ -/ -/ -For -the -braced -format -the -format -supported -is -{ -ref -} -where -ref -can -/ -/ -/ -be -any -sequence -of -bytes -except -for -} -. -If -no -closing -brace -occurs -/ -/ -/ -then -it -is -not -considered -a -capture -reference -. -As -with -the -unbraced -/ -/ -/ -format -if -ref -matches -^ -[ -0 -- -9 -] -+ -then -it -is -treated -as -a -capture -/ -/ -/ -group -index -and -not -a -name -. -/ -/ -/ -/ -/ -/ -The -braced -format -is -useful -for -exerting -precise -control -over -the -name -/ -/ -/ -of -the -capture -reference -. -For -example -{ -1 -} -a -corresponds -to -the -/ -/ -/ -capture -group -reference -1 -followed -by -the -letter -a -where -as -1a -/ -/ -/ -( -as -mentioned -above -) -corresponds -to -the -capture -group -reference -1a -. -/ -/ -/ -The -braced -format -is -also -useful -for -expressing -capture -group -names -/ -/ -/ -that -use -characters -not -supported -by -the -unbraced -format -. -For -example -/ -/ -/ -{ -foo -[ -bar -] -. -baz -} -refers -to -the -capture -group -named -foo -[ -bar -] -. -baz -. -/ -/ -/ -/ -/ -/ -If -a -capture -group -reference -is -found -and -it -does -not -refer -to -a -valid -/ -/ -/ -capture -group -then -it -will -be -replaced -with -the -empty -string -. -/ -/ -/ -/ -/ -/ -To -write -a -literal -use -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -/ -/ -/ -r -" -( -? -< -day -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -month -> -[ -0 -- -9 -] -{ -2 -} -) -- -( -? -< -year -> -[ -0 -- -9 -] -{ -4 -} -) -" -/ -/ -/ -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -On -14 -- -03 -- -2010 -I -became -a -Tenneessee -lamb -. -" -; -/ -/ -/ -let -caps -= -re -. -captures -( -hay -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -dst -= -String -: -: -new -( -) -; -/ -/ -/ -caps -. -expand -( -" -year -= -year -month -= -month -day -= -day -" -& -mut -dst -) -; -/ -/ -/ -assert_eq -! -( -dst -" -year -= -2010 -month -= -03 -day -= -14 -" -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -expand -( -& -self -replacement -: -& -str -dst -: -& -mut -String -) -{ -self -. -caps -. -interpolate_string_into -( -self -. -haystack -replacement -dst -) -; -} -/ -/ -/ -Returns -an -iterator -over -all -capture -groups -. -This -includes -both -/ -/ -/ -matching -and -non -- -matching -groups -. -/ -/ -/ -/ -/ -/ -The -iterator -always -yields -at -least -one -matching -group -: -the -first -group -/ -/ -/ -( -at -index -0 -) -with -no -name -. -Subsequent -groups -are -returned -in -the -order -/ -/ -/ -of -their -opening -parenthesis -in -the -regex -. -/ -/ -/ -/ -/ -/ -The -elements -yielded -have -type -Option -< -Match -< -' -h -> -> -where -a -non -- -None -/ -/ -/ -value -is -present -if -the -capture -group -matches -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -\ -w -) -( -\ -d -) -? -( -\ -w -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -" -AZ -" -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -let -mut -it -= -caps -. -iter -( -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -. -unwrap -( -) -. -map -( -| -m -| -m -. -as_str -( -) -) -Some -( -" -AZ -" -) -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -. -unwrap -( -) -. -map -( -| -m -| -m -. -as_str -( -) -) -Some -( -" -A -" -) -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -. -unwrap -( -) -. -map -( -| -m -| -m -. -as_str -( -) -) -None -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -. -unwrap -( -) -. -map -( -| -m -| -m -. -as_str -( -) -) -Some -( -" -Z -" -) -) -; -/ -/ -/ -assert_eq -! -( -it -. -next -( -) -None -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -iter -< -' -c -> -( -& -' -c -self -) -- -> -SubCaptureMatches -< -' -c -' -h -> -{ -SubCaptureMatches -{ -haystack -: -self -. -haystack -it -: -self -. -caps -. -iter -( -) -} -} -/ -/ -/ -Returns -the -total -number -of -capture -groups -. -This -includes -both -/ -/ -/ -matching -and -non -- -matching -groups -. -/ -/ -/ -/ -/ -/ -The -length -returned -is -always -equivalent -to -the -number -of -elements -/ -/ -/ -yielded -by -[ -Captures -: -: -iter -] -. -Consequently -the -length -is -always -/ -/ -/ -greater -than -zero -since -every -Captures -value -always -includes -the -/ -/ -/ -match -for -the -entire -regex -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -\ -w -) -( -\ -d -) -? -( -\ -w -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -caps -= -re -. -captures -( -" -AZ -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -caps -. -len -( -) -4 -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -caps -. -group_len -( -) -} -} -impl -< -' -h -> -core -: -: -fmt -: -: -Debug -for -Captures -< -' -h -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -/ -/ -/ -A -little -helper -type -to -provide -a -nice -map -- -like -debug -/ -/ -/ -representation -for -our -capturing -group -spans -. -/ -/ -/ -/ -/ -/ -regex -- -automata -has -something -similar -but -it -includes -the -pattern -/ -/ -/ -ID -in -its -debug -output -which -is -confusing -. -It -also -doesn -' -t -include -/ -/ -/ -that -strings -that -match -because -a -regex -- -automata -Captures -doesn -' -t -/ -/ -/ -borrow -the -haystack -. -struct -CapturesDebugMap -< -' -a -> -{ -caps -: -& -' -a -Captures -< -' -a -> -} -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -CapturesDebugMap -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -let -mut -map -= -f -. -debug_map -( -) -; -let -names -= -self -. -caps -. -caps -. -group_info -( -) -. -pattern_names -( -PatternID -: -: -ZERO -) -; -for -( -group_index -maybe_name -) -in -names -. -enumerate -( -) -{ -let -key -= -Key -( -group_index -maybe_name -) -; -match -self -. -caps -. -get -( -group_index -) -{ -None -= -> -map -. -entry -( -& -key -& -None -: -: -< -( -) -> -) -Some -( -mat -) -= -> -map -. -entry -( -& -key -& -Value -( -mat -) -) -} -; -} -map -. -finish -( -) -} -} -struct -Key -< -' -a -> -( -usize -Option -< -& -' -a -str -> -) -; -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -Key -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -} -" -self -. -0 -) -? -; -if -let -Some -( -name -) -= -self -. -1 -{ -write -! -( -f -" -/ -{ -: -? -} -" -name -) -? -; -} -Ok -( -( -) -) -} -} -struct -Value -< -' -a -> -( -Match -< -' -a -> -) -; -impl -< -' -a -> -core -: -: -fmt -: -: -Debug -for -Value -< -' -a -> -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -{ -} -. -. -{ -} -/ -{ -: -? -} -" -self -. -0 -. -start -( -) -self -. -0 -. -end -( -) -self -. -0 -. -as_str -( -) -) -} -} -f -. -debug_tuple -( -" -Captures -" -) -. -field -( -& -CapturesDebugMap -{ -caps -: -self -} -) -. -finish -( -) -} -} -/ -/ -/ -Get -a -matching -capture -group -' -s -haystack -substring -by -index -. -/ -/ -/ -/ -/ -/ -The -haystack -substring -returned -can -' -t -outlive -the -Captures -object -if -this -/ -/ -/ -method -is -used -because -of -how -Index -is -defined -( -normally -a -[ -i -] -is -part -/ -/ -/ -of -a -and -can -' -t -outlive -it -) -. -To -work -around -this -limitation -do -that -use -/ -/ -/ -[ -Captures -: -: -get -] -instead -. -/ -/ -/ -/ -/ -/ -' -h -is -the -lifetime -of -the -matched -haystack -but -the -lifetime -of -the -/ -/ -/ -& -str -returned -by -this -implementation -is -the -lifetime -of -the -Captures -/ -/ -/ -value -itself -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -there -is -no -matching -group -at -the -given -index -. -impl -< -' -h -> -core -: -: -ops -: -: -Index -< -usize -> -for -Captures -< -' -h -> -{ -type -Output -= -str -; -/ -/ -The -lifetime -is -written -out -to -make -it -clear -that -the -& -str -returned -/ -/ -does -NOT -have -a -lifetime -equivalent -to -' -h -. -fn -index -< -' -a -> -( -& -' -a -self -i -: -usize -) -- -> -& -' -a -str -{ -self -. -get -( -i -) -. -map -( -| -m -| -m -. -as_str -( -) -) -. -unwrap_or_else -( -| -| -panic -! -( -" -no -group -at -index -' -{ -} -' -" -i -) -) -} -} -/ -/ -/ -Get -a -matching -capture -group -' -s -haystack -substring -by -name -. -/ -/ -/ -/ -/ -/ -The -haystack -substring -returned -can -' -t -outlive -the -Captures -object -if -this -/ -/ -/ -method -is -used -because -of -how -Index -is -defined -( -normally -a -[ -i -] -is -part -/ -/ -/ -of -a -and -can -' -t -outlive -it -) -. -To -work -around -this -limitation -do -that -use -/ -/ -/ -[ -Captures -: -: -get -] -instead -. -/ -/ -/ -/ -/ -/ -' -h -is -the -lifetime -of -the -matched -haystack -but -the -lifetime -of -the -/ -/ -/ -& -str -returned -by -this -implementation -is -the -lifetime -of -the -Captures -/ -/ -/ -value -itself -. -/ -/ -/ -/ -/ -/ -' -n -is -the -lifetime -of -the -group -name -used -to -index -the -Captures -value -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -there -is -no -matching -group -at -the -given -name -. -impl -< -' -h -' -n -> -core -: -: -ops -: -: -Index -< -& -' -n -str -> -for -Captures -< -' -h -> -{ -type -Output -= -str -; -fn -index -< -' -a -> -( -& -' -a -self -name -: -& -' -n -str -) -- -> -& -' -a -str -{ -self -. -name -( -name -) -. -map -( -| -m -| -m -. -as_str -( -) -) -. -unwrap_or_else -( -| -| -panic -! -( -" -no -group -named -' -{ -} -' -" -name -) -) -} -} -/ -/ -/ -A -low -level -representation -of -the -byte -offsets -of -each -capture -group -. -/ -/ -/ -/ -/ -/ -You -can -think -of -this -as -a -lower -level -[ -Captures -] -where -this -type -does -/ -/ -/ -not -support -named -capturing -groups -directly -and -it -does -not -borrow -the -/ -/ -/ -haystack -that -these -offsets -were -matched -on -. -/ -/ -/ -/ -/ -/ -Primarily -this -type -is -useful -when -using -the -lower -level -Regex -APIs -such -/ -/ -/ -as -[ -Regex -: -: -captures_read -] -which -permits -amortizing -the -allocation -in -/ -/ -/ -which -capture -match -offsets -are -stored -. -/ -/ -/ -/ -/ -/ -In -order -to -build -a -value -of -this -type -you -' -ll -need -to -call -the -/ -/ -/ -[ -Regex -: -: -capture_locations -] -method -. -The -value -returned -can -then -be -reused -/ -/ -/ -in -subsequent -searches -for -that -regex -. -Using -it -for -other -regexes -may -/ -/ -/ -result -in -a -panic -or -otherwise -incorrect -results -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -how -to -create -and -use -CaptureLocations -in -a -search -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -+ -) -\ -s -+ -( -? -< -last -> -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -let -m -= -re -. -captures_read -( -& -mut -locs -" -Bruce -Springsteen -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -0 -. -. -17 -m -. -range -( -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -17 -) -) -locs -. -get -( -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -5 -) -) -locs -. -get -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -6 -17 -) -) -locs -. -get -( -2 -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Asking -for -an -invalid -capture -group -always -returns -None -. -/ -/ -/ -assert_eq -! -( -None -locs -. -get -( -3 -) -) -; -/ -/ -/ -assert_eq -! -( -None -locs -. -get -( -34973498648 -) -) -; -/ -/ -/ -assert_eq -! -( -None -locs -. -get -( -9944060567225171988 -) -) -; -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -CaptureLocations -( -captures -: -: -Captures -) -; -/ -/ -/ -A -type -alias -for -CaptureLocations -for -backwards -compatibility -. -/ -/ -/ -/ -/ -/ -Previously -we -exported -CaptureLocations -as -Locations -in -an -/ -/ -/ -undocumented -API -. -To -prevent -breaking -that -code -( -e -. -g -. -in -regex -- -capi -) -/ -/ -/ -we -continue -re -- -exporting -the -same -undocumented -API -. -# -[ -doc -( -hidden -) -] -pub -type -Locations -= -CaptureLocations -; -impl -CaptureLocations -{ -/ -/ -/ -Returns -the -start -and -end -byte -offsets -of -the -capture -group -at -index -/ -/ -/ -i -. -This -returns -None -if -i -is -not -a -valid -capture -group -or -if -the -/ -/ -/ -capture -group -did -not -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -+ -) -\ -s -+ -( -? -< -last -> -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -re -. -captures_read -( -& -mut -locs -" -Bruce -Springsteen -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -17 -) -) -locs -. -get -( -0 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -0 -5 -) -) -locs -. -get -( -1 -) -) -; -/ -/ -/ -assert_eq -! -( -Some -( -( -6 -17 -) -) -locs -. -get -( -2 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -get -( -& -self -i -: -usize -) -- -> -Option -< -( -usize -usize -) -> -{ -self -. -0 -. -get_group -( -i -) -. -map -( -| -sp -| -( -sp -. -start -sp -. -end -) -) -} -/ -/ -/ -Returns -the -total -number -of -capture -groups -( -even -if -they -didn -' -t -match -) -. -/ -/ -/ -That -is -the -length -returned -is -unaffected -by -the -result -of -a -search -. -/ -/ -/ -/ -/ -/ -This -is -always -at -least -1 -since -every -regex -has -at -least -1 -/ -/ -/ -capturing -group -that -corresponds -to -the -entire -match -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -first -> -\ -w -+ -) -\ -s -+ -( -? -< -last -> -\ -w -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -mut -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert_eq -! -( -3 -locs -. -len -( -) -) -; -/ -/ -/ -re -. -captures_read -( -& -mut -locs -" -Bruce -Springsteen -" -) -. -unwrap -( -) -; -/ -/ -/ -assert_eq -! -( -3 -locs -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Notice -that -the -length -is -always -at -least -1 -regardless -of -the -regex -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -Regex -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -" -) -. -unwrap -( -) -; -/ -/ -/ -let -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert_eq -! -( -1 -locs -. -len -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -[ -a -& -& -b -] -is -a -regex -that -never -matches -anything -. -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -[ -a -& -& -b -] -" -) -. -unwrap -( -) -; -/ -/ -/ -let -locs -= -re -. -capture_locations -( -) -; -/ -/ -/ -assert_eq -! -( -1 -locs -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -/ -/ -self -. -0 -. -group_len -( -) -returns -0 -if -the -underlying -captures -doesn -' -t -/ -/ -represent -a -match -but -the -behavior -guaranteed -for -this -method -is -/ -/ -that -the -length -doesn -' -t -change -based -on -a -match -or -not -. -self -. -0 -. -group_info -( -) -. -group_len -( -PatternID -: -: -ZERO -) -} -/ -/ -/ -An -alias -for -the -get -method -for -backwards -compatibility -. -/ -/ -/ -/ -/ -/ -Previously -we -exported -get -as -pos -in -an -undocumented -API -. -To -/ -/ -/ -prevent -breaking -that -code -( -e -. -g -. -in -regex -- -capi -) -we -continue -/ -/ -/ -re -- -exporting -the -same -undocumented -API -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -pos -( -& -self -i -: -usize -) -- -> -Option -< -( -usize -usize -) -> -{ -self -. -get -( -i -) -} -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -matches -in -a -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -[ -Match -] -values -. -The -iterator -stops -when -no -more -/ -/ -/ -matches -can -be -found -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -and -' -h -is -the -/ -/ -/ -lifetime -of -the -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -find_iter -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -an -iterator -runs -potentially -many -searches -on -the -haystack -/ -/ -/ -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -complexity -the -/ -/ -/ -overall -worst -case -time -complexity -for -iteration -is -O -( -m -* -n -^ -2 -) -. -# -[ -derive -( -Debug -) -] -pub -struct -Matches -< -' -r -' -h -> -{ -haystack -: -& -' -h -str -it -: -meta -: -: -FindMatches -< -' -r -' -h -> -} -impl -< -' -r -' -h -> -Iterator -for -Matches -< -' -r -' -h -> -{ -type -Item -= -Match -< -' -h -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Match -< -' -h -> -> -{ -self -. -it -. -next -( -) -. -map -( -| -sp -| -Match -: -: -new -( -self -. -haystack -sp -. -start -( -) -sp -. -end -( -) -) -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -/ -/ -This -can -actually -be -up -to -2x -faster -than -calling -next -( -) -until -/ -/ -completion -because -counting -matches -when -using -a -DFA -only -requires -/ -/ -finding -the -end -of -each -match -. -But -returning -a -Match -via -next -( -) -/ -/ -requires -the -start -of -each -match -which -with -a -DFA -requires -a -/ -/ -reverse -forward -scan -to -find -it -. -self -. -it -. -count -( -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -Matches -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -all -non -- -overlapping -capture -matches -in -a -haystack -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -[ -Captures -] -values -. -The -iterator -stops -when -no -more -/ -/ -/ -matches -can -be -found -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -and -' -h -is -the -/ -/ -/ -lifetime -of -the -matched -string -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -captures_iter -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -an -iterator -runs -potentially -many -searches -on -the -haystack -/ -/ -/ -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -complexity -the -/ -/ -/ -overall -worst -case -time -complexity -for -iteration -is -O -( -m -* -n -^ -2 -) -. -# -[ -derive -( -Debug -) -] -pub -struct -CaptureMatches -< -' -r -' -h -> -{ -haystack -: -& -' -h -str -it -: -meta -: -: -CapturesMatches -< -' -r -' -h -> -} -impl -< -' -r -' -h -> -Iterator -for -CaptureMatches -< -' -r -' -h -> -{ -type -Item -= -Captures -< -' -h -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Captures -< -' -h -> -> -{ -let -static_captures_len -= -self -. -it -. -regex -( -) -. -static_captures_len -( -) -; -self -. -it -. -next -( -) -. -map -( -| -caps -| -Captures -{ -haystack -: -self -. -haystack -caps -static_captures_len -} -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -/ -/ -This -can -actually -be -up -to -2x -faster -than -calling -next -( -) -until -/ -/ -completion -because -counting -matches -when -using -a -DFA -only -requires -/ -/ -finding -the -end -of -each -match -. -But -returning -a -Match -via -next -( -) -/ -/ -requires -the -start -of -each -match -which -with -a -DFA -requires -a -/ -/ -reverse -forward -scan -to -find -it -. -self -. -it -. -count -( -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -CaptureMatches -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -all -substrings -delimited -by -a -regex -match -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -and -' -h -is -the -/ -/ -/ -lifetime -of -the -byte -string -being -split -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -split -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -an -iterator -runs -potentially -many -searches -on -the -haystack -/ -/ -/ -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -complexity -the -/ -/ -/ -overall -worst -case -time -complexity -for -iteration -is -O -( -m -* -n -^ -2 -) -. -# -[ -derive -( -Debug -) -] -pub -struct -Split -< -' -r -' -h -> -{ -haystack -: -& -' -h -str -it -: -meta -: -: -Split -< -' -r -' -h -> -} -impl -< -' -r -' -h -> -Iterator -for -Split -< -' -r -' -h -> -{ -type -Item -= -& -' -h -str -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -& -' -h -str -> -{ -self -. -it -. -next -( -) -. -map -( -| -span -| -& -self -. -haystack -[ -span -] -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -Split -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -at -most -N -substrings -delimited -by -a -regex -match -. -/ -/ -/ -/ -/ -/ -The -last -substring -yielded -by -this -iterator -will -be -whatever -remains -after -/ -/ -/ -N -- -1 -splits -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -and -' -h -is -the -/ -/ -/ -lifetime -of -the -byte -string -being -split -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -splitn -] -. -/ -/ -/ -/ -/ -/ -# -Time -complexity -/ -/ -/ -/ -/ -/ -Note -that -since -an -iterator -runs -potentially -many -searches -on -the -haystack -/ -/ -/ -and -since -each -search -has -worst -case -O -( -m -* -n -) -time -complexity -the -/ -/ -/ -overall -worst -case -time -complexity -for -iteration -is -O -( -m -* -n -^ -2 -) -. -/ -/ -/ -/ -/ -/ -Although -note -that -the -worst -case -time -here -has -an -upper -bound -given -/ -/ -/ -by -the -limit -parameter -to -[ -Regex -: -: -splitn -] -. -# -[ -derive -( -Debug -) -] -pub -struct -SplitN -< -' -r -' -h -> -{ -haystack -: -& -' -h -str -it -: -meta -: -: -SplitN -< -' -r -' -h -> -} -impl -< -' -r -' -h -> -Iterator -for -SplitN -< -' -r -' -h -> -{ -type -Item -= -& -' -h -str -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -& -' -h -str -> -{ -self -. -it -. -next -( -) -. -map -( -| -span -| -& -self -. -haystack -[ -span -] -) -} -# -[ -inline -] -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -it -. -size_hint -( -) -} -} -impl -< -' -r -' -h -> -core -: -: -iter -: -: -FusedIterator -for -SplitN -< -' -r -' -h -> -{ -} -/ -/ -/ -An -iterator -over -the -names -of -all -capture -groups -in -a -regex -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -values -of -type -Option -< -& -str -> -in -order -of -the -opening -/ -/ -/ -capture -group -parenthesis -in -the -regex -pattern -. -None -is -yielded -for -/ -/ -/ -groups -with -no -name -. -The -first -element -always -corresponds -to -the -implicit -/ -/ -/ -and -unnamed -group -for -the -overall -match -. -/ -/ -/ -/ -/ -/ -' -r -is -the -lifetime -of -the -compiled -regular -expression -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -[ -Regex -: -: -capture_names -] -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -CaptureNames -< -' -r -> -( -captures -: -: -GroupInfoPatternNames -< -' -r -> -) -; -impl -< -' -r -> -Iterator -for -CaptureNames -< -' -r -> -{ -type -Item -= -Option -< -& -' -r -str -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Option -< -& -' -r -str -> -> -{ -self -. -0 -. -next -( -) -} -# -[ -inline -] -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -0 -. -size_hint -( -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -self -. -0 -. -count -( -) -} -} -impl -< -' -r -> -ExactSizeIterator -for -CaptureNames -< -' -r -> -{ -} -impl -< -' -r -> -core -: -: -iter -: -: -FusedIterator -for -CaptureNames -< -' -r -> -{ -} -/ -/ -/ -An -iterator -over -all -group -matches -in -a -[ -Captures -] -value -. -/ -/ -/ -/ -/ -/ -This -iterator -yields -values -of -type -Option -< -Match -< -' -h -> -> -where -' -h -is -the -/ -/ -/ -lifetime -of -the -haystack -that -the -matches -are -for -. -The -order -of -elements -/ -/ -/ -yielded -corresponds -to -the -order -of -the -opening -parenthesis -for -the -group -/ -/ -/ -in -the -regex -pattern -. -None -is -yielded -for -groups -that -did -not -participate -/ -/ -/ -in -the -match -. -/ -/ -/ -/ -/ -/ -The -first -element -always -corresponds -to -the -implicit -group -for -the -overall -/ -/ -/ -match -. -Since -this -iterator -is -created -by -a -[ -Captures -] -value -and -a -/ -/ -/ -Captures -value -is -only -created -when -a -match -occurs -it -follows -that -the -/ -/ -/ -first -element -yielded -by -this -iterator -is -guaranteed -to -be -non -- -None -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -c -corresponds -to -the -lifetime -of -the -Captures -value -that -/ -/ -/ -created -this -iterator -and -the -lifetime -' -h -corresponds -to -the -originally -/ -/ -/ -matched -haystack -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -SubCaptureMatches -< -' -c -' -h -> -{ -haystack -: -& -' -h -str -it -: -captures -: -: -CapturesPatternIter -< -' -c -> -} -impl -< -' -c -' -h -> -Iterator -for -SubCaptureMatches -< -' -c -' -h -> -{ -type -Item -= -Option -< -Match -< -' -h -> -> -; -# -[ -inline -] -fn -next -( -& -mut -self -) -- -> -Option -< -Option -< -Match -< -' -h -> -> -> -{ -self -. -it -. -next -( -) -. -map -( -| -group -| -{ -group -. -map -( -| -sp -| -Match -: -: -new -( -self -. -haystack -sp -. -start -sp -. -end -) -) -} -) -} -# -[ -inline -] -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -it -. -size_hint -( -) -} -# -[ -inline -] -fn -count -( -self -) -- -> -usize -{ -self -. -it -. -count -( -) -} -} -impl -< -' -c -' -h -> -ExactSizeIterator -for -SubCaptureMatches -< -' -c -' -h -> -{ -} -impl -< -' -c -' -h -> -core -: -: -iter -: -: -FusedIterator -for -SubCaptureMatches -< -' -c -' -h -> -{ -} -/ -/ -/ -A -trait -for -types -that -can -be -used -to -replace -matches -in -a -haystack -. -/ -/ -/ -/ -/ -/ -In -general -users -of -this -crate -shouldn -' -t -need -to -implement -this -trait -/ -/ -/ -since -implementations -are -already -provided -for -& -str -along -with -other -/ -/ -/ -variants -of -string -types -as -well -as -FnMut -( -& -Captures -) -- -> -String -( -or -any -/ -/ -/ -FnMut -( -& -Captures -) -- -> -T -where -T -: -AsRef -< -str -> -) -. -Those -cover -most -use -cases -/ -/ -/ -but -callers -can -implement -this -trait -directly -if -necessary -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -a -basic -implementation -of -the -Replacer -trait -. -This -/ -/ -/ -can -be -done -much -more -simply -using -the -replacement -string -interpolation -/ -/ -/ -support -( -e -. -g -. -first -last -) -but -this -approach -avoids -needing -to -parse -/ -/ -/ -the -replacement -string -at -all -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -{ -Captures -Regex -Replacer -} -; -/ -/ -/ -/ -/ -/ -struct -NameSwapper -; -/ -/ -/ -/ -/ -/ -impl -Replacer -for -NameSwapper -{ -/ -/ -/ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -/ -/ -/ -dst -. -push_str -( -& -caps -[ -" -first -" -] -) -; -/ -/ -/ -dst -. -push_str -( -" -" -) -; -/ -/ -/ -dst -. -push_str -( -& -caps -[ -" -last -" -] -) -; -/ -/ -/ -} -/ -/ -/ -} -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -last -> -[ -^ -\ -s -] -+ -) -\ -s -+ -( -? -< -first -> -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -" -Springsteen -Bruce -" -NameSwapper -) -; -/ -/ -/ -assert_eq -! -( -result -" -Bruce -Springsteen -" -) -; -/ -/ -/ -pub -trait -Replacer -{ -/ -/ -/ -Appends -possibly -empty -data -to -dst -to -replace -the -current -match -. -/ -/ -/ -/ -/ -/ -The -current -match -is -represented -by -caps -which -is -guaranteed -to -/ -/ -/ -have -a -match -at -capture -group -0 -. -/ -/ -/ -/ -/ -/ -For -example -a -no -- -op -replacement -would -be -dst -. -push_str -( -& -caps -[ -0 -] -) -. -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -; -/ -/ -/ -Return -a -fixed -unchanging -replacement -string -. -/ -/ -/ -/ -/ -/ -When -doing -replacements -if -access -to -[ -Captures -] -is -not -needed -( -e -. -g -. -/ -/ -/ -the -replacement -string -does -not -need -expansion -) -then -it -can -be -/ -/ -/ -beneficial -to -avoid -finding -sub -- -captures -. -/ -/ -/ -/ -/ -/ -In -general -this -is -called -once -for -every -call -to -a -replacement -routine -/ -/ -/ -such -as -[ -Regex -: -: -replace_all -] -. -fn -no_expansion -< -' -r -> -( -& -' -r -mut -self -) -- -> -Option -< -Cow -< -' -r -str -> -> -{ -None -} -/ -/ -/ -Returns -a -type -that -implements -Replacer -but -that -borrows -and -wraps -/ -/ -/ -this -Replacer -. -/ -/ -/ -/ -/ -/ -This -is -useful -when -you -want -to -take -a -generic -Replacer -( -which -might -/ -/ -/ -not -be -cloneable -) -and -use -it -without -consuming -it -so -it -can -be -used -/ -/ -/ -more -than -once -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -{ -Regex -Replacer -} -; -/ -/ -/ -/ -/ -/ -fn -replace_all_twice -< -R -: -Replacer -> -( -/ -/ -/ -re -: -Regex -/ -/ -/ -src -: -& -str -/ -/ -/ -mut -rep -: -R -/ -/ -/ -) -- -> -String -{ -/ -/ -/ -let -dst -= -re -. -replace_all -( -src -rep -. -by_ref -( -) -) -; -/ -/ -/ -let -dst -= -re -. -replace_all -( -& -dst -rep -. -by_ref -( -) -) -; -/ -/ -/ -dst -. -into_owned -( -) -/ -/ -/ -} -/ -/ -/ -fn -by_ref -< -' -r -> -( -& -' -r -mut -self -) -- -> -ReplacerRef -< -' -r -Self -> -{ -ReplacerRef -( -self -) -} -} -impl -< -' -a -> -Replacer -for -& -' -a -str -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -caps -. -expand -( -* -self -dst -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -str -> -> -{ -no_expansion -( -self -) -} -} -impl -< -' -a -> -Replacer -for -& -' -a -String -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -self -. -as_str -( -) -. -replace_append -( -caps -dst -) -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -str -> -> -{ -no_expansion -( -self -) -} -} -impl -Replacer -for -String -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -self -. -as_str -( -) -. -replace_append -( -caps -dst -) -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -str -> -> -{ -no_expansion -( -self -) -} -} -impl -< -' -a -> -Replacer -for -Cow -< -' -a -str -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -self -. -as_ref -( -) -. -replace_append -( -caps -dst -) -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -str -> -> -{ -no_expansion -( -self -) -} -} -impl -< -' -a -> -Replacer -for -& -' -a -Cow -< -' -a -str -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -self -. -as_ref -( -) -. -replace_append -( -caps -dst -) -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -str -> -> -{ -no_expansion -( -self -) -} -} -impl -< -F -T -> -Replacer -for -F -where -F -: -FnMut -( -& -Captures -< -' -_ -> -) -- -> -T -T -: -AsRef -< -str -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -dst -. -push_str -( -( -* -self -) -( -caps -) -. -as_ref -( -) -) -; -} -} -/ -/ -/ -A -by -- -reference -adaptor -for -a -[ -Replacer -] -. -/ -/ -/ -/ -/ -/ -This -permits -reusing -the -same -Replacer -value -in -multiple -calls -to -a -/ -/ -/ -replacement -routine -like -[ -Regex -: -: -replace_all -] -. -/ -/ -/ -/ -/ -/ -This -type -is -created -by -[ -Replacer -: -: -by_ref -] -. -# -[ -derive -( -Debug -) -] -pub -struct -ReplacerRef -< -' -a -R -: -? -Sized -> -( -& -' -a -mut -R -) -; -impl -< -' -a -R -: -Replacer -+ -? -Sized -+ -' -a -> -Replacer -for -ReplacerRef -< -' -a -R -> -{ -fn -replace_append -( -& -mut -self -caps -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -self -. -0 -. -replace_append -( -caps -dst -) -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -str -> -> -{ -self -. -0 -. -no_expansion -( -) -} -} -/ -/ -/ -A -helper -type -for -forcing -literal -string -replacement -. -/ -/ -/ -/ -/ -/ -It -can -be -used -with -routines -like -[ -Regex -: -: -replace -] -and -/ -/ -/ -[ -Regex -: -: -replace_all -] -to -do -a -literal -string -replacement -without -expanding -/ -/ -/ -name -to -their -corresponding -capture -groups -. -This -can -be -both -convenient -/ -/ -/ -( -to -avoid -escaping -for -example -) -and -faster -( -since -capture -groups -/ -/ -/ -don -' -t -need -to -be -found -) -. -/ -/ -/ -/ -/ -/ -' -s -is -the -lifetime -of -the -literal -string -to -use -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -{ -NoExpand -Regex -} -; -/ -/ -/ -/ -/ -/ -let -re -= -Regex -: -: -new -( -r -" -( -? -< -last -> -[ -^ -\ -s -] -+ -) -\ -s -+ -( -\ -S -+ -) -" -) -. -unwrap -( -) -; -/ -/ -/ -let -result -= -re -. -replace -( -" -Springsteen -Bruce -" -NoExpand -( -" -2 -last -" -) -) -; -/ -/ -/ -assert_eq -! -( -result -" -2 -last -" -) -; -/ -/ -/ -# -[ -derive -( -Clone -Debug -) -] -pub -struct -NoExpand -< -' -s -> -( -pub -& -' -s -str -) -; -impl -< -' -s -> -Replacer -for -NoExpand -< -' -s -> -{ -fn -replace_append -( -& -mut -self -_ -: -& -Captures -< -' -_ -> -dst -: -& -mut -String -) -{ -dst -. -push_str -( -self -. -0 -) -; -} -fn -no_expansion -( -& -mut -self -) -- -> -Option -< -Cow -< -' -_ -str -> -> -{ -Some -( -Cow -: -: -Borrowed -( -self -. -0 -) -) -} -} -/ -/ -/ -Quickly -checks -the -given -replacement -string -for -whether -interpolation -/ -/ -/ -should -be -done -on -it -. -It -returns -None -if -a -was -found -anywhere -in -the -/ -/ -/ -given -string -which -suggests -interpolation -needs -to -be -done -. -But -if -there -' -s -/ -/ -/ -no -anywhere -then -interpolation -definitely -does -not -need -to -be -done -. -In -/ -/ -/ -that -case -the -given -string -is -returned -as -a -borrowed -Cow -. -/ -/ -/ -/ -/ -/ -This -is -meant -to -be -used -to -implement -the -Replacer -: -: -no_expandsion -method -/ -/ -/ -in -its -various -trait -impls -. -fn -no_expansion -< -T -: -AsRef -< -str -> -> -( -replacement -: -& -T -) -- -> -Option -< -Cow -< -' -_ -str -> -> -{ -let -replacement -= -replacement -. -as_ref -( -) -; -match -crate -: -: -find_byte -: -: -find_byte -( -b -' -' -replacement -. -as_bytes -( -) -) -{ -Some -( -_ -) -= -> -None -None -= -> -Some -( -Cow -: -: -Borrowed -( -replacement -) -) -} -} diff --git a/third_party/rust/regex/src/regexset/bytes.rs b/third_party/rust/regex/src/regexset/bytes.rs deleted file mode 100644 index 9d54bccb96006..0000000000000 --- a/third_party/rust/regex/src/regexset/bytes.rs +++ /dev/null @@ -1,6845 +0,0 @@ -use -alloc -: -: -string -: -: -String -; -use -regex_automata -: -: -{ -meta -Input -PatternID -PatternSet -PatternSetIter -} -; -use -crate -: -: -{ -bytes -: -: -RegexSetBuilder -Error -} -; -/ -/ -/ -Match -multiple -possibly -overlapping -regexes -in -a -single -search -. -/ -/ -/ -/ -/ -/ -A -regex -set -corresponds -to -the -union -of -zero -or -more -regular -expressions -. -/ -/ -/ -That -is -a -regex -set -will -match -a -haystack -when -at -least -one -of -its -/ -/ -/ -constituent -regexes -matches -. -A -regex -set -as -its -formulated -here -provides -a -/ -/ -/ -touch -more -power -: -it -will -also -report -* -which -* -regular -expressions -in -the -/ -/ -/ -set -match -. -Indeed -this -is -the -key -difference -between -regex -sets -and -a -/ -/ -/ -single -Regex -with -many -alternates -since -only -one -alternate -can -match -at -/ -/ -/ -a -time -. -/ -/ -/ -/ -/ -/ -For -example -consider -regular -expressions -to -match -email -addresses -and -/ -/ -/ -domains -: -[ -a -- -z -] -+ -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -and -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -. -If -a -/ -/ -/ -regex -set -is -constructed -from -those -regexes -then -searching -the -haystack -/ -/ -/ -foo -example -. -com -will -report -both -regexes -as -matching -. -Of -course -one -/ -/ -/ -could -accomplish -this -by -compiling -each -regex -on -its -own -and -doing -two -/ -/ -/ -searches -over -the -haystack -. -The -key -advantage -of -using -a -regex -set -is -/ -/ -/ -that -it -will -report -the -matching -regexes -using -a -* -single -pass -through -the -/ -/ -/ -haystack -* -. -If -one -has -hundreds -or -thousands -of -regexes -to -match -repeatedly -/ -/ -/ -( -like -a -URL -router -for -a -complex -web -application -or -a -user -agent -matcher -) -/ -/ -/ -then -a -regex -set -* -can -* -realize -huge -performance -gains -. -/ -/ -/ -/ -/ -/ -Unlike -the -top -- -level -[ -RegexSet -] -( -crate -: -: -RegexSet -) -this -RegexSet -/ -/ -/ -searches -haystacks -with -type -& -[ -u8 -] -instead -of -& -str -. -Consequently -this -/ -/ -/ -RegexSet -is -permitted -to -match -invalid -UTF -- -8 -. -/ -/ -/ -/ -/ -/ -# -Limitations -/ -/ -/ -/ -/ -/ -Regex -sets -are -limited -to -answering -the -following -two -questions -: -/ -/ -/ -/ -/ -/ -1 -. -Does -any -regex -in -the -set -match -? -/ -/ -/ -2 -. -If -so -which -regexes -in -the -set -match -? -/ -/ -/ -/ -/ -/ -As -with -the -main -[ -Regex -] -[ -crate -: -: -bytes -: -: -Regex -] -type -it -is -cheaper -to -ask -/ -/ -/ -( -1 -) -instead -of -( -2 -) -since -the -matching -engines -can -stop -after -the -first -/ -/ -/ -match -is -found -. -/ -/ -/ -/ -/ -/ -You -cannot -directly -extract -[ -Match -] -[ -crate -: -: -bytes -: -: -Match -] -or -/ -/ -/ -[ -Captures -] -[ -crate -: -: -bytes -: -: -Captures -] -objects -from -a -regex -set -. -If -you -need -/ -/ -/ -these -operations -the -recommended -approach -is -to -compile -each -pattern -in -/ -/ -/ -the -set -independently -and -scan -the -exact -same -haystack -a -second -time -with -/ -/ -/ -those -independently -compiled -patterns -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -{ -Regex -RegexSet -} -; -/ -/ -/ -/ -/ -/ -let -patterns -= -[ -" -foo -" -" -bar -" -] -; -/ -/ -/ -/ -/ -Both -patterns -will -match -different -ranges -of -this -string -. -/ -/ -/ -let -hay -= -b -" -barfoo -" -; -/ -/ -/ -/ -/ -/ -/ -/ -Compile -a -set -matching -any -of -our -patterns -. -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -patterns -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -Compile -each -pattern -independently -. -/ -/ -/ -let -regexes -: -Vec -< -_ -> -= -set -/ -/ -/ -. -patterns -( -) -/ -/ -/ -. -iter -( -) -/ -/ -/ -. -map -( -| -pat -| -Regex -: -: -new -( -pat -) -. -unwrap -( -) -) -/ -/ -/ -. -collect -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Match -against -the -whole -set -first -and -identify -the -individual -/ -/ -/ -/ -/ -matching -patterns -. -/ -/ -/ -let -matches -: -Vec -< -& -[ -u8 -] -> -= -set -/ -/ -/ -. -matches -( -hay -) -/ -/ -/ -. -into_iter -( -) -/ -/ -/ -/ -/ -Dereference -the -match -index -to -get -the -corresponding -/ -/ -/ -/ -/ -compiled -pattern -. -/ -/ -/ -. -map -( -| -index -| -& -regexes -[ -index -] -) -/ -/ -/ -/ -/ -To -get -match -locations -or -any -other -info -we -then -have -to -search -the -/ -/ -/ -/ -/ -exact -same -haystack -again -using -our -separately -- -compiled -pattern -. -/ -/ -/ -. -map -( -| -re -| -re -. -find -( -hay -) -. -unwrap -( -) -. -as_bytes -( -) -) -/ -/ -/ -. -collect -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Matches -arrive -in -the -order -the -constituent -patterns -were -declared -/ -/ -/ -/ -/ -not -the -order -they -appear -in -the -haystack -. -/ -/ -/ -assert_eq -! -( -vec -! -[ -& -b -" -foo -" -[ -. -. -] -& -b -" -bar -" -[ -. -. -] -] -matches -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -# -Performance -/ -/ -/ -/ -/ -/ -A -RegexSet -has -the -same -performance -characteristics -as -Regex -. -Namely -/ -/ -/ -search -takes -O -( -m -* -n -) -time -where -m -is -proportional -to -the -size -of -the -/ -/ -/ -regex -set -and -n -is -proportional -to -the -length -of -the -haystack -. -/ -/ -/ -/ -/ -/ -# -Trait -implementations -/ -/ -/ -/ -/ -/ -The -Default -trait -is -implemented -for -RegexSet -. -The -default -value -/ -/ -/ -is -an -empty -set -. -An -empty -set -can -also -be -explicitly -constructed -via -/ -/ -/ -[ -RegexSet -: -: -empty -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -shows -how -the -above -two -regexes -( -for -matching -email -addresses -and -/ -/ -/ -domains -) -might -work -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -& -[ -/ -/ -/ -r -" -[ -a -- -z -] -+ -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -r -" -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Ask -whether -any -regexes -in -the -set -match -. -/ -/ -/ -assert -! -( -set -. -is_match -( -b -" -foo -example -. -com -" -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Identify -which -regexes -in -the -set -match -. -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches -( -b -" -foo -example -. -com -" -) -. -into_iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -vec -! -[ -0 -1 -] -matches -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Try -again -but -with -a -haystack -that -only -matches -one -of -the -regexes -. -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches -( -b -" -example -. -com -" -) -. -into_iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -vec -! -[ -1 -] -matches -) -; -/ -/ -/ -/ -/ -/ -/ -/ -Try -again -but -with -a -haystack -that -doesn -' -t -match -any -regex -in -the -set -. -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches -( -b -" -example -" -) -. -into_iter -( -) -. -collect -( -) -; -/ -/ -/ -assert -! -( -matches -. -is_empty -( -) -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -it -would -be -possible -to -adapt -the -above -example -to -using -Regex -/ -/ -/ -with -an -expression -like -: -/ -/ -/ -/ -/ -/ -text -/ -/ -/ -( -? -P -< -email -> -[ -a -- -z -] -+ -( -? -P -< -email_domain -> -[ -a -- -z -] -+ -[ -. -] -( -com -| -org -| -net -) -) -) -| -( -? -P -< -domain -> -[ -a -- -z -] -+ -[ -. -] -( -com -| -org -| -net -) -) -/ -/ -/ -/ -/ -/ -/ -/ -/ -After -a -match -one -could -then -inspect -the -capture -groups -to -figure -out -/ -/ -/ -which -alternates -matched -. -The -problem -is -that -it -is -hard -to -make -this -/ -/ -/ -approach -scale -when -there -are -many -regexes -since -the -overlap -between -each -/ -/ -/ -alternate -isn -' -t -always -obvious -to -reason -about -. -# -[ -derive -( -Clone -) -] -pub -struct -RegexSet -{ -pub -( -crate -) -meta -: -meta -: -: -Regex -pub -( -crate -) -patterns -: -alloc -: -: -sync -: -: -Arc -< -[ -String -] -> -} -impl -RegexSet -{ -/ -/ -/ -Create -a -new -regex -set -with -the -given -regular -expressions -. -/ -/ -/ -/ -/ -/ -This -takes -an -iterator -of -S -where -S -is -something -that -can -produce -/ -/ -/ -a -& -str -. -If -any -of -the -strings -in -the -iterator -are -not -valid -regular -/ -/ -/ -expressions -then -an -error -is -returned -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Create -a -new -regex -set -from -an -iterator -of -strings -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -r -" -\ -w -+ -" -r -" -\ -d -+ -" -] -) -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -set -. -is_match -( -b -" -foo -" -) -) -; -/ -/ -/ -pub -fn -new -< -I -S -> -( -exprs -: -I -) -- -> -Result -< -RegexSet -Error -> -where -S -: -AsRef -< -str -> -I -: -IntoIterator -< -Item -= -S -> -{ -RegexSetBuilder -: -: -new -( -exprs -) -. -build -( -) -} -/ -/ -/ -Create -a -new -empty -regex -set -. -/ -/ -/ -/ -/ -/ -An -empty -regex -never -matches -anything -. -/ -/ -/ -/ -/ -/ -This -is -a -convenience -function -for -RegexSet -: -: -new -( -[ -] -) -but -doesn -' -t -/ -/ -/ -require -one -to -specify -the -type -of -the -input -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -empty -( -) -; -/ -/ -/ -assert -! -( -set -. -is_empty -( -) -) -; -/ -/ -/ -/ -/ -an -empty -set -matches -nothing -/ -/ -/ -assert -! -( -! -set -. -is_match -( -b -" -" -) -) -; -/ -/ -/ -pub -fn -empty -( -) -- -> -RegexSet -{ -let -empty -: -[ -& -str -; -0 -] -= -[ -] -; -RegexSetBuilder -: -: -new -( -empty -) -. -build -( -) -. -unwrap -( -) -} -/ -/ -/ -Returns -true -if -and -only -if -one -of -the -regexes -in -this -set -matches -/ -/ -/ -the -haystack -given -. -/ -/ -/ -/ -/ -/ -This -method -should -be -preferred -if -you -only -need -to -test -whether -any -/ -/ -/ -of -the -regexes -in -the -set -should -match -but -don -' -t -care -about -* -which -* -/ -/ -/ -regexes -matched -. -This -is -because -the -underlying -matching -engine -will -/ -/ -/ -quit -immediately -after -seeing -the -first -match -instead -of -continuing -to -/ -/ -/ -find -all -matches -. -/ -/ -/ -/ -/ -/ -Note -that -as -with -searches -using -[ -Regex -] -( -crate -: -: -bytes -: -: -Regex -) -the -/ -/ -/ -expression -is -unanchored -by -default -. -That -is -if -the -regex -does -not -/ -/ -/ -start -with -^ -or -\ -A -or -end -with -or -\ -z -then -it -is -permitted -/ -/ -/ -to -match -anywhere -in -the -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Tests -whether -a -set -matches -somewhere -in -a -haystack -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -r -" -\ -w -+ -" -r -" -\ -d -+ -" -] -) -. -unwrap -( -) -; -/ -/ -/ -assert -! -( -set -. -is_match -( -b -" -foo -" -) -) -; -/ -/ -/ -assert -! -( -! -set -. -is_match -( -" -" -. -as_bytes -( -) -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_match -( -& -self -haystack -: -& -[ -u8 -] -) -- -> -bool -{ -self -. -is_match_at -( -haystack -0 -) -} -/ -/ -/ -Returns -true -if -and -only -if -one -of -the -regexes -in -this -set -matches -the -/ -/ -/ -haystack -given -with -the -search -starting -at -the -offset -given -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -This -example -shows -the -significance -of -start -. -Namely -consider -a -/ -/ -/ -haystack -foobar -and -a -desire -to -execute -a -search -starting -at -offset -/ -/ -/ -3 -. -You -could -search -a -substring -explicitly -but -then -the -look -- -around -/ -/ -/ -assertions -won -' -t -work -correctly -. -Instead -you -can -use -this -method -to -/ -/ -/ -specify -the -start -position -of -a -search -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -r -" -\ -bbar -\ -b -" -r -" -( -? -m -) -^ -bar -" -] -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -foobar -" -; -/ -/ -/ -/ -/ -We -get -a -match -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -assert -! -( -set -. -is_match -( -& -hay -[ -3 -. -. -] -) -) -; -/ -/ -/ -/ -/ -No -match -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -assert -! -( -! -set -. -is_match_at -( -hay -3 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_match_at -( -& -self -haystack -: -& -[ -u8 -] -start -: -usize -) -- -> -bool -{ -self -. -meta -. -is_match -( -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -) -} -/ -/ -/ -Returns -the -set -of -regexes -that -match -in -the -given -haystack -. -/ -/ -/ -/ -/ -/ -The -set -returned -contains -the -index -of -each -regex -that -matches -in -/ -/ -/ -the -given -haystack -. -The -index -is -in -correspondence -with -the -order -of -/ -/ -/ -regular -expressions -given -to -RegexSet -' -s -constructor -. -/ -/ -/ -/ -/ -/ -The -set -can -also -be -used -to -iterate -over -the -matched -indices -. -The -order -/ -/ -/ -of -iteration -is -always -ascending -with -respect -to -the -matching -indices -. -/ -/ -/ -/ -/ -/ -Note -that -as -with -searches -using -[ -Regex -] -( -crate -: -: -bytes -: -: -Regex -) -the -/ -/ -/ -expression -is -unanchored -by -default -. -That -is -if -the -regex -does -not -/ -/ -/ -start -with -^ -or -\ -A -or -end -with -or -\ -z -then -it -is -permitted -/ -/ -/ -to -match -anywhere -in -the -haystack -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Tests -which -regular -expressions -match -the -given -haystack -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -\ -w -+ -" -/ -/ -/ -r -" -\ -d -+ -" -/ -/ -/ -r -" -\ -pL -+ -" -/ -/ -/ -r -" -foo -" -/ -/ -/ -r -" -bar -" -/ -/ -/ -r -" -barfoo -" -/ -/ -/ -r -" -foobar -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches -( -b -" -foobar -" -) -. -into_iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -0 -2 -3 -4 -6 -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -You -can -also -test -whether -a -particular -regex -matched -: -/ -/ -/ -let -matches -= -set -. -matches -( -b -" -foobar -" -) -; -/ -/ -/ -assert -! -( -! -matches -. -matched -( -5 -) -) -; -/ -/ -/ -assert -! -( -matches -. -matched -( -6 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -matches -( -& -self -haystack -: -& -[ -u8 -] -) -- -> -SetMatches -{ -self -. -matches_at -( -haystack -0 -) -} -/ -/ -/ -Returns -the -set -of -regexes -that -match -in -the -given -haystack -. -/ -/ -/ -/ -/ -/ -The -set -returned -contains -the -index -of -each -regex -that -matches -in -/ -/ -/ -the -given -haystack -. -The -index -is -in -correspondence -with -the -order -of -/ -/ -/ -regular -expressions -given -to -RegexSet -' -s -constructor -. -/ -/ -/ -/ -/ -/ -The -set -can -also -be -used -to -iterate -over -the -matched -indices -. -The -order -/ -/ -/ -of -iteration -is -always -ascending -with -respect -to -the -matching -indices -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -This -panics -when -start -> -= -haystack -. -len -( -) -+ -1 -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Tests -which -regular -expressions -match -the -given -haystack -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -r -" -\ -bbar -\ -b -" -r -" -( -? -m -) -^ -bar -" -] -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -b -" -foobar -" -; -/ -/ -/ -/ -/ -We -get -matches -here -but -it -' -s -probably -not -intended -. -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches -( -& -hay -[ -3 -. -. -] -) -. -into_iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -0 -1 -] -) -; -/ -/ -/ -/ -/ -No -matches -because -the -assertions -take -the -context -into -account -. -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches_at -( -hay -3 -) -. -into_iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -matches_at -( -& -self -haystack -: -& -[ -u8 -] -start -: -usize -) -- -> -SetMatches -{ -let -input -= -Input -: -: -new -( -haystack -) -. -span -( -start -. -. -haystack -. -len -( -) -) -; -let -mut -patset -= -PatternSet -: -: -new -( -self -. -meta -. -pattern_len -( -) -) -; -self -. -meta -. -which_overlapping_matches -( -& -input -& -mut -patset -) -; -SetMatches -( -patset -) -} -/ -/ -/ -Returns -the -same -as -matches -but -starts -the -search -at -the -given -/ -/ -/ -offset -and -stores -the -matches -into -the -slice -given -. -/ -/ -/ -/ -/ -/ -The -significance -of -the -starting -point -is -that -it -takes -the -surrounding -/ -/ -/ -context -into -consideration -. -For -example -the -\ -A -anchor -can -only -/ -/ -/ -match -when -start -= -= -0 -. -/ -/ -/ -/ -/ -/ -matches -must -have -a -length -that -is -at -least -the -number -of -regexes -/ -/ -/ -in -this -set -. -/ -/ -/ -/ -/ -/ -This -method -returns -true -if -and -only -if -at -least -one -member -of -/ -/ -/ -matches -is -true -after -executing -the -set -against -haystack -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -matches_read_at -( -& -self -matches -: -& -mut -[ -bool -] -haystack -: -& -[ -u8 -] -start -: -usize -) -- -> -bool -{ -/ -/ -This -is -pretty -dumb -. -We -should -try -to -fix -this -but -the -/ -/ -regex -- -automata -API -doesn -' -t -provide -a -way -to -store -matches -in -an -/ -/ -arbitrary -& -mut -[ -bool -] -. -Thankfully -this -API -is -is -doc -( -hidden -) -and -/ -/ -thus -not -public -. -. -. -But -regex -- -capi -currently -uses -it -. -We -should -/ -/ -fix -regex -- -capi -to -use -a -PatternSet -maybe -? -Not -sure -. -. -. -PatternSet -/ -/ -is -in -regex -- -automata -not -regex -. -So -maybe -we -should -just -accept -a -/ -/ -' -SetMatches -' -which -is -basically -just -a -newtype -around -PatternSet -. -let -mut -patset -= -PatternSet -: -: -new -( -self -. -meta -. -pattern_len -( -) -) -; -let -mut -input -= -Input -: -: -new -( -haystack -) -; -input -. -set_start -( -start -) -; -self -. -meta -. -which_overlapping_matches -( -& -input -& -mut -patset -) -; -for -pid -in -patset -. -iter -( -) -{ -matches -[ -pid -] -= -true -; -} -! -patset -. -is_empty -( -) -} -/ -/ -/ -An -alias -for -matches_read_at -to -preserve -backward -compatibility -. -/ -/ -/ -/ -/ -/ -The -regex -- -capi -crate -used -this -method -so -to -avoid -breaking -that -/ -/ -/ -crate -we -continue -to -export -it -as -an -undocumented -API -. -# -[ -doc -( -hidden -) -] -# -[ -inline -] -pub -fn -read_matches_at -( -& -self -matches -: -& -mut -[ -bool -] -haystack -: -& -[ -u8 -] -start -: -usize -) -- -> -bool -{ -self -. -matches_read_at -( -matches -haystack -start -) -} -/ -/ -/ -Returns -the -total -number -of -regexes -in -this -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -assert_eq -! -( -0 -RegexSet -: -: -empty -( -) -. -len -( -) -) -; -/ -/ -/ -assert_eq -! -( -1 -RegexSet -: -: -new -( -[ -r -" -[ -0 -- -9 -] -" -] -) -. -unwrap -( -) -. -len -( -) -) -; -/ -/ -/ -assert_eq -! -( -2 -RegexSet -: -: -new -( -[ -r -" -[ -0 -- -9 -] -" -r -" -[ -a -- -z -] -" -] -) -. -unwrap -( -) -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -meta -. -pattern_len -( -) -} -/ -/ -/ -Returns -true -if -this -set -contains -no -regexes -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -assert -! -( -RegexSet -: -: -empty -( -) -. -is_empty -( -) -) -; -/ -/ -/ -assert -! -( -! -RegexSet -: -: -new -( -[ -r -" -[ -0 -- -9 -] -" -] -) -. -unwrap -( -) -. -is_empty -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -is_empty -( -& -self -) -- -> -bool -{ -self -. -meta -. -pattern_len -( -) -= -= -0 -} -/ -/ -/ -Returns -the -regex -patterns -that -this -regex -set -was -constructed -from -. -/ -/ -/ -/ -/ -/ -This -function -can -be -used -to -determine -the -pattern -for -a -match -. -The -/ -/ -/ -slice -returned -has -exactly -as -many -patterns -givens -to -this -regex -set -/ -/ -/ -and -the -order -of -the -slice -is -the -same -as -the -order -of -the -patterns -/ -/ -/ -provided -to -the -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -& -[ -/ -/ -/ -r -" -\ -w -+ -" -/ -/ -/ -r -" -\ -d -+ -" -/ -/ -/ -r -" -\ -pL -+ -" -/ -/ -/ -r -" -foo -" -/ -/ -/ -r -" -bar -" -/ -/ -/ -r -" -barfoo -" -/ -/ -/ -r -" -foobar -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -/ -/ -/ -. -matches -( -b -" -foobar -" -) -/ -/ -/ -. -into_iter -( -) -/ -/ -/ -. -map -( -| -index -| -& -set -. -patterns -( -) -[ -index -] -) -/ -/ -/ -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -r -" -\ -w -+ -" -r -" -\ -pL -+ -" -r -" -foo -" -r -" -bar -" -r -" -foobar -" -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -patterns -( -& -self -) -- -> -& -[ -String -] -{ -& -self -. -patterns -} -} -impl -Default -for -RegexSet -{ -fn -default -( -) -- -> -Self -{ -RegexSet -: -: -empty -( -) -} -} -/ -/ -/ -A -set -of -matches -returned -by -a -regex -set -. -/ -/ -/ -/ -/ -/ -Values -of -this -type -are -constructed -by -[ -RegexSet -: -: -matches -] -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -SetMatches -( -PatternSet -) -; -impl -SetMatches -{ -/ -/ -/ -Whether -this -set -contains -any -matches -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -& -[ -/ -/ -/ -r -" -[ -a -- -z -] -+ -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -r -" -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -= -set -. -matches -( -b -" -foo -example -. -com -" -) -; -/ -/ -/ -assert -! -( -matches -. -matched_any -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -matched_any -( -& -self -) -- -> -bool -{ -! -self -. -0 -. -is_empty -( -) -} -/ -/ -/ -Whether -the -regex -at -the -given -index -matched -. -/ -/ -/ -/ -/ -/ -The -index -for -a -regex -is -determined -by -its -insertion -order -upon -the -/ -/ -/ -initial -construction -of -a -RegexSet -starting -at -0 -. -/ -/ -/ -/ -/ -/ -# -Panics -/ -/ -/ -/ -/ -/ -If -index -is -greater -than -or -equal -to -the -number -of -regexes -in -the -/ -/ -/ -original -set -that -produced -these -matches -. -Equivalently -when -index -/ -/ -/ -is -greater -than -or -equal -to -[ -SetMatches -: -: -len -] -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -[ -a -- -z -] -+ -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -r -" -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -= -set -. -matches -( -b -" -example -. -com -" -) -; -/ -/ -/ -assert -! -( -! -matches -. -matched -( -0 -) -) -; -/ -/ -/ -assert -! -( -matches -. -matched -( -1 -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -matched -( -& -self -index -: -usize -) -- -> -bool -{ -self -. -0 -. -contains -( -PatternID -: -: -new_unchecked -( -index -) -) -} -/ -/ -/ -The -total -number -of -regexes -in -the -set -that -created -these -matches -. -/ -/ -/ -/ -/ -/ -* -* -WARNING -: -* -* -This -always -returns -the -same -value -as -[ -RegexSet -: -: -len -] -. -/ -/ -/ -In -particular -it -does -* -not -* -return -the -number -of -elements -yielded -by -/ -/ -/ -[ -SetMatches -: -: -iter -] -. -The -only -way -to -determine -the -total -number -of -/ -/ -/ -matched -regexes -is -to -iterate -over -them -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -Notice -that -this -method -returns -the -total -number -of -regexes -in -the -/ -/ -/ -original -set -and -* -not -* -the -total -number -of -regexes -that -matched -. -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -[ -a -- -z -] -+ -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -r -" -[ -a -- -z -] -+ -\ -. -( -com -| -org -| -net -) -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -matches -= -set -. -matches -( -b -" -example -. -com -" -) -; -/ -/ -/ -/ -/ -Total -number -of -patterns -that -matched -. -/ -/ -/ -assert_eq -! -( -1 -matches -. -iter -( -) -. -count -( -) -) -; -/ -/ -/ -/ -/ -Total -number -of -patterns -in -the -set -. -/ -/ -/ -assert_eq -! -( -2 -matches -. -len -( -) -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -len -( -& -self -) -- -> -usize -{ -self -. -0 -. -capacity -( -) -} -/ -/ -/ -Returns -an -iterator -over -the -indices -of -the -regexes -that -matched -. -/ -/ -/ -/ -/ -/ -This -will -always -produces -matches -in -ascending -order -where -the -index -/ -/ -/ -yielded -corresponds -to -the -index -of -the -regex -that -matched -with -respect -/ -/ -/ -to -its -position -when -initially -building -the -set -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -[ -0 -- -9 -] -" -/ -/ -/ -r -" -[ -a -- -z -] -" -/ -/ -/ -r -" -[ -A -- -Z -] -" -/ -/ -/ -r -" -\ -p -{ -Greek -} -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -a1 -" -. -as_bytes -( -) -; -/ -/ -/ -let -matches -: -Vec -< -_ -> -= -set -. -matches -( -hay -) -. -iter -( -) -. -collect -( -) -; -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -0 -1 -3 -] -) -; -/ -/ -/ -/ -/ -/ -/ -/ -/ -Note -that -SetMatches -also -implemnets -the -IntoIterator -trait -so -/ -/ -/ -this -method -is -not -always -needed -. -For -example -: -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -[ -0 -- -9 -] -" -/ -/ -/ -r -" -[ -a -- -z -] -" -/ -/ -/ -r -" -[ -A -- -Z -] -" -/ -/ -/ -r -" -\ -p -{ -Greek -} -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -a1 -" -. -as_bytes -( -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -for -index -in -set -. -matches -( -hay -) -{ -/ -/ -/ -matches -. -push -( -index -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -0 -1 -3 -] -) -; -/ -/ -/ -# -[ -inline -] -pub -fn -iter -( -& -self -) -- -> -SetMatchesIter -< -' -_ -> -{ -SetMatchesIter -( -self -. -0 -. -iter -( -) -) -} -} -impl -IntoIterator -for -SetMatches -{ -type -IntoIter -= -SetMatchesIntoIter -; -type -Item -= -usize -; -fn -into_iter -( -self -) -- -> -Self -: -: -IntoIter -{ -let -it -= -0 -. -. -self -. -0 -. -capacity -( -) -; -SetMatchesIntoIter -{ -patset -: -self -. -0 -it -} -} -} -impl -< -' -a -> -IntoIterator -for -& -' -a -SetMatches -{ -type -IntoIter -= -SetMatchesIter -< -' -a -> -; -type -Item -= -usize -; -fn -into_iter -( -self -) -- -> -Self -: -: -IntoIter -{ -self -. -iter -( -) -} -} -/ -/ -/ -An -owned -iterator -over -the -set -of -matches -from -a -regex -set -. -/ -/ -/ -/ -/ -/ -This -will -always -produces -matches -in -ascending -order -of -index -where -the -/ -/ -/ -index -corresponds -to -the -index -of -the -regex -that -matched -with -respect -to -/ -/ -/ -its -position -when -initially -building -the -set -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -calling -SetMatches -: -: -into_iter -via -the -/ -/ -/ -IntoIterator -trait -. -This -is -automatically -done -in -for -loops -. -/ -/ -/ -/ -/ -/ -# -Example -/ -/ -/ -/ -/ -/ -/ -/ -/ -use -regex -: -: -bytes -: -: -RegexSet -; -/ -/ -/ -/ -/ -/ -let -set -= -RegexSet -: -: -new -( -[ -/ -/ -/ -r -" -[ -0 -- -9 -] -" -/ -/ -/ -r -" -[ -a -- -z -] -" -/ -/ -/ -r -" -[ -A -- -Z -] -" -/ -/ -/ -r -" -\ -p -{ -Greek -} -" -/ -/ -/ -] -) -. -unwrap -( -) -; -/ -/ -/ -let -hay -= -" -a1 -" -. -as_bytes -( -) -; -/ -/ -/ -let -mut -matches -= -vec -! -[ -] -; -/ -/ -/ -for -index -in -set -. -matches -( -hay -) -{ -/ -/ -/ -matches -. -push -( -index -) -; -/ -/ -/ -} -/ -/ -/ -assert_eq -! -( -matches -vec -! -[ -0 -1 -3 -] -) -; -/ -/ -/ -# -[ -derive -( -Debug -) -] -pub -struct -SetMatchesIntoIter -{ -patset -: -PatternSet -it -: -core -: -: -ops -: -: -Range -< -usize -> -} -impl -Iterator -for -SetMatchesIntoIter -{ -type -Item -= -usize -; -fn -next -( -& -mut -self -) -- -> -Option -< -usize -> -{ -loop -{ -let -id -= -self -. -it -. -next -( -) -? -; -if -self -. -patset -. -contains -( -PatternID -: -: -new_unchecked -( -id -) -) -{ -return -Some -( -id -) -; -} -} -} -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -it -. -size_hint -( -) -} -} -impl -DoubleEndedIterator -for -SetMatchesIntoIter -{ -fn -next_back -( -& -mut -self -) -- -> -Option -< -usize -> -{ -loop -{ -let -id -= -self -. -it -. -next_back -( -) -? -; -if -self -. -patset -. -contains -( -PatternID -: -: -new_unchecked -( -id -) -) -{ -return -Some -( -id -) -; -} -} -} -} -impl -core -: -: -iter -: -: -FusedIterator -for -SetMatchesIntoIter -{ -} -/ -/ -/ -A -borrowed -iterator -over -the -set -of -matches -from -a -regex -set -. -/ -/ -/ -/ -/ -/ -The -lifetime -' -a -refers -to -the -lifetime -of -the -[ -SetMatches -] -value -that -/ -/ -/ -created -this -iterator -. -/ -/ -/ -/ -/ -/ -This -will -always -produces -matches -in -ascending -order -where -the -index -/ -/ -/ -corresponds -to -the -index -of -the -regex -that -matched -with -respect -to -its -/ -/ -/ -position -when -initially -building -the -set -. -/ -/ -/ -/ -/ -/ -This -iterator -is -created -by -the -[ -SetMatches -: -: -iter -] -method -. -# -[ -derive -( -Clone -Debug -) -] -pub -struct -SetMatchesIter -< -' -a -> -( -PatternSetIter -< -' -a -> -) -; -impl -< -' -a -> -Iterator -for -SetMatchesIter -< -' -a -> -{ -type -Item -= -usize -; -fn -next -( -& -mut -self -) -- -> -Option -< -usize -> -{ -self -. -0 -. -next -( -) -. -map -( -| -pid -| -pid -. -as_usize -( -) -) -} -fn -size_hint -( -& -self -) -- -> -( -usize -Option -< -usize -> -) -{ -self -. -0 -. -size_hint -( -) -} -} -impl -< -' -a -> -DoubleEndedIterator -for -SetMatchesIter -< -' -a -> -{ -fn -next_back -( -& -mut -self -) -- -> -Option -< -usize -> -{ -self -. -0 -. -next_back -( -) -. -map -( -| -pid -| -pid -. -as_usize -( -) -) -} -} -impl -< -' -a -> -core -: -: -iter -: -: -FusedIterator -for -SetMatchesIter -< -' -a -> -{ -} -impl -core -: -: -fmt -: -: -Debug -for -RegexSet -{ -fn -fmt -( -& -self -f -: -& -mut -core -: -: -fmt -: -: -Formatter -< -' -_ -> -) -- -> -core -: -: -fmt -: -: -Result -{ -write -! -( -f -" -RegexSet -( -{ -: -? -} -) -" -self -. -patterns -( -) -) -} -} diff --git a/third_party/rust/regex/src/regexset/mod.rs b/third_party/rust/regex/src/regexset/mod.rs deleted file mode 100644 index a31dfcb1251ab..0000000000000 --- a/third_party/rust/regex/src/regexset/mod.rs +++ /dev/null @@ -1,14 +0,0 @@ -pub -( -crate -) -mod -bytes -; -pub -( -crate -) -mod -string -; diff --git a/third_party/rust/regex/src/sparse.rs b/third_party/rust/regex/src/sparse.rs new file mode 100644 index 0000000000000..f320489f720f1 --- /dev/null +++ b/third_party/rust/regex/src/sparse.rs @@ -0,0 +1,593 @@ +use +std +: +: +fmt +; +use +std +: +: +ops +: +: +Deref +; +use +std +: +: +slice +; +/ +/ +/ +A +sparse +set +used +for +representing +ordered +NFA +states +. +/ +/ +/ +/ +/ +/ +This +supports +constant +time +addition +and +membership +testing +. +Clearing +an +/ +/ +/ +entire +set +can +also +be +done +in +constant +time +. +Iteration +yields +elements +/ +/ +/ +in +the +order +in +which +they +were +inserted +. +/ +/ +/ +/ +/ +/ +The +data +structure +is +based +on +: +https +: +/ +/ +research +. +swtch +. +com +/ +sparse +/ +/ +/ +Note +though +that +we +don +' +t +actually +use +uninitialized +memory +. +We +generally +/ +/ +/ +reuse +allocations +so +the +initial +allocation +cost +is +bareable +. +However +/ +/ +/ +its +other +properties +listed +above +are +extremely +useful +. +# +[ +derive +( +Clone +) +] +pub +struct +SparseSet +{ +/ +/ +/ +Dense +contains +the +instruction +pointers +in +the +order +in +which +they +/ +/ +/ +were +inserted +. +dense +: +Vec +< +usize +> +/ +/ +/ +Sparse +maps +instruction +pointers +to +their +location +in +dense +. +/ +/ +/ +/ +/ +/ +An +instruction +pointer +is +in +the +set +if +and +only +if +/ +/ +/ +sparse +[ +ip +] +< +dense +. +len +( +) +& +& +ip += += +dense +[ +sparse +[ +ip +] +] +. +sparse +: +Box +< +[ +usize +] +> +} +impl +SparseSet +{ +pub +fn +new +( +size +: +usize +) +- +> +SparseSet +{ +SparseSet +{ +dense +: +Vec +: +: +with_capacity +( +size +) +sparse +: +vec +! +[ +0 +; +size +] +. +into_boxed_slice +( +) +} +} +pub +fn +len +( +& +self +) +- +> +usize +{ +self +. +dense +. +len +( +) +} +pub +fn +is_empty +( +& +self +) +- +> +bool +{ +self +. +dense +. +is_empty +( +) +} +pub +fn +capacity +( +& +self +) +- +> +usize +{ +self +. +dense +. +capacity +( +) +} +pub +fn +insert +( +& +mut +self +value +: +usize +) +{ +let +i += +self +. +len +( +) +; +assert +! +( +i +< +self +. +capacity +( +) +) +; +self +. +dense +. +push +( +value +) +; +self +. +sparse +[ +value +] += +i +; +} +pub +fn +contains +( +& +self +value +: +usize +) +- +> +bool +{ +let +i += +self +. +sparse +[ +value +] +; +self +. +dense +. +get +( +i +) += += +Some +( +& +value +) +} +pub +fn +clear +( +& +mut +self +) +{ +self +. +dense +. +clear +( +) +; +} +} +impl +fmt +: +: +Debug +for +SparseSet +{ +fn +fmt +( +& +self +f +: +& +mut +fmt +: +: +Formatter +< +' +_ +> +) +- +> +fmt +: +: +Result +{ +write +! +( +f +" +SparseSet +( +{ +: +? +} +) +" +self +. +dense +) +} +} +impl +Deref +for +SparseSet +{ +type +Target += +[ +usize +] +; +fn +deref +( +& +self +) +- +> +& +Self +: +: +Target +{ +& +self +. +dense +} +} +impl +< +' +a +> +IntoIterator +for +& +' +a +SparseSet +{ +type +Item += +& +' +a +usize +; +type +IntoIter += +slice +: +: +Iter +< +' +a +usize +> +; +fn +into_iter +( +self +) +- +> +Self +: +: +IntoIter +{ +self +. +iter +( +) +} +} diff --git a/third_party/rust/regex-automata/LICENSE-MIT b/third_party/rust/regex/src/testdata/LICENSE similarity index 61% rename from third_party/rust/regex-automata/LICENSE-MIT rename to third_party/rust/regex/src/testdata/LICENSE index 9feccea9c1744..c0dc2bbc7ca3f 100644 --- a/third_party/rust/regex-automata/LICENSE-MIT +++ b/third_party/rust/regex/src/testdata/LICENSE @@ -1,12 +1,16 @@ -Copyright -( -c -) -2014 The -Rust -Project -Developers +following +license +covers +testregex +. +c +and +all +associated +test +data +. Permission is hereby @@ -21,12 +25,9 @@ obtaining a copy of -this -software -and -associated -documentation -files +THIS +SOFTWARE +FILE ( the " @@ -52,7 +53,6 @@ modify merge publish distribute -sublicense and / or @@ -78,106 +78,127 @@ subject to the following -conditions +disclaimer : -The -above -copyright -notice -and -this -permission -notice -shall -be -included -in -all -copies -or -substantial -portions -of -the -Software -. -THE +THIS SOFTWARE IS PROVIDED -" +BY +AT +& +T AS IS -" -WITHOUT -WARRANTY -OF +' +' +AND ANY -KIND EXPRESS OR IMPLIED +WARRANTIES INCLUDING BUT NOT LIMITED TO THE +IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE -AND -NONINFRINGEMENT +ARE +DISCLAIMED . IN NO EVENT SHALL -THE -AUTHORS -OR -COPYRIGHT -HOLDERS +AT +& +T BE LIABLE FOR ANY -CLAIM +DIRECT +INDIRECT +INCIDENTAL +SPECIAL +EXEMPLARY +OR +CONSEQUENTIAL DAMAGES +( +INCLUDING +BUT +NOT +LIMITED +TO +PROCUREMENT +OF +SUBSTITUTE +GOODS +OR +SERVICES +; +LOSS +OF +USE +DATA +OR +PROFITS +; OR -OTHER +BUSINESS +INTERRUPTION +) +HOWEVER +CAUSED +AND +ON +ANY +THEORY +OF LIABILITY WHETHER IN -AN -ACTION -OF CONTRACT +STRICT +LIABILITY +OR TORT +( +INCLUDING +NEGLIGENCE OR OTHERWISE +) ARISING -FROM +IN +ANY +WAY OUT OF -OR -IN -CONNECTION -WITH -THE -SOFTWARE -OR THE USE -OR -OTHER -DEALINGS -IN -THE +OF +THIS SOFTWARE +EVEN +IF +ADVISED +OF +THE +POSSIBILITY +OF +SUCH +DAMAGE . diff --git a/third_party/rust/regex/src/testdata/README b/third_party/rust/regex/src/testdata/README new file mode 100644 index 0000000000000..af1db519e393f --- /dev/null +++ b/third_party/rust/regex/src/testdata/README @@ -0,0 +1,165 @@ +Test +data +was +taken +from +the +Go +distribution +which +was +in +turn +taken +from +the +testregex +test +suite +: +http +: +/ +/ +www2 +. +research +. +att +. +com +/ +~ +astopen +/ +testregex +/ +testregex +. +html +The +LICENSE +in +this +directory +corresponds +to +the +LICENSE +that +the +data +was +released +under +. +The +tests +themselves +were +modified +for +RE2 +/ +Go +. +A +couple +were +modified +further +by +me +( +Andrew +Gallant +) +( +only +in +repetition +. +dat +) +so +that +RE2 +/ +Go +would +pass +them +. +( +Yes +it +seems +like +RE2 +/ +Go +includes +failing +test +cases +. +) +This +may +or +may +not +have +been +a +bad +idea +but +I +think +being +consistent +with +an +established +Regex +library +is +worth +something +. +Note +that +these +files +are +read +by +' +scripts +/ +regex +- +match +- +tests +. +py +' +and +turned +into +Rust +tests +found +in +' +regex_macros +/ +tests +/ +matches +. +rs +' +. diff --git a/third_party/rust/regex/testdata/fowler/dat/basic.dat b/third_party/rust/regex/src/testdata/basic.dat similarity index 93% rename from third_party/rust/regex/testdata/fowler/dat/basic.dat rename to third_party/rust/regex/src/testdata/basic.dat index 48a7eb994cb17..34f03746e1b24 100644 --- a/third_party/rust/regex/testdata/fowler/dat/basic.dat +++ b/third_party/rust/regex/src/testdata/basic.dat @@ -745,6 +745,11 @@ xxabc ) Ei ( +? +- +u +) +( Ab | cD @@ -1052,7 +1057,6 @@ xxx 0 3 ) -# E1 ( ^ @@ -1110,75 +1114,6 @@ feb 0 6 ) -E -( -? -: -^ -| -[ -( -; -] -) -( -? -: -( -? -: -( -? -: -[ -Ff -] -eb -[ -^ -] -* -* -| -0 -* -2 -/ -| -\ -* -* -/ -? -) -0 -* -[ -6 -- -7 -] -) -) -( -? -: -[ -^ -0 -- -9 -] -| -) -feb -6 -( -0 -6 -) -Rust -# E1 ( ^ @@ -1230,421 +1165,72 @@ eb ] | ) -2 -/ -7 -( -0 -3 -) -E -( -? -: -^ -| -[ -( -; -] -) -( -? -: -( -? -: -( -? -: -[ -Ff -] -eb -[ -^ -] -* -* -| -0 -* -2 -/ -| -\ -* -* -/ -? -) -0 -* -[ -6 -- -7 -] -) -) -( -? -: -[ -^ -0 -- -9 -] -| -) -2 -/ -7 -( -0 -3 -) -Rust -# -E1 -( -^ -| -[ -( -; -] -) -( -( -( -[ -Ff -] -eb -[ -^ -] -* -* -| -0 -* -2 -/ -| -\ -* -* -/ -? -) -0 -* -[ -6 -- -7 -] -) -) -( -[ -^ -0 -- -9 -] -| -) -feb -1 -Feb -6 -( -5 -11 -) -E -( -? -: -^ -| -[ -( -; -] -) -( -? -: -( -? -: -( -? -: -[ -Ff -] -eb -[ -^ -] -* -* -| -0 -* -2 -/ -| -\ -* -* -/ -? -) -0 -* -[ -6 -- -7 -] -) -) -( -? -: -[ -^ -0 -- -9 -] -| -) -feb -1 -Feb -6 -( -5 -11 -) -Rust -# -E3 -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -( -x -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -x -( -0 -1 -) -( -0 -1 -) -( -0 -1 -) -E -( -( -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: +2 +/ +7 ( -? -: +0 +3 +) +E1 ( -? -: +^ +| +[ ( -? -: +; +] +) ( -? -: ( -? -: ( +[ +Ff +] +eb +[ +^ +] +* +* +| +0 +* +2 +/ +| +\ +* +* +/ ? -: -x -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) ) +0 +* +[ +6 +- +7 +] ) ) -x ( +[ +^ 0 -1 +- +9 +] +| ) -( -0 +feb 1 -) +Feb +6 ( -0 -1 +5 +11 ) -Rust -# E3 ( ( @@ -1707,107 +1293,50 @@ x ) ) ) -* -xx +x ( 0 -2 +1 ) ( +0 1 -2 ) ( +0 1 -2 ) -E +E3 ( ( ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: ( -? -: x ) ) @@ -1853,7 +1382,6 @@ xx 1 2 ) -Rust E a ? @@ -1919,18 +1447,6 @@ baaabbbabac 7 11 ) -# -BE -. -* -\ -x01 -\ -xff -( -0 -2 -) BE . * @@ -1942,7 +1458,6 @@ x7f 0 2 ) -Rust E aaaa | @@ -2443,6 +1958,7 @@ aaa 0 3 ) +# E ( a @@ -2463,6 +1979,24 @@ E a * ) +* +- +( +0 +0 +) +( +? +? +) +RE2 +/ +Go +E +( +a +* +) + - ( @@ -2473,6 +2007,7 @@ a 0 0 ) +# E ( a @@ -2493,6 +2028,26 @@ b E ( a +* +| +b +) +* +- +( +0 +0 +) +( +? +? +) +RE2 +/ +Go +E +( +a + | b @@ -2552,6 +2107,7 @@ cde 0 3 ) +# E ( ^ @@ -2566,6 +2122,23 @@ E 0 0 ) +E +( +^ +) +* +- +( +0 +0 +) +( +? +? +) +RE2 +/ +Go BE a * @@ -2645,6 +2218,7 @@ ef 0 1 ) +# E ( ( @@ -2668,6 +2242,32 @@ b 0 0 ) +E +( +( +a +* +| +b +) +) +* +- +( +0 +0 +) +( +? +? +) +( +? +? +) +RE2 +/ +Go BE abcd * diff --git a/third_party/rust/regex/testdata/fowler/dat/nullsubexpr.dat b/third_party/rust/regex/src/testdata/nullsubexpr.dat similarity index 92% rename from third_party/rust/regex/testdata/fowler/dat/nullsubexpr.dat rename to third_party/rust/regex/src/testdata/nullsubexpr.dat index 044c701865b39..dbbde424fe6cf 100644 --- a/third_party/rust/regex/testdata/fowler/dat/nullsubexpr.dat +++ b/third_party/rust/regex/src/testdata/nullsubexpr.dat @@ -23,6 +23,7 @@ a 0 1 ) +# E SAME x @@ -36,6 +37,20 @@ x ) E SAME +x +( +0 +0 +) +( +? +? +) +RE2 +/ +Go +E +SAME aaaaaa ( 0 @@ -206,6 +221,7 @@ a 0 1 ) +# E SAME x @@ -219,6 +235,20 @@ x ) E SAME +x +( +0 +0 +) +( +? +? +) +RE2 +/ +Go +E +SAME aaaaaa ( 0 @@ -307,6 +337,7 @@ a 0 1 ) +# E SAME b @@ -320,6 +351,20 @@ b ) E SAME +b +( +0 +0 +) +( +? +? +) +RE2 +/ +Go +E +SAME aaaaaa ( 0 @@ -452,6 +497,7 @@ bbbbbb 0 6 ) +# E SAME aaaaaa @@ -464,6 +510,20 @@ aaaaaa 0 ) E +SAME +aaaaaa +( +0 +0 +) +( +? +? +) +RE2 +/ +Go +E ( [ ^ @@ -481,6 +541,7 @@ ccccxx 0 6 ) +# E SAME ababab @@ -492,26 +553,20 @@ ababab 0 0 ) -# E -( -( -z -) -+ -| -a -) -* -zabcde +SAME +ababab ( 0 -2 +0 ) ( -1 -2 +? +? ) +RE2 +/ +Go E ( ( @@ -531,11 +586,6 @@ zabcde 1 2 ) -( -0 -1 -) -Rust # { E @@ -889,6 +939,7 @@ axxa 2 3 ) +# E ( a @@ -920,6 +971,31 @@ a ( x ) +x +( +0 +1 +) +( +? +? +) +( +0 +1 +) +RE2 +/ +Go +E +( +a +* +) +* +( +x +) ax ( 0 diff --git a/third_party/rust/regex/testdata/fowler/dat/repetition.dat b/third_party/rust/regex/src/testdata/repetition.dat similarity index 94% rename from third_party/rust/regex/testdata/fowler/dat/repetition.dat rename to third_party/rust/regex/src/testdata/repetition.dat index cab8c42778b2e..6c4d2471abb4d 100644 --- a/third_party/rust/regex/testdata/fowler/dat/repetition.dat +++ b/third_party/rust/regex/src/testdata/repetition.dat @@ -2728,42 +2728,6 @@ like 6 ) . -# -: -HA -# -260 -: -E -( -a -| -ab -| -c -| -bcd -) -{ -0 -} -( -d -* -) -ababcd -( -0 -6 -) -( -3 -6 -) -( -6 -6 -) : HA # @@ -2799,43 +2763,6 @@ ababcd 1 1 ) -Rust -# -: -HA -# -261 -: -E -( -a -| -ab -| -c -| -bcd -) -{ -1 -} -( -d -* -) -ababcd -( -0 -6 -) -( -3 -6 -) -( -6 -6 -) : HA # @@ -2871,7 +2798,6 @@ ababcd 1 1 ) -Rust : HA # @@ -2966,43 +2892,6 @@ d ) ababcd NOMATCH -# -: -HA -# -265 -: -E -( -a -| -ab -| -c -| -bcd -) -{ -0 -10 -} -( -d -* -) -ababcd -( -0 -6 -) -( -3 -6 -) -( -6 -6 -) : HA # @@ -3039,44 +2928,6 @@ ababcd 1 1 ) -Rust -# -: -HA -# -266 -: -E -( -a -| -ab -| -c -| -bcd -) -{ -1 -10 -} -( -d -* -) -ababcd -( -0 -6 -) -( -3 -6 -) -( -6 -6 -) : HA # @@ -3113,7 +2964,6 @@ ababcd 1 1 ) -Rust : HA # @@ -3211,40 +3061,6 @@ d ) ababcd NOMATCH -# -: -HA -# -270 -: -E -( -a -| -ab -| -c -| -bcd -) -* -( -d -* -) -ababcd -( -0 -6 -) -( -3 -6 -) -( -6 -6 -) : HA # @@ -3278,41 +3094,6 @@ ababcd 1 1 ) -Rust -# -: -HA -# -271 -: -E -( -a -| -ab -| -c -| -bcd -) -+ -( -d -* -) -ababcd -( -0 -6 -) -( -3 -6 -) -( -6 -6 -) : HA # @@ -3346,7 +3127,6 @@ ababcd 1 1 ) -Rust # The above diff --git a/third_party/rust/regex/src/utf8.rs b/third_party/rust/regex/src/utf8.rs new file mode 100644 index 0000000000000..7fe78272d56b2 --- /dev/null +++ b/third_party/rust/regex/src/utf8.rs @@ -0,0 +1,2076 @@ +/ +/ +/ +A +few +elementary +UTF +- +8 +encoding +and +decoding +functions +used +by +the +matching +/ +/ +/ +engines +. +/ +/ +/ +/ +/ +/ +In +an +ideal +world +the +matching +engines +operate +on +& +str +and +we +can +just +/ +/ +/ +lean +on +the +standard +library +for +all +our +UTF +- +8 +needs +. +However +to +support +/ +/ +/ +byte +based +regexes +( +that +can +match +on +arbitrary +bytes +which +may +contain +/ +/ +/ +UTF +- +8 +) +we +need +to +be +capable +of +searching +and +decoding +UTF +- +8 +on +a +& +[ +u8 +] +. +/ +/ +/ +The +standard +library +doesn +' +t +really +recognize +this +use +case +so +we +have +/ +/ +/ +to +build +it +out +ourselves +. +/ +/ +/ +/ +/ +/ +Should +this +be +factored +out +into +a +separate +crate +? +It +seems +independently +/ +/ +/ +useful +. +There +are +other +crates +that +already +exist +( +e +. +g +. +utf +- +8 +) +that +have +/ +/ +/ +overlapping +use +cases +. +Not +sure +what +to +do +. +use +std +: +: +char +; +const +TAG_CONT +: +u8 += +0b1000_0000 +; +const +TAG_TWO +: +u8 += +0b1100_0000 +; +const +TAG_THREE +: +u8 += +0b1110_0000 +; +const +TAG_FOUR +: +u8 += +0b1111_0000 +; +/ +/ +/ +Returns +the +smallest +possible +index +of +the +next +valid +UTF +- +8 +sequence +/ +/ +/ +starting +after +i +. +pub +fn +next_utf8 +( +text +: +& +[ +u8 +] +i +: +usize +) +- +> +usize +{ +let +b += +match +text +. +get +( +i +) +{ +None += +> +return +i ++ +1 +Some +( +& +b +) += +> +b +} +; +let +inc += +if +b +< += +0x7F +{ +1 +} +else +if +b +< += +0b110_11111 +{ +2 +} +else +if +b +< += +0b1110_1111 +{ +3 +} +else +{ +4 +} +; +i ++ +inc +} +/ +/ +/ +Decode +a +single +UTF +- +8 +sequence +into +a +single +Unicode +codepoint +from +src +. +/ +/ +/ +/ +/ +/ +If +no +valid +UTF +- +8 +sequence +could +be +found +then +None +is +returned +. +/ +/ +/ +Otherwise +the +decoded +codepoint +and +the +number +of +bytes +read +is +returned +. +/ +/ +/ +The +number +of +bytes +read +( +for +a +valid +UTF +- +8 +sequence +) +is +guaranteed +to +be +/ +/ +/ +1 +2 +3 +or +4 +. +/ +/ +/ +/ +/ +/ +Note +that +a +UTF +- +8 +sequence +is +invalid +if +it +is +incorrect +UTF +- +8 +encodes +a +/ +/ +/ +codepoint +that +is +out +of +range +( +surrogate +codepoints +are +out +of +range +) +or +/ +/ +/ +is +not +the +shortest +possible +UTF +- +8 +sequence +for +that +codepoint +. +# +[ +inline +] +pub +fn +decode_utf8 +( +src +: +& +[ +u8 +] +) +- +> +Option +< +( +char +usize +) +> +{ +let +b0 += +match +src +. +get +( +0 +) +{ +None += +> +return +None +Some +( +& +b +) +if +b +< += +0x7F += +> +return +Some +( +( +b +as +char +1 +) +) +Some +( +& +b +) += +> +b +} +; +match +b0 +{ +0b110_00000 +. +. += +0b110_11111 += +> +{ +if +src +. +len +( +) +< +2 +{ +return +None +; +} +let +b1 += +src +[ +1 +] +; +if +0b11_000000 +& +b1 +! += +TAG_CONT +{ +return +None +; +} +let +cp += +( +( +b0 +& +! +TAG_TWO +) +as +u32 +) +< +< +6 +| +( +( +b1 +& +! +TAG_CONT +) +as +u32 +) +; +match +cp +{ +0x80 +. +. += +0x7FF += +> +char +: +: +from_u32 +( +cp +) +. +map +( +| +cp +| +( +cp +2 +) +) +_ += +> +None +} +} +0b1110_0000 +. +. += +0b1110_1111 += +> +{ +if +src +. +len +( +) +< +3 +{ +return +None +; +} +let +( +b1 +b2 +) += +( +src +[ +1 +] +src +[ +2 +] +) +; +if +0b11_000000 +& +b1 +! += +TAG_CONT +{ +return +None +; +} +if +0b11_000000 +& +b2 +! += +TAG_CONT +{ +return +None +; +} +let +cp += +( +( +b0 +& +! +TAG_THREE +) +as +u32 +) +< +< +12 +| +( +( +b1 +& +! +TAG_CONT +) +as +u32 +) +< +< +6 +| +( +( +b2 +& +! +TAG_CONT +) +as +u32 +) +; +match +cp +{ +/ +/ +char +: +: +from_u32 +will +disallow +surrogate +codepoints +. +0x800 +. +. += +0xFFFF += +> +char +: +: +from_u32 +( +cp +) +. +map +( +| +cp +| +( +cp +3 +) +) +_ += +> +None +} +} +0b11110_000 +. +. += +0b11110_111 += +> +{ +if +src +. +len +( +) +< +4 +{ +return +None +; +} +let +( +b1 +b2 +b3 +) += +( +src +[ +1 +] +src +[ +2 +] +src +[ +3 +] +) +; +if +0b11_000000 +& +b1 +! += +TAG_CONT +{ +return +None +; +} +if +0b11_000000 +& +b2 +! += +TAG_CONT +{ +return +None +; +} +if +0b11_000000 +& +b3 +! += +TAG_CONT +{ +return +None +; +} +let +cp += +( +( +b0 +& +! +TAG_FOUR +) +as +u32 +) +< +< +18 +| +( +( +b1 +& +! +TAG_CONT +) +as +u32 +) +< +< +12 +| +( +( +b2 +& +! +TAG_CONT +) +as +u32 +) +< +< +6 +| +( +( +b3 +& +! +TAG_CONT +) +as +u32 +) +; +match +cp +{ +0x10000 +. +. += +0x0010_FFFF += +> +char +: +: +from_u32 +( +cp +) +. +map +( +| +cp +| +( +cp +4 +) +) +_ += +> +None +} +} +_ += +> +None +} +} +/ +/ +/ +Like +decode_utf8 +but +decodes +the +last +UTF +- +8 +sequence +in +src +instead +/ +/ +/ +of +the +first +. +pub +fn +decode_last_utf8 +( +src +: +& +[ +u8 +] +) +- +> +Option +< +( +char +usize +) +> +{ +if +src +. +is_empty +( +) +{ +return +None +; +} +let +mut +start += +src +. +len +( +) +- +1 +; +if +src +[ +start +] +< += +0x7F +{ +return +Some +( +( +src +[ +start +] +as +char +1 +) +) +; +} +while +start +> +src +. +len +( +) +. +saturating_sub +( +4 +) +{ +start +- += +1 +; +if +is_start_byte +( +src +[ +start +] +) +{ +break +; +} +} +match +decode_utf8 +( +& +src +[ +start +. +. +] +) +{ +None += +> +None +Some +( +( +_ +n +) +) +if +n +< +src +. +len +( +) +- +start += +> +None +Some +( +( +cp +n +) +) += +> +Some +( +( +cp +n +) +) +} +} +fn +is_start_byte +( +b +: +u8 +) +- +> +bool +{ +b +& +0b11_000000 +! += +0b1_0000000 +} +# +[ +cfg +( +test +) +] +mod +tests +{ +use +std +: +: +str +; +use +quickcheck +: +: +quickcheck +; +use +super +: +: +{ +decode_last_utf8 +decode_utf8 +TAG_CONT +TAG_FOUR +TAG_THREE +TAG_TWO +} +; +# +[ +test +] +fn +prop_roundtrip +( +) +{ +fn +p +( +given_cp +: +char +) +- +> +bool +{ +let +mut +tmp += +[ +0 +; +4 +] +; +let +encoded_len += +given_cp +. +encode_utf8 +( +& +mut +tmp +) +. +len +( +) +; +let +( +got_cp +got_len +) += +decode_utf8 +( +& +tmp +[ +. +. +encoded_len +] +) +. +unwrap +( +) +; +encoded_len += += +got_len +& +& +given_cp += += +got_cp +} +quickcheck +( +p +as +fn +( +char +) +- +> +bool +) +} +# +[ +test +] +fn +prop_roundtrip_last +( +) +{ +fn +p +( +given_cp +: +char +) +- +> +bool +{ +let +mut +tmp += +[ +0 +; +4 +] +; +let +encoded_len += +given_cp +. +encode_utf8 +( +& +mut +tmp +) +. +len +( +) +; +let +( +got_cp +got_len +) += +decode_last_utf8 +( +& +tmp +[ +. +. +encoded_len +] +) +. +unwrap +( +) +; +encoded_len += += +got_len +& +& +given_cp += += +got_cp +} +quickcheck +( +p +as +fn +( +char +) +- +> +bool +) +} +# +[ +test +] +fn +prop_encode_matches_std +( +) +{ +fn +p +( +cp +: +char +) +- +> +bool +{ +let +mut +got += +[ +0 +; +4 +] +; +let +n += +cp +. +encode_utf8 +( +& +mut +got +) +. +len +( +) +; +let +expected += +cp +. +to_string +( +) +; +& +got +[ +. +. +n +] += += +expected +. +as_bytes +( +) +} +quickcheck +( +p +as +fn +( +char +) +- +> +bool +) +} +# +[ +test +] +fn +prop_decode_matches_std +( +) +{ +fn +p +( +given_cp +: +char +) +- +> +bool +{ +let +mut +tmp += +[ +0 +; +4 +] +; +let +n += +given_cp +. +encode_utf8 +( +& +mut +tmp +) +. +len +( +) +; +let +( +got_cp +_ +) += +decode_utf8 +( +& +tmp +[ +. +. +n +] +) +. +unwrap +( +) +; +let +expected_cp += +str +: +: +from_utf8 +( +& +tmp +[ +. +. +n +] +) +. +unwrap +( +) +. +chars +( +) +. +next +( +) +. +unwrap +( +) +; +got_cp += += +expected_cp +} +quickcheck +( +p +as +fn +( +char +) +- +> +bool +) +} +# +[ +test +] +fn +prop_decode_last_matches_std +( +) +{ +fn +p +( +given_cp +: +char +) +- +> +bool +{ +let +mut +tmp += +[ +0 +; +4 +] +; +let +n += +given_cp +. +encode_utf8 +( +& +mut +tmp +) +. +len +( +) +; +let +( +got_cp +_ +) += +decode_last_utf8 +( +& +tmp +[ +. +. +n +] +) +. +unwrap +( +) +; +let +expected_cp += +str +: +: +from_utf8 +( +& +tmp +[ +. +. +n +] +) +. +unwrap +( +) +. +chars +( +) +. +rev +( +) +. +next +( +) +. +unwrap +( +) +; +got_cp += += +expected_cp +} +quickcheck +( +p +as +fn +( +char +) +- +> +bool +) +} +# +[ +test +] +fn +reject_invalid +( +) +{ +/ +/ +Invalid +start +byte +assert_eq +! +( +decode_utf8 +( +& +[ +0xFF +] +) +None +) +; +/ +/ +Surrogate +pair +assert_eq +! +( +decode_utf8 +( +& +[ +0xED +0xA0 +0x81 +] +) +None +) +; +/ +/ +Invalid +continuation +byte +. +assert_eq +! +( +decode_utf8 +( +& +[ +0xD4 +0xC2 +] +) +None +) +; +/ +/ +Bad +lengths +assert_eq +! +( +decode_utf8 +( +& +[ +0xC3 +] +) +None +) +; +/ +/ +2 +bytes +assert_eq +! +( +decode_utf8 +( +& +[ +0xEF +0xBF +] +) +None +) +; +/ +/ +3 +bytes +assert_eq +! +( +decode_utf8 +( +& +[ +0xF4 +0x8F +0xBF +] +) +None +) +; +/ +/ +4 +bytes +/ +/ +Not +a +minimal +UTF +- +8 +sequence +assert_eq +! +( +decode_utf8 +( +& +[ +TAG_TWO +TAG_CONT +| +b +' +a +' +] +) +None +) +; +assert_eq +! +( +decode_utf8 +( +& +[ +TAG_THREE +TAG_CONT +TAG_CONT +| +b +' +a +' +] +) +None +) +; +assert_eq +! +( +decode_utf8 +( +& +[ +TAG_FOUR +TAG_CONT +TAG_CONT +TAG_CONT +| +b +' +a +' +] +) +None +) +; +} +# +[ +test +] +fn +reject_invalid_last +( +) +{ +/ +/ +Invalid +start +byte +assert_eq +! +( +decode_last_utf8 +( +& +[ +0xFF +] +) +None +) +; +/ +/ +Surrogate +pair +assert_eq +! +( +decode_last_utf8 +( +& +[ +0xED +0xA0 +0x81 +] +) +None +) +; +/ +/ +Bad +lengths +assert_eq +! +( +decode_last_utf8 +( +& +[ +0xC3 +] +) +None +) +; +/ +/ +2 +bytes +assert_eq +! +( +decode_last_utf8 +( +& +[ +0xEF +0xBF +] +) +None +) +; +/ +/ +3 +bytes +assert_eq +! +( +decode_last_utf8 +( +& +[ +0xF4 +0x8F +0xBF +] +) +None +) +; +/ +/ +4 +bytes +/ +/ +Not +a +minimal +UTF +- +8 +sequence +assert_eq +! +( +decode_last_utf8 +( +& +[ +TAG_TWO +TAG_CONT +| +b +' +a +' +] +) +None +) +; +assert_eq +! +( +decode_last_utf8 +( +& +[ +TAG_THREE +TAG_CONT +TAG_CONT +| +b +' +a +' +] +) +None +) +; +assert_eq +! +( +decode_last_utf8 +( +& +[ +TAG_FOUR +TAG_CONT +TAG_CONT +TAG_CONT +| +b +' +a +' +] +) +None +) +; +} +} diff --git a/third_party/rust/regex/test b/third_party/rust/regex/test index df9272b71f8bb..668c32b5251a3 100644 --- a/third_party/rust/regex/test +++ b/third_party/rust/regex/test @@ -8,48 +8,6 @@ set - e # -cd -to -the -directory -containing -this -crate -' -s -Cargo -. -toml -so -that -we -don -' -t -need -# -to -pass -- -- -manifest -- -path -to -every -cargo -command -. -cd -" -( -dirname -" -0 -" -) -" -# This is a @@ -124,71 +82,9 @@ FEATURES = = = -= -= " cargo test -# -no -- -std -mode -is -annoyingly -difficult -to -test -. -Currently -the -integration -tests -# -don -' -t -run -. -So -for -now -we -just -test -that -library -tests -run -. -( -There -aren -' -t -# -many -because -regex -is -just -a -wrapper -crate -. -) -cargo -test -- -- -no -- -default -- -features -- -- -lib echo " = @@ -201,8 +97,6 @@ TESTS = = = -= -= " cargo test @@ -253,26 +147,6 @@ perf - literal " -" -std -perf -- -dfa -- -full -" -" -std -perf -- -onepass -" -" -std -perf -- -backtrack -" ) for f @@ -296,8 +170,9 @@ echo FEATURE : f -= -= +( +default +) = = = @@ -307,7 +182,7 @@ test - - test -integration +default - - no @@ -321,37 +196,6 @@ features " f " -done -# -And -test -the -probably -- -forever -- -nightly -- -only -' -pattern -' -feature -. -. -. -if -rustc -- -- -version -| -grep -- -q -nightly -; -then echo " = @@ -361,13 +205,12 @@ echo = FEATURE : -std -pattern -unicode +f +( +default - -perl -= -= +bytes +) = = = @@ -377,7 +220,9 @@ test - - test -integration +default +- +bytes - - no @@ -388,9 +233,7 @@ features - - features -std -pattern -unicode -- -perl -fi +" +f +" +done diff --git a/third_party/rust/regex/testdata/README.md b/third_party/rust/regex/testdata/README.md deleted file mode 100644 index db4b6d9e77e08..0000000000000 --- a/third_party/rust/regex/testdata/README.md +++ /dev/null @@ -1,244 +0,0 @@ -This -directory -contains -a -large -suite -of -regex -tests -defined -in -a -TOML -format -. -They -are -used -to -drive -tests -in -tests -/ -lib -. -rs -regex -- -automata -/ -tests -/ -lib -. -rs -and -regex -- -lite -/ -tests -/ -lib -. -rs -. -See -the -[ -regex -- -test -] -[ -regex -- -test -] -crate -documentation -for -an -explanation -of -the -format -and -how -it -generates -tests -. -The -basic -idea -here -is -that -we -have -many -different -regex -engines -but -generally -one -set -of -tests -. -We -want -to -be -able -to -run -those -tests -( -or -most -of -them -) -on -every -engine -. -Prior -to -regex -1 -. -9 -we -used -to -do -this -with -a -hodge -podge -soup -of -macros -and -a -different -test -executable -for -each -engine -. -It -overall -took -a -longer -time -to -compile -was -harder -to -maintain -and -it -made -the -test -definitions -themselves -less -clear -. -In -regex -1 -. -9 -when -we -moved -over -to -regex -- -automata -the -situation -got -a -lot -worse -because -of -an -increase -in -the -number -of -engines -. -So -I -devised -an -engine -independent -format -for -testing -regex -patterns -and -their -semantics -. -Note -: -the -naming -scheme -used -in -these -tests -isn -' -t -terribly -consistent -. -It -would -be -great -to -fix -that -. -[ -regex -- -test -] -: -https -: -/ -/ -docs -. -rs -/ -regex -- -test diff --git a/third_party/rust/regex/testdata/anchored.toml b/third_party/rust/regex/testdata/anchored.toml deleted file mode 100644 index 3af6101b42c7f..0000000000000 --- a/third_party/rust/regex/testdata/anchored.toml +++ /dev/null @@ -1,902 +0,0 @@ -# -These -tests -are -specifically -geared -toward -searches -with -' -anchored -= -true -' -. -# -While -they -are -interesting -in -their -own -right -they -are -particularly -# -important -for -testing -the -one -- -pass -DFA -since -the -one -- -pass -DFA -can -' -t -work -in -# -unanchored -contexts -. -# -# -Note -that -" -anchored -" -in -this -context -does -not -mean -" -^ -" -. -Anchored -searches -are -# -searches -whose -matches -must -begin -at -the -start -of -the -search -which -may -not -# -be -at -the -start -of -the -haystack -. -That -' -s -why -anchored -searches -- -- -- -and -there -are -# -some -examples -below -- -- -- -can -still -report -multiple -matches -. -This -occurs -when -the -# -matches -are -adjacent -to -one -another -. -[ -[ -test -] -] -name -= -" -greedy -" -regex -= -' -( -abc -) -+ -' -haystack -= -" -abcabcabc -" -matches -= -[ -[ -[ -0 -9 -] -[ -6 -9 -] -] -] -anchored -= -true -# -When -a -" -earliest -" -search -is -used -greediness -doesn -' -t -really -exist -because -# -matches -are -reported -as -soon -as -they -are -known -. -[ -[ -test -] -] -name -= -" -greedy -- -earliest -" -regex -= -' -( -abc -) -+ -' -haystack -= -" -abcabcabc -" -matches -= -[ -[ -[ -0 -3 -] -[ -0 -3 -] -] -[ -[ -3 -6 -] -[ -3 -6 -] -] -[ -[ -6 -9 -] -[ -6 -9 -] -] -] -anchored -= -true -search -- -kind -= -" -earliest -" -[ -[ -test -] -] -name -= -" -nongreedy -" -regex -= -' -( -abc -) -+ -? -' -haystack -= -" -abcabcabc -" -matches -= -[ -[ -[ -0 -3 -] -[ -0 -3 -] -] -[ -[ -3 -6 -] -[ -3 -6 -] -] -[ -[ -6 -9 -] -[ -6 -9 -] -] -] -anchored -= -true -# -When -" -all -" -semantics -are -used -non -- -greediness -doesn -' -t -exist -since -the -longest -# -possible -match -is -always -taken -. -[ -[ -test -] -] -name -= -" -nongreedy -- -all -" -regex -= -' -( -abc -) -+ -? -' -haystack -= -" -abcabcabc -" -matches -= -[ -[ -[ -0 -9 -] -[ -6 -9 -] -] -] -anchored -= -true -match -- -kind -= -" -all -" -[ -[ -test -] -] -name -= -" -word -- -boundary -- -unicode -- -01 -" -regex -= -' -\ -b -\ -w -+ -\ -b -' -haystack -= -' -' -matches -= -[ -[ -0 -6 -] -] -anchored -= -true -[ -[ -test -] -] -name -= -" -word -- -boundary -- -nounicode -- -01 -" -regex -= -' -\ -b -\ -w -+ -\ -b -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -3 -] -] -anchored -= -true -unicode -= -false -# -Tests -that -' -. -c -' -doesn -' -t -match -' -abc -' -when -performing -an -anchored -search -from -# -the -beginning -of -the -haystack -. -This -test -found -two -different -bugs -in -the -# -PikeVM -and -the -meta -engine -. -[ -[ -test -] -] -name -= -" -no -- -match -- -at -- -start -" -regex -= -' -. -c -' -haystack -= -' -abc -' -matches -= -[ -] -anchored -= -true -# -Like -above -but -at -a -non -- -zero -start -offset -. -[ -[ -test -] -] -name -= -" -no -- -match -- -at -- -start -- -bounds -" -regex -= -' -. -c -' -haystack -= -' -aabc -' -bounds -= -[ -1 -4 -] -matches -= -[ -] -anchored -= -true -# -This -is -like -no -- -match -- -at -- -start -but -hits -the -" -reverse -inner -" -optimization -# -inside -the -meta -engine -. -( -no -- -match -- -at -- -start -hits -the -" -reverse -suffix -" -# -optimization -. -) -[ -[ -test -] -] -name -= -" -no -- -match -- -at -- -start -- -reverse -- -inner -" -regex -= -' -. -c -[ -a -- -z -] -' -haystack -= -' -abcz -' -matches -= -[ -] -anchored -= -true -# -Like -above -but -at -a -non -- -zero -start -offset -. -[ -[ -test -] -] -name -= -" -no -- -match -- -at -- -start -- -reverse -- -inner -- -bounds -" -regex -= -' -. -c -[ -a -- -z -] -' -haystack -= -' -aabcz -' -bounds -= -[ -1 -5 -] -matches -= -[ -] -anchored -= -true -# -Same -as -no -- -match -- -at -- -start -but -applies -to -the -meta -engine -' -s -" -reverse -# -anchored -" -optimization -. -[ -[ -test -] -] -name -= -" -no -- -match -- -at -- -start -- -reverse -- -anchored -" -regex -= -' -. -c -[ -a -- -z -] -' -haystack -= -' -abcz -' -matches -= -[ -] -anchored -= -true -# -Like -above -but -at -a -non -- -zero -start -offset -. -[ -[ -test -] -] -name -= -" -no -- -match -- -at -- -start -- -reverse -- -anchored -- -bounds -" -regex -= -' -. -c -[ -a -- -z -] -' -haystack -= -' -aabcz -' -bounds -= -[ -1 -5 -] -matches -= -[ -] -anchored -= -true diff --git a/third_party/rust/regex/testdata/bytes.toml b/third_party/rust/regex/testdata/bytes.toml deleted file mode 100644 index f89b02098d271..0000000000000 --- a/third_party/rust/regex/testdata/bytes.toml +++ /dev/null @@ -1,1483 +0,0 @@ -# -These -are -tests -specifically -crafted -for -regexes -that -can -match -arbitrary -# -bytes -. -In -some -cases -we -also -test -the -Unicode -variant -as -well -just -because -# -it -' -s -good -sense -to -do -so -. -But -also -these -tests -aren -' -t -really -about -Unicode -# -but -whether -matches -are -only -reported -at -valid -UTF -- -8 -boundaries -. -For -most -# -tests -in -this -entire -collection -utf8 -= -true -. -But -for -these -tests -we -use -# -utf8 -= -false -. -[ -[ -test -] -] -name -= -" -word -- -boundary -- -ascii -" -regex -= -' -\ -b -' -haystack -= -" -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -word -- -boundary -- -unicode -" -regex -= -' -\ -b -' -haystack -= -" -" -matches -= -[ -[ -0 -1 -] -] -unicode -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -word -- -boundary -- -ascii -- -not -" -regex -= -' -\ -B -' -haystack -= -" -" -matches -= -[ -[ -0 -1 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -word -- -boundary -- -unicode -- -not -" -regex -= -' -\ -B -' -haystack -= -" -" -matches -= -[ -] -unicode -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -perl -- -word -- -ascii -" -regex -= -' -\ -w -+ -' -haystack -= -" -a -" -matches -= -[ -[ -0 -1 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -perl -- -word -- -unicode -" -regex -= -' -\ -w -+ -' -haystack -= -" -a -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -perl -- -decimal -- -ascii -" -regex -= -' -\ -d -+ -' -haystack -= -" -1 -9 -" -matches -= -[ -[ -0 -1 -] -[ -7 -8 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -perl -- -decimal -- -unicode -" -regex -= -' -\ -d -+ -' -haystack -= -" -1 -9 -" -matches -= -[ -[ -0 -8 -] -] -unicode -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -perl -- -whitespace -- -ascii -" -regex -= -' -\ -s -+ -' -haystack -= -" -\ -u1680 -" -matches -= -[ -[ -0 -1 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -perl -- -whitespace -- -unicode -" -regex -= -' -\ -s -+ -' -haystack -= -" -\ -u1680 -" -matches -= -[ -[ -0 -4 -] -] -unicode -= -true -utf8 -= -false -# -The -first -( -. -+ -) -matches -two -Unicode -codepoints -but -can -' -t -match -the -5th -# -byte -which -isn -' -t -valid -UTF -- -8 -. -The -second -( -byte -based -) -( -. -+ -) -takes -over -and -# -matches -. -[ -[ -test -] -] -name -= -" -mixed -- -dot -" -regex -= -' -( -. -+ -) -( -? -- -u -) -( -. -+ -) -' -haystack -= -' -\ -xCE -\ -x93 -\ -xCE -\ -x94 -\ -xFF -' -matches -= -[ -[ -[ -0 -5 -] -[ -0 -4 -] -[ -4 -5 -] -] -] -unescape -= -true -unicode -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -case -- -one -- -ascii -" -regex -= -' -a -' -haystack -= -" -A -" -matches -= -[ -[ -0 -1 -] -] -case -- -insensitive -= -true -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -case -- -one -- -unicode -" -regex -= -' -a -' -haystack -= -" -A -" -matches -= -[ -[ -0 -1 -] -] -case -- -insensitive -= -true -unicode -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -case -- -class -- -simple -- -ascii -" -regex -= -' -[ -a -- -z -] -+ -' -haystack -= -" -AaAaA -" -matches -= -[ -[ -0 -5 -] -] -case -- -insensitive -= -true -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -case -- -class -- -ascii -" -regex -= -' -[ -a -- -z -] -+ -' -haystack -= -" -aA -\ -u212AaA -" -matches -= -[ -[ -0 -2 -] -[ -5 -7 -] -] -case -- -insensitive -= -true -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -case -- -class -- -unicode -" -regex -= -' -[ -a -- -z -] -+ -' -haystack -= -" -aA -\ -u212AaA -" -matches -= -[ -[ -0 -7 -] -] -case -- -insensitive -= -true -unicode -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -negate -- -ascii -" -regex -= -' -[ -^ -a -] -' -haystack -= -" -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -negate -- -unicode -" -regex -= -' -[ -^ -a -] -' -haystack -= -" -" -matches -= -[ -[ -0 -2 -] -] -unicode -= -true -utf8 -= -false -# -When -utf8 -= -true -this -won -' -t -match -because -the -implicit -' -. -* -? -' -prefix -is -# -Unicode -aware -and -will -refuse -to -match -through -invalid -UTF -- -8 -bytes -. -[ -[ -test -] -] -name -= -" -dotstar -- -prefix -- -ascii -" -regex -= -' -a -' -haystack -= -' -\ -xFFa -' -matches -= -[ -[ -1 -2 -] -] -unescape -= -true -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -dotstar -- -prefix -- -unicode -" -regex -= -' -a -' -haystack -= -' -\ -xFFa -' -matches -= -[ -[ -1 -2 -] -] -unescape -= -true -unicode -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -null -- -bytes -" -regex -= -' -( -? -P -< -cstr -> -[ -^ -\ -x00 -] -+ -) -\ -x00 -' -haystack -= -' -foo -\ -x00 -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -3 -] -] -] -unescape -= -true -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -invalid -- -utf8 -- -anchor -- -100 -" -regex -= -' -\ -xCC -? -^ -' -haystack -= -' -\ -x8d -# -; -\ -x1a -\ -xa4s3 -\ -x05foobarX -\ -\ -\ -x0f0t -\ -xe4 -\ -x9b -\ -xa4 -' -matches -= -[ -[ -0 -0 -] -] -unescape -= -true -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -invalid -- -utf8 -- -anchor -- -200 -" -regex -= -' -^ -\ -xf7 -| -4 -\ -xff -\ -d -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -# -# -# -# -# -# -# -# -# -# -[ -] -d -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -\ -x8a -# -# -# -# -# -# -# -# -# -# -\ -[ -] -# -# -# -# -# -\ -x80 -\ -S7 -| -' -haystack -= -' -\ -x8d -# -; -\ -x1a -\ -xa4s3 -\ -x05foobarX -\ -\ -\ -x0f0t -\ -xe4 -\ -x9b -\ -xa4 -' -matches -= -[ -[ -22 -22 -] -] -unescape -= -true -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -invalid -- -utf8 -- -anchor -- -300 -" -regex -= -' -^ -| -ddp -\ -xff -\ -xffdddddlQd -\ -x80 -' -haystack -= -' -\ -x8d -# -; -\ -x1a -\ -xa4s3 -\ -x05foobarX -\ -\ -\ -x0f0t -\ -xe4 -\ -x9b -\ -xa4 -' -matches -= -[ -[ -0 -0 -] -] -unescape -= -true -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -word -- -boundary -- -ascii -- -100 -" -regex -= -' -\ -Bx -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -word -- -boundary -- -ascii -- -200 -" -regex -= -' -\ -B -' -haystack -= -" -0 -\ -U0007EF5E -" -matches -= -[ -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -unicode -= -false -utf8 -= -false diff --git a/third_party/rust/regex/testdata/crazy.toml b/third_party/rust/regex/testdata/crazy.toml deleted file mode 100644 index 5a03f65893243..0000000000000 --- a/third_party/rust/regex/testdata/crazy.toml +++ /dev/null @@ -1,2675 +0,0 @@ -[ -[ -test -] -] -name -= -" -nothing -- -empty -" -regex -= -[ -] -haystack -= -" -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -nothing -- -something -" -regex -= -[ -] -haystack -= -" -wat -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -ranges -" -regex -= -' -( -? -- -u -) -\ -b -( -? -: -[ -0 -- -9 -] -| -[ -1 -- -9 -] -[ -0 -- -9 -] -| -1 -[ -0 -- -9 -] -[ -0 -- -9 -] -| -2 -[ -0 -- -4 -] -[ -0 -- -9 -] -| -25 -[ -0 -- -5 -] -) -\ -b -' -haystack -= -" -num -: -255 -" -matches -= -[ -[ -5 -8 -] -] -[ -[ -test -] -] -name -= -" -ranges -- -not -" -regex -= -' -( -? -- -u -) -\ -b -( -? -: -[ -0 -- -9 -] -| -[ -1 -- -9 -] -[ -0 -- -9 -] -| -1 -[ -0 -- -9 -] -[ -0 -- -9 -] -| -2 -[ -0 -- -4 -] -[ -0 -- -9 -] -| -25 -[ -0 -- -5 -] -) -\ -b -' -haystack -= -" -num -: -256 -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -float1 -" -regex -= -' -[ -- -+ -] -? -[ -0 -- -9 -] -* -\ -. -? -[ -0 -- -9 -] -+ -' -haystack -= -" -0 -. -1 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -float2 -" -regex -= -' -[ -- -+ -] -? -[ -0 -- -9 -] -* -\ -. -? -[ -0 -- -9 -] -+ -' -haystack -= -" -0 -. -1 -. -2 -" -matches -= -[ -[ -0 -3 -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -float3 -" -regex -= -' -[ -- -+ -] -? -[ -0 -- -9 -] -* -\ -. -? -[ -0 -- -9 -] -+ -' -haystack -= -" -a1 -. -2 -" -matches -= -[ -[ -1 -4 -] -] -[ -[ -test -] -] -name -= -" -float4 -" -regex -= -' -[ -- -+ -] -? -[ -0 -- -9 -] -* -\ -. -? -[ -0 -- -9 -] -+ -' -haystack -= -" -1 -. -a -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -float5 -" -regex -= -' -^ -[ -- -+ -] -? -[ -0 -- -9 -] -* -\ -. -? -[ -0 -- -9 -] -+ -' -haystack -= -" -1 -. -a -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -email -" -regex -= -' -( -? -i -- -u -) -\ -b -[ -A -- -Z0 -- -9 -. -_ -% -+ -- -] -+ -[ -A -- -Z0 -- -9 -. -- -] -+ -\ -. -[ -A -- -Z -] -{ -2 -4 -} -\ -b -' -haystack -= -" -mine -is -jam -. -slam -gmail -. -com -" -matches -= -[ -[ -8 -26 -] -] -[ -[ -test -] -] -name -= -" -email -- -not -" -regex -= -' -( -? -i -- -u -) -\ -b -[ -A -- -Z0 -- -9 -. -_ -% -+ -- -] -+ -[ -A -- -Z0 -- -9 -. -- -] -+ -\ -. -[ -A -- -Z -] -{ -2 -4 -} -\ -b -' -haystack -= -" -mine -is -jam -. -slam -gmail -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -email -- -big -" -regex -= -' -' -' -[ -a -- -z0 -- -9 -! -# -% -& -' -* -+ -/ -= -? -^ -_ -{ -| -} -~ -- -] -+ -( -? -: -\ -. -[ -a -- -z0 -- -9 -! -# -% -& -' -* -+ -/ -= -? -^ -_ -{ -| -} -~ -- -] -+ -) -* -( -? -: -[ -a -- -z0 -- -9 -] -( -? -: -[ -a -- -z0 -- -9 -- -] -* -[ -a -- -z0 -- -9 -] -) -? -\ -. -) -+ -[ -a -- -z0 -- -9 -] -( -? -: -[ -a -- -z0 -- -9 -- -] -* -[ -a -- -z0 -- -9 -] -) -? -' -' -' -haystack -= -" -mine -is -jam -. -slam -gmail -. -com -" -matches -= -[ -[ -8 -26 -] -] -[ -[ -test -] -] -name -= -" -date1 -" -regex -= -' -^ -( -? -: -19 -| -20 -) -\ -d -\ -d -[ -- -/ -. -] -( -? -: -0 -[ -1 -- -9 -] -| -1 -[ -012 -] -) -[ -- -/ -. -] -( -? -: -0 -[ -1 -- -9 -] -| -[ -12 -] -[ -0 -- -9 -] -| -3 -[ -01 -] -) -' -haystack -= -" -1900 -- -01 -- -01 -" -matches -= -[ -[ -0 -10 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -date2 -" -regex -= -' -^ -( -? -: -19 -| -20 -) -\ -d -\ -d -[ -- -/ -. -] -( -? -: -0 -[ -1 -- -9 -] -| -1 -[ -012 -] -) -[ -- -/ -. -] -( -? -: -0 -[ -1 -- -9 -] -| -[ -12 -] -[ -0 -- -9 -] -| -3 -[ -01 -] -) -' -haystack -= -" -1900 -- -00 -- -01 -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -date3 -" -regex -= -' -^ -( -? -: -19 -| -20 -) -\ -d -\ -d -[ -- -/ -. -] -( -? -: -0 -[ -1 -- -9 -] -| -1 -[ -012 -] -) -[ -- -/ -. -] -( -? -: -0 -[ -1 -- -9 -] -| -[ -12 -] -[ -0 -- -9 -] -| -3 -[ -01 -] -) -' -haystack -= -" -1900 -- -13 -- -01 -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -start -- -end -- -empty -" -regex -= -' -^ -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -start -- -end -- -empty -- -rev -" -regex -= -' -^ -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -start -- -end -- -empty -- -many -- -1 -" -regex -= -' -^ -^ -^ -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -start -- -end -- -empty -- -many -- -2 -" -regex -= -' -^ -^ -^ -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -start -- -end -- -empty -- -rep -" -regex -= -' -( -? -: -^ -) -* -' -haystack -= -" -a -\ -nb -\ -nc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -start -- -end -- -empty -- -rep -- -rev -" -regex -= -' -( -? -: -^ -) -* -' -haystack -= -" -a -\ -nb -\ -nc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -neg -- -class -- -letter -" -regex -= -' -[ -^ -ac -] -' -haystack -= -" -acx -" -matches -= -[ -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -neg -- -class -- -letter -- -comma -" -regex -= -' -[ -^ -a -] -' -haystack -= -" -a -x -" -matches -= -[ -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -neg -- -class -- -letter -- -space -" -regex -= -' -[ -^ -a -[ -: -space -: -] -] -' -haystack -= -" -a -x -" -matches -= -[ -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -neg -- -class -- -comma -" -regex -= -' -[ -^ -] -' -haystack -= -" -x -" -matches -= -[ -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -neg -- -class -- -space -" -regex -= -' -[ -^ -[ -: -space -: -] -] -' -haystack -= -" -a -" -matches -= -[ -[ -1 -2 -] -] -[ -[ -test -] -] -name -= -" -neg -- -class -- -space -- -comma -" -regex -= -' -[ -^ -[ -: -space -: -] -] -' -haystack -= -" -a -" -matches -= -[ -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -neg -- -class -- -comma -- -space -" -regex -= -' -[ -^ -[ -: -space -: -] -] -' -haystack -= -" -a -" -matches -= -[ -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -neg -- -class -- -ascii -" -regex -= -' -[ -^ -[ -: -alpha -: -] -Z -] -' -haystack -= -" -A1 -" -matches -= -[ -[ -1 -2 -] -] -[ -[ -test -] -] -name -= -" -lazy -- -many -- -many -" -regex -= -' -( -? -: -( -? -: -. -* -) -* -? -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -lazy -- -many -- -optional -" -regex -= -' -( -? -: -( -? -: -. -? -) -* -? -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -lazy -- -one -- -many -- -many -" -regex -= -' -( -? -: -( -? -: -. -* -) -+ -? -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -lazy -- -one -- -many -- -optional -" -regex -= -' -( -? -: -( -? -: -. -? -) -+ -? -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -lazy -- -range -- -min -- -many -" -regex -= -' -( -? -: -( -? -: -. -* -) -{ -1 -} -? -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -lazy -- -range -- -many -" -regex -= -' -( -? -: -( -? -: -. -* -) -{ -1 -2 -} -? -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -greedy -- -many -- -many -" -regex -= -' -( -? -: -( -? -: -. -* -) -* -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -greedy -- -many -- -optional -" -regex -= -' -( -? -: -( -? -: -. -? -) -* -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -greedy -- -one -- -many -- -many -" -regex -= -' -( -? -: -( -? -: -. -* -) -+ -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -greedy -- -one -- -many -- -optional -" -regex -= -' -( -? -: -( -? -: -. -? -) -+ -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -greedy -- -range -- -min -- -many -" -regex -= -' -( -? -: -( -? -: -. -* -) -{ -1 -} -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -greedy -- -range -- -many -" -regex -= -' -( -? -: -( -? -: -. -* -) -{ -1 -2 -} -) -= -' -haystack -= -" -a -= -b -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -empty1 -" -regex -= -' -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -empty2 -" -regex -= -' -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty3 -" -regex -= -' -( -? -: -) -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty4 -" -regex -= -' -( -? -: -) -* -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty5 -" -regex -= -' -( -? -: -) -+ -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty6 -" -regex -= -' -( -? -: -) -? -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty7 -" -regex -= -' -( -? -: -) -( -? -: -) -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty8 -" -regex -= -' -( -? -: -) -+ -| -z -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty9 -" -regex -= -' -z -| -( -? -: -) -+ -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty10 -" -regex -= -' -( -? -: -) -+ -| -b -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty11 -" -regex -= -' -b -| -( -? -: -) -+ -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -2 -] -[ -3 -3 -] -] diff --git a/third_party/rust/regex/testdata/crlf.toml b/third_party/rust/regex/testdata/crlf.toml deleted file mode 100644 index 528f53f48eb4f..0000000000000 --- a/third_party/rust/regex/testdata/crlf.toml +++ /dev/null @@ -1,1175 +0,0 @@ -# -This -is -a -basic -test -that -checks -^ -and -treat -\ -r -\ -n -as -a -single -line -# -terminator -. -If -^ -and -only -treated -\ -n -as -a -line -terminator -then -this -would -# -only -match -' -xyz -' -at -the -end -of -the -haystack -. -[ -[ -test -] -] -name -= -" -basic -" -regex -= -' -( -? -mR -) -^ -[ -a -- -z -] -+ -' -haystack -= -" -abc -\ -r -\ -ndef -\ -r -\ -nxyz -" -matches -= -[ -[ -0 -3 -] -[ -5 -8 -] -[ -10 -13 -] -] -# -Tests -that -a -CRLF -- -aware -' -^ -' -assertion -does -not -match -between -CR -and -LF -. -[ -[ -test -] -] -name -= -" -start -- -end -- -non -- -empty -" -regex -= -' -( -? -mR -) -^ -' -haystack -= -" -abc -\ -r -\ -ndef -\ -r -\ -nxyz -" -matches -= -[ -] -# -Tests -that -a -CRLF -- -aware -' -^ -' -assertion -matches -the -empty -string -just -like -# -a -non -- -CRLF -- -aware -' -^ -' -assertion -. -[ -[ -test -] -] -name -= -" -start -- -end -- -empty -" -regex -= -' -( -? -mR -) -^ -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -# -Tests -that -a -CRLF -- -aware -' -^ -' -assertion -matches -the -empty -string -preceding -# -and -following -a -line -terminator -. -[ -[ -test -] -] -name -= -" -start -- -end -- -before -- -after -" -regex -= -' -( -? -mR -) -^ -' -haystack -= -" -\ -r -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -] -# -Tests -that -a -CRLF -- -aware -' -^ -' -assertion -does -not -split -a -line -terminator -. -[ -[ -test -] -] -name -= -" -start -- -no -- -split -" -regex -= -' -( -? -mR -) -^ -' -haystack -= -" -abc -\ -r -\ -ndef -\ -r -\ -nxyz -" -matches -= -[ -[ -0 -0 -] -[ -5 -5 -] -[ -10 -10 -] -] -# -Same -as -above -but -with -adjacent -runs -of -line -terminators -. -[ -[ -test -] -] -name -= -" -start -- -no -- -split -- -adjacent -" -regex -= -' -( -? -mR -) -^ -' -haystack -= -" -\ -r -\ -n -\ -r -\ -n -\ -r -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -[ -4 -4 -] -[ -6 -6 -] -] -# -Same -as -above -but -with -adjacent -runs -of -just -carriage -returns -. -[ -[ -test -] -] -name -= -" -start -- -no -- -split -- -adjacent -- -cr -" -regex -= -' -( -? -mR -) -^ -' -haystack -= -" -\ -r -\ -r -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -# -Same -as -above -but -with -adjacent -runs -of -just -line -feeds -. -[ -[ -test -] -] -name -= -" -start -- -no -- -split -- -adjacent -- -lf -" -regex -= -' -( -? -mR -) -^ -' -haystack -= -" -\ -n -\ -n -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -# -Tests -that -a -CRLF -- -aware -' -' -assertion -does -not -split -a -line -terminator -. -[ -[ -test -] -] -name -= -" -end -- -no -- -split -" -regex -= -' -( -? -mR -) -' -haystack -= -" -abc -\ -r -\ -ndef -\ -r -\ -nxyz -" -matches -= -[ -[ -3 -3 -] -[ -8 -8 -] -[ -13 -13 -] -] -# -Same -as -above -but -with -adjacent -runs -of -line -terminators -. -[ -[ -test -] -] -name -= -" -end -- -no -- -split -- -adjacent -" -regex -= -' -( -? -mR -) -' -haystack -= -" -\ -r -\ -n -\ -r -\ -n -\ -r -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -[ -4 -4 -] -[ -6 -6 -] -] -# -Same -as -above -but -with -adjacent -runs -of -just -carriage -returns -. -[ -[ -test -] -] -name -= -" -end -- -no -- -split -- -adjacent -- -cr -" -regex -= -' -( -? -mR -) -' -haystack -= -" -\ -r -\ -r -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -# -Same -as -above -but -with -adjacent -runs -of -just -line -feeds -. -[ -[ -test -] -] -name -= -" -end -- -no -- -split -- -adjacent -- -lf -" -regex -= -' -( -? -mR -) -' -haystack -= -" -\ -n -\ -n -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -# -Tests -that -' -. -' -does -not -match -either -\ -r -or -\ -n -when -CRLF -mode -is -enabled -. -Note -# -that -this -doesn -' -t -require -multi -- -line -mode -to -be -enabled -. -[ -[ -test -] -] -name -= -" -dot -- -no -- -crlf -" -regex -= -' -( -? -R -) -. -' -haystack -= -" -\ -r -\ -n -\ -r -\ -n -\ -r -\ -n -" -matches -= -[ -] -# -This -is -a -test -that -caught -a -bug -in -the -one -- -pass -DFA -where -it -( -amazingly -) -was -# -using -' -is_end_lf -' -instead -of -' -is_end_crlf -' -here -. -It -was -probably -a -copy -& -# -paste -bug -. -We -insert -an -empty -capture -group -here -because -it -provokes -the -meta -# -regex -engine -to -first -find -a -match -and -then -trip -over -a -panic -because -the -# -one -- -pass -DFA -erroneously -says -there -is -no -match -. -[ -[ -test -] -] -name -= -" -onepass -- -wrong -- -crlf -- -with -- -capture -" -regex -= -' -( -? -Rm -: -( -) -. -) -' -haystack -= -" -ZZ -\ -r -" -matches -= -[ -[ -[ -1 -2 -] -[ -1 -1 -] -] -] -# -This -is -like -onepass -- -wrong -- -crlf -- -with -- -capture -above -except -it -sets -up -the -# -test -so -that -it -can -be -run -by -the -one -- -pass -DFA -directly -. -( -i -. -e -. -Make -it -# -anchored -and -start -the -search -at -the -right -place -. -) -[ -[ -test -] -] -name -= -" -onepass -- -wrong -- -crlf -- -anchored -" -regex -= -' -( -? -Rm -: -. -) -' -haystack -= -" -ZZ -\ -r -" -matches -= -[ -[ -1 -2 -] -] -anchored -= -true -bounds -= -[ -1 -3 -] diff --git a/third_party/rust/regex/testdata/earliest.toml b/third_party/rust/regex/testdata/earliest.toml deleted file mode 100644 index 04977afe6728d..0000000000000 --- a/third_party/rust/regex/testdata/earliest.toml +++ /dev/null @@ -1,324 +0,0 @@ -[ -[ -test -] -] -name -= -" -no -- -greedy -- -100 -" -regex -= -' -a -+ -' -haystack -= -" -aaa -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -[ -2 -3 -] -] -search -- -kind -= -" -earliest -" -[ -[ -test -] -] -name -= -" -no -- -greedy -- -200 -" -regex -= -' -abc -+ -' -haystack -= -" -zzzabccc -" -matches -= -[ -[ -3 -6 -] -] -search -- -kind -= -" -earliest -" -[ -[ -test -] -] -name -= -" -is -- -ungreedy -" -regex -= -' -a -+ -? -' -haystack -= -" -aaa -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -[ -2 -3 -] -] -search -- -kind -= -" -earliest -" -[ -[ -test -] -] -name -= -" -look -- -start -- -test -" -regex -= -' -^ -( -abc -| -a -) -' -haystack -= -" -abc -" -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -search -- -kind -= -" -earliest -" -[ -[ -test -] -] -name -= -" -look -- -end -- -test -" -regex -= -' -( -abc -| -a -) -' -haystack -= -" -abc -" -matches -= -[ -[ -[ -0 -3 -] -[ -0 -3 -] -] -] -search -- -kind -= -" -earliest -" -[ -[ -test -] -] -name -= -" -no -- -leftmost -- -first -- -100 -" -regex -= -' -abc -| -a -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -1 -] -] -search -- -kind -= -" -earliest -" -[ -[ -test -] -] -name -= -" -no -- -leftmost -- -first -- -200 -" -regex -= -' -aba -| -a -' -haystack -= -" -aba -" -matches -= -[ -[ -0 -1 -] -[ -2 -3 -] -] -search -- -kind -= -" -earliest -" diff --git a/third_party/rust/regex/testdata/empty.toml b/third_party/rust/regex/testdata/empty.toml deleted file mode 100644 index b3372da88d57b..0000000000000 --- a/third_party/rust/regex/testdata/empty.toml +++ /dev/null @@ -1,765 +0,0 @@ -[ -[ -test -] -] -name -= -" -100 -" -regex -= -" -| -b -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -110 -" -regex -= -" -b -| -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -120 -" -regex -= -" -| -z -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -130 -" -regex -= -" -z -| -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -200 -" -regex -= -" -| -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -210 -" -regex -= -" -| -| -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -220 -" -regex -= -" -| -| -b -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -230 -" -regex -= -" -b -| -| -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -240 -" -regex -= -" -| -| -z -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -300 -" -regex -= -" -( -? -: -) -| -b -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -310 -" -regex -= -" -b -| -( -? -: -) -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -320 -" -regex -= -" -( -? -: -| -) -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -330 -" -regex -= -" -( -? -: -| -) -| -z -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -400 -" -regex -= -" -a -( -? -: -) -| -b -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -] -[ -[ -test -] -] -name -= -" -500 -" -regex -= -" -" -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -510 -" -regex -= -" -" -haystack -= -" -a -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -[ -[ -test -] -] -name -= -" -520 -" -regex -= -" -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -600 -" -regex -= -' -( -? -: -| -a -) -* -' -haystack -= -" -aaa -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -610 -" -regex -= -' -( -? -: -| -a -) -+ -' -haystack -= -" -aaa -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] diff --git a/third_party/rust/regex/testdata/expensive.toml b/third_party/rust/regex/testdata/expensive.toml deleted file mode 100644 index c6b03e91eec91..0000000000000 --- a/third_party/rust/regex/testdata/expensive.toml +++ /dev/null @@ -1,256 +0,0 @@ -# -This -file -represent -tests -that -may -be -expensive -to -run -on -some -regex -engines -. -# -For -example -tests -that -build -a -full -DFA -ahead -of -time -and -minimize -it -can -# -take -a -horrendously -long -time -on -regexes -that -are -large -( -or -result -in -an -# -explosion -in -the -number -of -states -) -. -We -group -these -tests -together -so -that -# -such -engines -can -simply -skip -these -tests -. -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -98 -[ -[ -test -] -] -name -= -" -regression -- -many -- -repeat -- -no -- -stack -- -overflow -" -regex -= -' -^ -. -{ -1 -2500 -} -' -haystack -= -" -a -" -matches -= -[ -[ -0 -1 -] -] -# -This -test -is -meant -to -blow -the -bounded -backtracker -' -s -visited -capacity -. -In -# -order -to -do -that -we -need -a -somewhat -sizeable -regex -. -The -purpose -of -this -# -is -to -make -sure -there -' -s -at -least -one -test -that -exercises -this -path -in -the -# -backtracker -. -All -other -tests -( -at -time -of -writing -) -are -small -enough -that -the -# -backtracker -can -handle -them -fine -. -[ -[ -test -] -] -name -= -" -backtrack -- -blow -- -visited -- -capacity -" -regex -= -' -\ -pL -{ -50 -} -' -haystack -= -" -abcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyabcdefghijklmnopqrstuvwxyZZ -" -matches -= -[ -[ -0 -50 -] -[ -50 -100 -] -[ -100 -150 -] -] diff --git a/third_party/rust/regex/testdata/flags.toml b/third_party/rust/regex/testdata/flags.toml deleted file mode 100644 index 1cc26e1272c2e..0000000000000 --- a/third_party/rust/regex/testdata/flags.toml +++ /dev/null @@ -1,432 +0,0 @@ -[ -[ -test -] -] -name -= -" -1 -" -regex -= -" -( -? -i -) -abc -" -haystack -= -" -ABC -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -2 -" -regex -= -" -( -? -i -) -a -( -? -- -i -) -bc -" -haystack -= -" -Abc -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -3 -" -regex -= -" -( -? -i -) -a -( -? -- -i -) -bc -" -haystack -= -" -ABC -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -4 -" -regex -= -" -( -? -is -) -a -. -" -haystack -= -" -A -\ -n -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -5 -" -regex -= -" -( -? -is -) -a -. -( -? -- -is -) -a -. -" -haystack -= -" -A -\ -nab -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -6 -" -regex -= -" -( -? -is -) -a -. -( -? -- -is -) -a -. -" -haystack -= -" -A -\ -na -\ -n -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -7 -" -regex -= -" -( -? -is -) -a -. -( -? -- -is -: -a -. -) -? -" -haystack -= -" -A -\ -na -\ -n -" -matches -= -[ -[ -0 -2 -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -8 -" -regex -= -" -( -? -U -) -a -+ -" -haystack -= -" -aa -" -matches -= -[ -[ -0 -1 -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -9 -" -regex -= -" -( -? -U -) -a -+ -? -" -haystack -= -" -aa -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -10 -" -regex -= -" -( -? -U -) -( -? -- -U -) -a -+ -" -haystack -= -" -aa -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -11 -" -regex -= -' -( -? -m -) -( -? -: -^ -\ -d -+ -\ -n -? -) -+ -' -haystack -= -" -123 -\ -n456 -\ -n789 -" -matches -= -[ -[ -0 -11 -] -] -unicode -= -false diff --git a/third_party/rust/regex/testdata/fowler/basic.toml b/third_party/rust/regex/testdata/fowler/basic.toml deleted file mode 100644 index af10d3c6fc7bc..0000000000000 --- a/third_party/rust/regex/testdata/fowler/basic.toml +++ /dev/null @@ -1,12846 +0,0 @@ -# -! -! -! -DO -NOT -EDIT -! -! -! -# -Automatically -generated -by -' -regex -- -cli -generate -fowler -' -. -# -Numbers -in -the -test -names -correspond -to -the -line -number -of -the -test -from -# -the -original -dat -file -. -[ -[ -test -] -] -name -= -" -basic3 -" -regex -= -' -' -' -abracadabra -' -' -' -haystack -= -' -' -' -abracadabracadabra -' -' -' -matches -= -[ -[ -[ -7 -18 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic4 -" -regex -= -' -' -' -a -. -. -. -b -' -' -' -haystack -= -' -' -' -abababbb -' -' -' -matches -= -[ -[ -[ -2 -7 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic5 -" -regex -= -' -' -' -XXXXXX -' -' -' -haystack -= -' -' -' -. -. -XXXXXX -' -' -' -matches -= -[ -[ -[ -2 -8 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic6 -" -regex -= -' -' -' -\ -) -' -' -' -haystack -= -' -' -' -( -) -' -' -' -matches -= -[ -[ -[ -1 -2 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic7 -" -regex -= -' -' -' -a -] -' -' -' -haystack -= -' -' -' -a -] -a -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic9 -" -regex -= -' -' -' -\ -} -' -' -' -haystack -= -' -' -' -} -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic10 -" -regex -= -' -' -' -\ -] -' -' -' -haystack -= -' -' -' -] -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic12 -" -regex -= -' -' -' -] -' -' -' -haystack -= -' -' -' -] -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic15 -" -regex -= -' -' -' -^ -a -' -' -' -haystack -= -' -' -' -ax -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic16 -" -regex -= -' -' -' -\ -^ -a -' -' -' -haystack -= -' -' -' -a -^ -a -' -' -' -matches -= -[ -[ -[ -1 -3 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic17 -" -regex -= -' -' -' -a -\ -^ -' -' -' -haystack -= -' -' -' -a -^ -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic18 -" -regex -= -' -' -' -a -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -1 -2 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic19 -" -regex -= -' -' -' -a -\ -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic20 -" -regex -= -' -' -' -^ -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -[ -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic21 -" -regex -= -' -' -' -^ -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -[ -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic22 -" -regex -= -' -' -' -a -( -) -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -1 -2 -] -[ -2 -2 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic23 -" -regex -= -' -' -' -a -* -( -^ -a -) -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic24 -" -regex -= -' -' -' -( -. -. -) -* -( -. -. -. -) -* -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic25 -" -regex -= -' -' -' -( -. -. -) -* -( -. -. -. -) -* -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -2 -4 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic26 -" -regex -= -' -' -' -( -ab -| -a -) -( -bc -| -c -) -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -2 -] -[ -2 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic27 -" -regex -= -' -' -' -( -ab -) -c -| -abc -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic28 -" -regex -= -' -' -' -a -{ -0 -} -b -' -' -' -haystack -= -' -' -' -ab -' -' -' -matches -= -[ -[ -[ -1 -2 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic29 -" -regex -= -' -' -' -( -a -* -) -( -b -? -) -( -b -+ -) -b -{ -3 -} -' -' -' -haystack -= -' -' -' -aaabbbbbbb -' -' -' -matches -= -[ -[ -[ -0 -10 -] -[ -0 -3 -] -[ -3 -4 -] -[ -4 -7 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic30 -" -regex -= -' -' -' -( -a -* -) -( -b -{ -0 -1 -} -) -( -b -{ -1 -} -) -b -{ -3 -} -' -' -' -haystack -= -' -' -' -aaabbbbbbb -' -' -' -matches -= -[ -[ -[ -0 -10 -] -[ -0 -3 -] -[ -3 -4 -] -[ -4 -7 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic32 -" -regex -= -' -' -' -( -( -a -| -a -) -| -a -) -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic33 -" -regex -= -' -' -' -( -a -* -) -( -a -| -aa -) -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -3 -] -[ -3 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic34 -" -regex -= -' -' -' -a -* -( -a -. -| -aa -) -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -2 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic35 -" -regex -= -' -' -' -a -( -b -) -| -c -( -d -) -| -a -( -e -) -f -' -' -' -haystack -= -' -' -' -aef -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -] -[ -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic36 -" -regex -= -' -' -' -( -a -| -b -) -? -. -* -' -' -' -haystack -= -' -' -' -b -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic37 -" -regex -= -' -' -' -( -a -| -b -) -c -| -a -( -b -| -c -) -' -' -' -haystack -= -' -' -' -ac -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -1 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic38 -" -regex -= -' -' -' -( -a -| -b -) -c -| -a -( -b -| -c -) -' -' -' -haystack -= -' -' -' -ab -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic39 -" -regex -= -' -' -' -( -a -| -b -) -* -c -| -( -a -| -ab -) -* -c -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -1 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic40 -" -regex -= -' -' -' -( -a -| -b -) -* -c -| -( -a -| -ab -) -* -c -' -' -' -haystack -= -' -' -' -xc -' -' -' -matches -= -[ -[ -[ -1 -2 -] -[ -] -[ -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic41 -" -regex -= -' -' -' -( -. -a -| -. -b -) -. -* -| -. -* -( -. -a -| -. -b -) -' -' -' -haystack -= -' -' -' -xa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic42 -" -regex -= -' -' -' -a -? -( -ab -| -ba -) -ab -' -' -' -haystack -= -' -' -' -abab -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic43 -" -regex -= -' -' -' -a -? -( -ac -{ -0 -} -b -| -ba -) -ab -' -' -' -haystack -= -' -' -' -abab -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic44 -" -regex -= -' -' -' -ab -| -abab -' -' -' -haystack -= -' -' -' -abbabab -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic45 -" -regex -= -' -' -' -aba -| -bab -| -bba -' -' -' -haystack -= -' -' -' -baaabbbaba -' -' -' -matches -= -[ -[ -[ -5 -8 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic46 -" -regex -= -' -' -' -aba -| -bab -' -' -' -haystack -= -' -' -' -baaabbbaba -' -' -' -matches -= -[ -[ -[ -6 -9 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic47 -" -regex -= -' -' -' -( -aa -| -aaa -) -* -| -( -a -| -aaaaa -) -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic48 -" -regex -= -' -' -' -( -a -. -| -. -a -. -) -* -| -( -a -| -. -a -. -. -. -) -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic49 -" -regex -= -' -' -' -ab -| -a -' -' -' -haystack -= -' -' -' -xabc -' -' -' -matches -= -[ -[ -[ -1 -3 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic50 -" -regex -= -' -' -' -ab -| -a -' -' -' -haystack -= -' -' -' -xxabc -' -' -' -matches -= -[ -[ -[ -2 -4 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic51 -" -regex -= -' -' -' -( -Ab -| -cD -) -* -' -' -' -haystack -= -' -' -' -aBcD -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -2 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -case -- -insensitive -= -true -[ -[ -test -] -] -name -= -" -basic52 -" -regex -= -' -' -' -[ -^ -- -] -' -' -' -haystack -= -' -' -' -- -- -a -' -' -' -matches -= -[ -[ -[ -2 -3 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic53 -" -regex -= -' -' -' -[ -a -- -] -* -' -' -' -haystack -= -' -' -' -- -- -a -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic54 -" -regex -= -' -' -' -[ -a -- -m -- -] -* -' -' -' -haystack -= -' -' -' -- -- -amoma -- -- -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic55 -" -regex -= -' -' -' -: -: -: -1 -: -: -: -0 -: -| -: -: -: -1 -: -1 -: -0 -: -' -' -' -haystack -= -' -' -' -: -: -: -0 -: -: -: -1 -: -: -: -1 -: -: -: -0 -: -' -' -' -matches -= -[ -[ -[ -8 -17 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic56 -" -regex -= -' -' -' -: -: -: -1 -: -: -: -0 -: -| -: -: -: -1 -: -1 -: -1 -: -' -' -' -haystack -= -' -' -' -: -: -: -0 -: -: -: -1 -: -: -: -1 -: -: -: -0 -: -' -' -' -matches -= -[ -[ -[ -8 -17 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic57 -" -regex -= -' -' -' -[ -[ -: -upper -: -] -] -' -' -' -haystack -= -' -' -' -A -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic58 -" -regex -= -' -' -' -[ -[ -: -lower -: -] -] -+ -' -' -' -haystack -= -' -' -' -az -{ -' -' -' -matches -= -[ -[ -[ -1 -3 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic59 -" -regex -= -' -' -' -[ -[ -: -upper -: -] -] -+ -' -' -' -haystack -= -' -' -' -AZ -[ -' -' -' -matches -= -[ -[ -[ -1 -3 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic65 -" -regex -= -' -' -' -\ -n -' -' -' -haystack -= -' -' -' -\ -n -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -unescape -= -true -[ -[ -test -] -] -name -= -" -basic66 -" -regex -= -' -' -' -\ -n -' -' -' -haystack -= -' -' -' -\ -n -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -unescape -= -true -[ -[ -test -] -] -name -= -" -basic67 -" -regex -= -' -' -' -[ -^ -a -] -' -' -' -haystack -= -' -' -' -\ -n -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -unescape -= -true -[ -[ -test -] -] -name -= -" -basic68 -" -regex -= -' -' -' -\ -na -' -' -' -haystack -= -' -' -' -\ -na -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -unescape -= -true -[ -[ -test -] -] -name -= -" -basic69 -" -regex -= -' -' -' -( -a -) -( -b -) -( -c -) -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -1 -] -[ -1 -2 -] -[ -2 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic70 -" -regex -= -' -' -' -xxx -' -' -' -haystack -= -' -' -' -xxx -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -basic72 -" -regex -= -' -' -' -( -? -: -^ -| -[ -( -; -] -) -( -? -: -( -? -: -( -? -: -[ -Ff -] -eb -[ -^ -] -* -* -| -0 -* -2 -/ -| -\ -* -* -/ -? -) -0 -* -[ -6 -- -7 -] -) -) -( -? -: -[ -^ -0 -- -9 -] -| -) -' -' -' -haystack -= -' -' -' -feb -6 -' -' -' -matches -= -[ -[ -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -basic74 -" -regex -= -' -' -' -( -? -: -^ -| -[ -( -; -] -) -( -? -: -( -? -: -( -? -: -[ -Ff -] -eb -[ -^ -] -* -* -| -0 -* -2 -/ -| -\ -* -* -/ -? -) -0 -* -[ -6 -- -7 -] -) -) -( -? -: -[ -^ -0 -- -9 -] -| -) -' -' -' -haystack -= -' -' -' -2 -/ -7 -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -basic76 -" -regex -= -' -' -' -( -? -: -^ -| -[ -( -; -] -) -( -? -: -( -? -: -( -? -: -[ -Ff -] -eb -[ -^ -] -* -* -| -0 -* -2 -/ -| -\ -* -* -/ -? -) -0 -* -[ -6 -- -7 -] -) -) -( -? -: -[ -^ -0 -- -9 -] -| -) -' -' -' -haystack -= -' -' -' -feb -1 -Feb -6 -' -' -' -matches -= -[ -[ -[ -5 -11 -] -] -] -match -- -limit -= -1 -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -basic78 -" -regex -= -' -' -' -( -( -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -x -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -basic80 -" -regex -= -' -' -' -( -( -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -( -? -: -x -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -) -* -' -' -' -haystack -= -' -' -' -xx -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -1 -2 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic81 -" -regex -= -' -' -' -a -? -( -ab -| -ba -) -* -' -' -' -haystack -= -' -' -' -ababababababababababababababababababababababababababababababababababababababababa -' -' -' -matches -= -[ -[ -[ -0 -81 -] -[ -79 -81 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic82 -" -regex -= -' -' -' -abaa -| -abbaa -| -abbbaa -| -abbbbaa -' -' -' -haystack -= -' -' -' -ababbabbbabbbabbbbabbbbaa -' -' -' -matches -= -[ -[ -[ -18 -25 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic83 -" -regex -= -' -' -' -abaa -| -abbaa -| -abbbaa -| -abbbbaa -' -' -' -haystack -= -' -' -' -ababbabbbabbbabbbbabaa -' -' -' -matches -= -[ -[ -[ -18 -22 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic84 -" -regex -= -' -' -' -aaac -| -aabc -| -abac -| -abbc -| -baac -| -babc -| -bbac -| -bbbc -' -' -' -haystack -= -' -' -' -baaabbbabac -' -' -' -matches -= -[ -[ -[ -7 -11 -] -] -] -match -- -limit -= -1 -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -basic86 -" -regex -= -' -' -' -. -* -' -' -' -haystack -= -' -' -' -\ -x01 -\ -x7f -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -unescape -= -true -[ -[ -test -] -] -name -= -" -basic87 -" -regex -= -' -' -' -aaaa -| -bbbb -| -cccc -| -ddddd -| -eeeeee -| -fffffff -| -gggg -| -hhhh -| -iiiii -| -jjjjj -| -kkkkk -| -llll -' -' -' -haystack -= -' -' -' -XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa -' -' -' -matches -= -[ -[ -[ -53 -57 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic89 -" -regex -= -' -' -' -a -* -a -* -a -* -a -* -a -* -b -' -' -' -haystack -= -' -' -' -aaaaaaaaab -' -' -' -matches -= -[ -[ -[ -0 -10 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic90 -" -regex -= -' -' -' -^ -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -[ -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic91 -" -regex -= -' -' -' -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -[ -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic92 -" -regex -= -' -' -' -^ -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -[ -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic93 -" -regex -= -' -' -' -^ -a -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic94 -" -regex -= -' -' -' -abc -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic95 -" -regex -= -' -' -' -abc -' -' -' -haystack -= -' -' -' -xabcy -' -' -' -matches -= -[ -[ -[ -1 -4 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic96 -" -regex -= -' -' -' -abc -' -' -' -haystack -= -' -' -' -ababc -' -' -' -matches -= -[ -[ -[ -2 -5 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic97 -" -regex -= -' -' -' -ab -* -c -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic98 -" -regex -= -' -' -' -ab -* -bc -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic99 -" -regex -= -' -' -' -ab -* -bc -' -' -' -haystack -= -' -' -' -abbc -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic100 -" -regex -= -' -' -' -ab -* -bc -' -' -' -haystack -= -' -' -' -abbbbc -' -' -' -matches -= -[ -[ -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic101 -" -regex -= -' -' -' -ab -+ -bc -' -' -' -haystack -= -' -' -' -abbc -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic102 -" -regex -= -' -' -' -ab -+ -bc -' -' -' -haystack -= -' -' -' -abbbbc -' -' -' -matches -= -[ -[ -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic103 -" -regex -= -' -' -' -ab -? -bc -' -' -' -haystack -= -' -' -' -abbc -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic104 -" -regex -= -' -' -' -ab -? -bc -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic105 -" -regex -= -' -' -' -ab -? -c -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic106 -" -regex -= -' -' -' -^ -abc -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic107 -" -regex -= -' -' -' -^ -abc -' -' -' -haystack -= -' -' -' -abcc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic108 -" -regex -= -' -' -' -abc -' -' -' -haystack -= -' -' -' -aabc -' -' -' -matches -= -[ -[ -[ -1 -4 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic109 -" -regex -= -' -' -' -^ -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic110 -" -regex -= -' -' -' -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -3 -3 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic111 -" -regex -= -' -' -' -a -. -c -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic112 -" -regex -= -' -' -' -a -. -c -' -' -' -haystack -= -' -' -' -axc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic113 -" -regex -= -' -' -' -a -. -* -c -' -' -' -haystack -= -' -' -' -axyzc -' -' -' -matches -= -[ -[ -[ -0 -5 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic114 -" -regex -= -' -' -' -a -[ -bc -] -d -' -' -' -haystack -= -' -' -' -abd -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic115 -" -regex -= -' -' -' -a -[ -b -- -d -] -e -' -' -' -haystack -= -' -' -' -ace -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic116 -" -regex -= -' -' -' -a -[ -b -- -d -] -' -' -' -haystack -= -' -' -' -aac -' -' -' -matches -= -[ -[ -[ -1 -3 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic117 -" -regex -= -' -' -' -a -[ -- -b -] -' -' -' -haystack -= -' -' -' -a -- -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic118 -" -regex -= -' -' -' -a -[ -b -- -] -' -' -' -haystack -= -' -' -' -a -- -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic119 -" -regex -= -' -' -' -a -] -' -' -' -haystack -= -' -' -' -a -] -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic120 -" -regex -= -' -' -' -a -[ -] -] -b -' -' -' -haystack -= -' -' -' -a -] -b -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic121 -" -regex -= -' -' -' -a -[ -^ -bc -] -d -' -' -' -haystack -= -' -' -' -aed -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic122 -" -regex -= -' -' -' -a -[ -^ -- -b -] -c -' -' -' -haystack -= -' -' -' -adc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic123 -" -regex -= -' -' -' -a -[ -^ -] -b -] -c -' -' -' -haystack -= -' -' -' -adc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic124 -" -regex -= -' -' -' -ab -| -cd -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic125 -" -regex -= -' -' -' -ab -| -cd -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic126 -" -regex -= -' -' -' -a -\ -( -b -' -' -' -haystack -= -' -' -' -a -( -b -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic127 -" -regex -= -' -' -' -a -\ -( -* -b -' -' -' -haystack -= -' -' -' -ab -' -' -' -matches -= -[ -[ -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic128 -" -regex -= -' -' -' -a -\ -( -* -b -' -' -' -haystack -= -' -' -' -a -( -( -b -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic129 -" -regex -= -' -' -' -( -( -a -) -) -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic130 -" -regex -= -' -' -' -( -a -) -b -( -c -) -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -1 -] -[ -2 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic131 -" -regex -= -' -' -' -a -+ -b -+ -c -' -' -' -haystack -= -' -' -' -aabbabc -' -' -' -matches -= -[ -[ -[ -4 -7 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic132 -" -regex -= -' -' -' -a -* -' -' -' -haystack -= -' -' -' -aaa -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic133 -" -regex -= -' -' -' -( -a -* -) -* -' -' -' -haystack -= -' -' -' -- -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic134 -" -regex -= -' -' -' -( -a -* -) -+ -' -' -' -haystack -= -' -' -' -- -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic135 -" -regex -= -' -' -' -( -a -* -| -b -) -* -' -' -' -haystack -= -' -' -' -- -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic136 -" -regex -= -' -' -' -( -a -+ -| -b -) -* -' -' -' -haystack -= -' -' -' -ab -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic137 -" -regex -= -' -' -' -( -a -+ -| -b -) -+ -' -' -' -haystack -= -' -' -' -ab -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic138 -" -regex -= -' -' -' -( -a -+ -| -b -) -? -' -' -' -haystack -= -' -' -' -ab -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic139 -" -regex -= -' -' -' -[ -^ -ab -] -* -' -' -' -haystack -= -' -' -' -cde -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic140 -" -regex -= -' -' -' -( -^ -) -* -' -' -' -haystack -= -' -' -' -- -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic141 -" -regex -= -' -' -' -a -* -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -[ -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic142 -" -regex -= -' -' -' -( -[ -abc -] -) -* -d -' -' -' -haystack -= -' -' -' -abbbcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic143 -" -regex -= -' -' -' -( -[ -abc -] -) -* -bcd -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic144 -" -regex -= -' -' -' -a -| -b -| -c -| -d -| -e -' -' -' -haystack -= -' -' -' -e -' -' -' -matches -= -[ -[ -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic145 -" -regex -= -' -' -' -( -a -| -b -| -c -| -d -| -e -) -f -' -' -' -haystack -= -' -' -' -ef -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic146 -" -regex -= -' -' -' -( -( -a -* -| -b -) -) -* -' -' -' -haystack -= -' -' -' -- -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic147 -" -regex -= -' -' -' -abcd -* -efg -' -' -' -haystack -= -' -' -' -abcdefg -' -' -' -matches -= -[ -[ -[ -0 -7 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic148 -" -regex -= -' -' -' -ab -* -' -' -' -haystack -= -' -' -' -xabyabbbz -' -' -' -matches -= -[ -[ -[ -1 -3 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic149 -" -regex -= -' -' -' -ab -* -' -' -' -haystack -= -' -' -' -xayabbbz -' -' -' -matches -= -[ -[ -[ -1 -2 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic150 -" -regex -= -' -' -' -( -ab -| -cd -) -e -' -' -' -haystack -= -' -' -' -abcde -' -' -' -matches -= -[ -[ -[ -2 -5 -] -[ -2 -4 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic151 -" -regex -= -' -' -' -[ -abhgefdc -] -ij -' -' -' -haystack -= -' -' -' -hij -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic152 -" -regex -= -' -' -' -( -a -| -b -) -c -* -d -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -1 -4 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic153 -" -regex -= -' -' -' -( -ab -| -ab -* -) -bc -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic154 -" -regex -= -' -' -' -a -( -[ -bc -] -* -) -c -* -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -1 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic155 -" -regex -= -' -' -' -a -( -[ -bc -] -* -) -( -c -* -d -) -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -1 -3 -] -[ -3 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic156 -" -regex -= -' -' -' -a -( -[ -bc -] -+ -) -( -c -* -d -) -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -1 -3 -] -[ -3 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic157 -" -regex -= -' -' -' -a -( -[ -bc -] -* -) -( -c -+ -d -) -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -1 -2 -] -[ -2 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic158 -" -regex -= -' -' -' -a -[ -bcd -] -* -dcdcde -' -' -' -haystack -= -' -' -' -adcdcde -' -' -' -matches -= -[ -[ -[ -0 -7 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic159 -" -regex -= -' -' -' -( -ab -| -a -) -b -* -c -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic160 -" -regex -= -' -' -' -( -( -a -) -( -b -) -c -) -( -d -) -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -3 -] -[ -0 -1 -] -[ -1 -2 -] -[ -3 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic161 -" -regex -= -' -' -' -[ -A -- -Za -- -z_ -] -[ -A -- -Za -- -z0 -- -9_ -] -* -' -' -' -haystack -= -' -' -' -alpha -' -' -' -matches -= -[ -[ -[ -0 -5 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic162 -" -regex -= -' -' -' -^ -a -( -bc -+ -| -b -[ -eh -] -) -g -| -. -h -' -' -' -haystack -= -' -' -' -abh -' -' -' -matches -= -[ -[ -[ -1 -3 -] -[ -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic163 -" -regex -= -' -' -' -( -bc -+ -d -| -ef -* -g -. -| -h -? -i -( -j -| -k -) -) -' -' -' -haystack -= -' -' -' -effgz -' -' -' -matches -= -[ -[ -[ -0 -5 -] -[ -0 -5 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic164 -" -regex -= -' -' -' -( -bc -+ -d -| -ef -* -g -. -| -h -? -i -( -j -| -k -) -) -' -' -' -haystack -= -' -' -' -ij -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic165 -" -regex -= -' -' -' -( -bc -+ -d -| -ef -* -g -. -| -h -? -i -( -j -| -k -) -) -' -' -' -haystack -= -' -' -' -reffgz -' -' -' -matches -= -[ -[ -[ -1 -6 -] -[ -1 -6 -] -[ -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic166 -" -regex -= -' -' -' -( -( -( -( -( -( -( -( -( -a -) -) -) -) -) -) -) -) -) -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic167 -" -regex -= -' -' -' -multiple -words -' -' -' -haystack -= -' -' -' -multiple -words -yeah -' -' -' -matches -= -[ -[ -[ -0 -14 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic168 -" -regex -= -' -' -' -( -. -* -) -c -( -. -* -) -' -' -' -haystack -= -' -' -' -abcde -' -' -' -matches -= -[ -[ -[ -0 -5 -] -[ -0 -2 -] -[ -3 -5 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic169 -" -regex -= -' -' -' -abcd -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic170 -" -regex -= -' -' -' -a -( -bc -) -d -' -' -' -haystack -= -' -' -' -abcd -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -1 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic171 -" -regex -= -' -' -' -a -[ -\ -x01 -- -\ -x03 -] -? -c -' -' -' -haystack -= -' -' -' -a -\ -x02c -' -' -' -matches -= -[ -[ -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -unescape -= -true -[ -[ -test -] -] -name -= -" -basic172 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Qaddafi -' -' -' -matches -= -[ -[ -[ -0 -15 -] -[ -] -[ -10 -12 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic173 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Mo -' -ammar -Gadhafi -' -' -' -matches -= -[ -[ -[ -0 -16 -] -[ -] -[ -11 -13 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic174 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Kaddafi -' -' -' -matches -= -[ -[ -[ -0 -15 -] -[ -] -[ -10 -12 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic175 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Qadhafi -' -' -' -matches -= -[ -[ -[ -0 -15 -] -[ -] -[ -10 -12 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic176 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Gadafi -' -' -' -matches -= -[ -[ -[ -0 -14 -] -[ -] -[ -10 -11 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic177 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Mu -' -ammar -Qadafi -' -' -' -matches -= -[ -[ -[ -0 -15 -] -[ -] -[ -11 -12 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic178 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Moamar -Gaddafi -' -' -' -matches -= -[ -[ -[ -0 -14 -] -[ -] -[ -9 -11 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic179 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Mu -' -ammar -Qadhdhafi -' -' -' -matches -= -[ -[ -[ -0 -18 -] -[ -] -[ -13 -15 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic180 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Khaddafi -' -' -' -matches -= -[ -[ -[ -0 -16 -] -[ -] -[ -11 -13 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic181 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Ghaddafy -' -' -' -matches -= -[ -[ -[ -0 -16 -] -[ -] -[ -11 -13 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic182 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Ghadafi -' -' -' -matches -= -[ -[ -[ -0 -15 -] -[ -] -[ -11 -12 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic183 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Ghaddafi -' -' -' -matches -= -[ -[ -[ -0 -16 -] -[ -] -[ -11 -13 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic184 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muamar -Kaddafi -' -' -' -matches -= -[ -[ -[ -0 -14 -] -[ -] -[ -9 -11 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic185 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Quathafi -' -' -' -matches -= -[ -[ -[ -0 -16 -] -[ -] -[ -11 -13 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic186 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Muammar -Gheddafi -' -' -' -matches -= -[ -[ -[ -0 -16 -] -[ -] -[ -11 -13 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic187 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Moammar -Khadafy -' -' -' -matches -= -[ -[ -[ -0 -15 -] -[ -] -[ -11 -12 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic188 -" -regex -= -' -' -' -M -[ -ou -] -' -? -am -+ -[ -ae -] -r -. -* -( -[ -AEae -] -l -[ -- -] -) -? -[ -GKQ -] -h -? -[ -aeu -] -+ -( -[ -dtz -] -[ -dhz -] -? -) -+ -af -[ -iy -] -' -' -' -haystack -= -' -' -' -Moammar -Qudhafi -' -' -' -matches -= -[ -[ -[ -0 -15 -] -[ -] -[ -10 -12 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic189 -" -regex -= -' -' -' -a -+ -( -b -| -c -) -* -d -+ -' -' -' -haystack -= -' -' -' -aabcdd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -3 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic190 -" -regex -= -' -' -' -^ -. -+ -' -' -' -haystack -= -' -' -' -vivi -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic191 -" -regex -= -' -' -' -^ -( -. -+ -) -' -' -' -haystack -= -' -' -' -vivi -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic192 -" -regex -= -' -' -' -^ -( -[ -^ -! -. -] -+ -) -. -att -. -com -! -( -. -+ -) -' -' -' -haystack -= -' -' -' -gryphon -. -att -. -com -! -eby -' -' -' -matches -= -[ -[ -[ -0 -19 -] -[ -0 -7 -] -[ -16 -19 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic193 -" -regex -= -' -' -' -^ -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -' -' -' -haystack -= -' -' -' -bas -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -] -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic194 -" -regex -= -' -' -' -^ -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -' -' -' -haystack -= -' -' -' -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -4 -] -[ -4 -7 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic195 -" -regex -= -' -' -' -^ -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -' -' -' -haystack -= -' -' -' -foo -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -4 -] -[ -4 -7 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic196 -" -regex -= -' -' -' -^ -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -' -' -' -haystack -= -' -' -' -foo -! -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -11 -] -[ -4 -8 -] -[ -8 -11 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic197 -" -regex -= -' -' -' -( -( -foo -) -| -( -bar -) -) -! -bas -' -' -' -haystack -= -' -' -' -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -3 -] -[ -] -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic198 -" -regex -= -' -' -' -( -( -foo -) -| -( -bar -) -) -! -bas -' -' -' -haystack -= -' -' -' -foo -! -bar -! -bas -' -' -' -matches -= -[ -[ -[ -4 -11 -] -[ -4 -7 -] -[ -] -[ -4 -7 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic199 -" -regex -= -' -' -' -( -( -foo -) -| -( -bar -) -) -! -bas -' -' -' -haystack -= -' -' -' -foo -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -3 -] -[ -0 -3 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic200 -" -regex -= -' -' -' -( -( -foo -) -| -bar -) -! -bas -' -' -' -haystack -= -' -' -' -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -3 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic201 -" -regex -= -' -' -' -( -( -foo -) -| -bar -) -! -bas -' -' -' -haystack -= -' -' -' -foo -! -bar -! -bas -' -' -' -matches -= -[ -[ -[ -4 -11 -] -[ -4 -7 -] -[ -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic202 -" -regex -= -' -' -' -( -( -foo -) -| -bar -) -! -bas -' -' -' -haystack -= -' -' -' -foo -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -3 -] -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic203 -" -regex -= -' -' -' -( -foo -| -( -bar -) -) -! -bas -' -' -' -haystack -= -' -' -' -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -3 -] -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic204 -" -regex -= -' -' -' -( -foo -| -( -bar -) -) -! -bas -' -' -' -haystack -= -' -' -' -foo -! -bar -! -bas -' -' -' -matches -= -[ -[ -[ -4 -11 -] -[ -4 -7 -] -[ -4 -7 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic205 -" -regex -= -' -' -' -( -foo -| -( -bar -) -) -! -bas -' -' -' -haystack -= -' -' -' -foo -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -3 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic206 -" -regex -= -' -' -' -( -foo -| -bar -) -! -bas -' -' -' -haystack -= -' -' -' -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic207 -" -regex -= -' -' -' -( -foo -| -bar -) -! -bas -' -' -' -haystack -= -' -' -' -foo -! -bar -! -bas -' -' -' -matches -= -[ -[ -[ -4 -11 -] -[ -4 -7 -] -] -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -basic208 -" -regex -= -' -' -' -( -foo -| -bar -) -! -bas -' -' -' -haystack -= -' -' -' -foo -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic209 -" -regex -= -' -' -' -^ -( -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -) -' -' -' -haystack -= -' -' -' -foo -! -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -11 -] -[ -0 -11 -] -[ -] -[ -] -[ -4 -8 -] -[ -8 -11 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic210 -" -regex -= -' -' -' -^ -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -^ -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -' -' -' -haystack -= -' -' -' -bas -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -] -[ -0 -3 -] -[ -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic211 -" -regex -= -' -' -' -^ -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -^ -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -' -' -' -haystack -= -' -' -' -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -4 -] -[ -4 -7 -] -[ -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic212 -" -regex -= -' -' -' -^ -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -^ -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -' -' -' -haystack -= -' -' -' -foo -! -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -11 -] -[ -] -[ -] -[ -4 -8 -] -[ -8 -11 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic213 -" -regex -= -' -' -' -^ -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -^ -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -' -' -' -haystack -= -' -' -' -foo -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -4 -] -[ -4 -7 -] -[ -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic214 -" -regex -= -' -' -' -^ -( -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -) -' -' -' -haystack -= -' -' -' -bas -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -3 -] -[ -] -[ -0 -3 -] -[ -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic215 -" -regex -= -' -' -' -^ -( -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -) -' -' -' -haystack -= -' -' -' -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -7 -] -[ -0 -4 -] -[ -4 -7 -] -[ -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic216 -" -regex -= -' -' -' -^ -( -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -) -' -' -' -haystack -= -' -' -' -foo -! -bar -! -bas -' -' -' -matches -= -[ -[ -[ -0 -11 -] -[ -0 -11 -] -[ -] -[ -] -[ -4 -8 -] -[ -8 -11 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic217 -" -regex -= -' -' -' -^ -( -( -[ -^ -! -] -+ -! -) -? -( -[ -^ -! -] -+ -) -| -. -+ -! -( -[ -^ -! -] -+ -! -) -( -[ -^ -! -] -+ -) -) -' -' -' -haystack -= -' -' -' -foo -! -bas -' -' -' -matches -= -[ -[ -[ -0 -7 -] -[ -0 -7 -] -[ -0 -4 -] -[ -4 -7 -] -[ -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic218 -" -regex -= -' -' -' -. -* -( -/ -XXX -) -. -* -' -' -' -haystack -= -' -' -' -/ -XXX -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic219 -" -regex -= -' -' -' -. -* -( -\ -\ -XXX -) -. -* -' -' -' -haystack -= -' -' -' -\ -XXX -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic220 -" -regex -= -' -' -' -\ -\ -XXX -' -' -' -haystack -= -' -' -' -\ -XXX -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic221 -" -regex -= -' -' -' -. -* -( -/ -000 -) -. -* -' -' -' -haystack -= -' -' -' -/ -000 -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic222 -" -regex -= -' -' -' -. -* -( -\ -\ -000 -) -. -* -' -' -' -haystack -= -' -' -' -\ -000 -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -basic223 -" -regex -= -' -' -' -\ -\ -000 -' -' -' -haystack -= -' -' -' -\ -000 -' -' -' -matches -= -[ -[ -[ -0 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true diff --git a/third_party/rust/regex/testdata/fowler/dat/README b/third_party/rust/regex/testdata/fowler/dat/README deleted file mode 100644 index 75aed0b6ab9a1..0000000000000 --- a/third_party/rust/regex/testdata/fowler/dat/README +++ /dev/null @@ -1,243 +0,0 @@ -Test -data -was -taken -from -the -Go -distribution -which -was -in -turn -taken -from -the -testregex -test -suite -: -http -: -/ -/ -web -. -archive -. -org -/ -web -/ -20150925124103 -/ -http -: -/ -/ -www2 -. -research -. -att -. -com -/ -~ -astopen -/ -testregex -/ -testregex -. -html -Unfortunately -the -original -web -site -now -appears -dead -but -the -test -data -lives -on -. -The -LICENSE -in -this -directory -corresponds -to -the -LICENSE -that -the -data -was -originally -released -under -. -The -tests -themselves -were -modified -for -RE2 -/ -Go -( -and -marked -as -such -) -. -A -couple -were -modified -further -by -me -( -Andrew -Gallant -) -and -marked -with -' -Rust -' -. -After -some -number -of -years -these -tests -were -transformed -into -a -TOML -format -using -the -' -regex -- -cli -generate -fowler -' -command -. -To -re -- -generate -the -TOML -files -run -the -following -from -the -root -of -this -repository -: -regex -- -cli -generate -fowler -tests -/ -data -/ -fowler -tests -/ -data -/ -fowler -/ -dat -/ -* -. -dat -This -assumes -that -you -have -' -regex -- -cli -' -installed -. -See -' -regex -- -cli -/ -README -. -md -' -from -the -root -of -the -repository -for -more -information -. -This -brings -the -Fowler -tests -into -a -more -" -sensible -" -structured -format -in -which -other -tests -can -be -written -such -that -they -aren -' -t -write -- -only -. diff --git a/third_party/rust/regex/testdata/fowler/nullsubexpr.toml b/third_party/rust/regex/testdata/fowler/nullsubexpr.toml deleted file mode 100644 index 0543f7ec634c2..0000000000000 --- a/third_party/rust/regex/testdata/fowler/nullsubexpr.toml +++ /dev/null @@ -1,2870 +0,0 @@ -# -! -! -! -DO -NOT -EDIT -! -! -! -# -Automatically -generated -by -' -regex -- -cli -generate -fowler -' -. -# -Numbers -in -the -test -names -correspond -to -the -line -number -of -the -test -from -# -the -original -dat -file -. -[ -[ -test -] -] -name -= -" -nullsubexpr3 -" -regex -= -' -' -' -( -a -* -) -* -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr4 -" -regex -= -' -' -' -( -a -* -) -* -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr5 -" -regex -= -' -' -' -( -a -* -) -* -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr6 -" -regex -= -' -' -' -( -a -* -) -* -' -' -' -haystack -= -' -' -' -aaaaaax -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr7 -" -regex -= -' -' -' -( -a -* -) -+ -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr8 -" -regex -= -' -' -' -( -a -* -) -+ -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr9 -" -regex -= -' -' -' -( -a -* -) -+ -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr10 -" -regex -= -' -' -' -( -a -* -) -+ -' -' -' -haystack -= -' -' -' -aaaaaax -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr11 -" -regex -= -' -' -' -( -a -+ -) -* -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr12 -" -regex -= -' -' -' -( -a -+ -) -* -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr13 -" -regex -= -' -' -' -( -a -+ -) -* -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr14 -" -regex -= -' -' -' -( -a -+ -) -* -' -' -' -haystack -= -' -' -' -aaaaaax -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr15 -" -regex -= -' -' -' -( -a -+ -) -+ -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr16 -" -regex -= -' -' -' -( -a -+ -) -+ -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -nullsubexpr17 -" -regex -= -' -' -' -( -a -+ -) -+ -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr18 -" -regex -= -' -' -' -( -a -+ -) -+ -' -' -' -haystack -= -' -' -' -aaaaaax -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr20 -" -regex -= -' -' -' -( -[ -a -] -* -) -* -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr21 -" -regex -= -' -' -' -( -[ -a -] -* -) -* -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr22 -" -regex -= -' -' -' -( -[ -a -] -* -) -* -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr23 -" -regex -= -' -' -' -( -[ -a -] -* -) -* -' -' -' -haystack -= -' -' -' -aaaaaax -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr24 -" -regex -= -' -' -' -( -[ -a -] -* -) -+ -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr25 -" -regex -= -' -' -' -( -[ -a -] -* -) -+ -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr26 -" -regex -= -' -' -' -( -[ -a -] -* -) -+ -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr27 -" -regex -= -' -' -' -( -[ -a -] -* -) -+ -' -' -' -haystack -= -' -' -' -aaaaaax -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr28 -" -regex -= -' -' -' -( -[ -^ -b -] -* -) -* -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr29 -" -regex -= -' -' -' -( -[ -^ -b -] -* -) -* -' -' -' -haystack -= -' -' -' -b -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr30 -" -regex -= -' -' -' -( -[ -^ -b -] -* -) -* -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr31 -" -regex -= -' -' -' -( -[ -^ -b -] -* -) -* -' -' -' -haystack -= -' -' -' -aaaaaab -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr32 -" -regex -= -' -' -' -( -[ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr33 -" -regex -= -' -' -' -( -[ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr34 -" -regex -= -' -' -' -( -[ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -ababab -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr35 -" -regex -= -' -' -' -( -[ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -bababa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr36 -" -regex -= -' -' -' -( -[ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -b -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr37 -" -regex -= -' -' -' -( -[ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -bbbbbb -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr38 -" -regex -= -' -' -' -( -[ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -aaaabcde -' -' -' -matches -= -[ -[ -[ -0 -5 -] -[ -0 -5 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr39 -" -regex -= -' -' -' -( -[ -^ -a -] -* -) -* -' -' -' -haystack -= -' -' -' -b -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr40 -" -regex -= -' -' -' -( -[ -^ -a -] -* -) -* -' -' -' -haystack -= -' -' -' -bbbbbb -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr41 -" -regex -= -' -' -' -( -[ -^ -a -] -* -) -* -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr42 -" -regex -= -' -' -' -( -[ -^ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -ccccxx -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr43 -" -regex -= -' -' -' -( -[ -^ -ab -] -* -) -* -' -' -' -haystack -= -' -' -' -ababab -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -0 -0 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -nullsubexpr46 -" -regex -= -' -' -' -( -( -z -) -+ -| -a -) -* -' -' -' -haystack -= -' -' -' -zabcde -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -1 -2 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr64 -" -regex -= -' -' -' -( -a -* -) -* -( -x -) -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -0 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr65 -" -regex -= -' -' -' -( -a -* -) -* -( -x -) -' -' -' -haystack -= -' -' -' -ax -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -1 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr66 -" -regex -= -' -' -' -( -a -* -) -* -( -x -) -' -' -' -haystack -= -' -' -' -axa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -1 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr68 -" -regex -= -' -' -' -( -a -* -) -+ -( -x -) -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -0 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr69 -" -regex -= -' -' -' -( -a -* -) -+ -( -x -) -' -' -' -haystack -= -' -' -' -ax -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -1 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr70 -" -regex -= -' -' -' -( -a -* -) -+ -( -x -) -' -' -' -haystack -= -' -' -' -axa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -1 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr72 -" -regex -= -' -' -' -( -a -* -) -{ -2 -} -( -x -) -' -' -' -haystack -= -' -' -' -x -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -0 -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr73 -" -regex -= -' -' -' -( -a -* -) -{ -2 -} -( -x -) -' -' -' -haystack -= -' -' -' -ax -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -1 -1 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -nullsubexpr74 -" -regex -= -' -' -' -( -a -* -) -{ -2 -} -( -x -) -' -' -' -haystack -= -' -' -' -axa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -1 -1 -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true diff --git a/third_party/rust/regex/testdata/fowler/repetition.toml b/third_party/rust/regex/testdata/fowler/repetition.toml deleted file mode 100644 index ce64bbd455df5..0000000000000 --- a/third_party/rust/regex/testdata/fowler/repetition.toml +++ /dev/null @@ -1,6391 +0,0 @@ -# -! -! -! -DO -NOT -EDIT -! -! -! -# -Automatically -generated -by -' -regex -- -cli -generate -fowler -' -. -# -Numbers -in -the -test -names -correspond -to -the -line -number -of -the -test -from -# -the -original -dat -file -. -[ -[ -test -] -] -name -= -" -repetition10 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition11 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition12 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition14 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -1 -} -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition15 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -2 -} -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition16 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -3 -} -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition18 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -* -' -' -' -haystack -= -' -' -' -' -' -' -matches -= -[ -[ -[ -0 -0 -] -[ -] -[ -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition20 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition21 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition22 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition24 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -1 -} -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition25 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -2 -} -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition26 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -3 -} -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition28 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -* -' -' -' -haystack -= -' -' -' -a -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -] -[ -0 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition30 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition31 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -1 -] -[ -] -[ -0 -1 -] -[ -1 -2 -] -[ -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition32 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition34 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -1 -} -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition35 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -2 -} -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -1 -2 -] -[ -] -[ -1 -2 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition36 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -3 -} -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -] -match -- -limit -= -1 -[ -[ -test -] -] -name -= -" -repetition38 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -* -' -' -' -haystack -= -' -' -' -aa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition40 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition41 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaa -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -[ -2 -3 -] -[ -] -[ -2 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition42 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaa -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -0 -1 -] -[ -] -[ -0 -1 -] -[ -1 -2 -] -[ -] -[ -1 -2 -] -[ -2 -3 -] -[ -] -[ -2 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition44 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -1 -} -' -' -' -haystack -= -' -' -' -aaa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition46 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -2 -} -' -' -' -haystack -= -' -' -' -aaa -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -2 -3 -] -[ -0 -2 -] -[ -2 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition47 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -3 -} -' -' -' -haystack -= -' -' -' -aaa -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -2 -3 -] -[ -] -[ -2 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition50 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -* -' -' -' -haystack -= -' -' -' -aaa -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -2 -3 -] -[ -0 -2 -] -[ -2 -3 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition52 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition53 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition54 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -[ -2 -3 -] -[ -] -[ -2 -3 -] -[ -3 -4 -] -[ -] -[ -3 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition56 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -1 -} -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition57 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -2 -} -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition59 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -3 -} -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -3 -4 -] -[ -0 -2 -] -[ -3 -4 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition61 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -* -' -' -' -haystack -= -' -' -' -aaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition63 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaaa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition64 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition65 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaaa -' -' -' -matches -= -[ -[ -[ -0 -5 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -[ -4 -5 -] -[ -] -[ -4 -5 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition67 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -1 -} -' -' -' -haystack -= -' -' -' -aaaaa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition68 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -2 -} -' -' -' -haystack -= -' -' -' -aaaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition70 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -3 -} -' -' -' -haystack -= -' -' -' -aaaaa -' -' -' -matches -= -[ -[ -[ -0 -5 -] -[ -4 -5 -] -[ -2 -4 -] -[ -4 -5 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition73 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -* -' -' -' -haystack -= -' -' -' -aaaaa -' -' -' -matches -= -[ -[ -[ -0 -5 -] -[ -4 -5 -] -[ -2 -4 -] -[ -4 -5 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition75 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition76 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition77 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -( -( -. -. -) -| -( -. -) -) -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -[ -4 -6 -] -[ -4 -6 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition79 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -1 -} -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -[ -0 -2 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition80 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -2 -} -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -4 -] -[ -2 -4 -] -[ -2 -4 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition81 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -{ -3 -} -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -6 -] -[ -4 -6 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition83 -" -regex -= -' -' -' -( -( -. -. -) -| -( -. -) -) -* -' -' -' -haystack -= -' -' -' -aaaaaa -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -6 -] -[ -4 -6 -] -[ -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive90 -" -regex -= -' -' -' -X -( -. -? -) -{ -0 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -7 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive91 -" -regex -= -' -' -' -X -( -. -? -) -{ -1 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -7 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive92 -" -regex -= -' -' -' -X -( -. -? -) -{ -2 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -7 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive93 -" -regex -= -' -' -' -X -( -. -? -) -{ -3 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -7 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive94 -" -regex -= -' -' -' -X -( -. -? -) -{ -4 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -7 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive95 -" -regex -= -' -' -' -X -( -. -? -) -{ -5 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -7 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive96 -" -regex -= -' -' -' -X -( -. -? -) -{ -6 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -7 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive97 -" -regex -= -' -' -' -X -( -. -? -) -{ -7 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -7 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive98 -" -regex -= -' -' -' -X -( -. -? -) -{ -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive100 -" -regex -= -' -' -' -X -( -. -? -) -{ -0 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive102 -" -regex -= -' -' -' -X -( -. -? -) -{ -1 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive104 -" -regex -= -' -' -' -X -( -. -? -) -{ -2 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive106 -" -regex -= -' -' -' -X -( -. -? -) -{ -3 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive108 -" -regex -= -' -' -' -X -( -. -? -) -{ -4 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive110 -" -regex -= -' -' -' -X -( -. -? -) -{ -5 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive112 -" -regex -= -' -' -' -X -( -. -? -) -{ -6 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive114 -" -regex -= -' -' -' -X -( -. -? -) -{ -7 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive115 -" -regex -= -' -' -' -X -( -. -? -) -{ -8 -8 -} -Y -' -' -' -haystack -= -' -' -' -X1234567Y -' -' -' -matches -= -[ -[ -[ -0 -9 -] -[ -8 -8 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive127 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -0 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -1 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive129 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -1 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -1 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive130 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -2 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -3 -6 -] -[ -6 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive131 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -3 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -3 -6 -] -[ -6 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive132 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -4 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -] -match -- -limit -= -1 -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive134 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -0 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -1 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive136 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -1 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -1 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive137 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -2 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -3 -6 -] -[ -6 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive138 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -3 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -3 -6 -] -[ -6 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive139 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -{ -4 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -] -match -- -limit -= -1 -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive141 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -* -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -1 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -Rust -regex -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive143 -" -regex -= -' -' -' -( -a -| -ab -| -c -| -bcd -) -+ -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -1 -] -[ -0 -1 -] -[ -1 -1 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive149 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -0 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive151 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -1 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive153 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -2 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive155 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -3 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive156 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -4 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -] -match -- -limit -= -1 -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive158 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -0 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive160 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -1 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive162 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -2 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive164 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -3 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -[ -[ -test -] -] -name -= -" -repetition -- -expensive165 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -{ -4 -10 -} -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -] -match -- -limit -= -1 -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive167 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -* -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true -# -Test -added -by -RE2 -/ -Go -project -. -[ -[ -test -] -] -name -= -" -repetition -- -expensive169 -" -regex -= -' -' -' -( -ab -| -a -| -c -| -bcd -) -+ -( -d -* -) -' -' -' -haystack -= -' -' -' -ababcd -' -' -' -matches -= -[ -[ -[ -0 -6 -] -[ -4 -5 -] -[ -5 -6 -] -] -] -match -- -limit -= -1 -anchored -= -true diff --git a/third_party/rust/regex/testdata/iter.toml b/third_party/rust/regex/testdata/iter.toml deleted file mode 100644 index e3ff762a737df..0000000000000 --- a/third_party/rust/regex/testdata/iter.toml +++ /dev/null @@ -1,999 +0,0 @@ -[ -[ -test -] -] -name -= -" -1 -" -regex -= -" -a -" -haystack -= -" -aaa -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -2 -" -regex -= -" -a -" -haystack -= -" -aba -" -matches -= -[ -[ -0 -1 -] -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -empty1 -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -empty2 -" -regex -= -' -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty3 -" -regex -= -' -( -? -: -) -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty4 -" -regex -= -' -( -? -: -) -* -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty5 -" -regex -= -' -( -? -: -) -+ -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty6 -" -regex -= -' -( -? -: -) -? -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty7 -" -regex -= -' -( -? -: -) -( -? -: -) -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty8 -" -regex -= -' -( -? -: -) -+ -| -z -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty9 -" -regex -= -' -z -| -( -? -: -) -+ -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty10 -" -regex -= -' -( -? -: -) -+ -| -b -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -empty11 -" -regex -= -' -b -| -( -? -: -) -+ -' -haystack -= -' -abc -' -matches -= -[ -[ -0 -0 -] -[ -1 -2 -] -[ -3 -3 -] -] -[ -[ -test -] -] -name -= -" -start1 -" -regex -= -" -^ -a -" -haystack -= -" -a -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -start2 -" -regex -= -" -^ -a -" -haystack -= -" -aa -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -anchored1 -" -regex -= -" -a -" -haystack -= -" -a -" -matches -= -[ -[ -0 -1 -] -] -anchored -= -true -# -This -test -is -pretty -subtle -. -It -demonstrates -the -crucial -difference -between -# -' -^ -a -' -and -' -a -' -compiled -in -' -anchored -' -mode -. -The -former -regex -exclusively -# -matches -at -the -start -of -a -haystack -and -nowhere -else -. -The -latter -regex -has -# -no -such -restriction -but -its -automaton -is -constructed -such -that -it -lacks -a -# -. -* -? -prefix -. -So -it -can -actually -produce -matches -at -multiple -locations -. -# -The -anchored3 -test -drives -this -point -home -. -[ -[ -test -] -] -name -= -" -anchored2 -" -regex -= -" -a -" -haystack -= -" -aa -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -] -anchored -= -true -# -Unlikely -anchored2 -this -test -stops -matching -anything -after -it -sees -b -# -since -it -lacks -a -. -* -? -prefix -. -Since -it -is -looking -for -' -a -' -but -sees -' -b -' -it -# -determines -that -there -are -no -remaining -matches -. -[ -[ -test -] -] -name -= -" -anchored3 -" -regex -= -" -a -" -haystack -= -" -aaba -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -] -anchored -= -true -[ -[ -test -] -] -name -= -" -nonempty -- -followedby -- -empty -" -regex -= -' -abc -| -. -* -? -' -haystack -= -" -abczzz -" -matches -= -[ -[ -0 -3 -] -[ -4 -4 -] -[ -5 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -nonempty -- -followedby -- -oneempty -" -regex -= -' -abc -| -. -* -? -' -haystack -= -" -abcz -" -matches -= -[ -[ -0 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -nonempty -- -followedby -- -onemixed -" -regex -= -' -abc -| -. -* -? -' -haystack -= -" -abczabc -" -matches -= -[ -[ -0 -3 -] -[ -4 -7 -] -] -[ -[ -test -] -] -name -= -" -nonempty -- -followedby -- -twomixed -" -regex -= -' -abc -| -. -* -? -' -haystack -= -" -abczzabc -" -matches -= -[ -[ -0 -3 -] -[ -4 -4 -] -[ -5 -8 -] -] diff --git a/third_party/rust/regex/testdata/leftmost-all.toml b/third_party/rust/regex/testdata/leftmost-all.toml deleted file mode 100644 index f2bc05b2d1bfe..0000000000000 --- a/third_party/rust/regex/testdata/leftmost-all.toml +++ /dev/null @@ -1,145 +0,0 @@ -[ -[ -test -] -] -name -= -" -alt -" -regex -= -' -foo -| -foobar -' -haystack -= -" -foobar -" -matches -= -[ -[ -0 -6 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -multi -" -regex -= -[ -' -foo -' -' -foobar -' -] -haystack -= -" -foobar -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -6 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -dotall -" -regex -= -' -( -? -s -: -. -) -' -haystack -= -" -foobar -" -matches -= -[ -[ -5 -6 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -leftmost -" diff --git a/third_party/rust/regex/testdata/line-terminator.toml b/third_party/rust/regex/testdata/line-terminator.toml deleted file mode 100644 index c6b33961eaca8..0000000000000 --- a/third_party/rust/regex/testdata/line-terminator.toml +++ /dev/null @@ -1,771 +0,0 @@ -# -This -tests -that -we -can -switch -the -line -terminator -to -the -NUL -byte -. -[ -[ -test -] -] -name -= -" -nul -" -regex -= -' -( -? -m -) -^ -[ -a -- -z -] -+ -' -haystack -= -' -\ -x00abc -\ -x00 -' -matches -= -[ -[ -1 -4 -] -] -unescape -= -true -line -- -terminator -= -' -\ -x00 -' -# -This -tests -that -' -. -' -will -not -match -the -configured -line -terminator -but -will -# -match -\ -n -. -[ -[ -test -] -] -name -= -" -dot -- -changes -- -with -- -line -- -terminator -" -regex -= -' -. -' -haystack -= -' -\ -x00 -\ -n -' -matches -= -[ -[ -1 -2 -] -] -unescape -= -true -line -- -terminator -= -' -\ -x00 -' -# -This -tests -that -when -we -switch -the -line -terminator -\ -n -is -no -longer -# -recognized -as -the -terminator -. -[ -[ -test -] -] -name -= -" -not -- -line -- -feed -" -regex -= -' -( -? -m -) -^ -[ -a -- -z -] -+ -' -haystack -= -' -\ -nabc -\ -n -' -matches -= -[ -] -unescape -= -true -line -- -terminator -= -' -\ -x00 -' -# -This -tests -that -we -can -set -the -line -terminator -to -a -non -- -ASCII -byte -and -have -# -it -behave -as -expected -. -[ -[ -test -] -] -name -= -" -non -- -ascii -" -regex -= -' -( -? -m -) -^ -[ -a -- -z -] -+ -' -haystack -= -' -\ -xFFabc -\ -xFF -' -matches -= -[ -[ -1 -4 -] -] -unescape -= -true -line -- -terminator -= -' -\ -xFF -' -utf8 -= -false -# -This -tests -that -we -can -set -the -line -terminator -to -a -byte -corresponding -to -a -# -word -character -and -things -work -as -expected -. -[ -[ -test -] -] -name -= -" -word -- -byte -" -regex -= -' -( -? -m -) -^ -[ -a -- -z -] -+ -' -haystack -= -' -ZabcZ -' -matches -= -[ -[ -1 -4 -] -] -unescape -= -true -line -- -terminator -= -' -Z -' -# -This -tests -that -we -can -set -the -line -terminator -to -a -byte -corresponding -to -a -# -non -- -word -character -and -things -work -as -expected -. -[ -[ -test -] -] -name -= -" -non -- -word -- -byte -" -regex -= -' -( -? -m -) -^ -[ -a -- -z -] -+ -' -haystack -= -' -% -abc -% -' -matches -= -[ -[ -1 -4 -] -] -unescape -= -true -line -- -terminator -= -' -% -' -# -This -combines -" -set -line -terminator -to -a -word -byte -" -with -a -word -boundary -# -assertion -which -should -result -in -no -match -even -though -^ -/ -matches -. -[ -[ -test -] -] -name -= -" -word -- -boundary -" -regex -= -' -( -? -m -) -^ -\ -b -[ -a -- -z -] -+ -\ -b -' -haystack -= -' -ZabcZ -' -matches -= -[ -] -unescape -= -true -line -- -terminator -= -' -Z -' -# -Like -' -word -- -boundary -' -but -does -an -anchored -search -at -the -point -where -^ -# -matches -but -where -\ -b -should -not -. -[ -[ -test -] -] -name -= -" -word -- -boundary -- -at -" -regex -= -' -( -? -m -) -^ -\ -b -[ -a -- -z -] -+ -\ -b -' -haystack -= -' -ZabcZ -' -matches -= -[ -] -bounds -= -[ -1 -4 -] -anchored -= -true -unescape -= -true -line -- -terminator -= -' -Z -' -# -Like -' -word -- -boundary -- -at -' -but -flips -the -word -boundary -to -a -negation -. -This -# -in -particular -tests -a -tricky -case -in -DFA -engines -where -they -must -consider -# -explicitly -that -a -starting -configuration -from -a -custom -line -terminator -may -# -also -required -setting -the -" -is -from -word -byte -" -flag -on -a -state -. -Otherwise -# -it -' -s -treated -as -" -not -from -a -word -byte -" -which -would -result -in -\ -B -not -matching -# -here -when -it -should -. -[ -[ -test -] -] -name -= -" -not -- -word -- -boundary -- -at -" -regex -= -' -( -? -m -) -^ -\ -B -[ -a -- -z -] -+ -\ -B -' -haystack -= -' -ZabcZ -' -matches -= -[ -[ -1 -4 -] -] -bounds -= -[ -1 -4 -] -anchored -= -true -unescape -= -true -line -- -terminator -= -' -Z -' diff --git a/third_party/rust/regex/testdata/misc.toml b/third_party/rust/regex/testdata/misc.toml deleted file mode 100644 index 33c9d66101906..0000000000000 --- a/third_party/rust/regex/testdata/misc.toml +++ /dev/null @@ -1,552 +0,0 @@ -[ -[ -test -] -] -name -= -" -ascii -- -literal -" -regex -= -" -a -" -haystack -= -" -a -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -ascii -- -literal -- -not -" -regex -= -" -a -" -haystack -= -" -z -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -ascii -- -literal -- -anchored -" -regex -= -" -a -" -haystack -= -" -a -" -matches -= -[ -[ -0 -1 -] -] -anchored -= -true -[ -[ -test -] -] -name -= -" -ascii -- -literal -- -anchored -- -not -" -regex -= -" -a -" -haystack -= -" -z -" -matches -= -[ -] -anchored -= -true -[ -[ -test -] -] -name -= -" -anchor -- -start -- -end -- -line -" -regex -= -' -( -? -m -) -^ -bar -' -haystack -= -" -foo -\ -nbar -\ -nbaz -" -matches -= -[ -[ -4 -7 -] -] -[ -[ -test -] -] -name -= -" -prefix -- -literal -- -match -" -regex -= -' -^ -abc -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -prefix -- -literal -- -match -- -ascii -" -regex -= -' -^ -abc -' -haystack -= -" -abc -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -prefix -- -literal -- -no -- -match -" -regex -= -' -^ -abc -' -haystack -= -" -zabc -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -one -- -literal -- -edge -" -regex -= -' -abc -' -haystack -= -" -xxxxxab -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -terminates -" -regex -= -' -a -' -haystack -= -" -a -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -suffix -- -100 -" -regex -= -' -. -* -abcd -' -haystack -= -" -abcd -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -suffix -- -200 -" -regex -= -' -. -* -( -? -: -abcd -) -+ -' -haystack -= -" -abcd -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -suffix -- -300 -" -regex -= -' -. -* -( -? -: -abcd -) -+ -' -haystack -= -" -abcdabcd -" -matches -= -[ -[ -0 -8 -] -] -[ -[ -test -] -] -name -= -" -suffix -- -400 -" -regex -= -' -. -* -( -? -: -abcd -) -+ -' -haystack -= -" -abcdxabcd -" -matches -= -[ -[ -0 -9 -] -] -[ -[ -test -] -] -name -= -" -suffix -- -500 -" -regex -= -' -. -* -x -( -? -: -abcd -) -+ -' -haystack -= -" -abcdxabcd -" -matches -= -[ -[ -0 -9 -] -] -[ -[ -test -] -] -name -= -" -suffix -- -600 -" -regex -= -' -[ -^ -abcd -] -* -x -( -? -: -abcd -) -+ -' -haystack -= -" -abcdxabcd -" -matches -= -[ -[ -4 -9 -] -] diff --git a/third_party/rust/regex/testdata/multiline.toml b/third_party/rust/regex/testdata/multiline.toml deleted file mode 100644 index 7cfbd3472a49b..0000000000000 --- a/third_party/rust/regex/testdata/multiline.toml +++ /dev/null @@ -1,7531 +0,0 @@ -[ -[ -test -] -] -name -= -" -basic1 -" -regex -= -' -( -? -m -) -^ -[ -a -- -z -] -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -3 -] -[ -4 -7 -] -[ -8 -11 -] -] -[ -[ -test -] -] -name -= -" -basic1 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -[ -a -- -z -] -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -3 -] -[ -4 -7 -] -[ -8 -11 -] -] -[ -[ -test -] -] -name -= -" -basic1 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -^ -[ -a -- -z -] -+ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -3 -] -[ -4 -7 -] -[ -8 -11 -] -] -[ -[ -test -] -] -name -= -" -basic2 -" -regex -= -' -( -? -m -) -^ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic2 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic2 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -^ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic3 -" -regex -= -' -( -? -m -) -^ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -0 -] -[ -4 -4 -] -[ -8 -8 -] -] -[ -[ -test -] -] -name -= -" -basic3 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -0 -] -[ -4 -4 -] -[ -8 -8 -] -] -[ -[ -test -] -] -name -= -" -basic3 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -^ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -0 -] -[ -4 -4 -] -[ -8 -8 -] -] -[ -[ -test -] -] -name -= -" -basic4 -" -regex -= -' -( -? -m -) -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -3 -3 -] -[ -7 -7 -] -[ -11 -11 -] -] -[ -[ -test -] -] -name -= -" -basic4 -- -crlf -" -regex -= -' -( -? -Rm -) -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -3 -3 -] -[ -7 -7 -] -[ -11 -11 -] -] -[ -[ -test -] -] -name -= -" -basic4 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -3 -3 -] -[ -7 -7 -] -[ -11 -11 -] -] -[ -[ -test -] -] -name -= -" -basic5 -" -regex -= -' -( -? -m -) -^ -[ -a -- -z -] -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -1 -] -[ -4 -5 -] -[ -8 -9 -] -] -[ -[ -test -] -] -name -= -" -basic5 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -[ -a -- -z -] -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -1 -] -[ -4 -5 -] -[ -8 -9 -] -] -[ -[ -test -] -] -name -= -" -basic5 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -^ -[ -a -- -z -] -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -1 -] -[ -4 -5 -] -[ -8 -9 -] -] -[ -[ -test -] -] -name -= -" -basic6 -" -regex -= -' -( -? -m -) -[ -a -- -z -] -^ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic6 -- -crlf -" -regex -= -' -( -? -Rm -) -[ -a -- -z -] -^ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic6 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -[ -a -- -z -] -^ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic7 -" -regex -= -' -( -? -m -) -[ -a -- -z -] -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -2 -3 -] -[ -6 -7 -] -[ -10 -11 -] -] -[ -[ -test -] -] -name -= -" -basic7 -- -crlf -" -regex -= -' -( -? -Rm -) -[ -a -- -z -] -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -2 -3 -] -[ -6 -7 -] -[ -10 -11 -] -] -[ -[ -test -] -] -name -= -" -basic7 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -[ -a -- -z -] -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -2 -3 -] -[ -6 -7 -] -[ -10 -11 -] -] -[ -[ -test -] -] -name -= -" -basic8 -" -regex -= -' -( -? -m -) -[ -a -- -z -] -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic8 -- -crlf -" -regex -= -' -( -? -Rm -) -[ -a -- -z -] -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic8 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -[ -a -- -z -] -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -basic9 -" -regex -= -' -( -? -m -) -^ -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -basic9 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -repeat1 -" -regex -= -' -( -? -m -) -( -? -: -^ -) -* -' -haystack -= -" -a -\ -nb -\ -nc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat1 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -) -* -' -haystack -= -" -a -\ -nb -\ -nc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat1 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -) -* -' -haystack -= -" -a -\ -rb -\ -rc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat1 -- -no -- -multi -" -regex -= -' -( -? -: -^ -) -* -' -haystack -= -" -a -\ -nb -\ -nc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat1 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -) -* -' -haystack -= -" -a -\ -nb -\ -nc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat1 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -) -* -' -haystack -= -" -a -\ -rb -\ -rc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat2 -" -regex -= -' -( -? -m -) -( -? -: -^ -| -a -) -+ -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat2 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -a -) -+ -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat2 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -a -) -+ -' -haystack -= -" -a -\ -raaa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat2 -- -no -- -multi -" -regex -= -' -( -? -: -^ -| -a -) -+ -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat2 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -| -a -) -+ -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat2 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -| -a -) -+ -' -haystack -= -" -a -\ -raaa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -2 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat3 -" -regex -= -' -( -? -m -) -( -? -: -^ -| -a -) -* -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat3 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -a -) -* -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat3 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -a -) -* -' -haystack -= -" -a -\ -raaa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat3 -- -no -- -multi -" -regex -= -' -( -? -: -^ -| -a -) -* -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat3 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -| -a -) -* -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat3 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -| -a -) -* -' -haystack -= -" -a -\ -raaa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat4 -" -regex -= -' -( -? -m -) -( -? -: -^ -| -a -+ -) -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat4 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -a -+ -) -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat4 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -a -+ -) -' -haystack -= -" -a -\ -raaa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat4 -- -no -- -multi -" -regex -= -' -( -? -: -^ -| -a -+ -) -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat4 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -| -a -+ -) -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -2 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat4 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -| -a -+ -) -' -haystack -= -" -a -\ -raaa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -2 -5 -] -] -[ -[ -test -] -] -name -= -" -repeat5 -" -regex -= -' -( -? -m -) -( -? -: -^ -| -a -* -) -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat5 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -a -* -) -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat5 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -a -* -) -' -haystack -= -" -a -\ -raaa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat5 -- -no -- -multi -" -regex -= -' -( -? -: -^ -| -a -* -) -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat5 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -| -a -* -) -' -haystack -= -" -a -\ -naaa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat5 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -| -a -* -) -' -haystack -= -" -a -\ -raaa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -5 -] -[ -6 -6 -] -] -[ -[ -test -] -] -name -= -" -repeat6 -" -regex -= -' -( -? -m -) -( -? -: -^ -[ -a -- -z -] -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -1 -] -[ -4 -5 -] -[ -8 -9 -] -] -[ -[ -test -] -] -name -= -" -repeat6 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -[ -a -- -z -] -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -1 -] -[ -4 -5 -] -[ -8 -9 -] -] -[ -[ -test -] -] -name -= -" -repeat6 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -[ -a -- -z -] -) -+ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -1 -] -[ -4 -5 -] -[ -8 -9 -] -] -[ -[ -test -] -] -name -= -" -repeat6 -- -no -- -multi -" -regex -= -' -( -? -: -^ -[ -a -- -z -] -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -repeat6 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -[ -a -- -z -] -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -repeat6 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -[ -a -- -z -] -) -+ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -repeat7 -" -regex -= -' -( -? -m -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -n -? -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat7 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -n -? -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat7 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -r -? -) -+ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat7 -- -no -- -multi -" -regex -= -' -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -n -? -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat7 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -n -? -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat7 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -r -? -) -+ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat8 -" -regex -= -' -( -? -m -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -n -? -) -* -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat8 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -n -? -) -* -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat8 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -r -? -) -* -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat8 -- -no -- -multi -" -regex -= -' -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -n -? -) -* -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -[ -8 -8 -] -[ -9 -9 -] -[ -10 -10 -] -[ -11 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat8 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -n -? -) -* -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -[ -8 -8 -] -[ -9 -9 -] -[ -10 -10 -] -[ -11 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat8 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -[ -a -- -z -] -{ -3 -} -\ -r -? -) -* -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -[ -8 -8 -] -[ -9 -9 -] -[ -10 -10 -] -[ -11 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat9 -" -regex -= -' -( -? -m -) -( -? -: -\ -n -? -[ -a -- -z -] -{ -3 -} -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat9 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -\ -n -? -[ -a -- -z -] -{ -3 -} -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat9 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -\ -r -? -[ -a -- -z -] -{ -3 -} -) -+ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat9 -- -no -- -multi -" -regex -= -' -( -? -: -\ -n -? -[ -a -- -z -] -{ -3 -} -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -7 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat9 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -\ -n -? -[ -a -- -z -] -{ -3 -} -) -+ -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -7 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat9 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -\ -r -? -[ -a -- -z -] -{ -3 -} -) -+ -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -7 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat10 -" -regex -= -' -( -? -m -) -( -? -: -\ -n -? -[ -a -- -z -] -{ -3 -} -) -* -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat10 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -\ -n -? -[ -a -- -z -] -{ -3 -} -) -* -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat10 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -\ -r -? -[ -a -- -z -] -{ -3 -} -) -* -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat10 -- -no -- -multi -" -regex -= -' -( -? -: -\ -n -? -[ -a -- -z -] -{ -3 -} -) -* -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat10 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -\ -n -? -[ -a -- -z -] -{ -3 -} -) -* -' -haystack -= -" -abc -\ -ndef -\ -nxyz -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat10 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -\ -r -? -[ -a -- -z -] -{ -3 -} -) -* -' -haystack -= -" -abc -\ -rdef -\ -rxyz -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -11 -] -] -[ -[ -test -] -] -name -= -" -repeat11 -" -regex -= -' -( -? -m -) -^ -* -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat11 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -* -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat11 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -^ -* -' -haystack -= -" -\ -raa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat11 -- -no -- -multi -" -regex -= -' -^ -* -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat11 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -^ -* -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat11 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -^ -* -' -haystack -= -" -\ -raa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat12 -" -regex -= -' -( -? -m -) -^ -+ -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat12 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -+ -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat12 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -^ -+ -' -haystack -= -" -\ -raa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat12 -- -no -- -multi -" -regex -= -' -^ -+ -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -repeat12 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -^ -+ -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -repeat12 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -^ -+ -' -haystack -= -" -\ -raa -\ -r -" -matches -= -[ -[ -0 -0 -] -] -[ -[ -test -] -] -name -= -" -repeat13 -" -regex -= -' -( -? -m -) -* -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat13 -- -crlf -" -regex -= -' -( -? -Rm -) -* -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat13 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -* -' -haystack -= -" -\ -raa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat13 -- -no -- -multi -" -regex -= -' -* -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat13 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -* -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat13 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -* -' -haystack -= -" -\ -raa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat14 -" -regex -= -' -( -? -m -) -+ -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat14 -- -crlf -" -regex -= -' -( -? -Rm -) -+ -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat14 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -+ -' -haystack -= -" -\ -raa -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -3 -3 -] -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat14 -- -no -- -multi -" -regex -= -' -+ -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat14 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -+ -' -haystack -= -" -\ -naa -\ -n -" -matches -= -[ -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat14 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -+ -' -haystack -= -" -\ -raa -\ -r -" -matches -= -[ -[ -4 -4 -] -] -[ -[ -test -] -] -name -= -" -repeat15 -" -regex -= -' -( -? -m -) -( -? -: -\ -n -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat15 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -\ -n -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat15 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -\ -r -) -+ -' -haystack -= -" -\ -r -\ -raaa -\ -r -\ -r -" -matches -= -[ -[ -0 -2 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat15 -- -no -- -multi -" -regex -= -' -( -? -: -\ -n -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -repeat15 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -\ -n -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -repeat15 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -\ -r -) -+ -' -haystack -= -" -\ -r -\ -raaa -\ -r -\ -r -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -repeat16 -" -regex -= -' -( -? -m -) -( -? -: -\ -n -) -* -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat16 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -\ -n -) -* -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat16 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -\ -r -) -* -' -haystack -= -" -\ -r -\ -raaa -\ -r -\ -r -" -matches -= -[ -[ -0 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat16 -- -no -- -multi -" -regex -= -' -( -? -: -\ -n -) -* -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat16 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -\ -n -) -* -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat16 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -\ -r -) -* -' -haystack -= -" -\ -r -\ -raaa -\ -r -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat17 -" -regex -= -' -( -? -m -) -( -? -: -\ -n -^ -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat17 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -\ -n -^ -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat17 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -\ -r -^ -) -+ -' -haystack -= -" -\ -r -\ -raaa -\ -r -\ -r -" -matches -= -[ -[ -0 -2 -] -[ -5 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat17 -- -no -- -multi -" -regex -= -' -( -? -: -\ -n -^ -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -repeat17 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -\ -n -^ -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -repeat17 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -\ -r -^ -) -+ -' -haystack -= -" -\ -r -\ -raaa -\ -r -\ -r -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -repeat18 -" -regex -= -' -( -? -m -) -( -? -: -^ -| -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat18 -- -crlf -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat18 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -( -? -: -^ -| -) -+ -' -haystack -= -" -\ -r -\ -raaa -\ -r -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -5 -5 -] -[ -6 -6 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat18 -- -no -- -multi -" -regex -= -' -( -? -: -^ -| -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat18 -- -no -- -multi -- -crlf -" -regex -= -' -( -? -R -) -( -? -: -^ -| -) -+ -' -haystack -= -" -\ -n -\ -naaa -\ -n -\ -n -" -matches -= -[ -[ -0 -0 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -repeat18 -- -no -- -multi -- -crlf -- -cr -" -regex -= -' -( -? -R -) -( -? -: -^ -| -) -+ -' -haystack -= -" -\ -r -\ -raaa -\ -r -\ -r -" -matches -= -[ -[ -0 -0 -] -[ -7 -7 -] -] -[ -[ -test -] -] -name -= -" -match -- -line -- -100 -" -regex -= -' -( -? -m -) -^ -. -+ -' -haystack -= -" -aa -\ -naaaaaaaaaaaaaaaaaaa -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -3 -22 -] -] -[ -[ -test -] -] -name -= -" -match -- -line -- -100 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -. -+ -' -haystack -= -" -aa -\ -naaaaaaaaaaaaaaaaaaa -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -3 -22 -] -] -[ -[ -test -] -] -name -= -" -match -- -line -- -100 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -^ -. -+ -' -haystack -= -" -aa -\ -raaaaaaaaaaaaaaaaaaa -\ -r -" -matches -= -[ -[ -0 -2 -] -[ -3 -22 -] -] -[ -[ -test -] -] -name -= -" -match -- -line -- -200 -" -regex -= -' -( -? -m -) -^ -. -+ -' -haystack -= -" -aa -\ -naaaaaaaaaaaaaaaaaaa -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -3 -22 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -match -- -line -- -200 -- -crlf -" -regex -= -' -( -? -Rm -) -^ -. -+ -' -haystack -= -" -aa -\ -naaaaaaaaaaaaaaaaaaa -\ -n -" -matches -= -[ -[ -0 -2 -] -[ -3 -22 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -match -- -line -- -200 -- -crlf -- -cr -" -regex -= -' -( -? -Rm -) -^ -. -+ -' -haystack -= -" -aa -\ -raaaaaaaaaaaaaaaaaaa -\ -r -" -matches -= -[ -[ -0 -2 -] -[ -3 -22 -] -] -unicode -= -false -utf8 -= -false diff --git a/third_party/rust/regex/testdata/no-unicode.toml b/third_party/rust/regex/testdata/no-unicode.toml deleted file mode 100644 index 2169e0ff9dd9b..0000000000000 --- a/third_party/rust/regex/testdata/no-unicode.toml +++ /dev/null @@ -1,1506 +0,0 @@ -[ -[ -test -] -] -name -= -" -invalid -- -utf8 -- -literal1 -" -regex -= -' -\ -xFF -' -haystack -= -' -\ -xFF -' -matches -= -[ -[ -0 -1 -] -] -unicode -= -false -utf8 -= -false -unescape -= -true -[ -[ -test -] -] -name -= -" -mixed -" -regex -= -' -( -? -: -. -+ -) -( -? -- -u -) -( -? -: -. -+ -) -' -haystack -= -' -\ -xCE -\ -x93 -\ -xCE -\ -x94 -\ -xFF -' -matches -= -[ -[ -0 -5 -] -] -utf8 -= -false -unescape -= -true -[ -[ -test -] -] -name -= -" -case1 -" -regex -= -" -a -" -haystack -= -" -A -" -matches -= -[ -[ -0 -1 -] -] -case -- -insensitive -= -true -unicode -= -false -[ -[ -test -] -] -name -= -" -case2 -" -regex -= -" -[ -a -- -z -] -+ -" -haystack -= -" -AaAaA -" -matches -= -[ -[ -0 -5 -] -] -case -- -insensitive -= -true -unicode -= -false -[ -[ -test -] -] -name -= -" -case3 -" -regex -= -" -[ -a -- -z -] -+ -" -haystack -= -" -aA -\ -u212AaA -" -matches -= -[ -[ -0 -7 -] -] -case -- -insensitive -= -true -[ -[ -test -] -] -name -= -" -case4 -" -regex -= -" -[ -a -- -z -] -+ -" -haystack -= -" -aA -\ -u212AaA -" -matches -= -[ -[ -0 -2 -] -[ -5 -7 -] -] -case -- -insensitive -= -true -unicode -= -false -[ -[ -test -] -] -name -= -" -negate1 -" -regex -= -" -[ -^ -a -] -" -haystack -= -" -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -negate2 -" -regex -= -" -[ -^ -a -] -" -haystack -= -" -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -dotstar -- -prefix1 -" -regex -= -" -a -" -haystack -= -' -\ -xFFa -' -matches -= -[ -[ -1 -2 -] -] -unicode -= -false -utf8 -= -false -unescape -= -true -[ -[ -test -] -] -name -= -" -dotstar -- -prefix2 -" -regex -= -" -a -" -haystack -= -' -\ -xFFa -' -matches -= -[ -[ -1 -2 -] -] -utf8 -= -false -unescape -= -true -[ -[ -test -] -] -name -= -" -null -- -bytes1 -" -regex -= -' -[ -^ -\ -x00 -] -+ -\ -x00 -' -haystack -= -' -foo -\ -x00 -' -matches -= -[ -[ -0 -4 -] -] -unicode -= -false -utf8 -= -false -unescape -= -true -[ -[ -test -] -] -name -= -" -word -- -ascii -" -regex -= -' -\ -w -+ -' -haystack -= -" -a -" -matches -= -[ -[ -0 -1 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -word -- -unicode -" -regex -= -' -\ -w -+ -' -haystack -= -" -a -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -decimal -- -ascii -" -regex -= -' -\ -d -+ -' -haystack -= -" -1 -9 -" -matches -= -[ -[ -0 -1 -] -[ -7 -8 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -decimal -- -unicode -" -regex -= -' -\ -d -+ -' -haystack -= -" -1 -9 -" -matches -= -[ -[ -0 -8 -] -] -[ -[ -test -] -] -name -= -" -space -- -ascii -" -regex -= -' -\ -s -+ -' -haystack -= -" -\ -u1680 -" -matches -= -[ -[ -0 -1 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -space -- -unicode -" -regex -= -' -\ -s -+ -' -haystack -= -" -\ -u1680 -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -484 -name -= -" -iter1 -- -bytes -" -regex -= -' -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -utf8 -= -false -[ -[ -test -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -484 -name -= -" -iter1 -- -utf8 -" -regex -= -' -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -[ -3 -3 -] -] -[ -[ -test -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -484 -# -Note -that -iter2 -- -utf8 -doesn -' -t -make -sense -here -since -the -input -isn -' -t -UTF -- -8 -. -name -= -" -iter2 -- -bytes -" -regex -= -' -' -haystack -= -' -b -\ -xFFr -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -unescape -= -true -utf8 -= -false -# -These -test -that -unanchored -prefixes -can -munch -through -invalid -UTF -- -8 -even -when -# -utf8 -is -enabled -. -# -# -This -test -actually -reflects -an -interesting -simplification -in -how -the -Thompson -# -NFA -is -constructed -. -It -used -to -be -that -the -NFA -could -be -built -with -an -# -unanchored -prefix -that -either -matched -any -byte -or -_only_ -matched -valid -UTF -- -8 -. -# -But -the -latter -turns -out -to -be -pretty -precarious -when -it -comes -to -prefilters -# -because -if -you -search -a -haystack -that -contains -invalid -UTF -- -8 -but -have -an -# -unanchored -prefix -that -requires -UTF -- -8 -then -prefilters -are -no -longer -a -valid -# -optimization -because -you -actually -have -to -check -that -everything -is -valid -# -UTF -- -8 -. -# -# -Originally -I -had -thought -that -we -needed -a -valid -UTF -- -8 -unanchored -prefix -in -# -order -to -guarantee -that -we -only -match -at -valid -UTF -- -8 -boundaries -. -But -this -# -isn -' -t -actually -true -! -There -are -really -only -two -things -to -consider -here -: -# -# -1 -) -Will -a -regex -match -split -an -encoded -codepoint -? -No -. -Because -by -construction -# -we -ensure -that -a -MATCH -state -can -only -be -reached -by -following -valid -UTF -- -8 -( -assuming -# -all -of -the -UTF -- -8 -modes -are -enabled -) -. -# -# -2 -) -Will -a -regex -match -arbitrary -bytes -that -aren -' -t -valid -UTF -- -8 -? -Again -no -# -assuming -all -of -the -UTF -- -8 -modes -are -enabled -. -[ -[ -test -] -] -name -= -" -unanchored -- -invalid -- -utf8 -- -match -- -100 -" -regex -= -' -[ -a -- -z -] -' -haystack -= -' -\ -xFFa -\ -xFF -' -matches -= -[ -[ -1 -2 -] -] -unescape -= -true -utf8 -= -false -# -This -test -shows -that -we -can -still -prevent -a -match -from -occurring -by -requiring -# -that -valid -UTF -- -8 -match -by -inserting -our -own -unanchored -prefix -. -Thus -if -the -# -behavior -of -not -munching -through -invalid -UTF -- -8 -anywhere -is -needed -then -it -# -can -be -achieved -thusly -. -[ -[ -test -] -] -name -= -" -unanchored -- -invalid -- -utf8 -- -nomatch -" -regex -= -' -^ -( -? -s -: -. -) -* -? -[ -a -- -z -] -' -haystack -= -' -\ -xFFa -\ -xFF -' -matches -= -[ -] -unescape -= -true -utf8 -= -false -# -This -is -a -tricky -test -that -makes -sure -we -don -' -t -accidentally -do -a -kind -of -# -unanchored -search -when -we -' -ve -requested -that -a -regex -engine -not -report -# -empty -matches -that -split -a -codepoint -. -This -test -caught -a -regression -during -# -development -where -the -code -for -skipping -over -bad -empty -matches -would -do -so -# -even -if -the -search -should -have -been -anchored -. -This -is -ultimately -what -led -to -# -making -' -anchored -' -an -' -Input -' -option -so -that -it -was -always -clear -what -kind -# -of -search -was -being -performed -. -( -Before -that -whether -a -search -was -anchored -# -or -not -was -a -config -knob -on -the -regex -engine -. -) -This -did -wind -up -making -DFAs -# -a -little -more -complex -to -configure -( -with -their -' -StartKind -' -knob -) -but -it -# -generally -smoothed -out -everything -else -. -# -# -Great -example -of -a -test -whose -failure -motivated -a -sweeping -API -refactoring -. -[ -[ -test -] -] -name -= -" -anchored -- -iter -- -empty -- -utf8 -" -regex -= -' -' -haystack -= -' -a -z -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -unescape -= -false -utf8 -= -true -anchored -= -true diff --git a/third_party/rust/regex/testdata/overlapping.toml b/third_party/rust/regex/testdata/overlapping.toml deleted file mode 100644 index 504735e8a76f5..0000000000000 --- a/third_party/rust/regex/testdata/overlapping.toml +++ /dev/null @@ -1,2024 +0,0 @@ -# -NOTE -: -We -define -a -number -of -tests -where -the -* -match -* -kind -is -' -leftmost -- -first -' -# -but -the -* -search -* -kind -is -' -overlapping -' -. -This -is -a -somewhat -nonsensical -# -combination -and -can -produce -odd -results -. -Nevertheless -those -results -should -# -be -consistent -so -we -test -them -here -. -( -At -the -time -of -writing -this -note -I -# -hadn -' -t -yet -decided -whether -to -make -' -leftmost -- -first -' -with -' -overlapping -' -result -# -in -unspecified -behavior -. -) -# -This -demonstrates -how -a -full -overlapping -search -is -obvious -quadratic -. -This -# -regex -reports -a -match -for -every -substring -in -the -haystack -. -[ -[ -test -] -] -name -= -" -ungreedy -- -dotstar -- -matches -- -everything -- -100 -" -regex -= -[ -" -. -* -? -" -] -haystack -= -" -zzz -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -0 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -{ -id -= -0 -span -= -[ -2 -3 -] -} -{ -id -= -0 -span -= -[ -1 -3 -] -} -{ -id -= -0 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -greedy -- -dotstar -- -matches -- -everything -- -100 -" -regex -= -[ -" -. -* -" -] -haystack -= -" -zzz -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -0 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -{ -id -= -0 -span -= -[ -2 -3 -] -} -{ -id -= -0 -span -= -[ -1 -3 -] -} -{ -id -= -0 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -plus -- -leftmost -- -first -- -100 -" -regex -= -' -a -+ -' -haystack -= -" -aaa -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -[ -0 -2 -] -[ -2 -3 -] -[ -1 -3 -] -[ -0 -3 -] -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -plus -- -leftmost -- -first -- -110 -" -regex -= -' -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -[ -3 -6 -] -[ -0 -6 -] -[ -6 -9 -] -[ -3 -9 -] -[ -0 -9 -] -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -plus -- -all -- -100 -" -regex -= -' -a -+ -' -haystack -= -" -aaa -" -matches -= -[ -[ -0 -1 -] -[ -1 -2 -] -[ -0 -2 -] -[ -2 -3 -] -[ -1 -3 -] -[ -0 -3 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -plus -- -all -- -110 -" -regex -= -' -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -[ -3 -6 -] -[ -0 -6 -] -[ -6 -9 -] -[ -3 -9 -] -[ -0 -9 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -plus -- -leftmost -- -first -- -200 -" -regex -= -' -( -abc -) -+ -' -haystack -= -" -zzabcabczzabc -" -matches -= -[ -[ -[ -2 -5 -] -[ -2 -5 -] -] -[ -[ -5 -8 -] -[ -5 -8 -] -] -[ -[ -2 -8 -] -[ -5 -8 -] -] -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -plus -- -all -- -200 -" -regex -= -' -( -abc -) -+ -' -haystack -= -" -zzabcabczzabc -" -matches -= -[ -[ -[ -2 -5 -] -[ -2 -5 -] -] -[ -[ -5 -8 -] -[ -5 -8 -] -] -[ -[ -2 -8 -] -[ -5 -8 -] -] -[ -[ -10 -13 -] -[ -10 -13 -] -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -star -- -leftmost -- -first -- -100 -" -regex -= -' -a -* -' -haystack -= -" -aaa -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -0 -1 -] -[ -2 -2 -] -[ -1 -2 -] -[ -0 -2 -] -[ -3 -3 -] -[ -2 -3 -] -[ -1 -3 -] -[ -0 -3 -] -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -star -- -all -- -100 -" -regex -= -' -a -* -' -haystack -= -" -aaa -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -0 -1 -] -[ -2 -2 -] -[ -1 -2 -] -[ -0 -2 -] -[ -3 -3 -] -[ -2 -3 -] -[ -1 -3 -] -[ -0 -3 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -star -- -leftmost -- -first -- -200 -" -regex -= -' -( -abc -) -* -' -haystack -= -" -zzabcabczzabc -" -matches -= -[ -[ -[ -0 -0 -] -[ -] -] -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -repetition -- -star -- -all -- -200 -" -regex -= -' -( -abc -) -* -' -haystack -= -" -zzabcabczzabc -" -matches -= -[ -[ -[ -0 -0 -] -[ -] -] -[ -[ -1 -1 -] -[ -] -] -[ -[ -2 -2 -] -[ -] -] -[ -[ -3 -3 -] -[ -] -] -[ -[ -4 -4 -] -[ -] -] -[ -[ -5 -5 -] -[ -] -] -[ -[ -2 -5 -] -[ -2 -5 -] -] -[ -[ -6 -6 -] -[ -] -] -[ -[ -7 -7 -] -[ -] -] -[ -[ -8 -8 -] -[ -] -] -[ -[ -5 -8 -] -[ -5 -8 -] -] -[ -[ -2 -8 -] -[ -5 -8 -] -] -[ -[ -9 -9 -] -[ -] -] -[ -[ -10 -10 -] -[ -] -] -[ -[ -11 -11 -] -[ -] -] -[ -[ -12 -12 -] -[ -] -] -[ -[ -13 -13 -] -[ -] -] -[ -[ -10 -13 -] -[ -10 -13 -] -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -start -- -end -- -rep -- -leftmost -- -first -" -regex -= -' -( -^ -) -* -' -haystack -= -" -abc -" -matches -= -[ -[ -[ -0 -0 -] -[ -] -] -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -start -- -end -- -rep -- -all -" -regex -= -' -( -^ -) -* -' -haystack -= -" -abc -" -matches -= -[ -[ -[ -0 -0 -] -[ -] -] -[ -[ -1 -1 -] -[ -] -] -[ -[ -2 -2 -] -[ -] -] -[ -[ -3 -3 -] -[ -] -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -alt -- -leftmost -- -first -- -100 -" -regex -= -' -abc -| -a -' -haystack -= -" -zzabcazzaabc -" -matches -= -[ -[ -2 -3 -] -[ -2 -5 -] -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -alt -- -all -- -100 -" -regex -= -' -abc -| -a -' -haystack -= -" -zzabcazzaabc -" -matches -= -[ -[ -2 -3 -] -[ -2 -5 -] -[ -5 -6 -] -[ -8 -9 -] -[ -9 -10 -] -[ -9 -12 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty -- -000 -" -regex -= -" -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty -- -alt -- -000 -" -regex -= -" -| -b -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -1 -2 -] -[ -3 -3 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty -- -alt -- -010 -" -regex -= -" -b -| -" -haystack -= -" -abc -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -1 -2 -] -[ -3 -3 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -484 -name -= -" -iter1 -- -bytes -" -regex -= -' -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -484 -name -= -" -iter1 -- -utf8 -" -regex -= -' -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -[ -3 -3 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -iter1 -- -incomplete -- -utf8 -" -regex -= -' -' -haystack -= -' -\ -xE2 -\ -x98 -' -# -incomplete -snowman -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -unescape -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -scratch -" -regex -= -[ -' -sam -' -' -samwise -' -] -haystack -= -" -samwise -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -overlapping -" diff --git a/third_party/rust/regex/testdata/regex-lite.toml b/third_party/rust/regex/testdata/regex-lite.toml deleted file mode 100644 index 93be606efdf21..0000000000000 --- a/third_party/rust/regex/testdata/regex-lite.toml +++ /dev/null @@ -1,696 +0,0 @@ -# -These -tests -are -specifically -written -to -test -the -regex -- -lite -crate -. -While -it -# -largely -has -the -same -semantics -as -the -regex -crate -there -are -some -differences -# -around -Unicode -support -and -UTF -- -8 -. -# -# -To -be -clear -regex -- -lite -supports -far -fewer -patterns -because -of -its -lack -of -# -Unicode -support -nested -character -classes -and -character -class -set -operations -. -# -What -we -' -re -talking -about -here -are -the -patterns -that -both -crates -support -but -# -where -the -semantics -might -differ -. -# -regex -- -lite -uses -ASCII -definitions -for -Perl -character -classes -. -[ -[ -test -] -] -name -= -" -perl -- -class -- -decimal -" -regex -= -' -\ -d -' -haystack -= -' -' -matches -= -[ -] -unicode -= -true -# -regex -- -lite -uses -ASCII -definitions -for -Perl -character -classes -. -[ -[ -test -] -] -name -= -" -perl -- -class -- -space -" -regex -= -' -\ -s -' -haystack -= -" -\ -u2000 -" -matches -= -[ -] -unicode -= -true -# -regex -- -lite -uses -ASCII -definitions -for -Perl -character -classes -. -[ -[ -test -] -] -name -= -" -perl -- -class -- -word -" -regex -= -' -\ -w -' -haystack -= -' -' -matches -= -[ -] -unicode -= -true -# -regex -- -lite -uses -the -ASCII -definition -of -word -for -word -boundary -assertions -. -[ -[ -test -] -] -name -= -" -word -- -boundary -" -regex -= -' -\ -b -' -haystack -= -' -' -matches -= -[ -] -unicode -= -true -# -regex -- -lite -uses -the -ASCII -definition -of -word -for -negated -word -boundary -# -assertions -. -But -note -that -it -should -still -not -split -codepoints -! -[ -[ -test -] -] -name -= -" -word -- -boundary -- -negated -" -regex -= -' -\ -B -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -] -unicode -= -true -# -While -we -' -re -here -the -empty -regex -- -- -- -which -matches -at -every -# -position -- -- -- -shouldn -' -t -split -a -codepoint -either -. -[ -[ -test -] -] -name -= -" -empty -- -no -- -split -- -codepoint -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -[ -4 -4 -] -] -unicode -= -true -# -A -dot -always -matches -a -full -codepoint -. -[ -[ -test -] -] -name -= -" -dot -- -always -- -matches -- -codepoint -" -regex -= -' -. -' -haystack -= -' -' -matches -= -[ -[ -0 -4 -] -] -unicode -= -false -# -A -negated -character -class -also -always -matches -a -full -codepoint -. -[ -[ -test -] -] -name -= -" -negated -- -class -- -always -- -matches -- -codepoint -" -regex -= -' -[ -^ -a -] -' -haystack -= -' -' -matches -= -[ -[ -0 -4 -] -] -unicode -= -false -# -regex -- -lite -only -supports -ASCII -- -aware -case -insensitive -matching -. -[ -[ -test -] -] -name -= -" -case -- -insensitive -- -is -- -ascii -- -only -" -regex -= -' -s -' -haystack -= -' -' -matches -= -[ -] -unicode -= -true -case -- -insensitive -= -true -# -Negated -word -boundaries -shouldn -' -t -split -a -codepoint -but -they -will -match -# -between -invalid -UTF -- -8 -. -# -# -This -test -is -only -valid -for -a -' -bytes -' -API -but -that -doesn -' -t -( -yet -) -exist -in -# -regex -- -lite -. -This -can -' -t -happen -in -the -main -API -because -& -str -can -' -t -contain -# -invalid -UTF -- -8 -. -# -[ -[ -test -] -] -# -name -= -" -word -- -boundary -- -invalid -- -utf8 -" -# -regex -= -' -\ -B -' -# -haystack -= -' -\ -xFF -\ -xFF -\ -xFF -\ -xFF -' -# -unescape -= -true -# -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -# -unicode -= -true -# -utf8 -= -false diff --git a/third_party/rust/regex/testdata/regression.toml b/third_party/rust/regex/testdata/regression.toml deleted file mode 100644 index cb6829ea94c1e..0000000000000 --- a/third_party/rust/regex/testdata/regression.toml +++ /dev/null @@ -1,7364 +0,0 @@ -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -48 -[ -[ -test -] -] -name -= -" -invalid -- -regex -- -no -- -crash -- -100 -" -regex -= -' -( -* -) -' -haystack -= -" -" -matches -= -[ -] -compiles -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -48 -[ -[ -test -] -] -name -= -" -invalid -- -regex -- -no -- -crash -- -200 -" -regex -= -' -( -? -: -? -) -' -haystack -= -" -" -matches -= -[ -] -compiles -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -48 -[ -[ -test -] -] -name -= -" -invalid -- -regex -- -no -- -crash -- -300 -" -regex -= -' -( -? -) -' -haystack -= -" -" -matches -= -[ -] -compiles -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -48 -[ -[ -test -] -] -name -= -" -invalid -- -regex -- -no -- -crash -- -400 -" -regex -= -' -* -' -haystack -= -" -" -matches -= -[ -] -compiles -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -75 -[ -[ -test -] -] -name -= -" -unsorted -- -binary -- -search -- -100 -" -regex -= -' -( -? -i -- -u -) -[ -a_ -] -+ -' -haystack -= -" -A_ -" -matches -= -[ -[ -0 -2 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -75 -[ -[ -test -] -] -name -= -" -unsorted -- -binary -- -search -- -200 -" -regex -= -' -( -? -i -- -u -) -[ -A_ -] -+ -' -haystack -= -" -a_ -" -matches -= -[ -[ -0 -2 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -76 -[ -[ -test -] -] -name -= -" -unicode -- -case -- -lower -- -nocase -- -flag -" -regex -= -' -( -? -i -) -\ -p -{ -Ll -} -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -10 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -99 -[ -[ -test -] -] -name -= -" -negated -- -char -- -class -- -100 -" -regex -= -' -( -? -i -) -[ -^ -x -] -' -haystack -= -" -x -" -matches -= -[ -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -99 -[ -[ -test -] -] -name -= -" -negated -- -char -- -class -- -200 -" -regex -= -' -( -? -i -) -[ -^ -x -] -' -haystack -= -" -X -" -matches -= -[ -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -101 -[ -[ -test -] -] -name -= -" -ascii -- -word -- -underscore -" -regex -= -' -[ -[ -: -word -: -] -] -' -haystack -= -" -_ -" -matches -= -[ -[ -0 -1 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -129 -[ -[ -test -] -] -name -= -" -captures -- -repeat -" -regex -= -' -( -[ -a -- -f -] -) -{ -2 -} -( -? -P -< -foo -> -[ -x -- -z -] -) -' -haystack -= -" -abx -" -matches -= -[ -[ -[ -0 -3 -] -[ -1 -2 -] -[ -2 -3 -] -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -153 -[ -[ -test -] -] -name -= -" -alt -- -in -- -alt -- -100 -" -regex -= -' -ab -? -| -' -haystack -= -" -az -" -matches -= -[ -[ -0 -1 -] -[ -2 -2 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -153 -[ -[ -test -] -] -name -= -" -alt -- -in -- -alt -- -200 -" -regex -= -' -^ -( -? -: -. -* -? -) -( -? -: -\ -n -| -\ -r -\ -n -? -| -) -' -haystack -= -" -ab -\ -rcd -" -matches -= -[ -[ -0 -3 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -169 -[ -[ -test -] -] -name -= -" -leftmost -- -first -- -prefix -" -regex -= -' -z -* -azb -' -haystack -= -" -azb -" -matches -= -[ -[ -0 -3 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -191 -[ -[ -test -] -] -name -= -" -many -- -alternates -" -regex -= -' -1 -| -2 -| -3 -| -4 -| -5 -| -6 -| -7 -| -8 -| -9 -| -10 -| -int -' -haystack -= -" -int -" -matches -= -[ -[ -0 -3 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -204 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -alone -- -100 -" -regex -= -' -\ -b -' -haystack -= -" -Should -this -( -work -? -) -" -matches -= -[ -[ -0 -0 -] -[ -6 -6 -] -[ -7 -7 -] -[ -11 -11 -] -[ -13 -13 -] -[ -17 -17 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -204 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -alone -- -200 -" -regex -= -' -\ -b -' -haystack -= -" -a -b -c -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -264 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -ascii -- -no -- -capture -" -regex -= -' -\ -B -' -haystack -= -" -\ -U00028F3E -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -unicode -= -false -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -264 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -ascii -- -capture -" -regex -= -' -( -? -: -\ -B -) -' -haystack -= -" -\ -U00028F3E -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -unicode -= -false -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -268 -[ -[ -test -] -] -name -= -" -partial -- -anchor -" -regex -= -' -^ -a -| -b -' -haystack -= -" -ba -" -matches -= -[ -[ -0 -1 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -271 -[ -[ -test -] -] -name -= -" -endl -- -or -- -word -- -boundary -" -regex -= -' -( -? -m -: -) -| -( -? -- -u -: -\ -b -) -' -haystack -= -" -\ -U0006084E -" -matches -= -[ -[ -4 -4 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -271 -[ -[ -test -] -] -name -= -" -zero -- -or -- -end -" -regex -= -' -( -? -i -- -u -: -\ -x00 -) -| -' -haystack -= -" -\ -U000E682F -" -matches -= -[ -[ -4 -4 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -271 -[ -[ -test -] -] -name -= -" -y -- -or -- -endl -" -regex -= -' -( -? -i -- -u -: -y -) -| -( -? -m -: -) -' -haystack -= -" -\ -U000B4331 -" -matches -= -[ -[ -4 -4 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -271 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -start -- -x -" -regex -= -' -( -? -u -: -\ -b -) -^ -( -? -- -u -: -X -) -' -haystack -= -" -X -" -matches -= -[ -[ -0 -1 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -271 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -ascii -- -start -- -x -" -regex -= -' -( -? -- -u -: -\ -b -) -^ -( -? -- -u -: -X -) -' -haystack -= -" -X -" -matches -= -[ -[ -0 -1 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -271 -[ -[ -test -] -] -name -= -" -end -- -not -- -word -- -boundary -" -regex -= -' -\ -B -' -haystack -= -" -\ -U0005C124 -\ -U000B576C -" -matches -= -[ -[ -8 -8 -] -] -unicode -= -false -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -280 -[ -[ -test -] -] -name -= -" -partial -- -anchor -- -alternate -- -begin -" -regex -= -' -^ -a -| -z -' -haystack -= -" -yyyyya -" -matches -= -[ -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -280 -[ -[ -test -] -] -name -= -" -partial -- -anchor -- -alternate -- -end -" -regex -= -' -a -| -z -' -haystack -= -" -ayyyyy -" -matches -= -[ -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -289 -[ -[ -test -] -] -name -= -" -lits -- -unambiguous -- -100 -" -regex -= -' -( -? -: -ABC -| -CDA -| -BC -) -X -' -haystack -= -" -CDAX -" -matches -= -[ -[ -0 -4 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -291 -[ -[ -test -] -] -name -= -" -lits -- -unambiguous -- -200 -" -regex -= -' -( -( -IMG -| -CAM -| -MG -| -MB2 -) -_ -| -( -DSCN -| -CIMG -) -) -( -? -P -< -n -> -[ -0 -- -9 -] -+ -) -' -haystack -= -" -CIMG2341 -" -matches -= -[ -[ -[ -0 -8 -] -[ -0 -4 -] -[ -] -[ -0 -4 -] -[ -4 -8 -] -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -303 -# -# -2022 -- -09 -- -19 -: -This -has -now -been -" -properly -" -fixed -in -that -empty -character -# -classes -are -fully -supported -as -something -that -can -never -match -. -This -test -# -used -to -be -marked -as -' -compiles -= -false -' -but -now -it -works -. -[ -[ -test -] -] -name -= -" -negated -- -full -- -byte -- -range -" -regex -= -' -[ -^ -\ -x00 -- -\ -xFF -] -' -haystack -= -" -" -matches -= -[ -] -compiles -= -true -unicode -= -false -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -321 -[ -[ -test -] -] -name -= -" -strange -- -anchor -- -non -- -complete -- -prefix -" -regex -= -' -a -^ -{ -2 -} -' -haystack -= -" -" -matches -= -[ -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -321 -[ -[ -test -] -] -name -= -" -strange -- -anchor -- -non -- -complete -- -suffix -" -regex -= -' -{ -2 -} -a -' -haystack -= -" -" -matches -= -[ -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -334 -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -557 -[ -[ -test -] -] -name -= -" -captures -- -after -- -dfa -- -premature -- -end -- -100 -" -regex -= -' -a -( -b -* -( -X -| -) -) -? -' -haystack -= -" -abcbX -" -matches -= -[ -[ -[ -0 -1 -] -[ -] -[ -] -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -334 -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -557 -[ -[ -test -] -] -name -= -" -captures -- -after -- -dfa -- -premature -- -end -- -200 -" -regex -= -' -a -( -bc -* -( -X -| -) -) -? -' -haystack -= -" -abcbX -" -matches -= -[ -[ -[ -0 -1 -] -[ -] -[ -] -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -334 -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -557 -[ -[ -test -] -] -name -= -" -captures -- -after -- -dfa -- -premature -- -end -- -300 -" -regex -= -' -( -aa -) -? -' -haystack -= -" -aaz -" -matches -= -[ -[ -[ -0 -0 -] -[ -] -] -[ -[ -1 -1 -] -[ -] -] -[ -[ -2 -2 -] -[ -] -] -[ -[ -3 -3 -] -[ -] -] -] -# -Plucked -from -" -Why -aren -t -regular -expressions -a -lingua -franca -? -an -empirical -# -study -on -the -re -- -use -and -portability -of -regular -expressions -" -The -ACM -Joint -# -European -Software -Engineering -Conference -and -Symposium -on -the -Foundations -of -# -Software -Engineering -( -ESEC -/ -FSE -) -2019 -. -# -# -Link -: -https -: -/ -/ -dl -. -acm -. -org -/ -doi -/ -pdf -/ -10 -. -1145 -/ -3338906 -. -3338909 -[ -[ -test -] -] -name -= -" -captures -- -after -- -dfa -- -premature -- -end -- -400 -" -regex -= -' -( -a -) -\ -d -* -\ -. -? -\ -d -+ -\ -b -' -haystack -= -" -a0 -. -0c -" -matches -= -[ -[ -[ -0 -2 -] -[ -0 -1 -] -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -437 -[ -[ -test -] -] -name -= -" -literal -- -panic -" -regex -= -' -typename -type -\ -- -parameter -\ -- -[ -0 -- -9 -] -+ -\ -- -[ -0 -- -9 -] -+ -: -: -. -+ -' -haystack -= -" -test -" -matches -= -[ -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -527 -[ -[ -test -] -] -name -= -" -empty -- -flag -- -expr -" -regex -= -' -( -? -: -( -? -: -( -? -x -) -) -) -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -533 -# -[ -[ -tests -] -] -# -name -= -" -blank -- -matches -- -nothing -- -between -- -space -- -and -- -tab -" -# -regex -= -' -[ -[ -: -blank -: -] -] -' -# -input -= -' -\ -x0A -\ -x0B -\ -x0C -\ -x0D -\ -x0E -\ -x0F -\ -x10 -\ -x11 -\ -x12 -\ -x13 -\ -x14 -\ -x15 -\ -x16 -\ -x17 -\ -x18 -\ -x19 -\ -x1A -\ -x1B -\ -x1C -\ -x1D -\ -x1E -\ -x1F -' -# -match -= -false -# -unescape -= -true -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -533 -# -[ -[ -tests -] -] -# -name -= -" -blank -- -matches -- -nothing -- -between -- -space -- -and -- -tab -- -inverted -" -# -regex -= -' -^ -[ -[ -: -^ -blank -: -] -] -+ -' -# -input -= -' -\ -x0A -\ -x0B -\ -x0C -\ -x0D -\ -x0E -\ -x0F -\ -x10 -\ -x11 -\ -x12 -\ -x13 -\ -x14 -\ -x15 -\ -x16 -\ -x17 -\ -x18 -\ -x19 -\ -x1A -\ -x1B -\ -x1C -\ -x1D -\ -x1E -\ -x1F -' -# -match -= -true -# -unescape -= -true -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -555 -[ -[ -test -] -] -name -= -" -invalid -- -repetition -" -regex -= -' -( -? -m -) -{ -1 -1 -} -' -haystack -= -" -" -matches -= -[ -] -compiles -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -640 -[ -[ -test -] -] -name -= -" -flags -- -are -- -unset -" -regex -= -' -( -? -: -( -? -i -) -foo -) -| -Bar -' -haystack -= -" -foo -Foo -bar -Bar -" -matches -= -[ -[ -0 -3 -] -[ -4 -7 -] -[ -12 -15 -] -] -# -Note -that -' -' -is -not -' -j -' -but -cyrillic -Je -# -https -: -/ -/ -en -. -wikipedia -. -org -/ -wiki -/ -Je_ -( -Cyrillic -) -# -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -659 -[ -[ -test -] -] -name -= -" -empty -- -group -- -with -- -unicode -" -regex -= -' -( -? -: -) -01 -' -haystack -= -' -z -01 -' -matches -= -[ -[ -1 -5 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -579 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -weird -" -regex -= -' -\ -b -. -. -\ -b -' -haystack -= -" -I -have -12 -he -has -2 -! -" -matches -= -[ -[ -0 -2 -] -[ -7 -9 -] -[ -9 -11 -] -[ -11 -13 -] -[ -17 -19 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -579 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -weird -- -ascii -" -regex -= -' -\ -b -. -. -\ -b -' -haystack -= -" -I -have -12 -he -has -2 -! -" -matches -= -[ -[ -0 -2 -] -[ -7 -9 -] -[ -9 -11 -] -[ -11 -13 -] -[ -17 -19 -] -] -unicode -= -false -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -579 -[ -[ -test -] -] -name -= -" -word -- -boundary -- -weird -- -minimal -- -ascii -" -regex -= -' -\ -b -. -. -\ -b -' -haystack -= -" -az -b -" -matches -= -[ -[ -0 -2 -] -[ -2 -4 -] -] -unicode -= -false -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -ripgrep -/ -issues -/ -1203 -[ -[ -test -] -] -name -= -" -reverse -- -suffix -- -100 -" -regex -= -' -[ -0 -- -4 -] -[ -0 -- -4 -] -[ -0 -- -4 -] -000 -' -haystack -= -" -153 -. -230000 -" -matches -= -[ -[ -4 -10 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -ripgrep -/ -issues -/ -1203 -[ -[ -test -] -] -name -= -" -reverse -- -suffix -- -200 -" -regex -= -' -[ -0 -- -9 -] -[ -0 -- -9 -] -[ -0 -- -9 -] -000 -' -haystack -= -" -153 -. -230000 -\ -n -" -matches -= -[ -[ -4 -10 -] -] -# -This -is -a -tricky -case -for -the -reverse -suffix -optimization -because -it -# -finds -the -' -foobar -' -match -but -the -reverse -scan -must -fail -to -find -a -match -by -# -correctly -dealing -with -the -word -boundary -following -the -' -foobar -' -literal -when -# -computing -the -start -state -. -# -# -This -test -exists -because -I -tried -to -break -the -following -assumption -that -# -is -currently -in -the -code -: -that -if -a -suffix -is -found -and -the -reverse -scan -# -succeeds -then -it -' -s -guaranteed -that -there -is -an -overall -match -. -Namely -the -# -' -is_match -' -routine -does -* -not -* -do -another -forward -scan -in -this -case -because -of -# -this -assumption -. -[ -[ -test -] -] -name -= -" -reverse -- -suffix -- -300 -" -regex -= -' -\ -w -+ -foobar -\ -b -' -haystack -= -" -xyzfoobarZ -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -ripgrep -/ -issues -/ -1247 -[ -[ -test -] -] -name -= -" -stops -" -regex -= -' -\ -bs -( -? -: -[ -ab -] -) -' -haystack -= -' -s -\ -xE4 -' -matches -= -[ -] -unescape -= -true -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -BurntSushi -/ -ripgrep -/ -issues -/ -1247 -[ -[ -test -] -] -name -= -" -stops -- -ascii -" -regex -= -' -( -? -- -u -: -\ -b -) -s -( -? -: -[ -ab -] -) -' -haystack -= -' -s -\ -xE4 -' -matches -= -[ -] -unescape -= -true -utf8 -= -false -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -850 -[ -[ -test -] -] -name -= -" -adjacent -- -line -- -boundary -- -100 -" -regex -= -' -( -? -m -) -^ -( -? -: -[ -^ -] -+ -? -) -' -haystack -= -" -line1 -\ -nline2 -" -matches -= -[ -[ -0 -5 -] -[ -6 -11 -] -] -# -Continued -. -[ -[ -test -] -] -name -= -" -adjacent -- -line -- -boundary -- -200 -" -regex -= -' -( -? -m -) -^ -( -? -: -[ -^ -] -+ -? -) -' -haystack -= -" -A -\ -nB -" -matches -= -[ -[ -0 -1 -] -[ -2 -3 -] -] -# -There -is -no -issue -for -this -bug -. -[ -[ -test -] -] -name -= -" -anchored -- -prefix -- -100 -" -regex -= -' -^ -a -[ -[ -: -^ -space -: -] -] -' -haystack -= -" -a -" -matches -= -[ -] -# -There -is -no -issue -for -this -bug -. -[ -[ -test -] -] -name -= -" -anchored -- -prefix -- -200 -" -regex -= -' -^ -a -[ -[ -: -^ -space -: -] -] -' -haystack -= -" -foo -boo -a -" -matches -= -[ -] -# -There -is -no -issue -for -this -bug -. -[ -[ -test -] -] -name -= -" -anchored -- -prefix -- -300 -" -regex -= -' -^ -- -[ -a -- -z -] -' -haystack -= -" -r -- -f -" -matches -= -[ -] -# -Tests -that -a -possible -Aho -- -Corasick -optimization -works -correctly -. -It -only -# -kicks -in -when -we -have -a -lot -of -literals -. -By -" -works -correctly -" -we -mean -that -# -leftmost -- -first -match -semantics -are -properly -respected -. -That -is -samwise -# -should -match -not -sam -. -# -# -There -is -no -issue -for -this -bug -. -[ -[ -test -] -] -name -= -" -aho -- -corasick -- -100 -" -regex -= -' -samwise -| -sam -| -a -| -b -| -c -| -d -| -e -| -f -| -g -| -h -| -i -| -j -| -k -| -l -| -m -| -n -| -o -| -p -| -q -| -r -| -s -| -t -| -u -| -v -| -w -| -x -| -y -| -z -| -A -| -B -| -C -| -D -| -E -| -F -| -G -| -H -| -I -| -J -| -K -| -L -| -M -| -N -| -O -| -P -| -Q -| -R -| -S -| -T -| -U -| -V -| -W -| -X -| -Y -| -Z -' -haystack -= -" -samwise -" -matches -= -[ -[ -0 -7 -] -] -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -921 -[ -[ -test -] -] -name -= -" -interior -- -anchor -- -capture -" -regex -= -' -( -a -) -b -' -haystack -= -' -ab -' -matches -= -[ -] -# -I -found -this -bug -in -the -course -of -adding -some -of -the -regexes -that -Ruff -uses -# -to -rebar -. -It -turns -out -that -the -lazy -DFA -was -finding -a -match -that -was -being -# -rejected -by -the -one -- -pass -DFA -. -Yikes -. -I -then -minimized -the -regex -and -haystack -. -# -# -Source -: -https -: -/ -/ -github -. -com -/ -charliermarsh -/ -ruff -/ -blob -/ -a919041ddaa64cdf6f216f90dd0480dab69fd3ba -/ -crates -/ -ruff -/ -src -/ -rules -/ -pycodestyle -/ -rules -/ -whitespace_around_keywords -. -rs -# -L52 -[ -[ -test -] -] -name -= -" -ruff -- -whitespace -- -around -- -keywords -" -regex -= -' -^ -( -a -| -ab -) -' -haystack -= -" -ab -" -anchored -= -true -unicode -= -false -utf8 -= -true -matches -= -[ -[ -[ -0 -2 -] -[ -0 -2 -] -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -0 -" -regex -= -' -( -? -: -( -? -- -u -: -\ -b -) -| -( -? -u -: -h -) -) -+ -' -haystack -= -" -h -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -1 -" -regex -= -' -( -? -u -: -\ -B -) -' -haystack -= -" -" -unicode -= -true -utf8 -= -false -matches -= -[ -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -2 -" -regex -= -' -( -? -: -( -? -u -: -\ -b -) -| -( -? -s -- -u -: -. -) -) -+ -' -haystack -= -" -oB -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -0 -0 -] -[ -1 -2 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -3 -" -regex -= -' -( -? -: -( -? -- -u -: -\ -B -) -| -( -? -su -: -. -) -) -+ -' -haystack -= -" -\ -U000FEF80 -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -3 -- -utf8 -" -regex -= -' -( -? -: -( -? -- -u -: -\ -B -) -| -( -? -su -: -. -) -) -+ -' -haystack -= -" -\ -U000FEF80 -" -unicode -= -true -utf8 -= -true -matches -= -[ -[ -0 -0 -] -[ -4 -4 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -4 -" -regex -= -' -( -? -m -: -) -( -? -m -: -^ -) -( -? -su -: -. -) -' -haystack -= -" -\ -n -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -0 -1 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -5 -" -regex -= -' -( -? -m -: -) -^ -( -? -m -: -^ -) -' -haystack -= -" -\ -n -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -0 -0 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -6 -" -regex -= -' -( -? -P -< -kp -> -( -? -iu -: -do -) -( -? -m -: -) -) -* -' -haystack -= -" -dodo -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -[ -0 -0 -] -[ -] -] -[ -[ -1 -1 -] -[ -] -] -[ -[ -2 -4 -] -[ -2 -4 -] -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -7 -" -regex -= -' -( -? -u -: -\ -B -) -' -haystack -= -" -" -unicode -= -true -utf8 -= -false -matches -= -[ -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -8 -" -regex -= -' -( -? -: -( -? -- -u -: -\ -b -) -| -( -? -u -: -[ -\ -u -{ -0 -} -- -W -] -) -) -+ -' -haystack -= -" -0 -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -9 -" -regex -= -' -( -( -? -m -: -) -( -? -- -u -: -\ -B -) -( -? -s -- -u -: -. -) -( -? -- -u -: -\ -B -) -) -' -haystack -= -" -\ -n -\ -n -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -[ -1 -2 -] -[ -1 -2 -] -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -10 -" -regex -= -' -( -? -m -: -) -( -? -m -: -) -^ -( -? -su -: -. -) -' -haystack -= -" -\ -n -\ -u0081 -\ -u200a -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -0 -1 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -11 -" -regex -= -' -( -? -- -u -: -\ -B -) -( -? -m -: -^ -) -' -haystack -= -" -0 -\ -n -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -2 -2 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -429 -[ -[ -test -] -] -name -= -" -i429 -- -12 -" -regex -= -' -( -? -: -( -? -u -: -\ -b -) -| -( -? -- -u -: -. -) -) -+ -' -haystack -= -" -0 -" -unicode -= -true -utf8 -= -false -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -969 -[ -[ -test -] -] -name -= -" -i969 -" -regex -= -' -c -. -* -d -\ -z -' -haystack -= -" -ababcd -" -bounds -= -[ -4 -6 -] -search -- -kind -= -" -earliest -" -matches -= -[ -[ -4 -6 -] -] -# -I -found -this -during -the -regex -- -automata -migration -. -This -is -the -fowler -basic -# -154 -test -but -without -anchored -= -true -and -without -a -match -limit -. -# -# -This -test -caught -a -subtle -bug -in -the -hybrid -reverse -DFA -search -where -it -# -would -skip -over -the -termination -condition -if -it -entered -a -start -state -. -This -# -was -a -double -bug -. -Firstly -the -reverse -DFA -shouldn -' -t -have -had -start -states -# -specialized -in -the -first -place -and -thus -it -shouldn -' -t -have -possible -to -detect -# -that -the -DFA -had -entered -a -start -state -. -The -second -bug -was -that -the -start -# -state -handling -was -incorrect -by -jumping -over -the -termination -condition -. -[ -[ -test -] -] -name -= -" -fowler -- -basic154 -- -unanchored -" -regex -= -' -' -' -a -( -[ -bc -] -* -) -c -* -' -' -' -haystack -= -' -' -' -abc -' -' -' -matches -= -[ -[ -[ -0 -3 -] -[ -1 -3 -] -] -] -# -From -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -981 -# -# -This -was -never -really -a -problem -in -the -new -architecture -because -the -# -regex -- -automata -engines -are -far -more -principled -about -how -they -deal -with -# -look -- -around -. -( -This -was -one -of -the -many -reasons -I -wanted -to -re -- -work -the -# -original -regex -crate -engines -. -) -[ -[ -test -] -] -name -= -" -word -- -boundary -- -interact -- -poorly -- -with -- -literal -- -optimizations -" -regex -= -' -( -? -i -: -( -? -: -\ -b -| -_ -) -win -( -? -: -32 -| -64 -| -dows -) -? -( -? -: -\ -b -| -_ -) -) -' -haystack -= -' -ubi -- -Darwin -- -x86_64 -. -tar -. -gz -' -matches -= -[ -] -# -This -was -found -during -fuzz -testing -of -regex -. -It -provoked -a -panic -in -the -meta -# -engine -as -a -result -of -the -reverse -suffix -optimization -. -Namely -it -hit -a -case -# -where -a -suffix -match -was -found -a -corresponding -reverse -match -was -found -but -# -the -forward -search -turned -up -no -match -. -The -forward -search -should -always -match -# -if -the -suffix -and -reverse -search -match -. -# -# -This -in -turn -uncovered -an -inconsistency -between -the -PikeVM -and -the -DFA -( -lazy -# -and -fully -compiled -) -engines -. -It -was -caused -by -a -mishandling -of -the -collection -# -of -NFA -state -IDs -in -the -generic -determinization -code -( -which -is -why -both -types -# -of -DFA -were -impacted -) -. -Namely -when -a -fail -state -was -encountered -( -that -' -s -the -# -[ -^ -\ -s -\ -S -] -in -the -pattern -below -) -then -it -would -just -stop -collecting -states -. -# -But -that -' -s -not -correct -since -a -later -state -could -lead -to -a -match -. -[ -[ -test -] -] -name -= -" -impossible -- -branch -" -regex -= -' -. -* -[ -^ -\ -s -\ -S -] -A -| -B -' -haystack -= -" -B -" -matches -= -[ -[ -0 -1 -] -] -# -This -was -found -during -fuzz -testing -in -regex -- -lite -. -The -regex -crate -never -# -suffered -from -this -bug -but -it -causes -regex -- -lite -to -incorrectly -compile -# -captures -. -[ -[ -test -] -] -name -= -" -captures -- -wrong -- -order -" -regex -= -' -( -a -) -{ -0 -} -( -a -) -' -haystack -= -' -a -' -matches -= -[ -[ -[ -0 -1 -] -[ -] -[ -0 -1 -] -] -] -# -This -tests -a -bug -in -how -quit -states -are -handled -in -the -DFA -. -At -some -point -# -during -development -the -DFAs -were -tweaked -slightly -such -that -if -they -hit -# -a -quit -state -( -which -means -they -hit -a -byte -that -the -caller -configured -should -# -stop -the -search -) -then -it -might -not -return -an -error -necessarily -. -Namely -if -a -# -match -had -already -been -found -then -it -would -be -returned -instead -of -an -error -. -# -# -But -this -is -actually -wrong -! -Why -? -Because -even -though -a -match -had -been -found -# -it -wouldn -' -t -be -fully -correct -to -return -it -once -a -quit -state -has -been -seen -# -because -you -can -' -t -determine -whether -the -match -offset -returned -is -the -correct -# -greedy -/ -leftmost -- -first -match -. -Since -you -can -' -t -complete -the -search -as -requested -# -by -the -caller -the -DFA -should -just -stop -and -return -an -error -. -# -# -Interestingly -this -does -seem -to -produce -an -unavoidable -difference -between -# -' -try_is_match -( -) -. -unwrap -( -) -' -and -' -try_find -( -) -. -unwrap -( -) -. -is_some -( -) -' -for -the -DFAs -. -# -The -former -will -stop -immediately -once -a -match -is -known -to -occur -and -return -# -' -Ok -( -true -) -' -where -as -the -latter -could -find -the -match -but -quit -with -an -# -' -Err -( -. -. -) -' -first -. -# -# -Thankfully -I -believe -this -inconsistency -between -' -is_match -( -) -' -and -' -find -( -) -' -# -cannot -be -observed -in -the -higher -level -meta -regex -API -because -it -specifically -# -will -try -another -engine -that -won -' -t -fail -in -the -case -of -a -DFA -failing -. -# -# -This -regression -happened -in -the -regex -crate -rewrite -but -before -anything -got -# -released -. -[ -[ -test -] -] -name -= -" -negated -- -unicode -- -word -- -boundary -- -dfa -- -fail -" -regex -= -' -\ -B -. -* -' -haystack -= -" -! -\ -u02D7 -" -matches -= -[ -[ -0 -3 -] -] -# -This -failure -was -found -in -the -* -old -* -regex -crate -( -prior -to -regex -1 -. -9 -) -but -# -I -didn -' -t -investigate -why -. -My -best -guess -is -that -it -' -s -a -literal -optimization -# -bug -. -It -didn -' -t -occur -in -the -rewrite -. -[ -[ -test -] -] -name -= -" -missed -- -match -" -regex -= -' -e -. -. -+ -e -. -ee -> -' -haystack -= -' -Zeee -. -eZZZZZZZZeee -> -eeeeeee -> -' -matches -= -[ -[ -1 -26 -] -] -# -This -test -came -from -the -' -ignore -' -crate -and -tripped -a -bug -in -how -accelerated -# -DFA -states -were -handled -in -an -overlapping -search -. -[ -[ -test -] -] -name -= -" -regex -- -to -- -glob -" -regex -= -[ -' -( -? -- -u -) -^ -path1 -/ -[ -^ -/ -] -* -' -] -haystack -= -" -path1 -/ -foo -" -matches -= -[ -[ -0 -9 -] -] -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1060 -[ -[ -test -] -] -name -= -" -reverse -- -inner -- -plus -- -shorter -- -than -- -expected -" -regex -= -' -( -? -: -( -\ -d -+ -) -[ -: -. -] -) -? -( -\ -d -{ -1 -2 -} -) -[ -: -. -] -( -\ -d -{ -2 -} -) -' -haystack -= -' -102 -: -12 -: -39 -' -matches -= -[ -[ -[ -0 -9 -] -[ -0 -3 -] -[ -4 -6 -] -[ -7 -9 -] -] -] -# -Like -reverse -- -inner -- -plus -- -shorter -- -than -- -expected -but -using -a -far -simpler -regex -# -to -demonstrate -the -extent -of -the -rot -. -Sigh -. -# -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1060 -[ -[ -test -] -] -name -= -" -reverse -- -inner -- -short -" -regex -= -' -( -? -: -( -[ -0 -- -9 -] -[ -0 -- -9 -] -[ -0 -- -9 -] -) -: -) -? -( -[ -0 -- -9 -] -[ -0 -- -9 -] -) -: -( -[ -0 -- -9 -] -[ -0 -- -9 -] -) -' -haystack -= -' -102 -: -12 -: -39 -' -matches -= -[ -[ -[ -0 -9 -] -[ -0 -3 -] -[ -4 -6 -] -[ -7 -9 -] -] -] -# -This -regression -test -was -found -via -the -RegexSet -APIs -. -It -triggered -a -# -particular -code -path -where -a -regex -was -compiled -with -' -All -' -match -semantics -# -( -to -support -overlapping -search -) -but -got -funneled -down -into -a -standard -# -leftmost -search -when -calling -' -is_match -' -. -This -is -fine -on -its -own -but -the -# -leftmost -search -will -use -a -prefilter -and -that -' -s -where -this -went -awry -. -# -# -Namely -since -' -All -' -semantics -were -used -the -aho -- -corasick -prefilter -was -# -incorrectly -compiled -with -' -Standard -' -semantics -. -This -was -wrong -because -# -' -Standard -' -immediately -attempts -to -report -a -match -at -every -position -even -if -# -that -would -mean -reporting -a -match -past -the -leftmost -match -before -reporting -# -the -leftmost -match -. -This -breaks -the -prefilter -contract -of -never -having -false -# -negatives -and -leads -overall -to -the -engine -not -finding -a -match -. -# -# -See -: -https -: -/ -/ -github -. -com -/ -rust -- -lang -/ -regex -/ -issues -/ -1070 -[ -[ -test -] -] -name -= -" -prefilter -- -with -- -aho -- -corasick -- -standard -- -semantics -" -regex -= -' -( -? -m -) -^ -* -v -[ -0 -- -9 -] -' -haystack -= -' -v -0 -' -matches -= -[ -{ -id -= -0 -spans -= -[ -[ -0 -3 -] -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -unicode -= -true -utf8 -= -true diff --git a/third_party/rust/regex/testdata/set.toml b/third_party/rust/regex/testdata/set.toml deleted file mode 100644 index 474a2c7dbb9e4..0000000000000 --- a/third_party/rust/regex/testdata/set.toml +++ /dev/null @@ -1,4442 +0,0 @@ -# -Basic -multi -- -regex -tests -. -[ -[ -test -] -] -name -= -" -basic10 -" -regex -= -[ -" -a -" -" -a -" -] -haystack -= -" -a -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -1 -span -= -[ -0 -1 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic10 -- -leftmost -- -first -" -regex -= -[ -" -a -" -" -a -" -] -haystack -= -" -a -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -1 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -basic20 -" -regex -= -[ -" -a -" -" -a -" -] -haystack -= -" -ba -" -matches -= -[ -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -1 -span -= -[ -1 -2 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic30 -" -regex -= -[ -" -a -" -" -b -" -] -haystack -= -" -a -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -1 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic40 -" -regex -= -[ -" -a -" -" -b -" -] -haystack -= -" -b -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -1 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic50 -" -regex -= -[ -" -a -| -b -" -" -b -| -a -" -] -haystack -= -" -b -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -1 -span -= -[ -0 -1 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic60 -" -regex -= -[ -" -foo -" -" -oo -" -] -haystack -= -" -foo -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -3 -] -} -{ -id -= -1 -span -= -[ -1 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic60 -- -leftmost -- -first -" -regex -= -[ -" -foo -" -" -oo -" -] -haystack -= -" -foo -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -basic61 -" -regex -= -[ -" -oo -" -" -foo -" -] -haystack -= -" -foo -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -3 -] -} -{ -id -= -0 -span -= -[ -1 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic61 -- -leftmost -- -first -" -regex -= -[ -" -oo -" -" -foo -" -] -haystack -= -" -foo -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -basic70 -" -regex -= -[ -" -abcd -" -" -bcd -" -" -cd -" -" -d -" -] -haystack -= -" -abcd -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -4 -] -} -{ -id -= -1 -span -= -[ -1 -4 -] -} -{ -id -= -2 -span -= -[ -2 -4 -] -} -{ -id -= -3 -span -= -[ -3 -4 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic71 -" -regex -= -[ -" -bcd -" -" -cd -" -" -d -" -" -abcd -" -] -haystack -= -" -abcd -" -matches -= -[ -{ -id -= -3 -span -= -[ -0 -4 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -basic80 -" -regex -= -[ -" -^ -foo -" -" -bar -" -] -haystack -= -" -foo -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic81 -" -regex -= -[ -" -^ -foo -" -" -bar -" -] -haystack -= -" -foo -bar -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -3 -] -} -{ -id -= -1 -span -= -[ -4 -7 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic82 -" -regex -= -[ -" -^ -foo -" -" -bar -" -] -haystack -= -" -bar -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic90 -" -regex -= -[ -" -[ -a -- -z -] -+ -" -" -foo -" -] -haystack -= -" -01234 -foo -" -matches -= -[ -{ -id -= -0 -span -= -[ -8 -9 -] -} -{ -id -= -0 -span -= -[ -7 -9 -] -} -{ -id -= -0 -span -= -[ -6 -9 -] -} -{ -id -= -1 -span -= -[ -6 -9 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic91 -" -regex -= -[ -" -[ -a -- -z -] -+ -" -" -foo -" -] -haystack -= -" -foo -01234 -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic100 -" -regex -= -[ -" -. -* -? -" -" -a -" -] -haystack -= -" -zzza -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -0 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -{ -id -= -0 -span -= -[ -2 -3 -] -} -{ -id -= -0 -span -= -[ -1 -3 -] -} -{ -id -= -0 -span -= -[ -0 -3 -] -} -{ -id -= -0 -span -= -[ -4 -4 -] -} -{ -id -= -0 -span -= -[ -3 -4 -] -} -{ -id -= -0 -span -= -[ -2 -4 -] -} -{ -id -= -0 -span -= -[ -1 -4 -] -} -{ -id -= -0 -span -= -[ -0 -4 -] -} -{ -id -= -1 -span -= -[ -3 -4 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic101 -" -regex -= -[ -" -. -* -" -" -a -" -] -haystack -= -" -zzza -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -0 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -{ -id -= -0 -span -= -[ -2 -3 -] -} -{ -id -= -0 -span -= -[ -1 -3 -] -} -{ -id -= -0 -span -= -[ -0 -3 -] -} -{ -id -= -0 -span -= -[ -4 -4 -] -} -{ -id -= -0 -span -= -[ -3 -4 -] -} -{ -id -= -0 -span -= -[ -2 -4 -] -} -{ -id -= -0 -span -= -[ -1 -4 -] -} -{ -id -= -0 -span -= -[ -0 -4 -] -} -{ -id -= -1 -span -= -[ -3 -4 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic102 -" -regex -= -[ -" -. -* -" -" -a -" -] -haystack -= -" -zzz -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -0 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -{ -id -= -0 -span -= -[ -2 -3 -] -} -{ -id -= -0 -span -= -[ -1 -3 -] -} -{ -id -= -0 -span -= -[ -0 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic110 -" -regex -= -[ -' -\ -ba -\ -b -' -] -haystack -= -" -hello -a -bye -" -matches -= -[ -{ -id -= -0 -span -= -[ -6 -7 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic111 -" -regex -= -[ -' -\ -ba -\ -b -' -' -\ -be -\ -b -' -] -haystack -= -" -hello -a -bye -e -" -matches -= -[ -{ -id -= -0 -span -= -[ -6 -7 -] -} -{ -id -= -1 -span -= -[ -12 -13 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic120 -" -regex -= -[ -" -a -" -] -haystack -= -" -a -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -1 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic121 -" -regex -= -[ -" -. -* -a -" -] -haystack -= -" -a -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -1 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic122 -" -regex -= -[ -" -. -* -a -" -" -" -] -haystack -= -" -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -2 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -basic130 -" -regex -= -[ -" -ab -" -" -b -" -] -haystack -= -" -ba -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -1 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -These -test -cases -where -one -of -the -regexes -matches -the -empty -string -. -[ -[ -test -] -] -name -= -" -empty10 -" -regex -= -[ -" -" -" -a -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -1 -span -= -[ -0 -1 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty10 -- -leftmost -- -first -" -regex -= -[ -" -" -" -a -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -empty11 -" -regex -= -[ -" -a -" -" -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -1 -span -= -[ -1 -1 -] -} -{ -id -= -1 -span -= -[ -2 -2 -] -} -{ -id -= -1 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty11 -- -leftmost -- -first -" -regex -= -[ -" -a -" -" -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -1 -] -} -{ -id -= -1 -span -= -[ -2 -2 -] -} -{ -id -= -1 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -empty20 -" -regex -= -[ -" -" -" -b -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -1 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty20 -- -leftmost -- -first -" -regex -= -[ -" -" -" -b -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -empty21 -" -regex -= -[ -" -b -" -" -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -0 -] -} -{ -id -= -1 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -1 -span -= -[ -2 -2 -] -} -{ -id -= -1 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty21 -- -leftmost -- -first -" -regex -= -[ -" -b -" -" -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -1 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -empty22 -" -regex -= -[ -" -( -? -: -) -" -" -b -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -1 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty23 -" -regex -= -[ -" -b -" -" -( -? -: -) -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -0 -] -} -{ -id -= -1 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -1 -2 -] -} -{ -id -= -1 -span -= -[ -2 -2 -] -} -{ -id -= -1 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty30 -" -regex -= -[ -" -" -" -z -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty30 -- -leftmost -- -first -" -regex -= -[ -" -" -" -z -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -0 -span -= -[ -0 -0 -] -} -{ -id -= -0 -span -= -[ -1 -1 -] -} -{ -id -= -0 -span -= -[ -2 -2 -] -} -{ -id -= -0 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -empty31 -" -regex -= -[ -" -z -" -" -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -0 -] -} -{ -id -= -1 -span -= -[ -1 -1 -] -} -{ -id -= -1 -span -= -[ -2 -2 -] -} -{ -id -= -1 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty31 -- -leftmost -- -first -" -regex -= -[ -" -z -" -" -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -1 -span -= -[ -0 -0 -] -} -{ -id -= -1 -span -= -[ -1 -1 -] -} -{ -id -= -1 -span -= -[ -2 -2 -] -} -{ -id -= -1 -span -= -[ -3 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -[ -[ -test -] -] -name -= -" -empty40 -" -regex -= -[ -" -c -( -? -: -) -" -" -b -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -1 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -2 -3 -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -empty40 -- -leftmost -- -first -" -regex -= -[ -" -c -( -? -: -) -" -" -b -" -] -haystack -= -" -abc -" -matches -= -[ -{ -id -= -1 -span -= -[ -1 -2 -] -} -{ -id -= -0 -span -= -[ -2 -3 -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -# -These -test -cases -where -there -are -no -matches -. -[ -[ -test -] -] -name -= -" -nomatch10 -" -regex -= -[ -" -a -" -" -a -" -] -haystack -= -" -b -" -matches -= -[ -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -nomatch20 -" -regex -= -[ -" -^ -foo -" -" -bar -" -] -haystack -= -" -bar -foo -" -matches -= -[ -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -nomatch30 -" -regex -= -[ -] -haystack -= -" -a -" -matches -= -[ -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -[ -[ -test -] -] -name -= -" -nomatch40 -" -regex -= -[ -" -^ -rooted -" -' -\ -. -log -' -] -haystack -= -" -notrooted -" -matches -= -[ -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -These -test -multi -- -regex -searches -with -capture -groups -. -# -# -NOTE -: -I -wrote -these -tests -in -the -course -of -developing -a -first -class -API -for -# -overlapping -capturing -group -matches -but -ultimately -removed -that -API -because -# -the -semantics -for -overlapping -matches -aren -' -t -totally -clear -. -However -I -' -ve -# -left -the -tests -because -I -believe -the -semantics -for -these -patterns -are -clear -# -and -because -we -can -still -test -our -" -which -patterns -matched -" -APIs -with -them -. -[ -[ -test -] -] -name -= -" -caps -- -010 -" -regex -= -[ -' -^ -( -\ -w -+ -) -( -\ -w -+ -) -' -' -^ -( -\ -S -+ -) -( -\ -S -+ -) -' -] -haystack -= -" -Bruce -Springsteen -" -matches -= -[ -{ -id -= -0 -spans -= -[ -[ -0 -17 -] -[ -0 -5 -] -[ -6 -17 -] -] -} -{ -id -= -1 -spans -= -[ -[ -0 -17 -] -[ -0 -5 -] -[ -6 -17 -] -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -caps -- -020 -" -regex -= -[ -' -^ -( -\ -w -+ -) -( -\ -w -+ -) -' -' -^ -[ -A -- -Z -] -( -\ -S -+ -) -[ -A -- -Z -] -( -\ -S -+ -) -' -] -haystack -= -" -Bruce -Springsteen -" -matches -= -[ -{ -id -= -0 -spans -= -[ -[ -0 -17 -] -[ -0 -5 -] -[ -6 -17 -] -] -} -{ -id -= -1 -spans -= -[ -[ -0 -17 -] -[ -1 -5 -] -[ -7 -17 -] -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -caps -- -030 -" -regex -= -[ -' -^ -( -\ -w -+ -) -( -\ -w -+ -) -' -' -^ -( -[ -A -- -Z -] -) -( -\ -S -+ -) -( -[ -A -- -Z -] -) -( -\ -S -+ -) -' -] -haystack -= -" -Bruce -Springsteen -" -matches -= -[ -{ -id -= -0 -spans -= -[ -[ -0 -17 -] -[ -0 -5 -] -[ -6 -17 -] -] -} -{ -id -= -1 -spans -= -[ -[ -0 -17 -] -[ -0 -1 -] -[ -1 -5 -] -[ -6 -7 -] -[ -7 -17 -] -] -} -] -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -caps -- -110 -" -regex -= -[ -' -( -\ -w -+ -) -( -\ -w -+ -) -' -' -( -\ -S -+ -) -( -\ -S -+ -) -' -] -haystack -= -" -Bruce -Springsteen -" -matches -= -[ -{ -id -= -0 -spans -= -[ -[ -0 -17 -] -[ -0 -5 -] -[ -6 -17 -] -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -caps -- -120 -" -regex -= -[ -' -( -\ -w -+ -) -( -\ -w -+ -) -' -' -( -\ -S -+ -) -( -\ -S -+ -) -' -] -haystack -= -" -& -ruce -pringsteen -" -matches -= -[ -{ -id -= -1 -spans -= -[ -[ -0 -17 -] -[ -0 -5 -] -[ -6 -17 -] -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -caps -- -121 -" -regex -= -[ -' -( -\ -w -+ -) -( -\ -w -+ -) -' -' -( -\ -S -+ -) -( -\ -S -+ -) -' -] -haystack -= -" -& -ruce -pringsteen -Foo -Bar -" -matches -= -[ -{ -id -= -1 -spans -= -[ -[ -0 -17 -] -[ -0 -5 -] -[ -6 -17 -] -] -} -{ -id -= -0 -spans -= -[ -[ -18 -25 -] -[ -18 -21 -] -[ -22 -25 -] -] -} -] -match -- -kind -= -" -leftmost -- -first -" -search -- -kind -= -" -leftmost -" -unicode -= -false -utf8 -= -false diff --git a/third_party/rust/regex/testdata/substring.toml b/third_party/rust/regex/testdata/substring.toml deleted file mode 100644 index 5d5c0d3f20788..0000000000000 --- a/third_party/rust/regex/testdata/substring.toml +++ /dev/null @@ -1,290 +0,0 @@ -# -These -tests -check -that -regex -engines -perform -as -expected -when -the -search -is -# -instructed -to -only -search -a -substring -of -a -haystack -instead -of -the -entire -# -haystack -. -This -tends -to -exercise -interesting -edge -cases -that -are -otherwise -# -difficult -to -provoke -. -( -But -not -necessarily -impossible -. -Regex -search -iterators -# -for -example -make -use -of -the -" -search -just -a -substring -" -APIs -by -changing -the -# -starting -position -of -a -search -to -the -end -position -of -the -previous -match -. -) -[ -[ -test -] -] -name -= -" -unicode -- -word -- -start -" -regex -= -' -\ -b -[ -0 -- -9 -] -+ -\ -b -' -haystack -= -" -123 -" -bounds -= -{ -start -= -2 -end -= -5 -} -matches -= -[ -] -[ -[ -test -] -] -name -= -" -unicode -- -word -- -end -" -regex -= -' -\ -b -[ -0 -- -9 -] -+ -\ -b -' -haystack -= -" -123 -" -bounds -= -{ -start -= -0 -end -= -3 -} -matches -= -[ -] -[ -[ -test -] -] -name -= -" -ascii -- -word -- -start -" -regex -= -' -\ -b -[ -0 -- -9 -] -+ -\ -b -' -haystack -= -" -123 -" -bounds -= -{ -start -= -2 -end -= -5 -} -matches -= -[ -[ -2 -5 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -ascii -- -word -- -end -" -regex -= -' -\ -b -[ -0 -- -9 -] -+ -\ -b -' -haystack -= -" -123 -" -bounds -= -{ -start -= -0 -end -= -3 -} -matches -= -[ -[ -0 -3 -] -] -unicode -= -false diff --git a/third_party/rust/regex/testdata/unicode.toml b/third_party/rust/regex/testdata/unicode.toml deleted file mode 100644 index 942af297791b2..0000000000000 --- a/third_party/rust/regex/testdata/unicode.toml +++ /dev/null @@ -1,2869 +0,0 @@ -# -Basic -Unicode -literal -support -. -[ -[ -test -] -] -name -= -" -literal1 -" -regex -= -' -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -literal2 -" -regex -= -' -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -literal3 -" -regex -= -' -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -case -- -insensitive -= -true -[ -[ -test -] -] -name -= -" -literal4 -" -regex -= -' -' -haystack -= -" -" -matches -= -[ -[ -0 -2 -] -] -case -- -insensitive -= -true -# -Unicode -word -boundaries -. -[ -[ -test -] -] -name -= -" -wb -- -100 -" -regex -= -' -\ -d -\ -b -' -haystack -= -" -6 -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -wb -- -200 -" -regex -= -' -\ -d -\ -b -' -haystack -= -" -6 -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -wb -- -300 -" -regex -= -' -\ -d -\ -B -' -haystack -= -" -6 -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -wb -- -400 -" -regex -= -' -\ -d -\ -B -' -haystack -= -" -6 -" -matches -= -[ -] -# -Unicode -character -class -support -. -[ -[ -test -] -] -name -= -" -class1 -" -regex -= -' -[ -] -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class2 -" -regex -= -' -\ -pN -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class3 -" -regex -= -' -\ -pN -+ -' -haystack -= -" -1 -2 -" -matches -= -[ -[ -0 -8 -] -] -[ -[ -test -] -] -name -= -" -class4 -" -regex -= -' -\ -PN -+ -' -haystack -= -" -ab -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -class5 -" -regex -= -' -[ -\ -PN -] -+ -' -haystack -= -" -ab -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -class6 -" -regex -= -' -[ -^ -\ -PN -] -+ -' -haystack -= -" -ab -" -matches -= -[ -[ -2 -5 -] -] -[ -[ -test -] -] -name -= -" -class7 -" -regex -= -' -\ -p -{ -Lu -} -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -8 -] -] -[ -[ -test -] -] -name -= -" -class8 -" -regex -= -' -\ -p -{ -Lu -} -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -10 -] -] -case -- -insensitive -= -true -[ -[ -test -] -] -name -= -" -class9 -" -regex -= -' -\ -pL -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -10 -] -] -[ -[ -test -] -] -name -= -" -class10 -" -regex -= -' -\ -p -{ -Ll -} -+ -' -haystack -= -" -" -matches -= -[ -[ -8 -10 -] -] -# -Unicode -aware -" -Perl -" -character -classes -. -[ -[ -test -] -] -name -= -" -perl1 -" -regex -= -' -\ -w -+ -' -haystack -= -" -d -d -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -perl2 -" -regex -= -' -\ -w -+ -' -haystack -= -" -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -perl3 -" -regex -= -' -\ -W -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -perl4 -" -regex -= -' -\ -d -+ -' -haystack -= -" -1 -9 -" -matches -= -[ -[ -0 -8 -] -] -[ -[ -test -] -] -name -= -" -perl5 -" -regex -= -' -\ -d -+ -' -haystack -= -" -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -perl6 -" -regex -= -' -\ -D -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -perl7 -" -regex -= -' -\ -s -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -perl8 -" -regex -= -' -\ -s -+ -' -haystack -= -" -" -matches -= -[ -] -[ -[ -test -] -] -name -= -" -perl9 -" -regex -= -' -\ -S -+ -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -# -Specific -tests -for -Unicode -general -category -classes -. -[ -[ -test -] -] -name -= -" -class -- -gencat1 -" -regex -= -' -\ -p -{ -Cased_Letter -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat2 -" -regex -= -' -\ -p -{ -Close_Punctuation -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat3 -" -regex -= -' -\ -p -{ -Connector_Punctuation -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat4 -" -regex -= -' -\ -p -{ -Control -} -' -haystack -= -" -\ -u009F -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat5 -" -regex -= -' -\ -p -{ -Currency_Symbol -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat6 -" -regex -= -' -\ -p -{ -Dash_Punctuation -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat7 -" -regex -= -' -\ -p -{ -Decimal_Number -} -' -haystack -= -" -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat8 -" -regex -= -' -\ -p -{ -Enclosing_Mark -} -' -haystack -= -" -\ -uA672 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat9 -" -regex -= -' -\ -p -{ -Final_Punctuation -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat10 -" -regex -= -' -\ -p -{ -Format -} -' -haystack -= -" -\ -U000E007F -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat11 -" -regex -= -' -\ -p -{ -Initial_Punctuation -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat12 -" -regex -= -' -\ -p -{ -Letter -} -' -haystack -= -" -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat13 -" -regex -= -' -\ -p -{ -Letter_Number -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat14 -" -regex -= -' -\ -p -{ -Line_Separator -} -' -haystack -= -" -\ -u2028 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat15 -" -regex -= -' -\ -p -{ -Lowercase_Letter -} -' -haystack -= -" -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat16 -" -regex -= -' -\ -p -{ -Mark -} -' -haystack -= -" -\ -U000E01EF -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat17 -" -regex -= -' -\ -p -{ -Math -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat18 -" -regex -= -' -\ -p -{ -Modifier_Letter -} -' -haystack -= -" -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat19 -" -regex -= -' -\ -p -{ -Modifier_Symbol -} -' -haystack -= -" -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat20 -" -regex -= -' -\ -p -{ -Nonspacing_Mark -} -' -haystack -= -" -\ -U0001E94A -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat21 -" -regex -= -' -\ -p -{ -Number -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat22 -" -regex -= -' -\ -p -{ -Open_Punctuation -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat23 -" -regex -= -' -\ -p -{ -Other -} -' -haystack -= -" -\ -u0BC9 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat24 -" -regex -= -' -\ -p -{ -Other_Letter -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat25 -" -regex -= -' -\ -p -{ -Other_Number -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat26 -" -regex -= -' -\ -p -{ -Other_Punctuation -} -' -haystack -= -" -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat27 -" -regex -= -' -\ -p -{ -Other_Symbol -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat28 -" -regex -= -' -\ -p -{ -Paragraph_Separator -} -' -haystack -= -" -\ -u2029 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat29 -" -regex -= -' -\ -p -{ -Private_Use -} -' -haystack -= -" -\ -U0010FFFD -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat30 -" -regex -= -' -\ -p -{ -Punctuation -} -' -haystack -= -" -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat31 -" -regex -= -' -\ -p -{ -Separator -} -' -haystack -= -" -\ -u3000 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat32 -" -regex -= -' -\ -p -{ -Space_Separator -} -' -haystack -= -" -\ -u205F -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat33 -" -regex -= -' -\ -p -{ -Spacing_Mark -} -' -haystack -= -" -\ -U00016F7E -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat34 -" -regex -= -' -\ -p -{ -Symbol -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat35 -" -regex -= -' -\ -p -{ -Titlecase_Letter -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat36 -" -regex -= -' -\ -p -{ -Unassigned -} -' -haystack -= -" -\ -U0010FFFF -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gencat37 -" -regex -= -' -\ -p -{ -Uppercase_Letter -} -' -haystack -= -" -" -matches -= -[ -[ -0 -3 -] -] -# -Tests -for -Unicode -emoji -properties -. -[ -[ -test -] -] -name -= -" -class -- -emoji1 -" -regex -= -' -\ -p -{ -Emoji -} -' -haystack -= -" -\ -u23E9 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -emoji2 -" -regex -= -' -\ -p -{ -emoji -} -' -haystack -= -" -\ -U0001F21A -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -emoji3 -" -regex -= -' -\ -p -{ -extendedpictographic -} -' -haystack -= -" -\ -U0001FA6E -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -emoji4 -" -regex -= -' -\ -p -{ -extendedpictographic -} -' -haystack -= -" -\ -U0001FFFD -" -matches -= -[ -[ -0 -4 -] -] -# -Tests -for -Unicode -grapheme -cluster -properties -. -[ -[ -test -] -] -name -= -" -class -- -gcb1 -" -regex -= -' -\ -p -{ -grapheme_cluster_break -= -prepend -} -' -haystack -= -" -\ -U00011D46 -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gcb2 -" -regex -= -' -\ -p -{ -gcb -= -regional_indicator -} -' -haystack -= -" -\ -U0001F1E6 -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gcb3 -" -regex -= -' -\ -p -{ -gcb -= -ri -} -' -haystack -= -" -\ -U0001F1E7 -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gcb4 -" -regex -= -' -\ -p -{ -regionalindicator -} -' -haystack -= -" -\ -U0001F1FF -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -gcb5 -" -regex -= -' -\ -p -{ -gcb -= -lvt -} -' -haystack -= -" -\ -uC989 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -gcb6 -" -regex -= -' -\ -p -{ -gcb -= -zwj -} -' -haystack -= -" -\ -u200D -" -matches -= -[ -[ -0 -3 -] -] -# -Tests -for -Unicode -word -boundary -properties -. -[ -[ -test -] -] -name -= -" -class -- -word -- -break1 -" -regex -= -' -\ -p -{ -word_break -= -Hebrew_Letter -} -' -haystack -= -" -\ -uFB46 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -word -- -break2 -" -regex -= -' -\ -p -{ -wb -= -hebrewletter -} -' -haystack -= -" -\ -uFB46 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -word -- -break3 -" -regex -= -' -\ -p -{ -wb -= -ExtendNumLet -} -' -haystack -= -" -\ -uFF3F -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -word -- -break4 -" -regex -= -' -\ -p -{ -wb -= -WSegSpace -} -' -haystack -= -" -\ -u3000 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -word -- -break5 -" -regex -= -' -\ -p -{ -wb -= -numeric -} -' -haystack -= -" -\ -U0001E950 -" -matches -= -[ -[ -0 -4 -] -] -# -Tests -for -Unicode -sentence -boundary -properties -. -[ -[ -test -] -] -name -= -" -class -- -sentence -- -break1 -" -regex -= -' -\ -p -{ -sentence_break -= -Lower -} -' -haystack -= -" -\ -u0469 -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -class -- -sentence -- -break2 -" -regex -= -' -\ -p -{ -sb -= -lower -} -' -haystack -= -" -\ -u0469 -" -matches -= -[ -[ -0 -2 -] -] -[ -[ -test -] -] -name -= -" -class -- -sentence -- -break3 -" -regex -= -' -\ -p -{ -sb -= -Close -} -' -haystack -= -" -\ -uFF60 -" -matches -= -[ -[ -0 -3 -] -] -[ -[ -test -] -] -name -= -" -class -- -sentence -- -break4 -" -regex -= -' -\ -p -{ -sb -= -Close -} -' -haystack -= -" -\ -U0001F677 -" -matches -= -[ -[ -0 -4 -] -] -[ -[ -test -] -] -name -= -" -class -- -sentence -- -break5 -" -regex -= -' -\ -p -{ -sb -= -SContinue -} -' -haystack -= -" -\ -uFF64 -" -matches -= -[ -[ -0 -3 -] -] diff --git a/third_party/rust/regex/testdata/utf8.toml b/third_party/rust/regex/testdata/utf8.toml deleted file mode 100644 index a0c5030d2ca09..0000000000000 --- a/third_party/rust/regex/testdata/utf8.toml +++ /dev/null @@ -1,2945 +0,0 @@ -# -These -test -the -UTF -- -8 -modes -expose -by -regex -- -automata -. -Namely -when -utf8 -is -# -true -then -we -promise -that -the -haystack -is -valid -UTF -- -8 -. -( -Otherwise -behavior -# -is -unspecified -. -) -This -also -corresponds -to -building -the -regex -engine -with -the -# -following -two -guarantees -: -# -# -1 -) -For -any -non -- -empty -match -reported -its -span -is -guaranteed -to -correspond -to -# -valid -UTF -- -8 -. -# -2 -) -All -empty -or -zero -- -width -matches -reported -must -never -split -a -UTF -- -8 -# -encoded -codepoint -. -If -the -haystack -has -invalid -UTF -- -8 -then -this -results -in -# -unspecified -behavior -. -# -# -The -( -2 -) -is -in -particular -what -we -focus -our -testing -on -since -( -1 -) -is -generally -# -guaranteed -by -regex -- -syntax -' -s -AST -- -to -- -HIR -translator -and -is -well -tested -there -. -# -The -thing -with -( -2 -) -is -that -it -can -' -t -be -described -in -the -HIR -so -the -regex -# -engines -have -to -handle -that -case -. -Thus -we -test -it -here -. -# -# -Note -that -it -is -possible -to -build -a -regex -that -has -property -( -1 -) -but -not -# -( -2 -) -and -vice -versa -. -This -is -done -by -building -the -HIR -with -' -utf8 -= -true -' -but -# -building -the -Thompson -NFA -with -' -utf8 -= -false -' -. -We -don -' -t -test -that -here -because -# -the -harness -doesn -' -t -expose -a -way -to -enable -or -disable -UTF -- -8 -mode -with -that -# -granularity -. -Instead -those -combinations -are -lightly -tested -via -doc -examples -. -# -That -' -s -not -to -say -that -( -1 -) -without -( -2 -) -is -uncommon -. -Indeed -ripgrep -uses -it -# -because -it -cannot -guarantee -that -its -haystack -is -valid -UTF -- -8 -. -# -This -tests -that -an -empty -regex -doesn -' -t -split -a -codepoint -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -[ -3 -3 -] -] -unicode -= -true -utf8 -= -true -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -overlapping -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -[ -3 -3 -] -] -unicode -= -true -utf8 -= -true -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -This -tests -that -an -empty -regex -DOES -split -a -codepoint -when -utf -= -false -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -unicode -= -true -utf8 -= -false -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -overlapping -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -unicode -= -true -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -This -tests -that -an -empty -regex -doesn -' -t -split -a -codepoint -even -if -we -give -# -it -bounds -entirely -within -the -codepoint -. -# -# -This -is -one -of -the -trickier -cases -and -is -what -motivated -the -current -UTF -- -8 -# -mode -design -. -In -particular -at -one -point -this -test -failed -the -' -is_match -' -# -variant -of -the -test -but -not -' -find -' -. -This -is -because -the -' -is_match -' -code -path -# -is -specifically -optimized -for -" -was -a -match -found -" -rather -than -" -where -is -the -# -match -. -" -In -the -former -case -you -don -' -t -really -care -about -the -empty -- -vs -- -non -- -empty -# -matches -and -thus -the -codepoint -splitting -filtering -logic -wasn -' -t -getting -# -applied -. -( -In -multiple -ways -across -multiple -regex -engines -. -) -In -this -way -you -# -can -wind -up -with -a -situation -where -' -is_match -' -says -" -yes -" -but -' -find -' -says -# -" -I -didn -' -t -find -anything -. -" -Which -is -. -. -. -not -great -. -# -# -I -could -have -decided -to -say -that -providing -boundaries -that -themselves -split -# -a -codepoint -would -have -unspecified -behavior -. -But -I -couldn -' -t -quite -convince -# -myself -that -such -boundaries -were -the -only -way -to -get -an -inconsistency -between -# -' -is_match -' -and -' -find -' -. -# -# -Note -that -I -also -tried -to -come -up -with -a -test -like -this -that -fails -without -# -using -bounds -. -Specifically -a -test -where -' -is_match -' -and -' -find -' -disagree -. -# -But -I -couldn -' -t -do -it -and -I -' -m -tempted -to -conclude -it -is -impossible -. -The -# -fundamental -problem -is -that -you -need -to -simultaneously -produce -an -empty -match -# -that -splits -a -codepoint -while -* -not -* -matching -before -or -after -the -codepoint -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -bounds -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -3 -] -matches -= -[ -] -unicode -= -true -utf8 -= -true -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -bounds -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -3 -] -matches -= -[ -] -unicode -= -true -utf8 -= -true -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -This -tests -that -an -empty -regex -splits -a -codepoint -when -the -bounds -are -# -entirely -within -the -codepoint -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -bounds -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -3 -] -matches -= -[ -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -unicode -= -true -utf8 -= -false -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -bounds -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -3 -] -matches -= -[ -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -unicode -= -true -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -In -this -test -we -anchor -the -search -. -Since -the -start -position -is -also -a -UTF -- -8 -# -boundary -we -get -a -match -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -anchored -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -] -anchored -= -true -unicode -= -true -utf8 -= -true -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -anchored -- -overlapping -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -] -anchored -= -true -unicode -= -true -utf8 -= -true -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -Same -as -above -except -with -UTF -- -8 -mode -disabled -. -It -almost -doesn -' -t -change -the -# -result -except -for -the -fact -that -since -this -is -an -anchored -search -and -we -# -always -find -all -matches -the -test -harness -will -keep -reporting -matches -until -# -none -are -found -. -Because -it -' -s -anchored -matches -will -be -reported -so -long -as -# -they -are -directly -adjacent -. -Since -with -UTF -- -8 -mode -the -next -anchored -search -# -after -the -match -at -[ -0 -0 -] -fails -iteration -stops -( -and -doesn -' -t -find -the -last -# -match -at -[ -4 -4 -] -) -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -anchored -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -anchored -= -true -unicode -= -true -utf8 -= -false -# -Tests -the -overlapping -case -of -the -above -. -# -# -Note -that -overlapping -anchored -searches -are -a -little -weird -and -it -' -s -not -# -totally -clear -what -their -semantics -ought -to -be -. -For -now -we -just -test -the -# -current -behavior -of -our -test -shim -that -implements -overlapping -search -. -( -This -# -is -one -of -the -reasons -why -we -don -' -t -really -expose -regex -- -level -overlapping -# -searches -. -) -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -anchored -- -overlapping -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -[ -0 -0 -] -] -anchored -= -true -unicode -= -true -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -In -this -test -we -anchor -the -search -but -also -set -bounds -. -The -bounds -start -the -# -search -in -the -middle -of -a -codepoint -so -there -should -never -be -a -match -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -anchored -- -bounds -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -] -bounds -= -[ -1 -3 -] -anchored -= -true -unicode -= -true -utf8 -= -true -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -anchored -- -bounds -- -overlapping -" -regex -= -' -' -haystack -= -' -' -matches -= -[ -] -bounds -= -[ -1 -3 -] -anchored -= -true -unicode -= -true -utf8 -= -true -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -Same -as -above -except -with -UTF -- -8 -mode -disabled -. -Without -UTF -- -8 -mode -enabled -# -matching -within -a -codepoint -is -allowed -. -And -remember -as -in -the -anchored -test -# -above -with -UTF -- -8 -mode -disabled -iteration -will -report -all -adjacent -matches -. -# -The -matches -at -[ -0 -0 -] -and -[ -4 -4 -] -are -not -included -because -of -the -bounds -of -# -the -search -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -anchored -- -bounds -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -3 -] -matches -= -[ -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -] -anchored -= -true -unicode -= -true -utf8 -= -false -# -Tests -the -overlapping -case -of -the -above -. -# -# -Note -that -overlapping -anchored -searches -are -a -little -weird -and -it -' -s -not -# -totally -clear -what -their -semantics -ought -to -be -. -For -now -we -just -test -the -# -current -behavior -of -our -test -shim -that -implements -overlapping -search -. -( -This -# -is -one -of -the -reasons -why -we -don -' -t -really -expose -regex -- -level -overlapping -# -searches -. -) -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -anchored -- -bounds -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -3 -] -matches -= -[ -[ -1 -1 -] -] -anchored -= -true -unicode -= -true -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -This -tests -that -we -find -the -match -at -the -end -of -the -string -when -the -bounds -# -exclude -the -first -match -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -startbound -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -4 -] -matches -= -[ -[ -4 -4 -] -] -unicode -= -true -utf8 -= -true -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -startbound -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -4 -] -matches -= -[ -[ -4 -4 -] -] -unicode -= -true -utf8 -= -true -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -Same -as -above -except -since -UTF -- -8 -mode -is -disabled -we -also -find -the -matches -# -inbetween -that -split -the -codepoint -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -startbound -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -4 -] -matches -= -[ -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -unicode -= -true -utf8 -= -false -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -startbound -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -4 -] -matches -= -[ -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -unicode -= -true -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -This -tests -that -we -don -' -t -find -any -matches -in -an -anchored -search -even -when -# -the -bounds -include -a -match -( -at -the -end -) -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -anchored -- -startbound -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -4 -] -matches -= -[ -] -anchored -= -true -unicode -= -true -utf8 -= -true -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -anchored -- -startbound -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -4 -] -matches -= -[ -] -anchored -= -true -unicode -= -true -utf8 -= -true -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -Same -as -above -except -since -UTF -- -8 -mode -is -disabled -we -also -find -the -matches -# -inbetween -that -split -the -codepoint -. -Even -though -this -is -an -anchored -search -# -since -the -matches -are -adjacent -we -find -all -of -them -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -anchored -- -startbound -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -4 -] -matches -= -[ -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -] -anchored -= -true -unicode -= -true -utf8 -= -false -# -Tests -the -overlapping -case -of -the -above -. -# -# -Note -that -overlapping -anchored -searches -are -a -little -weird -and -it -' -s -not -# -totally -clear -what -their -semantics -ought -to -be -. -For -now -we -just -test -the -# -current -behavior -of -our -test -shim -that -implements -overlapping -search -. -( -This -# -is -one -of -the -reasons -why -we -don -' -t -really -expose -regex -- -level -overlapping -# -searches -. -) -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -anchored -- -startbound -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -1 -4 -] -matches -= -[ -[ -1 -1 -] -] -anchored -= -true -unicode -= -true -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -This -tests -that -we -find -the -match -at -the -end -of -the -haystack -in -UTF -- -8 -mode -# -when -our -bounds -only -include -the -empty -string -at -the -end -of -the -haystack -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -anchored -- -endbound -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -4 -4 -] -matches -= -[ -[ -4 -4 -] -] -anchored -= -true -unicode -= -true -utf8 -= -true -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8yes -- -anchored -- -endbound -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -4 -4 -] -matches -= -[ -[ -4 -4 -] -] -anchored -= -true -unicode -= -true -utf8 -= -true -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" -# -Same -as -above -but -with -UTF -- -8 -mode -disabled -. -Results -remain -the -same -since -# -the -only -possible -match -does -not -split -a -codepoint -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -anchored -- -endbound -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -4 -4 -] -matches -= -[ -[ -4 -4 -] -] -anchored -= -true -unicode -= -true -utf8 -= -false -# -Tests -the -overlapping -case -of -the -above -. -[ -[ -test -] -] -name -= -" -empty -- -utf8no -- -anchored -- -endbound -- -overlapping -" -regex -= -' -' -haystack -= -' -' -bounds -= -[ -4 -4 -] -matches -= -[ -[ -4 -4 -] -] -anchored -= -true -unicode -= -true -utf8 -= -false -match -- -kind -= -" -all -" -search -- -kind -= -" -overlapping -" diff --git a/third_party/rust/regex/testdata/word-boundary.toml b/third_party/rust/regex/testdata/word-boundary.toml deleted file mode 100644 index 3ec6f977eb91f..0000000000000 --- a/third_party/rust/regex/testdata/word-boundary.toml +++ /dev/null @@ -1,4393 +0,0 @@ -# -Some -of -these -are -cribbed -from -RE2 -' -s -test -suite -. -# -These -test -\ -b -. -Below -are -tests -for -\ -B -. -[ -[ -test -] -] -name -= -" -wb1 -" -regex -= -' -\ -b -' -haystack -= -" -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb2 -" -regex -= -' -\ -b -' -haystack -= -" -a -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb3 -" -regex -= -' -\ -b -' -haystack -= -" -ab -" -matches -= -[ -[ -0 -0 -] -[ -2 -2 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb4 -" -regex -= -' -^ -\ -b -' -haystack -= -" -ab -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb5 -" -regex -= -' -\ -b -' -haystack -= -" -ab -" -matches -= -[ -[ -2 -2 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb6 -" -regex -= -' -^ -\ -b -' -haystack -= -" -ab -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb7 -" -regex -= -' -\ -bbar -\ -b -' -haystack -= -" -nobar -bar -foo -bar -" -matches -= -[ -[ -6 -9 -] -[ -14 -17 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb8 -" -regex -= -' -a -\ -b -' -haystack -= -" -faoa -x -" -matches -= -[ -[ -3 -4 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb9 -" -regex -= -' -\ -bbar -' -haystack -= -" -bar -x -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb10 -" -regex -= -' -\ -bbar -' -haystack -= -" -foo -\ -nbar -x -" -matches -= -[ -[ -4 -7 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb11 -" -regex -= -' -bar -\ -b -' -haystack -= -" -foobar -" -matches -= -[ -[ -3 -6 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb12 -" -regex -= -' -bar -\ -b -' -haystack -= -" -foobar -\ -nxxx -" -matches -= -[ -[ -3 -6 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb13 -" -regex -= -' -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -b -' -haystack -= -" -foo -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb14 -" -regex -= -' -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -b -' -haystack -= -" -foo -\ -n -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb15 -" -regex -= -' -\ -b -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -' -haystack -= -" -foo -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb16 -" -regex -= -' -\ -b -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -b -' -haystack -= -" -X -" -matches -= -[ -[ -0 -1 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb17 -" -regex -= -' -\ -b -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -b -' -haystack -= -" -XY -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb18 -" -regex -= -' -\ -b -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -b -' -haystack -= -" -bar -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb19 -" -regex -= -' -\ -b -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -b -' -haystack -= -" -foo -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb20 -" -regex -= -' -\ -b -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -b -' -haystack -= -" -foo -\ -n -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb21 -" -regex -= -' -\ -b -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -b -' -haystack -= -" -ffoo -bbar -N -x -" -matches -= -[ -[ -10 -11 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb22 -" -regex -= -' -\ -b -( -? -: -fo -| -foo -) -\ -b -' -haystack -= -" -fo -" -matches -= -[ -[ -0 -2 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb23 -" -regex -= -' -\ -b -( -? -: -fo -| -foo -) -\ -b -' -haystack -= -" -foo -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb24 -" -regex -= -' -\ -b -\ -b -' -haystack -= -" -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb25 -" -regex -= -' -\ -b -\ -b -' -haystack -= -" -a -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb26 -" -regex -= -' -\ -b -' -haystack -= -" -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb27 -" -regex -= -' -\ -b -' -haystack -= -" -x -" -matches -= -[ -[ -1 -1 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb28 -" -regex -= -' -\ -b -' -haystack -= -" -y -x -" -matches -= -[ -[ -3 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb29 -" -regex -= -' -( -? -- -u -: -\ -b -) -. -' -haystack -= -" -x -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -wb30 -" -regex -= -' -^ -\ -b -( -? -: -fo -| -foo -) -\ -b -' -haystack -= -" -fo -" -matches -= -[ -[ -0 -2 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb31 -" -regex -= -' -^ -\ -b -( -? -: -fo -| -foo -) -\ -b -' -haystack -= -" -foo -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb32 -" -regex -= -' -^ -\ -b -' -haystack -= -" -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb33 -" -regex -= -' -^ -\ -b -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb34 -" -regex -= -' -^ -( -? -- -u -: -\ -b -) -. -' -haystack -= -" -x -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -wb35 -" -regex -= -' -^ -( -? -- -u -: -\ -b -) -. -( -? -- -u -: -\ -b -) -' -haystack -= -" -x -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -wb36 -" -regex -= -' -^ -^ -^ -^ -^ -\ -b -' -haystack -= -" -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb37 -" -regex -= -' -^ -^ -^ -^ -^ -( -? -- -u -: -\ -b -) -. -' -haystack -= -" -x -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -wb38 -" -regex -= -' -^ -^ -^ -^ -^ -\ -b -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb39 -" -regex -= -' -^ -^ -^ -^ -^ -( -? -- -u -: -\ -b -\ -b -\ -b -) -. -( -? -- -u -: -\ -b -\ -b -\ -b -) -' -haystack -= -" -x -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -wb40 -" -regex -= -' -( -? -- -u -: -\ -b -) -. -+ -( -? -- -u -: -\ -b -) -' -haystack -= -" -abc -" -matches -= -[ -[ -2 -5 -] -] -[ -[ -test -] -] -name -= -" -wb41 -" -regex -= -' -\ -b -' -haystack -= -" -a -b -c -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb42 -" -regex -= -' -\ -bfoo -\ -b -' -haystack -= -" -zzz -foo -zzz -" -matches -= -[ -[ -4 -7 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb43 -" -regex -= -' -\ -b -^ -' -haystack -= -" -ab -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -wb44 -" -regex -= -' -\ -b -' -haystack -= -" -ab -" -matches -= -[ -[ -2 -2 -] -] -unicode -= -false -# -Tests -for -\ -B -. -Note -that -\ -B -is -not -allowed -if -UTF -- -8 -mode -is -enabled -so -we -# -have -to -disable -it -for -most -of -these -tests -. -This -is -because -\ -B -can -match -at -# -non -- -UTF -- -8 -boundaries -. -[ -[ -test -] -] -name -= -" -nb1 -" -regex -= -' -\ -Bfoo -\ -B -' -haystack -= -" -n -foo -xfoox -that -" -matches -= -[ -[ -7 -10 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb2 -" -regex -= -' -a -\ -B -' -haystack -= -" -faoa -x -" -matches -= -[ -[ -1 -2 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb3 -" -regex -= -' -\ -Bbar -' -haystack -= -" -bar -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb4 -" -regex -= -' -\ -Bbar -' -haystack -= -" -foo -\ -nbar -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb5 -" -regex -= -' -bar -\ -B -' -haystack -= -" -foobar -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb6 -" -regex -= -' -bar -\ -B -' -haystack -= -" -foobar -\ -nxxx -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb7 -" -regex -= -' -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -foox -" -matches -= -[ -[ -0 -3 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb8 -" -regex -= -' -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -foo -\ -n -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb9 -" -regex -= -' -\ -B -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb10 -" -regex -= -' -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb11 -" -regex -= -' -\ -B -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -' -haystack -= -" -foo -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb12 -" -regex -= -' -\ -B -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -xXy -" -matches -= -[ -[ -1 -2 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb13 -" -regex -= -' -\ -B -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -XY -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb14 -" -regex -= -' -\ -B -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -XYZ -" -matches -= -[ -[ -1 -2 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb15 -" -regex -= -' -\ -B -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -abara -" -matches -= -[ -[ -1 -4 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb16 -" -regex -= -' -\ -B -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -xfoo_ -" -matches -= -[ -[ -1 -4 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb17 -" -regex -= -' -\ -B -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -xfoo -\ -n -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb18 -" -regex -= -' -\ -B -( -? -: -foo -| -bar -| -[ -A -- -Z -] -) -\ -B -' -haystack -= -" -foo -bar -vNX -" -matches -= -[ -[ -9 -10 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb19 -" -regex -= -' -\ -B -( -? -: -fo -| -foo -) -\ -B -' -haystack -= -" -xfoo -" -matches -= -[ -[ -1 -3 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb20 -" -regex -= -' -\ -B -( -? -: -foo -| -fo -) -\ -B -' -haystack -= -" -xfooo -" -matches -= -[ -[ -1 -4 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb21 -" -regex -= -' -\ -B -\ -B -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb22 -" -regex -= -' -\ -B -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb23 -" -regex -= -' -\ -B -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb24 -" -regex -= -' -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb25 -" -regex -= -' -\ -B -' -haystack -= -" -y -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb26 -" -regex -= -' -\ -B -. -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb27 -" -regex -= -' -^ -\ -B -( -? -: -fo -| -foo -) -\ -B -' -haystack -= -" -fo -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb28 -" -regex -= -' -^ -\ -B -( -? -: -fo -| -foo -) -\ -B -' -haystack -= -" -fo -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb29 -" -regex -= -' -^ -\ -B -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb30 -" -regex -= -' -^ -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb31 -" -regex -= -' -^ -\ -B -\ -B -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb32 -" -regex -= -' -^ -\ -B -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb33 -" -regex -= -' -^ -\ -B -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb34 -" -regex -= -' -^ -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb35 -" -regex -= -' -^ -\ -B -. -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb36 -" -regex -= -' -^ -\ -B -. -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb37 -" -regex -= -' -^ -^ -^ -^ -^ -\ -B -' -haystack -= -" -" -matches -= -[ -[ -0 -0 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb38 -" -regex -= -' -^ -^ -^ -^ -^ -\ -B -. -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -nb39 -" -regex -= -' -^ -^ -^ -^ -^ -\ -B -' -haystack -= -" -x -" -matches -= -[ -] -unicode -= -false -utf8 -= -false -# -unicode1 -* -and -unicode2 -* -work -for -both -Unicode -and -ASCII -because -all -matches -# -are -reported -as -byte -offsets -and -and -do -not -correspond -to -word -# -boundaries -at -either -the -character -or -byte -level -. -[ -[ -test -] -] -name -= -" -unicode1 -" -regex -= -' -\ -bx -\ -b -' -haystack -= -" -x -" -matches -= -[ -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -unicode1 -- -only -- -ascii -" -regex -= -' -\ -bx -\ -b -' -haystack -= -" -x -" -matches -= -[ -[ -2 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -unicode2 -" -regex -= -' -\ -bx -\ -b -' -haystack -= -" -x -" -matches -= -[ -[ -0 -1 -] -] -[ -[ -test -] -] -name -= -" -unicode2 -- -only -- -ascii -" -regex -= -' -\ -bx -\ -b -' -haystack -= -" -x -" -matches -= -[ -[ -0 -1 -] -] -unicode -= -false -# -ASCII -word -boundaries -are -completely -oblivious -to -Unicode -characters -so -# -even -though -is -a -character -an -ASCII -\ -b -treats -it -as -a -word -boundary -# -when -it -is -adjacent -to -another -ASCII -character -. -( -The -ASCII -\ -b -only -looks -# -at -the -leading -byte -of -. -) -For -Unicode -\ -b -the -tests -are -precisely -inverted -. -[ -[ -test -] -] -name -= -" -unicode3 -" -regex -= -' -\ -bx -\ -b -' -haystack -= -' -x -' -matches -= -[ -] -[ -[ -test -] -] -name -= -" -unicode3 -- -only -- -ascii -" -regex -= -' -\ -bx -\ -b -' -haystack -= -' -x -' -matches -= -[ -[ -2 -3 -] -] -unicode -= -false -[ -[ -test -] -] -name -= -" -unicode4 -" -regex -= -' -\ -Bx -\ -B -' -haystack -= -' -x -' -matches -= -[ -[ -2 -3 -] -] -[ -[ -test -] -] -name -= -" -unicode4 -- -only -- -ascii -" -regex -= -' -\ -Bx -\ -B -' -haystack -= -' -x -' -matches -= -[ -] -unicode -= -false -utf8 -= -false -# -The -same -as -above -but -with -\ -b -instead -of -\ -B -as -a -sanity -check -. -[ -[ -test -] -] -name -= -" -unicode5 -" -regex -= -' -\ -b -' -haystack -= -" -0 -\ -U0007EF5E -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -[ -[ -test -] -] -name -= -" -unicode5 -- -only -- -ascii -" -regex -= -' -\ -b -' -haystack -= -" -0 -\ -U0007EF5E -" -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -unicode -= -false -utf8 -= -false -[ -[ -test -] -] -name -= -" -unicode5 -- -noutf8 -" -regex -= -' -\ -b -' -haystack -= -' -0 -\ -xFF -\ -xFF -\ -xFF -\ -xFF -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -unescape -= -true -utf8 -= -false -[ -[ -test -] -] -name -= -" -unicode5 -- -noutf8 -- -only -- -ascii -" -regex -= -' -\ -b -' -haystack -= -' -0 -\ -xFF -\ -xFF -\ -xFF -\ -xFF -' -matches -= -[ -[ -0 -0 -] -[ -1 -1 -] -] -unescape -= -true -unicode -= -false -utf8 -= -false -# -Weird -special -case -to -ensure -that -ASCII -\ -B -treats -each -individual -code -unit -# -as -a -non -- -word -byte -. -( -The -specific -codepoint -is -irrelevant -. -It -' -s -an -arbitrary -# -codepoint -that -uses -4 -bytes -in -its -UTF -- -8 -encoding -and -is -not -a -member -of -the -# -\ -w -character -class -. -) -[ -[ -test -] -] -name -= -" -unicode5 -- -not -" -regex -= -' -\ -B -' -haystack -= -" -0 -\ -U0007EF5E -" -matches -= -[ -[ -5 -5 -] -] -[ -[ -test -] -] -name -= -" -unicode5 -- -not -- -only -- -ascii -" -regex -= -' -\ -B -' -haystack -= -" -0 -\ -U0007EF5E -" -matches -= -[ -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -unicode -= -false -utf8 -= -false -# -This -gets -no -matches -since -\ -B -only -matches -in -the -presence -of -valid -UTF -- -8 -# -when -Unicode -is -enabled -even -when -UTF -- -8 -mode -is -disabled -. -[ -[ -test -] -] -name -= -" -unicode5 -- -not -- -noutf8 -" -regex -= -' -\ -B -' -haystack -= -' -0 -\ -xFF -\ -xFF -\ -xFF -\ -xFF -' -matches -= -[ -] -unescape -= -true -utf8 -= -false -# -But -this -DOES -get -matches -since -\ -B -in -ASCII -mode -only -looks -at -individual -# -bytes -. -[ -[ -test -] -] -name -= -" -unicode5 -- -not -- -noutf8 -- -only -- -ascii -" -regex -= -' -\ -B -' -haystack -= -' -0 -\ -xFF -\ -xFF -\ -xFF -\ -xFF -' -matches -= -[ -[ -2 -2 -] -[ -3 -3 -] -[ -4 -4 -] -[ -5 -5 -] -] -unescape -= -true -unicode -= -false -utf8 -= -false -# -Some -tests -of -no -particular -significance -. -[ -[ -test -] -] -name -= -" -unicode6 -" -regex -= -' -\ -b -[ -0 -- -9 -] -+ -\ -b -' -haystack -= -" -foo -123 -bar -456 -quux -789 -" -matches -= -[ -[ -4 -7 -] -[ -12 -15 -] -[ -21 -24 -] -] -[ -[ -test -] -] -name -= -" -unicode7 -" -regex -= -' -\ -b -[ -0 -- -9 -] -+ -\ -b -' -haystack -= -" -foo -123 -bar -a456 -quux -789 -" -matches -= -[ -[ -4 -7 -] -[ -22 -25 -] -] -[ -[ -test -] -] -name -= -" -unicode8 -" -regex -= -' -\ -b -[ -0 -- -9 -] -+ -\ -b -' -haystack -= -" -foo -123 -bar -456a -quux -789 -" -matches -= -[ -[ -4 -7 -] -[ -22 -25 -] -] -# -A -variant -of -the -problem -described -here -: -# -https -: -/ -/ -github -. -com -/ -google -/ -re2 -/ -blob -/ -89567f5de5b23bb5ad0c26cbafc10bdc7389d1fa -/ -re2 -/ -dfa -. -cc -# -L658 -- -L667 -[ -[ -test -] -] -name -= -" -alt -- -with -- -assertion -- -repetition -" -regex -= -' -( -? -: -\ -b -| -% -) -+ -' -haystack -= -" -z -% -" -bounds -= -[ -1 -2 -] -anchored -= -true -matches -= -[ -[ -1 -1 -] -] diff --git a/third_party/rust/regex/tests/api.rs b/third_party/rust/regex/tests/api.rs new file mode 100644 index 0000000000000..27208894cf3d3 --- /dev/null +++ b/third_party/rust/regex/tests/api.rs @@ -0,0 +1,3113 @@ +# +[ +test +] +fn +empty_regex_empty_match +( +) +{ +let +re += +regex +! +( +" +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +0 +) +] +findall +! +( +re +" +" +) +) +; +} +# +[ +test +] +fn +empty_regex_nonempty_match +( +) +{ +let +re += +regex +! +( +" +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +] +findall +! +( +re +" +abc +" +) +) +; +} +# +[ +test +] +fn +one_zero_length_match +( +) +{ +let +re += +regex +! +( +r +" +[ +0 +- +9 +] +* +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +0 +) +( +1 +2 +) +( +3 +4 +) +] +findall +! +( +re +" +a1b2 +" +) +) +; +} +# +[ +test +] +fn +many_zero_length_match +( +) +{ +let +re += +regex +! +( +r +" +[ +0 +- +9 +] +* +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +0 +) +( +1 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +6 +) +] +findall +! +( +re +" +a1bbb2 +" +) +) +; +} +# +[ +test +] +fn +many_sequential_zero_length_match +( +) +{ +let +re += +regex +! +( +r +" +[ +0 +- +9 +] +? +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +0 +) +( +1 +2 +) +( +2 +3 +) +( +4 +5 +) +( +6 +6 +) +] +findall +! +( +re +" +a12b3c +" +) +) +; +} +# +[ +test +] +fn +quoted_bracket_set +( +) +{ +let +re += +regex +! +( +r +" +( +[ +\ +x +{ +5b +} +\ +x +{ +5d +} +] +) +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +1 +) +( +1 +2 +) +] +findall +! +( +re +" +[ +] +" +) +) +; +let +re += +regex +! +( +r +" +( +[ +\ +[ +\ +] +] +) +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +1 +) +( +1 +2 +) +] +findall +! +( +re +" +[ +] +" +) +) +; +} +# +[ +test +] +fn +first_range_starts_with_left_bracket +( +) +{ +let +re += +regex +! +( +r +" +( +[ +\ +[ +- +z +] +) +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +1 +) +( +1 +2 +) +] +findall +! +( +re +" +[ +] +" +) +) +; +} +# +[ +test +] +fn +range_ends_with_escape +( +) +{ +let +re += +regex +! +( +r +" +( +[ +\ +[ +- +\ +x +{ +5d +} +] +) +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +1 +) +( +1 +2 +) +] +findall +! +( +re +" +[ +] +" +) +) +; +} +# +[ +test +] +fn +empty_match_find_iter +( +) +{ +let +re += +regex +! +( +r +" +. +* +? +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +] +findall +! +( +re +" +abc +" +) +) +; +} +# +[ +test +] +fn +empty_match_captures_iter +( +) +{ +let +re += +regex +! +( +r +" +. +* +? +" +) +; +let +ms +: +Vec +< +_ +> += +re +. +captures_iter +( +text +! +( +" +abc +" +) +) +. +map +( +| +c +| +c +. +get +( +0 +) +. +unwrap +( +) +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +. +collect +( +) +; +assert_eq +! +( +ms +vec +! +[ +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +] +) +; +} +# +[ +test +] +fn +capture_names +( +) +{ +let +re += +regex +! +( +r +" +( +. +) +( +? +P +< +a +> +. +) +" +) +; +assert_eq +! +( +3 +re +. +captures_len +( +) +) +; +assert_eq +! +( +( +3 +Some +( +3 +) +) +re +. +capture_names +( +) +. +size_hint +( +) +) +; +assert_eq +! +( +vec +! +[ +None +None +Some +( +" +a +" +) +] +re +. +capture_names +( +) +. +collect +: +: +< +Vec +< +_ +> +> +( +) +) +; +} +# +[ +test +] +fn +regex_string +( +) +{ +assert_eq +! +( +r +" +[ +a +- +zA +- +Z0 +- +9 +] ++ +" +regex +! +( +r +" +[ +a +- +zA +- +Z0 +- +9 +] ++ +" +) +. +as_str +( +) +) +; +assert_eq +! +( +r +" +[ +a +- +zA +- +Z0 +- +9 +] ++ +" +& +format +! +( +" +{ +} +" +regex +! +( +r +" +[ +a +- +zA +- +Z0 +- +9 +] ++ +" +) +) +) +; +assert_eq +! +( +r +" +[ +a +- +zA +- +Z0 +- +9 +] ++ +" +& +format +! +( +" +{ +: +? +} +" +regex +! +( +r +" +[ +a +- +zA +- +Z0 +- +9 +] ++ +" +) +) +) +; +} +# +[ +test +] +fn +capture_index +( +) +{ +let +re += +regex +! +( +r +" +^ +( +? +P +< +name +> +. ++ +) +" +) +; +let +cap += +re +. +captures +( +t +! +( +" +abc +" +) +) +. +unwrap +( +) +; +assert_eq +! +( +& +cap +[ +0 +] +t +! +( +" +abc +" +) +) +; +assert_eq +! +( +& +cap +[ +1 +] +t +! +( +" +abc +" +) +) +; +assert_eq +! +( +& +cap +[ +" +name +" +] +t +! +( +" +abc +" +) +) +; +} +# +[ +test +] +# +[ +should_panic +] +# +[ +cfg_attr +( +all +( +target_env += +" +msvc +" +target_pointer_width += +" +32 +" +) +ignore +) +] +fn +capture_index_panic_usize +( +) +{ +let +re += +regex +! +( +r +" +^ +( +? +P +< +name +> +. ++ +) +" +) +; +let +cap += +re +. +captures +( +t +! +( +" +abc +" +) +) +. +unwrap +( +) +; +let +_ += +cap +[ +2 +] +; +} +# +[ +test +] +# +[ +should_panic +] +# +[ +cfg_attr +( +all +( +target_env += +" +msvc +" +target_pointer_width += +" +32 +" +) +ignore +) +] +fn +capture_index_panic_name +( +) +{ +let +re += +regex +! +( +r +" +^ +( +? +P +< +name +> +. ++ +) +" +) +; +let +cap += +re +. +captures +( +t +! +( +" +abc +" +) +) +. +unwrap +( +) +; +let +_ += +cap +[ +" +bad +name +" +] +; +} +# +[ +test +] +fn +capture_index_lifetime +( +) +{ +/ +/ +This +is +a +test +of +whether +the +types +on +caps +[ +" +. +. +. +" +] +are +general +/ +/ +enough +. +If +not +this +will +fail +to +typecheck +. +fn +inner +( +s +: +& +str +) +- +> +usize +{ +let +re += +regex +! +( +r +" +( +? +P +< +number +> +[ +0 +- +9 +] ++ +) +" +) +; +let +caps += +re +. +captures +( +t +! +( +s +) +) +. +unwrap +( +) +; +caps +[ +" +number +" +] +. +len +( +) +} +assert_eq +! +( +3 +inner +( +" +123 +" +) +) +; +} +# +[ +test +] +fn +capture_misc +( +) +{ +let +re += +regex +! +( +r +" +( +. +) +( +? +P +< +a +> +a +) +? +( +. +) +( +? +P +< +b +> +. +) +" +) +; +let +cap += +re +. +captures +( +t +! +( +" +abc +" +) +) +. +unwrap +( +) +; +assert_eq +! +( +5 +cap +. +len +( +) +) +; +assert_eq +! +( +( +0 +3 +) +{ +let +m += +cap +. +get +( +0 +) +. +unwrap +( +) +; +( +m +. +start +( +) +m +. +end +( +) +) +} +) +; +assert_eq +! +( +None +cap +. +get +( +2 +) +) +; +assert_eq +! +( +( +2 +3 +) +{ +let +m += +cap +. +get +( +4 +) +. +unwrap +( +) +; +( +m +. +start +( +) +m +. +end +( +) +) +} +) +; +assert_eq +! +( +t +! +( +" +abc +" +) +match_text +! +( +cap +. +get +( +0 +) +. +unwrap +( +) +) +) +; +assert_eq +! +( +None +cap +. +get +( +2 +) +) +; +assert_eq +! +( +t +! +( +" +c +" +) +match_text +! +( +cap +. +get +( +4 +) +. +unwrap +( +) +) +) +; +assert_eq +! +( +None +cap +. +name +( +" +a +" +) +) +; +assert_eq +! +( +t +! +( +" +c +" +) +match_text +! +( +cap +. +name +( +" +b +" +) +. +unwrap +( +) +) +) +; +} +# +[ +test +] +fn +sub_capture_matches +( +) +{ +let +re += +regex +! +( +r +" +( +[ +a +- +z +] +) +( +( +[ +a +- +z +] +) +| +( +[ +0 +- +9 +] +) +) +" +) +; +let +cap += +re +. +captures +( +t +! +( +" +a5 +" +) +) +. +unwrap +( +) +; +let +subs +: +Vec +< +_ +> += +cap +. +iter +( +) +. +collect +( +) +; +assert_eq +! +( +5 +subs +. +len +( +) +) +; +assert +! +( +subs +[ +0 +] +. +is_some +( +) +) +; +assert +! +( +subs +[ +1 +] +. +is_some +( +) +) +; +assert +! +( +subs +[ +2 +] +. +is_some +( +) +) +; +assert +! +( +subs +[ +3 +] +. +is_none +( +) +) +; +assert +! +( +subs +[ +4 +] +. +is_some +( +) +) +; +assert_eq +! +( +t +! +( +" +a5 +" +) +match_text +! +( +subs +[ +0 +] +. +unwrap +( +) +) +) +; +assert_eq +! +( +t +! +( +" +a +" +) +match_text +! +( +subs +[ +1 +] +. +unwrap +( +) +) +) +; +assert_eq +! +( +t +! +( +" +5 +" +) +match_text +! +( +subs +[ +2 +] +. +unwrap +( +) +) +) +; +assert_eq +! +( +t +! +( +" +5 +" +) +match_text +! +( +subs +[ +4 +] +. +unwrap +( +) +) +) +; +} +expand +! +( +expand1 +r +" +( +? +- +u +) +( +? +P +< +foo +> +\ +w ++ +) +" +" +abc +" +" +foo +" +" +abc +" +) +; +expand +! +( +expand2 +r +" +( +? +- +u +) +( +? +P +< +foo +> +\ +w ++ +) +" +" +abc +" +" +0 +" +" +abc +" +) +; +expand +! +( +expand3 +r +" +( +? +- +u +) +( +? +P +< +foo +> +\ +w ++ +) +" +" +abc +" +" +1 +" +" +abc +" +) +; +expand +! +( +expand4 +r +" +( +? +- +u +) +( +? +P +< +foo +> +\ +w ++ +) +" +" +abc +" +" +1 +" +" +1 +" +) +; +expand +! +( +expand5 +r +" +( +? +- +u +) +( +? +P +< +foo +> +\ +w ++ +) +" +" +abc +" +" +foo +" +" +foo +" +) +; +expand +! +( +expand6 +r +" +( +? +- +u +) +( +? +P +< +a +> +\ +w ++ +) +\ +s ++ +( +? +P +< +b +> +\ +d ++ +) +" +" +abc +123 +" +" +b +a +" +" +123abc +" +) +; +expand +! +( +expand7 +r +" +( +? +- +u +) +( +? +P +< +a +> +\ +w ++ +) +\ +s ++ +( +? +P +< +b +> +\ +d ++ +) +" +" +abc +123 +" +" +z +bz +az +" +" +z +" +) +; +expand +! +( +expand8 +r +" +( +? +- +u +) +( +? +P +< +a +> +\ +w ++ +) +\ +s ++ +( +? +P +< +b +> +\ +d ++ +) +" +" +abc +123 +" +" +. +b +. +a +. +" +" +. +123 +. +abc +. +" +) +; +expand +! +( +expand9 +r +" +( +? +- +u +) +( +? +P +< +a +> +\ +w ++ +) +\ +s ++ +( +? +P +< +b +> +\ +d ++ +) +" +" +abc +123 +" +" +b +a +" +" +123 +abc +" +) +; +expand +! +( +expand10 +r +" +( +? +- +u +) +( +? +P +< +a +> +\ +w ++ +) +\ +s ++ +( +? +P +< +b +> +\ +d ++ +) +" +" +abc +123 +" +" +bz +az +" +" +" +) +; +expand +! +( +expand_name1 +r +" +% +( +? +P +< +Z +> +[ +a +- +z +] ++ +) +" +" +% +abc +" +" +Z +% +" +" +abc +% +" +) +; +expand +! +( +expand_name2 +r +" +\ +[ +( +? +P +< +Z +> +[ +a +- +z +] ++ +) +" +" +[ +abc +" +" +Z +[ +" +" +abc +[ +" +) +; +expand +! +( +expand_name3 +r +" +\ +{ +( +? +P +< +Z +> +[ +a +- +z +] ++ +) +" +" +{ +abc +" +" +Z +{ +" +" +abc +{ +" +) +; +expand +! +( +expand_name4 +r +" +\ +} +( +? +P +< +Z +> +[ +a +- +z +] ++ +) +" +" +} +abc +" +" +Z +} +" +" +abc +} +" +) +; +expand +! +( +expand_name5 +r +" +% +( +[ +a +- +z +] ++ +) +" +" +% +abc +" +" +1a +% +" +" +% +" +) +; +expand +! +( +expand_name6 +r +" +% +( +[ +a +- +z +] ++ +) +" +" +% +abc +" +" +{ +1 +} +a +% +" +" +abca +% +" +) +; +expand +! +( +expand_name7 +r +" +\ +[ +( +? +P +< +Z +[ +> +[ +a +- +z +] ++ +) +" +" +[ +abc +" +" +{ +Z +[ +} +[ +" +" +abc +[ +" +) +; +expand +! +( +expand_name8 +r +" +\ +[ +( +? +P +< +Z +[ +> +[ +a +- +z +] ++ +) +" +" +[ +abc +" +" +{ +foo +} +[ +" +" +[ +" +) +; +expand +! +( +expand_name9 +r +" +\ +[ +( +? +P +< +Z +[ +> +[ +a +- +z +] ++ +) +" +" +[ +abc +" +" +{ +1a +} +[ +" +" +[ +" +) +; +expand +! +( +expand_name10 +r +" +\ +[ +( +? +P +< +Z +[ +> +[ +a +- +z +] ++ +) +" +" +[ +abc +" +" +{ +# +} +[ +" +" +[ +" +) +; +expand +! +( +expand_name11 +r +" +\ +[ +( +? +P +< +Z +[ +> +[ +a +- +z +] ++ +) +" +" +[ +abc +" +" +{ +} +[ +" +" +[ +" +) +; +split +! +( +split1 +r +" +( +? +- +u +) +\ +s ++ +" +" +a +b +\ +nc +\ +td +\ +n +\ +t +e +" +& +[ +t +! +( +" +a +" +) +t +! +( +" +b +" +) +t +! +( +" +c +" +) +t +! +( +" +d +" +) +t +! +( +" +e +" +) +] +) +; +split +! +( +split2 +r +" +( +? +- +u +) +\ +b +" +" +a +b +c +" +& +[ +t +! +( +" +" +) +t +! +( +" +a +" +) +t +! +( +" +" +) +t +! +( +" +b +" +) +t +! +( +" +" +) +t +! +( +" +c +" +) +t +! +( +" +" +) +] +) +; +split +! +( +split3 +r +" +a +" +" +a +" +& +[ +t +! +( +" +" +) +t +! +( +" +" +) +] +) +; +split +! +( +split_none +r +" +- +" +r +" +a +" +& +[ +t +! +( +" +a +" +) +] +) +; +split +! +( +split_trailing_blank +r +" +- +" +r +" +a +- +" +& +[ +t +! +( +" +a +" +) +t +! +( +" +" +) +] +) +; +split +! +( +split_trailing_blanks +r +" +- +" +r +" +a +- +- +" +& +[ +t +! +( +" +a +" +) +t +! +( +" +" +) +t +! +( +" +" +) +] +) +; +split +! +( +split_empty +r +" +- +" +r +" +" +& +[ +t +! +( +" +" +) +] +) +; +splitn +! +( +splitn_below_limit +r +" +- +" +r +" +a +" +2 +& +[ +t +! +( +" +a +" +) +] +) +; +splitn +! +( +splitn_at_limit +r +" +- +" +r +" +a +- +b +" +2 +& +[ +t +! +( +" +a +" +) +t +! +( +" +b +" +) +] +) +; +splitn +! +( +splitn_above_limit +r +" +- +" +r +" +a +- +b +- +c +" +2 +& +[ +t +! +( +" +a +" +) +t +! +( +" +b +- +c +" +) +] +) +; +splitn +! +( +splitn_zero_limit +r +" +- +" +r +" +a +- +b +" +0 +empty_vec +! +( +) +) +; +splitn +! +( +splitn_trailing_blank +r +" +- +" +r +" +a +- +" +2 +& +[ +t +! +( +" +a +" +) +t +! +( +" +" +) +] +) +; +splitn +! +( +splitn_trailing_separator +r +" +- +" +r +" +a +- +- +" +2 +& +[ +t +! +( +" +a +" +) +t +! +( +" +- +" +) +] +) +; +splitn +! +( +splitn_empty +r +" +- +" +r +" +" +1 +& +[ +t +! +( +" +" +) +] +) +; diff --git a/third_party/rust/regex/tests/api_str.rs b/third_party/rust/regex/tests/api_str.rs new file mode 100644 index 0000000000000..cbcee07d917b3 --- /dev/null +++ b/third_party/rust/regex/tests/api_str.rs @@ -0,0 +1,361 @@ +/ +/ +These +tests +don +' +t +really +make +sense +with +the +bytes +API +so +we +only +test +them +/ +/ +on +the +Unicode +API +. +# +[ +test +] +fn +empty_match_unicode_find_iter +( +) +{ +/ +/ +Tests +that +we +still +yield +byte +ranges +at +valid +UTF +- +8 +sequence +boundaries +/ +/ +even +when +we +' +re +susceptible +to +empty +width +matches +. +let +re += +regex +! +( +r +" +. +* +? +" +) +; +assert_eq +! +( +vec +! +[ +( +0 +0 +) +( +3 +3 +) +( +4 +4 +) +( +7 +7 +) +( +8 +8 +) +] +findall +! +( +re +" +1 +2 +" +) +) +; +} +# +[ +test +] +fn +empty_match_unicode_captures_iter +( +) +{ +/ +/ +Same +as +empty_match_unicode_find_iter +but +tests +capture +iteration +. +let +re += +regex +! +( +r +" +. +* +? +" +) +; +let +ms +: +Vec +< +_ +> += +re +. +captures_iter +( +text +! +( +" +1 +2 +" +) +) +. +map +( +| +c +| +c +. +get +( +0 +) +. +unwrap +( +) +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +. +collect +( +) +; +assert_eq +! +( +vec +! +[ +( +0 +0 +) +( +3 +3 +) +( +4 +4 +) +( +7 +7 +) +( +8 +8 +) +] +ms +) +; +} +# +[ +test +] +fn +match_as_str +( +) +{ +let +re += +regex +! +( +r +" +fo ++ +" +) +; +let +caps += +re +. +captures +( +" +barfoobar +" +) +. +unwrap +( +) +; +assert_eq +! +( +caps +. +get +( +0 +) +. +map +( +| +m +| +m +. +as_str +( +) +) +Some +( +" +foo +" +) +) +; +assert_eq +! +( +caps +. +get +( +0 +) +. +map +( +From +: +: +from +) +Some +( +" +foo +" +) +) +; +assert_eq +! +( +caps +. +get +( +0 +) +. +map +( +Into +: +: +into +) +Some +( +" +foo +" +) +) +; +} diff --git a/third_party/rust/regex/tests/bytes.rs b/third_party/rust/regex/tests/bytes.rs new file mode 100644 index 0000000000000..2e68481a6fd59 --- /dev/null +++ b/third_party/rust/regex/tests/bytes.rs @@ -0,0 +1,1378 @@ +/ +/ +These +are +tests +specifically +crafted +for +regexes +that +can +match +arbitrary +/ +/ +bytes +. +/ +/ +A +silly +wrapper +to +make +it +possible +to +write +and +match +raw +bytes +. +struct +R +< +' +a +> +( +& +' +a +[ +u8 +] +) +; +impl +< +' +a +> +R +< +' +a +> +{ +fn +as_bytes +( +& +self +) +- +> +& +' +a +[ +u8 +] +{ +self +. +0 +} +} +mat +! +( +word_boundary +r +" +( +? +- +u +) +\ +b +" +" +" +None +) +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mat +! +( +word_boundary_unicode +r +" +\ +b +" +" +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +word_not_boundary +r +" +( +? +- +u +) +\ +B +" +" +" +Some +( +( +0 +1 +) +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mat +! +( +word_not_boundary_unicode +r +" +\ +B +" +" +" +None +) +; +mat +! +( +perl_w_ascii +r +" +( +? +- +u +) +\ +w ++ +" +" +a +" +Some +( +( +0 +1 +) +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mat +! +( +perl_w_unicode +r +" +\ +w ++ +" +" +a +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +perl_d_ascii +r +" +( +? +- +u +) +\ +d ++ +" +" +1 +9 +" +Some +( +( +0 +1 +) +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mat +! +( +perl_d_unicode +r +" +\ +d ++ +" +" +1 +9 +" +Some +( +( +0 +8 +) +) +) +; +mat +! +( +perl_s_ascii +r +" +( +? +- +u +) +\ +s ++ +" +" +\ +u +{ +1680 +} +" +Some +( +( +0 +1 +) +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mat +! +( +perl_s_unicode +r +" +\ +s ++ +" +" +\ +u +{ +1680 +} +" +Some +( +( +0 +4 +) +) +) +; +/ +/ +The +first +( +. ++ +) +matches +two +Unicode +codepoints +but +can +' +t +match +the +5th +/ +/ +byte +which +isn +' +t +valid +UTF +- +8 +. +The +second +( +byte +based +) +( +. ++ +) +takes +over +and +/ +/ +matches +. +mat +! +( +mixed1 +r +" +( +. ++ +) +( +? +- +u +) +( +. ++ +) +" +R +( +b +" +\ +xCE +\ +x93 +\ +xCE +\ +x94 +\ +xFF +" +) +Some +( +( +0 +5 +) +) +Some +( +( +0 +4 +) +) +Some +( +( +4 +5 +) +) +) +; +mat +! +( +case_ascii_one +r +" +( +? +i +- +u +) +a +" +" +A +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +case_ascii_class +r +" +( +? +i +- +u +) +[ +a +- +z +] ++ +" +" +AaAaA +" +Some +( +( +0 +5 +) +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +mat +! +( +case_unicode +r +" +( +? +i +) +[ +a +- +z +] ++ +" +" +aA +\ +u +{ +212A +} +aA +" +Some +( +( +0 +7 +) +) +) +; +mat +! +( +case_not_unicode +r +" +( +? +i +- +u +) +[ +a +- +z +] ++ +" +" +aA +\ +u +{ +212A +} +aA +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +negate_unicode +r +" +[ +^ +a +] +" +" +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +negate_not_unicode +r +" +( +? +- +u +) +[ +^ +a +] +" +" +" +Some +( +( +0 +1 +) +) +) +; +/ +/ +This +doesn +' +t +match +in +a +normal +Unicode +regex +because +the +implicit +preceding +/ +/ +. +* +? +is +Unicode +aware +. +mat +! +( +dotstar_prefix_not_unicode1 +r +" +( +? +- +u +) +a +" +R +( +b +" +\ +xFFa +" +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +dotstar_prefix_not_unicode2 +r +" +a +" +R +( +b +" +\ +xFFa +" +) +Some +( +( +1 +2 +) +) +) +; +/ +/ +Have +fun +with +null +bytes +. +mat +! +( +null_bytes +r +" +( +? +- +u +) +( +? +P +< +cstr +> +[ +^ +\ +x00 +] ++ +) +\ +x00 +" +R +( +b +" +foo +\ +x00 +" +) +Some +( +( +0 +4 +) +) +Some +( +( +0 +3 +) +) +) +; +/ +/ +Test +that +lookahead +operators +work +properly +in +the +face +of +invalid +UTF +- +8 +. +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +277 +matiter +! +( +invalidutf8_anchor1 +r +" +( +? +- +u +) +\ +xcc +? +^ +" +R +( +b +" +\ +x8d +# +; +\ +x1a +\ +xa4s3 +\ +x05foobarX +\ +\ +\ +x0f0t +\ +xe4 +\ +x9b +\ +xa4 +" +) +( +0 +0 +) +) +; +matiter +! +( +invalidutf8_anchor2 +r +" +( +? +- +u +) +^ +\ +xf7 +| +4 +\ +xff +\ +d +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +# +# +# +# +# +# +# +# +# +# +[ +] +d +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +\ +x8a +# +# +# +# +# +# +# +# +# +# +\ +[ +] +# +# +# +# +# +\ +x80 +\ +S7 +| +" +R +( +b +" +\ +x8d +# +; +\ +x1a +\ +xa4s3 +\ +x05foobarX +\ +\ +\ +x0f0t +\ +xe4 +\ +x9b +\ +xa4 +" +) +( +22 +22 +) +) +; +matiter +! +( +invalidutf8_anchor3 +r +" +( +? +- +u +) +^ +| +ddp +\ +xff +\ +xffdddddlQd +\ +x80 +" +R +( +b +" +\ +x8d +# +; +\ +x1a +\ +xa4s3 +\ +x05foobarX +\ +\ +\ +x0f0t +\ +xe4 +\ +x9b +\ +xa4 +" +) +( +0 +0 +) +) +; +/ +/ +See +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +303 +# +[ +test +] +fn +negated_full_byte_range +( +) +{ +assert +! +( +: +: +regex +: +: +bytes +: +: +Regex +: +: +new +( +r +# +" +( +? +- +u +) +[ +^ +\ +x00 +- +\ +xff +] +" +# +) +. +is_err +( +) +) +; +} +matiter +! +( +word_boundary_ascii1 +r +" +( +? +- +u +: +\ +B +) +x +( +? +- +u +: +\ +B +) +" +" +x +" +) +; +matiter +! +( +word_boundary_ascii2 +r +" +( +? +- +u +: +\ +B +) +" +" +0 +\ +u +{ +7EF5E +} +" +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +5 +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +264 +mat +! +( +ascii_boundary_no_capture +r +" +( +? +- +u +) +\ +B +" +" +\ +u +{ +28f3e +} +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +ascii_boundary_capture +r +" +( +? +- +u +) +( +\ +B +) +" +" +\ +u +{ +28f3e +} +" +Some +( +( +0 +0 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +271 +mat +! +( +end_not_wb +r +" +( +? +- +u +: +\ +B +) +" +" +\ +u +{ +5c124 +} +\ +u +{ +b576c +} +" +Some +( +( +8 +8 +) +) +) +; diff --git a/third_party/rust/regex/tests/consistent.rs b/third_party/rust/regex/tests/consistent.rs new file mode 100644 index 0000000000000..a639f7ba54df7 --- /dev/null +++ b/third_party/rust/regex/tests/consistent.rs @@ -0,0 +1,1540 @@ +use +regex +: +: +internal +: +: +ExecBuilder +; +/ +/ +/ +Given +a +regex +check +if +all +of +the +backends +produce +the +same +/ +/ +/ +results +on +a +number +of +different +inputs +. +/ +/ +/ +/ +/ +/ +For +now +this +just +throws +quickcheck +at +the +problem +which +/ +/ +/ +is +not +very +good +because +it +only +really +tests +half +of +the +/ +/ +/ +problem +space +. +It +is +pretty +unlikely +that +a +random +string +/ +/ +/ +will +match +any +given +regex +so +this +will +probably +just +/ +/ +/ +be +checking +that +the +different +backends +fail +in +the +same +/ +/ +/ +way +. +This +is +still +worthwhile +to +test +but +is +definitely +not +/ +/ +/ +the +whole +story +. +/ +/ +/ +/ +/ +/ +TODO +( +ethan +) +: +In +order +to +cover +the +other +half +of +the +problem +/ +/ +/ +space +we +should +generate +a +random +matching +string +by +inspecting +/ +/ +/ +the +AST +of +the +input +regex +. +The +right +way +to +do +this +probably +/ +/ +/ +involves +adding +a +custom +Arbitrary +instance +around +a +couple +/ +/ +/ +of +newtypes +. +That +way +we +can +respect +the +quickcheck +size +hinting +/ +/ +/ +and +shrinking +and +whatnot +. +pub +fn +backends_are_consistent +( +re +: +& +str +) +- +> +Result +< +u64 +String +> +{ +let +standard_backends += +vec +! +[ +( +" +bounded_backtracking_re +" +ExecBuilder +: +: +new +( +re +) +. +bounded_backtracking +( +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +( +" +pikevm_re +" +ExecBuilder +: +: +new +( +re +) +. +nfa +( +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +( +" +default_re +" +ExecBuilder +: +: +new +( +re +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +] +; +let +utf8bytes_backends += +vec +! +[ +( +" +bounded_backtracking_utf8bytes_re +" +ExecBuilder +: +: +new +( +re +) +. +bounded_backtracking +( +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +( +" +pikevm_utf8bytes_re +" +ExecBuilder +: +: +new +( +re +) +. +nfa +( +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +( +" +default_utf8bytes_re +" +ExecBuilder +: +: +new +( +re +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +] +; +let +bytes_backends += +vec +! +[ +( +" +bounded_backtracking_bytes_re +" +ExecBuilder +: +: +new +( +re +) +. +bounded_backtracking +( +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_byte_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +( +" +pikevm_bytes_re +" +ExecBuilder +: +: +new +( +re +) +. +nfa +( +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_byte_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +( +" +default_bytes_re +" +ExecBuilder +: +: +new +( +re +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_byte_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +? +) +] +; +Ok +( +string_checker +: +: +check_backends +( +& +standard_backends +) +? ++ +string_checker +: +: +check_backends +( +& +utf8bytes_backends +) +? ++ +bytes_checker +: +: +check_backends +( +& +bytes_backends +) +? +) +} +/ +/ +/ +/ +A +consistency +checker +parameterized +by +the +input +type +( +& +str +or +& +[ +u8 +] +) +. +/ +/ +macro_rules +! +checker +{ +( +module_name +: +ident +regex_type +: +path +mk_input +: +expr +) += +> +{ +mod +module_name +{ +use +quickcheck +; +use +quickcheck +: +: +{ +Arbitrary +TestResult +} +; +pub +fn +check_backends +( +backends +: +& +[ +( +& +str +regex_type +) +] +) +- +> +Result +< +u64 +String +> +{ +let +mut +total_passed += +0 +; +for +regex +in +backends +[ +1 +. +. +] +. +iter +( +) +{ +total_passed ++ += +quickcheck_regex_eq +( +& +backends +[ +0 +] +regex +) +? +; +} +Ok +( +total_passed +) +} +fn +quickcheck_regex_eq +( +& +( +name1 +ref +re1 +) +: +& +( +& +str +regex_type +) +& +( +name2 +ref +re2 +) +: +& +( +& +str +regex_type +) +) +- +> +Result +< +u64 +String +> +{ +quickcheck +: +: +QuickCheck +: +: +new +( +) +. +quicktest +( +RegexEqualityTest +: +: +new +( +re1 +. +clone +( +) +re2 +. +clone +( +) +) +) +. +map_err +( +| +err +| +{ +format +! +( +" +{ +} +( +/ +{ +} +/ +) +and +{ +} +( +/ +{ +} +/ +) +are +inconsistent +. +\ +QuickCheck +Err +: +{ +: +? +} +" +name1 +re1 +name2 +re2 +err +) +} +) +} +struct +RegexEqualityTest +{ +re1 +: +regex_type +re2 +: +regex_type +} +impl +RegexEqualityTest +{ +fn +new +( +re1 +: +regex_type +re2 +: +regex_type +) +- +> +Self +{ +RegexEqualityTest +{ +re1 +: +re1 +re2 +: +re2 +} +} +} +impl +quickcheck +: +: +Testable +for +RegexEqualityTest +{ +fn +result +( +& +self +gen +: +& +mut +quickcheck +: +: +Gen +) +- +> +TestResult +{ +let +input += +mk_input +( +gen +) +; +let +input += +& +input +; +if +self +. +re1 +. +find +( +& +input +) +! += +self +. +re2 +. +find +( +input +) +{ +return +TestResult +: +: +error +( +format +! +( +" +find +mismatch +input += +{ +: +? +} +" +input +) +) +; +} +let +cap1 += +self +. +re1 +. +captures +( +input +) +; +let +cap2 += +self +. +re2 +. +captures +( +input +) +; +match +( +cap1 +cap2 +) +{ +( +None +None +) += +> +{ +} +( +Some +( +cap1 +) +Some +( +cap2 +) +) += +> +{ +for +( +c1 +c2 +) +in +cap1 +. +iter +( +) +. +zip +( +cap2 +. +iter +( +) +) +{ +if +c1 +! += +c2 +{ +return +TestResult +: +: +error +( +format +! +( +" +captures +mismatch +input += +{ +: +? +} +" +input +) +) +; +} +} +} +_ += +> +{ +return +TestResult +: +: +error +( +format +! +( +" +captures +mismatch +input += +{ +: +? +} +" +input +) +) +} +} +let +fi1 += +self +. +re1 +. +find_iter +( +input +) +; +let +fi2 += +self +. +re2 +. +find_iter +( +input +) +; +for +( +m1 +m2 +) +in +fi1 +. +zip +( +fi2 +) +{ +if +m1 +! += +m2 +{ +return +TestResult +: +: +error +( +format +! +( +" +find_iter +mismatch +input += +{ +: +? +} +" +input +) +) +; +} +} +let +ci1 += +self +. +re1 +. +captures_iter +( +input +) +; +let +ci2 += +self +. +re2 +. +captures_iter +( +input +) +; +for +( +cap1 +cap2 +) +in +ci1 +. +zip +( +ci2 +) +{ +for +( +c1 +c2 +) +in +cap1 +. +iter +( +) +. +zip +( +cap2 +. +iter +( +) +) +{ +if +c1 +! += +c2 +{ +return +TestResult +: +: +error +( +format +! +( +" +captures_iter +mismatch +input += +{ +: +? +} +" +input +) +) +; +} +} +} +let +s1 += +self +. +re1 +. +split +( +input +) +; +let +s2 += +self +. +re2 +. +split +( +input +) +; +for +( +chunk1 +chunk2 +) +in +s1 +. +zip +( +s2 +) +{ +if +chunk1 +! += +chunk2 +{ +return +TestResult +: +: +error +( +format +! +( +" +split +mismatch +input += +{ +: +? +} +" +input +) +) +; +} +} +TestResult +: +: +from_bool +( +true +) +} +} +} +/ +/ +mod +} +; +/ +/ +rule +case +} +/ +/ +macro_rules +! +checker +! +( +string_checker +: +: +regex +: +: +Regex +| +gen +| +String +: +: +arbitrary +( +gen +) +) +; +checker +! +( +bytes_checker +: +: +regex +: +: +bytes +: +: +Regex +| +gen +| +Vec +: +: +< +u8 +> +: +: +arbitrary +( +gen +) +) +; diff --git a/third_party/rust/regex/tests/crates_regex.rs b/third_party/rust/regex/tests/crates_regex.rs new file mode 100644 index 0000000000000..f68ec03cce9ae --- /dev/null +++ b/third_party/rust/regex/tests/crates_regex.rs @@ -0,0 +1,63116 @@ +/ +/ +DO +NOT +EDIT +. +Automatically +generated +by +' +scripts +/ +scrape_crates_io +. +py +' +/ +/ +on +2018 +- +06 +- +20 +09 +: +56 +: +32 +. +820354 +. +/ +/ +autoshutdown +- +0 +. +1 +. +0 +: +r +" +\ +s +* +( +\ +d ++ +) +( +\ +w +) +\ +s +* +" +consistent +! +( +autoshutdown_0 +r +" +\ +s +* +( +\ +d ++ +) +( +\ +w +) +\ +s +* +" +) +; +/ +/ +epub +- +1 +. +1 +. +1 +: +r +" +/ +" +consistent +! +( +epub_0 +r +" +/ +" +) +; +/ +/ +rpi +- +info +- +0 +. +2 +. +0 +: +" +^ +Revision +\ +t ++ +: +( +[ +0 +- +9a +- +fA +- +F +] ++ +) +" +consistent +! +( +rpi_info_0 +" +^ +Revision +\ +t ++ +: +( +[ +0 +- +9a +- +fA +- +F +] ++ +) +" +) +; +/ +/ +rpi +- +info +- +0 +. +2 +. +0 +: +" +Serial +\ +t ++ +: +( +[ +0 +- +9a +- +fA +- +F +] ++ +) +" +consistent +! +( +rpi_info_1 +" +Serial +\ +t ++ +: +( +[ +0 +- +9a +- +fA +- +F +] ++ +) +" +) +; +/ +/ +pnet_macros +- +0 +. +21 +. +0 +: +r +" +^ +u +( +[ +0 +- +9 +] ++ +) +( +be +| +le +| +he +) +? +" +consistent +! +( +pnet_macros_0 +r +" +^ +u +( +[ +0 +- +9 +] ++ +) +( +be +| +le +| +he +) +? +" +) +; +/ +/ +iban_validate +- +1 +. +0 +. +3 +: +r +" +^ +[ +A +- +Z +] +{ +2 +} +\ +d +{ +2 +} +[ +A +- +Z +\ +d +] +{ +1 +30 +} +" +consistent +! +( +iban_validate_0 +r +" +^ +[ +A +- +Z +] +{ +2 +} +\ +d +{ +2 +} +[ +A +- +Z +\ +d +] +{ +1 +30 +} +" +) +; +/ +/ +markifier +- +0 +. +1 +. +0 +: +r +" +. +* +\ +[ +( +? +P +< +percent +> +. ++ +) +% +. +* +\ +] +. +* +" +consistent +! +( +markifier_0 +r +" +. +* +\ +[ +( +? +P +< +percent +> +. ++ +) +% +. +* +\ +] +. +* +" +) +; +/ +/ +mallumo +- +0 +. +3 +. +0 +: +r +" +( +# +include +) +( +\ +S +* +) +( +. +* +) +" +consistent +! +( +mallumo_0 +r +" +( +# +include +) +( +\ +S +* +) +( +. +* +) +" +) +; +/ +/ +mallumo +- +0 +. +3 +. +0 +: +r +" +( +ERROR +: +\ +d ++ +: +) +( +\ +d ++ +) +( +: +) +( +. ++ +) +" +consistent +! +( +mallumo_1 +r +" +( +ERROR +: +\ +d ++ +: +) +( +\ +d ++ +) +( +: +) +( +. ++ +) +" +) +; +/ +/ +mallumo +- +0 +. +3 +. +0 +: +r +" +( +\ +d ++ +\ +( +) +( +\ +d ++ +) +( +? +: +\ +) +: +) +( +. ++ +) +" +consistent +! +( +mallumo_2 +r +" +( +\ +d ++ +\ +( +) +( +\ +d ++ +) +( +? +: +\ +) +: +) +( +. ++ +) +" +) +; +/ +/ +magnet_more +- +0 +. +0 +. +1 +: +r +" +( +. ++ +? +) +( +\ +[ +. +* +? +\ +] +) +? +" +consistent +! +( +magnet_more_0 +r +" +( +. ++ +? +) +( +\ +[ +. +* +? +\ +] +) +? +" +) +; +/ +/ +magnet_app +- +0 +. +0 +. +1 +: +r +" +: +( +? +P +< +k +> +[ +a +- +zA +- +Z_ +] ++ +) +" +consistent +! +( +magnet_app_0 +r +" +: +( +? +P +< +k +> +[ +a +- +zA +- +Z_ +] ++ +) +" +) +; +/ +/ +yubibomb +- +0 +. +2 +. +0 +: +r +" +^ +\ +d +{ +6 +} +( +? +: +\ +s +* +\ +s +* +\ +d +{ +6 +} +) +* +" +consistent +! +( +yubibomb_0 +r +" +^ +\ +d +{ +6 +} +( +? +: +\ +s +* +\ +s +* +\ +d +{ +6 +} +) +* +" +) +; +/ +/ +multirust +- +rs +- +0 +. +0 +. +4 +: +r +" +[ +\ +\ +/ +] +( +[ +^ +\ +\ +/ +? +] ++ +) +( +\ +? +. +* +) +? +" +consistent +! +( +multirust_rs_0 +r +" +[ +\ +\ +/ +] +( +[ +^ +\ +\ +/ +? +] ++ +) +( +\ +? +. +* +) +? +" +) +; +/ +/ +hueclient +- +0 +. +3 +. +2 +: +" +\ +" +[ +a +- +z +] +* +\ +" +: +null +" +consistent +! +( +hueclient_0 +" +\ +" +[ +a +- +z +] +* +\ +" +: +null +" +) +; +/ +/ +hueclient +- +0 +. +3 +. +2 +: +" ++ +" +consistent +! +( +hueclient_1 +" ++ +" +) +; +/ +/ +hueclient +- +0 +. +3 +. +2 +: +" +\ +\ +} +" +consistent +! +( +hueclient_2 +" +\ +\ +} +" +) +; +/ +/ +hueclient +- +0 +. +3 +. +2 +: +" +\ +\ +{ +" +consistent +! +( +hueclient_3 +" +\ +\ +{ +" +) +; +/ +/ +aerial +- +0 +. +1 +. +0 +: +r +" +[ +a +- +zA +- +Z_ +\ +] +[ +a +- +zA +- +Z_0 +- +9 +] +* +" +consistent +! +( +aerial_0 +r +" +[ +a +- +zA +- +Z_ +\ +] +[ +a +- +zA +- +Z_0 +- +9 +] +* +" +) +; +/ +/ +aerial +- +0 +. +1 +. +0 +: +r +" +thi +[ +sng +] ++ +" +consistent +! +( +aerial_1 +r +" +thi +[ +sng +] ++ +" +) +; +/ +/ +rvue +- +0 +. +1 +. +0 +: +r +" +( +. ++ +) +\ +s ++ +\ +( +( +. ++ +? +) +\ +) +" +consistent +! +( +rvue_0 +r +" +( +. ++ +) +\ +s ++ +\ +( +( +. ++ +? +) +\ +) +" +) +; +/ +/ +rvue +- +0 +. +1 +. +0 +: +r +" +( +[ +\ +d +\ +. +] ++ +) +\ +s +* +out +\ +s +* +of +\ +s +* +( +[ +\ +d +\ +. +] ++ +) +" +consistent +! +( +rvue_1 +r +" +( +[ +\ +d +\ +. +] ++ +) +\ +s +* +out +\ +s +* +of +\ +s +* +( +[ +\ +d +\ +. +] ++ +) +" +) +; +/ +/ +rvue +- +0 +. +1 +. +0 +: +r +" +^ +( +[ +\ +d +\ +. +] ++ +) +\ +s +* +( +? +: +\ +( +\ +) +) +? +" +consistent +! +( +rvue_2 +r +" +^ +( +[ +\ +d +\ +. +] ++ +) +\ +s +* +( +? +: +\ +( +\ +) +) +? +" +) +; +/ +/ +rvue +- +0 +. +1 +. +0 +: +r +" +( +[ +\ +d +\ +. +] ++ +) +\ +s +* +Points +\ +s +* +Possible +" +consistent +! +( +rvue_3 +r +" +( +[ +\ +d +\ +. +] ++ +) +\ +s +* +Points +\ +s +* +Possible +" +) +; +/ +/ +rvue +- +0 +. +1 +. +0 +: +r +" +( +[ +\ +d +\ +. +] ++ +) +\ +s +* +/ +\ +s +* +( +[ +\ +d +\ +. +] ++ +) +" +consistent +! +( +rvue_4 +r +" +( +[ +\ +d +\ +. +] ++ +) +\ +s +* +/ +\ +s +* +( +[ +\ +d +\ +. +] ++ +) +" +) +; +/ +/ +rvsim +- +0 +. +1 +. +0 +: +r +" +_ +? +( +[ +_a +- +z0 +- +9 +] ++ +) +\ +s +* +: +\ +s +* +( +[ +_a +- +z0 +- +9 +] ++ +) +\ +s +* +[ +) +] +" +consistent +! +( +rvsim_0 +r +" +_ +? +( +[ +_a +- +z0 +- +9 +] ++ +) +\ +s +* +: +\ +s +* +( +[ +_a +- +z0 +- +9 +] ++ +) +\ +s +* +[ +) +] +" +) +; +/ +/ +nereon +- +0 +. +1 +. +4 +: +" +( +. +* +[ +^ +\ +\ +\ +\ +] +) +\ +\ +{ +\ +\ +} +( +. +* +) +" +consistent +! +( +nereon_0 +" +( +. +* +[ +^ +\ +\ +\ +\ +] +) +\ +\ +{ +\ +\ +} +( +. +* +) +" +) +; +/ +/ +next_episode +- +0 +. +3 +. +0 +: +r +" +( +( +? +i +) +^ +( +. ++ +) +. +s +( +\ +d ++ +) +e +( +\ +d ++ +) +. +* +) +" +consistent +! +( +next_episode_0 +r +" +( +( +? +i +) +^ +( +. ++ +) +. +s +( +\ +d ++ +) +e +( +\ +d ++ +) +. +* +) +" +) +; +/ +/ +migrant_lib +- +0 +. +19 +. +2 +: +r +" +[ +^ +a +- +z0 +- +9 +- +] ++ +" +consistent +! +( +migrant_lib_0 +r +" +[ +^ +a +- +z0 +- +9 +- +] ++ +" +) +; +/ +/ +migrant_lib +- +0 +. +19 +. +2 +: +r +" +[ +0 +- +9 +] +{ +14 +} +_ +[ +a +- +z0 +- +9 +- +] ++ +" +consistent +! +( +migrant_lib_1 +r +" +[ +0 +- +9 +] +{ +14 +} +_ +[ +a +- +z0 +- +9 +- +] ++ +" +) +; +/ +/ +migrant_lib +- +0 +. +19 +. +2 +: +r +" +( +[ +0 +- +9 +] +{ +14 +} +_ +) +? +[ +a +- +z0 +- +9 +- +] ++ +" +consistent +! +( +migrant_lib_2 +r +" +( +[ +0 +- +9 +] +{ +14 +} +_ +) +? +[ +a +- +z0 +- +9 +- +] ++ +" +) +; +/ +/ +minipre +- +0 +. +2 +. +0 +: +" +_ +" +consistent +! +( +minipre_0 +" +_ +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +r +" +> +\ +s ++ +< +" +consistent +! +( +minifier_0 +r +" +> +\ +s ++ +< +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +r +" +\ +s +{ +2 +} +| +[ +\ +r +\ +n +] +" +consistent +! +( +minifier_1 +r +" +\ +s +{ +2 +} +| +[ +\ +r +\ +n +] +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +r +" +< +( +style +| +script +) +[ +\ +w +| +\ +s +] +. +* +? +> +" +consistent +! +( +minifier_2 +r +" +< +( +style +| +script +) +[ +\ +w +| +\ +s +] +. +* +? +> +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +" +< +! +- +- +( +. +| +\ +n +) +* +? +- +- +> +" +consistent +! +( +minifier_3 +" +< +! +- +- +( +. +| +\ +n +) +* +? +- +- +> +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +r +" +< +\ +w +. +* +? +> +" +consistent +! +( +minifier_4 +r +" +< +\ +w +. +* +? +> +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +r +" +\ +s ++ +| +\ +s ++ +" +consistent +! +( +minifier_5 +r +" +\ +s ++ +| +\ +s ++ +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +r +" +\ +w +\ +s ++ +\ +w +" +consistent +! +( +minifier_6 +r +" +\ +w +\ +s ++ +\ +w +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +r +" +' +\ +s ++ +> +" +consistent +! +( +minifier_7 +r +" +' +\ +s ++ +> +" +) +; +/ +/ +minifier +- +0 +. +0 +. +13 +: +r +" +\ +d +\ +s ++ +> +" +consistent +! +( +minifier_8 +r +" +\ +d +\ +s ++ +> +" +) +; +/ +/ +ggp +- +rs +- +0 +. +1 +. +2 +: +r +" +( +? +P +< +relation +> +\ +( +[ +^ +) +] ++ +\ +) +) +| +( +? +P +< +prop +> +[ +a +- +zA +- +Z0 +- +9_ +] ++ +) +" +consistent +! +( +ggp_rs_0 +r +" +( +? +P +< +relation +> +\ +( +[ +^ +) +] ++ +\ +) +) +| +( +? +P +< +prop +> +[ +a +- +zA +- +Z0 +- +9_ +] ++ +) +" +) +; +/ +/ +ggp +- +rs +- +0 +. +1 +. +2 +: +r +" +\ +( +( +. +* +) +\ +) +. +" +consistent +! +( +ggp_rs_1 +r +" +\ +( +( +. +* +) +\ +) +. +" +) +; +/ +/ +poe +- +superfilter +- +0 +. +2 +. +0 +: +" +[ +A +- +Za +- +z0 +- +9_ +] +" +consistent +! +( +poe_superfilter_0 +" +[ +A +- +Za +- +z0 +- +9_ +] +" +) +; +/ +/ +poke +- +a +- +mango +- +0 +. +5 +. +0 +: +r +" +( +\ +d ++ +) +x +( +\ +d ++ +) +" +consistent +! +( +poke_a_mango_0 +r +" +( +\ +d ++ +) +x +( +\ +d ++ +) +" +) +; +/ +/ +pop3 +- +rs +- +0 +. +1 +. +0 +: +r +" +( +? +P +< +nmsg +> +\ +d ++ +) +( +? +P +< +size +> +\ +d ++ +) +" +consistent +! +( +pop3_rs_0 +r +" +( +? +P +< +nmsg +> +\ +d ++ +) +( +? +P +< +size +> +\ +d ++ +) +" +) +; +/ +/ +pop3 +- +rs +- +0 +. +1 +. +0 +: +r +" +( +? +P +< +msgid +> +\ +d ++ +) +( +? +P +< +uidl +> +[ +\ +x21 +- +\ +x7E +] +{ +1 +70 +} +) +" +consistent +! +( +pop3_rs_1 +r +" +( +? +P +< +msgid +> +\ +d ++ +) +( +? +P +< +uidl +> +[ +\ +x21 +- +\ +x7E +] +{ +1 +70 +} +) +" +) +; +/ +/ +pop3 +- +rs +- +0 +. +1 +. +0 +: +r +" +( +< +. +* +> +) +\ +r +\ +n +" +consistent +! +( +pop3_rs_2 +r +" +( +< +. +* +> +) +\ +r +\ +n +" +) +; +/ +/ +pop3 +- +rs +- +0 +. +1 +. +0 +: +r +" +^ +( +? +P +< +status +> +\ ++ +OK +| +- +ERR +) +( +? +P +< +statustext +> +. +* +) +" +consistent +! +( +pop3_rs_3 +r +" +^ +( +? +P +< +status +> +\ ++ +OK +| +- +ERR +) +( +? +P +< +statustext +> +. +* +) +" +) +; +/ +/ +pop3 +- +1 +. +0 +. +6 +: +r +" +^ +\ +. +\ +r +\ +n +" +consistent +! +( +pop3_0 +r +" +^ +\ +. +\ +r +\ +n +" +) +; +/ +/ +pop3 +- +1 +. +0 +. +6 +: +r +" +\ ++ +OK +( +. +* +) +" +consistent +! +( +pop3_1 +r +" +\ ++ +OK +( +. +* +) +" +) +; +/ +/ +pop3 +- +1 +. +0 +. +6 +: +r +" +- +ERR +( +. +* +) +" +consistent +! +( +pop3_2 +r +" +- +ERR +( +. +* +) +" +) +; +/ +/ +pop3 +- +1 +. +0 +. +6 +: +r +" +\ ++ +OK +( +\ +d ++ +) +( +\ +d ++ +) +\ +r +\ +n +" +consistent +! +( +pop3_3 +r +" +\ ++ +OK +( +\ +d ++ +) +( +\ +d ++ +) +\ +r +\ +n +" +) +; +/ +/ +pop3 +- +1 +. +0 +. +6 +: +r +" +( +\ +d ++ +) +( +[ +\ +x21 +- +\ +x7e +] ++ +) +\ +r +\ +n +" +consistent +! +( +pop3_4 +r +" +( +\ +d ++ +) +( +[ +\ +x21 +- +\ +x7e +] ++ +) +\ +r +\ +n +" +) +; +/ +/ +pop3 +- +1 +. +0 +. +6 +: +r +" +\ ++ +OK +( +\ +d ++ +) +( +[ +\ +x21 +- +\ +x7e +] ++ +) +\ +r +\ +n +" +consistent +! +( +pop3_5 +r +" +\ ++ +OK +( +\ +d ++ +) +( +[ +\ +x21 +- +\ +x7e +] ++ +) +\ +r +\ +n +" +) +; +/ +/ +pop3 +- +1 +. +0 +. +6 +: +r +" +( +\ +d ++ +) +( +\ +d ++ +) +\ +r +\ +n +" +consistent +! +( +pop3_6 +r +" +( +\ +d ++ +) +( +\ +d ++ +) +\ +r +\ +n +" +) +; +/ +/ +pop3 +- +1 +. +0 +. +6 +: +r +" +\ ++ +OK +( +\ +d ++ +) +( +\ +d ++ +) +\ +r +\ +n +" +consistent +! +( +pop3_7 +r +" +\ ++ +OK +( +\ +d ++ +) +( +\ +d ++ +) +\ +r +\ +n +" +) +; +/ +/ +polk +- +1 +. +1 +. +3 +: +" +github +: +( +\ +\ +w ++ +) +/ +? +( +\ +\ +w ++ +) +? +" +consistent +! +( +polk_0 +" +github +: +( +\ +\ +w ++ +) +/ +? +( +\ +\ +w ++ +) +? +" +) +; +/ +/ +geochunk +- +0 +. +1 +. +5 +: +" +^ +[ +0 +- +9 +] +{ +5 +} +" +consistent +! +( +geochunk_0 +" +^ +[ +0 +- +9 +] +{ +5 +} +" +) +; +/ +/ +generic +- +dns +- +update +- +1 +. +1 +. +4 +: +r +" +( +( +? +: +( +? +: +0 +| +1 +[ +\ +d +] +{ +0 +2 +} +| +2 +( +? +: +[ +0 +- +4 +] +\ +d +? +| +5 +[ +0 +- +5 +] +? +| +[ +6 +- +9 +] +) +? +| +[ +3 +- +9 +] +\ +d +? +) +\ +. +) +{ +3 +} +( +? +: +0 +| +1 +[ +\ +d +] +{ +0 +2 +} +| +2 +( +? +: +[ +0 +- +4 +] +\ +d +? +| +5 +[ +0 +- +5 +] +? +| +[ +6 +- +9 +] +) +? +| +[ +3 +- +9 +] +\ +d +? +) +) +" +consistent +! +( +generic_dns_update_0 +r +" +( +( +? +: +( +? +: +0 +| +1 +[ +\ +d +] +{ +0 +2 +} +| +2 +( +? +: +[ +0 +- +4 +] +\ +d +? +| +5 +[ +0 +- +5 +] +? +| +[ +6 +- +9 +] +) +? +| +[ +3 +- +9 +] +\ +d +? +) +\ +. +) +{ +3 +} +( +? +: +0 +| +1 +[ +\ +d +] +{ +0 +2 +} +| +2 +( +? +: +[ +0 +- +4 +] +\ +d +? +| +5 +[ +0 +- +5 +] +? +| +[ +6 +- +9 +] +) +? +| +[ +3 +- +9 +] +\ +d +? +) +) +" +) +; +/ +/ +generic +- +dns +- +update +- +1 +. +1 +. +4 +: +r +" +( +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +7 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +6 +} +: +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +5 +} +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +? +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +4 +} +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +2 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +3 +} +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +3 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +2 +} +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +4 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +6 +} +( +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +\ +. +) +{ +3 +} +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +5 +} +: +( +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +\ +. +) +{ +3 +} +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +) +| +( +: +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +5 +} +( +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +\ +. +) +{ +3 +} +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +) +| +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +5 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +: +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +6 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +1 +7 +} +: +) +) +" +consistent +! +( +generic_dns_update_1 +r +" +( +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +7 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +6 +} +: +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +5 +} +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +? +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +4 +} +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +2 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +3 +} +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +3 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +2 +} +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +4 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +6 +} +( +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +\ +. +) +{ +3 +} +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +5 +} +: +( +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +\ +. +) +{ +3 +} +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +) +| +( +: +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +5 +} +( +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +\ +. +) +{ +3 +} +( +\ +d +( +( +25 +[ +0 +- +5 +] +) +| +( +1 +\ +d +{ +2 +} +) +| +( +2 +[ +0 +- +4 +] +\ +d +) +| +( +\ +d +{ +1 +2 +} +) +) +\ +d +) +) +| +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +5 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +: +: +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +0 +6 +} +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +) +| +( +( +[ +0 +- +9A +- +Fa +- +f +] +{ +1 +4 +} +: +) +{ +1 +7 +} +: +) +) +" +) +; +/ +/ +generic +- +dns +- +update +- +1 +. +1 +. +4 +: +r +" +< +value +> +< +string +> +( +[ +0 +- +9 +. +] +* +) +< +/ +string +> +< +/ +value +> +" +consistent +! +( +generic_dns_update_2 +r +" +< +value +> +< +string +> +( +[ +0 +- +9 +. +] +* +) +< +/ +string +> +< +/ +value +> +" +) +; +/ +/ +generic +- +dns +- +update +- +1 +. +1 +. +4 +: +r +" +< +int +> +( +[ +0 +- +9 +] ++ +) +< +/ +int +> +" +consistent +! +( +generic_dns_update_3 +r +" +< +int +> +( +[ +0 +- +9 +] ++ +) +< +/ +int +> +" +) +; +/ +/ +generic +- +dns +- +update +- +1 +. +1 +. +4 +: +r +" +< +int +> +( +[ +0 +- +9 +] ++ +) +< +/ +int +> +" +consistent +! +( +generic_dns_update_4 +r +" +< +int +> +( +[ +0 +- +9 +] ++ +) +< +/ +int +> +" +) +; +/ +/ +generic +- +dns +- +update +- +1 +. +1 +. +4 +: +r +" +< +boolean +> +( +[ +0 +- +1 +] +* +) +< +/ +boolean +> +" +consistent +! +( +generic_dns_update_5 +r +" +< +boolean +> +( +[ +0 +- +1 +] +* +) +< +/ +boolean +> +" +) +; +/ +/ +generate +- +nix +- +pkg +- +0 +. +3 +. +0 +: +r +" +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +" +consistent +! +( +generate_nix_pkg_0 +r +" +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +" +) +; +/ +/ +generate +- +nix +- +pkg +- +0 +. +3 +. +0 +: +r +" +^ +( +\ +S +* +) +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +" +consistent +! +( +generate_nix_pkg_1 +r +" +^ +( +\ +S +* +) +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +" +) +; +/ +/ +genact +- +0 +. +6 +. +0 +: +r +" +arch +/ +( +[ +a +- +z0 +- +9_ +] +) ++ +/ +" +consistent +! +( +genact_0 +r +" +arch +/ +( +[ +a +- +z0 +- +9_ +] +) ++ +/ +" +) +; +/ +/ +genact +- +0 +. +6 +. +0 +: +r +" +arch +/ +( +[ +a +- +z0 +- +9_ +] +) ++ +/ +" +consistent +! +( +genact_1 +r +" +arch +/ +( +[ +a +- +z0 +- +9_ +] +) ++ +/ +" +) +; +/ +/ +cron_rs +- +0 +. +1 +. +6 +: +r +" +^ +\ +s +* +( +( +\ +* +( +/ +\ +d ++ +) +? +) +| +[ +0 +- +9 +- +/ +] ++ +) +( +\ +s ++ +( +( +\ +* +( +/ +\ +d ++ +) +? +) +| +[ +0 +- +9 +- +/ +] ++ +) +) +{ +4 +5 +} +\ +s +* +" +consistent +! +( +cron_rs_0 +r +" +^ +\ +s +* +( +( +\ +* +( +/ +\ +d ++ +) +? +) +| +[ +0 +- +9 +- +/ +] ++ +) +( +\ +s ++ +( +( +\ +* +( +/ +\ +d ++ +) +? +) +| +[ +0 +- +9 +- +/ +] ++ +) +) +{ +4 +5 +} +\ +s +* +" +) +; +/ +/ +systemfd +- +0 +. +3 +. +0 +: +r +" +^ +( +[ +a +- +zA +- +Z +] ++ +) +: +: +( +. ++ +) +" +consistent +! +( +systemfd_0 +r +" +^ +( +[ +a +- +zA +- +Z +] ++ +) +: +: +( +. ++ +) +" +) +; +/ +/ +symbolic +- +debuginfo +- +5 +. +0 +. +2 +: +" +__ +? +hidden +# +\ +\ +d ++ +_ +" +consistent +! +( +symbolic_debuginfo_0 +" +__ +? +hidden +# +\ +\ +d ++ +_ +" +) +; +/ +/ +symbolic +- +minidump +- +5 +. +0 +. +2 +: +r +" +^ +Linux +( +[ +^ +] ++ +) +( +. +* +) +\ +w ++ +( +? +: +GNU +/ +Linux +) +? +" +consistent +! +( +symbolic_minidump_0 +r +" +^ +Linux +( +[ +^ +] ++ +) +( +. +* +) +\ +w ++ +( +? +: +GNU +/ +Linux +) +? +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +# +) +( +? +u +: +[ +\ +t +- +\ +r +- +\ +u +{ +85 +} +- +\ +u +{ +85 +} +\ +u +{ +a0 +} +- +\ +u +{ +a0 +} +\ +u +{ +1680 +} +- +\ +u +{ +1680 +} +\ +u +{ +2000 +} +- +\ +u +{ +200a +} +\ +u +{ +2028 +} +- +\ +u +{ +2029 +} +\ +u +{ +202f +} +- +\ +u +{ +202f +} +\ +u +{ +205f +} +- +\ +u +{ +205f +} +\ +u +{ +3000 +} +- +\ +u +{ +3000 +} +] +) +* +( +? +u +: +. +) ++ +" +consistent +! +( +graphql_idl_parser_0 +" +^ +( +? +u +: +\ +\ +# +) +( +? +u +: +[ +\ +t +- +\ +r +- +\ +u +{ +85 +} +- +\ +u +{ +85 +} +\ +u +{ +a0 +} +- +\ +u +{ +a0 +} +\ +u +{ +1680 +} +- +\ +u +{ +1680 +} +\ +u +{ +2000 +} +- +\ +u +{ +200a +} +\ +u +{ +2028 +} +- +\ +u +{ +2029 +} +\ +u +{ +202f +} +- +\ +u +{ +202f +} +\ +u +{ +205f +} +- +\ +u +{ +205f +} +\ +u +{ +3000 +} +- +\ +u +{ +3000 +} +] +) +* +( +? +u +: +. +) ++ +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: += +) +( +? +u +: +[ +\ +t +- +\ +r +- +\ +u +{ +85 +} +- +\ +u +{ +85 +} +\ +u +{ +a0 +} +- +\ +u +{ +a0 +} +\ +u +{ +1680 +} +- +\ +u +{ +1680 +} +\ +u +{ +2000 +} +- +\ +u +{ +200a +} +\ +u +{ +2028 +} +- +\ +u +{ +2029 +} +\ +u +{ +202f +} +- +\ +u +{ +202f +} +\ +u +{ +205f +} +- +\ +u +{ +205f +} +\ +u +{ +3000 +} +- +\ +u +{ +3000 +} +] +) +* +( +? +u +: +. +) ++ +" +consistent +! +( +graphql_idl_parser_1 +" +^ +( +? +u +: += +) +( +? +u +: +[ +\ +t +- +\ +r +- +\ +u +{ +85 +} +- +\ +u +{ +85 +} +\ +u +{ +a0 +} +- +\ +u +{ +a0 +} +\ +u +{ +1680 +} +- +\ +u +{ +1680 +} +\ +u +{ +2000 +} +- +\ +u +{ +200a +} +\ +u +{ +2028 +} +- +\ +u +{ +2029 +} +\ +u +{ +202f +} +- +\ +u +{ +202f +} +\ +u +{ +205f +} +- +\ +u +{ +205f +} +\ +u +{ +3000 +} +- +\ +u +{ +3000 +} +] +) +* +( +? +u +: +. +) ++ +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +[ +A +- +Z_ +- +_a +- +z +] +) +( +? +u +: +[ +0 +- +9A +- +Z_ +- +_a +- +z +] +) +* +" +consistent +! +( +graphql_idl_parser_2 +" +^ +( +? +u +: +[ +A +- +Z_ +- +_a +- +z +] +) +( +? +u +: +[ +0 +- +9A +- +Z_ +- +_a +- +z +] +) +* +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +! +) +" +consistent +! +( +graphql_idl_parser_3 +" +^ +( +? +u +: +! +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +( +) +" +consistent +! +( +graphql_idl_parser_4 +" +^ +( +? +u +: +\ +\ +( +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +) +) +" +consistent +! +( +graphql_idl_parser_5 +" +^ +( +? +u +: +\ +\ +) +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +) +" +consistent +! +( +graphql_idl_parser_6 +" +^ +( +? +u +: +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +: +) +" +consistent +! +( +graphql_idl_parser_7 +" +^ +( +? +u +: +: +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +) +" +consistent +! +( +graphql_idl_parser_8 +" +^ +( +? +u +: +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +[ +) +" +consistent +! +( +graphql_idl_parser_9 +" +^ +( +? +u +: +\ +\ +[ +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +] +) +" +consistent +! +( +graphql_idl_parser_10 +" +^ +( +? +u +: +\ +\ +] +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +enum +) +" +consistent +! +( +graphql_idl_parser_11 +" +^ +( +? +u +: +enum +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +implements +) +" +consistent +! +( +graphql_idl_parser_12 +" +^ +( +? +u +: +implements +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +input +) +" +consistent +! +( +graphql_idl_parser_13 +" +^ +( +? +u +: +input +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +interface +) +" +consistent +! +( +graphql_idl_parser_14 +" +^ +( +? +u +: +interface +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +scalar +) +" +consistent +! +( +graphql_idl_parser_15 +" +^ +( +? +u +: +scalar +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +type +) +" +consistent +! +( +graphql_idl_parser_16 +" +^ +( +? +u +: +type +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +union +) +" +consistent +! +( +graphql_idl_parser_17 +" +^ +( +? +u +: +union +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +{ +) +" +consistent +! +( +graphql_idl_parser_18 +" +^ +( +? +u +: +\ +\ +{ +) +" +) +; +/ +/ +graphql +- +idl +- +parser +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +} +) +" +consistent +! +( +graphql_idl_parser_19 +" +^ +( +? +u +: +\ +\ +} +) +" +) +; +/ +/ +grimoire +- +0 +. +1 +. +0 +: +r +" +( +? +s +) +/ +\ +* +( +? +P +< +config +> +. +* +? +) +\ +* +/ +" +consistent +! +( +grimoire_0 +r +" +( +? +s +) +/ +\ +* +( +? +P +< +config +> +. +* +? +) +\ +* +/ +" +) +; +/ +/ +phonenumber +- +0 +. +2 +. +0 ++ +8 +. +9 +. +0 +: +r +" +[ +\ +d +] ++ +( +? +: +[ +~ +\ +x +{ +2053 +} +\ +x +{ +223C +} +\ +x +{ +FF5E +} +] +[ +\ +d +] ++ +) +? +" +consistent +! +( +phonenumber_0 +r +" +[ +\ +d +] ++ +( +? +: +[ +~ +\ +x +{ +2053 +} +\ +x +{ +223C +} +\ +x +{ +FF5E +} +] +[ +\ +d +] ++ +) +? +" +) +; +/ +/ +phonenumber +- +0 +. +2 +. +0 ++ +8 +. +9 +. +0 +: +r +" +[ +\ +[ +\ +] +] +" +consistent +! +( +phonenumber_1 +r +" +[ +\ +[ +\ +] +] +" +) +; +/ +/ +phonenumber +- +0 +. +2 +. +0 ++ +8 +. +9 +. +0 +: +r +" +[ +\ +\ +/ +] +* +x +" +consistent +! +( +phonenumber_2 +r +" +[ +\ +\ +/ +] +* +x +" +) +; +/ +/ +phonenumber +- +0 +. +2 +. +0 ++ +8 +. +9 +. +0 +: +r +" +[ +[ +\ +P +{ +N +} +& +& +\ +P +{ +L +} +] +& +& +[ +^ +# +] +] ++ +" +consistent +! +( +phonenumber_3 +r +" +[ +[ +\ +P +{ +N +} +& +& +\ +P +{ +L +} +] +& +& +[ +^ +# +] +] ++ +" +) +; +/ +/ +phonenumber +- +0 +. +2 +. +0 ++ +8 +. +9 +. +0 +: +r +" +( +? +: +. +* +? +[ +A +- +Za +- +z +] +) +{ +3 +} +. +* +" +consistent +! +( +phonenumber_4 +r +" +( +? +: +. +* +? +[ +A +- +Za +- +z +] +) +{ +3 +} +. +* +" +) +; +/ +/ +phonenumber +- +0 +. +2 +. +0 ++ +8 +. +9 +. +0 +: +r +" +( +\ +D ++ +) +" +consistent +! +( +phonenumber_5 +r +" +( +\ +D ++ +) +" +) +; +/ +/ +phonenumber +- +0 +. +2 +. +0 ++ +8 +. +9 +. +0 +: +r +" +( +\ +\ +d +) +" +consistent +! +( +phonenumber_6 +r +" +( +\ +\ +d +) +" +) +; +/ +/ +phonenumber +- +0 +. +2 +. +0 ++ +8 +. +9 +. +0 +: +r +" +\ +( +? +\ +1 +\ +) +? +" +consistent +! +( +phonenumber_7 +r +" +\ +( +? +\ +1 +\ +) +? +" +) +; +/ +/ +phone_number +- +0 +. +1 +. +0 +: +r +" +\ +D +" +consistent +! +( +phone_number_0 +r +" +\ +D +" +) +; +/ +/ +phone_number +- +0 +. +1 +. +0 +: +r +" +^ +0 ++ +" +consistent +! +( +phone_number_1 +r +" +^ +0 ++ +" +) +; +/ +/ +phone_number +- +0 +. +1 +. +0 +: +r +" +^ +89 +" +consistent +! +( +phone_number_2 +r +" +^ +89 +" +) +; +/ +/ +phone_number +- +0 +. +1 +. +0 +: +r +" +^ +8 ++ +" +consistent +! +( +phone_number_3 +r +" +^ +8 ++ +" +) +; +/ +/ +phile +- +0 +. +1 +. +4 +: +r +" +^ +* +( +\ +^ +_ +* +\ +^ +) +* +" +consistent +! +( +phile_0 +r +" +^ +* +( +\ +^ +_ +* +\ +^ +) +* +" +) +; +/ +/ +phile +- +0 +. +1 +. +4 +: +r +" +^ +[ +_ +\ +p +{ +XID_Start +} +] +" +consistent +! +( +phile_1 +r +" +^ +[ +_ +\ +p +{ +XID_Start +} +] +" +) +; +/ +/ +phile +- +0 +. +1 +. +4 +: +r +" +^ +\ +p +{ +XID_Continue +} +" +consistent +! +( +phile_2 +r +" +^ +\ +p +{ +XID_Continue +} +" +) +; +/ +/ +uritemplate +- +0 +. +1 +. +2 +: +" +% +25 +( +? +P +< +hex +> +[ +0 +- +9a +- +fA +- +F +] +[ +0 +- +9a +- +fA +- +F +] +) +" +consistent +! +( +uritemplate_0 +" +% +25 +( +? +P +< +hex +> +[ +0 +- +9a +- +fA +- +F +] +[ +0 +- +9a +- +fA +- +F +] +) +" +) +; +/ +/ +urdf +- +rs +- +0 +. +4 +. +2 +: +" +^ +package +: +/ +/ +( +\ +\ +w ++ +) +/ +" +consistent +! +( +urdf_rs_0 +" +^ +package +: +/ +/ +( +\ +\ +w ++ +) +/ +" +) +; +/ +/ +url +- +match +- +0 +. +1 +. +7 +: +r +" +( +? +P +< +key +> +[ +? +& +. +] +) +" +consistent +! +( +url_match_0 +r +" +( +? +P +< +key +> +[ +? +& +. +] +) +" +) +; +/ +/ +url +- +match +- +0 +. +1 +. +7 +: +r +" +: +( +? +P +< +key +> +[ +a +- +zA +- +Z0 +- +9_ +- +] ++ +) +" +consistent +! +( +url_match_1 +r +" +: +( +? +P +< +key +> +[ +a +- +zA +- +Z0 +- +9_ +- +] ++ +) +" +) +; +/ +/ +tsm +- +sys +- +0 +. +1 +. +0 +: +r +" +hello +world +" +consistent +! +( +tsm_sys_0 +r +" +hello +world +" +) +; +/ +/ +deb +- +version +- +0 +. +1 +. +0 +: +" +^ +( +? +: +( +? +: +( +? +: +\ +\ +d ++ +: +) +. ++ +) +| +( +? +: +[ +^ +: +] ++ +) +) +" +consistent +! +( +deb_version_0 +" +^ +( +? +: +( +? +: +( +? +: +\ +\ +d ++ +: +) +. ++ +) +| +( +? +: +[ +^ +: +] ++ +) +) +" +) +; +/ +/ +debcargo +- +2 +. +1 +. +0 +: +r +" +^ +( +? +i +) +( +a +| +an +| +the +) +\ +s ++ +" +consistent +! +( +debcargo_0 +r +" +^ +( +? +i +) +( +a +| +an +| +the +) +\ +s ++ +" +) +; +/ +/ +debcargo +- +2 +. +1 +. +0 +: +r +" +^ +( +? +i +) +( +rust +\ +s ++ +) +? +( +implementation +| +library +| +tool +| +crate +) +\ +s ++ +( +of +| +to +| +for +) +\ +s ++ +" +consistent +! +( +debcargo_1 +r +" +^ +( +? +i +) +( +rust +\ +s ++ +) +? +( +implementation +| +library +| +tool +| +crate +) +\ +s ++ +( +of +| +to +| +for +) +\ +s ++ +" +) +; +/ +/ +feaders +- +0 +. +2 +. +0 +: +r +" +^ +. +* +\ +. +h +" +consistent +! +( +feaders_0 +r +" +^ +. +* +\ +. +h +" +) +; +/ +/ +feaders +- +0 +. +2 +. +0 +: +r +" +^ +. +* +\ +. +c +" +consistent +! +( +feaders_1 +r +" +^ +. +* +\ +. +c +" +) +; +/ +/ +feaders +- +0 +. +2 +. +0 +: +r +" +^ +. +* +\ +. +hpp +" +consistent +! +( +feaders_2 +r +" +^ +. +* +\ +. +hpp +" +) +; +/ +/ +feaders +- +0 +. +2 +. +0 +: +r +" +^ +. +* +\ +. +cc +" +consistent +! +( +feaders_3 +r +" +^ +. +* +\ +. +cc +" +) +; +/ +/ +feaders +- +0 +. +2 +. +0 +: +r +" +^ +. +* +\ +. +cpp +" +consistent +! +( +feaders_4 +r +" +^ +. +* +\ +. +cpp +" +) +; +/ +/ +hyperscan +- +0 +. +1 +. +6 +: +r +" +CPtr +\ +( +\ +w ++ +\ +) +" +consistent +! +( +hyperscan_0 +r +" +CPtr +\ +( +\ +w ++ +\ +) +" +) +; +/ +/ +hyperscan +- +0 +. +1 +. +6 +: +r +" +^ +Version +: +\ +s +( +\ +d +\ +. +\ +d +\ +. +\ +d +) +\ +sFeatures +: +\ +s ++ +( +\ +w ++ +) +? +\ +sMode +: +\ +s +( +\ +w ++ +) +" +consistent +! +( +hyperscan_1 +r +" +^ +Version +: +\ +s +( +\ +d +\ +. +\ +d +\ +. +\ +d +) +\ +sFeatures +: +\ +s ++ +( +\ +w ++ +) +? +\ +sMode +: +\ +s +( +\ +w ++ +) +" +) +; +/ +/ +hyperscan +- +0 +. +1 +. +6 +: +r +" +RawDatabase +< +Block +> +\ +{ +db +: +\ +w ++ +\ +} +" +consistent +! +( +hyperscan_2 +r +" +RawDatabase +< +Block +> +\ +{ +db +: +\ +w ++ +\ +} +" +) +; +/ +/ +hyperscan +- +0 +. +1 +. +6 +: +r +" +RawSerializedDatabase +\ +{ +p +: +\ +w ++ +len +: +\ +d ++ +\ +} +" +consistent +! +( +hyperscan_3 +r +" +RawSerializedDatabase +\ +{ +p +: +\ +w ++ +len +: +\ +d ++ +\ +} +" +) +; +/ +/ +ucd +- +parse +- +0 +. +1 +. +1 +: +r +" +[ +0 +- +9A +- +F +] ++ +" +consistent +! +( +ucd_parse_0 +r +" +[ +0 +- +9A +- +F +] ++ +" +) +; +/ +/ +afsort +- +0 +. +2 +. +0 +: +r +" +. +* +" +consistent +! +( +afsort_0 +r +" +. +* +" +) +; +/ +/ +afsort +- +0 +. +2 +. +0 +: +r +" +. +* +" +consistent +! +( +afsort_1 +r +" +. +* +" +) +; +/ +/ +afsort +- +0 +. +2 +. +0 +: +r +" +. +* +" +consistent +! +( +afsort_2 +r +" +. +* +" +) +; +/ +/ +afsort +- +0 +. +2 +. +0 +: +r +" +. +* +" +consistent +! +( +afsort_3 +r +" +. +* +" +) +; +/ +/ +afsort +- +0 +. +2 +. +0 +: +r +" +. +* +" +consistent +! +( +afsort_4 +r +" +. +* +" +) +; +/ +/ +afsort +- +0 +. +2 +. +0 +: +r +" +. +* +" +consistent +! +( +afsort_5 +r +" +. +* +" +) +; +/ +/ +afsort +- +0 +. +2 +. +0 +: +r +" +^ +[ +a +- +z +] ++ +" +consistent +! +( +afsort_6 +r +" +^ +[ +a +- +z +] ++ +" +) +; +/ +/ +afsort +- +0 +. +2 +. +0 +: +r +" +^ +[ +a +- +z +] ++ +" +consistent +! +( +afsort_7 +r +" +^ +[ +a +- +z +] ++ +" +) +; +/ +/ +tin +- +summer +- +1 +. +21 +. +4 +: +r +" +( +\ +. +git +| +\ +. +pijul +| +_darcs +| +\ +. +hg +) +" +consistent +! +( +tin_summer_0 +r +" +( +\ +. +git +| +\ +. +pijul +| +_darcs +| +\ +. +hg +) +" +) +; +/ +/ +tin +- +drummer +- +1 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +a +| +la +| +lo +| +o +| +ll +| +keter +| +bc +| +dyn_o +| +d +| +rlib +| +crate +| +min +\ +. +js +| +hi +| +dyn_hi +| +S +| +jsexe +| +webapp +| +js +\ +. +externs +| +ibc +| +toc +| +aux +| +fdb_latexmk +| +fls +| +egg +- +info +| +whl +| +js_a +| +js_hi +| +jld +| +ji +| +js_o +| +so +. +* +| +dump +- +. +* +| +vmb +| +crx +| +orig +| +elmo +| +elmi +| +pyc +| +mod +| +p_hi +| +p_o +| +prof +| +tix +) +" +consistent +! +( +tin_drummer_0 +r +" +. +* +? +\ +. +( +a +| +la +| +lo +| +o +| +ll +| +keter +| +bc +| +dyn_o +| +d +| +rlib +| +crate +| +min +\ +. +js +| +hi +| +dyn_hi +| +S +| +jsexe +| +webapp +| +js +\ +. +externs +| +ibc +| +toc +| +aux +| +fdb_latexmk +| +fls +| +egg +- +info +| +whl +| +js_a +| +js_hi +| +jld +| +ji +| +js_o +| +so +. +* +| +dump +- +. +* +| +vmb +| +crx +| +orig +| +elmo +| +elmi +| +pyc +| +mod +| +p_hi +| +p_o +| +prof +| +tix +) +" +) +; +/ +/ +tin +- +drummer +- +1 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +stats +| +conf +| +h +| +out +| +cache +. +* +| +dat +| +pc +| +info +| +\ +. +js +) +" +consistent +! +( +tin_drummer_1 +r +" +. +* +? +\ +. +( +stats +| +conf +| +h +| +out +| +cache +. +* +| +dat +| +pc +| +info +| +\ +. +js +) +" +) +; +/ +/ +tin +- +drummer +- +1 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +exe +| +a +| +la +| +o +| +ll +| +keter +| +bc +| +dyn_o +| +d +| +rlib +| +crate +| +min +\ +. +js +| +hi +| +dyn_hi +| +jsexe +| +webapp +| +js +\ +. +externs +| +ibc +| +toc +| +aux +| +fdb_latexmk +| +fls +| +egg +- +info +| +whl +| +js_a +| +js_hi +| +jld +| +ji +| +js_o +| +so +. +* +| +dump +- +. +* +| +vmb +| +crx +| +orig +| +elmo +| +elmi +| +pyc +| +mod +| +p_hi +| +p_o +| +prof +| +tix +) +" +consistent +! +( +tin_drummer_2 +r +" +. +* +? +\ +. +( +exe +| +a +| +la +| +o +| +ll +| +keter +| +bc +| +dyn_o +| +d +| +rlib +| +crate +| +min +\ +. +js +| +hi +| +dyn_hi +| +jsexe +| +webapp +| +js +\ +. +externs +| +ibc +| +toc +| +aux +| +fdb_latexmk +| +fls +| +egg +- +info +| +whl +| +js_a +| +js_hi +| +jld +| +ji +| +js_o +| +so +. +* +| +dump +- +. +* +| +vmb +| +crx +| +orig +| +elmo +| +elmi +| +pyc +| +mod +| +p_hi +| +p_o +| +prof +| +tix +) +" +) +; +/ +/ +tin +- +drummer +- +1 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +stats +| +conf +| +h +| +out +| +cache +. +* +| +\ +. +js +) +" +consistent +! +( +tin_drummer_3 +r +" +. +* +? +\ +. +( +stats +| +conf +| +h +| +out +| +cache +. +* +| +\ +. +js +) +" +) +; +/ +/ +tin +- +drummer +- +1 +. +0 +. +1 +: +r +" +( +\ +. +git +| +\ +. +pijul +| +_darcs +| +\ +. +hg +) +" +consistent +! +( +tin_drummer_4 +r +" +( +\ +. +git +| +\ +. +pijul +| +_darcs +| +\ +. +hg +) +" +) +; +/ +/ +tin +- +drummer +- +1 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +dyn_o +| +out +| +d +| +hi +| +dyn_hi +| +dump +- +. +* +| +p_hi +| +p_o +| +prof +| +tix +) +" +consistent +! +( +tin_drummer_5 +r +" +. +* +? +\ +. +( +dyn_o +| +out +| +d +| +hi +| +dyn_hi +| +dump +- +. +* +| +p_hi +| +p_o +| +prof +| +tix +) +" +) +; +/ +/ +tin +- +drummer +- +1 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +ibc +) +" +consistent +! +( +tin_drummer_6 +r +" +. +* +? +\ +. +( +ibc +) +" +) +; +/ +/ +tin +- +drummer +- +1 +. +0 +. +1 +: +r +" +\ +. +stack +- +work +| +dist +- +newstyle +" +consistent +! +( +tin_drummer_7 +r +" +\ +. +stack +- +work +| +dist +- +newstyle +" +) +; +/ +/ +timmy +- +0 +. +3 +. +0 +: +r +" +_NET_WM_PID +\ +( +CARDINAL +\ +) += +( +\ +d ++ +) +" +consistent +! +( +timmy_0 +r +" +_NET_WM_PID +\ +( +CARDINAL +\ +) += +( +\ +d ++ +) +" +) +; +/ +/ +timmy +- +0 +. +3 +. +0 +: +r +" +today +| +yesterday +| +now +" +consistent +! +( +timmy_1 +r +" +today +| +yesterday +| +now +" +) +; +/ +/ +timmy +- +0 +. +3 +. +0 +: +r +" +( +? +P +< +day +> +\ +d +{ +1 +2 +} +) +/ +( +? +P +< +month +> +\ +d +{ +1 +2 +} +) +( +/ +( +? +P +< +year +> +\ +d +{ +4 +} +| +\ +d +{ +2 +} +) +) +? +" +consistent +! +( +timmy_2 +r +" +( +? +P +< +day +> +\ +d +{ +1 +2 +} +) +/ +( +? +P +< +month +> +\ +d +{ +1 +2 +} +) +( +/ +( +? +P +< +year +> +\ +d +{ +4 +} +| +\ +d +{ +2 +} +) +) +? +" +) +; +/ +/ +timmy +- +0 +. +3 +. +0 +: +r +" +( +? +P +< +n +> +\ +d ++ +) +( +days +? +| +ds +? +) +( +? +P +< +ago +> +( +ago +) +? +) +" +consistent +! +( +timmy_3 +r +" +( +? +P +< +n +> +\ +d ++ +) +( +days +? +| +ds +? +) +( +? +P +< +ago +> +( +ago +) +? +) +" +) +; +/ +/ +timmy +- +0 +. +3 +. +0 +: +r +" +( +? +P +< +hr +> +\ +d +{ +2 +} +) +: +( +? +P +< +mins +> +\ +d +{ +2 +} +) +" +consistent +! +( +timmy_4 +r +" +( +? +P +< +hr +> +\ +d +{ +2 +} +) +: +( +? +P +< +mins +> +\ +d +{ +2 +} +) +" +) +; +/ +/ +tinfo +- +0 +. +5 +. +0 +: +r +" +^ +( +\ +d ++ +) +: +\ +d ++ +windows +\ +( +. +* +\ +) +\ +[ +\ +d ++ +x +\ +d ++ +\ +] +( +\ +( +attached +\ +) +) +? +" +consistent +! +( +tinfo_0 +r +" +^ +( +\ +d ++ +) +: +\ +d ++ +windows +\ +( +. +* +\ +) +\ +[ +\ +d ++ +x +\ +d ++ +\ +] +( +\ +( +attached +\ +) +) +? +" +) +; +/ +/ +tinfo +- +0 +. +5 +. +0 +: +r +" +^ +( +\ +d ++ +) +: +( +\ +d ++ +) +: +( +. +* +) +\ +( +( +\ +d ++ +) +panes +\ +) +\ +[ +( +\ +d ++ +) +x +( +\ +d ++ +) +\ +] +" +consistent +! +( +tinfo_1 +r +" +^ +( +\ +d ++ +) +: +( +\ +d ++ +) +: +( +. +* +) +\ +( +( +\ +d ++ +) +panes +\ +) +\ +[ +( +\ +d ++ +) +x +( +\ +d ++ +) +\ +] +" +) +; +/ +/ +timespan +- +0 +. +0 +. +4 +: +r +" +( +? +: +\ +\ +\ +{ +start +\ +\ +\ +} +| +\ +\ +\ +{ +end +\ +\ +\ +} +) +" +consistent +! +( +timespan_0 +r +" +( +? +: +\ +\ +\ +{ +start +\ +\ +\ +} +| +\ +\ +\ +{ +end +\ +\ +\ +} +) +" +) +; +/ +/ +timespan +- +0 +. +0 +. +4 +: +r +" +( +. +* +) +\ +s ++ +- +\ +s ++ +( +. +* +) +" +consistent +! +( +timespan_1 +r +" +( +. +* +) +\ +s ++ +- +\ +s ++ +( +. +* +) +" +) +; +/ +/ +timespan +- +0 +. +0 +. +4 +: +r +" +( +. +* +) +\ +s ++ +( +\ +w ++ +) +" +consistent +! +( +timespan_2 +r +" +( +. +* +) +\ +s ++ +( +\ +w ++ +) +" +) +; +/ +/ +timespan +- +0 +. +0 +. +4 +: +r +" +( +. +* +) +\ +s ++ +( +\ +w ++ +) +" +consistent +! +( +timespan_3 +r +" +( +. +* +) +\ +s ++ +( +\ +w ++ +) +" +) +; +/ +/ +timespan +- +0 +. +0 +. +4 +: +r +" +( +. +* +) +\ +s ++ +- +\ +s ++ +( +. +* +) +" +consistent +! +( +timespan_4 +r +" +( +. +* +) +\ +s ++ +- +\ +s ++ +( +. +* +) +" +) +; +/ +/ +titlecase +- +0 +. +10 +. +0 +: +r +" +[ +[ +: +lower +: +] +] +" +consistent +! +( +titlecase_0 +r +" +[ +[ +: +lower +: +] +] +" +) +; +/ +/ +tight +- +0 +. +1 +. +3 +: +r +" +^ +\ +d ++ +( +day +| +week +| +month +| +year +) +s +? +" +consistent +! +( +tight_0 +r +" +^ +\ +d ++ +( +day +| +week +| +month +| +year +) +s +? +" +) +; +/ +/ +tight +- +0 +. +1 +. +3 +: +r +" +^ +\ +d ++ +( +day +| +week +| +month +| +year +) +s +? +" +consistent +! +( +tight_1 +r +" +^ +\ +d ++ +( +day +| +week +| +month +| +year +) +s +? +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +[ +- ++ +] +? +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9_ +] +* +) +" +consistent +! +( +yaml_0 +r +" +^ +[ +- ++ +] +? +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9_ +] +* +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +( +[ +- ++ +] +? +) +0o +? +( +[ +0 +- +7_ +] ++ +) +" +consistent +! +( +yaml_1 +r +" +^ +( +[ +- ++ +] +? +) +0o +? +( +[ +0 +- +7_ +] ++ +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +( +[ +- ++ +] +? +) +0x +( +[ +0 +- +9a +- +fA +- +F_ +] ++ +) +" +consistent +! +( +yaml_2 +r +" +^ +( +[ +- ++ +] +? +) +0x +( +[ +0 +- +9a +- +fA +- +F_ +] ++ +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +( +[ +- ++ +] +? +) +0b +( +[ +0 +- +1_ +] ++ +) +" +consistent +! +( +yaml_3 +r +" +^ +( +[ +- ++ +] +? +) +0b +( +[ +0 +- +1_ +] ++ +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +( +[ +- ++ +] +? +) +( +\ +. +[ +0 +- +9 +] ++ +| +[ +0 +- +9 +] ++ +( +\ +. +[ +0 +- +9 +] +* +) +? +( +[ +eE +] +[ +- ++ +] +? +[ +0 +- +9 +] ++ +) +? +) +" +consistent +! +( +yaml_4 +r +" +^ +( +[ +- ++ +] +? +) +( +\ +. +[ +0 +- +9 +] ++ +| +[ +0 +- +9 +] ++ +( +\ +. +[ +0 +- +9 +] +* +) +? +( +[ +eE +] +[ +- ++ +] +? +[ +0 +- +9 +] ++ +) +? +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +[ ++ +] +? +( +\ +. +inf +| +\ +. +Inf +| +\ +. +INF +) +" +consistent +! +( +yaml_5 +r +" +^ +[ ++ +] +? +( +\ +. +inf +| +\ +. +Inf +| +\ +. +INF +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +- +( +\ +. +inf +| +\ +. +Inf +| +\ +. +INF +) +" +consistent +! +( +yaml_6 +r +" +^ +- +( +\ +. +inf +| +\ +. +Inf +| +\ +. +INF +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +( +\ +. +nan +| +\ +. +NaN +| +\ +. +NAN +) +" +consistent +! +( +yaml_7 +r +" +^ +( +\ +. +nan +| +\ +. +NaN +| +\ +. +NAN +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +( +null +| +Null +| +NULL +| +~ +) +" +consistent +! +( +yaml_8 +r +" +^ +( +null +| +Null +| +NULL +| +~ +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +( +true +| +True +| +TRUE +| +yes +| +Yes +| +YES +) +" +consistent +! +( +yaml_9 +r +" +^ +( +true +| +True +| +TRUE +| +yes +| +Yes +| +YES +) +" +) +; +/ +/ +yaml +- +0 +. +2 +. +1 +: +r +" +^ +( +false +| +False +| +FALSE +| +no +| +No +| +NO +) +" +consistent +! +( +yaml_10 +r +" +^ +( +false +| +False +| +FALSE +| +no +| +No +| +NO +) +" +) +; +/ +/ +kefia +- +0 +. +1 +. +0 +: +r +" +( +? +m +) +^ +( +\ +S ++ +) +/ +( +\ +S ++ +) +( +\ +S ++ +) +( +? +: +\ +( +( +. +* +) +\ +) +) +? +" +consistent +! +( +kefia_0 +r +" +( +? +m +) +^ +( +\ +S ++ +) +/ +( +\ +S ++ +) +( +\ +S ++ +) +( +? +: +\ +( +( +. +* +) +\ +) +) +? +" +) +; +/ +/ +risp +- +0 +. +7 +. +0 +: +" +^ +( +\ +\ +s ++ +| +; +. +* +? +( +\ +n +| +) +) ++ +" +consistent +! +( +risp_0 +" +^ +( +\ +\ +s ++ +| +; +. +* +? +( +\ +n +| +) +) ++ +" +) +; +/ +/ +risp +- +0 +. +7 +. +0 +: +" +^ +\ +" +. +* +? +\ +" +" +consistent +! +( +risp_1 +" +^ +\ +" +. +* +? +\ +" +" +) +; +/ +/ +risp +- +0 +. +7 +. +0 +: +r +" +^ +[ +^ +\ +s +\ +{ +\ +} +( +) +\ +[ +\ +] +] ++ +" +consistent +! +( +risp_2 +r +" +^ +[ +^ +\ +s +\ +{ +\ +} +( +) +\ +[ +\ +] +] ++ +" +) +; +/ +/ +risp +- +0 +. +7 +. +0 +: +r +" +^ +- +? +\ +d ++ +" +consistent +! +( +risp_3 +r +" +^ +- +? +\ +d ++ +" +) +; +/ +/ +ripgrep +- +0 +. +8 +. +1 +: +" +^ +( +[ +0 +- +9 +] ++ +) +( +[ +KMG +] +) +? +" +consistent +! +( +ripgrep_0 +" +^ +( +[ +0 +- +9 +] ++ +) +( +[ +KMG +] +) +? +" +) +; +/ +/ +riquid +- +0 +. +0 +. +1 +: +r +" +^ +\ +w ++ +" +consistent +! +( +riquid_0 +r +" +^ +\ +w ++ +" +) +; +/ +/ +riquid +- +0 +. +0 +. +1 +: +r +" +^ +\ +d ++ +" +consistent +! +( +riquid_1 +r +" +^ +\ +d ++ +" +) +; +/ +/ +recursive_disassembler +- +2 +. +1 +. +2 +: +r +" +\ +A +( +0x +) +? +( +[ +a +- +fA +- +F0 +- +9 +] ++ +) +\ +z +" +consistent +! +( +recursive_disassembler_0 +r +" +\ +A +( +0x +) +? +( +[ +a +- +fA +- +F0 +- +9 +] ++ +) +\ +z +" +) +; +/ +/ +remake +- +0 +. +1 +. +0 +: +r +" +^ +[ +a +- +zA +- +Z_ +] +[ +a +- +zA +- +Z0 +- +9_ +] +* +" +consistent +! +( +remake_0 +r +" +^ +[ +a +- +zA +- +Z_ +] +[ +a +- +zA +- +Z0 +- +9_ +] +* +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +consistent +! +( +regex_decode_0 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +consistent +! +( +regex_decode_1 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +consistent +! +( +regex_decode_2 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +consistent +! +( +regex_decode_3 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +consistent +! +( +regex_decode_4 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +consistent +! +( +regex_decode_5 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +2 +} +) +\ +) +" +consistent +! +( +regex_decode_6 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +2 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +consistent +! +( +regex_decode_7 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +consistent +! +( +regex_decode_8 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +consistent +! +( +regex_decode_9 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +consistent +! +( +regex_decode_10 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +consistent +! +( +regex_decode_11 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +consistent +! +( +regex_decode_12 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +) +; +/ +/ +regex +- +decode +- +0 +. +1 +. +0 +: +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +consistent +! +( +regex_decode_13 +r +" +' +( +? +P +< +title +> +[ +^ +' +] ++ +) +' +\ +s ++ +\ +( +( +? +P +< +year +> +\ +d +{ +4 +} +) +? +\ +) +" +) +; +/ +/ +regex +- +cache +- +0 +. +2 +. +0 +: +" +[ +0 +- +9 +] +{ +3 +} +- +[ +0 +- +9 +] +{ +3 +} +- +[ +0 +- +9 +] +{ +4 +} +" +consistent +! +( +regex_cache_0 +" +[ +0 +- +9 +] +{ +3 +} +- +[ +0 +- +9 +] +{ +3 +} +- +[ +0 +- +9 +] +{ +4 +} +" +) +; +/ +/ +regex +- +cache +- +0 +. +2 +. +0 +: +r +" +^ +\ +d ++ +" +consistent +! +( +regex_cache_1 +r +" +^ +\ +d ++ +" +) +; +/ +/ +regex +- +cache +- +0 +. +2 +. +0 +: +r +" +^ +[ +a +- +z +] ++ +" +consistent +! +( +regex_cache_2 +r +" +^ +[ +a +- +z +] ++ +" +) +; +/ +/ +regex +- +cache +- +0 +. +2 +. +0 +: +r +" +^ +\ +d ++ +" +consistent +! +( +regex_cache_3 +r +" +^ +\ +d ++ +" +) +; +/ +/ +regex +- +cache +- +0 +. +2 +. +0 +: +r +" +^ +\ +d ++ +" +consistent +! +( +regex_cache_4 +r +" +^ +\ +d ++ +" +) +; +/ +/ +regex_dfa +- +0 +. +5 +. +0 +: +r +" +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +" +consistent +! +( +regex_dfa_0 +r +" +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +" +) +; +/ +/ +reaper +- +2 +. +0 +. +0 +: +r +" +^ +[ +0 +- +9 +\ +p +{ +L +} +_ +\ +\ +. +] +{ +3 +16 +} +" +consistent +! +( +reaper_0 +r +" +^ +[ +0 +- +9 +\ +p +{ +L +} +_ +\ +\ +. +] +{ +3 +16 +} +" +) +; +/ +/ +retdec +- +0 +. +1 +. +0 +: +r +" +^ +attachment +; +filename += +( +. ++ +) +" +consistent +! +( +retdec_0 +r +" +^ +attachment +; +filename += +( +. ++ +) +" +) +; +/ +/ +renvsubst +- +0 +. +1 +. +2 +: +r +" +( +\ +\ +) +( +? +P +< +head +> +\ +[ +0 +- +9A +- +Za +- +z_ +{ +] +) +" +consistent +! +( +renvsubst_0 +r +" +( +\ +\ +) +( +? +P +< +head +> +\ +[ +0 +- +9A +- +Za +- +z_ +{ +] +) +" +) +; +/ +/ +renvsubst +- +0 +. +1 +. +2 +: +r +" +\ +( +[ +[ +: +word +: +] +] ++ +) +" +consistent +! +( +renvsubst_1 +r +" +\ +( +[ +[ +: +word +: +] +] ++ +) +" +) +; +/ +/ +renvsubst +- +0 +. +1 +. +2 +: +r +" +\ +\ +{ +( +[ +[ +: +word +: +] +] ++ +) +\ +} +" +consistent +! +( +renvsubst_2 +r +" +\ +\ +{ +( +[ +[ +: +word +: +] +] ++ +) +\ +} +" +) +; +/ +/ +rexpect +- +0 +. +3 +. +0 +: +r +" +' +[ +a +- +z +] ++ +' +" +consistent +! +( +rexpect_0 +r +" +' +[ +a +- +z +] ++ +' +" +) +; +/ +/ +rexpect +- +0 +. +3 +. +0 +: +r +" +^ +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +" +consistent +! +( +rexpect_1 +r +" +^ +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +" +) +; +/ +/ +rexpect +- +0 +. +3 +. +0 +: +r +" +- +\ +d +{ +2 +} +- +" +consistent +! +( +rexpect_2 +r +" +- +\ +d +{ +2 +} +- +" +) +; +/ +/ +luther +- +0 +. +1 +. +0 +: +" +^ +a +( +b +| +c +) +c +* +" +consistent +! +( +luther_0 +" +^ +a +( +b +| +c +) +c +* +" +) +; +/ +/ +little_boxes +- +1 +. +6 +. +0 +: +r +" +( +\ +x9B +| +\ +x1B +\ +[ +) +[ +0 +- +? +] +* +[ +- +/ +] +* +[ +- +~ +] +" +consistent +! +( +little_boxes_0 +r +" +( +\ +x9B +| +\ +x1B +\ +[ +) +[ +0 +- +? +] +* +[ +- +/ +] +* +[ +- +~ +] +" +) +; +/ +/ +libimagentrytag +- +0 +. +8 +. +0 +: +" +^ +[ +a +- +zA +- +Z +] +( +[ +a +- +zA +- +Z0 +- +9_ +- +] +* +) +" +consistent +! +( +libimagentrytag_0 +" +^ +[ +a +- +zA +- +Z +] +( +[ +a +- +zA +- +Z0 +- +9_ +- +] +* +) +" +) +; +/ +/ +libimaginteraction +- +0 +. +8 +. +0 +: +r +" +^ +[ +Yy +] +( +\ +n +? +) +" +consistent +! +( +libimaginteraction_0 +r +" +^ +[ +Yy +] +( +\ +n +? +) +" +) +; +/ +/ +libimaginteraction +- +0 +. +8 +. +0 +: +r +" +^ +[ +Nn +] +( +\ +n +? +) +" +consistent +! +( +libimaginteraction_1 +r +" +^ +[ +Nn +] +( +\ +n +? +) +" +) +; +/ +/ +libimagutil +- +0 +. +8 +. +0 +: +" +^ +( +? +P +< +KEY +> +( +[ +^ += +] +* +) +) += +( +. +* +) +" +consistent +! +( +libimagutil_0 +" +^ +( +? +P +< +KEY +> +( +[ +^ += +] +* +) +) += +( +. +* +) +" +) +; +/ +/ +libimagutil +- +0 +. +8 +. +0 +: +" +( +. +* +) += +( +\ +" +( +? +P +< +QVALUE +> +( +[ +^ +\ +" +] +* +) +) +\ +" +| +( +? +P +< +VALUE +> +( +. +* +) +) +) +" +consistent +! +( +libimagutil_1 +" +( +. +* +) += +( +\ +" +( +? +P +< +QVALUE +> +( +[ +^ +\ +" +] +* +) +) +\ +" +| +( +? +P +< +VALUE +> +( +. +* +) +) +) +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +\ +s ++ +" +consistent +! +( +linux_ip_0 +r +" +\ +s ++ +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +\ +s +* +[ +\ +n +\ +r +] ++ +\ +s +* +" +consistent +! +( +linux_ip_1 +r +" +\ +s +* +[ +\ +n +\ +r +] ++ +\ +s +* +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +^ +( +[ +0 +- +9a +- +fA +- +F +\ +. +: +/ +] ++ +) +\ +s ++ +dev +\ +s ++ +( +[ +a +- +z0 +- +9 +\ +. +] ++ +) +\ +s +* +( +. +* +) +" +consistent +! +( +linux_ip_2 +r +" +^ +( +[ +0 +- +9a +- +fA +- +F +\ +. +: +/ +] ++ +) +\ +s ++ +dev +\ +s ++ +( +[ +a +- +z0 +- +9 +\ +. +] ++ +) +\ +s +* +( +. +* +) +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +^ +( +[ +0 +- +9a +- +fA +- +F +\ +. +: +/ +] ++ +| +default +) +\ +s ++ +via +\ +s ++ +( +[ +a +- +z0 +- +9 +\ +. +: +] ++ +) +\ +s ++ +dev +\ +s ++ +( +[ +a +- +z0 +- +9 +\ +. +] ++ +) +\ +s +* +( +. +* +) +" +consistent +! +( +linux_ip_3 +r +" +^ +( +[ +0 +- +9a +- +fA +- +F +\ +. +: +/ +] ++ +| +default +) +\ +s ++ +via +\ +s ++ +( +[ +a +- +z0 +- +9 +\ +. +: +] ++ +) +\ +s ++ +dev +\ +s ++ +( +[ +a +- +z0 +- +9 +\ +. +] ++ +) +\ +s +* +( +. +* +) +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +^ +( +blackhole +) +\ +s ++ +( +[ +0 +- +9a +- +fA +- +F +\ +. +: +/ +] ++ +) +" +consistent +! +( +linux_ip_4 +r +" +^ +( +blackhole +) +\ +s ++ +( +[ +0 +- +9a +- +fA +- +F +\ +. +: +/ +] ++ +) +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +^ +( +unreachable +) +\ +s ++ +( +[ +0 +- +9a +- +fA +- +F +\ +. +: +/ +] ++ +) +\ +s ++ +dev +\ +s ++ +( +[ +a +- +z0 +- +9 +\ +. +] ++ +) +\ +s ++ +( +. +* +) +" +consistent +! +( +linux_ip_5 +r +" +^ +( +unreachable +) +\ +s ++ +( +[ +0 +- +9a +- +fA +- +F +\ +. +: +/ +] ++ +) +\ +s ++ +dev +\ +s ++ +( +[ +a +- +z0 +- +9 +\ +. +] ++ +) +\ +s ++ +( +. +* +) +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +\ +s +* +[ +\ +n +\ +r +] ++ +\ +s +* +" +consistent +! +( +linux_ip_6 +r +" +\ +s +* +[ +\ +n +\ +r +] ++ +\ +s +* +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +^ +\ +d ++ +: +\ +s ++ +( +[ +a +- +zA +- +Z0 +- +9 +\ +. +- +] ++ +) +( +\ +S ++ +) +* +: +\ +s ++ +( +. +* +) +" +consistent +! +( +linux_ip_7 +r +" +^ +\ +d ++ +: +\ +s ++ +( +[ +a +- +zA +- +Z0 +- +9 +\ +. +- +] ++ +) +( +\ +S ++ +) +* +: +\ +s ++ +( +. +* +) +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +\ +s +* +link +/ +ether +\ +s ++ +( +[ +a +- +f0 +- +9 +: +] ++ +) +\ +s ++ +. +* +" +consistent +! +( +linux_ip_8 +r +" +\ +s +* +link +/ +ether +\ +s ++ +( +[ +a +- +f0 +- +9 +: +] ++ +) +\ +s ++ +. +* +" +) +; +/ +/ +linux_ip +- +0 +. +1 +. +0 +: +r +" +\ +s +* +inet +[ +6 +] +* +\ +s ++ +( +[ +0 +- +9a +- +f +: +\ +. +/ +] ++ +) +\ +s ++ +. +* +" +consistent +! +( +linux_ip_9 +r +" +\ +s +* +inet +[ +6 +] +* +\ +s ++ +( +[ +0 +- +9a +- +f +: +\ +. +/ +] ++ +) +\ +s ++ +. +* +" +) +; +/ +/ +linky +- +0 +. +1 +. +4 +: +r +" +[ +^ +\ +w +- +] +" +consistent +! +( +linky_0 +r +" +[ +^ +\ +w +- +] +" +) +; +/ +/ +linky +- +0 +. +1 +. +4 +: +r +" +^ +( +. +* +) +: +( +\ +d ++ +) +: +[ +^ +] +* +( +[ +^ +] +* +) +" +consistent +! +( +linky_1 +r +" +^ +( +. +* +) +: +( +\ +d ++ +) +: +[ +^ +] +* +( +[ +^ +] +* +) +" +) +; +/ +/ +limonite +- +0 +. +2 +. +1 +: +r +" +^ +( +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +) +- +( +\ +d +{ +3 +} +) +- +( +. ++ +) +" +consistent +! +( +limonite_0 +r +" +^ +( +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +) +- +( +\ +d +{ +3 +} +) +- +( +. ++ +) +" +) +; +/ +/ +process +- +queue +- +0 +. +1 +. +1 +: +r +" +^ +[ +a +- +zA +- +Z +] ++ +" +consistent +! +( +process_queue_0 +r +" +^ +[ +a +- +zA +- +Z +] ++ +" +) +; +/ +/ +pronghorn +- +0 +. +1 +. +2 +: +r +" +^ +\ +{ +( +[ +a +- +zA +- +Z_ +] ++ +) +\ +} +" +consistent +! +( +pronghorn_0 +r +" +^ +\ +{ +( +[ +a +- +zA +- +Z_ +] ++ +) +\ +} +" +) +; +/ +/ +protocol +- +ftp +- +client +- +0 +. +1 +. +1 +: +" +( +? +m +: +^ +( +\ +\ +d +{ +3 +} +) +( +. ++ +) +\ +r +) +" +consistent +! +( +protocol_ftp_client_0 +" +( +? +m +: +^ +( +\ +\ +d +{ +3 +} +) +( +. ++ +) +\ +r +) +" +) +; +/ +/ +protocol +- +ftp +- +client +- +0 +. +1 +. +1 +: +" +\ +" +( +. ++ +) +\ +" +" +consistent +! +( +protocol_ftp_client_1 +" +\ +" +( +. ++ +) +\ +" +" +) +; +/ +/ +protocol +- +ftp +- +client +- +0 +. +1 +. +1 +: +" +( +\ +\ +w ++ +) +[ +Tt +] +ype +: +( +\ +\ +w ++ +) +" +consistent +! +( +protocol_ftp_client_2 +" +( +\ +\ +w ++ +) +[ +Tt +] +ype +: +( +\ +\ +w ++ +) +" +) +; +/ +/ +protocol +- +ftp +- +client +- +0 +. +1 +. +1 +: +" +( +? +m +: +^ +( +\ +\ +d +{ +3 +} +) +- +. ++ +\ +r +) +" +consistent +! +( +protocol_ftp_client_3 +" +( +? +m +: +^ +( +\ +\ +d +{ +3 +} +) +- +. ++ +\ +r +) +" +) +; +/ +/ +protocol +- +ftp +- +client +- +0 +. +1 +. +1 +: +" +Entering +Passive +Mode +\ +\ +( +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +\ +\ +) +" +consistent +! +( +protocol_ftp_client_4 +" +Entering +Passive +Mode +\ +\ +( +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +( +\ +\ +d ++ +) +\ +\ +) +" +) +; +/ +/ +protocol +- +ftp +- +client +- +0 +. +1 +. +1 +: +" +( +? +m +: +^ +( +. ++ +) +\ +r +) +" +consistent +! +( +protocol_ftp_client_5 +" +( +? +m +: +^ +( +. ++ +) +\ +r +) +" +) +; +/ +/ +protocol +- +ftp +- +client +- +0 +. +1 +. +1 +: +" +^ +( +[ +d +- +] +) +( +? +: +[ +rwx +- +] +{ +3 +} +) +{ +3 +} ++ +\ +\ +d ++ ++ +\ +\ +w ++ ++ +\ +\ +w ++ ++ +( +\ +\ +d ++ +) ++ +( +. ++ +) ++ +( +. ++ +) +" +consistent +! +( +protocol_ftp_client_6 +" +^ +( +[ +d +- +] +) +( +? +: +[ +rwx +- +] +{ +3 +} +) +{ +3 +} ++ +\ +\ +d ++ ++ +\ +\ +w ++ ++ +\ +\ +w ++ ++ +( +\ +\ +d ++ +) ++ +( +. ++ +) ++ +( +. ++ +) +" +) +; +/ +/ +article +- +date +- +extractor +- +0 +. +1 +. +1 +: +r +" +( +[ +\ +. +/ +\ +- +_ +] +{ +0 +1 +} +( +19 +| +20 +) +\ +d +{ +2 +} +) +[ +\ +. +/ +\ +- +_ +] +{ +0 +1 +} +( +( +[ +0 +- +3 +] +{ +0 +1 +} +[ +0 +- +9 +] +[ +\ +. +/ +\ +- +_ +] +) +| +( +\ +w +{ +3 +5 +} +[ +\ +. +/ +\ +- +_ +] +) +) +( +[ +0 +- +3 +] +{ +0 +1 +} +[ +0 +- +9 +] +[ +\ +. +/ +\ +- +] +{ +0 +1 +} +) +" +consistent +! +( +article_date_extractor_0 +r +" +( +[ +\ +. +/ +\ +- +_ +] +{ +0 +1 +} +( +19 +| +20 +) +\ +d +{ +2 +} +) +[ +\ +. +/ +\ +- +_ +] +{ +0 +1 +} +( +( +[ +0 +- +3 +] +{ +0 +1 +} +[ +0 +- +9 +] +[ +\ +. +/ +\ +- +_ +] +) +| +( +\ +w +{ +3 +5 +} +[ +\ +. +/ +\ +- +_ +] +) +) +( +[ +0 +- +3 +] +{ +0 +1 +} +[ +0 +- +9 +] +[ +\ +. +/ +\ +- +] +{ +0 +1 +} +) +" +) +; +/ +/ +article +- +date +- +extractor +- +0 +. +1 +. +1 +: +r +" +( +? +i +) +publishdate +| +pubdate +| +timestamp +| +article_date +| +articledate +| +date +" +consistent +! +( +article_date_extractor_1 +r +" +( +? +i +) +publishdate +| +pubdate +| +timestamp +| +article_date +| +articledate +| +date +" +) +; +/ +/ +arthas_plugin +- +0 +. +1 +. +1 +: +r +" +type +\ +( +( +. +* +) +\ +) +" +consistent +! +( +arthas_plugin_0 +r +" +type +\ +( +( +. +* +) +\ +) +" +) +; +/ +/ +arthas_plugin +- +0 +. +1 +. +1 +: +r +" +Vec +< +( +. +* +) +> +" +consistent +! +( +arthas_plugin_1 +r +" +Vec +< +( +. +* +) +> +" +) +; +/ +/ +arthas_plugin +- +0 +. +1 +. +1 +: +r +" +Option +< +( +. +* +) +> +" +consistent +! +( +arthas_plugin_2 +r +" +Option +< +( +. +* +) +> +" +) +; +/ +/ +arthas_plugin +- +0 +. +1 +. +1 +: +r +" +HashMap +< +[ +a +- +z0 +- +9A +- +Z +] ++ +* +( +. +* +) +> +" +consistent +! +( +arthas_plugin_3 +r +" +HashMap +< +[ +a +- +z0 +- +9A +- +Z +] ++ +* +( +. +* +) +> +" +) +; +/ +/ +arthas_derive +- +0 +. +1 +. +0 +: +" +Vec +* +< +* +( +. +* +) +* +> +" +consistent +! +( +arthas_derive_0 +" +Vec +* +< +* +( +. +* +) +* +> +" +) +; +/ +/ +arthas_derive +- +0 +. +1 +. +0 +: +r +" +Option +* +< +* +( +. +* +) +* +> +" +consistent +! +( +arthas_derive_1 +r +" +Option +* +< +* +( +. +* +) +* +> +" +) +; +/ +/ +arthas_derive +- +0 +. +1 +. +0 +: +r +" +HashMap +* +< +* +[ +a +- +z0 +- +9A +- +Z +] ++ +* +* +( +. +* +) +* +> +" +consistent +! +( +arthas_derive_2 +r +" +HashMap +* +< +* +[ +a +- +z0 +- +9A +- +Z +] ++ +* +* +( +. +* +) +* +> +" +) +; +/ +/ +arpabet +- +0 +. +2 +. +0 +: +r +" +^ +( +[ +\ +w +\ +- +\ +( +\ +) +\ +. +' +] ++ +) +\ +s ++ +( +[ +^ +\ +s +] +. +* +) +\ +s +* +" +consistent +! +( +arpabet_0 +r +" +^ +( +[ +\ +w +\ +- +\ +( +\ +) +\ +. +' +] ++ +) +\ +s ++ +( +[ +^ +\ +s +] +. +* +) +\ +s +* +" +) +; +/ +/ +arpabet +- +0 +. +2 +. +0 +: +r +" +^ +; +; +; +\ +s ++ +" +consistent +! +( +arpabet_1 +r +" +^ +; +; +; +\ +s ++ +" +) +; +/ +/ +glossy_codegen +- +0 +. +2 +. +0 +: +r +" +/ +\ +* +. +* +? +\ +* +/ +| +/ +/ +. +* +" +consistent +! +( +glossy_codegen_0 +r +" +/ +\ +* +. +* +? +\ +* +/ +| +/ +/ +. +* +" +) +; +/ +/ +glossy_codegen +- +0 +. +2 +. +0 +: +" +^ +\ +\ +s +* +# +\ +\ +s +* +include +\ +\ +s ++ +< +( +[ +: +print +: +] ++ +) +> +\ +\ +s +* +" +consistent +! +( +glossy_codegen_1 +" +^ +\ +\ +s +* +# +\ +\ +s +* +include +\ +\ +s ++ +< +( +[ +: +print +: +] ++ +) +> +\ +\ +s +* +" +) +; +/ +/ +glossy_codegen +- +0 +. +2 +. +0 +: +" +^ +\ +\ +s +* +# +\ +\ +s +* +include +\ +\ +s ++ +\ +" +( +[ +: +print +: +] ++ +) +\ +" +\ +\ +s +* +" +consistent +! +( +glossy_codegen_2 +" +^ +\ +\ +s +* +# +\ +\ +s +* +include +\ +\ +s ++ +\ +" +( +[ +: +print +: +] ++ +) +\ +" +\ +\ +s +* +" +) +; +/ +/ +glossy_codegen +- +0 +. +2 +. +0 +: +r +" +^ +\ +s +* +# +\ +s +* +version +\ +s ++ +( +\ +d ++ +) +" +consistent +! +( +glossy_codegen_3 +r +" +^ +\ +s +* +# +\ +s +* +version +\ +s ++ +( +\ +d ++ +) +" +) +; +/ +/ +glossy_codegen +- +0 +. +2 +. +0 +: +r +" +^ +\ +s +* +" +consistent +! +( +glossy_codegen_4 +r +" +^ +\ +s +* +" +) +; +/ +/ +gluster +- +1 +. +0 +. +1 +: +r +" +( +? +P +< +addr +> +via +\ +S ++ +) +" +consistent +! +( +gluster_0 +r +" +( +? +P +< +addr +> +via +\ +S ++ +) +" +) +; +/ +/ +gluster +- +1 +. +0 +. +1 +: +r +" +( +? +P +< +src +> +src +\ +S ++ +) +" +consistent +! +( +gluster_1 +r +" +( +? +P +< +src +> +src +\ +S ++ +) +" +) +; +/ +/ +gl_helpers +- +0 +. +1 +. +7 +: +r +" +( +. +* +) +\ +[ +\ +d ++ +\ +] +" +consistent +! +( +gl_helpers_0 +r +" +( +. +* +) +\ +[ +\ +d ++ +\ +] +" +) +; +/ +/ +gl_helpers +- +0 +. +1 +. +7 +: +r +" +( +\ +d ++ +) +. +( +\ +d ++ +) +" +consistent +! +( +gl_helpers_1 +r +" +( +\ +d ++ +) +. +( +\ +d ++ +) +" +) +; +/ +/ +glr +- +parser +- +0 +. +0 +. +1 +: +r +" +( +? +P +< +c +> +[ +\ +\ +\ +. +\ ++ +\ +* +\ +? +\ +( +\ +) +\ +| +\ +[ +\ +] +\ +{ +\ +} +\ +^ +\ +] +) +" +consistent +! +( +glr_parser_0 +r +" +( +? +P +< +c +> +[ +\ +\ +\ +. +\ ++ +\ +* +\ +? +\ +( +\ +) +\ +| +\ +[ +\ +] +\ +{ +\ +} +\ +^ +\ +] +) +" +) +; +/ +/ +glr +- +parser +- +0 +. +0 +. +1 +: +r +" +^ +\ +w ++ +" +consistent +! +( +glr_parser_1 +r +" +^ +\ +w ++ +" +) +; +/ +/ +glr +- +parser +- +0 +. +0 +. +1 +: +" +' +[ +^ +' +] ++ +' +" +consistent +! +( +glr_parser_2 +" +' +[ +^ +' +] ++ +' +" +) +; +/ +/ +hoodlum +- +0 +. +5 +. +0 +: +r +" +( +? +m +) +/ +/ +. +* +" +consistent +! +( +hoodlum_0 +r +" +( +? +m +) +/ +/ +. +* +" +) +; +/ +/ +form +- +checker +- +0 +. +2 +. +2 +: +r +" +^ +1 +\ +d +{ +10 +} +" +consistent +! +( +form_checker_0 +r +" +^ +1 +\ +d +{ +10 +} +" +) +; +/ +/ +form +- +checker +- +0 +. +2 +. +2 +: +r +" +( +? +i +) +^ +[ +\ +w +. +% ++ +- +] ++ +( +? +: +[ +A +- +Z0 +- +9 +- +] ++ +\ +. +) ++ +[ +A +- +Z +] +{ +2 +4 +} +" +consistent +! +( +form_checker_1 +r +" +( +? +i +) +^ +[ +\ +w +. +% ++ +- +] ++ +( +? +: +[ +A +- +Z0 +- +9 +- +] ++ +\ +. +) ++ +[ +A +- +Z +] +{ +2 +4 +} +" +) +; +/ +/ +wikibase +- +0 +. +2 +. +0 +: +r +" +( +? +P +< +user_agent +> +[ +a +- +zA +- +Z0 +- +9 +- +_ +] ++ +/ +[ +0 +- +9 +\ +. +] ++ +) +" +consistent +! +( +wikibase_0 +r +" +( +? +P +< +user_agent +> +[ +a +- +zA +- +Z0 +- +9 +- +_ +] ++ +/ +[ +0 +- +9 +\ +. +] ++ +) +" +) +; +/ +/ +wifiscanner +- +0 +. +3 +. +6 +: +r +" +Cell +[ +0 +- +9 +] +{ +2 +} +- +Address +: +" +consistent +! +( +wifiscanner_0 +r +" +Cell +[ +0 +- +9 +] +{ +2 +} +- +Address +: +" +) +; +/ +/ +wifiscanner +- +0 +. +3 +. +6 +: +r +" +( +[ +0 +- +9a +- +zA +- +Z +] +{ +1 +} +[ +0 +- +9a +- +zA +- +Z +] +{ +1 +} +[ +: +] +{ +1 +} +) +{ +5 +} +[ +0 +- +9a +- +zA +- +Z +] +{ +1 +} +[ +0 +- +9a +- +zA +- +Z +] +{ +1 +} +" +consistent +! +( +wifiscanner_1 +r +" +( +[ +0 +- +9a +- +zA +- +Z +] +{ +1 +} +[ +0 +- +9a +- +zA +- +Z +] +{ +1 +} +[ +: +] +{ +1 +} +) +{ +5 +} +[ +0 +- +9a +- +zA +- +Z +] +{ +1 +} +[ +0 +- +9a +- +zA +- +Z +] +{ +1 +} +" +) +; +/ +/ +wifiscanner +- +0 +. +3 +. +6 +: +r +" +Signal +level += +( +\ +d ++ +) +/ +100 +" +consistent +! +( +wifiscanner_2 +r +" +Signal +level += +( +\ +d ++ +) +/ +100 +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +b +\ +] +( +. +* +? +) +\ +[ +/ +b +\ +] +" +consistent +! +( +bbcode_0 +r +" +( +? +s +) +\ +[ +b +\ +] +( +. +* +? +) +\ +[ +/ +b +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +i +\ +] +( +. +* +? +) +\ +[ +/ +i +\ +] +" +consistent +! +( +bbcode_1 +r +" +( +? +s +) +\ +[ +i +\ +] +( +. +* +? +) +\ +[ +/ +i +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +u +\ +] +( +. +* +? +) +\ +[ +/ +u +\ +] +" +consistent +! +( +bbcode_2 +r +" +( +? +s +) +\ +[ +u +\ +] +( +. +* +? +) +\ +[ +/ +u +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +s +\ +] +( +. +* +? +) +\ +[ +/ +s +\ +] +" +consistent +! +( +bbcode_3 +r +" +( +? +s +) +\ +[ +s +\ +] +( +. +* +? +) +\ +[ +/ +s +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +size += +( +\ +d ++ +) +] +( +. +* +? +) +\ +[ +/ +size +\ +] +" +consistent +! +( +bbcode_4 +r +" +( +? +s +) +\ +[ +size += +( +\ +d ++ +) +] +( +. +* +? +) +\ +[ +/ +size +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +color += +( +. ++ +) +] +( +. +* +? +) +\ +[ +/ +color +\ +] +" +consistent +! +( +bbcode_5 +r +" +( +? +s +) +\ +[ +color += +( +. ++ +) +] +( +. +* +? +) +\ +[ +/ +color +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +center +\ +] +( +. +* +? +) +\ +[ +/ +center +\ +] +" +consistent +! +( +bbcode_6 +r +" +( +? +s +) +\ +[ +center +\ +] +( +. +* +? +) +\ +[ +/ +center +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +left +\ +] +( +. +* +? +) +\ +[ +/ +left +\ +] +" +consistent +! +( +bbcode_7 +r +" +( +? +s +) +\ +[ +left +\ +] +( +. +* +? +) +\ +[ +/ +left +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +right +\ +] +( +. +* +? +) +\ +[ +/ +right +\ +] +" +consistent +! +( +bbcode_8 +r +" +( +? +s +) +\ +[ +right +\ +] +( +. +* +? +) +\ +[ +/ +right +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +table +\ +] +( +. +* +? +) +\ +[ +/ +table +\ +] +" +consistent +! +( +bbcode_9 +r +" +( +? +s +) +\ +[ +table +\ +] +( +. +* +? +) +\ +[ +/ +table +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +td +\ +] +( +. +* +? +) +\ +[ +/ +td +\ +] +" +consistent +! +( +bbcode_10 +r +" +( +? +s +) +\ +[ +td +\ +] +( +. +* +? +) +\ +[ +/ +td +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +tr +\ +] +( +. +* +? +) +\ +[ +/ +tr +\ +] +" +consistent +! +( +bbcode_11 +r +" +( +? +s +) +\ +[ +tr +\ +] +( +. +* +? +) +\ +[ +/ +tr +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +th +\ +] +( +. +* +? +) +\ +[ +/ +th +\ +] +" +consistent +! +( +bbcode_12 +r +" +( +? +s +) +\ +[ +th +\ +] +( +. +* +? +) +\ +[ +/ +th +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +url +\ +] +( +. +* +? +) +\ +[ +/ +url +\ +] +" +consistent +! +( +bbcode_13 +r +" +( +? +s +) +\ +[ +url +\ +] +( +. +* +? +) +\ +[ +/ +url +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +url += +( +. ++ +) +\ +] +( +. +* +? +) +\ +[ +/ +url +\ +] +" +consistent +! +( +bbcode_14 +r +" +( +? +s +) +\ +[ +url += +( +. ++ +) +\ +] +( +. +* +? +) +\ +[ +/ +url +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +quote +\ +] +( +. +* +? +) +\ +[ +/ +quote +\ +] +" +consistent +! +( +bbcode_15 +r +" +( +? +s +) +\ +[ +quote +\ +] +( +. +* +? +) +\ +[ +/ +quote +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +quote += +( +. ++ +) +\ +] +( +. +* +? +) +\ +[ +/ +quote +\ +] +" +consistent +! +( +bbcode_16 +r +" +( +? +s +) +\ +[ +quote += +( +. ++ +) +\ +] +( +. +* +? +) +\ +[ +/ +quote +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +img += +( +\ +d ++ +) +x +( +\ +d ++ +) +( +\ +b +. +* +) +? +\ +] +( +. +* +? +) +\ +[ +/ +img +\ +] +" +consistent +! +( +bbcode_17 +r +" +( +? +s +) +\ +[ +img += +( +\ +d ++ +) +x +( +\ +d ++ +) +( +\ +b +. +* +) +? +\ +] +( +. +* +? +) +\ +[ +/ +img +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +img += +( +. ++ +) +( +\ +b +. +* +) +? +\ +] +( +. +* +? +) +\ +[ +/ +img +\ +] +" +consistent +! +( +bbcode_18 +r +" +( +? +s +) +\ +[ +img += +( +. ++ +) +( +\ +b +. +* +) +? +\ +] +( +. +* +? +) +\ +[ +/ +img +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +img +( +\ +b +. +* +) +? +\ +] +( +. +* +? +) +\ +[ +/ +img +\ +] +" +consistent +! +( +bbcode_19 +r +" +( +? +s +) +\ +[ +img +( +\ +b +. +* +) +? +\ +] +( +. +* +? +) +\ +[ +/ +img +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +ol +\ +] +( +. +* +? +) +\ +[ +/ +ol +\ +] +" +consistent +! +( +bbcode_20 +r +" +( +? +s +) +\ +[ +ol +\ +] +( +. +* +? +) +\ +[ +/ +ol +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +ul +\ +] +( +. +* +? +) +\ +[ +/ +ul +\ +] +" +consistent +! +( +bbcode_21 +r +" +( +? +s +) +\ +[ +ul +\ +] +( +. +* +? +) +\ +[ +/ +ul +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +list +\ +] +( +. +* +? +) +\ +[ +/ +list +\ +] +" +consistent +! +( +bbcode_22 +r +" +( +? +s +) +\ +[ +list +\ +] +( +. +* +? +) +\ +[ +/ +list +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +youtube +\ +] +( +. +* +? +) +\ +[ +/ +youtube +\ +] +" +consistent +! +( +bbcode_23 +r +" +( +? +s +) +\ +[ +youtube +\ +] +( +. +* +? +) +\ +[ +/ +youtube +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +youtube += +( +\ +d ++ +) +x +( +\ +d ++ +) +\ +] +( +. +* +? +) +\ +[ +/ +youtube +\ +] +" +consistent +! +( +bbcode_24 +r +" +( +? +s +) +\ +[ +youtube += +( +\ +d ++ +) +x +( +\ +d ++ +) +\ +] +( +. +* +? +) +\ +[ +/ +youtube +\ +] +" +) +; +/ +/ +bbcode +- +1 +. +0 +. +2 +: +r +" +( +? +s +) +\ +[ +li +\ +] +( +. +* +? +) +\ +[ +/ +li +\ +] +" +consistent +! +( +bbcode_25 +r +" +( +? +s +) +\ +[ +li +\ +] +( +. +* +? +) +\ +[ +/ +li +\ +] +" +) +; +/ +/ +block +- +utils +- +0 +. +5 +. +0 +: +r +" +loop +\ +d ++ +" +consistent +! +( +block_utils_0 +r +" +loop +\ +d ++ +" +) +; +/ +/ +block +- +utils +- +0 +. +5 +. +0 +: +r +" +ram +\ +d ++ +" +consistent +! +( +block_utils_1 +r +" +ram +\ +d ++ +" +) +; +/ +/ +block +- +utils +- +0 +. +5 +. +0 +: +r +" +md +\ +d ++ +" +consistent +! +( +block_utils_2 +r +" +md +\ +d ++ +" +) +; +/ +/ +kvvliveapi +- +0 +. +1 +. +0 +: +r +" +^ +( +[ +1 +- +9 +] +) +min +" +consistent +! +( +kvvliveapi_0 +r +" +^ +( +[ +1 +- +9 +] +) +min +" +) +; +/ +/ +rfc822_sanitizer +- +0 +. +3 +. +3 +: +r +" +( +\ +d +{ +2 +} +) +: +( +\ +d +{ +2 +} +) +: +( +\ +d +{ +2 +} +) +" +consistent +! +( +rfc822_sanitizer_0 +r +" +( +\ +d +{ +2 +} +) +: +( +\ +d +{ +2 +} +) +: +( +\ +d +{ +2 +} +) +" +) +; +/ +/ +rfc822_sanitizer +- +0 +. +3 +. +3 +: +r +" +( +\ +d +{ +1 +2 +} +) +: +( +\ +d +{ +1 +2 +} +) +: +( +\ +d +{ +1 +2 +} +) +" +consistent +! +( +rfc822_sanitizer_1 +r +" +( +\ +d +{ +1 +2 +} +) +: +( +\ +d +{ +1 +2 +} +) +: +( +\ +d +{ +1 +2 +} +) +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +[ +2 +- +9 +] +" +consistent +! +( +faker_0 +r +" +[ +2 +- +9 +] +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +[ +1 +- +9 +] +" +consistent +! +( +faker_1 +r +" +[ +1 +- +9 +] +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +[ +0 +- +9 +] +" +consistent +! +( +faker_2 +r +" +[ +0 +- +9 +] +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +\ +d +{ +10 +} +" +consistent +! +( +faker_3 +r +" +\ +d +{ +10 +} +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +\ +d +{ +1 +} +" +consistent +! +( +faker_4 +r +" +\ +d +{ +1 +} +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +^ +\ +w ++ +" +consistent +! +( +faker_5 +r +" +^ +\ +w ++ +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +^ +\ +w ++ +" +consistent +! +( +faker_6 +r +" +^ +\ +w ++ +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +^ +( +\ +w ++ +\ +. +? +? +) +{ +2 +3 +} +" +consistent +! +( +faker_7 +r +" +^ +( +\ +w ++ +\ +. +? +? +) +{ +2 +3 +} +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +^ +[ +A +- +Z +] +[ +a +- +z +] ++ +\ +. +? +" +consistent +! +( +faker_8 +r +" +^ +[ +A +- +Z +] +[ +a +- +z +] ++ +\ +. +? +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +^ +[ +A +- +Z +] +[ +A +- +Za +- +z +] +* +\ +. +? +" +consistent +! +( +faker_9 +r +" +^ +[ +A +- +Z +] +[ +A +- +Za +- +z +] +* +\ +. +? +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +http +: +/ +/ +lorempixel +. +com +/ +100 +/ +100 +/ +\ +w ++ +" +consistent +! +( +faker_10 +r +" +http +: +/ +/ +lorempixel +. +com +/ +100 +/ +100 +/ +\ +w ++ +" +) +; +/ +/ +faker +- +0 +. +0 +. +4 +: +r +" +http +: +/ +/ +lorempixel +. +com +/ +100 +/ +100 +/ +cats +" +consistent +! +( +faker_11 +r +" +http +: +/ +/ +lorempixel +. +com +/ +100 +/ +100 +/ +cats +" +) +; +/ +/ +fancy +- +regex +- +0 +. +1 +. +0 +: +" +( +? +i +: +) +" +consistent +! +( +fancy_regex_0 +" +( +? +i +: +) +" +) +; +/ +/ +fancy +- +regex +- +0 +. +1 +. +0 +: +" +( +? +i +: +\ +\ +x +{ +0587 +} +) +" +consistent +! +( +fancy_regex_1 +" +( +? +i +: +\ +\ +x +{ +0587 +} +) +" +) +; +/ +/ +fancy +- +regex +- +0 +. +1 +. +0 +: +" +^ +\ +\ +\ +\ +( +[ +! +- +/ +: +- +\ +\ +[ +- +\ +\ +{ +- +~ +aftnrv +] +| +[ +0 +- +7 +] +{ +1 +3 +} +| +x +[ +0 +- +9a +- +fA +- +F +] +{ +2 +} +| +x +\ +\ +{ +[ +0 +- +9a +- +fA +- +F +] +{ +1 +6 +} +\ +\ +} +) +" +consistent +! +( +fancy_regex_2 +" +^ +\ +\ +\ +\ +( +[ +! +- +/ +: +- +\ +\ +[ +- +\ +\ +{ +- +~ +aftnrv +] +| +[ +0 +- +7 +] +{ +1 +3 +} +| +x +[ +0 +- +9a +- +fA +- +F +] +{ +2 +} +| +x +\ +\ +{ +[ +0 +- +9a +- +fA +- +F +] +{ +1 +6 +} +\ +\ +} +) +" +) +; +/ +/ +fancy +- +prompt +- +0 +. +1 +. +5 +: +r +" +/ +( +[ +^ +/ +] +) +[ +^ +/ +] ++ +/ +" +consistent +! +( +fancy_prompt_0 +r +" +/ +( +[ +^ +/ +] +) +[ +^ +/ +] ++ +/ +" +) +; +/ +/ +fancy +- +prompt +- +0 +. +1 +. +5 +: +r +" +^ +( +[ +^ +: +] ++ +) +: +. +* +? +( +? +: +: +( +[ +^ +: +] ++ +) +) +? +" +consistent +! +( +fancy_prompt_1 +r +" +^ +( +[ +^ +: +] ++ +) +: +. +* +? +( +? +: +: +( +[ +^ +: +] ++ +) +) +? +" +) +; +/ +/ +fanta +- +0 +. +2 +. +0 +: +r +" +^ +( +/ +? +__ +\ +w ++ +__ +) +/ +( +. +* +) +" +consistent +! +( +fanta_0 +r +" +^ +( +/ +? +__ +\ +w ++ +__ +) +/ +( +. +* +) +" +) +; +/ +/ +fanta +- +cli +- +0 +. +1 +. +1 +: +r +" +( +. +) +( +[ +A +- +Z +] +) +" +consistent +! +( +fanta_cli_0 +r +" +( +. +) +( +[ +A +- +Z +] +) +" +) +; +/ +/ +fanta +- +cli +- +0 +. +1 +. +1 +: +" +\ +\ +{ +: +[ +^ +\ +\ +s +] ++ +\ +\ +} +" +consistent +! +( +fanta_cli_1 +" +\ +\ +{ +: +[ +^ +\ +\ +s +] ++ +\ +\ +} +" +) +; +/ +/ +amethyst_tools +- +0 +. +7 +. +1 +: +" +( +? +P +< +last +> +[ +^ +\ +r +] +) +\ +n +" +consistent +! +( +amethyst_tools_0 +" +( +? +P +< +last +> +[ +^ +\ +r +] +) +\ +n +" +) +; +/ +/ +amigo +- +0 +. +3 +. +1 +: +r +" +^ +- +? +\ +d ++ +( +\ +. +\ +d +) +? +" +consistent +! +( +amigo_0 +r +" +^ +- +? +\ +d ++ +( +\ +. +\ +d +) +? +" +) +; +/ +/ +amigo +- +0 +. +3 +. +1 +: +r +" +^ +[ +a +- +zA +- +Z_ +] ++ +[ +\ +w +- +] +* +[ +! +? +_ +] +? +" +consistent +! +( +amigo_1 +r +" +^ +[ +a +- +zA +- +Z_ +] ++ +[ +\ +w +- +] +* +[ +! +? +_ +] +? +" +) +; +/ +/ +amigo +- +0 +. +3 +. +1 +: +r +" +^ +\ +( +" +consistent +! +( +amigo_2 +r +" +^ +\ +( +" +) +; +/ +/ +amigo +- +0 +. +3 +. +1 +: +r +" +^ +\ +) +" +consistent +! +( +amigo_3 +r +" +^ +\ +) +" +) +; +/ +/ +amigo +- +0 +. +3 +. +1 +: +r +" +^ +\ +s ++ +" +consistent +! +( +amigo_4 +r +" +^ +\ +s ++ +" +) +; +/ +/ +ethcore +- +logger +- +1 +. +12 +. +0 +: +" +\ +x1b +\ +\ +[ +[ +^ +m +] ++ +m +" +consistent +! +( +ethcore_logger_0 +" +\ +x1b +\ +\ +[ +[ +^ +m +] ++ +m +" +) +; +/ +/ +dash2html +- +1 +. +0 +. +1 +: +r +" +__ +. +* +? +__ +" +consistent +! +( +dash2html_0 +r +" +__ +. +* +? +__ +" +) +; +/ +/ +dash2html +- +1 +. +0 +. +1 +: +r +" +( +? +i +) +( +? +: +time +| +clipboard +| +cursor +| +date +) +" +consistent +! +( +dash2html_1 +r +" +( +? +i +) +( +? +: +time +| +clipboard +| +cursor +| +date +) +" +) +; +/ +/ +os_type +- +2 +. +0 +. +0 +: +r +" +^ +Microsoft +Windows +\ +[ +Version +\ +s +( +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +) +\ +] +" +consistent +! +( +os_type_0 +r +" +^ +Microsoft +Windows +\ +[ +Version +\ +s +( +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +) +\ +] +" +) +; +/ +/ +os_type +- +2 +. +0 +. +0 +: +r +" +ProductName +: +\ +s +( +[ +\ +w +\ +s +] ++ +) +\ +n +" +consistent +! +( +os_type_1 +r +" +ProductName +: +\ +s +( +[ +\ +w +\ +s +] ++ +) +\ +n +" +) +; +/ +/ +os_type +- +2 +. +0 +. +0 +: +r +" +ProductVersion +: +\ +s +( +\ +w ++ +\ +. +\ +w ++ +\ +. +\ +w ++ +) +" +consistent +! +( +os_type_2 +r +" +ProductVersion +: +\ +s +( +\ +w ++ +\ +. +\ +w ++ +\ +. +\ +w ++ +) +" +) +; +/ +/ +os_type +- +2 +. +0 +. +0 +: +r +" +BuildVersion +: +\ +s +( +\ +w ++ +) +" +consistent +! +( +os_type_3 +r +" +BuildVersion +: +\ +s +( +\ +w ++ +) +" +) +; +/ +/ +os_type +- +2 +. +0 +. +0 +: +r +" +( +\ +w ++ +) +Linux +release +" +consistent +! +( +os_type_4 +r +" +( +\ +w ++ +) +Linux +release +" +) +; +/ +/ +os_type +- +2 +. +0 +. +0 +: +r +" +release +\ +s +( +[ +\ +w +\ +. +] ++ +) +" +consistent +! +( +os_type_5 +r +" +release +\ +s +( +[ +\ +w +\ +. +] ++ +) +" +) +; +/ +/ +os_type +- +2 +. +0 +. +0 +: +r +" +Distributor +ID +: +\ +s +( +\ +w ++ +) +" +consistent +! +( +os_type_6 +r +" +Distributor +ID +: +\ +s +( +\ +w ++ +) +" +) +; +/ +/ +os_type +- +2 +. +0 +. +0 +: +r +" +Release +: +\ +s +( +[ +\ +w +\ +. +] ++ +) +" +consistent +! +( +os_type_7 +r +" +Release +: +\ +s +( +[ +\ +w +\ +. +] ++ +) +" +) +; +/ +/ +bindgen +- +0 +. +37 +. +0 +: +r +" +typename +type +\ +- +parameter +\ +- +\ +d ++ +\ +- +\ +d ++ +: +: +. ++ +" +consistent +! +( +bindgen_0 +r +" +typename +type +\ +- +parameter +\ +- +\ +d ++ +\ +- +\ +d ++ +: +: +. ++ +" +) +; +/ +/ +imap +- +0 +. +8 +. +1 +: +" +^ ++ +( +. +* +) +\ +r +\ +n +" +consistent +! +( +imap_0 +" +^ ++ +( +. +* +) +\ +r +\ +n +" +) +; +/ +/ +image +- +base64 +- +0 +. +1 +. +0 +: +r +" +^ +ffd8ffe0 +" +consistent +! +( +image_base64_0 +r +" +^ +ffd8ffe0 +" +) +; +/ +/ +image +- +base64 +- +0 +. +1 +. +0 +: +r +" +^ +89504e47 +" +consistent +! +( +image_base64_1 +r +" +^ +89504e47 +" +) +; +/ +/ +image +- +base64 +- +0 +. +1 +. +0 +: +r +" +^ +47494638 +" +consistent +! +( +image_base64_2 +r +" +^ +47494638 +" +) +; +/ +/ +json +- +pointer +- +0 +. +3 +. +2 +: +" +^ +( +/ +( +[ +^ +/ +~ +] +| +~ +[ +01 +] +) +* +) +* +" +consistent +! +( +json_pointer_0 +" +^ +( +/ +( +[ +^ +/ +~ +] +| +~ +[ +01 +] +) +* +) +* +" +) +; +/ +/ +json +- +pointer +- +0 +. +3 +. +2 +: +" +^ +# +( +/ +( +[ +^ +/ +~ +% +] +| +~ +[ +01 +] +| +% +[ +0 +- +9a +- +fA +- +F +] +{ +2 +} +) +* +) +* +" +consistent +! +( +json_pointer_1 +" +^ +# +( +/ +( +[ +^ +/ +~ +% +] +| +~ +[ +01 +] +| +% +[ +0 +- +9a +- +fA +- +F +] +{ +2 +} +) +* +) +* +" +) +; +/ +/ +mysql_common +- +0 +. +7 +. +0 +: +r +" +^ +5 +. +5 +. +5 +- +( +\ +d +{ +1 +2 +} +) +\ +. +( +\ +d +{ +1 +2 +} +) +\ +. +( +\ +d +{ +1 +3 +} +) +- +MariaDB +" +consistent +! +( +mysql_common_0 +r +" +^ +5 +. +5 +. +5 +- +( +\ +d +{ +1 +2 +} +) +\ +. +( +\ +d +{ +1 +2 +} +) +\ +. +( +\ +d +{ +1 +3 +} +) +- +MariaDB +" +) +; +/ +/ +mysql_common +- +0 +. +7 +. +0 +: +r +" +^ +( +\ +d +{ +1 +2 +} +) +\ +. +( +\ +d +{ +1 +2 +} +) +\ +. +( +\ +d +{ +1 +3 +} +) +( +. +* +) +" +consistent +! +( +mysql_common_1 +r +" +^ +( +\ +d +{ +1 +2 +} +) +\ +. +( +\ +d +{ +1 +2 +} +) +\ +. +( +\ +d +{ +1 +3 +} +) +( +. +* +) +" +) +; +/ +/ +government_id +- +0 +. +1 +. +0 +: +r +" +^ +[ +0 +- +9 +] +{ +4 +} +[ +0 +- +9A +- +Z +] +{ +2 +} +[ +0 +- +9 +] +{ +3 +} +" +consistent +! +( +government_id_0 +r +" +^ +[ +0 +- +9 +] +{ +4 +} +[ +0 +- +9A +- +Z +] +{ +2 +} +[ +0 +- +9 +] +{ +3 +} +" +) +; +/ +/ +ohmers +- +0 +. +1 +. +1 +: +r +" +UniqueIndexViolation +: +( +\ +w ++ +) +" +consistent +! +( +ohmers_0 +r +" +UniqueIndexViolation +: +( +\ +w ++ +) +" +) +; +/ +/ +eliza +- +1 +. +0 +. +0 +: +r +" +( +. +* +) +you +are +( +. +* +) +" +consistent +! +( +eliza_0 +r +" +( +. +* +) +you +are +( +. +* +) +" +) +; +/ +/ +eliza +- +1 +. +0 +. +0 +: +r +" +( +. +* +) +you +are +( +. +* +) +" +consistent +! +( +eliza_1 +r +" +( +. +* +) +you +are +( +. +* +) +" +) +; +/ +/ +eliza +- +1 +. +0 +. +0 +: +r +" +( +. +* +) +you +are +( +. +* +) +" +consistent +! +( +eliza_2 +r +" +( +. +* +) +you +are +( +. +* +) +" +) +; +/ +/ +chema +- +0 +. +0 +. +5 +: +" +^ +\ +\ +s +* +\ +\ +* +" +consistent +! +( +chema_0 +" +^ +\ +\ +s +* +\ +\ +* +" +) +; +/ +/ +chema +- +0 +. +0 +. +5 +: +" +^ +\ +\ +s +* +( +\ +\ +w ++ +) +\ +\ +s ++ +( +. +* +) +" +consistent +! +( +chema_1 +" +^ +\ +\ +s +* +( +\ +\ +w ++ +) +\ +\ +s ++ +( +. +* +) +" +) +; +/ +/ +chord3 +- +0 +. +3 +. +0 +: +r +" +^ +\ +s +* +# +" +consistent +! +( +chord3_0 +r +" +^ +\ +s +* +# +" +) +; +/ +/ +chord3 +- +0 +. +3 +. +0 +: +r +" +\ +{ +( +? +P +< +cmd +> +\ +w ++ +) +( +? +: +: +? +\ +s +* +( +? +P +< +arg +> +. +* +) +) +? +\ +} +" +consistent +! +( +chord3_1 +r +" +\ +{ +( +? +P +< +cmd +> +\ +w ++ +) +( +? +: +: +? +\ +s +* +( +? +P +< +arg +> +. +* +) +) +? +\ +} +" +) +; +/ +/ +chord3 +- +0 +. +3 +. +0 +: +r +" +\ +{ +( +eot +| +end_of_tab +) +: +? +\ +s +* +" +consistent +! +( +chord3_2 +r +" +\ +{ +( +eot +| +end_of_tab +) +: +? +\ +s +* +" +) +; +/ +/ +chord3 +- +0 +. +3 +. +0 +: +r +" +( +[ +^ +\ +[ +] +* +) +( +? +: +\ +[ +( +[ +^ +\ +] +] +* +) +\ +] +) +? +" +consistent +! +( +chord3_3 +r +" +( +[ +^ +\ +[ +] +* +) +( +? +: +\ +[ +( +[ +^ +\ +] +] +* +) +\ +] +) +? +" +) +; +/ +/ +checkmail +- +0 +. +1 +. +1 +: +" +^ +[ +a +- +zA +- +Z0 +- +9 +. +! +# +% +& +' +* ++ +/ += +? +^ +_ +{ +| +} +~ +- +] ++ +[ +a +- +zA +- +Z0 +- +9 +] +( +? +: +[ +a +- +zA +- +Z0 +- +9 +- +] +{ +0 +61 +} +[ +a +- +zA +- +Z0 +- +9 +] +) +? +( +? +: +\ +\ +. +[ +a +- +zA +- +Z0 +- +9 +] +( +? +: +[ +a +- +zA +- +Z0 +- +9 +- +] +{ +0 +61 +} +[ +a +- +zA +- +Z0 +- +9 +] +) +? +) +* +" +consistent +! +( +checkmail_0 +" +^ +[ +a +- +zA +- +Z0 +- +9 +. +! +# +% +& +' +* ++ +/ += +? +^ +_ +{ +| +} +~ +- +] ++ +[ +a +- +zA +- +Z0 +- +9 +] +( +? +: +[ +a +- +zA +- +Z0 +- +9 +- +] +{ +0 +61 +} +[ +a +- +zA +- +Z0 +- +9 +] +) +? +( +? +: +\ +\ +. +[ +a +- +zA +- +Z0 +- +9 +] +( +? +: +[ +a +- +zA +- +Z0 +- +9 +- +] +{ +0 +61 +} +[ +a +- +zA +- +Z0 +- +9 +] +) +? +) +* +" +) +; +/ +/ +cntk +- +0 +. +2 +. +1 +: +r +" +\ +b +\ +w +\ +w ++ +\ +b +" +consistent +! +( +cntk_0 +r +" +\ +b +\ +w +\ +w ++ +\ +b +" +) +; +/ +/ +cntk +- +0 +. +2 +. +1 +: +r +" +\ +b +\ +w +\ +w ++ +\ +b +" +consistent +! +( +cntk_1 +r +" +\ +b +\ +w +\ +w ++ +\ +b +" +) +; +/ +/ +cniguru +- +0 +. +1 +. +0 +: +r +" +\ +( +id +: +( +\ +d ++ +) +\ +) +" +consistent +! +( +cniguru_0 +r +" +\ +( +id +: +( +\ +d ++ +) +\ +) +" +) +; +/ +/ +upm_lib +- +0 +. +3 +. +0 +: +r +" +^ +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +( +? +: +- +( +[ +\ +dA +- +Za +- +z +- +] ++ +( +? +: +\ +. +[ +\ +dA +- +Za +- +z +- +] ++ +) +* +) +) +? +( +? +: +\ ++ +( +[ +\ +dA +- +Za +- +z +- +] ++ +( +? +: +\ +. +[ +\ +dA +- +Za +- +z +- +] ++ +) +* +) +) +? +" +consistent +! +( +upm_lib_0 +r +" +^ +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +( +? +: +- +( +[ +\ +dA +- +Za +- +z +- +] ++ +( +? +: +\ +. +[ +\ +dA +- +Za +- +z +- +] ++ +) +* +) +) +? +( +? +: +\ ++ +( +[ +\ +dA +- +Za +- +z +- +] ++ +( +? +: +\ +. +[ +\ +dA +- +Za +- +z +- +] ++ +) +* +) +) +? +" +) +; +/ +/ +avro +- +0 +. +2 +. +1 +: +r +" +^ +\ +s +* +( +\ +* ++ +( +\ +s ++ +) +) +? +" +consistent +! +( +avro_0 +r +" +^ +\ +s +* +( +\ +* ++ +( +\ +s ++ +) +) +? +" +) +; +/ +/ +avro +- +0 +. +2 +. +1 +: +r +" +^ +\ +s +* +( +\ +* ++ +) +? +" +consistent +! +( +avro_1 +r +" +^ +\ +s +* +( +\ +* ++ +) +? +" +) +; +/ +/ +nomi +- +0 +. +0 +. +2 +: +" +[ +0 +- +9 +] ++ +" +consistent +! +( +nomi_0 +" +[ +0 +- +9 +] ++ +" +) +; +/ +/ +nodes +- +0 +. +1 +. +0 +: +" +( +[ +0 +- +9 +] ++ +) +( +? +: +nodes +| +n +) +? +: +( +[ +^ +] ++ +) +? +" +consistent +! +( +nodes_0 +" +( +[ +0 +- +9 +] ++ +) +( +? +: +nodes +| +n +) +? +: +( +[ +^ +] ++ +) +? +" +) +; +/ +/ +not +- +stakkr +- +1 +. +0 +. +0 +: +r +" +( +? +i +) +in +( +\ +d ++ +) +( +second +| +minute +| +hour +| +day +| +week +) +s +? +" +consistent +! +( +not_stakkr_0 +r +" +( +? +i +) +in +( +\ +d ++ +) +( +second +| +minute +| +hour +| +day +| +week +) +s +? +" +) +; +/ +/ +notetxt +- +0 +. +0 +. +1 +: +" +^ +( +[ +A +- +Za +- +z0 +- +9 +- +_ +: +] ++ +) +\ +n +- ++ +\ +n +" +consistent +! +( +notetxt_0 +" +^ +( +[ +A +- +Za +- +z0 +- +9 +- +_ +: +] ++ +) +\ +n +- ++ +\ +n +" +) +; +/ +/ +nail +- +0 +. +1 +. +0 +- +pre +. +0 +: +r +" +^ +- +? +[ +0 +- +9 +] ++ +( +\ +. +[ +0 +- +9 +] ++ +) +? +( +[ +eE +] +- +? +[ +0 +- +9 +] ++ +) +? +" +consistent +! +( +nail_0 +r +" +^ +- +? +[ +0 +- +9 +] ++ +( +\ +. +[ +0 +- +9 +] ++ +) +? +( +[ +eE +] +- +? +[ +0 +- +9 +] ++ +) +? +" +) +; +/ +/ +nail +- +0 +. +1 +. +0 +- +pre +. +0 +: +r +" +^ +- +? +[ +0 +- +9 +] ++ +" +consistent +! +( +nail_1 +r +" +^ +- +? +[ +0 +- +9 +] ++ +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +[ +^ +\ +w +\ +s +\ +pP +] ++ +" +consistent +! +( +askalono_0 +r +" +[ +^ +\ +w +\ +s +\ +pP +] ++ +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +( +? +x +) +[ +\ +t +\ +p +{ +Zs +} +\ +\ +/ +\ +| +\ +x2044 +] ++ +" +consistent +! +( +askalono_1 +r +" +( +? +x +) +[ +\ +t +\ +p +{ +Zs +} +\ +\ +/ +\ +| +\ +x2044 +] ++ +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +\ +p +{ +Pd +} ++ +" +consistent +! +( +askalono_2 +r +" +\ +p +{ +Pd +} ++ +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +\ +p +{ +Ps +} ++ +" +consistent +! +( +askalono_3 +r +" +\ +p +{ +Ps +} ++ +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +\ +p +{ +Pe +} ++ +" +consistent +! +( +askalono_4 +r +" +\ +p +{ +Pe +} ++ +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +\ +p +{ +Pc +} ++ +" +consistent +! +( +askalono_5 +r +" +\ +p +{ +Pc +} ++ +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +[ +] +" +consistent +! +( +askalono_6 +r +" +[ +] +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +[ +\ +r +\ +n +\ +v +\ +f +] +" +consistent +! +( +askalono_7 +r +" +[ +\ +r +\ +n +\ +v +\ +f +] +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +\ +n +{ +3 +} +" +consistent +! +( +askalono_8 +r +" +\ +n +{ +3 +} +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +[ +^ +\ +w +\ +s +] ++ +" +consistent +! +( +askalono_9 +r +" +[ +^ +\ +w +\ +s +] ++ +" +) +; +/ +/ +askalono +- +0 +. +2 +. +0 +: +r +" +\ +s ++ +" +consistent +! +( +askalono_10 +r +" +\ +s ++ +" +) +; +/ +/ +assembunny_plus +- +0 +. +0 +. +3 +: +r +" +[ +^ +0 +- +9a +- +zA +- +Z_ +] +" +consistent +! +( +assembunny_plus_0 +r +" +[ +^ +0 +- +9a +- +zA +- +Z_ +] +" +) +; +/ +/ +assembunny_plus +- +0 +. +0 +. +3 +: +r +" +[ +0 +- +9 +] +" +consistent +! +( +assembunny_plus_1 +r +" +[ +0 +- +9 +] +" +) +; +/ +/ +salt +- +compressor +- +0 +. +4 +. +0 +: +r +" +( +? +m +) +^ +Minion +( +\ +S +* +) +did +not +respond +\ +. +No +job +will +be +sent +\ +. +" +consistent +! +( +salt_compressor_0 +r +" +( +? +m +) +^ +Minion +( +\ +S +* +) +did +not +respond +\ +. +No +job +will +be +sent +\ +. +" +) +; +/ +/ +sabisabi +- +0 +. +4 +. +1 +: +r +" +< +/ +? +[ +^ +> +] ++ +? +> +" +consistent +! +( +sabisabi_0 +r +" +< +/ +? +[ +^ +> +] ++ +? +> +" +) +; +/ +/ +sabisabi +- +0 +. +4 +. +1 +: +r +" +\ +( +[ +^ +) +] +* +\ +) +" +consistent +! +( +sabisabi_1 +r +" +\ +( +[ +^ +) +] +* +\ +) +" +) +; +/ +/ +sassers +- +0 +. +13 +. +5 +- +h28 +: +" +import +\ +" +( +[ +^ +\ +" +] +* +) +\ +" +; +" +consistent +! +( +sassers_0 +" +import +\ +" +( +[ +^ +\ +" +] +* +) +\ +" +; +" +) +; +/ +/ +shadowsocks +- +0 +. +6 +. +2 +: +r +" +[ +A +- +Za +- +z +\ +d +- +] +{ +1 +63 +} +" +consistent +! +( +shadowsocks_0 +r +" +[ +A +- +Za +- +z +\ +d +- +] +{ +1 +63 +} +" +) +; +/ +/ +shkeleton +- +0 +. +1 +. +5 +: +" +[ +abc +] ++ +" +consistent +! +( +shkeleton_0 +" +[ +abc +] ++ +" +) +; +/ +/ +shellwords +- +0 +. +1 +. +0 +: +r +" +( +[ +^ +A +- +Za +- +z0 +- +9_ +\ +- +. +: +/ +\ +n +] +) +" +consistent +! +( +shellwords_0 +r +" +( +[ +^ +A +- +Za +- +z0 +- +9_ +\ +- +. +: +/ +\ +n +] +) +" +) +; +/ +/ +shellwords +- +0 +. +1 +. +0 +: +r +" +\ +n +" +consistent +! +( +shellwords_1 +r +" +\ +n +" +) +; +/ +/ +shush +- +0 +. +1 +. +5 +: +" +( +? +P +< +num +> +[ +0 +- +9 +] ++ +) +( +? +P +< +units +> +[ +dhms +] +) +" +consistent +! +( +shush_0 +" +( +? +P +< +num +> +[ +0 +- +9 +] ++ +) +( +? +P +< +units +> +[ +dhms +] +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +: +Chrome +| +CrMo +| +CriOS +) +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_0 +r +" +( +? +: +Chrome +| +CrMo +| +CriOS +) +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Vivaldi +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_1 +r +" +Vivaldi +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Firefox +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_2 +r +" +Firefox +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +^ +Mozilla +/ +[ +. +0 +- +9 +] ++ +\ +( +( +? +: +Mobile +| +Tablet +) +; +( +? +: +. +* +; +) +? +rv +: +( +[ +. +0 +- +9 +] ++ +) +\ +) +Gecko +/ +[ +. +0 +- +9 +] ++ +Firefox +/ +[ +. +0 +- +9 +] ++ +" +consistent +! +( +woothee_3 +r +" +^ +Mozilla +/ +[ +. +0 +- +9 +] ++ +\ +( +( +? +: +Mobile +| +Tablet +) +; +( +? +: +. +* +; +) +? +rv +: +( +[ +. +0 +- +9 +] ++ +) +\ +) +Gecko +/ +[ +. +0 +- +9 +] ++ +Firefox +/ +[ +. +0 +- +9 +] ++ +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +FxiOS +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_4 +r +" +FxiOS +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +\ +( +( +[ +^ +; +) +] ++ +) +; +FOMA +; +" +consistent +! +( +woothee_5 +r +" +\ +( +( +[ +^ +; +) +] ++ +) +; +FOMA +; +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +jig +browser +[ +^ +; +] ++ +; +( +[ +^ +) +; +] ++ +) +" +consistent +! +( +woothee_6 +r +" +jig +browser +[ +^ +; +] ++ +; +( +[ +^ +) +; +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +i +) +rss +( +? +: +reader +| +bar +| +[ +- +_ +/ +; +( +) +] +| +[ ++ +] +* +/ +) +" +consistent +! +( +woothee_7 +r +" +( +? +i +) +rss +( +? +: +reader +| +bar +| +[ +- +_ +/ +; +( +) +] +| +[ ++ +] +* +/ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +i +) +( +? +: +bot +| +crawler +| +spider +) +( +? +: +[ +- +_ +. +/ +; +( +) +] +| +) +" +consistent +! +( +woothee_8 +r +" +( +? +i +) +( +? +: +bot +| +crawler +| +spider +) +( +? +: +[ +- +_ +. +/ +; +( +) +] +| +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +i +) +( +? +: +feed +| +web +) +? +parser +" +consistent +! +( +woothee_9 +r +" +( +? +i +) +( +? +: +feed +| +web +) +? +parser +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +i +) +watch +? +dog +" +consistent +! +( +woothee_10 +r +" +( +? +i +) +watch +? +dog +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Edge +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_11 +r +" +Edge +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +MSIE +( +[ +. +0 +- +9 +] ++ +) +; +" +consistent +! +( +woothee_12 +r +" +MSIE +( +[ +. +0 +- +9 +] ++ +) +; +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Version +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_13 +r +" +Version +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Opera +[ +/ +] +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_14 +r +" +Opera +[ +/ +] +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +OPR +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_15 +r +" +OPR +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Version +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_16 +r +" +Version +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +: +SoftBank +| +Vodafone +| +J +- +PHONE +) +/ +[ +. +0 +- +9 +] ++ +/ +( +[ +^ +/ +; +( +) +] ++ +) +" +consistent +! +( +woothee_17 +r +" +( +? +: +SoftBank +| +Vodafone +| +J +- +PHONE +) +/ +[ +. +0 +- +9 +] ++ +/ +( +[ +^ +/ +; +( +) +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Trident +/ +( +[ +. +0 +- +9 +] ++ +) +; +" +consistent +! +( +woothee_18 +r +" +Trident +/ +( +[ +. +0 +- +9 +] ++ +) +; +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +rv +: +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_19 +r +" +rv +: +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +IEMobile +/ +( +[ +. +0 +- +9 +] ++ +) +; +" +consistent +! +( +woothee_20 +r +" +IEMobile +/ +( +[ +. +0 +- +9 +] ++ +) +; +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +: +WILLCOM +| +DDIPOCKET +) +; +[ +^ +/ +] ++ +/ +( +[ +^ +/ +; +( +) +] ++ +) +" +consistent +! +( +woothee_21 +r +" +( +? +: +WILLCOM +| +DDIPOCKET +) +; +[ +^ +/ +] ++ +/ +( +[ +^ +/ +; +( +) +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Windows +( +[ +. +a +- +zA +- +Z0 +- +9 +] ++ +) +[ +; +\ +\ +) +] +" +consistent +! +( +woothee_22 +r +" +Windows +( +[ +. +a +- +zA +- +Z0 +- +9 +] ++ +) +[ +; +\ +\ +) +] +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +^ +Phone +( +? +: +OS +) +? +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_23 +r +" +^ +Phone +( +? +: +OS +) +? +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +iP +( +hone +; +| +ad +; +| +od +) +. +* +like +Mac +OS +X +" +consistent +! +( +woothee_24 +r +" +iP +( +hone +; +| +ad +; +| +od +) +. +* +like +Mac +OS +X +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Version +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_25 +r +" +Version +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +rv +: +( +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +) +" +consistent +! +( +woothee_26 +r +" +rv +: +( +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +FreeBSD +( +[ +^ +; +\ +) +] ++ +) +; +" +consistent +! +( +woothee_27 +r +" +FreeBSD +( +[ +^ +; +\ +) +] ++ +) +; +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +CrOS +( +[ +^ +\ +) +] ++ +) +\ +) +" +consistent +! +( +woothee_28 +r +" +CrOS +( +[ +^ +\ +) +] ++ +) +\ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Android +[ +- +] +( +\ +d ++ +\ +. +\ +d ++ +( +? +: +\ +. +\ +d ++ +) +? +) +" +consistent +! +( +woothee_29 +r +" +Android +[ +- +] +( +\ +d ++ +\ +. +\ +d ++ +( +? +: +\ +. +\ +d ++ +) +? +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +PSP +\ +( +PlayStation +Portable +\ +) +; +( +[ +. +0 +- +9 +] ++ +) +\ +) +" +consistent +! +( +woothee_30 +r +" +PSP +\ +( +PlayStation +Portable +\ +) +; +( +[ +. +0 +- +9 +] ++ +) +\ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +PLAYSTATION +3 +; +? +( +[ +. +0 +- +9 +] ++ +) +\ +) +" +consistent +! +( +woothee_31 +r +" +PLAYSTATION +3 +; +? +( +[ +. +0 +- +9 +] ++ +) +\ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +PlayStation +Vita +( +[ +. +0 +- +9 +] ++ +) +\ +) +" +consistent +! +( +woothee_32 +r +" +PlayStation +Vita +( +[ +. +0 +- +9 +] ++ +) +\ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +PlayStation +4 +( +[ +. +0 +- +9 +] ++ +) +\ +) +" +consistent +! +( +woothee_33 +r +" +PlayStation +4 +( +[ +. +0 +- +9 +] ++ +) +\ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +BB10 +( +? +: +. ++ +) +Version +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_34 +r +" +BB10 +( +? +: +. ++ +) +Version +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +BlackBerry +( +? +: +\ +d ++ +) +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_35 +r +" +BlackBerry +( +? +: +\ +d ++ +) +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +; +CPU +( +? +: +iPhone +) +? +OS +( +\ +d ++ +_ +\ +d ++ +( +? +: +_ +\ +d ++ +) +? +) +like +Mac +OS +X +" +consistent +! +( +woothee_36 +r +" +; +CPU +( +? +: +iPhone +) +? +OS +( +\ +d ++ +_ +\ +d ++ +( +? +: +_ +\ +d ++ +) +? +) +like +Mac +OS +X +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Mac +OS +X +( +10 +[ +. +_ +] +\ +d ++ +( +? +: +[ +. +_ +] +\ +d ++ +) +? +) +( +? +: +\ +) +| +; +) +" +consistent +! +( +woothee_37 +r +" +Mac +OS +X +( +10 +[ +. +_ +] +\ +d ++ +( +? +: +[ +. +_ +] +\ +d ++ +) +? +) +( +? +: +\ +) +| +; +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +^ +( +? +: +Apache +- +HttpClient +/ +| +Jakarta +Commons +- +HttpClient +/ +| +Java +/ +) +" +consistent +! +( +woothee_38 +r +" +^ +( +? +: +Apache +- +HttpClient +/ +| +Jakarta +Commons +- +HttpClient +/ +| +Java +/ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +[ +- +] +HttpClient +( +/ +| +) +" +consistent +! +( +woothee_39 +r +" +[ +- +] +HttpClient +( +/ +| +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +^ +( +? +: +PHP +| +WordPress +| +CakePHP +| +PukiWiki +| +PECL +: +: +HTTP +) +( +? +: +/ +| +| +) +" +consistent +! +( +woothee_40 +r +" +^ +( +? +: +PHP +| +WordPress +| +CakePHP +| +PukiWiki +| +PECL +: +: +HTTP +) +( +? +: +/ +| +| +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +: +PEAR +HTTP_Request +| +HTTP_Request +) +( +? +: +class +| +2 +) +" +consistent +! +( +woothee_41 +r +" +( +? +: +PEAR +HTTP_Request +| +HTTP_Request +) +( +? +: +class +| +2 +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +( +? +: +Rome +Client +| +UnwindFetchor +/ +| +ia_archiver +| +Summify +| +PostRank +/ +) +" +consistent +! +( +woothee_42 +r +" +( +? +: +Rome +Client +| +UnwindFetchor +/ +| +ia_archiver +| +Summify +| +PostRank +/ +) +" +) +; +/ +/ +woothee +- +0 +. +8 +. +0 +: +r +" +Sleipnir +/ +( +[ +. +0 +- +9 +] ++ +) +" +consistent +! +( +woothee_43 +r +" +Sleipnir +/ +( +[ +. +0 +- +9 +] ++ +) +" +) +; +/ +/ +word_replace +- +0 +. +0 +. +3 +: +r +" +[ +a +- +z +| +A +- +Z +| +\ +d +] ++ +" +consistent +! +( +word_replace_0 +r +" +[ +a +- +z +| +A +- +Z +| +\ +d +] ++ +" +) +; +/ +/ +wordcount +- +0 +. +1 +. +0 +: +r +" +\ +w ++ +" +consistent +! +( +wordcount_0 +r +" +\ +w ++ +" +) +; +/ +/ +just +- +0 +. +3 +. +12 +: +" +^ +( +[ +^ += +] ++ +) += +( +. +* +) +" +consistent +! +( +just_0 +" +^ +( +[ +^ += +] ++ +) += +( +. +* +) +" +) +; +/ +/ +emote +- +0 +. +1 +. +0 +: +r +" +: +[ +a +- +zA +- +Z_ +] ++ +? +: +" +consistent +! +( +emote_0 +r +" +: +[ +a +- +zA +- +Z_ +] ++ +? +: +" +) +; +/ +/ +emojicons +- +1 +. +0 +. +1 +: +r +" +: +( +[ +a +- +zA +- +Z0 +- +9_ ++ +- +] ++ +) +: +" +consistent +! +( +emojicons_0 +r +" +: +( +[ +a +- +zA +- +Z0 +- +9_ ++ +- +] ++ +) +: +" +) +; +/ +/ +git2_codecommit +- +0 +. +1 +. +2 +: +r +" +git +- +codecommit +\ +. +( +[ +a +- +z0 +- +9 +- +] ++ +) +\ +. +amazonaws +\ +. +com +" +consistent +! +( +git2_codecommit_0 +r +" +git +- +codecommit +\ +. +( +[ +a +- +z0 +- +9 +- +] ++ +) +\ +. +amazonaws +\ +. +com +" +) +; +/ +/ +git +- +workarea +- +3 +. +1 +. +2 +: +r +" +^ +submodule +\ +. +( +? +P +< +name +> +. +* +) +\ +. +( +? +P +< +key +> +[ +^ += +] +* +) += +( +? +P +< +value +> +. +* +) +" +consistent +! +( +git_workarea_0 +r +" +^ +submodule +\ +. +( +? +P +< +name +> +. +* +) +\ +. +( +? +P +< +key +> +[ +^ += +] +* +) += +( +? +P +< +value +> +. +* +) +" +) +; +/ +/ +git +- +shell +- +enforce +- +directory +- +1 +. +0 +. +0 +: +r +" +^ +( +? +P +< +command +> +git +- +( +? +: +receive +| +upload +) +- +pack +) +' +( +? +P +< +path +> +. ++ +) +' +" +consistent +! +( +git_shell_enforce_directory_0 +r +" +^ +( +? +P +< +command +> +git +- +( +? +: +receive +| +upload +) +- +pack +) +' +( +? +P +< +path +> +. ++ +) +' +" +) +; +/ +/ +git +- +journal +- +1 +. +6 +. +3 +: +r +" +[ +\ +n +] +: +( +. +* +? +) +: +" +consistent +! +( +git_journal_0 +r +" +[ +\ +n +] +: +( +. +* +? +) +: +" +) +; +/ +/ +git +- +find +- +0 +. +3 +. +2 +: +r +" +^ +git +( +? +P +< +host +> +[ +[ +: +alnum +: +] +\ +. +_ +- +] ++ +) +: +( +? +P +< +path +> +[ +[ +: +alnum +: +] +\ +. +_ +\ +- +/ +] ++ +) +. +git +" +consistent +! +( +git_find_0 +r +" +^ +git +( +? +P +< +host +> +[ +[ +: +alnum +: +] +\ +. +_ +- +] ++ +) +: +( +? +P +< +path +> +[ +[ +: +alnum +: +] +\ +. +_ +\ +- +/ +] ++ +) +. +git +" +) +; +/ +/ +gitlab +- +api +- +0 +. +6 +. +0 +: +r +" +private_token += +\ +w +{ +20 +} +" +consistent +! +( +gitlab_api_0 +r +" +private_token += +\ +w +{ +20 +} +" +) +; +/ +/ +td +- +client +- +0 +. +7 +. +0 +: +" +^ +( +http +: +/ +/ +| +https +: +/ +/ +) +" +consistent +! +( +td_client_0 +" +^ +( +http +: +/ +/ +| +https +: +/ +/ +) +" +) +; +/ +/ +karaconv +- +0 +. +3 +. +0 +: +r +" +- +- +( +? +P +< +type +> +[ +a +- +zA +- +Z +] ++ +) +- +- +( +? +P +< +contents +> +. +* +) +" +consistent +! +( +karaconv_0 +r +" +- +- +( +? +P +< +type +> +[ +a +- +zA +- +Z +] ++ +) +- +- +( +? +P +< +contents +> +. +* +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +( +? +P +< +comp +> +et +al +\ +. +) +( +? +: +\ +. +) +" +consistent +! +( +katana_0 +r +" +( +? +P +< +comp +> +et +al +\ +. +) +( +? +: +\ +. +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +\ +. +{ +3 +} +" +consistent +! +( +katana_1 +r +" +\ +. +{ +3 +} +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +( +? +P +< +number +> +[ +0 +- +9 +] ++ +) +\ +. +( +? +P +< +decimal +> +[ +0 +- +9 +] ++ +) +" +consistent +! +( +katana_2 +r +" +( +? +P +< +number +> +[ +0 +- +9 +] ++ +) +\ +. +( +? +P +< +decimal +> +[ +0 +- +9 +] ++ +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +\ +s +\ +. +( +? +P +< +nums +> +[ +0 +- +9 +] ++ +) +" +consistent +! +( +katana_3 +r +" +\ +s +\ +. +( +? +P +< +nums +> +[ +0 +- +9 +] ++ +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +( +? +: +[ +A +- +Za +- +z +] +\ +. +) +{ +2 +} +" +consistent +! +( +katana_4 +r +" +( +? +: +[ +A +- +Za +- +z +] +\ +. +) +{ +2 +} +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +( +? +P +< +init +> +[ +A +- +Z +] +) +( +? +P +< +point +> +\ +. +) +" +consistent +! +( +katana_5 +r +" +( +? +P +< +init +> +[ +A +- +Z +] +) +( +? +P +< +point +> +\ +. +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +( +? +P +< +title +> +[ +A +- +Z +] +[ +a +- +z +] +{ +1 +3 +} +) +( +\ +. +) +" +consistent +! +( +katana_6 +r +" +( +? +P +< +title +> +[ +A +- +Z +] +[ +a +- +z +] +{ +1 +3 +} +) +( +\ +. +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +& += += +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +consistent +! +( +katana_7 +r +" +& += += +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +& +\ +^ +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +consistent +! +( +katana_8 +r +" +& +\ +^ +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +& +\ +* +\ +* +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +consistent +! +( +katana_9 +r +" +& +\ +* +\ +* +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +& += +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +consistent +! +( +katana_10 +r +" +& += +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +& +# +# +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +consistent +! +( +katana_11 +r +" +& +# +# +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +) +; +/ +/ +katana +- +1 +. +0 +. +2 +: +r +" +& +\ +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +consistent +! +( +katana_12 +r +" +& +\ +& +( +? +P +< +p +> +[ +. +! +? +] +) +" +) +; +/ +/ +kailua_syntax +- +1 +. +1 +. +0 +: +r +" +( +? +: +_ +| +\ +d ++ +( +? +: +/ +\ +d ++ +( +? +: +- +\ +d ++ +) +? +) +? +) +" +consistent +! +( +kailua_syntax_0 +r +" +( +? +: +_ +| +\ +d ++ +( +? +: +/ +\ +d ++ +( +? +: +- +\ +d ++ +) +? +) +? +) +" +) +; +/ +/ +kailua_syntax +- +1 +. +1 +. +0 +: +r +" +< +( +\ +d ++ +) +> +" +consistent +! +( +kailua_syntax_1 +r +" +< +( +\ +d ++ +) +> +" +) +; +/ +/ +ftp +- +3 +. +0 +. +1 +: +r +" +\ +( +( +\ +d ++ +) +( +\ +d ++ +) +( +\ +d ++ +) +( +\ +d ++ +) +( +\ +d ++ +) +( +\ +d ++ +) +\ +) +" +consistent +! +( +ftp_0 +r +" +\ +( +( +\ +d ++ +) +( +\ +d ++ +) +( +\ +d ++ +) +( +\ +d ++ +) +( +\ +d ++ +) +( +\ +d ++ +) +\ +) +" +) +; +/ +/ +ftp +- +3 +. +0 +. +1 +: +r +" +\ +b +( +\ +d +{ +4 +} +) +( +\ +d +{ +2 +} +) +( +\ +d +{ +2 +} +) +( +\ +d +{ +2 +} +) +( +\ +d +{ +2 +} +) +( +\ +d +{ +2 +} +) +\ +b +" +consistent +! +( +ftp_1 +r +" +\ +b +( +\ +d +{ +4 +} +) +( +\ +d +{ +2 +} +) +( +\ +d +{ +2 +} +) +( +\ +d +{ +2 +} +) +( +\ +d +{ +2 +} +) +( +\ +d +{ +2 +} +) +\ +b +" +) +; +/ +/ +ftp +- +3 +. +0 +. +1 +: +r +" +\ +s ++ +( +\ +d ++ +) +\ +s +* +" +consistent +! +( +ftp_2 +r +" +\ +s ++ +( +\ +d ++ +) +\ +s +* +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +< +countryCode +> +( +. +* +? +) +< +/ +countryCode +> +" +consistent +! +( +vat_0 +r +" +< +countryCode +> +( +. +* +? +) +< +/ +countryCode +> +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +< +vatNumber +> +( +. +* +? +) +< +/ +vatNumber +> +" +consistent +! +( +vat_1 +r +" +< +vatNumber +> +( +. +* +? +) +< +/ +vatNumber +> +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +< +name +> +( +. +* +? +) +< +/ +name +> +" +consistent +! +( +vat_2 +r +" +< +name +> +( +. +* +? +) +< +/ +name +> +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +< +address +> +( +? +s +) +( +. +* +? +) +( +? +- +s +) +< +/ +address +> +" +consistent +! +( +vat_3 +r +" +< +address +> +( +? +s +) +( +. +* +? +) +( +? +- +s +) +< +/ +address +> +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +< +valid +> +( +true +| +false +) +< +/ +valid +> +" +consistent +! +( +vat_4 +r +" +< +valid +> +( +true +| +false +) +< +/ +valid +> +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +ATU +\ +d +{ +8 +} +" +consistent +! +( +vat_5 +r +" +^ +ATU +\ +d +{ +8 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +BE0 +? +\ +d +{ +9 +10 +} +" +consistent +! +( +vat_6 +r +" +^ +BE0 +? +\ +d +{ +9 +10 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +BG +\ +d +{ +9 +10 +} +" +consistent +! +( +vat_7 +r +" +^ +BG +\ +d +{ +9 +10 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +HR +\ +d +{ +11 +} +" +consistent +! +( +vat_8 +r +" +^ +HR +\ +d +{ +11 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +CY +\ +d +{ +8 +} +[ +A +- +Z +] +" +consistent +! +( +vat_9 +r +" +^ +CY +\ +d +{ +8 +} +[ +A +- +Z +] +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +CZ +\ +d +{ +8 +10 +} +" +consistent +! +( +vat_10 +r +" +^ +CZ +\ +d +{ +8 +10 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +DK +\ +d +{ +8 +} +" +consistent +! +( +vat_11 +r +" +^ +DK +\ +d +{ +8 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +EE +\ +d +{ +9 +} +" +consistent +! +( +vat_12 +r +" +^ +EE +\ +d +{ +9 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +FI +\ +d +{ +8 +} +" +consistent +! +( +vat_13 +r +" +^ +FI +\ +d +{ +8 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +FR +[ +A +- +HJ +- +NP +- +Z0 +- +9 +] +[ +A +- +HJ +- +NP +- +Z0 +- +9 +] +\ +d +{ +9 +} +" +consistent +! +( +vat_14 +r +" +^ +FR +[ +A +- +HJ +- +NP +- +Z0 +- +9 +] +[ +A +- +HJ +- +NP +- +Z0 +- +9 +] +\ +d +{ +9 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +DE +\ +d +{ +9 +} +" +consistent +! +( +vat_15 +r +" +^ +DE +\ +d +{ +9 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +EL +\ +d +{ +9 +} +" +consistent +! +( +vat_16 +r +" +^ +EL +\ +d +{ +9 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +HU +\ +d +{ +8 +} +" +consistent +! +( +vat_17 +r +" +^ +HU +\ +d +{ +8 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +IE +\ +d +[ +A +- +Z0 +- +9 +\ ++ +\ +* +] +\ +d +{ +5 +} +[ +A +- +Z +] +{ +1 +2 +} +" +consistent +! +( +vat_18 +r +" +^ +IE +\ +d +[ +A +- +Z0 +- +9 +\ ++ +\ +* +] +\ +d +{ +5 +} +[ +A +- +Z +] +{ +1 +2 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +IT +\ +d +{ +11 +} +" +consistent +! +( +vat_19 +r +" +^ +IT +\ +d +{ +11 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +LV +\ +d +{ +11 +} +" +consistent +! +( +vat_20 +r +" +^ +LV +\ +d +{ +11 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +LT +( +\ +d +{ +9 +} +| +\ +d +{ +12 +} +) +" +consistent +! +( +vat_21 +r +" +^ +LT +( +\ +d +{ +9 +} +| +\ +d +{ +12 +} +) +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +LU +\ +d +{ +8 +} +" +consistent +! +( +vat_22 +r +" +^ +LU +\ +d +{ +8 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +MT +\ +d +{ +8 +} +" +consistent +! +( +vat_23 +r +" +^ +MT +\ +d +{ +8 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +NL +\ +d +{ +9 +} +B +\ +d +{ +2 +} +" +consistent +! +( +vat_24 +r +" +^ +NL +\ +d +{ +9 +} +B +\ +d +{ +2 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +PL +\ +d +{ +10 +} +" +consistent +! +( +vat_25 +r +" +^ +PL +\ +d +{ +10 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +PT +\ +d +{ +9 +} +" +consistent +! +( +vat_26 +r +" +^ +PT +\ +d +{ +9 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +RO +\ +d +{ +2 +10 +} +" +consistent +! +( +vat_27 +r +" +^ +RO +\ +d +{ +2 +10 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +SK +\ +d +{ +10 +} +" +consistent +! +( +vat_28 +r +" +^ +SK +\ +d +{ +10 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +SI +\ +d +{ +8 +} +" +consistent +! +( +vat_29 +r +" +^ +SI +\ +d +{ +8 +} +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +ES +[ +A +- +Z0 +- +9 +] +\ +d +{ +7 +} +[ +A +- +Z0 +- +9 +] +" +consistent +! +( +vat_30 +r +" +^ +ES +[ +A +- +Z0 +- +9 +] +\ +d +{ +7 +} +[ +A +- +Z0 +- +9 +] +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +SE +\ +d +{ +10 +} +01 +" +consistent +! +( +vat_31 +r +" +^ +SE +\ +d +{ +10 +} +01 +" +) +; +/ +/ +vat +- +0 +. +1 +. +0 +: +r +" +^ +( +GB +( +GD +| +HA +) +\ +d +{ +3 +} +| +GB +\ +d +{ +9 +} +| +GB +\ +d +{ +12 +} +) +" +consistent +! +( +vat_32 +r +" +^ +( +GB +( +GD +| +HA +) +\ +d +{ +3 +} +| +GB +\ +d +{ +9 +} +| +GB +\ +d +{ +12 +} +) +" +) +; +/ +/ +eve +- +0 +. +1 +. +1 +: +r +" +\ +{ +\ +{ +( +. +* +) +\ +} +\ +} +" +consistent +! +( +eve_0 +r +" +\ +{ +\ +{ +( +. +* +) +\ +} +\ +} +" +) +; +/ +/ +egc +- +0 +. +1 +. +2 +: +" +^ +mio +" +consistent +! +( +egc_0 +" +^ +mio +" +) +; +/ +/ +pew +- +0 +. +2 +. +3 +: +" +" +consistent +! +( +pew_0 +" +" +) +; +/ +/ +pew +- +0 +. +2 +. +3 +: +" +" +consistent +! +( +pew_1 +" +" +) +; +/ +/ +mob +- +0 +. +4 +. +3 +: +" +y +" +consistent +! +( +mob_0 +" +y +" +) +; +/ +/ +lit +- +0 +. +2 +. +8 +: +" +( +[ +a +- +z +] ++ +) +" +consistent +! +( +lit_0 +" +( +[ +a +- +z +] ++ +) +" +) +; +/ +/ +lit +- +0 +. +2 +. +8 +: +" +( +[ +A +- +Z +- +] ++ +) +: +( +. +* +) +" +consistent +! +( +lit_1 +" +( +[ +A +- +Z +- +] ++ +) +: +( +. +* +) +" +) +; +/ +/ +lit +- +0 +. +2 +. +8 +: +" +^ +[ +a +- +zA +- +Z_ +] +[ +a +- +zA +- +Z0 +- +9_ +] +* +" +consistent +! +( +lit_2 +" +^ +[ +a +- +zA +- +Z_ +] +[ +a +- +zA +- +Z0 +- +9_ +] +* +" +) +; +/ +/ +avm +- +1 +. +0 +. +1 +: +r +" +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +" +consistent +! +( +avm_0 +r +" +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +" +) +; +/ +/ +avm +- +1 +. +0 +. +1 +: +r +" +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +" +consistent +! +( +avm_1 +r +" +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +" +) +; +/ +/ +orm +- +0 +. +2 +. +0 +: +r +" +^ +Vec +< +( +. ++ +) +> +" +consistent +! +( +orm_0 +r +" +^ +Vec +< +( +. ++ +) +> +" +) +; +/ +/ +sgf +- +0 +. +1 +. +5 +: +r +" +\ +\ +( +\ +r +\ +n +| +\ +n +\ +r +| +\ +n +| +\ +r +) +" +consistent +! +( +sgf_0 +r +" +\ +\ +( +\ +r +\ +n +| +\ +n +\ +r +| +\ +n +| +\ +r +) +" +) +; +/ +/ +sgf +- +0 +. +1 +. +5 +: +r +" +\ +\ +( +. +) +" +consistent +! +( +sgf_1 +r +" +\ +\ +( +. +) +" +) +; +/ +/ +sgf +- +0 +. +1 +. +5 +: +r +" +\ +r +\ +n +| +\ +n +\ +r +| +\ +n +| +\ +r +" +consistent +! +( +sgf_2 +r +" +\ +r +\ +n +| +\ +n +\ +r +| +\ +n +| +\ +r +" +) +; +/ +/ +sgf +- +0 +. +1 +. +5 +: +r +" +( +[ +\ +] +\ +\ +: +] +) +" +consistent +! +( +sgf_3 +r +" +( +[ +\ +] +\ +\ +: +] +) +" +) +; +/ +/ +dok +- +0 +. +2 +. +0 +: +" +^ +Bearer +realm += +\ +" +( +. ++ +? +) +\ +" +service += +\ +" +( +. ++ +? +) +\ +" +scope += +\ +" +( +. ++ +? +) +\ +" +" +consistent +! +( +dok_0 +" +^ +Bearer +realm += +\ +" +( +. ++ +? +) +\ +" +service += +\ +" +( +. ++ +? +) +\ +" +scope += +\ +" +( +. ++ +? +) +\ +" +" +) +; +/ +/ +d20 +- +0 +. +1 +. +0 +: +r +" +( +[ ++ +- +] +? +\ +s +* +\ +d ++ +[ +dD +] +\ +d ++ +| +[ ++ +- +] +? +\ +s +* +\ +d ++ +) +" +consistent +! +( +d20_0 +r +" +( +[ ++ +- +] +? +\ +s +* +\ +d ++ +[ +dD +] +\ +d ++ +| +[ ++ +- +] +? +\ +s +* +\ +d ++ +) +" +) +; +/ +/ +dvb +- +0 +. +3 +. +0 +: +" +E +" +consistent +! +( +dvb_0 +" +E +" +) +; +/ +/ +dvb +- +0 +. +3 +. +0 +: +" +^ +F +" +consistent +! +( +dvb_1 +" +^ +F +" +) +; +/ +/ +dvb +- +0 +. +3 +. +0 +: +" +^ +S +" +consistent +! +( +dvb_2 +" +^ +S +" +) +; +/ +/ +ger +- +0 +. +2 +. +0 +: +r +" +Change +- +Id +: +( +I +[ +a +- +f0 +- +9 +] +{ +40 +} +) +" +consistent +! +( +ger_0 +r +" +Change +- +Id +: +( +I +[ +a +- +f0 +- +9 +] +{ +40 +} +) +" +) +; +/ +/ +ger +- +0 +. +2 +. +0 +: +r +" +( +refs +| +ref +| +fix +| +fixes +| +close +| +closes +) +\ +s ++ +( +[ +A +- +Z +] +{ +2 +5 +} +- +[ +0 +- +9 +] +{ +1 +5 +} +) +" +consistent +! +( +ger_1 +r +" +( +refs +| +ref +| +fix +| +fixes +| +close +| +closes +) +\ +s ++ +( +[ +A +- +Z +] +{ +2 +5 +} +- +[ +0 +- +9 +] +{ +1 +5 +} +) +" +) +; +/ +/ +n5 +- +0 +. +2 +. +1 +: +r +" +( +\ +d ++ +) +( +\ +. +( +\ +d ++ +) +) +? +( +\ +. +( +\ +d ++ +) +) +? +( +. +* +) +" +consistent +! +( +n5_0 +r +" +( +\ +d ++ +) +( +\ +. +( +\ +d ++ +) +) +? +( +\ +. +( +\ +d ++ +) +) +? +( +. +* +) +" +) +; +/ +/ +po +- +0 +. +1 +. +4 +: +r +" +[ +A +- +Za +- +z0 +- +9 +] +" +consistent +! +( +po_0 +r +" +[ +A +- +Za +- +z0 +- +9 +] +" +) +; +/ +/ +carnix +- +0 +. +8 +. +5 +: +" +path +is +( +| +' +) +? +( +[ +^ +' +\ +n +] +* +) +( +| +' +) +? +" +consistent +! +( +carnix_0 +" +path +is +( +| +' +) +? +( +[ +^ +' +\ +n +] +* +) +( +| +' +) +? +" +) +; +/ +/ +carnix +- +0 +. +8 +. +5 +: +r +" +^ +( +\ +S +* +) +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +( +. +* +) +? +" +consistent +! +( +carnix_1 +r +" +^ +( +\ +S +* +) +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +( +. +* +) +? +" +) +; +/ +/ +carnix +- +0 +. +8 +. +5 +: +r +" +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +" +consistent +! +( +carnix_2 +r +" +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +" +) +; +/ +/ +carnix +- +0 +. +8 +. +5 +: +r +" +( +\ +S +* +) +- +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +" +consistent +! +( +carnix_3 +r +" +( +\ +S +* +) +- +( +\ +d +* +) +\ +. +( +\ +d +* +) +\ +. +( +\ +d +* +) +( +- +( +\ +S +* +) +) +? +" +) +; +/ +/ +caseless +- +0 +. +2 +. +1 +: +r +" +^ +# +CaseFolding +- +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +. +txt +" +consistent +! +( +caseless_0 +r +" +^ +# +CaseFolding +- +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +. +txt +" +) +; +/ +/ +caseless +- +0 +. +2 +. +1 +: +r +" +^ +( +[ +0 +- +9A +- +F +] ++ +) +; +[ +CF +] +; +( +[ +0 +- +9A +- +F +] ++ +) +; +" +consistent +! +( +caseless_1 +r +" +^ +( +[ +0 +- +9A +- +F +] ++ +) +; +[ +CF +] +; +( +[ +0 +- +9A +- +F +] ++ +) +; +" +) +; +/ +/ +cabot +- +0 +. +2 +. +0 +: +" +\ +r +? +\ +n +\ +r +? +\ +n +" +consistent +! +( +cabot_0 +" +\ +r +? +\ +n +\ +r +? +\ +n +" +) +; +/ +/ +cabot +- +0 +. +2 +. +0 +: +" +\ +r +? +\ +n +" +consistent +! +( +cabot_1 +" +\ +r +? +\ +n +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +600 +" +consistent +! +( +card_validate_0 +r +" +^ +600 +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +5019 +" +consistent +! +( +card_validate_1 +r +" +^ +5019 +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +4 +" +consistent +! +( +card_validate_2 +r +" +^ +4 +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +( +5 +[ +1 +- +5 +] +| +2 +[ +2 +- +7 +] +) +" +consistent +! +( +card_validate_3 +r +" +^ +( +5 +[ +1 +- +5 +] +| +2 +[ +2 +- +7 +] +) +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +3 +[ +47 +] +" +consistent +! +( +card_validate_4 +r +" +^ +3 +[ +47 +] +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +3 +[ +0689 +] +" +consistent +! +( +card_validate_5 +r +" +^ +3 +[ +0689 +] +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +6 +( +[ +045 +] +| +22 +) +" +consistent +! +( +card_validate_6 +r +" +^ +6 +( +[ +045 +] +| +22 +) +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +( +62 +| +88 +) +" +consistent +! +( +card_validate_7 +r +" +^ +( +62 +| +88 +) +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +35 +" +consistent +! +( +card_validate_8 +r +" +^ +35 +" +) +; +/ +/ +card +- +validate +- +2 +. +2 +. +1 +: +r +" +^ +[ +0 +- +9 +] ++ +" +consistent +! +( +card_validate_9 +r +" +^ +[ +0 +- +9 +] ++ +" +) +; +/ +/ +cargo +- +testify +- +0 +. +3 +. +0 +: +r +" +\ +d +{ +1 +} +passed +. +* +filtered +out +" +consistent +! +( +cargo_testify_0 +r +" +\ +d +{ +1 +} +passed +. +* +filtered +out +" +) +; +/ +/ +cargo +- +testify +- +0 +. +3 +. +0 +: +r +" +error +( +: +| +\ +[ +) +. +* +" +consistent +! +( +cargo_testify_1 +r +" +error +( +: +| +\ +[ +) +. +* +" +) +; +/ +/ +cargo +- +wix +- +0 +. +0 +. +5 +: +r +" +< +( +. +* +? +) +> +" +consistent +! +( +cargo_wix_0 +r +" +< +( +. +* +? +) +> +" +) +; +/ +/ +cargo +- +wix +- +0 +. +0 +. +5 +: +r +" +< +( +. +* +? +) +> +" +consistent +! +( +cargo_wix_1 +r +" +< +( +. +* +? +) +> +" +) +; +/ +/ +cargo +- +wix +- +0 +. +0 +. +5 +: +r +" +< +( +. +* +? +) +> +" +consistent +! +( +cargo_wix_2 +r +" +< +( +. +* +? +) +> +" +) +; +/ +/ +cargo +- +wix +- +0 +. +0 +. +5 +: +r +" +< +( +. +* +? +) +> +" +consistent +! +( +cargo_wix_3 +r +" +< +( +. +* +? +) +> +" +) +; +/ +/ +cargo +- +incremental +- +0 +. +1 +. +23 +: +r +" +( +? +m +) +^ +incremental +: +re +- +using +( +\ +d ++ +) +out +of +( +\ +d ++ +) +modules +" +consistent +! +( +cargo_incremental_0 +r +" +( +? +m +) +^ +incremental +: +re +- +using +( +\ +d ++ +) +out +of +( +\ +d ++ +) +modules +" +) +; +/ +/ +cargo +- +incremental +- +0 +. +1 +. +23 +: +" +( +? +m +) +( +warning +| +error +) +: +( +. +* +) +\ +n +- +- +> +( +[ +^ +: +] +: +\ +\ +d ++ +: +\ +\ +d ++ +) +" +consistent +! +( +cargo_incremental_1 +" +( +? +m +) +( +warning +| +error +) +: +( +. +* +) +\ +n +- +- +> +( +[ +^ +: +] +: +\ +\ +d ++ +: +\ +\ +d ++ +) +" +) +; +/ +/ +cargo +- +incremental +- +0 +. +1 +. +23 +: +r +" +( +? +m +) +^ +test +( +. +* +) +\ +. +\ +. +\ +. +( +\ +w ++ +) +" +consistent +! +( +cargo_incremental_2 +r +" +( +? +m +) +^ +test +( +. +* +) +\ +. +\ +. +\ +. +( +\ +w ++ +) +" +) +; +/ +/ +cargo +- +incremental +- +0 +. +1 +. +23 +: +r +" +( +? +m +) +( +\ +d ++ +) +passed +; +( +\ +d ++ +) +failed +; +( +\ +d ++ +) +ignored +; +\ +d ++ +measured +" +consistent +! +( +cargo_incremental_3 +r +" +( +? +m +) +( +\ +d ++ +) +passed +; +( +\ +d ++ +) +failed +; +( +\ +d ++ +) +ignored +; +\ +d ++ +measured +" +) +; +/ +/ +cargo +- +testjs +- +0 +. +1 +. +2 +: +r +" +^ +[ +^ +- +] ++ +- +[ +0 +- +9a +- +f +] ++ +\ +. +js +" +consistent +! +( +cargo_testjs_0 +r +" +^ +[ +^ +- +] ++ +- +[ +0 +- +9a +- +f +] ++ +\ +. +js +" +) +; +/ +/ +cargo +- +tarpaulin +- +0 +. +6 +. +2 +: +r +" +\ +s +* +/ +/ +" +consistent +! +( +cargo_tarpaulin_0 +r +" +\ +s +* +/ +/ +" +) +; +/ +/ +cargo +- +tarpaulin +- +0 +. +6 +. +2 +: +r +" +/ +\ +* +" +consistent +! +( +cargo_tarpaulin_1 +r +" +/ +\ +* +" +) +; +/ +/ +cargo +- +tarpaulin +- +0 +. +6 +. +2 +: +r +" +\ +* +/ +" +consistent +! +( +cargo_tarpaulin_2 +r +" +\ +* +/ +" +) +; +/ +/ +cargo +- +culture +- +kit +- +0 +. +1 +. +0 +: +r +" +^ +fo +" +consistent +! +( +cargo_culture_kit_0 +r +" +^ +fo +" +) +; +/ +/ +cargo +- +screeps +- +0 +. +1 +. +3 +: +" +\ +\ +s ++ +" +consistent +! +( +cargo_screeps_0 +" +\ +\ +s ++ +" +) +; +/ +/ +cargo +- +brew +- +0 +. +1 +. +4 +: +r +" +( +\ +S ++ +) +v +( +[ +0 +- +9 +. +] ++ +) +" +consistent +! +( +cargo_brew_0 +r +" +( +\ +S ++ +) +v +( +[ +0 +- +9 +. +] ++ +) +" +) +; +/ +/ +cargo +- +release +- +0 +. +10 +. +2 +: +" +^ +\ +\ +[ +. ++ +\ +\ +] +" +consistent +! +( +cargo_release_0 +" +^ +\ +\ +[ +. ++ +\ +\ +] +" +) +; +/ +/ +cargo +- +release +- +0 +. +10 +. +2 +: +" +^ +\ +\ +[ +\ +\ +[ +. ++ +\ +\ +] +\ +\ +] +" +consistent +! +( +cargo_release_1 +" +^ +\ +\ +[ +\ +\ +[ +. ++ +\ +\ +] +\ +\ +] +" +) +; +/ +/ +cargo +- +edit +- +0 +. +3 +. +0 +- +beta +. +1 +: +r +" +^ +https +: +/ +/ +github +. +com +/ +( +[ +- +_0 +- +9a +- +zA +- +Z +] ++ +) +/ +( +[ +- +_0 +- +9a +- +zA +- +Z +] ++ +) +( +/ +| +. +git +) +? +" +consistent +! +( +cargo_edit_0 +r +" +^ +https +: +/ +/ +github +. +com +/ +( +[ +- +_0 +- +9a +- +zA +- +Z +] ++ +) +/ +( +[ +- +_0 +- +9a +- +zA +- +Z +] ++ +) +( +/ +| +. +git +) +? +" +) +; +/ +/ +cargo +- +edit +- +0 +. +3 +. +0 +- +beta +. +1 +: +r +" +^ +https +: +/ +/ +gitlab +. +com +/ +( +[ +- +_0 +- +9a +- +zA +- +Z +] ++ +) +/ +( +[ +- +_0 +- +9a +- +zA +- +Z +] ++ +) +( +/ +| +. +git +) +? +" +consistent +! +( +cargo_edit_1 +r +" +^ +https +: +/ +/ +gitlab +. +com +/ +( +[ +- +_0 +- +9a +- +zA +- +Z +] ++ +) +/ +( +[ +- +_0 +- +9a +- +zA +- +Z +] ++ +) +( +/ +| +. +git +) +? +" +) +; +/ +/ +cargo +- +disassemble +- +0 +. +1 +. +1 +: +" +. +* +" +consistent +! +( +cargo_disassemble_0 +" +. +* +" +) +; +/ +/ +cargo +- +demangle +- +0 +. +1 +. +2 +: +r +" +( +? +m +) +( +? +P +< +symbol +> +_ZN +[ +0 +- +9 +] ++ +. +* +E +) +" +consistent +! +( +cargo_demangle_0 +r +" +( +? +m +) +( +? +P +< +symbol +> +_ZN +[ +0 +- +9 +] ++ +. +* +E +) +" +) +; +/ +/ +cargo +- +coverage +- +annotations +- +0 +. +1 +. +5 +: +r +" +^ +\ +s +* +\ +} +( +? +: +\ +) +* +; +? +| +\ +s +* +else +\ +s +* +\ +{ +) +" +consistent +! +( +cargo_coverage_annotations_0 +r +" +^ +\ +s +* +\ +} +( +? +: +\ +) +* +; +? +| +\ +s +* +else +\ +s +* +\ +{ +) +" +) +; +/ +/ +cargo +- +urlcrate +- +1 +. +0 +. +1 +: +" +[ +\ +u +{ +001b +} +\ +u +{ +009b +} +] +[ +\ +\ +[ +( +) +# +; +? +] +* +( +? +: +[ +0 +- +9 +] +{ +1 +4 +} +( +? +: +; +[ +0 +- +9 +] +{ +0 +4 +} +) +* +) +? +[ +0 +- +9A +- +PRZcf +- +nqry += +> +< +] +" +consistent +! +( +cargo_urlcrate_0 +" +[ +\ +u +{ +001b +} +\ +u +{ +009b +} +] +[ +\ +\ +[ +( +) +# +; +? +] +* +( +? +: +[ +0 +- +9 +] +{ +1 +4 +} +( +? +: +; +[ +0 +- +9 +] +{ +0 +4 +} +) +* +) +? +[ +0 +- +9A +- +PRZcf +- +nqry += +> +< +] +" +) +; +/ +/ +cargo +- +script +- +0 +. +2 +. +8 +: +r +" +^ +\ +s +* +\ +* +( +| +) +" +consistent +! +( +cargo_script_0 +r +" +^ +\ +s +* +\ +* +( +| +) +" +) +; +/ +/ +cargo +- +script +- +0 +. +2 +. +8 +: +r +" +^ +( +\ +s ++ +) +" +consistent +! +( +cargo_script_1 +r +" +^ +( +\ +s ++ +) +" +) +; +/ +/ +cargo +- +script +- +0 +. +2 +. +8 +: +r +" +/ +\ +* +| +\ +* +/ +" +consistent +! +( +cargo_script_2 +r +" +/ +\ +* +| +\ +* +/ +" +) +; +/ +/ +cargo +- +script +- +0 +. +2 +. +8 +: +r +" +^ +\ +s +* +/ +/ +! +" +consistent +! +( +cargo_script_3 +r +" +^ +\ +s +* +/ +/ +! +" +) +; +/ +/ +cargo +- +script +- +0 +. +2 +. +8 +: +r +" +^ +# +! +[ +^ +\ +[ +] +. +* +? +( +\ +r +\ +n +| +\ +n +) +" +consistent +! +( +cargo_script_4 +r +" +^ +# +! +[ +^ +\ +[ +] +. +* +? +( +\ +r +\ +n +| +\ +n +) +" +) +; +/ +/ +cargo +- +update +- +1 +. +5 +. +2 +: +r +" +cargo +- +install +- +update +\ +. +exe +- +v +. ++ +" +consistent +! +( +cargo_update_0 +r +" +cargo +- +install +- +update +\ +. +exe +- +v +. ++ +" +) +; +/ +/ +canteen +- +0 +. +4 +. +1 +: +r +" +^ +< +( +? +: +( +int +| +uint +| +str +| +float +| +path +) +: +) +? +( +[ +\ +w_ +] +[ +a +- +zA +- +Z0 +- +9_ +] +* +) +> +" +consistent +! +( +canteen_0 +r +" +^ +< +( +? +: +( +int +| +uint +| +str +| +float +| +path +) +: +) +? +( +[ +\ +w_ +] +[ +a +- +zA +- +Z0 +- +9_ +] +* +) +> +" +) +; +/ +/ +thruster +- +cli +- +0 +. +1 +. +3 +: +r +" +( +. +) +( +[ +A +- +Z +] +) +" +consistent +! +( +thruster_cli_0 +r +" +( +. +) +( +[ +A +- +Z +] +) +" +) +; +/ +/ +thieves +- +cant +- +0 +. +1 +. +0 +: +" +( +[ +Z +] ++ +) +" +consistent +! +( +thieves_cant_0 +" +( +[ +Z +] ++ +) +" +) +; +/ +/ +codeowners +- +0 +. +1 +. +3 +: +r +" +^ +\ +S ++ +/ +\ +S ++ +" +consistent +! +( +codeowners_0 +r +" +^ +\ +S ++ +/ +\ +S ++ +" +) +; +/ +/ +codeowners +- +0 +. +1 +. +3 +: +r +" +^ +\ +S ++ +" +consistent +! +( +codeowners_1 +r +" +^ +\ +S ++ +" +) +; +/ +/ +codeowners +- +0 +. +1 +. +3 +: +r +" +^ +\ +S ++ +\ +S ++ +" +consistent +! +( +codeowners_2 +r +" +^ +\ +S ++ +\ +S ++ +" +) +; +/ +/ +conserve +- +0 +. +4 +. +2 +: +r +" +^ +b0000 +{ +21 +} +complete +20 +[ +- +0 +- +9T +: ++ +] ++ +\ +s ++ +\ +d ++ +s +\ +n +" +consistent +! +( +conserve_0 +r +" +^ +b0000 +{ +21 +} +complete +20 +[ +- +0 +- +9T +: ++ +] ++ +\ +s ++ +\ +d ++ +s +\ +n +" +) +; +/ +/ +commodore +- +0 +. +3 +. +0 +: +r +" +( +? +P +< +greeting +> +\ +S ++ +? +) +( +? +P +< +name +> +\ +S ++ +? +) +" +consistent +! +( +commodore_0 +r +" +( +? +P +< +greeting +> +\ +S ++ +? +) +( +? +P +< +name +> +\ +S ++ +? +) +" +) +; +/ +/ +corollary +- +0 +. +3 +. +0 +: +r +" +( +[ +\ +t +] +* +) +haskell +( +[ +\ +s +\ +S +] +* +? +) +" +consistent +! +( +corollary_0 +r +" +( +[ +\ +t +] +* +) +haskell +( +[ +\ +s +\ +S +] +* +? +) +" +) +; +/ +/ +corollary +- +0 +. +3 +. +0 +: +r +" +\ +b +( +( +? +: +a +| +b +| +t +) +\ +d +* +) +\ +b +" +consistent +! +( +corollary_1 +r +" +\ +b +( +( +? +: +a +| +b +| +t +) +\ +d +* +) +\ +b +" +) +; +/ +/ +colorizex +- +0 +. +1 +. +3 +: +" +NB +" +consistent +! +( +colorizex_0 +" +NB +" +) +; +/ +/ +colorstring +- +0 +. +0 +. +1 +: +r +" +( +? +i +) +\ +[ +[ +a +- +z0 +- +9_ +- +] ++ +\ +] +" +consistent +! +( +colorstring_0 +r +" +( +? +i +) +\ +[ +[ +a +- +z0 +- +9_ +- +] ++ +\ +] +" +) +; +/ +/ +colorstring +- +0 +. +0 +. +1 +: +r +" +^ +( +? +i +) +( +\ +[ +[ +a +- +z0 +- +9_ +- +] ++ +\ +] +) ++ +" +consistent +! +( +colorstring_1 +r +" +^ +( +? +i +) +( +\ +[ +[ +a +- +z0 +- +9_ +- +] ++ +\ +] +) ++ +" +) +; +/ +/ +cosmogony +- +0 +. +3 +. +0 +: +" +name +: +( +. ++ +) +" +consistent +! +( +cosmogony_0 +" +name +: +( +. ++ +) +" +) +; +/ +/ +cobalt +- +bin +- +0 +. +12 +. +1 +: +r +" +( +? +m +: +^ +{ +0 +3 +} +\ +[ +[ +^ +\ +] +] ++ +\ +] +: +. ++ +) +" +consistent +! +( +cobalt_bin_0 +r +" +( +? +m +: +^ +{ +0 +3 +} +\ +[ +[ +^ +\ +] +] ++ +\ +] +: +. ++ +) +" +) +; +/ +/ +comrak +- +0 +. +2 +. +12 +: +r +" +[ +^ +\ +p +{ +L +} +\ +p +{ +M +} +\ +p +{ +N +} +\ +p +{ +Pc +} +- +] +" +consistent +! +( +comrak_0 +r +" +[ +^ +\ +p +{ +L +} +\ +p +{ +M +} +\ +p +{ +N +} +\ +p +{ +Pc +} +- +] +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +" +consistent +! +( +content_blocker_0 +" +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +( +? +i +) +hi +" +consistent +! +( +content_blocker_1 +" +( +? +i +) +hi +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +[ +s +] +? +: +/ +/ +domain +. +org +" +consistent +! +( +content_blocker_2 +" +http +[ +s +] +? +: +/ +/ +domain +. +org +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +( +? +i +) +http +[ +s +] +? +: +/ +/ +domain +. +org +" +consistent +! +( +content_blocker_3 +" +( +? +i +) +http +[ +s +] +? +: +/ +/ +domain +. +org +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +: +/ +/ +domain +. +org +" +consistent +! +( +content_blocker_4 +" +http +: +/ +/ +domain +. +org +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +: +/ +/ +domain +. +org +" +consistent +! +( +content_blocker_5 +" +http +: +/ +/ +domain +. +org +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +ad +. +html +" +consistent +! +( +content_blocker_6 +" +ad +. +html +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +ad +. +html +" +consistent +! +( +content_blocker_7 +" +ad +. +html +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +: +/ +/ +domain +. +org +" +consistent +! +( +content_blocker_8 +" +http +: +/ +/ +domain +. +org +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +: +/ +/ +domain +. +org +/ +nocookies +. +sjs +" +consistent +! +( +content_blocker_9 +" +http +: +/ +/ +domain +. +org +/ +nocookies +. +sjs +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +: +/ +/ +domain +. +org +/ +nocookies +. +sjs +" +consistent +! +( +content_blocker_10 +" +http +: +/ +/ +domain +. +org +/ +nocookies +. +sjs +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +: +/ +/ +domain +. +org +/ +hideme +. +jpg +" +consistent +! +( +content_blocker_11 +" +http +: +/ +/ +domain +. +org +/ +hideme +. +jpg +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +: +/ +/ +domain +. +org +/ +ok +. +html +" +consistent +! +( +content_blocker_12 +" +http +: +/ +/ +domain +. +org +/ +ok +. +html +" +) +; +/ +/ +content +- +blocker +- +0 +. +2 +. +3 +: +" +http +: +/ +/ +domain +. +org +/ +ok +. +html +\ +\ +? +except_this += +1 +" +consistent +! +( +content_blocker_13 +" +http +: +/ +/ +domain +. +org +/ +ok +. +html +\ +\ +? +except_this += +1 +" +) +; +/ +/ +victoria +- +dom +- +0 +. +1 +. +2 +: +" +[ +A +- +Za +- +z0 +- +9 += +] +" +consistent +! +( +victoria_dom_0 +" +[ +A +- +Za +- +z0 +- +9 += +] +" +) +; +/ +/ +numbat +- +1 +. +0 +. +0 +: +r +" +^ +nsq +: +/ +/ +" +consistent +! +( +numbat_0 +r +" +^ +nsq +: +/ +/ +" +) +; +/ +/ +airkorea +- +0 +. +1 +. +2 +: +r +" +[ +\ +s +\ +t +\ +r +\ +n +] +" +consistent +! +( +airkorea_0 +r +" +[ +\ +s +\ +t +\ +r +\ +n +] +" +) +; +/ +/ +airkorea +- +0 +. +1 +. +2 +: +r +" +( +[ +\ +{ +\ +[ +] +) +| +( +[ +\ +} +\ +] +] +) +" +consistent +! +( +airkorea_1 +r +" +( +[ +\ +{ +\ +[ +] +) +| +( +[ +\ +} +\ +] +] +) +" +) +; +/ +/ +airkorea +- +0 +. +1 +. +2 +: +r +" +[ +^ +. +\ +d +] ++ +" +consistent +! +( +airkorea_2 +r +" +[ +^ +. +\ +d +] ++ +" +) +; +/ +/ +rofl +- +0 +. +0 +. +1 +: +r +" +\ +b +" +/ +/ +consistent +! +( +rofl_0 +r +" +\ +b +" +) +; +/ +/ +rogcat +- +0 +. +2 +. +15 +: +r +" +- +- +- +- +- +- +- +- +- +beginning +of +. +* +" +consistent +! +( +rogcat_0 +r +" +- +- +- +- +- +- +- +- +- +beginning +of +. +* +" +) +; +/ +/ +rogcat +- +0 +. +2 +. +15 +: +r +" +a +| +e +| +i +| +o +| +u +" +consistent +! +( +rogcat_1 +r +" +a +| +e +| +i +| +o +| +u +" +) +; +/ +/ +rogcat +- +0 +. +2 +. +15 +: +r +" +^ +( +\ +d ++ +) +( +[ +kMG +] +) +" +consistent +! +( +rogcat_2 +r +" +^ +( +\ +d ++ +) +( +[ +kMG +] +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +\ +\ +. +( +[ +A +- +Za +- +z0 +- +9 +] +{ +2 +4 +} +) +" +consistent +! +( +media_filename_0 +" +\ +\ +. +( +[ +A +- +Za +- +z0 +- +9 +] +{ +2 +4 +} +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +( +[ +0 +- +9 +] +{ +3 +4 +} +p +| +[ +0 +- +9 +] +{ +3 +4 +} +x +[ +0 +- +9 +] +{ +3 +4 +} +) +" +consistent +! +( +media_filename_1 +" +( +[ +0 +- +9 +] +{ +3 +4 +} +p +| +[ +0 +- +9 +] +{ +3 +4 +} +x +[ +0 +- +9 +] +{ +3 +4 +} +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +( +? +: +^ +\ +\ +[ +( +[ +^ +] +] ++ +) +\ +\ +] +| +- +? +( +[ +^ +- +] ++ +) +) +" +consistent +! +( +media_filename_2 +" +( +? +: +^ +\ +\ +[ +( +[ +^ +] +] ++ +) +\ +\ +] +| +- +? +( +[ +^ +- +] ++ +) +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +( +? +: +[ +eE +] +( +[ +0 +- +9 +] +{ +2 +3 +} +) +| +[ +^ +0 +- +9A +- +Za +- +z +] +( +[ +0 +- +9 +] +{ +2 +3 +} +) +( +? +: +v +[ +0 +- +9 +] +) +? +[ +^ +0 +- +9A +- +Za +- +z +] +) +" +consistent +! +( +media_filename_3 +" +( +? +: +[ +eE +] +( +[ +0 +- +9 +] +{ +2 +3 +} +) +| +[ +^ +0 +- +9A +- +Za +- +z +] +( +[ +0 +- +9 +] +{ +2 +3 +} +) +( +? +: +v +[ +0 +- +9 +] +) +? +[ +^ +0 +- +9A +- +Za +- +z +] +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +[ +sS +] +( +[ +0 +- +9 +] +{ +1 +2 +} +) +" +consistent +! +( +media_filename_4 +" +[ +sS +] +( +[ +0 +- +9 +] +{ +1 +2 +} +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +( +( +? +i +) +( +? +: +PPV +. +) +? +[ +HP +] +DTV +| +( +? +: +HD +) +? +CAM +| +BRRIP +| +[ +^ +a +- +z +] +TS +[ +^ +a +- +z +] +| +( +? +: +PPV +) +? +WEB +. +? +DL +( +? +: +DVDRip +) +? +| +HDRip +| +DVDRip +| +CamRip +| +W +[ +EB +] +BRip +| +BluRay +| +BD +| +DVD +| +DvDScr +| +hdtv +) +" +consistent +! +( +media_filename_5 +" +( +( +? +i +) +( +? +: +PPV +. +) +? +[ +HP +] +DTV +| +( +? +: +HD +) +? +CAM +| +BRRIP +| +[ +^ +a +- +z +] +TS +[ +^ +a +- +z +] +| +( +? +: +PPV +) +? +WEB +. +? +DL +( +? +: +DVDRip +) +? +| +HDRip +| +DVDRip +| +CamRip +| +W +[ +EB +] +BRip +| +BluRay +| +BD +| +DVD +| +DvDScr +| +hdtv +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +( +( +19 +[ +0 +- +9 +] +| +20 +[ +01 +] +) +[ +0 +- +9 +] +) +" +consistent +! +( +media_filename_6 +" +( +( +19 +[ +0 +- +9 +] +| +20 +[ +01 +] +) +[ +0 +- +9 +] +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +( +( +? +i +) +xvid +| +x264 +| +h +\ +\ +. +? +264 +) +" +consistent +! +( +media_filename_7 +" +( +( +? +i +) +xvid +| +x264 +| +h +\ +\ +. +? +264 +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +( +( +? +i +) +MP3 +| +DD5 +\ +\ +. +? +1 +| +Dual +[ +- +] +Audio +| +LiNE +| +DTS +| +AAC +( +? +: +\ +\ +. +? +2 +\ +\ +. +0 +) +? +| +AC3 +( +? +: +\ +\ +. +5 +\ +\ +. +1 +) +? +) +" +consistent +! +( +media_filename_8 +" +( +( +? +i +) +MP3 +| +DD5 +\ +\ +. +? +1 +| +Dual +[ +- +] +Audio +| +LiNE +| +DTS +| +AAC +( +? +: +\ +\ +. +? +2 +\ +\ +. +0 +) +? +| +AC3 +( +? +: +\ +\ +. +5 +\ +\ +. +1 +) +? +) +" +) +; +/ +/ +media_filename +- +0 +. +1 +. +4 +: +" +\ +\ +[ +( +[ +0 +- +9A +- +F +] +{ +8 +} +) +\ +\ +] +" +consistent +! +( +media_filename_9 +" +\ +\ +[ +( +[ +0 +- +9A +- +F +] +{ +8 +} +) +\ +\ +] +" +) +; +/ +/ +termimage +- +0 +. +3 +. +2 +: +r +" +( +\ +d ++ +) +[ +xX +] +( +\ +d ++ +) +" +consistent +! +( +termimage_0 +r +" +( +\ +d ++ +) +[ +xX +] +( +\ +d ++ +) +" +) +; +/ +/ +teensy +- +0 +. +1 +. +0 +: +r +" +. +* +( +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +) +. +* +" +consistent +! +( +teensy_0 +r +" +. +* +( +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +) +. +* +" +) +; +/ +/ +telescreen +- +0 +. +1 +. +3 +: +r +" +< +( +. ++ +) +> +" +consistent +! +( +telescreen_0 +r +" +< +( +. ++ +) +> +" +) +; +/ +/ +tempus_fugit +- +0 +. +4 +. +4 +: +r +" +^ +( +\ +d ++ +) +" +consistent +! +( +tempus_fugit_0 +r +" +^ +( +\ +d ++ +) +" +) +; +/ +/ +fselect +- +0 +. +4 +. +1 +: +" +( +\ +\ +? +| +\ +\ +. +| +\ +\ +* +| +\ +\ +[ +| +\ +\ +] +| +\ +\ +( +| +\ +\ +) +| +\ +\ +^ +| +\ +\ +) +" +consistent +! +( +fselect_0 +" +( +\ +\ +? +| +\ +\ +. +| +\ +\ +* +| +\ +\ +[ +| +\ +\ +] +| +\ +\ +( +| +\ +\ +) +| +\ +\ +^ +| +\ +\ +) +" +) +; +/ +/ +fselect +- +0 +. +4 +. +1 +: +" +( +% +| +_ +| +\ +\ +? +| +\ +\ +. +| +\ +\ +* +| +\ +\ +[ +| +\ +\ +] +| +\ +\ +( +| +\ +\ +) +| +\ +\ +^ +| +\ +\ +) +" +consistent +! +( +fselect_1 +" +( +% +| +_ +| +\ +\ +? +| +\ +\ +. +| +\ +\ +* +| +\ +\ +[ +| +\ +\ +] +| +\ +\ +( +| +\ +\ +) +| +\ +\ +^ +| +\ +\ +) +" +) +; +/ +/ +fs_eventbridge +- +0 +. +1 +. +0 +: +r +" +^ +( +[ +A +- +Z +] ++ +) +( +? +: +\ +s +( +. ++ +) +) +? +\ +s +* +" +consistent +! +( +fs_eventbridge_0 +r +" +^ +( +[ +A +- +Z +] ++ +) +( +? +: +\ +s +( +. ++ +) +) +? +\ +s +* +" +) +; +/ +/ +joseki +- +0 +. +0 +. +1 +: +r +" +( +\ +w +{ +1 +2 +} +) +\ +[ +( +. ++ +? +) +\ +] +" +consistent +! +( +joseki_0 +r +" +( +\ +w +{ +1 +2 +} +) +\ +[ +( +. ++ +? +) +\ +] +" +) +; +/ +/ +tweetr +- +0 +. +2 +. +1 +: +r +" +( +? +i +) +in +( +\ +d ++ +) +( +second +| +minute +| +hour +| +day +| +week +) +s +? +" +consistent +! +( +tweetr_0 +r +" +( +? +i +) +in +( +\ +d ++ +) +( +second +| +minute +| +hour +| +day +| +week +) +s +? +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +[ +0 +- +9 +] +) ++ +" +consistent +! +( +bullet_core_0 +" +^ +( +? +u +: +[ +0 +- +9 +] +) ++ +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +[ +0 +- +9 +] +) ++ +( +? +u +: +\ +\ +. +) +( +? +u +: +[ +0 +- +9 +] +) ++ +" +consistent +! +( +bullet_core_1 +" +^ +( +? +u +: +[ +0 +- +9 +] +) ++ +( +? +u +: +\ +\ +. +) +( +? +u +: +[ +0 +- +9 +] +) ++ +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +[ +A +- +Za +- +z +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +] +) ++ +" +consistent +! +( +bullet_core_2 +" +^ +( +? +u +: +[ +A +- +Za +- +z +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +] +) ++ +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +d +/ +d +) +( +( +? +u +: +[ +A +- +Za +- +z +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +] +) ++ +) +" +consistent +! +( +bullet_core_3 +" +^ +( +? +u +: +d +/ +d +) +( +( +? +u +: +[ +A +- +Za +- +z +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +- +] +) ++ +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +( +) +" +consistent +! +( +bullet_core_4 +" +^ +( +? +u +: +\ +\ +( +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +) +) +" +consistent +! +( +bullet_core_5 +" +^ +( +? +u +: +\ +\ +) +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +* +) +" +consistent +! +( +bullet_core_6 +" +^ +( +? +u +: +\ +\ +* +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ ++ +) +" +consistent +! +( +bullet_core_7 +" +^ +( +? +u +: +\ +\ ++ +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +) +" +consistent +! +( +bullet_core_8 +" +^ +( +? +u +: +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +- +) +" +consistent +! +( +bullet_core_9 +" +^ +( +? +u +: +\ +\ +- +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +/ +) +" +consistent +! +( +bullet_core_10 +" +^ +( +? +u +: +/ +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +[ +) +" +consistent +! +( +bullet_core_11 +" +^ +( +? +u +: +\ +\ +[ +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +] +) +" +consistent +! +( +bullet_core_12 +" +^ +( +? +u +: +\ +\ +] +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +\ +\ +^ +) +" +consistent +! +( +bullet_core_13 +" +^ +( +? +u +: +\ +\ +^ +) +" +) +; +/ +/ +bullet_core +- +0 +. +1 +. +1 +: +" +^ +( +? +u +: +) +" +consistent +! +( +bullet_core_14 +" +^ +( +? +u +: +) +" +) +; +/ +/ +actix +- +web +- +0 +. +6 +. +13 +: +" +/ +/ ++ +" +consistent +! +( +actix_web_0 +" +/ +/ ++ +" +) +; +/ +/ +actix +- +web +- +0 +. +6 +. +13 +: +" +/ +/ ++ +" +consistent +! +( +actix_web_1 +" +/ +/ ++ +" +) +; +/ +/ +althea_kernel_interface +- +0 +. +1 +. +0 +: +r +" +( +\ +S +* +) +. +* +( +\ +S +* +) +( +REACHABLE +| +STALE +| +DELAY +) +" +consistent +! +( +althea_kernel_interface_0 +r +" +( +\ +S +* +) +. +* +( +\ +S +* +) +( +REACHABLE +| +STALE +| +DELAY +) +" +) +; +/ +/ +althea_kernel_interface +- +0 +. +1 +. +0 +: +r +" +- +s +( +. +* +) +- +- +ip6 +- +dst +( +. +* +) +/ +. +* +bcnt += +( +. +* +) +" +consistent +! +( +althea_kernel_interface_1 +r +" +- +s +( +. +* +) +- +- +ip6 +- +dst +( +. +* +) +/ +. +* +bcnt += +( +. +* +) +" +) +; +/ +/ +alcibiades +- +0 +. +3 +. +0 +: +r +" +\ +buci +( +? +: +\ +s +| +) +" +consistent +! +( +alcibiades_0 +r +" +\ +buci +( +? +: +\ +s +| +) +" +) +; +/ +/ +ruma +- +identifiers +- +0 +. +11 +. +0 +: +r +" +\ +A +[ +a +- +z0 +- +9 +. +_ += +- +] ++ +\ +z +" +consistent +! +( +ruma_identifiers_0 +r +" +\ +A +[ +a +- +z0 +- +9 +. +_ += +- +] ++ +\ +z +" +) +; +/ +/ +rusqbin +- +0 +. +2 +. +3 +: +r +" +/ +rusqbins +/ +( +( +? +i +) +[ +A +- +F0 +- +9 +] +{ +8 +} +\ +- +[ +A +- +F0 +- +9 +] +{ +4 +} +\ +- +4 +[ +A +- +F0 +- +9 +] +{ +3 +} +\ +- +[ +89AB +] +[ +A +- +F0 +- +9 +] +{ +3 +} +\ +- +[ +A +- +F0 +- +9 +] +{ +12 +} +) +" +consistent +! +( +rusqbin_0 +r +" +/ +rusqbins +/ +( +( +? +i +) +[ +A +- +F0 +- +9 +] +{ +8 +} +\ +- +[ +A +- +F0 +- +9 +] +{ +4 +} +\ +- +4 +[ +A +- +F0 +- +9 +] +{ +3 +} +\ +- +[ +89AB +] +[ +A +- +F0 +- +9 +] +{ +3 +} +\ +- +[ +A +- +F0 +- +9 +] +{ +12 +} +) +" +) +; +/ +/ +rusqbin +- +0 +. +2 +. +3 +: +r +" +/ +rusqbins +/ +( +( +? +i +) +[ +A +- +F0 +- +9 +] +{ +8 +} +\ +- +[ +A +- +F0 +- +9 +] +{ +4 +} +\ +- +4 +[ +A +- +F0 +- +9 +] +{ +3 +} +\ +- +[ +89AB +] +[ +A +- +F0 +- +9 +] +{ +3 +} +\ +- +[ +A +- +F0 +- +9 +] +{ +12 +} +) +/ +requests +/ +? +" +consistent +! +( +rusqbin_1 +r +" +/ +rusqbins +/ +( +( +? +i +) +[ +A +- +F0 +- +9 +] +{ +8 +} +\ +- +[ +A +- +F0 +- +9 +] +{ +4 +} +\ +- +4 +[ +A +- +F0 +- +9 +] +{ +3 +} +\ +- +[ +89AB +] +[ +A +- +F0 +- +9 +] +{ +3 +} +\ +- +[ +A +- +F0 +- +9 +] +{ +12 +} +) +/ +requests +/ +? +" +) +; +/ +/ +rust +- +install +- +0 +. +0 +. +4 +: +r +" +^ +( +nightly +| +beta +| +stable +) +( +? +: +- +( +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +) +) +? +" +consistent +! +( +rust_install_0 +r +" +^ +( +nightly +| +beta +| +stable +) +( +? +: +- +( +\ +d +{ +4 +} +- +\ +d +{ +2 +} +- +\ +d +{ +2 +} +) +) +? +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +" +^ ++ +( +. +* +) +\ +r +\ +n +" +consistent +! +( +rust_inbox_0 +" +^ ++ +( +. +* +) +\ +r +\ +n +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +\ +* +CAPABILITY +( +. +* +) +\ +r +\ +n +" +consistent +! +( +rust_inbox_1 +r +" +^ +\ +* +CAPABILITY +( +. +* +) +\ +r +\ +n +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +( +[ +a +- +zA +- +Z0 +- +9 +] ++ +) +( +OK +| +NO +| +BAD +) +( +. +* +) +" +consistent +! +( +rust_inbox_2 +r +" +^ +( +[ +a +- +zA +- +Z0 +- +9 +] ++ +) +( +OK +| +NO +| +BAD +) +( +. +* +) +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +\ +* +( +\ +d ++ +) +EXISTS +\ +r +\ +n +" +consistent +! +( +rust_inbox_3 +r +" +^ +\ +* +( +\ +d ++ +) +EXISTS +\ +r +\ +n +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +\ +* +( +\ +d ++ +) +RECENT +\ +r +\ +n +" +consistent +! +( +rust_inbox_4 +r +" +^ +\ +* +( +\ +d ++ +) +RECENT +\ +r +\ +n +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +\ +* +FLAGS +( +. ++ +) +\ +r +\ +n +" +consistent +! +( +rust_inbox_5 +r +" +^ +\ +* +FLAGS +( +. ++ +) +\ +r +\ +n +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +\ +* +OK +\ +[ +UNSEEN +( +\ +d ++ +) +\ +] +( +. +* +) +\ +r +\ +n +" +consistent +! +( +rust_inbox_6 +r +" +^ +\ +* +OK +\ +[ +UNSEEN +( +\ +d ++ +) +\ +] +( +. +* +) +\ +r +\ +n +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +\ +* +OK +\ +[ +UIDVALIDITY +( +\ +d ++ +) +\ +] +( +. +* +) +\ +r +\ +n +" +consistent +! +( +rust_inbox_7 +r +" +^ +\ +* +OK +\ +[ +UIDVALIDITY +( +\ +d ++ +) +\ +] +( +. +* +) +\ +r +\ +n +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +\ +* +OK +\ +[ +UIDNEXT +( +\ +d ++ +) +\ +] +( +. +* +) +\ +r +\ +n +" +consistent +! +( +rust_inbox_8 +r +" +^ +\ +* +OK +\ +[ +UIDNEXT +( +\ +d ++ +) +\ +] +( +. +* +) +\ +r +\ +n +" +) +; +/ +/ +rust_inbox +- +0 +. +0 +. +5 +: +r +" +^ +\ +* +OK +\ +[ +PERMANENTFLAGS +( +. ++ +) +\ +] +( +. +* +) +\ +r +\ +n +" +consistent +! +( +rust_inbox_9 +r +" +^ +\ +* +OK +\ +[ +PERMANENTFLAGS +( +. ++ +) +\ +] +( +. +* +) +\ +r +\ +n +" +) +; +/ +/ +rustml +- +0 +. +0 +. +7 +: +r +" +^ +[ +a +- +z +] ++ +( +\ +d ++ +) +" +consistent +! +( +rustml_0 +r +" +^ +[ +a +- +z +] ++ +( +\ +d ++ +) +" +) +; +/ +/ +rustml +- +0 +. +0 +. +7 +: +r +" +^ +[ +a +- +z +] ++ +( +\ +d ++ +) +" +consistent +! +( +rustml_1 +r +" +^ +[ +a +- +z +] ++ +( +\ +d ++ +) +" +) +; +/ +/ +rustml +- +0 +. +0 +. +7 +: +r +" +^ +[ +a +- +z +] ++ +( +\ +d ++ +) +" +consistent +! +( +rustml_2 +r +" +^ +[ +a +- +z +] ++ +( +\ +d ++ +) +" +) +; +/ +/ +rustfmt +- +0 +. +10 +. +0 +: +r +" +( +[ +^ +\ +\ +] +( +\ +\ +\ +\ +) +* +) +\ +\ +[ +\ +n +\ +r +] +[ +[ +: +space +: +] +] +* +" +consistent +! +( +rustfmt_0 +r +" +( +[ +^ +\ +\ +] +( +\ +\ +\ +\ +) +* +) +\ +\ +[ +\ +n +\ +r +] +[ +[ +: +space +: +] +] +* +" +) +; +/ +/ +rustfmt +- +core +- +0 +. +4 +. +0 +: +r +" +( +^ +\ +s +* +) +| +( +^ +\ +s +* +/ +/ +\ +s +* +rustfmt +- +[ +^ +: +] ++ +: +\ +s +* +\ +S ++ +) +" +consistent +! +( +rustfmt_core_0 +r +" +( +^ +\ +s +* +) +| +( +^ +\ +s +* +/ +/ +\ +s +* +rustfmt +- +[ +^ +: +] ++ +: +\ +s +* +\ +S ++ +) +" +) +; +/ +/ +rustfmt +- +core +- +0 +. +4 +. +0 +: +r +" +^ +# +# +( +[ +^ +] ++ +) +" +consistent +! +( +rustfmt_core_1 +r +" +^ +# +# +( +[ +^ +] ++ +) +" +) +; +/ +/ +rustfmt +- +core +- +0 +. +4 +. +0 +: +r +" +( +[ +^ +\ +\ +] +( +\ +\ +\ +\ +) +* +) +\ +\ +[ +\ +n +\ +r +] +[ +[ +: +space +: +] +] +* +" +consistent +! +( +rustfmt_core_2 +r +" +( +[ +^ +\ +\ +] +( +\ +\ +\ +\ +) +* +) +\ +\ +[ +\ +n +\ +r +] +[ +[ +: +space +: +] +] +* +" +) +; +/ +/ +rustfmt +- +core +- +0 +. +4 +. +0 +: +r +" +\ +s +; +" +consistent +! +( +rustfmt_core_3 +r +" +\ +s +; +" +) +; +/ +/ +rust +- +enum +- +derive +- +0 +. +4 +. +0 +: +r +" +^ +( +0x +) +? +( +[ +: +digit +: +] ++ +) +" +consistent +! +( +rust_enum_derive_0 +r +" +^ +( +0x +) +? +( +[ +: +digit +: +] ++ +) +" +) +; +/ +/ +rust +- +enum +- +derive +- +0 +. +4 +. +0 +: +r +" +^ +( +[ +: +digit +: +] ++ +) +[ +: +space +: +] +* +< +< +[ +: +space +: +] +* +( +[ +: +digit +: +] ++ +) +" +consistent +! +( +rust_enum_derive_1 +r +" +^ +( +[ +: +digit +: +] ++ +) +[ +: +space +: +] +* +< +< +[ +: +space +: +] +* +( +[ +: +digit +: +] ++ +) +" +) +; +/ +/ +rust +- +enum +- +derive +- +0 +. +4 +. +0 +: +r +" +^ +[ +: +space +: +] +* +( +[ +[ +: +alnum +: +] +_ +] ++ +) +( +[ +: +space +: +] +* += +[ +: +space +: +] +* +( +[ +: +graph +: +] ++ +) +) +? +[ +: +space +: +] +* +" +consistent +! +( +rust_enum_derive_2 +r +" +^ +[ +: +space +: +] +* +( +[ +[ +: +alnum +: +] +_ +] ++ +) +( +[ +: +space +: +] +* += +[ +: +space +: +] +* +( +[ +: +graph +: +] ++ +) +) +? +[ +: +space +: +] +* +" +) +; +/ +/ +rust +- +enum +- +derive +- +0 +. +4 +. +0 +: +r +" +^ +# +define +[ +: +space +: +] ++ +( +[ +: +graph +: +] ++ +) +[ +: +space +: +] ++ +( +[ +: +graph +: +] ++ +) +" +consistent +! +( +rust_enum_derive_3 +r +" +^ +# +define +[ +: +space +: +] ++ +( +[ +: +graph +: +] ++ +) +[ +: +space +: +] ++ +( +[ +: +graph +: +] ++ +) +" +) +; +/ +/ +rustsourcebundler +- +0 +. +2 +. +0 +: +r +" +^ +\ +s +* +pub +mod +( +. ++ +) +; +" +consistent +! +( +rustsourcebundler_0 +r +" +^ +\ +s +* +pub +mod +( +. ++ +) +; +" +) +; +/ +/ +rustsourcebundler +- +0 +. +2 +. +0 +: +r +" +^ +\ +s +* +pub +mod +( +. ++ +) +; +" +consistent +! +( +rustsourcebundler_1 +r +" +^ +\ +s +* +pub +mod +( +. ++ +) +; +" +) +; +/ +/ +rustfmt +- +nightly +- +0 +. +8 +. +2 +: +r +" +( +[ +^ +\ +\ +] +( +\ +\ +\ +\ +) +* +) +\ +\ +[ +\ +n +\ +r +] +[ +[ +: +space +: +] +] +* +" +consistent +! +( +rustfmt_nightly_0 +r +" +( +[ +^ +\ +\ +] +( +\ +\ +\ +\ +) +* +) +\ +\ +[ +\ +n +\ +r +] +[ +[ +: +space +: +] +] +* +" +) +; +/ +/ +rustfmt +- +nightly +- +0 +. +8 +. +2 +: +r +" +\ +s +; +" +consistent +! +( +rustfmt_nightly_1 +r +" +\ +s +; +" +) +; +/ +/ +rustache +- +0 +. +1 +. +0 +: +r +" +( +? +s +) +( +. +* +? +) +( +[ +\ +t +\ +r +\ +n +] +* +) +( +\ +{ +\ +{ +( +\ +{ +? +\ +S +? +\ +s +* +? +[ +\ +w +\ +. +\ +s +] +* +. +* +? +\ +s +* +? +\ +} +? +) +\ +} +\ +} +) +( +[ +\ +t +\ +r +\ +n +] +* +) +" +consistent +! +( +rustache_0 +r +" +( +? +s +) +( +. +* +? +) +( +[ +\ +t +\ +r +\ +n +] +* +) +( +\ +{ +\ +{ +( +\ +{ +? +\ +S +? +\ +s +* +? +[ +\ +w +\ +. +\ +s +] +* +. +* +? +\ +s +* +? +\ +} +? +) +\ +} +\ +} +) +( +[ +\ +t +\ +r +\ +n +] +* +) +" +) +; +/ +/ +rustfilt +- +0 +. +2 +. +0 +: +r +" +_ZN +[ +\ +\ +. +_ +[ +: +alnum +: +] +] +* +" +consistent +! +( +rustfilt_0 +r +" +_ZN +[ +\ +\ +. +_ +[ +: +alnum +: +] +] +* +" +) +; +/ +/ +rustache +- +lists +- +0 +. +1 +. +2 +: +r +" +( +? +s +) +( +. +* +? +) +( +[ +\ +t +\ +r +\ +n +] +* +) +( +\ +{ +\ +{ +( +\ +{ +? +\ +S +? +\ +s +* +? +[ +\ +w +\ +. +\ +s +] +* +. +* +? +\ +s +* +? +\ +} +? +) +\ +} +\ +} +) +( +[ +\ +t +\ +r +\ +n +] +* +) +" +consistent +! +( +rustache_lists_0 +r +" +( +? +s +) +( +. +* +? +) +( +[ +\ +t +\ +r +\ +n +] +* +) +( +\ +{ +\ +{ +( +\ +{ +? +\ +S +? +\ +s +* +? +[ +\ +w +\ +. +\ +s +] +* +. +* +? +\ +s +* +? +\ +} +? +) +\ +} +\ +} +) +( +[ +\ +t +\ +r +\ +n +] +* +) +" +) +; +/ +/ +rural +- +0 +. +7 +. +3 +: +" +( +. ++ +) += +( +. ++ +) +" +consistent +! +( +rural_0 +" +( +. ++ +) += +( +. ++ +) +" +) +; +/ +/ +rural +- +0 +. +7 +. +3 +: +" +( +. +* +) +: +( +. ++ +) +" +consistent +! +( +rural_1 +" +( +. +* +) +: +( +. ++ +) +" +) +; +/ +/ +rural +- +0 +. +7 +. +3 +: +" +( +. ++ +) +: += +( +. ++ +) +" +consistent +! +( +rural_2 +" +( +. ++ +) +: += +( +. ++ +) +" +) +; +/ +/ +rural +- +0 +. +7 +. +3 +: +" +( +. +* +) += += +( +. ++ +) +" +consistent +! +( +rural_3 +" +( +. +* +) += += +( +. ++ +) +" +) +; +/ +/ +rusoto_credential +- +0 +. +11 +. +0 +: +r +" +^ +\ +[ +( +[ +^ +\ +] +] ++ +) +\ +] +" +consistent +! +( +rusoto_credential_0 +r +" +^ +\ +[ +( +[ +^ +\ +] +] ++ +) +\ +] +" +) +; +/ +/ +rumblebars +- +0 +. +3 +. +0 +: +" +( +[ +: +blank +: +] +* +) +" +consistent +! +( +rumblebars_0 +" +( +[ +: +blank +: +] +* +) +" +) +; +/ +/ +rumblebars +- +0 +. +3 +. +0 +: +" +( +\ +r +? +\ +n +) +[ +: +blank +: +] +* +( +\ +\ +{ +\ +\ +{ +~ +? +[ +# +! +/ +] +( +? +: +\ +\ +} +? +[ +^ +} +] +) +* +\ +\ +} +\ +\ +} +) +[ +: +blank +: +] +* +( +: +? +\ +r +? +\ +n +) +? +\ +\ +z +" +consistent +! +( +rumblebars_1 +" +( +\ +r +? +\ +n +) +[ +: +blank +: +] +* +( +\ +\ +{ +\ +\ +{ +~ +? +[ +# +! +/ +] +( +? +: +\ +\ +} +? +[ +^ +} +] +) +* +\ +\ +} +\ +\ +} +) +[ +: +blank +: +] +* +( +: +? +\ +r +? +\ +n +) +? +\ +\ +z +" +) +; +/ +/ +rumblebars +- +0 +. +3 +. +0 +: +" +( +\ +r +? +\ +n +[ +: +blank +: +] +* +) +( +\ +\ +{ +\ +\ +{ +~ +? +> +( +? +: +\ +\ +} +? +[ +^ +} +] +) +* +\ +\ +} +\ +\ +} +) +[ +: +blank +: +] +* +( +: +? +\ +r +? +\ +n +) +? +\ +\ +z +" +consistent +! +( +rumblebars_2 +" +( +\ +r +? +\ +n +[ +: +blank +: +] +* +) +( +\ +\ +{ +\ +\ +{ +~ +? +> +( +? +: +\ +\ +} +? +[ +^ +} +] +) +* +\ +\ +} +\ +\ +} +) +[ +: +blank +: +] +* +( +: +? +\ +r +? +\ +n +) +? +\ +\ +z +" +) +; +/ +/ +rumblebars +- +0 +. +3 +. +0 +: +" +( +( +? +: +[ +: +blank +: +] +| +\ +r +? +\ +n +) +* +) +( +\ +r +? +\ +n +) +[ +: +blank +: +] +* +" +consistent +! +( +rumblebars_3 +" +( +( +? +: +[ +: +blank +: +] +| +\ +r +? +\ +n +) +* +) +( +\ +r +? +\ +n +) +[ +: +blank +: +] +* +" +) +; +/ +/ +rumblebars +- +0 +. +3 +. +0 +: +" +^ +( +[ +: +blank +: +] +* +\ +r +? +\ +n +) +( +. +* +) +" +consistent +! +( +rumblebars_4 +" +^ +( +[ +: +blank +: +] +* +\ +r +? +\ +n +) +( +. +* +) +" +) +; +/ +/ +diesel_cli +- +1 +. +3 +. +1 +: +r +" +( +? +P +< +stamp +> +[ +\ +d +- +] +* +) +_hello +" +consistent +! +( +diesel_cli_0 +r +" +( +? +P +< +stamp +> +[ +\ +d +- +] +* +) +_hello +" +) +; +/ +/ +dishub +- +0 +. +1 +. +1 +: +r +" +( +\ +d ++ +) +s +" +consistent +! +( +dishub_0 +r +" +( +\ +d ++ +) +s +" +) +; +/ +/ +spreadsheet_textconv +- +0 +. +1 +. +0 +: +r +" +\ +n +" +consistent +! +( +spreadsheet_textconv_0 +r +" +\ +n +" +) +; +/ +/ +spreadsheet_textconv +- +0 +. +1 +. +0 +: +r +" +\ +r +" +consistent +! +( +spreadsheet_textconv_1 +r +" +\ +r +" +) +; +/ +/ +spreadsheet_textconv +- +0 +. +1 +. +0 +: +r +" +\ +t +" +consistent +! +( +spreadsheet_textconv_2 +r +" +\ +t +" +) +; +/ +/ +split_aud +- +0 +. +1 +. +0 +: +r +" +DELAY +( +- +? +\ +d ++ +) +ms +" +consistent +! +( +split_aud_0 +r +" +DELAY +( +- +? +\ +d ++ +) +ms +" +) +; +/ +/ +split_aud +- +0 +. +1 +. +0 +: +r +" +Trim +\ +( +( +\ +d ++ +) +? +( +\ +d ++ +) +\ +) +" +consistent +! +( +split_aud_1 +r +" +Trim +\ +( +( +\ +d ++ +) +? +( +\ +d ++ +) +\ +) +" +) +; +/ +/ +spotrust +- +0 +. +0 +. +5 +: +r +" +spotify +: +[ +a +- +z +] ++ +: +[ +a +- +zA +- +Z0 +- +9 +] ++ +" +consistent +! +( +spotrust_0 +r +" +spotify +: +[ +a +- +z +] ++ +: +[ +a +- +zA +- +Z0 +- +9 +] ++ +" +) +; +/ +/ +spaceslugs +- +0 +. +1 +. +0 +: +r +" +[ +^ +\ +x00 +- +\ +x7F +] +" +consistent +! +( +spaceslugs_0 +r +" +[ +^ +\ +x00 +- +\ +x7F +] +" +) +; +/ +/ +spaceslugs +- +0 +. +1 +. +0 +: +r +" +[ +' +] ++ +" +consistent +! +( +spaceslugs_1 +r +" +[ +' +] ++ +" +) +; +/ +/ +spaceslugs +- +0 +. +1 +. +0 +: +r +" +\ +W ++ +" +consistent +! +( +spaceslugs_2 +r +" +\ +W ++ +" +) +; +/ +/ +spaceslugs +- +0 +. +1 +. +0 +: +r +" +[ +] ++ +" +consistent +! +( +spaceslugs_3 +r +" +[ +] ++ +" +) +; +/ +/ +space_email_api +- +0 +. +1 +. +1 +: +" +PHPSESSID += +( +[ +0 +- +9a +- +f +] ++ +) +" +consistent +! +( +space_email_api_0 +" +PHPSESSID += +( +[ +0 +- +9a +- +f +] ++ +) +" +) +; +/ +/ +lorikeet +- +0 +. +7 +. +0 +: +" +[ +^ +0 +- +9 +. +] +" +consistent +! +( +lorikeet_0 +" +[ +^ +0 +- +9 +. +] +" +) +; +/ +/ +claude +- +0 +. +3 +. +0 +: +r +" +^ +( +? +: +\ +b +| +( +- +) +? +) +( +\ +p +{ +Currency_Symbol +} +) +? +( +( +? +: +( +? +: +\ +d +{ +1 +3 +} +[ +\ +. +] +) ++ +\ +d +{ +3 +} +) +| +\ +d ++ +) +( +? +: +[ +\ +. +] +( +\ +d +{ +2 +} +) +) +? +\ +b +" +consistent +! +( +claude_0 +r +" +^ +( +? +: +\ +b +| +( +- +) +? +) +( +\ +p +{ +Currency_Symbol +} +) +? +( +( +? +: +( +? +: +\ +d +{ +1 +3 +} +[ +\ +. +] +) ++ +\ +d +{ +3 +} +) +| +\ +d ++ +) +( +? +: +[ +\ +. +] +( +\ +d +{ +2 +} +) +) +? +\ +b +" +) +; +/ +/ +clam +- +0 +. +1 +. +6 +: +r +" +< +% += +\ +s +* +( +. ++ +? +) +\ +s +* +% +> +" +consistent +! +( +clam_0 +r +" +< +% += +\ +s +* +( +. ++ +? +) +\ +s +* +% +> +" +) +; +/ +/ +classifier +- +0 +. +0 +. +3 +: +r +" +( +\ +s +) +" +consistent +! +( +classifier_0 +r +" +( +\ +s +) +" +) +; +/ +/ +click +- +0 +. +3 +. +2 +: +r +" +( +- +- +- +- +- +BEGIN +. +* +- +- +- +- +- +\ +n +) +( +( +? +: +( +? +: +[ +A +- +Za +- +z0 +- +9 ++ +/ +] +{ +4 +} +) +* +( +? +: +[ +A +- +Za +- +z0 +- +9 ++ +/ +] +{ +2 +} += += +| +[ +A +- +Za +- +z0 +- +9 ++ +/ +] +{ +3 +} += +) +* +\ +n +) ++ +) +( +- +- +- +- +- +END +. +* +- +- +- +- +- +) +" +consistent +! +( +click_0 +r +" +( +- +- +- +- +- +BEGIN +. +* +- +- +- +- +- +\ +n +) +( +( +? +: +( +? +: +[ +A +- +Za +- +z0 +- +9 ++ +/ +] +{ +4 +} +) +* +( +? +: +[ +A +- +Za +- +z0 +- +9 ++ +/ +] +{ +2 +} += += +| +[ +A +- +Za +- +z0 +- +9 ++ +/ +] +{ +3 +} += +) +* +\ +n +) ++ +) +( +- +- +- +- +- +END +. +* +- +- +- +- +- +) +" +) +; +/ +/ +click +- +0 +. +3 +. +2 +: +r +" +- +- +- +- +- +BEGIN +PRIVATE +KEY +- +- +- +- +- +" +consistent +! +( +click_1 +r +" +- +- +- +- +- +BEGIN +PRIVATE +KEY +- +- +- +- +- +" +) +; +/ +/ +ultrastar +- +txt +- +0 +. +1 +. +2 +: +r +" +# +( +[ +A +- +Z3a +- +z +] +* +) +: +( +. +* +) +" +consistent +! +( +ultrastar_txt_0 +r +" +# +( +[ +A +- +Z3a +- +z +] +* +) +: +( +. +* +) +" +) +; +/ +/ +ultrastar +- +txt +- +0 +. +1 +. +2 +: +" +^ +- +\ +\ +s +? +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s +* +" +consistent +! +( +ultrastar_txt_1 +" +^ +- +\ +\ +s +? +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s +* +" +) +; +/ +/ +ultrastar +- +txt +- +0 +. +1 +. +2 +: +" +^ +- +\ +\ +s +? +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s ++ +( +- +? +[ +0 +- +9 +] ++ +) +" +consistent +! +( +ultrastar_txt_2 +" +^ +- +\ +\ +s +? +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s ++ +( +- +? +[ +0 +- +9 +] ++ +) +" +) +; +/ +/ +ultrastar +- +txt +- +0 +. +1 +. +2 +: +" +^ +( +. +) +\ +\ +s +* +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s ++ +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s ++ +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s +? +( +. +* +) +" +consistent +! +( +ultrastar_txt_3 +" +^ +( +. +) +\ +\ +s +* +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s ++ +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s ++ +( +- +? +[ +0 +- +9 +] ++ +) +\ +\ +s +? +( +. +* +) +" +) +; +/ +/ +ultrastar +- +txt +- +0 +. +1 +. +2 +: +" +^ +P +\ +\ +s +? +( +- +? +[ +0 +- +9 +] ++ +) +" +consistent +! +( +ultrastar_txt_4 +" +^ +P +\ +\ +s +? +( +- +? +[ +0 +- +9 +] ++ +) +" +) +; +/ +/ +db +- +accelerate +- +2 +. +0 +. +0 +: +r +" +^ +template +\ +. +add +( +| +\ +. +. ++ +) +" +consistent +! +( +db_accelerate_0 +r +" +^ +template +\ +. +add +( +| +\ +. +. ++ +) +" +) +; +/ +/ +db +- +accelerate +- +2 +. +0 +. +0 +: +r +" +^ +template +\ +. +sub +( +| +\ +. +. ++ +) +" +consistent +! +( +db_accelerate_1 +r +" +^ +template +\ +. +sub +( +| +\ +. +. ++ +) +" +) +; +/ +/ +sterling +- +0 +. +3 +. +0 +: +r +" +( +\ +d ++ +) +( +[ +cegps +] +) +" +consistent +! +( +sterling_0 +r +" +( +\ +d ++ +) +( +[ +cegps +] +) +" +) +; +/ +/ +stache +- +0 +. +2 +. +0 +: +r +" +[ +^ +\ +w +] +" +consistent +! +( +stache_0 +r +" +[ +^ +\ +w +] +" +) +; +/ +/ +strukt +- +0 +. +1 +. +0 +: +" +\ +" +( +[ +< +> +] +? +) +( +[ +xcbB +\ +\ +? +hHiIlLqQfdspP +] +* +) +\ +" +" +consistent +! +( +strukt_0 +" +\ +" +( +[ +< +> +] +? +) +( +[ +xcbB +\ +\ +? +hHiIlLqQfdspP +] +* +) +\ +" +" +) +; +/ +/ +steamid +- +ng +- +0 +. +3 +. +1 +: +r +" +^ +STEAM_ +( +[ +0 +- +4 +] +) +: +( +[ +0 +- +1 +] +) +: +( +[ +0 +- +9 +] +{ +1 +10 +} +) +" +consistent +! +( +steamid_ng_0 +r +" +^ +STEAM_ +( +[ +0 +- +4 +] +) +: +( +[ +0 +- +1 +] +) +: +( +[ +0 +- +9 +] +{ +1 +10 +} +) +" +) +; +/ +/ +steamid +- +ng +- +0 +. +3 +. +1 +: +r +" +^ +\ +[ +( +[ +AGMPCgcLTIUai +] +) +: +( +[ +0 +- +4 +] +) +: +( +[ +0 +- +9 +] +{ +1 +10 +} +) +( +: +( +[ +0 +- +9 +] ++ +) +) +? +\ +] +" +consistent +! +( +steamid_ng_1 +r +" +^ +\ +[ +( +[ +AGMPCgcLTIUai +] +) +: +( +[ +0 +- +4 +] +) +: +( +[ +0 +- +9 +] +{ +1 +10 +} +) +( +: +( +[ +0 +- +9 +] ++ +) +) +? +\ +] +" +) +; +/ +/ +strscan +- +0 +. +1 +. +1 +: +r +" +^ +\ +w ++ +" +consistent +! +( +strscan_0 +r +" +^ +\ +w ++ +" +) +; +/ +/ +strscan +- +0 +. +1 +. +1 +: +r +" +^ +\ +s ++ +" +consistent +! +( +strscan_1 +r +" +^ +\ +s ++ +" +) +; +/ +/ +strscan +- +0 +. +1 +. +1 +: +r +" +^ +\ +w ++ +" +consistent +! +( +strscan_2 +r +" +^ +\ +w ++ +" +) +; +/ +/ +strscan +- +0 +. +1 +. +1 +: +r +" +^ +\ +s ++ +" +consistent +! +( +strscan_3 +r +" +^ +\ +s ++ +" +) +; +/ +/ +strscan +- +0 +. +1 +. +1 +: +r +" +^ +( +\ +w ++ +) +\ +s ++ +" +consistent +! +( +strscan_4 +r +" +^ +( +\ +w ++ +) +\ +s ++ +" +) +; +/ +/ +tk +- +carbon +- +0 +. +2 +. +0 +: +r +" +^ +( +[ +a +- +zA +- +Z0 +- +9 +\ +. +- +] ++ +) +( +? +: +\ +s ++ +( +\ +d ++ +) +) +" +consistent +! +( +tk_carbon_0 +r +" +^ +( +[ +a +- +zA +- +Z0 +- +9 +\ +. +- +] ++ +) +( +? +: +\ +s ++ +( +\ +d ++ +) +) +" +) +; +/ +/ +tk +- +carbon +- +0 +. +2 +. +0 +: +r +" +^ +( +[ +a +- +zA +- +Z0 +- +9 +\ +. +- +] ++ +) +( +? +: +\ +s ++ +( +\ +d ++ +) +) +" +consistent +! +( +tk_carbon_1 +r +" +^ +( +[ +a +- +zA +- +Z0 +- +9 +\ +. +- +] ++ +) +( +? +: +\ +s ++ +( +\ +d ++ +) +) +" +) +; +/ +/ +evalrs +- +0 +. +0 +. +10 +: +r +" +extern +\ +s ++ +crate +\ +s ++ +( +[ +a +- +z0 +- +9_ +] ++ +) +\ +s +* +; +( +\ +s +* +/ +/ +( +. ++ +) +) +? +" +consistent +! +( +evalrs_0 +r +" +extern +\ +s ++ +crate +\ +s ++ +( +[ +a +- +z0 +- +9_ +] ++ +) +\ +s +* +; +( +\ +s +* +/ +/ +( +. ++ +) +) +? +" +) +; +/ +/ +evalrs +- +0 +. +0 +. +10 +: +r +" +( +? +m +) +^ +# +" +consistent +! +( +evalrs_1 +r +" +( +? +m +) +^ +# +" +) +; +/ +/ +evalrs +- +0 +. +0 +. +10 +: +r +" +( +? +m +) +^ +\ +s +* +fn ++ +main +* +\ +( +* +\ +) +" +consistent +! +( +evalrs_2 +r +" +( +? +m +) +^ +\ +s +* +fn ++ +main +* +\ +( +* +\ +) +" +) +; +/ +/ +evalrs +- +0 +. +0 +. +10 +: +r +" +( +extern +\ +s ++ +crate +\ +s ++ +[ +a +- +z0 +- +9_ +] ++ +\ +s +* +; +) +" +consistent +! +( +evalrs_3 +r +" +( +extern +\ +s ++ +crate +\ +s ++ +[ +a +- +z0 +- +9_ +] ++ +\ +s +* +; +) +" +) +; +/ +/ +gate_build +- +0 +. +5 +. +0 +: +" +( +. +* +) +_t +( +[ +0 +- +9 +] ++ +) +" +consistent +! +( +gate_build_0 +" +( +. +* +) +_t +( +[ +0 +- +9 +] ++ +) +" +) +; +/ +/ +rake +- +0 +. +1 +. +1 +: +r +" +[ +^ +\ +P +{ +P +} +- +] +| +\ +s ++ +- +\ +s ++ +" +consistent +! +( +rake_0 +r +" +[ +^ +\ +P +{ +P +} +- +] +| +\ +s ++ +- +\ +s ++ +" +) +; +/ +/ +rafy +- +0 +. +2 +. +1 +: +r +" +^ +. +* +( +? +: +( +? +: +youtu +\ +. +be +/ +| +v +/ +| +vi +/ +| +u +/ +w +/ +| +embed +/ +) +| +( +? +: +( +? +: +watch +) +? +\ +? +v +( +? +: +i +) +? += +| +\ +& +v +( +? +: +i +) +? += +) +) +( +[ +^ +# +\ +& +\ +? +] +* +) +. +* +" +consistent +! +( +rafy_0 +r +" +^ +. +* +( +? +: +( +? +: +youtu +\ +. +be +/ +| +v +/ +| +vi +/ +| +u +/ +w +/ +| +embed +/ +) +| +( +? +: +( +? +: +watch +) +? +\ +? +v +( +? +: +i +) +? += +| +\ +& +v +( +? +: +i +) +? += +) +) +( +[ +^ +# +\ +& +\ +? +] +* +) +. +* +" +) +; +/ +/ +raven +- +0 +. +2 +. +1 +: +r +" +^ +( +? +P +< +protocol +> +. +* +? +) +: +/ +/ +( +? +P +< +public_key +> +. +* +? +) +: +( +? +P +< +secret_key +> +. +* +? +) +( +? +P +< +host +> +. +* +? +) +/ +( +? +P +< +path +> +. +* +/ +) +? +( +? +P +< +project_id +> +. +* +) +" +consistent +! +( +raven_0 +r +" +^ +( +? +P +< +protocol +> +. +* +? +) +: +/ +/ +( +? +P +< +public_key +> +. +* +? +) +: +( +? +P +< +secret_key +> +. +* +? +) +( +? +P +< +host +> +. +* +? +) +/ +( +? +P +< +path +> +. +* +/ +) +? +( +? +P +< +project_id +> +. +* +) +" +) +; +/ +/ +rargs +- +0 +. +2 +. +0 +: +r +" +\ +{ +[ +[ +: +space +: +] +] +* +[ +^ +{ +} +] +* +[ +[ +: +space +: +] +] +* +\ +} +" +consistent +! +( +rargs_0 +r +" +\ +{ +[ +[ +: +space +: +] +] +* +[ +^ +{ +} +] +* +[ +[ +: +space +: +] +] +* +\ +} +" +) +; +/ +/ +rargs +- +0 +. +2 +. +0 +: +r +" +^ +\ +{ +[ +[ +: +space +: +] +] +* +( +? +P +< +name +> +[ +[ +: +word +: +] +] +* +) +[ +[ +: +space +: +] +] +* +\ +} +" +consistent +! +( +rargs_1 +r +" +^ +\ +{ +[ +[ +: +space +: +] +] +* +( +? +P +< +name +> +[ +[ +: +word +: +] +] +* +) +[ +[ +: +space +: +] +] +* +\ +} +" +) +; +/ +/ +rargs +- +0 +. +2 +. +0 +: +r +" +^ +\ +{ +[ +[ +: +space +: +] +] +* +( +? +P +< +num +> +- +? +\ +d ++ +) +[ +[ +: +space +: +] +] +* +\ +} +" +consistent +! +( +rargs_2 +r +" +^ +\ +{ +[ +[ +: +space +: +] +] +* +( +? +P +< +num +> +- +? +\ +d ++ +) +[ +[ +: +space +: +] +] +* +\ +} +" +) +; +/ +/ +rargs +- +0 +. +2 +. +0 +: +r +" +^ +\ +{ +( +? +P +< +left +> +- +? +\ +d +* +) +? +\ +. +\ +. +( +? +P +< +right +> +- +? +\ +d +* +) +? +( +? +: +: +( +? +P +< +sep +> +. +* +) +) +? +\ +} +" +consistent +! +( +rargs_3 +r +" +^ +\ +{ +( +? +P +< +left +> +- +? +\ +d +* +) +? +\ +. +\ +. +( +? +P +< +right +> +- +? +\ +d +* +) +? +( +? +: +: +( +? +P +< +sep +> +. +* +) +) +? +\ +} +" +) +; +/ +/ +rargs +- +0 +. +2 +. +0 +: +r +" +( +. +* +? +) +[ +[ +: +space +: +] +] ++ +| +( +. +* +? +) +" +consistent +! +( +rargs_4 +r +" +( +. +* +? +) +[ +[ +: +space +: +] +] ++ +| +( +. +* +? +) +" +) +; +/ +/ +indradb +- +lib +- +0 +. +15 +. +0 +: +r +" +[ +a +- +zA +- +Z0 +- +9 +] +{ +8 +} +" +consistent +! +( +indradb_lib_0 +r +" +[ +a +- +zA +- +Z0 +- +9 +] +{ +8 +} +" +) +; +/ +/ +fungi +- +lang +- +0 +. +1 +. +50 +: +r +" +: +: +" +consistent +! +( +fungi_lang_0 +r +" +: +: +" +) +; +/ +/ +nickel +- +0 +. +10 +. +1 +: +" +/ +hello +/ +( +? +P +< +name +> +[ +a +- +zA +- +Z +] ++ +) +" +consistent +! +( +nickel_0 +" +/ +hello +/ +( +? +P +< +name +> +[ +a +- +zA +- +Z +] ++ +) +" +) +; +/ +/ +nickel +- +0 +. +10 +. +1 +: +" +/ +hello +/ +( +? +P +< +name +> +[ +a +- +zA +- +Z +] ++ +) +" +consistent +! +( +nickel_1 +" +/ +hello +/ +( +? +P +< +name +> +[ +a +- +zA +- +Z +] ++ +) +" +) +; +/ +/ +pact_verifier +- +0 +. +4 +. +0 +: +r +" +\ +{ +( +\ +w ++ +) +\ +} +" +consistent +! +( +pact_verifier_0 +r +" +\ +{ +( +\ +w ++ +) +\ +} +" +) +; +/ +/ +pact_matching +- +0 +. +4 +. +1 +: +" +application +/ +. +* +json +" +consistent +! +( +pact_matching_0 +" +application +/ +. +* +json +" +) +; +/ +/ +pact_matching +- +0 +. +4 +. +1 +: +" +application +/ +json +. +* +" +consistent +! +( +pact_matching_1 +" +application +/ +json +. +* +" +) +; +/ +/ +pact_matching +- +0 +. +4 +. +1 +: +" +application +/ +. +* +xml +" +consistent +! +( +pact_matching_2 +" +application +/ +. +* +xml +" +) +; +/ +/ +pangu +- +0 +. +2 +. +0 +: +" +( +[ +\ +" +' +\ +\ +( +\ +\ +[ +\ +\ +{ +{ +< +\ +u +{ +201c +} +] +) +( +\ +\ +s +* +) +( +. ++ +? +) +( +\ +\ +s +* +) +( +[ +\ +" +' +\ +\ +) +\ +\ +] +\ +\ +} +} +> +\ +u +{ +201d +} +] +) +" +consistent +! +( +pangu_0 +" +( +[ +\ +" +' +\ +\ +( +\ +\ +[ +\ +\ +{ +{ +< +\ +u +{ +201c +} +] +) +( +\ +\ +s +* +) +( +. ++ +? +) +( +\ +\ +s +* +) +( +[ +\ +" +' +\ +\ +) +\ +\ +] +\ +\ +} +} +> +\ +u +{ +201d +} +] +) +" +) +; +/ +/ +pangu +- +0 +. +2 +. +0 +: +" +( +[ +\ +\ +( +\ +\ +[ +\ +\ +{ +{ +< +\ +u +{ +201c +} +] ++ +) +( +\ +\ +s +* +) +( +. ++ +? +) +( +\ +\ +s +* +) +( +[ +\ +\ +) +\ +\ +] +\ +\ +} +} +> +\ +u +{ +201d +} +] ++ +) +" +consistent +! +( +pangu_1 +" +( +[ +\ +\ +( +\ +\ +[ +\ +\ +{ +{ +< +\ +u +{ +201c +} +] ++ +) +( +\ +\ +s +* +) +( +. ++ +? +) +( +\ +\ +s +* +) +( +[ +\ +\ +) +\ +\ +] +\ +\ +} +} +> +\ +u +{ +201d +} +] ++ +) +" +) +; +/ +/ +parser +- +haskell +- +0 +. +2 +. +0 +: +r +" +\ +{ +- +[ +\ +s +\ +S +] +* +? +- +\ +} +" +consistent +! +( +parser_haskell_0 +r +" +\ +{ +- +[ +\ +s +\ +S +] +* +? +- +\ +} +" +) +; +/ +/ +parser +- +haskell +- +0 +. +2 +. +0 +: +r +" +( +? +m +) +; ++ +\ +s +* +" +consistent +! +( +parser_haskell_1 +r +" +( +? +m +) +; ++ +\ +s +* +" +) +; +/ +/ +parser +- +haskell +- +0 +. +2 +. +0 +: +r +" +( +? +m +) +^ +# +( +if +| +ifn +? +def +| +endif +| +else +| +include +| +elif +) +. +* +" +consistent +! +( +parser_haskell_2 +r +" +( +? +m +) +^ +# +( +if +| +ifn +? +def +| +endif +| +else +| +include +| +elif +) +. +* +" +) +; +/ +/ +parser +- +haskell +- +0 +. +2 +. +0 +: +r +" +' +( +[ +^ +' +\ +\ +] +| +\ +\ +[ +A +- +Z +] +{ +1 +3 +} +| +\ +\ +. +) +' +" +consistent +! +( +parser_haskell_3 +r +" +' +( +[ +^ +' +\ +\ +] +| +\ +\ +[ +A +- +Z +] +{ +1 +3 +} +| +\ +\ +. +) +' +" +) +; +/ +/ +parser +- +haskell +- +0 +. +2 +. +0 +: +r +" +forall +\ +s ++ +( +. +* +? +) +\ +. +" +consistent +! +( +parser_haskell_4 +r +" +forall +\ +s ++ +( +. +* +? +) +\ +. +" +) +; +/ +/ +html2md +- +0 +. +2 +. +1 +: +" +\ +\ +s +{ +2 +} +" +consistent +! +( +html2md_0 +" +\ +\ +s +{ +2 +} +" +) +; +/ +/ +html2md +- +0 +. +2 +. +1 +: +" +\ +\ +n +{ +2 +} +" +consistent +! +( +html2md_1 +" +\ +\ +n +{ +2 +} +" +) +; +/ +/ +html2md +- +0 +. +2 +. +1 +: +" +( +? +m +) +( +\ +\ +S +) +" +consistent +! +( +html2md_2 +" +( +? +m +) +( +\ +\ +S +) +" +) +; +/ +/ +html2md +- +0 +. +2 +. +1 +: +" +( +? +m +) +^ +[ +- +* +] +" +consistent +! +( +html2md_3 +" +( +? +m +) +^ +[ +- +* +] +" +) +; +/ +/ +ovpnfile +- +0 +. +1 +. +2 +: +r +" +# +. +* +" +consistent +! +( +ovpnfile_0 +r +" +# +. +* +" +) +; +/ +/ +ovpnfile +- +0 +. +1 +. +2 +: +r +" +^ +< +( +\ +S ++ +) +> +" +consistent +! +( +ovpnfile_1 +r +" +^ +< +( +\ +S ++ +) +> +" +) +; +/ +/ +ovpnfile +- +0 +. +1 +. +2 +: +r +" +^ +< +/ +( +\ +S ++ +) +> +" +consistent +! +( +ovpnfile_2 +r +" +^ +< +/ +( +\ +S ++ +) +> +" +) +; +/ +/ +screenruster +- +saver +- +fractal +- +0 +. +1 +. +1 +: +r +" +# +( +[ +: +xdigit +: +] +{ +2 +} +) +( +[ +: +xdigit +: +] +{ +2 +} +) +( +[ +: +xdigit +: +] +{ +2 +} +) +" +consistent +! +( +screenruster_saver_fractal_0 +r +" +# +( +[ +: +xdigit +: +] +{ +2 +} +) +( +[ +: +xdigit +: +] +{ +2 +} +) +( +[ +: +xdigit +: +] +{ +2 +} +) +" +) +; +/ +/ +scarlet +- +0 +. +2 +. +2 +: +r +" +rgb +\ +( +( +? +: +* +( +\ +d +{ +1 +3 +} +) +) +( +? +: +* +( +\ +d +{ +1 +3 +} +) +) +( +? +: +* +( +\ +d +{ +1 +3 +} +) +) +\ +) +" +consistent +! +( +scarlet_0 +r +" +rgb +\ +( +( +? +: +* +( +\ +d +{ +1 +3 +} +) +) +( +? +: +* +( +\ +d +{ +1 +3 +} +) +) +( +? +: +* +( +\ +d +{ +1 +3 +} +) +) +\ +) +" +) +; +/ +/ +cpp_to_rust_generator +- +0 +. +2 +. +0 +: +r +" +^ +( +[ +\ +w +: +] ++ +) +< +( +. ++ +) +> +" +consistent +! +( +cpp_to_rust_generator_0 +r +" +^ +( +[ +\ +w +: +] ++ +) +< +( +. ++ +) +> +" +) +; +/ +/ +cpp_to_rust_generator +- +0 +. +2 +. +0 +: +r +" +^ +type +- +parameter +- +( +\ +d ++ +) +- +( +\ +d ++ +) +" +consistent +! +( +cpp_to_rust_generator_1 +r +" +^ +type +- +parameter +- +( +\ +d ++ +) +- +( +\ +d ++ +) +" +) +; +/ +/ +cpp_to_rust_generator +- +0 +. +2 +. +0 +: +r +" +^ +( +[ +\ +w +~ +] ++ +) +< +[ +^ +< +> +] ++ +> +" +consistent +! +( +cpp_to_rust_generator_2 +r +" +^ +( +[ +\ +w +~ +] ++ +) +< +[ +^ +< +> +] ++ +> +" +) +; +/ +/ +cpp_to_rust_generator +- +0 +. +2 +. +0 +: +r +" +( +signals +| +Q_SIGNALS +) +\ +s +* +: +" +consistent +! +( +cpp_to_rust_generator_3 +r +" +( +signals +| +Q_SIGNALS +) +\ +s +* +: +" +) +; +/ +/ +cpp_to_rust_generator +- +0 +. +2 +. +0 +: +r +" +( +slots +| +Q_SLOTS +) +\ +s +* +: +" +consistent +! +( +cpp_to_rust_generator_4 +r +" +( +slots +| +Q_SLOTS +) +\ +s +* +: +" +) +; +/ +/ +cpp_to_rust_generator +- +0 +. +2 +. +0 +: +r +" +( +public +| +protected +| +private +) +\ +s +* +: +" +consistent +! +( +cpp_to_rust_generator_5 +r +" +( +public +| +protected +| +private +) +\ +s +* +: +" +) +; +/ +/ +cpp_to_rust +- +0 +. +5 +. +3 +: +r +" +^ +( +[ +\ +w +: +] ++ +) +< +( +. ++ +) +> +" +consistent +! +( +cpp_to_rust_0 +r +" +^ +( +[ +\ +w +: +] ++ +) +< +( +. ++ +) +> +" +) +; +/ +/ +cpp_to_rust +- +0 +. +5 +. +3 +: +r +" +^ +type +- +parameter +- +( +\ +d ++ +) +- +( +\ +d ++ +) +" +consistent +! +( +cpp_to_rust_1 +r +" +^ +type +- +parameter +- +( +\ +d ++ +) +- +( +\ +d ++ +) +" +) +; +/ +/ +cpp_to_rust +- +0 +. +5 +. +3 +: +r +" +^ +( +[ +\ +w +~ +] ++ +) +< +[ +^ +< +> +] ++ +> +" +consistent +! +( +cpp_to_rust_2 +r +" +^ +( +[ +\ +w +~ +] ++ +) +< +[ +^ +< +> +] ++ +> +" +) +; +/ +/ +cpp_to_rust +- +0 +. +5 +. +3 +: +r +" +( +signals +| +Q_SIGNALS +) +\ +s +* +: +" +consistent +! +( +cpp_to_rust_3 +r +" +( +signals +| +Q_SIGNALS +) +\ +s +* +: +" +) +; +/ +/ +cpp_to_rust +- +0 +. +5 +. +3 +: +r +" +( +slots +| +Q_SLOTS +) +\ +s +* +: +" +consistent +! +( +cpp_to_rust_4 +r +" +( +slots +| +Q_SLOTS +) +\ +s +* +: +" +) +; +/ +/ +cpp_to_rust +- +0 +. +5 +. +3 +: +r +" +( +public +| +protected +| +private +) +\ +s +* +: +" +consistent +! +( +cpp_to_rust_5 +r +" +( +public +| +protected +| +private +) +\ +s +* +: +" +) +; +/ +/ +fritzbox_logs +- +0 +. +2 +. +0 +: +" +( +\ +\ +d +{ +2 +} +\ +\ +. +\ +\ +d +{ +2 +} +\ +\ +. +\ +\ +d +{ +2 +} +) +( +\ +\ +d +{ +2 +} +: +\ +\ +d +{ +2 +} +: +\ +\ +d +{ +2 +} +) +( +. +* +) +" +consistent +! +( +fritzbox_logs_0 +" +( +\ +\ +d +{ +2 +} +\ +\ +. +\ +\ +d +{ +2 +} +\ +\ +. +\ +\ +d +{ +2 +} +) +( +\ +\ +d +{ +2 +} +: +\ +\ +d +{ +2 +} +: +\ +\ +d +{ +2 +} +) +( +. +* +) +" +) +; +/ +/ +fractal +- +matrix +- +api +- +3 +. +29 +. +0 +: +r +" +mxc +: +/ +/ +( +? +P +< +server +> +[ +^ +/ +] ++ +) +/ +( +? +P +< +media +> +. ++ +) +" +consistent +! +( +fractal_matrix_api_0 +r +" +mxc +: +/ +/ +( +? +P +< +server +> +[ +^ +/ +] ++ +) +/ +( +? +P +< +media +> +. ++ +) +" +) +; +/ +/ +smtp2go +- +0 +. +1 +. +4 +: +r +" +^ +api +- +[ +a +- +zA +- +Z0 +- +9 +] +{ +32 +} +" +consistent +! +( +smtp2go_0 +r +" +^ +api +- +[ +a +- +zA +- +Z0 +- +9 +] +{ +32 +} +" +) +; +/ +/ +pusher +- +0 +. +3 +. +1 +: +r +" +^ +[ +- +a +- +zA +- +Z0 +- +9_ += +. +; +] ++ +" +consistent +! +( +pusher_0 +r +" +^ +[ +- +a +- +zA +- +Z0 +- +9_ += +. +; +] ++ +" +) +; +/ +/ +pusher +- +0 +. +3 +. +1 +: +r +" +\ +A +\ +d ++ +\ +. +\ +d ++ +\ +z +" +consistent +! +( +pusher_1 +r +" +\ +A +\ +d ++ +\ +. +\ +d ++ +\ +z +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +\ +. +( +. ++ +? +) ++ +? +( +. ++ +) +" +consistent +! +( +bakervm_0 +r +" +^ +\ +. +( +. ++ +? +) ++ +? +( +. ++ +) +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +\ +. +( +[ +^ +\ +s +] ++ +) +" +consistent +! +( +bakervm_1 +r +" +^ +\ +. +( +[ +^ +\ +s +] ++ +) +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +include +! ++ +( +[ +^ +\ +s +] ++ +) +" +consistent +! +( +bakervm_2 +r +" +^ +include +! ++ +( +[ +^ +\ +s +] ++ +) +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +( +\ +d ++ +) +" +consistent +! +( +bakervm_3 +r +" +^ +( +\ +d ++ +) +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +true +| +false +" +consistent +! +( +bakervm_4 +r +" +^ +true +| +false +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +( +- +? +\ +d ++ +) +? +\ +. +[ +0 +- +9 +] ++ +" +consistent +! +( +bakervm_5 +r +" +^ +( +- +? +\ +d ++ +) +? +\ +. +[ +0 +- +9 +] ++ +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +( +- +? +\ +d ++ +) +? +" +consistent +! +( +bakervm_6 +r +" +^ +( +- +? +\ +d ++ +) +? +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +# +( +[ +0 +- +9abcdefABCDEF +] +{ +6 +} +) +" +consistent +! +( +bakervm_7 +r +" +^ +# +( +[ +0 +- +9abcdefABCDEF +] +{ +6 +} +) +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +' +( +. +) +' +" +consistent +! +( +bakervm_8 +r +" +^ +' +( +. +) +' +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +\ +vi +\ +( +( +\ +d ++ +) +\ +) +" +consistent +! +( +bakervm_9 +r +" +^ +\ +vi +\ +( +( +\ +d ++ +) +\ +) +" +) +; +/ +/ +bakervm +- +0 +. +9 +. +0 +: +r +" +^ +\ +key +\ +( +( +\ +d ++ +) +\ +) +" +consistent +! +( +bakervm_10 +r +" +^ +\ +key +\ +( +( +\ +d ++ +) +\ +) +" +) +; +/ +/ +banana +- +0 +. +0 +. +2 +: +" +( +? +P +< +type +> +[ +A +- +Z +^ +' +] ++ +) +( +? +P +< +route +> +[ +^ +' +] ++ +) +HTTP +/ +( +? +P +< +http +> +[ +^ +' +] ++ +) +" +consistent +! +( +banana_0 +" +( +? +P +< +type +> +[ +A +- +Z +^ +' +] ++ +) +( +? +P +< +route +> +[ +^ +' +] ++ +) +HTTP +/ +( +? +P +< +http +> +[ +^ +' +] ++ +) +" +) +; +/ +/ +serial +- +key +- +2 +. +0 +. +0 +: +r +" +[ +A +- +F0 +- +9 +] +{ +8 +} +" +consistent +! +( +serial_key_0 +r +" +[ +A +- +F0 +- +9 +] +{ +8 +} +" +) +; +/ +/ +serde +- +hjson +- +0 +. +8 +. +1 +: +" +[ +\ +\ +\ +\ +\ +" +\ +x00 +- +\ +x1f +\ +x7f +- +\ +u +{ +9f +} +\ +u +{ +00ad +} +\ +u +{ +0600 +} +- +\ +u +{ +0604 +} +\ +u +{ +070f +} +\ +u +{ +17b4 +} +\ +u +{ +17b5 +} +\ +u +{ +200c +} +- +\ +u +{ +200f +} +\ +u +{ +2028 +} +- +\ +u +{ +202f +} +\ +u +{ +2060 +} +- +\ +u +{ +206f +} +\ +u +{ +feff +} +\ +u +{ +fff0 +} +- +\ +u +{ +ffff +} +] +" +consistent +! +( +serde_hjson_0 +" +[ +\ +\ +\ +\ +\ +" +\ +x00 +- +\ +x1f +\ +x7f +- +\ +u +{ +9f +} +\ +u +{ +00ad +} +\ +u +{ +0600 +} +- +\ +u +{ +0604 +} +\ +u +{ +070f +} +\ +u +{ +17b4 +} +\ +u +{ +17b5 +} +\ +u +{ +200c +} +- +\ +u +{ +200f +} +\ +u +{ +2028 +} +- +\ +u +{ +202f +} +\ +u +{ +2060 +} +- +\ +u +{ +206f +} +\ +u +{ +feff +} +\ +u +{ +fff0 +} +- +\ +u +{ +ffff +} +] +" +) +; +/ +/ +serde +- +hjson +- +0 +. +8 +. +1 +: +" +[ +\ +x00 +- +\ +x1f +\ +x7f +- +\ +u +{ +9f +} +\ +u +{ +00ad +} +\ +u +{ +0600 +} +- +\ +u +{ +0604 +} +\ +u +{ +070f +} +\ +u +{ +17b4 +} +\ +u +{ +17b5 +} +\ +u +{ +200c +} +- +\ +u +{ +200f +} +\ +u +{ +2028 +} +- +\ +u +{ +202f +} +\ +u +{ +2060 +} +- +\ +u +{ +206f +} +\ +u +{ +feff +} +\ +u +{ +fff0 +} +- +\ +u +{ +ffff +} +] +" +consistent +! +( +serde_hjson_1 +" +[ +\ +x00 +- +\ +x1f +\ +x7f +- +\ +u +{ +9f +} +\ +u +{ +00ad +} +\ +u +{ +0600 +} +- +\ +u +{ +0604 +} +\ +u +{ +070f +} +\ +u +{ +17b4 +} +\ +u +{ +17b5 +} +\ +u +{ +200c +} +- +\ +u +{ +200f +} +\ +u +{ +2028 +} +- +\ +u +{ +202f +} +\ +u +{ +2060 +} +- +\ +u +{ +206f +} +\ +u +{ +feff +} +\ +u +{ +fff0 +} +- +\ +u +{ +ffff +} +] +" +) +; +/ +/ +serde +- +hjson +- +0 +. +8 +. +1 +: +" +' +' +' +| +[ +\ +x00 +- +\ +x09 +\ +x0b +\ +x0c +\ +x0e +- +\ +x1f +\ +x7f +- +\ +u +{ +9f +} +\ +u +{ +00ad +} +\ +u +{ +0600 +} +- +\ +u +{ +0604 +} +\ +u +{ +070f +} +\ +u +{ +17b4 +} +\ +u +{ +17b5 +} +\ +u +{ +200c +} +- +\ +u +{ +200f +} +\ +u +{ +2028 +} +- +\ +u +{ +202f +} +\ +u +{ +2060 +} +- +\ +u +{ +206f +} +\ +u +{ +feff +} +\ +u +{ +fff0 +} +- +\ +u +{ +ffff +} +] +" +consistent +! +( +serde_hjson_2 +" +' +' +' +| +[ +\ +x00 +- +\ +x09 +\ +x0b +\ +x0c +\ +x0e +- +\ +x1f +\ +x7f +- +\ +u +{ +9f +} +\ +u +{ +00ad +} +\ +u +{ +0600 +} +- +\ +u +{ +0604 +} +\ +u +{ +070f +} +\ +u +{ +17b4 +} +\ +u +{ +17b5 +} +\ +u +{ +200c +} +- +\ +u +{ +200f +} +\ +u +{ +2028 +} +- +\ +u +{ +202f +} +\ +u +{ +2060 +} +- +\ +u +{ +206f +} +\ +u +{ +feff +} +\ +u +{ +fff0 +} +- +\ +u +{ +ffff +} +] +" +) +; +/ +/ +serde +- +odbc +- +0 +. +1 +. +0 +: +r +" +/ +todos +/ +( +? +P +< +id +> +\ +d ++ +) +" +consistent +! +( +serde_odbc_0 +r +" +/ +todos +/ +( +? +P +< +id +> +\ +d ++ +) +" +) +; +/ +/ +sentry +- +0 +. +6 +. +0 +: +r +" +^ +( +? +: +_ +< +) +? +( +[ +a +- +zA +- +Z0 +- +9_ +] ++ +? +) +( +? +: +\ +. +\ +. +| +: +: +) +" +consistent +! +( +sentry_0 +r +" +^ +( +? +: +_ +< +) +? +( +[ +a +- +zA +- +Z0 +- +9_ +] ++ +? +) +( +? +: +\ +. +\ +. +| +: +: +) +" +) +; +/ +/ +sentiment +- +0 +. +1 +. +1 +: +r +" +[ +^ +a +- +zA +- +Z0 +- +] ++ +" +consistent +! +( +sentiment_0 +r +" +[ +^ +a +- +zA +- +Z0 +- +] ++ +" +) +; +/ +/ +sentiment +- +0 +. +1 +. +1 +: +r +" +{ +2 +} +" +consistent +! +( +sentiment_1 +r +" +{ +2 +} +" +) +; +/ +/ +verilog +- +0 +. +0 +. +1 +: +r +" +( +? +m +) +/ +/ +. +* +" +consistent +! +( +verilog_0 +r +" +( +? +m +) +/ +/ +. +* +" +) +; +/ +/ +verex +- +0 +. +2 +. +2 +: +" +( +? +P +< +robot +> +C3PO +) +" +consistent +! +( +verex_0 +" +( +? +P +< +robot +> +C3PO +) +" +) +; +/ +/ +handlebars +- +0 +. +32 +. +4 +: +" +> +| +< +| +\ +" +| +& +" +consistent +! +( +handlebars_0 +" +> +| +< +| +\ +" +| +& +" +) +; +/ +/ +haikunator +- +0 +. +1 +. +2 +: +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +0123456789 +] +{ +4 +} +" +consistent +! +( +haikunator_0 +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +0123456789 +] +{ +4 +} +" +) +; +/ +/ +haikunator +- +0 +. +1 +. +2 +: +r +" +^ +\ +w ++ +\ +w ++ +[ +0123456789 +] +{ +4 +} +" +consistent +! +( +haikunator_1 +r +" +^ +\ +w ++ +\ +w ++ +[ +0123456789 +] +{ +4 +} +" +) +; +/ +/ +haikunator +- +0 +. +1 +. +2 +: +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +0123456789abcdef +] +{ +4 +} +" +consistent +! +( +haikunator_2 +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +0123456789abcdef +] +{ +4 +} +" +) +; +/ +/ +haikunator +- +0 +. +1 +. +2 +: +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +0123456789 +] +{ +10 +} +" +consistent +! +( +haikunator_3 +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +0123456789 +] +{ +10 +} +" +) +; +/ +/ +haikunator +- +0 +. +1 +. +2 +: +r +" +^ +\ +w ++ +- +\ +w ++ +" +consistent +! +( +haikunator_4 +r +" +^ +\ +w ++ +- +\ +w ++ +" +) +; +/ +/ +haikunator +- +0 +. +1 +. +2 +: +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +foo +] +{ +4 +} +" +consistent +! +( +haikunator_5 +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +foo +] +{ +4 +} +" +) +; +/ +/ +haikunator +- +0 +. +1 +. +2 +: +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +0123456789 +] +{ +5 +} +" +consistent +! +( +haikunator_6 +r +" +^ +\ +w ++ +- +\ +w ++ +- +[ +0123456789 +] +{ +5 +} +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +( +. +* +) +" +consistent +! +( +bobbin_cli_0 +r +" +( +. +* +) +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +rustc +( +. +* +) +" +consistent +! +( +bobbin_cli_1 +r +" +rustc +( +. +* +) +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +cargo +( +. +* +) +" +consistent +! +( +bobbin_cli_2 +r +" +cargo +( +. +* +) +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +xargo +( +. +* +) +\ +n +" +consistent +! +( +bobbin_cli_3 +r +" +xargo +( +. +* +) +\ +n +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +Open +On +- +Chip +Debugger +( +. +* +) +" +consistent +! +( +bobbin_cli_4 +r +" +Open +On +- +Chip +Debugger +( +. +* +) +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +arm +- +none +- +eabi +- +gcc +\ +( +GNU +Tools +for +ARM +Embedded +Processors +[ +^ +\ +) +] +* +\ +) +( +. +* +) +" +consistent +! +( +bobbin_cli_5 +r +" +arm +- +none +- +eabi +- +gcc +\ +( +GNU +Tools +for +ARM +Embedded +Processors +[ +^ +\ +) +] +* +\ +) +( +. +* +) +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +( +? +m +) +. +* +\ +nBasic +Open +Source +SAM +- +BA +Application +\ +( +BOSSA +\ +) +Version +( +. +* +) +\ +n +" +consistent +! +( +bobbin_cli_6 +r +" +( +? +m +) +. +* +\ +nBasic +Open +Source +SAM +- +BA +Application +\ +( +BOSSA +\ +) +Version +( +. +* +) +\ +n +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +( +? +m +) +SEGGER +J +- +Link +Commander +( +. +* +) +\ +n +" +consistent +! +( +bobbin_cli_7 +r +" +( +? +m +) +SEGGER +J +- +Link +Commander +( +. +* +) +\ +n +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +( +? +m +) +Teensy +Loader +Command +Line +Version +( +. +* +) +\ +n +" +consistent +! +( +bobbin_cli_8 +r +" +( +? +m +) +Teensy +Loader +Command +Line +Version +( +. +* +) +\ +n +" +) +; +/ +/ +bobbin +- +cli +- +0 +. +8 +. +3 +: +r +" +dfu +- +util +( +. +* +) +\ +n +" +consistent +! +( +bobbin_cli_9 +r +" +dfu +- +util +( +. +* +) +\ +n +" +) +; +/ +/ +borsholder +- +0 +. +9 +. +1 +: +r +" +^ +/ +static +/ +[ +\ +w +. +] ++ +" +consistent +! +( +borsholder_0 +r +" +^ +/ +static +/ +[ +\ +w +. +] ++ +" +) +; +/ +/ +borsholder +- +0 +. +9 +. +1 +: +r +" +^ +/ +timeline +/ +( +[ +0 +- +9 +] ++ +) +" +consistent +! +( +borsholder_1 +r +" +^ +/ +timeline +/ +( +[ +0 +- +9 +] ++ +) +" +) +; +/ +/ +fblog +- +1 +. +0 +. +1 +: +" +\ +u +{ +001B +} +\ +\ +[ +[ +\ +\ +d +; +] +* +[ +^ +\ +\ +d +; +] +" +consistent +! +( +fblog_0 +" +\ +u +{ +001B +} +\ +\ +[ +[ +\ +\ +d +; +] +* +[ +^ +\ +\ +d +; +] +" +) +; +/ +/ +fblog +- +1 +. +0 +. +1 +: +" +\ +u +{ +001B +} +\ +\ +[ +[ +\ +\ +d +; +] +* +[ +^ +\ +\ +d +; +] +" +consistent +! +( +fblog_1 +" +\ +u +{ +001B +} +\ +\ +[ +[ +\ +\ +d +; +] +* +[ +^ +\ +\ +d +; +] +" +) +; +/ +/ +toml +- +query +- +0 +. +6 +. +0 +: +r +" +^ +\ +[ +\ +d ++ +\ +] +" +consistent +! +( +toml_query_0 +r +" +^ +\ +[ +\ +d ++ +\ +] +" +) +; +/ +/ +todo +- +txt +- +1 +. +1 +. +0 +: +r +" +( +? +P +< +key +> +[ +^ +\ +s +] ++ +) +: +( +? +P +< +value +> +[ +^ +\ +s +^ +/ +] ++ +) +" +consistent +! +( +todo_txt_0 +r +" +( +? +P +< +key +> +[ +^ +\ +s +] ++ +) +: +( +? +P +< +value +> +[ +^ +\ +s +^ +/ +] ++ +) +" +) +; +/ +/ +findr +- +0 +. +1 +. +5 +: +r +" +\ +band +\ +b +" +consistent +! +( +findr_0 +r +" +\ +band +\ +b +" +) +; +/ +/ +findr +- +0 +. +1 +. +5 +: +r +" +\ +bor +\ +b +" +consistent +! +( +findr_1 +r +" +\ +bor +\ +b +" +) +; +/ +/ +findr +- +0 +. +1 +. +5 +: +r +" +\ +bnot +\ +b +" +consistent +! +( +findr_2 +r +" +\ +bnot +\ +b +" +) +; +/ +/ +file +- +sniffer +- +3 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +a +| +la +| +lo +| +o +| +ll +| +keter +| +bc +| +dyn_o +| +out +| +d +| +rlib +| +crate +| +min +\ +. +js +| +hi +| +dyn_hi +| +S +| +jsexe +| +webapp +| +js +\ +. +externs +| +ibc +| +toc +| +aux +| +fdb_latexmk +| +fls +| +egg +- +info +| +whl +| +js_a +| +js_hi +| +jld +| +ji +| +js_o +| +so +. +* +| +dump +- +. +* +| +vmb +| +crx +| +orig +| +elmo +| +elmi +| +pyc +| +mod +| +p_hi +| +p_o +| +prof +| +tix +) +" +consistent +! +( +file_sniffer_0 +r +" +. +* +? +\ +. +( +a +| +la +| +lo +| +o +| +ll +| +keter +| +bc +| +dyn_o +| +out +| +d +| +rlib +| +crate +| +min +\ +. +js +| +hi +| +dyn_hi +| +S +| +jsexe +| +webapp +| +js +\ +. +externs +| +ibc +| +toc +| +aux +| +fdb_latexmk +| +fls +| +egg +- +info +| +whl +| +js_a +| +js_hi +| +jld +| +ji +| +js_o +| +so +. +* +| +dump +- +. +* +| +vmb +| +crx +| +orig +| +elmo +| +elmi +| +pyc +| +mod +| +p_hi +| +p_o +| +prof +| +tix +) +" +) +; +/ +/ +file +- +sniffer +- +3 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +stats +| +conf +| +h +| +cache +. +* +| +dat +| +pc +| +info +) +" +consistent +! +( +file_sniffer_1 +r +" +. +* +? +\ +. +( +stats +| +conf +| +h +| +cache +. +* +| +dat +| +pc +| +info +) +" +) +; +/ +/ +file +- +sniffer +- +3 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +exe +| +a +| +la +| +o +| +ll +| +keter +| +bc +| +dyn_o +| +out +| +d +| +rlib +| +crate +| +min +\ +. +js +| +hi +| +dyn_hi +| +jsexe +| +webapp +| +js +\ +. +externs +| +ibc +| +toc +| +aux +| +fdb_latexmk +| +fls +| +egg +- +info +| +whl +| +js_a +| +js_hi +| +jld +| +ji +| +js_o +| +so +. +* +| +dump +- +. +* +| +vmb +| +crx +| +orig +| +elmo +| +elmi +| +pyc +| +mod +| +p_hi +| +p_o +| +prof +| +tix +) +" +consistent +! +( +file_sniffer_2 +r +" +. +* +? +\ +. +( +exe +| +a +| +la +| +o +| +ll +| +keter +| +bc +| +dyn_o +| +out +| +d +| +rlib +| +crate +| +min +\ +. +js +| +hi +| +dyn_hi +| +jsexe +| +webapp +| +js +\ +. +externs +| +ibc +| +toc +| +aux +| +fdb_latexmk +| +fls +| +egg +- +info +| +whl +| +js_a +| +js_hi +| +jld +| +ji +| +js_o +| +so +. +* +| +dump +- +. +* +| +vmb +| +crx +| +orig +| +elmo +| +elmi +| +pyc +| +mod +| +p_hi +| +p_o +| +prof +| +tix +) +" +) +; +/ +/ +file +- +sniffer +- +3 +. +0 +. +1 +: +r +" +. +* +? +\ +. +( +stats +| +conf +| +h +| +cache +. +* +) +" +consistent +! +( +file_sniffer_3 +r +" +. +* +? +\ +. +( +stats +| +conf +| +h +| +cache +. +* +) +" +) +; +/ +/ +file +- +sniffer +- +3 +. +0 +. +1 +: +r +" +( +\ +. +git +| +\ +. +pijul +| +_darcs +| +\ +. +hg +) +" +consistent +! +( +file_sniffer_4 +r +" +( +\ +. +git +| +\ +. +pijul +| +_darcs +| +\ +. +hg +) +" +) +; +/ +/ +file_logger +- +0 +. +1 +. +0 +: +" +test +" +consistent +! +( +file_logger_0 +" +test +" +) +; +/ +/ +file_scanner +- +0 +. +2 +. +0 +: +r +" +foo +" +consistent +! +( +file_scanner_0 +r +" +foo +" +) +; +/ +/ +file_scanner +- +0 +. +2 +. +0 +: +r +" +a ++ +b +" +consistent +! +( +file_scanner_1 +r +" +a ++ +b +" +) +; +/ +/ +file_scanner +- +0 +. +2 +. +0 +: +r +" +a +[ +ab +] +* +b +" +consistent +! +( +file_scanner_2 +r +" +a +[ +ab +] +* +b +" +) +; +/ +/ +file_scanner +- +0 +. +2 +. +0 +: +r +" +\ +s ++ +" +consistent +! +( +file_scanner_3 +r +" +\ +s ++ +" +) +; +/ +/ +file_scanner +- +0 +. +2 +. +0 +: +r +" +\ +s ++ +" +consistent +! +( +file_scanner_4 +r +" +\ +s ++ +" +) +; +/ +/ +cellsplit +- +0 +. +2 +. +1 +: +r +" +^ +\ +s +* +( +[ +^ +\ +s +] ++ +) +% +cellsplit +< +\ +d ++ +> +" +consistent +! +( +cellsplit_0 +r +" +^ +\ +s +* +( +[ +^ +\ +s +] ++ +) +% +cellsplit +< +\ +d ++ +> +" +) +; +/ +/ +cellsplit +- +0 +. +2 +. +1 +: +r +" +^ +\ +s +* +( +[ +^ +\ +s +] ++ +) +% +cellsplit +< +\ +d ++ +> +" +consistent +! +( +cellsplit_1 +r +" +^ +\ +s +* +( +[ +^ +\ +s +] ++ +) +% +cellsplit +< +\ +d ++ +> +" +) +; +/ +/ +aterm +- +0 +. +20 +. +0 +: +r +" +^ +[ ++ +\ +- +] +? +[ +0 +- +9 +] ++ +" +consistent +! +( +aterm_0 +r +" +^ +[ ++ +\ +- +] +? +[ +0 +- +9 +] ++ +" +) +; +/ +/ +aterm +- +0 +. +20 +. +0 +: +r +" +^ +[ ++ +\ +- +] +? +[ +0 +- +9 +] ++ +\ +. +[ +0 +- +9 +] +* +( +[ +eE +] +[ ++ +\ +- +] +? +[ +0 +- +9 +] ++ +) +? +" +consistent +! +( +aterm_1 +r +" +^ +[ ++ +\ +- +] +? +[ +0 +- +9 +] ++ +\ +. +[ +0 +- +9 +] +* +( +[ +eE +] +[ ++ +\ +- +] +? +[ +0 +- +9 +] ++ +) +? +" +) +; +/ +/ +atarashii_imap +- +0 +. +3 +. +0 +: +r +" +^ +[ +* +] +OK +" +consistent +! +( +atarashii_imap_0 +r +" +^ +[ +* +] +OK +" +) +; +/ +/ +atarashii_imap +- +0 +. +3 +. +0 +: +r +" +FLAGS +\ +s +\ +( +( +. ++ +) +\ +) +" +consistent +! +( +atarashii_imap_1 +r +" +FLAGS +\ +s +\ +( +( +. ++ +) +\ +) +" +) +; +/ +/ +atarashii_imap +- +0 +. +3 +. +0 +: +r +" +\ +[ +PERMANENTFLAGS +\ +s +\ +( +( +. ++ +) +\ +) +\ +] +" +consistent +! +( +atarashii_imap_2 +r +" +\ +[ +PERMANENTFLAGS +\ +s +\ +( +( +. ++ +) +\ +) +\ +] +" +) +; +/ +/ +atarashii_imap +- +0 +. +3 +. +0 +: +r +" +\ +[ +UIDVALIDITY +\ +s +( +\ +d ++ +) +\ +] +" +consistent +! +( +atarashii_imap_3 +r +" +\ +[ +UIDVALIDITY +\ +s +( +\ +d ++ +) +\ +] +" +) +; +/ +/ +atarashii_imap +- +0 +. +3 +. +0 +: +r +" +( +\ +d ++ +) +\ +sEXISTS +" +consistent +! +( +atarashii_imap_4 +r +" +( +\ +d ++ +) +\ +sEXISTS +" +) +; +/ +/ +atarashii_imap +- +0 +. +3 +. +0 +: +r +" +( +\ +d ++ +) +\ +sRECENT +" +consistent +! +( +atarashii_imap_5 +r +" +( +\ +d ++ +) +\ +sRECENT +" +) +; +/ +/ +atarashii_imap +- +0 +. +3 +. +0 +: +r +" +\ +[ +UNSEEN +\ +s +( +\ +d ++ +) +\ +] +" +consistent +! +( +atarashii_imap_6 +r +" +\ +[ +UNSEEN +\ +s +( +\ +d ++ +) +\ +] +" +) +; +/ +/ +atarashii_imap +- +0 +. +3 +. +0 +: +r +" +\ +[ +UIDNEXT +\ +s +( +\ +d ++ +) +\ +] +" +consistent +! +( +atarashii_imap_7 +r +" +\ +[ +UIDNEXT +\ +s +( +\ +d ++ +) +\ +] +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +\ +\ +( +\ +{ +| +\ +} +) +" +consistent +! +( +editorconfig_0 +r +" +\ +\ +( +\ +{ +| +\ +} +) +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +( +^ +| +[ +^ +\ +\ +] +) +\ +\ +\ +| +" +consistent +! +( +editorconfig_1 +r +" +( +^ +| +[ +^ +\ +\ +] +) +\ +\ +\ +| +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +\ +[ +( +[ +^ +\ +] +] +* +) +" +consistent +! +( +editorconfig_2 +r +" +\ +[ +( +[ +^ +\ +] +] +* +) +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +\ +[ +( +. +* +/ +. +* +) +\ +] +" +consistent +! +( +editorconfig_3 +r +" +\ +[ +( +. +* +/ +. +* +) +\ +] +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +\ +{ +( +- +? +\ +d ++ +\ +\ +\ +. +\ +\ +\ +. +- +? +\ +d ++ +) +\ +} +" +consistent +! +( +editorconfig_4 +r +" +\ +{ +( +- +? +\ +d ++ +\ +\ +\ +. +\ +\ +\ +. +- +? +\ +d ++ +) +\ +} +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +\ +{ +( +[ +^ +] ++ +) +\ +} +" +consistent +! +( +editorconfig_5 +r +" +\ +{ +( +[ +^ +] ++ +) +\ +} +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +\ +{ +( +( +[ +^ +\ +} +] +. +* +) +? +( +| +\ +| +) +( +. +* +[ +^ +\ +\ +] +) +? +) +\ +} +" +consistent +! +( +editorconfig_6 +r +" +\ +{ +( +( +[ +^ +\ +} +] +. +* +) +? +( +| +\ +| +) +( +. +* +[ +^ +\ +\ +] +) +? +) +\ +} +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +^ +/ +" +consistent +! +( +editorconfig_7 +r +" +^ +/ +" +) +; +/ +/ +editorconfig +- +1 +. +0 +. +0 +: +r +" +( +^ +| +[ +^ +\ +\ +] +) +( +\ +{ +| +\ +} +) +" +consistent +! +( +editorconfig_8 +r +" +( +^ +| +[ +^ +\ +\ +] +) +( +\ +{ +| +\ +} +) +" +) +; +/ +/ +edmunge +- +1 +. +0 +. +0 +: +" +^ +# +! +. +* +\ +n +" +consistent +! +( +edmunge_0 +" +^ +# +! +. +* +\ +n +" +) +; +/ +/ +unicode_names2_macros +- +0 +. +2 +. +0 +: +r +" +\ +\ +N +\ +{ +( +. +* +? +) +( +? +: +\ +} +| +) +" +consistent +! +( +unicode_names2_macros_0 +r +" +\ +\ +N +\ +{ +( +. +* +? +) +( +? +: +\ +} +| +) +" +) +; +/ +/ +unidiff +- +0 +. +2 +. +1 +: +r +" +^ +- +- +- +( +? +P +< +filename +> +[ +^ +\ +t +\ +n +] ++ +) +( +? +: +\ +t +( +? +P +< +timestamp +> +[ +^ +\ +n +] ++ +) +) +? +" +consistent +! +( +unidiff_0 +r +" +^ +- +- +- +( +? +P +< +filename +> +[ +^ +\ +t +\ +n +] ++ +) +( +? +: +\ +t +( +? +P +< +timestamp +> +[ +^ +\ +n +] ++ +) +) +? +" +) +; +/ +/ +unidiff +- +0 +. +2 +. +1 +: +r +" +^ +\ ++ +\ ++ +\ ++ +( +? +P +< +filename +> +[ +^ +\ +t +\ +n +] ++ +) +( +? +: +\ +t +( +? +P +< +timestamp +> +[ +^ +\ +n +] ++ +) +) +? +" +consistent +! +( +unidiff_1 +r +" +^ +\ ++ +\ ++ +\ ++ +( +? +P +< +filename +> +[ +^ +\ +t +\ +n +] ++ +) +( +? +: +\ +t +( +? +P +< +timestamp +> +[ +^ +\ +n +] ++ +) +) +? +" +) +; +/ +/ +unidiff +- +0 +. +2 +. +1 +: +r +" +^ +- +( +\ +d ++ +) +( +? +: +( +\ +d ++ +) +) +? +\ ++ +( +\ +d ++ +) +( +? +: +( +\ +d ++ +) +) +? +[ +] +? +( +. +* +) +" +consistent +! +( +unidiff_2 +r +" +^ +- +( +\ +d ++ +) +( +? +: +( +\ +d ++ +) +) +? +\ ++ +( +\ +d ++ +) +( +? +: +( +\ +d ++ +) +) +? +[ +] +? +( +. +* +) +" +) +; +/ +/ +unidiff +- +0 +. +2 +. +1 +: +r +" +^ +( +? +P +< +line_type +> +[ +- +\ +n +\ ++ +\ +\ +] +? +) +( +? +P +< +value +> +. +* +) +" +consistent +! +( +unidiff_3 +r +" +^ +( +? +P +< +line_type +> +[ +- +\ +n +\ ++ +\ +\ +] +? +) +( +? +P +< +value +> +. +* +) +" +) +; +/ +/ +slippy +- +map +- +tiles +- +0 +. +13 +. +1 +: +" +/ +? +( +? +P +< +zoom +> +[ +0 +- +9 +] +? +[ +0 +- +9 +] +) +/ +( +? +P +< +x +> +[ +0 +- +9 +] +{ +1 +10 +} +) +/ +( +? +P +< +y +> +[ +0 +- +9 +] +{ +1 +10 +} +) +( +\ +\ +. +[ +a +- +zA +- +Z +] +{ +3 +4 +} +) +? +" +consistent +! +( +slippy_map_tiles_0 +" +/ +? +( +? +P +< +zoom +> +[ +0 +- +9 +] +? +[ +0 +- +9 +] +) +/ +( +? +P +< +x +> +[ +0 +- +9 +] +{ +1 +10 +} +) +/ +( +? +P +< +y +> +[ +0 +- +9 +] +{ +1 +10 +} +) +( +\ +\ +. +[ +a +- +zA +- +Z +] +{ +3 +4 +} +) +? +" +) +; +/ +/ +slippy +- +map +- +tiles +- +0 +. +13 +. +1 +: +r +" +^ +( +? +P +< +minlon +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +minlat +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +maxlon +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +maxlat +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +" +consistent +! +( +slippy_map_tiles_1 +r +" +^ +( +? +P +< +minlon +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +minlat +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +maxlon +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +maxlat +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +" +) +; +/ +/ +slippy +- +map +- +tiles +- +0 +. +13 +. +1 +: +r +" +^ +( +? +P +< +minlon +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +minlat +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +maxlon +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +maxlat +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +" +consistent +! +( +slippy_map_tiles_2 +r +" +^ +( +? +P +< +minlon +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +minlat +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +maxlon +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +( +? +P +< +maxlat +> +- +? +[ +0 +- +9 +] +{ +1 +3 +} +( +\ +. +[ +0 +- +9 +] +{ +1 +10 +} +) +? +) +" +) +; +/ +/ +sonos +- +0 +. +1 +. +2 +: +r +" +^ +https +? +: +/ +/ +( +. ++ +? +) +: +1400 +/ +xml +" +consistent +! +( +sonos_0 +r +" +^ +https +? +: +/ +/ +( +. ++ +? +) +: +1400 +/ +xml +" +) +; +/ +/ +validator_derive +- +0 +. +7 +. +0 +: +r +" +^ +[ +a +- +z +] +{ +2 +} +" +consistent +! +( +validator_derive_0 +r +" +^ +[ +a +- +z +] +{ +2 +} +" +) +; +/ +/ +validator_derive +- +0 +. +7 +. +0 +: +r +" +[ +a +- +z +] +{ +2 +} +" +consistent +! +( +validator_derive_1 +r +" +[ +a +- +z +] +{ +2 +} +" +) +; +/ +/ +validator_derive +- +0 +. +7 +. +0 +: +r +" +[ +a +- +z +] +{ +2 +} +" +consistent +! +( +validator_derive_2 +r +" +[ +a +- +z +] +{ +2 +} +" +) +; +/ +/ +nginx +- +config +- +0 +. +8 +. +0 +: +r +" +one +of +\ +d ++ +options +" +consistent +! +( +nginx_config_0 +r +" +one +of +\ +d ++ +options +" +) +; +/ +/ +waltz +- +0 +. +4 +. +0 +: +r +" +[ +\ +s +] +" +consistent +! +( +waltz_0 +r +" +[ +\ +s +] +" +) +; +/ +/ +warheadhateus +- +0 +. +2 +. +1 +: +r +" +^ +aws_access_key_id += +( +. +* +) +" +consistent +! +( +warheadhateus_0 +r +" +^ +aws_access_key_id += +( +. +* +) +" +) +; +/ +/ +warheadhateus +- +0 +. +2 +. +1 +: +r +" +^ +aws_secret_access_key += +( +. +* +) +" +consistent +! +( +warheadhateus_1 +r +" +^ +aws_secret_access_key += +( +. +* +) +" +) +; +/ +/ +warheadhateus +- +0 +. +2 +. +1 +: +r +" +^ +aws_access_key_id += +( +. +* +) +" +consistent +! +( +warheadhateus_2 +r +" +^ +aws_access_key_id += +( +. +* +) +" +) +; +/ +/ +warheadhateus +- +0 +. +2 +. +1 +: +r +" +^ +aws_secret_access_key += +( +. +* +) +" +consistent +! +( +warheadhateus_3 +r +" +^ +aws_secret_access_key += +( +. +* +) +" +) +; +/ +/ +jieba +- +rs +- +0 +. +2 +. +2 +: +r +" +( +[ +\ +u +{ +4E00 +} +- +\ +u +{ +9FD5 +} +a +- +zA +- +Z0 +- +9 ++ +# +& +\ +. +_ +% +] ++ +) +" +consistent +! +( +jieba_rs_0 +r +" +( +[ +\ +u +{ +4E00 +} +- +\ +u +{ +9FD5 +} +a +- +zA +- +Z0 +- +9 ++ +# +& +\ +. +_ +% +] ++ +) +" +) +; +/ +/ +jieba +- +rs +- +0 +. +2 +. +2 +: +r +" +( +\ +r +\ +n +| +\ +s +) +" +consistent +! +( +jieba_rs_1 +r +" +( +\ +r +\ +n +| +\ +s +) +" +) +; +/ +/ +jieba +- +rs +- +0 +. +2 +. +2 +: +" +( +[ +\ +u +{ +4E00 +} +- +\ +u +{ +9FD5 +} +] ++ +) +" +consistent +! +( +jieba_rs_2 +" +( +[ +\ +u +{ +4E00 +} +- +\ +u +{ +9FD5 +} +] ++ +) +" +) +; +/ +/ +jieba +- +rs +- +0 +. +2 +. +2 +: +r +" +[ +^ +a +- +zA +- +Z0 +- +9 ++ +# +\ +n +] +" +consistent +! +( +jieba_rs_3 +r +" +[ +^ +a +- +zA +- +Z0 +- +9 ++ +# +\ +n +] +" +) +; +/ +/ +jieba +- +rs +- +0 +. +2 +. +2 +: +r +" +( +[ +\ +u +{ +4E00 +} +- +\ +u +{ +9FD5 +} +] ++ +) +" +consistent +! +( +jieba_rs_4 +r +" +( +[ +\ +u +{ +4E00 +} +- +\ +u +{ +9FD5 +} +] ++ +) +" +) +; +/ +/ +jieba +- +rs +- +0 +. +2 +. +2 +: +r +" +( +[ +a +- +zA +- +Z0 +- +9 +] ++ +( +? +: +. +\ +d ++ +) +? +% +? +) +" +consistent +! +( +jieba_rs_5 +r +" +( +[ +a +- +zA +- +Z0 +- +9 +] ++ +( +? +: +. +\ +d ++ +) +? +% +? +) +" +) +; +/ +/ +lalrpop +- +0 +. +15 +. +2 +: +r +" +Span +\ +( +[ +0 +- +9 +] +* +\ +) +" +consistent +! +( +lalrpop_0 +r +" +Span +\ +( +[ +0 +- +9 +] +* +\ +) +" +) +; +/ +/ +lalrpop +- +snap +- +0 +. +15 +. +2 +: +r +" +Span +\ +( +[ +0 +- +9 +] +* +\ +) +" +consistent +! +( +lalrpop_snap_0 +r +" +Span +\ +( +[ +0 +- +9 +] +* +\ +) +" +) +; +/ +/ +nlp +- +tokenize +- +0 +. +1 +. +0 +: +r +" +[ +\ +S +] ++ +" +consistent +! +( +nlp_tokenize_0 +r +" +[ +\ +S +] ++ +" +) +; +/ +/ +kbgpg +- +0 +. +1 +. +2 +: +" +[ +[ +: +xdigit +: +] +] +[ +70 +] +" +consistent +! +( +kbgpg_0 +" +[ +[ +: +xdigit +: +] +] +[ +70 +] +" +) +; +/ +/ +cdbd +- +0 +. +1 +. +1 +: +r +" +^ +( +( +? +P +< +address +> +. +* +) +: +) +? +( +? +P +< +port +> +\ +d ++ +) +" +consistent +! +( +cdbd_0 +r +" +^ +( +( +? +P +< +address +> +. +* +) +: +) +? +( +? +P +< +port +> +\ +d ++ +) +" +) +; +/ +/ +mbutiles +- +0 +. +1 +. +1 +: +r +" +[ +\ +w +\ +s += ++ +- +/ +] ++ +\ +( +( +\ +{ +( +. +| +\ +n +) +* +\ +} +) +\ +) +; +? +" +consistent +! +( +mbutiles_0 +r +" +[ +\ +w +\ +s += ++ +- +/ +] ++ +\ +( +( +\ +{ +( +. +| +\ +n +) +* +\ +} +) +\ +) +; +? +" +) +; +/ +/ +extrahop +- +0 +. +2 +. +5 +: +r +" +^ +- +\ +d ++ +( +? +: +ms +| +s +| +m +| +h +| +d +| +w +| +y +) +? +" +consistent +! +( +extrahop_0 +r +" +^ +- +\ +d ++ +( +? +: +ms +| +s +| +m +| +h +| +d +| +w +| +y +) +? +" +) +; +/ +/ +pippin +- +0 +. +1 +. +0 +: +" +^ +( +( +? +: +. +* +) +- +) +? +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +pip +" +consistent +! +( +pippin_0 +" +^ +( +( +? +: +. +* +) +- +) +? +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +pip +" +) +; +/ +/ +pippin +- +0 +. +1 +. +0 +: +" +^ +( +( +? +: +. +* +) +- +) +? +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +- +cl +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +piplog +" +consistent +! +( +pippin_1 +" +^ +( +( +? +: +. +* +) +- +) +? +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +- +cl +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +piplog +" +) +; +/ +/ +pippin +- +0 +. +1 +. +0 +: +" +^ +( +( +? +: +. +* +) +- +) +? +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +pip +" +consistent +! +( +pippin_2 +" +^ +( +( +? +: +. +* +) +- +) +? +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +pip +" +) +; +/ +/ +pippin +- +0 +. +1 +. +0 +: +" +^ +( +( +? +: +. +* +) +- +) +? +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +- +cl +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +piplog +" +consistent +! +( +pippin_3 +" +^ +( +( +? +: +. +* +) +- +) +? +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +- +cl +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +piplog +" +) +; +/ +/ +pippin +- +0 +. +1 +. +0 +: +" +^ +. +* +pn +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +( +- +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +( +\ +\ +. +pip +| +- +cl +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +piplog +) +) +? +" +consistent +! +( +pippin_4 +" +^ +. +* +pn +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +( +- +ss +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +( +\ +\ +. +pip +| +- +cl +( +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +piplog +) +) +? +" +) +; +/ +/ +pippin +- +0 +. +1 +. +0 +: +" +^ +( +. +* +) +- +ss +( +? +: +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +( +? +: +\ +\ +. +pip +| +- +cl +( +? +: +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +piplog +) +" +consistent +! +( +pippin_5 +" +^ +( +. +* +) +- +ss +( +? +: +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +( +? +: +\ +\ +. +pip +| +- +cl +( +? +: +0 +| +[ +1 +- +9 +] +[ +0 +- +9 +] +* +) +\ +\ +. +piplog +) +" +) +; +/ +/ +pinyin +- +0 +. +3 +. +0 +: +r +" +( +? +i +) +[ +] +" +consistent +! +( +pinyin_0 +r +" +( +? +i +) +[ +] +" +) +; +/ +/ +pinyin +- +0 +. +3 +. +0 +: +r +" +( +[ +aeoiuvnm +] +) +( +[ +0 +- +4 +] +) +" +consistent +! +( +pinyin_1 +r +" +( +[ +aeoiuvnm +] +) +( +[ +0 +- +4 +] +) +" +) +; +/ +/ +duration +- +parser +- +0 +. +2 +. +0 +: +r +" +( +? +P +< +value +> +\ +d ++ +) +( +? +P +< +units +> +[ +a +- +z +] +) +" +consistent +! +( +duration_parser_0 +r +" +( +? +P +< +value +> +\ +d ++ +) +( +? +P +< +units +> +[ +a +- +z +] +) +" +) +; +/ +/ +dutree +- +0 +. +2 +. +7 +: +r +" +^ +\ +d ++ +\ +D +? +" +consistent +! +( +dutree_0 +r +" +^ +\ +d ++ +\ +D +? +" +) +; +/ +/ +djangohashers +- +0 +. +3 +. +0 +: +r +" +^ +[ +A +- +Za +- +z0 +- +9 +] +* +" +consistent +! +( +djangohashers_0 +r +" +^ +[ +A +- +Za +- +z0 +- +9 +] +* +" +) +; +/ +/ +rtag +- +0 +. +3 +. +5 +: +r +" +^ +[ +A +- +Z +] +[ +A +- +Z0 +- +9 +] +{ +2 +} +" +consistent +! +( +rtag_0 +r +" +^ +[ +A +- +Z +] +[ +A +- +Z0 +- +9 +] +{ +2 +} +" +) +; +/ +/ +rtag +- +0 +. +3 +. +5 +: +r +" +^ +http +: +/ +/ +www +\ +. +emusic +\ +. +com +" +consistent +! +( +rtag_1 +r +" +^ +http +: +/ +/ +www +\ +. +emusic +\ +. +com +" +) +; +/ +/ +rtag +- +0 +. +3 +. +5 +: +r +" +^ +[ +A +- +Z +] +[ +A +- +Z0 +- +9 +] +{ +2 +} +" +consistent +! +( +rtag_2 +r +" +^ +[ +A +- +Z +] +[ +A +- +Z0 +- +9 +] +{ +2 +} +" +) +; +/ +/ +rtag +- +0 +. +3 +. +5 +: +r +" +( +^ +[ +\ +x +{ +0 +} +| +\ +x +{ +feff +} +| +\ +x +{ +fffe +} +] +* +| +[ +\ +x +{ +0 +} +| +\ +x +{ +feff +} +| +\ +x +{ +fffe +} +] +* +) +" +consistent +! +( +rtag_3 +r +" +( +^ +[ +\ +x +{ +0 +} +| +\ +x +{ +feff +} +| +\ +x +{ +fffe +} +] +* +| +[ +\ +x +{ +0 +} +| +\ +x +{ +feff +} +| +\ +x +{ +fffe +} +] +* +) +" +) +; +/ +/ +rtow +- +0 +. +1 +. +0 +: +r +" +( +\ +d ++ +) +[ +xX +] +( +\ +d ++ +) +" +consistent +! +( +rtow_0 +r +" +( +\ +d ++ +) +[ +xX +] +( +\ +d ++ +) +" +) +; +/ +/ +pleingres +- +sql +- +plugin +- +0 +. +1 +. +0 +: +r +" +\ +( +[ +a +- +zA +- +Z0 +- +9_ +] ++ +) +" +consistent +! +( +pleingres_sql_plugin_0 +r +" +\ +( +[ +a +- +zA +- +Z0 +- +9_ +] ++ +) +" +) +; +/ +/ +dono +- +2 +. +0 +. +0 +: +" +[ +\ +\ +n +] ++ +" +consistent +! +( +dono_0 +" +[ +\ +\ +n +] ++ +" +) +; +/ +/ +dono +- +2 +. +0 +. +0 +: +" +( +? +m +) +^ +\ +\ +n +" +consistent +! +( +dono_1 +" +( +? +m +) +^ +\ +\ +n +" +) +; +/ +/ +dono +- +2 +. +0 +. +0 +: +" +( +? +m +) +^ +\ +\ +n +" +consistent +! +( +dono_2 +" +( +? +m +) +^ +\ +\ +n +" +) +; +/ +/ +ssb +- +common +- +0 +. +3 +. +0 +: +r +" +^ +[ +0 +- +9A +- +Za +- +z +\ ++ +/ +] +{ +43 +} += +\ +. +ed25519 +" +consistent +! +( +ssb_common_0 +r +" +^ +[ +0 +- +9A +- +Za +- +z +\ ++ +/ +] +{ +43 +} += +\ +. +ed25519 +" +) +; +/ +/ +ssb +- +common +- +0 +. +3 +. +0 +: +r +" +^ +[ +0 +- +9A +- +Za +- +z +\ ++ +/ +] +{ +86 +} += += +\ +. +ed25519 +" +consistent +! +( +ssb_common_1 +r +" +^ +[ +0 +- +9A +- +Za +- +z +\ ++ +/ +] +{ +86 +} += += +\ +. +ed25519 +" +) +; +/ +/ +ssb +- +common +- +0 +. +3 +. +0 +: +r +" +^ +[ +0 +- +9A +- +Za +- +z +\ ++ +/ +] +{ +43 +} += +\ +. +sha256 +" +consistent +! +( +ssb_common_2 +r +" +^ +[ +0 +- +9A +- +Za +- +z +\ ++ +/ +] +{ +43 +} += +\ +. +sha256 +" +) +; +/ +/ +mozversion +- +0 +. +1 +. +3 +: +r +" +^ +( +? +P +< +major +> +\ +d ++ +) +\ +. +( +? +P +< +minor +> +\ +d ++ +) +( +? +: +\ +. +( +? +P +< +patch +> +\ +d ++ +) +) +? +( +? +: +( +? +P +< +pre0 +> +[ +a +- +z +] ++ +) +( +? +P +< +pre1 +> +\ +d +* +) +) +? +" +consistent +! +( +mozversion_0 +r +" +^ +( +? +P +< +major +> +\ +d ++ +) +\ +. +( +? +P +< +minor +> +\ +d ++ +) +( +? +: +\ +. +( +? +P +< +patch +> +\ +d ++ +) +) +? +( +? +: +( +? +P +< +pre0 +> +[ +a +- +z +] ++ +) +( +? +P +< +pre1 +> +\ +d +* +) +) +? +" +) +; +/ +/ +monger +- +0 +. +5 +. +6 +: +r +" +^ +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +" +consistent +! +( +monger_0 +r +" +^ +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +" +) +; +/ +/ +mongo_rub +- +0 +. +0 +. +2 +: +r +" +^ +[ +rv +] +2 +\ +. +6 +" +consistent +! +( +mongo_rub_0 +r +" +^ +[ +rv +] +2 +\ +. +6 +" +) +; +/ +/ +flow +- +0 +. +3 +. +5 +: +" +body +value +" +consistent +! +( +flow_0 +" +body +value +" +) +; +/ +/ +flow +- +0 +. +3 +. +5 +: +" +start +marker +" +consistent +! +( +flow_1 +" +start +marker +" +) +; +/ +/ +flow +- +0 +. +3 +. +5 +: +" +end +marker +" +consistent +! +( +flow_2 +" +end +marker +" +) +; +/ +/ +flow +- +0 +. +3 +. +5 +: +" +body +value +" +consistent +! +( +flow_3 +" +body +value +" +) +; +/ +/ +vobsub +- +0 +. +2 +. +3 +: +" +^ +( +[ +A +- +Za +- +z +/ +] ++ +) +: +( +. +* +) +" +consistent +! +( +vobsub_0 +" +^ +( +[ +A +- +Za +- +z +/ +] ++ +) +: +( +. +* +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +( +[ +^ +\ +s += +] ++ +) +* +" +consistent +! +( +voidmap_0 +r +" +# +( +[ +^ +\ +s += +] ++ +) +* +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +( +\ +S ++ +) +* +" +consistent +! +( +voidmap_1 +r +" +# +( +\ +S ++ +) +* +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +prio += +( +\ +d ++ +) +" +consistent +! +( +voidmap_2 +r +" +# +prio += +( +\ +d ++ +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +\ +[ +( +\ +S ++ +) +\ +] +" +consistent +! +( +voidmap_3 +r +" +\ +[ +( +\ +S ++ +) +\ +] +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +limit += +( +\ +d ++ +) +" +consistent +! +( +voidmap_4 +r +" +# +limit += +( +\ +d ++ +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +tagged += +( +\ +S ++ +) +" +consistent +! +( +voidmap_5 +r +" +# +tagged += +( +\ +S ++ +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +rev +\ +b +" +consistent +! +( +voidmap_6 +r +" +# +rev +\ +b +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +done +\ +b +" +consistent +! +( +voidmap_7 +r +" +# +done +\ +b +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +open +\ +b +" +consistent +! +( +voidmap_8 +r +" +# +open +\ +b +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +since += +( +\ +S ++ +) +" +consistent +! +( +voidmap_9 +r +" +# +since += +( +\ +S ++ +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +until += +( +\ +S ++ +) +" +consistent +! +( +voidmap_10 +r +" +# +until += +( +\ +S ++ +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +plot += +( +\ +S ++ +) +" +consistent +! +( +voidmap_11 +r +" +# +plot += +( +\ +S ++ +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +# +n += +( +\ +d ++ +) +" +consistent +! +( +voidmap_12 +r +" +# +n += +( +\ +d ++ +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +( +\ +S ++ +) +" +consistent +! +( +voidmap_13 +r +" +( +\ +S ++ +) +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +( +? +P +< +y +> +\ +d ++ +) +y +" +consistent +! +( +voidmap_14 +r +" +( +? +P +< +y +> +\ +d ++ +) +y +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +( +? +P +< +m +> +\ +d ++ +) +m +" +consistent +! +( +voidmap_15 +r +" +( +? +P +< +m +> +\ +d ++ +) +m +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +( +? +P +< +w +> +\ +d ++ +) +w +" +consistent +! +( +voidmap_16 +r +" +( +? +P +< +w +> +\ +d ++ +) +w +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +( +? +P +< +d +> +\ +d ++ +) +d +" +consistent +! +( +voidmap_17 +r +" +( +? +P +< +d +> +\ +d ++ +) +d +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +( +? +P +< +h +> +\ +d ++ +) +h +" +consistent +! +( +voidmap_18 +r +" +( +? +P +< +h +> +\ +d ++ +) +h +" +) +; +/ +/ +voidmap +- +1 +. +1 +. +2 +: +r +" +C +- +( +. +) +" +consistent +! +( +voidmap_19 +r +" +C +- +( +. +) +" +) +; +/ +/ +qt_generator +- +0 +. +2 +. +0 +: +r +" +^ +\ +. +\ +. +/ +qt +[ +^ +/ +] ++ +/ +" +consistent +! +( +qt_generator_0 +r +" +^ +\ +. +\ +. +/ +qt +[ +^ +/ +] ++ +/ +" +) +; +/ +/ +qt_generator +- +0 +. +2 +. +0 +: +" +( +href +| +src +) += +\ +" +( +[ +^ +\ +" +] +* +) +\ +" +" +consistent +! +( +qt_generator_1 +" +( +href +| +src +) += +\ +" +( +[ +^ +\ +" +] +* +) +\ +" +" +) +; +/ +/ +kryptos +- +0 +. +6 +. +1 +: +r +" +[ +01 +] +{ +5 +} +" +consistent +! +( +kryptos_0 +r +" +[ +01 +] +{ +5 +} +" +) +; +/ +/ +cifar_10_loader +- +0 +. +2 +. +0 +: +" +data_batch_ +[ +1 +- +5 +] +. +bin +" +consistent +! +( +cifar_10_loader_0 +" +data_batch_ +[ +1 +- +5 +] +. +bin +" +) +; +/ +/ +cifar_10_loader +- +0 +. +2 +. +0 +: +" +test_batch +. +bin +" +consistent +! +( +cifar_10_loader_1 +" +test_batch +. +bin +" +) +; +/ +/ +circadian +- +0 +. +6 +. +0 +: +r +" +^ +\ +d ++ +. +\ +d ++ +s +" +consistent +! +( +circadian_0 +r +" +^ +\ +d ++ +. +\ +d ++ +s +" +) +; +/ +/ +circadian +- +0 +. +6 +. +0 +: +r +" +^ +\ +d ++ +: +\ +d ++ +" +consistent +! +( +circadian_1 +r +" +^ +\ +d ++ +: +\ +d ++ +" +) +; +/ +/ +circadian +- +0 +. +6 +. +0 +: +r +" +^ +\ +d ++ +: +\ +d ++ +m +" +consistent +! +( +circadian_2 +r +" +^ +\ +d ++ +: +\ +d ++ +m +" +) +; +/ +/ +cicada +- +0 +. +8 +. +1 +: +r +" +! +! +" +consistent +! +( +cicada_0 +r +" +! +! +" +) +; +/ +/ +cicada +- +0 +. +8 +. +1 +: +r +" +^ +( +[ +^ +] +* +) +( +[ +^ +] ++ +) +( +. +* +) +" +consistent +! +( +cicada_1 +r +" +^ +( +[ +^ +] +* +) +( +[ +^ +] ++ +) +( +. +* +) +" +) +; +/ +/ +cicada +- +0 +. +8 +. +1 +: +r +" +\ +* ++ +" +consistent +! +( +cicada_2 +r +" +\ +* ++ +" +) +; +/ +/ +cicada +- +0 +. +8 +. +1 +: +r +" +( +[ +^ +\ +] +* +) +\ +\ +{ +? +( +[ +A +- +Za +- +z0 +- +9 +\ +? +\ +_ +] ++ +) +\ +} +? +( +. +* +) +" +consistent +! +( +cicada_3 +r +" +( +[ +^ +\ +] +* +) +\ +\ +{ +? +( +[ +A +- +Za +- +z0 +- +9 +\ +? +\ +_ +] ++ +) +\ +} +? +( +. +* +) +" +) +; +/ +/ +cicada +- +0 +. +8 +. +1 +: +r +" +^ +* +alias ++ +( +[ +a +- +zA +- +Z0 +- +9_ +\ +. +- +] ++ +) += +( +. +* +) +" +consistent +! +( +cicada_4 +r +" +^ +* +alias ++ +( +[ +a +- +zA +- +Z0 +- +9_ +\ +. +- +] ++ +) += +( +. +* +) +" +) +; +/ +/ +vterm +- +sys +- +0 +. +1 +. +0 +: +r +" +hi +" +consistent +! +( +vterm_sys_0 +r +" +hi +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" +. +* +? +\ +t +" +consistent +! +( +skim_0 +r +" +. +* +? +\ +t +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" +. +* +? +[ +\ +t +] +" +consistent +! +( +skim_1 +r +" +. +* +? +[ +\ +t +] +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" +( +\ +{ +- +? +[ +0 +- +9 +. +q +] +* +? +} +) +" +consistent +! +( +skim_2 +r +" +( +\ +{ +- +? +[ +0 +- +9 +. +q +] +* +? +} +) +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" +[ +\ +t +\ +n +] ++ +" +consistent +! +( +skim_3 +r +" +[ +\ +t +\ +n +] ++ +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" +[ +\ +t +\ +n +] ++ +" +consistent +! +( +skim_4 +r +" +[ +\ +t +\ +n +] ++ +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" +( +[ +^ +| +] ++ +( ++ +\ +| ++ +[ +^ +| +] +* +) ++ +) +| +( ++ +) +" +consistent +! +( +skim_5 +r +" +( +[ +^ +| +] ++ +( ++ +\ +| ++ +[ +^ +| +] +* +) ++ +) +| +( ++ +) +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" ++ +\ +| ++ +" +consistent +! +( +skim_6 +r +" ++ +\ +| ++ +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" +^ +( +? +P +< +left +> +- +? +\ +d ++ +) +? +( +? +P +< +sep +> +\ +. +\ +. +) +? +( +? +P +< +right +> +- +? +\ +d ++ +) +? +" +consistent +! +( +skim_7 +r +" +^ +( +? +P +< +left +> +- +? +\ +d ++ +) +? +( +? +P +< +sep +> +\ +. +\ +. +) +? +( +? +P +< +right +> +- +? +\ +d ++ +) +? +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +" +" +consistent +! +( +skim_8 +" +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +" +. +* +? +" +consistent +! +( +skim_9 +" +. +* +? +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +" +. +* +? +" +consistent +! +( +skim_10 +" +. +* +? +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +" +" +consistent +! +( +skim_11 +" +" +) +; +/ +/ +skim +- +0 +. +5 +. +0 +: +r +" +\ +x1B +\ +[ +( +? +: +( +[ +0 +- +9 +] ++ +; +[ +0 +- +9 +] ++ +[ +Hf +] +) +| +( +[ +0 +- +9 +] ++ +[ +ABCD +] +) +| +( +s +| +u +| +2J +| +K +) +| +( +[ +0 +- +9 +; +] +* +m +) +| +( += +[ +0 +- +9 +] ++ +[ +hI +] +) +) +" +consistent +! +( +skim_12 +r +" +\ +x1B +\ +[ +( +? +: +( +[ +0 +- +9 +] ++ +; +[ +0 +- +9 +] ++ +[ +Hf +] +) +| +( +[ +0 +- +9 +] ++ +[ +ABCD +] +) +| +( +s +| +u +| +2J +| +K +) +| +( +[ +0 +- +9 +; +] +* +m +) +| +( += +[ +0 +- +9 +] ++ +[ +hI +] +) +) +" +) +; +/ +/ +egg +- +mode +- +text +- +1 +. +14 +. +7 +: +r +" +[ +- +_ +. +/ +] +\ +z +" +consistent +! +( +egg_mode_text_0 +r +" +[ +- +_ +. +/ +] +\ +z +" +) +; +/ +/ +java +- +properties +- +1 +. +1 +. +1 +: +" +^ +[ +\ +t +\ +r +\ +n +\ +x0c +] +* +[ +# +! +] +" +consistent +! +( +java_properties_0 +" +^ +[ +\ +t +\ +r +\ +n +\ +x0c +] +* +[ +# +! +] +" +) +; +/ +/ +java +- +properties +- +1 +. +1 +. +1 +: +r +" +^ +[ +\ +t +\ +x0c +] +* +[ +# +! +] +[ +^ +\ +r +\ +n +] +* +" +consistent +! +( +java_properties_1 +r +" +^ +[ +\ +t +\ +x0c +] +* +[ +# +! +] +[ +^ +\ +r +\ +n +] +* +" +) +; +/ +/ +java +- +properties +- +1 +. +1 +. +1 +: +r +" +^ +( +[ +\ +t +\ +x0c +] +* +[ +: += +] +[ +\ +t +\ +x0c +] +* +| +[ +\ +t +\ +x0c +] ++ +) +" +consistent +! +( +java_properties_2 +r +" +^ +( +[ +\ +t +\ +x0c +] +* +[ +: += +] +[ +\ +t +\ +x0c +] +* +| +[ +\ +t +\ +x0c +] ++ +) +" +) +; +/ +/ +ipaddress +- +0 +. +1 +. +2 +: +r +" +: +. ++ +\ +. +" +consistent +! +( +ipaddress_0 +r +" +: +. ++ +\ +. +" +) +; +/ +/ +ipaddress +- +0 +. +1 +. +2 +: +r +" +\ +. +" +consistent +! +( +ipaddress_1 +r +" +\ +. +" +) +; +/ +/ +ipaddress +- +0 +. +1 +. +2 +: +r +" +: +" +consistent +! +( +ipaddress_2 +r +" +: +" +) +; +/ +/ +iptables +- +0 +. +2 +. +2 +: +r +" +v +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +" +consistent +! +( +iptables_0 +r +" +v +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +\ +. +( +\ +d ++ +) +" +) +; +/ +/ +rsure +- +0 +. +8 +. +1 +: +r +" +^ +( +[ +^ +- +] ++ +) +- +( +. +* +) +\ +. +dat +\ +. +gz +" +consistent +! +( +rsure_0 +r +" +^ +( +[ +^ +- +] ++ +) +- +( +. +* +) +\ +. +dat +\ +. +gz +" +) +; +/ +/ +rs +- +jsonpath +- +0 +. +1 +. +0 +: +" +^ +( +. +* +? +) +( +< += +| +< +| += += +| +> += +| +> +) +( +. +* +? +) +" +consistent +! +( +rs_jsonpath_0 +" +^ +( +. +* +? +) +( +< += +| +< +| += += +| +> += +| +> +) +( +. +* +? +) +" +) +; +/ +/ +oatie +- +0 +. +3 +. +0 +: +r +" +( +\ +n +| +^ +) +( +\ +w ++ +) +: +( +[ +\ +n +\ +w +\ +W +] ++ +? +) +( +\ +n +( +? +: +\ +w +) +| +( +\ +n +\ +] +) +) +" +consistent +! +( +oatie_0 +r +" +( +\ +n +| +^ +) +( +\ +w ++ +) +: +( +[ +\ +n +\ +w +\ +W +] ++ +? +) +( +\ +n +( +? +: +\ +w +) +| +( +\ +n +\ +] +) +) +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +" +# +. +* +" +consistent +! +( +weld_0 +" +# +. +* +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +[ +A +- +Za +- +z +_ +] +[ +A +- +Za +- +z0 +- +9 +_ +] +* +" +consistent +! +( +weld_1 +r +" +^ +[ +A +- +Za +- +z +_ +] +[ +A +- +Za +- +z0 +- +9 +_ +] +* +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +[ +0 +- +9 +] ++ +[ +cC +] +" +consistent +! +( +weld_2 +r +" +^ +[ +0 +- +9 +] ++ +[ +cC +] +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +0b +[ +0 +- +1 +] ++ +[ +cC +] +" +consistent +! +( +weld_3 +r +" +^ +0b +[ +0 +- +1 +] ++ +[ +cC +] +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +0x +[ +0 +- +9a +- +fA +- +F +] ++ +[ +cC +] +" +consistent +! +( +weld_4 +r +" +^ +0x +[ +0 +- +9a +- +fA +- +F +] ++ +[ +cC +] +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +[ +0 +- +9 +] ++ +" +consistent +! +( +weld_5 +r +" +^ +[ +0 +- +9 +] ++ +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +0b +[ +0 +- +1 +] ++ +" +consistent +! +( +weld_6 +r +" +^ +0b +[ +0 +- +1 +] ++ +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +0x +[ +0 +- +9a +- +fA +- +F +] ++ +" +consistent +! +( +weld_7 +r +" +^ +0x +[ +0 +- +9a +- +fA +- +F +] ++ +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +[ +0 +- +9 +] ++ +[ +lL +] +" +consistent +! +( +weld_8 +r +" +^ +[ +0 +- +9 +] ++ +[ +lL +] +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +0b +[ +0 +- +1 +] ++ +[ +lL +] +" +consistent +! +( +weld_9 +r +" +^ +0b +[ +0 +- +1 +] ++ +[ +lL +] +" +) +; +/ +/ +weld +- +0 +. +2 +. +0 +: +r +" +^ +0x +[ +0 +- +9a +- +fA +- +F +] ++ +[ +lL +] +" +consistent +! +( +weld_10 +r +" +^ +0x +[ +0 +- +9a +- +fA +- +F +] ++ +[ +lL +] +" +) +; +/ +/ +webgl_generator +- +0 +. +1 +. +0 +: +" +( +[ +( +] +) +enum +\ +\ +b +" +consistent +! +( +webgl_generator_0 +" +( +[ +( +] +) +enum +\ +\ +b +" +) +; +/ +/ +webgl_generator +- +0 +. +1 +. +0 +: +" +\ +\ +bAcquireResourcesCallback +\ +\ +b +" +consistent +! +( +webgl_generator_1 +" +\ +\ +bAcquireResourcesCallback +\ +\ +b +" +) +; +/ +/ +weave +- +0 +. +2 +. +0 +: +r +" +^ +( +\ +d ++ +) +( +( +\ +d ++ +) +) +? +( +[ +acd +] +) +. +* +" +consistent +! +( +weave_0 +r +" +^ +( +\ +d ++ +) +( +( +\ +d ++ +) +) +? +( +[ +acd +] +) +. +* +" +) +; +/ +/ +wemo +- +0 +. +0 +. +12 +: +r +" +< +BinaryState +> +( +\ +d +) +( +\ +| +- +? +\ +d ++ +) +* +< +/ +BinaryState +> +" +consistent +! +( +wemo_0 +r +" +< +BinaryState +> +( +\ +d +) +( +\ +| +- +? +\ +d ++ +) +* +< +/ +BinaryState +> +" +) +; +/ +/ +webscale +- +0 +. +9 +. +4 +: +r +" +( +http +[ +s +] +? +: +/ +/ +[ +^ +\ +s +] ++ +) +" +consistent +! +( +webscale_0 +r +" +( +http +[ +s +] +? +: +/ +/ +[ +^ +\ +s +] ++ +) +" +) +; +/ +/ +svgrep +- +1 +. +1 +. +0 +: +r +" +^ +\ +d ++ +. +* +" +consistent +! +( +svgrep_0 +r +" +^ +\ +d ++ +. +* +" +) +; +/ +/ +ignore +- +0 +. +4 +. +2 +: +r +" +^ +[ +\ +pL +\ +pN +] ++ +" +consistent +! +( +ignore_0 +r +" +^ +[ +\ +pL +\ +pN +] ++ +" +) +; +/ +/ +ommui_string_patterns +- +0 +. +1 +. +2 +: +r +" +^ +( +[ +A +- +Za +- +z +] +[ +0 +- +9A +- +Za +- +z_ +] +* +) +? +" +consistent +! +( +ommui_string_patterns_0 +r +" +^ +( +[ +A +- +Za +- +z +] +[ +0 +- +9A +- +Za +- +z_ +] +* +) +? +" +) +; +/ +/ +ommui_string_patterns +- +0 +. +1 +. +2 +: +r +" +^ +( +\ +S ++ +( +? +: +. +* +\ +S +) +? +) +? +" +consistent +! +( +ommui_string_patterns_1 +r +" +^ +( +\ +S ++ +( +? +: +. +* +\ +S +) +? +) +? +" +) +; +/ +/ +opcua +- +types +- +0 +. +3 +. +0 +: +" +^ +( +? +P +< +min +> +[ +0 +- +9 +] +{ +1 +10 +} +) +( +: +( +? +P +< +max +> +[ +0 +- +9 +] +{ +1 +10 +} +) +) +? +" +consistent +! +( +opcua_types_0 +" +^ +( +? +P +< +min +> +[ +0 +- +9 +] +{ +1 +10 +} +) +( +: +( +? +P +< +max +> +[ +0 +- +9 +] +{ +1 +10 +} +) +) +? +" +) +; +/ +/ +opcua +- +types +- +0 +. +3 +. +0 +: +r +" +^ +( +ns += +( +? +P +< +ns +> +[ +0 +- +9 +] ++ +) +; +) +? +( +? +P +< +t +> +[ +isgb +] +) += +( +? +P +< +v +> +. ++ +) +" +consistent +! +( +opcua_types_1 +r +" +^ +( +ns += +( +? +P +< +ns +> +[ +0 +- +9 +] ++ +) +; +) +? +( +? +P +< +t +> +[ +isgb +] +) += +( +? +P +< +v +> +. ++ +) +" +) +; +/ +/ +open_read_later +- +1 +. +1 +. +1 +: +r +" +^ +( +. ++ +? +) +\ +s +* +: +\ +s +* +( +. ++ +) +" +consistent +! +( +open_read_later_0 +r +" +^ +( +. ++ +? +) +\ +s +* +: +\ +s +* +( +. ++ +) +" +) +; +/ +/ +youtube +- +downloader +- +0 +. +1 +. +0 +: +r +" +^ +. +* +( +? +: +( +? +: +youtu +\ +. +be +/ +| +v +/ +| +vi +/ +| +u +/ +w +/ +| +embed +/ +) +| +( +? +: +( +? +: +watch +) +? +\ +? +v +( +? +: +i +) +? += +| +\ +& +v +( +? +: +i +) +? += +) +) +( +[ +^ +# +\ +& +\ +? +] +* +) +. +* +" +consistent +! +( +youtube_downloader_0 +r +" +^ +. +* +( +? +: +( +? +: +youtu +\ +. +be +/ +| +v +/ +| +vi +/ +| +u +/ +w +/ +| +embed +/ +) +| +( +? +: +( +? +: +watch +) +? +\ +? +v +( +? +: +i +) +? += +| +\ +& +v +( +? +: +i +) +? += +) +) +( +[ +^ +# +\ +& +\ +? +] +* +) +. +* +" +) +; +/ +/ +yobot +- +0 +. +1 +. +1 +: +" +. +" +consistent +! +( +yobot_0 +" +. +" +) +; +/ +/ +yobot +- +0 +. +1 +. +1 +: +r +" +. +" +consistent +! +( +yobot_1 +r +" +. +" +) +; +/ +/ +yobot +- +0 +. +1 +. +1 +: +r +" +. ++ +" +consistent +! +( +yobot_2 +r +" +. ++ +" +) +; +/ +/ +yobot +- +0 +. +1 +. +1 +: +r +" +. +" +consistent +! +( +yobot_3 +r +" +. +" +) +; +/ +/ +ubiquity +- +0 +. +1 +. +5 +: +r +" +foo +" +consistent +! +( +ubiquity_0 +r +" +foo +" +) +; +/ +/ +ubiquity +- +0 +. +1 +. +5 +: +r +" +/ +target +/ +" +consistent +! +( +ubiquity_1 +r +" +/ +target +/ +" +) +; +/ +/ +ubiquity +- +0 +. +1 +. +5 +: +r +" +. +DS_Store +" +consistent +! +( +ubiquity_2 +r +" +. +DS_Store +" +) +; +/ +/ +qasm +- +1 +. +0 +. +0 +: +r +" +/ +/ +. +* +" +consistent +! +( +qasm_0 +r +" +/ +/ +. +* +" +) +; +/ +/ +drill +- +0 +. +3 +. +5 +: +r +" +\ +{ +\ +{ +* +( +[ +a +- +z +\ +. +_ +] ++ +) +* +\ +} +\ +} +" +consistent +! +( +drill_0 +r +" +\ +{ +\ +{ +* +( +[ +a +- +z +\ +. +_ +] ++ +) +* +\ +} +\ +} +" +) +; +/ +/ +queryst +- +2 +. +0 +. +0 +: +r +" +^ +( +[ +^ +\ +] +\ +[ +] ++ +) +" +consistent +! +( +queryst_0 +r +" +^ +( +[ +^ +\ +] +\ +[ +] ++ +) +" +) +; +/ +/ +queryst +- +2 +. +0 +. +0 +: +r +" +( +\ +[ +[ +^ +\ +] +\ +[ +] +* +\ +] +) +" +consistent +! +( +queryst_1 +r +" +( +\ +[ +[ +^ +\ +] +\ +[ +] +* +\ +] +) +" +) +; +/ +/ +qui +- +vive +- +0 +. +1 +. +0 +: +r +" +^ +/ +( +\ +w ++ +) +" +consistent +! +( +qui_vive_0 +r +" +^ +/ +( +\ +w ++ +) +" +) +; +/ +/ +qui +- +vive +- +0 +. +1 +. +0 +: +r +" +^ +/ +key +" +consistent +! +( +qui_vive_1 +r +" +^ +/ +key +" +) +; +/ +/ +qui +- +vive +- +0 +. +1 +. +0 +: +r +" +^ +/ +key +/ +( +\ +w ++ +) +" +consistent +! +( +qui_vive_2 +r +" +^ +/ +key +/ +( +\ +w ++ +) +" +) +; +/ +/ +qui +- +vive +- +0 +. +1 +. +0 +: +r +" +^ +/ +url +" +consistent +! +( +qui_vive_3 +r +" +^ +/ +url +" +) +; +/ +/ +qui +- +vive +- +0 +. +1 +. +0 +: +r +" +^ +/ +url +/ +( +\ +w ++ +) +" +consistent +! +( +qui_vive_4 +r +" +^ +/ +url +/ +( +\ +w ++ +) +" +) +; +/ +/ +qui +- +vive +- +0 +. +1 +. +0 +: +r +" +^ +/ +inv +" +consistent +! +( +qui_vive_5 +r +" +^ +/ +inv +" +) +; +/ +/ +qui +- +vive +- +0 +. +1 +. +0 +: +r +" +^ +/ +inv +/ +( +\ +w ++ +) +" +consistent +! +( +qui_vive_6 +r +" +^ +/ +inv +/ +( +\ +w ++ +) +" +) +; +/ +/ +subdiff +- +0 +. +1 +. +0 +: +r +" +\ +b +" +/ +/ +consistent +! +( +subdiff_0 +r +" +\ +b +" +) +; +/ +/ +substudy +- +0 +. +4 +. +5 +: +r +" +^ +( +\ +d ++ +) +/ +( +\ +d ++ +) +" +consistent +! +( +substudy_0 +r +" +^ +( +\ +d ++ +) +/ +( +\ +d ++ +) +" +) +; +/ +/ +substudy +- +0 +. +4 +. +5 +: +r +" +\ +s ++ +" +consistent +! +( +substudy_1 +r +" +\ +s ++ +" +) +; +/ +/ +substudy +- +0 +. +4 +. +5 +: +r +" +< +[ +a +- +z +/ +] +[ +^ +> +] +* +> +" +consistent +! +( +substudy_2 +r +" +< +[ +a +- +z +/ +] +[ +^ +> +] +* +> +" +) +; +/ +/ +substudy +- +0 +. +4 +. +5 +: +r +" +( +\ +( +[ +^ +) +] +* +\ +) +| +[ +^ +] +* +| +[ +A +- +Z +] +{ +2 +} +? +: +) +" +consistent +! +( +substudy_3 +r +" +( +\ +( +[ +^ +) +] +* +\ +) +| +[ +^ +] +* +| +[ +A +- +Z +] +{ +2 +} +? +: +) +" +) +; +/ +/ +substudy +- +0 +. +4 +. +5 +: +r +" +\ +s ++ +" +consistent +! +( +substudy_4 +r +" +\ +s ++ +" +) +; +/ +/ +isbnid +- +0 +. +1 +. +3 +: +r +" +^ +( +\ +d +( +- +| +) +? +) +{ +9 +} +( +x +| +X +| +\ +d +| +( +\ +d +( +- +| +) +? +) +{ +3 +} +\ +d +) +" +consistent +! +( +isbnid_0 +r +" +^ +( +\ +d +( +- +| +) +? +) +{ +9 +} +( +x +| +X +| +\ +d +| +( +\ +d +( +- +| +) +? +) +{ +3 +} +\ +d +) +" +) +; +/ +/ +isbnid +- +0 +. +1 +. +3 +: +r +" +[ +^ +0 +- +9X +] +" +consistent +! +( +isbnid_1 +r +" +[ +^ +0 +- +9X +] +" +) +; +/ +/ +ispc +- +0 +. +3 +. +5 +: +r +" +Intel +\ +( +r +\ +) +SPMD +Program +Compiler +\ +( +ispc +\ +) +( +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +) +" +consistent +! +( +ispc_0 +r +" +Intel +\ +( +r +\ +) +SPMD +Program +Compiler +\ +( +ispc +\ +) +( +\ +d ++ +\ +. +\ +d ++ +\ +. +\ +d ++ +) +" +) +; diff --git a/third_party/rust/regex/tests/crazy.rs b/third_party/rust/regex/tests/crazy.rs new file mode 100644 index 0000000000000..0516e03e1c652 --- /dev/null +++ b/third_party/rust/regex/tests/crazy.rs @@ -0,0 +1,3980 @@ +mat +! +( +ascii_literal +r +" +a +" +" +a +" +Some +( +( +0 +1 +) +) +) +; +/ +/ +Some +crazy +expressions +from +regular +- +expressions +. +info +. +mat +! +( +match_ranges +r +" +( +? +- +u +) +\ +b +( +? +: +[ +0 +- +9 +] +| +[ +1 +- +9 +] +[ +0 +- +9 +] +| +1 +[ +0 +- +9 +] +[ +0 +- +9 +] +| +2 +[ +0 +- +4 +] +[ +0 +- +9 +] +| +25 +[ +0 +- +5 +] +) +\ +b +" +" +num +: +255 +" +Some +( +( +5 +8 +) +) +) +; +mat +! +( +match_ranges_not +r +" +( +? +- +u +) +\ +b +( +? +: +[ +0 +- +9 +] +| +[ +1 +- +9 +] +[ +0 +- +9 +] +| +1 +[ +0 +- +9 +] +[ +0 +- +9 +] +| +2 +[ +0 +- +4 +] +[ +0 +- +9 +] +| +25 +[ +0 +- +5 +] +) +\ +b +" +" +num +: +256 +" +None +) +; +mat +! +( +match_float1 +r +" +[ +- ++ +] +? +[ +0 +- +9 +] +* +\ +. +? +[ +0 +- +9 +] ++ +" +" +0 +. +1 +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_float2 +r +" +[ +- ++ +] +? +[ +0 +- +9 +] +* +\ +. +? +[ +0 +- +9 +] ++ +" +" +0 +. +1 +. +2 +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_float3 +r +" +[ +- ++ +] +? +[ +0 +- +9 +] +* +\ +. +? +[ +0 +- +9 +] ++ +" +" +a1 +. +2 +" +Some +( +( +1 +4 +) +) +) +; +mat +! +( +match_float4 +r +" +^ +[ +- ++ +] +? +[ +0 +- +9 +] +* +\ +. +? +[ +0 +- +9 +] ++ +" +" +1 +. +a +" +None +) +; +mat +! +( +match_email +r +" +( +? +i +- +u +) +\ +b +[ +A +- +Z0 +- +9 +. +_ +% ++ +- +] ++ +[ +A +- +Z0 +- +9 +. +- +] ++ +\ +. +[ +A +- +Z +] +{ +2 +4 +} +\ +b +" +" +mine +is +jam +. +slam +gmail +. +com +" +Some +( +( +8 +26 +) +) +) +; +mat +! +( +match_email_not +r +" +( +? +i +- +u +) +\ +b +[ +A +- +Z0 +- +9 +. +_ +% ++ +- +] ++ +[ +A +- +Z0 +- +9 +. +- +] ++ +\ +. +[ +A +- +Z +] +{ +2 +4 +} +\ +b +" +" +mine +is +jam +. +slam +gmail +" +None +) +; +mat +! +( +match_email_big +r +" +[ +a +- +z0 +- +9 +! +# +% +& +' +* ++ +/ += +? +^ +_ +{ +| +} +~ +- +] ++ +( +? +: +\ +. +[ +a +- +z0 +- +9 +! +# +% +& +' +* ++ +/ += +? +^ +_ +{ +| +} +~ +- +] ++ +) +* +( +? +: +[ +a +- +z0 +- +9 +] +( +? +: +[ +a +- +z0 +- +9 +- +] +* +[ +a +- +z0 +- +9 +] +) +? +\ +. +) ++ +[ +a +- +z0 +- +9 +] +( +? +: +[ +a +- +z0 +- +9 +- +] +* +[ +a +- +z0 +- +9 +] +) +? +" +" +mine +is +jam +. +slam +gmail +. +com +" +Some +( +( +8 +26 +) +) +) +; +mat +! +( +match_date1 +r +" +( +? +- +u +) +^ +( +19 +| +20 +) +\ +d +\ +d +[ +- +/ +. +] +( +0 +[ +1 +- +9 +] +| +1 +[ +012 +] +) +[ +- +/ +. +] +( +0 +[ +1 +- +9 +] +| +[ +12 +] +[ +0 +- +9 +] +| +3 +[ +01 +] +) +" +" +1900 +- +01 +- +01 +" +Some +( +( +0 +10 +) +) +) +; +mat +! +( +match_date2 +r +" +( +? +- +u +) +^ +( +19 +| +20 +) +\ +d +\ +d +[ +- +/ +. +] +( +0 +[ +1 +- +9 +] +| +1 +[ +012 +] +) +[ +- +/ +. +] +( +0 +[ +1 +- +9 +] +| +[ +12 +] +[ +0 +- +9 +] +| +3 +[ +01 +] +) +" +" +1900 +- +00 +- +01 +" +None +) +; +mat +! +( +match_date3 +r +" +( +? +- +u +) +^ +( +19 +| +20 +) +\ +d +\ +d +[ +- +/ +. +] +( +0 +[ +1 +- +9 +] +| +1 +[ +012 +] +) +[ +- +/ +. +] +( +0 +[ +1 +- +9 +] +| +[ +12 +] +[ +0 +- +9 +] +| +3 +[ +01 +] +) +" +" +1900 +- +13 +- +01 +" +None +) +; +/ +/ +Do +some +crazy +dancing +with +the +start +/ +end +assertions +. +matiter +! +( +match_start_end_empty +r +" +^ +" +" +" +( +0 +0 +) +) +; +matiter +! +( +match_start_end_empty_many_1 +r +" +^ +^ +^ +" +" +" +( +0 +0 +) +) +; +matiter +! +( +match_start_end_empty_many_2 +r +" +^ +^ +^ +" +" +" +( +0 +0 +) +) +; +matiter +! +( +match_start_end_empty_rev +r +" +^ +" +" +" +( +0 +0 +) +) +; +matiter +! +( +match_start_end_empty_rep +r +" +( +? +: +^ +) +* +" +" +a +\ +nb +\ +nc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +5 +) +) +; +matiter +! +( +match_start_end_empty_rep_rev +r +" +( +? +: +^ +) +* +" +" +a +\ +nb +\ +nc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +5 +) +) +; +/ +/ +Test +negated +character +classes +. +mat +! +( +negclass_letters +r +" +[ +^ +ac +] +" +" +acx +" +Some +( +( +2 +3 +) +) +) +; +mat +! +( +negclass_letter_comma +r +" +[ +^ +a +] +" +" +a +x +" +Some +( +( +2 +3 +) +) +) +; +mat +! +( +negclass_letter_space +r +" +[ +^ +a +[ +: +space +: +] +] +" +" +a +x +" +Some +( +( +2 +3 +) +) +) +; +mat +! +( +negclass_comma +r +" +[ +^ +] +" +" +x +" +Some +( +( +2 +3 +) +) +) +; +mat +! +( +negclass_space +r +" +[ +^ +[ +: +space +: +] +] +" +" +a +" +Some +( +( +1 +2 +) +) +) +; +mat +! +( +negclass_space_comma +r +" +[ +^ +[ +: +space +: +] +] +" +" +a +" +Some +( +( +2 +3 +) +) +) +; +mat +! +( +negclass_comma_space +r +" +[ +^ +[ +: +space +: +] +] +" +" +a +" +Some +( +( +2 +3 +) +) +) +; +mat +! +( +negclass_ascii +r +" +[ +^ +[ +: +alpha +: +] +Z +] +" +" +A1 +" +Some +( +( +1 +2 +) +) +) +; +/ +/ +Test +that +repeated +empty +expressions +don +' +t +loop +forever +. +mat +! +( +lazy_many_many +r +" +( +( +? +: +. +* +) +* +? +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +lazy_many_optional +r +" +( +( +? +: +. +? +) +* +? +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +lazy_one_many_many +r +" +( +( +? +: +. +* +) ++ +? +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +lazy_one_many_optional +r +" +( +( +? +: +. +? +) ++ +? +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +lazy_range_min_many +r +" +( +( +? +: +. +* +) +{ +1 +} +? +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +lazy_range_many +r +" +( +( +? +: +. +* +) +{ +1 +2 +} +? +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +greedy_many_many +r +" +( +( +? +: +. +* +) +* +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +greedy_many_optional +r +" +( +( +? +: +. +? +) +* +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +greedy_one_many_many +r +" +( +( +? +: +. +* +) ++ +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +greedy_one_many_optional +r +" +( +( +? +: +. +? +) ++ +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +greedy_range_min_many +r +" +( +( +? +: +. +* +) +{ +1 +} +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +greedy_range_many +r +" +( +( +? +: +. +* +) +{ +1 +2 +} +) += +" +" +a += +b +" +Some +( +( +0 +2 +) +) +) +; +/ +/ +Test +that +we +handle +various +flavors +of +empty +expressions +. +matiter +! +( +match_empty1 +r +" +" +" +" +( +0 +0 +) +) +; +matiter +! +( +match_empty2 +r +" +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty3 +r +" +( +) +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty4 +r +" +( +) +* +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty5 +r +" +( +) ++ +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty6 +r +" +( +) +? +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty7 +r +" +( +) +( +) +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty8 +r +" +( +) ++ +| +z +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty9 +r +" +z +| +( +) ++ +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty10 +r +" +( +) ++ +| +b +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty11 +r +" +b +| +( +) ++ +" +" +abc +" +( +0 +0 +) +( +1 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty12 +r +" +| +b +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty13 +r +" +b +| +" +" +abc +" +( +0 +0 +) +( +1 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty14 +r +" +| +z +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty15 +r +" +z +| +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty16 +r +" +| +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty17 +r +" +| +| +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty18 +r +" +| +| +z +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty19 +r +" +( +? +: +) +| +b +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty20 +r +" +b +| +( +? +: +) +" +" +abc +" +( +0 +0 +) +( +1 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty21 +r +" +( +? +: +| +) +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty22 +r +" +( +? +: +| +) +| +z +" +" +abc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +) +; +matiter +! +( +match_empty23 +r +" +a +( +? +: +) +| +b +" +" +abc +" +( +0 +1 +) +( +1 +2 +) +) +; +/ +/ +Test +that +the +DFA +can +handle +pathological +cases +. +/ +/ +( +This +should +result +in +the +DFA +' +s +cache +being +flushed +too +frequently +which +/ +/ +should +cause +it +to +quit +and +fall +back +to +the +NFA +algorithm +. +) +# +[ +test +] +fn +dfa_handles_pathological_case +( +) +{ +fn +ones_and_zeroes +( +count +: +usize +) +- +> +String +{ +use +rand +: +: +rngs +: +: +SmallRng +; +use +rand +: +: +{ +Rng +SeedableRng +} +; +let +mut +rng += +SmallRng +: +: +from_entropy +( +) +; +let +mut +s += +String +: +: +new +( +) +; +for +_ +in +0 +. +. +count +{ +if +rng +. +gen +( +) +{ +s +. +push +( +' +1 +' +) +; +} +else +{ +s +. +push +( +' +0 +' +) +; +} +} +s +} +let +re += +regex +! +( +r +" +[ +01 +] +* +1 +[ +01 +] +{ +20 +} +" +) +; +let +text += +{ +let +mut +pieces += +ones_and_zeroes +( +100_000 +) +; +pieces +. +push +( +' +1 +' +) +; +pieces +. +push_str +( +& +ones_and_zeroes +( +20 +) +) +; +pieces +} +; +assert +! +( +re +. +is_match +( +text +! +( +& +* +text +) +) +) +; +} +# +[ +test +] +fn +nest_limit_makes_it_parse +( +) +{ +use +regex +: +: +RegexBuilder +; +RegexBuilder +: +: +new +( +r +# +" +( +? +- +u +) +2 +( +? +: +[ +45 +] +\ +d +{ +3 +} +| +7 +( +? +: +1 +[ +0 +- +267 +] +| +2 +[ +0 +- +289 +] +| +3 +[ +0 +- +29 +] +| +4 +[ +01 +] +| +5 +[ +1 +- +3 +] +| +6 +[ +013 +] +| +7 +[ +0178 +] +| +91 +) +| +8 +( +? +: +0 +[ +125 +] +| +[ +139 +] +[ +1 +- +6 +] +| +2 +[ +0157 +- +9 +] +| +41 +| +6 +[ +1 +- +35 +] +| +7 +[ +1 +- +5 +] +| +8 +[ +1 +- +8 +] +| +90 +) +| +9 +( +? +: +0 +[ +0 +- +2 +] +| +1 +[ +0 +- +4 +] +| +2 +[ +568 +] +| +3 +[ +3 +- +6 +] +| +5 +[ +5 +- +7 +] +| +6 +[ +0167 +] +| +7 +[ +15 +] +| +8 +[ +0146 +- +9 +] +) +) +\ +d +{ +4 +} +| +3 +( +? +: +12 +? +[ +5 +- +7 +] +\ +d +{ +2 +} +| +0 +( +? +: +2 +( +? +: +[ +025 +- +79 +] +\ +d +| +[ +348 +] +\ +d +{ +1 +2 +} +) +| +3 +( +? +: +[ +2 +- +4 +] +\ +d +| +[ +56 +] +\ +d +? +) +) +| +2 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +[ +12 +] +\ +d +| +[ +35 +] +\ +d +{ +1 +2 +} +| +4 +\ +d +? +) +) +| +3 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +[ +2356 +] +\ +d +| +4 +\ +d +{ +1 +2 +} +) +) +| +4 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +2 +\ +d +{ +1 +2 +} +| +[ +47 +] +| +5 +\ +d +{ +2 +} +) +) +| +5 +( +? +: +1 +\ +d +{ +2 +} +| +29 +) +| +[ +67 +] +1 +\ +d +{ +2 +} +| +8 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +2 +\ +d +{ +2 +} +| +3 +| +4 +\ +d +) +) +) +\ +d +{ +3 +} +| +4 +( +? +: +0 +( +? +: +2 +( +? +: +[ +09 +] +\ +d +| +7 +) +| +33 +\ +d +{ +2 +} +) +| +1 +\ +d +{ +3 +} +| +2 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +[ +25 +] +\ +d +? +| +[ +348 +] +\ +d +| +[ +67 +] +\ +d +{ +1 +2 +} +) +) +| +3 +( +? +: +1 +\ +d +{ +2 +} +( +? +: +\ +d +{ +2 +} +) +? +| +2 +( +? +: +[ +045 +] +\ +d +| +[ +236 +- +9 +] +\ +d +{ +1 +2 +} +) +| +32 +\ +d +{ +2 +} +) +| +4 +( +? +: +[ +18 +] +\ +d +{ +2 +} +| +2 +( +? +: +[ +2 +- +46 +] +\ +d +{ +2 +} +| +3 +) +| +5 +[ +25 +] +\ +d +{ +2 +} +) +| +5 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +3 +\ +d +| +5 +) +) +| +6 +( +? +: +[ +18 +] +\ +d +{ +2 +} +| +2 +( +? +: +3 +( +? +: +\ +d +{ +2 +} +) +? +| +[ +46 +] +\ +d +{ +1 +2 +} +| +5 +\ +d +{ +2 +} +| +7 +\ +d +) +| +5 +( +? +: +3 +\ +d +? +| +4 +\ +d +| +[ +57 +] +\ +d +{ +1 +2 +} +| +6 +\ +d +{ +2 +} +| +8 +) +) +| +71 +\ +d +{ +2 +} +| +8 +( +? +: +[ +18 +] +\ +d +{ +2 +} +| +23 +\ +d +{ +2 +} +| +54 +\ +d +{ +2 +} +) +| +9 +( +? +: +[ +18 +] +\ +d +{ +2 +} +| +2 +[ +2 +- +5 +] +\ +d +{ +2 +} +| +53 +\ +d +{ +1 +2 +} +) +) +\ +d +{ +3 +} +| +5 +( +? +: +02 +[ +03489 +] +\ +d +{ +2 +} +| +1 +\ +d +{ +2 +} +| +2 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +2 +( +? +: +\ +d +{ +2 +} +) +? +| +[ +457 +] +\ +d +{ +2 +} +) +) +| +3 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +[ +37 +] +( +? +: +\ +d +{ +2 +} +) +? +| +[ +569 +] +\ +d +{ +2 +} +) +) +| +4 +( +? +: +1 +\ +d +{ +2 +} +| +2 +[ +46 +] +\ +d +{ +2 +} +) +| +5 +( +? +: +1 +\ +d +{ +2 +} +| +26 +\ +d +{ +1 +2 +} +) +| +6 +( +? +: +[ +18 +] +\ +d +{ +2 +} +| +2 +| +53 +\ +d +{ +2 +} +) +| +7 +( +? +: +1 +| +24 +) +\ +d +{ +2 +} +| +8 +( +? +: +1 +| +26 +) +\ +d +{ +2 +} +| +91 +\ +d +{ +2 +} +) +\ +d +{ +3 +} +| +6 +( +? +: +0 +( +? +: +1 +\ +d +{ +2 +} +| +2 +( +? +: +3 +\ +d +{ +2 +} +| +4 +\ +d +{ +1 +2 +} +) +) +| +2 +( +? +: +2 +[ +2 +- +5 +] +\ +d +{ +2 +} +| +5 +( +? +: +[ +3 +- +5 +] +\ +d +{ +2 +} +| +7 +) +| +8 +\ +d +{ +2 +} +) +| +3 +( +? +: +1 +| +2 +[ +3478 +] +) +\ +d +{ +2 +} +| +4 +( +? +: +1 +| +2 +[ +34 +] +) +\ +d +{ +2 +} +| +5 +( +? +: +1 +| +2 +[ +47 +] +) +\ +d +{ +2 +} +| +6 +( +? +: +[ +18 +] +\ +d +{ +2 +} +| +6 +( +? +: +2 +( +? +: +2 +\ +d +| +[ +34 +] +\ +d +{ +2 +} +) +| +5 +( +? +: +[ +24 +] +\ +d +{ +2 +} +| +3 +\ +d +| +5 +\ +d +{ +1 +2 +} +) +) +) +| +72 +[ +2 +- +5 +] +\ +d +{ +2 +} +| +8 +( +? +: +1 +\ +d +{ +2 +} +| +2 +[ +2 +- +5 +] +\ +d +{ +2 +} +) +| +9 +( +? +: +1 +\ +d +{ +2 +} +| +2 +[ +2 +- +6 +] +\ +d +{ +2 +} +) +) +\ +d +{ +3 +} +| +7 +( +? +: +( +? +: +02 +| +[ +3 +- +589 +] +1 +| +6 +[ +12 +] +| +72 +[ +24 +] +) +\ +d +{ +2 +} +| +21 +\ +d +{ +3 +} +| +32 +) +\ +d +{ +3 +} +| +8 +( +? +: +( +? +: +4 +[ +12 +] +| +[ +5 +- +7 +] +2 +| +1 +\ +d +? +) +| +( +? +: +0 +| +3 +[ +12 +] +| +[ +5 +- +7 +] +1 +| +217 +) +\ +d +) +\ +d +{ +4 +} +| +9 +( +? +: +[ +35 +] +1 +| +( +? +: +[ +024 +] +2 +| +81 +) +\ +d +| +( +? +: +1 +| +[ +24 +] +1 +) +\ +d +{ +2 +} +) +\ +d +{ +3 +} +" +# +) +. +build +( +) +. +unwrap +( +) +; +} diff --git a/third_party/rust/regex/tests/flags.rs b/third_party/rust/regex/tests/flags.rs new file mode 100644 index 0000000000000..5015401ba8dda --- /dev/null +++ b/third_party/rust/regex/tests/flags.rs @@ -0,0 +1,392 @@ +mat +! +( +match_flag_case +" +( +? +- +u +) +( +? +i +) +abc +" +" +ABC +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_flag_weird_case +" +( +? +- +u +) +( +? +i +) +a +( +? +- +i +) +bc +" +" +Abc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_flag_weird_case_not +" +( +? +- +u +) +( +? +i +) +a +( +? +- +i +) +bc +" +" +ABC +" +None +) +; +mat +! +( +match_flag_case_dotnl +" +( +? +- +u +) +( +? +is +) +a +( +? +u +: +. +) +" +" +A +\ +n +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_flag_case_dotnl_toggle +" +( +? +- +u +) +( +? +is +) +a +( +? +u +: +. +) +( +? +- +is +) +a +( +? +u +: +. +) +" +" +A +\ +nab +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_flag_case_dotnl_toggle_not +" +( +? +- +u +) +( +? +is +) +a +( +? +u +: +. +) +( +? +- +is +) +a +( +? +u +: +. +) +" +" +A +\ +na +\ +n +" +None +) +; +mat +! +( +match_flag_case_dotnl_toggle_ok +" +( +? +- +u +) +( +? +is +) +a +( +? +u +: +. +) +( +? +- +is +: +a +( +? +u +: +. +) +) +? +" +" +A +\ +na +\ +n +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_flag_multi +r +" +( +? +- +u +) +( +? +m +) +( +? +: +^ +\ +d ++ +\ +n +? +) ++ +" +" +123 +\ +n456 +\ +n789 +" +Some +( +( +0 +11 +) +) +) +; +mat +! +( +match_flag_ungreedy +" +( +? +U +) +a ++ +" +" +aa +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_flag_ungreedy_greedy +" +( +? +U +) +a ++ +? +" +" +aa +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_flag_ungreedy_noop +" +( +? +U +) +( +? +- +U +) +a ++ +" +" +aa +" +Some +( +( +0 +2 +) +) +) +; diff --git a/third_party/rust/regex/tests/fowler.rs b/third_party/rust/regex/tests/fowler.rs new file mode 100644 index 0000000000000..12726f9106cff --- /dev/null +++ b/third_party/rust/regex/tests/fowler.rs @@ -0,0 +1,13911 @@ +/ +/ +DO +NOT +EDIT +. +Automatically +generated +by +' +scripts +/ +regex +- +match +- +tests +. +py +' +/ +/ +on +2019 +- +09 +- +02 +11 +: +07 +: +37 +. +849994 +. +/ +/ +Tests +from +basic +. +dat +mat +! +( +match_basic_3 +r +" +abracadabra +" +r +" +abracadabracadabra +" +Some +( +( +7 +18 +) +) +) +; +mat +! +( +match_basic_4 +r +" +a +. +. +. +b +" +r +" +abababbb +" +Some +( +( +2 +7 +) +) +) +; +mat +! +( +match_basic_5 +r +" +XXXXXX +" +r +" +. +. +XXXXXX +" +Some +( +( +2 +8 +) +) +) +; +mat +! +( +match_basic_6 +r +" +\ +) +" +r +" +( +) +" +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_7 +r +" +a +] +" +r +" +a +] +a +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_9 +r +" +\ +} +" +r +" +} +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_10 +r +" +\ +] +" +r +" +] +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_12 +r +" +] +" +r +" +] +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_15 +r +" +^ +a +" +r +" +ax +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_16 +r +" +\ +^ +a +" +r +" +a +^ +a +" +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_17 +r +" +a +\ +^ +" +r +" +a +^ +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_18 +r +" +a +" +r +" +aa +" +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_19 +r +" +a +\ +" +r +" +a +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_20 +r +" +^ +" +r +" +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_21 +r +" +^ +" +r +" +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_22 +r +" +a +( +) +" +r +" +aa +" +Some +( +( +1 +2 +) +) +Some +( +( +2 +2 +) +) +) +; +mat +! +( +match_basic_23 +r +" +a +* +( +^ +a +) +" +r +" +aa +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_24 +r +" +( +. +. +) +* +( +. +. +. +) +* +" +r +" +a +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_25 +r +" +( +. +. +) +* +( +. +. +. +) +* +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +Some +( +( +2 +4 +) +) +) +; +mat +! +( +match_basic_26 +r +" +( +ab +| +a +) +( +bc +| +c +) +" +r +" +abc +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_basic_27 +r +" +( +ab +) +c +| +abc +" +r +" +abc +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_28 +r +" +a +{ +0 +} +b +" +r +" +ab +" +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_29 +r +" +( +a +* +) +( +b +? +) +( +b ++ +) +b +{ +3 +} +" +r +" +aaabbbbbbb +" +Some +( +( +0 +10 +) +) +Some +( +( +0 +3 +) +) +Some +( +( +3 +4 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_30 +r +" +( +a +* +) +( +b +{ +0 +1 +} +) +( +b +{ +1 +} +) +b +{ +3 +} +" +r +" +aaabbbbbbb +" +Some +( +( +0 +10 +) +) +Some +( +( +0 +3 +) +) +Some +( +( +3 +4 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_32 +r +" +( +( +a +| +a +) +| +a +) +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_33 +r +" +( +a +* +) +( +a +| +aa +) +" +r +" +aaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +3 +) +) +Some +( +( +3 +4 +) +) +) +; +mat +! +( +match_basic_34 +r +" +a +* +( +a +. +| +aa +) +" +r +" +aaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +2 +4 +) +) +) +; +mat +! +( +match_basic_35 +r +" +a +( +b +) +| +c +( +d +) +| +a +( +e +) +f +" +r +" +aef +" +Some +( +( +0 +3 +) +) +None +None +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_36 +r +" +( +a +| +b +) +? +. +* +" +r +" +b +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_37 +r +" +( +a +| +b +) +c +| +a +( +b +| +c +) +" +r +" +ac +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_38 +r +" +( +a +| +b +) +c +| +a +( +b +| +c +) +" +r +" +ab +" +Some +( +( +0 +2 +) +) +None +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_39 +r +" +( +a +| +b +) +* +c +| +( +a +| +ab +) +* +c +" +r +" +abc +" +Some +( +( +0 +3 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_40 +r +" +( +a +| +b +) +* +c +| +( +a +| +ab +) +* +c +" +r +" +xc +" +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_41 +r +" +( +. +a +| +. +b +) +. +* +| +. +* +( +. +a +| +. +b +) +" +r +" +xa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_42 +r +" +a +? +( +ab +| +ba +) +ab +" +r +" +abab +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_43 +r +" +a +? +( +ac +{ +0 +} +b +| +ba +) +ab +" +r +" +abab +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_44 +r +" +ab +| +abab +" +r +" +abbabab +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_45 +r +" +aba +| +bab +| +bba +" +r +" +baaabbbaba +" +Some +( +( +5 +8 +) +) +) +; +mat +! +( +match_basic_46 +r +" +aba +| +bab +" +r +" +baaabbbaba +" +Some +( +( +6 +9 +) +) +) +; +mat +! +( +match_basic_47 +r +" +( +aa +| +aaa +) +* +| +( +a +| +aaaaa +) +" +r +" +aa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_48 +r +" +( +a +. +| +. +a +. +) +* +| +( +a +| +. +a +. +. +. +) +" +r +" +aa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_49 +r +" +ab +| +a +" +r +" +xabc +" +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_50 +r +" +ab +| +a +" +r +" +xxabc +" +Some +( +( +2 +4 +) +) +) +; +mat +! +( +match_basic_51 +r +" +( +? +i +) +( +? +- +u +) +( +Ab +| +cD +) +* +" +r +" +aBcD +" +Some +( +( +0 +4 +) +) +Some +( +( +2 +4 +) +) +) +; +mat +! +( +match_basic_52 +r +" +[ +^ +- +] +" +r +" +- +- +a +" +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_basic_53 +r +" +[ +a +- +] +* +" +r +" +- +- +a +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_54 +r +" +[ +a +- +m +- +] +* +" +r +" +- +- +amoma +- +- +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_55 +r +" +: +: +: +1 +: +: +: +0 +: +| +: +: +: +1 +: +1 +: +0 +: +" +r +" +: +: +: +0 +: +: +: +1 +: +: +: +1 +: +: +: +0 +: +" +Some +( +( +8 +17 +) +) +) +; +mat +! +( +match_basic_56 +r +" +: +: +: +1 +: +: +: +0 +: +| +: +: +: +1 +: +1 +: +1 +: +" +r +" +: +: +: +0 +: +: +: +1 +: +: +: +1 +: +: +: +0 +: +" +Some +( +( +8 +17 +) +) +) +; +mat +! +( +match_basic_57 +r +" +[ +[ +: +upper +: +] +] +" +r +" +A +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_58 +r +" +[ +[ +: +lower +: +] +] ++ +" +r +" +az +{ +" +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_59 +r +" +[ +[ +: +upper +: +] +] ++ +" +r +" +AZ +[ +" +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_65 +r +" +" +r +" +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_66 +r +" +" +r +" +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_67 +r +" +[ +^ +a +] +" +r +" +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_68 +r +" +a +" +r +" +a +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_69 +r +" +( +a +) +( +b +) +( +c +) +" +r +" +abc +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +2 +) +) +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_basic_70 +r +" +xxx +" +r +" +xxx +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_71 +r +" +( +^ +| +[ +( +; +] +) +( +( +( +[ +Ff +] +eb +[ +^ +] +* +* +| +0 +* +2 +/ +| +\ +* +* +/ +? +) +0 +* +[ +6 +- +7 +] +) +) +( +[ +^ +0 +- +9 +] +| +) +" +r +" +feb +6 +" +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_basic_72 +r +" +( +^ +| +[ +( +; +] +) +( +( +( +[ +Ff +] +eb +[ +^ +] +* +* +| +0 +* +2 +/ +| +\ +* +* +/ +? +) +0 +* +[ +6 +- +7 +] +) +) +( +[ +^ +0 +- +9 +] +| +) +" +r +" +2 +/ +7 +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_73 +r +" +( +^ +| +[ +( +; +] +) +( +( +( +[ +Ff +] +eb +[ +^ +] +* +* +| +0 +* +2 +/ +| +\ +* +* +/ +? +) +0 +* +[ +6 +- +7 +] +) +) +( +[ +^ +0 +- +9 +] +| +) +" +r +" +feb +1 +Feb +6 +" +Some +( +( +5 +11 +) +) +) +; +mat +! +( +match_basic_74 +r +" +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +x +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +" +r +" +x +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_75 +r +" +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +( +x +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +) +* +" +r +" +xx +" +Some +( +( +0 +2 +) +) +Some +( +( +1 +2 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_76 +r +" +a +? +( +ab +| +ba +) +* +" +r +" +ababababababababababababababababababababababababababababababababababababababababa +" +Some +( +( +0 +81 +) +) +Some +( +( +79 +81 +) +) +) +; +mat +! +( +match_basic_77 +r +" +abaa +| +abbaa +| +abbbaa +| +abbbbaa +" +r +" +ababbabbbabbbabbbbabbbbaa +" +Some +( +( +18 +25 +) +) +) +; +mat +! +( +match_basic_78 +r +" +abaa +| +abbaa +| +abbbaa +| +abbbbaa +" +r +" +ababbabbbabbbabbbbabaa +" +Some +( +( +18 +22 +) +) +) +; +mat +! +( +match_basic_79 +r +" +aaac +| +aabc +| +abac +| +abbc +| +baac +| +babc +| +bbac +| +bbbc +" +r +" +baaabbbabac +" +Some +( +( +7 +11 +) +) +) +; +mat +! +( +match_basic_80 +r +" +. +* +" +r +" +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_81 +r +" +aaaa +| +bbbb +| +cccc +| +ddddd +| +eeeeee +| +fffffff +| +gggg +| +hhhh +| +iiiii +| +jjjjj +| +kkkkk +| +llll +" +r +" +XaaaXbbbXcccXdddXeeeXfffXgggXhhhXiiiXjjjXkkkXlllXcbaXaaaa +" +Some +( +( +53 +57 +) +) +) +; +mat +! +( +match_basic_83 +r +" +a +* +a +* +a +* +a +* +a +* +b +" +r +" +aaaaaaaaab +" +Some +( +( +0 +10 +) +) +) +; +mat +! +( +match_basic_84 +r +" +^ +" +r +" +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_85 +r +" +" +r +" +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_86 +r +" +^ +" +r +" +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_87 +r +" +^ +a +" +r +" +a +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_88 +r +" +abc +" +r +" +abc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_89 +r +" +abc +" +r +" +xabcy +" +Some +( +( +1 +4 +) +) +) +; +mat +! +( +match_basic_90 +r +" +abc +" +r +" +ababc +" +Some +( +( +2 +5 +) +) +) +; +mat +! +( +match_basic_91 +r +" +ab +* +c +" +r +" +abc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_92 +r +" +ab +* +bc +" +r +" +abc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_93 +r +" +ab +* +bc +" +r +" +abbc +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_94 +r +" +ab +* +bc +" +r +" +abbbbc +" +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_basic_95 +r +" +ab ++ +bc +" +r +" +abbc +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_96 +r +" +ab ++ +bc +" +r +" +abbbbc +" +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_basic_97 +r +" +ab +? +bc +" +r +" +abbc +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_98 +r +" +ab +? +bc +" +r +" +abc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_99 +r +" +ab +? +c +" +r +" +abc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_100 +r +" +^ +abc +" +r +" +abc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_101 +r +" +^ +abc +" +r +" +abcc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_102 +r +" +abc +" +r +" +aabc +" +Some +( +( +1 +4 +) +) +) +; +mat +! +( +match_basic_103 +r +" +^ +" +r +" +abc +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_104 +r +" +" +r +" +abc +" +Some +( +( +3 +3 +) +) +) +; +mat +! +( +match_basic_105 +r +" +a +. +c +" +r +" +abc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_106 +r +" +a +. +c +" +r +" +axc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_107 +r +" +a +. +* +c +" +r +" +axyzc +" +Some +( +( +0 +5 +) +) +) +; +mat +! +( +match_basic_108 +r +" +a +[ +bc +] +d +" +r +" +abd +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_109 +r +" +a +[ +b +- +d +] +e +" +r +" +ace +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_110 +r +" +a +[ +b +- +d +] +" +r +" +aac +" +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_111 +r +" +a +[ +- +b +] +" +r +" +a +- +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_112 +r +" +a +[ +b +- +] +" +r +" +a +- +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_113 +r +" +a +] +" +r +" +a +] +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_114 +r +" +a +[ +] +] +b +" +r +" +a +] +b +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_115 +r +" +a +[ +^ +bc +] +d +" +r +" +aed +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_116 +r +" +a +[ +^ +- +b +] +c +" +r +" +adc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_117 +r +" +a +[ +^ +] +b +] +c +" +r +" +adc +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_118 +r +" +ab +| +cd +" +r +" +abc +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_119 +r +" +ab +| +cd +" +r +" +abcd +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_120 +r +" +a +\ +( +b +" +r +" +a +( +b +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_121 +r +" +a +\ +( +* +b +" +r +" +ab +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_122 +r +" +a +\ +( +* +b +" +r +" +a +( +( +b +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_123 +r +" +( +( +a +) +) +" +r +" +abc +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_124 +r +" +( +a +) +b +( +c +) +" +r +" +abc +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_basic_125 +r +" +a ++ +b ++ +c +" +r +" +aabbabc +" +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_126 +r +" +a +* +" +r +" +aaa +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_128 +r +" +( +a +* +) +* +" +r +" +- +" +Some +( +( +0 +0 +) +) +None +) +; +mat +! +( +match_basic_129 +r +" +( +a +* +) ++ +" +r +" +- +" +Some +( +( +0 +0 +) +) +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_131 +r +" +( +a +* +| +b +) +* +" +r +" +- +" +Some +( +( +0 +0 +) +) +None +) +; +mat +! +( +match_basic_132 +r +" +( +a ++ +| +b +) +* +" +r +" +ab +" +Some +( +( +0 +2 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_133 +r +" +( +a ++ +| +b +) ++ +" +r +" +ab +" +Some +( +( +0 +2 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_134 +r +" +( +a ++ +| +b +) +? +" +r +" +ab +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_135 +r +" +[ +^ +ab +] +* +" +r +" +cde +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_137 +r +" +( +^ +) +* +" +r +" +- +" +Some +( +( +0 +0 +) +) +None +) +; +mat +! +( +match_basic_138 +r +" +a +* +" +r +" +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_basic_139 +r +" +( +[ +abc +] +) +* +d +" +r +" +abbbcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +) +; +mat +! +( +match_basic_140 +r +" +( +[ +abc +] +) +* +bcd +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_141 +r +" +a +| +b +| +c +| +d +| +e +" +r +" +e +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_142 +r +" +( +a +| +b +| +c +| +d +| +e +) +f +" +r +" +ef +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_144 +r +" +( +( +a +* +| +b +) +) +* +" +r +" +- +" +Some +( +( +0 +0 +) +) +None +None +) +; +mat +! +( +match_basic_145 +r +" +abcd +* +efg +" +r +" +abcdefg +" +Some +( +( +0 +7 +) +) +) +; +mat +! +( +match_basic_146 +r +" +ab +* +" +r +" +xabyabbbz +" +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_147 +r +" +ab +* +" +r +" +xayabbbz +" +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_148 +r +" +( +ab +| +cd +) +e +" +r +" +abcde +" +Some +( +( +2 +5 +) +) +Some +( +( +2 +4 +) +) +) +; +mat +! +( +match_basic_149 +r +" +[ +abhgefdc +] +ij +" +r +" +hij +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_150 +r +" +( +a +| +b +) +c +* +d +" +r +" +abcd +" +Some +( +( +1 +4 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_151 +r +" +( +ab +| +ab +* +) +bc +" +r +" +abc +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_152 +r +" +a +( +[ +bc +] +* +) +c +* +" +r +" +abc +" +Some +( +( +0 +3 +) +) +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_153 +r +" +a +( +[ +bc +] +* +) +( +c +* +d +) +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +Some +( +( +1 +3 +) +) +Some +( +( +3 +4 +) +) +) +; +mat +! +( +match_basic_154 +r +" +a +( +[ +bc +] ++ +) +( +c +* +d +) +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +Some +( +( +1 +3 +) +) +Some +( +( +3 +4 +) +) +) +; +mat +! +( +match_basic_155 +r +" +a +( +[ +bc +] +* +) +( +c ++ +d +) +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +Some +( +( +1 +2 +) +) +Some +( +( +2 +4 +) +) +) +; +mat +! +( +match_basic_156 +r +" +a +[ +bcd +] +* +dcdcde +" +r +" +adcdcde +" +Some +( +( +0 +7 +) +) +) +; +mat +! +( +match_basic_157 +r +" +( +ab +| +a +) +b +* +c +" +r +" +abc +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +2 +) +) +) +; +mat +! +( +match_basic_158 +r +" +( +( +a +) +( +b +) +c +) +( +d +) +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +3 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +2 +) +) +Some +( +( +3 +4 +) +) +) +; +mat +! +( +match_basic_159 +r +" +[ +A +- +Za +- +z_ +] +[ +A +- +Za +- +z0 +- +9_ +] +* +" +r +" +alpha +" +Some +( +( +0 +5 +) +) +) +; +mat +! +( +match_basic_160 +r +" +^ +a +( +bc ++ +| +b +[ +eh +] +) +g +| +. +h +" +r +" +abh +" +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_161 +r +" +( +bc ++ +d +| +ef +* +g +. +| +h +? +i +( +j +| +k +) +) +" +r +" +effgz +" +Some +( +( +0 +5 +) +) +Some +( +( +0 +5 +) +) +) +; +mat +! +( +match_basic_162 +r +" +( +bc ++ +d +| +ef +* +g +. +| +h +? +i +( +j +| +k +) +) +" +r +" +ij +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_basic_163 +r +" +( +bc ++ +d +| +ef +* +g +. +| +h +? +i +( +j +| +k +) +) +" +r +" +reffgz +" +Some +( +( +1 +6 +) +) +Some +( +( +1 +6 +) +) +) +; +mat +! +( +match_basic_164 +r +" +( +( +( +( +( +( +( +( +( +a +) +) +) +) +) +) +) +) +) +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_basic_165 +r +" +multiple +words +" +r +" +multiple +words +yeah +" +Some +( +( +0 +14 +) +) +) +; +mat +! +( +match_basic_166 +r +" +( +. +* +) +c +( +. +* +) +" +r +" +abcde +" +Some +( +( +0 +5 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +3 +5 +) +) +) +; +mat +! +( +match_basic_167 +r +" +abcd +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_168 +r +" +a +( +bc +) +d +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +Some +( +( +1 +3 +) +) +) +; +mat +! +( +match_basic_169 +r +" +a +[ +- +] +? +c +" +r +" +a +c +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_170 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Qaddafi +" +Some +( +( +0 +15 +) +) +None +Some +( +( +10 +12 +) +) +) +; +mat +! +( +match_basic_171 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Mo +' +ammar +Gadhafi +" +Some +( +( +0 +16 +) +) +None +Some +( +( +11 +13 +) +) +) +; +mat +! +( +match_basic_172 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Kaddafi +" +Some +( +( +0 +15 +) +) +None +Some +( +( +10 +12 +) +) +) +; +mat +! +( +match_basic_173 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Qadhafi +" +Some +( +( +0 +15 +) +) +None +Some +( +( +10 +12 +) +) +) +; +mat +! +( +match_basic_174 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Gadafi +" +Some +( +( +0 +14 +) +) +None +Some +( +( +10 +11 +) +) +) +; +mat +! +( +match_basic_175 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Mu +' +ammar +Qadafi +" +Some +( +( +0 +15 +) +) +None +Some +( +( +11 +12 +) +) +) +; +mat +! +( +match_basic_176 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Moamar +Gaddafi +" +Some +( +( +0 +14 +) +) +None +Some +( +( +9 +11 +) +) +) +; +mat +! +( +match_basic_177 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Mu +' +ammar +Qadhdhafi +" +Some +( +( +0 +18 +) +) +None +Some +( +( +13 +15 +) +) +) +; +mat +! +( +match_basic_178 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Khaddafi +" +Some +( +( +0 +16 +) +) +None +Some +( +( +11 +13 +) +) +) +; +mat +! +( +match_basic_179 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Ghaddafy +" +Some +( +( +0 +16 +) +) +None +Some +( +( +11 +13 +) +) +) +; +mat +! +( +match_basic_180 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Ghadafi +" +Some +( +( +0 +15 +) +) +None +Some +( +( +11 +12 +) +) +) +; +mat +! +( +match_basic_181 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Ghaddafi +" +Some +( +( +0 +16 +) +) +None +Some +( +( +11 +13 +) +) +) +; +mat +! +( +match_basic_182 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muamar +Kaddafi +" +Some +( +( +0 +14 +) +) +None +Some +( +( +9 +11 +) +) +) +; +mat +! +( +match_basic_183 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Quathafi +" +Some +( +( +0 +16 +) +) +None +Some +( +( +11 +13 +) +) +) +; +mat +! +( +match_basic_184 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Muammar +Gheddafi +" +Some +( +( +0 +16 +) +) +None +Some +( +( +11 +13 +) +) +) +; +mat +! +( +match_basic_185 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Moammar +Khadafy +" +Some +( +( +0 +15 +) +) +None +Some +( +( +11 +12 +) +) +) +; +mat +! +( +match_basic_186 +r +" +M +[ +ou +] +' +? +am ++ +[ +ae +] +r +. +* +( +[ +AEae +] +l +[ +- +] +) +? +[ +GKQ +] +h +? +[ +aeu +] ++ +( +[ +dtz +] +[ +dhz +] +? +) ++ +af +[ +iy +] +" +r +" +Moammar +Qudhafi +" +Some +( +( +0 +15 +) +) +None +Some +( +( +10 +12 +) +) +) +; +mat +! +( +match_basic_187 +r +" +a ++ +( +b +| +c +) +* +d ++ +" +r +" +aabcdd +" +Some +( +( +0 +6 +) +) +Some +( +( +3 +4 +) +) +) +; +mat +! +( +match_basic_188 +r +" +^ +. ++ +" +r +" +vivi +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_189 +r +" +^ +( +. ++ +) +" +r +" +vivi +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_190 +r +" +^ +( +[ +^ +! +. +] ++ +) +. +att +. +com +! +( +. ++ +) +" +r +" +gryphon +. +att +. +com +! +eby +" +Some +( +( +0 +19 +) +) +Some +( +( +0 +7 +) +) +Some +( +( +16 +19 +) +) +) +; +mat +! +( +match_basic_191 +r +" +^ +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +" +r +" +bas +" +Some +( +( +0 +3 +) +) +None +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_192 +r +" +^ +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +" +r +" +bar +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +4 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_193 +r +" +^ +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +" +r +" +foo +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +4 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_194 +r +" +^ +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +" +r +" +foo +! +bar +! +bas +" +Some +( +( +0 +11 +) +) +Some +( +( +4 +8 +) +) +Some +( +( +8 +11 +) +) +) +; +mat +! +( +match_basic_195 +r +" +( +( +foo +) +| +( +bar +) +) +! +bas +" +r +" +bar +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +3 +) +) +None +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_196 +r +" +( +( +foo +) +| +( +bar +) +) +! +bas +" +r +" +foo +! +bar +! +bas +" +Some +( +( +4 +11 +) +) +Some +( +( +4 +7 +) +) +None +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_197 +r +" +( +( +foo +) +| +( +bar +) +) +! +bas +" +r +" +foo +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +3 +) +) +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_198 +r +" +( +( +foo +) +| +bar +) +! +bas +" +r +" +bar +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_199 +r +" +( +( +foo +) +| +bar +) +! +bas +" +r +" +foo +! +bar +! +bas +" +Some +( +( +4 +11 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_200 +r +" +( +( +foo +) +| +bar +) +! +bas +" +r +" +foo +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +3 +) +) +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_201 +r +" +( +foo +| +( +bar +) +) +! +bas +" +r +" +bar +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +3 +) +) +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_202 +r +" +( +foo +| +( +bar +) +) +! +bas +" +r +" +foo +! +bar +! +bas +" +Some +( +( +4 +11 +) +) +Some +( +( +4 +7 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_203 +r +" +( +foo +| +( +bar +) +) +! +bas +" +r +" +foo +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_204 +r +" +( +foo +| +bar +) +! +bas +" +r +" +bar +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_205 +r +" +( +foo +| +bar +) +! +bas +" +r +" +foo +! +bar +! +bas +" +Some +( +( +4 +11 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_206 +r +" +( +foo +| +bar +) +! +bas +" +r +" +foo +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_207 +r +" +^ +( +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +) +" +r +" +foo +! +bar +! +bas +" +Some +( +( +0 +11 +) +) +Some +( +( +0 +11 +) +) +None +None +Some +( +( +4 +8 +) +) +Some +( +( +8 +11 +) +) +) +; +mat +! +( +match_basic_208 +r +" +^ +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +^ +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +" +r +" +bas +" +Some +( +( +0 +3 +) +) +None +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_209 +r +" +^ +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +^ +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +" +r +" +bar +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +4 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_210 +r +" +^ +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +^ +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +" +r +" +foo +! +bar +! +bas +" +Some +( +( +0 +11 +) +) +None +None +Some +( +( +4 +8 +) +) +Some +( +( +8 +11 +) +) +) +; +mat +! +( +match_basic_211 +r +" +^ +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +^ +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +" +r +" +foo +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +4 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_212 +r +" +^ +( +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +) +" +r +" +bas +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +3 +) +) +None +Some +( +( +0 +3 +) +) +) +; +mat +! +( +match_basic_213 +r +" +^ +( +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +) +" +r +" +bar +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +7 +) +) +Some +( +( +0 +4 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_214 +r +" +^ +( +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +) +" +r +" +foo +! +bar +! +bas +" +Some +( +( +0 +11 +) +) +Some +( +( +0 +11 +) +) +None +None +Some +( +( +4 +8 +) +) +Some +( +( +8 +11 +) +) +) +; +mat +! +( +match_basic_215 +r +" +^ +( +( +[ +^ +! +] ++ +! +) +? +( +[ +^ +! +] ++ +) +| +. ++ +! +( +[ +^ +! +] ++ +! +) +( +[ +^ +! +] ++ +) +) +" +r +" +foo +! +bas +" +Some +( +( +0 +7 +) +) +Some +( +( +0 +7 +) +) +Some +( +( +0 +4 +) +) +Some +( +( +4 +7 +) +) +) +; +mat +! +( +match_basic_216 +r +" +. +* +( +/ +XXX +) +. +* +" +r +" +/ +XXX +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_217 +r +" +. +* +( +\ +\ +XXX +) +. +* +" +r +" +\ +XXX +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_218 +r +" +\ +\ +XXX +" +r +" +\ +XXX +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_219 +r +" +. +* +( +/ +000 +) +. +* +" +r +" +/ +000 +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_220 +r +" +. +* +( +\ +\ +000 +) +. +* +" +r +" +\ +000 +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +4 +) +) +) +; +mat +! +( +match_basic_221 +r +" +\ +\ +000 +" +r +" +\ +000 +" +Some +( +( +0 +4 +) +) +) +; +/ +/ +Tests +from +nullsubexpr +. +dat +mat +! +( +match_nullsubexpr_3 +r +" +( +a +* +) +* +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_5 +r +" +( +a +* +) +* +" +r +" +x +" +Some +( +( +0 +0 +) +) +None +) +; +mat +! +( +match_nullsubexpr_6 +r +" +( +a +* +) +* +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_7 +r +" +( +a +* +) +* +" +r +" +aaaaaax +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_8 +r +" +( +a +* +) ++ +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_9 +r +" +( +a +* +) ++ +" +r +" +x +" +Some +( +( +0 +0 +) +) +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_nullsubexpr_10 +r +" +( +a +* +) ++ +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_11 +r +" +( +a +* +) ++ +" +r +" +aaaaaax +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_12 +r +" +( +a ++ +) +* +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_13 +r +" +( +a ++ +) +* +" +r +" +x +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_nullsubexpr_14 +r +" +( +a ++ +) +* +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_15 +r +" +( +a ++ +) +* +" +r +" +aaaaaax +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_16 +r +" +( +a ++ +) ++ +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_17 +r +" +( +a ++ +) ++ +" +r +" +x +" +None +) +; +mat +! +( +match_nullsubexpr_18 +r +" +( +a ++ +) ++ +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_19 +r +" +( +a ++ +) ++ +" +r +" +aaaaaax +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_21 +r +" +( +[ +a +] +* +) +* +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_23 +r +" +( +[ +a +] +* +) +* +" +r +" +x +" +Some +( +( +0 +0 +) +) +None +) +; +mat +! +( +match_nullsubexpr_24 +r +" +( +[ +a +] +* +) +* +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_25 +r +" +( +[ +a +] +* +) +* +" +r +" +aaaaaax +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_26 +r +" +( +[ +a +] +* +) ++ +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_27 +r +" +( +[ +a +] +* +) ++ +" +r +" +x +" +Some +( +( +0 +0 +) +) +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_nullsubexpr_28 +r +" +( +[ +a +] +* +) ++ +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_29 +r +" +( +[ +a +] +* +) ++ +" +r +" +aaaaaax +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_30 +r +" +( +[ +^ +b +] +* +) +* +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_32 +r +" +( +[ +^ +b +] +* +) +* +" +r +" +b +" +Some +( +( +0 +0 +) +) +None +) +; +mat +! +( +match_nullsubexpr_33 +r +" +( +[ +^ +b +] +* +) +* +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_34 +r +" +( +[ +^ +b +] +* +) +* +" +r +" +aaaaaab +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_35 +r +" +( +[ +ab +] +* +) +* +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_36 +r +" +( +[ +ab +] +* +) +* +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_37 +r +" +( +[ +ab +] +* +) +* +" +r +" +ababab +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_38 +r +" +( +[ +ab +] +* +) +* +" +r +" +bababa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_39 +r +" +( +[ +ab +] +* +) +* +" +r +" +b +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_40 +r +" +( +[ +ab +] +* +) +* +" +r +" +bbbbbb +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_41 +r +" +( +[ +ab +] +* +) +* +" +r +" +aaaabcde +" +Some +( +( +0 +5 +) +) +Some +( +( +0 +5 +) +) +) +; +mat +! +( +match_nullsubexpr_42 +r +" +( +[ +^ +a +] +* +) +* +" +r +" +b +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_43 +r +" +( +[ +^ +a +] +* +) +* +" +r +" +bbbbbb +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_45 +r +" +( +[ +^ +a +] +* +) +* +" +r +" +aaaaaa +" +Some +( +( +0 +0 +) +) +None +) +; +mat +! +( +match_nullsubexpr_46 +r +" +( +[ +^ +ab +] +* +) +* +" +r +" +ccccxx +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +6 +) +) +) +; +mat +! +( +match_nullsubexpr_48 +r +" +( +[ +^ +ab +] +* +) +* +" +r +" +ababab +" +Some +( +( +0 +0 +) +) +None +) +; +mat +! +( +match_nullsubexpr_50 +r +" +( +( +z +) ++ +| +a +) +* +" +r +" +zabcde +" +Some +( +( +0 +2 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_nullsubexpr_69 +r +" +( +a +* +) +* +( +x +) +" +r +" +x +" +Some +( +( +0 +1 +) +) +None +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_70 +r +" +( +a +* +) +* +( +x +) +" +r +" +ax +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_nullsubexpr_71 +r +" +( +a +* +) +* +( +x +) +" +r +" +axa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_nullsubexpr_73 +r +" +( +a +* +) ++ +( +x +) +" +r +" +x +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +0 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_74 +r +" +( +a +* +) ++ +( +x +) +" +r +" +ax +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_nullsubexpr_75 +r +" +( +a +* +) ++ +( +x +) +" +r +" +axa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_nullsubexpr_77 +r +" +( +a +* +) +{ +2 +} +( +x +) +" +r +" +x +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +0 +) +) +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_nullsubexpr_78 +r +" +( +a +* +) +{ +2 +} +( +x +) +" +r +" +ax +" +Some +( +( +0 +2 +) +) +Some +( +( +1 +1 +) +) +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_nullsubexpr_79 +r +" +( +a +* +) +{ +2 +} +( +x +) +" +r +" +axa +" +Some +( +( +0 +2 +) +) +Some +( +( +1 +1 +) +) +Some +( +( +1 +2 +) +) +) +; +/ +/ +Tests +from +repetition +. +dat +mat +! +( +match_repetition_10 +r +" +( +( +. +. +) +| +( +. +) +) +" +r +" +" +None +) +; +mat +! +( +match_repetition_11 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +" +None +) +; +mat +! +( +match_repetition_12 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +" +None +) +; +mat +! +( +match_repetition_14 +r +" +( +( +. +. +) +| +( +. +) +) +{ +1 +} +" +r +" +" +None +) +; +mat +! +( +match_repetition_15 +r +" +( +( +. +. +) +| +( +. +) +) +{ +2 +} +" +r +" +" +None +) +; +mat +! +( +match_repetition_16 +r +" +( +( +. +. +) +| +( +. +) +) +{ +3 +} +" +r +" +" +None +) +; +mat +! +( +match_repetition_18 +r +" +( +( +. +. +) +| +( +. +) +) +* +" +r +" +" +Some +( +( +0 +0 +) +) +) +; +mat +! +( +match_repetition_20 +r +" +( +( +. +. +) +| +( +. +) +) +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +None +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_repetition_21 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +a +" +None +) +; +mat +! +( +match_repetition_22 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +a +" +None +) +; +mat +! +( +match_repetition_24 +r +" +( +( +. +. +) +| +( +. +) +) +{ +1 +} +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +None +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_repetition_25 +r +" +( +( +. +. +) +| +( +. +) +) +{ +2 +} +" +r +" +a +" +None +) +; +mat +! +( +match_repetition_26 +r +" +( +( +. +. +) +| +( +. +) +) +{ +3 +} +" +r +" +a +" +None +) +; +mat +! +( +match_repetition_28 +r +" +( +( +. +. +) +| +( +. +) +) +* +" +r +" +a +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +None +Some +( +( +0 +1 +) +) +) +; +mat +! +( +match_repetition_30 +r +" +( +( +. +. +) +| +( +. +) +) +" +r +" +aa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_31 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +1 +) +) +None +Some +( +( +0 +1 +) +) +Some +( +( +1 +2 +) +) +None +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_repetition_32 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aa +" +None +) +; +mat +! +( +match_repetition_34 +r +" +( +( +. +. +) +| +( +. +) +) +{ +1 +} +" +r +" +aa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_35 +r +" +( +( +. +. +) +| +( +. +) +) +{ +2 +} +" +r +" +aa +" +Some +( +( +0 +2 +) +) +Some +( +( +1 +2 +) +) +None +Some +( +( +1 +2 +) +) +) +; +mat +! +( +match_repetition_36 +r +" +( +( +. +. +) +| +( +. +) +) +{ +3 +} +" +r +" +aa +" +None +) +; +mat +! +( +match_repetition_38 +r +" +( +( +. +. +) +| +( +. +) +) +* +" +r +" +aa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_40 +r +" +( +( +. +. +) +| +( +. +) +) +" +r +" +aaa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_41 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aaa +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +Some +( +( +2 +3 +) +) +None +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_repetition_42 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aaa +" +Some +( +( +0 +3 +) +) +Some +( +( +0 +1 +) +) +None +Some +( +( +0 +1 +) +) +Some +( +( +1 +2 +) +) +None +Some +( +( +1 +2 +) +) +Some +( +( +2 +3 +) +) +None +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_repetition_44 +r +" +( +( +. +. +) +| +( +. +) +) +{ +1 +} +" +r +" +aaa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_46 +r +" +( +( +. +. +) +| +( +. +) +) +{ +2 +} +" +r +" +aaa +" +Some +( +( +0 +3 +) +) +Some +( +( +2 +3 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_repetition_47 +r +" +( +( +. +. +) +| +( +. +) +) +{ +3 +} +" +r +" +aaa +" +Some +( +( +0 +3 +) +) +Some +( +( +2 +3 +) +) +None +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_repetition_50 +r +" +( +( +. +. +) +| +( +. +) +) +* +" +r +" +aaa +" +Some +( +( +0 +3 +) +) +Some +( +( +2 +3 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +2 +3 +) +) +) +; +mat +! +( +match_repetition_52 +r +" +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_53 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +) +; +mat +! +( +match_repetition_54 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +Some +( +( +2 +3 +) +) +None +Some +( +( +2 +3 +) +) +Some +( +( +3 +4 +) +) +None +Some +( +( +3 +4 +) +) +) +; +mat +! +( +match_repetition_56 +r +" +( +( +. +. +) +| +( +. +) +) +{ +1 +} +" +r +" +aaaa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_57 +r +" +( +( +. +. +) +| +( +. +) +) +{ +2 +} +" +r +" +aaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +) +; +mat +! +( +match_repetition_59 +r +" +( +( +. +. +) +| +( +. +) +) +{ +3 +} +" +r +" +aaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +3 +4 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +3 +4 +) +) +) +; +mat +! +( +match_repetition_61 +r +" +( +( +. +. +) +| +( +. +) +) +* +" +r +" +aaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +) +; +mat +! +( +match_repetition_63 +r +" +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaaa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_64 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +) +; +mat +! +( +match_repetition_65 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaaa +" +Some +( +( +0 +5 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +Some +( +( +4 +5 +) +) +None +Some +( +( +4 +5 +) +) +) +; +mat +! +( +match_repetition_67 +r +" +( +( +. +. +) +| +( +. +) +) +{ +1 +} +" +r +" +aaaaa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_68 +r +" +( +( +. +. +) +| +( +. +) +) +{ +2 +} +" +r +" +aaaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +) +; +mat +! +( +match_repetition_70 +r +" +( +( +. +. +) +| +( +. +) +) +{ +3 +} +" +r +" +aaaaa +" +Some +( +( +0 +5 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +2 +4 +) +) +Some +( +( +4 +5 +) +) +) +; +mat +! +( +match_repetition_73 +r +" +( +( +. +. +) +| +( +. +) +) +* +" +r +" +aaaaa +" +Some +( +( +0 +5 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +2 +4 +) +) +Some +( +( +4 +5 +) +) +) +; +mat +! +( +match_repetition_75 +r +" +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaaaa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_76 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +) +; +mat +! +( +match_repetition_77 +r +" +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +( +( +. +. +) +| +( +. +) +) +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +Some +( +( +4 +6 +) +) +Some +( +( +4 +6 +) +) +None +) +; +mat +! +( +match_repetition_79 +r +" +( +( +. +. +) +| +( +. +) +) +{ +1 +} +" +r +" +aaaaaa +" +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +Some +( +( +0 +2 +) +) +None +) +; +mat +! +( +match_repetition_80 +r +" +( +( +. +. +) +| +( +. +) +) +{ +2 +} +" +r +" +aaaaaa +" +Some +( +( +0 +4 +) +) +Some +( +( +2 +4 +) +) +Some +( +( +2 +4 +) +) +None +) +; +mat +! +( +match_repetition_81 +r +" +( +( +. +. +) +| +( +. +) +) +{ +3 +} +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +6 +) +) +Some +( +( +4 +6 +) +) +None +) +; +mat +! +( +match_repetition_83 +r +" +( +( +. +. +) +| +( +. +) +) +* +" +r +" +aaaaaa +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +6 +) +) +Some +( +( +4 +6 +) +) +None +) +; +mat +! +( +match_repetition_90 +r +" +X +( +. +? +) +{ +0 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +7 +8 +) +) +) +; +mat +! +( +match_repetition_91 +r +" +X +( +. +? +) +{ +1 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +7 +8 +) +) +) +; +mat +! +( +match_repetition_92 +r +" +X +( +. +? +) +{ +2 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +7 +8 +) +) +) +; +mat +! +( +match_repetition_93 +r +" +X +( +. +? +) +{ +3 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +7 +8 +) +) +) +; +mat +! +( +match_repetition_94 +r +" +X +( +. +? +) +{ +4 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +7 +8 +) +) +) +; +mat +! +( +match_repetition_95 +r +" +X +( +. +? +) +{ +5 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +7 +8 +) +) +) +; +mat +! +( +match_repetition_96 +r +" +X +( +. +? +) +{ +6 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +7 +8 +) +) +) +; +mat +! +( +match_repetition_97 +r +" +X +( +. +? +) +{ +7 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +7 +8 +) +) +) +; +mat +! +( +match_repetition_98 +r +" +X +( +. +? +) +{ +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_100 +r +" +X +( +. +? +) +{ +0 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_102 +r +" +X +( +. +? +) +{ +1 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_104 +r +" +X +( +. +? +) +{ +2 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_106 +r +" +X +( +. +? +) +{ +3 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_108 +r +" +X +( +. +? +) +{ +4 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_110 +r +" +X +( +. +? +) +{ +5 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_112 +r +" +X +( +. +? +) +{ +6 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_114 +r +" +X +( +. +? +) +{ +7 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_115 +r +" +X +( +. +? +) +{ +8 +8 +} +Y +" +r +" +X1234567Y +" +Some +( +( +0 +9 +) +) +Some +( +( +8 +8 +) +) +) +; +mat +! +( +match_repetition_126 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +0 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +1 +) +) +) +; +mat +! +( +match_repetition_127 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +1 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +1 +) +) +) +; +mat +! +( +match_repetition_128 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +2 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +3 +6 +) +) +Some +( +( +6 +6 +) +) +) +; +mat +! +( +match_repetition_129 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +3 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +3 +6 +) +) +Some +( +( +6 +6 +) +) +) +; +mat +! +( +match_repetition_130 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +4 +} +( +d +* +) +" +r +" +ababcd +" +None +) +; +mat +! +( +match_repetition_131 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +0 +10 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +1 +) +) +) +; +mat +! +( +match_repetition_132 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +1 +10 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +1 +) +) +) +; +mat +! +( +match_repetition_133 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +2 +10 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +3 +6 +) +) +Some +( +( +6 +6 +) +) +) +; +mat +! +( +match_repetition_134 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +3 +10 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +3 +6 +) +) +Some +( +( +6 +6 +) +) +) +; +mat +! +( +match_repetition_135 +r +" +( +a +| +ab +| +c +| +bcd +) +{ +4 +10 +} +( +d +* +) +" +r +" +ababcd +" +None +) +; +mat +! +( +match_repetition_136 +r +" +( +a +| +ab +| +c +| +bcd +) +* +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +1 +) +) +) +; +mat +! +( +match_repetition_137 +r +" +( +a +| +ab +| +c +| +bcd +) ++ +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +1 +) +) +Some +( +( +0 +1 +) +) +Some +( +( +1 +1 +) +) +) +; +mat +! +( +match_repetition_143 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +0 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_145 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +1 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_147 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +2 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_149 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +3 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_150 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +4 +} +( +d +* +) +" +r +" +ababcd +" +None +) +; +mat +! +( +match_repetition_152 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +0 +10 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_154 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +1 +10 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_156 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +2 +10 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_158 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +3 +10 +} +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_159 +r +" +( +ab +| +a +| +c +| +bcd +) +{ +4 +10 +} +( +d +* +) +" +r +" +ababcd +" +None +) +; +mat +! +( +match_repetition_161 +r +" +( +ab +| +a +| +c +| +bcd +) +* +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; +mat +! +( +match_repetition_163 +r +" +( +ab +| +a +| +c +| +bcd +) ++ +( +d +* +) +" +r +" +ababcd +" +Some +( +( +0 +6 +) +) +Some +( +( +4 +5 +) +) +Some +( +( +5 +6 +) +) +) +; diff --git a/third_party/rust/regex/tests/fuzz/mod.rs b/third_party/rust/regex/tests/fuzz/mod.rs deleted file mode 100644 index f88dd704118f0..0000000000000 --- a/third_party/rust/regex/tests/fuzz/mod.rs +++ /dev/null @@ -1,1481 +0,0 @@ -/ -/ -This -set -of -tests -is -different -from -regression_fuzz -in -that -the -tests -start -/ -/ -from -the -fuzzer -data -directly -. -The -test -essentially -duplicates -the -fuzz -/ -/ -target -. -I -wonder -if -there -' -s -a -better -way -to -set -this -up -. -. -. -Hmmm -. -I -bet -/ -/ -cargo -fuzz -has -something -where -it -can -run -a -target -against -crash -files -and -/ -/ -verify -that -they -pass -. -/ -/ -This -case -found -by -the -fuzzer -causes -the -meta -engine -to -use -the -" -reverse -/ -/ -inner -" -literal -strategy -. -That -in -turn -uses -a -specialized -search -routine -/ -/ -for -the -lazy -DFA -in -order -to -avoid -worst -case -quadratic -behavior -. -That -/ -/ -specialized -search -routine -had -a -bug -where -it -assumed -that -start -state -/ -/ -specialization -was -disabled -. -But -this -is -indeed -not -the -case -since -it -/ -/ -reuses -the -" -general -" -lazy -DFA -for -the -full -regex -created -as -part -of -the -core -/ -/ -strategy -which -might -very -well -have -start -states -specialized -due -to -the -/ -/ -existence -of -a -prefilter -. -/ -/ -/ -/ -This -is -a -somewhat -weird -case -because -if -the -core -engine -has -a -prefilter -/ -/ -then -it -' -s -usually -the -case -that -the -" -reverse -inner -" -optimization -won -' -t -be -/ -/ -pursued -in -that -case -. -But -there -are -some -heuristics -that -try -to -detect -/ -/ -whether -a -prefilter -is -" -fast -" -or -not -. -If -it -' -s -not -then -the -meta -engine -will -/ -/ -attempt -the -reverse -inner -optimization -. -And -indeed -that -' -s -what -happens -/ -/ -here -. -So -the -reverse -inner -optimization -ends -up -with -a -lazy -DFA -that -has -/ -/ -start -states -specialized -. -Ideally -this -wouldn -' -t -happen -because -specializing -/ -/ -start -states -without -a -prefilter -inside -the -DFA -can -be -disastrous -for -/ -/ -performance -by -causing -the -DFA -to -ping -- -pong -in -and -out -of -the -special -state -/ -/ -handling -. -In -this -case -it -' -s -probably -not -a -huge -deal -because -the -lazy -/ -/ -DFA -is -only -used -for -part -of -the -matching -where -as -the -work -horse -is -the -/ -/ -prefilter -found -by -the -reverse -inner -optimization -. -/ -/ -/ -/ -We -could -maybe -fix -this -by -refactoring -the -meta -engine -to -be -a -little -more -/ -/ -careful -. -For -example -by -attempting -the -optimizations -before -building -the -/ -/ -core -engine -. -But -this -is -perhaps -a -little -tricky -. -# -[ -test -] -fn -meta_stopat_specialize_start_states -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -crash -- -8760b19b25d74e3603d4c643e9c7404fdd3631f9 -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -Same -bug -as -meta_stopat_specialize_start_states -but -minimized -by -the -/ -/ -fuzzer -. -# -[ -test -] -fn -meta_stopat_specialize_start_states_min -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -minimized -- -from -- -8760b19b25d74e3603d4c643e9c7404fdd3631f9 -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -This -input -generated -a -pattern -with -a -fail -state -( -e -. -g -. -\ -P -{ -any -} -[ -^ -\ -s -\ -S -] -/ -/ -or -[ -a -& -& -b -] -) -. -But -the -fail -state -was -in -a -branch -where -a -subsequent -branch -/ -/ -should -have -led -to -an -overall -match -but -handling -of -the -fail -state -/ -/ -prevented -it -from -doing -so -. -A -hand -- -minimized -version -of -this -is -' -[ -^ -\ -s -\ -S -] -A -| -B -' -/ -/ -on -the -haystack -' -B -' -. -That -should -yield -a -match -of -' -B -' -. -/ -/ -/ -/ -The -underlying -cause -was -an -issue -in -how -DFA -determinization -handled -fail -/ -/ -states -. -The -bug -didn -' -t -impact -the -PikeVM -or -the -bounded -backtracker -. -# -[ -test -] -fn -fail_branch_prevents_match -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -crash -- -cd33b13df59ea9d74503986f9d32a270dd43cc04 -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -This -input -generated -a -pattern -that -contained -a -sub -- -expression -like -this -: -/ -/ -/ -/ -a -{ -0 -} -{ -50000 -} -/ -/ -/ -/ -This -turned -out -to -provoke -quadratic -behavior -in -the -NFA -compiler -. -/ -/ -Basically -the -NFA -compiler -works -in -two -phases -. -The -first -phase -builds -/ -/ -a -more -complicated -- -but -- -simpler -- -to -- -construct -sequence -of -NFA -states -that -/ -/ -includes -unconditional -epsilon -transitions -. -As -part -of -converting -this -/ -/ -sequence -to -the -" -final -" -NFA -we -remove -those -unconditional -espilon -/ -/ -transition -. -The -code -responsible -for -doing -this -follows -every -chain -of -/ -/ -these -transitions -and -remaps -the -state -IDs -. -The -way -we -were -doing -this -/ -/ -before -resulted -in -re -- -following -every -subsequent -part -of -the -chain -for -each -/ -/ -state -in -the -chain -which -ended -up -being -quadratic -behavior -. -We -effectively -/ -/ -memoized -this -which -fixed -the -performance -bug -. -# -[ -test -] -fn -slow_big_empty_chain -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -slow -- -unit -- -9ca9cc9929fee1fcbb847a78384effb8b98ea18a -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -A -different -case -of -slow_big_empty_chain -. -# -[ -test -] -fn -slow_big_empty_chain2 -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -slow -- -unit -- -3ab758ea520027fefd3f00e1384d9aeef155739e -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -A -different -case -of -slow_big_empty_chain -. -# -[ -test -] -fn -slow_big_empty_chain3 -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -slow -- -unit -- -b8a052f4254802edbe5f569b6ce6e9b6c927e9d6 -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -A -different -case -of -slow_big_empty_chain -. -# -[ -test -] -fn -slow_big_empty_chain4 -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -slow -- -unit -- -93c73a43581f205f9aaffd9c17e52b34b17becd0 -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -A -different -case -of -slow_big_empty_chain -. -# -[ -test -] -fn -slow_big_empty_chain5 -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -slow -- -unit -- -5345fccadf3812c53c3ccc7af5aa2741b7b2106c -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -A -different -case -of -slow_big_empty_chain -. -# -[ -test -] -fn -slow_big_empty_chain6 -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -slow -- -unit -- -6bd643eec330166e4ada91da2d3f284268481085 -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -This -fuzz -input -generated -a -pattern -with -a -large -repetition -that -would -fail -/ -/ -NFA -compilation -but -its -HIR -was -small -. -( -HIR -doesn -' -t -expand -repetitions -. -) -/ -/ -But -the -bounds -were -high -enough -that -the -minimum -length -calculation -/ -/ -overflowed -. -We -fixed -this -by -using -saturating -arithmetic -( -and -also -checked -/ -/ -arithmetic -for -the -maximum -length -calculation -) -. -/ -/ -/ -/ -Incidentally -this -was -the -only -unguarded -arithmetic -operation -performed -in -/ -/ -the -HIR -smart -constructors -. -And -the -fuzzer -found -it -. -Hah -. -Nice -. -# -[ -test -] -fn -minimum_len_overflow -( -) -{ -let -data -= -include_bytes -! -( -" -testdata -/ -crash -- -7eb3351f0965e5d6c1cb98aa8585949ef96531ff -" -) -; -let -_ -= -run -( -data -) -; -} -/ -/ -This -is -the -fuzz -target -function -. -We -duplicate -it -here -since -this -is -the -/ -/ -thing -we -use -to -interpret -the -data -. -It -is -ultimately -what -we -want -to -/ -/ -succeed -. -fn -run -( -data -: -& -[ -u8 -] -) -- -> -Option -< -( -) -> -{ -if -data -. -len -( -) -< -2 -{ -return -None -; -} -let -mut -split_at -= -usize -: -: -from -( -data -[ -0 -] -) -; -let -data -= -std -: -: -str -: -: -from_utf8 -( -& -data -[ -1 -. -. -] -) -. -ok -( -) -? -; -/ -/ -Split -data -into -a -regex -and -haystack -to -search -. -let -len -= -usize -: -: -try_from -( -data -. -chars -( -) -. -count -( -) -) -. -ok -( -) -? -; -split_at -= -std -: -: -cmp -: -: -max -( -split_at -1 -) -% -len -; -let -char_index -= -data -. -char_indices -( -) -. -nth -( -split_at -) -? -. -0 -; -let -( -pattern -input -) -= -data -. -split_at -( -char_index -) -; -let -re -= -regex -: -: -Regex -: -: -new -( -pattern -) -. -ok -( -) -? -; -re -. -is_match -( -input -) -; -Some -( -( -) -) -} diff --git a/third_party/rust/regex/tests/fuzz/testdata/crash-7eb3351f0965e5d6c1cb98aa8585949ef96531ff b/third_party/rust/regex/tests/fuzz/testdata/crash-7eb3351f0965e5d6c1cb98aa8585949ef96531ff deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/crash-8760b19b25d74e3603d4c643e9c7404fdd3631f9 b/third_party/rust/regex/tests/fuzz/testdata/crash-8760b19b25d74e3603d4c643e9c7404fdd3631f9 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/crash-cd33b13df59ea9d74503986f9d32a270dd43cc04 b/third_party/rust/regex/tests/fuzz/testdata/crash-cd33b13df59ea9d74503986f9d32a270dd43cc04 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/minimized-from-8760b19b25d74e3603d4c643e9c7404fdd3631f9 b/third_party/rust/regex/tests/fuzz/testdata/minimized-from-8760b19b25d74e3603d4c643e9c7404fdd3631f9 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/slow-unit-3ab758ea520027fefd3f00e1384d9aeef155739e b/third_party/rust/regex/tests/fuzz/testdata/slow-unit-3ab758ea520027fefd3f00e1384d9aeef155739e deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/slow-unit-5345fccadf3812c53c3ccc7af5aa2741b7b2106c b/third_party/rust/regex/tests/fuzz/testdata/slow-unit-5345fccadf3812c53c3ccc7af5aa2741b7b2106c deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/slow-unit-6bd643eec330166e4ada91da2d3f284268481085 b/third_party/rust/regex/tests/fuzz/testdata/slow-unit-6bd643eec330166e4ada91da2d3f284268481085 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/slow-unit-93c73a43581f205f9aaffd9c17e52b34b17becd0 b/third_party/rust/regex/tests/fuzz/testdata/slow-unit-93c73a43581f205f9aaffd9c17e52b34b17becd0 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/slow-unit-9ca9cc9929fee1fcbb847a78384effb8b98ea18a b/third_party/rust/regex/tests/fuzz/testdata/slow-unit-9ca9cc9929fee1fcbb847a78384effb8b98ea18a deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/fuzz/testdata/slow-unit-b8a052f4254802edbe5f569b6ce6e9b6c927e9d6 b/third_party/rust/regex/tests/fuzz/testdata/slow-unit-b8a052f4254802edbe5f569b6ce6e9b6c927e9d6 deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/third_party/rust/regex/tests/lib.rs b/third_party/rust/regex/tests/lib.rs deleted file mode 100644 index a3a403051ee58..0000000000000 --- a/third_party/rust/regex/tests/lib.rs +++ /dev/null @@ -1,384 +0,0 @@ -# -! -[ -cfg_attr -( -feature -= -" -pattern -" -feature -( -pattern -) -) -] -mod -fuzz -; -mod -misc -; -mod -regression -; -mod -regression_fuzz -; -mod -replace -; -# -[ -cfg -( -feature -= -" -pattern -" -) -] -mod -searcher -; -mod -suite_bytes -; -mod -suite_bytes_set -; -mod -suite_string -; -mod -suite_string_set -; -const -BLACKLIST -: -& -[ -& -str -] -= -& -[ -/ -/ -Nothing -to -blacklist -yet -! -] -; -fn -suite -( -) -- -> -anyhow -: -: -Result -< -regex_test -: -: -RegexTests -> -{ -let -_ -= -env_logger -: -: -try_init -( -) -; -let -mut -tests -= -regex_test -: -: -RegexTests -: -: -new -( -) -; -macro_rules -! -load -{ -( -name -: -expr -) -= -> -{ -{ -const -DATA -: -& -[ -u8 -] -= -include_bytes -! -( -concat -! -( -" -. -. -/ -testdata -/ -" -name -" -. -toml -" -) -) -; -tests -. -load_slice -( -name -DATA -) -? -; -} -} -; -} -load -! -( -" -anchored -" -) -; -load -! -( -" -bytes -" -) -; -load -! -( -" -crazy -" -) -; -load -! -( -" -crlf -" -) -; -load -! -( -" -earliest -" -) -; -load -! -( -" -empty -" -) -; -load -! -( -" -expensive -" -) -; -load -! -( -" -flags -" -) -; -load -! -( -" -iter -" -) -; -load -! -( -" -leftmost -- -all -" -) -; -load -! -( -" -line -- -terminator -" -) -; -load -! -( -" -misc -" -) -; -load -! -( -" -multiline -" -) -; -load -! -( -" -no -- -unicode -" -) -; -load -! -( -" -overlapping -" -) -; -load -! -( -" -regression -" -) -; -load -! -( -" -set -" -) -; -load -! -( -" -substring -" -) -; -load -! -( -" -unicode -" -) -; -load -! -( -" -utf8 -" -) -; -load -! -( -" -word -- -boundary -" -) -; -load -! -( -" -fowler -/ -basic -" -) -; -load -! -( -" -fowler -/ -nullsubexpr -" -) -; -load -! -( -" -fowler -/ -repetition -" -) -; -Ok -( -tests -) -} diff --git a/third_party/rust/regex/tests/macros.rs b/third_party/rust/regex/tests/macros.rs new file mode 100644 index 0000000000000..0ce802c9c5ce1 --- /dev/null +++ b/third_party/rust/regex/tests/macros.rs @@ -0,0 +1,1314 @@ +/ +/ +Convenience +macros +. +macro_rules +! +findall +{ +( +re +: +expr +text +: +expr +) += +> +{ +{ +re +. +find_iter +( +text +! +( +text +) +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +. +collect +: +: +< +Vec +< +_ +> +> +( +) +} +} +} +/ +/ +Macros +for +automatically +producing +tests +. +macro_rules +! +ismatch +{ +( +name +: +ident +re +: +expr +text +: +expr +ismatch +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +re += +regex +! +( +re +) +; +assert_eq +! +( +ismatch +re +. +is_match +( +text +! +( +text +) +) +) +; +} +} +; +} +macro_rules +! +mat +( +( +name +: +ident +re +: +expr +text +: +expr +( +loc +: +tt +) ++ +) += +> +( +# +[ +test +] +fn +name +( +) +{ +let +text += +text +! +( +text +) +; +let +expected +: +Vec +< +Option +< +_ +> +> += +vec +! +[ +( +loc +) ++ +] +; +let +r += +regex +! +( +re +) +; +let +got +: +Vec +< +Option +< +_ +> +> += +match +r +. +captures +( +text +) +{ +Some +( +c +) += +> +{ +assert +! +( +r +. +is_match +( +text +) +) +; +assert +! +( +r +. +shortest_match +( +text +) +. +is_some +( +) +) +; +r +. +capture_names +( +) +. +enumerate +( +) +. +map +( +| +( +i +_ +) +| +c +. +get +( +i +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +) +. +collect +( +) +} +None += +> +vec +! +[ +None +] +} +; +/ +/ +The +test +set +sometimes +leave +out +capture +groups +so +truncate +/ +/ +actual +capture +groups +to +match +test +set +. +let +mut +sgot += +& +got +[ +. +. +] +; +if +sgot +. +len +( +) +> +expected +. +len +( +) +{ +sgot += +& +sgot +[ +0 +. +. +expected +. +len +( +) +] +} +if +expected +! += +sgot +{ +panic +! +( +" +For +RE +' +{ +} +' +against +' +{ +: +? +} +' +\ +expected +' +{ +: +? +} +' +but +got +' +{ +: +? +} +' +" +re +text +expected +sgot +) +; +} +} +) +; +) +; +macro_rules +! +matiter +( +( +name +: +ident +re +: +expr +text +: +expr +) += +> +( +# +[ +test +] +fn +name +( +) +{ +let +text += +text +! +( +text +) +; +let +expected +: +Vec +< +( +usize +usize +) +> += +vec +! +[ +] +; +let +r += +regex +! +( +re +) +; +let +got +: +Vec +< +_ +> += +r +. +find_iter +( +text +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +. +collect +( +) +; +if +expected +! += +got +{ +panic +! +( +" +For +RE +' +{ +} +' +against +' +{ +: +? +} +' +\ +expected +' +{ +: +? +} +' +but +got +' +{ +: +? +} +' +" +re +text +expected +got +) +; +} +let +captures_got +: +Vec +< +_ +> += +r +. +captures_iter +( +text +) +. +map +( +| +c +| +c +. +get +( +0 +) +. +unwrap +( +) +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +. +collect +( +) +; +if +captures_got +! += +got +{ +panic +! +( +" +For +RE +' +{ +} +' +against +' +{ +: +? +} +' +\ +got +' +{ +: +? +} +' +using +find_iter +but +got +' +{ +: +? +} +' +\ +using +captures_iter +" +re +text +got +captures_got +) +; +} +} +) +; +( +name +: +ident +re +: +expr +text +: +expr +( +loc +: +tt +) ++ +) += +> +( +# +[ +test +] +fn +name +( +) +{ +let +text += +text +! +( +text +) +; +let +expected +: +Vec +< +_ +> += +vec +! +[ +( +loc +) ++ +] +; +let +r += +regex +! +( +re +) +; +let +got +: +Vec +< +_ +> += +r +. +find_iter +( +text +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +. +collect +( +) +; +if +expected +! += +got +{ +panic +! +( +" +For +RE +' +{ +} +' +against +' +{ +: +? +} +' +\ +expected +' +{ +: +? +} +' +but +got +' +{ +: +? +} +' +" +re +text +expected +got +) +; +} +let +captures_got +: +Vec +< +_ +> += +r +. +captures_iter +( +text +) +. +map +( +| +c +| +c +. +get +( +0 +) +. +unwrap +( +) +) +. +map +( +| +m +| +( +m +. +start +( +) +m +. +end +( +) +) +) +. +collect +( +) +; +if +captures_got +! += +got +{ +panic +! +( +" +For +RE +' +{ +} +' +against +' +{ +: +? +} +' +\ +got +' +{ +: +? +} +' +using +find_iter +but +got +' +{ +: +? +} +' +\ +using +captures_iter +" +re +text +got +captures_got +) +; +} +} +) +; +) +; +macro_rules +! +matset +{ +( +name +: +ident +res +: +expr +text +: +expr +( +match_index +: +expr +) +* +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +text += +text +! +( +text +) +; +let +set += +regex_set +! +( +res +) +; +assert +! +( +set +. +is_match +( +text +) +) +; +let +expected += +vec +! +[ +( +match_index +) +* +] +; +let +matches += +set +. +matches +( +text +) +; +assert +! +( +matches +. +matched_any +( +) +) +; +let +got +: +Vec +< +_ +> += +matches +. +into_iter +( +) +. +collect +( +) +; +assert_eq +! +( +expected +got +) +; +} +} +} +macro_rules +! +nomatset +{ +( +name +: +ident +res +: +expr +text +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +text += +text +! +( +text +) +; +let +set += +regex_set +! +( +res +) +; +assert +! +( +! +set +. +is_match +( +text +) +) +; +let +matches += +set +. +matches +( +text +) +; +assert +! +( +! +matches +. +matched_any +( +) +) +; +assert_eq +! +( +0 +matches +. +into_iter +( +) +. +count +( +) +) +; +} +} +} +macro_rules +! +split +{ +( +name +: +ident +re +: +expr +text +: +expr +expected +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +re += +regex +! +( +re +) +; +let +splitted +: +Vec +< +_ +> += +re +. +split +( +t +! +( +text +) +) +. +collect +( +) +; +assert_eq +! +( +expected +& +* +splitted +) +; +} +} +} +macro_rules +! +splitn +{ +( +name +: +ident +re +: +expr +text +: +expr +limit +: +expr +expected +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +re += +regex +! +( +re +) +; +let +splitted +: +Vec +< +_ +> += +re +. +splitn +( +t +! +( +text +) +limit +) +. +collect +( +) +; +assert_eq +! +( +expected +& +* +splitted +) +; +} +} +} diff --git a/third_party/rust/regex/tests/macros_bytes.rs b/third_party/rust/regex/tests/macros_bytes.rs new file mode 100644 index 0000000000000..42284e70d27d4 --- /dev/null +++ b/third_party/rust/regex/tests/macros_bytes.rs @@ -0,0 +1,350 @@ +/ +/ +Macros +for +use +in +writing +tests +generic +over +& +str +/ +& +[ +u8 +] +. +macro_rules +! +text +{ +( +text +: +expr +) += +> +{ +text +. +as_bytes +( +) +} +} +macro_rules +! +t +{ +( +re +: +expr +) += +> +{ +text +! +( +re +) +} +} +macro_rules +! +match_text +{ +( +text +: +expr +) += +> +{ +text +. +as_bytes +( +) +} +} +macro_rules +! +use_ +{ +( +( +path +: +tt +) +* +) += +> +{ +use +regex +: +: +bytes +: +: +( +path +) +* +; +} +} +macro_rules +! +empty_vec +{ +( +) += +> +{ +< +Vec +< +& +[ +u8 +] +> +> +: +: +new +( +) +} +} +macro_rules +! +bytes +{ +( +text +: +expr +) += +> +{ +text +} +} +macro_rules +! +no_expand +{ +( +text +: +expr +) += +> +{ +{ +use +regex +: +: +bytes +: +: +NoExpand +; +NoExpand +( +text +! +( +text +) +) +} +} +} +macro_rules +! +show +{ +( +text +: +expr +) += +> +{ +{ +use +std +: +: +ascii +: +: +escape_default +; +let +mut +s += +vec +! +[ +] +; +for +& +b +in +bytes +! +( +text +) +{ +s +. +extend +( +escape_default +( +b +) +) +; +} +String +: +: +from_utf8 +( +s +) +. +unwrap +( +) +} +} +} +macro_rules +! +expand +{ +( +name +: +ident +re +: +expr +text +: +expr +expand +: +expr +expected +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +re += +regex +! +( +re +) +; +let +cap += +re +. +captures +( +t +! +( +text +) +) +. +unwrap +( +) +; +let +mut +got += +vec +! +[ +] +; +cap +. +expand +( +t +! +( +expand +) +& +mut +got +) +; +assert_eq +! +( +show +! +( +t +! +( +expected +) +) +show +! +( +& +* +got +) +) +; +} +} +} diff --git a/third_party/rust/regex/tests/macros_str.rs b/third_party/rust/regex/tests/macros_str.rs new file mode 100644 index 0000000000000..01dda8017352f --- /dev/null +++ b/third_party/rust/regex/tests/macros_str.rs @@ -0,0 +1,420 @@ +/ +/ +Macros +for +use +in +writing +tests +generic +over +& +str +/ +& +[ +u8 +] +. +macro_rules +! +text +{ +( +text +: +expr +) += +> +{ +text +} +} +macro_rules +! +t +{ +( +text +: +expr +) += +> +{ +text +! +( +text +) +} +} +macro_rules +! +match_text +{ +( +text +: +expr +) += +> +{ +text +. +as_str +( +) +} +} +macro_rules +! +use_ +{ +( +( +path +: +tt +) +* +) += +> +{ +use +regex +: +: +( +path +) +* +; +} +} +macro_rules +! +empty_vec +{ +( +) += +> +{ +< +Vec +< +& +str +> +> +: +: +new +( +) +} +} +macro_rules +! +bytes +{ +( +text +: +expr +) += +> +{ +std +: +: +str +: +: +from_utf8 +( +text +. +as_ref +( +) +) +. +unwrap +( +) +} +} +macro_rules +! +no_expand +{ +( +text +: +expr +) += +> +{ +{ +use +regex +: +: +NoExpand +; +NoExpand +( +text +! +( +text +) +) +} +} +} +macro_rules +! +show +{ +( +text +: +expr +) += +> +{ +text +} +} +/ +/ +N +. +B +. +The +expansion +API +for +& +str +and +& +[ +u8 +] +APIs +differs +slightly +for +now +/ +/ +but +they +should +be +unified +in +1 +. +0 +. +Then +we +can +move +this +macro +back +into +/ +/ +tests +/ +api +. +rs +where +it +is +used +. +- +- +- +AG +macro_rules +! +expand +{ +( +name +: +ident +re +: +expr +text +: +expr +expand +: +expr +expected +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +re += +regex +! +( +re +) +; +let +cap += +re +. +captures +( +t +! +( +text +) +) +. +unwrap +( +) +; +let +mut +got += +String +: +: +new +( +) +; +cap +. +expand +( +t +! +( +expand +) +& +mut +got +) +; +assert_eq +! +( +show +! +( +t +! +( +expected +) +) +show +! +( +& +* +got +) +) +; +} +} +} +# +[ +cfg +( +feature += +" +pattern +" +) +] +macro_rules +! +searcher_expr +{ +( +e +: +expr +) += +> +( +e +) +} +# +[ +cfg +( +not +( +feature += +" +pattern +" +) +) +] +macro_rules +! +searcher_expr +{ +( +e +: +expr +) += +> +( +{ +} +) +} diff --git a/third_party/rust/regex/tests/misc.rs b/third_party/rust/regex/tests/misc.rs index 9c32d168fa51d..02dd9f597aa14 100644 --- a/third_party/rust/regex/tests/misc.rs +++ b/third_party/rust/regex/tests/misc.rs @@ -1,1338 +1,71 @@ -use -regex -: -: -Regex -; -macro_rules -! -regex -{ -( -pattern -: -expr -) -= -> -{ -regex -: -: -Regex -: -: -new -( -pattern -) -. -unwrap -( -) -} -; -} -# -[ -test -] -fn -unclosed_group_error -( -) -{ -let -err -= -Regex -: -: -new -( -r -" -( -" -) -. -unwrap_err -( -) -; -let -msg -= -err -. -to_string -( -) -; -assert -! -( -msg -. -contains -( -" -unclosed -group -" -) -" -error -message -: -{ -: -? -} -" -msg -) -; -} -# -[ -test -] -fn -regex_string -( -) -{ -assert_eq -! -( -r -" -[ -a -- -zA -- -Z0 -- -9 -] -+ -" -regex -! -( -r -" -[ -a -- -zA -- -Z0 -- -9 -] -+ -" -) -. -as_str -( -) -) -; -assert_eq -! -( -r -" -[ -a -- -zA -- -Z0 -- -9 -] -+ -" -& -format -! -( -" -{ -} -" -regex -! -( -r -" -[ -a -- -zA -- -Z0 -- -9 -] -+ -" -) -) -) -; -assert_eq -! -( -r -# -" -Regex -( -" -[ -a -- -zA -- -Z0 -- -9 -] -+ -" -) -" -# -& -format -! -( -" -{ -: -? -} -" -regex +mat ! ( +prefix_literal_match r " -[ -a -- -zA -- -Z0 -- -9 -] -+ +^ +abc " -) -) -) -; -} -# -[ -test -] -fn -capture_names -( -) -{ -let -re -= -regex -! -( r " -( -. -) -( -? -P -< -a -> -. -) +abc " -) -; -assert_eq -! -( -3 -re -. -captures_len -( -) -) -; -assert_eq -! -( -( -3 -Some -( -3 -) -) -re -. -capture_names -( -) -. -size_hint -( -) -) -; -assert_eq -! -( -vec -! -[ -None -None Some ( -" -a -" -) -] -re -. -capture_names ( +0 +3 ) -. -collect -: -: -< -Vec -< -_ -> -> -( ) ) ; -} -# -[ -test -] -fn -capture_index -( -) -{ -let -re -= -regex +mat ! ( +prefix_literal_nomatch r " ^ -( -? -P -< -name -> -. -+ -) -" -) -; -let -cap -= -re -. -captures -( -" -abc -" -) -. -unwrap -( -) -; -assert_eq -! -( -& -cap -[ -0 -] -" -abc -" -) -; -assert_eq -! -( -& -cap -[ -1 -] -" -abc -" -) -; -assert_eq -! -( -& -cap -[ -" -name -" -] -" abc " -) -; -} -# -[ -test -] -# -[ -should_panic -] -fn -capture_index_panic_usize -( -) -{ -let -re -= -regex -! -( r " -^ -( -? -P -< -name -> -. -+ -) -" -) -; -let -cap -= -re -. -captures -( -" -abc +zabc " +None ) -. -unwrap -( -) -; -let -_ -= -cap -[ -2 -] ; -} -# -[ -test -] -# -[ -should_panic -] -fn -capture_index_panic_name -( -) -{ -let -re -= -regex +mat ! ( +one_literal_edge r " -^ -( -? -P -< -name -> -. -+ -) -" -) -; -let -cap -= -re -. -captures -( -" abc " -) -. -unwrap -( -) -; -let -_ -= -cap -[ -" -bad -name -" -] -; -} -# -[ -test -] -fn -capture_index_lifetime -( -) -{ -/ -/ -This -is -a -test -of -whether -the -types -on -caps -[ -" -. -. -. -" -] -are -general -/ -/ -enough -. -If -not -this -will -fail -to -typecheck -. -fn -inner -( -s -: -& -str -) -- -> -usize -{ -let -re -= -regex -! -( r " -( -? -P -< -number -> -[ -0 -- -9 -] -+ -) +xxxxxab " +None ) ; -let -caps -= -re -. -captures -( -s -) -. -unwrap -( -) -; -caps -[ -" -number -" -] -. -len -( -) -} -assert_eq +matiter ! ( -3 -inner -( +terminates +r " -123 +a " -) -) -; -} -# -[ -test -] -fn -capture_misc -( -) -{ -let -re -= -regex -! -( r " -( -. -) -( -? -P -< -a -> a -) -? -( -. -) -( -? -P -< -b -> -. -) " -) -; -let -cap -= -re -. -captures ( -" -abc -" -) -. -unwrap -( -) -; -assert_eq -! -( -5 -cap -. -len -( -) -) -; -assert_eq -! -( -( -0 -3 -) -{ -let -m -= -cap -. -get -( -0 -) -. -unwrap -( -) -; -( -m -. -start -( -) -m -. -end -( -) -) -} -) -; -assert_eq -! -( -None -cap -. -get -( -2 -) -) -; -assert_eq -! -( -( -2 -3 -) -{ -let -m -= -cap -. -get -( -4 -) -. -unwrap -( -) -; -( -m -. -start -( -) -m -. -end -( -) -) -} -) -; -assert_eq -! -( -" -abc -" -cap -. -get -( -0 -) -. -unwrap -( -) -. -as_str -( -) -) -; -assert_eq -! -( -None -cap -. -get -( -2 -) -) -; -assert_eq -! -( -" -c -" -cap -. -get -( -4 -) -. -unwrap -( -) -. -as_str -( -) -) -; -assert_eq -! -( -None -cap -. -name -( -" -a -" -) -) -; -assert_eq -! -( -" -c -" -cap -. -name -( -" -b -" -) -. -unwrap -( -) -. -as_str -( -) -) -; -} -# -[ -test -] -fn -sub_capture_matches -( -) -{ -let -re -= -regex -! -( -r -" -( -[ -a -- -z -] -) -( -( -[ -a -- -z -] -) -| -( -[ -0 -- -9 -] -) -) -" -) -; -let -cap -= -re -. -captures -( -" -a5 -" -) -. -unwrap -( -) -; -let -subs -: -Vec -< -_ -> -= -cap -. -iter -( -) -. -collect -( -) -; -assert_eq -! -( -5 -subs -. -len -( -) -) -; -assert -! -( -subs -[ -0 -] -. -is_some -( -) -) -; -assert -! -( -subs -[ -1 -] -. -is_some -( -) -) -; -assert -! -( -subs -[ -2 -] -. -is_some -( -) -) -; -assert -! -( -subs -[ -3 -] -. -is_none -( -) -) -; -assert -! -( -subs -[ -4 -] -. -is_some -( -) -) -; -assert_eq -! -( -" -a5 -" -subs -[ 0 -] -. -unwrap -( -) -. -as_str -( -) -) -; -assert_eq -! -( -" -a -" -subs -[ 1 -] -. -unwrap -( -) -. -as_str -( -) -) -; -assert_eq -! -( -" -5 -" -subs -[ -2 -] -. -unwrap -( -) -. -as_str -( -) -) -; -assert_eq -! -( -" -5 -" -subs -[ -4 -] -. -unwrap -( -) -. -as_str -( -) -) -; -} -/ -/ -Test -that -the -DFA -can -handle -pathological -cases -. -( -This -should -result -in -the -/ -/ -DFA -' -s -cache -being -flushed -too -frequently -which -should -cause -it -to -quit -and -/ -/ -fall -back -to -the -NFA -algorithm -. -) -# -[ -test -] -fn -dfa_handles_pathological_case -( -) -{ -fn -ones_and_zeroes -( -count -: -usize -) -- -> -String -{ -let -mut -s -= -String -: -: -new -( -) -; -for -i -in -0 -. -. -count -{ -if -i -% -3 -= -= -0 -{ -s -. -push -( -' -1 -' -) -; -} -else -{ -s -. -push -( -' -0 -' -) -; -} -} -s -} -let -re -= -regex -! -( -r -" -[ -01 -] -* -1 -[ -01 -] -{ -20 -} -" -) -; -let -text -= -{ -let -mut -pieces -= -ones_and_zeroes -( -100_000 -) -; -pieces -. -push -( -' -1 -' -) -; -pieces -. -push_str -( -& -ones_and_zeroes -( -20 -) -) -; -pieces -} -; -assert -! -( -re -. -is_match -( -& -text ) ) ; -} diff --git a/third_party/rust/regex/tests/multiline.rs b/third_party/rust/regex/tests/multiline.rs new file mode 100644 index 0000000000000..572ffd64fa4ef --- /dev/null +++ b/third_party/rust/regex/tests/multiline.rs @@ -0,0 +1,979 @@ +matiter +! +( +match_multi_1 +r +" +( +? +m +) +^ +[ +a +- +z +] ++ +" +" +abc +\ +ndef +\ +nxyz +" +( +0 +3 +) +( +4 +7 +) +( +8 +11 +) +) +; +matiter +! +( +match_multi_2 +r +" +( +? +m +) +^ +" +" +abc +\ +ndef +\ +nxyz +" +) +; +matiter +! +( +match_multi_3 +r +" +( +? +m +) +^ +" +" +abc +\ +ndef +\ +nxyz +" +( +0 +0 +) +( +4 +4 +) +( +8 +8 +) +) +; +matiter +! +( +match_multi_4 +r +" +( +? +m +) +" +" +abc +\ +ndef +\ +nxyz +" +( +3 +3 +) +( +7 +7 +) +( +11 +11 +) +) +; +matiter +! +( +match_multi_5 +r +" +( +? +m +) +^ +[ +a +- +z +] +" +" +abc +\ +ndef +\ +nxyz +" +( +0 +1 +) +( +4 +5 +) +( +8 +9 +) +) +; +matiter +! +( +match_multi_6 +r +" +( +? +m +) +[ +a +- +z +] +^ +" +" +abc +\ +ndef +\ +nxyz +" +) +; +matiter +! +( +match_multi_7 +r +" +( +? +m +) +[ +a +- +z +] +" +" +abc +\ +ndef +\ +nxyz +" +( +2 +3 +) +( +6 +7 +) +( +10 +11 +) +) +; +matiter +! +( +match_multi_8 +r +" +( +? +m +) +[ +a +- +z +] +" +" +abc +\ +ndef +\ +nxyz +" +) +; +matiter +! +( +match_multi_9 +r +" +( +? +m +) +^ +" +" +" +( +0 +0 +) +) +; +matiter +! +( +match_multi_rep_1 +r +" +( +? +m +) +( +? +: +^ +) +* +" +" +a +\ +nb +\ +nc +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +5 +) +) +; +matiter +! +( +match_multi_rep_2 +r +" +( +? +m +) +( +? +: +^ +| +a +) ++ +" +" +a +\ +naaa +\ +n +" +( +0 +0 +) +( +2 +2 +) +( +3 +5 +) +( +6 +6 +) +) +; +matiter +! +( +match_multi_rep_3 +r +" +( +? +m +) +( +? +: +^ +| +a +) +* +" +" +a +\ +naaa +\ +n +" +( +0 +1 +) +( +2 +5 +) +( +6 +6 +) +) +; +matiter +! +( +match_multi_rep_4 +r +" +( +? +m +) +( +? +: +^ +[ +a +- +z +] +) ++ +" +" +abc +\ +ndef +\ +nxyz +" +( +0 +1 +) +( +4 +5 +) +( +8 +9 +) +) +; +matiter +! +( +match_multi_rep_5 +r +" +( +? +m +) +( +? +: +^ +[ +a +- +z +] +{ +3 +} +\ +n +? +) ++ +" +" +abc +\ +ndef +\ +nxyz +" +( +0 +11 +) +) +; +matiter +! +( +match_multi_rep_6 +r +" +( +? +m +) +( +? +: +^ +[ +a +- +z +] +{ +3 +} +\ +n +? +) +* +" +" +abc +\ +ndef +\ +nxyz +" +( +0 +11 +) +) +; +matiter +! +( +match_multi_rep_7 +r +" +( +? +m +) +( +? +: +\ +n +? +[ +a +- +z +] +{ +3 +} +) ++ +" +" +abc +\ +ndef +\ +nxyz +" +( +0 +11 +) +) +; +matiter +! +( +match_multi_rep_8 +r +" +( +? +m +) +( +? +: +\ +n +? +[ +a +- +z +] +{ +3 +} +) +* +" +" +abc +\ +ndef +\ +nxyz +" +( +0 +11 +) +) +; +matiter +! +( +match_multi_rep_9 +r +" +( +? +m +) +^ +* +" +" +\ +naa +\ +n +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +) +; +matiter +! +( +match_multi_rep_10 +r +" +( +? +m +) +^ ++ +" +" +\ +naa +\ +n +" +( +0 +0 +) +( +1 +1 +) +( +4 +4 +) +) +; +matiter +! +( +match_multi_rep_11 +r +" +( +? +m +) +* +" +" +\ +naa +\ +n +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +) +; +matiter +! +( +match_multi_rep_12 +r +" +( +? +m +) ++ +" +" +\ +naa +\ +n +" +( +0 +0 +) +( +3 +3 +) +( +4 +4 +) +) +; +matiter +! +( +match_multi_rep_13 +r +" +( +? +m +) +( +? +: +\ +n +) ++ +" +" +\ +n +\ +naaa +\ +n +\ +n +" +( +0 +2 +) +( +5 +7 +) +) +; +matiter +! +( +match_multi_rep_14 +r +" +( +? +m +) +( +? +: +\ +n +) +* +" +" +\ +n +\ +naaa +\ +n +\ +n +" +( +0 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +7 +) +) +; +matiter +! +( +match_multi_rep_15 +r +" +( +? +m +) +( +? +: +\ +n +^ +) ++ +" +" +\ +n +\ +naaa +\ +n +\ +n +" +( +0 +2 +) +( +5 +7 +) +) +; +matiter +! +( +match_multi_rep_16 +r +" +( +? +m +) +( +? +: +^ +| +) ++ +" +" +\ +n +\ +naaa +\ +n +\ +n +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +5 +5 +) +( +6 +6 +) +( +7 +7 +) +) +; +matiter +! +( +match_multi_rep_17 +r +" +( +? +m +) +( +? +: +\ +n +) +* +" +" +\ +n +\ +naaa +\ +n +\ +n +" +( +0 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +7 +) +) +; diff --git a/third_party/rust/regex/tests/noparse.rs b/third_party/rust/regex/tests/noparse.rs new file mode 100644 index 0000000000000..cbe5c442fc31f --- /dev/null +++ b/third_party/rust/regex/tests/noparse.rs @@ -0,0 +1,483 @@ +macro_rules +! +noparse +( +( +name +: +ident +re +: +expr +) += +> +( +# +[ +test +] +fn +name +( +) +{ +let +re += +re +; +match +regex_new +! +( +re +) +{ +Err +( +_ +) += +> +{ +} +Ok +( +_ +) += +> +panic +! +( +" +Regex +' +{ +} +' +should +cause +a +parse +error +. +" +re +) +} +} +) +; +) +; +noparse +! +( +fail_no_repeat_arg +" +* +" +) +; +noparse +! +( +fail_incomplete_escape +" +\ +\ +" +) +; +noparse +! +( +fail_class_incomplete +" +[ +A +- +" +) +; +noparse +! +( +fail_class_not_closed +" +[ +A +" +) +; +noparse +! +( +fail_class_no_begin +r +" +[ +\ +A +] +" +) +; +noparse +! +( +fail_class_no_end +r +" +[ +\ +z +] +" +) +; +noparse +! +( +fail_class_no_boundary +r +" +[ +\ +b +] +" +) +; +noparse +! +( +fail_open_paren +" +( +" +) +; +noparse +! +( +fail_close_paren +" +) +" +) +; +noparse +! +( +fail_invalid_range +" +[ +a +- +Z +] +" +) +; +noparse +! +( +fail_empty_capture_name +" +( +? +P +< +> +a +) +" +) +; +noparse +! +( +fail_bad_capture_name +" +( +? +P +< +na +- +me +> +) +" +) +; +noparse +! +( +fail_bad_flag +" +( +? +a +) +a +" +) +; +noparse +! +( +fail_too_big +" +a +{ +10000000 +} +" +) +; +noparse +! +( +fail_counted_no_close +" +a +{ +1001 +" +) +; +noparse +! +( +fail_counted_decreasing +" +a +{ +2 +1 +} +" +) +; +noparse +! +( +fail_counted_nonnegative +" +a +{ +- +1 +1 +} +" +) +; +noparse +! +( +fail_unfinished_cap +" +( +? +" +) +; +noparse +! +( +fail_unfinished_escape +" +\ +\ +" +) +; +noparse +! +( +fail_octal_digit +r +" +\ +8 +" +) +; +noparse +! +( +fail_hex_digit +r +" +\ +xG0 +" +) +; +noparse +! +( +fail_hex_short +r +" +\ +xF +" +) +; +noparse +! +( +fail_hex_long_digits +r +" +\ +x +{ +fffg +} +" +) +; +noparse +! +( +fail_flag_bad +" +( +? +a +) +" +) +; +noparse +! +( +fail_flag_empty +" +( +? +) +" +) +; +noparse +! +( +fail_double_neg +" +( +? +- +i +- +i +) +" +) +; +noparse +! +( +fail_neg_empty +" +( +? +i +- +) +" +) +; +noparse +! +( +fail_dupe_named +" +( +? +P +< +a +> +. +) +( +? +P +< +a +> +. +) +" +) +; +noparse +! +( +fail_range_end_no_class +" +[ +a +- +[ +: +lower +: +] +] +" +) +; +noparse +! +( +fail_range_end_no_begin +r +" +[ +a +- +\ +A +] +" +) +; +noparse +! +( +fail_range_end_no_end +r +" +[ +a +- +\ +z +] +" +) +; +noparse +! +( +fail_range_end_no_boundary +r +" +[ +a +- +\ +b +] +" +) +; diff --git a/third_party/rust/regex/tests/regression.rs b/third_party/rust/regex/tests/regression.rs index e032ae275415f..fcec5d1034f34 100644 --- a/third_party/rust/regex/tests/regression.rs +++ b/third_party/rust/regex/tests/regression.rs @@ -1,38 +1,3 @@ -use -regex -: -: -Regex -; -macro_rules -! -regex -{ -( -pattern -: -expr -) -= -> -{ -regex -: -: -Regex -: -: -new -( -pattern -) -. -unwrap -( -) -} -; -} / / See @@ -66,10 +31,8 @@ invalid_regexes_no_crash assert ! ( -Regex -: -: -new +regex_new +! ( " ( @@ -86,10 +49,8 @@ is_err assert ! ( -Regex -: -: -new +regex_new +! ( " ( @@ -108,10 +69,8 @@ is_err assert ! ( -Regex -: -: -new +regex_new +! ( " ( @@ -128,10 +87,8 @@ is_err assert ! ( -Regex -: -: -new +regex_new +! ( " * @@ -196,43 +153,19 @@ assert_eq vec ! [ +( 0 -. -. 1 +) ] -re -. -find_iter +findall +! ( +re " a " ) -. -map -( -| -m -| -m -. -range -( -) -) -. -collect -: -: -< -Vec -< -_ -> -> -( -) ) ; } @@ -269,10 +202,8 @@ regression_invalid_repetition_expr assert ! ( -Regex -: -: -new +regex_new +! ( " ( @@ -325,10 +256,8 @@ regression_invalid_flags_expression assert ! ( -Regex -: -: -new +regex_new +! ( " ( @@ -368,81 +297,65 @@ regex / issues / -129 -# -[ -test -] -fn -regression_captures_rep -( -) -{ -let -re -= -regex +75 +mat ! ( +regression_unsorted_binary_search_1 r " ( -[ -a +? +i - -f -] +u ) -{ -2 -} -( -? -P -< -foo -> [ -x -- -z +a_ ] -) ++ " -) -; -let -caps -= -re -. -captures -( " -abx +A_ " -) -. -unwrap +Some ( +( +0 +2 +) +) ) ; -assert_eq +mat ! ( -& -caps -[ -" -foo +regression_unsorted_binary_search_2 +r " +( +? +i +- +u +) +[ +A_ ] ++ " -x " +a_ +" +Some +( +( +0 +2 +) +) ) ; -} / / See @@ -455,13 +368,15 @@ github . com / -BurntSushi +rust +- +lang / -ripgrep +regex / issues / -1247 +99 # [ cfg @@ -471,73 +386,65 @@ feature " unicode - -perl +case " ) ] -# -[ -test -] -fn -regression_nfa_stops1 -( -) -{ -let -re -= -regex -: -: -bytes -: -: -Regex -: -: -new +mat +! ( +regression_negated_char_class_1 r " -\ -bs ( ? -: +i +) [ -ab +^ +x ] -) " -) -. -unwrap -( +" +x +" +None ) ; -assert_eq -! -( -0 -re -. -find_iter +# +[ +cfg ( -b +feature += " -s -\ -xE4 +unicode +- +case " ) -. -count +] +mat +! +( +regression_negated_char_class_2 +r +" ( +? +i ) +[ +^ +x +] +" +" +X +" +None ) ; -} / / See @@ -558,24 +465,60 @@ regex / issues / -981 -# -[ -cfg +101 +mat +! ( -feature -= -" -unicode +regression_ascii_word_underscore +r " -) +[ +[ +: +word +: ] +] +" +" +_ +" +Some +( +( +0 +1 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +129 # [ test ] fn -regression_bad_word_boundary +regression_captures_rep ( ) { @@ -586,92 +529,77 @@ regex ! ( r -# " ( -? -i -: -( -? -: -\ -b -| -_ -) -win -( -? -: -32 -| -64 -| -dows +[ +a +- +f +] ) -? +{ +2 +} ( ? -: -\ -b -| -_ -) +P +< +foo +> +[ +x +- +z +] ) " -# ) ; let -hay +caps = -" -ubi -- -Darwin -- -x86_64 -. -tar +re . -gz -" -; -assert -! +captures ( +text ! -re -. -is_match ( -hay +" +abx +" ) ) -; -let -hay -= -" -ubi -- -Windows -- -x86_64 . -zip -" +unwrap +( +) ; -assert +assert_eq ! ( -re +match_text +! +( +caps +. +name +( +" +foo +" +) . -is_match +unwrap +( +) +) +text +! ( -hay +" +x +" ) ) ; @@ -696,145 +624,67 @@ regex / issues / -982 -# -[ -cfg -( -feature -= -" -unicode -- -perl -" -) -] -# -[ -test -] -fn -regression_unicode_perl_not_enabled +153 +mat +! ( -) -{ -let -pat -= +regression_alt_in_alt1 r " -( -\ -d -+ -\ -s +ab ? -( -years -| -year | -y -) -) -? -\ -s -? +" +" +az +" +Some ( -\ -d -+ -\ -s -? ( -months -| -month -| -m +0 +1 ) ) -? -\ -s -? +) +; +mat +! ( -\ -d -+ -\ -s -? +regression_alt_in_alt2 +r +" +^ ( -weeks -| -week -| -w -) -) -? -\ -s +. +* ? +) ( \ -d -+ -\ -s -? -( -days +n | -day -| -d -) -) -? -\ -s -? -( \ -d -+ +r \ -s +n ? -( -hours | -hour -| -h ) -) -? " -; -assert -! +" +ab +\ +rcd +" +Some ( -Regex -: -: -new ( -pat +0 +3 ) -. -is_ok -( ) ) ; -} / / See @@ -855,49 +705,29 @@ regex / issues / -995 -# -[ -test -] -fn -regression_big_regex_overflow +169 +mat +! ( -) -{ -let -pat -= +regression_leftmost_first_prefix r " -{ -2147483516 -} -{ -2147483416 -} -{ -5 -} +z +* +azb " -; -assert -! +" +azb +" +Some ( -Regex -: -: -new ( -pat +0 +3 ) -. -is_err -( ) ) ; -} / / See @@ -918,130 +748,1673 @@ regex / issues / -999 +76 # [ -test -] -fn -regression_complete_literals_suffix_incorrect +cfg ( -) -{ -let -needles +all +( +feature = -vec -! -[ -" -aA -" -" -bA " +unicode +- +case " -cA -" -" -dA -" -" -eA -" +feature += " -fA +unicode +- +gencat " +) +) +] +mat +! +( +uni_case_lower_nocase_flag +r " -gA +( +? +i +) +\ +p +{ +Ll +} ++ " " -hA " +Some +( +( +0 +10 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +191 +mat +! +( +many_alternates +r " -iA +1 +| +2 +| +3 +| +4 +| +5 +| +6 +| +7 +| +8 +| +9 +| +10 +| +int " " -jA +int " +Some +( +( +0 +3 +) +) +) +; +/ +/ +burntsushi +was +bad +and +didn +' +t +create +an +issue +for +this +bug +. +mat +! +( +anchored_prefix1 +r " -kA +^ +a +[ +[ +: +^ +space +: +] +] " " -lA +a " +None +) +; +mat +! +( +anchored_prefix2 +r " -mA +^ +a +[ +[ +: +^ +space +: +] +] " " -nA +foo +boo +a " +None +) +; +mat +! +( +anchored_prefix3 +r " -oA +^ +- +[ +a +- +z +] " " -pA +r +- +f " +None +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +204 +# +[ +cfg +( +feature += " -qA +unicode +- +perl " +) +] +split +! +( +split_on_word_boundary +r " -rA +\ +b " +r " -sA +Should +this +( +work +? +) " +& +[ +t +! +( " -tA " +) +t +! +( " -uA +Should " +) +t +! +( " -vA " +) +t +! +( " -wA +this " +) +t +! +( " -xA +( " +) +t +! +( " -yA +work " +) +t +! +( " -zA +? +) " +) ] +) ; -let -pattern -= -needles -. -join +# +[ +cfg ( +feature += " -| +unicode +- +perl " ) -; -let -re -= -regex +] +matiter ! ( -& -pattern -) -; -let -hay -= -" -FUBAR +word_boundary_dfa +r " +\ +b +" +" +a +b +c +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +5 +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +268 +matiter +! +( +partial_anchor +r +" +^ +a +| +b +" +" +ba +" +( +0 +1 +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +280 +ismatch +! +( +partial_anchor_alternate_begin +r +" +^ +a +| +z +" +" +yyyyya +" +false +) +; +ismatch +! +( +partial_anchor_alternate_end +r +" +a +| +z +" +" +ayyyyy +" +false +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +289 +mat +! +( +lits_unambiguous1 +r +" +( +ABC +| +CDA +| +BC +) +X +" +" +CDAX +" +Some +( +( +0 +4 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +291 +mat +! +( +lits_unambiguous2 +r +" +( +( +IMG +| +CAM +| +MG +| +MB2 +) +_ +| +( +DSCN +| +CIMG +) +) +( +? +P +< +n +> +[ +0 +- +9 +] ++ +) +" +" +CIMG2341 +" +Some +( +( +0 +8 +) +) +Some +( +( +0 +4 +) +) +None +Some +( +( +0 +4 +) +) +Some +( +( +4 +8 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +271 +mat +! +( +endl_or_wb +r +" +( +? +m +: +) +| +( +? +- +u +: +\ +b +) +" +" +\ +u +{ +6084e +} +" +Some +( +( +4 +4 +) +) +) +; +mat +! +( +zero_or_end +r +" +( +? +i +- +u +: +\ +x00 +) +| +" +" +\ +u +{ +e682f +} +" +Some +( +( +4 +4 +) +) +) +; +mat +! +( +y_or_endl +r +" +( +? +i +- +u +: +y +) +| +( +? +m +: +) +" +" +\ +u +{ +b4331 +} +" +Some +( +( +4 +4 +) +) +) +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mat +! +( +wb_start_x +r +" +( +? +u +: +\ +b +) +^ +( +? +- +u +: +X +) +" +" +X +" +Some +( +( +0 +1 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +321 +ismatch +! +( +strange_anchor_non_complete_prefix +r +" +a +^ +{ +2 +} +" +" +" +false +) +; +ismatch +! +( +strange_anchor_non_complete_suffix +r +" +{ +2 +} +a +" +" +" +false +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +BurntSushi +/ +ripgrep +/ +issues +/ +1203 +ismatch +! +( +reverse_suffix1 +r +" +[ +0 +- +4 +] +[ +0 +- +4 +] +[ +0 +- +4 +] +000 +" +" +153 +. +230000 +" +true +) +; +ismatch +! +( +reverse_suffix2 +r +" +[ +0 +- +9 +] +[ +0 +- +9 +] +[ +0 +- +9 +] +000 +" +" +153 +. +230000 +\ +n +" +true +) +; +matiter +! +( +reverse_suffix3 +r +" +[ +0 +- +9 +] +[ +0 +- +9 +] +[ +0 +- +9 +] +000 +" +" +153 +. +230000 +\ +n +" +( +4 +10 +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +334 +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +557 +mat +! +( +captures_after_dfa_premature_end1 +r +" +a +( +b +* +( +X +| +) +) +? +" +" +abcbX +" +Some +( +( +0 +1 +) +) +None +None +) +; +mat +! +( +captures_after_dfa_premature_end2 +r +" +a +( +bc +* +( +X +| +) +) +? +" +" +abcbX +" +Some +( +( +0 +1 +) +) +None +None +) +; +mat +! +( +captures_after_dfa_premature_end3 +r +" +( +aa +) +? +" +" +aaz +" +Some +( +( +0 +0 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +437 +ismatch +! +( +literal_panic +r +" +typename +type +\ +- +parameter +\ +- +[ +0 +- +9 +] ++ +\ +- +[ +0 +- +9 +] ++ +: +: +. ++ +" +" +test +" +false +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +533 +ismatch +! +( +blank_matches_nothing_between_space_and_tab +r +" +[ +[ +: +blank +: +] +] +" +" +\ +u +{ +a +} +\ +u +{ +b +} +\ +u +{ +c +} +\ +u +{ +d +} +\ +u +{ +e +} +\ +u +{ +f +} +\ +\ +u +{ +10 +} +\ +u +{ +11 +} +\ +u +{ +12 +} +\ +u +{ +13 +} +\ +u +{ +14 +} +\ +u +{ +15 +} +\ +u +{ +16 +} +\ +u +{ +17 +} +\ +\ +u +{ +18 +} +\ +u +{ +19 +} +\ +u +{ +1a +} +\ +u +{ +1b +} +\ +u +{ +1c +} +\ +u +{ +1d +} +\ +u +{ +1e +} +\ +u +{ +1f +} +" +false +) +; +ismatch +! +( +inverted_blank_matches_everything_between_space_and_tab +r +" +^ +[ +[ +: +^ +blank +: +] +] ++ +" +" +\ +u +{ +a +} +\ +u +{ +b +} +\ +u +{ +c +} +\ +u +{ +d +} +\ +u +{ +e +} +\ +u +{ +f +} +\ +\ +u +{ +10 +} +\ +u +{ +11 +} +\ +u +{ +12 +} +\ +u +{ +13 +} +\ +u +{ +14 +} +\ +u +{ +15 +} +\ +u +{ +16 +} +\ +u +{ +17 +} +\ +\ +u +{ +18 +} +\ +u +{ +19 +} +\ +u +{ +1a +} +\ +u +{ +1b +} +\ +u +{ +1c +} +\ +u +{ +1d +} +\ +u +{ +1e +} +\ +u +{ +1f +} +" +true +) +; +/ +/ +Tests +that +our +Aho +- +Corasick +optimization +works +correctly +. +It +only +/ +/ +kicks +in +when +we +have +> +32 +literals +. +By +" +works +correctly +" +we +mean +that +/ +/ +leftmost +- +first +match +semantics +are +properly +respected +. +That +is +samwise +/ +/ +should +match +not +sam +. +mat +! +( +ahocorasick1 +" +samwise +| +sam +| +a +| +b +| +c +| +d +| +e +| +f +| +g +| +h +| +i +| +j +| +k +| +l +| +m +| +n +| +o +| +p +| +q +| +r +| +s +| +t +| +u +| +v +| +w +| +x +| +y +| +z +| +\ +A +| +B +| +C +| +D +| +E +| +F +| +G +| +H +| +I +| +J +| +K +| +L +| +M +| +N +| +O +| +P +| +Q +| +R +| +S +| +T +| +U +| +V +| +W +| +X +| +Y +| +Z +" +" +samwise +" +Some +( +( +0 +7 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +BurntSushi +/ +ripgrep +/ +issues +/ +1247 +# +[ +test +] +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +fn +regression_nfa_stops1 +( +) +{ +let +re += +: +: +regex +: +: +bytes +: +: +Regex +: +: +new +( +r +" +\ +bs +( +? +: +[ +ab +] +) +" +) +. +unwrap +( +) ; assert_eq ! @@ -1051,7 +2424,12 @@ re . find_iter ( -hay +b +" +s +\ +xE4 +" ) . count @@ -1060,3 +2438,208 @@ count ) ; } +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +640 +# +[ +cfg +( +feature += +" +unicode +- +case +" +) +] +matiter +! +( +flags_are_unset +r +" +( +( +? +i +) +foo +) +| +Bar +" +" +foo +Foo +bar +Bar +" +( +0 +3 +) +( +4 +7 +) +( +12 +15 +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +659 +/ +/ +/ +/ +Note +that +' +' +is +not +' +j +' +but +cyrillic +Je +/ +/ +https +: +/ +/ +en +. +wikipedia +. +org +/ +wiki +/ +Je_ +( +Cyrillic +) +ismatch +! +( +empty_group_match +r +" +( +) +01 +" +" +z +01 +" +true +) +; +matiter +! +( +empty_group_find +r +" +( +) +01 +" +" +z +01 +" +( +1 +5 +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +862 +mat +! +( +non_greedy_question_literal +r +" +ab +? +? +" +" +ab +" +Some +( +( +0 +1 +) +) +) +; diff --git a/third_party/rust/regex/tests/regression_fuzz.rs b/third_party/rust/regex/tests/regression_fuzz.rs index 12daf6cf26e71..bed4a3fdef95f 100644 --- a/third_party/rust/regex/tests/regression_fuzz.rs +++ b/third_party/rust/regex/tests/regression_fuzz.rs @@ -49,41 +49,6 @@ mode : - / -use -regex -: -: -Regex -; -macro_rules -! -regex -{ -( -pattern -: -expr -) -= -> -{ -regex -: -: -Regex -: -: -new -( -pattern -) -. -unwrap -( -) -} -; -} / / See @@ -234,17 +199,6 @@ issues [ test ] -# -[ -cfg -( -feature -= -" -unicode -" -) -] fn empty_any_errors_no_panic ( @@ -253,10 +207,8 @@ empty_any_errors_no_panic assert ! ( -Regex -: -: -new +regex_new +! ( r " @@ -268,7 +220,7 @@ any " ) . -is_ok +is_err ( ) ) @@ -407,200 +359,14 @@ p assert ! ( -Regex -: -: -new -( -pat -) -. -is_err -( -) -) -; -} -/ -/ -This -was -caught -while -on -master -but -before -a -release -went -out -( -! -) -. -/ -/ -/ -/ -See -: -https -: -/ -/ -bugs -. -chromium -. -org -/ -p -/ -oss -- -fuzz -/ -issues -/ -detail -? -id -= -58173 -# -[ -test -] -fn -todo -( -) -{ -let -pat -= -" -( -? -: -z -| -xx -) -| -xx -" -; -assert +regex_new ! ( -Regex -: -: -new -( -pat -) -. -is_ok -( -) -) -; -} -/ -/ -This -was -caused -by -the -fuzzer -and -then -minimized -by -hand -. -/ -/ -/ -/ -This -was -caused -by -a -bug -in -DFA -determinization -that -mishandled -NFA -fail -/ -/ -states -. -# -[ -test -] -fn -fail_branch_prevents_match -( -) -{ -let -pat -= -r -" -. -* -[ -a -& -& -b -] -A -| -B -" -; -let -hay -= -" -B -" -; -let -re -= -Regex -: -: -new -( pat ) . -unwrap -( -) -; -assert -! -( -re -. -is_match +is_err ( -hay ) ) ; diff --git a/third_party/rust/regex/tests/replace.rs b/third_party/rust/regex/tests/replace.rs index 802a971a4a4f9..ac3b3a73dd948 100644 --- a/third_party/rust/regex/tests/replace.rs +++ b/third_party/rust/regex/tests/replace.rs @@ -38,19 +38,10 @@ let re = regex -: -: -Regex -: -: -new +! ( re ) -. -unwrap -( -) ; assert_eq ! @@ -59,11 +50,19 @@ re . which ( +text +! +( search +) replace ) +text +! +( result ) +) ; } ) @@ -88,9 +87,13 @@ age : 26 " +t +! +( " Z " +) " age : @@ -117,9 +120,13 @@ age : 26 " +t +! +( " Z " +) " age : @@ -145,9 +152,13 @@ age : 26 " +t +! +( " Z " +) " age : @@ -163,18 +174,21 @@ replace r " ( -[ -^ -] +? +- +u +) +( +\ +S + ) -[ -] +\ +s + ( -[ -^ -] +\ +S + ) " @@ -182,10 +196,14 @@ r w1 w2 " +t +! +( " 2 1 " +) " w2 w1 @@ -200,18 +218,21 @@ replace r " ( -[ -^ -] +? +- +u +) +( +\ +S + ) -[ -] +\ +s + ( -[ -^ -] +\ +S + ) " @@ -219,10 +240,14 @@ r w1 w2 " +t +! +( " 2 1 " +) " w2 1 @@ -251,9 +276,13 @@ ies " skies " +t +! +( " 1y " +) " sky " @@ -268,17 +297,21 @@ r " ( ? +- +u +) +( +? P < first > -[ -^ -] +\ +S + ) -[ -] +\ +s + ( ? @@ -286,9 +319,8 @@ P < last > -[ -^ -] +\ +S + ) ( @@ -297,8 +329,8 @@ P < space > -[ -] +\ +s * ) " @@ -308,11 +340,15 @@ w2 w3 w4 " +t +! +( " last first space " +) " w2 w1 @@ -350,8 +386,12 @@ t \ t " +t +! +( " " +) " trim me @@ -361,7 +401,7 @@ me replace ! ( -number_hyphen +number_hypen replace r " @@ -375,11 +415,15 @@ r " ab " +t +! +( " 1 - 2 " +) " a - @@ -406,10 +450,14 @@ r " ab " +t +! +( " 1_ 2 " +) " a_b " @@ -423,28 +471,31 @@ replace_all r " ( -[ -a +? - -z -] +u ) ( -[ -a -- -z -] +\ +w +) +( +\ +w ) " " a b " +t +! +( " 2 1 " +) " b a @@ -459,19 +510,18 @@ replace_all r " ( -[ -a +? - -z -] +u +) +( +\ +w + ) ( -[ -a -- -z -] +\ +w + ) " @@ -479,9 +529,13 @@ z a b " +t +! +( " 1 " +) " 1 " @@ -495,19 +549,18 @@ replace_all r " ( -[ -a +? - -z -] +u +) +( +\ +w + ) ( -[ -a -- -z -] +\ +w + ) " @@ -515,11 +568,15 @@ z a b " +t +! +( " 2 c 1 " +) " b c @@ -535,18 +592,21 @@ replace r " ( -[ -^ -] +? +- +u +) +( +\ +S + ) -[ -] +\ +s + ( -[ -^ -] +\ +S + ) " @@ -554,10 +614,8 @@ r w1 w2 " -regex -: -: -NoExpand +no_expand +! ( " 2 @@ -578,18 +636,21 @@ replace r " ( -[ -^ -] +? +- +u +) +( +\ +S + ) -[ -] +\ +s + ( -[ -^ -] +\ +S + ) " @@ -597,10 +658,8 @@ r w1 w2 " -regex -: -: -NoExpand +no_expand +! ( " 1 @@ -611,6 +670,12 @@ NoExpand " ) ; +use_ +! +( +Captures +) +; replace ! ( @@ -636,9 +701,6 @@ age captures : & -regex -: -: Captures < ' @@ -646,10 +708,20 @@ _ > | { +match_text +! +( captures -[ +. +get +( 1 -] +) +. +unwrap +( +) +) [ 0 . @@ -691,18 +763,19 @@ age _captures : & -regex -: -: Captures < ' _ > | +t +! +( " Z " +) . to_owned ( @@ -746,8 +819,12 @@ foo " foobar " +t +! +( " " +) " bar " @@ -785,9 +862,13 @@ r " bar " +t +! +( " foo " +) " foobar " @@ -827,6 +908,9 @@ r " b " +t +! +( " { 1 @@ -834,6 +918,7 @@ b a 1a " +) " ba " @@ -857,6 +942,9 @@ age : 26 " +t +! +( " Z " @@ -864,6 +952,7 @@ Z to_string ( ) +) " age : @@ -889,6 +978,9 @@ age : 26 " +t +! +( & " Z @@ -897,6 +989,7 @@ Z to_string ( ) +) " age : @@ -922,6 +1015,9 @@ age : 26 " +t +! +( std : : @@ -944,6 +1040,7 @@ Borrowed Z " ) +) " age : @@ -969,6 +1066,9 @@ age : 26 " +t +! +( & std : @@ -992,6 +1092,7 @@ Borrowed Z " ) +) " age : @@ -1017,6 +1118,9 @@ age : 26 " +t +! +( std : : @@ -1043,6 +1147,7 @@ to_string ( ) ) +) " age : @@ -1068,6 +1173,9 @@ age : 26 " +t +! +( & std : @@ -1095,6 +1203,7 @@ to_string ( ) ) +) " age : @@ -1102,10 +1211,317 @@ Z6 " ) ; -# -[ -test -] +replace +! +( +impl_vec_u8 +replace +r +" +[ +0 +- +9 +] +" +" +age +: +26 +" +bytes +! +( +vec +! +[ +b +' +Z +' +] +) +" +age +: +Z6 +" +) +; +replace +! +( +impl_vec_u8_ref +replace +r +" +[ +0 +- +9 +] +" +" +age +: +26 +" +bytes +! +( +& +vec +! +[ +b +' +Z +' +] +) +" +age +: +Z6 +" +) +; +replace +! +( +impl_cow_slice_borrowed +replace +r +" +[ +0 +- +9 +] +" +" +age +: +26 +" +bytes +! +( +std +: +: +borrow +: +: +Cow +: +: +< +' +_ +[ +u8 +] +> +: +: +Borrowed +( +& +[ +b +' +Z +' +] +) +) +" +age +: +Z6 +" +) +; +replace +! +( +impl_cow_slice_borrowed_ref +replace +r +" +[ +0 +- +9 +] +" +" +age +: +26 +" +bytes +! +( +& +std +: +: +borrow +: +: +Cow +: +: +< +' +_ +[ +u8 +] +> +: +: +Borrowed +( +& +[ +b +' +Z +' +] +) +) +" +age +: +Z6 +" +) +; +replace +! +( +impl_cow_slice_owned +replace +r +" +[ +0 +- +9 +] +" +" +age +: +26 +" +bytes +! +( +std +: +: +borrow +: +: +Cow +: +: +< +' +_ +[ +u8 +] +> +: +: +Owned +( +vec +! +[ +b +' +Z +' +] +) +) +" +age +: +Z6 +" +) +; +replace +! +( +impl_cow_slice_owned_ref +replace +r +" +[ +0 +- +9 +] +" +" +age +: +26 +" +bytes +! +( +& +std +: +: +borrow +: +: +Cow +: +: +< +' +_ +[ +u8 +] +> +: +: +Owned +( +vec +! +[ +b +' +Z +' +] +) +) +" +age +: +Z6 +" +) +; +# +[ +test +] fn replacen_no_captures ( @@ -1115,12 +1531,7 @@ let re = regex -: -: -Regex -: -: -new +! ( r " @@ -1131,10 +1542,6 @@ r ] " ) -. -unwrap -( -) ; assert_eq ! @@ -1143,22 +1550,34 @@ re . replacen ( +text +! +( " age : 1234 " +) 2 +t +! +( " Z " ) +) +text +! +( " age : ZZ34 " ) +) ; } # @@ -1174,12 +1593,7 @@ let re = regex -: -: -Regex -: -: -new +! ( r " @@ -1192,10 +1606,6 @@ r ) " ) -. -unwrap -( -) ; assert_eq ! @@ -1204,12 +1614,19 @@ re . replacen ( +text +! +( " age : 1234 " +) 2 +t +! +( " { 1 @@ -1217,11 +1634,16 @@ age Z " ) +) +text +! +( " age : 1Z2Z34 " ) +) ; } diff --git a/third_party/rust/regex/tests/searcher.rs b/third_party/rust/regex/tests/searcher.rs index db31dc79d65bc..71badf2e01ac3 100644 --- a/third_party/rust/regex/tests/searcher.rs +++ b/third_party/rust/regex/tests/searcher.rs @@ -143,6 +143,10 @@ name ( ) { +searcher_expr +! +{ +{ use std : @@ -181,19 +185,10 @@ let re = regex -: -: -Regex -: -: -new +! ( re ) -. -unwrap -( -) ; let mut @@ -250,6 +245,8 @@ expect_steps ) ; } +} +} ) ; } diff --git a/third_party/rust/regex/tests/set.rs b/third_party/rust/regex/tests/set.rs new file mode 100644 index 0000000000000..86e68e0c0744b --- /dev/null +++ b/third_party/rust/regex/tests/set.rs @@ -0,0 +1,880 @@ +matset +! +( +set1 +& +[ +" +a +" +" +a +" +] +" +a +" +0 +1 +) +; +matset +! +( +set2 +& +[ +" +a +" +" +a +" +] +" +ba +" +0 +1 +) +; +matset +! +( +set3 +& +[ +" +a +" +" +b +" +] +" +a +" +0 +) +; +matset +! +( +set4 +& +[ +" +a +" +" +b +" +] +" +b +" +1 +) +; +matset +! +( +set5 +& +[ +" +a +| +b +" +" +b +| +a +" +] +" +b +" +0 +1 +) +; +matset +! +( +set6 +& +[ +" +foo +" +" +oo +" +] +" +foo +" +0 +1 +) +; +matset +! +( +set7 +& +[ +" +^ +foo +" +" +bar +" +] +" +foo +" +0 +) +; +matset +! +( +set8 +& +[ +" +^ +foo +" +" +bar +" +] +" +foo +bar +" +0 +1 +) +; +matset +! +( +set9 +& +[ +" +^ +foo +" +" +bar +" +] +" +bar +" +1 +) +; +matset +! +( +set10 +& +[ +r +" +[ +a +- +z +] ++ +" +" +foo +" +] +" +01234 +foo +" +0 +1 +) +; +matset +! +( +set11 +& +[ +r +" +[ +a +- +z +] ++ +" +" +foo +" +] +" +foo +01234 +" +1 +) +; +matset +! +( +set12 +& +[ +r +" +. +* +? +" +" +a +" +] +" +zzzzzza +" +0 +1 +) +; +matset +! +( +set13 +& +[ +r +" +. +* +" +" +a +" +] +" +zzzzzza +" +0 +1 +) +; +matset +! +( +set14 +& +[ +r +" +. +* +" +" +a +" +] +" +zzzzzz +" +0 +) +; +matset +! +( +set15 +& +[ +r +" +( +? +- +u +) +\ +ba +\ +b +" +] +" +hello +a +bye +" +0 +) +; +matset +! +( +set16 +& +[ +" +a +" +] +" +a +" +0 +) +; +matset +! +( +set17 +& +[ +" +. +* +a +" +] +" +a +" +0 +) +; +matset +! +( +set18 +& +[ +" +a +" +" +" +] +" +" +1 +) +; +/ +/ +regexes +that +match +the +empty +string +matset +! +( +setempty1 +& +[ +" +" +" +a +" +] +" +abc +" +0 +1 +) +; +matset +! +( +setempty2 +& +[ +" +" +" +b +" +] +" +abc +" +0 +1 +) +; +matset +! +( +setempty3 +& +[ +" +" +" +z +" +] +" +abc +" +0 +) +; +matset +! +( +setempty4 +& +[ +" +a +" +" +" +] +" +abc +" +0 +1 +) +; +matset +! +( +setempty5 +& +[ +" +b +" +" +" +] +" +abc +" +0 +1 +) +; +matset +! +( +setempty6 +& +[ +" +z +" +" +" +] +" +abc +" +1 +) +; +matset +! +( +setempty7 +& +[ +" +b +" +" +( +? +: +) +" +] +" +abc +" +0 +1 +) +; +matset +! +( +setempty8 +& +[ +" +( +? +: +) +" +" +b +" +] +" +abc +" +0 +1 +) +; +matset +! +( +setempty9 +& +[ +" +c +( +? +: +) +" +" +b +" +] +" +abc +" +0 +1 +) +; +nomatset +! +( +nset1 +& +[ +" +a +" +" +a +" +] +" +b +" +) +; +nomatset +! +( +nset2 +& +[ +" +^ +foo +" +" +bar +" +] +" +bar +foo +" +) +; +nomatset +! +( +nset3 +{ +let +xs +: +& +[ +& +str +] += +& +[ +] +; +xs +} +" +a +" +) +; +nomatset +! +( +nset4 +& +[ +r +" +^ +rooted +" +r +" +\ +. +log +" +] +" +notrooted +" +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +187 +# +[ +test +] +fn +regression_subsequent_matches +( +) +{ +let +set += +regex_set +! +( +& +[ +" +ab +" +" +b +" +] +) +; +let +text += +text +! +( +" +ba +" +) +; +assert +! +( +set +. +matches +( +text +) +. +matched +( +1 +) +) +; +assert +! +( +set +. +matches +( +text +) +. +matched +( +1 +) +) +; +} +# +[ +test +] +fn +get_set_patterns +( +) +{ +let +set += +regex_set +! +( +& +[ +" +a +" +" +b +" +] +) +; +assert_eq +! +( +vec +! +[ +" +a +" +" +b +" +] +set +. +patterns +( +) +) +; +} +# +[ +test +] +fn +len_and_empty +( +) +{ +let +empty += +regex_set +! +( +& +[ +" +" +; +0 +] +) +; +assert_eq +! +( +empty +. +len +( +) +0 +) +; +assert +! +( +empty +. +is_empty +( +) +) +; +let +not_empty += +regex_set +! +( +& +[ +" +ab +" +" +b +" +] +) +; +assert_eq +! +( +not_empty +. +len +( +) +2 +) +; +assert +! +( +! +not_empty +. +is_empty +( +) +) +; +} diff --git a/third_party/rust/regex/tests/shortest_match.rs b/third_party/rust/regex/tests/shortest_match.rs new file mode 100644 index 0000000000000..6cced66b93d2c --- /dev/null +++ b/third_party/rust/regex/tests/shortest_match.rs @@ -0,0 +1,120 @@ +macro_rules +! +shortmat +{ +( +name +: +ident +re +: +expr +text +: +expr +shortest_match +: +expr +) += +> +{ +# +[ +test +] +fn +name +( +) +{ +let +text += +text +! +( +text +) +; +let +re += +regex +! +( +re +) +; +assert_eq +! +( +shortest_match +re +. +shortest_match +( +text +) +) +; +} +} +; +} +shortmat +! +( +t01 +r +" +a ++ +" +r +" +aa +" +Some +( +1 +) +) +; +/ +/ +Test +that +the +reverse +suffix +optimization +gets +it +right +. +shortmat +! +( +t02 +r +" +. +* +( +? +: +abcd +) ++ +" +r +" +abcdabcd +" +Some +( +4 +) +) +; diff --git a/third_party/rust/regex/tests/suffix_reverse.rs b/third_party/rust/regex/tests/suffix_reverse.rs new file mode 100644 index 0000000000000..9d804a046a9ac --- /dev/null +++ b/third_party/rust/regex/tests/suffix_reverse.rs @@ -0,0 +1,168 @@ +mat +! +( +t01 +r +" +. +* +abcd +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +t02 +r +" +. +* +( +? +: +abcd +) ++ +" +r +" +abcd +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +t03 +r +" +. +* +( +? +: +abcd +) ++ +" +r +" +abcdabcd +" +Some +( +( +0 +8 +) +) +) +; +mat +! +( +t04 +r +" +. +* +( +? +: +abcd +) ++ +" +r +" +abcdxabcd +" +Some +( +( +0 +9 +) +) +) +; +mat +! +( +t05 +r +" +. +* +x +( +? +: +abcd +) ++ +" +r +" +abcdxabcd +" +Some +( +( +0 +9 +) +) +) +; +mat +! +( +t06 +r +" +[ +^ +abcd +] +* +x +( +? +: +abcd +) ++ +" +r +" +abcdxabcd +" +Some +( +( +4 +9 +) +) +) +; diff --git a/third_party/rust/regex/tests/suite_bytes.rs b/third_party/rust/regex/tests/suite_bytes.rs deleted file mode 100644 index dd535be38ce32..0000000000000 --- a/third_party/rust/regex/tests/suite_bytes.rs +++ /dev/null @@ -1,1002 +0,0 @@ -use -{ -anyhow -: -: -Result -regex -: -: -bytes -: -: -{ -Regex -RegexBuilder -} -regex_test -: -: -{ -CompiledRegex -Match -RegexTest -Span -TestResult -TestRunner -} -} -; -/ -/ -/ -Tests -the -default -configuration -of -the -hybrid -NFA -/ -DFA -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -super -: -: -BLACKLIST -) -. -test_iter -( -crate -: -: -suite -( -) -? -. -iter -( -) -compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -run_test -( -re -: -& -Regex -test -: -& -RegexTest -) -- -> -TestResult -{ -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -TestResult -: -: -matched -( -re -. -is_match -( -test -. -haystack -( -) -) -) -" -find -" -= -> -TestResult -: -: -matches -( -re -. -find_iter -( -test -. -haystack -( -) -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -0 -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -) -" -captures -" -= -> -{ -let -it -= -re -. -captures_iter -( -test -. -haystack -( -) -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -caps -| -testify_captures -( -& -caps -) -) -; -TestResult -: -: -captures -( -it -) -} -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Converts -the -given -regex -test -to -a -closure -that -searches -with -a -/ -/ -/ -bytes -: -: -Regex -. -If -the -test -configuration -is -unsupported -then -a -/ -/ -/ -CompiledRegex -that -skips -the -test -is -returned -. -fn -compiler -( -test -: -& -RegexTest -_patterns -: -& -[ -String -] -) -- -> -anyhow -: -: -Result -< -CompiledRegex -> -{ -let -skip -= -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -/ -/ -We -' -re -only -testing -bytes -: -: -Regex -here -which -supports -one -pattern -only -. -let -pattern -= -match -test -. -regexes -( -) -. -len -( -) -{ -1 -= -> -& -test -. -regexes -( -) -[ -0 -] -_ -= -> -return -skip -} -; -/ -/ -We -only -test -is_match -find_iter -and -captures_iter -. -All -of -those -are -/ -/ -leftmost -searches -. -if -! -matches -! -( -test -. -search_kind -( -) -regex_test -: -: -SearchKind -: -: -Leftmost -) -{ -return -skip -; -} -/ -/ -The -top -- -level -single -- -pattern -regex -API -always -uses -leftmost -- -first -. -if -! -matches -! -( -test -. -match_kind -( -) -regex_test -: -: -MatchKind -: -: -LeftmostFirst -) -{ -return -skip -; -} -/ -/ -The -top -- -level -regex -API -always -runs -unanchored -searches -. -. -. -. -But -we -can -/ -/ -handle -tests -that -are -anchored -but -have -only -one -match -. -if -test -. -anchored -( -) -& -& -test -. -match_limit -( -) -! -= -Some -( -1 -) -{ -return -skip -; -} -/ -/ -We -don -' -t -support -tests -with -explicit -search -bounds -. -We -could -probably -/ -/ -support -this -by -using -the -' -find_at -' -( -and -such -) -APIs -. -let -bounds -= -test -. -bounds -( -) -; -if -! -( -bounds -. -start -= -= -0 -& -& -bounds -. -end -= -= -test -. -haystack -( -) -. -len -( -) -) -{ -return -skip -; -} -/ -/ -The -bytes -: -: -Regex -API -specifically -does -not -support -enabling -UTF -- -8 -mode -. -/ -/ -It -could -I -suppose -but -currently -it -does -not -. -That -is -it -permits -/ -/ -matches -to -have -offsets -that -split -codepoints -. -if -test -. -utf8 -( -) -{ -return -skip -; -} -/ -/ -If -the -test -requires -Unicode -but -the -Unicode -feature -isn -' -t -enabled -/ -/ -skip -it -. -This -is -a -little -aggressive -but -the -test -suite -doesn -' -t -/ -/ -have -any -easy -way -of -communicating -which -Unicode -features -are -needed -. -if -test -. -unicode -( -) -& -& -! -cfg -! -( -feature -= -" -unicode -" -) -{ -return -skip -; -} -let -re -= -RegexBuilder -: -: -new -( -pattern -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -. -build -( -) -? -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -run_test -( -& -re -test -) -) -) -} -/ -/ -/ -Convert -Captures -into -the -test -suite -' -s -capture -values -. -fn -testify_captures -( -caps -: -& -regex -: -: -bytes -: -: -Captures -< -' -_ -> -) -- -> -regex_test -: -: -Captures -{ -let -spans -= -caps -. -iter -( -) -. -map -( -| -group -| -{ -group -. -map -( -| -m -| -regex_test -: -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -) -} -) -; -/ -/ -This -unwrap -is -OK -because -we -assume -our -' -caps -' -represents -a -match -and -/ -/ -a -match -always -gives -a -non -- -zero -number -of -groups -with -the -first -group -/ -/ -being -non -- -None -. -regex_test -: -: -Captures -: -: -new -( -0 -spans -) -. -unwrap -( -) -} diff --git a/third_party/rust/regex/tests/suite_bytes_set.rs b/third_party/rust/regex/tests/suite_bytes_set.rs deleted file mode 100644 index e8e5c907609e5..0000000000000 --- a/third_party/rust/regex/tests/suite_bytes_set.rs +++ /dev/null @@ -1,643 +0,0 @@ -use -{ -anyhow -: -: -Result -regex -: -: -bytes -: -: -{ -RegexSet -RegexSetBuilder -} -regex_test -: -: -{ -CompiledRegex -RegexTest -TestResult -TestRunner -} -} -; -/ -/ -/ -Tests -the -default -configuration -of -the -hybrid -NFA -/ -DFA -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -which -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -super -: -: -BLACKLIST -) -. -test_iter -( -crate -: -: -suite -( -) -? -. -iter -( -) -compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -run_test -( -re -: -& -RegexSet -test -: -& -RegexTest -) -- -> -TestResult -{ -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -TestResult -: -: -matched -( -re -. -is_match -( -test -. -haystack -( -) -) -) -" -which -" -= -> -TestResult -: -: -which -( -re -. -matches -( -test -. -haystack -( -) -) -. -iter -( -) -) -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Converts -the -given -regex -test -to -a -closure -that -searches -with -a -/ -/ -/ -bytes -: -: -Regex -. -If -the -test -configuration -is -unsupported -then -a -/ -/ -/ -CompiledRegex -that -skips -the -test -is -returned -. -fn -compiler -( -test -: -& -RegexTest -_patterns -: -& -[ -String -] -) -- -> -anyhow -: -: -Result -< -CompiledRegex -> -{ -let -skip -= -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -/ -/ -The -top -- -level -RegexSet -API -only -supports -" -overlapping -" -semantics -. -if -! -matches -! -( -test -. -search_kind -( -) -regex_test -: -: -SearchKind -: -: -Overlapping -) -{ -return -skip -; -} -/ -/ -The -top -- -level -RegexSet -API -only -supports -" -all -" -semantics -. -if -! -matches -! -( -test -. -match_kind -( -) -regex_test -: -: -MatchKind -: -: -All -) -{ -return -skip -; -} -/ -/ -The -top -- -level -RegexSet -API -always -runs -unanchored -searches -. -if -test -. -anchored -( -) -{ -return -skip -; -} -/ -/ -We -don -' -t -support -tests -with -explicit -search -bounds -. -let -bounds -= -test -. -bounds -( -) -; -if -! -( -bounds -. -start -= -= -0 -& -& -bounds -. -end -= -= -test -. -haystack -( -) -. -len -( -) -) -{ -return -skip -; -} -/ -/ -The -bytes -: -: -Regex -API -specifically -does -not -support -enabling -UTF -- -8 -mode -. -/ -/ -It -could -I -suppose -but -currently -it -does -not -. -That -is -it -permits -/ -/ -matches -to -have -offsets -that -split -codepoints -. -if -test -. -utf8 -( -) -{ -return -skip -; -} -/ -/ -If -the -test -requires -Unicode -but -the -Unicode -feature -isn -' -t -enabled -/ -/ -skip -it -. -This -is -a -little -aggressive -but -the -test -suite -doesn -' -t -/ -/ -have -any -easy -way -of -communicating -which -Unicode -features -are -needed -. -if -test -. -unicode -( -) -& -& -! -cfg -! -( -feature -= -" -unicode -" -) -{ -return -skip -; -} -let -re -= -RegexSetBuilder -: -: -new -( -test -. -regexes -( -) -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -. -build -( -) -? -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -run_test -( -& -re -test -) -) -) -} diff --git a/third_party/rust/regex/tests/suite_string.rs b/third_party/rust/regex/tests/suite_string.rs deleted file mode 100644 index 4776c0f158b25..0000000000000 --- a/third_party/rust/regex/tests/suite_string.rs +++ /dev/null @@ -1,1034 +0,0 @@ -use -{ -anyhow -: -: -Result -regex -: -: -{ -Regex -RegexBuilder -} -regex_test -: -: -{ -CompiledRegex -Match -RegexTest -Span -TestResult -TestRunner -} -} -; -/ -/ -/ -Tests -the -default -configuration -of -the -hybrid -NFA -/ -DFA -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -find -" -" -captures -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -super -: -: -BLACKLIST -) -. -test_iter -( -crate -: -: -suite -( -) -? -. -iter -( -) -compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -run_test -( -re -: -& -Regex -test -: -& -RegexTest -) -- -> -TestResult -{ -let -hay -= -match -std -: -: -str -: -: -from_utf8 -( -test -. -haystack -( -) -) -{ -Ok -( -hay -) -= -> -hay -Err -( -err -) -= -> -{ -return -TestResult -: -: -fail -( -& -format -! -( -" -haystack -is -not -valid -UTF -- -8 -: -{ -} -" -err -) -) -; -} -} -; -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -TestResult -: -: -matched -( -re -. -is_match -( -hay -) -) -" -find -" -= -> -TestResult -: -: -matches -( -re -. -find_iter -( -hay -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -m -| -Match -{ -id -: -0 -span -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -} -) -) -" -captures -" -= -> -{ -let -it -= -re -. -captures_iter -( -hay -) -. -take -( -test -. -match_limit -( -) -. -unwrap_or -( -std -: -: -usize -: -: -MAX -) -) -. -map -( -| -caps -| -testify_captures -( -& -caps -) -) -; -TestResult -: -: -captures -( -it -) -} -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Converts -the -given -regex -test -to -a -closure -that -searches -with -a -/ -/ -/ -bytes -: -: -Regex -. -If -the -test -configuration -is -unsupported -then -a -/ -/ -/ -CompiledRegex -that -skips -the -test -is -returned -. -fn -compiler -( -test -: -& -RegexTest -_patterns -: -& -[ -String -] -) -- -> -anyhow -: -: -Result -< -CompiledRegex -> -{ -let -skip -= -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -/ -/ -We -' -re -only -testing -bytes -: -: -Regex -here -which -supports -one -pattern -only -. -let -pattern -= -match -test -. -regexes -( -) -. -len -( -) -{ -1 -= -> -& -test -. -regexes -( -) -[ -0 -] -_ -= -> -return -skip -} -; -/ -/ -We -only -test -is_match -find_iter -and -captures_iter -. -All -of -those -are -/ -/ -leftmost -searches -. -if -! -matches -! -( -test -. -search_kind -( -) -regex_test -: -: -SearchKind -: -: -Leftmost -) -{ -return -skip -; -} -/ -/ -The -top -- -level -single -- -pattern -regex -API -always -uses -leftmost -- -first -. -if -! -matches -! -( -test -. -match_kind -( -) -regex_test -: -: -MatchKind -: -: -LeftmostFirst -) -{ -return -skip -; -} -/ -/ -The -top -- -level -regex -API -always -runs -unanchored -searches -. -. -. -. -But -we -can -/ -/ -handle -tests -that -are -anchored -but -have -only -one -match -. -if -test -. -anchored -( -) -& -& -test -. -match_limit -( -) -! -= -Some -( -1 -) -{ -return -skip -; -} -/ -/ -We -don -' -t -support -tests -with -explicit -search -bounds -. -We -could -probably -/ -/ -support -this -by -using -the -' -find_at -' -( -and -such -) -APIs -. -let -bounds -= -test -. -bounds -( -) -; -if -! -( -bounds -. -start -= -= -0 -& -& -bounds -. -end -= -= -test -. -haystack -( -) -. -len -( -) -) -{ -return -skip -; -} -/ -/ -The -Regex -API -specifically -does -not -support -disabling -UTF -- -8 -mode -because -/ -/ -it -can -only -search -& -str -which -is -always -valid -UTF -- -8 -. -if -! -test -. -utf8 -( -) -{ -return -skip -; -} -/ -/ -If -the -test -requires -Unicode -but -the -Unicode -feature -isn -' -t -enabled -/ -/ -skip -it -. -This -is -a -little -aggressive -but -the -test -suite -doesn -' -t -/ -/ -have -any -easy -way -of -communicating -which -Unicode -features -are -needed -. -if -test -. -unicode -( -) -& -& -! -cfg -! -( -feature -= -" -unicode -" -) -{ -return -skip -; -} -let -re -= -RegexBuilder -: -: -new -( -pattern -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -. -build -( -) -? -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -run_test -( -& -re -test -) -) -) -} -/ -/ -/ -Convert -Captures -into -the -test -suite -' -s -capture -values -. -fn -testify_captures -( -caps -: -& -regex -: -: -Captures -< -' -_ -> -) -- -> -regex_test -: -: -Captures -{ -let -spans -= -caps -. -iter -( -) -. -map -( -| -group -| -{ -group -. -map -( -| -m -| -regex_test -: -: -Span -{ -start -: -m -. -start -( -) -end -: -m -. -end -( -) -} -) -} -) -; -/ -/ -This -unwrap -is -OK -because -we -assume -our -' -caps -' -represents -a -match -and -/ -/ -a -match -always -gives -a -non -- -zero -number -of -groups -with -the -first -group -/ -/ -being -non -- -None -. -regex_test -: -: -Captures -: -: -new -( -0 -spans -) -. -unwrap -( -) -} diff --git a/third_party/rust/regex/tests/suite_string_set.rs b/third_party/rust/regex/tests/suite_string_set.rs deleted file mode 100644 index ee836fa1baafd..0000000000000 --- a/third_party/rust/regex/tests/suite_string_set.rs +++ /dev/null @@ -1,682 +0,0 @@ -use -{ -anyhow -: -: -Result -regex -: -: -{ -RegexSet -RegexSetBuilder -} -regex_test -: -: -{ -CompiledRegex -RegexTest -TestResult -TestRunner -} -} -; -/ -/ -/ -Tests -the -default -configuration -of -the -hybrid -NFA -/ -DFA -. -# -[ -test -] -fn -default -( -) -- -> -Result -< -( -) -> -{ -let -mut -runner -= -TestRunner -: -: -new -( -) -? -; -runner -. -expand -( -& -[ -" -is_match -" -" -which -" -] -| -test -| -test -. -compiles -( -) -) -. -blacklist_iter -( -super -: -: -BLACKLIST -) -. -test_iter -( -crate -: -: -suite -( -) -? -. -iter -( -) -compiler -) -. -assert -( -) -; -Ok -( -( -) -) -} -fn -run_test -( -re -: -& -RegexSet -test -: -& -RegexTest -) -- -> -TestResult -{ -let -hay -= -match -std -: -: -str -: -: -from_utf8 -( -test -. -haystack -( -) -) -{ -Ok -( -hay -) -= -> -hay -Err -( -err -) -= -> -{ -return -TestResult -: -: -fail -( -& -format -! -( -" -haystack -is -not -valid -UTF -- -8 -: -{ -} -" -err -) -) -; -} -} -; -match -test -. -additional_name -( -) -{ -" -is_match -" -= -> -TestResult -: -: -matched -( -re -. -is_match -( -hay -) -) -" -which -" -= -> -TestResult -: -: -which -( -re -. -matches -( -hay -) -. -iter -( -) -) -name -= -> -TestResult -: -: -fail -( -& -format -! -( -" -unrecognized -test -name -: -{ -} -" -name -) -) -} -} -/ -/ -/ -Converts -the -given -regex -test -to -a -closure -that -searches -with -a -/ -/ -/ -bytes -: -: -Regex -. -If -the -test -configuration -is -unsupported -then -a -/ -/ -/ -CompiledRegex -that -skips -the -test -is -returned -. -fn -compiler -( -test -: -& -RegexTest -_patterns -: -& -[ -String -] -) -- -> -anyhow -: -: -Result -< -CompiledRegex -> -{ -let -skip -= -Ok -( -CompiledRegex -: -: -skip -( -) -) -; -/ -/ -The -top -- -level -RegexSet -API -only -supports -" -overlapping -" -semantics -. -if -! -matches -! -( -test -. -search_kind -( -) -regex_test -: -: -SearchKind -: -: -Overlapping -) -{ -return -skip -; -} -/ -/ -The -top -- -level -RegexSet -API -only -supports -" -all -" -semantics -. -if -! -matches -! -( -test -. -match_kind -( -) -regex_test -: -: -MatchKind -: -: -All -) -{ -return -skip -; -} -/ -/ -The -top -- -level -RegexSet -API -always -runs -unanchored -searches -. -if -test -. -anchored -( -) -{ -return -skip -; -} -/ -/ -We -don -' -t -support -tests -with -explicit -search -bounds -. -let -bounds -= -test -. -bounds -( -) -; -if -! -( -bounds -. -start -= -= -0 -& -& -bounds -. -end -= -= -test -. -haystack -( -) -. -len -( -) -) -{ -return -skip -; -} -/ -/ -The -Regex -API -specifically -does -not -support -disabling -UTF -- -8 -mode -because -/ -/ -it -can -only -search -& -str -which -is -always -valid -UTF -- -8 -. -if -! -test -. -utf8 -( -) -{ -return -skip -; -} -/ -/ -If -the -test -requires -Unicode -but -the -Unicode -feature -isn -' -t -enabled -/ -/ -skip -it -. -This -is -a -little -aggressive -but -the -test -suite -doesn -' -t -/ -/ -have -any -easy -way -of -communicating -which -Unicode -features -are -needed -. -if -test -. -unicode -( -) -& -& -! -cfg -! -( -feature -= -" -unicode -" -) -{ -return -skip -; -} -let -re -= -RegexSetBuilder -: -: -new -( -test -. -regexes -( -) -) -. -case_insensitive -( -test -. -case_insensitive -( -) -) -. -unicode -( -test -. -unicode -( -) -) -. -line_terminator -( -test -. -line_terminator -( -) -) -. -build -( -) -? -; -Ok -( -CompiledRegex -: -: -compiled -( -move -| -test -| -run_test -( -& -re -test -) -) -) -} diff --git a/third_party/rust/regex/tests/test_backtrack.rs b/third_party/rust/regex/tests/test_backtrack.rs new file mode 100644 index 0000000000000..32acaed0bb76d --- /dev/null +++ b/third_party/rust/regex/tests/test_backtrack.rs @@ -0,0 +1,281 @@ +# +! +[ +cfg_attr +( +feature += +" +pattern +" +feature +( +pattern +) +) +] +macro_rules +! +regex_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new +( +re +) +. +bounded_backtracking +( +) +. +build +( +) +. +map +( +| +e +| +e +. +into_regex +( +) +) +} +} +; +} +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +regex_new +! +( +re +) +. +unwrap +( +) +} +; +} +macro_rules +! +regex_set_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new_many +( +re +) +. +bounded_backtracking +( +) +. +build +( +) +. +map +( +| +e +| +e +. +into_regex_set +( +) +) +} +} +; +} +macro_rules +! +regex_set +{ +( +res +: +expr +) += +> +{ +regex_set_new +! +( +res +) +. +unwrap +( +) +} +; +} +/ +/ +Must +come +before +other +module +definitions +. +include +! +( +" +macros_str +. +rs +" +) +; +include +! +( +" +macros +. +rs +" +) +; +mod +api +; +mod +api_str +; +mod +crazy +; +mod +flags +; +mod +fowler +; +mod +multiline +; +mod +noparse +; +mod +regression +; +mod +replace +; +mod +searcher +; +mod +set +; +mod +suffix_reverse +; +# +[ +cfg +( +feature += +" +unicode +" +) +] +mod +unicode +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary_unicode +; diff --git a/third_party/rust/regex/tests/test_backtrack_bytes.rs b/third_party/rust/regex/tests/test_backtrack_bytes.rs new file mode 100644 index 0000000000000..b5eff4bac321f --- /dev/null +++ b/third_party/rust/regex/tests/test_backtrack_bytes.rs @@ -0,0 +1,272 @@ +macro_rules +! +regex_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new +( +re +) +. +bounded_backtracking +( +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +e +| +e +. +into_byte_regex +( +) +) +} +} +; +} +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +regex_new +! +( +re +) +. +unwrap +( +) +} +; +} +macro_rules +! +regex_set_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new_many +( +re +) +. +bounded_backtracking +( +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +e +| +e +. +into_byte_regex_set +( +) +) +} +} +; +} +macro_rules +! +regex_set +{ +( +res +: +expr +) += +> +{ +regex_set_new +! +( +res +) +. +unwrap +( +) +} +; +} +/ +/ +Must +come +before +other +module +definitions +. +include +! +( +" +macros_bytes +. +rs +" +) +; +include +! +( +" +macros +. +rs +" +) +; +mod +api +; +mod +bytes +; +mod +crazy +; +mod +flags +; +mod +fowler +; +mod +multiline +; +mod +noparse +; +mod +regression +; +mod +replace +; +mod +set +; +mod +suffix_reverse +; +# +[ +cfg +( +feature += +" +unicode +" +) +] +mod +unicode +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary_ascii +; diff --git a/third_party/rust/regex/tests/test_backtrack_utf8bytes.rs b/third_party/rust/regex/tests/test_backtrack_utf8bytes.rs new file mode 100644 index 0000000000000..927c8ab33a163 --- /dev/null +++ b/third_party/rust/regex/tests/test_backtrack_utf8bytes.rs @@ -0,0 +1,291 @@ +# +! +[ +cfg_attr +( +feature += +" +pattern +" +feature +( +pattern +) +) +] +macro_rules +! +regex_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new +( +re +) +. +bounded_backtracking +( +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +e +| +e +. +into_regex +( +) +) +} +} +; +} +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +regex_new +! +( +re +) +. +unwrap +( +) +} +; +} +macro_rules +! +regex_set_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new_many +( +re +) +. +bounded_backtracking +( +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +e +| +e +. +into_regex_set +( +) +) +} +} +; +} +macro_rules +! +regex_set +{ +( +res +: +expr +) += +> +{ +regex_set_new +! +( +res +) +. +unwrap +( +) +} +; +} +/ +/ +Must +come +before +other +module +definitions +. +include +! +( +" +macros_str +. +rs +" +) +; +include +! +( +" +macros +. +rs +" +) +; +mod +api +; +mod +api_str +; +mod +crazy +; +mod +flags +; +mod +fowler +; +mod +multiline +; +mod +noparse +; +mod +regression +; +mod +replace +; +mod +searcher +; +mod +set +; +mod +suffix_reverse +; +# +[ +cfg +( +feature += +" +unicode +" +) +] +mod +unicode +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary_unicode +; diff --git a/third_party/rust/regex/tests/test_crates_regex.rs b/third_party/rust/regex/tests/test_crates_regex.rs new file mode 100644 index 0000000000000..825edfc9db901 --- /dev/null +++ b/third_party/rust/regex/tests/test_crates_regex.rs @@ -0,0 +1,316 @@ +/ +* +* +This +test +is +a +minimal +version +of +< +rofl_0 +> +and +< +subdiff_0 +> +* +* +Once +this +bug +gets +fixed +uncomment +rofl_0 +and +subdiff_0 +* +( +in +tests +/ +crates_regex +. +rs +) +. +# +[ +test +] +fn +word_boundary_backtracking_default_mismatch +( +) +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +let +backtrack_re += +ExecBuilder +: +: +new +( +r +" +\ +b +" +) +. +bounded_backtracking +( +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +. +unwrap +( +) +; +let +default_re += +ExecBuilder +: +: +new +( +r +" +\ +b +" +) +. +build +( +) +. +map +( +| +exec +| +exec +. +into_regex +( +) +) +. +map_err +( +| +err +| +format +! +( +" +{ +} +" +err +) +) +. +unwrap +( +) +; +let +input += +" +\ +\ +u +{ +a0 +} +" +; +let +fi1 += +backtrack_re +. +find_iter +( +input +) +; +let +fi2 += +default_re +. +find_iter +( +input +) +; +for +( +m1 +m2 +) +in +fi1 +. +zip +( +fi2 +) +{ +assert_eq +! +( +m1 +m2 +) +; +} +} +* +/ +mod +consistent +; +mod +crates_regex +{ +macro_rules +! +consistent +{ +( +test_name +: +ident +regex_src +: +expr +) += +> +{ +# +[ +test +] +fn +test_name +( +) +{ +use +super +: +: +consistent +: +: +backends_are_consistent +; +if +option_env +! +( +" +RUST_REGEX_RANDOM_TEST +" +) +. +is_some +( +) +{ +match +backends_are_consistent +( +regex_src +) +{ +Ok +( +_ +) += +> +{ +} +Err +( +err +) += +> +panic +! +( +" +{ +} +" +err +) +} +} +} +} +; +} +include +! +( +" +crates_regex +. +rs +" +) +; +} diff --git a/third_party/rust/regex/tests/test_default.rs b/third_party/rust/regex/tests/test_default.rs new file mode 100644 index 0000000000000..3bb02731fbe54 --- /dev/null +++ b/third_party/rust/regex/tests/test_default.rs @@ -0,0 +1,1838 @@ +# +! +[ +cfg_attr +( +feature += +" +pattern +" +feature +( +pattern +) +) +] +use +regex +; +/ +/ +Due +to +macro +scoping +rules +this +definition +only +applies +for +the +modules +/ +/ +defined +below +. +Effectively +it +allows +us +to +use +the +same +tests +for +both +/ +/ +native +and +dynamic +regexes +. +/ +/ +/ +/ +This +is +also +used +to +test +the +various +matching +engines +. +This +one +exercises +/ +/ +the +normal +code +path +which +automatically +chooses +the +engine +based +on +the +/ +/ +regex +and +the +input +. +Other +dynamic +tests +explicitly +set +the +engine +to +use +. +macro_rules +! +regex_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +Regex +; +Regex +: +: +new +( +re +) +} +} +; +} +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +regex_new +! +( +re +) +. +unwrap +( +) +} +; +} +macro_rules +! +regex_set_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +RegexSet +; +RegexSet +: +: +new +( +re +) +} +} +; +} +macro_rules +! +regex_set +{ +( +res +: +expr +) += +> +{ +regex_set_new +! +( +res +) +. +unwrap +( +) +} +; +} +/ +/ +Must +come +before +other +module +definitions +. +include +! +( +" +macros_str +. +rs +" +) +; +include +! +( +" +macros +. +rs +" +) +; +mod +api +; +mod +api_str +; +mod +crazy +; +mod +flags +; +mod +fowler +; +mod +misc +; +mod +multiline +; +mod +noparse +; +mod +regression +; +mod +regression_fuzz +; +mod +replace +; +mod +searcher +; +mod +set +; +mod +shortest_match +; +mod +suffix_reverse +; +# +[ +cfg +( +feature += +" +unicode +" +) +] +mod +unicode +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary_unicode +; +# +[ +test +] +fn +disallow_non_utf8 +( +) +{ +assert +! +( +regex +: +: +Regex +: +: +new +( +r +" +( +? +- +u +) +\ +xFF +" +) +. +is_err +( +) +) +; +assert +! +( +regex +: +: +Regex +: +: +new +( +r +" +( +? +- +u +) +. +" +) +. +is_err +( +) +) +; +assert +! +( +regex +: +: +Regex +: +: +new +( +r +" +( +? +- +u +) +[ +\ +xFF +] +" +) +. +is_err +( +) +) +; +assert +! +( +regex +: +: +Regex +: +: +new +( +r +" +( +? +- +u +) +" +) +. +is_err +( +) +) +; +} +# +[ +test +] +fn +disallow_octal +( +) +{ +assert +! +( +regex +: +: +Regex +: +: +new +( +r +" +\ +0 +" +) +. +is_err +( +) +) +; +} +# +[ +test +] +fn +allow_octal +( +) +{ +assert +! +( +regex +: +: +RegexBuilder +: +: +new +( +r +" +\ +0 +" +) +. +octal +( +true +) +. +build +( +) +. +is_ok +( +) +) +; +} +# +[ +test +] +fn +oibits +( +) +{ +use +regex +: +: +bytes +; +use +regex +: +: +{ +Regex +RegexBuilder +RegexSet +RegexSetBuilder +} +; +use +std +: +: +panic +: +: +{ +RefUnwindSafe +UnwindSafe +} +; +fn +assert_send +< +T +: +Send +> +( +) +{ +} +fn +assert_sync +< +T +: +Sync +> +( +) +{ +} +fn +assert_unwind_safe +< +T +: +UnwindSafe +> +( +) +{ +} +fn +assert_ref_unwind_safe +< +T +: +RefUnwindSafe +> +( +) +{ +} +assert_send +: +: +< +Regex +> +( +) +; +assert_sync +: +: +< +Regex +> +( +) +; +assert_unwind_safe +: +: +< +Regex +> +( +) +; +assert_ref_unwind_safe +: +: +< +Regex +> +( +) +; +assert_send +: +: +< +RegexBuilder +> +( +) +; +assert_sync +: +: +< +RegexBuilder +> +( +) +; +assert_unwind_safe +: +: +< +RegexBuilder +> +( +) +; +assert_ref_unwind_safe +: +: +< +RegexBuilder +> +( +) +; +assert_send +: +: +< +bytes +: +: +Regex +> +( +) +; +assert_sync +: +: +< +bytes +: +: +Regex +> +( +) +; +assert_unwind_safe +: +: +< +bytes +: +: +Regex +> +( +) +; +assert_ref_unwind_safe +: +: +< +bytes +: +: +Regex +> +( +) +; +assert_send +: +: +< +bytes +: +: +RegexBuilder +> +( +) +; +assert_sync +: +: +< +bytes +: +: +RegexBuilder +> +( +) +; +assert_unwind_safe +: +: +< +bytes +: +: +RegexBuilder +> +( +) +; +assert_ref_unwind_safe +: +: +< +bytes +: +: +RegexBuilder +> +( +) +; +assert_send +: +: +< +RegexSet +> +( +) +; +assert_sync +: +: +< +RegexSet +> +( +) +; +assert_unwind_safe +: +: +< +RegexSet +> +( +) +; +assert_ref_unwind_safe +: +: +< +RegexSet +> +( +) +; +assert_send +: +: +< +RegexSetBuilder +> +( +) +; +assert_sync +: +: +< +RegexSetBuilder +> +( +) +; +assert_unwind_safe +: +: +< +RegexSetBuilder +> +( +) +; +assert_ref_unwind_safe +: +: +< +RegexSetBuilder +> +( +) +; +assert_send +: +: +< +bytes +: +: +RegexSet +> +( +) +; +assert_sync +: +: +< +bytes +: +: +RegexSet +> +( +) +; +assert_unwind_safe +: +: +< +bytes +: +: +RegexSet +> +( +) +; +assert_ref_unwind_safe +: +: +< +bytes +: +: +RegexSet +> +( +) +; +assert_send +: +: +< +bytes +: +: +RegexSetBuilder +> +( +) +; +assert_sync +: +: +< +bytes +: +: +RegexSetBuilder +> +( +) +; +assert_unwind_safe +: +: +< +bytes +: +: +RegexSetBuilder +> +( +) +; +assert_ref_unwind_safe +: +: +< +bytes +: +: +RegexSetBuilder +> +( +) +; +} +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +568 +# +[ +test +] +fn +oibits_regression +( +) +{ +use +regex +: +: +Regex +; +use +std +: +: +panic +; +let +_ += +panic +: +: +catch_unwind +( +| +| +Regex +: +: +new +( +" +a +" +) +. +unwrap +( +) +) +; +} +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +750 +# +[ +test +] +# +[ +cfg +( +target_pointer_width += +" +64 +" +) +] +fn +regex_is_reasonably_small +( +) +{ +use +std +: +: +mem +: +: +size_of +; +use +regex +: +: +bytes +; +use +regex +: +: +{ +Regex +RegexSet +} +; +assert_eq +! +( +16 +size_of +: +: +< +Regex +> +( +) +) +; +assert_eq +! +( +16 +size_of +: +: +< +RegexSet +> +( +) +) +; +assert_eq +! +( +16 +size_of +: +: +< +bytes +: +: +Regex +> +( +) +) +; +assert_eq +! +( +16 +size_of +: +: +< +bytes +: +: +RegexSet +> +( +) +) +; +} +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +security +/ +advisories +/ +GHSA +- +m5pq +- +gvj9 +- +9vr8 +/ +/ +See +: +CVE +- +2022 +- +24713 +/ +/ +/ +/ +We +test +that +our +regex +compiler +will +correctly +return +a +" +too +big +" +error +when +/ +/ +we +try +to +use +a +very +large +repetition +on +an +* +empty +* +sub +- +expression +. +/ +/ +/ +/ +At +the +time +this +test +was +written +the +regex +compiler +does +not +represent +/ +/ +empty +sub +- +expressions +with +any +bytecode +instructions +. +In +effect +it +' +s +an +/ +/ +" +optimization +" +to +leave +them +out +since +they +would +otherwise +correspond +/ +/ +to +an +unconditional +JUMP +in +the +regex +bytecode +( +i +. +e +. +an +unconditional +/ +/ +epsilon +transition +in +the +NFA +graph +) +. +Therefore +an +empty +sub +- +expression +/ +/ +represents +an +interesting +case +for +the +compiler +' +s +size +limits +. +Since +it +/ +/ +doesn +' +t +actually +contribute +any +additional +memory +to +the +compiled +regex +/ +/ +instructions +the +size +limit +machinery +never +detects +it +. +Instead +it +just +/ +/ +dumbly +tries +to +compile +the +empty +sub +- +expression +N +times +where +N +is +the +/ +/ +repetition +size +. +/ +/ +/ +/ +When +N +is +very +large +this +will +cause +the +compiler +to +essentially +spin +and +/ +/ +do +nothing +for +a +decently +large +amount +of +time +. +It +causes +the +regex +to +take +/ +/ +quite +a +bit +of +time +to +compile +despite +the +concrete +syntax +of +the +regex +/ +/ +being +quite +small +. +/ +/ +/ +/ +The +degree +to +which +this +is +actually +a +problem +is +somewhat +of +a +judgment +/ +/ +call +. +Some +regexes +simply +take +a +long +time +to +compile +. +But +in +general +you +/ +/ +should +be +able +to +reasonably +control +this +by +setting +lower +or +higher +size +/ +/ +limits +on +the +compiled +object +size +. +But +this +mitigation +doesn +' +t +work +at +all +/ +/ +for +this +case +. +/ +/ +/ +/ +This +particular +test +is +somewhat +narrow +. +It +merely +checks +that +regex +/ +/ +compilation +will +at +some +point +return +a +" +too +big +" +error +. +Before +the +/ +/ +fix +landed +this +test +would +eventually +fail +because +the +regex +would +be +/ +/ +successfully +compiled +( +after +enough +time +elapsed +) +. +So +while +this +test +/ +/ +doesn +' +t +check +that +we +exit +in +a +reasonable +amount +of +time +it +does +at +least +/ +/ +check +that +we +are +properly +returning +an +error +at +some +point +. +# +[ +test +] +fn +big_empty_regex_fails +( +) +{ +use +regex +: +: +Regex +; +let +result += +Regex +: +: +new +( +" +( +? +: +) +{ +4294967295 +} +" +) +; +assert +! +( +result +. +is_err +( +) +) +; +} +/ +/ +Below +is +a +" +billion +laughs +" +variant +of +the +previous +test +case +. +# +[ +test +] +fn +big_empty_reps_chain_regex_fails +( +) +{ +use +regex +: +: +Regex +; +let +result += +Regex +: +: +new +( +" +( +? +: +) +{ +64 +} +{ +64 +} +{ +64 +} +{ +64 +} +{ +64 +} +{ +64 +} +" +) +; +assert +! +( +result +. +is_err +( +) +) +; +} +/ +/ +Below +is +another +situation +where +a +zero +- +length +sub +- +expression +can +be +/ +/ +introduced +. +# +[ +test +] +fn +big_zero_reps_regex_fails +( +) +{ +use +regex +: +: +Regex +; +let +result += +Regex +: +: +new +( +r +" +x +{ +0 +} +{ +4294967295 +} +" +) +; +assert +! +( +result +. +is_err +( +) +) +; +} +/ +/ +Testing +another +case +for +completeness +. +# +[ +test +] +fn +empty_alt_regex_fails +( +) +{ +use +regex +: +: +Regex +; +let +result += +Regex +: +: +new +( +r +" +( +? +: +| +) +{ +4294967295 +} +" +) +; +assert +! +( +result +. +is_err +( +) +) +; +} diff --git a/third_party/rust/regex/tests/test_default_bytes.rs b/third_party/rust/regex/tests/test_default_bytes.rs new file mode 100644 index 0000000000000..81af2b7945048 --- /dev/null +++ b/third_party/rust/regex/tests/test_default_bytes.rs @@ -0,0 +1,475 @@ +macro_rules +! +regex_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +bytes +: +: +Regex +; +Regex +: +: +new +( +re +) +} +} +; +} +macro_rules +! +regex_set_new +{ +( +res +: +expr +) += +> +{ +{ +use +regex +: +: +bytes +: +: +RegexSet +; +RegexSet +: +: +new +( +res +) +} +} +; +} +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +regex_new +! +( +re +) +. +unwrap +( +) +} +; +} +macro_rules +! +regex_set +{ +( +res +: +expr +) += +> +{ +regex_set_new +! +( +res +) +. +unwrap +( +) +} +; +} +/ +/ +Must +come +before +other +module +definitions +. +include +! +( +" +macros_bytes +. +rs +" +) +; +include +! +( +" +macros +. +rs +" +) +; +/ +/ +A +silly +wrapper +to +make +it +possible +to +write +and +match +raw +bytes +. +struct +R +< +' +a +> +( +& +' +a +[ +u8 +] +) +; +impl +< +' +a +> +R +< +' +a +> +{ +fn +as_bytes +( +& +self +) +- +> +& +' +a +[ +u8 +] +{ +self +. +0 +} +} +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +321 +/ +/ +/ +/ +These +tests +are +here +because +they +do +not +have +the +same +behavior +in +every +/ +/ +regex +engine +. +mat +! +( +invalid_utf8_nfa1 +r +" +. +" +R +( +b +" +\ +xD4 +\ +xC2 +\ +x65 +\ +x2B +\ +x0E +\ +xFE +" +) +Some +( +( +2 +3 +) +) +) +; +mat +! +( +invalid_utf8_nfa2 +r +" +{ +2 +} +" +R +( +b +" +\ +xD4 +\ +xC2 +\ +x65 +\ +x2B +\ +x0E +\ +xFE +" +) +None +) +; +mat +! +( +invalid_utf8_nfa3 +r +" +. +" +R +( +b +" +\ +x0A +\ +xDB +\ +x82 +\ +x6E +\ +x33 +\ +x01 +\ +xDD +\ +x33 +\ +xCD +" +) +Some +( +( +1 +3 +) +) +) +; +mat +! +( +invalid_utf8_nfa4 +r +" +{ +2 +} +" +R +( +b +" +\ +x0A +\ +xDB +\ +x82 +\ +x6E +\ +x33 +\ +x01 +\ +xDD +\ +x33 +\ +xCD +" +) +None +) +; +mod +api +; +mod +bytes +; +mod +crazy +; +mod +flags +; +mod +fowler +; +mod +multiline +; +mod +noparse +; +mod +regression +; +mod +replace +; +mod +set +; +mod +shortest_match +; +mod +suffix_reverse +; +# +[ +cfg +( +feature += +" +unicode +" +) +] +mod +unicode +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary_unicode +; diff --git a/third_party/rust/regex/tests/test_nfa.rs b/third_party/rust/regex/tests/test_nfa.rs new file mode 100644 index 0000000000000..66961a2e582ef --- /dev/null +++ b/third_party/rust/regex/tests/test_nfa.rs @@ -0,0 +1,281 @@ +# +! +[ +cfg_attr +( +feature += +" +pattern +" +feature +( +pattern +) +) +] +macro_rules +! +regex_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new +( +re +) +. +nfa +( +) +. +build +( +) +. +map +( +| +e +| +e +. +into_regex +( +) +) +} +} +; +} +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +regex_new +! +( +re +) +. +unwrap +( +) +} +; +} +macro_rules +! +regex_set_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new_many +( +re +) +. +nfa +( +) +. +build +( +) +. +map +( +| +e +| +e +. +into_regex_set +( +) +) +} +} +; +} +macro_rules +! +regex_set +{ +( +res +: +expr +) += +> +{ +regex_set_new +! +( +res +) +. +unwrap +( +) +} +; +} +/ +/ +Must +come +before +other +module +definitions +. +include +! +( +" +macros_str +. +rs +" +) +; +include +! +( +" +macros +. +rs +" +) +; +mod +api +; +mod +api_str +; +mod +crazy +; +mod +flags +; +mod +fowler +; +mod +multiline +; +mod +noparse +; +mod +regression +; +mod +replace +; +mod +searcher +; +mod +set +; +mod +suffix_reverse +; +# +[ +cfg +( +feature += +" +unicode +" +) +] +mod +unicode +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary_unicode +; diff --git a/third_party/rust/regex/tests/test_nfa_bytes.rs b/third_party/rust/regex/tests/test_nfa_bytes.rs new file mode 100644 index 0000000000000..aee52473c7b2d --- /dev/null +++ b/third_party/rust/regex/tests/test_nfa_bytes.rs @@ -0,0 +1,272 @@ +macro_rules +! +regex_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new +( +re +) +. +nfa +( +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +e +| +e +. +into_byte_regex +( +) +) +} +} +; +} +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +regex_new +! +( +re +) +. +unwrap +( +) +} +; +} +macro_rules +! +regex_set_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new_many +( +re +) +. +nfa +( +) +. +only_utf8 +( +false +) +. +build +( +) +. +map +( +| +e +| +e +. +into_byte_regex_set +( +) +) +} +} +; +} +macro_rules +! +regex_set +{ +( +res +: +expr +) += +> +{ +regex_set_new +! +( +res +) +. +unwrap +( +) +} +; +} +/ +/ +Must +come +before +other +module +definitions +. +include +! +( +" +macros_bytes +. +rs +" +) +; +include +! +( +" +macros +. +rs +" +) +; +mod +api +; +mod +bytes +; +mod +crazy +; +mod +flags +; +mod +fowler +; +mod +multiline +; +mod +noparse +; +mod +regression +; +mod +replace +; +mod +set +; +mod +suffix_reverse +; +# +[ +cfg +( +feature += +" +unicode +" +) +] +mod +unicode +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary_unicode +; diff --git a/third_party/rust/regex/tests/test_nfa_utf8bytes.rs b/third_party/rust/regex/tests/test_nfa_utf8bytes.rs new file mode 100644 index 0000000000000..80d2988038524 --- /dev/null +++ b/third_party/rust/regex/tests/test_nfa_utf8bytes.rs @@ -0,0 +1,291 @@ +# +! +[ +cfg_attr +( +feature += +" +pattern +" +feature +( +pattern +) +) +] +macro_rules +! +regex_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new +( +re +) +. +nfa +( +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +e +| +e +. +into_regex +( +) +) +} +} +; +} +macro_rules +! +regex +{ +( +re +: +expr +) += +> +{ +regex_new +! +( +re +) +. +unwrap +( +) +} +; +} +macro_rules +! +regex_set_new +{ +( +re +: +expr +) += +> +{ +{ +use +regex +: +: +internal +: +: +ExecBuilder +; +ExecBuilder +: +: +new_many +( +re +) +. +nfa +( +) +. +bytes +( +true +) +. +build +( +) +. +map +( +| +e +| +e +. +into_regex_set +( +) +) +} +} +; +} +macro_rules +! +regex_set +{ +( +res +: +expr +) += +> +{ +regex_set_new +! +( +res +) +. +unwrap +( +) +} +; +} +/ +/ +Must +come +before +other +module +definitions +. +include +! +( +" +macros_str +. +rs +" +) +; +include +! +( +" +macros +. +rs +" +) +; +mod +api +; +mod +api_str +; +mod +crazy +; +mod +flags +; +mod +fowler +; +mod +multiline +; +mod +noparse +; +mod +regression +; +mod +replace +; +mod +searcher +; +mod +set +; +mod +suffix_reverse +; +# +[ +cfg +( +feature += +" +unicode +" +) +] +mod +unicode +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary +; +# +[ +cfg +( +feature += +" +unicode +- +perl +" +) +] +mod +word_boundary_unicode +; diff --git a/third_party/rust/regex/tests/unicode.rs b/third_party/rust/regex/tests/unicode.rs new file mode 100644 index 0000000000000..c57cda08bca92 --- /dev/null +++ b/third_party/rust/regex/tests/unicode.rs @@ -0,0 +1,2383 @@ +mat +! +( +uni_literal +r +" +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_literal_plus +r +" ++ +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_literal_casei_plus +r +" +( +? +i +) ++ +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_plus +r +" +[ +] ++ +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_one +r +" +\ +pN +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_mixed +r +" +\ +pN ++ +" +" +1 +2 +" +Some +( +( +0 +8 +) +) +) +; +mat +! +( +uni_not +r +" +\ +PN ++ +" +" +ab +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +uni_not_class +r +" +[ +\ +PN +] ++ +" +" +ab +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +uni_not_class_neg +r +" +[ +^ +\ +PN +] ++ +" +" +ab +" +Some +( +( +2 +5 +) +) +) +; +mat +! +( +uni_case +r +" +( +? +i +) +" +" +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +uni_case_upper +r +" +\ +p +{ +Lu +} ++ +" +" +" +Some +( +( +0 +8 +) +) +) +; +mat +! +( +uni_case_upper_nocase_flag +r +" +( +? +i +) +\ +p +{ +Lu +} ++ +" +" +" +Some +( +( +0 +10 +) +) +) +; +mat +! +( +uni_case_upper_nocase +r +" +\ +p +{ +L +} ++ +" +" +" +Some +( +( +0 +10 +) +) +) +; +mat +! +( +uni_case_lower +r +" +\ +p +{ +Ll +} ++ +" +" +" +Some +( +( +8 +10 +) +) +) +; +/ +/ +Test +the +Unicode +friendliness +of +Perl +character +classes +. +mat +! +( +uni_perl_w +r +" +\ +w ++ +" +" +d +d +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_perl_w_not +r +" +\ +w ++ +" +" +" +None +) +; +mat +! +( +uni_perl_w_neg +r +" +\ +W ++ +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_perl_d +r +" +\ +d ++ +" +" +1 +9 +" +Some +( +( +0 +8 +) +) +) +; +mat +! +( +uni_perl_d_not +r +" +\ +d ++ +" +" +" +None +) +; +mat +! +( +uni_perl_d_neg +r +" +\ +D ++ +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_perl_s +r +" +\ +s ++ +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_perl_s_not +r +" +\ +s ++ +" +" +" +None +) +; +mat +! +( +uni_perl_s_neg +r +" +\ +S ++ +" +" +" +Some +( +( +0 +3 +) +) +) +; +/ +/ +And +do +the +same +for +word +boundaries +. +mat +! +( +uni_boundary_none +r +" +\ +d +\ +b +" +" +6 +" +None +) +; +mat +! +( +uni_boundary_ogham +r +" +\ +d +\ +b +" +" +6 +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +uni_not_boundary_none +r +" +\ +d +\ +B +" +" +6 +" +Some +( +( +0 +1 +) +) +) +; +mat +! +( +uni_not_boundary_ogham +r +" +\ +d +\ +B +" +" +6 +" +None +) +; +/ +/ +Test +general +categories +. +/ +/ +/ +/ +We +should +test +more +but +there +' +s +a +lot +. +Write +a +script +to +generate +more +of +/ +/ +these +tests +. +mat +! +( +uni_class_gencat_cased_letter +r +" +\ +p +{ +Cased_Letter +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_close_punctuation +r +" +\ +p +{ +Close_Punctuation +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_connector_punctuation +r +" +\ +p +{ +Connector_Punctuation +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_control +r +" +\ +p +{ +Control +} +" +" +\ +u +{ +9f +} +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +uni_class_gencat_currency_symbol +r +" +\ +p +{ +Currency_Symbol +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_dash_punctuation +r +" +\ +p +{ +Dash_Punctuation +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_decimal_numer +r +" +\ +p +{ +Decimal_Number +} +" +" +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_enclosing_mark +r +" +\ +p +{ +Enclosing_Mark +} +" +" +\ +u +{ +A672 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_final_punctuation +r +" +\ +p +{ +Final_Punctuation +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_format +r +" +\ +p +{ +Format +} +" +" +\ +u +{ +E007F +} +" +Some +( +( +0 +4 +) +) +) +; +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +719 +mat +! +( +uni_class_gencat_format_abbrev1 +r +" +\ +p +{ +cf +} +" +" +\ +u +{ +E007F +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_format_abbrev2 +r +" +\ +p +{ +gc += +cf +} +" +" +\ +u +{ +E007F +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_initial_punctuation +r +" +\ +p +{ +Initial_Punctuation +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_letter +r +" +\ +p +{ +Letter +} +" +" +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +uni_class_gencat_letter_number +r +" +\ +p +{ +Letter_Number +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_line_separator +r +" +\ +p +{ +Line_Separator +} +" +" +\ +u +{ +2028 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_lowercase_letter +r +" +\ +p +{ +Lowercase_Letter +} +" +" +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +uni_class_gencat_mark +r +" +\ +p +{ +Mark +} +" +" +\ +u +{ +E01EF +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_math +r +" +\ +p +{ +Math +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_modifier_letter +r +" +\ +p +{ +Modifier_Letter +} +" +" +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_modifier_symbol +r +" +\ +p +{ +Modifier_Symbol +} +" +" +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_nonspacing_mark +r +" +\ +p +{ +Nonspacing_Mark +} +" +" +\ +u +{ +1E94A +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_number +r +" +\ +p +{ +Number +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_open_punctuation +r +" +\ +p +{ +Open_Punctuation +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_other +r +" +\ +p +{ +Other +} +" +" +\ +u +{ +bc9 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_other_letter +r +" +\ +p +{ +Other_Letter +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_other_number +r +" +\ +p +{ +Other_Number +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_other_punctuation +r +" +\ +p +{ +Other_Punctuation +} +" +" +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_other_symbol +r +" +\ +p +{ +Other_Symbol +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_paragraph_separator +r +" +\ +p +{ +Paragraph_Separator +} +" +" +\ +u +{ +2029 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_private_use +r +" +\ +p +{ +Private_Use +} +" +" +\ +u +{ +10FFFD +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_punctuation +r +" +\ +p +{ +Punctuation +} +" +" +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_separator +r +" +\ +p +{ +Separator +} +" +" +\ +u +{ +3000 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_space_separator +r +" +\ +p +{ +Space_Separator +} +" +" +\ +u +{ +205F +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_spacing_mark +r +" +\ +p +{ +Spacing_Mark +} +" +" +\ +u +{ +16F7E +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_symbol +r +" +\ +p +{ +Symbol +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_titlecase_letter +r +" +\ +p +{ +Titlecase_Letter +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gencat_unassigned +r +" +\ +p +{ +Unassigned +} +" +" +\ +u +{ +10FFFF +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gencat_uppercase_letter +r +" +\ +p +{ +Uppercase_Letter +} +" +" +" +Some +( +( +0 +3 +) +) +) +; +/ +/ +Test +a +smattering +of +properties +. +mat +! +( +uni_class_prop_emoji1 +r +" +\ +p +{ +Emoji +} +" +" +\ +u +{ +23E9 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_prop_emoji2 +r +" +\ +p +{ +emoji +} +" +" +\ +u +{ +1F21A +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_prop_picto1 +r +" +\ +p +{ +extendedpictographic +} +" +" +\ +u +{ +1FA6E +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_prop_picto2 +r +" +\ +p +{ +extendedpictographic +} +" +" +\ +u +{ +1FFFD +} +" +Some +( +( +0 +4 +) +) +) +; +/ +/ +grapheme_cluster_break +mat +! +( +uni_class_gcb_prepend +r +" +\ +p +{ +grapheme_cluster_break += +prepend +} +" +" +\ +u +{ +11D46 +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gcb_ri1 +r +" +\ +p +{ +gcb += +regional_indicator +} +" +" +\ +u +{ +1F1E6 +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gcb_ri2 +r +" +\ +p +{ +gcb += +ri +} +" +" +\ +u +{ +1F1E7 +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gcb_ri3 +r +" +\ +p +{ +gcb += +regionalindicator +} +" +" +\ +u +{ +1F1FF +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_gcb_lvt +r +" +\ +p +{ +gcb += +lvt +} +" +" +\ +u +{ +C989 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_gcb_zwj +r +" +\ +p +{ +gcb += +zwj +} +" +" +\ +u +{ +200D +} +" +Some +( +( +0 +3 +) +) +) +; +/ +/ +word_break +mat +! +( +uni_class_wb1 +r +" +\ +p +{ +word_break += +Hebrew_Letter +} +" +" +\ +u +{ +FB46 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_wb2 +r +" +\ +p +{ +wb += +hebrewletter +} +" +" +\ +u +{ +FB46 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_wb3 +r +" +\ +p +{ +wb += +ExtendNumLet +} +" +" +\ +u +{ +FF3F +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_wb4 +r +" +\ +p +{ +wb += +WSegSpace +} +" +" +\ +u +{ +3000 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_wb5 +r +" +\ +p +{ +wb += +numeric +} +" +" +\ +u +{ +1E950 +} +" +Some +( +( +0 +4 +) +) +) +; +/ +/ +sentence_break +mat +! +( +uni_class_sb1 +r +" +\ +p +{ +sentence_break += +Lower +} +" +" +\ +u +{ +0469 +} +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +uni_class_sb2 +r +" +\ +p +{ +sb += +lower +} +" +" +\ +u +{ +0469 +} +" +Some +( +( +0 +2 +) +) +) +; +mat +! +( +uni_class_sb3 +r +" +\ +p +{ +sb += +Close +} +" +" +\ +u +{ +FF60 +} +" +Some +( +( +0 +3 +) +) +) +; +mat +! +( +uni_class_sb4 +r +" +\ +p +{ +sb += +Close +} +" +" +\ +u +{ +1F677 +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_class_sb5 +r +" +\ +p +{ +sb += +SContinue +} +" +" +\ +u +{ +FF64 +} +" +Some +( +( +0 +3 +) +) +) +; +/ +/ +Test +' +Vithkuqi +' +support +which +was +added +in +Unicode +14 +. +/ +/ +See +: +https +: +/ +/ +github +. +com +/ +rust +- +lang +/ +regex +/ +issues +/ +877 +mat +! +( +uni_vithkuqi_literal_upper +r +" +( +? +i +) +^ +\ +u +{ +10570 +} +" +" +\ +u +{ +10570 +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_vithkuqi_literal_lower +r +" +( +? +i +) +^ +\ +u +{ +10570 +} +" +" +\ +u +{ +10597 +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_vithkuqi_word_upper +r +" +^ +\ +w +" +" +\ +u +{ +10570 +} +" +Some +( +( +0 +4 +) +) +) +; +mat +! +( +uni_vithkuqi_word_lower +r +" +^ +\ +w +" +" +\ +u +{ +10597 +} +" +Some +( +( +0 +4 +) +) +) +; diff --git a/third_party/rust/regex/tests/word_boundary.rs b/third_party/rust/regex/tests/word_boundary.rs new file mode 100644 index 0000000000000..44baa0e6542e2 --- /dev/null +++ b/third_party/rust/regex/tests/word_boundary.rs @@ -0,0 +1,1861 @@ +/ +/ +Many +of +these +are +cribbed +from +RE2 +' +s +test +suite +. +matiter +! +( +wb1 +r +" +\ +b +" +" +" +) +; +matiter +! +( +wb2 +r +" +\ +b +" +" +a +" +( +0 +0 +) +( +1 +1 +) +) +; +matiter +! +( +wb3 +r +" +\ +b +" +" +ab +" +( +0 +0 +) +( +2 +2 +) +) +; +matiter +! +( +wb4 +r +" +^ +\ +b +" +" +ab +" +( +0 +0 +) +) +; +matiter +! +( +wb5 +r +" +\ +b +" +" +ab +" +( +2 +2 +) +) +; +matiter +! +( +wb6 +r +" +^ +\ +b +" +" +ab +" +) +; +matiter +! +( +wb7 +r +" +\ +bbar +\ +b +" +" +nobar +bar +foo +bar +" +( +6 +9 +) +( +14 +17 +) +) +; +matiter +! +( +wb8 +r +" +a +\ +b +" +" +faoa +x +" +( +3 +4 +) +) +; +matiter +! +( +wb9 +r +" +\ +bbar +" +" +bar +x +" +( +0 +3 +) +) +; +matiter +! +( +wb10 +r +" +\ +bbar +" +" +foo +\ +nbar +x +" +( +4 +7 +) +) +; +matiter +! +( +wb11 +r +" +bar +\ +b +" +" +foobar +" +( +3 +6 +) +) +; +matiter +! +( +wb12 +r +" +bar +\ +b +" +" +foobar +\ +nxxx +" +( +3 +6 +) +) +; +matiter +! +( +wb13 +r +" +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +b +" +" +foo +" +( +0 +3 +) +) +; +matiter +! +( +wb14 +r +" +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +b +" +" +foo +\ +n +" +( +0 +3 +) +) +; +matiter +! +( +wb15 +r +" +\ +b +( +foo +| +bar +| +[ +A +- +Z +] +) +" +" +foo +" +( +0 +3 +) +) +; +matiter +! +( +wb16 +r +" +\ +b +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +b +" +" +X +" +( +0 +1 +) +) +; +matiter +! +( +wb17 +r +" +\ +b +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +b +" +" +XY +" +) +; +matiter +! +( +wb18 +r +" +\ +b +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +b +" +" +bar +" +( +0 +3 +) +) +; +matiter +! +( +wb19 +r +" +\ +b +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +b +" +" +foo +" +( +0 +3 +) +) +; +matiter +! +( +wb20 +r +" +\ +b +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +b +" +" +foo +\ +n +" +( +0 +3 +) +) +; +matiter +! +( +wb21 +r +" +\ +b +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +b +" +" +ffoo +bbar +N +x +" +( +10 +11 +) +) +; +matiter +! +( +wb22 +r +" +\ +b +( +fo +| +foo +) +\ +b +" +" +fo +" +( +0 +2 +) +) +; +matiter +! +( +wb23 +r +" +\ +b +( +fo +| +foo +) +\ +b +" +" +foo +" +( +0 +3 +) +) +; +matiter +! +( +wb24 +r +" +\ +b +\ +b +" +" +" +) +; +matiter +! +( +wb25 +r +" +\ +b +\ +b +" +" +a +" +( +0 +0 +) +( +1 +1 +) +) +; +matiter +! +( +wb26 +r +" +\ +b +" +" +" +) +; +matiter +! +( +wb27 +r +" +\ +b +" +" +x +" +( +1 +1 +) +) +; +matiter +! +( +wb28 +r +" +\ +b +" +" +y +x +" +( +3 +3 +) +) +; +matiter +! +( +wb29 +r +" +\ +b +. +" +" +x +" +( +0 +1 +) +) +; +matiter +! +( +wb30 +r +" +^ +\ +b +( +fo +| +foo +) +\ +b +" +" +fo +" +( +0 +2 +) +) +; +matiter +! +( +wb31 +r +" +^ +\ +b +( +fo +| +foo +) +\ +b +" +" +foo +" +( +0 +3 +) +) +; +matiter +! +( +wb32 +r +" +^ +\ +b +" +" +" +) +; +matiter +! +( +wb33 +r +" +^ +\ +b +" +" +x +" +) +; +matiter +! +( +wb34 +r +" +^ +\ +b +. +" +" +x +" +( +0 +1 +) +) +; +matiter +! +( +wb35 +r +" +^ +\ +b +. +\ +b +" +" +x +" +( +0 +1 +) +) +; +matiter +! +( +wb36 +r +" +^ +^ +^ +^ +^ +\ +b +" +" +" +) +; +matiter +! +( +wb37 +r +" +^ +^ +^ +^ +^ +\ +b +. +" +" +x +" +( +0 +1 +) +) +; +matiter +! +( +wb38 +r +" +^ +^ +^ +^ +^ +\ +b +" +" +x +" +) +; +matiter +! +( +wb39 +r +" +^ +^ +^ +^ +^ +\ +b +\ +b +\ +b +. +\ +b +\ +b +\ +b +" +" +x +" +( +0 +1 +) +) +; +matiter +! +( +wb40 +r +" +\ +b +. ++ +\ +b +" +" +abc +" +( +2 +5 +) +) +; +matiter +! +( +wb41 +r +" +\ +b +" +" +a +b +c +" +( +0 +0 +) +( +1 +1 +) +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +5 +) +) +; +matiter +! +( +nb1 +r +" +\ +Bfoo +\ +B +" +" +n +foo +xfoox +that +" +( +7 +10 +) +) +; +matiter +! +( +nb2 +r +" +a +\ +B +" +" +faoa +x +" +( +1 +2 +) +) +; +matiter +! +( +nb3 +r +" +\ +Bbar +" +" +bar +x +" +) +; +matiter +! +( +nb4 +r +" +\ +Bbar +" +" +foo +\ +nbar +x +" +) +; +matiter +! +( +nb5 +r +" +bar +\ +B +" +" +foobar +" +) +; +matiter +! +( +nb6 +r +" +bar +\ +B +" +" +foobar +\ +nxxx +" +) +; +matiter +! +( +nb7 +r +" +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +foox +" +( +0 +3 +) +) +; +matiter +! +( +nb8 +r +" +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +foo +\ +n +" +) +; +matiter +! +( +nb9 +r +" +\ +B +" +" +" +( +0 +0 +) +) +; +matiter +! +( +nb10 +r +" +\ +B +" +" +x +" +) +; +matiter +! +( +nb11 +r +" +\ +B +( +foo +| +bar +| +[ +A +- +Z +] +) +" +" +foo +" +) +; +matiter +! +( +nb12 +r +" +\ +B +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +xXy +" +( +1 +2 +) +) +; +matiter +! +( +nb13 +r +" +\ +B +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +XY +" +) +; +matiter +! +( +nb14 +r +" +\ +B +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +XYZ +" +( +1 +2 +) +) +; +matiter +! +( +nb15 +r +" +\ +B +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +abara +" +( +1 +4 +) +) +; +matiter +! +( +nb16 +r +" +\ +B +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +xfoo_ +" +( +1 +4 +) +) +; +matiter +! +( +nb17 +r +" +\ +B +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +xfoo +\ +n +" +) +; +matiter +! +( +nb18 +r +" +\ +B +( +foo +| +bar +| +[ +A +- +Z +] +) +\ +B +" +" +foo +bar +vNX +" +( +9 +10 +) +) +; +matiter +! +( +nb19 +r +" +\ +B +( +fo +| +foo +) +\ +B +" +" +xfoo +" +( +1 +3 +) +) +; +matiter +! +( +nb20 +r +" +\ +B +( +foo +| +fo +) +\ +B +" +" +xfooo +" +( +1 +4 +) +) +; +matiter +! +( +nb21 +r +" +\ +B +\ +B +" +" +" +( +0 +0 +) +) +; +matiter +! +( +nb22 +r +" +\ +B +\ +B +" +" +x +" +) +; +matiter +! +( +nb23 +r +" +\ +B +" +" +" +( +0 +0 +) +) +; +matiter +! +( +nb24 +r +" +\ +B +" +" +x +" +) +; +matiter +! +( +nb25 +r +" +\ +B +" +" +y +x +" +) +; +matiter +! +( +nb26 +r +" +\ +B +. +" +" +x +" +) +; +matiter +! +( +nb27 +r +" +^ +\ +B +( +fo +| +foo +) +\ +B +" +" +fo +" +) +; +matiter +! +( +nb28 +r +" +^ +\ +B +( +fo +| +foo +) +\ +B +" +" +foo +" +) +; +matiter +! +( +nb29 +r +" +^ +\ +B +" +" +" +( +0 +0 +) +) +; +matiter +! +( +nb30 +r +" +^ +\ +B +" +" +x +" +) +; +matiter +! +( +nb31 +r +" +^ +\ +B +\ +B +" +" +" +( +0 +0 +) +) +; +matiter +! +( +nb32 +r +" +^ +\ +B +\ +B +" +" +x +" +) +; +matiter +! +( +nb33 +r +" +^ +\ +B +" +" +" +( +0 +0 +) +) +; +matiter +! +( +nb34 +r +" +^ +\ +B +" +" +x +" +) +; +matiter +! +( +nb35 +r +" +^ +\ +B +. +" +" +x +" +) +; +matiter +! +( +nb36 +r +" +^ +\ +B +. +\ +B +" +" +x +" +) +; +matiter +! +( +nb37 +r +" +^ +^ +^ +^ +^ +\ +B +" +" +" +( +0 +0 +) +) +; +matiter +! +( +nb38 +r +" +^ +^ +^ +^ +^ +\ +B +. +" +" +x +" +) +; +matiter +! +( +nb39 +r +" +^ +^ +^ +^ +^ +\ +B +" +" +x +" +) +; +/ +/ +These +work +for +both +Unicode +and +ASCII +because +all +matches +are +reported +as +/ +/ +byte +offsets +and +and +do +not +correspond +to +word +boundaries +at +either +/ +/ +the +character +or +byte +level +. +matiter +! +( +unicode1 +r +" +\ +bx +\ +b +" +" +x +" +( +2 +3 +) +) +; +matiter +! +( +unicode2 +r +" +\ +bx +\ +b +" +" +x +" +( +0 +1 +) +) +; diff --git a/third_party/rust/regex/tests/word_boundary_ascii.rs b/third_party/rust/regex/tests/word_boundary_ascii.rs new file mode 100644 index 0000000000000..5e001435dbf1e --- /dev/null +++ b/third_party/rust/regex/tests/word_boundary_ascii.rs @@ -0,0 +1,177 @@ +/ +/ +ASCII +word +boundaries +are +completely +oblivious +to +Unicode +characters +. +/ +/ +For +Unicode +word +boundaries +the +tests +are +precisely +inverted +. +matiter +! +( +ascii1 +r +" +( +? +- +u +: +\ +b +) +x +( +? +- +u +: +\ +b +) +" +" +x +" +( +2 +3 +) +) +; +matiter +! +( +ascii2 +r +" +( +? +- +u +: +\ +B +) +x +( +? +- +u +: +\ +B +) +" +" +x +" +) +; +matiter +! +( +ascii3 +r +" +( +? +- +u +: +\ +B +) +" +" +0 +\ +u +{ +7EF5E +} +" +( +2 +2 +) +( +3 +3 +) +( +4 +4 +) +( +5 +5 +) +) +; +/ +/ +We +still +get +Unicode +word +boundaries +by +default +in +byte +regexes +. +matiter +! +( +unicode1 +r +" +\ +bx +\ +b +" +" +x +" +) +; +matiter +! +( +unicode2 +r +" +\ +Bx +\ +B +" +" +x +" +( +2 +3 +) +) +; diff --git a/third_party/rust/regex/tests/word_boundary_unicode.rs b/third_party/rust/regex/tests/word_boundary_unicode.rs new file mode 100644 index 0000000000000..3de96f451f2fc --- /dev/null +++ b/third_party/rust/regex/tests/word_boundary_unicode.rs @@ -0,0 +1,91 @@ +/ +/ +Unicode +word +boundaries +know +about +Unicode +characters +. +/ +/ +For +ASCII +word +boundaries +the +tests +are +precisely +inverted +. +matiter +! +( +unicode1 +r +" +\ +bx +\ +b +" +" +x +" +) +; +matiter +! +( +unicode2 +r +" +\ +Bx +\ +B +" +" +x +" +( +2 +3 +) +) +; +matiter +! +( +ascii1 +r +" +( +? +- +u +: +\ +b +) +x +( +? +- +u +: +\ +b +) +" +" +x +" +( +2 +3 +) +) +;