Skip to content

Recursive minor improvements #942

@wkordalski

Description

@wkordalski

First of all, I would like to thank the authors of this crate.

I'm using it to parse programs written in my own programming language.
My parser utilizes Recursive::declare/define and the caching pattern (but with thread-locally stored parsers as Recursive is not Send nor Sync).

  1. The first thing is missing documentation about cloning behavior of Recursive. Especially that one can safely clone the result of Recursive::declare and then call Recursive::define on one of the clones (because Rc<_> is used internally). I think this is an important information for the crate users. Or am I wrong about this?

  2. The second thing is that Recursive::define takes &mut self. It is not necessary and counter-intuitive as the common case is "declare, then use it, and finally define". In my parser I ended up with code like:

    fn define_expr(parser: &Recursive<...>, cache: &ParserCache) {
        let mut parser = parser.clone();
        parser.define(...);
    }

I can write appropriate PR if the ideas get accepted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions