Implement convert functions for RGB(A)
This commit is contained in:
@@ -22,6 +22,10 @@ impl Error {
|
||||
Error::from_text(error.to_string())
|
||||
}
|
||||
|
||||
pub fn from_callback<F>(callback: F) -> Error where F: Fn() -> String {
|
||||
Error::from_text(callback())
|
||||
}
|
||||
|
||||
pub fn not_implemented(function: &str) -> Error {
|
||||
Error::from_text(format!("{} not implemented yet", function))
|
||||
}
|
||||
@@ -38,7 +42,7 @@ impl Error {
|
||||
}
|
||||
|
||||
pub fn ok_or_new<T, F>(option: Option<T>, error_text: F) -> Result<T, Error> where F: Fn () -> String{
|
||||
Ok(option.ok_or(Error{exit_code: Self::DEFAULT_EXITCODE, action: String::new(), text: error_text()})?)
|
||||
Ok(option.ok_or(Error::from_callback(error_text))?)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user