pub struct Import {
pub module: String,
pub items: Vec<String>,
pub is_type_only: bool,
}Expand description
Represents an import/require/use statement in any language
Fields§
§module: StringModule or package name (e.g., “typing”, “graphql”, “@apollo/client”)
items: Vec<String>Specific items to import (e.g., [“List”, “Dict”] for Python) If empty, import the entire module
is_type_only: boolFor TypeScript: whether this is a type-only import (import type { … } from …)
Implementations§
Source§impl Import
impl Import
Sourcepub fn new(module: impl Into<String>) -> Self
pub fn new(module: impl Into<String>) -> Self
Create a new import with no specific items (full module import)
§Example
use spikard_cli::codegen::formatters::Import;
let import = Import::new("typing");
assert_eq!(import.module, "typing");
assert!(import.items.is_empty());Sourcepub fn with_items(module: impl Into<String>, items: Vec<&str>) -> Self
pub fn with_items(module: impl Into<String>, items: Vec<&str>) -> Self
Create an import with specific items
§Example
use spikard_cli::codegen::formatters::Import;
let import = Import::with_items("typing", vec!["List", "Dict"]);
assert_eq!(import.items.len(), 2);Sourcepub const fn with_type_only(self, type_only: bool) -> Self
pub const fn with_type_only(self, type_only: bool) -> Self
Mark this import as type-only (TypeScript only)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Import
impl RefUnwindSafe for Import
impl Send for Import
impl Sync for Import
impl Unpin for Import
impl UnsafeUnpin for Import
impl UnwindSafe for Import
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