-
Notifications
You must be signed in to change notification settings - Fork 19
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
Box/Vec/slice convenience NonNull methods #418
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Comments
theemathas
added
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
labels
Jul 27, 2024
We discussed this in today's @rust-lang/libs-api meeting. We'd like to add most of these, with some tweaks:
We're accepting that subset of the ACP, and we'd ask you to open a new ACP for the remaining methods with guidance from T-opsem. |
joshtriplett
added
the
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
label
Sep 3, 2024
This was referenced Sep 7, 2024
3 tasks
Zalathar
added a commit
to Zalathar/rust
that referenced
this issue
Sep 15, 2024
…kSimulacrum,workingjubilee Add `NonNull` convenience methods to `Box` and `Vec` Implements the ACP: rust-lang/libs-team#418. The docs for the added methods are mostly copied from the existing methods that use raw pointers instead of `NonNull`. I'm new to this "contributing to rustc" thing, so I'm sorry if I did something wrong. In particular, I don't know what the process is for creating a new unstable feature. Please advise me if I should do something. Thank you.
Zalathar
added a commit
to Zalathar/rust
that referenced
this issue
Sep 15, 2024
…kSimulacrum,workingjubilee Add `NonNull` convenience methods to `Box` and `Vec` Implements the ACP: rust-lang/libs-team#418. The docs for the added methods are mostly copied from the existing methods that use raw pointers instead of `NonNull`. I'm new to this "contributing to rustc" thing, so I'm sorry if I did something wrong. In particular, I don't know what the process is for creating a new unstable feature. Please advise me if I should do something. Thank you.
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this issue
Sep 15, 2024
Rollup merge of rust-lang#130061 - theemathas:box_vec_non_null, r=MarkSimulacrum,workingjubilee Add `NonNull` convenience methods to `Box` and `Vec` Implements the ACP: rust-lang/libs-team#418. The docs for the added methods are mostly copied from the existing methods that use raw pointers instead of `NonNull`. I'm new to this "contributing to rustc" thing, so I'm sorry if I did something wrong. In particular, I don't know what the process is for creating a new unstable feature. Please advise me if I should do something. Thank you.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ACP-accepted
API Change Proposal is accepted (seconded with no objections)
api-change-proposal
A proposal to add or alter unstable APIs in the standard libraries
T-libs-api
Proposal
Problem statement
NonNull
is the correct type for implementing unsafe data structures. However, using them requires extra conversions fromBox
andVec
, meaning that the path of least resistance is using*mut
/*const
raw pointers. Thus, with similar motivation to the ACP forNonNull
convenience methods, I'm proposing some convenience methods onBox
andVec
.Motivating examples or use cases
The linked list book has an example of how someone might want to allocate some memory with
Box
, convert it intoNonNull
for storage, and later convert it back toBox
for deallocation.Solution sketch
I would like to proposing the following API additions:
Alternatives
The status quo: users need to do an extra layer of conversion to/from
NonNull
.Vec::as_non_null
might take&self
instead of&mut self
.We might also want convenience methods for slices.
Links and related work
There are already some methods on
NonNull<[T]>
.What happens now?
This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.
Possible responses
The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: