Run cargo fmt --all

This commit is contained in:
Alex Crichton 2019-06-13 08:30:06 -07:00
parent 3aa803c55c
commit 83a3f5d44a
5 changed files with 58 additions and 45 deletions

View File

@ -1174,7 +1174,8 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
//
// But for now, we just bounce wasm -> js -> wasm because it is
// easy.
self.cx.require_internal_export("__wbindgen_anyref_heap_live_count_impl")?;
self.cx
.require_internal_export("__wbindgen_anyref_heap_live_count_impl")?;
"wasm.__wbindgen_anyref_heap_live_count_impl()".into()
} else {
self.cx.expose_global_heap();

View File

@ -11,9 +11,9 @@ use walrus::Module;
mod anyref;
mod decode;
mod intrinsic;
mod descriptor;
mod descriptors;
mod intrinsic;
mod js;
pub mod wasm2es6js;
mod webidl;
@ -337,7 +337,10 @@ impl Bindgen {
let (js, ts) = {
let mut cx = js::Context::new(&mut module, self)?;
let aux = cx.module.customs.delete_typed::<webidl::WasmBindgenAux>()
let aux = cx
.module
.customs
.delete_typed::<webidl::WasmBindgenAux>()
.expect("aux section should be present");
cx.generate(&aux)?;
@ -346,10 +349,7 @@ impl Bindgen {
for (identifier, list) in aux.snippets.iter() {
for (i, js) in list.iter().enumerate() {
let name = format!("inline{}.js", i);
let path = out_dir
.join("snippets")
.join(identifier)
.join(name);
let path = out_dir.join("snippets").join(identifier).join(name);
fs::create_dir_all(path.parent().unwrap())?;
fs::write(&path, js)
.with_context(|_| format!("failed to write `{}`", path.display()))?;

View File

@ -71,7 +71,8 @@ fn rmain() -> Result<(), Error> {
// that any exported function with the prefix `__wbg_test` is a test we need
// to execute.
let wasm = fs::read(&wasm_file_to_test).context("failed to read wasm file")?;
let mut wasm = walrus::Module::from_buffer(&wasm).context("failed to deserialize wasm module")?;
let mut wasm =
walrus::Module::from_buffer(&wasm).context("failed to deserialize wasm module")?;
let mut tests = Vec::new();
for export in wasm.exports.iter() {

View File

@ -1,57 +1,68 @@
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub struct ColorWithGetter { r: f64, _g: f64, _b: f64, _a: u8 }
pub struct ColorWithGetter {
r: f64,
_g: f64,
_b: f64,
_a: u8,
}
#[wasm_bindgen]
impl ColorWithGetter {
#[wasm_bindgen(getter)]
pub fn r(&self) -> f64 {
self.r
}
#[wasm_bindgen(getter)]
pub fn r(&self) -> f64 {
self.r
}
}
#[wasm_bindgen]
pub struct ColorWithSetter { r: f64, _g: f64, _b: f64, a: u8 }
pub struct ColorWithSetter {
r: f64,
_g: f64,
_b: f64,
a: u8,
}
#[wasm_bindgen]
impl ColorWithSetter {
#[wasm_bindgen(setter)]
pub fn set_r(&mut self, r: f64) {
self.r = r;
self.a = if self.r > 1.0 {
255
#[wasm_bindgen(setter)]
pub fn set_r(&mut self, r: f64) {
self.r = r;
self.a = if self.r > 1.0 {
255
} else if self.r < 0.0 {
0
} else {
(self.r * 255.0) as u8
};
}
else if self.r < 0.0 {
0
}
else {
(self.r * 255.0) as u8
};
}
}
#[wasm_bindgen]
pub struct ColorWithGetterAndSetter { r: f64, _g: f64, _b: f64, a: u8 }
pub struct ColorWithGetterAndSetter {
r: f64,
_g: f64,
_b: f64,
a: u8,
}
#[wasm_bindgen]
impl ColorWithGetterAndSetter {
#[wasm_bindgen(getter)]
pub fn r(&self) -> f64 {
self.r
}
#[wasm_bindgen(getter)]
pub fn r(&self) -> f64 {
self.r
}
#[wasm_bindgen(setter)]
pub fn set_r(&mut self, r: f64) {
self.r = r;
self.a = if self.r > 1.0 {
255
#[wasm_bindgen(setter)]
pub fn set_r(&mut self, r: f64) {
self.r = r;
self.a = if self.r > 1.0 {
255
} else if self.r < 0.0 {
0
} else {
(self.r * 255.0) as u8
};
}
else if self.r < 0.0 {
0
}
else {
(self.r * 255.0) as u8
};
}
}
}

View File

@ -1080,7 +1080,7 @@ pub mod __rt {
pub fn take_last_exception() -> Result<(), super::JsValue> {
unsafe {
let ret = if GLOBAL_EXNDATA[0] == 1 {
Err(super::JsValue:: _new(GLOBAL_EXNDATA[1]))
Err(super::JsValue::_new(GLOBAL_EXNDATA[1]))
} else {
Ok(())
};