Skip to content

Commit

Permalink
Bug 1412486: Unconditionally implement Debug for RefPtr. r?xidorn
Browse files Browse the repository at this point in the history
Bindgen doesn't know how to derive debug for a Gecko font family list. Hopefully
it doesn't need to.

MozReview-Commit-ID: 4iZKzjad6K9
  • Loading branch information
emilio committed Oct 31, 2017
1 parent 5bce3a3 commit 75b9d30
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions components/style/gecko_bindings/sugar/refptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use gecko_bindings::structs;
use gecko_bindings::sugar::ownership::HasArcFFI;
use servo_arc::Arc;
use std::{mem, ptr};
use std::{fmt, mem, ptr};
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};

Expand All @@ -25,12 +25,19 @@ pub unsafe trait ThreadSafeRefCounted: RefCounted {}

/// A custom RefPtr implementation to take into account Drop semantics and
/// a bit less-painful memory management.
#[derive(Debug)]
pub struct RefPtr<T: RefCounted> {
ptr: *mut T,
_marker: PhantomData<T>,
}

impl<T: RefCounted> fmt::Debug for RefPtr<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("RefPtr { ")?;
self.ptr.fmt(f)?;
f.write_str("}")
}
}

/// A RefPtr that we know is uniquely owned.
///
/// This is basically Box<T>, with the additional guarantee that the box can be
Expand Down

0 comments on commit 75b9d30

Please sign in to comment.