From 92bf9b68da05504e925e2b66ceb9f3e5f1a5b0ee Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Wed, 24 Apr 2013 22:33:13 -0400 Subject: [PATCH 1/2] Add basic documentation for with_capacity --- src/libcore/vec.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index e478936ff65cc..f5ed574527d2d 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -173,6 +173,7 @@ pub fn from_slice(t: &[T]) -> ~[T] { from_fn(t.len(), |i| t[i]) } +/// Creates a new vector with a capacity of `capacity` pub fn with_capacity(capacity: uint) -> ~[T] { let mut vec = ~[]; reserve(&mut vec, capacity); From 91fb7b282de4877e72f22f42b4535e3c76732264 Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Wed, 24 Apr 2013 22:33:48 -0400 Subject: [PATCH 2/2] Move documentation for vec::windowed where it will be generated --- src/libcore/vec.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index f5ed574527d2d..a56f69f4ae9ff 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -1566,6 +1566,16 @@ pub fn each_permutation(v: &[T], put: &fn(ts: &[T]) -> bool) { } } +// see doc below +#[cfg(stage0)] // XXX: lifetimes! +pub fn windowed(n: uint, v: &[T], it: &fn(&[T]) -> bool) { + assert!(1u <= n); + if n > v.len() { return; } + for uint::range(0, v.len() - n + 1) |i| { + if !it(v.slice(i, i+n)) { return } + } +} + /** * Iterate over all contiguous windows of length `n` of the vector `v`. * @@ -1580,14 +1590,6 @@ pub fn each_permutation(v: &[T], put: &fn(ts: &[T]) -> bool) { * ~~~ * */ -#[cfg(stage0)] // XXX: lifetimes! -pub fn windowed(n: uint, v: &[T], it: &fn(&[T]) -> bool) { - assert!(1u <= n); - if n > v.len() { return; } - for uint::range(0, v.len() - n + 1) |i| { - if !it(v.slice(i, i+n)) { return } - } -} #[cfg(stage1)] #[cfg(stage2)] #[cfg(stage3)]