From e40eab9107609ee6a785631e933a16fb6ccaeff8 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Sun, 18 Aug 2024 11:56:23 -0400 Subject: [PATCH] api: remove 'impl Into' from parameter types I think this was an oversight. I generally don't like using 'impl Trait' in public APIs unless there is no avoiding it. In particular, when using 'impl Trait', it inhibits the use of turbofish, which can sometimes be useful. --- src/civil/datetime.rs | 4 ++-- src/civil/time.rs | 2 +- src/civil/weekday.rs | 4 ++-- src/span.rs | 28 ++++++++++++++-------------- src/timestamp.rs | 4 ++-- src/zoned.rs | 4 ++-- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/civil/datetime.rs b/src/civil/datetime.rs index b5da48c3..07931f12 100644 --- a/src/civil/datetime.rs +++ b/src/civil/datetime.rs @@ -2140,9 +2140,9 @@ impl DateTime { /// # Ok::<(), Box>(()) /// ``` #[inline] - pub fn round( + pub fn round>( self, - options: impl Into, + options: R, ) -> Result { let options: DateTimeRound = options.into(); options.round(t::NANOS_PER_CIVIL_DAY, self) diff --git a/src/civil/time.rs b/src/civil/time.rs index 3d4e6725..95d7b6f3 100644 --- a/src/civil/time.rs +++ b/src/civil/time.rs @@ -1478,7 +1478,7 @@ impl Time { /// # Ok::<(), Box>(()) /// ``` #[inline] - pub fn round(self, options: impl Into) -> Result { + pub fn round>(self, options: R) -> Result { let options: TimeRound = options.into(); options.round(self) } diff --git a/src/civil/weekday.rs b/src/civil/weekday.rs index 3a85a02f..502cfe64 100644 --- a/src/civil/weekday.rs +++ b/src/civil/weekday.rs @@ -408,7 +408,7 @@ impl Weekday { /// assert_eq!(1 + Weekday::Sunday, Weekday::Monday); /// ``` #[inline] - pub fn wrapping_add(self, days: impl Into) -> Weekday { + pub fn wrapping_add>(self, days: D) -> Weekday { let start = t::NoUnits::rfrom(self.to_monday_zero_offset_ranged()); // OK because all i64 values fit in a NoUnits. let rhs = t::NoUnits::new(days.into()).unwrap(); @@ -452,7 +452,7 @@ impl Weekday { /// weekday has no semantic meaning, the weekday cannot be on the right /// hand side of the `-` operator. #[inline] - pub fn wrapping_sub(self, days: impl Into) -> Weekday { + pub fn wrapping_sub>(self, days: D) -> Weekday { self.wrapping_add(-days.into()) } diff --git a/src/span.rs b/src/span.rs index 5c02f324..8fe42f72 100644 --- a/src/span.rs +++ b/src/span.rs @@ -1559,9 +1559,9 @@ impl Span { /// # Ok::<(), Box>(()) /// ``` #[inline] - pub fn checked_add<'a>( + pub fn checked_add<'a, A: Into>>( &self, - options: impl Into>, + options: A, ) -> Result { let options: SpanArithmetic<'_> = options.into(); options.checked_add(*self) @@ -1687,9 +1687,9 @@ impl Span { /// # Ok::<(), Box>(()) /// ``` #[inline] - pub fn checked_sub<'a>( + pub fn checked_sub<'a, A: Into>>( &self, - options: impl Into>, + options: A, ) -> Result { let mut options: SpanArithmetic<'_> = options.into(); options.duration = options.duration.checked_neg()?; @@ -1780,9 +1780,9 @@ impl Span { /// See the examples for [`Span::total`] if you want to sort spans without /// an `unwrap()` call. #[inline] - pub fn compare<'a>( + pub fn compare<'a, C: Into>>( &self, - options: impl Into>, + options: C, ) -> Result { let options: SpanCompare<'_> = options.into(); options.compare(*self) @@ -1910,9 +1910,9 @@ impl Span { /// # Ok::<(), Box>(()) /// ``` #[inline] - pub fn total<'a>( + pub fn total<'a, T: Into>>( &self, - options: impl Into>, + options: T, ) -> Result { let options: SpanTotal<'_> = options.into(); options.total(*self) @@ -2077,9 +2077,9 @@ impl Span { /// # Ok::<(), Box>(()) /// ``` #[inline] - pub fn round<'a>( + pub fn round<'a, R: Into>>( self, - options: impl Into>, + options: R, ) -> Result { let options: SpanRound<'a> = options.into(); options.round(self) @@ -2141,9 +2141,9 @@ impl Span { /// # Ok::<(), Box>(()) /// ``` #[inline] - pub fn to_jiff_duration<'a>( + pub fn to_jiff_duration<'a, R: Into>>( &self, - relative: impl Into>, + relative: R, ) -> Result { let max_unit = self.largest_unit(); let relative: SpanRelativeTo<'a> = relative.into(); @@ -2289,9 +2289,9 @@ impl Span { /// ``` #[deprecated(since = "0.1.5", note = "use Span::to_jiff_duration instead")] #[inline] - pub fn to_duration<'a>( + pub fn to_duration<'a, R: Into>>( &self, - relative: impl Into>, + relative: R, ) -> Result { if self.is_negative() { return Err(err!( diff --git a/src/timestamp.rs b/src/timestamp.rs index d22edb93..2e488c02 100644 --- a/src/timestamp.rs +++ b/src/timestamp.rs @@ -1820,9 +1820,9 @@ impl Timestamp { /// # Ok::<(), Box>(()) /// ``` #[inline] - pub fn round( + pub fn round>( self, - options: impl Into, + options: R, ) -> Result { let options: TimestampRound = options.into(); options.round(self) diff --git a/src/zoned.rs b/src/zoned.rs index 6ae0a713..97adffd8 100644 --- a/src/zoned.rs +++ b/src/zoned.rs @@ -2788,9 +2788,9 @@ impl Zoned { /// timestamp would result in rounding up to the next day. But the next day /// is greater than the maximum, and so this returns an error. #[inline] - pub fn round( + pub fn round>( &self, - options: impl Into, + options: R, ) -> Result { let options: ZonedRound = options.into(); options.round(self)