Skip to content

Trait bounds for type inference #8

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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