fn split_lifetimes(
    generics: Generics,
    args: &Punctuated<FnArg, Token![,]>,
    rt: &ReturnType)
    -> (Generics, Generics, Generics)
{
    if generics.lt_token.is_none() {
        return (generics, Generics::default(), Generics::default());
    }

    // Check which lifetimes are referenced by the arguments
    let mut alts = HashSet::<Lifetime>::default();
    for arg in args {
        match arg {
            FnArg::Typed(pt) => {
                alts.extend(find_lifetimes(pt.ty.as_ref()))
            },
            _ => ()
        };
    };

    // Check which lifetimes are referenced by the return type
    let rlts = match rt {
        ReturnType::Default => HashSet::default(),
        ReturnType::Type(_, ty) => find_lifetimes(ty)
    };

    let mut tv = Vec::new();
    let mut alv = Vec::new();
    let mut rlv = Vec::new();
    for p in generics.params {
        match &p {
            GenericParam::Lifetime(ltd) if rlts.contains(&ltd.lifetime) &&
                                           alts.contains(&ltd.lifetime) =>
            {
                unimplemented!("Methods that return references to their arguments are TODO")
            },
            GenericParam::Lifetime(ltd) if alts.contains(&ltd.lifetime) =>
                alv.push(p),
            GenericParam::Lifetime(ltd) if rlts.contains(&ltd.lifetime) =>
                rlv.push(p),
            GenericParam::Lifetime(_) =>
                panic!("An unused lifetime parameter?"),
            _ => tv.push(p)
        }
    }

    let alg = lifetimes_to_generics(alv);
    let rlg = lifetimes_to_generics(rlv);

    let tg = if tv.is_empty() {
        Generics::default()
    } else {
        Generics {
            lt_token: generics.lt_token,
            gt_token: generics.gt_token,
            params: Punctuated::from_iter(tv.into_iter()),
            // XXX this assumes that none of the lifetimes are referenced by the
            // where clause
            where_clause: generics.where_clause
        }
    };

    (tg, alg, rlg)
}
/// Split a generics list into three: one for type generics, one for lifetime
/// generics that relate to the arguments, and one for lifetime generics that
/// relate to the return type.
Split a generics list into three: one for type generics, one for lifetime
generics that relate to the arguments, and one for lifetime generics that
relate to the return type.
Split a generics list into three : one for type generics one for lifetime generics that relate to the arguments and one for lifetime generics that relate to the return type .
fn split_lifetimes(
    generics: Generics,
    args: &Punctuated<FnArg, Token![,]>,
    rt: &ReturnType)
    -> (Generics, Generics, Generics)
{
    if generics.lt_token.is_none() {
        return (generics, Generics::default(), Generics::default());
    }
    // Check which lifetimes are referenced by the arguments
    let mut alts = HashSet::<Lifetime>::default();
    for arg in args {
        match arg {
            FnArg::Typed(pt) => {
                alts.extend(find_lifetimes(pt.ty.as_ref()))
            },
            _ => ()
        };
    };
    // Check which lifetimes are referenced by the return type
    let rlts = match rt {
        ReturnType::Default => HashSet::default(),
        ReturnType::Type(_, ty) => find_lifetimes(ty)
    };
    let mut tv = Vec::new();
    let mut alv = Vec::new();
    let mut rlv = Vec::new();
    for p in generics.params {
        match &p {
            GenericParam::Lifetime(ltd) if rlts.contains(&ltd.lifetime) &&
                                           alts.contains(&ltd.lifetime) =>
            {
                unimplemented!("Methods that return references to their arguments are TODO")
            },
            GenericParam::Lifetime(ltd) if alts.contains(&ltd.lifetime) =>
                alv.push(p),
            GenericParam::Lifetime(ltd) if rlts.contains(&ltd.lifetime) =>
                rlv.push(p),
            GenericParam::Lifetime(_) =>
                panic!("An unused lifetime parameter?"),
            _ => tv.push(p)
        }
    }
    let alg = lifetimes_to_generics(alv);
    let rlg = lifetimes_to_generics(rlv);
    let tg = if tv.is_empty() {
        Generics::default()
    } else {
        Generics {
            lt_token: generics.lt_token,
            gt_token: generics.gt_token,
            params: Punctuated::from_iter(tv.into_iter()),
            // XXX this assumes that none of the lifetimes are referenced by the
            // where clause
            where_clause: generics.where_clause
        }
    };
    (tg, alg, rlg)
}
fn split_lifetimes ( generics : Generics , args : & Punctuated < FnArg , Token ! [ ] > , rt : & ReturnType ) -> ( Generics , Generics , Generics ) { if generics . lt_token . is_none ( ) { return ( generics , Generics :: default ( ) , Generics :: default ( ) ) ; } // Check which lifetimes are referenced by the arguments let mut alts = HashSet :: < Lifetime > :: default ( ) ; for arg in args { match arg { FnArg :: Typed ( pt ) => { alts . extend ( find_lifetimes ( pt . ty . as_ref ( ) ) ) } , _ => ( ) } ; } ; // Check which lifetimes are referenced by the return type let rlts = match rt { ReturnType :: Default => HashSet :: default ( ) , ReturnType :: Type ( _ , ty ) => find_lifetimes ( ty ) } ; let mut tv = Vec :: new ( ) ; let mut alv = Vec :: new ( ) ; let mut rlv = Vec :: new ( ) ; for p in generics . params { match & p { GenericParam :: Lifetime ( ltd ) if rlts . contains ( & ltd . lifetime ) && alts . contains ( & ltd . lifetime ) => { unimplemented ! ( " " ) } , GenericParam :: Lifetime ( ltd ) if alts . contains ( & ltd . lifetime ) => alv . push ( p ) , GenericParam :: Lifetime ( ltd ) if rlts . contains ( & ltd . lifetime ) => rlv . push ( p ) , GenericParam :: Lifetime ( _ ) => panic ! ( " " ) , _ => tv . push ( p ) } } let alg = lifetimes_to_generics ( alv ) ; let rlg = lifetimes_to_generics ( rlv ) ; let tg = if tv . is_empty ( ) { Generics :: default ( ) } else { Generics { lt_token : generics . lt_token , gt_token : generics . gt_token , params : Punctuated :: from_iter ( tv . into_iter ( ) ) , // XXX this assumes that none of the lifetimes are referenced by the // where clause where_clause : generics . where_clause } } ; ( tg , alg , rlg ) }
Split a generics list into three: one for type generics, one for lifetime
generics that relate to the arguments, and one for lifetime generics that
relate to the return type.
Split a generics list into three : one for type generics one for lifetime generics that relate to the arguments and one for lifetime generics that relate to the return type .
generics
Generics
args
&Punctuated<FnArg, Token![,]>
rt
&ReturnType
generics
Generics
args
&Punctuated<FnArg, Token![,]>
rt
&ReturnType