[][src]Function genco::dart::imported

pub fn imported<P: Into<ItemStr>, N: Into<ItemStr>>(path: P, name: N) -> Type

Setup an imported element.

Examples

use genco::prelude::*;

let a = dart::imported("package:http/http.dart", "A");
let b = dart::imported("package:http/http.dart", "B");
let c = dart::imported("package:http/http.dart", "C").alias("h2");
let d = dart::imported("../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().unwrap());