Jenna Magius is a user on octodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Jenna Magius @jennamagius

Rust needs .unwrap_as_in_i_havent_worried_about_error_handling_yet() and .unwrap_as_in_it_is_statically_impossible_for_this_to_go_wrong_and_if_it_does_you_should_really_panic()

· Web · 0 · 0

.expect() pulls some of that weight, but like... it doesn't make sense to be like:

if x.is_none() {
return;
}
let x = x.expect("Shouldn't happen")

@jennamagius hmm, I think “if let Some(x) = x { ... }” is the recommended way to do that right now, and I vaguely remember discussion on internals.rust-lang.org of making an early return form possible as well

@jennamagius I suppose my approach would be to alias oopsie_woopsie to unwrap when it's something you want to take more care around later. Makes it easier to grep.

(Don't ask me how to do that, though; I'ven't got to the macros chapter yet...)

@jennamagius (Bonus: Make a git hook or something that prevents you from actually pushing, or maybe even committing, the use of that macro. have considered doing this in the past, never actually tried it out.)