Trait core::str::pattern::Searcher [−][src]
pub unsafe trait Searcher<'a> {
fn haystack(&self) -> &'a str;
fn next(&mut self) -> SearchStep;
fn next_match(&mut self) -> Option<(usize, usize)> { ... }
fn next_reject(&mut self) -> Option<(usize, usize)> { ... }
}🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
Expand description
Required methods
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
Getter 查找要在其中搜索的基础字符串
总是返回相同的 &str。
fn next(&mut self) -> SearchStep
[src]
fn next(&mut self) -> SearchStep
[src]🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
从头开始执行下一个搜索步骤。
- 如果
haystack[a..b]与模式匹配,则返回Match(a, b)。 - 如果
haystack[a..b]甚至部分不匹配,则返回Reject(a, b)。 - 如果已访问 haystack 的每个字节,则返回
Done。
直到 Done 的 Match 和 Reject 值流将包含相邻,不重叠,覆盖整个 haystack 并位于 utf8 边界上的索引范围。
Match 结果需要包含整个匹配的模式,但是 Reject 结果可以分为任意多个相邻的片段。两个范围的长度都可以为零。
例如,模式 "aaa" 和 haystack "cbaaaaab" 可能会产生流
[Reject(0, 1), Reject(1, 2), Match(2, 5), Reject(5, 8)]
Provided methods
fn next_match(&mut self) -> Option<(usize, usize)>
[src]
fn next_match(&mut self) -> Option<(usize, usize)>
[src]🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
与 next() 不同,不能保证此和 next_reject 的返回范围会重叠。
这将返回 (start_match, end_match),其中 start_match 是匹配开始的索引,end_match 是匹配结束后的索引。
fn next_reject(&mut self) -> Option<(usize, usize)>
[src]
fn next_reject(&mut self) -> Option<(usize, usize)>
[src]🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
查找下一个 Reject 结果。请参见 next() 和 next_match()。
与 next() 不同,不能保证此和 next_match 的返回范围会重叠。
Implementors
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized
🔬 This is a nightly-only experimental API. (pattern #27721)
API not fully fleshed out and ready to be stabilized