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

pub struct Import { /* fields omitted */ }

The import of a Python name from module import foo.

Created through the import() function.

Implementations

impl Import[src]

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

Configure the importe name with the specified alias.

This implised that the import is not qualified.

Examples

use genco::prelude::*;

let toks = quote! {
    #(python::import("collections", "namedtuple").with_alias("nt"))
};

assert_eq!(
    vec![
        "from collections import namedtuple as nt",
        "",
        "nt",
    ],
    toks.to_file_vec()?
);

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

Indicate that the import is qualified (module prefixed).

Examples

use genco::prelude::*;

let toks = quote! {
    #(python::import("collections", "namedtuple").qualified())
};

assert_eq!(
    vec![
        "import collections",
        "",
        "collections.namedtuple",
    ],
    toks.to_file_vec()?
);

pub fn with_module_alias<T>(self, module_alias: T) -> Self where
    T: Into<ItemStr>, 
[src]

Configure the imported name with the specified alias.

This implies that the import is qualified.

Examples

use genco::prelude::*;

let toks = quote! {
    #(python::import("collections", "namedtuple").with_module_alias("c"))
};

assert_eq!(
    vec![
        "import collections as c",
        "",
        "c.namedtuple",
    ],
    toks.to_file_vec()?
);

Trait Implementations

impl Clone for Import[src]

impl Debug for Import[src]

impl Eq for Import[src]

impl FormatInto<Python> for Import[src]

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

impl<'a> From<&'a Import> for LangBox<Python>[src]

impl From<Import> for Any[src]

impl From<Import> for LangBox<Python>[src]

impl Hash for Import[src]

impl LangItem<Python> for Import[src]

impl Ord for Import[src]

impl PartialEq<Import> for Import[src]

impl PartialOrd<Import> for Import[src]

impl StructuralEq for Import[src]

impl StructuralPartialEq for Import[src]

impl TypeTrait 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.