pub fn trait_id_of_impl(tcx: ctxt,
                        def_id: ast::DefId) -> Option<ast::DefId> {
    let node = match tcx.items.find(def_id.node) {
        Some(node) => node,
        None => return None
    };
    match node {
        ast_map::NodeItem(item, _) => {
            match item.node {
                ast::ItemImpl(_, Some(ref trait_ref), _, _) => {
                    Some(node_id_to_trait_ref(tcx, trait_ref.ref_id).def_id)
                }
                _ => None
            }
        }
        _ => None
    }
}
/// Given the def_id of an impl, return the def_id of the trait it implements.
/// If it implements no trait, return `None`.
Given the def_id of an impl, return the def_id of the trait it implements.
If it implements no trait, return `None`.
Given the def_id of an impl return the def_id of the trait it implements . If it implements no trait return ` None ` .
pub fn trait_id_of_impl(tcx: ctxt,
                        def_id: ast::DefId) -> Option<ast::DefId> {
    let node = match tcx.items.find(def_id.node) {
        Some(node) => node,
        None => return None
    };
    match node {
        ast_map::NodeItem(item, _) => {
            match item.node {
                ast::ItemImpl(_, Some(ref trait_ref), _, _) => {
                    Some(node_id_to_trait_ref(tcx, trait_ref.ref_id).def_id)
                }
                _ => None
            }
        }
        _ => None
    }
}
pub fn trait_id_of_impl ( tcx : ctxt , def_id : ast :: DefId ) -> Option < ast :: DefId > { let node = match tcx . items . find ( def_id . node ) { Some ( node ) => node , None => return None } ; match node { ast_map :: NodeItem ( item , _ ) => { match item . node { ast :: ItemImpl ( _ , Some ( ref trait_ref ) , _ , _ ) => { Some ( node_id_to_trait_ref ( tcx , trait_ref . ref_id ) . def_id ) } _ => None } } _ => None } }
Given the def_id of an impl, return the def_id of the trait it implements.
Given the def_id of an impl return the def_id of the trait it implements .
tcx
ctxt
def_id
ast::DefId
tcx
ctxt
def_id
ast::DefId