Skip to content

Commit

Permalink
remove whitespace::sp
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Apr 27, 2019
1 parent 13cf30c commit f6487c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

- character parsers that were aliases to their `*1` version: eol, alpha, digit, hex_digit, oct_digit, alphanumeric, space, multispace
- `count_fixed` macro
- `whitespace::sp` can be replaced by `character::complete::multispace0`

## 4.2.3 - 2019-03-23

Expand Down
27 changes: 5 additions & 22 deletions src/whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -829,23 +829,6 @@ macro_rules! sep (
};
);

use internal::IResult;
use traits::{AsChar, FindToken, InputTakeAtPosition};
#[allow(unused_imports)]
pub fn sp<'a, T>(input: T) -> IResult<T, T>
where
T: InputTakeAtPosition,
<T as InputTakeAtPosition>::Item: AsChar + Clone,
&'a str: FindToken<<T as InputTakeAtPosition>::Item>,
{
input.split_at_position(|item| {
let c = item.clone().as_char();
!(c == ' ' || c == '\t' || c == '\r' || c == '\n')
})
//this could be written as followed, but not using FindToken is faster
//eat_separator!(input, " \t\r\n")
}

/// `ws!(I -> IResult<I,O>) => I -> IResult<I, O>`
///
/// transforms a parser to automatically consume
Expand Down Expand Up @@ -876,15 +859,15 @@ where
macro_rules! ws (
($i:expr, $($args:tt)*) => (
{
use $crate::sp;
use $crate::Convert;
use $crate::Err;
use $crate::lib::std::result::Result::*;
use $crate::character::complete::multispace0;

match sep!($i, sp, $($args)*) {
match sep!($i, multispace0, $($args)*) {
Err(e) => Err(e),
Ok((i1,o)) => {
match (sp)(i1) {
match (multispace0)(i1) {
Err(e) => Err(Err::convert(e)),
Ok((i2,_)) => Ok((i2, o))
}
Expand All @@ -902,12 +885,12 @@ mod tests {
use lib::std::fmt::Debug;
use internal::{Err, IResult, Needed};
use error::ParseError;
use super::sp;
use character::complete::multispace0 as sp;
use error::ErrorKind;

#[test]
fn spaaaaace() {
assert_eq!(sp(&b" \t abc "[..]), Ok((&b"abc "[..], &b" \t "[..])));
assert_eq!(sp::<_,(_,ErrorKind)>(&b" \t abc "[..]), Ok((&b"abc "[..], &b" \t "[..])));
}

#[test]
Expand Down

0 comments on commit f6487c5

Please sign in to comment.