Skip to content

Commit

Permalink
fix fmt errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Gae24 committed Oct 17, 2024
1 parent 326ede7 commit 87c5290
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/set_get_html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ consectetur adipiscing elit."#;

ctx.set_html(html, Some(alt_text)).unwrap();
thread::sleep(Duration::from_secs(5));

let success = ctx.get().html().unwrap() == html;
println!("Set and Get html operations were successful: {success}");
}
2 changes: 1 addition & 1 deletion src/platform/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ impl<'clipboard> Get<'clipboard> {
Clipboard::X11(clipboard) => clipboard.get_html(self.selection),
#[cfg(feature = "wayland-data-control")]
Clipboard::WlDataControl(clipboard) => clipboard.get_html(self.selection),
}
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/platform/linux/wayland.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,11 @@ impl Clipboard {
Ok(Self {})
}

fn string_for_mime(&mut self, selection: LinuxClipboardKind, mime: paste::MimeType) -> Result<String, Error> {
fn string_for_mime(
&mut self,
selection: LinuxClipboardKind,
mime: paste::MimeType,
) -> Result<String, Error> {
let result = get_contents(selection.try_into()?, Seat::Unspecified, mime);
match result {
Ok((mut pipe, _)) => {
Expand Down
13 changes: 5 additions & 8 deletions src/platform/osx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,19 @@ impl Clipboard {
unsafe { self.pasteboard.clearContents() };
}

fn string_from_type(&self, type: &'static NSString) -> Result<String, Error> {
fn string_from_type(&self, type_: &'static NSString) -> Result<String, Error> {
// XXX: There does not appear to be an alternative for obtaining text without the need for
// autorelease behavior.
autoreleasepool(|_| {
// XXX: We explicitly use `pasteboardItems` and not `stringForType` since the latter will concat
// multiple strings, if present, into one and return it instead of reading just the first which is `arboard`'s
// historical behavior.
let contents =
unsafe { self.pasteboard.pasteboardItems() }.ok_or_else(|| {
Error::Unknown {
description: String::from("NSPasteboard#pasteboardItems errored"),
}
})?;
let contents = unsafe { self.pasteboard.pasteboardItems() }.ok_or_else(|| {
Error::Unknown { description: String::from("NSPasteboard#pasteboardItems errored") }
})?;

for item in contents {
if let Some(string) = unsafe { item.stringForType(type) } {
if let Some(string) = unsafe { item.stringForType(type_) } {
return Ok(string.to_string());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/platform/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ impl<'clipboard> Get<'clipboard> {
.ok_or_else(|| Error::unknown("unable to register HTML format"))?;
let mut out: Vec<u8> = Vec::new();
clipboard_win::raw::get_html(format.get(), &mut out)
.map_err(|_| Error::unknown("failed to read clipboard string"))?;
.map_err(|_| Error::unknown("failed to read clipboard string"))?;
String::from_utf8(out).map_err(|_| Error::ConversionFailure)
}

Expand Down

0 comments on commit 87c5290

Please sign in to comment.