mirror of
https://github.com/openharmony/third_party_rust_serde_urlencoded.git
synced 2026-07-01 20:03:59 -04:00
upgrade serde_urlencoded third party rust to version 7.1.0
Signed-off-by: peizhe <472708703@qq.com>
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
language: rust
|
||||
rust:
|
||||
- nightly
|
||||
- beta
|
||||
- stable
|
||||
branches:
|
||||
except:
|
||||
- staging.tmp
|
||||
+9
-7
@@ -1,13 +1,15 @@
|
||||
[package]
|
||||
name = "serde_urlencoded"
|
||||
version = "0.6.1"
|
||||
version = "0.7.1" # bump in documentation link and in README on update
|
||||
authors = ["Anthony Ramine <n.oxyde@gmail.com>"]
|
||||
license = "MIT/Apache-2.0"
|
||||
repository = "https://github.com/nox/serde_urlencoded"
|
||||
documentation = "https://docs.rs/serde_urlencoded"
|
||||
documentation = "https://docs.rs/serde_urlencoded/0.7.1/serde_urlencoded/"
|
||||
description = "`x-www-form-urlencoded` meets Serde"
|
||||
categories = ["encoding", "web-programming"]
|
||||
keywords = ["serde", "serialization", "urlencoded"]
|
||||
exclude = ["/.travis.yml", "/bors.toml"]
|
||||
edition = "2018"
|
||||
|
||||
[badges]
|
||||
travis-ci = {repository = "nox/serde_urlencoded"}
|
||||
@@ -16,10 +18,10 @@ travis-ci = {repository = "nox/serde_urlencoded"}
|
||||
test = false
|
||||
|
||||
[dependencies]
|
||||
dtoa = "0.4.0"
|
||||
itoa = "0.4.0"
|
||||
serde = "1.0.0"
|
||||
url = "2.0.0"
|
||||
form_urlencoded = "1"
|
||||
itoa = "1"
|
||||
ryu = "1"
|
||||
serde = "1.0.69"
|
||||
|
||||
[dev-dependencies]
|
||||
serde_derive = "1.0"
|
||||
serde_derive = "1"
|
||||
|
||||
@@ -18,10 +18,13 @@ This crate works with Cargo and can be found on
|
||||
|
||||
```toml
|
||||
[dependencies]
|
||||
serde_urlencoded = "0.5.1"
|
||||
serde_urlencoded = "0.7"
|
||||
```
|
||||
|
||||
The documentation is available on [docs.rs].
|
||||
|
||||
[crates.io]: https://crates.io/crates/serde_urlencoded
|
||||
[docs.rs]: https://docs.rs/serde_urlencoded/0.7.1/serde_urlencoded/
|
||||
|
||||
## Getting help
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
match_block_trailing_comma = true
|
||||
match_block_trailing_comma = false
|
||||
max_width = 80
|
||||
newline_style = "Unix"
|
||||
reorder_imports = true
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
//! Deserialization support for the `application/x-www-form-urlencoded` format.
|
||||
|
||||
use form_urlencoded::parse;
|
||||
use form_urlencoded::Parse as UrlEncodedParse;
|
||||
use serde::de::value::MapDeserializer;
|
||||
use serde::de::Error as de_Error;
|
||||
use serde::de::{self, IntoDeserializer};
|
||||
use serde::forward_to_deserialize_any;
|
||||
use std::borrow::Cow;
|
||||
use std::io::Read;
|
||||
use url::form_urlencoded::parse;
|
||||
use url::form_urlencoded::Parse as UrlEncodedParse;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use serde::de::value::Error;
|
||||
|
||||
/// Deserializes a `application/x-wwww-url-encoded` value from a `&[u8]`.
|
||||
/// Deserializes a `application/x-www-form-urlencoded` value from a `&[u8]`.
|
||||
///
|
||||
/// ```
|
||||
/// let meal = vec![
|
||||
@@ -33,7 +34,7 @@ where
|
||||
T::deserialize(Deserializer::new(parse(input)))
|
||||
}
|
||||
|
||||
/// Deserializes a `application/x-wwww-url-encoded` value from a `&str`.
|
||||
/// Deserializes a `application/x-www-form-urlencoded` value from a `&str`.
|
||||
///
|
||||
/// ```
|
||||
/// let meal = vec![
|
||||
|
||||
+3
-8
@@ -1,17 +1,12 @@
|
||||
//! `x-www-form-urlencoded` meets Serde
|
||||
|
||||
#![warn(unused_extern_crates)]
|
||||
|
||||
extern crate dtoa;
|
||||
extern crate itoa;
|
||||
#[macro_use]
|
||||
extern crate serde;
|
||||
extern crate url;
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
pub mod de;
|
||||
pub mod ser;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use de::{from_bytes, from_reader, from_str, Deserializer};
|
||||
pub use crate::de::{from_bytes, from_reader, from_str, Deserializer};
|
||||
#[doc(inline)]
|
||||
pub use ser::{to_string, Serializer};
|
||||
pub use crate::ser::{to_string, Serializer};
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
use ser::part::Sink;
|
||||
use ser::Error;
|
||||
use crate::ser::part::Sink;
|
||||
use crate::ser::Error;
|
||||
use serde::Serialize;
|
||||
use std::borrow::Cow;
|
||||
use std::ops::Deref;
|
||||
@@ -38,7 +38,7 @@ where
|
||||
End: for<'key> FnOnce(Key<'key>) -> Result<Ok, Error>,
|
||||
{
|
||||
pub fn new(end: End) -> Self {
|
||||
KeySink { end: end }
|
||||
KeySink { end }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+45
-28
@@ -5,15 +5,15 @@ mod pair;
|
||||
mod part;
|
||||
mod value;
|
||||
|
||||
use form_urlencoded::Serializer as UrlEncodedSerializer;
|
||||
use form_urlencoded::Target as UrlEncodedTarget;
|
||||
use serde::ser;
|
||||
use std::borrow::Cow;
|
||||
use std::error;
|
||||
use std::fmt;
|
||||
use std::str;
|
||||
use url::form_urlencoded::Serializer as UrlEncodedSerializer;
|
||||
use url::form_urlencoded::Target as UrlEncodedTarget;
|
||||
|
||||
/// Serializes a value into a `application/x-wwww-url-encoded` `String` buffer.
|
||||
/// Serializes a value into a `application/x-www-form-urlencoded` `String` buffer.
|
||||
///
|
||||
/// ```
|
||||
/// let meal = &[
|
||||
@@ -42,16 +42,18 @@ pub fn to_string<T: ser::Serialize>(input: T) -> Result<String, Error> {
|
||||
/// unit structs and unit variants.
|
||||
///
|
||||
/// * Newtype structs defer to their inner values.
|
||||
pub struct Serializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
||||
pub struct Serializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||
}
|
||||
|
||||
impl<'input, 'output, Target: 'output + UrlEncodedTarget> Serializer<'input, 'output, Target> {
|
||||
impl<'input, 'output, Target: 'output + UrlEncodedTarget>
|
||||
Serializer<'input, 'output, Target>
|
||||
{
|
||||
/// Returns a new `Serializer`.
|
||||
pub fn new(urlencoder: &'output mut UrlEncodedSerializer<'input, Target>) -> Self {
|
||||
Serializer {
|
||||
urlencoder: urlencoder,
|
||||
}
|
||||
pub fn new(
|
||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||
) -> Self {
|
||||
Serializer { urlencoder }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +65,7 @@ pub enum Error {
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
Error::Custom(ref msg) => msg.fmt(f),
|
||||
Error::Utf8(ref err) => write!(f, "invalid UTF-8: {}", err),
|
||||
@@ -80,7 +82,15 @@ impl error::Error for Error {
|
||||
}
|
||||
|
||||
/// The lower-level cause of this error, in the case of a `Utf8` error.
|
||||
fn cause(&self) -> Option<&error::Error> {
|
||||
fn cause(&self) -> Option<&dyn error::Error> {
|
||||
match *self {
|
||||
Error::Custom(_) => None,
|
||||
Error::Utf8(ref err) => Some(err),
|
||||
}
|
||||
}
|
||||
|
||||
/// The lower-level source of this error, in the case of a `Utf8` error.
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
match *self {
|
||||
Error::Custom(_) => None,
|
||||
Error::Utf8(ref err) => Some(err),
|
||||
@@ -95,50 +105,51 @@ impl ser::Error for Error {
|
||||
}
|
||||
|
||||
/// Sequence serializer.
|
||||
pub struct SeqSerializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
||||
pub struct SeqSerializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||
}
|
||||
|
||||
/// Tuple serializer.
|
||||
///
|
||||
/// Mostly used for arrays.
|
||||
pub struct TupleSerializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
||||
pub struct TupleSerializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||
}
|
||||
|
||||
/// Tuple struct serializer.
|
||||
///
|
||||
/// Never instantiated, tuple structs are not supported.
|
||||
pub struct TupleStructSerializer<'input, 'output, T: 'output + UrlEncodedTarget> {
|
||||
pub struct TupleStructSerializer<'input, 'output, T: UrlEncodedTarget> {
|
||||
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
||||
}
|
||||
|
||||
/// Tuple variant serializer.
|
||||
///
|
||||
/// Never instantiated, tuple variants are not supported.
|
||||
pub struct TupleVariantSerializer<'input, 'output, T: 'output + UrlEncodedTarget> {
|
||||
pub struct TupleVariantSerializer<'input, 'output, T: UrlEncodedTarget> {
|
||||
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
||||
}
|
||||
|
||||
/// Map serializer.
|
||||
pub struct MapSerializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
||||
pub struct MapSerializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||
key: Option<Cow<'static, str>>,
|
||||
}
|
||||
|
||||
/// Struct serializer.
|
||||
pub struct StructSerializer<'input, 'output, Target: 'output + UrlEncodedTarget> {
|
||||
pub struct StructSerializer<'input, 'output, Target: UrlEncodedTarget> {
|
||||
urlencoder: &'output mut UrlEncodedSerializer<'input, Target>,
|
||||
}
|
||||
|
||||
/// Struct variant serializer.
|
||||
///
|
||||
/// Never instantiated, struct variants are not supported.
|
||||
pub struct StructVariantSerializer<'input, 'output, T: 'output + UrlEncodedTarget> {
|
||||
pub struct StructVariantSerializer<'input, 'output, T: UrlEncodedTarget> {
|
||||
inner: ser::Impossible<&'output mut UrlEncodedSerializer<'input, T>, Error>,
|
||||
}
|
||||
|
||||
impl<'input, 'output, Target> ser::Serializer for Serializer<'input, 'output, Target>
|
||||
impl<'input, 'output, Target> ser::Serializer
|
||||
for Serializer<'input, 'output, Target>
|
||||
where
|
||||
Target: 'output + UrlEncodedTarget,
|
||||
{
|
||||
@@ -147,10 +158,12 @@ where
|
||||
type SerializeSeq = SeqSerializer<'input, 'output, Target>;
|
||||
type SerializeTuple = TupleSerializer<'input, 'output, Target>;
|
||||
type SerializeTupleStruct = TupleStructSerializer<'input, 'output, Target>;
|
||||
type SerializeTupleVariant = TupleVariantSerializer<'input, 'output, Target>;
|
||||
type SerializeTupleVariant =
|
||||
TupleVariantSerializer<'input, 'output, Target>;
|
||||
type SerializeMap = MapSerializer<'input, 'output, Target>;
|
||||
type SerializeStruct = StructSerializer<'input, 'output, Target>;
|
||||
type SerializeStructVariant = StructVariantSerializer<'input, 'output, Target>;
|
||||
type SerializeStructVariant =
|
||||
StructVariantSerializer<'input, 'output, Target>;
|
||||
|
||||
/// Returns an error.
|
||||
fn serialize_bool(self, _v: bool) -> Result<Self::Ok, Error> {
|
||||
@@ -222,9 +235,9 @@ where
|
||||
Err(Error::top_level())
|
||||
}
|
||||
|
||||
/// Returns an error.
|
||||
/// Returns `Ok`.
|
||||
fn serialize_unit(self) -> Result<Self::Ok, Error> {
|
||||
Err(Error::top_level())
|
||||
Ok(self.urlencoder)
|
||||
}
|
||||
|
||||
/// Returns `Ok`.
|
||||
@@ -352,7 +365,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'input, 'output, Target> ser::SerializeSeq for SeqSerializer<'input, 'output, Target>
|
||||
impl<'input, 'output, Target> ser::SerializeSeq
|
||||
for SeqSerializer<'input, 'output, Target>
|
||||
where
|
||||
Target: 'output + UrlEncodedTarget,
|
||||
{
|
||||
@@ -371,7 +385,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'input, 'output, Target> ser::SerializeTuple for TupleSerializer<'input, 'output, Target>
|
||||
impl<'input, 'output, Target> ser::SerializeTuple
|
||||
for TupleSerializer<'input, 'output, Target>
|
||||
where
|
||||
Target: 'output + UrlEncodedTarget,
|
||||
{
|
||||
@@ -430,7 +445,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'input, 'output, Target> ser::SerializeMap for MapSerializer<'input, 'output, Target>
|
||||
impl<'input, 'output, Target> ser::SerializeMap
|
||||
for MapSerializer<'input, 'output, Target>
|
||||
where
|
||||
Target: 'output + UrlEncodedTarget,
|
||||
{
|
||||
@@ -470,7 +486,7 @@ where
|
||||
value: &T,
|
||||
) -> Result<(), Error> {
|
||||
{
|
||||
let key = self.key.as_ref().ok_or_else(|| Error::no_key())?;
|
||||
let key = self.key.as_ref().ok_or_else(Error::no_key)?;
|
||||
let value_sink = value::ValueSink::new(self.urlencoder, &key);
|
||||
value.serialize(part::PartSerializer::new(value_sink))?;
|
||||
}
|
||||
@@ -483,7 +499,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'input, 'output, Target> ser::SerializeStruct for StructSerializer<'input, 'output, Target>
|
||||
impl<'input, 'output, Target> ser::SerializeStruct
|
||||
for StructSerializer<'input, 'output, Target>
|
||||
where
|
||||
Target: 'output + UrlEncodedTarget,
|
||||
{
|
||||
|
||||
+18
-14
@@ -1,14 +1,14 @@
|
||||
use ser::key::KeySink;
|
||||
use ser::part::PartSerializer;
|
||||
use ser::value::ValueSink;
|
||||
use ser::Error;
|
||||
use crate::ser::key::KeySink;
|
||||
use crate::ser::part::PartSerializer;
|
||||
use crate::ser::value::ValueSink;
|
||||
use crate::ser::Error;
|
||||
use form_urlencoded::Serializer as UrlEncodedSerializer;
|
||||
use form_urlencoded::Target as UrlEncodedTarget;
|
||||
use serde::ser;
|
||||
use std::borrow::Cow;
|
||||
use std::mem;
|
||||
use url::form_urlencoded::Serializer as UrlEncodedSerializer;
|
||||
use url::form_urlencoded::Target as UrlEncodedTarget;
|
||||
|
||||
pub struct PairSerializer<'input, 'target, Target: 'target + UrlEncodedTarget> {
|
||||
pub struct PairSerializer<'input, 'target, Target: UrlEncodedTarget> {
|
||||
urlencoder: &'target mut UrlEncodedSerializer<'input, Target>,
|
||||
state: PairState,
|
||||
}
|
||||
@@ -17,15 +17,18 @@ impl<'input, 'target, Target> PairSerializer<'input, 'target, Target>
|
||||
where
|
||||
Target: 'target + UrlEncodedTarget,
|
||||
{
|
||||
pub fn new(urlencoder: &'target mut UrlEncodedSerializer<'input, Target>) -> Self {
|
||||
pub fn new(
|
||||
urlencoder: &'target mut UrlEncodedSerializer<'input, Target>,
|
||||
) -> Self {
|
||||
PairSerializer {
|
||||
urlencoder: urlencoder,
|
||||
urlencoder,
|
||||
state: PairState::WaitingForKey,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'input, 'target, Target> ser::Serializer for PairSerializer<'input, 'target, Target>
|
||||
impl<'input, 'target, Target> ser::Serializer
|
||||
for PairSerializer<'input, 'target, Target>
|
||||
where
|
||||
Target: 'target + UrlEncodedTarget,
|
||||
{
|
||||
@@ -200,7 +203,8 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<'input, 'target, Target> ser::SerializeTuple for PairSerializer<'input, 'target, Target>
|
||||
impl<'input, 'target, Target> ser::SerializeTuple
|
||||
for PairSerializer<'input, 'target, Target>
|
||||
where
|
||||
Target: 'target + UrlEncodedTarget,
|
||||
{
|
||||
@@ -219,7 +223,7 @@ where
|
||||
key: value.serialize(key_serializer)?,
|
||||
};
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
PairState::WaitingForValue { key } => {
|
||||
let result = {
|
||||
let value_sink = ValueSink::new(self.urlencoder, &key);
|
||||
@@ -229,10 +233,10 @@ where
|
||||
if result.is_ok() {
|
||||
self.state = PairState::Done;
|
||||
} else {
|
||||
self.state = PairState::WaitingForValue { key: key };
|
||||
self.state = PairState::WaitingForValue { key };
|
||||
}
|
||||
result
|
||||
},
|
||||
}
|
||||
PairState::Done => Err(Error::done()),
|
||||
}
|
||||
}
|
||||
|
||||
+17
-13
@@ -1,6 +1,4 @@
|
||||
use dtoa;
|
||||
use itoa;
|
||||
use ser::Error;
|
||||
use crate::ser::Error;
|
||||
use serde::ser;
|
||||
use std::str;
|
||||
|
||||
@@ -10,7 +8,7 @@ pub struct PartSerializer<S> {
|
||||
|
||||
impl<S: Sink> PartSerializer<S> {
|
||||
pub fn new(sink: S) -> Self {
|
||||
PartSerializer { sink: sink }
|
||||
PartSerializer { sink }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +80,14 @@ impl<S: Sink> ser::Serializer for PartSerializer<S> {
|
||||
self.serialize_integer(v)
|
||||
}
|
||||
|
||||
fn serialize_u128(self, v: u128) -> Result<S::Ok, Error> {
|
||||
self.serialize_integer(v)
|
||||
}
|
||||
|
||||
fn serialize_i128(self, v: i128) -> Result<S::Ok, Error> {
|
||||
self.serialize_integer(v)
|
||||
}
|
||||
|
||||
fn serialize_f32(self, v: f32) -> Result<S::Ok, Error> {
|
||||
self.serialize_floating(v)
|
||||
}
|
||||
@@ -110,7 +116,7 @@ impl<S: Sink> ser::Serializer for PartSerializer<S> {
|
||||
}
|
||||
|
||||
fn serialize_unit_struct(self, name: &'static str) -> Result<S::Ok, Error> {
|
||||
self.sink.serialize_static_str(name.into())
|
||||
self.sink.serialize_static_str(name)
|
||||
}
|
||||
|
||||
fn serialize_unit_variant(
|
||||
@@ -119,7 +125,7 @@ impl<S: Sink> ser::Serializer for PartSerializer<S> {
|
||||
_variant_index: u32,
|
||||
variant: &'static str,
|
||||
) -> Result<S::Ok, Error> {
|
||||
self.sink.serialize_static_str(variant.into())
|
||||
self.sink.serialize_static_str(variant)
|
||||
}
|
||||
|
||||
fn serialize_newtype_struct<T: ?Sized + ser::Serialize>(
|
||||
@@ -214,19 +220,17 @@ impl<S: Sink> PartSerializer<S> {
|
||||
where
|
||||
I: itoa::Integer,
|
||||
{
|
||||
let mut buf = [b'\0'; 20];
|
||||
let len = itoa::write(&mut buf[..], value).unwrap();
|
||||
let part = unsafe { str::from_utf8_unchecked(&buf[0..len]) };
|
||||
let mut buf = itoa::Buffer::new();
|
||||
let part = buf.format(value);
|
||||
ser::Serializer::serialize_str(self, part)
|
||||
}
|
||||
|
||||
fn serialize_floating<F>(self, value: F) -> Result<S::Ok, Error>
|
||||
where
|
||||
F: dtoa::Floating,
|
||||
F: ryu::Float,
|
||||
{
|
||||
let mut buf = [b'\0'; 24];
|
||||
let len = dtoa::write(&mut buf[..], value).unwrap();
|
||||
let part = unsafe { str::from_utf8_unchecked(&buf[0..len]) };
|
||||
let mut buf = ryu::Buffer::new();
|
||||
let part = buf.format(value);
|
||||
ser::Serializer::serialize_str(self, part)
|
||||
}
|
||||
}
|
||||
|
||||
+8
-10
@@ -1,13 +1,13 @@
|
||||
use ser::part::{PartSerializer, Sink};
|
||||
use ser::Error;
|
||||
use crate::ser::part::{PartSerializer, Sink};
|
||||
use crate::ser::Error;
|
||||
use form_urlencoded::Serializer as UrlEncodedSerializer;
|
||||
use form_urlencoded::Target as UrlEncodedTarget;
|
||||
use serde::ser::Serialize;
|
||||
use std::str;
|
||||
use url::form_urlencoded::Serializer as UrlEncodedSerializer;
|
||||
use url::form_urlencoded::Target as UrlEncodedTarget;
|
||||
|
||||
pub struct ValueSink<'input, 'key, 'target, Target>
|
||||
where
|
||||
Target: 'target + UrlEncodedTarget,
|
||||
Target: UrlEncodedTarget,
|
||||
{
|
||||
urlencoder: &'target mut UrlEncodedSerializer<'input, Target>,
|
||||
key: &'key str,
|
||||
@@ -21,14 +21,12 @@ where
|
||||
urlencoder: &'target mut UrlEncodedSerializer<'input, Target>,
|
||||
key: &'key str,
|
||||
) -> Self {
|
||||
ValueSink {
|
||||
urlencoder: urlencoder,
|
||||
key: key,
|
||||
}
|
||||
ValueSink { urlencoder, key }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'input, 'key, 'target, Target> Sink for ValueSink<'input, 'key, 'target, Target>
|
||||
impl<'input, 'key, 'target, Target> Sink
|
||||
for ValueSink<'input, 'key, 'target, Target>
|
||||
where
|
||||
Target: 'target + UrlEncodedTarget,
|
||||
{
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
extern crate serde_urlencoded;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
#[derive(Deserialize, Debug, PartialEq)]
|
||||
struct NewType<T>(T);
|
||||
@@ -83,3 +81,8 @@ fn deserialize_unit_enum() {
|
||||
Ok(result)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deserialize_unit_type() {
|
||||
assert_eq!(serde_urlencoded::from_str(""), Ok(()));
|
||||
}
|
||||
|
||||
+24
-3
@@ -1,6 +1,4 @@
|
||||
extern crate serde_urlencoded;
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
use serde_derive::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct NewType<T>(T);
|
||||
@@ -14,6 +12,24 @@ fn serialize_newtype_i32() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_newtype_u128() {
|
||||
let params = &[("field", Some(NewType(u128::MAX)))];
|
||||
assert_eq!(
|
||||
serde_urlencoded::to_string(params),
|
||||
Ok(format!("field={}", u128::MAX))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_newtype_i128() {
|
||||
let params = &[("field", Some(NewType(i128::MIN)))];
|
||||
assert_eq!(
|
||||
serde_urlencoded::to_string(params),
|
||||
Ok(format!("field={}", i128::MIN))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_option_map_int() {
|
||||
let params = &[("first", Some(23)), ("middle", None), ("last", Some(42))];
|
||||
@@ -81,3 +97,8 @@ struct Unit;
|
||||
fn serialize_unit_struct() {
|
||||
assert_eq!(serde_urlencoded::to_string(Unit), Ok("".to_owned()));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_unit_type() {
|
||||
assert_eq!(serde_urlencoded::to_string(()), Ok("".to_owned()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user