aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-11-14 08:36:57 +0100
committerMartin Fischer <martin@push-f.com>2021-12-05 01:53:28 +0100
commitb74f8b6b0d0f080cff5f5ff78d88dc4d7d2165a1 (patch)
tree1060754a18ddb081f22250d96f472fef03478663 /src
parenta4b81f82d6cd427f83c52777b5f5a437d91cce8d (diff)
Make Debug impl of Uri developer friendly
Previously an assertion like: assert_eq!(Uri::parse("some/path"), Uri::parse("other/path")); resulted in a panic like: thread 'uri::tests::example' panicked at 'assertion failed: `(left == right)` left: `Ok(Uri { scheme: None, authority: None, path: [[115, 111, 109, 101], [112, 97, 116, 104]], query: None, fragment: None })`, right: `Ok(Uri { scheme: None, authority: None, path: [[111, 116, 104, 101, 114], [112, 97, 116, 104]], query: None, fragment: None })`' This commit changes the Debug impl to be more developer friendly: thread 'uri::tests::example' panicked at 'assertion failed: `(left == right)` left: `Ok(Uri("some/path"))`, right: `Ok(Uri("other/path"))`' Fixes #3.
Diffstat (limited to 'src')
-rw-r--r--src/uri.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/uri.rs b/src/uri.rs
index bd1b82c..da706f2 100644
--- a/src/uri.rs
+++ b/src/uri.rs
@@ -97,7 +97,7 @@ use super::{
/// [slice]: https://doc.rust-lang.org/std/primitive.slice.html
/// [`TryFrom::try_from`]: https://doc.rust-lang.org/std/convert/trait.TryFrom.html#tymethod.try_from
/// [`TryInto::try_into`]: https://doc.rust-lang.org/std/convert/trait.TryInto.html#tymethod.try_into
-#[derive(Clone, Debug, Default, PartialEq)]
+#[derive(Clone, Default, PartialEq)]
pub struct Uri {
scheme: Option<String>,
authority: Option<Authority>,
@@ -775,6 +775,15 @@ impl Uri {
}
}
+impl std::fmt::Debug for Uri {
+ fn fmt(
+ &self,
+ f: &mut std::fmt::Formatter<'_>,
+ ) -> std::fmt::Result {
+ f.debug_tuple("Uri").field(&self.to_string()).finish()
+ }
+}
+
impl std::fmt::Display for Uri {
fn fmt(
&self,