Skip to content
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

Multi-line k/v pairs #707

Closed
rakanalh opened this issue Mar 24, 2024 · 1 comment
Closed

Multi-line k/v pairs #707

rakanalh opened this issue Mar 24, 2024 · 1 comment

Comments

@rakanalh
Copy link

Hello,

If i have:

[keys]
key1 = {
    use = true,
    value = "123"
}

And the following code:

use std::fs;
use std::process::exit;
use toml::{self, Value};

fn main() {
    let filename = "config.toml";
    let contents = match fs::read_to_string(filename) {
        Ok(c) => c,
        Err(_) => {
            eprintln!("Could not read file `{}`", filename);
            exit(1);
        }
    };

    let data: Value = match toml::from_str(&contents) {
        Ok(d) => d,
        Err(e) => {
            eprintln!("Unable to load data from `{}` {}", filename, e);
            exit(1);
        }
    };

    println!("{:?}", data);
}

Running this would result in:

Unable to load data from `config.toml` TOML parse error at line 14, column 9
   |
14 | key1 = {
   |         ^
invalid inline table
expected `}`

Which is unexpected since i believe the key/value pairs should be possible to span multiple lines.

Apparently, support for this was already merged in the TOML spec: toml-lang/toml#516 in this PR: toml-lang/toml#904

@epage
Copy link
Member

epage commented Mar 25, 2024

The spec is unreleased, see #397. Closing rn favor of that issue

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants