enum_coder 0.0.1

Enum coder macro. A syntancic sugar for generating lists of instructions, intermediate representations for compilers etc.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 27.89 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 298 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s Average build duration of successful builds.
  • all releases: 6s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • pczarn/enum_coder
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • pczarn

enum_coder

Enum coder macro. A syntancic sugar for generating lists of instructions, intermediate representations for compilers etc.

Input for the macro consists of one enum definition, followed by function definitions.

Attributes generate_list makes a generator of enum values. The function signature is fn f() -> Vec<T>.

Attribute missing_field marks the computation of default values for fields. Alternatively, the attribute can be written as missing_field(args, ...). Then, function signature is fn f(args, field_name: &str).

See examples for more.

enum_coder! {
    enum Instruction {
        Push(String),
        Concat(usize),
        ConcatSeparated(usize, String),
        Dup,
        Test,
        ConcatRef {
            ref_a: usize,
            ref_b: usize,
        },
    }

    #[generate_list]
    fn make_instructions() -> Vec<Instruction> {
        Push("hello".to_string());
        Push("world!".to_string());
        // ConcatSeparated(2, ", ".to_string());
        // or
        ConcatRef {
            ref_a: 0,
            ref_b: 1,
        };
        for _ in 0..10 {
            Dup()
        }
        Test();
        Concat(10 + 1)
    }
}

Documentation is available here: https://docs.rs/enum_coder/latest/enum_coder/