Stream: wg-cli

Topic: u64_vs_usize


Donough Liu (Jan 28 2021 at 04:41, on Zulip):

I noticed that all of the number type in Arg is u64, why aren't they usize?

Josh Triplett (Feb 16 2021 at 20:59, on Zulip):

@Donough Liu usize is appropriate for "size of an array or string or similar that fits in memory". It isn't appropriate for arbitrary numeric values.

Josh Triplett (Feb 16 2021 at 21:00, on Zulip):

An arbitrary numeric command-line argument should not have a maximum size that varies by platform.

Donough Liu (Feb 17 2021 at 16:47, on Zulip):

@Josh Triplett All of the u64 in the Arg is for array size. Changing them to usize doesn't affect a numeric argument's value range. :sweat_smile:

Donough Liu (Feb 17 2021 at 17:08, on Zulip):

It's pretty internal though.

Josh Triplett (Feb 17 2021 at 17:20, on Zulip):

Ah, sorry, I didn't realize you meant internal to a structure.

Josh Triplett (Feb 17 2021 at 17:21, on Zulip):

Thanks for clarifying.

Josh Triplett (Feb 17 2021 at 17:21, on Zulip):

Then yeah, usize sounds fine.

Last update: Apr 15 2021 at 02:00UTC