From 7f3235115bc4097f90cd156c97844c30bd258426 Mon Sep 17 00:00:00 2001 From: Tshepang Mbambo Date: Wed, 18 Feb 2026 01:52:46 +0200 Subject: [PATCH] expr.block.value-(no-)trailing-expr: more clearly demonstrate intent Showing type annotations clutters the examples somewhat, because we also use asserts to prove the rules. --- src/expressions/block-expr.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/expressions/block-expr.md b/src/expressions/block-expr.md index 4ae74d1674..77e5849bf3 100644 --- a/src/expressions/block-expr.md +++ b/src/expressions/block-expr.md @@ -46,9 +46,9 @@ r[expr.block.value-trailing-expr] When a block contains a [final operand], the block has the type and value of that final operand. ```rust -let x: u8 = { 0u8 }; // `0u8` is the final operand. +let x = { 0u8 }; // `0u8` is the final operand. assert_eq!(x, 0); -let x: u8 = { (); 0u8 }; // As above. +let x = { (); 0u8 }; // As above. assert_eq!(x, 0); ``` @@ -56,9 +56,9 @@ r[expr.block.value-no-trailing-expr] When a block does not contain a [final operand] and the block does not diverge, the block has [unit type] and [unit value]. ```rust -let x: () = {}; // Has no final operand. +let x = {}; // Has no final operand. assert_eq!(x, ()); -let x: () = { 0u8; }; // As above. +let x = { 0u8; }; // As above. assert_eq!(x, ()); ```