Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.


## [Unreleased]
### Changed
- Rename the "ipnet" feature to "ipnetwork" to match the dependency.
- Rename the "mac" feature to "macaddr" to match the dependency.


## [0.2.0] - 2025-05-11
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ proc-macro = true
## By default, only generate stdlib types
default = []
## enables generation of [`ipnetwork`] types
ipnet = ["dep:ipnetwork"]
ipnetwork = ["dep:ipnetwork"]
## enables generation of [`macaddr`] types
mac = ["dep:macaddr"]
macaddr = ["dep:macaddr"]

[dependencies]
cfg-if = "1"
Expand Down
24 changes: 12 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ make_macro! {
// IpNetwork types

cfg_if::cfg_if! {
if #[cfg(feature = "ipnet")] {
if #[cfg(feature = "ipnetwork")] {
use ipnetwork::{IpNetwork, Ipv4Network, Ipv6Network};

make_macro!{
Expand All @@ -198,7 +198,7 @@ cfg_if::cfg_if! {
quote! { ipnetwork::IpNetwork::V6(#inner) }
}
};
"ipnet"
"ipnetwork"
}

make_macro!{
Expand All @@ -208,7 +208,7 @@ cfg_if::cfg_if! {
let prefix = net.prefix();
quote! { ipnetwork::Ipv4Network::new_checked(#ip, #prefix).unwrap() }
};
"ipnet"
"ipnetwork"
}


Expand All @@ -219,15 +219,15 @@ cfg_if::cfg_if! {
let prefix = net.prefix();
quote! { ipnetwork::Ipv6Network::new_checked(#ip, #prefix).unwrap() }
};
"ipnet"
"ipnetwork"
}
}
}

// MacAddr types

cfg_if::cfg_if! {
if #[cfg(feature = "mac")] {
if #[cfg(feature = "macaddr")] {
use macaddr::{MacAddr, MacAddr6, MacAddr8};

make_macro!{
Expand All @@ -242,7 +242,7 @@ cfg_if::cfg_if! {
quote! { macaddr::MacAddr::V8(#inner) }
}
};
"mac"
"macaddr"
}

make_macro! {
Expand All @@ -251,7 +251,7 @@ cfg_if::cfg_if! {
let bytes = addr.into_array();
quote! { macaddr::MacAddr6::new(#(#bytes),*) }
};
"mac"
"macaddr"
}

make_macro!{
Expand All @@ -260,7 +260,7 @@ cfg_if::cfg_if! {
let bytes = addr.into_array();
quote! { macaddr::MacAddr8::new(#(#bytes),*) }
};
"mac"
"macaddr"
}
}
}
Expand All @@ -278,13 +278,13 @@ mod tests {
t.compile_fail("tests/fail/sock4.rs");
t.compile_fail("tests/fail/sock6.rs");

if cfg!(feature = "ipnet") {
if cfg!(feature = "ipnetwork") {
t.compile_fail("tests/fail/net.rs");
t.compile_fail("tests/fail/net4.rs");
t.compile_fail("tests/fail/net6.rs");
}

if cfg!(feature = "mac") {
if cfg!(feature = "macaddr") {
t.compile_fail("tests/fail/mac.rs");
t.compile_fail("tests/fail/mac6.rs");
t.compile_fail("tests/fail/mac8.rs");
Expand All @@ -297,13 +297,13 @@ mod tests {
t.pass("tests/pass/sock4.rs");
t.pass("tests/pass/sock6.rs");

if cfg!(feature = "ipnet") {
if cfg!(feature = "ipnetwork") {
t.pass("tests/pass/net.rs");
t.pass("tests/pass/net4.rs");
t.pass("tests/pass/net6.rs");
}

if cfg!(feature = "mac") {
if cfg!(feature = "macaddr") {
t.pass("tests/pass/mac.rs");
t.pass("tests/pass/mac6.rs");
t.pass("tests/pass/mac8.rs");
Expand Down