MCPcopy Create free account
hub / github.com/derekbanas/Rust-Tutorial / use_func

Function use_func

main.rs:861–863  ·  view source on GitHub ↗

You can pass closures to functions

(a: i32, b: i32, func: T)

Source from the content-addressed store, hash-verified

859
860 // You can pass closures to functions
861 fn use_func<T>(a: i32, b: i32, func: T) -> i32 where T: Fn(i32, i32) -> i32 {
862 func(a, b)
863 }
864
865 let sum = |a, b| a + b;
866 let prod = |a, b| a * b;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected