1
0
Fork 0

Use &str instead of String.

This commit is contained in:
Taylor Holliday 2023-02-22 10:14:54 -08:00
parent 2b70a08e14
commit dbda356826
5 changed files with 6 additions and 6 deletions

View file

@ -30,7 +30,7 @@ impl WindowHandler for OpenWindowExample {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
match e { match e {
MouseEvent::ButtonPressed { button, modifiers } => { MouseEvent::ButtonPressed { button, modifiers } => {
copy_to_clipboard("This is a test!".into()) copy_to_clipboard(&"This is a test!")
} }
_ => (), _ => (),
} }

View file

@ -5,6 +5,6 @@ use crate::win as platform;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
use crate::x11 as platform; use crate::x11 as platform;
pub fn copy_to_clipboard(data: String) { pub fn copy_to_clipboard(data: &str) {
platform::copy_to_clipboard(data) platform::copy_to_clipboard(data)
} }

View file

@ -484,11 +484,11 @@ unsafe impl HasRawWindowHandle for Window {
} }
} }
pub fn copy_to_clipboard(string: String) { pub fn copy_to_clipboard(string: &str) {
unsafe { unsafe {
let pb = NSPasteboard::generalPasteboard(nil); 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.clearContents();
pb.setString_forType(ns_str, cocoa::appkit::NSPasteboardTypeString); pb.setString_forType(ns_str, cocoa::appkit::NSPasteboardTypeString);

View file

@ -764,6 +764,6 @@ unsafe impl HasRawWindowHandle for Window<'_> {
} }
} }
pub fn copy_to_clipboard(data: String) { pub fn copy_to_clipboard(data: &str) {
todo!() todo!()
} }

View file

@ -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!() todo!()
} }