Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tokio_util::io::read_exact_arc to safely read a new uninitialized Arc #7165

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

joshtriplett
Copy link
Contributor

This encapsulates a common bit of unsafety.


Motivation

Inspired by having an otherwise completely safe crate in which this was the
only bit of unsafe code. Reading into an uninitialized Arc and then
initializing it requires the unsafe assume_init.

#7127

@joshtriplett
Copy link
Contributor Author

joshtriplett commented Feb 17, 2025

This will, presumably, need to wait for tokio's MSRV. :(

I've rewritten this to no longer require rust 1.82.

@maminrayej maminrayej added the A-tokio-util Area: The tokio-util crate label Feb 18, 2025
@Darksonn Darksonn added the M-io Module: tokio/io label Feb 18, 2025
@joshtriplett joshtriplett force-pushed the read-exact-arc branch 2 times, most recently from b37f27e to c0eb519 Compare February 25, 2025 15:39
…ed `Arc`

This encapsulates a common bit of unsafety.

This uses some workarounds to avoid requiring MSRV 1.82; once tokio uses
MSRV 1.82 it can use simpler functions provided by the standard library.
@joshtriplett
Copy link
Contributor Author

Passes CI. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio-util Area: The tokio-util crate M-io Module: tokio/io
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants