summary refs log tree commit diff
path: root/src/libstd/prelude.rs
AgeCommit message (Collapse)AuthorLines
2014-03-28Rename Pod into CopyFlavio Percoco-1/+1
Summary: So far, we've used the term POD "Plain Old Data" to refer to types that can be safely copied. However, this term is not consistent with the other built-in bounds that use verbs instead. This patch renames the Pod kind into Copy. RFC: 0003-opt-in-builtin-traits Test Plan: make check Reviewers: cmr Differential Revision: http://phabricator.octayn.net/D3
2014-03-24comm: Implement synchronous channelsAlex Crichton-1/+1
This commit contains an implementation of synchronous, bounded channels for Rust. This is an implementation of the proposal made last January [1]. These channels are built on mutexes, and currently focus on a working implementation rather than speed. Receivers for sync channels have select() implemented for them, but there is currently no implementation of select() for sync senders. Rust will continue to provide both synchronous and asynchronous channels as part of the standard distribution, there is no intent to remove asynchronous channels. This flavor of channels is meant to provide an alternative to asynchronous channels because like green tasks, asynchronous channels are not appropriate for all situations. [1] - https://mail.mozilla.org/pipermail/rust-dev/2014-January/007924.html
2014-03-22std: Remove the Freeze kind and the NoFreeze markerFlavio Percoco-1/+1
2014-03-20std: Add Vec to the preludeAlex Crichton-0/+1
This is an incredibly common type, and it is expected to be used in many many places. This type should be in the prelude.
2014-03-20Add a Share kindFlavio Percoco-1/+1
Fixes #11781
2014-03-20rename std::vec -> std::sliceDaniel Micay-4/+4
Closes #12702
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-1/+1
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-03-08Removed DeepClone. Issue #12698.Michael Darakananda-1/+1
2014-03-04auto merge of #12491 : eddyb/rust/deref, r=nikomatsakisbors-1/+1
Add the `Deref` and `DerefMut` traits and implement overloading explicit dereferences.
2014-03-04Cleaned up `std::any`Marvin Löbel-1/+0
- Added `TraitObject` representation to `std::raw`. - Added doc to `std::raw`. - Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()` methods as they are uneccessary now after the removal of headers on owned boxes. This reduces the number of virtual calls needed. - Made the `..Ext` implementations work directly with the repr of a trait object. - Removed `Any`-related traits from the prelude. - Added bench for `Any`
2014-03-04Add the DerefImm and DerefMut traits.Eduard Burtescu-1/+1
2014-02-25Remove std::bool::{Bool, all_values}Brendan Zabarauskas-1/+0
These were never used outside of the tests
2014-02-24Remove std::num::ToStrRadix from the preludeBrendan Zabarauskas-1/+1
2014-02-24Remove std::from_str::FromStr from the preludeBrendan Zabarauskas-1/+0
2014-02-24Remove std::default::Default from the preludeBrendan Zabarauskas-1/+0
2014-02-24Transition to new `Hash`, removing IterBytes and std::to_bytes.Huon Wilson-1/+0
2014-02-21std: rewrite Hash to make it more genericErick Tryzelaar-1/+0
This patch merges IterBytes and Hash traits, which clears up the confusion of using `#[deriving(IterBytes)]` to support hashing. Instead, it now is much easier to use the new `#[deriving(Hash)]` for making a type hashable with a stream hash. Furthermore, it supports custom non-stream-based hashers, such as if a value's hash was cached in a database. This does not yet replace the old IterBytes-hash with this new version.
2014-02-21std: minor whitespace cleanupErick Tryzelaar-1/+1
2014-02-22Move std::num::Integer to libnumBrendan Zabarauskas-1/+1
2014-02-19Update comments in the preludePalmer Cox-11/+2
The comments say that the prelude imports std::io::println since it would be annoying to have to import it in every program that uses it. However, the prelude doesn't actually import that function anymore. So, update the comments to better match reality.
2014-02-17auto merge of #12321 : bjz/rust/remove-real, r=alexcrichtonbors-1/+1
This is part of the effort to simplify `std::num`, as tracked in issue #10387. It is also a step towards a proper IEEE-754 trait (see #12281).
2014-02-17Remove Real trait and move methods into FloatBrendan Zabarauskas-1/+1
This is part of the effort to simplify `std::num`, as tracked in issue #10387.
2014-02-17Remove CloneableTuple and ImmutableTuple traitsBrendan Zabarauskas-1/+0
These are adequately covered by the Tuple2 trait.
2014-02-16Merge ImmutableTuple* traits into their respective Tuple* traitBrendan Zabarauskas-3/+0
2014-02-13Removed num::OrderableMichael Darakananda-1/+1
2014-02-11Rewrite channels yet again for upgradeabilityAlex Crichton-1/+1
This, the Nth rewrite of channels, is not a rewrite of the core logic behind channels, but rather their API usage. In the past, we had the distinction between oneshot, stream, and shared channels, but the most recent rewrite dropped oneshots in favor of streams and shared channels. This distinction of stream vs shared has shown that it's not quite what we'd like either, and this moves the `std::comm` module in the direction of "one channel to rule them all". There now remains only one Chan and one Port. This new channel is actually a hybrid oneshot/stream/shared channel under the hood in order to optimize for the use cases in question. Additionally, this also reduces the cognitive burden of having to choose between a Chan or a SharedChan in an API. My simple benchmarks show no reduction in efficiency over the existing channels today, and a 3x improvement in the oneshot case. I sadly don't have a pre-last-rewrite compiler to test out the old old oneshots, but I would imagine that the performance is comparable, but slightly slower (due to atomic reference counting). This commit also brings the bonus bugfix to channels that the pending queue of messages are all dropped when a Port disappears rather then when both the Port and the Chan disappear.
2014-02-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-4/+1
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-07Delete send_str, rewrite clients on top of MaybeOwned<'static>Kevin Ballard-2/+1
Declare a `type SendStr = MaybeOwned<'static>` to ease readibility of types that needed the old SendStr behavior. Implement all the traits for MaybeOwned that SendStr used to implement.
2014-01-29auto merge of #11672 : bjz/rust/remove-times, r=brsonbors-1/+0
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal (which I liked) was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-30Remove Times traitBrendan Zabarauskas-1/+0
`Times::times` was always a second-class loop because it did not support the `break` and `continue` operations. Its playful appeal was then lost after `do` was disabled for closures. It's time to let this one go.
2014-01-28Rename CopyableTuple to CloneableTupleVirgile Andreani-1/+1
2014-01-28Rename ImmutableCopyableVector to ImmutableCloneableVectorVirgile Andreani-1/+1
2014-01-28Rename OwnedCopyableVector to OwnedCloneableVectorVirgile Andreani-1/+1
2014-01-28Rename CopyableVector to CloneableVectorVirgile Andreani-1/+1
2014-01-16Merge Bitwise and BitCount traits and remove from prelude, along with BoundedBrendan Zabarauskas-2/+1
One less trait in std::num, and three less exported in the prelude.
2014-01-11Remove re-exports of std::io::stdio::{print, println} in the prelude.Brendan Zabarauskas-1/+0
The `print!` and `println!` macros are now the preferred method of printing, and so there is no reason to export the `stdio` functions in the prelude. The functions have also been replaced by their macro counterparts in the tutorial and other documentation so that newcomers don't get confused about what they should be using.
2014-01-09librustc: Implement placement `box` for GC and unique pointers.Patrick Walton-0/+4
2014-01-09auto merge of #11412 : bjz/rust/num-cleanups, r=alexcrichtonbors-3/+1
The methods contained in `std::num::{Algebraic, Trigonometric, Exponential, Hyperbolic}` have now been moved into `std::num::Real`. This is part of an ongoing effort to simplify `std::num` (see issue #10387). `std::num::RealExt` has also been removed from the prelude because it is not a commonly used trait. r? @alexcrichton
2014-01-09Remove ApproxEq and assert_approx_eq!Brendan Zabarauskas-1/+1
This trait seems to stray too far from the mandate of a standard library as implementations may vary between use cases.
2014-01-09Merge some numeric traits with Real and don't re-export RealExtBrendan Zabarauskas-3/+1
The methods contained in `std::num::{Algebraic, Trigonometric, Exponential, Hyperbolic}` have now been moved into `std::num::Real`. This is part of an ongoing effort to simplify `std::num` (see issue #10387). `std::num::RealExt` has also been removed from the prelude because it is not a commonly used trait.
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`.