pub(crate) struct Item {
pub(crate) name: Option<Symbol>,
pub(crate) inner: Box<ItemInner>,
pub(crate) item_id: ItemId,
pub(crate) inline_stmt_id: Option<LocalDefId>,
pub(crate) cfg: Option<Arc<Cfg>>,
}
Expand description
Anything with a source location and set of attributes and, optionally, a name. That is, anything that can be documented. This doesn’t correspond directly to the AST’s concept of an item; it’s a strict superset.
Fields§
§name: Option<Symbol>
The name of this item. Optional because not every item has a name, e.g. impls.
inner: Box<ItemInner>
§item_id: ItemId
§inline_stmt_id: Option<LocalDefId>
This is the LocalDefId
of the use
statement if the item was inlined.
The crate metadata doesn’t hold this information, so the use
statement
always belongs to the current crate.
cfg: Option<Arc<Cfg>>
Implementations§
Source§impl Item
impl Item
Sourcepub(crate) fn stability(&self, tcx: TyCtxt<'_>) -> Option<Stability>
pub(crate) fn stability(&self, tcx: TyCtxt<'_>) -> Option<Stability>
Returns the effective stability of the item.
This method should only be called after the propagate-stability
pass has been run.
pub(crate) fn const_stability(&self, tcx: TyCtxt<'_>) -> Option<ConstStability>
pub(crate) fn deprecation(&self, tcx: TyCtxt<'_>) -> Option<Deprecation>
pub(crate) fn inner_docs(&self, tcx: TyCtxt<'_>) -> bool
pub(crate) fn span(&self, tcx: TyCtxt<'_>) -> Option<Span>
pub(crate) fn attr_span(&self, tcx: TyCtxt<'_>) -> Span
Sourcepub(crate) fn doc_value(&self) -> String
pub(crate) fn doc_value(&self) -> String
Combine all doc strings into a single value handling indentation and newlines as needed.
Sourcepub(crate) fn opt_doc_value(&self) -> Option<String>
pub(crate) fn opt_doc_value(&self) -> Option<String>
Combine all doc strings into a single value handling indentation and newlines as needed.
Returns None
is there’s no documentation at all, and Some("")
if there is some
documentation but it is empty (e.g. #[doc = ""]
).
pub(crate) fn from_def_id_and_parts( def_id: DefId, name: Option<Symbol>, kind: ItemKind, cx: &mut DocContext<'_>, ) -> Item
pub(crate) fn from_def_id_and_attrs_and_parts( def_id: DefId, name: Option<Symbol>, kind: ItemKind, attrs: Attributes, cfg: Option<Arc<Cfg>>, ) -> Item
pub(crate) fn links(&self, cx: &Context<'_>) -> Vec<RenderedLink>
Sourcepub(crate) fn link_names(&self, cache: &Cache) -> Vec<RenderedLink>
pub(crate) fn link_names(&self, cache: &Cache) -> Vec<RenderedLink>
Find a list of all link names, without finding their href.
This is used for generating summary text, which does not include
the link text, but does need to know which []
-bracketed names
are actually links.
pub(crate) fn is_crate(&self) -> bool
pub(crate) fn is_mod(&self) -> bool
pub(crate) fn is_struct(&self) -> bool
pub(crate) fn is_enum(&self) -> bool
pub(crate) fn is_variant(&self) -> bool
pub(crate) fn is_associated_type(&self) -> bool
pub(crate) fn is_ty_associated_type(&self) -> bool
pub(crate) fn is_associated_const(&self) -> bool
pub(crate) fn is_ty_associated_const(&self) -> bool
pub(crate) fn is_method(&self) -> bool
pub(crate) fn is_ty_method(&self) -> bool
pub(crate) fn is_primitive(&self) -> bool
pub(crate) fn is_union(&self) -> bool
pub(crate) fn is_import(&self) -> bool
pub(crate) fn is_extern_crate(&self) -> bool
pub(crate) fn is_keyword(&self) -> bool
pub(crate) fn is_stripped(&self) -> bool
pub(crate) fn has_stripped_entries(&self) -> Option<bool>
pub(crate) fn stability_class(&self, tcx: TyCtxt<'_>) -> Option<String>
pub(crate) fn stable_since(&self, tcx: TyCtxt<'_>) -> Option<StableSince>
pub(crate) fn is_non_exhaustive(&self) -> bool
pub(crate) fn is_default(&self) -> bool
Sourcepub(crate) fn fn_header(&self, tcx: TyCtxt<'_>) -> Option<FnHeader>
pub(crate) fn fn_header(&self, tcx: TyCtxt<'_>) -> Option<FnHeader>
Returns a FnHeader
if self
is a function item, otherwise returns None
.
Sourcepub(crate) fn visibility(&self, tcx: TyCtxt<'_>) -> Option<Visibility<DefId>>
pub(crate) fn visibility(&self, tcx: TyCtxt<'_>) -> Option<Visibility<DefId>>
Returns the visibility of the current item. If the visibility is “inherited”, then None
is returned.
pub(crate) fn attributes( &self, tcx: TyCtxt<'_>, cache: &Cache, keep_as_is: bool, ) -> Vec<String>
pub fn def_id(&self) -> Option<DefId>
Trait Implementations§
Source§impl Debug for Item
impl Debug for Item
NOTE: this does NOT unconditionally print every item, to avoid thousands of lines of logs.
If you want to see the debug output for attributes and the kind
as well, use {:#?}
instead of {:?}
.
Source§impl<'a> From<&'a Item> for ModuleLike
impl<'a> From<&'a Item> for ModuleLike
Source§fn from(it: &'a Item) -> ModuleLike
fn from(it: &'a Item) -> ModuleLike
Auto Trait Implementations§
impl Freeze for Item
impl !RefUnwindSafe for Item
impl !Send for Item
impl !Sync for Item
impl Unpin 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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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 moreSource§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 48 bytes