display_enum

Crates.iodisplay_enum
lib.rsdisplay_enum
version0.1.5
sourcesrc
created_at2024-10-26 10:27:13.370756
updated_at2024-11-16 16:12:33.145515
descriptionImplement Display For the Enumeration
homepagehttps://github.com/ptechen
repositoryhttps://github.com/ptechen/display_enum.git
max_upload_size
id1423731
size8,953
Petechen (ptechen)

documentation

https://docs.rs/display_enum

README

enum_display_derive

Version info Downloads docs dependency status

example:

use display_enum::Display;

#[derive(Display)]
#[to_vec]
//#[ignore_field]
enum Test{
    A(i32),
    #[ignore_field]
    B(Data, i32),
    C(Data, i32),
    TestA,
    #[ignore_field]
    Data{name: Data, test: i64},
    Data1{name: Data, test: i64},
}

#[derive(Debug)]
struct Data {
    test: i32
}
#[test]
fn test() {
    assert_eq!("B", Test::B(Data{test: 5}, 6).to_string());
    assert_eq!("C:(Data { test: 5 }, 6)", Test::C(Data{test: 5}, 6).to_string());
    assert_eq!("Data", Test::Data {name: Data{ test: 0 }, test: 42}.to_string());
    assert_eq!("Data1:(Data { test: 0 }, 42)", Test::Data1 {name: Data{ test: 0 }, test: 42}.to_string());
}
Commit count: 11

cargo fmt