From e09a5fade3cfd0b2f0ad8079ec37dfa3a4b8c4f5 Mon Sep 17 00:00:00 2001 From: DavidMei <94948521@163.com> Date: Fri, 27 Mar 2026 18:31:36 +0800 Subject: [PATCH] Clarify implicit unit return in functions chapter Align the prose with the compiler output by explaining that the semicolon makes the function implicitly return the unit type instead of suggesting that nothing is returned. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/ch03-03-how-functions-work.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ch03-03-how-functions-work.md b/src/ch03-03-how-functions-work.md index 5f9e512da2..84b6daf54e 100644 --- a/src/ch03-03-how-functions-work.md +++ b/src/ch03-03-how-functions-work.md @@ -247,7 +247,7 @@ Compiling this code will produce an error, as follows: The main error message, `mismatched types`, reveals the core issue with this code. The definition of the function `plus_one` says that it will return an `i32`, but statements don’t evaluate to a value, which is expressed by `()`, -the unit type. Therefore, nothing is returned, which contradicts the function -definition and results in an error. In this output, Rust provides a message to -possibly help rectify this issue: It suggests removing the semicolon, which -would fix the error. +the unit type. Therefore, the function implicitly returns `()`, which +contradicts the function definition and results in an error. In this output, +Rust provides a message to possibly help rectify this issue: It suggests +removing the semicolon, which would fix the error.