Skip to content

Commit 24c1b67

Browse files
committed
track_caller on panicking constructors
1 parent ffe49dc commit 24c1b67

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/common.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ impl Frame<'static> {
189189
/// # Panics:
190190
/// * If the length of pixels does not equal `width * height * 4`.
191191
#[cfg(feature = "color_quant")]
192+
#[track_caller]
192193
pub fn from_rgba(width: u16, height: u16, pixels: &mut [u8]) -> Self {
193194
Frame::from_rgba_speed(width, height, pixels, 1)
194195
}
@@ -208,6 +209,7 @@ impl Frame<'static> {
208209
/// * If the length of pixels does not equal `width * height * 4`.
209210
/// * If `speed < 1` or `speed > 30`
210211
#[cfg(feature = "color_quant")]
212+
#[track_caller]
211213
pub fn from_rgba_speed(width: u16, height: u16, pixels: &mut [u8], speed: i32) -> Self {
212214
assert_eq!(width as usize * height as usize * 4, pixels.len(), "Too much or too little pixel data for the given width and height to create a GIF Frame");
213215
assert!(speed >= 1 && speed <= 30, "speed needs to be in the range [1, 30]");
@@ -263,6 +265,7 @@ impl Frame<'static> {
263265
/// # Panics:
264266
/// * If the length of pixels does not equal `width * height`.
265267
/// * If the length of palette > `256 * 3`.
268+
#[track_caller]
266269
pub fn from_palette_pixels(width: u16, height: u16, pixels: impl Into<Vec<u8>>, palette: impl Into<Vec<u8>>, transparent: Option<u8>) -> Self {
267270
let pixels = pixels.into();
268271
let palette = palette.into();
@@ -283,6 +286,7 @@ impl Frame<'static> {
283286
///
284287
/// # Panics:
285288
/// * If the length of pixels does not equal `width * height`.
289+
#[track_caller]
286290
pub fn from_indexed_pixels(width: u16, height: u16, pixels: impl Into<Vec<u8>>, transparent: Option<u8>) -> Self {
287291
let pixels = pixels.into();
288292
assert_eq!(width as usize * height as usize, pixels.len(), "Too many or too little pixels for the given width and height to create a GIF Frame");
@@ -309,6 +313,7 @@ impl Frame<'static> {
309313
/// * If the length of pixels does not equal `width * height * 3`.
310314
#[cfg(feature = "color_quant")]
311315
#[must_use]
316+
#[track_caller]
312317
pub fn from_rgb(width: u16, height: u16, pixels: &[u8]) -> Self {
313318
Frame::from_rgb_speed(width, height, pixels, 1)
314319
}
@@ -329,6 +334,7 @@ impl Frame<'static> {
329334
/// * If `speed < 1` or `speed > 30`
330335
#[cfg(feature = "color_quant")]
331336
#[must_use]
337+
#[track_caller]
332338
pub fn from_rgb_speed(width: u16, height: u16, pixels: &[u8], speed: i32) -> Self {
333339
assert_eq!(width as usize * height as usize * 3, pixels.len(), "Too much or too little pixel data for the given width and height to create a GIF Frame");
334340
let mut vec: Vec<u8> = Vec::new();

0 commit comments

Comments
 (0)