-
Notifications
You must be signed in to change notification settings - Fork 17
Remove (or annotate) unwrap() from fontdrasil #1880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
818bbc3 to
ee99af4
Compare
ee99af4 to
e7d7b3c
Compare
cmyr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good simon, thanks for taking this on!
| if let Some(weight) = weights.last() { | ||
| trace!(" {} {:?}", loc_idx, weight); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alternatively we could just remove the unwrap, and we will debug-print the Option.
| assert!( | ||
| minmax.contains_key(tag), | ||
| "axis_order contained axes not in locations" | ||
| ); | ||
| #[allow(clippy::unwrap_used)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
totally not necessary to change but: this could also be expressed a bit more concisely by just using expect in place of unwrap below, with the same text as your assertion here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, but I see a philosophical difference. I want to ban expects because they're just unwraps with an error message. I know the actual outcome is the same, but assert affirmatively signals that we're testing an internal invariant ("In a mad world this might fail, let's make sure and bug out if it does"), while .unwrap/.expect is "I am positively sure this won't fail".
Co-authored-by: Colin Rofls <colin@cmyr.net>
b408c36 to
348c336
Compare
This PR bans
unwrap,expectand indexing slicing (i.e. panicable operations) from fontdrasil.unwrap()is replaced either with aok_oror explained with an annotation.This does change the API somewhat; creating coordinate convertors, and converting coordinates, returns a
Result.There is also an unrelated change to the version of
vergen-gitclused by fontc. Without this, we were usingvergen-gitcl1.0 which pulled invergen v9.1.0, which had a very different API to the onevergen-gitclexpected. So I couldn't get things to compile without it.Fixes #1879