Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

armanriazi•rust•error•E0308•mismatched types

 Note that we haven’t added any type annotations to the definition: 
 if we then try to call the closure twice, using a String as an argument the first time and a u32 the second time, we’ll get an error.
```
fn main() {
    let example_closure = |x| x;

    let s = example_closure(String::from("hello"));
    let n = example_closure(5);
}
```
 
PREVIOUS NEXT
Tagged: #types
ADD COMMENT
Topic
Name
8+7 =