Skip to content

Commit

Permalink
Move the info about perfect derive to shared.rs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 590702727
  • Loading branch information
kupiakos authored and copybara-github committed Dec 13, 2023
1 parent 7c38dab commit c2532d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 0 additions & 3 deletions rust/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
5 changes: 5 additions & 0 deletions rust/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit c2532d5

Please sign in to comment.