std::to_str: Use .iter() for HashMap and HashSet
This commit is contained in:
parent
13f666a724
commit
8baefec013
@ -23,6 +23,7 @@ use hash::Hash;
|
||||
use cmp::Eq;
|
||||
use old_iter::BaseIter;
|
||||
use vec::ImmutableVector;
|
||||
use iterator::IteratorUtil;
|
||||
|
||||
/// A generic trait for converting a value to a string
|
||||
pub trait ToStr {
|
||||
@ -56,7 +57,7 @@ impl<A:ToStr+Hash+Eq, B:ToStr+Hash+Eq> ToStr for HashMap<A, B> {
|
||||
#[inline]
|
||||
fn to_str(&self) -> ~str {
|
||||
let mut (acc, first) = (~"{", true);
|
||||
for self.each |key, value| {
|
||||
for self.iter().advance |(key, value)| {
|
||||
if first {
|
||||
first = false;
|
||||
}
|
||||
@ -76,7 +77,7 @@ impl<A:ToStr+Hash+Eq> ToStr for HashSet<A> {
|
||||
#[inline]
|
||||
fn to_str(&self) -> ~str {
|
||||
let mut (acc, first) = (~"{", true);
|
||||
for self.each |element| {
|
||||
for self.iter().advance |element| {
|
||||
if first {
|
||||
first = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user