Skip to content

Conversation

@Its-Just-Nans
Copy link
Contributor

@Its-Just-Nans Its-Just-Nans commented Dec 14, 2025

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] ?

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");
Copy link
Contributor Author

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");
Copy link
Contributor Author

@Its-Just-Nans Its-Just-Nans Dec 14, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Panic called Option::unwrap() on a None value in crates/resvg/src/lib.rs Panic attempt to multiply with overflow in crates/resvg/src/lib.rs

1 participant