Skip to content

Possible panic in Delay initialization #79

Open
@Robsutar

Description

@Robsutar

Delay::new can panic due Subtracting Duration from Instant on Mac is panic-prone, it can be seen in this action run.

Suggestion: add documentation, similar to the add implementation for Instant:

impl Add<Duration> for Instant {
    type Output = Instant;

    /// # Panics
    ///
    /// This function may panic if the resulting point in time cannot be represented by the
    /// underlying data structure. See [`Instant::checked_add`] for a version without panic.
    fn add(self, other: Duration) -> Instant {
        self.checked_add(other).expect("overflow when adding duration to instant")
    }
}

And/or add an checked function variant for Delay::new, like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions