Skip to content

Commit

Permalink
Remove incorrect section from example
Browse files Browse the repository at this point in the history
Closures no longer need to be `'static` as we now track the
lifetime of the wrapped function
  • Loading branch information
MrGVSV committed Jun 29, 2024
1 parent b8ed0a8 commit ba72789
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions examples/reflection/function_reflection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ fn main() {
dbg!(increment_function.call_once(args).unwrap());
assert_eq!(count, 5);

// All closures must be `'static`— that is, they take full ownership of any captured variables.
let add_closure = |left: i32, right: i32| -> i32 { left + right };
let mut count_function = dbg!(add_closure.into_function());
let args = dbg!(ArgList::new().push_owned(2_i32).push_owned(2_i32));
let value = dbg!(count_function.call(args).unwrap()).unwrap_owned();
assert_eq!(value.take::<i32>().unwrap(), 4);

// As stated before, this works for many kinds of simple functions.
// Functions with non-reflectable arguments or return values may not be able to be converted.
// Generic functions are also not supported.
Expand Down

0 comments on commit ba72789

Please sign in to comment.