-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feature] Table -> InlineTable #74
Comments
hey @gabbifish! This is the expected output. Inline tables are something different: https://github.com/toml-lang/toml#user-content-inline-table. site = { bucket = "", entry-point = "workers-site" } This would be an equivalent inline table in your case. Does that make sense? |
Ah, I see you're trying to convert a PRs are welcome :) |
Here is my snippet which converts fn make_inline_tbls(paths_arr: &mut ArrayOfTables) {
for x in (0..paths_arr.len()) {
let sub = paths_arr.get_mut(x).expect("");
let tgt_raw = sub.entry("target");
tgt_raw.as_inline_table_mut().map(|e| e.fmt());
let tgt_table = tgt_raw.as_table().expect("");
let mut tgt_inline = InlineTable::default();
tgt_table.iter().for_each(|i| {
let key = i.0;
let value = i.1.as_value().expect("").to_owned();
tgt_inline.get_or_insert(key, value);
});
tgt_inline.fmt();
let mut tgt_val = Value::InlineTable(tgt_inline);
let tgt_item = Item::Value(tgt_val);
*tgt_raw = tgt_item;
}
} I'm not a rustacean, so, probably, this is a piece of crap, though it works. Would really like to see a built-in API. |
The next release includes a |
This also made it trivial to optimize the conversion of Items to Values by not re-allocating the underlying containers. Fixes toml-rs#74
This also made it trivial to optimize the conversion of Items to Values by not re-allocating the underlying containers. Fixes #74
Hello! I'm trying to turn
into an inline table using toml_edit. Oddly enough, when I parse my toml, I get
Type
Table(Table...
was not I expected to see above, and I suspect it's why calling.as_inline_table()
fails on the table provided above. (instead, calling.as_inline_table()
returnsNone
).Any pieces of advice? :)
The text was updated successfully, but these errors were encountered: