()
| 1 | fn main() { |
| 2 | let example_closure = |x| x; |
| 3 | |
| 4 | let s = example_closure(String::from("hello")); |
| 5 | let n = example_closure(5); |
| 6 | println!("{} {}", s, n); |
| 7 | |
| 8 | let x = vec![1, 2, 3]; |
| 9 | |
| 10 | let equal_to_x = move |z| z == x; |
| 11 | |
| 12 | println!("this is x {:?}", x); |
| 13 | let y = vec![1, 2, 3]; |
| 14 | assert!(equal_to_x(y)); |
| 15 | |
| 16 | let items: Vec<i32> = vec![1, 2, 3, 4, 5]; |
| 17 | let plus_one: Vec<_> = items.iter().map(|x| x + 1).collect(); |
| 18 | let sum_all: i32 = items.iter().map(|x| x + 1).sum(); |
| 19 | println!("{:?} {}", plus_one, sum_all); |
| 20 | |
| 21 | let two_args = |x, y| x - y; |
| 22 | println!("{}", two_args(5, 3)); |
| 23 | } |
nothing calls this directly
no outgoing calls
no test coverage detected