Skip to content

Parser cannot handle enum variants whose name contains spaces, within larger structs #9

@coriolinus

Description

@coriolinus
#[derive(parse_display::FromStr)]
enum Instruction {
    #[display("turn off")]
    TurnOff,
    #[display("toggle")]
    Toggle,
}

//succeeds
#[test]
fn parses_toggle() {
    "toggle".parse::<Instruction>().unwrap();
}

//succeeds
#[test]
fn parses_turn_off() {
    "turn off".parse::<Instruction>().unwrap();
}

#[derive(parse_display::FromStr)]
#[display("{instruction} {value}")]
struct ContainsInstruction {
    instruction: Instruction,
    value: u64,
}

//succeeds
#[test]
fn parses_contains_toggle() {
    "toggle 123".parse::<ContainsInstruction>().unwrap();
}

//fails
#[test]
fn parses_contains_turn_on() {
    "turn off 123".parse::<ContainsInstruction>().unwrap();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions