From cd45ae504e21d038ab455870cd5cafbee3c0166f Mon Sep 17 00:00:00 2001 From: Sam McCall Date: Mon, 23 Feb 2026 09:20:24 +0100 Subject: [PATCH] s/double/triple/ to avoid unintentional pun Replaced 'double' function with 'triple' function in example. "double" is the name of a type in C and others, and `double(uid)` is valid syntax for an explicit cast! --- src/idiomatic/leveraging-the-type-system/newtype-pattern.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/idiomatic/leveraging-the-type-system/newtype-pattern.md b/src/idiomatic/leveraging-the-type-system/newtype-pattern.md index f95b7a48879b..ab7b56fc8ecc 100644 --- a/src/idiomatic/leveraging-the-type-system/newtype-pattern.md +++ b/src/idiomatic/leveraging-the-type-system/newtype-pattern.md @@ -26,11 +26,11 @@ Unlike type aliases, newtypes aren't interchangeable with the wrapped type: # // SPDX-License-Identifier: Apache-2.0 # # pub struct UserId(u64); -fn double(n: u64) -> u64 { - n * 2 +fn triple(n: u64) -> u64 { + n * 3 } -double(UserId(1)); // 🛠️❌ +triple(UserId(1)); // 🛠️❌ ``` The Rust compiler won't let you use methods or operators defined on the