The Problem
Trying to output the data structure in TOML format (with -T option) produces an error on macOS High Sierra:
$ rq -tT 'id' < ./test.toml
[ERROR] [rq] Encountered: values must be emitted before tables
[ERROR] [rq] (Re-run with --trace or RUST_BACKTRACE=1 for a backtrace)
Investigations
Doing a web search with that error message led me to this source file of the toml crate project, that is responsible for serialising the data structure to a TOML file, that states:
Note that the TOML format has a restriction that if a table itself contains
tables, all keys with non-table values must be emitted first. This is
typically easy to ensure happens when you're defining a `struct` as you can
reorder the fields manually, but when working with maps (such as `BTreeMap`
or `HashMap`) this can lead to serialization errors. In those situations you
may use the `tables_last` function in this module [...]
And indeed, the error occurred only when there were tables to be serialised.
Solution
As stated in the serialisation source file, a solution is to make use of the tables_last function. I am currently figuring out, how I need to adapt the rq/src/value/toml.rs source file to do exactly that.
Any help is appreciated, especially as I have started learning Rust only a few days ago.
The Problem
Trying to output the data structure in TOML format (with
-Toption) produces an error on macOS High Sierra:Investigations
Doing a web search with that error message led me to this source file of the
tomlcrate project, that is responsible for serialising the data structure to a TOML file, that states:And indeed, the error occurred only when there were tables to be serialised.
Solution
As stated in the serialisation source file, a solution is to make use of the
tables_lastfunction. I am currently figuring out, how I need to adapt therq/src/value/toml.rssource file to do exactly that.Any help is appreciated, especially as I have started learning Rust only a few days ago.