mirror of
https://github.com/bytedream/serde-inline-default.git
synced 2025-12-16 08:40:44 +01:00
Copy conditional compilation flags onto created constructors (#13)
(Closes #12)
This commit is contained in:
@@ -43,3 +43,26 @@ fn test_lifetime() {
|
||||
|
||||
assert_eq!(lifetime_test.test_str, "test");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(dead_code)]
|
||||
fn test_conditional_compilation() {
|
||||
#[cfg(debug_assertions)]
|
||||
#[derive(Deserialize)]
|
||||
struct TypeA(u8);
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[derive(Deserialize)]
|
||||
struct TypeB(u8);
|
||||
|
||||
#[serde_inline_default]
|
||||
#[derive(Deserialize)]
|
||||
struct Test {
|
||||
#[cfg(debug_assertions)]
|
||||
#[serde_inline_default(TypeA(1))]
|
||||
val_a: TypeA,
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[serde_inline_default(TypeB(1))]
|
||||
val_b: TypeB,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user