/// 运算代送
pub mod iter;
/// 随机集合
pub mod random;
cfg_base64! {
  /// base64
  pub mod base64;
}

/// # Random 工具宏
///
/// # Exmaple `Nanoid`
/// ```no_run
/// fn main() {
///     use e_utils::algorithm;
///     println!("nanoid -> {}", algorithm!(nanoid));
///     println!("nanoid 16bytes -> {}", algorithm!(nanoid 16));
///     println!("nanoid 16bytes -> {}", algorithm!(nanoid 16));
///     println!("nanoid 10bytes [alphabet:expr] -> {}", algorithm!(nanoid 16, &['1', 'b', 'c', '7']));
///     println!("nanoid unsafe 10bytes -> {}", algorithm!(nanoid unsafe 10));
///     println!("nanoid unsafe 10bytes [alphabet:expr]-> {}", algorithm!(nanoid unsafe 10, &['1','0']));
/// }
/// ```
///
/// # Exmaple `random`
/// ```no_run
/// fn main() {
///    use e_utils::algorithm;
///    println!("random bool -> {}", algorithm!());
///    println!("random type -> {}", algorithm!(#u32));
///    println!("random type[] -> {:?}", algorithm!([u32; 10]));
///    println!("random range 0-13 -> {}", algorithm!(13));
///    println!("random range -> {}", algorithm!(0i32..13));
///    println!("random rgb range -> {:?}", algorithm!(rgb 100,255));
/// }
/// ```
#[macro_export]
#[cfg(feature = "algorithm")]
#[doc(hidden)]
macro_rules! algorithm {
  () => {
    $crate::algorithm::random::Rand::Safe.random_bool()
  };
  (#$t:ty) => {
    $crate::algorithm::random::Rand::Safe.random_type::<$t>()
  };
  ([$t:ty; $size:expr]) => {
    $crate::algorithm::random::Rand::Safe.random_type::<[$t; $size]>()
  };
  (rgb $min:tt, $max:tt) => {
    $crate::algorithm::random::Rand::Safe.rgb_range($min, $max)
  };
  (nanoid) => {
    $crate::algorithm::random::Rand::Safe.nanoid_format(&$crate::algorithm::random::NID_SAFE, 21)
  };
  // generate
  (nanoid $size:tt) => {
    $crate::algorithm::random::Rand::Safe.nanoid_format(&$crate::algorithm::random::NID_SAFE, $size)
  };
  // custom
  (nanoid $size:tt, $alphabet:expr) => {
    $crate::algorithm::random::Rand::Safe.nanoid_format($alphabet, $size)
  };
  // unsafe
  (nanoid unsafe $size:tt) => {
    $crate::algorithm::random::Rand::UnSafe.nanoid_format(&$crate::algorithm::random::NID_SAFE, $size)
  };
  // unsafe custom
  (nanoid unsafe $size:tt, $alphabet:expr) => {
    $crate::algorithm::random::Rand::UnSafe.nanoid_format($alphabet, $size)
  };
  // UUID 获取
  (uuid_v4 $size:tt, $alphabet:expr) => {
    $crate::algorithm::random::Rand::UnSafe.nanoid_format($alphabet, $size)
  };
  ($size:tt) => {
    $crate::algorithm::random::Rand::Safe.random_range(0..$size)
  };
  ($min:tt..$max:tt) => {
    $crate::algorithm::random::Rand::Safe.random_range($min..$max)
  };
}
