fn find_examples() -> Vec<Example> {
    // Find target/ using std::env::current_exe().
    let exe_dir = std::env::current_exe().expect("Unable to find executable location");
    let target_dir = exe_dir
        .parent()
        .expect("Unable to find target/ directory")
        .parent()
        .expect("Unable to find target/ directory");

    let mut examples = Vec::new();

    for arch in &ARCHITECTURES {
        // Set examples_dir to target/$ARCH/examples/
        let mut examples_dir = target_dir.to_path_buf();
        examples_dir.push(arch);
        examples_dir.push("release");
        examples_dir.push("examples");

        // If the architecture's examples directory exists, iterate through the
        // files through it and search for examples. If the directory doesn't
        // exist we skip this architecture.
        if let Ok(read_dir) = examples_dir.read_dir() {
            for file in read_dir.filter_map(Result::ok) {
                use std::os::unix::ffi::OsStrExt;

                // Skip entries that are not files. If file_type() returns
                // Err(_) we skip the entry as well.
                if !file.file_type().map_or(false, |t| t.is_file()) {
                    continue;
                }

                // Skip files with dots (*.d files) and hyphens (-$HASH) in
                // them.
                if file.file_name().as_bytes().contains(&b'.')
                    || file.file_name().as_bytes().contains(&b'-')
                {
                    continue;
                }

                examples.push(Example {
                    name: file.file_name().to_string_lossy().into_owned(),
                    arch,
                    path: file.path(),
                });
            }
        }
    }

    examples
}
// Finds the example binaries and returns a list of their paths.
Finds the example binaries and returns a list of their paths.
Finds the example binaries and returns a list of their paths .
fn find_examples() -> Vec<Example> {
    // Find target/ using std::env::current_exe().
    let exe_dir = std::env::current_exe().expect("Unable to find executable location");
    let target_dir = exe_dir
        .parent()
        .expect("Unable to find target/ directory")
        .parent()
        .expect("Unable to find target/ directory");
    let mut examples = Vec::new();
    for arch in &ARCHITECTURES {
        // Set examples_dir to target/$ARCH/examples/
        let mut examples_dir = target_dir.to_path_buf();
        examples_dir.push(arch);
        examples_dir.push("release");
        examples_dir.push("examples");
        // If the architecture's examples directory exists, iterate through the
        // files through it and search for examples. If the directory doesn't
        // exist we skip this architecture.
        if let Ok(read_dir) = examples_dir.read_dir() {
            for file in read_dir.filter_map(Result::ok) {
                use std::os::unix::ffi::OsStrExt;
                // Skip entries that are not files. If file_type() returns
                // Err(_) we skip the entry as well.
                if !file.file_type().map_or(false, |t| t.is_file()) {
                    continue;
                }
                // Skip files with dots (*.d files) and hyphens (-$HASH) in
                // them.
                if file.file_name().as_bytes().contains(&b'.')
                    || file.file_name().as_bytes().contains(&b'-')
                {
                    continue;
                }
                examples.push(Example {
                    name: file.file_name().to_string_lossy().into_owned(),
                    arch,
                    path: file.path(),
                });
            }
        }
    }
    examples
}
fn find_examples ( ) -> Vec < Example > { // Find target/ using std::env::current_exe(). let exe_dir = std :: env :: current_exe ( ) . expect ( " " ) ; let target_dir = exe_dir . parent ( ) . expect ( " " ) . parent ( ) . expect ( " " ) ; let mut examples = Vec :: new ( ) ; for arch in & ARCHITECTURES { // Set examples_dir to target/$ARCH/examples/ let mut examples_dir = target_dir . to_path_buf ( ) ; examples_dir . push ( arch ) ; examples_dir . push ( " " ) ; examples_dir . push ( " " ) ; // If the architecture's examples directory exists, iterate through the // files through it and search for examples. If the directory doesn't // exist we skip this architecture. if let Ok ( read_dir ) = examples_dir . read_dir ( ) { for file in read_dir . filter_map ( Result :: ok ) { use std :: os :: unix :: ffi :: OsStrExt ; // Skip entries that are not files. If file_type() returns // Err(_) we skip the entry as well. if ! file . file_type ( ) . map_or ( false , | t | t . is_file ( ) ) { continue ; } // Skip files with dots (*.d files) and hyphens (-$HASH) in // them. if file . file_name ( ) . as_bytes ( ) . contains ( & b'.' ) || file . file_name ( ) . as_bytes ( ) . contains ( & b'-' ) { continue ; } examples . push ( Example { name : file . file_name ( ) . to_string_lossy ( ) . into_owned ( ) , arch , path : file . path ( ) , } ) ; } } } examples }
Finds the example binaries and returns a list of their paths.
Finds the example binaries and returns a list of their paths .