From 493a3191321d8ee3872f0b839881300cf5abca53 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 5 Mar 2017 05:49:38 +0000 Subject: [PATCH] Remove the `use_` prefix from feature names. I haven't realized that a feature `log` with an optional crate dependency `log` activates that dependency, and added the prefix to avoid a "clash". This is unnecessary. --- .travis.yml | 10 +++++----- Cargo.toml | 11 +++++------ README.md | 16 ++++++++-------- src/iface/arp_cache.rs | 4 ++-- src/lib.rs | 14 +++++++------- src/phy/mod.rs | 10 +++++----- src/phy/tracer.rs | 2 +- src/socket/set.rs | 2 +- 8 files changed, 34 insertions(+), 35 deletions(-) diff --git a/.travis.yml b/.travis.yml index 011227a..64155b7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,15 +2,15 @@ language: rust matrix: include: - rust: stable - env: FEATURES='use_std' MODE='test' + env: FEATURES='std' MODE='test' - rust: beta - env: FEATURES='use_std' MODE='test' + env: FEATURES='std' MODE='test' - rust: nightly - env: FEATURES='use_std' MODE='test' + env: FEATURES='std' MODE='test' - rust: nightly - env: FEATURES='use_std use_log' MODE='test' + env: FEATURES='std log' MODE='test' - rust: nightly - env: FEATURES='use_alloc use_collections' MODE='build' + env: FEATURES='alloc collections' MODE='build' - rust: nightly env: FEATURES='' MODE='build' allow_failures: diff --git a/Cargo.toml b/Cargo.toml index 1df1cbc..63a3512 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ license = "0BSD" [dependencies] byteorder = { version = "1.0", default-features = false } -managed = { version = "0.2.1", default-features = false } +managed = { version = "0.3.0", default-features = false } log = { version = "0.3", default-features = false, optional = true } libc = { version = "0.2.18", optional = true } @@ -22,12 +22,11 @@ env_logger = "0.4" getopts = "0.2" [features] -use_std = ["managed/use_std", "libc"] -use_alloc = ["managed/use_alloc"] -use_collections = ["managed/use_collections"] -use_log = ["log"] +std = ["managed/std", "libc"] +alloc = ["managed/alloc"] +collections = ["managed/collections"] verbose = [] -default = ["use_std", "use_log", "verbose"] +default = ["std", "log", "verbose"] [[example]] name = "tcpdump" diff --git a/README.md b/README.md index d5236f6..7ff00f2 100644 --- a/README.md +++ b/README.md @@ -82,27 +82,27 @@ You probably want to disable default features and configure them one by one: smoltcp = { version = ..., default-features = false, features = [...] } ``` -### Feature `use_std` +### Feature `std` -The `use_std` feature enables use of objects and slices owned by the networking stack through a +The `std` feature enables use of objects and slices owned by the networking stack through a dependency on `std::boxed::Box` and `std::vec::Vec`. It also enables `smoltcp::phy::RawSocket` and `smoltcp::phy::TapInterface`, if the platform supports it. This feature is enabled by default. -### Feature `use_alloc` +### Feature `alloc` -The `use_alloc` feature enables use of objects owned by the networking stack through a dependency +The `alloc` feature enables use of objects owned by the networking stack through a dependency on `alloc::boxed::Box`. This only works on nightly rustc. -### Feature `use_collections` +### Feature `collections` -The `use_collections` feature enables use of slices owned by the networking stack through a dependency +The `collections` feature enables use of slices owned by the networking stack through a dependency on `collections::vec::Vec`. This only works on nightly rustc. -### Feature `use_log` +### Feature `log` -The `use_log` feature enables logging of events within the networking stack through +The `log` feature enables logging of events within the networking stack through the [log crate][log]. The events are emitted with the TRACE log level. [log]: https://crates.io/crates/log diff --git a/src/iface/arp_cache.rs b/src/iface/arp_cache.rs index 561e349..7544d7e 100644 --- a/src/iface/arp_cache.rs +++ b/src/iface/arp_cache.rs @@ -67,12 +67,12 @@ impl<'a> SliceCache<'a> { /// Sort entries in an order suitable for `find`. fn sort(&mut self) { - #[cfg(feature = "use_std")] + #[cfg(feature = "std")] fn sort(data: &mut [(IpAddress, EthernetAddress, usize)]) { data.sort_by_key(|&(key, _, _)| key) } - #[cfg(not(feature = "use_std"))] + #[cfg(not(feature = "std"))] fn sort(data: &mut [(IpAddress, EthernetAddress, usize)]) { // Use an insertion sort, which performs best on 10 elements and less. for i in 1..data.len() { diff --git a/src/lib.rs b/src/lib.rs index bb46a6a..37dcc7c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![cfg_attr(feature = "use_alloc", feature(alloc))] +#![cfg_attr(feature = "alloc", feature(alloc))] #![no_std] //! The _smoltcp_ library is built in a layered structure, with the layers corresponding @@ -69,22 +69,22 @@ extern crate byteorder; extern crate managed; -#[cfg(any(test, feature = "use_std"))] +#[cfg(any(test, feature = "std"))] #[macro_use] extern crate std; -#[cfg(feature = "use_std")] +#[cfg(feature = "std")] extern crate libc; -#[cfg(feature = "use_alloc")] +#[cfg(feature = "alloc")] extern crate alloc; -#[cfg(any(test, feature = "use_log"))] +#[cfg(any(test, feature = "log"))] #[macro_use(trace, log)] extern crate log; macro_rules! net_trace { ($($arg:expr),*) => { - #[cfg(feature = "use_log")] + #[cfg(feature = "log")] trace!($($arg),*); - #[cfg(not(feature = "use_log"))] + #[cfg(not(feature = "log"))] $( let _ = $arg );*; // suppress unused variable warnings } } diff --git a/src/phy/mod.rs b/src/phy/mod.rs index 5805f65..50657fc 100644 --- a/src/phy/mod.rs +++ b/src/phy/mod.rs @@ -97,21 +97,21 @@ impl Drop for EthernetTxBuffer { use Error; -#[cfg(feature = "use_std")] +#[cfg(feature = "std")] mod sys; mod tracer; mod fault_injector; -#[cfg(feature = "use_std")] +#[cfg(feature = "std")] mod raw_socket; -#[cfg(all(feature = "use_std", target_os = "linux"))] +#[cfg(all(feature = "std", target_os = "linux"))] mod tap_interface; pub use self::tracer::Tracer; pub use self::fault_injector::FaultInjector; -#[cfg(feature = "use_std")] +#[cfg(feature = "std")] pub use self::raw_socket::RawSocket; -#[cfg(all(feature = "use_std", target_os = "linux"))] +#[cfg(all(feature = "std", target_os = "linux"))] pub use self::tap_interface::TapInterface; /// An interface for sending and receiving raw network frames. diff --git a/src/phy/tracer.rs b/src/phy/tracer.rs index 182353b..6c32021 100644 --- a/src/phy/tracer.rs +++ b/src/phy/tracer.rs @@ -21,7 +21,7 @@ impl Tracer { } /// Create a tracer device, printing to standard output. - #[cfg(feature = "use_std")] + #[cfg(feature = "std")] pub fn new_stdout(lower: T) -> Tracer { fn writer(printer: PrettyPrinter) { print!("{}", printer) diff --git a/src/socket/set.rs b/src/socket/set.rs index fd74c74..ff34cc5 100644 --- a/src/socket/set.rs +++ b/src/socket/set.rs @@ -61,7 +61,7 @@ impl<'a, 'b: 'a, 'c: 'a + 'b> Set<'a, 'b, 'c> { ManagedSlice::Borrowed(_) => { panic!("adding a socket to a full SocketSet") } - #[cfg(any(feature = "use_std", feature = "use_collections"))] + #[cfg(any(feature = "std", feature = "collections"))] ManagedSlice::Owned(ref mut sockets) => { sockets.push(None); let index = sockets.len() - 1;