Skip to content

Commit

Permalink
Use &str instead of String.
Browse files Browse the repository at this point in the history
  • Loading branch information
wtholliday committed Feb 22, 2023
1 parent 2b70a08 commit dbda356
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/open_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!")
}
_ => (),
}
Expand Down
2 changes: 1 addition & 1 deletion src/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
4 changes: 2 additions & 2 deletions src/macos/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/win/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,6 @@ unsafe impl HasRawWindowHandle for Window<'_> {
}
}

pub fn copy_to_clipboard(data: String) {
pub fn copy_to_clipboard(data: &str) {
todo!()
}
2 changes: 1 addition & 1 deletion src/x11/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!()
}

0 comments on commit dbda356

Please sign in to comment.