pub struct ImportRef {
pub span: Span,
pub path: ModulePath,
pub group: Option<ImportGroup>,
pub glob: bool,
pub declares: bool,
pub reexport: bool,
pub alias: Option<Name>,
}Expand description
The nouns of the plugin contract that appear in the engine’s answers, so
an interface needs nothing but this crate.
One path in one file. span covers exactly the text a rewrite replaces.
Fields§
§span: Span§path: ModulePathThe full path as written (crate::a::b, ../x/y), parsed by the
grammar’s PathSyntax. For a grouped entry this includes the
group’s prefix.
group: Option<ImportGroup>Present when the path is an entry of a grouped import such as
use a::{b, c::d}; replacing span alone can then only express
paths that stay under the group’s prefix.
glob: booluse a::b::*: every name under the path is brought into scope.
declares: boolPart of an import statement (use, import), so it brings its last
segment into the file’s scope. A qualified path in an expression
(fff::GrepMatch in a type position) is a reference to rewrite on a
move, but declares nothing.
reexport: boolA pub use, an export … from: the name it brings in is offered on
again under this file’s address, so a path to it here reaches the
original declaration.
alias: Option<Name>The name the statement binds instead of the path’s last segment:
Cfg in use a::Config as Cfg.
Implementations§
Source§impl ImportRef
impl ImportRef
pub fn new(span: Span, path: ModulePath) -> ImportRef
pub fn glob(self) -> ImportRef
pub fn reexporting(self) -> ImportRef
pub fn aliased(self, alias: impl Into<Name>) -> ImportRef
Sourcepub fn binding(&self) -> Option<&Name>
pub fn binding(&self) -> Option<&Name>
The name the import brings into scope: its alias, else the path’s last segment; a glob binds nothing nameable.
Sourcepub fn is_standalone(&self) -> bool
pub fn is_standalone(&self) -> bool
True when replacing span with any path is a complete rewrite.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for ImportRef
impl<'de> Deserialize<'de> for ImportRef
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ImportRef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ImportRef, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
impl Eq for ImportRef
Source§impl Serialize for ImportRef
impl Serialize for ImportRef
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for ImportRef
Auto Trait Implementations§
impl Freeze for ImportRef
impl RefUnwindSafe for ImportRef
impl Send for ImportRef
impl Sync for ImportRef
impl Unpin for ImportRef
impl UnsafeUnpin for ImportRef
impl UnwindSafe for ImportRef
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more