deepmerge 0.1.0

Deep merge functionality with policy-driven merging and derive macro support
Documentation
/// Basic usage example demonstrating core deepmerge functionality.
/// 
/// This example shows how to use the DeepMerge derive macro with custom policies
/// to control merge behavior for different types.

use deepmerge::prelude::*;

fn main() {
    println!("=== Basic Usage Example ===\n");
    
    demo_basic_usage();
}

/// Demonstrates core deepmerge functionality:
/// - Using the DeepMerge derive macro for automatic trait implementation  
/// - Creating custom policies with ComposedPolicy
/// - Configuring different merge behaviors for strings, sequences, and booleans
fn demo_basic_usage() {
    // Use clean identifier syntax instead of string literals
    #[derive(DeepMerge, Debug)]
    struct Config {
        pub title: String,
        pub tags: Vec<String>,
        pub enabled: bool,
        pub version: String,
    }

    let mut config = Config {
        title: "My App".to_string(),
        tags: vec!["web".to_string()],
        enabled: false,
        version: "1.0".to_string(),
    };

    let update = Config {
        title: " v2".to_string(),
        tags: vec!["api".to_string()],
        enabled: true,
        version: "2.0".to_string(),
    };

    println!("Before merge:");
    println!("  title: {:?}", config.title);
    println!("  tags: {:?}", config.tags);
    println!("  enabled: {}", config.enabled);
    println!("  version: {:?}", config.version);
    
    println!("\nUpdate values:");
    println!("  title: {:?}", update.title);
    println!("  tags: {:?}", update.tags);
    println!("  enabled: {}", update.enabled);
    println!("  version: {:?}", update.version);

    // Create a custom policy for merge behavior
    let policy = ComposedPolicy::new(DefaultPolicy)
        .with_string_merge(StringMerge::Concat)
        .with_sequence_merge(SequenceMerge::Append)
        .with_bool_merge(BoolMerge::TrueWins);
        
    config.merge_with_policy(update, &policy);

    println!("\nAfter merge:");
    println!("  title: {:?} (concatenated using custom policy)", config.title);
    println!("  tags: {:?} (appended using custom policy)", config.tags);
    println!("  enabled: {} (true wins using custom policy)", config.enabled);
    println!("  version: {:?} (concatenated using custom policy)", config.version);
    
    // Verify the expected results with the custom policy
    assert_eq!(config.title, "My App v2");
    assert_eq!(config.tags, vec!["web", "api"]); 
    assert_eq!(config.enabled, true);
    assert_eq!(config.version, "1.02.0"); // Also concatenated since all strings use the same policy
    
    println!("\n✓ All assertions passed! Example matches README documentation.");
}