@@ -42,6 +42,14 @@ pub enum ItemType {
42
42
AssociatedConst = 18 ,
43
43
}
44
44
45
+
46
+ #[ derive( Copy , Eq , PartialEq , Clone ) ]
47
+ pub enum NameSpace {
48
+ Type ,
49
+ Value ,
50
+ Macro ,
51
+ }
52
+
45
53
impl ItemType {
46
54
pub fn from_item ( item : & clean:: Item ) -> ItemType {
47
55
let inner = match item. inner {
@@ -113,10 +121,50 @@ impl ItemType {
113
121
ItemType :: AssociatedConst => "associatedconstant" ,
114
122
}
115
123
}
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
+ }
116
150
}
117
151
118
152
impl fmt:: Display for ItemType {
119
153
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
120
154
self . css_class ( ) . fmt ( f)
121
155
}
122
156
}
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