Skip to content

nibrobb/to-sql-enum-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ToSqlEnum

ToSqlEnum is a generic trait used to serialize your enums for use in SQL table definitions

Example

You must use the trait first, then it can be used on any compliant enum

The following code will serialize MyEnum into

ENUM('foo','bar')
use strum_macros::{Display, EnumIter};
use to_sql_enum::ToSqlEnum;

#[derive(Copy, Clone, EnumIter, Display)]
enum MyEnum {
    #[strum(serialize = "foo")]
    Foo,
    #[strum(serialize = "bar")]
    Bar,
}

fn main() {
    println!("{}", MyEnum::to_sql_enum())
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages