about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2013-08-15auto merge of #8491 : robertknight/rust/7722-reservoir_sampling, r=graydonbors-0/+56
Fixes #7722 I had a couple of queries: - Should this return an array or an iterator? - Should this be a method on iterators or on the rng? I implemented it in RngUtils as it seemed to belong with shuffle().
2013-08-15auto merge of #8490 : huonw/rust/fromiterator-extendable, r=catamorphismbors-29/+29
If they are on the trait then it is extremely annoying to use them as generic parameters to a function, e.g. with the iterator param on the trait itself, if one was to pass an Extendable<int> to a function that filled it either from a Range or a Map<VecIterator>, one needs to write something like: fn foo<E: Extendable<int, Range<int>> + Extendable<int, Map<&'self int, int, VecIterator<int>>> (e: &mut E, ...) { ... } since using a generic, i.e. `foo<E: Extendable<int, I>, I: Iterator<int>>` means that `foo` takes 2 type parameters, and the caller has to specify them (which doesn't work anyway, as they'll mismatch with the iterators used in `foo` itself). This patch changes it to: fn foo<E: Extendable<int>>(e: &mut E, ...) { ... }
2013-08-15Make CString.iter() publicKevin Ballard-1/+1
2013-08-15Add ToCStr method .with_c_str()Kevin Ballard-53/+76
.with_c_str() is a replacement for the old .as_c_str(), to avoid unnecessary boilerplate. Replace all usages of .to_c_str().with_ref() with .with_c_str().
2013-08-15Check for interior nulls in .to_c_str()Kevin Ballard-12/+107
Previous dicussions about CString suggested that interior nulls should throw an error. This was never implemented. Add this now, using a condition (named null_byte) to allow for recovery. Add method .to_c_str_unchecked() that skips this check.
2013-08-14auto merge of #8481 : cmr/rust/bench/std/at_vec, r=graydonbors-0/+81
2013-08-14Clarify docs on CString.unwrap()Kevin Ballard-0/+1
CString.unwrap() drops ownership of the buffer on the floor. Put this in the docs.
2013-08-15std: Replace map_vec, map_vec2, iter_vec2 in std::resultblake2-ppc-55/+84
Replace these with three functions based on iterators: collect, fold, and fold_. The mapping part is replaced by iterator .map(), so the part that these functions do is to accumulate the final Result<,> value. * `result::collect` gathers `Iterator<Result<V, U>>` to `Result<~[V], U>` * `result::fold` folds `Iterator<Result<T, E>>` to `Result<V, E>` * `result::fold_` folds `Iterator<Result<T, E>>` to `Result<(), E>`
2013-08-15Update either::partitionblake2-ppc-2/+3
Remove the only use of either::partition since it was better accomplished with vector methods. Update either::partition so that it sizes the vectors correctly before it starts.
2013-08-15std: Change either::{lefts, rights} to return an iteratorblake2-ppc-25/+28
2013-08-14std: Change ProcessOptions struct to have an option of a ~ vectorTim Chevalier-10/+10
This is a workaround for #8498
2013-08-14Rewrite Saturating in terms of CheckedAdd/CheckedSubKevin Ballard-38/+25
2013-08-14auto merge of #8452 : Kimundi/rust/stuff02, r=bstriebors-47/+88
- Methodyfied the string ascii extionsion functions - They got added recently, I wrapped them in a trait. - Added `into_owned()` method for vectors - similar to `Str`'s `into_owned()` function, allows to convert to a owned vector without making a copy if the source is a owned vector. - Added `or_some` method to option - similar to `unwrap_or_default`, but keeps the values wrapped in an `Option`. Useful for `Option` chains, eg Iterator impls. - Added `DoubleEndedIterator` impl to `Option` - Just for compatibility with generic Iterator functions. - Renamed nil.rs to unit.rs - the type got renamed ages ago, it's time the source file is as well.
2013-08-15std: Move the iterator param on FromIterator and Extendable to the method.Huon Wilson-29/+29
If they are on the trait then it is extremely annoying to use them as generic parameters to a function, e.g. with the iterator param on the trait itself, if one was to pass an Extendable<int> to a function that filled it either from a Range or a Map<VecIterator>, one needs to write something like: fn foo<E: Extendable<int, Range<int>> + Extendable<int, Map<&'self int, int, VecIterator<int>>> (e: &mut E, ...) { ... } since using a generic, i.e. `foo<E: Extendable<int, I>, I: Iterator<int>>` means that `foo` takes 2 type parameters, and the caller has to specify them (which doesn't work anyway, as they'll mismatch with the iterators used in `foo` itself). This patch changes it to: fn foo<E: Extendable<int>>(e: &mut E, ...) { ... }
2013-08-14Methodyfied the string ascii extionsion functionsMarvin Löbel-47/+88
Added into_owned() method for vectors Added DoubleEnded Iterator impl to Option Renamed nil.rs to unit.rs
2013-08-14auto merge of #8439 : huonw/rust/hashset-clone, r=cmrbors-0/+26
Closes #5581.
2013-08-13auto merge of #8446 : alexcrichton/rust/ifmt++, r=graydonbors-117/+622
This includes a number of improvements to `ifmt!` * Implements formatting arguments -- `{:0.5x}` works now * Formatting now works on all integer widths, not just `int` and `uint` * Added a large doc block to `std::fmt` which should help explain what `ifmt!` is all about * Added floating point formatters, although they have the same pitfalls from before (they're just proof-of-concept now) Closed a couple of issues along the way, yay! Once this gets into a snapshot, I'll start looking into removing all of `fmt`
2013-08-13Add `f` formats to `ifmt!`Alex Crichton-1/+33
Currently the work just the same as the old `extfmt` versions
2013-08-13auto merge of #8475 : kmcallister/rust/stack_segment, r=brson,brsonbors-2/+2
Servo needs to tell SpiderMonkey about the stack bounds. r? @brson
2013-08-13Make rt::stack publicKeegan McAllister-1/+1
Fixes #8478.
2013-08-13auto merge of #8423 : alexcrichton/rust/less-priv-again, r=bstriebors-30/+30
Closes #5495
2013-08-13Add RngUtils::sample() method for reservoir sampling from iteratorsRobert Knight-0/+56
2013-08-13auto merge of #8411 : bblum/rust/assorted-fixes, r=brsonbors-479/+469
Each commit is pretty much what it says on the tin. r anybody.
2013-08-12auto merge of #8487 : brson/rust/local-opts, r=brsonbors-16/+24
I did this once but acciddentally undid it in a later patch.
2013-08-12Forbid pub/priv where it has no effectAlex Crichton-30/+30
Closes #5495
2013-08-12Explain what ifmt! is all aboutAlex Crichton-0/+301
2013-08-12Correct the padding on integer types for formattingAlex Crichton-43/+63
2013-08-12Define integer formats for all widthsAlex Crichton-37/+56
Closes #1653
2013-08-12Implement formatting arguments for strings and integersAlex Crichton-63/+196
Closes #1651
2013-08-12std: Re-optimize tls access on local allocation pathBrian Anderson-16/+24
I did this once but acciddentally undid it in a later patch.
2013-08-12auto merge of #8476 : thestinger/rust/snapshot, r=brsonbors-599/+16
2013-08-12std::at_vec: add benchmarksCorey Richardson-0/+81
2013-08-12auto merge of #8419 : cmr/rust/fix-rtdebug, r=brsonbors-12/+4
It now actually does logging, and is compiled out when `--cfg rtdebug` is not given to the libstd build, which it isn't by default. This makes the rt benchmarks 18-50% faster.
2013-08-12fix build with the new snapshot compilerDaniel Micay-599/+16
2013-08-12rt::task: Make current_stack_segment publicKeegan McAllister-1/+1
Servo needs to tell SpiderMonkey about the stack bounds.
2013-08-12Clean up transitionary glue in task/spawn.rs. Don't hold kill-little-lock ↵Ben Blum-138/+69
for O(n) time, cf #3100, and optimize out several unneeded clone()s.
2013-08-12auto merge of #8400 : blake2-ppc/rust/seq-ord, r=cmrbors-70/+247
Use Eq + Ord for lexicographical ordering of sequences. For each of <, <=, >= or > as R, use:: [x, ..xs] R [y, ..ys] = if x != y { x R y } else { xs R ys } Previous code using `a < b` and then `!(b < a)` for short-circuiting fails on cases such as [1.0, 2.0] < [0.0/0.0, 3.0], where the first element was effectively considered equal. Containers like &[T] did also implement only one comparison operator `<`, and derived the comparison results from this. This isn't correct either for Ord. Implement functions in `std::iterator::order::{lt,le,gt,ge,equal,cmp}` that all iterable containers can use for lexical order. We also visit tuple ordering, having the same problem and same solution (but differing implementation).
2013-08-12Fix select() in light of the deschedule...and then race. Close #8347.Ben Blum-1/+23
2013-08-12Make cell with_ref/with_mut_ref use finally. Close #7975.Ben Blum-8/+8
2013-08-12Reorganise Select traits to not expose internal runtime types. Close #5160. ↵Ben Blum-313/+348
Pending #8215.
2013-08-12Don't use unkillable in UnsafeArc dtor when there's no unwrapper. Close #8382.Ben Blum-19/+21
2013-08-12auto merge of #8428 : blake2-ppc/rust/peekable-iterators, r=thestingerbors-19/+92
Peekable changes by @SimonSapin and original PR is #8396
2013-08-11num: implement CheckedDivDaniel Micay-2/+42
2013-08-11auto merge of #8455 : nikomatsakis/rust/issue-5762-objects-dralston-d, r=graydonbors-1/+47
Fix #5762 and various other aspects of object invocation. r? @graydon
2013-08-11Update type visitor to use &Visitor and not @VisitorNiko Matsakis-0/+28
2013-08-11Add a field `borrow_offset` to the type descriptor indicatingNiko Matsakis-1/+19
what amount a T* pointer must be adjusted to reach the contents of the box. For `~T` types, this requires knowing the type `T`, which is not known in the case of objects.
2013-08-11auto merge of #8412 : thestinger/rust/vector-add, r=alexcrichtonbors-16/+44
2013-08-11fix unused importsDaniel Micay-2/+1
2013-08-11move `strdup_uniq` lang item to std::strDaniel Micay-6/+8
2013-08-11str: optimize `with_capacity`Daniel Micay-3/+21
before: test bench_with_capacity ... bench: 104 ns/iter (+/- 4) after: test bench_with_capacity ... bench: 56 ns/iter (+/- 1)