[][src]Function genco::js::import_default

pub fn import_default<M, N>(module: M, name: N) -> ImportDefault where
    M: Into<ItemStr>,
    N: Into<ItemStr>, 

Import the default element from the specified module.

Note that the default element may only be aliased once, so multiple aliases will cause an error.

Examples

use genco::prelude::*;

let a = js::import_default("collections", "defaultVec");
let b = js::import("collections", "vec");
let c = js::import("collections", "vec").alias("list");

let toks = quote! {
    #a
    #b
    #c
};

assert_eq!(
    vec![
        "import defaultVec, {vec, vec as list} from \"collections\";",
        "",
        "defaultVec",
        "vec",
        "list",
    ],
    toks.to_file_vec().unwrap()
);