tree-type 0.4.5

Rust macros for creating type-safe filesystem tree structures
Documentation
#![cfg(all(feature = "codegen-v2", feature = "serde"))]

use tree_type::tree_type;

#[test]
fn test_transparent_root_node() {
    tree_type! {
        #[transparent]
        Root {
            #[default("test content")]
            file("test.txt")
        }
    }

    let root = Root::new("/tmp/test").unwrap();

    // Verify transparent serialization - should serialize as path string, not as object
    let json = serde_json::to_string(&root).unwrap();
    assert!(
        !json.contains("\"path\""),
        "Transparent type should not wrap path in object"
    );
    assert!(
        json.contains("/tmp/test"),
        "Should serialize as path string"
    );
}

#[test]
fn test_transparent_root_child() {
    tree_type! {
        Root {
            #[transparent]
            #[default("child content")]
            child("child.txt")
        }
    }

    let root = Root::new("/tmp/test").unwrap();
    let child = root.child();

    // Verify transparent serialization on child
    let json = serde_json::to_string(&child).unwrap();
    assert!(
        !json.contains("\"path\""),
        "Transparent child should not wrap path in object"
    );
    assert!(
        json.contains("/tmp/test/child.txt"),
        "Should serialize as path string"
    );
}