pub fn trait_method_of_method(tcx: ctxt,
                              def_id: ast::DefId) -> Option<ast::DefId> {
    let method;
    {
        let methods = tcx.methods.borrow();
        match methods.get().find(&def_id) {
            Some(m) => method = *m,
            None => return None,
        }
    }
    let name = method.ident.name;
    match trait_of_method(tcx, def_id) {
        Some(trait_did) => {
            let trait_methods = ty::trait_methods(tcx, trait_did);
            trait_methods.iter()
                .position(|m| m.ident.name == name)
                .map(|idx| ty::trait_method(tcx, trait_did, idx).def_id)
        }
        None => None
    }
}
/// If the given def ID describes a method belonging to a trait, (either a
/// default method or an implementation of a trait method), return the ID of
/// the method inside trait definition (this means that if the given def ID
/// is already that of the original trait method, then the return value is
/// the same).
/// Otherwise, return `None`.
If the given def ID describes a method belonging to a trait, (either a
default method or an implementation of a trait method), return the ID of
the method inside trait definition (this means that if the given def ID
is already that of the original trait method, then the return value is
the same).
Otherwise, return `None`.
If the given def ID describes a method belonging to a trait ( either a default method or an implementation of a trait method ) return the ID of the method inside trait definition ( this means that if the given def ID is already that of the original trait method then the return value is the same ) . Otherwise return ` None ` .
pub fn trait_method_of_method(tcx: ctxt,
                              def_id: ast::DefId) -> Option<ast::DefId> {
    let method;
    {
        let methods = tcx.methods.borrow();
        match methods.get().find(&def_id) {
            Some(m) => method = *m,
            None => return None,
        }
    }
    let name = method.ident.name;
    match trait_of_method(tcx, def_id) {
        Some(trait_did) => {
            let trait_methods = ty::trait_methods(tcx, trait_did);
            trait_methods.iter()
                .position(|m| m.ident.name == name)
                .map(|idx| ty::trait_method(tcx, trait_did, idx).def_id)
        }
        None => None
    }
}
pub fn trait_method_of_method ( tcx : ctxt , def_id : ast :: DefId ) -> Option < ast :: DefId > { let method ; { let methods = tcx . methods . borrow ( ) ; match methods . get ( ) . find ( & def_id ) { Some ( m ) => method = * m , None => return None , } } let name = method . ident . name ; match trait_of_method ( tcx , def_id ) { Some ( trait_did ) => { let trait_methods = ty :: trait_methods ( tcx , trait_did ) ; trait_methods . iter ( ) . position ( | m | m . ident . name == name ) . map ( | idx | ty :: trait_method ( tcx , trait_did , idx ) . def_id ) } None => None } }
If the given def ID describes a method belonging to a trait, (either a
default method or an implementation of a trait method), return the ID of
the method inside trait definition (this means that if the given def ID
is already that of the original trait method, then the return value is
the same).
If the given def ID describes a method belonging to a trait ( either a default method or an implementation of a trait method ) return the ID of the method inside trait definition ( this means that if the given def ID is already that of the original trait method then the return value is the same ) .
tcx
ctxt
def_id
ast::DefId
tcx
ctxt
def_id
ast::DefId