#![warn(unsafe_code)]
#![warn(missing_copy_implementations)]
#![warn(missing_debug_implementations)]
#![feature(generators, generator_trait)]
#![feature(type_ascription)]
#![feature(marker_trait_attr)]
pub mod generator;
pub mod shared;
pub mod singleton;
pub mod cartesian;
pub use enso_shapely_macros::*;
pub use generator::GeneratingIterator;
#[macro_export]
macro_rules! replace {
($a:tt,$($b:tt)*) => {$($b)*}
}
#[macro_export]
macro_rules! newtype_prim_no_derives {
($( $(#$meta:tt)* $name:ident($type:ty); )*) => {$(
$(#$meta)*
pub struct $name {
raw:$type
}
impl $name {
/// Constructor.
pub const fn new(raw:$type) -> Self {
Self {raw}
}
}
impl Deref for $name {
type Target = $type;
fn deref(&self) -> &Self::Target {
&self.raw
}
}
impl DerefMut for $name {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.raw
}
}
impl From<$type> for $name { fn from(t:$type) -> Self { Self::new(t) } }
impl From<&$type> for $name { fn from(t:&$type) -> Self { Self::new(*t) } }
impl From<&&$type> for $name { fn from(t:&&$type) -> Self { Self::new(**t) } }
impl From<$name> for $type { fn from(t:$name) -> Self { t.raw } }
impl From<&$name> for $type { fn from(t:&$name) -> Self { t.raw } }
impl From<&&$name> for $type { fn from(t:&&$name) -> Self { t.raw } }
)*}
}
#[macro_export]
macro_rules! newtype_prim {
($( $(#$meta:tt)* $name:ident($type:ty); )*) => {
$crate::newtype_prim_no_derives! {
$(
$(#$meta)*
#[derive(Copy,Clone,CloneRef,Debug,Default,Display,Eq,Hash,Ord,PartialOrd,PartialEq)]
$name($type);
)*
}
}
}
#[macro_export]
macro_rules! newtype_prim_no_default {
($( $(#$meta:tt)* $name:ident($type:ty); )*) => {
$crate::newtype_prim_no_derives! {
$(
$(#$meta)*
#[derive(Copy,Clone,CloneRef,Debug,Display,Eq,Hash,Ord,PartialOrd,PartialEq)]
$name($type);
)*
}
}
}
#[macro_export]
macro_rules! newtype_prim_no_default_no_display {
($( $(#$meta:tt)* $name:ident($type:ty); )*) => {
$crate::newtype_prim_no_derives! {
$(
$(#$meta)*
#[derive(Copy,Clone,CloneRef,Debug,Eq,Hash,Ord,PartialOrd,PartialEq)]
$name($type);
)*
}
}
}
#[macro_export]
macro_rules! derive_clone_plus {
($name:ident) => {
impl<T:Clone+Into<$name>> From<&T> for $name {
fn from(t: &T) -> Self {
t.clone().into()
}
}
}
}