| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#; |
| 2 | |
| 3 | use craterust-analyzer cargo cargo_toml 0.22.3 crate/::Errorrust-analyzer cargo cargo_toml 0.22.3 error/Error#; |
| 4 | use serderust-analyzer cargo serde 1.0.229 crate/::{Deserializerust-analyzer cargo serde_core 1.0.229 de/Deserialize#, Serializerust-analyzer cargo serde_core 1.0.229 ser/Serialize#, Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#}; |
| 5 | |
| 6 | /// Placeholder for a property that may be missing from its package, and needs to be copied from a `Workspace`. |
| 7 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:, Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:)] |
| 8 | #[serde(untagged, try_from = "InheritableSerdeParser<T>")] |
| 9 | pub enum Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T> { |
| 10 | Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(T), |
| 11 | #[serderust-analyzer cargo serde_derive 1.0.229 serde:(serialize_with = "workspace_true")] |
| 12 | Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited#, |
| 13 | } |
| 14 | |
| 15 | impl<T> TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<InheritableSerdeParserrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#<T>> for Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T> { |
| 16 | type Errorrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`TryFrom<InheritableSerdeParser<T>>`]Error# = Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#; |
| 17 | |
| 18 | fn try_fromrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`TryFrom<InheritableSerdeParser<T>>`]try_from().(parsed: InheritableSerdeParserrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#<T>) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`TryFrom<InheritableSerdeParser<T>>`], Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> { |
| 19 | match parsed { |
| 20 | InheritableSerdeParserrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#Set#(v) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`TryFrom<InheritableSerdeParser<T>>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(v)), |
| 21 | InheritableSerdeParserrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#Inherited# { workspacerust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#Inherited#workspace.: true } => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`TryFrom<InheritableSerdeParser<T>>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited#), |
| 22 | InheritableSerdeParserrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#Inherited# { workspacerust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#Inherited#workspace.: false } => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#("inherited field with `workspace = false` is not allowed".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()), |
| 23 | InheritableSerdeParserrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#::ParseErrorFallbackrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#ParseErrorFallback#(s) => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Error parsing field content. Expected to deserialize {}, found {s}", stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/::type_namerust-analyzer cargo core https://github.com/rust-lang/rust/library/core any/type_name().::<T>())), |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | fn workspace_truerust-analyzer cargo cargo_toml 0.22.3 inheritable/workspace_true().<S: Serializerrust-analyzer cargo serde_core 1.0.229 ser/Serializer#>(serializer: S) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<S::Okrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Ok#, S::Errorrust-analyzer cargo serde_core 1.0.229 ser/Serializer#Error#> { |
| 29 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:)] |
| 30 | struct Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inherited# { |
| 31 | workspacerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inherited#workspace.: bool, |
| 32 | } |
| 33 | Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inherited# { workspacerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inherited#workspace.: true }.serializerust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[Inherited][Serialize]serialize().(serializer) |
| 34 | } |
| 35 | |
| 36 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Deserializerust-analyzer cargo serde_derive 1.0.229 Deserialize:)] |
| 37 | #[serde(untagged)] |
| 38 | pub enum InheritableSerdeParserrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#<T> { |
| 39 | Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#Set#(T), |
| 40 | Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#Inherited# { |
| 41 | /// Always `true` (this is for serde) |
| 42 | workspacerust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#Inherited#workspace.: bool, |
| 43 | }, |
| 44 | ParseErrorFallbackrust-analyzer cargo cargo_toml 0.22.3 inheritable/InheritableSerdeParser#ParseErrorFallback#(tomlrust-analyzer cargo toml 1.1.4+spec-1.1.0 crate/::Valuerust-analyzer cargo toml 1.1.4+spec-1.1.0 value/Value#), |
| 45 | } |
| 46 | |
| 47 | impl<T: PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#> PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq# for Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T> { |
| 48 | fn eqrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`PartialEq<Self>`]eq().(&self, other: &Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`PartialEq<Self>`]) -> bool { |
| 49 | match (self, other) { |
| 50 | (Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`PartialEq<Self>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(a), Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`PartialEq<Self>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(b)) => a.eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().(b), |
| 51 | _ => false, |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | impl<T> Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T> { |
| 57 | pub fn as_refrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]as_ref().(&self) -> Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<&T> { |
| 58 | match self { |
| 59 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(t) => Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(t), |
| 60 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited#, |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /// You can read the value |
| 65 | pub fn is_setrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]is_set().(&self) -> bool { |
| 66 | matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(_)) |
| 67 | } |
| 68 | |
| 69 | pub fn getrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]get().(&self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&T, Errorrust-analyzer cargo cargo_toml 0.22.3 error/Error#> { |
| 70 | match self { |
| 71 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(t) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t), |
| 72 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo cargo_toml 0.22.3 error/Error#::InheritedUnknownValuerust-analyzer cargo cargo_toml 0.22.3 error/Error#InheritedUnknownValue#), |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | pub fn setrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]set().(&mut self, val: T) { |
| 77 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self = Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(val); |
| 78 | } |
| 79 | |
| 80 | pub fn as_mutrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]as_mut().(&mut self) -> Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<&mut T> { |
| 81 | match self { |
| 82 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(t) => Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(t), |
| 83 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited#, |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | /// Fails if inherited |
| 88 | pub fn get_mutrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]get_mut().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<&mut T, Errorrust-analyzer cargo cargo_toml 0.22.3 error/Error#> { |
| 89 | match self { |
| 90 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(t) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(t), |
| 91 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo cargo_toml 0.22.3 error/Error#::InheritedUnknownValuerust-analyzer cargo cargo_toml 0.22.3 error/Error#InheritedUnknownValue#), |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | /// Panics if inherited |
| 96 | #[track_caller] |
| 97 | pub fn unwraprust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]unwrap().(self) -> T { |
| 98 | match self { |
| 99 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(t) => t, |
| 100 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => panicrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/panic!!("inherited workspace value"), |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /// Copy from workspace if needed |
| 105 | pub fn inheritrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]inherit().(&mut self, other: &T) where T: Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# { |
| 106 | if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(self, Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited#) { |
| 107 | *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().self = Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(other.clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone#clone().()); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | impl<T: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T> { |
| 113 | fn defaultrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][Default]default().() -> Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][Default] { |
| 114 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][Default]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(T::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().()) |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | impl<T> Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<T>> { |
| 119 | /// False if inherited and unknown |
| 120 | #[must_use] |
| 121 | pub fn is_emptyrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<Vec<T>>`]is_empty().(&self) -> bool { |
| 122 | match self { |
| 123 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<Vec<T>>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => false, |
| 124 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<Vec<T>>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(v) => v.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().(), |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | impl<K, V> Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<K, V>> { |
| 130 | /// False if inherited and unknown |
| 131 | #[must_use] |
| 132 | pub fn is_emptyrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<BTreeMap<K, V>>`]is_empty().(&self) -> bool { |
| 133 | match self { |
| 134 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<BTreeMap<K, V>>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => false, |
| 135 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<BTreeMap<K, V>>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(v) => v.is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]is_empty().(), |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | impl<T: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#> Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T> { |
| 141 | /// False if inherited and unknown |
| 142 | pub fn is_defaultrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]is_default().(&self) -> bool { |
| 143 | match self { |
| 144 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => false, |
| 145 | Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(v) => T::defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#default().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().v, |
| 146 | } |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | impl<T> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T>> for Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T> { |
| 151 | /// Inherits if `None` |
| 152 | fn fromrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`From<Option<T>>`]from().(val: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T>) -> Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`From<Option<T>>`] { |
| 153 | match val { |
| 154 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val) => Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`From<Option<T>>`]::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(val), |
| 155 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Inheritable<T>`][`From<Option<T>>`]::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited#, |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | impl<T> Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T>> for Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<T> { |
| 161 | /// `None` if inherited |
| 162 | fn fromrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Option<T>`][`From<Inheritable<T>>`]from().(val: Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<T>) -> Selfrust-analyzer cargo cargo_toml 0.22.3 inheritable/impl#[`Option<T>`][`From<Inheritable<T>>`] { |
| 163 | match val { |
| 164 | Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited# => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 165 | Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#(val) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(val), |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 171 | fn serializesrust-analyzer cargo cargo_toml 0.22.3 inheritable/serializes().() { |
| 172 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Serializerust-analyzer cargo serde_derive 1.0.229 Serialize:)] |
| 173 | struct Foorust-analyzer cargo cargo_toml 0.22.3 inheritable/Foo# { |
| 174 | barrust-analyzer cargo cargo_toml 0.22.3 inheritable/Foo#bar.: Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#<&'static str>, |
| 175 | } |
| 176 | let s = tomlrust-analyzer cargo toml 1.1.4+spec-1.1.0 crate/::to_stringrust-analyzer cargo toml 1.1.4+spec-1.1.0 ser/to_string().(&Foorust-analyzer cargo cargo_toml 0.22.3 inheritable/Foo# { |
| 177 | barrust-analyzer cargo cargo_toml 0.22.3 inheritable/Foo#bar.: Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#::Inheritedrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Inherited#, |
| 178 | }).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 179 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, "[bar]\nworkspace = true\n"); |
| 180 | |
| 181 | let s = tomlrust-analyzer cargo toml 1.1.4+spec-1.1.0 crate/::to_stringrust-analyzer cargo toml 1.1.4+spec-1.1.0 ser/to_string().(&Foorust-analyzer cargo cargo_toml 0.22.3 inheritable/Foo# { |
| 182 | barrust-analyzer cargo cargo_toml 0.22.3 inheritable/Foo#bar.: Inheritablerust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#::Setrust-analyzer cargo cargo_toml 0.22.3 inheritable/Inheritable#Set#("hello"), |
| 183 | }).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 184 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, "bar = \"hello\"\n"); |
| 185 | } |