fn add_results()

in src/lib.rs [101:134]


fn add_results(
    results: Vec<(String, CovResult)>,
    result_map: &SyncCovResultMap,
    source_dir: Option<&Path>,
) {
    let mut map = result_map.lock().unwrap();
    let mut warn_overflow = false;
    for result in results.into_iter() {
        let path = match source_dir {
            Some(source_dir) => {
                // the goal here is to be able to merge results for paths like foo/./bar and foo/bar
                if let Ok(p) = canonicalize_path(source_dir.join(&result.0)) {
                    String::from(p.to_str().unwrap())
                } else {
                    result.0
                }
            }
            None => result.0,
        };
        let entry = map.entry(path);
        match entry {
            hash_map::Entry::Occupied(obj) => {
                warn_overflow |= merge_results(obj.into_mut(), result.1);
            }
            hash_map::Entry::Vacant(v) => {
                v.insert(result.1);
            }
        };
    }

    if warn_overflow {
        warn!("Execution count overflow detected.");
    }
}