From 8053774ba38827352d0bbc2e343b66496472d91d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Fri, 25 Jul 2025 11:24:15 -0700 Subject: [PATCH] Fix `Config.set` working with the `rust` table --- crates/mdbook-core/src/config.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/crates/mdbook-core/src/config.rs b/crates/mdbook-core/src/config.rs index 9ab564c2..36e586a6 100644 --- a/crates/mdbook-core/src/config.rs +++ b/crates/mdbook-core/src/config.rs @@ -230,6 +230,8 @@ impl Config { self.book.update_value(key, value); } else if let Some(key) = index.strip_prefix("build.") { self.build.update_value(key, value); + } else if let Some(key) = index.strip_prefix("rust.") { + self.rust.update_value(key, value); } else { self.rest.insert(index, value); } @@ -1111,6 +1113,22 @@ mod tests { assert_eq!(got, value); } + #[test] + fn set_special_tables() { + let mut cfg = Config::default(); + assert_eq!(cfg.book.title, None); + cfg.set("book.title", "my title").unwrap(); + assert_eq!(cfg.book.title, Some("my title".to_string())); + + assert_eq!(&cfg.build.build_dir, Path::new("book")); + cfg.set("build.build-dir", "some-directory").unwrap(); + assert_eq!(&cfg.build.build_dir, Path::new("some-directory")); + + assert_eq!(cfg.rust.edition, None); + cfg.set("rust.edition", "2024").unwrap(); + assert_eq!(cfg.rust.edition, Some(RustEdition::E2024)); + } + #[test] fn parse_env_vars() { let inputs = vec![