Skip to content

Commit

Permalink
Merge pull request #677 from epage/unpeek
Browse files Browse the repository at this point in the history
fix: Deprecate `unpeek`
  • Loading branch information
epage authored Jan 7, 2025
2 parents c20aba1 + 4e01c8f commit a2f1e5b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion 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::{IResult, PResult, Parser};

/// Number of bits in a byte
const BYTE: usize = u8::BITS as usize;
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 @@ -123,6 +125,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 @@ -203,6 +207,8 @@ where
Count: ToUsize,
Error: ParserError<(Input, usize)>,
{
#![allow(deprecated)]
use crate::unpeek;
let count = count.to_usize();
trace(
"take",
Expand Down
3 changes: 2 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1261,8 +1261,9 @@ impl<I, O, E> Parser<I, O, E> for Box<dyn Parser<I, O, E> + '_> {
}
}

/// Convert a [`Parser::parse_peek`] style parse function to be a [`Parser`]
/// Deprecated
#[inline(always)]
#[deprecated(since = "0.6.23")]
pub fn unpeek<'a, I, O, E>(
mut peek: impl FnMut(I) -> IResult<I, O, E> + 'a,
) -> impl FnMut(&mut I) -> PResult<O, E>
Expand Down

0 comments on commit a2f1e5b

Please sign in to comment.