Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add saturating_add and saturating_sub to Instant #3846

Merged
merged 2 commits into from
Feb 4, 2025

Conversation

wackazong
Copy link
Contributor

No description provided.

This is more idiomatic since methods with these names usually take self and not &mut self.
Copy link
Member

@lulf lulf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@lulf lulf added this pull request to the merge queue Feb 4, 2025
Merged via the queue into embassy-rs:main with commit e0eefbb Feb 4, 2025
7 checks passed

/// Adds a Duration to self. In case of overflow, the maximum value is returned.
pub fn saturating_add(mut self, duration: Duration) -> Self {
self.ticks = self.ticks.saturating_add(duration.ticks);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mutating self is a bit strange. could you do Self::from_ticks(self.ticks.saturating_add(duration.ticks))?

same for sub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol already merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants