Skip to content
Better HN
Top
New
Best
Ask
Show
Jobs
Search
⌘K
0 points
sayrer
4mo ago
0 comments
Share
Yes, can't have .unwrap() in production code (it's ok in tests)
undefined | Better HN
0 comments
default
newest
oldest
orphea
4mo ago
Like goto, unwrap is just a tool that has its use cases. No need to make a boogeyman out of it.
gishh
4mo 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
4mo ago
Nonsense. Linux kernel for one example, uses goto everywhere for error handling.
1 more reply
metaltyphoon
4mo 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
4mo ago
panicans should be using .expect() in production
keyle
4mo ago
unwrap itself isn't the problem...
j
/
k
navigate · click thread line to collapse