Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
sayrer
· 1y ago · 0 comments
Yes, can't have .unwrap() in production code (it's ok in tests)
Comments
[–]
orphea
1y ago
Like goto, unwrap is just a tool that has its use cases. No need to make a boogeyman out of it.
[–]
gishh
1y ago
To be fair, if you’re not “this tall” you really shouldn’t consider using goto in a c program. Most people aren’t that tall.
[–]
tucnak
1y ago
Nonsense. Linux kernel for one example, uses goto everywhere for error handling.
[–]
gishh
1y ago
How many codebases besides the Linux kernel had you seen an intentional amount of use of goto?
[–]
metaltyphoon
1y ago
Yes it's meant to be used in test code. If you're sure it can't fail do then use .expect() that way it shows you made a choice and it wasn't just a dev oversight.
[–]
fwjafwasd
1y ago
panicans should be using .expect() in production
[–]
keyle
1y ago
unwrap itself isn't the problem...