Token
如果变量的值为空,我想跳过变量的序列化。
impl<'a> Serialize for UriParam<'a> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer
{
match self {
&UriParam::Token(ref token) => {
if !token.is_empty() {
serializer.serialize_some(token)
} else {
// what should I return instead?
}
},
&UriParam::URI(ref uri) => serializer.serialize_some(uri),
&UriParam::Param(ref option) => serializer.serialize_some(option),
}
}
}