let canvas = canvas_option.take().unwrap_or_else( || Canvas::new(dim_x, dim_y) );
if (dim_x, dim_y) == canvas.img.dimensions() {
let canvas = rgb_encode_to_canvas(canvas, percent_decode_str(&data).into_iter().borrow_mut())?;
- canvas_option.insert(canvas).img.clone()
+ Ok(canvas_option.insert(canvas).img.clone())
}
else {
- canvas_option.insert(canvas);
- drop(canvas_option);
- return Err(CanvasError::DimensionMismatch)?
+ _ = canvas_option.insert(canvas);
+ Err(CanvasError::DimensionMismatch)
}
- };
+ }?;
let (tdim_x, tdim_y) = img.dimensions();
let (tdim_x, tdim_y) = (tdim_x * scale, tdim_y * scale);
let img = resize(&img, tdim_x, tdim_y, FilterType::Nearest);