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

Clarify the internal module name #1412

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/bits/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//!

use crate::error::{ErrorKind, ParseError};
use crate::internal::{Err, IResult};
use crate::lib::std::ops::{AddAssign, Div, RangeFrom, Shl, Shr};
use crate::parser::{Err, IResult};
use crate::traits::{InputIter, InputLength, Slice, ToUsize};

/// Generates a parser taking `count` bits
Expand Down
2 changes: 1 addition & 1 deletion src/bits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub mod complete;
pub mod streaming;

use crate::error::{ErrorKind, ParseError};
use crate::internal::{Err, IResult, Needed};
use crate::lib::std::ops::RangeFrom;
use crate::parser::{Err, IResult, Needed};
use crate::traits::{ErrorConvert, Slice};

/// Converts a byte-level input to a bit-level input, for consumption by a parser that uses bits.
Expand Down
2 changes: 1 addition & 1 deletion src/bits/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
//!

use crate::error::{ErrorKind, ParseError};
use crate::internal::{Err, IResult, Needed};
use crate::lib::std::ops::{AddAssign, Div, RangeFrom, Shl, Shr};
use crate::parser::{Err, IResult, Needed};
use crate::traits::{InputIter, InputLength, Slice, ToUsize};

/// Generates a parser taking `count` bits
Expand Down
2 changes: 1 addition & 1 deletion src/branch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ mod tests;

use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult, Parser};
use crate::parser::{Err, IResult, Parser};

/// Helper trait for the [alt()] combinator.
///
Expand Down
2 changes: 1 addition & 1 deletion src/branch/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::branch::{alt, permutation};
use crate::bytes::streaming::tag;
use crate::error::ErrorKind;
use crate::internal::{Err, IResult, Needed};
use crate::parser::{Err, IResult, Needed};
#[cfg(feature = "alloc")]
use crate::{
error::ParseError,
Expand Down
2 changes: 1 addition & 1 deletion src/bytes/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult, Parser};
use crate::lib::std::ops::RangeFrom;
use crate::lib::std::result::Result::*;
use crate::parser::{Err, IResult, Parser};
use crate::traits::{
Compare, CompareResult, FindSubstring, FindToken, InputIter, InputLength, InputTake,
InputTakeAtPosition, Slice, ToUsize,
Expand Down
2 changes: 1 addition & 1 deletion src/bytes/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult, Needed, Parser};
use crate::lib::std::ops::RangeFrom;
use crate::lib::std::result::Result::*;
use crate::parser::{Err, IResult, Needed, Parser};
use crate::traits::{
Compare, CompareResult, FindSubstring, FindToken, InputIter, InputLength, InputTake,
InputTakeAtPosition, Slice, ToUsize,
Expand Down
2 changes: 1 addition & 1 deletion src/bytes/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::character::streaming::{
multispace1 as multispace, oct_digit1 as oct_digit, space1 as space,
};
use crate::error::ErrorKind;
use crate::internal::{Err, IResult, Needed};
use crate::parser::{Err, IResult, Needed};
#[cfg(feature = "alloc")]
use crate::{
branch::alt,
Expand Down
12 changes: 6 additions & 6 deletions src/character/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::branch::alt;
use crate::combinator::opt;
use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult};
use crate::lib::std::ops::{Range, RangeFrom, RangeTo};
use crate::parser::{Err, IResult};
use crate::traits::{
AsChar, FindToken, InputIter, InputLength, InputTake, InputTakeAtPosition, Slice,
};
Expand Down 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 Expand Up @@ -831,7 +831,7 @@ uints! { u8 u16 u32 u64 u128 }
#[cfg(test)]
mod tests {
use super::*;
use crate::internal::Err;
use crate::parser::Err;
use crate::traits::ParseTo;
use proptest::prelude::*;

Expand Down
4 changes: 2 additions & 2 deletions src/character/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::branch::alt;
use crate::combinator::opt;
use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult, Needed};
use crate::lib::std::ops::{Range, RangeFrom, RangeTo};
use crate::parser::{Err, IResult, Needed};
use crate::traits::{
AsChar, FindToken, InputIter, InputLength, InputTake, InputTakeAtPosition, Slice,
};
Expand Down Expand Up @@ -738,7 +738,7 @@ uints! { u8 u16 u32 u64 u128 }
mod tests {
use super::*;
use crate::error::ErrorKind;
use crate::internal::{Err, Needed};
use crate::parser::{Err, Needed};
use crate::sequence::pair;
use crate::traits::ParseTo;
use proptest::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/character/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::streaming::*;
use crate::error::ErrorKind;
use crate::internal::{Err, IResult};
use crate::parser::{Err, IResult};

#[test]
fn one_of_test() {
Expand Down
2 changes: 1 addition & 1 deletion src/combinator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
use crate::lib::std::boxed::Box;

use crate::error::{ErrorKind, FromExternalError, ParseError};
use crate::internal::*;
use crate::lib::std::borrow::Borrow;
use crate::lib::std::convert::Into;
#[cfg(feature = "std")]
use crate::lib::std::fmt::Debug;
use crate::lib::std::mem::transmute;
use crate::lib::std::ops::{Range, RangeFrom, RangeTo};
use crate::parser::*;
use crate::traits::{AsChar, InputIter, InputLength, InputTakeAtPosition, ParseTo};
use crate::traits::{Compare, CompareResult, Offset, Slice};

Expand Down
2 changes: 1 addition & 1 deletion src/combinator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use crate::bytes::complete::take;
use crate::bytes::streaming::tag;
use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult, Needed};
#[cfg(feature = "alloc")]
use crate::lib::std::boxed::Box;
use crate::number::complete::u8;
use crate::parser::{Err, IResult, Needed};

macro_rules! assert_parse(
($left: expr, $right: expr) => {
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//! Parsers are generic over their error type, requiring that it implements
//! the `error::ParseError<Input>` trait.

use crate::internal::Parser;
use crate::lib::std::fmt;
use crate::parser::Parser;

/// This trait must be implemented by the error type of a nom parser.
///
Expand Down Expand Up @@ -225,7 +225,7 @@ impl<I: fmt::Display> fmt::Display for VerboseError<I> {
#[cfg(feature = "std")]
impl<I: fmt::Debug + fmt::Display> std::error::Error for VerboseError<I> {}

use crate::internal::{Err, IResult};
use crate::parser::{Err, IResult};

/// Create a new error from an input position, a static string and an existing error.
/// This is used mainly in the [context] combinator, to add user friendly information
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ pub mod lib {
}

pub use self::bits::*;
pub use self::internal::*;
pub use self::parser::*;
pub use self::traits::*;

pub use self::str::*;
Expand All @@ -442,7 +442,7 @@ pub use self::str::*;
pub mod error;

pub mod combinator;
mod internal;
mod parser;
mod traits;
epage marked this conversation as resolved.
Show resolved Hide resolved
#[macro_use]
pub mod branch;
Expand Down
2 changes: 1 addition & 1 deletion src/multi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ mod tests;

use crate::error::ErrorKind;
use crate::error::ParseError;
use crate::internal::{Err, IResult, Needed, Parser};
#[cfg(feature = "alloc")]
use crate::lib::std::vec::Vec;
use crate::parser::{Err, IResult, Needed, Parser};
use crate::traits::{InputLength, InputTake, ToUsize};
use core::num::NonZeroUsize;

Expand Down
2 changes: 1 addition & 1 deletion src/multi/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ use crate::{
bytes::streaming::tag,
character::streaming::digit1 as digit,
error::{ErrorKind, ParseError},
internal::{Err, IResult, Needed},
lib::std::str::{self, FromStr},
number::streaming::{be_u16, be_u8},
parser::{Err, IResult, Needed},
sequence::{pair, tuple},
};
#[cfg(feature = "alloc")]
Expand Down
4 changes: 2 additions & 2 deletions src/number/complete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use crate::character::complete::{char, digit1, sign};
use crate::combinator::{cut, map, opt, recognize};
use crate::error::ParseError;
use crate::error::{make_error, ErrorKind};
use crate::internal::*;
use crate::lib::std::ops::{Range, RangeFrom, RangeTo};
use crate::parser::*;
use crate::sequence::{pair, tuple};
use crate::traits::{
AsBytes, AsChar, Compare, InputIter, InputLength, InputTake, InputTakeAtPosition, Offset, Slice,
Expand Down Expand Up @@ -1663,7 +1663,7 @@ where
mod tests {
use super::*;
use crate::error::ErrorKind;
use crate::internal::Err;
use crate::parser::Err;
use proptest::prelude::*;

macro_rules! assert_parse(
Expand Down
4 changes: 2 additions & 2 deletions src/number/streaming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use crate::bytes::streaming::tag;
use crate::character::streaming::{char, digit1, sign};
use crate::combinator::{cut, map, opt, recognize};
use crate::error::{ErrorKind, ParseError};
use crate::internal::*;
use crate::lib::std::ops::{RangeFrom, RangeTo};
use crate::parser::*;
use crate::sequence::{pair, tuple};
use crate::traits::{
AsBytes, AsChar, Compare, InputIter, InputLength, InputTake, InputTakeAtPosition, Offset, Slice,
Expand Down Expand Up @@ -1636,7 +1636,7 @@ where
mod tests {
use super::*;
use crate::error::ErrorKind;
use crate::internal::{Err, Needed};
use crate::parser::{Err, Needed};
use proptest::prelude::*;

macro_rules! assert_parse(
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/sequence/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
mod tests;

use crate::error::ParseError;
use crate::internal::{IResult, Parser};
use crate::parser::{IResult, Parser};

/// Gets an object from the first parser,
/// then gets another object from the second parser.
Expand Down
2 changes: 1 addition & 1 deletion src/sequence/tests.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::*;
use crate::bytes::streaming::{tag, take};
use crate::error::ErrorKind;
use crate::internal::{Err, IResult, Needed};
use crate::number::streaming::be_u16;
use crate::parser::{Err, IResult, Needed};

#[test]
fn single_element_tuples() {
Expand Down
2 changes: 1 addition & 1 deletion src/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ mod test {
}
}

use crate::internal::Needed;
use crate::parser::Needed;

fn is_alphabetic(c: char) -> bool {
(c as u8 >= 0x41 && c as u8 <= 0x5A) || (c as u8 >= 0x61 && c as u8 <= 0x7A)
Expand Down
2 changes: 1 addition & 1 deletion src/traits.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//! Traits input types have to implement to work with nom combinators
use crate::error::{ErrorKind, ParseError};
use crate::internal::{Err, IResult, Needed};
use crate::lib::std::iter::{Copied, Enumerate};
use crate::lib::std::ops::{Range, RangeFrom, RangeFull, RangeTo};
use crate::lib::std::slice::Iter;
use crate::lib::std::str::from_utf8;
use crate::lib::std::str::CharIndices;
use crate::lib::std::str::Chars;
use crate::lib::std::str::FromStr;
use crate::parser::{Err, IResult, Needed};

#[cfg(feature = "alloc")]
use crate::lib::std::string::String;
Expand Down