1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
16 /// Item type. Corresponds to `clean::ItemEnum` variants.
18 /// The search index uses item types encoded as smaller numbers which equal to
19 /// discriminants. JavaScript then is used to decode them into the original value.
20 /// Consequently, every change to this type should be synchronized to
21 /// the `itemTypes` mapping table in `static/main.js`.
22 #[deriving(PartialEq, Clone)]
44 pub fn to_static_str(&self) -> &'static str {
54 ViewItem => "viewitem",
55 TyMethod => "tymethod",
57 StructField => "structfield",
59 ForeignFunction => "ffi",
60 ForeignStatic => "ffs",
62 Primitive => "primitive",
67 impl fmt::Show for ItemType {
68 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
69 self.to_static_str().fmt(f)
73 impl fmt::Unsigned for ItemType {
74 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
75 (*self as uint).fmt(f)
79 pub fn shortty(item: &clean::Item) -> ItemType {
81 clean::ModuleItem(..) => Module,
82 clean::StructItem(..) => Struct,
83 clean::EnumItem(..) => Enum,
84 clean::FunctionItem(..) => Function,
85 clean::TypedefItem(..) => Typedef,
86 clean::StaticItem(..) => Static,
87 clean::TraitItem(..) => Trait,
88 clean::ImplItem(..) => Impl,
89 clean::ViewItemItem(..) => ViewItem,
90 clean::TyMethodItem(..) => TyMethod,
91 clean::MethodItem(..) => Method,
92 clean::StructFieldItem(..) => StructField,
93 clean::VariantItem(..) => Variant,
94 clean::ForeignFunctionItem(..) => ForeignFunction,
95 clean::ForeignStaticItem(..) => ForeignStatic,
96 clean::MacroItem(..) => Macro,
97 clean::PrimitiveItem(..) => Primitive,