Skip to content

Have ip_addrs return IpNet or have a new method to do so #198

Closed

Description

@Isaac-Leonard

I'm working with some code that needs the prefix/mask for each ip in an interface and while writing my own function to do that was easy enough, it would be nice to have by default.
Something like:

pub fn ip_addrs_with_prefix(iface:Interface) -> Vec<IpNet> {
    self.ipv4_addrs()
        .into_iter()
        .chain(self.ipv6_addrs().into_iter())
        .collect()
}

Which is what I've got for myself now, though it should be changed to be an impl.

I'm happy to make a PR for this if you would like

Activity

  1. shellrow commented on Nov 21, 2026

    @shellrow
    Owner

    Thanks for the suggestion! I'll add ip_addrs_with_prefix() in v0.48.0, keeping ip_addrs() unchanged.

  2. linked a pull request that will close this issuefeat: add ip_addrs_with_prefix() #199on Nov 21, 2026
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