Skip to content

bytes! macro rejects zero literal in decimal and octal forms #41

@leighmcculloch

Description

@leighmcculloch

What version are you using?

0.0.5

What did you do?

Used bytes!(0) or bytes!(0o0) to convert the zero literal to bytes.

let b = bytes_lit::bytes!(0);
let b = bytes_lit::bytes!(0o0);

What did you expect to see?

Both produce [0u8], consistent with the hex and binary forms which already work:

bytes_lit::bytes!(0x0);  // => [0u8] ✓
bytes_lit::bytes!(0b0);  // => [0u8] ✓

What did you see instead?

Compile error:

leading zeros are not preserved or supported on integer literals in decimal form
leading zeros are not preserved or supported on integer literals in octal form

The leading-zero detection in bytes() treats the sole 0 digit as a leading zero. When the entire value is zero there is no meaningful leading zero to reject — it is just the value itself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions