Skip to content

Commit

Permalink
Remove unneeded Result from image_from_pixels
Browse files Browse the repository at this point in the history
  • Loading branch information
complexspaces committed Feb 13, 2025
1 parent 108cc38 commit c474298
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/platform/osx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn image_from_pixels(
pixels: Vec<u8>,
width: usize,
height: usize,
) -> Result<Retained<objc2_app_kit::NSImage>, Box<dyn std::error::Error>> {
) -> Retained<objc2_app_kit::NSImage> {
use objc2::AllocAnyThread;
use objc2_app_kit::NSImage;
use objc2_core_foundation::CGFloat;
Expand Down Expand Up @@ -84,9 +84,7 @@ fn image_from_pixels(
.unwrap();

let size = NSSize { width: width as CGFloat, height: height as CGFloat };
let image = unsafe { NSImage::initWithCGImage_size(NSImage::alloc(), &cg_image, size) };

Ok(image)
unsafe { NSImage::initWithCGImage_size(NSImage::alloc(), &cg_image, size) }
}

pub(crate) struct Clipboard {
Expand Down Expand Up @@ -305,8 +303,7 @@ impl<'clipboard> Set<'clipboard> {
#[cfg(feature = "image-data")]
pub(crate) fn image(self, data: ImageData) -> Result<(), Error> {
let pixels = data.bytes.into();
let image = image_from_pixels(pixels, data.width, data.height)
.map_err(|_| Error::ConversionFailure)?;
let image = image_from_pixels(pixels, data.width, data.height);

self.clipboard.clear();

Expand Down

0 comments on commit c474298

Please sign in to comment.