diff options
| author | Cheng Xu <git@xuc.me> | 2025-06-27 11:01:59 -0700 |
|---|---|---|
| committer | Cheng Xu <git@xuc.me> | 2025-06-27 11:12:32 -0700 |
| commit | cd1713ebba83a87e80a7366fdfe6fc28cabe6053 (patch) | |
| tree | 9c50e473e9b554891df50b0de9598067eacd6280 /library/alloc/src | |
| parent | 13c46fd0b089360922a557d8e18a63a2c41dfbeb (diff) | |
| download | rust-cd1713ebba83a87e80a7366fdfe6fc28cabe6053.tar.gz rust-cd1713ebba83a87e80a7366fdfe6fc28cabe6053.zip | |
BTreeSet: remove duplicated code by reusing `from_sorted_iter`
The method `BTreeSet::from_sorted_iter` was introduced in 49ccb7519f55bd117d2ab50b7a030637f380aec6, but it was not consistently used throughout the codebase. As a result, some code redundantly reimplemented its logic. This commit fixes the problem.
Diffstat (limited to 'library/alloc/src')
| -rw-r--r-- | library/alloc/src/collections/btree/set.rs | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/library/alloc/src/collections/btree/set.rs b/library/alloc/src/collections/btree/set.rs index aa9e5fce1d4..d50ce02bda7 100644 --- a/library/alloc/src/collections/btree/set.rs +++ b/library/alloc/src/collections/btree/set.rs @@ -1517,9 +1517,7 @@ impl<T: Ord, const N: usize> From<[T; N]> for BTreeSet<T> { // use stable sort to preserve the insertion order. arr.sort(); - let iter = IntoIterator::into_iter(arr).map(|k| (k, SetValZST::default())); - let map = BTreeMap::bulk_build_from_sorted_iter(iter, Global); - BTreeSet { map } + BTreeSet::from_sorted_iter(IntoIterator::into_iter(arr), Global) } } |
