]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_error_codes/src/error_codes/E0057.md
Re-use std::sealed::Sealed in os/linux/process.
[rust.git] / compiler / rustc_error_codes / src / error_codes / E0057.md
1 An invalid number of arguments was given when calling a closure.
2
3 Erroneous code example:
4
5 ```compile_fail,E0057
6 let f = |x| x * 3;
7 let a = f();        // invalid, too few parameters
8 let b = f(4);       // this works!
9 let c = f(2, 3);    // invalid, too many parameters
10 ```
11
12 When invoking closures or other implementations of the function traits `Fn`,
13 `FnMut` or `FnOnce` using call notation, the number of parameters passed to the
14 function must match its definition.
15
16 A generic function must be treated similarly:
17
18 ```
19 fn foo<F: Fn()>(f: F) {
20     f(); // this is valid, but f(3) would not work
21 }
22 ```