@@ -410,11 +410,7 @@ impl<'de> de::Deserialize<'de> for InheritableBtreeMap {
410
410
if let Ok ( w) = TomlInheritedField :: deserialize (
411
411
serde_value:: ValueDeserializer :: < D :: Error > :: new ( value. clone ( ) ) ,
412
412
) {
413
- return if w. workspace {
414
- Ok ( InheritableField :: Inherit ( w) )
415
- } else {
416
- Err ( de:: Error :: custom ( "`workspace` cannot be false" ) )
417
- } ;
413
+ return Ok ( InheritableField :: Inherit ( w) ) ;
418
414
}
419
415
BTreeMap :: deserialize ( serde_value:: ValueDeserializer :: < D :: Error > :: new ( value) )
420
416
. map ( InheritableField :: Value )
@@ -424,13 +420,14 @@ impl<'de> de::Deserialize<'de> for InheritableBtreeMap {
424
420
#[ derive( Deserialize , Serialize , Copy , Clone , Debug ) ]
425
421
#[ serde( rename_all = "kebab-case" ) ]
426
422
pub struct TomlInheritedField {
427
- #[ serde( deserialize_with = "bool_no_false" ) ]
428
- workspace : bool ,
423
+ workspace : WorkspaceValue ,
429
424
}
430
425
431
426
impl TomlInheritedField {
432
427
pub fn new ( ) -> Self {
433
- TomlInheritedField { workspace : true }
428
+ TomlInheritedField {
429
+ workspace : WorkspaceValue ,
430
+ }
434
431
}
435
432
}
436
433
@@ -449,6 +446,28 @@ fn bool_no_false<'de, D: de::Deserializer<'de>>(deserializer: D) -> Result<bool,
449
446
}
450
447
}
451
448
449
+ #[ derive( Deserialize , Serialize , Copy , Clone , Debug ) ]
450
+ #[ serde( try_from = "bool" ) ]
451
+ #[ serde( into = "bool" ) ]
452
+ struct WorkspaceValue ;
453
+
454
+ impl TryFrom < bool > for WorkspaceValue {
455
+ type Error = String ;
456
+ fn try_from ( other : bool ) -> Result < WorkspaceValue , Self :: Error > {
457
+ if other {
458
+ Ok ( WorkspaceValue )
459
+ } else {
460
+ Err ( "`workspace` cannot be false" . to_owned ( ) )
461
+ }
462
+ }
463
+ }
464
+
465
+ impl From < WorkspaceValue > for bool {
466
+ fn from ( _: WorkspaceValue ) -> bool {
467
+ true
468
+ }
469
+ }
470
+
452
471
#[ derive( Serialize , Clone , Debug ) ]
453
472
#[ serde( untagged) ]
454
473
pub enum InheritableDependency {
0 commit comments