@@ -29,13 +29,14 @@ pub struct CrateVersion(pub semver::Version);
29
29
pub struct CrateVersionReq ( pub semver:: VersionReq ) ;
30
30
pub struct KeywordList ( pub Vec < Keyword > ) ;
31
31
pub struct Keyword ( pub String ) ;
32
+ pub struct Feature ( pub String ) ;
32
33
33
34
#[ deriving( Decodable , Encodable ) ]
34
35
pub struct CrateDependency {
35
36
pub optional : bool ,
36
37
pub default_features : bool ,
37
38
pub name : CrateName ,
38
- pub features : Vec < CrateName > ,
39
+ pub features : Vec < Feature > ,
39
40
pub version_req : CrateVersionReq ,
40
41
pub target : Option < String > ,
41
42
pub kind : Option < DependencyKind > ,
@@ -63,6 +64,17 @@ impl<E, D: Decoder<E>> Decodable<D, E> for Keyword {
63
64
}
64
65
}
65
66
67
+ impl < E , D : Decoder < E > > Decodable < D , E > for Feature {
68
+ fn decode ( d : & mut D ) -> Result < Feature , E > {
69
+ let s = raw_try ! ( d. read_str( ) ) ;
70
+ if !Crate :: valid_feature_name ( s. as_slice ( ) ) {
71
+ return Err ( d. error ( format ! ( "invalid feature name specified: {}" ,
72
+ s) . as_slice ( ) ) )
73
+ }
74
+ Ok ( Feature ( s) )
75
+ }
76
+ }
77
+
66
78
impl < E , D : Decoder < E > > Decodable < D , E > for CrateVersion {
67
79
fn decode ( d : & mut D ) -> Result < CrateVersion , E > {
68
80
let s = raw_try ! ( d. read_str( ) ) ;
@@ -126,6 +138,12 @@ impl<E, D: Encoder<E>> Encodable<D, E> for Keyword {
126
138
}
127
139
}
128
140
141
+ impl < E , D : Encoder < E > > Encodable < D , E > for Feature {
142
+ fn encode ( & self , d : & mut D ) -> Result < ( ) , E > {
143
+ d. emit_str ( self . as_slice ( ) )
144
+ }
145
+ }
146
+
129
147
impl < E , D : Encoder < E > > Encodable < D , E > for CrateVersion {
130
148
fn encode ( & self , d : & mut D ) -> Result < ( ) , E > {
131
149
d. emit_str ( ( * * self ) . to_string ( ) . as_slice ( ) )
@@ -169,6 +187,13 @@ impl Deref<str> for Keyword {
169
187
}
170
188
}
171
189
190
+ impl Deref < str > for Feature {
191
+ fn deref < ' a > ( & ' a self ) -> & ' a str {
192
+ let Feature ( ref s) = * self ;
193
+ s. as_slice ( )
194
+ }
195
+ }
196
+
172
197
impl Deref < semver:: Version > for CrateVersion {
173
198
fn deref < ' a > ( & ' a self ) -> & ' a semver:: Version {
174
199
let CrateVersion ( ref s) = * self ; s
0 commit comments