Let's say I have an instance of this struct:
#[derive(Debug, Serialize, Deserialize)]
pub struct Payload {
#[serde(skip_serializing)]
pub k1: String,
pub k2: u32,
pub k3: u64,
#[serde(flatten)]
pub rest: Value,
}
How safe is it to call serde_json::to_string(o).unwrap()
? The documentation states that Serialization can fail if T's implementation of Serialize decides to fail, or if T contains a map with non-string keys.
It looks to me like calling unwrap is safe here but I want to be sure? Am I overlooking something?
5 posts - 4 participants