Calling closures in a Vec
In rust one might want to have a list of closures, for example as a list of callbacks.
let mut fs: |> = Vec new;
fs.push;
for f in fs.iter ;
Maybe if we borrow f?
for &f in fs.iter ;
But then if we dereference f?
for f in fs.iter ;
That’s not very helpful. Thanks to some friendly guys over at #rust
at irc.mozilla.org
I found something which works:
for f in fs.mut_iter ;
A note is that the closure types must be &mut ||
and not &||
.
In the end I think that the error messages could be more clear. But now we have a running example and all is well in the world!
// Print "imma firing my lazer"