about summary refs log tree commit diff
path: root/src/libstd/io/stdio.rs
AgeCommit message (Collapse)AuthorLines
2020-07-27mv std libs to library/mark-1064/+0
2020-07-14Rollup merge of #73759 - GuillaumeGomez:stdin-examples, r=Dylan-DPCManish Goregaokar-0/+31
Add missing Stdin and StdinLock examples r? @Dylan-DPC
2020-06-26Add missing Stdin and StdinLock exampelsGuillaume Gomez-0/+31
2020-06-17Restore some write_fmtsNathan West-0/+6
2020-06-17Removed write_fmt forwarding, to fix recursive borrow issuesNathan West-12/+0
2020-05-28Added io forwarding methods to the stdio structsNathan West-0/+83
2020-04-26Update nameSteven Fackler-22/+22
2020-04-26Add Read/Write::can_read/write_vectoredSteven Fackler-0/+56
When working with an arbitrary reader or writer, code that uses vectored operations may end up being slower than code that copies into a single buffer when the underlying reader or writer doesn't actually support vectored operations. These new methods allow you to ask the reader or witer up front if vectored operations are efficiently supported. Currently, you have to use some heuristics to guess by e.g. checking if the read or write only accessed the first buffer. Hyper is one concrete example of a library that has to do this dynamically: https://github.com/hyperium/hyper/blob/0eaf304644a396895a4ce1f0146e596640bb666a/src/proto/h1/io.rs#L582-L594
2020-03-31more clippy fixesMatthias Krüger-2/+2
use is_empty() instead of len comparison (clippy::len_zero) use if let instead of while let loop that never loops (clippy::never_loop) remove redundant returns (clippy::needless_return) remove redundant closures (clippy::redundant_closure) use if let instead of match and wildcard pattern (clippy::single_match) don't repeat field names redundantly (clippy::redundant_field_names)
2020-03-21Rollup merge of #69955 - alexcrichton:stderr-infallible, r=sfacklerDylan DPC-18/+31
Fix abort-on-eprintln during process shutdown This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations.
2020-03-20Fix abort-on-eprintln during process shutdownAlex Crichton-18/+31
This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations.
2020-03-18std: Don't abort process when printing panics in testsAlex Crichton-4/+8
This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes #69558
2020-02-23docs: Stdin::read_line: mention the appendingJakub Kądziołka-1/+1
2019-12-22Format the worldMark Rousskov-59/+78
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-4/+4
2019-10-20Fix parameter name in documentationAdrian Heine né Lang-1/+1
2019-09-11Fix inconsistent link formatting.Tomasz Różański-4/+4
2019-04-27Stabilized vectored IOSteven Fackler-12/+12
This renames `std::io::IoVec` to `std::io::IoSlice` and `std::io::IoVecMut` to `std::io::IoSliceMut`, and stabilizes `std::io::IoSlice`, `std::io::IoSliceMut`, `std::io::Read::read_vectored`, and `std::io::Write::write_vectored`. Closes #58452
2019-04-10std: Add `{read,write}_vectored` for more typesAlex Crichton-1/+50
This commit implements the `{read,write}_vectored` methods on more types in the standard library, namely: * `std::fs::File` * `std::process::ChildStd{in,out,err}` * `std::io::Std{in,out,err}` * `std::io::Std{in,out,err}Lock` * `std::io::Std{in,out,err}Raw` Where supported the OS implementations hook up to native support, otherwise it falls back to the already-defaulted implementation.
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-16/+16
2019-03-28Use write_all instead of write in example codeMatt Brubeck-6/+6
2019-03-08expand unused doc comment diagnosticAndy Russell-2/+2
Report the diagnostic on macro expansions, and add a label indicating why the comment is unused.
2019-02-28Use the correct stderr when testing libstdJethro Beekman-2/+14
2019-02-28libstd => 2018Taiki Endo-15/+15
2019-02-17Use more impl header lifetime elisionScott McMurray-7/+7
There are two big categories of changes in here - Removing lifetimes from common traits that can essentially never user a lifetime from an input (particularly `Drop` & `Debug`) - Forwarding impls that are only possible because the lifetime doesn't matter (like `impl<R: Read + ?Sized> Read for &mut R`) I omitted things that seemed like they could be more controversial, like the handful of iterators that have a `Item: 'static` despite the iterator having a lifetime or the `PartialEq` implementations where the flipped one cannot elide the lifetime.
2019-02-03Improve error message and docs for non-UTF-8 bytes in stdio on WindowsAustin Bonander-0/+45
cc #23344
2018-12-25Remove licensesMark Rousskov-10/+0
2018-12-07Various minor/cosmetic improvements to codeAlexander Regueiro-2/+2
2018-08-31Implement the `min_const_fn` feature gateOliver Schneider-8/+12
2018-08-06make Lazy::new unsafe and check reentrancy condition in the callersRalf Jung-3/+7
2018-07-10Deny bare trait objects in `src/libstd`.ljedrz-4/+4
2018-07-02Make Stdio handle UnwindSafeEvan Simmons-0/+22
2018-03-28Remove hidden `foo` functions from doc examples; use `Termination` trait.Corey Farwell-53/+53
Fixes https://github.com/rust-lang/rust/issues/49233.
2018-03-01Fix a bug introduced in previous commitStjepan Glavina-2/+2
2018-02-28Remove thread_local_stateStjepan Glavina-20/+19
2018-02-28Stabilize LocalKey::try_withStjepan Glavina-1/+4
2017-11-08std: Change how EBADF is handled in `sys`Alex Crichton-3/+1
This commit removes the reexport of `EBADF_ERR` as a constant from libstd's portability facade, instead opting for a platform-specific function that specifically queries an `io::Error`. Not all platforms may have a constant for this, so it makes the intent a little more clear that a code need not be supplied, just an answer to a query.
2017-06-20Add `Read::initializer`.Steven Fackler-11/+12
This is an API that allows types to indicate that they can be passed buffers of uninitialized memory which can improve performance.
2017-05-10Fix up stability annotations per feedback.Zack Weinberg-2/+2
2017-05-10Revise the eprint(ln)! feature.Zack Weinberg-50/+29
* Factor out the nigh-identical bodies of `_print` and `_eprint` to a helper function `print_to` (I was sorely tempted to call it `_doprnt`). * Update the issue number for the unstable `eprint` feature. * Add entries to the "unstable book" for `eprint` and `eprint_internal`. * Style corrections to the documentation.
2017-05-10Add `eprint!` and `eprintln!` macros to the prelude.Zack Weinberg-0/+36
These are exactly the same as `print!` and `println!` except that they write to stderr instead of stdout. Issue #39228.
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-2/+2
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-01-29Fix a few impl stability attributesOliver Middleton-6/+6
The versions show up in rustdoc.
2017-01-22libstd: replace all `try!` with `?` in documentation examplesUtkarsh Kukreti-9/+9
See #38644.
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-0/+42
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-16Address falloutAaron Turon-3/+3
2016-11-28Move stdout/err flush into sysJeremy Soller-6/+0
2016-11-10Merge branch 'master' into redoxJeremy Soller-1/+2
2016-11-10Fixes for stdio and processes on RedoxJeremy Soller-0/+6
2016-11-05add missing urls on io structsGuillaume Gomez-1/+2