Skip to main content

Item

Struct Item 

Source
#[non_exhaustive]
pub struct Item {
Show 21 fields pub id: ItemId, pub path: SharedStr, pub name: SharedStr, pub kind: SymbolKind, pub namespace: Namespace, pub file: RelPath, pub name_line: usize, pub span: SpanFact, pub body: Option<SpanFact>, pub visibility: Vis, pub documented: bool, pub doc_hidden: bool, pub test: TestRole, pub target: TargetId, pub self_type: Option<SharedStr>, pub trait_path: Option<SharedStr>, pub trait_key: Option<Arc<TraitKey>>, pub trait_definition_target: Option<TargetId>, pub self_key: Option<SelfType>, pub shape: Option<FieldShape>, pub macro_export: bool, /* private fields */
}
Expand description

One named item of the workspace.

A written source item is identified in its file by the byte offset where its span starts. Crate-root items represent whole files instead and have no source group, even when their key equals that of the first written item. A file that several module trees reach has one Item for each path it is reached under; the items share their file and offset and differ in path and target.

A record is at most 256 bytes: its text is shared (SharedStr and RelPath), and the trait key of an impl member is shared by the members of its impl block.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§id: ItemId

The identity of the item.

§path: SharedStr

The full path: the module path and the name, with a method under its impl type, <trait>::<method> for a trait impl on a type that is not a local struct, enum or union, or <self path>::<method> for an inherent impl whose self type the index cannot see (see SelfType::Unresolved).

§name: SharedStr

The name without a raw-identifier prefix.

§kind: SymbolKind

What the item is.

§namespace: Namespace

The main name space of the item. Unit and tuple structs are also in the value name space; see Item::in_namespace.

§file: RelPath

The file that defines the item.

§name_line: usize

The 1-based line of the name.

§span: SpanFact

The whole item, attributes included.

§body: Option<SpanFact>

The braced body, or the function block, if there is one.

§visibility: Vis

The declared visibility.

§documented: bool

True when the item has non-blank documentation: an unconditional #[doc] attribute or doc comment that holds text, or #[doc = include_str!(..)], where #[doc(hidden)] alone does not count; for a module that has its own file, the file’s inner documentation counts.

§doc_hidden: bool

True when the item has #[doc(hidden)].

§test: TestRole

The test role of the item, including the role the module tree gives it: an item in a file reached only through test code is CfgTest.

§target: TargetId

The target whose module tree holds the item.

§self_type: Option<SharedStr>

For a member of an impl block, the self type as written, without spaces.

§trait_path: Option<SharedStr>

For a trait impl method, the trait path as written.

§trait_key: Option<Arc<TraitKey>>

For a trait impl method on a type that is not local, how the trait is keyed; None for the members of impls on local types, which are recorded under the type.

§trait_definition_target: Option<TargetId>

The target defining a resolved trait key, when its definition is indexed.

Equal displayed trait paths in different targets have distinct identities. Only indexed trait definitions supply this evidence. None is missing evidence, never proof that no defining trait exists.

§self_key: Option<SelfType>

For a member of an impl block, how its self type placed it; None for every other item.

§shape: Option<FieldShape>

For a struct or union, how its fields are declared.

§macro_export: bool

True for a macro_rules! macro with an unconditional #[macro_export], which is indexed at the crate root and which other crates can name there; false for every other item.

Implementations§

Source§

impl Item

Source

pub fn enum_roster_has_only_written_variants(&self) -> bool

True when the written enum variants bound its member roster. Configuration can remove written variants. Attributes whose expansion could change the roster leave this proof unavailable.

Source

pub fn in_namespace(&self, namespace: Namespace) -> bool

True when the item defines a name in namespace.

Source

pub fn parameter_bindings(&self) -> &[String]

The names the parameters of a function or method bind, in signature order, as the source writes them: a mut x, a ref x, the names inside tuple, struct and slice patterns, a raw identifier with its r#. A receiver contributes self, first. Names that occur only in types are not bindings. Empty for an item that is not a function, for a function with no parameters and for a function the index reads from a declaration with no body.

The names are read during the budgeted parse, so no caller re-parses the signature.

Source

pub fn initializer(&self) -> Option<Range<usize>>

The byte range, in the text of the item’s file, of the value of a constant, an associated constant or a static: after the = and before the ;, never the type and never an attribute. None for an item that has no such value, such as a trait’s required constant or a function.

Source

pub fn source_key(&self) -> (&RelPath, usize)

The identity of the source item: its file and the byte offset where its span starts. A crate root spans a whole file and can share this key with its first written item; workspace source-group accessors exclude roots.

Trait Implementations§

Source§

impl Clone for Item

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Item

Source§

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

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

impl Eq for Item

Source§

impl PartialEq for Item

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Item

Auto Trait Implementations§

§

impl Forget for Item

§

impl Freeze for Item

§

impl Move for Item

§

impl RefUnwindSafe for Item

§

impl Send for Item

§

impl Sync for Item

§

impl Unpin for Item

§

impl UnsafeUnpin for Item

§

impl UnwindSafe for Item

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

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

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

Source§

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

Whether this borrowed key equals the stored key.
Source§

impl<Q, K> Equivalent<K> for Q
where 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> EvidenceLease for T
where T: Debug + Send + Sync,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.