Repository navigation
Conversation
These methods are of particular interest for users because they perform better due to specialization, e.g. when `elem` is zero. In that case, it will result in a call to `calloc` or equivalent, which is better than a call to `malloc` followed by `memset`. We also forward the existing `std::vec::from_elem` and `std::vec::from_elem_in` to these new associated methods on `Vec`. The module-level methods could potentially be removed in a follow-up.
| /// assert_eq!(vec, [0; 3]); | ||
| /// ``` | ||
| #[cfg(not(no_global_oom_handling))] | ||
| #[unstable(feature = "vec_from_elem", issue = "none")] |
There was a problem hiding this comment.
Is this part of an existing feature or should we create a new tracking issue for this? Also, should from_elem_in use the same feature or does it belong in allocator_ext?
There was a problem hiding this comment.
I would put both of these into their own from_elem issue since I have a feeling allocator_ext will get stabilised first. But yes, should have one.
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| #[doc(hidden)] | ||
| #[cfg(not(no_global_oom_handling))] | ||
| #[unstable(feature = "allocator_ext", issue = "163177", implied_by = "allocator_api")] | ||
| pub fn from_elem_in<T: Clone, A: Allocator>(elem: T, n: usize, alloc: A) -> Vec<T, A> { |
There was a problem hiding this comment.
I would just remove this since it's unstable and make the macro call the associated methods in both cases. The only reason the standalone from_elem shouldn't just be removed also is because it's currently marked as stable, and we want to see how #164053 goes.
|
r? ChrisDenton Offloading a few PRs, Chris should have enough context to handle this. |
These methods are of particular interest for users because they perform better due to specialization, e.g. when
elemis zero. In that case, it will result in a call tocallocor equivalent, which is better than a call tomallocfollowed bymemset.We also forward the existing
std::vec::from_elemandstd::vec::from_elem_into these new associated methods onVec. The module-level methods could potentially be removed in a follow-up.Zulip thread
r? @clarfonthey