我在查看Serde源代码时发现了missing_field
函数:
/// Report that the struct has a field that wasn't deserialized
fn missing_field<V>(&mut self, field: &'static str) -> Result<V, Self::Error>
where V: Deserialize,
{
Err(Error::missing_field(field))
}
这有什么用呢?如果Result
总是会无条件地返回Err
,为什么还要返回它呢?