Rostkopie in die Zwischenablage
//using https://docs.rs/cli-clipboard/latest/cli_clipboard crate
use cli_clipboard::{ClipboardContext, ClipboardProvider};
let mut ctx = ClipboardContext::new().unwrap();
let the_string = "Hello, world!";
ctx.set_contents(the_string.to_owned()).unwrap();
assert_eq!(ctx.get_contents().unwrap(), the_string);
ctx.clear();
// clearing the clipboard causes get_contents to return Err on macos and windows
if cfg!(any(windows, target_os = "macos")) {
if ctx.get_contents().is_ok() {
panic!("Should be Err");
}
} else {
assert_eq!(ctx.get_contents().unwrap(), "");
}
MXO