about summary refs log tree commit diff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index e8bd331f968..80b0764e513 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -645,7 +645,7 @@ pub fn format_code_block(code_snippet: &str, config: &Config) -> Option<String>
     // then unindent the whole code block.
     let formatted = format_snippet(&snippet, config)?;
     // 2 = "}\n"
-    let block_len = formatted.len().checked_sub(2).unwrap_or(0);
+    let block_len = formatted.rfind('}').unwrap_or(formatted.len());
     let mut is_indented = true;
     for (kind, ref line) in LineClasses::new(&formatted[FN_MAIN_PREFIX.len()..block_len]) {
         if !is_first {