Skip to content

Commit

Permalink
Add a prelude to reduce import noise
Browse files Browse the repository at this point in the history
  • Loading branch information
samueltardieu committed Feb 13, 2023
1 parent bf8cddb commit a95dd75
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,8 @@ mod str;

pub mod number;

pub mod prelude;

#[cfg(feature = "docsrs")]
#[cfg_attr(feature = "docsrs", cfg_attr(feature = "docsrs", doc = include_str!("../doc/nom_recipes.md")))]
pub mod recipes {}
39 changes: 39 additions & 0 deletions src/prelude.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//! Reexport the content of many modules, except `complete` and `streaming` modules
//! which have their own reexports as `prelude::complete` and `prelude::streaming`.
pub use crate::{
bits::{complete as _, streaming as _, *},
branch::*,
character::{complete as _, streaming as _, *},
combinator::{complete as _, *},
multi::*,
number::{complete as _, streaming as _, *},
sequence::*,
*,
};

/// Reexport all `complete` modules content but standard type names from `nom::number::complete`.
pub mod complete {
pub use crate::{
bits::complete::*,
bytes::complete::*,
character::complete::*,
number::complete::{
f32 as _, f64 as _, i128 as _, i16 as _, i32 as _, i64 as _, i8 as _, u128 as _, u16 as _,
u32 as _, u64 as _, u8 as _, *,
},
};
}

/// Reexport all `streaming` modules content but standard type names from `nom::number::streaming`.
pub mod streaming {
pub use crate::{
bits::streaming::*,
bytes::streaming::*,
character::streaming::*,
number::streaming::{
f32 as _, f64 as _, i128 as _, i16 as _, i32 as _, i64 as _, i8 as _, u128 as _, u16 as _,
u32 as _, u64 as _, u8 as _, *,
},
};
}

0 comments on commit a95dd75

Please sign in to comment.