Skip to content

Could consider using usize for the inner type of Size? #16

@kevinchannon

Description

@kevinchannon

In general, when talking about numbers of bytes and things like that, we don't care about negative numbers of bytes, so an unsized type could be good. Also, usize is specifically for representing the size of things. I think.

If a signed thing is necessary, then perhaps it could have a different type. For example, Offset could be defined with i64 as it's inner. An Offset could also be the result of a Size +/- some value.

Maybe Size could be generic on the type and constrain it to be some arithmetic, integer value?

Alternatively, a method like Size::ubytes() could return the size as an unsigned value? I just have a bunch of functions that take a value as an unsigned number of bytes, so I'd have to do a lot of casting everywhere to replace them with Size values, which I want to do :)

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