aboutsummaryrefslogtreecommitdiff
path: root/arg_picker/src/builtin/pick_pathbuf.rs
blob: 2b48e3d42f2875aa08c7cb99a319fa3baad91609 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::path::PathBuf;

use crate::{
    PickerArgResult::{NotFound, Parsed},
    SinglePickable,
};

impl SinglePickable for PathBuf {
    fn pick_single(str: Option<&str>) -> crate::PickerArgResult<Self> {
        str.map_or(NotFound, |str| {
            just_fmt::fmt_path_str(str).map_or(NotFound, |formated| Parsed(Self::from(formated)))
        })
    }
}