turning red squiggles into future problems, because sometimes you just want the compiler to shut the fun up
add this to your Cargo.toml
[dependencies]
returns = "0.1.0"> cargo run fn main() {
let _ = diagnose::<i32>();
}
pub fn diagnose<T>() -> T
{
// ..
returns::return_shit!()
}cargo run is debug mode by default, if you forget to write the valid return type, it will panic with information about the line you forget to implement
> cargo runreturn_shit! can not reach production or release versions, because it will trigger compiling error
> cargo run --releasepub fn diagnose<T>() -> T
where
T:Default
{
// ..
returns::return_default!()
}but T must implement Default
- debug-mode
> cargo runit will compile normally and returns the <T as Default>::default() value
if you insist to use the <T as Default>::default() in release mode you just can use returns::return_default!(force)
pub fn diagnose<T>() -> T
where
T:Default
{
// ..
returns::return_default!(force)
}> and you are all green again, go for it



