Merge pull request #1108 from elpiel/port-examples-julia_set-no_modules-paint-performance-to-rust-2018

Port `julia_set`, `no_modules`, `paint` and `performance` to Rust 2018
This commit is contained in:
Alex Crichton 2018-12-12 09:11:02 -06:00 committed by GitHub
commit df09df42d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 7 additions and 17 deletions

View File

@ -2,6 +2,7 @@
name = "julia_set"
version = "0.1.0"
authors = ["The wasm-bindgen Developers"]
edition = "2018"
[lib]
crate-type = ["cdylib"]

View File

@ -1,6 +1,3 @@
extern crate wasm_bindgen;
extern crate web_sys;
use std::ops::Add;
use wasm_bindgen::prelude::*;
use wasm_bindgen::Clamped;

View File

@ -2,6 +2,7 @@
name = "no_modules"
version = "0.1.0"
authors = ["The wasm-bindgen Developers"]
edition = "2018"
[lib]
crate-type = ["cdylib"]

View File

@ -1,6 +1,3 @@
extern crate wasm_bindgen;
extern crate web_sys;
use wasm_bindgen::prelude::*;
// Called by our JS entry point to run the example

View File

@ -2,6 +2,7 @@
name = "wasm-bindgen-paint"
version = "0.1.0"
authors = ["The wasm-bindgen Developers"]
edition = "2018"
[lib]
crate-type = ["cdylib"]

View File

@ -1,7 +1,3 @@
extern crate js_sys;
extern crate wasm_bindgen;
extern crate web_sys;
use std::cell::Cell;
use std::rc::Rc;
use wasm_bindgen::prelude::*;
@ -30,7 +26,7 @@ pub fn start() -> Result<(), JsValue> {
context.begin_path();
context.move_to(event.offset_x() as f64, event.offset_y() as f64);
pressed.set(true);
}) as Box<FnMut(_)>);
}) as Box<dyn FnMut(_)>);
canvas.add_event_listener_with_callback("mousedown", closure.as_ref().unchecked_ref())?;
closure.forget();
}
@ -44,7 +40,7 @@ pub fn start() -> Result<(), JsValue> {
context.begin_path();
context.move_to(event.offset_x() as f64, event.offset_y() as f64);
}
}) as Box<FnMut(_)>);
}) as Box<dyn FnMut(_)>);
canvas.add_event_listener_with_callback("mousemove", closure.as_ref().unchecked_ref())?;
closure.forget();
}
@ -55,7 +51,7 @@ pub fn start() -> Result<(), JsValue> {
pressed.set(false);
context.line_to(event.offset_x() as f64, event.offset_y() as f64);
context.stroke();
}) as Box<FnMut(_)>);
}) as Box<dyn FnMut(_)>);
canvas.add_event_listener_with_callback("mouseup", closure.as_ref().unchecked_ref())?;
closure.forget();
}

View File

@ -2,6 +2,7 @@
name = "performance"
version = "0.1.0"
authors = ["The wasm-bindgen Developers"]
edition = "2018"
[lib]
crate-type = ["cdylib"]

View File

@ -1,7 +1,3 @@
extern crate humantime;
extern crate wasm_bindgen;
extern crate web_sys;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
use wasm_bindgen::prelude::*;