#![feature(auto_traits, negative_impls)]
pub mod byte_size;
pub mod one_or_many;
pub mod zero_one_or_many;
pub mod array_tuple_ext;
pub use byte_size::{ByteSize, ByteSizeExt};
pub use one_or_many::OneOrMany;
pub use zero_one_or_many::ZeroOneOrMany;
#[cfg(feature = "array-tuples")]
pub use array_tuple_ext::{
ArrayTupleObjectExtKString, ArrayTupleObjectExtKV, ArrayTupleObjectExtStringString,
ArrayTupleObjectExtStringV, CollectionArrayTupleExtKString, CollectionArrayTupleExtKV,
CollectionArrayTupleExtStringString, CollectionArrayTupleExtStringV,
TryCollectionArrayTupleExtKString, TryCollectionArrayTupleExtKV,
TryCollectionArrayTupleExtStringString, TryCollectionArrayTupleExtStringV,
};
#[cfg(feature = "array-tuples")]
#[macro_export]
macro_rules! hash_map {
[ $($key:expr, $value:expr),* $(,)? ] => {
|| {
let mut map = ::hashbrown::HashMap::new();
$(
map.insert($key, $value);
)*
map
}
};
}
#[cfg(feature = "array-tuples")]
#[macro_export]
macro_rules! array_tuple_closure {
( $($input:tt)* ) => {
array_tuple_closure_internal! { $($input)* }
};
}
#[cfg(feature = "array-tuples")]
#[macro_export]
macro_rules! array_tuple_closure_internal {
( $($tokens:tt)* ) => {
array_tuple_closure_replace! { $($tokens)* }
};
}
#[cfg(feature = "array-tuples")]
#[macro_export]
macro_rules! array_tuple_closure_replace {
() => {};
( $($prefix:tt)* [ $($inner:tt)+ ] $($suffix:tt)* ) => {
array_tuple_closure_replace_inner! {
prefix: [ $($prefix)* ]
block: [ $($inner)+ ]
suffix: [ $($suffix)* ]
}
};
( $($tokens:tt)* ) => {
$($tokens)*
};
}
#[cfg(feature = "array-tuples")]
#[macro_export]
macro_rules! array_tuple_closure_replace_inner {
( prefix: [ $($prefix:tt)* ] block: [ $($inner:tt)+ ] suffix: [ $($suffix:tt)* ] ) => {
array_tuple_closure_check_tuples! {
prefix: [ $($prefix)* ]
inner: [ $($inner)+ ]
suffix: [ $($suffix)* ]
}
};
}
#[cfg(feature = "array-tuples")]
#[macro_export]
macro_rules! array_tuple_closure_check_tuples {
( prefix: [ $($prefix:tt)* ] inner: [ $($inner:tt)+ ] suffix: [ $($suffix:tt)* ] ) => {
array_tuple_closure_tuple_check! {
prefix: [ $($prefix)* ]
inner: [ $($inner)+ ]
suffix: [ $($suffix)* ]
}
};
}
#[cfg(feature = "array-tuples")]
#[macro_export]
macro_rules! array_tuple_closure_tuple_check {
( prefix: [ $($prefix:tt)* ] inner: [ $($pre:tt)* ( $($tuple:tt)* ) $($post:tt)* ] suffix: [ $($suffix:tt)* ] ) => {
array_tuple_closure_replace! { $($prefix)* sugars_macros::hash_map_fn! [ $($pre)* ( $($tuple)* ) $($post)* ] $($suffix)* }
};
( prefix: [ $($prefix:tt)* ] inner: [ $($inner:tt)+ ] suffix: [ $($suffix:tt)* ] ) => {
array_tuple_closure_replace! { $($prefix)* [ $($inner)+ ] $($suffix)* }
};
}