fn from_source_str(source: &str) -> Option<MethodInfo> {
        let trim: &[_] = &['\n', '\r', '{', ' '];
        let decorated = format!("{} {{}}()", source.trim_right_matches(trim));

        with_error_checking_parse(decorated, |p| {
            use std::result::Result::{Ok, Err};
            use syntex_syntax::diagnostic::FatalError;
            match p.parse_impl_item() {
                Ok(method) => {
                    match method.node {
                        ImplItem_::MethodImplItem(ref msig, _) => {
                            let ref decl = msig.decl;
                            Some(MethodInfo {
                                // ident.as_str calls Ident.name.as_str
                                name: method.ident.as_str().to_string(),
                                args: decl.inputs.iter().map(|arg| {
                                    let ref codemap = p.sess.span_diagnostic.cm;
                                    match codemap.span_to_snippet(arg.pat.span) {
                                        Ok(name) => name,
                                        _ => "".to_string()
                                    }
                                }).collect(),
                            })
                        },
                        _ => {
                            debug!("Unable to parse method declaration. |{}|", source);
                            return None;
                        }
                    }
                },
                Err(FatalError) => {
                    debug!("Unable to parse method declaration. |{}|",source);
                    return None;
                }
            }
        })
    }
///Parses method declaration as string and returns relevant data
Parses method declaration as string and returns relevant data
Parses method declaration as string and returns relevant data
fn from_source_str(source: &str) -> Option<MethodInfo> {
        let trim: &[_] = &['\n', '\r', '{', ' '];
        let decorated = format!("{} {{}}()", source.trim_right_matches(trim));
        with_error_checking_parse(decorated, |p| {
            use std::result::Result::{Ok, Err};
            use syntex_syntax::diagnostic::FatalError;
            match p.parse_impl_item() {
                Ok(method) => {
                    match method.node {
                        ImplItem_::MethodImplItem(ref msig, _) => {
                            let ref decl = msig.decl;
                            Some(MethodInfo {
                                // ident.as_str calls Ident.name.as_str
                                name: method.ident.as_str().to_string(),
                                args: decl.inputs.iter().map(|arg| {
                                    let ref codemap = p.sess.span_diagnostic.cm;
                                    match codemap.span_to_snippet(arg.pat.span) {
                                        Ok(name) => name,
                                        _ => "".to_string()
                                    }
                                }).collect(),
                            })
                        },
                        _ => {
                            debug!("Unable to parse method declaration. |{}|", source);
                            return None;
                        }
                    }
                },
                Err(FatalError) => {
                    debug!("Unable to parse method declaration. |{}|",source);
                    return None;
                }
            }
        })
    }
fn from_source_str ( source : & str ) -> Option < MethodInfo > { let trim : & [ _ ] = & [ '\n' , '\r' , '{' , ' ' ] ; let decorated = format ! ( " " source trim_right_matches ( trim ) ) ; with_error_checking_parse ( decorated , | p | { use std :: result :: Result :: { Ok , Err } ; use syntex_syntax :: diagnostic :: FatalError ; match p . parse_impl_item ( ) { Ok ( method ) => { match method . node { ImplItem_ :: MethodImplItem ( ref msig , _ ) => { let ref decl = msig . decl ; Some ( MethodInfo { // ident.as_str calls Ident.name.as_str name : method . ident . as_str ( ) . to_string ( ) , args : decl . inputs . iter ( ) . map ( | arg | { let ref codemap = p . sess . span_diagnostic . cm ; match codemap . span_to_snippet ( arg . pat . span ) { Ok ( name ) => name , _ => " " . to_string ( ) } } ) . collect ( ) , } ) } , _ => { debug ! ( " " source ) ; return None ; } } } , Err ( FatalError ) => { debug ! ( " " source ) ; return None ; } } } ) }
Parses method declaration as string and returns relevant data
Parses method declaration as string and returns relevant data
source
&str