Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deserilazing Cow<'_, serde_json::value::RawValue> always allocates #1076

Open
monoid opened this issue Oct 9, 2023 · 0 comments
Open

Deserilazing Cow<'_, serde_json::value::RawValue> always allocates #1076

monoid opened this issue Oct 9, 2023 · 0 comments

Comments

@monoid
Copy link

monoid commented Oct 9, 2023

It seems the following test should work, but it fails:

#[test]
fn test_cow_raw_value() {
    #[derive(Debug, Serialize, Deserialize)]
    struct V<'a> {
        #[serde(borrow)]
        key: Cow<'a, serde_json::value::RawValue>,
    }

    let a = r#"{"key":[1,2,3]}"#;
    let b: V<'_> = serde_json::from_str(a).expect("valid JSON");

    assert!(matches!(b.key, Cow::Borrowed(_)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant