better error handling
This commit is contained in:
parent
8ee3b422cf
commit
96c7f145d9
19
src/main.rs
19
src/main.rs
|
@ -22,15 +22,22 @@ impl History {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self) {
|
fn update(&mut self) {
|
||||||
let clip = self.clipboard.get_text().unwrap();
|
let clipboard_result = self.clipboard.get_text();
|
||||||
|
|
||||||
for entry in &self.entries {
|
match clipboard_result {
|
||||||
if &clip == entry {
|
Ok(clipboard_content) => {
|
||||||
return
|
for entry in &self.entries {
|
||||||
|
if &clipboard_content == entry {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
println!("new entry");
|
||||||
|
self.entries.insert(0, clipboard_content);
|
||||||
|
}
|
||||||
|
Err(why) => {
|
||||||
|
eprintln!("could not fetch clipboard : {}", why);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!("new entry");
|
|
||||||
self.entries.insert(0, clip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn paste(&mut self) {
|
fn paste(&mut self) {
|
||||||
|
|
Loading…
Reference in a new issue