pub fn delete_cidr(cidrs: &[Cidr], peers: &[Peer], request: &DeleteCidrOpts) -> Result<i64, Error> {
    let eligible_cidrs: Vec<_> = cidrs
        .iter()
        .filter(|cidr| {
            !peers.iter().any(|peer| peer.contents.cidr_id == cidr.id) &&
            !cidrs.iter().any(
                |cidr2| matches!(cidr2.contents.parent, Some(parent_id) if parent_id == cidr.id)
            )
        })
        .collect();
    let cidr = if let Some(ref name) = request.name {
        cidrs
            .iter()
            .find(|cidr| &cidr.name == name)
            .ok_or_else(|| anyhow!("CIDR {} doesn't exist or isn't eligible for deletion", name))?
    } else {
        select("Delete CIDR", &eligible_cidrs)?.1
    };

    if request.yes || confirm(&format!("Delete CIDR \"{}\"?", cidr.name))? {
        Ok(cidr.id)
    } else {
        Err(anyhow!("Canceled"))
    }
}
/// Bring up a prompt to delete a CIDR. Returns the peer request.
Bring up a prompt to delete a CIDR. Returns the peer request.
Bring up a prompt to delete a CIDR . Returns the peer request .
pub fn delete_cidr(cidrs: &[Cidr], peers: &[Peer], request: &DeleteCidrOpts) -> Result<i64, Error> {
    let eligible_cidrs: Vec<_> = cidrs
        .iter()
        .filter(|cidr| {
            !peers.iter().any(|peer| peer.contents.cidr_id == cidr.id) &&
            !cidrs.iter().any(
                |cidr2| matches!(cidr2.contents.parent, Some(parent_id) if parent_id == cidr.id)
            )
        })
        .collect();
    let cidr = if let Some(ref name) = request.name {
        cidrs
            .iter()
            .find(|cidr| &cidr.name == name)
            .ok_or_else(|| anyhow!("CIDR {} doesn't exist or isn't eligible for deletion", name))?
    } else {
        select("Delete CIDR", &eligible_cidrs)?.1
    };
    if request.yes || confirm(&format!("Delete CIDR \"{}\"?", cidr.name))? {
        Ok(cidr.id)
    } else {
        Err(anyhow!("Canceled"))
    }
}
pub fn delete_cidr ( cidrs : & [ Cidr ] , peers : & [ Peer ] , request : & DeleteCidrOpts ) -> Result < i64 , Error > { let eligible_cidrs : Vec < _ > = cidrs . iter ( ) . filter ( | cidr | { ! peers . iter ( ) . any ( | peer | peer . contents . cidr_id == cidr . id ) && ! cidrs . iter ( ) . any ( | cidr2 | matches ! ( cidr2 contents parent Some ( parent_id ) if parent_id cidr id ) ) } ) . collect ( ) ; let cidr = if let Some ( ref name ) = request . name { cidrs . iter ( ) . find ( | cidr | & cidr . name == name ) . ok_or_else ( | | anyhow ! ( " " name ) ) ? } else { select ( " " , & eligible_cidrs ) ? . 1 } ; if request . yes || confirm ( & format ! ( " \" \" " cidr name ) ) ? { Ok ( cidr . id ) } else { Err ( anyhow ! ( " " ) ) } }
Bring up a prompt to delete a CIDR.
Bring up a prompt to delete a CIDR .
cidrs
&[Cidr]
peers
&[Peer]
request
&DeleteCidrOpts