Namable-closures 0.2.1


#1

Hi all,

I have just published namable closures 0.2.1.

Compare to the last version, the updates are

  • Uses a single macro rather than 6 in the previous version
  • Matched the struct names with the macro grammar
  • Have some mirrored StableFn traits for stable build. Although, without the nightly Fn traits the usage will be ugly

In the last discussion of this crate, several requests and issues have been received and raised:

  • Make the macro grammar nicer. This is addressed in this release. More advises on the grammar are highly appreciated.
  • Recursion support. Will be addressed soon, maybe the next release.
  • Support for generic lifetime, making supporting Iterator::filter possible. This is the hardest part, and the current types is not able to support this. For individual fn types, this can be done case by case, but to make it generic there will be a long way to go. I am not sure whether this can be done at all, but at lease I will try to add some special case support for this.

What’s Next?

  • Make the “stable” grammar nicer as well, by some more macros. This would include some macros to build native closures on top of the Closure structs.
  • Add new types that supports recursion. Proberly something like ClosureRec, ClosureOnceRec etc.

Feedback

The repository is there for raising issues, advises and feature requests.

Issue on rustdoc

I tried the following markdown

| Macro Grammar | Struct | |-----------------------------------------------------------|--------------| |`closure!(state=ref_exp => |x,y| body(x,y,state))` | Closure | |`closure!(state=exp => move |x,y| body(x,y,state))` | ClosureOnce | |`closure!(mut state=ref_exp => |x,y| body(x,y,state))` | ClosureMut | |`closure!(mut state=exp => move |x,y| body(x,y,state))` | ClosureOnce | |`closure!(ref state=exp => move |x,y| body(x,y,state))` | ClosureRef | |`closure!(ref mut state=exp => move |x,y| body(x,y,state))`| ClosureRefMut|

in the README.md and documents, although github shows it properly, rustdoc does not. This is evident in a previous version 0.2.0 - you can see the table was broken. The workaround is to use embedded HTML tables.

It should look like

Macro Grammar Struct
closure!(state=ref_exp => |x,y| body(x,y,state)) Closure
closure!(state=exp => move |x,y| body(x,y,state)) ClosureOnce
closure!(mut state=ref_exp => |x,y| body(x,y,state)) ClosureMut
closure!(mut state=exp => move |x,y| body(x,y,state)) ClosureOnce
closure!(ref state=exp => move |x,y| body(x,y,state)) ClosureRef
closure!(ref mut state=exp => move |x,y| body(x,y,state)) ClosureRefMut

Is this a known bug or should I raise an issue for the doc team?