-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #305 Implement Debug for many types #335
Changes from 4 commits
b7ebdb3
94af92f
0ae3540
01e70b9
2f0f2f6
81fdb30
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,7 @@ use percent_encoding::{PATH_SEGMENT_ENCODE_SET, USERINFO_ENCODE_SET, | |
use std::borrow::Borrow; | ||
use std::cmp; | ||
#[cfg(feature = "serde")] use std::error::Error; | ||
use std::fmt::{self, Write}; | ||
use std::fmt::{self, Write, Debug, Formatter}; | ||
use std::hash; | ||
use std::io; | ||
use std::mem; | ||
|
@@ -213,6 +213,16 @@ impl<'a> ParseOptions<'a> { | |
} | ||
} | ||
|
||
impl<'a> Debug for ParseOptions<'a> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The body of this function can just be
Edit: I've never done a github review before so if this comment blocks or something feel free to close it with a garbage comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about the log_syntax_violation field? Shouldn't it be included? And as it includes a |
||
fn fmt(&self, f: &mut Formatter) -> fmt::Result { | ||
write!(f, "ParseOptions {{ base_url: {:?}, encoding_override: {:?}, log_syntax_violation: ", self.base_url, self.encoding_override)?; | ||
match self.log_syntax_violation { | ||
Some(_) => write!(f, "Some(Fn(&'static str)) }}"), | ||
None => write!(f, "None }}") | ||
} | ||
} | ||
} | ||
|
||
impl Url { | ||
/// Parse an absolute URL from a string. | ||
/// | ||
|
@@ -1870,6 +1880,7 @@ fn io_error<T>(reason: &str) -> io::Result<T> { | |
} | ||
|
||
/// Implementation detail of `Url::query_pairs_mut`. Typically not used directly. | ||
#[derive(Debug)] | ||
pub struct UrlQuery<'a> { | ||
url: &'a mut Url, | ||
fragment: Option<String>, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,7 @@ macro_rules! define_encode_set { | |
} | ||
|
||
/// This encode set is used for the path of cannot-be-a-base URLs. | ||
#[derive(Copy, Clone)] | ||
#[derive(Copy, Clone, Debug)] | ||
#[allow(non_camel_case_types)] | ||
pub struct SIMPLE_ENCODE_SET; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to derive Debug in the encoding set macro to get the rest of *_ENCODE_SET types. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, will do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
|
||
|
@@ -163,7 +163,7 @@ pub fn utf8_percent_encode<E: EncodeSet>(input: &str, encode_set: E) -> PercentE | |
} | ||
|
||
/// The return type of `percent_encode()` and `utf8_percent_encode()`. | ||
#[derive(Clone)] | ||
#[derive(Clone, Debug)] | ||
pub struct PercentEncode<'a, E: EncodeSet> { | ||
bytes: &'a [u8], | ||
encode_set: E, | ||
|
@@ -249,7 +249,7 @@ pub fn percent_decode<'a>(input: &'a [u8]) -> PercentDecode<'a> { | |
} | ||
|
||
/// The return type of `percent_decode()`. | ||
#[derive(Clone)] | ||
#[derive(Clone, Debug)] | ||
pub struct PercentDecode<'a> { | ||
bytes: slice::Iter<'a, u8>, | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just derive Debug on the structs compiled for each feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't derive Debug in this case because encoding field has type
Option<EncodingRef>
andEncodingRef
trait isn't Debug