mirror of https://github.com/fafhrd91/actix-web
fix for tuple struct
This commit is contained in:
parent
618ed2d821
commit
6d0bc6bd1a
|
|
@ -435,13 +435,13 @@ impl<'de> Deserializer<'de> for Value<'de> {
|
||||||
fn deserialize_tuple_struct<V>(
|
fn deserialize_tuple_struct<V>(
|
||||||
self,
|
self,
|
||||||
_: &'static str,
|
_: &'static str,
|
||||||
_: usize,
|
len: usize,
|
||||||
_: V,
|
visitor: V,
|
||||||
) -> Result<V::Value, Self::Error>
|
) -> Result<V::Value, Self::Error>
|
||||||
where
|
where
|
||||||
V: Visitor<'de>,
|
V: Visitor<'de>,
|
||||||
{
|
{
|
||||||
Err(de::value::Error::custom("unsupported type: tuple struct"))
|
self.deserialize_tuple(len, visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
fn deserialize_any<V>(self, visitor: V) -> Result<V::Value, Self::Error>
|
||||||
|
|
@ -627,6 +627,14 @@ mod tests {
|
||||||
tail: (String, String, String),
|
tail: (String, String, String),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
struct TestSeq3 {
|
||||||
|
tail: TestTupleStruct,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize, PartialEq)]
|
||||||
|
struct TestTupleStruct(String, String, String);
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_request_extract() {
|
fn test_request_extract() {
|
||||||
let mut router = Router::<()>::build();
|
let mut router = Router::<()>::build();
|
||||||
|
|
@ -753,6 +761,16 @@ mod tests {
|
||||||
String::from("slash/es")
|
String::from("slash/es")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let i: TestSeq3 = de::Deserialize::deserialize(PathDeserializer::new(&path)).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
i.tail,
|
||||||
|
TestTupleStruct(
|
||||||
|
String::from("tail"),
|
||||||
|
String::from("with"),
|
||||||
|
String::from("slash/es")
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue