Re:Parse, Don't Validate (2019)
by tialaramex on Tuesday March 07, 2023 @01:20PM
(#35058974)
And parse-don't-validate is often very nice to work with in Rust, I can describe how to turn some UTF-8 text into my type Foo in a function:
And then whenever I've got a string which I know ought to be a Foo, I can:
Since we said foo is a Foo, by inference the parsing of string needs to either succeed with a Foo, or fail while trying, so it calls that FromStr implementation we wrote earlier to achieve that.
[ Parent
| on HN ]
There are no comments on this comment yet.