Take self instead of &mut self

This is more idiomatic since methods with these names usually take self and not &mut self.
This commit is contained in:
wackazong 2025-02-04 11:09:52 +01:00 committed by GitHub
parent b7fbf6d519
commit 865266a4ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -117,13 +117,15 @@ impl Instant {
}
/// Adds a Duration to self. In case of overflow, the maximum value is returned.
pub fn saturating_add(&mut self, duration: Duration) {
pub fn saturating_add(mut self, duration: Duration) -> Self {
self.ticks = self.ticks.saturating_add(duration.ticks);
self
}
/// Subtracts a Duration from self. In case of overflow, the minimum value is returned.
pub fn saturating_sub(&mut self, duration: Duration) {
pub fn saturating_sub(mut self, duration: Duration) -> Self {
self.ticks = self.ticks.saturating_sub(duration.ticks);
self
}
}