From b0c011f7655b96466941290ceefedd1ee9ddbc1d Mon Sep 17 00:00:00 2001 From: Antoine PLASKOWSKI Date: Tue, 26 Mar 2024 14:45:38 +0100 Subject: [PATCH] remove core module for clarity; duplicate with core from Rust --- readme.md | 6 ++--- src/base/all.rs | 2 +- src/base/any.rs | 2 +- src/base/ascii.rs | 4 +-- src/base/base_atom.rs | 2 +- src/base/character.rs | 2 +- src/base/end_of_stream.rs | 12 ++++----- src/base/failure.rs | 2 +- src/base/float.rs | 28 +++++++++----------- src/base/is.rs | 12 ++++----- src/base/list.rs | 12 ++++----- src/base/nbit.rs | 14 +++++----- src/base/octet.rs | 12 ++++----- src/base/one_of.rs | 12 ++++----- src/base/parse.rs | 2 +- src/base/primitive.rs | 12 ++++----- src/base/radix.rs | 43 ++++++++++++++----------------- src/base/sign.rs | 12 ++++----- src/base/success.rs | 2 +- src/base/tag.rs | 12 ++++----- src/base/take.rs | 2 +- src/base/to_digit.rs | 12 ++++----- src/base/utf8.rs | 16 +++++------- src/context/ignore.rs | 2 +- src/context/keep.rs | 6 ++--- src/context/stack.rs | 6 ++--- src/context/tree.rs | 4 +-- src/{core => }/contexting.rs | 0 src/core/mod.rs | 31 ---------------------- src/{core => }/core_atom.rs | 4 +-- src/lib.rs | 24 +++++++++++++---- src/{core => }/parse.rs | 4 +-- src/{core => }/parsed.rs | 4 +-- src/{core => }/parsed_aux.rs | 0 src/{core => }/readme.md | 2 +- src/stream/bit_stream.rs | 2 +- src/stream/reader_stream.rs | 19 ++++++-------- src/stream/string_stream.rs | 2 +- src/stream/vec_stream.rs | 2 +- src/{core => }/streaming.rs | 4 +-- src/{core => }/success.rs | 0 src/{core => utils}/acc.rs | 2 +- src/utils/add_atom.rs | 2 +- src/utils/and.rs | 2 +- src/utils/and_drop.rs | 2 +- src/utils/and_then.rs | 2 +- src/utils/drop.rs | 2 +- src/utils/drop_and.rs | 2 +- src/utils/drop_first.rs | 2 +- src/utils/drop_last.rs | 2 +- src/utils/enumerate.rs | 2 +- src/{core => utils}/extend.rs | 0 src/utils/fill.rs | 12 ++++----- src/utils/filter.rs | 8 +++--- src/utils/filter_map.rs | 8 +++--- src/utils/fold_bounds.rs | 22 +++++++--------- src/utils/fold_until.rs | 10 +++---- src/utils/limit.rs | 8 +++--- src/utils/map.rs | 2 +- src/utils/mod.rs | 15 ++++++++++- src/utils/not.rs | 2 +- src/utils/opt.rs | 2 +- src/utils/or.rs | 2 +- src/utils/peek.rs | 2 +- src/{core => utils}/push.rs | 0 src/utils/span.rs | 12 ++++----- src/utils/to.rs | 2 +- src/{core => utils}/try_acc.rs | 2 +- src/{core => utils}/try_extend.rs | 0 src/utils/try_fold_bounds.rs | 22 +++++++--------- src/utils/try_fold_iter.rs | 12 ++++----- src/utils/try_fold_until.rs | 10 +++---- src/utils/try_map.rs | 2 +- src/{core => utils}/try_push.rs | 0 74 files changed, 230 insertions(+), 296 deletions(-) rename src/{core => }/contexting.rs (100%) delete mode 100644 src/core/mod.rs rename src/{core => }/core_atom.rs (95%) rename src/{core => }/parse.rs (98%) rename src/{core => }/parsed.rs (99%) rename src/{core => }/parsed_aux.rs (100%) rename src/{core => }/readme.md (97%) rename src/{core => }/streaming.rs (99%) rename src/{core => }/success.rs (100%) rename src/{core => utils}/acc.rs (95%) rename src/{core => utils}/extend.rs (100%) rename src/{core => utils}/push.rs (100%) rename src/{core => utils}/try_acc.rs (96%) rename src/{core => utils}/try_extend.rs (100%) rename src/{core => utils}/try_push.rs (100%) diff --git a/readme.md b/readme.md index d8939ce..761911d 100644 --- a/readme.md +++ b/readme.md @@ -8,6 +8,8 @@ The very same hex color example from nom but using binator: ```rust use binator::{ + Parse, + Parsed, base::{ is, uint_radix, @@ -15,10 +17,6 @@ use binator::{ Radix, }, context::Ignore, - core::{ - Parse, - Parsed, - }, utils::Utils, }; diff --git a/src/base/all.rs b/src/base/all.rs index 7ae7b63..ab16ede 100644 --- a/src/base/all.rs +++ b/src/base/all.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Contexting, CoreAtom, Parsed, diff --git a/src/base/any.rs b/src/base/any.rs index c373ea7..1a3e69c 100644 --- a/src/base/any.rs +++ b/src/base/any.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Contexting, CoreAtom, Parsed, diff --git a/src/base/ascii.rs b/src/base/ascii.rs index 0585d98..14d3ec4 100644 --- a/src/base/ascii.rs +++ b/src/base/ascii.rs @@ -1,6 +1,6 @@ //! ASCII Core Rules (RFC5234 B.1.) -use stdcore::fmt::{ +use core::fmt::{ self, Display, Formatter, @@ -8,8 +8,8 @@ use stdcore::fmt::{ use crate::{ base::*, - core::*, utils::*, + *, }; /// Meta trait for ascii combinator diff --git a/src/base/base_atom.rs b/src/base/base_atom.rs index 674cbba..51525d3 100644 --- a/src/base/base_atom.rs +++ b/src/base/base_atom.rs @@ -1,4 +1,4 @@ -use stdcore::fmt::{ +use core::fmt::{ Debug, Display, Formatter, diff --git a/src/base/character.rs b/src/base/character.rs index 755a5fc..5056917 100644 --- a/src/base/character.rs +++ b/src/base/character.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ any, Contexting, CoreAtom, diff --git a/src/base/end_of_stream.rs b/src/base/end_of_stream.rs index 0b5f1a3..f5cad82 100644 --- a/src/base/end_of_stream.rs +++ b/src/base/end_of_stream.rs @@ -1,12 +1,10 @@ use crate::{ base::any, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Context from end_of_stream parser. diff --git a/src/base/failure.rs b/src/base/failure.rs index 76a7dcc..dca555c 100644 --- a/src/base/failure.rs +++ b/src/base/failure.rs @@ -3,7 +3,7 @@ use core::{ fmt::Debug, }; -use crate::core::{ +use crate::{ Contexting, Parse, Parsed, diff --git a/src/base/float.rs b/src/base/float.rs index 679d48f..48002b1 100644 --- a/src/base/float.rs +++ b/src/base/float.rs @@ -1,4 +1,4 @@ -use stdcore::{ +use core::{ fmt::{ self, Debug, @@ -17,19 +17,17 @@ use crate::{ to_digit, BaseAtom, }, - core::{ - Acc, - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - Success, - }, utils::{ + Acc, Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, + Success, }; /// Information about float failure @@ -178,13 +176,11 @@ mod tests { use crate::{ base::BaseAtom, context::Tree, - core::{ - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::UtilsAtom, + CoreAtom, + Parse, + Parsed, + Streaming, }; #[derive(Display, Debug, Clone, From)] diff --git a/src/base/is.rs b/src/base/is.rs index a8cb0fe..e8641be 100644 --- a/src/base/is.rs +++ b/src/base/is.rs @@ -5,14 +5,12 @@ use crate::{ any, BaseAtom, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::Utils, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Return Success if item from stream is partially equal to t. diff --git a/src/base/list.rs b/src/base/list.rs index efe8f35..635079d 100644 --- a/src/base/list.rs +++ b/src/base/list.rs @@ -5,17 +5,15 @@ use crate::{ any, BaseAtom, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::{ Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Take a list of T and return a Parser that will partially Eq in order Item diff --git a/src/base/nbit.rs b/src/base/nbit.rs index 4335c04..7e930c8 100644 --- a/src/base/nbit.rs +++ b/src/base/nbit.rs @@ -1,12 +1,10 @@ use crate::{ base::octet, - core::{ - Contexting, - CoreAtom, - Parse, - Streaming, - }, utils::Utils, + Contexting, + CoreAtom, + Parse, + Streaming, }; /// Used by nbit to represent n only if 0 > n > 8 @@ -65,7 +63,7 @@ where feature = "tracing", tracing::instrument(level = "trace", name = "nbit", skip_all, ret(Display)) )] - fn parse(&mut self, stream: Stream) -> crate::core::Parsed { + fn parse(&mut self, stream: Stream) -> crate::Parsed { octet .map(|b| (b >> self.n, b & u8::MAX >> (8 - self.n))) .parse(stream) @@ -77,7 +75,7 @@ mod tests { use super::*; use crate::{ context::*, - core::*, + *, }; #[test] diff --git a/src/base/octet.rs b/src/base/octet.rs index c0d554a..c47bfb6 100644 --- a/src/base/octet.rs +++ b/src/base/octet.rs @@ -1,13 +1,11 @@ use crate::{ base::any, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::Utils, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Will read an item from the Stream and convert it to an octet diff --git a/src/base/one_of.rs b/src/base/one_of.rs index fba31d8..3cd8862 100644 --- a/src/base/one_of.rs +++ b/src/base/one_of.rs @@ -5,14 +5,12 @@ use crate::{ any, BaseAtom, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::Utils, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Will check if next Item from Stream is partially equal diff --git a/src/base/parse.rs b/src/base/parse.rs index d3fe57c..eb80482 100644 --- a/src/base/parse.rs +++ b/src/base/parse.rs @@ -1,6 +1,6 @@ use core::fmt::Debug; -use crate::core::Parse; +use crate::Parse; /// Take a parser and return a Parser that will call parse on it. pub fn parse( diff --git a/src/base/primitive.rs b/src/base/primitive.rs index f623910..b82cb41 100644 --- a/src/base/primitive.rs +++ b/src/base/primitive.rs @@ -2,17 +2,15 @@ use paste::paste; use crate::{ base::octet, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::{ Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Meta trait for number diff --git a/src/base/radix.rs b/src/base/radix.rs index a178b2c..aaca23e 100644 --- a/src/base/radix.rs +++ b/src/base/radix.rs @@ -1,3 +1,13 @@ +use core::{ + fmt::{ + self, + Debug, + Display, + Formatter, + }, + marker::PhantomData, +}; + use num_traits::{ cast::AsPrimitive, identities::Zero, @@ -11,15 +21,6 @@ use num_traits::{ }, CheckedSub, }; -use stdcore::{ - fmt::{ - self, - Debug, - Display, - Formatter, - }, - marker::PhantomData, -}; use crate::{ base::{ @@ -28,19 +29,17 @@ use crate::{ BaseAtom, Sign, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - Success, - }, utils::{ TryFoldBoundsParse, Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, + Success, }; /// Represent Radix, used to limit radix <= 36 @@ -309,13 +308,11 @@ mod tests { use crate::{ base::BaseAtom, context::Tree, - core::{ - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::UtilsAtom, + CoreAtom, + Parse, + Parsed, + Streaming, }; #[derive(Display, Debug, Clone, From)] diff --git a/src/base/sign.rs b/src/base/sign.rs index f244367..7f74b7c 100644 --- a/src/base/sign.rs +++ b/src/base/sign.rs @@ -3,17 +3,15 @@ use crate::{ is, BaseAtom, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::{ Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Enum that hold Sign value diff --git a/src/base/success.rs b/src/base/success.rs index ed373fd..e772b85 100644 --- a/src/base/success.rs +++ b/src/base/success.rs @@ -1,6 +1,6 @@ use core::fmt::Debug; -use crate::core::{ +use crate::{ Parse, Parsed, ProvideElement, diff --git a/src/base/tag.rs b/src/base/tag.rs index 2594185..678ce3e 100644 --- a/src/base/tag.rs +++ b/src/base/tag.rs @@ -3,17 +3,15 @@ use crate::{ take, BaseAtom, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::{ Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Take a &'static str and return a Parser that will diff --git a/src/base/take.rs b/src/base/take.rs index 786ba10..682ce07 100644 --- a/src/base/take.rs +++ b/src/base/take.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Contexting, CoreAtom, Parse, diff --git a/src/base/to_digit.rs b/src/base/to_digit.rs index f39eabe..33dba43 100644 --- a/src/base/to_digit.rs +++ b/src/base/to_digit.rs @@ -3,17 +3,15 @@ use crate::{ ascii::digit, BaseAtom, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::{ Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; /// Parse character digit and return it in integer format diff --git a/src/base/utf8.rs b/src/base/utf8.rs index f4837b3..b425e58 100644 --- a/src/base/utf8.rs +++ b/src/base/utf8.rs @@ -3,15 +3,13 @@ use crate::{ octet, BaseAtom, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - Success, - }, utils::Utils, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, + Success, }; fn raw(stream: Stream) -> Parsed @@ -82,7 +80,7 @@ where mod tests { use crate::{ context::Ignore, - core::Parsed, + Parsed, }; #[test] diff --git a/src/context/ignore.rs b/src/context/ignore.rs index 367ace5..b4b6e86 100644 --- a/src/context/ignore.rs +++ b/src/context/ignore.rs @@ -9,7 +9,7 @@ use core::{ }, }; -use crate::core::{ +use crate::{ Contexting, ProvideElement, }; diff --git a/src/context/keep.rs b/src/context/keep.rs index f7661ef..b2644a8 100644 --- a/src/context/keep.rs +++ b/src/context/keep.rs @@ -12,10 +12,8 @@ use crate::{ First, Last, }, - core::{ - Contexting, - ProvideElement, - }, + Contexting, + ProvideElement, }; /// Will keep only the first or the last Element that was feed to it. diff --git a/src/context/stack.rs b/src/context/stack.rs index fa29b38..0ce512f 100644 --- a/src/context/stack.rs +++ b/src/context/stack.rs @@ -17,10 +17,8 @@ use crate::{ First, Last, }, - core::{ - Contexting, - ProvideElement, - }, + Contexting, + ProvideElement, }; /// Will keep the last Stack of elements feed to it. diff --git a/src/context/tree.rs b/src/context/tree.rs index 76d80d2..19a5073 100644 --- a/src/context/tree.rs +++ b/src/context/tree.rs @@ -9,8 +9,8 @@ use core::{ }, }; -use crate::core::{ - Acc, +use crate::{ + utils::Acc, Contexting, ProvideElement, }; diff --git a/src/core/contexting.rs b/src/contexting.rs similarity index 100% rename from src/core/contexting.rs rename to src/contexting.rs diff --git a/src/core/mod.rs b/src/core/mod.rs deleted file mode 100644 index ed6b184..0000000 --- a/src/core/mod.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![doc = include_str!("readme.md")] - -mod core_atom; -pub use core_atom::*; - -mod contexting; -pub use contexting::*; -mod parse; -pub use parse::*; -mod success; -pub use success::*; -mod parsed_aux; -pub use parsed_aux::*; -mod parsed; -pub use parsed::*; - -mod streaming; -pub use streaming::*; - -mod acc; -pub use acc::*; -mod try_acc; -pub use try_acc::*; -mod extend; -pub use extend::*; -mod try_extend; -pub use try_extend::*; -mod push; -pub use push::*; -mod try_push; -pub use try_push::*; diff --git a/src/core/core_atom.rs b/src/core_atom.rs similarity index 95% rename from src/core/core_atom.rs rename to src/core_atom.rs index 6a5738f..d8c103d 100644 --- a/src/core/core_atom.rs +++ b/src/core_atom.rs @@ -1,10 +1,10 @@ -use stdcore::fmt::{ +use core::fmt::{ Debug, Display, Formatter, }; -use crate::core::*; +use crate::*; #[derive(Debug, Clone, PartialEq, Eq)] /// Core context used to implement context for basic type like u8 diff --git a/src/lib.rs b/src/lib.rs index 82cf1ef..dd7c3e7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,5 @@ -//! To learn how to use binator read [crate::core] doc. - #![doc = include_str!("../readme.md")] +#![doc = include_str!("readme.md")] #![cfg_attr(not(feature = "std"), no_std)] #![warn(clippy::missing_const_for_fn)] #![allow(clippy::needless_lifetimes)] @@ -16,11 +15,26 @@ #[cfg(feature = "alloc")] extern crate alloc; - -extern crate core as stdcore; +extern crate core; pub mod base; pub mod context; -pub mod core; pub mod stream; pub mod utils; + +mod core_atom; +pub use core_atom::*; + +mod contexting; +pub use contexting::*; +mod parse; +pub use parse::*; +mod success; +pub use success::*; +mod parsed_aux; +pub use parsed_aux::*; +mod parsed; +pub use parsed::*; + +mod streaming; +pub use streaming::*; diff --git a/src/core/parse.rs b/src/parse.rs similarity index 98% rename from src/core/parse.rs rename to src/parse.rs index 622e35a..5fe626b 100644 --- a/src/core/parse.rs +++ b/src/parse.rs @@ -3,7 +3,7 @@ use core::{ ops::BitOr, }; -use crate::core::{ +use crate::{ Parsed, Streaming, Success, @@ -106,7 +106,7 @@ impl Parse for () { mod tests { use core::ops::BitOr; - use crate::core::{ + use crate::{ Parse, Parsed, Streaming, diff --git a/src/core/parsed.rs b/src/parsed.rs similarity index 99% rename from src/core/parsed.rs rename to src/parsed.rs index d233cc5..658a0e6 100644 --- a/src/core/parsed.rs +++ b/src/parsed.rs @@ -13,7 +13,7 @@ use core::{ }, }; -use crate::core::{ +use crate::{ Contexting, ParsedAux, ProvideElement, @@ -291,7 +291,7 @@ where #[cfg(test)] mod tests { - use crate::core::{ + use crate::{ Parsed, Success, }; diff --git a/src/core/parsed_aux.rs b/src/parsed_aux.rs similarity index 100% rename from src/core/parsed_aux.rs rename to src/parsed_aux.rs diff --git a/src/core/readme.md b/src/readme.md similarity index 97% rename from src/core/readme.md rename to src/readme.md index 9918d47..25e202c 100644 --- a/src/core/readme.md +++ b/src/readme.md @@ -1,4 +1,4 @@ -Contains all require traits of binator, implement them on std and Rust type. +## How binator works Binator define trait that structure your parser. For something to be considered as a Parser by binator it must implement [Parse] trait. This trait is used every time you use a Parser. This trait only have one method [Parse::parse], it takes a Stream as parameter. A Stream can be anything that implement [Streaming], for example binator implement it for `&'a [u8]`. Most of the time a Parser will use indirectly [Streaming::split_first] to get a [Streaming::Item] from the Stream. When a Parser is done with the input it will return [Parsed]. It's an enumeration that implement [core::ops::Try] so you can use `?` on a Parser, this enumeration is used to represent the result of a Parser. A Parser can return [Parsed::Success], [Parsed::Failure] or [Parsed::Error]. Success contains a Token, that what the Parser produced from the Stream, and a Stream that contains the input not used by the Parser. Failure means the parser didn't recognize the input, it's not a fatal error at all, it's perfectly normal for a combinator parser to return Failure. And then Error is a fatal Error, like an Error produced by the Stream or by a Parser. Both Failure and Error contains a Context. Context is something that implement [Contexting], it's the way binator accumulate Failure, Context is like a container of Failure. If a Parser need to return a context, it can use [Contexting::new] that require an Atom. Atom can be anything a Parser want, for example, core define [crate::base::FloatAtom]. [Contexting] require that the Context implement [core::ops::Add] and [core::ops::BitOr] this mean if you already called another Parser that return a Context you can add you own Atom and build a more precise Context for the final user. Most combinator of binator do this for you already. With all of this you know mostly all about how binator works. diff --git a/src/stream/bit_stream.rs b/src/stream/bit_stream.rs index 8291837..af7c303 100644 --- a/src/stream/bit_stream.rs +++ b/src/stream/bit_stream.rs @@ -6,7 +6,7 @@ use core::{ }, }; -use crate::core::{ +use crate::{ SplitError, SplitFirst, UtilsStream, diff --git a/src/stream/reader_stream.rs b/src/stream/reader_stream.rs index fc93c9e..825a060 100644 --- a/src/stream/reader_stream.rs +++ b/src/stream/reader_stream.rs @@ -1,22 +1,19 @@ use alloc::rc::Rc; -use std::io::{ - self, - Read, -}; - -use stdcore::{ +use core::{ cell::UnsafeCell, fmt::Debug, slice::from_raw_parts_mut, }; +use std::io::{ + self, + Read, +}; use crate::{ - core::{ - Split, - Streaming, - Success, - }, stream::Position, + Split, + Streaming, + Success, }; #[derive(Debug)] diff --git a/src/stream/string_stream.rs b/src/stream/string_stream.rs index 74a4d89..3030216 100644 --- a/src/stream/string_stream.rs +++ b/src/stream/string_stream.rs @@ -8,7 +8,7 @@ use core::{ ops::Range, }; -use crate::core::{ +use crate::{ Split, Streaming, Success, diff --git a/src/stream/vec_stream.rs b/src/stream/vec_stream.rs index 5c77d16..c9d403e 100644 --- a/src/stream/vec_stream.rs +++ b/src/stream/vec_stream.rs @@ -5,7 +5,7 @@ use core::{ ops::Range, }; -use crate::core::{ +use crate::{ Split, Streaming, Success, diff --git a/src/core/streaming.rs b/src/streaming.rs similarity index 99% rename from src/core/streaming.rs rename to src/streaming.rs index f02b532..995dc00 100644 --- a/src/core/streaming.rs +++ b/src/streaming.rs @@ -1,4 +1,4 @@ -use stdcore::{ +use core::{ convert::Infallible, fmt::Debug, ops::{ @@ -8,7 +8,7 @@ use stdcore::{ }, }; -use crate::core::Success; +use crate::Success; /// This trait must be implement by all struct that want to be a stream for /// binator. diff --git a/src/core/success.rs b/src/success.rs similarity index 100% rename from src/core/success.rs rename to src/success.rs diff --git a/src/core/acc.rs b/src/utils/acc.rs similarity index 95% rename from src/core/acc.rs rename to src/utils/acc.rs index a0ccc91..da7ba98 100644 --- a/src/core/acc.rs +++ b/src/utils/acc.rs @@ -1,4 +1,4 @@ -use crate::core::Push; +use crate::utils::Push; /// This is very usefull to be use on combinator like fold. /// For example, `.fold_bounds(.., Vec::new, Acc::acc)`. diff --git a/src/utils/add_atom.rs b/src/utils/add_atom.rs index 0760663..1a1c9f4 100644 --- a/src/utils/add_atom.rs +++ b/src/utils/add_atom.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Contexting, Parse, Parsed, diff --git a/src/utils/and.rs b/src/utils/and.rs index d31f08f..31c71c0 100644 --- a/src/utils/and.rs +++ b/src/utils/and.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, Success, diff --git a/src/utils/and_drop.rs b/src/utils/and_drop.rs index 58b6a9d..8390786 100644 --- a/src/utils/and_drop.rs +++ b/src/utils/and_drop.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, Success, diff --git a/src/utils/and_then.rs b/src/utils/and_then.rs index 89b9b17..405d2fb 100644 --- a/src/utils/and_then.rs +++ b/src/utils/and_then.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, Success, diff --git a/src/utils/drop.rs b/src/utils/drop.rs index 2db8866..b3c44ea 100644 --- a/src/utils/drop.rs +++ b/src/utils/drop.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/utils/drop_and.rs b/src/utils/drop_and.rs index 25fde1b..f5f3a10 100644 --- a/src/utils/drop_and.rs +++ b/src/utils/drop_and.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, Success, diff --git a/src/utils/drop_first.rs b/src/utils/drop_first.rs index fb90d37..781c255 100644 --- a/src/utils/drop_first.rs +++ b/src/utils/drop_first.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/utils/drop_last.rs b/src/utils/drop_last.rs index d1304ab..c724639 100644 --- a/src/utils/drop_last.rs +++ b/src/utils/drop_last.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/utils/enumerate.rs b/src/utils/enumerate.rs index b6a7c9f..23ed71c 100644 --- a/src/utils/enumerate.rs +++ b/src/utils/enumerate.rs @@ -1,6 +1,6 @@ use core::mem; -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/core/extend.rs b/src/utils/extend.rs similarity index 100% rename from src/core/extend.rs rename to src/utils/extend.rs diff --git a/src/utils/fill.rs b/src/utils/fill.rs index 1ca98d6..e0370c4 100644 --- a/src/utils/fill.rs +++ b/src/utils/fill.rs @@ -1,13 +1,11 @@ use core::mem::MaybeUninit; use crate::{ - core::{ - Contexting, - Parse, - Parsed, - Streaming, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, + Streaming, }; /// Implementation of [crate::utils::Utils::fill] @@ -82,8 +80,8 @@ mod tests { Keep, Last, }, - core::CoreAtom, utils::Utils, + CoreAtom, }; type HandleAtom = Keep>; diff --git a/src/utils/filter.rs b/src/utils/filter.rs index c095c9e..b4ea763 100644 --- a/src/utils/filter.rs +++ b/src/utils/filter.rs @@ -1,10 +1,8 @@ use crate::{ - core::{ - Contexting, - Parse, - Parsed, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, }; /// Implementation of [crate::utils::Utils::filter] diff --git a/src/utils/filter_map.rs b/src/utils/filter_map.rs index 75bf07f..3301ad8 100644 --- a/src/utils/filter_map.rs +++ b/src/utils/filter_map.rs @@ -1,10 +1,8 @@ use crate::{ - core::{ - Contexting, - Parse, - Parsed, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, }; /// Implementation of [crate::utils::Utils::filter_map] diff --git a/src/utils/fold_bounds.rs b/src/utils/fold_bounds.rs index f51ff61..2ef1768 100644 --- a/src/utils/fold_bounds.rs +++ b/src/utils/fold_bounds.rs @@ -11,13 +11,11 @@ use core::{ }; use crate::{ - core::{ - Contexting, - Parse, - Parsed, - Streaming, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, + Streaming, }; /// Implementation of [crate::utils::Utils::fold_bounds] @@ -316,17 +314,15 @@ mod tests { Keep, Last, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::{ Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; #[derive(Display, Debug, Clone, From, PartialEq)] diff --git a/src/utils/fold_until.rs b/src/utils/fold_until.rs index ec670a1..6709d35 100644 --- a/src/utils/fold_until.rs +++ b/src/utils/fold_until.rs @@ -1,11 +1,9 @@ use crate::{ - core::{ - Contexting, - Parse, - Parsed, - Streaming, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, + Streaming, }; /// Implementation of [crate::utils::Utils::fold_until] diff --git a/src/utils/limit.rs b/src/utils/limit.rs index 3ce1790..9ac227d 100644 --- a/src/utils/limit.rs +++ b/src/utils/limit.rs @@ -1,10 +1,8 @@ use crate::{ - core::{ - Contexting, - Parse, - Parsed, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, }; /// Implementation of [crate::utils::Utils::limit] diff --git a/src/utils/map.rs b/src/utils/map.rs index 802e82a..3729dd7 100644 --- a/src/utils/map.rs +++ b/src/utils/map.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index 7325fd1..58080c3 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -16,7 +16,7 @@ use core::{ }, }; -use crate::core::{ +use crate::{ Contexting, Parse, Parsed, @@ -80,6 +80,19 @@ pub use limit::*; mod add_atom; pub use add_atom::*; +mod acc; +pub use acc::*; +mod try_acc; +pub use try_acc::*; +mod extend; +pub use extend::*; +mod try_extend; +pub use try_extend::*; +mod push; +pub use push::*; +mod try_push; +pub use try_push::*; + /// Atom for most utils combinator #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub enum UtilsAtom { diff --git a/src/utils/not.rs b/src/utils/not.rs index 4b5955e..0ba34e0 100644 --- a/src/utils/not.rs +++ b/src/utils/not.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Contexting, Parse, Parsed, diff --git a/src/utils/opt.rs b/src/utils/opt.rs index 50adf03..54bda92 100644 --- a/src/utils/opt.rs +++ b/src/utils/opt.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/utils/or.rs b/src/utils/or.rs index db26582..6ae3e71 100644 --- a/src/utils/or.rs +++ b/src/utils/or.rs @@ -1,6 +1,6 @@ use core::ops::BitOr; -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/utils/peek.rs b/src/utils/peek.rs index 4cd5a72..bd66c32 100644 --- a/src/utils/peek.rs +++ b/src/utils/peek.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, Success, diff --git a/src/core/push.rs b/src/utils/push.rs similarity index 100% rename from src/core/push.rs rename to src/utils/push.rs diff --git a/src/utils/span.rs b/src/utils/span.rs index 36c12ef..15a3955 100644 --- a/src/utils/span.rs +++ b/src/utils/span.rs @@ -1,12 +1,10 @@ use crate::{ - core::{ - Contexting, - Parse, - Parsed, - Streaming, - Success, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, + Streaming, + Success, }; /// Implementation of [crate::utils::Utils::span] diff --git a/src/utils/to.rs b/src/utils/to.rs index a089ade..941fae9 100644 --- a/src/utils/to.rs +++ b/src/utils/to.rs @@ -1,4 +1,4 @@ -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/core/try_acc.rs b/src/utils/try_acc.rs similarity index 96% rename from src/core/try_acc.rs rename to src/utils/try_acc.rs index 2965de8..e794e9b 100644 --- a/src/core/try_acc.rs +++ b/src/utils/try_acc.rs @@ -1,4 +1,4 @@ -use crate::core::TryPush; +use crate::utils::TryPush; /// This is very usefull to be use on combinator like try_fold. /// For example, `.try_fold_bounds(.., || Ok(Vec::new), TryAcc::try_acc)`. diff --git a/src/core/try_extend.rs b/src/utils/try_extend.rs similarity index 100% rename from src/core/try_extend.rs rename to src/utils/try_extend.rs diff --git a/src/utils/try_fold_bounds.rs b/src/utils/try_fold_bounds.rs index ffe67b5..fd8f271 100644 --- a/src/utils/try_fold_bounds.rs +++ b/src/utils/try_fold_bounds.rs @@ -13,13 +13,11 @@ use core::{ }; use crate::{ - core::{ - Contexting, - Parse, - Parsed, - Streaming, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, + Streaming, }; /// Implementation of [crate::utils::Utils::try_fold_bounds] @@ -345,17 +343,15 @@ mod tests { Keep, Last, }, - core::{ - Contexting, - CoreAtom, - Parse, - Parsed, - Streaming, - }, utils::{ Utils, UtilsAtom, }, + Contexting, + CoreAtom, + Parse, + Parsed, + Streaming, }; #[derive(Display, Debug, Clone, From, PartialEq)] diff --git a/src/utils/try_fold_iter.rs b/src/utils/try_fold_iter.rs index 44ce59e..baa15f7 100644 --- a/src/utils/try_fold_iter.rs +++ b/src/utils/try_fold_iter.rs @@ -4,14 +4,12 @@ use core::ops::{ }; use crate::{ - core::{ - Contexting, - Parse, - Parsed, - Streaming, - Success, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, + Streaming, + Success, }; /// Implementation of [crate::utils::Utils::try_fold_iter] diff --git a/src/utils/try_fold_until.rs b/src/utils/try_fold_until.rs index 0998665..0e3e755 100644 --- a/src/utils/try_fold_until.rs +++ b/src/utils/try_fold_until.rs @@ -4,13 +4,11 @@ use core::ops::{ }; use crate::{ - core::{ - Contexting, - Parse, - Parsed, - Streaming, - }, utils::UtilsAtom, + Contexting, + Parse, + Parsed, + Streaming, }; /// Implementation of [crate::utils::Utils::try_fold_until] diff --git a/src/utils/try_map.rs b/src/utils/try_map.rs index 1837564..4035ba5 100644 --- a/src/utils/try_map.rs +++ b/src/utils/try_map.rs @@ -3,7 +3,7 @@ use core::ops::{ Try, }; -use crate::core::{ +use crate::{ Parse, Parsed, }; diff --git a/src/core/try_push.rs b/src/utils/try_push.rs similarity index 100% rename from src/core/try_push.rs rename to src/utils/try_push.rs