Refactoring

This commit is contained in:
Billy Chan 2021-11-04 10:49:50 +08:00
parent bb78a1d709
commit 2b841b1b5d
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7

View File

@ -120,9 +120,14 @@ pub trait ActiveEnum: Sized + Iterable {
/// Get the database column definition of this active enum.
fn db_type() -> ColumnDef;
/// Convert an owned enum variant into the corresponding value.
fn into_value(self) -> Self::Value {
Self::to_value(&self)
}
/// Get the name of all enum variants
fn values() -> Vec<Self::Value> {
Self::iter().map(|s| s.to_value()).collect()
Self::iter().map(Self::into_value).collect()
}
}