Remove unused EnumIter

This commit is contained in:
Billy Chan 2021-10-25 16:56:36 +08:00
parent f20c64988d
commit 6059cdd9ad
No known key found for this signature in database
GPG Key ID: A2D690CAC7DF3CC7
2 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
use crate::{ColumnDef, DbErr, Iterable, TryGetable}; use crate::{ColumnDef, DbErr, TryGetable};
use sea_query::{Nullable, Value, ValueType}; use sea_query::{Nullable, Value, ValueType};
/// A Rust representation of enum defined in database. /// A Rust representation of enum defined in database.
@ -17,7 +17,7 @@ use sea_query::{Nullable, Value, ValueType};
/// use sea_orm::entity::prelude::*; /// use sea_orm::entity::prelude::*;
/// ///
/// // Using the derive macro /// // Using the derive macro
/// #[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] /// #[derive(Debug, PartialEq, DeriveActiveEnum)]
/// #[sea_orm(rs_type = "String", db_type = "String(Some(1))")] /// #[sea_orm(rs_type = "String", db_type = "String(Some(1))")]
/// pub enum DeriveCategory { /// pub enum DeriveCategory {
/// #[sea_orm(string_value = "B")] /// #[sea_orm(string_value = "B")]
@ -27,7 +27,7 @@ use sea_query::{Nullable, Value, ValueType};
/// } /// }
/// ///
/// // Implementing it manually /// // Implementing it manually
/// #[derive(Debug, PartialEq, EnumIter)] /// #[derive(Debug, PartialEq)]
/// pub enum Category { /// pub enum Category {
/// Big, /// Big,
/// Small, /// Small,
@ -71,7 +71,7 @@ use sea_query::{Nullable, Value, ValueType};
/// use sea_orm::entity::prelude::*; /// use sea_orm::entity::prelude::*;
/// ///
/// // Define the `Category` active enum /// // Define the `Category` active enum
/// #[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)] /// #[derive(Debug, Clone, PartialEq, DeriveActiveEnum)]
/// #[sea_orm(rs_type = "String", db_type = "String(Some(1))")] /// #[sea_orm(rs_type = "String", db_type = "String(Some(1))")]
/// pub enum Category { /// pub enum Category {
/// #[sea_orm(string_value = "B")] /// #[sea_orm(string_value = "B")]
@ -95,7 +95,7 @@ use sea_query::{Nullable, Value, ValueType};
/// ///
/// impl ActiveModelBehavior for ActiveModel {} /// impl ActiveModelBehavior for ActiveModel {}
/// ``` /// ```
pub trait ActiveEnum: Sized + Iterable { pub trait ActiveEnum: Sized {
/// Define the Rust type that each enum variant represents. /// Define the Rust type that each enum variant represents.
type Value: Into<Value> + ValueType + Nullable + TryGetable; type Value: Into<Value> + ValueType + Nullable + TryGetable;
@ -117,7 +117,7 @@ mod tests {
#[test] #[test]
fn active_enum_string() { fn active_enum_string() {
#[derive(Debug, PartialEq, EnumIter)] #[derive(Debug, PartialEq)]
pub enum Category { pub enum Category {
Big, Big,
Small, Small,
@ -150,7 +150,7 @@ mod tests {
} }
} }
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(Some(1))")] #[sea_orm(rs_type = "String", db_type = "String(Some(1))")]
pub enum DeriveCategory { pub enum DeriveCategory {
#[sea_orm(string_value = "B")] #[sea_orm(string_value = "B")]
@ -201,7 +201,7 @@ mod tests {
fn active_enum_derive_signed_integers() { fn active_enum_derive_signed_integers() {
macro_rules! test_int { macro_rules! test_int {
($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => { ($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)] #[sea_orm(rs_type = $rs_type, db_type = $db_type)]
pub enum $ident { pub enum $ident {
#[sea_orm(num_value = 1)] #[sea_orm(num_value = 1)]
@ -241,7 +241,7 @@ mod tests {
fn active_enum_derive_unsigned_integers() { fn active_enum_derive_unsigned_integers() {
macro_rules! test_uint { macro_rules! test_uint {
($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => { ($ident: ident, $rs_type: expr, $db_type: expr, $col_def: ident) => {
#[derive(Debug, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, PartialEq, DeriveActiveEnum)]
#[sea_orm(rs_type = $rs_type, db_type = $db_type)] #[sea_orm(rs_type = $rs_type, db_type = $db_type)]
pub enum $ident { pub enum $ident {
#[sea_orm(num_value = 1)] #[sea_orm(num_value = 1)]

View File

@ -15,7 +15,7 @@ pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {} impl ActiveModelBehavior for ActiveModel {}
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, DeriveActiveEnum)]
#[sea_orm(rs_type = "String", db_type = "String(Some(1))")] #[sea_orm(rs_type = "String", db_type = "String(Some(1))")]
pub enum Category { pub enum Category {
#[sea_orm(string_value = "B")] #[sea_orm(string_value = "B")]
@ -24,7 +24,7 @@ pub enum Category {
Small, Small,
} }
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, DeriveActiveEnum)]
#[sea_orm(rs_type = "i32", db_type = r#"Integer"#)] #[sea_orm(rs_type = "i32", db_type = r#"Integer"#)]
pub enum Color { pub enum Color {
#[sea_orm(num_value = 0)] #[sea_orm(num_value = 0)]
@ -33,7 +33,7 @@ pub enum Color {
White, White,
} }
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum)] #[derive(Debug, Clone, PartialEq, DeriveActiveEnum)]
#[sea_orm( #[sea_orm(
rs_type = "String", rs_type = "String",
db_type = r#"Enum("tea".to_owned(), vec!["EverydayTea".to_owned(), "BreakfastTea".to_owned()])"# db_type = r#"Enum("tea".to_owned(), vec!["EverydayTea".to_owned(), "BreakfastTea".to_owned()])"#