about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-04-03auto merge of #13286 : alexcrichton/rust/release, r=brsonbors-1/+1
Merging the 0.10 release into the master branch.
2014-04-02Fix fallout of requiring uint indicesAlex Crichton-24/+26
2014-04-02rand: remove (almost) all ~[]'s from Vec.Huon Wilson-15/+17
There are a few instances of them in tests which are using functions from std etc. that still are using ~[].
2014-04-02auto merge of #13243 : huonw/rust/cellshow, r=thestingerbors-2/+13
std: fix Cell's Show instance. Previously it was printing the address of the Unsafe contained in the Cell (i.e. the address of the Cell itself). This is clearly useless, and was presumably a mistake due to writing `*&` instead of `&*`. However, this later expression is likely also incorrect, since it takes a reference into a Cell while other user code is executing (i.e. the Show instance for the contained type), hence the contents should just be copied out.
2014-04-01auto merge of #13241 : stepancheg/rust/push-all, r=alexcrichtonbors-7/+3
* push_all* operations should reserve capacity before pushing data to avoid unnecessary reallocations * reserve_exact should never shrink, as specified in documentation
2014-04-01auto merge of #13225 : thestinger/rust/num, r=cmrbors-278/+126
The `Float` trait methods will be usable as functions via UFCS, and we came to a consensus to remove duplicate functions like this a long time ago. It does still make sense to keep the duplicate functions when the trait methods are static, unless the decision to leave out the in-scope trait name resolution for static methods changes.
2014-04-01Reimplement Vec::push_all* with .extendStepan Koltsov-6/+2
It is shorter and also fixes missed reserve call.
2014-04-01Vec::reserve_exact should not shrinkStepan Koltsov-1/+1
reserve_exact should not shrink according to documentation.
2014-04-01auto merge of #13115 : huonw/rust/rand-errors, r=alexcrichtonbors-34/+122
move errno -> IoError converter into std, bubble up OSRng errors Also adds a general errno -> `~str` converter to `std::os`, and makes the failure messages for the things using `OSRng` (e.g. (transitively) the task-local RNG, meaning hashmap initialisation failures aren't such a black box).
2014-04-01std: fix Cell's Show instance.Huon Wilson-2/+13
Previously it was printing the address of the Unsafe contained in the Cell (i.e. the address of the Cell itself). This is clearly useless, and was presumably a mistake due to writing `*&` instead of `&*`. However, this later expression is likely also incorrect, since it takes a reference into a Cell while other user code is executing (i.e. the Show instance for the contained type), hence the contents should just be copied out.
2014-04-01remove the cmath moduleDaniel Micay-205/+126
This is an implementation detail of the `f32` and `f64` modules and it should not be public. It renames many functions and leaves out any provided by LLVM intrinsics, so it is not a sensible binding to the C standard library's math library and will never be a stable target. This also removes the abuse of link_name so that this can be switched to using automatically generated definitions in the future. This also removes the `scalbn` binding as it is equivalent to `ldexp` when `FLT_RADIX` is 2, which must always be true for Rust.
2014-04-01rand: bubble up IO messages futher.Huon Wilson-23/+23
The various ...Rng::new() methods can hit IO errors from the OSRng they use, and it seems sensible to expose them at a higher level. Unfortunately, writing e.g. `StdRng::new().unwrap()` gives a much poorer error message than if it failed internally, but this is a problem with all `IoResult`s.
2014-04-01std: migrate the errno -> IoError converter from libnative.Huon Wilson-11/+99
This also adds a direct `errno` -> `~str` converter, rather than only being possible to get a string for the very last error.
2014-03-31std: Switch field privacy as necessaryAlex Crichton-893/+889
2014-03-31num: rm wrapping of `Float` methods as functionsDaniel Micay-73/+0
The `Float` trait methods will be usable as functions via UFCS, and we came to a consensus to remove duplicate functions like this a long time ago. It does still make sense to keep the duplicate functions when the trait methods are static, unless the decision to leave out the in-scope trait name resolution for static methods changes.
2014-03-31Bump version to 0.10Alex Crichton-1/+1
2014-03-31auto merge of #13221 : thestinger/rust/append, r=alexcrichtonbors-32/+32
These were only free functions on `~[T]` because taking self by-value used to be broken.
2014-03-31vec: convert `append` and `append_one` to methodsDaniel Micay-32/+32
These were only free functions on `~[T]` because taking self by-value used to be broken.
2014-03-30Rename `from_iterator` to `from_iter` for consistency.Brian Anderson-8/+8
2014-03-30Removed deprecated functions `map` and `flat_map` for vectors and slices.Marvin Löbel-91/+6
2014-03-29auto merge of #13183 : erickt/rust/remove-list, r=alexcrichtonbors-3/+3
`collections::list::List` was decided in a [team meeting](https://github.com/mozilla/rust/wiki/Meeting-weekly-2014-03-25) that it was unnecessary, so this PR removes it. Additionally, it removes an old and redundant purity test and fixes some warnings.
2014-03-29auto merge of #13188 : FlaPer87/rust/master, r=alexcrichtonbors-27/+0
2014-03-29Register new snapshotFlavio Percoco-27/+0
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-83/+83
Closes #2569
2014-03-28syntax: Accept meta matchers in macrosAlex Crichton-6/+6
This removes the `attr` matcher and adds a `meta` matcher. The previous `attr` matcher is now ambiguous because it doesn't disambiguate whether it means inner attribute or outer attribute. The new behavior can still be achieved by taking an argument of the form `#[$foo:meta]` (the brackets are part of the macro pattern). Closes #13067
2014-03-28auto merge of #13158 : alexcrichton/rust/issue-13123, r=brsonbors-0/+30
Some unix platforms will send a SIGPIPE signal instead of returning EPIPE from a syscall by default. The native runtime doesn't install a SIGPIPE handler, causing the program to die immediately in this case. This brings the behavior in line with libgreen by ignoring SIGPIPE and propagating EPIPE upwards to the application in the form of an IoError. Closes #13123
2014-03-28native: Ignore SIGPIPE by defaultAlex Crichton-0/+30
Some unix platforms will send a SIGPIPE signal instead of returning EPIPE from a syscall by default. The native runtime doesn't install a SIGPIPE handler, causing the program to die immediately in this case. This brings the behavior in line with libgreen by ignoring SIGPIPE and propagating EPIPE upwards to the application in the form of an IoError. Closes #13123
2014-03-28native: Use WNOHANG before signalingAlex Crichton-3/+32
It turns out that on linux, and possibly other platforms, child processes will continue to accept signals until they have been *reaped*. This means that once the child has exited, it will succeed to receive signals until waitpid() has been invoked on it. This is unfortunate behavior, and differs from what is seen on OSX and windows. This commit changes the behavior of Process::signal() to be the same across platforms, and updates the documentation of Process::kill() to note that when signaling a foreign process it may accept signals until reaped. Implementation-wise, this invokes waitpid() with WNOHANG before each signal to the child to ensure that if the child has exited that we will reap it. Other possibilities include installing a SIGCHLD signal handler, but at this time I believe that that's too complicated. Closes #13124
2014-03-28std and green: fix some warningsErick Tryzelaar-3/+3
2014-03-28auto merge of #13160 : FlaPer87/rust/rename-pod, r=thestingerbors-33/+48
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 r? @nikomatsakis
2014-03-28auto merge of #13154 : tomassedovic/rust/patch-1, r=alexcrichtonbors-1/+1
HashMap and HashSet require keys to implement TotalEq. This makes it possible to use TypeId as a HashMap key again. Question for reviewers: assuming we want to support `HashMap<TypeId, whatever>`, would it make sense to add a relevant test? If so, should it go to libcollections or libstd?
2014-03-28Rename Pod into CopyFlavio Percoco-33/+48
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-27Fix fallout of removing default boundsAlex Crichton-167/+177
This is all purely fallout of getting the previous commit to compile.
2014-03-26auto merge of #13135 : alexcrichton/rust/dox, r=alexcrichtonbors-114/+713
I touched up the documentation from @pcwalton found in #12952.
2014-03-26Derive TotalEq for std::intrinsics::TypeIdTomas Sedovic-1/+1
HashMap and HashSet require keys to implement TotalEq. This makes it possible to use TypeId as a HashMap key again.
2014-03-26auto merge of #13134 : alexcrichton/rust/freebsd-libm, r=thestingerbors-0/+1
Apparently we had forgotten to do this for freebsd, causing possible problems on FreeBSD 10. The discussion in #12324 has some more details about how it's missing.
2014-03-26auto merge of #13117 : alexcrichton/rust/no-crate-map, r=brsonbors-108/+1
This can be done now that logging has been moved out and libnative is the default (not libgreen)
2014-03-25auto merge of #13039 : Kimundi/rust/iter_by_value_extend, r=alexcrichtonbors-24/+24
# Summary Changed `iter::Extendable` and `iter::FromIterator` to take a `Iterator` by value. These functions always exhaust the passed `Iterator`, and are often used for transferring the values of a new `Iterator` directly into a data structure, so using them usually require the use of the `&mut` operator: ``` foo.extend(&mut bar.move_iter()); // Transfer content from bar into foo let mut iter = ...; foo.extend(&mut iter); // iter is now empty ``` This patch changes both the `FromIterator` and `Extendable` traits to take the iterator by value instead, which makes the common case of using these traits less heavy: ``` foo.extend(bar.move_iter()); // Transfer content from bar into foo let iter = ...; foo.extend(iter); // iter is now inaccessible if it moved // or unchanged if it was Pod and copied. ``` # Composability This technically makes the traits less flexible from a type system pov, because they now require ownership. However, because `Iterator` provides the `ByRef` adapter, there is no loss of functionality: ``` foo.extend(iter.by_ref()); // Same semantic as today, for the few situations where you need it. ``` # Motivation This change makes it less painful to use iterators for shuffling values around between collections, which makes it more acceptable to always use them for this, enabling more flexibility. For example, `foo.extend(bar.move_iter())` can generally be the fastest way to append an collections content to another one, without both needing to have the same type. Making this easy to use would allow the removal of special cased methods like `push_all()` on vectors. (See https://github.com/mozilla/rust/issues/12456) I opened https://github.com/mozilla/rust/issues/13038 as well, to discuss this change in general if people object to it. # Further work This didn't change the `collect()` method to take by value `self`, nor any of the other adapters that also exhaust their iterator argument. For consistency this should probably happen in the long term, but for now this is too much trouble, as every use of them would need to be checked for accidentally changed semantic by going `&mut self -> self`. (which allows for the possibility that a `Pod` iterator got copied instead of exhausted without generating a type error by the change)
2014-03-25Changed `iter::Extendable` and `iter::FromIterator` to take a `Iterator` by ↵Marvin Löbel-24/+24
value
2014-03-25auto merge of #13070 : huonw/rust/share-doc, r=alexcrichtonbors-1/+45
std: expand the `Share` docs to make them more precise. And give some examples about exactly what's `Share` and what's not.
2014-03-25std: Touch various I/O documentation blocksAlex Crichton-17/+39
These are mostly touchups from the previous commit.
2014-03-25libstd: Document the following modules:Patrick Walton-112/+689
* native::io * std::char * std::fmt * std::fmt::parse * std::io * std::io::extensions * std::io::net::ip * std::io::net::udp * std::io::net::unix * std::io::pipe * std::num * std::num::f32 * std::num::f64 * std::num::strconv * std::os
2014-03-25std: Explicitly link to libm for freebsdAlex Crichton-0/+1
Apparently we had forgotten to do this for freebsd, causing possible problems on FreeBSD 10. The discussion in #12324 has some more details about how it's missing.
2014-03-26std: expand the `Share` docs to make them more precise.Huon Wilson-1/+45
And give some examples about exactly what's `Share` and what's not.
2014-03-24comm: Implement synchronous channelsAlex Crichton-16/+1227
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-24auto merge of #12900 : alexcrichton/rust/rewrite-sync, r=brsonbors-55/+61
* Remove clone-ability from all primitives. All shared state will now come from the usage of the primitives being shared, not the primitives being inherently shareable. This allows for fewer allocations for stack-allocated primitives. * Add `Mutex<T>` and `RWLock<T>` which are stack-allocated primitives for purely wrapping a piece of data * Remove `RWArc<T>` in favor of `Arc<RWLock<T>>` * Remove `MutexArc<T>` in favor of `Arc<Mutex<T>>` * Shuffle around where things are located * The `arc` module now only contains `Arc` * A new `lock` module contains `Mutex`, `RWLock`, and `Barrier` * A new `raw` module contains the primitive implementations of `Semaphore`, `Mutex`, and `RWLock` * The Deref/DerefMut trait was implemented where appropriate * `CowArc` was removed, the functionality is now part of `Arc` and is tagged with `#[experimental]`. * The crate now has #[deny(missing_doc)] * `Arc` now supports weak pointers This is not a large-scale rewrite of the functionality contained within the `sync` crate, but rather a shuffling of who does what an a thinner hierarchy of ownership to allow for better composability.
2014-03-24std: Unignore atomic testsBrian Anderson-4/+2
2014-03-24auto merge of #13049 : alexcrichton/rust/io-fill, r=huonwbors-7/+38
This method can be used to fill a byte slice of data entirely, and it's considered an error if any error happens before its entirely filled.
2014-03-24rustc: Remove all crate map supportAlex Crichton-107/+0
The crate map is no longer necessary now that logging and event loop factories have been moved out. Closes #11617 Closes #11731
2014-03-24green: Remove the dependence on the crate mapAlex Crichton-1/+1
This is the final nail in the coffin for the crate map. The `start` function for libgreen now has a new added parameter which is the event loop factory instead of inferring it from the crate map. The two current valid values for this parameter are `green::basic::event_loop` and `rustuv::event_loop`.