From a8756a1af9f581a63253f3fa90a2c46086cd3b50 Mon Sep 17 00:00:00 2001 From: WuXing-ovo Date: Sun, 29 Mar 2026 22:06:05 +0800 Subject: [PATCH] fix: correct Mermaid rendering in lifetime elision diagram --- .../ch07-1-lifetimes-and-borrowing-deep-dive.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/c-cpp-book/src/ch07-1-lifetimes-and-borrowing-deep-dive.md b/c-cpp-book/src/ch07-1-lifetimes-and-borrowing-deep-dive.md index b31ced2..a8f44e8 100644 --- a/c-cpp-book/src/ch07-1-lifetimes-and-borrowing-deep-dive.md +++ b/c-cpp-book/src/ch07-1-lifetimes-and-borrowing-deep-dive.md @@ -181,15 +181,15 @@ lifetimes are determined after applying the rules, no annotations are needed. ```mermaid flowchart TD - A["Function signature with references"] --> R1 - R1["Rule 1: Each input reference
gets its own lifetime

fn f(&str, &str)
→ fn f<'a,'b>(&'a str, &'b str)"] + A["Function signature
with references"] --> R1 + R1["Rule 1: Each input
reference gets its own
lifetime

fn f(&str, &str)
→ fn f<'a,'b>(&'a str,
&'b str)"] R1 --> R2 - R2["Rule 2: If exactly ONE input
lifetime, assign it to ALL outputs

fn f(&str) → &str
→ fn f<'a>(&'a str) → &'a str"] + R2["Rule 2: If exactly ONE
input lifetime, assign it
to ALL outputs

fn f(&str) → &str
→ fn f<'a>(&'a str)
→ &'a str"] R2 --> R3 - R3["Rule 3: If one input is &self
or &mut self, assign its lifetime
to ALL outputs

fn f(&self, &str) → &str
→ fn f<'a>(&'a self, &str) → &'a str"] - R3 --> CHECK{{"All output lifetimes
determined?"}} - CHECK -->|"Yes"| OK["✅ No annotations needed"] - CHECK -->|"No"| ERR["❌ Compile error:
must annotate manually"] + R3["Rule 3: If one input is
&self or &mut self,
assign its lifetime to
ALL outputs

fn f(&self, &str) → &str
→ fn f<'a>(&'a self, &str)
→ &'a str"] + R3 --> CHECK{{"All output
lifetimes
determined?"}} + CHECK -->|Yes| OK["✅ No annotations
needed"] + CHECK -->|No| ERR["❌ Compile error:
must annotate
manually"] style OK fill:#91e5a3,color:#000 style ERR fill:#ff6b6b,color:#000