From ffc9fff720c33776d681034b7b7c8d920b2d6a15 Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 14 Jun 2012 16:24:21 -0700 Subject: In dvec, annotate a FIXME and uncomment append_iter I uncommented append_iter and made it compile. I hope it wasn't horribly flawed in some other way... but if so, there was no comment explaining how. --- src/libcore/dvec.rs | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'src/libcore') diff --git a/src/libcore/dvec.rs b/src/libcore/dvec.rs index ccaab58553f..428abb36cc8 100644 --- a/src/libcore/dvec.rs +++ b/src/libcore/dvec.rs @@ -129,7 +129,7 @@ impl extensions for dvec { #[doc = "Overwrite the current contents"] fn set(+w: [mut A]) { self.check_not_borrowed(); - self.data <- w; //FIXME check for recursive use + self.data <- w; //FIXME check for recursive use (#2607) } } @@ -177,25 +177,28 @@ impl extensions for dvec { } } - //FIXME-- - //#[doc = " - // Append all elements of an iterable. - // - // Failure will occur if the iterable's `each()` method - // attempts to access this vector. - //"] - //fn append_iter>(ts: I) { - // self.data.swap { |v| - // alt ts.size_hint() { - // none {} - // some(h) { vec::reserve(v, len(v) + h) } - // } - // - // for ts.each { |t| v = v + [t] }; - // - // v - // } - //} + #[doc = " + Append all elements of an iterable. + + Failure will occur if the iterable's `each()` method + attempts to access this vector. + "] + fn append_iter>(ts: I) { + self.swap { |v| + let mut v = alt ts.size_hint() { + none { v } + some(h) { + let len = v.len() + h; + let mut v <- v; + vec::reserve(v, len); + v + } + }; + + for ts.each { |t| v += [t] }; + v + } + } #[doc = " Gets a copy of the current contents. -- cgit 1.4.1-3-g733a5