Skip to content

Commit 2d6e6b5

Browse files
Merge pull request #62 from WuXing-ovo/fix/lifetime-flowchart
Fix Mermaid diagram rendering in ch07-1
2 parents e02e1aa + a8756a1 commit 2d6e6b5

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

c-cpp-book/src/ch07-1-lifetimes-and-borrowing-deep-dive.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ lifetimes are determined after applying the rules, no annotations are needed.
181181

182182
```mermaid
183183
flowchart TD
184-
A["Function signature with references"] --> R1
185-
R1["Rule 1: Each input reference<br/>gets its own lifetime<br/><br/>fn f(&str, &str)<br/>→ fn f<'a,'b>(&'a str, &'b str)"]
184+
A["Function signature<br/>with references"] --> R1
185+
R1["Rule 1: Each input<br/>reference gets its own<br/>lifetime<br/><br/>fn f(&amp;str, &amp;str)<br/>→ fn f&lt;'a,'b&gt;(&amp;'a str,<br/>&amp;'b str)"]
186186
R1 --> R2
187-
R2["Rule 2: If exactly ONE input<br/>lifetime, assign it to ALL outputs<br/><br/>fn f(&str) → &str<br/>→ fn f<'a>(&'a str) → &'a str"]
187+
R2["Rule 2: If exactly ONE<br/>input lifetime, assign it<br/>to ALL outputs<br/><br/>fn f(&amp;str) → &amp;str<br/>→ fn f&lt;'a&gt;(&amp;'a str)<br/>→ &amp;'a str"]
188188
R2 --> R3
189-
R3["Rule 3: If one input is &self<br/>or &mut self, assign its lifetime<br/>to ALL outputs<br/><br/>fn f(&self, &str) → &str<br/>→ fn f<'a>(&'a self, &str) → &'a str"]
190-
R3 --> CHECK{{"All output lifetimes<br/>determined?"}}
191-
CHECK -->|"Yes"| OK["✅ No annotations needed"]
192-
CHECK -->|"No"| ERR["❌ Compile error:<br/>must annotate manually"]
189+
R3["Rule 3: If one input is<br/>&amp;self or &amp;mut self,<br/>assign its lifetime to<br/>ALL outputs<br/><br/>fn f(&amp;self, &amp;str) → &amp;str<br/>→ fn f&lt;'a&gt;(&amp;'a self, &amp;str)<br/>→ &amp;'a str"]
190+
R3 --> CHECK{{"All output<br/>lifetimes<br/>determined?"}}
191+
CHECK -->|Yes| OK["✅ No annotations<br/>needed"]
192+
CHECK -->|No| ERR["❌ Compile error:<br/>must annotate<br/>manually"]
193193
194194
style OK fill:#91e5a3,color:#000
195195
style ERR fill:#ff6b6b,color:#000

0 commit comments

Comments
 (0)