// [dependencies]
// serde_json = "1.0.41"
fn main() {
let v = "hello";
let s = serde_json::to_string(&v).unwrap();
println!("{}", s);
let v2: std::borrow::Cow<str> = serde_json::from_str(&s).unwrap();
match v2 {
std::borrow::Cow::Borrowed(..) => println!("borrowed"),
std::borrow::Cow::Owned(..) => println!("owned"),
}
}
Expected result
Because string hello appears in the data as is, with no escaping or reader buffer boundaries.
Actual result
Expected result
Because string
helloappears in the data as is, with no escaping or reader buffer boundaries.Actual result