#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.id: ItemIdThe identity of the item.
path: SharedStrThe 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: SharedStrThe name without a raw-identifier prefix.
kind: SymbolKindWhat the item is.
namespace: NamespaceThe main name space of the item. Unit and tuple structs are also in
the value name space; see Item::in_namespace.
file: RelPathThe file that defines the item.
name_line: usizeThe 1-based line of the name.
span: SpanFactThe whole item, attributes included.
body: Option<SpanFact>The braced body, or the function block, if there is one.
visibility: VisThe declared visibility.
documented: boolTrue 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.
True when the item has #[doc(hidden)].
test: TestRoleThe 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: TargetIdThe 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: boolTrue 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
impl Item
Sourcepub fn enum_roster_has_only_written_variants(&self) -> bool
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.
Sourcepub fn in_namespace(&self, namespace: Namespace) -> bool
pub fn in_namespace(&self, namespace: Namespace) -> bool
True when the item defines a name in namespace.
Sourcepub fn parameter_bindings(&self) -> &[String]
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.
Sourcepub fn initializer(&self) -> Option<Range<usize>>
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.
Sourcepub fn source_key(&self) -> (&RelPath, usize)
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§
impl Eq for Item
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> 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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> EvidenceLease for T
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