From e865715f8b85b18301461c1568327229bc3ea753 Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Sat, 1 Jun 2024 19:41:06 -0600 Subject: [PATCH] Patch `(un)balance_relative` to avoid panicking --- src/components/duration/date.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/duration/date.rs b/src/components/duration/date.rs index c15ad272..debad04a 100644 --- a/src/components/duration/date.rs +++ b/src/components/duration/date.rs @@ -6,7 +6,7 @@ use crate::{ Duration, }, options::{ArithmeticOverflow, RelativeTo, TemporalRoundingMode, TemporalUnit}, - utils, TemporalError, TemporalResult, NS_PER_DAY, + utils, TemporalError, TemporalResult, TemporalUnwrap, NS_PER_DAY, }; use super::normalized::NormalizedTimeDuration; @@ -63,7 +63,7 @@ impl DateDuration { context: &mut C::Context, ) -> TemporalResult { // 1. Assert: If plainRelativeTo is not undefined, calendarRec is not undefined. - let plain_relative = plain_relative_to.expect("plainRelativeTo must not be undefined."); + let plain_relative = plain_relative_to.temporal_unwrap()?; // 2. Let defaultLargestUnit be DefaultTemporalLargestUnit(years, months, weeks, days, 0, 0, 0, 0, 0). let default_largest = self.default_largest_unit(); @@ -187,7 +187,7 @@ impl DateDuration { ) -> TemporalResult { // TODO: Confirm 1 or 5 based off response to issue. // 1. Assert: If plainRelativeTo is not undefined, calendarRec is not undefined. - let plain_relative = plain_relative_to.expect("plainRelativeTo must not be undefined."); + let plain_relative = plain_relative_to.temporal_unwrap()?; // 2. Let allZero be false. // 3. If years = 0, and months = 0, and weeks = 0, and days = 0, set allZero to true.