Skip to content

Commit b589d2a

Browse files
authored
feat: support toml 1.1 (#213)
Upgrade the `toml` crate to v1 which adds support for TOML 1.1. This now allows for newlines to be added to inline tables. Fixes: #212 Signed-off-by: JP-Ellis <josh@jpellis.me>
1 parent 1077fe7 commit b589d2a

3 files changed

Lines changed: 55 additions & 22 deletions

File tree

Cargo.lock

Lines changed: 27 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ serde = { version = "1.*", features = ["derive"] }
2626
shellexpand = "2.*"
2727
simplelog = "0.12.*"
2828
tokio = "1.*"
29-
toml = "0.9.6"
29+
toml = "1"
3030
watchexec = { version = "8", optional = true }
3131
watchexec-events = { version = "6.0.0", optional = true }
3232
watchexec-filterer-globset = { version = "8", optional = true }

src/config.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,33 @@ mod test {
771771
);
772772
}
773773

774+
#[test]
775+
fn inline_table_with_newlines() {
776+
// TOML 1.1 allows inline tables to span multiple lines (trailing commas
777+
// also permitted). This requires toml crate >= 0.10 which enables TOML
778+
// 1.1 parsing by default.
779+
let local: LocalConfig = toml::from_str(
780+
r#"
781+
packages = ['mypackage']
782+
783+
[variables]
784+
myvar = {
785+
key = "value",
786+
}
787+
"#,
788+
)
789+
.unwrap();
790+
791+
assert_eq!(
792+
local.variables.get("myvar"),
793+
Some(&toml::Value::Table(
794+
[("key".to_string(), toml::Value::String("value".to_string()))]
795+
.into_iter()
796+
.collect()
797+
))
798+
);
799+
}
800+
774801
#[test]
775802
fn setting_default_target_type_automatic() {
776803
let global: GlobalConfig = toml::from_str(

0 commit comments

Comments
 (0)