fn collapse_candidates_to_trait_pick(&self,
                                         probes: &[&Candidate<'tcx>])
                                         -> Option<Pick<'tcx>> {
        // Do all probes correspond to the same trait?
        let container = probes[0].item.container();
        match container {
            ty::TraitContainer(_) => {}
            ty::ImplContainer(_) => return None
        }
        if probes[1..].iter().any(|p| p.item.container() != container) {
            return None;
        }

        // If so, just use this trait and call it a day.
        Some(Pick {
            item: probes[0].item.clone(),
            kind: TraitPick,
            autoderefs: 0,
            autoref: None,
            unsize: None
        })
    }
/// Sometimes we get in a situation where we have multiple probes that are all impls of the
/// same trait, but we don't know which impl to use. In this case, since in all cases the
/// external interface of the method can be determined from the trait, it's ok not to decide.
/// We can basically just collapse all of the probes for various impls into one where-clause
/// probe. This will result in a pending obligation so when more type-info is available we can
/// make the final decision.
///
/// Example (`src/test/run-pass/method-two-trait-defer-resolution-1.rs`):
///
/// ```
/// trait Foo { ... }
/// impl Foo for Vec<int> { ... }
/// impl Foo for Vec<usize> { ... }
/// ```
///
/// Now imagine the receiver is `Vec<_>`. It doesn't really matter at this time which impl we
/// use, so it's ok to just commit to "using the method from the trait Foo".
Sometimes we get in a situation where we have multiple probes that are all impls of the
same trait, but we don't know which impl to use. In this case, since in all cases the
external interface of the method can be determined from the trait, it's ok not to decide.
We can basically just collapse all of the probes for various impls into one where-clause
probe. This will result in a pending obligation so when more type-info is available we can
make the final decision.





Now imagine the receiver is `Vec<_>`. It doesn't really matter at this time which impl we
use, so it's ok to just commit to "using the method from the trait Foo".
Sometimes we get in a situation where we have multiple probes that are all impls of the same trait but we don ' t know which impl to use . In this case since in all cases the external interface of the method can be determined from the trait it ' s ok not to decide . We can basically just collapse all of the probes for various impls into one where - clause probe . This will result in a pending obligation so when more type - info is available we can make the final decision . Now imagine the receiver is ` Vec<_ > ` . It doesn ' t really matter at this time which impl we use so it ' s ok to just commit to " using the method from the trait Foo " .
fn collapse_candidates_to_trait_pick(&self,
                                         probes: &[&Candidate<'tcx>])
                                         -> Option<Pick<'tcx>> {
        // Do all probes correspond to the same trait?
        let container = probes[0].item.container();
        match container {
            ty::TraitContainer(_) => {}
            ty::ImplContainer(_) => return None
        }
        if probes[1..].iter().any(|p| p.item.container() != container) {
            return None;
        }
        // If so, just use this trait and call it a day.
        Some(Pick {
            item: probes[0].item.clone(),
            kind: TraitPick,
            autoderefs: 0,
            autoref: None,
            unsize: None
        })
    }
fn collapse_candidates_to_trait_pick ( & self , probes : & [ & Candidate < ' tcx > ] ) -> Option < Pick < ' tcx > > { // Do all probes correspond to the same trait? let container = probes [ 0 ] . item . container ( ) ; match container { ty :: TraitContainer ( _ ) => { } ty :: ImplContainer ( _ ) => return None } if probes [ 1 .. ] . iter ( ) . any ( | p | p . item . container ( ) != container ) { return None ; } // If so, just use this trait and call it a day. Some ( Pick { item : probes [ 0 ] . item . clone ( ) , kind : TraitPick , autoderefs : 0 , autoref : None , unsize : None } ) }
Sometimes we get in a situation where we have multiple probes that are all impls of the
same trait, but we don't know which impl to use.
Sometimes we get in a situation where we have multiple probes that are all impls of the same trait but we don ' t know which impl to use .
&self
probes
&[&Candidate<'tcx>]
&self
probes
&[&Candidate<'tcx>]