Comparing functions for equality in Rust
问题 I have a function which takes a number as an argument, and then returns a function based on the number. Depending on many different things, it might return any of ~50 functions, and the cases for which one it should return get pretty complicated. As such, I want to build some tests to make sure the proper functions are being returned. What I have so far looks roughly like this. fn pick_a_function(decider: u32) -> fn(&mut SomeStruct) { match decider { 1 => add, 2 => sub, _ => zero, } } fn add