summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-07-24Rollup merge of #34975 - GuillaumeGomez:random_state_doc, r=steveklabnikManish Goregaokar-0/+19
Add Random state doc Last part of #29348. r? @steveklabnik
2016-07-23Fix HashMap's values_mut example to use println!Robert Williamson-1/+1
2016-07-23Add DirBuilder doc examplesGuillaume Gomez-1/+28
2016-07-22Add Random state docggomez-0/+19
2016-07-22Add HashMap Entry enums examplesggomez-5/+198
2016-07-21Auto merge of #34724 - mitchmindtree:mpsc_receiver_try_recv, r=alexcrichtonbors-0/+56
Add a method to the mpsc::Receiver for producing a non-blocking iterator Currently, the `mpsc::Receiver` offers methods for receiving values in both blocking (`recv`) and non-blocking (`try_recv`) flavours. However only blocking iteration over values is supported. This PR adds a non-blocking iterator to complement the `try_recv` method, just as the blocking iterator complements the `recv` method. Use-case ------------- I predominantly use rust in my work on real-time systems and in particular real-time audio generation/processing. I use `mpsc::channel`s to communicate between threads in a purely non-blocking manner. I.e. I might send messages from the GUI thread to the audio thread to update the state of the dsp-graph, or from the audio thread to the GUI thread to display the RMS of each node. These are just a couple examples (I'm probably using 30+ channels across my various projects). I almost exclusively use the `mpsc::Receiver::try_recv` method to avoid blocking any of the real-time threads and causing unwanted glitching/stuttering. Now that I mention it, I can't think of a single time that I personally have used the `recv` method (though I can of course see why it would be useful, and perhaps the common case for many people). As a result of this experience, I can't help but feel there is a large hole in the `Receiver` API. | blocking | non-blocking | |------------|--------------------| | `recv` | `try_recv` | | `iter` | 🙀 | For the most part, I've been working around this using `while let Ok(v) = r.try_recv() { ... }`, however as nice as this is, it is clearly no match for the Iterator API. As an example, in the majority of my channel use cases I only want to check for *n* number of messages before breaking from the loop so that I don't miss the audio IO callback or hog the GUI thread for too long when an unexpectedly large number of messages are sent. Currently, I have to write something like this: ```rust let mut take = 100; while let Ok(msg) = rx.try_recv() { // Do stuff with msg if take == 0 { break; } take -= 1; } ``` or wrap the `try_recv` call in a `Range<usize>`/`FilterMap` iterator combo. On the other hand, this PR would allow for the following: ```rust for msg in rx.try_iter().take(100) { // Do stuff with msg } ``` I imagine this might also be useful to game devs, embedded or anyone doing message passing across real-time threads.
2016-07-21Fix issue in receiver_try_iter test where response sender would panic ↵mitchmindtree-3/+3
instead of break from the loop
2016-07-21Rollup merge of #34937 - GuillaumeGomez:hash_map_entry_debug, r=apasel422Guillaume Gomez-0/+33
Add debug for hash_map::{Entry, VacantEntry, OccupiedEntry} r? @alexcrichton
2016-07-21Rollup merge of #34895 - mark-buer:patch-1, r=steveklabnikGuillaume Gomez-2/+2
Remove rustdoc reference to `walk_dir`
2016-07-20std: Fix usage of SOCK_CLOEXECAlex Crichton-2/+2
This code path was intended to only get executed on Linux, but unfortunately the `cfg!` was malformed so it actually never got executed.
2016-07-20Fix typo (privledge->privilege)Patrick McCann-1/+1
2016-07-20Auto merge of #34694 - mathphreak:master, r=alexcrichtonbors-0/+121
Add IpAddr common methods Per https://github.com/rust-lang/rfcs/pull/1668#issuecomment-230867962 no RFC is needed here. The generated documentation for these methods is being weird. It shows a deprecation message referencing #27709 for each of them even though two of the referenced methods were stabilized as part of that issue. I don't know how best to address that.
2016-07-20Auto merge of #33526 - steveklabnik:gh21889, r=alexcrichtonbors-0/+38
Add some warnings to std::env::current_exe /cc #21889 @rust-lang/libs @semarie I started writing this up. I'm not sure if we want to go into other things and in what depth; we don't currently have a lot of security-specific documentation to model after. Thoughts?
2016-07-20Add the missing tracking issue field for #34931 to the receiver_try_iter ↵mitchmindtree-3/+3
stability attributes
2016-07-19re-work exampleSteve Klabnik-12/+35
2016-07-19Auto merge of #33974 - habnabit:eintr-retry-for-read-iterators, r=alexcrichtonbors-11/+18
Retry on EINTR in Bytes and Chars. >Since Bytes and Chars called directly into Read::read, they didn't use any of the retrying wrappers. This allows both iterator types to retry.
2016-07-18Remove rustdoc reference to `walk_dir`Mark Buer-2/+2
2016-07-18Add debug for hash_map::{Entry, VacantEntry, OccupiedEntry}ggomez-0/+33
2016-07-16Revert "Refactored code to access TLS only in case of panic"Tim Neumann-11/+9
2016-07-16Merge pull request #34836 from cynicaldevil/panic-counterAlex Crichton-9/+11
Refactored code to access TLS only in case of panic
2016-07-16Refactored code to access TLS only in case of panicNikhil Shagrithaya-9/+11
2016-07-15Rollup merge of #34794 - frewsxcv:exitstatus-success, r=GuillaumeGomezGuillaume Gomez-0/+17
Add doc example for `std::process::ExitStatus::success`. None
2016-07-15Rollup merge of #34777 - glandium:issue34697, r=GuillaumeGomezGuillaume Gomez-1/+3
doc: Mention that writeln! and println! always use LF Fixes #34697 I'm not really satisfied with the wording, but I didn't have a better idea. Suggestions welcome.
2016-07-15Rollup merge of #34456 - tbu-:pr_ptr_null, r=aturonGuillaume Gomez-17/+22
Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`
2016-07-13Auto merge of #34776 - cuviper:solaris-readdir, r=alexcrichtonbors-22/+40
std: fix `readdir` errors for solaris A `NULL` from `readdir` could be the end of stream or an error. The only way to know is to check `errno`, so it must be set to a known value first, like a 0 that POSIX will never use. This currently only matters for solaris targets, as the other unix platforms are using `readdir_r` with a direct error return indication. However, this is getting deprecated (#34668) so they should all eventually switch to `readdir`. This PR adds `set_errno`, uses it to clear the value before calling `readdir`, then checks it again after to see the reason for a `NULL`. A few other small fixes are included just to get solaris compiling at all. I couldn't get cross-compilation completely going, so I don't have a good way to test this beyond a smoke-test cargo build of std. I'd appreciate input from someone more familiar with solaris -- cc @nbaksalyar?
2016-07-12Auto merge of #34756 - habnabit:mutex-refunwindsafe, r=alexcrichtonbors-0/+5
Mutex and RwLock need RefUnwindSafe too Incomplete, because I don't know what the appropriate stability annotation is here, but this is an attempt to bring the documentation for `std::panic` in line with reality. Right now, it says: >Types like `&Mutex<T>`, however, are unwind safe because they implement poisoning by default. But only `Mutex<T>`, not `&Mutex<T>`, is unwind-safe.
2016-07-12Auto merge of #34739 - therealbstern:ipv4unspec, r=alexcrichtonbors-0/+4
Mark Ipv4Addr is_unspecified as stable and provide reference. Per [#27709 (comment)](https://github.com/rust-lang/rust/issues/27709#issuecomment-231280999), no RFC is needed here. IPv4 "unspecified" has been defined in [Stevens], and has been part of the IPv4 stack for quite some time. This property should become stable, since this use of 0.0.0.0 is not going anywhere. [Stevens][_UNIX Network Programming Volume 1, Second Edition_. Stevens, W. Richard. Prentice-Hall, 1998. p. 891] Please let me know if I got the rustdoc wrong or something. I tried to be as terse as possible while still conveying the appropriate information. This also has a slight impact on PR #34694, but that one came first, so this shouldn't block it, IMO.
2016-07-12Add doc example for `std::process::ExitStatus::success`.Corey Farwell-0/+17
2016-07-12Auto merge of #34705 - alexcrichton:clean-deprecated, r=brsonbors-732/+234
std: Clean out deprecated APIs This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-07-12std: Clean out deprecated APIsAlex Crichton-732/+234
This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-07-12Auto merge of #34757 - sourcefrog:debug-filetype, r=alexcrichtonbors-3/+3
Derive Debug on FileType. Partially fixes #32054
2016-07-12Rollup merge of #34750 - GuillaumeGomez:error_doc, r=steveklabnikGuillaume Gomez-0/+70
Add examples for std::Error module Fixes #29352. r? @steveklabnik
2016-07-12Rollup merge of #34737 - frewsxcv:libstd-process-child, r=GuillaumeGomezGuillaume Gomez-11/+29
Various `std::process` doc improvements. None
2016-07-12Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`Tobias Bucher-17/+22
2016-07-12doc: Mention that writeln! and println! always use LFMike Hommey-1/+3
Fixes #34697
2016-07-11std: clear errno before readdir, then check it (solaris)Josh Stone-17/+32
A `NULL` from `readdir` could be the end of stream or an error. The only way to know is to check `errno`, so it must be set to a known value first, like a 0 that POSIX will never use. This patch adds `set_errno`, uses it to clear the value before calling `readdir`, then checks it again after to see the reason for a `NULL`.
2016-07-11std: Fix IPV6 imports for solarisJosh Stone-4/+8
Like BSDs, Solaris maps `IPV6_ADD_MEMBERSHIP` and `IPV6_DROP_MEMBERSHIP` from `IPV6_JOIN_GROUP` and `IPV6_LEAVE_GROUP` respectively.
2016-07-11std: Fix `Thread::set_name()` for newlib and solarisJosh Stone-1/+0
The `use ffi::CStr` in `unix/thread.rs` was previously guarded, but now all platforms need it for `Thread::set_name()`. Newlib and Solaris do nothing here, as they have no way to set a thread name, but they still define the same method signature.
2016-07-11Mark Ipv4Addr is_unspecified as stable and provide reference.Ben Stern-0/+4
2016-07-11Auto merge of #34686 - alexcrichton:new-stage, r=luqmanabors-15/+3
rustc: Update stage0 to beta-2016-07-06 Hot off the presses, let's update our stage0 compiler!
2016-07-11`std::process` doc improvements.Corey Farwell-11/+29
* Link to `process::Command` from `process::Child`. * Move out inline Markdown link in doc comment. * Link to `process::Child::wait` from `process::Child`. * Link to `process::Child` from `process::ChildStdin`. * Link to `process::Child` from `process::ChildStdout`. * Link to `process::Child` from `process::ChildStderr`.
2016-07-11Set unwind_safe_lock_refs stability to 1.12.0.Aaron Gallagher-3/+2
This is the first (and presumably only) use of this feature.
2016-07-10Derive Debug on FileType.Martin Pool-3/+3
Partially fixes #32054
2016-07-10Mutex and RwLock need RefUnwindSafe too.Aaron Gallagher-0/+6
2016-07-10Add examples for std::Error moduleGuillaume Gomez-0/+70
2016-07-10Demangle curly bracesSteven Fackler-1/+3
They show up in things like fn(&std..panic..PanicInfo<'_>) $u7b$hook$u7d$::fn_pointer_shim.8352::h01f889b2277c719d
2016-07-10Auto merge of #34731 - GGist:fix_sync_try_recv, r=alexcrichtonbors-1/+10
Check for data in Receiver::try_recv before reporting disconnect Fixes #34711 r? @alexcrichton
2016-07-09Auto merge of #34717 - frewsxcv:sink, r=apasel422bors-2/+2
Remove unnecessarily mutable reference in doc example. None
2016-07-09Auto merge of #34709 - GuillaumeGomez:primitives, r=steveklabnikbors-0/+30
Improve primitive integers documentation Fixes #29335. r? @steveklabnik
2016-07-08Check for data in Receiver::try_recv before reporting disconnectAndrew-1/+10