A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rust-lang/rust/issues/91913 below:

Consider adding `Vec::try_with_capacity(_in)` and friends · Issue #91913 · rust-lang/rust · GitHub

With try_reserve(_exact) stabilized, the following pattern is going to start cropping up (it already does in our internal code base):

let mut buf = Vec::new();
buf.try_reserve_exact(cap)?;

Would adding one or two extra methods per container; try_with_capacity(capacity: usize) -> Result<.., TryReserveError> and try_with_capacity_in(capacity: usize, alloc: A) -> Result<.., TryReserveError> be appropriate ?

Note that the two-liner above works perfectly to the best of my knowledge, it is just a question of conciseness. I also find it makes intent clearer from the start, but other may have diverging opinions on this.

Affected types would be:

@rustbot label T-libs C-feature-request T-libs-api

Aside: I'm not sure if this falls under A-allocators

paolobarbolini, Patrick-Poitras, bobbbay, Xuanwo, kornelski and 2 more


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4