Logo

Programming-Idioms

History of Idiom 37 > diff from v24 to v25

Edit summary for version 25 by Miquel:
New Rust implementation by user [Miquel]

Version 24

2018-01-23, 14:43:16

Version 25

2018-01-28, 08:21:20

Idiom #37 Currying

Transform a function that takes multiple arguments into a function for which some of the arguments are preset.

Idiom #37 Currying

Transform a function that takes multiple arguments into a function for which some of the arguments are preset.

Extra Keywords
curry
Extra Keywords
curry
Code
fn add(a: u32, b: u32) -> u32 {
    a + b
}
fn main() {
    let add5 = move |x| add(5, x);
    println!("{}", add5(2));
}
Doc URL
https://doc.rust-lang.org/book/first-edition/closures.html