fn parse_str(&mut self) -> Result<String, ()> {
        fn lit_is_str(lit: &ast::Lit) -> bool {
            match lit.node {
                ast::LitStr(_, _) => true,
                _ => false,
            }
        }
        fn lit_to_string(lit: &ast::Lit) -> String {
            match lit.node {
                ast::LitStr(ref s, _) => s.to_string(),
                _ => panic!("BUG: expected string literal"),
            }
        }
        let exp = self.cx.expander().fold_expr(self.p.parse_expr());
        let s = match exp.node {
            ast::ExprLit(ref lit) if lit_is_str(&**lit) => {
                lit_to_string(&**lit)
            }
            _ => {
                let err = format!("Expected string literal but got {}",
                                  pprust::expr_to_string(&*exp));
                self.cx.span_err(exp.span, err.as_slice());
                return Err(());
            }
        };
        self.p.bump();
        Ok(s)
    }
/// Parses a single string literal. On failure, an error is logged and
/// unit is returned.
Parses a single string literal. On failure, an error is logged and
unit is returned.
Parses a single string literal . On failure an error is logged and unit is returned .
fn parse_str(&mut self) -> Result<String, ()> {
        fn lit_is_str(lit: &ast::Lit) -> bool {
            match lit.node {
                ast::LitStr(_, _) => true,
                _ => false,
            }
        }
        fn lit_to_string(lit: &ast::Lit) -> String {
            match lit.node {
                ast::LitStr(ref s, _) => s.to_string(),
                _ => panic!("BUG: expected string literal"),
            }
        }
        let exp = self.cx.expander().fold_expr(self.p.parse_expr());
        let s = match exp.node {
            ast::ExprLit(ref lit) if lit_is_str(&**lit) => {
                lit_to_string(&**lit)
            }
            _ => {
                let err = format!("Expected string literal but got {}",
                                  pprust::expr_to_string(&*exp));
                self.cx.span_err(exp.span, err.as_slice());
                return Err(());
            }
        };
        self.p.bump();
        Ok(s)
    }
fn parse_str ( & mut self ) -> Result < String , ( ) > { fn lit_is_str ( lit : & ast :: Lit ) -> bool { match lit . node { ast :: LitStr ( _ , _ ) => true , _ => false , } } fn lit_to_string ( lit : & ast :: Lit ) -> String { match lit . node { ast :: LitStr ( ref s , _ ) => s . to_string ( ) , _ => panic ! ( " " ) , } } let exp = self . cx . expander ( ) . fold_expr ( self . p . parse_expr ( ) ) ; let s = match exp . node { ast :: ExprLit ( ref lit ) if lit_is_str ( & * * lit ) => { lit_to_string ( & * * lit ) } _ => { let err = format ! ( " " pprust expr_to_string ( exp ) ) ; self . cx . span_err ( exp . span , err . as_slice ( ) ) ; return Err ( ( ) ) ; } } ; self . p . bump ( ) ; Ok ( s ) }
Parses a single string literal.
Parses a single string literal .
&mut self
&mut self