Content-Length: 24624 | pFad | https://doc.rust-lang.org/std/string/../error/../string/../cmp/../../error_codes/./E0059.html

E0059 - Error codes index

Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Error code E0059

The built-in function traits are generic over a tuple of the function arguments. If one uses angle-bracket notation (Fn<(T,), Output=U>) instead of parentheses (Fn(T) -> U) to denote the function trait, the type parameter should be a tuple. Otherwise function call notation cannot be used and the trait will not be implemented by closures.

The most likely source of this error is using angle-bracket notation without wrapping the function argument type into a tuple, for example:

#![allow(unused)]
#![feature(unboxed_closures)]

fn main() {
fn foo<F: Fn<i32>>(f: F) -> F::Output { f(3) }
}

It can be fixed by adjusting the trait bound like this:

#![allow(unused)]
#![feature(unboxed_closures)]

fn main() {
fn foo<F: Fn<(i32,)>>(f: F) -> F::Output { f(3) }
}

Note that (T,) always denotes the type of a 1-tuple containing an element of type T. The comma is necessary for syntactic disambiguation.









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://doc.rust-lang.org/std/string/../error/../string/../cmp/../../error_codes/./E0059.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy