Skip to content

Commit 13fbed4

Browse files
committed
core: move Pattern et al to core::pattern module (RFC 2295)
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. Issue: rust-lang#49802
1 parent 4391e6a commit 13fbed4

File tree

10 files changed

+389
-355
lines changed

10 files changed

+389
-355
lines changed

library/alloc/src/str.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use core::borrow::{Borrow, BorrowMut};
1111
use core::iter::FusedIterator;
1212
use core::mem;
1313
use core::ptr;
14-
use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
14+
use core::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
1515
use core::unicode::conversions;
1616

1717
use crate::borrow::ToOwned;
@@ -20,8 +20,6 @@ use crate::slice::{Concat, Join, SliceIndex};
2020
use crate::string::String;
2121
use crate::vec::Vec;
2222

23-
#[stable(feature = "rust1", since = "1.0.0")]
24-
pub use core::str::pattern;
2523
#[stable(feature = "encode_utf16", since = "1.8.0")]
2624
pub use core::str::EncodeUtf16;
2725
#[stable(feature = "split_ascii_whitespace", since = "1.34.0")]

library/alloc/src/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ use core::ops::Bound::{Excluded, Included, Unbounded};
5757
use core::ops::{self, Index, IndexMut, Range, RangeBounds};
5858
use core::ptr;
5959
use core::slice;
60-
use core::str::pattern::Pattern;
60+
use core::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

+4-4
Original file line numberDiff line numberDiff line change
@@ -1856,14 +1856,14 @@ fn test_repeat() {
18561856
}
18571857

18581858
mod pattern {
1859-
use std::str::pattern::SearchStep::{self, Done, Match, Reject};
1860-
use std::str::pattern::{Pattern, ReverseSearcher, Searcher};
1859+
use core::pattern::SearchStep::{self, Done, Match, Reject};
1860+
use core::pattern::{Pattern, ReverseSearcher, Searcher};
18611861

18621862
macro_rules! make_test {
18631863
($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => {
18641864
#[allow(unused_imports)]
18651865
mod $name {
1866-
use std::str::pattern::SearchStep::{Match, Reject};
1866+
use core::pattern::SearchStep::{Match, Reject};
18671867
use super::{cmp_search_to_vec};
18681868
#[test]
18691869
fn fwd() {
@@ -2139,7 +2139,7 @@ generate_iterator_test! {
21392139

21402140
#[test]
21412141
fn different_str_pattern_forwarding_lifetimes() {
2142-
use std::str::pattern::Pattern;
2142+
use core::pattern::Pattern;
21432143

21442144
fn foo<'a, P>(p: P)
21452145
where

library/core/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ pub mod sync;
357357

358358
pub mod fmt;
359359
pub mod hash;
360+
pub mod pattern;
360361
pub mod slice;
361362
pub mod str;
362363
pub mod time;

0 commit comments

Comments
 (0)