1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
quick_error! {
    /// **AppError**
    #[derive(Debug,PartialEq)]
     pub enum AppError {
        Parse(err:String) {
            description("Parse Error")
            from()
        }
        Help(err: Option<String>) {
            description("-h, --help")
        }
        Version {
            description("-V, --version")
        }
    }
}

trait ToAppRest {
    fn to_app_rest(self) -> Result<(), AppError>;
}

impl<'a> ToAppRest for &'a Option<String> {
    fn to_app_rest(self) -> Result<(), AppError> {
        Err(AppError::Help((*self).clone()))
    }
}
impl<'a> ToAppRest for Option<String> {
    fn to_app_rest(self) -> Result<(), AppError> {
        Err(AppError::Help(self))
    }
}