@@ -42,6 +42,14 @@ pub enum ItemType {
4242 AssociatedConst = 18 ,
4343}
4444
45+
46+ #[ derive( Copy , Eq , PartialEq , Clone ) ]
47+ pub enum NameSpace {
48+ Type ,
49+ Value ,
50+ Macro ,
51+ }
52+
4553impl ItemType {
4654 pub fn from_item ( item : & clean:: Item ) -> ItemType {
4755 let inner = match item. inner {
@@ -113,10 +121,50 @@ impl ItemType {
113121 ItemType :: AssociatedConst => "associatedconstant" ,
114122 }
115123 }
124+
125+ pub fn name_space ( & self ) -> NameSpace {
126+ match * self {
127+ ItemType :: Struct |
128+ ItemType :: Enum |
129+ ItemType :: Module |
130+ ItemType :: Typedef |
131+ ItemType :: Trait |
132+ ItemType :: Primitive |
133+ ItemType :: AssociatedType => NameSpace :: Type ,
134+
135+ ItemType :: ExternCrate |
136+ ItemType :: Import |
137+ ItemType :: Function |
138+ ItemType :: Static |
139+ ItemType :: Impl |
140+ ItemType :: TyMethod |
141+ ItemType :: Method |
142+ ItemType :: StructField |
143+ ItemType :: Variant |
144+ ItemType :: Constant |
145+ ItemType :: AssociatedConst => NameSpace :: Value ,
146+
147+ ItemType :: Macro => NameSpace :: Macro ,
148+ }
149+ }
116150}
117151
118152impl fmt:: Display for ItemType {
119153 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
120154 self . css_class ( ) . fmt ( f)
121155 }
122156}
157+
158+ pub const NAMESPACE_TYPE : & ' static str = "t" ;
159+ pub const NAMESPACE_VALUE : & ' static str = "v" ;
160+ pub const NAMESPACE_MACRO : & ' static str = "m" ;
161+
162+ impl NameSpace {
163+ pub fn to_static_str ( & self ) -> & ' static str {
164+ match * self {
165+ NameSpace :: Type => NAMESPACE_TYPE ,
166+ NameSpace :: Value => NAMESPACE_VALUE ,
167+ NameSpace :: Macro => NAMESPACE_MACRO ,
168+ }
169+ }
170+ }
0 commit comments