Skip to content

Commit

Permalink
Merge pull request #676 from epage/legacy
Browse files Browse the repository at this point in the history
fix: De-emphasize `parse_peek`-related functionality
  • Loading branch information
epage authored Jan 7, 2025
2 parents d5a184f + e15ab93 commit 7e32086
Show file tree
Hide file tree
Showing 21 changed files with 305 additions and 165 deletions.
4 changes: 2 additions & 2 deletions src/ascii/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ where
///
/// ```rust
/// # use winnow::prelude::*;
/// # use winnow::{error::ErrMode, error::ErrorKind, error::InputError, error::Needed, IResult};
/// # use winnow::{error::ErrMode, error::ErrorKind, error::InputError, error::Needed, error::IResult};
/// # use winnow::ascii::digit1;
/// # use winnow::prelude::*;
/// use winnow::ascii::take_escaped;
Expand All @@ -1592,7 +1592,7 @@ where
///
/// ```rust
/// # use winnow::prelude::*;
/// # use winnow::{error::ErrMode, error::ErrorKind, error::InputError, error::Needed, IResult};
/// # use winnow::{error::ErrMode, error::ErrorKind, error::InputError, error::Needed, error::IResult};
/// # use winnow::ascii::digit1;
/// # use winnow::prelude::*;
/// # use winnow::Partial;
Expand Down
8 changes: 4 additions & 4 deletions src/ascii/tests.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::*;
use crate::prelude::*;

mod complete {
use super::*;
use crate::combinator::alt;
use crate::error::ErrMode;
use crate::error::ErrorKind;
use crate::error::IResult;
use crate::error::InputError;
use crate::stream::ParseSlice;
use crate::token::none_of;
Expand All @@ -16,7 +16,7 @@ mod complete {

macro_rules! assert_parse(
($left: expr, $right: expr) => {
let res: $crate::IResult<_, _, InputError<_>> = $left;
let res: $crate::error::IResult<_, _, InputError<_>> = $left;
assert_eq!(res, $right);
};
);
Expand Down Expand Up @@ -956,14 +956,14 @@ mod complete {
mod partial {
use super::*;
use crate::error::ErrorKind;
use crate::error::IResult;
use crate::error::InputError;
use crate::error::{ErrMode, Needed};
use crate::IResult;
use crate::Partial;

macro_rules! assert_parse(
($left: expr, $right: expr) => {
let res: $crate::IResult<_, _, InputError<_>> = $left;
let res: $crate::error::IResult<_, _, InputError<_>> = $left;
assert_eq!(res, $right);
};
);
Expand Down
22 changes: 16 additions & 6 deletions src/binary/bits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::combinator::trace;
use crate::error::{ErrMode, ErrorConvert, ErrorKind, Needed, ParserError};
use crate::lib::std::ops::{AddAssign, Div, Shl, Shr};
use crate::stream::{Stream, StreamIsPartial, ToUsize};
use crate::{unpeek, IResult, PResult, Parser};
use crate::{error::IResult, PResult, Parser};

/// Number of bits in a byte
const BYTE: usize = u8::BITS as usize;
Expand All @@ -19,11 +19,11 @@ const BYTE: usize = u8::BITS as usize;
///
/// # Example
/// ```
/// use winnow::prelude::*;
/// use winnow::Bytes;
/// use winnow::binary::bits::{bits, take};
/// use winnow::error::InputError;
///
/// # use winnow::prelude::*;
/// # use winnow::Bytes;
/// # use winnow::binary::bits::{bits, take};
/// # use winnow::error::InputError;
/// # use winnow::error::IResult;
/// type Stream<'i> = &'i Bytes;
///
/// fn stream(b: &[u8]) -> Stream<'_> {
Expand Down Expand Up @@ -56,6 +56,8 @@ where
Input: Stream + Clone,
ParseNext: Parser<(Input, usize), Output, BitError>,
{
#![allow(deprecated)]
use crate::unpeek;
trace(
"bits",
unpeek(move |input: Input| {
Expand Down Expand Up @@ -95,6 +97,7 @@ where
/// use winnow::binary::bits::{bits, bytes, take};
/// use winnow::token::rest;
/// use winnow::error::InputError;
/// use winnow::error::IResult;
///
/// type Stream<'i> = &'i Bytes;
///
Expand Down Expand Up @@ -123,6 +126,8 @@ where
Input: Stream<Token = u8> + Clone,
ParseNext: Parser<Input, Output, ByteError>,
{
#![allow(deprecated)]
use crate::unpeek;
trace(
"bytes",
unpeek(move |(input, offset): (Input, usize)| {
Expand Down Expand Up @@ -171,6 +176,7 @@ where
/// # use winnow::prelude::*;
/// # use winnow::Bytes;
/// # use winnow::error::{InputError, ErrorKind};
/// # use winnow::error::IResult;
/// use winnow::binary::bits::take;
///
/// type Stream<'i> = &'i Bytes;
Expand Down Expand Up @@ -203,6 +209,8 @@ where
Count: ToUsize,
Error: ParserError<(Input, usize)>,
{
#![allow(deprecated)]
use crate::unpeek;
let count = count.to_usize();
trace(
"take",
Expand Down Expand Up @@ -290,6 +298,7 @@ where
/// # use winnow::prelude::*;
/// # use winnow::Bytes;
/// # use winnow::error::{InputError, ErrorKind};
/// # use winnow::error::IResult;
/// use winnow::binary::bits::pattern;
///
/// type Stream<'i> = &'i Bytes;
Expand Down Expand Up @@ -390,6 +399,7 @@ where
/// # use winnow::prelude::*;
/// # use winnow::Bytes;
/// # use winnow::error::{InputError, ErrorKind};
/// # use winnow::error::IResult;
/// use winnow::binary::bits::bool;
///
/// type Stream<'i> = &'i Bytes;
Expand Down
Loading

0 comments on commit 7e32086

Please sign in to comment.