flatten and flatten_ref methods on ActiveValue - #3146
Conversation
|
Why not just: impl<V> ActiveValue<Option<V>>
where
V: Into<Value> + Nullable,
{
...
} |
|
Naming them |
This requires specialization afaik. The |
That's definitely shorter and nicer. |
Implementing it on impl<V> ActiveValue<Option<V>>
where
V: Into<Value> + Nullable,
{
pub fn as_option(&self) -> Option<&V> {
self.try_as_ref().and_then(Option::as_ref)
}
pub fn into_option(self) -> Option<V> {
match self {
Self::Set(value) | Self::Unchanged(value) => value,
Self::NotSet => None,
}
}
} |
|
Agree with @Huliiiiii's approach — implementing on
CI is red on all three doctests. The |
Closes #3145