Content-Length: 23984 | pFad | https://doc.rust-lang.org/std/string/../error/../string/../vec/../../../error_codes/./E0631.html

E0631 - 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 E0631

This error indicates a type mismatch in closure arguments.

Erroneous code example:

fn foo<F: Fn(i32)>(f: F) {
}

fn main() {
    foo(|x: &str| {});
}

The error occurs because foo accepts a closure that takes an i32 argument, but in main, it is passed a closure with a &str argument.

This can be resolved by changing the type annotation or removing it entirely if it can be inferred.

fn foo<F: Fn(i32)>(f: F) {
}

fn main() {
    foo(|x: i32| {});
}








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/../vec/../../../error_codes/./E0631.html

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy