Skip to content

Commit 5bc1e8d

Browse files
committed
Make duration capi getters non-optional
1 parent f5a6aa5 commit 5bc1e8d

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

temporal_capi/bindings/cpp/temporal_rs/Duration.d.hpp

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporal_capi/bindings/cpp/temporal_rs/Duration.hpp

Lines changed: 6 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporal_capi/src/duration.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,19 @@ pub mod ffi {
207207
pub fn milliseconds(&self) -> i64 {
208208
self.0.milliseconds()
209209
}
210-
pub fn microseconds(&self) -> Option<f64> {
211-
f64::from_i128(self.0.microseconds())
212-
}
213-
pub fn nanoseconds(&self) -> Option<f64> {
214-
f64::from_i128(self.0.nanoseconds())
210+
pub fn microseconds(&self) -> f64 {
211+
// The error case should never occur since
212+
// duration values are clamped within range
213+
//
214+
// https://github.com/boa-dev/temporal/issues/189
215+
f64::from_i128(self.0.microseconds()).unwrap_or(0.)
216+
}
217+
pub fn nanoseconds(&self) -> f64 {
218+
// The error case should never occur since
219+
// duration values are clamped within range
220+
//
221+
// https://github.com/boa-dev/temporal/issues/189
222+
f64::from_i128(self.0.nanoseconds()).unwrap_or(0.)
215223
}
216224

217225
pub fn sign(&self) -> Sign {

0 commit comments

Comments
 (0)