Skip to content

Commit

Permalink
Add str representation for HashSet.
Browse files Browse the repository at this point in the history
  • Loading branch information
samebchase committed May 11, 2013
1 parent b8d0ebe commit e2c73cc
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/libcore/to_str.rs
Expand Up @@ -72,6 +72,24 @@ impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
}
}
impl<A:ToStr+Hash+Eq> ToStr for HashSet<A> {
#[inline(always)]
fn to_str(&self) -> ~str {
let mut acc = ~"{", first = true;
for self.each |element| {
if first {
first = false;
}
else {
acc.push_str(", ");
}
acc.push_str(element.to_str());
}
acc.push_char('}');
acc
}
}
impl<A:ToStr,B:ToStr> ToStr for (A, B) {
#[inline(always)]
fn to_str(&self) -> ~str {
Expand Down

0 comments on commit e2c73cc

Please sign in to comment.