Skip to content

Commit d511655

Browse files
authored
Merge pull request #96 from shepmaster/pattern
Remove usage of unstable pattern feature
2 parents a8e9ca5 + 8ce8e7d commit d511655

File tree

3 files changed

+0
-92
lines changed

3 files changed

+0
-92
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,27 +46,6 @@ jobs:
4646

4747
- run: cargo test
4848

49-
features:
50-
runs-on: ubuntu-latest
51-
strategy:
52-
matrix:
53-
rust:
54-
- nightly
55-
features:
56-
- unstable
57-
# - compile_failure # Currently not clean
58-
59-
steps:
60-
- uses: actions/checkout@v4
61-
62-
- uses: dtolnay/rust-toolchain@master
63-
with:
64-
toolchain: ${{ matrix.rust }}
65-
66-
- run: cargo build --features ${{ matrix.features }}
67-
68-
- run: cargo test--features ${{ matrix.features }}
69-
7049
windows:
7150
runs-on: windows-latest
7251
strategy:

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@
4949
//! Try to leverage the type system as much as possible.
5050
5151
#![deny(rust_2018_idioms)]
52-
#![cfg_attr(feature = "unstable", feature(pattern))]
5352
#![cfg_attr(feature = "unstable", feature(test))]
5453

5554
#[macro_use]

src/str_ext.rs

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,16 @@
1-
#[cfg(feature = "unstable")]
2-
use std::str::pattern::{Pattern, Searcher};
3-
41
#[derive(Copy, Clone, Debug, PartialEq)]
52
pub enum SplitType<'a> {
63
Match(&'a str),
74
Delimiter(&'a str),
85
}
96

10-
#[cfg(feature = "unstable")]
11-
pub struct SplitKeepingDelimiter<'p, P>
12-
where
13-
P: Pattern<'p>,
14-
{
15-
searcher: P::Searcher,
16-
start: usize,
17-
saved: Option<usize>,
18-
}
19-
20-
#[cfg(feature = "unstable")]
21-
impl<'p, P> Iterator for SplitKeepingDelimiter<'p, P>
22-
where
23-
P: Pattern<'p>,
24-
{
25-
type Item = SplitType<'p>;
26-
27-
fn next(&mut self) -> Option<SplitType<'p>> {
28-
if self.start == self.searcher.haystack().len() {
29-
return None;
30-
}
31-
32-
if let Some(end_of_match) = self.saved.take() {
33-
let s = &self.searcher.haystack()[self.start..end_of_match];
34-
self.start = end_of_match;
35-
return Some(SplitType::Delimiter(s));
36-
}
37-
38-
match self.searcher.next_match() {
39-
Some((start, end)) => {
40-
if self.start == start {
41-
let s = &self.searcher.haystack()[start..end];
42-
self.start = end;
43-
Some(SplitType::Delimiter(s))
44-
} else {
45-
let s = &self.searcher.haystack()[self.start..start];
46-
self.start = start;
47-
self.saved = Some(end);
48-
Some(SplitType::Match(s))
49-
}
50-
}
51-
None => {
52-
let s = &self.searcher.haystack()[self.start..];
53-
self.start = self.searcher.haystack().len();
54-
Some(SplitType::Match(s))
55-
}
56-
}
57-
}
58-
}
59-
60-
#[cfg(feature = "unstable")]
61-
pub trait SplitKeepingDelimiterExt: ::std::ops::Index<::std::ops::RangeFull, Output = str> {
62-
fn split_keeping_delimiter<P>(&self, pattern: P) -> SplitKeepingDelimiter<'_, P>
63-
where
64-
P: for<'a> Pattern<'a>,
65-
{
66-
SplitKeepingDelimiter {
67-
searcher: pattern.into_searcher(&self[..]),
68-
start: 0,
69-
saved: None,
70-
}
71-
}
72-
}
73-
74-
#[cfg(not(feature = "unstable"))]
757
pub struct SplitKeepingDelimiter<'a, F> {
768
haystack: &'a str,
779
chars: F,
7810
start: usize,
7911
saved: Option<usize>,
8012
}
8113

82-
#[cfg(not(feature = "unstable"))]
8314
impl<'a, F> Iterator for SplitKeepingDelimiter<'a, F>
8415
where
8516
F: Fn(char) -> bool,
@@ -123,7 +54,6 @@ where
12354
}
12455
}
12556

126-
#[cfg(not(feature = "unstable"))]
12757
pub trait SplitKeepingDelimiterExt: ::std::ops::Index<::std::ops::RangeFull, Output = str> {
12858
fn split_keeping_delimiter<F>(&self, chars: F) -> SplitKeepingDelimiter<'_, F>
12959
where

0 commit comments

Comments
 (0)