pub struct ImportItem {
pub attributes: Vec<Attribute>,
pub is_pub: bool,
pub namespace: ImportItemNamespace,
pub name: Ident,
pub alias: Option<Ident>,
}Expand description
A single item in an import declaration, optionally aliased.
Example: name1 as local_name → ImportItem { name: "name1", alias: Some("local_name") }
Example: name1 → ImportItem { name: "name1", alias: None }
Example: type name1 → imports from the type namespace.
Example: pub name1 → re-exported at the importer (selective form).
Fields§
§attributes: Vec<Attribute>Attributes on this import item (e.g., #[expected_fail(...)]).
is_pub: boolWhether this item is re-exported (pub prefix) from the importer.
namespace: ImportItemNamespaceWhich namespace this selective import targets.
name: IdentThe name requested from the imported module.
Its span is the identifier’s use-site span in this import/include
statement, not the definition-site span in the imported module. The AST
is produced before external module resolution.
alias: Option<Ident>Optional local alias (introduced by as).
Implementations§
Source§impl ImportItem
impl ImportItem
Sourcepub fn local_name(&self) -> &str
pub fn local_name(&self) -> &str
The name that this import introduces into the local scope. Returns the alias if present, otherwise the original name.
Sourcepub fn local_span(&self) -> Span
pub fn local_span(&self) -> Span
The span of the local name (alias span if aliased, otherwise original name span).
Trait Implementations§
Source§impl Clone for ImportItem
impl Clone for ImportItem
Source§fn clone(&self) -> ImportItem
fn clone(&self) -> ImportItem
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ImportItem
impl Debug for ImportItem
Source§impl FormatEquivalent for ImportItem
impl FormatEquivalent for ImportItem
Source§fn format_equivalent(&self, other: &Self) -> bool
fn format_equivalent(&self, other: &Self) -> bool
true if self and other are equivalent up to formatting.