Skip to content

"0u8.." panics #35589

Closed
Closed
@Christopher22

Description

@Christopher22

The range for u8 does not work properly, it panics at the (valid) value 255. If this behavior is expected for bytes it should be documentated.

I tried this code to check correctness and it panics:
fn main() { assert_eq!((0u8..).last(), Some(255)); }

thread 'main' panicked at 'arithmetic operation overflowed', ../src/libcore/ops.rs:211
note: Run with RUST_BACKTRACE=1 for a backtrace.

Rusty greedings, Christopher
#24119

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions