File tree Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Expand file tree Collapse file tree 2 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -346,21 +346,17 @@ impl<'de> Deserialize<'de> for Config {
346
346
347
347
impl Serialize for Config {
348
348
fn serialize < S : Serializer > ( & self , s : S ) -> std:: result:: Result < S :: Ok , S :: Error > {
349
- use serde:: ser:: Error ;
350
349
// TODO: This should probably be removed and use a derive instead.
351
-
352
350
let mut table = self . rest . clone ( ) ;
353
351
354
- let book_config = match Value :: try_from ( self . book . clone ( ) ) {
355
- Ok ( cfg) => cfg,
356
- Err ( _) => {
357
- return Err ( S :: Error :: custom ( "Unable to serialize the BookConfig" ) ) ;
358
- }
359
- } ;
360
- let rust_config = Value :: try_from ( & self . rust ) . expect ( "should always be serializable" ) ;
361
-
352
+ let book_config = Value :: try_from ( & self . book ) . expect ( "should always be serializable" ) ;
362
353
table. insert ( "book" , book_config) ;
363
- table. insert ( "rust" , rust_config) ;
354
+
355
+ if self . rust != RustConfig :: default ( ) {
356
+ let rust_config = Value :: try_from ( & self . rust ) . expect ( "should always be serializable" ) ;
357
+ table. insert ( "rust" , rust_config) ;
358
+ }
359
+
364
360
table. serialize ( s)
365
361
}
366
362
}
Original file line number Diff line number Diff line change @@ -24,6 +24,12 @@ fn base_mdbook_init_should_create_default_content() {
24
24
println ! ( "{}" , target. display( ) ) ;
25
25
assert ! ( target. exists( ) , "{} doesn't exist" , file) ;
26
26
}
27
+
28
+ let contents = fs:: read_to_string ( temp. path ( ) . join ( "book.toml" ) ) . unwrap ( ) ;
29
+ assert_eq ! (
30
+ contents,
31
+ "[book]\n authors = []\n language = \" en\" \n multilingual = false\n src = \" src\" \n "
32
+ ) ;
27
33
}
28
34
29
35
/// Run `mdbook init` in a directory containing a SUMMARY.md should create the
You can’t perform that action at this time.
0 commit comments