async fn filter_instances<F: Fn(&Instance, ) -> bool>(ec2:&Ec2Client, filter:&F) -> Option<Vec<Instance>> {
        let desc_res = Self::describe_instances(ec2).await;

        let mut matches:Vec<Instance> = vec![];
        //I don't really know what a reservation is but apparently you can get more than one?
        for reservation in &desc_res.reservations? {
            let mut res_matches: Vec<Instance> = reservation.instances.clone()?
                .into_iter()
                .filter(|instance|filter(&instance))
                .collect::<Vec<Instance>>();
            matches.extend(res_matches.into_iter());
        }
        return if !matches.is_empty() {
            Some(matches)
        }
        else{
            None
        };
    }
/// filters all instances by given filter
filters all instances by given filter
filters all instances by given filter
async fn filter_instances<F: Fn(&Instance, ) -> bool>(ec2:&Ec2Client, filter:&F) -> Option<Vec<Instance>> {
        let desc_res = Self::describe_instances(ec2).await;
        let mut matches:Vec<Instance> = vec![];
        //I don't really know what a reservation is but apparently you can get more than one?
        for reservation in &desc_res.reservations? {
            let mut res_matches: Vec<Instance> = reservation.instances.clone()?
                .into_iter()
                .filter(|instance|filter(&instance))
                .collect::<Vec<Instance>>();
            matches.extend(res_matches.into_iter());
        }
        return if !matches.is_empty() {
            Some(matches)
        }
        else{
            None
        };
    }
async fn filter_instances < F : Fn ( & Instance , ) -> bool > ( ec2 : & Ec2Client , filter : & F ) -> Option < Vec < Instance > > { let desc_res = Self :: describe_instances ( ec2 ) . await ; let mut matches : Vec < Instance > = vec ! [ ] ; //I don't really know what a reservation is but apparently you can get more than one? for reservation in & desc_res . reservations ? { let mut res_matches : Vec < Instance > = reservation . instances . clone ( ) ? . into_iter ( ) . filter ( | instance | filter ( & instance ) ) . collect :: < Vec < Instance > > ( ) ; matches . extend ( res_matches . into_iter ( ) ) ; } return if ! matches . is_empty ( ) { Some ( matches ) } else { None } ; }
filters all instances by given filter
filters all instances by given filter
ec2
&Ec2Client
filter
&F