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
2 changes: 2 additions & 0 deletions examples/header_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
print("keys_len (unique keys):", headers.keys_len())
# Check if the map is empty
print("is_empty:", headers.is_empty())
# Print the entire header map
print(headers)
# Clear all headers
headers.clear()
print("After clear, is_empty:", headers.is_empty())
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl SocketAddr {
}
}

define_display!(SocketAddr);
impl_print_str!(Display, SocketAddr);

/// A builder for `Client`.
#[derive(Default)]
Expand Down
2 changes: 1 addition & 1 deletion src/client/resp/ws/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,4 @@ impl Message {
}
}

define_display!(Message);
impl_print_str!(Display, Message);
2 changes: 1 addition & 1 deletion src/cookie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Cookie {
}
}

define_display!(Cookie);
impl_print_str!(Display, Cookie);

// ===== impl Cookies =====

Expand Down
4 changes: 2 additions & 2 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl HeaderMap {
}
}

define_display!(HeaderMap);
impl_print_str!(Debug, HeaderMap);

impl FromPyObject<'_, '_> for HeaderMap {
type Error = PyErr;
Expand Down Expand Up @@ -338,7 +338,7 @@ impl OrigHeaderMap {
}
}

define_display!(OrigHeaderMap);
impl_print_str!(Debug, OrigHeaderMap);

impl FromPyObject<'_, '_> for OrigHeaderMap {
type Error = PyErr;
Expand Down
2 changes: 1 addition & 1 deletion src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ impl StatusCode {
}
}

define_display!(StatusCode);
impl_print_str!(Display, StatusCode);
2 changes: 1 addition & 1 deletion src/http1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ impl Http1Options {
}
}

define_display!(Http1Options);
impl_print_str!(Debug, Http1Options);
14 changes: 7 additions & 7 deletions src/http2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl StreamId {
}
}

define_display!(StreamId);
impl_print_str!(Display, StreamId);

// ===== impl StreamDependency =====

Expand All @@ -224,7 +224,7 @@ impl StreamDependency {
}
}

define_display!(StreamDependency);
impl_print_str!(Display, StreamDependency);

// ===== impl Priority =====

Expand All @@ -238,7 +238,7 @@ impl Priority {
}
}

define_display!(Priority);
impl_print_str!(Display, Priority);

// ===== impl Priorities =====

Expand All @@ -256,7 +256,7 @@ impl Priorities {
}
}

define_display!(Priorities);
impl_print_str!(Display, Priorities);

// ===== impl PseudoOrder =====

Expand All @@ -274,7 +274,7 @@ impl PseudoOrder {
}
}

define_display!(PseudoOrder);
impl_print_str!(Display, PseudoOrder);

// ===== impl SettingsOrder =====

Expand All @@ -292,7 +292,7 @@ impl SettingsOrder {
}
}

define_display!(SettingsOrder);
impl_print_str!(Display, SettingsOrder);

// ===== impl Builder =====

Expand Down Expand Up @@ -462,4 +462,4 @@ impl Http2Options {
}
}

define_display!(Http2Options);
impl_print_str!(Debug, Http2Options);
12 changes: 10 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,21 @@ macro_rules! define_enum {
};
}

macro_rules! define_display {
($typed:ident) => {
macro_rules! impl_print_str {
(Debug, $typed:ident) => {
impl std::fmt::Display for $typed {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Debug::fmt(&self.0, f)
}
}
};
(Display, $typed:ident) => {
impl std::fmt::Display for $typed {
#[inline]
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}
};
Comment thread
0x676e67 marked this conversation as resolved.
}
2 changes: 1 addition & 1 deletion src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl Proxy {
}
}

define_display!(Proxy);
impl_print_str!(Debug, Proxy);

fn create_proxy<'py>(
py: Python<'py>,
Expand Down
4 changes: 2 additions & 2 deletions src/redirect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl Policy {
}
}

define_display!(Policy);
impl_print_str!(Debug, Policy);

// ===== impl Attempt =====

Expand Down Expand Up @@ -196,4 +196,4 @@ impl Display for Action {

// ===== impl History =====

define_display!(History);
impl_print_str!(Debug, History);
Loading