1use serde::de::{self, Deserialize, Deserializer, Visitor};
2use serde_derive::Deserialize;
3use std::fmt;
4
5#[derive(Deserialize)]
6#[serde(deny_unknown_fields)]
7pub struct InheritEdition {
8 pub workspace: True,
9}
10
11pub struct True;
12
13impl<'de> Deserialize<'de> for True {
14 fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
15 where
16 D: Deserializer<'de>,
17 {
18 deserializer.deserialize_bool(True)
19 }
20}
21
22impl<'de> Visitor<'de> for True {
23 type Value = True;
24
25 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
26 formatter.write_str("bool")
27 }
28
29 fn visit_bool<E>(self, b: bool) -> Result<Self::Value, E>
30 where
31 E: de::Error,
32 {
33 if b {
34 Ok(True)
35 } else {
36 Err(de::Error::custom(
37 "workspace=false is unsupported for package.edition",
38 ))
39 }
40 }
41}
42