Delegate ToStr implementation to Show for tuples
This commit is contained in:
@@ -17,6 +17,7 @@ use clone::Clone;
|
||||
#[cfg(not(test))] use default::Default;
|
||||
use fmt;
|
||||
use result::{Ok, Err};
|
||||
use to_str::ToStr;
|
||||
|
||||
/// Method extensions to pairs where both types satisfy the `Clone` bound
|
||||
pub trait CloneableTuple<T, U> {
|
||||
@@ -179,6 +180,12 @@ macro_rules! tuple_impls {
|
||||
}
|
||||
}
|
||||
|
||||
impl<$($T: fmt::Show),+> ToStr for ($($T,)+) {
|
||||
fn to_str(&self) -> ~str {
|
||||
format!("{}", *self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<$($T: fmt::Show),+> fmt::Show for ($($T,)+) {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write_tuple!(f.buf, $(self.$get_ref_fn()),+)
|
||||
|
||||
Reference in New Issue
Block a user