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")]
|
#[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!")
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
|
@ -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!()
|
||||||
}
|
}
|
||||||
|
|
|
@ -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!()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue