pub fn choose_from<S: AsRef<str>>(
    filenames: &[S],
    lookup: impl Fn(&str) -> Option<u64>,
) -> Result<Vec<String>> {
    let mut chosen_filenames: Vec<String> = vec![];

    for filename in filenames.iter() {
        let sector_size = lookup(filename.as_ref())
            .with_context(|| format!("no sector size found for filename {}", filename.as_ref()))?;

        let msg = format!("(sector size: {}B) {}", sector_size, filename.as_ref());

        if choose(&msg) {
            chosen_filenames.push(filename.as_ref().to_string())
        }
    }

    Ok(chosen_filenames)
}
/// Prompts the user to approve/reject the filename
Prompts the user to approve/reject the filename
Prompts the user to approve / reject the filename
pub fn choose_from<S: AsRef<str>>(
    filenames: &[S],
    lookup: impl Fn(&str) -> Option<u64>,
) -> Result<Vec<String>> {
    let mut chosen_filenames: Vec<String> = vec![];
    for filename in filenames.iter() {
        let sector_size = lookup(filename.as_ref())
            .with_context(|| format!("no sector size found for filename {}", filename.as_ref()))?;
        let msg = format!("(sector size: {}B) {}", sector_size, filename.as_ref());
        if choose(&msg) {
            chosen_filenames.push(filename.as_ref().to_string())
        }
    }
    Ok(chosen_filenames)
}
pub fn choose_from < S : AsRef < str > > ( filenames : & [ S ] , lookup : impl Fn ( & str ) -> Option < u64 > , ) -> Result < Vec < String > > { let mut chosen_filenames : Vec < String > = vec ! [ ] ; for filename in filenames . iter ( ) { let sector_size = lookup ( filename . as_ref ( ) ) . with_context ( | | format ! ( " " filename as_ref ( ) ) ) ? ; let msg = format ! ( " " sector_size filename as_ref ( ) ) ; if choose ( & msg ) { chosen_filenames . push ( filename . as_ref ( ) . to_string ( ) ) } } Ok ( chosen_filenames ) }
Prompts the user to approve/reject the filename
Prompts the user to approve / reject the filename
filenames
&[S]
lookup
impl Fn(&str) -> Option<u64>
filenames
&[S]
lookup
impl Fn(&str) -> Option<u64>