1 unstable release
Uses new Rust 2024
| 0.1.0 | Apr 21, 2026 |
|---|
#1896 in Rust patterns
1.5MB
269 lines
Contains (WOFF font, 400KB) NanumBarunGothic-13b3dcba.ttf.woff2, (WOFF font, 140KB) FiraSans-Italic-81dc35de.woff2, (WOFF font, 135KB) FiraSans-Medium-e1aa3f0a.woff2, (WOFF font, 140KB) FiraSans-MediumItalic-ccf7e434.woff2, (WOFF font, 130KB) FiraSans-Regular-0fe48ade.woff2, (WOFF font, 82KB) SourceSerif4-Bold-6d4fd4c0.ttf.woff2 and 8 more.
idc: A simple crate for error propagation
Idc is a simple crate for propagating errors that implement std’s Error trait.
Idc also supports no_std with the same functionality, but you have to provide a global allocator and disable default features.
examples:
- propagating multiple different errors:
use std::fs;
use idc::*;
use serde_json::Value;
fn main() -> Result<()> {
let foo = fs::read_to_string("foo.json").context("failed to read foo.", "maybe it doesn't exist?".into())?;
let json: Value = serde_json::from_str(&foo).context("failed to turn foo into json.", "make sure foo.json is valid json.".into())?;
println!("{}", json["important item"]);
Ok(())
}
- returning an one-time error:
use std::env;
use idc::*;
fn main() -> Result<()> {
let args: Vec<String> = env::args().collect();
if args.len() < 2 {
bail!("no argument provided!");
}
//...
Ok(())
}
idc: A simple crate for error propagation
Idc is a simple crate for propagating errors that implement std’s Error trait.
Idc also supports no_std with the same functionality, but you have to provide a global allocator and disable default feature
examples:
- propagating multiple different errors:
use std::fs;
use idc::*;
use serde_json::Value;
fn main() -> Result<()> {
let foo = fs::read_to_string("foo.json").context("failed to read foo.", Some("maybe it doesn't exist?"))?;
let json: Value = serde_json::from_str(&foo).context("failed to turn foo into json", Some("make sure foo.json is valid json."))?;
println!("{}", json["important item"]);
Ok(())
}
- returning an one-time error:
use std::env;
use idc::*;
fn main() -> Result<()> {
let args: Vec<String> = env::Args.collect();
if args.len() < 2 {
bail!("no argument provided!");
}
//...
Ok(())
}