about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2014-12-29rollup merge of #20250: ipetkov/derivingAlex Crichton-2/+2
* Both enums already derived `Copy`, but storing them in any struct/container would prevent implementing `Clone` for said struct/container even though they should be clonable. * Also add PartialEq and Eq for good measure.
2014-12-29rollup merge of #20231: fhahn/issue-20226-eexistAlex Crichton-0/+13
I've created a patch for #20226, which maps `EEXIST` to the `PathAlreadyExists` error on Unix. To test this, I use `mkdir`, which raises `EEXIST` if the directory already exists. On Windows, I map `ERROR_ALREADY_EXISTS` to `PathAlreadyExist`, but I am note sure if `mkdir` on Windows raises `ERROR_ALREADY_EXISTS` and do not have a Windows installation handy for testing. And I noticed another thing. No error seems to map to `IoErrorKind::PathDoesntExist` and I am wondering what the difference to `FileNotFound` is?
2014-12-29rollup merge of #20160: nick29581/ranges2Alex Crichton-16/+16
The first six commits are from an earlier PR (#19858) and have already been reviewed. This PR makes an awful hack in the compiler to accommodate slices both natively and in the index a range form. After a snapshot we can hopefully add the new Index impls and then we can remove these awful hacks. r? @nikomatsakis (or anyone who knows the compiler, really)
2014-12-29rollup merge of #20042: alexcrichton/second-pass-ptrAlex Crichton-2/+2
This commit performs a second pass for stabilization over the `std::ptr` module. The specific actions taken were: * The `RawPtr` trait was renamed to `PtrExt` * The `RawMutPtr` trait was renamed to `PtrMutExt` * The module name `ptr` is now stable. * These functions were all marked `#[stable]` with no modification: * `null` * `null_mut` * `swap` * `replace` * `read` * `write` * `PtrExt::is_null` * `PtrExt::is_not_null` * `PtrExt::offset` * These functions remain unstable: * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive as null isn't the only bad value, and it's unclear whether we want to commit to these functions at this time. The reference/lifetime semantics as written are also problematic in how they encourage arbitrary lifetimes. * `zero_memory` - This function is currently not used at all in the distribution, and in general it plays a broader role in the "working with unsafe pointers" story. This story is not yet fully developed, so at this time the function remains unstable for now. * `read_and_zero` - This function remains unstable for largely the same reasons as `zero_memory`. * These functions are now all deprecated: * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead. * `PtrExt::to_uint` - use an `as` expression instead.
2014-12-30Fallout from mut slicesNick Cameron-16/+16
2014-12-29std: Second pass stabilization for `ptr`Alex Crichton-2/+2
This commit performs a second pass for stabilization over the `std::ptr` module. The specific actions taken were: * The `RawPtr` trait was renamed to `PtrExt` * The `RawMutPtr` trait was renamed to `MutPtrExt` * The module name `ptr` is now stable. * These functions were all marked `#[stable]` with no modification: * `null` * `null_mut` * `swap` * `replace` * `read` * `write` * `PtrExt::is_null` * `PtrExt::offset` * These functions remain unstable: * `as_ref`, `as_mut` - the return value of an `Option` is not fully expressive as null isn't the only bad value, and it's unclear whether we want to commit to these functions at this time. The reference/lifetime semantics as written are also problematic in how they encourage arbitrary lifetimes. * `zero_memory` - This function is currently not used at all in the distribution, and in general it plays a broader role in the "working with unsafe pointers" story. This story is not yet fully developed, so at this time the function remains unstable for now. * `read_and_zero` - This function remains unstable for largely the same reasons as `zero_memory`. * These functions are now all deprecated: * `PtrExt::null` - call `ptr::null` or `ptr::null_mut` instead. * `PtrExt::to_uint` - use an `as` expression instead. * `PtrExt::is_not_null` - use `!p.is_null()` instead.
2014-12-29std: Second pass stabilization for `comm`Alex Crichton-218/+235
This commit is a second pass stabilization for the `std::comm` module, performing the following actions: * The entire `std::comm` module was moved under `std::sync::mpsc`. This movement reflects that channels are just yet another synchronization primitive, and they don't necessarily deserve a special place outside of the other concurrency primitives that the standard library offers. * The `send` and `recv` methods have all been removed. * The `send_opt` and `recv_opt` methods have been renamed to `send` and `recv`. This means that all send/receive operations return a `Result` now indicating whether the operation was successful or not. * The error type of `send` is now a `SendError` to implement a custom error message and allow for `unwrap()`. The error type contains an `into_inner` method to extract the value. * The error type of `recv` is now `RecvError` for the same reasons as `send`. * The `TryRecvError` and `TrySendError` types have had public reexports removed of their variants and the variant names have been tweaked with enum namespacing rules. * The `Messages` iterator is renamed to `Iter` This functionality is now all `#[stable]`: * `Sender` * `SyncSender` * `Receiver` * `std::sync::mpsc` * `channel` * `sync_channel` * `Iter` * `Sender::send` * `Sender::clone` * `SyncSender::send` * `SyncSender::try_send` * `SyncSender::clone` * `Receiver::recv` * `Receiver::try_recv` * `Receiver::iter` * `SendError` * `RecvError` * `TrySendError::{mod, Full, Disconnected}` * `TryRecvError::{mod, Empty, Disconnected}` * `SendError::into_inner` * `TrySendError::into_inner` This is a breaking change due to the modification of where this module is located, as well as the changing of the semantics of `send` and `recv`. Most programs just need to rename imports of `std::comm` to `std::sync::mpsc` and add calls to `unwrap` after a send or a receive operation. [breaking-change]
2014-12-29std: Return Result from RWLock/Mutex methodsAlex Crichton-10/+10
All of the current std::sync primitives have poisoning enable which means that when a task fails inside of a write-access lock then all future attempts to acquire the lock will fail. This strategy ensures that stale data whose invariants are possibly not upheld are never viewed by other tasks to help propagate unexpected panics (bugs in a program) among tasks. Currently there is no way to test whether a mutex or rwlock is poisoned. One method would be to duplicate all the methods with a sister foo_catch function, for example. This pattern is, however, against our [error guidelines][errors]. As a result, this commit exposes the fact that a task has failed internally through the return value of a `Result`. [errors]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md#do-not-provide-both-result-and-fail-variants All methods now return a `LockResult<T>` or a `TryLockResult<T>` which communicates whether the lock was poisoned or not. In a `LockResult`, both the `Ok` and `Err` variants contains the `MutexGuard<T>` that is being returned in order to allow access to the data if poisoning is not desired. This also means that the lock is *always* held upon returning from `.lock()`. A new type, `PoisonError`, was added with one method `into_guard` which can consume the assertion that a lock is poisoned to gain access to the underlying data. This is a breaking change because the signatures of these methods have changed, often incompatible ways. One major difference is that the `wait` methods on a condition variable now consume the guard and return it in as a `LockResult` to indicate whether the lock was poisoned while waiting. Most code can be updated by calling `.unwrap()` on the return value of `.lock()`. [breaking-change]
2014-12-29std: Stabilize the prelude moduleAlex Crichton-166/+188
This commit is an implementation of [RFC 503][rfc] which is a stabilization story for the prelude. Most of the RFC was directly applied, removing reexports. Some reexports are kept around, however: * `range` remains until range syntax has landed to reduce churn. * `Path` and `GenericPath` remain until path reform lands. This is done to prevent many imports of `GenericPath` which will soon be removed. * All `io` traits remain until I/O reform lands so imports can be rewritten all at once to `std::io::prelude::*`. This is a breaking change because many prelude reexports have been removed, and the RFC can be consulted for the exact list of removed reexports, as well as to find the locations of where to import them. [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md [breaking-change] Closes #20068
2014-12-29Fallout from globs/re-export/shadowing changeNick Cameron-12/+17
2014-12-28Added `get_address_name`, an interface to `getnameinfo`Murarth-2/+9
2014-12-27Fallout of changing format_args!(f, args) to f(format_args!(args)).Eduard Burtescu-0/+62
2014-12-27auto merge of #20119 : FlaPer87/rust/oibit-send-and-friends, r=nikomatsakisbors-15/+32
More work on opt-in built in traits. `Send` and `Sync` are not opt-in, `OwnedPtr` renamed to `UniquePtr` and the `Send` and `Sync` traits are now unsafe. NOTE: This likely needs to be rebased on top of the yet-to-land snapshot. r? @nikomatsakis cc #13231
2014-12-27Fix falloutNick Cameron-5/+5
2014-12-26Derive Clone, PartialEq, and Eq for std::io::{FileAccess, FileMode}Ivan Petkov-2/+2
* Both enums already derived `Copy`, but storing them in any struct/container would prevent implementing `Clone` for said struct/container even though they should be clonable. * Also add PartialEq and Eq for good measure.
2014-12-26Implement RaceBox for StdinReaderFlavio Percoco-15/+32
2014-12-25Map EEXIST to PathAlreadyExists error, closes #20226Florian Hahn-0/+13
2014-12-25Parse fully-qualified associated types in generics without whitespaceP1start-2/+2
This breaks code that looks like this: let x = foo as bar << 13; Change such code to look like this: let x = (foo as bar) << 13; Closes #17362. [breaking-change]
2014-12-23Fix some spelling errors.Huon Wilson-5/+5
2014-12-21Fallout of std::str stabilizationAlex Crichton-7/+8
2014-12-21rollup merge of #20077: shepmaster/stdin-typoAlex Crichton-1/+1
2014-12-21rollup merge of #20070: aturon/stab-2-cloneAlex Crichton-0/+1
This patch marks `clone` stable, as well as the `Clone` trait, but leaves `clone_from` unstable. The latter will be decided by the beta. The patch also marks most manual implementations of `Clone` as stable, except where the APIs are otherwise deprecated or where there is uncertainty about providing `Clone`. r? @alexcrichton
2014-12-21rollup merge of #19932: elszben/masterAlex Crichton-0/+50
First attempt to contribute to rust (and using github). This commit adds a few examples to std::io::TempDir. The examples seem to look okay (in my browser) and make check also passes.
2014-12-20Correct typo in doc for StdinReaderGuardJake Goulding-1/+1
2014-12-20Stabilize cloneAaron Turon-0/+1
This patch marks `clone` stable, as well as the `Clone` trait, but leaves `clone_from` unstable. The latter will be decided by the beta. The patch also marks most manual implementations of `Clone` as stable, except where the APIs are otherwise deprecated or where there is uncertainty about providing `Clone`.
2014-12-20Fix fallout of removing import_shadowing in tests.Eduard Burtescu-11/+5
2014-12-19libstd: use `#[deriving(Copy)]`Jorge Aparicio-49/+19
2014-12-18Delete rest of rustrtAaron Turon-0/+1
... and address other rebasing fallout.
2014-12-18Revise std::thread API to join by defaultAaron Turon-16/+16
This commit is part of a series that introduces a `std::thread` API to replace `std::task`. In the new API, `spawn` returns a `JoinGuard`, which by default will join the spawned thread when dropped. It can also be used to join explicitly at any time, returning the thread's result. Alternatively, the spawned thread can be explicitly detached (so no join takes place). As part of this change, Rust processes now terminate when the main thread exits, even if other detached threads are still running, moving Rust closer to standard threading models. This new behavior may break code that was relying on the previously implicit join-all. In addition to the above, the new thread API also offers some built-in support for building blocking abstractions in user space; see the module doc for details. Closes #18000 [breaking-change]
2014-12-18Fix the capture_stderr testAlex Crichton-4/+3
There's always a fun time having two sets of standard libraries when testing!
2014-12-18Disable capture_stderr test for nowAaron Turon-1/+1
2014-12-18Fallout from new thread APIAaron Turon-32/+28
2014-12-18libs: merge librustrt into libstdAaron Turon-4/+3
This commit merges the `rustrt` crate into `std`, undoing part of the facade. This merger continues the paring down of the runtime system. Code relying on the public API of `rustrt` will break; some of this API is now available through `std::rt`, but is likely to change and/or be removed very soon. [breaking-change]
2014-12-18librustc: Always parse `macro!()`/`macro![]` as expressions if notPatrick Walton-11/+13
followed by a semicolon. This allows code like `vec![1i, 2, 3].len();` to work. This breaks code that uses macros as statements without putting semicolons after them, such as: fn main() { ... assert!(a == b) assert!(c == d) println(...); } It also breaks code that uses macros as items without semicolons: local_data_key!(foo) fn main() { println("hello world") } Add semicolons to fix this code. Those two examples can be fixed as follows: fn main() { ... assert!(a == b); assert!(c == d); println(...); } local_data_key!(foo); fn main() { println("hello world") } RFC #378. Closes #18635. [breaking-change]
2014-12-17rollup merge of #19902: alexcrichton/second-pass-memAlex Crichton-0/+2
This commit stabilizes the `mem` and `default` modules of std.
2014-12-17rollup merge of #19873: drewm1980/masterAlex Crichton-5/+5
In US english, "that" is used in restrictive clauses in place of "which", and often affects the meaning of sentences. In UK english and many dialects, no distinction is made. While Rust devs want to avoid unproductive pedanticism, it is worth at least being uniform in documentation such as: http://doc.rust-lang.org/std/iter/index.html and also in cases where correct usage of US english clarifies the sentence.
2014-12-17rollup merge of #19869: sfackler/free-stdinAlex Crichton-0/+7
r? @aturon
2014-12-17rollup merge of #19859: alexcrichton/flaky-testAlex Crichton-1/+2
This test would read with a timeout and then send a UDP message, expecting the message to be received. The receiving port, however, was bound in the child thread so it could be the case that the timeout and send happens before the child thread runs. To remedy this we just bind the port before the child thread runs, moving it into the child later on. cc #19120
2014-12-17Replaced wrapper functions with no_run and as_str().unwrap() with display()elszben-6/+3
2014-12-16Added example to TempDirelszben-0/+53
2014-12-16auto merge of #19777 : nikomatsakis/rust/warn-on-shadowing, r=acrichtobors-5/+5
per rfc 459 cc https://github.com/rust-lang/rust/issues/19390 One question is: should we start by warning, and only switch to hard error later? I think we discussed something like this in the meeting. r? @alexcrichton
2014-12-15std: Second pass stabilization of `default`Alex Crichton-0/+2
This commit performs a second pass stabilization of the `std::default` module. The module was already marked `#[stable]`, and the inheritance of `#[stable]` was removed since this attribute was applied. This commit adds the `#[stable]` attribute to the trait definition and one method name, along with all implementations found in the standard distribution.
2014-12-16auto merge of #19747 : alexcrichton/rust/slice-one-trait, r=brsonbors-9/+9
This commit collapses the various prelude traits for slices into just one trait: * SlicePrelude/SliceAllocPrelude => SliceExt * CloneSlicePrelude/CloneSliceAllocPrelude => CloneSliceExt * OrdSlicePrelude/OrdSliceAllocPrelude => OrdSliceExt * PartialEqSlicePrelude => PartialEqSliceExt
2014-12-15Remove all shadowed lifetimes.Niko Matsakis-5/+5
2014-12-15rollup merge of #19710: steveklabnik/gh15449Brian Anderson-4/+4
Fixes #15499.
2014-12-15Standardize some usages of "which" in docstringsAndrew Wagner-5/+5
In US english, "that" is used in restrictive clauses in place of "which", and often affects the meaning of sentences. In UK english and many dialects, no distinction is made. While Rust devs want to avoid unproductive pedanticism, it is worth at least being uniform in documentation such as: http://doc.rust-lang.org/std/iter/index.html and also in cases where correct usage of US english clarifies the sentence.
2014-12-14Free stdin on exitSteven Fackler-0/+7
2014-12-14std: Collapse SlicePrelude traitsAlex Crichton-9/+9
This commit collapses the various prelude traits for slices into just one trait: * SlicePrelude/SliceAllocPrelude => SliceExt * CloneSlicePrelude/CloneSliceAllocPrelude => CloneSliceExt * OrdSlicePrelude/OrdSliceAllocPrelude => OrdSliceExt * PartialEqSlicePrelude => PartialEqSliceExt
2014-12-14std: Bind port early to make a test more reliableAlex Crichton-1/+2
This test would read with a timeout and then send a UDP message, expecting the message to be received. The receiving port, however, was bound in the child thread so it could be the case that the timeout and send happens before the child thread runs. To remedy this we just bind the port before the child thread runs, moving it into the child later on. cc #19120
2014-12-15auto merge of #19742 : vhbit/rust/copy-for-bitflags, r=alexcrichtonbors-1/+0