Y
Hacker News
new
|
ask
|
show
|
jobs
by
jcparkyn
1251 days ago
Probably because you'd want to access the value in either case, depending on your application.
1 comments
howinteresting
1251 days ago
Could be a `Result<T, T>` which would seem to express the intent better.
link
3836293648
1251 days ago
Sometimes, sure. But an overflow doesn't have to be an error, it can be what you're after and you just want to know when it happens.
link
howinteresting
1251 days ago
Binary search is similar and the return type there is already Result<usize, usize>:
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.bin...
link