Skip to content

Integer::next_multiple_of unexpectedly fails on MIN and -1 #43

Closed
@jhpratt

Description

@jhpratt

i8::MIN.next_multiple_of(-1) should return -128 (i8::MIN), but instead panics. The fix for this is to add if self == -1 { return self; } at the top of the method.

I have not checked, but it is certainly worth checking whether a similar situation applies with prev_multiple_of.

This is the only issue with the current implementation of next_multiple_of. It otherwise works as expected.

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