mirror of
https://github.com/serde-rs/serde.git
synced 2025-09-29 22:11:09 +00:00

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
21 lines
351 B
Rust
21 lines
351 B
Rust
#![deny(deprecated)]
|
|
|
|
use serde::Deserializer;
|
|
use serde_derive::Deserialize;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Struct {
|
|
#[serde(deserialize_with = "deprecated_with")]
|
|
pub field: i32,
|
|
}
|
|
|
|
#[deprecated]
|
|
fn deprecated_with<'de, D>(_deserializer: D) -> Result<i32, D::Error>
|
|
where
|
|
D: Deserializer<'de>,
|
|
{
|
|
unimplemented!()
|
|
}
|
|
|
|
fn main() {}
|