mirror of
https://github.com/actix/actix-web.git
synced 2024-12-28 02:50:39 +00:00
derive debug where possible (#2142)
This commit is contained in:
parent
44a2d2214c
commit
c72d77065d
5 changed files with 14 additions and 43 deletions
|
@ -80,7 +80,7 @@ use crate::{
|
|||
/// })
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub struct Form<T>(pub T);
|
||||
|
||||
impl<T> Form<T> {
|
||||
|
@ -150,12 +150,6 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for Form<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Display> fmt::Display for Form<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
|
|
|
@ -23,7 +23,7 @@ use crate::{
|
|||
/// format!("Request was sent at {}", date.to_string())
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub struct Header<T>(pub T);
|
||||
|
||||
impl<T> Header<T> {
|
||||
|
@ -47,15 +47,6 @@ impl<T> ops::DerefMut for Header<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Header<T>
|
||||
where
|
||||
T: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Header: {:?}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> fmt::Display for Header<T>
|
||||
where
|
||||
T: fmt::Display,
|
||||
|
|
|
@ -73,6 +73,7 @@ use crate::{
|
|||
/// })
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Debug)]
|
||||
pub struct Json<T>(pub T);
|
||||
|
||||
impl<T> Json<T> {
|
||||
|
@ -96,15 +97,6 @@ impl<T> ops::DerefMut for Json<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> fmt::Debug for Json<T>
|
||||
where
|
||||
T: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "Json: {:?}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> fmt::Display for Json<T>
|
||||
where
|
||||
T: fmt::Display,
|
||||
|
|
|
@ -45,7 +45,7 @@ use crate::{dev::Payload, error::PathError, FromRequest, HttpRequest};
|
|||
/// format!("Welcome {}!", info.name)
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub struct Path<T>(T);
|
||||
|
||||
impl<T> Path<T> {
|
||||
|
@ -81,12 +81,6 @@ impl<T> From<T> for Path<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for Path<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Display> fmt::Display for Path<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
|
@ -261,7 +255,7 @@ mod tests {
|
|||
assert_eq!(s.value, "user2");
|
||||
assert_eq!(
|
||||
format!("{}, {:?}", s, s),
|
||||
"MyStruct(name, user2), MyStruct { key: \"name\", value: \"user2\" }"
|
||||
"MyStruct(name, user2), Path(MyStruct { key: \"name\", value: \"user2\" })"
|
||||
);
|
||||
let s = s.into_inner();
|
||||
assert_eq!(s.value, "user2");
|
||||
|
|
|
@ -57,7 +57,7 @@ use crate::{dev::Payload, error::QueryPayloadError, Error, FromRequest, HttpRequ
|
|||
/// "OK".to_string()
|
||||
/// }
|
||||
/// ```
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||
pub struct Query<T>(pub T);
|
||||
|
||||
impl<T> Query<T> {
|
||||
|
@ -100,12 +100,6 @@ impl<T> ops::DerefMut for Query<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Debug> fmt::Debug for Query<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: fmt::Display> fmt::Display for Query<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
self.0.fmt(f)
|
||||
|
@ -226,7 +220,10 @@ mod tests {
|
|||
let mut s = Query::<Id>::from_query(&req.query_string()).unwrap();
|
||||
|
||||
assert_eq!(s.id, "test");
|
||||
assert_eq!(format!("{}, {:?}", s, s), "test, Id { id: \"test\" }");
|
||||
assert_eq!(
|
||||
format!("{}, {:?}", s, s),
|
||||
"test, Query(Id { id: \"test\" })"
|
||||
);
|
||||
|
||||
s.id = "test1".to_string();
|
||||
let s = s.into_inner();
|
||||
|
@ -244,7 +241,10 @@ mod tests {
|
|||
|
||||
let mut s = Query::<Id>::from_request(&req, &mut pl).await.unwrap();
|
||||
assert_eq!(s.id, "test");
|
||||
assert_eq!(format!("{}, {:?}", s, s), "test, Id { id: \"test\" }");
|
||||
assert_eq!(
|
||||
format!("{}, {:?}", s, s),
|
||||
"test, Query(Id { id: \"test\" })"
|
||||
);
|
||||
|
||||
s.id = "test1".to_string();
|
||||
let s = s.into_inner();
|
||||
|
|
Loading…
Reference in a new issue