Skip to content

Trait bounds for type inference #8

@tisonkun

Description

@tisonkun

So far, we have only Unbounded to bound the supported types.

However, this may cause issues like (ref):

BSize::kib(16_u64); // compile failed; multiple applicable items in scope
BSize::<u64>::kib(16_u64); // compiled

I'm considering to change the unsigned.rs file to bounds.rs and add a series of trait bounds:

ByteSize = the current Unsigned
SupportKB = [u16, u32, u64, usize]
SupportKiB = [u16, u32, u64, usize]
SupportMB = [u32, u64, usize]
SupportMiB = [u32, u64, usize]
...

Let me demonstrate a changeset and see if it works well or adds too much type noise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions