From c2532d5f17872adeaba8e3cb32e0be41bec507dc Mon Sep 17 00:00:00 2001 From: Alyssa Haroldsen Date: Wed, 13 Dec 2023 13:52:31 -0800 Subject: [PATCH] Move the info about perfect derive to shared.rs PiperOrigin-RevId: 590702727 --- rust/cpp.rs | 3 --- rust/shared.rs | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rust/cpp.rs b/rust/cpp.rs index 2090a662f9ec..1d0fbe10c4c8 100644 --- a/rust/cpp.rs +++ b/rust/cpp.rs @@ -229,9 +229,6 @@ impl<'msg, T: ?Sized> RepeatedField<'msg, T> { } } -// These use manual impls instead of derives to avoid unnecessary bounds on `T`. -// This problem is referred to as "perfect derive". -// https://smallcultfollowing.com/babysteps/blog/2022/04/12/implied-bounds-and-perfect-derive/ impl<'msg, T: ?Sized> Copy for RepeatedField<'msg, T> {} impl<'msg, T: ?Sized> Clone for RepeatedField<'msg, T> { fn clone(&self) -> RepeatedField<'msg, T> { diff --git a/rust/shared.rs b/rust/shared.rs index f94f987989da..620d285061da 100644 --- a/rust/shared.rs +++ b/rust/shared.rs @@ -13,6 +13,11 @@ use std::fmt; +// There are a number of manual `Debug` and similar impls instead of using their +// derives, in order to to avoid unnecessary bounds on a generic `T`. +// This problem is referred to as "perfect derive". +// https://smallcultfollowing.com/babysteps/blog/2022/04/12/implied-bounds-and-perfect-derive/ + /// Everything in `__public` is re-exported in `protobuf.rs`. /// These are the items protobuf users can access directly. #[doc(hidden)]