You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know I said earlier that I didn't have any more changes before a new release. But after some thinking I realized one thing. What is the reason for returning the tuple (Ipv4Addr, u32) from mask, network and broadcast? I can't see a reason when a caller would want both. Plus, the caller can always go from one to the other very simply. Returning both feels a bit redundant.
I suggest the public API always return the Ipv4Addr version only and internal functions who need the integer representation simply use u32::from internally. Cleaner API plus makes it easier to cast the value. Today if you want the representation in a u64 for example you need to do it in two rows, but with the proposed change it would be possible to do it in one:
let n = u32::from(cidr.mask())asu64
I didn't submit this as a PR directly since I didn't know if there was any special reason it was designed like this or not. Also it would require a major version bump (0.9.0?). However, it's no hurry to get any of this out. As I will continue to use this library I will probably find more stuff to implement in it in the coming days.
The text was updated successfully, but these errors were encountered:
I know I said earlier that I didn't have any more changes before a new release. But after some thinking I realized one thing. What is the reason for returning the tuple
(Ipv4Addr, u32)
frommask
,network
andbroadcast
? I can't see a reason when a caller would want both. Plus, the caller can always go from one to the other very simply. Returning both feels a bit redundant.I suggest the public API always return the
Ipv4Addr
version only and internal functions who need the integer representation simply useu32::from
internally. Cleaner API plus makes it easier to cast the value. Today if you want the representation in au64
for example you need to do it in two rows, but with the proposed change it would be possible to do it in one:I didn't submit this as a PR directly since I didn't know if there was any special reason it was designed like this or not. Also it would require a major version bump (0.9.0?). However, it's no hurry to get any of this out. As I will continue to use this library I will probably find more stuff to implement in it in the coming days.
The text was updated successfully, but these errors were encountered: