Given code like this (not complete):
extern crate serde_json;
let g1 = vec![0; 16];
let json1 = serde_json::to_pretty_string(&g1).unwrap();
let foo: Foo = serde_json::from_str(&json1).unwrap();
The first error is correct but the second is nonsense:
error[E0425]: cannot find function `to_pretty_string` in module `serde_json`
--> serialization-tests/tests/serialization.rs:498:35
|
498 | let json1 = serde_json::to_pretty_string(&g1).unwrap();
| ^^^^^^^^^^^^^^^^ not found in `serde_json`
error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied
--> serialization-tests/tests/serialization.rs:498:13
|
498 | let json1 = serde_json::to_pretty_string(&g1).unwrap();
| ^^^^^ `str` does not have a constant size known at compile-time
|
= help: the trait `std::marker::Sized` is not implemented for `str`
= note: all local variables must have a statically known size
There's an extra error here. json1 is used in a way (with the from_str function) that it should be a str or something that derefs to str. The second error message supposes it is a str, which is nonsense that the user doesn't intend at all. (If the user would only find the right name of the function, they would get a String in the json variable and the next line compiles fine.)
Given code like this (not complete):
The first error is correct but the second is nonsense:
There's an extra error here.
json1is used in a way (with thefrom_strfunction) that it should be astror something that derefs tostr. The second error message supposes it is astr, which is nonsense that the user doesn't intend at all. (If the user would only find the right name of the function, they would get a String in the json variable and the next line compiles fine.)