[][src]Struct genco::lang::rust::Import

pub struct Import { /* fields omitted */ }

The import of a Rust name use std::collections::HashMap.

Created through the import() function.

Implementations

impl Import[src]

pub fn with_alias<A: Into<ItemStr>>(self, alias: A) -> Self[src]

Alias the given type as it's imported.

Examples

use genco::prelude::*;

let ty = rust::import("std::fmt", "Debug").with_alias("FmtDebug");

let toks = quote!(#ty);

assert_eq!(
    vec![
        "use std::fmt::Debug as FmtDebug;",
        "",
        "FmtDebug",
    ],
    toks.to_file_vec()?
);

pub fn with_module_alias<A: Into<ItemStr>>(self, alias: A) -> Self[src]

Alias the module being imported.

This also implies that the import is qualified().

Examples

use genco::prelude::*;

let ty = rust::import("std::fmt", "Debug").with_module_alias("other");

let toks = quote!(#ty);

assert_eq!(
    vec![
        "use std::fmt as other;",
        "",
        "other::Debug",
    ],
    toks.to_file_vec()?
);

pub fn qualified(self) -> Self[src]

Perform a qualified import by prefixing the module the type is being imported from.

So importing std::fmt::Debug will cause the module to be referenced as fmt::Debug instead of Debug.

This is implied if with_module_alias() is used.

Examples

use genco::prelude::*;

let ty = rust::import("std::fmt", "Debug").qualified();

let toks = quote!(#ty);

assert_eq!(
    vec![
        "use std::fmt;",
        "",
        "fmt::Debug",
    ],
    toks.to_file_vec()?
);

Trait Implementations

impl AsAny for Import[src]

impl Clone for Import[src]

impl Debug for Import[src]

impl Eq for Import[src]

impl FormatInto<Rust> for Import[src]

impl<'a> FormatInto<Rust> for &'a Import[src]

impl Hash for Import[src]

impl LangItem<Rust> for Import[src]

impl Ord for Import[src]

impl PartialEq<Import> for Import[src]

impl PartialOrd<Import> for Import[src]

impl Register<Rust> for Import[src]

impl<'a> Register<Rust> for &'a Import[src]

impl StructuralEq for Import[src]

impl StructuralPartialEq for Import[src]

Auto Trait Implementations

impl RefUnwindSafe for Import

impl Send for Import

impl Sync for Import

impl Unpin for Import

impl UnwindSafe for Import

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.