File tree 2 files changed +17
-3
lines changed
2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -6088,9 +6088,8 @@ impl<'a> Relative<'a> {
6088
6088
if smallest >= Unit :: Day {
6089
6089
Nudge :: relative_calendar (
6090
6090
relspan. span ,
6091
- // FIXME: Find a way to drop these clones.
6092
- & Relative :: Zoned ( start. clone ( ) ) ,
6093
- & Relative :: Zoned ( end. clone ( ) ) ,
6091
+ & Relative :: Zoned ( start. borrowed ( ) ) ,
6092
+ & Relative :: Zoned ( end. borrowed ( ) ) ,
6094
6093
smallest,
6095
6094
increment,
6096
6095
mode,
@@ -6364,6 +6363,12 @@ impl<'a> RelativeZoned<'a> {
6364
6363
)
6365
6364
} )
6366
6365
}
6366
+
6367
+ /// Returns the borrowed version of self; useful when you need to convert
6368
+ /// `&RelativeZoned` into `RelativeZoned` without cloning anything.
6369
+ fn borrowed ( & self ) -> RelativeZoned {
6370
+ RelativeZoned { zoned : self . zoned . borrowed ( ) }
6371
+ }
6367
6372
}
6368
6373
6369
6374
// The code below is the "core" rounding logic for spans. It was greatly
Original file line number Diff line number Diff line change @@ -14,6 +14,15 @@ pub(crate) enum DumbCow<'a, T> {
14
14
Borrowed ( & ' a T ) ,
15
15
}
16
16
17
+ impl < ' a , T > DumbCow < ' a , T > {
18
+ pub ( crate ) fn borrowed ( & self ) -> DumbCow < ' _ , T > {
19
+ match * self {
20
+ DumbCow :: Owned ( ref this) => DumbCow :: Borrowed ( this) ,
21
+ DumbCow :: Borrowed ( ref this) => DumbCow :: Borrowed ( this) ,
22
+ }
23
+ }
24
+ }
25
+
17
26
impl < ' a , T > core:: ops:: Deref for DumbCow < ' a , T > {
18
27
type Target = T ;
19
28
fn deref ( & self ) -> & T {
You can’t perform that action at this time.
0 commit comments