mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 19:28:01 +00:00
add #[allow(deprecated)] to derive implementations
Allow deprecated in the `Serialize`/`Deserialize` derive implementations. This allows you to deprecate structs, enums, struct fields, or enum variants and not get compiler warnings/errors about use of deprecated thing. We only do this if `#[deprecated]` or `#[allow(deprecated)]` exist on the root object or the variants of the root object (if it is an enum). Resolves #2195
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
#![deny(deprecated)]
|
||||
|
||||
use serde::Serializer;
|
||||
use serde_derive::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct Struct {
|
||||
#[serde(serialize_with = "deprecated_with")]
|
||||
pub field: i32,
|
||||
}
|
||||
|
||||
#[deprecated]
|
||||
fn deprecated_with<S>(_field: &i32, _serializer: S) -> Result<S::Ok, S::Error>
|
||||
where
|
||||
S: Serializer,
|
||||
{
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Reference in New Issue
Block a user