pub enum CNil {}
Expand description
Phantom type for signature purposes only (has no value)
+pub enum CNil {}
Expand description
Phantom type for signature purposes only (has no value)
Used by the macro to terminate the Coproduct type signature
-Trait Implementations§
§impl CoproductEmbedder<CNil, HNil> for CNil
impl CoproductEmbedder<CNil, HNil> for CNil
§impl<Head, Tail> CoproductEmbedder<Coproduct<Head, Tail>, HNil> for CNil
impl<Head, Tail> CoproductEmbedder<Coproduct<Head, Tail>, HNil> for CNil
§impl<F, R> CoproductFoldable<F, R> for CNil
impl<F, R> CoproductFoldable<F, R> for CNil
This is literally impossible; CNil is not instantiable
-§impl<F> CoproductMappable<F> for CNil
impl<F> CoproductMappable<F> for CNil
Base case map impl.
-§impl Hash for CNil
impl Hash for CNil
Trait Implementations§
source§impl<F, R> CoproductFoldable<F, R> for CNil
impl<F, R> CoproductFoldable<F, R> for CNil
This is literally impossible; CNil is not instantiable
+source§impl<F> CoproductMappable<F> for CNil
impl<F> CoproductMappable<F> for CNil
Base case map impl.
+source§impl Ord for CNil
impl Ord for CNil
source§impl PartialEq for CNil
impl PartialEq for CNil
§impl PartialOrd for CNil
impl PartialOrd for CNil
source§impl PartialOrd for CNil
impl PartialOrd for CNil
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl Copy for CNil
impl Eq for CNil
impl StructuralEq for CNil
impl StructuralPartialEq for CNil
Auto Trait Implementations§
impl RefUnwindSafe for CNil
impl Send for CNil
impl Sync for CNil
impl Unpin for CNil
impl UnwindSafe for CNil
Blanket Implementations§
impl Copy for CNil
impl Eq for CNil
impl StructuralEq for CNil
impl StructuralPartialEq for CNil
Auto Trait Implementations§
impl RefUnwindSafe for CNil
impl Send for CNil
impl Sync for CNil
impl Unpin for CNil
impl UnwindSafe for CNil
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
- T: ?Sized,
impl<T> BorrowMut<T> for Twhere
- T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
pub enum Coproduct<H, T> {
+ pub enum Coproduct<H, T> {
Inl(H),
Inr(T),
}
Variants§
§Inl(H)
Coproduct is either H or T, in this case, it is H
§Inr(T)
Coproduct is either H or T, in this case, it is T
-Implementations§
§impl<Head, Tail> Coproduct<Head, Tail>
Implementations§
source§impl<Head, Tail> Coproduct<Head, Tail>
sourcepub fn inject<T, Index>(to_insert: T) -> Coproduct<Head, Tail>where
Coproduct<Head, Tail>: CoprodInjector<T, Index>,
Instantiate a coproduct from an element.
This is generally much nicer than nested usage of Coproduct::{Inl, Inr}
.
The method uses a trick with type inference to automatically build the correct variant
@@ -54,7 +54,7 @@
Example
// The Index parameter should be left as `_`.
type Vi32Vf32 = Coprod!(Vec<i32>, Vec<f32>);
let _: Vi32Vf32 = Coproduct::inject::<Vec<i32>, _>(vec![]);Run
-sourcepub fn get<S, Index>(&self) -> Option<&S>where
Coproduct<Head, Tail>: CoproductSelector<S, Index>,
sourcepub fn take<T, Index>(self) -> Option<T>where
Coproduct<Head, Tail>: CoproductTaker<T, Index>,
pub fn uninject<T, Index>(
+
sourcepub fn uninject<T, Index>(
self
) -> Result<T, <Coproduct<Head, Tail> as CoprodUninjector<T, Index>>::Remainder>where
Coproduct<Head, Tail>: CoprodUninjector<T, Index>,
-pub fn subset<Targets, Indices>(
+
sourcepub fn subset<Targets, Indices>(
self
) -> Result<Targets, <Coproduct<Head, Tail> as CoproductSubsetter<Targets, Indices>>::Remainder>where
Coproduct<Head, Tail>: CoproductSubsetter<Targets, Indices>,
pub fn subset<Targets, Indices>(
self
) -> Result<Targets, <Coproduct<Head, Tail> as CoproductSubsetter<Targets, Indices>>::Remainder>where
Coproduct<Head, Tail>: CoproductSubsetter<Targets, Indices>,
Extract a subset of the possible types in a coproduct (or get the remaining possibilities)
@@ -222,7 +222,7 @@Example
assert_eq!(handle_all(Coproduct::inject("hello")), "&str hello"); assert_eq!(handle_all(Coproduct::inject(String::from("World!"))), "String World!"); assert_eq!(handle_all(Coproduct::inject(4)), "....");Runpub fn embed<Targets, Indices>(self) -> Targetswhere
+
pub fn embed<Targets, Indices>(self) -> Targetswhere
+
sourcepub fn embed<Targets, Indices>(self) -> Targetswhere
Coproduct<Head, Tail>: CoproductEmbedder<Targets, Indices>,
pub fn embed<Targets, Indices>(self) -> Targetswhere
Coproduct<Head, Tail>: CoproductEmbedder<Targets, Indices>,
Convert a coproduct into another that can hold its variants.
This converts a coproduct into another one which is capable of holding each of its types. The most well-supported use-cases (i.e. those where type inference @@ -258,7 +258,7 @@