fix: unexpected panic in PusTmReader constructor#12
Conversation
|
thanks. i should grep and check the codebase for unwraps.. |
|
the clippy error is unrelated |
|
As additional check You could introuduce new clippy rules like: allow-unwrap-in-tests = true
disallowed-methods = [
"std::option::Option::unwrap",
"std::result::Result::unwrap",
]I can do this if You'd like 😉 |
|
Is there a lint that forces me to comment why an unwrap is okay? because i do not think unwraps are inherently bad. there are cases where I check a pre-condition which would make a function call fail, and then I just unwrap that function. I think they should probably be treated like unsafe code. |
let something = result.expect("Explain why this shouldn't fail.") ;Is good enough replacement for unwrap with comment in my opinion if this is what You are looking for. |
|
I suppose you are right. https://doc.rust-lang.org/book/ch09-03-to-panic-or-not-to-panic.html#when-you-have-more-information-than-the-compiler mentions that would be a better approach as well. I might look into this soon. Maybe AI can help me a bit, also curious how much it would hallucinate. any help is appreciated as well :) there are a lot of unwraps. most of what i saw logically impossible. but still a bit of work to change all of those to expect |
Fixes unexpected panic in
PusTmReaderconstructor.