[][src]Function genco::lang::dart::import

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

Setup an imported element.

Examples

use genco::prelude::*;

let a = dart::import("package:http/http.dart", "A");
let b = dart::import("package:http/http.dart", "B");
let c = dart::import("package:http/http.dart", "C").with_alias("h2");
let d = dart::import("../http.dart", "D");

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

let expected = vec![
    "import \"../http.dart\";",
    "import \"package:http/http.dart\";",
    "import \"package:http/http.dart\" as h2;",
    "",
    "A",
    "B",
    "h2.C",
    "D",
];

assert_eq!(expected, toks.to_file_vec()?);