#[repr(u8)]pub(crate) enum ItemType {
Show 25 variants
Keyword = 0,
Primitive = 1,
Module = 2,
ExternCrate = 3,
Import = 4,
Struct = 5,
Enum = 6,
Function = 7,
TypeAlias = 8,
Static = 9,
Trait = 10,
Impl = 11,
TyMethod = 12,
Method = 13,
StructField = 14,
Variant = 15,
Macro = 16,
AssocType = 17,
Constant = 18,
AssocConst = 19,
Union = 20,
ForeignType = 21,
ProcAttribute = 23,
ProcDerive = 24,
TraitAlias = 25,
}
Expand description
Item type. Corresponds to clean::ItemEnum
variants.
The search index uses item types encoded as smaller numbers which equal to
discriminants. JavaScript then is used to decode them into the original value.
Consequently, every change to this type should be synchronized to
the itemTypes
mapping table in html/static/js/search.js
.
The search engine in search.js also uses item type numbers as a tie breaker when sorting results. Keywords and primitives are given first because we want them to be easily found by new users who don’t know about advanced features like type filters. The rest are mostly in an arbitrary order, but it’s easier to test the search engine when it’s deterministic, and these are strictly finer-grained than language namespaces, so using the path and the item type together to sort ensures that search sorting is stable.
In addition, code in html::render
uses this enum to generate CSS classes, page prefixes, and
module headings. If you are adding to this enum and want to ensure that the sidebar also prints
a heading, edit the listing in html/render.rs
, function sidebar_module
. This uses an
ordering based on a helper function inside item_module
, in the same file.
Variants§
Keyword = 0
Primitive = 1
Module = 2
ExternCrate = 3
Import = 4
Struct = 5
Enum = 6
Function = 7
TypeAlias = 8
Static = 9
Trait = 10
Impl = 11
TyMethod = 12
Method = 13
StructField = 14
Variant = 15
Macro = 16
AssocType = 17
Constant = 18
AssocConst = 19
Union = 20
ForeignType = 21
ProcAttribute = 23
ProcDerive = 24
TraitAlias = 25
Implementations§
source§impl ItemType
impl ItemType
sourcepub(crate) fn from_def_kind(kind: DefKind, parent_kind: Option<DefKind>) -> Self
pub(crate) fn from_def_kind(kind: DefKind, parent_kind: Option<DefKind>) -> Self
Depending on the parent kind, some variants have a different translation (like a Method
becoming a TyMethod
).
pub(crate) fn as_str(&self) -> &'static str
pub(crate) fn is_method(&self) -> bool
pub(crate) fn is_adt(&self) -> bool
Trait Implementations§
source§impl FromClean<ItemType> for ItemKind
impl FromClean<ItemType> for ItemKind
fn from_clean(kind: ItemType, _renderer: &JsonRenderer<'_>) -> Self
source§impl Ord for ItemType
impl Ord for ItemType
source§impl PartialOrd for ItemType
impl PartialOrd for ItemType
impl Copy for ItemType
impl Eq for ItemType
impl StructuralPartialEq for ItemType
Auto Trait Implementations§
impl Freeze for ItemType
impl RefUnwindSafe for ItemType
impl Send for ItemType
impl Sync for ItemType
impl Unpin for ItemType
impl UnwindSafe for ItemType
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
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.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: 1 byte
Size for each variant:
Keyword
: 0 bytesPrimitive
: 0 bytesModule
: 0 bytesExternCrate
: 0 bytesImport
: 0 bytesStruct
: 0 bytesEnum
: 0 bytesFunction
: 0 bytesTypeAlias
: 0 bytesStatic
: 0 bytesTrait
: 0 bytesImpl
: 0 bytesTyMethod
: 0 bytesMethod
: 0 bytesStructField
: 0 bytesVariant
: 0 bytesMacro
: 0 bytesAssocType
: 0 bytesConstant
: 0 bytesAssocConst
: 0 bytesUnion
: 0 bytesForeignType
: 0 bytesProcAttribute
: 0 bytesProcDerive
: 0 bytesTraitAlias
: 0 bytes