Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/ron/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  240_array_pretty.rs   Sprache: unbekannt

 
use ron::ser::{to_string_pretty, PrettyConfig};

#[test]
fn small_array() {
    let arr = &[(), (), ()][..];
    assert_eq!(
        to_string_pretty(&arr, PrettyConfig::new().new_line("\n".to_string())).unwrap(),
        "[
    (),
    (),
    (),
]"
    );
    assert_eq!(
        to_string_pretty(
            &arr,
            PrettyConfig::new()
                .new_line("\n".to_string())
                .compact_arrays(true)
        )
        .unwrap(),
        "[(), (), ()]"
    );
    assert_eq!(
        to_string_pretty(
            &arr,
            PrettyConfig::new()
                .new_line("\n".to_string())
                .compact_arrays(true)
                .separator("".to_string())
        )
        .unwrap(),
        "[(),(),()]"
    );
    assert_eq!(
        to_string_pretty(
            &vec![(1, 2), (3, 4)],
            PrettyConfig::new()
                .new_line("\n".to_string())
                .separate_tuple_members(true)
                .compact_arrays(true)
        )
        .unwrap(),
        "[(
    1,
    2,
), (
    3,
    4,
)]"
    );
}

[ Dauer der Verarbeitung: 0.2 Sekunden  (vorverarbeitet)  ]