pub struct InFile<T> {
    pub file_id: HirFileId,
    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: HirFileId§value: T

Implementations§

source§

impl<N: AstIdNode> InFile<FileAstId<N>>

source

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

source

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

source

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

source§

impl InFile<Idx<SyntaxNodePtr<RustLanguage>>>

source

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

source§

impl<T> InFile<T>

source

pub fn new(file_id: HirFileId, value: T) -> InFile<T>

source

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

source

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

source

pub fn as_ref(&self) -> InFile<&T>

source

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

source§

impl<T: Clone> InFile<&T>

source

pub fn cloned(&self) -> InFile<T>

source§

impl<T> InFile<Option<T>>

source

pub fn transpose(self) -> Option<InFile<T>>

source§

impl<L, R> InFile<Either<L, R>>

source

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

source§

impl InFile<&SyntaxNode>

source

pub fn ancestors_with_macros( self, db: &dyn ExpandDatabase ) -> impl Iterator<Item = InFile<SyntaxNode>> + Clone + '_

source

pub fn ancestors_with_macros_skip_attr_item( self, db: &dyn ExpandDatabase ) -> impl Iterator<Item = InFile<SyntaxNode>> + '_

Skips the attributed item that caused the macro invocation we are climbing up

source

pub fn original_file_range(self, db: &dyn ExpandDatabase) -> FileRange

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.

source

pub fn original_file_range_full(self, db: &dyn ExpandDatabase) -> FileRange

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

source

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

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

source

pub fn original_syntax_node( self, db: &dyn ExpandDatabase ) -> Option<InFile<SyntaxNode>>

source§

impl InFile<SyntaxToken>

source

pub fn upmap(self, db: &dyn ExpandDatabase) -> Option<InFile<SyntaxToken>>

source

pub fn original_file_range(self, db: &dyn ExpandDatabase) -> FileRange

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

source

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

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

source§

impl<N: AstNode> InFile<N>

source

pub fn descendants<T: AstNode>(self) -> impl Iterator<Item = InFile<T>>

source

pub fn original_ast_node(self, db: &dyn ExpandDatabase) -> Option<InFile<N>>

source

pub fn syntax(&self) -> InFile<&SyntaxNode>

Trait Implementations§

source§

impl<T: Clone> Clone for InFile<T>

source§

fn clone(&self) -> InFile<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
source§

impl<T: Debug> Debug for InFile<T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<T> From<InMacroFile<T>> for InFile<T>

source§

fn from(macro_file: InMacroFile<T>) -> Self

Converts to this type from the input type.
source§

impl<T: Hash> Hash for InFile<T>

source§

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

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

impl<T: PartialEq> PartialEq<InFile<T>> for InFile<T>

source§

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

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

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

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

impl<T: Copy> Copy for InFile<T>

source§

impl<T: Eq> Eq for InFile<T>

source§

impl<T> StructuralEq for InFile<T>

source§

impl<T> StructuralPartialEq for InFile<T>

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for InFile<T>where T: RefUnwindSafe,

§

impl<T> Send for InFile<T>where T: Send,

§

impl<T> Sync for InFile<T>where T: Sync,

§

impl<T> Unpin for InFile<T>where T: Unpin,

§

impl<T> UnwindSafe for InFile<T>where T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

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

source§

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

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

impl<Q, K> Equivalent<K> for Qwhere 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<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

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.

source§

impl<T> Instrument for T

source§

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

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

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 Twhere 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.

source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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

impl<T> WithSubscriber for T

source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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