1
2
3
4
5
6
7
8
9
10
11
12
13
use std::path::Path;

pub trait PathExt {
    fn ext_str(&self) -> &str;
}

impl PathExt for Path {
    fn ext_str(&self) -> &str {
        self.extension()
            .and_then(|ext| ext.to_str())
            .unwrap_or_default()
    }
}