Skip to content

Commit 9ba42ae

Browse files
committed
core: move Pattern et al to core::pattern module
Pattern is no longer str-specific, so move it from core::str::pattern module to a new core::pattern module. This introduces no changes in behaviour or implementation. Just moves stuff around and adjusts documentation.
1 parent a367365 commit 9ba42ae

File tree

10 files changed

+404
-369
lines changed

10 files changed

+404
-369
lines changed

library/alloc/src/str.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use core::borrow::{Borrow, BorrowMut};
1111
use core::iter::FusedIterator;
1212
use core::mem;
13+
use core::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
1314
use core::ptr;
14-
use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
1515
use core::unicode::conversions;
1616

1717
use crate::borrow::ToOwned;

library/alloc/src/string.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ use core::ops::AddAssign;
5555
#[cfg(not(no_global_oom_handling))]
5656
use core::ops::Bound::{Excluded, Included, Unbounded};
5757
use core::ops::{self, Index, IndexMut, Range, RangeBounds};
58+
use core::pattern::Pattern;
5859
use core::ptr;
5960
use core::slice;
60-
use core::str::pattern::Pattern;
6161
#[cfg(not(no_global_oom_handling))]
6262
use core::str::Utf8Chunks;
6363

@@ -1373,7 +1373,7 @@ impl String {
13731373
where
13741374
P: for<'x> Pattern<&'x str>,
13751375
{
1376-
use core::str::pattern::Searcher;
1376+
use core::pattern::Searcher;
13771377

13781378
let rejections = {
13791379
let mut searcher = pat.into_searcher(self);

library/alloc/tests/str.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1868,14 +1868,14 @@ fn test_repeat() {
18681868
}
18691869

18701870
mod pattern {
1871-
use std::str::pattern::SearchStep::{self, Done, Match, Reject};
1872-
use std::str::pattern::{Pattern, ReverseSearcher, Searcher};
1871+
use core::pattern::SearchStep::{self, Done, Match, Reject};
1872+
use core::pattern::{Pattern, ReverseSearcher, Searcher};
18731873

18741874
macro_rules! make_test {
18751875
($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => {
18761876
#[allow(unused_imports)]
18771877
mod $name {
1878-
use std::str::pattern::SearchStep::{Match, Reject};
1878+
use core::pattern::SearchStep::{Match, Reject};
18791879
use super::{cmp_search_to_vec};
18801880
#[test]
18811881
fn fwd() {
@@ -2151,7 +2151,7 @@ generate_iterator_test! {
21512151

21522152
#[test]
21532153
fn different_str_pattern_forwarding_lifetimes() {
2154-
use std::str::pattern::Pattern;
2154+
use core::pattern::Pattern;
21552155

21562156
fn foo<'a, P>(p: P)
21572157
where

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ pub mod sync;
362362

363363
pub mod fmt;
364364
pub mod hash;
365+
pub mod pattern;
365366
pub mod slice;
366367
pub mod str;
367368
pub mod time;

0 commit comments

Comments
 (0)