Skip to main content

RCurry

Trait RCurry 

Source
pub trait RCurry<C>: Sized {
    type Output;

    // Required method
    fn rcurry_once(self, arg: C) -> Self::Output;

    // Provided methods
    fn rcurry_mut(&mut self, arg: C) -> <&mut Self as RCurry<C>>::Output { ... }
    fn rcurry(&self, arg: C) -> <&Self as RCurry<C>>::Output { ... }
}
Expand description

A trait providing the method for currying from the right.

Only types that implement FnOnce and can take a rightmost argument of type C can be called once curried.

§Examples

use currying::*;
 
let f = |x, y, z| x + y + z;
let (x, y, z) = (1, 2, 3);
 
let fz = f.rcurry(z);
 
assert_eq!(fz(x, y), f(x, y, z));
 
let fyz = fz.rcurry(y);
 
assert_eq!(fyz(x), f(x, y, z));
 
let fxyz = fyz.rcurry(x);
 
assert_eq!(fxyz(), f(x, y, z));

Required Associated Types§

Required Methods§

Source

fn rcurry_once(self, arg: C) -> Self::Output

Provided Methods§

Source

fn rcurry_mut(&mut self, arg: C) -> <&mut Self as RCurry<C>>::Output

Source

fn rcurry(&self, arg: C) -> <&Self as RCurry<C>>::Output

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<C, F> RCurry<C> for F