You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
856 B
34 lines
856 B
enum WebEvent {
|
|
PageLoad,
|
|
PageUnload,
|
|
KeyPress(char),
|
|
Paste(String),
|
|
Click { x: i64, y: i64 },
|
|
}
|
|
|
|
fn inspect(event: WebEvent) {
|
|
match event {
|
|
WebEvent::PageLoad => println!("page loaded"),
|
|
WebEvent::PageUnload => println!("page unloaded"),
|
|
WebEvent::KeyPress(c) => println!("pressed '{}'.", c),
|
|
WebEvent::Paste(s) => println!("pasted \"{}\".", s),
|
|
WebEvent::Click { x, y } => {
|
|
println!("clicked at x={}, y={}.", x, y);
|
|
}
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let pressed = WebEvent::KeyPress('x');
|
|
let pasted = WebEvent::Paste("my text".to_owned());
|
|
let click = WebEvent::Click { x: 20, y: 80 };
|
|
let load = WebEvent::PageLoad;
|
|
let unload = WebEvent::PageUnload;
|
|
|
|
inspect(pressed);
|
|
inspect(pasted);
|
|
inspect(click);
|
|
inspect(load);
|
|
inspect(unload);
|
|
}
|