diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-06-14 16:24:21 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-06-14 17:56:41 -0700 |
| commit | ffc9fff720c33776d681034b7b7c8d920b2d6a15 (patch) | |
| tree | b2ae5920660b326049972180a70e430a7ca29978 | |
| parent | 97bcb2024440935f5e9ba2ac6116dc1ac8702824 (diff) | |
| download | rust-ffc9fff720c33776d681034b7b7c8d920b2d6a15.tar.gz rust-ffc9fff720c33776d681034b7b7c8d920b2d6a15.zip | |
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.
| -rw-r--r-- | src/libcore/dvec.rs | 43 |
1 files changed, 23 insertions, 20 deletions
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<A> for dvec<A> { #[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<A:copy> for dvec<A> { } } - //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<I:iter::base<A>>(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<A, I:iter::base_iter<A>>(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. |
