File tree 6 files changed +2311
-0
lines changed
6 files changed +2311
-0
lines changed Original file line number Diff line number Diff line change @@ -211,6 +211,7 @@ pub mod fmt;
211
211
pub mod time;
212
212
213
213
pub mod unicode;
214
+ pub mod needle;
214
215
215
216
/* Async */
216
217
pub mod future;
Load Diff Large diffs are not rendered by default.
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ #![ unstable( feature = "needle" , issue = "56345" ) ]
2
+
3
+ //! The Needle API, support generalized searching on strings, arrays and more.
4
+ //!
5
+ //! This module provides traits to facilitate searching [`Needle`] in a [`Haystack`].
6
+ //!
7
+ //! Haystacks
8
+ //! =========
9
+ //!
10
+ //! A *haystack* refers to any linear structure which can be split or sliced
11
+ //! into smaller, non-overlapping parts. Examples are strings and vectors.
12
+ //!
13
+ //! ```rust
14
+ //! let haystack: &str = "hello"; // a string slice (`&str`) is a haystack.
15
+ //! let (a, b) = haystack.split_at(4); // it can be split into two strings.
16
+ //! let c = &a[1..3]; // it can be sliced.
17
+ //! ```
18
+ //!
19
+ //! The minimal haystack which cannot be further sliced is called a *codeword*.
20
+ //! For instance, the codeword of a string would be a UTF-8 sequence. A haystack
21
+ //! can therefore be viewed as a consecutive list of codewords.
22
+ //!
23
+ //! The boundary between codewords can be addressed using an *index*. The
24
+ //! numbers 1, 3 and 4 in the snippet above are sample indices of a string. An
25
+ //! index is usually a `usize`.
26
+ //!
27
+ //! An arbitrary number may point outside of a haystack, or in the interior of a
28
+ //! codeword. These indices are invalid. A *valid index* of a certain haystack
29
+ //! would only point to the boundaries.
30
+
31
+ mod haystack;
32
+ mod needle;
33
+ pub mod ext;
34
+
35
+ pub use self :: haystack:: * ;
36
+ pub use self :: needle:: * ;
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change 274
274
#![ feature( link_args) ]
275
275
#![ feature( linkage) ]
276
276
#![ feature( maybe_uninit) ]
277
+ #![ feature( needle) ]
277
278
#![ feature( needs_panic_runtime) ]
278
279
#![ feature( never_type) ]
279
280
#![ feature( nll) ]
@@ -437,6 +438,8 @@ pub use core::char;
437
438
pub use core:: u128;
438
439
#[ stable( feature = "core_hint" , since = "1.27.0" ) ]
439
440
pub use core:: hint;
441
+ #[ unstable( feature = "needle" , issue = "56345" ) ]
442
+ pub use core:: needle;
440
443
441
444
pub mod f32;
442
445
pub mod f64;
You can’t perform that action at this time.
0 commit comments