I'm currently trying to implement a simple Parser-Combinator library in Rust. For this, I would like to have a generic map function to convert the result of the analyzer.
The problem is that I do not know how to copy a structure with a closure. An example is the map structure in the following example. It has a mapFunction field that stores a function that receives the result of the previous analyzer and returns a new result. map itself is a parser that can be further combined with other parsers.
However, for parsers that need to be combined, I would need to copy them (having a binding to Clone ), but how to do this for map ?
Example: (Only pseudo code will most likely not compile)
trait Parser<A> {
akuendig
source share