Use &str instead of String.
This commit is contained in:
parent
2b70a08e14
commit
dbda356826
|
@ -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!")
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -764,6 +764,6 @@ unsafe impl HasRawWindowHandle for Window<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn copy_to_clipboard(data: String) {
|
||||
pub fn copy_to_clipboard(data: &str) {
|
||||
todo!()
|
||||
}
|
||||
|
|
|
@ -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!()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue