remove attributes with the None value
This commit is contained in:
1 parent
cb2d672105
commit
ea43b864db
3 files changed
+34
-26
No files matched your search
@@ -80,7 +80,6 @@ pub enum OwnedAttributeValue<V: FromAnyValue = ()> {
|
||||
Int(i64),
|
||||
Bool(bool),
|
||||
Custom(V),
|
||||
None,
|
||||
}
|
||||
|
||||
pub trait FromAnyValue {
|
||||
@@ -99,7 +98,6 @@ impl<V: FromAnyValue> Debug for OwnedAttributeValue<V> {
|
||||
Self::Int(arg0) => f.debug_tuple("Int").field(arg0).finish(),
|
||||
Self::Bool(arg0) => f.debug_tuple("Bool").field(arg0).finish(),
|
||||
Self::Custom(_) => f.debug_tuple("Any").finish(),
|
||||
Self::None => write!(f, "None"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +110,7 @@ impl<V: FromAnyValue> From<BorrowedAttributeValue<'_>> for OwnedAttributeValue<V
|
||||
BorrowedAttributeValue::Int(int) => Self::Int(int),
|
||||
BorrowedAttributeValue::Bool(bool) => Self::Bool(bool),
|
||||
BorrowedAttributeValue::Any(any) => Self::Custom(V::from_any_value(&*any)),
|
||||
BorrowedAttributeValue::None => Self::None,
|
||||
BorrowedAttributeValue::None => panic!("None attribute values result in removing the attribute, not converting it to a None value.")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,13 +144,6 @@ impl<V: FromAnyValue> OwnedAttributeValue<V> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_none(&self) -> Option<()> {
|
||||
match self {
|
||||
OwnedAttributeValue::None => Some(()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_custom(&self) -> Option<&V> {
|
||||
match self {
|
||||
OwnedAttributeValue::Custom(custom) => Some(custom),
|
||||
|
||||
Reference in new issue
Block a user