Comments (6)
I might just go ahead and fork the repo and implement it myself, if I have the time.
from combine.
There is the function then already. I would not be opposed to having both though if you think its useful. Maybe the current function should just be replaced with the one you proposed. Looking through my code the only time I use it I could just as well have then
return a result instead of a parser.
from combine.
There is the function then already.
Yeah, I did see the then
function, but I was not really sure if it could be used for this purpose since it returns a parser.
The use case I have in mind here is parsing some strings that represent numbers, and then turning them into numeric values using from_str()
, which returns a Result
. It would be great if instead of
many1(hex_digit())
.map(|x| char::from_u32(u32::from_str_radix(x, 16).unwrap()).unwrap())
I could just say
many1(hex_digit())
.and_then(|x| u32::from_str_radix(x,16))
.and_then(|x| char::from_u32(x))
This way, I could avoid using unwrap()
, and have the error result from either from_str_radix
or from_u32
carried over as a parse error.
Just my two cents. I know I would definitely find this pattern useful.
from combine.
One problem with your proposed function is that it needs a FromError
implementation for ParseError
. Nothing that isn't solvable but I though I should point it out. As ParseError
is currently it would probably mean converting the error to a string and using Message variant though I would be open for suggestions for a better handling of user created errors.
from combine.
Ah, true, I hadn't thought of that. Well, put this one on the back burner for if/when you have time, I suppose.
from combine.
Closed through #28.
from combine.
Related Issues (20)
- Publishing 4.6.1? HOT 1
- choice! returns an error when one of its parsers would be successful HOT 2
- Throw stream errors HOT 5
- DateTime parser HOT 1
- take_until_bytes() and partial parsing HOT 2
- Is there a way to get `Stream<Token=char>` from `io::Read`? HOT 1
- Tools for debugging recursion problems? HOT 4
- Some issue with error reporting
- Errors include unprintable or awkwardly printed characters. HOT 6
- `expected` error strings always quote what was expected, even if it isn't a literal HOT 3
- How about offset into some data? HOT 3
- Outdated tutorial HOT 1
- Native/abstracted sub-parsers HOT 6
- XML parsing for React.js to Solid.js conversion HOT 4
- Comparison with LALRPOP
- Unbounded mutual recursion in Parser impl HOT 3
- Adivce on reducing code size in WASM target HOT 7
- Docs unclear whether `parser!` should be used on nightly rust HOT 2
- Parse `std::process::Child` stdout
- Successful parser will not clear the error stack HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from combine.