struct Imports {
imports: Vec<String>,
renaming: BTreeMap<(String, String), String>,
}Expand description
Datastructure to deduplicate, validate and generate imports
Fields§
§imports: Vec<String>Import lines ready to use
renaming: BTreeMap<(String, String), String>Renaming map: from module name and member name return the name to use in type hints
Implementations§
Source§impl Imports
impl Imports
Sourcefn create(module: &Module, module_parents: &[&str]) -> Self
fn create(module: &Module, module_parents: &[&str]) -> Self
This generates a map from the builtin or module name to the actual alias used in the file
For Python builtins and elements declared by the module the alias is always the actual name.
For other elements, we can alias them using the from X import Y as Z syntax.
So, we first list all builtins and local elements, then iterate on imports
and create the aliases when needed.
fn serialize_expr(&self, expr: &Expr, buffer: &mut String)
fn serialize_elts(&self, elts: &[Expr], buffer: &mut String)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Imports
impl RefUnwindSafe for Imports
impl Send for Imports
impl Sync for Imports
impl Unpin for Imports
impl UnsafeUnpin for Imports
impl UnwindSafe for Imports
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)]const SIZE: usize = _
#[doc(hidden)]const SIZE: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGN: usize = _
#[doc(hidden)]const ALIGN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const ALIGNMENT: Alignment = _
#[doc(hidden)]const ALIGNMENT: Alignment = _
🔬This is a nightly-only experimental API. (
ptr_alignment_type)Source§#[doc(hidden)]const IS_ZST: bool = _
#[doc(hidden)]const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const LAYOUT: Layout = _
#[doc(hidden)]const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties)Source§#[doc(hidden)]const MAX_SLICE_LEN: usize = _
#[doc(hidden)]const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties)The largest safe length for a
[Self]. Read more