Return Result in examples instead of unwrap
This commit is contained in:
parent
869737dadc
commit
e8f2fbdaf0
3 changed files with 47 additions and 50 deletions
|
|
@ -1,11 +1,12 @@
|
|||
use window_clipboard::Clipboard;
|
||||
use winit::{
|
||||
error::EventLoopError,
|
||||
event::{Event, WindowEvent},
|
||||
event_loop::EventLoop,
|
||||
window::WindowBuilder,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
fn main() -> Result<(), EventLoopError> {
|
||||
let event_loop = EventLoop::new().unwrap();
|
||||
|
||||
let window = WindowBuilder::new()
|
||||
|
|
@ -16,16 +17,14 @@ fn main() {
|
|||
let clipboard =
|
||||
unsafe { Clipboard::connect(&window) }.expect("Connect to clipboard");
|
||||
|
||||
event_loop
|
||||
.run(move |event, elwt| match event {
|
||||
Event::AboutToWait => {
|
||||
println!("{:?}", clipboard.read());
|
||||
}
|
||||
Event::WindowEvent {
|
||||
event: WindowEvent::CloseRequested,
|
||||
window_id,
|
||||
} if window_id == window.id() => elwt.exit(),
|
||||
_ => {}
|
||||
})
|
||||
.unwrap();
|
||||
event_loop.run(move |event, elwt| match event {
|
||||
Event::AboutToWait => {
|
||||
println!("{:?}", clipboard.read());
|
||||
}
|
||||
Event::WindowEvent {
|
||||
event: WindowEvent::CloseRequested,
|
||||
window_id,
|
||||
} if window_id == window.id() => elwt.exit(),
|
||||
_ => {}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue