Is it possible to define structures at runtime or otherwise achieve a similar effect?

I want to create a function (for a library) that will output a structure for any CSV that contains all the columns and their data. This means that column names (unless explicitly specified by the user) will not be known until runtime.

Can I create a structure definition at run time or modify an existing structure? If so, how?

For example, how can I mutate the following structure structure:

struct Point {
    x: String,
    y: String,
}

To the following (only in memory):

struct Point {
    x: String,
    y: String,
    z: String,
}

This behavior is possible in languages ​​like Python, but I'm not sure if this is possible in compiled languages ​​like Rust.

+4
source share
1 answer

No, It is Immpossible.

, (, , ..) , . , , , X foo.

Rust. , Rust, , ( Rust 300 + ).

, . Python Python, .

, Rust . , , . - , / , , .


, , HashMap.

+7

Source: https://habr.com/ru/post/1688879/


All Articles