Advertisement
cwchen

[Rust] function as value

Aug 23rd, 2017
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.13 KB | None | 0 0
  1. fn add_one(x: i32) -> i32 {
  2.     return x + 1;
  3. }
  4.  
  5. fn main() {
  6.     let f: fn(i32) -> i32 = add_one;
  7.     assert_eq!(f(5), 6);
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement