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
Does this make sense? I tried implementing it, I'm not sure what to do with name though. Would letting the variant name fill in for name be acceptable?
The text was updated successfully, but these errors were encountered:
Hey, I'm curious to hear more about what you mean here.
Are you referring to something along the lines of "the last variant is parsed if all else fails, therefore no peeking is required"? Or something more like "the last variant is empty, so it cannot fail"
In the first case, if parsing fails we still need a user-supplied value of name to construct an error message (admittedly, the documentation around the actual error messages produced is a bit lacking). I'm not sure what the best solution for the second case might be -- there's a handful of mediocre ones. My current working solution to the second case tends to look like this:
#[derive(Parse)]enumFoo{/* Other variants... */#[peek_with(|_| true, name = "<this message should never appear>")]NoneOfTheAbove,}
My use case is the first case (parse the last variant if all the #[peek(..)]s fail). I realized that I could use #[peek_with(|_| true, ...)] to achieve the effect I was looking for for that case too.
If you still think my suggestion is a good idea, I can open a PR.
Does this make sense? I tried implementing it, I'm not sure what to do with
name
though. Would letting the variant name fill in forname
be acceptable?The text was updated successfully, but these errors were encountered: