#![cfg(feature = "preserve_order")] extern crate indexmap; #[derive(serde::Deserialize, Eq, PartialEq, Debug)] struct Container { inner: T, } #[derive(serde::Deserialize, Eq, PartialEq, Debug)] struct Unsigned { unsigned: u16, } impl Default for Unsigned { fn default() -> Self { Self { unsigned: 128 } } } impl From for config::ValueKind { fn from(unsigned: Unsigned) -> Self { let mut properties = indexmap::IndexMap::new(); properties.insert( "unsigned".to_string(), config::Value::from(unsigned.unsigned), ); Self::Table(properties) } } #[test] fn test_deser_unsigned_int() { let container = Container { inner: Unsigned::default(), }; let built = config::Config::builder() .set_default("inner", Unsigned::default()) .unwrap() .build() .unwrap() .try_deserialize::>() .unwrap(); assert_eq!(container, built); }