@@ -174,7 +174,7 @@ pub enum FixtureMeta {
174174#[ derive( Debug , Eq , PartialEq ) ]
175175pub struct FileMeta {
176176 pub path : RelativePathBuf ,
177- pub krate : Option < String > ,
177+ pub crate_name : Option < String > ,
178178 pub deps : Vec < String > ,
179179 pub cfg : CfgOptions ,
180180 pub edition : Option < String > ,
@@ -189,12 +189,52 @@ impl FixtureMeta {
189189 }
190190 }
191191
192+ pub fn crate_name ( & self ) -> Option < & String > {
193+ match self {
194+ FixtureMeta :: File ( f) => f. crate_name . as_ref ( ) ,
195+ _ => None ,
196+ }
197+ }
198+
192199 pub fn cfg_options ( & self ) -> Option < & CfgOptions > {
193200 match self {
194201 FixtureMeta :: File ( f) => Some ( & f. cfg ) ,
195202 _ => None ,
196203 }
197204 }
205+
206+ pub fn edition ( & self ) -> Option < & String > {
207+ match self {
208+ FixtureMeta :: File ( f) => f. edition . as_ref ( ) ,
209+ _ => None ,
210+ }
211+ }
212+
213+ pub fn env ( & self ) -> impl Iterator < Item = ( & String , & String ) > {
214+ struct EnvIter < ' a > {
215+ iter : Option < std:: collections:: hash_map:: Iter < ' a , String , String > > ,
216+ }
217+
218+ impl < ' a > EnvIter < ' a > {
219+ fn new ( meta : & ' a FixtureMeta ) -> Self {
220+ Self {
221+ iter : match meta {
222+ FixtureMeta :: File ( f) => Some ( f. env . iter ( ) ) ,
223+ _ => None ,
224+ } ,
225+ }
226+ }
227+ }
228+
229+ impl < ' a > Iterator for EnvIter < ' a > {
230+ type Item = ( & ' a String , & ' a String ) ;
231+ fn next ( & mut self ) -> Option < Self :: Item > {
232+ self . iter . as_mut ( ) . and_then ( |i| i. next ( ) )
233+ }
234+ }
235+
236+ EnvIter :: new ( self )
237+ }
198238}
199239
200240/// Parses text which looks like this:
@@ -289,7 +329,7 @@ fn parse_meta(meta: &str) -> FixtureMeta {
289329 }
290330 }
291331
292- FixtureMeta :: File ( FileMeta { path, krate, deps, edition, cfg, env } )
332+ FixtureMeta :: File ( FileMeta { path, crate_name : krate, deps, edition, cfg, env } )
293333}
294334
295335fn split1 ( haystack : & str , delim : char ) -> Option < ( & str , & str ) > {
0 commit comments