mirror of
https://github.com/fafhrd91/actix-web
synced 2025-02-07 13:54:24 +01:00
derive debug where possible (#2142)
This commit is contained in:
parent
44a2d2214c
commit
c72d77065d
@ -80,7 +80,7 @@ use crate::{
|
|||||||
/// })
|
/// })
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||||
pub struct Form<T>(pub T);
|
pub struct Form<T>(pub T);
|
||||||
|
|
||||||
impl<T> Form<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> {
|
impl<T: fmt::Display> fmt::Display for Form<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.0.fmt(f)
|
self.0.fmt(f)
|
||||||
|
@ -23,7 +23,7 @@ use crate::{
|
|||||||
/// format!("Request was sent at {}", date.to_string())
|
/// 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);
|
pub struct Header<T>(pub T);
|
||||||
|
|
||||||
impl<T> Header<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>
|
impl<T> fmt::Display for Header<T>
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
|
@ -73,6 +73,7 @@ use crate::{
|
|||||||
/// })
|
/// })
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct Json<T>(pub T);
|
pub struct Json<T>(pub T);
|
||||||
|
|
||||||
impl<T> Json<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>
|
impl<T> fmt::Display for Json<T>
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
|
@ -45,7 +45,7 @@ use crate::{dev::Payload, error::PathError, FromRequest, HttpRequest};
|
|||||||
/// format!("Welcome {}!", info.name)
|
/// format!("Welcome {}!", info.name)
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||||
pub struct Path<T>(T);
|
pub struct Path<T>(T);
|
||||||
|
|
||||||
impl<T> Path<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> {
|
impl<T: fmt::Display> fmt::Display for Path<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.0.fmt(f)
|
self.0.fmt(f)
|
||||||
@ -261,7 +255,7 @@ mod tests {
|
|||||||
assert_eq!(s.value, "user2");
|
assert_eq!(s.value, "user2");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
format!("{}, {:?}", s, s),
|
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();
|
let s = s.into_inner();
|
||||||
assert_eq!(s.value, "user2");
|
assert_eq!(s.value, "user2");
|
||||||
|
@ -57,7 +57,7 @@ use crate::{dev::Payload, error::QueryPayloadError, Error, FromRequest, HttpRequ
|
|||||||
/// "OK".to_string()
|
/// "OK".to_string()
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug)]
|
||||||
pub struct Query<T>(pub T);
|
pub struct Query<T>(pub T);
|
||||||
|
|
||||||
impl<T> Query<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> {
|
impl<T: fmt::Display> fmt::Display for Query<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
self.0.fmt(f)
|
self.0.fmt(f)
|
||||||
@ -226,7 +220,10 @@ mod tests {
|
|||||||
let mut s = Query::<Id>::from_query(&req.query_string()).unwrap();
|
let mut s = Query::<Id>::from_query(&req.query_string()).unwrap();
|
||||||
|
|
||||||
assert_eq!(s.id, "test");
|
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();
|
s.id = "test1".to_string();
|
||||||
let s = s.into_inner();
|
let s = s.into_inner();
|
||||||
@ -244,7 +241,10 @@ mod tests {
|
|||||||
|
|
||||||
let mut s = Query::<Id>::from_request(&req, &mut pl).await.unwrap();
|
let mut s = Query::<Id>::from_request(&req, &mut pl).await.unwrap();
|
||||||
assert_eq!(s.id, "test");
|
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();
|
s.id = "test1".to_string();
|
||||||
let s = s.into_inner();
|
let s = s.into_inner();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user