Language Suggestion for .expect


#1

I would like to be able to produce more informative messages with .expect.
I.e. to print out some variables values as well as just a string.
Do you think it might be possible for .expect to have on the error reporting side the same functionality as
writeln!(&mut std::io::stderr(),String, arg1, arg2 …) ?


#2

Could you use expect(format!(...))?


#3

The problem with expect(format!(...)) is that you’ll do that formatting regardless of whether it will be used. Maybe this is better: unwrap_or_else(|| panic!("your message {} {}, arg1, arg2))


#4

Yeah, that’s true. Maybe an expect<F: FnOnce() -> String>(f: F) would be nice.