mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-18 20:11:02 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 930401b0dd | |||
| cb6eaea151 | |||
| b6f339ca36 | |||
| 2a5caea1a8 | |||
| b9f93f99aa | |||
| eb5cd476ba | |||
| 8478a3b7dd | |||
| dbb909136e |
@@ -52,6 +52,7 @@ jobs:
|
|||||||
toolchain: ${{matrix.rust}}
|
toolchain: ${{matrix.rust}}
|
||||||
- run: cd serde && cargo build --features rc
|
- run: cd serde && cargo build --features rc
|
||||||
- run: cd serde && cargo build --no-default-features
|
- run: cd serde && cargo build --no-default-features
|
||||||
|
- run: cd test_suite/no_std && cargo build
|
||||||
|
|
||||||
nightly:
|
nightly:
|
||||||
name: Rust nightly ${{matrix.os == 'windows' && '(windows)' || ''}}
|
name: Rust nightly ${{matrix.os == 'windows' && '(windows)' || ''}}
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.216"
|
version = "1.0.217"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
categories = ["encoding", "no-std", "no-std::no-alloc"]
|
categories = ["encoding", "no-std", "no-std::no-alloc"]
|
||||||
@@ -37,7 +37,7 @@ rustdoc-args = ["--generate-link-to-definition"]
|
|||||||
# is compatible with exactly one serde release because the generated code
|
# is compatible with exactly one serde release because the generated code
|
||||||
# involves nonpublic APIs which are not bound by semver.
|
# involves nonpublic APIs which are not bound by semver.
|
||||||
[target.'cfg(any())'.dependencies]
|
[target.'cfg(any())'.dependencies]
|
||||||
serde_derive = { version = "=1.0.216", path = "../serde_derive" }
|
serde_derive = { version = "=1.0.217", path = "../serde_derive" }
|
||||||
|
|
||||||
|
|
||||||
### FEATURES #################################################################
|
### FEATURES #################################################################
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
// Serde types in rustdoc of other crates get linked to here.
|
// Serde types in rustdoc of other crates get linked to here.
|
||||||
#![doc(html_root_url = "https://docs.rs/serde/1.0.216")]
|
#![doc(html_root_url = "https://docs.rs/serde/1.0.217")]
|
||||||
// Support using Serde without the standard library!
|
// Support using Serde without the standard library!
|
||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
// Show which crate feature enables conditionally compiled APIs in documentation.
|
// Show which crate feature enables conditionally compiled APIs in documentation.
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ enum Unsupported {
|
|||||||
Sequence,
|
Sequence,
|
||||||
Tuple,
|
Tuple,
|
||||||
TupleStruct,
|
TupleStruct,
|
||||||
|
#[cfg(not(any(feature = "std", feature = "alloc")))]
|
||||||
Enum,
|
Enum,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +71,7 @@ impl Display for Unsupported {
|
|||||||
Unsupported::Sequence => formatter.write_str("a sequence"),
|
Unsupported::Sequence => formatter.write_str("a sequence"),
|
||||||
Unsupported::Tuple => formatter.write_str("a tuple"),
|
Unsupported::Tuple => formatter.write_str("a tuple"),
|
||||||
Unsupported::TupleStruct => formatter.write_str("a tuple struct"),
|
Unsupported::TupleStruct => formatter.write_str("a tuple struct"),
|
||||||
|
#[cfg(not(any(feature = "std", feature = "alloc")))]
|
||||||
Unsupported::Enum => formatter.write_str("an enum"),
|
Unsupported::Enum => formatter.write_str("an enum"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1095,9 +1097,9 @@ where
|
|||||||
self,
|
self,
|
||||||
_: &'static str,
|
_: &'static str,
|
||||||
_: u32,
|
_: u32,
|
||||||
_: &'static str,
|
variant: &'static str,
|
||||||
) -> Result<Self::Ok, Self::Error> {
|
) -> Result<Self::Ok, Self::Error> {
|
||||||
Err(Self::bad_type(Unsupported::Enum))
|
self.0.serialize_entry(variant, &())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_newtype_struct<T>(
|
fn serialize_newtype_struct<T>(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.216"
|
version = "1.0.217"
|
||||||
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
authors = ["Erick Tryzelaar <erick.tryzelaar@gmail.com>", "David Tolnay <dtolnay@gmail.com>"]
|
||||||
categories = ["no-std", "no-std::no-alloc"]
|
categories = ["no-std", "no-std::no-alloc"]
|
||||||
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
description = "Macros 1.1 implementation of #[derive(Serialize, Deserialize)]"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
//!
|
//!
|
||||||
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
//! [https://serde.rs/derive.html]: https://serde.rs/derive.html
|
||||||
|
|
||||||
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.216")]
|
#![doc(html_root_url = "https://docs.rs/serde_derive/1.0.217")]
|
||||||
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
|
#![cfg_attr(not(check_cfg), allow(unexpected_cfgs))]
|
||||||
// Ignored clippy lints
|
// Ignored clippy lints
|
||||||
#![allow(
|
#![allow(
|
||||||
|
|||||||
@@ -10,4 +10,10 @@ libc = { version = "0.2", default-features = false }
|
|||||||
serde = { path = "../../serde", default-features = false }
|
serde = { path = "../../serde", default-features = false }
|
||||||
serde_derive = { path = "../../serde_derive" }
|
serde_derive = { path = "../../serde_derive" }
|
||||||
|
|
||||||
|
[profile.dev]
|
||||||
|
panic = "abort"
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
panic = "abort"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
|
|||||||
@@ -1,16 +1,13 @@
|
|||||||
#![allow(internal_features)]
|
|
||||||
#![feature(lang_items, start)]
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
#![no_main]
|
||||||
|
|
||||||
#[start]
|
use core::ffi::c_int;
|
||||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
|
||||||
|
#[no_mangle]
|
||||||
|
extern "C" fn main(_argc: c_int, _argv: *const *const u8) -> c_int {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
||||||
#[lang = "eh_personality"]
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn rust_eh_personality() {}
|
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|||||||
@@ -2655,11 +2655,46 @@ mod flatten {
|
|||||||
|
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||||
enum Enum {
|
enum Enum {
|
||||||
|
Unit,
|
||||||
Newtype(HashMap<String, String>),
|
Newtype(HashMap<String, String>),
|
||||||
Tuple(u32, u32),
|
Tuple(u32, u32),
|
||||||
Struct { index: u32, value: u32 },
|
Struct { index: u32, value: u32 },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unit() {
|
||||||
|
let value = Flatten {
|
||||||
|
data: Enum::Unit,
|
||||||
|
extra: HashMap::from_iter([("extra_key".into(), "extra value".into())]),
|
||||||
|
};
|
||||||
|
assert_tokens(
|
||||||
|
&value,
|
||||||
|
&[
|
||||||
|
Token::Map { len: None },
|
||||||
|
// data
|
||||||
|
Token::Str("Unit"), // variant
|
||||||
|
Token::Unit,
|
||||||
|
// extra
|
||||||
|
Token::Str("extra_key"),
|
||||||
|
Token::Str("extra value"),
|
||||||
|
Token::MapEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
assert_de_tokens(
|
||||||
|
&value,
|
||||||
|
&[
|
||||||
|
Token::Map { len: None },
|
||||||
|
// extra
|
||||||
|
Token::Str("extra_key"),
|
||||||
|
Token::Str("extra value"),
|
||||||
|
// data
|
||||||
|
Token::Str("Unit"), // variant
|
||||||
|
Token::Unit,
|
||||||
|
Token::MapEnd,
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn newtype() {
|
fn newtype() {
|
||||||
assert_tokens(
|
assert_tokens(
|
||||||
|
|||||||
@@ -769,7 +769,7 @@ fn test_gen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
struct Packed {
|
struct Packed {
|
||||||
x: u8,
|
x: u8,
|
||||||
@@ -915,14 +915,14 @@ where
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
pub struct RemotePacked {
|
pub struct RemotePacked {
|
||||||
pub a: u16,
|
pub a: u16,
|
||||||
pub b: u32,
|
pub b: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[serde(remote = "RemotePacked")]
|
#[serde(remote = "RemotePacked")]
|
||||||
pub struct RemotePackedDef {
|
pub struct RemotePackedDef {
|
||||||
a: u16,
|
a: u16,
|
||||||
@@ -933,14 +933,14 @@ impl Drop for RemotePackedDef {
|
|||||||
fn drop(&mut self) {}
|
fn drop(&mut self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
pub struct RemotePackedNonCopy {
|
pub struct RemotePackedNonCopy {
|
||||||
pub a: u16,
|
pub a: u16,
|
||||||
pub b: String,
|
pub b: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[repr(packed)]
|
#[repr(C, packed)]
|
||||||
#[serde(remote = "RemotePackedNonCopy")]
|
#[serde(remote = "RemotePackedNonCopy")]
|
||||||
pub struct RemotePackedNonCopyDef {
|
pub struct RemotePackedNonCopyDef {
|
||||||
a: u16,
|
a: u16,
|
||||||
|
|||||||
Reference in New Issue
Block a user