2 releases

0.1.5 Nov 16, 2024
0.1.4 Oct 27, 2024

#2205 in Procedural macros

Download history 267/week @ 2024-10-25 27/week @ 2024-11-01 1/week @ 2024-11-08 115/week @ 2024-11-15 14/week @ 2024-11-22 4/week @ 2024-11-29 14/week @ 2024-12-06

147 downloads per month
Used in enum_inject

MIT/Apache

7KB
100 lines

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());
}

Dependencies

~235–680KB
~16K SLoC