can-dbc icon indicating copy to clipboard operation
can-dbc copied to clipboard

Deduplicate Value Names

Open JoNil opened this issue 10 months ago • 1 comments

Hi!

I have a dbc with this line in it:

VAL_ 123456 Name 14 "Error" 0 "Normal" 1 "Low" 2 "Too low" 3 "High" 4 "Reserved" 5 "Reserved" 6 "Reserved" 15 "Not Available" ;

That generated this code with dbc-codegen:

#[derive(Clone, Copy, PartialEq)]
#[derive(Debug)]
pub enum Name {
    Error,
    Normal,
    Low,
    TooLow,
    High,
    Reserved,
    Reserved,
    Reserved,
    NotAvailable,
    _Other(u8),
}

Which is not valid rust. With this pr the generated code instead becomes:

#[derive(Clone, Copy, PartialEq)]
#[derive(Debug)]
pub enum Name {
    Error,
    Normal,
    Low,
    TooLow,
    High,
    Reserved,
    Reserved2,
    Reserved3,
    NotAvailable,
    _Other(u8),
}

JoNil avatar Apr 25 '24 09:04 JoNil