add quick_error
This commit is contained in:
14
quick_error/Cargo.lock
generated
Normal file
14
quick_error/Cargo.lock
generated
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
[[package]]
|
||||||
|
name = "quick-error"
|
||||||
|
version = "1.2.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quick_error"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"quick-error",
|
||||||
|
]
|
||||||
11
quick_error/Cargo.toml
Normal file
11
quick_error/Cargo.toml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[package]
|
||||||
|
name = "quick_error"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Hatter Jiang@Pixelbook <jht5945@gmail.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
quick-error = "1.2.3"
|
||||||
|
|
||||||
22
quick_error/src/main.rs
Normal file
22
quick_error/src/main.rs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#[macro_use] extern crate quick_error;
|
||||||
|
|
||||||
|
quick_error! {
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub enum SomeError {
|
||||||
|
Io(m: String) {
|
||||||
|
display("{}", m)
|
||||||
|
}
|
||||||
|
Utf8(err: std::str::Utf8Error) {
|
||||||
|
display("utf8 error")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://docs.rs/quick-error/1.2.3/quick_error/
|
||||||
|
fn main() -> Result<(), SomeError> {
|
||||||
|
println!("Hello, world!");
|
||||||
|
|
||||||
|
Err(SomeError::Io("m".to_owned()))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user