diff --git a/examples/open_window.rs b/examples/open_window.rs index ae5a421..0d285ae 100644 --- a/examples/open_window.rs +++ b/examples/open_window.rs @@ -30,7 +30,7 @@ impl WindowHandler for OpenWindowExample { #[cfg(target_os = "macos")] match e { MouseEvent::ButtonPressed { button, modifiers } => { - copy_to_clipboard("This is a test!".into()) + copy_to_clipboard(&"This is a test!") } _ => (), } diff --git a/src/clipboard.rs b/src/clipboard.rs index 05ed9e2..c4f7bc4 100644 --- a/src/clipboard.rs +++ b/src/clipboard.rs @@ -5,6 +5,6 @@ use crate::win as platform; #[cfg(target_os = "linux")] use crate::x11 as platform; -pub fn copy_to_clipboard(data: String) { +pub fn copy_to_clipboard(data: &str) { platform::copy_to_clipboard(data) } diff --git a/src/macos/window.rs b/src/macos/window.rs index 731e45e..54046dd 100644 --- a/src/macos/window.rs +++ b/src/macos/window.rs @@ -484,11 +484,11 @@ unsafe impl HasRawWindowHandle for Window { } } -pub fn copy_to_clipboard(string: String) { +pub fn copy_to_clipboard(string: &str) { unsafe { let pb = NSPasteboard::generalPasteboard(nil); - let ns_str = NSString::alloc(nil).init_str(&string); + let ns_str = NSString::alloc(nil).init_str(string); pb.clearContents(); pb.setString_forType(ns_str, cocoa::appkit::NSPasteboardTypeString); diff --git a/src/win/window.rs b/src/win/window.rs index f725d58..2af1abe 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -764,6 +764,6 @@ unsafe impl HasRawWindowHandle for Window<'_> { } } -pub fn copy_to_clipboard(data: String) { +pub fn copy_to_clipboard(data: &str) { todo!() } diff --git a/src/x11/window.rs b/src/x11/window.rs index d45cbbf..fcd9083 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -705,6 +705,6 @@ fn mouse_id(id: u8) -> MouseButton { } } -pub fn copy_to_clipboard(data: String) { +pub fn copy_to_clipboard(data: &str) { todo!() }