pub struct Imports { /* private fields */ }
Expand description
Provides assistance in generating use declarations.
It takes into account that use declaration referring to names within the same crate will look differently. It also avoids generating spurious declarations referring to names from within the same module as the one we are generating code for.
Implementations§
source§impl Imports
impl Imports
pub fn new(gir: &Library) -> Self
pub fn with_defined(gir: &Library, name: &str) -> Self
pub fn with_defaults( &mut self, version: Option<Version>, constraint: &Option<String>, ) -> ImportsWithDefault<'_>
sourcepub fn add_defined(&mut self, name: &str)
pub fn add_defined(&mut self, name: &str)
Declares that name
is defined in scope
Removes existing imports from self.map
and marks name
as
available to counter future import “requests”.
sourcepub fn add(&mut self, name: &str)
pub fn add(&mut self, name: &str)
Declares that name should be available through its last path component.
For example, if name is X::Y::Z
then it will be available as Z
.
Uses defaults.
sourcepub fn add_with_version(&mut self, name: &str, version: Option<Version>)
pub fn add_with_version(&mut self, name: &str, version: Option<Version>)
Declares that name should be available through its last path component.
For example, if name is X::Y::Z
then it will be available as Z
.
sourcepub fn add_with_constraint(
&mut self,
name: &str,
version: Option<Version>,
constraint: Option<&str>,
)
pub fn add_with_constraint( &mut self, name: &str, version: Option<Version>, constraint: Option<&str>, )
Declares that name should be available through its last path component and provides an optional feature constraint.
For example, if name is X::Y::Z
then it will be available as Z
.
sourcepub fn add_used_type(&mut self, used_type: &str)
pub fn add_used_type(&mut self, used_type: &str)
Declares that name should be available through its full path.
For example, if name is X::Y
then it will be available as X::Y
.
pub fn add_used_types(&mut self, used_types: &[String])
sourcepub fn add_used_type_with_version(
&mut self,
used_type: &str,
version: Option<Version>,
)
pub fn add_used_type_with_version( &mut self, used_type: &str, version: Option<Version>, )
Declares that name should be available through its full path.
For example, if name is X::Y
then it will be available as X::Y
.
pub fn iter(&self) -> IntoIter<(&String, &ImportConditions)>
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 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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)