Skip to content

Commit

Permalink
chore: Move macros to lib mod (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x676e67 authored Jan 23, 2025
1 parent f96523f commit 6209589
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 56 deletions.
57 changes: 56 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,62 @@ pub use self::error::{Error, Result};
pub use self::into_url::IntoUrl;
pub use self::response::ResponseBuilderExt;

/// Macro to implement Debug for a type, skipping certain fields.
#[macro_export]
macro_rules! impl_debug {
($type:ty, { $($field_name:ident),* }) => {
impl std::fmt::Debug for $type {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let mut debug_struct = f.debug_struct(stringify!($type));
$(
debug_struct.field(stringify!($field_name), &self.$field_name);
)*
debug_struct.finish()
}
}
}
}

/// Macro to conditionally compile code for bindable devices.
#[macro_export]
macro_rules! cfg_bindable_device {
($($tt:tt)*) => {
#[cfg(any(
target_os = "android",
target_os = "fuchsia",
target_os = "linux",
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos"
))]
$(
$tt
)*
};
}

/// Macro to conditionally compile code for non-bindable devices.
#[macro_export]
macro_rules! cfg_non_bindable_device {
($($tt:tt)*) => {
#[cfg(not(any(
target_os = "android",
target_os = "fuchsia",
target_os = "linux",
target_os = "ios",
target_os = "visionos",
target_os = "macos",
target_os = "tvos",
target_os = "watchos"
)))]
$(
$tt
)*
}
}

/// Shortcut method to quickly make a `GET` request.
///
/// See also the methods on the [`rquest::Response`](./struct.Response.html)
Expand Down Expand Up @@ -354,7 +410,6 @@ mod connect;
#[cfg(feature = "cookies")]
pub mod cookie;
pub mod dns;
mod macros;
mod proxy;
pub mod redirect;

Expand Down
55 changes: 0 additions & 55 deletions src/macros.rs

This file was deleted.

0 comments on commit 6209589

Please sign in to comment.