fn parse(&mut self) -> Result<Parsed, ()> {
        if self.p.token == token::Eof {
            self.cx.span_err(self.cx.call_site(), "macro expects arguments");
            return Err(());
        }
        let struct_info = try!(self.parse_struct_info());
        let docstr = try!(self.parse_str());

        let sep = SeqSep {
            sep: Some(token::Comma),
            trailing_sep_allowed: true,
        };
        let types = self.p.parse_seq_to_end(
            &token::Eof, sep, |p| MacParser::parse_type_annotation(p)
        ).into_iter()
         .map(|(ident, ty)| {
             let field_name = token::get_ident(ident).to_string();
             let key = ArgvMap::struct_field_to_key(field_name.as_slice());
             (Atom::new(key.as_slice()), ty)
          })
         .collect::<HashMap<Atom, P<ast::Ty>>>();
        self.p.expect(&token::Eof);

        // This config does not matter because we're only asking for the
        // usage patterns in the Docopt string. The configuration does not
        // affect the retrieval of usage patterns.
        let doc = match Docopt::new(docstr) {
            Ok(doc) => doc,
            Err(err) => {
                self.cx.span_err(self.cx.call_site(),
                                 format!("Invalid Docopt usage: {}",
                                         err).as_slice());
                return Err(());
            }
        };
        Ok(Parsed {
            struct_info: struct_info,
            doc: doc,
            types: types,
        })
    }
/// Main entry point for parsing arguments to `docopt` macro.
/// First looks for an identifier for the struct name.
/// Second, a string containing the docopt usage patterns.
/// Third, an optional list of type annotations.
Main entry point for parsing arguments to `docopt` macro.
First looks for an identifier for the struct name.
Second, a string containing the docopt usage patterns.
Third, an optional list of type annotations.
Main entry point for parsing arguments to ` docopt ` macro . First looks for an identifier for the struct name . Second a string containing the docopt usage patterns . Third an optional list of type annotations .
fn parse(&mut self) -> Result<Parsed, ()> {
        if self.p.token == token::Eof {
            self.cx.span_err(self.cx.call_site(), "macro expects arguments");
            return Err(());
        }
        let struct_info = try!(self.parse_struct_info());
        let docstr = try!(self.parse_str());
        let sep = SeqSep {
            sep: Some(token::Comma),
            trailing_sep_allowed: true,
        };
        let types = self.p.parse_seq_to_end(
            &token::Eof, sep, |p| MacParser::parse_type_annotation(p)
        ).into_iter()
         .map(|(ident, ty)| {
             let field_name = token::get_ident(ident).to_string();
             let key = ArgvMap::struct_field_to_key(field_name.as_slice());
             (Atom::new(key.as_slice()), ty)
          })
         .collect::<HashMap<Atom, P<ast::Ty>>>();
        self.p.expect(&token::Eof);
        // This config does not matter because we're only asking for the
        // usage patterns in the Docopt string. The configuration does not
        // affect the retrieval of usage patterns.
        let doc = match Docopt::new(docstr) {
            Ok(doc) => doc,
            Err(err) => {
                self.cx.span_err(self.cx.call_site(),
                                 format!("Invalid Docopt usage: {}",
                                         err).as_slice());
                return Err(());
            }
        };
        Ok(Parsed {
            struct_info: struct_info,
            doc: doc,
            types: types,
        })
    }
fn parse ( & mut self ) -> Result < Parsed , ( ) > { if self . p . token == token :: Eof { self . cx . span_err ( self . cx . call_site ( ) , " " ) ; return Err ( ( ) ) ; } let struct_info = try ! ( self parse_struct_info ( ) ) ; let docstr = try ! ( self parse_str ( ) ) ; let sep = SeqSep { sep : Some ( token :: Comma ) , trailing_sep_allowed : true , } ; let types = self . p . parse_seq_to_end ( & token :: Eof , sep , | p | MacParser :: parse_type_annotation ( p ) ) . into_iter ( ) . map ( | ( ident , ty ) | { let field_name = token :: get_ident ( ident ) . to_string ( ) ; let key = ArgvMap :: struct_field_to_key ( field_name . as_slice ( ) ) ; ( Atom :: new ( key . as_slice ( ) ) , ty ) } ) . collect :: < HashMap < Atom , P < ast :: Ty > > > ( ) ; self . p . expect ( & token :: Eof ) ; // This config does not matter because we're only asking for the // usage patterns in the Docopt string. The configuration does not // affect the retrieval of usage patterns. let doc = match Docopt :: new ( docstr ) { Ok ( doc ) => doc , Err ( err ) => { self . cx . span_err ( self . cx . call_site ( ) , format ! ( " " err ) . as_slice ( ) ) ; return Err ( ( ) ) ; } } ; Ok ( Parsed { struct_info : struct_info , doc : doc , types : types , } ) }
Main entry point for parsing arguments to `docopt` macro.
Main entry point for parsing arguments to ` docopt ` macro .
&mut self
&mut self