chrono icon indicating copy to clipboard operation
chrono copied to clipboard

DateTime#signed_duration_since should borrow instead of consume self and other

Open rkofman opened this issue 4 years ago • 0 comments

I'm very new to Rust, so this could be misunderstanding the language and/or the library, but it seems that DateTime#signed_duration_since could borrow the value as read-only since it is a non-mutating action (or DateTime could implement the Copy trait).

As is, clients are forced to clone() both the left and right side of the expression -- which seems like an unnecessary requirement for a method that calculates their difference and returns an OldDuration.

I'm happy to create a PR that adds a borrowed_signed_duration_since interface (to avoid a breaking change in the existing interface), but would appreciate somebody with more experience to first chime in and let me know that it's a reasonable change. This would be my first Rust PR.

:o)

rkofman avatar Jul 03 '21 22:07 rkofman