From 2b841b1b5d5bcea74ffc0cd99951c7f9a0955be5 Mon Sep 17 00:00:00 2001 From: Billy Chan Date: Thu, 4 Nov 2021 10:49:50 +0800 Subject: [PATCH] Refactoring --- src/entity/active_enum.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/entity/active_enum.rs b/src/entity/active_enum.rs index 104b573f..29238941 100644 --- a/src/entity/active_enum.rs +++ b/src/entity/active_enum.rs @@ -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::iter().map(|s| s.to_value()).collect() + Self::iter().map(Self::into_value).collect() } }