I'm trying to pass a callback into a method so my struct can use it later, but I'm getting expected closure, found a different closure
with the following code:
struct Struct<T>
where T: Fn(&[u8])
{
func: T
}
impl<T> Struct<T>
where T: Fn(&[u8])
{
fn set_callback(&mut self, callback: T) {
self.func = callback;
}
}
fn main() {
println!("Hello, world!");
// this works
let mut s = Struct {
func: |msg| {}
};
// this doesn't
s.set_callback(|msg| {});
}