MCPcopy Create free account
hub / github.com/IntegralPilot/rustc_codegen_jvm / main

Function main

tests/binary/closures/src/main.rs:1–18  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1fn main() {
2 // A simple closure that adds two numbers
3 let add = |a: i32, b: i32| a + b;
4 assert!(add(3, 4) == 7);
5 assert!(add(-1, 1) == 0);
6 assert!(add(0, 0) == 0);
7 assert!(add(5, 5) == 10);
8 assert!(add(10, 20) == 30);
9 assert!(add(-5, -5) == -10);
10 assert!(add(-3, 2) == -1);
11 assert!(add(-2, 3) == 1);
12
13 // A capturing closure
14 let offset = 11;
15 let add_offset = |value: i32| value + offset;
16 assert!(add_offset(0) == 11);
17 assert!(add_offset(31) == 42);
18}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected