Skip to content

Extracting struct name from Value? #264

@jgarvin

Description

@jgarvin

Looking at the docs for Value:

pub enum Value {
    Bool(bool),
    Char(char),
    Map(Map),
    Number(Number),
    Option(Option<Box<Value>>),
    String(String),
    Seq(Vec<Value>),
    Unit,
}

I don't see how to get the name of a struct out, e.g. if I were to call from_str on the contents of example.ron, how would I get the string "Nested" out of it? My use case is the following: I want to have a field that could be one of many different structs. I'd like to parse into a ron Value, check the parsed struct name, then based on that name choose which actual T to pass to into_rust. I couldn't find this in the examples/docs.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions