Derive Debug for ProxyVTable

This is now possible since we use the latest Rust toolchain.

PiperOrigin-RevId: 549038928
pull/13347/head
Marcel Hlopko 2 years ago committed by Copybara-Service
parent e38dcafc7c
commit 8e210a888d
  1. 16
      rust/optional.rs

@ -505,6 +505,7 @@ mod tests {
msg.presence & (1 << B_BIT) != 0
}
#[derive(Debug)]
struct ProxyVtable {
get: fn(&MyMessage) -> i32,
set: fn(&mut MyMessage, val: i32),
@ -512,21 +513,6 @@ mod tests {
has: fn(&MyMessage) -> bool,
}
impl Debug for ProxyVtable {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// Manual `Debug` impl to work around `fmt::Debug` not being implemented for
// functions pointers with higher-ranked lifetimes, which was fixed
// in Rust 1.70.
// TODO(hlopko): replace with `#[derive(Debug)]` when rustc is updated.
f.debug_struct("ProxyVtable")
.field("get", &(self.get as *const ()))
.field("set", &(self.set as *const ()))
.field("clear", &(self.clear as *const ()))
.field("has", &(self.has as *const ()))
.finish()
}
}
/// A proxy for a `i32` that is accessed through methods on a vtable.
struct VtableProxied;

Loading…
Cancel
Save