Improve fmt::Debug of Client and ClientBuilder

This commit is contained in:
Sean McArthur
2019-10-09 12:15:27 -07:00
parent 75ee4646ac
commit 6b5726aaa8
5 changed files with 141 additions and 16 deletions

View File

@@ -14,7 +14,6 @@ use crate::Url;
/// the allowed maximum redirect hops in a chain.
/// - `none` can be used to disable all redirect behavior.
/// - `custom` can be used to create a customized policy.
#[derive(Debug)]
pub struct RedirectPolicy {
inner: Policy,
}
@@ -142,10 +141,18 @@ impl RedirectPolicy {
})
.inner
}
pub(crate) fn is_default(&self) -> bool {
match self.inner {
Policy::Limit(10) => true,
_ => false,
}
}
}
impl Default for RedirectPolicy {
fn default() -> RedirectPolicy {
// Keep `is_default` in sync
RedirectPolicy::limited(10)
}
}
@@ -206,6 +213,12 @@ enum Policy {
None,
}
impl fmt::Debug for RedirectPolicy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_tuple("RedirectPolicy").field(&self.inner).finish()
}
}
impl fmt::Debug for Policy {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {