Repository: microsoft/onefuzz
File: src/agent/onefuzz/src/libfuzzer.rs (Rust)

Code before:
            .await
            .with_context(|| format_err!("libfuzzer failed to run: {}", self.exe.display()))?;

        let output_text = String::from_utf8_lossy(&output.stderr);
        let pat = r"MERGE-OUTER: (\d+) new files with (\d+) new features added";
        let re = regex::Regex::new(pat).unwrap();
        let captures = re.captures_iter(&output_text).next();
        match captures {
            Some(captures) => {
                let added_files_count = captures.get(1).unwrap().as_str().parse::<i32>().unwrap();
                let added_feature_count = captures.get(2).unwrap().as_str().parse::<i32>().unwrap();
                Ok(LibFuzzerMergeOutput {
                    added_files_count,
                    added_feature_count,
                })
            }
            None => Ok(LibFuzzerMergeOutput {
                added_files_count: 0,
                added_feature_count: 0,
            }),
        }
    }
}

#[cfg(target_os = "windows")]
fn artifact_prefix(fault_dir: impl AsRef<Path>) -> OsString {
    if fault_dir.as_ref().is_absolute() {
        format!("-artifact_prefix={}\\", fault_dir.as_ref().display()).into()
    } else {
        format!("-artifact_prefix={}/", fault_dir.as_ref().display()).into()
    }
}

#[cfg(not(target_os = "windows"))]
fn artifact_prefix(fault_dir: impl AsRef<Path>) -> OsString {
    format!("-artifact_prefix={}/", fault_dir.as_ref().display()).into()
}

pub struct LibFuzzerLine {
    _line: String,
    iters: u64,
    execs_sec: f64,
}

impl LibFuzzerLine {
    pub fn new(line: String, iters: u64, execs_sec: f64) -> Self {
        Self {
            iters,
            _line: line,
            execs_sec,
        }

Review comment (suggestion):
suggest just using `&Path`, caller is already doing `.as_ref()`

```suggestion
fn artifact_prefix(fault_dir: &Path) -> OsString {
```

Code after:
            .await
            .with_context(|| format_err!("libfuzzer failed to run: {}", self.exe.display()))?;

        let output_text = String::from_utf8_lossy(&output.stderr);
        let pat = r"MERGE-OUTER: (\d+) new files with (\d+) new features added";
        let re = regex::Regex::new(pat).unwrap();
        let captures = re.captures_iter(&output_text).next();
        match captures {
            Some(captures) => {
                let added_files_count = captures.get(1).unwrap().as_str().parse::<i32>().unwrap();
                let added_feature_count = captures.get(2).unwrap().as_str().parse::<i32>().unwrap();
                Ok(LibFuzzerMergeOutput {
                    added_files_count,
                    added_feature_count,
                })
            }
            None => Ok(LibFuzzerMergeOutput {
                added_files_count: 0,
                added_feature_count: 0,
            }),
        }
    }
}

#[cfg(target_os = "windows")]
fn artifact_prefix(fault_dir: &Path) -> OsString {
    if fault_dir.is_absolute() {
        format!("-artifact_prefix={}\\", fault_dir.display()).into()
    } else {
        format!("-artifact_prefix={}/", fault_dir.display()).into()
    }
}

#[cfg(not(target_os = "windows"))]
fn artifact_prefix(fault_dir: &Path) -> OsString {
    format!("-artifact_prefix={}/", fault_dir.display()).into()
}

pub struct LibFuzzerLine {
    _line: String,
    iters: u64,
    execs_sec: f64,
}

impl LibFuzzerLine {
    pub fn new(line: String, iters: u64, execs_sec: f64) -> Self {
        Self {
            iters,
            _line: line,
            execs_sec,
        }