[][src]Function genco::prelude::js::import

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

Import an element from a module

Examples

use genco::prelude::*;

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

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

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