-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Value::get_uint should return a Result, not an Option #22
Comments
I see your point. On the other hand, other parts of this library do not raise errors based of the semantics of values. How about this: Value::as_uint(&self) -> Option<SomeType>
SomeType::get(&self, index: usize) -> Option<u32> Then, we can do something like this: value.as_uint().expect("not unsigned integer")
.get(3).expect("out of range") |
Hmm. Would it make sense to migrate these wholesale? The core problem that we ran into here was trying to handle the errors more robustly. Your suggestion would definitely help, but it feels a little unidiomatic to not use |
By "other parts of this library do not raise errors based of the semantics of values", I meant that this library does not (mostly) care the semantics of the values because it heavily depends on the applications and tags. I did not mean this library returns an So, Maybe this? Value::as_uint(&self) -> Result<SomeType>
SomeType::get(&self, index: usize) -> Option<u32> |
Yep, I'd be happy with that! And then link back-and-forth in the docs :) |
There are several different ways this method can fail.
This return a
Result
with an enum that implements theError
trait that captures the failure mode and returns it to the end user.The text was updated successfully, but these errors were encountered: