From d3cb7b1952b4076511f270f3f8cca42414e0278e Mon Sep 17 00:00:00 2001 From: onalante-msft <89409054+onalante-msft@users.noreply.github.com> Date: Wed, 16 Feb 2022 07:24:28 -0800 Subject: [PATCH 1/2] Use all features in docsrs and use macro for features --- Cargo.toml | 3 +++ src/lib.rs | 40 +++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index fc2c070..7d18aa5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,3 +41,6 @@ required-features = ["server", "hyper/runtime"] [[test]] name = "server_client" required-features = ["client", "server", "hyper/runtime"] + +[package.metadata.docs.rs] +all-features = true diff --git a/src/lib.rs b/src/lib.rs index 0a64652..f5ec99b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,23 +21,33 @@ //! //! # Features //! -//! - Client- enables the client extension trait and connector. *Enabled by -//! default*. +//! - Client- enables the client extension trait and connector. //! -//! - Server- enables the server extension trait. *Enabled by default*. - -#[cfg(feature = "client")] -mod client; -#[cfg(feature = "client")] -pub use client::{UnixClientExt, UnixConnector}; - -#[cfg(feature = "server")] -mod server; -#[cfg(feature = "server")] -pub use server::UnixServerExt; +//! - Server- enables the server extension trait. mod uri; pub use uri::Uri; -#[cfg(feature = "server")] -pub use crate::server::conn::SocketIncoming; +macro_rules! attr_each { + (#[$meta:meta] $($item:item)*) => { + $( + #[$meta] + $item + )* + } +} + +attr_each! { + #[cfg(feature = "client")] + + mod client; + pub use client::{UnixClientExt, UnixConnector}; +} + +attr_each! { + #[cfg(feature = "server")] + + mod server; + pub use server::UnixServerExt; + pub use server::conn::SocketIncoming; +} From 1ec192c0a925f954624ec41c6cd0ae18fe59e5a1 Mon Sep 17 00:00:00 2001 From: onalante-msft <89409054+onalante-msft@users.noreply.github.com> Date: Wed, 16 Feb 2022 07:33:08 -0800 Subject: [PATCH 2/2] Remove duplicate .rustfmt.toml and fix deprecations merge_imports has been deprecated. --- .rustfmt.toml | 5 ----- rustfmt.toml | 11 +++++------ src/uri.rs | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) delete mode 100644 .rustfmt.toml diff --git a/.rustfmt.toml b/.rustfmt.toml deleted file mode 100644 index b4d1e94..0000000 --- a/.rustfmt.toml +++ /dev/null @@ -1,5 +0,0 @@ -version = "Two" -use_field_init_shorthand = true -merge_imports = true -wrap_comments = true -use_try_shorthand = true \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml index 0f780d3..82dc1c9 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,6 +1,5 @@ -# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#fn_args_layout -fn_args_layout = "Vertical" -# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#merge_imports -merge_imports = true -# https://github.com/rust-lang/rustfmt/blob/master/Configurations.md#format_code_in_doc_comments -format_code_in_doc_comments = true \ No newline at end of file +version = "Two" +imports_granularity = "Crate" +format_code_in_doc_comments = true +use_field_init_shorthand = true +wrap_comments = true diff --git a/src/uri.rs b/src/uri.rs index 23fb167..3c4723e 100644 --- a/src/uri.rs +++ b/src/uri.rs @@ -7,8 +7,8 @@ use std::path::Path; /// /// # Example /// ``` -/// use hyperlocal::Uri; /// use hyper::Uri as HyperUri; +/// use hyperlocal::Uri; /// /// let uri: HyperUri = Uri::new("/tmp/hyperlocal.sock", "/").into(); /// ```