pub enum ImportingFile<'db> {
ResolverFile(ResolverFile<'db>),
File(File, ResolverEnvironment<'db>),
}Expand description
The file from which an import is resolved.
Most absolute imports only need the resolver environment. Creating a ResolverFile for each
such import would unnecessarily intern the file and environment together, even though that
combined identity is never used:
resolve_module(ImportingFile::File(shared.py, environment), "dependency")
-> resolve using environment; no ResolverFile neededRelative imports, on the other hand, need the importing file’s module identity and therefore
require a ResolverFile:
from .dependency import value
-> importing_file.resolver_file(db)
-> ResolverFile(shared.py, environment)ImportingFile::File defers interning until such a code path actually calls
ImportingFile::resolver_file. Callers that already have an interned resolver file can pass
ImportingFile::ResolverFile to reuse it directly.
Variants§
ResolverFile(ResolverFile<'db>)
An already-interned resolver key that can be reused without materialization.
File(File, ResolverEnvironment<'db>)
An importing file and resolver environment whose combined key is materialized lazily.
Implementations§
Source§impl<'db> ImportingFile<'db>
impl<'db> ImportingFile<'db>
pub fn file(self, db: &dyn Db) -> File
pub fn resolver_environment(self, db: &'db dyn Db) -> ResolverEnvironment<'db>
pub fn python_version(self, db: &'db dyn Db) -> PythonVersion
Sourcepub fn resolver_file(self, db: &'db dyn Db) -> ResolverFile<'db>
pub fn resolver_file(self, db: &'db dyn Db) -> ResolverFile<'db>
Returns the existing resolver key or materializes one when required.
Trait Implementations§
Source§impl<'db> Clone for ImportingFile<'db>
impl<'db> Clone for ImportingFile<'db>
Source§fn clone(&self) -> ImportingFile<'db>
fn clone(&self) -> ImportingFile<'db>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl<'db> Copy for ImportingFile<'db>
Auto Trait Implementations§
impl<'db> Freeze for ImportingFile<'db>
impl<'db> RefUnwindSafe for ImportingFile<'db>
impl<'db> Send for ImportingFile<'db>
impl<'db> Sync for ImportingFile<'db>
impl<'db> Unpin for ImportingFile<'db>
impl<'db> UnsafeUnpin for ImportingFile<'db>
impl<'db> UnwindSafe for ImportingFile<'db>
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§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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