Commit Graph

114 Commits

Author SHA1 Message Date
Niko Matsakis 0c6d02f391 Correct merge errors 2013-07-08 13:55:11 -04:00
Niko Matsakis 979d3a54f9 Correct merge failures 2013-07-08 13:55:11 -04:00
Niko Matsakis 9999622e44 Patch up some code that was using irrefutable patterns incorrectly. 2013-07-08 13:53:44 -04:00
Niko Matsakis ba13482dfa update ptr intrinsics and rewrite vec routines to be more correct.
In particular, it is not valid to go around passing uninitialized or zero'd
memory as arguments. Rust should generally be free to assume that the arguments
it gets are valid input values, but the output of intrinsics::uninit() and
intrinsics::init() are not (e.g., an @T is just null, leading to an error
if we should try to increment the ref count).
2013-07-08 13:53:44 -04:00
bors 48ad726f2a auto merge of #7605 : thestinger/rust/vec, r=Aatch
This is work continued from the now landed #7495 and #7521 pulls.

Removing the headers from unique vectors is another project, so I've separated the allocator.
2013-07-08 02:52:56 -07:00
Daniel Micay 7bf34c3437 vec: make vec_reserve_shared_actual private 2013-07-08 03:41:21 -04:00
Daniel Micay 641aec7407 remove some method resolve workarounds 2013-07-07 19:51:13 -04:00
bors 3c44265d87 auto merge of #7602 : blake2-ppc/rust/vec-pop-opt, r=cmr
Implement methods `.pop_opt() -> Option<T>` and `.shift_opt() -> Option<T>` to allow retrieval of front/back of a vec in one operation without fail. .pop() and .shift() are changed to reuse the former two methods.

Follows the naming of the previous method .head_opt()
2013-07-07 09:35:04 -07:00
blake2-ppc fc17d4371f vec: Add .shift_opt() -> Option<T>
Add a function to safely retrieve the first element of a ~[T], as
Option<T>. Implement shift() using shift_opt().

Add tests for both .shift() and .shift_opt()
2013-07-05 20:32:25 +02:00
blake2-ppc d805b832f5 vec: Add .pop_opt() -> Option<T>
Add a function to safely retrieve the last element of a ~[T], as
Option<T>. Implement pop() using pop_opt(); it benches the same as the
old implementation when tested with optimization level 2.
2013-07-05 20:32:25 +02:00
Kevin Ballard dc9b3ff1b3 Change signature of Iterator.size_hint
Remove the Option wrapper around the lower bound. None is semantically
the same as Size(0), so there's no point in having a distinction.
2013-07-05 01:56:48 -07:00
Daniel Micay dd4f6bb2a2 Merge pull request #7565 from Blei/fix-rev-size-hint
vec: Fix size_hint() of reverse iterators
2013-07-03 22:07:20 -07:00
Huon Wilson cdea73cf5b Convert vec::{as_imm_buf, as_mut_buf} to methods. 2013-07-04 00:46:50 +10:00
Huon Wilson a732a2daff Convert vec::windowed to an external iterator, and add an n-at-a-time chunk iterator. 2013-07-04 00:46:50 +10:00
Huon Wilson 944d904ad4 Convert vec::{split, splitn, rsplit, rsplitn} to external iterators. 2013-07-04 00:46:50 +10:00
Huon Wilson f19fb2459f Remove standalone comparison functions in vec, make the trait impls better. 2013-07-04 00:46:50 +10:00
Huon Wilson 9207802589 Remove vec::reversed, replaced by iterators. 2013-07-04 00:46:50 +10:00
Huon Wilson de0d696561 Remove vec::{filter, filtered, filter_map, filter_mapped}, replaced by iterators. 2013-07-04 00:46:49 +10:00
Huon Wilson eee6775642 Implement consuming iterators for ~[], remove vec::{consume, consume_reverse, map_consume}. 2013-07-04 00:46:49 +10:00
Philipp Brüschweiler 6ee8fee730 vec: Fix size_hint() of reverse iterators
Fixes #7558
2013-07-03 14:56:26 +02:00
bors ea31b9cca1 auto merge of #7474 : Seldaek/rust/clean-iter, r=thestinger
I think it's WIP - but I wanted to ask for feedback (/cc @thestinger)

I had to move the impl of FromIter for vec into extra::iter because I don't think std can depend on extra, but that's a bit messed up. Similarly some FromIter uses are gone now, not sure if this is fixable or if I made a complete mess here..
2013-07-03 01:07:55 -07:00
bors d324014c6c auto merge of #7521 : thestinger/rust/vec, r=Aatch
continued from #7495
2013-07-01 02:26:46 -07:00
bors 07feeb95c5 auto merge of #7487 : huonw/rust/vec-kill, r=cmr
Continuation of #7430.

I haven't removed the `map` method, since the replacement `v.iter().transform(f).collect::<~[SomeType]>()` is a little ridiculous at the moment.
2013-06-30 21:14:13 -07:00
Daniel Micay b731d96b4f vec: implement exchange vector reserve in Rust 2013-06-30 22:30:37 -04:00
Jordi Boggiano 3fe05a987c Move most iter functionality to extra, fixes #7343 2013-07-01 01:50:40 +02:00
bors 040ac2a932 auto merge of #7495 : thestinger/rust/exchange, r=cmr
With these changes, exchange allocator headers are never initialized, read or written to. Removing the header will now just involve updating the code in trans using an offset to only do it if the type contained is managed.

The only thing blocking removing the initialization of the last field in the header was ~fn since it uses it to store the dynamic size/types due to captures. I temporarily switched it to a `closure_exchange_alloc` lang item (it uses the same `exchange_free`) and #7496 is filed about removing that.

Since the `exchange_free` call is now inlined all over the codebase, I don't think we should have an assert for null. It doesn't currently ever happen, but it would be fine if we started generating code that did do it. The `exchange_free` function also had a comment declaring that it must not fail, but a regular assert would cause a failure. I also removed the atomic counter because valgrind can already find these leaks, and we have valgrind bots now.

Note that exchange free does not currently print an error an out-of-memory when it aborts, because our `io` code may allocate. We could probably get away with a `#[rust_stack]` call to a `stdio` function but it would be better to make a write system call.
2013-06-30 15:02:05 -07:00
Huon Wilson c0a20d2929 Remove vec::{map, mapi, zip_map} and the methods, except for .map, since this
is very common, and the replacement (.iter().transform().collect()) is very
ugly.
2013-06-30 21:59:44 +10:00
Huon Wilson a396e1e2e9 Convert vec::{grow, grow_fn, grow_set} to methods. 2013-06-30 21:17:47 +10:00
Huon Wilson 2eea642c30 Convert vec::dedup to a method. 2013-06-30 21:17:09 +10:00
Huon Wilson faa8f8ff8b Convert vec::{bsearch, bsearch_elem} to methods. 2013-06-30 21:15:25 +10:00
Huon Wilson 9e83b2fe55 Convert vec::{reverse, swap} to methods. 2013-06-30 21:15:25 +10:00
Huon Wilson a890c2cbf1 Convert vec::{rposition, rposition_elem, position_elem, contains} to methods. 2013-06-30 21:15:24 +10:00
Huon Wilson 45940ed988 Remove vec::[r]position_between, replaced by slices & iterators. 2013-06-30 21:06:48 +10:00
Huon Wilson 5d46bcc0e4 Remove vec::{rfind, rfind_between, find_between}, replaced by slices and iterator adapators. 2013-06-30 21:06:47 +10:00
Daniel Micay 350a5c0b72 vec: use contains_managed instead of box header 2013-06-30 03:45:39 -04:00
Daniel Micay 052f28a808 minor vec cleanup
* hide the rustrt module in the docs
* remove the useless `traits` module wrapping the `Add` impl
2013-06-29 17:37:03 -04:00
Alex Crichton b29c368674 Removing a lot of usage of '&const' 2013-06-29 08:35:48 -07:00
Ben Blum ff4ab9e147 'Borrow' stack closures rather than copying them (e.g., "|x|f(x)"), in prep for making them noncopyable. 2013-06-29 04:39:34 -04:00
Michael Sullivan a9e51f5f70 Make default method handling not choke on self region params. Closes #7341. 2013-06-28 16:12:08 -07:00
Patrick Walton f9b54541ee librustc: Disallow "mut" from distributing over bindings.
This is the backwards-incompatible part of per-binding-site "mut".
2013-06-28 10:44:15 -04:00
Huon Wilson 366ca44cc8 std: silence some test warnings. 2013-06-28 01:45:24 +10:00
Huon Wilson 32d655916f Convert vec::{reserve, reserve_at_least, capacity} to methods. 2013-06-28 00:40:47 +10:00
Huon Wilson ae2f185349 Convert vec::{partition, partitioned} to methods. 2013-06-28 00:20:43 +10:00
Huon Wilson 206d4f00dc Convert vec::retain to a method. 2013-06-28 00:20:42 +10:00
Huon Wilson 4470d14388 Convert vec::truncate to a method. 2013-06-28 00:20:42 +10:00
Huon Wilson 29b0649a6a Convert vec::{push, push_all, push_all_move} to methods. 2013-06-28 00:20:42 +10:00
Huon Wilson 1cb0a567d1 Convert vec::{pop, shift, unshift, insert, remove, swap_remove} to methods. 2013-06-28 00:20:42 +10:00
Huon Wilson d2e3e1e52b Convert vec::{head, tail, init, last} (and similar fns) to methods. 2013-06-27 22:37:00 +10:00
Huon Wilson d0512b1055 Convert vec::[mut_]slice to methods, remove vec::const_slice. 2013-06-27 22:36:09 +10:00
Daniel Micay 9f5f609b1c vec: remove superseded reverse_part function
`reverse(xs.mut_slice(a, b))` replaces `reverse_part(xs, a, b)`
2013-06-26 19:42:34 -04:00