| Age | Commit message (Collapse) | Author | Lines |
|
This method is the mutable version of ImmutableVector::split. It is
a DoubleEndedIterator, making mut_rsplit irrelevent. The size_hint
method is not optimal because of #9629.
At the same time, clarify *split* iterator doc.
|
|
|
|
|
|
mut_chunks() returns an iterator that produces mutable slices. This is the
mutable version of the existing chunks() method on the ImmutableVector trait.
|
|
Also documented a few issues
|
|
nikomatsakis/rust/issue-8624-borrowck-overly-permissive, r=pnkfelix
See #8624 for details.
r? @pnkfelix
|
|
|
|
|
|
compile-fail tests, run-fail tests, and run-pass tests.
|
|
|
|
|
|
|
|
This also enables two tests properly.
|
|
first/last item in the slice and modify the slice to exclude the returned item. Useful when writing iterators over mutable references.
|
|
New benchmark tests in vec.rs:
`push`, `starts_with_same_vector`, `starts_with_single_element`,
`starts_with_diff_one_element_end`, `ends_with_same_vector`,
`ends_with_single_element`, `ends_with_diff_one_element_beginning` and
`contains_last_element`
|
|
Closes #10579
|
|
|
|
Fixes #10271
|
|
Closes #10240
|
|
|
|
|
|
Who doesn't like a massive renaming?
|
|
|
|
|
|
|
|
|
|
|
|
Commits have all the fun details
|
|
Closes #9824
|
|
This allows the indexing bounds check or other comparisons against an
element length to avoid a multiplication by the size.
|
|
This means the text is visible in rustdoc.
|
|
This adds `get_opt` to `std::vec`, which looks up an item by index and returns an `Option`. If the given index is out of range, `None` will be returned, otherwise a `Some`-wrapped item will be returned.
Example use case:
```rust
use std::os;
fn say_hello(name: &str) {
println(fmt!("Hello, %s", name));
}
fn main(){
// Try to get the first cmd line arg, but default to "World"
let args = os::args();
let default = ~"World";
say_hello(*args.get_opt(1).unwrap_or(&default));
}
```
If there's an existing way of implementing this pattern that's cleaner, I'll happily close this. I'm also open to naming suggestions (`index_opt`?)
|
|
|
|
|
|
std::vec: Sane implementations for connect_vec and concat_vec
Avoid unnecessary copying of subvectors, and calculate the needed space
beforehand. These implementations are simple but better than the
previous.
Also only implement it once, for all `Vector<T>` using:
impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V]
Closes #9581
|
|
std::vec::{concat, connect, concat_slices, connect_slices} are replaced
by the already existing trait methods .concat_vec() and .connect_vec().
|
|
Avoid unnecessary copying of subvectors, and calculate the needed space
beforehand. These implementations are simple but better than the
previous.
Also only implement it once, for all `Vector<T>` using:
impl<'self, T: Clone, V: Vector<T>> VectorVector<T> for &'self [V]
performance improved according to the bench test:
before
test vec::bench::concat ... bench: 74818 ns/iter (+/- 408)
test vec::bench::connect ... bench: 87066 ns/iter (+/- 376)
after
test vec::bench::concat ... bench: 17724 ns/iter (+/- 126)
test vec::bench::connect ... bench: 18353 ns/iter (+/- 691)
Closes #9581
|
|
|
|
std::vec: Use a valid value as lifetime dummy in iterator
The current implementation uses `&v[0]` for the lifetime struct field,
but that is a dangling pointer for iterators derived from zero-length
slices.
Example:
let v: [int, ..0] = []; println!("{:?}", v.iter())
std::vec::VecIterator<,int>{ptr: (0x7f3768626100 as *()), end: (0x7f3768626100 as *()), lifetime: &139875951207128}
To replace this parameter, use a field of type `Option<&'self ()>`
that is simply initialized with `None`, but still allows the iterator to
have a lifetime parameter.
|
|
The current implementation uses `&v[0]` for the lifetime struct field,
but that is a dangling pointer for iterators derived from zero-length
slices.
Example:
let v: [int, ..0] = []; println!("{:?}", v.iter())
std::vec::VecIterator<,int>{ptr: (0x7f3768626100 as *()), end: (0x7f3768626100 as *()), lifetime: &139875951207128}
To replace this parameter, use a field of type `Option<&'self ()>`
that is simply initialized with `None`, but still allows the iterator to
have a lifetime parameter.
|
|
|
|
find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g'
find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g'
find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
|
|
Closes #9379
|
|
Hopefull this will make our libstd docs appear a little more "full".
|
|
Easy to reproduce:
let mut v = ~[@1];
v.resize(-1); // success a.k.a silent failure
v.push(@2); // segfault
|
|
`push_bytes` is implemented with `ptr::copy_memory` here since this
function is intended to be used to implement `.push_str()` for str, so
we want to avoid the overhead.
|
|
Issue #8742
Add the method `.reserve_additional(n: uint)`: Check for overflow in
self.len() + n, and reserve that many elements (rounded up to next power
of two). Does nothing if self.len() + n < self.capacity() already.
|
|
Vecs are not numeric types, so it doesn't make sense for them to
implement Zero.
|
|
|
|
|