Skip to content

Commit 8053774

Browse files
committed
Fix Config.set working with the rust table
1 parent fe76ee6 commit 8053774

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

crates/mdbook-core/src/config.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ impl Config {
230230
self.book.update_value(key, value);
231231
} else if let Some(key) = index.strip_prefix("build.") {
232232
self.build.update_value(key, value);
233+
} else if let Some(key) = index.strip_prefix("rust.") {
234+
self.rust.update_value(key, value);
233235
} else {
234236
self.rest.insert(index, value);
235237
}
@@ -1111,6 +1113,22 @@ mod tests {
11111113
assert_eq!(got, value);
11121114
}
11131115

1116+
#[test]
1117+
fn set_special_tables() {
1118+
let mut cfg = Config::default();
1119+
assert_eq!(cfg.book.title, None);
1120+
cfg.set("book.title", "my title").unwrap();
1121+
assert_eq!(cfg.book.title, Some("my title".to_string()));
1122+
1123+
assert_eq!(&cfg.build.build_dir, Path::new("book"));
1124+
cfg.set("build.build-dir", "some-directory").unwrap();
1125+
assert_eq!(&cfg.build.build_dir, Path::new("some-directory"));
1126+
1127+
assert_eq!(cfg.rust.edition, None);
1128+
cfg.set("rust.edition", "2024").unwrap();
1129+
assert_eq!(cfg.rust.edition, Some(RustEdition::E2024));
1130+
}
1131+
11141132
#[test]
11151133
fn parse_env_vars() {
11161134
let inputs = vec![

0 commit comments

Comments
 (0)