-
Notifications
You must be signed in to change notification settings - Fork 38
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
rust: use specific error for traps in execute #735
Conversation
Codecov Report
@@ Coverage Diff @@
## master #735 +/- ##
==========================================
- Coverage 99.28% 99.27% -0.02%
==========================================
Files 88 88
Lines 13248 13154 -94
==========================================
- Hits 13153 13058 -95
- Misses 95 96 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are no examples using this, so can't tell if it is useful or not. Can't comment if this is rusty enough.
I thought I pushed the test changes. Anyway, it removes one level of indirection.
|
b2a0986
to
65c0da2
Compare
Not sure about the last commit, but otherwise this feels more native to Rust. |
1835ec4
to
bf5695d
Compare
22adb38
to
0f82440
Compare
sys::FizzyValueTypeI64 => TypedValue::U64(unsafe { self.result.value.i64 }), | ||
sys::FizzyValueTypeF32 => TypedValue::F32(unsafe { self.result.value.f32 }), | ||
sys::FizzyValueTypeF64 => TypedValue::F64(unsafe { self.result.value.f64 }), | ||
pub fn typed_value(&self, expected_type: sys::FizzyValueType) -> Option<TypedValue> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if should have this helper or not, e.g. to keep the last commit or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, but see comment below.
bindings/rust/src/lib.rs
Outdated
|
||
pub fn typed_value(&self, expected_type: sys::FizzyValueType) -> Option<TypedValue> { | ||
assert!(!self.0.trapped); | ||
if self.0.has_value { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now the decision what to return is based on both expected_type
and self.0.has_value
Maybe better change this to if expected_type != sys::FizzyValueTypeVoid
and assert inside assert!(self.0.has_value)
. Or even make it part of one bigger match expected_type
.
Also maybe rename expected_type
to just type
, otherwise it looks like it's mainly not a conversion, but a check / test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushed a commit flipping conditions, but it doesn't make much of a difference. assert!
's are always in the binary, debug_assert!
s aren't.
type
is a keyword, hence expected_type
.
No description provided.