From e2c73ccaf22ec3908cf77e604233c5833ac5ae7d Mon Sep 17 00:00:00 2001 From: Samuel Chase Date: Sat, 11 May 2013 19:18:14 +0530 Subject: [PATCH] Add str representation for HashSet. --- src/libcore/to_str.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libcore/to_str.rs b/src/libcore/to_str.rs index 3806335e2408..299ba45986e6 100644 --- a/src/libcore/to_str.rs +++ b/src/libcore/to_str.rs @@ -72,6 +72,24 @@ impl ToStr for HashMap { } } +impl ToStr for HashSet { + #[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 ToStr for (A, B) { #[inline(always)] fn to_str(&self) -> ~str {