Skip to content

Commit

Permalink
Require all Proxied types to be Sized.
Browse files Browse the repository at this point in the history
This is currently true and required by the IntoProxied trait. In Rust all type parameters are explicitly marked `Sized`, except for `Self` [1]. By marking `Proxied` as `Sized` we can write `IntoProxied<Self>` in generic code without having to add 'where Self: Sized` clauses.

An implication of this change is that Proxied can no longer be used from a trait object i.e. `let x: dyn &Proxied = &foo` will not compile. We are not anticipating such use cases at this point.

[1] https://doc.rust-lang.org/std/marker/trait.Sized.html

PiperOrigin-RevId: 649010900
  • Loading branch information
buchgr authored and copybara-github committed Jul 3, 2024
1 parent 64912c5 commit 73db255
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rust/proxied.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use std::fmt::Debug;
/// An instance of a `Proxied` can be accessed immutably via `Proxied::View`.
///
/// All Protobuf field types implement `Proxied`.
pub trait Proxied {
pub trait Proxied: Sized {
/// The proxy type that provides shared access to a `T`, like a `&'msg T`.
///
/// Most code should use the type alias [`View`].
Expand Down

0 comments on commit 73db255

Please sign in to comment.