mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 13:01:22 +00:00
Migrate all crates to the 2018 edition
Most of the CLI crates were already in the 2018 edition, and it turns out that one of the macro crates was already in the 2018 edition so we may as well move everything to the 2018 edition! Always nice to remove those `extern crate` statements nowadays! This commit also does a `cargo fmt --all` to make sure we're conforming with style again.
This commit is contained in:
@ -357,7 +357,8 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
return Ok(self);
|
||||
}
|
||||
Descriptor::RustStruct(ref s) => {
|
||||
self.js_arguments.push((name.clone(), format!("{} | undefined", s)));
|
||||
self.js_arguments
|
||||
.push((name.clone(), format!("{} | undefined", s)));
|
||||
self.prelude(&format!("let ptr{} = 0;", i));
|
||||
self.prelude(&format!("if ({0} !== null && {0} !== undefined) {{", name));
|
||||
self.assert_class(&name, s);
|
||||
@ -659,7 +660,8 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
Descriptor::RustStruct(ref name) => {
|
||||
self.ret_ty = format!("{} | undefined", name);
|
||||
self.cx.require_class_wrap(name);
|
||||
self.ret_expr = format!("
|
||||
self.ret_expr = format!(
|
||||
"
|
||||
const ptr = RET;
|
||||
return ptr === 0 ? undefined : {}.__wrap(ptr);
|
||||
",
|
||||
@ -830,7 +832,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
|
||||
fn assert_class(&mut self, arg: &str, class: &str) {
|
||||
if !self.cx.config.debug {
|
||||
return
|
||||
return;
|
||||
}
|
||||
self.cx.expose_assert_class();
|
||||
self.prelude(&format!("_assertClass({}, {});", arg, class));
|
||||
@ -838,7 +840,7 @@ impl<'a, 'b> Js2Rust<'a, 'b> {
|
||||
|
||||
fn assert_not_moved(&mut self, arg: &str) {
|
||||
if !self.cx.config.debug {
|
||||
return
|
||||
return;
|
||||
}
|
||||
self.prelude(&format!(
|
||||
"\
|
||||
|
@ -2,7 +2,7 @@ use crate::decode;
|
||||
use crate::descriptor::{Descriptor, VectorKind};
|
||||
use crate::{Bindgen, EncodeInto, OutputMode};
|
||||
use failure::{bail, Error, ResultExt};
|
||||
use std::collections::{HashMap, HashSet, BTreeMap};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use walrus::{MemoryId, Module};
|
||||
@ -2998,8 +2998,10 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
return Ok(());
|
||||
}
|
||||
if !self.cx.config.mode.nodejs() && !self.cx.config.mode.bundler() {
|
||||
bail!("NPM dependencies have been specified in `{}` but \
|
||||
this is only compatible with the `bundler` and `nodejs` targets");
|
||||
bail!(
|
||||
"NPM dependencies have been specified in `{}` but \
|
||||
this is only compatible with the `bundler` and `nodejs` targets"
|
||||
);
|
||||
}
|
||||
let contents = fs::read_to_string(path).context(format!("failed to read `{}`", path))?;
|
||||
let json: serde_json::Value = serde_json::from_str(&contents)?;
|
||||
|
@ -225,7 +225,10 @@ impl<'a, 'b> Rust2Js<'a, 'b> {
|
||||
}
|
||||
Descriptor::RustStruct(ref class) => {
|
||||
self.cx.require_class_wrap(class);
|
||||
let assign = format!("let c{0} = {0} === 0 ? undefined : {1}.__wrap({0});", abi, class);
|
||||
let assign = format!(
|
||||
"let c{0} = {0} === 0 ? undefined : {1}.__wrap({0});",
|
||||
abi, class
|
||||
);
|
||||
self.prelude(&assign);
|
||||
self.js_arguments.push(format!("c{}", abi));
|
||||
return Ok(());
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![doc(html_root_url = "https://docs.rs/wasm-bindgen-cli-support/0.2")]
|
||||
|
||||
use failure::{bail, Error, ResultExt};
|
||||
use std::collections::{BTreeSet, BTreeMap};
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use std::mem;
|
||||
|
Reference in New Issue
Block a user