- 2024-03-04[Rust] Using .map_err instead of wrap which cause panic
//Usingcatch-allerrortypeslike`Box<dynerror::Error>`isn'trecommended//forlibrarycode,wherecallersmightwanttomakedecisionsbasedonthe//errorcontent,insteadofprintingitoutorpropagatingitfurther.Here,we//defin
- 2024-03-04[Rust] Using Box<dyn error::Error>> return one of miultiple error types at runtime
usestd::error;usestd::fmt;usestd::num::ParseIntError;fnmain()->Result<(),Box<dynerror::Error>>{letpretend_user_input="42";letx:i64=pretend_user_input.parse()?;println!("output={:?}",Po
- 2024-03-01[Rust] PartialEq in test
#[derive(PartialEq,Debug)]enumCreationError{Negative,Zero,}#[derive(PartialEq,Debug)]structPositiveNonzeroInteger(u64);implPositiveNonzeroInteger{fnnew(value:i64)->Result<PositiveNonzeroInteger,CreationError>{