Skip to content

Add deprecations and new methods to prep for IO rewrite#216

Merged
cpubot merged 1 commit intomasterfrom
io-rewrite-prep
Mar 6, 2026
Merged

Add deprecations and new methods to prep for IO rewrite#216
cpubot merged 1 commit intomasterfrom
io-rewrite-prep

Conversation

@cpubot
Copy link
Copy Markdown
Contributor

@cpubot cpubot commented Mar 5, 2026

In prep for #213, this PR deprecates methods that will be removed in next breaking release (0.5), and adds new methods that will be included in #213 to make migration possible before switching to 0.5.

Deprecated methods

  • fill_buf: use copy_into_slice if you ultimately intend to copy the slice, or take_scoped for a call-scoped borrow. Be advised that take_scoped may not be implemented for all readers.
  • fill_exact: use copy_into_slice if you ultimately intend to copy the slice, or take_scoped for a call-scoped borrow. Be advised that take_scoped may not be implemented for all readers.
  • fill_array: use take_array.
  • copy_into_array: use take_array or copy_into_slice.
  • borrow_exact: use take_borrowed.
  • borrow_exact_mut: use take_borrowed_mut.
  • consume_unchecked - use one of the take_* methods, which automatically advance the reader.
  • consume - use one of the take_* methods, which automatically advance the reader.
  • peek - use take_byte.

New methods

  • take_byte: Return the next byte and advance by 1.
  • take_borrowed: Replaces borrow_exact.
  • take_borrowed_mut: Replaces borrow_exact_mut.
  • take_scoped: Return a call-site scoped immutable slice. The returned slice is tied to the borrow of self, meaning it is only valid while the current borrow of the reader is alive. Implementations are free to return slices backed by internal buffers or transient windows into the underlying source. This method is intended to be optional like take_borrowed and take_borrowed_mut, and return an error by default.

@cpubot cpubot requested a review from kskalski March 5, 2026 20:51
@cpubot cpubot force-pushed the io-rewrite-prep branch from c770886 to 3fb8dd0 Compare March 5, 2026 20:57
Copy link
Copy Markdown
Contributor

@kskalski kskalski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, I would just use the opportunity to improve the comments for borrow functions slightly

Comment thread wincode/src/io/mod.rs Outdated
Comment thread wincode/src/io/mod.rs Outdated
@cpubot cpubot force-pushed the io-rewrite-prep branch from 3fb8dd0 to 29a0027 Compare March 6, 2026 00:03
@cpubot cpubot merged commit 1c4d96c into master Mar 6, 2026
4 checks passed
@cpubot cpubot deleted the io-rewrite-prep branch March 6, 2026 02:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants