Skip to content

Commit

Permalink
core: move Pattern et al to core::pattern module (RFC 2295)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mina86 committed Feb 16, 2023
1 parent 4391e6a commit 13fbed4
Show file tree
Hide file tree
Showing 10 changed files with 389 additions and 355 deletions.
4 changes: 1 addition & 3 deletions library/alloc/src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use core::borrow::{Borrow, BorrowMut};
use core::iter::FusedIterator;
use core::mem;
use core::ptr;
use core::str::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
use core::pattern::{DoubleEndedSearcher, Pattern, ReverseSearcher, Searcher};
use core::unicode::conversions;

use crate::borrow::ToOwned;
Expand All @@ -20,8 +20,6 @@ use crate::slice::{Concat, Join, SliceIndex};
use crate::string::String;
use crate::vec::Vec;

#[stable(feature = "rust1", since = "1.0.0")]
pub use core::str::pattern;
#[stable(feature = "encode_utf16", since = "1.8.0")]
pub use core::str::EncodeUtf16;
#[stable(feature = "split_ascii_whitespace", since = "1.34.0")]
Expand Down
4 changes: 2 additions & 2 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ use core::ops::Bound::{Excluded, Included, Unbounded};
use core::ops::{self, Index, IndexMut, Range, RangeBounds};
use core::ptr;
use core::slice;
use core::str::pattern::Pattern;
use core::pattern::Pattern;
#[cfg(not(no_global_oom_handling))]
use core::str::Utf8Chunks;

Expand Down Expand Up @@ -1373,7 +1373,7 @@ impl String {
where
P: for<'x> Pattern<&'x str>,
{
use core::str::pattern::Searcher;
use core::pattern::Searcher;

let rejections = {
let mut searcher = pat.into_searcher(self);
Expand Down
8 changes: 4 additions & 4 deletions library/alloc/tests/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,14 +1856,14 @@ fn test_repeat() {
}

mod pattern {
use std::str::pattern::SearchStep::{self, Done, Match, Reject};
use std::str::pattern::{Pattern, ReverseSearcher, Searcher};
use core::pattern::SearchStep::{self, Done, Match, Reject};
use core::pattern::{Pattern, ReverseSearcher, Searcher};

macro_rules! make_test {
($name:ident, $p:expr, $h:expr, [$($e:expr,)*]) => {
#[allow(unused_imports)]
mod $name {
use std::str::pattern::SearchStep::{Match, Reject};
use core::pattern::SearchStep::{Match, Reject};
use super::{cmp_search_to_vec};
#[test]
fn fwd() {
Expand Down Expand Up @@ -2139,7 +2139,7 @@ generate_iterator_test! {

#[test]
fn different_str_pattern_forwarding_lifetimes() {
use std::str::pattern::Pattern;
use core::pattern::Pattern;

fn foo<'a, P>(p: P)
where
Expand Down
1 change: 1 addition & 0 deletions library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ pub mod sync;

pub mod fmt;
pub mod hash;
pub mod pattern;
pub mod slice;
pub mod str;
pub mod time;
Expand Down
Loading

0 comments on commit 13fbed4

Please sign in to comment.