Skip to content

Signed/Unsigned Inner Types #7

@PTaylor-us

Description

@PTaylor-us

I began this journey after finding that the core::Duration was an unsigned value. I then investigated the time crate and found that while it does have signed Duration, it is focused more toward "wall-clock" time considerations. This led me to great this project.

I began my development with the use-case of a non-wrapping timer (typically chaining two 32-bit peripheral timers in a microcontroller). However, if this project is to be compatible with wrapping timers, that may fundamentally change its design.

Signed durations can be useful when calculating the difference between two instances. It allows the subtraction to be done in either order returning a logical result. For example, in the expression x - y, if x is earlier than y, a negative duration is returned. However, if wrapping timers are to be supported, a negative duration will never be returned as subtracting a "higher-value" instance from a "lower-value" assumes the timer wrapped, and a positive duration is returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionSomething that needs more discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions