ruwuma/ruma-serde/src/can_be_empty.rs
Jonas Platte bfe4e9fa27
Add ruma_serde::is_empty
This will be used for serde attributes that are copied to incoming types
and thus actually have to function for multiple types.
2020-08-28 22:53:40 +02:00

10 lines
204 B
Rust

pub trait CanBeEmpty {
/// Check whether `self` is empty.
fn is_empty(&self) -> bool;
}
/// Check whether a value is empty.
pub fn is_empty<T: CanBeEmpty>(val: &T) -> bool {
val.is_empty()
}