Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 7.1.2 #1605

Merged
merged 3 commits into from Jan 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 59 additions & 1 deletion CHANGELOG.md
Expand Up @@ -6,6 +6,61 @@

### Changed

## 7.1.2 - 2023-01-01

### Thanks

- @joubs
- @Fyko
- @LoganDark
- @darnuria
- @jkugelman
- @barower
- @puzzlewolf
- @epage
- @cky
- @wolthom
- @w1ll-i-code

### Changed

- documentation fixes
- tests fixes
- limit the initial capacity of the result vector of `many_m_n` to 64kiB
- bits parser now accept `Parser` implementors instead of only functions

### Added

- implement `Tuple` parsing for the unit type as a special case
- implement `ErrorConvert` on the unit type to make it usable as error type for bits parsers
- bool parser for bits input

## 7.1.1 - 2022-03-14

### Thanks

- @ThomasdenH
- @@SphinxKnight
- @irevoire
- @doehyunbaek
- @pxeger
- @punkeel
- @max-sixty
- @Xiretza
- @5c077m4n
- @erihsu
- @TheNeikos
- @LoganDark
- @nickelc
- @chotchki
- @ctrlcctrlv


### Changed

- documentation fixes
- more examples

## 7.1.0 - 2021-11-04

### Thanks
Expand Down Expand Up @@ -1420,7 +1475,10 @@ Considering the number of changes since the last release, this version can conta

## Compare code

* [unreleased](https://github.com/Geal/nom/compare/7.0.0...HEAD)
* [unreleased](https://github.com/Geal/nom/compare/7.1.2...HEAD)
* [7.1.2](https://github.com/Geal/nom/compare/7.1.1...7.1.2)
* [7.1.1](https://github.com/Geal/nom/compare/7.1.0...7.1.1)
* [7.1.0](https://github.com/Geal/nom/compare/7.0.0...7.1.0)
* [7.0.0](https://github.com/Geal/nom/compare/6.2.1...7.0.0)
* [6.2.1](https://github.com/Geal/nom/compare/6.2.0...6.2.1)
* [6.2.0](https://github.com/Geal/nom/compare/6.1.2...6.2.0)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,7 +1,7 @@
[package]

name = "nom"
version = "7.1.1"
version = "7.1.2"
authors = [ "contact@geoffroycouprie.com" ]
description = "A byte-oriented, zero-copy, parser combinators library"
license = "MIT"
Expand Down
4 changes: 2 additions & 2 deletions src/bits/complete.rs
Expand Up @@ -121,8 +121,8 @@ where
/// assert_eq!(parse(([0b10000000].as_ref(), 1)), Ok((([0b10000000].as_ref(), 2), false)));
/// ```
pub fn bool<I, E: ParseError<(I, usize)>>(input: (I, usize)) -> IResult<(I, usize), bool, E>
where
I: Slice<RangeFrom<usize>> + InputIter<Item = u8> + InputLength,
where
I: Slice<RangeFrom<usize>> + InputIter<Item = u8> + InputLength,
{
let (res, bit): (_, u32) = take(1usize)(input)?;
Ok((res, bit != 0))
Expand Down
9 changes: 3 additions & 6 deletions src/bits/streaming.rs
Expand Up @@ -95,8 +95,8 @@ where
/// assert_eq!(parse(([0b10000000].as_ref(), 1)), Ok((([0b10000000].as_ref(), 2), false)));
/// ```
pub fn bool<I, E: ParseError<(I, usize)>>(input: (I, usize)) -> IResult<(I, usize), bool, E>
where
I: Slice<RangeFrom<usize>> + InputIter<Item = u8> + InputLength,
where
I: Slice<RangeFrom<usize>> + InputIter<Item = u8> + InputLength,
{
let (res, bit): (_, u32) = take(1usize)(input)?;
Ok((res, bit != 0))
Expand Down Expand Up @@ -165,9 +165,6 @@ mod test {

let result: crate::IResult<(&[u8], usize), bool> = bool((input, 8));

assert_eq!(
result,
Err(crate::Err::Incomplete(Needed::new(1)))
);
assert_eq!(result, Err(crate::Err::Incomplete(Needed::new(1))));
}
}
8 changes: 4 additions & 4 deletions src/character/complete.rs
Expand Up @@ -414,23 +414,23 @@ where
/// assert_eq!(parser("c1"), Err(Err::Error(Error::new("c1", ErrorKind::Digit))));
/// assert_eq!(parser(""), Err(Err::Error(Error::new("", ErrorKind::Digit))));
/// ```
///
///
/// ## Parsing an integer
/// You can use `digit1` in combination with [`map_res`] to parse an integer:
///
///
/// ```
/// # use nom::{Err, error::{Error, ErrorKind}, IResult, Needed};
/// # use nom::combinator::map_res;
/// # use nom::character::complete::digit1;
/// fn parser(input: &str) -> IResult<&str, u32> {
/// map_res(digit1, str::parse)(input)
/// }
///
///
/// assert_eq!(parser("416"), Ok(("", 416)));
/// assert_eq!(parser("12b"), Ok(("b", 12)));
/// assert!(parser("b").is_err());
/// ```
///
///
/// [`map_res`]: crate::combinator::map_res
pub fn digit1<T, E: ParseError<T>>(input: T) -> IResult<T, T, E>
where
Expand Down
17 changes: 13 additions & 4 deletions src/sequence/tests.rs
@@ -1,6 +1,6 @@
use super::*;
use crate::bytes::streaming::{tag, take};
use crate::error::{ErrorKind, Error};
use crate::error::{Error, ErrorKind};
use crate::internal::{Err, IResult, Needed};
use crate::number::streaming::be_u16;

Expand Down Expand Up @@ -275,7 +275,16 @@ fn tuple_test() {

#[test]
fn unit_type() {
assert_eq!(tuple::<&'static str, (), Error<&'static str>, ()>(())("abxsbsh"), Ok(("abxsbsh", ())));
assert_eq!(tuple::<&'static str, (), Error<&'static str>, ()>(())("sdfjakdsas"), Ok(("sdfjakdsas", ())));
assert_eq!(tuple::<&'static str, (), Error<&'static str>, ()>(())(""), Ok(("", ())));
assert_eq!(
tuple::<&'static str, (), Error<&'static str>, ()>(())("abxsbsh"),
Ok(("abxsbsh", ()))
);
assert_eq!(
tuple::<&'static str, (), Error<&'static str>, ()>(())("sdfjakdsas"),
Ok(("sdfjakdsas", ()))
);
assert_eq!(
tuple::<&'static str, (), Error<&'static str>, ()>(())(""),
Ok(("", ()))
);
}