Struct hir::InFileWrapper

pub struct InFileWrapper<FileKind, T> {
    pub file_id: FileKind,
    pub value: T,
}
Expand description

InFile<T> stores a value of T inside a particular file/syntax tree.

Typical usages are:

  • InFile<SyntaxNode> – syntax node in a file
  • InFile<ast::FnDef> – ast node in a file
  • InFile<TextSize> – offset in a file

Fields§

§file_id: FileKind§value: T

Implementations§

§

impl<N> InFileWrapper<HirFileId, FileAstId<N>>
where N: AstIdNode,

pub fn to_node(&self, db: &dyn ExpandDatabase) -> N

pub fn to_range(&self, db: &dyn ExpandDatabase) -> TextRange

pub fn to_in_file_node( &self, db: &dyn ExpandDatabase, ) -> InFileWrapper<HirFileId, N>

pub fn to_ptr(&self, db: &dyn ExpandDatabase) -> AstPtr<N>

§

impl InFileWrapper<HirFileId, ErasedFileAstId>

pub fn to_range(&self, db: &dyn ExpandDatabase) -> TextRange

pub fn to_ptr(&self, db: &dyn ExpandDatabase) -> SyntaxNodePtr<RustLanguage>

§

impl<FileKind, T> InFileWrapper<FileKind, T>

pub fn new(file_id: FileKind, value: T) -> InFileWrapper<FileKind, T>

pub fn map<F, U>(self, f: F) -> InFileWrapper<FileKind, U>
where F: FnOnce(T) -> U,

§

impl<FileKind, T> InFileWrapper<FileKind, T>
where FileKind: Copy,

pub fn with_value<U>(&self, value: U) -> InFileWrapper<FileKind, U>

pub fn as_ref(&self) -> InFileWrapper<FileKind, &T>

pub fn borrow<U>(&self) -> InFileWrapper<FileKind, &U>
where T: Borrow<U>,

§

impl<FileKind, T> InFileWrapper<FileKind, &T>
where FileKind: Copy, T: Clone,

pub fn cloned(&self) -> InFileWrapper<FileKind, T>

§

impl<FileKind, T> InFileWrapper<FileKind, Option<T>>

pub fn transpose(self) -> Option<InFileWrapper<FileKind, T>>

§

impl<FileKind, L, R> InFileWrapper<FileKind, Either<L, R>>

pub fn transpose( self, ) -> Either<InFileWrapper<FileKind, L>, InFileWrapper<FileKind, R>>

§

impl<FileId, T> InFileWrapper<FileId, T>
where FileId: FileIdToSyntax,

pub fn file_syntax(&self, db: &dyn ExpandDatabase) -> SyntaxNode<RustLanguage>

§

impl<FileId, N> InFileWrapper<FileId, N>
where FileId: Copy, N: AstNode,

pub fn syntax(&self) -> InFileWrapper<FileId, &SyntaxNode<RustLanguage>>

§

impl<FileId, N> InFileWrapper<FileId, &N>
where FileId: Copy, N: AstNode,

pub fn syntax_ref(&self) -> InFileWrapper<FileId, &SyntaxNode<RustLanguage>>

§

impl<SN> InFileWrapper<EditionedFileId, SN>
where SN: Borrow<SyntaxNode<RustLanguage>>,

pub fn file_range(&self) -> FileRangeWrapper<EditionedFileId>

§

impl<SN> InFileWrapper<HirFileId, SN>
where SN: Borrow<SyntaxNode<RustLanguage>>,

pub fn parent_ancestors_with_macros( self, db: &dyn ExpandDatabase, ) -> impl Iterator<Item = InFileWrapper<HirFileId, SyntaxNode<RustLanguage>>>

pub fn ancestors_with_macros( self, db: &dyn ExpandDatabase, ) -> impl Iterator<Item = InFileWrapper<HirFileId, SyntaxNode<RustLanguage>>>

pub fn kind(&self) -> SyntaxKind

pub fn text_range(&self) -> TextRange

pub fn original_file_range_rooted( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>

Falls back to the macro call range if the node cannot be mapped up fully.

For attributes and derives, this will point back to the attribute only. For the entire item use [InFile::original_file_range_full].

pub fn original_file_range_with_macro_call_body( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>

Falls back to the macro call range if the node cannot be mapped up fully.

pub fn original_syntax_node_rooted( self, db: &dyn ExpandDatabase, ) -> Option<InFileWrapper<EditionedFileId, SyntaxNode<RustLanguage>>>

§

impl InFileWrapper<HirFileId, &SyntaxNode<RustLanguage>>

pub fn original_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<(FileRangeWrapper<EditionedFileId>, SyntaxContextId)>

Attempts to map the syntax node back up its macro calls.

§

impl InFileWrapper<MacroFileId, SyntaxToken<RustLanguage>>

pub fn upmap_once( self, db: &dyn ExpandDatabase, ) -> InFileWrapper<HirFileId, SmallVec<[TextRange; 1]>>

§

impl InFileWrapper<HirFileId, SyntaxToken<RustLanguage>>

pub fn original_file_range( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>

Falls back to the macro call range if the node cannot be mapped up fully.

pub fn original_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<FileRangeWrapper<EditionedFileId>>

Attempts to map the syntax node back up its macro calls.

§

impl InFileWrapper<MacroFileId, TextSize>

pub fn original_file_range( self, db: &dyn ExpandDatabase, ) -> (FileRangeWrapper<EditionedFileId>, SyntaxContextId)

§

impl InFileWrapper<HirFileId, TextRange>

pub fn original_node_file_range( self, db: &dyn ExpandDatabase, ) -> (FileRangeWrapper<EditionedFileId>, SyntaxContextId)

pub fn original_node_file_range_rooted( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>

pub fn original_node_file_range_with_macro_call_body( self, db: &dyn ExpandDatabase, ) -> FileRangeWrapper<EditionedFileId>

pub fn original_node_file_range_opt( self, db: &dyn ExpandDatabase, ) -> Option<(FileRangeWrapper<EditionedFileId>, SyntaxContextId)>

§

impl<N> InFileWrapper<HirFileId, N>
where N: AstNode,

pub fn original_ast_node_rooted( self, db: &dyn ExpandDatabase, ) -> Option<InFileWrapper<EditionedFileId, N>>

§

impl<T> InFileWrapper<HirFileId, T>

pub fn into_real_file( self, ) -> Result<InFileWrapper<EditionedFileId, T>, InFileWrapper<HirFileId, T>>

Trait Implementations§

§

impl AsMacroCall for InFileWrapper<HirFileId, &MacroCall>

§

fn as_call_id_with_errors( &self, db: &dyn ExpandDatabase, krate: Idx<CrateData>, resolver: impl Fn(&ModPath) -> Option<MacroDefId> + Copy, ) -> Result<ValueResult<Option<MacroCallId>, ExpandError>, UnresolvedMacro>

§

fn as_call_id( &self, db: &dyn ExpandDatabase, krate: Idx<CrateData>, resolver: impl Fn(&ModPath) -> Option<MacroDefId> + Copy, ) -> Option<MacroCallId>

§

impl<FileKind, T> Clone for InFileWrapper<FileKind, T>
where FileKind: Clone, T: Clone,

§

fn clone(&self) -> InFileWrapper<FileKind, T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<FileKind, T> Debug for InFileWrapper<FileKind, T>
where FileKind: Debug, T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> From<InFileWrapper<EditionedFileId, T>> for InFileWrapper<HirFileId, T>

§

fn from(_: InFileWrapper<EditionedFileId, T>) -> InFileWrapper<HirFileId, T>

Converts to this type from the input type.
§

impl<T> From<InFileWrapper<MacroFileId, T>> for InFileWrapper<HirFileId, T>

§

fn from(_: InFileWrapper<MacroFileId, T>) -> InFileWrapper<HirFileId, T>

Converts to this type from the input type.
§

impl<FileKind, T> Hash for InFileWrapper<FileKind, T>
where FileKind: Hash, T: Hash,

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
§

impl<FileKind, T> PartialEq for InFileWrapper<FileKind, T>
where FileKind: PartialEq, T: PartialEq,

§

fn eq(&self, other: &InFileWrapper<FileKind, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<FileKind, T> Copy for InFileWrapper<FileKind, T>
where FileKind: Copy, T: Copy,

§

impl<FileKind, T> Eq for InFileWrapper<FileKind, T>
where FileKind: Eq, T: Eq,

§

impl<FileKind, T> StructuralPartialEq for InFileWrapper<FileKind, T>

Auto Trait Implementations§

§

impl<FileKind, T> Freeze for InFileWrapper<FileKind, T>
where FileKind: Freeze, T: Freeze,

§

impl<FileKind, T> RefUnwindSafe for InFileWrapper<FileKind, T>
where FileKind: RefUnwindSafe, T: RefUnwindSafe,

§

impl<FileKind, T> Send for InFileWrapper<FileKind, T>
where FileKind: Send, T: Send,

§

impl<FileKind, T> Sync for InFileWrapper<FileKind, T>
where FileKind: Sync, T: Sync,

§

impl<FileKind, T> Unpin for InFileWrapper<FileKind, T>
where FileKind: Unpin, T: Unpin,

§

impl<FileKind, T> UnwindSafe for InFileWrapper<FileKind, T>
where FileKind: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Cast for T

§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Sync + Send> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Sync + Send>

Convert self into the appropriate boxed form.
source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<'a, T> Captures<'a> for T
where T: ?Sized,