about summary refs log tree commit diff
path: root/library/std/src/io/cursor.rs
AgeCommit message (Collapse)AuthorLines
2025-02-27Override default Write methods for cursor-like typesThalia Archibald-13/+87
2025-02-18update version placeholdersJosh Stone-2/+2
(cherry picked from commit e4840ce59bdddb19394df008c5c26d9c493725f8)
2025-02-06Stabilise 'Cursor::{get_mut, set_position}' in 'const' scenarios;Gabriel Bjørnager Jensen-2/+2
2024-11-26std: update internal uses of `io::const_error!`joboet-2/+2
2024-09-24Mark 'get_mut' and 'set_position' in 'std::io::Cursor' as const;Gabriel Bjørnager Jensen-2/+4
2024-07-29Rollup merge of #109174 - soerenmeier:cursor_fns, r=dtolnayMatthias Krüger-30/+35
Replace `io::Cursor::{remaining_slice, is_empty}` This is a late follow up to the concerns raised in https://github.com/rust-lang/rust/issues/86369. https://github.com/rust-lang/rust/issues/86369#issuecomment-953096691 > This API seems focussed on the `Read` side of things. When `Seek`ing around and `Write`ing data, `is_empty` becomes confusing and `remaining_slice` is not very useful. When writing, the part of the slice before the cursor is much more interesting. Maybe we should have functions for both? Or a single function that returns both slices? (If we also have a `mut` version, a single function would be useful to allow mutable access to both sides at once.) New feature name: `cursor_remaining` > `cursor_split`. Added functions: ```rust fn split(&self) -> (&[u8], &[u8]); // fn before(&self) -> &[u8]; // fn after(&self) -> &[u8]; fn split_mut(&mut self) -> (&mut [u8], &mut [u8]); // fn before_mut(&mut self) -> &mut [u8]; // fn after_mut(&mut self) -> &mut [u8]; ``` A question was raised in https://github.com/rust-lang/rust/issues/86369#issuecomment-927124211 about whether to return a lifetime that would reflect the lifetime of the underlying bytes (`impl Cursor<&'a [u8]> { fn after(&self) -> &'a [u8] }`). The downside of doing this would be that it would not be possible to implement these functions generically over `T: AsRef<[u8]>`. ## Update Based on the review, before* and after* methods where removed.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-2/+1
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Replace `io::Cursor::{remaining_slice, is_empty}` with `io::Cursor::{split, ↵Sören Meier-30/+35
split_mut}`
2024-07-14std: Unsafe-wrap std::ioJubilee Young-1/+1
2024-05-20Address review commentsBenoît du Garreau-1/+1
2024-05-14Fix `read_exact` and `read_buf_exact` for `&[u8]` and `io:Cursor`Benoît du Garreau-10/+17
2024-05-04Rollup merge of #122441 - a1phyr:improve_read_impls, r=ChrisDentonMatthias Krüger-0/+21
Improve several `Read` implementations - `read_to_end` and `read_to_string` for `Cursor` - Error on OOM in `read_to_string` of `&[u8]` and `VecDeque<u8>` - Avoid making the slices contiguous in `VecDeque::read_to_string` - ~`read_exact` and (unstable) `read_buf_exact` for `Take`~ - ~`read_buf` for `UnixStream` and `&UnixStream`~ (moved to #123084) - `read_to_end` for `ChildStdErr`
2024-05-01Replace version placeholders for 1.79Mark Rousskov-3/+3
2024-04-17Stabilize `const_io_structs`Slanterns-3/+3
2024-04-12Improve several `Read` implementationsBenoît du Garreau-0/+21
2024-04-10Auto merge of #122393 - a1phyr:specialize_read_buf_exact, r=joboetbors-0/+7
Specialize many implementations of `Read::read_buf_exact` This makes all implementations of `Read` that have a specialized `read_exact` implementation also have one for `read_buf_exact`.
2024-03-14Fix minor documentation issue. Code outside the test would fail. Seek ↵baitcode-0/+2
documentation clearly states that negative indexes will cause error. Just making the code in the example to return Result::Ok, instead of Result::Error.
2024-03-12Specialize many implementations of `Read::read_buf_exact`Benoît du Garreau-0/+7
2023-03-27Rollup merge of #98651 - mattfbacon:master, r=ChrisDentonMatthias Krüger-1/+1
Follow C-RW-VALUE in std::io::Cursor example rustc-dev-guide says to do this: r? ``@steveklabnik``
2022-08-18Address reviewer commentsNick Cameron-2/+2
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-05non-linux platformsNick Cameron-2/+2
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-08-04std::io: migrate ReadBuf to BorrowBuf/BorrowCursorNick Cameron-5/+5
Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-06-28Follow C-RW-VALUE in std::io::Cursor exampleMatt Fellenz-1/+1
2022-06-26attempt to optimise vectored writeConrad Ludgate-25/+101
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-2/+0
2022-03-19Rollup merge of #92663 - cuviper:generic-write-cursor, r=dtolnayDylan DPC-7/+46
Implement `Write for Cursor<[u8; N]>`, plus `A: Allocator` cursor support This implements `Write for Cursor<[u8; N]>`, and also adds support for generic `A: Allocator` in `Box` and `Vec` cursors. This was inspired by a user questioning why they couldn't write a `Cursor<[u8; N]>`: https://users.rust-lang.org/t/why-vec-and-not-u8-makes-cursor-have-write/68210 Related history: - #27197 switched `AsRef<[u8]>` for reading and seeking - #67415 tried to use `AsMut<[u8]>` for writing, but did not specialize `Vec`.
2022-03-18Bump impl Write for Cursor<[u8; N]> to 1.61David Tolnay-1/+1
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-5/+5
2022-01-19Write for Cursor with a custom AllocatorJosh Stone-7/+23
2022-01-19impl Write for Cursor<[u8; N]>Josh Stone-0/+23
2021-11-02read_bufDrMeepster-6/+11
2021-10-01Add functions to add unsigned and signed integersBenoît du Garreau-6/+1
2021-09-25Apply 16 commits (squashed)Frank Steffahn-4/+4
---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::fmt ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::{rc, sync} ---------- Fix spacing for links inside code blocks, and improve link tooltips in alloc::string ---------- Fix spacing for links inside code blocks in alloc::vec ---------- Fix spacing for links inside code blocks in core::option ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in core::result ---------- Fix spacing for links inside code blocks in core::{iter::{self, iterator}, stream::stream, poll} ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{fs, path} ---------- Fix spacing for links inside code blocks in std::{collections, time} ---------- Fix spacing for links inside code blocks in and make formatting of `&str`-like types consistent in std::ffi::{c_str, os_str} ---------- Fix spacing for links inside code blocks, and improve link tooltips in std::ffi ---------- Fix spacing for links inside code blocks, and improve a few link tooltips in std::{io::{self, buffered::{bufreader, bufwriter}, cursor, util}, net::{self, addr}} ---------- Fix typo in link to `into` for `OsString` docs ---------- Remove tooltips that will probably become redundant in the future ---------- Apply suggestions from code review Replacing `…std/primitive.reference.html` paths with just `reference` Co-authored-by: Joshua Nelson <github@jyn.dev> ---------- Also replace `…std/primitive.reference.html` paths with just `reference` in `core::pin`
2021-07-02Remove unstable `Cursor::remaining`Sören Meier-26/+0
2021-06-17rename `remaining` to `remaining_slice` and add a new `remaining`Sören Meier-8/+34
2021-06-16Update tracking issueSören Meier-2/+2
2021-06-05Implement `Cursor::{remaining, is_empty}`Sören Meier-4/+59
2021-05-11Override `clone_from` for some typesBenoît du Garreau-1/+18
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-4/+4
2020-11-06Add tracking issueBenoît du Garreau-3/+3
2020-11-06Make some std::io functions `const`Benoît du Garreau-3/+6
Includes: - io::Cursor::new - io::Cursor::get_ref - io::Cursor::position - io::empty - io::repeat - io::sink
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-528/+3
Also doing fmt inplace as requested.
2020-08-18Move to intra doc links for std::ioAlexis Bourget-9/+5
2020-07-27mv std libs to library/mark-0/+981