-
Notifications
You must be signed in to change notification settings - Fork 289
fix: remove dangerous unwrap #989
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
base: main
Are you sure you want to change the base?
Conversation
| let mut pixmap = tiny_skia::PixmapMut::from_bytes(pixmap, width, height).unwrap(); | ||
|
|
||
| resvg::render(&tree.0, transform.to_tiny_skia(), &mut pixmap) | ||
| .expect("Failed to render to pixmap"); |
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.
Should we panic or fail quielty?
| size.height() as f32 / tree.size().height() as f32, | ||
| ); | ||
| resvg::render(&tree, render_ts, &mut pixmap.as_mut()); | ||
| resvg::render(&tree, render_ts, &mut pixmap.as_mut()).expect("Failed to render"); |
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.
The best would be to resturn a Option<usize> or a Result<usize, String>
I don't really like to .expect() but I do it now for this MR for no breaking change
Fix #937
Fix #941
This change the API of render() but is still compatible I think
(returns None instead of crashing)
Maybe we could add #[must_use] ?