Skip to content

Usage of FormatItem::First to attempt parsing with multiple descriptions #476

Closed Answered by jhpratt
johnbcodes asked this question in Question
Discussion options

You must be logged in to vote

It is Time::parse("20:45:31.133", &formats).expect("Parse failed"); that fails. There is a simple explanation for this behavior. The first format description ("[hour]:[minute]:[second]") does match the string, albeit with characters left over (hence the "trailing characters" error). This is due to the way parsing is done: one step parses the item, returning the remaining input, and another step sees the remaining input and returns an error. FormatItem::First only handles the catches errors at the first step. I will look into what it would take to change this — I'm not positive it's doable for the general case.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@johnbcodes
Comment options

@jhpratt
Comment options

@johnbcodes
Comment options

Answer selected by johnbcodes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants