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
I want to parse values, that are have the type in front of them.
Result value of parser - enum:
enum Val {
U8(u8),
U16(u16),
Str(String),
Arr(ValType, Vec),
}
u8 1
[u8] [1, 2, 3, 4]
[str] ["a", "b", "c"]
[u8] [1, "a"] <- Fail
Basically I want to parse the type and then make a decision which parser to use.
According to the docs I should use ignore_with_ctx() method with a custom() parser, but when I call .parse() on InputRef it passes the context(Extra) to the underlying parser, which doesn't know what to do with it. type_parser().ignore_with_ctx(custom(|r| r.parse(parser_with_type(<extract type from ctx>)))
parser_with_type returns regular parser with Extra = Default.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I want to parse values, that are have the type in front of them.
Result value of parser - enum:
enum Val {
U8(u8),
U16(u16),
Str(String),
Arr(ValType, Vec),
}
u8 1
[u8] [1, 2, 3, 4]
[str] ["a", "b", "c"]
[u8] [1, "a"] <- Fail
Basically I want to parse the type and then make a decision which parser to use.
According to the docs I should use ignore_with_ctx() method with a custom() parser, but when I call .parse() on InputRef it passes the context(Extra) to the underlying parser, which doesn't know what to do with it.
type_parser().ignore_with_ctx(custom(|r| r.parse(parser_with_type(<extract type from ctx>)))parser_with_type returns regular parser with Extra = Default.
How can I fix this?
Beta Was this translation helpful? Give feedback.
All reactions