Stabilize try_reserve by kornelski · Pull Request #87993 · rust-lang/rust (original) (raw)

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

kornelski

TimDiekmann, quininer, Friz64, kellerkindt, paolobarbolini, Wodann, GrayJack, and Kerollmops reacted with thumbs up emoji avl, GrayJack, jdahlstrom, Kerollmops, Razican, and kellerkindt reacted with hooray emoji c410-f3r and GrayJack reacted with eyes emoji

@rust-highfive

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@jonas-schievink jonas-schievink added relnotes

Marks issues that should be documented in the release notes of the next release.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Aug 12, 2021

@rust-log-analyzer

This comment has been minimized.

@TimDiekmann

cc @rust-lang/wg-allocators

@the8472 the8472 added T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.

and removed T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Aug 13, 2021

@bors

@Mark-Simulacrum

r? @joshtriplett perhaps, not sure what current T-libs FCP practice is. I don't think I see a completed one though.

@joshtriplett

FCP for stabilization:
@rfcbot merge

@rfcbot

@dtolnay

@joshtriplett

@dtolnay Thanks for catching that. I don't think we need that From instance.

m-ou-se

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request

Aug 26, 2021

@Dylan-DPC

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request

Aug 26, 2021

@GuillaumeGomez

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request

Aug 26, 2021

@Dylan-DPC

@dtolnay

@rfcbot

🔔 This is now entering its final comment period, as per the review above. 🔔

Manishearth added a commit to Manishearth/rust that referenced this pull request

Aug 26, 2021

@Manishearth

@bors

📌 Commit 00152d8 has been approved by joshtriplett

@bors

🌲 The tree is currently closed for pull requests below priority 4. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Oct 4, 2021

Manishearth added a commit to Manishearth/rust that referenced this pull request

Oct 5, 2021

@Manishearth

Manishearth added a commit to Manishearth/rust that referenced this pull request

Oct 5, 2021

@Manishearth

Manishearth added a commit to Manishearth/rust that referenced this pull request

Oct 5, 2021

@Manishearth

bors added a commit to rust-lang-ci/rust that referenced this pull request

Oct 5, 2021

@bors

@ojeda ojeda mentioned this pull request

Oct 16, 2021

95 tasks

@cmazakas

Why wasn't the actual error kind stabilized? There's no point to this feature without the ability to introspect.

@kornelski

@LeonineKing1199 You can see in the original RFC discussion that it wasn't certain if the error should be stabilized exactly as it is implemented currently, with separate cases that just mirror an inconsistency in std (where some allocation failures panic, and some abort). Waiting for resolution of that question was delaying stabilization of the entire feature.

I'm interested to hear what is your use-case and what data you'd like to get out of the error type, to help guide how the error type should be designed.

@cmazakas

Ha ha, looks like my case was already addressed:

One I can think of is someone creating a custom data structure, and wanting to mimic std API. But that's not a very strong case.

It is for implementing the stdlib APIs without polluting it with polyfills that are incompatible with what's in the stdlib.

@kornelski

Great. So you're not looking to get any data out of it yourself, you just want to return a TryReserveError instance? If there was TryReserveError::default() or just a very basic TryReserveError::new(allocation_size), would that work for you?

For now a hacky way to get some instance is Vec::<u8>::new().try_reserve(usize::MAX).unwrap_err(). That's guaranteed to always fail fast.

@Stargateur

Why wasn't the actual error kind stabilized? There's no point to this feature without the ability to introspect.

In my opinion, the error is more for the end user, or very special case for something like kernel linux. For a server I will log the error and continue anyway so don't really care, even if I would consider a CapacityOverflow a code bug in a server or at least get a look at it.

@kornelski Do you think we could have const value TryReserveError::CAPACITY_OVERFLOW ? Unless if we want to be able to precise the maximum value at runtine and possibly the value used I don't expect this to change a lot.

@cmazakas

Great. So you're not looking to get any data out of it yourself, you just want to return a TryReserveError instance? If there was TryReserveError::default() or just a very basic TryReserveError::new(allocation_size), would that work for you?

Actually, this would work perfectly!

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Dec 14, 2021

@matthiaskrgr

…, r=yaahc

add BinaryHeap::try_reserve and BinaryHeap::try_reserve_exact

try_reserve of many collections were stablized in rust-lang#87993 in 1.57.0. Add try_reserve for the rest collections such as BinaryHeap should be not controversial.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request

Dec 14, 2021

@matthiaskrgr

…, r=yaahc

add BinaryHeap::try_reserve and BinaryHeap::try_reserve_exact

try_reserve of many collections were stablized in rust-lang#87993 in 1.57.0. Add try_reserve for the rest collections such as BinaryHeap should be not controversial.

Labels

disposition-merge

This issue / PR is in PFCP or FCP with a disposition to merge it.

finished-final-comment-period

The final comment period is finished for this PR / Issue.

relnotes

Marks issues that should be documented in the release notes of the next release.

S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

T-libs-api

Relevant to the library API team, which will review and decide on the PR/issue.