refbox: add Debug impl

This commit is contained in:
Cody P Schafer 2015-04-03 15:39:28 -04:00
parent 86f7a2795f
commit 6240bcfc31
2 changed files with 7 additions and 1 deletions

View File

@ -1,5 +1,6 @@
use std::boxed::Box;
use std::ops::Deref;
use std::fmt;
use rustc_serialize::{Encodable, Encoder};
use rustc_serialize::{Decodable, Decoder};
@ -149,3 +150,8 @@ impl <'a, T> Deref for RefBox<'a, T> {
}
}
impl <'a, T: fmt::Debug> fmt::Debug for RefBox<'a, T> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> Result<(), fmt::Error> {
write!(fmt, "RefBox({:?})", *self)
}
}

View File

@ -269,7 +269,7 @@ fn test_refbox() {
large_map.insert(1, 2);
#[derive(RustcEncodable, RustcDecodable)]
#[derive(RustcEncodable, RustcDecodable, Debug)]
enum Message<'a> {
M1(RefBox<'a, Vec<u32>>),
M2(RefBox<'a, HashMap<u32, u32>>)