Skip to content

#[derive(Recap)] doesn't compose #10

Open
@ExpHP

Description

💡 Feature description

Currently the code generated by #[derive(Recap)] doesn't seem to be able to be composed in any manner. Ideally, I would more or less expect that fields of types with #[derive(Recap)] ought to be able to be parsed just like primitives and builtin types.

💻 Basic example

#[derive(Debug, Deserialize, Recap)]
#[recap(regex = r#"(?P<quantity>\d+) (?P<name>\w+)"#)]
struct Chemical {
    quantity: u32,
    name: String,
}

#[derive(Debug, Deserialize, Recap)]
#[recap(regex = r#"(?P<inner>\d+ \w+)"#)]
struct Wrapper {
    inner: Chemical,
}

fn main() {
    // ok
    "1 FUEL".parse::<Chemical>().unwrap();

    // Err(Custom("invalid type: string "1 FUEL", expected struct Chemical"))
    "1 FUEL".parse::<Wrapper>().unwrap();
}

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