You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey there! I needed to return parse result as a boxed closure Fn(usize) -> usize. Like every time before, I used map on a parser for this purpose, in which i pass a closure, that returns boxed closure. But compiler keeps cursing me with
I researched many sources on how to return closures in rust, and what I'm trying to do should theoretically work, but it doesn't.
And what is interesting, if I destruct parser Result myself and then return Ok variant with closure — it works! So I concluded there should be something about map combinator
Prerequisites
Rust version : rustc 1.71.0 (8ede3aae2 2023-07-12)
nom version : 7.1.3
nom compilation features used: only default ones
Adding nom v7.1.3 to dependencies.
Features:
+ alloc
+ std
- docsrs
Test case
It's not actually a unit test, it's just two functions: first function throws compilation error, second passes.
Hey there! I needed to return parse result as a boxed closure Fn(usize) -> usize. Like every time before, I used
map
on a parser for this purpose, in which i pass a closure, that returns boxed closure. But compiler keeps cursing me withI researched many sources on how to return closures in rust, and what I'm trying to do should theoretically work, but it doesn't.
And what is interesting, if I destruct parser Result myself and then return Ok variant with closure — it works! So I concluded there should be something about
map
combinatorPrerequisites
Test case
It's not actually a unit test, it's just two functions: first function throws compilation error, second passes.
Compiler says:
The text was updated successfully, but these errors were encountered: