Use cargo fmt and conform to Style Guide (mostly)
This commit is contained in:
parent
1f1eac6369
commit
2982a13bc2
15 changed files with 980 additions and 888 deletions
44
src/error.rs
44
src/error.rs
|
|
@ -1,33 +1,35 @@
|
|||
use std :: * ;
|
||||
use std :: any :: * ;
|
||||
use std::any::Any;
|
||||
use std::result;
|
||||
|
||||
|
||||
|
||||
# [ derive (Debug) ] pub enum ZoodexError {
|
||||
CollectionFileReadError ,
|
||||
#[derive(Debug)]
|
||||
pub enum ZoodexError {
|
||||
CollectionFileReadError,
|
||||
}
|
||||
|
||||
pub type Result <Success> = result :: Result < Success , ZoodexError > ;
|
||||
pub type Result<Success> = result::Result<Success, ZoodexError>;
|
||||
|
||||
impl From < Box < dyn Any + Send > > for ZoodexError {
|
||||
fn from ( error : Box < dyn Any + Send > ) -> Self {
|
||||
* error . downcast () . unwrap ()
|
||||
}
|
||||
impl From<Box<dyn Any + Send>> for ZoodexError {
|
||||
fn from(error: Box<dyn Any + Send>) -> Self {
|
||||
*error.downcast().unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules ! async_result_context { (
|
||||
$ future : expr
|
||||
$ ( , ok => $ on_success : expr ) ?
|
||||
$ ( , err => $ on_failure : expr ) ? $ (,) ?
|
||||
macro_rules! async_result_context {(
|
||||
$future: expr
|
||||
$(, ok => $on_success: expr)?
|
||||
$(, err => $on_failure: expr)?$(,)?
|
||||
) => {
|
||||
# [ allow (unreachable_patterns) ] match $ future . await {
|
||||
$ ( Ok (value) => $ on_success (value) , ) ?
|
||||
Ok (_) => {} ,
|
||||
$ ( Err (error) => $ on_failure (error) , ) ?
|
||||
Err (_) => {} ,
|
||||
}
|
||||
} }
|
||||
#[allow(unreachable_patterns)]
|
||||
match $future.await {
|
||||
$(Ok(value) => $on_success(value),)?
|
||||
Ok(_) => {},
|
||||
$(Err(error) => $on_failure(error),)?
|
||||
Err(_) => {},
|
||||
}
|
||||
}}
|
||||
|
||||
|
||||
|
||||
pub (crate) use async_result_context ;
|
||||
pub(crate) use async_result_context;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue