Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 // We want to make sure we are getting the shortest match possible
2 // without getting tripped up by pathological cases.
3 pub mod minspanrust-analyzer cargo minspan 0.1.5 minspan/ {
4
5 pub fn spanrust-analyzer cargo minspan 0.1.5 minspan/span().<A>(query: &Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<A>, history: &Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<A>) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, usize)>
6 where
7 A: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#,
8 {
9 // If history is empty, we cannot find any span with valid indices.
10 if history.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
11 return Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
12 }
13 // If query is empty, it's a subsequence starting at index 0.
14 // The current implementation returns (0, 0), representing history[0..=0].
15 // This is valid since history is non-empty here.
16 if query.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
17 return Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((0, 0));
18 }
19
20 // Initialize state for the main algorithm
21 let mut starting_at: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, usize)>> = query.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|_| Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#).collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
22 let mut best_complete_solution: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(usize, usize)> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
23
24 // Main loop: requires non-empty query and history
25 for (bodyindex, bodychr) in history.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().() {
26 for (keyindex, keychr) in query.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().enumeraterust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#enumerate().().revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() {
27 if keychr rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().bodychr {
28 // we have a match, therefore record it: it ends at bodyindex,
29 // and by construction, starts at starting_at[0]
30 starting_at[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().keyindex]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). = if keyindex rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 {
31 // we got nothing yet! set to beginning
32 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((bodyindex, bodyindex))
33 } else {
34 starting_at[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().keyindex rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index()..maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(start, _end)| (start, bodyindex))
35 };
36 // are we finished?
37 if (keyindex rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().query.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
38 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((from, to)) = starting_at[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().keyindex]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index(). {
39 best_complete_solution = match best_complete_solution {
40 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((from, to)), // 1+to - from),
41 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((currfrom, currto)) => {
42 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(if to rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().from rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().currto rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().currfrom {
43 (from, to)
44 } else {
45 (currfrom, currto)
46 })
47 }
48 }
49 }
50 }
51 }
52 }
53 }
54 best_complete_solution
55 }
56 }
57
58 // Add proptest imports for property-based testing
59 #[cfg(test)]
60 extern crate proptestrust-analyzer cargo minspan 0.1.5 proptest/;
61 #[cfg(test)]
62 use proptestrust-analyzer cargo proptest 1.11.0 crate/::preluderust-analyzer cargo proptest 1.11.0 prelude/::*;
63
64 #[cfg(test)]
65 mod testsrust-analyzer cargo minspan 0.1.5 tests/ {
66 use superrust-analyzer cargo minspan 0.1.5 crate/::*;
67 // Keep existing tests
68 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
69 fn test_minimal_matchrust-analyzer cargo minspan 0.1.5 tests/test_minimal_match().() {
70 // Helper to convert string slices to Vec<char> and call span
71 let run_span = |needle: &str, haystack: &str| {
72 let query: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = needle.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
73 let history: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = haystack.charsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]chars().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
74 minspanrust-analyzer cargo minspan 0.1.5 minspan/::spanrust-analyzer cargo minspan 0.1.5 minspan/span().(&query, &history)
75 };
76
77 // Helper to get span length or None
78 let get_span_len = |needle: &str, haystack: &str| {
79 run_span(needle, haystack).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(from, to)| 1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().to rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().from)
80 };
81
82 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("ab", "ab"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2));
83 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("a", "ab"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(1));
84 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("ab", "abc"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(2));
85 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("abc", "abcd"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3));
86 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("curl", "curly"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4));
87 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("curl", "acccccurlycurrelly"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(4));
88 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("z", "acccccurlycurrelly"), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
89 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("ssh", "testssh"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3));
90 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(get_span_len("aba", "abababa"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(3));
91 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(run_span("", "abc"), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((0, 0))); // Empty query
92 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(run_span("a", ""), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); // Empty history
93 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(run_span("", ""), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#); // Both empty
94 }
95
96 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
97 fn test_is_subsequence_consumes_main_seqrust-analyzer cargo minspan 0.1.5 tests/test_is_subsequence_consumes_main_seq().() {
98 let sub: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!['a', 'a', 'a'];
99 let main_seq: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!['a', 'a'];
100 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(!rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_subsequencerust-analyzer cargo minspan 0.1.5 tests/is_subsequence().(&sub, &main_seq), "is_subsequence should return false when main_seq is consumed before sub is fully matched");
101
102 let sub_ok: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!['a', 'a'];
103 let main_seq_ok: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!['a', 'a', 'a'];
104 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
105 is_subsequencerust-analyzer cargo minspan 0.1.5 tests/is_subsequence().(&sub_ok, &main_seq_ok),
106 "is_subsequence should return true when sub is shorter or equal and matches"
107 );
108
109 let sub_diff: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!['a', 'b'];
110 let main_seq_diff: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<char> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!!['a', 'a'];
111 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(
112 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_subsequencerust-analyzer cargo minspan 0.1.5 tests/is_subsequence().(&sub_diff, &main_seq_diff),
113 "is_subsequence should return false for non-matching elements"
114 );
115 }
116
117 // Helper function to check if `sub` is a subsequence of `main_seq`
118 fn is_subsequencerust-analyzer cargo minspan 0.1.5 tests/is_subsequence().<A: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#>(sub: &[A], main_seq: &[A]) -> bool {
119 let mut main_iter = main_seq.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().();
120 sub.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
121 .allrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]all().(|sub_item| main_iter.anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]any().(|main_item| main_item rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().sub_item))
122 }
123
124 // Use proptest! with a custom config and closure syntax
125 proptestrust-analyzer cargo proptest 1.11.0 sugar/proptest!! {
126 #![proptest_config(ProptestConfigrust-analyzer cargo proptest 1.11.0 test_runner/config/Config#::with_casesrust-analyzer cargo proptest 1.11.0 test_runner/config/impl#[Config]with_cases().(10000))]
127 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
128 fn prop_span_finds_valid_subsequencerust-analyzer cargo minspan 0.1.5 tests/prop_span_finds_valid_subsequence().(
129 // Query uses chars 'a'..'c' via regex strategy, length 0..10
130 query in proptestrust-analyzer cargo proptest 1.11.0 crate/::collectionrust-analyzer cargo proptest 1.11.0 collection/::vecrust-analyzer cargo proptest 1.11.0 collection/vec().("[a-c]", 0..10),
131 // History uses chars 'a'..'d' via regex strategy, length 0..50
132 history in proptestrust-analyzer cargo proptest 1.11.0 crate/::collectionrust-analyzer cargo proptest 1.11.0 collection/::vecrust-analyzer cargo proptest 1.11.0 collection/vec().("[a-d]", 0..50)
133 ) {
134 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((from, to)) = minspanrust-analyzer cargo minspan 0.1.5 minspan/::spanrust-analyzer cargo minspan 0.1.5 minspan/span().(&query, &history) {
135 // 1. Indices must be valid
136 prop_assertrust-analyzer cargo proptest 1.11.0 sugar/prop_assert!!(from <= to, "from index {} > to index {}", from, to);
137 prop_assertrust-analyzer cargo proptest 1.11.0 sugar/prop_assert!!(to <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). history.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().(), "to index {} is out of bounds for history len {}", to, history.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().());
138
139 // 2. The slice history[from..=to] must contain query as a subsequence
140 let history_slice = &history[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().from..=to]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
141 prop_assertrust-analyzer cargo proptest 1.11.0 sugar/prop_assert!!(
142 is_subsequencerust-analyzer cargo minspan 0.1.5 tests/is_subsequence().(&query, history_slice),
143 "query {:?} is not a subsequence of history slice {:?} (from={}, to={})",
144 query, history_slice, from, to
145 );
146
147 // 3. Check if a shorter span exists *before* the found one (minimality check part 1)
148 // This is tricky to fully verify without re-implementing the logic.
149 // We can check that no shorter valid subsequence exists ending at or before `to`.
150 // A simpler check: ensure the first element of query matches history[from]
151 // if query is not empty. This isn't always true for the *minimal* span,
152 // e.g., query="ab", history="axb", span=(1,2) 'xb', not (0,2) 'axb'.
153
154 // 3. Minimality Check: Ensure no shorter span contains the query.
155 // Iterate through all possible start (f) and end (t) indices.
156 for f in 0..history.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
157 for t in f..history.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() {
158 // Check only spans that are strictly shorter than the found span (to - from).
159 if t -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). f <rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). to -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). from {
160 let shorter_slice = &history[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().f..=t]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`Index<I>`]index().;
161 prop_assertrust-analyzer cargo proptest 1.11.0 sugar/prop_assert!!(
162 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_subsequencerust-analyzer cargo minspan 0.1.5 tests/is_subsequence().(&query, shorter_slice),
163 "Found shorter span history[{}:{}] ({:?}) that contains query {:?}, but span returned ({}, {}) len {}",
164 f, t, shorter_slice, query, from, to, to -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). from +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). 1
165 );
166 }
167 }
168 }
169
170 } else {
171 // If span returns None, then query should not be a subsequence of history,
172 // unless the query itself is empty (as empty query is always a subsequence).
173 prop_assertrust-analyzer cargo proptest 1.11.0 sugar/prop_assert!!(
174 !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().is_subsequencerust-analyzer cargo minspan 0.1.5 tests/is_subsequence().(&query, &history) || query.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().(),
175 "span returned None, but query {:?} IS a subsequence of history {:?}",
176 query, history
177 );
178 }
179 }
180 }
181 }