This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::error::Error; | |
// NOTE: requires `regex = "1.6"` under [build-dependencies] in Cargo.toml | |
fn main() { | |
println!("Running build.rs..."); | |
match run() { | |
Ok(_) => println!("...Success!"), | |
Err(e) => { | |
println!("...Failure!"); | |
eprintln!("{:?}", e); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
The contents of this file are Public Domain. You may use as you wish. | |
HOW TO IMPLEMENT JAVA-STYLE EXCEPTIONS IN IDIOMATIC RUST | |
(aka "How to have errors that don't suck") | |
Here we define a macro that creates a struct implementing the Error trait and automatically captures | |
and displays the backtrace unless running in release mode (and even then, you can specify | |
`RUST_BACKTRACE=1` to get the backtraces in release) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::sync::{Arc, Mutex}; | |
use tokio; | |
fn main() -> Result<(), Box<dyn std::error::Error>> { | |
println!("Starting..."); | |
println!("===== Direct Execution ==="); | |
println!("Got {} from Task 1", task1()); | |
println!("Got {} from Task 2", task2()); | |
println!("Got {} from Task 3", task3()); |
OlderNewer