From 479d834a1041faf890258c04cb20fb19b0b4f196 Mon Sep 17 00:00:00 2001 From: michael-kerscher Date: Wed, 7 May 2025 17:48:54 +0200 Subject: [PATCH] mdbook-exerciser: ensure all code block bytes of the examples are written to the file (#2742) - write() attempts to write the entire buffer does not guarantee this. Not writing all bytes is not considered an error. It just returns the number of bytes. - write_all() ensures that everything is written or throws an error --- mdbook-exerciser/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdbook-exerciser/src/lib.rs b/mdbook-exerciser/src/lib.rs index 8f6040d6..8a13abef 100644 --- a/mdbook-exerciser/src/lib.rs +++ b/mdbook-exerciser/src/lib.rs @@ -58,7 +58,7 @@ pub fn process(output_directory: &Path, input_contents: &str) -> anyhow::Result< Event::Text(text) => { info!("Text: {:?}", text); if let Some(output_file) = &mut current_file { - output_file.write(text.as_bytes())?; + output_file.write_all(text.as_bytes())?; } } Event::End(TagEnd::CodeBlock) => {