serde-saphyr 0.0.28

YAML (de)serializer for Serde, emphasizing panic-free parsing, fast builds and good error reporting. Supports properties, comments, include
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#![cfg(all(feature = "serialize", feature = "deserialize"))]
#[test]
fn test_double_quoted_strings_process_escape_sequences() {
    // Double-quoted YAML scalars process backslash escapes.
    let y = "\"line1\\nline2\\t\\\\\\\"\\u0041\"\n";
    let s: String = serde_saphyr::from_str(y).expect("Failed to parse double-quoted scalar");
    assert_eq!(s, "line1\nline2\t\\\"A");
}

#[test]
fn test_single_quoted_strings_do_not_process_backslash_escapes_but_double_quotes() {
    // Single-quoted YAML scalars do NOT process backslash escapes; the only escape is doubling '' -> '.
    let y = "'line1\\nline2\\t\\\\\\\"\\u0041 and it''s fine'\n";
    let s: String = serde_saphyr::from_str(y).expect("Failed to parse single-quoted scalar");
    assert_eq!(s, "line1\\nline2\\t\\\\\\\"\\u0041 and it's fine");
}