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")]
match e {
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")]
use crate::x11 as platform;
pub fn copy_to_clipboard(data: String) {
pub fn copy_to_clipboard(data: &str) {
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 {
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);

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

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