summary refs log tree commit diff
path: root/src/libstd/prelude.rs
AgeCommit message (Collapse)AuthorLines
2014-01-03Remove std::eitherAlex Crichton-1/+0
2013-12-29auto merge of #11134 : lucab/rust/lucab/libstd-doc, r=cmrbors-0/+2
Uniform the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index.
2013-12-27Renamed ClonableIterator to CloneableIteratorAlexandros Tasos-1/+1
2013-12-27std: uniform modules titles for docLuca Bruno-0/+2
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-22std::vec: make the sorting closure use `Ordering` rather than just beingHuon Wilson-1/+2
(implicitly) less_eq.
2013-12-21std::vec: add a sugary .sort() method for plain Ord sorting.Huon Wilson-1/+1
This moves the custom sorting to `.sort_by`.
2013-12-18Register new snapshotsAlex Crichton-5/+1
Time for a visit from the snapshot fairy!
2013-12-17auto merge of #10967 : chris-morgan/rust/clean-and-tidy-some-traits, ↵bors-2/+2
r=alexcrichton ### Remove {As,Into,To}{Option,Either,Result} traits. Expanded, that is: - `AsOption` - `IntoOption` - `ToOption` - `AsEither` - `IntoEither` - `ToEither` - `AsResult` - `IntoResult` - `ToResult` These were defined for each other but never *used* anywhere. They are all trivial and so removal will have negligible effect upon anyone. `Either` has fallen out of favour (and its implementation of these traits of dubious semantics), `Option<T>` → `Result<T, ()>` was never really useful and `Result<T, E>` → `Option<T>` should now be done with `Result.ok()` (mirrored with `Result.err()` for even more usefulness). In summary, there's really no point in any of these remaining. ### Rename To{Str,Bytes}Consume traits to Into*. That is: - `ToStrConsume` → `IntoStr`; - `ToBytesConsume` → `IntoBytes`.
2013-12-17auto merge of #10830 : alexcrichton/rust/spsc-queue, r=brsonbors-1/+1
This pull request completely rewrites std::comm and all associated users. Some major bullet points * Everything now works natively * oneshots have been removed * shared ports have been removed * try_recv no longer blocks (recv_opt blocks) * constructors are now Chan::new and SharedChan::new * failure is propagated on send * stream channels are 3x faster I have acquired the following measurements on this patch. I compared against Go, but remember that Go's channels are fundamentally different than ours in that sends are by-default blocking. This means that it's not really a totally fair comparison, but it's good to see ballpark numbers for anyway ``` oneshot stream shared1 std 2.111 3.073 1.730 my 6.639 1.037 1.238 native 5.748 1.017 1.250 go8 1.774 3.575 2.948 go8-inf slow 0.837 1.376 go8-128 4.832 1.430 1.504 go1 1.528 1.439 1.251 go2 1.753 3.845 3.166 ``` I had three benchmarks: * oneshot - N times, create a "oneshot channel", send on it, then receive on it (no task spawning) * stream - N times, send from one task to another task, wait for both to complete * shared1 - create N threads, each of which sends M times, and a port receives N*M times. The rows are as follows: * `std` - the current libstd implementation (before this pull request) * `my` - this pull request's implementation (in M:N mode) * `native` - this pull request's implementation (in 1:1 mode) * `goN` - go's implementation with GOMAXPROCS=N. The only relevant value is 8 (I had 8 cores on this machine) * `goN-X` - go's implementation where the channels in question were created with buffers of size `X` to behave more similarly to rust's channels.
2013-12-16librustc: Implement a `Pod` kind for types that can be `memcpy`'d.Patrick Walton-0/+3
This will be used for the new `Cell`.
2013-12-16Fallout of rewriting std::commAlex Crichton-1/+1
2013-12-15Rename To{Str,Bytes}Consume traits to Into*.Chris Morgan-2/+2
That is: - `ToStrConsume` → `IntoStr`; - `ToBytesConsume` → `IntoBytes`.
2013-12-03Move std::util::ignore to std::prelude::dropSteven Fackler-0/+4
It's a more fitting name for the most common use case of this function.
2013-11-13Introduce an io::Buffer traitAlex Crichton-1/+1
This trait is meant to abstract whether a reader is actually implemented with an underlying buffer. For all readers which are implemented as such, we can efficiently implement things like read_char, read_line, read_until, etc. There are two required methods for managing the internal buffer, and otherwise read_line and friends can all become default methods. Closes #10334
2013-11-11Move std::rt::io to std::ioAlex Crichton-2/+2
2013-11-03Move rt::io traits into the preludeAlex Crichton-0/+1
These traits belong here, and were simply waiting for the std::io traits to get removed. It's time they take their rightful positions!
2013-10-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-0/+2
Some code cleanup, sorting of import blocks Removed std::unstable::UnsafeArc's use of Either Added run-fail tests for the new FailWithCause impls Changed future_result and try to return Result<(), ~Any>. - Internally, there is an enum of possible fail messages passend around. - In case of linked failure or a string message, the ~Any gets lazyly allocated in future_results recv method. - For that, future result now returns a wrapper around a Port. - Moved and renamed task::TaskResult into rt::task::UnwindResult and made it an internal enum. - Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`.
2013-10-24Remove std::io once and for all!Alex Crichton-1/+0
2013-10-24Cleaned, documented, wrote tests for up std::boolMarvin Löbel-20/+19
Removed unused import warning in std::mem and cleaned it up too Removed is_true and is_false from std::bool Removed freestanding functions in std::bool
2013-10-15path2: Replace the path module outrightKevin Ballard-4/+1
Remove the old path. Rename path2 to path. Update all clients for the new path. Also make some miscellaneous changes to the Path APIs to help the adoption process.
2013-10-10Implement rt::io::stdioAlex Crichton-1/+1
Additionally, this moves the prelude imports of print/println from std::io to std::rt::io. Closes #6846
2013-10-02std: Replace num::IntConvertible with {To,From}PrimitiveErick Tryzelaar-1/+1
2013-09-25std: Replace CloneableTuple with Tuple, which takes self by-val.Huon Wilson-4/+4
The old behaviour of `foo.n0()` is replaced by `foo.n0_ref().clone()`.
2013-09-16Add an SendStr typeMarvin Löbel-0/+1
A SendStr is a string that can hold either a ~str or a &'static str. This can be useful as an optimization when an allocation is sometimes needed but the common case is statically known. Possible use cases include Maps with both static and owned keys, or propagating error messages across task boundaries. SendStr implements most basic traits in a way that hides the fact that it is an enum; in particular things like order and equality are only determined by the content of the wrapped strings. Replaced std::rt:logging::SendableString with SendStr Added tests for using an SendStr as key in Hash- and Treemaps
2013-09-09rename `std::iterator` to `std::iter`Daniel Micay-4/+4
The trait will keep the `Iterator` naming, but a more concise module name makes using the free functions less verbose. The module will define iterables in addition to iterators, as it deals with iteration in general.
2013-09-05Add a from_str function that calls out to the associated method on the traitCorey Richardson-0/+1
2013-09-01std::iterator: Use ExactSize, inheriting DoubleEndedIteratorblake2-ppc-1/+1
Address discussion with acrichto; inherit DoubleEndedIterator so that `.rposition()` can be a default method, and that the nische of the trait is clear. Use assertions when using `.size_hint()` in reverse enumerate and `.rposition()`
2013-08-30std: Implement .rposition() on double-ended iterators with known sizeblake2-ppc-1/+1
This is a generalization of the vector .rposition() method, to all double-ended iterators that have the ExactSizeHint trait. This resolves the slight asymmetry around `position` and `rposition` * position from front is `vec.iter().position()` * position from the back was, `vec.rposition()` is now `vec.iter().rposition()` Additionally, other indexed sequences (only `extra::ringbuf` I think), will have the same method available once it implements ExactSizeHint.
2013-08-29Remove the iter module.Jason Fager-1/+1
Moves the Times trait to num while the question of whether it should exist at all gets hashed out as a completely separate question.
2013-08-26Add a Default trait.Corey Richardson-0/+1
2013-08-20enable tests for the container tutorialDaniel Micay-3/+3
2013-08-20iterator: add a method for reversing a containerDaniel Micay-2/+2
this works on any container with a mutable double-ended iterator
2013-08-20rm obsolete integer to_str{,_radix} free functionsDaniel Micay-1/+1
2013-08-15tuple: remove obsolete ExtendedTupleOpsDaniel Micay-1/+1
replaced by iterators (generic composable `map` and `zip` adaptors)
2013-08-12auto merge of #8400 : blake2-ppc/rust/seq-ord, r=cmrbors-0/+1
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-11add intrinsics for checked overflow add/sub/mulDaniel Micay-1/+1
2013-08-10std: merge Iterator and IteratorUtilErick Tryzelaar-1/+1
2013-08-10std: merge iterator::DoubleEndedIterator and DoubleEndedIteratorUtilErick Tryzelaar-1/+1
2013-08-08std: Implement traits for the one-tupleblake2-ppc-0/+1
(A,) did not have the trait implementations of 2- to 12- tuples.
2013-08-07Merge remote-tracking branch 'remotes/origin/master' into ↵Erick Tryzelaar-1/+2
remove-str-trailing-nulls
2013-08-06add Extendable to the preludeDaniel Micay-1/+2
2013-08-04std: replace str::as_c_str with std::c_strErick Tryzelaar-0/+1
2013-08-04std: remove str::NullTerminatedStrErick Tryzelaar-1/+1
2013-08-02replace `range` with an external iteratorDaniel Micay-1/+2
2013-07-23std: move StrUtil::as_c_str into StrSliceErick Tryzelaar-1/+1
2013-07-17librustc: Remove all uses of the `Copy` bound.Patrick Walton-1/+1
2013-07-13Split mutable methods out of Set and MapSteven Fackler-1/+1
Fixes most of #4989. I didn't add Persistent{Set,Map} since the only persistent data structure is fun_treemap and its functionality is currently too limited to build a trait out of.
2013-07-12extend the iterator tutorialDaniel Micay-2/+3
documents conversion, size hints and double-ended iterators and adds more of the traits to the prelude
2013-07-04Remove standalone comparison functions in vec, make the trait impls better.Huon Wilson-1/+1
2013-07-03auto merge of #7474 : Seldaek/rust/clean-iter, r=thestingerbors-1/+1
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..