fn find_implied_output_region(input_tys: &[Ty], input_pats: Vec<String>)
                              -> (Option<ty::Region>, Vec<(String, uint)>)
{
    let mut lifetimes_for_params: Vec<(String, uint)> = Vec::new();
    let mut possible_implied_output_region = None;

    for (input_type, input_pat) in input_tys.iter().zip(input_pats.into_iter()) {
        let mut accumulator = Vec::new();
        ty::accumulate_lifetimes_in_type(&mut accumulator, *input_type);

        if accumulator.len() == 1 {
            // there's a chance that the unique lifetime of this
            // iteration will be the appropriate lifetime for output
            // parameters, so lets store it.
            possible_implied_output_region = Some(accumulator[0])
        }

        lifetimes_for_params.push((input_pat, accumulator.len()));
    }

    let implied_output_region = if lifetimes_for_params.iter().map(|&(_, n)| n).sum() == 1 {
        assert!(possible_implied_output_region.is_some());
        possible_implied_output_region
    } else {
        None
    };
    (implied_output_region, lifetimes_for_params)
}
/// Returns the appropriate lifetime to use for any output lifetimes
/// (if one exists) and a vector of the (pattern, number of lifetimes)
/// corresponding to each input type/pattern.
Returns the appropriate lifetime to use for any output lifetimes
(if one exists) and a vector of the (pattern, number of lifetimes)
corresponding to each input type/pattern.
Returns the appropriate lifetime to use for any output lifetimes ( if one exists ) and a vector of the ( pattern number of lifetimes ) corresponding to each input type / pattern .
fn find_implied_output_region(input_tys: &[Ty], input_pats: Vec<String>)
                              -> (Option<ty::Region>, Vec<(String, uint)>)
{
    let mut lifetimes_for_params: Vec<(String, uint)> = Vec::new();
    let mut possible_implied_output_region = None;
    for (input_type, input_pat) in input_tys.iter().zip(input_pats.into_iter()) {
        let mut accumulator = Vec::new();
        ty::accumulate_lifetimes_in_type(&mut accumulator, *input_type);
        if accumulator.len() == 1 {
            // there's a chance that the unique lifetime of this
            // iteration will be the appropriate lifetime for output
            // parameters, so lets store it.
            possible_implied_output_region = Some(accumulator[0])
        }
        lifetimes_for_params.push((input_pat, accumulator.len()));
    }
    let implied_output_region = if lifetimes_for_params.iter().map(|&(_, n)| n).sum() == 1 {
        assert!(possible_implied_output_region.is_some());
        possible_implied_output_region
    } else {
        None
    };
    (implied_output_region, lifetimes_for_params)
}
fn find_implied_output_region ( input_tys : & [ Ty ] , input_pats : Vec < String > ) -> ( Option < ty :: Region > , Vec < ( String , uint ) > ) { let mut lifetimes_for_params : Vec < ( String , uint ) > = Vec :: new ( ) ; let mut possible_implied_output_region = None ; for ( input_type , input_pat ) in input_tys . iter ( ) . zip ( input_pats . into_iter ( ) ) { let mut accumulator = Vec :: new ( ) ; ty :: accumulate_lifetimes_in_type ( & mut accumulator , * input_type ) ; if accumulator . len ( ) == 1 { // there's a chance that the unique lifetime of this // iteration will be the appropriate lifetime for output // parameters, so lets store it. possible_implied_output_region = Some ( accumulator [ 0 ] ) } lifetimes_for_params . push ( ( input_pat , accumulator . len ( ) ) ) ; } let implied_output_region = if lifetimes_for_params . iter ( ) . map ( | & ( _ , n ) | n ) . sum ( ) == 1 { assert ! ( possible_implied_output_region is_some ( ) ) ; possible_implied_output_region } else { None } ; ( implied_output_region , lifetimes_for_params ) }
Returns the appropriate lifetime to use for any output lifetimes
(if one exists) and a vector of the (pattern, number of lifetimes)
corresponding to each input type/pattern.
Returns the appropriate lifetime to use for any output lifetimes ( if one exists ) and a vector of the ( pattern number of lifetimes ) corresponding to each input type / pattern .
input_tys
&[Ty]
input_pats
Vec<String>