-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking Issue for try_reserve method on more containers #91789
Comments
After a diff between https://doc.rust-lang.org/std/?search=reserve and https://doc.rust-lang.org/std/?search=try_reserve, I think the current list is complete. |
I'm interested in implement try_reserve and try_reserve_exact on PathBuf. |
@TennyZhuang Please help update the issue link into description: #92338 |
And the support of |
Add try_reserve and try_reserve_exact for OsString Add `try_reserve` and `try_reserve_exact` for OsString. Part of rust-lang#91789 I will squash the commits after PR is ready to merge. Signed-off-by: Xuanwo <github@xuanwo.io>
@TennyZhuang #92513 has been submitted for review. Let's go forward the stabilization! |
std: Implement try_reserve and try_reserve_exact on PathBuf Part of rust-lang#91789 Signed-off-by: Xuanwo <github@xuanwo.io>
Let's stabilize this feature! Steps are listed here: From https://rustc-dev-guide.rust-lang.org/stability.html#stabilizing-a-library-feature
|
@yaahc Hi, can you help start an FCP for feature |
Absolutely! @rfcbot merge |
Team member @yaahc has proposed to merge this. The next step is review by the rest of the tagged team members: Concerns:
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
It's worth being aware that the fn os_string_push_str(buf: &mut OsString, data: &str) -> Result<(), TryReserveError> {
buf.try_reserve(data.len())?;
buf.push(data);
Ok(())
} The units in which string length is measured, and the units in which OsString capacity is measured, are in general totally different units. Quoting from elsewhere in the OsString docs:
This is saying that the "storage size" of an OS string (which is the size that @rfcbot concern do we need better docs about what the argument value means (not bytes) |
I definitely agree that |
I agree that |
I will start PRs to address the concern that @dtolnay proposed.
|
We should probably just update that documentation. We already guarantee any |
Sorry for stalling this work for so long; I'll take care of all the concerns next week. |
#91789 (comment) sounds good to me. I would be prepared to accept (with libs-api FCP) a PR that updates all the places talking about OS string capacity to indicate that this means UTF-8 byte size for OS strings which were created from valid unicode, and not otherwise specified for other contents. |
Great, please take a look at #95392 |
@rfcbot resolve do we need better docs about what the argument value means (not bytes) |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
look like Don't know what would be the plan for |
IMHO, we need a proposal to discuss adding |
BTreeSet and LinkedList are pointer-based data structure, which means that they can't benefit from batch allocation. The reserve method on them is exactly same as just allocate one by one, but will make the code much more complicated (we have to introduce placeholder nodes for that). |
ah I get fouled by https://doc.rust-lang.org/src/core/iter/traits/collect.rs.html#379 these two collections probably need something like |
std: Stabilize feature try_reserve_2 This PR intends to stabilize feature `try_reserve_2`, closes rust-lang/rust#91789 This PR will also replace the previous PR: rust-lang/rust#95139
This is another tracking issue for the try_reserve part of the RFC "fallible collection allocation" (rust-lang/rfcs#2116).
The feature gate for the issue is
#![feature(try_reserve_2)]
.The feature is a follow-up to #48043. Since
try_reserve
was stabilized in 1.57.0, we may need a new feature gate for furthertry_reserve
implementation on more containers.About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
try_reserve
andtry_reserve_exact
onBinaryHeap
add BinaryHeap::try_reserve and BinaryHeap::try_reserve_exact #91529try_reserve
andtry_reserve_exact
onPathBuf
std: Implement try_reserve and try_reserve_exact on PathBuf #92513try_reserve
andtry_reserve_exact
onOsString
Add try_reserve and try_reserve_exact for OsString #92338If any containers were missing, please comment in the issue, and I will add it to the list.
Unresolved Questions
Implementation history
#91529
#92338
#92513
The text was updated successfully, but these errors were encountered: